@hebcal/rest-api 5.0.5 → 5.1.1

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