afghan-datepicker 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,3120 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AFGHAN_SUPPORTED_YEAR_RANGE: () => AFGHAN_SUPPORTED_YEAR_RANGE,
24
+ Calendar: () => Calendar,
25
+ DatePicker: () => DatePicker,
26
+ DateRangePicker: () => DateRangePicker,
27
+ GREGORIAN_SUPPORTED_YEAR_RANGE: () => GREGORIAN_SUPPORTED_YEAR_RANGE,
28
+ IRANIAN_SUPPORTED_YEAR_RANGE: () => IRANIAN_SUPPORTED_YEAR_RANGE,
29
+ addDays: () => addDays,
30
+ addMonths: () => addMonths,
31
+ addWeeks: () => addWeeks,
32
+ addYears: () => addYears,
33
+ afghanCalendarAdapter: () => afghanCalendarAdapter,
34
+ afghanToJdn: () => afghanToJdn,
35
+ compareDates: () => compareDates,
36
+ convertDate: () => convertDate,
37
+ differenceInDays: () => differenceInDays,
38
+ differenceInMonths: () => differenceInMonths,
39
+ differenceInWeeks: () => differenceInWeeks,
40
+ differenceInYears: () => differenceInYears,
41
+ formatCalendarDate: () => formatCalendarDate,
42
+ fromLocalizedDigits: () => fromLocalizedDigits,
43
+ getAfghanMonthLength: () => getAfghanMonthLength,
44
+ getAvailableLocales: () => getAvailableLocales,
45
+ getDayOfWeek: () => getDayOfWeek,
46
+ getDaysInMonth: () => getDaysInMonth,
47
+ getDaysInYear: () => getDaysInYear,
48
+ getEndOfDay: () => getEndOfDay,
49
+ getEndOfMonth: () => getEndOfMonth,
50
+ getEndOfWeek: () => getEndOfWeek,
51
+ getEndOfYear: () => getEndOfYear,
52
+ getGregorianMonthLength: () => getGregorianMonthLength,
53
+ getIranianMonthLength: () => getIranianMonthLength,
54
+ getLocale: () => getLocale,
55
+ getLocaleDirection: () => getLocaleDirection,
56
+ getMonthsInYear: () => getMonthsInYear,
57
+ getOrderedWeekdays: () => getOrderedWeekdays,
58
+ getStartOfDay: () => getStartOfDay,
59
+ getStartOfMonth: () => getStartOfMonth,
60
+ getStartOfWeek: () => getStartOfWeek,
61
+ getStartOfYear: () => getStartOfYear,
62
+ getWeekday: () => getWeekday,
63
+ gregorianCalendarAdapter: () => gregorianCalendarAdapter,
64
+ gregorianToJdn: () => gregorianToJdn,
65
+ iranianCalendarAdapter: () => iranianCalendarAdapter,
66
+ iranianToJdn: () => iranianToJdn,
67
+ isAfghanLeapYear: () => isAfghanLeapYear,
68
+ isAfter: () => isAfter,
69
+ isBefore: () => isBefore,
70
+ isGregorianLeapYear: () => isGregorianLeapYear,
71
+ isIranianLeapYear: () => isIranianLeapYear,
72
+ isLeapYear: () => isLeapYear,
73
+ isSameDay: () => isSameDay,
74
+ isSameMonth: () => isSameMonth,
75
+ isSameYear: () => isSameYear,
76
+ isValidAfghanDate: () => isValidAfghanDate,
77
+ isValidGregorianDate: () => isValidGregorianDate,
78
+ isValidIranianDate: () => isValidIranianDate,
79
+ jdnToAfghan: () => jdnToAfghan,
80
+ jdnToGregorian: () => jdnToGregorian,
81
+ jdnToIranian: () => jdnToIranian,
82
+ registerLocale: () => registerLocale,
83
+ subtractDays: () => subtractDays,
84
+ subtractMonths: () => subtractMonths,
85
+ subtractWeeks: () => subtractWeeks,
86
+ subtractYears: () => subtractYears,
87
+ toLocalizedDigits: () => toLocalizedDigits
88
+ });
89
+ module.exports = __toCommonJS(index_exports);
90
+
91
+ // src/core/conversion/julian-day.ts
92
+ function assertJdn(jdn) {
93
+ if (!Number.isSafeInteger(jdn)) {
94
+ throw new RangeError("Julian Day Number must be a safe integer.");
95
+ }
96
+ }
97
+ function getWeekday(jdn) {
98
+ assertJdn(jdn);
99
+ const zeroBased = (jdn % 7 + 7) % 7;
100
+ return zeroBased + 1;
101
+ }
102
+
103
+ // src/core/validation/date.ts
104
+ function hasIntegerDateFields(value) {
105
+ if (typeof value !== "object" || value === null) {
106
+ return false;
107
+ }
108
+ const candidate = value;
109
+ return Number.isSafeInteger(candidate.year) && Number.isSafeInteger(candidate.month) && Number.isSafeInteger(candidate.day);
110
+ }
111
+
112
+ // src/core/calendars/gregorian/leap-year.ts
113
+ var GREGORIAN_SUPPORTED_YEAR_RANGE = {
114
+ min: 1,
115
+ max: 9999
116
+ };
117
+ function assertGregorianYear(year) {
118
+ const { min, max } = GREGORIAN_SUPPORTED_YEAR_RANGE;
119
+ if (!Number.isSafeInteger(year) || year < min || year > max) {
120
+ throw new RangeError(
121
+ `Gregorian year must be an integer from ${min} to ${max}; received ${year}.`
122
+ );
123
+ }
124
+ }
125
+ function isGregorianLeapYear(year) {
126
+ assertGregorianYear(year);
127
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
128
+ }
129
+ function countGregorianLeapYearsBefore(year) {
130
+ if (!Number.isSafeInteger(year) || year < 1 || year > 1e4) {
131
+ throw new RangeError(
132
+ `Gregorian exclusive year must be an integer from 1 to 10000; received ${year}.`
133
+ );
134
+ }
135
+ const lastYear = year - 1;
136
+ return Math.floor(lastYear / 4) - Math.floor(lastYear / 100) + Math.floor(lastYear / 400);
137
+ }
138
+
139
+ // src/core/calendars/afghan/leap-year.ts
140
+ var AFGHAN_SUPPORTED_YEAR_RANGE = {
141
+ min: 1,
142
+ max: 9377
143
+ };
144
+ function assertAfghanYear(year) {
145
+ const { min, max } = AFGHAN_SUPPORTED_YEAR_RANGE;
146
+ if (!Number.isSafeInteger(year) || year < min || year > max) {
147
+ throw new RangeError(
148
+ `Afghan year must be an integer from ${min} to ${max}; received ${year}.`
149
+ );
150
+ }
151
+ }
152
+ function isAfghanLeapYear(year) {
153
+ assertAfghanYear(year);
154
+ return isGregorianLeapYear(year + 621);
155
+ }
156
+ function countAfghanLeapYearsBefore(year) {
157
+ if (!Number.isSafeInteger(year) || year < AFGHAN_SUPPORTED_YEAR_RANGE.min || year > AFGHAN_SUPPORTED_YEAR_RANGE.max + 1) {
158
+ throw new RangeError(
159
+ `Afghan exclusive year must be an integer from ${AFGHAN_SUPPORTED_YEAR_RANGE.min} to ${AFGHAN_SUPPORTED_YEAR_RANGE.max + 1}; received ${year}.`
160
+ );
161
+ }
162
+ return countGregorianLeapYearsBefore(year + 621) - countGregorianLeapYearsBefore(622);
163
+ }
164
+
165
+ // src/core/calendars/afghan/month-length.ts
166
+ function getAfghanMonthLength(year, month) {
167
+ if (!Number.isSafeInteger(month) || month < 1 || month > 12) {
168
+ throw new RangeError(
169
+ `Afghan month must be an integer from 1 to 12; received ${month}.`
170
+ );
171
+ }
172
+ assertAfghanYear(year);
173
+ if (month <= 6) {
174
+ return 31;
175
+ }
176
+ if (month <= 11) {
177
+ return 30;
178
+ }
179
+ return isAfghanLeapYear(year) ? 30 : 29;
180
+ }
181
+
182
+ // src/core/calendars/afghan/conversion.ts
183
+ var REFERENCE_YEAR = 1382;
184
+ var REFERENCE_JDN = 2452720;
185
+ function assertAfghanYear2(year) {
186
+ const { min, max } = AFGHAN_SUPPORTED_YEAR_RANGE;
187
+ if (!Number.isSafeInteger(year) || year < min || year > max) {
188
+ throw new RangeError(
189
+ `Afghan year must be an integer from ${min} to ${max}; received ${year}.`
190
+ );
191
+ }
192
+ }
193
+ function afghanYearStartJdn(year) {
194
+ assertAfghanYear2(year);
195
+ const yearsFromReference = year - REFERENCE_YEAR;
196
+ const leapYearsFromReference = countAfghanLeapYearsBefore(year) - countAfghanLeapYearsBefore(REFERENCE_YEAR);
197
+ return REFERENCE_JDN + yearsFromReference * 365 + leapYearsFromReference;
198
+ }
199
+ function daysBeforeAfghanMonth(month) {
200
+ return month <= 6 ? (month - 1) * 31 : 186 + (month - 7) * 30;
201
+ }
202
+ function isValidAfghanDate(value) {
203
+ if (!hasIntegerDateFields(value)) {
204
+ return false;
205
+ }
206
+ const { year, month, day } = value;
207
+ if (year < AFGHAN_SUPPORTED_YEAR_RANGE.min || year > AFGHAN_SUPPORTED_YEAR_RANGE.max || month < 1 || month > 12 || day < 1) {
208
+ return false;
209
+ }
210
+ return day <= getAfghanMonthLength(year, month);
211
+ }
212
+ function afghanToJdn(date) {
213
+ if (!isValidAfghanDate(date)) {
214
+ throw new RangeError(
215
+ `Invalid Afghan date; expected a valid date in years ${AFGHAN_SUPPORTED_YEAR_RANGE.min} through ${AFGHAN_SUPPORTED_YEAR_RANGE.max}.`
216
+ );
217
+ }
218
+ return afghanYearStartJdn(date.year) + daysBeforeAfghanMonth(date.month) + date.day - 1;
219
+ }
220
+ function jdnToAfghan(jdn) {
221
+ assertJdn(jdn);
222
+ let low = AFGHAN_SUPPORTED_YEAR_RANGE.min;
223
+ let high = AFGHAN_SUPPORTED_YEAR_RANGE.max;
224
+ let year = -1;
225
+ while (low <= high) {
226
+ const candidate = Math.floor((low + high) / 2);
227
+ const yearStart = afghanYearStartJdn(candidate);
228
+ const nextYearStart = yearStart + 365 + (isAfghanLeapYear(candidate) ? 1 : 0);
229
+ if (jdn < yearStart) {
230
+ high = candidate - 1;
231
+ } else if (jdn >= nextYearStart) {
232
+ low = candidate + 1;
233
+ } else {
234
+ year = candidate;
235
+ break;
236
+ }
237
+ }
238
+ if (year === -1) {
239
+ throw new RangeError(
240
+ "Julian Day Number is outside the supported Afghan date range."
241
+ );
242
+ }
243
+ const dayOfYear = jdn - afghanYearStartJdn(year);
244
+ const month = dayOfYear < 186 ? Math.floor(dayOfYear / 31) + 1 : Math.floor((dayOfYear - 186) / 30) + 7;
245
+ const day = dayOfYear - daysBeforeAfghanMonth(month) + 1;
246
+ return { year, month, day };
247
+ }
248
+
249
+ // src/core/calendars/afghan/index.ts
250
+ var afghanCalendarAdapter = {
251
+ calendar: "afghan",
252
+ supportedYearRange: AFGHAN_SUPPORTED_YEAR_RANGE,
253
+ isLeapYear: isAfghanLeapYear,
254
+ getMonthLength: getAfghanMonthLength,
255
+ isValidDate: isValidAfghanDate,
256
+ toJdn: afghanToJdn,
257
+ fromJdn: jdnToAfghan
258
+ };
259
+
260
+ // src/core/calendars/gregorian/month-length.ts
261
+ function getGregorianMonthLength(year, month) {
262
+ if (!Number.isSafeInteger(month) || month < 1 || month > 12) {
263
+ throw new RangeError(
264
+ `Gregorian month must be an integer from 1 to 12; received ${month}.`
265
+ );
266
+ }
267
+ assertGregorianYear(year);
268
+ if (month === 2) {
269
+ return isGregorianLeapYear(year) ? 29 : 28;
270
+ }
271
+ return month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31;
272
+ }
273
+
274
+ // src/core/calendars/gregorian/conversion.ts
275
+ function gregorianToJdnUnchecked(year, month, day) {
276
+ const a = Math.floor((14 - month) / 12);
277
+ const adjustedYear = year + 4800 - a;
278
+ const adjustedMonth = month + 12 * a - 3;
279
+ return day + Math.floor((153 * adjustedMonth + 2) / 5) + 365 * adjustedYear + Math.floor(adjustedYear / 4) - Math.floor(adjustedYear / 100) + Math.floor(adjustedYear / 400) - 32045;
280
+ }
281
+ var MIN_SUPPORTED_JDN = gregorianToJdnUnchecked(1, 1, 1);
282
+ var MAX_SUPPORTED_JDN = gregorianToJdnUnchecked(9999, 12, 31);
283
+ function isValidGregorianDate(value) {
284
+ if (!hasIntegerDateFields(value)) {
285
+ return false;
286
+ }
287
+ const { year, month, day } = value;
288
+ if (year < GREGORIAN_SUPPORTED_YEAR_RANGE.min || year > GREGORIAN_SUPPORTED_YEAR_RANGE.max || month < 1 || month > 12 || day < 1) {
289
+ return false;
290
+ }
291
+ return day <= getGregorianMonthLength(year, month);
292
+ }
293
+ function gregorianToJdn(date) {
294
+ if (!isValidGregorianDate(date)) {
295
+ throw new RangeError(
296
+ "Invalid Gregorian date; expected a valid date in years 1 through 9999."
297
+ );
298
+ }
299
+ return gregorianToJdnUnchecked(date.year, date.month, date.day);
300
+ }
301
+ function jdnToGregorian(jdn) {
302
+ assertJdn(jdn);
303
+ if (jdn < MIN_SUPPORTED_JDN || jdn > MAX_SUPPORTED_JDN) {
304
+ throw new RangeError(
305
+ "Julian Day Number is outside the supported Gregorian date range."
306
+ );
307
+ }
308
+ const a = jdn + 32044;
309
+ const b = Math.floor((4 * a + 3) / 146097);
310
+ const c = a - Math.floor(146097 * b / 4);
311
+ const d = Math.floor((4 * c + 3) / 1461);
312
+ const e = c - Math.floor(1461 * d / 4);
313
+ const m = Math.floor((5 * e + 2) / 153);
314
+ const day = e - Math.floor((153 * m + 2) / 5) + 1;
315
+ const month = m + 3 - 12 * Math.floor(m / 10);
316
+ const year = 100 * b + d - 4800 + Math.floor(m / 10);
317
+ return { year, month, day };
318
+ }
319
+
320
+ // src/core/calendars/gregorian/index.ts
321
+ var gregorianCalendarAdapter = {
322
+ calendar: "gregorian",
323
+ supportedYearRange: GREGORIAN_SUPPORTED_YEAR_RANGE,
324
+ isLeapYear: isGregorianLeapYear,
325
+ getMonthLength: getGregorianMonthLength,
326
+ isValidDate: isValidGregorianDate,
327
+ toJdn: gregorianToJdn,
328
+ fromJdn: jdnToGregorian
329
+ };
330
+
331
+ // src/core/calendars/iranian/borkowski.ts
332
+ var IRANIAN_SUPPORTED_YEAR_RANGE = {
333
+ min: -61,
334
+ max: 3177
335
+ };
336
+ var BREAK_YEARS = [
337
+ -61,
338
+ 9,
339
+ 38,
340
+ 199,
341
+ 426,
342
+ 686,
343
+ 756,
344
+ 818,
345
+ 1111,
346
+ 1181,
347
+ 1210,
348
+ 1635,
349
+ 2060,
350
+ 2097,
351
+ 2192,
352
+ 2262,
353
+ 2324,
354
+ 2394,
355
+ 2456,
356
+ 3178
357
+ ];
358
+ function assertIranianYear(year) {
359
+ const { min, max } = IRANIAN_SUPPORTED_YEAR_RANGE;
360
+ if (!Number.isSafeInteger(year) || year < min || year > max) {
361
+ throw new RangeError(
362
+ `Iranian Jalali year must be an integer from ${min} to ${max}; received ${year}.`
363
+ );
364
+ }
365
+ }
366
+ function positiveMod(value, divisor) {
367
+ return (value % divisor + divisor) % divisor;
368
+ }
369
+ function getIranianYearInfo(year) {
370
+ assertIranianYear(year);
371
+ const gregorianYear = year + 621;
372
+ let leapJ = -14;
373
+ let jp = BREAK_YEARS[0];
374
+ let jump = 0;
375
+ for (let index = 1; index < BREAK_YEARS.length; index += 1) {
376
+ const jm = BREAK_YEARS[index];
377
+ jump = jm - jp;
378
+ if (year < jm) {
379
+ break;
380
+ }
381
+ leapJ += Math.floor(jump / 33) * 8 + Math.floor(jump % 33 / 4);
382
+ jp = jm;
383
+ }
384
+ const n = year - jp;
385
+ leapJ += Math.floor(n / 33) * 8 + Math.floor((n % 33 + 3) / 4);
386
+ if (jump % 33 === 4 && jump - n === 4) {
387
+ leapJ += 1;
388
+ }
389
+ const leapG = Math.floor(gregorianYear / 4) - Math.floor((Math.floor(gregorianYear / 100) + 1) * 3 / 4) - 150;
390
+ const marchDay = 20 + leapJ - leapG;
391
+ let yearsSinceLeap = n;
392
+ if (jump - n < 6) {
393
+ yearsSinceLeap = n - jump + Math.floor((jump + 4) / 33) * 33;
394
+ }
395
+ let leap = positiveMod(positiveMod(yearsSinceLeap + 1, 33) - 1, 4);
396
+ if (leap === 3 && positiveMod(yearsSinceLeap + 1, 33) === 0) {
397
+ leap = 4;
398
+ }
399
+ return { year, gregorianYear, marchDay, leap };
400
+ }
401
+
402
+ // src/core/calendars/iranian/leap-year.ts
403
+ function isIranianLeapYear(year) {
404
+ return getIranianYearInfo(year).leap === 0;
405
+ }
406
+
407
+ // src/core/calendars/iranian/month-length.ts
408
+ function getIranianMonthLength(year, month) {
409
+ if (!Number.isSafeInteger(month) || month < 1 || month > 12) {
410
+ throw new RangeError(
411
+ `Iranian Jalali month must be an integer from 1 to 12; received ${month}.`
412
+ );
413
+ }
414
+ assertIranianYear(year);
415
+ if (month <= 6) {
416
+ return 31;
417
+ }
418
+ if (month <= 11) {
419
+ return 30;
420
+ }
421
+ return isIranianLeapYear(year) ? 30 : 29;
422
+ }
423
+
424
+ // src/core/calendars/iranian/conversion.ts
425
+ function iranianYearStartJdn(year) {
426
+ const yearInfo = getIranianYearInfo(year);
427
+ return gregorianToJdn({
428
+ year: yearInfo.gregorianYear,
429
+ month: 3,
430
+ day: yearInfo.marchDay
431
+ });
432
+ }
433
+ function daysBeforeIranianMonth(month) {
434
+ return month <= 6 ? (month - 1) * 31 : 186 + (month - 7) * 30;
435
+ }
436
+ function isValidIranianDate(value) {
437
+ if (!hasIntegerDateFields(value)) {
438
+ return false;
439
+ }
440
+ const { year, month, day } = value;
441
+ if (year < IRANIAN_SUPPORTED_YEAR_RANGE.min || year > IRANIAN_SUPPORTED_YEAR_RANGE.max || month < 1 || month > 12 || day < 1) {
442
+ return false;
443
+ }
444
+ return day <= getIranianMonthLength(year, month);
445
+ }
446
+ function iranianToJdn(date) {
447
+ if (!isValidIranianDate(date)) {
448
+ throw new RangeError(
449
+ `Invalid Iranian Jalali date; expected a valid date in years ${IRANIAN_SUPPORTED_YEAR_RANGE.min} through ${IRANIAN_SUPPORTED_YEAR_RANGE.max}.`
450
+ );
451
+ }
452
+ return iranianYearStartJdn(date.year) + daysBeforeIranianMonth(date.month) + date.day - 1;
453
+ }
454
+ function jdnToIranian(jdn) {
455
+ assertJdn(jdn);
456
+ let low = IRANIAN_SUPPORTED_YEAR_RANGE.min;
457
+ let high = IRANIAN_SUPPORTED_YEAR_RANGE.max;
458
+ let year;
459
+ while (low <= high) {
460
+ const candidate = Math.floor((low + high) / 2);
461
+ const yearStart = iranianYearStartJdn(candidate);
462
+ const nextYearStart = yearStart + 365 + (getIranianMonthLength(candidate, 12) === 30 ? 1 : 0);
463
+ if (jdn < yearStart) {
464
+ high = candidate - 1;
465
+ } else if (jdn >= nextYearStart) {
466
+ low = candidate + 1;
467
+ } else {
468
+ year = candidate;
469
+ break;
470
+ }
471
+ }
472
+ if (year === void 0) {
473
+ throw new RangeError(
474
+ "Julian Day Number is outside the supported Iranian Jalali date range."
475
+ );
476
+ }
477
+ const dayOfYear = jdn - iranianYearStartJdn(year);
478
+ const month = dayOfYear < 186 ? Math.floor(dayOfYear / 31) + 1 : Math.floor((dayOfYear - 186) / 30) + 7;
479
+ const day = dayOfYear - daysBeforeIranianMonth(month) + 1;
480
+ return { year, month, day };
481
+ }
482
+
483
+ // src/core/calendars/iranian/index.ts
484
+ var iranianCalendarAdapter = {
485
+ calendar: "iranian",
486
+ supportedYearRange: IRANIAN_SUPPORTED_YEAR_RANGE,
487
+ isLeapYear: isIranianLeapYear,
488
+ getMonthLength: getIranianMonthLength,
489
+ isValidDate: isValidIranianDate,
490
+ toJdn: iranianToJdn,
491
+ fromJdn: jdnToIranian
492
+ };
493
+
494
+ // src/core/calendar-adapter.ts
495
+ var CALENDAR_ADAPTERS = {
496
+ afghan: afghanCalendarAdapter,
497
+ iranian: iranianCalendarAdapter,
498
+ gregorian: gregorianCalendarAdapter
499
+ };
500
+ function getCalendarAdapter(calendar) {
501
+ if (typeof calendar !== "string" || !Object.hasOwn(CALENDAR_ADAPTERS, calendar)) {
502
+ throw new RangeError(`Unsupported calendar system: ${calendar}.`);
503
+ }
504
+ return CALENDAR_ADAPTERS[calendar];
505
+ }
506
+ function getCalendarDateJdn(date, calendar) {
507
+ return getCalendarAdapter(calendar).toJdn(date);
508
+ }
509
+
510
+ // src/core/arithmetic/validation.ts
511
+ function assertIntegerAmount(amount) {
512
+ if (!Number.isSafeInteger(amount)) {
513
+ throw new RangeError(
514
+ `Amount must be a finite safe integer; received ${amount}.`
515
+ );
516
+ }
517
+ }
518
+ function resolveOverflowPolicy(options) {
519
+ if (options === void 0) {
520
+ return "constrain";
521
+ }
522
+ if (typeof options !== "object" || options === null || Array.isArray(options)) {
523
+ throw new TypeError("Date arithmetic options must be an object.");
524
+ }
525
+ const policy = options.overflow ?? "constrain";
526
+ if (policy !== "constrain" && policy !== "reject") {
527
+ throw new RangeError(`Unsupported date overflow policy: ${policy}.`);
528
+ }
529
+ return policy;
530
+ }
531
+
532
+ // src/core/arithmetic/add-days.ts
533
+ function addDays(date, amount, calendar) {
534
+ assertIntegerAmount(amount);
535
+ const adapter = getCalendarAdapter(calendar);
536
+ const targetJdn = adapter.toJdn(date) + amount;
537
+ if (!Number.isSafeInteger(targetJdn)) {
538
+ throw new RangeError(
539
+ "Resulting Julian Day Number is outside the safe range."
540
+ );
541
+ }
542
+ return adapter.fromJdn(targetJdn);
543
+ }
544
+ function subtractDays(date, amount, calendar) {
545
+ assertIntegerAmount(amount);
546
+ return addDays(date, -amount, calendar);
547
+ }
548
+
549
+ // src/core/arithmetic/add-weeks.ts
550
+ function daysInWeeks(amount) {
551
+ assertIntegerAmount(amount);
552
+ const days = amount * 7;
553
+ assertIntegerAmount(days);
554
+ return days;
555
+ }
556
+ function addWeeks(date, amount, calendar) {
557
+ return addDays(date, daysInWeeks(amount), calendar);
558
+ }
559
+ function subtractWeeks(date, amount, calendar) {
560
+ return addDays(date, -daysInWeeks(amount), calendar);
561
+ }
562
+
563
+ // src/core/arithmetic/add-months.ts
564
+ function addMonths(date, amount, calendar, options) {
565
+ assertIntegerAmount(amount);
566
+ const policy = resolveOverflowPolicy(options);
567
+ const adapter = getCalendarAdapter(calendar);
568
+ adapter.toJdn(date);
569
+ const absoluteMonth = date.year * 12 + date.month - 1 + amount;
570
+ if (!Number.isSafeInteger(absoluteMonth)) {
571
+ throw new RangeError("Target calendar month is outside the safe range.");
572
+ }
573
+ const year = Math.floor(absoluteMonth / 12);
574
+ const month = absoluteMonth - year * 12 + 1;
575
+ const monthLength = adapter.getMonthLength(year, month);
576
+ if (date.day > monthLength && policy === "reject") {
577
+ throw new RangeError(
578
+ `Day ${date.day} does not exist in ${calendar} year ${year}, month ${month}.`
579
+ );
580
+ }
581
+ return { year, month, day: Math.min(date.day, monthLength) };
582
+ }
583
+ function subtractMonths(date, amount, calendar, options) {
584
+ assertIntegerAmount(amount);
585
+ return addMonths(date, -amount, calendar, options);
586
+ }
587
+
588
+ // src/core/arithmetic/add-years.ts
589
+ function addYears(date, amount, calendar, options) {
590
+ assertIntegerAmount(amount);
591
+ const policy = resolveOverflowPolicy(options);
592
+ const adapter = getCalendarAdapter(calendar);
593
+ adapter.toJdn(date);
594
+ const year = date.year + amount;
595
+ if (!Number.isSafeInteger(year)) {
596
+ throw new RangeError("Target calendar year is outside the safe range.");
597
+ }
598
+ const monthLength = adapter.getMonthLength(year, date.month);
599
+ if (date.day > monthLength && policy === "reject") {
600
+ throw new RangeError(
601
+ `Day ${date.day} does not exist in ${calendar} year ${year}, month ${date.month}.`
602
+ );
603
+ }
604
+ return { year, month: date.month, day: Math.min(date.day, monthLength) };
605
+ }
606
+ function subtractYears(date, amount, calendar, options) {
607
+ assertIntegerAmount(amount);
608
+ return addYears(date, -amount, calendar, options);
609
+ }
610
+
611
+ // src/core/arithmetic/difference.ts
612
+ function differenceInDays(dateLeft, dateRight, calendar) {
613
+ const adapter = getCalendarAdapter(calendar);
614
+ return adapter.toJdn(dateLeft) - adapter.toJdn(dateRight);
615
+ }
616
+ function differenceInWeeks(dateLeft, dateRight, calendar) {
617
+ return Math.trunc(differenceInDays(dateLeft, dateRight, calendar) / 7);
618
+ }
619
+ function differenceInMonths(dateLeft, dateRight, calendar) {
620
+ const adapter = getCalendarAdapter(calendar);
621
+ const leftJdn = adapter.toJdn(dateLeft);
622
+ const rightJdn = adapter.toJdn(dateRight);
623
+ if (leftJdn === rightJdn) {
624
+ return 0;
625
+ }
626
+ const sign = leftJdn > rightJdn ? 1 : -1;
627
+ const earlier = sign > 0 ? dateRight : dateLeft;
628
+ const later = sign > 0 ? dateLeft : dateRight;
629
+ const laterJdn = sign > 0 ? leftJdn : rightJdn;
630
+ const candidateMonths = (later.year - earlier.year) * 12 + later.month - earlier.month;
631
+ const candidate = addMonths(earlier, candidateMonths, calendar);
632
+ const completedMonths = adapter.toJdn(candidate) > laterJdn ? candidateMonths - 1 : candidateMonths;
633
+ return sign * completedMonths;
634
+ }
635
+ function differenceInYears(dateLeft, dateRight, calendar) {
636
+ const adapter = getCalendarAdapter(calendar);
637
+ const leftJdn = adapter.toJdn(dateLeft);
638
+ const rightJdn = adapter.toJdn(dateRight);
639
+ if (leftJdn === rightJdn) {
640
+ return 0;
641
+ }
642
+ const sign = leftJdn > rightJdn ? 1 : -1;
643
+ const earlier = sign > 0 ? dateRight : dateLeft;
644
+ const later = sign > 0 ? dateLeft : dateRight;
645
+ const laterJdn = sign > 0 ? leftJdn : rightJdn;
646
+ const candidateYears = later.year - earlier.year;
647
+ const candidate = addYears(earlier, candidateYears, calendar);
648
+ const completedYears = adapter.toJdn(candidate) > laterJdn ? candidateYears - 1 : candidateYears;
649
+ return sign * completedYears;
650
+ }
651
+
652
+ // src/core/boundaries/day.ts
653
+ function getStartOfDay(date, calendar) {
654
+ getCalendarAdapter(calendar).toJdn(date);
655
+ return { year: date.year, month: date.month, day: date.day };
656
+ }
657
+ function getEndOfDay(date, calendar) {
658
+ return getStartOfDay(date, calendar);
659
+ }
660
+
661
+ // src/core/boundaries/month.ts
662
+ function getDaysInMonth(year, month, calendar) {
663
+ return getCalendarAdapter(calendar).getMonthLength(year, month);
664
+ }
665
+ function getStartOfMonth(date, calendar) {
666
+ getCalendarAdapter(calendar).toJdn(date);
667
+ return { year: date.year, month: date.month, day: 1 };
668
+ }
669
+ function getEndOfMonth(date, calendar) {
670
+ const adapter = getCalendarAdapter(calendar);
671
+ adapter.toJdn(date);
672
+ return {
673
+ year: date.year,
674
+ month: date.month,
675
+ day: adapter.getMonthLength(date.year, date.month)
676
+ };
677
+ }
678
+ function getMonthsInYear(year, calendar) {
679
+ getCalendarAdapter(calendar).getMonthLength(year, 1);
680
+ return 12;
681
+ }
682
+
683
+ // src/core/boundaries/week.ts
684
+ function defaultFirstDay(calendar) {
685
+ switch (calendar) {
686
+ case "afghan":
687
+ case "iranian":
688
+ return 6;
689
+ case "gregorian":
690
+ return 1;
691
+ default:
692
+ throw new RangeError(`Unsupported calendar system: ${calendar}.`);
693
+ }
694
+ }
695
+ function validateWeekday(weekday) {
696
+ if (!Number.isInteger(weekday) || weekday < 1 || weekday > 7) {
697
+ throw new RangeError(
698
+ `First day of week must be an ISO weekday from 1 to 7; received ${weekday}.`
699
+ );
700
+ }
701
+ }
702
+ function getDayOfWeek(date, calendar) {
703
+ return getWeekday(getCalendarDateJdn(date, calendar));
704
+ }
705
+ function getStartOfWeek(date, calendar, firstDayOfWeek) {
706
+ const adapter = getCalendarAdapter(calendar);
707
+ const firstDay = firstDayOfWeek ?? defaultFirstDay(calendar);
708
+ validateWeekday(firstDay);
709
+ const jdn = adapter.toJdn(date);
710
+ const weekday = getWeekday(jdn);
711
+ const daysToSubtract = (weekday - firstDay + 7) % 7;
712
+ return adapter.fromJdn(jdn - daysToSubtract);
713
+ }
714
+ function getEndOfWeek(date, calendar, firstDayOfWeek) {
715
+ const adapter = getCalendarAdapter(calendar);
716
+ const firstDay = firstDayOfWeek ?? defaultFirstDay(calendar);
717
+ validateWeekday(firstDay);
718
+ const start = getStartOfWeek(date, calendar, firstDay);
719
+ return adapter.fromJdn(adapter.toJdn(start) + 6);
720
+ }
721
+
722
+ // src/core/boundaries/year.ts
723
+ function getStartOfYear(date, calendar) {
724
+ getCalendarAdapter(calendar).toJdn(date);
725
+ return { year: date.year, month: 1, day: 1 };
726
+ }
727
+ function getEndOfYear(date, calendar) {
728
+ const adapter = getCalendarAdapter(calendar);
729
+ adapter.toJdn(date);
730
+ return {
731
+ year: date.year,
732
+ month: 12,
733
+ day: adapter.getMonthLength(date.year, 12)
734
+ };
735
+ }
736
+ function getDaysInYear(year, calendar) {
737
+ const adapter = getCalendarAdapter(calendar);
738
+ let total = 0;
739
+ for (let month = 1; month <= 12; month += 1) {
740
+ total += adapter.getMonthLength(year, month);
741
+ }
742
+ return total;
743
+ }
744
+ function isLeapYear(year, calendar) {
745
+ return getCalendarAdapter(calendar).isLeapYear(year);
746
+ }
747
+
748
+ // src/core/comparison/compare.ts
749
+ function compareDates(dateLeft, dateRight, calendar) {
750
+ const adapter = getCalendarAdapter(calendar);
751
+ const leftJdn = adapter.toJdn(dateLeft);
752
+ const rightJdn = adapter.toJdn(dateRight);
753
+ return leftJdn < rightJdn ? -1 : leftJdn > rightJdn ? 1 : 0;
754
+ }
755
+
756
+ // src/core/comparison/predicates.ts
757
+ function isSameDay(dateLeft, dateRight, calendar) {
758
+ return compareDates(dateLeft, dateRight, calendar) === 0;
759
+ }
760
+ function isBefore(dateLeft, dateRight, calendar) {
761
+ return compareDates(dateLeft, dateRight, calendar) < 0;
762
+ }
763
+ function isAfter(dateLeft, dateRight, calendar) {
764
+ return compareDates(dateLeft, dateRight, calendar) > 0;
765
+ }
766
+ function isSameMonth(dateLeft, dateRight, calendar) {
767
+ const adapter = getCalendarAdapter(calendar);
768
+ adapter.toJdn(dateLeft);
769
+ adapter.toJdn(dateRight);
770
+ return dateLeft.year === dateRight.year && dateLeft.month === dateRight.month;
771
+ }
772
+ function isSameYear(dateLeft, dateRight, calendar) {
773
+ const adapter = getCalendarAdapter(calendar);
774
+ adapter.toJdn(dateLeft);
775
+ adapter.toJdn(dateRight);
776
+ return dateLeft.year === dateRight.year;
777
+ }
778
+
779
+ // src/core/conversion/convert-date.ts
780
+ var adapters = {
781
+ afghan: afghanCalendarAdapter,
782
+ iranian: iranianCalendarAdapter,
783
+ gregorian: gregorianCalendarAdapter
784
+ };
785
+ function assertCalendarSystem(value) {
786
+ if (!Object.hasOwn(adapters, value)) {
787
+ throw new RangeError(`Unsupported calendar system: ${value}.`);
788
+ }
789
+ }
790
+ function convertDate(date, fromCalendar, toCalendar) {
791
+ assertCalendarSystem(fromCalendar);
792
+ assertCalendarSystem(toCalendar);
793
+ const jdn = adapters[fromCalendar].toJdn(date);
794
+ switch (toCalendar) {
795
+ case "afghan":
796
+ return adapters.afghan.fromJdn(jdn);
797
+ case "iranian":
798
+ return adapters.iranian.fromJdn(jdn);
799
+ case "gregorian":
800
+ return adapters.gregorian.fromJdn(jdn);
801
+ }
802
+ }
803
+
804
+ // src/locales/en/months.ts
805
+ var months = {
806
+ afghan: [
807
+ "Hamal",
808
+ "Sawr",
809
+ "Jawza",
810
+ "Saratan",
811
+ "Asad",
812
+ "Sonbola",
813
+ "Mizan",
814
+ "Aqrab",
815
+ "Qaws",
816
+ "Jadi",
817
+ "Dalwa",
818
+ "Hoot"
819
+ ],
820
+ iranian: [
821
+ "Farvardin",
822
+ "Ordibehesht",
823
+ "Khordad",
824
+ "Tir",
825
+ "Mordad",
826
+ "Shahrivar",
827
+ "Mehr",
828
+ "Aban",
829
+ "Azar",
830
+ "Dey",
831
+ "Bahman",
832
+ "Esfand"
833
+ ],
834
+ gregorian: [
835
+ "January",
836
+ "February",
837
+ "March",
838
+ "April",
839
+ "May",
840
+ "June",
841
+ "July",
842
+ "August",
843
+ "September",
844
+ "October",
845
+ "November",
846
+ "December"
847
+ ]
848
+ };
849
+ var shortMonths = {
850
+ afghan: [
851
+ "Ham",
852
+ "Saw",
853
+ "Jaw",
854
+ "Sar",
855
+ "Asa",
856
+ "Son",
857
+ "Miz",
858
+ "Aqr",
859
+ "Qaw",
860
+ "Jad",
861
+ "Dal",
862
+ "Hoo"
863
+ ],
864
+ iranian: [
865
+ "Far",
866
+ "Ord",
867
+ "Kho",
868
+ "Tir",
869
+ "Mor",
870
+ "Sha",
871
+ "Mehr",
872
+ "Aba",
873
+ "Aza",
874
+ "Dey",
875
+ "Bah",
876
+ "Esf"
877
+ ],
878
+ gregorian: [
879
+ "Jan",
880
+ "Feb",
881
+ "Mar",
882
+ "Apr",
883
+ "May",
884
+ "Jun",
885
+ "Jul",
886
+ "Aug",
887
+ "Sep",
888
+ "Oct",
889
+ "Nov",
890
+ "Dec"
891
+ ]
892
+ };
893
+
894
+ // src/locales/en/index.ts
895
+ var enLocale = {
896
+ code: "en",
897
+ name: "English",
898
+ nativeName: "English",
899
+ direction: "ltr",
900
+ months,
901
+ shortMonths,
902
+ weekdays: {
903
+ full: [
904
+ "Monday",
905
+ "Tuesday",
906
+ "Wednesday",
907
+ "Thursday",
908
+ "Friday",
909
+ "Saturday",
910
+ "Sunday"
911
+ ],
912
+ short: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
913
+ narrow: ["M", "T", "W", "T", "F", "S", "S"]
914
+ },
915
+ firstDayOfWeek: 7,
916
+ defaultNumeralSystem: "latin",
917
+ ui: {
918
+ today: "Today",
919
+ clear: "Clear",
920
+ cancel: "Cancel",
921
+ apply: "Apply",
922
+ previousMonth: "Previous month",
923
+ nextMonth: "Next month",
924
+ previousYear: "Previous year",
925
+ nextYear: "Next year",
926
+ selectMonth: "Select month",
927
+ selectYear: "Select year",
928
+ startDate: "Start date",
929
+ endDate: "End date",
930
+ noDateSelected: "No date selected",
931
+ invalidDate: "Invalid date",
932
+ selectStartDate: "Select a start date first.",
933
+ rangeIncludesDisabledDate: "The range includes a disabled date.",
934
+ rangeTooShort: "The range must include at least {days} days.",
935
+ rangeTooLong: "The range cannot include more than {days} days."
936
+ }
937
+ };
938
+
939
+ // src/locales/fa-AF/months.ts
940
+ var months2 = {
941
+ afghan: [
942
+ "\u062D\u0645\u0644",
943
+ "\u062B\u0648\u0631",
944
+ "\u062C\u0648\u0632\u0627",
945
+ "\u0633\u0631\u0637\u0627\u0646",
946
+ "\u0627\u0633\u062F",
947
+ "\u0633\u0646\u0628\u0644\u0647",
948
+ "\u0645\u06CC\u0632\u0627\u0646",
949
+ "\u0639\u0642\u0631\u0628",
950
+ "\u0642\u0648\u0633",
951
+ "\u062C\u062F\u06CC",
952
+ "\u062F\u0644\u0648",
953
+ "\u062D\u0648\u062A"
954
+ ],
955
+ iranian: [
956
+ "\u0641\u0631\u0648\u0631\u062F\u06CC\u0646",
957
+ "\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A",
958
+ "\u062E\u0631\u062F\u0627\u062F",
959
+ "\u062A\u06CC\u0631",
960
+ "\u0645\u0631\u062F\u0627\u062F",
961
+ "\u0634\u0647\u0631\u06CC\u0648\u0631",
962
+ "\u0645\u0647\u0631",
963
+ "\u0622\u0628\u0627\u0646",
964
+ "\u0622\u0630\u0631",
965
+ "\u062F\u06CC",
966
+ "\u0628\u0647\u0645\u0646",
967
+ "\u0627\u0633\u0641\u0646\u062F"
968
+ ],
969
+ gregorian: [
970
+ "\u062C\u0646\u0648\u0631\u06CC",
971
+ "\u0641\u0628\u0631\u0648\u0631\u06CC",
972
+ "\u0645\u0627\u0631\u0686",
973
+ "\u0627\u067E\u0631\u06CC\u0644",
974
+ "\u0645\u06CC",
975
+ "\u062C\u0648\u0646",
976
+ "\u062C\u0648\u0644\u0627\u06CC",
977
+ "\u0627\u06AF\u0633\u062A",
978
+ "\u0633\u067E\u062A\u0645\u0628\u0631",
979
+ "\u0627\u06A9\u062A\u0648\u0628\u0631",
980
+ "\u0646\u0648\u0627\u0645\u0628\u0631",
981
+ "\u062F\u0633\u0645\u0628\u0631"
982
+ ]
983
+ };
984
+ var shortMonths2 = {
985
+ afghan: months2.afghan,
986
+ iranian: months2.iranian,
987
+ gregorian: [
988
+ "\u062C\u0646\u0648\u0631\u06CC",
989
+ "\u0641\u0628\u0631\u0648\u0631\u06CC",
990
+ "\u0645\u0627\u0631\u0686",
991
+ "\u0627\u067E\u0631\u06CC\u0644",
992
+ "\u0645\u06CC",
993
+ "\u062C\u0648\u0646",
994
+ "\u062C\u0648\u0644\u0627\u06CC",
995
+ "\u0627\u06AF\u0633\u062A",
996
+ "\u0633\u067E\u062A\u0645\u0628\u0631",
997
+ "\u0627\u06A9\u062A\u0648\u0628\u0631",
998
+ "\u0646\u0648\u0627\u0645\u0628\u0631",
999
+ "\u062F\u0633\u0645\u0628\u0631"
1000
+ ]
1001
+ };
1002
+
1003
+ // src/locales/fa-AF/index.ts
1004
+ var faAfLocale = {
1005
+ code: "fa-AF",
1006
+ name: "Afghan Dari",
1007
+ nativeName: "\u062F\u0631\u06CC \u0627\u0641\u063A\u0627\u0646\u0633\u062A\u0627\u0646",
1008
+ direction: "rtl",
1009
+ months: months2,
1010
+ shortMonths: shortMonths2,
1011
+ weekdays: {
1012
+ full: [
1013
+ "\u062F\u0648\u0634\u0646\u0628\u0647",
1014
+ "\u0633\u0647\u200C\u0634\u0646\u0628\u0647",
1015
+ "\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647",
1016
+ "\u067E\u0646\u062C\u0634\u0646\u0628\u0647",
1017
+ "\u062C\u0645\u0639\u0647",
1018
+ "\u0634\u0646\u0628\u0647",
1019
+ "\u06CC\u06A9\u0634\u0646\u0628\u0647"
1020
+ ],
1021
+ short: ["\u062F\u0648\u0634", "\u0633\u0647\u200C\u0634\u0646", "\u0686\u0647\u0627\u0631", "\u067E\u0646\u062C", "\u062C\u0645\u0639", "\u0634\u0646", "\u06CC\u06A9"],
1022
+ narrow: ["\u062F", "\u0633", "\u0686", "\u067E", "\u062C", "\u0634", "\u06CC"]
1023
+ },
1024
+ firstDayOfWeek: 6,
1025
+ defaultNumeralSystem: "persian",
1026
+ ui: {
1027
+ today: "\u0627\u0645\u0631\u0648\u0632",
1028
+ clear: "\u067E\u0627\u06A9\u200C\u06A9\u0631\u062F\u0646",
1029
+ cancel: "\u0644\u063A\u0648",
1030
+ apply: "\u0627\u0639\u0645\u0627\u0644",
1031
+ previousMonth: "\u0645\u0627\u0647 \u0642\u0628\u0644",
1032
+ nextMonth: "\u0645\u0627\u0647 \u0628\u0639\u062F",
1033
+ previousYear: "\u0633\u0627\u0644 \u0642\u0628\u0644",
1034
+ nextYear: "\u0633\u0627\u0644 \u0628\u0639\u062F",
1035
+ selectMonth: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0645\u0627\u0647",
1036
+ selectYear: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0633\u0627\u0644",
1037
+ startDate: "\u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639",
1038
+ endDate: "\u062A\u0627\u0631\u06CC\u062E \u067E\u0627\u06CC\u0627\u0646",
1039
+ noDateSelected: "\u062A\u0627\u0631\u06CC\u062E\u06CC \u0627\u0646\u062A\u062E\u0627\u0628 \u0646\u0634\u062F\u0647",
1040
+ invalidDate: "\u062A\u0627\u0631\u06CC\u062E \u0646\u0627\u0645\u0639\u062A\u0628\u0631",
1041
+ selectStartDate: "\u0644\u0637\u0641\u0627\u064B \u0646\u062E\u0633\u062A \u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639 \u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F.",
1042
+ rangeIncludesDisabledDate: "\u0628\u0627\u0632\u0647\u0654 \u062A\u0627\u0631\u06CC\u062E \u0646\u0645\u06CC\u200C\u062A\u0648\u0627\u0646\u062F \u0634\u0627\u0645\u0644 \u062A\u0627\u0631\u06CC\u062E \u063A\u06CC\u0631\u0641\u0639\u0627\u0644 \u0628\u0627\u0634\u062F.",
1043
+ rangeTooShort: "\u0628\u0627\u0632\u0647 \u0628\u0627\u06CC\u062F \u062F\u0633\u062A\u200C\u06A9\u0645 {days} \u0631\u0648\u0632 \u0628\u0627\u0634\u062F.",
1044
+ rangeTooLong: "\u0628\u0627\u0632\u0647 \u0646\u0645\u06CC\u200C\u062A\u0648\u0627\u0646\u062F \u0628\u06CC\u0634 \u0627\u0632 {days} \u0631\u0648\u0632 \u0628\u0627\u0634\u062F."
1045
+ }
1046
+ };
1047
+
1048
+ // src/locales/fa-IR/months.ts
1049
+ var months3 = {
1050
+ afghan: [
1051
+ "\u062D\u0645\u0644",
1052
+ "\u062B\u0648\u0631",
1053
+ "\u062C\u0648\u0632\u0627",
1054
+ "\u0633\u0631\u0637\u0627\u0646",
1055
+ "\u0627\u0633\u062F",
1056
+ "\u0633\u0646\u0628\u0644\u0647",
1057
+ "\u0645\u06CC\u0632\u0627\u0646",
1058
+ "\u0639\u0642\u0631\u0628",
1059
+ "\u0642\u0648\u0633",
1060
+ "\u062C\u062F\u06CC",
1061
+ "\u062F\u0644\u0648",
1062
+ "\u062D\u0648\u062A"
1063
+ ],
1064
+ iranian: [
1065
+ "\u0641\u0631\u0648\u0631\u062F\u06CC\u0646",
1066
+ "\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A",
1067
+ "\u062E\u0631\u062F\u0627\u062F",
1068
+ "\u062A\u06CC\u0631",
1069
+ "\u0645\u0631\u062F\u0627\u062F",
1070
+ "\u0634\u0647\u0631\u06CC\u0648\u0631",
1071
+ "\u0645\u0647\u0631",
1072
+ "\u0622\u0628\u0627\u0646",
1073
+ "\u0622\u0630\u0631",
1074
+ "\u062F\u06CC",
1075
+ "\u0628\u0647\u0645\u0646",
1076
+ "\u0627\u0633\u0641\u0646\u062F"
1077
+ ],
1078
+ gregorian: [
1079
+ "\u0698\u0627\u0646\u0648\u06CC\u0647",
1080
+ "\u0641\u0648\u0631\u06CC\u0647",
1081
+ "\u0645\u0627\u0631\u0633",
1082
+ "\u0622\u0648\u0631\u06CC\u0644",
1083
+ "\u0645\u0647",
1084
+ "\u0698\u0648\u0626\u0646",
1085
+ "\u0698\u0648\u0626\u06CC\u0647",
1086
+ "\u0627\u0648\u062A",
1087
+ "\u0633\u067E\u062A\u0627\u0645\u0628\u0631",
1088
+ "\u0627\u06A9\u062A\u0628\u0631",
1089
+ "\u0646\u0648\u0627\u0645\u0628\u0631",
1090
+ "\u062F\u0633\u0627\u0645\u0628\u0631"
1091
+ ]
1092
+ };
1093
+ var shortMonths3 = {
1094
+ afghan: months3.afghan,
1095
+ iranian: months3.iranian,
1096
+ gregorian: [
1097
+ "\u0698\u0627\u0646\u0648\u06CC\u0647",
1098
+ "\u0641\u0648\u0631\u06CC\u0647",
1099
+ "\u0645\u0627\u0631\u0633",
1100
+ "\u0622\u0648\u0631\u06CC\u0644",
1101
+ "\u0645\u0647",
1102
+ "\u0698\u0648\u0626\u0646",
1103
+ "\u0698\u0648\u0626\u06CC\u0647",
1104
+ "\u0627\u0648\u062A",
1105
+ "\u0633\u067E\u062A\u0627\u0645\u0628\u0631",
1106
+ "\u0627\u06A9\u062A\u0628\u0631",
1107
+ "\u0646\u0648\u0627\u0645\u0628\u0631",
1108
+ "\u062F\u0633\u0627\u0645\u0628\u0631"
1109
+ ]
1110
+ };
1111
+
1112
+ // src/locales/fa-IR/index.ts
1113
+ var faIrLocale = {
1114
+ code: "fa-IR",
1115
+ name: "Iranian Persian",
1116
+ nativeName: "\u0641\u0627\u0631\u0633\u06CC (\u0627\u06CC\u0631\u0627\u0646)",
1117
+ direction: "rtl",
1118
+ months: months3,
1119
+ shortMonths: shortMonths3,
1120
+ weekdays: {
1121
+ full: [
1122
+ "\u062F\u0648\u0634\u0646\u0628\u0647",
1123
+ "\u0633\u0647\u200C\u0634\u0646\u0628\u0647",
1124
+ "\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647",
1125
+ "\u067E\u0646\u062C\u0634\u0646\u0628\u0647",
1126
+ "\u062C\u0645\u0639\u0647",
1127
+ "\u0634\u0646\u0628\u0647",
1128
+ "\u06CC\u06A9\u0634\u0646\u0628\u0647"
1129
+ ],
1130
+ short: ["\u062F\u0648\u0634", "\u0633\u0647\u200C\u0634\u0646", "\u0686\u0647\u0627\u0631", "\u067E\u0646\u062C", "\u062C\u0645\u0639", "\u0634\u0646", "\u06CC\u06A9"],
1131
+ narrow: ["\u062F", "\u0633", "\u0686", "\u067E", "\u062C", "\u0634", "\u06CC"]
1132
+ },
1133
+ firstDayOfWeek: 6,
1134
+ defaultNumeralSystem: "persian",
1135
+ ui: {
1136
+ today: "\u0627\u0645\u0631\u0648\u0632",
1137
+ clear: "\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646",
1138
+ cancel: "\u0644\u063A\u0648",
1139
+ apply: "\u0627\u0639\u0645\u0627\u0644",
1140
+ previousMonth: "\u0645\u0627\u0647 \u0642\u0628\u0644",
1141
+ nextMonth: "\u0645\u0627\u0647 \u0628\u0639\u062F",
1142
+ previousYear: "\u0633\u0627\u0644 \u0642\u0628\u0644",
1143
+ nextYear: "\u0633\u0627\u0644 \u0628\u0639\u062F",
1144
+ selectMonth: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0645\u0627\u0647",
1145
+ selectYear: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0633\u0627\u0644",
1146
+ startDate: "\u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639",
1147
+ endDate: "\u062A\u0627\u0631\u06CC\u062E \u067E\u0627\u06CC\u0627\u0646",
1148
+ noDateSelected: "\u062A\u0627\u0631\u06CC\u062E\u06CC \u0627\u0646\u062A\u062E\u0627\u0628 \u0646\u0634\u062F\u0647",
1149
+ invalidDate: "\u062A\u0627\u0631\u06CC\u062E \u0646\u0627\u0645\u0639\u062A\u0628\u0631",
1150
+ selectStartDate: "\u0644\u0637\u0641\u0627\u064B \u0627\u0628\u062A\u062F\u0627 \u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639 \u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F.",
1151
+ rangeIncludesDisabledDate: "\u0628\u0627\u0632\u0647\u0654 \u062A\u0627\u0631\u06CC\u062E \u0646\u0645\u06CC\u200C\u062A\u0648\u0627\u0646\u062F \u0634\u0627\u0645\u0644 \u062A\u0627\u0631\u06CC\u062E \u063A\u06CC\u0631\u0641\u0639\u0627\u0644 \u0628\u0627\u0634\u062F.",
1152
+ rangeTooShort: "\u0628\u0627\u0632\u0647 \u0628\u0627\u06CC\u062F \u062F\u0633\u062A\u200C\u06A9\u0645 {days} \u0631\u0648\u0632 \u0628\u0627\u0634\u062F.",
1153
+ rangeTooLong: "\u0628\u0627\u0632\u0647 \u0646\u0645\u06CC\u200C\u062A\u0648\u0627\u0646\u062F \u0628\u06CC\u0634 \u0627\u0632 {days} \u0631\u0648\u0632 \u0628\u0627\u0634\u062F."
1154
+ }
1155
+ };
1156
+
1157
+ // src/locales/ps-AF/months.ts
1158
+ var months4 = {
1159
+ afghan: [
1160
+ "\u0648\u0631\u06CC",
1161
+ "\u063A\u0648\u06CC\u06CC",
1162
+ "\u063A\u0628\u0631\u06AB\u0648\u0644\u06CC",
1163
+ "\u0686\u0646\u06AB\u0627\u069A",
1164
+ "\u0632\u0645\u0631\u06CC",
1165
+ "\u0648\u0696\u06CC",
1166
+ "\u062A\u0644\u0647",
1167
+ "\u0644\u0693\u0645",
1168
+ "\u0644\u06CC\u0646\u062F\u06CD",
1169
+ "\u0645\u0631\u063A\u0648\u0645\u06CC",
1170
+ "\u0633\u0644\u0648\u0627\u063A\u0647",
1171
+ "\u06A9\u0628"
1172
+ ],
1173
+ iranian: [
1174
+ "\u0641\u0631\u0648\u0631\u062F\u06CC\u0646",
1175
+ "\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A",
1176
+ "\u062E\u0631\u062F\u0627\u062F",
1177
+ "\u062A\u06CC\u0631",
1178
+ "\u0645\u0631\u062F\u0627\u062F",
1179
+ "\u0634\u0647\u0631\u06CC\u0648\u0631",
1180
+ "\u0645\u0647\u0631",
1181
+ "\u0622\u0628\u0627\u0646",
1182
+ "\u0622\u0630\u0631",
1183
+ "\u062F\u06CC",
1184
+ "\u0628\u0647\u0645\u0646",
1185
+ "\u0627\u0633\u0641\u0646\u062F"
1186
+ ],
1187
+ gregorian: [
1188
+ "\u062C\u0646\u0648\u0631\u064A",
1189
+ "\u0641\u0628\u0631\u0648\u0631\u064A",
1190
+ "\u0645\u0627\u0631\u0686",
1191
+ "\u0627\u067E\u0631\u06D0\u0644",
1192
+ "\u0645\u06D0",
1193
+ "\u062C\u0648\u0646",
1194
+ "\u062C\u0648\u0644\u0627\u06CC",
1195
+ "\u0627\u06AB\u0633\u062A",
1196
+ "\u0633\u067E\u067C\u0645\u0628\u0631",
1197
+ "\u0627\u06A9\u062A\u0648\u0628\u0631",
1198
+ "\u0646\u0648\u0645\u0628\u0631",
1199
+ "\u0689\u0633\u0645\u0628\u0631"
1200
+ ]
1201
+ };
1202
+ var shortMonths4 = {
1203
+ afghan: months4.afghan,
1204
+ iranian: months4.iranian,
1205
+ gregorian: [
1206
+ "\u062C\u0646\u0648\u0631\u064A",
1207
+ "\u0641\u0628\u0631\u0648\u0631\u064A",
1208
+ "\u0645\u0627\u0631\u0686",
1209
+ "\u0627\u067E\u0631\u06D0\u0644",
1210
+ "\u0645\u06D0",
1211
+ "\u062C\u0648\u0646",
1212
+ "\u062C\u0648\u0644\u0627\u06CC",
1213
+ "\u0627\u06AB\u0633\u062A",
1214
+ "\u0633\u067E\u067C\u0645\u0628\u0631",
1215
+ "\u0627\u06A9\u062A\u0648\u0628\u0631",
1216
+ "\u0646\u0648\u0645\u0628\u0631",
1217
+ "\u0689\u0633\u0645\u0628\u0631"
1218
+ ]
1219
+ };
1220
+
1221
+ // src/locales/ps-AF/index.ts
1222
+ var psAfLocale = {
1223
+ code: "ps-AF",
1224
+ name: "Afghan Pashto",
1225
+ nativeName: "\u067E\u069A\u062A\u0648 (\u0627\u0641\u063A\u0627\u0646\u0633\u062A\u0627\u0646)",
1226
+ direction: "rtl",
1227
+ months: months4,
1228
+ shortMonths: shortMonths4,
1229
+ weekdays: {
1230
+ full: [
1231
+ "\u062F\u0648\u0634\u0646\u0628\u0647",
1232
+ "\u0633\u0647 \u0634\u0646\u0628\u0647",
1233
+ "\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647",
1234
+ "\u067E\u0646\u062C \u0634\u0646\u0628\u0647",
1235
+ "\u062C\u0645\u0639\u0647",
1236
+ "\u0634\u0646\u0628\u0647",
1237
+ "\u06CC\u06A9\u0634\u0646\u0628\u0647"
1238
+ ],
1239
+ short: ["\u062F", "\u0633", "\u0686", "\u067E", "\u062C", "\u0634", "\u06CC"],
1240
+ narrow: ["\u062F", "\u0633", "\u0686", "\u067E", "\u062C", "\u0634", "\u06CC"]
1241
+ },
1242
+ firstDayOfWeek: 6,
1243
+ defaultNumeralSystem: "persian",
1244
+ ui: {
1245
+ today: "\u0646\u0646",
1246
+ clear: "\u067E\u0627\u06A9\u0648\u0644",
1247
+ cancel: "\u0644\u063A\u0648\u0647 \u06A9\u0648\u0644",
1248
+ apply: "\u067E\u0644\u064A \u06A9\u0648\u0644",
1249
+ previousMonth: "\u0645\u062E\u06A9\u06CC\u0646\u06CD \u0645\u06CC\u0627\u0634\u062A",
1250
+ nextMonth: "\u0631\u0627\u062A\u0644\u0648\u0646\u06A9\u06D0 \u0645\u06CC\u0627\u0634\u062A",
1251
+ previousYear: "\u0645\u062E\u06A9\u06CC\u0646\u06CC \u06A9\u0627\u0644",
1252
+ nextYear: "\u0631\u0627\u062A\u0644\u0648\u0646\u06A9\u06CC \u06A9\u0627\u0644",
1253
+ selectMonth: "\u0645\u06CC\u0627\u0634\u062A \u0648\u067C\u0627\u06A9\u0626",
1254
+ selectYear: "\u06A9\u0627\u0644 \u0648\u067C\u0627\u06A9\u0626",
1255
+ startDate: "\u062F \u067E\u06CC\u0644 \u0646\u06D0\u067C\u0647",
1256
+ endDate: "\u062F \u067E\u0627\u06CC \u0646\u06D0\u067C\u0647",
1257
+ noDateSelected: "\u0646\u06D0\u067C\u0647 \u0646\u0647 \u062F\u0647 \u067C\u0627\u06A9\u0644 \u0634\u0648\u06D0",
1258
+ invalidDate: "\u0646\u0627\u0633\u0645\u0647 \u0646\u06D0\u067C\u0647",
1259
+ selectStartDate: "\u0645\u0647\u0631\u0628\u0627\u0646\u064A \u0648\u06A9\u0693\u0626 \u0644\u0648\u0645\u0693\u06CC \u062F \u067E\u06CC\u0644 \u0646\u06D0\u067C\u0647 \u0648\u067C\u0627\u06A9\u0626.",
1260
+ rangeIncludesDisabledDate: "\u062F \u0646\u06D0\u067C\u0648 \u067E\u0647 \u0644\u0693 \u06A9\u06D0 \u0646\u0627\u062A\u0648\u0627\u0646\u0647 \u0634\u0648\u06D0 \u0646\u06D0\u067C\u0647 \u0646\u0634\u064A \u0634\u0627\u0645\u0644\u06D0\u062F\u0627\u06CC.",
1261
+ rangeTooShort: "\u062F \u0646\u06D0\u067C\u0648 \u0644\u0693 \u0628\u0627\u06CC\u062F \u0644\u0696 \u062A\u0631 \u0644\u0696\u0647 {days} \u0648\u0631\u0681\u06D0 \u0648\u0644\u0631\u064A.",
1262
+ rangeTooLong: "\u062F \u0646\u06D0\u067C\u0648 \u0644\u0693 \u0628\u0627\u06CC\u062F \u0644\u0647 {days} \u0648\u0631\u0681\u0648 \u0632\u06CC\u0627\u062A \u0646\u0647 \u0648\u064A."
1263
+ }
1264
+ };
1265
+
1266
+ // src/locales/registry.ts
1267
+ var CALENDAR_SYSTEMS = [
1268
+ "afghan",
1269
+ "iranian",
1270
+ "gregorian"
1271
+ ];
1272
+ var NUMERAL_SYSTEMS = [
1273
+ "latin",
1274
+ "persian",
1275
+ "arabic"
1276
+ ];
1277
+ var UI_KEYS = [
1278
+ "today",
1279
+ "clear",
1280
+ "cancel",
1281
+ "apply",
1282
+ "previousMonth",
1283
+ "nextMonth",
1284
+ "previousYear",
1285
+ "nextYear",
1286
+ "selectMonth",
1287
+ "selectYear",
1288
+ "startDate",
1289
+ "endDate",
1290
+ "noDateSelected",
1291
+ "invalidDate",
1292
+ "selectStartDate",
1293
+ "rangeIncludesDisabledDate",
1294
+ "rangeTooShort",
1295
+ "rangeTooLong"
1296
+ ];
1297
+ var WEEKDAY_ARRAY_KEYS = ["full", "short", "narrow"];
1298
+ var registry = /* @__PURE__ */ new Map();
1299
+ function isRecord(value) {
1300
+ return typeof value === "object" && value !== null;
1301
+ }
1302
+ function isNonEmptyString(value) {
1303
+ return typeof value === "string" && value.trim().length > 0;
1304
+ }
1305
+ function isMonthNameList(value) {
1306
+ return Array.isArray(value) && value.length === 12 && value.every(isNonEmptyString);
1307
+ }
1308
+ function isCalendarMonthNames(value) {
1309
+ if (!isRecord(value)) {
1310
+ return false;
1311
+ }
1312
+ return CALENDAR_SYSTEMS.every((calendar) => isMonthNameList(value[calendar]));
1313
+ }
1314
+ function isWeekdayNameList(value) {
1315
+ return Array.isArray(value) && value.length === 7 && value.every(isNonEmptyString);
1316
+ }
1317
+ function isWeekday(value) {
1318
+ return Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 7;
1319
+ }
1320
+ function isLocaleDefinition(value) {
1321
+ if (!isRecord(value)) {
1322
+ return false;
1323
+ }
1324
+ if (!isNonEmptyString(value.code) || !/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/.test(value.code) || !isNonEmptyString(value.name) || !isNonEmptyString(value.nativeName) || value.direction !== "rtl" && value.direction !== "ltr" || !isCalendarMonthNames(value.months) || !isCalendarMonthNames(value.shortMonths) || !isWeekday(value.firstDayOfWeek) || !NUMERAL_SYSTEMS.some((system) => system === value.defaultNumeralSystem)) {
1325
+ return false;
1326
+ }
1327
+ const weekdays = value.weekdays;
1328
+ if (!isRecord(weekdays)) {
1329
+ return false;
1330
+ }
1331
+ if (!WEEKDAY_ARRAY_KEYS.every((key) => isWeekdayNameList(weekdays[key]))) {
1332
+ return false;
1333
+ }
1334
+ const ui = value.ui;
1335
+ if (!isRecord(ui)) {
1336
+ return false;
1337
+ }
1338
+ return UI_KEYS.every((key) => isNonEmptyString(ui[key]));
1339
+ }
1340
+ function freezeMonthNameList(names) {
1341
+ return Object.freeze([
1342
+ names[0],
1343
+ names[1],
1344
+ names[2],
1345
+ names[3],
1346
+ names[4],
1347
+ names[5],
1348
+ names[6],
1349
+ names[7],
1350
+ names[8],
1351
+ names[9],
1352
+ names[10],
1353
+ names[11]
1354
+ ]);
1355
+ }
1356
+ function freezeCalendarMonthNames(monthNames) {
1357
+ return Object.freeze({
1358
+ afghan: freezeMonthNameList(monthNames.afghan),
1359
+ iranian: freezeMonthNameList(monthNames.iranian),
1360
+ gregorian: freezeMonthNameList(monthNames.gregorian)
1361
+ });
1362
+ }
1363
+ function freezeWeekdayNameList(names) {
1364
+ return Object.freeze([
1365
+ names[0],
1366
+ names[1],
1367
+ names[2],
1368
+ names[3],
1369
+ names[4],
1370
+ names[5],
1371
+ names[6]
1372
+ ]);
1373
+ }
1374
+ function freezeLocale(locale) {
1375
+ return Object.freeze({
1376
+ code: locale.code,
1377
+ name: locale.name,
1378
+ nativeName: locale.nativeName,
1379
+ direction: locale.direction,
1380
+ months: freezeCalendarMonthNames(locale.months),
1381
+ shortMonths: freezeCalendarMonthNames(locale.shortMonths),
1382
+ weekdays: Object.freeze({
1383
+ full: freezeWeekdayNameList(locale.weekdays.full),
1384
+ short: freezeWeekdayNameList(locale.weekdays.short),
1385
+ narrow: freezeWeekdayNameList(locale.weekdays.narrow)
1386
+ }),
1387
+ firstDayOfWeek: locale.firstDayOfWeek,
1388
+ defaultNumeralSystem: locale.defaultNumeralSystem,
1389
+ ui: Object.freeze({ ...locale.ui })
1390
+ });
1391
+ }
1392
+ for (const locale of [faAfLocale, psAfLocale, faIrLocale, enLocale]) {
1393
+ registry.set(locale.code, freezeLocale(locale));
1394
+ }
1395
+ function getLocale(localeCode, fallbackLocale) {
1396
+ const locale = registry.get(localeCode);
1397
+ if (locale) {
1398
+ return locale;
1399
+ }
1400
+ if (fallbackLocale !== void 0) {
1401
+ const fallback = registry.get(fallbackLocale);
1402
+ if (fallback) {
1403
+ return fallback;
1404
+ }
1405
+ throw new RangeError(
1406
+ `Unknown fallback locale "${fallbackLocale}". Available locales: ${getAvailableLocales().join(", ")}.`
1407
+ );
1408
+ }
1409
+ throw new RangeError(
1410
+ `Unknown locale "${localeCode}". Available locales: ${getAvailableLocales().join(", ")}.`
1411
+ );
1412
+ }
1413
+ function registerLocale(locale, options = {}) {
1414
+ if (!isLocaleDefinition(locale)) {
1415
+ throw new TypeError(
1416
+ "Invalid locale definition; all locale fields are required."
1417
+ );
1418
+ }
1419
+ if (!isRecord(options) || options.replace !== void 0 && typeof options.replace !== "boolean") {
1420
+ throw new TypeError(
1421
+ "Locale registration options must contain a boolean replace flag."
1422
+ );
1423
+ }
1424
+ if (registry.has(locale.code) && options.replace !== true) {
1425
+ throw new RangeError(
1426
+ `Locale "${locale.code}" is already registered; pass { replace: true } to replace it.`
1427
+ );
1428
+ }
1429
+ const registeredLocale = freezeLocale(locale);
1430
+ registry.set(registeredLocale.code, registeredLocale);
1431
+ return registeredLocale;
1432
+ }
1433
+ function getAvailableLocales() {
1434
+ return Object.freeze([...registry.keys()]);
1435
+ }
1436
+ function getLocaleDirection(localeCode, fallbackLocale) {
1437
+ return getLocale(localeCode, fallbackLocale).direction;
1438
+ }
1439
+ function getOrderedWeekdays(localeCode, fallbackLocale) {
1440
+ const locale = getLocale(localeCode, fallbackLocale);
1441
+ const ordered = [];
1442
+ for (let offset = 0; offset < 7; offset += 1) {
1443
+ const weekday = (locale.firstDayOfWeek - 1 + offset) % 7 + 1;
1444
+ const index = weekday - 1;
1445
+ ordered.push({
1446
+ weekday,
1447
+ full: locale.weekdays.full[index],
1448
+ short: locale.weekdays.short[index],
1449
+ narrow: locale.weekdays.narrow[index]
1450
+ });
1451
+ }
1452
+ return Object.freeze(ordered.map((weekday) => Object.freeze(weekday)));
1453
+ }
1454
+
1455
+ // src/locales/numerals.ts
1456
+ var DIGITS = {
1457
+ latin: "0123456789",
1458
+ persian: "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9",
1459
+ arabic: "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669"
1460
+ };
1461
+ function getDigitSet(numerals) {
1462
+ const digitSet = Object.hasOwn(DIGITS, numerals) ? DIGITS[numerals] : void 0;
1463
+ if (!digitSet) {
1464
+ throw new RangeError(`Unsupported numeral system: ${numerals}.`);
1465
+ }
1466
+ return digitSet;
1467
+ }
1468
+ function toLocalizedDigits(value, numerals) {
1469
+ const digits = getDigitSet(numerals);
1470
+ return String(value).replace(/[0-9]/g, (digit) => digits[Number(digit)]);
1471
+ }
1472
+ function fromLocalizedDigits(value) {
1473
+ const latinDigits = DIGITS.latin;
1474
+ const localizedDigits = `${DIGITS.persian}${DIGITS.arabic}`;
1475
+ return String(value).replace(/[۰-۹٠-٩]/g, (digit) => {
1476
+ const index = localizedDigits.indexOf(digit);
1477
+ return latinDigits[index % 10];
1478
+ });
1479
+ }
1480
+
1481
+ // src/core/formatting/format-calendar-date.ts
1482
+ var calendarAdapters = {
1483
+ afghan: afghanCalendarAdapter,
1484
+ iranian: iranianCalendarAdapter,
1485
+ gregorian: gregorianCalendarAdapter
1486
+ };
1487
+ var DATE_FORMATS = [
1488
+ "short",
1489
+ "medium",
1490
+ "long",
1491
+ "full"
1492
+ ];
1493
+ function paddedDatePart(value, width) {
1494
+ const magnitude = String(Math.abs(value)).padStart(width, "0");
1495
+ return value < 0 ? `-${magnitude}` : magnitude;
1496
+ }
1497
+ function formatCalendarDate(date, options) {
1498
+ if (!Object.hasOwn(calendarAdapters, options.calendar)) {
1499
+ throw new RangeError(`Unsupported calendar system: ${options.calendar}.`);
1500
+ }
1501
+ const format = options.format ?? "short";
1502
+ if (!DATE_FORMATS.includes(format)) {
1503
+ throw new RangeError(`Unsupported calendar date format: ${format}.`);
1504
+ }
1505
+ const locale = getLocale(options.locale, options.fallbackLocale);
1506
+ const numerals = options.numerals ?? locale.defaultNumeralSystem;
1507
+ const adapter = calendarAdapters[options.calendar];
1508
+ const jdn = adapter.toJdn(date);
1509
+ const year = toLocalizedDigits(paddedDatePart(date.year, 4), numerals);
1510
+ const monthNumber = toLocalizedDigits(
1511
+ paddedDatePart(date.month, 2),
1512
+ numerals
1513
+ );
1514
+ const dayNumber = toLocalizedDigits(paddedDatePart(date.day, 2), numerals);
1515
+ if (format === "short") {
1516
+ return `${year}/${monthNumber}/${dayNumber}`;
1517
+ }
1518
+ const monthName = locale.months[options.calendar][date.month - 1];
1519
+ const weekdayIndex = getWeekday(jdn) - 1;
1520
+ const month = format === "medium" ? locale.shortMonths[options.calendar][date.month - 1] : monthName;
1521
+ const day = toLocalizedDigits(String(date.day), numerals);
1522
+ if (format === "medium") {
1523
+ return locale.direction === "rtl" ? `${day} ${month} ${year}` : `${month} ${day}, ${year}`;
1524
+ }
1525
+ const weekday = format === "long" ? locale.weekdays.short[weekdayIndex] : locale.weekdays.full[weekdayIndex];
1526
+ return locale.direction === "rtl" ? `${weekday}\u060C ${day} ${month} ${year}` : `${weekday}, ${month} ${day}, ${year}`;
1527
+ }
1528
+
1529
+ // src/components/Calendar/Calendar.tsx
1530
+ var import_react = require("react");
1531
+
1532
+ // src/components/calendar-utils.ts
1533
+ function getDateKey(date) {
1534
+ return `${date.year}-${date.month}-${date.day}`;
1535
+ }
1536
+ function normalizeCalendarMonth(date, calendar) {
1537
+ const month = { year: date.year, month: date.month, day: 1 };
1538
+ getCalendarAdapter(calendar).toJdn(month);
1539
+ return month;
1540
+ }
1541
+ function getFallbackDate(calendar) {
1542
+ return convertDate({ year: 2e3, month: 1, day: 1 }, "gregorian", calendar);
1543
+ }
1544
+ function getMonthTitle(month, calendar, locale, numerals) {
1545
+ const name = locale.months[calendar][month.month - 1];
1546
+ const year = toLocalizedDigits(String(month.year), numerals);
1547
+ return locale.direction === "rtl" ? `${year} ${name}` : `${name} ${year}`;
1548
+ }
1549
+ function getSupportedJdnRange(calendar) {
1550
+ const adapter = getCalendarAdapter(calendar);
1551
+ const { min, max } = adapter.supportedYearRange;
1552
+ return {
1553
+ min: adapter.toJdn({ year: min, month: 1, day: 1 }),
1554
+ max: adapter.toJdn({
1555
+ year: max,
1556
+ month: 12,
1557
+ day: adapter.getMonthLength(max, 12)
1558
+ })
1559
+ };
1560
+ }
1561
+ function shiftDateWithinCalendar(date, amount, calendar, supportedJdnRange) {
1562
+ const jdn = getCalendarAdapter(calendar).toJdn(date) + amount;
1563
+ if (jdn < supportedJdnRange.min || jdn > supportedJdnRange.max) {
1564
+ return null;
1565
+ }
1566
+ return addDays(date, amount, calendar);
1567
+ }
1568
+ function isDateDisabled(date, calendar, options) {
1569
+ if (options.minDate && compareDates(date, options.minDate, calendar) < 0 || options.maxDate && compareDates(date, options.maxDate, calendar) > 0 || options.disabledDates?.some(
1570
+ (disabledDate) => compareDates(date, disabledDate, calendar) === 0
1571
+ )) {
1572
+ return true;
1573
+ }
1574
+ return options.isDateDisabled?.(date) ?? false;
1575
+ }
1576
+ function validateDateConstraints(calendar, constraints) {
1577
+ const adapter = getCalendarAdapter(calendar);
1578
+ if (constraints.minDate) {
1579
+ adapter.toJdn(constraints.minDate);
1580
+ }
1581
+ if (constraints.maxDate) {
1582
+ adapter.toJdn(constraints.maxDate);
1583
+ }
1584
+ if (constraints.minDate && constraints.maxDate && compareDates(constraints.minDate, constraints.maxDate, calendar) > 0) {
1585
+ throw new RangeError("minDate must not be later than maxDate.");
1586
+ }
1587
+ for (const date of constraints.disabledDates ?? []) {
1588
+ adapter.toJdn(date);
1589
+ }
1590
+ }
1591
+
1592
+ // src/components/Calendar/Calendar.tsx
1593
+ var import_jsx_runtime = require("react/jsx-runtime");
1594
+ function isSupportedMonth(date, calendar) {
1595
+ const { min, max } = getCalendarAdapter(calendar).supportedYearRange;
1596
+ return Number.isSafeInteger(date.year) && date.year >= min && date.year <= max && Number.isSafeInteger(date.month) && date.month >= 1 && date.month <= 12;
1597
+ }
1598
+ function getShiftedMonth(month, amount, calendar) {
1599
+ const absoluteMonth = month.year * 12 + month.month - 1 + amount;
1600
+ const targetYear = Math.floor(absoluteMonth / 12);
1601
+ const { min, max } = getCalendarAdapter(calendar).supportedYearRange;
1602
+ if (targetYear < min || targetYear > max) {
1603
+ return null;
1604
+ }
1605
+ return addMonths(month, amount, calendar);
1606
+ }
1607
+ function getWeekdayHeadings(locale, firstDayOfWeek) {
1608
+ return Array.from({ length: 7 }, (_, offset) => {
1609
+ const weekday = (firstDayOfWeek - 1 + offset) % 7 + 1;
1610
+ const index = weekday - 1;
1611
+ return {
1612
+ weekday,
1613
+ full: locale.weekdays.full[index],
1614
+ short: locale.weekdays.short[index],
1615
+ narrow: locale.weekdays.narrow[index]
1616
+ };
1617
+ });
1618
+ }
1619
+ function getCalendarCells(month, calendar, firstDayOfWeek) {
1620
+ const monthLength = getDaysInMonth(month.year, month.month, calendar);
1621
+ const leadingDays = (getDayOfWeek(month, calendar) - firstDayOfWeek + 7) % 7;
1622
+ const cellCount = Math.ceil((leadingDays + monthLength) / 7) * 7;
1623
+ const previousMonth = getShiftedMonth(month, -1, calendar);
1624
+ const nextMonth = getShiftedMonth(month, 1, calendar);
1625
+ const previousMonthLength = previousMonth ? getDaysInMonth(previousMonth.year, previousMonth.month, calendar) : 0;
1626
+ return Array.from({ length: cellCount }, (_, index) => {
1627
+ const day = index - leadingDays + 1;
1628
+ if (day < 1) {
1629
+ return {
1630
+ date: previousMonth ? {
1631
+ year: previousMonth.year,
1632
+ month: previousMonth.month,
1633
+ day: previousMonthLength + day
1634
+ } : null,
1635
+ outsideMonth: true
1636
+ };
1637
+ }
1638
+ if (day > monthLength) {
1639
+ return {
1640
+ date: nextMonth ? { ...nextMonth, day: day - monthLength } : null,
1641
+ outsideMonth: true
1642
+ };
1643
+ }
1644
+ return {
1645
+ date: { year: month.year, month: month.month, day },
1646
+ outsideMonth: false
1647
+ };
1648
+ });
1649
+ }
1650
+ function assertFirstDayOfWeek(value) {
1651
+ if (!Number.isInteger(value) || value < 1 || value > 7) {
1652
+ throw new RangeError(
1653
+ `firstDayOfWeek must be an ISO weekday from 1 to 7; received ${value}.`
1654
+ );
1655
+ }
1656
+ }
1657
+ function Calendar({
1658
+ calendar = "gregorian",
1659
+ locale: localeCode = "en",
1660
+ numerals,
1661
+ value,
1662
+ defaultValue = null,
1663
+ onChange,
1664
+ range,
1665
+ rangePreviewEnd,
1666
+ onDatePreviewChange,
1667
+ initialVisibleMonth,
1668
+ onVisibleMonthChange,
1669
+ today,
1670
+ minDate,
1671
+ maxDate,
1672
+ disabledDates,
1673
+ isDateDisabled: isDateDisabledProp,
1674
+ firstDayOfWeek,
1675
+ disabled = false,
1676
+ autoFocus = false,
1677
+ className,
1678
+ style,
1679
+ id
1680
+ }) {
1681
+ const locale = getLocale(localeCode);
1682
+ const numeralSystem = numerals ?? locale.defaultNumeralSystem;
1683
+ const effectiveFirstDay = firstDayOfWeek ?? locale.firstDayOfWeek;
1684
+ assertFirstDayOfWeek(effectiveFirstDay);
1685
+ validateDateConstraints(calendar, { minDate, maxDate, disabledDates });
1686
+ if (value) getCalendarAdapter(calendar).toJdn(value);
1687
+ if (defaultValue) getCalendarAdapter(calendar).toJdn(defaultValue);
1688
+ if (today) getCalendarAdapter(calendar).toJdn(today);
1689
+ if (range) {
1690
+ getCalendarAdapter(calendar).toJdn(range.start);
1691
+ if (range.end && compareDates(range.start, range.end, calendar) > 0) {
1692
+ throw new RangeError("range.end must not be earlier than range.start.");
1693
+ }
1694
+ }
1695
+ if (rangePreviewEnd) getCalendarAdapter(calendar).toJdn(rangePreviewEnd);
1696
+ const isControlled = value !== void 0;
1697
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react.useState)(defaultValue);
1698
+ const selectedDate = isControlled ? value ?? null : uncontrolledValue;
1699
+ const selectedDateKey = selectedDate ? getDateKey(selectedDate) : null;
1700
+ const initialDate = initialVisibleMonth ?? selectedDate ?? today ?? getFallbackDate(calendar);
1701
+ const initialMonth = normalizeCalendarMonth(initialDate, calendar);
1702
+ const [uncontrolledMonth, setUncontrolledMonth] = (0, import_react.useState)(initialMonth);
1703
+ const visibleMonth = isSupportedMonth(uncontrolledMonth, calendar) ? normalizeCalendarMonth(uncontrolledMonth, calendar) : initialMonth;
1704
+ const [activeDate, setActiveDate] = (0, import_react.useState)(() => {
1705
+ const candidate = selectedDate ?? initialMonth;
1706
+ return candidate.year === initialMonth.year && candidate.month === initialMonth.month ? candidate : initialMonth;
1707
+ });
1708
+ const cells = (0, import_react.useMemo)(
1709
+ () => getCalendarCells(visibleMonth, calendar, effectiveFirstDay),
1710
+ [visibleMonth.year, visibleMonth.month, calendar, effectiveFirstDay]
1711
+ );
1712
+ const activeIsVisible = isSupportedMonth(activeDate, calendar) && getCalendarAdapter(calendar).isValidDate(activeDate) && cells.some(
1713
+ (cell) => cell.date && getDateKey(cell.date) === getDateKey(activeDate)
1714
+ );
1715
+ const visibleActiveDate = activeIsVisible ? activeDate : visibleMonth;
1716
+ const lastSelectedDateKey = (0, import_react.useRef)(selectedDateKey);
1717
+ const weekdayHeadings = (0, import_react.useMemo)(
1718
+ () => getWeekdayHeadings(locale, effectiveFirstDay),
1719
+ [locale, effectiveFirstDay]
1720
+ );
1721
+ const supportedJdnRange = (0, import_react.useMemo)(
1722
+ () => getSupportedJdnRange(calendar),
1723
+ [calendar]
1724
+ );
1725
+ const dayButtons = (0, import_react.useRef)(/* @__PURE__ */ new Map());
1726
+ const focusActiveDate = (0, import_react.useRef)(autoFocus);
1727
+ const wasAutoFocus = (0, import_react.useRef)(autoFocus);
1728
+ (0, import_react.useEffect)(() => {
1729
+ if (lastSelectedDateKey.current === selectedDateKey) return;
1730
+ lastSelectedDateKey.current = selectedDateKey;
1731
+ if (!selectedDate) return;
1732
+ const selectedMonth = normalizeCalendarMonth(selectedDate, calendar);
1733
+ setActiveDate(selectedDate);
1734
+ if (selectedMonth.year !== visibleMonth.year || selectedMonth.month !== visibleMonth.month) {
1735
+ setUncontrolledMonth(selectedMonth);
1736
+ onVisibleMonthChange?.(selectedMonth);
1737
+ }
1738
+ }, [
1739
+ calendar,
1740
+ onVisibleMonthChange,
1741
+ selectedDate,
1742
+ selectedDateKey,
1743
+ visibleMonth.month,
1744
+ visibleMonth.year
1745
+ ]);
1746
+ (0, import_react.useEffect)(() => {
1747
+ if (!disabled && (focusActiveDate.current || autoFocus && !wasAutoFocus.current)) {
1748
+ dayButtons.current.get(getDateKey(visibleActiveDate))?.focus();
1749
+ }
1750
+ focusActiveDate.current = false;
1751
+ wasAutoFocus.current = autoFocus;
1752
+ }, [autoFocus, disabled, visibleActiveDate, cells]);
1753
+ const commitVisibleMonth = (month, nextActiveDate, focus = false) => {
1754
+ const normalized = normalizeCalendarMonth(month, calendar);
1755
+ if (normalized.year !== visibleMonth.year || normalized.month !== visibleMonth.month) {
1756
+ setUncontrolledMonth(normalized);
1757
+ onVisibleMonthChange?.(normalized);
1758
+ }
1759
+ if (nextActiveDate) {
1760
+ setActiveDate(nextActiveDate);
1761
+ focusActiveDate.current = focus;
1762
+ }
1763
+ };
1764
+ const shiftVisibleMonth = (amount, byYears = false) => {
1765
+ const target = byYears ? (() => {
1766
+ const targetYear = visibleMonth.year + amount;
1767
+ const { min, max } = getCalendarAdapter(calendar).supportedYearRange;
1768
+ return targetYear < min || targetYear > max ? null : addYears(visibleMonth, amount, calendar);
1769
+ })() : getShiftedMonth(visibleMonth, amount, calendar);
1770
+ if (!target || disabled) return;
1771
+ const activeDay = visibleActiveDate.year === visibleMonth.year && visibleActiveDate.month === visibleMonth.month ? visibleActiveDate.day : 1;
1772
+ const maxDay = getDaysInMonth(target.year, target.month, calendar);
1773
+ commitVisibleMonth(target, { ...target, day: Math.min(activeDay, maxDay) });
1774
+ };
1775
+ const selectDate = (date) => {
1776
+ if (disabled || isDateDisabled(date, calendar, {
1777
+ minDate,
1778
+ maxDate,
1779
+ disabledDates,
1780
+ isDateDisabled: isDateDisabledProp
1781
+ })) {
1782
+ return;
1783
+ }
1784
+ if (date.year !== visibleMonth.year || date.month !== visibleMonth.month) {
1785
+ commitVisibleMonth(date, date);
1786
+ } else {
1787
+ setActiveDate(date);
1788
+ }
1789
+ if (!isControlled) setUncontrolledValue(date);
1790
+ onChange?.(date);
1791
+ };
1792
+ const handleDayKeyDown = (date, event) => {
1793
+ if (disabled) return;
1794
+ let nextDate = null;
1795
+ const horizontalDirection = locale.direction === "rtl" ? -1 : 1;
1796
+ switch (event.key) {
1797
+ case "ArrowLeft":
1798
+ event.preventDefault();
1799
+ nextDate = shiftDateWithinCalendar(
1800
+ date,
1801
+ -horizontalDirection,
1802
+ calendar,
1803
+ supportedJdnRange
1804
+ );
1805
+ break;
1806
+ case "ArrowRight":
1807
+ event.preventDefault();
1808
+ nextDate = shiftDateWithinCalendar(
1809
+ date,
1810
+ horizontalDirection,
1811
+ calendar,
1812
+ supportedJdnRange
1813
+ );
1814
+ break;
1815
+ case "ArrowUp":
1816
+ event.preventDefault();
1817
+ nextDate = shiftDateWithinCalendar(
1818
+ date,
1819
+ -7,
1820
+ calendar,
1821
+ supportedJdnRange
1822
+ );
1823
+ break;
1824
+ case "ArrowDown":
1825
+ event.preventDefault();
1826
+ nextDate = shiftDateWithinCalendar(
1827
+ date,
1828
+ 7,
1829
+ calendar,
1830
+ supportedJdnRange
1831
+ );
1832
+ break;
1833
+ case "Home":
1834
+ case "End": {
1835
+ event.preventDefault();
1836
+ const offset = (getDayOfWeek(date, calendar) - effectiveFirstDay + 7) % 7;
1837
+ const amount = event.key === "Home" ? -offset : 6 - offset;
1838
+ nextDate = shiftDateWithinCalendar(
1839
+ date,
1840
+ amount,
1841
+ calendar,
1842
+ supportedJdnRange
1843
+ );
1844
+ break;
1845
+ }
1846
+ case "PageUp":
1847
+ case "PageDown": {
1848
+ event.preventDefault();
1849
+ const direction = event.key === "PageUp" ? -1 : 1;
1850
+ const amount = event.shiftKey ? direction * 12 : direction;
1851
+ const target = event.shiftKey ? (() => {
1852
+ const targetYear = date.year + direction;
1853
+ const { min, max } = getCalendarAdapter(calendar).supportedYearRange;
1854
+ return targetYear < min || targetYear > max ? null : addYears(date, direction, calendar);
1855
+ })() : getShiftedMonth(date, amount, calendar);
1856
+ if (target) {
1857
+ const month = normalizeCalendarMonth(target, calendar);
1858
+ const day = Math.min(
1859
+ target.day,
1860
+ getDaysInMonth(month.year, month.month, calendar)
1861
+ );
1862
+ commitVisibleMonth(month, { ...month, day }, true);
1863
+ }
1864
+ return;
1865
+ }
1866
+ case "Enter":
1867
+ case " ":
1868
+ event.preventDefault();
1869
+ selectDate(date);
1870
+ return;
1871
+ default:
1872
+ return;
1873
+ }
1874
+ if (nextDate) {
1875
+ event.preventDefault();
1876
+ setActiveDate(nextDate);
1877
+ focusActiveDate.current = true;
1878
+ if (nextDate.year !== visibleMonth.year || nextDate.month !== visibleMonth.month) {
1879
+ commitVisibleMonth(
1880
+ normalizeCalendarMonth(nextDate, calendar),
1881
+ nextDate,
1882
+ true
1883
+ );
1884
+ }
1885
+ }
1886
+ };
1887
+ const previousMonth = getShiftedMonth(visibleMonth, -1, calendar);
1888
+ const nextMonth = getShiftedMonth(visibleMonth, 1, calendar);
1889
+ const previousYear = visibleMonth.year > getCalendarAdapter(calendar).supportedYearRange.min;
1890
+ const nextYear = visibleMonth.year < getCalendarAdapter(calendar).supportedYearRange.max;
1891
+ const monthTitle = getMonthTitle(
1892
+ visibleMonth,
1893
+ calendar,
1894
+ locale,
1895
+ numeralSystem
1896
+ );
1897
+ const gridLabel = `${monthTitle}`;
1898
+ const rootClassName = [
1899
+ "afghan-calendar",
1900
+ disabled ? "afghan-calendar--disabled" : "",
1901
+ className ?? ""
1902
+ ].filter(Boolean).join(" ");
1903
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1904
+ "div",
1905
+ {
1906
+ className: rootClassName,
1907
+ dir: locale.direction,
1908
+ id,
1909
+ style,
1910
+ "data-calendar": calendar,
1911
+ lang: locale.code,
1912
+ onMouseLeave: () => onDatePreviewChange?.(null),
1913
+ children: [
1914
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "afghan-calendar__header", children: [
1915
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1916
+ "div",
1917
+ {
1918
+ className: "afghan-calendar__title",
1919
+ "aria-live": "polite",
1920
+ "aria-atomic": "true",
1921
+ children: monthTitle
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "afghan-calendar__navigation", children: [
1925
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1926
+ "button",
1927
+ {
1928
+ type: "button",
1929
+ className: "afghan-calendar__nav-button",
1930
+ "aria-label": locale.ui.previousYear,
1931
+ onClick: () => shiftVisibleMonth(-1, true),
1932
+ disabled: disabled || !previousYear,
1933
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", "data-nav": "previous", children: "\xAB" })
1934
+ }
1935
+ ),
1936
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1937
+ "button",
1938
+ {
1939
+ type: "button",
1940
+ className: "afghan-calendar__nav-button",
1941
+ "aria-label": locale.ui.previousMonth,
1942
+ onClick: () => shiftVisibleMonth(-1),
1943
+ disabled: disabled || !previousMonth,
1944
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", "data-nav": "previous", children: "\u2039" })
1945
+ }
1946
+ ),
1947
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1948
+ "button",
1949
+ {
1950
+ type: "button",
1951
+ className: "afghan-calendar__nav-button",
1952
+ "aria-label": locale.ui.nextMonth,
1953
+ onClick: () => shiftVisibleMonth(1),
1954
+ disabled: disabled || !nextMonth,
1955
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", "data-nav": "next", children: "\u203A" })
1956
+ }
1957
+ ),
1958
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1959
+ "button",
1960
+ {
1961
+ type: "button",
1962
+ className: "afghan-calendar__nav-button",
1963
+ "aria-label": locale.ui.nextYear,
1964
+ onClick: () => shiftVisibleMonth(1, true),
1965
+ disabled: disabled || !nextYear,
1966
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", "data-nav": "next", children: "\xBB" })
1967
+ }
1968
+ )
1969
+ ] })
1970
+ ] }),
1971
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "afghan-calendar__grid", role: "grid", "aria-label": gridLabel, children: [
1972
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "afghan-calendar__weekdays", role: "row", children: weekdayHeadings.map((weekday) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1973
+ "div",
1974
+ {
1975
+ className: "afghan-calendar__weekday",
1976
+ role: "columnheader",
1977
+ "aria-label": weekday.full,
1978
+ title: weekday.full,
1979
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", children: weekday.short })
1980
+ },
1981
+ weekday.weekday
1982
+ )) }),
1983
+ Array.from({ length: cells.length / 7 }, (_, row) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "afghan-calendar__week", role: "row", children: cells.slice(row * 7, row * 7 + 7).map((cell, index) => {
1984
+ if (!cell.date) {
1985
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1986
+ "div",
1987
+ {
1988
+ className: "afghan-calendar__empty-cell",
1989
+ role: "gridcell",
1990
+ "aria-hidden": "true"
1991
+ },
1992
+ `empty-${row}-${index}`
1993
+ );
1994
+ }
1995
+ const date = cell.date;
1996
+ const key = getDateKey(date);
1997
+ const selected = selectedDate !== null && selectedDate !== void 0 && getDateKey(selectedDate) === key;
1998
+ const isRangeStart = range !== void 0 && compareDates(date, range.start, calendar) === 0;
1999
+ const isRangeEnd = range?.end !== null && range?.end !== void 0 && compareDates(date, range.end, calendar) === 0;
2000
+ const isInRange = range?.end !== null && range?.end !== void 0 && compareDates(date, range.start, calendar) > 0 && compareDates(date, range.end, calendar) < 0;
2001
+ const isRangePreview = range?.end === null && rangePreviewEnd !== void 0 && rangePreviewEnd !== null && compareDates(rangePreviewEnd, range.start, calendar) > 0 && compareDates(date, range.start, calendar) > 0 && compareDates(date, rangePreviewEnd, calendar) < 0;
2002
+ const isRangePreviewEnd = range?.end === null && rangePreviewEnd !== void 0 && rangePreviewEnd !== null && compareDates(date, rangePreviewEnd, calendar) === 0;
2003
+ const isRangeSelected = isRangeStart || isRangeEnd || isInRange;
2004
+ const isToday = today !== void 0 && getDateKey(today) === key;
2005
+ const dateDisabled = isDateDisabled(date, calendar, {
2006
+ minDate,
2007
+ maxDate,
2008
+ disabledDates,
2009
+ isDateDisabled: isDateDisabledProp
2010
+ });
2011
+ const active = getDateKey(visibleActiveDate) === key;
2012
+ const ariaLabel = formatCalendarDate(date, {
2013
+ calendar,
2014
+ locale: localeCode,
2015
+ numerals: numeralSystem,
2016
+ format: "full"
2017
+ });
2018
+ const dayLabel = toLocalizedDigits(
2019
+ String(date.day),
2020
+ numeralSystem
2021
+ );
2022
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2023
+ "div",
2024
+ {
2025
+ className: "afghan-calendar__cell",
2026
+ role: "gridcell",
2027
+ "aria-selected": selected || isRangeSelected,
2028
+ "data-outside-month": cell.outsideMonth || void 0,
2029
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2030
+ "button",
2031
+ {
2032
+ type: "button",
2033
+ className: "afghan-calendar__day",
2034
+ ref: (element) => {
2035
+ if (element) dayButtons.current.set(key, element);
2036
+ else dayButtons.current.delete(key);
2037
+ },
2038
+ tabIndex: active ? 0 : -1,
2039
+ "aria-label": ariaLabel,
2040
+ "aria-current": isToday ? "date" : void 0,
2041
+ "aria-pressed": selected || isRangeStart || isRangeEnd,
2042
+ disabled,
2043
+ "aria-disabled": dateDisabled || disabled || void 0,
2044
+ "data-outside-month": cell.outsideMonth || void 0,
2045
+ "data-selected": selected || isRangeStart || isRangeEnd || void 0,
2046
+ "data-range-start": isRangeStart || void 0,
2047
+ "data-range-end": isRangeEnd || void 0,
2048
+ "data-in-range": isInRange || void 0,
2049
+ "data-range-preview": isRangePreview || void 0,
2050
+ "data-range-preview-end": isRangePreviewEnd || void 0,
2051
+ "data-today": isToday || void 0,
2052
+ "data-disabled": dateDisabled || disabled || void 0,
2053
+ onClick: () => selectDate(date),
2054
+ onMouseEnter: () => onDatePreviewChange?.(date),
2055
+ onFocus: () => onDatePreviewChange?.(date),
2056
+ onKeyDown: (event) => handleDayKeyDown(date, event),
2057
+ children: dayLabel
2058
+ }
2059
+ )
2060
+ },
2061
+ key
2062
+ );
2063
+ }) }, row))
2064
+ ] })
2065
+ ]
2066
+ }
2067
+ );
2068
+ }
2069
+
2070
+ // src/components/DatePicker/DatePicker.tsx
2071
+ var import_react2 = require("react");
2072
+
2073
+ // src/components/date-input-utils.ts
2074
+ function parseCalendarDateText(input, format, calendar, locale) {
2075
+ const normalized = fromLocalizedDigits(input.trim());
2076
+ if (format === "short") {
2077
+ const match = /^(-?\d{1,6})\/(\d{1,2})\/(\d{1,2})$/.exec(normalized);
2078
+ if (!match) return null;
2079
+ return {
2080
+ year: Number(match[1]),
2081
+ month: Number(match[2]),
2082
+ day: Number(match[3])
2083
+ };
2084
+ }
2085
+ const monthNames = format === "medium" ? locale.shortMonths[calendar] : locale.months[calendar];
2086
+ const monthName = [...monthNames].sort((left, right) => right.length - left.length).find((name) => normalized.includes(name));
2087
+ if (!monthName) return null;
2088
+ const numberParts = normalized.replace(monthName, " ").match(/-?\d+/g);
2089
+ if (!numberParts || numberParts.length !== 2) return null;
2090
+ return {
2091
+ year: Number(numberParts[1]),
2092
+ month: monthNames.indexOf(monthName) + 1,
2093
+ day: Number(numberParts[0])
2094
+ };
2095
+ }
2096
+
2097
+ // src/components/DatePicker/DatePicker.tsx
2098
+ var import_jsx_runtime2 = require("react/jsx-runtime");
2099
+ function DatePicker({
2100
+ calendar = "gregorian",
2101
+ locale: localeCode = "en",
2102
+ numerals,
2103
+ format = "short",
2104
+ value,
2105
+ defaultValue = null,
2106
+ onChange,
2107
+ minDate,
2108
+ maxDate,
2109
+ disabledDates,
2110
+ isDateDisabled: isDateDisabledProp,
2111
+ disabled = false,
2112
+ readOnly = false,
2113
+ placeholder,
2114
+ firstDayOfWeek,
2115
+ className,
2116
+ style,
2117
+ id,
2118
+ name,
2119
+ required = false,
2120
+ label,
2121
+ "aria-label": ariaLabel,
2122
+ today,
2123
+ initialVisibleMonth,
2124
+ open,
2125
+ defaultOpen = false,
2126
+ onOpenChange,
2127
+ closeOnSelect = true
2128
+ }) {
2129
+ const locale = getLocale(localeCode);
2130
+ const numeralSystem = numerals ?? locale.defaultNumeralSystem;
2131
+ validateDateConstraints(calendar, { minDate, maxDate, disabledDates });
2132
+ if (value) compareDates(value, value, calendar);
2133
+ if (defaultValue) compareDates(defaultValue, defaultValue, calendar);
2134
+ if (today) compareDates(today, today, calendar);
2135
+ if (initialVisibleMonth) {
2136
+ compareDates(
2137
+ { ...initialVisibleMonth, day: 1 },
2138
+ { ...initialVisibleMonth, day: 1 },
2139
+ calendar
2140
+ );
2141
+ }
2142
+ const isValueControlled = value !== void 0;
2143
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react2.useState)(defaultValue);
2144
+ const selectedDate = isValueControlled ? value ?? null : uncontrolledValue;
2145
+ const formattedValue = selectedDate ? formatCalendarDate(selectedDate, {
2146
+ calendar,
2147
+ locale: localeCode,
2148
+ numerals: numeralSystem,
2149
+ format
2150
+ }) : "";
2151
+ const [inputValue, setInputValue] = (0, import_react2.useState)(formattedValue);
2152
+ const [inputInvalid, setInputInvalid] = (0, import_react2.useState)(false);
2153
+ const isOpenControlled = open !== void 0;
2154
+ const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react2.useState)(defaultOpen);
2155
+ const isOpen = isOpenControlled ? open : uncontrolledOpen;
2156
+ const [focusCalendarOnOpen, setFocusCalendarOnOpen] = (0, import_react2.useState)(false);
2157
+ const generatedId = (0, import_react2.useId)();
2158
+ const inputId = id ?? `afghan-date-picker-${generatedId}`;
2159
+ const popoverId = `${inputId}-calendar`;
2160
+ const errorId = `${inputId}-error`;
2161
+ const containerRef = (0, import_react2.useRef)(null);
2162
+ const inputRef = (0, import_react2.useRef)(null);
2163
+ const returnFocus = (0, import_react2.useRef)(false);
2164
+ const changeOpen = (0, import_react2.useCallback)(
2165
+ (nextOpen) => {
2166
+ if (disabled && nextOpen) return;
2167
+ if (!isOpenControlled) setUncontrolledOpen(nextOpen);
2168
+ onOpenChange?.(nextOpen);
2169
+ },
2170
+ [disabled, isOpenControlled, onOpenChange]
2171
+ );
2172
+ (0, import_react2.useEffect)(() => {
2173
+ setInputValue(formattedValue);
2174
+ setInputInvalid(false);
2175
+ }, [formattedValue]);
2176
+ (0, import_react2.useEffect)(() => {
2177
+ if (!isOpen) {
2178
+ if (returnFocus.current) {
2179
+ inputRef.current?.focus();
2180
+ returnFocus.current = false;
2181
+ }
2182
+ return;
2183
+ }
2184
+ const handleOutsidePointer = (event) => {
2185
+ if (containerRef.current && event.target instanceof Node && !containerRef.current.contains(event.target)) {
2186
+ changeOpen(false);
2187
+ }
2188
+ };
2189
+ document.addEventListener("pointerdown", handleOutsidePointer);
2190
+ return () => document.removeEventListener("pointerdown", handleOutsidePointer);
2191
+ }, [isOpen, changeOpen]);
2192
+ const changeValue = (nextValue) => {
2193
+ if (!isValueControlled) setUncontrolledValue(nextValue);
2194
+ onChange?.(nextValue);
2195
+ setInputInvalid(false);
2196
+ if (!isValueControlled) {
2197
+ setInputValue(
2198
+ nextValue ? formatCalendarDate(nextValue, {
2199
+ calendar,
2200
+ locale: localeCode,
2201
+ numerals: numeralSystem,
2202
+ format
2203
+ }) : ""
2204
+ );
2205
+ }
2206
+ };
2207
+ const commitInput = () => {
2208
+ if (readOnly || disabled) return false;
2209
+ if (inputValue.trim() === "") {
2210
+ if (selectedDate !== null) changeValue(null);
2211
+ setInputValue("");
2212
+ return true;
2213
+ }
2214
+ const parsedDate = parseCalendarDateText(
2215
+ inputValue,
2216
+ format,
2217
+ calendar,
2218
+ locale
2219
+ );
2220
+ if (!parsedDate) {
2221
+ setInputInvalid(true);
2222
+ return false;
2223
+ }
2224
+ try {
2225
+ compareDates(parsedDate, parsedDate, calendar);
2226
+ } catch (error) {
2227
+ if (error instanceof RangeError) {
2228
+ setInputInvalid(true);
2229
+ return false;
2230
+ }
2231
+ throw error;
2232
+ }
2233
+ if (isDateDisabled(parsedDate, calendar, {
2234
+ minDate,
2235
+ maxDate,
2236
+ disabledDates,
2237
+ isDateDisabled: isDateDisabledProp
2238
+ })) {
2239
+ setInputInvalid(true);
2240
+ return false;
2241
+ }
2242
+ changeValue(parsedDate);
2243
+ if (!isValueControlled) {
2244
+ setInputValue(
2245
+ formatCalendarDate(parsedDate, {
2246
+ calendar,
2247
+ locale: localeCode,
2248
+ numerals: numeralSystem,
2249
+ format
2250
+ })
2251
+ );
2252
+ }
2253
+ return true;
2254
+ };
2255
+ const handleKeyDown = (event) => {
2256
+ if (event.key === "Escape" && isOpen) {
2257
+ event.preventDefault();
2258
+ event.stopPropagation();
2259
+ returnFocus.current = true;
2260
+ changeOpen(false);
2261
+ }
2262
+ };
2263
+ const handleCalendarChange = (date) => {
2264
+ changeValue(date);
2265
+ if (closeOnSelect) {
2266
+ returnFocus.current = true;
2267
+ changeOpen(false);
2268
+ }
2269
+ };
2270
+ const rootClassName = [
2271
+ "afghan-date-picker",
2272
+ disabled ? "afghan-date-picker--disabled" : "",
2273
+ className ?? ""
2274
+ ].filter(Boolean).join(" ");
2275
+ const effectiveLabel = ariaLabel ?? label ?? locale.ui.startDate;
2276
+ const initialMonth = initialVisibleMonth ?? selectedDate ?? today ?? getFallbackDate(calendar);
2277
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2278
+ "div",
2279
+ {
2280
+ className: rootClassName,
2281
+ dir: locale.direction,
2282
+ lang: locale.code,
2283
+ "data-calendar": calendar,
2284
+ ref: containerRef,
2285
+ style,
2286
+ onKeyDown: handleKeyDown,
2287
+ children: [
2288
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2289
+ "label",
2290
+ {
2291
+ className: label ? "afghan-date-picker__label" : "afghan-date-picker__label afghan-date-picker__visually-hidden",
2292
+ htmlFor: inputId,
2293
+ children: label ?? effectiveLabel
2294
+ }
2295
+ ),
2296
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "afghan-date-picker__control", children: [
2297
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2298
+ "input",
2299
+ {
2300
+ ref: inputRef,
2301
+ id: inputId,
2302
+ className: "afghan-date-picker__input",
2303
+ type: "text",
2304
+ name,
2305
+ value: inputValue,
2306
+ placeholder,
2307
+ disabled,
2308
+ readOnly,
2309
+ required,
2310
+ autoComplete: "off",
2311
+ "aria-label": ariaLabel,
2312
+ "aria-haspopup": "dialog",
2313
+ "aria-expanded": isOpen,
2314
+ "aria-controls": popoverId,
2315
+ "aria-invalid": inputInvalid || void 0,
2316
+ "aria-describedby": inputInvalid ? errorId : void 0,
2317
+ onClick: () => {
2318
+ setFocusCalendarOnOpen(false);
2319
+ changeOpen(true);
2320
+ },
2321
+ onChange: (event) => {
2322
+ setInputValue(event.currentTarget.value);
2323
+ setInputInvalid(false);
2324
+ },
2325
+ onBlur: () => {
2326
+ if (!readOnly && !disabled) commitInput();
2327
+ },
2328
+ onKeyDown: (event) => {
2329
+ if (event.key === "ArrowDown" && !disabled) {
2330
+ event.preventDefault();
2331
+ setFocusCalendarOnOpen(true);
2332
+ changeOpen(true);
2333
+ } else if (event.key === "Enter") {
2334
+ event.preventDefault();
2335
+ commitInput();
2336
+ }
2337
+ }
2338
+ }
2339
+ ),
2340
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2341
+ "button",
2342
+ {
2343
+ type: "button",
2344
+ className: "afghan-date-picker__trigger",
2345
+ "aria-label": `${locale.ui.selectMonth}, ${locale.ui.selectYear}`,
2346
+ "aria-haspopup": "dialog",
2347
+ "aria-expanded": isOpen,
2348
+ "aria-controls": popoverId,
2349
+ disabled,
2350
+ onClick: () => {
2351
+ setFocusCalendarOnOpen(true);
2352
+ changeOpen(true);
2353
+ },
2354
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2355
+ "svg",
2356
+ {
2357
+ "aria-hidden": "true",
2358
+ viewBox: "0 0 24 24",
2359
+ width: "20",
2360
+ height: "20",
2361
+ focusable: "false",
2362
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2363
+ "path",
2364
+ {
2365
+ d: "M7 2v3m10-3v3M4 9h16M5 4h14a1 1 0 0 1 1 1v14H4V5a1 1 0 0 1 1-1Z",
2366
+ fill: "none",
2367
+ stroke: "currentColor",
2368
+ strokeWidth: "1.7",
2369
+ strokeLinecap: "round",
2370
+ strokeLinejoin: "round"
2371
+ }
2372
+ )
2373
+ }
2374
+ )
2375
+ }
2376
+ )
2377
+ ] }),
2378
+ inputInvalid && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "afghan-date-picker__error", id: errorId, role: "alert", children: locale.ui.invalidDate }),
2379
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2380
+ "div",
2381
+ {
2382
+ className: "afghan-date-picker__popover",
2383
+ id: popoverId,
2384
+ role: "dialog",
2385
+ "aria-label": `${locale.ui.selectMonth}, ${locale.ui.selectYear}`,
2386
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2387
+ Calendar,
2388
+ {
2389
+ calendar,
2390
+ locale: localeCode,
2391
+ numerals: numeralSystem,
2392
+ value: selectedDate,
2393
+ onChange: handleCalendarChange,
2394
+ initialVisibleMonth: initialMonth,
2395
+ ...today !== void 0 ? { today } : {},
2396
+ ...minDate !== void 0 ? { minDate } : {},
2397
+ ...maxDate !== void 0 ? { maxDate } : {},
2398
+ ...disabledDates !== void 0 ? { disabledDates } : {},
2399
+ ...isDateDisabledProp !== void 0 ? { isDateDisabled: isDateDisabledProp } : {},
2400
+ ...firstDayOfWeek !== void 0 ? { firstDayOfWeek } : {},
2401
+ disabled,
2402
+ autoFocus: focusCalendarOnOpen
2403
+ }
2404
+ )
2405
+ }
2406
+ )
2407
+ ]
2408
+ }
2409
+ );
2410
+ }
2411
+
2412
+ // src/components/date-range-picker/DateRangePicker.tsx
2413
+ var import_react3 = require("react");
2414
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2415
+ function areRangesEqual(left, right) {
2416
+ if (left === right) return true;
2417
+ if (!left || !right) return false;
2418
+ return getDateKey(left.start) === getDateKey(right.start) && (left.end === null ? right.end === null : right.end !== null && getDateKey(left.end) === getDateKey(right.end));
2419
+ }
2420
+ function assertRangeLengthOptions(minRangeDays, maxRangeDays) {
2421
+ for (const [name, value] of [
2422
+ ["minRangeDays", minRangeDays],
2423
+ ["maxRangeDays", maxRangeDays]
2424
+ ]) {
2425
+ if (value !== void 0 && (!Number.isSafeInteger(value) || value < 1)) {
2426
+ throw new RangeError(`${name} must be a positive safe integer.`);
2427
+ }
2428
+ }
2429
+ if (minRangeDays !== void 0 && maxRangeDays !== void 0 && minRangeDays > maxRangeDays) {
2430
+ throw new RangeError("minRangeDays must not exceed maxRangeDays.");
2431
+ }
2432
+ }
2433
+ function formatRangeMessage(template, days, numeralSystem) {
2434
+ return template.replace(
2435
+ "{days}",
2436
+ toLocalizedDigits(String(days), numeralSystem)
2437
+ );
2438
+ }
2439
+ function getRangeValidationMessage(range, constraints) {
2440
+ const { calendar, locale, minDate, maxDate, disabledDates, isDateDisabled: isDateDisabled2 } = constraints;
2441
+ const { start, end } = range;
2442
+ const adapter = getCalendarAdapter(calendar);
2443
+ const startJdn = adapter.toJdn(start);
2444
+ if (!end) {
2445
+ if (minDate && compareDates(start, minDate, calendar) < 0 || maxDate && compareDates(start, maxDate, calendar) > 0) {
2446
+ return locale.ui.invalidDate;
2447
+ }
2448
+ if (disabledDates?.some((date) => adapter.toJdn(date) === startJdn) || isDateDisabled2?.(start)) {
2449
+ return locale.ui.rangeIncludesDisabledDate;
2450
+ }
2451
+ return null;
2452
+ }
2453
+ const endJdn = adapter.toJdn(end);
2454
+ if (endJdn < startJdn) return locale.ui.invalidDate;
2455
+ const days = differenceInDays(end, start, calendar) + 1;
2456
+ if (constraints.minRangeDays !== void 0 && days < constraints.minRangeDays) {
2457
+ return formatRangeMessage(
2458
+ locale.ui.rangeTooShort,
2459
+ constraints.minRangeDays,
2460
+ constraints.numeralSystem
2461
+ );
2462
+ }
2463
+ if (constraints.maxRangeDays !== void 0 && days > constraints.maxRangeDays) {
2464
+ return formatRangeMessage(
2465
+ locale.ui.rangeTooLong,
2466
+ constraints.maxRangeDays,
2467
+ constraints.numeralSystem
2468
+ );
2469
+ }
2470
+ if (minDate && compareDates(start, minDate, calendar) < 0 || maxDate && compareDates(end, maxDate, calendar) > 0) {
2471
+ return locale.ui.invalidDate;
2472
+ }
2473
+ if (disabledDates?.some((date) => {
2474
+ const jdn = adapter.toJdn(date);
2475
+ return jdn >= startJdn && jdn <= endJdn;
2476
+ })) {
2477
+ return locale.ui.rangeIncludesDisabledDate;
2478
+ }
2479
+ if (isDateDisabled2) {
2480
+ for (let offset = 0; offset < days; offset += 1) {
2481
+ if (isDateDisabled2(addDays(start, offset, calendar))) {
2482
+ return locale.ui.rangeIncludesDisabledDate;
2483
+ }
2484
+ }
2485
+ }
2486
+ return null;
2487
+ }
2488
+ function assertValidRange(range, constraints) {
2489
+ if (!range) return;
2490
+ const adapter = getCalendarAdapter(constraints.calendar);
2491
+ adapter.toJdn(range.start);
2492
+ if (range.end) {
2493
+ adapter.toJdn(range.end);
2494
+ if (compareDates(range.start, range.end, constraints.calendar) > 0) {
2495
+ throw new RangeError("range.end must not be earlier than range.start.");
2496
+ }
2497
+ const message = getRangeValidationMessage(range, constraints);
2498
+ if (message) throw new RangeError(message);
2499
+ }
2500
+ }
2501
+ function DateRangePicker({
2502
+ calendar = "gregorian",
2503
+ locale: localeCode = "en",
2504
+ numerals,
2505
+ format = "short",
2506
+ value,
2507
+ defaultValue = null,
2508
+ onChange,
2509
+ onIncompleteChange,
2510
+ onValidationError,
2511
+ minDate,
2512
+ maxDate,
2513
+ disabledDates,
2514
+ isDateDisabled: isDateDisabledProp,
2515
+ minRangeDays,
2516
+ maxRangeDays,
2517
+ disabled = false,
2518
+ readOnly = false,
2519
+ required = false,
2520
+ placeholder,
2521
+ startPlaceholder,
2522
+ endPlaceholder,
2523
+ separator = "\u2013",
2524
+ startLabel,
2525
+ endLabel,
2526
+ firstDayOfWeek,
2527
+ today,
2528
+ initialVisibleMonth,
2529
+ closeOnSelect = false,
2530
+ open,
2531
+ defaultOpen = false,
2532
+ onOpenChange,
2533
+ className,
2534
+ style,
2535
+ id,
2536
+ name
2537
+ }) {
2538
+ const locale = getLocale(localeCode);
2539
+ const numeralSystem = numerals ?? locale.defaultNumeralSystem;
2540
+ const adapter = getCalendarAdapter(calendar);
2541
+ const constraints = {
2542
+ calendar,
2543
+ locale,
2544
+ numeralSystem,
2545
+ ...minDate !== void 0 ? { minDate } : {},
2546
+ ...maxDate !== void 0 ? { maxDate } : {},
2547
+ ...disabledDates !== void 0 ? { disabledDates } : {},
2548
+ ...isDateDisabledProp !== void 0 ? { isDateDisabled: isDateDisabledProp } : {},
2549
+ ...minRangeDays !== void 0 ? { minRangeDays } : {},
2550
+ ...maxRangeDays !== void 0 ? { maxRangeDays } : {}
2551
+ };
2552
+ validateDateConstraints(calendar, { minDate, maxDate, disabledDates });
2553
+ assertRangeLengthOptions(minRangeDays, maxRangeDays);
2554
+ if (today) adapter.toJdn(today);
2555
+ if (initialVisibleMonth) {
2556
+ adapter.toJdn({
2557
+ year: initialVisibleMonth.year,
2558
+ month: initialVisibleMonth.month,
2559
+ day: 1
2560
+ });
2561
+ }
2562
+ const isValueControlled = value !== void 0;
2563
+ assertValidRange(
2564
+ isValueControlled ? value ?? null : defaultValue,
2565
+ constraints
2566
+ );
2567
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react3.useState)(
2568
+ defaultValue
2569
+ );
2570
+ const selectedRange = isValueControlled ? value ?? null : uncontrolledValue;
2571
+ const isOpenControlled = open !== void 0;
2572
+ const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react3.useState)(defaultOpen);
2573
+ const isOpen = isOpenControlled ? open : uncontrolledOpen;
2574
+ const [draftRange, setDraftRange] = (0, import_react3.useState)(selectedRange);
2575
+ const [previewEnd, setPreviewEnd] = (0, import_react3.useState)(null);
2576
+ const [errorMessage, setErrorMessage] = (0, import_react3.useState)(null);
2577
+ const [announcement, setAnnouncement] = (0, import_react3.useState)("");
2578
+ const generatedId = (0, import_react3.useId)();
2579
+ const inputId = id ?? `afghan-date-range-picker-${generatedId}`;
2580
+ const popoverId = `${inputId}-calendar`;
2581
+ const errorId = `${inputId}-error`;
2582
+ const containerRef = (0, import_react3.useRef)(null);
2583
+ const startInputRef = (0, import_react3.useRef)(null);
2584
+ const returnFocus = (0, import_react3.useRef)(false);
2585
+ const draftTouched = (0, import_react3.useRef)(false);
2586
+ const wasOpen = (0, import_react3.useRef)(isOpen);
2587
+ const lastCommittedRange = (0, import_react3.useRef)(selectedRange);
2588
+ const [focusCalendarOnOpen, setFocusCalendarOnOpen] = (0, import_react3.useState)(false);
2589
+ const formatDate = (0, import_react3.useCallback)(
2590
+ (date) => date ? formatCalendarDate(date, {
2591
+ calendar,
2592
+ locale: localeCode,
2593
+ numerals: numeralSystem,
2594
+ format
2595
+ }) : "",
2596
+ [calendar, format, localeCode, numeralSystem]
2597
+ );
2598
+ const [startText, setStartText] = (0, import_react3.useState)(
2599
+ () => formatDate(selectedRange?.start ?? null)
2600
+ );
2601
+ const [endText, setEndText] = (0, import_react3.useState)(
2602
+ () => formatDate(selectedRange?.end ?? null)
2603
+ );
2604
+ const setDraft = (next) => {
2605
+ draftTouched.current = true;
2606
+ setDraftRange(next);
2607
+ setStartText(formatDate(next?.start ?? null));
2608
+ setEndText(formatDate(next?.end ?? null));
2609
+ setErrorMessage(null);
2610
+ setPreviewEnd(null);
2611
+ setAnnouncement(
2612
+ next ? `${locale.ui.startDate}: ${formatDate(next.start)}` : locale.ui.noDateSelected
2613
+ );
2614
+ if (!next || next.end === null) onIncompleteChange?.(next);
2615
+ };
2616
+ const commitRange = (next) => {
2617
+ if (!isValueControlled) setUncontrolledValue(next);
2618
+ onChange?.(next);
2619
+ };
2620
+ const requestOpen = (0, import_react3.useCallback)(
2621
+ (nextOpen, focusCalendar = false) => {
2622
+ if (disabled && nextOpen) return;
2623
+ if (!isOpenControlled) setUncontrolledOpen(nextOpen);
2624
+ if (nextOpen) setFocusCalendarOnOpen(focusCalendar);
2625
+ onOpenChange?.(nextOpen);
2626
+ },
2627
+ [disabled, isOpenControlled, onOpenChange]
2628
+ );
2629
+ (0, import_react3.useEffect)(() => {
2630
+ const committedRangeChanged = !areRangesEqual(
2631
+ lastCommittedRange.current,
2632
+ selectedRange
2633
+ );
2634
+ lastCommittedRange.current = selectedRange;
2635
+ if (!isOpen || committedRangeChanged) {
2636
+ setDraftRange(selectedRange);
2637
+ setStartText(formatDate(selectedRange?.start ?? null));
2638
+ setEndText(formatDate(selectedRange?.end ?? null));
2639
+ setErrorMessage(null);
2640
+ setPreviewEnd(null);
2641
+ draftTouched.current = false;
2642
+ } else if (!wasOpen.current && !draftTouched.current) {
2643
+ setDraftRange(selectedRange);
2644
+ setStartText(formatDate(selectedRange?.start ?? null));
2645
+ setEndText(formatDate(selectedRange?.end ?? null));
2646
+ setErrorMessage(null);
2647
+ setPreviewEnd(null);
2648
+ } else if (wasOpen.current) {
2649
+ setStartText(formatDate(draftRange?.start ?? null));
2650
+ setEndText(formatDate(draftRange?.end ?? null));
2651
+ }
2652
+ wasOpen.current = isOpen;
2653
+ if (!isOpen && returnFocus.current) {
2654
+ startInputRef.current?.focus();
2655
+ returnFocus.current = false;
2656
+ }
2657
+ }, [formatDate, isOpen, selectedRange]);
2658
+ (0, import_react3.useEffect)(() => {
2659
+ if (!isOpen) return;
2660
+ const handleOutsidePointer = (event) => {
2661
+ if (containerRef.current && event.target instanceof Node && !containerRef.current.contains(event.target)) {
2662
+ requestOpen(false);
2663
+ }
2664
+ };
2665
+ document.addEventListener("pointerdown", handleOutsidePointer);
2666
+ return () => document.removeEventListener("pointerdown", handleOutsidePointer);
2667
+ }, [isOpen, requestOpen]);
2668
+ const reportError = (message) => {
2669
+ setErrorMessage(message);
2670
+ onValidationError?.(message);
2671
+ };
2672
+ const completeRange = (next) => {
2673
+ const message = getRangeValidationMessage(next, constraints);
2674
+ if (message) {
2675
+ setPreviewEnd(null);
2676
+ reportError(message);
2677
+ return false;
2678
+ }
2679
+ setDraftRange(next);
2680
+ draftTouched.current = true;
2681
+ setStartText(formatDate(next.start));
2682
+ setEndText(formatDate(next.end));
2683
+ setErrorMessage(null);
2684
+ setPreviewEnd(null);
2685
+ setAnnouncement(
2686
+ `${locale.ui.startDate}: ${formatDate(next.start)}. ${locale.ui.endDate}: ${formatDate(next.end)}`
2687
+ );
2688
+ if (closeOnSelect) {
2689
+ commitRange(next);
2690
+ if (isOpen) {
2691
+ returnFocus.current = true;
2692
+ requestOpen(false);
2693
+ }
2694
+ }
2695
+ return true;
2696
+ };
2697
+ const selectDate = (date) => {
2698
+ if (disabled) return;
2699
+ if (isDateDisabled(date, calendar, {
2700
+ minDate,
2701
+ maxDate,
2702
+ disabledDates,
2703
+ isDateDisabled: isDateDisabledProp
2704
+ })) {
2705
+ return;
2706
+ }
2707
+ if (!draftRange || draftRange.end !== null) {
2708
+ setDraft({ start: date, end: null });
2709
+ return;
2710
+ }
2711
+ if (compareDates(date, draftRange.start, calendar) < 0) {
2712
+ setDraft({ start: date, end: null });
2713
+ return;
2714
+ }
2715
+ completeRange({ start: draftRange.start, end: date });
2716
+ };
2717
+ const commitManualInput = (field) => {
2718
+ if (disabled || readOnly) return;
2719
+ const text = field === "start" ? startText : endText;
2720
+ const currentDate = field === "start" ? draftRange?.start : draftRange?.end;
2721
+ if (text.trim() === "" && !currentDate) return;
2722
+ if (currentDate && text === formatDate(currentDate)) return;
2723
+ if (text.trim() === "") {
2724
+ if (field === "start") {
2725
+ setDraft(null);
2726
+ } else if (draftRange?.start) {
2727
+ setDraft({ start: draftRange.start, end: null });
2728
+ }
2729
+ return;
2730
+ }
2731
+ const parsedDate = parseCalendarDateText(text, format, calendar, locale);
2732
+ if (!parsedDate) {
2733
+ reportError(locale.ui.invalidDate);
2734
+ return;
2735
+ }
2736
+ try {
2737
+ getCalendarAdapter(calendar).toJdn(parsedDate);
2738
+ } catch (error) {
2739
+ if (error instanceof RangeError) {
2740
+ reportError(locale.ui.invalidDate);
2741
+ return;
2742
+ }
2743
+ throw error;
2744
+ }
2745
+ if (isDateDisabled(parsedDate, calendar, {
2746
+ minDate,
2747
+ maxDate,
2748
+ disabledDates,
2749
+ isDateDisabled: isDateDisabledProp
2750
+ })) {
2751
+ reportError(locale.ui.invalidDate);
2752
+ return;
2753
+ }
2754
+ if (field === "start") {
2755
+ setDraft({ start: parsedDate, end: null });
2756
+ return;
2757
+ }
2758
+ if (!draftRange?.start) {
2759
+ reportError(locale.ui.selectStartDate);
2760
+ return;
2761
+ }
2762
+ if (compareDates(parsedDate, draftRange.start, calendar) < 0) {
2763
+ setDraft({ start: parsedDate, end: null });
2764
+ return;
2765
+ }
2766
+ completeRange({ start: draftRange.start, end: parsedDate });
2767
+ };
2768
+ const apply = () => {
2769
+ if (draftRange?.end === null) {
2770
+ reportError(locale.ui.selectStartDate);
2771
+ return;
2772
+ }
2773
+ if (draftRange?.end) {
2774
+ const message = getRangeValidationMessage(draftRange, constraints);
2775
+ if (message) {
2776
+ reportError(message);
2777
+ return;
2778
+ }
2779
+ }
2780
+ commitRange(draftRange);
2781
+ returnFocus.current = true;
2782
+ requestOpen(false);
2783
+ };
2784
+ const cancel = () => {
2785
+ setDraftRange(selectedRange);
2786
+ draftTouched.current = false;
2787
+ setStartText(formatDate(selectedRange?.start ?? null));
2788
+ setEndText(formatDate(selectedRange?.end ?? null));
2789
+ setPreviewEnd(null);
2790
+ setErrorMessage(null);
2791
+ onIncompleteChange?.(null);
2792
+ returnFocus.current = true;
2793
+ requestOpen(false);
2794
+ };
2795
+ const clear = () => setDraft(null);
2796
+ const handleKeyDown = (event) => {
2797
+ if (event.key === "Escape" && isOpen) {
2798
+ event.preventDefault();
2799
+ event.stopPropagation();
2800
+ returnFocus.current = true;
2801
+ requestOpen(false);
2802
+ }
2803
+ };
2804
+ const rootClassName = [
2805
+ "afghan-date-range-picker",
2806
+ disabled ? "afghan-date-range-picker--disabled" : "",
2807
+ className ?? ""
2808
+ ].filter(Boolean).join(" ");
2809
+ const initialMonth = initialVisibleMonth ?? draftRange?.start ?? selectedRange?.start ?? today ?? getFallbackDate(calendar);
2810
+ const applyDisabled = disabled || errorMessage !== null || required && draftRange === null || draftRange?.end === null;
2811
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2812
+ "div",
2813
+ {
2814
+ className: rootClassName,
2815
+ dir: locale.direction,
2816
+ lang: locale.code,
2817
+ "data-calendar": calendar,
2818
+ ref: containerRef,
2819
+ style,
2820
+ onKeyDown: handleKeyDown,
2821
+ children: [
2822
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "afghan-date-range-picker__fields", children: [
2823
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "afghan-date-range-picker__field", children: [
2824
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2825
+ "label",
2826
+ {
2827
+ className: "afghan-date-range-picker__label",
2828
+ htmlFor: `${inputId}-start`,
2829
+ children: startLabel ?? locale.ui.startDate
2830
+ }
2831
+ ),
2832
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2833
+ "input",
2834
+ {
2835
+ ref: startInputRef,
2836
+ id: `${inputId}-start`,
2837
+ className: "afghan-date-range-picker__input",
2838
+ type: "text",
2839
+ name: name ? `${name}-start` : void 0,
2840
+ value: startText,
2841
+ placeholder: startPlaceholder ?? placeholder,
2842
+ disabled,
2843
+ readOnly,
2844
+ required,
2845
+ autoComplete: "off",
2846
+ "aria-haspopup": "dialog",
2847
+ "aria-expanded": isOpen,
2848
+ "aria-controls": popoverId,
2849
+ "aria-invalid": errorMessage ? true : void 0,
2850
+ "aria-describedby": errorMessage ? errorId : void 0,
2851
+ onClick: () => requestOpen(true),
2852
+ onChange: (event) => {
2853
+ draftTouched.current = true;
2854
+ setStartText(event.currentTarget.value);
2855
+ setErrorMessage(null);
2856
+ },
2857
+ onBlur: () => commitManualInput("start"),
2858
+ onKeyDown: (event) => {
2859
+ if (event.key === "ArrowDown" && !disabled) {
2860
+ event.preventDefault();
2861
+ requestOpen(true, true);
2862
+ } else if (event.key === "Enter") {
2863
+ event.preventDefault();
2864
+ commitManualInput("start");
2865
+ }
2866
+ }
2867
+ }
2868
+ )
2869
+ ] }),
2870
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2871
+ "span",
2872
+ {
2873
+ className: "afghan-date-range-picker__separator",
2874
+ "aria-hidden": "true",
2875
+ children: separator
2876
+ }
2877
+ ),
2878
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "afghan-date-range-picker__field", children: [
2879
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2880
+ "label",
2881
+ {
2882
+ className: "afghan-date-range-picker__label",
2883
+ htmlFor: `${inputId}-end`,
2884
+ children: endLabel ?? locale.ui.endDate
2885
+ }
2886
+ ),
2887
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2888
+ "input",
2889
+ {
2890
+ id: `${inputId}-end`,
2891
+ className: "afghan-date-range-picker__input",
2892
+ type: "text",
2893
+ name: name ? `${name}-end` : void 0,
2894
+ value: endText,
2895
+ placeholder: endPlaceholder ?? placeholder,
2896
+ disabled,
2897
+ readOnly,
2898
+ required,
2899
+ autoComplete: "off",
2900
+ "aria-haspopup": "dialog",
2901
+ "aria-expanded": isOpen,
2902
+ "aria-controls": popoverId,
2903
+ "aria-invalid": errorMessage ? true : void 0,
2904
+ "aria-describedby": errorMessage ? errorId : void 0,
2905
+ onClick: () => requestOpen(true),
2906
+ onChange: (event) => {
2907
+ draftTouched.current = true;
2908
+ setEndText(event.currentTarget.value);
2909
+ setErrorMessage(null);
2910
+ },
2911
+ onBlur: () => commitManualInput("end"),
2912
+ onKeyDown: (event) => {
2913
+ if (event.key === "ArrowDown" && !disabled) {
2914
+ event.preventDefault();
2915
+ requestOpen(true, true);
2916
+ } else if (event.key === "Enter") {
2917
+ event.preventDefault();
2918
+ commitManualInput("end");
2919
+ }
2920
+ }
2921
+ }
2922
+ )
2923
+ ] }),
2924
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2925
+ "button",
2926
+ {
2927
+ type: "button",
2928
+ className: "afghan-date-range-picker__action",
2929
+ "aria-label": `${locale.ui.selectMonth}, ${locale.ui.selectYear}`,
2930
+ "aria-haspopup": "dialog",
2931
+ "aria-expanded": isOpen,
2932
+ "aria-controls": popoverId,
2933
+ disabled,
2934
+ onClick: () => requestOpen(true, true),
2935
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2936
+ "svg",
2937
+ {
2938
+ "aria-hidden": "true",
2939
+ viewBox: "0 0 24 24",
2940
+ width: "20",
2941
+ height: "20",
2942
+ focusable: "false",
2943
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2944
+ "path",
2945
+ {
2946
+ d: "M7 2v3m10-3v3M4 9h16M5 4h14a1 1 0 0 1 1 1v14H4V5a1 1 0 0 1 1-1Z",
2947
+ fill: "none",
2948
+ stroke: "currentColor",
2949
+ strokeWidth: "1.7",
2950
+ strokeLinecap: "round",
2951
+ strokeLinejoin: "round"
2952
+ }
2953
+ )
2954
+ }
2955
+ )
2956
+ }
2957
+ )
2958
+ ] }),
2959
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2960
+ "span",
2961
+ {
2962
+ className: "afghan-date-range-picker__error",
2963
+ id: errorId,
2964
+ role: "alert",
2965
+ children: errorMessage
2966
+ }
2967
+ ),
2968
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2969
+ "div",
2970
+ {
2971
+ className: "afghan-date-range-picker__popover",
2972
+ id: popoverId,
2973
+ role: "dialog",
2974
+ "aria-label": `${locale.ui.startDate} \u2013 ${locale.ui.endDate}`,
2975
+ children: [
2976
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2977
+ Calendar,
2978
+ {
2979
+ calendar,
2980
+ locale: localeCode,
2981
+ numerals: numeralSystem,
2982
+ value: draftRange?.start ?? null,
2983
+ initialVisibleMonth: initialMonth,
2984
+ onChange: selectDate,
2985
+ ...draftRange ? { range: draftRange } : {},
2986
+ ...previewEnd ? { rangePreviewEnd: previewEnd } : {},
2987
+ onDatePreviewChange: (date) => {
2988
+ if (draftRange?.end === null && date && compareDates(date, draftRange.start, calendar) > 0) {
2989
+ setPreviewEnd(date);
2990
+ } else {
2991
+ setPreviewEnd(null);
2992
+ }
2993
+ },
2994
+ ...today !== void 0 ? { today } : {},
2995
+ ...minDate !== void 0 ? { minDate } : {},
2996
+ ...maxDate !== void 0 ? { maxDate } : {},
2997
+ ...disabledDates !== void 0 ? { disabledDates } : {},
2998
+ ...isDateDisabledProp !== void 0 ? { isDateDisabled: isDateDisabledProp } : {},
2999
+ ...firstDayOfWeek !== void 0 ? { firstDayOfWeek } : {},
3000
+ disabled,
3001
+ autoFocus: focusCalendarOnOpen
3002
+ }
3003
+ ),
3004
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "afghan-date-range-picker__actions", children: [
3005
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3006
+ "button",
3007
+ {
3008
+ type: "button",
3009
+ className: "afghan-date-range-picker__action",
3010
+ onClick: clear,
3011
+ disabled: disabled || readOnly,
3012
+ children: locale.ui.clear
3013
+ }
3014
+ ),
3015
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3016
+ "button",
3017
+ {
3018
+ type: "button",
3019
+ className: "afghan-date-range-picker__action",
3020
+ onClick: cancel,
3021
+ disabled,
3022
+ children: locale.ui.cancel
3023
+ }
3024
+ ),
3025
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3026
+ "button",
3027
+ {
3028
+ type: "button",
3029
+ className: "afghan-date-range-picker__action afghan-date-range-picker__action--primary",
3030
+ onClick: apply,
3031
+ disabled: applyDisabled,
3032
+ children: locale.ui.apply
3033
+ }
3034
+ )
3035
+ ] })
3036
+ ]
3037
+ }
3038
+ ),
3039
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3040
+ "span",
3041
+ {
3042
+ className: "afghan-date-range-picker__visually-hidden",
3043
+ "aria-live": "polite",
3044
+ "aria-atomic": "true",
3045
+ children: announcement
3046
+ }
3047
+ )
3048
+ ]
3049
+ }
3050
+ );
3051
+ }
3052
+ // Annotate the CommonJS export names for ESM import in node:
3053
+ 0 && (module.exports = {
3054
+ AFGHAN_SUPPORTED_YEAR_RANGE,
3055
+ Calendar,
3056
+ DatePicker,
3057
+ DateRangePicker,
3058
+ GREGORIAN_SUPPORTED_YEAR_RANGE,
3059
+ IRANIAN_SUPPORTED_YEAR_RANGE,
3060
+ addDays,
3061
+ addMonths,
3062
+ addWeeks,
3063
+ addYears,
3064
+ afghanCalendarAdapter,
3065
+ afghanToJdn,
3066
+ compareDates,
3067
+ convertDate,
3068
+ differenceInDays,
3069
+ differenceInMonths,
3070
+ differenceInWeeks,
3071
+ differenceInYears,
3072
+ formatCalendarDate,
3073
+ fromLocalizedDigits,
3074
+ getAfghanMonthLength,
3075
+ getAvailableLocales,
3076
+ getDayOfWeek,
3077
+ getDaysInMonth,
3078
+ getDaysInYear,
3079
+ getEndOfDay,
3080
+ getEndOfMonth,
3081
+ getEndOfWeek,
3082
+ getEndOfYear,
3083
+ getGregorianMonthLength,
3084
+ getIranianMonthLength,
3085
+ getLocale,
3086
+ getLocaleDirection,
3087
+ getMonthsInYear,
3088
+ getOrderedWeekdays,
3089
+ getStartOfDay,
3090
+ getStartOfMonth,
3091
+ getStartOfWeek,
3092
+ getStartOfYear,
3093
+ getWeekday,
3094
+ gregorianCalendarAdapter,
3095
+ gregorianToJdn,
3096
+ iranianCalendarAdapter,
3097
+ iranianToJdn,
3098
+ isAfghanLeapYear,
3099
+ isAfter,
3100
+ isBefore,
3101
+ isGregorianLeapYear,
3102
+ isIranianLeapYear,
3103
+ isLeapYear,
3104
+ isSameDay,
3105
+ isSameMonth,
3106
+ isSameYear,
3107
+ isValidAfghanDate,
3108
+ isValidGregorianDate,
3109
+ isValidIranianDate,
3110
+ jdnToAfghan,
3111
+ jdnToGregorian,
3112
+ jdnToIranian,
3113
+ registerLocale,
3114
+ subtractDays,
3115
+ subtractMonths,
3116
+ subtractWeeks,
3117
+ subtractYears,
3118
+ toLocalizedDigits
3119
+ });
3120
+ //# sourceMappingURL=index.cjs.map