@hebcal/core 6.14.3 → 6.14.5

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 (64) hide show
  1. package/dist/bundle.js +217 -166
  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.d.ts +2 -1
  9. package/dist/esm/HolidayEvent.js +6 -2
  10. package/dist/esm/HolidayEvent.js.map +1 -1
  11. package/dist/esm/KiddushLevanaEvent.js +1 -1
  12. package/dist/esm/KiddushLevanaEvent.js.map +1 -1
  13. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  14. package/dist/esm/MevarchimChodeshEvent.js.map +1 -1
  15. package/dist/esm/ParshaEvent.js +1 -1
  16. package/dist/esm/ParshaEvent.js.map +1 -1
  17. package/dist/esm/TimedEvent.js +1 -1
  18. package/dist/esm/TimedEvent.js.map +1 -1
  19. package/dist/esm/YomKippurKatanEvent.js +1 -1
  20. package/dist/esm/YomKippurKatanEvent.js.map +1 -1
  21. package/dist/esm/ashkenazi.po.js +1 -1
  22. package/dist/esm/calendar.d.ts +10 -0
  23. package/dist/esm/calendar.js +36 -27
  24. package/dist/esm/calendar.js.map +1 -1
  25. package/dist/esm/candles.js +1 -1
  26. package/dist/esm/candles.js.map +1 -1
  27. package/dist/esm/cities.json.js +1 -1
  28. package/dist/esm/event.js +1 -1
  29. package/dist/esm/getStartAndEnd.js +1 -1
  30. package/dist/esm/hallel.js +1 -1
  31. package/dist/esm/he-x-NoNikud.po.js +1 -1
  32. package/dist/esm/he.po.js +1 -1
  33. package/dist/esm/hebcal.js +1 -1
  34. package/dist/esm/holidays.d.ts +26 -8
  35. package/dist/esm/holidays.js +54 -15
  36. package/dist/esm/holidays.js.map +1 -1
  37. package/dist/esm/index.js +1 -1
  38. package/dist/esm/isAssurBemlacha.js +1 -1
  39. package/dist/esm/isAveilut.js +1 -1
  40. package/dist/esm/isFastDay.js +1 -1
  41. package/dist/esm/locale.js +1 -1
  42. package/dist/esm/location.js +1 -1
  43. package/dist/esm/location.js.map +1 -1
  44. package/dist/esm/modern.js +1 -1
  45. package/dist/esm/molad.js +1 -1
  46. package/dist/esm/molad.js.map +1 -1
  47. package/dist/esm/moladBase.js +1 -1
  48. package/dist/esm/moladDate.js +1 -1
  49. package/dist/esm/omer.js +1 -1
  50. package/dist/esm/omer.js.map +1 -1
  51. package/dist/esm/parshaName.js +1 -1
  52. package/dist/esm/parshaYear.js +1 -1
  53. package/dist/esm/pkgVersion.d.ts +1 -1
  54. package/dist/esm/pkgVersion.js +2 -2
  55. package/dist/esm/pkgVersion.js.map +1 -1
  56. package/dist/esm/reformatTimeStr.js +1 -1
  57. package/dist/esm/sedra.js +1 -1
  58. package/dist/esm/sefira.json.js +1 -1
  59. package/dist/esm/staticHolidays.js +1 -1
  60. package/dist/esm/string.js +1 -1
  61. package/dist/esm/tachanun.js +1 -1
  62. package/dist/esm/zenith.js +1 -1
  63. package/dist/esm/zmanim.js +1 -1
  64. package/package.json +4 -4
package/dist/bundle.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! @hebcal/core v6.14.3, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
1
+ /*! @hebcal/core v6.14.5, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
5
5
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
6
- const version = '6.14.3';
6
+ const version = '6.14.5';
7
7
 
8
8
  /*! @hebcal/hdate v0.23.1, distributed under GPLv2 or later https://www.gnu.org/licenses/gpl-2.0.txt */
9
9
  /**
@@ -11465,9 +11465,13 @@ class HolidayEvent extends Event {
11465
11465
  /**
11466
11466
  * Returns a `https://www.hebcal.com/holidays/...` URL for more detail on
11467
11467
  * this holiday. Israel-only holidays get an `?i=on` query parameter.
11468
- * Returns `undefined` for years outside `[100, 2999]`.
11468
+ * Returns `undefined` for years outside `[100, 2999]` and for
11469
+ * Ta'anit BeHaB, which has no holiday page.
11469
11470
  */
