@event-calendar/core 4.5.2 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * EventCalendar v4.5.2
2
+ * EventCalendar v4.7.0
3
3
  * https://github.com/vkurko/calendar
4
4
  */
5
5
  import { tick, getContext, untrack, setContext, onMount, mount, unmount } from "svelte";
@@ -18,9 +18,9 @@ function setContent(node, content) {
18
18
  update(content2) {
19
19
  if (typeof content2 == "string") {
20
20
  node.innerText = content2;
21
- } else if (content2 == null ? void 0 : content2.domNodes) {
21
+ } else if (content2?.domNodes) {
22
22
  node.replaceChildren(...content2.domNodes);
23
- } else if (content2 == null ? void 0 : content2.html) {
23
+ } else if (content2?.html) {
24
24
  node.innerHTML = content2.html;
25
25
  }
26
26
  }
@@ -251,7 +251,7 @@ function flushDebounce(queue) {
251
251
  queue.clear();
252
252
  }
253
253
  function task(fn, handle, tasks) {
254
- handle ?? (handle = fn);
254
+ handle ??= fn;
255
255
  if (!tasks.has(handle)) {
256
256
  tasks.set(handle, setTimeout(() => {
257
257
  tasks.delete(handle);
@@ -264,7 +264,7 @@ function setPayload(obj, payload) {
264
264
  obj[payloadProp] = payload;
265
265
  }
266
266
  function hasPayload(obj) {
267
- return !!(obj == null ? void 0 : obj[payloadProp]);
267
+ return !!obj?.[payloadProp];
268
268
  }
269
269
  function getPayload(obj) {
270
270
  return obj[payloadProp];
@@ -395,8 +395,23 @@ function createEventChunk(event, start, end) {
395
395
  chunk.zeroDuration = datesEqual(chunk.start, chunk.end);
396
396
  return chunk;
397
397
  }
398
- function sortEventChunks(chunks) {
399
- chunks.sort((a, b) => a.start - b.start || b.event.allDay - a.event.allDay);
398
+ function sortEventChunks(chunks, eventOrder) {
399
+ if (isFunction(eventOrder)) {
400
+ chunks.sort((a, b) => eventOrder(
401
+ _toChunkWithLocalDates(a),
402
+ _toChunkWithLocalDates(b)
403
+ ));
404
+ } else {
405
+ chunks.sort((a, b) => a.start - b.start || b.event.allDay - a.event.allDay);
406
+ }
407
+ }
408
+ function _toChunkWithLocalDates(chunk) {
409
+ return {
410
+ ...chunk,
411
+ start: toLocalDate(chunk.start),
412
+ end: toLocalDate(chunk.end),
413
+ event: toEventWithLocalDates(chunk.event)
414
+ };
400
415
  }
401
416
  function createEventContent(chunk, displayEventEnd, eventContent, theme, _intlEventTime, _view) {
402
417
  let timeText = _intlEventTime.formatRange(
@@ -466,10 +481,10 @@ function _cloneEvent(event, dateFn) {
466
481
  event.end = dateFn(event.end);
467
482
  return event;
468
483
  }
469
- function prepareEventChunks$1(chunks, hiddenDays) {
484
+ function prepareEventChunks$1(chunks, hiddenDays, eventOrder) {
470
485
  let longChunks = {};
471
486
  if (chunks.length) {
472
- sortEventChunks(chunks);
487
+ sortEventChunks(chunks, eventOrder);
473
488
  let prevChunk;
474
489
  for (let chunk of chunks) {
475
490
  let dates = [];
@@ -540,11 +555,10 @@ function repositionEvent$1(chunk, longChunks, height2) {
540
555
  return margin;
541
556
  }
542
557
  function runReposition(refs, data) {
543
- var _a;
544
558
  refs.length = data.length;
545
559
  let result = [];
546
560
  for (let ref of refs) {
547
- result.push((_a = ref == null ? void 0 : ref.reposition) == null ? void 0 : _a.call(ref));
561
+ result.push(ref?.reposition?.());
548
562
  }
549
563
  return result;
550
564
  }
@@ -656,12 +670,10 @@ function createResource(input) {
656
670
  };
657
671
  }
658
672
  function resourceBackgroundColor(event, resources) {
659
- var _a;
660
- return (_a = findResource(event, resources)) == null ? void 0 : _a.eventBackgroundColor;
673
+ return findResource(event, resources)?.eventBackgroundColor;
661
674
  }
662
675
  function resourceTextColor(event, resources) {
663
- var _a;
664
- return (_a = findResource(event, resources)) == null ? void 0 : _a.eventTextColor;
676
+ return findResource(event, resources)?.eventTextColor;
665
677
  }
666
678
  function findResource(event, resources) {
667
679
  return resources.find((resource) => event.resourceIds.includes(resource.id));
@@ -769,7 +781,7 @@ function createSlotTimeLimits($slotMinTime, $slotMaxTime, $flexibleSlotTimeLimit
769
781
  if ($flexibleSlotTimeLimits) {
770
782
  let minMin = createDuration(min(toSeconds(min$1), max(0, toSeconds(max$1) - DAY_IN_SECONDS)));
771
783
  let maxMax = createDuration(max(toSeconds(max$1), toSeconds(minMin) + DAY_IN_SECONDS));
772
- let filter = isFunction($flexibleSlotTimeLimits == null ? void 0 : $flexibleSlotTimeLimits.eventFilter) ? $flexibleSlotTimeLimits.eventFilter : (event) => !bgEvent(event.display);
784
+ let filter = isFunction($flexibleSlotTimeLimits?.eventFilter) ? $flexibleSlotTimeLimits.eventFilter : (event) => !bgEvent(event.display);
773
785
  loop: for (let date of $_viewDates) {
774
786
  let start = addDuration(cloneDate(date), min$1);
775
787
  let end = addDuration(cloneDate(date), max$1);
@@ -798,8 +810,8 @@ function createSlotTimeLimits($slotMinTime, $slotMaxTime, $flexibleSlotTimeLimit
798
810
  }
799
811
  return { min: min$1, max: max$1 };
800
812
  }
813
+ const specialOptions = ["buttonText", "customButtons", "theme"];
801
814
  function createOptions(plugins) {
802
- var _a;
803
815
  let options = {
804
816
  allDayContent: void 0,
805
817
  allDaySlot: true,
@@ -831,6 +843,7 @@ function createOptions(plugins) {
831
843
  // ec option
832
844
  eventMouseEnter: void 0,
833
845
  eventMouseLeave: void 0,
846
+ eventOrder: void 0,
834
847
  eventSources: [],
835
848
  eventTextColor: void 0,
836
849
  eventTimeFormat: {
@@ -924,12 +937,11 @@ function createOptions(plugins) {
924
937
  views: {}
925
938
  };
926
939
  for (let plugin of plugins) {
927
- (_a = plugin.createOptions) == null ? void 0 : _a.call(plugin, options);
940
+ plugin.createOptions?.(options);
928
941
  }
929
942
  return options;
930
943
  }
931
944
  function createParsers(plugins) {
932
- var _a;
933
945
  let parsers = {
934
946
  date: (date) => setMidnight(createDate(date)),
935
947
  duration: createDuration,
@@ -946,7 +958,7 @@ function createParsers(plugins) {
946
958
  validRange: createDateRange
947
959
  };
948
960
  for (let plugin of plugins) {
949
- (_a = plugin.createParsers) == null ? void 0 : _a.call(plugin, parsers);
961
+ plugin.createParsers?.(parsers);
950
962
  }
951
963
  return parsers;
952
964
  }
@@ -960,7 +972,7 @@ function diff(options, prevOptions) {
960
972
  return diff2;
961
973
  }
962
974
  function dayGrid(state) {
963
- return derived(state.view, ($view) => $view == null ? void 0 : $view.startsWith("dayGrid"));
975
+ return derived(state.view, ($view) => $view?.startsWith("dayGrid"));
964
976
  }
965
977
  function activeRange(state) {
966
978
  return derived(
@@ -1134,7 +1146,6 @@ function today(state) {
1134
1146
  }
1135
1147
  class State {
1136
1148
  constructor(plugins, input) {
1137
- var _a, _b;
1138
1149
  plugins = plugins || [];
1139
1150
  let options = createOptions(plugins);
1140
1151
  let parsers = createParsers(plugins);
@@ -1180,7 +1191,7 @@ class State {
1180
1191
  };
1181
1192
  this._get = (key) => validKey(key, this) ? get(this[key]) : void 0;
1182
1193
  for (let plugin of plugins) {
1183
- (_a = plugin.createStores) == null ? void 0 : _a.call(plugin, this);
1194
+ plugin.createStores?.(this);
1184
1195
  }
1185
1196
  if (input.view) {
1186
1197
  this.view.set(input.view);
@@ -1188,14 +1199,14 @@ class State {
1188
1199
  let views = /* @__PURE__ */ new Set([...keys(options.views), ...keys(input.views ?? {})]);
1189
1200
  for (let view2 of views) {
1190
1201
  let defOpts = mergeOpts(options, options.views[view2] ?? {});
1191
- let opts = mergeOpts(defOpts, input, ((_b = input.views) == null ? void 0 : _b[view2]) ?? {});
1202
+ let opts = mergeOpts(defOpts, input, input.views?.[view2] ?? {});
1192
1203
  let component = opts.component;
1193
1204
  filterOpts(opts, this);
1194
1205
  for (let key of keys(opts)) {
1195
1206
  let { set, _set = set, ...rest } = this[key];
1196
1207
  this[key] = {
1197
1208
  // Set value in all views
1198
- set: ["buttonText", "theme"].includes(key) ? (value) => {
1209
+ set: specialOptions.includes(key) ? (value) => {
1199
1210
  if (isFunction(value)) {
1200
1211
  let result = value(defOpts[key]);
1201
1212
  opts[key] = result;
@@ -1247,7 +1258,7 @@ function mergeOpts(...args) {
1247
1258
  let result = {};
1248
1259
  for (let opts of args) {
1249
1260
  let override = {};
1250
- for (let key of ["buttonText", "theme"]) {
1261
+ for (let key of specialOptions) {
1251
1262
  if (isFunction(opts[key])) {
1252
1263
  override[key] = opts[key](result[key]);
1253
1264
  }
@@ -1274,7 +1285,6 @@ var root_10$1 = $.from_html(`<button></button>`);
1274
1285
  var root_12$1 = $.from_html(`<button> </button>`);
1275
1286
  function Buttons($$anchor, $$props) {
1276
1287
  $.push($$props, false);
1277
- const [$$stores, $$cleanup] = $.setup_stores();
1278
1288
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
1279
1289
  const $date = () => $.store_get(date, "$date", $$stores);
1280
1290
  const $duration = () => $.store_get(duration, "$duration", $$stores);
@@ -1286,6 +1296,7 @@ function Buttons($$anchor, $$props) {
1286
1296
  const $buttonText = () => $.store_get(buttonText, "$buttonText", $$stores);
1287
1297
  const $customButtons = () => $.store_get(customButtons, "$customButtons", $$stores);
1288
1298
  const $view = () => $.store_get(view2, "$view", $$stores);
1299
+ const [$$stores, $$cleanup] = $.setup_stores();
1289
1300
  let buttons = $.prop($$props, "buttons", 8);
1290
1301
  let {
1291
1302
  _currentRange,
@@ -1355,7 +1366,7 @@ function Buttons($$anchor, $$props) {
1355
1366
  {
1356
1367
  var consequent = ($$anchor3) => {
1357
1368
  var h2 = root_2$7();
1358
- $.action(h2, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), $_viewTitle);
1369
+ $.action(h2, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), $_viewTitle);
1359
1370
  $.template_effect(() => $.set_class(h2, 1, ($theme(), $.untrack(() => $theme().title))));
1360
1371
  $.append($$anchor3, h2);
1361
1372
  };
@@ -1418,10 +1429,9 @@ function Buttons($$anchor, $$props) {
1418
1429
  var consequent_4 = ($$anchor7) => {
1419
1430
  var button_4 = root_10$1();
1420
1431
  $.effect(() => $.event("click", button_4, function(...$$args) {
1421
- var _a;
1422
- (_a = $customButtons()[$.get(button)].click) == null ? void 0 : _a.apply(this, $$args);
1432
+ $customButtons()[$.get(button)].click?.apply(this, $$args);
1423
1433
  }));
1424
- $.action(button_4, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $customButtons()[$.get(button)].text);
1434
+ $.action(button_4, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $customButtons()[$.get(button)].text);
1425
1435
  $.template_effect(() => $.set_class(button_4, 1, `${($theme(), $.untrack(() => $theme().button)) ?? ""} ec-${$.get(button) ?? ""}${($customButtons(), $.get(button), $theme(), $.untrack(() => $customButtons()[$.get(button)].active ? " " + $theme().active : "")) ?? ""}`));
1426
1436
  $.append($$anchor7, button_4);
1427
1437
  };
@@ -1510,15 +1520,14 @@ var root_1$d = $.from_html(`<div></div>`);
1510
1520
  var root$r = $.from_html(`<nav></nav>`);
1511
1521
  function Toolbar($$anchor, $$props) {
1512
1522
  $.push($$props, true);
1513
- const [$$stores, $$cleanup] = $.setup_stores();
1514
1523
  const $headerToolbar = () => $.store_get(headerToolbar, "$headerToolbar", $$stores);
1515
1524
  const $theme = () => $.store_get(theme, "$theme", $$stores);
1525
+ const [$$stores, $$cleanup] = $.setup_stores();
1516
1526
  let { headerToolbar, theme } = getContext("state");
1517
1527
  let sections = $.derived(() => {
1518
- var _a;
1519
1528
  let sections2 = {};
1520
1529
  for (let key of ["start", "center", "end"]) {
1521
- sections2[key] = ((_a = $headerToolbar()[key]) == null ? void 0 : _a.split(" ").map((group) => group.split(","))) ?? [];
1530
+ sections2[key] = $headerToolbar()[key]?.split(" ").map((group) => group.split(",")) ?? [];
1522
1531
  }
1523
1532
  return sections2;
1524
1533
  });
@@ -1567,7 +1576,6 @@ function Toolbar($$anchor, $$props) {
1567
1576
  }
1568
1577
  function Auxiliary$1($$anchor, $$props) {
1569
1578
  $.push($$props, true);
1570
- const [$$stores, $$cleanup] = $.setup_stores();
1571
1579
  const $_activeRange = () => $.store_get(_activeRange, "$_activeRange", $$stores);
1572
1580
  const $datesSet = () => $.store_get(datesSet, "$datesSet", $$stores);
1573
1581
  const $_view = () => $.store_get(_view, "$_view", $$stores);
@@ -1577,6 +1585,7 @@ function Auxiliary$1($$anchor, $$props) {
1577
1585
  const $_recheckScrollable = () => $.store_get(_recheckScrollable, "$_recheckScrollable", $$stores);
1578
1586
  const $_bodyEl = () => $.store_get(_bodyEl, "$_bodyEl", $$stores);
1579
1587
  const $_auxiliary = () => $.store_get(_auxiliary, "$_auxiliary", $$stores);
1588
+ const [$$stores, $$cleanup] = $.setup_stores();
1580
1589
  let {
1581
1590
  datesSet,
1582
1591
  eventAllUpdated,
@@ -1644,7 +1653,6 @@ function Auxiliary$1($$anchor, $$props) {
1644
1653
  var root$q = $.from_html(`<div><!> <!></div> <!>`, 1);
1645
1654
  function Calendar($$anchor, $$props) {
1646
1655
  $.push($$props, true);
1647
- const [$$stores, $$cleanup] = $.setup_stores();
1648
1656
  const $_events = () => $.store_get(_events, "$_events", $$stores);
1649
1657
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
1650
1658
  const $date = () => $.store_get(date, "$date", $$stores);
@@ -1656,6 +1664,7 @@ function Calendar($$anchor, $$props) {
1656
1664
  const $_iClass = () => $.store_get(_iClass, "$_iClass", $$stores);
1657
1665
  const $height = () => $.store_get(height2, "$height", $$stores);
1658
1666
  const $view = () => $.store_get(view2, "$view", $$stores);
1667
+ const [$$stores, $$cleanup] = $.setup_stores();
1659
1668
  let plugins = $.prop($$props, "plugins", 19, () => []), options = $.prop($$props, "options", 19, () => ({}));
1660
1669
  let state = new State(plugins(), options());
1661
1670
  setContext("state", state);
@@ -1733,8 +1742,7 @@ function Calendar($$anchor, $$props) {
1733
1742
  return toViewWithLocalDates(get(state._view));
1734
1743
  }
1735
1744
  function unselect() {
1736
- var _a;
1737
- (_a = $_interaction().action) == null ? void 0 : _a.unselect();
1745
+ $_interaction().action?.unselect();
1738
1746
  return this;
1739
1747
  }
1740
1748
  function dateFromPoint(x, y) {
@@ -1755,6 +1763,21 @@ function Calendar($$anchor, $$props) {
1755
1763
  return this;
1756
1764
  }
1757
1765
  let View2 = $.derived($_viewComponent);
1766
+ var $$exports = {
1767
+ setOption,
1768
+ getOption,
1769
+ refetchEvents,
1770
+ getEvents,
1771
+ getEventById,
1772
+ addEvent,
1773
+ updateEvent,
1774
+ removeEventById,
1775
+ getView,
1776
+ unselect,
1777
+ dateFromPoint,
1778
+ next,
1779
+ prev
1780
+ };
1758
1781
  var fragment = root$q();
1759
1782
  var div = $.first_child(fragment);
1760
1783
  let styles;
@@ -1779,21 +1802,7 @@ function Calendar($$anchor, $$props) {
1779
1802
  ]
1780
1803
  );
1781
1804
  $.append($$anchor, fragment);
1782
- var $$pop = $.pop({
1783
- setOption,
1784
- getOption,
1785
- refetchEvents,
1786
- getEvents,
1787
- getEventById,
1788
- addEvent,
1789
- updateEvent,
1790
- removeEventById,
1791
- getView,
1792
- unselect,
1793
- dateFromPoint,
1794
- next,
1795
- prev
1796
- });
1805
+ var $$pop = $.pop($$exports);
1797
1806
  $$cleanup();
1798
1807
  return $$pop;
1799
1808
  }
@@ -1819,11 +1828,11 @@ var root_1$c = $.from_html(`<div role="columnheader"><span></span></div>`);
1819
1828
  var root$p = $.from_html(`<div><div role="row"></div> <div></div></div>`);
1820
1829
  function Header$1($$anchor, $$props) {
1821
1830
  $.push($$props, false);
1822
- const [$$stores, $$cleanup] = $.setup_stores();
1823
1831
  const $theme = () => $.store_get(theme, "$theme", $$stores);
1824
1832
  const $_days = () => $.store_get(_days, "$_days", $$stores);
1825
1833
  const $_intlDayHeaderAL = () => $.store_get(_intlDayHeaderAL, "$_intlDayHeaderAL", $$stores);
1826
1834
  const $_intlDayHeader = () => $.store_get(_intlDayHeader, "$_intlDayHeader", $$stores);
1835
+ const [$$stores, $$cleanup] = $.setup_stores();
1827
1836
  let { theme, _intlDayHeader, _intlDayHeaderAL, _days } = getContext("state");
1828
1837
  $.init();
1829
1838
  var div = root$p();
@@ -1831,7 +1840,7 @@ function Header$1($$anchor, $$props) {
1831
1840
  $.each(div_1, 5, $_days, $.index, ($$anchor2, day) => {
1832
1841
  var div_2 = root_1$c();
1833
1842
  var span = $.child(div_2);
1834
- $.action(span, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayHeader().format($.get(day)));
1843
+ $.action(span, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayHeader().format($.get(day)));
1835
1844
  $.reset(div_2);
1836
1845
  $.template_effect(
1837
1846
  ($0, $1) => {
@@ -1839,10 +1848,7 @@ function Header$1($$anchor, $$props) {
1839
1848
  $.set_attribute(span, "aria-label", $1);
1840
1849
  },
1841
1850
  [
1842
- () => {
1843
- var _a;
1844
- return (_a = $theme().weekdays) == null ? void 0 : _a[$.get(day).getUTCDay()];
1845
- },
1851
+ () => $theme().weekdays?.[$.get(day).getUTCDay()],
1846
1852
  () => $_intlDayHeaderAL().format($.get(day))
1847
1853
  ]
1848
1854
  );
@@ -1864,7 +1870,6 @@ var root_1$b = $.from_html(`<div></div>`);
1864
1870
  var root$o = $.from_html(`<article><!></article>`);
1865
1871
  function BaseEvent($$anchor, $$props) {
1866
1872
  $.push($$props, true);
1867
- const [$$stores, $$cleanup] = $.setup_stores();
1868
1873
  const $resources = () => $.store_get(resources, "$resources", $$stores);
1869
1874
  const $eventBackgroundColor = () => $.store_get(eventBackgroundColor, "$eventBackgroundColor", $$stores);
1870
1875
  const $eventColor = () => $.store_get(eventColor, "$eventColor", $$stores);
@@ -1879,6 +1884,7 @@ function BaseEvent($$anchor, $$props) {
1879
1884
  const $eventClick = () => $.store_get(eventClick, "$eventClick", $$stores);
1880
1885
  const $eventMouseEnter = () => $.store_get(eventMouseEnter, "$eventMouseEnter", $$stores);
1881
1886
  const $eventMouseLeave = () => $.store_get(eventMouseLeave, "$eventMouseLeave", $$stores);
1887
+ const [$$stores, $$cleanup] = $.setup_stores();
1882
1888
  let el = $.prop($$props, "el", 15), classes = $.prop($$props, "classes", 3, identity), styles = $.prop($$props, "styles", 3, identity);
1883
1889
  let {
1884
1890
  displayEventEnd,
@@ -1930,21 +1936,18 @@ function BaseEvent($$anchor, $$props) {
1930
1936
  let onmouseleave = $.derived(() => createHandler($eventMouseLeave(), $.get(display)));
1931
1937
  var article = root$o();
1932
1938
  article.__click = function(...$$args) {
1933
- var _a;
1934
- (_a = $.get(onclick2)) == null ? void 0 : _a.apply(this, $$args);
1939
+ $.get(onclick2)?.apply(this, $$args);
1935
1940
  };
1936
1941
  article.__keydown = function(...$$args) {
1937
- var _a;
1938
- (_a = $.get(onkeydown)) == null ? void 0 : _a.apply(this, $$args);
1942
+ $.get(onkeydown)?.apply(this, $$args);
1939
1943
  };
1940
1944
  article.__pointerdown = function(...$$args) {
1941
- var _a;
1942
- (_a = $$props.onpointerdown) == null ? void 0 : _a.apply(this, $$args);
1945
+ $$props.onpointerdown?.apply(this, $$args);
1943
1946
  };
1944
1947
  {
1945
1948
  const defaultBody = ($$anchor2) => {
1946
1949
  var div = root_1$b();
1947
- $.action(div, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(content));
1950
+ $.action(div, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(content));
1948
1951
  $.template_effect(() => $.set_class(div, 1, $.clsx($theme().eventBody)));
1949
1952
  $.append($$anchor2, div);
1950
1953
  };
@@ -1974,12 +1977,10 @@ function BaseEvent($$anchor, $$props) {
1974
1977
  $.set_attribute(article, "tabindex", $.get(onclick2) ? 0 : void 0);
1975
1978
  });
1976
1979
  $.event("mouseenter", article, function(...$$args) {
1977
- var _a;
1978
- (_a = $.get(onmouseenter)) == null ? void 0 : _a.apply(this, $$args);
1980
+ $.get(onmouseenter)?.apply(this, $$args);
1979
1981
  });
1980
1982
  $.event("mouseleave", article, function(...$$args) {
1981
- var _a;
1982
- (_a = $.get(onmouseleave)) == null ? void 0 : _a.apply(this, $$args);
1983
+ $.get(onmouseleave)?.apply(this, $$args);
1983
1984
  });
1984
1985
  $.append($$anchor, article);
1985
1986
  $.pop();
@@ -1988,20 +1989,16 @@ function BaseEvent($$anchor, $$props) {
1988
1989
  $.delegate(["click", "keydown", "pointerdown"]);
1989
1990
  function InteractableEvent($$anchor, $$props) {
1990
1991
  $.push($$props, true);
1991
- const [$$stores, $$cleanup] = $.setup_stores();
1992
1992
  const $_iClasses = () => $.store_get(_iClasses, "$_iClasses", $$stores);
1993
1993
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
1994
+ const [$$stores, $$cleanup] = $.setup_stores();
1994
1995
  let el = $.prop($$props, "el", 15);
1995
1996
  let { _interaction, _iClasses } = getContext("state");
1996
1997
  let event = $.derived(() => $$props.chunk.event);
1997
1998
  let display = $.derived(() => $$props.chunk.event.display);
1998
1999
  let classes = $.derived(() => (classNames) => $_iClasses()(classNames, $.get(event)));
1999
2000
  function createDragHandler(event2) {
2000
- var _a, _b;
2001
- return ((_a = $_interaction().action) == null ? void 0 : _a.draggable(event2)) ? (jsEvent) => {
2002
- var _a2, _b2;
2003
- return $_interaction().action.drag(event2, jsEvent, (_a2 = $$props.forceDate) == null ? void 0 : _a2.call($$props), (_b2 = $$props.forceMargin) == null ? void 0 : _b2.call($$props));
2004
- } : (_b = $_interaction().action) == null ? void 0 : _b.noAction;
2001
+ return $_interaction().action?.draggable(event2) ? (jsEvent) => $_interaction().action.drag(event2, jsEvent, $$props.forceDate?.(), $$props.forceMargin?.()) : $_interaction().action?.noAction;
2005
2002
  }
2006
2003
  let onpointerdown = $.derived(() => !bgEvent($.get(display)) && !helperEvent($.get(display)) ? createDragHandler($.get(event)) : void 0);
2007
2004
  let Resizer2 = $.derived(() => $_interaction().resizer);
@@ -2079,10 +2076,10 @@ function InteractableEvent($$anchor, $$props) {
2079
2076
  }
2080
2077
  function Event$4($$anchor, $$props) {
2081
2078
  $.push($$props, true);
2082
- const [$$stores, $$cleanup] = $.setup_stores();
2083
2079
  const $dayMaxEvents = () => $.store_get(dayMaxEvents, "$dayMaxEvents", $$stores);
2084
2080
  const $_hiddenEvents = () => $.store_get(_hiddenEvents, "$_hiddenEvents", $$stores);
2085
2081
  const $_popupDate = () => $.store_get(_popupDate, "$_popupDate", $$stores);
2082
+ const [$$stores, $$cleanup] = $.setup_stores();
2086
2083
  let longChunks = $.prop($$props, "longChunks", 19, () => ({})), inPopup = $.prop($$props, "inPopup", 3, false), dates = $.prop($$props, "dates", 19, () => []);
2087
2084
  let { dayMaxEvents, _hiddenEvents, _popupDate } = getContext("state");
2088
2085
  let el = $.state(void 0);
@@ -2151,6 +2148,7 @@ function Event$4($$anchor, $$props) {
2151
2148
  }
2152
2149
  return h;
2153
2150
  }
2151
+ var $$exports = { reposition };
2154
2152
  InteractableEvent($$anchor, {
2155
2153
  get chunk() {
2156
2154
  return $$props.chunk;
@@ -2171,20 +2169,20 @@ function Event$4($$anchor, $$props) {
2171
2169
  $.set(el, $$value, true);
2172
2170
  }
2173
2171
  });
2174
- var $$pop = $.pop({ reposition });
2172
+ var $$pop = $.pop($$exports);
2175
2173
  $$cleanup();
2176
2174
  return $$pop;
2177
2175
  }
2178
2176
  var root$n = $.from_html(`<div><div><time></time> <a role="button" tabindex="0">&times;</a></div> <div></div></div>`);
2179
2177
  function Popup($$anchor, $$props) {
2180
2178
  $.push($$props, true);
2181
- const [$$stores, $$cleanup] = $.setup_stores();
2182
2179
  const $_popupChunks = () => $.store_get(_popupChunks, "$_popupChunks", $$stores);
2183
2180
  const $_popupDate = () => $.store_get(_popupDate, "$_popupDate", $$stores);
2184
2181
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
2185
2182
  const $theme = () => $.store_get(theme, "$theme", $$stores);
2186
2183
  const $_intlDayPopover = () => $.store_get(_intlDayPopover, "$_intlDayPopover", $$stores);
2187
2184
  const $buttonText = () => $.store_get(buttonText, "$buttonText", $$stores);
2185
+ const [$$stores, $$cleanup] = $.setup_stores();
2188
2186
  let {
2189
2187
  buttonText,
2190
2188
  theme,
@@ -2247,29 +2245,25 @@ function Popup($$anchor, $$props) {
2247
2245
  $.store_set(_popupChunks, []);
2248
2246
  }
2249
2247
  function handlePointerDownOutside() {
2250
- var _a;
2251
2248
  close();
2252
- (_a = $_interaction().action) == null ? void 0 : _a.noClick();
2249
+ $_interaction().action?.noClick();
2253
2250
  }
2254
2251
  var div = root$n();
2255
2252
  var event_handler = $.derived(stopPropagation);
2256
2253
  div.__pointerdown = function(...$$args) {
2257
- var _a;
2258
- (_a = $.get(event_handler)) == null ? void 0 : _a.apply(this, $$args);
2254
+ $.get(event_handler)?.apply(this, $$args);
2259
2255
  };
2260
2256
  var div_1 = $.child(div);
2261
2257
  var time = $.child(div_1);
2262
- $.action(time, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayPopover().format($_popupDate()));
2258
+ $.action(time, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayPopover().format($_popupDate()));
2263
2259
  var a = $.sibling(time, 2);
2264
2260
  var event_handler_1 = $.derived(() => stopPropagation(close));
2265
2261
  a.__click = function(...$$args) {
2266
- var _a;
2267
- (_a = $.get(event_handler_1)) == null ? void 0 : _a.apply(this, $$args);
2262
+ $.get(event_handler_1)?.apply(this, $$args);
2268
2263
  };
2269
2264
  var event_handler_2 = $.derived(() => keyEnter(close));
2270
2265
  a.__keydown = function(...$$args) {
2271
- var _a;
2272
- (_a = $.get(event_handler_2)) == null ? void 0 : _a.apply(this, $$args);
2266
+ $.get(event_handler_2)?.apply(this, $$args);
2273
2267
  };
2274
2268
  $.reset(div_1);
2275
2269
  var div_2 = $.sibling(div_1, 2);
@@ -2284,7 +2278,7 @@ function Popup($$anchor, $$props) {
2284
2278
  $.reset(div_2);
2285
2279
  $.reset(div);
2286
2280
  $.bind_this(div, ($$value) => $.set(el, $$value), () => $.get(el));
2287
- $.action(div, ($$node, $$action_arg) => outsideEvent == null ? void 0 : outsideEvent($$node, $$action_arg), () => "pointerdown");
2281
+ $.action(div, ($$node, $$action_arg) => outsideEvent?.($$node, $$action_arg), () => "pointerdown");
2288
2282
  $.template_effect(
2289
2283
  ($0) => {
2290
2284
  $.set_class(div, 1, $theme().popup);
@@ -2310,7 +2304,6 @@ var root_10 = $.from_html(`<a role="button" tabindex="0" aria-haspopup="true"></
2310
2304
  var root$m = $.from_html(`<div role="cell"><div><time></time> <!></div> <div><!></div> <!> <div><!></div> <!> <div><!></div></div>`);
2311
2305
  function Day$4($$anchor, $$props) {
2312
2306
  $.push($$props, true);
2313
- const [$$stores, $$cleanup] = $.setup_stores();
2314
2307
  const $_hiddenEvents = () => $.store_get(_hiddenEvents, "$_hiddenEvents", $$stores);
2315
2308
  const $_today = () => $.store_get(_today, "$_today", $$stores);
2316
2309
  const $currentDate = () => $.store_get(currentDate, "$currentDate", $$stores);
@@ -2324,6 +2317,7 @@ function Day$4($$anchor, $$props) {
2324
2317
  const $theme = () => $.store_get(theme, "$theme", $$stores);
2325
2318
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
2326
2319
  const $_intlDayCell = () => $.store_get(_intlDayCell, "$_intlDayCell", $$stores);
2320
+ const [$$stores, $$cleanup] = $.setup_stores();
2327
2321
  let iChunks = $.prop($$props, "iChunks", 19, () => []);
2328
2322
  let {
2329
2323
  date: currentDate,
@@ -2401,9 +2395,8 @@ function Day$4($$anchor, $$props) {
2401
2395
  }
2402
2396
  });
2403
2397
  function setPopupChunks() {
2404
- var _a;
2405
2398
  let nextDay = addDay(cloneDate($$props.date));
2406
- let chunks = $.get(dayChunks).concat(((_a = $$props.longChunks[$$props.date.getTime()]) == null ? void 0 : _a.chunks) || []);
2399
+ let chunks = $.get(dayChunks).concat($$props.longChunks[$$props.date.getTime()]?.chunks || []);
2407
2400
  $.store_set(_popupChunks, chunks.map((chunk) => assign({}, chunk, createEventChunk(chunk.event, $$props.date, nextDay), { days: 1, dates: [$$props.date] })).sort((a, b) => a.top - b.top));
2408
2401
  }
2409
2402
  let showWeekNumber = $.derived(() => $weekNumbers() && $$props.date.getUTCDay() == ($firstDay() ? 1 : 0));
@@ -2424,19 +2417,19 @@ function Day$4($$anchor, $$props) {
2424
2417
  runReposition(refs, $.get(dayChunks));
2425
2418
  }
2426
2419
  }
2420
+ var $$exports = { reposition };
2427
2421
  var div = root$m();
2428
2422
  div.__pointerdown = function(...$$args) {
2429
- var _a, _b;
2430
- (_b = (_a = $_interaction().action) == null ? void 0 : _a.select) == null ? void 0 : _b.apply(this, $$args);
2423
+ $_interaction().action?.select?.apply(this, $$args);
2431
2424
  };
2432
2425
  var div_1 = $.child(div);
2433
2426
  var time = $.child(div_1);
2434
- $.action(time, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayCell().format($$props.date));
2427
+ $.action(time, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayCell().format($$props.date));
2435
2428
  var node = $.sibling(time, 2);
2436
2429
  {
2437
2430
  var consequent = ($$anchor2) => {
2438
2431
  var span = root_1$a();
2439
- $.action(span, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(weekNumber));
2432
+ $.action(span, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(weekNumber));
2440
2433
  $.template_effect(() => $.set_class(span, 1, $theme().weekNumber));
2441
2434
  $.append($$anchor2, span);
2442
2435
  };
@@ -2531,7 +2524,7 @@ function Day$4($$anchor, $$props) {
2531
2524
  }
2532
2525
  }),
2533
2526
  ($$value, i2) => refs[i2] = $$value,
2534
- (i2) => refs == null ? void 0 : refs[i2],
2527
+ (i2) => refs?.[i2],
2535
2528
  () => [$.get(i)]
2536
2529
  );
2537
2530
  });
@@ -2558,20 +2551,17 @@ function Day$4($$anchor, $$props) {
2558
2551
  var a_1 = root_10();
2559
2552
  var event_handler = $.derived(() => stopPropagation(showMore));
2560
2553
  a_1.__click = function(...$$args) {
2561
- var _a;
2562
- (_a = $.get(event_handler)) == null ? void 0 : _a.apply(this, $$args);
2554
+ $.get(event_handler)?.apply(this, $$args);
2563
2555
  };
2564
2556
  var event_handler_1 = $.derived(() => keyEnter(showMore));
2565
2557
  a_1.__keydown = function(...$$args) {
2566
- var _a;
2567
- (_a = $.get(event_handler_1)) == null ? void 0 : _a.apply(this, $$args);
2558
+ $.get(event_handler_1)?.apply(this, $$args);
2568
2559
  };
2569
2560
  var event_handler_2 = $.derived(stopPropagation);
2570
2561
  a_1.__pointerdown = function(...$$args) {
2571
- var _a;
2572
- (_a = $.get(event_handler_2)) == null ? void 0 : _a.apply(this, $$args);
2562
+ $.get(event_handler_2)?.apply(this, $$args);
2573
2563
  };
2574
- $.action(a_1, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(moreLink));
2564
+ $.action(a_1, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(moreLink));
2575
2565
  $.append($$anchor2, a_1);
2576
2566
  };
2577
2567
  $.if(node_11, ($$render) => {
@@ -2591,15 +2581,12 @@ function Day$4($$anchor, $$props) {
2591
2581
  $.set_class(div_6, 1, $theme().dayFoot);
2592
2582
  },
2593
2583
  [
2594
- () => {
2595
- var _a;
2596
- return (_a = $theme().weekdays) == null ? void 0 : _a[$$props.date.getUTCDay()];
2597
- },
2584
+ () => $theme().weekdays?.[$$props.date.getUTCDay()],
2598
2585
  () => toISOString($$props.date, 10)
2599
2586
  ]
2600
2587
  );
2601
2588
  $.append($$anchor, div);
2602
- var $$pop = $.pop({ reposition });
2589
+ var $$pop = $.pop($$exports);
2603
2590
  $$cleanup();
2604
2591
  return $$pop;
2605
2592
  }
@@ -2607,18 +2594,20 @@ $.delegate(["pointerdown", "click", "keydown"]);
2607
2594
  var root$l = $.from_html(`<div role="row"></div>`);
2608
2595
  function Week$1($$anchor, $$props) {
2609
2596
  $.push($$props, true);
2610
- const [$$stores, $$cleanup] = $.setup_stores();
2611
2597
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
2612
2598
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
2613
2599
  const $filterEventsWithResources = () => $.store_get(filterEventsWithResources, "$filterEventsWithResources", $$stores);
2614
2600
  const $resources = () => $.store_get(resources, "$resources", $$stores);
2615
2601
  const $hiddenDays = () => $.store_get(hiddenDays, "$hiddenDays", $$stores);
2602
+ const $eventOrder = () => $.store_get(eventOrder, "$eventOrder", $$stores);
2616
2603
  const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
2617
2604
  const $theme = () => $.store_get(theme, "$theme", $$stores);
2605
+ const [$$stores, $$cleanup] = $.setup_stores();
2618
2606
  let {
2619
2607
  _filteredEvents,
2620
2608
  _iEvents,
2621
2609
  resources,
2610
+ eventOrder,
2622
2611
  filterEventsWithResources,
2623
2612
  hiddenDays,
2624
2613
  theme,
@@ -2642,15 +2631,15 @@ function Week$1($$anchor, $$props) {
2642
2631
  }
2643
2632
  }
2644
2633
  }
2645
- prepareEventChunks$1(bgChunks2, $hiddenDays());
2646
- let longChunks2 = prepareEventChunks$1(chunks2, $hiddenDays());
2634
+ prepareEventChunks$1(bgChunks2, $hiddenDays(), $eventOrder());
2635
+ let longChunks2 = prepareEventChunks$1(chunks2, $hiddenDays(), $eventOrder());
2647
2636
  return [chunks2, bgChunks2, longChunks2];
2648
2637
  }), $$array = $.derived(() => $.to_array($.get($$d), 3)), chunks = $.derived(() => $.get($$array)[0]), bgChunks = $.derived(() => $.get($$array)[1]), longChunks = $.derived(() => $.get($$array)[2]);
2649
2638
  let iChunks = $.derived(() => $_iEvents().map((event) => {
2650
2639
  let chunk;
2651
2640
  if (event && eventIntersects(event, $.get(start), $.get(end))) {
2652
2641
  chunk = createEventChunk(event, $.get(start), $.get(end));
2653
- prepareEventChunks$1([chunk], $hiddenDays());
2642
+ prepareEventChunks$1([chunk], $hiddenDays(), $eventOrder());
2654
2643
  } else {
2655
2644
  chunk = null;
2656
2645
  }
@@ -2659,6 +2648,7 @@ function Week$1($$anchor, $$props) {
2659
2648
  function reposition() {
2660
2649
  runReposition(refs, $$props.dates);
2661
2650
  }
2651
+ var $$exports = { reposition };
2662
2652
  var div = root$l();
2663
2653
  $.each(div, 21, () => $$props.dates, $.index, ($$anchor2, date, i) => {
2664
2654
  $.bind_this(
@@ -2683,21 +2673,20 @@ function Week$1($$anchor, $$props) {
2683
2673
  }
2684
2674
  }),
2685
2675
  ($$value, i2) => refs[i2] = $$value,
2686
- (i2) => refs == null ? void 0 : refs[i2],
2676
+ (i2) => refs?.[i2],
2687
2677
  () => [i]
2688
2678
  );
2689
2679
  });
2690
2680
  $.reset(div);
2691
2681
  $.template_effect(() => $.set_class(div, 1, $theme().days));
2692
2682
  $.append($$anchor, div);
2693
- var $$pop = $.pop({ reposition });
2683
+ var $$pop = $.pop($$exports);
2694
2684
  $$cleanup();
2695
2685
  return $$pop;
2696
2686
  }
2697
2687
  var root$k = $.from_html(`<div><div></div></div>`);
2698
2688
  function Body$3($$anchor, $$props) {
2699
2689
  $.push($$props, true);
2700
- const [$$stores, $$cleanup] = $.setup_stores();
2701
2690
  const $hiddenDays = () => $.store_get(hiddenDays, "$hiddenDays", $$stores);
2702
2691
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
2703
2692
  const $dayMaxEvents = () => $.store_get(dayMaxEvents, "$dayMaxEvents", $$stores);
@@ -2705,6 +2694,7 @@ function Body$3($$anchor, $$props) {
2705
2694
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
2706
2695
  const $_bodyEl = () => $.store_get(_bodyEl, "$_bodyEl", $$stores);
2707
2696
  const $theme = () => $.store_get(theme, "$theme", $$stores);
2697
+ const [$$stores, $$cleanup] = $.setup_stores();
2708
2698
  let {
2709
2699
  _bodyEl,
2710
2700
  _viewDates,
@@ -2753,14 +2743,14 @@ function Body$3($$anchor, $$props) {
2753
2743
  }
2754
2744
  }),
2755
2745
  ($$value, i2) => refs[i2] = $$value,
2756
- (i2) => refs == null ? void 0 : refs[i2],
2746
+ (i2) => refs?.[i2],
2757
2747
  () => [i]
2758
2748
  );
2759
2749
  });
2760
2750
  $.reset(div_1);
2761
2751
  $.reset(div);
2762
2752
  $.bind_this(div, ($$value) => $.store_set(_bodyEl, $$value), () => $_bodyEl());
2763
- $.action(div, ($$node, $$action_arg) => observeResize == null ? void 0 : observeResize($$node, $$action_arg), () => () => $.store_set(_recheckScrollable, true));
2753
+ $.action(div, ($$node, $$action_arg) => observeResize?.($$node, $$action_arg), () => () => $.store_set(_recheckScrollable, true));
2764
2754
  $.template_effect(() => {
2765
2755
  $.set_class(div, 1, `${$theme().body ?? ""}${$dayMaxEvents() === true ? " " + $theme().uniform : ""}`);
2766
2756
  $.set_class(div_1, 1, $theme().content);
@@ -2834,7 +2824,6 @@ function limit(value, minLimit, maxLimit) {
2834
2824
  }
2835
2825
  function Action($$anchor, $$props) {
2836
2826
  $.push($$props, false);
2837
- const [$$stores, $$cleanup] = $.setup_stores();
2838
2827
  const $eventStartEditable = () => $.store_get(eventStartEditable, "$eventStartEditable", $$stores);
2839
2828
  const $editable = () => $.store_get(editable, "$editable", $$stores);
2840
2829
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
@@ -2870,6 +2859,7 @@ function Action($$anchor, $$props) {
2870
2859
  const $_events = () => $.store_get(_events, "$_events", $$stores);
2871
2860
  const $selectBackgroundColor = () => $.store_get(selectBackgroundColor, "$selectBackgroundColor", $$stores);
2872
2861
  const $unselectFn = () => $.store_get(unselectFn, "$unselectFn", $$stores);
2862
+ const [$$stores, $$cleanup] = $.setup_stores();
2873
2863
  let {
2874
2864
  _iEvents,
2875
2865
  _iClass,
@@ -3400,6 +3390,16 @@ function Action($$anchor, $$props) {
3400
3390
  }
3401
3391
  };
3402
3392
  }
3393
+ var $$exports = {
3394
+ draggable,
3395
+ drag,
3396
+ resize,
3397
+ select,
3398
+ noAction,
3399
+ handleScroll,
3400
+ unselect,
3401
+ noClick
3402
+ };
3403
3403
  $.init();
3404
3404
  $.event("pointermove", $.window, handlePointerMove);
3405
3405
  $.event("pointerup", $.window, handlePointerUp);
@@ -3407,13 +3407,11 @@ function Action($$anchor, $$props) {
3407
3407
  $.event("scroll", $.window, handleScroll);
3408
3408
  var event_handler = $.derived(() => createPreventDefaultHandler(complexAction));
3409
3409
  $.event("selectstart", $.window, function(...$$args) {
3410
- var _a;
3411
- (_a = $.get(event_handler)) == null ? void 0 : _a.apply(this, $$args);
3410
+ $.get(event_handler)?.apply(this, $$args);
3412
3411
  });
3413
3412
  var event_handler_1 = $.derived(() => createPreventDefaultHandler(() => $.get(timer)));
3414
3413
  $.event("contextmenu", $.window, function(...$$args) {
3415
- var _a;
3416
- (_a = $.get(event_handler_1)) == null ? void 0 : _a.apply(this, $$args);
3414
+ $.get(event_handler_1)?.apply(this, $$args);
3417
3415
  });
3418
3416
  $.event("touchstart", $.window, handleTouchStart, void 0, true);
3419
3417
  $.bind_prop($$props, "draggable", draggable);
@@ -3424,24 +3422,15 @@ function Action($$anchor, $$props) {
3424
3422
  $.bind_prop($$props, "handleScroll", handleScroll);
3425
3423
  $.bind_prop($$props, "unselect", unselect);
3426
3424
  $.bind_prop($$props, "noClick", noClick);
3427
- var $$pop = $.pop({
3428
- draggable,
3429
- drag,
3430
- resize,
3431
- select,
3432
- noAction,
3433
- handleScroll,
3434
- unselect,
3435
- noClick
3436
- });
3425
+ var $$pop = $.pop($$exports);
3437
3426
  $$cleanup();
3438
3427
  return $$pop;
3439
3428
  }
3440
3429
  function Pointer($$anchor, $$props) {
3441
3430
  $.push($$props, true);
3442
- const [$$stores, $$cleanup] = $.setup_stores();
3443
3431
  const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
3444
3432
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
3433
+ const [$$stores, $$cleanup] = $.setup_stores();
3445
3434
  let { _iEvents, slotDuration } = getContext("state");
3446
3435
  let x = 0, y = 0;
3447
3436
  $.user_effect(() => {
@@ -3502,9 +3491,10 @@ function Pointer($$anchor, $$props) {
3502
3491
  function validEvent(jsEvent) {
3503
3492
  return jsEvent.isPrimary && jsEvent.pointerType === "mouse";
3504
3493
  }
3494
+ var $$exports = { handleScroll };
3505
3495
  $.event("pointermove", $.window, handlePointerMove);
3506
3496
  $.event("scroll", $.window, handleScroll);
3507
- var $$pop = $.pop({ handleScroll });
3497
+ var $$pop = $.pop($$exports);
3508
3498
  $$cleanup();
3509
3499
  return $$pop;
3510
3500
  }
@@ -3513,12 +3503,12 @@ var root_2$6 = $.from_html(`<div></div>`);
3513
3503
  var root$i = $.from_html(`<!> <!> <!>`, 1);
3514
3504
  function Resizer($$anchor, $$props) {
3515
3505
  $.push($$props, true);
3516
- const [$$stores, $$cleanup] = $.setup_stores();
3517
3506
  const $eventDurationEditable = () => $.store_get(eventDurationEditable, "$eventDurationEditable", $$stores);
3518
3507
  const $editable = () => $.store_get(editable, "$editable", $$stores);
3519
3508
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
3520
3509
  const $eventResizableFromStart = () => $.store_get(eventResizableFromStart, "$eventResizableFromStart", $$stores);
3521
3510
  const $theme = () => $.store_get(theme, "$theme", $$stores);
3511
+ const [$$stores, $$cleanup] = $.setup_stores();
3522
3512
  let forceDate = $.prop($$props, "forceDate", 3, void 0), forceMargin = $.prop($$props, "forceMargin", 3, void 0);
3523
3513
  let {
3524
3514
  theme,
@@ -3531,10 +3521,7 @@ function Resizer($$anchor, $$props) {
3531
3521
  let display = $.derived(() => $$props.chunk.event.display);
3532
3522
  let resizable = $.derived(() => !bgEvent($.get(display)) && !helperEvent($.get(display)) && eventResizable($.get(event), $eventDurationEditable(), $editable()));
3533
3523
  function createResizeHandler(start) {
3534
- return (jsEvent) => {
3535
- var _a, _b;
3536
- return $_interaction().action.resize($.get(event), jsEvent, start, $$props.axis, (_a = forceDate()) == null ? void 0 : _a(), (_b = forceMargin()) == null ? void 0 : _b(), $$props.chunk.zeroDuration);
3537
- };
3524
+ return (jsEvent) => $_interaction().action.resize($.get(event), jsEvent, start, $$props.axis, forceDate()?.(), forceMargin()?.(), $$props.chunk.zeroDuration);
3538
3525
  }
3539
3526
  var fragment = root$i();
3540
3527
  var node = $.first_child(fragment);
@@ -3543,8 +3530,7 @@ function Resizer($$anchor, $$props) {
3543
3530
  var div = root_1$9();
3544
3531
  var event_handler = $.derived(() => createResizeHandler(true));
3545
3532
  div.__pointerdown = function(...$$args) {
3546
- var _a;
3547
- (_a = $.get(event_handler)) == null ? void 0 : _a.apply(this, $$args);
3533
+ $.get(event_handler)?.apply(this, $$args);
3548
3534
  };
3549
3535
  $.template_effect(() => $.set_class(div, 1, `${$theme().resizer ?? ""} ${$theme().start ?? ""}`));
3550
3536
  $.append($$anchor2, div);
@@ -3561,8 +3547,7 @@ function Resizer($$anchor, $$props) {
3561
3547
  var div_1 = root_2$6();
3562
3548
  var event_handler_1 = $.derived(() => createResizeHandler(false));
3563
3549
  div_1.__pointerdown = function(...$$args) {
3564
- var _a;
3565
- (_a = $.get(event_handler_1)) == null ? void 0 : _a.apply(this, $$args);
3550
+ $.get(event_handler_1)?.apply(this, $$args);
3566
3551
  };
3567
3552
  $.template_effect(() => $.set_class(div_1, 1, $theme().resizer));
3568
3553
  $.append($$anchor2, div_1);
@@ -3579,13 +3564,13 @@ $.delegate(["pointerdown"]);
3579
3564
  var root$h = $.from_html(`<!> <!>`, 1);
3580
3565
  function Auxiliary($$anchor, $$props) {
3581
3566
  $.push($$props, true);
3582
- const [$$stores, $$cleanup] = $.setup_stores();
3583
3567
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
3584
3568
  const $theme = () => $.store_get(theme, "$theme", $$stores);
3585
3569
  const $eventStartEditable = () => $.store_get(eventStartEditable, "$eventStartEditable", $$stores);
3586
3570
  const $editable = () => $.store_get(editable, "$editable", $$stores);
3587
3571
  const $_bodyEl = () => $.store_get(_bodyEl, "$_bodyEl", $$stores);
3588
3572
  const $pointer = () => $.store_get(pointer, "$pointer", $$stores);
3573
+ const [$$stores, $$cleanup] = $.setup_stores();
3589
3574
  let {
3590
3575
  theme,
3591
3576
  editable,
@@ -3614,24 +3599,17 @@ function Auxiliary($$anchor, $$props) {
3614
3599
  }
3615
3600
  });
3616
3601
  function bodyScrollHandler() {
3617
- var _a;
3618
3602
  for (let component of Object.values($_interaction())) {
3619
- (_a = component == null ? void 0 : component.handleScroll) == null ? void 0 : _a.call(component);
3603
+ component?.handleScroll?.();
3620
3604
  }
3621
3605
  }
3622
3606
  var fragment = root$h();
3623
3607
  var node = $.first_child(fragment);
3624
- $.bind_this(Action(node, {}), ($$value) => $.store_mutate(_interaction, $.untrack($_interaction).action = $$value, $.untrack($_interaction)), () => {
3625
- var _a;
3626
- return (_a = $_interaction()) == null ? void 0 : _a.action;
3627
- });
3608
+ $.bind_this(Action(node, {}), ($$value) => $.store_mutate(_interaction, $.untrack($_interaction).action = $$value, $.untrack($_interaction)), () => $_interaction()?.action);
3628
3609
  var node_1 = $.sibling(node, 2);
3629
3610
  {
3630
3611
  var consequent = ($$anchor2) => {
3631
- $.bind_this(Pointer($$anchor2, {}), ($$value) => $.store_mutate(_interaction, $.untrack($_interaction).pointer = $$value, $.untrack($_interaction)), () => {
3632
- var _a;
3633
- return (_a = $_interaction()) == null ? void 0 : _a.pointer;
3634
- });
3612
+ $.bind_this(Pointer($$anchor2, {}), ($$value) => $.store_mutate(_interaction, $.untrack($_interaction).pointer = $$value, $.untrack($_interaction)), () => $_interaction()?.pointer);
3635
3613
  };
3636
3614
  $.if(node_1, ($$render) => {
3637
3615
  if ($pointer()) $$render(consequent);
@@ -3687,9 +3665,9 @@ const index$3 = {
3687
3665
  var root_1$8 = $.from_html(`<div></div> <!>`, 1);
3688
3666
  function Event$3($$anchor, $$props) {
3689
3667
  $.push($$props, true);
3690
- const [$$stores, $$cleanup] = $.setup_stores();
3691
3668
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
3692
3669
  const $theme = () => $.store_get(theme, "$theme", $$stores);
3670
+ const [$$stores, $$cleanup] = $.setup_stores();
3693
3671
  let { theme, _interaction } = getContext("state");
3694
3672
  let styles = $.derived(() => (style) => {
3695
3673
  delete style["background-color"];
@@ -3712,10 +3690,7 @@ function Event$3($$anchor, $$props) {
3712
3690
  );
3713
3691
  $.append($$anchor2, fragment_1);
3714
3692
  };
3715
- let $0 = $.derived(() => {
3716
- var _a;
3717
- return (_a = $_interaction().action) == null ? void 0 : _a.noAction;
3718
- });
3693
+ let $0 = $.derived(() => $_interaction().action?.noAction);
3719
3694
  BaseEvent($$anchor, {
3720
3695
  get chunk() {
3721
3696
  return $$props.chunk;
@@ -3736,17 +3711,18 @@ function Event$3($$anchor, $$props) {
3736
3711
  var root_1$7 = $.from_html(`<div role="listitem"><h4><time></time> <time></time></h4> <!></div>`);
3737
3712
  function Day$3($$anchor, $$props) {
3738
3713
  $.push($$props, true);
3739
- const [$$stores, $$cleanup] = $.setup_stores();
3740
3714
  const $_today = () => $.store_get(_today, "$_today", $$stores);
3741
3715
  const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
3742
3716
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
3743
3717
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
3744
3718
  const $filterEventsWithResources = () => $.store_get(filterEventsWithResources, "$filterEventsWithResources", $$stores);
3745
3719
  const $resources = () => $.store_get(resources, "$resources", $$stores);
3720
+ const $eventOrder = () => $.store_get(eventOrder, "$eventOrder", $$stores);
3746
3721
  const $theme = () => $.store_get(theme, "$theme", $$stores);
3747
3722
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
3748
3723
  const $_intlListDay = () => $.store_get(_intlListDay, "$_intlListDay", $$stores);
3749
3724
  const $_intlListDaySide = () => $.store_get(_intlListDaySide, "$_intlListDaySide", $$stores);
3725
+ const [$$stores, $$cleanup] = $.setup_stores();
3750
3726
  let {
3751
3727
  _filteredEvents,
3752
3728
  _interaction,
@@ -3754,6 +3730,7 @@ function Day$3($$anchor, $$props) {
3754
3730
  _intlListDaySide,
3755
3731
  _today,
3756
3732
  resources,
3733
+ eventOrder,
3757
3734
  filterEventsWithResources,
3758
3735
  highlightedDates,
3759
3736
  theme,
@@ -3775,7 +3752,7 @@ function Day$3($$anchor, $$props) {
3775
3752
  chunks2.push(chunk);
3776
3753
  }
3777
3754
  }
3778
- sortEventChunks(chunks2);
3755
+ sortEventChunks(chunks2, $eventOrder());
3779
3756
  }
3780
3757
  return chunks2;
3781
3758
  });
@@ -3796,14 +3773,13 @@ function Day$3($$anchor, $$props) {
3796
3773
  var consequent = ($$anchor2) => {
3797
3774
  var div = root_1$7();
3798
3775
  div.__pointerdown = function(...$$args) {
3799
- var _a, _b;
3800
- (_b = (_a = $_interaction().action) == null ? void 0 : _a.select) == null ? void 0 : _b.apply(this, $$args);
3776
+ $_interaction().action?.select?.apply(this, $$args);
3801
3777
  };
3802
3778
  var h4 = $.child(div);
3803
3779
  var time = $.child(h4);
3804
- $.action(time, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlListDay().format($$props.date));
3780
+ $.action(time, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlListDay().format($$props.date));
3805
3781
  var time_1 = $.sibling(time, 2);
3806
- $.action(time_1, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlListDaySide().format($$props.date));
3782
+ $.action(time_1, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlListDaySide().format($$props.date));
3807
3783
  $.reset(h4);
3808
3784
  var node_1 = $.sibling(h4, 2);
3809
3785
  $.each(node_1, 17, () => $.get(chunks), (chunk) => chunk.event, ($$anchor3, chunk) => {
@@ -3823,10 +3799,7 @@ function Day$3($$anchor, $$props) {
3823
3799
  $.set_class(time_1, 1, $theme().daySide);
3824
3800
  $.set_attribute(time_1, "datetime", $.get(datetime));
3825
3801
  },
3826
- [() => {
3827
- var _a;
3828
- return (_a = $theme().weekdays) == null ? void 0 : _a[$$props.date.getUTCDay()];
3829
- }]
3802
+ [() => $theme().weekdays?.[$$props.date.getUTCDay()]]
3830
3803
  );
3831
3804
  $.append($$anchor2, div);
3832
3805
  };
@@ -3848,7 +3821,6 @@ var root_1$6 = $.from_html(`<div></div>`);
3848
3821
  var root$g = $.from_html(`<div><div><!></div></div>`);
3849
3822
  function Body$2($$anchor, $$props) {
3850
3823
  $.push($$props, true);
3851
- const [$$stores, $$cleanup] = $.setup_stores();
3852
3824
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
3853
3825
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
3854
3826
  const $noEventsContent = () => $.store_get(noEventsContent, "$noEventsContent", $$stores);
@@ -3856,6 +3828,7 @@ function Body$2($$anchor, $$props) {
3856
3828
  const $_view = () => $.store_get(_view, "$_view", $$stores);
3857
3829
  const $_bodyEl = () => $.store_get(_bodyEl, "$_bodyEl", $$stores);
3858
3830
  const $theme = () => $.store_get(theme, "$theme", $$stores);
3831
+ const [$$stores, $$cleanup] = $.setup_stores();
3859
3832
  let {
3860
3833
  _bodyEl,
3861
3834
  _filteredEvents,
@@ -3887,7 +3860,7 @@ function Body$2($$anchor, $$props) {
3887
3860
  var consequent = ($$anchor2) => {
3888
3861
  var div_2 = root_1$6();
3889
3862
  div_2.__click = [onclick$1, $noEventsClick, noEventsClick, $_view, _view];
3890
- $.action(div_2, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(content));
3863
+ $.action(div_2, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(content));
3891
3864
  $.template_effect(() => $.set_class(div_2, 1, $theme().noEvents));
3892
3865
  $.append($$anchor2, div_2);
3893
3866
  };
@@ -3979,11 +3952,11 @@ function slotTimeLimits(state) {
3979
3952
  (args) => createSlotTimeLimits(...args)
3980
3953
  );
3981
3954
  }
3982
- function groupEventChunks(chunks) {
3955
+ function groupEventChunks(chunks, $eventOrder) {
3983
3956
  if (!chunks.length) {
3984
3957
  return;
3985
3958
  }
3986
- sortEventChunks(chunks);
3959
+ sortEventChunks(chunks, $eventOrder);
3987
3960
  let group = {
3988
3961
  columns: [],
3989
3962
  end: chunks[0].end
@@ -4032,22 +4005,22 @@ var root_1$5 = $.from_html(`<time></time>`);
4032
4005
  var root$f = $.from_html(`<div><div></div> <!></div> <div role="row"><div><!></div> <!></div>`, 1);
4033
4006
  function Section($$anchor, $$props) {
4034
4007
  $.push($$props, true);
4035
- const [$$stores, $$cleanup] = $.setup_stores();
4036
4008
  const $allDayContent = () => $.store_get(allDayContent, "$allDayContent", $$stores);
4037
4009
  const $slotLabelInterval = () => $.store_get(slotLabelInterval, "$slotLabelInterval", $$stores);
4038
4010
  const $theme = () => $.store_get(theme, "$theme", $$stores);
4039
4011
  const $_times = () => $.store_get(_times, "$_times", $$stores);
4012
+ const [$$stores, $$cleanup] = $.setup_stores();
4040
4013
  let { allDayContent, slotLabelInterval, theme, _times } = getContext("state");
4041
4014
  let allDayText = $.derived(() => createAllDayContent($allDayContent()));
4042
4015
  let showAllTimes = $.derived(() => $slotLabelInterval() && $slotLabelInterval().seconds <= 0);
4043
4016
  var fragment = root$f();
4044
4017
  var div = $.first_child(fragment);
4045
4018
  var div_1 = $.child(div);
4046
- $.action(div_1, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(allDayText));
4019
+ $.action(div_1, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(allDayText));
4047
4020
  var node = $.sibling(div_1, 2);
4048
4021
  $.each(node, 1, $_times, $.index, ($$anchor2, time, i) => {
4049
4022
  var time_1 = root_1$5();
4050
- $.action(time_1, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(time)[1]);
4023
+ $.action(time_1, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(time)[1]);
4051
4024
  $.template_effect(() => {
4052
4025
  $.set_class(time_1, 1, `${$theme().time ?? ""}${(i || $.get(showAllTimes)) && $.get(time)[2] ? "" : " " + $theme().minor}`);
4053
4026
  $.set_attribute(time_1, "datetime", $.get(time)[0]);
@@ -4097,7 +4070,6 @@ var root_2$5 = $.from_html(`<div></div>`);
4097
4070
  var root$e = $.from_html(`<div><div><!></div></div>`);
4098
4071
  function Body$1($$anchor, $$props) {
4099
4072
  $.push($$props, true);
4100
- const [$$stores, $$cleanup] = $.setup_stores();
4101
4073
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
4102
4074
  const $scrollTime = () => $.store_get(scrollTime, "$scrollTime", $$stores);
4103
4075
  const $_slotTimeLimits = () => $.store_get(_slotTimeLimits, "$_slotTimeLimits", $$stores);
@@ -4105,6 +4077,7 @@ function Body$1($$anchor, $$props) {
4105
4077
  const $slotHeight = () => $.store_get(slotHeight, "$slotHeight", $$stores);
4106
4078
  const $theme = () => $.store_get(theme, "$theme", $$stores);
4107
4079
  const $_times = () => $.store_get(_times, "$_times", $$stores);
4080
+ const [$$stores, $$cleanup] = $.setup_stores();
4108
4081
  let {
4109
4082
  _bodyEl,
4110
4083
  _viewDates,
@@ -4153,7 +4126,7 @@ function Body$1($$anchor, $$props) {
4153
4126
  $.reset(div_1);
4154
4127
  $.reset(div);
4155
4128
  $.bind_this(div, ($$value) => $.set(el, $$value), () => $.get(el));
4156
- $.action(div, ($$node, $$action_arg) => observeResize == null ? void 0 : observeResize($$node, $$action_arg), () => () => $.store_set(_recheckScrollable, true));
4129
+ $.action(div, ($$node, $$action_arg) => observeResize?.($$node, $$action_arg), () => () => $.store_set(_recheckScrollable, true));
4157
4130
  $.template_effect(() => {
4158
4131
  $.set_class(div, 1, $theme().body);
4159
4132
  $.set_class(div_1, 1, $theme().content);
@@ -4164,11 +4137,11 @@ function Body$1($$anchor, $$props) {
4164
4137
  }
4165
4138
  function Event$2($$anchor, $$props) {
4166
4139
  $.push($$props, true);
4167
- const [$$stores, $$cleanup] = $.setup_stores();
4168
4140
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
4169
4141
  const $_slotTimeLimits = () => $.store_get(_slotTimeLimits, "$_slotTimeLimits", $$stores);
4170
4142
  const $slotHeight = () => $.store_get(slotHeight, "$slotHeight", $$stores);
4171
4143
  const $slotEventOverlap = () => $.store_get(slotEventOverlap, "$slotEventOverlap", $$stores);
4144
+ const [$$stores, $$cleanup] = $.setup_stores();
4172
4145
  let { slotEventOverlap, slotDuration, slotHeight, _slotTimeLimits } = getContext("state");
4173
4146
  let display = $.derived(() => $$props.chunk.event.display);
4174
4147
  let styles = $.derived(() => (style) => {
@@ -4205,13 +4178,13 @@ function Event$2($$anchor, $$props) {
4205
4178
  var root$d = $.from_html(`<div></div>`);
4206
4179
  function NowIndicator$1($$anchor, $$props) {
4207
4180
  $.push($$props, true);
4208
- const [$$stores, $$cleanup] = $.setup_stores();
4209
4181
  const $_now = () => $.store_get(_now, "$_now", $$stores);
4210
4182
  const $_today = () => $.store_get(_today, "$_today", $$stores);
4211
4183
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
4212
4184
  const $_slotTimeLimits = () => $.store_get(_slotTimeLimits, "$_slotTimeLimits", $$stores);
4213
4185
  const $slotHeight = () => $.store_get(slotHeight, "$slotHeight", $$stores);
4214
4186
  const $theme = () => $.store_get(theme, "$theme", $$stores);
4187
+ const [$$stores, $$cleanup] = $.setup_stores();
4215
4188
  let {
4216
4189
  slotDuration,
4217
4190
  slotHeight,
@@ -4239,7 +4212,6 @@ var root_3$4 = $.from_html(`<!> <!> <!>`, 1);
4239
4212
  var root$c = $.from_html(`<div role="cell"><div><!></div> <div><!></div> <div><!></div></div>`);
4240
4213
  function Day$2($$anchor, $$props) {
4241
4214
  $.push($$props, true);
4242
- const [$$stores, $$cleanup] = $.setup_stores();
4243
4215
  const $_today = () => $.store_get(_today, "$_today", $$stores);
4244
4216
  const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
4245
4217
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
@@ -4247,12 +4219,14 @@ function Day$2($$anchor, $$props) {
4247
4219
  const $filterEventsWithResources = () => $.store_get(filterEventsWithResources, "$filterEventsWithResources", $$stores);
4248
4220
  const $resources = () => $.store_get(resources, "$resources", $$stores);
4249
4221
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
4222
+ const $eventOrder = () => $.store_get(eventOrder, "$eventOrder", $$stores);
4250
4223
  const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
4251
4224
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
4252
4225
  const $slotHeight = () => $.store_get(slotHeight, "$slotHeight", $$stores);
4253
4226
  const $theme = () => $.store_get(theme, "$theme", $$stores);
4254
4227
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
4255
4228
  const $nowIndicator = () => $.store_get(nowIndicator, "$nowIndicator", $$stores);
4229
+ const [$$stores, $$cleanup] = $.setup_stores();
4256
4230
  let resource = $.prop($$props, "resource", 3, void 0);
4257
4231
  let {
4258
4232
  _filteredEvents,
@@ -4262,6 +4236,7 @@ function Day$2($$anchor, $$props) {
4262
4236
  slotDuration,
4263
4237
  slotHeight,
4264
4238
  filterEventsWithResources,
4239
+ eventOrder,
4265
4240
  theme,
4266
4241
  resources,
4267
4242
  validRange,
@@ -4294,7 +4269,7 @@ function Day$2($$anchor, $$props) {
4294
4269
  }
4295
4270
  }
4296
4271
  }
4297
- groupEventChunks(chunks2);
4272
+ groupEventChunks(chunks2, $eventOrder());
4298
4273
  return [chunks2, bgChunks2];
4299
4274
  }), $$array = $.derived(() => $.to_array($.get($$d), 2)), chunks = $.derived(() => $.get($$array)[0]), bgChunks = $.derived(() => $.get($$array)[1]);
4300
4275
  let iChunks = $.derived(() => {
@@ -4318,8 +4293,7 @@ function Day$2($$anchor, $$props) {
4318
4293
  });
4319
4294
  var div = root$c();
4320
4295
  div.__pointerdown = function(...$$args) {
4321
- var _a, _b;
4322
- (_b = !$.get(disabled) ? (_a = $_interaction().action) == null ? void 0 : _a.select : void 0) == null ? void 0 : _b.apply(this, $$args);
4296
+ (!$.get(disabled) ? $_interaction().action?.select : void 0)?.apply(this, $$args);
4323
4297
  };
4324
4298
  var div_1 = $.child(div);
4325
4299
  var node = $.child(div_1);
@@ -4419,10 +4393,7 @@ function Day$2($$anchor, $$props) {
4419
4393
  $.set_class(div_2, 1, $theme().events);
4420
4394
  $.set_class(div_3, 1, $theme().extra);
4421
4395
  },
4422
- [() => {
4423
- var _a;
4424
- return (_a = $theme().weekdays) == null ? void 0 : _a[$$props.date.getUTCDay()];
4425
- }]
4396
+ [() => $theme().weekdays?.[$$props.date.getUTCDay()]]
4426
4397
  );
4427
4398
  $.append($$anchor, div);
4428
4399
  $.pop();
@@ -4451,6 +4422,7 @@ function Event$1($$anchor, $$props) {
4451
4422
  }
4452
4423
  $.set(margin, repositionEvent$1($$props.chunk, longChunks(), height($.get(el))), true);
4453
4424
  }
4425
+ var $$exports = { reposition };
4454
4426
  InteractableEvent($$anchor, {
4455
4427
  get chunk() {
4456
4428
  return $$props.chunk;
@@ -4467,18 +4439,18 @@ function Event$1($$anchor, $$props) {
4467
4439
  $.set(el, $$value, true);
4468
4440
  }
4469
4441
  });
4470
- return $.pop({ reposition });
4442
+ return $.pop($$exports);
4471
4443
  }
4472
4444
  var root_3$3 = $.from_html(`<div><!></div>`);
4473
4445
  var root$b = $.from_html(`<div role="cell"><div><!></div> <!> <div><!></div></div>`);
4474
4446
  function Day$1($$anchor, $$props) {
4475
4447
  $.push($$props, true);
4476
- const [$$stores, $$cleanup] = $.setup_stores();
4477
4448
  const $_today = () => $.store_get(_today, "$_today", $$stores);
4478
4449
  const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
4479
4450
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
4480
4451
  const $theme = () => $.store_get(theme, "$theme", $$stores);
4481
4452
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
4453
+ const [$$stores, $$cleanup] = $.setup_stores();
4482
4454
  let iChunks = $.prop($$props, "iChunks", 19, () => []), resource = $.prop($$props, "resource", 3, void 0);
4483
4455
  let { highlightedDates, theme, validRange, _interaction, _today } = getContext("state");
4484
4456
  let el = $.state(void 0);
@@ -4502,10 +4474,10 @@ function Day$1($$anchor, $$props) {
4502
4474
  runReposition(refs, $.get(dayChunks));
4503
4475
  }
4504
4476
  }
4477
+ var $$exports = { reposition };
4505
4478
  var div = root$b();
4506
4479
  div.__pointerdown = function(...$$args) {
4507
- var _a, _b;
4508
- (_b = !$.get(disabled) ? (_a = $_interaction().action) == null ? void 0 : _a.select : void 0) == null ? void 0 : _b.apply(this, $$args);
4480
+ (!$.get(disabled) ? $_interaction().action?.select : void 0)?.apply(this, $$args);
4509
4481
  };
4510
4482
  var div_1 = $.child(div);
4511
4483
  var node = $.child(div_1);
@@ -4562,7 +4534,7 @@ function Day$1($$anchor, $$props) {
4562
4534
  }
4563
4535
  }),
4564
4536
  ($$value, i2) => refs[i2] = $$value,
4565
- (i2) => refs == null ? void 0 : refs[i2],
4537
+ (i2) => refs?.[i2],
4566
4538
  () => [$.get(i)]
4567
4539
  );
4568
4540
  });
@@ -4581,30 +4553,29 @@ function Day$1($$anchor, $$props) {
4581
4553
  $.set_class(div_1, 1, $theme().bgEvents);
4582
4554
  $.set_class(div_3, 1, $theme().events);
4583
4555
  },
4584
- [() => {
4585
- var _a;
4586
- return (_a = $theme().weekdays) == null ? void 0 : _a[$$props.date.getUTCDay()];
4587
- }]
4556
+ [() => $theme().weekdays?.[$$props.date.getUTCDay()]]
4588
4557
  );
4589
4558
  $.append($$anchor, div);
4590
- var $$pop = $.pop({ reposition });
4559
+ var $$pop = $.pop($$exports);
4591
4560
  $$cleanup();
4592
4561
  return $$pop;
4593
4562
  }
4594
4563
  $.delegate(["pointerdown"]);
4595
4564
  function Week($$anchor, $$props) {
4596
4565
  $.push($$props, true);
4597
- const [$$stores, $$cleanup] = $.setup_stores();
4598
4566
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
4599
4567
  const $filterEventsWithResources = () => $.store_get(filterEventsWithResources, "$filterEventsWithResources", $$stores);
4600
4568
  const $resources = () => $.store_get(resources, "$resources", $$stores);
4601
4569
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
4602
4570
  const $hiddenDays = () => $.store_get(hiddenDays, "$hiddenDays", $$stores);
4571
+ const $eventOrder = () => $.store_get(eventOrder, "$eventOrder", $$stores);
4603
4572
  const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
4573
+ const [$$stores, $$cleanup] = $.setup_stores();
4604
4574
  let resource = $.prop($$props, "resource", 3, void 0);
4605
4575
  let {
4606
4576
  _filteredEvents,
4607
4577
  _iEvents,
4578
+ eventOrder,
4608
4579
  hiddenDays,
4609
4580
  resources,
4610
4581
  filterEventsWithResources,
@@ -4627,8 +4598,8 @@ function Week($$anchor, $$props) {
4627
4598
  }
4628
4599
  }
4629
4600
  }
4630
- prepareEventChunks$1(bgChunks2, $hiddenDays());
4631
- let longChunks2 = prepareEventChunks$1(chunks2, $hiddenDays());
4601
+ prepareEventChunks$1(bgChunks2, $hiddenDays(), $eventOrder());
4602
+ let longChunks2 = prepareEventChunks$1(chunks2, $hiddenDays(), $eventOrder());
4632
4603
  return [chunks2, bgChunks2, longChunks2];
4633
4604
  }), $$array = $.derived(() => $.to_array($.get($$d), 3)), chunks = $.derived(() => $.get($$array)[0]), bgChunks = $.derived(() => $.get($$array)[1]), longChunks = $.derived(() => $.get($$array)[2]);
4634
4605
  function reposition() {
@@ -4642,7 +4613,7 @@ function Week($$anchor, $$props) {
4642
4613
  let chunk;
4643
4614
  if (event && event.allDay && eventIntersects(event, $.get(start), $.get(end), resource())) {
4644
4615
  chunk = createEventChunk(event, $.get(start), $.get(end));
4645
- prepareEventChunks$1([chunk], $hiddenDays());
4616
+ prepareEventChunks$1([chunk], $hiddenDays(), $eventOrder());
4646
4617
  } else {
4647
4618
  chunk = null;
4648
4619
  }
@@ -4674,7 +4645,7 @@ function Week($$anchor, $$props) {
4674
4645
  }
4675
4646
  }),
4676
4647
  ($$value, i2) => refs[i2] = $$value,
4677
- (i2) => refs == null ? void 0 : refs[i2],
4648
+ (i2) => refs?.[i2],
4678
4649
  () => [i]
4679
4650
  );
4680
4651
  });
@@ -4687,13 +4658,13 @@ var root_3$2 = $.from_html(`<div><div><!> <div></div></div></div>`);
4687
4658
  var root$a = $.from_html(`<div><!> <div></div></div> <!> <!>`, 1);
4688
4659
  function View$2($$anchor, $$props) {
4689
4660
  $.push($$props, false);
4690
- const [$$stores, $$cleanup] = $.setup_stores();
4691
4661
  const $theme = () => $.store_get(theme, "$theme", $$stores);
4692
4662
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
4693
4663
  const $_today = () => $.store_get(_today, "$_today", $$stores);
4694
4664
  const $_intlDayHeaderAL = () => $.store_get(_intlDayHeaderAL, "$_intlDayHeaderAL", $$stores);
4695
4665
  const $_intlDayHeader = () => $.store_get(_intlDayHeader, "$_intlDayHeader", $$stores);
4696
4666
  const $allDaySlot = () => $.store_get(allDaySlot, "$allDaySlot", $$stores);
4667
+ const [$$stores, $$cleanup] = $.setup_stores();
4697
4668
  let {
4698
4669
  _viewDates,
4699
4670
  _intlDayHeader,
@@ -4713,7 +4684,7 @@ function View$2($$anchor, $$props) {
4713
4684
  $.each(node_1, 1, $_viewDates, $.index, ($$anchor3, date) => {
4714
4685
  var div_1 = root_2$4();
4715
4686
  var time = $.child(div_1);
4716
- $.action(time, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayHeader().format($.get(date)));
4687
+ $.action(time, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayHeader().format($.get(date)));
4717
4688
  $.reset(div_1);
4718
4689
  $.template_effect(
4719
4690
  ($0, $1, $2, $3) => {
@@ -4722,10 +4693,7 @@ function View$2($$anchor, $$props) {
4722
4693
  $.set_attribute(time, "aria-label", $3);
4723
4694
  },
4724
4695
  [
4725
- () => {
4726
- var _a;
4727
- return (_a = $theme().weekdays) == null ? void 0 : _a[$.get(date).getUTCDay()];
4728
- },
4696
+ () => $theme().weekdays?.[$.get(date).getUTCDay()],
4729
4697
  () => datesEqual($.get(date), $_today()) ? " " + $theme().today : "",
4730
4698
  () => toISOString($.get(date), 10),
4731
4699
  () => $_intlDayHeaderAL().format($.get(date))
@@ -4821,10 +4789,10 @@ const TimeGrid = {
4821
4789
  var root$9 = $.from_html(`<span></span>`);
4822
4790
  function Label$1($$anchor, $$props) {
4823
4791
  $.push($$props, true);
4824
- const [$$stores, $$cleanup] = $.setup_stores();
4825
4792
  const $resourceLabelContent = () => $.store_get(resourceLabelContent, "$resourceLabelContent", $$stores);
4826
4793
  const $_intlDayHeaderAL = () => $.store_get(_intlDayHeaderAL, "$_intlDayHeaderAL", $$stores);
4827
4794
  const $resourceLabelDidMount = () => $.store_get(resourceLabelDidMount, "$resourceLabelDidMount", $$stores);
4795
+ const [$$stores, $$cleanup] = $.setup_stores();
4828
4796
  let date = $.prop($$props, "date", 3, void 0), setLabel = $.prop($$props, "setLabel", 3, void 0);
4829
4797
  let {
4830
4798
  resourceLabelContent,
@@ -4865,7 +4833,7 @@ function Label$1($$anchor, $$props) {
4865
4833
  });
4866
4834
  var span = root$9();
4867
4835
  $.bind_this(span, ($$value) => $.set(el, $$value), () => $.get(el));
4868
- $.action(span, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(content));
4836
+ $.action(span, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(content));
4869
4837
  $.template_effect(() => $.set_attribute(span, "aria-label", $.get(ariaLabel)));
4870
4838
  $.append($$anchor, span);
4871
4839
  $.pop();
@@ -4884,7 +4852,6 @@ var root_17 = $.from_html(`<div></div>`);
4884
4852
  var root$8 = $.from_html(`<div><!> <div></div></div> <!> <!>`, 1);
4885
4853
  function View$1($$anchor, $$props) {
4886
4854
  $.push($$props, true);
4887
- const [$$stores, $$cleanup] = $.setup_stores();
4888
4855
  const $datesAboveResources = () => $.store_get(datesAboveResources, "$datesAboveResources", $$stores);
4889
4856
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
4890
4857
  const $_viewResources = () => $.store_get(_viewResources, "$_viewResources", $$stores);
@@ -4893,6 +4860,7 @@ function View$1($$anchor, $$props) {
4893
4860
  const $_intlDayHeaderAL = () => $.store_get(_intlDayHeaderAL, "$_intlDayHeaderAL", $$stores);
4894
4861
  const $_intlDayHeader = () => $.store_get(_intlDayHeader, "$_intlDayHeader", $$stores);
4895
4862
  const $allDaySlot = () => $.store_get(allDaySlot, "$allDaySlot", $$stores);
4863
+ const [$$stores, $$cleanup] = $.setup_stores();
4896
4864
  let {
4897
4865
  datesAboveResources,
4898
4866
  _today,
@@ -4919,7 +4887,7 @@ function View$1($$anchor, $$props) {
4919
4887
  var consequent = ($$anchor4) => {
4920
4888
  var div_2 = root_3$1();
4921
4889
  var time = $.child(div_2);
4922
- $.action(time, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayHeader().format($.get(item0)));
4890
+ $.action(time, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayHeader().format($.get(item0)));
4923
4891
  $.reset(div_2);
4924
4892
  $.template_effect(
4925
4893
  ($0, $1, $2, $3) => {
@@ -4928,10 +4896,7 @@ function View$1($$anchor, $$props) {
4928
4896
  $.set_attribute(time, "aria-label", $3);
4929
4897
  },
4930
4898
  [
4931
- () => {
4932
- var _a;
4933
- return (_a = $theme().weekdays) == null ? void 0 : _a[$.get(item0).getUTCDay()];
4934
- },
4899
+ () => $theme().weekdays?.[$.get(item0).getUTCDay()],
4935
4900
  () => datesEqual($.get(item0), $_today()) ? " " + $theme().today : "",
4936
4901
  () => toISOString($.get(item0), 10),
4937
4902
  () => $_intlDayHeaderAL().format($.get(item0))
@@ -4983,7 +4948,7 @@ function View$1($$anchor, $$props) {
4983
4948
  var alternate_1 = ($$anchor6) => {
4984
4949
  var div_6 = root_8();
4985
4950
  var time_1 = $.child(div_6);
4986
- $.action(time_1, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayHeader().format($.get(item1)));
4951
+ $.action(time_1, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayHeader().format($.get(item1)));
4987
4952
  $.reset(div_6);
4988
4953
  $.template_effect(
4989
4954
  ($0, $1, $2, $3) => {
@@ -4992,10 +4957,7 @@ function View$1($$anchor, $$props) {
4992
4957
  $.set_attribute(time_1, "aria-label", `${resourceLabels[i] ?? ""}${$3 ?? ""}`);
4993
4958
  },
4994
4959
  [
4995
- () => {
4996
- var _a;
4997
- return (_a = $theme().weekdays) == null ? void 0 : _a[$.get(item1).getUTCDay()];
4998
- },
4960
+ () => $theme().weekdays?.[$.get(item1).getUTCDay()],
4999
4961
  () => datesEqual($.get(item1), $_today()) ? " " + $theme().today : "",
5000
4962
  () => toISOString($.get(item1), 10),
5001
4963
  () => $_intlDayHeaderAL().format($.get(item1))
@@ -5208,10 +5170,10 @@ function nestedResources(state) {
5208
5170
  var root$7 = $.from_html(`<span></span>`);
5209
5171
  function Label($$anchor, $$props) {
5210
5172
  $.push($$props, true);
5211
- const [$$stores, $$cleanup] = $.setup_stores();
5212
5173
  const $resourceLabelContent = () => $.store_get(resourceLabelContent, "$resourceLabelContent", $$stores);
5213
5174
  const $_resHs = () => $.store_get(_resHs, "$_resHs", $$stores);
5214
5175
  const $resourceLabelDidMount = () => $.store_get(resourceLabelDidMount, "$resourceLabelDidMount", $$stores);
5176
+ const [$$stores, $$cleanup] = $.setup_stores();
5215
5177
  let date = $.prop($$props, "date", 3, void 0);
5216
5178
  let { resourceLabelContent, resourceLabelDidMount, _resHs } = getContext("state");
5217
5179
  let el = $.state(void 0);
@@ -5243,7 +5205,7 @@ function Label($$anchor, $$props) {
5243
5205
  });
5244
5206
  var span = root$7();
5245
5207
  $.bind_this(span, ($$value) => $.set(el, $$value), () => $.get(el));
5246
- $.action(span, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(content));
5208
+ $.action(span, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(content));
5247
5209
  $.append($$anchor, span);
5248
5210
  $.pop();
5249
5211
  $$cleanup();
@@ -5259,8 +5221,8 @@ var root_2$2 = $.from_html(`<button><!></button>`);
5259
5221
  var root$6 = $.from_html(`<!> <span><!></span>`, 1);
5260
5222
  function Expander($$anchor, $$props) {
5261
5223
  $.push($$props, true);
5262
- const [$$stores, $$cleanup] = $.setup_stores();
5263
5224
  const $theme = () => $.store_get(theme, "$theme", $$stores);
5225
+ const [$$stores, $$cleanup] = $.setup_stores();
5264
5226
  let { resources, theme } = getContext("state");
5265
5227
  let payload = $.state({});
5266
5228
  let expanded = $.state(true);
@@ -5310,8 +5272,7 @@ function Expander($$anchor, $$props) {
5310
5272
  $.append($$anchor2, button);
5311
5273
  };
5312
5274
  $.if(node_1, ($$render) => {
5313
- var _a;
5314
- if ((_a = $.get(payload).children) == null ? void 0 : _a.length) $$render(consequent_1);
5275
+ if ($.get(payload).children?.length) $$render(consequent_1);
5315
5276
  });
5316
5277
  }
5317
5278
  $.reset(span_1);
@@ -5325,7 +5286,6 @@ var root_1$3 = $.from_html(`<div role="rowheader"><!> <!></div>`);
5325
5286
  var root$5 = $.from_html(`<div><div></div> <div></div></div>`);
5326
5287
  function Sidebar($$anchor, $$props) {
5327
5288
  $.push($$props, true);
5328
- const [$$stores, $$cleanup] = $.setup_stores();
5329
5289
  const $_viewResources = () => $.store_get(_viewResources, "$_viewResources", $$stores);
5330
5290
  const $_resHs = () => $.store_get(_resHs, "$_resHs", $$stores);
5331
5291
  const $_bodyEl = () => $.store_get(_bodyEl, "$_bodyEl", $$stores);
@@ -5334,6 +5294,7 @@ function Sidebar($$anchor, $$props) {
5334
5294
  const $_sidebarEl = () => $.store_get(_sidebarEl, "$_sidebarEl", $$stores);
5335
5295
  const $_daysHs = () => $.store_get(_daysHs, "$_daysHs", $$stores);
5336
5296
  const $_nestedResources = () => $.store_get(_nestedResources, "$_nestedResources", $$stores);
5297
+ const [$$stores, $$cleanup] = $.setup_stores();
5337
5298
  let {
5338
5299
  _viewResources,
5339
5300
  _headerHeight,
@@ -5410,7 +5371,6 @@ var root_1$2 = $.from_html(`<div><!></div>`);
5410
5371
  var root$4 = $.from_html(`<div><div role="row"></div> <div></div></div>`);
5411
5372
  function Header($$anchor, $$props) {
5412
5373
  $.push($$props, false);
5413
- const [$$stores, $$cleanup] = $.setup_stores();
5414
5374
  const $theme = () => $.store_get(theme, "$theme", $$stores);
5415
5375
  const $_headerEl = () => $.store_get(_headerEl, "$_headerEl", $$stores);
5416
5376
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
@@ -5419,6 +5379,7 @@ function Header($$anchor, $$props) {
5419
5379
  const $_intlDayHeaderAL = () => $.store_get(_intlDayHeaderAL, "$_intlDayHeaderAL", $$stores);
5420
5380
  const $_intlDayHeader = () => $.store_get(_intlDayHeader, "$_intlDayHeader", $$stores);
5421
5381
  const $_dayTimes = () => $.store_get(_dayTimes, "$_dayTimes", $$stores);
5382
+ const [$$stores, $$cleanup] = $.setup_stores();
5422
5383
  let {
5423
5384
  _headerEl,
5424
5385
  _headerHeight,
@@ -5441,13 +5402,13 @@ function Header($$anchor, $$props) {
5441
5402
  var fragment = root_2$1();
5442
5403
  var div_3 = $.first_child(fragment);
5443
5404
  var time_1 = $.child(div_3);
5444
- $.action(time_1, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayHeader().format($.get(date)));
5405
+ $.action(time_1, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayHeader().format($.get(date)));
5445
5406
  $.reset(div_3);
5446
5407
  var div_4 = $.sibling(div_3, 2);
5447
5408
  $.each(div_4, 5, () => $_dayTimes()[$.get(date).getTime()], $.index, ($$anchor4, time) => {
5448
5409
  var div_5 = root_3();
5449
5410
  var time_2 = $.child(div_5);
5450
- $.action(time_2, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $.get(time)[1]);
5411
+ $.action(time_2, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $.get(time)[1]);
5451
5412
  $.reset(div_5);
5452
5413
  $.template_effect(() => {
5453
5414
  $.set_class(div_5, 1, `${$theme().time ?? ""}${$.get(time)[2] ? "" : " " + $theme().minor}`);
@@ -5473,7 +5434,7 @@ function Header($$anchor, $$props) {
5473
5434
  var alternate = ($$anchor3) => {
5474
5435
  var div_6 = root_4();
5475
5436
  var time_3 = $.child(div_6);
5476
- $.action(time_3, ($$node, $$action_arg) => setContent == null ? void 0 : setContent($$node, $$action_arg), () => $_intlDayHeader().format($.get(date)));
5437
+ $.action(time_3, ($$node, $$action_arg) => setContent?.($$node, $$action_arg), () => $_intlDayHeader().format($.get(date)));
5477
5438
  $.reset(div_6);
5478
5439
  $.template_effect(
5479
5440
  ($0, $1) => {
@@ -5495,10 +5456,7 @@ function Header($$anchor, $$props) {
5495
5456
  }
5496
5457
  $.reset(div_2);
5497
5458
  $.template_effect(($0, $1) => $.set_class(div_2, 1, `${$theme().day ?? ""} ${$0 ?? ""}${$1 ?? ""}`), [
5498
- () => {
5499
- var _a;
5500
- return (_a = $theme().weekdays) == null ? void 0 : _a[$.get(date).getUTCDay()];
5501
- },
5459
+ () => $theme().weekdays?.[$.get(date).getUTCDay()],
5502
5460
  () => datesEqual($.get(date), $_today()) ? " " + $theme().today : ""
5503
5461
  ]);
5504
5462
  $.append($$anchor2, div_2);
@@ -5507,7 +5465,7 @@ function Header($$anchor, $$props) {
5507
5465
  var div_7 = $.sibling(div_1, 2);
5508
5466
  $.reset(div);
5509
5467
  $.bind_this(div, ($$value) => $.store_set(_headerEl, $$value), () => $_headerEl());
5510
- $.action(div, ($$node, $$action_arg) => observeResize == null ? void 0 : observeResize($$node, $$action_arg), () => () => $.store_set(_headerHeight, $_headerEl().clientHeight));
5468
+ $.action(div, ($$node, $$action_arg) => observeResize?.($$node, $$action_arg), () => () => $.store_set(_headerHeight, $_headerEl().clientHeight));
5511
5469
  $.template_effect(() => {
5512
5470
  $.set_class(div, 1, $theme().header);
5513
5471
  $.set_class(div_1, 1, $theme().days);
@@ -5517,11 +5475,11 @@ function Header($$anchor, $$props) {
5517
5475
  $.pop();
5518
5476
  $$cleanup();
5519
5477
  }
5520
- function prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration) {
5478
+ function prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration, $eventOrder) {
5521
5479
  let longChunks = {};
5522
5480
  let filteredChunks = [];
5523
5481
  if (chunks.length) {
5524
- sortEventChunks(chunks);
5482
+ sortEventChunks(chunks, $eventOrder);
5525
5483
  let step = toSeconds($slotDuration);
5526
5484
  let prevChunk;
5527
5485
  for (let chunk of chunks) {
@@ -5614,7 +5572,7 @@ function repositionEvent(chunk, dayChunks, longChunks, height2, allDay) {
5614
5572
  chunk.bottom = height2;
5615
5573
  let margin = 1;
5616
5574
  let key = chunk.date.getTime();
5617
- longChunks = (longChunks == null ? void 0 : longChunks[key]) ?? [];
5575
+ longChunks = longChunks?.[key] ?? [];
5618
5576
  let chunks = [...dayChunks, ...longChunks];
5619
5577
  chunks.sort((a, b) => (a.top ?? 0) - (b.top ?? 0) || a.start - b.start || b.event.allDay - a.event.allDay);
5620
5578
  for (let dayChunk of chunks) {
@@ -5635,9 +5593,9 @@ function getSlotTimeLimits($_dayTimeLimits, date) {
5635
5593
  }
5636
5594
  function Event($$anchor, $$props) {
5637
5595
  $.push($$props, true);
5638
- const [$$stores, $$cleanup] = $.setup_stores();
5639
5596
  const $slotWidth = () => $.store_get(slotWidth, "$slotWidth", $$stores);
5640
5597
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
5598
+ const [$$stores, $$cleanup] = $.setup_stores();
5641
5599
  let dayChunks = $.prop($$props, "dayChunks", 19, () => []), longChunks = $.prop($$props, "longChunks", 19, () => ({})), resource = $.prop($$props, "resource", 3, void 0);
5642
5600
  let { slotDuration, slotWidth } = getContext("state");
5643
5601
  let el = $.state(void 0);
@@ -5670,6 +5628,7 @@ function Event($$anchor, $$props) {
5670
5628
  $.set(margin, repositionEvent($$props.chunk, dayChunks(), longChunks(), h, !toSeconds($slotDuration())), true);
5671
5629
  return $.get(margin) + h;
5672
5630
  }
5631
+ var $$exports = { reposition };
5673
5632
  var fragment = $.comment();
5674
5633
  var node = $.first_child(fragment);
5675
5634
  {
@@ -5696,7 +5655,7 @@ function Event($$anchor, $$props) {
5696
5655
  });
5697
5656
  }
5698
5657
  $.append($$anchor, fragment);
5699
- var $$pop = $.pop({ reposition });
5658
+ var $$pop = $.pop($$exports);
5700
5659
  $$cleanup();
5701
5660
  return $$pop;
5702
5661
  }
@@ -5704,7 +5663,6 @@ var root_1$1 = $.from_html(`<!> <!> <!> <!>`, 1);
5704
5663
  var root$3 = $.from_html(`<div role="cell"><div><!></div></div>`);
5705
5664
  function Day($$anchor, $$props) {
5706
5665
  $.push($$props, true);
5707
- const [$$stores, $$cleanup] = $.setup_stores();
5708
5666
  const $_today = () => $.store_get(_today, "$_today", $$stores);
5709
5667
  const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
5710
5668
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
@@ -5713,6 +5671,7 @@ function Day($$anchor, $$props) {
5713
5671
  const $slotWidth = () => $.store_get(slotWidth, "$slotWidth", $$stores);
5714
5672
  const $theme = () => $.store_get(theme, "$theme", $$stores);
5715
5673
  const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
5674
+ const [$$stores, $$cleanup] = $.setup_stores();
5716
5675
  let iChunks = $.prop($$props, "iChunks", 19, () => []);
5717
5676
  let {
5718
5677
  highlightedDates,
@@ -5753,10 +5712,10 @@ function Day($$anchor, $$props) {
5753
5712
  function reposition() {
5754
5713
  return max(...runReposition(refs, $.get(dayChunks)));
5755
5714
  }
5715
+ var $$exports = { reposition };
5756
5716
  var div = root$3();
5757
5717
  div.__pointerdown = function(...$$args) {
5758
- var _a, _b;
5759
- (_b = (_a = $_interaction().action) == null ? void 0 : _a.select) == null ? void 0 : _b.apply(this, $$args);
5718
+ $_interaction().action?.select?.apply(this, $$args);
5760
5719
  };
5761
5720
  var div_1 = $.child(div);
5762
5721
  var node = $.child(div_1);
@@ -5802,7 +5761,7 @@ function Day($$anchor, $$props) {
5802
5761
  }
5803
5762
  }),
5804
5763
  ($$value, i2) => refs[i2] = $$value,
5805
- (i2) => refs == null ? void 0 : refs[i2],
5764
+ (i2) => refs?.[i2],
5806
5765
  () => [$.get(i)]
5807
5766
  );
5808
5767
  });
@@ -5838,15 +5797,12 @@ function Day($$anchor, $$props) {
5838
5797
  $.set_class(div_1, 1, $theme().events);
5839
5798
  },
5840
5799
  [
5841
- () => {
5842
- var _a;
5843
- return (_a = $theme().weekdays) == null ? void 0 : _a[$$props.date.getUTCDay()];
5844
- },
5800
+ () => $theme().weekdays?.[$$props.date.getUTCDay()],
5845
5801
  () => $.get(allDay) ? null : ceil((toSeconds($.get(slotTimeLimits2).max) - toSeconds($.get(slotTimeLimits2).min)) / toSeconds($slotDuration()))
5846
5802
  ]
5847
5803
  );
5848
5804
  $.append($$anchor, div);
5849
- var $$pop = $.pop({ reposition });
5805
+ var $$pop = $.pop($$exports);
5850
5806
  $$cleanup();
5851
5807
  return $$pop;
5852
5808
  }
@@ -5854,16 +5810,17 @@ $.delegate(["pointerdown"]);
5854
5810
  var root$2 = $.from_html(`<div role="row"></div>`);
5855
5811
  function Days($$anchor, $$props) {
5856
5812
  $.push($$props, true);
5857
- const [$$stores, $$cleanup] = $.setup_stores();
5858
5813
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
5859
5814
  const $validRange = () => $.store_get(validRange, "$validRange", $$stores);
5860
5815
  const $_dayTimeLimits = () => $.store_get(_dayTimeLimits, "$_dayTimeLimits", $$stores);
5861
5816
  const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
5862
5817
  const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
5818
+ const $eventOrder = () => $.store_get(eventOrder, "$eventOrder", $$stores);
5863
5819
  const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
5864
5820
  const $_daysHs = () => $.store_get(_daysHs, "$_daysHs", $$stores);
5865
5821
  const $theme = () => $.store_get(theme, "$theme", $$stores);
5866
5822
  const $_resHs = () => $.store_get(_resHs, "$_resHs", $$stores);
5823
+ const [$$stores, $$cleanup] = $.setup_stores();
5867
5824
  let {
5868
5825
  _viewDates,
5869
5826
  _filteredEvents,
@@ -5871,6 +5828,7 @@ function Days($$anchor, $$props) {
5871
5828
  _dayTimeLimits,
5872
5829
  _daysHs,
5873
5830
  _resHs,
5831
+ eventOrder,
5874
5832
  slotDuration,
5875
5833
  theme,
5876
5834
  validRange
@@ -5903,15 +5861,15 @@ function Days($$anchor, $$props) {
5903
5861
  }
5904
5862
  }
5905
5863
  }
5906
- [bgChunks2] = prepareEventChunks(bgChunks2, $_viewDates(), $_dayTimeLimits(), $slotDuration());
5907
- [chunks2, longChunks2] = prepareEventChunks(chunks2, $_viewDates(), $_dayTimeLimits(), $slotDuration());
5864
+ [bgChunks2] = prepareEventChunks(bgChunks2, $_viewDates(), $_dayTimeLimits(), $slotDuration(), $eventOrder());
5865
+ [chunks2, longChunks2] = prepareEventChunks(chunks2, $_viewDates(), $_dayTimeLimits(), $slotDuration(), $eventOrder());
5908
5866
  return [chunks2, bgChunks2, longChunks2];
5909
5867
  }), $$array_3 = $.derived(() => $.to_array($.get($$d_1), 3)), chunks = $.derived(() => $.get($$array_3)[0]), bgChunks = $.derived(() => $.get($$array_3)[1]), longChunks = $.derived(() => $.get($$array_3)[2]);
5910
5868
  let iChunks = $.derived(() => $_iEvents().map((event) => {
5911
5869
  let chunk;
5912
5870
  if (event && eventIntersects(event, $.get(start), $.get(end), $$props.resource)) {
5913
5871
  chunk = createEventChunk(event, $.get(start), $.get(end));
5914
- [[chunk]] = prepareEventChunks([chunk], $_viewDates(), $_dayTimeLimits(), $slotDuration());
5872
+ [[chunk]] = prepareEventChunks([chunk], $_viewDates(), $_dayTimeLimits(), $slotDuration(), $eventOrder());
5915
5873
  } else {
5916
5874
  chunk = null;
5917
5875
  }
@@ -5921,6 +5879,7 @@ function Days($$anchor, $$props) {
5921
5879
  $_daysHs().set($$props.resource, ceil(max(...runReposition(refs, $_viewDates()))) + 10);
5922
5880
  $.store_set(_daysHs, $_daysHs());
5923
5881
  }
5882
+ var $$exports = { reposition };
5924
5883
  var div = root$2();
5925
5884
  $.each(div, 5, $_viewDates, $.index, ($$anchor2, date, i) => {
5926
5885
  $.bind_this(
@@ -5945,7 +5904,7 @@ function Days($$anchor, $$props) {
5945
5904
  }
5946
5905
  }),
5947
5906
  ($$value, i2) => refs[i2] = $$value,
5948
- (i2) => refs == null ? void 0 : refs[i2],
5907
+ (i2) => refs?.[i2],
5949
5908
  () => [i]
5950
5909
  );
5951
5910
  });
@@ -5960,7 +5919,7 @@ function Days($$anchor, $$props) {
5960
5919
  ]
5961
5920
  );
5962
5921
  $.append($$anchor, div);
5963
- var $$pop = $.pop({ reposition });
5922
+ var $$pop = $.pop($$exports);
5964
5923
  $$cleanup();
5965
5924
  return $$pop;
5966
5925
  }
@@ -5968,7 +5927,6 @@ var root_2 = $.from_html(`<div></div>`);
5968
5927
  var root$1 = $.from_html(`<div><div><div></div> <!></div></div>`);
5969
5928
  function Body($$anchor, $$props) {
5970
5929
  $.push($$props, true);
5971
- const [$$stores, $$cleanup] = $.setup_stores();
5972
5930
  const $_dayTimeLimits = () => $.store_get(_dayTimeLimits, "$_dayTimeLimits", $$stores);
5973
5931
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
5974
5932
  const $_bodyEl = () => $.store_get(_bodyEl, "$_bodyEl", $$stores);
@@ -5982,6 +5940,7 @@ function Body($$anchor, $$props) {
5982
5940
  const $_sidebarEl = () => $.store_get(_sidebarEl, "$_sidebarEl", $$stores);
5983
5941
  const $theme = () => $.store_get(theme, "$theme", $$stores);
5984
5942
  const $_dayTimes = () => $.store_get(_dayTimes, "$_dayTimes", $$stores);
5943
+ const [$$stores, $$cleanup] = $.setup_stores();
5985
5944
  let {
5986
5945
  _bodyEl,
5987
5946
  _bodyHeight,
@@ -6055,14 +6014,14 @@ function Body($$anchor, $$props) {
6055
6014
  }
6056
6015
  }),
6057
6016
  ($$value, i2) => refs[i2] = $$value,
6058
- (i2) => refs == null ? void 0 : refs[i2],
6017
+ (i2) => refs?.[i2],
6059
6018
  () => [i]
6060
6019
  );
6061
6020
  });
6062
6021
  $.reset(div_1);
6063
6022
  $.reset(div);
6064
6023
  $.bind_this(div, ($$value) => $.store_set(_bodyEl, $$value), () => $_bodyEl());
6065
- $.action(div, ($$node, $$action_arg) => observeResize == null ? void 0 : observeResize($$node, $$action_arg), () => onresize);
6024
+ $.action(div, ($$node, $$action_arg) => observeResize?.($$node, $$action_arg), () => onresize);
6066
6025
  $.template_effect(() => {
6067
6026
  $.set_class(div, 1, $theme().body);
6068
6027
  $.set_class(div_1, 1, $theme().content);
@@ -6076,7 +6035,6 @@ function Body($$anchor, $$props) {
6076
6035
  var root_1 = $.from_html(`<div></div>`);
6077
6036
  function NowIndicator($$anchor, $$props) {
6078
6037
  $.push($$props, true);
6079
- const [$$stores, $$cleanup] = $.setup_stores();
6080
6038
  const $_viewDates = () => $.store_get(_viewDates, "$_viewDates", $$stores);
6081
6039
  const $_dayTimeLimits = () => $.store_get(_dayTimeLimits, "$_dayTimeLimits", $$stores);
6082
6040
  const $_today = () => $.store_get(_today, "$_today", $$stores);
@@ -6088,6 +6046,7 @@ function NowIndicator($$anchor, $$props) {
6088
6046
  const $theme = () => $.store_get(theme, "$theme", $$stores);
6089
6047
  const $_headerHeight = () => $.store_get(_headerHeight, "$_headerHeight", $$stores);
6090
6048
  const $_bodyHeight = () => $.store_get(_bodyHeight, "$_bodyHeight", $$stores);
6049
+ const [$$stores, $$cleanup] = $.setup_stores();
6091
6050
  let {
6092
6051
  slotDuration,
6093
6052
  slotWidth,
@@ -6153,9 +6112,9 @@ function NowIndicator($$anchor, $$props) {
6153
6112
  var root = $.from_html(`<div><!> <div><!> <!> <!></div></div>`);
6154
6113
  function View($$anchor, $$props) {
6155
6114
  $.push($$props, false);
6156
- const [$$stores, $$cleanup] = $.setup_stores();
6157
6115
  const $theme = () => $.store_get(theme, "$theme", $$stores);
6158
6116
  const $nowIndicator = () => $.store_get(nowIndicator, "$nowIndicator", $$stores);
6117
+ const [$$stores, $$cleanup] = $.setup_stores();
6159
6118
  let { nowIndicator, theme } = getContext("state");
6160
6119
  $.init();
6161
6120
  var div = root();