@hebcal/core 5.9.9 → 5.10.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.
Files changed (70) hide show
  1. package/dist/bundle.js +2555 -2496
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/bundle.min.js +6 -6
  4. package/dist/bundle.min.js.map +1 -1
  5. package/dist/esm/DailyLearning.js +1 -1
  6. package/dist/esm/HebrewDateEvent.js +1 -1
  7. package/dist/esm/HebrewDateEvent.js.map +1 -1
  8. package/dist/esm/HolidayEvent.js +1 -1
  9. package/dist/esm/HolidayEvent.js.map +1 -1
  10. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  11. package/dist/esm/ParshaEvent.js +1 -1
  12. package/dist/esm/ParshaEvent.js.map +1 -1
  13. package/dist/esm/TimedEvent.js +1 -1
  14. package/dist/esm/TimedEvent.js.map +1 -1
  15. package/dist/esm/YomKippurKatanEvent.js +1 -1
  16. package/dist/esm/YomKippurKatanEvent.js.map +1 -1
  17. package/dist/esm/ashkenazi.po.js +1 -1
  18. package/dist/esm/calendar.js +1 -1
  19. package/dist/esm/calendar.js.map +1 -1
  20. package/dist/esm/candles.js +1 -1
  21. package/dist/esm/candles.js.map +1 -1
  22. package/dist/esm/event.js +1 -1
  23. package/dist/esm/event.js.map +1 -1
  24. package/dist/esm/getStartAndEnd.js +1 -1
  25. package/dist/esm/getStartAndEnd.js.map +1 -1
  26. package/dist/esm/hallel.js +1 -1
  27. package/dist/esm/hallel.js.map +1 -1
  28. package/dist/esm/he-x-NoNikud.po.js +1 -1
  29. package/dist/esm/he.po.js +1 -1
  30. package/dist/esm/hebcal.js +1 -1
  31. package/dist/esm/holidays.js +1 -1
  32. package/dist/esm/holidays.js.map +1 -1
  33. package/dist/esm/index.d.ts +1 -0
  34. package/dist/esm/index.js +2 -1
  35. package/dist/esm/index.js.map +1 -1
  36. package/dist/esm/isAssurBemlacha.d.ts +9 -0
  37. package/dist/esm/isAssurBemlacha.js +67 -0
  38. package/dist/esm/isAssurBemlacha.js.map +1 -0
  39. package/dist/esm/locale.js +1 -1
  40. package/dist/esm/location.js +1 -1
  41. package/dist/esm/location.js.map +1 -1
  42. package/dist/esm/modern.js +1 -1
  43. package/dist/esm/molad.js +1 -1
  44. package/dist/esm/molad.js.map +1 -1
  45. package/dist/esm/omer.d.ts +0 -1
  46. package/dist/esm/omer.js +1 -2
  47. package/dist/esm/omer.js.map +1 -1
  48. package/dist/esm/parshaName.js +1 -1
  49. package/dist/esm/parshaName.js.map +1 -1
  50. package/dist/esm/parshaYear.js +1 -1
  51. package/dist/esm/parshaYear.js.map +1 -1
  52. package/dist/esm/pkgVersion.d.ts +1 -1
  53. package/dist/esm/pkgVersion.js +2 -2
  54. package/dist/esm/pkgVersion.js.map +1 -1
  55. package/dist/esm/reformatTimeStr.js +1 -1
  56. package/dist/esm/reformatTimeStr.js.map +1 -1
  57. package/dist/esm/sedra.js +1 -1
  58. package/dist/esm/sedra.js.map +1 -1
  59. package/dist/esm/staticHolidays.js +1 -1
  60. package/dist/esm/staticHolidays.js.map +1 -1
  61. package/dist/esm/tachanun.js +1 -1
  62. package/dist/esm/tachanun.js.map +1 -1
  63. package/dist/esm/zmanim.js +1 -1
  64. package/dist/index.cjs +2423 -2364
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.ts +1 -0
  67. package/dist/isAssurBemlacha.d.ts +9 -0
  68. package/dist/omer.d.ts +0 -1
  69. package/dist/pkgVersion.d.ts +1 -1
  70. package/package.json +6 -6
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- /*! @hebcal/core v5.9.9, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v5.10.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  'use strict';
3
3
 
4
4
  require('temporal-polyfill/global');
5
5
 
6
6
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
7
- const version = '5.9.9';
7
+ const version = '5.10.0';
8
8
 
9
9
  /*! @hebcal/hdate v0.14.2, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
10
10
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
@@ -4182,1546 +4182,13 @@ class Zmanim {
4182
4182
  }
4183
4183
  }
4184
4184
 
4185
- const hour12cc = {
4186
- US: 1,
4187
- CA: 1,
4188
- BR: 1,
4189
- AU: 1,
4190
- NZ: 1,
4191
- DO: 1,
4192
- PR: 1,
4193
- GR: 1,
4194
- IN: 1,
4195
- KR: 1,
4196
- NP: 1,
4197
- ZA: 1,
4198
- };
4199
- /**
4200
- * @private
4201
- * @param timeStr - original time like "20:30"
4202
- * @param suffix - "p" or "pm" or " P.M.". Add leading space if you want it
4203
- * @param options
4204
- */
4205
- function reformatTimeStr(timeStr, suffix, options) {
4206
- var _a;
4207
- if (typeof timeStr !== 'string')
4208
- throw new TypeError(`Bad timeStr: ${timeStr}`);
4209
- const cc = ((_a = options === null || options === void 0 ? void 0 : options.location) === null || _a === void 0 ? void 0 : _a.getCountryCode()) || ((options === null || options === void 0 ? void 0 : options.il) ? 'IL' : 'US');
4210
- const hour12 = options === null || options === void 0 ? void 0 : options.hour12;
4211
- if (typeof hour12 !== 'undefined' && !hour12) {
4212
- return timeStr;
4213
- }
4214
- if (!hour12 && typeof hour12cc[cc] === 'undefined') {
4215
- return timeStr;
4216
- }
4217
- const hm = timeStr.split(':');
4218
- let hour = parseInt(hm[0], 10);
4219
- if (hour < 12 && suffix) {
4220
- suffix = suffix.replace('p', 'a').replace('P', 'A');
4221
- if (hour === 0) {
4222
- hour = 12;
4223
- }
4224
- }
4225
- else if (hour > 12) {
4226
- hour = hour % 12;
4227
- }
4228
- else if (hour === 0) {
4229
- hour = '00';
4230
- }
4231
- return `${hour}:${hm[1]}${suffix}`;
4232
- }
4185
+ class QuickLRU extends Map {
4186
+ constructor(options = {}) {
4187
+ super();
4233
4188
 
4234
- /** An event that has an `eventTime` and `eventTimeStr` */
4235
- class TimedEvent extends Event {
4236
- /**
4237
- * @param desc Description (not translated)
4238
- */
4239
- constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
4240
- super(date, desc, mask);
4241
- this.eventTime = Zmanim.roundTime(eventTime);
4242
- this.location = location;
4243
- const timeFormat = location.getTimeFormatter();
4244
- this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
4245
- const opts = Object.assign(Object.assign({}, options), { location });
4246
- this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
4247
- if (typeof linkedEvent !== 'undefined') {
4248
- this.linkedEvent = linkedEvent;
4249
- }
4250
- }
4251
- /**
4252
- * @param [locale] Optional locale name (defaults to active locale).
4253
- */
4254
- render(locale) {
4255
- return Locale.gettext(this.getDesc(), locale) + ': ' + this.fmtTime;
4256
- }
4257
- /**
4258
- * Returns translation of "Candle lighting" without the time.
4259
- * @param [locale] Optional locale name (defaults to active locale).
4260
- */
4261
- renderBrief(locale) {
4262
- return Locale.gettext(this.getDesc(), locale);
4263
- }
4264
- getCategories() {
4265
- const desc = this.getDesc();
4266
- switch (desc) {
4267
- // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
4268
- case 'Candle lighting':
4269
- return ['candles'];
4270
- // YOM_TOV_ENDS
4271
- case 'Havdalah':
4272
- return ['havdalah'];
4273
- // flags.MINOR_FAST or flags.MAJOR_FAST
4274
- case 'Fast begins':
4275
- case 'Fast ends':
4276
- return ['zmanim', 'fast'];
4277
- }
4278
- /* NOTREACHED */
4279
- return ['unknown'];
4280
- }
4281
- }
4282
- /** Candle lighting before Shabbat or holiday */
4283
- class CandleLightingEvent extends TimedEvent {
4284
- constructor(date, mask, eventTime, location, linkedEvent, options) {
4285
- super(date, 'Candle lighting', mask, eventTime, location, linkedEvent, options);
4286
- }
4287
- getEmoji() {
4288
- return '🕯️';
4289
- }
4290
- }
4291
- /** Havdalah after Shabbat or holiday */
4292
- class HavdalahEvent extends TimedEvent {
4293
- constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
4294
- super(date, 'Havdalah', mask, eventTime, location, linkedEvent, options);
4295
- if (havdalahMins) {
4296
- this.havdalahMins = havdalahMins;
4297
- }
4298
- }
4299
- /**
4300
- * @param [locale] Optional locale name (defaults to active locale).
4301
- */
4302
- render(locale) {
4303
- return this.renderBrief(locale) + ': ' + this.fmtTime;
4304
- }
4305
- /**
4306
- * Returns translation of "Havdalah" without the time.
4307
- * @param [locale] Optional locale name (defaults to active locale).
4308
- */
4309
- renderBrief(locale) {
4310
- let str = Locale.gettext(this.getDesc(), locale);
4311
- if (this.havdalahMins) {
4312
- const min = Locale.gettext('min', locale);
4313
- str += ` (${this.havdalahMins} ${min})`;
4314
- }
4315
- return str;
4316
- }
4317
- getEmoji() {
4318
- return '✨';
4319
- }
4320
- }
4321
-
4322
- const Nisan = months.NISAN;
4323
- const Iyyar = months.IYYAR;
4324
- const Sivan = months.SIVAN;
4325
- const Tamuz = months.TAMUZ;
4326
- const Av = months.AV;
4327
- const Elul = months.ELUL;
4328
- const Tishrei = months.TISHREI;
4329
- const Cheshvan = months.CHESHVAN;
4330
- const Kislev = months.KISLEV;
4331
- const Shvat = months.SHVAT;
4332
- const Adar2 = months.ADAR_II;
4333
- const CHAG$1 = flags.CHAG;
4334
- const LIGHT_CANDLES$2 = flags.LIGHT_CANDLES;
4335
- const YOM_TOV_ENDS$1 = flags.YOM_TOV_ENDS;
4336
- const CHUL_ONLY$1 = flags.CHUL_ONLY;
4337
- const IL_ONLY$2 = flags.IL_ONLY;
4338
- const LIGHT_CANDLES_TZEIS$3 = flags.LIGHT_CANDLES_TZEIS;
4339
- const CHANUKAH_CANDLES$2 = flags.CHANUKAH_CANDLES;
4340
- const MAJOR_FAST$2 = flags.MAJOR_FAST;
4341
- const MINOR_HOLIDAY$2 = flags.MINOR_HOLIDAY;
4342
- const EREV$2 = flags.EREV;
4343
- const CHOL_HAMOED$1 = flags.CHOL_HAMOED;
4344
- const emojiPesach = '🫓';
4345
- const emojiSukkot = '🌿🍋';
4346
- const ROSH_HASHANA_II = 'Rosh Hashana II';
4347
- const EREV_YOM_KIPPUR = 'Erev Yom Kippur';
4348
- const YOM_KIPPUR = 'Yom Kippur';
4349
- const EREV_SUKKOT = 'Erev Sukkot';
4350
- const SUKKOT_I = 'Sukkot I';
4351
- const SUKKOT_II = 'Sukkot II';
4352
- const SUKKOT_III_CHM = "Sukkot III (CH''M)";
4353
- const SUKKOT_IV_CHM = "Sukkot IV (CH''M)";
4354
- const SUKKOT_V_CHM = "Sukkot V (CH''M)";
4355
- const SUKKOT_VI_CHM = "Sukkot VI (CH''M)";
4356
- const SHMINI_ATZERET = 'Shmini Atzeret';
4357
- const SIMCHAT_TORAH = 'Simchat Torah';
4358
- const SUKKOT_II_CHM = "Sukkot II (CH''M)";
4359
- const SUKKOT_VII_HOSHANA_RABA = 'Sukkot VII (Hoshana Raba)';
4360
- const CHANUKAH_1_CANDLE = 'Chanukah: 1 Candle';
4361
- const TU_BISHVAT = 'Tu BiShvat';
4362
- const EREV_PURIM = 'Erev Purim';
4363
- const PURIM = 'Purim';
4364
- const SHUSHAN_PURIM = 'Shushan Purim';
4365
- const EREV_PESACH = 'Erev Pesach';
4366
- const PESACH_I = 'Pesach I';
4367
- const PESACH_II = 'Pesach II';
4368
- const PESACH_II_CHM = "Pesach II (CH''M)";
4369
- const PESACH_III_CHM = "Pesach III (CH''M)";
4370
- const PESACH_IV_CHM = "Pesach IV (CH''M)";
4371
- const PESACH_V_CHM = "Pesach V (CH''M)";
4372
- const PESACH_VI_CHM = "Pesach VI (CH''M)";
4373
- const PESACH_VII = 'Pesach VII';
4374
- const PESACH_VIII = 'Pesach VIII';
4375
- const PESACH_SHENI = 'Pesach Sheni';
4376
- const LAG_BAOMER = 'Lag BaOmer';
4377
- const EREV_SHAVUOT = 'Erev Shavuot';
4378
- const SHAVUOT$1 = 'Shavuot';
4379
- const SHAVUOT_I = 'Shavuot I';
4380
- const SHAVUOT_II = 'Shavuot II';
4381
- const TU_BAV = "Tu B'Av";
4382
- const ROSH_HASHANA_LABEHEMOT = 'Rosh Hashana LaBehemot';
4383
- const EREV_ROSH_HASHANA = 'Erev Rosh Hashana';
4384
- const YOM_YERUSHALAYIM = 'Yom Yerushalayim';
4385
- const BEN_GURION_DAY = 'Ben-Gurion Day';
4386
- const FAMILY_DAY = 'Family Day';
4387
- const YITZHAK_RABIN_MEMORIAL_DAY = 'Yitzhak Rabin Memorial Day';
4388
- const HERZL_DAY = 'Herzl Day';
4389
- const JABOTINSKY_DAY = 'Jabotinsky Day';
4390
- const SIGD = 'Sigd';
4391
- const YOM_HAALIYAH = 'Yom HaAliyah';
4392
- const YOM_HAALIYAH_SCHOOL_OBSERVANCE = 'Yom HaAliyah School Observance';
4393
- const HEBREW_LANGUAGE_DAY = 'Hebrew Language Day';
4394
- /**
4395
- * Transliterated names of holidays, used by `Event.getDesc()`
4396
- * @readonly
4397
- * @enum {string}
4398
- */
4399
- const holidayDesc = {
4400
- /** Asara B'Tevet */
4401
- ASARA_BTEVET: "Asara B'Tevet",
4402
- /** Birkat Hachamah */
4403
- BIRKAT_HACHAMAH: 'Birkat Hachamah',
4404
- /** Chag HaBanot */
4405
- CHAG_HABANOT: 'Chag HaBanot',
4406
- /** Chanukah: 8th Day */
4407
- CHANUKAH_8TH_DAY: 'Chanukah: 8th Day',
4408
- /** Erev Tish'a B'Av */
4409
- EREV_TISHA_BAV: "Erev Tish'a B'Av",
4410
- /** Leil Selichot */
4411
- LEIL_SELICHOT: 'Leil Selichot',
4412
- /** Purim Katan */
4413
- PURIM_KATAN: 'Purim Katan',
4414
- /** Purim Meshulash */
4415
- PURIM_MESHULASH: 'Purim Meshulash',
4416
- /** Shabbat Chazon */
4417
- SHABBAT_CHAZON: 'Shabbat Chazon',
4418
- /** Shabbat HaChodesh */
4419
- SHABBAT_HACHODESH: 'Shabbat HaChodesh',
4420
- /** Shabbat HaGadol */
4421
- SHABBAT_HAGADOL: 'Shabbat HaGadol',
4422
- /** Shabbat Nachamu */
4423
- SHABBAT_NACHAMU: 'Shabbat Nachamu',
4424
- /** Shabbat Parah */
4425
- SHABBAT_PARAH: 'Shabbat Parah',
4426
- /** Shabbat Shekalim */
4427
- SHABBAT_SHEKALIM: 'Shabbat Shekalim',
4428
- /** Shabbat Shirah */
4429
- SHABBAT_SHIRAH: 'Shabbat Shirah',
4430
- /** Shabbat Shuva */
4431
- SHABBAT_SHUVA: 'Shabbat Shuva',
4432
- /** Shabbat Zachor */
4433
- SHABBAT_ZACHOR: 'Shabbat Zachor',
4434
- /** Shushan Purim Katan */
4435
- SHUSHAN_PURIM_KATAN: 'Shushan Purim Katan',
4436
- /** Ta'anit Bechorot */
4437
- TAANIT_BECHOROT: "Ta'anit Bechorot",
4438
- /** Ta'anit Esther */
4439
- TAANIT_ESTHER: "Ta'anit Esther",
4440
- /** Tish'a B'Av */
4441
- TISHA_BAV: "Tish'a B'Av",
4442
- /** Tzom Gedaliah */
4443
- TZOM_GEDALIAH: 'Tzom Gedaliah',
4444
- /** Tzom Tammuz */
4445
- TZOM_TAMMUZ: 'Tzom Tammuz',
4446
- /** Yom HaAtzma'ut */
4447
- YOM_HAATZMA_UT: "Yom HaAtzma'ut",
4448
- /** Yom HaShoah */
4449
- YOM_HASHOAH: 'Yom HaShoah',
4450
- /** Yom HaZikaron */
4451
- YOM_HAZIKARON: 'Yom HaZikaron',
4452
- /** Ben-Gurion Day */
4453
- BEN_GURION_DAY,
4454
- /** Chanukah: 1 Candle */
4455
- CHANUKAH_1_CANDLE,
4456
- /** Erev Pesach */
4457
- EREV_PESACH,
4458
- /** Erev Purim */
4459
- EREV_PURIM,
4460
- /** Erev Rosh Hashana */
4461
- EREV_ROSH_HASHANA,
4462
- /** Erev Shavuot */
4463
- EREV_SHAVUOT,
4464
- /** Erev Sukkot */
4465
- EREV_SUKKOT,
4466
- /** Erev Yom Kippur */
4467
- EREV_YOM_KIPPUR,
4468
- /** Family Day */
4469
- FAMILY_DAY,
4470
- /** Hebrew Language Day */
4471
- HEBREW_LANGUAGE_DAY,
4472
- /** Herzl Day */
4473
- HERZL_DAY,
4474
- /** Jabotinsky Day */
4475
- JABOTINSKY_DAY,
4476
- /** Lag BaOmer */
4477
- LAG_BAOMER,
4478
- /** Pesach I */
4479
- PESACH_I,
4480
- /** Pesach II */
4481
- PESACH_II,
4482
- /** Pesach III (CH''M) */
4483
- PESACH_III_CHM,
4484
- /** Pesach II (CH''M) */
4485
- PESACH_II_CHM,
4486
- /** Pesach IV (CH''M) */
4487
- PESACH_IV_CHM,
4488
- /** Pesach Sheni */
4489
- PESACH_SHENI,
4490
- /** Pesach VII */
4491
- PESACH_VII,
4492
- /** Pesach VIII */
4493
- PESACH_VIII,
4494
- /** Pesach VI (CH''M) */
4495
- PESACH_VI_CHM,
4496
- /** Pesach V (CH''M) */
4497
- PESACH_V_CHM,
4498
- /** Purim */
4499
- PURIM,
4500
- /** Rosh Hashana II */
4501
- ROSH_HASHANA_II,
4502
- /** Rosh Hashana LaBehemot */
4503
- ROSH_HASHANA_LABEHEMOT,
4504
- /** Shavuot */
4505
- SHAVUOT: SHAVUOT$1,
4506
- /** Shavuot I */
4507
- SHAVUOT_I,
4508
- /** Shavuot II */
4509
- SHAVUOT_II,
4510
- /** Shmini Atzeret */
4511
- SHMINI_ATZERET,
4512
- /** Shushan Purim */
4513
- SHUSHAN_PURIM,
4514
- /** Sigd */
4515
- SIGD,
4516
- /** Simchat Torah */
4517
- SIMCHAT_TORAH,
4518
- /** Sukkot I */
4519
- SUKKOT_I,
4520
- /** Sukkot II */
4521
- SUKKOT_II,
4522
- /** Sukkot III (CH''M) */
4523
- SUKKOT_III_CHM,
4524
- /** Sukkot II (CH''M) */
4525
- SUKKOT_II_CHM,
4526
- /** Sukkot IV (CH''M) */
4527
- SUKKOT_IV_CHM,
4528
- /** Sukkot VII (Hoshana Raba) */
4529
- SUKKOT_VII_HOSHANA_RABA,
4530
- /** Sukkot VI (CH''M) */
4531
- SUKKOT_VI_CHM,
4532
- /** Sukkot V (CH''M) */
4533
- SUKKOT_V_CHM,
4534
- /** Tu B\'Av */
4535
- TU_BAV,
4536
- /** Tu BiShvat */
4537
- TU_BISHVAT,
4538
- /** Yitzhak Rabin Memorial Day */
4539
- YITZHAK_RABIN_MEMORIAL_DAY,
4540
- /** Yom HaAliyah */
4541
- YOM_HAALIYAH,
4542
- /** Yom HaAliyah School Observance */
4543
- YOM_HAALIYAH_SCHOOL_OBSERVANCE,
4544
- /** Yom Kippur */
4545
- YOM_KIPPUR,
4546
- /** Yom Yerushalayim */
4547
- YOM_YERUSHALAYIM,
4548
- };
4549
- const staticHolidays = [
4550
- {
4551
- mm: Tishrei,
4552
- dd: 2,
4553
- desc: ROSH_HASHANA_II,
4554
- flags: CHAG$1 | YOM_TOV_ENDS$1,
4555
- emoji: '🍏🍯',
4556
- },
4557
- { mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$2 | LIGHT_CANDLES$2 },
4558
- {
4559
- mm: Tishrei,
4560
- dd: 10,
4561
- desc: YOM_KIPPUR,
4562
- flags: CHAG$1 | MAJOR_FAST$2 | YOM_TOV_ENDS$1,
4563
- },
4564
- {
4565
- mm: Tishrei,
4566
- dd: 14,
4567
- desc: EREV_SUKKOT,
4568
- flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2,
4569
- emoji: emojiSukkot,
4570
- },
4571
- {
4572
- mm: Tishrei,
4573
- dd: 15,
4574
- desc: SUKKOT_I,
4575
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
4576
- emoji: emojiSukkot,
4577
- },
4578
- {
4579
- mm: Tishrei,
4580
- dd: 16,
4581
- desc: SUKKOT_II,
4582
- flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
4583
- emoji: emojiSukkot,
4584
- },
4585
- {
4586
- mm: Tishrei,
4587
- dd: 17,
4588
- desc: SUKKOT_III_CHM,
4589
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4590
- chmDay: 1,
4591
- emoji: emojiSukkot,
4592
- },
4593
- {
4594
- mm: Tishrei,
4595
- dd: 18,
4596
- desc: SUKKOT_IV_CHM,
4597
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4598
- chmDay: 2,
4599
- emoji: emojiSukkot,
4600
- },
4601
- {
4602
- mm: Tishrei,
4603
- dd: 19,
4604
- desc: SUKKOT_V_CHM,
4605
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4606
- chmDay: 3,
4607
- emoji: emojiSukkot,
4608
- },
4609
- {
4610
- mm: Tishrei,
4611
- dd: 20,
4612
- desc: SUKKOT_VI_CHM,
4613
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4614
- chmDay: 4,
4615
- emoji: emojiSukkot,
4616
- },
4617
- {
4618
- mm: Tishrei,
4619
- dd: 22,
4620
- desc: SHMINI_ATZERET,
4621
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
4622
- },
4623
- {
4624
- mm: Tishrei,
4625
- dd: 23,
4626
- desc: SIMCHAT_TORAH,
4627
- flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
4628
- },
4629
- {
4630
- mm: Tishrei,
4631
- dd: 14,
4632
- desc: EREV_SUKKOT,
4633
- flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2,
4634
- emoji: emojiSukkot,
4635
- },
4636
- {
4637
- mm: Tishrei,
4638
- dd: 15,
4639
- desc: SUKKOT_I,
4640
- flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
4641
- emoji: emojiSukkot,
4642
- },
4643
- {
4644
- mm: Tishrei,
4645
- dd: 16,
4646
- desc: SUKKOT_II_CHM,
4647
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4648
- chmDay: 1,
4649
- emoji: emojiSukkot,
4650
- },
4651
- {
4652
- mm: Tishrei,
4653
- dd: 17,
4654
- desc: SUKKOT_III_CHM,
4655
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4656
- chmDay: 2,
4657
- emoji: emojiSukkot,
4658
- },
4659
- {
4660
- mm: Tishrei,
4661
- dd: 18,
4662
- desc: SUKKOT_IV_CHM,
4663
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4664
- chmDay: 3,
4665
- emoji: emojiSukkot,
4666
- },
4667
- {
4668
- mm: Tishrei,
4669
- dd: 19,
4670
- desc: SUKKOT_V_CHM,
4671
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4672
- chmDay: 4,
4673
- emoji: emojiSukkot,
4674
- },
4675
- {
4676
- mm: Tishrei,
4677
- dd: 20,
4678
- desc: SUKKOT_VI_CHM,
4679
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4680
- chmDay: 5,
4681
- emoji: emojiSukkot,
4682
- },
4683
- {
4684
- mm: Tishrei,
4685
- dd: 22,
4686
- desc: SHMINI_ATZERET,
4687
- flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
4688
- },
4689
- {
4690
- mm: Tishrei,
4691
- dd: 21,
4692
- desc: SUKKOT_VII_HOSHANA_RABA,
4693
- flags: LIGHT_CANDLES$2 | CHOL_HAMOED$1,
4694
- chmDay: -1,
4695
- emoji: emojiSukkot,
4696
- },
4697
- {
4698
- mm: Kislev,
4699
- dd: 24,
4700
- desc: CHANUKAH_1_CANDLE,
4701
- flags: EREV$2 | MINOR_HOLIDAY$2 | CHANUKAH_CANDLES$2,
4702
- emoji: '🕎1️⃣',
4703
- },
4704
- { mm: Shvat, dd: 15, desc: TU_BISHVAT, flags: MINOR_HOLIDAY$2, emoji: '🌳' },
4705
- {
4706
- mm: Adar2,
4707
- dd: 13,
4708
- desc: EREV_PURIM,
4709
- flags: EREV$2 | MINOR_HOLIDAY$2,
4710
- emoji: '🎭️📜',
4711
- },
4712
- { mm: Adar2, dd: 14, desc: PURIM, flags: MINOR_HOLIDAY$2, emoji: '🎭️📜' },
4713
- {
4714
- mm: Adar2,
4715
- dd: 15,
4716
- desc: SHUSHAN_PURIM,
4717
- flags: MINOR_HOLIDAY$2,
4718
- emoji: '🎭️📜',
4719
- },
4720
- // Pesach Israel
4721
- {
4722
- mm: Nisan,
4723
- dd: 14,
4724
- desc: EREV_PESACH,
4725
- flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$2,
4726
- emoji: '🫓🍷',
4727
- },
4728
- {
4729
- mm: Nisan,
4730
- dd: 15,
4731
- desc: PESACH_I,
4732
- flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
4733
- emoji: emojiPesach,
4734
- },
4735
- {
4736
- mm: Nisan,
4737
- dd: 16,
4738
- desc: PESACH_II_CHM,
4739
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4740
- chmDay: 1,
4741
- emoji: emojiPesach,
4742
- },
4743
- {
4744
- mm: Nisan,
4745
- dd: 17,
4746
- desc: PESACH_III_CHM,
4747
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4748
- chmDay: 2,
4749
- emoji: emojiPesach,
4750
- },
4751
- {
4752
- mm: Nisan,
4753
- dd: 18,
4754
- desc: PESACH_IV_CHM,
4755
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4756
- chmDay: 3,
4757
- emoji: emojiPesach,
4758
- },
4759
- {
4760
- mm: Nisan,
4761
- dd: 19,
4762
- desc: PESACH_V_CHM,
4763
- flags: IL_ONLY$2 | CHOL_HAMOED$1,
4764
- chmDay: 4,
4765
- emoji: emojiPesach,
4766
- },
4767
- {
4768
- mm: Nisan,
4769
- dd: 20,
4770
- desc: PESACH_VI_CHM,
4771
- flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$2,
4772
- chmDay: 5,
4773
- emoji: emojiPesach,
4774
- },
4775
- {
4776
- mm: Nisan,
4777
- dd: 21,
4778
- desc: PESACH_VII,
4779
- flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
4780
- emoji: emojiPesach,
4781
- },
4782
- // Pesach chutz l'aretz
4783
- {
4784
- mm: Nisan,
4785
- dd: 14,
4786
- desc: EREV_PESACH,
4787
- flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$2,
4788
- emoji: '🫓🍷',
4789
- },
4790
- {
4791
- mm: Nisan,
4792
- dd: 15,
4793
- desc: PESACH_I,
4794
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
4795
- emoji: '🫓🍷',
4796
- },
4797
- {
4798
- mm: Nisan,
4799
- dd: 16,
4800
- desc: PESACH_II,
4801
- flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
4802
- emoji: emojiPesach,
4803
- },
4804
- {
4805
- mm: Nisan,
4806
- dd: 17,
4807
- desc: PESACH_III_CHM,
4808
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4809
- chmDay: 1,
4810
- emoji: emojiPesach,
4811
- },
4812
- {
4813
- mm: Nisan,
4814
- dd: 18,
4815
- desc: PESACH_IV_CHM,
4816
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4817
- chmDay: 2,
4818
- emoji: emojiPesach,
4819
- },
4820
- {
4821
- mm: Nisan,
4822
- dd: 19,
4823
- desc: PESACH_V_CHM,
4824
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
4825
- chmDay: 3,
4826
- emoji: emojiPesach,
4827
- },
4828
- {
4829
- mm: Nisan,
4830
- dd: 20,
4831
- desc: PESACH_VI_CHM,
4832
- flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$2,
4833
- chmDay: 4,
4834
- emoji: emojiPesach,
4835
- },
4836
- {
4837
- mm: Nisan,
4838
- dd: 21,
4839
- desc: PESACH_VII,
4840
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
4841
- emoji: emojiPesach,
4842
- },
4843
- {
4844
- mm: Nisan,
4845
- dd: 22,
4846
- desc: PESACH_VIII,
4847
- flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
4848
- emoji: emojiPesach,
4849
- },
4850
- { mm: Iyyar, dd: 14, desc: PESACH_SHENI, flags: MINOR_HOLIDAY$2 },
4851
- { mm: Iyyar, dd: 18, desc: LAG_BAOMER, flags: MINOR_HOLIDAY$2, emoji: '🔥' },
4852
- {
4853
- mm: Sivan,
4854
- dd: 5,
4855
- desc: EREV_SHAVUOT,
4856
- flags: EREV$2 | LIGHT_CANDLES$2,
4857
- emoji: '⛰️🌸',
4858
- },
4859
- {
4860
- mm: Sivan,
4861
- dd: 6,
4862
- desc: SHAVUOT$1,
4863
- flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
4864
- emoji: '⛰️🌸',
4865
- },
4866
- {
4867
- mm: Sivan,
4868
- dd: 6,
4869
- desc: SHAVUOT_I,
4870
- flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
4871
- emoji: '⛰️🌸',
4872
- },
4873
- {
4874
- mm: Sivan,
4875
- dd: 7,
4876
- desc: SHAVUOT_II,
4877
- flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
4878
- emoji: '⛰️🌸',
4879
- },
4880
- { mm: Av, dd: 15, desc: TU_BAV, flags: MINOR_HOLIDAY$2, emoji: '❤️' },
4881
- {
4882
- mm: Elul,
4883
- dd: 1,
4884
- desc: ROSH_HASHANA_LABEHEMOT,
4885
- flags: MINOR_HOLIDAY$2,
4886
- emoji: '🐑',
4887
- },
4888
- {
4889
- mm: Elul,
4890
- dd: 29,
4891
- desc: EREV_ROSH_HASHANA,
4892
- flags: EREV$2 | LIGHT_CANDLES$2,
4893
- emoji: '🍏🍯',
4894
- },
4895
- ];
4896
- const staticModernHolidays = [
4897
- { firstYear: 5727, mm: Iyyar, dd: 28, desc: YOM_YERUSHALAYIM, chul: true },
4898
- {
4899
- firstYear: 5737,
4900
- mm: Kislev,
4901
- dd: 6,
4902
- desc: BEN_GURION_DAY,
4903
- satPostponeToSun: true,
4904
- friPostponeToSun: true,
4905
- },
4906
- { firstYear: 5750, mm: Shvat, dd: 30, desc: FAMILY_DAY },
4907
- {
4908
- firstYear: 5758,
4909
- mm: Cheshvan,
4910
- dd: 12,
4911
- desc: YITZHAK_RABIN_MEMORIAL_DAY,
4912
- friSatMovetoThu: true,
4913
- },
4914
- { firstYear: 5764, mm: Iyyar, dd: 10, desc: HERZL_DAY, satPostponeToSun: true },
4915
- {
4916
- firstYear: 5765,
4917
- mm: Tamuz,
4918
- dd: 29,
4919
- desc: JABOTINSKY_DAY,
4920
- satPostponeToSun: true,
4921
- },
4922
- {
4923
- firstYear: 5769,
4924
- mm: Cheshvan,
4925
- dd: 29,
4926
- desc: SIGD,
4927
- chul: true,
4928
- suppressEmoji: true,
4929
- friSatMovetoThu: true,
4930
- },
4931
- { firstYear: 5777, mm: Nisan, dd: 10, desc: YOM_HAALIYAH, chul: true },
4932
- { firstYear: 5777, mm: Cheshvan, dd: 7, desc: YOM_HAALIYAH_SCHOOL_OBSERVANCE },
4933
- // https://www.gov.il/he/departments/policies/2012_des5234
4934
- {
4935
- firstYear: 5773,
4936
- mm: months.TEVET,
4937
- dd: 21,
4938
- desc: HEBREW_LANGUAGE_DAY,
4939
- friSatMovetoThu: true,
4940
- },
4941
- ];
4942
-
4943
- /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
4944
- class HolidayEvent extends Event {
4945
- basename() {
4946
- return this.getDesc()
4947
- .replace(/ \d{4}$/, '')
4948
- .replace(/ \(CH''M\)$/, '')
4949
- .replace(/ \(observed\)$/, '')
4950
- .replace(/ \(Hoshana Raba\)$/, '')
4951
- .replace(/ [IV]+$/, '')
4952
- .replace(/: \d Candles?$/, '')
4953
- .replace(/: 8th Day$/, '')
4954
- .replace(/^Erev /, '');
4955
- }
4956
- url() {
4957
- const year = this.getDate().greg().getFullYear();
4958
- if (year < 100) {
4959
- return undefined;
4960
- }
4961
- const url = 'https://www.hebcal.com/holidays/' +
4962
- this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
4963
- '-' +
4964
- this.urlDateSuffix();
4965
- return this.getFlags() & flags.IL_ONLY ? url + '?i=on' : url;
4966
- }
4967
- urlDateSuffix() {
4968
- const year = this.getDate().greg().getFullYear();
4969
- return String(year);
4970
- }
4971
- getEmoji() {
4972
- if (this.emoji) {
4973
- return this.emoji;
4974
- }
4975
- else if (this.getFlags() & flags.SPECIAL_SHABBAT) {
4976
- return '🕍';
4977
- }
4978
- else {
4979
- return '✡️';
4980
- }
4981
- }
4982
- getCategories() {
4983
- if (this.cholHaMoedDay) {
4984
- return ['holiday', 'major', 'cholhamoed'];
4985
- }
4986
- const cats = super.getCategories();
4987
- if (cats[0] !== 'unknown') {
4988
- return cats;
4989
- }
4990
- // Don't depend on flags.MINOR_HOLIDAY always being set. Look for minor holidays.
4991
- const desc = this.getDesc();
4992
- switch (desc) {
4993
- case holidayDesc.LAG_BAOMER:
4994
- case holidayDesc.LEIL_SELICHOT:
4995
- case holidayDesc.PESACH_SHENI:
4996
- case holidayDesc.EREV_PURIM:
4997
- case holidayDesc.PURIM_KATAN:
4998
- case holidayDesc.SHUSHAN_PURIM:
4999
- case holidayDesc.TU_BAV:
5000
- case holidayDesc.TU_BISHVAT:
5001
- case holidayDesc.ROSH_HASHANA_LABEHEMOT:
5002
- return ['holiday', 'minor'];
5003
- }
5004
- return ['holiday', 'major'];
5005
- }
5006
- /**
5007
- * Returns (translated) description of this event
5008
- * @param [locale] Optional locale name (defaults to active locale).
5009
- */
5010
- render(locale) {
5011
- const str = super.render(locale);
5012
- return str.replace(/'/g, '’');
5013
- }
5014
- /**
5015
- * Returns a brief (translated) description of this event.
5016
- * For most events, this is the same as render(). For some events, it procudes
5017
- * a shorter text (e.g. without a time or added description).
5018
- * @param [locale] Optional locale name (defaults to active locale).
5019
- */
5020
- renderBrief(locale) {
5021
- const str = super.renderBrief(locale);
5022
- return str.replace(/'/g, '’');
5023
- }
5024
- /**
5025
- * Makes a clone of this Event object
5026
- * @deprecated
5027
- */
5028
- clone() {
5029
- const ev = new HolidayEvent(this.date, this.desc, this.mask);
5030
- // overwrite all enumerable properties
5031
- Object.assign(ev, this);
5032
- return ev;
5033
- }
5034
- }
5035
- /**
5036
- * Because Asara B'Tevet often occurs twice in the same Gregorian year,
5037
- * we subclass HolidayEvent to generate the correct URL.
5038
- */
5039
- class AsaraBTevetEvent extends HolidayEvent {
5040
- urlDateSuffix() {
5041
- const isoDate = isoDateString(this.getDate().greg());
5042
- return isoDate.replace(/-/g, '');
5043
- }
5044
- }
5045
- /**
5046
- * Because Chanukah sometimes starts in December and ends in January,
5047
- * we subclass HolidayEvent to generate the correct URL.
5048
- */
5049
- class ChanukahEvent extends HolidayEvent {
5050
- urlDateSuffix() {
5051
- const dt = this.getDate().greg();
5052
- let year = dt.getFullYear();
5053
- if (dt.getMonth() === 0) {
5054
- year--;
5055
- }
5056
- return String(year);
5057
- }
5058
- }
5059
- /** Represents Rosh Hashana, the Jewish New Year */
5060
- class RoshHashanaEvent extends HolidayEvent {
5061
- /**
5062
- * @private
5063
- * @param date Hebrew date event occurs
5064
- * @param hyear Hebrew year
5065
- * @param mask optional holiday flags
5066
- */
5067
- constructor(date, hyear, mask) {
5068
- super(date, `Rosh Hashana ${hyear}`, mask);
5069
- this.hyear = hyear;
5070
- }
5071
- /**
5072
- * Returns (translated) description of this event
5073
- * @param [locale] Optional locale name (defaults to active locale).
5074
- */
5075
- render(locale) {
5076
- return Locale.gettext('Rosh Hashana', locale) + ' ' + this.hyear;
5077
- }
5078
- getEmoji() {
5079
- return '🍏🍯';
5080
- }
5081
- }
5082
- const roshChodeshStr = 'Rosh Chodesh';
5083
- /** Represents Rosh Chodesh, the beginning of a new month */
5084
- class RoshChodeshEvent extends HolidayEvent {
5085
- /**
5086
- * Constructs Rosh Chodesh event
5087
- * @param date Hebrew date event occurs
5088
- * @param monthName Hebrew month name (not translated)
5089
- */
5090
- constructor(date, monthName) {
5091
- super(date, `${roshChodeshStr} ${monthName}`, flags.ROSH_CHODESH);
5092
- }
5093
- /**
5094
- * Returns (translated) description of this event
5095
- * @param [locale] Optional locale name (defaults to active locale).
5096
- */
5097
- render(locale) {
5098
- const monthName = this.getDesc().substring(roshChodeshStr.length + 1);
5099
- const monthName0 = Locale.gettext(monthName, locale);
5100
- const monthName1 = monthName0.replace(/'/g, '’');
5101
- return Locale.gettext(roshChodeshStr, locale) + ' ' + monthName1;
5102
- }
5103
- basename() {
5104
- return this.getDesc();
5105
- }
5106
- getEmoji() {
5107
- return this.emoji || '🌒';
5108
- }
5109
- }
5110
-
5111
- /* eslint-disable max-len */
5112
- const LIGHT_CANDLES$1 = flags.LIGHT_CANDLES;
5113
- const LIGHT_CANDLES_TZEIS$2 = flags.LIGHT_CANDLES_TZEIS;
5114
- /**
5115
- * @private
5116
- */
5117
- function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
5118
- let havdalahTitle = false;
5119
- let useHavdalahOffset = isSaturday;
5120
- let mask = ev ? ev.getFlags() : LIGHT_CANDLES$1;
5121
- if (typeof ev !== 'undefined') {
5122
- // if linked event && dow == FRI, use Candle lighting time & title
5123
- if (!isFriday) {
5124
- if (mask & (LIGHT_CANDLES_TZEIS$2 | flags.CHANUKAH_CANDLES)) {
5125
- useHavdalahOffset = true;
5126
- }
5127
- else if (mask & flags.YOM_TOV_ENDS) {
5128
- havdalahTitle = true;
5129
- useHavdalahOffset = true;
5130
- }
5131
- }
5132
- }
5133
- else if (isSaturday) {
5134
- havdalahTitle = true;
5135
- mask = LIGHT_CANDLES_TZEIS$2;
5136
- }
5137
- // if Havdalah offset is 0 or undefined, we'll use tzeit time
5138
- const offset = useHavdalahOffset
5139
- ? Number(options.havdalahMins)
5140
- : Number(options.candleLightingMins);
5141
- const location = options.location;
5142
- const useElevation = Boolean(options.useElevation);
5143
- const zmanim = new Zmanim(location, hd, useElevation);
5144
- const time = useHavdalahOffset && !offset
5145
- ? zmanim.tzeit(options.havdalahDeg)
5146
- : zmanim.sunsetOffset(offset, true);
5147
- if (isNaN(time.getTime())) {
5148
- return undefined; // no sunset
5149
- }
5150
- if (havdalahTitle) {
5151
- return new HavdalahEvent(hd, mask, time, location, options.havdalahMins, ev, options);
5152
- }
5153
- else {
5154
- mask |= LIGHT_CANDLES$1;
5155
- return new CandleLightingEvent(hd, mask, time, location, ev, options);
5156
- }
5157
- }
5158
- const FAST_BEGINS = 'Fast begins';
5159
- const FAST_ENDS = 'Fast ends';
5160
- /** A fast day also contains a start and end time */
5161
- class FastDayEvent extends HolidayEvent {
5162
- constructor(linkedEvent, startEvent, endEvent) {
5163
- super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.getFlags());
5164
- this.linkedEvent = linkedEvent;
5165
- this.startEvent = startEvent;
5166
- this.endEvent = endEvent;
5167
- }
5168
- render(locale) {
5169
- return this.linkedEvent.render(locale);
5170
- }
5171
- renderBrief(locale) {
5172
- return this.linkedEvent.renderBrief(locale);
5173
- }
5174
- urlDateSuffix() {
5175
- return this.linkedEvent.urlDateSuffix();
5176
- }
5177
- url() {
5178
- return this.linkedEvent.url();
5179
- }
5180
- getEmoji() {
5181
- return this.linkedEvent.getEmoji();
5182
- }
5183
- getCategories() {
5184
- return this.linkedEvent.getCategories();
5185
- }
5186
- }
5187
- /**
5188
- * Makes a pair of events representing fast start and end times
5189
- * @private
5190
- */
5191
- function makeFastStartEnd(ev, options) {
5192
- const desc = ev.getDesc();
5193
- if (desc === 'Yom Kippur') {
5194
- throw new RangeError('YK does not require this function');
5195
- }
5196
- const hd = ev.getDate();
5197
- const dt = hd.greg();
5198
- const location = options.location;
5199
- const fastEndDeg = options.fastEndDeg;
5200
- const useElevation = Boolean(options.useElevation);
5201
- const zmanim = new Zmanim(location, dt, useElevation);
5202
- let startEvent;
5203
- let endEvent;
5204
- if (desc === "Erev Tish'a B'Av") {
5205
- const sunset = zmanim.sunset();
5206
- if (!isNaN(sunset.getTime())) {
5207
- startEvent = makeTimedEvent(ev, sunset, FAST_BEGINS, options);
5208
- }
5209
- }
5210
- else if (desc.startsWith("Tish'a B'Av")) {
5211
- const tzeit = zmanim.tzeit(fastEndDeg);
5212
- if (!isNaN(tzeit.getTime())) {
5213
- endEvent = makeTimedEvent(ev, tzeit, FAST_ENDS, options);
5214
- }
5215
- }
5216
- else {
5217
- const dawn = zmanim.alotHaShachar();
5218
- if (!isNaN(dawn.getTime())) {
5219
- startEvent = makeTimedEvent(ev, dawn, FAST_BEGINS, options);
5220
- }
5221
- if (dt.getDay() !== 5 &&
5222
- !(hd.getDate() === 14 && hd.getMonth() === months.NISAN)) {
5223
- const tzeit = zmanim.tzeit(fastEndDeg);
5224
- if (!isNaN(tzeit.getTime())) {
5225
- endEvent = makeTimedEvent(ev, tzeit, FAST_ENDS, options);
5226
- }
5227
- }
5228
- }
5229
- const ev2 = new FastDayEvent(ev, startEvent, endEvent);
5230
- // copy properties such as memo or emoji
5231
- Object.assign(ev2, ev);
5232
- return ev2;
5233
- }
5234
- /**
5235
- * @private
5236
- */
5237
- function makeTimedEvent(ev, time, desc, options) {
5238
- const location = options.location;
5239
- const hd = ev.getDate();
5240
- return new TimedEvent(hd, desc, ev.getFlags(), time, location, ev, options);
5241
- }
5242
- class TimedChanukahEvent extends ChanukahEvent {
5243
- constructor(date, desc, mask, eventTime, location) {
5244
- super(date, desc, mask);
5245
- this.eventTime = Zmanim.roundTime(eventTime);
5246
- const timeFormat = location.getTimeFormatter();
5247
- this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
5248
- this.location = location;
5249
- }
5250
- }
5251
- /**
5252
- * Makes a candle-lighting event for Chankah (not on Friday/Saturday).
5253
- * At one point this used civil dusk (6 degrees below horizon).
5254
- * Another source suggests 4.6667 degrees below horizon.
5255
- * @private
5256
- */
5257
- function makeWeekdayChanukahCandleLighting(ev, hd, options) {
5258
- const location = options.location;
5259
- const useElevation = Boolean(options.useElevation);
5260
- const zmanim = new Zmanim(location, hd.greg(), useElevation);
5261
- const candleLightingTime = zmanim.beinHaShmashos();
5262
- if (isNaN(candleLightingTime.getTime())) {
5263
- return null;
5264
- }
5265
- const ev2 = new TimedChanukahEvent(hd, ev.getDesc(), ev.getFlags(), candleLightingTime, location);
5266
- ev2.emoji = ev.emoji;
5267
- ev2.chanukahDay = ev.chanukahDay;
5268
- return ev2;
5269
- }
5270
-
5271
- /* eslint-disable camelcase */
5272
- const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
5273
- const heDayNames = [
5274
- 'רִאשׁוֹן',
5275
- 'שֵׁנִי',
5276
- 'שְׁלִישִׁי',
5277
- 'רְבִיעִי',
5278
- 'חֲמִישִׁי',
5279
- 'שִׁישִּׁי',
5280
- 'שַׁבָּת',
5281
- ];
5282
- const frDayNames = ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'];
5283
- const night = 'בַּלַּ֥יְלָה';
5284
- function getHebrewTimeOfDay(hour) {
5285
- if (hour < 5)
5286
- return night;
5287
- else if (hour < 12)
5288
- return 'בַּבֹּקֶר';
5289
- else if (hour < 17)
5290
- return 'בַּצׇּהֳרַיִים';
5291
- else if (hour < 21)
5292
- return 'בָּעֶרֶב';
5293
- return night;
5294
- }
5295
- /**
5296
- * Represents a molad, the moment when the new moon is "born"
5297
- */
5298
- class Molad {
5299
- /**
5300
- * Calculates the molad for a Hebrew month
5301
- * @param year
5302
- * @param month
5303
- */
5304
- constructor(year, month) {
5305
- this.m = molad(year, month);
5306
- }
5307
- /**
5308
- */
5309
- getYear() {
5310
- return this.m.year;
5311
- }
5312
- /**
5313
- */
5314
- getMonth() {
5315
- return this.m.month;
5316
- }
5317
- /**
5318
- */
5319
- getMonthName() {
5320
- return HDate.getMonthName(this.m.month, this.m.year);
5321
- }
5322
- /**
5323
- * @returns Day of Week (0=Sunday, 6=Saturday)
5324
- */
5325
- getDow() {
5326
- return this.m.dayOfWeek;
5327
- }
5328
- /**
5329
- * @returns hour of day (0-23)
5330
- */
5331
- getHour() {
5332
- return this.m.hour;
5333
- }
5334
- /**
5335
- * @returns minutes past hour (0-59)
5336
- */
5337
- getMinutes() {
5338
- return this.m.minutes;
5339
- }
5340
- /**
5341
- * @returns parts of a minute (0-17)
5342
- */
5343
- getChalakim() {
5344
- return this.m.chalakim;
5345
- }
5346
- /**
5347
- * @param [locale] Optional locale name (defaults to active locale)
5348
- * @param options
5349
- */
5350
- render(locale, options) {
5351
- var _a;
5352
- locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
5353
- if (typeof locale === 'string') {
5354
- locale = locale.toLowerCase();
5355
- }
5356
- const isHebrewLocale = locale === 'he' || locale === 'he-x-nonikud' || locale === 'h';
5357
- const isFrenchLocale = locale === 'fr';
5358
- const monthName = Locale.gettext(this.getMonthName(), locale);
5359
- const dayNames = isHebrewLocale ? heDayNames : (isFrenchLocale ? frDayNames : shortDayNames);
5360
- const dow = dayNames[this.getDow()];
5361
- const minutes = this.getMinutes();
5362
- const hour = this.getHour();
5363
- const chalakim = this.getChalakim();
5364
- const moladStr = Locale.gettext('Molad', locale);
5365
- const minutesStr = (_a = Locale.lookupTranslation('min', locale)) !== null && _a !== void 0 ? _a : 'minutes';
5366
- const chalakimStr = Locale.gettext('chalakim', locale);
5367
- const and = Locale.gettext('and', locale);
5368
- const after = Locale.gettext('after', locale);
5369
- if (isHebrewLocale) {
5370
- const ampm = getHebrewTimeOfDay(hour);
5371
- const result = `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` +
5372
- `בְּשָׁעָה ${hour} ${ampm}, ` +
5373
- `ו-${minutes} ${minutesStr} ` +
5374
- `ו-${chalakim} ${chalakimStr}`;
5375
- if (locale === 'he-x-nonikud') {
5376
- return Locale.hebrewStripNikkud(result);
5377
- }
5378
- return result;
5379
- }
5380
- const fmtTime = reformatTimeStr(`${hour}:00`, 'pm', options);
5381
- const month = monthName.replace(/'/g, '’');
5382
- return `${moladStr} ${month}: ${dow}, ${minutes} ${minutesStr} ${and} ${chalakim} ${chalakimStr} ${after} ${fmtTime}`;
5383
- }
5384
- }
5385
- /** Represents a Molad announcement on Shabbat Mevarchim */
5386
- class MoladEvent extends Event {
5387
- /**
5388
- * @param date Hebrew date event occurs
5389
- * @param hyear molad year
5390
- * @param hmonth molad month
5391
- * @param options
5392
- */
5393
- constructor(date, hyear, hmonth, options) {
5394
- const m = new Molad(hyear, hmonth);
5395
- const monthName = m.getMonthName();
5396
- super(date, `Molad ${monthName} ${hyear}`, flags.MOLAD);
5397
- this.molad = m;
5398
- this.options = options;
5399
- }
5400
- /**
5401
- * @param [locale] Optional locale name (defaults to active locale).
5402
- */
5403
- render(locale) {
5404
- return this.molad.render(locale, this.options);
5405
- }
5406
- }
5407
-
5408
- const sefirot = {
5409
- en: {
5410
- infix: 'within ',
5411
- infix26: 'within ',
5412
- words: [
5413
- '',
5414
- 'Lovingkindness',
5415
- 'Might',
5416
- 'Beauty',
5417
- 'Eternity',
5418
- 'Splendor',
5419
- 'Foundation',
5420
- 'Majesty',
5421
- ],
5422
- pfxWords: null,
5423
- },
5424
- he: {
5425
- infix: null,
5426
- infix26: null,
5427
- words: [
5428
- '',
5429
- 'חֶֽסֶד',
5430
- 'גְּבוּרָה',
5431
- 'תִּפְאֶֽרֶת',
5432
- 'נֶּֽצַח',
5433
- 'הוֹד',
5434
- 'יְּסוֹד',
5435
- 'מַלְכוּת',
5436
- ],
5437
- pfxWords: [
5438
- '',
5439
- 'שֶׁבְּחֶֽסֶד',
5440
- 'שֶׁבִּגְבוּרָה',
5441
- 'שֶׁבְּתִפְאֶֽרֶת',
5442
- 'שֶׁבְּנֶֽצַח',
5443
- 'שֶׁבְּהוֹד',
5444
- 'שֶׁבִּיְסוֹד',
5445
- 'שֶׁבְּמַלְכוּת',
5446
- ],
5447
- },
5448
- translit: {
5449
- infix: "sheb'",
5450
- infix26: 'shebi',
5451
- words: [
5452
- '',
5453
- 'Chesed',
5454
- 'Gevurah',
5455
- 'Tiferet',
5456
- 'Netzach',
5457
- 'Hod',
5458
- 'Yesod',
5459
- 'Malkhut',
5460
- ],
5461
- pfxWords: null,
5462
- },
5463
- };
5464
- function checkDay(omerDay) {
5465
- if (omerDay < 1 || omerDay > 49) {
5466
- throw new RangeError(`Invalid Omer day ${omerDay}`);
5467
- }
5468
- }
5469
- function getWeeks(omerDay) {
5470
- const weekNum = Math.floor((omerDay - 1) / 7) + 1;
5471
- const daysWithinWeeks = omerDay % 7 || 7;
5472
- return [weekNum, daysWithinWeeks];
5473
- }
5474
- function omerTodayIsEn(omerDay) {
5475
- const [weekNumber, daysWithinWeeks] = getWeeks(omerDay);
5476
- const totalDaysStr = omerDay === 1 ? 'day' : 'days';
5477
- let str = `Today is ${omerDay} ${totalDaysStr}`;
5478
- if (weekNumber > 1 || omerDay === 7) {
5479
- const day7 = daysWithinWeeks === 7;
5480
- const numWeeks = day7 ? weekNumber : weekNumber - 1;
5481
- const weeksStr = numWeeks === 1 ? 'week' : 'weeks';
5482
- str += `, which is ${numWeeks} ${weeksStr}`;
5483
- if (!day7) {
5484
- const daysStr = daysWithinWeeks === 1 ? 'day' : 'days';
5485
- str += ` and ${daysWithinWeeks} ${daysStr}`;
5486
- }
5487
- }
5488
- return str + ' of the Omer';
5489
- }
5490
- // adapted from pip hdate package (GPL)
5491
- // https://github.com/py-libhdate/py-libhdate/blob/master/hdate/date.py
5492
- const tens = ['', 'עֲשָׂרָה', 'עֶשְׂרִים', 'שְׁלוֹשִׁים', 'אַרְבָּעִים'];
5493
- const ones = [
5494
- '',
5495
- 'אֶחָד',
5496
- 'שְׁנַיִם',
5497
- 'שְׁלוֹשָׁה',
5498
- 'אַרְבָּעָה',
5499
- 'חֲמִשָּׁה',
5500
- 'שִׁשָּׁה',
5501
- 'שִׁבְעָה',
5502
- 'שְׁמוֹנָה',
5503
- 'תִּשְׁעָה',
5504
- ];
5505
- const shnei = 'שְׁנֵי';
5506
- const yamim = 'יָמִים';
5507
- const shneiYamim = shnei + ' ' + yamim;
5508
- const shavuot = 'שָׁבוּעוֹת';
5509
- const yom = 'יוֹם';
5510
- const yomEchad = yom + ' ' + ones[1];
5511
- const asar = 'עָשָׂר';
5512
- function omerTodayIsHe(omerDay) {
5513
- const ten = Math.floor(omerDay / 10);
5514
- const one = omerDay % 10;
5515
- let str = 'הַיּוֹם ';
5516
- if (omerDay === 11) {
5517
- str += 'אַחַד ' + asar;
5518
- }
5519
- else if (omerDay === 12) {
5520
- str += 'שְׁנֵים ' + asar;
5521
- }
5522
- else if (12 < omerDay && omerDay < 20) {
5523
- str += ones[one] + ' ' + asar;
5524
- }
5525
- else if (omerDay > 9) {
5526
- str += ones[one];
5527
- if (one) {
5528
- str += ' ';
5529
- str += ten === 3 ? 'וּ' : 'וְ';
5530
- }
5531
- }
5532
- if (omerDay > 2) {
5533
- if (omerDay > 20 || omerDay === 10 || omerDay === 20) {
5534
- str += tens[ten];
5535
- }
5536
- if (omerDay < 11) {
5537
- str += ones[one] + ' ' + yamim + ' ';
5538
- }
5539
- else {
5540
- str += ' ' + yom + ' ';
5541
- }
5542
- }
5543
- else if (omerDay === 1) {
5544
- str += yomEchad + ' ';
5545
- }
5546
- else {
5547
- // omer == 2
5548
- str += shneiYamim + ' ';
5549
- }
5550
- if (omerDay > 6) {
5551
- str = str.trim(); // remove trailing space before comma
5552
- str += ', שֶׁהֵם ';
5553
- const weeks = Math.floor(omerDay / 7);
5554
- const days = omerDay % 7;
5555
- if (weeks > 2) {
5556
- str += ones[weeks] + ' ' + shavuot + ' ';
5557
- }
5558
- else if (weeks === 1) {
5559
- str += 'שָׁבֽוּעַ' + ' ' + ones[1] + ' ';
5560
- }
5561
- else {
5562
- // weeks == 2
5563
- str += shnei + ' ' + shavuot + ' ';
5564
- }
5565
- if (days) {
5566
- if (days === 2 || days === 3) {
5567
- str += 'וּ';
5568
- }
5569
- else if (days === 5) {
5570
- str += 'וַ';
5571
- }
5572
- else {
5573
- str += 'וְ';
5574
- }
5575
- if (days > 2) {
5576
- str += ones[days] + ' ' + yamim + ' ';
5577
- }
5578
- else if (days === 1) {
5579
- str += yomEchad + ' ';
5580
- }
5581
- else {
5582
- // days == 2
5583
- str += shneiYamim + ' ';
5584
- }
5585
- }
5586
- }
5587
- str += 'לָעֽוֹמֶר';
5588
- return str.normalize();
5589
- }
5590
- /** Represents a day 1-49 of counting the Omer from Pesach to Shavuot */
5591
- class OmerEvent extends Event {
5592
- /**
5593
- * @param date
5594
- * @param omerDay
5595
- */
5596
- constructor(date, omerDay) {
5597
- super(date, `Omer ${omerDay}`, flags.OMER_COUNT);
5598
- checkDay(omerDay);
5599
- this.weekNumber = Math.floor((omerDay - 1) / 7) + 1;
5600
- this.daysWithinWeeks = omerDay % 7 || 7;
5601
- this.omer = omerDay;
5602
- }
5603
- /**
5604
- * Returns the sefira. For example, on day 8:
5605
- * * חֶֽסֶד שֶׁבִּגְבוּרָה
5606
- * * Chesed shebiGevurah
5607
- * * Lovingkindness within Might
5608
- * @param lang `en` (English), `he` (Hebrew with nikud), or `translit` (Hebrew in Sephardic transliteration)
5609
- * @returns a string such as `Lovingkindness within Might` or `חֶֽסֶד שֶׁבִּגְבוּרָה`
5610
- */
5611
- sefira(lang = 'en') {
5612
- if (lang !== 'he' && lang !== 'translit') {
5613
- lang = 'en';
5614
- }
5615
- const [weekNum, daysWithinWeeks] = getWeeks(this.omer);
5616
- const config = sefirot[lang];
5617
- const pfxWords = config.pfxWords;
5618
- const words = config.words;
5619
- const week = pfxWords ? pfxWords[weekNum] : words[weekNum];
5620
- const dayWithinWeek = words[daysWithinWeeks];
5621
- const infix = pfxWords
5622
- ? ''
5623
- : weekNum === 2 || weekNum === 6
5624
- ? config.infix26
5625
- : config.infix;
5626
- return (dayWithinWeek + ' ' + infix + week).normalize();
5627
- }
5628
- /**
5629
- * @param [locale] Optional locale name (defaults to active locale).
5630
- */
5631
- render(locale) {
5632
- locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
5633
- if (typeof locale === 'string') {
5634
- locale = locale.toLowerCase();
5635
- }
5636
- const isHebrewLocale = locale === 'he' || locale === 'he-x-nonikud' || locale === 'h';
5637
- const omer = this.omer;
5638
- const nth = isHebrewLocale ? gematriya(omer) : Locale.ordinal(omer, locale);
5639
- return nth + ' ' + Locale.gettext('day of the Omer', locale);
5640
- }
5641
- /**
5642
- * Returns translation of "Omer day 22" without ordinal numbers.
5643
- * @param [locale] Optional locale name (defaults to active locale).
5644
- */
5645
- renderBrief(locale) {
5646
- return (Locale.gettext('Omer', locale) +
5647
- ' ' +
5648
- Locale.gettext('day', locale) +
5649
- ' ' +
5650
- this.omer);
5651
- }
5652
- /**
5653
- * Returns an emoji number symbol with a circle, for example `㊲`
5654
- * from the “Enclosed CJK Letters and Months” block of the Unicode standard
5655
- * @param omerDay the day of the omer, 1-49 inclusive
5656
- * @returns a single Unicode character from `①` through `㊾`
5657
- */
5658
- getEmoji() {
5659
- if (typeof this.emoji === 'string')
5660
- return this.emoji;
5661
- let codePoint;
5662
- const omerDay = this.omer;
5663
- if (omerDay <= 20) {
5664
- codePoint = 9312 + omerDay - 1;
5665
- }
5666
- else if (omerDay <= 35) {
5667
- // between 21 and 35 inclusive
5668
- codePoint = 12881 + omerDay - 21;
5669
- }
5670
- else {
5671
- // between 36 and 49 inclusive
5672
- codePoint = 12977 + omerDay - 36;
5673
- }
5674
- return String.fromCodePoint(codePoint);
5675
- }
5676
- getWeeks() {
5677
- const day7 = this.daysWithinWeeks === 7;
5678
- return day7 ? this.weekNumber : this.weekNumber - 1;
5679
- }
5680
- getDaysWithinWeeks() {
5681
- return this.daysWithinWeeks;
5682
- }
5683
- /**
5684
- * Returns a sentence with that evening's omer count
5685
- * @returns a string such as `Today is 10 days, which is 1 week and 3 days of the Omer`
5686
- * or `הַיוֹם עֲשָׂרָה יָמִים, שְׁהֵם שָׁבוּעַ אֶחָד וְשְׁלוֹשָׁה יָמִים לָעוֹמֶר`
5687
- */
5688
- getTodayIs(locale) {
5689
- locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
5690
- if (typeof locale === 'string') {
5691
- locale = locale.toLowerCase();
5692
- }
5693
- const isHebrew = locale === 'he' || locale === 'he-x-nonikud';
5694
- const str = isHebrew ? omerTodayIsHe(this.omer) : omerTodayIsEn(this.omer);
5695
- if (locale === 'he-x-nonikud') {
5696
- return Locale.hebrewStripNikkud(str);
5697
- }
5698
- return str;
5699
- }
5700
- url() {
5701
- return `https://www.hebcal.com/omer/${this.getDate().getFullYear()}/${this.omer}`;
5702
- }
5703
- }
5704
-
5705
- /** @private */
5706
- function renderParshaName(parsha, locale) {
5707
- const locale0 = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
5708
- let name = Locale.gettext(parsha[0], locale0);
5709
- if (parsha.length === 2) {
5710
- const hyphen = locale0 === 'he' ? '־' : '-';
5711
- name += hyphen + Locale.gettext(parsha[1], locale0);
5712
- }
5713
- name = name.replace(/'/g, '’');
5714
- const str = Locale.gettext('Parashat', locale) + ' ' + name;
5715
- return str.normalize();
5716
- }
5717
-
5718
- class QuickLRU extends Map {
5719
- constructor(options = {}) {
5720
- super();
5721
-
5722
- if (!(options.maxSize && options.maxSize > 0)) {
5723
- throw new TypeError('`maxSize` must be a number greater than 0');
5724
- }
4189
+ if (!(options.maxSize && options.maxSize > 0)) {
4190
+ throw new TypeError('`maxSize` must be a number greater than 0');
4191
+ }
5725
4192
 
5726
4193
  if (typeof options.maxAge === 'number' && options.maxAge === 0) {
5727
4194
  throw new TypeError('`maxAge` must be a number greater than 0');
@@ -5981,22 +4448,1406 @@ class QuickLRU extends Map {
5981
4448
  }
5982
4449
  }
5983
4450
 
5984
- return Math.min(this._size + oldCacheSize, this.maxSize);
5985
- }
4451
+ return Math.min(this._size + oldCacheSize, this.maxSize);
4452
+ }
4453
+
4454
+ entries() {
4455
+ return this.entriesAscending();
4456
+ }
4457
+
4458
+ forEach(callbackFunction, thisArgument = this) {
4459
+ for (const [key, value] of this.entriesAscending()) {
4460
+ callbackFunction.call(thisArgument, value, key, this);
4461
+ }
4462
+ }
4463
+
4464
+ get [Symbol.toStringTag]() {
4465
+ return JSON.stringify([...this.entriesAscending()]);
4466
+ }
4467
+ }
4468
+
4469
+ const SUN$1 = 0;
4470
+ const TUE$1 = 2;
4471
+ const FRI$2 = 5;
4472
+ const SAT$2 = 6;
4473
+ const NISAN$2 = months.NISAN;
4474
+ const IYYAR = months.IYYAR;
4475
+ /**
4476
+ * Yom HaShoah first observed in 1951.
4477
+ * When the actual date of Yom Hashoah falls on a Friday, the
4478
+ * state of Israel observes Yom Hashoah on the preceding
4479
+ * Thursday. When it falls on a Sunday, Yom Hashoah is observed
4480
+ * on the following Monday.
4481
+ * http://www.ushmm.org/remembrance/dor/calendar/
4482
+ * @private
4483
+ * @param year
4484
+ */
4485
+ function dateYomHaShoah(year) {
4486
+ if (year < 5711) {
4487
+ return null;
4488
+ }
4489
+ let nisan27dt = new HDate(27, NISAN$2, year);
4490
+ if (nisan27dt.getDay() === FRI$2) {
4491
+ nisan27dt = new HDate(26, NISAN$2, year);
4492
+ }
4493
+ else if (nisan27dt.getDay() === SUN$1) {
4494
+ nisan27dt = new HDate(28, NISAN$2, year);
4495
+ }
4496
+ return nisan27dt;
4497
+ }
4498
+ /**
4499
+ * Yom HaAtzma'ut only celebrated after 1948
4500
+ * @private
4501
+ * @param year
4502
+ */
4503
+ function dateYomHaZikaron(year) {
4504
+ if (year < 5708) {
4505
+ return null;
4506
+ }
4507
+ let day;
4508
+ const pesach = new HDate(15, NISAN$2, year);
4509
+ const pdow = pesach.getDay();
4510
+ if (pdow === SUN$1) {
4511
+ day = 2;
4512
+ }
4513
+ else if (pdow === SAT$2) {
4514
+ day = 3;
4515
+ }
4516
+ else if (year < 5764) {
4517
+ day = 4;
4518
+ }
4519
+ else if (pdow === TUE$1) {
4520
+ day = 5;
4521
+ }
4522
+ else {
4523
+ day = 4;
4524
+ }
4525
+ return new HDate(day, IYYAR, year);
4526
+ }
4527
+
4528
+ /** @private */
4529
+ function renderParshaName(parsha, locale) {
4530
+ const locale0 = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
4531
+ let name = Locale.gettext(parsha[0], locale0);
4532
+ if (parsha.length === 2) {
4533
+ const hyphen = locale0 === 'he' ? '־' : '-';
4534
+ name += hyphen + Locale.gettext(parsha[1], locale0);
4535
+ }
4536
+ name = name.replace(/'/g, '’');
4537
+ const str = Locale.gettext('Parashat', locale) + ' ' + name;
4538
+ return str.normalize();
4539
+ }
4540
+
4541
+ /*
4542
+ Hebcal - A Jewish Calendar Generator
4543
+ Copyright (c) 1994-2020 Danny Sadinoff
4544
+ Portions copyright Eyal Schachter and Michael J. Radwin
4545
+
4546
+ https://github.com/hebcal/hebcal-es6
4547
+
4548
+ This program is free software; you can redistribute it and/or
4549
+ modify it under the terms of the GNU General Public License
4550
+ as published by the Free Software Foundation; either version 2
4551
+ of the License, or (at your option) any later version.
4552
+
4553
+ This program is distributed in the hope that it will be useful,
4554
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
4555
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4556
+ GNU General Public License for more details.
4557
+
4558
+ You should have received a copy of the GNU General Public License
4559
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
4560
+ */
4561
+ /*
4562
+ * Many of the following algorithms were taken from hebrew calendar
4563
+ * routines by Maimonedes, from his Mishneh Torah, and implemented by
4564
+ * Nachum Dershowitz Department of Computer Science
4565
+ * (217) 333-4219 University of Illinois at Urbana-Champaign
4566
+ * nachum@cs.uiuedu 1304 West Springfield Avenue
4567
+ * Urbana, Illinois 61801
4568
+ *
4569
+ * The routines were included in the emacs 19 distribution.
4570
+ *
4571
+ */
4572
+ const INCOMPLETE = 0;
4573
+ const REGULAR = 1;
4574
+ const COMPLETE = 2;
4575
+ function yearType(hyear) {
4576
+ const longC = HDate.longCheshvan(hyear);
4577
+ const shortK = HDate.shortKislev(hyear);
4578
+ if (longC && !shortK) {
4579
+ return COMPLETE;
4580
+ }
4581
+ else if (!longC && shortK) {
4582
+ return INCOMPLETE;
4583
+ }
4584
+ else {
4585
+ return REGULAR;
4586
+ }
4587
+ }
4588
+ /**
4589
+ * Represents Parashah HaShavua for an entire Hebrew year
4590
+ */
4591
+ class Sedra {
4592
+ /**
4593
+ * Caculates the Parashah HaShavua for an entire Hebrew year
4594
+ * @param hyear - Hebrew year (e.g. 5749)
4595
+ * @param il - Use Israel sedra schedule (false for Diaspora)
4596
+ */
4597
+ constructor(hyear, il) {
4598
+ hyear = +hyear;
4599
+ this.year = hyear;
4600
+ const rh0 = new HDate(1, months.TISHREI, hyear);
4601
+ const rh = rh0.abs();
4602
+ const rhDay = rh0.getDay() + 1;
4603
+ // find the first Saturday on or after Rosh Hashana
4604
+ this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
4605
+ const leap = +HDate.isLeapYear(hyear);
4606
+ this.il = Boolean(il);
4607
+ const type = yearType(hyear);
4608
+ let key = `${leap}${rhDay}${type}`;
4609
+ if (types[key]) {
4610
+ this.theSedraArray = types[key];
4611
+ this.yearKey = key;
4612
+ }
4613
+ else {
4614
+ key = key + +this.il; // cast to num, then concat
4615
+ this.theSedraArray = types[key];
4616
+ this.yearKey = key;
4617
+ }
4618
+ if (!this.theSedraArray) {
4619
+ throw new Error(`improper sedra year type ${key} calculated for ${hyear}`);
4620
+ }
4621
+ }
4622
+ /**
4623
+ * Returns the parsha (or parshiyot) read on Hebrew date
4624
+ * @deprecated Use {@link lookup} instead
4625
+ * @param hd Hebrew date or R.D. days
4626
+ */
4627
+ get(hd) {
4628
+ return this.lookup(hd).parsha;
4629
+ }
4630
+ /**
4631
+ * Looks up parsha for the date, then returns a translated or transliterated string
4632
+ * @deprecated Use {@link lookup} instead
4633
+ * @param hd Hebrew date or R.D. days
4634
+ * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale
4635
+ */
4636
+ getString(hd, locale) {
4637
+ const parsha = this.get(hd);
4638
+ return renderParshaName(parsha, locale);
4639
+ }
4640
+ /**
4641
+ * Checks to see if this day would be a regular parasha HaShavua
4642
+ * Torah reading or special holiday reading
4643
+ * @deprecated Use {@link lookup} instead
4644
+ * @param hd Hebrew date or R.D. days
4645
+ */
4646
+ isParsha(hd) {
4647
+ return !this.lookup(hd).chag;
4648
+ }
4649
+ /**
4650
+ * Returns the date that a parsha occurs
4651
+ * or `null` if the parsha doesn't occur this year
4652
+ * @param parsha if a `string`, specified with Sephardic transliterations
4653
+ * like `'Noach'` or `'Matot-Masei'`. If an array, must be a 1- or 2-element
4654
+ * array such as `['Noach']` or `['Matot', 'Masei']`. If a `number`, should
4655
+ * be a 0-based parsha index (`0` for Bereshit, `1` for Noach) or a negative
4656
+ * number for a doubled parsha (e.g. `-21` for Vayakhel-Pekudei)
4657
+ */
4658
+ find(parsha) {
4659
+ if (typeof parsha === 'number') {
4660
+ if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
4661
+ throw new RangeError(`Invalid parsha number: ${parsha}`);
4662
+ }
4663
+ return this.findInternal(parsha);
4664
+ }
4665
+ else if (typeof parsha === 'string') {
4666
+ const num = parsha2id.get(parsha);
4667
+ if (typeof num === 'number') {
4668
+ return this.find(num);
4669
+ }
4670
+ else if (parsha.indexOf('-') !== -1) {
4671
+ if (parsha === CHMPESACH || parsha === CHMSUKOT) {
4672
+ return this.findInternal(parsha);
4673
+ }
4674
+ return this.find(parsha.split('-'));
4675
+ }
4676
+ else {
4677
+ // try to find Saturday holiday like 'Yom Kippur'
4678
+ return this.findInternal(parsha);
4679
+ }
4680
+ }
4681
+ else if (Array.isArray(parsha)) {
4682
+ const plen = parsha.length;
4683
+ if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
4684
+ throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
4685
+ }
4686
+ if (plen === 1) {
4687
+ return this.find(parsha[0]);
4688
+ }
4689
+ const p1 = parsha[0];
4690
+ const p2 = parsha[1];
4691
+ const num1 = parsha2id.get(p1);
4692
+ const num2 = parsha2id.get(p2);
4693
+ if (typeof num1 !== 'number' ||
4694
+ typeof num2 !== 'number' ||
4695
+ num2 !== num1 + 1 ||
4696
+ !isValidDouble(-num1)) {
4697
+ throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
4698
+ }
4699
+ return this.find(-num1);
4700
+ }
4701
+ return null; /* NOTREACHED */
4702
+ }
4703
+ findInternal(parsha) {
4704
+ const idx = this.theSedraArray.indexOf(parsha);
4705
+ if (idx === -1) {
4706
+ return null; // doesn't occur this year
4707
+ }
4708
+ return new HDate(this.firstSaturday + idx * 7);
4709
+ }
4710
+ /**
4711
+ * Returns the date that a parsha (or its doubled or undoubled counterpart)
4712
+ * occurs, or `null` if the parsha doesn't occur this year
4713
+ */
4714
+ findContaining(parsha) {
4715
+ const hdate = this.find(parsha);
4716
+ if (hdate) {
4717
+ return hdate;
4718
+ }
4719
+ if (typeof parsha === 'number') {
4720
+ // a valid negative number (double parsha in a year where they are
4721
+ // combined) would've been found above, and a invalid negative number
4722
+ // would've thrown an error, so this parsha must be a positive number
4723
+ // representing either p1 or p2
4724
+ const p1 = -parsha;
4725
+ if (isValidDouble(p1)) {
4726
+ return this.find(p1);
4727
+ }
4728
+ else {
4729
+ // this must be the second individual parsha of a doubled pair
4730
+ // for example 29 for Kedoshim, so check for -28 for Achrei Mot-Kedoshim
4731
+ return this.find(p1 + 1);
4732
+ }
4733
+ }
4734
+ else {
4735
+ const num = parsha2id.get(parsha);
4736
+ if (num) {
4737
+ // parsha is either the first or second individual parsha of
4738
+ // a pair that is doubled this year
4739
+ const p1 = -num;
4740
+ if (isValidDouble(p1)) {
4741
+ return this.find(p1);
4742
+ }
4743
+ else {
4744
+ return this.find(p1 + 1);
4745
+ }
4746
+ }
4747
+ else {
4748
+ // this was indeed a doubled parsha, so return date of the first half
4749
+ const [p1] = parsha.split('-');
4750
+ return this.find(p1);
4751
+ }
4752
+ }
4753
+ }
4754
+ /**
4755
+ * Returns the underlying annual sedra schedule.
4756
+ * Used by `@hebcal/triennial`
4757
+ */
4758
+ getSedraArray() {
4759
+ return this.theSedraArray;
4760
+ }
4761
+ /**
4762
+ * R.D. date of the first Saturday on or after Rosh Hashana
4763
+ */
4764
+ getFirstSaturday() {
4765
+ return this.firstSaturday;
4766
+ }
4767
+ getYear() {
4768
+ return this.year;
4769
+ }
4770
+ /**
4771
+ * Returns an object describing the parsha on the first Saturday on or after `hd`
4772
+ * @param hd Hebrew date or R.D. days
4773
+ */
4774
+ lookup(hd) {
4775
+ const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
4776
+ if (isNaN(abs)) {
4777
+ throw new TypeError(`Bad date argument: ${hd}`);
4778
+ }
4779
+ // find the first saturday on or after today's date
4780
+ const saturday = HDate.dayOnOrBefore(6, abs + 6);
4781
+ const weekNum = (saturday - this.firstSaturday) / 7;
4782
+ const index = this.theSedraArray[weekNum];
4783
+ if (typeof index === 'undefined') {
4784
+ const sedra = getSedra(this.year + 1, this.il);
4785
+ return sedra.lookup(saturday); // must be next year
4786
+ }
4787
+ const hdate = new HDate(saturday);
4788
+ if (typeof index === 'string') {
4789
+ // Shabbat has a chag. Return a description
4790
+ return { parsha: [index], chag: true, hdate };
4791
+ }
4792
+ if (index >= 0) {
4793
+ return { parsha: [parshiot[index]], chag: false, num: index + 1, hdate };
4794
+ }
4795
+ const p1 = D(index); // undouble the parsha
4796
+ return {
4797
+ parsha: [parshiot[p1], parshiot[p1 + 1]],
4798
+ chag: false,
4799
+ num: [p1 + 1, p1 + 2],
4800
+ hdate,
4801
+ };
4802
+ }
4803
+ }
4804
+ /**
4805
+ * The 54 parshiyot of the Torah as transilterated strings.
4806
+ * parshiot[0] == 'Bereshit', parshiot[1] == 'Noach', parshiot[52] == "Ha'azinu".
4807
+ * @readonly
4808
+ * @type {string[]}
4809
+ */
4810
+ const parshiot = [
4811
+ 'Bereshit',
4812
+ 'Noach',
4813
+ 'Lech-Lecha',
4814
+ 'Vayera',
4815
+ 'Chayei Sara',
4816
+ 'Toldot',
4817
+ 'Vayetzei',
4818
+ 'Vayishlach',
4819
+ 'Vayeshev',
4820
+ 'Miketz',
4821
+ 'Vayigash',
4822
+ 'Vayechi',
4823
+ 'Shemot',
4824
+ 'Vaera',
4825
+ 'Bo',
4826
+ 'Beshalach',
4827
+ 'Yitro',
4828
+ 'Mishpatim',
4829
+ 'Terumah',
4830
+ 'Tetzaveh',
4831
+ 'Ki Tisa',
4832
+ 'Vayakhel',
4833
+ 'Pekudei',
4834
+ 'Vayikra',
4835
+ 'Tzav',
4836
+ 'Shmini',
4837
+ 'Tazria',
4838
+ 'Metzora',
4839
+ 'Achrei Mot',
4840
+ 'Kedoshim',
4841
+ 'Emor',
4842
+ 'Behar',
4843
+ 'Bechukotai',
4844
+ 'Bamidbar',
4845
+ 'Nasso',
4846
+ "Beha'alotcha",
4847
+ "Sh'lach",
4848
+ 'Korach',
4849
+ 'Chukat',
4850
+ 'Balak',
4851
+ 'Pinchas',
4852
+ 'Matot',
4853
+ 'Masei',
4854
+ 'Devarim',
4855
+ 'Vaetchanan',
4856
+ 'Eikev',
4857
+ "Re'eh",
4858
+ 'Shoftim',
4859
+ 'Ki Teitzei',
4860
+ 'Ki Tavo',
4861
+ 'Nitzavim',
4862
+ 'Vayeilech',
4863
+ "Ha'azinu",
4864
+ ];
4865
+ // 0-based parsha IDs
4866
+ const parsha2id = new Map();
4867
+ for (let id = 0; id < parshiot.length; id++) {
4868
+ const name = parshiot[id];
4869
+ parsha2id.set(name, id);
4870
+ }
4871
+ // 0-based parsha IDs
4872
+ const doubles = [
4873
+ 21, // Vayakhel-Pekudei
4874
+ 26, // Tazria-Metzora
4875
+ 28, // Achrei Mot-Kedoshim
4876
+ 31, // Behar-Bechukotai
4877
+ 38, // Chukat-Balak
4878
+ 41, // Matot-Masei
4879
+ 50, // Nitzavim-Vayeilech
4880
+ ];
4881
+ /**
4882
+ * @private
4883
+ * @param id a negative number
4884
+ */
4885
+ function isValidDouble(id) {
4886
+ return doubles.includes(-id);
4887
+ }
4888
+ /**
4889
+ * parsha doubler/undoubler
4890
+ * @private
4891
+ * @param p
4892
+ */
4893
+ function D(p) {
4894
+ return -p;
4895
+ }
4896
+ const RH = 'Rosh Hashana'; // 0
4897
+ const YK = 'Yom Kippur'; // 1
4898
+ const SUKKOT = 'Sukkot'; // 0
4899
+ const CHMSUKOT = 'Sukkot Shabbat Chol ha-Moed'; // 0
4900
+ const SHMINI = 'Shmini Atzeret'; // 0
4901
+ const PESACH = 'Pesach'; // 25
4902
+ const PESACH1 = 'Pesach I';
4903
+ const CHMPESACH = 'Pesach Shabbat Chol ha-Moed'; // 25
4904
+ const PESACH7 = 'Pesach VII'; // 25
4905
+ const PESACH8 = 'Pesach VIII';
4906
+ const SHAVUOT$1 = 'Shavuot'; // 33
4907
+ /**
4908
+ * Returns an array from start to end
4909
+ * @private
4910
+ * @param start beginning number, inclusive
4911
+ * @param stop ending number, inclusive
4912
+ */
4913
+ function range$1(start, stop) {
4914
+ return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
4915
+ }
4916
+ const yearStartVayeilech = [51, 52, CHMSUKOT];
4917
+ const yearStartHaazinu = [52, YK, CHMSUKOT];
4918
+ const yearStartRH = [RH, 52, SUKKOT, SHMINI];
4919
+ const r020 = range$1(0, 20);
4920
+ const r027 = range$1(0, 27);
4921
+ const r3340 = range$1(33, 40);
4922
+ const r4349 = range$1(43, 49);
4923
+ const r4350 = range$1(43, 50);
4924
+ /**
4925
+ * The ordinary year types (keviot)
4926
+ * names are leap/nonleap - day - incomplete/regular/complete - diaspora/Israel
4927
+ * @private
4928
+ * @readonly
4929
+ */
4930
+ const types = {
4931
+ /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
4932
+ * Kislev each have 29 days), and has Passover start on Tuesday. */
4933
+ // e.g. 5753
4934
+ '020': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
4935
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
4936
+ * Kislev each have 30 days), and has Passover start on Thursday. */
4937
+ // e.g. 5756
4938
+ '0220': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
4939
+ /* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
4940
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
4941
+ // e.g. 5701
4942
+ '0510': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
4943
+ /* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
4944
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
4945
+ // e.g. 5745
4946
+ '0511': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), range$1(30, 40), D(41), r4350),
4947
+ /* Hebrew year that starts on Thursday, is `complete' (Heshvan and
4948
+ * Kislev each have 30 days), and has Passover start on Sunday. */
4949
+ // e.g. 5754
4950
+ '052': yearStartHaazinu.concat(range$1(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
4951
+ /* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
4952
+ * each have 29 days), and has Passover start on Sunday. */
4953
+ // e.g. 5761
4954
+ '070': yearStartRH.concat(r020, D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
4955
+ /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
4956
+ * Kislev each have 30 days), and has Passover start on Tuesday. */
4957
+ // e.g. 5716
4958
+ '072': yearStartRH.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
4959
+ /* -- The leap year types (keviot) -- */
4960
+ /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
4961
+ * Kislev each have 29 days), and has Passover start on Thursday. */
4962
+ // e.g. 5746
4963
+ '1200': yearStartVayeilech.concat(r027, CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
4964
+ /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
4965
+ * Kislev each have 29 days), and has Passover start on Thursday. */
4966
+ // e.g. 5746
4967
+ '1201': yearStartVayeilech.concat(r027, CHMPESACH, range$1(28, 40), D(41), r4349, D(50)),
4968
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
4969
+ * Kislev each have 30 days), and has Passover start on Saturday. */
4970
+ // e.g.5752
4971
+ '1220': yearStartVayeilech.concat(r027, PESACH1, PESACH8, range$1(28, 40), D(41), r4350),
4972
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
4973
+ * Kislev each have 30 days), and has Passover start on Saturday. */
4974
+ // e.g.5752
4975
+ '1221': yearStartVayeilech.concat(r027, PESACH, range$1(28, 50)),
4976
+ /* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
4977
+ * Kislev both have 29 days), and has Passover start on Sunday. */
4978
+ // e.g. 5768
4979
+ '150': yearStartHaazinu.concat(range$1(0, 28), PESACH7, range$1(29, 50)),
4980
+ /* Hebrew year that starts on Thursday, is `complete' (Heshvan and
4981
+ * Kislev both have 30 days), and has Passover start on Tuesday. */
4982
+ // eg. 5771
4983
+ '152': yearStartHaazinu.concat(range$1(0, 28), CHMPESACH, range$1(29, 49), D(50)),
4984
+ /* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
4985
+ * Kislev each have 29 days), and has Passover start on Tuesday. */
4986
+ // e.g.5757
4987
+ '170': yearStartRH.concat(r027, CHMPESACH, range$1(28, 40), D(41), r4349, D(50)),
4988
+ /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
4989
+ * Kislev each have 30 days), and has Passover start on Thursday. */
4990
+ '1720': yearStartRH.concat(r027, CHMPESACH, range$1(28, 33), SHAVUOT$1, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
4991
+ };
4992
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
4993
+ * Kislev each have 30 days), and has Passover start on Thursday. */
4994
+ types['0221'] = types['020'];
4995
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
4996
+ * days and Kislev has 30 days), and has Passover start on Thursday. */
4997
+ // e.g. 5715
4998
+ types['0310'] = types['0220'];
4999
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
5000
+ * days and Kislev has 30 days), and has Passover start on Thursday. */
5001
+ types['0311'] = types['020'];
5002
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
5003
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
5004
+ // e.g. 5715
5005
+ types['1310'] = types['1220'];
5006
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
5007
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
5008
+ types['1311'] = types['1221'];
5009
+ /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
5010
+ * Kislev each have 30 days), and has Passover start on Thursday. */
5011
+ types['1721'] = types['170'];
5012
+ const sedraCache = new QuickLRU({ maxSize: 400 });
5013
+ /**
5014
+ * Convenience function to create an instance of `Sedra` or reuse a previously
5015
+ * created and cached instance.
5016
+ * @param hyear
5017
+ * @param il
5018
+ */
5019
+ function getSedra(hyear, il) {
5020
+ const cacheKey = `${hyear}-${il ? 1 : 0}`;
5021
+ let sedra = sedraCache.get(cacheKey);
5022
+ if (!sedra) {
5023
+ sedra = new Sedra(hyear, il);
5024
+ sedraCache.set(cacheKey, sedra);
5025
+ }
5026
+ return sedra;
5027
+ }
5986
5028
 