11470
11471
  url() {
11472
+ if (this.hasFlag('BEHAB')) {
11473
+ return undefined;
11474
+ }
11471
11475
  const year = this.greg().getFullYear();
11472
11476
  if (year < 100 || year > 2999) {
11473
11477
  return undefined;
@@ -12442,6 +12446,131 @@ function getSedra(hyear, il) {
12442
12446
  return sedra;
12443
12447
  }
12444
12448
 
12449
+ const { HAVDALAH, CANDLE_LIGHTING } = holidayDesc;
12450
+ /**
12451
+ * Base class for events that have an associated wall-clock time and
12452
+ * geographic location — for example, candle lighting, havdalah, and
12453
+ * fast begin/end times.
12454
+ *
12455
+ * Stores both a `Date` (`eventTime`) and pre-formatted 24-hour
12456
+ * (`eventTimeStr`) and locale-aware (`fmtTime`) strings. May reference a
12457
+ * "linked" event such as the holiday whose candle-lighting time this
12458
+ * represents.
12459
+ */
12460
+ class TimedEvent extends Event {
12461
+ /**
12462
+ * Normally created by {@link calendar} rather than directly.
12463
+ * @param date Hebrew date the event occurs
12464
+ * @param desc Description (not translated)
12465
+ * @param mask optional holiday flags
12466
+ * @param eventTime the exact moment of the event
12467
+ * @param location geographic location used to format the time
12468
+ * @param linkedEvent optional event this time is associated with
12469
+ * @param options optional; `locale` and `hour12` affect {@link fmtTime}
12470
+ */
12471
+ constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
12472
+ super(date, desc, mask);
12473
+ this.eventTime = Zmanim.roundTime(eventTime);
12474
+ this.location = location;
12475
+ const timeFormat = location.getTimeFormatter();
12476
+ this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
12477
+ const opts = { ...options, location };
12478
+ this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
12479
+ if (linkedEvent !== undefined) {
12480
+ this.linkedEvent = linkedEvent;
12481
+ }
12482
+ }
12483
+ /**
12484
+ * @param [locale] Optional locale name (defaults to empty locale)
12485
+ */
12486
+ render(locale) {
12487
+ return `${Locale.gettext(this.getDesc(), locale)}: ${this.fmtTime}`;
12488
+ }
12489
+ /**
12490
+ * Returns translation of "Candle lighting" without the time.
12491
+ * @param [locale] Optional locale name (defaults to empty locale)
12492
+ */
12493
+ renderBrief(locale) {
12494
+ return Locale.gettext(this.getDesc(), locale);
12495
+ }
12496
+ getCategories() {
12497
+ const desc = this.getDesc();
12498
+ switch (desc) {
12499
+ // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
12500
+ case CANDLE_LIGHTING:
12501
+ return ['candles'];
12502
+ // YOM_TOV_ENDS
12503
+ case HAVDALAH:
12504
+ return ['havdalah'];
12505
+ // flags.MINOR_FAST or flags.MAJOR_FAST
12506
+ case holidayDesc.FAST_BEGINS:
12507
+ case holidayDesc.FAST_ENDS:
12508
+ return ['zmanim', 'fast'];
12509
+ case holidayDesc.SOF_ZMAN_ACHILAT_CHAMETZ:
12510
+ return ['zmanim', 'achilasChametz'];
12511
+ case holidayDesc.BIUR_CHAMETZ:
12512
+ return ['zmanim', 'biurChametz'];
12513
+ }
12514
+ /* NOTREACHED */
12515
+ return ['unknown'];
12516
+ }
12517
+ }
12518
+ /**
12519
+ * Candle-lighting event for the eve of Shabbat or a Yom Tov.
12520
+ *
12521
+ * Generated by {@link calendar} when `options.candlelighting`
12522
+ * is `true` and `options.location` is provided. By default candle lighting
12523
+ * occurs 18 minutes before sundown in the Diaspora and 20 minutes before
12524
+ * sundown in Israel (40 minutes in Jerusalem; 30 minutes in Haifa and
12525
+ * Zikhron Ya'akov), configurable via `options.candleLightingMins`.
12526
+ */
12527
+ class CandleLightingEvent extends TimedEvent {
12528
+ constructor(date, mask, eventTime, location, linkedEvent, options) {
12529
+ super(date, CANDLE_LIGHTING, mask, eventTime, location, linkedEvent, options);
12530
+ }
12531
+ getEmoji() {
12532
+ return '🕯️';
12533
+ }
12534
+ }
12535
+ /**
12536
+ * Havdalah event marking the end of Shabbat or a Yom Tov.
12537
+ *
12538
+ * Generated by {@link calendar} when `options.candlelighting`
12539
+ * is `true` and `options.location` is provided. By default Havdalah is
12540
+ * calculated by *tzeit hakochavim* (8.5° solar depression); pass
12541
+ * `options.havdalahMins` to use a fixed minute offset instead, or
12542
+ * `options.havdalahDeg` to use a different degree.
12543
+ */
12544
+ class HavdalahEvent extends TimedEvent {
12545
+ constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
12546
+ super(date, HAVDALAH, mask, eventTime, location, linkedEvent, options);
12547
+ if (havdalahMins) {
12548
+ this.havdalahMins = havdalahMins;
12549
+ }
12550
+ }
12551
+ /**
12552
+ * @param [locale] Optional locale name (defaults to empty locale)
12553
+ */
12554
+ render(locale) {
12555
+ return `${this.renderBrief(locale)}: ${this.fmtTime}`;
12556
+ }
12557
+ /**
12558
+ * Returns translation of "Havdalah" without the time.
12559
+ * @param [locale] Optional locale name (defaults to empty locale)
12560
+ */
12561
+ renderBrief(locale) {
12562
+ let str = Locale.gettext(this.getDesc(), locale);
12563
+ if (this.havdalahMins) {
12564
+ const min = Locale.gettext('min', locale);
12565
+ str += ` (${this.havdalahMins} ${min})`;
12566
+ }
12567
+ return str;
12568
+ }
12569
+ getEmoji() {
12570
+ return '✨';
12571
+ }
12572
+ }
12573
+
12445
12574
  const ykk = 'Yom Kippur Katan';
