@burdenoff/microfe-calendar 2026.1120.1 → 2026.1123.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/CalendarRoutes.d.ts +3 -0
  2. package/dist/CalendarRoutes.js +37 -32
  3. package/dist/CalendarRoutes.js.map +1 -1
  4. package/dist/generated/global-operations.d.ts +74 -0
  5. package/dist/generated/global-operations.js +20 -0
  6. package/dist/generated/global-operations.js.map +1 -0
  7. package/dist/generated/global-types.d.ts +9902 -578
  8. package/dist/generated/wspace-operations.d.ts +298 -0
  9. package/dist/generated/wspace-operations.js +126 -1
  10. package/dist/generated/wspace-operations.js.map +1 -1
  11. package/dist/generated/wspace-types.d.ts +204825 -48049
  12. package/dist/providers/CalendarProvider.d.ts +2 -0
  13. package/dist/providers/CalendarProvider.js +12 -10
  14. package/dist/providers/CalendarProvider.js.map +1 -1
  15. package/dist/translations/en.d.ts +5 -0
  16. package/dist/types/index.d.ts +6 -0
  17. package/dist/v2/CalendarPageV2.d.ts +1 -0
  18. package/dist/v2/CalendarPageV2.js +19 -0
  19. package/dist/v2/CalendarPageV2.js.map +1 -0
  20. package/dist/v2/CalendarRoutesV2.d.ts +1 -0
  21. package/dist/v2/CalendarRoutesV2.js +117 -0
  22. package/dist/v2/CalendarRoutesV2.js.map +1 -0
  23. package/dist/v2/data/invalidation.d.ts +4 -0
  24. package/dist/v2/data/normalize.d.ts +26 -0
  25. package/dist/v2/data/normalize.js +87 -0
  26. package/dist/v2/data/normalize.js.map +1 -0
  27. package/dist/v2/data/useCalendarsV2.d.ts +16 -0
  28. package/dist/v2/data/useCalendarsV2.js +25 -0
  29. package/dist/v2/data/useCalendarsV2.js.map +1 -0
  30. package/dist/v2/data/useEventsInRangeV2.d.ts +18 -0
  31. package/dist/v2/data/useFreeBusy.d.ts +22 -0
  32. package/dist/v2/data/useKeyedLoad.d.ts +17 -0
  33. package/dist/v2/prefs/CalendarPrefsProvider.d.ts +25 -0
  34. package/dist/v2/prefs/CalendarPrefsProvider.js +52 -0
  35. package/dist/v2/prefs/CalendarPrefsProvider.js.map +1 -0
  36. package/dist/v2/prefs/calendarPrefs.d.ts +73 -0
  37. package/dist/v2/prefs/calendarPrefs.js +71 -0
  38. package/dist/v2/prefs/calendarPrefs.js.map +1 -0
  39. package/dist/v2/prefs/prefsApi.d.ts +16 -0
  40. package/dist/v2/prefs/prefsApi.js +46 -0
  41. package/dist/v2/prefs/prefsApi.js.map +1 -0
  42. package/dist/v2/prefs/prefsSession.d.ts +55 -0
  43. package/dist/v2/prefs/prefsSession.js +94 -0
  44. package/dist/v2/prefs/prefsSession.js.map +1 -0
  45. package/dist/v2/prefs/prefsStorage.d.ts +17 -0
  46. package/dist/v2/prefs/prefsStorage.js +56 -0
  47. package/dist/v2/prefs/prefsStorage.js.map +1 -0
  48. package/dist/v2/routes.d.ts +43 -0
  49. package/dist/v2/routes.js +60 -0
  50. package/dist/v2/routes.js.map +1 -0
  51. package/dist/v2/state/calendarV2Store.d.ts +54 -0
  52. package/dist/v2/state/calendarV2Store.js +78 -0
  53. package/dist/v2/state/calendarV2Store.js.map +1 -0
  54. package/dist/v2/state/useCalendarV2Navigation.d.ts +25 -0
  55. package/dist/v2/state/useCalendarV2Navigation.js +52 -0
  56. package/dist/v2/state/useCalendarV2Navigation.js.map +1 -0
  57. package/dist/v2/state/useCalendarV2PrefsBridge.d.ts +1 -0
  58. package/dist/v2/state/useCalendarV2PrefsBridge.js +28 -0
  59. package/dist/v2/state/useCalendarV2PrefsBridge.js.map +1 -0
  60. package/dist/v2/time/calendarTime.d.ts +115 -0
  61. package/dist/v2/time/calendarTime.js +59 -0
  62. package/dist/v2/time/calendarTime.js.map +1 -0
  63. package/dist/v2/types.d.ts +202 -0
  64. package/package.json +12 -5