5987
- entries() {
5988
- return this.entriesAscending();
5989
- }
5029
+ const Nisan = months.NISAN;
5030
+ const Iyyar = months.IYYAR;
5031
+ const Sivan = months.SIVAN;
5032
+ const Tamuz = months.TAMUZ;
5033
+ const Av = months.AV;
5034
+ const Elul = months.ELUL;
5035
+ const Tishrei = months.TISHREI;
5036
+ const Cheshvan = months.CHESHVAN;
5037
+ const Kislev = months.KISLEV;
5038
+ const Shvat = months.SHVAT;
5039
+ const Adar2 = months.ADAR_II;
5040
+ const CHAG$1 = flags.CHAG;
5041
+ const LIGHT_CANDLES$3 = flags.LIGHT_CANDLES;
5042
+ const YOM_TOV_ENDS$1 = flags.YOM_TOV_ENDS;
5043
+ const CHUL_ONLY$1 = flags.CHUL_ONLY;
5044
+ const IL_ONLY$2 = flags.IL_ONLY;
5045
+ const LIGHT_CANDLES_TZEIS$3 = flags.LIGHT_CANDLES_TZEIS;
5046
+ const CHANUKAH_CANDLES$2 = flags.CHANUKAH_CANDLES;
5047
+ const MAJOR_FAST$2 = flags.MAJOR_FAST;
5048
+ const MINOR_HOLIDAY$2 = flags.MINOR_HOLIDAY;
5049
+ const EREV$2 = flags.EREV;
5050
+ const CHOL_HAMOED$1 = flags.CHOL_HAMOED;
5051
+ const emojiPesach = '🫓';
5052
+ const emojiSukkot = '🌿🍋';
5053
+ const ROSH_HASHANA_II = 'Rosh Hashana II';
5054
+ const EREV_YOM_KIPPUR = 'Erev Yom Kippur';
5055
+ const YOM_KIPPUR = 'Yom Kippur';
5056
+ const EREV_SUKKOT = 'Erev Sukkot';
5057
+ const SUKKOT_I = 'Sukkot I';
5058
+ const SUKKOT_II = 'Sukkot II';
5059
+ const SUKKOT_III_CHM = "Sukkot III (CH''M)";
5060
+ const SUKKOT_IV_CHM = "Sukkot IV (CH''M)";
5061
+ const SUKKOT_V_CHM = "Sukkot V (CH''M)";
5062
+ const SUKKOT_VI_CHM = "Sukkot VI (CH''M)";
5063
+ const SHMINI_ATZERET = 'Shmini Atzeret';
5064
+ const SIMCHAT_TORAH = 'Simchat Torah';
5065
+ const SUKKOT_II_CHM = "Sukkot II (CH''M)";
5066
+ const SUKKOT_VII_HOSHANA_RABA = 'Sukkot VII (Hoshana Raba)';
5067
+ const CHANUKAH_1_CANDLE = 'Chanukah: 1 Candle';
5068
+ const TU_BISHVAT = 'Tu BiShvat';
5069
+ const EREV_PURIM = 'Erev Purim';
5070
+ const PURIM = 'Purim';
5071
+ const SHUSHAN_PURIM = 'Shushan Purim';
5072
+ const EREV_PESACH = 'Erev Pesach';
5073
+ const PESACH_I = 'Pesach I';
5074
+ const PESACH_II = 'Pesach II';
5075
+ const PESACH_II_CHM = "Pesach II (CH''M)";
5076
+ const PESACH_III_CHM = "Pesach III (CH''M)";
5077
+ const PESACH_IV_CHM = "Pesach IV (CH''M)";
5078
+ const PESACH_V_CHM = "Pesach V (CH''M)";
5079
+ const PESACH_VI_CHM = "Pesach VI (CH''M)";
5080
+ const PESACH_VII = 'Pesach VII';
5081
+ const PESACH_VIII = 'Pesach VIII';
5082
+ const PESACH_SHENI = 'Pesach Sheni';
5083
+ const LAG_BAOMER = 'Lag BaOmer';
5084
+ const EREV_SHAVUOT = 'Erev Shavuot';
5085
+ const SHAVUOT = 'Shavuot';
5086
+ const SHAVUOT_I = 'Shavuot I';
5087
+ const SHAVUOT_II = 'Shavuot II';
5088
+ const TU_BAV = "Tu B'Av";
5089
+ const ROSH_HASHANA_LABEHEMOT = 'Rosh Hashana LaBehemot';
5090
+ const EREV_ROSH_HASHANA = 'Erev Rosh Hashana';
5091
+ const YOM_YERUSHALAYIM = 'Yom Yerushalayim';
5092
+ const BEN_GURION_DAY = 'Ben-Gurion Day';
5093
+ const FAMILY_DAY = 'Family Day';
5094
+ const YITZHAK_RABIN_MEMORIAL_DAY = 'Yitzhak Rabin Memorial Day';
5095
+ const HERZL_DAY = 'Herzl Day';
5096
+ const JABOTINSKY_DAY = 'Jabotinsky Day';
5097
+ const SIGD = 'Sigd';
5098
+ const YOM_HAALIYAH = 'Yom HaAliyah';
5099
+ const YOM_HAALIYAH_SCHOOL_OBSERVANCE = 'Yom HaAliyah School Observance';
5100
+ const HEBREW_LANGUAGE_DAY = 'Hebrew Language Day';
5101
+ /**
5102
+ * Transliterated names of holidays, used by `Event.getDesc()`
5103
+ * @readonly
5104
+ * @enum {string}
5105
+ */
5106
+ const holidayDesc = {
5107
+ /** Asara B'Tevet */
5108
+ ASARA_BTEVET: "Asara B'Tevet",
5109
+ /** Birkat Hachamah */
5110
+ BIRKAT_HACHAMAH: 'Birkat Hachamah',
5111
+ /** Chag HaBanot */
5112
+ CHAG_HABANOT: 'Chag HaBanot',
5113
+ /** Chanukah: 8th Day */
5114
+ CHANUKAH_8TH_DAY: 'Chanukah: 8th Day',
5115
+ /** Erev Tish'a B'Av */
5116
+ EREV_TISHA_BAV: "Erev Tish'a B'Av",
5117
+ /** Leil Selichot */
5118
+ LEIL_SELICHOT: 'Leil Selichot',
5119
+ /** Purim Katan */
5120
+ PURIM_KATAN: 'Purim Katan',
5121
+ /** Purim Meshulash */
5122
+ PURIM_MESHULASH: 'Purim Meshulash',
5123
+ /** Shabbat Chazon */
5124
+ SHABBAT_CHAZON: 'Shabbat Chazon',
5125
+ /** Shabbat HaChodesh */
5126
+ SHABBAT_HACHODESH: 'Shabbat HaChodesh',
5127
+ /** Shabbat HaGadol */
5128
+ SHABBAT_HAGADOL: 'Shabbat HaGadol',
5129
+ /** Shabbat Nachamu */
5130
+ SHABBAT_NACHAMU: 'Shabbat Nachamu',
5131
+ /** Shabbat Parah */
5132
+ SHABBAT_PARAH: 'Shabbat Parah',
5133
+ /** Shabbat Shekalim */
5134
+ SHABBAT_SHEKALIM: 'Shabbat Shekalim',
5135
+ /** Shabbat Shirah */
5136
+ SHABBAT_SHIRAH: 'Shabbat Shirah',
5137
+ /** Shabbat Shuva */
5138
+ SHABBAT_SHUVA: 'Shabbat Shuva',
5139
+ /** Shabbat Zachor */
5140
+ SHABBAT_ZACHOR: 'Shabbat Zachor',
5141
+ /** Shushan Purim Katan */
5142
+ SHUSHAN_PURIM_KATAN: 'Shushan Purim Katan',
5143
+ /** Ta'anit Bechorot */
5144
+ TAANIT_BECHOROT: "Ta'anit Bechorot",
5145
+ /** Ta'anit Esther */
5146
+ TAANIT_ESTHER: "Ta'anit Esther",
5147
+ /** Tish'a B'Av */
5148
+ TISHA_BAV: "Tish'a B'Av",
5149
+ /** Tzom Gedaliah */
5150
+ TZOM_GEDALIAH: 'Tzom Gedaliah',
5151
+ /** Tzom Tammuz */
5152
+ TZOM_TAMMUZ: 'Tzom Tammuz',
5153
+ /** Yom HaAtzma'ut */
5154
+ YOM_HAATZMA_UT: "Yom HaAtzma'ut",
5155
+ /** Yom HaShoah */
5156
+ YOM_HASHOAH: 'Yom HaShoah',
5157
+ /** Yom HaZikaron */
5158
+ YOM_HAZIKARON: 'Yom HaZikaron',
5159
+ /** Ben-Gurion Day */
5160
+ BEN_GURION_DAY,
5161
+ /** Chanukah: 1 Candle */
5162
+ CHANUKAH_1_CANDLE,
5163
+ /** Erev Pesach */
5164
+ EREV_PESACH,
5165
+ /** Erev Purim */
5166
+ EREV_PURIM,
5167
+ /** Erev Rosh Hashana */
5168
+ EREV_ROSH_HASHANA,
5169
+ /** Erev Shavuot */
5170
+ EREV_SHAVUOT,
5171
+ /** Erev Sukkot */
5172
+ EREV_SUKKOT,
5173
+ /** Erev Yom Kippur */
5174
+ EREV_YOM_KIPPUR,
5175
+ /** Family Day */
5176
+ FAMILY_DAY,
5177
+ /** Hebrew Language Day */
5178
+ HEBREW_LANGUAGE_DAY,
5179
+ /** Herzl Day */
5180
+ HERZL_DAY,
5181
+ /** Jabotinsky Day */
5182
+ JABOTINSKY_DAY,
5183
+ /** Lag BaOmer */
5184
+ LAG_BAOMER,
5185
+ /** Pesach I */
5186
+ PESACH_I,
5187
+ /** Pesach II */
5188
+ PESACH_II,
5189
+ /** Pesach III (CH''M) */
5190
+ PESACH_III_CHM,
5191
+ /** Pesach II (CH''M) */
5192
+ PESACH_II_CHM,
5193
+ /** Pesach IV (CH''M) */
5194
+ PESACH_IV_CHM,
5195
+ /** Pesach Sheni */
5196
+ PESACH_SHENI,
5197
+ /** Pesach VII */
5198
+ PESACH_VII,
5199
+ /** Pesach VIII */
5200
+ PESACH_VIII,
5201
+ /** Pesach VI (CH''M) */
5202
+ PESACH_VI_CHM,
5203
+ /** Pesach V (CH''M) */
5204
+ PESACH_V_CHM,
5205
+ /** Purim */
5206
+ PURIM,
5207
+ /** Rosh Hashana II */
5208
+ ROSH_HASHANA_II,
5209
+ /** Rosh Hashana LaBehemot */
5210
+ ROSH_HASHANA_LABEHEMOT,
5211
+ /** Shavuot */
5212
+ SHAVUOT,
5213
+ /** Shavuot I */
5214
+ SHAVUOT_I,
5215
+ /** Shavuot II */
5216
+ SHAVUOT_II,
5217
+ /** Shmini Atzeret */
5218
+ SHMINI_ATZERET,
5219
+ /** Shushan Purim */
5220
+ SHUSHAN_PURIM,
5221
+ /** Sigd */
5222
+ SIGD,
5223
+ /** Simchat Torah */
5224
+ SIMCHAT_TORAH,
5225
+ /** Sukkot I */
5226
+ SUKKOT_I,
5227
+ /** Sukkot II */
5228
+ SUKKOT_II,
5229
+ /** Sukkot III (CH''M) */
5230
+ SUKKOT_III_CHM,
5231
+ /** Sukkot II (CH''M) */
5232
+ SUKKOT_II_CHM,
5233
+ /** Sukkot IV (CH''M) */
5234
+ SUKKOT_IV_CHM,
5235
+ /** Sukkot VII (Hoshana Raba) */
5236
+ SUKKOT_VII_HOSHANA_RABA,
5237
+ /** Sukkot VI (CH''M) */
5238
+ SUKKOT_VI_CHM,
5239
+ /** Sukkot V (CH''M) */
5240
+ SUKKOT_V_CHM,
5241
+ /** Tu B\'Av */
5242
+ TU_BAV,
5243
+ /** Tu BiShvat */
5244
+ TU_BISHVAT,
5245
+ /** Yitzhak Rabin Memorial Day */
5246
+ YITZHAK_RABIN_MEMORIAL_DAY,
5247
+ /** Yom HaAliyah */
5248
+ YOM_HAALIYAH,
5249
+ /** Yom HaAliyah School Observance */
5250
+ YOM_HAALIYAH_SCHOOL_OBSERVANCE,
5251
+ /** Yom Kippur */
5252
+ YOM_KIPPUR,
5253
+ /** Yom Yerushalayim */
5254
+ YOM_YERUSHALAYIM,
5255
+ };
5256
+ const staticHolidays = [
5257
+ {
5258
+ mm: Tishrei,
5259
+ dd: 2,
5260
+ desc: ROSH_HASHANA_II,
5261
+ flags: CHAG$1 | YOM_TOV_ENDS$1,
5262
+ emoji: '🍏🍯',
5263
+ },
5264
+ { mm: Tishrei, dd: 9, desc: EREV_YOM_KIPPUR, flags: EREV$2 | LIGHT_CANDLES$3 },
5265
+ {
5266
+ mm: Tishrei,
5267
+ dd: 10,
5268
+ desc: YOM_KIPPUR,
5269
+ flags: CHAG$1 | MAJOR_FAST$2 | YOM_TOV_ENDS$1,
5270
+ },
5271
+ {
5272
+ mm: Tishrei,
5273
+ dd: 14,
5274
+ desc: EREV_SUKKOT,
5275
+ flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$3,
5276
+ emoji: emojiSukkot,
5277
+ },
5278
+ {
5279
+ mm: Tishrei,
5280
+ dd: 15,
5281
+ desc: SUKKOT_I,
5282
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
5283
+ emoji: emojiSukkot,
5284
+ },
5285
+ {
5286
+ mm: Tishrei,
5287
+ dd: 16,
5288
+ desc: SUKKOT_II,
5289
+ flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
5290
+ emoji: emojiSukkot,
5291
+ },
5292
+ {
5293
+ mm: Tishrei,
5294
+ dd: 17,
5295
+ desc: SUKKOT_III_CHM,
5296
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5297
+ chmDay: 1,
5298
+ emoji: emojiSukkot,
5299
+ },
5300
+ {
5301
+ mm: Tishrei,
5302
+ dd: 18,
5303
+ desc: SUKKOT_IV_CHM,
5304
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5305
+ chmDay: 2,
5306
+ emoji: emojiSukkot,
5307
+ },
5308
+ {
5309
+ mm: Tishrei,
5310
+ dd: 19,
5311
+ desc: SUKKOT_V_CHM,
5312
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5313
+ chmDay: 3,
5314
+ emoji: emojiSukkot,
5315
+ },
5316
+ {
5317
+ mm: Tishrei,
5318
+ dd: 20,
5319
+ desc: SUKKOT_VI_CHM,
5320
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5321
+ chmDay: 4,
5322
+ emoji: emojiSukkot,
5323
+ },
5324
+ {
5325
+ mm: Tishrei,
5326
+ dd: 22,
5327
+ desc: SHMINI_ATZERET,
5328
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
5329
+ },
5330
+ {
5331
+ mm: Tishrei,
5332
+ dd: 23,
5333
+ desc: SIMCHAT_TORAH,
5334
+ flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
5335
+ },
5336
+ {
5337
+ mm: Tishrei,
5338
+ dd: 14,
5339
+ desc: EREV_SUKKOT,
5340
+ flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$3,
5341
+ emoji: emojiSukkot,
5342
+ },
5343
+ {
5344
+ mm: Tishrei,
5345
+ dd: 15,
5346
+ desc: SUKKOT_I,
5347
+ flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
5348
+ emoji: emojiSukkot,
5349
+ },
5350
+ {
5351
+ mm: Tishrei,
5352
+ dd: 16,
5353
+ desc: SUKKOT_II_CHM,
5354
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5355
+ chmDay: 1,
5356
+ emoji: emojiSukkot,
5357
+ },
5358
+ {
5359
+ mm: Tishrei,
5360
+ dd: 17,
5361
+ desc: SUKKOT_III_CHM,
5362
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5363
+ chmDay: 2,
5364
+ emoji: emojiSukkot,
5365
+ },
5366
+ {
5367
+ mm: Tishrei,
5368
+ dd: 18,
5369
+ desc: SUKKOT_IV_CHM,
5370
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5371
+ chmDay: 3,
5372
+ emoji: emojiSukkot,
5373
+ },
5374
+ {
5375
+ mm: Tishrei,
5376
+ dd: 19,
5377
+ desc: SUKKOT_V_CHM,
5378
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5379
+ chmDay: 4,
5380
+ emoji: emojiSukkot,
5381
+ },
5382
+ {
5383
+ mm: Tishrei,
5384
+ dd: 20,
5385
+ desc: SUKKOT_VI_CHM,
5386
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5387
+ chmDay: 5,
5388
+ emoji: emojiSukkot,
5389
+ },
5390
+ {
5391
+ mm: Tishrei,
5392
+ dd: 22,
5393
+ desc: SHMINI_ATZERET,
5394
+ flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
5395
+ },
5396
+ {
5397
+ mm: Tishrei,
5398
+ dd: 21,
5399
+ desc: SUKKOT_VII_HOSHANA_RABA,
5400
+ flags: LIGHT_CANDLES$3 | CHOL_HAMOED$1,
5401
+ chmDay: -1,
5402
+ emoji: emojiSukkot,
5403
+ },
5404
+ {
5405
+ mm: Kislev,
5406
+ dd: 24,
5407
+ desc: CHANUKAH_1_CANDLE,
5408
+ flags: EREV$2 | MINOR_HOLIDAY$2 | CHANUKAH_CANDLES$2,
5409
+ emoji: '🕎1️⃣',
5410
+ },
5411
+ { mm: Shvat, dd: 15, desc: TU_BISHVAT, flags: MINOR_HOLIDAY$2, emoji: '🌳' },
5412
+ {
5413
+ mm: Adar2,
5414
+ dd: 13,
5415
+ desc: EREV_PURIM,
5416
+ flags: EREV$2 | MINOR_HOLIDAY$2,
5417
+ emoji: '🎭️📜',
5418
+ },
5419
+ { mm: Adar2, dd: 14, desc: PURIM, flags: MINOR_HOLIDAY$2, emoji: '🎭️📜' },
5420
+ {
5421
+ mm: Adar2,
5422
+ dd: 15,
5423
+ desc: SHUSHAN_PURIM,
5424
+ flags: MINOR_HOLIDAY$2,
5425
+ emoji: '🎭️📜',
5426
+ },
5427
+ // Pesach Israel
5428
+ {
5429
+ mm: Nisan,
5430
+ dd: 14,
5431
+ desc: EREV_PESACH,
5432
+ flags: IL_ONLY$2 | EREV$2 | LIGHT_CANDLES$3,
5433
+ emoji: '🫓🍷',
5434
+ },
5435
+ {
5436
+ mm: Nisan,
5437
+ dd: 15,
5438
+ desc: PESACH_I,
5439
+ flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
5440
+ emoji: emojiPesach,
5441
+ },
5442
+ {
5443
+ mm: Nisan,
5444
+ dd: 16,
5445
+ desc: PESACH_II_CHM,
5446
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5447
+ chmDay: 1,
5448
+ emoji: emojiPesach,
5449
+ },
5450
+ {
5451
+ mm: Nisan,
5452
+ dd: 17,
5453
+ desc: PESACH_III_CHM,
5454
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5455
+ chmDay: 2,
5456
+ emoji: emojiPesach,
5457
+ },
5458
+ {
5459
+ mm: Nisan,
5460
+ dd: 18,
5461
+ desc: PESACH_IV_CHM,
5462
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5463
+ chmDay: 3,
5464
+ emoji: emojiPesach,
5465
+ },
5466
+ {
5467
+ mm: Nisan,
5468
+ dd: 19,
5469
+ desc: PESACH_V_CHM,
5470
+ flags: IL_ONLY$2 | CHOL_HAMOED$1,
5471
+ chmDay: 4,
5472
+ emoji: emojiPesach,
5473
+ },
5474
+ {
5475
+ mm: Nisan,
5476
+ dd: 20,
5477
+ desc: PESACH_VI_CHM,
5478
+ flags: IL_ONLY$2 | CHOL_HAMOED$1 | LIGHT_CANDLES$3,
5479
+ chmDay: 5,
5480
+ emoji: emojiPesach,
5481
+ },
5482
+ {
5483
+ mm: Nisan,
5484
+ dd: 21,
5485
+ desc: PESACH_VII,
5486
+ flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
5487
+ emoji: emojiPesach,
5488
+ },
5489
+ // Pesach chutz l'aretz
5490
+ {
5491
+ mm: Nisan,
5492
+ dd: 14,
5493
+ desc: EREV_PESACH,
5494
+ flags: CHUL_ONLY$1 | EREV$2 | LIGHT_CANDLES$3,
5495
+ emoji: '🫓🍷',
5496
+ },
5497
+ {
5498
+ mm: Nisan,
5499
+ dd: 15,
5500
+ desc: PESACH_I,
5501
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
5502
+ emoji: '🫓🍷',
5503
+ },
5504
+ {
5505
+ mm: Nisan,
5506
+ dd: 16,
5507
+ desc: PESACH_II,
5508
+ flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
5509
+ emoji: emojiPesach,
5510
+ },
5511
+ {
5512
+ mm: Nisan,
5513
+ dd: 17,
5514
+ desc: PESACH_III_CHM,
5515
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5516
+ chmDay: 1,
5517
+ emoji: emojiPesach,
5518
+ },
5519
+ {
5520
+ mm: Nisan,
5521
+ dd: 18,
5522
+ desc: PESACH_IV_CHM,
5523
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5524
+ chmDay: 2,
5525
+ emoji: emojiPesach,
5526
+ },
5527
+ {
5528
+ mm: Nisan,
5529
+ dd: 19,
5530
+ desc: PESACH_V_CHM,
5531
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1,
5532
+ chmDay: 3,
5533
+ emoji: emojiPesach,
5534
+ },
5535
+ {
5536
+ mm: Nisan,
5537
+ dd: 20,
5538
+ desc: PESACH_VI_CHM,
5539
+ flags: CHUL_ONLY$1 | CHOL_HAMOED$1 | LIGHT_CANDLES$3,
5540
+ chmDay: 4,
5541
+ emoji: emojiPesach,
5542
+ },
5543
+ {
5544
+ mm: Nisan,
5545
+ dd: 21,
5546
+ desc: PESACH_VII,
5547
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
5548
+ emoji: emojiPesach,
5549
+ },
5550
+ {
5551
+ mm: Nisan,
5552
+ dd: 22,
5553
+ desc: PESACH_VIII,
5554
+ flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
5555
+ emoji: emojiPesach,
5556
+ },
5557
+ { mm: Iyyar, dd: 14, desc: PESACH_SHENI, flags: MINOR_HOLIDAY$2 },
5558
+ { mm: Iyyar, dd: 18, desc: LAG_BAOMER, flags: MINOR_HOLIDAY$2, emoji: '🔥' },
5559
+ {
5560
+ mm: Sivan,
5561
+ dd: 5,
5562
+ desc: EREV_SHAVUOT,
5563
+ flags: EREV$2 | LIGHT_CANDLES$3,
5564
+ emoji: '⛰️🌸',
5565
+ },
5566
+ {
5567
+ mm: Sivan,
5568
+ dd: 6,
5569
+ desc: SHAVUOT,
5570
+ flags: IL_ONLY$2 | CHAG$1 | YOM_TOV_ENDS$1,
5571
+ emoji: '⛰️🌸',
5572
+ },
5573
+ {
5574
+ mm: Sivan,
5575
+ dd: 6,
5576
+ desc: SHAVUOT_I,
5577
+ flags: CHUL_ONLY$1 | CHAG$1 | LIGHT_CANDLES_TZEIS$3,
5578
+ emoji: '⛰️🌸',
5579
+ },
5580
+ {
5581
+ mm: Sivan,
5582
+ dd: 7,
5583
+ desc: SHAVUOT_II,
5584
+ flags: CHUL_ONLY$1 | CHAG$1 | YOM_TOV_ENDS$1,
5585
+ emoji: '⛰️🌸',
5586
+ },
5587
+ { mm: Av, dd: 15, desc: TU_BAV, flags: MINOR_HOLIDAY$2, emoji: '❤️' },
5588
+ {
5589
+ mm: Elul,
5590
+ dd: 1,
5591
+ desc: ROSH_HASHANA_LABEHEMOT,
5592
+ flags: MINOR_HOLIDAY$2,
5593
+ emoji: '🐑',
5594
+ },
5595
+ {
5596
+ mm: Elul,
5597
+ dd: 29,
5598
+ desc: EREV_ROSH_HASHANA,
5599
+ flags: EREV$2 | LIGHT_CANDLES$3,
5600
+ emoji: '🍏🍯',
5601
+ },
5602
+ ];
5603
+ const staticModernHolidays = [
5604
+ { firstYear: 5727, mm: Iyyar, dd: 28, desc: YOM_YERUSHALAYIM, chul: true },
5605
+ {
5606
+ firstYear: 5737,
5607
+ mm: Kislev,
5608
+ dd: 6,
5609
+ desc: BEN_GURION_DAY,
5610
+ satPostponeToSun: true,
5611
+ friPostponeToSun: true,
5612
+ },
5613
+ { firstYear: 5750, mm: Shvat, dd: 30, desc: FAMILY_DAY },
5614
+ {
5615
+ firstYear: 5758,
5616
+ mm: Cheshvan,
5617
+ dd: 12,
5618
+ desc: YITZHAK_RABIN_MEMORIAL_DAY,
5619
+ friSatMovetoThu: true,
5620
+ },
5621
+ { firstYear: 5764, mm: Iyyar, dd: 10, desc: HERZL_DAY, satPostponeToSun: true },
5622
+ {
5623
+ firstYear: 5765,
5624
+ mm: Tamuz,
5625
+ dd: 29,
5626
+ desc: JABOTINSKY_DAY,
5627
+ satPostponeToSun: true,
5628
+ },
5629
+ {
5630
+ firstYear: 5769,
5631
+ mm: Cheshvan,
5632
+ dd: 29,
5633
+ desc: SIGD,
5634
+ chul: true,
5635
+ suppressEmoji: true,
5636
+ friSatMovetoThu: true,
5637
+ },
5638
+ { firstYear: 5777, mm: Nisan, dd: 10, desc: YOM_HAALIYAH, chul: true },
5639
+ { firstYear: 5777, mm: Cheshvan, dd: 7, desc: YOM_HAALIYAH_SCHOOL_OBSERVANCE },
5640
+ // https://www.gov.il/he/departments/policies/2012_des5234
5641
+ {
5642
+ firstYear: 5773,
5643
+ mm: months.TEVET,
5644
+ dd: 21,
5645
+ desc: HEBREW_LANGUAGE_DAY,
5646
+ friSatMovetoThu: true,
5647
+ },
5648
+ ];
5990
5649
 