12446
12575
  /** YKK is minor day of atonement on the day preceeding each Rosh Chodesh */
12447
12576
  class YomKippurKatanEvent extends HolidayEvent {
@@ -12524,7 +12653,7 @@ function getHolidaysOnDate(date, il) {
12524
12653
  }
12525
12654
  return events.filter(ev => ev.observedIn(il));
12526
12655
  }
12527
- const { CHAG, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2, CHANUKAH_CANDLES: CHANUKAH_CANDLES$1, BEHAB: BEHAB$1, MINOR_FAST: MINOR_FAST$1, SPECIAL_SHABBAT: SPECIAL_SHABBAT$1, MAJOR_FAST: MAJOR_FAST$1, MINOR_HOLIDAY: MINOR_HOLIDAY$1, EREV: EREV$1, SHABBAT_MEVARCHIM: SHABBAT_MEVARCHIM$1, } = flags;
12656
+ const { CHAG, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$2, CHANUKAH_CANDLES: CHANUKAH_CANDLES$1, BEHAB: BEHAB$1, MINOR_FAST: MINOR_FAST$1, SPECIAL_SHABBAT: SPECIAL_SHABBAT$1, MAJOR_FAST: MAJOR_FAST$1, MINOR_HOLIDAY: MINOR_HOLIDAY$1, EREV: EREV$1, } = flags;
12528
12657
  const SUN = 0;
12529
12658
  const TUE = 2;
12530
12659
  const THU = 4;
@@ -12545,36 +12674,74 @@ function addToMap(map, ...events) {
12545
12674
  }
12546
12675
  }
12547
12676
  /** @internal */
12548
- const TIME_OF_DAY_MORNING = 0;
12677
+ const TIME_OF_DAY_DAWN = 0;
12678
+ /** @internal */
12679
+ const TIME_OF_DAY_MORNING = 1;
12549
12680
  /** @internal */
12550
- const TIME_OF_DAY_MEVARCHIM = 1;
12681
+ const TIME_OF_DAY_MEVARCHIM = 2;
12551
12682
  /** @internal */
12552
- const TIME_OF_DAY_DAY = 2;
12683
+ const TIME_OF_DAY_DAY = 3;
12553
12684
  /** @internal */
