@burdenoff/microfe-calendar 2026.1124.1 → 2026.1124.3

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 (156) hide show
  1. package/dist/generated/wspace-operations.d.ts +658 -0
  2. package/dist/generated/wspace-operations.js +179 -6
  3. package/dist/generated/wspace-operations.js.map +1 -1
  4. package/dist/generated/wspace-types.d.ts +1243 -10
  5. package/dist/hooks/useSafePermissions.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/pages/ResourcesPage.js.map +1 -1
  8. package/dist/providers/CalendarProvider.d.ts +3 -1
  9. package/dist/providers/CalendarProvider.js +12 -10
  10. package/dist/providers/CalendarProvider.js.map +1 -1
  11. package/dist/translations/en.d.ts +291 -1
  12. package/dist/types/index.d.ts +9 -0
  13. package/dist/v2/CalendarPageV2.js +44 -39
  14. package/dist/v2/CalendarPageV2.js.map +1 -1
  15. package/dist/v2/data/enums.d.ts +1 -0
  16. package/dist/v2/data/enums.js +6 -2
  17. package/dist/v2/data/enums.js.map +1 -1
  18. package/dist/v2/dialogs/CalendarDialogsV2.js +12 -9
  19. package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -1
  20. package/dist/v2/event/CustomRepeat.d.ts +5 -0
  21. package/dist/v2/event/CustomRepeat.js +246 -0
  22. package/dist/v2/event/CustomRepeat.js.map +1 -0
  23. package/dist/v2/event/EventDetailsTab.d.ts +6 -0
  24. package/dist/v2/event/EventDetailsTab.js +291 -0
  25. package/dist/v2/event/EventDetailsTab.js.map +1 -0
  26. package/dist/v2/event/EventDialog.d.ts +25 -0
  27. package/dist/v2/event/EventDialog.js +365 -0
  28. package/dist/v2/event/EventDialog.js.map +1 -0
  29. package/dist/v2/event/EventDialogs.d.ts +3 -0
  30. package/dist/v2/event/EventDialogs.js +111 -0
  31. package/dist/v2/event/EventDialogs.js.map +1 -0
  32. package/dist/v2/event/EventMoreTab.d.ts +4 -0
  33. package/dist/v2/event/EventMoreTab.js +214 -0
  34. package/dist/v2/event/EventMoreTab.js.map +1 -0
  35. package/dist/v2/event/EventPeopleTab.d.ts +8 -0
  36. package/dist/v2/event/EventPeopleTab.js +422 -0
  37. package/dist/v2/event/EventPeopleTab.js.map +1 -0
  38. package/dist/v2/event/EventPlaceTab.d.ts +6 -0
  39. package/dist/v2/event/EventPlaceTab.js +264 -0
  40. package/dist/v2/event/EventPlaceTab.js.map +1 -0
  41. package/dist/v2/event/FindTimeDialog.d.ts +26 -0
  42. package/dist/v2/event/FindTimeDialog.js +667 -0
  43. package/dist/v2/event/FindTimeDialog.js.map +1 -0
  44. package/dist/v2/event/RepeatField.d.ts +5 -0
  45. package/dist/v2/event/RepeatField.js +88 -0
  46. package/dist/v2/event/RepeatField.js.map +1 -0
  47. package/dist/v2/event/dialogLogic.d.ts +87 -0
  48. package/dist/v2/event/dialogLogic.js +117 -0
  49. package/dist/v2/event/dialogLogic.js.map +1 -0
  50. package/dist/v2/event/dialogModel.d.ts +48 -0
  51. package/dist/v2/event/dialogModel.js +13 -0
  52. package/dist/v2/event/dialogModel.js.map +1 -0
  53. package/dist/v2/event/eventForm.d.ts +209 -0
  54. package/dist/v2/event/eventForm.js +397 -0
  55. package/dist/v2/event/eventForm.js.map +1 -0
  56. package/dist/v2/event/findTime.d.ts +120 -0
  57. package/dist/v2/event/findTime.js +149 -0
  58. package/dist/v2/event/findTime.js.map +1 -0
  59. package/dist/v2/event/findTimeSource.d.ts +102 -0
  60. package/dist/v2/event/findTimeSource.js +107 -0
  61. package/dist/v2/event/findTimeSource.js.map +1 -0
  62. package/dist/v2/event/parts.d.ts +46 -0
  63. package/dist/v2/event/parts.js +124 -0
  64. package/dist/v2/event/parts.js.map +1 -0
  65. package/dist/v2/event/place.d.ts +64 -0
  66. package/dist/v2/event/place.js +48 -0
  67. package/dist/v2/event/place.js.map +1 -0
  68. package/dist/v2/event/repeatWords.d.ts +19 -0
  69. package/dist/v2/event/repeatWords.js +130 -0
  70. package/dist/v2/event/repeatWords.js.map +1 -0
  71. package/dist/v2/event/rrule.d.ts +90 -0
  72. package/dist/v2/event/rrule.js +368 -0
  73. package/dist/v2/event/rrule.js.map +1 -0
  74. package/dist/v2/event/savePlan.d.ts +50 -0
  75. package/dist/v2/event/savePlan.js +125 -0
  76. package/dist/v2/event/savePlan.js.map +1 -0
  77. package/dist/v2/event/useEventData.d.ts +91 -0
  78. package/dist/v2/event/useEventData.js +202 -0
  79. package/dist/v2/event/useEventData.js.map +1 -0
  80. package/dist/v2/event/useEventDialogModel.d.ts +37 -0
  81. package/dist/v2/event/useEventDialogModel.js +129 -0
  82. package/dist/v2/event/useEventDialogModel.js.map +1 -0
  83. package/dist/v2/event/useEventSave.d.ts +41 -0
  84. package/dist/v2/event/useEventSave.js +185 -0
  85. package/dist/v2/event/useEventSave.js.map +1 -0
  86. package/dist/v2/format.d.ts +2 -0
  87. package/dist/v2/format.js +4 -0
  88. package/dist/v2/format.js.map +1 -1
  89. package/dist/v2/grid/GridParts.js +100 -94
  90. package/dist/v2/grid/GridParts.js.map +1 -1
  91. package/dist/v2/grid/TimeGrid.js +98 -89
  92. package/dist/v2/grid/TimeGrid.js.map +1 -1
  93. package/dist/v2/list/ListViewV2.d.ts +6 -2
  94. package/dist/v2/list/ListViewV2.js +50 -44
  95. package/dist/v2/list/ListViewV2.js.map +1 -1
  96. package/dist/v2/month/MonthView.js +130 -126
  97. package/dist/v2/month/MonthView.js.map +1 -1
  98. package/dist/v2/peek/EventPeek.js.map +1 -1
  99. package/dist/v2/peek/PeekEvent.js.map +1 -1
  100. package/dist/v2/rail/CalendarRail.js +54 -80
  101. package/dist/v2/rail/CalendarRail.js.map +1 -1
  102. package/dist/v2/runs/RunPeek.d.ts +2 -0
  103. package/dist/v2/runs/RunPeek.js +382 -0
  104. package/dist/v2/runs/RunPeek.js.map +1 -0
  105. package/dist/v2/runs/RunPills.d.ts +28 -0
  106. package/dist/v2/runs/RunPills.js +179 -0
  107. package/dist/v2/runs/RunPills.js.map +1 -0
  108. package/dist/v2/runs/RunRows.d.ts +21 -0
  109. package/dist/v2/runs/RunRows.js +140 -0
  110. package/dist/v2/runs/RunRows.js.map +1 -0
  111. package/dist/v2/runs/RunsNotices.d.ts +1 -0
  112. package/dist/v2/runs/RunsNotices.js +37 -0
  113. package/dist/v2/runs/RunsNotices.js.map +1 -0
  114. package/dist/v2/runs/RunsSwitch.d.ts +1 -0
  115. package/dist/v2/runs/RunsSwitch.js +54 -0
  116. package/dist/v2/runs/RunsSwitch.js.map +1 -0
  117. package/dist/v2/runs/WorkflowRunsLayer.d.ts +4 -0
  118. package/dist/v2/runs/WorkflowRunsLayer.js +82 -0
  119. package/dist/v2/runs/WorkflowRunsLayer.js.map +1 -0
  120. package/dist/v2/runs/runAccess.d.ts +37 -0
  121. package/dist/v2/runs/runAccess.js +14 -0
  122. package/dist/v2/runs/runAccess.js.map +1 -0
  123. package/dist/v2/runs/runLayout.d.ts +76 -0
  124. package/dist/v2/runs/runLayout.js +129 -0
  125. package/dist/v2/runs/runLayout.js.map +1 -0
  126. package/dist/v2/runs/runLinks.d.ts +32 -0
  127. package/dist/v2/runs/runLinks.js +50 -0
  128. package/dist/v2/runs/runLinks.js.map +1 -0
  129. package/dist/v2/runs/runModel.d.ts +97 -0
  130. package/dist/v2/runs/runModel.js +132 -0
  131. package/dist/v2/runs/runModel.js.map +1 -0
  132. package/dist/v2/runs/runPeekState.d.ts +53 -0
  133. package/dist/v2/runs/runPeekState.js +62 -0
  134. package/dist/v2/runs/runPeekState.js.map +1 -0
  135. package/dist/v2/runs/runTypes.d.ts +60 -0
  136. package/dist/v2/runs/runWords.d.ts +23 -0
  137. package/dist/v2/runs/runWords.js +83 -0
  138. package/dist/v2/runs/runWords.js.map +1 -0
  139. package/dist/v2/runs/runsLayerContext.d.ts +26 -0
  140. package/dist/v2/runs/runsLayerContext.js +33 -0
  141. package/dist/v2/runs/runsLayerContext.js.map +1 -0
  142. package/dist/v2/runs/useRunHrefs.d.ts +10 -0
  143. package/dist/v2/runs/useRunHrefs.js +60 -0
  144. package/dist/v2/runs/useRunHrefs.js.map +1 -0
  145. package/dist/v2/runs/useRunLabels.d.ts +6 -0
  146. package/dist/v2/runs/useRunLabels.js +27 -0
  147. package/dist/v2/runs/useRunLabels.js.map +1 -0
  148. package/dist/v2/runs/useRunsAccess.d.ts +2 -0
  149. package/dist/v2/runs/useRunsAccess.js +14 -0
  150. package/dist/v2/runs/useRunsAccess.js.map +1 -0
  151. package/dist/v2/runs/useWorkflowRuns.d.ts +61 -0
  152. package/dist/v2/runs/useWorkflowRuns.js +119 -0
  153. package/dist/v2/runs/useWorkflowRuns.js.map +1 -0
  154. package/dist/v2/states/CalendarStates.js.map +1 -1
  155. package/dist/v2/types.d.ts +2 -0
  156. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventForm.js","names":["MINUTE_MS","LENGTH_CHIPS","startWall","instantToZoned","form","endWall","firstDayOf","startInstant","endInstant","addDays","lengthMinutes","lengthChip","length","startingAt","start","followingStart","after","repeatFollowingStart","before","anchorOf","withStartDate","date","days","dayDifference","wall","zonedTimeToInstant","withStartTime","minutes","withEndTime","day","nextDay","withEndClock","withEndDate","withLength","withAllDay","allDay","first","lastMoment","last","withTimeZone","timeZone","end","wallIn","withSlot","slot","repeat","followStart","offered","presetsFor","presetRule","repeatRuleOf","rruleOf","rule","buildRRule","repeatStateOf","parsed","parseRRule","rrule","anchor","preset","presetOf","isEmailAddress","text","guestKey","guest","addressOfGuest","email","withGuests","guests","keys","changed","person","people","organizerId","key","address","same","already","withoutGuest","withReminder","reminder","minutesBefore","channel","reminders","a","b","withoutReminder","videoOf","event","addressOf","location","locationIsRoomName","availabilitySpan","startOfDayInZone","calendarTimeZone","name","eventRoom","defaultReminders","defaults","draftLength","from","newEventForm","draft","startMinutes","formFromEvent","room","activeRoom","eventDays","formIssues","issues","safeWebUrl","problem","ruleProblem","hasIssues","sameForm","comparable"],"sources":["../../../src/v2/event/eventForm.ts"],"sourcesContent":["/**\n * The event dialog's form (BOFF-15698 A2): what the person sets, and the rules between the\n * fields. Pure.\n *\n * - A timed event is its start and end instants, shown on its own zone's clock (the Time zone\n * field). Instants, not clock times, so an event ending in the second 01:30 of 25 October in\n * London keeps its end: a clock time names only the first. Lengths are real time: \"1 h\" from\n * 00:30 on 29 March ends at 02:30; a clock time the clocks skip (01:30 then) becomes the time\n * after the gap (02:30), as the grid reads it.\n * - An all-day event is its first and last day, floating: it is written at UTC midnights (the\n * API's own rule, which the .ics export and free/busy read), the same days wherever it is read.\n * Its start and end instants are kept meanwhile: switching All day back off restores them.\n * - Changing the time zone keeps the clock times shown (\"09:00 in New York\") and moves the\n * instants; `wallIn` says where they land on the calendar's clock.\n * - Moving the start keeps the length. The end can't come before the start.\n */\nimport { addDays, type DateValue } from '@burdenoff/fe-libs/ui';\nimport { eventRoom, safeWebUrl } from '../events/eventModel';\nimport {\n dayDifference,\n eventDays,\n instantToZoned,\n startOfDayInZone,\n zonedTimeToInstant,\n} from '../time/calendarTime';\nimport type {\n CalendarEventV2,\n CalendarV2EventDraft,\n EventResponseV2,\n EventVisibilityV2,\n} from '../types';\nimport {\n buildRRule,\n followStart,\n parseRRule,\n presetOf,\n presetRule,\n presetsFor,\n ruleProblem,\n type RepeatPreset,\n type RepeatRule,\n type RuleAnchor,\n type RuleProblem,\n} from './rrule';\n\nconst MINUTE_MS = 60_000;\n\n/** The Length chips, in minutes. */\nexport const LENGTH_CHIPS: readonly number[] = [30, 45, 60, 90];\n\nexport interface GuestDraft {\n /** `u:<userId>` for a member, `e:<email>` for anyone else. */\n key: string;\n userId: string | null;\n email: string | null;\n name: string | null;\n optional: boolean;\n /** The guest's row, for someone the event already has. */\n attendeeId: string | null;\n response: EventResponseV2 | null;\n}\n\nexport type ReminderChannelV2 = 'IN_APP' | 'EMAIL' | 'SMS';\n\nexport interface ReminderDraft {\n /** `r:<id>` for a reminder the event has, `<channel>:<minutes>` for a new one. */\n key: string;\n minutesBefore: number;\n channel: ReminderChannelV2;\n /** The reminder's row, for one the event already has. */\n reminderId: string | null;\n}\n\nexport type RepeatState =\n | { kind: 'none' }\n /** A menu preset, worked out from the start whenever it moves. */\n | { kind: 'preset'; preset: RepeatPreset }\n | { kind: 'custom'; rule: RepeatRule }\n /** A stored rule the builder can't hold, kept as it is. */\n | { kind: 'kept'; text: string };\n\nexport interface EventForm {\n title: string;\n allDay: boolean;\n /** Timed: when it starts and ends. All-day: the times to go back to when it is switched off. */\n start: Date;\n end: Date;\n /** All-day: the first and last day, both included. */\n firstDay: DateValue;\n lastDay: DateValue;\n timeZone: string;\n repeat: RepeatState;\n description: string;\n guests: GuestDraft[];\n roomId: string | null;\n videoUrl: string;\n address: string;\n calendarId: string | null;\n visibility: EventVisibilityV2;\n reminders: ReminderDraft[];\n}\n\n/** What a new event starts with besides its draft. */\nexport interface NewFormDefaults {\n /** The calendar's zone. */\n timeZone: string;\n today: DateValue;\n /** Minutes. */\n defaultLength: number;\n /** Minutes before, or null for none. */\n defaultReminder: number | null;\n defaultCalendarId: string | null;\n}\n\n/** A day, and minutes after its midnight on a clock. */\nexport interface WallTime {\n date: DateValue;\n minutes: number;\n}\n\n// ── Times ────────────────────────────────────────────────────────────────────\n\n/** Where the start shows on the event's own clock. */\nexport function startWall(form: EventForm): WallTime {\n return instantToZoned(form.start, form.timeZone);\n}\n\n/** Where the end shows on the event's own clock. */\nexport function endWall(form: EventForm): WallTime {\n return instantToZoned(form.end, form.timeZone);\n}\n\n/** The event's first day: an all-day event's own, else its start's on its clock. */\nexport function firstDayOf(form: EventForm): DateValue {\n return form.allDay ? form.firstDay : startWall(form).date;\n}\n\n/** When the event starts: the instant, or the UTC midnight of an all-day event's first day. */\nexport function startInstant(form: EventForm): Date {\n return form.allDay ? new Date(`${form.firstDay}T00:00:00.000Z`) : form.start;\n}\n\n/** When it ends: the instant, or the UTC midnight after an all-day event's last day. */\nexport function endInstant(form: EventForm): Date {\n return form.allDay ? new Date(`${addDays(form.lastDay, 1)}T00:00:00.000Z`) : form.end;\n}\n\n/** How long a timed event lasts, in real minutes. */\nexport function lengthMinutes(form: EventForm): number {\n return Math.round((form.end.getTime() - form.start.getTime()) / MINUTE_MS);\n}\n\n/** The Length chip the event's length is, if it is one. */\nexport function lengthChip(form: EventForm): number | null {\n if (form.allDay) return null;\n const length = lengthMinutes(form);\n return LENGTH_CHIPS.includes(length) ? length : null;\n}\n\n/** A start, and an end `length` real minutes after it (the length never below a minute). */\nfunction startingAt(form: EventForm, start: Date, length: number): EventForm {\n return { ...form, start, end: new Date(start.getTime() + Math.max(1, length) * MINUTE_MS) };\n}\n\n/** The form after its start moved: its repeat follows, so the start stays an occurrence. */\nfunction followingStart(before: EventForm, after: EventForm): EventForm {\n return {\n ...after,\n repeat: repeatFollowingStart(before.repeat, anchorOf(before), anchorOf(after)),\n };\n}\n\n/** The start on another day, the length kept (all-day: the number of days kept). */\nexport function withStartDate(form: EventForm, date: DateValue): EventForm {\n if (form.allDay) {\n if (date === form.firstDay) return form;\n const days = Math.max(0, dayDifference(form.firstDay, form.lastDay));\n return followingStart(form, { ...form, firstDay: date, lastDay: addDays(date, days) });\n }\n const wall = startWall(form);\n if (date === wall.date) return form;\n const start = zonedTimeToInstant(date, wall.minutes, form.timeZone);\n return followingStart(form, startingAt(form, start, lengthMinutes(form)));\n}\n\n/** The start at another time of its day, the length kept. */\nexport function withStartTime(form: EventForm, minutes: number): EventForm {\n if (form.allDay) return form;\n const start = zonedTimeToInstant(startWall(form).date, minutes, form.timeZone);\n return followingStart(form, startingAt(form, start, lengthMinutes(form)));\n}\n\n/**\n * The end picked in the end picker beside the start, whose times run on past midnight\n * (`nextDay`): on the start's day, or the day after.\n */\nexport function withEndTime(form: EventForm, minutes: number, nextDay: boolean): EventForm {\n if (form.allDay) return form;\n const day = startWall(form).date;\n return {\n ...form,\n end: zonedTimeToInstant(nextDay ? addDays(day, 1) : day, minutes, form.timeZone),\n };\n}\n\n/** The end's time on its own day (an event of more than a day has an end date of its own). */\nexport function withEndClock(form: EventForm, minutes: number): EventForm {\n if (form.allDay) return form;\n return { ...form, end: zonedTimeToInstant(endWall(form).date, minutes, form.timeZone) };\n}\n\n/** The end's day (timed), or the last day (all-day). */\nexport function withEndDate(form: EventForm, date: DateValue): EventForm {\n if (form.allDay) return { ...form, lastDay: date };\n return { ...form, end: zonedTimeToInstant(date, endWall(form).minutes, form.timeZone) };\n}\n\n/** The Length chips: the end `minutes` real minutes after the start. */\nexport function withLength(form: EventForm, minutes: number): EventForm {\n if (form.allDay) return form;\n return startingAt(form, form.start, minutes);\n}\n\n/**\n * All day on or off. On: the days the times touch (an end at midnight doesn't add its day).\n * Off: the times it had, on its first day.\n */\nexport function withAllDay(form: EventForm, allDay: boolean): EventForm {\n if (form.allDay === allDay) return form;\n if (allDay) {\n const first = startWall(form).date;\n const lastMoment = new Date(Math.max(form.start.getTime(), form.end.getTime() - 1));\n const last = instantToZoned(lastMoment, form.timeZone).date;\n return { ...form, allDay: true, firstDay: first, lastDay: last < first ? first : last };\n }\n const start = zonedTimeToInstant(form.firstDay, startWall(form).minutes, form.timeZone);\n return followingStart(form, startingAt({ ...form, allDay: false }, start, lengthMinutes(form)));\n}\n\n/** The time zone, keeping the clock times shown (a time the new zone skips moves past the gap). */\nexport function withTimeZone(form: EventForm, timeZone: string): EventForm {\n if (timeZone === form.timeZone) return form;\n const start = startWall(form);\n const end = endWall(form);\n return {\n ...form,\n timeZone,\n start: zonedTimeToInstant(start.date, start.minutes, timeZone),\n end: zonedTimeToInstant(end.date, end.minutes, timeZone),\n };\n}\n\n/** Where the event's start and end land on another clock (the calendar's: \"your time\"). */\nexport function wallIn(form: EventForm, timeZone: string): { start: WallTime; end: WallTime } {\n return {\n start: instantToZoned(startInstant(form), timeZone),\n end: instantToZoned(endInstant(form), timeZone),\n };\n}\n\n/** A time from Find a time: `start` minutes on `date` on `timeZone`'s clock, for `length`. */\nexport function withSlot(\n form: EventForm,\n slot: { date: DateValue; start: number; length: number; timeZone: string }\n): EventForm {\n const start = zonedTimeToInstant(slot.date, slot.start, slot.timeZone);\n return followingStart(form, startingAt({ ...form, allDay: false }, start, slot.length));\n}\n\n// ── Repeat ───────────────────────────────────────────────────────────────────\n\n/** What the form's repeat rule is tied to: its start on its own clock. */\nexport function anchorOf(form: EventForm): RuleAnchor {\n if (form.allDay) {\n return { start: form.firstDay, startMinutes: 0, timeZone: form.timeZone, allDay: true };\n }\n const wall = startWall(form);\n return { start: wall.date, startMinutes: wall.minutes, timeZone: form.timeZone, allDay: false };\n}\n\n/**\n * A repeat after the start moved: a preset stays that preset for the new start (the nearest one\n * when the new start doesn't offer it), a custom rule keeps the start an occurrence.\n */\nfunction repeatFollowingStart(\n repeat: RepeatState,\n before: RuleAnchor,\n after: RuleAnchor\n): RepeatState {\n if (repeat.kind === 'custom') {\n return { kind: 'custom', rule: followStart(repeat.rule, before, after) };\n }\n if (repeat.kind !== 'preset') return repeat;\n const offered = presetsFor(after);\n if (offered.includes(repeat.preset)) return repeat;\n if (repeat.preset === 'monthlyNth' && offered.includes('monthlyLast')) {\n return { kind: 'preset', preset: 'monthlyLast' };\n }\n if (repeat.preset === 'monthlyLast' && offered.includes('monthlyNth')) {\n return { kind: 'preset', preset: 'monthlyNth' };\n }\n // \"Every weekday\" from a weekend day: the weekdays and the new start's day.\n return { kind: 'custom', rule: followStart(presetRule(repeat.preset, before), before, after) };\n}\n\n/** The rule the form repeats by; null when it doesn't repeat or keeps a stored rule. */\nexport function repeatRuleOf(form: EventForm): RepeatRule | null {\n if (form.repeat.kind === 'preset') return presetRule(form.repeat.preset, anchorOf(form));\n if (form.repeat.kind === 'custom') return form.repeat.rule;\n return null;\n}\n\n/** The RRULE to store: null when the event doesn't repeat; a kept rule as it was. */\nexport function rruleOf(form: EventForm): string | null {\n if (form.repeat.kind === 'none') return null;\n if (form.repeat.kind === 'kept') return form.repeat.text;\n const rule = repeatRuleOf(form);\n return rule ? buildRRule(rule, anchorOf(form)) : null;\n}\n\n/** A stored rule as the form holds it: a preset when it is one. */\nexport function repeatStateOf(rrule: string | null, anchor: RuleAnchor): RepeatState {\n const parsed = parseRRule(rrule, anchor);\n if (parsed.kind === 'none') return { kind: 'none' };\n if (parsed.kind === 'kept') return { kind: 'kept', text: parsed.text };\n const preset = presetOf(parsed.rule, anchor);\n return preset ? { kind: 'preset', preset } : { kind: 'custom', rule: parsed.rule };\n}\n\n// ── People and reminders ─────────────────────────────────────────────────────\n\n/** A plain email address check: something@something.tld, no spaces. */\nexport function isEmailAddress(text: string): boolean {\n return /^[^\\s@,;<>]+@[^\\s@,;<>]+\\.[^\\s@,;<>.]{2,}$/.test(text.trim());\n}\n\nexport function guestKey(guest: { userId: string | null; email: string | null }): string {\n return guest.userId ? `u:${guest.userId}` : `e:${(guest.email ?? '').trim().toLowerCase()}`;\n}\n\nfunction addressOfGuest(email: string | null): string | null {\n return email?.trim().toLowerCase() || null;\n}\n\n/**\n * The form with these people added: each once, never the organiser. A member and their email\n * address are one guest: an address that is a member's isn't added again, and a member found\n * after their address was typed (before the workspace's people loaded, say) takes the place of\n * that address while it isn't saved yet; once saved, the address stays the guest.\n */\nexport function withGuests(\n form: EventForm,\n people: readonly { userId: string | null; email: string | null; name: string | null }[],\n organizerId: string | null\n): EventForm {\n const guests = [...form.guests];\n const keys = new Set(guests.map((guest) => guest.key));\n let changed = false;\n for (const person of people) {\n if (person.userId && person.userId === organizerId) continue;\n const email = person.email?.trim() || null;\n const key = guestKey({ userId: person.userId, email });\n if (key === 'e:' || keys.has(key)) continue;\n const address = addressOfGuest(email);\n const same = address\n ? guests.findIndex((guest) => addressOfGuest(guest.email) === address)\n : -1;\n const already = guests[same];\n if (already) {\n if (!person.userId || already.userId || already.attendeeId !== null) continue;\n guests.splice(same, 1);\n keys.delete(already.key);\n }\n keys.add(key);\n guests.push({\n key,\n userId: person.userId,\n email,\n name: person.name,\n optional: false,\n attendeeId: null,\n response: null,\n });\n changed = true;\n }\n return changed ? { ...form, guests } : form;\n}\n\nexport function withoutGuest(form: EventForm, key: string): EventForm {\n return { ...form, guests: form.guests.filter((guest) => guest.key !== key) };\n}\n\n/** The form with a reminder added, unless it has one at that time on that channel. */\nexport function withReminder(\n form: EventForm,\n minutesBefore: number,\n channel: ReminderChannelV2\n): EventForm {\n const same = (reminder: ReminderDraft) =>\n reminder.minutesBefore === minutesBefore && reminder.channel === channel;\n if (form.reminders.some(same)) return form;\n const key = `${channel}:${minutesBefore}`;\n const reminders = [...form.reminders, { key, minutesBefore, channel, reminderId: null }];\n reminders.sort((a, b) => a.minutesBefore - b.minutesBefore || a.channel.localeCompare(b.channel));\n return { ...form, reminders };\n}\n\nexport function withoutReminder(form: EventForm, key: string): EventForm {\n return { ...form, reminders: form.reminders.filter((reminder) => reminder.key !== key) };\n}\n\n// ── Place ────────────────────────────────────────────────────────────────────\n\n/** Which of the event's fields the video link lives in. */\nexport type VideoField = 'onlineMeetingUrl' | 'locationUrl';\n/** Which of the event's fields the address lives in. */\nexport type AddressField = 'location' | 'locationAddress';\n\n/**\n * An event's video link and the field it is in: the meeting link, else an online event's\n * location link (today's form wrote it there).\n */\nexport function videoOf(event: CalendarEventV2): { url: string; field: VideoField } {\n if (event.meeting?.url) return { url: event.meeting.url, field: 'onlineMeetingUrl' };\n if (event.locationType === 'ONLINE' && event.locationUrl) {\n return { url: event.locationUrl, field: 'locationUrl' };\n }\n return { url: '', field: 'onlineMeetingUrl' };\n}\n\n/**\n * An event's address and the field it is in: the location, unless it is a room's name or a\n * link; else the address field. A new address goes in the location, which every app reads.\n */\nexport function addressOf(event: CalendarEventV2): { text: string; field: AddressField } {\n const location = event.location?.trim() ?? '';\n if (location && !locationIsRoomName(event) && !/^https?:\\/\\//i.test(location)) {\n return { text: location, field: 'location' };\n }\n if (event.locationAddress?.trim())\n return { text: event.locationAddress, field: 'locationAddress' };\n return { text: '', field: 'location' };\n}\n\n/**\n * The time a person's availability is checked over: a timed event's instants; an all-day\n * event's days from midnight to midnight on the calendar's clock (its stored UTC midnights would\n * reach into the days either side, where time off is kept on that clock too).\n */\nexport function availabilitySpan(\n form: EventForm,\n calendarTimeZone: string\n): { start: Date; end: Date; allDay: boolean } {\n if (!form.allDay) return { start: startInstant(form), end: endInstant(form), allDay: false };\n return {\n start: startOfDayInZone(form.firstDay, calendarTimeZone),\n end: startOfDayInZone(addDays(form.lastDay, 1), calendarTimeZone),\n allDay: true,\n };\n}\n\n/** The event's location is only the name of its booked room (as other apps write it). */\nexport function locationIsRoomName(event: CalendarEventV2): boolean {\n const name = eventRoom(event)?.name?.trim();\n return Boolean(name) && event.location?.trim() === name;\n}\n\n// ── Building a form ──────────────────────────────────────────────────────────\n\nfunction defaultReminders(defaults: NewFormDefaults): ReminderDraft[] {\n if (defaults.defaultReminder === null) return [];\n return [\n {\n key: `IN_APP:${defaults.defaultReminder}`,\n minutesBefore: defaults.defaultReminder,\n channel: 'IN_APP',\n reminderId: null,\n },\n ];\n}\n\n/**\n * A draft's length in minutes. Its end is a time on the same clock as its start (an end of 1440\n * is the next midnight), so the length is the time between the two instants: on a day the clocks\n * change, the difference of the clock times would gain or lose the hour. Null without an end\n * after the start.\n */\nfunction draftLength(\n date: DateValue,\n start: number,\n end: number | undefined,\n timeZone: string\n): number | null {\n if (end === undefined || end <= start) return null;\n const from = zonedTimeToInstant(date, start, timeZone).getTime();\n const minutes = Math.round(\n (zonedTimeToInstant(date, end, timeZone).getTime() - from) / MINUTE_MS\n );\n return minutes > 0 ? minutes : null;\n}\n\n/**\n * A new event's form from what the view set (`CalendarV2EventDraft`): its day and times on the\n * calendar's clock (an end of 1440 is the next midnight), else 09:00 for the default length.\n */\nexport function newEventForm(\n draft: CalendarV2EventDraft | null,\n defaults: NewFormDefaults\n): EventForm {\n const date = draft?.date ?? defaults.today;\n const startMinutes = Math.max(0, Math.round(draft?.start ?? 9 * 60));\n const length =\n draftLength(date, startMinutes, draft?.end, defaults.timeZone) ?? defaults.defaultLength;\n const start = zonedTimeToInstant(date, startMinutes, defaults.timeZone);\n const form: EventForm = {\n title: draft?.title ?? '',\n allDay: false,\n start,\n end: new Date(start.getTime() + Math.max(1, length) * MINUTE_MS),\n firstDay: date,\n lastDay: date,\n timeZone: defaults.timeZone,\n repeat: { kind: 'none' },\n description: '',\n guests: [],\n roomId: draft?.resourceIds?.[0] ?? null,\n videoUrl: '',\n address: '',\n calendarId: draft?.calendarId ?? defaults.defaultCalendarId,\n visibility: 'PUBLIC',\n reminders: defaultReminders(defaults),\n };\n return draft?.allDay ? withAllDay(form, true) : form;\n}\n\n/**\n * An existing event's form: its instants on its own zone's clock (else the calendar's), its days\n * when all-day (with 09:00 for an hour on its first day to switch to), its guests but the\n * organiser, its room, link, address and reminders. `draft` may bring a new time on the\n * calendar's clock (Find a time's \"Use this time\" on a repeating event).\n */\nexport function formFromEvent(\n event: CalendarEventV2,\n calendarTimeZone: string,\n draft: CalendarV2EventDraft | null = null\n): EventForm {\n const timeZone = event.timeZone ?? calendarTimeZone;\n const room = eventRoom(event);\n const activeRoom =\n room && (room.status === 'APPROVED' || room.status === 'PENDING') ? room : null;\n const days = eventDays(event, calendarTimeZone);\n const start = event.allDay ? zonedTimeToInstant(days.start, 9 * 60, timeZone) : event.start;\n const end = event.allDay ? new Date(start.getTime() + 60 * MINUTE_MS) : event.end;\n let form: EventForm = {\n title: event.title,\n allDay: event.allDay,\n start,\n end,\n firstDay: days.start,\n lastDay: days.end,\n timeZone,\n repeat: { kind: 'none' },\n description: event.description ?? '',\n guests: event.guests\n .filter((guest) => !guest.organizer && guest.userId !== event.organizerId)\n .map((guest) => ({\n key: guestKey(guest),\n userId: guest.userId,\n email: guest.email,\n name: guest.name,\n optional: guest.optional,\n attendeeId: guest.id,\n response: guest.response,\n })),\n roomId: activeRoom?.resourceId ?? null,\n videoUrl: videoOf(event).url,\n address: addressOf(event).text,\n calendarId: event.calendarId,\n visibility: event.visibility,\n reminders: event.reminders.map((reminder) => ({\n key: `r:${reminder.id}`,\n minutesBefore: reminder.minutesBefore,\n channel: reminder.channel,\n reminderId: reminder.id,\n })),\n };\n if (event.isRecurring && event.rrule) {\n form = { ...form, repeat: repeatStateOf(event.rrule, anchorOf(form)) };\n } else if (event.rrule) {\n form = { ...form, repeat: { kind: 'kept', text: event.rrule } };\n }\n if (draft?.date !== undefined && draft.start !== undefined) {\n const length =\n draftLength(draft.date, draft.start, draft.end, calendarTimeZone) ?? lengthMinutes(form);\n form = withSlot(form, {\n date: draft.date,\n start: draft.start,\n length,\n timeZone: calendarTimeZone,\n });\n }\n return form;\n}\n\n// ── Checks ───────────────────────────────────────────────────────────────────\n\nexport interface FormIssues {\n title?: 'missing';\n when?: 'endBeforeStart';\n video?: 'notWebAddress';\n repeat?: RuleProblem;\n}\n\n/** What stops the form from being saved. */\nexport function formIssues(form: EventForm): FormIssues {\n const issues: FormIssues = {};\n if (form.title.trim() === '') issues.title = 'missing';\n const ends = form.allDay\n ? form.lastDay >= form.firstDay\n : form.end.getTime() > form.start.getTime();\n if (!ends) issues.when = 'endBeforeStart';\n if (form.videoUrl.trim() !== '' && !safeWebUrl(form.videoUrl)) issues.video = 'notWebAddress';\n if (form.repeat.kind === 'custom') {\n const problem = ruleProblem(form.repeat.rule, anchorOf(form));\n if (problem) issues.repeat = problem;\n }\n return issues;\n}\n\nexport function hasIssues(issues: FormIssues): boolean {\n return Object.keys(issues).length > 0;\n}\n\n/** The two forms hold the same event (the dialog asks before dropping changes). */\nexport function sameForm(a: EventForm, b: EventForm): boolean {\n const comparable = (form: EventForm) => JSON.stringify({ ...form, title: form.title.trim() });\n return comparable(a) === comparable(b);\n}\n"],"mappings":";;;;;AA6CA,IAAMA,IAAY,KAGLC,IAAkC;CAAC;CAAI;CAAI;CAAI;AAAE;AA2E9D,SAAgBC,EAAU,GAA2B;CACnD,OAAOC,EAAeC,EAAK,OAAOA,EAAK,QAAQ;AACjD;AAGA,SAAgBC,EAAQ,GAA2B;CACjD,OAAOF,EAAeC,EAAK,KAAKA,EAAK,QAAQ;AAC/C;AAGA,SAAgBE,EAAW,GAA4B;CACrD,OAAOF,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G,EAAK,OAAO,MAAMe,EAASf,CAAI,CAAC;EAC5D,AAAI2G,MAAS,EAAO,SAASA;CAC/B;CACA,OAAOF;AACT;AAEA,SAAgBI,GAAU,GAA6B;CACrD,OAAO,OAAO,KAAKJ,CAAM,CAAC,CAAC,SAAS;AACtC;AAGA,SAAgBK,GAAS,GAAc,GAAuB;CAC5D,IAAMC,KAAc,MAAoB,KAAK,UAAU;EAAE,GAAG/G;EAAM,OAAOA,EAAK,MAAM,KAAK;CAAE,CAAC;CAC5F,OAAO+G,EAAW/B,CAAC,MAAM+B,EAAW9B,CAAC;AACvC"}