5991
- forEach(callbackFunction, thisArgument = this) {
5992
- for (const [key, value] of this.entriesAscending()) {
5993
- callbackFunction.call(thisArgument, value, key, this);
5994
- }
5995
- }
5650
+ /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
5651
+ class HolidayEvent extends Event {
5652
+ basename() {
5653
+ return this.getDesc()
5654
+ .replace(/ \d{4}$/, '')
5655
+ .replace(/ \(CH''M\)$/, '')
5656
+ .replace(/ \(observed\)$/, '')
5657
+ .replace(/ \(Hoshana Raba\)$/, '')
5658
+ .replace(/ [IV]+$/, '')
5659
+ .replace(/: \d Candles?$/, '')
5660
+ .replace(/: 8th Day$/, '')
5661
+ .replace(/^Erev /, '');
5662
+ }
5663
+ url() {
5664
+ const year = this.getDate().greg().getFullYear();
5665
+ if (year < 100) {
5666
+ return undefined;
5667
+ }
5668
+ const url = 'https://www.hebcal.com/holidays/' +
5669
+ this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
5670
+ '-' +
5671
+ this.urlDateSuffix();
5672
+ return this.getFlags() & flags.IL_ONLY ? url + '?i=on' : url;
5673
+ }
5674
+ urlDateSuffix() {
5675
+ const year = this.getDate().greg().getFullYear();
5676
+ return String(year);
5677
+ }
5678
+ getEmoji() {
5679
+ if (this.emoji) {
5680
+ return this.emoji;
5681
+ }
5682
+ else if (this.getFlags() & flags.SPECIAL_SHABBAT) {
5683
+ return '🕍';
5684
+ }
5685
+ else {
5686
+ return '✡️';
5687
+ }
5688
+ }
5689
+ getCategories() {
5690
+ if (this.cholHaMoedDay) {
5691
+ return ['holiday', 'major', 'cholhamoed'];
5692
+ }
5693
+ const cats = super.getCategories();
5694
+ if (cats[0] !== 'unknown') {
5695
+ return cats;
5696
+ }
5697
+ // Don't depend on flags.MINOR_HOLIDAY always being set. Look for minor holidays.
5698
+ const desc = this.getDesc();
5699
+ switch (desc) {
5700
+ case holidayDesc.LAG_BAOMER:
5701
+ case holidayDesc.LEIL_SELICHOT:
5702
+ case holidayDesc.PESACH_SHENI:
5703
+ case holidayDesc.EREV_PURIM:
5704
+ case holidayDesc.PURIM_KATAN:
5705
+ case holidayDesc.SHUSHAN_PURIM:
5706
+ case holidayDesc.TU_BAV:
5707
+ case holidayDesc.TU_BISHVAT:
5708
+ case holidayDesc.ROSH_HASHANA_LABEHEMOT:
5709
+ return ['holiday', 'minor'];
5710
+ }
5711
+ return ['holiday', 'major'];
5712
+ }
5713
+ /**
5714
+ * Returns (translated) description of this event
5715
+ * @param [locale] Optional locale name (defaults to active locale).
5716
+ */
5717
+ render(locale) {
5718
+ const str = super.render(locale);
5719
+ return str.replace(/'/g, '’');
5720
+ }
5721
+ /**
5722
+ * Returns a brief (translated) description of this event.
5723
+ * For most events, this is the same as render(). For some events, it procudes
5724
+ * a shorter text (e.g. without a time or added description).
5725
+ * @param [locale] Optional locale name (defaults to active locale).
5726
+ */
5727
+ renderBrief(locale) {
5728
+ const str = super.renderBrief(locale);
5729
+ return str.replace(/'/g, '’');
5730
+ }
5731
+ /**
5732
+ * Makes a clone of this Event object
5733
+ * @deprecated
5734
+ */
5735
+ clone() {
5736
+ const ev = new HolidayEvent(this.date, this.desc, this.mask);
5737
+ // overwrite all enumerable properties
5738
+ Object.assign(ev, this);
5739
+ return ev;
5740
+ }
5741
+ }
5742
+ /**
5743
+ * Because Asara B'Tevet often occurs twice in the same Gregorian year,
5744
+ * we subclass HolidayEvent to generate the correct URL.
5745
+ */
5746
+ class AsaraBTevetEvent extends HolidayEvent {
5747
+ urlDateSuffix() {
5748
+ const isoDate = isoDateString(this.getDate().greg());
5749
+ return isoDate.replace(/-/g, '');
5750
+ }
5751
+ }
5752
+ /**
5753
+ * Because Chanukah sometimes starts in December and ends in January,
5754
+ * we subclass HolidayEvent to generate the correct URL.
5755
+ */
5756
+ class ChanukahEvent extends HolidayEvent {
5757
+ urlDateSuffix() {
5758
+ const dt = this.getDate().greg();
5759
+ let year = dt.getFullYear();
5760
+ if (dt.getMonth() === 0) {
5761
+ year--;
5762
+ }
5763
+ return String(year);
5764
+ }
5765
+ }
5766
+ /** Represents Rosh Hashana, the Jewish New Year */
5767
+ class RoshHashanaEvent extends HolidayEvent {
5768
+ /**
5769
+ * @private
5770
+ * @param date Hebrew date event occurs
5771
+ * @param hyear Hebrew year
5772
+ * @param mask optional holiday flags
5773
+ */
5774
+ constructor(date, hyear, mask) {
5775
+ super(date, `Rosh Hashana ${hyear}`, mask);
5776
+ this.hyear = hyear;
5777
+ }
5778
+ /**
5779
+ * Returns (translated) description of this event
5780
+ * @param [locale] Optional locale name (defaults to active locale).
5781
+ */
5782
+ render(locale) {
5783
+ return Locale.gettext('Rosh Hashana', locale) + ' ' + this.hyear;
5784
+ }
5785
+ getEmoji() {
5786
+ return '🍏🍯';
5787
+ }
5788
+ }
5789
+ const roshChodeshStr = 'Rosh Chodesh';
5790
+ /** Represents Rosh Chodesh, the beginning of a new month */
5791
+ class RoshChodeshEvent extends HolidayEvent {
5792
+ /**
5793
+ * Constructs Rosh Chodesh event
5794
+ * @param date Hebrew date event occurs
5795
+ * @param monthName Hebrew month name (not translated)
5796
+ */
5797
+ constructor(date, monthName) {
5798
+ super(date, `${roshChodeshStr} ${monthName}`, flags.ROSH_CHODESH);
5799
+ }
5800
+ /**
5801
+ * Returns (translated) description of this event
5802
+ * @param [locale] Optional locale name (defaults to active locale).
5803
+ */
5804
+ render(locale) {
5805
+ const monthName = this.getDesc().substring(roshChodeshStr.length + 1);
5806
+ const monthName0 = Locale.gettext(monthName, locale);
5807
+ const monthName1 = monthName0.replace(/'/g, '’');
5808
+ return Locale.gettext(roshChodeshStr, locale) + ' ' + monthName1;
5809
+ }
5810
+ basename() {
5811
+ return this.getDesc();
5812
+ }
5813
+ getEmoji() {
5814
+ return this.emoji || '🌒';
5815
+ }
5816
+ }
5996
5817
 
5997
- get [Symbol.toStringTag]() {
5998
- return JSON.stringify([...this.entriesAscending()]);
5999
- }
5818
+ const ykk = 'Yom Kippur Katan';
5819
+ /** YKK is minor day of atonement on the day preceeding each Rosh Chodesh */
5820
+ class YomKippurKatanEvent extends HolidayEvent {
5821
+ /**
5822
+ * @private
5823
+ * @param date Hebrew date event occurs
5824
+ * @param nextMonthName name of the upcoming month
5825
+ */
5826
+ constructor(date, nextMonthName) {
5827
+ super(date, `${ykk} ${nextMonthName}`, flags.MINOR_FAST | flags.YOM_KIPPUR_KATAN);
5828
+ this.nextMonthName = nextMonthName;
5829
+ this.memo = `Minor Day of Atonement on the day preceeding Rosh Chodesh ${nextMonthName}`;
5830
+ }
5831
+ basename() {
5832
+ return this.getDesc();
5833
+ }
5834
+ /**
5835
+ * @param [locale] Optional locale name (defaults to active locale).
5836
+ */
5837
+ render(locale) {
5838
+ const monthName0 = Locale.gettext(this.nextMonthName, locale);
5839
+ const monthName = monthName0.replace(/'/g, '’');
5840
+ return Locale.gettext(ykk, locale) + ' ' + monthName;
5841
+ }
5842
+ /**
5843
+ * @param [locale] Optional locale name (defaults to active locale).
5844
+ */
5845
+ renderBrief(locale) {
5846
+ return Locale.gettext(ykk, locale);
5847
+ }
5848
+ url() {
5849
+ return undefined;
5850
+ }
6000
5851
  }
6001
5852
 
6002
5853
  /*
@@ -6019,939 +5870,1146 @@ class QuickLRU extends Map {
6019
5870
  You should have received a copy of the GNU General Public License
6020
5871
  along with this program. If not, see <http://www.gnu.org/licenses/>.
6021
5872
  */
6022
- /*
6023
- * Many of the following algorithms were taken from hebrew calendar
6024
- * routines by Maimonedes, from his Mishneh Torah, and implemented by
6025
- * Nachum Dershowitz Department of Computer Science
6026
- * (217) 333-4219 University of Illinois at Urbana-Champaign
6027
- * nachum@cs.uiuedu 1304 West Springfield Avenue
6028
- * Urbana, Illinois 61801
6029
- *
6030
- * The routines were included in the emacs 19 distribution.
6031
- *
5873
+ /** @private */
5874
+ function observedInIsrael(ev) {
5875
+ return ev.observedInIsrael();
5876
+ }
5877
+ /** @private */
5878
+ function observedInDiaspora(ev) {
5879
+ return ev.observedInDiaspora();
5880
+ }
5881
+ /** @private */
5882
+ function holidayFilter(il) {
5883
+ return il ? observedInIsrael : observedInDiaspora;
5884
+ }
5885
+ /**
5886
+ * Returns an array of Events on this date (or `undefined` if no events)
5887
+ * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
5888
+ * @param [il] use the Israeli schedule for holidays
6032
5889
  */
6033
- const INCOMPLETE = 0;
6034
- const REGULAR = 1;
6035
- const COMPLETE = 2;
6036
- function yearType(hyear) {
6037
- const longC = HDate.longCheshvan(hyear);
6038
- const shortK = HDate.shortKislev(hyear);
6039
- if (longC && !shortK) {
6040
- return COMPLETE;
6041
- }
6042
- else if (!longC && shortK) {
6043
- return INCOMPLETE;
6044
- }
6045
- else {
6046
- return REGULAR;
5890
+ function getHolidaysOnDate(date, il) {
5891
+ const hd = HDate.isHDate(date) ? date : new HDate(date);
5892
+ const hdStr = hd.toString();
5893
+ const yearMap = getHolidaysForYear_(hd.getFullYear());
5894
+ const events = yearMap.get(hdStr);
5895
+ // if il isn't a boolean return both diaspora + IL for day
5896
+ if (typeof il === 'undefined' || typeof events === 'undefined') {
5897
+ return events;
6047
5898
  }
5899
+ const filtered = events.filter(holidayFilter(il));
5900
+ return filtered;
6048
5901
  }
5902
+ const CHAG = flags.CHAG;
5903
+ const IL_ONLY$1 = flags.IL_ONLY;
5904
+ const LIGHT_CANDLES_TZEIS$2 = flags.LIGHT_CANDLES_TZEIS;
5905
+ const CHANUKAH_CANDLES$1 = flags.CHANUKAH_CANDLES;
5906
+ const MINOR_FAST$1 = flags.MINOR_FAST;
5907
+ const SPECIAL_SHABBAT$1 = flags.SPECIAL_SHABBAT;
5908
+ const MODERN_HOLIDAY$1 = flags.MODERN_HOLIDAY;
5909
+ const MAJOR_FAST$1 = flags.MAJOR_FAST;
5910
+ const MINOR_HOLIDAY$1 = flags.MINOR_HOLIDAY;
5911
+ const EREV$1 = flags.EREV;
5912
+ const SUN = 0;
5913
+ const TUE = 2;
5914
+ const THU = 4;
5915
+ const FRI$1 = 5;
5916
+ const SAT$1 = 6;
5917
+ const NISAN$1 = months.NISAN;
5918
+ const TAMUZ = months.TAMUZ;
5919
+ const AV = months.AV;
5920
+ const TISHREI$1 = months.TISHREI;
5921
+ const KISLEV = months.KISLEV;
5922
+ const TEVET = months.TEVET;
5923
+ const ADAR_I = months.ADAR_I;
5924
+ const ADAR_II = months.ADAR_II;
5925
+ const emojiIsraelFlag = { emoji: '🇮🇱' };
5926
+ const chanukahEmoji = '🕎';
5927
+ const yearCache = new QuickLRU({ maxSize: 400 });
5928
+ const KEYCAP_DIGITS = [
5929
+ '0️⃣',
5930
+ '1️⃣',
5931
+ '2️⃣',
5932
+ '3️⃣',
5933
+ '4️⃣',
5934
+ '5️⃣',
5935
+ '6️⃣',
5936
+ '7️⃣',
5937
+ '8️⃣',
5938
+ '9️⃣',
5939
+ ];
6049
5940
  /**
6050
- * Represents Parashah HaShavua for an entire Hebrew year
5941
+ * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
5942
+ * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
5943
+ * or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
5944
+ * @private
6051
5945
  */
6052
- class Sedra {
6053
- /**
6054
- * Caculates the Parashah HaShavua for an entire Hebrew year
6055
- * @param hyear - Hebrew year (e.g. 5749)
6056
- * @param il - Use Israel sedra schedule (false for Diaspora)
6057
- */
6058
- constructor(hyear, il) {
6059
- hyear = +hyear;
6060
- this.year = hyear;
6061
- const rh0 = new HDate(1, months.TISHREI, hyear);
6062
- const rh = rh0.abs();
6063
- const rhDay = rh0.getDay() + 1;
6064
- // find the first Saturday on or after Rosh Hashana
6065
- this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
6066
- const leap = +HDate.isLeapYear(hyear);
6067
- this.il = Boolean(il);
6068
- const type = yearType(hyear);
6069
- let key = `${leap}${rhDay}${type}`;
6070
- if (types[key]) {
6071
- this.theSedraArray = types[key];
6072
- this.yearKey = key;
6073
- }
6074
- else {
6075
- key = key + +this.il; // cast to num, then concat
6076
- this.theSedraArray = types[key];
6077
- this.yearKey = key;
6078
- }
6079
- if (!this.theSedraArray) {
6080
- throw new Error(`improper sedra year type ${key} calculated for ${hyear}`);
6081
- }
6082
- }
6083
- /**
6084
- * Returns the parsha (or parshiyot) read on Hebrew date
6085
- * @deprecated Use {@link lookup} instead
6086
- * @param hd Hebrew date or R.D. days
6087
- */
6088
- get(hd) {
6089
- return this.lookup(hd).parsha;
6090
- }
6091
- /**
6092
- * Looks up parsha for the date, then returns a translated or transliterated string
6093
- * @deprecated Use {@link lookup} instead
6094
- * @param hd Hebrew date or R.D. days
6095
- * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale
6096
- */
6097
- getString(hd, locale) {
6098
- const parsha = this.get(hd);
6099
- return renderParshaName(parsha, locale);
6100
- }
6101
- /**
6102
- * Checks to see if this day would be a regular parasha HaShavua
6103
- * Torah reading or special holiday reading
6104
- * @deprecated Use {@link lookup} instead
6105
- * @param hd Hebrew date or R.D. days
6106
- */
6107
- isParsha(hd) {
6108
- return !this.lookup(hd).chag;
6109
- }
6110
- /**
6111
- * Returns the date that a parsha occurs
6112
- * or `null` if the parsha doesn't occur this year
6113
- * @param parsha if a `string`, specified with Sephardic transliterations
6114
- * like `'Noach'` or `'Matot-Masei'`. If an array, must be a 1- or 2-element
6115
- * array such as `['Noach']` or `['Matot', 'Masei']`. If a `number`, should
6116
- * be a 0-based parsha index (`0` for Bereshit, `1` for Noach) or a negative
6117
- * number for a doubled parsha (e.g. `-21` for Vayakhel-Pekudei)
6118
- */
6119
- find(parsha) {
6120
- if (typeof parsha === 'number') {
6121
- if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
6122
- throw new RangeError(`Invalid parsha number: ${parsha}`);
6123
- }
6124
- return this.findInternal(parsha);
6125
- }
6126
- else if (typeof parsha === 'string') {
6127
- const num = parsha2id.get(parsha);
6128
- if (typeof num === 'number') {
6129
- return this.find(num);
6130
- }
6131
- else if (parsha.indexOf('-') !== -1) {
6132
- if (parsha === CHMPESACH || parsha === CHMSUKOT) {
6133
- return this.findInternal(parsha);
6134
- }
6135
- return this.find(parsha.split('-'));
6136
- }
6137
- else {
6138
- // try to find Saturday holiday like 'Yom Kippur'
6139
- return this.findInternal(parsha);
6140
- }
6141
- }
6142
- else if (Array.isArray(parsha)) {
6143
- const plen = parsha.length;
6144
- if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
6145
- throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
6146
- }
6147
- if (plen === 1) {
6148
- return this.find(parsha[0]);
6149
- }
6150
- const p1 = parsha[0];
6151
- const p2 = parsha[1];
6152
- const num1 = parsha2id.get(p1);
6153
- const num2 = parsha2id.get(p2);
6154
- if (typeof num1 !== 'number' ||
6155
- typeof num2 !== 'number' ||
6156
- num2 !== num1 + 1 ||
6157
- !isValidDouble(-num1)) {
6158
- throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
6159
- }
6160
- return this.find(-num1);
6161
- }
6162
- return null; /* NOTREACHED */
6163
- }
6164
- findInternal(parsha) {
6165
- const idx = this.theSedraArray.indexOf(parsha);
6166
- if (idx === -1) {
6167
- return null; // doesn't occur this year
6168
- }
6169
- return new HDate(this.firstSaturday + idx * 7);
6170
- }
6171
- /**
6172
- * Returns the date that a parsha (or its doubled or undoubled counterpart)
6173
- * occurs, or `null` if the parsha doesn't occur this year
6174
- */
6175
- findContaining(parsha) {
6176
- const hdate = this.find(parsha);
6177
- if (hdate) {
6178
- return hdate;
6179
- }
6180
- if (typeof parsha === 'number') {
6181
- // a valid negative number (double parsha in a year where they are
6182
- // combined) would've been found above, and a invalid negative number
6183
- // would've thrown an error, so this parsha must be a positive number
6184
- // representing either p1 or p2
6185
- const p1 = -parsha;
6186
- if (isValidDouble(p1)) {
6187
- return this.find(p1);
6188
- }
6189
- else {
6190
- // this must be the second individual parsha of a doubled pair
6191
- // for example 29 for Kedoshim, so check for -28 for Achrei Mot-Kedoshim
6192
- return this.find(p1 + 1);
6193
- }
6194
- }
6195
- else {
6196
- const num = parsha2id.get(parsha);
6197
- if (num) {
6198
- // parsha is either the first or second individual parsha of
6199
- // a pair that is doubled this year
6200
- const p1 = -num;
6201
- if (isValidDouble(p1)) {
6202
- return this.find(p1);
5946
+ function getHolidaysForYear_(year) {
5947
+ if (typeof year !== 'number') {
5948
+ throw new TypeError(`bad Hebrew year: ${year}`);
5949
+ }
5950
+ else if (year < 1 || year > 32658) {
5951
+ throw new RangeError(`Hebrew year ${year} out of range 1-32658`);
5952
+ }
5953
+ const cached = yearCache.get(year);
5954
+ if (cached) {
5955
+ return cached;
5956
+ }
5957
+ const RH = new HDate(1, TISHREI$1, year);
5958
+ const pesach = new HDate(15, NISAN$1, year);
5959
+ const map = new Map();
5960
+ function add(...events) {
5961
+ for (const ev of events) {
5962
+ const key = ev.date.toString();
5963
+ const arr = map.get(key);
5964
+ if (typeof arr === 'object') {
5965
+ if (arr[0].getFlags() & EREV$1) {
5966
+ arr.unshift(ev);
6203
5967
  }
6204
5968
  else {
6205
- return this.find(p1 + 1);
5969
+ arr.push(ev);
6206
5970
  }
6207
5971
  }
6208
5972
  else {
6209
- // this was indeed a doubled parsha, so return date of the first half
6210
- const [p1] = parsha.split('-');
6211
- return this.find(p1);
5973
+ map.set(key, [ev]);
6212
5974
  }
6213
5975
  }
6214
5976
  }
6215
- /**
6216
- * Returns the underlying annual sedra schedule.
6217
- * Used by `@hebcal/triennial`
6218
- */
6219
- getSedraArray() {
6220
- return this.theSedraArray;
5977
+ for (const h of staticHolidays) {
5978
+ const hd = new HDate(h.dd, h.mm, year);
5979
+ const ev = new HolidayEvent(hd, h.desc, h.flags);
5980
+ if (h.emoji)
5981
+ ev.emoji = h.emoji;
5982
+ if (h.chmDay)
5983
+ ev.cholHaMoedDay = h.chmDay;
5984
+ add(ev);
6221
5985
  }
6222
- /**
6223
- * R.D. date of the first Saturday on or after Rosh Hashana
6224
- */
6225
- getFirstSaturday() {
6226
- return this.firstSaturday;
5986
+ // standard holidays that don't shift based on year
5987
+ add(new RoshHashanaEvent(RH, year, CHAG | LIGHT_CANDLES_TZEIS$2));
5988
+ // Variable date holidays
5989
+ const tzomGedaliahDay = RH.getDay() === THU ? 4 : 3;
5990
+ add(new HolidayEvent(new HDate(tzomGedaliahDay, TISHREI$1, year), holidayDesc.TZOM_GEDALIAH, MINOR_FAST$1));
5991
+ // first SAT after RH
5992
+ add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, 7 + RH.abs())), holidayDesc.SHABBAT_SHUVA, SPECIAL_SHABBAT$1));
5993
+ const rchTevet = HDate.shortKislev(year)
5994
+ ? new HDate(1, TEVET, year)
5995
+ : new HDate(30, KISLEV, year);
5996
+ add(new HolidayEvent(rchTevet, holidayDesc.CHAG_HABANOT, MINOR_HOLIDAY$1));
5997
+ // yes, we know Kislev 30-32 are wrong
5998
+ // HDate() corrects the month automatically
5999
+ for (let candles = 2; candles <= 8; candles++) {
6000
+ const hd = new HDate(23 + candles, KISLEV, year);
6001
+ add(new ChanukahEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, {
6002
+ chanukahDay: candles - 1,
6003
+ emoji: chanukahEmoji + KEYCAP_DIGITS[candles],
6004
+ }));
6227
6005
  }
6228
- getYear() {
6229
- return this.year;
6006
+ add(new ChanukahEvent(new HDate(32, KISLEV, year), holidayDesc.CHANUKAH_8TH_DAY, MINOR_HOLIDAY$1, { chanukahDay: 8, emoji: chanukahEmoji }));
6007
+ add(new AsaraBTevetEvent(new HDate(10, TEVET, year), holidayDesc.ASARA_BTEVET, MINOR_FAST$1));
6008
+ const pesachAbs = pesach.abs();
6009
+ add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 43)), holidayDesc.SHABBAT_SHEKALIM, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 30)), holidayDesc.SHABBAT_ZACHOR, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() === TUE ? 33 : 31)), holidayDesc.TAANIT_ESTHER, MINOR_FAST$1));
6010
+ const haChodeshAbs = HDate.dayOnOrBefore(SAT$1, pesachAbs - 14);
6011
+ add(new HolidayEvent(new HDate(haChodeshAbs - 7), holidayDesc.SHABBAT_PARAH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(haChodeshAbs), holidayDesc.SHABBAT_HACHODESH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 1)), holidayDesc.SHABBAT_HAGADOL, SPECIAL_SHABBAT$1), new HolidayEvent(
6012
+ // if the fast falls on Shabbat, move to Thursday
6013
+ pesach.prev().getDay() === SAT$1
6014
+ ? pesach.onOrBefore(THU)
6015
+ : new HDate(14, NISAN$1, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST$1));
6016
+ add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, new HDate(1, TISHREI$1, year + 1).abs() - 4)), holidayDesc.LEIL_SELICHOT, MINOR_HOLIDAY$1, { emoji: '🕍' }));
6017
+ if (pesach.getDay() === SUN) {
6018
+ add(new HolidayEvent(new HDate(16, ADAR_II, year), holidayDesc.PURIM_MESHULASH, MINOR_HOLIDAY$1));
6230
6019
  }
