@tempo-kit/plugin-holidays 0.0.0-stage → 2.0.0-rc.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/CHANGELOG.md +49 -0
- package/LICENSE +21 -0
- package/README.md +93 -2
- package/dist/cache.d.ts +24 -0
- package/dist/calendars/au.d.ts +2 -0
- package/dist/calendars/ca.d.ts +2 -0
- package/dist/calendars/de.d.ts +2 -0
- package/dist/calendars/fr.d.ts +2 -0
- package/dist/calendars/gb.d.ts +2 -0
- package/dist/calendars/jp.d.ts +2 -0
- package/dist/calendars/nz.d.ts +2 -0
- package/dist/calendars/us.d.ts +2 -0
- package/dist/computus.d.ts +64 -0
- package/dist/engine.d.ts +105 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +1058 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +1061 -0
- package/dist/preload.d.ts +12 -0
- package/dist/registry.d.ts +31 -0
- package/dist/types.d.ts +45 -0
- package/package.json +64 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@tempo-kit/plugin-holidays` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-11-27
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-holidays` to `@tempo-kit/plugin-holidays`.
|
|
12
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
13
|
+
|
|
14
|
+
## [2.0.0] - 2026-11-27
|
|
15
|
+
|
|
16
|
+
### Breaking Changes
|
|
17
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-holidays` to `@tempo-kit/plugin-holidays`.
|
|
18
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
19
|
+
|
|
20
|
+
## [1.0.3] - 2026-10-29
|
|
21
|
+
|
|
22
|
+
### Changed & Performance
|
|
23
|
+
- **Civil Calendar Integer Arithmetic**:
|
|
24
|
+
- Replaced JavaScript `Date` object allocations in `computus.ts` with pure integer calendar math (`civilToDays`, `isoWeekdayFromDays`, `epochMsFromParts`, `partsFromEpochMs`, and `getDaysInMonth`) imported from `@magmacomputing/tempo/library`.
|
|
25
|
+
- Optimized `offsetDate` using direct millisecond offset calculation (`86_400_000` ms/day) and `partsFromEpochMs` decomposition.
|
|
26
|
+
- Accelerated `getNthWeekdayOfMonth` and `getIsoDayOfWeek` with zero-allocation day-of-week indexing directly from civil days.
|
|
27
|
+
|
|
28
|
+
## [1.0.2] - 2026-10-02
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- **Intl Namespace Integration**: Updated country code and regional weekend resolution cascade to target the structured `tempo.intl.info.region` and `tempo.intl.info.weekend` properties.
|
|
32
|
+
|
|
33
|
+
## [1.0.1] - 2026-09-29
|
|
34
|
+
|
|
35
|
+
### Changed & Performance
|
|
36
|
+
- **WeakCache Memoization**:
|
|
37
|
+
- Memoized `getEasterSunday(year)` calculation results in `computus.ts` using `WeakCache<number, EasterResult>`.
|
|
38
|
+
- Computed holiday dates and Computus results are now auto-reclaimed upon garbage collection, preventing unbounded memory retention when computing holidays across large date ranges or multiple country jurisdictions.
|
|
39
|
+
|
|
40
|
+
## [1.0.0] - 2026-09-26
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
- Initial bootstrap release of `@tempo-kit/plugin-holidays`.
|
|
44
|
+
- Zero-latency synchronous offline holiday calendars for major economies (US, AU, GB, CA, DE, FR, JP, NZ).
|
|
45
|
+
- Astronomical Easter Computus calculations supporting floating Christian holidays (Good Friday, Easter Monday, Ascension, Pentecost/Whit Sunday, Whit Monday).
|
|
46
|
+
- Weekend observation rules (Saturday → Friday / Sunday → Monday, Australian & UK substitute days, Japan Furikae Kyūjitsu, NZ Mondayisation).
|
|
47
|
+
- Integration with `t.geo.country` and `t.locale` country code cascades.
|
|
48
|
+
- Pure tree-shakeable functional API (`isPublicHoliday`, `isBusinessDay`, `getHolidayName`, `getYearHolidays`, `addBusinessDays`, `businessDaysBetween`).
|
|
49
|
+
- Fluent OOP instance methods (`t.isHoliday()`, `t.isBusinessDay()`, `t.nextBusinessDay()`, `t.prevBusinessDay()`, `t.addBusinessDays()`, `t.holidays`).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magma Computing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,94 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tempo-kit/plugin-holidays
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@tempo-kit/plugin-holidays"><img src="https://img.shields.io/npm/v/@tempo-kit/plugin-holidays?style=flat-square" alt="npm version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/tempo-kit"><img src="https://img.shields.io/npm/dependency-version/@tempo-kit/plugin-holidays/peer/tempo-kit?style=flat-square" alt="npm peer dependency version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/@tempo-kit/plugin-holidays"><img src="https://img.shields.io/npm/l/@tempo-kit/plugin-holidays?style=flat-square" alt="License" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript&style=flat-square" alt="TypeScript Ready" style="display: inline-block; margin: 0 4px;"></a> <a href="https://magmacomputing.github.io/magma/doc/9-plugins/holidays.index.html"><img src="https://img.shields.io/badge/Docs-VitePress-brightgreen?logo=vitepress&style=flat-square" alt="Documentation" style="display: inline-block; margin: 0 4px;"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
Regional bank holiday, public holiday, and business day SLA scheduling plugin for [Tempo](https://github.com/magmacomputing/magma/tree/main/packages/tempo).
|
|
10
|
+
|
|
11
|
+
Provides zero-latency synchronous bank holiday resolution for top economies (US, AU, GB, CA, DE, FR, JP, NZ), weekend observation shifts, Easter Computus, and business day arithmetic directly integrated with `t.geo.country`.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @tempo-kit/plugin-holidays
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Fluent OOP Namespace API (Automatic Auto-Install)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import '@tempo-kit/plugin-holidays/install';
|
|
29
|
+
import { Tempo } from 'tempo-kit';
|
|
30
|
+
|
|
31
|
+
// Resolves automatically via t.geo.country
|
|
32
|
+
const t = new Tempo('2026-01-26', { geo: { country: 'AU' } });
|
|
33
|
+
|
|
34
|
+
console.log(t.holidays.isHoliday()); // true
|
|
35
|
+
console.log(t.holidays.name); // 'Australia Day'
|
|
36
|
+
console.log(t.holidays.isBusinessDay()); // false
|
|
37
|
+
|
|
38
|
+
// Advance to next valid business day past holidays & weekends
|
|
39
|
+
const nextWorkDay = t.holidays.nextBusinessDay();
|
|
40
|
+
console.log(nextWorkDay.format('{yyyy}-{mm}-{dd}')); // '2026-01-27'
|
|
41
|
+
|
|
42
|
+
// Add N working business days
|
|
43
|
+
const deadline = t.holidays.addBusinessDays(5);
|
|
44
|
+
console.log(deadline.format('{yyyy}-{mm}-{dd}'));
|
|
45
|
+
|
|
46
|
+
// Calculate SLA working hours
|
|
47
|
+
const start = new Tempo('2026-01-23 15:00:00', { geo: { country: 'AU' } });
|
|
48
|
+
const end = new Tempo('2026-01-27 11:00:00', { geo: { country: 'AU' } });
|
|
49
|
+
console.log(start.holidays.workingHoursUntil(end)); // 4.0 hours
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> ⚡ **[Try this live in the interactive Tempo Sandbox ↗](https://magmacomputing.github.io/magma/repl/index.html?plugin=holidays)**
|
|
53
|
+
|
|
54
|
+
### 2. Pure Tree-Shakeable Functional API
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { isPublicHoliday, isBusinessDay, getHolidayName, addBusinessDays, workingHoursBetween } from '@tempo-kit/plugin-holidays';
|
|
58
|
+
import { Tempo } from 'tempo-kit';
|
|
59
|
+
|
|
60
|
+
const t = new Tempo('2026-12-25');
|
|
61
|
+
|
|
62
|
+
console.log(isPublicHoliday(t, { country: 'US' })); // true
|
|
63
|
+
console.log(getHolidayName(t, { country: 'US' })); // 'Christmas Day'
|
|
64
|
+
console.log(isBusinessDay(t, { country: 'US' })); // false
|
|
65
|
+
|
|
66
|
+
const fiveDaysLater = addBusinessDays(t, 5, { country: 'US' });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Supported Built-in Countries
|
|
72
|
+
|
|
73
|
+
| Country | Code | Features Supported |
|
|
74
|
+
| :--- | :--- | :--- |
|
|
75
|
+
| **United States** | `US` | All Federal holidays, floating Mondays, Juneteenth, CA/FL day after Thanksgiving, weekend observation shifts. |
|
|
76
|
+
| **Australia** | `AU` | National holidays, state overlays (NSW, VIC, QLD, WA, SA, TAS, ACT, NT), King's Birthday variations, Melbourne Cup, dual Christmas/Boxing Day shifts. |
|
|
77
|
+
| **United Kingdom** | `GB` | England & Wales, Scotland (2nd Jan, Summer Bank, St Andrew's), Northern Ireland (St Patrick's, Battle of the Boyne). |
|
|
78
|
+
| **Canada** | `CA` | Federal statutory holidays, Victoria Day, Canada Day, Civic Holiday, Truth and Reconciliation Day, Family Day / provincial variations. |
|
|
79
|
+
| **Germany** | `DE` | Federal holidays, German Unity Day, Easter floating holidays (Corpus Christi, Ascension, Pentecost), Catholic/Protestant state holidays. |
|
|
80
|
+
| **France** | `FR` | National holidays, Bastille Day, Armistice, Victory in Europe, Ascension, Alsace-Moselle overlays (Good Friday, St. Stephen's Day). |
|
|
81
|
+
| **Japan** | `JP` | National holidays, Golden Week, Vernal & Autumnal Equinoxes, Mountain Day, Silver Week, Furikae Kyūjitsu (substitute holidays). |
|
|
82
|
+
| **New Zealand** | `NZ` | National holidays, Waitangi Day, ANZAC Day, Matariki statutory dates, Mondayisation rules. |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
📖 **[Read the Official Holidays Plugin Documentation](https://magmacomputing.github.io/magma/doc/9-plugins/holidays.index.html)**
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
This is a **Community** plugin. It is completely free and open-source for personal and commercial use under the [MIT License](./LICENSE).
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory and universal storage cache for holiday calendars with TTL support.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves a cached item if not expired.
|
|
6
|
+
*
|
|
7
|
+
* @param key - Storage key
|
|
8
|
+
* @returns Cached value or undefined
|
|
9
|
+
*/
|
|
10
|
+
export declare function getStorage<T>(key: string): T | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Stores an item in cache with a TTL.
|
|
13
|
+
*
|
|
14
|
+
* @param key - Storage key
|
|
15
|
+
* @param value - Value to cache
|
|
16
|
+
* @param options - Options with ttl in milliseconds
|
|
17
|
+
*/
|
|
18
|
+
export declare function setStorage<T>(key: string, value: T, options?: {
|
|
19
|
+
ttl?: number;
|
|
20
|
+
}): void;
|
|
21
|
+
/**
|
|
22
|
+
* Clears all entries in the holiday storage cache.
|
|
23
|
+
*/
|
|
24
|
+
export declare function clearStorage(): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats year, month, and day integers into an ISO 8601 'YYYY-MM-DD' date string.
|
|
3
|
+
*
|
|
4
|
+
* @param year - The full 4-digit calendar year
|
|
5
|
+
* @param month - 1-based month (1 = Jan, 12 = Dec)
|
|
6
|
+
* @param day - 1-based day of month (1..31)
|
|
7
|
+
* @returns Formatted ISO date string
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatDate(year: number, month: number, day: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Calculates the day of the week (1 = Monday, 7 = Sunday) according to ISO 8601.
|
|
12
|
+
*
|
|
13
|
+
* @param year - 4-digit calendar year
|
|
14
|
+
* @param month - 1-based month
|
|
15
|
+
* @param day - 1-based day of month
|
|
16
|
+
* @returns ISO day of week (1 = Monday .. 7 = Sunday)
|
|
17
|
+
*/
|
|
18
|
+
export declare function getIsoDayOfWeek(year: number, month: number, day: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Adds or subtracts N days from a base date, returning the resulting ISO date string.
|
|
21
|
+
*
|
|
22
|
+
* @param year - Base year
|
|
23
|
+
* @param month - Base month (1..12)
|
|
24
|
+
* @param day - Base day (1..31)
|
|
25
|
+
* @param daysOffset - Positive or negative number of days to offset
|
|
26
|
+
* @returns The resulting ISO date string
|
|
27
|
+
*/
|
|
28
|
+
export declare function offsetDate(year: number, month: number, day: number, daysOffset: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Calculates Easter Sunday for a given year using the Anonymous Gregorian Meeus algorithm.
|
|
31
|
+
*
|
|
32
|
+
* @param year - Calendar year (1583 to 4099)
|
|
33
|
+
* @returns Object with year, month (1..12), and day
|
|
34
|
+
*/
|
|
35
|
+
export declare function getEasterSunday(year: number): {
|
|
36
|
+
year: number;
|
|
37
|
+
month: number;
|
|
38
|
+
day: number;
|
|
39
|
+
dateStr: string;
|
|
40
|
+
};
|
|
41
|
+
/** Returns ISO date string for Good Friday (Easter - 2 days). */
|
|
42
|
+
export declare function getGoodFriday(year: number): string;
|
|
43
|
+
/** Returns ISO date string for Easter Saturday (Easter - 1 day). */
|
|
44
|
+
export declare function getEasterSaturday(year: number): string;
|
|
45
|
+
/** Returns ISO date string for Easter Monday (Easter + 1 day). */
|
|
46
|
+
export declare function getEasterMonday(year: number): string;
|
|
47
|
+
/** Returns ISO date string for Ascension Day (Easter + 39 days). */
|
|
48
|
+
export declare function getAscensionDay(year: number): string;
|
|
49
|
+
/** Returns ISO date string for Whit Sunday / Pentecost (Easter + 49 days). */
|
|
50
|
+
export declare function getPentecost(year: number): string;
|
|
51
|
+
/** Returns ISO date string for Whit Monday / Pentecost Monday (Easter + 50 days). */
|
|
52
|
+
export declare function getWhitMonday(year: number): string;
|
|
53
|
+
/** Returns ISO date string for Corpus Christi (Easter + 60 days). */
|
|
54
|
+
export declare function getCorpusChristi(year: number): string;
|
|
55
|
+
/**
|
|
56
|
+
* Calculates the date of the Nth occurrence of a specific weekday in a given month.
|
|
57
|
+
*
|
|
58
|
+
* @param year - 4-digit calendar year
|
|
59
|
+
* @param month - 1-based month (1 = Jan .. 12 = Dec)
|
|
60
|
+
* @param weekday - ISO weekday (1 = Monday .. 7 = Sunday)
|
|
61
|
+
* @param n - Occurrence: 1 (first), 2 (second), 3 (third), 4 (fourth), or -1 (last)
|
|
62
|
+
* @returns ISO date string
|
|
63
|
+
*/
|
|
64
|
+
export declare function getNthWeekdayOfMonth(year: number, month: number, weekday: number, n: number): string;
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Tempo } from 'tempo-kit';
|
|
2
|
+
import type { HolidayItem, HolidayOptions, WorkingHoursOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves effective holiday options using Tempo instance metadata when fields are omitted.
|
|
5
|
+
* Fallback Cascade:
|
|
6
|
+
* 1. options.country (explicit override)
|
|
7
|
+
* 2. tempo.geo.country (geographic location)
|
|
8
|
+
* 3. explicit tempo locale region (e.g. 'en-AU' -> 'AU')
|
|
9
|
+
* 4. explicit tempo timeZone country inference (e.g. 'Australia/Sydney' -> 'AU')
|
|
10
|
+
* 5. tempo.intl.info.region (internationalization settings)
|
|
11
|
+
* 6. tempo.locale region
|
|
12
|
+
* 7. Default fallback to 'US'
|
|
13
|
+
*
|
|
14
|
+
* @param tempo - Target Tempo instance
|
|
15
|
+
* @param options - Explicit options overrides
|
|
16
|
+
* @returns Fully resolved HolidayOptions
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveHolidayOptions(tempo?: Tempo, options?: HolidayOptions): HolidayOptions;
|
|
19
|
+
/** Formats a Tempo instance into an ISO date string (YYYY-MM-DD). */
|
|
20
|
+
export declare function toIsoDate(tempo: Tempo): string;
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the holiday items matching the given date.
|
|
23
|
+
*
|
|
24
|
+
* @param tempo - The Tempo instance to evaluate
|
|
25
|
+
* @param options - Configuration options
|
|
26
|
+
* @returns Array of matching holiday items, or empty array if none
|
|
27
|
+
*/
|
|
28
|
+
export declare function getMatchingHolidays(tempo: Tempo, options?: HolidayOptions): HolidayItem[];
|
|
29
|
+
/**
|
|
30
|
+
* Determines whether a Tempo instance falls on a recognized public holiday.
|
|
31
|
+
*
|
|
32
|
+
* @param tempo - The Tempo instance to evaluate
|
|
33
|
+
* @param options - Configuration options
|
|
34
|
+
* @returns True if the date is a public holiday
|
|
35
|
+
*/
|
|
36
|
+
export declare function isPublicHoliday(tempo: Tempo, options?: HolidayOptions): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the name of the public holiday for the given date, or null if not a holiday.
|
|
39
|
+
*
|
|
40
|
+
* @param tempo - The Tempo instance to evaluate
|
|
41
|
+
* @param options - Configuration options
|
|
42
|
+
* @returns Holiday name string or null
|
|
43
|
+
*/
|
|
44
|
+
export declare function getHolidayName(tempo: Tempo, options?: HolidayOptions): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Determines whether a Tempo instance is a standard working business day (Mon-Fri and not a holiday).
|
|
47
|
+
* Respects cultural weekend definitions from `tempo.intl.info.weekend` (e.g. [5, 6] in Middle Eastern locales).
|
|
48
|
+
*
|
|
49
|
+
* @param tempo - The Tempo instance to evaluate
|
|
50
|
+
* @param options - Configuration options
|
|
51
|
+
* @returns True if the date is a business day
|
|
52
|
+
*/
|
|
53
|
+
export declare function isBusinessDay(tempo: Tempo, options?: HolidayOptions): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves all public holidays occurring in a calendar year for a country.
|
|
56
|
+
*
|
|
57
|
+
* @param year - 4-digit calendar year
|
|
58
|
+
* @param options - Configuration options
|
|
59
|
+
* @returns Array of HolidayItem objects
|
|
60
|
+
*/
|
|
61
|
+
export declare function getYearHolidays(year: number, options?: HolidayOptions): HolidayItem[];
|
|
62
|
+
/**
|
|
63
|
+
* Returns the next valid business day, advancing past weekends and holidays.
|
|
64
|
+
*
|
|
65
|
+
* @param tempo - Starting Tempo instance
|
|
66
|
+
* @param options - Configuration options
|
|
67
|
+
* @returns A new Tempo instance on the next business day
|
|
68
|
+
*/
|
|
69
|
+
export declare function nextBusinessDay(tempo: Tempo, options?: HolidayOptions): Tempo;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the previous valid business day, stepping backward past weekends and holidays.
|
|
72
|
+
*
|
|
73
|
+
* @param tempo - Starting Tempo instance
|
|
74
|
+
* @param options - Configuration options
|
|
75
|
+
* @returns A new Tempo instance on the previous business day
|
|
76
|
+
*/
|
|
77
|
+
export declare function prevBusinessDay(tempo: Tempo, options?: HolidayOptions): Tempo;
|
|
78
|
+
/**
|
|
79
|
+
* Adds or subtracts N business days from a Tempo instance, skipping weekends and public holidays.
|
|
80
|
+
*
|
|
81
|
+
* @param tempo - Starting Tempo instance
|
|
82
|
+
* @param amount - Number of business days to add (positive) or subtract (negative)
|
|
83
|
+
* @param options - Configuration options
|
|
84
|
+
* @returns A new Tempo instance advanced or rewound by N business days
|
|
85
|
+
*/
|
|
86
|
+
export declare function addBusinessDays(tempo: Tempo, amount: number, options?: HolidayOptions): Tempo;
|
|
87
|
+
/**
|
|
88
|
+
* Calculates the exact number of full business days between two Tempo instances.
|
|
89
|
+
*
|
|
90
|
+
* @param start - Starting date
|
|
91
|
+
* @param end - Ending date
|
|
92
|
+
* @param options - Configuration options
|
|
93
|
+
* @returns Integer count of business days (positive if start < end, negative if start > end)
|
|
94
|
+
*/
|
|
95
|
+
export declare function businessDaysBetween(start: Tempo, end: Tempo, options?: HolidayOptions): number;
|
|
96
|
+
/**
|
|
97
|
+
* Calculates the exact number of SLA-eligible working hours between two Tempo instances.
|
|
98
|
+
* Automatically excludes weekends and public holidays according to the instance/options locale and country.
|
|
99
|
+
*
|
|
100
|
+
* @param start - Starting date/time
|
|
101
|
+
* @param end - Ending date/time (deadline)
|
|
102
|
+
* @param options - Working hours boundaries and holiday configuration
|
|
103
|
+
* @returns Total business working hours (negative if start is after end)
|
|
104
|
+
*/
|
|
105
|
+
export declare function workingHoursBetween(start: Tempo, end: Tempo, options?: WorkingHoursOptions): number;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type TempoPlugin } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import type { Tempo } from 'tempo-kit';
|
|
3
|
+
import { isPublicHoliday, isBusinessDay, getHolidayName, getYearHolidays, nextBusinessDay, prevBusinessDay, addBusinessDays, businessDaysBetween, workingHoursBetween } from './engine.js';
|
|
4
|
+
import { normalizeCountryCode } from './registry.js';
|
|
5
|
+
import { preloadHolidayCalendar } from './preload.js';
|
|
6
|
+
import type { HolidayItem, HolidayOptions, WorkingHoursOptions, HolidayCalendarGenerator } from './types.js';
|
|
7
|
+
export { isPublicHoliday, isBusinessDay, getHolidayName, getYearHolidays, nextBusinessDay, prevBusinessDay, addBusinessDays, businessDaysBetween, workingHoursBetween, normalizeCountryCode, preloadHolidayCalendar, };
|
|
8
|
+
export type { HolidayItem, HolidayOptions, WorkingHoursOptions, HolidayCalendarGenerator, };
|
|
9
|
+
/**
|
|
10
|
+
* Instance-level namespace providing holiday evaluation and business day arithmetic for a Tempo instance.
|
|
11
|
+
*/
|
|
12
|
+
export interface TempoHolidaysNamespace {
|
|
13
|
+
/** Name of the active public holiday on this date, or null */
|
|
14
|
+
readonly name: string | null;
|
|
15
|
+
/** Array of public holidays occurring in the current calendar year */
|
|
16
|
+
readonly list: readonly HolidayItem[];
|
|
17
|
+
/** Resolved ISO 3166-1 country code */
|
|
18
|
+
readonly country: string;
|
|
19
|
+
/** Resolved subdivision or state code */
|
|
20
|
+
readonly region?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Determines whether the current date is a recognized public holiday in `t.geo.country`.
|
|
23
|
+
*
|
|
24
|
+
* @param countryOrOptions - Optional ISO country code string or configuration options
|
|
25
|
+
* @returns True if the date is a public holiday
|
|
26
|
+
*/
|
|
27
|
+
isHoliday(countryOrOptions?: string | HolidayOptions): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Determines whether the current date is a working business day (Mon-Fri and not a holiday).
|
|
30
|
+
*
|
|
31
|
+
* @param countryOrOptions - Optional ISO country code string or configuration options
|
|
32
|
+
* @returns True if the date is a working business day
|
|
33
|
+
*/
|
|
34
|
+
isBusinessDay(countryOrOptions?: string | HolidayOptions): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the next valid business day, advancing past weekends and public holidays.
|
|
37
|
+
*
|
|
38
|
+
* @param countryOrOptions - Optional ISO country code string or configuration options
|
|
39
|
+
* @returns A new Tempo instance on the next business day
|
|
40
|
+
*/
|
|
41
|
+
nextBusinessDay(countryOrOptions?: string | HolidayOptions): Tempo;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the previous valid business day, stepping backward past weekends and public holidays.
|
|
44
|
+
*
|
|
45
|
+
* @param countryOrOptions - Optional ISO country code string or configuration options
|
|
46
|
+
* @returns A new Tempo instance on the previous business day
|
|
47
|
+
*/
|
|
48
|
+
prevBusinessDay(countryOrOptions?: string | HolidayOptions): Tempo;
|
|
49
|
+
/**
|
|
50
|
+
* Adds or subtracts N business days, skipping weekends and public holidays.
|
|
51
|
+
*
|
|
52
|
+
* @param amount - Number of business days to add (positive) or subtract (negative)
|
|
53
|
+
* @param countryOrOptions - Optional ISO country code string or configuration options
|
|
54
|
+
* @returns A new Tempo instance advanced or rewound by N business days
|
|
55
|
+
*/
|
|
56
|
+
addBusinessDays(amount: number, countryOrOptions?: string | HolidayOptions): Tempo;
|
|
57
|
+
/**
|
|
58
|
+
* Calculates the number of working business days between this instance and the target date.
|
|
59
|
+
*
|
|
60
|
+
* @param target - The ending Tempo instance
|
|
61
|
+
* @param countryOrOptions - Optional ISO country code string or configuration options
|
|
62
|
+
* @returns Number of business days
|
|
63
|
+
*/
|
|
64
|
+
businessDaysUntil(target: Tempo, countryOrOptions?: string | HolidayOptions): number;
|
|
65
|
+
/**
|
|
66
|
+
* Calculates the exact number of SLA-eligible working hours between this instance and the target date.
|
|
67
|
+
* Excludes weekends and recognized holidays according to instance/options country rules.
|
|
68
|
+
*
|
|
69
|
+
* @param target - The ending Tempo instance (deadline)
|
|
70
|
+
* @param options - Working hours boundaries and holiday configuration
|
|
71
|
+
* @returns Total business working hours
|
|
72
|
+
*/
|
|
73
|
+
workingHoursUntil(target: Tempo, options?: WorkingHoursOptions): number;
|
|
74
|
+
/**
|
|
75
|
+
* Preloads and caches holiday data for this instance's country and year in runtime storage.
|
|
76
|
+
*
|
|
77
|
+
* @param year - Optional year to preload (defaults to current year)
|
|
78
|
+
* @returns Promise resolving to the holiday items array
|
|
79
|
+
*/
|
|
80
|
+
preload(year?: number): Promise<HolidayItem[]>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Static namespace attached to the Tempo constructor for global holiday queries and caching.
|
|
84
|
+
*/
|
|
85
|
+
export interface TempoStaticHolidaysNamespace {
|
|
86
|
+
readonly preload: (year: number, countryOrOptions?: string | HolidayOptions) => Promise<HolidayItem[]>;
|
|
87
|
+
readonly getYearHolidays: (year: number, options?: HolidayOptions) => HolidayItem[];
|
|
88
|
+
readonly isPublicHoliday: (tempo: Tempo, options?: HolidayOptions) => boolean;
|
|
89
|
+
readonly isBusinessDay: (tempo: Tempo, options?: HolidayOptions) => boolean;
|
|
90
|
+
readonly getHolidayName: (tempo: Tempo, options?: HolidayOptions) => string | null;
|
|
91
|
+
readonly nextBusinessDay: (tempo: Tempo, options?: HolidayOptions) => Tempo;
|
|
92
|
+
readonly prevBusinessDay: (tempo: Tempo, options?: HolidayOptions) => Tempo;
|
|
93
|
+
readonly addBusinessDays: (tempo: Tempo, amount: number, options?: HolidayOptions) => Tempo;
|
|
94
|
+
readonly businessDaysBetween: (start: Tempo, end: Tempo, options?: HolidayOptions) => number;
|
|
95
|
+
readonly workingHoursBetween: (start: Tempo, end: Tempo, options?: WorkingHoursOptions) => number;
|
|
96
|
+
readonly normalizeCountryCode: (countryCode?: string) => string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The Regional Holidays Plugin for Tempo.
|
|
100
|
+
*
|
|
101
|
+
* Provides zero-latency national bank holiday resolution, business day calculations,
|
|
102
|
+
* and working day arithmetic linked to `t.geo.country` under the `t.holidays` namespace.
|
|
103
|
+
*/
|
|
104
|
+
export declare const HolidaysPlugin: TempoPlugin;
|
|
105
|
+
export default HolidaysPlugin;
|
|
106
|
+
declare module 'tempo-kit' {
|
|
107
|
+
interface Tempo {
|
|
108
|
+
/**
|
|
109
|
+
* Accesses the Regional Holidays namespace for the current Tempo instance.
|
|
110
|
+
*/
|
|
111
|
+
readonly holidays: TempoHolidaysNamespace;
|
|
112
|
+
}
|
|
113
|
+
namespace Tempo {
|
|
114
|
+
let holidays: TempoStaticHolidaysNamespace;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Magma;((Magma||={}).plugins||={}).holidays=(()=>{var ln=Object.create;var ce=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var fn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var pn=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},Et=(e,t)=>{for(var n in t)ce(e,n,{get:t[n],enumerable:!0})},ae=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of fn(t))!mn.call(e,i)&&i!==n&&ce(e,i,{get:()=>t[i],enumerable:!(r=un(t,i))||r.enumerable});return e},te=(e,t,n)=>(ae(e,t,"default"),n&&ae(n,t,"default")),At=(e,t,n)=>(n=e!=null?ln(dn(e)):{},ae(t||!e||!e.__esModule?ce(n,"default",{value:e,enumerable:!0}):n,e)),yn=e=>ae(ce({},"__esModule",{value:!0}),e);var Ze=pn((br,It)=>{"use strict";It.exports=window.Magma.pluginSdk});var Sr={};Et(Sr,{HolidaysPlugin:()=>sn,addBusinessDays:()=>Fe,businessDaysBetween:()=>$e,default:()=>hr,getHolidayName:()=>Pe,getYearHolidays:()=>xe,isBusinessDay:()=>R,isPublicHoliday:()=>ie,nextBusinessDay:()=>ke,normalizeCountryCode:()=>H,preloadHolidayCalendar:()=>Ue,prevBusinessDay:()=>Le,workingHoursBetween:()=>ve});var I={};Et(I,{definePlugin:()=>Ye,defineTerm:()=>gn});te(I,At(Ze()));var le=At(Ze()),Ye=e=>(0,le.definePlugin)({...e,version:"2.0.0-rc.0"}),gn=e=>(0,le.defineTerm)({...e,version:"2.0.0-rc.0"});function ue(e,t,n,r,i,s){function o(D){if(D!==void 0&&typeof D!="function")throw new TypeError("Function expected");return D}for(var a=r.kind,c=a==="getter"?"get":a==="setter"?"set":"value",u=!t&&e?r.static?e:e.prototype:null,f=t||(u?Object.getOwnPropertyDescriptor(u,r.name):{}),d,m=!1,y=n.length-1;y>=0;y--){var p={};for(var T in r)p[T]=T==="access"?{}:r[T];for(var T in r.access)p.access[T]=r.access[T];p.addInitializer=function(D){if(m)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(D||null))};var b=(0,n[y])(a==="accessor"?{get:f.get,set:f.set}:f[c],p);if(a==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(d=o(b.get))&&(f.get=d),(d=o(b.set))&&(f.set=d),(d=o(b.init))&&i.unshift(d)}else(d=o(b))&&(a==="field"?i.unshift(d):f[c]=d)}u&&Object.defineProperty(u,r.name,f),m=!0}function fe(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}var hn=Symbol.for("$LibraryTarget"),Sn=Symbol.for("$LibraryDiscover"),Tn=Symbol.for("$LibraryExtensible"),bn=Symbol.for("nodejs.util.inspect.custom"),Dn=Symbol.for("$LibraryLogConfig"),wn=Symbol.for("$LibraryRegistry"),On=Symbol.for("$LibraryRegister"),En=Symbol.for("$LibrarySerializerRegistry"),An=Symbol.for("$LibraryMutable"),In=Symbol.for("$LibraryIdentity"),Nn=Symbol.for("$LibraryUnwrapped"),E={$Target:hn,$Discover:Sn,$Extensible:Tn,$Inspect:bn,$LogConfig:Dn,$Registry:wn,$Register:On,$SerializerRegistry:En,$Identity:In,$Mutable:An,$Unwrapped:Nn};function de(e){let t=e,n=0,r=50;for(;t;){let i=t[E.$Target];if(!i||n>=r)break;t=i,n++}return t}function k(e,t,...n){if(e===null||typeof e!="object"&&typeof e!="function")return!1;let r=de(e);if(!Object.hasOwn(r,t))return!1;if(n.length===0)return!0;let i=r[t];return Nt(i,n)}function W(e,t,...n){if(e===null||typeof e!="object"&&typeof e!="function")return!1;let r=de(e);if(!(t in r))return!1;if(n.length===0)return!0;let i=r[t];return Nt(i,n)}function Nt(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="function"){if(r(e))return!0}else if(typeof r=="string"&&Cn(e,r.trim().toLowerCase()))return!0}return!1}function Cn(e,t){switch(t){case"string":case"number":case"boolean":case"function":case"bigint":case"symbol":case"undefined":return typeof e===t;case"array":return Array.isArray(e);case"null":return e===null;case"object":return e!==null&&!Array.isArray(e)&&typeof e=="object";case"any":case"unknown":return!0;default:return!1}}function Ct(e){if(!e||typeof e!="object"&&typeof e!="string")return[];let t=e.length;if(typeof t!="number"||!Number.isInteger(t)||t<=0||t>4294967295)return[];let n=new Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}var _n=[],Ge=e=>{if(e===null)return"Null";if(e===void 0)return"Undefined";let t=typeof e;if(t==="string")return"String";if(t==="number")return"Number";if(t==="boolean")return"Boolean";if(t==="bigint")return"BigInt";if(t==="symbol")return"Symbol";try{let n=t==="object"?de(e):e;return Object.prototype.toString.call(n).slice(8,-1)}catch{return t==="function"?"Function":"Object"}},ze=e=>{try{let t=e?.[Symbol.toStringTag]??e?.prototype?.[Symbol.toStringTag];if(typeof t=="string")return t}catch{}},_t=(e,...t)=>{let n=e;try{n=e?.[E.$Target]??e}catch{n=e}let r=Ge(n);switch(r){case"Function":try{return Hn(n)?"Class":"Function"}catch{return"Function"}case"Object":{try{if("length"in n&&Object.keys(n).every(s=>s==="length"||Number.isFinite(Number(s))))return"ArrayLike";for(let s of t){let o=s.class?.[E.$Target]??s.class;if(n===o||o&&n instanceof o)return s.type}let i=globalThis[E.$Registry]??[];for(let s of[..._n,...i]){let o=s.class?.[E.$Target]??s.class;if(n===o||o&&n instanceof o)return s.type}}catch{return"Object"}return"Object"}default:return r}};var Mn=/^\s*(class\s|\[native code\])/,Hn=e=>{if(typeof e!="function")return!1;let t=e?.[E.$Target]??e;if(!("prototype"in t))return!1;let n=t?.name,r=ze(t);if(t?.[E.$Identity]||t?.prototype?.[E.$Identity]||typeof r=="string"&&r.startsWith("Temporal."))return!0;if(typeof r=="string"&&r.endsWith("Function"))return!1;if((globalThis[E.$Registry]??[]).some(s=>(s.class?.[E.$Target]??s.class)===t||n&&s.type===n||r&&s.type===r))return!0;try{let s=Function.prototype.toString.call(t);if(Mn.test(s))return!0;let o=Object.getOwnPropertyDescriptor(t,"prototype");if(o&&o.writable===!1&&!Object.isFrozen(t))return!0;let a=t.prototype;if(a&&Object.getOwnPropertyNames(a).length>2)return!0}catch{return!1}return!1};var Mt=e=>e;var P=(e,...t)=>t.includes(_t(e)),Ht=e=>e===null||typeof e!="object"&&typeof e!="function",G=e=>!Ht(e),me=e=>Symbol.iterator in Object(e)&&!h(e),h=e=>typeof e=="string",pe=e=>typeof e=="string"&&e.trim().length>0,U=e=>Number.isFinite(e);var ye=e=>typeof e=="bigint";var Rt=e=>Array.isArray(e),ge=e=>Ge(e)==="Object"&&"length"in e&&Object.keys(e).every(t=>t==="length"||U(Number(t))),z=e=>P(e,"Object");var he=e=>P(e,"Date");var ne=e=>typeof e=="symbol";var Ke=e=>e==null,A=e=>e!=null,N=e=>e===void 0,Je=e=>e!==void 0;var x=e=>P(e,"Function","AsyncFunction","GeneratorFunction","AsyncGeneratorFunction"),M=e=>typeof e=="function";var Se=e=>P(e,"Map"),Te=e=>P(e,"Set"),Ve=(e,t)=>P(e,"Error")&&(t?e instanceof t:!0);var be=e=>P(e,"Temporal.ZonedDateTime")||A(globalThis.Temporal?.ZonedDateTime)&&e instanceof globalThis.Temporal.ZonedDateTime||A(e)&&e[Symbol.toStringTag]==="Temporal.ZonedDateTime"||A(e)&&x(e.toInstant)&&(A(e.timeZoneId)||A(e.timeZone));var K=e=>typeof Intl<"u"&&typeof Intl.Locale=="function"&&e instanceof Intl.Locale;var Xe=(e,t)=>{if(!e||typeof e!="object"&&typeof e!="function")return!1;try{return e[t]===!0}catch{return!1}};var re=e=>Ke(e)||z(e)&&Reflect.ownKeys(e).length===0||h(e)&&e.trim().length===0||typeof e=="number"&&Number.isNaN(e)||Rt(e)&&e.length===0||Te(e)&&e.size===0||Se(e)&&e.size===0||ArrayBuffer.isView(e)&&e.byteLength===0||he(e)&&Number.isNaN(e.getTime())||P(e,"Empty","Void");function De(e,t=new WeakSet){return JSON.stringify(e,function(n,r){if(N(r))return"\0__undefined__\0";if(ye(r))return`\0__bigint:${r}__\0`;if(x(r))return`function:${r.name||"anonymous"}`;if(G(r)){if(t.has(r))return"<Circular>";if(t.add(r),K(r))return r.toString();if(Se(r))return`map:[${Array.from(r.entries()).map(i=>De(i,t)).sort().join(",")}]`;if(Te(r))return`set:[${Array.from(r).map(i=>De(i,t)).sort().join(",")}]`}return r})}function O(e){let t=new Map;return function(...n){let r=Je(this)&&this!==globalThis?De([this,...n]):De(n);if(!t.has(r)){let i=e.apply(this,n);t.set(r,i)}return t.get(r)}}function Pt(e){try{return JSON.parse(JSON.stringify(e))}catch(t){throw console.warn("Could not clean object:",t?.message??t),t}}var Lr=globalThis[E.$SerializerRegistry]??=new Map;function xt(e,t){try{return globalThis.structuredClone(e,t)}catch{return Pt(e)}}var Rn={"%20":" ","%22":'"',"%3B":";","%3C":"<","%3E":">","%5B":"[","%5D":"]","%5E":"^","%7B":"{","%7C":"|","%7D":"}"},Fr=new RegExp(Object.keys(Rn).join("|"),"gi");var $r=globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID().split("-")[0]:Math.random().toString(36).slice(2,10);var kt=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"";function xn(e,t){return ze(e)??(N(t)?e.name||void 0:String(t))}function we(e,t){let n=(r,i,s,o)=>{let a=s??(h(i)?i:void 0)??(ne(i)&&i.description?i.description:void 0)??xn(r,o),c=a?String(a).replace(/^\$/,""):"Instance",u=h(i)||h(s),f=ne(i)?i:u?Symbol.for(`Brand.${c}`):Symbol(`Brand.${c}`),d=p=>Xe(p,f),m=r.prototype;if(m&&!k(m,f)&&Object.defineProperty(m,f,{value:!0,configurable:!1,writable:!1,enumerable:!1}),m&&!k(m,Symbol.toStringTag)&&Object.defineProperty(m,Symbol.toStringTag,{value:c,configurable:!0,writable:!1,enumerable:!1}),!r.name||r.name!==c)try{Object.defineProperty(r,"name",{value:c,configurable:!0,writable:!1,enumerable:!1})}catch{}let y=`is${kt(c)}`;if(!k(r,y))try{Object.defineProperty(r,y,{value:d,configurable:!0,writable:!1,enumerable:!1})}catch{}if(!k(r,Symbol.hasInstance))try{Object.defineProperty(r,Symbol.hasInstance,{value:function(p){if(k(this,y)){let T=this[y];if(M(T))return T.call(this,p)}return G(p)&&G(this?.prototype)&&Object.prototype.isPrototypeOf.call(this.prototype,p)},configurable:!0,writable:!1,enumerable:!1})}catch{}return r};return M(e)&&t?.kind==="class"?n(e,void 0,void 0,t.name):(r,i)=>{let s=h(e)||ne(e)?e:void 0,o=h(t)?t:void 0;return n(r,s,o,i?.name)}}function Lt(e=[],t){if(N(t))return Array.isArray(e)?Ct(e):ge(e)||me(e)&&!h(e)?Array.from(e):[e];let n=r=>A(r)?r:xt(t);return Array.isArray(e)?Array.from({length:e.length},(r,i)=>n(e[i])):ge(e)||me(e)&&!h(e)?Array.from(e,n):[e]}var qr=BigInt(Number.MAX_SAFE_INTEGER),Qr=BigInt(Number.MIN_SAFE_INTEGER);function Ft(e){if(Ve(e))return e;let t=new Error(W(e,"message",h)?e.message:String(e));return z(e)&&(t.name=W(e,"name","string")?e.name:"Error",W(e,"code","string","number")&&(t.code=e.code),W(e,"stack","string")&&(t.stack=e.stack)),t}var Oe=new FinalizationRegistry(e=>{try{x(e)&&e()}catch(t){console.error("Finalizer callback error:",t)}}),qe=(()=>{let e=[we("Finalizer")],t,n=[],r;return class{static{r=this}static{let i=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ue(null,t={value:r},e,{kind:"class",name:r.name,metadata:i},null,n),r=t.value,i&&Object.defineProperty(r,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:i}),fe(r,n)}#e;constructor(i){this.#e=i}register(i,s,o){let a=o??Object.create(null),c=this.#e;Oe.register(i,()=>{c(s)},a)}unregister(i){return Oe.unregister(i)}static register(i,s,o){let a=o??Object.create(null);return Oe.register(i,s,a),()=>Oe.unregister(a)}},r})(),ro=qe.isFinalizer;if(typeof globalThis.Temporal>"u")throw new Error("Temporal API is not available. Node 20+ with a polyfill (e.g. @js-temporal/polyfill) is highly recommended. Native Temporal is fully reliable only on Node 26+ (while Node 22 may have instabilities).");try{if(typeof Temporal.Now.zonedDateTimeISO=="function"&&typeof Temporal.Now.zonedDateTimeISO().add!="function")throw new Error("Incomplete Temporal implementation")}catch(e){let t=Ft(e);if(console.warn("Tempo: Native Temporal implementation appears incomplete. Consider loading a polyfill.",t),t.message!=="Incomplete Temporal implementation")throw t}var B=(()=>{let e=[we("WeakCache")],t,n=[],r;return class{static{r=this}static{let i=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ue(null,t={value:r},e,{kind:"class",name:r.name,metadata:i},null,n),r=t.value,i&&Object.defineProperty(r,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:i})}#e=new Map;#t;static isWeakCache=i=>typeof i=="object"&&i!==null&&#e in i;constructor(){this.#t=new qe(i=>{let s=this.#e.get(i.key);s&&s.token===i.token&&this.#e.delete(i.key)})}set(i,s){this.delete(i);let o=Object.create(null);return this.#e.set(i,{ref:new WeakRef(s),token:o}),this.#t.register(s,{key:i,token:o},o),this}get(i){let s=this.#e.get(i);if(N(s))return;let o=s.ref.deref();if(N(o)){this.#t.unregister(s.token),this.#e.delete(i);return}return o}has(i){return A(this.get(i))}getOrSet(i,s){let o=this.get(i);if(A(o))return o;let a=s(i);return this.set(i,a),a}delete(i){let s=this.#e.get(i);return A(s)?(this.#e.delete(i),this.#t.unregister(s.token),!0):!1}clear(){for(let i of this.#e.values())this.#t.unregister(i.token);this.#e.clear()}static{fe(r,n)}},r})(),vn=B.isWeakCache;var $t=new Map;function Qe(e,t=2024){let n=`${e}::${t}`,r=$t.get(n);if(N(r)){let i=Temporal.ZonedDateTime.from({year:t,month:1,day:1,hour:0,minute:0,second:0,timeZone:e}).offsetNanoseconds,s=Temporal.ZonedDateTime.from({year:t,month:7,day:1,hour:0,minute:0,second:0,timeZone:e}).offsetNanoseconds;r=Object.freeze({jan:i,jul:s}),$t.set(n,r)}return r}var ho=new B,So=new B;function je(e,t){let n=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",r,i;if(be(e)){let f=e;r=f.timeZoneId??f.timeZone?.id??f.timeZone,i=A(t)?t:f.calendarId??f.calendar?.id??f.calendar}else r=e,i=t;let s=f=>h(f)?f:be(f)?s(f.timeZoneId??f.timeZone?.id??f.timeZone):z(f)?String(f.id??f.timeZoneId??f.calendarId??""):String(f??""),o=s(r),a=s(i),c=pe(o)&&o!=="[object Object]"&&o!=="undefined"?o:n,u=pe(a)&&a!=="[object Object]"&&a!=="undefined"?a:"iso8601";return[c,u]}var Un=/_/g,Bn=/[.@]/,Bt=/^[a-zA-Z]{2}$|^\d{3}$/,L=e=>typeof Intl<"u"&&(!e||k(Intl,e,M)),$=e=>{if(K(e)&&(e=e.toString()),!h(e))return;let t=e.trim();if(re(t))return;let n=t.split(Bn)[0];if(!re(n))return n.replace(Un,"-")},vt=O((e,t)=>new Intl.RelativeTimeFormat($(e),t)),Wt=O((e,t)=>new Intl.ListFormat($(e),t)),V=O((e,t)=>new Intl.DateTimeFormat($(e),t)),Zn=O((e,t)=>{try{return new Intl.PluralRules($(e),t)}catch{return Mt({select:()=>"other"})}}),et=O((e,t)=>new Intl.NumberFormat($(e),t)),Io=O((e,t)=>{try{let n=new Intl.DurationFormat($(e),t);if(x(n.format))return n;throw new Error("No format method")}catch{return{format:r=>String(r)}}});function J(e,t,n){if(e){if(M(e[t]))return e[t]();if(n&&n in e)return e[n]}}var Yn=new Set(["US","CA","MX","BR","IL","JP","TW","HK","MO","PH","SG","TH","IN","KR","CO","PE","VE","ZA"]),Gn=new Set(["SA","AF","BH","DJ","DZ","EG","IQ","IR","JO","KW","LY","OM","QA","SD","SY","YE"]),zn=new Set(["MV"]),Kn=new Set(["SA","BH","DJ","DZ","EG","IQ","JO","KW","LY","OM","QA","SD","SY","YE"]),Jn=new Set(["AD","AN","AT","AX","BE","BG","CH","CZ","DE","DK","EE","ES","FI","FJ","FO","FR","GB","GF","GG","GI","GP","GR","HU","IE","IM","IS","IT","JE","LI","LT","LU","LV","MC","MQ","NL","NO","PL","PT","RE","RO","RU","SE","SI","SJ","SK","SM","VA","YT"]),Vn=new Set(["ar","he","fa","ur","yi","ps","sd","ug","ckb"]),Xn=new Set(["Arab","Hebr","Thaa","Syrc","Mand","Samr","Nkoo"]),Ut=Object.freeze([6,7]),qn=Object.freeze([5,6]),Qn=Object.freeze([5]),jn=Object.freeze([4,5]);function er(e){return e?zn.has(e)?5:Gn.has(e)?6:Yn.has(e)?7:1:1}function tr(e){return e?e==="IR"?Qn:e==="AF"?jn:Kn.has(e)?qn:Ut:Ut}function nr(e){return e&&Jn.has(e)?4:1}function rr(e,t){let n=e?.script??(M(e?.maximize)?e.maximize().script:void 0);return n&&Xn.has(n)||t&&Vn.has(t)?"rtl":"ltr"}var F=O(e=>{if(K(e))return e;if(L("Locale"))try{let t=$(e);return new Intl.Locale(t||"en-US")}catch{return}}),or=O(e=>{let t=F(e)??F("en-US"),n=t?.baseName??Zt(e)??"en-US",r=t?.language??n.split("-")[0]?.toLowerCase(),i=[];for(let se of n.split("-").slice(1)){if(se.length===1)break;i.push(se)}let s=t?.region??(M(t?.maximize)?t.maximize().region:void 0)??i.find(se=>Bt.test(se))?.toUpperCase(),o=t?.script??(M(t?.maximize)?t.maximize().script:void 0),a=J(t,"getWeekInfo","weekInfo"),c=a?.firstDay??er(s),u=a?.minimalDays??nr(s),f=Array.isArray(a?.weekend)?Object.freeze([...a.weekend]):tr(s),m=J(t,"getHourCycles","hourCycles")??t?.hourCycle??(L("DateTimeFormat")?V(n,{hour:"numeric"}).resolvedOptions().hourCycle:void 0),y=Array.isArray(m)&&m.length>0?Object.freeze([...m]):h(m)?Object.freeze([m]):Object.freeze(["h23"]),p=J(t,"getTextInfo","textInfo"),T=p?.direction==="rtl"||p?.direction==="ltr"?p.direction:rr(t,r),D=J(t,"getNumberingSystems","numberingSystems")??t?.numberingSystem??(L("NumberFormat")?et(n).resolvedOptions().numberingSystem:void 0),Dt=Array.isArray(D)&&D.length>0?Object.freeze([...D]):h(D)?Object.freeze([D]):Object.freeze(["latn"]),Be=J(t,"getTimeZones","timeZones"),an=Array.isArray(Be)&&Be.length>0?Object.freeze([...Be]):Object.freeze([]),ee=J(t,"getCalendars","calendars")??t?.calendar,wt=L("DateTimeFormat")?V(t??n).resolvedOptions().calendar:void 0,Ot=Array.isArray(ee)&&ee.length>0?Object.freeze([...ee]):h(ee)?Object.freeze([ee]):h(wt)?Object.freeze([wt]):Object.freeze(["gregory"]),cn=Ot[0]??"gregory";return Object.freeze({baseName:n,language:r,region:s,script:o,firstDay:c,minimalDays:u,weekend:f,hourCycle:y[0]??"h23",hourCycles:y,direction:T,numberingSystem:Dt[0]??"latn",numberingSystems:Dt,timeZones:an,calendar:cn,calendars:Ot})}),No=O((e,t)=>{let n=or(e),r=F(e)??F("en-US"),i=r?.toString()??n.baseName,s=t?je(t)[0]:void 0;return Object.freeze({info:n,locale:r,relativeTime(o,a,c){return vt(i,c).format(o,a)},list(o,a){return Wt(i,a).format(Array.from(o))},number(o,a){return et(i,a).format(o)},plural(o,a){return Zn(i,a).select(o)},dtf(o){let a=s&&!o?.timeZone?{...o,timeZone:s}:o;return V(i,a)},rtf(o){return vt(i,o)},lf(o){return Wt(i,o)},nf(o){return et(i,o)}})}),Co=O((e="latn")=>{if(!(!e||e==="latn"||!L("NumberFormat")))try{let t=new Intl.NumberFormat(`en-u-nu-${e}`,{useGrouping:!1}),n=Array.from({length:10},(r,i)=>t.format(i));return n[0]==="0"&&n[9]==="9"?void 0:Object.freeze(n)}catch{return}});var ir=Object.freeze({locale:"en-US",calendar:"iso8601",numberingSystem:"latn",timeZone:"UTC"}),sr=O(()=>L("DateTimeFormat")?Object.freeze(V().resolvedOptions()):ir),Zt=O(e=>{let t=$(e);if(t){if(L("getCanonicalLocales"))try{return Intl.getCanonicalLocales(t)[0]}catch{return}return F(t)?.baseName??t}}),_o=O(e=>Object.freeze(Lt(e).map(t=>Zt(t)).filter(Boolean)));var Mo=O((e=sr().timeZone)=>{try{let{jan:t,jul:n}=Qe(e),i=["Australia","Antarctica","Africa/Johannesburg","America/Argentina/Buenos_Aires","America/Sao_Paulo"].some(s=>e.startsWith(s));switch(!0){case n>t:return"north";case n<t:return"south";default:return i?"south":void 0}}catch{return}});var ar={AU:["Australia/Sydney","Australia/Melbourne","Australia/Brisbane","Australia/Perth","Australia/Adelaide","Australia/Hobart","Australia/Darwin","Australia/Lord_Howe","Australia/Eucla","Australia/Broken_Hill","Australia/Lindeman"],BR:["America/Sao_Paulo","America/Manaus","America/Fortaleza","America/Recife","America/Belem","America/Bahia","America/Cuiaba","America/Campo_Grande","America/Porto_Velho","America/Boa_Vista","America/Rio_Branco","America/Noronha"],CA:["America/Toronto","America/Vancouver","America/Edmonton","America/Winnipeg","America/Halifax","America/St_Johns","America/Regina","America/Whitehorse","America/Yellowknife","America/Iqaluit","America/Moncton"],CH:["Europe/Zurich"],CN:["Asia/Shanghai","Asia/Urumqi"],DE:["Europe/Berlin","Europe/Busingen"],DK:["Europe/Copenhagen"],EG:["Africa/Cairo"],ES:["Europe/Madrid","Atlantic/Canary","Africa/Ceuta"],FR:["Europe/Paris"],GB:["Europe/London"],HK:["Asia/Hong_Kong"],IE:["Europe/Dublin"],IN:["Asia/Kolkata"],IT:["Europe/Rome"],JP:["Asia/Tokyo"],KE:["Africa/Nairobi"],KR:["Asia/Seoul"],MX:["America/Mexico_City","America/Cancun","America/Monterrey","America/Tijuana","America/Merida","America/Chihuahua","America/Mazatlan","America/Hermosillo"],NL:["Europe/Amsterdam"],NO:["Europe/Oslo"],NZ:["Pacific/Auckland","Pacific/Chatham"],PK:["Asia/Karachi"],SE:["Europe/Stockholm"],SG:["Asia/Singapore"],TW:["Asia/Taipei"],US:["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Phoenix","America/Anchorage","America/Juneau","America/Sitka","America/Metlakatla","America/Yakutat","America/Nome","America/Adak","America/Detroit","America/Boise","America/Indiana/Indianapolis","America/Indiana/Knox","Pacific/Honolulu"],ZA:["Africa/Johannesburg"]},cr=O(e=>{let t=new Map;if(!(L("Locale")&&typeof Intl.Locale.prototype.getTimeZones=="function")){let i=e==="*"?null:new Set(e.split(",").map(s=>s.toUpperCase()));for(let[s,o]of Object.entries(ar))if(!(i&&!i.has(s)))for(let a of o){t.has(a)||t.set(a,s);try{let c=V("en-US",{timeZone:a}).resolvedOptions().timeZone;c&&!t.has(c)&&t.set(c,s)}catch{}}return t}let r=[];if(e==="*")for(let i=65;i<=90;i++)for(let s=65;s<=90;s++)r.push(String.fromCharCode(i,s));else for(let i of e.split(","))Bt.test(i)&&r.push(i.toUpperCase());for(let i of r)try{let s=new Intl.Locale(`und-${i}`).getTimeZones?.();if(!s)continue;for(let o of s)t.has(o)||t.set(o,i)}catch{}return t});function tt(e,t){if(!h(e)||re(e))return;let n=e.trim();if(!n)return;try{n=V("en-US",{timeZone:n}).resolvedOptions().timeZone||n}catch{return}let r=t&&t.length>0?t.map(i=>i.toUpperCase()).join(","):"*";return cr(r).get(n)}var lr=Object.freeze({MO:1,TU:2,WE:3,TH:4,FR:5,SA:6,SU:7,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6,SUN:7}),ur=Object.freeze({JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12}),fr=Object.freeze({1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday",7:"Sunday"}),Yt=[0,31,28,31,30,31,30,31,31,30,31,30,31];var oe=864e5,Ee=36e5,Ae=6e4,Ie=1e3;function nt(e,t=!1){return t?(e%4+4)%4===0:e%4===0&&e%100!==0||e%400===0}function rt(e,t,n=!1){if(t>=1&&t<=12)return t===2?nt(e,n)?29:28:Yt[t];let r=e+Math.floor((t-1)/12),i=((t-1)%12+12)%12+1;return i===2?nt(r,n)?29:28:Yt[i]}function X(e,t,n){let r,i,s;if(U(e))r=e,i=t,s=n;else if(he(e))r=e.getUTCFullYear(),i=e.getUTCMonth()+1,s=e.getUTCDate();else{let d=e?.calendarId??e?.calendar?.id;if(d&&d!=="iso8601"&&d!=="gregory")throw new RangeError(`civilToDays requires an ISO or Gregorian calendar date, got "${d}"`);r=e.year,i=e.month,s=e.day}if(!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(s))throw new RangeError(`Year, month, and day must be integers: got year=${r}, month=${i}, day=${s}`);if(i<1||i>12){let d=i-1;r+=Math.floor(d/12),i=(d%12+12)%12+1}let o=r-(i<=2?1:0),a=Math.floor(o/400),c=o-a*400,u=Math.floor((153*(i>2?i-3:i+9)+2)/5)+s-1,f=c*365+Math.floor(c/4)-Math.floor(c/100)+u;return a*146097+f-719468}function Gt(e){let t=e+719468,n=Math.floor(t/146097),r=t-n*146097,i=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),s=i+n*400,o=r-(365*i+Math.floor(i/4)-Math.floor(i/100)),a=Math.floor((5*o+2)/153),c=o-Math.floor((153*a+2)/5)+1,u=a<10?a+3:a-9;return{year:s+(u<=2?1:0),month:u,day:c}}function q(e){return(e%7+10)%7+1}function ot(e,t,n,r=0,i=0,s=0,o=0){return X(e,t,n)*oe+r*Ee+i*Ae+s*Ie+o}function it(e){let t=Math.floor(e/oe),n=e-t*oe;n<0&&(n+=oe);let{year:r,month:i,day:s}=Gt(t),o=q(t),a=Math.floor(n/Ee);n%=Ee;let c=Math.floor(n/Ae);n%=Ae;let u=Math.floor(n/Ie),f=n%Ie;return{year:r,month:i,day:s,weekday:o,hours:a,minutes:c,seconds:u,milliseconds:f}}var st=new Map;function Ne(e){let t=st.get(e);if(t){if(Date.now()>t.expiresAt){st.delete(e);return}return t.value}}function at(e,t,n){let r=n?.ttl??864e5;st.set(e,{value:t,expiresAt:Date.now()+r})}var zt=new B;function l(e,t,n){let r=String(t).padStart(2,"0"),i=String(n).padStart(2,"0");return`${e}-${r}-${i}`}function S(e,t,n){let r=X(e,t,n);return q(r)}function w(e,t,n,r){let s=ot(e,t,n)+r*864e5,{year:o,month:a,day:c}=it(s);return l(o,a,c)}function v(e){let t=zt.get(e);if(t)return t;let n=e%19,r=Math.floor(e/100),i=e%100,s=Math.floor(r/4),o=r%4,a=Math.floor((r+8)/25),c=Math.floor((r-a+1)/3),u=(19*n+r-s-c+15)%30,f=Math.floor(i/4),d=i%4,m=(32+2*o+2*f-u-d)%7,y=Math.floor((n+11*u+22*m)/451),p=Math.floor((u+m-7*y+114)/31),T=(u+m-7*y+114)%31+1,b={year:e,month:p,day:T,dateStr:l(e,p,T)};return zt.set(e,b),b}function C(e){let{month:t,day:n}=v(e);return w(e,t,n,-2)}function Kt(e){let{month:t,day:n}=v(e);return w(e,t,n,-1)}function _(e){let{month:t,day:n}=v(e);return w(e,t,n,1)}function Ce(e){let{month:t,day:n}=v(e);return w(e,t,n,39)}function _e(e){let{month:t,day:n}=v(e);return w(e,t,n,50)}function Jt(e){let{month:t,day:n}=v(e);return w(e,t,n,60)}function g(e,t,n,r){let i=rt(e,t);if(r===-1){for(let o=i;o>=1;o--)if(q(X(e,t,o))===n)return l(e,t,o);throw new Error(`Unable to find last weekday ${n} in ${e}-${t}`)}let s=0;for(let o=1;o<=i;o++)if(q(X(e,t,o))===n&&(s++,s===r))return l(e,t,o);throw new Error(`Unable to find ${r}th weekday ${n} in ${e}-${t}`)}function Vt(e,t,n){let r=S(e,t,n);return r===6?w(e,t,n,-1):r===7?w(e,t,n,1):null}var Me=(e,t,n=!0)=>{let r=[],s=t?t.toUpperCase().replace(/^US-/,""):void 0,o=(d,m,y=!1,p)=>{r.push({date:d,name:m,country:"US",region:p,isObserved:y})},a=(d,m,y,p)=>{let T=l(e,d,m);if(o(T,y,!1,p),n){let b=Vt(e,d,m);b&&o(b,`${y} (Observed)`,!0,p)}};if(o(l(e,1,1),"New Year's Day"),n){let d=Vt(e,1,1);d&&d.startsWith(`${e}-`)&&o(d,"New Year's Day (Observed)",!0),S(e+1,1,1)===6&&o(l(e,12,31),"New Year's Day (Observed)",!0)}o(g(e,1,1,3),"Martin Luther King Jr. Day"),o(g(e,2,1,3),"Washington's Birthday"),o(g(e,5,1,-1),"Memorial Day"),e>=2021&&a(6,19,"Juneteenth National Independence Day"),a(7,4,"Independence Day"),o(g(e,9,1,1),"Labor Day"),o(g(e,10,1,2),"Columbus Day"),a(11,11,"Veterans Day");let c=g(e,11,4,4);o(c,"Thanksgiving Day");let u=c.split("-").map(Number),f=w(u[0],u[1],u[2],1);return s&&["CA","DE","FL","IA","IL","KS","KY","ME","MI","MN","NE","NV","NH","NC","OK","PA","SC","TN","TX","VA","WV"].includes(s)&&o(f,"Day After Thanksgiving",!1,s),a(12,25,"Christmas Day"),r.sort((d,m)=>d.date.localeCompare(m.date))};var ct=(e,t,n=!0)=>{let r=[],s=t?t.toUpperCase().replace(/^AU-/,""):void 0,o=(d,m,y=!1,p)=>{(!p||!s||p===s)&&r.push({date:d,name:m,country:"AU",region:p,isObserved:y})},a=S(e,1,1);o(l(e,1,1),"New Year's Day"),n&&(a===6&&o(l(e,1,3),"New Year's Day (Observed)",!0),a===7&&o(l(e,1,2),"New Year's Day (Observed)",!0));let c=S(e,1,26);if(o(l(e,1,26),"Australia Day"),n&&(c===6&&o(l(e,1,28),"Australia Day (Observed)",!0),c===7&&o(l(e,1,27),"Australia Day (Observed)",!0)),o(C(e),"Good Friday"),o(Kt(e),"Easter Saturday"),o(v(e).dateStr,"Easter Sunday"),o(_(e),"Easter Monday"),o(l(e,4,25),"ANZAC Day"),n&&["WA","ACT","NT"].includes(s??"")){let d=S(e,4,25);d===7&&o(l(e,4,26),"ANZAC Day (Observed)",!0,s),d===6&&s==="WA"&&o(l(e,4,27),"ANZAC Day (Observed)",!0,"WA")}s==="WA"?o(g(e,9,1,-1),"King's Birthday",!1,"WA"):s==="QLD"?o(g(e,10,1,1),"King's Birthday",!1,"QLD"):o(g(e,6,1,2),"King's Birthday"),s==="WA"?o(g(e,3,1,1),"Labour Day",!1,"WA"):s==="VIC"?o(g(e,3,1,2),"Labour Day",!1,"VIC"):s==="TAS"?o(g(e,3,1,2),"Eight Hours Day",!1,"TAS"):s==="QLD"?o(g(e,5,1,1),"Labour Day",!1,"QLD"):s==="NT"?o(g(e,5,1,1),"May Day",!1,"NT"):(s==="ACT"||s==="NSW"||s==="SA"||!s)&&o(g(e,10,1,1),"Labour Day",!1,s),s==="VIC"&&o(g(e,11,2,1),"Melbourne Cup Day",!1,"VIC");let u=S(e,12,25);o(l(e,12,25),"Christmas Day");let f=s==="SA"?"Proclamation Day":"Boxing Day";return o(l(e,12,26),f),n&&(u===6?(o(l(e,12,27),"Christmas Day (Observed)",!0),o(l(e,12,28),`${f} (Observed)`,!0)):u===7?o(l(e,12,27),"Christmas Day (Observed)",!0):u===5&&o(l(e,12,28),`${f} (Observed)`,!0)),r.sort((d,m)=>d.date.localeCompare(m.date))};var lt=(e,t,n=!0)=>{let r=[],s=t?t.toUpperCase().replace(/^GB-/,""):void 0,o=s==="SCT"||s==="SCOTLAND",a=s==="NIR"||s==="NORTHERN-IRELAND",c=(d,m,y=!1,p)=>{r.push({date:d,name:m,country:"GB",region:p,isObserved:y})},u=S(e,1,1);c(l(e,1,1),"New Year's Day"),n&&(u===6&&c(l(e,1,3),"New Year's Day (Observed)",!0),u===7&&c(l(e,1,2),"New Year's Day (Observed)",!0)),o&&c(l(e,1,2),"2nd January",!1,"SCT"),a&&c(l(e,3,17),"St Patrick's Day",!1,"NIR"),c(C(e),"Good Friday"),o||c(_(e),"Easter Monday"),c(g(e,5,1,1),"Early May Bank Holiday"),c(g(e,5,1,-1),"Spring Bank Holiday"),a&&c(l(e,7,12),"Battle of the Boyne",!1,"NIR"),o?c(g(e,8,1,1),"Summer Bank Holiday",!1,"SCT"):c(g(e,8,1,-1),"Summer Bank Holiday"),o&&c(l(e,11,30),"St Andrew's Day",!1,"SCT");let f=S(e,12,25);return c(l(e,12,25),"Christmas Day"),c(l(e,12,26),"Boxing Day"),n&&(f===6?(c(l(e,12,27),"Christmas Day (Observed)",!0),c(l(e,12,28),"Boxing Day (Observed)",!0)):f===7?c(l(e,12,27),"Christmas Day (Observed)",!0):f===5&&c(l(e,12,28),"Boxing Day (Observed)",!0)),r.sort((d,m)=>d.date.localeCompare(m.date))};var ut=(e,t,n=!0)=>{let r=[],s=t?t.toUpperCase().replace(/^CA-/,""):void 0,o=(p,T,b=!1,D)=>{(!D||!s||D===s)&&r.push({date:p,name:T,country:"CA",region:D,isObserved:b})},a=S(e,1,1);o(l(e,1,1),"New Year's Day"),n&&(a===6&&o(l(e,1,3),"New Year's Day (Observed)",!0),a===7&&o(l(e,1,2),"New Year's Day (Observed)",!0));let c=g(e,2,1,3);s==="MB"?o(c,"Louis Riel Day",!1,"MB"):s==="PE"?o(c,"Islander Day",!1,"PE"):s==="NS"?o(c,"Heritage Day",!1,"NS"):o(c,"Family Day",!1,s),o(C(e),"Good Friday"),(s==="QC"||!s)&&o(_(e),"Easter Monday",!1,s);let u=S(e,5,24),f=u===1?0:-(u-1),d=w(e,5,24,f);o(d,s==="QC"?"National Patriots\u2019 Day":"Victoria Day",!1,s);let y=S(e,7,1);return o(l(e,7,1),"Canada Day"),n&&y===7&&o(l(e,7,2),"Canada Day (Observed)",!0),o(g(e,8,1,1),"Civic Holiday",!1,s),o(g(e,9,1,1),"Labour Day"),e>=2021&&o(l(e,9,30),"National Day for Truth and Reconciliation"),o(g(e,10,1,2),"Thanksgiving"),o(l(e,11,11),"Remembrance Day"),o(l(e,12,25),"Christmas Day"),o(l(e,12,26),"Boxing Day"),r.sort((p,T)=>p.date.localeCompare(T.date))};var ft=(e,t)=>{let n=[],i=t?t.toUpperCase().replace(/^DE-/,""):void 0,s=(o,a,c,u)=>{(!u||!i||u===i)&&n.push({date:o,name:a,localName:c,country:"DE",region:u})};if(s(l(e,1,1),"New Year's Day","Neujahr"),["BW","BY","ST"].includes(i??"")&&s(l(e,1,6),"Epiphany","Heilige Drei K\xF6nige",i),(e>=2019&&i==="BE"||e>=2023&&i==="MV")&&s(l(e,3,8),"International Women's Day","Internationaler Frauentag",i),s(C(e),"Good Friday","Karfreitag"),s(_(e),"Easter Monday","Ostermontag"),s(l(e,5,1),"Labour Day","Tag der Arbeit"),s(Ce(e),"Ascension Day","Christi Himmelfahrt"),s(_e(e),"Whit Monday","Pfingstmontag"),["BW","BY","HE","NW","RP","SL"].includes(i??"")&&s(Jt(e),"Corpus Christi","Fronleichnam",i),["BY","SL"].includes(i??"")&&s(l(e,8,15),"Assumption Day","Mari\xE4 Himmelfahrt",i),e>=2019&&i==="TH"&&s(l(e,9,20),"World Children's Day","Weltkindertag","TH"),s(l(e,10,3),"German Unity Day","Tag der Deutschen Einheit"),["BB","HB","HH","MV","NI","SN","ST","SH","TH"].includes(i??"")&&s(l(e,10,31),"Reformation Day","Reformationstag",i),["BW","BY","NW","RP","SL"].includes(i??"")&&s(l(e,11,1),"All Saints' Day","Allerheiligen",i),i==="SN"){let a=(S(e,11,23)-3+7)%7||7;s(w(e,11,23,-a),"Repentance and Prayer Day","Bu\xDF- und Bettag","SN")}return s(l(e,12,25),"Christmas Day","1. Weihnachtstag"),s(l(e,12,26),"St. Stephen's Day","2. Weihnachtstag"),n.sort((o,a)=>o.date.localeCompare(a.date))};var dt=(e,t)=>{let n=[],i=t?t.toUpperCase().replace(/^FR-/,""):void 0,s=["57","67","68","ALSACE","MOSELLE"].includes(i??""),o=(a,c,u,f)=>{(!f||!i||f===i)&&n.push({date:a,name:c,localName:u,country:"FR",region:f})};return o(l(e,1,1),"New Year's Day","Jour de l'An"),s&&o(C(e),"Good Friday","Vendredi Saint",i),o(_(e),"Easter Monday","Lundi de P\xE2ques"),o(l(e,5,1),"Labour Day","F\xEAte du Travail"),o(l(e,5,8),"Victory in Europe Day","Victoire 1945"),o(Ce(e),"Ascension Day","Ascension"),o(_e(e),"Whit Monday","Lundi de Pentec\xF4te"),o(l(e,7,14),"Bastille Day","F\xEAte Nationale"),o(l(e,8,15),"Assumption of Mary","Assomption"),o(l(e,11,1),"All Saints' Day","Toussaint"),o(l(e,11,11),"Armistice Day","Armistice 1918"),o(l(e,12,25),"Christmas Day","No\xEBl"),s&&o(l(e,12,26),"St. Stephen's Day","Saint-\xC9tienne",i),n.sort((a,c)=>a.date.localeCompare(c.date))};function dr(e){return e>=1980&&e<=2099?Math.floor(20.8431+.242194*(e-1980)-Math.floor((e-1980)/4)):20}function mr(e){return e>=1980&&e<=2099?Math.floor(23.2488+.242194*(e-1980)-Math.floor((e-1980)/4)):23}var mt=(e,t,n=!0)=>{let r=[],s=(d,m,y,p=!1)=>{r.push({date:d,name:m,localName:y,country:"JP",isObserved:p})};s(l(e,1,1),"New Year's Day","\u5143\u65E5"),s(g(e,1,1,2),"Coming of Age Day","\u6210\u4EBA\u306E\u65E5"),s(l(e,2,11),"National Foundation Day","\u5EFA\u56FD\u8A18\u5FF5\u306E\u65E5"),e>=2020&&s(l(e,2,23),"Emperor's Birthday","\u5929\u7687\u8A95\u751F\u65E5");let o=dr(e);s(l(e,3,o),"Vernal Equinox Day","\u6625\u5206\u306E\u65E5"),s(l(e,4,29),"Sh\u014Dwa Day","\u662D\u548C\u306E\u65E5"),s(l(e,5,3),"Constitution Memorial Day","\u61B2\u6CD5\u8A18\u5FF5\u65E5"),s(l(e,5,4),"Greenery Day","\u307F\u3069\u308A\u306E\u65E5"),s(l(e,5,5),"Children's Day","\u3053\u3069\u3082\u306E\u65E5"),s(g(e,7,1,3),"Marine Day","\u6D77\u306E\u65E5"),e>=2016&&s(l(e,8,11),"Mountain Day","\u5C71\u306E\u65E5");let a=g(e,9,1,3);s(a,"Respect for the Aged Day","\u656C\u8001\u306E\u65E5");let c=mr(e),u=l(e,9,c);s(u,"Autumnal Equinox Day","\u79CB\u5206\u306E\u65E5");let f=Number(a.split("-")[2]);if(c-f===2&&s(l(e,9,f+1),"Citizen's Holiday","\u56FD\u6C11\u306E\u4F11\u65E5"),s(g(e,10,1,2),"Sports Day","\u30B9\u30DD\u30FC\u30C4\u306E\u65E5"),s(l(e,11,3),"Culture Day","\u6587\u5316\u306E\u65E5"),s(l(e,11,23),"Labor Thanksgiving Day","\u52E4\u52B4\u611F\u8B1D\u306E\u65E5"),n){let d=new Set(r.map(y=>y.date)),m=[];for(let y of r){let p=y.date.split("-").map(Number);if(S(p[0],p[1],p[2])===7){let b=1,D=w(p[0],p[1],p[2],b);for(;d.has(D);)b++,D=w(p[0],p[1],p[2],b);m.push({date:D,name:`${y.name} (Observed)`,localName:"\u632F\u66FF\u4F11\u65E5",country:"JP",isObserved:!0}),d.add(D)}}r.push(...m)}return r.sort((d,m)=>d.date.localeCompare(m.date))};var Xt={2022:"2022-06-24",2023:"2023-07-14",2024:"2024-06-28",2025:"2025-06-20",2026:"2026-07-10",2027:"2027-06-25",2028:"2028-07-14",2029:"2029-07-06",2030:"2030-06-21",2031:"2031-07-11",2032:"2032-07-02",2033:"2033-06-24",2034:"2034-07-07",2035:"2035-06-29"},pt=(e,t,n=!0)=>{let r=[],s=t?t.toUpperCase().replace(/^NZ-/,""):void 0,o=(d,m,y=!1,p)=>{(!p||!s||p===s)&&r.push({date:d,name:m,country:"NZ",region:p,isObserved:y})},a=S(e,1,1);o(l(e,1,1),"New Year's Day"),o(l(e,1,2),"Day after New Year's Day"),n&&(a===6?(o(l(e,1,3),"New Year's Day (Observed)",!0),o(l(e,1,4),"Day after New Year's Day (Observed)",!0)):a===7?o(l(e,1,3),"New Year's Day (Observed)",!0):a===5&&o(l(e,1,4),"Day after New Year's Day (Observed)",!0));let c=S(e,2,6);o(l(e,2,6),"Waitangi Day"),n&&(c===6&&o(l(e,2,8),"Waitangi Day (Observed)",!0),c===7&&o(l(e,2,7),"Waitangi Day (Observed)",!0)),o(C(e),"Good Friday"),o(_(e),"Easter Monday");let u=S(e,4,25);o(l(e,4,25),"ANZAC Day"),n&&(u===6&&o(l(e,4,27),"ANZAC Day (Observed)",!0),u===7&&o(l(e,4,26),"ANZAC Day (Observed)",!0)),o(g(e,6,1,1),"King's Birthday"),Xt[e]&&o(Xt[e],"Matariki"),o(g(e,10,1,4),"Labour Day");let f=S(e,12,25);return o(l(e,12,25),"Christmas Day"),o(l(e,12,26),"Boxing Day"),n&&(f===6?(o(l(e,12,27),"Christmas Day (Observed)",!0),o(l(e,12,28),"Boxing Day (Observed)",!0)):f===7?o(l(e,12,27),"Christmas Day (Observed)",!0):f===5&&o(l(e,12,28),"Boxing Day (Observed)",!0)),r.sort((d,m)=>d.date.localeCompare(m.date))};var gt={US:Me,USA:Me,AU:ct,AUS:ct,GB:lt,UK:lt,CA:ut,CAN:ut,DE:ft,DEU:ft,FR:dt,FRA:dt,JP:mt,JPN:mt,NZ:pt,NZL:pt},He=new Map,yt=new Map;function ht(e){return H(e)in gt}function St(e,t,n){let r=H(t),i=`${e}_${r}`;yt.set(i,n),He.set(`${e}-${r}-ALL-true`,n),He.set(`${e}-${r}-ALL-false`,n)}var Z={USA:"US",AUS:"AU",GBR:"GB",CAN:"CA",DEU:"DE",FRA:"FR",JPN:"JP",NZL:"NZ",IRL:"IE",ITA:"IT",ESP:"ES",NLD:"NL",BEL:"BE",SWE:"SE",NOR:"NO",DNK:"DK",FIN:"FI",CHE:"CH",AUT:"AT",SGP:"SG",ZAF:"ZA",BRA:"BR",MEX:"MX",IND:"IN",CHN:"CN",UK:"GB"};function H(e){if(!h(e)||!e)return"US";let t=e.trim().toUpperCase();if(Z[t])return Z[t];if(t.includes("-")){let r=t.split("-")[0].toUpperCase();if(Z[r])return Z[r];if(r in gt||Object.values(Z).includes(r))return r;try{let i=new Intl.Locale(t);if(i.region){let s=i.region.toUpperCase();return Z[s]??s}}catch{}return Z[r]??r.slice(0,2)}return t.slice(0,2)}function Q(e,t={}){let n=H(t.country),r=t.region,i=t.includeObserved??!0,s=`${e}-${n}-${r??"ALL"}-${i}`,o=He.get(s);if(!o){if(ht(n))o=(gt[n]??Me)(e,r,i);else{let a=`${e}_${n}`,c=yt.get(a);if(!c){let u=`_magma_holidays_${e}_${n}`,f=Ne(u);f&&Array.isArray(f)&&f.length>0&&(c=f,yt.set(a,c))}if(c){let u=r?r.toUpperCase().replace(/^[A-Z]{2}-/,""):void 0;o=u?c.filter(f=>!f.region||f.region.toUpperCase().replace(/^[A-Z]{2}-/,"")===u):c}else{let u=[];return t.customHolidays&&t.customHolidays.length>0?t.customHolidays.map(d=>({date:d,name:"Custom Holiday",country:n,region:r})).sort((d,m)=>d.date.localeCompare(m.date)):u}}He.set(s,o)}if(t.customHolidays&&t.customHolidays.length>0){let a=t.customHolidays.map(c=>({date:c,name:"Custom Holiday",country:n,region:r}));return[...o,...a].sort((c,u)=>c.date.localeCompare(u.date))}return o}function qt(e){if(!h(e)||!e)return;let t=F(e)?.region;if(t)return t;if(e.includes("-")){let n=e.split("-");for(let r=1;r<n.length;r++){let i=n[r];if(i.length===2&&/^[a-zA-Z]{2}$/.test(i))return i.toUpperCase()}}}function Re(e,t={}){let n=e?.[I.$Internal]?.()?.options??{},r=h(n.locale)?qt(n.locale):void 0,i=h(n.timeZone)?tt(e?.timeZone??n.timeZone):void 0,s=e&&h(e.locale)?qt(e.locale):void 0,o=t.country??e?.geo?.country??r??i??e?.intl?.info?.region??s??"US",a=t.region??e?.geo?.region??e?.geo?.state;return{country:H(o),region:a?String(a).toUpperCase().replace(/^[A-Z]{2}-/,""):void 0,customHolidays:t.customHolidays,includeObserved:t.includeObserved??!0}}function Y(e){let t=String(e.mm).padStart(2,"0"),n=String(e.dd).padStart(2,"0");return`${e.yy}-${t}-${n}`}function Qt(e,t){let n=Re(e,t),r=Y(e);return Q(e.yy,n).filter(s=>s.date===r)}function ie(e,t){return Qt(e,t).length>0}function Pe(e,t){let n=Qt(e,t);return n.length===0?null:n[0].name}function R(e,t){let n=e.toDateTime().dayOfWeek;return(e.intl?.info?.weekend??[6,7]).includes(n)?!1:!ie(e,t)}function xe(e,t={}){return Q(e,t)}function ke(e,t){let n=e.add({days:1});for(;!R(n,t);)n=n.add({days:1});return n}function Le(e,t){let n=e.subtract({days:1});for(;!R(n,t);)n=n.subtract({days:1});return n}function Fe(e,t,n){if(t===0)return e;let r=t>0?1:-1,i=Math.abs(t),s=e;for(;i>0;)s=s.add({days:r}),R(s,n)&&i--;return s}function $e(e,t,n){let r=Y(e),i=Y(t);if(r===i)return 0;let s=e,o=0;if(e.epoch.ms<t.epoch.ms){for(s=s.add({days:1});Y(s)<=i;)R(s,n)&&o++,s=s.add({days:1});return o}else{for(s=s.subtract({days:1});Y(s)>=i;)R(s,n)&&o--,s=s.subtract({days:1});return o}}function ve(e,t,n){let r=n?.startHour??9,i=n?.endHour??17;if(r>=i)throw new Error("[holidays] startHour must be strictly less than endHour");let s=e.epoch.ms,o=t.epoch.ms;if(s===o)return 0;let a=s<o,c=a?e:t,u=a?t:e,f=0,d=c.set({hour:0,minute:0,second:0,millisecond:0}),m=Y(u);for(;Y(d)<=m;){if(R(d,n)){let p=d.set({hour:r,minute:0,second:0,millisecond:0}),T=d.set({hour:i,minute:0,second:0,millisecond:0}),b=Math.max(c.epoch.ms,p.epoch.ms),D=Math.min(u.epoch.ms,T.epoch.ms);b<D&&(f+=D-b)}d=d.add({days:1})}let y=f/(1e3*60*60);return a?y:-y}var jt=async(e,t=2e3,n={})=>{let r=new AbortController,i=setTimeout(()=>r.abort(),t),s=n.signal?AbortSignal.any([n.signal,r.signal]):r.signal;try{let o=await fetch(e,{...n,signal:s});if(!o.ok)throw new Error(`API returned ${o.status} for ${e}`);return o}finally{clearTimeout(i)}};var Tt,pr=()=>(Tt||(Tt=Intl.DateTimeFormat().resolvedOptions()),Tt),en=new Map,tn=e=>{let t=e||pr().locale,n=en.get(t);return n||(n=new Intl.Locale(t),en.set(t,n)),n};var nn=()=>{if(typeof globalThis<"u"&&"Temporal"in globalThis)return globalThis.Temporal;if(typeof Temporal<"u")return Temporal;throw new Error("[functions] Temporal API is not available in the global scope. Ensure a polyfill is loaded.")};var yr="https://date.nager.at/api/v3/PublicHolidays",bt=new Map,We=async(e=nn().Now.plainDateISO().year,t)=>{let n=t||tn().region||"US",r=`${e}-${n}`;if(bt.has(r))return bt.get(r);let i=n.split("-")[0].toUpperCase();if(!/^[A-Z]{2}$/.test(i))throw new Error(`[functions] Invalid region code: '${n}'. Expected a 2-letter ISO 3166-1 country code.`);let s=await jt(`${yr}/${e}/${i}`,2e3);if(!s.ok)throw new Error(`[functions] Failed to fetch holidays: HTTP ${s.status} ${s.statusText}`);let o=await s.json();return bt.set(r,o),o};var gr="_magma_holidays_",rn=1440*60*1e3;async function Ue(e,t){let n=h(t)?{country:t}:t??{},r=H(n.country),i=n.region,s=`${gr}${e}_${r}`;if(ht(r)){let a=Q(e,n);return at(s,a,{ttl:rn}),a}let o=Ne(s);if(o&&Array.isArray(o)&&o.length>0)return St(e,r,o),on(o,i);try{let c=(await We(e,r)||[]).flatMap(u=>u.counties&&u.counties.length>0?u.counties.map(f=>({date:u.date,name:u.name||u.localName,country:u.countryCode,region:f})):[{date:u.date,name:u.name||u.localName,country:u.countryCode,region:void 0}]);return at(s,c,{ttl:rn}),St(e,r,c),on(c,i)}catch{return Q(e,n)}}function on(e,t){if(!t)return e;let n=t.toUpperCase().replace(/^[A-Z]{2}-/,"");return e.filter(r=>!r.region||r.region.toUpperCase().replace(/^[A-Z]{2}-/,"")===n)}function j(e){return h(e)?{country:e}:e??{}}var sn=Ye({name:"holidays",install(e){let t={preload:Ue,getYearHolidays:xe,isPublicHoliday:ie,isBusinessDay:R,getHolidayName:Pe,nextBusinessDay:ke,prevBusinessDay:Le,addBusinessDays:Fe,businessDaysBetween:$e,workingHoursBetween:ve,normalizeCountryCode:H};(0,I.hasOwn)(e,"holidays")||Object.defineProperty(e,"holidays",{value:Object.freeze(t),writable:!1,configurable:!1,enumerable:!1}),(0,I.hasOwn)(e.prototype,"holidays")||Object.defineProperty(e.prototype,"holidays",{get(){let n=this,r=Re(n),i=Pe(n,r),s=xe(n.yy,r),o=H(r.country);return Object.freeze({name:i,list:Object.freeze(s),country:o,region:r.region,isHoliday:a=>{let c=j(a);return ie(n,c)},isBusinessDay:a=>{let c=j(a);return R(n,c)},nextBusinessDay:a=>{let c=j(a);return ke(n,c)},prevBusinessDay:a=>{let c=j(a);return Le(n,c)},addBusinessDays:(a,c)=>{let u=j(c);return Fe(n,a,u)},businessDaysUntil:(a,c)=>{let u=j(c);return $e(n,a,u)},workingHoursUntil:(a,c)=>ve(n,a,c),preload:a=>Ue(a??n.yy,Re(n))})},enumerable:!1,configurable:!0})}}),hr=sn;return yn(Sr);})();
|