@algorisys/zen-ui-vanilla 13.10.1 → 13.11.1

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 (106) hide show
  1. package/AGENTS.md +2 -2
  2. package/dist/_core/index.d.ts +1 -0
  3. package/dist/_core/messages-all.d.ts +5 -0
  4. package/dist/_core/messages.d.ts +5 -0
  5. package/dist/_core/planning-gesture.d.ts +31 -0
  6. package/dist/_core/planning.d.ts +71 -9
  7. package/dist/components/data-table/data-table.d.ts.map +1 -1
  8. package/dist/components/event-calendar/event-calendar-item.d.ts.map +1 -1
  9. package/dist/components/event-calendar/event-calendar-model.d.ts +6 -0
  10. package/dist/components/event-calendar/event-calendar-model.d.ts.map +1 -1
  11. package/dist/components/planning-calendar/planning-calendar.d.ts +65 -3
  12. package/dist/components/planning-calendar/planning-calendar.d.ts.map +1 -1
  13. package/dist/components/rich-text/rich-text.d.ts +5 -7
  14. package/dist/components/rich-text/rich-text.d.ts.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index108.js +12 -4
  18. package/dist/index108.js.map +1 -1
  19. package/dist/index112.js +244 -144
  20. package/dist/index112.js.map +1 -1
  21. package/dist/index113.js +6 -6
  22. package/dist/index114.js +1 -1
  23. package/dist/index115.js +1 -1
  24. package/dist/index116.js +1 -1
  25. package/dist/index118.js +2 -2
  26. package/dist/index120.js +2 -2
  27. package/dist/index168.js +1 -1
  28. package/dist/index175.js +1 -1
  29. package/dist/index187.js +1 -1
  30. package/dist/index191.js +1 -1
  31. package/dist/index194.js +2 -2
  32. package/dist/index199.js +1 -1
  33. package/dist/index211.js +5 -0
  34. package/dist/index211.js.map +1 -1
  35. package/dist/index230.js +107 -75
  36. package/dist/index230.js.map +1 -1
  37. package/dist/index231.js +95 -7
  38. package/dist/index231.js.map +1 -1
  39. package/dist/index232.js +7 -48
  40. package/dist/index232.js.map +1 -1
  41. package/dist/index233.js +45 -37
  42. package/dist/index233.js.map +1 -1
  43. package/dist/index234.js +38 -149
  44. package/dist/index234.js.map +1 -1
  45. package/dist/index235.js +138 -177
  46. package/dist/index235.js.map +1 -1
  47. package/dist/index236.js +190 -90
  48. package/dist/index236.js.map +1 -1
  49. package/dist/index237.js +90 -444
  50. package/dist/index237.js.map +1 -1
  51. package/dist/index238.js +436 -98
  52. package/dist/index238.js.map +1 -1
  53. package/dist/index239.js +106 -2
  54. package/dist/index239.js.map +1 -1
  55. package/dist/index240.js +2 -18804
  56. package/dist/index240.js.map +1 -1
  57. package/dist/index241.js +18798 -117
  58. package/dist/index241.js.map +1 -1
  59. package/dist/index242.js +122 -13
  60. package/dist/index242.js.map +1 -1
  61. package/dist/index243.js +13 -3012
  62. package/dist/index243.js.map +1 -1
  63. package/dist/index244.js +3006 -123
  64. package/dist/index244.js.map +1 -1
  65. package/dist/index245.js +125 -140
  66. package/dist/index245.js.map +1 -1
  67. package/dist/index246.js +138 -93
  68. package/dist/index246.js.map +1 -1
  69. package/dist/index247.js +91 -104
  70. package/dist/index247.js.map +1 -1
  71. package/dist/index248.js +95 -111
  72. package/dist/index248.js.map +1 -1
  73. package/dist/index249.js +127 -4
  74. package/dist/index249.js.map +1 -1
  75. package/dist/index250.js +5 -34
  76. package/dist/index250.js.map +1 -1
  77. package/dist/index251.js +34 -9
  78. package/dist/index251.js.map +1 -1
  79. package/dist/index252.js +10 -7
  80. package/dist/index252.js.map +1 -1
  81. package/dist/index253.js +6 -15
  82. package/dist/index253.js.map +1 -1
  83. package/dist/index254.js +15 -11
  84. package/dist/index254.js.map +1 -1
  85. package/dist/index255.js +11 -3
  86. package/dist/index255.js.map +1 -1
  87. package/dist/index256.js +7 -0
  88. package/dist/index256.js.map +1 -0
  89. package/dist/index99.js.map +1 -1
  90. package/dist/previews/analytic-chart.jpg +0 -0
  91. package/dist/previews/chunk-uploader.jpg +0 -0
  92. package/dist/previews/code-editor.jpg +0 -0
  93. package/dist/previews/countdown.jpg +0 -0
  94. package/dist/previews/loading.jpg +0 -0
  95. package/dist/previews/map.jpg +0 -0
  96. package/dist/previews/tile.jpg +0 -0
  97. package/dist/style.css +1 -1
  98. package/package.json +1 -1
  99. package/skills/zen-ui/SKILL.md +1 -1
  100. package/skills/zen-ui/references/api/event-calendar-event-calendar.md +1 -0
  101. package/skills/zen-ui/references/api/index.md +1 -1
  102. package/skills/zen-ui/references/api/locale.md +5 -0
  103. package/skills/zen-ui/references/api/planning-calendar.md +30 -1
  104. package/skills/zen-ui/references/api/rich-text.md +1 -1
  105. package/skills/zen-ui/references/api/scan-input.md +1 -1
  106. package/skills/zen-ui/references/catalogue.md +2 -2