6231
- /**
6232
- * Returns an object describing the parsha on the first Saturday on or after `hd`
6233
- * @param hd Hebrew date or R.D. days
6234
- */
6235
- lookup(hd) {
6236
- const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
6237
- if (isNaN(abs)) {
6238
- throw new TypeError(`Bad date argument: ${hd}`);
6020
+ if (HDate.isLeapYear(year)) {
6021
+ add(new HolidayEvent(new HDate(14, ADAR_I, year), holidayDesc.PURIM_KATAN, MINOR_HOLIDAY$1, { emoji: '🎭️' }));
6022
+ add(new HolidayEvent(new HDate(15, ADAR_I, year), holidayDesc.SHUSHAN_PURIM_KATAN, MINOR_HOLIDAY$1, { emoji: '🎭️' }));
6023
+ }
6024
+ const nisan27dt = dateYomHaShoah(year);
6025
+ if (nisan27dt) {
6026
+ add(new HolidayEvent(nisan27dt, holidayDesc.YOM_HASHOAH, MODERN_HOLIDAY$1));
6027
+ }
6028
+ const yomHaZikaronDt = dateYomHaZikaron(year);
6029
+ if (yomHaZikaronDt) {
6030
+ add(new HolidayEvent(yomHaZikaronDt, holidayDesc.YOM_HAZIKARON, MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(yomHaZikaronDt.next(), holidayDesc.YOM_HAATZMA_UT, MODERN_HOLIDAY$1, emojiIsraelFlag));
6031
+ }
6032
+ for (const h of staticModernHolidays) {
6033
+ if (year >= h.firstYear) {
6034
+ let hd = new HDate(h.dd, h.mm, year);
6035
+ const dow = hd.getDay();
6036
+ if (h.friSatMovetoThu && (dow === FRI$1 || dow === SAT$1)) {
6037
+ hd = hd.onOrBefore(THU);
6038
+ }
6039
+ else if (h.friPostponeToSun && dow === FRI$1) {
6040
+ hd = new HDate(hd.abs() + 2);
6041
+ }
6042
+ else if (h.satPostponeToSun && dow === SAT$1) {
6043
+ hd = hd.next();
6044
+ }
6045
+ const mask = h.chul ? MODERN_HOLIDAY$1 : MODERN_HOLIDAY$1 | IL_ONLY$1;
6046
+ const ev = new HolidayEvent(hd, h.desc, mask);
6047
+ if (!h.suppressEmoji) {
6048
+ ev.emoji = '🇮🇱';
6049
+ }
6050
+ add(ev);
6239
6051
  }
6240
- // find the first saturday on or after today's date
6241
- const saturday = HDate.dayOnOrBefore(6, abs + 6);
6242
- const weekNum = (saturday - this.firstSaturday) / 7;
6243
- const index = this.theSedraArray[weekNum];
6244
- if (typeof index === 'undefined') {
6245
- const sedra = getSedra(this.year + 1, this.il);
6246
- return sedra.lookup(saturday); // must be next year
6052
+ }
6053
+ let tamuz17 = new HDate(17, TAMUZ, year);
6054
+ let tamuz17attrs;
6055
+ if (tamuz17.getDay() === SAT$1) {
6056
+ tamuz17 = new HDate(18, TAMUZ, year);
6057
+ tamuz17attrs = { observed: true };
6058
+ }
6059
+ add(new HolidayEvent(tamuz17, holidayDesc.TZOM_TAMMUZ, MINOR_FAST$1, tamuz17attrs));
6060
+ let av9dt = new HDate(9, AV, year);
6061
+ let av9title = holidayDesc.TISHA_BAV;
6062
+ let av9attrs;
6063
+ if (av9dt.getDay() === SAT$1) {
6064
+ av9dt = av9dt.next();
6065
+ av9attrs = { observed: true };
6066
+ av9title += ' (observed)';
6067
+ }
6068
+ const av9abs = av9dt.abs();
6069
+ add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT$1), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV$1 | MAJOR_FAST$1, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST$1, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT$1));
6070
+ const monthsInYear = HDate.monthsInYear(year);
6071
+ for (let month = 1; month <= monthsInYear; month++) {
6072
+ const monthName = HDate.getMonthName(month, year);
6073
+ if ((month === NISAN$1
6074
+ ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1)
6075
+ : HDate.daysInMonth(month - 1, year)) === 30) {
6076
+ add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
6077
+ add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
6247
6078
  }
6248
- const hdate = new HDate(saturday);
6249
- if (typeof index === 'string') {
6250
- // Shabbat has a chag. Return a description
6251
- return { parsha: [index], chag: true, hdate };
6079
+ else if (month !== TISHREI$1) {
6080
+ add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
6252
6081
  }
6253
- if (index >= 0) {
6254
- return { parsha: [parshiot[index]], chag: false, num: index + 1, hdate };
6082
+ }
6083
+ // Begin: Yom Kippur Katan
6084
+ // start at Iyyar because one may not fast during Nisan
6085
+ for (let month = months.IYYAR; month <= monthsInYear; month++) {
6086
+ const nextMonth = month + 1;
6087
+ // Yom Kippur Katan is not observed on the day before Rosh Hashanah.
6088
+ // Not observed prior to Rosh Chodesh Cheshvan because Yom Kippur has just passed.
6089
+ // Not observed before Rosh Chodesh Tevet, because that day is Hanukkah.
6090
+ if (nextMonth === TISHREI$1 ||
6091
+ nextMonth === months.CHESHVAN ||
6092
+ nextMonth === TEVET) {
6093
+ continue;
6255
6094
  }
6256
- const p1 = D(index); // undouble the parsha
6257
- return {
6258
- parsha: [parshiot[p1], parshiot[p1 + 1]],
6259
- chag: false,
6260
- num: [p1 + 1, p1 + 2],
6261
- hdate,
6262
- };
6095
+ let ykk = new HDate(29, month, year);
6096
+ const dow = ykk.getDay();
6097
+ if (dow === FRI$1 || dow === SAT$1) {
6098
+ ykk = ykk.onOrBefore(THU);
6099
+ }
6100
+ const nextMonthName = HDate.getMonthName(nextMonth, year);
6101
+ const ev = new YomKippurKatanEvent(ykk, nextMonthName);
6102
+ add(ev);
6263
6103
  }
6104
+ const sedra = getSedra(year, false);
6105
+ const beshalachHd = sedra.find(15);
6106
+ add(new HolidayEvent(beshalachHd, holidayDesc.SHABBAT_SHIRAH, SPECIAL_SHABBAT$1));
6107
+ // Birkat Hachamah appears only once every 28 years
6108
+ const birkatHaChama = getBirkatHaChama(year);
6109
+ if (birkatHaChama) {
6110
+ const hd = new HDate(birkatHaChama);
6111
+ add(new HolidayEvent(hd, holidayDesc.BIRKAT_HACHAMAH, MINOR_HOLIDAY$1, { emoji: '☀️' }));
6112
+ }
6113
+ yearCache.set(year, map);
6114
+ return map;
6264
6115
  }
6265
6116
  /**
6266
- * The 54 parshiyot of the Torah as transilterated strings.
6267
- * parshiot[0] == 'Bereshit', parshiot[1] == 'Noach', parshiot[52] == "Ha'azinu".
6268
- * @readonly
6269
- * @type {string[]}
6270
- */
6271
- const parshiot = [
6272
- 'Bereshit',
6273
- 'Noach',
6274
- 'Lech-Lecha',
6275
- 'Vayera',
6276
- 'Chayei Sara',
6277
- 'Toldot',
6278
- 'Vayetzei',
6279
- 'Vayishlach',
6280
- 'Vayeshev',
6281
- 'Miketz',
6282
- 'Vayigash',
6283
- 'Vayechi',
6284
- 'Shemot',
6285
- 'Vaera',
6286
- 'Bo',
6287
- 'Beshalach',
6288
- 'Yitro',
6289
- 'Mishpatim',
6290
- 'Terumah',
6291
- 'Tetzaveh',
6292
- 'Ki Tisa',
6293
- 'Vayakhel',
6294
- 'Pekudei',
6295
- 'Vayikra',
6296
- 'Tzav',
6297
- 'Shmini',
6298
- 'Tazria',
6299
- 'Metzora',
6300
- 'Achrei Mot',
6301
- 'Kedoshim',
6302
- 'Emor',
6303
- 'Behar',
6304
- 'Bechukotai',
6305
- 'Bamidbar',
6306
- 'Nasso',
6307
- "Beha'alotcha",
6308
- "Sh'lach",
6309
- 'Korach',
6310
- 'Chukat',
6311
- 'Balak',
6312
- 'Pinchas',
6313
- 'Matot',
6314
- 'Masei',
6315
- 'Devarim',
6316
- 'Vaetchanan',
6317
- 'Eikev',
6318
- "Re'eh",
6319
- 'Shoftim',
6320
- 'Ki Teitzei',
6321
- 'Ki Tavo',
6322
- 'Nitzavim',
6323
- 'Vayeilech',
6324
- "Ha'azinu",
6325
- ];
6326
- // 0-based parsha IDs
6327
- const parsha2id = new Map();
6328
- for (let id = 0; id < parshiot.length; id++) {
6329
- const name = parshiot[id];
6330
- parsha2id.set(name, id);
6331
- }
6332
- // 0-based parsha IDs
6333
- const doubles = [
6334
- 21, // Vayakhel-Pekudei
6335
- 26, // Tazria-Metzora
6336
- 28, // Achrei Mot-Kedoshim
6337
- 31, // Behar-Bechukotai
6338
- 38, // Chukat-Balak
6339
- 41, // Matot-Masei
6340
- 50, // Nitzavim-Vayeilech
6341
- ];
6342
- /**
6117
+ * Birkat Hachamah appears only once every 28 years.
6118
+ * Although almost always in Nisan, it can occur in Adar II.
6119
+ * - 27 Adar II 5461 (Gregorian year 1701)
6120
+ * - 29 Adar II 5993 (Gregorian year 2233)
6121
+ *
6122
+ * Due to drift, this will eventually slip into Iyyar
6123
+ * - 2 Iyyar 7141 (Gregorian year 3381)
6343
6124
  * @private
6344
- * @param id a negative number
6345
6125
  */
6346
- function isValidDouble(id) {
6347
- return doubles.includes(-id);
6126
+ function getBirkatHaChama(year) {
6127
+ const leap = HDate.isLeapYear(year);
6128
+ const startMonth = leap ? ADAR_II : NISAN$1;
6129
+ const startDay = leap ? 20 : 1;
6130
+ const baseRd = HDate.hebrew2abs(year, startMonth, startDay);
6131
+ for (let day = 0; day <= 40; day++) {
6132
+ const abs = baseRd + day;
6133
+ const elapsed = abs + 1373429;
6134
+ if (elapsed % 10227 === 172) {
6135
+ return abs;
6136
+ }
6137
+ }
6138
+ return 0;
6348
6139
  }
6349
6140
  /**
6350
- * parsha doubler/undoubler
6351
- * @private
6352
- * @param p
6141
+ * Returns an array of holidays for the year
6142
+ * @param year Hebrew year
6143
+ * @param il use the Israeli schedule for holidays
6353
6144
  */
6354
- function D(p) {
6355
- return -p;
6145
+ function getHolidaysForYearArray(year, il) {
6146
+ const yearMap = getHolidaysForYear_(year);
6147
+ const startAbs = HDate.hebrew2abs(year, TISHREI$1, 1);
6148
+ const endAbs = HDate.hebrew2abs(year + 1, TISHREI$1, 1) - 1;
6149
+ let events = [];
6150
+ const myFilter = il ? observedInIsrael : observedInDiaspora;
6151
+ for (let absDt = startAbs; absDt <= endAbs; absDt++) {
6152
+ const hd = new HDate(absDt);
6153
+ const holidays = yearMap.get(hd.toString());
6154
+ if (holidays) {
6155
+ const filtered = holidays.filter(myFilter);
6156
+ events = events.concat(filtered);
6157
+ }
6158
+ }
6159
+ return events;
6160
+ }
6161
+
6162
+ const LIGHT_CANDLES$2 = flags.LIGHT_CANDLES | flags.LIGHT_CANDLES_TZEIS;
6163
+ function isTomorrowShabbosOrYomTov(dow, events) {
6164
+ if (dow === 5) {
6165
+ return true;
6166
+ }
6167
+ const erev = events.find(ev => ev.getFlags() & LIGHT_CANDLES$2);
6168
+ if (erev) {
6169
+ return true;
6170
+ }
6171
+ return false;
6356
6172
  }
6357
- const RH = 'Rosh Hashana'; // 0
6358
- const YK = 'Yom Kippur'; // 1
6359
- const SUKKOT = 'Sukkot'; // 0
6360
- const CHMSUKOT = 'Sukkot Shabbat Chol ha-Moed'; // 0
6361
- const SHMINI = 'Shmini Atzeret'; // 0
6362
- const PESACH = 'Pesach'; // 25
6363
- const PESACH1 = 'Pesach I';
6364
- const CHMPESACH = 'Pesach Shabbat Chol ha-Moed'; // 25
6365
- const PESACH7 = 'Pesach VII'; // 25
6366
- const PESACH8 = 'Pesach VIII';
6367
- const SHAVUOT = 'Shavuot'; // 33
6368
6173
  /**
6369
- * Returns an array from start to end
6370
- * @private
6371
- * @param start beginning number, inclusive
6372
- * @param stop ending number, inclusive
6174
+ * Returns true if it is <em>Shabbos</em> or if it is a <em>Yom Tov</em> day that has a <em>melacha</em> (work) prohibition.
6175
+ *
6176
+ * @return if the day is a <em>Yom Tov</em> that is <em>assur bemlacha</em> or <em>Shabbos</em>
6373
6177
  */
6374
- function range$1(start, stop) {
6375
- return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
6178
+ function isTodayAssurBemelacha(dow, events) {
6179
+ if (dow === 6) {
6180
+ return true;
6181
+ }
6182
+ const chag = events.find(ev => ev.getFlags() & flags.CHAG);
6183
+ if (chag) {
6184
+ return true;
6185
+ }
6186
+ return false;
6376
6187
  }
6377
- const yearStartVayeilech = [51, 52, CHMSUKOT];
6378
- const yearStartHaazinu = [52, YK, CHMSUKOT];
6379
- const yearStartRH = [RH, 52, SUKKOT, SHMINI];
6380
- const r020 = range$1(0, 20);
6381
- const r027 = range$1(0, 27);
6382
- const r3340 = range$1(33, 40);
6383
- const r4349 = range$1(43, 49);
6384
- const r4350 = range$1(43, 50);
6385
6188
  /**
6386
- * The ordinary year types (keviot)
6387
- * names are leap/nonleap - day - incomplete/regular/complete - diaspora/Israel
6388
- * @private
6389
- * @readonly
6189
+ * Utility method to determine if the date and time has a <em>melacha</em> (work) prohibition.
6190
+ * Although there are many opinions on the time of <em>tzais</em>, for simplicity
6191
+ * this function uses solar depression of 8.5 degrees.
6192
+ *
6193
+ * @return `true` if <em>melacha</em> is prohibited or `false` if it is not.
6390
6194
  */
6391
- const types = {
6392
- /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
6393
- * Kislev each have 29 days), and has Passover start on Tuesday. */
6394
- // e.g. 5753
6395
- '020': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
6396
- /* Hebrew year that starts on Monday, is `complete' (Heshvan and
6397
- * Kislev each have 30 days), and has Passover start on Thursday. */
6398
- // e.g. 5756
6399
- '0220': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
6400
- /* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
6401
- * days and Kislev has 30 days), and has Passover start on Saturday. */
6402
- // e.g. 5701
6403
- '0510': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
6404
- /* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
6405
- * days and Kislev has 30 days), and has Passover start on Saturday. */
6406
- // e.g. 5745
6407
- '0511': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), range$1(30, 40), D(41), r4350),
6408
- /* Hebrew year that starts on Thursday, is `complete' (Heshvan and
6409
- * Kislev each have 30 days), and has Passover start on Sunday. */
6410
- // e.g. 5754
6411
- '052': yearStartHaazinu.concat(range$1(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
6412
- /* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
6413
- * each have 29 days), and has Passover start on Sunday. */
6414
- // e.g. 5761
6415
- '070': yearStartRH.concat(r020, D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
6416
- /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
6417
- * Kislev each have 30 days), and has Passover start on Tuesday. */
6418
- // e.g. 5716
6419
- '072': yearStartRH.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
6420
- /* -- The leap year types (keviot) -- */
6421
- /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
6422
- * Kislev each have 29 days), and has Passover start on Thursday. */
6423
- // e.g. 5746
6424
- '1200': yearStartVayeilech.concat(r027, CHMPESACH, range$1(28, 33), SHAVUOT, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
6425
- /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
6426
- * Kislev each have 29 days), and has Passover start on Thursday. */
6427
- // e.g. 5746
6428
- '1201': yearStartVayeilech.concat(r027, CHMPESACH, range$1(28, 40), D(41), r4349, D(50)),
6429
- /* Hebrew year that starts on Monday, is `complete' (Heshvan and
6430
- * Kislev each have 30 days), and has Passover start on Saturday. */
6431
- // e.g.5752
6432
- '1220': yearStartVayeilech.concat(r027, PESACH1, PESACH8, range$1(28, 40), D(41), r4350),
6433
- /* Hebrew year that starts on Monday, is `complete' (Heshvan and
6434
- * Kislev each have 30 days), and has Passover start on Saturday. */
6435
- // e.g.5752
6436
- '1221': yearStartVayeilech.concat(r027, PESACH, range$1(28, 50)),
6437
- /* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
6438
- * Kislev both have 29 days), and has Passover start on Sunday. */
6439
- // e.g. 5768
6440
- '150': yearStartHaazinu.concat(range$1(0, 28), PESACH7, range$1(29, 50)),
6441
- /* Hebrew year that starts on Thursday, is `complete' (Heshvan and
6442
- * Kislev both have 30 days), and has Passover start on Tuesday. */
6443
- // eg. 5771
6444
- '152': yearStartHaazinu.concat(range$1(0, 28), CHMPESACH, range$1(29, 49), D(50)),
6445
- /* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
6446
- * Kislev each have 29 days), and has Passover start on Tuesday. */
6447
- // e.g.5757
6448
- '170': yearStartRH.concat(r027, CHMPESACH, range$1(28, 40), D(41), r4349, D(50)),
6449
- /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
6450
- * Kislev each have 30 days), and has Passover start on Thursday. */
6451
- '1720': yearStartRH.concat(r027, CHMPESACH, range$1(28, 33), SHAVUOT, range$1(34, 37), D(38), 40, D(41), r4349, D(50)),
6195
+ function isAssurBemlacha(currentTime, location, useElevation) {
6196
+ const zmanim = new Zmanim(location, currentTime, useElevation);
6197
+ // erev shabbos, YT or YT sheni and after shkiah
6198
+ const sunset = zmanim.sunset();
6199
+ const sunsetMillis = sunset.getTime();
6200
+ if (isNaN(sunsetMillis)) {
6201
+ throw new Error('Could not determine sunset');
6202
+ }
6203
+ // erev shabbos, YT or YT sheni and after shkiah
6204
+ const il = location.getIsrael();
6205
+ const currentMillis = currentTime.getTime();
6206
+ const hd = new HDate(currentTime);
6207
+ const dow = hd.getDay();
6208
+ const events = getHolidaysOnDate(hd, il) || [];
6209
+ if (isTomorrowShabbosOrYomTov(dow, events) && currentMillis >= sunsetMillis) {
6210
+ return true;
6211
+ }
6212
+ // is shabbos or YT and it is before tzais
6213
+ if (isTodayAssurBemelacha(dow, events)) {
6214
+ const tzais = zmanim.tzeit();
6215
+ const tzaisMillis = tzais.getTime();
6216
+ return currentMillis <= tzaisMillis;
6217
+ }
6218
+ return false;
6219
+ }
6220
+
6221
+ const hour12cc = {
6222
+ US: 1,
6223
+ CA: 1,
6224
+ BR: 1,
6225
+ AU: 1,
6226
+ NZ: 1,
6227
+ DO: 1,
6228
+ PR: 1,
6229
+ GR: 1,
6230
+ IN: 1,
6231
+ KR: 1,
6232
+ NP: 1,
6233
+ ZA: 1,
6452
6234
  };
6453
- /* Hebrew year that starts on Monday, is `complete' (Heshvan and
6454
- * Kislev each have 30 days), and has Passover start on Thursday. */
6455
- types['0221'] = types['020'];
6456
- /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
6457
- * days and Kislev has 30 days), and has Passover start on Thursday. */
6458
- // e.g. 5715
6459
- types['0310'] = types['0220'];
6460
- /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
6461
- * days and Kislev has 30 days), and has Passover start on Thursday. */
6462
- types['0311'] = types['020'];
6463
- /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
6464
- * days and Kislev has 30 days), and has Passover start on Saturday. */
6465
- // e.g. 5715
6466
- types['1310'] = types['1220'];
6467
- /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
6468
- * days and Kislev has 30 days), and has Passover start on Saturday. */
6469
- types['1311'] = types['1221'];
6470
- /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
6471
- * Kislev each have 30 days), and has Passover start on Thursday. */
6472
- types['1721'] = types['170'];
6473
- const sedraCache = new QuickLRU({ maxSize: 400 });
6474
6235
  /**
6475
- * Convenience function to create an instance of `Sedra` or reuse a previously
6476
- * created and cached instance.
6477
- * @param hyear
6478
- * @param il
6236
+ * @private
6237
+ * @param timeStr - original time like "20:30"
6238
+ * @param suffix - "p" or "pm" or " P.M.". Add leading space if you want it
6239
+ * @param options
6479
6240
  */
