@hebcal/rest-api 5.0.4 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,990 +1,1303 @@
1
- /*! @hebcal/rest-api v5.0.4 */
2
- import { flags, HDate, HebrewCalendar, Zmanim, Locale, gematriya } from '@hebcal/core';
1
+ /*! @hebcal/rest-api v5.1.0 */
2
+ import { flags, HDate, HebrewCalendar, Zmanim, Locale as Locale$1, gematriya } from '@hebcal/core';
3
3
  import { getLeyningForParshaHaShavua, getLeyningForHoliday, formatAliyahWithBook } from '@hebcal/leyning';
4
4
  import { getTriennialForParshaHaShavua } from '@hebcal/triennial';
5
5
 
6
- var holidayDescription = {
7
- "Asara B'Tevet": "Fast commemorating the siege of Jerusalem",
8
- "Ben-Gurion Day": "Commemorates the life and vision of Israel's first Prime Minister David Ben-Gurion",
9
- "Birkat Hachamah": "A rare Jewish blessing recited once every 28 years thanking G-d for creating the sun",
10
- "Chag HaBanot": "North African Chanukah festival of daughters. Called Eid al-Banat in Arabic, the holiday was most preserved in Tunisia",
11
- "Chanukah": "Hanukkah, the Jewish festival of rededication. Also known as the Festival of Lights, the eight-day festival is observed by lighting the candles of a hanukkiah (menorah)",
12
- "Days of the Omer": "7 weeks from the second night of Pesach to the day before Shavuot. Also called Sefirat HaOmer, it is a practice that consists of a verbal counting of each of the forty-nine days between the two holidays",
13
- "Family Day": "Yom HaMishpacha, a day to honor the family unit",
14
- "Hebrew Language Day": "Promotes the Hebrew language in Israel and around the world. Occurs on the birthday of Eliezer Ben Yehuda, the father of modern spoken Hebrew",
15
- "Herzl Day": "Commemorates the life and vision of Zionist leader Theodor Herzl",
16
- "Jabotinsky Day": "Commemorates the life and vision of Zionist leader Ze'ev Jabotinsky",
17
- "Lag BaOmer": "33rd day of counting the Omer. The holiday is a temporary break from the semi-mourning period the counting of the Omer. Practices include lighting bonfires, getting haircuts, and Jewish weddings",
18
- "Leil Selichot": "Prayers for forgiveness in preparation for the High Holidays",
19
- "Pesach Sheni": "Second Passover, one month after Passover",
20
- "Pesach": "Passover, the Feast of Unleavened Bread. Also called Chag HaMatzot (the Festival of Matzah), it commemorates the Exodus and freedom of the Israelites from ancient Egypt",
21
- "Purim Katan": "Minor Purim celebration during Adar I on leap years",
22
- "Purim": "Celebration of Jewish deliverance as told by Megilat Esther. It commemorates a time when the Jewish people living in Persia were saved from extermination",
23
- "Purim Meshulash": "Triple Purim, spanning 3 days in Jerusalem and walled cities. It occurs when the 15th of Adar coincides with Shabbat",
24
- "Rosh Chodesh Nisan": "Start of month of Nisan on the Hebrew calendar. נִיסָן (transliterated Nisan or Nissan) is the 1st month of the Hebrew year, has 30 days, and corresponds to March or April on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
25
- "Rosh Chodesh Iyyar": "Start of month of Iyyar on the Hebrew calendar. אִיָיר (transliterated Iyyar or Iyar) is the 2nd month of the Hebrew year, has 29 days, and corresponds to April or May on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
26
- "Rosh Chodesh Sivan": "Start of month of Sivan on the Hebrew calendar. Sivan (סִיוָן) is the 3rd month of the Hebrew year, has 30 days, and corresponds to May or June on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
27
- "Rosh Chodesh Tamuz": "Start of month of Tamuz on the Hebrew calendar. תַּמּוּז (transliterated Tamuz or Tammuz) is the 4th month of the Hebrew year, has 29 days, and corresponds to June or July on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
28
- "Rosh Chodesh Av": "Start of month of Av on the Hebrew calendar. Av (אָב) is the 5th month of the Hebrew year, has 30 days, and corresponds to July or August on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
29
- "Rosh Chodesh Elul": "Start of month of Elul on the Hebrew calendar. Elul (אֱלוּל) is the 6th month of the Hebrew year, has 29 days, and corresponds to August or September on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
30
- "Rosh Chodesh Cheshvan": "Start of month of Cheshvan on the Hebrew calendar. חֶשְׁוָן (transliterated Cheshvan or Heshvan) is the 8th month of the Hebrew year, has 29 or 30 days, and corresponds to October or November on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
31
- "Rosh Chodesh Kislev": "Start of month of Kislev on the Hebrew calendar. Kislev (כִּסְלֵו) is the 9th month of the Hebrew year, has 30 or 29 days, and corresponds to November or December on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
32
- "Rosh Chodesh Tevet": "Start of month of Tevet on the Hebrew calendar. Tevet (טֵבֵת) is the 10th month of the Hebrew year, has 29 days, and corresponds to December or January on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
33
- "Rosh Chodesh Sh'vat": "Start of month of Sh'vat on the Hebrew calendar. שְׁבָט (transliterated Sh'vat or Shevat) is the 11th month of the Hebrew year, has 30 days, and corresponds to January or February on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
34
- "Rosh Chodesh Adar": "Start of month of Adar on the Hebrew calendar. Adar (אַדָר) is the 12th month of the Hebrew year, has 29 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
35
- "Rosh Chodesh Adar I": "Start of month of Adar I (on leap years) on the Hebrew calendar. Adar I (אַדָר א׳) is the 12th month of the Hebrew year, occurs only on leap years, has 30 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
36
- "Rosh Chodesh Adar II": "Start of month of Adar II (on leap years) on the Hebrew calendar. Adar II (אַדָר ב׳), sometimes \"Adar Bet\" or \"Adar Sheni\", is the 13th month of the Hebrew year, has 29 days, occurs only on leap years, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
37
- "Rosh Hashana": "The Jewish New Year. Also spelled Rosh Hashanah",
38
- "Rosh Hashana LaBehemot": "New Year for Tithing Animals",
39
- "Shabbat Chazon": "Shabbat of Prophecy/Shabbat of Vision. Shabbat before Tish'a B'Av",
40
- "Shabbat HaChodesh": "Shabbat before Rosh Chodesh Nissan. Read in preparation for Passover",
41
- "Shabbat HaGadol": "Shabbat before Pesach (The Great Shabbat)",
42
- "Shabbat Machar Chodesh": "When Shabbat falls the day before Rosh Chodesh",
43
- "Shabbat Nachamu": "Shabbat after Tish'a B'Av (Shabbat of Consolation). The first of seven Shabbatot leading up to Rosh Hashanah. Named after the Haftarah (from Isaiah 40) which begins with the verse נַחֲמוּ נַחֲמוּ, עַמִּי (\"Comfort, oh comfort my people\")",
44
- "Shabbat Parah": "Shabbat of the Red Heifer. Shabbat before Shabbat HaChodesh, in preparation for Passover",
45
- "Shabbat Rosh Chodesh": "When Shabbat falls on Rosh Chodesh",
46
- "Shabbat Shekalim": "Shabbat before Rosh Chodesh Adar. Read in preparation for Purim",
47
- "Shabbat Shirah": "Shabbat of Song. Shabbat that includes Parashat Beshalach",
48
- "Shabbat Shuva": "Shabbat of Returning. Shabbat that occurs during the Ten Days of Repentance between Rosh Hashanah and Yom Kippur",
49
- "Shabbat Zachor": "Shabbat of Remembrance. Shabbat before Purim",
50
- "Shavuot": "Festival of Weeks. Commemorates the giving of the Torah at Mount Sinai",
51
- "Shmini Atzeret": "Eighth Day of Assembly. Immediately following Sukkot, it is observed as a separate holiday in the Diaspora and is combined with Simchat Torah in Israel",
52
- "Shushan Purim": "Purim celebrated in Jerusalem and walled cities",
53
- "Shushan Purim Katan": "Minor Purim celebration during Adar I on leap years in Jerusalem and walled cities",
54
- "Sigd": "Ethiopian Jewish holiday occurring 50 days after Yom Kippur",
55
- "Simchat Torah": "Day of Celebrating the Torah. Celebration marking the conclusion of the annual cycle of public Torah readings, and the beginning of a new cycle",
56
- "Sukkot": "Feast of Booths. Also called the Feast of Tabernacles, the seven-day holiday is one of the Three Pilgrimage Festivals (Hebrew: שלוש רגלים, shalosh regalim)",
57
- "Ta'anit Bechorot": "Fast of the First Born",
58
- "Ta'anit Esther": "Fast of Esther",
59
- "Tish'a B'Av": "The Ninth of Av. Fast commemorating the destruction of the two Temples",
60
- "Tu B'Av": "Minor Jewish holiday of love. Observed on the 15th day of the Hebrew month of Av",
61
- "Tu BiShvat": "New Year for Trees. Tu BiShvat is one of four “New Years” mentioned in the Mishnah",
62
- "Tzom Gedaliah": "Fast of the Seventh Month. Commemorates the assassination of the Jewish governor of Judah",
63
- "Tzom Tammuz": "Fast commemorating breaching of the walls of Jerusalem before the destruction of the Second Temple",
64
- "Yitzhak Rabin Memorial Day": "Commemorates the life of Israeli Prime Minister Yitzhak Rabin",
65
- "Yom HaAliyah": "Recognizes Aliyah, immigration to the Jewish State of Israel",
66
- "Yom HaAliyah School Observance": "Aliyah Day observed in Israeli schools",
67
- "Yom HaAtzma'ut": "Israeli Independence Day. Commemorates the declaration of independence of Israel in 1948. Although Yom HaAtzma'ut is normally observed on the 5th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaZikaron, which always precedes it) would conflict with Shabbat",
68
- "Yom HaShoah": "Holocaust Memorial Day",
69
- "Yom HaZikaron": "Israeli Memorial Day. Remembers those who died in the War of Independence and other wars in Israel. The full name of the holiday is Yom HaZikaron LeHalalei Ma'arakhot Yisrael ul'Nifge'ei Pe'ulot HaEivah (Hebrew: יוֹם הזִּכָּרוֹן לְחַלְלֵי מַעֲרָכוֹת יִשְׂרָאֵל וּלְנִפְגְעֵי פְּעֻלּוֹת הָאֵיבָה), Memorial Day for the Fallen Soldiers of the Wars of Israel and Victims of Actions of Terrorism. Although Yom Hazikaron is normally observed on the 4th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaAtzma'ut, which always follows it) would conflict with Shabbat",
70
- "Yom Kippur": "Day of Atonement. The holiest day of the year in Judaism, traditionally observed with a 25-hour period of fasting and intensive prayer",
71
- "Yom Kippur Katan": "Minor day of atonement occurring monthly on the day preceeding each Rosh Chodesh",
72
- "Yom Yerushalayim": "Jerusalem Day. Commemorates the re-unification of Jerusalem in 1967"
73
- };
74
-
75
- var countryNames = {
76
- "AD": "Andorra",
77
- "AE": "United Arab Emirates",
78
- "AF": "Afghanistan",
79
- "AI": "Anguilla",
80
- "AL": "Albania",
81
- "AM": "Armenia",
82
- "AO": "Angola",
83
- "AR": "Argentina",
84
- "AS": "American Samoa",
85
- "AT": "Austria",
86
- "AU": "Australia",
87
- "AW": "Aruba",
88
- "AZ": "Azerbaijan",
89
- "BA": "Bosnia and Herzegovina",
90
- "BB": "Barbados",
91
- "BD": "Bangladesh",
92
- "BE": "Belgium",
93
- "BF": "Burkina Faso",
94
- "BG": "Bulgaria",
95
- "BH": "Bahrain",
96
- "BI": "Burundi",
97
- "BJ": "Benin",
98
- "BM": "Bermuda",
99
- "BN": "Brunei",
100
- "BO": "Bolivia",
101
- "BR": "Brazil",
102
- "BS": "Bahamas",
103
- "BT": "Bhutan",
104
- "BW": "Botswana",
105
- "BY": "Belarus",
106
- "BZ": "Belize",
107
- "CA": "Canada",
108
- "CD": "Democratic Republic of the Congo",
109
- "CF": "Central African Republic",
110
- "CG": "Republic of the Congo",
111
- "CH": "Switzerland",
112
- "CI": "Ivory Coast",
113
- "CK": "Cook Islands",
114
- "CL": "Chile",
115
- "CM": "Cameroon",
116
- "CN": "China",
117
- "CO": "Colombia",
118
- "CR": "Costa Rica",
119
- "CU": "Cuba",
120
- "CV": "Cape Verde",
121
- "CW": "Curacao",
122
- "CY": "Cyprus",
123
- "CZ": "Czech Republic",
124
- "DE": "Germany",
125
- "DK": "Denmark",
126
- "DM": "Dominica",
127
- "DO": "Dominican Republic",
128
- "DZ": "Algeria",
129
- "EC": "Ecuador",
130
- "EE": "Estonia",
131
- "EG": "Egypt",
132
- "ER": "Eritrea",
133
- "ES": "Spain",
134
- "ET": "Ethiopia",
135
- "FI": "Finland",
136
- "FJ": "Fiji",
137
- "FK": "Falkland Islands",
138
- "FO": "Faroe Islands",
139
- "FR": "France",
140
- "GA": "Gabon",
141
- "GB": "United Kingdom",
142
- "GE": "Georgia",
143
- "GH": "Ghana",
144
- "GI": "Gibraltar",
145
- "GL": "Greenland",
146
- "GM": "Gambia",
147
- "GN": "Guinea",
148
- "GQ": "Equatorial Guinea",
149
- "GR": "Greece",
150
- "GT": "Guatemala",
151
- "GW": "Guinea-Bissau",
152
- "GY": "Guyana",
153
- "HK": "Hong Kong",
154
- "HN": "Honduras",
155
- "HR": "Croatia",
156
- "HT": "Haiti",
157
- "HU": "Hungary",
158
- "ID": "Indonesia",
159
- "IE": "Ireland",
160
- "IL": "Israel",
161
- "IM": "Isle of Man",
162
- "IN": "India",
163
- "IQ": "Iraq",
164
- "IR": "Iran",
165
- "IS": "Iceland",
166
- "IT": "Italy",
167
- "JM": "Jamaica",
168
- "JO": "Jordan",
169
- "JP": "Japan",
170
- "KE": "Kenya",
171
- "KG": "Kyrgyzstan",
172
- "KH": "Cambodia",
173
- "KM": "Comoros",
174
- "KN": "Saint Kitts and Nevis",
175
- "KP": "North Korea",
176
- "KR": "South Korea",
177
- "KW": "Kuwait",
178
- "KY": "Cayman Islands",
179
- "KZ": "Kazakhstan",
180
- "LA": "Laos",
181
- "LB": "Lebanon",
182
- "LC": "Saint Lucia",
183
- "LI": "Liechtenstein",
184
- "LR": "Liberia",
185
- "LS": "Lesotho",
186
- "LT": "Lithuania",
187
- "LU": "Luxembourg",
188
- "LV": "Latvia",
189
- "LY": "Libya",
190
- "MA": "Morocco",
191
- "MD": "Moldova",
192
- "ME": "Montenegro",
193
- "MG": "Madagascar",
194
- "MK": "Macedonia",
195
- "ML": "Mali",
196
- "MM": "Myanmar",
197
- "MN": "Mongolia",
198
- "MP": "Northern Mariana Islands",
199
- "MR": "Mauritania",
200
- "MS": "Montserrat",
201
- "MT": "Malta",
202
- "MU": "Mauritius",
203
- "MW": "Malawi",
204
- "MX": "Mexico",
205
- "MY": "Malaysia",
206
- "MZ": "Mozambique",
207
- "NA": "Namibia",
208
- "NC": "New Caledonia",
209
- "NE": "Niger",
210
- "NG": "Nigeria",
211
- "NI": "Nicaragua",
212
- "NL": "Netherlands",
213
- "NO": "Norway",
214
- "NP": "Nepal",
215
- "NU": "Niue",
216
- "NZ": "New Zealand",
217
- "OM": "Oman",
218
- "PA": "Panama",
219
- "PE": "Peru",
220
- "PF": "French Polynesia",
221
- "PG": "Papua New Guinea",
222
- "PH": "Philippines",
223
- "PK": "Pakistan",
224
- "PL": "Poland",
225
- "PR": "Puerto Rico",
226
- "PT": "Portugal",
227
- "PY": "Paraguay",
228
- "QA": "Qatar",
229
- "RO": "Romania",
230
- "RS": "Serbia",
231
- "RU": "Russia",
232
- "RW": "Rwanda",
233
- "SA": "Saudi Arabia",
234
- "SB": "Solomon Islands",
235
- "SC": "Seychelles",
236
- "SD": "Sudan",
237
- "SE": "Sweden",
238
- "SG": "Singapore",
239
- "SH": "Saint Helena",
240
- "SI": "Slovenia",
241
- "SK": "Slovakia",
242
- "SL": "Sierra Leone",
243
- "SN": "Senegal",
244
- "SO": "Somalia",
245
- "SR": "Suriname",
246
- "ST": "Sao Tome and Principe",
247
- "SV": "El Salvador",
248
- "SY": "Syria",
249
- "SZ": "Swaziland",
250
- "TC": "Turks and Caicos Islands",
251
- "TD": "Chad",
252
- "TG": "Togo",
253
- "TH": "Thailand",
254
- "TJ": "Tajikistan",
255
- "TM": "Turkmenistan",
256
- "TN": "Tunisia",
257
- "TR": "Turkey",
258
- "TV": "Tuvalu",
259
- "TW": "Taiwan",
260
- "TZ": "Tanzania",
261
- "UA": "Ukraine",
262
- "UG": "Uganda",
263
- "US": "United States",
264
- "UY": "Uruguay",
265
- "UZ": "Uzbekistan",
266
- "VC": "Saint Vincent and the Grenadines",
267
- "VE": "Venezuela",
268
- "VG": "British Virgin Islands",
269
- "VN": "Vietnam",
270
- "WS": "Samoa",
271
- "YE": "Yemen",
272
- "YT": "Mayotte",
273
- "ZA": "South Africa",
274
- "ZM": "Zambia",
275
- "ZW": "Zimbabwe"
276
- };
277
-
6
+ /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
7
+ /** @private */
8
+ const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
9
+ /** @private */
10
+ const monthLengths = [lengths, lengths.slice()];
11
+ monthLengths[1][2] = 29;
278
12
  /**
279
- * Location information
280
- * @typedef {Object} LocationPlainObj
281
- * @property {string} title
282
- * @property {string} city
283
- * @property {string} tzid
284
- * @property {number} latitude
285
- * @property {number} longitude
286
- * @property {string} cc
287
- * @property {string} country
288
- * @property {string} admin1
289
- * @property {string} asciiname
290
- * @property {string} geo
291
- * @property {string} zip
292
- * @property {string} state
293
- * @property {string} stateName
294
- * @property {number} geonameid
13
+ * @private
295
14
  */
