@hebcal/core 5.6.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/CalOptions.d.ts +1 -1
- package/dist/HolidayEvent.d.ts +0 -5
- package/dist/YomKippurKatanEvent.d.ts +0 -1
- package/dist/bundle.js +9735 -9576
- package/dist/bundle.js.map +1 -1
- package/dist/bundle.min.js +2 -2
- package/dist/bundle.min.js.map +1 -1
- package/dist/calendar.d.ts +110 -0
- package/dist/candles.d.ts +9 -1
- package/dist/es/CalOptions.d.ts +158 -0
- package/dist/es/DailyLearning.d.ts +21 -0
- package/dist/es/DailyLearning.js +36 -0
- package/dist/es/DailyLearning.js.map +1 -0
- package/dist/es/HebrewDateEvent.d.ts +37 -0
- package/dist/es/HebrewDateEvent.js +77 -0
- package/dist/es/HebrewDateEvent.js.map +1 -0
- package/dist/es/HolidayEvent.d.ts +76 -0
- package/dist/es/HolidayEvent.js +165 -0
- package/dist/es/HolidayEvent.js.map +1 -0
- package/dist/es/MevarchimChodeshEvent.d.ts +25 -0
- package/dist/es/MevarchimChodeshEvent.js +54 -0
- package/dist/es/MevarchimChodeshEvent.js.map +1 -0
- package/dist/es/ParshaEvent.d.ts +23 -0
- package/dist/es/ParshaEvent.js +53 -0
- package/dist/es/ParshaEvent.js.map +1 -0
- package/dist/es/TimedEvent.d.ts +47 -0
- package/dist/es/TimedEvent.js +97 -0
- package/dist/es/TimedEvent.js.map +1 -0
- package/dist/es/YomKippurKatanEvent.d.ts +23 -0
- package/dist/es/YomKippurKatanEvent.js +43 -0
- package/dist/es/YomKippurKatanEvent.js.map +1 -0
- package/dist/es/ashkenazi.po.d.ts +67 -0
- package/dist/es/ashkenazi.po.js +5 -0
- package/dist/es/ashkenazi.po.js.map +1 -0
- package/dist/es/calendar.d.ts +110 -0
- package/dist/es/calendar.js +615 -0
- package/dist/es/calendar.js.map +1 -0
- package/dist/es/candles.d.ts +36 -0
- package/dist/es/candles.js +154 -0
- package/dist/es/candles.js.map +1 -0
- package/dist/es/event.d.ts +187 -0
- package/dist/es/event.js +243 -0
- package/dist/es/event.js.map +1 -0
- package/dist/es/getStartAndEnd.d.ts +6 -0
- package/dist/es/getStartAndEnd.js +102 -0
- package/dist/es/getStartAndEnd.js.map +1 -0
- package/dist/es/hallel.d.ts +6 -0
- package/dist/es/hallel.js +52 -0
- package/dist/es/hallel.js.map +1 -0
- package/dist/es/he.po.d.ts +246 -0
- package/dist/es/he.po.js +5 -0
- package/dist/es/he.po.js.map +1 -0
- package/dist/es/hebcal.d.ts +259 -0
- package/dist/es/hebcal.js +336 -0
- package/dist/es/hebcal.js.map +1 -0
- package/dist/es/holidays.d.ts +22 -0
- package/dist/es/holidays.js +321 -0
- package/dist/es/holidays.js.map +1 -0
- package/dist/es/index.d.ts +23 -0
- package/dist/es/index.js +22 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/locale.d.ts +1 -0
- package/dist/es/locale.js +21 -0
- package/dist/es/locale.js.map +1 -0
- package/dist/es/location.d.ts +73 -0
- package/dist/es/location.js +306 -0
- package/dist/es/location.js.map +1 -0
- package/dist/es/modern.d.ts +18 -0
- package/dist/es/modern.js +64 -0
- package/dist/es/modern.js.map +1 -0
- package/dist/es/molad.d.ts +62 -0
- package/dist/es/molad.js +141 -0
- package/dist/es/molad.js.map +1 -0
- package/dist/es/omer.d.ts +37 -0
- package/dist/es/omer.js +88 -0
- package/dist/es/omer.js.map +1 -0
- package/dist/es/parshaName.d.ts +3 -0
- package/dist/es/parshaName.js +19 -0
- package/dist/es/parshaName.js.map +1 -0
- package/dist/es/pkgVersion.d.ts +2 -0
- package/dist/es/pkgVersion.js +6 -0
- package/dist/es/pkgVersion.js.map +1 -0
- package/dist/es/reformatTimeStr.d.ts +8 -0
- package/dist/es/reformatTimeStr.js +52 -0
- package/dist/es/reformatTimeStr.js.map +1 -0
- package/dist/es/sedra.d.ts +107 -0
- package/dist/es/sedra.js +494 -0
- package/dist/es/sedra.js.map +1 -0
- package/dist/es/staticHolidays.d.ts +176 -0
- package/dist/es/staticHolidays.js +626 -0
- package/dist/es/staticHolidays.js.map +1 -0
- package/dist/es/tachanun.d.ts +29 -0
- package/dist/es/tachanun.js +125 -0
- package/dist/es/tachanun.js.map +1 -0
- package/dist/es/zmanim.d.ts +341 -0
- package/dist/es/zmanim.js +573 -0
- package/dist/es/zmanim.js.map +1 -0
- package/dist/event.d.ts +1 -0
- package/dist/he.po.d.ts +0 -51
- package/dist/holidays.d.ts +13 -0
- package/dist/index.cjs +2757 -10038
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/module.d.ts +105 -80
- package/dist/pkgVersion.d.ts +1 -1
- package/dist/sedra.d.ts +9 -4
- package/dist/tachanun.d.ts +17 -1
- package/package.json +21 -9
- package/dist/index.mjs +0 -11993
- package/dist/index.mjs.map +0 -1
package/dist/es/event.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/*! @hebcal/core v5.7.0 */
|
|
2
|
+
import { HDate, Locale } from '@hebcal/hdate';
|
|
3
|
+
import './locale.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Holiday flags for Event. These flags are typically
|
|
7
|
+
* combined using bitwise arithmetic to form a mask.
|
|
8
|
+
* @readonly
|
|
9
|
+
* @enum {number}
|
|
10
|
+
*/
|
|
11
|
+
const flags = {
|
|
12
|
+
/** Chag, yontiff, yom tov */
|
|
13
|
+
CHAG: 0x000001,
|
|
14
|
+
/** Light candles 18 minutes before sundown */
|
|
15
|
+
LIGHT_CANDLES: 0x000002,
|
|
16
|
+
/** End of holiday (end of Yom Tov) */
|
|
17
|
+
YOM_TOV_ENDS: 0x000004,
|
|
18
|
+
/** Observed only in the Diaspora (chutz l'aretz) */
|
|
19
|
+
CHUL_ONLY: 0x000008,
|
|
20
|
+
/** Observed only in Israel */
|
|
21
|
+
IL_ONLY: 0x000010,
|
|
22
|
+
/** Light candles in the evening at Tzeit time (3 small stars) */
|
|
23
|
+
LIGHT_CANDLES_TZEIS: 0x000020,
|
|
24
|
+
/** Candle-lighting for Chanukah */
|
|
25
|
+
CHANUKAH_CANDLES: 0x000040,
|
|
26
|
+
/** Rosh Chodesh, beginning of a new Hebrew month */
|
|
27
|
+
ROSH_CHODESH: 0x000080,
|
|
28
|
+
/** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */
|
|
29
|
+
MINOR_FAST: 0x000100,
|
|
30
|
+
/** Shabbat Shekalim, Zachor, ... */
|
|
31
|
+
SPECIAL_SHABBAT: 0x000200,
|
|
32
|
+
/** Weekly sedrot on Saturdays */
|
|
33
|
+
PARSHA_HASHAVUA: 0x000400,
|
|
34
|
+
/** Daily page of Talmud (Bavli) */
|
|
35
|
+
DAF_YOMI: 0x000800,
|
|
36
|
+
/** Days of the Omer */
|
|
37
|
+
OMER_COUNT: 0x001000,
|
|
38
|
+
/** Yom HaShoah, Yom HaAtzma'ut, ... */
|
|
39
|
+
MODERN_HOLIDAY: 0x002000,
|
|
40
|
+
/** Yom Kippur and Tish'a B'Av */
|
|
41
|
+
MAJOR_FAST: 0x004000,
|
|
42
|
+
/** On the Saturday before Rosh Chodesh */
|
|
43
|
+
SHABBAT_MEVARCHIM: 0x008000,
|
|
44
|
+
/** Molad */
|
|
45
|
+
MOLAD: 0x010000,
|
|
46
|
+
/** Yahrzeit or Hebrew Anniversary */
|
|
47
|
+
USER_EVENT: 0x020000,
|
|
48
|
+
/** Daily Hebrew date ("11th of Sivan, 5780") */
|
|
49
|
+
HEBREW_DATE: 0x040000,
|
|
50
|
+
/** A holiday that's not major, modern, rosh chodesh, or a fast day */
|
|
51
|
+
MINOR_HOLIDAY: 0x080000,
|
|
52
|
+
/** Evening before a major or minor holiday */
|
|
53
|
+
EREV: 0x100000,
|
|
54
|
+
/** Chol haMoed, intermediate days of Pesach or Sukkot */
|
|
55
|
+
CHOL_HAMOED: 0x200000,
|
|
56
|
+
/** Mishna Yomi */
|
|
57
|
+
MISHNA_YOMI: 0x400000,
|
|
58
|
+
/** Yom Kippur Katan, minor day of atonement on the day preceeding each Rosh Chodesh */
|
|
59
|
+
YOM_KIPPUR_KATAN: 0x800000,
|
|
60
|
+
/** Daily page of Jerusalem Talmud (Yerushalmi) */
|
|
61
|
+
YERUSHALMI_YOMI: 0x1000000,
|
|
62
|
+
/** Nach Yomi */
|
|
63
|
+
NACH_YOMI: 0x2000000,
|
|
64
|
+
/** Daily Learning */
|
|
65
|
+
DAILY_LEARNING: 0x4000000,
|
|
66
|
+
};
|
|
67
|
+
const flagToCategory = [
|
|
68
|
+
[flags.MAJOR_FAST, 'holiday', 'major', 'fast'],
|
|
69
|
+
[flags.CHANUKAH_CANDLES, 'holiday', 'major'],
|
|
70
|
+
[flags.HEBREW_DATE, 'hebdate'],
|
|
71
|
+
[flags.MINOR_FAST, 'holiday', 'fast'],
|
|
72
|
+
[flags.MINOR_HOLIDAY, 'holiday', 'minor'],
|
|
73
|
+
[flags.MODERN_HOLIDAY, 'holiday', 'modern'],
|
|
74
|
+
[flags.MOLAD, 'molad'],
|
|
75
|
+
[flags.OMER_COUNT, 'omer'],
|
|
76
|
+
[flags.PARSHA_HASHAVUA, 'parashat'], // backwards-compat
|
|
77
|
+
[flags.ROSH_CHODESH, 'roshchodesh'],
|
|
78
|
+
[flags.SHABBAT_MEVARCHIM, 'mevarchim'],
|
|
79
|
+
[flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'],
|
|
80
|
+
[flags.USER_EVENT, 'user'],
|
|
81
|
+
];
|
|
82
|
+
/**
|
|
83
|
+
* Represents an Event with a title, date, and flags.
|
|
84
|
+
*
|
|
85
|
+
* Events are used to represent holidays, candle-lighting times,
|
|
86
|
+
* Torah readings, and more.
|
|
87
|
+
*
|
|
88
|
+
* To get the title of the event a language other than English
|
|
89
|
+
* with Sephardic transliterations, use the `render()` method.
|
|
90
|
+
*/
|
|
91
|
+
class Event {
|
|
92
|
+
/**
|
|
93
|
+
* Constructs Event
|
|
94
|
+
* @param date Hebrew date event occurs
|
|
95
|
+
* @param desc Description (not translated)
|
|
96
|
+
* @param [mask=0] optional bitmask of holiday flags (see {@link flags})
|
|
97
|
+
* @param [attrs={}] optional additional attributes (e.g. `eventTimeStr`, `cholHaMoedDay`)
|
|
98
|
+
*/
|
|
99
|
+
constructor(date, desc, mask = 0, attrs) {
|
|
100
|
+
if (!HDate.isHDate(date)) {
|
|
101
|
+
throw new TypeError(`Invalid Event date: ${date}`);
|
|
102
|
+
}
|
|
103
|
+
else if (typeof desc !== 'string') {
|
|
104
|
+
throw new TypeError(`Invalid Event description: ${desc}`);
|
|
105
|
+
}
|
|
106
|
+
this.date = date;
|
|
107
|
+
this.desc = desc;
|
|
108
|
+
this.mask = +mask;
|
|
109
|
+
if (typeof attrs === 'object' && attrs !== null) {
|
|
110
|
+
Object.assign(this, attrs);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Hebrew date of this event
|
|
115
|
+
*/
|
|
116
|
+
getDate() {
|
|
117
|
+
return this.date;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Untranslated title of this event. Note that these description
|
|
121
|
+
* strings are always in English and will remain stable across releases.
|
|
122
|
+
* To get the title of the event in another language, use the
|
|
123
|
+
* `render()` method.
|
|
124
|
+
*/
|
|
125
|
+
getDesc() {
|
|
126
|
+
return this.desc;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Bitmask of optional event flags. See {@link flags}
|
|
130
|
+
*/
|
|
131
|
+
getFlags() {
|
|
132
|
+
return this.mask;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns (translated) description of this event
|
|
136
|
+
* @example
|
|
137
|
+
* const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);
|
|
138
|
+
* ev.render('en'); // 'Shavuot'
|
|
139
|
+
* ev.render('he'); // 'שָׁבוּעוֹת'
|
|
140
|
+
* ev.render('ashkenazi'); // 'Shavuos'
|
|
141
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
142
|
+
*/
|
|
143
|
+
render(locale) {
|
|
144
|
+
return Locale.gettext(this.desc, locale);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns a brief (translated) description of this event.
|
|
148
|
+
* For most events, this is the same as render(). For some events, it procudes
|
|
149
|
+
* a shorter text (e.g. without a time or added description).
|
|
150
|
+
* @param [locale] Optional locale name (defaults to active locale).
|
|
151
|
+
*/
|
|
152
|
+
renderBrief(locale) {
|
|
153
|
+
return this.render(locale);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Optional holiday-specific Emoji or `null`.
|
|
157
|
+
*/
|
|
158
|
+
getEmoji() {
|
|
159
|
+
return this.emoji || null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Returns a simplified (untranslated) description for this event. For example,
|
|
163
|
+
* the `HolidayEvent` class supports
|
|
164
|
+
* "Erev Pesach" => "Pesach", and "Sukkot III (CH''M)" => "Sukkot".
|
|
165
|
+
* For many holidays the basename and the event description are the same.
|
|
166
|
+
*/
|
|
167
|
+
basename() {
|
|
168
|
+
return this.getDesc();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Returns a URL to hebcal.com or sefaria.org for more detail on the event.
|
|
172
|
+
* Returns `undefined` for events with no detail page.
|
|
173
|
+
*/
|
|
174
|
+
url() {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Is this event observed in Israel?
|
|
179
|
+
* @example
|
|
180
|
+
* const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
|
|
181
|
+
* ev1.observedInIsrael(); // false
|
|
182
|
+
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
183
|
+
* ev2.observedInIsrael(); // true
|
|
184
|
+
*/
|
|
185
|
+
observedInIsrael() {
|
|
186
|
+
return !(this.mask & flags.CHUL_ONLY);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Is this event observed in the Diaspora?
|
|
190
|
+
* @example
|
|
191
|
+
* const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
|
|
192
|
+
* ev1.observedInDiaspora(); // true
|
|
193
|
+
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
194
|
+
* ev2.observedInDiaspora(); // true
|
|
195
|
+
*/
|
|
196
|
+
observedInDiaspora() {
|
|
197
|
+
return !(this.mask & flags.IL_ONLY);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Is this event observed in Israel/Diaspora?
|
|
201
|
+
* @example
|
|
202
|
+
* const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);
|
|
203
|
+
* ev1.observedIn(false); // true
|
|
204
|
+
* ev1.observedIn(true); // false
|
|
205
|
+
* const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);
|
|
206
|
+
* ev2.observedIn(false); // true
|
|
207
|
+
* ev2.observedIn(true); // true
|
|
208
|
+
* @param il
|
|
209
|
+
*/
|
|
210
|
+
observedIn(il) {
|
|
211
|
+
return il ? this.observedInIsrael() : this.observedInDiaspora();
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Makes a clone of this Event object
|
|
215
|
+
* @deprecated
|
|
216
|
+
*/
|
|
217
|
+
clone() {
|
|
218
|
+
const ev = new Event(this.date, this.desc, this.mask);
|
|
219
|
+
for (const property in this) {
|
|
220
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
221
|
+
if (this.hasOwnProperty(property)) {
|
|
222
|
+
Object.defineProperty(ev, property, { value: this[property] });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return ev;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Returns a list of event categories
|
|
229
|
+
*/
|
|
230
|
+
getCategories() {
|
|
231
|
+
const mask = this.getFlags();
|
|
232
|
+
for (const attrs of flagToCategory) {
|
|
233
|
+
const attr0 = attrs[0];
|
|
234
|
+
if (mask & attr0) {
|
|
235
|
+
return attrs.slice(1);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return ['unknown'];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export { Event, flags };
|
|
243
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sources":["../../../src/event.ts"],"sourcesContent":["import {HDate, Locale} from '@hebcal/hdate';\nimport './locale'; // Adds Hebrew and Ashkenazic translations\n\n/**\n * Holiday flags for Event. These flags are typically\n * combined using bitwise arithmetic to form a mask.\n * @readonly\n * @enum {number}\n */\nexport const flags = {\n /** Chag, yontiff, yom tov */\n CHAG: 0x000001,\n /** Light candles 18 minutes before sundown */\n LIGHT_CANDLES: 0x000002,\n /** End of holiday (end of Yom Tov) */\n YOM_TOV_ENDS: 0x000004,\n /** Observed only in the Diaspora (chutz l'aretz) */\n CHUL_ONLY: 0x000008,\n /** Observed only in Israel */\n IL_ONLY: 0x000010,\n /** Light candles in the evening at Tzeit time (3 small stars) */\n LIGHT_CANDLES_TZEIS: 0x000020,\n /** Candle-lighting for Chanukah */\n CHANUKAH_CANDLES: 0x000040,\n /** Rosh Chodesh, beginning of a new Hebrew month */\n ROSH_CHODESH: 0x000080,\n /** Minor fasts like Tzom Tammuz, Ta'anit Esther, ... */\n MINOR_FAST: 0x000100,\n /** Shabbat Shekalim, Zachor, ... */\n SPECIAL_SHABBAT: 0x000200,\n /** Weekly sedrot on Saturdays */\n PARSHA_HASHAVUA: 0x000400,\n /** Daily page of Talmud (Bavli) */\n DAF_YOMI: 0x000800,\n /** Days of the Omer */\n OMER_COUNT: 0x001000,\n /** Yom HaShoah, Yom HaAtzma'ut, ... */\n MODERN_HOLIDAY: 0x002000,\n /** Yom Kippur and Tish'a B'Av */\n MAJOR_FAST: 0x004000,\n /** On the Saturday before Rosh Chodesh */\n SHABBAT_MEVARCHIM: 0x008000,\n /** Molad */\n MOLAD: 0x010000,\n /** Yahrzeit or Hebrew Anniversary */\n USER_EVENT: 0x020000,\n /** Daily Hebrew date (\"11th of Sivan, 5780\") */\n HEBREW_DATE: 0x040000,\n /** A holiday that's not major, modern, rosh chodesh, or a fast day */\n MINOR_HOLIDAY: 0x080000,\n /** Evening before a major or minor holiday */\n EREV: 0x100000,\n /** Chol haMoed, intermediate days of Pesach or Sukkot */\n CHOL_HAMOED: 0x200000,\n /** Mishna Yomi */\n MISHNA_YOMI: 0x400000,\n /** Yom Kippur Katan, minor day of atonement on the day preceeding each Rosh Chodesh */\n YOM_KIPPUR_KATAN: 0x800000,\n /** Daily page of Jerusalem Talmud (Yerushalmi) */\n YERUSHALMI_YOMI: 0x1000000,\n /** Nach Yomi */\n NACH_YOMI: 0x2000000,\n /** Daily Learning */\n DAILY_LEARNING: 0x4000000,\n} as const;\n\nconst flagToCategory = [\n [flags.MAJOR_FAST, 'holiday', 'major', 'fast'],\n [flags.CHANUKAH_CANDLES, 'holiday', 'major'],\n [flags.HEBREW_DATE, 'hebdate'],\n [flags.MINOR_FAST, 'holiday', 'fast'],\n [flags.MINOR_HOLIDAY, 'holiday', 'minor'],\n [flags.MODERN_HOLIDAY, 'holiday', 'modern'],\n [flags.MOLAD, 'molad'],\n [flags.OMER_COUNT, 'omer'],\n [flags.PARSHA_HASHAVUA, 'parashat'], // backwards-compat\n [flags.ROSH_CHODESH, 'roshchodesh'],\n [flags.SHABBAT_MEVARCHIM, 'mevarchim'],\n [flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'],\n [flags.USER_EVENT, 'user'],\n] as const;\n\n/**\n * Represents an Event with a title, date, and flags.\n *\n * Events are used to represent holidays, candle-lighting times,\n * Torah readings, and more.\n *\n * To get the title of the event a language other than English\n * with Sephardic transliterations, use the `render()` method.\n */\nexport class Event {\n /** Hebrew date of this event */\n readonly date: HDate;\n /**\n * Untranslated title of this event. Note that these description\n * strings are always in English and will remain stable across releases.\n * To get the title of the event in another language, use the\n * `render()` method.\n */\n readonly desc: string;\n /** Bitmask of optional event flags. See {@link flags} */\n readonly mask: number;\n /** Optional emoji character such as ✡️, 🕯️, 🕎, 🕍, 🌒 */\n emoji?: string;\n /** Optional longer description or memo text */\n memo?: string;\n /** Alarms are used by iCalendar feeds */\n alarm?: Date | string | boolean;\n /**\n * Constructs Event\n * @param date Hebrew date event occurs\n * @param desc Description (not translated)\n * @param [mask=0] optional bitmask of holiday flags (see {@link flags})\n * @param [attrs={}] optional additional attributes (e.g. `eventTimeStr`, `cholHaMoedDay`)\n */\n constructor(date: HDate, desc: string, mask = 0, attrs?: object) {\n if (!HDate.isHDate(date)) {\n throw new TypeError(`Invalid Event date: ${date}`);\n } else if (typeof desc !== 'string') {\n throw new TypeError(`Invalid Event description: ${desc}`);\n }\n this.date = date;\n this.desc = desc;\n this.mask = +mask;\n if (typeof attrs === 'object' && attrs !== null) {\n Object.assign(this, attrs);\n }\n }\n /**\n * Hebrew date of this event\n */\n getDate(): HDate {\n return this.date;\n }\n /**\n * Untranslated title of this event. Note that these description\n * strings are always in English and will remain stable across releases.\n * To get the title of the event in another language, use the\n * `render()` method.\n */\n getDesc(): string {\n return this.desc;\n }\n /**\n * Bitmask of optional event flags. See {@link flags}\n */\n getFlags(): number {\n return this.mask;\n }\n /**\n * Returns (translated) description of this event\n * @example\n * const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG);\n * ev.render('en'); // 'Shavuot'\n * ev.render('he'); // 'שָׁבוּעוֹת'\n * ev.render('ashkenazi'); // 'Shavuos'\n * @param [locale] Optional locale name (defaults to active locale).\n */\n render(locale?: string): string {\n return Locale.gettext(this.desc, locale);\n }\n /**\n * Returns a brief (translated) description of this event.\n * For most events, this is the same as render(). For some events, it procudes\n * a shorter text (e.g. without a time or added description).\n * @param [locale] Optional locale name (defaults to active locale).\n */\n renderBrief(locale?: string): string {\n return this.render(locale);\n }\n /**\n * Optional holiday-specific Emoji or `null`.\n */\n getEmoji(): string | null {\n return this.emoji || null;\n }\n /**\n * Returns a simplified (untranslated) description for this event. For example,\n * the `HolidayEvent` class supports\n * \"Erev Pesach\" => \"Pesach\", and \"Sukkot III (CH''M)\" => \"Sukkot\".\n * For many holidays the basename and the event description are the same.\n */\n basename(): string {\n return this.getDesc();\n }\n /**\n * Returns a URL to hebcal.com or sefaria.org for more detail on the event.\n * Returns `undefined` for events with no detail page.\n */\n url(): string | undefined {\n return undefined;\n }\n /**\n * Is this event observed in Israel?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedInIsrael(); // false\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedInIsrael(); // true\n */\n observedInIsrael(): boolean {\n return !(this.mask & flags.CHUL_ONLY);\n }\n /**\n * Is this event observed in the Diaspora?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedInDiaspora(); // true\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedInDiaspora(); // true\n */\n observedInDiaspora(): boolean {\n return !(this.mask & flags.IL_ONLY);\n }\n /**\n * Is this event observed in Israel/Diaspora?\n * @example\n * const ev1 = new Event(new HDate(7, 'Sivan', 5749), 'Shavuot II', flags.CHAG | flags.CHUL_ONLY);\n * ev1.observedIn(false); // true\n * ev1.observedIn(true); // false\n * const ev2 = new Event(new HDate(26, 'Kislev', 5749), 'Chanukah: 3 Candles', 0);\n * ev2.observedIn(false); // true\n * ev2.observedIn(true); // true\n * @param il\n */\n observedIn(il: boolean): boolean {\n return il ? this.observedInIsrael() : this.observedInDiaspora();\n }\n /**\n * Makes a clone of this Event object\n * @deprecated\n */\n clone(): Event {\n const ev = new Event(this.date, this.desc, this.mask);\n for (const property in this) {\n // eslint-disable-next-line no-prototype-builtins\n if (this.hasOwnProperty(property)) {\n Object.defineProperty(ev, property, {value: this[property]});\n }\n }\n return ev;\n }\n /**\n * Returns a list of event categories\n */\n getCategories(): string[] {\n const mask = this.getFlags();\n for (const attrs of flagToCategory) {\n const attr0 = attrs[0] as number;\n if (mask & attr0) {\n return attrs.slice(1) as string[];\n }\n }\n return ['unknown'];\n }\n}\n"],"names":[],"mappings":";;;;AAGA;;;;;AAKG;AACU,MAAA,KAAK,GAAG;;AAEnB,IAAA,IAAI,EAAE,QAAQ;;AAEd,IAAA,aAAa,EAAE,QAAQ;;AAEvB,IAAA,YAAY,EAAE,QAAQ;;AAEtB,IAAA,SAAS,EAAE,QAAQ;;AAEnB,IAAA,OAAO,EAAE,QAAQ;;AAEjB,IAAA,mBAAmB,EAAE,QAAQ;;AAE7B,IAAA,gBAAgB,EAAE,QAAQ;;AAE1B,IAAA,YAAY,EAAE,QAAQ;;AAEtB,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,eAAe,EAAE,QAAQ;;AAEzB,IAAA,eAAe,EAAE,QAAQ;;AAEzB,IAAA,QAAQ,EAAE,QAAQ;;AAElB,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,cAAc,EAAE,QAAQ;;AAExB,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,iBAAiB,EAAE,QAAQ;;AAE3B,IAAA,KAAK,EAAE,QAAQ;;AAEf,IAAA,UAAU,EAAE,QAAQ;;AAEpB,IAAA,WAAW,EAAE,QAAQ;;AAErB,IAAA,aAAa,EAAE,QAAQ;;AAEvB,IAAA,IAAI,EAAE,QAAQ;;AAEd,IAAA,WAAW,EAAE,QAAQ;;AAErB,IAAA,WAAW,EAAE,QAAQ;;AAErB,IAAA,gBAAgB,EAAE,QAAQ;;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,CAAC,EAAW,EAAA;AACpB,QAAA,OAAO,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,kBAAkB,EAAE;;AAEjE;;;AAGG;IACH,KAAK,GAAA;AACH,QAAA,MAAM,EAAE,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;AACrD,QAAA,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE;;AAE3B,YAAA,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;AACjC,gBAAA,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;;;AAGhE,QAAA,OAAO,EAAE;;AAEX;;AAEG;IACH,aAAa,GAAA;AACX,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE;AAC5B,QAAA,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE;AAClC,YAAA,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAW;AAChC,YAAA,IAAI,IAAI,GAAG,KAAK,EAAE;AAChB,gBAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAa;;;QAGrC,OAAO,CAAC,SAAS,CAAC;;AAErB;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*! @hebcal/core v5.7.0 */
|
|
2
|
+
import { months, HDate, greg2abs, daysInGregMonth, isDate } from '@hebcal/hdate';
|
|
3
|
+
|
|
4
|
+
const TISHREI = months.TISHREI;
|
|
5
|
+
/**
|
|
6
|
+
* Gets the R.D. days for a number, Date, or HDate
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
function getAbs(d) {
|
|
10
|
+
if (typeof d === 'number')
|
|
11
|
+
return d;
|
|
12
|
+
if (isDate(d))
|
|
13
|
+
return greg2abs(d);
|
|
14
|
+
if (HDate.isHDate(d))
|
|
15
|
+
return d.abs();
|
|
16
|
+
throw new TypeError(`Invalid date type: ${d}`);
|
|
17
|
+
}
|
|
18
|
+
function getYear(options) {
|
|
19
|
+
if (typeof options.year !== 'undefined') {
|
|
20
|
+
return Number(options.year);
|
|
21
|
+
}
|
|
22
|
+
return options.isHebrewYear
|
|
23
|
+
? new HDate().getFullYear()
|
|
24
|
+
: new Date().getFullYear();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse options object to determine start & end days
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
function getStartAndEnd(options) {
|
|
31
|
+
if ((options.start && !options.end) || (options.end && !options.start)) {
|
|
32
|
+
throw new TypeError('Both options.start and options.end are required');
|
|
33
|
+
}
|
|
34
|
+
else if (options.start && options.end) {
|
|
35
|
+
return [getAbs(options.start), getAbs(options.end)];
|
|
36
|
+
}
|
|
37
|
+
const isHebrewYear = Boolean(options.isHebrewYear);
|
|
38
|
+
const theYear = getYear(options);
|
|
39
|
+
if (isNaN(theYear)) {
|
|
40
|
+
throw new RangeError(`Invalid year ${options.year}`);
|
|
41
|
+
}
|
|
42
|
+
else if (isHebrewYear && theYear < 1) {
|
|
43
|
+
throw new RangeError(`Invalid Hebrew year ${theYear}`);
|
|
44
|
+
}
|
|
45
|
+
const theMonth = getMonth(options);
|
|
46
|
+
const numYears = Number(options.numYears) || 1;
|
|
47
|
+
if (isHebrewYear) {
|
|
48
|
+
return startEndHebrew(theMonth, theYear, numYears);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return startEndGregorian(theMonth, theYear, numYears);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function getMonth(options) {
|
|
55
|
+
if (options.month) {
|
|
56
|
+
if (options.isHebrewYear) {
|
|
57
|
+
return HDate.monthNum(options.month);
|
|
58
|
+
}
|
|
59
|
+
else if (typeof options.month === 'number') {
|
|
60
|
+
return options.month;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return NaN;
|
|
64
|
+
}
|
|
65
|
+
function startEndGregorian(theMonth, theYear, numYears) {
|
|
66
|
+
const gregMonth = theMonth ? theMonth - 1 : 0;
|
|
67
|
+
const startGreg = new Date(theYear, gregMonth, 1);
|
|
68
|
+
if (theYear < 100) {
|
|
69
|
+
startGreg.setFullYear(theYear);
|
|
70
|
+
}
|
|
71
|
+
const startAbs = greg2abs(startGreg);
|
|
72
|
+
let endAbs;
|
|
73
|
+
if (theMonth) {
|
|
74
|
+
endAbs = startAbs + daysInGregMonth(theMonth, theYear) - 1;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const endYear = theYear + numYears;
|
|
78
|
+
const endGreg = new Date(endYear, 0, 1);
|
|
79
|
+
if (endYear < 100) {
|
|
80
|
+
endGreg.setFullYear(endYear);
|
|
81
|
+
}
|
|
82
|
+
endAbs = greg2abs(endGreg) - 1;
|
|
83
|
+
}
|
|
84
|
+
return [startAbs, endAbs];
|
|
85
|
+
}
|
|
86
|
+
function startEndHebrew(theMonth, theYear, numYears) {
|
|
87
|
+
const startDate = new HDate(1, theMonth || TISHREI, theYear);
|
|
88
|
+
let startAbs = startDate.abs();
|
|
89
|
+
const endAbs = theMonth
|
|
90
|
+
? startAbs + startDate.daysInMonth()
|
|
91
|
+
: new HDate(1, TISHREI, theYear + numYears).abs() - 1;
|
|
92
|
+
// for full Hebrew year, start on Erev Rosh Hashana which
|
|
93
|
+
// is technically in the previous Hebrew year
|
|
94
|
+
// (but conveniently lets us get candle-lighting time for Erev)
|
|
95
|
+
if (!theMonth && theYear > 1) {
|
|
96
|
+
startAbs--;
|
|
97
|
+
}
|
|
98
|
+
return [startAbs, endAbs];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { getStartAndEnd };
|
|
102
|
+
//# sourceMappingURL=getStartAndEnd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStartAndEnd.js","sources":["../../../src/getStartAndEnd.ts"],"sourcesContent":["import {greg2abs, isDate, daysInGregMonth, HDate, months} from '@hebcal/hdate';\nimport {CalOptions} from './CalOptions';\n\nconst TISHREI = months.TISHREI;\n\n/**\n * Gets the R.D. days for a number, Date, or HDate\n * @private\n */\nfunction getAbs(d: Date | HDate | number): number {\n if (typeof d === 'number') return d;\n if (isDate(d)) return greg2abs(d as Date);\n if (HDate.isHDate(d)) return (d as HDate).abs();\n throw new TypeError(`Invalid date type: ${d}`);\n}\n\nfunction getYear(options: CalOptions): number {\n if (typeof options.year !== 'undefined') {\n return Number(options.year);\n }\n return options.isHebrewYear\n ? new HDate().getFullYear()\n : new Date().getFullYear();\n}\n\n/**\n * Parse options object to determine start & end days\n * @private\n */\nexport function getStartAndEnd(options: CalOptions): number[] {\n if ((options.start && !options.end) || (options.end && !options.start)) {\n throw new TypeError('Both options.start and options.end are required');\n } else if (options.start && options.end) {\n return [getAbs(options.start), getAbs(options.end)];\n }\n const isHebrewYear = Boolean(options.isHebrewYear);\n const theYear = getYear(options);\n if (isNaN(theYear)) {\n throw new RangeError(`Invalid year ${options.year}`);\n } else if (isHebrewYear && theYear < 1) {\n throw new RangeError(`Invalid Hebrew year ${theYear}`);\n }\n const theMonth = getMonth(options);\n const numYears = Number(options.numYears) || 1;\n if (isHebrewYear) {\n return startEndHebrew(theMonth, theYear, numYears);\n } else {\n return startEndGregorian(theMonth, theYear, numYears);\n }\n}\n\nfunction getMonth(options: CalOptions): number {\n if (options.month) {\n if (options.isHebrewYear) {\n return HDate.monthNum(options.month);\n } else if (typeof options.month === 'number') {\n return options.month;\n }\n }\n return NaN;\n}\n\nfunction startEndGregorian(\n theMonth: number,\n theYear: number,\n numYears: number\n): number[] {\n const gregMonth = theMonth ? theMonth - 1 : 0;\n const startGreg = new Date(theYear, gregMonth, 1);\n if (theYear < 100) {\n startGreg.setFullYear(theYear);\n }\n const startAbs = greg2abs(startGreg);\n let endAbs;\n if (theMonth) {\n endAbs = startAbs + daysInGregMonth(theMonth, theYear) - 1;\n } else {\n const endYear = theYear + numYears;\n const endGreg = new Date(endYear, 0, 1);\n if (endYear < 100) {\n endGreg.setFullYear(endYear);\n }\n endAbs = greg2abs(endGreg) - 1;\n }\n return [startAbs, endAbs];\n}\n\nfunction startEndHebrew(\n theMonth: number,\n theYear: number,\n numYears: number\n): number[] {\n const startDate = new HDate(1, theMonth || TISHREI, theYear);\n let startAbs = startDate.abs();\n const endAbs = theMonth\n ? startAbs + startDate.daysInMonth()\n : new HDate(1, TISHREI, theYear + numYears).abs() - 1;\n // for full Hebrew year, start on Erev Rosh Hashana which\n // is technically in the previous Hebrew year\n // (but conveniently lets us get candle-lighting time for Erev)\n if (!theMonth && theYear > 1) {\n startAbs--;\n }\n return [startAbs, endAbs];\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;AAE9B;;;AAGG;AACH,SAAS,MAAM,CAAC,CAAwB,EAAA;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAC;IACnC,IAAI,MAAM,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,QAAQ,CAAC,CAAS,CAAC;AACzC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAAE,QAAA,OAAQ,CAAW,CAAC,GAAG,EAAE;AAC/C,IAAA,MAAM,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAA,CAAE,CAAC;AAChD;AAEA,SAAS,OAAO,CAAC,OAAmB,EAAA;AAClC,IAAA,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE;AACvC,QAAA,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;;IAE7B,OAAO,OAAO,CAAC;AACb,UAAE,IAAI,KAAK,EAAE,CAAC,WAAW;AACzB,UAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC9B;AAEA;;;AAGG;AACG,SAAU,cAAc,CAAC,OAAmB,EAAA;IAChD,IAAI,CAA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IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;;;;AAIvD,IAAA,IAAI,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE;AAC5B,QAAA,QAAQ,EAAE;;AAEZ,IAAA,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;AAC3B;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*! @hebcal/core v5.7.0 */
|
|
2
|
+
import { months } from '@hebcal/hdate';
|
|
3
|
+
import { flags } from './event.js';
|
|
4
|
+
|
|
5
|
+
const NONE = 0;
|
|
6
|
+
const HALF = 1;
|
|
7
|
+
const WHOLE = 2;
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
function hallel_(events, hdate) {
|
|
12
|
+
const whole = events
|
|
13
|
+
.filter(ev => {
|
|
14
|
+
const desc = ev.getDesc();
|
|
15
|
+
const hd = ev.getDate();
|
|
16
|
+
const month = hd.getMonth();
|
|
17
|
+
const mday = hd.getDate();
|
|
18
|
+
return (desc.startsWith('Chanukah') ||
|
|
19
|
+
desc.startsWith('Shavuot') ||
|
|
20
|
+
desc.startsWith('Sukkot') ||
|
|
21
|
+
(month === months.NISAN &&
|
|
22
|
+
(mday === 15 || mday === 16) &&
|
|
23
|
+
ev.getFlags() & flags.CHAG) || // Pesach
|
|
24
|
+
desc === "Yom HaAtzma'ut" ||
|
|
25
|
+
desc === 'Yom Yerushalayim');
|
|
26
|
+
})
|
|
27
|
+
.map(ev => {
|
|
28
|
+
return ev.getDate().abs();
|
|
29
|
+
});
|
|
30
|
+
const abs = hdate.abs();
|
|
31
|
+
if (whole.includes(abs)) {
|
|
32
|
+
return WHOLE;
|
|
33
|
+
}
|
|
34
|
+
const half = events
|
|
35
|
+
.filter(ev => {
|
|
36
|
+
const desc = ev.getDesc();
|
|
37
|
+
return (ev.getFlags() & flags.ROSH_CHODESH ||
|
|
38
|
+
(desc.startsWith('Pesach') &&
|
|
39
|
+
desc !== 'Pesach I' &&
|
|
40
|
+
desc !== 'Pesach II'));
|
|
41
|
+
})
|
|
42
|
+
.map(ev => {
|
|
43
|
+
return ev.getDate().abs();
|
|
44
|
+
});
|
|
45
|
+
if (half.includes(abs)) {
|
|
46
|
+
return HALF;
|
|
47
|
+
}
|
|
48
|
+
return NONE;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { hallel_ };
|
|
52
|
+
//# sourceMappingURL=hallel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hallel.js","sources":["../../../src/hallel.ts"],"sourcesContent":["import {HDate, months} from '@hebcal/hdate';\nimport {Event, flags} from './event';\n\nconst NONE = 0;\nconst HALF = 1;\nconst WHOLE = 2;\n\n/**\n * @private\n */\nexport function hallel_(events: Event[], hdate: HDate): number {\n const whole = events\n .filter(ev => {\n const desc: string = ev.getDesc();\n const hd: HDate = ev.getDate();\n const month = hd.getMonth();\n const mday = hd.getDate();\n return (\n desc.startsWith('Chanukah') ||\n desc.startsWith('Shavuot') ||\n desc.startsWith('Sukkot') ||\n (month === months.NISAN &&\n (mday === 15 || mday === 16) &&\n ev.getFlags() & flags.CHAG) || // Pesach\n desc === \"Yom HaAtzma'ut\" ||\n desc === 'Yom Yerushalayim'\n );\n })\n .map(ev => {\n return ev.getDate().abs();\n });\n\n const abs = hdate.abs();\n if (whole.includes(abs)) {\n return WHOLE;\n }\n\n const half = events\n .filter(ev => {\n const desc = ev.getDesc();\n return (\n ev.getFlags() & flags.ROSH_CHODESH ||\n (desc.startsWith('Pesach') &&\n desc !== 'Pesach I' &&\n desc !== 'Pesach II')\n );\n })\n .map(ev => {\n return ev.getDate().abs();\n });\n\n if (half.includes(abs)) {\n return HALF;\n }\n\n return NONE;\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,K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