@@ -0,0 +1,60 @@
1
+ import { isDateValue as e } from "@burdenoff/fe-libs/ui";
2
+ // src/v2/routes.ts
3
+ var t = [
4
+ "day",
5
+ "week",
6
+ "month",
7
+ "list"
8
+ ], n = [
9
+ "rooms",
10
+ "share",
11
+ "settings"
12
+ ], r = "week", i = {
13
+ year: "month",
14
+ timeline: "week",
15
+ agenda: "list"
16
+ }, a = {
17
+ resources: "rooms",
18
+ subscriptions: "share",
19
+ settings: "settings"
20
+ }, o = {
21
+ date: "date",
22
+ dialog: "dialog",
23
+ event: "event"
24
+ }, s = new Set(t), c = new Set(n);
25
+ function l(e) {
26
+ return s.has(e);
27
+ }
28
+ function u(e) {
29
+ return c.has(e);
30
+ }
31
+ function d(e) {
32
+ return l(e) ? e : e && Object.hasOwn(i, e) ? i[e] ?? null : null;
33
+ }
34
+ function f(e) {
35
+ let t = (e ?? "").replace(/\/+$/, "");
36
+ return t === "" || t.startsWith("/") ? t : `/${t}`;
37
+ }
38
+ function p(t) {
39
+ let n = typeof t == "string" ? new URLSearchParams(t) : t, r = n.get(o.date), i = n.get(o.dialog), a = n.get(o.event)?.trim();
40
+ return {
41
+ date: e(r) ? r : null,
42
+ dialog: u(i) ? i : null,
43
+ eventId: a || null
44
+ };
45
+ }
46
+ function m(e, t) {
47
+ let n = new URLSearchParams(e);
48
+ for (let [e, r] of Object.entries(t)) r == null || r === "" ? n.delete(e) : n.set(e, r);
49
+ let r = n.toString();
50
+ return r ? `?${r}` : "";
51
+ }
52
+ function h(e, t) {
53
+ return `${f(e)}/view/${t}`;
54
+ }
55
+ function g(e, t, n = {}, r = "") {
56
+ return `${h(e, t)}${m(r, n)}`;
57
+ }
58
+ export { n as CALENDAR_V2_DIALOGS, t as CALENDAR_V2_VIEWS, r as DEFAULT_VIEW, a as LEGACY_PAGE_DIALOGS, i as LEGACY_VIEW_REDIRECTS, o as SEARCH_PARAMS, g as calendarV2Href, u as isCalendarV2Dialog, l as isCalendarV2View, f as normalizeBasePath, p as readCalendarV2Search, d as viewForName, h as viewPath, m as withSearchParams };
59
+
60
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","names":["CALENDAR_V2_VIEWS","CALENDAR_V2_DIALOGS","DEFAULT_VIEW","LEGACY_VIEW_REDIRECTS","LEGACY_PAGE_DIALOGS","SEARCH_PARAMS","VIEW_NAMES","DIALOG_NAMES","isCalendarV2View","value","isCalendarV2Dialog","viewForName","name","normalizeBasePath","trimmed","basePath","readCalendarV2Search","params","search","date","dialog","eventId","isDateValue","withSearchParams","changes","query","viewPath","view","calendarV2Href","keep"],"sources":["../../src/v2/routes.ts"],"sourcesContent":["/**\n * The redesigned calendar's addresses (BOFF-15698 §2), relative to the calendar's base path:\n *\n * view/<day|week|month|list>?date=YYYY-MM-DD a view at a day (today without `date`)\n * &dialog=<rooms|share|settings> … with a dialog open\n * &event=<id> … with an event's peek open\n *\n * Today's addresses keep working (bookmarks, notifications, emails, the assistant): each\n * redirects to the redesign's place for it (`LEGACY_VIEW_REDIRECTS`, `LEGACY_PAGE_DIALOGS`,\n * and `event/:id`, which opens the peek on that event's week).\n */\nimport { isDateValue, type DateValue } from '@burdenoff/fe-libs/ui';\nimport type { CalendarV2Dialog, CalendarV2View } from './types';\n\nexport const CALENDAR_V2_VIEWS: readonly CalendarV2View[] = ['day', 'week', 'month', 'list'];\n\nexport const CALENDAR_V2_DIALOGS: readonly CalendarV2Dialog[] = ['rooms', 'share', 'settings'];\n\n/** The view an address shows when it names none. */\nexport const DEFAULT_VIEW: CalendarV2View = 'week';\n\n/** Today's views the redesign drops, and the view each now opens (§2). */\nexport const LEGACY_VIEW_REDIRECTS: Readonly<Record<string, CalendarV2View>> = {\n year: 'month',\n timeline: 'week',\n agenda: 'list',\n};\n\n/** Today's pages that are dialogs in the redesign (§2), opened over the week view. */\nexport const LEGACY_PAGE_DIALOGS: Readonly<Record<string, CalendarV2Dialog>> = {\n resources: 'rooms',\n subscriptions: 'share',\n settings: 'settings',\n};\n\n/** The query parameters the redesign reads. */\nexport const SEARCH_PARAMS = {\n date: 'date',\n dialog: 'dialog',\n event: 'event',\n} as const;\n\nconst VIEW_NAMES: ReadonlySet<unknown> = new Set(CALENDAR_V2_VIEWS);\nconst DIALOG_NAMES: ReadonlySet<unknown> = new Set(CALENDAR_V2_DIALOGS);\n\nexport function isCalendarV2View(value: unknown): value is CalendarV2View {\n return VIEW_NAMES.has(value);\n}\n\nexport function isCalendarV2Dialog(value: unknown): value is CalendarV2Dialog {\n return DIALOG_NAMES.has(value);\n}\n\n/**\n * The view an address's view name opens: a redesign view as it is, a dropped one where §2\n * sends it, anything else null. Own keys only, so `constructor` or `toString` read as unknown.\n */\nexport function viewForName(name: string | null | undefined): CalendarV2View | null {\n if (isCalendarV2View(name)) return name;\n return name && Object.hasOwn(LEGACY_VIEW_REDIRECTS, name)\n ? (LEGACY_VIEW_REDIRECTS[name] ?? null)\n : null;\n}\n\n/** The calendar's base path without a trailing slash: `/calendar`, or '' at the root. */\nexport function normalizeBasePath(basePath: string | undefined): string {\n const trimmed = (basePath ?? '').replace(/\\/+$/, '');\n return trimmed === '' || trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\n/** What an address of the redesign says. */\nexport interface CalendarV2Location {\n /** The day the address names, when it names a real one. */\n date: DateValue | null;\n dialog: CalendarV2Dialog | null;\n eventId: string | null;\n}\n\n/** Reads the redesign's query parameters; anything that isn't a real value reads as absent. */\nexport function readCalendarV2Search(search: string | URLSearchParams): CalendarV2Location {\n const params = typeof search === 'string' ? new URLSearchParams(search) : search;\n const date = params.get(SEARCH_PARAMS.date);\n const dialog = params.get(SEARCH_PARAMS.dialog);\n const eventId = params.get(SEARCH_PARAMS.event)?.trim();\n return {\n date: isDateValue(date) ? date : null,\n dialog: isCalendarV2Dialog(dialog) ? dialog : null,\n eventId: eventId ? eventId : null,\n };\n}\n\n/**\n * A query string: `search` with `changes` applied (a null or undefined value removes the\n * parameter). Other parameters are kept, so a redirect does not drop what a link carried.\n */\nexport function withSearchParams(\n search: string | URLSearchParams,\n changes: Readonly<Record<string, string | null | undefined>>\n): string {\n const params = new URLSearchParams(search);\n for (const [name, value] of Object.entries(changes)) {\n if (value === null || value === undefined || value === '') params.delete(name);\n else params.set(name, value);\n }\n const query = params.toString();\n return query ? `?${query}` : '';\n}\n\n/** The path of a view under the calendar's base path: `/calendar/view/week`. */\nexport function viewPath(basePath: string, view: CalendarV2View): string {\n return `${normalizeBasePath(basePath)}/view/${view}`;\n}\n\n/** A full address of the redesign: a view, with the query parameters `changes` sets. */\nexport function calendarV2Href(\n basePath: string,\n view: CalendarV2View,\n changes: Readonly<Record<string, string | null | undefined>> = {},\n keep: string | URLSearchParams = ''\n): string {\n return `${viewPath(basePath, view)}${withSearchParams(keep, changes)}`;\n}\n"],"mappings":";;AAcA,IAAaA,IAA+C;CAAC;CAAO;CAAQ;CAAS;AAAM,GAE9EC,IAAmD;CAAC;CAAS;CAAS;AAAU,GAGhFC,IAA+B,QAG/BC,IAAkE;CAC7E,MAAM;CACN,UAAU;CACV,QAAQ;AACV,GAGaC,IAAkE;CAC7E,WAAW;CACX,eAAe;CACf,UAAU;AACZ,GAGaC,IAAgB;CAC3B,MAAM;CACN,QAAQ;CACR,OAAO;AACT,GAEMC,IAAmC,IAAI,IAAIN,CAAiB,GAC5DO,IAAqC,IAAI,IAAIN,CAAmB;AAEtE,SAAgBO,EAAiB,GAAyC;CACxE,OAAOF,EAAW,IAAIG,CAAK;AAC7B;AAEA,SAAgBC,EAAmB,GAA2C;CAC5E,OAAOH,EAAa,IAAIE,CAAK;AAC/B;AAMA,SAAgBE,EAAY,GAAwD;CAElF,OADIH,EAAiBI,CAAI,IAAUA,IAC5BA,KAAQ,OAAO,OAAOT,GAAuBS,CAAI,IACnDT,EAAsBS,MAAS,OAChC;AACN;AAGA,SAAgBC,EAAkB,GAAsC;CACtE,IAAMC,KAAWC,KAAY,GAAA,CAAI,QAAQ,QAAQ,EAAE;CACnD,OAAOD,MAAY,MAAMA,EAAQ,WAAW,GAAG,IAAIA,IAAU,IAAIA;AACnE;AAWA,SAAgBE,EAAqB,GAAsD;CACzF,IAAMC,IAAS,OAAOC,KAAW,WAAW,IAAI,gBAAgBA,CAAM,IAAIA,GACpEC,IAAOF,EAAO,IAAIZ,EAAc,IAAI,GACpCe,IAASH,EAAO,IAAIZ,EAAc,MAAM,GACxCgB,IAAUJ,EAAO,IAAIZ,EAAc,KAAK,CAAC,EAAE,KAAK;CACtD,OAAO;EACL,MAAMiB,EAAYH,CAAI,IAAIA,IAAO;EACjC,QAAQT,EAAmBU,CAAM,IAAIA,IAAS;EAC9C,SAASC,KAAoB;CAC/B;AACF;AAMA,SAAgBE,EACd,GACA,GACQ;CACR,IAAMN,IAAS,IAAI,gBAAgBC,CAAM;CACzC,KAAK,IAAM,CAACN,GAAMH,MAAU,OAAO,QAAQe,CAAO,GAChD,AAAIf,KAAU,QAA+BA,MAAU,KAAIQ,EAAO,OAAOL,CAAI,IACxEK,EAAO,IAAIL,GAAMH,CAAK;CAE7B,IAAMgB,IAAQR,EAAO,SAAS;CAC9B,OAAOQ,IAAQ,IAAIA,MAAU;AAC/B;AAGA,SAAgBC,EAAS,GAAkB,GAA8B;CACvE,OAAO,GAAGb,EAAkBE,CAAQ,EAAE,QAAQY;AAChD;AAGA,SAAgBC,EACd,GACA,GACA,IAA+D,CAAC,GAChE,IAAiC,IACzB;CACR,OAAO,GAAGF,EAASX,GAAUY,CAAI,IAAIJ,EAAiBM,GAAML,CAAO;AACrE"}
@@ -0,0 +1,54 @@
1
+ import { DateValue } from '@burdenoff/fe-libs/ui';
2
+ import { CalendarV2View } from '../types';
3
+ /** The settings the store writes to the account when they change here. */
4
+ export interface CalendarV2PrefsPatch {
5
+ hiddenCalendarIds?: string[];
6
+ runsLayer?: boolean;
7
+ }
8
+ export type CalendarV2PrefsWriter = (patch: CalendarV2PrefsPatch) => void;
9
+ interface CalendarV2Data {
10
+ view: CalendarV2View;
11
+ /** Null until the address has been read once. */
12
+ anchorDate: DateValue | null;
13
+ /** Sorted, without repeats. */
14
+ hiddenCalendarIds: readonly string[];
15
+ runsLayer: boolean;
16
+ search: string;
17
+ railOpen: boolean;
18
+ }
19
+ export interface CalendarV2State extends CalendarV2Data {
20
+ /** Mirrors the address. Only `CalendarRoutesV2` calls it. */
21
+ syncRoute: (view: CalendarV2View, anchorDate: DateValue) => void;
22
+ toggleCalendar: (calendarId: string) => void;
23
+ setCalendarHidden: (calendarId: string, hidden: boolean) => void;
24
+ setHiddenCalendars: (calendarIds: readonly string[]) => void;
25
+ showAllCalendars: () => void;
26
+ setRunsLayer: (on: boolean) => void;
27
+ setSearch: (query: string) => void;
28
+ setRailOpen: (open: boolean) => void;
29
+ toggleRail: () => void;
30
+ /** The account's settings (loaded, or merged with changes made while it loaded). */
31
+ hydrateFromPrefs: (prefs: {
32
+ hiddenCalendarIds: readonly string[];
33
+ runsLayer: boolean;
34
+ }) => void;
35
+ /** Connects the account writer; returns the disconnect. Only `CalendarRoutesV2` calls it. */
36
+ connectPrefsWriter: (writer: CalendarV2PrefsWriter) => () => void;
37
+ reset: () => void;
38
+ }
39
+ /** Ids sorted and without repeats or blanks, so equal sets compare equal. */
40
+ export declare function normalizeCalendarIds(ids: readonly string[]): string[];
41
+ export declare const useCalendarV2Store: import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CalendarV2State>, "setState" | "persist"> & {
42
+ setState(partial: CalendarV2State | Partial<CalendarV2State> | ((state: CalendarV2State) => CalendarV2State | Partial<CalendarV2State>), replace?: false | undefined): unknown;
43
+ setState(state: CalendarV2State | ((state: CalendarV2State) => CalendarV2State), replace: true): unknown;
44
+ persist: {
45
+ setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CalendarV2State, unknown, unknown>>) => void;
46
+ clearStorage: () => void;
47
+ rehydrate: () => Promise<void> | void;
48
+ hasHydrated: () => boolean;
49
+ onHydrate: (fn: (state: CalendarV2State) => void) => () => void;
50
+ onFinishHydration: (fn: (state: CalendarV2State) => void) => () => void;
51
+ getOptions: () => Partial<import('zustand/middleware').PersistOptions<CalendarV2State, unknown, unknown>>;
52
+ };
53
+ }>;
54
+ export {};
@@ -0,0 +1,78 @@
1
+ import { create as e } from "zustand";
2
+ import { persist as t } from "zustand/middleware";
3
+ import { createProfileScopedStorage as n } from "@burdenoff/fe-libs/shared/utils";
4
+ // src/v2/state/calendarV2Store.ts
5
+ var r = {
6
+ view: "week",
7
+ anchorDate: null,
8
+ hiddenCalendarIds: [],
9
+ runsLayer: !1,
10
+ search: "",
11
+ railOpen: !0
12
+ };
13
+ function i(e) {
14
+ return [...new Set(e.filter((e) => e.trim() !== ""))].sort();
15
+ }
16
+ function a(e, t) {
17
+ return e.length === t.length && e.every((e, n) => e === t[n]);
18
+ }
19
+ var o = null, s = e()(t((e, t) => {
20
+ let n = (n) => {
21
+ let r = i(n);
22
+ a(r, t().hiddenCalendarIds) || (e({ hiddenCalendarIds: r }), o?.({ hiddenCalendarIds: r }));
23
+ };
24
+ return {
25
+ ...r,
26
+ syncRoute: (n, r) => {
27
+ let i = t();
28
+ (i.view !== n || i.anchorDate !== r) && e({
29
+ view: n,
30
+ anchorDate: r
31
+ });
32
+ },
33
+ toggleCalendar: (e) => {
34
+ let r = t().hiddenCalendarIds;
35
+ n(r.includes(e) ? r.filter((t) => t !== e) : [...r, e]);
36
+ },
37
+ setCalendarHidden: (e, r) => {
38
+ let i = t().hiddenCalendarIds;
39
+ i.includes(e) !== r && n(r ? [...i, e] : i.filter((t) => t !== e));
40
+ },
41
+ setHiddenCalendars: (e) => n(e),
42
+ showAllCalendars: () => n([]),
43
+ setRunsLayer: (n) => {
44
+ t().runsLayer !== n && (e({ runsLayer: n }), o?.({ runsLayer: n }));
45
+ },
46
+ setSearch: (t) => e({ search: t }),
47
+ setRailOpen: (t) => e({ railOpen: t }),
48
+ toggleRail: () => e({ railOpen: !t().railOpen }),
49
+ hydrateFromPrefs: (n) => {
50
+ let r = i(n.hiddenCalendarIds), o = t();
51
+ a(r, o.hiddenCalendarIds) ? o.runsLayer !== n.runsLayer && e({ runsLayer: n.runsLayer }) : e({
52
+ hiddenCalendarIds: r,
53
+ runsLayer: n.runsLayer
54
+ });
55
+ },
56
+ connectPrefsWriter: (e) => (o = e, () => {
57
+ o === e && (o = null);
58
+ }),
59
+ reset: () => e({
60
+ ...r,
61
+ railOpen: t().railOpen
62
+ })
63
+ };
64
+ }, {
65
+ name: "burdenoff-calendar-v2-ui",
66
+ storage: n(),
67
+ partialize: (e) => ({ railOpen: e.railOpen }),
68
+ merge: (e, t) => {
69
+ let n = typeof e == "object" && e && "railOpen" in e ? e.railOpen : void 0;
70
+ return {
71
+ ...t,
72
+ railOpen: typeof n == "boolean" ? n : t.railOpen
73
+ };
74
+ }
75
+ }));
76
+ export { i as normalizeCalendarIds, s as useCalendarV2Store };
77
+
78
+ //# sourceMappingURL=calendarV2Store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarV2Store.js","names":["DEFAULTS","normalizeCalendarIds","ids","id","sameIds","a","b","index","prefsWriter","useCalendarV2Store","create","persist","writeHidden","next","get","set","state","view","anchorDate","hidden","calendarId","current","calendarIds","on","query","open","hiddenCalendarIds","prefs","writer","createProfileScopedStorage","railOpen","persisted"],"sources":["../../../src/v2/state/calendarV2Store.ts"],"sourcesContent":["/**\n * The redesigned calendar's shared state (BOFF-15698 A0): the view and its day, the hidden\n * calendars, the Workflow runs layer, the search and the rail.\n *\n * - `view` and `anchorDate` mirror the address (`view/<view>?date=`), which is the source of\n * truth: change them with `useCalendarV2Navigation`, never by setting them here.\n * `CalendarRoutesV2` keeps the mirror in step.\n * - `hiddenCalendarIds` and `runsLayer` are the person's settings (`calendar` in their account\n * preferences, B3). The actions here change them at once and write them to the account\n * through the writer `CalendarRoutesV2` connects; `hydrateFromPrefs` takes what the account\n * says without writing it back.\n * - `railOpen` is kept on this device (profile-scoped storage).\n * - `search` lives for the visit only.\n */\nimport { create } from 'zustand';\nimport { persist } from 'zustand/middleware';\nimport { createProfileScopedStorage } from '@burdenoff/fe-libs/shared/utils';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport type { CalendarV2View } from '../types';\n\n/** The settings the store writes to the account when they change here. */\nexport interface CalendarV2PrefsPatch {\n hiddenCalendarIds?: string[];\n runsLayer?: boolean;\n}\n\nexport type CalendarV2PrefsWriter = (patch: CalendarV2PrefsPatch) => void;\n\ninterface CalendarV2Data {\n view: CalendarV2View;\n /** Null until the address has been read once. */\n anchorDate: DateValue | null;\n /** Sorted, without repeats. */\n hiddenCalendarIds: readonly string[];\n runsLayer: boolean;\n search: string;\n railOpen: boolean;\n}\n\nexport interface CalendarV2State extends CalendarV2Data {\n /** Mirrors the address. Only `CalendarRoutesV2` calls it. */\n syncRoute: (view: CalendarV2View, anchorDate: DateValue) => void;\n toggleCalendar: (calendarId: string) => void;\n setCalendarHidden: (calendarId: string, hidden: boolean) => void;\n setHiddenCalendars: (calendarIds: readonly string[]) => void;\n showAllCalendars: () => void;\n setRunsLayer: (on: boolean) => void;\n setSearch: (query: string) => void;\n setRailOpen: (open: boolean) => void;\n toggleRail: () => void;\n /** The account's settings (loaded, or merged with changes made while it loaded). */\n hydrateFromPrefs: (prefs: { hiddenCalendarIds: readonly string[]; runsLayer: boolean }) => void;\n /** Connects the account writer; returns the disconnect. Only `CalendarRoutesV2` calls it. */\n connectPrefsWriter: (writer: CalendarV2PrefsWriter) => () => void;\n reset: () => void;\n}\n\nconst DEFAULTS: CalendarV2Data = {\n view: 'week',\n anchorDate: null,\n hiddenCalendarIds: [],\n runsLayer: false,\n search: '',\n railOpen: true,\n};\n\n/** Ids sorted and without repeats or blanks, so equal sets compare equal. */\nexport function normalizeCalendarIds(ids: readonly string[]): string[] {\n return [...new Set(ids.filter((id) => id.trim() !== ''))].sort();\n}\n\nfunction sameIds(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((id, index) => id === b[index]);\n}\n\nlet prefsWriter: CalendarV2PrefsWriter | null = null;\n\nexport const useCalendarV2Store = create<CalendarV2State>()(\n persist(\n (set, get) => {\n const writeHidden = (ids: readonly string[]) => {\n const next = normalizeCalendarIds(ids);\n if (sameIds(next, get().hiddenCalendarIds)) return;\n set({ hiddenCalendarIds: next });\n prefsWriter?.({ hiddenCalendarIds: next });\n };\n return {\n ...DEFAULTS,\n\n syncRoute: (view, anchorDate) => {\n const state = get();\n if (state.view !== view || state.anchorDate !== anchorDate) set({ view, anchorDate });\n },\n\n toggleCalendar: (calendarId) => {\n const hidden = get().hiddenCalendarIds;\n writeHidden(\n hidden.includes(calendarId)\n ? hidden.filter((id) => id !== calendarId)\n : [...hidden, calendarId]\n );\n },\n\n setCalendarHidden: (calendarId, hidden) => {\n const current = get().hiddenCalendarIds;\n if (current.includes(calendarId) === hidden) return;\n writeHidden(\n hidden ? [...current, calendarId] : current.filter((id) => id !== calendarId)\n );\n },\n\n setHiddenCalendars: (calendarIds) => writeHidden(calendarIds),\n\n showAllCalendars: () => writeHidden([]),\n\n setRunsLayer: (on) => {\n if (get().runsLayer === on) return;\n set({ runsLayer: on });\n prefsWriter?.({ runsLayer: on });\n },\n\n setSearch: (query) => set({ search: query }),\n\n setRailOpen: (open) => set({ railOpen: open }),\n\n toggleRail: () => set({ railOpen: !get().railOpen }),\n\n hydrateFromPrefs: (prefs) => {\n const hiddenCalendarIds = normalizeCalendarIds(prefs.hiddenCalendarIds);\n const state = get();\n if (sameIds(hiddenCalendarIds, state.hiddenCalendarIds)) {\n if (state.runsLayer !== prefs.runsLayer) set({ runsLayer: prefs.runsLayer });\n return;\n }\n set({ hiddenCalendarIds, runsLayer: prefs.runsLayer });\n },\n\n connectPrefsWriter: (writer) => {\n prefsWriter = writer;\n return () => {\n if (prefsWriter === writer) prefsWriter = null;\n };\n },\n\n reset: () => set({ ...DEFAULTS, railOpen: get().railOpen }),\n };\n },\n {\n name: 'burdenoff-calendar-v2-ui',\n storage: createProfileScopedStorage(),\n partialize: (state) => ({ railOpen: state.railOpen }),\n merge: (persisted, current) => {\n const railOpen =\n typeof persisted === 'object' && persisted !== null && 'railOpen' in persisted\n ? persisted.railOpen\n : undefined;\n return {\n ...current,\n railOpen: typeof railOpen === 'boolean' ? railOpen : current.railOpen,\n };\n },\n }\n )\n);\n"],"mappings":";;;;AAyDA,IAAMA,IAA2B;CAC/B,MAAM;CACN,YAAY;CACZ,mBAAmB,CAAC;CACpB,WAAW;CACX,QAAQ;CACR,UAAU;AACZ;AAGA,SAAgBC,EAAqB,GAAkC;CACrE,OAAO,CAAC,GAAG,IAAI,IAAIC,EAAI,QAAQ,MAAOC,EAAG,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK;AACjE;AAEA,SAASC,EAAQ,GAAsB,GAA+B;CACpE,OAAOC,EAAE,WAAWC,EAAE,UAAUD,EAAE,OAAO,GAAI,MAAUF,MAAOG,EAAEC,EAAM;AACxE;AAEA,IAAIC,IAA4C,MAEnCC,IAAqBC,EAAwB,CAAC,CACzDC,GACG,GAAK,MAAQ;CACZ,IAAMC,KAAe,MAA2B;EAC9C,IAAMC,IAAOZ,EAAqBC,CAAG;EACrC,AAAIE,EAAQS,GAAMC,EAAI,CAAC,CAAC,iBAAiB,MACzCC,EAAI,EAAE,mBAAmBF,EAAK,CAAC,GAC/BL,IAAc,EAAE,mBAAmBK,EAAK,CAAC;CAC3C;CACA,OAAO;EACL,GAAGb;EAEH,YAAY,GAAM,MAAe;GAC/B,IAAMgB,IAAQF,EAAI;GAClB,CAAIE,EAAM,SAASC,KAAQD,EAAM,eAAeE,MAAYH,EAAI;IAAE;IAAM;GAAW,CAAC;EACtF;EAEA,iBAAiB,MAAe;GAC9B,IAAMI,IAASL,EAAI,CAAC,CAAC;GACrB,EACEK,EAAO,SAASC,CAAU,IACtBD,EAAO,QAAQ,MAAOhB,MAAOiB,CAAU,IACvC,CAAC,GAAGD,GAAQC,CAAU,CAC5B;EACF;EAEA,oBAAoB,GAAY,MAAW;GACzC,IAAMC,IAAUP,EAAI,CAAC,CAAC;GACtB,AAAIO,EAAQ,SAASD,CAAU,MAAMD,KACrCP,EACEO,IAAS,CAAC,GAAGE,GAASD,CAAU,IAAIC,EAAQ,QAAQ,MAAOlB,MAAOiB,CAAU,CAC9E;EACF;EAEA,qBAAqB,MAAgBR,EAAYU,CAAW;EAE5D,wBAAwBV,EAAY,CAAC,CAAC;EAEtC,eAAe,MAAO;GACpB,AAAIE,EAAI,CAAC,CAAC,cAAcS,MACxBR,EAAI,EAAE,WAAWQ,EAAG,CAAC,GACrBf,IAAc,EAAE,WAAWe,EAAG,CAAC;EACjC;EAEA,YAAY,MAAUR,EAAI,EAAE,QAAQS,EAAM,CAAC;EAE3C,cAAc,MAAST,EAAI,EAAE,UAAUU,EAAK,CAAC;EAE7C,kBAAkBV,EAAI,EAAE,UAAU,CAACD,EAAI,CAAC,CAAC,SAAS,CAAC;EAEnD,mBAAmB,MAAU;GAC3B,IAAMY,IAAoBzB,EAAqB0B,EAAM,iBAAiB,GAChEX,IAAQF,EAAI;GAClB,AAAIV,EAAQsB,GAAmBV,EAAM,iBAAiB,IAChDA,EAAM,cAAcW,EAAM,aAAWZ,EAAI,EAAE,WAAWY,EAAM,UAAU,CAAC,IAG7EZ,EAAI;IAAE;IAAmB,WAAWY,EAAM;GAAU,CAAC;EACvD;EAEA,qBAAqB,OACnB,IAAcC,SACD;GACX,AAAIpB,MAAgBoB,MAAQ,IAAc;EAC5C;EAGF,aAAab,EAAI;GAAE,GAAGf;GAAU,UAAUc,EAAI,CAAC,CAAC;EAAS,CAAC;CAC5D;AACF,GACA;CACE,MAAM;CACN,SAASe,EAA2B;CACpC,aAAa,OAAW,EAAE,UAAUb,EAAM,SAAS;CACnD,QAAQ,GAAW,MAAY;EAC7B,IAAMc,IACJ,OAAOC,KAAc,YAAYA,KAAsB,cAAcA,IACjEA,EAAU,WACV,KAAA;EACN,OAAO;GACL,GAAGV;GACH,UAAU,OAAOS,KAAa,YAAYA,IAAWT,EAAQ;EAC/D;CACF;AACF,CACF,CACF"}
@@ -0,0 +1,25 @@
1
+ import { DateValue } from '@burdenoff/fe-libs/ui';
2
+ import { CalendarV2Dialog, CalendarV2View } from '../types';
3
+ export interface CalendarV2Navigation {
4
+ view: CalendarV2View;
5
+ /** The day the view is at: the address's day, else today in the calendar's zone. */
6
+ date: DateValue;
7
+ /** Today in the calendar's zone. */
8
+ today: DateValue;
9
+ dialog: CalendarV2Dialog | null;
10
+ eventId: string | null;
11
+ goTo: (target: {
12
+ view?: CalendarV2View;
13
+ date?: DateValue;
14
+ }, options?: {
15
+ replace?: boolean;
16
+ }) => void;
17
+ openDialog: (dialog: CalendarV2Dialog) => void;
18
+ closeDialog: () => void;
19
+ /** Opens an event's peek, on its day when given. */
20
+ openEvent: (eventId: string, date?: DateValue) => void;
21
+ closeEvent: () => void;
22
+ /** The address of a view at a day (today when left out). */
23
+ href: (view: CalendarV2View, date?: DateValue) => string;
24
+ }
25
+ export declare function useCalendarV2Navigation(): CalendarV2Navigation;
@@ -0,0 +1,52 @@
1
+ import { useCalendar as e } from "../../providers/CalendarProvider.js";
2
+ import { useCalendarTimeZone as t } from "../prefs/CalendarPrefsProvider.js";
3
+ import { SEARCH_PARAMS as n, calendarV2Href as r, isCalendarV2View as i, readCalendarV2Search as a, withSearchParams as o } from "../routes.js";
4
+ import { today as s } from "../time/calendarTime.js";
5
+ import { useCalendarV2Store as c } from "./calendarV2Store.js";
6
+ import { useCallback as l, useMemo as u } from "react";
7
+ import { useLocation as d, useNavigate as f, useParams as p } from "react-router";
8
+ // src/v2/state/useCalendarV2Navigation.ts
9
+ function m() {
10
+ let { basePath: m } = e(), h = f(), g = d(), { viewType: _ } = p(), v = c((e) => e.view), y = t(), b = s(y), x = i(_) ? _ : v, S = u(() => a(g.search), [g.search]), C = S.date ?? b, w = l((e) => e === b ? null : e, [b]), T = l((e, t = {}) => {
11
+ let i = e.view ?? x, a = e.date ?? C;
12
+ h(r(m, i, {
13
+ [n.date]: w(a),
14
+ [n.event]: null
15
+ }, g.search), { replace: t.replace ?? !1 });
16
+ }, [
17
+ m,
18
+ C,
19
+ w,
20
+ g.search,
21
+ h,
22
+ x
23
+ ]), E = l((e) => {
24
+ h({
25
+ pathname: g.pathname,
26
+ search: o(g.search, e)
27
+ }, { replace: !0 });
28
+ }, [
29
+ g.pathname,
30
+ g.search,
31
+ h
32
+ ]);
33
+ return {
34
+ view: x,
35
+ date: C,
36
+ today: b,
37
+ dialog: S.dialog,
38
+ eventId: S.eventId,
39
+ goTo: T,
40
+ openDialog: l((e) => E({ [n.dialog]: e }), [E]),
41
+ closeDialog: l(() => E({ [n.dialog]: null }), [E]),
42
+ openEvent: l((e, t) => E({
43
+ [n.event]: e,
44
+ ...t ? { [n.date]: w(t) } : {}
45
+ }), [w, E]),
46
+ closeEvent: l(() => E({ [n.event]: null }), [E]),
47
+ href: l((e, t) => r(m, e, { [n.date]: t ? w(t) : null }), [m, w])
48
+ };
49
+ }
50
+ export { m as useCalendarV2Navigation };
51
+
52
+ //# sourceMappingURL=useCalendarV2Navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCalendarV2Navigation.js","names":["useCalendarV2Navigation","useCalendar","navigate","useNavigate","location","useLocation","useParams","mirroredView","useCalendarV2Store","state","timeZone","useCalendarTimeZone","todayValue","today","view","isCalendarV2View","viewType","parsed","useMemo","readCalendarV2Search","date","dayParam","useCallback","day","goTo","nextView","target","nextDate","calendarV2Href","basePath","SEARCH_PARAMS","options","setParams","withSearchParams","changes","dialog","eventId"],"sources":["../../../src/v2/state/useCalendarV2Navigation.ts"],"sourcesContent":["/**\n * Where the redesigned calendar is, and how to move it (BOFF-15698 A0). The address is the\n * source of truth (`view/<view>?date=&dialog=&event=`, see `routes.ts`), so the back button,\n * bookmarks and shared links all work; the store only mirrors view and day.\n *\n * - `goTo` changes the view or the day and closes an open peek. The day is left out of the\n * address when it is today, so a saved link keeps opening on the current day.\n * - Dialogs and peeks replace the address instead of adding to the history.\n */\nimport { useCallback, useMemo } from 'react';\nimport { useLocation, useNavigate, useParams } from 'react-router';\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { useCalendarTimeZone } from '../prefs/CalendarPrefsProvider';\nimport {\n calendarV2Href,\n isCalendarV2View,\n readCalendarV2Search,\n SEARCH_PARAMS,\n withSearchParams,\n} from '../routes';\nimport { today } from '../time/calendarTime';\nimport type { CalendarV2Dialog, CalendarV2View } from '../types';\nimport { useCalendarV2Store } from './calendarV2Store';\n\nexport interface CalendarV2Navigation {\n view: CalendarV2View;\n /** The day the view is at: the address's day, else today in the calendar's zone. */\n date: DateValue;\n /** Today in the calendar's zone. */\n today: DateValue;\n dialog: CalendarV2Dialog | null;\n eventId: string | null;\n goTo: (\n target: { view?: CalendarV2View; date?: DateValue },\n options?: { replace?: boolean }\n ) => void;\n openDialog: (dialog: CalendarV2Dialog) => void;\n closeDialog: () => void;\n /** Opens an event's peek, on its day when given. */\n openEvent: (eventId: string, date?: DateValue) => void;\n closeEvent: () => void;\n /** The address of a view at a day (today when left out). */\n href: (view: CalendarV2View, date?: DateValue) => string;\n}\n\nexport function useCalendarV2Navigation(): CalendarV2Navigation {\n const { basePath } = useCalendar();\n const navigate = useNavigate();\n const location = useLocation();\n const { viewType } = useParams();\n const mirroredView = useCalendarV2Store((state) => state.view);\n const timeZone = useCalendarTimeZone();\n const todayValue = today(timeZone);\n const view = isCalendarV2View(viewType) ? viewType : mirroredView;\n const parsed = useMemo(() => readCalendarV2Search(location.search), [location.search]);\n const date = parsed.date ?? todayValue;\n\n const dayParam = useCallback((day: DateValue) => (day === todayValue ? null : day), [todayValue]);\n\n const goTo = useCallback<CalendarV2Navigation['goTo']>(\n (target, options = {}) => {\n const nextView = target.view ?? view;\n const nextDate = target.date ?? date;\n navigate(\n calendarV2Href(\n basePath,\n nextView,\n { [SEARCH_PARAMS.date]: dayParam(nextDate), [SEARCH_PARAMS.event]: null },\n location.search\n ),\n { replace: options.replace ?? false }\n );\n },\n [basePath, date, dayParam, location.search, navigate, view]\n );\n\n const setParams = useCallback(\n (changes: Readonly<Record<string, string | null>>) => {\n navigate(\n { pathname: location.pathname, search: withSearchParams(location.search, changes) },\n { replace: true }\n );\n },\n [location.pathname, location.search, navigate]\n );\n\n return {\n view,\n date,\n today: todayValue,\n dialog: parsed.dialog,\n eventId: parsed.eventId,\n goTo,\n openDialog: useCallback(\n (dialog: CalendarV2Dialog) => setParams({ [SEARCH_PARAMS.dialog]: dialog }),\n [setParams]\n ),\n closeDialog: useCallback(() => setParams({ [SEARCH_PARAMS.dialog]: null }), [setParams]),\n openEvent: useCallback(\n (eventId: string, day?: DateValue) =>\n setParams({\n [SEARCH_PARAMS.event]: eventId,\n ...(day ? { [SEARCH_PARAMS.date]: dayParam(day) } : {}),\n }),\n [dayParam, setParams]\n ),\n closeEvent: useCallback(() => setParams({ [SEARCH_PARAMS.event]: null }), [setParams]),\n href: useCallback(\n (target: CalendarV2View, day?: DateValue) =>\n calendarV2Href(basePath, target, { [SEARCH_PARAMS.date]: day ? dayParam(day) : null }),\n [basePath, dayParam]\n ),\n };\n}\n"],"mappings":";;;;;;;;AA8CA,SAAgBA,IAAgD;CAC9D,IAAM,EAAE,gBAAaC,EAAY,GAC3BC,IAAWC,EAAY,GACvBC,IAAWC,EAAY,GACvB,EAAE,gBAAaC,EAAU,GACzBC,IAAeC,GAAoB,MAAUC,EAAM,IAAI,GACvDC,IAAWC,EAAoB,GAC/BC,IAAaC,EAAMH,CAAQ,GAC3BI,IAAOC,EAAiBC,CAAQ,IAAIA,IAAWT,GAC/CU,IAASC,QAAcC,EAAqBf,EAAS,MAAM,GAAG,CAACA,EAAS,MAAM,CAAC,GAC/EgB,IAAOH,EAAO,QAAQL,GAEtBS,IAAWC,GAAa,MAAoBC,MAAQX,IAAa,OAAOW,GAAM,CAACX,CAAU,CAAC,GAE1FY,IAAOF,GACV,GAAQ,IAAU,CAAC,MAAM;EACxB,IAAMG,IAAWC,EAAO,QAAQZ,GAC1Ba,IAAWD,EAAO,QAAQN;EAChC,EACEQ,EACEC,GACAJ,GACA;IAAGK,EAAc,OAAOT,EAASM,CAAQ;IAAIG,EAAc,QAAQ;EAAK,GACxE1B,EAAS,MACX,GACA,EAAE,SAAS2B,EAAQ,WAAW,GAAM,CACtC;CACF,GACA;EAACF;EAAUT;EAAMC;EAAUjB,EAAS;EAAQF;EAAUY;CAAI,CAC5D,GAEMkB,IAAYV,GACf,MAAqD;EACpD,EACE;GAAE,UAAUlB,EAAS;GAAU,QAAQ6B,EAAiB7B,EAAS,QAAQ8B,CAAO;EAAE,GAClF,EAAE,SAAS,GAAK,CAClB;CACF,GACA;EAAC9B,EAAS;EAAUA,EAAS;EAAQF;CAAQ,CAC/C;CAEA,OAAO;EACL;EACA;EACA,OAAOU;EACP,QAAQK,EAAO;EACf,SAASA,EAAO;EAChB;EACA,YAAYK,GACT,MAA6BU,EAAU,GAAGF,EAAc,SAASK,EAAO,CAAC,GAC1E,CAACH,CAAS,CACZ;EACA,aAAaV,QAAkBU,EAAU,GAAGF,EAAc,SAAS,KAAK,CAAC,GAAG,CAACE,CAAS,CAAC;EACvF,WAAWV,GACR,GAAiB,MAChBU,EAAU;IACPF,EAAc,QAAQM;GACvB,GAAIb,IAAM,GAAGO,EAAc,OAAOT,EAASE,CAAG,EAAE,IAAI,CAAC;EACvD,CAAC,GACH,CAACF,GAAUW,CAAS,CACtB;EACA,YAAYV,QAAkBU,EAAU,GAAGF,EAAc,QAAQ,KAAK,CAAC,GAAG,CAACE,CAAS,CAAC;EACrF,MAAMV,GACH,GAAwB,MACvBM,EAAeC,GAAUH,GAAQ,GAAGI,EAAc,OAAOP,IAAMF,EAASE,CAAG,IAAI,KAAK,CAAC,GACvF,CAACM,GAAUR,CAAQ,CACrB;CACF;AACF"}
@@ -0,0 +1 @@
1
+ export declare function useCalendarV2PrefsBridge(): void;
@@ -0,0 +1,28 @@
1
+ import { useCalendarsV2 as e } from "../data/useCalendarsV2.js";
2
+ import { hiddenFromVisible as t } from "../prefs/calendarPrefs.js";
3
+ import { useCalendarPrefs as n } from "../prefs/CalendarPrefsProvider.js";
4
+ import { useCalendarV2Store as r } from "./calendarV2Store.js";
5
+ import { useEffect as i, useRef as a } from "react";
6
+ // src/v2/state/useCalendarV2PrefsBridge.ts
7
+ function o() {
8
+ let { prefs: o, revision: s, update: c, legacyVisibleCalendarIds: l, clearLegacyVisibleCalendarIds: u } = n(), d = a(o);
9
+ i(() => {
10
+ d.current = o;
11
+ }, [o]), i(() => {
12
+ r.getState().hydrateFromPrefs(d.current);
13
+ }, [s]), i(() => r.getState().connectPrefsWriter((e) => c(e)), [c]);
14
+ let f = e({ skip: l === null });
15
+ i(() => {
16
+ if (l === null || f.status !== "ready") return;
17
+ let e = t(l, f.calendars.map((e) => e.id));
18
+ e.length > 0 && r.getState().setHiddenCalendars(e), u();
19
+ }, [
20
+ f.calendars,
21
+ f.status,
22
+ u,
23
+ l
24
+ ]);
25
+ }
26
+ export { o as useCalendarV2PrefsBridge };
27
+
28
+ //# sourceMappingURL=useCalendarV2PrefsBridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCalendarV2PrefsBridge.js","names":["useCalendarV2PrefsBridge","useCalendarPrefs","prefsRef","useRef","prefs","useEffect","revision","useCalendarV2Store","update","patch","calendars","useCalendarsV2","legacyVisibleCalendarIds","hidden","hiddenFromVisible","calendar","clearLegacyVisibleCalendarIds"],"sources":["../../../src/v2/state/useCalendarV2PrefsBridge.ts"],"sourcesContent":["/**\n * Keeps the store's hidden calendars and runs layer in step with the person's account settings\n * (BOFF-15698 A0). Mounted once, by `CalendarRoutesV2`.\n *\n * - The store takes the settings when they arrive from the account (`revision`), never on its\n * own changes coming back: copying those back while a quick second change is still on its way\n * would undo it.\n * - The store's changes are written to the account through the connected writer.\n * - The first visit of an account with no calendar settings turns today's ticked calendars\n * into hidden ones, once the calendar list is known.\n */\nimport { useEffect, useRef } from 'react';\nimport { useCalendarsV2 } from '../data/useCalendarsV2';\nimport { hiddenFromVisible } from '../prefs/calendarPrefs';\nimport { useCalendarPrefs } from '../prefs/CalendarPrefsProvider';\nimport { useCalendarV2Store } from './calendarV2Store';\n\nexport function useCalendarV2PrefsBridge(): void {\n const { prefs, revision, update, legacyVisibleCalendarIds, clearLegacyVisibleCalendarIds } =\n useCalendarPrefs();\n const prefsRef = useRef(prefs);\n useEffect(() => {\n prefsRef.current = prefs;\n }, [prefs]);\n\n useEffect(() => {\n useCalendarV2Store.getState().hydrateFromPrefs(prefsRef.current);\n }, [revision]);\n\n useEffect(\n () => useCalendarV2Store.getState().connectPrefsWriter((patch) => update(patch)),\n [update]\n );\n\n const calendars = useCalendarsV2({ skip: legacyVisibleCalendarIds === null });\n useEffect(() => {\n if (legacyVisibleCalendarIds === null || calendars.status !== 'ready') return;\n const hidden = hiddenFromVisible(\n legacyVisibleCalendarIds,\n calendars.calendars.map((calendar) => calendar.id)\n );\n if (hidden.length > 0) useCalendarV2Store.getState().setHiddenCalendars(hidden);\n clearLegacyVisibleCalendarIds();\n }, [\n calendars.calendars,\n calendars.status,\n clearLegacyVisibleCalendarIds,\n legacyVisibleCalendarIds,\n ]);\n}\n"],"mappings":";;;;;;AAiBA,SAAgBA,IAAiC;CAC/C,IAAM,EAAE,UAAO,aAAU,WAAQ,6BAA0B,qCACzDC,EAAiB,GACbC,IAAWC,EAAOC,CAAK;CAS7B,AARAC,QAAgB;EACd,EAAS,UAAUD;CACrB,GAAG,CAACA,CAAK,CAAC,GAEVC,QAAgB;EACd,EAAmB,SAAS,CAAC,CAAC,iBAAiBH,EAAS,OAAO;CACjE,GAAG,CAACI,CAAQ,CAAC,GAEbD,QACQE,EAAmB,SAAS,CAAC,CAAC,oBAAoB,MAAUC,EAAOC,CAAK,CAAC,GAC/E,CAACD,CAAM,CACT;CAEA,IAAME,IAAYC,EAAe,EAAE,MAAMC,MAA6B,KAAK,CAAC;CAC5E,QAAgB;EACd,IAAIA,MAA6B,QAAQF,EAAU,WAAW,SAAS;EACvE,IAAMG,IAASC,EACbF,GACAF,EAAU,UAAU,KAAK,MAAaK,EAAS,EAAE,CACnD;EAEA,AADIF,EAAO,SAAS,KAAGN,EAAmB,SAAS,CAAC,CAAC,mBAAmBM,CAAM,GAC9EG,EAA8B;CAChC,GAAG;EACDN,EAAU;EACVA,EAAU;EACVM;EACAJ;CACF,CAAC;AACH"}
@@ -0,0 +1,115 @@
1
+ import { DateValue, WeekStart } from '@burdenoff/fe-libs/ui';
2
+ import { CalendarV2View, TimedSegment } from '../types';
3
+ export declare const MINUTES_PER_DAY = 1440;
4
+ /** The list view shows two weeks from its day. */
5
+ export declare const LIST_VIEW_DAYS = 14;
6
+ /** On a phone the week view shows three days from its day. */
7
+ export declare const COMPACT_WEEK_DAYS = 3;
8
+ /** The week starts a person can pick, as fe-libs' pickers number them. */
9
+ export declare const WEEK_STARTS: readonly WeekStart[];
10
+ export declare function isWeekStart(value: unknown): value is WeekStart;
11
+ /**
12
+ * The zone the calendar shows: the person's choice when it names a real zone (as today's IANA
13
+ * name: Asia/Kolkata for Asia/Calcutta), else this device's.
14
+ */
15
+ export declare function resolveTimeZone(preferred?: string | null): string;
16
+ /** Today in `timeZone`. */
17
+ export declare function today(timeZone: string, now?: Date): DateValue;
18
+ /** The day of the week, 0 Sunday to 6 Saturday. */
19
+ export declare function weekdayOf(date: DateValue): number;
20
+ export declare function isWeekendDay(date: DateValue): boolean;
21
+ /** The days from `first` to `last`, both included; none when `last` is before `first`. */
22
+ export declare function daysBetween(first: DateValue, last: DateValue): DateValue[];
23
+ /** Whole days from `a` to `b` (negative when `b` is earlier). */
24
+ export declare function dayDifference(a: DateValue, b: DateValue): number;
25
+ /**
26
+ * The instant a wall-clock time on a day stands for in `timeZone`. `minutes` count from the
27
+ * day's midnight and may run past it (1500 is 01:00 the next day). A skipped time moves
28
+ * forward by the gap; a repeated time is the first of the two.
29
+ */
30
+ export declare function zonedTimeToInstant(date: DateValue, minutes: number, timeZone: string): Date;
31
+ /** The day, and the minutes after its midnight, that an instant shows on a clock in `timeZone`. */
32
+ export declare function instantToZoned(instant: Date, timeZone: string): {
33
+ date: DateValue;
34
+ minutes: number;
35
+ };
36
+ /** The first instant of a day in `timeZone`: its midnight, or the end of a gap at midnight. */
37
+ export declare function startOfDayInZone(date: DateValue, timeZone: string): Date;
38
+ /** How long a day lasts in `timeZone`, in minutes: 1440, or 1380 and 1500 when clocks change. */
39
+ export declare function dayLengthMinutes(date: DateValue, timeZone: string): number;
40
+ /** The instants days `first` to `last` (both included) cover in `timeZone`: `[from, to)`. */
41
+ export declare function daysToInstants(first: DateValue, last: DateValue, timeZone: string): {
42
+ from: Date;
43
+ to: Date;
44
+ };
45
+ export interface ViewDaysOptions {
46
+ weekStart: WeekStart;
47
+ /** The week view without Saturday and Sunday when false. Default true. */
48
+ showWeekends?: boolean;
49
+ /** A phone: the week view shows three days from its day. */
50
+ compact?: boolean;
51
+ }
52
+ /**
53
+ * The days a view shows for its day `anchor`:
54
+ * - day: that day;
55
+ * - week: its week from the person's week start (Monday, Sunday or Saturday), without the
56
+ * weekend when it is hidden; on a phone, three days from `anchor`;
57
+ * - month: whole weeks from the week of the 1st to the week of the last day (4 to 6 rows);
58
+ * - list: two weeks from `anchor`.
59
+ */
60
+ export declare function viewDays(view: CalendarV2View, anchor: DateValue, options: ViewDaysOptions): DateValue[];
61
+ /** The month grid of the month `anchor` is in: whole weeks, from the person's week start. */
62
+ export declare function monthGridDays(anchor: DateValue, weekStart: WeekStart): DateValue[];
63
+ /**
64
+ * The day a view moves to for "previous" (-1) and "next" (1): a day, a week (three days on a
65
+ * phone), a month (the same day of the month, or its last day), or a week of the list.
66
+ */
67
+ export declare function stepAnchor(view: CalendarV2View, anchor: DateValue, direction: -1 | 1, options?: {
68
+ compact?: boolean;
69
+ }): DateValue;
70
+ /**
71
+ * What a view needs to load: its days, and the instants to ask the API for. The range runs a
72
+ * day past either end, so an all-day event stored at a UTC midnight is still found when the
73
+ * calendar's zone is far from UTC; the views place events by day and skip days they don't show.
74
+ */
75
+ export declare function viewQueryRange(view: CalendarV2View, anchor: DateValue, options: ViewDaysOptions, timeZone: string): {
76
+ days: DateValue[];
77
+ from: Date;
78
+ to: Date;
79
+ };
80
+ /**
81
+ * A timed event's pieces, one per day it touches between `first` and `last` (both included),
82
+ * on the clock in `timeZone`. An event that ends at midnight ends that day at 24:00 (1440), with
83
+ * no empty piece on the next day. Where the clocks go back and the end reads earlier than the
84
+ * start on the same day, or the same, the piece keeps the event's real length.
85
+ */
86
+ export declare function timedSegments(start: Date, end: Date, timeZone: string, first: DateValue, last: DateValue): TimedSegment[];
87
+ /**
88
+ * The days an all-day event or block covers, both included, the same wherever it is read.
89
+ *
90
+ * All-day times are stored in two ways: at UTC midnights (links, imports, other apps, the API's
91
+ * own rule) and, from today's event form, at midnight where the person who made it was. So the
92
+ * day is read in UTC when the start is a UTC midnight, else in the event's own zone when the
93
+ * start is a midnight there, else in `viewerTimeZone`. The end is exclusive (the next midnight)
94
+ * or the last moment of the last day; an end at or before the start is a one-day event.
95
+ */
96
+ export declare function allDayDays(start: Date, end: Date, options: {
97
+ eventTimeZone?: string | null;
98
+ viewerTimeZone: string;
99
+ }): {
100
+ start: DateValue;
101
+ end: DateValue;
102
+ };
103
+ /**
104
+ * The first and last day an event touches in `timeZone`: its days for an all-day event, else
105
+ * the days of its start and of the moment before its end.
106
+ */
107
+ export declare function eventDays(event: {
108
+ start: Date;
109
+ end: Date;
110
+ allDay: boolean;
111
+ timeZone?: string | null;
112
+ }, timeZone: string): {
113
+ start: DateValue;
114
+ end: DateValue;
115
+ };
@@ -0,0 +1,59 @@
1
+ import { canonicalTimeZone as e, dateValueInZone as t, getLocalTimeZone as n, timeZoneOffsetMinutes as r, todayDateValue as i } from "@burdenoff/fe-libs/ui";
2
+ // src/v2/time/calendarTime.ts
3
+ var a = 6e4, o = 864e5;
4
+ function s(e) {
5
+ return e === 0 || e === 1 || e === 6;
6
+ }
7
+ function c(t) {
8
+ return e(t) ?? n();
9
+ }
10
+ function l(e, t = /* @__PURE__ */ new Date()) {
11
+ return i(e, t);
12
+ }
13
+ function u(e) {
14
+ return (/* @__PURE__ */ new Date(Math.floor(e / o) * o)).toISOString().slice(0, 10);
15
+ }
16
+ function d(e, t) {
17
+ return r(e, new Date(t)) * a;
18
+ }
19
+ function f(e, t) {
20
+ let n = e.getTime() + d(t, e.getTime()), r = Math.floor(n / o) * o;
21
+ return {
22
+ date: u(n),
23
+ minutes: Math.floor((n - r) / a)
24
+ };
25
+ }
26
+ function p(e, t) {
27
+ return f(e, t).minutes === 0;
28
+ }
29
+ function m(n, r, i) {
30
+ let a = e(i.eventTimeZone), s = n.getTime() % o === 0 ? "UTC" : a && p(n, a) ? a : i.viewerTimeZone, c = t(n, s);
31
+ if (r.getTime() <= n.getTime()) return {
32
+ start: c,
33
+ end: c
34
+ };
35
+ let l = t(/* @__PURE__ */ new Date(r.getTime() - 1), s);
36
+ return {
37
+ start: c,
38
+ end: l < c ? c : l
39
+ };
40
+ }
41
+ function h(e, n) {
42
+ if (e.allDay) return m(e.start, e.end, {
43
+ eventTimeZone: e.timeZone,
44
+ viewerTimeZone: n
45
+ });
46
+ let r = t(e.start, n);
47
+ if (e.end.getTime() <= e.start.getTime()) return {
48
+ start: r,
49
+ end: r
50
+ };
51
+ let i = t(/* @__PURE__ */ new Date(e.end.getTime() - 1), n);
52
+ return {
53
+ start: r,
54
+ end: i < r ? r : i
55
+ };
56
+ }
57
+ export { m as allDayDays, h as eventDays, f as instantToZoned, s as isWeekStart, c as resolveTimeZone, l as today };
58
+
59
+ //# sourceMappingURL=calendarTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarTime.js","names":["MINUTE_MS","DAY_MS","isWeekStart","value","resolveTimeZone","canonicalTimeZone","preferred","getLocalTimeZone","today","todayDateValue","timeZone","now","dateOfWall","wall","offsetMs","timeZoneOffsetMinutes","instant","instantToZoned","midnight","isMidnightIn","allDayDays","eventZone","options","zone","start","first","dateValueInZone","end","lastDay","eventDays","event"],"sources":["../../../src/v2/time/calendarTime.ts"],"sourcesContent":["/**\n * The redesigned calendar's time maths (BOFF-15698 A0): which days a view shows, and where\n * an instant falls on the clock of an IANA time zone, correct on the days the clocks change.\n *\n * Built on fe-libs' calendar helpers (`@burdenoff/fe-libs/ui`): a day is a floating\n * `YYYY-MM-DD` (`DateValue`) whose arithmetic runs on UTC midnights, so adding days never\n * skips or repeats one; a zone's offset at an instant comes from `Intl`\n * (`timeZoneOffsetMinutes`). Nothing here assumes a fixed offset.\n *\n * - A wall-clock time the clocks skip (01:30 in London on 29 March 2026) moves forward by the\n * gap (02:30 BST); one that happens twice (01:30 on 25 October 2026) is the first of the\n * two. That is RFC 5545's rule and Temporal's \"compatible\" one.\n * - A day lasts 23 or 25 hours where the clocks change; the grid stays a 24-hour clock face,\n * so an event is placed by its wall-clock minutes (`timedSegments`).\n * - All-day events and blocks are floating days (`allDayDays`): the same days wherever they\n * are read.\n */\nimport {\n addDays,\n addMonths,\n canonicalTimeZone,\n dateValueInZone,\n endOfWeek,\n getLocalTimeZone,\n monthOf,\n parseDateValue,\n startOfWeek,\n timeZoneOffsetMinutes,\n todayDateValue,\n type DateValue,\n type WeekStart,\n} from '@burdenoff/fe-libs/ui';\nimport type { CalendarV2View, TimedSegment } from '../types';\n\nexport const MINUTES_PER_DAY = 1440;\n/** The list view shows two weeks from its day. */\nexport const LIST_VIEW_DAYS = 14;\n/** On a phone the week view shows three days from its day. */\nexport const COMPACT_WEEK_DAYS = 3;\n\nconst MINUTE_MS = 60_000;\nconst DAY_MS = 86_400_000;\n\n/** The week starts a person can pick, as fe-libs' pickers number them. */\nexport const WEEK_STARTS: readonly WeekStart[] = [1, 0, 6];\n\nexport function isWeekStart(value: unknown): value is WeekStart {\n return value === 0 || value === 1 || value === 6;\n}\n\n/**\n * The zone the calendar shows: the person's choice when it names a real zone (as today's IANA\n * name: Asia/Kolkata for Asia/Calcutta), else this device's.\n */\nexport function resolveTimeZone(preferred?: string | null): string {\n return canonicalTimeZone(preferred) ?? getLocalTimeZone();\n}\n\n/** Today in `timeZone`. */\nexport function today(timeZone: string, now: Date = new Date()): DateValue {\n return todayDateValue(timeZone, now);\n}\n\nfunction partsOf(date: DateValue): { year: number; month: number; day: number } {\n const parts = parseDateValue(date);\n if (!parts) throw new RangeError(`Not a calendar day: ${date}`);\n return parts;\n}\n\n/** The UTC midnight of a day: its wall clock read as if it were UTC. */\nfunction wallMidnight(date: DateValue): number {\n const { year, month, day } = partsOf(date);\n return Date.UTC(year, month - 1, day);\n}\n\n/** The day a \"wall clock as UTC\" millisecond count falls on. */\nfunction dateOfWall(wall: number): DateValue {\n return new Date(Math.floor(wall / DAY_MS) * DAY_MS).toISOString().slice(0, 10);\n}\n\nfunction offsetMs(timeZone: string, instant: number): number {\n return timeZoneOffsetMinutes(timeZone, new Date(instant)) * MINUTE_MS;\n}\n\n/** The day of the week, 0 Sunday to 6 Saturday. */\nexport function weekdayOf(date: DateValue): number {\n return new Date(wallMidnight(date)).getUTCDay();\n}\n\nexport function isWeekendDay(date: DateValue): boolean {\n const weekday = weekdayOf(date);\n return weekday === 0 || weekday === 6;\n}\n\n/** The days from `first` to `last`, both included; none when `last` is before `first`. */\nexport function daysBetween(first: DateValue, last: DateValue): DateValue[] {\n const days: DateValue[] = [];\n for (let day = first; day <= last; day = addDays(day, 1)) days.push(day);\n return days;\n}\n\n/** Whole days from `a` to `b` (negative when `b` is earlier). */\nexport function dayDifference(a: DateValue, b: DateValue): number {\n return Math.round((wallMidnight(b) - wallMidnight(a)) / DAY_MS);\n}\n\n/**\n * The instant a wall-clock time on a day stands for in `timeZone`. `minutes` count from the\n * day's midnight and may run past it (1500 is 01:00 the next day). A skipped time moves\n * forward by the gap; a repeated time is the first of the two.\n */\nexport function zonedTimeToInstant(date: DateValue, minutes: number, timeZone: string): Date {\n const wall = wallMidnight(date) + Math.round(minutes * MINUTE_MS);\n // The offsets in force a day either side: a time zone changes its offset at most once there.\n const before = offsetMs(timeZone, wall - DAY_MS);\n const after = offsetMs(timeZone, wall + DAY_MS);\n const candidates = (before === after ? [before] : [before, after])\n .map((offset) => wall - offset)\n .sort((a, b) => a - b);\n for (const instant of candidates) {\n // The clock reads `wall` at this instant: a real time (the earlier one when it repeats).\n if (offsetMs(timeZone, instant) === wall - instant) return new Date(instant);\n }\n // Skipped by the clocks: read it with the offset before the change, which lands after the gap.\n return new Date(wall - before);\n}\n\n/** The day, and the minutes after its midnight, that an instant shows on a clock in `timeZone`. */\nexport function instantToZoned(\n instant: Date,\n timeZone: string\n): { date: DateValue; minutes: number } {\n const wall = instant.getTime() + offsetMs(timeZone, instant.getTime());\n const midnight = Math.floor(wall / DAY_MS) * DAY_MS;\n return { date: dateOfWall(wall), minutes: Math.floor((wall - midnight) / MINUTE_MS) };\n}\n\n/** The first instant of a day in `timeZone`: its midnight, or the end of a gap at midnight. */\nexport function startOfDayInZone(date: DateValue, timeZone: string): Date {\n return zonedTimeToInstant(date, 0, timeZone);\n}\n\n/** How long a day lasts in `timeZone`, in minutes: 1440, or 1380 and 1500 when clocks change. */\nexport function dayLengthMinutes(date: DateValue, timeZone: string): number {\n const start = startOfDayInZone(date, timeZone).getTime();\n const next = startOfDayInZone(addDays(date, 1), timeZone).getTime();\n return Math.round((next - start) / MINUTE_MS);\n}\n\n/** The instants days `first` to `last` (both included) cover in `timeZone`: `[from, to)`. */\nexport function daysToInstants(\n first: DateValue,\n last: DateValue,\n timeZone: string\n): { from: Date; to: Date } {\n return {\n from: startOfDayInZone(first, timeZone),\n to: startOfDayInZone(addDays(last, 1), timeZone),\n };\n}\n\nexport interface ViewDaysOptions {\n weekStart: WeekStart;\n /** The week view without Saturday and Sunday when false. Default true. */\n showWeekends?: boolean;\n /** A phone: the week view shows three days from its day. */\n compact?: boolean;\n}\n\n/**\n * The days a view shows for its day `anchor`:\n * - day: that day;\n * - week: its week from the person's week start (Monday, Sunday or Saturday), without the\n * weekend when it is hidden; on a phone, three days from `anchor`;\n * - month: whole weeks from the week of the 1st to the week of the last day (4 to 6 rows);\n * - list: two weeks from `anchor`.\n */\nexport function viewDays(\n view: CalendarV2View,\n anchor: DateValue,\n options: ViewDaysOptions\n): DateValue[] {\n switch (view) {\n case 'day':\n return [anchor];\n case 'week': {\n if (options.compact) return daysBetween(anchor, addDays(anchor, COMPACT_WEEK_DAYS - 1));\n const week = daysBetween(\n startOfWeek(anchor, options.weekStart),\n endOfWeek(anchor, options.weekStart)\n );\n return options.showWeekends === false ? week.filter((day) => !isWeekendDay(day)) : week;\n }\n case 'month':\n return monthGridDays(anchor, options.weekStart);\n case 'list':\n return daysBetween(anchor, addDays(anchor, LIST_VIEW_DAYS - 1));\n }\n}\n\n/** The month grid of the month `anchor` is in: whole weeks, from the person's week start. */\nexport function monthGridDays(anchor: DateValue, weekStart: WeekStart): DateValue[] {\n const first = `${monthOf(anchor)}-01`;\n const last = addDays(addMonths(first, 1), -1);\n return daysBetween(startOfWeek(first, weekStart), endOfWeek(last, weekStart));\n}\n\n/**\n * The day a view moves to for \"previous\" (-1) and \"next\" (1): a day, a week (three days on a\n * phone), a month (the same day of the month, or its last day), or a week of the list.\n */\nexport function stepAnchor(\n view: CalendarV2View,\n anchor: DateValue,\n direction: -1 | 1,\n options: { compact?: boolean } = {}\n): DateValue {\n switch (view) {\n case 'day':\n return addDays(anchor, direction);\n case 'week':\n return addDays(anchor, direction * (options.compact ? COMPACT_WEEK_DAYS : 7));\n case 'month':\n return addMonths(anchor, direction);\n case 'list':\n return addDays(anchor, direction * 7);\n }\n}\n\n/**\n * What a view needs to load: its days, and the instants to ask the API for. The range runs a\n * day past either end, so an all-day event stored at a UTC midnight is still found when the\n * calendar's zone is far from UTC; the views place events by day and skip days they don't show.\n */\nexport function viewQueryRange(\n view: CalendarV2View,\n anchor: DateValue,\n options: ViewDaysOptions,\n timeZone: string\n): { days: DateValue[]; from: Date; to: Date } {\n const days = viewDays(view, anchor, options);\n const first = days[0] ?? anchor;\n const last = days[days.length - 1] ?? anchor;\n const { from, to } = daysToInstants(addDays(first, -1), addDays(last, 1), timeZone);\n return { days, from, to };\n}\n\n/**\n * A timed event's pieces, one per day it touches between `first` and `last` (both included),\n * on the clock in `timeZone`. An event that ends at midnight ends that day at 24:00 (1440), with\n * no empty piece on the next day. Where the clocks go back and the end reads earlier than the\n * start on the same day, or the same, the piece keeps the event's real length.\n */\nexport function timedSegments(\n start: Date,\n end: Date,\n timeZone: string,\n first: DateValue,\n last: DateValue\n): TimedSegment[] {\n const startMs = start.getTime();\n const endMs = Math.max(end.getTime(), startMs);\n const from = instantToZoned(start, timeZone);\n const to = instantToZoned(new Date(endMs), timeZone);\n let lastDay = to.date;\n let lastMinute = to.minutes;\n if (lastMinute === 0 && endMs > startMs && lastDay > from.date) {\n lastDay = addDays(lastDay, -1);\n lastMinute = MINUTES_PER_DAY;\n }\n const segments: TimedSegment[] = [];\n const firstShown = from.date > first ? from.date : first;\n const lastShown = lastDay < last ? lastDay : last;\n for (const date of daysBetween(firstShown, lastShown)) {\n const startMinute = date === from.date ? from.minutes : 0;\n let endMinute = date === lastDay ? lastMinute : MINUTES_PER_DAY;\n // Where the clocks go back, an end can read earlier than (or the same as) the start.\n if (date === from.date && date === lastDay && endMinute <= startMinute && endMs > startMs) {\n endMinute = Math.min(\n MINUTES_PER_DAY,\n startMinute + Math.round((endMs - startMs) / MINUTE_MS)\n );\n }\n segments.push({\n date,\n startMinute,\n endMinute,\n continuesBefore: date !== from.date,\n continuesAfter: date !== lastDay,\n });\n }\n return segments;\n}\n\nfunction isMidnightIn(instant: Date, timeZone: string): boolean {\n return instantToZoned(instant, timeZone).minutes === 0;\n}\n\n/**\n * The days an all-day event or block covers, both included, the same wherever it is read.\n *\n * All-day times are stored in two ways: at UTC midnights (links, imports, other apps, the API's\n * own rule) and, from today's event form, at midnight where the person who made it was. So the\n * day is read in UTC when the start is a UTC midnight, else in the event's own zone when the\n * start is a midnight there, else in `viewerTimeZone`. The end is exclusive (the next midnight)\n * or the last moment of the last day; an end at or before the start is a one-day event.\n */\nexport function allDayDays(\n start: Date,\n end: Date,\n options: { eventTimeZone?: string | null; viewerTimeZone: string }\n): { start: DateValue; end: DateValue } {\n const eventZone = canonicalTimeZone(options.eventTimeZone);\n const zone =\n start.getTime() % DAY_MS === 0\n ? 'UTC'\n : eventZone && isMidnightIn(start, eventZone)\n ? eventZone\n : options.viewerTimeZone;\n const first = dateValueInZone(start, zone);\n if (end.getTime() <= start.getTime()) return { start: first, end: first };\n const lastDay = dateValueInZone(new Date(end.getTime() - 1), zone);\n return { start: first, end: lastDay < first ? first : lastDay };\n}\n\n/**\n * The first and last day an event touches in `timeZone`: its days for an all-day event, else\n * the days of its start and of the moment before its end.\n */\nexport function eventDays(\n event: { start: Date; end: Date; allDay: boolean; timeZone?: string | null },\n timeZone: string\n): { start: DateValue; end: DateValue } {\n if (event.allDay) {\n return allDayDays(event.start, event.end, {\n eventTimeZone: event.timeZone,\n viewerTimeZone: timeZone,\n });\n }\n const first = dateValueInZone(event.start, timeZone);\n if (event.end.getTime() <= event.start.getTime()) return { start: first, end: first };\n const lastDay = dateValueInZone(new Date(event.end.getTime() - 1), timeZone);\n return { start: first, end: lastDay < first ? first : lastDay };\n}\n"],"mappings":";;AAwCA,IAAMA,IAAY,KACZC,IAAS;AAKf,SAAgBC,EAAY,GAAoC;CAC9D,OAAOC,MAAU,KAAKA,MAAU,KAAKA,MAAU;AACjD;AAMA,SAAgBC,EAAgB,GAAmC;CACjE,OAAOC,EAAkBC,CAAS,KAAKC,EAAiB;AAC1D;AAGA,SAAgBC,EAAM,GAAkB,oBAAY,IAAI,KAAK,GAAc;CACzE,OAAOC,EAAeC,GAAUC,CAAG;AACrC;AAeA,SAASC,EAAW,GAAyB;CAC3C,wBAAO,IAAI,KAAK,KAAK,MAAMC,IAAOZ,CAAM,IAAIA,CAAM,EAAA,CAAE,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE;AAC/E;AAEA,SAASa,EAAS,GAAkB,GAAyB;CAC3D,OAAOC,EAAsBL,GAAU,IAAI,KAAKM,CAAO,CAAC,IAAIhB;AAC9D;AA8CA,SAAgBiB,EACd,GACA,GACsC;CACtC,IAAMJ,IAAOG,EAAQ,QAAQ,IAAIF,EAASJ,GAAUM,EAAQ,QAAQ,CAAC,GAC/DE,IAAW,KAAK,MAAML,IAAOZ,CAAM,IAAIA;CAC7C,OAAO;EAAE,MAAMW,EAAWC,CAAI;EAAG,SAAS,KAAK,OAAOA,IAAOK,KAAYlB,CAAS;CAAE;AACtF;AA+JA,SAASmB,EAAa,GAAe,GAA2B;CAC9D,OAAOF,EAAeD,GAASN,CAAQ,CAAC,CAAC,YAAY;AACvD;AAWA,SAAgBU,EACd,GACA,GACA,GACsC;CACtC,IAAMC,IAAYhB,EAAkBiB,EAAQ,aAAa,GACnDC,IACJC,EAAM,QAAQ,IAAIvB,MAAW,IACzB,QACAoB,KAAaF,EAAaK,GAAOH,CAAS,IACxCA,IACAC,EAAQ,gBACVG,IAAQC,EAAgBF,GAAOD,CAAI;CACzC,IAAII,EAAI,QAAQ,KAAKH,EAAM,QAAQ,GAAG,OAAO;EAAE,OAAOC;EAAO,KAAKA;CAAM;CACxE,IAAMG,IAAUF,kBAAgB,IAAI,KAAKC,EAAI,QAAQ,IAAI,CAAC,GAAGJ,CAAI;CACjE,OAAO;EAAE,OAAOE;EAAO,KAAKG,IAAUH,IAAQA,IAAQG;CAAQ;AAChE;AAMA,SAAgBC,EACd,GACA,GACsC;CACtC,IAAIC,EAAM,QACR,OAAOV,EAAWU,EAAM,OAAOA,EAAM,KAAK;EACxC,eAAeA,EAAM;EACrB,gBAAgBpB;CAClB,CAAC;CAEH,IAAMe,IAAQC,EAAgBI,EAAM,OAAOpB,CAAQ;CACnD,IAAIoB,EAAM,IAAI,QAAQ,KAAKA,EAAM,MAAM,QAAQ,GAAG,OAAO;EAAE,OAAOL;EAAO,KAAKA;CAAM;CACpF,IAAMG,IAAUF,kBAAgB,IAAI,KAAKI,EAAM,IAAI,QAAQ,IAAI,CAAC,GAAGpB,CAAQ;CAC3E,OAAO;EAAE,OAAOe;EAAO,KAAKG,IAAUH,IAAQA,IAAQG;CAAQ;AAChE"}