12554
- const TIME_OF_DAY_EVENING = 3;
12685
+ const TIME_OF_DAY_MIDDAY = 4;
12686
+ /** @internal */
12687
+ const TIME_OF_DAY_LEARNING = 5;
12688
+ /** @internal */
12689
+ const TIME_OF_DAY_EVENING = 6;
12690
+ /** @internal */
12691
+ const TIME_OF_DAY_NIGHT = 7;
12555
12692
  /**
12556
12693
  * Approximate time of day of an event, used to order events on the same date.
12557
- * - Morning: special Shabbatot (tied to the Torah or Haftarah reading), minor
12558
- * fasts (which begin at dawn) and Birkat Hachamah (recited at sunrise)
12559
- * - Shabbat Mevarchim, announced in synagogue after the Torah reading
12560
- * - Day: everything else
12694
+ * Events of equal rank keep the order in which they were created, and timed
12695
+ * events of equal rank are ordered by their time.
12696
+ * - Dawn: Fast begins for a minor fast, and a Latest Kiddush Levana before
12697
+ * noon (which is never later than _alot hashachar_)
12698
+ * - Morning: the parsha, special Shabbatot (tied to the Torah or Haftarah
12699
+ * reading), minor fasts (which begin at dawn) and Birkat Hachamah
12700
+ * (recited at sunrise)
12701
+ * - Molad and Shabbat Mevarchim, announced in synagogue after the Torah
12702
+ * reading
12703
+ * - Day: everything else, including Yizkor and the Omer count
12704
+ * - Midday: the deadlines for eating and burning chametz
12705
+ * - Daily learning
12561
12706
  * - Evening: Erev holidays, Chanukah candle-lighting and Leil Selichot
12707
+ * - Night: other timed events such as candle-lighting, Havdalah,
12708
+ * Fast ends, and a Latest Kiddush Levana after noon
12562
12709
  * @internal
12563
12710
  */
