@ilamy/calendar 3.1.0 → 3.2.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.
package/dist/index.d.ts CHANGED
@@ -59,8 +59,15 @@ type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "fr
59
59
  */
60
60
  interface BusinessHours {
61
61
  /**
62
- * Days of the week to apply business hours to.
63
- * @default ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
62
+ * Days of the week to apply business hours to. Omitted, the hours apply to
63
+ * every day, weekends included, in both the object and the array form.
64
+ *
65
+ * This deviates from FullCalendar, which defaults an object to Monday-Friday
66
+ * and ignores an array entry without days
67
+ * (core/src/structs/business-hours.ts, v6.1.21). Kept until the next major
68
+ * (see the TODO in business-hours.ts); list the days explicitly to get
69
+ * weekdays only.
70
+ * @default every day
64
71
  */
65
72
  daysOfWeek?: WeekDays[];
66
73
  /**
@@ -129,6 +136,32 @@ interface PluginMutationResult {
129
136
  deleted: CalendarEvent[];
130
137
  }
131
138
  /**
139
+ * One user action and every stored row it touched, reported once through
140
+ * `onEventsChange` (#309). A recurring edit touches several rows (the series,
141
+ * an override, deleted overrides) that the per-row callbacks report one by
142
+ * one; this reports them together so they can be saved, or refused, as a unit.
143
+ * FullCalendar reports an action once the same way (`eventChange` with
144
+ * `relatedEvents`).
145
+ */
146
+ interface EventsChange {
147
+ /** What the user did. */
148
+ action: "add" | "update" | "delete";
149
+ /** The event the user acted on, as it was shown (an occurrence, for a series). */
150
+ event: CalendarEvent;
151
+ /**
152
+ * The scope chosen in the plugin's scope dialog, when a plugin manages the
153
+ * event; otherwise undefined. The recurrence plugin passes its
154
+ * `RecurrenceEditScope` (`'this' | 'following' | 'all'`).
155
+ */
156
+ scope?: unknown;
157
+ /** New rows, the same ones passed to `onEventAdd`. */
158
+ added: CalendarEvent[];
159
+ /** Changed rows, the same ones passed to `onEventUpdate`. */
160
+ updated: CalendarEvent[];
161
+ /** Removed rows, the same ones passed to `onEventDelete`. */
162
+ deleted: CalendarEvent[];
163
+ }
164
+ /**
132
165
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
133
166
  * Carries the resource axis (`resources`, `orientation`) so a resource-capable
134
167
  * view can compose both arrangements. `range()` receives only the
@@ -342,9 +375,10 @@ interface EventMutationScopeSlotContext {
342
375
  resolve: (scope: unknown) => void;
343
376
  cancel: () => void;
344
377
  }
378
+ import { ConfigType, Dayjs as DayjsInstance, ManipulateType as DayjsManipulateType } from "dayjs";
345
379
  import dayjs from "dayjs";
346
- type Dayjs3 = dayjs.Dayjs3;
347
- type ManipulateType3 = dayjs.ManipulateType3;
380
+ type Dayjs3 = DayjsInstance;
381
+ type ManipulateType3 = DayjsManipulateType;
348
382
  /**
349
383
  * dayjs's statics without its call signatures. Mapping over the keys drops the
350
384
  * call signatures, which is what lets the exported type re-advertise only the
@@ -364,27 +398,8 @@ type DayjsStatics = { [K in keyof typeof dayjs] : (typeof dayjs)[K] };
364
398
  * (https://day.js.org/docs/en/parse/string-format). To read a bare wall-clock
365
399
  * string as a time in a given zone, call `dayjs.tz(input, timezone)`.
366
400
  */
367
- type ConfiguredDayjs = ((date?: dayjs.ConfigType) => dayjs.Dayjs3) & DayjsStatics;
401
+ type ConfiguredDayjs = ((date?: ConfigType) => DayjsInstance) & DayjsStatics;
368
402
  declare const _default: ConfiguredDayjs;
369
- /**
370
- * The calendar's plugin mount points. These belong to the host (the components
371
- * that render them: the event form and the drag-and-drop flow), NOT to the
372
- * plugin kernel and NOT to any individual plugin. The kernel's `renderSlot`
373
- * takes a plain `slotName: string` and knows nothing about this list; the core
374
- * renders these named slots and any plugin may fill the ones it cares about.
375
- */
376
- declare const SLOT_EVENT_FORM = "event-form";
377
- declare const SLOT_EVENT_MUTATION_SCOPE = "event-mutation-scope";
378
- interface EventFormProps {
379
- open?: boolean;
380
- selectedEvent?: CalendarEvent | null;
381
- onAdd?: (event: CalendarEvent) => void;
382
- onUpdate?: (event: CalendarEvent) => void;
383
- onDelete?: (event: CalendarEvent) => void;
384
- onClose: () => void;
385
- }
386
- import React4 from "react";
387
- import React3 from "react";
388
403
  declare const defaultTranslations: {
389
404
  today: string;
390
405
  create: string;
@@ -477,6 +492,25 @@ type Translations = Record<keyof typeof defaultTranslations, string>;
477
492
  type TranslationKey = keyof Translations;
478
493
  type TranslatorFunction = (key: TranslationKey | string) => string;
479
494
  /**
495
+ * The calendar's plugin mount points. These belong to the host (the components
496
+ * that render them: the event form and the drag-and-drop flow), NOT to the
497
+ * plugin kernel and NOT to any individual plugin. The kernel's `renderSlot`
498
+ * takes a plain `slotName: string` and knows nothing about this list; the core
499
+ * renders these named slots and any plugin may fill the ones it cares about.
500
+ */
501
+ declare const SLOT_EVENT_FORM = "event-form";
502
+ declare const SLOT_EVENT_MUTATION_SCOPE = "event-mutation-scope";
503
+ interface EventFormProps {
504
+ open?: boolean;
505
+ selectedEvent?: CalendarEvent | null;
506
+ onAdd?: (event: CalendarEvent) => void;
507
+ onUpdate?: (event: CalendarEvent) => void;
508
+ onDelete?: (event: CalendarEvent) => void;
509
+ onClose: () => void;
510
+ }
511
+ import React3 from "react";
512
+ import { ReactNode as ReactNode4 } from "react";
513
+ /**
480
514
  * Available calendar view types. The built-in views (day, week, month, year)
481
515
  * are `PluginView` specs in `features/calendar/components/views`; plugins may
482
516
  * contribute additional view names, so this is a broad `string`.
@@ -627,7 +661,7 @@ interface IlamyCalendarProps {
627
661
  * and `top: var(--ilamy-sticky-top)`, which each grid publishes to clear
628
662
  * its own sticky column and header.
629
663
  */
630
- renderEvent?: (event: CalendarEvent, segment: EventSegment) => React3.ReactNode;
664
+ renderEvent?: (event: CalendarEvent, segment: EventSegment) => ReactNode4;
631
665
  /**
632
666
  * Callback when an event is clicked.
633
667
  * Provides the clicked event object.
@@ -673,6 +707,13 @@ interface IlamyCalendarProps {
673
707
  */
674
708
  onEventDelete?: (event: CalendarEvent) => void;
675
709
  /**
710
+ * Callback once per user action, with every stored row it touched: what
711
+ * `onEventAdd`, `onEventUpdate` and `onEventDelete` report one row at a time.
712
+ * Use it to save a recurring edit (series, override, deleted overrides) as
713
+ * one unit. The per-row callbacks still fire; use one or the other.
714
+ */
715
+ onEventsChange?: (change: EventsChange) => void;
716
+ /**
676
717
  * Callback when the current date changes (navigation).
677
718
  * Provides the new current date and the current visible range.
678
719
  */
@@ -747,7 +788,7 @@ interface IlamyCalendarProps {
747
788
  * Custom header component to replace the default calendar header.
748
789
  * Useful for adding custom branding or additional controls.
749
790
  */
750
- headerComponent?: React3.ReactNode;
791
+ headerComponent?: ReactNode4;
751
792
  /**
752
793
  * Custom class name for the calendar header.
753
794
  * Useful for applying custom styles to the header.
@@ -765,7 +806,7 @@ interface IlamyCalendarProps {
765
806
  * If provided, it will override the default event form component.
766
807
  * The function receives EventFormProps and should return a React node.
767
808
  */
768
- renderEventForm?: (props: EventFormProps) => React3.ReactNode;
809
+ renderEventForm?: (props: EventFormProps) => ReactNode4;
769
810
  /**
770
811
  * Called when the "+N more" overflow indicator in a month/grid cell is
771
812
  * clicked, receiving the cell's day and its full list of events.
@@ -834,7 +875,7 @@ interface IlamyCalendarProps {
834
875
  * }}
835
876
  * ```
836
877
  */
837
- renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React3.ReactNode;
878
+ renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => ReactNode4;
838
879
  /**
839
880
  * Days of the week to hide from the week view.
840
881
  * Hidden days won't render as columns, giving remaining days more space.
@@ -858,7 +899,7 @@ interface IlamyCalendarProps {
858
899
  * Custom render function for the hour labels in the gutter/header.
859
900
  * Receives a Dayjs object for the hour and should return a React node.
860
901
  */
861
- renderHour?: (date: Dayjs3) => React3.ReactNode;
902
+ renderHour?: (date: Dayjs3) => ReactNode4;
862
903
  /**
863
904
  * Granularity of the time grid in minutes for day, week, and resource hour views.
864
905
  * Quarter-hour increments only: `15`, `30`, or `60`.
@@ -878,7 +919,8 @@ interface IlamyCalendarProps {
878
919
  * the requested hour.
879
920
  *
880
921
  * Reapplied whenever the visible date range changes (navigation, view
881
- * switch) and whenever `scrollTime` itself changes, as FullCalendar does.
922
+ * switch), the rendered hours change, or `scrollTime` itself changes, as
923
+ * FullCalendar does.
882
924
  * Ordinary re-renders leave the user's own scroll position alone.
883
925
  * `scrollToNow` takes precedence while the current moment is on screen.
884
926
  *
@@ -909,9 +951,9 @@ interface IlamyCalendarProps {
909
951
  * Applies only while now is on screen. On a range without it (after
910
952
  * navigating away, or when the current hour or day is hidden) the grid
911
953
  * falls back to `scrollTime`, or to its start. Like `scrollTime`, it is
912
- * applied when the range changes and when this prop changes, not as the
913
- * clock moves, so it never pulls the grid away from a reader. "Now" is the
914
- * current instant; the calendar's `timezone` only decides how it is drawn.
954
+ * applied when the range, rendered hours, or this prop changes. Clock
955
+ * movement alone never changes the scroll position. "Now" is the current
956
+ * instant; the calendar's `timezone` only decides how it is drawn.
915
957
  *
916
958
  * Now is lined up with the leading edge, like `scrollTime`. Late in the day
917
959
  * or month there is not enough grid left to do that, and the browser stops
@@ -939,7 +981,7 @@ interface IlamyCalendarProps {
939
981
  */
940
982
  resources?: Resource[];
941
983
  /** Custom render function for resource header cells. */
942
- renderResource?: (resource: Resource) => React3.ReactNode;
984
+ renderResource?: (resource: Resource) => ReactNode4;
943
985
  /**
944
986
  * How resources are arranged. Only applies when `resources` is set.
945
987
  * - "horizontal": resources are rows, time is columns (default)
@@ -954,8 +996,8 @@ interface IlamyCalendarProps {
954
996
  */
955
997
  weekViewGranularity?: "hourly" | "daily";
956
998
  }
957
- declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
958
- import React5 from "react";
999
+ declare const IlamyCalendar: React3.FC<IlamyCalendarProps>;
1000
+ import React4 from "react";
959
1001
  /**
960
1002
  * @deprecated Since v2.0 `IlamyCalendar` accepts `resources`, `renderResource`,
961
1003
  * `orientation`, and `weekViewGranularity` directly — use it instead. This
@@ -963,8 +1005,8 @@ import React5 from "react";
963
1005
  */
964
1006
  type IlamyResourceCalendarProps = IlamyCalendarProps;
965
1007
  /** @deprecated Since v2.0 — use `IlamyCalendar` with the `resources` prop. */
966
- declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
967
- import React6 from "react";
1008
+ declare const IlamyResourceCalendar: React4.FC<IlamyResourceCalendarProps>;
1009
+ import React5 from "react";
968
1010
  /**
969
1011
  * The public calendar API surface exposed by useIlamyCalendarContext() — for consumers and plugin
970
1012
  * components. The full internal context is intentionally not exported.
@@ -1006,7 +1048,7 @@ interface IlamyCalendarApi {
1006
1048
  * plugin views (e.g. agenda) render the indicator consistently with the
1007
1049
  * built-in views via the shared `@ilamy/ui` CurrentTimeIndicator.
1008
1050
  */
1009
- readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React6.ReactNode;
1051
+ readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React5.ReactNode;
1010
1052
  /**
1011
1053
  * Events whose resource membership (`resourceIds`, falling back to
1012
1054
  * `resourceId`) contains the given resource. On a calendar without
@@ -1022,7 +1064,7 @@ interface IlamyCalendarApi {
1022
1064
  readonly applyScopedEdit: (event: CalendarEvent, updates: Partial<CalendarEvent>, scope: unknown) => void;
1023
1065
  readonly applyScopedDelete: (event: CalendarEvent, scope: unknown) => void;
1024
1066
  readonly getEventManager: (event: CalendarEvent) => IlamyPlugin | undefined;
1025
- readonly renderSlot: (slotName: string, context: unknown) => React6.ReactNode[];
1067
+ readonly renderSlot: (slotName: string, context: unknown) => React5.ReactNode[];
1026
1068
  readonly collect: (point: string, context: unknown) => unknown[];
1027
1069
  readonly getViews: () => PluginView[];
1028
1070
  }
@@ -1031,4 +1073,4 @@ interface IlamyCalendarApi {
1031
1073
  * Returns a limited set of commonly used properties and methods.
1032
1074
  */
1033
1075
  declare function useIlamyCalendarContext(): IlamyCalendarApi;
1034
- export { BusinessHours, CalendarClassesOverride, CalendarEvent, CalendarView, CellInfo, ColumnSpec, Dayjs3 as Dayjs, EventFormProps, EventFormSlotContext, EventMutationScopeSlotContext, EventSegment, HorizontalCellSpec, HorizontalRowSpec, IlamyCalendar, IlamyCalendarApi, IlamyCalendarProps, IlamyPlugin, IlamyResourceCalendar, IlamyResourceCalendarProps, ManipulateType3 as ManipulateType, OpenEventFormInput, PluginDateRange, PluginMutationArgs, PluginMutationResult, PluginView, RenderCurrentTimeIndicatorProps, Resource, SLOT_EVENT_FORM, SLOT_EVENT_MUTATION_SCOPE, SlotDuration, TimeFormat, TranslationKey, Translations, TranslatorFunction, VerticalColumnSpec, ViewConfig, ViewHeaderContext, WeekDays, _default as dayjs, defaultTranslations, useIlamyCalendarContext };
1076
+ export { BusinessHours, CalendarClassesOverride, CalendarEvent, CalendarView, CellInfo, ColumnSpec, Dayjs3 as Dayjs, EventFormProps, EventFormSlotContext, EventMutationScopeSlotContext, EventSegment, EventsChange, HorizontalCellSpec, HorizontalRowSpec, IlamyCalendar, IlamyCalendarApi, IlamyCalendarProps, IlamyPlugin, IlamyResourceCalendar, IlamyResourceCalendarProps, ManipulateType3 as ManipulateType, OpenEventFormInput, PluginDateRange, PluginMutationArgs, PluginMutationResult, PluginView, RenderCurrentTimeIndicatorProps, Resource, SLOT_EVENT_FORM, SLOT_EVENT_MUTATION_SCOPE, SlotDuration, TimeFormat, TranslationKey, Translations, TranslatorFunction, VerticalColumnSpec, ViewConfig, ViewHeaderContext, WeekDays, _default as dayjs, defaultTranslations, useIlamyCalendarContext };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import{t}from"./shared/chunk-kpzykmz4.js";import{r,me,l,oe,p,g,U,ie,le,k,N,O,a,i,V,Y,n,K,q,X,I,de,j,Z,x,L,H,z,Q,J,ee,te,re,M,ne,ce,ae,B}from"./shared/chunk-tvq5v791.js";import{e,d,ue}from"./shared/chunk-h5d5q285.js";import{R,w,S,F,P,_}from"./shared/chunk-5kjrv081.js";import{o,v,m,s,C,D,h,E,f}from"./shared/chunk-jge2sq3v.js";import{u,y}from"./shared/chunk-m1q73v86.js";var lr="event-form",dr="event-mutation-scope",cr=({event:c,onChange:b})=>r((A)=>A.renderSlot)(lr,{event:c,onChange:b}),ft=({dialog:c,onResolve:b,onCancel:T})=>{let A=r((pe)=>pe.getEventManager);if(!(c.isOpen&&c.event))return null;let G=A(c.event),W={event:c.event,operation:c.operation,resolve:b,cancel:T};return G?.renderSlot?.(dr,W)};import{useEffect as ri,useMemo as oi}from"react";import{DndContext as hn,pointerWithin as En}from"@dnd-kit/core";import{useId as bn}from"react";import{MouseSensor as rn,TouchSensor as on,useSensor as ur,useSensors as nn}from"@dnd-kit/core";import{useEffect as an,useRef as gt,useState as sn}from"react";var en=(c)=>c.hour!==void 0,Lt=(c,b,T=g)=>{let{date:A,hour:G=0,minute:W=0,allDay:pe}=b,se=c.end.diff(c.start,"second"),fe=(xe)=>({start:xe,end:xe.add(se,"second")});if(en(b)){let Re=t(A).hour(G).minute(W).subtract(T.minutes,"minute");return{...fe(Re),allDay:!1}}let ve=t(A).subtract(T.days,"day"),ge=pe===!0,ye=pe===void 0,Ce=Boolean(c.allDay);if(ge||ye&&Ce)return{...fe(ve.startOf("day")),allDay:!0};let Ee=ve.format("YYYY-MM-DD"),De=c.start.format("HH:mm:ss.SSS"),we=t(`${Ee}T${De}`);return{...fe(we),allDay:!1}},tn=(c,b,T)=>{if(T===void 0||b===T)return{};if(!c.resourceIds)return{resourceId:T};let G=c.resourceIds.indexOf(b);if(G===-1)return{};let W=c.resourceIds.slice();if(W.splice(G,1),!W.includes(T))W.push(T);return{resourceIds:W}},mr=(c,b,T=g)=>{let{active:A,over:G}=c;if(!A||!G||!b)return null;let W=G.data.current||{};if(W.disabled)return null;let{resourceId:pe}=W,{start:se,end:fe,allDay:ve}=Lt(b,W,T),ge=A.data.current?.sourceResourceId,ye={start:se,end:fe,...tn(b,ge,pe),allDay:ve};return{activeEvent:b,updates:ye}};var ln=(c,b)=>{if(!c)return!1;let T=c.start.isSame(b.start)&&c.end.isSame(b.end),A=c.resourceId===b.resourceId&&c.allDay===b.allDay,G=c.isDropAllowed===b.isDropAllowed;return T&&A&&G},dn=({active:c,activatorEvent:b})=>{if(c.data.current?.type!=="calendar-event")return null;let T=c.data.current.event,A=c.data.current.dragSegment;if(!A)return{calendarEvent:T,pending:null};let G=c.data.current.getBarRect;return{calendarEvent:T,pending:{calendarEvent:T,segment:A,activatorEvent:b,barRect:G?.()}}},cn=(c,b,T)=>{let A=b??{},{start:G,end:W,allDay:pe}=Lt(c,A,T);return{event:c,start:G,end:W,resourceId:A.resourceId??c.resourceId,allDay:pe,isDropAllowed:!A.disabled}},mn=(c)=>{let b=le(c);an(()=>{if(!b)return;let T=document.body.style.cursor;return document.body.style.cursor=b,()=>{document.body.style.cursor=T}},[b])},un=()=>{let c=ur(rn,{activationConstraint:{distance:2}}),b=ur(on,{activationConstraint:{delay:100,tolerance:5}});return nn(c,b)},pr=(c)=>{let b=r((he)=>he.slotDuration),T=un(),A=gt(null),G=gt(g),W=gt(null),pe=gt(null),[se,fe]=sn(null);mn(se);let ve=()=>{A.current=null,G.current=g,W.current=null,fe(null),pe.current?.setActiveEvent(null)},ge=(he)=>{let Ee=dn(he);if(!Ee)return;pe.current?.setActiveEvent(Ee.calendarEvent),A.current=Ee.calendarEvent,G.current=g,W.current=Ee.pending},ye=(he)=>{let Ee=W.current;if(!Ee)return;let De=Ee.barRect??he.active.rect.current.initial;if(!De)return;G.current=ie({activeEvent:Ee.calendarEvent,initialRect:De,activatorEvent:Ee.activatorEvent,segment:Ee.segment,slotDurationMinutes:b}),W.current=null};return{sensors:T,dragPreview:se,overlayRef:pe,handlers:{onDragStart:ge,onDragOver:(he)=>{ye(he);let Ee=A.current;if(!Ee||!he.over){fe(null);return}let De=cn(Ee,he.over.data.current,G.current);fe((we)=>{if(ln(we,De))return we;return De})},onDragEnd:(he)=>{let Ee=mr(he,A.current,G.current);if(Ee)c(Ee.activeEvent,Ee.updates);ve()},onDragCancel:ve}}};import{useCallback as vt,useEffect as pn,useRef as fn,useState as gn}from"react";var Ft={isOpen:!1,operation:"edit",event:null};function yt(c){let{applyScopedEdit:b,applyScopedDelete:T}=r((ge)=>({applyScopedEdit:ge.applyScopedEdit,applyScopedDelete:ge.applyScopedDelete})),[A,G]=gn(Ft),W=fn(A);pn(()=>{W.current=A},[A]);let pe=vt((ge,ye)=>{G({isOpen:!0,operation:"edit",event:ge,updates:ye})},[]),se=vt((ge)=>{G({isOpen:!0,operation:"delete",event:ge})},[]),fe=vt(()=>G(Ft),[]),ve=vt((ge)=>{let ye=W.current;if(!ye.event)return;if(ye.operation==="edit")b(ye.event,ye.updates??{},ge);else T(ye.event,ge);G(Ft),c?.()},[b,T,c]);return{dialogState:A,openEditDialog:pe,openDeleteDialog:se,closeDialog:fe,handleConfirm:ve}}var fr=()=>{let{updateEvent:c,getEventManager:b}=r((se)=>({updateEvent:se.updateEvent,getEventManager:se.getEventManager})),{dialogState:T,openEditDialog:A,closeDialog:G,handleConfirm:W}=yt();return{commitDrop:(se,fe)=>{let ve=Object.keys(fe).length===0;if(!se.id||ve)return;if(b(se)?.applyEdit){A(se,fe);return}c(se.id,fe)},scopeDialog:{dialog:T,onCancel:G,onResolve:W}}};import{DragOverlay as vn}from"@dnd-kit/core";import{snapCenterToCursor as yn}from"@dnd-kit/modifiers";import{useImperativeHandle as Dn,useState as Cn}from"react";import{jsx as gr}from"react/jsx-runtime";var vr=({ref:c})=>{let[b,T]=Cn(null),A=p();if(Dn(c,()=>({setActiveEvent:T})),A)return null;return gr(vn,{modifiers:[yn],children:b&&gr("div",{className:e("cursor-grabbing truncate rounded-md px-3 py-1.5 text-xs font-medium shadow-xl opacity-80",k(b)),style:N(b),children:b.title})})};import{jsx as yr,jsxs as Dr}from"react/jsx-runtime";function Cr({children:c}){let b=bn(),T=r((ve)=>ve.disableDragAndDrop),{commitDrop:A,scopeDialog:G}=fr(),{sensors:W,dragPreview:pe,overlayRef:se,handlers:fe}=pr(A);if(T)return c;return Dr(oe.Provider,{value:pe,children:[Dr(hn,{collisionDetection:En,id:b,sensors:W,...fe,children:[c,yr(vr,{ref:se})]}),yr(ft,{...G})]})}import{ChevronDownIcon as Sn}from"lucide-react";import{useEffect as xn,useState as wn}from"react";import*as Le from"@radix-ui/react-popover";import{jsx as Dt}from"react/jsx-runtime";function ze({...c}){return Dt(Le.Root,{"data-slot":"popover",...c})}function Ye({...c}){return Dt(Le.Trigger,{"data-slot":"popover-trigger",...c})}function _e({className:c,align:b="center",sideOffset:T=4,...A}){return Dt(Le.Portal,{children:Dt(Le.Content,{align:b,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",c),"data-slot":"popover-content",sideOffset:T,...A})})}import{jsx as je,jsxs as it}from"react/jsx-runtime";var hr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Gt=(c)=>Boolean(c&&hr.test(c)),Pn=(c)=>{let b=c.match(/bg-([a-z]+)-\d+/)?.at(1);if(!b)return"Custom";return b.charAt(0).toUpperCase()+b.slice(1)};function Er({value:c,onChange:b,swatches:T=[],className:A,"aria-label":G="Select color"}){let[W,pe]=wn(Gt(c)?c:"");xn(()=>{pe(Gt(c)?c:"")},[c]);let se=(ye)=>{let Ce=ye.target.value;if(pe(Ce),hr.test(Ce))b(Ce)},fe=Gt(c),ve=T.find((ye)=>ye.value===c),ge;if(ve)ge=ve.label;else if(fe)ge=c;else if(c)ge=Pn(c);else ge="Pick a color";return it(ze,{children:[it(Ye,{"aria-label":G,className:e("border-input focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 text-sm shadow-xs outline-none focus-visible:ring-[3px]",A),"data-slot":"color-picker-trigger",type:"button",children:[it("span",{className:"flex items-center gap-2",children:[je("span",{className:e("size-5 shrink-0 rounded-full border",!fe&&c),style:fe?{backgroundColor:c}:void 0}),je("span",{className:e(fe&&"font-mono text-xs"),children:ge})]}),je(Sn,{className:"size-4 shrink-0 opacity-50"})]}),it(_e,{className:"w-56","data-slot":"color-picker-content",children:[T.length>0&&je("div",{className:"grid grid-cols-7 gap-1.5",children:T.map((ye)=>{let Ce=c===ye.value;return je("button",{"aria-label":ye.label,"aria-pressed":Ce,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",ye.value,Ce&&"ring-ring ring-2 ring-offset-1"),onClick:()=>b(ye.value),type:"button"},ye.value)})}),je("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),it("div",{className:"flex items-center gap-2",children:[je("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(ye)=>b(ye.target.value),type:"color",value:fe?c:"#000000"}),je(m,{"aria-label":"Hex color",className:"font-mono",onChange:se,placeholder:"#000000",value:W})]})]})]})}import{jsx as Tn}from"react/jsx-runtime";function br({className:c,...b}){return Tn("textarea",{className:e("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",c),"data-slot":"textarea",...b})}import{useEffect as jn,useState as Oe}from"react";import{PopoverClose as Vn}from"@radix-ui/react-popover";import{Calendar as An}from"lucide-react";import{useEffect as Ln,useRef as Fn,useState as Gn}from"react";import{useState as Mn}from"react";import{ChevronLeftIcon as Rn,ChevronRightIcon as Nn}from"lucide-react";import{jsx as st,jsxs as kn}from"react/jsx-runtime";function Qe({label:c,onPrev:b,onNext:T,prevLabel:A,nextLabel:G}){return kn("div",{className:"mb-2 flex items-center justify-between",children:[st(o,{"aria-label":A,onClick:b,size:"icon",variant:"ghost",children:st(Rn,{className:"size-4"})}),st("div",{className:"text-sm font-medium select-none",children:c}),st(o,{"aria-label":G,onClick:T,size:"icon",variant:"ghost",children:st(Nn,{className:"size-4"})})]})}import{jsx as Fe,jsxs as Sr}from"react/jsx-runtime";function Hn(c){let b=c.weekHover&&!c.isCurrentWeek;return e("p-0 text-center",c.weekHover&&"first:rounded-l-md last:rounded-r-md",b&&"group-hover/week:bg-accent",c.isCurrentWeek&&"bg-primary")}function In(c){return e("w-full aspect-square text-sm select-none",!c.isDisabled&&"cursor-pointer",!(c.weekHover||c.isDisabled)&&"hover:bg-accent rounded-md",c.isOutside&&"text-muted-foreground/50",c.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",c.isCurrentWeek&&"text-primary-foreground font-medium",c.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",c.isDisabled&&"opacity-50 cursor-not-allowed")}function On({day:c,state:b,onSelect:T}){return Fe("td",{className:Hn(b),"data-disabled":b.isDisabled,"data-outside":b.isOutside,"data-selected":b.isSelected,role:"gridcell",tabIndex:-1,children:Fe("button",{"aria-disabled":b.isDisabled,"aria-hidden":b.isOutside,className:In(b),"data-disabled":b.isDisabled,"data-selected":b.isSelected,disabled:b.isDisabled||b.isOutside,onClick:()=>T?.(c.toDate()),tabIndex:b.isOutside?-1:0,type:"button",children:c.format("D")})})}function lt({selected:c,defaultMonth:b,onSelect:T,disabled:A,firstDayOfWeek:G=0,className:W,weekHover:pe=!1,highlightedWeekOf:se}){let[fe,ve]=Mn(()=>t(b??c??new Date).startOf("month")),ge=V(fe,G),ye=c?t(c).format("YYYY-MM-DD"):void 0,Ce=i(t(),G).map((De)=>De.format("dd")),Se,he;if(se){let De=i(se,G);Se=De.at(0),he=De.at(-1)}let Ee=(De)=>{let we=De.format("YYYY-MM-DD")===ye,xe=!1;if(Se&&he){let Re=!De.isBefore(Se,"day"),Pe=!De.isAfter(he,"day");xe=Re&&Pe}return{isOutside:!De.isSame(fe,"month"),isSelected:we,isDisabled:A?.(De.toDate())??!1,isCurrent:a(De)&&!we,isCurrentWeek:xe,weekHover:pe}};return Sr("div",{className:e("bg-background p-3 w-72",W),"data-slot":"calendar",children:[Fe(Qe,{label:fe.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>ve((De)=>De.add(1,"month")),onPrev:()=>ve((De)=>De.subtract(1,"month")),prevLabel:"Previous month"}),Sr("table",{className:"w-full border-collapse",role:"grid",children:[Fe("thead",{children:Fe("tr",{children:Ce.map((De,we)=>Fe("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:De},we))})}),Fe("tbody",{children:ge.map((De,we)=>Fe("tr",{className:e(pe&&"group/week"),children:De.map((xe)=>Fe(On,{day:xe,onSelect:T,state:Ee(xe)},xe.toISOString()))},we))})]})]})}import{jsx as Je,jsxs as Bt}from"react/jsx-runtime";function xr({date:c,closeOnSelect:b,onChange:T,label:A="Pick a date",className:G,disabled:W}){let pe=r((ye)=>ye.firstDayOfWeek),se=Fn(null),[fe,ve]=Gn(c);Ln(()=>{ve(c)},[c]);let ge=(ye)=>{if(ve(ye),b)se.current?.click();T?.(ye)};return Je("div",{className:G,children:Bt(ze,{children:[Je(Ye,{asChild:!0,children:Bt(o,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!c,variant:"outline",children:[Je(An,{}),fe?t(fe).format("ll"):Je("span",{children:A})]})}),Bt(_e,{align:"start",className:"w-auto p-0",children:[Je(Vn,{ref:se,style:{display:"none"}}),Je(lt,{defaultMonth:fe,disabled:W,firstDayOfWeek:pe,onSelect:ge,selected:fe})]})]})})}import{Clock as zn}from"lucide-react";import{useEffect as Yn,useRef as Pr,useState as zt}from"react";import{useMemo as Bn}from"react";function wr({timeFormat:c="12-hour",minTime:b="00:00",maxTime:T="23:45"}){return{timeOptions:Bn(()=>{let W=[],[pe,se]=b.split(":").map(Number),[fe,ve]=T.split(":").map(Number),ge=pe*60+se,ye=fe*60+ve;for(let Ce=ge;Ce<=ye;Ce+=15){let Se=Math.floor(Ce/60),he=Ce%60,Ee=`${Se.toString().padStart(2,"0")}:${he.toString().padStart(2,"0")}`;W.push(Ee)}return W},[b,T]),formatTime:(W)=>{let[pe,se]=W.split(":").map(Number);if(c==="24-hour")return`${pe.toString().padStart(2,"0")}:${se.toString().padStart(2,"0")}`;let fe=pe>=12?"PM":"AM",ve=pe;if(pe===0)ve=12;else if(pe>12)ve=pe-12;return`${ve}:${se.toString().padStart(2,"0")} ${fe}`}}}import{jsx as $e,jsxs as Yt}from"react/jsx-runtime";var _n=(c)=>{c.stopPropagation()};function Tr({value:c,onChange:b,minTime:T="00:00",maxTime:A="23:45",timeFormat:G="12-hour",placeholder:W="Select time...",className:pe,disabled:se=!1,name:fe}){let[ve,ge]=zt(!1),[ye,Ce]=zt(""),Se=Pr(null),he=Pr(null),[Ee,De]=zt(0),{timeOptions:we,formatTime:xe}=wr({timeFormat:G,minTime:T,maxTime:A}),Re=we.filter((Me)=>xe(Me).toLowerCase().includes(ye.toLowerCase())),Pe=(Me)=>{b(Me),ge(!1),Ce("")};Yn(()=>{if(ve){if(he.current)De(he.current.offsetWidth);setTimeout(()=>{Se.current?.focus()},0)}},[ve]);let Ge=c?xe(c):W;return Yt(ze,{onOpenChange:ge,open:ve,children:[$e(Ye,{asChild:!0,children:Yt(o,{"aria-controls":"time-picker-listbox","aria-expanded":ve,className:e("w-full justify-start",pe),"data-testid":n.timePicker(fe),disabled:se,ref:he,role:"combobox",variant:"outline",children:[$e(zn,{className:"mr-2 h-4 w-4"}),Ge]})}),Yt(_e,{align:"start",className:"p-0",style:{width:Ee},children:[$e("div",{className:"p-2 border-b",children:$e(m,{className:"h-8",onChange:(Me)=>Ce(Me.target.value),placeholder:"Search time...",ref:Se,value:ye})}),$e(u,{className:"h-[200px]",onWheel:_n,children:$e("div",{className:"p-1",children:Re.length===0?$e("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):Re.map((Me)=>{let mt=xe(Me);return $e("button",{className:e("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",Me===c&&"bg-accent text-accent-foreground"),onClick:()=>Pe(Me),type:"button",children:mt},Me)})})})]})]})}var Rr=(c,b)=>{let[T,A]=b.split(":").map(Number);return t(c).hour(T).minute(A).second(0).millisecond(0)},Nr=(c,b,T)=>{let A=Rr(c,b);return T?A.hour(0).minute(0):A},kr=(c,b,T)=>{let A=Rr(c,b);return T?A.add(1,"day").startOf("day"):A},_t=(c,b)=>{if(!b)return{min:"00:00",max:"23:59"};let T=t(c),{minStart:A,maxEnd:G,hasBusinessHours:W}=Z({allDates:[T],businessHours:b,hideNonBusinessHours:!1});if(!W)return{min:"00:00",max:"23:59"};return{min:`${A.toString().padStart(2,"0")}:00`,max:`${(G-1).toString().padStart(2,"0")}:45`}};import{jsx as Te,jsxs as He,Fragment as Zn}from"react/jsx-runtime";var Mr="bg-blue-100 text-blue-800",$n=[{value:Mr,label:"Blue"},{value:"bg-green-100 text-green-800",label:"Green"},{value:"bg-purple-100 text-purple-800",label:"Purple"},{value:"bg-red-100 text-red-800",label:"Red"},{value:"bg-yellow-100 text-yellow-800",label:"Yellow"},{value:"bg-pink-100 text-pink-800",label:"Pink"},{value:"bg-indigo-100 text-indigo-800",label:"Indigo"},{value:"bg-amber-100 text-amber-800",label:"Amber"},{value:"bg-emerald-100 text-emerald-800",label:"Emerald"},{value:"bg-sky-100 text-sky-800",label:"Sky"},{value:"bg-violet-100 text-violet-800",label:"Violet"},{value:"bg-rose-100 text-rose-800",label:"Rose"},{value:"bg-teal-100 text-teal-800",label:"Teal"},{value:"bg-orange-100 text-orange-800",label:"Orange"}],Hr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Wn=(c,b)=>{if(c&&Hr.test(c))return c;return b??Mr},Un=(c)=>{if(Hr.test(c))return{backgroundColor:c,color:ue(c)};return{backgroundColor:void 0,color:c}},Kn=({colorChanged:c,hadInitialColor:b,selectedColor:T,initialBackgroundColor:A,initialColor:G})=>{if(c||!b)return Un(T);return{backgroundColor:A,color:G}},jt=({name:c,label:b,placeholder:T,value:A,required:G=!1,multiline:W=!1,onChange:pe})=>He("div",{className:"grid gap-1 sm:gap-2",children:[Te(s,{className:"text-xs sm:text-sm",htmlFor:c,children:b}),W?Te(br,{className:"min-h-16 text-sm",id:c,name:c,onChange:pe,placeholder:T,required:G,value:A}):Te(m,{className:"h-8 text-sm sm:h-9",id:c,name:c,onChange:pe,placeholder:T,required:G,value:A})]}),Ir=({selectedEvent:c,onClose:b,onUpdate:T,onDelete:A,onAdd:G})=>{let{dialogState:W,openEditDialog:pe,openDeleteDialog:se,closeDialog:fe,handleConfirm:ve}=yt(b),{t:ge,timeFormat:ye,getEventManager:Ce,resources:Se}=r((be)=>({t:be.t,timeFormat:be.timeFormat,getEventManager:be.getEventManager,resources:be.resources??[]})),{id:he,resourceId:Ee,resourceIds:De,start:we=t(),end:xe=t().add(1,"hour"),allDay:Re=!1,color:Pe,backgroundColor:Ge,title:Me="",description:mt="",location:Jt=""}=c??{},er=Se.length>0,tr=Ee??De?.at(0),rr=er&&tr===void 0,[Nt,Ro]=Oe(tr),kt=er?Nt:Ee,ut=K(kt),or=Boolean(c&&Ce(c)),No=xe.isSame(xe.startOf("day")),ko=Re&&No?xe.subtract(1,"day"):xe,[Ke,nr]=Oe(we.toDate()),[Xe,Mt]=Oe(ko.toDate()),[Be,Mo]=Oe(Re),[Ht,Ho]=Oe(Wn(Ge,Pe)),[Io,Oo]=Oe(!1),Vo=Boolean(Pe||Ge),Ao=(be)=>{Ho(be),Oo(!0)},[It,ar]=Oe(we.format("HH:mm")),[pt,Ot]=Oe(xe.format("HH:mm")),[Ae,Lo]=Oe({title:Me,description:mt,location:Jt}),[Vt,Fo]=Oe({}),Go={...c,...Vt},Bo=(be)=>Fo((Ne)=>({...Ne,...be})),zo=(be)=>{if(!be)return;if(nr(be),t(be).isAfter(t(Xe)))Mt(be)},Yo=(be)=>{if(!be)return;if(Mt(be),be&&t(be).isBefore(t(Ke)))nr(be)},_o=(be)=>{if(Mo(be),!(be&&pt==="00:00"))return;Mt((Ne)=>t(Ne).isAfter(t(Ke),"day")?t(Ne).subtract(1,"day").toDate():Ne)},jo=(be)=>{if(ar(be),t(Ke).isSame(t(Xe),"day")&&be>pt)Ot(be)},$o=(be)=>{if(Ot(be),t(Ke).isSame(t(Xe),"day")&&be<It)ar(be)},At=(be)=>{let{name:Ne,value:Ie}=be.target;Lo((nt)=>({...nt,[Ne]:Ie}))};jn(()=>{if(Be)Ot("23:59")},[Be]);let Wo=(be)=>Se.find((Ie)=>String(Ie.id)===be)?.id??be,ir=rr&&Nt===void 0,Uo=(be)=>{if(be.preventDefault(),ir)return;let Ne=Nr(Ke,It,Be),Ie=kr(Xe,pt,Be),nt=Kn({colorChanged:Io,hadInitialColor:Vo,selectedColor:Ht,initialBackgroundColor:Ge,initialColor:Pe}),at={id:he||t().format("YYYYMMDDHHmmss"),title:Ae.title,start:Ne,end:Ie,resourceId:kt,description:Ae.description,location:Ae.location,allDay:Be,...nt,...Vt};if(c?.id&&or){pe(c,{title:Ae.title,start:Ne,end:Ie,resourceId:kt,description:Ae.description,location:Ae.location,allDay:Be,color:Ht,...Vt});return}if(he)T?.(at);else G?.(at);b()},Ko=()=>{if(!c?.id)return;if(or){se(c);return}A?.(c),b()},sr;if(ut)sr=(be)=>!j(t(be),ut);let Zo=_t(Ke,ut),qo=_t(Xe,ut),Xo=[["startDate",Ke,zo],["endDate",Xe,Yo]],Qo=[["startTime","start-time",It,jo,Zo],["endTime","end-time",pt,$o,qo]],Jo=Nt?.toString();return He(Zn,{children:[He("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:Uo,children:[Te(u,{className:"flex-1 min-h-0",children:He("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Te(jt,{label:ge("title"),name:"title",onChange:At,placeholder:ge("eventTitlePlaceholder"),required:!0,value:Ae.title}),Te(jt,{label:ge("description"),multiline:!0,name:"description",onChange:At,placeholder:ge("eventDescriptionPlaceholder"),value:Ae.description}),rr&&He("div",{className:"grid gap-1 sm:gap-2",children:[Te(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ge("resource")}),He(C,{onValueChange:(be)=>Ro(Wo(be)),value:Jo,children:[Te(h,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:Te(D,{placeholder:ge("selectResource")})}),Te(E,{children:Se.map((be)=>Te(f,{value:String(be.id),children:be.title},String(be.id)))})]})]}),He("div",{className:"flex items-center space-x-2",children:[Te(v,{checked:Be,id:"allDay",onCheckedChange:(be)=>_o(be===!0)}),Te(s,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ge("allDay")})]}),Te("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Xo.map(([be,Ne,Ie])=>He("div",{children:[Te(s,{className:"text-xs sm:text-sm",children:ge(be)}),Te(xr,{className:"mt-1",closeOnSelect:!0,date:Ne,disabled:sr,onChange:Ie})]},be))}),!Be&&Te("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Qo.map(([be,Ne,Ie,nt,at])=>He("div",{children:[Te(s,{className:"text-xs sm:text-sm",children:ge(be)}),Te(Tr,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:at.max,minTime:at.min,name:Ne,onChange:nt,placeholder:ge("searchTime"),timeFormat:ye,value:Ie})]},be))}),He("div",{className:"grid gap-1 sm:gap-2",children:[Te(s,{className:"text-xs sm:text-sm",children:ge("color")}),Te(Er,{"aria-label":ge("color"),onChange:Ao,swatches:$n,value:Ht})]}),Te(jt,{label:ge("location"),name:"location",onChange:At,placeholder:ge("eventLocationPlaceholder"),value:Ae.location}),Te(cr,{event:Go,onChange:Bo})]})}),He(F,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[he&&Te(o,{className:"w-full sm:mr-auto sm:w-auto",onClick:Ko,size:"sm",type:"button",variant:"destructive",children:ge("delete")}),He("div",{className:"flex w-full gap-2 sm:w-auto",children:[Te(o,{className:"flex-1 sm:flex-none",onClick:b,size:"sm",type:"button",variant:"outline",children:ge("cancel")}),Te(o,{className:"flex-1 sm:flex-none",disabled:ir,size:"sm",type:"submit",children:he?ge("update"):ge("create")})]})]})]}),Te(ft,{dialog:W,onCancel:fe,onResolve:ve})]})};import{jsx as Ct,jsxs as Or}from"react/jsx-runtime";var Vr=()=>{let{t:c,selectedEvent:b,isEventFormOpen:T,closeEventForm:A,addEvent:G,updateEvent:W,deleteEvent:pe,renderEventForm:se}=r((ye)=>({t:ye.t,selectedEvent:ye.selectedEvent,isEventFormOpen:ye.isEventFormOpen,closeEventForm:ye.closeEventForm,addEvent:ye.addEvent,updateEvent:ye.updateEvent,deleteEvent:ye.deleteEvent,renderEventForm:ye.renderEventForm})),ge={open:T,onClose:A,selectedEvent:b,onAdd:G,onUpdate:(ye)=>{W(ye.id,ye)},onDelete:(ye)=>{pe(ye.id)}};if(se)return se(ge);return Ct(R,{onOpenChange:A,open:T,children:Or(w,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[Or(S,{className:"mb-2 sm:mb-4 shrink-0",children:[Ct(P,{className:"text-base sm:text-lg",children:b?.id?c("editEvent"):c("createEvent")}),Ct(_,{className:"text-xs sm:text-sm",children:b?.id?c("editEventDetails"):c("addNewEvent")})]}),Ct(Ir,{...ge})]})})};import{ChevronLeft as ga,ChevronRight as va,Download as ya,Plus as Da}from"lucide-react";import{ChevronDown as ta}from"lucide-react";import{useState as ra}from"react";function Ar(){let{currentLocale:c,timezone:b}=r((A)=>({currentLocale:A.currentLocale,timezone:A.timezone}));return{formatDateRange:(A,G)=>{let W=new Intl.DateTimeFormat(c,{timeZone:b,month:"short",day:"numeric"});if(A.year()===G.year())return W.formatRange(A.toDate(),G.toDate());return`${W.format(A.toDate())} – ${W.format(G.toDate())}`}}}import{useState as Xn}from"react";import{jsx as qn}from"react/jsx-runtime";function ht({label:c,isSelected:b,isCurrent:T,onSelect:A}){return qn("button",{"aria-pressed":b,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",T&&"ring-1 ring-inset ring-foreground/40",b&&"bg-primary text-primary-foreground"),onClick:A,type:"button",children:c})}import{jsx as $t,jsxs as Qn}from"react/jsx-runtime";function Lr({selected:c,onSelect:b}){let[T,A]=Xn(()=>c.year()),G=t(),W=Array.from({length:12},(pe,se)=>({index:se,label:c.month(se).format("MMM")}));return Qn("div",{className:"w-72 p-3","data-slot":"month-grid",children:[$t(Qe,{label:T,nextLabel:"Next year",onNext:()=>A((pe)=>pe+1),onPrev:()=>A((pe)=>pe-1),prevLabel:"Previous year"}),$t("div",{className:"grid grid-cols-3 gap-1",children:W.map((pe)=>{let se=T===c.year()&&pe.index===c.month(),fe=T===G.year()&&pe.index===G.month()&&!se;return $t(ht,{isCurrent:fe,isSelected:se,label:pe.label,onSelect:()=>b(c.year(T).month(pe.index).date(1))},pe.index)})})]})}import{useState as Jn}from"react";import{jsx as Wt,jsxs as ea}from"react/jsx-runtime";var dt=12;function Fr({selected:c,onSelect:b}){let[T,A]=Jn(()=>c.year()-c.year()%dt),G=t(),W=Array.from({length:dt},(pe,se)=>T+se);return ea("div",{className:"w-72 p-3","data-slot":"year-grid",children:[Wt(Qe,{label:`${T} – ${T+dt-1}`,nextLabel:"Next years",onNext:()=>A((pe)=>pe+dt),onPrev:()=>A((pe)=>pe-dt),prevLabel:"Previous years"}),Wt("div",{className:"grid grid-cols-3 gap-1",children:W.map((pe)=>{let se=pe===c.year(),fe=pe===G.year()&&!se;return Wt(ht,{isCurrent:fe,isSelected:se,label:pe,onSelect:()=>b(c.year(pe))},pe)})})]})}import{jsx as Ze,jsxs as Gr}from"react/jsx-runtime";var oa={day:"day",week:"week",month:"month",year:"year"};function na(c){let b=c?.navigationStep??{amount:1,unit:c?.navigationUnit??"day"};if(b.amount!==1)return"range";return oa[b.unit]??"range"}function Br({className:c}){let{currentDate:b,currentRange:T,view:A,selectDate:G,firstDayOfWeek:W,getViews:pe}=r((Pe)=>({currentDate:Pe.currentDate,currentRange:Pe.currentRange,view:Pe.view,selectDate:Pe.selectDate,firstDayOfWeek:Pe.firstDayOfWeek,getViews:Pe.getViews})),{formatDateRange:se}=Ar(),[fe,ve]=ra(!1),ge=i(b,W),ye=ge.at(0)??b,Ce=ge.at(-1)??b,Se=(Pe)=>{G(Pe),ve(!1)},he=na(pe().find((Pe)=>Pe.name===A)),De={year:b.format("YYYY"),month:b.format("MMM YYYY"),week:se(ye,Ce),day:b.format("ddd, MMM D, YYYY"),range:se(T.start,T.end)}[he],we=Ze(lt,{defaultMonth:b.toDate(),firstDayOfWeek:W,onSelect:(Pe)=>Pe&&Se(t(Pe)),selected:b.toDate()}),Re={year:Ze(Fr,{onSelect:Se,selected:b}),month:Ze(Lr,{onSelect:Se,selected:b}),week:Ze(lt,{defaultMonth:b.toDate(),firstDayOfWeek:W,highlightedWeekOf:b,onSelect:(Pe)=>Pe&&Se(t(Pe)),weekHover:!0}),day:we,range:we}[he];return Gr(ze,{onOpenChange:ve,open:fe,children:[Ze(Ye,{asChild:!0,children:Gr(o,{className:e("font-semibold",c),"data-testid":"calendar-title",variant:"outline",children:[De,Ze(ta,{className:"size-4 shrink-0 opacity-50"})]})}),Ze(_e,{align:"start",className:"w-auto p-0",children:Re})]})}var Ut=`\r
2
- `,aa=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Ut),Et=(c)=>c.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
- `,"\\n").replaceAll("\r",""),zr=(c,b=!1)=>{if(b)return c.format("YYYYMMDD");return c.utc().format("YYYYMMDD[T]HHmmss[Z]")},ia=(c)=>c.uid||`${c.id}@ilamy.calendar`,sa=(c,b)=>{let T=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),A=c.allDay?";VALUE=DATE":"",G=["BEGIN:VEVENT",`UID:${ia(c)}`,`DTSTART${A}:${zr(c.start,c.allDay)}`,`DTEND${A}:${zr(c.end,c.allDay)}`,`SUMMARY:${Et(c.title)}`,c.description&&`DESCRIPTION:${Et(c.description)}`,c.location&&`LOCATION:${Et(c.location)}`].filter(Boolean),W=b("ical:vevent-properties",c).filter((se)=>typeof se==="string"),pe=[`DTSTAMP:${T}`,`CREATED:${T}`,`LAST-MODIFIED:${T}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...G,...W,...pe].join(Ut)},la=(c,b,T="ilamy Calendar")=>{let A=Et(T),G=c.map((W)=>sa(W,b));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${A}`,`X-WR-CALDESC:Exported from ${A}`,aa,...G,"END:VCALENDAR"].join(Ut)},Yr=(c,b,T="calendar.ics",A="ilamy Calendar")=>{let G=new Blob([la(c,b,A)],{type:"text/calendar;charset=utf-8"}),W=URL.createObjectURL(G),pe=T;if(!T.endsWith(".ics"))pe=`${T}.ics`;let se=document.createElement("a");se.href=W,se.download=pe,document.body.append(se),se.click(),se.remove(),URL.revokeObjectURL(W)};function _r(){let{rawEvents:c,collect:b}=r((T)=>({rawEvents:T.rawEvents,collect:T.collect}));return()=>{let T=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Yr(c,b,T,"ilamy Calendar")}}import*as Ve from"@radix-ui/react-dropdown-menu";import{jsx as ct}from"react/jsx-runtime";function jr({...c}){return ct(Ve.Root,{"data-slot":"dropdown-menu",...c})}function $r({...c}){return ct(Ve.Trigger,{"data-slot":"dropdown-menu-trigger",...c})}function Wr({className:c,sideOffset:b=4,align:T="end",...A}){return ct(Ve.Portal,{children:ct(Ve.Content,{align:T,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",c),"data-slot":"dropdown-menu-content",sideOffset:b,...A})})}function Ur({className:c,...b}){return ct(Ve.Item,{className:e("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",c),"data-slot":"dropdown-menu-item",...b})}import{Check as da,ChevronDown as ca}from"lucide-react";function bt(){let{getViews:c,resources:b}=r((A)=>({getViews:A.getViews,resources:A.resources})),T=Boolean(b?.length);return c().filter((A)=>!T||A.supportsResources)}import{jsx as We,jsxs as Kt}from"react/jsx-runtime";function Kr({className:c}){let{view:b,setView:T,t:A}=r((fe)=>({view:fe.view,setView:fe.setView,t:fe.t})),G=bt(),W=G.find((fe)=>fe.name===b),pe=W?A(W.label??W.name):"",se=W?.icon;return Kt(jr,{children:[We($r,{asChild:!0,className:c,children:Kt(o,{size:"default",variant:"outline",children:[se&&We(se,{className:"size-4"}),We("span",{children:pe}),We(ca,{className:"size-4 opacity-50"})]})}),We(Wr,{align:"end",className:"min-w-40",children:G.map((fe)=>{let ve=fe.icon;return Kt(Ur,{onSelect:()=>T(fe.name),children:[We(ve,{className:"size-4"}),We("span",{className:"flex-1",children:A(fe.label??fe.name)}),fe.name===b&&We(da,{className:"size-4"})]},fe.name)})})]})}import*as St from"@radix-ui/react-toggle-group";import{cva as ma}from"class-variance-authority";import{createContext as ua,useContext as pa}from"react";import{jsx as Zt}from"react/jsx-runtime";var fa=ma("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors outline-none hover:bg-muted hover:text-muted-foreground focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer select-none",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-2.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),Zr=ua({size:"default",variant:"default"});function qr({className:c,variant:b,size:T,children:A,...G}){return Zt(St.Root,{className:e("flex items-center justify-center gap-1",c),"data-slot":"toggle-group",...G,children:Zt(Zr.Provider,{value:{variant:b,size:T},children:A})})}function Xr({className:c,children:b,variant:T,size:A,...G}){let W=pa(Zr);return Zt(St.Item,{className:e(fa({variant:W.variant||T,size:W.size||A}),c),"data-slot":"toggle-group-item",...G,children:b})}import{jsx as Qr}from"react/jsx-runtime";function Jr({className:c}){let{view:b,setView:T,t:A}=r((W)=>({view:W.view,setView:W.setView,t:W.t})),G=bt();return Qr(qr,{className:e("bg-muted gap-0 rounded-lg p-0.75",c),onValueChange:(W)=>W&&T(W),size:"sm",type:"single",value:b,children:G.map((W)=>Qr(Xr,{className:"text-muted-foreground data-[state=on]:bg-background data-[state=on]:text-foreground rounded-md px-3 font-medium data-[state=on]:shadow-sm",value:W.name,children:A(W.label??W.name)},W.name))})}import{jsx as ke,jsxs as et}from"react/jsx-runtime";var eo=({className:c=""})=>{let{nextPeriod:b,prevPeriod:T,today:A,openEventForm:G,headerComponent:W,headerClassName:pe,t:se,hideExportButton:fe}=r((ge)=>({nextPeriod:ge.nextPeriod,prevPeriod:ge.prevPeriod,today:ge.today,openEventForm:ge.openEventForm,headerComponent:ge.headerComponent,headerClassName:ge.headerClassName,t:ge.t,hideExportButton:ge.hideExportButton})),ve=_r();if(W)return W;return ke("div",{className:e("@container/base-header w-full",pe),"data-testid":"calendar-header",children:et("div",{className:e("flex flex-col items-center gap-2 @lg/base-header:flex-row @lg/base-header:justify-between",c),children:[et("div",{className:"flex min-w-0 items-center gap-2",children:[et("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[ke(o,{"aria-label":se("previous"),className:"h-full",onClick:T,size:"icon",variant:"ghost",children:ke(ga,{className:"size-4"})}),ke(o,{"aria-label":se("next"),className:"h-full",onClick:b,size:"icon",variant:"ghost",children:ke(va,{className:"size-4"})})]}),ke(o,{onClick:A,size:"default",variant:"outline",children:se("today")}),ke(Br,{})]}),et("div",{className:"flex items-center gap-2",children:[ke(Jr,{className:"hidden @3xl/base-header:flex"}),ke(Kr,{className:"@3xl/base-header:hidden"}),!fe&&et(o,{"aria-label":se("export"),onClick:ve,size:"default",variant:"outline",children:[ke(ya,{className:"size-4"}),ke("span",{className:"hidden @2xl/base-header:inline",children:se("export")})]}),et(o,{"aria-label":se("new"),onClick:()=>G(),size:"default",children:[ke(Da,{className:"size-4"}),ke("span",{className:"hidden @2xl/base-header:inline",children:se("new")})]})]})]})})};import{useMemo as xo}from"react";import{useRef as ao}from"react";import{useEffect as Ca,useRef as ha}from"react";var Ea=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,ba="[data-hour]",Sa='[data-start]:not([data-all-day="true"])',xa=(c)=>{let T=Ea.exec(c)?.at(1);if(!T)return null;let A=Number.parseInt(T,10);return A>=0&&A<=23?A:null},qt=(c)=>Number.parseInt(c.getAttribute("data-hour")??"",10),wa=(c,b)=>{let T=c.at(0),A=c.at(-1);if(!T||!A)return null;if(b<=qt(T))return T;if(b>=qt(A))return A;return c.find((G)=>qt(G)===b)??null},Pa=(c)=>({start:t(c.dataset.start??""),end:t(c.dataset.end??"")}),Ta=(c)=>{let b=Array.from(c.querySelectorAll(Sa)),T=b.at(0),A=t(),G=b.find((W)=>d(Pa(W),A,A));if(!T||!G)return null;return{target:G,origin:T}},Ra=(c,b)=>{let T=b?xa(b):null;if(T===null)return null;let A=Array.from(c.querySelectorAll(ba)),G=A.at(0),W=wa(A,T);if(!G||!W)return null;return{target:W,origin:G}},Na=(c,b,T,A)=>{let G=b.getBoundingClientRect(),W=T.getBoundingClientRect(),pe=G.left-W.left,se=G.top-W.top;to(c,A,A==="horizontal"?pe:se)},to=(c,b,T)=>{let A=b==="horizontal"?"left":"top";c.scrollTo({[A]:T,behavior:"auto"})},ka=(c,{scrollTime:b,scrollToNow:T,axis:A})=>{let W=(T?Ta(c):null)??Ra(c,b);if(W)return Na(c,W.target,W.origin,A),!0;if(T)return to(c,A,0),!0;return!1},xt=({viewportRef:c,scrollTime:b,scrollToNow:T=!1,enabled:A,scrollKey:G,axis:W="vertical"})=>{let pe=ha(null);Ca(()=>{if(!A)return;let se=`${G}|${b}|${T}`;if(pe.current===se)return;let fe=c.current;if(!fe)return;if(ka(fe,{scrollTime:b,scrollToNow:T,axis:W}))pe.current=se},[A,b,T,G,c,W])};import{useLayoutEffect as Ma}from"react";var Xt="data-sticky-inset",wt=(c)=>c?"top":void 0,ro={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},oo=new Set(["hidden","scroll","auto","overlay","clip"]),Ha=(c)=>{let b=[];for(let T=c.parentElement;T;T=T.parentElement){let{overflowX:A,overflowY:G}=getComputedStyle(T);if(oo.has(A)||oo.has(G))b.push(T)}return b},Ia=(c,b,T)=>{let A=b.getBoundingClientRect(),G={left:-A.left,top:-A.top};for(let pe of T){let se=pe.getBoundingClientRect();G.left=Math.max(G.left,se.left-A.left),G.top=Math.max(G.top,se.top-A.top)}let W=c.querySelectorAll(`[${Xt}]`);for(let pe of W){let se=pe.getAttribute(Xt),fe=pe.getBoundingClientRect();if(se==="left")G.left=Math.max(G.left,fe.right-A.left);if(se==="top")G.top=Math.max(G.top,fe.bottom-A.top)}return{left:Math.max(0,G.left),top:Math.max(0,G.top)}},Pt=(c,b,T)=>{let{currentDate:A,view:G,stickyViewHeader:W}=r((se)=>({currentDate:se.currentDate,view:se.view,stickyViewHeader:se.stickyViewHeader})),pe=n.stickyInsets(G,A,W,T);Ma(()=>{let se=c.current,fe=b.current;if(!se||!fe)return;let ve=Ha(se),ge=()=>{let Ee=Ia(se,fe,ve);fe.style.setProperty(ro.left,`${Ee.left}px`),fe.style.setProperty(ro.top,`${Ee.top}px`)};ge();let ye,Ce=()=>{if(ye!==void 0)return;ye=requestAnimationFrame(()=>{ye=void 0,ge()})},Se=[...ve,window];for(let Ee of Se)Ee.addEventListener("scroll",Ce,{passive:!0});window.addEventListener("resize",Ce,{passive:!0});let he=typeof ResizeObserver>"u"?void 0:new ResizeObserver(ge);he?.observe(fe);for(let Ee of se.querySelectorAll(`[${Xt}]`))he?.observe(Ee);return()=>{for(let Ee of Se)Ee.removeEventListener("scroll",Ce);if(window.removeEventListener("resize",Ce),he?.disconnect(),ye!==void 0)cancelAnimationFrame(ye)}},[c,b,pe])};import{memo as Oa}from"react";import{jsx as Aa}from"react/jsx-runtime";var Va=({children:c,className:b})=>{let{stickyViewHeader:T,viewHeaderClassName:A}=r((G)=>({stickyViewHeader:G.stickyViewHeader,viewHeaderClassName:G.viewHeaderClassName}));return Aa("div",{className:e("flex h-12 w-fit",T&&"sticky top-0 z-21 bg-background",b,A),"data-sticky-inset":wt(T),"data-testid":"horizontal-grid-header",children:c})},no=Oa(Va);import{jsx as tt,jsxs as io}from"react/jsx-runtime";var so=({rows:c,children:b,classes:T,allDay:A,gridType:G,variant:W="resource",dayNumberHeight:pe})=>{let{currentDate:se,view:fe,scrollTime:ve,scrollToNow:ge}=r(),ye=ao(null),Ce=ao(null),Se=W==="resource",he=!Se;xt({viewportRef:Ce,scrollTime:ve,scrollToNow:ge,enabled:Se,scrollKey:`${fe}-${se.format("YYYY-MM-DD")}`,axis:"horizontal"}),Pt(ye,Ce,c.length);let Ee=b&&tt(no,{className:T?.header,children:b});return io("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:ye,children:[he&&Ee,io(u,{className:e("h-full",he&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:Ce},children:[Se&&Ee,tt("div",{className:e("flex flex-1 w-fit",T?.body),"data-testid":"horizontal-grid-body",children:tt("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:c.map((De)=>tt(re,{allDay:De.allDay??A,dayNumberHeight:pe,gridType:G,variant:W,...De},De.id))},se.format("YYYY-MM"))}),tt(y,{className:"z-30"}),tt(y,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as Eo}from"react";import{memo as Ua}from"react";import{memo as _a,useMemo as ja}from"react";import{useMemo as co}from"react";var La=(c)=>{let b=[],T=[],A=null;for(let G of c){if(A&&G.start.isSameOrAfter(A)){if(T.length>0)b.push(T);T=[]}T.push(G),A=A?t.max(A,G.end):G.end}if(T.length>0)b.push(T);return b},lo=(c,{gridStart:b,totalUnits:T,gridType:A,isDiscrete:G})=>{let W=c.start.diff(b,A,!0),pe=c.end.diff(b,A,!0);if(G){if(W=Math.floor(W),pe=Math.ceil(pe),pe<=W)pe=W+1}let se=W<0,fe=pe>T;if(se)W=0;if(fe)pe=T;let ve=Math.max(0,pe-W);if(ve===0)return null;return{top:W/T*100,height:ve/T*100,isTruncatedStart:se,isTruncatedEnd:fe}},Fa={2:25,3:50,4:60},Ga=70,Ba=(c)=>Fa[c]??Ga,za=(c,b)=>{let T=c.length===1?c.at(0):void 0;if(T){let se=lo(T,b);if(!se)return[];return[{kind:"vertical",event:T,left:0,width:100,...se}]}let A=[...c].sort((se,fe)=>{let ve=fe.end.diff(fe.start,"minute")-se.end.diff(se.start,"minute");return ve!==0?ve:se.start.diff(fe.start)}),G=A.length,W=G>1?Ba(G)/(G-1):0,pe=[];for(let se=0;se<G;se++){let fe=A.at(se);if(!fe)continue;let ve=lo(fe,b);if(!ve)continue;let ge=se===0?0:W*se;pe.push({kind:"vertical",event:fe,...ve,left:ge,width:100-ge,zIndex:se+1})}return pe},Tt=({days:c,gridType:b="hour",events:T})=>{let A=T.filter((W)=>!W.allDay).toSorted((W,pe)=>W.start.diff(pe.start));if(A.length===0)return[];let G={gridStart:c.at(0)||t(),totalUnits:c.length,gridType:b,isDiscrete:b==="day"};return La(A).flatMap((W)=>za(W,G))};var mo=({days:c,gridType:b,resourceId:T})=>{let{getEventsForDateRange:A}=r(),G=c.at(0),W=c.at(-1),pe=G?.startOf("day"),se=W?.endOf("day"),fe=co(()=>{if(!pe||!se)return[];let ge=A(pe,se);if(T)ge=x(ge,T);return ge.filter((ye)=>!ye.allDay)},[pe,se,A,T]);return co(()=>Tt({days:c,events:fe,gridType:b}),[c,b,fe])};import{jsx as Ya,jsxs as uo}from"react/jsx-runtime";function po({previewPositioned:c}){let b=r((pe)=>pe.timeFormat),{event:T,isTruncatedStart:A,isTruncatedEnd:G}=c,W=Y(b);return uo(ee,{contentClassName:"px-1.5 py-1 relative",event:T,isTruncatedEnd:G,isTruncatedStart:A,orientation:"vertical",style:te(c),children:[uo("p",{className:"text-[10px] font-semibold sm:text-xs",children:[T.start.format(W)," – ",T.end.format(W)]}),Ya("p",{className:e("text-[10px] font-bold sm:text-xs truncate",O.vertical),children:T.title})]})}import{jsx as fo}from"react/jsx-runtime";var go=(c,b,T,A)=>`event-${c}-${b}-${T.at(0)?.toISOString()}-${A??"no-resource"}`;function vo({positioned:c,elementId:b,range:T,resourceId:A,draggedEventId:G}){let{event:W}=c,pe=W.end.diff(W.start,"minute")<=15;return fo("div",{className:"absolute","data-testid":n.container.verticalEvent(W.id),style:te(c),children:fo(H,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":pe}),dragSegment:U(W,T,"vertical"),elementId:b,event:W,isBeingDragged:G===W.id,isTruncatedEnd:c.isTruncatedEnd,isTruncatedStart:c.isTruncatedStart,sourceResourceId:A})})}import{jsx as Rt,jsxs as Wa}from"react/jsx-runtime";var $a=({days:c,gridType:b="hour",resourceId:T,resource:A,"data-testid":G})=>{let W=r((he)=>he.resources),pe=p(),se=mo({days:c,gridType:b,resourceId:T}),fe=c.at(0),ve=c.at(-1)?.add(1,b),ge=!T||W?.at(0)?.id===T,ye=b==="hour"&&Boolean(fe&&ve),Ce=J({days:c,gridType:b,resourceId:T}),Se=ja(()=>{if(!Ce)return null;return Tt({days:c,gridType:b,events:[Ce]}).at(0)??null},[Ce,c,b]);return Rt(L.Provider,{value:"vertical",children:Wa("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":G,children:[ye&&fe&&ve&&Rt(Q,{rangeEnd:ve,rangeStart:fe,resource:A,withDot:ge}),se.map((he,Ee)=>{let De=go(he.event.id,Ee,c,T);return Rt(vo,{draggedEventId:pe?.event.id,elementId:De,positioned:he,range:{start:fe,end:ve},resourceId:T},n.listKey(De,"wrapper"))}),Se&&Rt(po,{previewPositioned:Se})]})})},yo=_a($a);import{jsx as rt,jsxs as Za}from"react/jsx-runtime";var Ka=({id:c,days:b,resource:T,"data-testid":A,"data-sticky-inset":G,gridType:W,className:pe,renderCell:se,noEvents:fe,slotDurationMinutes:ve=60})=>{let ge=T?.id,ye=Math.floor(60/ve),Ce=Array.from({length:ye},(he,Ee)=>Ee*ve),Se=Ce.length>1;return rt("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",pe),"data-sticky-inset":G,"data-testid":A||n.container.vertical.col(c),children:Za("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${b.length}, minmax(0, 1fr))`},children:[b.map((he,Ee)=>{let De=he.format("HH");if(se){let we=c===n.col.time,xe=we?n.cell.verticalTime(De):n.cell.vertical(he,De,"00",ge);return rt("div",{className:"min-h-[60px] bg-background","data-hour":we?De:void 0,"data-testid":xe,children:se(he)},n.listKey(c,Ee,De))}return rt("div",{className:"flex flex-col min-h-[60px]",children:Ce.map((we,xe)=>{let Re=String(we).padStart(2,"0"),Pe=n.cell.vertical(he,De,Re,ge),Ge=Se&&xe<Ce.length-1;return rt(z,{className:e("hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",Ge&&"border-b border-dashed"),"data-testid":Pe,day:Se?he.minute(we):he,gridType:W,hour:W==="hour"?he.hour():void 0,isSubDivider:Ge,minute:Se?we:void 0,resourceId:ge,shouldRenderEvents:!1,slotDurationMinutes:ve},n.listKey(c,Ee,Re))})},n.listKey(c,Ee,De))}),!fe&&rt("div",{className:"absolute inset-0 z-10 pointer-events-none",children:rt(yo,{"data-testid":n.container.eventsLayer("vertical",c),days:b,gridType:W,resource:T,resourceId:ge})})]})})},Do=Ua(Ka);import{memo as qa}from"react";import{jsx as Co,jsxs as Qa}from"react/jsx-runtime";var Xa=({children:c,classes:b,allDayRow:T,expandAllDayRow:A=!1})=>{let{stickyViewHeader:G,viewHeaderClassName:W}=r((se)=>({stickyViewHeader:se.stickyViewHeader,viewHeaderClassName:se.viewHeaderClassName})),pe="min-w-full w-fit";return Qa("div",{className:e(A&&"flex h-full flex-col",G&&"sticky top-0 z-21 bg-background",W),"data-sticky-inset":wt(G),children:[Co("div",{className:e("min-h-12 border-b","min-w-full w-fit",b?.header),"data-testid":"vertical-grid-header",children:c}),T&&Co("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",A&&"flex-1 overflow-hidden",b?.allDay),"data-testid":"vertical-grid-all-day",children:T})]})},ho=qa(Xa);import{jsx as ot,jsxs as bo}from"react/jsx-runtime";var So=({columns:c,children:b,gridType:T="day",variant:A="resource",classes:G,allDayRow:W,slotDurationMinutes:pe,style:se})=>{let fe=A==="resource",ve=!fe,ge=c.every((Re)=>!Re.days?.length),{currentDate:ye,view:Ce,scrollTime:Se,scrollToNow:he}=r(),Ee=Eo(null),De=Eo(null);xt({viewportRef:De,scrollTime:Se,scrollToNow:he,enabled:!ge,scrollKey:`${Ce}-${ye.format("YYYY-MM-DD")}`}),Pt(Ee,De,c.length);let xe=b&&ot(ho,{allDayRow:W,classes:{header:G?.header,allDay:G?.allDay},expandAllDayRow:ge,children:b});if(ge&&xe)return ot("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:se,children:xe});return bo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:Ee,style:se,children:[ve&&xe,bo(u,{className:e("h-full",ve&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:De},children:[fe&&xe,ot("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",G?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:c.map((Re,Pe)=>ot(Do,{...Re,gridType:T,slotDurationMinutes:pe},n.listKey(Re.id,Pe)))}),ot(y,{className:"z-30"})," ",ot(y,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as qe}from"react/jsx-runtime";var Ja=(c,b)=>b==="vertical",ei=({specs:c,header:b,composesResourceAxis:T,variant:A})=>{let{slotDuration:G}=r((Ce)=>({slotDuration:Ce.slotDuration})),W=c.some((Ce)=>Ce.gridType==="hour")?"hour":"day",pe=c.filter((Ce)=>!Ce.noEvents).map((Ce)=>Ce.day).filter((Ce)=>Boolean(Ce)),se=c.find((Ce)=>Ce.noEvents),ve=Boolean(se?.className?.includes(M))?{cell:"flex-1 min-w-0",spacer:M}:void 0,ge;if(W==="hour")ge=T?qe(ce,{columns:c}):qe(ne,{classes:ve,days:pe});return qe(So,{allDayRow:ge,classes:T?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:c,gridType:W,slotDurationMinutes:G,variant:A,children:b})},ti=({specs:c,header:b,composesResourceAxis:T,variant:A})=>{let G=c.some((se)=>se.columns?.some((fe)=>fe.gridType==="hour"))?"hour":"day",W=c.some((se)=>se.columns?.some((fe)=>fe.days)),pe=T?{header:e(W&&de,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return qe(so,{classes:pe,dayNumberHeight:T?0:void 0,gridType:G,rows:c,variant:A,children:b})},wo=({view:c})=>{let{currentDate:b,firstDayOfWeek:T,hiddenDays:A,businessHours:G,hideNonBusinessHours:W,resources:pe,orientation:se,weekViewGranularity:fe}=r((De)=>({currentDate:De.currentDate,firstDayOfWeek:De.firstDayOfWeek,hiddenDays:De.hiddenDays,businessHours:De.businessHours,hideNonBusinessHours:De.hideNonBusinessHours,resources:De.resources,orientation:De.orientation,weekViewGranularity:De.weekViewGranularity})),ve=xo(()=>({firstDayOfWeek:T,hiddenDays:A,businessHours:G,hideNonBusinessHours:W,resources:pe,orientation:se,weekViewGranularity:fe}),[T,A,G,W,pe,se,fe]),ge=xo(()=>c.columns?.(b,ve),[c,b,ve]);if(!ge||!c.layout){let De=c.component;if(De)return qe(De,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${c.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let Ce=Boolean(pe?.length)&&Boolean(c.supportsResources),Se=Ce?se??"horizontal":c.layout,he=Ce?"resource":"regular",Ee=c.renderHeader?.({date:b,config:ve});if(Ja(ge,Se))return qe(ei,{composesResourceAxis:Ce,header:Ee,specs:ge,variant:he});return qe(ti,{composesResourceAxis:Ce,header:Ee,specs:ge,variant:he})};var Po=(c)=>{if(!c||c.length===0)return;return new Set(c.map((b)=>I[b]))};function To(c){if(!c?.length)return[];return c.map((b)=>({...b,start:t(b.start),end:t(b.end)}))}import{jsx as Ue,jsxs as ai}from"react/jsx-runtime";var ni=()=>{let{view:c,getViews:b}=r((G)=>({view:G.view,getViews:G.getViews})),T=b().find((G)=>G.name===c);return ai("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[Ue(eo,{className:"p-1 shrink-0 mb-1"}),Ue(Cr,{children:Ue(l,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:c,children:Ue("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:T?Ue(wo,{view:T},c):null})})}),Ue(Vr,{})]})},Qt=({events:c,firstDayOfWeek:b="sunday",initialView:T="month",initialDate:A,eventSpacing:G=q,eventHeight:W=X,stickyViewHeader:pe=!0,viewHeaderClassName:se="",timeFormat:fe="12-hour",hideNonBusinessHours:ve=!1,hiddenDays:ge,resources:ye,orientation:Ce,...Se})=>{let he=Boolean(ye?.length),Ee=oi(()=>To(c),[c]);return ri(()=>{if(typeof process<"u"&&!1)console.warn("[@ilamy/calendar] `orientation` was provided without `resources` — it only applies when the calendar has resources, so it is ignored.")},[Ce,he]),Ue(B,{eventHeight:W,eventSpacing:G,events:Ee,firstDayOfWeek:I[b],hiddenDays:Po(ge),hideNonBusinessHours:ve,initialDate:A,initialView:T,orientation:Ce,resources:ye,stickyViewHeader:pe,timeFormat:fe,viewHeaderClassName:se,...Se,children:Ue(ni,{})})};import{jsx as si}from"react/jsx-runtime";var ii=(c)=>si(Qt,{...c});export{Qt as IlamyCalendar,ii as IlamyResourceCalendar,lr as SLOT_EVENT_FORM,dr as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,ae as defaultTranslations,me as useIlamyCalendarContext};
1
+ import{t}from"./shared/chunk-nvtnncwx.js";import{R,w,S,G,P,W}from"./shared/chunk-pg39xa62.js";import{se,r,fe,l,g,K,de,ce,ie,p,O,I,M,a,i,L,q,n,X,Z,Q,H,ue,B,J,x,F,A,z,ee,te,re,ne,oe,j,ae,me,_}from"./shared/chunk-j4pfc0hb.js";import{e,d,N,pe}from"./shared/chunk-89xfgjfh.js";import{o,v,m,s,C,D,E,h,f}from"./shared/chunk-j4ngnkkv.js";import{u,y}from"./shared/chunk-bgegqhb4.js";var mr="event-form",ur="event-mutation-scope",pr=({event:c,onChange:b})=>r((k)=>k.renderSlot)(mr,{event:c,onChange:b}),gt=({dialog:c,onResolve:b,onCancel:T})=>{let k=r((le)=>le.getEventManager);if(!(c.isOpen&&c.event))return null;let V=k(c.event),Y={event:c.event,operation:c.operation,resolve:b,cancel:T};return V?.renderSlot?.(ur,Y)};import{useEffect as li,useMemo as di}from"react";import{DndContext as Pn}from"@dnd-kit/core";import{useId as Tn}from"react";import{MouseSensor as an,TouchSensor as sn,useSensor as gr,useSensors as ln}from"@dnd-kit/core";import{useEffect as dn,useRef as vt,useState as cn}from"react";var on=(c)=>c.hour!==void 0,Gt=(c,b,T=g)=>{let{date:k,hour:V=0,minute:Y=0,allDay:le}=b,U=c.end.diff(c.start,"second"),ge=(Ce)=>({start:Ce,end:Ce.add(U,"second")});if(on(b)){let we=t(k).hour(V).minute(Y).subtract(T.minutes,"minute");return{...ge(we),allDay:!1}}let ye=t(k).subtract(T.days,"day"),ve=le===!0,De=Boolean(c.allDay);if(ve||De)return{...ge(ye.startOf("day")),allDay:!0};let xe=ye.format("YYYY-MM-DD"),be=c.start.format("HH:mm:ss.SSS"),Ee=t(`${xe}T${be}`);return{...ge(Ee),allDay:!1}},nn=(c,b,T)=>{if(T===void 0||b===T)return{};if(!c.resourceIds)return{resourceId:T};let V=c.resourceIds.indexOf(b);if(V===-1)return{};let Y=c.resourceIds.slice();if(Y.splice(V,1),!Y.includes(T))Y.push(T);return{resourceIds:Y}},fr=(c,b,T=g)=>{let{active:k,over:V}=c;if(!k||!V||!b)return null;let Y=V.data.current||{};if(Y.disabled)return null;let{resourceId:le}=Y,{start:U,end:ge,allDay:ye}=Gt(b,Y,T),ve=k.data.current?.sourceResourceId,De={start:U,end:ge,...nn(b,ve,le),allDay:ye};return{activeEvent:b,updates:De}};var mn=(c,b)=>{if(!c)return!1;let T=c.start.isSame(b.start)&&c.end.isSame(b.end),k=c.resourceId===b.resourceId&&c.allDay===b.allDay,V=c.isDropAllowed===b.isDropAllowed;return T&&k&&V},un=({active:c,activatorEvent:b})=>{if(c.data.current?.type!=="calendar-event")return null;let T=c.data.current.event,k=c.data.current.dragSegment;if(!k)return{calendarEvent:T,pending:null};let V=c.data.current.getBarRect;return{calendarEvent:T,pending:{calendarEvent:T,segment:k,activatorEvent:b,barRect:V?.()}}},pn=(c,b,T)=>{let k=b??{},{start:V,end:Y,allDay:le}=Gt(c,k,T);return{event:c,start:V,end:Y,resourceId:k.resourceId??c.resourceId,allDay:le,isDropAllowed:!k.disabled}},fn=(c)=>{let b=ce(c);dn(()=>{if(!b)return;let T=document.body.style.cursor;return document.body.style.cursor=b,()=>{document.body.style.cursor=T}},[b])},gn={activationConstraint:{distance:2}},vn={activationConstraint:{delay:100,tolerance:5}},yn=()=>{let c=gr(an,gn),b=gr(sn,vn);return ln(c,b)},vr=(c)=>{let b=r((be)=>be.slotDuration),T=yn(),k=vt(null),V=vt(g),Y=vt(null),le=vt(null),[U,ge]=cn(null);fn(U);let ye=()=>{k.current=null,V.current=g,Y.current=null,ge(null),le.current?.setActiveEvent(null)},ve=(be)=>{let Ee=un(be);if(!Ee)return;le.current?.setActiveEvent(Ee.calendarEvent),k.current=Ee.calendarEvent,V.current=g,Y.current=Ee.pending},De=(be)=>{let Ee=Y.current;if(!Ee)return;let Ce=Ee.barRect??be.active.rect.current.initial;if(!Ce)return;V.current=de({activeEvent:Ee.calendarEvent,initialRect:Ce,activatorEvent:Ee.activatorEvent,segment:Ee.segment,slotDurationMinutes:b}),Y.current=null};return{sensors:T,dragPreview:U,overlayRef:le,handlers:{onDragStart:ve,onDragOver:(be)=>{De(be);let Ee=k.current;if(!Ee||!be.over){ge(null);return}let Ce=pn(Ee,be.over.data.current,V.current);ge((we)=>{if(mn(we,Ce))return we;return Ce})},onDragEnd:(be)=>{let Ee=fr(be,k.current,V.current);if(Ee)c(Ee.activeEvent,Ee.updates);ye()},onDragCancel:ye}}};import{useCallback as yt,useEffect as Dn,useRef as Cn,useState as hn}from"react";var Bt={isOpen:!1,operation:"edit",event:null};function Dt(c){let{applyScopedEdit:b,applyScopedDelete:T}=r((ve)=>({applyScopedEdit:ve.applyScopedEdit,applyScopedDelete:ve.applyScopedDelete})),[k,V]=hn(Bt),Y=Cn(k);Dn(()=>{Y.current=k},[k]);let le=yt((ve,De)=>{V({isOpen:!0,operation:"edit",event:ve,updates:De})},[]),U=yt((ve)=>{V({isOpen:!0,operation:"delete",event:ve})},[]),ge=yt(()=>V(Bt),[]),ye=yt((ve)=>{let De=Y.current;if(!De.event)return;if(De.operation==="edit")b(De.event,De.updates??{},ve);else T(De.event,ve);V(Bt),c?.()},[b,T,c]);return{dialogState:k,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}}var yr=()=>{let{updateEvent:c,getEventManager:b}=r((U)=>({updateEvent:U.updateEvent,getEventManager:U.getEventManager})),{dialogState:T,openEditDialog:k,closeDialog:V,handleConfirm:Y}=Dt();return{commitDrop:(U,ge)=>{let ye=Object.keys(ge).length===0;if(!U.id||ye)return;if(b(U)?.applyEdit){k(U,ge);return}c(U.id,ge)},scopeDialog:{dialog:T,onCancel:V,onResolve:Y}}};import{pointerWithin as En}from"@dnd-kit/core";var Dr=(c)=>{let{droppableContainers:b,droppableRects:T,pointerCoordinates:k}=c;if(!k)return[];let{x:V,y:Y}=k,le=(ge)=>{if(!(ge.top<=Y))return!1;if(!(Y<=ge.bottom))return!1;if(!(ge.left<=V))return!1;return V<=ge.right},U=b.filter((ge)=>{let ye=T.get(ge.id);return ye!==void 0&&le(ye)});return En({...c,droppableContainers:U})};import{DragOverlay as bn}from"@dnd-kit/core";import{snapCenterToCursor as Sn}from"@dnd-kit/modifiers";import{useImperativeHandle as xn,useState as wn}from"react";import{jsx as Cr}from"react/jsx-runtime";var hr=({ref:c})=>{let[b,T]=wn(null),k=p();if(xn(c,()=>({setActiveEvent:T})),k)return null;return Cr(bn,{modifiers:[Sn],children:b&&Cr("div",{className:e("cursor-grabbing truncate rounded-md px-3 py-1.5 text-xs font-medium shadow-xl opacity-80",O(b)),style:I(b),children:b.title})})};import{jsx as zt,jsxs as Er}from"react/jsx-runtime";function br({children:c}){let b=Tn(),T=r((ve)=>ve.disableDragAndDrop),{commitDrop:k,scopeDialog:V}=yr(),{sensors:Y,dragPreview:le,overlayRef:U,handlers:ge}=vr(k),ye=le!==null;if(T)return c;return Er(ie.Provider,{value:le,children:[Er(Pn,{collisionDetection:Dr,id:b,sensors:Y,...ge,children:[zt("div",{className:"contents","data-dragging":ye?"true":void 0,children:c}),zt(hr,{ref:U})]}),zt(gt,{...V})]})}import{ChevronDownIcon as Rn}from"lucide-react";import{useEffect as Nn,useState as kn}from"react";import*as Ge from"@radix-ui/react-popover";import{jsx as Ct}from"react/jsx-runtime";function je({...c}){return Ct(Ge.Root,{"data-slot":"popover",...c})}function _e({...c}){return Ct(Ge.Trigger,{"data-slot":"popover-trigger",...c})}function Ye({className:c,align:b="center",sideOffset:T=4,...k}){return Ct(Ge.Portal,{children:Ct(Ge.Content,{align:b,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",c),"data-slot":"popover-content",sideOffset:T,...k})})}import{jsx as $e,jsxs as st}from"react/jsx-runtime";var Sr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,jt=(c)=>Boolean(c&&Sr.test(c)),Mn=(c)=>{let b=c.match(/bg-([a-z]+)-\d+/)?.at(1);if(!b)return"Custom";return b.charAt(0).toUpperCase()+b.slice(1)};function xr({value:c,onChange:b,swatches:T=[],className:k,"aria-label":V="Select color"}){let[Y,le]=kn(jt(c)?c:"");Nn(()=>{le(jt(c)?c:"")},[c]);let U=(De)=>{let he=De.target.value;if(le(he),Sr.test(he))b(he)},ge=jt(c),ye=T.find((De)=>De.value===c),ve;if(ye)ve=ye.label;else if(ge)ve=c;else if(c)ve=Mn(c);else ve="Pick a color";return st(je,{children:[st(_e,{"aria-label":V,className:e("border-input focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 text-sm shadow-xs outline-none focus-visible:ring-[3px]",k),"data-slot":"color-picker-trigger",type:"button",children:[st("span",{className:"flex items-center gap-2",children:[$e("span",{className:e("size-5 shrink-0 rounded-full border",!ge&&c),style:ge?{backgroundColor:c}:void 0}),$e("span",{className:e(ge&&"font-mono text-xs"),children:ve})]}),$e(Rn,{className:"size-4 shrink-0 opacity-50"})]}),st(Ye,{className:"w-56","data-slot":"color-picker-content",children:[T.length>0&&$e("div",{className:"grid grid-cols-7 gap-1.5",children:T.map((De)=>{let he=c===De.value;return $e("button",{"aria-label":De.label,"aria-pressed":he,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",De.value,he&&"ring-ring ring-2 ring-offset-1"),onClick:()=>b(De.value),type:"button"},De.value)})}),$e("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),st("div",{className:"flex items-center gap-2",children:[$e("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(De)=>b(De.target.value),type:"color",value:ge?c:"#000000"}),$e(m,{"aria-label":"Hex color",className:"font-mono",onChange:U,placeholder:"#000000",value:Y})]})]})]})}import{jsx as Hn}from"react/jsx-runtime";function wr({className:c,...b}){return Hn("textarea",{className:e("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",c),"data-slot":"textarea",...b})}import{useEffect as Zn,useState as Ae}from"react";import{PopoverClose as Bn}from"@radix-ui/react-popover";import{Calendar as zn}from"lucide-react";import{useEffect as jn,useRef as _n,useState as Yn}from"react";import{useState as An}from"react";import{ChevronLeftIcon as On,ChevronRightIcon as In}from"lucide-react";import{jsx as lt,jsxs as Vn}from"react/jsx-runtime";function Je({label:c,onPrev:b,onNext:T,prevLabel:k,nextLabel:V}){return Vn("div",{className:"mb-2 flex items-center justify-between",children:[lt(o,{"aria-label":k,onClick:b,size:"icon",variant:"ghost",children:lt(On,{className:"size-4"})}),lt("div",{className:"text-sm font-medium select-none",children:c}),lt(o,{"aria-label":V,onClick:T,size:"icon",variant:"ghost",children:lt(In,{className:"size-4"})})]})}import{jsx as Be,jsxs as Pr}from"react/jsx-runtime";function Ln(c){let b=c.weekHover&&!c.isCurrentWeek;return e("p-0 text-center",c.weekHover&&"first:rounded-l-md last:rounded-r-md",b&&"group-hover/week:bg-accent",c.isCurrentWeek&&"bg-primary")}function Fn(c){return e("w-full aspect-square text-sm select-none",!c.isDisabled&&"cursor-pointer",!(c.weekHover||c.isDisabled)&&"hover:bg-accent rounded-md",c.isOutside&&"text-muted-foreground/50",c.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",c.isCurrentWeek&&"text-primary-foreground font-medium",c.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",c.isDisabled&&"opacity-50 cursor-not-allowed")}function Gn({day:c,state:b,onSelect:T}){return Be("td",{className:Ln(b),"data-disabled":b.isDisabled,"data-outside":b.isOutside,"data-selected":b.isSelected,role:"gridcell",tabIndex:-1,children:Be("button",{"aria-disabled":b.isDisabled,"aria-hidden":b.isOutside,className:Fn(b),"data-disabled":b.isDisabled,"data-selected":b.isSelected,disabled:b.isDisabled||b.isOutside,onClick:()=>T?.(c.toDate()),tabIndex:b.isOutside?-1:0,type:"button",children:c.format("D")})})}function dt({selected:c,defaultMonth:b,onSelect:T,disabled:k,firstDayOfWeek:V=0,className:Y,weekHover:le=!1,highlightedWeekOf:U}){let[ge,ye]=An(()=>t(b??c??new Date).startOf("month")),ve=L(ge,V),De=c?t(c).format("YYYY-MM-DD"):void 0,he=i(t(),V).map((Ce)=>Ce.format("dd")),xe,be;if(U){let Ce=i(U,V);xe=Ce.at(0),be=Ce.at(-1)}let Ee=(Ce)=>{let we=Ce.format("YYYY-MM-DD")===De,Te=!1;if(xe&&be){let Ne=!Ce.isBefore(xe,"day"),Pe=!Ce.isAfter(be,"day");Te=Ne&&Pe}return{isOutside:!Ce.isSame(ge,"month"),isSelected:we,isDisabled:k?.(Ce.toDate())??!1,isCurrent:a(Ce)&&!we,isCurrentWeek:Te,weekHover:le}};return Pr("div",{className:e("bg-background p-3 w-72",Y),"data-slot":"calendar",children:[Be(Je,{label:ge.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>ye((Ce)=>Ce.add(1,"month")),onPrev:()=>ye((Ce)=>Ce.subtract(1,"month")),prevLabel:"Previous month"}),Pr("table",{className:"w-full border-collapse",role:"grid",children:[Be("thead",{children:Be("tr",{children:he.map((Ce,we)=>Be("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:Ce},we))})}),Be("tbody",{children:ve.map((Ce,we)=>Be("tr",{className:e(le&&"group/week"),children:Ce.map((Te)=>Be(Gn,{day:Te,onSelect:T,state:Ee(Te)},Te.toISOString()))},we))})]})]})}import{jsx as et,jsxs as _t}from"react/jsx-runtime";function Tr({date:c,closeOnSelect:b,onChange:T,label:k="Pick a date",className:V,disabled:Y}){let le=r((De)=>De.firstDayOfWeek),U=_n(null),[ge,ye]=Yn(c);jn(()=>{ye(c)},[c]);let ve=(De)=>{if(ye(De),b)U.current?.click();T?.(De)};return et("div",{className:V,children:_t(je,{children:[et(_e,{asChild:!0,children:_t(o,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!c,variant:"outline",children:[et(zn,{}),ge?t(ge).format("ll"):et("span",{children:k})]})}),_t(Ye,{align:"start",className:"w-auto p-0",children:[et(Bn,{ref:U,style:{display:"none"}}),et(dt,{defaultMonth:ge,disabled:Y,firstDayOfWeek:le,onSelect:ve,selected:ge})]})]})})}import{Clock as Wn}from"lucide-react";import{useEffect as Un,useRef as Nr,useState as Yt}from"react";import{useMemo as $n}from"react";function Rr({timeFormat:c="12-hour",minTime:b="00:00",maxTime:T="23:45"}){return{timeOptions:$n(()=>{let Y=[],[le,U]=b.split(":").map(Number),[ge,ye]=T.split(":").map(Number),ve=le*60+U,De=ge*60+ye;for(let he=ve;he<=De;he+=15){let xe=Math.floor(he/60),be=he%60,Ee=`${xe.toString().padStart(2,"0")}:${be.toString().padStart(2,"0")}`;Y.push(Ee)}return Y},[b,T]),formatTime:(Y)=>{let[le,U]=Y.split(":").map(Number);if(c==="24-hour")return`${le.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`;let ge=le>=12?"PM":"AM",ye=le;if(le===0)ye=12;else if(le>12)ye=le-12;return`${ye}:${U.toString().padStart(2,"0")} ${ge}`}}}import{jsx as We,jsxs as $t}from"react/jsx-runtime";var Kn=(c)=>{c.stopPropagation()};function kr({value:c,onChange:b,minTime:T="00:00",maxTime:k="23:45",timeFormat:V="12-hour",placeholder:Y="Select time...",className:le,disabled:U=!1,name:ge}){let[ye,ve]=Yt(!1),[De,he]=Yt(""),xe=Nr(null),be=Nr(null),[Ee,Ce]=Yt(0),{timeOptions:we,formatTime:Te}=Rr({timeFormat:V,minTime:T,maxTime:k}),Ne=we.filter((He)=>Te(He).toLowerCase().includes(De.toLowerCase())),Pe=(He)=>{b(He),ve(!1),he("")};Un(()=>{if(ye){if(be.current)Ce(be.current.offsetWidth);setTimeout(()=>{xe.current?.focus()},0)}},[ye]);let Ve=c?Te(c):Y;return $t(je,{onOpenChange:ve,open:ye,children:[We(_e,{asChild:!0,children:$t(o,{"aria-controls":"time-picker-listbox","aria-expanded":ye,className:e("w-full justify-start",le),"data-testid":n.timePicker(ge),disabled:U,ref:be,role:"combobox",variant:"outline",children:[We(Wn,{className:"mr-2 h-4 w-4"}),Ve]})}),$t(Ye,{align:"start",className:"p-0",style:{width:Ee},children:[We("div",{className:"p-2 border-b",children:We(m,{className:"h-8",onChange:(He)=>he(He.target.value),placeholder:"Search time...",ref:xe,value:De})}),We(u,{className:"h-[200px]",onWheel:Kn,children:We("div",{className:"p-1",children:Ne.length===0?We("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):Ne.map((He)=>{let ut=Te(He);return We("button",{className:e("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",He===c&&"bg-accent text-accent-foreground"),onClick:()=>Pe(He),type:"button",children:ut},He)})})})]})]})}var Mr=(c,b)=>{let[T,k]=b.split(":").map(Number);return t(c).hour(T).minute(k).second(0).millisecond(0)},Hr=(c,b,T)=>{let k=Mr(c,b);return T?k.hour(0).minute(0):k},Or=(c,b,T)=>{let k=Mr(c,b);return T?k.add(1,"day").startOf("day"):k},Wt=(c,b)=>{if(!b)return{min:"00:00",max:"23:59"};let T=t(c),{minStart:k,maxEnd:V,hasBusinessHours:Y}=J({allDates:[T],businessHours:b,hideNonBusinessHours:!1});if(!Y)return{min:"00:00",max:"23:59"};return{min:`${k.toString().padStart(2,"0")}:00`,max:`${(V-1).toString().padStart(2,"0")}:45`}};import{jsx as Re,jsxs as Oe,Fragment as ea}from"react/jsx-runtime";var Ir="bg-blue-100 text-blue-800",qn=[{value:Ir,label:"Blue"},{value:"bg-green-100 text-green-800",label:"Green"},{value:"bg-purple-100 text-purple-800",label:"Purple"},{value:"bg-red-100 text-red-800",label:"Red"},{value:"bg-yellow-100 text-yellow-800",label:"Yellow"},{value:"bg-pink-100 text-pink-800",label:"Pink"},{value:"bg-indigo-100 text-indigo-800",label:"Indigo"},{value:"bg-amber-100 text-amber-800",label:"Amber"},{value:"bg-emerald-100 text-emerald-800",label:"Emerald"},{value:"bg-sky-100 text-sky-800",label:"Sky"},{value:"bg-violet-100 text-violet-800",label:"Violet"},{value:"bg-rose-100 text-rose-800",label:"Rose"},{value:"bg-teal-100 text-teal-800",label:"Teal"},{value:"bg-orange-100 text-orange-800",label:"Orange"}],Vr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Xn=(c,b)=>{if(c&&Vr.test(c))return c;return b??Ir},Qn=(c)=>{if(Vr.test(c))return{backgroundColor:c,color:pe(c)};return{backgroundColor:void 0,color:c}},Jn=({colorChanged:c,hadInitialColor:b,selectedColor:T,initialBackgroundColor:k,initialColor:V})=>{if(c||!b)return Qn(T);return{backgroundColor:k,color:V}},Ut=({name:c,label:b,placeholder:T,value:k,required:V=!1,multiline:Y=!1,onChange:le})=>Oe("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:c,children:b}),Y?Re(wr,{className:"min-h-16 text-sm",id:c,name:c,onChange:le,placeholder:T,required:V,value:k}):Re(m,{className:"h-8 text-sm sm:h-9",id:c,name:c,onChange:le,placeholder:T,required:V,value:k})]}),Ar=({selectedEvent:c,onClose:b,onUpdate:T,onDelete:k,onAdd:V})=>{let{dialogState:Y,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}=Dt(b),{t:ve,timeFormat:De,getEventManager:he,resources:xe}=r((Se)=>({t:Se.t,timeFormat:Se.timeFormat,getEventManager:Se.getEventManager,resources:Se.resources??[]})),{id:be,resourceId:Ee,resourceIds:Ce,start:we=t(),end:Te=t().add(1,"hour"),allDay:Ne=!1,color:Pe,backgroundColor:Ve,title:He="",description:ut="",location:rr=""}=c??{},or=xe.length>0,nr=Ee??Ce?.at(0),ar=or&&nr===void 0,[Mt,Mo]=Ae(nr),Ht=or?Mt:Ee,pt=X(Ht),ir=Boolean(c&&he(c)),Ho=Te.isSame(Te.startOf("day")),Oo=Ne&&Ho?Te.subtract(1,"day"):Te,[Ze,sr]=Ae(we.toDate()),[Qe,Ot]=Ae(Oo.toDate()),[ze,Io]=Ae(Ne),[It,Vo]=Ae(Xn(Ve,Pe)),[Ao,Lo]=Ae(!1),Fo=Boolean(Pe||Ve),Go=(Se)=>{Vo(Se),Lo(!0)},[Vt,lr]=Ae(we.format("HH:mm")),[ft,At]=Ae(Te.format("HH:mm")),[Fe,Bo]=Ae({title:He,description:ut,location:rr}),[Lt,zo]=Ae({}),jo={...c,...Lt},_o=(Se)=>zo((ke)=>({...ke,...Se})),Yo=(Se)=>{if(!Se)return;if(sr(Se),t(Se).isAfter(t(Qe)))Ot(Se)},$o=(Se)=>{if(!Se)return;if(Ot(Se),Se&&t(Se).isBefore(t(Ze)))sr(Se)},Wo=(Se)=>{if(Io(Se),!(Se&&ft==="00:00"))return;Ot((ke)=>t(ke).isAfter(t(Ze),"day")?t(ke).subtract(1,"day").toDate():ke)},Uo=(Se)=>{if(lr(Se),t(Ze).isSame(t(Qe),"day")&&Se>ft)At(Se)},Ko=(Se)=>{if(At(Se),t(Ze).isSame(t(Qe),"day")&&Se<Vt)lr(Se)},Ft=(Se)=>{let{name:ke,value:Ie}=Se.target;Bo((at)=>({...at,[ke]:Ie}))};Zn(()=>{if(ze)At("23:59")},[ze]);let Zo=(Se)=>xe.find((Ie)=>String(Ie.id)===Se)?.id??Se,dr=ar&&Mt===void 0,qo=(Se)=>{if(Se.preventDefault(),dr)return;let ke=Hr(Ze,Vt,ze),Ie=Or(Qe,ft,ze),at=Jn({colorChanged:Ao,hadInitialColor:Fo,selectedColor:It,initialBackgroundColor:Ve,initialColor:Pe}),it={id:be||t().format("YYYYMMDDHHmmss"),title:Fe.title,start:ke,end:Ie,resourceId:Ht,description:Fe.description,location:Fe.location,allDay:ze,...at,...Lt};if(c?.id&&ir){le(c,{title:Fe.title,start:ke,end:Ie,resourceId:Ht,description:Fe.description,location:Fe.location,allDay:ze,color:It,...Lt});return}if(be)T?.(it);else V?.(it);b()},Xo=()=>{if(!c?.id)return;if(ir){U(c);return}k?.(c),b()},cr;if(pt)cr=(Se)=>!B(t(Se),pt);let Qo=Wt(Ze,pt),Jo=Wt(Qe,pt),en=[["startDate",Ze,Yo],["endDate",Qe,$o]],tn=[["startTime","start-time",Vt,Uo,Qo],["endTime","end-time",ft,Ko,Jo]],rn=Mt?.toString();return Oe(ea,{children:[Oe("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:qo,children:[Re(u,{className:"flex-1 min-h-0",children:Oe("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Re(Ut,{label:ve("title"),name:"title",onChange:Ft,placeholder:ve("eventTitlePlaceholder"),required:!0,value:Fe.title}),Re(Ut,{label:ve("description"),multiline:!0,name:"description",onChange:Ft,placeholder:ve("eventDescriptionPlaceholder"),value:Fe.description}),ar&&Oe("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ve("resource")}),Oe(C,{onValueChange:(Se)=>Mo(Zo(Se)),value:rn,children:[Re(E,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:Re(D,{placeholder:ve("selectResource")})}),Re(h,{children:xe.map((Se)=>Re(f,{value:String(Se.id),children:Se.title},String(Se.id)))})]})]}),Oe("div",{className:"flex items-center space-x-2",children:[Re(v,{checked:ze,id:"allDay",onCheckedChange:(Se)=>Wo(Se===!0)}),Re(s,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ve("allDay")})]}),Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:en.map(([Se,ke,Ie])=>Oe("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(Tr,{className:"mt-1",closeOnSelect:!0,date:ke,disabled:cr,onChange:Ie})]},Se))}),!ze&&Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:tn.map(([Se,ke,Ie,at,it])=>Oe("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(kr,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:it.max,minTime:it.min,name:ke,onChange:at,placeholder:ve("searchTime"),timeFormat:De,value:Ie})]},Se))}),Oe("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",children:ve("color")}),Re(xr,{"aria-label":ve("color"),onChange:Go,swatches:qn,value:It})]}),Re(Ut,{label:ve("location"),name:"location",onChange:Ft,placeholder:ve("eventLocationPlaceholder"),value:Fe.location}),Re(pr,{event:jo,onChange:_o})]})}),Oe(G,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[be&&Re(o,{className:"w-full sm:mr-auto sm:w-auto",onClick:Xo,size:"sm",type:"button",variant:"destructive",children:ve("delete")}),Oe("div",{className:"flex w-full gap-2 sm:w-auto",children:[Re(o,{className:"flex-1 sm:flex-none",onClick:b,size:"sm",type:"button",variant:"outline",children:ve("cancel")}),Re(o,{className:"flex-1 sm:flex-none",disabled:dr,size:"sm",type:"submit",children:be?ve("update"):ve("create")})]})]})]}),Re(gt,{dialog:Y,onCancel:ge,onResolve:ye})]})};import{jsx as ht,jsxs as Lr}from"react/jsx-runtime";var Fr=()=>{let{t:c,selectedEvent:b,isEventFormOpen:T,closeEventForm:k,addEvent:V,updateEvent:Y,deleteEvent:le,renderEventForm:U}=r((De)=>({t:De.t,selectedEvent:De.selectedEvent,isEventFormOpen:De.isEventFormOpen,closeEventForm:De.closeEventForm,addEvent:De.addEvent,updateEvent:De.updateEvent,deleteEvent:De.deleteEvent,renderEventForm:De.renderEventForm})),ve={open:T,onClose:k,selectedEvent:b,onAdd:V,onUpdate:(De)=>{Y(De.id,De)},onDelete:(De)=>{le(De.id)}};if(U)return U(ve);return ht(R,{onOpenChange:k,open:T,children:Lr(w,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[Lr(S,{className:"mb-2 sm:mb-4 shrink-0",children:[ht(P,{className:"text-base sm:text-lg",children:b?.id?c("editEvent"):c("createEvent")}),ht(W,{className:"text-xs sm:text-sm",children:b?.id?c("editEventDetails"):c("addNewEvent")})]}),ht(Ar,{...ve})]})})};import{ChevronLeft as ha,ChevronRight as Ea,Download as ba,Plus as Sa}from"lucide-react";var Kt=`\r
2
+ `,ta=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Kt),Et=(c)=>c.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
+ `,"\\n").replaceAll("\r",""),Gr=(c,b=!1)=>{if(b)return c.format("YYYYMMDD");return c.utc().format("YYYYMMDD[T]HHmmss[Z]")},ra=(c)=>c.uid||`${c.id}@ilamy.calendar`,oa=(c,b)=>{let T=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),k=c.allDay?";VALUE=DATE":"",V=["BEGIN:VEVENT",`UID:${ra(c)}`,`DTSTART${k}:${Gr(c.start,c.allDay)}`,`DTEND${k}:${Gr(c.end,c.allDay)}`,`SUMMARY:${Et(c.title)}`,c.description&&`DESCRIPTION:${Et(c.description)}`,c.location&&`LOCATION:${Et(c.location)}`].filter(Boolean),Y=b("ical:vevent-properties",c).filter((U)=>typeof U==="string"),le=[`DTSTAMP:${T}`,`CREATED:${T}`,`LAST-MODIFIED:${T}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...V,...Y,...le].join(Kt)},na=(c,b,T="ilamy Calendar")=>{let k=Et(T),V=c.map((Y)=>oa(Y,b));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${k}`,`X-WR-CALDESC:Exported from ${k}`,ta,...V,"END:VCALENDAR"].join(Kt)},Br=(c,b,T="calendar.ics",k="ilamy Calendar")=>{let V=new Blob([na(c,b,k)],{type:"text/calendar;charset=utf-8"}),Y=URL.createObjectURL(V),le=T;if(!T.endsWith(".ics"))le=`${T}.ics`;let U=document.createElement("a");U.href=Y,U.download=le,document.body.append(U),U.click(),U.remove(),URL.revokeObjectURL(Y)};function zr(){let{rawEvents:c,collect:b}=r((T)=>({rawEvents:T.rawEvents,collect:T.collect}));return()=>{let T=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Br(c,b,T,"ilamy Calendar")}}import{ChevronDown as ca}from"lucide-react";import{useState as ma}from"react";function jr(){let{currentLocale:c,timezone:b}=r((k)=>({currentLocale:k.currentLocale,timezone:k.timezone}));return{formatDateRange:(k,V)=>{let Y=new Intl.DateTimeFormat(c,{timeZone:b,month:"short",day:"numeric"});if(k.year()===V.year())return Y.formatRange(k.toDate(),V.toDate());return`${Y.format(k.toDate())} – ${Y.format(V.toDate())}`}}}import{useState as ia}from"react";import{jsx as aa}from"react/jsx-runtime";function bt({label:c,isSelected:b,isCurrent:T,onSelect:k}){return aa("button",{"aria-pressed":b,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",T&&"ring-1 ring-inset ring-foreground/40",b&&"bg-primary text-primary-foreground"),onClick:k,type:"button",children:c})}import{jsx as Zt,jsxs as sa}from"react/jsx-runtime";function _r({selected:c,onSelect:b}){let[T,k]=ia(()=>c.year()),V=t(),Y=Array.from({length:12},(le,U)=>({index:U,label:c.month(U).format("MMM")}));return sa("div",{className:"w-72 p-3","data-slot":"month-grid",children:[Zt(Je,{label:T,nextLabel:"Next year",onNext:()=>k((le)=>le+1),onPrev:()=>k((le)=>le-1),prevLabel:"Previous year"}),Zt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=T===c.year()&&le.index===c.month(),ge=T===V.year()&&le.index===V.month()&&!U;return Zt(bt,{isCurrent:ge,isSelected:U,label:le.label,onSelect:()=>b(c.year(T).month(le.index).date(1))},le.index)})})]})}import{useState as la}from"react";import{jsx as qt,jsxs as da}from"react/jsx-runtime";var ct=12;function Yr({selected:c,onSelect:b}){let[T,k]=la(()=>c.year()-c.year()%ct),V=t(),Y=Array.from({length:ct},(le,U)=>T+U);return da("div",{className:"w-72 p-3","data-slot":"year-grid",children:[qt(Je,{label:`${T} – ${T+ct-1}`,nextLabel:"Next years",onNext:()=>k((le)=>le+ct),onPrev:()=>k((le)=>le-ct),prevLabel:"Previous years"}),qt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=le===c.year(),ge=le===V.year()&&!U;return qt(bt,{isCurrent:ge,isSelected:U,label:le,onSelect:()=>b(c.year(le))},le)})})]})}import{jsx as qe,jsxs as $r}from"react/jsx-runtime";var ua={day:"day",week:"week",month:"month",year:"year"};function pa(c){let b=c?.navigationStep??{amount:1,unit:c?.navigationUnit??"day"};if(b.amount!==1)return"range";return ua[b.unit]??"range"}function Wr({className:c}){let{currentDate:b,currentRange:T,view:k,selectDate:V,firstDayOfWeek:Y,getViews:le}=r((Pe)=>({currentDate:Pe.currentDate,currentRange:Pe.currentRange,view:Pe.view,selectDate:Pe.selectDate,firstDayOfWeek:Pe.firstDayOfWeek,getViews:Pe.getViews})),{formatDateRange:U}=jr(),[ge,ye]=ma(!1),ve=i(b,Y),De=ve.at(0)??b,he=ve.at(-1)??b,xe=(Pe)=>{V(Pe),ye(!1)},be=pa(le().find((Pe)=>Pe.name===k)),Ce={year:b.format("YYYY"),month:b.format("MMM YYYY"),week:U(De,he),day:b.format("ddd, MMM D, YYYY"),range:U(T.start,T.end)}[be],we=qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,onSelect:(Pe)=>Pe&&xe(t(Pe)),selected:b.toDate()}),Ne={year:qe(Yr,{onSelect:xe,selected:b}),month:qe(_r,{onSelect:xe,selected:b}),week:qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,highlightedWeekOf:b,onSelect:(Pe)=>Pe&&xe(t(Pe)),weekHover:!0}),day:we,range:we}[be];return $r(je,{onOpenChange:ye,open:ge,children:[qe(_e,{asChild:!0,children:$r(o,{className:e("font-semibold",c),"data-testid":"calendar-title",variant:"outline",children:[Ce,qe(ca,{className:"size-4 shrink-0 opacity-50"})]})}),qe(Ye,{align:"start",className:"w-auto p-0",children:Ne})]})}import*as Le from"@radix-ui/react-dropdown-menu";import{jsx as mt}from"react/jsx-runtime";function Ur({...c}){return mt(Le.Root,{"data-slot":"dropdown-menu",...c})}function Kr({...c}){return mt(Le.Trigger,{"data-slot":"dropdown-menu-trigger",...c})}function Zr({className:c,sideOffset:b=4,align:T="end",...k}){return mt(Le.Portal,{children:mt(Le.Content,{align:T,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",c),"data-slot":"dropdown-menu-content",sideOffset:b,...k})})}function qr({className:c,...b}){return mt(Le.Item,{className:e("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",c),"data-slot":"dropdown-menu-item",...b})}import{Check as fa,ChevronDown as ga}from"lucide-react";function St(){let{getViews:c,resources:b}=r((k)=>({getViews:k.getViews,resources:k.resources})),T=Boolean(b?.length);return c().filter((k)=>!T||k.supportsResources)}import{jsx as Ue,jsxs as Xt}from"react/jsx-runtime";function Xr({className:c}){let{view:b,setView:T,t:k}=r((ge)=>({view:ge.view,setView:ge.setView,t:ge.t})),V=St(),Y=V.find((ge)=>ge.name===b),le=Y?k(Y.label??Y.name):"",U=Y?.icon;return Xt(Ur,{children:[Ue(Kr,{asChild:!0,className:c,children:Xt(o,{size:"default",variant:"outline",children:[U&&Ue(U,{className:"size-4"}),Ue("span",{children:le}),Ue(ga,{className:"size-4 opacity-50"})]})}),Ue(Zr,{align:"end",className:"min-w-40",children:V.map((ge)=>{let ye=ge.icon;return Xt(qr,{onSelect:()=>T(ge.name),children:[Ue(ye,{className:"size-4"}),Ue("span",{className:"flex-1",children:k(ge.label??ge.name)}),ge.name===b&&Ue(fa,{className:"size-4"})]},ge.name)})})]})}import*as xt from"@radix-ui/react-toggle-group";import{cva as va}from"class-variance-authority";import{createContext as ya,useContext as Da}from"react";import{jsx as Qt}from"react/jsx-runtime";var Ca=va("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors outline-none hover:bg-muted hover:text-muted-foreground focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer select-none",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-2.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qr=ya({size:"default",variant:"default"});function Jr({className:c,variant:b,size:T,children:k,...V}){return Qt(xt.Root,{className:e("flex items-center justify-center gap-1",c),"data-slot":"toggle-group",...V,children:Qt(Qr.Provider,{value:{variant:b,size:T},children:k})})}function eo({className:c,children:b,variant:T,size:k,...V}){let Y=Da(Qr);return Qt(xt.Item,{className:e(Ca({variant:Y.variant||T,size:Y.size||k}),c),"data-slot":"toggle-group-item",...V,children:b})}import{jsx as to}from"react/jsx-runtime";function ro({className:c}){let{view:b,setView:T,t:k}=r((Y)=>({view:Y.view,setView:Y.setView,t:Y.t})),V=St();return to(Jr,{className:e("bg-muted gap-0 rounded-lg p-0.75",c),onValueChange:(Y)=>Y&&T(Y),size:"sm",type:"single",value:b,children:V.map((Y)=>to(eo,{className:"text-muted-foreground data-[state=on]:bg-background data-[state=on]:text-foreground rounded-md px-3 font-medium data-[state=on]:shadow-sm",value:Y.name,children:k(Y.label??Y.name)},Y.name))})}import{jsx as Me,jsxs as tt}from"react/jsx-runtime";var oo=({className:c=""})=>{let{nextPeriod:b,prevPeriod:T,today:k,openEventForm:V,headerComponent:Y,headerClassName:le,t:U,hideExportButton:ge}=r((ve)=>({nextPeriod:ve.nextPeriod,prevPeriod:ve.prevPeriod,today:ve.today,openEventForm:ve.openEventForm,headerComponent:ve.headerComponent,headerClassName:ve.headerClassName,t:ve.t,hideExportButton:ve.hideExportButton})),ye=zr();if(Y)return Y;return Me("div",{className:e("@container/base-header w-full",le),"data-testid":"calendar-header",children:tt("div",{className:e("flex flex-col items-center gap-2 @xl/base-header:flex-row @xl/base-header:justify-between",c),children:[tt("div",{className:"flex min-w-0 flex-wrap items-center justify-center gap-2",children:[tt("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[Me(o,{"aria-label":U("previous"),className:"h-full",onClick:T,size:"icon",variant:"ghost",children:Me(ha,{className:"size-4"})}),Me(o,{"aria-label":U("next"),className:"h-full",onClick:b,size:"icon",variant:"ghost",children:Me(Ea,{className:"size-4"})})]}),Me(o,{onClick:k,size:"default",variant:"outline",children:U("today")}),Me(Wr,{})]}),tt("div",{className:"flex items-center gap-2",children:[Me(ro,{className:"hidden @4xl/base-header:flex"}),Me(Xr,{className:"@4xl/base-header:hidden"}),!ge&&tt(o,{"aria-label":U("export"),onClick:ye,size:"default",variant:"outline",children:[Me(ba,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("export")})]}),tt(o,{"aria-label":U("new"),onClick:()=>V(),size:"default",children:[Me(Sa,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("new")})]})]})]})})};import{useMemo as To}from"react";import{useRef as lo}from"react";import{useEffect as xa,useRef as wa}from"react";var Pa=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,Ta="[data-hour]",Ra='[data-start]:not([data-all-day="true"])',Na=(c)=>{let T=Pa.exec(c)?.at(1);if(!T)return null;let k=Number.parseInt(T,10);return k>=0&&k<=23?k:null},Jt=(c)=>Number.parseInt(c.getAttribute("data-hour")??"",10),ka=(c,b)=>{let T=c.at(0),k=c.at(-1);if(!T||!k)return null;if(b<=Jt(T))return T;if(b>=Jt(k))return k;return c.find((V)=>Jt(V)===b)??null},Ma=(c)=>({start:t(c.dataset.start??""),end:t(c.dataset.end??"")}),Ha=(c)=>{let b=Array.from(c.querySelectorAll(Ra)),T=b.at(0),k=t(),V=b.find((Y)=>d(Ma(Y),k,k));if(!T||!V)return null;return{target:V,origin:T}},Oa=(c,b)=>{let T=b?Na(b):null;if(T===null)return null;let k=Array.from(c.querySelectorAll(Ta)),V=k.at(0),Y=ka(k,T);if(!V||!Y)return null;return{target:Y,origin:V}},Ia=(c,b,T,k)=>{let V=b.getBoundingClientRect(),Y=T.getBoundingClientRect(),le=V.left-Y.left,U=V.top-Y.top;no(c,k,k==="horizontal"?le:U)},no=(c,b,T)=>{let k=b==="horizontal"?"left":"top";c.scrollTo({[k]:T,behavior:"auto"})},Va=(c,{scrollTime:b,scrollToNow:T,axis:k})=>{let Y=(T?Ha(c):null)??Oa(c,b);if(Y)return Ia(c,Y.target,Y.origin,k),!0;if(T)return no(c,k,0),!0;return!1},wt=({viewportRef:c,scrollTime:b,scrollToNow:T=!1,enabled:k,scrollKey:V,axis:Y="vertical"})=>{let le=wa(null);xa(()=>{if(!k)return;let U=`${V}|${b}|${T}`;if(le.current===U)return;let ge=c.current;if(!ge)return;if(Va(ge,{scrollTime:b,scrollToNow:T,axis:Y}))le.current=U},[k,b,T,V,c,Y])};import{useLayoutEffect as Aa}from"react";var er="data-sticky-inset",Pt=(c)=>c?"top":void 0,ao={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},io=new Set(["hidden","scroll","auto","overlay","clip"]),La=(c)=>{let b=[];for(let T=c.parentElement;T;T=T.parentElement){let{overflowX:k,overflowY:V}=getComputedStyle(T);if(io.has(k)||io.has(V))b.push(T)}return b},Fa=(c,b,T)=>{let k=b.getBoundingClientRect(),V={left:-k.left,top:-k.top};for(let le of T){let U=le.getBoundingClientRect();V.left=Math.max(V.left,U.left-k.left),V.top=Math.max(V.top,U.top-k.top)}let Y=c.querySelectorAll(`[${er}]`);for(let le of Y){let U=le.getAttribute(er),ge=le.getBoundingClientRect();if(U==="left")V.left=Math.max(V.left,ge.right-k.left);if(U==="top")V.top=Math.max(V.top,ge.bottom-k.top)}return{left:Math.max(0,V.left),top:Math.max(0,V.top)}},Tt=(c,b,T)=>{let{currentDate:k,view:V,stickyViewHeader:Y}=r((U)=>({currentDate:U.currentDate,view:U.view,stickyViewHeader:U.stickyViewHeader})),le=n.stickyInsets(V,k,Y,T);Aa(()=>{let U=c.current,ge=b.current;if(!U||!ge)return;let ye=La(U),ve=()=>{let Ee=Fa(U,ge,ye);ge.style.setProperty(ao.left,`${Ee.left}px`),ge.style.setProperty(ao.top,`${Ee.top}px`)};ve();let De,he=()=>{if(De!==void 0)return;De=requestAnimationFrame(()=>{De=void 0,ve()})},xe=[...ye,window];for(let Ee of xe)Ee.addEventListener("scroll",he,{passive:!0});window.addEventListener("resize",he,{passive:!0});let be=typeof ResizeObserver>"u"?void 0:new ResizeObserver(ve);be?.observe(ge);for(let Ee of U.querySelectorAll(`[${er}]`))be?.observe(Ee);return()=>{for(let Ee of xe)Ee.removeEventListener("scroll",he);if(window.removeEventListener("resize",he),be?.disconnect(),De!==void 0)cancelAnimationFrame(De)}},[c,b,le])};var Ga=(c)=>{if(c.days)return c.days;return c.day?[c.day]:[]},Rt=(c,b,T)=>{let k=T.flatMap(Ga).map((Y)=>Y.toISOString()),V=[...new Set(k)].join(",");return`${c}-${b.format("YYYY-MM-DD")}-${V}`};import{memo as Ba}from"react";import{jsx as ja}from"react/jsx-runtime";var za=({children:c,className:b})=>{let{stickyViewHeader:T,viewHeaderClassName:k}=r((V)=>({stickyViewHeader:V.stickyViewHeader,viewHeaderClassName:V.viewHeaderClassName}));return ja("div",{className:e("flex h-12 w-fit",T&&"sticky top-0 z-21 bg-background",b,k),"data-sticky-inset":Pt(T),"data-testid":"horizontal-grid-header",children:c})},so=Ba(za);import{jsx as rt,jsxs as co}from"react/jsx-runtime";var mo=({rows:c,children:b,classes:T,allDay:k,gridType:V,variant:Y="resource",dayNumberHeight:le})=>{let{currentDate:U,view:ge,scrollTime:ye,scrollToNow:ve}=r(),De=lo(null),he=lo(null),xe=Y==="resource",be=!xe,Ee=c.flatMap((Te)=>Te.columns??[]),Ce=Rt(ge,U,Ee);wt({viewportRef:he,scrollTime:ye,scrollToNow:ve,enabled:xe,scrollKey:Ce,axis:"horizontal"}),Tt(De,he,c.length);let we=b&&rt(so,{className:T?.header,children:b});return co("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:De,children:[be&&we,co(u,{className:e("h-full",be&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:he},children:[xe&&we,rt("div",{className:e("flex flex-1 w-fit",T?.body),"data-testid":"horizontal-grid-body",children:rt("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:c.map((Te)=>rt(oe,{allDay:Te.allDay??k,dayNumberHeight:le,gridType:V,variant:Y,...Te},Te.id))})}),rt(y,{className:"z-30"}),rt(y,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as xo}from"react";import{memo as Ja}from"react";import{memo as Za,useMemo as qa}from"react";import{useMemo as po}from"react";var _a=(c)=>{let b=[],T=[],k=null;for(let V of c){if(k&&V.start.isSameOrAfter(k)){if(T.length>0)b.push(T);T=[]}T.push(V),k=k?t.max(k,V.end):V.end}if(T.length>0)b.push(T);return b},uo=(c,{gridStart:b,totalUnits:T,gridType:k,isDiscrete:V})=>{let Y=N(c.start,b,k),le=N(c.end,b,k);if(V){if(Y=Math.floor(Y),le=Math.ceil(le),le<=Y)le=Y+1}let U=Y<0,ge=le>T;if(U)Y=0;if(ge)le=T;let ye=Math.max(0,le-Y);if(ye===0)return null;return{top:Y/T*100,height:ye/T*100,isTruncatedStart:U,isTruncatedEnd:ge}},Ya={2:25,3:50,4:60},$a=70,Wa=(c)=>Ya[c]??$a,Ua=(c,b)=>{let T=c.length===1?c.at(0):void 0;if(T){let U=uo(T,b);if(!U)return[];return[{kind:"vertical",event:T,left:0,width:100,...U}]}let k=[...c].sort((U,ge)=>{let ye=ge.end.diff(ge.start,"minute")-U.end.diff(U.start,"minute");return ye!==0?ye:U.start.diff(ge.start)}),V=k.length,Y=V>1?Wa(V)/(V-1):0,le=[];for(let U=0;U<V;U++){let ge=k.at(U);if(!ge)continue;let ye=uo(ge,b);if(!ye)continue;let ve=U===0?0:Y*U;le.push({kind:"vertical",event:ge,...ye,left:ve,width:100-ve,zIndex:U+1})}return le},Nt=({days:c,gridType:b="hour",events:T})=>{let Y=(b==="day"?T:T.filter((U)=>!U.allDay)).toSorted((U,ge)=>U.start.diff(ge.start));if(Y.length===0)return[];let le={gridStart:c.at(0)||t(),totalUnits:c.length,gridType:b,isDiscrete:b==="day"};return _a(Y).flatMap((U)=>Ua(U,le))};var fo=({days:c,gridType:b,resourceId:T})=>{let{getEventsForDateRange:k}=r(),V=c.at(0),Y=c.at(-1),le=V?.startOf("day"),U=Y?.endOf("day"),ge=po(()=>{if(!le||!U)return[];let ve=k(le,U);return x(ve,T)},[le,U,k,T]);return po(()=>Nt({days:c,events:ge,gridType:b}),[c,b,ge])};import{jsx as Ka,jsxs as go}from"react/jsx-runtime";function vo({previewPositioned:c}){let b=r((U)=>U.timeFormat),{event:T,isTruncatedStart:k,isTruncatedEnd:V}=c,Y=q(b),le=!T.allDay;return go(re,{contentClassName:"px-1.5 py-1 relative",event:T,isTruncatedEnd:V,isTruncatedStart:k,orientation:"vertical",style:ne(c),children:[le&&go("p",{className:"text-[10px] font-semibold sm:text-xs",children:[T.start.format(Y)," – ",T.end.format(Y)]}),Ka("p",{className:e("text-[10px] font-bold sm:text-xs truncate",M.vertical),children:T.title})]})}import{jsx as yo}from"react/jsx-runtime";var Do=(c,b,T,k)=>`event-${c}-${b}-${T.at(0)?.toISOString()}-${k??"no-resource"}`;function Co({positioned:c,elementId:b,range:T,resourceId:k,draggedEventId:V}){let{event:Y}=c,le=Y.end.diff(Y.start,"minute")<=15;return yo("div",{className:"absolute","data-testid":n.container.verticalEvent(Y.id),style:ne(c),children:yo(A,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":le}),dragSegment:K(Y,T,"vertical"),elementId:b,event:Y,isBeingDragged:V===Y.id,isTruncatedEnd:c.isTruncatedEnd,isTruncatedStart:c.isTruncatedStart,sourceResourceId:k})})}import{jsx as kt,jsxs as Qa}from"react/jsx-runtime";var Xa=({days:c,gridType:b="hour",resourceId:T,resource:k,"data-testid":V})=>{let Y=r((Ee)=>Ee.resources),le=p(),U=fo({days:c,gridType:b,resourceId:T}),ge=c.at(0),ye=c.at(-1)?.add(1,b),De=T===void 0||Y?.at(0)?.id===T,he=b==="hour"&&Boolean(ge&&ye),xe=te({days:c,gridType:b,resourceId:T}),be=qa(()=>{if(!xe)return null;return Nt({days:c,gridType:b,events:[xe]}).at(0)??null},[xe,c,b]);return kt(F.Provider,{value:"vertical",children:Qa("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":V,children:[he&&ge&&ye&&kt(ee,{rangeEnd:ye,rangeStart:ge,resource:k,withDot:De}),U.map((Ee,Ce)=>{let we=Do(Ee.event.id,Ce,c,T);return kt(Co,{draggedEventId:le?.event.id,elementId:we,positioned:Ee,range:{start:ge,end:ye},resourceId:T},n.listKey(we,"wrapper"))}),be&&kt(vo,{previewPositioned:be})]})})},ho=Za(Xa);import{jsx as ot,jsxs as ti}from"react/jsx-runtime";var ei=({id:c,days:b,resource:T,"data-testid":k,"data-sticky-inset":V,gridType:Y,className:le,renderCell:U,noEvents:ge,slotDurationMinutes:ye=60})=>{let ve=T?.id,De=Math.floor(60/ye),he=Array.from({length:De},(be,Ee)=>Ee*ye),xe=he.length>1;return ot("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",le),"data-sticky-inset":V,"data-testid":k||n.container.vertical.col(c),children:ti("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${b.length}, minmax(0, 1fr))`},children:[b.map((be,Ee)=>{let Ce=be.format("HH");if(U){let we=c===n.col.time,Te=we?n.cell.verticalTime(Ce):n.cell.vertical(be,Ce,"00",ve);return ot("div",{className:"min-h-[60px] bg-background","data-hour":we?Ce:void 0,"data-testid":Te,children:U(be)},n.listKey(Ee,Ce))}return ot("div",{className:"flex flex-col min-h-[60px]",children:he.map((we,Te)=>{let Ne=String(we).padStart(2,"0"),Pe=n.cell.vertical(be,Ce,Ne,ve),Ve=xe&&Te<he.length-1;return ot(z,{className:e("not-in-data-dragging:hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",Ve&&"border-b border-dashed"),"data-testid":Pe,day:xe?be.minute(we):be,gridType:Y,hour:Y==="hour"?be.hour():void 0,isSubDivider:Ve,minute:xe?we:void 0,resourceId:ve,shouldRenderEvents:!1,slotDurationMinutes:ye},n.listKey(Ee,Ne))})},n.listKey(Ee,Ce))}),!ge&&ot("div",{className:"absolute inset-0 z-10 pointer-events-none",children:ot(ho,{"data-testid":n.container.eventsLayer("vertical",c),days:b,gridType:Y,resource:T,resourceId:ve})})]})})},Eo=Ja(ei);import{memo as ri}from"react";import{jsx as bo,jsxs as ni}from"react/jsx-runtime";var oi=({children:c,classes:b,allDayRow:T,expandAllDayRow:k=!1})=>{let{stickyViewHeader:V,viewHeaderClassName:Y}=r((U)=>({stickyViewHeader:U.stickyViewHeader,viewHeaderClassName:U.viewHeaderClassName})),le="min-w-full w-fit";return ni("div",{className:e(k&&"flex h-full flex-col",V&&"sticky top-0 z-21 bg-background",Y),"data-sticky-inset":Pt(V),children:[bo("div",{className:e("min-h-12 border-b","min-w-full w-fit",b?.header),"data-testid":"vertical-grid-header",children:c}),T&&bo("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",k&&"flex-1 overflow-hidden",b?.allDay),"data-testid":"vertical-grid-all-day",children:T})]})},So=ri(oi);import{jsx as nt,jsxs as wo}from"react/jsx-runtime";var Po=({columns:c,children:b,gridType:T="day",variant:k="resource",classes:V,allDayRow:Y,slotDurationMinutes:le,style:U})=>{let ge=k==="resource",ye=!ge,ve=c.every((Pe)=>!Pe.days?.length),{currentDate:De,view:he,scrollTime:xe,scrollToNow:be}=r(),Ee=xo(null),Ce=xo(null),we=!ve,Te=Rt(he,De,c);wt({viewportRef:Ce,scrollTime:xe,scrollToNow:be,enabled:we,scrollKey:Te}),Tt(Ee,Ce,c.length);let Ne=b&&nt(So,{allDayRow:Y,classes:{header:V?.header,allDay:V?.allDay},expandAllDayRow:ve,children:b});if(ve&&Ne)return nt("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:U,children:Ne});return wo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:Ee,style:U,children:[ye&&Ne,wo(u,{className:e("h-full",ye&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:Ce},children:[ge&&Ne,nt("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",V?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:c.map((Pe,Ve)=>nt(Eo,{...Pe,gridType:T,slotDurationMinutes:le},n.listKey("col",Ve)))}),nt(y,{className:"z-30"})," ",nt(y,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as Xe}from"react/jsx-runtime";var ai=(c,b)=>b==="vertical",ii=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let{slotDuration:V}=r((he)=>({slotDuration:he.slotDuration})),Y=c.some((he)=>he.gridType==="hour")?"hour":"day",le=c.filter((he)=>!he.noEvents).map((he)=>he.day).filter((he)=>Boolean(he)),U=c.find((he)=>he.noEvents),ye=Boolean(U?.className?.includes(j))?{cell:"flex-1 min-w-0",spacer:j}:void 0,ve;if(Y==="hour")ve=T?Xe(me,{columns:c}):Xe(ae,{classes:ye,days:le});return Xe(Po,{allDayRow:ve,classes:T?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:c,gridType:Y,slotDurationMinutes:V,variant:k,children:b})},si=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let V=c.some((U)=>U.columns?.some((ge)=>ge.gridType==="hour"))?"hour":"day",Y=c.some((U)=>U.columns?.some((ge)=>ge.days)),le=T?{header:e(Y&&ue,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return Xe(mo,{classes:le,dayNumberHeight:T?0:void 0,gridType:V,rows:c,variant:k,children:b})},Ro=({view:c})=>{let{currentDate:b,firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}=r((Ce)=>({currentDate:Ce.currentDate,firstDayOfWeek:Ce.firstDayOfWeek,hiddenDays:Ce.hiddenDays,businessHours:Ce.businessHours,hideNonBusinessHours:Ce.hideNonBusinessHours,resources:Ce.resources,orientation:Ce.orientation,weekViewGranularity:Ce.weekViewGranularity})),ye=To(()=>({firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}),[T,k,V,Y,le,U,ge]),ve=To(()=>c.columns?.(b,ye),[c,b,ye]);if(!ve||!c.layout){let Ce=c.component;if(Ce)return Xe(Ce,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${c.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let he=Boolean(le?.length)&&Boolean(c.supportsResources),xe=he?U??"horizontal":c.layout,be=he?"resource":"regular",Ee=c.renderHeader?.({date:b,config:ye});if(ai(ve,xe))return Xe(ii,{composesResourceAxis:he,header:Ee,specs:ve,variant:be});return Xe(si,{composesResourceAxis:he,header:Ee,specs:ve,variant:be})};var No=(c)=>{if(!c||c.length===0)return;return new Set(c.map((b)=>H[b]))};function ko(c){if(!c?.length)return[];return c.map((b)=>({...b,start:t(b.start),end:t(b.end)}))}import{jsx as Ke,jsxs as mi}from"react/jsx-runtime";var ci=()=>{let{view:c,getViews:b}=r((V)=>({view:V.view,getViews:V.getViews})),T=b().find((V)=>V.name===c);return mi("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[Ke(oo,{className:"p-1 shrink-0 mb-1"}),Ke(br,{children:Ke(l,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:c,children:Ke("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:T?Ke(Ro,{view:T},c):null})})}),Ke(Fr,{})]})},tr=({events:c,firstDayOfWeek:b="sunday",initialView:T="month",initialDate:k,eventSpacing:V=Z,eventHeight:Y=Q,stickyViewHeader:le=!0,viewHeaderClassName:U="",timeFormat:ge="12-hour",hideNonBusinessHours:ye=!1,hiddenDays:ve,resources:De,orientation:he,...xe})=>{let be=Boolean(De?.length),Ee=di(()=>ko(c),[c]);return li(()=>{if(typeof process<"u"&&!1)console.warn("[@ilamy/calendar] `orientation` was provided without `resources` — it only applies when the calendar has resources, so it is ignored.")},[he,be]),Ke(_,{eventHeight:Y,eventSpacing:V,events:Ee,firstDayOfWeek:H[b],hiddenDays:No(ve),hideNonBusinessHours:ye,initialDate:k,initialView:T,orientation:he,resources:De,stickyViewHeader:le,timeFormat:ge,viewHeaderClassName:U,...xe,children:Ke(ci,{})})};import{jsx as pi}from"react/jsx-runtime";var ui=(c)=>pi(tr,{...c});export{tr as IlamyCalendar,ui as IlamyResourceCalendar,mr as SLOT_EVENT_FORM,ur as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,se as defaultTranslations,fe as useIlamyCalendarContext};
@@ -59,8 +59,15 @@ type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "fr
59
59
  */
60
60
  interface BusinessHours {
61
61
  /**
62
- * Days of the week to apply business hours to.
63
- * @default ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
62
+ * Days of the week to apply business hours to. Omitted, the hours apply to
63
+ * every day, weekends included, in both the object and the array form.
64
+ *
65
+ * This deviates from FullCalendar, which defaults an object to Monday-Friday
66
+ * and ignores an array entry without days
67
+ * (core/src/structs/business-hours.ts, v6.1.21). Kept until the next major
68
+ * (see the TODO in business-hours.ts); list the days explicitly to get
69
+ * weekdays only.
70
+ * @default every day
64
71
  */
65
72
  daysOfWeek?: WeekDays[];
66
73
  /**
@@ -1 +1 @@
1
- import{e,W,d,T}from"../shared/chunk-h5d5q285.js";import{u,b,G}from"../shared/chunk-m1q73v86.js";import{t}from"../shared/chunk-kpzykmz4.js";import{List as M}from"lucide-react";import{createElement as H}from"react";import{useIlamyCalendarContext as Y}from"@ilamy/calendar";var S={day:(a)=>({start:a.startOf("day"),end:a.endOf("day")}),week:(a,n)=>{let r=(a.day()-n+7)%7,o=a.subtract(r,"day").startOf("day");return{start:o,end:o.add(6,"day").endOf("day")}},month:(a)=>({start:a.startOf("month"),end:a.endOf("month")})},P={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},p=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return S[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return P[a]};var V=(a,n,r)=>{if(a.allDay)return d(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},j=(a,n)=>{let r=a.allDay?0:1,o=n.allDay?0:1;if(r!==o)return r-o;return a.start.valueOf()-n.start.valueOf()},v=(a,n)=>{let r=[],o=n.end.startOf("day"),s=n.start.startOf("day");while(s.isSameOrBefore(o)){let i=s.startOf("day"),y=s.endOf("day"),m=a.filter((l)=>V(l,i,y)).sort(j);if(m.length>0)r.push({key:s.format("YYYY-MM-DD"),date:i,events:m});s=s.add(1,"day")}return r};import{useIlamyCalendarContext as L}from"@ilamy/calendar";import{useIlamyCalendarContext as I}from"@ilamy/calendar";import{jsx as f,jsxs as F}from"react/jsx-runtime";var B=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:s}=I(),i=a.start.format(B(o)),y=a.allDay?r("allDay"):i,m=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(m,"day")+1,R=n.startOf("day").diff(m,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return F("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>s(a),type:"button",children:[f("span",{className:"text-muted-foreground w-20 shrink-0",children:y}),f("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),f("span",{className:"truncate",children:a.title}),x&&f("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as c,jsxs as k}from"react/jsx-runtime";var C=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=L(),o=W(a.date,t()),s;if(r)s=(i)=>r({...i,view:n});return k("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":T("agenda-day",a.key),children:[c("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:c(b,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),k("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&c(G,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:s}),a.events.map((i)=>c(O,{day:a.date,event:i},T(a.key,i.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var h=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:s}=Y(),i=p(n,a,s),y=r(i.start,i.end),m=v(y,i);if(m.length===0)return g("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-sm","data-testid":"agenda-empty",children:o("agendaNoEvents")});return g(u,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:m.map((l)=>g(C,{group:l},l.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:M,navigationStep:A(a),range:(n,r)=>p(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>H(h,{window:a})});var z=(a={})=>({name:"agenda",views:[D(a)]});export{z as agendaPlugin,D as createAgendaView};
1
+ import{e,U,d,T}from"../shared/chunk-89xfgjfh.js";import{u,b,Y}from"../shared/chunk-bgegqhb4.js";import{t}from"../shared/chunk-nvtnncwx.js";import{List as L}from"lucide-react";import{createElement as M}from"react";import{useIlamyCalendarContext as F}from"@ilamy/calendar";var S={day:(a)=>({start:a.startOf("day"),end:a.endOf("day")}),week:(a,n)=>{let r=(a.day()-n+7)%7,o=a.subtract(r,"day").startOf("day");return{start:o,end:o.add(6,"day").endOf("day")}},month:(a)=>({start:a.startOf("month"),end:a.endOf("month")})},P={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},p=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return S[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return P[a]};var W=(a,n,r)=>{if(a.allDay)return d(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},V=(a,n)=>{let r=a.allDay?0:1,o=n.allDay?0:1;if(r!==o)return r-o;return a.start.valueOf()-n.start.valueOf()},v=(a,n)=>{let r=[],o=n.end.startOf("day"),s=n.start.startOf("day");while(s.isSameOrBefore(o)){let i=s.startOf("day"),y=s.endOf("day"),m=a.filter((l)=>W(l,i,y)).sort(V);if(m.length>0)r.push({key:s.format("YYYY-MM-DD"),date:i,events:m});s=s.add(1,"day")}return r};import{useIlamyCalendarContext as B}from"@ilamy/calendar";import{useIlamyCalendarContext as j}from"@ilamy/calendar";import{jsx as f,jsxs as G}from"react/jsx-runtime";var I=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:s}=j(),i=a.start.format(I(o)),y=a.allDay?r("allDay"):i,m=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(m,"day")+1,R=n.startOf("day").diff(m,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return G("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>s(a),type:"button",children:[f("span",{className:"text-muted-foreground w-20 shrink-0",children:y}),f("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),f("span",{className:"truncate",children:a.title}),x&&f("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as c,jsxs as k}from"react/jsx-runtime";var C=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=B(),o=U(a.date,t()),s;if(r)s=(i)=>r({...i,view:n});return k("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":T("agenda-day",a.key),children:[c("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:c(b,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),k("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&c(Y,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:s}),a.events.map((i)=>c(O,{day:a.date,event:i},T(a.key,i.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var h=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:s}=F(),i=p(n,a,s),y=r(i.start,i.end),m=v(y,i);if(m.length===0)return g("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-sm","data-testid":"agenda-empty",children:o("agendaNoEvents")});return g(u,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:m.map((l)=>g(C,{group:l},l.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:L,navigationStep:A(a),range:(n,r)=>p(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>M(h,{window:a})});var H=(a={})=>({name:"agenda",views:[D(a)]});export{H as agendaPlugin,D as createAgendaView};
@@ -59,8 +59,15 @@ type WeekDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "fr
59
59
  */
60
60
  interface BusinessHours {
61
61
  /**
62
- * Days of the week to apply business hours to.
63
- * @default ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
62
+ * Days of the week to apply business hours to. Omitted, the hours apply to
63
+ * every day, weekends included, in both the object and the array form.
64
+ *
65
+ * This deviates from FullCalendar, which defaults an object to Monday-Friday
66
+ * and ignores an array entry without days
67
+ * (core/src/structs/business-hours.ts, v6.1.21). Kept until the next major
68
+ * (see the TODO in business-hours.ts); list the days explicitly to get
69
+ * weekdays only.
70
+ * @default every day
64
71
  */
65
72
  daysOfWeek?: WeekDays[];
66
73
  /**
@@ -325,8 +332,8 @@ interface IlamyPlugin {
325
332
  children: ReactNode2;
326
333
  }>;
327
334
  }
328
- import dayjs from "dayjs";
329
- type Dayjs3 = dayjs.Dayjs3;
335
+ import { Dayjs as DayjsInstance } from "dayjs";
336
+ type Dayjs3 = DayjsInstance;
330
337
  interface CellInfo {
331
338
  /** Start date/time of the cell */
332
339
  start: Dayjs3;