package/dist/index233.js CHANGED
@@ -1,43 +1,51 @@
1
- import { cn as r } from "./index194.js";
2
- const f = {
3
- default: "zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary",
4
- info: "zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info",
5
- success: "zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success",
6
- warning: "zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning",
7
- error: "zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error"
8
- }, g = {
9
- default: "zen-bg-zen-primary",
10
- info: "zen-bg-zen-info",
11
- success: "zen-bg-zen-success",
12
- warning: "zen-bg-zen-warning",
13
- error: "zen-bg-zen-error"
14
- }, s = "zen-opacity-40", z = "zen-bg-zen-primary-soft", i = (n) => !!n && getComputedStyle(n).direction === "rtl", a = (n, e) => n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate(), l = (n, e, t) => {
15
- const o = document.createElement(n);
16
- return e && (o.className = e), t !== void 0 && (o.textContent = t), o;
17
- };
18
- function u(n, e, t) {
19
- !e || t === "chip" || t === "row" || (n.style.backgroundColor = `color-mix(in srgb, ${e} 18%, var(--zen-color-background))`, n.style.borderColor = e, n.style.color = "var(--zen-color-foreground)");
20
- }
21
- function b(n, e) {
22
- for (const t of n) {
23
- const o = e !== null && t.day >= e.start && t.day < e.end;
24
- t.node.className = r(t.base, o && z);
1
+ import { agendaGroups as p, eventCalendarRange as m } from "./index117.js";
2
+ import { toNodes as l } from "./index195.js";
3
+ import { eventItem as f } from "./index245.js";
4
+ import { el as o, sameDay as u, markMoving as c } from "./index234.js";
5
+ import { cn as i } from "./index194.js";
6
+ function b(n, z, d) {
7
+ const s = o("ul", "zen-m-0 zen-flex zen-list-none zen-flex-col zen-gap-0.5 zen-p-0");
8
+ for (const t of d) {
9
+ const e = z[t.index], r = o("li", "zen-flex zen-min-w-0 zen-items-center zen-gap-3 zen-rounded-zen-sm hover:zen-bg-zen-muted"), a = o(
10
+ "span",
11
+ "zen-w-32 zen-shrink-0 zen-ps-1.5 zen-text-xs zen-tabular-nums zen-text-zen-muted-fg",
12
+ t.allDay ? n.loc.t("eventCalendar.allDay") : n.timeLabel(e)
13
+ );
14
+ a.setAttribute("aria-hidden", "true"), r.append(
15
+ a,
16
+ f(n, e, {
17
+ variant: "row",
18
+ continuesBefore: t.continuesBefore,
19
+ continuesAfter: t.continuesAfter,
20
+ class: "zen-min-h-8 zen-flex-1"
21
+ })
22
+ ), s.append(r);
25
23
  }
24
+ return s;
26
25
  }
27
- function d(n, e) {
28
- for (const t of n.querySelectorAll("[data-cal-event]"))
29
- t.classList.toggle(s, e !== void 0 && t.getAttribute("data-cal-event") === e);
26
+ function w(n) {
27
+ const z = n.props.events ?? [], d = p(z, m("agenda", n.anchor, n.options)), s = (e) => new Intl.DateTimeFormat(n.loc.locale, { weekday: "long", day: "numeric", month: "long" }).format(e), t = o("div", "zen-rounded-zen-md zen-border zen-border-zen-border");
28
+ if (d.length === 0) {
29
+ const e = o("p", "zen-m-0 zen-py-10 zen-text-center zen-text-sm zen-text-zen-muted-fg");
30
+ e.append(...l(n.props.emptyMessage ?? n.loc.t("eventCalendar.noEvents"))), t.append(e);
31
+ }
32
+ for (const e of d) {
33
+ const r = o(
34
+ "section",
35
+ i("zen-flex zen-flex-col zen-gap-1 zen-border-b zen-border-zen-border zen-px-3 zen-py-2 last:zen-border-b-0", n.props.dayClassName?.(e.date))
36
+ );
37
+ r.setAttribute("aria-label", s(e.date));
38
+ const a = o(
39
+ "p",
40
+ i("zen-m-0 zen-text-sm zen-font-semibold", u(e.date, n.now) ? "zen-text-zen-primary" : "zen-text-zen-foreground"),
41
+ s(e.date)
42
+ );
43
+ a.setAttribute("aria-hidden", "true"), r.append(a, b(n, z, e.items)), t.append(r);
44
+ }
45
+ return { el: t, applyPreview: (e) => c(n.root, e?.eventId) };
30
46
  }
31
47
  export {
32
- g as DOT_CLASS,
33
- z as LIT_CLASS,
34
- s as MOVING_CLASS,
35
- f as STATE_CLASS,
36
- u as applyCustomColor,
37
- l as el,
38
- i as isRtl,
39
- d as markMoving,
40
- b as relight,
41
- a as sameDay
48
+ w as agenda,
49
+ b as dayList
42
50
  };
43
51
  //# sourceMappingURL=index233.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index233.js","sources":["../src/components/event-calendar/event-calendar-model.ts"],"sourcesContent":["import type {\n CalendarProposedSpan,\n EventCalendarOptions,\n SlotCursor,\n EventCalendarView,\n Weekday,\n} from \"@algorisys/zen-ui-core/event-calendar\";\nimport type { Density } from \"@algorisys/zen-ui-core/density\";\nimport { cn } from \"../../lib/cn\";\nimport type { AnyZenComponent, BaseProps, Child } from \"../../lib/component\";\nimport type { useLocale } from \"../locale/locale\";\n\nexport type CalendarEventState = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport interface CalendarEvent {\n id: string;\n title: string;\n start: Date;\n /** Exclusive. For an all-day event, the first day NOT included (or the same day for a one-day event). */\n end: Date;\n allDay?: boolean;\n /** Token colour. \"default\" is the primary tint. */\n state?: CalendarEventState;\n /** Any CSS colour; wins over `state`. For a per-calendar colour from your own map. */\n color?: string;\n location?: string;\n /** Minutes before the start. Shown as a mark; zen-ui does not fire reminders. */\n reminders?: number[];\n /** Shown as a mark. Expand the occurrences before passing them (see `expandRecurrence`). */\n recurring?: boolean;\n /** \"task\" draws a checkbox; `done` strikes it through. */\n kind?: \"event\" | \"task\";\n done?: boolean;\n /** Never offered for moving or resizing, whatever `canEditEvent` says. */\n readOnly?: boolean;\n}\n\nexport interface CalendarSlot {\n start: Date;\n /** Exclusive. */\n end: Date;\n allDay: boolean;\n}\n\nexport interface CalendarEventChange {\n /** The event as you passed it. */\n event: CalendarEvent;\n start: Date;\n end: Date;\n allDay: boolean;\n kind: \"move\" | \"resize\";\n}\n\nexport type CalendarEventVariant = \"block\" | \"bar\" | \"chip\" | \"row\";\n\nexport interface CalendarEventRenderContext {\n view: EventCalendarView;\n /** \"block\" in a time grid, \"bar\" for multi-day and all-day, \"chip\" for a timed event in a month cell, \"row\" in lists. */\n variant: CalendarEventVariant;\n /** \"09:00 – 10:30\" or the localised \"All day\". */\n timeLabel: string;\n /** Too short for a second line. */\n compact: boolean;\n}\n\nexport interface EventCalendarProps extends BaseProps {\n events: CalendarEvent[];\n /** Starting view. The factory owns it after that; pass `view` (or call update) to control it. Default \"week\". */\n defaultView?: EventCalendarView;\n view?: EventCalendarView;\n onViewChange?: (view: EventCalendarView) => void;\n /** Which views the switcher offers, in order. Default month, week, day, agenda. */\n views?: EventCalendarView[];\n /** Any date inside the range to open on. Default today. */\n defaultDate?: Date;\n date?: Date;\n onDateChange?: (date: Date) => void;\n /** Reference \"now\" for today and the now line. Injectable for tests and demos. */\n now?: Date;\n /** First column of a week. Default 1 (Monday). */\n weekStartsOn?: Weekday;\n /** Shaded, and left out of the work-week view. Default [0, 6]. */\n nonWorkingDays?: number[];\n /** [from, to) hours drawn unshaded in the time grid. Default [9, 18]. */\n workingHours?: [number, number];\n /** Days shown by the agenda. Default 14. */\n agendaDays?: number;\n /** Hour scrolled to the top of the time grid when it opens. Default 8. */\n scrollToHour?: number;\n /** Pixels per hour in the time grid. Wins over `density`. */\n hourHeight?: number;\n /** \"compact\", \"comfortable\" (default) or \"touch\" (44px rows, 64px hours). */\n density?: Density;\n /** Height of the time grid's scrolling area in px. Default 576. */\n height?: number;\n /** Minutes a drag snaps to, and a keyboard step. Default 15. */\n snapMinutes?: number;\n /** Length of the slot a single click selects. Default 60. */\n newEventMinutes?: number;\n /** Rows of events in a month cell before \"+N more\". Default 3. */\n maxEventsPerDay?: number;\n onEventClick?: (event: CalendarEvent) => void;\n /** Empty time was clicked or dragged across. Without it, empty time is not interactive. */\n onSlotSelect?: (slot: CalendarSlot) => void;\n /** A move or resize, proposed. Nothing changes until you pass back new `events`. Without it the calendar is read-only. */\n onEventChange?: (change: CalendarEventChange) => void;\n /** Per-event gate for editing. A blocked event is not draggable at all, rather than refused on drop. */\n canEditEvent?: (event: CalendarEvent) => boolean;\n /** A task's checkbox was toggled. Without it the checkbox is shown but disabled. */\n onTaskToggle?: (event: CalendarEvent, done: boolean) => void;\n /** Replace an event's content (title, time, marks). The calendar keeps the box, the colour and the controls. */\n renderEvent?: (event: CalendarEvent, context: CalendarEventRenderContext) => Child;\n /** Extra classes on an event's box. */\n eventClassName?: (event: CalendarEvent) => string | undefined;\n /** Extra classes on a day: a month cell, a time-grid column and its header. Holidays, closures. */\n dayClassName?: (date: Date) => string | undefined;\n /** Extra classes on the row of day headers. */\n headerClassName?: string;\n /** Your own controls, at the end of the toolbar. */\n toolbarActions?: Child;\n /** Hide the toolbar when your page already has one (drive `view` and `date` yourself). */\n hideToolbar?: boolean;\n /** What the agenda says when nothing is on. */\n emptyMessage?: Child;\n}\n\nexport interface CalendarPreview {\n kind: \"move\" | \"resize\" | \"select\";\n /** Where the drag is happening, which decides how the preview is drawn. */\n surface: \"time\" | \"day\";\n /** The event being moved or resized. */\n eventId?: string;\n span: CalendarProposedSpan;\n}\n\n/**\n * What one render owns: the components it built and the listeners it added to\n * nodes it created. Both are released before the next render and on destroy,\n * because a full re-render with nothing released leaks a listener per event\n * per render.\n */\nexport interface RenderScope {\n keep<T extends AnyZenComponent>(component: T): T;\n on<K extends keyof HTMLElementEventMap>(\n node: HTMLElement,\n type: K,\n listener: (event: HTMLElementEventMap[K]) => void,\n ): void;\n /** Run when this render is released (an observer to disconnect, say). */\n onRelease(cleanup: () => void): void;\n}\n\n/**\n * View state that must outlive a render. The factory rebuilds its DOM when the\n * data changes; without this the slot cursor, the focused day and the grid's\n * scroll position would all reset every time the caller passed new events.\n */\nexport interface CalendarMemory {\n cursor?: SlotCursor;\n focusedDay?: Date;\n /** Set by keyboard paging only: focus `focusedDay` once the new page is built. */\n focusDayAfterRender?: boolean;\n scrollTop?: number;\n /** The view the scroll position belongs to; a new view scrolls to scrollToHour instead. */\n scrollView?: string;\n /** The day whose \"+N more\" panel is open, kept open across a re-render. */\n openMore?: string;\n}\n\n/** What the root hands every view for one render. */\nexport interface CalendarContext {\n memory: CalendarMemory;\n props: EventCalendarProps;\n loc: ReturnType<typeof useLocale>;\n scope: RenderScope;\n view: EventCalendarView;\n anchor: Date;\n now: Date;\n options: EventCalendarOptions;\n hourPx: number;\n rowPx: number;\n snap: number;\n root: HTMLElement;\n hintId: string;\n /** The preview in progress when this render started (a re-render during a drag). */\n preview: CalendarPreview | null;\n setPreview: (preview: CalendarPreview | null) => void;\n editable: (event: CalendarEvent) => boolean;\n selectable: boolean;\n canGoToDay: boolean;\n goToDay: (date: Date) => void;\n setDate: (date: Date) => void;\n openEvent: (event: CalendarEvent) => void;\n toggleTask: (event: CalendarEvent) => void;\n selectSlot: (slot: CalendarSlot) => void;\n propose: (event: CalendarEvent, span: CalendarProposedSpan, kind: \"move\" | \"resize\", fromKeyboard: boolean) => void;\n timeLabel: (span: { start: Date; end: Date; allDay?: boolean }) => string;\n announce: (text: string) => void;\n}\n\n/** A built view: its element, and how it shows a drag in progress without being rebuilt. */\nexport interface CalendarViewHandle {\n el: HTMLElement;\n /** Draw (or clear) the preview in place. A drag updates it every frame; rebuilding the view each frame would drop focus and thrash layout. */\n applyPreview(preview: CalendarPreview | null): void;\n /** Called once the view is in the document (scroll position, focus). */\n mounted?(): void;\n}\n\nexport const STATE_CLASS: Record<CalendarEventState, string> = {\n default: \"zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary\",\n info: \"zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info\",\n success: \"zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success\",\n warning: \"zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning\",\n error: \"zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error\",\n};\n\nexport const DOT_CLASS: Record<CalendarEventState, string> = {\n default: \"zen-bg-zen-primary\",\n info: \"zen-bg-zen-info\",\n success: \"zen-bg-zen-success\",\n warning: \"zen-bg-zen-warning\",\n error: \"zen-bg-zen-error\",\n};\n\n/** The class a drag adds to the event it is moving. */\nexport const MOVING_CLASS = \"zen-opacity-40\";\n/** The class a preview adds to a day it covers. */\nexport const LIT_CLASS = \"zen-bg-zen-primary-soft\";\n\nexport const isRtl = (node: Element | null | undefined): boolean => !!node && getComputedStyle(node).direction === \"rtl\";\n\nexport const sameDay = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();\n\nexport const el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className?: string,\n text?: string,\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag);\n if (className) node.className = className;\n if (text !== undefined) node.textContent = text;\n return node;\n};\n\n/**\n * A caller's colour as a tint with a solid edge, mixed against the theme's\n * background so it reads in dark mode; the text stays the theme's foreground.\n */\nexport function applyCustomColor(node: HTMLElement, color: string | undefined, variant: CalendarEventVariant): void {\n if (!color || variant === \"chip\" || variant === \"row\") return;\n node.style.backgroundColor = `color-mix(in srgb, ${color} 18%, var(--zen-color-background))`;\n node.style.borderColor = color;\n node.style.color = \"var(--zen-color-foreground)\";\n}\n\n/**\n * The cells a day-surface preview lights, by recomputing their class from the\n * base they were built with: adding the tint beside a weekend shade would leave\n * the two fighting on stylesheet order.\n */\nexport function relight(cells: Array<{ node: HTMLElement; base: string; day: Date }>, range: { start: Date; end: Date } | null): void {\n for (const cell of cells) {\n const lit = range !== null && cell.day >= range.start && cell.day < range.end;\n cell.node.className = cn(cell.base, lit && LIT_CLASS);\n }\n}\n\n/** Dim the event being dragged (every piece of it) and undim the rest. */\nexport function markMoving(root: HTMLElement, id: string | undefined): void {\n for (const node of root.querySelectorAll<HTMLElement>(\"[data-cal-event]\")) {\n node.classList.toggle(MOVING_CLASS, id !== undefined && node.getAttribute(\"data-cal-event\") === id);\n }\n}\n"],"names":["STATE_CLASS","DOT_CLASS","MOVING_CLASS","LIT_CLASS","isRtl","node","sameDay","a","b","el","tag","className","text","applyCustomColor","color","variant","relight","cells","range","cell","lit","cn","markMoving","root","id"],"mappings":";AAiNO,MAAMA,IAAkD;AAAA,EAC7D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAEaC,IAAgD;AAAA,EAC3D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAGaC,IAAe,kBAEfC,IAAY,2BAEZC,IAAQ,CAACC,MAA8C,CAAC,CAACA,KAAQ,iBAAiBA,CAAI,EAAE,cAAc,OAEtGC,IAAU,CAACC,GAASC,MAC/BD,EAAE,YAAA,MAAkBC,EAAE,YAAA,KAAiBD,EAAE,SAAA,MAAeC,EAAE,SAAA,KAAcD,EAAE,QAAA,MAAcC,EAAE,QAAA,GAE/EC,IAAK,CAChBC,GACAC,GACAC,MAC6B;AAC7B,QAAMP,IAAO,SAAS,cAAcK,CAAG;AACvC,SAAIC,QAAgB,YAAYA,IAC5BC,MAAS,WAAWP,EAAK,cAAcO,IACpCP;AACT;AAMO,SAASQ,EAAiBR,GAAmBS,GAA2BC,GAAqC;AAClH,EAAI,CAACD,KAASC,MAAY,UAAUA,MAAY,UAChDV,EAAK,MAAM,kBAAkB,sBAAsBS,CAAK,sCACxDT,EAAK,MAAM,cAAcS,GACzBT,EAAK,MAAM,QAAQ;AACrB;AAOO,SAASW,EAAQC,GAA8DC,GAAgD;AACpI,aAAWC,KAAQF,GAAO;AACxB,UAAMG,IAAMF,MAAU,QAAQC,EAAK,OAAOD,EAAM,SAASC,EAAK,MAAMD,EAAM;AAC1E,IAAAC,EAAK,KAAK,YAAYE,EAAGF,EAAK,MAAMC,KAAOjB,CAAS;AAAA,EACtD;AACF;AAGO,SAASmB,EAAWC,GAAmBC,GAA8B;AAC1E,aAAWnB,KAAQkB,EAAK,iBAA8B,kBAAkB;AACtE,IAAAlB,EAAK,UAAU,OAAOH,GAAcsB,MAAO,UAAanB,EAAK,aAAa,gBAAgB,MAAMmB,CAAE;AAEtG;"}
1
+ {"version":3,"file":"index233.js","sources":["../src/components/event-calendar/event-calendar-agenda.ts"],"sourcesContent":["import { agendaGroups, eventCalendarRange, type AgendaItem } from \"@algorisys/zen-ui-core/event-calendar\";\nimport { cn } from \"../../lib/cn\";\nimport { toNodes } from \"../../lib/component\";\nimport { eventItem } from \"./event-calendar-item\";\nimport { type CalendarContext, type CalendarEvent, type CalendarViewHandle, el, markMoving, sameDay } from \"./event-calendar-model\";\n\n/** One day's events as a list: the agenda's rows, and the month's \"+N more\" panel. */\nexport function dayList(cal: CalendarContext, events: CalendarEvent[], items: AgendaItem[]): HTMLElement {\n const list = el(\"ul\", \"zen-m-0 zen-flex zen-list-none zen-flex-col zen-gap-0.5 zen-p-0\");\n for (const item of items) {\n const event = events[item.index];\n const li = el(\"li\", \"zen-flex zen-min-w-0 zen-items-center zen-gap-3 zen-rounded-zen-sm hover:zen-bg-zen-muted\");\n const time = el(\n \"span\",\n \"zen-w-32 zen-shrink-0 zen-ps-1.5 zen-text-xs zen-tabular-nums zen-text-zen-muted-fg\",\n item.allDay ? cal.loc.t(\"eventCalendar.allDay\") : cal.timeLabel(event),\n );\n time.setAttribute(\"aria-hidden\", \"true\");\n li.append(\n time,\n eventItem(cal, event, {\n variant: \"row\",\n continuesBefore: item.continuesBefore,\n continuesAfter: item.continuesAfter,\n class: \"zen-min-h-8 zen-flex-1\",\n }),\n );\n list.append(li);\n }\n return list;\n}\n\nexport function agenda(cal: CalendarContext): CalendarViewHandle {\n const events = cal.props.events ?? [];\n const groups = agendaGroups(events, eventCalendarRange(\"agenda\", cal.anchor, cal.options));\n const heading = (d: Date) => new Intl.DateTimeFormat(cal.loc.locale, { weekday: \"long\", day: \"numeric\", month: \"long\" }).format(d);\n const box = el(\"div\", \"zen-rounded-zen-md zen-border zen-border-zen-border\");\n\n if (groups.length === 0) {\n const empty = el(\"p\", \"zen-m-0 zen-py-10 zen-text-center zen-text-sm zen-text-zen-muted-fg\");\n empty.append(...toNodes(cal.props.emptyMessage ?? cal.loc.t(\"eventCalendar.noEvents\")));\n box.append(empty);\n }\n for (const group of groups) {\n const section = el(\n \"section\",\n cn(\"zen-flex zen-flex-col zen-gap-1 zen-border-b zen-border-zen-border zen-px-3 zen-py-2 last:zen-border-b-0\", cal.props.dayClassName?.(group.date)),\n );\n section.setAttribute(\"aria-label\", heading(group.date));\n const label = el(\n \"p\",\n cn(\"zen-m-0 zen-text-sm zen-font-semibold\", sameDay(group.date, cal.now) ? \"zen-text-zen-primary\" : \"zen-text-zen-foreground\"),\n heading(group.date),\n );\n label.setAttribute(\"aria-hidden\", \"true\");\n section.append(label, dayList(cal, events, group.items));\n box.append(section);\n }\n\n return { el: box, applyPreview: (preview) => markMoving(cal.root, preview?.eventId) };\n}\n"],"names":["dayList","cal","events","items","list","el","item","event","li","time","eventItem","agenda","groups","agendaGroups","eventCalendarRange","heading","d","box","empty","toNodes","group","section","cn","label","sameDay","preview","markMoving"],"mappings":";;;;;AAOO,SAASA,EAAQC,GAAsBC,GAAyBC,GAAkC;AACvG,QAAMC,IAAOC,EAAG,MAAM,iEAAiE;AACvF,aAAWC,KAAQH,GAAO;AACxB,UAAMI,IAAQL,EAAOI,EAAK,KAA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AM,MAAMnB,EAAI,GAAG,IAAI,yBAAyB,yBAAyB;AAAA,MAC7Hc,EAAQK,EAAM,IAAI;AAAA,IAAA;AAEpB,IAAAG,EAAM,aAAa,eAAe,MAAM,GACxCF,EAAQ,OAAOE,GAAOvB,EAAQC,GAAKC,GAAQkB,EAAM,KAAK,CAAC,GACvDH,EAAI,OAAOI,CAAO;AAAA,EACpB;AAEA,SAAO,EAAE,IAAIJ,GAAK,cAAc,CAACQ,MAAYC,EAAWzB,EAAI,MAAMwB,GAAS,OAAO,EAAA;AACpF;"}
package/dist/index234.js CHANGED
@@ -1,154 +1,43 @@
1
- import { monthGrid as N, weekdayLabels as U, eventCalendarRange as W, calendarDayDiff as _, segmentSpanning as X, isSpanning as q, agendaGroups as J, sameTimeDaysLater as f, eventDayRange as Q } from "./index117.js";
2
- import { calendarDayKey as y, startCalendarGesture as V } from "./index245.js";
3
- import { Popover as Z } from "./index58.js";
4
- import { dayList as ee } from "./index232.js";
5
- import { eventItem as te } from "./index244.js";
6
- import { el as d, markMoving as ne, relight as oe, isRtl as re } from "./index233.js";
7
- import { cn as M } from "./index194.js";
8
- const T = 28;
9
- function ze(n) {
10
- const { loc: g, props: b, scope: D, memory: l } = n, w = b.events ?? [], k = Math.max(1, b.maxEventsPerDay ?? 3), S = N(n.anchor, { ...n.options, now: n.now }), Y = U(n.options.weekStartsOn ?? 1, g.locale, "short"), I = T + k * (n.rowPx + 2) + 4, h = (t) => new Intl.DateTimeFormat(g.locale, { weekday: "long", day: "numeric", month: "long", year: "numeric" }).format(t), R = W("month", n.anchor, n.options), B = (t) => t >= R.start && t < R.end;
11
- let p = l.focusedDay;
12
- if (!p || p.getMonth() !== n.anchor.getMonth() || p.getFullYear() !== n.anchor.getFullYear()) {
13
- const t = p ?? n.anchor, o = new Date(n.anchor.getFullYear(), n.anchor.getMonth() + 1, 0).getDate();
14
- p = new Date(n.anchor.getFullYear(), n.anchor.getMonth(), Math.min(t.getDate(), o));
1
+ import { cn as r } from "./index194.js";
2
+ const f = {
3
+ default: "zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary",
4
+ info: "zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info",
5
+ success: "zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success",
6
+ warning: "zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning",
7
+ error: "zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error"
8
+ }, g = {
9
+ default: "zen-bg-zen-primary",
10
+ info: "zen-bg-zen-info",
11
+ success: "zen-bg-zen-success",
12
+ warning: "zen-bg-zen-warning",
13
+ error: "zen-bg-zen-error"
14
+ }, s = "zen-opacity-40", z = "zen-bg-zen-primary-soft", i = (n) => !!n && getComputedStyle(n).direction === "rtl", a = (n, e) => n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate(), l = (n, e, t) => {
15
+ const o = document.createElement(n);
16
+ return e && (o.className = e), t !== void 0 && (o.textContent = t), o;
17
+ };
18
+ function u(n, e, t) {
19
+ !e || t === "chip" || t === "row" || (n.style.backgroundColor = `color-mix(in srgb, ${e} 18%, var(--zen-color-background))`, n.style.borderColor = e, n.style.color = "var(--zen-color-foreground)");
20
+ }
21
+ function b(n, e) {
22
+ for (const t of n) {
23
+ const o = e !== null && t.day >= e.start && t.day < e.end;
24
+ t.node.className = r(t.base, o && z);
15
25
  }
16
- l.focusedDay = p;
17
- const A = n.canGoToDay ? "day" : n.selectable ? "select" : null, O = (t) => {
18
- A === "day" ? n.goToDay(t) : A === "select" && n.selectSlot({ start: t, end: f(t, 1), allDay: !0 });
19
- }, $ = d("div", "zen-overflow-x-auto zen-rounded-zen-md zen-border zen-border-zen-border"), C = d("div", "zen-min-w-[560px]");
20
- $.append(C);
21
- const E = d("div", M("zen-grid zen-grid-cols-7 zen-border-b zen-border-zen-border zen-bg-zen-muted", b.headerClassName));
22
- for (const t of Y) E.append(d("div", "zen-px-2 zen-py-1.5 zen-text-center zen-text-xs zen-font-medium zen-text-zen-muted-fg", t));
23
- C.append(E);
24
- const P = /* @__PURE__ */ new Map(), G = (t) => {
25
- l.focusedDay = t;
26
- for (const [u, i] of P) i.tabIndex = u === y(t) ? 0 : -1;
27
- const o = P.get(y(t));
28
- o ? o.focus() : (l.focusDayAfterRender = !0, n.setDate(t));
29
- }, j = (t, o, u) => {
30
- const i = re(u), v = n.options.weekStartsOn ?? 1;
31
- let a = null;
32
- if (t.key === "ArrowRight") a = f(o, i ? -1 : 1);
33
- else if (t.key === "ArrowLeft") a = f(o, i ? 1 : -1);
34
- else if (t.key === "ArrowDown") a = f(o, 7);
35
- else if (t.key === "ArrowUp") a = f(o, -7);
36
- else if (t.key === "Home") a = f(o, -((o.getDay() - v + 7) % 7));
37
- else if (t.key === "End") a = f(o, 6 - (o.getDay() - v + 7) % 7);
38
- else if (t.key === "PageUp" || t.key === "PageDown") {
39
- const e = new Date(o.getFullYear(), o.getMonth() + (t.key === "PageDown" ? 1 : -1), 1), c = new Date(e.getFullYear(), e.getMonth() + 1, 0).getDate();
40
- a = new Date(e.getFullYear(), e.getMonth(), Math.min(o.getDate(), c));
41
- }
42
- if (a) {
43
- if (t.preventDefault(), a.getMonth() !== n.anchor.getMonth() || !B(a)) {
44
- l.focusedDay = a, l.focusDayAfterRender = !0, n.setDate(a);
45
- return;
46
- }
47
- G(a);
48
- }
49
- }, H = (t, o) => {
50
- if (!n.selectable) return;
51
- const u = t.target;
52
- u.closest("[data-cal-event]") || u.closest("button") || V({
53
- event: t,
54
- target: o,
55
- root: n.root,
56
- kind: "select",
57
- surface: "day",
58
- snap: n.snap,
59
- newEventMinutes: b.newEventMinutes ?? 60,
60
- onPreview: (i) => n.setPreview(i ? { kind: "select", surface: "day", span: i } : null),
61
- onCommit: (i) => n.selectSlot(i),
62
- onClick: (i) => i && n.selectSlot(i)
63
- });
64
- }, F = [];
65
- let L = null;
66
- return S.forEach((t, o) => {
67
- const u = d("div", "zen-relative zen-border-b zen-border-zen-border last:zen-border-b-0");
68
- u.style.height = `${I + (o < S.length - 1 ? 1 : 0)}px`;
69
- const i = d("div", "zen-absolute zen-inset-0 zen-grid zen-grid-cols-7");
70
- for (const e of t) {
71
- const c = M(
72
- "zen-flex zen-items-start zen-justify-end zen-border-s zen-border-zen-border zen-p-1 first:zen-border-s-0",
73
- e.nonWorking && "zen-bg-zen-muted",
74
- n.selectable && "zen-cursor-cell",
75
- b.dayClassName?.(e.date)
76
- ), s = d("div", c);
77
- s.setAttribute("data-cal-cell", y(e.date)), s.setAttribute("data-cal-month-cell", ""), D.on(s, "pointerdown", (r) => H(r, s));
78
- const z = M(
79
- "zen-flex zen-h-6 zen-min-w-6 zen-items-center zen-justify-center zen-rounded-zen-full zen-px-1 zen-text-xs zen-font-medium",
80
- e.today ? "zen-bg-zen-primary zen-text-zen-primary-fg" : e.inMonth ? "zen-text-zen-foreground" : "zen-text-zen-muted-fg"
81
- );
82
- if (A) {
83
- const r = d(
84
- "button",
85
- M(z, "focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring", !e.today && "hover:zen-bg-zen-muted"),
86
- String(e.date.getDate())
87
- );
88
- r.type = "button", r.setAttribute("data-cal-daynum", ""), r.setAttribute("data-cal-focus", `day:${y(e.date)}`), r.tabIndex = _(e.date, p) === 0 ? 0 : -1, r.setAttribute(
89
- "aria-label",
90
- A === "day" ? g.t("eventCalendar.goToDay", { date: h(e.date) }) : g.t("eventCalendar.newEvent", { time: h(e.date) })
91
- ), e.today && r.setAttribute("aria-current", "date"), D.on(r, "click", () => {
92
- l.focusedDay = e.date, O(e.date);
93
- }), D.on(r, "keydown", (m) => j(m, e.date, r)), P.set(y(e.date), r), s.append(r);
94
- } else
95
- s.append(d("span", z, String(e.date.getDate())));
96
- F.push({ node: s, base: c, day: e.date }), i.append(s);
97
- }
98
- u.append(i);
99
- const v = X(w, t.map((e) => e.date), { maxSlots: k }), a = d("div", "zen-pointer-events-none zen-absolute zen-inset-0 zen-grid zen-grid-cols-7 zen-gap-y-0.5 zen-px-px");
100
- a.style.gridTemplateRows = `${T}px repeat(${k}, ${n.rowPx}px)`;
101
- for (const e of v.segments) {
102
- if (!e.visible) continue;
103
- const c = w[e.index], s = q(c) || e.endCol - e.startCol > 1 || e.continuesBefore || e.continuesAfter, z = te(n, c, {
104
- variant: s ? "bar" : "chip",
105
- surface: "day",
106
- weekRows: !0,
107
- resizable: !!c.allDay && !e.continuesAfter,
108
- continuesBefore: e.continuesBefore,
109
- continuesAfter: e.continuesAfter,
110
- class: "zen-pointer-events-auto zen-mx-0.5"
111
- });
112
- z.style.gridColumn = `${e.startCol + 1} / ${e.endCol + 1}`, z.style.gridRow = `${e.slot + 2}`, a.append(z);
113
- }
114
- v.hidden.forEach((e, c) => {
115
- if (e <= 0) return;
116
- const s = t[c].date, z = y(s), r = d(
117
- "button",
118
- "zen-w-full zen-truncate zen-rounded-zen-sm zen-px-1.5 zen-text-start zen-text-xs zen-font-medium zen-text-zen-muted-fg hover:zen-bg-zen-muted hover:zen-text-zen-foreground focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring",
119
- g.t("eventCalendar.more", { count: e })
120
- );
121
- r.type = "button", r.setAttribute("data-cal-more", ""), r.setAttribute("data-cal-focus", `more:${z}`), r.setAttribute("aria-label", g.t("eventCalendar.moreLabel", { count: e, date: h(s) }));
122
- const m = d("div");
123
- m.setAttribute("data-cal-owner", n.hintId), m.setAttribute("aria-label", g.t("eventCalendar.eventsOn", { date: h(s) })), m.append(
124
- d("p", "zen-m-0 zen-mb-1 zen-px-1.5 zen-text-sm zen-font-semibold zen-text-zen-foreground", h(s)),
125
- ee(n, w, J(w, { start: s, end: f(s, 1) })[0]?.items ?? [])
126
- );
127
- const x = D.keep(
128
- Z({
129
- trigger: r,
130
- children: m,
131
- class: "zen-w-80 zen-p-2",
132
- onOpenChange: (K) => {
133
- K ? l.openMore = z : l.openMore === z && (l.openMore = void 0);
134
- }
135
- })
136
- );
137
- l.openMore === z && (L = x), x.el.classList.add("zen-pointer-events-auto", "zen-mx-0.5", "zen-min-w-0"), x.el.style.gridColumn = `${c + 1}`, x.el.style.gridRow = `${k + 1}`, a.append(x.el);
138
- }), u.append(a), C.append(u);
139
- }), {
140
- el: $,
141
- /* Reopened once the page is in the document, where the panel can measure
142
- its trigger: opening it while detached places it at the corner. */
143
- mounted() {
144
- L?.open();
145
- },
146
- applyPreview(t) {
147
- ne(n.root, t?.eventId), oe(F, t && t.surface === "day" ? Q(t.span) : null);
148
- }
149
- };
26
+ }
27
+ function d(n, e) {
28
+ for (const t of n.querySelectorAll("[data-cal-event]"))
29
+ t.classList.toggle(s, e !== void 0 && t.getAttribute("data-cal-event") === e);
150
30
  }
151
31
  export {
152
- ze as month
32
+ g as DOT_CLASS,
33
+ z as LIT_CLASS,
34
+ s as MOVING_CLASS,
35
+ f as STATE_CLASS,
36
+ u as applyCustomColor,
37
+ l as el,
38
+ i as isRtl,
39
+ d as markMoving,
40
+ b as relight,
41
+ a as sameDay
153
42
  };
154
43
  //# sourceMappingURL=index234.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index234.js","sources":["../src/components/event-calendar/event-calendar-month.ts"],"sourcesContent":["import {\n agendaGroups,\n calendarDayDiff,\n eventCalendarRange,\n eventDayRange,\n isSpanning,\n monthGrid,\n sameTimeDaysLater,\n segmentSpanning,\n weekdayLabels,\n} from \"@algorisys/zen-ui-core/event-calendar\";\nimport { calendarDayKey, startCalendarGesture } from \"@algorisys/zen-ui-core/event-calendar-gesture\";\nimport { cn } from \"../../lib/cn\";\nimport { Popover } from \"../popover/popover\";\nimport { dayList } from \"./event-calendar-agenda\";\nimport { eventItem } from \"./event-calendar-item\";\nimport { type CalendarContext, type CalendarViewHandle, el, isRtl, markMoving, relight } from \"./event-calendar-model\";\n\n/** Height of the row holding the day number, above the event rows. */\nconst DATE_ROW_PX = 28;\n\n/**\n * The month page: six weeks of seven days, events as rows inside the cells.\n * Every cell has `maxEventsPerDay` rows, so every week is the same height. A\n * day with more shows \"+N more\", which opens that day's list. The day numbers\n * are one tab stop with arrow keys between them; events are their own.\n */\nexport function month(cal: CalendarContext): CalendarViewHandle {\n const { loc, props, scope, memory } = cal;\n const events = props.events ?? [];\n const maxSlots = Math.max(1, props.maxEventsPerDay ?? 3);\n const grid = monthGrid(cal.anchor, { ...cal.options, now: cal.now });\n const weekdays = weekdayLabels(cal.options.weekStartsOn ?? 1, loc.locale, \"short\");\n const rowHeight = DATE_ROW_PX + maxSlots * (cal.rowPx + 2) + 4;\n const longDate = (d: Date) => new Intl.DateTimeFormat(loc.locale, { weekday: \"long\", day: \"numeric\", month: \"long\", year: \"numeric\" }).format(d);\n const page = eventCalendarRange(\"month\", cal.anchor, cal.options);\n const inPage = (d: Date) => d >= page.start && d < page.end;\n\n // The focused day follows the anchor into a new month, at the same date.\n let focused = memory.focusedDay;\n if (!focused || focused.getMonth() !== cal.anchor.getMonth() || focused.getFullYear() !== cal.anchor.getFullYear()) {\n const base = focused ?? cal.anchor;\n const last = new Date(cal.anchor.getFullYear(), cal.anchor.getMonth() + 1, 0).getDate();\n focused = new Date(cal.anchor.getFullYear(), cal.anchor.getMonth(), Math.min(base.getDate(), last));\n }\n memory.focusedDay = focused;\n\n const dayAction = cal.canGoToDay ? \"day\" : cal.selectable ? \"select\" : null;\n const activate = (d: Date) => {\n if (dayAction === \"day\") cal.goToDay(d);\n else if (dayAction === \"select\") cal.selectSlot({ start: d, end: sameTimeDaysLater(d, 1), allDay: true });\n };\n\n const box = el(\"div\", \"zen-overflow-x-auto zen-rounded-zen-md zen-border zen-border-zen-border\");\n const inner = el(\"div\", \"zen-min-w-[560px]\");\n box.append(inner);\n\n const head = el(\"div\", cn(\"zen-grid zen-grid-cols-7 zen-border-b zen-border-zen-border zen-bg-zen-muted\", props.headerClassName));\n for (const label of weekdays) head.append(el(\"div\", \"zen-px-2 zen-py-1.5 zen-text-center zen-text-xs zen-font-medium zen-text-zen-muted-fg\", label));\n inner.append(head);\n\n const dayButtons = new Map<string, HTMLButtonElement>();\n const focusDay = (d: Date) => {\n memory.focusedDay = d;\n for (const [key, button] of dayButtons) button.tabIndex = key === calendarDayKey(d) ? 0 : -1;\n const button = dayButtons.get(calendarDayKey(d));\n if (button) button.focus();\n // Off this page: the root re-renders on the new month, then focuses it.\n else {\n memory.focusDayAfterRender = true;\n cal.setDate(d);\n }\n };\n\n const onDayKey = (e: KeyboardEvent, d: Date, button: HTMLElement) => {\n const rtl = isRtl(button);\n const weekStart = cal.options.weekStartsOn ?? 1;\n let next: Date | null = null;\n if (e.key === \"ArrowRight\") next = sameTimeDaysLater(d, rtl ? -1 : 1);\n else if (e.key === \"ArrowLeft\") next = sameTimeDaysLater(d, rtl ? 1 : -1);\n else if (e.key === \"ArrowDown\") next = sameTimeDaysLater(d, 7);\n else if (e.key === \"ArrowUp\") next = sameTimeDaysLater(d, -7);\n else if (e.key === \"Home\") next = sameTimeDaysLater(d, -((d.getDay() - weekStart + 7) % 7));\n else if (e.key === \"End\") next = sameTimeDaysLater(d, 6 - ((d.getDay() - weekStart + 7) % 7));\n else if (e.key === \"PageUp\" || e.key === \"PageDown\") {\n const target = new Date(d.getFullYear(), d.getMonth() + (e.key === \"PageDown\" ? 1 : -1), 1);\n const last = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();\n next = new Date(target.getFullYear(), target.getMonth(), Math.min(d.getDate(), last));\n }\n if (!next) return;\n e.preventDefault();\n if (next.getMonth() !== cal.anchor.getMonth() || !inPage(next)) {\n memory.focusedDay = next;\n memory.focusDayAfterRender = true;\n cal.setDate(next);\n return;\n }\n focusDay(next);\n };\n\n const startSelect = (e: PointerEvent, target: HTMLElement) => {\n if (!cal.selectable) return;\n const hit = e.target as Element;\n if (hit.closest(\"[data-cal-event]\") || hit.closest(\"button\")) return;\n startCalendarGesture({\n event: e,\n target,\n root: cal.root,\n kind: \"select\",\n surface: \"day\",\n snap: cal.snap,\n newEventMinutes: props.newEventMinutes ?? 60,\n onPreview: (span) => cal.setPreview(span ? { kind: \"select\", surface: \"day\", span } : null),\n onCommit: (span) => cal.selectSlot(span),\n onClick: (span) => span && cal.selectSlot(span),\n });\n };\n\n const cells: Array<{ node: HTMLElement; base: string; day: Date }> = [];\n let reopen: { open(): void } | null = null;\n grid.forEach((week, rowIndex) => {\n // The divider is the row's own bottom border, which the last row does not\n // have; it gets that pixel back so all six weeks have the same room.\n const row = el(\"div\", \"zen-relative zen-border-b zen-border-zen-border last:zen-border-b-0\");\n row.style.height = `${rowHeight + (rowIndex < grid.length - 1 ? 1 : 0)}px`;\n\n const cellLayer = el(\"div\", \"zen-absolute zen-inset-0 zen-grid zen-grid-cols-7\");\n for (const cell of week) {\n const base = cn(\n \"zen-flex zen-items-start zen-justify-end zen-border-s zen-border-zen-border zen-p-1 first:zen-border-s-0\",\n cell.nonWorking && \"zen-bg-zen-muted\",\n cal.selectable && \"zen-cursor-cell\",\n props.dayClassName?.(cell.date),\n );\n const cellEl = el(\"div\", base);\n cellEl.setAttribute(\"data-cal-cell\", calendarDayKey(cell.date));\n cellEl.setAttribute(\"data-cal-month-cell\", \"\");\n scope.on(cellEl, \"pointerdown\", (e) => startSelect(e, cellEl));\n const number = cn(\n \"zen-flex zen-h-6 zen-min-w-6 zen-items-center zen-justify-center zen-rounded-zen-full zen-px-1 zen-text-xs zen-font-medium\",\n cell.today ? \"zen-bg-zen-primary zen-text-zen-primary-fg\" : cell.inMonth ? \"zen-text-zen-foreground\" : \"zen-text-zen-muted-fg\",\n );\n if (dayAction) {\n const button = el(\n \"button\",\n cn(number, \"focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring\", !cell.today && \"hover:zen-bg-zen-muted\"),\n String(cell.date.getDate()),\n );\n button.type = \"button\";\n button.setAttribute(\"data-cal-daynum\", \"\");\n button.setAttribute(\"data-cal-focus\", `day:${calendarDayKey(cell.date)}`);\n button.tabIndex = calendarDayDiff(cell.date, focused) === 0 ? 0 : -1;\n button.setAttribute(\n \"aria-label\",\n dayAction === \"day\"\n ? loc.t(\"eventCalendar.goToDay\", { date: longDate(cell.date) })\n : loc.t(\"eventCalendar.newEvent\", { time: longDate(cell.date) }),\n );\n if (cell.today) button.setAttribute(\"aria-current\", \"date\");\n scope.on(button, \"click\", () => {\n memory.focusedDay = cell.date;\n activate(cell.date);\n });\n scope.on(button, \"keydown\", (e) => onDayKey(e, cell.date, button));\n dayButtons.set(calendarDayKey(cell.date), button);\n cellEl.append(button);\n } else {\n cellEl.append(el(\"span\", number, String(cell.date.getDate())));\n }\n cells.push({ node: cellEl, base, day: cell.date });\n cellLayer.append(cellEl);\n }\n row.append(cellLayer);\n\n /* Events over the cells. The layer lets pointer events through to the\n cells (so empty space still selects a day); the events take them back. */\n const layout = segmentSpanning(events, week.map((c) => c.date), { maxSlots });\n const eventLayer = el(\"div\", \"zen-pointer-events-none zen-absolute zen-inset-0 zen-grid zen-grid-cols-7 zen-gap-y-0.5 zen-px-px\");\n eventLayer.style.gridTemplateRows = `${DATE_ROW_PX}px repeat(${maxSlots}, ${cal.rowPx}px)`; // i18n-ignore (CSS grid value)\n for (const segment of layout.segments) {\n if (!segment.visible) continue;\n const event = events[segment.index];\n // A timed event that crosses midnight covers two cells: a bar, like any multi-day event.\n const bar = isSpanning(event) || segment.endCol - segment.startCol > 1 || segment.continuesBefore || segment.continuesAfter;\n const item = eventItem(cal, event, {\n variant: bar ? \"bar\" : \"chip\",\n surface: \"day\",\n weekRows: true,\n resizable: Boolean(event.allDay) && !segment.continuesAfter,\n continuesBefore: segment.continuesBefore,\n continuesAfter: segment.continuesAfter,\n class: \"zen-pointer-events-auto zen-mx-0.5\",\n });\n item.style.gridColumn = `${segment.startCol + 1} / ${segment.endCol + 1}`;\n item.style.gridRow = `${segment.slot + 2}`;\n eventLayer.append(item);\n }\n layout.hidden.forEach((count, i) => {\n if (count <= 0) return;\n const date = week[i].date;\n const key = calendarDayKey(date);\n const trigger = el(\n \"button\",\n \"zen-w-full zen-truncate zen-rounded-zen-sm zen-px-1.5 zen-text-start zen-text-xs zen-font-medium zen-text-zen-muted-fg hover:zen-bg-zen-muted hover:zen-text-zen-foreground focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring\",\n loc.t(\"eventCalendar.more\", { count }),\n );\n trigger.type = \"button\";\n trigger.setAttribute(\"data-cal-more\", \"\");\n trigger.setAttribute(\"data-cal-focus\", `more:${key}`);\n trigger.setAttribute(\"aria-label\", loc.t(\"eventCalendar.moreLabel\", { count, date: longDate(date) }));\n const panel = el(\"div\");\n // Marks the portaled panel as this calendar's, so focus can be restored into it.\n panel.setAttribute(\"data-cal-owner\", cal.hintId);\n panel.setAttribute(\"aria-label\", loc.t(\"eventCalendar.eventsOn\", { date: longDate(date) }));\n panel.append(\n el(\"p\", \"zen-m-0 zen-mb-1 zen-px-1.5 zen-text-sm zen-font-semibold zen-text-zen-foreground\", longDate(date)),\n dayList(cal, events, agendaGroups(events, { start: date, end: sameTimeDaysLater(date, 1) })[0]?.items ?? []),\n );\n /* Reopened after a re-render (see mounted): ticking a task in the panel\n passes new events back, and a panel that closed under the user's hand\n would lose their place. */\n const pop = scope.keep(\n Popover({\n trigger,\n children: panel,\n class: \"zen-w-80 zen-p-2\",\n onOpenChange: (open) => {\n if (open) memory.openMore = key;\n else if (memory.openMore === key) memory.openMore = undefined;\n },\n }),\n );\n if (memory.openMore === key) reopen = pop;\n pop.el.classList.add(\"zen-pointer-events-auto\", \"zen-mx-0.5\", \"zen-min-w-0\");\n pop.el.style.gridColumn = `${i + 1}`;\n pop.el.style.gridRow = `${maxSlots + 1}`;\n eventLayer.append(pop.el);\n });\n row.append(eventLayer);\n inner.append(row);\n });\n\n return {\n el: box,\n /* Reopened once the page is in the document, where the panel can measure\n its trigger: opening it while detached places it at the corner. */\n mounted() {\n reopen?.open();\n },\n applyPreview(preview) {\n markMoving(cal.root, preview?.eventId);\n relight(cells, preview && preview.surface === \"day\" ? eventDayRange(preview.span) : null);\n },\n };\n}\n"],"names":["DATE_ROW_PX","month","cal","loc","props","scope","memory","events","maxSlots","grid","monthGrid","weekdays","weekdayLabels","rowHeight","longDate","d","page","eventCalendarRange","inPage","focused","base","last","dayAction","activate","sameTimeDaysLater","box","el","inner","head","cn","label","dayButtons","focusDay","key","button","calendarDayKey","onDayKey","e","rtl","isRtl","weekStart","next","target","startSelect","hit","startCalendarGesture","span","cells","reopen","week","rowIndex","row","cellLayer","cell","cellEl","number","calendarDayDiff","layout","segmentSpanning","c","eventLayer","segment","event","bar","isSpanning","item","eventItem","count","i","date","trigger","panel","dayList","agendaGroups","pop","Popover","open","preview","markMoving","relight","eventDayRange"],"mappings":";;;;;;;AAmBA,MAAMA,IAAc;AAQb,SAASC,GAAMC,GAA0C;AAC9D,QAAM,EAAE,KAAAC,GAAK,OAAAC,GAAO,OAAAC,GAAO,QAAAC,MAAWJ,GAChCK,IAASH,EAAM,UAAU,CAAA,GACzBI,IAAW,KAAK,IAAI,GAAGJ,EAAM,mBAAmB,CAAC,GACjDK,IAAOC,EAAUR,EAAI,QAAQ,EAAE,GAAGA,EAAI,SAAS,KAAKA,EAAI,IAAA,CAAK,GAC7DS,IAAWC,EAAcV,EAAI,QAAQ,gBAAgB,GAAGC,EAAI,QAAQ,OAAO,GAC3EU,IAAYb,IAAcQ,KAAYN,EAAI,QAAQ,KAAK,GACvDY,IAAW,CAACC,MAAY,IAAI,KAAK,eAAeZ,EAAI,QAAQ,EAAE,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,MAAM,WAAW,EAAE,OAAOY,CAAC,GACzIC,IAAOC,EAAmB,SAASf,EAAI,QAAQA,EAAI,OAAO,GAC1DgB,IAAS,CAACH,MAAYA,KAAKC,EAAK,SAASD,IAAIC,EAAK;AAGxD,MAAIG,IAAUb,EAAO;AACrB,MAAI,CAACa,KAAWA,EAAQ,SAAA,MAAejB,EAAI,OAAO,SAAA,KAAciB,EAAQ,YAAA,MAAkBjB,EAAI,OA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,MAAAC,GAAW5E,EAAI,MAAM2E,GAAS,OAAO,GACrCE,GAAQhC,GAAO8B,KAAWA,EAAQ,YAAY,QAAQG,EAAcH,EAAQ,IAAI,IAAI,IAAI;AAAA,IAC1F;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"index234.js","sources":["../src/components/event-calendar/event-calendar-model.ts"],"sourcesContent":["import type {\n CalendarProposedSpan,\n EventCalendarOptions,\n SlotCursor,\n EventCalendarView,\n Weekday,\n} from \"@algorisys/zen-ui-core/event-calendar\";\nimport type { Density } from \"@algorisys/zen-ui-core/density\";\nimport { cn } from \"../../lib/cn\";\nimport type { AnyZenComponent, BaseProps, Child } from \"../../lib/component\";\nimport type { useLocale } from \"../locale/locale\";\n\nexport type CalendarEventState = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport interface CalendarEvent {\n id: string;\n title: string;\n start: Date;\n /** Exclusive. For an all-day event, the first day NOT included (or the same day for a one-day event). */\n end: Date;\n allDay?: boolean;\n /** Token colour. \"default\" is the primary tint. */\n state?: CalendarEventState;\n /** Any CSS colour; wins over `state`. For a per-calendar colour from your own map. */\n color?: string;\n location?: string;\n /** Minutes before the start. Shown as a mark; zen-ui does not fire reminders. */\n reminders?: number[];\n /** Shown as a mark. Expand the occurrences before passing them (see `expandRecurrence`). */\n recurring?: boolean;\n /** \"task\" draws a checkbox; `done` strikes it through. */\n kind?: \"event\" | \"task\";\n done?: boolean;\n /** Never offered for moving or resizing, whatever `canEditEvent` says. */\n readOnly?: boolean;\n /**\n * Render the event as a link to this URL, so middle-click and \"open in new\n * tab\" work. `onEventClick` still fires on a plain click; the browser then\n * follows the link.\n */\n href?: string;\n}\n\nexport interface CalendarSlot {\n start: Date;\n /** Exclusive. */\n end: Date;\n allDay: boolean;\n}\n\nexport interface CalendarEventChange {\n /** The event as you passed it. */\n event: CalendarEvent;\n start: Date;\n end: Date;\n allDay: boolean;\n kind: \"move\" | \"resize\";\n}\n\nexport type CalendarEventVariant = \"block\" | \"bar\" | \"chip\" | \"row\";\n\nexport interface CalendarEventRenderContext {\n view: EventCalendarView;\n /** \"block\" in a time grid, \"bar\" for multi-day and all-day, \"chip\" for a timed event in a month cell, \"row\" in lists. */\n variant: CalendarEventVariant;\n /** \"09:00 – 10:30\" or the localised \"All day\". */\n timeLabel: string;\n /** Too short for a second line. */\n compact: boolean;\n}\n\nexport interface EventCalendarProps extends BaseProps {\n events: CalendarEvent[];\n /** Starting view. The factory owns it after that; pass `view` (or call update) to control it. Default \"week\". */\n defaultView?: EventCalendarView;\n view?: EventCalendarView;\n onViewChange?: (view: EventCalendarView) => void;\n /** Which views the switcher offers, in order. Default month, week, day, agenda. */\n views?: EventCalendarView[];\n /** Any date inside the range to open on. Default today. */\n defaultDate?: Date;\n date?: Date;\n onDateChange?: (date: Date) => void;\n /** Reference \"now\" for today and the now line. Injectable for tests and demos. */\n now?: Date;\n /** First column of a week. Default 1 (Monday). */\n weekStartsOn?: Weekday;\n /** Shaded, and left out of the work-week view. Default [0, 6]. */\n nonWorkingDays?: number[];\n /** [from, to) hours drawn unshaded in the time grid. Default [9, 18]. */\n workingHours?: [number, number];\n /** Days shown by the agenda. Default 14. */\n agendaDays?: number;\n /** Hour scrolled to the top of the time grid when it opens. Default 8. */\n scrollToHour?: number;\n /** Pixels per hour in the time grid. Wins over `density`. */\n hourHeight?: number;\n /** \"compact\", \"comfortable\" (default) or \"touch\" (44px rows, 64px hours). */\n density?: Density;\n /** Height of the time grid's scrolling area in px. Default 576. */\n height?: number;\n /** Minutes a drag snaps to, and a keyboard step. Default 15. */\n snapMinutes?: number;\n /** Length of the slot a single click selects. Default 60. */\n newEventMinutes?: number;\n /** Rows of events in a month cell before \"+N more\". Default 3. */\n maxEventsPerDay?: number;\n onEventClick?: (event: CalendarEvent) => void;\n /** Empty time was clicked or dragged across. Without it, empty time is not interactive. */\n onSlotSelect?: (slot: CalendarSlot) => void;\n /** A move or resize, proposed. Nothing changes until you pass back new `events`. Without it the calendar is read-only. */\n onEventChange?: (change: CalendarEventChange) => void;\n /** Per-event gate for editing. A blocked event is not draggable at all, rather than refused on drop. */\n canEditEvent?: (event: CalendarEvent) => boolean;\n /** A task's checkbox was toggled. Without it the checkbox is shown but disabled. */\n onTaskToggle?: (event: CalendarEvent, done: boolean) => void;\n /** Replace an event's content (title, time, marks). The calendar keeps the box, the colour and the controls. */\n renderEvent?: (event: CalendarEvent, context: CalendarEventRenderContext) => Child;\n /** Extra classes on an event's box. */\n eventClassName?: (event: CalendarEvent) => string | undefined;\n /** Extra classes on a day: a month cell, a time-grid column and its header. Holidays, closures. */\n dayClassName?: (date: Date) => string | undefined;\n /** Extra classes on the row of day headers. */\n headerClassName?: string;\n /** Your own controls, at the end of the toolbar. */\n toolbarActions?: Child;\n /** Hide the toolbar when your page already has one (drive `view` and `date` yourself). */\n hideToolbar?: boolean;\n /** What the agenda says when nothing is on. */\n emptyMessage?: Child;\n}\n\nexport interface CalendarPreview {\n kind: \"move\" | \"resize\" | \"select\";\n /** Where the drag is happening, which decides how the preview is drawn. */\n surface: \"time\" | \"day\";\n /** The event being moved or resized. */\n eventId?: string;\n span: CalendarProposedSpan;\n}\n\n/**\n * What one render owns: the components it built and the listeners it added to\n * nodes it created. Both are released before the next render and on destroy,\n * because a full re-render with nothing released leaks a listener per event\n * per render.\n */\nexport interface RenderScope {\n keep<T extends AnyZenComponent>(component: T): T;\n on<K extends keyof HTMLElementEventMap>(\n node: HTMLElement,\n type: K,\n listener: (event: HTMLElementEventMap[K]) => void,\n ): void;\n /** Run when this render is released (an observer to disconnect, say). */\n onRelease(cleanup: () => void): void;\n}\n\n/**\n * View state that must outlive a render. The factory rebuilds its DOM when the\n * data changes; without this the slot cursor, the focused day and the grid's\n * scroll position would all reset every time the caller passed new events.\n */\nexport interface CalendarMemory {\n cursor?: SlotCursor;\n focusedDay?: Date;\n /** Set by keyboard paging only: focus `focusedDay` once the new page is built. */\n focusDayAfterRender?: boolean;\n scrollTop?: number;\n /** The view the scroll position belongs to; a new view scrolls to scrollToHour instead. */\n scrollView?: string;\n /** The day whose \"+N more\" panel is open, kept open across a re-render. */\n openMore?: string;\n}\n\n/** What the root hands every view for one render. */\nexport interface CalendarContext {\n memory: CalendarMemory;\n props: EventCalendarProps;\n loc: ReturnType<typeof useLocale>;\n scope: RenderScope;\n view: EventCalendarView;\n anchor: Date;\n now: Date;\n options: EventCalendarOptions;\n hourPx: number;\n rowPx: number;\n snap: number;\n root: HTMLElement;\n hintId: string;\n /** The preview in progress when this render started (a re-render during a drag). */\n preview: CalendarPreview | null;\n setPreview: (preview: CalendarPreview | null) => void;\n editable: (event: CalendarEvent) => boolean;\n selectable: boolean;\n canGoToDay: boolean;\n goToDay: (date: Date) => void;\n setDate: (date: Date) => void;\n openEvent: (event: CalendarEvent) => void;\n toggleTask: (event: CalendarEvent) => void;\n selectSlot: (slot: CalendarSlot) => void;\n propose: (event: CalendarEvent, span: CalendarProposedSpan, kind: \"move\" | \"resize\", fromKeyboard: boolean) => void;\n timeLabel: (span: { start: Date; end: Date; allDay?: boolean }) => string;\n announce: (text: string) => void;\n}\n\n/** A built view: its element, and how it shows a drag in progress without being rebuilt. */\nexport interface CalendarViewHandle {\n el: HTMLElement;\n /** Draw (or clear) the preview in place. A drag updates it every frame; rebuilding the view each frame would drop focus and thrash layout. */\n applyPreview(preview: CalendarPreview | null): void;\n /** Called once the view is in the document (scroll position, focus). */\n mounted?(): void;\n}\n\nexport const STATE_CLASS: Record<CalendarEventState, string> = {\n default: \"zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary\",\n info: \"zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info\",\n success: \"zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success\",\n warning: \"zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning\",\n error: \"zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error\",\n};\n\nexport const DOT_CLASS: Record<CalendarEventState, string> = {\n default: \"zen-bg-zen-primary\",\n info: \"zen-bg-zen-info\",\n success: \"zen-bg-zen-success\",\n warning: \"zen-bg-zen-warning\",\n error: \"zen-bg-zen-error\",\n};\n\n/** The class a drag adds to the event it is moving. */\nexport const MOVING_CLASS = \"zen-opacity-40\";\n/** The class a preview adds to a day it covers. */\nexport const LIT_CLASS = \"zen-bg-zen-primary-soft\";\n\nexport const isRtl = (node: Element | null | undefined): boolean => !!node && getComputedStyle(node).direction === \"rtl\";\n\nexport const sameDay = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();\n\nexport const el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className?: string,\n text?: string,\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag);\n if (className) node.className = className;\n if (text !== undefined) node.textContent = text;\n return node;\n};\n\n/**\n * A caller's colour as a tint with a solid edge, mixed against the theme's\n * background so it reads in dark mode; the text stays the theme's foreground.\n */\nexport function applyCustomColor(node: HTMLElement, color: string | undefined, variant: CalendarEventVariant): void {\n if (!color || variant === \"chip\" || variant === \"row\") return;\n node.style.backgroundColor = `color-mix(in srgb, ${color} 18%, var(--zen-color-background))`;\n node.style.borderColor = color;\n node.style.color = \"var(--zen-color-foreground)\";\n}\n\n/**\n * The cells a day-surface preview lights, by recomputing their class from the\n * base they were built with: adding the tint beside a weekend shade would leave\n * the two fighting on stylesheet order.\n */\nexport function relight(cells: Array<{ node: HTMLElement; base: string; day: Date }>, range: { start: Date; end: Date } | null): void {\n for (const cell of cells) {\n const lit = range !== null && cell.day >= range.start && cell.day < range.end;\n cell.node.className = cn(cell.base, lit && LIT_CLASS);\n }\n}\n\n/** Dim the event being dragged (every piece of it) and undim the rest. */\nexport function markMoving(root: HTMLElement, id: string | undefined): void {\n for (const node of root.querySelectorAll<HTMLElement>(\"[data-cal-event]\")) {\n node.classList.toggle(MOVING_CLASS, id !== undefined && node.getAttribute(\"data-cal-event\") === id);\n }\n}\n"],"names":["STATE_CLASS","DOT_CLASS","MOVING_CLASS","LIT_CLASS","isRtl","node","sameDay","a","b","el","tag","className","text","applyCustomColor","color","variant","relight","cells","range","cell","lit","cn","markMoving","root","id"],"mappings":";AAuNO,MAAMA,IAAkD;AAAA,EAC7D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAEaC,IAAgD;AAAA,EAC3D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAGaC,IAAe,kBAEfC,IAAY,2BAEZC,IAAQ,CAACC,MAA8C,CAAC,CAACA,KAAQ,iBAAiBA,CAAI,EAAE,cAAc,OAEtGC,IAAU,CAACC,GAASC,MAC/BD,EAAE,YAAA,MAAkBC,EAAE,YAAA,KAAiBD,EAAE,SAAA,MAAeC,EAAE,SAAA,KAAcD,EAAE,QAAA,MAAcC,EAAE,QAAA,GAE/EC,IAAK,CAChBC,GACAC,GACAC,MAC6B;AAC7B,QAAMP,IAAO,SAAS,cAAcK,CAAG;AACvC,SAAIC,QAAgB,YAAYA,IAC5BC,MAAS,WAAWP,EAAK,cAAcO,IACpCP;AACT;AAMO,SAASQ,EAAiBR,GAAmBS,GAA2BC,GAAqC;AAClH,EAAI,CAACD,KAASC,MAAY,UAAUA,MAAY,UAChDV,EAAK,MAAM,kBAAkB,sBAAsBS,CAAK,sCACxDT,EAAK,MAAM,cAAcS,GACzBT,EAAK,MAAM,QAAQ;AACrB;AAOO,SAASW,EAAQC,GAA8DC,GAAgD;AACpI,aAAWC,KAAQF,GAAO;AACxB,UAAMG,IAAMF,MAAU,QAAQC,EAAK,OAAOD,EAAM,SAASC,EAAK,MAAMD,EAAM;AAC1E,IAAAC,EAAK,KAAK,YAAYE,EAAGF,EAAK,MAAMC,KAAOjB,CAAS;AAAA,EACtD;AACF;AAGO,SAASmB,EAAWC,GAAmBC,GAA8B;AAC1E,aAAWn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