@hebcal/rest-api 5.1.4 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,431 +1,12 @@
1
- /*! @hebcal/rest-api v5.1.4 */
2
- import { parshiot, HDate, flags, HebrewCalendar, Zmanim, Locale as Locale$1, gematriya } from '@hebcal/core';
3
- import { getLeyningForParshaHaShavua, getLeyningForHoliday, formatAliyahWithBook } from '@hebcal/leyning';
1
+ /*! @hebcal/rest-api v6.0.0 */
2
+ import { parshiot, HDate, flags, HebrewCalendar, version, Zmanim, Locale, gematriya } from '@hebcal/core';
3
+ import { isoDateString } from '@hebcal/hdate';
4
+ export { pad2, pad4 } from '@hebcal/hdate';
5
+ import { getLeyningForParshaHaShavua } from '@hebcal/leyning/dist/esm/leyning';
6
+ import { getLeyningForHoliday } from '@hebcal/leyning/dist/esm/getLeyningForHoliday';
7
+ import { formatAliyahWithBook } from '@hebcal/leyning/dist/esm/common';
4
8
  import { getTriennialForParshaHaShavua } from '@hebcal/triennial';
5
9
 
6
- /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
7
- /** @private */
8
- const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
9
- /** @private */
10
- const monthLengths = [lengths, lengths.slice()];
11
- monthLengths[1][2] = 29;
12
- /**
13
- * @private
14
- */
15
- function mod(x, y) {
16
- return x - y * Math.floor(x / y);
17
- }
18
- /**
19
- * @private
20
- */
21
- function quotient(x, y) {
22
- return Math.floor(x / y);
23
- }
24
- /**
25
- * @private
26
- * @param abs - R.D. number of days
27
- */
28
- function yearFromFixed(abs) {
29
- const l0 = abs - 1;
30
- const n400 = quotient(l0, 146097);
31
- const d1 = mod(l0, 146097);
32
- const n100 = quotient(d1, 36524);
33
- const d2 = mod(d1, 36524);
34
- const n4 = quotient(d2, 1461);
35
- const d3 = mod(d2, 1461);
36
- const n1 = quotient(d3, 365);
37
- const year = 400 * n400 + 100 * n100 + 4 * n4 + n1;
38
- return n100 !== 4 && n1 !== 4 ? year + 1 : year;
39
- }
40
- /*
41
- const ABS_14SEP1752 = 639797;
42
- const ABS_2SEP1752 = 639785;
43
- */
44
- /*
45
- * Formerly in namespace, now top-level
46
- */
47
- /**
48
- * Returns true if the Gregorian year is a leap year
49
- * @param year Gregorian year
50
- */
51
- function isGregLeapYear(year) {
52
- return !(year % 4) && (!!(year % 100) || !(year % 400));
53
- }
54
- /**
55
- * Number of days in the Gregorian month for given year
56
- * @param month Gregorian month (1=January, 12=December)
57
- * @param year Gregorian year
58
- */
59
- function daysInGregMonth(month, year) {
60
- // 1 based months
61
- return monthLengths[+isGregLeapYear(year)][month];
62
- }
63
- /**
64
- * Returns true if the object is a Javascript Date
65
- */
66
- function isDate(obj) {
67
- // eslint-disable-next-line no-prototype-builtins
68
- return typeof obj === 'object' && Date.prototype.isPrototypeOf(obj);
69
- }
70
- /**
71
- * @private
72
- * @param year
73
- * @param month (1-12)
74
- * @param day (1-31)
75
- */
76
- function toFixed(year, month, day) {
77
- const py = year - 1;
78
- return (365 * py +
79
- quotient(py, 4) -
80
- quotient(py, 100) +
81
- quotient(py, 400) +
82
- quotient(367 * month - 362, 12) +
83
- (month <= 2 ? 0 : isGregLeapYear(year) ? -1 : -2) +
84
- day);
85
- }
86
- /**
87
- * Converts Gregorian date to absolute R.D. (Rata Die) days
88
- * @param date Gregorian date
89
- */
90
- function greg2abs(date) {
91
- if (!isDate(date)) {
92
- throw new TypeError(`Argument not a Date: ${date}`);
93
- }
94
- const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
95
- /*
96
- if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
97
- throw new RangeError(`Invalid Date: ${date}`);
98
- }
99
- */
100
- return abs;
101
- }
102
- /**
103
- * Converts from Rata Die (R.D. number) to Gregorian date.
104
- * See the footnote on page 384 of ``Calendrical Calculations, Part II:
105
- * Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
106
- * Clamen, Software--Practice and Experience, Volume 23, Number 4
107
- * (April, 1993), pages 383-404 for an explanation.
108
- * @param abs - R.D. number of days
109
- */
110
- function abs2greg(abs) {
111
- if (typeof abs !== 'number') {
112
- throw new TypeError(`Argument not a Number: ${abs}`);
113
- }
114
- abs = Math.trunc(abs);
115
- /*
116
- if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
117
- throw new RangeError(`Invalid Date: ${abs}`);
118
- }
119
- */
120
- const year = yearFromFixed(abs);
121
- const priorDays = abs - toFixed(year, 1, 1);
122
- const correction = abs < toFixed(year, 3, 1) ? 0 : isGregLeapYear(year) ? 1 : 2;
123
- const month = quotient(12 * (priorDays + correction) + 373, 367);
124
- const day = abs - toFixed(year, month, 1) + 1;
125
- const dt = new Date(year, month - 1, day);
126
- if (year < 100 && year >= 0) {
127
- dt.setFullYear(year);
128
- }
129
- return dt;
130
- }
131
-
132
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
133
- /**
134
- * Gregorian date helper functions
135
- */
136
- var greg;
137
- (function (greg) {
138
- })(greg || (greg = {}));
139
- greg.abs2greg = abs2greg;
140
- greg.daysInMonth = daysInGregMonth;
141
- greg.greg2abs = greg2abs;
142
- greg.isDate = isDate;
143
- greg.isLeapYear = isGregLeapYear;
144
-
145
- const alefbet = {
146
- א: 1,
147
- ב: 2,
148
- ג: 3,
149
- ד: 4,
150
- ה: 5,
151
- ו: 6,
152
- ז: 7,
153
- ח: 8,
154
- ט: 9,
155
- י: 10,
156
- כ: 20,
157
- ל: 30,
158
- מ: 40,
159
- נ: 50,
160
- ס: 60,
161
- ע: 70,
162
- פ: 80,
163
- צ: 90,
164
- ק: 100,
165
- ר: 200,
166
- ש: 300,
167
- ת: 400,
168
- };
169
- const heb2num = new Map();
170
- const num2heb = new Map();
171
- for (const [key, val] of Object.entries(alefbet)) {
172
- heb2num.set(key, val);
173
- num2heb.set(val, key);
174
- }
175
-
176
- /**
177
- * Formats a number with leading zeros so the resulting string is 4 digits long.
178
- * Similar to `string.padStart(4, '0')` but will also format
179
- * negative numbers similar to how the JavaScript date formats
180
- * negative year numbers (e.g. `-37` is formatted as `-000037`).
181
- */
182
- function pad4(num) {
183
- if (num < 0) {
184
- return '-00' + pad4(-num);
185
- }
186
- else if (num < 10) {
187
- return '000' + num;
188
- }
189
- else if (num < 100) {
190
- return '00' + num;
191
- }
192
- else if (num < 1000) {
193
- return '0' + num;
194
- }
195
- return String(num);
196
- }
197
- /**
198
- * Formats a number with leading zeros so the resulting string is 2 digits long.
199
- * Similar to `string.padStart(2, '0')`.
200
- */
201
- function pad2(num) {
202
- if (num >= 0 && num < 10) {
203
- return '0' + num;
204
- }
205
- return String(num);
206
- }
207
-
208
- /**
209
- * Returns YYYY-MM-DD in the local timezone
210
- */
211
- function isoDateString(dt) {
212
- return (pad4(dt.getFullYear()) +
213
- '-' +
214
- pad2(dt.getMonth() + 1) +
215
- '-' +
216
- pad2(dt.getDate()));
217
- }
218
-
219
- var poAshkenazi = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);" }, "contexts": { "": { "Tevet": ["Teves"] } } };
220
-
221
- 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": ["תִּשְׁרֵי"] } } };
222
-
223
- const noopLocale = {
224
- headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
225
- contexts: { '': {} },
226
- };
227
- const alias = {
228
- h: 'he',
229
- a: 'ashkenazi',
230
- s: 'en',
231
- '': 'en',
232
- };
233
- /** @private */
234
- const locales = new Map();
235
- /** @private */
236
- let activeLocale;
237
- /** @private */
238
- let activeName;
239
- /** @private */
240
- function getEnOrdinal(n) {
241
- const s = ['th', 'st', 'nd', 'rd'];
242
- const v = n % 100;
243
- return n + (s[(v - 20) % 10] || s[v] || s[0]);
244
- }
245
- /** @private */
246
- function checkLocale(locale) {
247
- if (typeof locale !== 'string') {
248
- throw new TypeError(`Invalid locale name: ${locale}`);
249
- }
250
- return locale.toLowerCase();
251
- }
252
- /** @private */
253
- function getExistingLocale(locale) {
254
- const locale1 = checkLocale(locale);
255
- const loc = locales.get(locale1);
256
- if (!loc) {
257
- throw new RangeError(`Locale '${locale}' not found`);
258
- }
259
- return loc;
260
- }
261
- /**
262
- * A locale in Hebcal is used for translations/transliterations of
263
- * holidays. `@hebcal/hdate` supports four locales by default
264
- * * `en` - default, Sephardic transliterations (e.g. "Shabbat")
265
- * * `ashkenazi` - Ashkenazi transliterations (e.g. "Shabbos")
266
- * * `he` - Hebrew (e.g. "שַׁבָּת")
267
- * * `he-x-NoNikud` - Hebrew without nikud (e.g. "שבת")
268
- */
269
- class Locale {
270
- /**
271
- * Returns translation only if `locale` offers a non-empty translation for `id`.
272
- * Otherwise, returns `undefined`.
273
- * @param id Message ID to translate
274
- * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
275
- */
276
- static lookupTranslation(id, locale) {
277
- const loc = (typeof locale === 'string' && locales.get(locale.toLowerCase())) ||
278
- activeLocale;
279
- const array = loc[id];
280
- if ((array === null || array === void 0 ? void 0 : array.length) && array[0].length) {
281
- return array[0];
282
- }
283
- return undefined;
284
- }
285
- /**
286
- * By default, if no translation was found, returns `id`.
287
- * @param id Message ID to translate
288
- * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
289
- */
290
- static gettext(id, locale) {
291
- const text = this.lookupTranslation(id, locale);
292
- if (typeof text === 'undefined') {
293
- return id;
294
- }
295
- return text;
296
- }
297
- /**
298
- * Register locale translations.
299
- * @param locale Locale name (i.e.: `'he'`, `'fr'`)
300
- * @param data parsed data from a `.po` file.
301
- */
302
- static addLocale(locale, data) {
303
- locale = checkLocale(locale);
304
- if (typeof data.contexts !== 'object' ||
305
- typeof data.contexts[''] !== 'object') {
306
- throw new TypeError(`Locale '${locale}' invalid compact format`);
307
- }
308
- locales.set(locale, data.contexts['']);
309
- }
310
- /**
311
- * Adds a translation to `locale`, replacing any previous translation.
312
- * @param locale Locale name (i.e: `'he'`, `'fr'`).
313
- * @param id Message ID to translate
314
- * @param translation Translation text
315
- */
316
- static addTranslation(locale, id, translation) {
317
- const loc = getExistingLocale(locale);
318
- if (typeof id !== 'string' || id.length === 0) {
319
- throw new TypeError(`Invalid id string: ${id}`);
320
- }
321
- const isArray = Array.isArray(translation);
322
- if (isArray) {
323
- const t0 = translation[0];
324
- if (typeof t0 !== 'string' || t0.length === 0) {
325
- throw new TypeError(`Invalid translation array: ${translation}`);
326
- }
327
- }
328
- else if (typeof translation !== 'string') {
329
- throw new TypeError(`Invalid translation string: ${translation}`);
330
- }
331
- loc[id] = isArray ? translation : [translation];
332
- }
333
- /**
334
- * Adds multiple translations to `locale`, replacing any previous translations.
335
- * @param locale Locale name (i.e: `'he'`, `'fr'`).
336
- * @param data parsed data from a `.po` file.
337
- */
338
- static addTranslations(locale, data) {
339
- const loc = getExistingLocale(locale);
340
- if (typeof data.contexts !== 'object' ||
341
- 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 locale Locale name (i.e: `'he'`, `'fr'`)
352
- */
353
- static useLocale(locale) {
354
- const locale0 = checkLocale(locale);
355
- const obj = getExistingLocale(locale0);
356
- activeName = alias[locale0] || locale0;
357
- activeLocale = obj;
358
- return activeLocale;
359
- }
360
- /**
361
- * Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')
362
- */
363
- static getLocaleName() {
364
- return activeName;
365
- }
366
- /**
367
- * Returns the names of registered locales
368
- */
369
- static getLocaleNames() {
370
- const keys = Array.from(locales.keys());
371
- return keys.sort((a, b) => a.localeCompare(b));
372
- }
373
- /**
374
- * Renders a number in ordinal, such as 1st, 2nd or 3rd
375
- * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
376
- */
377
- static ordinal(n, locale) {
378
- const locale1 = locale === null || locale === void 0 ? void 0 : locale.toLowerCase();
379
- const locale0 = locale1 || activeName;
380
- if (!locale0) {
381
- return getEnOrdinal(n);
382
- }
383
- switch (locale0) {
384
- case 'en':
385
- case 's':
386
- case 'a':
387
- return getEnOrdinal(n);
388
- case 'es':
389
- return n + 'º';
390
- case 'h':
391
- case 'he':
392
- case 'he-x-nonikud':
393
- return String(n);
394
- }
395
- if (locale0.startsWith('ashkenazi')) {
396
- return getEnOrdinal(n);
397
- }
398
- return n + '.';
399
- }
400
- /**
401
- * Removes nekudot from Hebrew string
402
- */
403
- static hebrewStripNikkud(str) {
404
- return str.replace(/[\u0590-\u05bd]/g, '').replace(/[\u05bf-\u05c7]/g, '');
405
- }
406
- }
407
- Locale.addLocale('en', noopLocale);
408
- Locale.addLocale('s', noopLocale);
409
- Locale.addLocale('', noopLocale);
410
- Locale.useLocale('en');
411
- /* Ashkenazic transliterations */
412
- Locale.addLocale('ashkenazi', poAshkenazi);
413
- Locale.addLocale('a', poAshkenazi);
414
- /* Hebrew with nikkud */
415
- Locale.addLocale('he', poHe);
416
- Locale.addLocale('h', poHe);
417
- /* Hebrew without nikkud */
418
- const heStrs = poHe.contexts[''];
419
- const heNoNikud = {};
420
- for (const [key, val] of Object.entries(heStrs)) {
421
- heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
422
- }
423
- const poHeNoNikud = {
424
- headers: poHe.headers,
425
- contexts: { '': heNoNikud },
426
- };
427
- Locale.addLocale('he-x-NoNikud', poHeNoNikud);
428
-
429
10
  var countryNames0 = {
430
11
  "AD": "Andorra",
431
12
  "AE": "United Arab Emirates",
@@ -706,7 +287,8 @@ var holidayDescription0 = {
706
287
  * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
707
288
  */
708
289
  function makeAnchor(s) {
709
- return s.toLowerCase()
290
+ return s
291
+ .toLowerCase()
710
292
  .replace(/'/g, '')
711
293
  .replace(/[^\w]/g, '-')
712
294
  .replace(/-+/g, '-')
@@ -732,7 +314,7 @@ const doubled = new Set();
732
314
  for (const name of doubledParshiyot) {
733
315
  const anchor = makeAnchor(name);
734
316
  doubled.add(anchor);
735
- const [p1, p2] = anchor.split('-');
317
+ const [p1] = anchor.split('-');
736
318
  const id = parsha2id.get(p1);
737
319
  parsha2id.set(anchor, id);
738
320
  }
@@ -775,14 +357,25 @@ function shortenSedrotUrl(u) {
775
357
  }
776
358
  }
777
359
 
778
- const LOC_FIELDS = ['elevation', 'admin1', 'asciiname', 'geo', 'zip', 'state', 'stateName', 'geonameid'];
360
+ const LOC_FIELDS = [
361
+ 'elevation',
362
+ 'admin1',
363
+ 'asciiname',
364
+ 'geo',
365
+ 'zip',
366
+ 'state',
367
+ 'stateName',
368
+ 'geonameid',
369
+ ];
779
370
  const holidayDescription = holidayDescription0;
780
371
  const countryNames = countryNames0;
781
372
  /**
782
373
  * Converts a @hebcal/core `Location` to a plain JS object.
783
374
  */
784
375
  function locationToPlainObj(location) {
785
- if (typeof location === 'object' && location !== null && typeof location.getLatitude === 'function') {
376
+ if (typeof location === 'object' &&
377
+ location !== null &&
378
+ typeof location.getLatitude === 'function') {
786
379
  const cc = location.getCountryCode();
787
380
  const o = {
788
381
  title: location.getName(),
@@ -816,7 +409,8 @@ function getDownloadFilename(options) {
816
409
  fileName += '_' + options.month;
817
410
  }
818
411
  }
819
- else if (typeof options.start === 'object' && typeof options.end === 'object') {
412
+ else if (typeof options.start === 'object' &&
413
+ typeof options.end === 'object') {
820
414
  const start = new HDate(options.start);
821
415
  const end = new HDate(options.end);
822
416
  const y1 = start.greg().getFullYear();
@@ -857,7 +451,9 @@ function getEventCategories(ev) {
857
451
  * Renders the event title in default locale, but strips off time
858
452
  */
859
453
  function renderTitleWithoutTime(ev) {
860
- return typeof ev.eventTime === 'undefined' ? ev.render() : ev.renderBrief();
454
+ return typeof ev.eventTime === 'undefined'
455
+ ? ev.render()
456
+ : ev.renderBrief();
861
457
  }
862
458
  function shortLocationName(options) {
863
459
  const loc = options.location;
@@ -890,19 +486,20 @@ function getCalendarTitle(events, options) {
890
486
  else {
891
487
  title += ' Diaspora';
892
488
  }
893
- if (options.subscribe == '1') {
489
+ const sub = options.subscribe;
490
+ if (sub === '1' || sub === 1 || sub === true) {
894
491
  return title;
895
492
  }
896
- if (options.year && (options.isHebrewYear || events.length == 0)) {
493
+ if (options.year && (options.isHebrewYear || events.length === 0)) {
897
494
  title += ' ' + options.year;
898
495
  }
899
496
  else if (events.length) {
900
497
  const start = events[0].getDate().greg();
901
498
  const end = events[events.length - 1].getDate().greg();
902
- if (start.getFullYear() != end.getFullYear()) {
499
+ if (start.getFullYear() !== end.getFullYear()) {
903
500
  title += ' ' + start.getFullYear() + '-' + end.getFullYear();
904
501
  }
905
- else if (start.getMonth() == end.getMonth()) {
502
+ else if (start.getMonth() === end.getMonth()) {
906
503
  const monthFormat = new Intl.DateTimeFormat('en-US', { month: 'long' });
907
504
  const startMonth = monthFormat.format(start);
908
505
  title += ' ' + startMonth + ' ' + start.getFullYear();
@@ -917,34 +514,42 @@ function getCalendarTitle(events, options) {
917
514
  * Returns an English language description of the holiday
918
515
  */
919
516
  function getHolidayDescription(ev, firstSentence = false) {
920
- const str0 = ev.getFlags() & flags.SHABBAT_MEVARCHIM ?
921
- holidayDescription['Shabbat Mevarchim Chodesh'] :
922
- holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
517
+ const str0 = ev.getFlags() & flags.SHABBAT_MEVARCHIM
518
+ ? holidayDescription['Shabbat Mevarchim Chodesh']
519
+ : holidayDescription[ev.getDesc()] ||
520
+ holidayDescription[ev.basename()] ||
521
+ '';
923
522
  const str = str0.normalize();
924
523
  if (firstSentence && str) {
925
524
  const dot = str.indexOf('.');
926
- if (dot != -1) {
525
+ if (dot !== -1) {
927
526
  return str.substring(0, dot);
928
527
  }
929
528
  }
930
529
  return str;
931
530
  }
932
- const HOLIDAY_IGNORE_MASK = flags.DAF_YOMI | flags.OMER_COUNT |
933
- flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT |
934
- flags.NACH_YOMI | flags.DAILY_LEARNING |
935
- flags.HEBREW_DATE | flags.YERUSHALMI_YOMI;
531
+ const HOLIDAY_IGNORE_MASK = flags.DAF_YOMI |
532
+ flags.OMER_COUNT |
533
+ flags.SHABBAT_MEVARCHIM |
534
+ flags.MOLAD |
535
+ flags.USER_EVENT |
536
+ flags.NACH_YOMI |
537
+ flags.DAILY_LEARNING |
538
+ flags.HEBREW_DATE |
539
+ flags.YERUSHALMI_YOMI;
936
540
  /**
937
541
  * Makes mulit-line text that summarizes Torah & Haftarah
938
542
  */
939
543
  function makeTorahMemoText(ev, il) {
940
544
  var _a;
941
545
  const mask = ev.getFlags();
942
- if ((mask & HOLIDAY_IGNORE_MASK) || (typeof ev.eventTime !== 'undefined')) {
546
+ if (mask & HOLIDAY_IGNORE_MASK ||
547
+ typeof ev.eventTime !== 'undefined') {
943
548
  return '';
944
549
  }
945
- const reading = (mask & flags.PARSHA_HASHAVUA) ?
946
- getLeyningForParshaHaShavua(ev, il) :
947
- getLeyningForHoliday(ev, il);
550
+ const reading = mask & flags.PARSHA_HASHAVUA
551
+ ? getLeyningForParshaHaShavua(ev, il)
552
+ : getLeyningForHoliday(ev, il);
948
553
  let memo = '';
949
554
  if (reading && (reading.summary || reading.haftara)) {
950
555
  if (reading.summary) {
@@ -1004,10 +609,12 @@ function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
1004
609
  else if (isSedrot) {
1005
610
  shortenSedrotUrl(u);
1006
611
  }
1007
- else { // isOmer
612
+ else {
613
+ // isOmer
1008
614
  u.pathname = '/o/' + path.substring(6);
1009
615
  }
1010
- if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
616
+ if (!utmCampaign ||
617
+ !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
1011
618
  if (utmSource) {
1012
619
  u.searchParams.set('us', utmSource);
1013
620
  }
@@ -1040,12 +647,14 @@ function shouldRenderBrief(ev) {
1040
647
  const mask = ev.getFlags();
1041
648
  if (mask & flags.HEBREW_DATE) {
1042
649
  const hd = ev.getDate();
1043
- return (hd.getDate() === 1) ? false : true;
650
+ return hd.getDate() === 1 ? false : true;
1044
651
  }
1045
- else if (mask & (flags.DAILY_LEARNING | flags.DAF_YOMI | flags.YERUSHALMI_YOMI)) {
652
+ else if (mask &
653
+ (flags.DAILY_LEARNING | flags.DAF_YOMI | flags.YERUSHALMI_YOMI)) {
1046
654
  return true;
1047
655
  }
1048
- else if (mask & flags.MINOR_FAST && ev.getDesc().substring(0, 16) === 'Yom Kippur Katan') {
656
+ else if (mask & flags.MINOR_FAST &&
657
+ ev.getDesc().substring(0, 16) === 'Yom Kippur Katan') {
1049
658
  return true;
1050
659
  }
1051
660
  else if (mask & flags.SHABBAT_MEVARCHIM) {
@@ -1081,15 +690,20 @@ function eventToCsv(ev, options) {
1081
690
  const mday = d.getDate();
1082
691
  const mon = d.getMonth() + 1;
1083
692
  const year = String(d.getFullYear()).padStart(4, '0');
1084
- const date = options.euro ? `"${mday}/${mon}/${year}"` : `"${mon}/${mday}/${year}"`;
693
+ const date = options.euro
694
+ ? `"${mday}/${mon}/${year}"`
695
+ : `"${mon}/${mday}/${year}"`;
1085
696
  let startTime = '';
1086
697
  let endTime = '';
1087
698
  let endDate = '';
1088
699
  let allDay = '"true"';
1089
- const timed = Boolean(ev.eventTime);
1090
- let subj = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
700
+ const timedEv = ev;
701
+ const timed = Boolean(timedEv.eventTime);
702
+ let subj = shouldRenderBrief(ev)
703
+ ? ev.renderBrief(options.locale)
704
+ : ev.render(options.locale);
1091
705
  if (timed) {
1092
- const timeStr = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, ' PM', options);
706
+ const timeStr = HebrewCalendar.reformatTimeStr(timedEv.eventTimeStr, ' PM', options);
1093
707
  endTime = startTime = `"${timeStr}"`;
1094
708
  endDate = date;
1095
709
  allDay = '"false"';
@@ -1108,7 +722,7 @@ function eventToCsv(ev, options) {
1108
722
  loc = category;
1109
723
  }
1110
724
  }
1111
- subj = subj.replace(/,/g, '').replace(/"/g, '\'\'');
725
+ subj = subj.replace(/,/g, '').replace(/"/g, "''");
1112
726
  if (options.appendHebrewToSubject) {
1113
727
  const hebrew = ev.renderBrief('he');
1114
728
  if (hebrew) {
@@ -1116,15 +730,19 @@ function eventToCsv(ev, options) {
1116
730
  }
1117
731
  }
1118
732
  let memo0 = ev.memo || getHolidayDescription(ev, true);
1119
- if (!memo0 && typeof ev.linkedEvent !== 'undefined') {
1120
- memo0 = ev.linkedEvent.render(options.locale);
1121
- }
1122
- const memo = memo0.replace(/,/g, ';').replace(/"/g, '\'\'').replace(/\n/g, ' / ');
1123
- const showTimeAs = (timed || (mask & flags.CHAG)) ? 4 : 3;
733
+ if (!memo0 && typeof timedEv.linkedEvent !== 'undefined') {
734
+ memo0 = timedEv.linkedEvent.render(options.locale);
735
+ }
736
+ const memo = memo0
737
+ .replace(/,/g, ';')
738
+ .replace(/"/g, "''")
739
+ .replace(/\n/g, ' / ');
740
+ const showTimeAs = timed || mask & flags.CHAG ? 4 : 3;
1124
741
  return `"${subj}",${date},${startTime},${endDate},${endTime},${allDay},"${memo}","${showTimeAs}","${loc}"`;
1125
742
  }
1126
743
  function eventsToCsv(events, options) {
1127
- return [csvHeader].concat(events.map((ev) => eventToCsv(ev, options))).join('\r\n') + '\r\n';
744
+ return ([csvHeader].concat(events.map(ev => eventToCsv(ev, options))).join('\r\n') +
745
+ '\r\n');
1128
746
  }
1129
747
 
1130
748
  function eventIsoDate(ev) {
@@ -1137,6 +755,7 @@ function eventsToClassicApi(events, options, leyning = true) {
1137
755
  const result = {
1138
756
  title: getCalendarTitle(events, options),
1139
757
  date: new Date().toISOString(),
758
+ version,
1140
759
  };
1141
760
  result.location = locationToPlainObj(options.location);
1142
761
  if (events.length) {
@@ -1145,28 +764,31 @@ function eventsToClassicApi(events, options, leyning = true) {
1145
764
  end: eventIsoDate(events[events.length - 1]),
1146
765
  };
1147
766
  }
1148
- result.items = events.map((ev) => eventToClassicApiObject(ev, options, leyning));
767
+ result.items = events.map(ev => eventToClassicApiObject(ev, options, leyning));
1149
768
  return result;
1150
769
  }
1151
770
  /**
1152
771
  * Converts a Hebcal event to a classic Hebcal.com JSON API object
1153
772
  */
1154
773
  function eventToClassicApiObject(ev, options, leyning = true) {
1155
- const eventTime = ev.eventTime;
774
+ const timedEv = ev;
775
+ const eventTime = timedEv.eventTime;
1156
776
  const timed = Boolean(eventTime);
1157
777
  const hd = ev.getDate();
1158
778
  const dt = hd.greg();
1159
779
  const tzid = typeof options.location === 'object' ? options.location.getTzid() : 'UTC';
1160
- const date = timed ?
1161
- Zmanim.formatISOWithTimeZone(tzid, eventTime) :
1162
- isoDateString(dt);
780
+ const date = timed
781
+ ? Zmanim.formatISOWithTimeZone(tzid, eventTime)
782
+ : isoDateString(dt);
1163
783
  const categories = getEventCategories(ev);
1164
784
  const mask = ev.getFlags();
1165
- let title = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
785
+ let title = shouldRenderBrief(ev)
786
+ ? ev.renderBrief(options.locale)
787
+ : ev.render(options.locale);
1166
788
  const desc = ev.getDesc();
1167
789
  const candles = desc === 'Havdalah' || desc === 'Candle lighting';
1168
790
  if (candles) {
1169
- const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
791
+ const time = HebrewCalendar.reformatTimeStr(timedEv.eventTimeStr, 'pm', options);
1170
792
  title += ': ' + time;
1171
793
  }
1172
794
  const result = {
@@ -1180,23 +802,23 @@ function eventToClassicApiObject(ev, options, leyning = true) {
1180
802
  if (categories.length > 1) {
1181
803
  result.subcat = categories[1];
1182
804
  }
1183
- if (categories[0] === 'holiday' && (mask & flags.CHAG)) {
805
+ if (categories[0] === 'holiday' && mask & flags.CHAG) {
1184
806
  result.yomtov = true;
1185
807
  }
1186
- if (title != desc) {
808
+ if (title !== desc) {
1187
809
  result.title_orig = desc;
1188
810
  }
1189
811
  const hebrew = ev.renderBrief('he');
1190
812
  if (hebrew) {
1191
- result.hebrew = Locale$1.hebrewStripNikkud(hebrew);
813
+ result.hebrew = Locale.hebrewStripNikkud(hebrew);
1192
814
  }
1193
815
  if (!candles) {
1194
816
  if (leyning) {
1195
817
  const il = options.il;
1196
- const isParsha = (mask === flags.PARSHA_HASHAVUA);
1197
- const reading = isParsha ?
1198
- getLeyningForParshaHaShavua(ev, il) :
1199
- getLeyningForHoliday(ev, il);
818
+ const isParsha = mask === flags.PARSHA_HASHAVUA;
819
+ const reading = isParsha
820
+ ? getLeyningForParshaHaShavua(ev, il)
821
+ : getLeyningForHoliday(ev, il);
1200
822
  if (reading) {
1201
823
  result.leyning = formatLeyningResult(reading);
1202
824
  const hyear = hd.getFullYear();
@@ -1244,13 +866,13 @@ function eventToClassicApiObject(ev, options, leyning = true) {
1244
866
  };
1245
867
  delete result.hebrew;
1246
868
  }
1247
- if ((options.heDateParts && !timed) || (mask & flags.HEBREW_DATE)) {
869
+ if ((options.heDateParts && !timed) || mask & flags.HEBREW_DATE) {
1248
870
  const yy = hd.getFullYear();
1249
871
  const mm = hd.getMonthName();
1250
872
  const dd = hd.getDate();
1251
873
  result.heDateParts = {
1252
874
  y: gematriya(yy),
1253
- m: Locale$1.gettext(mm, 'he-x-NoNikud'),
875
+ m: Locale.gettext(mm, 'he-x-NoNikud'),
1254
876
  d: gematriya(dd),
1255
877
  };
1256
878
  }
@@ -1258,8 +880,8 @@ function eventToClassicApiObject(ev, options, leyning = true) {
1258
880
  if (typeof memo === 'string' && memo.length !== 0) {
1259
881
  result.memo = memo.normalize();
1260
882
  }
1261
- else if (typeof ev.linkedEvent !== 'undefined') {
1262
- result.memo = ev.linkedEvent.render(options.locale);
883
+ else if (typeof timedEv.linkedEvent !== 'undefined') {
884
+ result.memo = timedEv.linkedEvent.render(options.locale);
1263
885
  }
1264
886
  if (options.includeEvent) {
1265
887
  result.ev = ev;
@@ -1269,7 +891,7 @@ function eventToClassicApiObject(ev, options, leyning = true) {
1269
891
  function formatAliyot(result, aliyot) {
1270
892
  for (const [num, aliyah] of Object.entries(aliyot)) {
1271
893
  if (typeof aliyah !== 'undefined') {
1272
- const k = num == 'M' ? 'maftir' : num;
894
+ const k = num === 'M' ? 'maftir' : num;
1273
895
  result[k] = formatAliyahWithBook(aliyah);
1274
896
  }
1275
897
  }
@@ -1278,7 +900,7 @@ function formatAliyot(result, aliyot) {
1278
900
  function formatReasons(result, reason) {
1279
901
  for (const num of ['7', '8', 'M']) {
1280
902
  if (reason[num]) {
1281
- const k = num == 'M' ? 'maftir' : num;
903
+ const k = num === 'M' ? 'maftir' : num;
1282
904
  result[k] += ' | ' + reason[num];
1283
905
  }
1284
906
  }
@@ -1331,12 +953,12 @@ function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
1331
953
  return [link, guid];
1332
954
  }
1333
955
  const localeToLg = {
1334
- 's': 'en',
1335
- 'a': 'en',
956
+ s: 'en',
957
+ a: 'en',
1336
958
  'he-x-NoNikud': 'he',
1337
- 'h': 'he',
1338
- 'ah': 'en',
1339
- 'sh': 'en',
959
+ h: 'he',
960
+ ah: 'en',
961
+ sh: 'en',
1340
962
  };
1341
963
  function eventsToRss2(events, options) {
1342
964
  options.dayFormat = new Intl.DateTimeFormat('en-US', {
@@ -1349,9 +971,9 @@ function eventsToRss2(events, options) {
1349
971
  if (!options.mainUrl || !options.selfUrl) {
1350
972
  throw new TypeError('mainUrl cannot be empty or blank');
1351
973
  }
1352
- const buildDate = options.buildDate = options.buildDate || new Date();
974
+ const buildDate = (options.buildDate = options.buildDate || new Date());
1353
975
  const thisYear = buildDate.getFullYear();
1354
- const lastBuildDate = options.lastBuildDate = buildDate.toUTCString();
976
+ const lastBuildDate = (options.lastBuildDate = buildDate.toUTCString());
1355
977
  const title = options.title || getCalendarTitle(events, options);
1356
978
  const description = options.description || title;
1357
979
  const utmSource = options.utmSource || 'shabbat1c';
@@ -1406,8 +1028,8 @@ function eventToRssItem2(ev, options) {
1406
1028
  let memo;
1407
1029
  if (candles) {
1408
1030
  const colon = subj.indexOf(': ');
1409
- if (colon != -1) {
1410
- const options = { location, il, locale: Locale$1.getLocaleName() };
1031
+ if (colon !== -1) {
1032
+ const options = { location, il, locale: Locale.getLocaleName() };
1411
1033
  const time = HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
1412
1034
  subj = subj.substring(0, colon) + ': ' + time;
1413
1035
  }
@@ -1416,11 +1038,11 @@ function eventToRssItem2(ev, options) {
1416
1038
  memo = makeMemo(ev, il);
1417
1039
  }
1418
1040
  const dayFormat = options.dayFormat;
1419
- const description0 = memo || dayFormat.format(evDate);
1420
- const description = description0.indexOf('<') === -1 ? description0 : `<![CDATA[${description0}]]>`;
1421
- const geoTags = (cat0 == 'candles') ?
1422
- `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n` :
1423
- '';
1041
+ const tmp = memo || dayFormat.format(evDate);
1042
+ const description = tmp.indexOf('<') === -1 ? tmp : `<![CDATA[${tmp}]]>`;
1043
+ const geoTags = cat0 === 'candles'
1044
+ ? `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n`
1045
+ : '';
1424
1046
  return `<item>
1425
1047
  <title>${subj}</title>
1426
1048
  <link>${link}</link>
@@ -1438,15 +1060,16 @@ ${geoTags}</item>
1438
1060
  function eventToFullCalendar(ev, tzid, il) {
1439
1061
  const classes = getEventCategories(ev);
1440
1062
  const mask = ev.getFlags();
1441
- if (classes[0] == 'holiday' && mask & flags.CHAG) {
1063
+ if (classes[0] === 'holiday' && mask & flags.CHAG) {
1442
1064
  classes.push('yomtov');
1443
1065
  }
1444
- const eventTime = ev.eventTime;
1066
+ const timedEv = ev;
1067
+ const eventTime = timedEv.eventTime;
1445
1068
  const timed = Boolean(eventTime);
1446
1069
  const title = shouldRenderBrief(ev) ? ev.renderBrief() : ev.render();
1447
- const start = timed ?
1448
- Zmanim.formatISOWithTimeZone(tzid, eventTime) :
1449
- isoDateString(ev.getDate().greg());
1070
+ const start = timed
1071
+ ? Zmanim.formatISOWithTimeZone(tzid, eventTime)
1072
+ : isoDateString(ev.getDate().greg());
1450
1073
  const result = {
1451
1074
  title,
1452
1075
  start,
@@ -1455,7 +1078,7 @@ function eventToFullCalendar(ev, tzid, il) {
1455
1078
  };
1456
1079
  const hebrew = ev.renderBrief('he');
1457
1080
  if (hebrew) {
1458
- result.hebrew = Locale$1.hebrewStripNikkud(hebrew);
1081
+ result.hebrew = Locale.hebrewStripNikkud(hebrew);
1459
1082
  }
1460
1083
  const url = ev.url();
1461
1084
  if (url) {
@@ -1468,11 +1091,11 @@ function eventToFullCalendar(ev, tzid, il) {
1468
1091
  if (memo) {
1469
1092
  result.description = memo;
1470
1093
  }
1471
- else if (typeof ev.linkedEvent !== 'undefined') {
1472
- result.description = ev.linkedEvent.render();
1094
+ else if (typeof timedEv.linkedEvent !== 'undefined') {
1095
+ result.description = timedEv.linkedEvent.render();
1473
1096
  }
1474
1097
  }
1475
1098
  return result;
1476
1099
  }
1477
1100
 
1478
- export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem2, eventsToClassicApi, eventsToCsv, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, locationToPlainObj, makeAnchor, makeMemo, makeTorahMemoText, pad2, pad4, renderTitleWithoutTime, shouldRenderBrief, toISOString };
1101
+ export { appendIsraelAndTracking, countryNames, eventToClassicApiObject, eventToCsv, eventToFullCalendar, eventToRssItem2, eventsToClassicApi, eventsToCsv, eventsToRss2, getCalendarTitle, getDownloadFilename, getEventCategories, getHolidayDescription, holidayDescription, locationToPlainObj, makeAnchor, makeMemo, makeTorahMemoText, renderTitleWithoutTime, shouldRenderBrief, toISOString };