@@ -0,0 +1,120 @@
1
+ import { DateValue } from '@burdenoff/fe-libs/ui';
2
+ import { DayHours } from '../grid/workingHours';
3
+ import { CalendarEventV2, CalendarV2, PersonFreeBusyV2 } from '../types';
4
+ import { RoomForEvent } from './place';
5
+ /** `away`: time off. `booked`: a room's booking. `closed`: a room that takes no bookings. */
6
+ export type BusyKind = 'tentative' | 'busy' | 'away' | 'booked' | 'closed';
7
+ /** A stretch of busy time, in epoch milliseconds. */
8
+ export interface BusySpan {
9
+ start: number;
10
+ end: number;
11
+ kind: BusyKind;
12
+ }
13
+ /** Spans in time order, those that overlap or touch made one (named by the strongest kind). */
14
+ export declare function mergeSpans(spans: readonly BusySpan[]): BusySpan[];
15
+ /** `spans` without the time from `start` to `end` (an event's own time, when it is edited). */
16
+ export declare function withoutSpan(spans: readonly BusySpan[], start: number, end: number): BusySpan[];
17
+ /**
18
+ * A person's busy time: their timed blocks, and their all-day time off as whole days on the
19
+ * calendar's clock. `exclude`: an event's own time (the event being edited, for its organiser).
20
+ */
21
+ export declare function personBusySpans(person: PersonFreeBusyV2, timeZone: string, exclude?: {
22
+ start: Date;
23
+ end: Date;
24
+ } | null): BusySpan[];
25
+ /**
26
+ * A room's busy time from `from` to `to`: all of it when closed, else its bookings, widened as
27
+ * the service checks a new one (its window, less the buffer before and plus the buffer after,
28
+ * may not touch a booking): a booking keeps the room from `bufferAfter` before it to
29
+ * `bufferBefore` after it.
30
+ */
31
+ export declare function roomBusySpans(room: RoomForEvent, from: Date, to: Date, ownEventId: string | null): BusySpan[];
32
+ /** The first busy span that overlaps `start`–`end`; null when that time is free. */
33
+ export declare function busyDuring(spans: readonly BusySpan[], start: Date, end: Date): BusySpan | null;
34
+ export interface FindTimePerson {
35
+ id: string;
36
+ required: boolean;
37
+ busy: readonly BusySpan[];
38
+ }
39
+ export interface SuggestInput {
40
+ /** The first day searched (the Day field). */
41
+ day: DateValue;
42
+ /** How many days to search from it. */
43
+ days: number;
44
+ /** The calendar's zone: slots are times on its clock. */
45
+ timeZone: string;
46
+ /** Minutes. */
47
+ length: number;
48
+ now: Date;
49
+ /** Minutes between offered starts. */
50
+ step: number;
51
+ /** The person's working hours on a day (null: a day off). */
52
+ workingHours: (date: DateValue) => DayHours | null;
53
+ /** Everyone whose busy time is known (the person included). */
54
+ people: readonly FindTimePerson[];
55
+ room: {
56
+ id: string;
57
+ busy: readonly BusySpan[];
58
+ } | null;
59
+ }
60
+ export interface Suggestion {
61
+ date: DateValue;
62
+ /** Minutes after midnight on the calendar's clock. */
63
+ start: number;
64
+ startAt: Date;
65
+ endAt: Date;
66
+ /** Who can't make it: people's ids, and the room's when it is taken. */
67
+ clashes: string[];
68
+ /** Of `clashes`, the required people and the room. */
69
+ requiredClashes: number;
70
+ }
71
+ /** Everyone free, offered at most. */
72
+ export declare const MAX_FREE_SUGGESTIONS = 3;
73
+ /** Near misses on the chosen day, offered at most. */
74
+ export declare const MAX_NEAR_MISSES = 2;
75
+ /**
76
+ * Who can't make `start`–`end`: the people's ids, and the room's when it is taken; and how many
77
+ * of them count (the required people and the room).
78
+ */
79
+ export declare function clashesAt(people: readonly FindTimePerson[], room: {
80
+ id: string;
81
+ busy: readonly BusySpan[];
82
+ } | null, start: Date, end: Date): {
83
+ clashes: string[];
84
+ requiredClashes: number;
85
+ };
86
+ /** Times for a meeting: everyone free first, then near misses (see the module note). */
87
+ export declare function suggestTimes(input: SuggestInput): Suggestion[];
88
+ /**
89
+ * The whole days on the calendar's clock that an event (or a search) touches, as a free/busy
90
+ * range: from the first day's start to the day after the last, at most 60 days.
91
+ */
92
+ export declare function freeBusyRangeFor(start: Date, end: Date, timeZone: string): {
93
+ from: Date;
94
+ to: Date;
95
+ };
96
+ /**
97
+ * "Find a better time" moves the event itself (with Undo, as a drag does) when a drag could: a
98
+ * one-day event the person may change that doesn't repeat. One with a room booked opens the
99
+ * event dialog instead, whose save moves the booking too (a move alone would leave the room
100
+ * booked at the old time).
101
+ */
102
+ export declare function movesDirectly(event: CalendarEventV2, calendar: CalendarV2 | undefined, me: string | null, timeZone: string): boolean;
103
+ /** The stretch of a day the timeline shows: at least 08:00 to 19:00, more if work runs longer. */
104
+ export declare function timelineWindow(hours: DayHours | null): {
105
+ start: number;
106
+ end: number;
107
+ };
108
+ export interface TimelineBlock {
109
+ /** Minutes on the day's clock face. */
110
+ start: number;
111
+ end: number;
112
+ kind: BusyKind;
113
+ }
114
+ /** Busy spans on one day of the calendar's clock, as the grid places time. */
115
+ export declare function blocksOnDay(spans: readonly BusySpan[], date: DateValue, timeZone: string): TimelineBlock[];
116
+ /** The quarter hour a click on the timeline lands on, keeping a slot inside the window. */
117
+ export declare function minuteAt(fraction: number, window: {
118
+ start: number;
119
+ end: number;
120
+ }, length: number, step?: number): number;
@@ -0,0 +1,149 @@
1
+ import { allDayDays as e, dayDifference as t, instantToZoned as n, startOfDayInZone as r, timedSegments as i, zonedTimeToInstant as a } from "../time/calendarTime.js";
2
+ import { canMoveOnGrid as o, eventRoom as s } from "../events/eventModel.js";
3
+ import { addDays as c } from "@burdenoff/fe-libs/ui";
4
+ // src/v2/event/findTime.ts
5
+ var l = 6e4, u = {
6
+ tentative: 0,
7
+ booked: 1,
8
+ busy: 2,
9
+ away: 3,
10
+ closed: 4
11
+ };
12
+ function d(e) {
13
+ let t = e.filter((e) => e.end > e.start).sort((e, t) => e.start - t.start || e.end - t.end), n = [];
14
+ for (let e of t) {
15
+ let t = n[n.length - 1];
16
+ t && e.start <= t.end ? n[n.length - 1] = {
17
+ start: t.start,
18
+ end: Math.max(t.end, e.end),
19
+ kind: u[e.kind] > u[t.kind] ? e.kind : t.kind
20
+ } : n.push({ ...e });
21
+ }
22
+ return n;
23
+ }
24
+ function f(e, t, n) {
25
+ return n <= t ? [...e] : e.flatMap((e) => {
26
+ if (e.end <= t || e.start >= n) return [e];
27
+ let r = [];
28
+ return e.start < t && r.push({
29
+ ...e,
30
+ end: t
31
+ }), e.end > n && r.push({
32
+ ...e,
33
+ start: n
34
+ }), r;
35
+ });
36
+ }
37
+ function p(t, n, i = null) {
38
+ let a = [];
39
+ for (let i of t.blocks) {
40
+ let t = i.kind === "OUT_OF_OFFICE" ? "away" : i.kind === "TENTATIVE" ? "tentative" : "busy";
41
+ if (!i.allDay) {
42
+ a.push({
43
+ start: i.start.getTime(),
44
+ end: i.end.getTime(),
45
+ kind: t
46
+ });
47
+ continue;
48
+ }
49
+ if (t !== "away") continue;
50
+ let o = e(i.start, i.end, { viewerTimeZone: n });
51
+ a.push({
52
+ start: r(o.start, n).getTime(),
53
+ end: r(c(o.end, 1), n).getTime(),
54
+ kind: t
55
+ });
56
+ }
57
+ return d(i ? f(a, i.start.getTime(), i.end.getTime()) : a);
58
+ }
59
+ function m(e, t, n, r) {
60
+ return e.bookable ? d(e.bookings.filter((e) => e.eventId !== r).map((t) => ({
61
+ start: t.start.getTime() - e.bufferAfter * l,
62
+ end: t.end.getTime() + e.bufferBefore * l,
63
+ kind: "booked"
64
+ }))) : [{
65
+ start: t.getTime(),
66
+ end: n.getTime(),
67
+ kind: "closed"
68
+ }];
69
+ }
70
+ function h(e, t, n) {
71
+ let r = t.getTime(), i = n.getTime();
72
+ return e.find((e) => e.start < i && e.end > r) ?? null;
73
+ }
74
+ function g(e, r) {
75
+ let i = e.workingHours(r);
76
+ if (!i) return [];
77
+ let o = [];
78
+ for (let s of i.spans) for (let i = Math.ceil(s.start / e.step) * e.step; i < s.end; i += e.step) {
79
+ let c = a(r, i, e.timeZone), u = n(c, e.timeZone);
80
+ if (u.date !== r || u.minutes !== i) continue;
81
+ let d = new Date(c.getTime() + e.length * l), f = n(d, e.timeZone);
82
+ t(r, f.date) * 1440 + f.minutes > s.end || c.getTime() < e.now.getTime() || o.push({
83
+ start: i,
84
+ startAt: c,
85
+ endAt: d
86
+ });
87
+ }
88
+ return o;
89
+ }
90
+ function _(e, t, n, r) {
91
+ let i = [], a = 0;
92
+ for (let t of e) h(t.busy, n, r) && (i.push(t.id), t.required && (a += 1));
93
+ return t && h(t.busy, n, r) && (i.push(t.id), a += 1), {
94
+ clashes: i,
95
+ requiredClashes: a
96
+ };
97
+ }
98
+ function v(e) {
99
+ let t = [];
100
+ for (let n = 0; n < e.days; n += 1) {
101
+ let r = c(e.day, n);
102
+ for (let i of g(e, r)) {
103
+ let a = _(e.people, e.room, i.startAt, i.endAt);
104
+ t.push({
105
+ suggestion: {
106
+ date: r,
107
+ ...i,
108
+ ...a
109
+ },
110
+ dayIndex: n
111
+ });
112
+ }
113
+ }
114
+ let n = (e, t) => e.startAt.getTime() - t.startAt.getTime(), r = t.map((e) => e.suggestion).filter((e) => e.clashes.length === 0).sort(n), i = t.filter((e) => e.suggestion.clashes.length > 0 && (r.length === 0 || e.dayIndex === 0)).map((e) => e.suggestion).sort((e, t) => e.requiredClashes - t.requiredClashes || e.clashes.length - t.clashes.length || n(e, t));
115
+ return [...r.slice(0, 3), ...i.slice(0, r.length === 0 ? 3 : 2)];
116
+ }
117
+ var y = 60;
118
+ function b(e, i, a) {
119
+ let o = n(e, a).date, s = n(new Date(Math.max(e.getTime(), i.getTime() - 1)), a).date;
120
+ return t(o, s) >= y && (s = c(o, 59)), {
121
+ from: r(o, a),
122
+ to: r(c(s, 1), a)
123
+ };
124
+ }
125
+ function x(e, t, n, r) {
126
+ let i = s(e);
127
+ return (i === null || i.status !== "APPROVED" && i.status !== "PENDING") && o(e, t, n, r);
128
+ }
129
+ function S(e) {
130
+ let t = Math.min(480, Math.floor((e?.start ?? 480) / 60) * 60), n = Math.max(1140, Math.ceil((e?.end ?? 1140) / 60) * 60);
131
+ return {
132
+ start: t,
133
+ end: Math.min(n, 1440)
134
+ };
135
+ }
136
+ function C(e, t, n) {
137
+ return e.flatMap((e) => i(new Date(e.start), new Date(e.end), n, t, t).map((t) => ({
138
+ start: t.startMinute,
139
+ end: t.endMinute,
140
+ kind: e.kind
141
+ })));
142
+ }
143
+ function w(e, t, n, r = 15) {
144
+ let i = t.start + Math.min(Math.max(e, 0), 1) * (t.end - t.start), a = Math.round(i / r) * r;
145
+ return Math.max(t.start, Math.min(a, t.end - n));
146
+ }
147
+ export { C as blocksOnDay, h as busyDuring, _ as clashesAt, b as freeBusyRangeFor, d as mergeSpans, w as minuteAt, x as movesDirectly, p as personBusySpans, m as roomBusySpans, v as suggestTimes, S as timelineWindow, f as withoutSpan };
148
+
149
+ //# sourceMappingURL=findTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findTime.js","names":["MINUTE_MS","KIND_RANK","mergeSpans","sorted","spans","span","a","b","merged","last","withoutSpan","end","start","parts","personBusySpans","block","person","kind","days","allDayDays","timeZone","startOfDayInZone","addDays","exclude","roomBusySpans","room","booking","ownEventId","from","to","busyDuring","slotsOn","hours","input","date","slots","minute","startAt","zonedTimeToInstant","reads","instantToZoned","endAt","dayDifference","clashesAt","clashes","requiredClashes","people","suggestTimes","candidates","dayIndex","slot","clash","byTime","free","item","near","MAX_RANGE_DAYS","freeBusyRangeFor","first","movesDirectly","eventRoom","event","canMoveOnGrid","calendar","me","timelineWindow","blocksOnDay","timedSegments","segment","minuteAt","raw","window","fraction","snapped","step","length"],"sources":["../../../src/v2/event/findTime.ts"],"sourcesContent":["/**\n * Find a time (BOFF-15698 A2): who is busy when, and the times that suit everyone. Pure.\n *\n * - People's busy time is free/busy (times only); a room's is its bookings, widened by the\n * room's buffers as the service checks them. All-day blocks count only when they are time\n * off: an all-day event (on call, a holiday) keeps nobody busy, as in the Day panel.\n * - Times are offered on the calendar's clock, every half hour inside the person's working\n * hours (their availability rules, as the grid shades them), from now on, for a week from\n * the chosen day. A clock time the clocks skip isn't offered; one they repeat is its first\n * pass. A length is real time, so on those mornings a slot ends earlier or later on the clock.\n * - Everyone free comes first (up to three, soonest first); then near misses on the chosen day\n * (on any day when nothing suits everyone), naming who can't make it: fewer required people\n * (the room is required) before more, then fewer people, then the earlier time.\n */\nimport { addDays, type DateValue } from '@burdenoff/fe-libs/ui';\nimport type { DayHours } from '../grid/workingHours';\nimport {\n allDayDays,\n dayDifference,\n instantToZoned,\n startOfDayInZone,\n timedSegments,\n zonedTimeToInstant,\n} from '../time/calendarTime';\nimport { canMoveOnGrid, eventRoom } from '../events/eventModel';\nimport type { CalendarEventV2, CalendarV2, PersonFreeBusyV2 } from '../types';\nimport type { RoomForEvent } from './place';\n\nconst MINUTE_MS = 60_000;\n\n/** `away`: time off. `booked`: a room's booking. `closed`: a room that takes no bookings. */\nexport type BusyKind = 'tentative' | 'busy' | 'away' | 'booked' | 'closed';\n\n/** A stretch of busy time, in epoch milliseconds. */\nexport interface BusySpan {\n start: number;\n end: number;\n kind: BusyKind;\n}\n\n/** Where overlapping kinds meet, the stronger one names the merged span. */\nconst KIND_RANK: Readonly<Record<BusyKind, number>> = {\n tentative: 0,\n booked: 1,\n busy: 2,\n away: 3,\n closed: 4,\n};\n\n/** Spans in time order, those that overlap or touch made one (named by the strongest kind). */\nexport function mergeSpans(spans: readonly BusySpan[]): BusySpan[] {\n const sorted = spans\n .filter((span) => span.end > span.start)\n .sort((a, b) => a.start - b.start || a.end - b.end);\n const merged: BusySpan[] = [];\n for (const span of sorted) {\n const last = merged[merged.length - 1];\n if (last && span.start <= last.end) {\n merged[merged.length - 1] = {\n start: last.start,\n end: Math.max(last.end, span.end),\n kind: KIND_RANK[span.kind] > KIND_RANK[last.kind] ? span.kind : last.kind,\n };\n } else {\n merged.push({ ...span });\n }\n }\n return merged;\n}\n\n/** `spans` without the time from `start` to `end` (an event's own time, when it is edited). */\nexport function withoutSpan(spans: readonly BusySpan[], start: number, end: number): BusySpan[] {\n if (end <= start) return [...spans];\n return spans.flatMap((span) => {\n if (span.end <= start || span.start >= end) return [span];\n const parts: BusySpan[] = [];\n if (span.start < start) parts.push({ ...span, end: start });\n if (span.end > end) parts.push({ ...span, start: end });\n return parts;\n });\n}\n\n/**\n * A person's busy time: their timed blocks, and their all-day time off as whole days on the\n * calendar's clock. `exclude`: an event's own time (the event being edited, for its organiser).\n */\nexport function personBusySpans(\n person: PersonFreeBusyV2,\n timeZone: string,\n exclude: { start: Date; end: Date } | null = null\n): BusySpan[] {\n const spans: BusySpan[] = [];\n for (const block of person.blocks) {\n const kind: BusyKind =\n block.kind === 'OUT_OF_OFFICE' ? 'away' : block.kind === 'TENTATIVE' ? 'tentative' : 'busy';\n if (!block.allDay) {\n spans.push({ start: block.start.getTime(), end: block.end.getTime(), kind });\n continue;\n }\n if (kind !== 'away') continue;\n const days = allDayDays(block.start, block.end, { viewerTimeZone: timeZone });\n spans.push({\n start: startOfDayInZone(days.start, timeZone).getTime(),\n end: startOfDayInZone(addDays(days.end, 1), timeZone).getTime(),\n kind,\n });\n }\n // The event's own time first goes from the raw blocks, so a block it touches keeps its edges.\n const own = exclude ? withoutSpan(spans, exclude.start.getTime(), exclude.end.getTime()) : spans;\n return mergeSpans(own);\n}\n\n/**\n * A room's busy time from `from` to `to`: all of it when closed, else its bookings, widened as\n * the service checks a new one (its window, less the buffer before and plus the buffer after,\n * may not touch a booking): a booking keeps the room from `bufferAfter` before it to\n * `bufferBefore` after it.\n */\nexport function roomBusySpans(\n room: RoomForEvent,\n from: Date,\n to: Date,\n ownEventId: string | null\n): BusySpan[] {\n if (!room.bookable) return [{ start: from.getTime(), end: to.getTime(), kind: 'closed' }];\n return mergeSpans(\n room.bookings\n .filter((booking) => booking.eventId !== ownEventId)\n .map((booking) => ({\n start: booking.start.getTime() - room.bufferAfter * MINUTE_MS,\n end: booking.end.getTime() + room.bufferBefore * MINUTE_MS,\n kind: 'booked' as const,\n }))\n );\n}\n\n/** The first busy span that overlaps `start`–`end`; null when that time is free. */\nexport function busyDuring(spans: readonly BusySpan[], start: Date, end: Date): BusySpan | null {\n const from = start.getTime();\n const to = end.getTime();\n return spans.find((span) => span.start < to && span.end > from) ?? null;\n}\n\nexport interface FindTimePerson {\n id: string;\n required: boolean;\n busy: readonly BusySpan[];\n}\n\nexport interface SuggestInput {\n /** The first day searched (the Day field). */\n day: DateValue;\n /** How many days to search from it. */\n days: number;\n /** The calendar's zone: slots are times on its clock. */\n timeZone: string;\n /** Minutes. */\n length: number;\n now: Date;\n /** Minutes between offered starts. */\n step: number;\n /** The person's working hours on a day (null: a day off). */\n workingHours: (date: DateValue) => DayHours | null;\n /** Everyone whose busy time is known (the person included). */\n people: readonly FindTimePerson[];\n room: { id: string; busy: readonly BusySpan[] } | null;\n}\n\nexport interface Suggestion {\n date: DateValue;\n /** Minutes after midnight on the calendar's clock. */\n start: number;\n startAt: Date;\n endAt: Date;\n /** Who can't make it: people's ids, and the room's when it is taken. */\n clashes: string[];\n /** Of `clashes`, the required people and the room. */\n requiredClashes: number;\n}\n\n/** Everyone free, offered at most. */\nexport const MAX_FREE_SUGGESTIONS = 3;\n/** Near misses on the chosen day, offered at most. */\nexport const MAX_NEAR_MISSES = 2;\n\n/** The times inside the working hours of `date` where a meeting of `length` fits. */\nfunction slotsOn(\n input: SuggestInput,\n date: DateValue\n): { start: number; startAt: Date; endAt: Date }[] {\n const hours = input.workingHours(date);\n if (!hours) return [];\n const slots: { start: number; startAt: Date; endAt: Date }[] = [];\n for (const span of hours.spans) {\n for (\n let minute = Math.ceil(span.start / input.step) * input.step;\n minute < span.end;\n minute += input.step\n ) {\n const startAt = zonedTimeToInstant(date, minute, input.timeZone);\n const reads = instantToZoned(startAt, input.timeZone);\n // A time the clocks skip reads as another: it isn't a real start.\n if (reads.date !== date || reads.minutes !== minute) continue;\n const endAt = new Date(startAt.getTime() + input.length * MINUTE_MS);\n const end = instantToZoned(endAt, input.timeZone);\n const endOnClock = dayDifference(date, end.date) * 1440 + end.minutes;\n if (endOnClock > span.end) continue;\n if (startAt.getTime() < input.now.getTime()) continue;\n slots.push({ start: minute, startAt, endAt });\n }\n }\n return slots;\n}\n\n/**\n * Who can't make `start`–`end`: the people's ids, and the room's when it is taken; and how many\n * of them count (the required people and the room).\n */\nexport function clashesAt(\n people: readonly FindTimePerson[],\n room: { id: string; busy: readonly BusySpan[] } | null,\n start: Date,\n end: Date\n): { clashes: string[]; requiredClashes: number } {\n const clashes: string[] = [];\n let requiredClashes = 0;\n for (const person of people) {\n if (!busyDuring(person.busy, start, end)) continue;\n clashes.push(person.id);\n if (person.required) requiredClashes += 1;\n }\n if (room && busyDuring(room.busy, start, end)) {\n clashes.push(room.id);\n requiredClashes += 1;\n }\n return { clashes, requiredClashes };\n}\n\n/** Times for a meeting: everyone free first, then near misses (see the module note). */\nexport function suggestTimes(input: SuggestInput): Suggestion[] {\n const candidates: { suggestion: Suggestion; dayIndex: number }[] = [];\n for (let dayIndex = 0; dayIndex < input.days; dayIndex += 1) {\n const date = addDays(input.day, dayIndex);\n for (const slot of slotsOn(input, date)) {\n const clash = clashesAt(input.people, input.room, slot.startAt, slot.endAt);\n candidates.push({ suggestion: { date, ...slot, ...clash }, dayIndex });\n }\n }\n const byTime = (a: Suggestion, b: Suggestion) => a.startAt.getTime() - b.startAt.getTime();\n const free = candidates\n .map((item) => item.suggestion)\n .filter((item) => item.clashes.length === 0)\n .sort(byTime);\n const near = candidates\n .filter(\n (item) => item.suggestion.clashes.length > 0 && (free.length === 0 || item.dayIndex === 0)\n )\n .map((item) => item.suggestion)\n .sort(\n (a, b) =>\n a.requiredClashes - b.requiredClashes || a.clashes.length - b.clashes.length || byTime(a, b)\n );\n return [\n ...free.slice(0, MAX_FREE_SUGGESTIONS),\n ...near.slice(0, free.length === 0 ? MAX_FREE_SUGGESTIONS : MAX_NEAR_MISSES),\n ];\n}\n\n/** The longest span the dialog asks free/busy about, in days (the service takes 62). */\nconst MAX_RANGE_DAYS = 60;\n\n/**\n * The whole days on the calendar's clock that an event (or a search) touches, as a free/busy\n * range: from the first day's start to the day after the last, at most 60 days.\n */\nexport function freeBusyRangeFor(\n start: Date,\n end: Date,\n timeZone: string\n): { from: Date; to: Date } {\n const first = instantToZoned(start, timeZone).date;\n let last = instantToZoned(new Date(Math.max(start.getTime(), end.getTime() - 1)), timeZone).date;\n if (dayDifference(first, last) >= MAX_RANGE_DAYS) last = addDays(first, MAX_RANGE_DAYS - 1);\n return {\n from: startOfDayInZone(first, timeZone),\n to: startOfDayInZone(addDays(last, 1), timeZone),\n };\n}\n\n/**\n * \"Find a better time\" moves the event itself (with Undo, as a drag does) when a drag could: a\n * one-day event the person may change that doesn't repeat. One with a room booked opens the\n * event dialog instead, whose save moves the booking too (a move alone would leave the room\n * booked at the old time).\n */\nexport function movesDirectly(\n event: CalendarEventV2,\n calendar: CalendarV2 | undefined,\n me: string | null,\n timeZone: string\n): boolean {\n const room = eventRoom(event);\n const booked = room !== null && (room.status === 'APPROVED' || room.status === 'PENDING');\n return !booked && canMoveOnGrid(event, calendar, me, timeZone);\n}\n\n// ── The timeline ─────────────────────────────────────────────────────────────\n\n/** The stretch of a day the timeline shows: at least 08:00 to 19:00, more if work runs longer. */\nexport function timelineWindow(hours: DayHours | null): { start: number; end: number } {\n const start = Math.min(8 * 60, Math.floor((hours?.start ?? 8 * 60) / 60) * 60);\n const end = Math.max(19 * 60, Math.ceil((hours?.end ?? 19 * 60) / 60) * 60);\n return { start, end: Math.min(end, 1440) };\n}\n\nexport interface TimelineBlock {\n /** Minutes on the day's clock face. */\n start: number;\n end: number;\n kind: BusyKind;\n}\n\n/** Busy spans on one day of the calendar's clock, as the grid places time. */\nexport function blocksOnDay(\n spans: readonly BusySpan[],\n date: DateValue,\n timeZone: string\n): TimelineBlock[] {\n return spans.flatMap((span) =>\n timedSegments(new Date(span.start), new Date(span.end), timeZone, date, date).map(\n (segment) => ({\n start: segment.startMinute,\n end: segment.endMinute,\n kind: span.kind,\n })\n )\n );\n}\n\n/** The quarter hour a click on the timeline lands on, keeping a slot inside the window. */\nexport function minuteAt(\n fraction: number,\n window: { start: number; end: number },\n length: number,\n step = 15\n): number {\n const raw = window.start + Math.min(Math.max(fraction, 0), 1) * (window.end - window.start);\n const snapped = Math.round(raw / step) * step;\n return Math.max(window.start, Math.min(snapped, window.end - length));\n}\n"],"mappings":";;;;AA4BA,IAAMA,IAAY,KAaZC,IAAgD;CACpD,WAAW;CACX,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ;AACV;AAGA,SAAgBC,EAAW,GAAwC;CACjE,IAAMC,IAASC,EACZ,QAAQ,MAASC,EAAK,MAAMA,EAAK,KAAK,CAAC,CACvC,MAAM,GAAG,MAAMC,EAAE,QAAQC,EAAE,SAASD,EAAE,MAAMC,EAAE,GAAG,GAC9CC,IAAqB,CAAC;CAC5B,KAAK,IAAMH,KAAQF,GAAQ;EACzB,IAAMM,IAAOD,EAAOA,EAAO,SAAS;EACpC,AAAIC,KAAQJ,EAAK,SAASI,EAAK,MAC7B,EAAOD,EAAO,SAAS,KAAK;GAC1B,OAAOC,EAAK;GACZ,KAAK,KAAK,IAAIA,EAAK,KAAKJ,EAAK,GAAG;GAChC,MAAMJ,EAAUI,EAAK,QAAQJ,EAAUQ,EAAK,QAAQJ,EAAK,OAAOI,EAAK;EACvE,IAEAD,EAAO,KAAK,EAAE,GAAGH,EAAK,CAAC;CAE3B;CACA,OAAOG;AACT;AAGA,SAAgBE,EAAY,GAA4B,GAAe,GAAyB;CAE9F,OADIC,KAAOC,IAAc,CAAC,GAAGR,CAAK,IAC3BA,EAAM,SAAS,MAAS;EAC7B,IAAIC,EAAK,OAAOO,KAASP,EAAK,SAASM,GAAK,OAAO,CAACN,CAAI;EACxD,IAAMQ,IAAoB,CAAC;EAG3B,OAFIR,EAAK,QAAQO,KAAOC,EAAM,KAAK;GAAE,GAAGR;GAAM,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CACzC,OAAO,KAAK,IAAIH,EAAO,OAAO,KAAK,IAAIE,GAASF,EAAO,MAAMI,CAAM,CAAC;AACtE"}
@@ -0,0 +1,102 @@
1
+ import { DateValue } from '@burdenoff/fe-libs/ui';
2
+ import { CalendarEventV2, CalendarV2, CalendarV2EventDraft } from '../types';
3
+ import { EventForm } from './eventForm';
4
+ import { BusySpan } from './findTime';
5
+ import { RoomForEvent } from './place';
6
+ /** A time picked: `start` minutes on the calendar's clock of `date`, lasting `length`. */
7
+ export interface PickedTime {
8
+ date: DateValue;
9
+ start: number;
10
+ length: number;
11
+ }
12
+ /** Where it opened, once what it looks at is in hand. */
13
+ export type FindTimeBasis = {
14
+ kind: 'form';
15
+ form: EventForm;
16
+ event: CalendarEventV2 | null;
17
+ } | {
18
+ kind: 'event';
19
+ event: CalendarEventV2;
20
+ } | {
21
+ kind: 'none';
22
+ };
23
+ export interface Participant {
24
+ /** `u:<userId>`, or `e:<email>` for someone outside the workspace. */
25
+ key: string;
26
+ userId: string | null;
27
+ name: string;
28
+ /** "Organiser", "Required", "Optional". */
29
+ role: string;
30
+ required: boolean;
31
+ }
32
+ /** The words a participant list needs, already translated. */
33
+ export interface ParticipantWords {
34
+ you: string;
35
+ organiser: string;
36
+ required: string;
37
+ optional: string;
38
+ guest: string;
39
+ }
40
+ /** The person first (as organiser), then the guests: each once. */
41
+ export declare function participantsOf(basis: FindTimeBasis, me: string | null, words: ParticipantWords): Participant[];
42
+ /** The room the time is for: the form's (not for all day), or the event's booked one. */
43
+ export declare function roomIdOf(basis: FindTimeBasis): string | null;
44
+ /** The booked room's name, from the event's booking (for a room the rooms list no longer has). */
45
+ export declare function bookedRoomNameOf(basis: FindTimeBasis): string | null;
46
+ /** The room's row in Find a time. */
47
+ export interface FindTimeRoom {
48
+ /** `room:<id>`, never a person's key. */
49
+ id: string;
50
+ name: string;
51
+ busy: BusySpan[];
52
+ }
53
+ /**
54
+ * The room the time is for, as Find a time weighs it: its bookings (its buffers counted, the
55
+ * event's own left out); nothing while the rooms load; and one the rooms list no longer has
56
+ * (deleted, or closed down) busy all along, so no time is called free with it.
57
+ */
58
+ export declare function findTimeRoomOf(roomId: string | null, rooms: {
59
+ rooms: readonly RoomForEvent[];
60
+ status: string;
61
+ }, name: string, range: {
62
+ from: Date;
63
+ to: Date;
64
+ }, ownEventId: string | null): FindTimeRoom | null;
65
+ /** The length to start with: the event's own (15 minutes to 8 hours), else an hour. */
66
+ export declare function startLengthOf(basis: FindTimeBasis): number;
67
+ /**
68
+ * The day to start on, on the calendar's clock: the event's (an all-day one's first day, not
69
+ * its stored UTC midnight), never before today.
70
+ */
71
+ export declare function startDayOf(basis: FindTimeBasis, timeZone: string, today: DateValue): DateValue;
72
+ /**
73
+ * A pick's end on its day's clock (past 1440, the next day's): its start's instant plus its
74
+ * length, so a time across a change of the clocks ends where the clock says.
75
+ */
76
+ export declare function pickEndClock(time: PickedTime, timeZone: string): number;
77
+ /** What "Use this time" does. */
78
+ export type PickStep =
79
+ /** Back to the event dialog, its form at the time. */
80
+ {
81
+ kind: 'fillForm';
82
+ form: EventForm;
83
+ }
84
+ /** The event moves there (with Undo, as a drag does). */
85
+ | {
86
+ kind: 'move';
87
+ event: CalendarEventV2;
88
+ start: Date;
89
+ end: Date;
90
+ }
91
+ /** The event dialog opens with the time: the event's, or a new one. */
92
+ | {
93
+ kind: 'openDialog';
94
+ draft: CalendarV2EventDraft;
95
+ };
96
+ /**
97
+ * What "Use this time" does, from where Find a time opened: from the event dialog the time fills
98
+ * its form; from an event's peek the event moves there when a drag could move it (`movesDirectly`)
99
+ * and otherwise the event dialog opens with the time, to ask what it must and move the room too;
100
+ * from ⋯ a new event starts there. `calendar` is the event's.
101
+ */
102
+ export declare function stepForPick(time: PickedTime, basis: FindTimeBasis, calendar: CalendarV2 | undefined, me: string | null, timeZone: string): PickStep;
@@ -0,0 +1,107 @@
1
+ import { eventRoom as e } from "../events/eventModel.js";
2
+ import { dayDifference as t, eventDays as n, instantToZoned as r, zonedTimeToInstant as i } from "../time/calendarTime.js";
3
+ import { lengthMinutes as a, startInstant as o, withSlot as s } from "./eventForm.js";
4
+ import { movesDirectly as c, roomBusySpans as l } from "./findTime.js";
5
+ // src/v2/event/findTimeSource.ts
6
+ function u(e) {
7
+ if (e.kind === "form") return e.form.guests;
8
+ if (e.kind === "none") return [];
9
+ let t = e.event;
10
+ return t.guests.filter((e) => !e.organizer && e.userId !== t.organizerId);
11
+ }
12
+ function d(e, t, n) {
13
+ let r = t ? [{
14
+ key: `u:${t}`,
15
+ userId: t,
16
+ name: n.you,
17
+ role: n.organiser,
18
+ required: !0
19
+ }] : [];
20
+ for (let i of u(e)) i.userId && i.userId === t || r.push({
21
+ key: i.userId ? `u:${i.userId}` : `e:${i.email ?? ""}`,
22
+ userId: i.userId,
23
+ name: i.name ?? i.email ?? n.guest,
24
+ role: i.optional ? n.optional : n.required,
25
+ required: !i.optional
26
+ });
27
+ return r;
28
+ }
29
+ function f(t) {
30
+ if (t.kind === "form") return t.form.allDay ? null : t.form.roomId;
31
+ if (t.kind === "none") return null;
32
+ let n = e(t.event);
33
+ return n && (n.status === "APPROVED" || n.status === "PENDING") ? n.resourceId : null;
34
+ }
35
+ function p(t) {
36
+ let n = t.kind === "none" ? null : t.event, r = n ? e(n) : null;
37
+ return r && r.resourceId === f(t) ? r.name : null;
38
+ }
39
+ function m(e, t, n, r, i) {
40
+ if (e === null) return null;
41
+ let a = t.rooms.find((t) => t.id === e);
42
+ if (a) return {
43
+ id: `room:${a.id}`,
44
+ name: a.name,
45
+ busy: l(a, r.from, r.to, i)
46
+ };
47
+ if (t.status !== "ready") return null;
48
+ let o = {
49
+ start: r.from.getTime(),
50
+ end: r.to.getTime(),
51
+ kind: "closed"
52
+ };
53
+ return {
54
+ id: `room:${e}`,
55
+ name: n,
56
+ busy: [o]
57
+ };
58
+ }
59
+ function h(e) {
60
+ let t = 60;
61
+ return e.kind === "form" && !e.form.allDay && (t = a(e.form)), e.kind === "event" && !e.event.allDay && (t = Math.round((e.event.end.getTime() - e.event.start.getTime()) / 6e4)), t >= 15 && t <= 480 ? t : 60;
62
+ }
63
+ function g(e, t, i) {
64
+ let a = i;
65
+ return e.kind === "form" ? a = e.form.allDay ? e.form.firstDay : r(o(e.form), t).date : e.kind === "event" && (a = e.event.allDay ? n(e.event, t).start : r(e.event.start, t).date), a < i ? i : a;
66
+ }
67
+ function _(e, n) {
68
+ let a = i(e.date, e.start, n), o = r(new Date(a.getTime() + e.length * 6e4), n);
69
+ return t(e.date, o.date) * 1440 + o.minutes;
70
+ }
71
+ function v(e, t, n, r, a) {
72
+ if (t.kind === "form") return {
73
+ kind: "fillForm",
74
+ form: s(t.form, {
75
+ ...e,
76
+ timeZone: a
77
+ })
78
+ };
79
+ let o = i(e.date, e.start, a), l = new Date(o.getTime() + e.length * 6e4), u = _(e, a);
80
+ if (t.kind === "none") return {
81
+ kind: "openDialog",
82
+ draft: {
83
+ date: e.date,
84
+ start: e.start,
85
+ end: u,
86
+ allDay: !1
87
+ }
88
+ };
89
+ let d = t.event;
90
+ return c(d, n, r, a) ? {
91
+ kind: "move",
92
+ event: d,
93
+ start: o,
94
+ end: l
95
+ } : {
96
+ kind: "openDialog",
97
+ draft: {
98
+ eventId: d.id,
99
+ date: e.date,
100
+ start: e.start,
101
+ end: u
102
+ }
103
+ };
104
+ }
105
+ export { p as bookedRoomNameOf, m as findTimeRoomOf, d as participantsOf, _ as pickEndClock, f as roomIdOf, g as startDayOf, h as startLengthOf, v as stepForPick };
106
+
107
+ //# sourceMappingURL=findTimeSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findTimeSource.js","names":["guestsOf","basis","event","guest","participantsOf","list","me","words","roomIdOf","booking","eventRoom","bookedRoomNameOf","findTimeRoomOf","roomId","room","rooms","item","roomBusySpans","range","ownEventId","always","startLengthOf","length","lengthMinutes","startDayOf","day","today","instantToZoned","startInstant","timeZone","eventDays","pickEndClock","start","zonedTimeToInstant","time","end","dayDifference","stepForPick","withSlot","endAt","movesDirectly","calendar"],"sources":["../../../src/v2/event/findTimeSource.ts"],"sourcesContent":["/**\n * Who and what Find a time looks at (BOFF-15698 A2), from where it opened: the event dialog's\n * form, an event's peek, or the page's ⋯ menu. Pure.\n */\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { eventRoom } from '../events/eventModel';\nimport { dayDifference, eventDays, instantToZoned, zonedTimeToInstant } from '../time/calendarTime';\nimport type { CalendarEventV2, CalendarV2, CalendarV2EventDraft } from '../types';\nimport { lengthMinutes, startInstant, withSlot, type EventForm } from './eventForm';\nimport { movesDirectly, roomBusySpans, type BusySpan } from './findTime';\nimport type { RoomForEvent } from './place';\n\n/** A time picked: `start` minutes on the calendar's clock of `date`, lasting `length`. */\nexport interface PickedTime {\n date: DateValue;\n start: number;\n length: number;\n}\n\n/** Where it opened, once what it looks at is in hand. */\nexport type FindTimeBasis =\n | { kind: 'form'; form: EventForm; event: CalendarEventV2 | null }\n | { kind: 'event'; event: CalendarEventV2 }\n | { kind: 'none' };\n\nexport interface Participant {\n /** `u:<userId>`, or `e:<email>` for someone outside the workspace. */\n key: string;\n userId: string | null;\n name: string;\n /** \"Organiser\", \"Required\", \"Optional\". */\n role: string;\n required: boolean;\n}\n\n/** The words a participant list needs, already translated. */\nexport interface ParticipantWords {\n you: string;\n organiser: string;\n required: string;\n optional: string;\n guest: string;\n}\n\ninterface GuestLike {\n userId: string | null;\n email: string | null;\n name: string | null;\n optional: boolean;\n}\n\nfunction guestsOf(basis: FindTimeBasis): GuestLike[] {\n if (basis.kind === 'form') return basis.form.guests;\n if (basis.kind === 'none') return [];\n const event = basis.event;\n return event.guests.filter((guest) => !guest.organizer && guest.userId !== event.organizerId);\n}\n\n/** The person first (as organiser), then the guests: each once. */\nexport function participantsOf(\n basis: FindTimeBasis,\n me: string | null,\n words: ParticipantWords\n): Participant[] {\n const list: Participant[] = me\n ? [{ key: `u:${me}`, userId: me, name: words.you, role: words.organiser, required: true }]\n : [];\n for (const guest of guestsOf(basis)) {\n if (guest.userId && guest.userId === me) continue;\n list.push({\n key: guest.userId ? `u:${guest.userId}` : `e:${guest.email ?? ''}`,\n userId: guest.userId,\n name: guest.name ?? guest.email ?? words.guest,\n role: guest.optional ? words.optional : words.required,\n required: !guest.optional,\n });\n }\n return list;\n}\n\n/** The room the time is for: the form's (not for all day), or the event's booked one. */\nexport function roomIdOf(basis: FindTimeBasis): string | null {\n if (basis.kind === 'form') return basis.form.allDay ? null : basis.form.roomId;\n if (basis.kind === 'none') return null;\n const booking = eventRoom(basis.event);\n return booking && (booking.status === 'APPROVED' || booking.status === 'PENDING')\n ? booking.resourceId\n : null;\n}\n\n/** The booked room's name, from the event's booking (for a room the rooms list no longer has). */\nexport function bookedRoomNameOf(basis: FindTimeBasis): string | null {\n const event = basis.kind === 'none' ? null : basis.event;\n const booking = event ? eventRoom(event) : null;\n return booking && booking.resourceId === roomIdOf(basis) ? booking.name : null;\n}\n\n/** The room's row in Find a time. */\nexport interface FindTimeRoom {\n /** `room:<id>`, never a person's key. */\n id: string;\n name: string;\n busy: BusySpan[];\n}\n\n/**\n * The room the time is for, as Find a time weighs it: its bookings (its buffers counted, the\n * event's own left out); nothing while the rooms load; and one the rooms list no longer has\n * (deleted, or closed down) busy all along, so no time is called free with it.\n */\nexport function findTimeRoomOf(\n roomId: string | null,\n rooms: { rooms: readonly RoomForEvent[]; status: string },\n name: string,\n range: { from: Date; to: Date },\n ownEventId: string | null\n): FindTimeRoom | null {\n if (roomId === null) return null;\n const room = rooms.rooms.find((item) => item.id === roomId);\n if (room) {\n return {\n id: `room:${room.id}`,\n name: room.name,\n busy: roomBusySpans(room, range.from, range.to, ownEventId),\n };\n }\n if (rooms.status !== 'ready') return null;\n const always: BusySpan = { start: range.from.getTime(), end: range.to.getTime(), kind: 'closed' };\n return { id: `room:${roomId}`, name, busy: [always] };\n}\n\n/** The length to start with: the event's own (15 minutes to 8 hours), else an hour. */\nexport function startLengthOf(basis: FindTimeBasis): number {\n let length = 60;\n if (basis.kind === 'form' && !basis.form.allDay) length = lengthMinutes(basis.form);\n if (basis.kind === 'event' && !basis.event.allDay) {\n length = Math.round((basis.event.end.getTime() - basis.event.start.getTime()) / 60_000);\n }\n return length >= 15 && length <= 8 * 60 ? length : 60;\n}\n\n/**\n * The day to start on, on the calendar's clock: the event's (an all-day one's first day, not\n * its stored UTC midnight), never before today.\n */\nexport function startDayOf(basis: FindTimeBasis, timeZone: string, today: DateValue): DateValue {\n let day = today;\n if (basis.kind === 'form') {\n day = basis.form.allDay\n ? basis.form.firstDay\n : instantToZoned(startInstant(basis.form), timeZone).date;\n } else if (basis.kind === 'event') {\n day = basis.event.allDay\n ? eventDays(basis.event, timeZone).start\n : instantToZoned(basis.event.start, timeZone).date;\n }\n return day < today ? today : day;\n}\n\n/**\n * A pick's end on its day's clock (past 1440, the next day's): its start's instant plus its\n * length, so a time across a change of the clocks ends where the clock says.\n */\nexport function pickEndClock(time: PickedTime, timeZone: string): number {\n const start = zonedTimeToInstant(time.date, time.start, timeZone);\n const end = instantToZoned(new Date(start.getTime() + time.length * 60_000), timeZone);\n return dayDifference(time.date, end.date) * 1440 + end.minutes;\n}\n\n/** What \"Use this time\" does. */\nexport type PickStep =\n /** Back to the event dialog, its form at the time. */\n | { kind: 'fillForm'; form: EventForm }\n /** The event moves there (with Undo, as a drag does). */\n | { kind: 'move'; event: CalendarEventV2; start: Date; end: Date }\n /** The event dialog opens with the time: the event's, or a new one. */\n | { kind: 'openDialog'; draft: CalendarV2EventDraft };\n\n/**\n * What \"Use this time\" does, from where Find a time opened: from the event dialog the time fills\n * its form; from an event's peek the event moves there when a drag could move it (`movesDirectly`)\n * and otherwise the event dialog opens with the time, to ask what it must and move the room too;\n * from ⋯ a new event starts there. `calendar` is the event's.\n */\nexport function stepForPick(\n time: PickedTime,\n basis: FindTimeBasis,\n calendar: CalendarV2 | undefined,\n me: string | null,\n timeZone: string\n): PickStep {\n if (basis.kind === 'form') {\n return { kind: 'fillForm', form: withSlot(basis.form, { ...time, timeZone }) };\n }\n const start = zonedTimeToInstant(time.date, time.start, timeZone);\n const endAt = new Date(start.getTime() + time.length * 60_000);\n // A draft's end is a time on its day's clock, so a time across a change of the clocks keeps\n // its length.\n const end = pickEndClock(time, timeZone);\n if (basis.kind === 'none') {\n return {\n kind: 'openDialog',\n draft: { date: time.date, start: time.start, end, allDay: false },\n };\n }\n const event = basis.event;\n if (movesDirectly(event, calendar, me, timeZone)) {\n return { kind: 'move', event, start, end: endAt };\n }\n return {\n kind: 'openDialog',\n draft: { eventId: event.id, date: time.date, start: time.start, end },\n };\n}\n"],"mappings":";;;;;AAmDA,SAASA,EAAS,GAAmC;CACnD,IAAIC,EAAM,SAAS,QAAQ,OAAOA,EAAM,KAAK;CAC7C,IAAIA,EAAM,SAAS,QAAQ,OAAO,CAAC;CACnC,IAAMC,IAAQD,EAAM;CACpB,OAAOC,EAAM,OAAO,QAAQ,MAAU,CAACC,EAAM,aAAaA,EAAM,WAAWD,EAAM,WAAW;AAC9F;AAGA,SAAgBE,EACd,GACA,GACA,GACe;CACf,IAAMC,IAAsBC,IACxB,CAAC;EAAE,KAAK,KAAKA;EAAM,QAAQA;EAAI,MAAMC,EAAM;EAAK,MAAMA,EAAM;EAAW,UAAU;CAAK,CAAC,IACvF,CAAC;CACL,KAAK,IAAMJ,KAASH,EAASC,CAAK,GAChC,AAAIE,EAAM,UAAUA,EAAM,WAAWG,KACrCD,EAAK,KAAK;EACR,KAAKF,EAAM,SAAS,KAAKA,EAAM,WAAW,KAAKA,EAAM,SAAS;EAC9D,QAAQA,EAAM;EACd,MAAMA,EAAM,QAAQA,EAAM,SAASI,EAAM;EACzC,MAAMJ,EAAM,WAAWI,EAAM,WAAWA,EAAM;EAC9C,UAAU,CAACJ,EAAM;CACnB,CAAC;CAEH,OAAOE;AACT;AAGA,SAAgBG,EAAS,GAAqC;CAC5D,IAAIP,EAAM,SAAS,QAAQ,OAAOA,EAAM,KAAK,SAAS,OAAOA,EAAM,KAAK;CACxE,IAAIA,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