296
-
297
- const LOC_FIELDS = ['elevation', 'admin1', 'asciiname', 'geo', 'zip', 'state', 'stateName', 'geonameid'];
298
-
15
+ function mod(x, y) {
16
+ return x - y * Math.floor(x / y);
17
+ }
299
18
  /**
300
- * Converts a @hebcal/core `Location` to a plain JS object.
301
- * @param {Location} location
302
- * @return {LocationPlainObj}
19
+ * @private
303
20
  */
304
- function locationToPlainObj(location) {
305
- if (typeof location === 'object' && location !== null && typeof location.latitude === 'number') {
306
- const o = {
307
- title: location.getName(),
308
- city: location.getShortName(),
309
- tzid: location.getTzid(),
310
- latitude: location.getLatitude(),
311
- longitude: location.getLongitude(),
312
- cc: location.getCountryCode(),
313
- country: countryNames[location.getCountryCode()],
314
- };
315
- for (const k of LOC_FIELDS) {
316
- if (location[k]) {
317
- o[k] = location[k];
318
- }
319
- }
320
- return o;
321
- } else {
322
- return {geo: 'none'};
323
- }
21
+ function quotient(x, y) {
22
+ return Math.floor(x / y);
324
23
  }
325
-
326
24
  /**
327
- * Helper function to transform a string to make it more usable in a URL or filename.
328
- * Converts to lowercase and replaces non-word characters with hyphen ('-').
329
- * @example
330
- * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
331
- * @param {string} s
332
- * @return {string}
25
+ * @private
26
+ * @param abs - R.D. number of days
333
27
  */
334
- function makeAnchor(s) {
335
- return s.toLowerCase()
336
- .replace(/'/g, '')
337
- .replace(/[^\w]/g, '-')
338
- .replace(/-+/g, '-')
339
- .replace(/^-/g, '')
340
- .replace(/-$/g, '');
28
+ function yearFromFixed(abs) {
29
+ const l0 = abs - 1;
30
+ const n400 = quotient(l0, 146097);
31
+ const d1 = mod(l0, 146097);
32
+ const n100 = quotient(d1, 36524);
33
+ const d2 = mod(d1, 36524);
34
+ const n4 = quotient(d2, 1461);
35
+ const d3 = mod(d2, 1461);
36
+ const n1 = quotient(d3, 365);
37
+ const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
38
+ return n100 !== 4 && n1 !== 4 ? year + 1 : year;
39
+ }
40
+ /*
41
+ const ABS_14SEP1752 = 639797;
42
+ const ABS_2SEP1752 = 639785;
43
+ */
44
+ /**
45
+ * Gregorian date helper functions.
46
+ */
47
+ var greg;
48
+ (function (greg) {
49
+ /**
50
+ * Returns true if the Gregorian year is a leap year
51
+ * @param {number} year Gregorian year
52
+ * @return {boolean}
53
+ */
54
+ function isLeapYear(year) {
55
+ return !(year % 4) && (!!(year % 100) || !(year % 400));
56
+ }
57
+ greg.isLeapYear = isLeapYear;
58
+ /**
59
+ * Number of days in the Gregorian month for given year
60
+ * @param {number} month Gregorian month (1=January, 12=December)
61
+ * @param {number} year Gregorian year
62
+ * @return {number}
63
+ */
64
+ function daysInMonth(month, year) {
65
+ // 1 based months
66
+ return monthLengths[+isLeapYear(year)][month];
67
+ }
68
+ greg.daysInMonth = daysInMonth;
69
+ /**
70
+ * Returns true if the object is a Javascript Date
71
+ * @param {Object} obj
72
+ * @return {boolean}
73
+ */
74
+ function isDate(obj) {
75
+ // eslint-disable-next-line no-prototype-builtins
76
+ return typeof obj === 'object' && Date.prototype.isPrototypeOf(obj);
77
+ }
78
+ greg.isDate = isDate;
79
+ /**
80
+ * @private
81
+ * @param year
82
+ * @param month (1-12)
83
+ * @param day (1-31)
84
+ */
85
+ function toFixed(year, month, day) {
86
+ const py = year - 1;
87
+ return (365 * py +
88
+ quotient(py, 4) -
89
+ quotient(py, 100) +
90
+ quotient(py, 400) +
91
+ quotient(367 * month - 362, 12) +
92
+ (month <= 2 ? 0 : isLeapYear(year) ? -1 : -2) +
93
+ day);
94
+ }
95
+ /**
96
+ * Converts Gregorian date to absolute R.D. (Rata Die) days
97
+ * @param {Date} date Gregorian date
98
+ * @return {number}
99
+ */
100
+ function greg2abs(date) {
101
+ if (!isDate(date)) {
102
+ throw new TypeError(`Argument not a Date: ${date}`);
103
+ }
104
+ const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
105
+ /*
106
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
107
+ throw new RangeError(`Invalid Date: ${date}`);
108
+ }
109
+ */
110
+ return abs;
111
+ }
112
+ greg.greg2abs = greg2abs;
113
+ /**
114
+ * Converts from Rata Die (R.D. number) to Gregorian date.
115
+ * See the footnote on page 384 of ``Calendrical Calculations, Part II:
116
+ * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
117
+ * Clamen, Software--Practice and Experience, Volume 23, Number 4
118
+ * (April, 1993), pages 383-404 for an explanation.
119
+ * @param {number} abs - R.D. number of days
120
+ * @return {Date}
121
+ */
122
+ function abs2greg(abs) {
123
+ if (typeof abs !== 'number') {
124
+ throw new TypeError(`Argument not a Number: ${abs}`);
125
+ }
126
+ abs = Math.trunc(abs);
127
+ /*
128
+ if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
129
+ throw new RangeError(`Invalid Date: ${abs}`);
130
+ }
131
+ */
132
+ const year = yearFromFixed(abs);
133
+ const priorDays = abs - toFixed(year, 1, 1);
134
+ const correction = abs < toFixed(year, 3, 1) ? 0 : isLeapYear(year) ? 1 : 2;
135
+ const month = quotient(12 * (priorDays + correction) + 373, 367);
136
+ const day = abs - toFixed(year, month, 1) + 1;
137
+ const dt = new Date(year, month - 1, day);
138
+ if (year < 100 && year >= 0) {
139
+ dt.setFullYear(year);
140
+ }
141
+ return dt;
142
+ }
143
+ greg.abs2greg = abs2greg;
144
+ })(greg || (greg = {}));
145
+
146
+ const alefbet = {
147
+ א: 1,
148
+ ב: 2,
149
+ ג: 3,
150
+ ד: 4,
151
+ ה: 5,
152
+ ו: 6,
153
+ ז: 7,
154
+ ח: 8,
155
+ ט: 9,
156
+ י: 10,
157
+ כ: 20,
158
+ ל: 30,
159
+ מ: 40,
160
+ נ: 50,
161
+ ס: 60,
162
+ ע: 70,
163
+ פ: 80,
164
+ צ: 90,
165
+ ק: 100,
166
+ ר: 200,
167
+ ש: 300,
168
+ ת: 400,
169
+ };
170
+ const heb2num = new Map();
171
+ const num2heb = new Map();
172
+ for (const [key, val] of Object.entries(alefbet)) {
173
+ heb2num.set(key, val);
174
+ num2heb.set(val, key);
341
175
  }
342
176
 
343
177
  /**
344
- * @param {CalOptions} options
178
+ * Formats a number with leading zeros so the resulting string is 4 digits long.
179
+ * Similar to `string.padStart(4, '0')` but will also format
180
+ * negative numbers similar to how the JavaScript date formats
181
+ * negative year numbers (e.g. `-37` is formatted as `-000037`).
182
+ * @param {number} number
345
183
  * @return {string}
346
184
  */
347
- function getDownloadFilename(options) {
348
- let fileName = 'hebcal';
349
- if (options.year) {
350
- fileName += '_' + options.year;
351
- if (options.isHebrewYear) {
352
- fileName += 'h';
353
- }
354
- if (options.month) {
355
- fileName += '_' + options.month;
356
- }
357
- } else if (typeof options.start === 'object' && typeof options.end === 'object') {
358
- const start = new HDate(options.start);
359
- const end = new HDate(options.end);
360
- const y1 = start.greg().getFullYear();
361
- const y2 = end.greg().getFullYear();
362
- if (y1 === y2) {
363
- fileName += '_' + y1;
364
- } else {
365
- fileName += '_' + y1 + '_' + y2;
366
- }
367
- }
368
- if (typeof options.location === 'object') {
369
- const loc = options.location;
370
- const name = loc.zip || loc.asciiname || loc.getShortName();
371
- if (name) {
372
- fileName += '_' + makeAnchor(name).replace(/[-]/g, '_');
373
- }
374
- }
375
- return fileName;
185
+ function pad4(number) {
186
+ if (number < 0) {
187
+ return '-00' + pad4(-number);
188
+ }
189
+ else if (number < 10) {
190
+ return '000' + number;
191
+ }
192
+ else if (number < 100) {
193
+ return '00' + number;
194
+ }
195
+ else if (number < 1000) {
196
+ return '0' + number;
197
+ }
198
+ return String(number);
376
199
  }
377
-
378
200
  /**
201
+ * Formats a number with leading zeros so the resulting string is 2 digits long.
202
+ * Similar to `string.padStart(2, '0')`.
379
203
  * @param {number} number
380
204
  * @return {string}
381
205
  */
382
206
  function pad2(number) {
383
- if (number < 10) {
384
- return '0' + number;
385
- }
386
- return '' + number;
207
+ if (number < 10) {
208
+ return '0' + number;
209
+ }
210
+ return String(number);
387
211
  }
388
-
389
212
  /**
390
- * @param {number} number
213
+ * Returns YYYY-MM-DD in the local timezone
214
+ * @private
215
+ * @param {Date} dt
391
216
  * @return {string}
392
217
  */
393
- function pad4(number) {
394
- if (number < 0) {
395
- return '-00' + pad4(-number);
396
- } else if (number < 10) {
397
- return '000' + number;
398
- } else if (number < 100) {
399
- return '00' + number;
400
- } else if (number < 1000) {
401
- return '0' + number;
402
- }
403
- return '' + number;
218
+ function isoDateString(dt) {
219
+ return (pad4(dt.getFullYear()) +
220
+ '-' +
221
+ pad2(dt.getMonth() + 1) +
222
+ '-' +
223
+ pad2(dt.getDate()));
404
224
  }
405
225
 
226
+ var poAshkenazi = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);" }, "contexts": { "": { "Tevet": ["Teves"] } } };
227
+
228
+ var poHe = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);" }, "contexts": { "": { "Adar": ["אַדָר"], "Adar I": ["אַדָר א׳"], "Adar II": ["אַדָר ב׳"], "Av": ["אָב"], "Cheshvan": ["חֶשְׁוָן"], "Elul": ["אֱלוּל"], "Iyyar": ["אִיָיר"], "Kislev": ["כִּסְלֵו"], "Nisan": ["נִיסָן"], "Sh'vat": ["שְׁבָט"], "Sivan": ["סִיוָן"], "Tamuz": ["תַּמּוּז"], "Tevet": ["טֵבֵת"], "Tishrei": ["תִּשְׁרֵי"] } } };
229
+
230
+ const noopLocale = {
231
+ headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
232
+ contexts: { '': {} },
233
+ };
234
+ const alias = {
235
+ 'h': 'he',
236
+ 'a': 'ashkenazi',
237
+ 's': 'en',
238
+ '': 'en',
239
+ };
240
+ /** @private */
241
+ const locales = new Map();
242
+ /** @private */
243
+ let activeLocale;
244
+ /** @private */
245
+ let activeName;
246
+ /**
247
+ * A locale in Hebcal is used for translations/transliterations of
248
+ * holidays. `@hebcal/hdate` supports four locales by default
249
+ * * `en` - default, Sephardic transliterations (e.g. "Shabbat")
250
+ * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
251
+ * * `he` - Hebrew (e.g. "שַׁבָּת")
252
+ * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
253
+ */
254
+ class Locale {
255
+ /**
256
+ * Returns translation only if `locale` offers a non-empty translation for `id`.
257
+ * Otherwise, returns `undefined`.
258
+ * @param {string} id Message ID to translate
259
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
260
+ * @return {string}
261
+ */
262
+ static lookupTranslation(id, locale) {
263
+ const loc = (typeof locale === 'string' && locales.get(locale.toLowerCase())) || activeLocale;
264
+ const array = loc[id];
265
+ if ((array === null || array === void 0 ? void 0 : array.length) && array[0].length) {
266
+ return array[0];
267
+ }
268
+ return undefined;
269
+ }
270
+ /**
271
+ * By default, if no translation was found, returns `id`.
272
+ * @param {string} id Message ID to translate
273
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
274
+ * @return {string}
275
+ */
276
+ static gettext(id, locale) {
277
+ const text = this.lookupTranslation(id, locale);
278
+ if (typeof text === 'undefined') {
279
+ return id;
280
+ }
281
+ return text;
282
+ }
283
+ /**
284
+ * Register locale translations.
285
+ * @param {string} locale Locale name (i.e.: `'he'`, `'fr'`)
286
+ * @param {LocaleData} data parsed data from a `.po` file.
287
+ */
288
+ static addLocale(locale, data) {
289
+ if (typeof locale !== 'string') {
290
+ throw new TypeError(`Invalid locale name: ${locale}`);
291
+ }
292
+ if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
293
+ throw new TypeError(`Locale '${locale}' invalid compact format`);
294
+ }
295
+ locales.set(locale.toLowerCase(), data.contexts['']);
296
+ }
297
+ /**
298
+ * Adds a translation to `locale`, replacing any previous translation.
299
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
300
+ * @param {string} id Message ID to translate
301
+ * @param {string | string[]} translation Translation text
302
+ */
303
+ static addTranslation(locale, id, translation) {
304
+ if (typeof locale !== 'string') {
305
+ throw new TypeError(`Invalid locale name: ${locale}`);
306
+ }
307
+ const loc = locales.get(locale.toLowerCase());
308
+ if (!loc) {
309
+ throw new TypeError(`Unknown locale: ${locale}`);
310
+ }
311
+ if (typeof id !== 'string' || id.length === 0) {
312
+ throw new TypeError(`Invalid id: ${id}`);
313
+ }
314
+ const isArray = Array.isArray(translation);
315
+ if (isArray) {
316
+ const t0 = translation[0];
317
+ if (typeof t0 !== 'string' || t0.length === 0) {
318
+ throw new TypeError(`Invalid translation array: ${translation}`);
319
+ }
320
+ }
321
+ else if (typeof translation !== 'string') {
322
+ throw new TypeError(`Invalid translation: ${translation}`);
323
+ }
324
+ loc[id] = isArray ? translation : [translation];
325
+ }
326
+ /**
327
+ * Adds multiple translations to `locale`, replacing any previous translations.
328
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
329
+ * @param {LocaleData} data parsed data from a `.po` file.
330
+ */
331
+ static addTranslations(locale, data) {
332
+ if (typeof locale !== 'string') {
333
+ throw new TypeError(`Invalid locale name: ${locale}`);
334
+ }
335
+ const loc = locales.get(locale.toLowerCase());
336
+ if (!loc) {
337
+ throw new TypeError(`Unknown locale: ${locale}`);
338
+ }
339
+ if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
340
+ throw new TypeError(`Locale '${locale}' invalid compact format`);
341
+ }
342
+ const ctx = data.contexts[''];
343
+ Object.assign(loc, ctx);
344
+ }
345
+ /**
346
+ * Activates a locale. Throws an error if the locale has not been previously added.
347
+ * After setting the locale to be used, all strings marked for translations
348
+ * will be represented by the corresponding translation in the specified locale.
349
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`)
350
+ */
351
+ static useLocale(locale) {
352
+ const locale0 = locale.toLowerCase();
353
+ const obj = locales.get(locale0);
354
+ if (!obj) {
355
+ throw new RangeError(`Locale '${locale}' not found`);
356
+ }
357
+ activeName = alias[locale0] || locale0;
358
+ activeLocale = obj;
359
+ return activeLocale;
360
+ }
361
+ /**
362
+ * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
363
+ * @return {string}
364
+ */
365
+ static getLocaleName() {
366
+ return activeName;
367
+ }
368
+ /**
369
+ * Returns the names of registered locales
370
+ * @return {string[]}
371
+ */
372
+ static getLocaleNames() {
373
+ const keys = Array.from(locales.keys());
374
+ return keys.sort((a, b) => a.localeCompare(b));
375
+ }
376
+ /**
377
+ * @param {number} n
378
+ * @param {string} [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
379
+ * @return {string}
380
+ */
381
+ static ordinal(n, locale) {
382
+ const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
383
+ const locale0 = locale1 || activeName;
384
+ if (!locale0) {
385
+ return this.getEnOrdinal(n);
386
+ }
387
+ switch (locale0) {
388
+ case 'en':
389
+ case 's':
390
+ case 'a':
391
+ case 'ashkenazi':
392
+ case 'ashkenazi_litvish':
393
+ case 'ashkenazi_poylish':
394
+ case 'ashkenazi_standard':
395
+ return this.getEnOrdinal(n);
396
+ case 'es':
397
+ return n + 'º';
398
+ case 'h':
399
+ case 'he':
400
+ case 'he-x-nonikud':
401
+ return String(n);
402
+ default:
403
+ return n + '.';
404
+ }
405
+ }
406
+ /**
407
+ * @private
408
+ * @param {number} n
409
+ * @return {string}
410
+ */
411
+ static getEnOrdinal(n) {
412
+ const s = ['th', 'st', 'nd', 'rd'];
413
+ const v = n % 100;
414
+ return n + (s[(v - 20) % 10] || s[v] || s[0]);
415
+ }
416
+ /**
417
+ * Removes nekudot from Hebrew string
418
+ * @param {string} str
419
+ * @return {string}
420
+ */
421
+ static hebrewStripNikkud(str) {
422
+ return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
423
+ }
424
+ }
425
+ Locale.addLocale('en', noopLocale);
426
+ Locale.addLocale('s', noopLocale);
427
+ Locale.addLocale('', noopLocale);
428
+ Locale.useLocale('en');
429
+ /* Ashkenazic transliterations */
430
+ Locale.addLocale('ashkenazi', poAshkenazi);
431
+ Locale.addLocale('a', poAshkenazi);
432
+ /* Hebrew with nikkud */
433
+ Locale.addLocale('he', poHe);
434
+ Locale.addLocale('h', poHe);
435
+ /* Hebrew without nikkud */
436
+ const heStrs = poHe.contexts[''];
437
+ const heNoNikud = {};
438
+ for (const [key, val] of Object.entries(heStrs)) {
439
+ heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
440
+ }
441
+ const poHeNoNikud = {
442
+ headers: poHe.headers,
443
+ contexts: { '': heNoNikud },
444
+ };
445
+ Locale.addLocale('he-x-NoNikud', poHeNoNikud);
446
+
447
+ var countryNames0 = {
448
+ "AD": "Andorra",
449
+ "AE": "United Arab Emirates",
450
+ "AF": "Afghanistan",
451
+ "AI": "Anguilla",
452
+ "AL": "Albania",
453
+ "AM": "Armenia",
454
+ "AO": "Angola",
455
+ "AR": "Argentina",
456
+ "AS": "American Samoa",
457
+ "AT": "Austria",
458
+ "AU": "Australia",
459
+ "AW": "Aruba",
460
+ "AZ": "Azerbaijan",
461
+ "BA": "Bosnia and Herzegovina",
462
+ "BB": "Barbados",
463
+ "BD": "Bangladesh",
464
+ "BE": "Belgium",
465
+ "BF": "Burkina Faso",
466
+ "BG": "Bulgaria",
467
+ "BH": "Bahrain",
468
+ "BI": "Burundi",
469
+ "BJ": "Benin",
470
+ "BM": "Bermuda",
471
+ "BN": "Brunei",
472
+ "BO": "Bolivia",
473
+ "BR": "Brazil",
474
+ "BS": "Bahamas",
475
+ "BT": "Bhutan",
476
+ "BW": "Botswana",
477
+ "BY": "Belarus",
478
+ "BZ": "Belize",
479
+ "CA": "Canada",
480
+ "CD": "Democratic Republic of the Congo",
481
+ "CF": "Central African Republic",
482
+ "CG": "Republic of the Congo",
483
+ "CH": "Switzerland",
484
+ "CI": "Ivory Coast",
485
+ "CK": "Cook Islands",
486
+ "CL": "Chile",
487
+ "CM": "Cameroon",
488
+ "CN": "China",
489
+ "CO": "Colombia",
490
+ "CR": "Costa Rica",
491
+ "CU": "Cuba",
492
+ "CV": "Cape Verde",
493
+ "CW": "Curacao",
494
+ "CY": "Cyprus",
495
+ "CZ": "Czech Republic",
496
+ "DE": "Germany",
497
+ "DK": "Denmark",
498
+ "DM": "Dominica",
499
+ "DO": "Dominican Republic",
500
+ "DZ": "Algeria",
501
+ "EC": "Ecuador",
502
+ "EE": "Estonia",
503
+ "EG": "Egypt",
504
+ "ER": "Eritrea",
505
+ "ES": "Spain",
506
+ "ET": "Ethiopia",
507
+ "FI": "Finland",
508
+ "FJ": "Fiji",
509
+ "FK": "Falkland Islands",
510
+ "FO": "Faroe Islands",
511
+ "FR": "France",
512
+ "GA": "Gabon",
513
+ "GB": "United Kingdom",
514
+ "GE": "Georgia",
515
+ "GH": "Ghana",
516
+ "GI": "Gibraltar",
517
+ "GL": "Greenland",
518
+ "GM": "Gambia",
519
+ "GN": "Guinea",
520
+ "GQ": "Equatorial Guinea",
521
+ "GR": "Greece",
522
+ "GT": "Guatemala",
523
+ "GW": "Guinea-Bissau",
524
+ "GY": "Guyana",
525
+ "HK": "Hong Kong",
526
+ "HN": "Honduras",
527
+ "HR": "Croatia",
528
+ "HT": "Haiti",
529
+ "HU": "Hungary",
530
+ "ID": "Indonesia",
531
+ "IE": "Ireland",
532
+ "IL": "Israel",
533
+ "IM": "Isle of Man",
534
+ "IN": "India",
535
+ "IQ": "Iraq",
536
+ "IR": "Iran",
537
+ "IS": "Iceland",
538
+ "IT": "Italy",
539
+ "JM": "Jamaica",
540
+ "JO": "Jordan",
541
+ "JP": "Japan",
542
+ "KE": "Kenya",
543
+ "KG": "Kyrgyzstan",
544
+ "KH": "Cambodia",
545
+ "KM": "Comoros",
546
+ "KN": "Saint Kitts and Nevis",
547
+ "KP": "North Korea",
548
+ "KR": "South Korea",
549
+ "KW": "Kuwait",
550
+ "KY": "Cayman Islands",
551
+ "KZ": "Kazakhstan",
552
+ "LA": "Laos",
553
+ "LB": "Lebanon",
554
+ "LC": "Saint Lucia",
555
+ "LI": "Liechtenstein",
556
+ "LR": "Liberia",
557
+ "LS": "Lesotho",
558
+ "LT": "Lithuania",
559
+ "LU": "Luxembourg",
560
+ "LV": "Latvia",
561
+ "LY": "Libya",
562
+ "MA": "Morocco",
563
+ "MD": "Moldova",
564
+ "ME": "Montenegro",
565
+ "MG": "Madagascar",
566
+ "MK": "Macedonia",
567
+ "ML": "Mali",
568
+ "MM": "Myanmar",
569
+ "MN": "Mongolia",
570
+ "MP": "Northern Mariana Islands",
571
+ "MR": "Mauritania",
572
+ "MS": "Montserrat",
573
+ "MT": "Malta",
574
+ "MU": "Mauritius",
575
+ "MW": "Malawi",
576
+ "MX": "Mexico",
577
+ "MY": "Malaysia",
578
+ "MZ": "Mozambique",
579
+ "NA": "Namibia",
580
+ "NC": "New Caledonia",
581
+ "NE": "Niger",
582
+ "NG": "Nigeria",
583
+ "NI": "Nicaragua",
584
+ "NL": "Netherlands",
585
+ "NO": "Norway",
586
+ "NP": "Nepal",
587
+ "NU": "Niue",
588
+ "NZ": "New Zealand",
589
+ "OM": "Oman",
590
+ "PA": "Panama",
591
+ "PE": "Peru",
592
+ "PF": "French Polynesia",
593
+ "PG": "Papua New Guinea",
594
+ "PH": "Philippines",
595
+ "PK": "Pakistan",
596
+ "PL": "Poland",
597
+ "PR": "Puerto Rico",
598
+ "PT": "Portugal",
599
+ "PY": "Paraguay",
600
+ "QA": "Qatar",
601
+ "RO": "Romania",
602
+ "RS": "Serbia",
603
+ "RU": "Russia",
604
+ "RW": "Rwanda",
605
+ "SA": "Saudi Arabia",
606
+ "SB": "Solomon Islands",
607
+ "SC": "Seychelles",
608
+ "SD": "Sudan",
609
+ "SE": "Sweden",
610
+ "SG": "Singapore",
611
+ "SH": "Saint Helena",
612
+ "SI": "Slovenia",
613
+ "SK": "Slovakia",
614
+ "SL": "Sierra Leone",
615
+ "SN": "Senegal",
616
+ "SO": "Somalia",
617
+ "SR": "Suriname",
618
+ "ST": "Sao Tome and Principe",
619
+ "SV": "El Salvador",
620
+ "SY": "Syria",
621
+ "SZ": "Swaziland",
622
+ "TC": "Turks and Caicos Islands",
623
+ "TD": "Chad",
624
+ "TG": "Togo",
625
+ "TH": "Thailand",
626
+ "TJ": "Tajikistan",
627
+ "TM": "Turkmenistan",
628
+ "TN": "Tunisia",
629
+ "TR": "Turkey",
630
+ "TV": "Tuvalu",
631
+ "TW": "Taiwan",
632
+ "TZ": "Tanzania",
633
+ "UA": "Ukraine",
634
+ "UG": "Uganda",
635
+ "US": "United States",
636
+ "UY": "Uruguay",
637
+ "UZ": "Uzbekistan",
638
+ "VC": "Saint Vincent and the Grenadines",
639
+ "VE": "Venezuela",
640
+ "VG": "British Virgin Islands",
641
+ "VN": "Vietnam",
642
+ "WS": "Samoa",
643
+ "YE": "Yemen",
644
+ "YT": "Mayotte",
645
+ "ZA": "South Africa",
646
+ "ZM": "Zambia",
647
+ "ZW": "Zimbabwe"
648
+ };
649
+
650
+ var holidayDescription0 = {
651
+ "Asara B'Tevet": "Fast commemorating the siege of Jerusalem",
652
+ "Ben-Gurion Day": "Commemorates the life and vision of Israel's first Prime Minister David Ben-Gurion",
653
+ "Birkat Hachamah": "A rare Jewish blessing recited once every 28 years thanking G-d for creating the sun",
654
+ "Chag HaBanot": "North African Chanukah festival of daughters. Called Eid al-Banat in Arabic, the holiday was most preserved in Tunisia",
655
+ "Chanukah": "Hanukkah, the Jewish festival of rededication. Also known as the Festival of Lights, the eight-day festival is observed by lighting the candles of a hanukkiah (menorah)",
656
+ "Days of the Omer": "7 weeks from the second night of Pesach to the day before Shavuot. Also called Sefirat HaOmer, it is a practice that consists of a verbal counting of each of the forty-nine days between the two holidays",
657
+ "Family Day": "Yom HaMishpacha, a day to honor the family unit",
658
+ "Hebrew Language Day": "Promotes the Hebrew language in Israel and around the world. Occurs on the birthday of Eliezer Ben Yehuda, the father of modern spoken Hebrew",
659
+ "Herzl Day": "Commemorates the life and vision of Zionist leader Theodor Herzl",
660
+ "Jabotinsky Day": "Commemorates the life and vision of Zionist leader Ze'ev Jabotinsky",
661
+ "Lag BaOmer": "33rd day of counting the Omer. The holiday is a temporary break from the semi-mourning period the counting of the Omer. Practices include lighting bonfires, getting haircuts, and Jewish weddings",
662
+ "Leil Selichot": "Prayers for forgiveness in preparation for the High Holidays",
663
+ "Pesach Sheni": "Second Passover, one month after Passover",
664
+ "Pesach": "Passover, the Feast of Unleavened Bread. Also called Chag HaMatzot (the Festival of Matzah), it commemorates the Exodus and freedom of the Israelites from ancient Egypt",
665
+ "Purim Katan": "Minor Purim celebration during Adar I on leap years",
666
+ "Purim": "Celebration of Jewish deliverance as told by Megilat Esther. It commemorates a time when the Jewish people living in Persia were saved from extermination",
667
+ "Purim Meshulash": "Triple Purim, spanning 3 days in Jerusalem and walled cities. It occurs when the 15th of Adar coincides with Shabbat",
668
+ "Rosh Chodesh Nisan": "Start of month of Nisan on the Hebrew calendar. נִיסָן (transliterated Nisan or Nissan) is the 1st month of the Hebrew year, has 30 days, and corresponds to March or April on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
669
+ "Rosh Chodesh Iyyar": "Start of month of Iyyar on the Hebrew calendar. אִיָיר (transliterated Iyyar or Iyar) is the 2nd month of the Hebrew year, has 29 days, and corresponds to April or May on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
670
+ "Rosh Chodesh Sivan": "Start of month of Sivan on the Hebrew calendar. Sivan (סִיוָן) is the 3rd month of the Hebrew year, has 30 days, and corresponds to May or June on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
671
+ "Rosh Chodesh Tamuz": "Start of month of Tamuz on the Hebrew calendar. תַּמּוּז (transliterated Tamuz or Tammuz) is the 4th month of the Hebrew year, has 29 days, and corresponds to June or July on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
672
+ "Rosh Chodesh Av": "Start of month of Av on the Hebrew calendar. Av (אָב) is the 5th month of the Hebrew year, has 30 days, and corresponds to July or August on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
673
+ "Rosh Chodesh Elul": "Start of month of Elul on the Hebrew calendar. Elul (אֱלוּל) is the 6th month of the Hebrew year, has 29 days, and corresponds to August or September on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
674
+ "Rosh Chodesh Cheshvan": "Start of month of Cheshvan on the Hebrew calendar. חֶשְׁוָן (transliterated Cheshvan or Heshvan) is the 8th month of the Hebrew year, has 29 or 30 days, and corresponds to October or November on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
675
+ "Rosh Chodesh Kislev": "Start of month of Kislev on the Hebrew calendar. Kislev (כִּסְלֵו) is the 9th month of the Hebrew year, has 30 or 29 days, and corresponds to November or December on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
676
+ "Rosh Chodesh Tevet": "Start of month of Tevet on the Hebrew calendar. Tevet (טֵבֵת) is the 10th month of the Hebrew year, has 29 days, and corresponds to December or January on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
677
+ "Rosh Chodesh Sh'vat": "Start of month of Sh'vat on the Hebrew calendar. שְׁבָט (transliterated Sh'vat or Shevat) is the 11th month of the Hebrew year, has 30 days, and corresponds to January or February on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
678
+ "Rosh Chodesh Adar": "Start of month of Adar on the Hebrew calendar. Adar (אַדָר) is the 12th month of the Hebrew year, has 29 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
679
+ "Rosh Chodesh Adar I": "Start of month of Adar I (on leap years) on the Hebrew calendar. Adar I (אַדָר א׳) is the 12th month of the Hebrew year, occurs only on leap years, has 30 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
680
+ "Rosh Chodesh Adar II": "Start of month of Adar II (on leap years) on the Hebrew calendar. Adar II (אַדָר ב׳), sometimes \"Adar Bet\" or \"Adar Sheni\", is the 13th month of the Hebrew year, has 29 days, occurs only on leap years, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon",
681
+ "Rosh Hashana": "The Jewish New Year. Also spelled Rosh Hashanah",
682
+ "Rosh Hashana LaBehemot": "New Year for Tithing Animals",
683
+ "Shabbat Chazon": "Shabbat of Prophecy/Shabbat of Vision. Shabbat before Tish'a B'Av",
684
+ "Shabbat HaChodesh": "Shabbat before Rosh Chodesh Nissan. Read in preparation for Passover",
685
+ "Shabbat HaGadol": "Shabbat before Pesach (The Great Shabbat)",
686
+ "Shabbat Machar Chodesh": "When Shabbat falls the day before Rosh Chodesh",
687
+ "Shabbat Mevarchim Chodesh": "Shabbat that precedes Rosh Chodesh. The congregation blesses the forthcoming new month",
688
+ "Shabbat Nachamu": "Shabbat after Tish'a B'Av (Shabbat of Consolation). The first of seven Shabbatot leading up to Rosh Hashanah. Named after the Haftarah (from Isaiah 40) which begins with the verse נַחֲמוּ נַחֲמוּ, עַמִּי (\"Comfort, oh comfort my people\")",
689
+ "Shabbat Parah": "Shabbat of the Red Heifer. Shabbat before Shabbat HaChodesh, in preparation for Passover",
690
+ "Shabbat Rosh Chodesh": "When Shabbat falls on Rosh Chodesh",
691
+ "Shabbat Shekalim": "Shabbat before Rosh Chodesh Adar. Read in preparation for Purim",
692
+ "Shabbat Shirah": "Shabbat of Song. Shabbat that includes Parashat Beshalach",
693
+ "Shabbat Shuva": "Shabbat of Returning. Shabbat that occurs during the Ten Days of Repentance between Rosh Hashanah and Yom Kippur",
694
+ "Shabbat Zachor": "Shabbat of Remembrance. Shabbat before Purim",
695
+ "Shavuot": "Festival of Weeks. Commemorates the giving of the Torah at Mount Sinai",
696
+ "Shmini Atzeret": "Eighth Day of Assembly. Immediately following Sukkot, it is observed as a separate holiday in the Diaspora and is combined with Simchat Torah in Israel",
697
+ "Shushan Purim": "Purim celebrated in Jerusalem and walled cities",
698
+ "Shushan Purim Katan": "Minor Purim celebration during Adar I on leap years in Jerusalem and walled cities",
699
+ "Sigd": "Ethiopian Jewish holiday occurring 50 days after Yom Kippur",
700
+ "Simchat Torah": "Day of Celebrating the Torah. Celebration marking the conclusion of the annual cycle of public Torah readings, and the beginning of a new cycle",
701
+ "Sukkot": "Feast of Booths. Also called the Feast of Tabernacles, the seven-day holiday is one of the Three Pilgrimage Festivals (Hebrew: שלוש רגלים, shalosh regalim)",
702
+ "Ta'anit Bechorot": "Fast of the First Born",
703
+ "Ta'anit Esther": "Fast of Esther",
704
+ "Tish'a B'Av": "The Ninth of Av. Fast commemorating the destruction of the two Temples",
705
+ "Tu B'Av": "Minor Jewish holiday of love. Observed on the 15th day of the Hebrew month of Av",
706
+ "Tu BiShvat": "New Year for Trees. Tu BiShvat is one of four “New Years” mentioned in the Mishnah",
707
+ "Tzom Gedaliah": "Fast of the Seventh Month. Commemorates the assassination of the Jewish governor of Judah",
708
+ "Tzom Tammuz": "Fast commemorating breaching of the walls of Jerusalem before the destruction of the Second Temple",
709
+ "Yitzhak Rabin Memorial Day": "Commemorates the life of Israeli Prime Minister Yitzhak Rabin",
710
+ "Yom HaAliyah": "Recognizes Aliyah, immigration to the Jewish State of Israel",
711
+ "Yom HaAliyah School Observance": "Aliyah Day observed in Israeli schools",
712
+ "Yom HaAtzma'ut": "Israeli Independence Day. Commemorates the declaration of independence of Israel in 1948. Although Yom HaAtzma'ut is normally observed on the 5th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaZikaron, which always precedes it) would conflict with Shabbat",
713
+ "Yom HaShoah": "Holocaust Memorial Day",
714
+ "Yom HaZikaron": "Israeli Memorial Day. Remembers those who died in the War of Independence and other wars in Israel. The full name of the holiday is Yom HaZikaron LeHalalei Ma'arakhot Yisrael ul'Nifge'ei Pe'ulot HaEivah (Hebrew: יוֹם הזִּכָּרוֹן לְחַלְלֵי מַעֲרָכוֹת יִשְׂרָאֵל וּלְנִפְגְעֵי פְּעֻלּוֹת הָאֵיבָה), Memorial Day for the Fallen Soldiers of the Wars of Israel and Victims of Actions of Terrorism. Although Yom Hazikaron is normally observed on the 4th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaAtzma'ut, which always follows it) would conflict with Shabbat",
715
+ "Yom Kippur": "Day of Atonement. The holiest day of the year in Judaism, traditionally observed with a 25-hour period of fasting and intensive prayer",
716
+ "Yom Kippur Katan": "Minor day of atonement occurring monthly on the day preceeding each Rosh Chodesh",
717
+ "Yom Yerushalayim": "Jerusalem Day. Commemorates the re-unification of Jerusalem in 1967"
718
+ };
719
+
720
+ const LOC_FIELDS = ['elevation', 'admin1', 'asciiname', 'geo', 'zip', 'state', 'stateName', 'geonameid'];
721
+ const holidayDescription = holidayDescription0;
722
+ const countryNames = countryNames0;
723
+ /**
724
+ * Converts a @hebcal/core `Location` to a plain JS object.
725
+ */
726
+ function locationToPlainObj(location) {
727
+ if (typeof location === 'object' && location !== null && typeof location.getLatitude === 'function') {
728
+ const cc = location.getCountryCode();
729
+ const o = {
730
+ title: location.getName(),
731
+ city: location.getShortName(),
732
+ tzid: location.getTzid(),
733
+ latitude: location.getLatitude(),
734
+ longitude: location.getLongitude(),
735
+ cc: cc,
736
+ country: countryNames[cc],
737
+ };
738
+ for (const k of LOC_FIELDS) {
739
+ const val = location[k];
740
+ if (val) {
741
+ o[k] = val;
742
+ }
743
+ }
744
+ return o;
745
+ }
746
+ else {
747
+ return { geo: 'none' };
748
+ }
749
+ }
750
+ /**
751
+ * Helper function to transform a string to make it more usable in a URL or filename.
752
+ * Converts to lowercase and replaces non-word characters with hyphen ('-').
753
+ * @example
754
+ * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
755
+ */
756
+ function makeAnchor(s) {
757
+ return s.toLowerCase()
758
+ .replace(/'/g, '')
759
+ .replace(/[^\w]/g, '-')
760
+ .replace(/-+/g, '-')
761
+ .replace(/^-/g, '')
762
+ .replace(/-$/g, '');
763
+ }
764
+ function getDownloadFilename(options) {
765
+ let fileName = 'hebcal';
766
+ if (options.year) {
767
+ fileName += '_' + options.year;
768
+ if (options.isHebrewYear) {
769
+ fileName += 'h';
770
+ }
771
+ if (options.month) {
772
+ fileName += '_' + options.month;
773
+ }
774
+ }
775
+ else if (typeof options.start === 'object' && typeof options.end === 'object') {
776
+ const start = new HDate(options.start);
777
+ const end = new HDate(options.end);
778
+ const y1 = start.greg().getFullYear();
779
+ const y2 = end.greg().getFullYear();
780
+ if (y1 === y2) {
781
+ fileName += '_' + y1;
782
+ }
783
+ else {
784
+ fileName += '_' + y1 + '_' + y2;
785
+ }
786
+ }
787
+ if (typeof options.location === 'object') {
788
+ const loc = options.location;
789
+ const name = loc.zip || loc.asciiname || loc.getShortName();
790
+ if (name) {
791
+ fileName += '_' + makeAnchor(name).replace(/[-]/g, '_');
792
+ }
793
+ }
794
+ return fileName;
795
+ }
406
796
  /**
407
797
  * Returns just the date portion as YYYY-MM-DD
408
- * @param {Date} d
409
- * @return {string}
410
798
  */
411
799
  function toISOString(d) {
412
- return pad4(d.getFullYear()) + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate());
800
+ return isoDateString(d);
413
801
  }
414
-
415
802
  /**
416
803
  * Returns a category and subcategory name
417
- * @param {Event} ev
418
- * @return {string[]}
419
804
  */
420
805
  function getEventCategories(ev) {
421
- const desc = ev.getDesc();
422
- if (desc === 'Purim' || desc === 'Erev Purim') {
423
- return ['holiday', 'major'];
424
- }
425
- return ev.getCategories();
806
+ const desc = ev.getDesc();
807
+ if (desc === 'Purim' || desc === 'Erev Purim') {
808
+ return ['holiday', 'major'];
809
+ }
810
+ return ev.getCategories();
426
811
  }
427
-
428
812
  /**
429
813
  * Renders the event title in default locale, but strips off time
430
- * @param {Event} ev
431
- * @return {string}
432
814
  */
433
815
  function renderTitleWithoutTime(ev) {
434
- return typeof ev.eventTime === 'undefined' ? ev.render() : ev.renderBrief();
816
+ return typeof ev.eventTime === 'undefined' ? ev.render() : ev.renderBrief();
435
817
  }
436
-
437
818
  /**
438
819
  * Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
439
- * @param {Event[]} events
440
- * @param {CalOptions} options
441
- * @return {string}
442
820
  */
443
821
  function getCalendarTitle(events, options) {
444
- let title = 'Hebcal';
445
- const location = options.location;
446
- const locationName = location?.getName();
447
- if (options.yahrzeit) {
448
- title += ' Yahrzeits and Anniversaries';
449
- } else if (locationName) {
450
- const comma = locationName.indexOf(',');
451
- const name = (comma == -1) ? locationName : locationName.substring(0, comma);
452
- title += ' ' + name;
453
- } else if (options.il) {
454
- title += ' Israel';
455
- } else {
456
- title += ' Diaspora';
457
- }
458
- if (options.subscribe == '1') {
822
+ let title = 'Hebcal';
823
+ const location = options.location;
824
+ const locationName = location === null || location === void 0 ? void 0 : location.getName();
825
+ if (options.yahrzeit) {
826
+ title += ' Yahrzeits and Anniversaries';
827
+ }
828
+ else if (locationName) {
829
+ const comma = locationName.indexOf(',');
830
+ const name = (comma == -1) ? locationName : locationName.substring(0, comma);
831
+ title += ' ' + name;
832
+ }
833
+ else if (options.il) {
834
+ title += ' Israel';
835
+ }
836
+ else {
837
+ title += ' Diaspora';
838
+ }
839
+ if (options.subscribe == '1') {
840
+ return title;
841
+ }
842
+ if (options.year && (options.isHebrewYear || events.length == 0)) {
843
+ title += ' ' + options.year;
844
+ }
845
+ else if (events.length) {
846
+ const start = events[0].getDate().greg();
847
+ const end = events[events.length - 1].getDate().greg();
848
+ if (start.getFullYear() != end.getFullYear()) {
849
+ title += ' ' + start.getFullYear() + '-' + end.getFullYear();
850
+ }
851
+ else if (start.getMonth() == end.getMonth()) {
852
+ const monthFormat = new Intl.DateTimeFormat('en-US', { month: 'long' });
853
+ const startMonth = monthFormat.format(start);
854
+ title += ' ' + startMonth + ' ' + start.getFullYear();
855
+ }
856
+ else {
857
+ title += ' ' + start.getFullYear();
858
+ }
859
+ }
459
860
  return title;
460
- }
461
- if (options.year && (options.isHebrewYear || events.length == 0)) {
462
- title += ' ' + options.year;
463
- } else if (events.length) {
464
- const start = events[0].getDate().greg();
465
- const end = events[events.length - 1].getDate().greg();
466
- if (start.getFullYear() != end.getFullYear()) {
467
- title += ' ' + start.getFullYear() + '-' + end.getFullYear();
468
- } else if (start.getMonth() == end.getMonth()) {
469
- const monthFormat = new Intl.DateTimeFormat('en-US', {month: 'long'});
470
- const startMonth = monthFormat.format(start);
471
- title += ' ' + startMonth + ' ' + start.getFullYear();
472
- } else {
473
- title += ' ' + start.getFullYear();
474
- }
475
- }
476
- return title;
477
861
  }
478
-
479
862
  /**
480
863
  * Returns an English language description of the holiday
481
- * @param {Event} ev
482
- * @param {boolean} [firstSentence=false]
483
- * @return {string}
484
864
  */
485
- function getHolidayDescription(ev, firstSentence=false) {
486
- const str0 = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
487
- const str = str0.normalize();
488
- if (firstSentence && str) {
489
- const dot = str.indexOf('.');
490
- if (dot != -1) {
491
- return str.substring(0, dot);
492
- }
493
- }
494
- return str;
865
+ function getHolidayDescription(ev, firstSentence = false) {
866
+ const str0 = ev.getFlags() & flags.SHABBAT_MEVARCHIM ?
867
+ holidayDescription['Shabbat Mevarchim Chodesh'] :
868
+ holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
869
+ const str = str0.normalize();
870
+ if (firstSentence && str) {
871
+ const dot = str.indexOf('.');
872
+ if (dot != -1) {
873
+ return str.substring(0, dot);
874
+ }
875
+ }
876
+ return str;
495
877
  }
496
-
497
878
  const HOLIDAY_IGNORE_MASK = flags.DAF_YOMI | flags.OMER_COUNT |
498
- flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT |
499
- flags.NACH_YOMI | flags.DAILY_LEARNING |
500
- flags.HEBREW_DATE | flags.YERUSHALMI_YOMI;
501
-
879
+ flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT |
880
+ flags.NACH_YOMI | flags.DAILY_LEARNING |
881
+ flags.HEBREW_DATE | flags.YERUSHALMI_YOMI;
502
882
  /**
503
883
  * Makes mulit-line text that summarizes Torah & Haftarah
504
- * @param {Event} ev
505
- * @param {boolean} il
506
- * @return {string}
507
884
  */
508
885
  function makeTorahMemoText(ev, il) {
509
- const mask = ev.getFlags();
510
- if ((mask & HOLIDAY_IGNORE_MASK) || (typeof ev.eventTime !== 'undefined')) {
511
- return '';
512
- }
513
- const reading = (mask & flags.PARSHA_HASHAVUA) ?
514
- getLeyningForParshaHaShavua(ev, il) :
515
- getLeyningForHoliday(ev, il);
516
- let memo = '';
517
- if (reading && (reading.summary || reading.haftara)) {
518
- if (reading.summary) {
519
- memo += `Torah: ${reading.summary}`;
886
+ var _a;
887
+ const mask = ev.getFlags();
888
+ if ((mask & HOLIDAY_IGNORE_MASK) || (typeof ev.eventTime !== 'undefined')) {
889
+ return '';
520
890
  }
521
- if (reading.summary && reading.haftara) {
522
- memo += '\n';
891
+ const reading = (mask & flags.PARSHA_HASHAVUA) ?
892
+ getLeyningForParshaHaShavua(ev, il) :
893
+ getLeyningForHoliday(ev, il);
894
+ let memo = '';
895
+ if (reading && (reading.summary || reading.haftara)) {
896
+ if (reading.summary) {
897
+ memo += `Torah: ${reading.summary}`;
898
+ }
899
+ if (reading.summary && reading.haftara) {
900
+ memo += '\n';
901
+ }
902
+ if (reading.haftara) {
903
+ memo += 'Haftarah: ' + reading.haftara;
904
+ if ((_a = reading.reason) === null || _a === void 0 ? void 0 : _a.haftara) {
905
+ memo += ' | ' + reading.reason.haftara;
906
+ }
907
+ }
523
908
  }
524
- if (reading.haftara) {
525
- memo += 'Haftarah: ' + reading.haftara;
526
- if (reading.reason?.haftara) {
527
- memo += ' | ' + reading.reason.haftara;
528
- }
529
- }
530
- }
531
- if (reading?.sephardic) {
532
- memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
533
- }
534
- return memo;
909
+ if (reading === null || reading === void 0 ? void 0 : reading.sephardic) {
910
+ memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
911
+ }
912
+ return memo;
535
913
  }
536
-
537
- /**
538
- * @private
539
- * @param {Event} ev
540
- * @param {boolean} il
541
- * @return {string}
542
- */
543
914
  function makeMemo(ev, il) {
544
- if (ev.getFlags() & flags.PARSHA_HASHAVUA) {
545
- try {
546
- const memo = makeTorahMemoText(ev, il);
547
- if (memo) {
548
- return memo;
549
- }
550
- } catch (err) {
551
- // fallthru
552
- }
553
- }
554
- return ev.memo || holidayDescription[ev.basename()];
915
+ if (ev.getFlags() & flags.PARSHA_HASHAVUA) {
916
+ try {
917
+ const memo = makeTorahMemoText(ev, il);
918
+ if (memo) {
919
+ return memo;
920
+ }
921
+ }
922
+ catch (err) {
923
+ // fallthru
924
+ }
925
+ }
926
+ return ev.memo || holidayDescription[ev.basename()];
555
927
  }
556
-
557
928
  /**
558
929
  * Appends utm_source and utm_medium parameters to a URL
559
- * @param {string} url
560
- * @param {boolean} il
561
- * @param {string} utmSource
562
- * @param {string} utmMedium
563
- * @param {string} utmCampaign
564
- * @return {string}
565
930
  */
566
931
  function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
567
- const u = new URL(url);
568
- const isHebcal = u.host === 'www.hebcal.com';
569
- if (isHebcal) {
570
- if (il) {
571
- u.searchParams.set('i', 'on');
572
- }
573
- const path = u.pathname;
574
- const isHolidays = path.startsWith('/holidays/');
575
- const isSedrot = path.startsWith('/sedrot/');
576
- const isOmer = path.startsWith('/omer/');
577
- if (isHolidays || isSedrot || isOmer) {
578
- u.host = 'hebcal.com';
579
- if (isHolidays) {
580
- u.pathname = '/h/' + path.substring(10);
581
- } else if (isSedrot) {
582
- u.pathname = '/s/' + path.substring(8);
583
- } else { // isOmer
584
- u.pathname = '/o/' + path.substring(6);
585
- }
586
- if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
587
- if (utmSource) {
588
- u.searchParams.set('us', utmSource);
932
+ const u = new URL(url);
933
+ const isHebcal = u.host === 'www.hebcal.com';
934
+ if (isHebcal) {
935
+ if (il) {
936
+ u.searchParams.set('i', 'on');
589
937
  }
590
- if (utmMedium) {
591
- u.searchParams.set('um', utmMedium);
938
+ const path = u.pathname;
939
+ const isHolidays = path.startsWith('/holidays/');
940
+ const isSedrot = path.startsWith('/sedrot/');
941
+ const isOmer = path.startsWith('/omer/');
942
+ if (isHolidays || isSedrot || isOmer) {
943
+ u.host = 'hebcal.com';
944
+ if (isHolidays) {
945
+ u.pathname = '/h/' + path.substring(10);
946
+ }
947
+ else if (isSedrot) {
948
+ u.pathname = '/s/' + path.substring(8);
949
+ }
950
+ else { // isOmer
951
+ u.pathname = '/o/' + path.substring(6);
952
+ }
953
+ if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
954
+ if (utmSource) {
955
+ u.searchParams.set('us', utmSource);
956
+ }
957
+ if (utmMedium) {
958
+ u.searchParams.set('um', utmMedium);
959
+ }
960
+ }
961
+ if (utmCampaign) {
962
+ u.searchParams.set('uc', utmCampaign);
963
+ }
964
+ return u.toString();
592
965
  }
593
- }
594
- if (utmCampaign) {
595
- u.searchParams.set('uc', utmCampaign);
596
- }
597
- return u.toString();
598
- }
599
- }
600
- utmSource = isHebcal ? utmSource : 'hebcal.com';
601
- if (utmSource) {
602
- u.searchParams.set('utm_source', utmSource);
603
- }
604
- if (utmMedium) {
605
- u.searchParams.set('utm_medium', utmMedium);
606
- }
607
- if (utmCampaign) {
608
- u.searchParams.set('utm_campaign', utmCampaign);
609
- }
610
- return u.toString();
966
+ }
967
+ utmSource = isHebcal ? utmSource : 'hebcal.com';
968
+ if (utmSource) {
969
+ u.searchParams.set('utm_source', utmSource);
970
+ }
971
+ if (utmMedium) {
972
+ u.searchParams.set('utm_medium', utmMedium);
973
+ }
974
+ if (utmCampaign) {
975
+ u.searchParams.set('utm_campaign', utmCampaign);
976
+ }
977
+ return u.toString();
611
978
  }
612
-
613
- /**
614
- * @private
615
- * @param {Event} ev
616
- * @return {boolean}
617
- */
618
979
  function shouldRenderBrief(ev) {
619
- if (typeof ev.eventTime !== 'undefined') return true;
620
- const mask = ev.getFlags();
621
- if (mask & flags.HEBREW_DATE) {
622
- const hd = ev.getDate();
623
- return (hd.getDate() === 1) ? false : true;
624
- } else if (mask & (flags.DAILY_LEARNING | flags.DAF_YOMI | flags.YERUSHALMI_YOMI)) {
625
- return true;
626
- } else if (mask & flags.MINOR_FAST && ev.getDesc().substring(0, 16) === 'Yom Kippur Katan') {
627
- return true;
628
- } else if (mask & flags.SHABBAT_MEVARCHIM) {
629
- return true;
630
- } else {
631
- return false;
632
- }
980
+ if (typeof ev.eventTime !== 'undefined') {
981
+ return true;
982
+ }
983
+ const mask = ev.getFlags();
984
+ if (mask & flags.HEBREW_DATE) {
985
+ const hd = ev.getDate();
986
+ return (hd.getDate() === 1) ? false : true;
987
+ }
988
+ else if (mask & (flags.DAILY_LEARNING | flags.DAF_YOMI | flags.YERUSHALMI_YOMI)) {
989
+ return true;
990
+ }
991
+ else if (mask & flags.MINOR_FAST && ev.getDesc().substring(0, 16) === 'Yom Kippur Katan') {
992
+ return true;
993
+ }
994
+ else if (mask & flags.SHABBAT_MEVARCHIM) {
995
+ return true;
996
+ }
997
+ else {
998
+ return false;
999
+ }
633
1000
  }
634
1001
 
635
1002
  // eslint-disable-next-line max-len
636
1003
  const csvHeader = '"Subject","Start Date","Start Time","End Date","End Time","All day event","Description","Show time as","Location"';
637
-
638
1004
  const CATEGORY = {
639
- dafyomi: 'Daf Yomi',
640
- mishnayomi: 'Mishna Yomi',
641
- nachyomi: 'Nach Yomi',
642
- yerushalmi: 'Yerushalmi Yomi',
643
- hebdate: 'Hebrew Date',
644
- holiday: 'Jewish Holidays',
645
- mevarchim: '',
646
- molad: '',
647
- omer: '',
648
- parashat: 'Torah Reading',
649
- roshchodesh: 'Jewish Holidays',
650
- user: 'Personal',
651
- zmanim: '',
1005
+ dafyomi: 'Daf Yomi',
1006
+ mishnayomi: 'Mishna Yomi',
1007
+ nachyomi: 'Nach Yomi',
1008
+ yerushalmi: 'Yerushalmi Yomi',
1009
+ hebdate: 'Hebrew Date',
1010
+ holiday: 'Jewish Holidays',
1011
+ mevarchim: '',
1012
+ molad: '',
1013
+ omer: '',
1014
+ parashat: 'Torah Reading',
1015
+ roshchodesh: 'Jewish Holidays',
1016
+ user: 'Personal',
1017
+ zmanim: '',
652
1018
  };
653
-
654
1019
  /**
655
1020
  * Renders an Event as a string
656
- * @param {Event} e
657
- * @param {CalOptions} options
658
- * @return {string}
659
1021
  */
660
- function eventToCsv(e, options) {
661
- const d = e.getDate().greg();
662
- const mday = d.getDate();
663
- const mon = d.getMonth() + 1;
664
- const year = String(d.getFullYear()).padStart(4, '0');
665
- const date = options.euro ? `"${mday}/${mon}/${year}"` : `"${mon}/${mday}/${year}"`;
666
-
667
- let startTime = '';
668
- let endTime = '';
669
- let endDate = '';
670
- let allDay = '"true"';
671
-
672
- const timed = Boolean(e.eventTime);
673
- let subj = shouldRenderBrief(e) ? e.renderBrief(options.locale) : e.render(options.locale);
674
- if (e.eventTime) {
675
- const timeStr = HebrewCalendar.reformatTimeStr(e.eventTimeStr, ' PM', options);
676
- endTime = startTime = `"${timeStr}"`;
677
- endDate = date;
678
- allDay = '"false"';
679
- }
680
-
681
- let loc = 'Jewish Holidays';
682
- const mask = e.getFlags();
683
- if (timed && typeof options.location === 'object') {
684
- const locationName = options.location.getShortName();
685
- const comma = locationName.indexOf(',');
686
- loc = (comma === -1) ? locationName : locationName.substring(0, comma);
687
- } else {
688
- const category = CATEGORY[getEventCategories(e)[0]];
689
- if (typeof category === 'string') {
690
- loc = category;
691
- }
692
- }
693
-
694
- subj = subj.replace(/,/g, '').replace(/"/g, '\'\'');
695
-
696
- if (options.appendHebrewToSubject) {
697
- const hebrew = e.renderBrief('he');
698
- if (hebrew) {
699
- subj += ` / ${hebrew}`;
1022
+ function eventToCsv(ev, options) {
1023
+ const d = ev.getDate().greg();
1024
+ const mday = d.getDate();
1025
+ const mon = d.getMonth() + 1;
1026
+ const year = String(d.getFullYear()).padStart(4, '0');
1027
+ const date = options.euro ? `"${mday}/${mon}/${year}"` : `"${mon}/${mday}/${year}"`;
1028
+ let startTime = '';
1029
+ let endTime = '';
1030
+ let endDate = '';
1031
+ let allDay = '"true"';
1032
+ const timed = Boolean(ev.eventTime);
1033
+ let subj = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
1034
+ if (timed) {
1035
+ const timeStr = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, ' PM', options);
1036
+ endTime = startTime = `"${timeStr}"`;
1037
+ endDate = date;
1038
+ allDay = '"false"';
700
1039
  }
701
- }
702
-
703
- let memo0 = e.memo || getHolidayDescription(e, true);
704
- if (!memo0 && typeof e.linkedEvent !== 'undefined') {
705
- memo0 = e.linkedEvent.render(options.locale);
706
- }
707
- const memo = memo0.replace(/,/g, ';').replace(/"/g, '\'\'').replace(/\n/g, ' / ');
708
-
709
- const showTimeAs = (timed || (mask & flags.CHAG)) ? 4 : 3;
710
- return `"${subj}",${date},${startTime},${endDate},${endTime},${allDay},"${memo}","${showTimeAs}","${loc}"`;
1040
+ let loc = 'Jewish Holidays';
1041
+ const mask = ev.getFlags();
1042
+ if (timed && typeof options.location === 'object') {
1043
+ const locationName = options.location.getShortName();
1044
+ const comma = locationName.indexOf(',');
1045
+ loc = (comma === -1) ? locationName : locationName.substring(0, comma);
1046
+ }
1047
+ else {
1048
+ const category = CATEGORY[getEventCategories(ev)[0]];
1049
+ if (typeof category === 'string') {
1050
+ loc = category;
1051
+ }
1052
+ }
1053
+ subj = subj.replace(/,/g, '').replace(/"/g, '\'\'');
1054
+ if (options.appendHebrewToSubject) {
1055
+ const hebrew = ev.renderBrief('he');
1056
+ if (hebrew) {
1057
+ subj += ` / ${hebrew}`;
1058
+ }
1059
+ }
1060
+ let memo0 = ev.memo || getHolidayDescription(ev, true);
1061
+ if (!memo0 && typeof ev.linkedEvent !== 'undefined') {
1062
+ memo0 = ev.linkedEvent.render(options.locale);
1063
+ }
1064
+ const memo = memo0.replace(/,/g, ';').replace(/"/g, '\'\'').replace(/\n/g, ' / ');
1065
+ const showTimeAs = (timed || (mask & flags.CHAG)) ? 4 : 3;
1066
+ return `"${subj}",${date},${startTime},${endDate},${endTime},${allDay},"${memo}","${showTimeAs}","${loc}"`;
711
1067
  }
712
-
713
- /**
714
- * @param {Event[]} events
715
- * @param {HebcalOptions} options
716
- * @return {string}
717
- */
718
1068
  function eventsToCsv(events, options) {
719
- return [csvHeader].concat(events.map((e) => eventToCsv(e, options))).join('\r\n') + '\r\n';
1069
+ return [csvHeader].concat(events.map((ev) => eventToCsv(ev, options))).join('\r\n') + '\r\n';
720
1070
  }
721
1071
 
722
- /**
723
- * @private
724
- * @param {Event} ev
725
- * @return {string}
726
- */
727
1072
  function eventIsoDate(ev) {
728
- return toISOString(ev.getDate().greg());
1073
+ return isoDateString(ev.getDate().greg());
729
1074
  }
730
-
731
1075
  /**
732
1076
  * Formats a list events for the classic Hebcal.com JSON API response
733
- * @param {Event[]} events
734
- * @param {CalOptions} options
735
- * @param {boolean} [leyning=true]
736
- * @return {Object}
737
1077
  */
738
- function eventsToClassicApi(events, options, leyning=true) {
739
- const result = {
740
- title: getCalendarTitle(events, options),
741
- date: new Date().toISOString(),
742
- };
743
- result.location = locationToPlainObj(options.location);
744
- if (events.length) {
745
- result.range = {
746
- start: eventIsoDate(events[0]),
747
- end: eventIsoDate(events[events.length - 1]),
1078
+ function eventsToClassicApi(events, options, leyning = true) {
1079
+ const result = {
1080
+ title: getCalendarTitle(events, options),
1081
+ date: new Date().toISOString(),
748
1082
  };
749
- }
750
- result.items = events.map((ev) => eventToClassicApiObject(ev, options, leyning));
751
- return result;
1083
+ result.location = locationToPlainObj(options.location);
1084
+ if (events.length) {
1085
+ result.range = {
1086
+ start: eventIsoDate(events[0]),
1087
+ end: eventIsoDate(events[events.length - 1]),
1088
+ };
1089
+ }
1090
+ result.items = events.map((ev) => eventToClassicApiObject(ev, options, leyning));
1091
+ return result;
752
1092
  }
753
-
754
1093
  /**
755
1094
  * Converts a Hebcal event to a classic Hebcal.com JSON API object
756
- * @param {Event} ev
757
- * @param {CalOptions} options
758
- * @param {boolean} [leyning=true]
759
- * @return {Object}
760
1095
  */
761
- function eventToClassicApiObject(ev, options, leyning=true) {
762
- const timed = Boolean(ev.eventTime);
763
- const hd = ev.getDate();
764
- const dt = hd.greg();
765
- const tzid = typeof options.location === 'object' ? options.location.getTzid() : 'UTC';
766
- const date = timed ?
767
- Zmanim.formatISOWithTimeZone(tzid, ev.eventTime) :
768
- toISOString(dt);
769
- const categories = getEventCategories(ev);
770
- const mask = ev.getFlags();
771
- let title = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
772
- const desc = ev.getDesc();
773
- const candles = desc === 'Havdalah' || desc === 'Candle lighting';
774
- if (candles) {
775
- const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
776
- title += ': ' + time;
777
- }
778
- const result = {
779
- title: title,
780
- date: date,
781
- };
782
- if (!timed) {
783
- result.hdate = hd.toString();
784
- }
785
- result.category = categories[0];
786
- if (categories.length > 1) {
787
- result.subcat = categories[1];
788
- }
789
- if (categories[0] === 'holiday' && (mask & flags.CHAG)) {
790
- result.yomtov = true;
791
- }
792
- if (title != desc) {
793
- result.title_orig = desc;
794
- }
795
- const hebrew = ev.renderBrief('he');
796
- if (hebrew) {
797
- result.hebrew = Locale.hebrewStripNikkud(hebrew);
798
- }
799
- if (!candles) {
800
- if (leyning) {
801
- const il = options.il;
802
- const isParsha = (mask === flags.PARSHA_HASHAVUA);
803
- const reading = isParsha ?
804
- getLeyningForParshaHaShavua(ev, il) :
805
- getLeyningForHoliday(ev, il);
806
- if (reading) {
807
- result.leyning = formatLeyningResult(reading);
808
- const hyear = hd.getFullYear();
809
- if (isParsha && !il && hyear >= 5745) {
810
- const triReading = getTriennialForParshaHaShavua(ev);
811
- if (triReading) {
812
- result.leyning.triennial = formatAliyot({}, triReading.aliyot);
813
- }
814
- }
815
- }
1096
+ function eventToClassicApiObject(ev, options, leyning = true) {
1097
+ const eventTime = ev.eventTime;
1098
+ const timed = Boolean(eventTime);
1099
+ const hd = ev.getDate();
1100
+ const dt = hd.greg();
1101
+ const tzid = typeof options.location === 'object' ? options.location.getTzid() : 'UTC';
1102
+ const date = timed ?
1103
+ Zmanim.formatISOWithTimeZone(tzid, eventTime) :
1104
+ isoDateString(dt);
1105
+ const categories = getEventCategories(ev);
1106
+ const mask = ev.getFlags();
1107
+ let title = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
1108
+ const desc = ev.getDesc();
1109
+ const candles = desc === 'Havdalah' || desc === 'Candle lighting';
1110
+ if (candles) {
1111
+ const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
1112
+ title += ': ' + time;
816
1113
  }
817
- const url = ev.url();
818
- if (url) {
819
- const utmSource = options.utmSource || 'js';
820
- const utmMedium = options.utmMedium || 'api';
821
- const utmCampaign = options.utmCampaign;
822
- result.link = appendIsraelAndTracking(url, options.il,
823
- utmSource, utmMedium, utmCampaign);
824
- }
825
- }
826
- if (mask & flags.OMER_COUNT) {
827
- result.omer = {
828
- count: {
829
- he: ev.getTodayIs('he'),
830
- en: ev.getTodayIs('en'),
831
- },
832
- sefira: {
833
- he: ev.sefira('he'),
834
- translit: ev.sefira('translit'),
835
- en: ev.sefira('en'),
836
- },
1114
+ const result = {
1115
+ title: title,
1116
+ date: date,
837
1117
  };
838
- }
839
- if (mask & flags.MOLAD) {
840
- const m = ev.molad;
841
- result.molad = {
842
- hy: m.year,
843
- hm: HDate.getMonthName(m.month, m.year),
844
- dow: m.dow,
845
- hour: m.hour,
846
- minutes: m.minutes,
847
- chalakim: m.chalakim,
848
- };
849
- delete result.hebrew;
850
- }
851
- if ((options.heDateParts && !timed) || (mask & flags.HEBREW_DATE)) {
852
- const yy = hd.getFullYear();
853
- const mm = hd.getMonthName();
854
- const dd = hd.getDate();
855
- result.heDateParts = {
856
- y: gematriya(yy),
857
- m: Locale.gettext(mm, 'he-x-NoNikud'),
858
- d: gematriya(dd),
859
- };
860
- }
861
- const memo = ev.memo || holidayDescription[ev.basename()];
862
- if (typeof memo === 'string' && memo.length !== 0) {
863
- result.memo = memo.normalize();
864
- } else if (typeof ev.linkedEvent !== 'undefined') {
865
- result.memo = ev.linkedEvent.render(options.locale);
866
- }
867
- if (options.includeEvent) {
868
- result.ev = ev;
869
- }
870
- return result;
1118
+ if (!timed) {
1119
+ result.hdate = hd.toString();
1120
+ }
1121
+ result.category = categories[0];
1122
+ if (categories.length > 1) {
1123
+ result.subcat = categories[1];
1124
+ }
1125
+ if (categories[0] === 'holiday' && (mask & flags.CHAG)) {
1126
+ result.yomtov = true;
1127
+ }
1128
+ if (title != desc) {
1129
+ result.title_orig = desc;
1130
+ }
1131
+ const hebrew = ev.renderBrief('he');
1132
+ if (hebrew) {
1133
+ result.hebrew = Locale$1.hebrewStripNikkud(hebrew);
1134
+ }
1135
+ if (!candles) {
1136
+ if (leyning) {
1137
+ const il = options.il;
1138
+ const isParsha = (mask === flags.PARSHA_HASHAVUA);
1139
+ const reading = isParsha ?
1140
+ getLeyningForParshaHaShavua(ev, il) :
1141
+ getLeyningForHoliday(ev, il);
1142
+ if (reading) {
1143
+ result.leyning = formatLeyningResult(reading);
1144
+ const hyear = hd.getFullYear();
1145
+ if (isParsha && !il && hyear >= 5745) {
1146
+ const triReading = getTriennialForParshaHaShavua(ev);
1147
+ if (triReading) {
1148
+ result.leyning.triennial = formatAliyot({}, triReading.aliyot);
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+ const url = ev.url();
1154
+ if (url) {
1155
+ const utmSource = options.utmSource || 'js';
1156
+ const utmMedium = options.utmMedium || 'api';
1157
+ const utmCampaign = options.utmCampaign;
1158
+ result.link = appendIsraelAndTracking(url, Boolean(options.il), utmSource, utmMedium, utmCampaign);
1159
+ }
1160
+ }
1161
+ if (mask & flags.OMER_COUNT) {
1162
+ const omerEv = ev;
1163
+ result.omer = {
1164
+ count: {
1165
+ he: omerEv.getTodayIs('he'),
1166
+ en: omerEv.getTodayIs('en'),
1167
+ },
1168
+ sefira: {
1169
+ he: omerEv.sefira('he'),
1170
+ translit: omerEv.sefira('translit'),
1171
+ en: omerEv.sefira('en'),
1172
+ },
1173
+ };
1174
+ }
1175
+ if (mask & flags.MOLAD) {
1176
+ const moladEv = ev;
1177
+ const m = moladEv.molad;
1178
+ const hy = m.getYear();
1179
+ result.molad = {
1180
+ hy,
1181
+ hm: HDate.getMonthName(m.getMonth(), hy),
1182
+ dow: m.getDow(),
1183
+ hour: m.getHour(),
1184
+ minutes: m.getMinutes(),
1185
+ chalakim: m.getChalakim(),
1186
+ };
1187
+ delete result.hebrew;
1188
+ }
1189
+ if ((options.heDateParts && !timed) || (mask & flags.HEBREW_DATE)) {
1190
+ const yy = hd.getFullYear();
1191
+ const mm = hd.getMonthName();
1192
+ const dd = hd.getDate();
1193
+ result.heDateParts = {
1194
+ y: gematriya(yy),
1195
+ m: Locale$1.gettext(mm, 'he-x-NoNikud'),
1196
+ d: gematriya(dd),
1197
+ };
1198
+ }
1199
+ const memo = ev.memo || holidayDescription[ev.basename()];
1200
+ if (typeof memo === 'string' && memo.length !== 0) {
1201
+ result.memo = memo.normalize();
1202
+ }
1203
+ else if (typeof ev.linkedEvent !== 'undefined') {
1204
+ result.memo = ev.linkedEvent.render(options.locale);
1205
+ }
1206
+ if (options.includeEvent) {
1207
+ result.ev = ev;
1208
+ }
1209
+ return result;
871
1210
  }
872
-
873
- /**
874
- * @param {Object} result
875
- * @param {Object} aliyot
876
- * @return {Object}
877
- */
878
1211
  function formatAliyot(result, aliyot) {
879
- for (const [num, aliyah] of Object.entries(aliyot)) {
880
- if (typeof aliyah !== 'undefined') {
881
- const k = num == 'M' ? 'maftir' : num;
882
- result[k] = formatAliyahWithBook(aliyah);
1212
+ for (const [num, aliyah] of Object.entries(aliyot)) {
1213
+ if (typeof aliyah !== 'undefined') {
1214
+ const k = num == 'M' ? 'maftir' : num;
1215
+ result[k] = formatAliyahWithBook(aliyah);
1216
+ }
883
1217
  }
884
- }
885
- return result;
1218
+ return result;
886
1219
  }
887
-
888
- /**
889
- * @param {Leyning} reading
890
- * @return {Object}
891
- */
892
1220
  function formatLeyningResult(reading) {
893
- const result = {};
894
- if (reading.summary) {
895
- result.torah = reading.summary;
896
- }
897
- if (reading.haftara) {
898
- result.haftarah = reading.haftara;
899
- }
900
- if (reading.sephardic) {
901
- result.haftarah_sephardic = reading.sephardic;
902
- }
903
- if (reading.fullkriyah) {
904
- formatAliyot(result, reading.fullkriyah);
905
- }
906
- if (reading.reason) {
907
- for (const num of ['7', '8', 'M']) {
908
- if (reading.reason[num]) {
909
- const k = num == 'M' ? 'maftir' : num;
910
- result[k] += ' | ' + reading.reason[num];
911
- }
912
- }
913
- if (reading.reason.haftara) {
914
- result.haftarah += ' | ' + reading.reason.haftara;
915
- }
916
- }
917
- return result;
1221
+ const result = {};
1222
+ if (reading.summary) {
1223
+ result.torah = reading.summary;
1224
+ }
1225
+ if (reading.haftara) {
1226
+ result.haftarah = reading.haftara;
1227
+ }
1228
+ if (reading.sephardic) {
1229
+ result.haftarah_sephardic = reading.sephardic;
1230
+ }
1231
+ if (reading.fullkriyah) {
1232
+ formatAliyot(result, reading.fullkriyah);
1233
+ }
1234
+ if (reading.reason) {
1235
+ for (const num of ['7', '8', 'M']) {
1236
+ if (reading.reason[num]) {
1237
+ const k = num == 'M' ? 'maftir' : num;
1238
+ result[k] += ' | ' + reading.reason[num];
1239
+ }
1240
+ }
1241
+ if (reading.reason.haftara) {
1242
+ result.haftarah += ' | ' + reading.reason.haftara;
1243
+ }
1244
+ }
1245
+ return result;
918
1246
  }
919
1247
 
920
- /**
921
- * @private
922
- * @param {Event} ev
923
- * @param {boolean} il
924
- * @param {string} tzid
925
- * @param {string} mainUrl
926
- * @param {string} utmSource
927
- * @param {string} utmMedium
928
- * @return {string[]}
929
- */
930
1248
  function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
931
- let link;
932
- let guid;
933
- const dt = ev.eventTime || ev.getDate().greg();
934
- const isoDateTime = Zmanim.formatISOWithTimeZone(tzid, dt);
935
- const dtStr = isoDateTime.substring(0, isoDateTime.indexOf('T'));
936
- const dtAnchor = dtStr.replace(/-/g, '');
937
- const descAnchor = makeAnchor(ev.getDesc());
938
- const anchor = `${dtAnchor}-${descAnchor}`;
939
- const url0 = ev.url();
940
- if (url0) {
941
- link = appendIsraelAndTracking(url0, il, utmSource, utmMedium).replace(/&/g, '&amp;');
942
- guid = `${url0}#${anchor}`;
943
- } else {
944
- const url1 = `${mainUrl}&dt=${dtStr}`;
945
- const url = appendIsraelAndTracking(url1, il, utmSource, utmMedium).replace(/&/g, '&amp;');
946
- guid = url1.replace(/&/g, '&amp;') + `#${anchor}`;
947
- link = `${url}#${anchor}`;
948
- }
949
- return [link, guid];
1249
+ let link;
1250
+ let guid;
1251
+ const eventTime = ev.eventTime;
1252
+ const dt = eventTime || ev.getDate().greg();
1253
+ const isoDateTime = Zmanim.formatISOWithTimeZone(tzid, dt);
1254
+ const dtStr = isoDateTime.substring(0, isoDateTime.indexOf('T'));
1255
+ const dtAnchor = dtStr.replace(/-/g, '');
1256
+ const descAnchor = makeAnchor(ev.getDesc());
1257
+ const anchor = `${dtAnchor}-${descAnchor}`;
1258
+ const url0 = ev.url();
1259
+ if (url0) {
1260
+ link = appendIsraelAndTracking(url0, il, utmSource, utmMedium).replace(/&/g, '&amp;');
1261
+ guid = `${url0}#${anchor}`;
1262
+ }
1263
+ else {
1264
+ const url1 = `${mainUrl}&dt=${dtStr}`;
1265
+ const url = appendIsraelAndTracking(url1, il, utmSource, utmMedium).replace(/&/g, '&amp;');
1266
+ guid = url1.replace(/&/g, '&amp;') + `#${anchor}`;
1267
+ link = `${url}#${anchor}`;
1268
+ }
1269
+ return [link, guid];
950
1270
  }
951
-
952
1271
  const localeToLg = {
953
- 's': 'en',
954
- 'a': 'en',
955
- 'he-x-NoNikud': 'he',
956
- 'h': 'he',
957
- 'ah': 'en',
958
- 'sh': 'en',
1272
+ 's': 'en',
1273
+ 'a': 'en',
1274
+ 'he-x-NoNikud': 'he',
1275
+ 'h': 'he',
1276
+ 'ah': 'en',
1277
+ 'sh': 'en',
959
1278
  };
960
-
961
- /**
962
- * @param {Event[]} events
963
- * @param {CalOptions} options
964
- * @return {string}
965
- */
966
1279
  function eventsToRss2(events, options) {
967
- options.dayFormat = new Intl.DateTimeFormat('en-US', {
968
- weekday: 'long',
969
- day: '2-digit',
970
- month: 'long',
971
- year: 'numeric',
972
- });
973
- const location = options.location;
974
- const mainUrl = options.mainUrl;
975
- const buildDate = options.buildDate = options.buildDate || new Date();
976
- const thisYear = buildDate.getFullYear();
977
- const lastBuildDate = options.lastBuildDate = buildDate.toUTCString();
978
- const title = options.title || getCalendarTitle(events, options);
979
- const description = options.description || title;
980
- const utmSource = options.utmSource || 'shabbat1c';
981
- const utmMedium = options.utmMedium || 'rss';
982
- const mainUrlEsc = appendIsraelAndTracking(mainUrl,
983
- location?.getIsrael(),
984
- utmSource, utmMedium, options.utmCampaign).replace(/&/g, '&amp;');
985
- const selfUrlEsc = options.selfUrl.replace(/&/g, '&amp;');
986
- const lang = options.lang || localeToLg[options.locale] || options.locale || 'en-US';
987
- let str = `<?xml version="1.0" encoding="UTF-8"?>
1280
+ options.dayFormat = new Intl.DateTimeFormat('en-US', {
1281
+ weekday: 'long',
1282
+ day: '2-digit',
1283
+ month: 'long',
1284
+ year: 'numeric',
1285
+ });
1286
+ const location = options.location;
1287
+ if (!options.mainUrl || !options.selfUrl) {
1288
+ throw new TypeError('mainUrl cannot be empty or blank');
1289
+ }
1290
+ const buildDate = options.buildDate = options.buildDate || new Date();
1291
+ const thisYear = buildDate.getFullYear();
1292
+ const lastBuildDate = options.lastBuildDate = buildDate.toUTCString();
1293
+ const title = options.title || getCalendarTitle(events, options);
1294
+ const description = options.description || title;
1295
+ const utmSource = options.utmSource || 'shabbat1c';
1296
+ const utmMedium = options.utmMedium || 'rss';
1297
+ const mainUrlEsc = appendIsraelAndTracking(options.mainUrl, Boolean(location === null || location === void 0 ? void 0 : location.getIsrael()), utmSource, utmMedium, options.utmCampaign).replace(/&/g, '&amp;');
1298
+ const selfUrlEsc = options.selfUrl.replace(/&/g, '&amp;');
1299
+ const lang = options.lang || localeToLg[options.locale] || options.locale || 'en-US';
1300
+ let str = `<?xml version="1.0" encoding="UTF-8"?>
988
1301
  <rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:atom="http://www.w3.org/2005/Atom">
989
1302
  <channel>
990
1303
  <title>${title}</title>
@@ -995,71 +1308,58 @@ function eventsToRss2(events, options) {
995
1308
  <copyright>Copyright (c) ${thisYear} Michael J. Radwin. All rights reserved.</copyright>
996
1309
  <lastBuildDate>${lastBuildDate}</lastBuildDate>
997
1310
  `;
998
- for (const ev of events) {
999
- str += eventToRssItem2(ev, options);
1000
- }
1001
- str += '</channel>\n</rss>\n';
1002
- return str;
1311
+ for (const ev of events) {
1312
+ str += eventToRssItem2(ev, options);
1313
+ }
1314
+ str += '</channel>\n</rss>\n';
1315
+ return str;
1003
1316
  }
1004
-
1005
- /**
1006
- * @private
1007
- * @param {Event} ev
1008
- * @param {boolean} evPubDate
1009
- * @param {Date} evDate
1010
- * @param {string} lastBuildDate
1011
- * @return {string}
1012
- */
1013
1317
  function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
1014
- if (evPubDate) {
1015
- const dt = ev.eventTime;
1016
- if (dt) {
1017
- return dt.toUTCString();
1018
- }
1019
- return evDate.toUTCString().replace(/ \S+ GMT$/, ' 00:00:00 GMT');
1020
- }
1021
- return lastBuildDate;
1318
+ if (evPubDate) {
1319
+ const dt = ev.eventTime;
1320
+ if (dt) {
1321
+ return dt.toUTCString();
1322
+ }
1323
+ return evDate.toUTCString().replace(/ \S+ GMT$/, ' 00:00:00 GMT');
1324
+ }
1325
+ return lastBuildDate;
1022
1326
  }
1023
-
1024
- /**
1025
- * @param {Event} ev
1026
- * @param {CalOptions} options
1027
- * @return {string}
1028
- */
1029
1327
  function eventToRssItem2(ev, options) {
1030
- let subj = ev.render();
1031
- const evDate = ev.getDate().greg();
1032
- const pubDate = getPubDate(ev, options.evPubDate, evDate, options.lastBuildDate);
1033
- const location = options.location;
1034
- const il = location ? location.getIsrael() : false;
1035
- const tzid = location ? location.getTzid() : 'UTC';
1036
- const utmSource = options.utmSource || 'shabbat1c';
1037
- const utmMedium = options.utmMedium || 'rss';
1038
- const linkGuid = getLinkAndGuid(ev, il, tzid, options.mainUrl, utmSource, utmMedium);
1039
- const link = linkGuid[0];
1040
- const guid = linkGuid[1];
1041
- const categories = getEventCategories(ev);
1042
- const cat0 = categories[0];
1043
- const desc = ev.getDesc();
1044
- const candles = desc === 'Havdalah' || desc === 'Candle lighting';
1045
- let memo;
1046
- if (candles) {
1047
- const colon = subj.indexOf(': ');
1048
- if (colon != -1) {
1049
- const options = {location, il, locale: Locale.getLocaleName()};
1050
- const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
1051
- subj = subj.substring(0, colon) + ': ' + time;
1052
- }
1053
- } else {
1054
- memo = makeMemo(ev, il);
1055
- }
1056
- const dayFormat = options.dayFormat;
1057
- const description0 = memo || dayFormat.format(evDate);
1058
- const description = description0.indexOf('<') === -1 ? description0 : `<![CDATA[${description0}]]>`;
1059
- const geoTags = (cat0 == 'candles') ?
1060
- `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n` :
1061
- '';
1062
- return `<item>
1328
+ let subj = ev.render();
1329
+ const evDate = ev.getDate().greg();
1330
+ const pubDate = getPubDate(ev, options.evPubDate, evDate, options.lastBuildDate);
1331
+ const location = options.location;
1332
+ const il = location ? location.getIsrael() : false;
1333
+ const tzid = location ? location.getTzid() : 'UTC';
1334
+ const utmSource = options.utmSource || 'shabbat1c';
1335
+ const utmMedium = options.utmMedium || 'rss';
1336
+ const mainUrl = options.mainUrl || '';
1337
+ const linkGuid = getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium);
1338
+ const link = linkGuid[0];
1339
+ const guid = linkGuid[1];
1340
+ const categories = getEventCategories(ev);
1341
+ const cat0 = categories[0];
1342
+ const desc = ev.getDesc();
1343
+ const candles = desc === 'Havdalah' || desc === 'Candle lighting';
1344
+ let memo;
1345
+ if (candles) {
1346
+ const colon = subj.indexOf(': ');
1347
+ if (colon != -1) {
1348
+ const options = { location, il, locale: Locale$1.getLocaleName() };
1349
+ const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
1350
+ subj = subj.substring(0, colon) + ': ' + time;
1351
+ }
1352
+ }
1353
+ else {
1354
+ memo = makeMemo(ev, il);
1355
+ }
1356
+ const dayFormat = options.dayFormat;
1357
+ const description0 = memo || dayFormat.format(evDate);
1358
+ const description = description0.indexOf('<') === -1 ? description0 : `<![CDATA[${description0}]]>`;
1359
+ const geoTags = (cat0 == 'candles') ?
1360
+ `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n` :
1361
+ '';
1362
+ return `<item>
1063
1363
  <title>${subj}</title>
1064
1364
  <link>${link}</link>
1065
1365
  <guid isPermaLink="false">${guid}</guid>
@@ -1072,47 +1372,45 @@ ${geoTags}</item>
1072
1372
 
1073
1373
  /**
1074
1374
  * Converts a Hebcal event to a FullCalendar.io object
1075
- * @param {Event} ev
1076
- * @param {string} tzid timeZone identifier
1077
- * @param {boolean} il true if Israel
1078
- * @return {Object}
1079
1375
  */
1080
1376
  function eventToFullCalendar(ev, tzid, il) {
1081
- const classes = getEventCategories(ev);
1082
- const mask = ev.getFlags();
1083
- if (classes[0] == 'holiday' && mask & flags.CHAG) {
1084
- classes.push('yomtov');
1085
- }
1086
- const timed = Boolean(ev.eventTime);
1087
- const title = shouldRenderBrief(ev) ? ev.renderBrief() : ev.render();
1088
- const start = timed ?
1089
- Zmanim.formatISOWithTimeZone(tzid, ev.eventTime) :
1090
- toISOString(ev.getDate().greg());
1091
- const result = {
1092
- title,
1093
- start,
1094
- allDay: !timed,
1095
- className: classes.join(' '),
1096
- };
1097
- const hebrew = ev.renderBrief('he');
1098
- if (hebrew) {
1099
- result.hebrew = Locale.hebrewStripNikkud(hebrew);
1100
- }
1101
- const url = ev.url();
1102
- if (url) {
1103
- result.url = appendIsraelAndTracking(url, il, 'js', 'fc');
1104
- }
1105
- const desc = ev.getDesc();
1106
- const candles = desc === 'Havdalah' || desc === 'Candle lighting';
1107
- if (!candles) {
1108
- const memo = makeMemo(ev, il);
1109
- if (memo) {
1110
- result.description = memo;
1111
- } else if (typeof ev.linkedEvent !== 'undefined') {
1112
- result.description = ev.linkedEvent.render();
1113
- }
1114
- }
1115
- return result;
1377
+ const classes = getEventCategories(ev);
1378
+ const mask = ev.getFlags();
1379
+ if (classes[0] == 'holiday' && mask & flags.CHAG) {
1380
+ classes.push('yomtov');
1381
+ }
1382
+ const eventTime = ev.eventTime;
1383
+ const timed = Boolean(eventTime);
1384
+ const title = shouldRenderBrief(ev) ? ev.renderBrief() : ev.render();
1385
+ const start = timed ?
1386
+ Zmanim.formatISOWithTimeZone(tzid, eventTime) :
1387
+ isoDateString(ev.getDate().greg());
1388
+ const result = {
1389
+ title,
1390
+ start,
1391
+ allDay: !timed,
1392
+ className: classes.join(' '),
1393
+ };
1394
+ const hebrew = ev.renderBrief('he');
1395
+ if (hebrew) {
1396
+ result.hebrew = Locale$1.hebrewStripNikkud(hebrew);
1397
+ }
1398
+ const url = ev.url();
1399
+ if (url) {
1400
+ result.url = appendIsraelAndTracking(url, il, 'js', 'fc');
1401
+ }
1402
+ const desc = ev.getDesc();
1403
+ const candles = desc === 'Havdalah' || desc === 'Candle lighting';
1404
+ if (!candles) {
1405
+ const memo = makeMemo(ev, il);
1406
+ if (memo) {
1407
+ result.description = memo;
1408
+ }
1409
+ else if (typeof ev.linkedEvent !== 'undefined') {
1410
+ result.description = ev.linkedEvent.render();
1411
+ }
1412
+ }
1413
+ return result;
1116
1414
  }
1117
1415
 
1118
1416
  export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem2, eventsToClassicApi, eventsToCsv, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, locationToPlainObj, makeAnchor, makeMemo, makeTorahMemoText, pad2, pad4, renderTitleWithoutTime, shouldRenderBrief, toISOString };