@hebcal/rest-api 5.0.4 → 5.1.0

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