12564
12711
  function timeOfDay(ev) {
12565
- const mask = ev.getFlags();
12712
+ if (ev instanceof TimedEvent) {
12713
+ return timedEventTimeOfDay(ev);
12714
+ }
12566
12715
  const desc = ev.getDesc();
12567
- if (mask & (EREV$1 | CHANUKAH_CANDLES$1) || desc === holidayDesc.LEIL_SELICHOT) {
12716
+ if (ev.hasAnyFlag('EREV', 'CHANUKAH_CANDLES') || desc === holidayDesc.LEIL_SELICHOT) {
12568
12717
  return TIME_OF_DAY_EVENING;
12569
12718
  }
12570
- if (mask & (SPECIAL_SHABBAT$1 | MINOR_FAST$1) || desc === holidayDesc.BIRKAT_HACHAMAH) {
12719
+ if (ev.hasAnyFlag('PARSHA_HASHAVUA', 'SPECIAL_SHABBAT', 'MINOR_FAST') ||
12720
+ desc === holidayDesc.BIRKAT_HACHAMAH) {
12571
12721
  return TIME_OF_DAY_MORNING;
12572
12722
  }
12573
- if (mask & SHABBAT_MEVARCHIM$1) {
12723
+ if (ev.hasAnyFlag('SHABBAT_MEVARCHIM', 'MOLAD')) {
12574
12724
  return TIME_OF_DAY_MEVARCHIM;
12575
12725
  }
12726
+ if (ev.hasAnyFlag('DAILY_LEARNING', 'DAF_YOMI', 'MISHNA_YOMI', 'NACH_YOMI', 'YERUSHALMI_YOMI')) {
12727
+ return TIME_OF_DAY_LEARNING;
12728
+ }
12576
12729
  return TIME_OF_DAY_DAY;
12577
12730
  }
12731
+ function timedEventTimeOfDay(ev) {
12732
+ const desc = ev.getDesc();
12733
+ if (desc === holidayDesc.SOF_ZMAN_ACHILAT_CHAMETZ || desc === holidayDesc.BIUR_CHAMETZ) {
12734
+ return TIME_OF_DAY_MIDDAY;
12735
+ }
12736
+ // A minor fast begins at dawn, but Tish'a B'Av at sunset the day before.
12737
+ // Latest Kiddush Levana is either before dawn or after nightfall.
12738
+ if (desc === holidayDesc.FAST_BEGINS || ev.hasFlag('KIDDUSH_LEVANA')) {
12739
+ // `eventTimeStr` is 24-hour local time; some engines format midnight as 24:00
12740
+ const hour = Number.parseInt(ev.eventTimeStr, 10) % 24;
12741
+ return hour < 12 ? TIME_OF_DAY_DAWN : TIME_OF_DAY_NIGHT;
12742
+ }
12743
+ return TIME_OF_DAY_NIGHT;
12744
+ }
12578
12745
  function addStaticHolidays(map, year) {
12579
12746
  for (const h of staticHolidays) {
12580
12747
  const hd = new HDate(h.dd, h.mm, year);
@@ -12950,131 +13117,6 @@ function isFastDay(date, il) {
12950
13117
  return events.some(ev => ev.hasAnyFlag('MAJOR_FAST', 'MINOR_FAST') && !ev.hasFlag('EREV'));
12951
13118
  }
12952
13119
 
12953
- const { HAVDALAH, CANDLE_LIGHTING } = holidayDesc;
12954
- /**
12955
- * Base class for events that have an associated wall-clock time and
12956
- * geographic location — for example, candle lighting, havdalah, and
12957
- * fast begin/end times.
12958
- *
12959
- * Stores both a `Date` (`eventTime`) and pre-formatted 24-hour
12960
- * (`eventTimeStr`) and locale-aware (`fmtTime`) strings. May reference a
12961
- * "linked" event such as the holiday whose candle-lighting time this
12962
- * represents.
12963
- */
12964
- class TimedEvent extends Event {
12965
- /**
12966
- * Normally created by {@link calendar} rather than directly.
12967
- * @param date Hebrew date the event occurs
12968
- * @param desc Description (not translated)
12969
- * @param mask optional holiday flags
12970
- * @param eventTime the exact moment of the event
12971
- * @param location geographic location used to format the time
12972
- * @param linkedEvent optional event this time is associated with
12973
- * @param options optional; `locale` and `hour12` affect {@link fmtTime}
12974
- */
12975
- constructor(date, desc, mask, eventTime, location, linkedEvent, options) {
12976
- super(date, desc, mask);
12977
- this.eventTime = Zmanim.roundTime(eventTime);
12978
- this.location = location;
12979
- const timeFormat = location.getTimeFormatter();
12980
- this.eventTimeStr = Zmanim.formatTime(this.eventTime, timeFormat);
12981
- const opts = { ...options, location };
12982
- this.fmtTime = reformatTimeStr(this.eventTimeStr, 'pm', opts);
12983
- if (linkedEvent !== undefined) {
12984
- this.linkedEvent = linkedEvent;
12985
- }
12986
- }
12987
- /**
12988
- * @param [locale] Optional locale name (defaults to empty locale)
12989
- */
12990
- render(locale) {
12991
- return `${Locale.gettext(this.getDesc(), locale)}: ${this.fmtTime}`;
12992
- }
12993
- /**
12994
- * Returns translation of "Candle lighting" without the time.
12995
- * @param [locale] Optional locale name (defaults to empty locale)
12996
- */
12997
- renderBrief(locale) {
12998
- return Locale.gettext(this.getDesc(), locale);
12999
- }
13000
- getCategories() {
13001
- const desc = this.getDesc();
13002
- switch (desc) {
13003
- // LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
13004
- case CANDLE_LIGHTING:
13005
- return ['candles'];
13006
- // YOM_TOV_ENDS
13007
- case HAVDALAH:
13008
- return ['havdalah'];
13009
- // flags.MINOR_FAST or flags.MAJOR_FAST
13010
- case holidayDesc.FAST_BEGINS:
13011
- case holidayDesc.FAST_ENDS:
13012
- return ['zmanim', 'fast'];
13013
- case holidayDesc.SOF_ZMAN_ACHILAT_CHAMETZ:
13014
- return ['zmanim', 'achilasChametz'];
13015
- case holidayDesc.BIUR_CHAMETZ:
13016
- return ['zmanim', 'biurChametz'];
13017
- }
13018
- /* NOTREACHED */
13019
- return ['unknown'];
13020
- }
13021
- }
13022
- /**
13023
- * Candle-lighting event for the eve of Shabbat or a Yom Tov.
13024
- *
13025
- * Generated by {@link calendar} when `options.candlelighting`
13026
- * is `true` and `options.location` is provided. By default candle lighting
13027
- * occurs 18 minutes before sundown in the Diaspora and 20 minutes before
13028
- * sundown in Israel (40 minutes in Jerusalem; 30 minutes in Haifa and
13029
- * Zikhron Ya'akov), configurable via `options.candleLightingMins`.
13030
- */
13031
- class CandleLightingEvent extends TimedEvent {
13032
- constructor(date, mask, eventTime, location, linkedEvent, options) {
13033
- super(date, CANDLE_LIGHTING, mask, eventTime, location, linkedEvent, options);
13034
- }
13035
- getEmoji() {
13036
- return '🕯️';
13037
- }
13038
- }
13039
- /**
13040
- * Havdalah event marking the end of Shabbat or a Yom Tov.
13041
- *
13042
- * Generated by {@link calendar} when `options.candlelighting`
13043
- * is `true` and `options.location` is provided. By default Havdalah is
13044
- * calculated by *tzeit hakochavim* (8.5° solar depression); pass
13045
- * `options.havdalahMins` to use a fixed minute offset instead, or
13046
- * `options.havdalahDeg` to use a different degree.
13047
- */
13048
- class HavdalahEvent extends TimedEvent {
13049
- constructor(date, mask, eventTime, location, havdalahMins, linkedEvent, options) {
13050
- super(date, HAVDALAH, mask, eventTime, location, linkedEvent, options);
13051
- if (havdalahMins) {
13052
- this.havdalahMins = havdalahMins;
13053
- }
13054
- }
13055
- /**
13056
- * @param [locale] Optional locale name (defaults to empty locale)
13057
- */
13058
- render(locale) {
13059
- return `${this.renderBrief(locale)}: ${this.fmtTime}`;
13060
- }
13061
- /**
13062
- * Returns translation of "Havdalah" without the time.
13063
- * @param [locale] Optional locale name (defaults to empty locale)
13064
- */
13065
- renderBrief(locale) {
13066
- let str = Locale.gettext(this.getDesc(), locale);
13067
- if (this.havdalahMins) {
13068
- const min = Locale.gettext('min', locale);
13069
- str += ` (${this.havdalahMins} ${min})`;
13070
- }
13071
- return str;
13072
- }
13073
- getEmoji() {
13074
- return '✨';
13075
- }
13076
- }
13077
-
13078
13120
  const { LIGHT_CANDLES: LIGHT_CANDLES$1, LIGHT_CANDLES_TZEIS: LIGHT_CANDLES_TZEIS$1 } = flags;
13079
13121
  const { FAST_BEGINS, FAST_ENDS } = holidayDesc;
13080
13122
  /** @internal */
@@ -14511,6 +14553,16 @@ class MevarchimChodeshEvent extends Event {
14511
14553
  * * `options.addHebrewDates` - print the Hebrew date for the entire date range
14512
14554
  * * `options.addHebrewDatesForEvents` - print the Hebrew date for dates with some events
14513
14555
  *
14556
+ * Events are returned in date order. Events on the same date are ordered by
14557
+ * approximate time of day: timed events before dawn (Fast begins, an early
14558
+ * Latest Kiddush Levana), then the parsha, special Shabbatot and minor fasts,
14559
+ * then the Molad and Shabbat Mevarchim, then other holidays, Yizkor and the
14560
+ * Omer, then the chametz deadlines on Erev Pesach, then daily learning, then
14561
+ * evening holidays (Erev holidays, Chanukah), and finally the remaining timed
14562
+ * events (candle-lighting, Havdalah, Fast ends) in order of time. When
14563
+ * `options.addHebrewDates` or `options.addHebrewDatesForEvents` adds a Hebrew
14564
+ * date event, it comes first.
14565
+ *
14514
14566
  * Lastly, translation and transliteration of event titles is controlled by
14515
14567
  * `options.locale` and the {@link Locale} API.
14516
14568
  * `@hebcal/core` supports three locales by default:
@@ -14601,26 +14653,18 @@ function calendar(options = {}) {
14601
14653
  let candlesEv;
14602
14654
  const holidays0 = holidaysYear.get(hd.toString()) || [];
14603
14655
  const holidays = holidays0.filter(ev => ev.observedIn(il));
14604
- // On Shabbat, events tied to the morning Torah reading and announcements
14605
- // in synagogue come first: the parsha, special Shabbatot such as
14606
- // Shabbat Shekalim, then the Molad and Shabbat Mevarchim
14607
14656
  if (options.sedrot && isSaturday) {
14608
14657
  const parsha0 = sedra.lookup(abs);
14609
14658
  if (!parsha0.chag) {
14610
14659
  evts.push(new ParshaEvent(parsha0));
14611
14660
  }
14612
14661
  }
14613
- let mevarchim = isSaturday && (options.molad || options.shabbatMevarchim)
14614
- ? makeMoladAndMevarchimChodesh(hd, options)
14615
- : [];
14662
+ if (isSaturday && (options.molad || options.shabbatMevarchim)) {
14663
+ evts.push(...makeMoladAndMevarchimChodesh(hd, options));
14664
+ }
14616
14665
  for (const ev of holidays) {
14617
- if (mevarchim.length && timeOfDay(ev) > TIME_OF_DAY_MEVARCHIM) {
14618
- evts.push(...mevarchim);
14619
- mevarchim = [];
14620
- }
14621
14666
  candlesEv = appendHolidayAndRelated(candlesEv, evts, ev, options, isFriday, isSaturday, hasUserMask);
14622
14667
  }
14623
- evts.push(...mevarchim);
14624
14668
  const mm = hd.getMonth();
14625
14669
  const dd = hd.getDate();
14626
14670
  // When Erev Pesach falls on Shabbat, burning chametz is moved to Friday.
@@ -14686,9 +14730,10 @@ function calendar(options = {}) {
14686
14730
  kiddushLevanaEv = makeKiddushLevanaEvent(hyear, mm, options);
14687
14731
  }
14688
14732
  if (kiddushLevanaEv?.getDate().abs() === abs) {
14689
- insertTimedEvent(evts, prevEventsLength, kiddushLevanaEv);
14733
+ evts.push(kiddushLevanaEv);
14690
14734
  }
14691
14735
  }
14736
+ sortByTimeOfDay(evts, prevEventsLength);
14692
14737
  if (options.addHebrewDates ||
14693
14738
  (options.addHebrewDatesForEvents &&
14694
14739
  prevEventsLength !== evts.length - numDailyLearning)) {
@@ -14994,22 +15039,28 @@ function setOptionsFromMask(options) {
14994
15039
  options.kiddushLevanaMaharil = true;
14995
15040
  return m;
14996
15041
  }
15042
+ function compareTimeOfDay(a, b) {
15043
+ const diff = timeOfDay(a) - timeOfDay(b);
15044
+ if (diff !== 0) {
15045
+ return diff;
15046
+ }
15047
+ if (a instanceof TimedEvent && b instanceof TimedEvent) {
15048
+ return a.eventTime.getTime() - b.eventTime.getTime();
15049
+ }
15050
+ return 0;
15051
+ }
14997
15052
  /**
14998
- * Inserts `ev` into today's events (those at index `start` and beyond)
14999
- * just before the first `TimedEvent` that occurs later, or appends it.
15000
- * Unlike other timed events, Latest Kiddush Levana may fall at dawn,
15001
- * at candle-lighting or late at night, so its position can't be fixed.
15053
+ * Sorts today's events (those at index `start` and beyond) in place by
15054
+ * {@link timeOfDay}. The sort is stable, so events of equal rank keep the
15055
+ * order in which they were added, e.g. Yizkor after its holiday.
15002
15056
  */
15003
- function insertTimedEvent(events, start, ev) {
15004
- const time = ev.eventTime.getTime();
15005
- for (let i = start; i < events.length; i++) {
15006
- const other = events[i];
15007
- if (other instanceof TimedEvent && other.eventTime.getTime() > time) {
15008
- events.splice(i, 0, ev);
15009
- return;
15010
- }
15057
+ function sortByTimeOfDay(events, start) {
15058
+ if (events.length - start < 2) {
15059
+ return;
15011
15060
  }
15012
- events.push(ev);
15061
+ const today = events.splice(start);
15062
+ today.sort(compareTimeOfDay);
15063
+ events.push(...today);
15013
15064
  }
15014
15065
  /**
15015
15066
  * Appends the Event `ev` to the `events` array. Also may add related