@ilamy/calendar 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![License](https://img.shields.io/npm/l/@ilamy/calendar?style=flat-square&color=black)](https://github.com/kcsujeet/ilamy-calendar/blob/main/LICENSE)
5
5
  [![Build Status](https://img.shields.io/github/actions/workflow/status/kcsujeet/ilamy-calendar/ci.yml?branch=main&style=flat-square)](https://github.com/kcsujeet/ilamy-calendar/actions)
6
6
 
7
- A powerful, full-featured yet **lightweight and highly pluggable** React calendar component library built with **TypeScript**, **Tailwind CSS 4**, and **shadcn/ui**. The core is small — ~40 KB minified (≈13 KB gzipped) — with opt-in plugins for recurring events, agenda views, and more, so you only ship what you use. Built for high-performance scheduling with RFC 5545 recurring events, resource management, and drag-and-drop interactions.
7
+ A powerful, full-featured yet **lightweight and highly pluggable** React calendar component library built with **TypeScript**, **Tailwind CSS 4**, and **shadcn/ui**. The core is small — ~118 KB minified (≈40 KB gzipped), React and other dependencies not included — with opt-in plugins for recurring events, agenda views, and more, so you only ship what you use. Built for high-performance scheduling with RFC 5545 recurring events, resource management, and drag-and-drop interactions.
8
8
 
9
9
  <div align="center">
10
10
  <img width="1159" height="698" alt="Screenshot 2026-07-12 at 2 44 36 PM" src="https://github.com/user-attachments/assets/316c6ad4-2965-4dc4-b779-88b0ac916669" />
package/dist/index.d.ts CHANGED
@@ -129,6 +129,32 @@ interface PluginMutationResult {
129
129
  deleted: CalendarEvent[];
130
130
  }
131
131
  /**
132
+ * One user action and every stored row it touched, reported once through
133
+ * `onEventsChange` (#309). A recurring edit touches several rows (the series,
134
+ * an override, deleted overrides) that the per-row callbacks report one by
135
+ * one; this reports them together so they can be saved, or refused, as a unit.
136
+ * FullCalendar reports an action once the same way (`eventChange` with
137
+ * `relatedEvents`).
138
+ */
139
+ interface EventsChange {
140
+ /** What the user did. */
141
+ action: "add" | "update" | "delete";
142
+ /** The event the user acted on, as it was shown (an occurrence, for a series). */
143
+ event: CalendarEvent;
144
+ /**
145
+ * The scope chosen in the plugin's scope dialog, when a plugin manages the
146
+ * event; otherwise undefined. The recurrence plugin passes its
147
+ * `RecurrenceEditScope` (`'this' | 'following' | 'all'`).
148
+ */
149
+ scope?: unknown;
150
+ /** New rows, the same ones passed to `onEventAdd`. */
151
+ added: CalendarEvent[];
152
+ /** Changed rows, the same ones passed to `onEventUpdate`. */
153
+ updated: CalendarEvent[];
154
+ /** Removed rows, the same ones passed to `onEventDelete`. */
155
+ deleted: CalendarEvent[];
156
+ }
157
+ /**
132
158
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
133
159
  * Carries the resource axis (`resources`, `orientation`) so a resource-capable
134
160
  * view can compose both arrangements. `range()` receives only the
@@ -342,9 +368,10 @@ interface EventMutationScopeSlotContext {
342
368
  resolve: (scope: unknown) => void;
343
369
  cancel: () => void;
344
370
  }
371
+ import { ConfigType, Dayjs as DayjsInstance, ManipulateType as DayjsManipulateType } from "dayjs";
345
372
  import dayjs from "dayjs";
346
- type Dayjs3 = dayjs.Dayjs3;
347
- type ManipulateType3 = dayjs.ManipulateType3;
373
+ type Dayjs3 = DayjsInstance;
374
+ type ManipulateType3 = DayjsManipulateType;
348
375
  /**
349
376
  * dayjs's statics without its call signatures. Mapping over the keys drops the
350
377
  * call signatures, which is what lets the exported type re-advertise only the
@@ -364,27 +391,8 @@ type DayjsStatics = { [K in keyof typeof dayjs] : (typeof dayjs)[K] };
364
391
  * (https://day.js.org/docs/en/parse/string-format). To read a bare wall-clock
365
392
  * string as a time in a given zone, call `dayjs.tz(input, timezone)`.
366
393
  */
367
- type ConfiguredDayjs = ((date?: dayjs.ConfigType) => dayjs.Dayjs3) & DayjsStatics;
394
+ type ConfiguredDayjs = ((date?: ConfigType) => DayjsInstance) & DayjsStatics;
368
395
  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
396
  declare const defaultTranslations: {
389
397
  today: string;
390
398
  create: string;
@@ -477,6 +485,25 @@ type Translations = Record<keyof typeof defaultTranslations, string>;
477
485
  type TranslationKey = keyof Translations;
478
486
  type TranslatorFunction = (key: TranslationKey | string) => string;
479
487
  /**
488
+ * The calendar's plugin mount points. These belong to the host (the components
489
+ * that render them: the event form and the drag-and-drop flow), NOT to the
490
+ * plugin kernel and NOT to any individual plugin. The kernel's `renderSlot`
491
+ * takes a plain `slotName: string` and knows nothing about this list; the core
492
+ * renders these named slots and any plugin may fill the ones it cares about.
493
+ */
494
+ declare const SLOT_EVENT_FORM = "event-form";
495
+ declare const SLOT_EVENT_MUTATION_SCOPE = "event-mutation-scope";
496
+ interface EventFormProps {
497
+ open?: boolean;
498
+ selectedEvent?: CalendarEvent | null;
499
+ onAdd?: (event: CalendarEvent) => void;
500
+ onUpdate?: (event: CalendarEvent) => void;
501
+ onDelete?: (event: CalendarEvent) => void;
502
+ onClose: () => void;
503
+ }
504
+ import React3 from "react";
505
+ import { ReactNode as ReactNode4 } from "react";
506
+ /**
480
507
  * Available calendar view types. The built-in views (day, week, month, year)
481
508
  * are `PluginView` specs in `features/calendar/components/views`; plugins may
482
509
  * contribute additional view names, so this is a broad `string`.
@@ -620,8 +647,14 @@ interface IlamyCalendarProps {
620
647
  /**
621
648
  * Custom render function for calendar events.
622
649
  * If provided, it will override the default event rendering.
650
+ *
651
+ * The default content keeps its title in view while a long event is
652
+ * scrolled partly out of the grid; custom content does not. To opt a
653
+ * custom title in, make it sticky with `left: var(--ilamy-sticky-left)`
654
+ * and `top: var(--ilamy-sticky-top)`, which each grid publishes to clear
655
+ * its own sticky column and header.
623
656
  */
624
- renderEvent?: (event: CalendarEvent, segment: EventSegment) => React3.ReactNode;
657
+ renderEvent?: (event: CalendarEvent, segment: EventSegment) => ReactNode4;
625
658
  /**
626
659
  * Callback when an event is clicked.
627
660
  * Provides the clicked event object.
@@ -667,6 +700,13 @@ interface IlamyCalendarProps {
667
700
  */
668
701
  onEventDelete?: (event: CalendarEvent) => void;
669
702
  /**
703
+ * Callback once per user action, with every stored row it touched: what
704
+ * `onEventAdd`, `onEventUpdate` and `onEventDelete` report one row at a time.
705
+ * Use it to save a recurring edit (series, override, deleted overrides) as
706
+ * one unit. The per-row callbacks still fire; use one or the other.
707
+ */
708
+ onEventsChange?: (change: EventsChange) => void;
709
+ /**
670
710
  * Callback when the current date changes (navigation).
671
711
  * Provides the new current date and the current visible range.
672
712
  */
@@ -741,7 +781,7 @@ interface IlamyCalendarProps {
741
781
  * Custom header component to replace the default calendar header.
742
782
  * Useful for adding custom branding or additional controls.
743
783
  */
744
- headerComponent?: React3.ReactNode;
784
+ headerComponent?: ReactNode4;
745
785
  /**
746
786
  * Custom class name for the calendar header.
747
787
  * Useful for applying custom styles to the header.
@@ -759,7 +799,7 @@ interface IlamyCalendarProps {
759
799
  * If provided, it will override the default event form component.
760
800
  * The function receives EventFormProps and should return a React node.
761
801
  */
762
- renderEventForm?: (props: EventFormProps) => React3.ReactNode;
802
+ renderEventForm?: (props: EventFormProps) => ReactNode4;
763
803
  /**
764
804
  * Called when the "+N more" overflow indicator in a month/grid cell is
765
805
  * clicked, receiving the cell's day and its full list of events.
@@ -828,7 +868,7 @@ interface IlamyCalendarProps {
828
868
  * }}
829
869
  * ```
830
870
  */
831
- renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React3.ReactNode;
871
+ renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => ReactNode4;
832
872
  /**
833
873
  * Days of the week to hide from the week view.
834
874
  * Hidden days won't render as columns, giving remaining days more space.
@@ -852,7 +892,7 @@ interface IlamyCalendarProps {
852
892
  * Custom render function for the hour labels in the gutter/header.
853
893
  * Receives a Dayjs object for the hour and should return a React node.
854
894
  */
855
- renderHour?: (date: Dayjs3) => React3.ReactNode;
895
+ renderHour?: (date: Dayjs3) => ReactNode4;
856
896
  /**
857
897
  * Granularity of the time grid in minutes for day, week, and resource hour views.
858
898
  * Quarter-hour increments only: `15`, `30`, or `60`.
@@ -871,6 +911,11 @@ interface IlamyCalendarProps {
871
911
  * clamped to the nearest visible row when `hideNonBusinessHours` hides
872
912
  * the requested hour.
873
913
  *
914
+ * Reapplied whenever the visible date range changes (navigation, view
915
+ * switch) and whenever `scrollTime` itself changes, as FullCalendar does.
916
+ * Ordinary re-renders leave the user's own scroll position alone.
917
+ * `scrollToNow` takes precedence while the current moment is on screen.
918
+ *
874
919
  * Independent of `businessHours`: you can show all 24 hours and still
875
920
  * focus on 08:00 on load.
876
921
  *
@@ -889,6 +934,32 @@ interface IlamyCalendarProps {
889
934
  */
890
935
  scrollTime?: string;
891
936
  /**
937
+ * Open every scrolling grid on the current moment rather than its start:
938
+ * the current hour in time grids (day, week, resource day, hourly resource
939
+ * week), and today's column or row in day grids (resource month, daily
940
+ * resource week, #285). Month and year grids do not scroll, so it does
941
+ * nothing there.
942
+ *
943
+ * Applies only while now is on screen. On a range without it (after
944
+ * navigating away, or when the current hour or day is hidden) the grid
945
+ * falls back to `scrollTime`, or to its start. Like `scrollTime`, it is
946
+ * applied when the range changes and when this prop changes, not as the
947
+ * clock moves, so it never pulls the grid away from a reader. "Now" is the
948
+ * current instant; the calendar's `timezone` only decides how it is drawn.
949
+ *
950
+ * Now is lined up with the leading edge, like `scrollTime`. Late in the day
951
+ * or month there is not enough grid left to do that, and the browser stops
952
+ * at its maximum scroll: now stays on screen, short of the edge. FullCalendar
953
+ * behaves the same.
954
+ *
955
+ * Neither FullCalendar nor RFC 5545 defines this. FullCalendar's timeline
956
+ * opens on the range start plus `scrollTime`, and its users reach today by
957
+ * setting `scrollTime` themselves; this is that, done for them.
958
+ *
959
+ * @default false
960
+ */
961
+ scrollToNow?: boolean;
962
+ /**
892
963
  * Optional plugins that add behavior/UI (e.g. recurrence). The core ships
893
964
  * with no plugins by default — pass `recurrencePlugin()` to enable recurring
894
965
  * events.
@@ -902,7 +973,7 @@ interface IlamyCalendarProps {
902
973
  */
903
974
  resources?: Resource[];
904
975
  /** Custom render function for resource header cells. */
905
- renderResource?: (resource: Resource) => React3.ReactNode;
976
+ renderResource?: (resource: Resource) => ReactNode4;
906
977
  /**
907
978
  * How resources are arranged. Only applies when `resources` is set.
908
979
  * - "horizontal": resources are rows, time is columns (default)
@@ -917,8 +988,8 @@ interface IlamyCalendarProps {
917
988
  */
918
989
  weekViewGranularity?: "hourly" | "daily";
919
990
  }
920
- declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
921
- import React5 from "react";
991
+ declare const IlamyCalendar: React3.FC<IlamyCalendarProps>;
992
+ import React4 from "react";
922
993
  /**
923
994
  * @deprecated Since v2.0 `IlamyCalendar` accepts `resources`, `renderResource`,
924
995
  * `orientation`, and `weekViewGranularity` directly — use it instead. This
@@ -926,8 +997,8 @@ import React5 from "react";
926
997
  */
927
998
  type IlamyResourceCalendarProps = IlamyCalendarProps;
928
999
  /** @deprecated Since v2.0 — use `IlamyCalendar` with the `resources` prop. */
929
- declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
930
- import React6 from "react";
1000
+ declare const IlamyResourceCalendar: React4.FC<IlamyResourceCalendarProps>;
1001
+ import React5 from "react";
931
1002
  /**
932
1003
  * The public calendar API surface exposed by useIlamyCalendarContext() — for consumers and plugin
933
1004
  * components. The full internal context is intentionally not exported.
@@ -969,7 +1040,7 @@ interface IlamyCalendarApi {
969
1040
  * plugin views (e.g. agenda) render the indicator consistently with the
970
1041
  * built-in views via the shared `@ilamy/ui` CurrentTimeIndicator.
971
1042
  */
972
- readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React6.ReactNode;
1043
+ readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React5.ReactNode;
973
1044
  /**
974
1045
  * Events whose resource membership (`resourceIds`, falling back to
975
1046
  * `resourceId`) contains the given resource. On a calendar without
@@ -985,7 +1056,7 @@ interface IlamyCalendarApi {
985
1056
  readonly applyScopedEdit: (event: CalendarEvent, updates: Partial<CalendarEvent>, scope: unknown) => void;
986
1057
  readonly applyScopedDelete: (event: CalendarEvent, scope: unknown) => void;
987
1058
  readonly getEventManager: (event: CalendarEvent) => IlamyPlugin | undefined;
988
- readonly renderSlot: (slotName: string, context: unknown) => React6.ReactNode[];
1059
+ readonly renderSlot: (slotName: string, context: unknown) => React5.ReactNode[];
989
1060
  readonly collect: (point: string, context: unknown) => unknown[];
990
1061
  readonly getViews: () => PluginView[];
991
1062
  }
@@ -994,4 +1065,4 @@ interface IlamyCalendarApi {
994
1065
  * Returns a limited set of commonly used properties and methods.
995
1066
  */
996
1067
  declare function useIlamyCalendarContext(): IlamyCalendarApi;
997
- 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 };
1068
+ 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-4jynmg6d.js";import{r,Q,i,l,s,O,o,L,z,B,P,q,I,_,E,k,H,G,W,T,U,X,Y,M}from"./shared/chunk-79d4xe20.js";import{e,Z}from"./shared/chunk-d7599sry.js";import{b,R,x,A,w,V}from"./shared/chunk-n7xt0j3a.js";import{n,y,m,a,g,v,C,D,p}from"./shared/chunk-4yfcvykw.js";import{c,f}from"./shared/chunk-w4nsrq2y.js";var Lt="event-form",Yt="event-mutation-scope",_t=({event:d,onChange:u})=>r((S)=>S.renderSlot)(Lt,{event:d,onChange:u}),Je=({dialog:d,onResolve:u,onCancel:h})=>{let S=r((K)=>K.getEventManager);if(!(d.isOpen&&d.event))return null;let N=S(d.event),F={event:d.event,operation:d.operation,resolve:u,cancel:h};return N?.renderSlot?.(Yt,F)};import{useEffect as ca,useMemo as ma}from"react";import{DndContext as Mo,MouseSensor as Ho,pointerWithin as Vo,TouchSensor as Io,useSensor as Wt,useSensors as Oo}from"@dnd-kit/core";import{useId as Ao,useRef as Kt}from"react";import{useCallback as et,useEffect as xo,useRef as So,useState as wo}from"react";var yt={isOpen:!1,operation:"edit",event:null};function tt(d){let{applyScopedEdit:u,applyScopedDelete:h}=r((ee)=>({applyScopedEdit:ee.applyScopedEdit,applyScopedDelete:ee.applyScopedDelete})),[S,N]=wo(yt),F=So(S);xo(()=>{F.current=S},[S]);let K=et((ee,te)=>{N({isOpen:!0,operation:"edit",event:ee,updates:te})},[]),j=et((ee)=>{N({isOpen:!0,operation:"delete",event:ee})},[]),J=et(()=>N(yt),[]),re=et((ee)=>{let te=F.current;if(!te.event)return;if(te.operation==="edit")u(te.event,te.updates??{},ee);else h(te.event,ee);N(yt),d?.()},[u,h,d]);return{dialogState:S,openEditDialog:K,openDeleteDialog:j,closeDialog:J,handleConfirm:re}}var Po=(d,u,h)=>{if(h===void 0||u===h)return{};if(!d.resourceIds)return{resourceId:h};let N=d.resourceIds.indexOf(u);if(N===-1)return{};let F=d.resourceIds.slice();if(F.splice(N,1),!F.includes(h))F.push(h);return{resourceIds:F}},jt=(d,u)=>{let{active:h,over:S}=d;if(!h||!S||!u)return null;let N=S.data.current||{},F=N.type==="time-cell",{resourceId:K,allDay:j}=N,J;if(F){let{date:ie,hour:se=0,minute:de=0}=N;J=t(ie).hour(se).minute(de)}else{let{date:ie}=N;J=t(ie)}let re=u.end.diff(u.start,"second"),ee=J.add(re,"second"),te=h.data.current?.sourceResourceId,oe={start:J,end:ee,...Po(u,te,K),allDay:F?!1:j??u.allDay};return{activeEvent:u,updates:oe}};import{DragOverlay as No}from"@dnd-kit/core";import{snapCenterToCursor as To}from"@dnd-kit/modifiers";import{useImperativeHandle as Ro,useState as ko}from"react";import{jsx as $t}from"react/jsx-runtime";var Ut=({ref:d})=>{let[u,h]=ko(null);return Ro(d,()=>({setActiveEvent:h})),$t(No,{modifiers:[To],children:u&&$t("div",{className:e("cursor-grab truncate rounded bg-amber-200 p-2 text-[10px] shadow-lg sm:text-xs w-20",u.backgroundColor||"bg-blue-500",u.color||"text-white"),children:u?.title})})};import{jsx as Zt,jsxs as qt,Fragment as Fo}from"react/jsx-runtime";function Xt({children:d}){let u=Ao(),h=Kt(null),S=Kt(null),{updateEvent:N,getEventManager:F,disableDragAndDrop:K}=r((le)=>({updateEvent:le.updateEvent,getEventManager:le.getEventManager,disableDragAndDrop:le.disableDragAndDrop})),{dialogState:j,openEditDialog:J,closeDialog:re,handleConfirm:ee}=tt(),te=Wt(Ho,{activationConstraint:{distance:2}}),oe=Wt(Io,{activationConstraint:{delay:100,tolerance:5}}),ie=Oo(te,oe),se=(le,pe)=>{let ce=!pe||Object.keys(pe).length===0;if(!le?.id||ce)return;if(F(le)?.applyEdit)J(le,pe);else N(le.id,pe)},de=(le)=>{let{active:pe}=le;if(pe.data.current?.type==="calendar-event")S.current?.setActiveEvent(pe.data.current.event),h.current=pe.data.current.event},ae=(le)=>{let pe=jt(le,h.current);if(pe){let{activeEvent:ce,updates:Se}=pe;se(ce,Se)}h.current=null,S.current?.setActiveEvent(null)},ue=(le)=>{h.current=null};if(K)return d;return qt(Fo,{children:[qt(Mo,{collisionDetection:Vo,id:u,onDragCancel:ue,onDragEnd:ae,onDragStart:de,sensors:ie,children:[d,Zt(Ut,{ref:S})]}),Zt(Je,{dialog:j,onCancel:re,onResolve:ee})]})}import{ChevronDownIcon as zo}from"lucide-react";import{useEffect as Go,useState as Bo}from"react";import*as Ee from"@radix-ui/react-popover";import{jsx as rt}from"react/jsx-runtime";function Pe({...d}){return rt(Ee.Root,{"data-slot":"popover",...d})}function Ne({...d}){return rt(Ee.Trigger,{"data-slot":"popover-trigger",...d})}function Te({className:d,align:u="center",sideOffset:h=4,...S}){return rt(Ee.Portal,{children:rt(Ee.Content,{align:u,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",d),"data-slot":"popover-content",sideOffset:h,...S})})}import{jsx as Re,jsxs as $e}from"react/jsx-runtime";var Qt=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ht=(d)=>Boolean(d&&Qt.test(d)),Lo=(d)=>{let u=d.match(/bg-([a-z]+)-\d+/)?.at(1);if(!u)return"Custom";return u.charAt(0).toUpperCase()+u.slice(1)};function Jt({value:d,onChange:u,swatches:h=[],className:S,"aria-label":N="Select color"}){let[F,K]=Bo(ht(d)?d:"");Go(()=>{K(ht(d)?d:"")},[d]);let j=(te)=>{let oe=te.target.value;if(K(oe),Qt.test(oe))u(oe)},J=ht(d),re=h.find((te)=>te.value===d),ee;if(re)ee=re.label;else if(J)ee=d;else if(d)ee=Lo(d);else ee="Pick a color";return $e(Pe,{children:[$e(Ne,{"aria-label":N,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]",S),"data-slot":"color-picker-trigger",type:"button",children:[$e("span",{className:"flex items-center gap-2",children:[Re("span",{className:e("size-5 shrink-0 rounded-full border",!J&&d),style:J?{backgroundColor:d}:void 0}),Re("span",{className:e(J&&"font-mono text-xs"),children:ee})]}),Re(zo,{className:"size-4 shrink-0 opacity-50"})]}),$e(Te,{className:"w-56","data-slot":"color-picker-content",children:[h.length>0&&Re("div",{className:"grid grid-cols-7 gap-1.5",children:h.map((te)=>{let oe=d===te.value;return Re("button",{"aria-label":te.label,"aria-pressed":oe,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",te.value,oe&&"ring-ring ring-2 ring-offset-1"),onClick:()=>u(te.value),type:"button"},te.value)})}),Re("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),$e("div",{className:"flex items-center gap-2",children:[Re("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(te)=>u(te.target.value),type:"color",value:J?d:"#000000"}),Re(m,{"aria-label":"Hex color",className:"font-mono",onChange:j,placeholder:"#000000",value:F})]})]})]})}import{jsx as Yo}from"react/jsx-runtime";function er({className:d,...u}){return Yo("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",d),"data-slot":"textarea",...u})}import{useEffect as an,useState as Ce}from"react";import{PopoverClose as qo}from"@radix-ui/react-popover";import{Calendar as Xo}from"lucide-react";import{useEffect as Qo,useRef as Jo,useState as en}from"react";import{useState as Uo}from"react";import{ChevronLeftIcon as _o,ChevronRightIcon as jo}from"lucide-react";import{jsx as Ue,jsxs as $o}from"react/jsx-runtime";function Fe({label:d,onPrev:u,onNext:h,prevLabel:S,nextLabel:N}){return $o("div",{className:"mb-2 flex items-center justify-between",children:[Ue(n,{"aria-label":S,onClick:u,size:"icon",variant:"ghost",children:Ue(_o,{className:"size-4"})}),Ue("div",{className:"text-sm font-medium select-none",children:d}),Ue(n,{"aria-label":N,onClick:h,size:"icon",variant:"ghost",children:Ue(jo,{className:"size-4"})})]})}import{jsx as xe,jsxs as tr}from"react/jsx-runtime";function Wo(d){let u=d.weekHover&&!d.isCurrentWeek;return e("p-0 text-center",d.weekHover&&"first:rounded-l-md last:rounded-r-md",u&&"group-hover/week:bg-accent",d.isCurrentWeek&&"bg-primary")}function Ko(d){return e("w-full aspect-square text-sm select-none",!d.isDisabled&&"cursor-pointer",!(d.weekHover||d.isDisabled)&&"hover:bg-accent rounded-md",d.isOutside&&"text-muted-foreground/50",d.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",d.isCurrentWeek&&"text-primary-foreground font-medium",d.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",d.isDisabled&&"opacity-50 cursor-not-allowed")}function Zo({day:d,state:u,onSelect:h}){return xe("td",{className:Wo(u),"data-disabled":u.isDisabled,"data-outside":u.isOutside,"data-selected":u.isSelected,role:"gridcell",tabIndex:-1,children:xe("button",{"aria-disabled":u.isDisabled,"aria-hidden":u.isOutside,className:Ko(u),"data-disabled":u.isDisabled,"data-selected":u.isSelected,disabled:u.isDisabled||u.isOutside,onClick:()=>h?.(d.toDate()),tabIndex:u.isOutside?-1:0,type:"button",children:d.format("D")})})}function We({selected:d,defaultMonth:u,onSelect:h,disabled:S,firstDayOfWeek:N=0,className:F,weekHover:K=!1,highlightedWeekOf:j}){let[J,re]=Uo(()=>t(u??d??new Date).startOf("month")),ee=O(J,N),te=d?t(d).format("YYYY-MM-DD"):void 0,oe=s(t(),N).map((ae)=>ae.format("dd")),ie,se;if(j){let ae=s(j,N);ie=ae.at(0),se=ae.at(-1)}let de=(ae)=>{let ue=ae.format("YYYY-MM-DD")===te,le=!1;if(ie&&se){let pe=!ae.isBefore(ie,"day"),ce=!ae.isAfter(se,"day");le=pe&&ce}return{isOutside:!ae.isSame(J,"month"),isSelected:ue,isDisabled:S?.(ae.toDate())??!1,isCurrent:l(ae)&&!ue,isCurrentWeek:le,weekHover:K}};return tr("div",{className:e("bg-background p-3 w-72",F),"data-slot":"calendar",children:[xe(Fe,{label:J.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>re((ae)=>ae.add(1,"month")),onPrev:()=>re((ae)=>ae.subtract(1,"month")),prevLabel:"Previous month"}),tr("table",{className:"w-full border-collapse",role:"grid",children:[xe("thead",{children:xe("tr",{children:oe.map((ae,ue)=>xe("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:ae},ue))})}),xe("tbody",{children:ee.map((ae,ue)=>xe("tr",{className:e(K&&"group/week"),children:ae.map((le)=>xe(Zo,{day:le,onSelect:h,state:de(le)},le.toISOString()))},ue))})]})]})}import{jsx as ze,jsxs as Ct}from"react/jsx-runtime";function rr({date:d,closeOnSelect:u,onChange:h,label:S="Pick a date",className:N,disabled:F}){let K=r((te)=>te.firstDayOfWeek),j=Jo(null),[J,re]=en(d);Qo(()=>{re(d)},[d]);let ee=(te)=>{if(re(te),u)j.current?.click();h?.(te)};return ze("div",{className:N,children:Ct(Pe,{children:[ze(Ne,{asChild:!0,children:Ct(n,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!d,variant:"outline",children:[ze(Xo,{}),J?t(J).format("ll"):ze("span",{children:S})]})}),Ct(Te,{align:"start",className:"w-auto p-0",children:[ze(qo,{ref:j,style:{display:"none"}}),ze(We,{defaultMonth:J,disabled:F,firstDayOfWeek:K,onSelect:ee,selected:J})]})]})})}import{Clock as rn}from"lucide-react";import{useEffect as on,useRef as nr,useState as Dt}from"react";import{useMemo as tn}from"react";function or({timeFormat:d="12-hour",minTime:u="00:00",maxTime:h="23:45"}){return{timeOptions:tn(()=>{let F=[],[K,j]=u.split(":").map(Number),[J,re]=h.split(":").map(Number),ee=K*60+j,te=J*60+re;for(let oe=ee;oe<=te;oe+=15){let ie=Math.floor(oe/60),se=oe%60,de=`${ie.toString().padStart(2,"0")}:${se.toString().padStart(2,"0")}`;F.push(de)}return F},[u,h]),formatTime:(F)=>{let[K,j]=F.split(":").map(Number);if(d==="24-hour")return`${K.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`;let J=K>=12?"PM":"AM",re=K;if(K===0)re=12;else if(K>12)re=K-12;return`${re}:${j.toString().padStart(2,"0")} ${J}`}}}import{jsx as ke,jsxs as bt}from"react/jsx-runtime";var nn=(d)=>{d.stopPropagation()};function ar({value:d,onChange:u,minTime:h="00:00",maxTime:S="23:45",timeFormat:N="12-hour",placeholder:F="Select time...",className:K,disabled:j=!1,name:J}){let[re,ee]=Dt(!1),[te,oe]=Dt(""),ie=nr(null),se=nr(null),[de,ae]=Dt(0),{timeOptions:ue,formatTime:le}=or({timeFormat:N,minTime:h,maxTime:S}),pe=ue.filter((ve)=>le(ve).toLowerCase().includes(te.toLowerCase())),ce=(ve)=>{u(ve),ee(!1),oe("")};on(()=>{if(re){if(se.current)ae(se.current.offsetWidth);setTimeout(()=>{ie.current?.focus()},0)}},[re]);let Se=d?le(d):F;return bt(Pe,{onOpenChange:ee,open:re,children:[ke(Ne,{asChild:!0,children:bt(n,{"aria-controls":"time-picker-listbox","aria-expanded":re,className:e("w-full justify-start",K),"data-testid":o.timePicker(J),disabled:j,ref:se,role:"combobox",variant:"outline",children:[ke(rn,{className:"mr-2 h-4 w-4"}),Se]})}),bt(Te,{align:"start",className:"p-0",style:{width:de},children:[ke("div",{className:"p-2 border-b",children:ke(m,{className:"h-8",onChange:(ve)=>oe(ve.target.value),placeholder:"Search time...",ref:ie,value:te})}),ke(c,{className:"h-[200px]",onWheel:nn,children:ke("div",{className:"p-1",children:pe.length===0?ke("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):pe.map((ve)=>{let qe=le(ve);return ke("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",ve===d&&"bg-accent text-accent-foreground"),onClick:()=>ce(ve),type:"button",children:qe},ve)})})})]})]})}var ir=(d,u)=>{let[h,S]=u.split(":").map(Number);return t(d).hour(h).minute(S).second(0).millisecond(0)},sr=(d,u,h)=>{let S=ir(d,u);return h?S.hour(0).minute(0):S},lr=(d,u,h)=>{let S=ir(d,u);return h?S.add(1,"day").startOf("day"):S},Et=(d,u)=>{if(!u)return{min:"00:00",max:"23:59"};let h=t(d),{minStart:S,maxEnd:N,hasBusinessHours:F}=_({allDates:[h],businessHours:u,hideNonBusinessHours:!1});if(!F)return{min:"00:00",max:"23:59"};return{min:`${S.toString().padStart(2,"0")}:00`,max:`${(N-1).toString().padStart(2,"0")}:45`}};import{jsx as me,jsxs as ye,Fragment as mn}from"react/jsx-runtime";var dr="bg-blue-100 text-blue-800",sn=[{value:dr,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"}],cr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ln=(d,u)=>{if(d&&cr.test(d))return d;return u??dr},dn=(d)=>{if(cr.test(d))return{backgroundColor:d,color:Z(d)};return{backgroundColor:void 0,color:d}},cn=({colorChanged:d,hadInitialColor:u,selectedColor:h,initialBackgroundColor:S,initialColor:N})=>{if(d||!u)return dn(h);return{backgroundColor:S,color:N}},xt=({name:d,label:u,placeholder:h,value:S,required:N=!1,multiline:F=!1,onChange:K})=>ye("div",{className:"grid gap-1 sm:gap-2",children:[me(a,{className:"text-xs sm:text-sm",htmlFor:d,children:u}),F?me(er,{className:"min-h-16 text-sm",id:d,name:d,onChange:K,placeholder:h,required:N,value:S}):me(m,{className:"h-8 text-sm sm:h-9",id:d,name:d,onChange:K,placeholder:h,required:N,value:S})]}),mr=({selectedEvent:d,onClose:u,onUpdate:h,onDelete:S,onAdd:N})=>{let{dialogState:F,openEditDialog:K,openDeleteDialog:j,closeDialog:J,handleConfirm:re}=tt(u),{t:ee,timeFormat:te,getEventManager:oe,resources:ie}=r((ne)=>({t:ne.t,timeFormat:ne.timeFormat,getEventManager:ne.getEventManager,resources:ne.resources??[]})),{id:se,resourceId:de,resourceIds:ae,start:ue=t(),end:le=t().add(1,"hour"),allDay:pe=!1,color:ce,backgroundColor:Se,title:ve="",description:qe="",location:Ht=""}=d??{},Vt=ie.length>0,It=de??ae?.at(0),Ot=Vt&&It===void 0,[dt,qr]=Ce(It),ct=Vt?dt:de,Xe=L(ct),At=Boolean(d&&oe(d)),Xr=le.isSame(le.startOf("day")),Qr=pe&&Xr?le.subtract(1,"day"):le,[Ve,Ft]=Ce(ue.toDate()),[Ae,mt]=Ce(Qr.toDate()),[we,Jr]=Ce(pe),[ut,eo]=Ce(ln(Se,ce)),[to,ro]=Ce(!1),oo=Boolean(ce||Se),no=(ne)=>{eo(ne),ro(!0)},[pt,zt]=Ce(ue.format("HH:mm")),[Qe,ft]=Ce(le.format("HH:mm")),[be,ao]=Ce({title:ve,description:qe,location:Ht}),[gt,io]=Ce({}),so={...d,...gt},lo=(ne)=>io((fe)=>({...fe,...ne})),co=(ne)=>{if(!ne)return;if(Ft(ne),t(ne).isAfter(t(Ae)))mt(ne)},mo=(ne)=>{if(!ne)return;if(mt(ne),ne&&t(ne).isBefore(t(Ve)))Ft(ne)},uo=(ne)=>{if(Jr(ne),!(ne&&Qe==="00:00"))return;mt((fe)=>t(fe).isAfter(t(Ve),"day")?t(fe).subtract(1,"day").toDate():fe)},po=(ne)=>{if(zt(ne),t(Ve).isSame(t(Ae),"day")&&ne>Qe)ft(ne)},fo=(ne)=>{if(ft(ne),t(Ve).isSame(t(Ae),"day")&&ne<pt)zt(ne)},vt=(ne)=>{let{name:fe,value:he}=ne.target;ao((_e)=>({..._e,[fe]:he}))};an(()=>{if(we)ft("23:59")},[we]);let go=(ne)=>ie.find((he)=>String(he.id)===ne)?.id??ne,Gt=Ot&&dt===void 0,vo=(ne)=>{if(ne.preventDefault(),Gt)return;let fe=sr(Ve,pt,we),he=lr(Ae,Qe,we),_e=cn({colorChanged:to,hadInitialColor:oo,selectedColor:ut,initialBackgroundColor:Se,initialColor:ce}),je={id:se||t().format("YYYYMMDDHHmmss"),title:be.title,start:fe,end:he,resourceId:ct,description:be.description,location:be.location,allDay:we,..._e,...gt};if(d?.id&&At){K(d,{title:be.title,start:fe,end:he,resourceId:ct,description:be.description,location:be.location,allDay:we,color:ut,...gt});return}if(se)h?.(je);else N?.(je);u()},yo=()=>{if(!d?.id)return;if(At){j(d);return}S?.(d),u()},Bt;if(Xe)Bt=(ne)=>!I(t(ne),Xe);let ho=Et(Ve,Xe),Co=Et(Ae,Xe),Do=[["startDate",Ve,co],["endDate",Ae,mo]],bo=[["startTime","start-time",pt,po,ho],["endTime","end-time",Qe,fo,Co]],Eo=dt?.toString();return ye(mn,{children:[ye("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:vo,children:[me(c,{className:"flex-1 min-h-0",children:ye("div",{className:"grid gap-3 sm:gap-4 p-1",children:[me(xt,{label:ee("title"),name:"title",onChange:vt,placeholder:ee("eventTitlePlaceholder"),required:!0,value:be.title}),me(xt,{label:ee("description"),multiline:!0,name:"description",onChange:vt,placeholder:ee("eventDescriptionPlaceholder"),value:be.description}),Ot&&ye("div",{className:"grid gap-1 sm:gap-2",children:[me(a,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ee("resource")}),ye(g,{onValueChange:(ne)=>qr(go(ne)),value:Eo,children:[me(C,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:me(v,{placeholder:ee("selectResource")})}),me(D,{children:ie.map((ne)=>me(p,{value:String(ne.id),children:ne.title},String(ne.id)))})]})]}),ye("div",{className:"flex items-center space-x-2",children:[me(y,{checked:we,id:"allDay",onCheckedChange:(ne)=>uo(ne===!0)}),me(a,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ee("allDay")})]}),me("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Do.map(([ne,fe,he])=>ye("div",{children:[me(a,{className:"text-xs sm:text-sm",children:ee(ne)}),me(rr,{className:"mt-1",closeOnSelect:!0,date:fe,disabled:Bt,onChange:he})]},ne))}),!we&&me("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:bo.map(([ne,fe,he,_e,je])=>ye("div",{children:[me(a,{className:"text-xs sm:text-sm",children:ee(ne)}),me(ar,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:je.max,minTime:je.min,name:fe,onChange:_e,placeholder:ee("searchTime"),timeFormat:te,value:he})]},ne))}),ye("div",{className:"grid gap-1 sm:gap-2",children:[me(a,{className:"text-xs sm:text-sm",children:ee("color")}),me(Jt,{"aria-label":ee("color"),onChange:no,swatches:sn,value:ut})]}),me(xt,{label:ee("location"),name:"location",onChange:vt,placeholder:ee("eventLocationPlaceholder"),value:be.location}),me(_t,{event:so,onChange:lo})]})}),ye(A,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[se&&me(n,{className:"w-full sm:mr-auto sm:w-auto",onClick:yo,size:"sm",type:"button",variant:"destructive",children:ee("delete")}),ye("div",{className:"flex w-full gap-2 sm:w-auto",children:[me(n,{className:"flex-1 sm:flex-none",onClick:u,size:"sm",type:"button",variant:"outline",children:ee("cancel")}),me(n,{className:"flex-1 sm:flex-none",disabled:Gt,size:"sm",type:"submit",children:se?ee("update"):ee("create")})]})]})]}),me(Je,{dialog:F,onCancel:J,onResolve:re})]})};import{jsx as ot,jsxs as ur}from"react/jsx-runtime";var pr=()=>{let{t:d,selectedEvent:u,isEventFormOpen:h,closeEventForm:S,addEvent:N,updateEvent:F,deleteEvent:K,renderEventForm:j}=r((te)=>({t:te.t,selectedEvent:te.selectedEvent,isEventFormOpen:te.isEventFormOpen,closeEventForm:te.closeEventForm,addEvent:te.addEvent,updateEvent:te.updateEvent,deleteEvent:te.deleteEvent,renderEventForm:te.renderEventForm})),ee={open:h,onClose:S,selectedEvent:u,onAdd:N,onUpdate:(te)=>{F(te.id,te)},onDelete:(te)=>{K(te.id)}};if(j)return j(ee);return ot(b,{onOpenChange:S,open:h,children:ur(R,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[ur(x,{className:"mb-2 sm:mb-4 shrink-0",children:[ot(w,{className:"text-base sm:text-lg",children:u?.id?d("editEvent"):d("createEvent")}),ot(V,{className:"text-xs sm:text-sm",children:u?.id?d("editEventDetails"):d("addNewEvent")})]}),ot(mr,{...ee})]})})};import{ChevronLeft as Mn,ChevronRight as Hn,Download as Vn,Plus as In}from"lucide-react";import{ChevronDown as yn}from"lucide-react";import{useState as hn}from"react";function fr(){let{currentLocale:d,timezone:u}=r((S)=>({currentLocale:S.currentLocale,timezone:S.timezone}));return{formatDateRange:(S,N)=>{let F=new Intl.DateTimeFormat(d,{timeZone:u,month:"short",day:"numeric"});if(S.year()===N.year())return F.formatRange(S.toDate(),N.toDate());return`${F.format(S.toDate())} – ${F.format(N.toDate())}`}}}import{useState as pn}from"react";import{jsx as un}from"react/jsx-runtime";function nt({label:d,isSelected:u,isCurrent:h,onSelect:S}){return un("button",{"aria-pressed":u,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",h&&"ring-1 ring-inset ring-foreground/40",u&&"bg-primary text-primary-foreground"),onClick:S,type:"button",children:d})}import{jsx as St,jsxs as fn}from"react/jsx-runtime";function gr({selected:d,onSelect:u}){let[h,S]=pn(()=>d.year()),N=t(),F=Array.from({length:12},(K,j)=>({index:j,label:d.month(j).format("MMM")}));return fn("div",{className:"w-72 p-3","data-slot":"month-grid",children:[St(Fe,{label:h,nextLabel:"Next year",onNext:()=>S((K)=>K+1),onPrev:()=>S((K)=>K-1),prevLabel:"Previous year"}),St("div",{className:"grid grid-cols-3 gap-1",children:F.map((K)=>{let j=h===d.year()&&K.index===d.month(),J=h===N.year()&&K.index===N.month()&&!j;return St(nt,{isCurrent:J,isSelected:j,label:K.label,onSelect:()=>u(d.year(h).month(K.index).date(1))},K.index)})})]})}import{useState as gn}from"react";import{jsx as wt,jsxs as vn}from"react/jsx-runtime";var Ke=12;function vr({selected:d,onSelect:u}){let[h,S]=gn(()=>d.year()-d.year()%Ke),N=t(),F=Array.from({length:Ke},(K,j)=>h+j);return vn("div",{className:"w-72 p-3","data-slot":"year-grid",children:[wt(Fe,{label:`${h} – ${h+Ke-1}`,nextLabel:"Next years",onNext:()=>S((K)=>K+Ke),onPrev:()=>S((K)=>K-Ke),prevLabel:"Previous years"}),wt("div",{className:"grid grid-cols-3 gap-1",children:F.map((K)=>{let j=K===d.year(),J=K===N.year()&&!j;return wt(nt,{isCurrent:J,isSelected:j,label:K,onSelect:()=>u(d.year(K))},K)})})]})}import{jsx as Ie,jsxs as yr}from"react/jsx-runtime";var Cn={day:"day",week:"week",month:"month",year:"year"};function Dn(d){let u=d?.navigationStep??{amount:1,unit:d?.navigationUnit??"day"};if(u.amount!==1)return"range";return Cn[u.unit]??"range"}function hr({className:d}){let{currentDate:u,currentRange:h,view:S,selectDate:N,firstDayOfWeek:F,getViews:K}=r((ce)=>({currentDate:ce.currentDate,currentRange:ce.currentRange,view:ce.view,selectDate:ce.selectDate,firstDayOfWeek:ce.firstDayOfWeek,getViews:ce.getViews})),{formatDateRange:j}=fr(),[J,re]=hn(!1),ee=s(u,F),te=ee.at(0)??u,oe=ee.at(-1)??u,ie=(ce)=>{N(ce),re(!1)},se=Dn(K().find((ce)=>ce.name===S)),ae={year:u.format("YYYY"),month:u.format("MMM YYYY"),week:j(te,oe),day:u.format("ddd, MMM D, YYYY"),range:j(h.start,h.end)}[se],ue=Ie(We,{defaultMonth:u.toDate(),firstDayOfWeek:F,onSelect:(ce)=>ce&&ie(t(ce)),selected:u.toDate()}),pe={year:Ie(vr,{onSelect:ie,selected:u}),month:Ie(gr,{onSelect:ie,selected:u}),week:Ie(We,{defaultMonth:u.toDate(),firstDayOfWeek:F,highlightedWeekOf:u,onSelect:(ce)=>ce&&ie(t(ce)),weekHover:!0}),day:ue,range:ue}[se];return yr(Pe,{onOpenChange:re,open:J,children:[Ie(Ne,{asChild:!0,children:yr(n,{className:e("font-semibold",d),"data-testid":"calendar-title",variant:"outline",children:[ae,Ie(yn,{className:"size-4 shrink-0 opacity-50"})]})}),Ie(Te,{align:"start",className:"w-auto p-0",children:pe})]})}var Pt=`\r
2
- `,bn=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Pt),at=(d)=>d.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
- `,"\\n").replaceAll("\r",""),Cr=(d,u=!1)=>{if(u)return d.format("YYYYMMDD");return d.utc().format("YYYYMMDD[T]HHmmss[Z]")},En=(d)=>d.uid||`${d.id}@ilamy.calendar`,xn=(d,u)=>{let h=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),S=d.allDay?";VALUE=DATE":"",N=["BEGIN:VEVENT",`UID:${En(d)}`,`DTSTART${S}:${Cr(d.start,d.allDay)}`,`DTEND${S}:${Cr(d.end,d.allDay)}`,`SUMMARY:${at(d.title)}`,d.description&&`DESCRIPTION:${at(d.description)}`,d.location&&`LOCATION:${at(d.location)}`].filter(Boolean),F=u("ical:vevent-properties",d).filter((j)=>typeof j==="string"),K=[`DTSTAMP:${h}`,`CREATED:${h}`,`LAST-MODIFIED:${h}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...N,...F,...K].join(Pt)},Sn=(d,u,h="ilamy Calendar")=>{let S=at(h),N=d.map((F)=>xn(F,u));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${S}`,`X-WR-CALDESC:Exported from ${S}`,bn,...N,"END:VCALENDAR"].join(Pt)},Dr=(d,u,h="calendar.ics",S="ilamy Calendar")=>{let N=new Blob([Sn(d,u,S)],{type:"text/calendar;charset=utf-8"}),F=URL.createObjectURL(N),K=h;if(!h.endsWith(".ics"))K=`${h}.ics`;let j=document.createElement("a");j.href=F,j.download=K,document.body.append(j),j.click(),j.remove(),URL.revokeObjectURL(F)};function br(){let{rawEvents:d,collect:u}=r((h)=>({rawEvents:h.rawEvents,collect:h.collect}));return()=>{let h=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Dr(d,u,h,"ilamy Calendar")}}import*as De from"@radix-ui/react-dropdown-menu";import{jsx as Ze}from"react/jsx-runtime";function Er({...d}){return Ze(De.Root,{"data-slot":"dropdown-menu",...d})}function xr({...d}){return Ze(De.Trigger,{"data-slot":"dropdown-menu-trigger",...d})}function Sr({className:d,sideOffset:u=4,align:h="end",...S}){return Ze(De.Portal,{children:Ze(De.Content,{align:h,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",d),"data-slot":"dropdown-menu-content",sideOffset:u,...S})})}function wr({className:d,...u}){return Ze(De.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",d),"data-slot":"dropdown-menu-item",...u})}import{Check as wn,ChevronDown as Pn}from"lucide-react";function it(){let{getViews:d,resources:u}=r((S)=>({getViews:S.getViews,resources:S.resources})),h=Boolean(u?.length);return d().filter((S)=>!h||S.supportsResources)}import{jsx as Me,jsxs as Nt}from"react/jsx-runtime";function Pr({className:d}){let{view:u,setView:h,t:S}=r((J)=>({view:J.view,setView:J.setView,t:J.t})),N=it(),F=N.find((J)=>J.name===u),K=F?S(F.label??F.name):"",j=F?.icon;return Nt(Er,{children:[Me(xr,{asChild:!0,className:d,children:Nt(n,{size:"default",variant:"outline",children:[j&&Me(j,{className:"size-4"}),Me("span",{children:K}),Me(Pn,{className:"size-4 opacity-50"})]})}),Me(Sr,{align:"end",className:"min-w-40",children:N.map((J)=>{let re=J.icon;return Nt(wr,{onSelect:()=>h(J.name),children:[Me(re,{className:"size-4"}),Me("span",{className:"flex-1",children:S(J.label??J.name)}),J.name===u&&Me(wn,{className:"size-4"})]},J.name)})})]})}import*as st from"@radix-ui/react-toggle-group";import{cva as Nn}from"class-variance-authority";import{createContext as Tn,useContext as Rn}from"react";import{jsx as Tt}from"react/jsx-runtime";var kn=Nn("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"}}),Nr=Tn({size:"default",variant:"default"});function Tr({className:d,variant:u,size:h,children:S,...N}){return Tt(st.Root,{className:e("flex items-center justify-center gap-1",d),"data-slot":"toggle-group",...N,children:Tt(Nr.Provider,{value:{variant:u,size:h},children:S})})}function Rr({className:d,children:u,variant:h,size:S,...N}){let F=Rn(Nr);return Tt(st.Item,{className:e(kn({variant:F.variant||h,size:F.size||S}),d),"data-slot":"toggle-group-item",...N,children:u})}import{jsx as kr}from"react/jsx-runtime";function Mr({className:d}){let{view:u,setView:h,t:S}=r((F)=>({view:F.view,setView:F.setView,t:F.t})),N=it();return kr(Tr,{className:e("bg-muted gap-0 rounded-lg p-0.75",d),onValueChange:(F)=>F&&h(F),size:"sm",type:"single",value:u,children:N.map((F)=>kr(Rr,{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:F.name,children:S(F.label??F.name)},F.name))})}import{jsx as ge,jsxs as Ge}from"react/jsx-runtime";var Hr=({className:d=""})=>{let{nextPeriod:u,prevPeriod:h,today:S,openEventForm:N,headerComponent:F,headerClassName:K,t:j,hideExportButton:J}=r((ee)=>({nextPeriod:ee.nextPeriod,prevPeriod:ee.prevPeriod,today:ee.today,openEventForm:ee.openEventForm,headerComponent:ee.headerComponent,headerClassName:ee.headerClassName,t:ee.t,hideExportButton:ee.hideExportButton})),re=br();if(F)return F;return ge("div",{className:e("@container/base-header w-full",K),"data-testid":"calendar-header",children:Ge("div",{className:e("flex flex-col items-center gap-2 @lg/base-header:flex-row @lg/base-header:justify-between",d),children:[Ge("div",{className:"flex min-w-0 items-center gap-2",children:[Ge("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[ge(n,{"aria-label":j("previous"),className:"h-full",onClick:h,size:"icon",variant:"ghost",children:ge(Mn,{className:"size-4"})}),ge(n,{"aria-label":j("next"),className:"h-full",onClick:u,size:"icon",variant:"ghost",children:ge(Hn,{className:"size-4"})})]}),ge(n,{onClick:S,size:"default",variant:"outline",children:j("today")}),ge(hr,{})]}),Ge("div",{className:"flex items-center gap-2",children:[ge(Mr,{className:"hidden @3xl/base-header:flex"}),ge(Pr,{className:"@3xl/base-header:hidden"}),!J&&Ge(n,{"aria-label":j("export"),onClick:re,size:"default",variant:"outline",children:[ge(Vn,{className:"size-4"}),ge("span",{className:"hidden @2xl/base-header:inline",children:j("export")})]}),Ge(n,{"aria-label":j("new"),onClick:()=>N(),size:"default",children:[ge(In,{className:"size-4"}),ge("span",{className:"hidden @2xl/base-header:inline",children:j("new")})]})]})]})})};import{useMemo as Ur}from"react";import{useRef as $n}from"react";import{useEffect as On,useRef as An}from"react";var Fn=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,zn="[data-hour]",Gn=(d)=>{let h=Fn.exec(d)?.at(1);if(!h)return null;let S=Number.parseInt(h,10);return S>=0&&S<=23?S:null},Rt=(d)=>Number.parseInt(d.getAttribute("data-hour")??"",10),Bn=(d,u)=>{let h=d.at(0),S=d.at(-1);if(!h||!S)return null;if(u<=Rt(h))return h;if(u>=Rt(S))return S;return d.find((N)=>Rt(N)===u)??null},Ln=(d,u,h,S)=>{let N=u.getBoundingClientRect(),F=h.getBoundingClientRect();if(S==="horizontal"){d.scrollTo({left:N.left-F.left,behavior:"auto"});return}d.scrollTo({top:N.top-F.top,behavior:"auto"})},lt=({viewportRef:d,scrollTime:u,enabled:h,scrollKey:S,axis:N="vertical"})=>{let F=An(null);On(()=>{if(!h||!u)return;if(F.current===S)return;let K=Gn(u);if(K===null)return;let j=d.current;if(!j)return;let J=Array.from(j.querySelectorAll(zn)),re=J.at(0),ee=Bn(J,K);if(!re||!ee)return;Ln(j,ee,re,N),F.current=S},[h,u,S,d,N])};import{memo as Yn}from"react";import{jsx as jn}from"react/jsx-runtime";var _n=({children:d,className:u})=>{let{stickyViewHeader:h,viewHeaderClassName:S}=r((N)=>({stickyViewHeader:N.stickyViewHeader,viewHeaderClassName:N.viewHeaderClassName}));return jn("div",{className:e("flex h-12 w-fit",h&&"sticky top-0 z-21 bg-background",u,S),"data-testid":"horizontal-grid-header",children:d})},Vr=Yn(_n);import{jsx as Be,jsxs as Ir}from"react/jsx-runtime";var Or=({rows:d,children:u,classes:h,allDay:S,gridType:N,variant:F="resource",dayNumberHeight:K})=>{let{currentDate:j,view:J,scrollTime:re}=r(),ee=$n(null),te=F==="resource",oe=!te;lt({viewportRef:ee,scrollTime:re,enabled:N==="hour"&&te,scrollKey:`${J}-${j.format("YYYY-MM-DD")}`,axis:"horizontal"});let se=u&&Be(Vr,{className:h?.header,children:u});return Ir("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",children:[oe&&se,Ir(c,{className:e("h-full",oe&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:ee},children:[te&&se,Be("div",{className:e("flex flex-1 w-fit",h?.body),"data-testid":"horizontal-grid-body",children:Be("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:d.map((de)=>Be(W,{allDay:de.allDay??S,dayNumberHeight:K,gridType:N,variant:F,...de},de.id))},j.format("YYYY-MM"))}),Be(f,{className:"z-30"}),Be(f,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as ia}from"react";import{memo as ea}from"react";import{memo as Xn}from"react";import{useMemo as zr}from"react";var Un=(d)=>{let u=[],h=[],S=null;for(let N of d){if(S&&N.start.isSameOrAfter(S)){if(h.length>0)u.push(h);h=[]}h.push(N),S=S?t.max(S,N.end):N.end}if(h.length>0)u.push(h);return u},Ar=(d,{gridStart:u,totalUnits:h,gridType:S,isDiscrete:N})=>{let F=d.start.diff(u,S,!0),K=d.end.diff(u,S,!0);if(N){if(F=Math.floor(F),K=Math.ceil(K),K<=F)K=F+1}let j=F<0,J=K>h;if(j)F=0;if(J)K=h;let re=Math.max(0,K-F);if(re===0)return null;return{top:F/h*100,height:re/h*100,isTruncatedStart:j,isTruncatedEnd:J}},Wn={2:25,3:50,4:60},Kn=70,Zn=(d)=>Wn[d]??Kn,qn=(d,u)=>{let h=d.length===1?d.at(0):void 0;if(h){let j=Ar(h,u);if(!j)return[];return[{kind:"vertical",event:h,left:0,width:100,...j}]}let S=[...d].sort((j,J)=>{let re=J.end.diff(J.start,"minute")-j.end.diff(j.start,"minute");return re!==0?re:j.start.diff(J.start)}),N=S.length,F=N>1?Zn(N)/(N-1):0,K=[];for(let j=0;j<N;j++){let J=S.at(j);if(!J)continue;let re=Ar(J,u);if(!re)continue;let ee=j===0?0:F*j;K.push({kind:"vertical",event:J,...re,left:ee,width:100-ee,zIndex:j+1})}return K},Fr=({days:d,gridType:u="hour",events:h})=>{let S=h.filter((F)=>!F.allDay).toSorted((F,K)=>F.start.diff(K.start));if(S.length===0)return[];let N={gridStart:d.at(0)||t(),totalUnits:d.length,gridType:u,isDiscrete:u==="day"};return Un(S).flatMap((F)=>qn(F,N))};var Gr=({days:d,gridType:u,resourceId:h})=>{let{getEventsForDateRange:S}=r(),N=d.at(0),F=d.at(-1),K=N?.startOf("day"),j=F?.endOf("day"),J=zr(()=>{if(!K||!j)return[];let ee=S(K,j);if(h)ee=E(ee,h);return ee.filter((te)=>!te.allDay)},[K,j,S,h]);return zr(()=>Fr({days:d,events:J,gridType:u}),[d,u,J])};import{jsx as kt,jsxs as Jn}from"react/jsx-runtime";var Qn=({days:d,gridType:u="hour",resourceId:h,resource:S,"data-testid":N})=>{let{resources:F}=r((te)=>({resources:te.resources})),K=Gr({days:d,gridType:u,resourceId:h}),j=d.at(0),J=d.at(-1)?.add(1,u),re=!h||F?.at(0)?.id===h,ee=u==="hour"&&Boolean(j&&J);return Jn("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":N,children:[ee&&j&&J&&kt(G,{rangeEnd:J,rangeStart:j,resource:S,withDot:re}),K.map((te,oe)=>{let{event:ie}=te,se=`event-${ie.id}-${oe}-${d.at(0)?.toISOString()}-${h??"no-resource"}`,de=ie.end.diff(ie.start,"minute")<=15;return kt("div",{className:"absolute",style:{left:`${te.left}%`,width:`calc(${te.width}% - var(--spacing) * 2)`,top:`${te.top}%`,height:`${te.height}%`},children:kt(k,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":de}),elementId:se,event:ie,isTruncatedEnd:te.isTruncatedEnd,isTruncatedStart:te.isTruncatedStart,sourceResourceId:h})},o.listKey(se,"wrapper"))})]})},Br=Xn(Qn);import{jsx as Le,jsxs as ra}from"react/jsx-runtime";var ta=({id:d,days:u,resource:h,"data-testid":S,gridType:N,className:F,renderCell:K,noEvents:j,slotDurationMinutes:J=60})=>{let re=h?.id,ee=Math.floor(60/J),te=Array.from({length:ee},(ie,se)=>se*J),oe=te.length>1;return Le("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",F),"data-testid":S||o.container.vertical.col(d),children:ra("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${u.length}, minmax(0, 1fr))`},children:[u.map((ie,se)=>{let de=ie.format("HH");if(K){let ae=d===o.col.time,ue=ae?o.cell.verticalTime(de):o.cell.vertical(ie,de,"00",re);return Le("div",{className:"min-h-[60px] bg-background","data-hour":ae?de:void 0,"data-testid":ue,children:K(ie)},o.listKey(d,se,de))}return Le("div",{className:"flex flex-col min-h-[60px]",children:te.map((ae,ue)=>{let le=String(ae).padStart(2,"0"),pe=o.cell.vertical(ie,de,le,re),ce=oe&&ue<te.length-1;return Le(H,{className:e("hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",ce&&"border-b border-dashed"),"data-testid":pe,day:oe?ie.minute(ae):ie,gridType:N,hour:N==="hour"?ie.hour():void 0,minute:oe?ae:void 0,resourceId:re,shouldRenderEvents:!1,slotDurationMinutes:J},o.listKey(d,se,le))})},o.listKey(d,se,de))}),!j&&Le("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Le(Br,{"data-testid":o.container.eventsLayer("vertical",d),days:u,gridType:N,resource:h,resourceId:re})})]})})},Lr=ea(ta);import{memo as oa}from"react";import{jsx as Yr,jsxs as aa}from"react/jsx-runtime";var na=({children:d,classes:u,allDayRow:h,expandAllDayRow:S=!1})=>{let{stickyViewHeader:N,viewHeaderClassName:F}=r((j)=>({stickyViewHeader:j.stickyViewHeader,viewHeaderClassName:j.viewHeaderClassName})),K="min-w-full w-fit";return aa("div",{className:e(S&&"flex h-full flex-col",N&&"sticky top-0 z-21 bg-background",F),children:[Yr("div",{className:e("min-h-12 border-b","min-w-full w-fit",u?.header),"data-testid":"vertical-grid-header",children:d}),h&&Yr("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",S&&"flex-1 overflow-hidden",u?.allDay),"data-testid":"vertical-grid-all-day",children:h})]})},_r=oa(na);import{jsx as Ye,jsxs as jr}from"react/jsx-runtime";var $r=({columns:d,children:u,gridType:h="day",variant:S="resource",classes:N,allDayRow:F,slotDurationMinutes:K,style:j})=>{let J=S==="resource",re=!J,ee=d.every((ue)=>!ue.days?.length),{currentDate:te,view:oe,scrollTime:ie}=r(),se=ia(null);lt({viewportRef:se,scrollTime:ie,enabled:h==="hour"&&!ee,scrollKey:`${oe}-${te.format("YYYY-MM-DD")}`});let ae=u&&Ye(_r,{allDayRow:F,classes:{header:N?.header,allDay:N?.allDay},expandAllDayRow:ee,children:u});if(ee&&ae)return Ye("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:j,children:ae});return jr("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:j,children:[re&&ae,jr(c,{className:e("h-full",re&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:se},children:[J&&ae,Ye("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",N?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:d.map((ue,le)=>Ye(Lr,{...ue,gridType:h,slotDurationMinutes:K},o.listKey(ue.id,le)))}),Ye(f,{className:"z-30"})," ",Ye(f,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as Oe}from"react/jsx-runtime";var sa=(d,u)=>u==="vertical",la=({specs:d,header:u,composesResourceAxis:h,variant:S})=>{let{slotDuration:N}=r((oe)=>({slotDuration:oe.slotDuration})),F=d.some((oe)=>oe.gridType==="hour")?"hour":"day",K=d.filter((oe)=>!oe.noEvents).map((oe)=>oe.day).filter((oe)=>Boolean(oe)),j=d.find((oe)=>oe.noEvents),re=Boolean(j?.className?.includes(T))?{cell:"flex-1 min-w-0",spacer:T}:void 0,ee;if(F==="hour")ee=h?Oe(X,{columns:d}):Oe(U,{classes:re,days:K});return Oe($r,{allDayRow:ee,classes:h?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:d,gridType:F,slotDurationMinutes:N,variant:S,children:u})},da=({specs:d,header:u,composesResourceAxis:h,variant:S})=>{let N=d.some((j)=>j.columns?.some((J)=>J.gridType==="hour"))?"hour":"day",F=d.some((j)=>j.columns?.some((J)=>J.days)),K=h?{header:e(F&&q,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return Oe(Or,{classes:K,dayNumberHeight:h?0:void 0,gridType:N,rows:d,variant:S,children:u})},Wr=({view:d})=>{let{currentDate:u,firstDayOfWeek:h,hiddenDays:S,businessHours:N,hideNonBusinessHours:F,resources:K,orientation:j,weekViewGranularity:J}=r((ae)=>({currentDate:ae.currentDate,firstDayOfWeek:ae.firstDayOfWeek,hiddenDays:ae.hiddenDays,businessHours:ae.businessHours,hideNonBusinessHours:ae.hideNonBusinessHours,resources:ae.resources,orientation:ae.orientation,weekViewGranularity:ae.weekViewGranularity})),re=Ur(()=>({firstDayOfWeek:h,hiddenDays:S,businessHours:N,hideNonBusinessHours:F,resources:K,orientation:j,weekViewGranularity:J}),[h,S,N,F,K,j,J]),ee=Ur(()=>d.columns?.(u,re),[d,u,re]);if(!ee||!d.layout){let ae=d.component;if(ae)return Oe(ae,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${d.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let oe=Boolean(K?.length)&&Boolean(d.supportsResources),ie=oe?j??"horizontal":d.layout,se=oe?"resource":"regular",de=d.renderHeader?.({date:u,config:re});if(sa(ee,ie))return Oe(la,{composesResourceAxis:oe,header:de,specs:ee,variant:se});return Oe(da,{composesResourceAxis:oe,header:de,specs:ee,variant:se})};var Kr=(d)=>{if(!d||d.length===0)return;return new Set(d.map((u)=>P[u]))};function Zr(d){if(!d?.length)return[];return d.map((u)=>({...u,start:t(u.start),end:t(u.end)}))}import{jsx as He,jsxs as pa}from"react/jsx-runtime";var ua=()=>{let{view:d,getViews:u}=r((N)=>({view:N.view,getViews:N.getViews})),h=u().find((N)=>N.name===d);return pa("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[He(Hr,{className:"p-1 shrink-0 mb-1"}),He(Xt,{children:He(i,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:d,children:He("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:h?He(Wr,{view:h},d):null})})}),He(pr,{})]})},Mt=({events:d,firstDayOfWeek:u="sunday",initialView:h="month",initialDate:S,eventSpacing:N=z,eventHeight:F=B,stickyViewHeader:K=!0,viewHeaderClassName:j="",timeFormat:J="12-hour",hideNonBusinessHours:re=!1,hiddenDays:ee,resources:te,orientation:oe,...ie})=>{let se=Boolean(te?.length),de=ma(()=>Zr(d),[d]);return ca(()=>{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.")},[oe,se]),He(M,{eventHeight:F,eventSpacing:N,events:de,firstDayOfWeek:P[u],hiddenDays:Kr(ee),hideNonBusinessHours:re,initialDate:S,initialView:h,orientation:oe,resources:te,stickyViewHeader:K,timeFormat:J,viewHeaderClassName:j,...ie,children:He(ua,{})})};import{jsx as ga}from"react/jsx-runtime";var fa=(d)=>ga(Mt,{...d});export{Mt as IlamyCalendar,fa as IlamyResourceCalendar,Lt as SLOT_EVENT_FORM,Yt as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,Y as defaultTranslations,Q as useIlamyCalendarContext};
1
+ import{t}from"./shared/chunk-cn24081x.js";import{R,w,S,G,P,W}from"./shared/chunk-1x8xjsbq.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-mn44xvnt.js";import{e,d,N,pe}from"./shared/chunk-tfk3a0d4.js";import{o,v,m,s,C,D,E,h,f}from"./shared/chunk-p26ryh5z.js";import{u,y}from"./shared/chunk-xf8cy2gp.js";var cr="event-form",mr="event-mutation-scope",ur=({event:c,onChange:b})=>r((k)=>k.renderSlot)(cr,{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?.(mr,Y)};import{useEffect as ii,useMemo as si}from"react";import{DndContext as wn}from"@dnd-kit/core";import{useId as Pn}from"react";import{MouseSensor as nn,TouchSensor as an,useSensor as fr,useSensors as sn}from"@dnd-kit/core";import{useEffect as ln,useRef as vt,useState as dn}from"react";var rn=(c)=>c.hour!==void 0,Ft=(c,b,T=g)=>{let{date:k,hour:V=0,minute:Y=0,allDay:le}=b,U=c.end.diff(c.start,"second"),ge=(Pe)=>({start:Pe,end:Pe.add(U,"second")});if(rn(b)){let Ne=t(k).hour(V).minute(Y).subtract(T.minutes,"minute");return{...ge(Ne),allDay:!1}}let ye=t(k).subtract(T.days,"day"),ve=le===!0,De=le===void 0,Ce=Boolean(c.allDay);if(ve||De&&Ce)return{...ge(ye.startOf("day")),allDay:!0};let Ee=ye.format("YYYY-MM-DD"),he=c.start.format("HH:mm:ss.SSS"),we=t(`${Ee}T${he}`);return{...ge(we),allDay:!1}},on=(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}},pr=(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}=Ft(b,Y,T),ve=k.data.current?.sourceResourceId,De={start:U,end:ge,...on(b,ve,le),allDay:ye};return{activeEvent:b,updates:De}};var cn=(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},mn=({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?.()}}},un=(c,b,T)=>{let k=b??{},{start:V,end:Y,allDay:le}=Ft(c,k,T);return{event:c,start:V,end:Y,resourceId:k.resourceId??c.resourceId,allDay:le,isDropAllowed:!k.disabled}},pn=(c)=>{let b=ce(c);ln(()=>{if(!b)return;let T=document.body.style.cursor;return document.body.style.cursor=b,()=>{document.body.style.cursor=T}},[b])},fn={activationConstraint:{distance:2}},gn={activationConstraint:{delay:100,tolerance:5}},vn=()=>{let c=fr(nn,fn),b=fr(an,gn);return sn(c,b)},gr=(c)=>{let b=r((be)=>be.slotDuration),T=vn(),k=vt(null),V=vt(g),Y=vt(null),le=vt(null),[U,ge]=dn(null);pn(U);let ye=()=>{k.current=null,V.current=g,Y.current=null,ge(null),le.current?.setActiveEvent(null)},ve=(be)=>{let Ee=mn(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 he=Ee.barRect??be.active.rect.current.initial;if(!he)return;V.current=de({activeEvent:Ee.calendarEvent,initialRect:he,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 he=un(Ee,be.over.data.current,V.current);ge((we)=>{if(cn(we,he))return we;return he})},onDragEnd:(be)=>{let Ee=pr(be,k.current,V.current);if(Ee)c(Ee.activeEvent,Ee.updates);ye()},onDragCancel:ye}}};import{useCallback as yt,useEffect as yn,useRef as Dn,useState as Cn}from"react";var Gt={isOpen:!1,operation:"edit",event:null};function Dt(c){let{applyScopedEdit:b,applyScopedDelete:T}=r((ve)=>({applyScopedEdit:ve.applyScopedEdit,applyScopedDelete:ve.applyScopedDelete})),[k,V]=Cn(Gt),Y=Dn(k);yn(()=>{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(Gt),[]),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(Gt),c?.()},[b,T,c]);return{dialogState:k,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}}var vr=()=>{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 hn}from"@dnd-kit/core";var yr=(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 hn({...c,droppableContainers:U})};import{DragOverlay as En}from"@dnd-kit/core";import{snapCenterToCursor as bn}from"@dnd-kit/modifiers";import{useImperativeHandle as Sn,useState as xn}from"react";import{jsx as Dr}from"react/jsx-runtime";var Cr=({ref:c})=>{let[b,T]=xn(null),k=p();if(Sn(c,()=>({setActiveEvent:T})),k)return null;return Dr(En,{modifiers:[bn],children:b&&Dr("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 Bt,jsxs as hr}from"react/jsx-runtime";function Er({children:c}){let b=Pn(),T=r((ve)=>ve.disableDragAndDrop),{commitDrop:k,scopeDialog:V}=vr(),{sensors:Y,dragPreview:le,overlayRef:U,handlers:ge}=gr(k),ye=le!==null;if(T)return c;return hr(ie.Provider,{value:le,children:[hr(wn,{collisionDetection:yr,id:b,sensors:Y,...ge,children:[Bt("div",{className:"contents","data-dragging":ye?"true":void 0,children:c}),Bt(Cr,{ref:U})]}),Bt(gt,{...V})]})}import{ChevronDownIcon as Tn}from"lucide-react";import{useEffect as Rn,useState as Nn}from"react";import*as Fe from"@radix-ui/react-popover";import{jsx as Ct}from"react/jsx-runtime";function Ye({...c}){return Ct(Fe.Root,{"data-slot":"popover",...c})}function _e({...c}){return Ct(Fe.Trigger,{"data-slot":"popover-trigger",...c})}function je({className:c,align:b="center",sideOffset:T=4,...k}){return Ct(Fe.Portal,{children:Ct(Fe.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 br=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,zt=(c)=>Boolean(c&&br.test(c)),kn=(c)=>{let b=c.match(/bg-([a-z]+)-\d+/)?.at(1);if(!b)return"Custom";return b.charAt(0).toUpperCase()+b.slice(1)};function Sr({value:c,onChange:b,swatches:T=[],className:k,"aria-label":V="Select color"}){let[Y,le]=Nn(zt(c)?c:"");Rn(()=>{le(zt(c)?c:"")},[c]);let U=(De)=>{let Ce=De.target.value;if(le(Ce),br.test(Ce))b(Ce)},ge=zt(c),ye=T.find((De)=>De.value===c),ve;if(ye)ve=ye.label;else if(ge)ve=c;else if(c)ve=kn(c);else ve="Pick a color";return st(Ye,{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(Tn,{className:"size-4 shrink-0 opacity-50"})]}),st(je,{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 Ce=c===De.value;return $e("button",{"aria-label":De.label,"aria-pressed":Ce,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",De.value,Ce&&"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 Mn}from"react/jsx-runtime";function xr({className:c,...b}){return Mn("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 Kn,useState as Ve}from"react";import{PopoverClose as Gn}from"@radix-ui/react-popover";import{Calendar as Bn}from"lucide-react";import{useEffect as zn,useRef as Yn,useState as _n}from"react";import{useState as Vn}from"react";import{ChevronLeftIcon as On,ChevronRightIcon as Hn}from"lucide-react";import{jsx as lt,jsxs as In}from"react/jsx-runtime";function Je({label:c,onPrev:b,onNext:T,prevLabel:k,nextLabel:V}){return In("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(Hn,{className:"size-4"})})]})}import{jsx as Ge,jsxs as wr}from"react/jsx-runtime";function An(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 Ln(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 Fn({day:c,state:b,onSelect:T}){return Ge("td",{className:An(b),"data-disabled":b.isDisabled,"data-outside":b.isOutside,"data-selected":b.isSelected,role:"gridcell",tabIndex:-1,children:Ge("button",{"aria-disabled":b.isDisabled,"aria-hidden":b.isOutside,className:Ln(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]=Vn(()=>t(b??c??new Date).startOf("month")),ve=L(ge,V),De=c?t(c).format("YYYY-MM-DD"):void 0,Ce=i(t(),V).map((he)=>he.format("dd")),xe,be;if(U){let he=i(U,V);xe=he.at(0),be=he.at(-1)}let Ee=(he)=>{let we=he.format("YYYY-MM-DD")===De,Pe=!1;if(xe&&be){let Ne=!he.isBefore(xe,"day"),Te=!he.isAfter(be,"day");Pe=Ne&&Te}return{isOutside:!he.isSame(ge,"month"),isSelected:we,isDisabled:k?.(he.toDate())??!1,isCurrent:a(he)&&!we,isCurrentWeek:Pe,weekHover:le}};return wr("div",{className:e("bg-background p-3 w-72",Y),"data-slot":"calendar",children:[Ge(Je,{label:ge.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>ye((he)=>he.add(1,"month")),onPrev:()=>ye((he)=>he.subtract(1,"month")),prevLabel:"Previous month"}),wr("table",{className:"w-full border-collapse",role:"grid",children:[Ge("thead",{children:Ge("tr",{children:Ce.map((he,we)=>Ge("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:he},we))})}),Ge("tbody",{children:ve.map((he,we)=>Ge("tr",{className:e(le&&"group/week"),children:he.map((Pe)=>Ge(Fn,{day:Pe,onSelect:T,state:Ee(Pe)},Pe.toISOString()))},we))})]})]})}import{jsx as et,jsxs as Yt}from"react/jsx-runtime";function Pr({date:c,closeOnSelect:b,onChange:T,label:k="Pick a date",className:V,disabled:Y}){let le=r((De)=>De.firstDayOfWeek),U=Yn(null),[ge,ye]=_n(c);zn(()=>{ye(c)},[c]);let ve=(De)=>{if(ye(De),b)U.current?.click();T?.(De)};return et("div",{className:V,children:Yt(Ye,{children:[et(_e,{asChild:!0,children:Yt(o,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!c,variant:"outline",children:[et(Bn,{}),ge?t(ge).format("ll"):et("span",{children:k})]})}),Yt(je,{align:"start",className:"w-auto p-0",children:[et(Gn,{ref:U,style:{display:"none"}}),et(dt,{defaultMonth:ge,disabled:Y,firstDayOfWeek:le,onSelect:ve,selected:ge})]})]})})}import{Clock as $n}from"lucide-react";import{useEffect as Wn,useRef as Rr,useState as _t}from"react";import{useMemo as jn}from"react";function Tr({timeFormat:c="12-hour",minTime:b="00:00",maxTime:T="23:45"}){return{timeOptions:jn(()=>{let Y=[],[le,U]=b.split(":").map(Number),[ge,ye]=T.split(":").map(Number),ve=le*60+U,De=ge*60+ye;for(let Ce=ve;Ce<=De;Ce+=15){let xe=Math.floor(Ce/60),be=Ce%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 jt}from"react/jsx-runtime";var Un=(c)=>{c.stopPropagation()};function Nr({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]=_t(!1),[De,Ce]=_t(""),xe=Rr(null),be=Rr(null),[Ee,he]=_t(0),{timeOptions:we,formatTime:Pe}=Tr({timeFormat:V,minTime:T,maxTime:k}),Ne=we.filter((Oe)=>Pe(Oe).toLowerCase().includes(De.toLowerCase())),Te=(Oe)=>{b(Oe),ve(!1),Ce("")};Wn(()=>{if(ye){if(be.current)he(be.current.offsetWidth);setTimeout(()=>{xe.current?.focus()},0)}},[ye]);let Be=c?Pe(c):Y;return jt(Ye,{onOpenChange:ve,open:ye,children:[We(_e,{asChild:!0,children:jt(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($n,{className:"mr-2 h-4 w-4"}),Be]})}),jt(je,{align:"start",className:"p-0",style:{width:Ee},children:[We("div",{className:"p-2 border-b",children:We(m,{className:"h-8",onChange:(Oe)=>Ce(Oe.target.value),placeholder:"Search time...",ref:xe,value:De})}),We(u,{className:"h-[200px]",onWheel:Un,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((Oe)=>{let ut=Pe(Oe);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",Oe===c&&"bg-accent text-accent-foreground"),onClick:()=>Te(Oe),type:"button",children:ut},Oe)})})})]})]})}var kr=(c,b)=>{let[T,k]=b.split(":").map(Number);return t(c).hour(T).minute(k).second(0).millisecond(0)},Mr=(c,b,T)=>{let k=kr(c,b);return T?k.hour(0).minute(0):k},Or=(c,b,T)=>{let k=kr(c,b);return T?k.add(1,"day").startOf("day"):k},$t=(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 He,Fragment as Jn}from"react/jsx-runtime";var Hr="bg-blue-100 text-blue-800",Zn=[{value:Hr,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"}],Ir=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,qn=(c,b)=>{if(c&&Ir.test(c))return c;return b??Hr},Xn=(c)=>{if(Ir.test(c))return{backgroundColor:c,color:pe(c)};return{backgroundColor:void 0,color:c}},Qn=({colorChanged:c,hadInitialColor:b,selectedColor:T,initialBackgroundColor:k,initialColor:V})=>{if(c||!b)return Xn(T);return{backgroundColor:k,color:V}},Wt=({name:c,label:b,placeholder:T,value:k,required:V=!1,multiline:Y=!1,onChange:le})=>He("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:c,children:b}),Y?Re(xr,{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})]}),Vr=({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:Ce,resources:xe}=r((Se)=>({t:Se.t,timeFormat:Se.timeFormat,getEventManager:Se.getEventManager,resources:Se.resources??[]})),{id:be,resourceId:Ee,resourceIds:he,start:we=t(),end:Pe=t().add(1,"hour"),allDay:Ne=!1,color:Te,backgroundColor:Be,title:Oe="",description:ut="",location:tr=""}=c??{},rr=xe.length>0,or=Ee??he?.at(0),nr=rr&&or===void 0,[kt,ko]=Ve(or),Mt=rr?kt:Ee,pt=X(Mt),ar=Boolean(c&&Ce(c)),Mo=Pe.isSame(Pe.startOf("day")),Oo=Ne&&Mo?Pe.subtract(1,"day"):Pe,[Ze,ir]=Ve(we.toDate()),[Qe,Ot]=Ve(Oo.toDate()),[ze,Ho]=Ve(Ne),[Ht,Io]=Ve(qn(Be,Te)),[Vo,Ao]=Ve(!1),Lo=Boolean(Te||Be),Fo=(Se)=>{Io(Se),Ao(!0)},[It,sr]=Ve(we.format("HH:mm")),[ft,Vt]=Ve(Pe.format("HH:mm")),[Le,Go]=Ve({title:Oe,description:ut,location:tr}),[At,Bo]=Ve({}),zo={...c,...At},Yo=(Se)=>Bo((ke)=>({...ke,...Se})),_o=(Se)=>{if(!Se)return;if(ir(Se),t(Se).isAfter(t(Qe)))Ot(Se)},jo=(Se)=>{if(!Se)return;if(Ot(Se),Se&&t(Se).isBefore(t(Ze)))ir(Se)},$o=(Se)=>{if(Ho(Se),!(Se&&ft==="00:00"))return;Ot((ke)=>t(ke).isAfter(t(Ze),"day")?t(ke).subtract(1,"day").toDate():ke)},Wo=(Se)=>{if(sr(Se),t(Ze).isSame(t(Qe),"day")&&Se>ft)Vt(Se)},Uo=(Se)=>{if(Vt(Se),t(Ze).isSame(t(Qe),"day")&&Se<It)sr(Se)},Lt=(Se)=>{let{name:ke,value:Ie}=Se.target;Go((at)=>({...at,[ke]:Ie}))};Kn(()=>{if(ze)Vt("23:59")},[ze]);let Ko=(Se)=>xe.find((Ie)=>String(Ie.id)===Se)?.id??Se,lr=nr&&kt===void 0,Zo=(Se)=>{if(Se.preventDefault(),lr)return;let ke=Mr(Ze,It,ze),Ie=Or(Qe,ft,ze),at=Qn({colorChanged:Vo,hadInitialColor:Lo,selectedColor:Ht,initialBackgroundColor:Be,initialColor:Te}),it={id:be||t().format("YYYYMMDDHHmmss"),title:Le.title,start:ke,end:Ie,resourceId:Mt,description:Le.description,location:Le.location,allDay:ze,...at,...At};if(c?.id&&ar){le(c,{title:Le.title,start:ke,end:Ie,resourceId:Mt,description:Le.description,location:Le.location,allDay:ze,color:Ht,...At});return}if(be)T?.(it);else V?.(it);b()},qo=()=>{if(!c?.id)return;if(ar){U(c);return}k?.(c),b()},dr;if(pt)dr=(Se)=>!B(t(Se),pt);let Xo=$t(Ze,pt),Qo=$t(Qe,pt),Jo=[["startDate",Ze,_o],["endDate",Qe,jo]],en=[["startTime","start-time",It,Wo,Xo],["endTime","end-time",ft,Uo,Qo]],tn=kt?.toString();return He(Jn,{children:[He("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:Zo,children:[Re(u,{className:"flex-1 min-h-0",children:He("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Re(Wt,{label:ve("title"),name:"title",onChange:Lt,placeholder:ve("eventTitlePlaceholder"),required:!0,value:Le.title}),Re(Wt,{label:ve("description"),multiline:!0,name:"description",onChange:Lt,placeholder:ve("eventDescriptionPlaceholder"),value:Le.description}),nr&&He("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ve("resource")}),He(C,{onValueChange:(Se)=>ko(Ko(Se)),value:tn,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)))})]})]}),He("div",{className:"flex items-center space-x-2",children:[Re(v,{checked:ze,id:"allDay",onCheckedChange:(Se)=>$o(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:Jo.map(([Se,ke,Ie])=>He("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(Pr,{className:"mt-1",closeOnSelect:!0,date:ke,disabled:dr,onChange:Ie})]},Se))}),!ze&&Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:en.map(([Se,ke,Ie,at,it])=>He("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(Nr,{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))}),He("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",children:ve("color")}),Re(Sr,{"aria-label":ve("color"),onChange:Fo,swatches:Zn,value:Ht})]}),Re(Wt,{label:ve("location"),name:"location",onChange:Lt,placeholder:ve("eventLocationPlaceholder"),value:Le.location}),Re(ur,{event:zo,onChange:Yo})]})}),He(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:qo,size:"sm",type:"button",variant:"destructive",children:ve("delete")}),He("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:lr,size:"sm",type:"submit",children:be?ve("update"):ve("create")})]})]})]}),Re(gt,{dialog:Y,onCancel:ge,onResolve:ye})]})};import{jsx as ht,jsxs as Ar}from"react/jsx-runtime";var Lr=()=>{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:Ar(w,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[Ar(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(Vr,{...ve})]})})};import{ChevronLeft as Ca,ChevronRight as ha,Download as Ea,Plus as ba}from"lucide-react";var Ut=`\r
2
+ `,ea=["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",""),Fr=(c,b=!1)=>{if(b)return c.format("YYYYMMDD");return c.utc().format("YYYYMMDD[T]HHmmss[Z]")},ta=(c)=>c.uid||`${c.id}@ilamy.calendar`,ra=(c,b)=>{let T=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),k=c.allDay?";VALUE=DATE":"",V=["BEGIN:VEVENT",`UID:${ta(c)}`,`DTSTART${k}:${Fr(c.start,c.allDay)}`,`DTEND${k}:${Fr(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(Ut)},oa=(c,b,T="ilamy Calendar")=>{let k=Et(T),V=c.map((Y)=>ra(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}`,ea,...V,"END:VCALENDAR"].join(Ut)},Gr=(c,b,T="calendar.ics",k="ilamy Calendar")=>{let V=new Blob([oa(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 Br(){let{rawEvents:c,collect:b}=r((T)=>({rawEvents:T.rawEvents,collect:T.collect}));return()=>{let T=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Gr(c,b,T,"ilamy Calendar")}}import{ChevronDown as da}from"lucide-react";import{useState as ca}from"react";function zr(){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 aa}from"react";import{jsx as na}from"react/jsx-runtime";function bt({label:c,isSelected:b,isCurrent:T,onSelect:k}){return na("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 Kt,jsxs as ia}from"react/jsx-runtime";function Yr({selected:c,onSelect:b}){let[T,k]=aa(()=>c.year()),V=t(),Y=Array.from({length:12},(le,U)=>({index:U,label:c.month(U).format("MMM")}));return ia("div",{className:"w-72 p-3","data-slot":"month-grid",children:[Kt(Je,{label:T,nextLabel:"Next year",onNext:()=>k((le)=>le+1),onPrev:()=>k((le)=>le-1),prevLabel:"Previous year"}),Kt("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 Kt(bt,{isCurrent:ge,isSelected:U,label:le.label,onSelect:()=>b(c.year(T).month(le.index).date(1))},le.index)})})]})}import{useState as sa}from"react";import{jsx as Zt,jsxs as la}from"react/jsx-runtime";var ct=12;function _r({selected:c,onSelect:b}){let[T,k]=sa(()=>c.year()-c.year()%ct),V=t(),Y=Array.from({length:ct},(le,U)=>T+U);return la("div",{className:"w-72 p-3","data-slot":"year-grid",children:[Zt(Je,{label:`${T} – ${T+ct-1}`,nextLabel:"Next years",onNext:()=>k((le)=>le+ct),onPrev:()=>k((le)=>le-ct),prevLabel:"Previous years"}),Zt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=le===c.year(),ge=le===V.year()&&!U;return Zt(bt,{isCurrent:ge,isSelected:U,label:le,onSelect:()=>b(c.year(le))},le)})})]})}import{jsx as qe,jsxs as jr}from"react/jsx-runtime";var ma={day:"day",week:"week",month:"month",year:"year"};function ua(c){let b=c?.navigationStep??{amount:1,unit:c?.navigationUnit??"day"};if(b.amount!==1)return"range";return ma[b.unit]??"range"}function $r({className:c}){let{currentDate:b,currentRange:T,view:k,selectDate:V,firstDayOfWeek:Y,getViews:le}=r((Te)=>({currentDate:Te.currentDate,currentRange:Te.currentRange,view:Te.view,selectDate:Te.selectDate,firstDayOfWeek:Te.firstDayOfWeek,getViews:Te.getViews})),{formatDateRange:U}=zr(),[ge,ye]=ca(!1),ve=i(b,Y),De=ve.at(0)??b,Ce=ve.at(-1)??b,xe=(Te)=>{V(Te),ye(!1)},be=ua(le().find((Te)=>Te.name===k)),he={year:b.format("YYYY"),month:b.format("MMM YYYY"),week:U(De,Ce),day:b.format("ddd, MMM D, YYYY"),range:U(T.start,T.end)}[be],we=qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,onSelect:(Te)=>Te&&xe(t(Te)),selected:b.toDate()}),Ne={year:qe(_r,{onSelect:xe,selected:b}),month:qe(Yr,{onSelect:xe,selected:b}),week:qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,highlightedWeekOf:b,onSelect:(Te)=>Te&&xe(t(Te)),weekHover:!0}),day:we,range:we}[be];return jr(Ye,{onOpenChange:ye,open:ge,children:[qe(_e,{asChild:!0,children:jr(o,{className:e("font-semibold",c),"data-testid":"calendar-title",variant:"outline",children:[he,qe(da,{className:"size-4 shrink-0 opacity-50"})]})}),qe(je,{align:"start",className:"w-auto p-0",children:Ne})]})}import*as Ae from"@radix-ui/react-dropdown-menu";import{jsx as mt}from"react/jsx-runtime";function Wr({...c}){return mt(Ae.Root,{"data-slot":"dropdown-menu",...c})}function Ur({...c}){return mt(Ae.Trigger,{"data-slot":"dropdown-menu-trigger",...c})}function Kr({className:c,sideOffset:b=4,align:T="end",...k}){return mt(Ae.Portal,{children:mt(Ae.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 Zr({className:c,...b}){return mt(Ae.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 pa,ChevronDown as fa}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 qt}from"react/jsx-runtime";function qr({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 qt(Wr,{children:[Ue(Ur,{asChild:!0,className:c,children:qt(o,{size:"default",variant:"outline",children:[U&&Ue(U,{className:"size-4"}),Ue("span",{children:le}),Ue(fa,{className:"size-4 opacity-50"})]})}),Ue(Kr,{align:"end",className:"min-w-40",children:V.map((ge)=>{let ye=ge.icon;return qt(Zr,{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(pa,{className:"size-4"})]},ge.name)})})]})}import*as xt from"@radix-ui/react-toggle-group";import{cva as ga}from"class-variance-authority";import{createContext as va,useContext as ya}from"react";import{jsx as Xt}from"react/jsx-runtime";var Da=ga("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"}}),Xr=va({size:"default",variant:"default"});function Qr({className:c,variant:b,size:T,children:k,...V}){return Xt(xt.Root,{className:e("flex items-center justify-center gap-1",c),"data-slot":"toggle-group",...V,children:Xt(Xr.Provider,{value:{variant:b,size:T},children:k})})}function Jr({className:c,children:b,variant:T,size:k,...V}){let Y=ya(Xr);return Xt(xt.Item,{className:e(Da({variant:Y.variant||T,size:Y.size||k}),c),"data-slot":"toggle-group-item",...V,children:b})}import{jsx as eo}from"react/jsx-runtime";function to({className:c}){let{view:b,setView:T,t:k}=r((Y)=>({view:Y.view,setView:Y.setView,t:Y.t})),V=St();return eo(Qr,{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)=>eo(Jr,{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 ro=({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=Br();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(Ca,{className:"size-4"})}),Me(o,{"aria-label":U("next"),className:"h-full",onClick:b,size:"icon",variant:"ghost",children:Me(ha,{className:"size-4"})})]}),Me(o,{onClick:k,size:"default",variant:"outline",children:U("today")}),Me($r,{})]}),tt("div",{className:"flex items-center gap-2",children:[Me(to,{className:"hidden @4xl/base-header:flex"}),Me(qr,{className:"@4xl/base-header:hidden"}),!ge&&tt(o,{"aria-label":U("export"),onClick:ye,size:"default",variant:"outline",children:[Me(Ea,{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(ba,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("new")})]})]})]})})};import{useMemo as Po}from"react";import{useRef as so}from"react";import{useEffect as Sa,useRef as xa}from"react";var wa=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,Pa="[data-hour]",Ta='[data-start]:not([data-all-day="true"])',Ra=(c)=>{let T=wa.exec(c)?.at(1);if(!T)return null;let k=Number.parseInt(T,10);return k>=0&&k<=23?k:null},Qt=(c)=>Number.parseInt(c.getAttribute("data-hour")??"",10),Na=(c,b)=>{let T=c.at(0),k=c.at(-1);if(!T||!k)return null;if(b<=Qt(T))return T;if(b>=Qt(k))return k;return c.find((V)=>Qt(V)===b)??null},ka=(c)=>({start:t(c.dataset.start??""),end:t(c.dataset.end??"")}),Ma=(c)=>{let b=Array.from(c.querySelectorAll(Ta)),T=b.at(0),k=t(),V=b.find((Y)=>d(ka(Y),k,k));if(!T||!V)return null;return{target:V,origin:T}},Oa=(c,b)=>{let T=b?Ra(b):null;if(T===null)return null;let k=Array.from(c.querySelectorAll(Pa)),V=k.at(0),Y=Na(k,T);if(!V||!Y)return null;return{target:Y,origin:V}},Ha=(c,b,T,k)=>{let V=b.getBoundingClientRect(),Y=T.getBoundingClientRect(),le=V.left-Y.left,U=V.top-Y.top;oo(c,k,k==="horizontal"?le:U)},oo=(c,b,T)=>{let k=b==="horizontal"?"left":"top";c.scrollTo({[k]:T,behavior:"auto"})},Ia=(c,{scrollTime:b,scrollToNow:T,axis:k})=>{let Y=(T?Ma(c):null)??Oa(c,b);if(Y)return Ha(c,Y.target,Y.origin,k),!0;if(T)return oo(c,k,0),!0;return!1},wt=({viewportRef:c,scrollTime:b,scrollToNow:T=!1,enabled:k,scrollKey:V,axis:Y="vertical"})=>{let le=xa(null);Sa(()=>{if(!k)return;let U=`${V}|${b}|${T}`;if(le.current===U)return;let ge=c.current;if(!ge)return;if(Ia(ge,{scrollTime:b,scrollToNow:T,axis:Y}))le.current=U},[k,b,T,V,c,Y])};import{useLayoutEffect as Va}from"react";var Jt="data-sticky-inset",Pt=(c)=>c?"top":void 0,no={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},ao=new Set(["hidden","scroll","auto","overlay","clip"]),Aa=(c)=>{let b=[];for(let T=c.parentElement;T;T=T.parentElement){let{overflowX:k,overflowY:V}=getComputedStyle(T);if(ao.has(k)||ao.has(V))b.push(T)}return b},La=(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(`[${Jt}]`);for(let le of Y){let U=le.getAttribute(Jt),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);Va(()=>{let U=c.current,ge=b.current;if(!U||!ge)return;let ye=Aa(U),ve=()=>{let Ee=La(U,ge,ye);ge.style.setProperty(no.left,`${Ee.left}px`),ge.style.setProperty(no.top,`${Ee.top}px`)};ve();let De,Ce=()=>{if(De!==void 0)return;De=requestAnimationFrame(()=>{De=void 0,ve()})},xe=[...ye,window];for(let Ee of xe)Ee.addEventListener("scroll",Ce,{passive:!0});window.addEventListener("resize",Ce,{passive:!0});let be=typeof ResizeObserver>"u"?void 0:new ResizeObserver(ve);be?.observe(ge);for(let Ee of U.querySelectorAll(`[${Jt}]`))be?.observe(Ee);return()=>{for(let Ee of xe)Ee.removeEventListener("scroll",Ce);if(window.removeEventListener("resize",Ce),be?.disconnect(),De!==void 0)cancelAnimationFrame(De)}},[c,b,le])};import{memo as Fa}from"react";import{jsx as Ba}from"react/jsx-runtime";var Ga=({children:c,className:b})=>{let{stickyViewHeader:T,viewHeaderClassName:k}=r((V)=>({stickyViewHeader:V.stickyViewHeader,viewHeaderClassName:V.viewHeaderClassName}));return Ba("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})},io=Fa(Ga);import{jsx as rt,jsxs as lo}from"react/jsx-runtime";var co=({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=so(null),Ce=so(null),xe=Y==="resource",be=!xe;wt({viewportRef:Ce,scrollTime:ye,scrollToNow:ve,enabled:xe,scrollKey:`${ge}-${U.format("YYYY-MM-DD")}`,axis:"horizontal"}),Tt(De,Ce,c.length);let Ee=b&&rt(io,{className:T?.header,children:b});return lo("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:De,children:[be&&Ee,lo(u,{className:e("h-full",be&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:Ce},children:[xe&&Ee,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((he)=>rt(oe,{allDay:he.allDay??k,dayNumberHeight:le,gridType:V,variant:Y,...he},he.id))})}),rt(y,{className:"z-30"}),rt(y,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as So}from"react";import{memo as Xa}from"react";import{memo as Ua,useMemo as Ka}from"react";import{useMemo as uo}from"react";var za=(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},mo=(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,ja=(c)=>Ya[c]??_a,$a=(c,b)=>{let T=c.length===1?c.at(0):void 0;if(T){let U=mo(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?ja(V)/(V-1):0,le=[];for(let U=0;U<V;U++){let ge=k.at(U);if(!ge)continue;let ye=mo(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},Rt=({days:c,gridType:b="hour",events:T})=>{let k=T.filter((Y)=>!Y.allDay).toSorted((Y,le)=>Y.start.diff(le.start));if(k.length===0)return[];let V={gridStart:c.at(0)||t(),totalUnits:c.length,gridType:b,isDiscrete:b==="day"};return za(k).flatMap((Y)=>$a(Y,V))};var po=({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=uo(()=>{if(!le||!U)return[];let ve=k(le,U);return x(ve,T).filter((Ce)=>!Ce.allDay)},[le,U,k,T]);return uo(()=>Rt({days:c,events:ge,gridType:b}),[c,b,ge])};import{jsx as Wa,jsxs as fo}from"react/jsx-runtime";function go({previewPositioned:c}){let b=r((le)=>le.timeFormat),{event:T,isTruncatedStart:k,isTruncatedEnd:V}=c,Y=q(b);return fo(re,{contentClassName:"px-1.5 py-1 relative",event:T,isTruncatedEnd:V,isTruncatedStart:k,orientation:"vertical",style:ne(c),children:[fo("p",{className:"text-[10px] font-semibold sm:text-xs",children:[T.start.format(Y)," – ",T.end.format(Y)]}),Wa("p",{className:e("text-[10px] font-bold sm:text-xs truncate",M.vertical),children:T.title})]})}import{jsx as vo}from"react/jsx-runtime";var yo=(c,b,T,k)=>`event-${c}-${b}-${T.at(0)?.toISOString()}-${k??"no-resource"}`;function Do({positioned:c,elementId:b,range:T,resourceId:k,draggedEventId:V}){let{event:Y}=c,le=Y.end.diff(Y.start,"minute")<=15;return vo("div",{className:"absolute","data-testid":n.container.verticalEvent(Y.id),style:ne(c),children:vo(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 Nt,jsxs as qa}from"react/jsx-runtime";var Za=({days:c,gridType:b="hour",resourceId:T,resource:k,"data-testid":V})=>{let Y=r((Ee)=>Ee.resources),le=p(),U=po({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,Ce=b==="hour"&&Boolean(ge&&ye),xe=te({days:c,gridType:b,resourceId:T}),be=Ka(()=>{if(!xe)return null;return Rt({days:c,gridType:b,events:[xe]}).at(0)??null},[xe,c,b]);return Nt(F.Provider,{value:"vertical",children:qa("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":V,children:[Ce&&ge&&ye&&Nt(ee,{rangeEnd:ye,rangeStart:ge,resource:k,withDot:De}),U.map((Ee,he)=>{let we=yo(Ee.event.id,he,c,T);return Nt(Do,{draggedEventId:le?.event.id,elementId:we,positioned:Ee,range:{start:ge,end:ye},resourceId:T},n.listKey(we,"wrapper"))}),be&&Nt(go,{previewPositioned:be})]})})},Co=Ua(Za);import{jsx as ot,jsxs as Ja}from"react/jsx-runtime";var Qa=({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),Ce=Array.from({length:De},(be,Ee)=>Ee*ye),xe=Ce.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:Ja("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 he=be.format("HH");if(U){let we=c===n.col.time,Pe=we?n.cell.verticalTime(he):n.cell.vertical(be,he,"00",ve);return ot("div",{className:"min-h-[60px] bg-background","data-hour":we?he:void 0,"data-testid":Pe,children:U(be)},n.listKey(Ee,he))}return ot("div",{className:"flex flex-col min-h-[60px]",children:Ce.map((we,Pe)=>{let Ne=String(we).padStart(2,"0"),Te=n.cell.vertical(be,he,Ne,ve),Be=xe&&Pe<Ce.length-1;return ot(z,{className:e("not-in-data-dragging:hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",Be&&"border-b border-dashed"),"data-testid":Te,day:xe?be.minute(we):be,gridType:Y,hour:Y==="hour"?be.hour():void 0,isSubDivider:Be,minute:xe?we:void 0,resourceId:ve,shouldRenderEvents:!1,slotDurationMinutes:ye},n.listKey(Ee,Ne))})},n.listKey(Ee,he))}),!ge&&ot("div",{className:"absolute inset-0 z-10 pointer-events-none",children:ot(Co,{"data-testid":n.container.eventsLayer("vertical",c),days:b,gridType:Y,resource:T,resourceId:ve})})]})})},ho=Xa(Qa);import{memo as ei}from"react";import{jsx as Eo,jsxs as ri}from"react/jsx-runtime";var ti=({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 ri("div",{className:e(k&&"flex h-full flex-col",V&&"sticky top-0 z-21 bg-background",Y),"data-sticky-inset":Pt(V),children:[Eo("div",{className:e("min-h-12 border-b","min-w-full w-fit",b?.header),"data-testid":"vertical-grid-header",children:c}),T&&Eo("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})]})},bo=ei(ti);import{jsx as nt,jsxs as xo}from"react/jsx-runtime";var wo=({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((Ne)=>!Ne.days?.length),{currentDate:De,view:Ce,scrollTime:xe,scrollToNow:be}=r(),Ee=So(null),he=So(null);wt({viewportRef:he,scrollTime:xe,scrollToNow:be,enabled:!ve,scrollKey:`${Ce}-${De.format("YYYY-MM-DD")}`}),Tt(Ee,he,c.length);let Pe=b&&nt(bo,{allDayRow:Y,classes:{header:V?.header,allDay:V?.allDay},expandAllDayRow:ve,children:b});if(ve&&Pe)return nt("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:U,children:Pe});return xo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:Ee,style:U,children:[ye&&Pe,xo(u,{className:e("h-full",ye&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:he},children:[ge&&Pe,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((Ne,Te)=>nt(ho,{...Ne,gridType:T,slotDurationMinutes:le},n.listKey("col",Te)))}),nt(y,{className:"z-30"})," ",nt(y,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as Xe}from"react/jsx-runtime";var oi=(c,b)=>b==="vertical",ni=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let{slotDuration:V}=r((Ce)=>({slotDuration:Ce.slotDuration})),Y=c.some((Ce)=>Ce.gridType==="hour")?"hour":"day",le=c.filter((Ce)=>!Ce.noEvents).map((Ce)=>Ce.day).filter((Ce)=>Boolean(Ce)),U=c.find((Ce)=>Ce.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(wo,{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})},ai=({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(co,{classes:le,dayNumberHeight:T?0:void 0,gridType:V,rows:c,variant:k,children:b})},To=({view:c})=>{let{currentDate:b,firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}=r((he)=>({currentDate:he.currentDate,firstDayOfWeek:he.firstDayOfWeek,hiddenDays:he.hiddenDays,businessHours:he.businessHours,hideNonBusinessHours:he.hideNonBusinessHours,resources:he.resources,orientation:he.orientation,weekViewGranularity:he.weekViewGranularity})),ye=Po(()=>({firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}),[T,k,V,Y,le,U,ge]),ve=Po(()=>c.columns?.(b,ye),[c,b,ye]);if(!ve||!c.layout){let he=c.component;if(he)return Xe(he,{});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(le?.length)&&Boolean(c.supportsResources),xe=Ce?U??"horizontal":c.layout,be=Ce?"resource":"regular",Ee=c.renderHeader?.({date:b,config:ye});if(oi(ve,xe))return Xe(ni,{composesResourceAxis:Ce,header:Ee,specs:ve,variant:be});return Xe(ai,{composesResourceAxis:Ce,header:Ee,specs:ve,variant:be})};var Ro=(c)=>{if(!c||c.length===0)return;return new Set(c.map((b)=>H[b]))};function No(c){if(!c?.length)return[];return c.map((b)=>({...b,start:t(b.start),end:t(b.end)}))}import{jsx as Ke,jsxs as di}from"react/jsx-runtime";var li=()=>{let{view:c,getViews:b}=r((V)=>({view:V.view,getViews:V.getViews})),T=b().find((V)=>V.name===c);return di("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[Ke(ro,{className:"p-1 shrink-0 mb-1"}),Ke(Er,{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(To,{view:T},c):null})})}),Ke(Lr,{})]})},er=({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:Ce,...xe})=>{let be=Boolean(De?.length),Ee=si(()=>No(c),[c]);return ii(()=>{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,be]),Ke(_,{eventHeight:Y,eventSpacing:V,events:Ee,firstDayOfWeek:H[b],hiddenDays:Ro(ve),hideNonBusinessHours:ye,initialDate:k,initialView:T,orientation:Ce,resources:De,stickyViewHeader:le,timeFormat:ge,viewHeaderClassName:U,...xe,children:Ke(li,{})})};import{jsx as mi}from"react/jsx-runtime";var ci=(c)=>mi(er,{...c});export{er as IlamyCalendar,ci as IlamyResourceCalendar,cr as SLOT_EVENT_FORM,mr as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,se as defaultTranslations,fe as useIlamyCalendarContext};
@@ -1 +1 @@
1
- import{e,F,u,S}from"../shared/chunk-d7599sry.js";import{c,h,j}from"../shared/chunk-w4nsrq2y.js";import{t}from"../shared/chunk-4jynmg6d.js";import{List as M}from"lucide-react";import{createElement as H}from"react";import{useIlamyCalendarContext as Y}from"@ilamy/calendar";var P={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")})},W={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},l=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return P[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return W[a]};var V=(a,n,r)=>{if(a.allDay)return u(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},I=(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"),d=n.start.startOf("day");while(d.isSameOrBefore(o)){let s=d.startOf("day"),m=d.endOf("day"),i=a.filter((y)=>V(y,s,m)).sort(I);if(i.length>0)r.push({key:d.format("YYYY-MM-DD"),date:s,events:i});d=d.add(1,"day")}return r};import{useIlamyCalendarContext as L}from"@ilamy/calendar";import{useIlamyCalendarContext as T}from"@ilamy/calendar";import{jsx as p,jsxs as B}from"react/jsx-runtime";var G=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:d}=T(),s=a.start.format(G(o)),m=a.allDay?r("allDay"):s,i=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(i,"day")+1,R=n.startOf("day").diff(i,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return B("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>d(a),type:"button",children:[p("span",{className:"text-muted-foreground w-20 shrink-0",children:m}),p("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),p("span",{className:"truncate",children:a.title}),x&&p("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as f,jsxs as b}from"react/jsx-runtime";var k=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=L(),o=F(a.date,t()),d;if(r)d=(s)=>r({...s,view:n});return b("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":S("agenda-day",a.key),children:[f("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:f(h,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),b("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&f(j,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:d}),a.events.map((s)=>f(O,{day:a.date,event:s},S(a.key,s.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var C=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:d}=Y(),s=l(n,a,d),m=r(s.start,s.end),i=v(m,s);if(i.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(c,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:i.map((y)=>g(k,{group:y},y.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:M,navigationStep:A(a),range:(n,r)=>l(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>H(C,{window:a})});var z=(a={})=>({name:"agenda",views:[D(a)]});export{z as agendaPlugin,D as createAgendaView};
1
+ import{e,Y,d,T}from"../shared/chunk-tfk3a0d4.js";import{u,b,U}from"../shared/chunk-xf8cy2gp.js";import{t}from"../shared/chunk-cn24081x.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=Y(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(U,{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};
@@ -325,8 +325,8 @@ interface IlamyPlugin {
325
325
  children: ReactNode2;
326
326
  }>;
327
327
  }
328
- import dayjs from "dayjs";
329
- type Dayjs3 = dayjs.Dayjs3;
328
+ import { Dayjs as DayjsInstance } from "dayjs";
329
+ type Dayjs3 = DayjsInstance;
330
330
  interface CellInfo {
331
331
  /** Start date/time of the cell */
332
332
  start: Dayjs3;
@@ -1 +1 @@
1
- import{t}from"../shared/chunk-4jynmg6d.js";import{useIlamyCalendarContext as V}from"@ilamy/calendar";import{useRef as J,useState as Q}from"react";import{createPortal as Z}from"react-dom";import{useEffect as U,useRef as H}from"react";var M=(n,e)=>{let o=Math.min(n.top,e.top),l=Math.min(n.left,e.left),i=Math.max(n.left+n.width,e.left+e.width),s=Math.max(n.top+n.height,e.top+e.height);return{top:o,left:l,width:i-l,height:s-o}},I=(n,e)=>{let o=Math.max(n.top,e.top),l=Math.max(n.left,e.left),i=Math.min(n.left+n.width,e.left+e.width),s=Math.min(n.top+n.height,e.top+e.height),u=i-l,m=s-o;if(u<=0||m<=0)return null;return{top:o,left:l,width:u,height:m}},A=(n,e,o)=>{let l=0,i=0;if(n.clientY<e.top+o.edge)i=-o.speed;else if(n.clientY>e.top+e.height-o.edge)i=o.speed;if(n.clientX<e.left+o.edge)l=-o.speed;else if(n.clientX>e.left+e.width-o.edge)l=o.speed;let s=o.axis??"both";return{x:s==="y"?0:l,y:s==="x"?0:i}};var O=new Set(["auto","scroll","overlay"]),j=(n)=>{let e=getComputedStyle(n),o=O.has(e.overflowY)&&n.scrollHeight>n.clientHeight,l=O.has(e.overflowX)&&n.scrollWidth>n.clientWidth;return o||l},X=(n)=>{let e=n instanceof HTMLElement?n:null;while(e){if(j(e))return e;e=e.parentElement}return null};var C=(n,e,o=2)=>Math.hypot(n,e)>=o,_=(n,e)=>{let o=n.allDay===e.allDay,l=n.resourceId===e.resourceId;return o&&l},k=(n,e)=>{let o=n.start.isAfter(e.start),l=o?e:n,i=o?n:e;return{start:l.start,end:i.end,allDay:l.allDay,resourceId:l.resourceId}};var z=400,W=10,q=40,K=5;function Y(n){let e=H(n);e.current=n;let o=H(null);U(()=>{let l=()=>{document.body.style.setProperty("user-select","none"),document.body.style.setProperty("-webkit-user-select","none")},i=()=>{document.body.style.removeProperty("user-select"),document.body.style.removeProperty("-webkit-user-select")},s=null,u=()=>{if(s!==null)clearTimeout(s),s=null},m=null,p=null,y=null,P=()=>{if(y!==null)cancelAnimationFrame(y),y=null},E=()=>{y=null;let r=o.current;if(!r?.active)return;if(!m||!p)return;let c=A(p,m.getBoundingClientRect(),{edge:q,speed:K,axis:e.current.scrollAxis});if(c.x===0&&c.y===0)return;m.scrollBy({left:c.x,top:c.y,behavior:"instant"}),e.current.onMove(p,r.payload),y=requestAnimationFrame(E)},R=()=>{if(y===null)y=requestAnimationFrame(E)},v=(r)=>{if(o.current?.active)r.preventDefault()},d=(r)=>{r.stopImmediatePropagation(),r.preventDefault(),window.removeEventListener("click",d,{capture:!0})},f=()=>{u(),P(),window.removeEventListener("touchmove",v),i(),m=null,p=null,o.current=null},a=()=>{let r=o.current!==null;if(f(),r)e.current.onCancel?.()},g=(r)=>{if(r.active=!0,u(),l(),window.getSelection()?.removeAllRanges(),r.pointerType==="touch")window.addEventListener("touchmove",v,{passive:!1});e.current.onStart?.(r.payload)},w=(r)=>{if(r.button!==0||!r.isPrimary)return;let c=e.current.resolvePress(r);if(c===null)return;u();let h={pointerId:r.pointerId,pointerType:r.pointerType,originX:r.clientX,originY:r.clientY,payload:c,active:!1};if(o.current=h,m=X(r.target),r.pointerType==="touch"){let T=e.current.longPressMs??z;s=setTimeout(()=>{if(o.current===h)g(h)},T)}},x=(r,c)=>{let h=c.clientX-r.originX,T=c.clientY-r.originY;if(r.pointerType==="touch"){let N=e.current.touchCancelSlopPx??W;if(C(h,T,N))a();return!1}if(!C(h,T,e.current.thresholdPx))return!1;return g(r),!0},S=(r)=>{let c=o.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active&&!x(c,r))return;p={clientX:r.clientX,clientY:r.clientY},e.current.onMove(p,c.payload),R()},b=(r)=>{let c=o.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active){f();return}window.addEventListener("click",d,{capture:!0});let{payload:h}=c;f(),e.current.onEnd(h)},L=(r)=>{if(r.key==="Escape")a()};return document.addEventListener("pointerdown",w),window.addEventListener("pointermove",S),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",a),window.addEventListener("blur",a),window.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",w),window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",a),window.removeEventListener("blur",a),window.removeEventListener("keydown",L),window.removeEventListener("click",d,{capture:!0}),window.removeEventListener("touchmove",v),u(),P(),i()}},[])}var D=(n,e)=>{let o=n?.closest("[data-start]");if(!o)return null;if(o.dataset.disabled==="true")return null;let l=o.dataset.start,i=o.dataset.end;if(!l||!i)return null;let s=(u)=>e?t.utc(u).tz(e):t.utc(u).local();return{start:s(l),end:s(i),resourceId:o.dataset.resourceId,allDay:o.dataset.allDay==="true",element:o}};import{jsx as B,jsxs as ne,Fragment as te}from"react/jsx-runtime";var G=(n,e)=>{let o=M(n.element.getBoundingClientRect(),e.element.getBoundingClientRect()),l=n.element.closest("[data-calendar-scroll-content]");if(l instanceof HTMLElement){let u=l.getBoundingClientRect();return{rect:{top:o.top-u.top,left:o.left-u.left,width:o.width,height:o.height},content:l}}let i=n.element.closest("[data-calendar-viewport]");if(!i)return{rect:o,content:null};let s=I(o,i.getBoundingClientRect());if(!s)return null;return{rect:s,content:null}};function ee({rect:n,content:e}){return Z(B("div",{"aria-hidden":"true",className:`pointer-events-none ${e?"absolute z-15":"fixed z-50"} rounded-sm border border-primary bg-primary/20`,style:{top:n.top,left:n.left,width:n.width,height:n.height}}),e??document.body)}function F({children:n,options:e}){let{openEventForm:o,resources:l,timezone:i,orientation:s}=V(),[u,m]=Q(null),p=J(null),E=l.length>0?s==="vertical"?"y":"x":"both",R=()=>{p.current=null,m(null)},v=(d,f)=>{let a=k(d,f),g=l.find((x)=>String(x.id)===a.resourceId),w={start:a.start,end:a.end,resource:g,allDay:a.allDay};if(e.onSelect)e.onSelect(w,o);else o({start:a.start,end:a.end,allDay:a.allDay,resourceId:a.resourceId})};return Y({scrollAxis:E,resolvePress:(d)=>D(d.target,i),onStart:(d)=>{p.current=d,m(G(d,d))},onMove:({clientX:d,clientY:f},a)=>{let g=D(document.elementFromPoint(d,f),i);if(g&&_(a,g))p.current=g;let w=p.current??a;m(G(a,w))},onEnd:(d)=>{let f=p.current??d;v(d,f),R()},onCancel:R}),ne(te,{children:[n,u&&B(ee,{...u})]})}import{jsx as re}from"react/jsx-runtime";var oe=(n={})=>({name:"drag-to-create",provider:({children:e})=>re(F,{options:n,children:e})});export{oe as dragToCreatePlugin};
1
+ import{t}from"../shared/chunk-cn24081x.js";import{useIlamyCalendarContext as V}from"@ilamy/calendar";import{useRef as J,useState as Q}from"react";import{createPortal as Z}from"react-dom";import{useEffect as U,useRef as H}from"react";var M=(n,e)=>{let o=Math.min(n.top,e.top),l=Math.min(n.left,e.left),i=Math.max(n.left+n.width,e.left+e.width),s=Math.max(n.top+n.height,e.top+e.height);return{top:o,left:l,width:i-l,height:s-o}},I=(n,e)=>{let o=Math.max(n.top,e.top),l=Math.max(n.left,e.left),i=Math.min(n.left+n.width,e.left+e.width),s=Math.min(n.top+n.height,e.top+e.height),u=i-l,m=s-o;if(u<=0||m<=0)return null;return{top:o,left:l,width:u,height:m}},A=(n,e,o)=>{let l=0,i=0;if(n.clientY<e.top+o.edge)i=-o.speed;else if(n.clientY>e.top+e.height-o.edge)i=o.speed;if(n.clientX<e.left+o.edge)l=-o.speed;else if(n.clientX>e.left+e.width-o.edge)l=o.speed;let s=o.axis??"both";return{x:s==="y"?0:l,y:s==="x"?0:i}};var O=new Set(["auto","scroll","overlay"]),j=(n)=>{let e=getComputedStyle(n),o=O.has(e.overflowY)&&n.scrollHeight>n.clientHeight,l=O.has(e.overflowX)&&n.scrollWidth>n.clientWidth;return o||l},X=(n)=>{let e=n instanceof HTMLElement?n:null;while(e){if(j(e))return e;e=e.parentElement}return null};var C=(n,e,o=2)=>Math.hypot(n,e)>=o,_=(n,e)=>{let o=n.allDay===e.allDay,l=n.resourceId===e.resourceId;return o&&l},k=(n,e)=>{let o=n.start.isAfter(e.start),l=o?e:n,i=o?n:e;return{start:l.start,end:i.end,allDay:l.allDay,resourceId:l.resourceId}};var z=400,W=10,q=40,K=5;function Y(n){let e=H(n);e.current=n;let o=H(null);U(()=>{let l=()=>{document.body.style.setProperty("user-select","none"),document.body.style.setProperty("-webkit-user-select","none")},i=()=>{document.body.style.removeProperty("user-select"),document.body.style.removeProperty("-webkit-user-select")},s=null,u=()=>{if(s!==null)clearTimeout(s),s=null},m=null,p=null,y=null,P=()=>{if(y!==null)cancelAnimationFrame(y),y=null},E=()=>{y=null;let r=o.current;if(!r?.active)return;if(!m||!p)return;let c=A(p,m.getBoundingClientRect(),{edge:q,speed:K,axis:e.current.scrollAxis});if(c.x===0&&c.y===0)return;m.scrollBy({left:c.x,top:c.y,behavior:"instant"}),e.current.onMove(p,r.payload),y=requestAnimationFrame(E)},R=()=>{if(y===null)y=requestAnimationFrame(E)},v=(r)=>{if(o.current?.active)r.preventDefault()},d=(r)=>{r.stopImmediatePropagation(),r.preventDefault(),window.removeEventListener("click",d,{capture:!0})},f=()=>{u(),P(),window.removeEventListener("touchmove",v),i(),m=null,p=null,o.current=null},a=()=>{let r=o.current!==null;if(f(),r)e.current.onCancel?.()},g=(r)=>{if(r.active=!0,u(),l(),window.getSelection()?.removeAllRanges(),r.pointerType==="touch")window.addEventListener("touchmove",v,{passive:!1});e.current.onStart?.(r.payload)},w=(r)=>{if(r.button!==0||!r.isPrimary)return;let c=e.current.resolvePress(r);if(c===null)return;u();let h={pointerId:r.pointerId,pointerType:r.pointerType,originX:r.clientX,originY:r.clientY,payload:c,active:!1};if(o.current=h,m=X(r.target),r.pointerType==="touch"){let T=e.current.longPressMs??z;s=setTimeout(()=>{if(o.current===h)g(h)},T)}},x=(r,c)=>{let h=c.clientX-r.originX,T=c.clientY-r.originY;if(r.pointerType==="touch"){let N=e.current.touchCancelSlopPx??W;if(C(h,T,N))a();return!1}if(!C(h,T,e.current.thresholdPx))return!1;return g(r),!0},S=(r)=>{let c=o.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active&&!x(c,r))return;p={clientX:r.clientX,clientY:r.clientY},e.current.onMove(p,c.payload),R()},b=(r)=>{let c=o.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active){f();return}window.addEventListener("click",d,{capture:!0});let{payload:h}=c;f(),e.current.onEnd(h)},L=(r)=>{if(r.key==="Escape")a()};return document.addEventListener("pointerdown",w),window.addEventListener("pointermove",S),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",a),window.addEventListener("blur",a),window.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",w),window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",a),window.removeEventListener("blur",a),window.removeEventListener("keydown",L),window.removeEventListener("click",d,{capture:!0}),window.removeEventListener("touchmove",v),u(),P(),i()}},[])}var D=(n,e)=>{let o=n?.closest("[data-start]");if(!o)return null;if(o.dataset.disabled==="true")return null;let l=o.dataset.start,i=o.dataset.end;if(!l||!i)return null;let s=(u)=>e?t.utc(u).tz(e):t.utc(u).local();return{start:s(l),end:s(i),resourceId:o.dataset.resourceId,allDay:o.dataset.allDay==="true",element:o}};import{jsx as B,jsxs as ne,Fragment as te}from"react/jsx-runtime";var G=(n,e)=>{let o=M(n.element.getBoundingClientRect(),e.element.getBoundingClientRect()),l=n.element.closest("[data-calendar-scroll-content]");if(l instanceof HTMLElement){let u=l.getBoundingClientRect();return{rect:{top:o.top-u.top,left:o.left-u.left,width:o.width,height:o.height},content:l}}let i=n.element.closest("[data-calendar-viewport]");if(!i)return{rect:o,content:null};let s=I(o,i.getBoundingClientRect());if(!s)return null;return{rect:s,content:null}};function ee({rect:n,content:e}){return Z(B("div",{"aria-hidden":"true",className:`pointer-events-none ${e?"absolute z-15":"fixed z-50"} rounded-sm border border-primary bg-primary/20`,style:{top:n.top,left:n.left,width:n.width,height:n.height}}),e??document.body)}function F({children:n,options:e}){let{openEventForm:o,resources:l,timezone:i,orientation:s}=V(),[u,m]=Q(null),p=J(null),E=l.length>0?s==="vertical"?"y":"x":"both",R=()=>{p.current=null,m(null)},v=(d,f)=>{let a=k(d,f),g=l.find((x)=>String(x.id)===a.resourceId),w={start:a.start,end:a.end,resource:g,allDay:a.allDay};if(e.onSelect)e.onSelect(w,o);else o({start:a.start,end:a.end,allDay:a.allDay,resourceId:a.resourceId})};return Y({scrollAxis:E,resolvePress:(d)=>D(d.target,i),onStart:(d)=>{p.current=d,m(G(d,d))},onMove:({clientX:d,clientY:f},a)=>{let g=D(document.elementFromPoint(d,f),i);if(g&&_(a,g))p.current=g;let w=p.current??a;m(G(a,w))},onEnd:(d)=>{let f=p.current??d;v(d,f),R()},onCancel:R}),ne(te,{children:[n,u&&B(ee,{...u})]})}import{jsx as re}from"react/jsx-runtime";var oe=(n={})=>({name:"drag-to-create",provider:({children:e})=>re(F,{options:n,children:e})});export{oe as dragToCreatePlugin};