6480
- function getSedra(hyear, il) {
6481
- const cacheKey = `${hyear}-${il ? 1 : 0}`;
6482
- let sedra = sedraCache.get(cacheKey);
6483
- if (!sedra) {
6484
- sedra = new Sedra(hyear, il);
6485
- sedraCache.set(cacheKey, sedra);
6241
+ function reformatTimeStr(timeStr, suffix, options) {
6242
+ var _a;
6243
+ if (typeof timeStr !== 'string')
6244
+ throw new TypeError(`Bad timeStr: ${timeStr}`);
6245
+ const cc = ((_a = options === null || options === void 0 ? void 0 : options.location) === null || _a === void 0 ? void 0 : _a.getCountryCode()) || ((options === null || options === void 0 ? void 0 : options.il) ? 'IL' : 'US');
6246
+ const hour12 = options === null || options === void 0 ? void 0 : options.hour12;
6247
+ if (typeof hour12 !== 'undefined' && !hour12) {
6248
+ return timeStr;
6249
+ }
6250
+ if (!hour12 && typeof hour12cc[cc] === 'undefined') {
6251
+ return timeStr;
6252
+ }
6253
+ const hm = timeStr.split(':');
6254
+ let hour = parseInt(hm[0], 10);
6255
+ if (hour < 12 && suffix) {
6256
+ suffix = suffix.replace('p', 'a').replace('P', 'A');
6257
+ if (hour === 0) {
6258
+ hour = 12;
6259
+ }
6260
+ }
6261
+ else if (hour > 12) {
6262
+ hour = hour % 12;
6263
+ }
6264
+ else if (hour === 0) {
6265
+ hour = '00';
6266
+ }
6267
+ return `${hour}:${hm[1]}${suffix}`;
6268
+ }
6269
+
6270
+ /** An event that has an `eventTime` and `eventTimeStr` */
6271
+ class TimedEvent extends Event {
6272
+ /**
6273
+ * @param desc Description (not translated)
6274
+ */
6275
+ constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
6276
+ super(date, desc, mask);
6277
+ this.eventTime = Zmanim.roundTime(eventTime);
6278
+ this.location = location;
6279
+ const timeFormat = location.getTimeFormatter();
6280
+ this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
6281
+ const opts = Object.assign(Object.assign({}, options), { location });
6282
+ this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
6283
+ if (typeof linkedEvent !== 'undefined') {
6284
+ this.linkedEvent = linkedEvent;
6285
+ }
6486
6286
  }
6487
- return sedra;
6488
- }
6489
-
6490
- /**
6491
- * Represents one of 54 weekly Torah portions, always on a Saturday
6492
- */
6493
- class ParshaEvent extends Event {
6494
6287
  /**
6495
- * @param parsha - untranslated name of single or double parsha,
6496
- * such as ['Bereshit'] or ['Achrei Mot', 'Kedoshim']
6288
+ * @param [locale] Optional locale name (defaults to active locale).
6497
6289
  */
6498
- constructor(date, parsha, il = false, num = -1) {
6499
- if (!Array.isArray(parsha) || parsha.length === 0 || parsha.length > 2) {
6500
- throw new TypeError('Bad parsha argument');
6290
+ render(locale) {
6291
+ return Locale.gettext(this.getDesc(), locale) + ': ' + this.fmtTime;
6292
+ }
6293
+ /**
6294
+ * Returns translation of "Candle lighting" without the time.
6295
+ * @param [locale] Optional locale name (defaults to active locale).
6296
+ */
6297
+ renderBrief(locale) {
6298
+ return Locale.gettext(this.getDesc(), locale);
6299
+ }
6300
+ getCategories() {
6301
+ const desc = this.getDesc();
6302
+ switch (desc) {
6303
+ // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
6304
+ case 'Candle lighting':
6305
+ return ['candles'];
6306
+ // YOM_TOV_ENDS
6307
+ case 'Havdalah':
6308
+ return ['havdalah'];
6309
+ // flags.MINOR_FAST or flags.MAJOR_FAST
6310
+ case 'Fast begins':
6311
+ case 'Fast ends':
6312
+ return ['zmanim', 'fast'];
6313
+ }
6314
+ /* NOTREACHED */
6315
+ return ['unknown'];
6316
+ }
6317
+ }
6318
+ /** Candle lighting before Shabbat or holiday */
6319
+ class CandleLightingEvent extends TimedEvent {
6320
+ constructor(date, mask, eventTime, location, linkedEvent, options) {
6321
+ super(date, 'Candle lighting', mask, eventTime, location, linkedEvent, options);
6322
+ }
6323
+ getEmoji() {
6324
+ return '🕯️';
6325
+ }
6326
+ }
6327
+ /** Havdalah after Shabbat or holiday */
6328
+ class HavdalahEvent extends TimedEvent {
6329
+ constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
6330
+ super(date, 'Havdalah', mask, eventTime, location, linkedEvent, options);
6331
+ if (havdalahMins) {
6332
+ this.havdalahMins = havdalahMins;
6501
6333
  }
6502
- const desc = 'Parashat ' + parsha.join('-');
6503
- super(date, desc, flags.PARSHA_HASHAVUA);
6504
- this.parsha = parsha;
6505
- this.il = Boolean(il);
6506
- this.num = num || -1;
6507
6334
  }
6508
6335
  /**
6509
- * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
6336
+ * @param [locale] Optional locale name (defaults to active locale).
6510
6337
  */
6511
6338
  render(locale) {
6512
- return renderParshaName(this.parsha, locale);
6513
- }
6514
- basename() {
6515
- return this.parsha.join('-');
6339
+ return this.renderBrief(locale) + ': ' + this.fmtTime;
6516
6340
  }
6517
- url() {
6518
- const year = this.getDate().greg().getFullYear();
6519
- if (year < 100) {
6520
- return undefined;
6341
+ /**
6342
+ * Returns translation of "Havdalah" without the time.
6343
+ * @param [locale] Optional locale name (defaults to active locale).
6344
+ */
6345
+ renderBrief(locale) {
6346
+ let str = Locale.gettext(this.getDesc(), locale);
6347
+ if (this.havdalahMins) {
6348
+ const min = Locale.gettext('min', locale);
6349
+ str += ` (${this.havdalahMins} ${min})`;
6521
6350
  }
6522
- const dt = this.urlDateSuffix();
6523
- const url = 'https://www.hebcal.com/sedrot/' +
6524
- this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
6525
- '-' +
6526
- dt;
6527
- return this.il ? url + '?i=on' : url;
6351
+ return str;
6528
6352
  }
6529
- urlDateSuffix() {
6530
- const isoDate = isoDateString(this.getDate().greg());
6531
- return isoDate.replace(/-/g, '');
6353
+ getEmoji() {
6354
+ return '✨';
6532
6355
  }
6533
6356
  }
6534
6357
 
6358
+ /* eslint-disable max-len */
6359
+ const LIGHT_CANDLES$1 = flags.LIGHT_CANDLES;
6360
+ const LIGHT_CANDLES_TZEIS$1 = flags.LIGHT_CANDLES_TZEIS;
6535
6361
  /**
6536
- * Calculates weekly Torah Reading on Saturdays for entire year
6537
- * @param year Hebrew year
6538
- * @param il Israel (false for Diaspora)
6539
- * @returns an array of `ParshaEvent` occurring on Saturdays that contain a regular
6540
- * (non-holiday) Parashat HaShavua
6362
+ * @private
6541
6363
  */
6542
- function parshaYear(year, il) {
6543
- const sedra = getSedra(year, il);
6544
- const startAbs = sedra.getFirstSaturday();
6545
- const endAbs = HDate.hebrew2abs(year, months.ELUL, 29);
6546
- const events = [];
6547
- for (let absDt = startAbs; absDt <= endAbs; absDt += 7) {
6548
- const parsha = sedra.lookup(absDt);
6549
- if (!parsha.chag) {
6550
- const ev = new ParshaEvent(parsha.hdate, parsha.parsha, il, parsha.num);
6551
- events.push(ev);
6364
+ function makeCandleEvent(ev, hd, options, isFriday, isSaturday) {
6365
+ let havdalahTitle = false;
6366
+ let useHavdalahOffset = isSaturday;
6367
+ let mask = ev ? ev.getFlags() : LIGHT_CANDLES$1;
6368
+ if (typeof ev !== 'undefined') {
6369
+ // if linked event && dow == FRI, use Candle lighting time & title
6370
+ if (!isFriday) {
6371
+ if (mask & (LIGHT_CANDLES_TZEIS$1 | flags.CHANUKAH_CANDLES)) {
6372
+ useHavdalahOffset = true;
6373
+ }
6374
+ else if (mask & flags.YOM_TOV_ENDS) {
6375
+ havdalahTitle = true;
6376
+ useHavdalahOffset = true;
6377
+ }
6552
6378
  }
6553
6379
  }
6554
- return events;
6380
+ else if (isSaturday) {
6381
+ havdalahTitle = true;
6382
+ mask = LIGHT_CANDLES_TZEIS$1;
6383
+ }
6384
+ // if Havdalah offset is 0 or undefined, we'll use tzeit time
6385
+ const offset = useHavdalahOffset
6386
+ ? Number(options.havdalahMins)
6387
+ : Number(options.candleLightingMins);
6388
+ const location = options.location;
6389
+ const useElevation = Boolean(options.useElevation);
6390
+ const zmanim = new Zmanim(location, hd, useElevation);
6391
+ const time = useHavdalahOffset && !offset
6392
+ ? zmanim.tzeit(options.havdalahDeg)
6393
+ : zmanim.sunsetOffset(offset, true);
6394
+ if (isNaN(time.getTime())) {
6395
+ return undefined; // no sunset
6396
+ }
6397
+ if (havdalahTitle) {
6398
+ return new HavdalahEvent(hd, mask, time, location, options.havdalahMins, ev, options);
6399
+ }
6400
+ else {
6401
+ mask |= LIGHT_CANDLES$1;
6402
+ return new CandleLightingEvent(hd, mask, time, location, ev, options);
6403
+ }
6404
+ }
6405
+ const FAST_BEGINS = 'Fast begins';
6406
+ const FAST_ENDS = 'Fast ends';
6407
+ /** A fast day also contains a start and end time */
6408
+ class FastDayEvent extends HolidayEvent {
6409
+ constructor(linkedEvent, startEvent, endEvent) {
6410
+ super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.getFlags());
6411
+ this.linkedEvent = linkedEvent;
6412
+ this.startEvent = startEvent;
6413
+ this.endEvent = endEvent;
6414
+ }
6415
+ render(locale) {
6416
+ return this.linkedEvent.render(locale);
6417
+ }
6418
+ renderBrief(locale) {
6419
+ return this.linkedEvent.renderBrief(locale);
6420
+ }
6421
+ urlDateSuffix() {
6422
+ return this.linkedEvent.urlDateSuffix();
6423
+ }
6424
+ url() {
6425
+ return this.linkedEvent.url();
6426
+ }
6427
+ getEmoji() {
6428
+ return this.linkedEvent.getEmoji();
6429
+ }
6430
+ getCategories() {
6431
+ return this.linkedEvent.getCategories();
6432
+ }
6555
6433
  }
6556
-
6557
- const SUN$1 = 0;
6558
- const TUE$1 = 2;
6559
- const FRI$2 = 5;
6560
- const SAT$2 = 6;
6561
- const NISAN$2 = months.NISAN;
6562
- const IYYAR = months.IYYAR;
6563
6434
  /**
6564
- * Yom HaShoah first observed in 1951.
6565
- * When the actual date of Yom Hashoah falls on a Friday, the
6566
- * state of Israel observes Yom Hashoah on the preceding
6567
- * Thursday. When it falls on a Sunday, Yom Hashoah is observed
6568
- * on the following Monday.
6569
- * http://www.ushmm.org/remembrance/dor/calendar/
6435
+ * Makes a pair of events representing fast start and end times
6570
6436
  * @private
6571
- * @param year
6572
6437
  */
6573
- function dateYomHaShoah(year) {
6574
- if (year < 5711) {
6575
- return null;
6438
+ function makeFastStartEnd(ev, options) {
6439
+ const desc = ev.getDesc();
6440
+ if (desc === 'Yom Kippur') {
6441
+ throw new RangeError('YK does not require this function');
6576
6442
  }
6577
- let nisan27dt = new HDate(27, NISAN$2, year);
6578
- if (nisan27dt.getDay() === FRI$2) {
6579
- nisan27dt = new HDate(26, NISAN$2, year);
6443
+ const hd = ev.getDate();
6444
+ const dt = hd.greg();
6445
+ const location = options.location;
6446
+ const fastEndDeg = options.fastEndDeg;
6447
+ const useElevation = Boolean(options.useElevation);
6448
+ const zmanim = new Zmanim(location, dt, useElevation);
6449
+ let startEvent;
6450
+ let endEvent;
6451
+ if (desc === "Erev Tish'a B'Av") {
6452
+ const sunset = zmanim.sunset();
6453
+ if (!isNaN(sunset.getTime())) {
6454
+ startEvent = makeTimedEvent(ev, sunset, FAST_BEGINS, options);
6455
+ }
6580
6456
  }
6581
- else if (nisan27dt.getDay() === SUN$1) {
6582
- nisan27dt = new HDate(28, NISAN$2, year);
6457
+ else if (desc.startsWith("Tish'a B'Av")) {
6458
+ const tzeit = zmanim.tzeit(fastEndDeg);
6459
+ if (!isNaN(tzeit.getTime())) {
6460
+ endEvent = makeTimedEvent(ev, tzeit, FAST_ENDS, options);
6461
+ }
6462
+ }
6463
+ else {
6464
+ const dawn = zmanim.alotHaShachar();
6465
+ if (!isNaN(dawn.getTime())) {
6466
+ startEvent = makeTimedEvent(ev, dawn, FAST_BEGINS, options);
6467
+ }
6468
+ if (dt.getDay() !== 5 &&
6469
+ !(hd.getDate() === 14 && hd.getMonth() === months.NISAN)) {
6470
+ const tzeit = zmanim.tzeit(fastEndDeg);
6471
+ if (!isNaN(tzeit.getTime())) {
6472
+ endEvent = makeTimedEvent(ev, tzeit, FAST_ENDS, options);
6473
+ }
6474
+ }
6475
+ }
6476
+ const ev2 = new FastDayEvent(ev, startEvent, endEvent);
6477
+ // copy properties such as memo or emoji
6478
+ Object.assign(ev2, ev);
6479
+ return ev2;
6480
+ }
6481
+ /**
6482
+ * @private
6483
+ */
6484
+ function makeTimedEvent(ev, time, desc, options) {
6485
+ const location = options.location;
6486
+ const hd = ev.getDate();
6487
+ return new TimedEvent(hd, desc, ev.getFlags(), time, location, ev, options);
6488
+ }
6489
+ class TimedChanukahEvent extends ChanukahEvent {
6490
+ constructor(date, desc, mask, eventTime, location) {
6491
+ super(date, desc, mask);
6492
+ this.eventTime = Zmanim.roundTime(eventTime);
6493
+ const timeFormat = location.getTimeFormatter();
6494
+ this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
6495
+ this.location = location;
6583
6496
  }
6584
- return nisan27dt;
6585
6497
  }
6586
6498
  /**
6587
- * Yom HaAtzma'ut only celebrated after 1948
6499
+ * Makes a candle-lighting event for Chankah (not on Friday/Saturday).
6500
+ * At one point this used civil dusk (6 degrees below horizon).
6501
+ * Another source suggests 4.6667 degrees below horizon.
6588
6502
  * @private
6589
- * @param year
6590
6503
  */
6591
- function dateYomHaZikaron(year) {
6592
- if (year < 5708) {
6504
+ function makeWeekdayChanukahCandleLighting(ev, hd, options) {
6505
+ const location = options.location;
6506
+ const useElevation = Boolean(options.useElevation);
6507
+ const zmanim = new Zmanim(location, hd.greg(), useElevation);
6508
+ const candleLightingTime = zmanim.beinHaShmashos();
6509
+ if (isNaN(candleLightingTime.getTime())) {
6593
6510
  return null;
6594
6511
  }
6595
- let day;
6596
- const pesach = new HDate(15, NISAN$2, year);
6597
- const pdow = pesach.getDay();
6598
- if (pdow === SUN$1) {
6599
- day = 2;
6512
+ const ev2 = new TimedChanukahEvent(hd, ev.getDesc(), ev.getFlags(), candleLightingTime, location);
6513
+ ev2.emoji = ev.emoji;
6514
+ ev2.chanukahDay = ev.chanukahDay;
6515
+ return ev2;
6516
+ }
6517
+
6518
+ /* eslint-disable camelcase */
6519
+ const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
6520
+ const heDayNames = [
6521
+ 'רִאשׁוֹן',
6522
+ 'שֵׁנִי',
6523
+ 'שְׁלִישִׁי',
6524
+ 'רְבִיעִי',
6525
+ 'חֲמִישִׁי',
6526
+ 'שִׁישִּׁי',
6527
+ 'שַׁבָּת',
6528
+ ];
6529
+ const frDayNames = ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'];
6530
+ const night = 'בַּלַּ֥יְלָה';
6531
+ function getHebrewTimeOfDay(hour) {
6532
+ if (hour < 5)
6533
+ return night;
6534
+ else if (hour < 12)
6535
+ return 'בַּבֹּקֶר';
6536
+ else if (hour < 17)
6537
+ return 'בַּצׇּהֳרַיִים';
6538
+ else if (hour < 21)
6539
+ return 'בָּעֶרֶב';
6540
+ return night;
6541
+ }
6542
+ /**
6543
+ * Represents a molad, the moment when the new moon is "born"
6544
+ */
6545
+ class Molad {
6546
+ /**
6547
+ * Calculates the molad for a Hebrew month
6548
+ * @param year
6549
+ * @param month
6550
+ */
6551
+ constructor(year, month) {
6552
+ this.m = molad(year, month);
6600
6553
  }
6601
- else if (pdow === SAT$2) {
6602
- day = 3;
6554
+ /**
6555
+ */
6556
+ getYear() {
6557
+ return this.m.year;
6603
6558
  }
6604
- else if (year < 5764) {
6605
- day = 4;
6559
+ /**
6560
+ */
6561
+ getMonth() {
6562
+ return this.m.month;
6606
6563
  }
6607
- else if (pdow === TUE$1) {
6608
- day = 5;
6564
+ /**
6565
+ */
6566
+ getMonthName() {
6567
+ return HDate.getMonthName(this.m.month, this.m.year);
6609
6568
  }
6610
- else {
6611
- day = 4;
6569
+ /**
6570
+ * @returns Day of Week (0=Sunday, 6=Saturday)
6571
+ */
6572
+ getDow() {
6573
+ return this.m.dayOfWeek;
6612
6574
  }
6613
- return new HDate(day, IYYAR, year);
6614
- }
6615
-
6616
- const ykk = 'Yom Kippur Katan';
6617
- /** YKK is minor day of atonement on the day preceeding each Rosh Chodesh */
6618
- class YomKippurKatanEvent extends HolidayEvent {
6619
6575
  /**
6620
- * @private
6621
- * @param date Hebrew date event occurs
6622
- * @param nextMonthName name of the upcoming month
6576
+ * @returns hour of day (0-23)
6623
6577
  */
6624
- constructor(date, nextMonthName) {
6625
- super(date, `${ykk} ${nextMonthName}`, flags.MINOR_FAST | flags.YOM_KIPPUR_KATAN);
6626
- this.nextMonthName = nextMonthName;
6627
- this.memo = `Minor Day of Atonement on the day preceeding Rosh Chodesh ${nextMonthName}`;
6578
+ getHour() {
6579
+ return this.m.hour;
6628
6580
  }
6629
- basename() {
6630
- return this.getDesc();
6581
+ /**
6582
+ * @returns minutes past hour (0-59)
6583
+ */
6584
+ getMinutes() {
6585
+ return this.m.minutes;
6631
6586
  }
6632
6587
  /**
6633
- * @param [locale] Optional locale name (defaults to active locale).
6588
+ * @returns parts of a minute (0-17)
6634
6589
  */
6635
- render(locale) {
6636
- const monthName0 = Locale.gettext(this.nextMonthName, locale);
6637
- const monthName = monthName0.replace(/'/g, '’');
6638
- return Locale.gettext(ykk, locale) + ' ' + monthName;
6590
+ getChalakim() {
6591
+ return this.m.chalakim;
6639
6592
  }
6640
6593
  /**
6641
- * @param [locale] Optional locale name (defaults to active locale).
6594
+ * @param [locale] Optional locale name (defaults to active locale)
6595
+ * @param options
6642
6596
  */
6643
- renderBrief(locale) {
6644
- return Locale.gettext(ykk, locale);
6597
+ render(locale, options) {
6598
+ var _a;
6599
+ locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
6600
+ if (typeof locale === 'string') {
6601
+ locale = locale.toLowerCase();
6602
+ }
6603
+ const isHebrewLocale = locale === 'he' || locale === 'he-x-nonikud' || locale === 'h';
6604
+ const isFrenchLocale = locale === 'fr';
6605
+ const monthName = Locale.gettext(this.getMonthName(), locale);
6606
+ const dayNames = isHebrewLocale ? heDayNames : (isFrenchLocale ? frDayNames : shortDayNames);
6607
+ const dow = dayNames[this.getDow()];
6608
+ const minutes = this.getMinutes();
6609
+ const hour = this.getHour();
6610
+ const chalakim = this.getChalakim();
6611
+ const moladStr = Locale.gettext('Molad', locale);
6612
+ const minutesStr = (_a = Locale.lookupTranslation('min', locale)) !== null && _a !== void 0 ? _a : 'minutes';
6613
+ const chalakimStr = Locale.gettext('chalakim', locale);
6614
+ const and = Locale.gettext('and', locale);
6615
+ const after = Locale.gettext('after', locale);
6616
+ if (isHebrewLocale) {
6617
+ const ampm = getHebrewTimeOfDay(hour);
6618
+ const result = `${moladStr} ${monthName} יִהְיֶה בַּיּוֹם ${dow} בשָׁבוּעַ, ` +
6619
+ `בְּשָׁעָה ${hour} ${ampm}, ` +
6620
+ `ו-${minutes} ${minutesStr} ` +
6621
+ `ו-${chalakim} ${chalakimStr}`;
6622
+ if (locale === 'he-x-nonikud') {
6623
+ return Locale.hebrewStripNikkud(result);
6624
+ }
6625
+ return result;
6626
+ }
6627
+ const fmtTime = reformatTimeStr(`${hour}:00`, 'pm', options);
6628
+ const month = monthName.replace(/'/g, '’');
6629
+ return `${moladStr} ${month}: ${dow}, ${minutes} ${minutesStr} ${and} ${chalakim} ${chalakimStr} ${after} ${fmtTime}`;
6645
6630
  }
6646
- url() {
6647
- return undefined;
6631
+ }
6632
+ /** Represents a Molad announcement on Shabbat Mevarchim */
6633
+ class MoladEvent extends Event {
6634
+ /**
6635
+ * @param date Hebrew date event occurs
6636
+ * @param hyear molad year
6637
+ * @param hmonth molad month
6638
+ * @param options
6639
+ */
6640
+ constructor(date, hyear, hmonth, options) {
6641
+ const m = new Molad(hyear, hmonth);
6642
+ const monthName = m.getMonthName();
6643
+ super(date, `Molad ${monthName} ${hyear}`, flags.MOLAD);
6644
+ this.molad = m;
6645
+ this.options = options;
6646
+ }
6647
+ /**
6648
+ * @param [locale] Optional locale name (defaults to active locale).
6649
+ */
6650
+ render(locale) {
6651
+ return this.molad.render(locale, this.options);
6648
6652
  }
6649
6653
  }
6650
6654
 
6651
- /*
6652
- Hebcal - A Jewish Calendar Generator
6653
- Copyright (c) 1994-2020 Danny Sadinoff
6654
- Portions copyright Eyal Schachter and Michael J. Radwin
6655
-
6656
- https://github.com/hebcal/hebcal-es6
6657
-
6658
- This program is free software; you can redistribute it and/or
6659
- modify it under the terms of the GNU General Public License
6660
- as published by the Free Software Foundation; either version 2
6661
- of the License, or (at your option) any later version.
6662
-
6663
- This program is distributed in the hope that it will be useful,
6664
- but WITHOUT ANY WARRANTY; without even the implied warranty of
6665
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6666
- GNU General Public License for more details.
6667
-
6668
- You should have received a copy of the GNU General Public License
6669
- along with this program. If not, see <http://www.gnu.org/licenses/>.
6670
- */
6671
- /** @private */
6672
- function observedInIsrael(ev) {
6673
- return ev.observedInIsrael();
6674
- }
6675
- /** @private */
6676
- function observedInDiaspora(ev) {
6677
- return ev.observedInDiaspora();
6655
+ const sefirot = {
6656
+ en: {
6657
+ infix: 'within ',
6658
+ infix26: 'within ',
6659
+ words: [
6660
+ '',
6661
+ 'Lovingkindness',
6662
+ 'Might',
6663
+ 'Beauty',
6664
+ 'Eternity',
6665
+ 'Splendor',
6666
+ 'Foundation',
6667
+ 'Majesty',
6668
+ ],
6669
+ pfxWords: null,
6670
+ },
6671
+ he: {
6672
+ infix: null,
6673
+ infix26: null,
6674
+ words: [
6675
+ '',
6676
+ 'חֶֽסֶד',
6677
+ 'גְּבוּרָה',
6678
+ 'תִּפְאֶֽרֶת',
6679
+ 'נֶּֽצַח',
6680
+ 'הוֹד',
6681
+ 'יְּסוֹד',
6682
+ 'מַלְכוּת',
6683
+ ],
6684
+ pfxWords: [
6685
+ '',
6686
+ 'שֶׁבְּחֶֽסֶד',
6687
+ 'שֶׁבִּגְבוּרָה',
6688
+ 'שֶׁבְּתִפְאֶֽרֶת',
6689
+ 'שֶׁבְּנֶֽצַח',
6690
+ 'שֶׁבְּהוֹד',
6691
+ 'שֶׁבִּיְסוֹד',
6692
+ 'שֶׁבְּמַלְכוּת',
6693
+ ],
6694
+ },
6695
+ translit: {
6696
+ infix: "sheb'",
6697
+ infix26: 'shebi',
6698
+ words: [
6699
+ '',
6700
+ 'Chesed',
6701
+ 'Gevurah',
6702
+ 'Tiferet',
6703
+ 'Netzach',
6704
+ 'Hod',
6705
+ 'Yesod',
6706
+ 'Malkhut',
6707
+ ],
6708
+ pfxWords: null,
6709
+ },
6710
+ };
6711
+ function checkDay(omerDay) {
6712
+ if (omerDay < 1 || omerDay > 49) {
6713
+ throw new RangeError(`Invalid Omer day ${omerDay}`);
6714
+ }
6678
6715
  }
6679
- /** @private */
6680
- function holidayFilter(il) {
6681
- return il ? observedInIsrael : observedInDiaspora;
6716
+ function getWeeks(omerDay) {
6717
+ const weekNum = Math.floor((omerDay - 1) / 7) + 1;
6718
+ const daysWithinWeeks = omerDay % 7 || 7;
6719
+ return [weekNum, daysWithinWeeks];
6682
6720
  }
6683
- /**
6684
- * Returns an array of Events on this date (or `undefined` if no events)
6685
- * @param date Hebrew Date, Gregorian date, or absolute R.D. day number
6686
- * @param [il] use the Israeli schedule for holidays
6687
- */
6688
- function getHolidaysOnDate(date, il) {
6689
- const hd = HDate.isHDate(date) ? date : new HDate(date);
6690
- const hdStr = hd.toString();
6691
- const yearMap = getHolidaysForYear_(hd.getFullYear());
6692
- const events = yearMap.get(hdStr);
6693
- // if il isn't a boolean return both diaspora + IL for day
6694
- if (typeof il === 'undefined' || typeof events === 'undefined') {
6695
- return events;
6721
+ function omerTodayIsEn(omerDay) {
6722
+ const [weekNumber, daysWithinWeeks] = getWeeks(omerDay);
6723
+ const totalDaysStr = omerDay === 1 ? 'day' : 'days';
6724
+ let str = `Today is ${omerDay} ${totalDaysStr}`;
6725
+ if (weekNumber > 1 || omerDay === 7) {
6726
+ const day7 = daysWithinWeeks === 7;
6727
+ const numWeeks = day7 ? weekNumber : weekNumber - 1;
6728
+ const weeksStr = numWeeks === 1 ? 'week' : 'weeks';
6729
+ str += `, which is ${numWeeks} ${weeksStr}`;
6730
+ if (!day7) {
6731
+ const daysStr = daysWithinWeeks === 1 ? 'day' : 'days';
6732
+ str += ` and ${daysWithinWeeks} ${daysStr}`;
6733
+ }
6696
6734
  }
6697
- const filtered = events.filter(holidayFilter(il));
6698
- return filtered;
6735
+ return str + ' of the Omer';
6699
6736
  }
6700
- const CHAG = flags.CHAG;
6701
- const IL_ONLY$1 = flags.IL_ONLY;
6702
- const LIGHT_CANDLES_TZEIS$1 = flags.LIGHT_CANDLES_TZEIS;
6703
- const CHANUKAH_CANDLES$1 = flags.CHANUKAH_CANDLES;
6704
- const MINOR_FAST$1 = flags.MINOR_FAST;
6705
- const SPECIAL_SHABBAT$1 = flags.SPECIAL_SHABBAT;
6706
- const MODERN_HOLIDAY$1 = flags.MODERN_HOLIDAY;
6707
- const MAJOR_FAST$1 = flags.MAJOR_FAST;
6708
- const MINOR_HOLIDAY$1 = flags.MINOR_HOLIDAY;
6709
- const EREV$1 = flags.EREV;
6710
- const SUN = 0;
6711
- const TUE = 2;
6712
- const THU = 4;
6713
- const FRI$1 = 5;
6714
- const SAT$1 = 6;
6715
- const NISAN$1 = months.NISAN;
6716
- const TAMUZ = months.TAMUZ;
6717
- const AV = months.AV;
6718
- const TISHREI$1 = months.TISHREI;
6719
- const KISLEV = months.KISLEV;
6720
- const TEVET = months.TEVET;
6721
- const ADAR_I = months.ADAR_I;
6722
- const ADAR_II = months.ADAR_II;
6723
- const emojiIsraelFlag = { emoji: '🇮🇱' };
6724
- const chanukahEmoji = '🕎';
6725
- const yearCache = new QuickLRU({ maxSize: 400 });
6726
- const KEYCAP_DIGITS = [
6727
- '0️⃣',
6728
- '1️⃣',
6729
- '2️⃣',
6730
- '3️⃣',
6731
- '4️⃣',
6732
- '5️⃣',
6733
- '6️⃣',
6734
- '7️⃣',
6735
- '8️⃣',
6736
- '9️⃣',
6737
+ // adapted from pip hdate package (GPL)
6738
+ // https://github.com/py-libhdate/py-libhdate/blob/master/hdate/date.py
6739
+ const tens = ['', 'עֲשָׂרָה', 'עֶשְׂרִים', 'שְׁלוֹשִׁים', 'אַרְבָּעִים'];
6740
+ const ones = [
6741
+ '',
6742
+ 'אֶחָד',
6743
+ 'שְׁנַיִם',
6744
+ 'שְׁלוֹשָׁה',
6745
+ 'אַרְבָּעָה',
6746
+ 'חֲמִשָּׁה',
6747
+ 'שִׁשָּׁה',
6748
+ 'שִׁבְעָה',
6749
+ 'שְׁמוֹנָה',
6750
+ 'תִּשְׁעָה',
6737
6751
  ];
6738
- /**
6739
- * Lower-level holidays interface, which returns a `Map` of `Event`s indexed by
6740
- * `HDate.toString()`. These events must filtered especially for `flags.IL_ONLY`
6741
- * or `flags.CHUL_ONLY` depending on Israel vs. Diaspora holiday scheme.
6742
- * @private
6743
- */
6744
- function getHolidaysForYear_(year) {
6745
- if (typeof year !== 'number') {
6746
- throw new TypeError(`bad Hebrew year: ${year}`);
6752
+ const shnei = 'שְׁנֵי';
6753
+ const yamim = 'יָמִים';
6754
+ const shneiYamim = shnei + ' ' + yamim;
6755
+ const shavuot = 'שָׁבוּעוֹת';
6756
+ const yom = 'יוֹם';
6757
+ const yomEchad = yom + ' ' + ones[1];
6758
+ const asar = 'עָשָׂר';
6759
+ function omerTodayIsHe(omerDay) {
6760
+ const ten = Math.floor(omerDay / 10);
6761
+ const one = omerDay % 10;
6762
+ let str = 'הַיּוֹם ';
6763
+ if (omerDay === 11) {
6764
+ str += 'אַחַד ' + asar;
6747
6765
  }
6748
- else if (year < 1 || year > 32658) {
6749
- throw new RangeError(`Hebrew year ${year} out of range 1-32658`);
6766
+ else if (omerDay === 12) {
6767
+ str += 'שְׁנֵים ' + asar;
6750
6768
  }
6751
- const cached = yearCache.get(year);
6752
- if (cached) {
6753
- return cached;
6769
+ else if (12 < omerDay && omerDay < 20) {
6770
+ str += ones[one] + ' ' + asar;
6754
6771
  }
6755
- const RH = new HDate(1, TISHREI$1, year);
6756
- const pesach = new HDate(15, NISAN$1, year);
6757
- const map = new Map();
6758
- function add(...events) {
6759
- for (const ev of events) {
6760
- const key = ev.date.toString();
6761
- const arr = map.get(key);
6762
- if (typeof arr === 'object') {
6763
- if (arr[0].getFlags() & EREV$1) {
6764
- arr.unshift(ev);
6765
- }
6766
- else {
6767
- arr.push(ev);
6768
- }
6769
- }
6770
- else {
6771
- map.set(key, [ev]);
6772
- }
6772
+ else if (omerDay > 9) {
6773
+ str += ones[one];
6774
+ if (one) {
6775
+ str += ' ';
6776
+ str += ten === 3 ? 'וּ' : 'וְ';
6773
6777
  }
6774
6778
  }
6775
- for (const h of staticHolidays) {
6776
- const hd = new HDate(h.dd, h.mm, year);
6777
- const ev = new HolidayEvent(hd, h.desc, h.flags);
6778
- if (h.emoji)
6779
- ev.emoji = h.emoji;
6780
- if (h.chmDay)
6781
- ev.cholHaMoedDay = h.chmDay;
6782
- add(ev);
6783
- }
6784
- // standard holidays that don't shift based on year
6785
- add(new RoshHashanaEvent(RH, year, CHAG | LIGHT_CANDLES_TZEIS$1));
6786
- // Variable date holidays
6787
- const tzomGedaliahDay = RH.getDay() === THU ? 4 : 3;
6788
- add(new HolidayEvent(new HDate(tzomGedaliahDay, TISHREI$1, year), holidayDesc.TZOM_GEDALIAH, MINOR_FAST$1));
6789
- // first SAT after RH
6790
- add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, 7 + RH.abs())), holidayDesc.SHABBAT_SHUVA, SPECIAL_SHABBAT$1));
6791
- const rchTevet = HDate.shortKislev(year)
6792
- ? new HDate(1, TEVET, year)
6793
- : new HDate(30, KISLEV, year);
6794
- add(new HolidayEvent(rchTevet, holidayDesc.CHAG_HABANOT, MINOR_HOLIDAY$1));
6795
- // yes, we know Kislev 30-32 are wrong
6796
- // HDate() corrects the month automatically
6797
- for (let candles = 2; candles <= 8; candles++) {
6798
- const hd = new HDate(23 + candles, KISLEV, year);
6799
- add(new ChanukahEvent(hd, `Chanukah: ${candles} Candles`, MINOR_HOLIDAY$1 | CHANUKAH_CANDLES$1, {
6800
- chanukahDay: candles - 1,
6801
- emoji: chanukahEmoji + KEYCAP_DIGITS[candles],
6802
- }));
6803
- }
6804
- add(new ChanukahEvent(new HDate(32, KISLEV, year), holidayDesc.CHANUKAH_8TH_DAY, MINOR_HOLIDAY$1, { chanukahDay: 8, emoji: chanukahEmoji }));
6805
- add(new AsaraBTevetEvent(new HDate(10, TEVET, year), holidayDesc.ASARA_BTEVET, MINOR_FAST$1));
6806
- const pesachAbs = pesach.abs();
6807
- add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 43)), holidayDesc.SHABBAT_SHEKALIM, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 30)), holidayDesc.SHABBAT_ZACHOR, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(pesachAbs - (pesach.getDay() === TUE ? 33 : 31)), holidayDesc.TAANIT_ESTHER, MINOR_FAST$1));
6808
- const haChodeshAbs = HDate.dayOnOrBefore(SAT$1, pesachAbs - 14);
6809
- add(new HolidayEvent(new HDate(haChodeshAbs - 7), holidayDesc.SHABBAT_PARAH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(haChodeshAbs), holidayDesc.SHABBAT_HACHODESH, SPECIAL_SHABBAT$1), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, pesachAbs - 1)), holidayDesc.SHABBAT_HAGADOL, SPECIAL_SHABBAT$1), new HolidayEvent(
6810
- // if the fast falls on Shabbat, move to Thursday
6811
- pesach.prev().getDay() === SAT$1
6812
- ? pesach.onOrBefore(THU)
6813
- : new HDate(14, NISAN$1, year), holidayDesc.TAANIT_BECHOROT, MINOR_FAST$1));
6814
- add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, new HDate(1, TISHREI$1, year + 1).abs() - 4)), holidayDesc.LEIL_SELICHOT, MINOR_HOLIDAY$1, { emoji: '🕍' }));
6815
- if (pesach.getDay() === SUN) {
6816
- add(new HolidayEvent(new HDate(16, ADAR_II, year), holidayDesc.PURIM_MESHULASH, MINOR_HOLIDAY$1));
6817
- }
6818
- if (HDate.isLeapYear(year)) {
6819
- add(new HolidayEvent(new HDate(14, ADAR_I, year), holidayDesc.PURIM_KATAN, MINOR_HOLIDAY$1, { emoji: '🎭️' }));
6820
- add(new HolidayEvent(new HDate(15, ADAR_I, year), holidayDesc.SHUSHAN_PURIM_KATAN, MINOR_HOLIDAY$1, { emoji: '🎭️' }));
6779
+ if (omerDay > 2) {
6780
+ if (omerDay > 20 || omerDay === 10 || omerDay === 20) {
6781
+ str += tens[ten];
6782
+ }
6783
+ if (omerDay < 11) {
6784
+ str += ones[one] + ' ' + yamim + ' ';
6785
+ }
6786
+ else {
6787
+ str += ' ' + yom + ' ';
6788
+ }
6821
6789
  }
6822
- const nisan27dt = dateYomHaShoah(year);
6823
- if (nisan27dt) {
6824
- add(new HolidayEvent(nisan27dt, holidayDesc.YOM_HASHOAH, MODERN_HOLIDAY$1));
6790
+ else if (omerDay === 1) {
6791
+ str += yomEchad + ' ';
6825
6792
  }
6826
- const yomHaZikaronDt = dateYomHaZikaron(year);
6827
- if (yomHaZikaronDt) {
6828
- add(new HolidayEvent(yomHaZikaronDt, holidayDesc.YOM_HAZIKARON, MODERN_HOLIDAY$1, emojiIsraelFlag), new HolidayEvent(yomHaZikaronDt.next(), holidayDesc.YOM_HAATZMA_UT, MODERN_HOLIDAY$1, emojiIsraelFlag));
6793
+ else {
6794
+ // omer == 2
6795
+ str += shneiYamim + ' ';
6829
6796
  }
6830
- for (const h of staticModernHolidays) {
6831
- if (year >= h.firstYear) {
6832
- let hd = new HDate(h.dd, h.mm, year);
6833
- const dow = hd.getDay();
6834
- if (h.friSatMovetoThu && (dow === FRI$1 || dow === SAT$1)) {
6835
- hd = hd.onOrBefore(THU);
6797
+ if (omerDay > 6) {
6798
+ str = str.trim(); // remove trailing space before comma
6799
+ str += ', שֶׁהֵם ';
6800
+ const weeks = Math.floor(omerDay / 7);
6801
+ const days = omerDay % 7;
6802
+ if (weeks > 2) {
6803
+ str += ones[weeks] + ' ' + shavuot + ' ';
6804
+ }
6805
+ else if (weeks === 1) {
6806
+ str += 'שָׁבֽוּעַ' + ' ' + ones[1] + ' ';
6807
+ }
6808
+ else {
6809
+ // weeks == 2
6810
+ str += shnei + ' ' + shavuot + ' ';
6811
+ }
6812
+ if (days) {
6813
+ if (days === 2 || days === 3) {
6814
+ str += 'וּ';
6836
6815
  }
6837
- else if (h.friPostponeToSun && dow === FRI$1) {
6838
- hd = new HDate(hd.abs() + 2);
6816
+ else if (days === 5) {
6817
+ str += 'וַ';
6839
6818
  }
6840
- else if (h.satPostponeToSun && dow === SAT$1) {
6841
- hd = hd.next();
6819
+ else {
6820
+ str += 'וְ';
6821
+ }
6822
+ if (days > 2) {
6823
+ str += ones[days] + ' ' + yamim + ' ';
6824
+ }
6825
+ else if (days === 1) {
6826
+ str += yomEchad + ' ';
6842
6827
  }
6843
- const mask = h.chul ? MODERN_HOLIDAY$1 : MODERN_HOLIDAY$1 | IL_ONLY$1;
6844
- const ev = new HolidayEvent(hd, h.desc, mask);
6845
- if (!h.suppressEmoji) {
6846
- ev.emoji = '🇮🇱';
6828
+ else {
6829
+ // days == 2
6830
+ str += shneiYamim + ' ';
6847
6831
  }
6848
- add(ev);
6849
6832
  }
6850
6833
  }
6851
- let tamuz17 = new HDate(17, TAMUZ, year);
6852
- let tamuz17attrs;
6853
- if (tamuz17.getDay() === SAT$1) {
6854
- tamuz17 = new HDate(18, TAMUZ, year);
6855
- tamuz17attrs = { observed: true };
6834
+ str += 'לָעֽוֹמֶר';
6835
+ return str.normalize();
6836
+ }
6837
+ /** Represents a day 1-49 of counting the Omer from Pesach to Shavuot */
6838
+ class OmerEvent extends Event {
6839
+ /**
6840
+ * @param date
6841
+ * @param omerDay
6842
+ */
6843
+ constructor(date, omerDay) {
6844
+ super(date, `Omer ${omerDay}`, flags.OMER_COUNT);
6845
+ checkDay(omerDay);
6846
+ this.weekNumber = Math.floor((omerDay - 1) / 7) + 1;
6847
+ this.daysWithinWeeks = omerDay % 7 || 7;
6848
+ this.omer = omerDay;
6856
6849
  }
6857
- add(new HolidayEvent(tamuz17, holidayDesc.TZOM_TAMMUZ, MINOR_FAST$1, tamuz17attrs));
6858
- let av9dt = new HDate(9, AV, year);
6859
- let av9title = holidayDesc.TISHA_BAV;
6860
- let av9attrs;
6861
- if (av9dt.getDay() === SAT$1) {
6862
- av9dt = av9dt.next();
6863
- av9attrs = { observed: true };
6864
- av9title += ' (observed)';
6850
+ /**
6851
+ * Returns the sefira. For example, on day 8:
6852
+ * * חֶֽסֶד שֶׁבִּגְבוּרָה
6853
+ * * Chesed shebiGevurah
6854
+ * * Lovingkindness within Might
6855
+ * @param lang `en` (English), `he` (Hebrew with nikud), or `translit` (Hebrew in Sephardic transliteration)
6856
+ * @returns a string such as `Lovingkindness within Might` or `חֶֽסֶד שֶׁבִּגְבוּרָה`
6857
+ */
6858
+ sefira(lang = 'en') {
6859
+ if (lang !== 'he' && lang !== 'translit') {
6860
+ lang = 'en';
6861
+ }
6862
+ const [weekNum, daysWithinWeeks] = getWeeks(this.omer);
6863
+ const config = sefirot[lang];
6864
+ const pfxWords = config.pfxWords;
6865
+ const words = config.words;
6866
+ const week = pfxWords ? pfxWords[weekNum] : words[weekNum];
6867
+ const dayWithinWeek = words[daysWithinWeeks];
6868
+ const infix = pfxWords
6869
+ ? ''
6870
+ : weekNum === 2 || weekNum === 6
6871
+ ? config.infix26
6872
+ : config.infix;
6873
+ return (dayWithinWeek + ' ' + infix + week).normalize();
6865
6874
  }
6866
- const av9abs = av9dt.abs();
6867
- add(new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, av9abs)), holidayDesc.SHABBAT_CHAZON, SPECIAL_SHABBAT$1), new HolidayEvent(av9dt.prev(), holidayDesc.EREV_TISHA_BAV, EREV$1 | MAJOR_FAST$1, av9attrs), new HolidayEvent(av9dt, av9title, MAJOR_FAST$1, av9attrs), new HolidayEvent(new HDate(HDate.dayOnOrBefore(SAT$1, av9abs + 7)), holidayDesc.SHABBAT_NACHAMU, SPECIAL_SHABBAT$1));
6868
- const monthsInYear = HDate.monthsInYear(year);
6869
- for (let month = 1; month <= monthsInYear; month++) {
6870
- const monthName = HDate.getMonthName(month, year);
6871
- if ((month === NISAN$1
6872
- ? HDate.daysInMonth(HDate.monthsInYear(year - 1), year - 1)
6873
- : HDate.daysInMonth(month - 1, year)) === 30) {
6874
- add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
6875
- add(new RoshChodeshEvent(new HDate(30, month - 1, year), monthName));
6875
+ /**
6876
+ * @param [locale] Optional locale name (defaults to active locale).
6877
+ */
6878
+ render(locale) {
6879
+ locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
6880
+ if (typeof locale === 'string') {
6881
+ locale = locale.toLowerCase();
6876
6882
  }
6877
- else if (month !== TISHREI$1) {
6878
- add(new RoshChodeshEvent(new HDate(1, month, year), monthName));
6883
+ const isHebrewLocale = locale === 'he' || locale === 'he-x-nonikud' || locale === 'h';
6884
+ const omer = this.omer;
6885
+ const nth = isHebrewLocale ? gematriya(omer) : Locale.ordinal(omer, locale);
6886
+ return nth + ' ' + Locale.gettext('day of the Omer', locale);
6887
+ }
6888
+ /**
6889
+ * Returns translation of "Omer day 22" without ordinal numbers.
6890
+ * @param [locale] Optional locale name (defaults to active locale).
6891
+ */
6892
+ renderBrief(locale) {
6893
+ return (Locale.gettext('Omer', locale) +
6894
+ ' ' +
6895
+ Locale.gettext('day', locale) +
6896
+ ' ' +
6897
+ this.omer);
6898
+ }
6899
+ /**
6900
+ * Returns an emoji number symbol with a circle, for example `㊲`
6901
+ * from the “Enclosed CJK Letters and Months” block of the Unicode standard
6902
+ * @returns a single Unicode character from `①` through `㊾`
6903
+ */
6904
+ getEmoji() {
6905
+ if (typeof this.emoji === 'string')
6906
+ return this.emoji;
6907
+ let codePoint;
6908
+ const omerDay = this.omer;
6909
+ if (omerDay <= 20) {
6910
+ codePoint = 9312 + omerDay - 1;
6911
+ }
6912
+ else if (omerDay <= 35) {
6913
+ // between 21 and 35 inclusive
6914
+ codePoint = 12881 + omerDay - 21;
6879
6915
  }
6916
+ else {
6917
+ // between 36 and 49 inclusive
6918
+ codePoint = 12977 + omerDay - 36;
6919
+ }
6920
+ return String.fromCodePoint(codePoint);
6880
6921
  }
6881
- // Begin: Yom Kippur Katan
6882
- // start at Iyyar because one may not fast during Nisan
6883
- for (let month = months.IYYAR; month <= monthsInYear; month++) {
6884
- const nextMonth = month + 1;
6885
- // Yom Kippur Katan is not observed on the day before Rosh Hashanah.
6886
- // Not observed prior to Rosh Chodesh Cheshvan because Yom Kippur has just passed.
6887
- // Not observed before Rosh Chodesh Tevet, because that day is Hanukkah.
6888
- if (nextMonth === TISHREI$1 ||
6889
- nextMonth === months.CHESHVAN ||
6890
- nextMonth === TEVET) {
6891
- continue;
6922
+ getWeeks() {
6923
+ const day7 = this.daysWithinWeeks === 7;
6924
+ return day7 ? this.weekNumber : this.weekNumber - 1;
6925
+ }
6926
+ getDaysWithinWeeks() {
6927
+ return this.daysWithinWeeks;
6928
+ }
6929
+ /**
6930
+ * Returns a sentence with that evening's omer count
6931
+ * @returns a string such as `Today is 10 days, which is 1 week and 3 days of the Omer`
6932
+ * or `הַיוֹם עֲשָׂרָה יָמִים, שְׁהֵם שָׁבוּעַ אֶחָד וְשְׁלוֹשָׁה יָמִים לָעוֹמֶר`
6933
+ */
6934
+ getTodayIs(locale) {
6935
+ locale = locale !== null && locale !== void 0 ? locale : Locale.getLocaleName();
6936
+ if (typeof locale === 'string') {
6937
+ locale = locale.toLowerCase();
6892
6938
  }
6893
- let ykk = new HDate(29, month, year);
6894
- const dow = ykk.getDay();
6895
- if (dow === FRI$1 || dow === SAT$1) {
6896
- ykk = ykk.onOrBefore(THU);
6939
+ const isHebrew = locale === 'he' || locale === 'he-x-nonikud';
6940
+ const str = isHebrew ? omerTodayIsHe(this.omer) : omerTodayIsEn(this.omer);
6941
+ if (locale === 'he-x-nonikud') {
6942
+ return Locale.hebrewStripNikkud(str);
6897
6943
  }
6898
- const nextMonthName = HDate.getMonthName(nextMonth, year);
6899
- const ev = new YomKippurKatanEvent(ykk, nextMonthName);
6900
- add(ev);
6944
+ return str;
6901
6945
  }
6902
- const sedra = getSedra(year, false);
6903
- const beshalachHd = sedra.find(15);
6904
- add(new HolidayEvent(beshalachHd, holidayDesc.SHABBAT_SHIRAH, SPECIAL_SHABBAT$1));
6905
- // Birkat Hachamah appears only once every 28 years
6906
- const birkatHaChama = getBirkatHaChama(year);
6907
- if (birkatHaChama) {
6908
- const hd = new HDate(birkatHaChama);
6909
- add(new HolidayEvent(hd, holidayDesc.BIRKAT_HACHAMAH, MINOR_HOLIDAY$1, { emoji: '☀️' }));
6946
+ url() {
6947
+ return `https://www.hebcal.com/omer/${this.getDate().getFullYear()}/${this.omer}`;
6910
6948
  }
6911
- yearCache.set(year, map);
6912
- return map;
6913
6949
  }
6950
+
6914
6951
  /**
6915
- * Birkat Hachamah appears only once every 28 years.
6916
- * Although almost always in Nisan, it can occur in Adar II.
6917
- * - 27 Adar II 5461 (Gregorian year 1701)
6918
- * - 29 Adar II 5993 (Gregorian year 2233)
6919
- *
6920
- * Due to drift, this will eventually slip into Iyyar
6921
- * - 2 Iyyar 7141 (Gregorian year 3381)
6922
- * @private
6952
+ * Represents one of 54 weekly Torah portions, always on a Saturday
6923
6953
  */
6924
- function getBirkatHaChama(year) {
6925
- const leap = HDate.isLeapYear(year);
6926
- const startMonth = leap ? ADAR_II : NISAN$1;
6927
- const startDay = leap ? 20 : 1;
6928
- const baseRd = HDate.hebrew2abs(year, startMonth, startDay);
6929
- for (let day = 0; day <= 40; day++) {
6930
- const abs = baseRd + day;
6931
- const elapsed = abs + 1373429;
6932
- if (elapsed % 10227 === 172) {
6933
- return abs;
6954
+ class ParshaEvent extends Event {
6955
+ /**
6956
+ * @param parsha - untranslated name of single or double parsha,
6957
+ * such as ['Bereshit'] or ['Achrei Mot', 'Kedoshim']
6958
+ */
6959
+ constructor(date, parsha, il = false, num = -1) {
6960
+ if (!Array.isArray(parsha) || parsha.length === 0 || parsha.length > 2) {
6961
+ throw new TypeError('Bad parsha argument');
6934
6962
  }
6963
+ const desc = 'Parashat ' + parsha.join('-');
6964
+ super(date, desc, flags.PARSHA_HASHAVUA);
6965
+ this.parsha = parsha;
6966
+ this.il = Boolean(il);
6967
+ this.num = num || -1;
6968
+ }
6969
+ /**
6970
+ * @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to active locale.
6971
+ */
6972
+ render(locale) {
6973
+ return renderParshaName(this.parsha, locale);
6974
+ }
6975
+ basename() {
6976
+ return this.parsha.join('-');
6977
+ }
6978
+ url() {
6979
+ const year = this.getDate().greg().getFullYear();
6980
+ if (year < 100) {
6981
+ return undefined;
6982
+ }
6983
+ const dt = this.urlDateSuffix();
6984
+ const url = 'https://www.hebcal.com/sedrot/' +
6985
+ this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
6986
+ '-' +
6987
+ dt;
6988
+ return this.il ? url + '?i=on' : url;
6989
+ }
6990
+ urlDateSuffix() {
6991
+ const isoDate = isoDateString(this.getDate().greg());
6992
+ return isoDate.replace(/-/g, '');
6935
6993
  }
6936
- return 0;
6937
6994
  }
6995
+
6938
6996
  /**
6939
- * Returns an array of holidays for the year
6997
+ * Calculates weekly Torah Reading on Saturdays for entire year
6940
6998
  * @param year Hebrew year
6941
- * @param il use the Israeli schedule for holidays
6999
+ * @param il Israel (false for Diaspora)
7000
+ * @returns an array of `ParshaEvent` occurring on Saturdays that contain a regular
7001
+ * (non-holiday) Parashat HaShavua
6942
7002
  */
6943
- function getHolidaysForYearArray(year, il) {
6944
- const yearMap = getHolidaysForYear_(year);
6945
- const startAbs = HDate.hebrew2abs(year, TISHREI$1, 1);
6946
- const endAbs = HDate.hebrew2abs(year + 1, TISHREI$1, 1) - 1;
6947
- let events = [];
6948
- const myFilter = il ? observedInIsrael : observedInDiaspora;
6949
- for (let absDt = startAbs; absDt <= endAbs; absDt++) {
6950
- const hd = new HDate(absDt);
6951
- const holidays = yearMap.get(hd.toString());
6952
- if (holidays) {
6953
- const filtered = holidays.filter(myFilter);
6954
- events = events.concat(filtered);
7003
+ function parshaYear(year, il) {
7004
+ const sedra = getSedra(year, il);
7005
+ const startAbs = sedra.getFirstSaturday();
7006
+ const endAbs = HDate.hebrew2abs(year, months.ELUL, 29);
7007
+ const events = [];
7008
+ for (let absDt = startAbs; absDt <= endAbs; absDt += 7) {
7009
+ const parsha = sedra.lookup(absDt);
7010
+ if (!parsha.chag) {
7011
+ const ev = new ParshaEvent(parsha.hdate, parsha.parsha, il, parsha.num);
7012
+ events.push(ev);
6955
7013
  }
6956
7014
  }
6957
7015
  return events;
@@ -8312,6 +8370,7 @@ exports.gematriyaStrToNum = gematriyaStrToNum;
8312
8370
  exports.getHolidaysOnDate = getHolidaysOnDate;
8313
8371
  exports.getSedra = getSedra;
8314
8372
  exports.holidayDesc = holidayDesc;
8373
+ exports.isAssurBemlacha = isAssurBemlacha;
8315
8374
  exports.months = months;
8316
8375
  exports.parshaYear = parshaYear;
8317
8376
  exports.parshiot = parshiot;