@ilamy/calendar 3.2.1 → 3.3.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/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import{t}from"./shared/chunk-nvtnncwx.js";import{R,w,S,G,P,W}from"./shared/chunk-pg39xa62.js";import{se,r,fe,l,g,K,de,ce,ie,p,O,I,M,a,i,L,q,n,X,Z,Q,H,ue,B,J,x,F,A,z,ee,te,re,ne,oe,j,ae,me,_}from"./shared/chunk-j4pfc0hb.js";import{e,d,N,pe}from"./shared/chunk-89xfgjfh.js";import{o,v,m,s,C,D,E,h,f}from"./shared/chunk-j4ngnkkv.js";import{u,y}from"./shared/chunk-bgegqhb4.js";var mr="event-form",ur="event-mutation-scope",pr=({event:c,onChange:b})=>r((k)=>k.renderSlot)(mr,{event:c,onChange:b}),gt=({dialog:c,onResolve:b,onCancel:T})=>{let k=r((le)=>le.getEventManager);if(!(c.isOpen&&c.event))return null;let V=k(c.event),Y={event:c.event,operation:c.operation,resolve:b,cancel:T};return V?.renderSlot?.(ur,Y)};import{useEffect as li,useMemo as di}from"react";import{DndContext as Pn}from"@dnd-kit/core";import{useId as Tn}from"react";import{MouseSensor as an,TouchSensor as sn,useSensor as gr,useSensors as ln}from"@dnd-kit/core";import{useEffect as dn,useRef as vt,useState as cn}from"react";var on=(c)=>c.hour!==void 0,Gt=(c,b,T=g)=>{let{date:k,hour:V=0,minute:Y=0,allDay:le}=b,U=c.end.diff(c.start,"second"),ge=(Ce)=>({start:Ce,end:Ce.add(U,"second")});if(on(b)){let we=t(k).hour(V).minute(Y).subtract(T.minutes,"minute");return{...ge(we),allDay:!1}}let ye=t(k).subtract(T.days,"day"),ve=le===!0,De=Boolean(c.allDay);if(ve||De)return{...ge(ye.startOf("day")),allDay:!0};let xe=ye.format("YYYY-MM-DD"),be=c.start.format("HH:mm:ss.SSS"),Ee=t(`${xe}T${be}`);return{...ge(Ee),allDay:!1}},nn=(c,b,T)=>{if(T===void 0||b===T)return{};if(!c.resourceIds)return{resourceId:T};let V=c.resourceIds.indexOf(b);if(V===-1)return{};let Y=c.resourceIds.slice();if(Y.splice(V,1),!Y.includes(T))Y.push(T);return{resourceIds:Y}},fr=(c,b,T=g)=>{let{active:k,over:V}=c;if(!k||!V||!b)return null;let Y=V.data.current||{};if(Y.disabled)return null;let{resourceId:le}=Y,{start:U,end:ge,allDay:ye}=Gt(b,Y,T),ve=k.data.current?.sourceResourceId,De={start:U,end:ge,...nn(b,ve,le),allDay:ye};return{activeEvent:b,updates:De}};var mn=(c,b)=>{if(!c)return!1;let T=c.start.isSame(b.start)&&c.end.isSame(b.end),k=c.resourceId===b.resourceId&&c.allDay===b.allDay,V=c.isDropAllowed===b.isDropAllowed;return T&&k&&V},un=({active:c,activatorEvent:b})=>{if(c.data.current?.type!=="calendar-event")return null;let T=c.data.current.event,k=c.data.current.dragSegment;if(!k)return{calendarEvent:T,pending:null};let V=c.data.current.getBarRect;return{calendarEvent:T,pending:{calendarEvent:T,segment:k,activatorEvent:b,barRect:V?.()}}},pn=(c,b,T)=>{let k=b??{},{start:V,end:Y,allDay:le}=Gt(c,k,T);return{event:c,start:V,end:Y,resourceId:k.resourceId??c.resourceId,allDay:le,isDropAllowed:!k.disabled}},fn=(c)=>{let b=ce(c);dn(()=>{if(!b)return;let T=document.body.style.cursor;return document.body.style.cursor=b,()=>{document.body.style.cursor=T}},[b])},gn={activationConstraint:{distance:2}},vn={activationConstraint:{delay:100,tolerance:5}},yn=()=>{let c=gr(an,gn),b=gr(sn,vn);return ln(c,b)},vr=(c)=>{let b=r((be)=>be.slotDuration),T=yn(),k=vt(null),V=vt(g),Y=vt(null),le=vt(null),[U,ge]=cn(null);fn(U);let ye=()=>{k.current=null,V.current=g,Y.current=null,ge(null),le.current?.setActiveEvent(null)},ve=(be)=>{let Ee=un(be);if(!Ee)return;le.current?.setActiveEvent(Ee.calendarEvent),k.current=Ee.calendarEvent,V.current=g,Y.current=Ee.pending},De=(be)=>{let Ee=Y.current;if(!Ee)return;let Ce=Ee.barRect??be.active.rect.current.initial;if(!Ce)return;V.current=de({activeEvent:Ee.calendarEvent,initialRect:Ce,activatorEvent:Ee.activatorEvent,segment:Ee.segment,slotDurationMinutes:b}),Y.current=null};return{sensors:T,dragPreview:U,overlayRef:le,handlers:{onDragStart:ve,onDragOver:(be)=>{De(be);let Ee=k.current;if(!Ee||!be.over){ge(null);return}let Ce=pn(Ee,be.over.data.current,V.current);ge((we)=>{if(mn(we,Ce))return we;return Ce})},onDragEnd:(be)=>{let Ee=fr(be,k.current,V.current);if(Ee)c(Ee.activeEvent,Ee.updates);ye()},onDragCancel:ye}}};import{useCallback as yt,useEffect as Dn,useRef as Cn,useState as hn}from"react";var Bt={isOpen:!1,operation:"edit",event:null};function Dt(c){let{applyScopedEdit:b,applyScopedDelete:T}=r((ve)=>({applyScopedEdit:ve.applyScopedEdit,applyScopedDelete:ve.applyScopedDelete})),[k,V]=hn(Bt),Y=Cn(k);Dn(()=>{Y.current=k},[k]);let le=yt((ve,De)=>{V({isOpen:!0,operation:"edit",event:ve,updates:De})},[]),U=yt((ve)=>{V({isOpen:!0,operation:"delete",event:ve})},[]),ge=yt(()=>V(Bt),[]),ye=yt((ve)=>{let De=Y.current;if(!De.event)return;if(De.operation==="edit")b(De.event,De.updates??{},ve);else T(De.event,ve);V(Bt),c?.()},[b,T,c]);return{dialogState:k,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}}var yr=()=>{let{updateEvent:c,getEventManager:b}=r((U)=>({updateEvent:U.updateEvent,getEventManager:U.getEventManager})),{dialogState:T,openEditDialog:k,closeDialog:V,handleConfirm:Y}=Dt();return{commitDrop:(U,ge)=>{let ye=Object.keys(ge).length===0;if(!U.id||ye)return;if(b(U)?.applyEdit){k(U,ge);return}c(U.id,ge)},scopeDialog:{dialog:T,onCancel:V,onResolve:Y}}};import{pointerWithin as En}from"@dnd-kit/core";var Dr=(c)=>{let{droppableContainers:b,droppableRects:T,pointerCoordinates:k}=c;if(!k)return[];let{x:V,y:Y}=k,le=(ge)=>{if(!(ge.top<=Y))return!1;if(!(Y<=ge.bottom))return!1;if(!(ge.left<=V))return!1;return V<=ge.right},U=b.filter((ge)=>{let ye=T.get(ge.id);return ye!==void 0&&le(ye)});return En({...c,droppableContainers:U})};import{DragOverlay as bn}from"@dnd-kit/core";import{snapCenterToCursor as Sn}from"@dnd-kit/modifiers";import{useImperativeHandle as xn,useState as wn}from"react";import{jsx as Cr}from"react/jsx-runtime";var hr=({ref:c})=>{let[b,T]=wn(null),k=p();if(xn(c,()=>({setActiveEvent:T})),k)return null;return Cr(bn,{modifiers:[Sn],children:b&&Cr("div",{className:e("cursor-grabbing truncate rounded-md px-3 py-1.5 text-xs font-medium shadow-xl opacity-80",O(b)),style:I(b),children:b.title})})};import{jsx as zt,jsxs as Er}from"react/jsx-runtime";function br({children:c}){let b=Tn(),T=r((ve)=>ve.disableDragAndDrop),{commitDrop:k,scopeDialog:V}=yr(),{sensors:Y,dragPreview:le,overlayRef:U,handlers:ge}=vr(k),ye=le!==null;if(T)return c;return Er(ie.Provider,{value:le,children:[Er(Pn,{collisionDetection:Dr,id:b,sensors:Y,...ge,children:[zt("div",{className:"contents","data-dragging":ye?"true":void 0,children:c}),zt(hr,{ref:U})]}),zt(gt,{...V})]})}import{ChevronDownIcon as Rn}from"lucide-react";import{useEffect as Nn,useState as kn}from"react";import*as Ge from"@radix-ui/react-popover";import{jsx as Ct}from"react/jsx-runtime";function je({...c}){return Ct(Ge.Root,{"data-slot":"popover",...c})}function _e({...c}){return Ct(Ge.Trigger,{"data-slot":"popover-trigger",...c})}function Ye({className:c,align:b="center",sideOffset:T=4,...k}){return Ct(Ge.Portal,{children:Ct(Ge.Content,{align:b,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",c),"data-slot":"popover-content",sideOffset:T,...k})})}import{jsx as $e,jsxs as st}from"react/jsx-runtime";var Sr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,jt=(c)=>Boolean(c&&Sr.test(c)),Mn=(c)=>{let b=c.match(/bg-([a-z]+)-\d+/)?.at(1);if(!b)return"Custom";return b.charAt(0).toUpperCase()+b.slice(1)};function xr({value:c,onChange:b,swatches:T=[],className:k,"aria-label":V="Select color"}){let[Y,le]=kn(jt(c)?c:"");Nn(()=>{le(jt(c)?c:"")},[c]);let U=(De)=>{let he=De.target.value;if(le(he),Sr.test(he))b(he)},ge=jt(c),ye=T.find((De)=>De.value===c),ve;if(ye)ve=ye.label;else if(ge)ve=c;else if(c)ve=Mn(c);else ve="Pick a color";return st(je,{children:[st(_e,{"aria-label":V,className:e("border-input focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 text-sm shadow-xs outline-none focus-visible:ring-[3px]",k),"data-slot":"color-picker-trigger",type:"button",children:[st("span",{className:"flex items-center gap-2",children:[$e("span",{className:e("size-5 shrink-0 rounded-full border",!ge&&c),style:ge?{backgroundColor:c}:void 0}),$e("span",{className:e(ge&&"font-mono text-xs"),children:ve})]}),$e(Rn,{className:"size-4 shrink-0 opacity-50"})]}),st(Ye,{className:"w-56","data-slot":"color-picker-content",children:[T.length>0&&$e("div",{className:"grid grid-cols-7 gap-1.5",children:T.map((De)=>{let he=c===De.value;return $e("button",{"aria-label":De.label,"aria-pressed":he,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",De.value,he&&"ring-ring ring-2 ring-offset-1"),onClick:()=>b(De.value),type:"button"},De.value)})}),$e("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),st("div",{className:"flex items-center gap-2",children:[$e("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(De)=>b(De.target.value),type:"color",value:ge?c:"#000000"}),$e(m,{"aria-label":"Hex color",className:"font-mono",onChange:U,placeholder:"#000000",value:Y})]})]})]})}import{jsx as Hn}from"react/jsx-runtime";function wr({className:c,...b}){return Hn("textarea",{className:e("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",c),"data-slot":"textarea",...b})}import{useEffect as Zn,useState as Ae}from"react";import{PopoverClose as Bn}from"@radix-ui/react-popover";import{Calendar as zn}from"lucide-react";import{useEffect as jn,useRef as _n,useState as Yn}from"react";import{useState as An}from"react";import{ChevronLeftIcon as On,ChevronRightIcon as In}from"lucide-react";import{jsx as lt,jsxs as Vn}from"react/jsx-runtime";function Je({label:c,onPrev:b,onNext:T,prevLabel:k,nextLabel:V}){return Vn("div",{className:"mb-2 flex items-center justify-between",children:[lt(o,{"aria-label":k,onClick:b,size:"icon",variant:"ghost",children:lt(On,{className:"size-4"})}),lt("div",{className:"text-sm font-medium select-none",children:c}),lt(o,{"aria-label":V,onClick:T,size:"icon",variant:"ghost",children:lt(In,{className:"size-4"})})]})}import{jsx as Be,jsxs as Pr}from"react/jsx-runtime";function Ln(c){let b=c.weekHover&&!c.isCurrentWeek;return e("p-0 text-center",c.weekHover&&"first:rounded-l-md last:rounded-r-md",b&&"group-hover/week:bg-accent",c.isCurrentWeek&&"bg-primary")}function Fn(c){return e("w-full aspect-square text-sm select-none",!c.isDisabled&&"cursor-pointer",!(c.weekHover||c.isDisabled)&&"hover:bg-accent rounded-md",c.isOutside&&"text-muted-foreground/50",c.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",c.isCurrentWeek&&"text-primary-foreground font-medium",c.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",c.isDisabled&&"opacity-50 cursor-not-allowed")}function Gn({day:c,state:b,onSelect:T}){return Be("td",{className:Ln(b),"data-disabled":b.isDisabled,"data-outside":b.isOutside,"data-selected":b.isSelected,role:"gridcell",tabIndex:-1,children:Be("button",{"aria-disabled":b.isDisabled,"aria-hidden":b.isOutside,className:Fn(b),"data-disabled":b.isDisabled,"data-selected":b.isSelected,disabled:b.isDisabled||b.isOutside,onClick:()=>T?.(c.toDate()),tabIndex:b.isOutside?-1:0,type:"button",children:c.format("D")})})}function dt({selected:c,defaultMonth:b,onSelect:T,disabled:k,firstDayOfWeek:V=0,className:Y,weekHover:le=!1,highlightedWeekOf:U}){let[ge,ye]=An(()=>t(b??c??new Date).startOf("month")),ve=L(ge,V),De=c?t(c).format("YYYY-MM-DD"):void 0,he=i(t(),V).map((Ce)=>Ce.format("dd")),xe,be;if(U){let Ce=i(U,V);xe=Ce.at(0),be=Ce.at(-1)}let Ee=(Ce)=>{let we=Ce.format("YYYY-MM-DD")===De,Te=!1;if(xe&&be){let Ne=!Ce.isBefore(xe,"day"),Pe=!Ce.isAfter(be,"day");Te=Ne&&Pe}return{isOutside:!Ce.isSame(ge,"month"),isSelected:we,isDisabled:k?.(Ce.toDate())??!1,isCurrent:a(Ce)&&!we,isCurrentWeek:Te,weekHover:le}};return Pr("div",{className:e("bg-background p-3 w-72",Y),"data-slot":"calendar",children:[Be(Je,{label:ge.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>ye((Ce)=>Ce.add(1,"month")),onPrev:()=>ye((Ce)=>Ce.subtract(1,"month")),prevLabel:"Previous month"}),Pr("table",{className:"w-full border-collapse",role:"grid",children:[Be("thead",{children:Be("tr",{children:he.map((Ce,we)=>Be("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:Ce},we))})}),Be("tbody",{children:ve.map((Ce,we)=>Be("tr",{className:e(le&&"group/week"),children:Ce.map((Te)=>Be(Gn,{day:Te,onSelect:T,state:Ee(Te)},Te.toISOString()))},we))})]})]})}import{jsx as et,jsxs as _t}from"react/jsx-runtime";function Tr({date:c,closeOnSelect:b,onChange:T,label:k="Pick a date",className:V,disabled:Y}){let le=r((De)=>De.firstDayOfWeek),U=_n(null),[ge,ye]=Yn(c);jn(()=>{ye(c)},[c]);let ve=(De)=>{if(ye(De),b)U.current?.click();T?.(De)};return et("div",{className:V,children:_t(je,{children:[et(_e,{asChild:!0,children:_t(o,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!c,variant:"outline",children:[et(zn,{}),ge?t(ge).format("ll"):et("span",{children:k})]})}),_t(Ye,{align:"start",className:"w-auto p-0",children:[et(Bn,{ref:U,style:{display:"none"}}),et(dt,{defaultMonth:ge,disabled:Y,firstDayOfWeek:le,onSelect:ve,selected:ge})]})]})})}import{Clock as Wn}from"lucide-react";import{useEffect as Un,useRef as Nr,useState as Yt}from"react";import{useMemo as $n}from"react";function Rr({timeFormat:c="12-hour",minTime:b="00:00",maxTime:T="23:45"}){return{timeOptions:$n(()=>{let Y=[],[le,U]=b.split(":").map(Number),[ge,ye]=T.split(":").map(Number),ve=le*60+U,De=ge*60+ye;for(let he=ve;he<=De;he+=15){let xe=Math.floor(he/60),be=he%60,Ee=`${xe.toString().padStart(2,"0")}:${be.toString().padStart(2,"0")}`;Y.push(Ee)}return Y},[b,T]),formatTime:(Y)=>{let[le,U]=Y.split(":").map(Number);if(c==="24-hour")return`${le.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`;let ge=le>=12?"PM":"AM",ye=le;if(le===0)ye=12;else if(le>12)ye=le-12;return`${ye}:${U.toString().padStart(2,"0")} ${ge}`}}}import{jsx as We,jsxs as $t}from"react/jsx-runtime";var Kn=(c)=>{c.stopPropagation()};function kr({value:c,onChange:b,minTime:T="00:00",maxTime:k="23:45",timeFormat:V="12-hour",placeholder:Y="Select time...",className:le,disabled:U=!1,name:ge}){let[ye,ve]=Yt(!1),[De,he]=Yt(""),xe=Nr(null),be=Nr(null),[Ee,Ce]=Yt(0),{timeOptions:we,formatTime:Te}=Rr({timeFormat:V,minTime:T,maxTime:k}),Ne=we.filter((He)=>Te(He).toLowerCase().includes(De.toLowerCase())),Pe=(He)=>{b(He),ve(!1),he("")};Un(()=>{if(ye){if(be.current)Ce(be.current.offsetWidth);setTimeout(()=>{xe.current?.focus()},0)}},[ye]);let Ve=c?Te(c):Y;return $t(je,{onOpenChange:ve,open:ye,children:[We(_e,{asChild:!0,children:$t(o,{"aria-controls":"time-picker-listbox","aria-expanded":ye,className:e("w-full justify-start",le),"data-testid":n.timePicker(ge),disabled:U,ref:be,role:"combobox",variant:"outline",children:[We(Wn,{className:"mr-2 h-4 w-4"}),Ve]})}),$t(Ye,{align:"start",className:"p-0",style:{width:Ee},children:[We("div",{className:"p-2 border-b",children:We(m,{className:"h-8",onChange:(He)=>he(He.target.value),placeholder:"Search time...",ref:xe,value:De})}),We(u,{className:"h-[200px]",onWheel:Kn,children:We("div",{className:"p-1",children:Ne.length===0?We("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):Ne.map((He)=>{let ut=Te(He);return We("button",{className:e("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",He===c&&"bg-accent text-accent-foreground"),onClick:()=>Pe(He),type:"button",children:ut},He)})})})]})]})}var Mr=(c,b)=>{let[T,k]=b.split(":").map(Number);return t(c).hour(T).minute(k).second(0).millisecond(0)},Hr=(c,b,T)=>{let k=Mr(c,b);return T?k.hour(0).minute(0):k},Or=(c,b,T)=>{let k=Mr(c,b);return T?k.add(1,"day").startOf("day"):k},Wt=(c,b)=>{if(!b)return{min:"00:00",max:"23:59"};let T=t(c),{minStart:k,maxEnd:V,hasBusinessHours:Y}=J({allDates:[T],businessHours:b,hideNonBusinessHours:!1});if(!Y)return{min:"00:00",max:"23:59"};return{min:`${k.toString().padStart(2,"0")}:00`,max:`${(V-1).toString().padStart(2,"0")}:45`}};import{jsx as Re,jsxs as Oe,Fragment as ea}from"react/jsx-runtime";var Ir="bg-blue-100 text-blue-800",qn=[{value:Ir,label:"Blue"},{value:"bg-green-100 text-green-800",label:"Green"},{value:"bg-purple-100 text-purple-800",label:"Purple"},{value:"bg-red-100 text-red-800",label:"Red"},{value:"bg-yellow-100 text-yellow-800",label:"Yellow"},{value:"bg-pink-100 text-pink-800",label:"Pink"},{value:"bg-indigo-100 text-indigo-800",label:"Indigo"},{value:"bg-amber-100 text-amber-800",label:"Amber"},{value:"bg-emerald-100 text-emerald-800",label:"Emerald"},{value:"bg-sky-100 text-sky-800",label:"Sky"},{value:"bg-violet-100 text-violet-800",label:"Violet"},{value:"bg-rose-100 text-rose-800",label:"Rose"},{value:"bg-teal-100 text-teal-800",label:"Teal"},{value:"bg-orange-100 text-orange-800",label:"Orange"}],Vr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Xn=(c,b)=>{if(c&&Vr.test(c))return c;return b??Ir},Qn=(c)=>{if(Vr.test(c))return{backgroundColor:c,color:pe(c)};return{backgroundColor:void 0,color:c}},Jn=({colorChanged:c,hadInitialColor:b,selectedColor:T,initialBackgroundColor:k,initialColor:V})=>{if(c||!b)return Qn(T);return{backgroundColor:k,color:V}},Ut=({name:c,label:b,placeholder:T,value:k,required:V=!1,multiline:Y=!1,onChange:le})=>Oe("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:c,children:b}),Y?Re(wr,{className:"min-h-16 text-sm",id:c,name:c,onChange:le,placeholder:T,required:V,value:k}):Re(m,{className:"h-8 text-sm sm:h-9",id:c,name:c,onChange:le,placeholder:T,required:V,value:k})]}),Ar=({selectedEvent:c,onClose:b,onUpdate:T,onDelete:k,onAdd:V})=>{let{dialogState:Y,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}=Dt(b),{t:ve,timeFormat:De,getEventManager:he,resources:xe}=r((Se)=>({t:Se.t,timeFormat:Se.timeFormat,getEventManager:Se.getEventManager,resources:Se.resources??[]})),{id:be,resourceId:Ee,resourceIds:Ce,start:we=t(),end:Te=t().add(1,"hour"),allDay:Ne=!1,color:Pe,backgroundColor:Ve,title:He="",description:ut="",location:rr=""}=c??{},or=xe.length>0,nr=Ee??Ce?.at(0),ar=or&&nr===void 0,[Mt,Mo]=Ae(nr),Ht=or?Mt:Ee,pt=X(Ht),ir=Boolean(c&&he(c)),Ho=Te.isSame(Te.startOf("day")),Oo=Ne&&Ho?Te.subtract(1,"day"):Te,[Ze,sr]=Ae(we.toDate()),[Qe,Ot]=Ae(Oo.toDate()),[ze,Io]=Ae(Ne),[It,Vo]=Ae(Xn(Ve,Pe)),[Ao,Lo]=Ae(!1),Fo=Boolean(Pe||Ve),Go=(Se)=>{Vo(Se),Lo(!0)},[Vt,lr]=Ae(we.format("HH:mm")),[ft,At]=Ae(Te.format("HH:mm")),[Fe,Bo]=Ae({title:He,description:ut,location:rr}),[Lt,zo]=Ae({}),jo={...c,...Lt},_o=(Se)=>zo((ke)=>({...ke,...Se})),Yo=(Se)=>{if(!Se)return;if(sr(Se),t(Se).isAfter(t(Qe)))Ot(Se)},$o=(Se)=>{if(!Se)return;if(Ot(Se),Se&&t(Se).isBefore(t(Ze)))sr(Se)},Wo=(Se)=>{if(Io(Se),!(Se&&ft==="00:00"))return;Ot((ke)=>t(ke).isAfter(t(Ze),"day")?t(ke).subtract(1,"day").toDate():ke)},Uo=(Se)=>{if(lr(Se),t(Ze).isSame(t(Qe),"day")&&Se>ft)At(Se)},Ko=(Se)=>{if(At(Se),t(Ze).isSame(t(Qe),"day")&&Se<Vt)lr(Se)},Ft=(Se)=>{let{name:ke,value:Ie}=Se.target;Bo((at)=>({...at,[ke]:Ie}))};Zn(()=>{if(ze)At("23:59")},[ze]);let Zo=(Se)=>xe.find((Ie)=>String(Ie.id)===Se)?.id??Se,dr=ar&&Mt===void 0,qo=(Se)=>{if(Se.preventDefault(),dr)return;let ke=Hr(Ze,Vt,ze),Ie=Or(Qe,ft,ze),at=Jn({colorChanged:Ao,hadInitialColor:Fo,selectedColor:It,initialBackgroundColor:Ve,initialColor:Pe}),it={id:be||t().format("YYYYMMDDHHmmss"),title:Fe.title,start:ke,end:Ie,resourceId:Ht,description:Fe.description,location:Fe.location,allDay:ze,...at,...Lt};if(c?.id&&ir){le(c,{title:Fe.title,start:ke,end:Ie,resourceId:Ht,description:Fe.description,location:Fe.location,allDay:ze,color:It,...Lt});return}if(be)T?.(it);else V?.(it);b()},Xo=()=>{if(!c?.id)return;if(ir){U(c);return}k?.(c),b()},cr;if(pt)cr=(Se)=>!B(t(Se),pt);let Qo=Wt(Ze,pt),Jo=Wt(Qe,pt),en=[["startDate",Ze,Yo],["endDate",Qe,$o]],tn=[["startTime","start-time",Vt,Uo,Qo],["endTime","end-time",ft,Ko,Jo]],rn=Mt?.toString();return Oe(ea,{children:[Oe("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:qo,children:[Re(u,{className:"flex-1 min-h-0",children:Oe("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Re(Ut,{label:ve("title"),name:"title",onChange:Ft,placeholder:ve("eventTitlePlaceholder"),required:!0,value:Fe.title}),Re(Ut,{label:ve("description"),multiline:!0,name:"description",onChange:Ft,placeholder:ve("eventDescriptionPlaceholder"),value:Fe.description}),ar&&Oe("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ve("resource")}),Oe(C,{onValueChange:(Se)=>Mo(Zo(Se)),value:rn,children:[Re(E,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:Re(D,{placeholder:ve("selectResource")})}),Re(h,{children:xe.map((Se)=>Re(f,{value:String(Se.id),children:Se.title},String(Se.id)))})]})]}),Oe("div",{className:"flex items-center space-x-2",children:[Re(v,{checked:ze,id:"allDay",onCheckedChange:(Se)=>Wo(Se===!0)}),Re(s,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ve("allDay")})]}),Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:en.map(([Se,ke,Ie])=>Oe("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(Tr,{className:"mt-1",closeOnSelect:!0,date:ke,disabled:cr,onChange:Ie})]},Se))}),!ze&&Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:tn.map(([Se,ke,Ie,at,it])=>Oe("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(kr,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:it.max,minTime:it.min,name:ke,onChange:at,placeholder:ve("searchTime"),timeFormat:De,value:Ie})]},Se))}),Oe("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",children:ve("color")}),Re(xr,{"aria-label":ve("color"),onChange:Go,swatches:qn,value:It})]}),Re(Ut,{label:ve("location"),name:"location",onChange:Ft,placeholder:ve("eventLocationPlaceholder"),value:Fe.location}),Re(pr,{event:jo,onChange:_o})]})}),Oe(G,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[be&&Re(o,{className:"w-full sm:mr-auto sm:w-auto",onClick:Xo,size:"sm",type:"button",variant:"destructive",children:ve("delete")}),Oe("div",{className:"flex w-full gap-2 sm:w-auto",children:[Re(o,{className:"flex-1 sm:flex-none",onClick:b,size:"sm",type:"button",variant:"outline",children:ve("cancel")}),Re(o,{className:"flex-1 sm:flex-none",disabled:dr,size:"sm",type:"submit",children:be?ve("update"):ve("create")})]})]})]}),Re(gt,{dialog:Y,onCancel:ge,onResolve:ye})]})};import{jsx as ht,jsxs as Lr}from"react/jsx-runtime";var Fr=()=>{let{t:c,selectedEvent:b,isEventFormOpen:T,closeEventForm:k,addEvent:V,updateEvent:Y,deleteEvent:le,renderEventForm:U}=r((De)=>({t:De.t,selectedEvent:De.selectedEvent,isEventFormOpen:De.isEventFormOpen,closeEventForm:De.closeEventForm,addEvent:De.addEvent,updateEvent:De.updateEvent,deleteEvent:De.deleteEvent,renderEventForm:De.renderEventForm})),ve={open:T,onClose:k,selectedEvent:b,onAdd:V,onUpdate:(De)=>{Y(De.id,De)},onDelete:(De)=>{le(De.id)}};if(U)return U(ve);return ht(R,{onOpenChange:k,open:T,children:Lr(w,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[Lr(S,{className:"mb-2 sm:mb-4 shrink-0",children:[ht(P,{className:"text-base sm:text-lg",children:b?.id?c("editEvent"):c("createEvent")}),ht(W,{className:"text-xs sm:text-sm",children:b?.id?c("editEventDetails"):c("addNewEvent")})]}),ht(Ar,{...ve})]})})};import{ChevronLeft as ha,ChevronRight as Ea,Download as ba,Plus as Sa}from"lucide-react";var Kt=`\r
2
- `,ta=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Kt),Et=(c)=>c.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
- `,"\\n").replaceAll("\r",""),Gr=(c,b=!1)=>{if(b)return c.format("YYYYMMDD");return c.utc().format("YYYYMMDD[T]HHmmss[Z]")},ra=(c)=>c.uid||`${c.id}@ilamy.calendar`,oa=(c,b)=>{let T=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),k=c.allDay?";VALUE=DATE":"",V=["BEGIN:VEVENT",`UID:${ra(c)}`,`DTSTART${k}:${Gr(c.start,c.allDay)}`,`DTEND${k}:${Gr(c.end,c.allDay)}`,`SUMMARY:${Et(c.title)}`,c.description&&`DESCRIPTION:${Et(c.description)}`,c.location&&`LOCATION:${Et(c.location)}`].filter(Boolean),Y=b("ical:vevent-properties",c).filter((U)=>typeof U==="string"),le=[`DTSTAMP:${T}`,`CREATED:${T}`,`LAST-MODIFIED:${T}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...V,...Y,...le].join(Kt)},na=(c,b,T="ilamy Calendar")=>{let k=Et(T),V=c.map((Y)=>oa(Y,b));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${k}`,`X-WR-CALDESC:Exported from ${k}`,ta,...V,"END:VCALENDAR"].join(Kt)},Br=(c,b,T="calendar.ics",k="ilamy Calendar")=>{let V=new Blob([na(c,b,k)],{type:"text/calendar;charset=utf-8"}),Y=URL.createObjectURL(V),le=T;if(!T.endsWith(".ics"))le=`${T}.ics`;let U=document.createElement("a");U.href=Y,U.download=le,document.body.append(U),U.click(),U.remove(),URL.revokeObjectURL(Y)};function zr(){let{rawEvents:c,collect:b}=r((T)=>({rawEvents:T.rawEvents,collect:T.collect}));return()=>{let T=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Br(c,b,T,"ilamy Calendar")}}import{ChevronDown as ca}from"lucide-react";import{useState as ma}from"react";function jr(){let{currentLocale:c,timezone:b}=r((k)=>({currentLocale:k.currentLocale,timezone:k.timezone}));return{formatDateRange:(k,V)=>{let Y=new Intl.DateTimeFormat(c,{timeZone:b,month:"short",day:"numeric"});if(k.year()===V.year())return Y.formatRange(k.toDate(),V.toDate());return`${Y.format(k.toDate())} – ${Y.format(V.toDate())}`}}}import{useState as ia}from"react";import{jsx as aa}from"react/jsx-runtime";function bt({label:c,isSelected:b,isCurrent:T,onSelect:k}){return aa("button",{"aria-pressed":b,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",T&&"ring-1 ring-inset ring-foreground/40",b&&"bg-primary text-primary-foreground"),onClick:k,type:"button",children:c})}import{jsx as Zt,jsxs as sa}from"react/jsx-runtime";function _r({selected:c,onSelect:b}){let[T,k]=ia(()=>c.year()),V=t(),Y=Array.from({length:12},(le,U)=>({index:U,label:c.month(U).format("MMM")}));return sa("div",{className:"w-72 p-3","data-slot":"month-grid",children:[Zt(Je,{label:T,nextLabel:"Next year",onNext:()=>k((le)=>le+1),onPrev:()=>k((le)=>le-1),prevLabel:"Previous year"}),Zt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=T===c.year()&&le.index===c.month(),ge=T===V.year()&&le.index===V.month()&&!U;return Zt(bt,{isCurrent:ge,isSelected:U,label:le.label,onSelect:()=>b(c.year(T).month(le.index).date(1))},le.index)})})]})}import{useState as la}from"react";import{jsx as qt,jsxs as da}from"react/jsx-runtime";var ct=12;function Yr({selected:c,onSelect:b}){let[T,k]=la(()=>c.year()-c.year()%ct),V=t(),Y=Array.from({length:ct},(le,U)=>T+U);return da("div",{className:"w-72 p-3","data-slot":"year-grid",children:[qt(Je,{label:`${T} – ${T+ct-1}`,nextLabel:"Next years",onNext:()=>k((le)=>le+ct),onPrev:()=>k((le)=>le-ct),prevLabel:"Previous years"}),qt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=le===c.year(),ge=le===V.year()&&!U;return qt(bt,{isCurrent:ge,isSelected:U,label:le,onSelect:()=>b(c.year(le))},le)})})]})}import{jsx as qe,jsxs as $r}from"react/jsx-runtime";var ua={day:"day",week:"week",month:"month",year:"year"};function pa(c){let b=c?.navigationStep??{amount:1,unit:c?.navigationUnit??"day"};if(b.amount!==1)return"range";return ua[b.unit]??"range"}function Wr({className:c}){let{currentDate:b,currentRange:T,view:k,selectDate:V,firstDayOfWeek:Y,getViews:le}=r((Pe)=>({currentDate:Pe.currentDate,currentRange:Pe.currentRange,view:Pe.view,selectDate:Pe.selectDate,firstDayOfWeek:Pe.firstDayOfWeek,getViews:Pe.getViews})),{formatDateRange:U}=jr(),[ge,ye]=ma(!1),ve=i(b,Y),De=ve.at(0)??b,he=ve.at(-1)??b,xe=(Pe)=>{V(Pe),ye(!1)},be=pa(le().find((Pe)=>Pe.name===k)),Ce={year:b.format("YYYY"),month:b.format("MMM YYYY"),week:U(De,he),day:b.format("ddd, MMM D, YYYY"),range:U(T.start,T.end)}[be],we=qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,onSelect:(Pe)=>Pe&&xe(t(Pe)),selected:b.toDate()}),Ne={year:qe(Yr,{onSelect:xe,selected:b}),month:qe(_r,{onSelect:xe,selected:b}),week:qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,highlightedWeekOf:b,onSelect:(Pe)=>Pe&&xe(t(Pe)),weekHover:!0}),day:we,range:we}[be];return $r(je,{onOpenChange:ye,open:ge,children:[qe(_e,{asChild:!0,children:$r(o,{className:e("font-semibold",c),"data-testid":"calendar-title",variant:"outline",children:[Ce,qe(ca,{className:"size-4 shrink-0 opacity-50"})]})}),qe(Ye,{align:"start",className:"w-auto p-0",children:Ne})]})}import*as Le from"@radix-ui/react-dropdown-menu";import{jsx as mt}from"react/jsx-runtime";function Ur({...c}){return mt(Le.Root,{"data-slot":"dropdown-menu",...c})}function Kr({...c}){return mt(Le.Trigger,{"data-slot":"dropdown-menu-trigger",...c})}function Zr({className:c,sideOffset:b=4,align:T="end",...k}){return mt(Le.Portal,{children:mt(Le.Content,{align:T,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",c),"data-slot":"dropdown-menu-content",sideOffset:b,...k})})}function qr({className:c,...b}){return mt(Le.Item,{className:e("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",c),"data-slot":"dropdown-menu-item",...b})}import{Check as fa,ChevronDown as ga}from"lucide-react";function St(){let{getViews:c,resources:b}=r((k)=>({getViews:k.getViews,resources:k.resources})),T=Boolean(b?.length);return c().filter((k)=>!T||k.supportsResources)}import{jsx as Ue,jsxs as Xt}from"react/jsx-runtime";function Xr({className:c}){let{view:b,setView:T,t:k}=r((ge)=>({view:ge.view,setView:ge.setView,t:ge.t})),V=St(),Y=V.find((ge)=>ge.name===b),le=Y?k(Y.label??Y.name):"",U=Y?.icon;return Xt(Ur,{children:[Ue(Kr,{asChild:!0,className:c,children:Xt(o,{size:"default",variant:"outline",children:[U&&Ue(U,{className:"size-4"}),Ue("span",{children:le}),Ue(ga,{className:"size-4 opacity-50"})]})}),Ue(Zr,{align:"end",className:"min-w-40",children:V.map((ge)=>{let ye=ge.icon;return Xt(qr,{onSelect:()=>T(ge.name),children:[Ue(ye,{className:"size-4"}),Ue("span",{className:"flex-1",children:k(ge.label??ge.name)}),ge.name===b&&Ue(fa,{className:"size-4"})]},ge.name)})})]})}import*as xt from"@radix-ui/react-toggle-group";import{cva as va}from"class-variance-authority";import{createContext as ya,useContext as Da}from"react";import{jsx as Qt}from"react/jsx-runtime";var Ca=va("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors outline-none hover:bg-muted hover:text-muted-foreground focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer select-none",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-2.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qr=ya({size:"default",variant:"default"});function Jr({className:c,variant:b,size:T,children:k,...V}){return Qt(xt.Root,{className:e("flex items-center justify-center gap-1",c),"data-slot":"toggle-group",...V,children:Qt(Qr.Provider,{value:{variant:b,size:T},children:k})})}function eo({className:c,children:b,variant:T,size:k,...V}){let Y=Da(Qr);return Qt(xt.Item,{className:e(Ca({variant:Y.variant||T,size:Y.size||k}),c),"data-slot":"toggle-group-item",...V,children:b})}import{jsx as to}from"react/jsx-runtime";function ro({className:c}){let{view:b,setView:T,t:k}=r((Y)=>({view:Y.view,setView:Y.setView,t:Y.t})),V=St();return to(Jr,{className:e("bg-muted gap-0 rounded-lg p-0.75",c),onValueChange:(Y)=>Y&&T(Y),size:"sm",type:"single",value:b,children:V.map((Y)=>to(eo,{className:"text-muted-foreground data-[state=on]:bg-background data-[state=on]:text-foreground rounded-md px-3 font-medium data-[state=on]:shadow-sm",value:Y.name,children:k(Y.label??Y.name)},Y.name))})}import{jsx as Me,jsxs as tt}from"react/jsx-runtime";var oo=({className:c=""})=>{let{nextPeriod:b,prevPeriod:T,today:k,openEventForm:V,headerComponent:Y,headerClassName:le,t:U,hideExportButton:ge}=r((ve)=>({nextPeriod:ve.nextPeriod,prevPeriod:ve.prevPeriod,today:ve.today,openEventForm:ve.openEventForm,headerComponent:ve.headerComponent,headerClassName:ve.headerClassName,t:ve.t,hideExportButton:ve.hideExportButton})),ye=zr();if(Y)return Y;return Me("div",{className:e("@container/base-header w-full",le),"data-testid":"calendar-header",children:tt("div",{className:e("flex flex-col items-center gap-2 @xl/base-header:flex-row @xl/base-header:justify-between",c),children:[tt("div",{className:"flex min-w-0 flex-wrap items-center justify-center gap-2",children:[tt("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[Me(o,{"aria-label":U("previous"),className:"h-full",onClick:T,size:"icon",variant:"ghost",children:Me(ha,{className:"size-4"})}),Me(o,{"aria-label":U("next"),className:"h-full",onClick:b,size:"icon",variant:"ghost",children:Me(Ea,{className:"size-4"})})]}),Me(o,{onClick:k,size:"default",variant:"outline",children:U("today")}),Me(Wr,{})]}),tt("div",{className:"flex items-center gap-2",children:[Me(ro,{className:"hidden @4xl/base-header:flex"}),Me(Xr,{className:"@4xl/base-header:hidden"}),!ge&&tt(o,{"aria-label":U("export"),onClick:ye,size:"default",variant:"outline",children:[Me(ba,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("export")})]}),tt(o,{"aria-label":U("new"),onClick:()=>V(),size:"default",children:[Me(Sa,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("new")})]})]})]})})};import{useMemo as To}from"react";import{useRef as lo}from"react";import{useEffect as xa,useRef as wa}from"react";var Pa=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,Ta="[data-hour]",Ra='[data-start]:not([data-all-day="true"])',Na=(c)=>{let T=Pa.exec(c)?.at(1);if(!T)return null;let k=Number.parseInt(T,10);return k>=0&&k<=23?k:null},Jt=(c)=>Number.parseInt(c.getAttribute("data-hour")??"",10),ka=(c,b)=>{let T=c.at(0),k=c.at(-1);if(!T||!k)return null;if(b<=Jt(T))return T;if(b>=Jt(k))return k;return c.find((V)=>Jt(V)===b)??null},Ma=(c)=>({start:t(c.dataset.start??""),end:t(c.dataset.end??"")}),Ha=(c)=>{let b=Array.from(c.querySelectorAll(Ra)),T=b.at(0),k=t(),V=b.find((Y)=>d(Ma(Y),k,k));if(!T||!V)return null;return{target:V,origin:T}},Oa=(c,b)=>{let T=b?Na(b):null;if(T===null)return null;let k=Array.from(c.querySelectorAll(Ta)),V=k.at(0),Y=ka(k,T);if(!V||!Y)return null;return{target:Y,origin:V}},Ia=(c,b,T,k)=>{let V=b.getBoundingClientRect(),Y=T.getBoundingClientRect(),le=V.left-Y.left,U=V.top-Y.top;no(c,k,k==="horizontal"?le:U)},no=(c,b,T)=>{let k=b==="horizontal"?"left":"top";c.scrollTo({[k]:T,behavior:"auto"})},Va=(c,{scrollTime:b,scrollToNow:T,axis:k})=>{let Y=(T?Ha(c):null)??Oa(c,b);if(Y)return Ia(c,Y.target,Y.origin,k),!0;if(T)return no(c,k,0),!0;return!1},wt=({viewportRef:c,scrollTime:b,scrollToNow:T=!1,enabled:k,scrollKey:V,axis:Y="vertical"})=>{let le=wa(null);xa(()=>{if(!k)return;let U=`${V}|${b}|${T}`;if(le.current===U)return;let ge=c.current;if(!ge)return;if(Va(ge,{scrollTime:b,scrollToNow:T,axis:Y}))le.current=U},[k,b,T,V,c,Y])};import{useLayoutEffect as Aa}from"react";var er="data-sticky-inset",Pt=(c)=>c?"top":void 0,ao={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},io=new Set(["hidden","scroll","auto","overlay","clip"]),La=(c)=>{let b=[];for(let T=c.parentElement;T;T=T.parentElement){let{overflowX:k,overflowY:V}=getComputedStyle(T);if(io.has(k)||io.has(V))b.push(T)}return b},Fa=(c,b,T)=>{let k=b.getBoundingClientRect(),V={left:-k.left,top:-k.top};for(let le of T){let U=le.getBoundingClientRect();V.left=Math.max(V.left,U.left-k.left),V.top=Math.max(V.top,U.top-k.top)}let Y=c.querySelectorAll(`[${er}]`);for(let le of Y){let U=le.getAttribute(er),ge=le.getBoundingClientRect();if(U==="left")V.left=Math.max(V.left,ge.right-k.left);if(U==="top")V.top=Math.max(V.top,ge.bottom-k.top)}return{left:Math.max(0,V.left),top:Math.max(0,V.top)}},Tt=(c,b,T)=>{let{currentDate:k,view:V,stickyViewHeader:Y}=r((U)=>({currentDate:U.currentDate,view:U.view,stickyViewHeader:U.stickyViewHeader})),le=n.stickyInsets(V,k,Y,T);Aa(()=>{let U=c.current,ge=b.current;if(!U||!ge)return;let ye=La(U),ve=()=>{let Ee=Fa(U,ge,ye);ge.style.setProperty(ao.left,`${Ee.left}px`),ge.style.setProperty(ao.top,`${Ee.top}px`)};ve();let De,he=()=>{if(De!==void 0)return;De=requestAnimationFrame(()=>{De=void 0,ve()})},xe=[...ye,window];for(let Ee of xe)Ee.addEventListener("scroll",he,{passive:!0});window.addEventListener("resize",he,{passive:!0});let be=typeof ResizeObserver>"u"?void 0:new ResizeObserver(ve);be?.observe(ge);for(let Ee of U.querySelectorAll(`[${er}]`))be?.observe(Ee);return()=>{for(let Ee of xe)Ee.removeEventListener("scroll",he);if(window.removeEventListener("resize",he),be?.disconnect(),De!==void 0)cancelAnimationFrame(De)}},[c,b,le])};var Ga=(c)=>{if(c.days)return c.days;return c.day?[c.day]:[]},Rt=(c,b,T)=>{let k=T.flatMap(Ga).map((Y)=>Y.toISOString()),V=[...new Set(k)].join(",");return`${c}-${b.format("YYYY-MM-DD")}-${V}`};import{memo as Ba}from"react";import{jsx as ja}from"react/jsx-runtime";var za=({children:c,className:b})=>{let{stickyViewHeader:T,viewHeaderClassName:k}=r((V)=>({stickyViewHeader:V.stickyViewHeader,viewHeaderClassName:V.viewHeaderClassName}));return ja("div",{className:e("flex h-12 w-fit",T&&"sticky top-0 z-21 bg-background",b,k),"data-sticky-inset":Pt(T),"data-testid":"horizontal-grid-header",children:c})},so=Ba(za);import{jsx as rt,jsxs as co}from"react/jsx-runtime";var mo=({rows:c,children:b,classes:T,allDay:k,gridType:V,variant:Y="resource",dayNumberHeight:le})=>{let{currentDate:U,view:ge,scrollTime:ye,scrollToNow:ve}=r(),De=lo(null),he=lo(null),xe=Y==="resource",be=!xe,Ee=c.flatMap((Te)=>Te.columns??[]),Ce=Rt(ge,U,Ee);wt({viewportRef:he,scrollTime:ye,scrollToNow:ve,enabled:xe,scrollKey:Ce,axis:"horizontal"}),Tt(De,he,c.length);let we=b&&rt(so,{className:T?.header,children:b});return co("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:De,children:[be&&we,co(u,{className:e("h-full",be&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:he},children:[xe&&we,rt("div",{className:e("flex flex-1 w-fit",T?.body),"data-testid":"horizontal-grid-body",children:rt("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:c.map((Te)=>rt(oe,{allDay:Te.allDay??k,dayNumberHeight:le,gridType:V,variant:Y,...Te},Te.id))})}),rt(y,{className:"z-30"}),rt(y,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as xo}from"react";import{memo as Ja}from"react";import{memo as Za,useMemo as qa}from"react";import{useMemo as po}from"react";var _a=(c)=>{let b=[],T=[],k=null;for(let V of c){if(k&&V.start.isSameOrAfter(k)){if(T.length>0)b.push(T);T=[]}T.push(V),k=k?t.max(k,V.end):V.end}if(T.length>0)b.push(T);return b},uo=(c,{gridStart:b,totalUnits:T,gridType:k,isDiscrete:V})=>{let Y=N(c.start,b,k),le=N(c.end,b,k);if(V){if(Y=Math.floor(Y),le=Math.ceil(le),le<=Y)le=Y+1}let U=Y<0,ge=le>T;if(U)Y=0;if(ge)le=T;let ye=Math.max(0,le-Y);if(ye===0)return null;return{top:Y/T*100,height:ye/T*100,isTruncatedStart:U,isTruncatedEnd:ge}},Ya={2:25,3:50,4:60},$a=70,Wa=(c)=>Ya[c]??$a,Ua=(c,b)=>{let T=c.length===1?c.at(0):void 0;if(T){let U=uo(T,b);if(!U)return[];return[{kind:"vertical",event:T,left:0,width:100,...U}]}let k=[...c].sort((U,ge)=>{let ye=ge.end.diff(ge.start,"minute")-U.end.diff(U.start,"minute");return ye!==0?ye:U.start.diff(ge.start)}),V=k.length,Y=V>1?Wa(V)/(V-1):0,le=[];for(let U=0;U<V;U++){let ge=k.at(U);if(!ge)continue;let ye=uo(ge,b);if(!ye)continue;let ve=U===0?0:Y*U;le.push({kind:"vertical",event:ge,...ye,left:ve,width:100-ve,zIndex:U+1})}return le},Nt=({days:c,gridType:b="hour",events:T})=>{let Y=(b==="day"?T:T.filter((U)=>!U.allDay)).toSorted((U,ge)=>U.start.diff(ge.start));if(Y.length===0)return[];let le={gridStart:c.at(0)||t(),totalUnits:c.length,gridType:b,isDiscrete:b==="day"};return _a(Y).flatMap((U)=>Ua(U,le))};var fo=({days:c,gridType:b,resourceId:T})=>{let{getEventsForDateRange:k}=r(),V=c.at(0),Y=c.at(-1),le=V?.startOf("day"),U=Y?.endOf("day"),ge=po(()=>{if(!le||!U)return[];let ve=k(le,U);return x(ve,T)},[le,U,k,T]);return po(()=>Nt({days:c,events:ge,gridType:b}),[c,b,ge])};import{jsx as Ka,jsxs as go}from"react/jsx-runtime";function vo({previewPositioned:c}){let b=r((U)=>U.timeFormat),{event:T,isTruncatedStart:k,isTruncatedEnd:V}=c,Y=q(b),le=!T.allDay;return go(re,{contentClassName:"px-1.5 py-1 relative",event:T,isTruncatedEnd:V,isTruncatedStart:k,orientation:"vertical",style:ne(c),children:[le&&go("p",{className:"text-[10px] font-semibold sm:text-xs",children:[T.start.format(Y)," – ",T.end.format(Y)]}),Ka("p",{className:e("text-[10px] font-bold sm:text-xs truncate",M.vertical),children:T.title})]})}import{jsx as yo}from"react/jsx-runtime";var Do=(c,b,T,k)=>`event-${c}-${b}-${T.at(0)?.toISOString()}-${k??"no-resource"}`;function Co({positioned:c,elementId:b,range:T,resourceId:k,draggedEventId:V}){let{event:Y}=c,le=Y.end.diff(Y.start,"minute")<=15;return yo("div",{className:"absolute","data-testid":n.container.verticalEvent(Y.id),style:ne(c),children:yo(A,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":le}),dragSegment:K(Y,T,"vertical"),elementId:b,event:Y,isBeingDragged:V===Y.id,isTruncatedEnd:c.isTruncatedEnd,isTruncatedStart:c.isTruncatedStart,sourceResourceId:k})})}import{jsx as kt,jsxs as Qa}from"react/jsx-runtime";var Xa=({days:c,gridType:b="hour",resourceId:T,resource:k,"data-testid":V})=>{let Y=r((Ee)=>Ee.resources),le=p(),U=fo({days:c,gridType:b,resourceId:T}),ge=c.at(0),ye=c.at(-1)?.add(1,b),De=T===void 0||Y?.at(0)?.id===T,he=b==="hour"&&Boolean(ge&&ye),xe=te({days:c,gridType:b,resourceId:T}),be=qa(()=>{if(!xe)return null;return Nt({days:c,gridType:b,events:[xe]}).at(0)??null},[xe,c,b]);return kt(F.Provider,{value:"vertical",children:Qa("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":V,children:[he&&ge&&ye&&kt(ee,{rangeEnd:ye,rangeStart:ge,resource:k,withDot:De}),U.map((Ee,Ce)=>{let we=Do(Ee.event.id,Ce,c,T);return kt(Co,{draggedEventId:le?.event.id,elementId:we,positioned:Ee,range:{start:ge,end:ye},resourceId:T},n.listKey(we,"wrapper"))}),be&&kt(vo,{previewPositioned:be})]})})},ho=Za(Xa);import{jsx as ot,jsxs as ti}from"react/jsx-runtime";var ei=({id:c,days:b,resource:T,"data-testid":k,"data-sticky-inset":V,gridType:Y,className:le,renderCell:U,noEvents:ge,slotDurationMinutes:ye=60})=>{let ve=T?.id,De=Math.floor(60/ye),he=Array.from({length:De},(be,Ee)=>Ee*ye),xe=he.length>1;return ot("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",le),"data-sticky-inset":V,"data-testid":k||n.container.vertical.col(c),children:ti("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${b.length}, minmax(0, 1fr))`},children:[b.map((be,Ee)=>{let Ce=be.format("HH");if(U){let we=c===n.col.time,Te=we?n.cell.verticalTime(Ce):n.cell.vertical(be,Ce,"00",ve);return ot("div",{className:"min-h-[60px] bg-background","data-hour":we?Ce:void 0,"data-testid":Te,children:U(be)},n.listKey(Ee,Ce))}return ot("div",{className:"flex flex-col min-h-[60px]",children:he.map((we,Te)=>{let Ne=String(we).padStart(2,"0"),Pe=n.cell.vertical(be,Ce,Ne,ve),Ve=xe&&Te<he.length-1;return ot(z,{className:e("not-in-data-dragging:hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",Ve&&"border-b border-dashed"),"data-testid":Pe,day:xe?be.minute(we):be,gridType:Y,hour:Y==="hour"?be.hour():void 0,isSubDivider:Ve,minute:xe?we:void 0,resourceId:ve,shouldRenderEvents:!1,slotDurationMinutes:ye},n.listKey(Ee,Ne))})},n.listKey(Ee,Ce))}),!ge&&ot("div",{className:"absolute inset-0 z-10 pointer-events-none",children:ot(ho,{"data-testid":n.container.eventsLayer("vertical",c),days:b,gridType:Y,resource:T,resourceId:ve})})]})})},Eo=Ja(ei);import{memo as ri}from"react";import{jsx as bo,jsxs as ni}from"react/jsx-runtime";var oi=({children:c,classes:b,allDayRow:T,expandAllDayRow:k=!1})=>{let{stickyViewHeader:V,viewHeaderClassName:Y}=r((U)=>({stickyViewHeader:U.stickyViewHeader,viewHeaderClassName:U.viewHeaderClassName})),le="min-w-full w-fit";return ni("div",{className:e(k&&"flex h-full flex-col",V&&"sticky top-0 z-21 bg-background",Y),"data-sticky-inset":Pt(V),children:[bo("div",{className:e("min-h-12 border-b","min-w-full w-fit",b?.header),"data-testid":"vertical-grid-header",children:c}),T&&bo("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",k&&"flex-1 overflow-hidden",b?.allDay),"data-testid":"vertical-grid-all-day",children:T})]})},So=ri(oi);import{jsx as nt,jsxs as wo}from"react/jsx-runtime";var Po=({columns:c,children:b,gridType:T="day",variant:k="resource",classes:V,allDayRow:Y,slotDurationMinutes:le,style:U})=>{let ge=k==="resource",ye=!ge,ve=c.every((Pe)=>!Pe.days?.length),{currentDate:De,view:he,scrollTime:xe,scrollToNow:be}=r(),Ee=xo(null),Ce=xo(null),we=!ve,Te=Rt(he,De,c);wt({viewportRef:Ce,scrollTime:xe,scrollToNow:be,enabled:we,scrollKey:Te}),Tt(Ee,Ce,c.length);let Ne=b&&nt(So,{allDayRow:Y,classes:{header:V?.header,allDay:V?.allDay},expandAllDayRow:ve,children:b});if(ve&&Ne)return nt("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:U,children:Ne});return wo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:Ee,style:U,children:[ye&&Ne,wo(u,{className:e("h-full",ye&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:Ce},children:[ge&&Ne,nt("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",V?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:c.map((Pe,Ve)=>nt(Eo,{...Pe,gridType:T,slotDurationMinutes:le},n.listKey("col",Ve)))}),nt(y,{className:"z-30"})," ",nt(y,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as Xe}from"react/jsx-runtime";var ai=(c,b)=>b==="vertical",ii=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let{slotDuration:V}=r((he)=>({slotDuration:he.slotDuration})),Y=c.some((he)=>he.gridType==="hour")?"hour":"day",le=c.filter((he)=>!he.noEvents).map((he)=>he.day).filter((he)=>Boolean(he)),U=c.find((he)=>he.noEvents),ye=Boolean(U?.className?.includes(j))?{cell:"flex-1 min-w-0",spacer:j}:void 0,ve;if(Y==="hour")ve=T?Xe(me,{columns:c}):Xe(ae,{classes:ye,days:le});return Xe(Po,{allDayRow:ve,classes:T?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:c,gridType:Y,slotDurationMinutes:V,variant:k,children:b})},si=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let V=c.some((U)=>U.columns?.some((ge)=>ge.gridType==="hour"))?"hour":"day",Y=c.some((U)=>U.columns?.some((ge)=>ge.days)),le=T?{header:e(Y&&ue,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return Xe(mo,{classes:le,dayNumberHeight:T?0:void 0,gridType:V,rows:c,variant:k,children:b})},Ro=({view:c})=>{let{currentDate:b,firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}=r((Ce)=>({currentDate:Ce.currentDate,firstDayOfWeek:Ce.firstDayOfWeek,hiddenDays:Ce.hiddenDays,businessHours:Ce.businessHours,hideNonBusinessHours:Ce.hideNonBusinessHours,resources:Ce.resources,orientation:Ce.orientation,weekViewGranularity:Ce.weekViewGranularity})),ye=To(()=>({firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}),[T,k,V,Y,le,U,ge]),ve=To(()=>c.columns?.(b,ye),[c,b,ye]);if(!ve||!c.layout){let Ce=c.component;if(Ce)return Xe(Ce,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${c.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let he=Boolean(le?.length)&&Boolean(c.supportsResources),xe=he?U??"horizontal":c.layout,be=he?"resource":"regular",Ee=c.renderHeader?.({date:b,config:ye});if(ai(ve,xe))return Xe(ii,{composesResourceAxis:he,header:Ee,specs:ve,variant:be});return Xe(si,{composesResourceAxis:he,header:Ee,specs:ve,variant:be})};var No=(c)=>{if(!c||c.length===0)return;return new Set(c.map((b)=>H[b]))};function ko(c){if(!c?.length)return[];return c.map((b)=>({...b,start:t(b.start),end:t(b.end)}))}import{jsx as Ke,jsxs as mi}from"react/jsx-runtime";var ci=()=>{let{view:c,getViews:b}=r((V)=>({view:V.view,getViews:V.getViews})),T=b().find((V)=>V.name===c);return mi("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[Ke(oo,{className:"p-1 shrink-0 mb-1"}),Ke(br,{children:Ke(l,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:c,children:Ke("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:T?Ke(Ro,{view:T},c):null})})}),Ke(Fr,{})]})},tr=({events:c,firstDayOfWeek:b="sunday",initialView:T="month",initialDate:k,eventSpacing:V=Z,eventHeight:Y=Q,stickyViewHeader:le=!0,viewHeaderClassName:U="",timeFormat:ge="12-hour",hideNonBusinessHours:ye=!1,hiddenDays:ve,resources:De,orientation:he,...xe})=>{let be=Boolean(De?.length),Ee=di(()=>ko(c),[c]);return li(()=>{if(typeof process<"u"&&!1)console.warn("[@ilamy/calendar] `orientation` was provided without `resources` — it only applies when the calendar has resources, so it is ignored.")},[he,be]),Ke(_,{eventHeight:Y,eventSpacing:V,events:Ee,firstDayOfWeek:H[b],hiddenDays:No(ve),hideNonBusinessHours:ye,initialDate:k,initialView:T,orientation:he,resources:De,stickyViewHeader:le,timeFormat:ge,viewHeaderClassName:U,...xe,children:Ke(ci,{})})};import{jsx as pi}from"react/jsx-runtime";var ui=(c)=>pi(tr,{...c});export{tr as IlamyCalendar,ui as IlamyResourceCalendar,mr as SLOT_EVENT_FORM,ur as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,se as defaultTranslations,fe as useIlamyCalendarContext};
1
+ import{t,c,D,Ie,be,H,A,ne,oe}from"./shared/chunk-qc1dpk9c.js";import{k,N,O,ee,M,te}from"./shared/chunk-fdfxtah1.js";import{Ee,r,Se,a,h,ae,ke,se,ie,le,T,Ne,l,i,U,y,u,F,de,ce,K,ue,Re,we,Oe,xe,p,q,X,L,V,z,n,f,me,j,pe,fe,Z,_,Q,ye,G,ge,ve,Ce,De,W,he,Me,Pe,J}from"./shared/chunk-hd24e4t0.js";import{e}from"./shared/chunk-8n7287tn.js";import{o,b,g,s,E,S,R,w,v}from"./shared/chunk-ybbzp3rf.js";import{m,C}from"./shared/chunk-58t5nwpa.js";var Br="event-form",Gr="event-mutation-scope",zr=({event:d,onChange:P})=>r((I)=>I.renderSlot)(Br,{event:d,onChange:P}),Kt=({dialog:d,onResolve:P,onCancel:x})=>{let I=r((Te)=>Te.getEventManager);if(!(d.isOpen&&d.event))return null;let B=I(d.event),Y={event:d.event,operation:d.operation,resolve:P,cancel:x};return B?.renderSlot?.(Gr,Y)};import{useImperativeHandle as Ci,useInsertionEffect as hi,useMemo as Ei,useRef as bi}from"react";import{DndContext as fa}from"@dnd-kit/core";import{useId as ga}from"react";import{MouseSensor as Uo,TouchSensor as Ko,useSensor as Zr,useSensors as qo}from"@dnd-kit/core";import{useEffect as Jr,useRef as vt,useState as Zo}from"react";var fr=(d)=>{if(d.hour===void 0)return!1;let P=H(d.minute,d.slotDurationMinutes);return A(d.snapMinutes,P)<P},gr=(d,P)=>{if(!fr(d))return d;let x=H(d.minute,d.slotDurationMinutes),I=A(d.snapMinutes,x),{index:B}=oe(P,x,I),Y=(d.minute??0)+B*I;return{...d,minute:Y,slotDurationMinutes:I}};var Nt=(d)=>d.hour!==void 0,Lo=(d)=>("slots"in d),_r=(d,P,x)=>{if(!d||!fr(d))return d;if(!x)return gr(d,0);let I=d.axis==="horizontal",B=I?x.x:x.y,Y=I?P.left:P.top,Te=I?P.width:P.height,re=ne(B,Y,Te);return gr(d,re)},Bo={top:0,left:0,width:0,height:0},qt=(d,P)=>P>=0&&P<d.length?d.at(P)?.element.getBoundingClientRect():void 0,Go=(d,P)=>{let x=0,I=d.length-1;while(x<I){let B=Math.ceil((x+I)/2);if((qt(d,B)?.top??Number.POSITIVE_INFINITY)<=P)x=B;else I=B-1}return x},zo=(d,P,x)=>{let I=qt(d,P)?.top===x,B=qt(d,P-1)?.bottom??Number.NaN;return I&&B>=x},_o=({slots:d},P)=>{let x=P?P.y:Number.NEGATIVE_INFINITY,I=Go(d,x),Y=zo(d,I,x)?I-1:I,Te=qt(d,Y)??Bo;return{slot:d.at(Y)?.data,slotRect:Te}},Bt=(d,P)=>{let x=d?.data.current;if(!d||!x)return;if(Lo(x)){let{slot:I,slotRect:B}=_o(x,P);return _r(I,B,P)}return _r(x,d.rect,P)},xt="00:00:00.000",vr="HH:mm:ss.SSS",jr="YYYY-MM-DDTHH:mm:ss.SSS",Yo=3600000,jo=Yo,yr=(d)=>t.utc(d.format(jr)).valueOf(),Wo=(d)=>yr(d.end)-yr(d.start),Yr=(d,P)=>{let x=t.utc(yr(d)+P);return t(x.format(jr))},Dr=(d,P,x=h)=>{let{date:I,hour:B=0,minute:Y=0,allDay:Te}=P,re=Boolean(d.allDay),Ae=Wo(d),Ve=(ze)=>({start:ze,end:Yr(ze,Ae)});if(Nt(P)){let ze=`${String(B).padStart(2,"0")}:${String(Y).padStart(2,"0")}:00.000`,qe=u(t(I),ze);if(re){let We=Yr(qe,jo);return{start:qe,end:We,allDay:!1}}let _e=qe.subtract(x.minutes,"minute");return{...Ve(_e),allDay:!1}}let He=t(I).subtract(x.days,"day");if(Te===!0||re){let ze=u(He,xt);if(!re){let _e=u(He.add(1,"day"),xt);return{start:ze,end:_e,allDay:!0}}return{...Ve(ze),allDay:!0}}let Ge=d.start.format(vr),Le=u(He,Ge);return{...Ve(Le),allDay:!1}},Wr=(d)=>{let{target:P}=d;if(!(P instanceof Element))return;let x=P.closest("[data-resize-handle]")?.getAttribute("data-resize-handle");if(x==="start"||x==="end")return x;return},$r=(d)=>{let{date:P,hour:x=0,minute:I,slotDurationMinutes:B}=d;if(!P)return;let Y=H(I,B),Te=`${String(x).padStart(2,"0")}:${String(I??0).padStart(2,"0")}:00.000`,re=u(P,Te);return{start:re,end:re.add(Y,"minute")}},Ur=(d)=>{let{date:P}=d;if(!P)return;if(Nt(d))return $r(d);return{start:u(P,xt),end:u(P.add(1,"day"),xt)}},Kr=(d,P,x)=>{let{date:I}=P;if(!I)return null;let{start:B,end:Y}=d,Te=$r(P);if(Nt(P)&&Te)if(x==="end")Y=Te.end;else B=Te.start;else if(x==="end"){let re=d.end.isSame(d.end.startOf("day"));Y=Boolean(d.allDay)||re?u(I.add(1,"day"),xt):u(I,d.end.format(vr))}else{let re=d.allDay?xt:d.start.format(vr);B=u(I,re)}return Y.isAfter(B)?{start:B,end:Y}:null},$o=(d,P,x)=>{if(x===void 0||P===x)return{};if(!d.resourceIds)return{resourceId:x};let B=d.resourceIds.indexOf(P);if(B===-1)return{};let Y=d.resourceIds.slice();if(Y.splice(B,1),!Y.includes(x))Y.push(x);return{resourceIds:Y}},qr=(d,P,x=h,I)=>{let{active:B,over:Y}=d;if(!B||!Y||!P)return null;let Te=Bt(Y,I);if(!Te||Te.disabled)return null;let{resourceId:re}=Te,{start:Ae,end:Ve,allDay:He}=Dr(P,Te,x),Fe=B.data.current?.sourceResourceId,Be=$o(P,Fe,re),Ge=Ae.isSame(P.start)&&Ve.isSame(P.end),Le=He===Boolean(P.allDay),ze=Object.keys(Be).length===0;if(Ge&&Le&&ze)return null;let qe={start:Ae,end:Ve,...Be,allDay:He};return{activeEvent:P,updates:qe}};var Xr=(d,P)=>{if(!d)return!1;let x=d.start.isSame(P.start)&&d.end.isSame(P.end),I=d.resourceId===P.resourceId&&d.allDay===P.allDay,B=d.isDropAllowed===P.isDropAllowed;return x&&I&&B},Xo=({active:d,activatorEvent:P})=>{if(d.data.current?.type!=="calendar-event")return null;let x=d.data.current.event,I=d.data.current.dragSegment;if(!I)return{calendarEvent:x,pending:null};let B=d.data.current.getBarRect;return{calendarEvent:x,pending:{calendarEvent:x,segment:I,activatorEvent:P,barRect:B?.()}}},Qo=({active:d,activatorEvent:P})=>{let x=d.data.current,I=Wr(P),B=x?.resizeGranularity;if(x?.type!=="calendar-event"||!I||!B)return null;return{calendarEvent:x.event,resize:{edge:I,granularity:B,sourceResourceId:x.sourceResourceId}}},Jo=(d,P,x,I)=>{let B={event:d,start:d.start,end:d.end,resourceId:P.sourceResourceId??d.resourceId,allDay:Boolean(d.allDay),isDropAllowed:!0};if(!x)return B;let Y=P.granularity==="slot";if(Nt(x)!==Y)return B;let re=Kr(d,x,P.edge);if(!re)return B;return{...B,...re,isDropAllowed:!I}},ea=(d,P,x)=>{let I=P??{},{start:B,end:Y,allDay:Te}=Dr(d,I,x);return{event:d,start:B,end:Y,resourceId:I.resourceId??d.resourceId,allDay:Te,isDropAllowed:!I.disabled}},ta=(d)=>{let P=Oe(d);Jr(()=>{if(!P)return;let x=document.body.style.cursor;return document.body.style.cursor=P,()=>{document.body.style.cursor=x}},[P])},Qr=(d)=>{let{clientX:P,clientY:x,touches:I}=d,B=I?.item(0)??{clientX:P,clientY:x};if(B.clientX===void 0||B.clientY===void 0)return;return{x:B.clientX,y:B.clientY}},ra=()=>{let d=vt(void 0),P=vt(()=>{}),x=()=>{P.current(),P.current=()=>{},d.current=void 0},I=(B)=>{x(),d.current=Qr(B);let Y=(Te)=>{d.current=Qr(Te)??d.current};window.addEventListener("pointermove",Y),window.addEventListener("touchmove",Y),P.current=()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("touchmove",Y)}};return Jr(()=>()=>P.current(),[]),{pointerRef:d,follow:I,stopFollowing:x}},na={activationConstraint:{distance:2}},oa={activationConstraint:{delay:100,tolerance:5}},aa=()=>{let d=Zr(Uo,na),P=Zr(Ko,oa);return qo(d,P)},en=(d)=>{let{slotDuration:P,snapDuration:x,eventAllow:I,businessHours:B,getResourceById:Y,isCellDisabled:Te,view:re,currentDate:Ae}=r((Ye)=>({slotDuration:Ye.slotDuration,snapDuration:Ye.snapDuration,eventAllow:Ye.eventAllow,businessHours:Ye.businessHours,getResourceById:Ye.getResourceById,isCellDisabled:Ye.isCellDisabled,view:Ye.view,currentDate:Ye.currentDate})),Ve=aa(),He=vt(null),Fe=vt(h),Be=vt(null),Ge=vt(null),Le=vt(null),{pointerRef:ze,follow:qe,stopFollowing:_e}=ra(),We=vt(null),[je,Ke]=Zo(null);ta(je);let Je=()=>{_e(),He.current=null,Fe.current=h,Be.current=null,Ge.current=null,We.current=null,Ke(null),Le.current?.setActiveEvent(null)},rt=(Ye,$e)=>{if(!I)return!0;let Ue=We.current;if(Ue&&Xr(Ue.placement,$e))return Ue.isAllowed;let{start:et,end:tt,allDay:nt,resourceId:ot}=$e,gt=I({start:et,end:tt,allDay:nt,resourceId:ot},Ye)??!0;return We.current={placement:$e,isAllowed:gt},gt},ct=(Ye,$e)=>{let Ue=Be.current;if(Ue)return Qe(Ye,Ue,$e);let et=ea(Ye,$e,Fe.current),tt=et.isDropAllowed&&rt(Ye,et);return{...et,isDropAllowed:tt}},Pt=(Ye,$e,Ue)=>{let et=Nt($e)?"hour":"day";return Re({day:Ue.start,gridType:et,slotDurationMinutes:Ue.end.diff(Ue.start,"minute"),businessHours:Ye?.businessHours??B})},Rt=(Ye,$e,Ue)=>Boolean(Te?.({...Ue,resource:Ye,allDay:$e.allDay})),Vt=(Ye,$e)=>{let Ue=$e?Ur($e):void 0;if(!$e||!Ue)return!1;let et=Ye===void 0?void 0:Y?.(Ye),tt=we(Ue.start,re,Ae);return Pt(et,$e,Ue)||tt||Rt(et,$e,Ue)},Qe=(Ye,$e,Ue)=>{let et=$e.sourceResourceId??Ye.resourceId,tt=Vt(et,Ue),nt=Jo(Ye,$e,Ue,tt),ot=nt.start.isSame(Ye.start)&&nt.end.isSame(Ye.end),gt=nt.isDropAllowed&&(ot||rt(Ye,nt));return{...nt,isDropAllowed:gt}},Xe=(Ye)=>{qe(Ye.activatorEvent);let $e=Qo(Ye);if($e){He.current=$e.calendarEvent,Be.current=$e.resize;return}let Ue=Xo(Ye);if(!Ue)return;Le.current?.setActiveEvent(Ue.calendarEvent),He.current=Ue.calendarEvent,Fe.current=h,Ge.current=Ue.pending},mt=(Ye)=>A(x,Ye==="vertical"?P:be),mr=(Ye)=>{let $e=Ge.current;if(!$e)return;let Ue=$e.barRect??Ye.active.rect.current.initial;if(!Ue)return;Fe.current=ke({activeEvent:$e.calendarEvent,initialRect:Ue,activatorEvent:$e.activatorEvent,segment:$e.segment,slotDurationMinutes:mt($e.segment.axis)}),Ge.current=null},Ft=(Ye)=>{mr(Ye);let $e=He.current,Ue=Bt(Ye.over,ze.current);if(!$e||!Ue){Ke(null);return}let et=ct($e,Ue);Ke((tt)=>{if(Xr(tt,et))return tt;return et})},Wt=(Ye,$e,Ue)=>{let et=Qe(Ye,$e,Ue),{start:tt,end:nt}=et,ot=!tt.isSame(Ye.start)||!nt.isSame(Ye.end);if(et.isDropAllowed&&ot)d(Ye,{start:tt,end:nt})};return{sensors:Ve,dragPreview:je,overlayRef:Le,handlers:{onDragStart:Xe,onDragMove:Ft,onDragOver:Ft,onDragEnd:(Ye)=>{let $e=Be.current,Ue=He.current;if($e&&Ue){Wt(Ue,$e,Bt(Ye.over,ze.current)),Je();return}let et=qr(Ye,He.current,Fe.current,ze.current),tt=He.current,nt=Bt(Ye.over,ze.current),gt=(tt?ct(tt,nt):null)?.isDropAllowed===!1;if(et&&!gt)d(et.activeEvent,et.updates);Je()},onDragCancel:Je}}};import{useCallback as Zt,useEffect as sa,useRef as ia,useState as la}from"react";var Cr={isOpen:!1,operation:"edit",event:null};function Xt(d){let{applyScopedEdit:P,applyScopedDelete:x}=r((He)=>({applyScopedEdit:He.applyScopedEdit,applyScopedDelete:He.applyScopedDelete})),[I,B]=la(Cr),Y=ia(I);sa(()=>{Y.current=I},[I]);let Te=Zt((He,Fe)=>{B({isOpen:!0,operation:"edit",event:He,updates:Fe})},[]),re=Zt((He)=>{B({isOpen:!0,operation:"delete",event:He})},[]),Ae=Zt(()=>B(Cr),[]),Ve=Zt((He)=>{let Fe=Y.current;if(!Fe.event)return;if(Fe.operation==="edit")P(Fe.event,Fe.updates??{},He);else x(Fe.event,He);B(Cr),d?.()},[P,x,d]);return{dialogState:I,openEditDialog:Te,openDeleteDialog:re,closeDialog:Ae,handleConfirm:Ve}}var tn=()=>{let{updateEvent:d,getEventManager:P}=r((re)=>({updateEvent:re.updateEvent,getEventManager:re.getEventManager})),{dialogState:x,openEditDialog:I,closeDialog:B,handleConfirm:Y}=Xt();return{commitDrop:(re,Ae)=>{let Ve=Object.keys(Ae).length===0;if(!re.id||Ve)return;if(P(re)?.applyEdit){I(re,Ae);return}d(re.id,Ae)},scopeDialog:{dialog:x,onCancel:B,onResolve:Y}}};import{pointerWithin as rn}from"@dnd-kit/core";var da=(d)=>d.data.current?.allDay===!0,nn=(d)=>{let{droppableContainers:P,droppableRects:x,pointerCoordinates:I}=d;if(!I)return[];let{x:B,y:Y}=I,Te=(Be)=>{if(!(Be.top<=Y))return!1;if(!(Y<=Be.bottom))return!1;if(!(Be.left<=B))return!1;return B<=Be.right},re=(Be)=>{let Ge=Be.node.current?.getBoundingClientRect();return Ge!==void 0&&Te(Ge)},Ae=P.filter(da),Ve=new Map;for(let Be of Ae){let Ge=Be.node.current?.getBoundingClientRect();if(Ge)Ve.set(Be.id,Ge)}let He=rn({...d,droppableContainers:Ae,droppableRects:Ve});if(He.length>0)return He;let Fe=P.filter((Be)=>{let Ge=x.get(Be.id);return Ge!==void 0&&Te(Ge)&&re(Be)});return rn({...d,droppableContainers:Fe})};import{DragOverlay as ca}from"@dnd-kit/core";import{snapCenterToCursor as ua}from"@dnd-kit/modifiers";import{useImperativeHandle as ma,useState as pa}from"react";import{jsx as on}from"react/jsx-runtime";var an=({ref:d})=>{let[P,x]=pa(null),I=p();if(ma(d,()=>({setActiveEvent:x})),I)return null;return on(ca,{modifiers:[ua],children:P&&on("div",{className:e("cursor-grabbing truncate rounded-md px-3 py-1.5 text-xs font-medium shadow-xl opacity-80",L(P)),style:V(P),children:P.title})})};import{jsx as hr,jsxs as sn}from"react/jsx-runtime";var va={screenReaderInstructions:{draggable:""},announcements:{onDragStart:()=>{return},onDragOver:()=>{return},onDragEnd:()=>{return},onDragCancel:()=>{return}}};function ln({children:d}){let P=ga(),x=r((He)=>{let Fe={editable:He.editable,eventStartEditable:He.eventStartEditable,eventDurationEditable:He.eventDurationEditable,disableDragAndDrop:He.disableDragAndDrop},Be=q({},Fe),Ge=X({},Fe),Le=He.events.some((ze)=>q(ze,Fe)||X(ze,Fe));return Be||Ge||Le}),{commitDrop:I,scopeDialog:B}=tn(),{sensors:Y,dragPreview:Te,overlayRef:re,handlers:Ae}=en(I),Ve=Te!==null;if(!x)return d;return sn(xe.Provider,{value:Te,children:[sn(fa,{accessibility:va,collisionDetection:nn,id:P,sensors:Y,...Ae,children:[hr("div",{className:"contents","data-dragging":Ve?"true":void 0,children:d}),hr(an,{ref:re})]}),hr(Kt,{...B})]})}import{useRef as Qa}from"react";import{ChevronDownIcon as ya}from"lucide-react";import{useEffect as Da,useState as Ca}from"react";import*as pt from"@radix-ui/react-popover";import{jsx as Qt}from"react/jsx-runtime";function yt({...d}){return Qt(pt.Root,{"data-slot":"popover",...d})}function Dt({...d}){return Qt(pt.Trigger,{"data-slot":"popover-trigger",...d})}function Ct({className:d,align:P="center",sideOffset:x=4,...I}){return Qt(pt.Portal,{children:Qt(pt.Content,{align:P,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:x,...I})})}import{jsx as ht,jsxs as Gt}from"react/jsx-runtime";var dn=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Er=(d)=>Boolean(d&&dn.test(d)),ha=(d)=>{let P=d.match(/bg-([a-z]+)-\d+/)?.at(1);if(!P)return"Custom";return P.charAt(0).toUpperCase()+P.slice(1)};function cn({value:d,onChange:P,swatches:x=[],className:I,"aria-label":B="Select color"}){let[Y,Te]=Ca(Er(d)?d:"");Da(()=>{Te(Er(d)?d:"")},[d]);let re=(Fe)=>{let Be=Fe.target.value;if(Te(Be),dn.test(Be))P(Be)},Ae=Er(d),Ve=x.find((Fe)=>Fe.value===d),He;if(Ve)He=Ve.label;else if(Ae)He=d;else if(d)He=ha(d);else He="Pick a color";return Gt(yt,{children:[Gt(Dt,{"aria-label":B,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]",I),"data-slot":"color-picker-trigger",type:"button",children:[Gt("span",{className:"flex items-center gap-2",children:[ht("span",{className:e("size-5 shrink-0 rounded-full border",!Ae&&d),style:Ae?{backgroundColor:d}:void 0}),ht("span",{className:e(Ae&&"font-mono text-xs"),children:He})]}),ht(ya,{className:"size-4 shrink-0 opacity-50"})]}),Gt(Ct,{className:"w-56","data-slot":"color-picker-content",children:[x.length>0&&ht("div",{className:"grid grid-cols-7 gap-1.5",children:x.map((Fe)=>{let Be=d===Fe.value;return ht("button",{"aria-label":Fe.label,"aria-pressed":Be,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",Fe.value,Be&&"ring-ring ring-2 ring-offset-1"),onClick:()=>P(Fe.value),type:"button"},Fe.value)})}),ht("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),Gt("div",{className:"flex items-center gap-2",children:[ht("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(Fe)=>P(Fe.target.value),type:"color",value:Ae?d:"#000000"}),ht(g,{"aria-label":"Hex color",className:"font-mono",onChange:re,placeholder:"#000000",value:Y})]})]})]})}import{jsx as Ea}from"react/jsx-runtime";function un({className:d,...P}){return Ea("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",...P})}import{useState as dt}from"react";import{PopoverClose as Na}from"@radix-ui/react-popover";import{Calendar as Ma}from"lucide-react";import{useEffect as Ia,useId as ka,useRef as Oa,useState as Aa}from"react";import{useState as Ra}from"react";import{ChevronLeftIcon as ba,ChevronRightIcon as Sa}from"lucide-react";import{jsx as zt,jsxs as wa}from"react/jsx-runtime";function Mt({label:d,onPrev:P,onNext:x,prevLabel:I,nextLabel:B}){return wa("div",{className:"mb-2 flex items-center justify-between",children:[zt(o,{"aria-label":I,onClick:P,size:"icon",variant:"ghost",children:zt(ba,{className:"size-4"})}),zt("div",{className:"text-sm font-medium select-none",children:d}),zt(o,{"aria-label":B,onClick:x,size:"icon",variant:"ghost",children:zt(Sa,{className:"size-4"})})]})}import{jsx as ft,jsxs as mn}from"react/jsx-runtime";function Ta(d){let P=d.weekHover&&!d.isCurrentWeek;return e("p-0 text-center",d.weekHover&&"first:rounded-l-md last:rounded-r-md",P&&"group-hover/week:bg-accent",d.isCurrentWeek&&"bg-primary")}function Pa(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 xa({day:d,state:P,onSelect:x}){return ft("td",{className:Ta(P),"data-disabled":P.isDisabled,"data-outside":P.isOutside,"data-selected":P.isSelected,role:"gridcell",tabIndex:-1,children:ft("button",{"aria-disabled":P.isDisabled,"aria-hidden":P.isOutside,className:Pa(P),"data-disabled":P.isDisabled,"data-selected":P.isSelected,disabled:P.isDisabled||P.isOutside,onClick:()=>x?.(d.toDate()),tabIndex:P.isOutside?-1:0,type:"button",children:d.format("D")})})}function _t({selected:d,defaultMonth:P,onSelect:x,disabled:I,firstDayOfWeek:B=0,className:Y,weekHover:Te=!1,highlightedWeekOf:re}){let Ae=r((_e)=>_e.t),[Ve,He]=Ra(()=>t(P??d??new Date).startOf("month")),Fe=U(Ve,B),Be=d?t(d).format("YYYY-MM-DD"):void 0,Ge=i(t(),B).map((_e)=>_e.format("dd")),Le,ze;if(re){let _e=i(re,B);Le=_e.at(0),ze=_e.at(-1)}let qe=(_e)=>{let We=_e.format("YYYY-MM-DD")===Be,je=!1;if(Le&&ze){let Ke=!_e.isBefore(Le,"day"),Je=!_e.isAfter(ze,"day");je=Ke&&Je}return{isOutside:!_e.isSame(Ve,"month"),isSelected:We,isDisabled:I?.(_e.toDate())??!1,isCurrent:l(_e)&&!We,isCurrentWeek:je,weekHover:Te}};return mn("div",{className:e("bg-background p-3 w-72",Y),"data-slot":"calendar",children:[ft(Mt,{label:Ve.format("MMMM YYYY"),nextLabel:Ae("nextMonth"),onNext:()=>He((_e)=>_e.add(1,"month")),onPrev:()=>He((_e)=>_e.subtract(1,"month")),prevLabel:Ae("previousMonth")}),mn("table",{className:"w-full border-collapse",role:"grid",children:[ft("thead",{children:ft("tr",{children:Ge.map((_e,We)=>ft("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:_e},We))})}),ft("tbody",{children:Fe.map((_e,We)=>ft("tr",{className:e(Te&&"group/week"),children:_e.map((je)=>ft(xa,{day:je,onSelect:x,state:qe(je)},je.toISOString()))},We))})]})]})}import{jsx as It,jsxs as br}from"react/jsx-runtime";function pn({date:d,closeOnSelect:P,onChange:x,id:I,labelId:B,className:Y,disabled:Te}){let{firstDayOfWeek:re,t:Ae}=r((Le)=>({firstDayOfWeek:Le.firstDayOfWeek,t:Le.t})),Ve=Oa(null),[He,Fe]=Aa(d);Ia(()=>{Fe(d)},[d]);let Be=(Le)=>{if(Fe(Le),P)Ve.current?.click();x?.(Le)},Ge=ka();return It("div",{className:Y,children:br(yt,{children:[It(Dt,{asChild:!0,children:br(o,{"aria-labelledby":`${B} ${Ge}`,className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!d,id:I,variant:"outline",children:[It(Ma,{}),It("span",{id:Ge,children:He?t(He).format("ll"):Ae("pickDate")})]})}),br(Ct,{align:"start",className:"w-auto p-0",children:[It(Na,{ref:Ve,style:{display:"none"}}),It(_t,{defaultMonth:He,disabled:Te,firstDayOfWeek:re,onSelect:Be,selected:He})]})]})})}import{Clock as Va}from"lucide-react";import{useEffect as gn,useId as Fa,useRef as vn,useState as Sr}from"react";import{useMemo as Ha}from"react";function fn({timeFormat:d="12-hour",minTime:P="00:00",maxTime:x="23:45"}){return{timeOptions:Ha(()=>{let Y=[],[Te,re]=P.split(":").map(Number),[Ae,Ve]=x.split(":").map(Number),He=Te*60+re,Fe=Ae*60+Ve;for(let Be=He;Be<=Fe;Be+=15){let Ge=Math.floor(Be/60),Le=Be%60,ze=`${Ge.toString().padStart(2,"0")}:${Le.toString().padStart(2,"0")}`;Y.push(ze)}return Y},[P,x]),formatTime:(Y)=>{let[Te,re]=Y.split(":").map(Number);if(d==="24-hour")return`${Te.toString().padStart(2,"0")}:${re.toString().padStart(2,"0")}`;let Ae=Te>=12?"PM":"AM",Ve=Te;if(Te===0)Ve=12;else if(Te>12)Ve=Te-12;return`${Ve}:${re.toString().padStart(2,"0")} ${Ae}`}}}import{jsx as lt,jsxs as wr,Fragment as Ga}from"react/jsx-runtime";var La=(d)=>{d.stopPropagation()};function Ba({options:d,selected:P,formatTime:x,onSelect:I}){let B=r((Fe)=>Fe.t),[Y,Te]=Sr(""),re=vn(null);gn(()=>{setTimeout(()=>{re.current?.focus()},0)},[]);let Ae=d.filter((Fe)=>x(Fe).toLowerCase().includes(Y.toLowerCase())),Ve=Ae.map((Fe)=>lt("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",Fe===P&&"bg-accent text-accent-foreground"),onClick:()=>I(Fe),type:"button",children:x(Fe)},Fe)),He=lt("div",{className:"py-6 text-center text-sm text-muted-foreground",children:B("noTimeFound")});return wr(Ga,{children:[lt("div",{className:"p-2 border-b",children:lt(g,{className:"h-8",onChange:(Fe)=>Te(Fe.target.value),placeholder:B("searchTime"),ref:re,value:Y})}),lt(m,{className:"h-[200px]",onWheel:La,children:lt("div",{className:"p-1",children:Ae.length===0?He:Ve})})]})}function yn({value:d,onChange:P,minTime:x="00:00",maxTime:I="23:45",timeFormat:B="12-hour",id:Y,labelId:Te,className:re,disabled:Ae=!1,name:Ve}){let He=r((Je)=>Je.t),[Fe,Be]=Sr(!1),Ge=vn(null),[Le,ze]=Sr(0),{timeOptions:qe,formatTime:_e}=fn({timeFormat:B,minTime:x,maxTime:I}),We=(Je)=>{P(Je),Be(!1)};gn(()=>{if(Fe)ze(Ge.current?.offsetWidth??0)},[Fe]);let je=Fa(),Ke=d?_e(d):He("selectTime");return wr(yt,{onOpenChange:Be,open:Fe,children:[lt(Dt,{asChild:!0,children:wr(o,{"aria-expanded":Fe,"aria-labelledby":`${Te} ${je}`,className:e("w-full justify-start",re),"data-testid":n.timePicker(Ve),disabled:Ae,id:Y,ref:Ge,role:"combobox",variant:"outline",children:[lt(Va,{className:"mr-2 h-4 w-4"}),lt("span",{id:je,children:Ke})]})}),lt(Ct,{align:"start",className:"p-0",style:{width:Le},children:lt(Ba,{formatTime:_e,onSelect:We,options:qe,selected:d})})]})}var Rr=(d,P)=>u(t(d),`${P}:00.000`),Cn="00:00",hn=(d,P,x)=>Rr(d,x?Cn:P),En=(d,P,x)=>{if(!x)return Rr(d,P);return Rr(d,Cn).add(1,"day").startOf("day")},Tr=(d,P)=>{if(!P)return{min:"00:00",max:"23:59"};let x=t(d),{minStart:I,maxEnd:B,hasBusinessHours:Y}=ue({allDates:[x],businessHours:P,hideNonBusinessHours:!1});if(!Y)return{min:"00:00",max:"23:59"};return{min:`${I.toString().padStart(2,"0")}:00`,max:`${(B-1).toString().padStart(2,"0")}:45`}},bn=60000,za=60,Jt=(d,P)=>{let x=t(d).format("YYYY-MM-DD");return Date.parse(`${x}T${P}:00.000Z`)/bn},Dn=(d)=>{let P=new Date(d*bn).toISOString(),x=P.slice(0,10);return{date:t(`${x}T00:00:00.000`).toDate(),time:P.slice(11,16)}},Sn=(d,P)=>{let x=Jt(d.toDate(),d.format("HH:mm")),B=Jt(P.toDate(),P.format("HH:mm"))-x;return B>0?B:za},wn=(d,P,x)=>{let I=Jt(d.startDate,d.startTime),B=Jt(d.endDate,d.endTime);if(B>I)return d;if(P==="start"){let Te=Dn(I+x);return{...d,endDate:Te.date,endTime:Te.time}}let Y=Dn(B-x);return{...d,startDate:Y.date,startTime:Y.time}};import{jsx as Ze,jsxs as at,Fragment as Nn}from"react/jsx-runtime";var Tn="bg-blue-100 text-blue-800",_a=[{value:Tn,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"}],Rn="23:59",Pn=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Ya=(d,P)=>{if(d&&Pn.test(d))return d;return P??Tn},ja=(d)=>{if(Pn.test(d))return{backgroundColor:d,color:Ie(d)};return{backgroundColor:void 0,color:d}},Wa=({colorChanged:d,hadInitialColor:P,selectedColor:x,initialBackgroundColor:I,initialColor:B})=>{if(d||!P)return ja(x);return{backgroundColor:I,color:B}},Pr=({name:d,label:P,placeholder:x,value:I,required:B=!1,multiline:Y=!1,onChange:Te})=>at("div",{className:"grid gap-1 sm:gap-2",children:[Ze(s,{className:"text-xs sm:text-sm",htmlFor:d,children:P}),Y?Ze(un,{className:"min-h-16 text-sm",id:d,name:d,onChange:Te,placeholder:x,required:B,value:I}):Ze(g,{className:"h-8 text-sm sm:h-9",id:d,name:d,onChange:Te,placeholder:x,required:B,value:I})]}),$a=({value:d,onChange:P})=>{let{t:x,resources:I}=r((Y)=>({t:Y.t,resources:Y.resources??[]})),B=(Y)=>I.find((re)=>String(re.id)===Y)?.id??Y;return at("div",{className:"grid gap-1 sm:gap-2",children:[Ze(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:x("resource")}),at(E,{onValueChange:(Y)=>P(B(Y)),value:d?.toString(),children:[Ze(R,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:Ze(S,{placeholder:x("selectResource")})}),Ze(w,{children:I.map((Y)=>Ze(v,{value:String(Y.id),children:Y.title},String(Y.id)))})]})]})},Ua=({isExistingEvent:d,isSubmitDisabled:P,onDelete:x,onClose:I})=>{let B=r((Y)=>Y.t);return at(ee,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[d&&Ze(o,{className:"w-full sm:mr-auto sm:w-auto",onClick:x,size:"sm",type:"button",variant:"destructive",children:B("delete")}),at("div",{className:"flex w-full gap-2 sm:w-auto",children:[Ze(o,{className:"flex-1 sm:flex-none",onClick:I,size:"sm",type:"button",variant:"outline",children:B("cancel")}),Ze(o,{className:"flex-1 sm:flex-none",disabled:P,size:"sm",type:"submit",children:d?B("update"):B("create")})]})]})},Ka=({start:d,end:P,initialAllDay:x,isExistingEvent:I})=>{let B=P.isSame(P.startOf("day")),Y=x&&B?P.subtract(1,"day").startOf("day"):P,[Te,re]=dt(d.toDate()),[Ae,Ve]=dt(Y.toDate()),[He,Fe]=dt(x),[Be,Ge]=dt(d.format("HH:mm")),[Le,ze]=dt(x?Rn:P.format("HH:mm")),[qe,_e]=dt(!1),We=Sn(d,P),je=(Qe,Xe)=>{let mt=He?Qe:wn(Qe,Xe,We);re(mt.startDate),Ge(mt.startTime),Ve(mt.endDate),ze(mt.endTime),_e(!0)},Ke={startDate:Te,startTime:Be,endDate:Ae,endTime:Le};return{startDate:Te,endDate:Ae,isAllDay:He,buildScheduleFields:()=>{if(I&&!qe)return{start:d,end:P,allDay:x};return{start:hn(Te,Be,He),end:En(Ae,Le,He),allDay:He}},startTime:Be,endTime:Le,handleStartDateChange:(Qe)=>{if(!Qe)return;let Xe=t(Qe).isAfter(t(Ae))?Qe:Ae;je({...Ke,startDate:Qe,endDate:Xe},"start")},handleEndDateChange:(Qe)=>{if(!Qe)return;let Xe=t(Qe).isBefore(t(Te))?Qe:Te;je({...Ke,endDate:Qe,startDate:Xe},"end")},handleAllDayChange:(Qe)=>{if(Fe(Qe),_e(!0),!(Qe&&Le==="00:00"))return;if(!t(Ae).isAfter(t(Te),"day"))return;Ve(t(Ae).subtract(1,"day").startOf("day").toDate()),ze(Rn)},handleStartTimeChange:(Qe)=>je({...Ke,startTime:Qe},"start"),handleEndTimeChange:(Qe)=>je({...Ke,endTime:Qe},"end")}},qa=({schedule:d,businessHours:P})=>{let{t:x,timeFormat:I}=r((je)=>({t:je.t,timeFormat:je.timeFormat})),{startDate:B,endDate:Y,isAllDay:Te,startTime:re,endTime:Ae,handleStartDateChange:Ve,handleEndDateChange:He,handleAllDayChange:Fe,handleStartTimeChange:Be,handleEndTimeChange:Ge}=d,Le;if(P)Le=(je)=>!K(t(je),P);let ze=Tr(B,P),qe=Tr(Y,P),_e=[["startDate","start-date",B,Ve],["endDate","end-date",Y,He]],We=[["startTime","start-time",re,Be,ze],["endTime","end-time",Ae,Ge,qe]];return at(Nn,{children:[at("div",{className:"flex items-center space-x-2",children:[Ze(b,{checked:Te,id:"allDay",onCheckedChange:(je)=>Fe(je===!0)}),Ze(s,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:x("allDay")})]}),Ze("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:_e.map(([je,Ke,Je,rt])=>at("div",{children:[Ze(s,{className:"text-xs sm:text-sm",htmlFor:Ke,id:n.fieldLabel(Ke),children:x(je)}),Ze(pn,{className:"mt-1",closeOnSelect:!0,date:Je,disabled:Le,id:Ke,labelId:n.fieldLabel(Ke),onChange:rt})]},je))}),!Te&&Ze("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:We.map(([je,Ke,Je,rt,ct])=>at("div",{children:[Ze(s,{className:"text-xs sm:text-sm",htmlFor:Ke,id:n.fieldLabel(Ke),children:x(je)}),Ze(yn,{className:"mt-1 h-8 text-sm sm:h-9",id:Ke,labelId:n.fieldLabel(Ke),maxTime:ct.max,minTime:ct.min,name:Ke,onChange:rt,timeFormat:I,value:Je})]},je))})]})},Za=(d)=>{let{start:P=t(),end:x=t().add(1,"hour"),allDay:I=!1,title:B="",description:Y="",location:Te="",...re}=d??{};return{...re,start:P,end:x,allDay:I,title:B,description:Y,location:Te}},Xa=({resourceId:d,resourceIds:P,hasResourceAxis:x})=>{let I=d??P?.at(0),B=x&&I===void 0,[Y,Te]=dt(I),re=x?Y:d;return{selectedResourceId:Y,setSelectedResourceId:Te,effectiveResourceId:re,resourceFields:P!==void 0?{}:{resourceId:re},showResourceSelector:B,isResourceMissing:B&&Y===void 0}},xn=({selectedEvent:d,onClose:P,onUpdate:x,onDelete:I,onAdd:B})=>{let{dialogState:Y,openEditDialog:Te,openDeleteDialog:re,closeDialog:Ae,handleConfirm:Ve}=Xt(P),{t:He,getEventManager:Fe,hasResourceAxis:Be}=r((it)=>({t:it.t,getEventManager:it.getEventManager,hasResourceAxis:it.hasResourceAxis})),{id:Ge,resourceId:Le,resourceIds:ze,start:qe,end:_e,allDay:We,color:je,backgroundColor:Ke,title:Je,description:rt,location:ct}=Za(d),{selectedResourceId:Pt,setSelectedResourceId:Rt,effectiveResourceId:Vt,resourceFields:Qe,showResourceSelector:Xe,isResourceMissing:mt}=Xa({resourceId:Le,resourceIds:ze,hasResourceAxis:Be}),mr=ce(Vt),Ft=Boolean(d&&Fe(d)),Wt=Ka({start:qe,end:_e,initialAllDay:We,isExistingEvent:Boolean(Ge)}),{buildScheduleFields:Fr}=Wt,[Ye,$e]=dt(Ya(Ke,je)),[Ue,et]=dt(!1),tt=Boolean(je||Ke),nt=(it)=>{$e(it),et(!0)},[ot,gt]=dt({title:Je,description:rt,location:ct}),[Lr,Oo]=dt({}),Ao={...d,...Lr},Ho=(it)=>Oo((Lt)=>({...Lt,...it})),pr=(it)=>{let{name:Lt,value:$t}=it.target;gt((Ut)=>({...Ut,[Lt]:$t}))},Vo=(it)=>{if(it.preventDefault(),mt)return;let Lt=Wa({colorChanged:Ue,hadInitialColor:tt,selectedColor:Ye,initialBackgroundColor:Ke,initialColor:je}),$t={title:ot.title,...Fr(),...Qe,description:ot.description,location:ot.location,...Lr};if(d?.id&&Ft){Te(d,{color:Ye,...$t});return}let Ut={id:Ge||t().format("YYYYMMDDHHmmss"),...Lt,...$t};if(Ge)x?.(Ut);else B?.(Ut);P()},Fo=()=>{if(!d?.id)return;if(Ft){re(d);return}I?.(d),P()};return at(Nn,{children:[at("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:Vo,children:[Ze(m,{className:"flex-1 min-h-0",children:at("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Ze(Pr,{label:He("title"),name:"title",onChange:pr,placeholder:He("eventTitlePlaceholder"),required:!0,value:ot.title}),Ze(Pr,{label:He("description"),multiline:!0,name:"description",onChange:pr,placeholder:He("eventDescriptionPlaceholder"),value:ot.description}),Xe&&Ze($a,{onChange:Rt,value:Pt}),Ze(qa,{businessHours:mr,schedule:Wt}),at("div",{className:"grid gap-1 sm:gap-2",children:[Ze(s,{className:"text-xs sm:text-sm",children:He("color")}),Ze(cn,{"aria-label":He("color"),onChange:nt,swatches:_a,value:Ye})]}),Ze(Pr,{label:He("location"),name:"location",onChange:pr,placeholder:He("eventLocationPlaceholder"),value:ot.location}),Ze(zr,{event:Ao,onChange:Ho})]})}),Ze(Ua,{isExistingEvent:Boolean(Ge),isSubmitDisabled:mt,onClose:P,onDelete:Fo})]}),Ze(Kt,{dialog:Y,onCancel:Ae,onResolve:Ve})]})};import{jsx as er,jsxs as Mn}from"react/jsx-runtime";var In=()=>{let{t:d,selectedEvent:P,isEventFormOpen:x,closeEventForm:I,addEvent:B,updateEvent:Y,deleteEvent:Te,renderEventForm:re}=r((Le)=>({t:Le.t,selectedEvent:Le.selectedEvent,isEventFormOpen:Le.isEventFormOpen,closeEventForm:Le.closeEventForm,addEvent:Le.addEvent,updateEvent:Le.updateEvent,deleteEvent:Le.deleteEvent,renderEventForm:Le.renderEventForm})),Ae=Qa(null),Ve=()=>{Ae.current=document.activeElement},He=(Le)=>{if(Le.preventDefault(),Ae.current instanceof HTMLElement)Ae.current.focus()},Ge={open:x,onClose:I,selectedEvent:P,onAdd:B,onUpdate:(Le)=>{Y(Le.id,Le)},onDelete:(Le)=>{Te(Le.id)}};if(re)return re(Ge);return er(k,{onOpenChange:I,open:x,children:Mn(N,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",onCloseAutoFocus:He,onOpenAutoFocus:Ve,children:[Mn(O,{className:"mb-2 sm:mb-4 shrink-0",children:[er(M,{className:"text-base sm:text-lg",children:P?.id?d("editEvent"):d("createEvent")}),er(te,{className:"text-xs sm:text-sm",children:P?.id?d("editEventDetails"):d("addNewEvent")})]}),er(xn,{...Ge})]})})};import{ChevronLeft as hs,ChevronRight as Es,Download as bs,Plus as Ss}from"lucide-react";var xr=`\r
2
+ `,kn=75,Ja=new TextEncoder,es=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"],ts=(d)=>{let P=[],x="",I=0;for(let B of d){let Y=Ja.encode(B).length,Te=P.length===0?kn:kn-1;if(I+Y>Te)P.push(x),x="",I=0;x+=B,I+=Y}return P.push(x),P.join(`${xr} `)},tr=(d)=>d.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
+ `,"\\n").replaceAll("\r",""),On=(d,P=!1)=>{if(P)return d.format("YYYYMMDD");return d.utc().format("YYYYMMDD[T]HHmmss[Z]")},rs=(d)=>d.uid||`${d.id}@ilamy.calendar`,ns=(d,P)=>{let x=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),I=d.allDay?";VALUE=DATE":"",B=["BEGIN:VEVENT",`UID:${rs(d)}`,`DTSTART${I}:${On(d.start,d.allDay)}`,`DTEND${I}:${On(d.end,d.allDay)}`,`SUMMARY:${tr(d.title)}`,d.description&&`DESCRIPTION:${tr(d.description)}`,d.location&&`LOCATION:${tr(d.location)}`].filter((re)=>Boolean(re)),Y=P("ical:vevent-properties",d).filter((re)=>typeof re==="string"),Te=[`DTSTAMP:${x}`,`CREATED:${x}`,`LAST-MODIFIED:${x}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...B,...Y,...Te]},os=(d,P,x="ilamy Calendar")=>{let I=tr(x),B=d.flatMap((Te)=>ns(Te,P));return`${["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${I}`,`X-WR-CALDESC:Exported from ${I}`,...es,...B,"END:VCALENDAR"].map(ts).join(xr)}${xr}`},An=(d,P,x="calendar.ics",I="ilamy Calendar")=>{let B=new Blob([os(d,P,I)],{type:"text/calendar;charset=utf-8"}),Y=URL.createObjectURL(B),Te=x;if(!x.endsWith(".ics"))Te=`${x}.ics`;let re=document.createElement("a");re.href=Y,re.download=Te,document.body.append(re),re.click(),re.remove(),URL.revokeObjectURL(Y)};function Hn(){let{rawEvents:d,collect:P}=r((x)=>({rawEvents:x.rawEvents,collect:x.collect}));return()=>{let x=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;An(d,P,x,"ilamy Calendar")}}import{ChevronDown as cs}from"lucide-react";import{useState as us}from"react";import{useState as ss}from"react";import{jsx as as}from"react/jsx-runtime";function rr({label:d,isSelected:P,isCurrent:x,onSelect:I}){return as("button",{"aria-pressed":P,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",x&&"ring-1 ring-inset ring-foreground/40",P&&"bg-primary text-primary-foreground"),onClick:I,type:"button",children:d})}import{jsx as Nr,jsxs as is}from"react/jsx-runtime";function Vn({selected:d,onSelect:P}){let x=r((Ae)=>Ae.t),[I,B]=ss(()=>d.year()),Y=t(),Te=(Ae)=>F(d.year(I).month(Ae).date(1)),re=Array.from({length:12},(Ae,Ve)=>({index:Ve,label:d.month(Ve).format("MMM")}));return is("div",{className:"w-72 p-3","data-slot":"month-grid",children:[Nr(Mt,{label:I,nextLabel:x("nextYear"),onNext:()=>B((Ae)=>Ae+1),onPrev:()=>B((Ae)=>Ae-1),prevLabel:x("previousYear")}),Nr("div",{className:"grid grid-cols-3 gap-1",children:re.map((Ae)=>{let Ve=I===d.year()&&Ae.index===d.month(),He=I===Y.year()&&Ae.index===Y.month()&&!Ve;return Nr(rr,{isCurrent:He,isSelected:Ve,label:Ae.label,onSelect:()=>P(Te(Ae.index))},Ae.index)})})]})}import{useState as ls}from"react";import{jsx as Mr,jsxs as ds}from"react/jsx-runtime";var Yt=12;function Fn({selected:d,onSelect:P}){let x=r((re)=>re.t),[I,B]=ls(()=>d.year()-d.year()%Yt),Y=t(),Te=Array.from({length:Yt},(re,Ae)=>I+Ae);return ds("div",{className:"w-72 p-3","data-slot":"year-grid",children:[Mr(Mt,{label:`${I} – ${I+Yt-1}`,nextLabel:x("nextYears"),onNext:()=>B((re)=>re+Yt),onPrev:()=>B((re)=>re-Yt),prevLabel:x("previousYears")}),Mr("div",{className:"grid grid-cols-3 gap-1",children:Te.map((re)=>{let Ae=re===d.year(),Ve=re===Y.year()&&!Ae;return Mr(rr,{isCurrent:Ve,isSelected:Ae,label:re,onSelect:()=>P(F(d.year(re)))},re)})})]})}import{jsx as Tt,jsxs as Ln}from"react/jsx-runtime";var ms={day:"day",week:"week",month:"month",year:"year"};function ps(d){let P=d?.navigationStep??{amount:1,unit:d?.navigationUnit??"day"};if(P.amount!==1)return"range";return ms[P.unit]??"range"}function Bn({className:d}){let{currentDate:P,currentRange:x,view:I,selectDate:B,firstDayOfWeek:Y,hiddenDays:Te,getViews:re}=r((Xe)=>({currentDate:Xe.currentDate,currentRange:Xe.currentRange,view:Xe.view,selectDate:Xe.selectDate,firstDayOfWeek:Xe.firstDayOfWeek,hiddenDays:Xe.hiddenDays,getViews:Xe.getViews})),{formatDateRange:Ae,formatTitle:Ve}=f(),[He,Fe]=us(!1),Be=re().find((Xe)=>Xe.name===I),Ge=ps(Be),Le=Boolean(Be?.columns),ze=i(P,Y),qe=Le?y(ze,Te):ze,_e=qe.at(0)??P,We=qe.at(-1)??P,je=(Xe)=>{B(Xe),Fe(!1)},Ke={year:P.format("YYYY"),month:P.format("MMM YYYY"),week:Ae(_e,We),day:P.format("ddd, MMM D, YYYY"),range:Ae(x.start,x.end)},Je={year:[P.startOf("year"),P.endOf("year").startOf("day")],month:[P.startOf("month"),P.endOf("month").startOf("day")],week:[_e,We],day:[P,P],range:[x.start,x.end]},[rt,ct]=Je[Ge],Pt=Ve(rt,ct)??Ke[Ge],Rt=Tt(_t,{defaultMonth:P.toDate(),firstDayOfWeek:Y,onSelect:(Xe)=>Xe&&je(t(Xe)),selected:P.toDate()}),Qe={year:Tt(Fn,{onSelect:je,selected:P}),month:Tt(Vn,{onSelect:je,selected:P}),week:Tt(_t,{defaultMonth:P.toDate(),firstDayOfWeek:Y,highlightedWeekOf:P,onSelect:(Xe)=>Xe&&je(t(Xe)),weekHover:!0}),day:Rt,range:Rt}[Ge];return Ln(yt,{onOpenChange:Fe,open:He,children:[Tt(Dt,{asChild:!0,children:Ln(o,{className:e("font-semibold",d),"data-testid":"calendar-title",variant:"outline",children:[Pt,Tt(cs,{className:"size-4 shrink-0 opacity-50"})]})}),Tt(Ct,{align:"start",className:"w-auto p-0",children:Qe})]})}import*as ut from"@radix-ui/react-dropdown-menu";import{jsx as jt}from"react/jsx-runtime";function Gn({...d}){return jt(ut.Root,{"data-slot":"dropdown-menu",...d})}function zn({...d}){return jt(ut.Trigger,{"data-slot":"dropdown-menu-trigger",...d})}function _n({className:d,sideOffset:P=4,align:x="end",...I}){return jt(ut.Portal,{children:jt(ut.Content,{align:x,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:P,...I})})}function Yn({className:d,...P}){return jt(ut.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",...P})}import{Check as fs,ChevronDown as gs}from"lucide-react";function nr(){let{getViews:d,hasResourceAxis:P}=r((x)=>({getViews:x.getViews,hasResourceAxis:x.hasResourceAxis}));return d().filter((x)=>!P||x.supportsResources)}import{jsx as Et,jsxs as Ir}from"react/jsx-runtime";function jn({className:d}){let{view:P,setView:x,t:I}=r((Ae)=>({view:Ae.view,setView:Ae.setView,t:Ae.t})),B=nr(),Y=B.find((Ae)=>Ae.name===P),Te=Y?I(Y.label??Y.name):"",re=Y?.icon;return Ir(Gn,{children:[Et(zn,{asChild:!0,className:d,children:Ir(o,{size:"default",variant:"outline",children:[re&&Et(re,{className:"size-4"}),Et("span",{children:Te}),Et(gs,{className:"size-4 opacity-50"})]})}),Et(_n,{align:"end",className:"min-w-40",children:B.map((Ae)=>{let Ve=Ae.icon;return Ir(Yn,{onSelect:()=>x(Ae.name),children:[Et(Ve,{className:"size-4"}),Et("span",{className:"flex-1",children:I(Ae.label??Ae.name)}),Ae.name===P&&Et(fs,{className:"size-4"})]},Ae.name)})})]})}import*as or from"@radix-ui/react-toggle-group";import{cva as vs}from"class-variance-authority";import{createContext as ys,useContext as Ds}from"react";import{jsx as kr}from"react/jsx-runtime";var Cs=vs("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"}}),Wn=ys({size:"default",variant:"default"});function $n({className:d,variant:P,size:x,children:I,...B}){return kr(or.Root,{className:e("flex items-center justify-center gap-1",d),"data-slot":"toggle-group",...B,children:kr(Wn.Provider,{value:{variant:P,size:x},children:I})})}function Un({className:d,children:P,variant:x,size:I,...B}){let Y=Ds(Wn);return kr(or.Item,{className:e(Cs({variant:Y.variant||x,size:Y.size||I}),d),"data-slot":"toggle-group-item",...B,children:P})}import{jsx as Kn}from"react/jsx-runtime";function qn({className:d}){let{view:P,setView:x,t:I}=r((Y)=>({view:Y.view,setView:Y.setView,t:Y.t})),B=nr();return Kn($n,{className:e("bg-muted gap-0 rounded-lg p-0.75",d),onValueChange:(Y)=>Y&&x(Y),size:"sm",type:"single",value:P,children:B.map((Y)=>Kn(Un,{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:I(Y.label??Y.name)},Y.name))})}import{jsx as st,jsxs as kt}from"react/jsx-runtime";var Zn=({className:d=""})=>{let{nextPeriod:P,prevPeriod:x,today:I,openEventForm:B,headerComponent:Y,headerClassName:Te,t:re,hideExportButton:Ae}=r((He)=>({nextPeriod:He.nextPeriod,prevPeriod:He.prevPeriod,today:He.today,openEventForm:He.openEventForm,headerComponent:He.headerComponent,headerClassName:He.headerClassName,t:He.t,hideExportButton:He.hideExportButton})),Ve=Hn();if(Y)return Y;return st("div",{className:e("@container/base-header w-full",Te),"data-testid":"calendar-header",children:kt("div",{className:e("flex flex-col items-center gap-2 @xl/base-header:flex-row @xl/base-header:justify-between",d),children:[kt("div",{className:"flex min-w-0 flex-wrap items-center justify-center gap-2",children:[kt("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[st(o,{"aria-label":re("previous"),className:"h-full",onClick:x,size:"icon",variant:"ghost",children:st(hs,{className:"size-4"})}),st(o,{"aria-label":re("next"),className:"h-full",onClick:P,size:"icon",variant:"ghost",children:st(Es,{className:"size-4"})})]}),st(o,{onClick:I,size:"default",variant:"outline",children:re("today")}),st(Bn,{})]}),kt("div",{className:"flex items-center gap-2",children:[st(qn,{className:"hidden @4xl/base-header:flex"}),st(jn,{className:"@4xl/base-header:hidden"}),!Ae&&kt(o,{"aria-label":re("export"),onClick:Ve,size:"default",variant:"outline",children:[st(bs,{className:"size-4"}),st("span",{className:"hidden @2xl/base-header:inline",children:re("export")})]}),kt(o,{"aria-label":re("new"),onClick:()=>B(),size:"default",children:[st(Ss,{className:"size-4"}),st("span",{className:"hidden @2xl/base-header:inline",children:re("new")})]})]})]})})};import{useMemo as Ar}from"react";import{useRef as ao}from"react";import{useEffect as Xn,useRef as Qn}from"react";var ws=/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?$/,Rs=3600,Ts=86400000,Ps="[data-hour]",xs='[data-start]:not([data-all-day="true"])',Ns=(d)=>{let P=ws.exec(d),x=P?.at(1);if(!x)return null;let I=Number.parseInt(x,10),B=Number.parseInt(P?.at(2)??"0",10),Y=Number.parseInt(P?.at(3)??"0",10);if(!(I<=23&&B<=59&&Y<=59))return null;let re=B*60+Y;return{hour:I,hourFraction:re/Rs}},Ot=(d)=>Number.parseInt(d.getAttribute("data-hour")??"",10),Ms=(d)=>{let P=d.findIndex((x,I)=>{let B=d.at(I-1);return!(I===0||B===void 0)&&Ot(x)<=Ot(B)});return P===-1?d:d.slice(0,P)},Is=(d,P)=>{let x=d.at(0),I=d.at(-1);if(!x||!I)return null;if(P<=Ot(x))return x;if(P>=Ot(I))return I;return d.find((B)=>Ot(B)===P)??null},Jn=(d)=>({start:t(d.dataset.start??""),end:t(d.dataset.end??"")}),ks=(d)=>{let P=Array.from(d.querySelectorAll(xs)),x=P.at(0),I=t(),B=P.find((He)=>c(Jn(He),I,I));if(!x||!B)return null;let{start:Y,end:Te}=Jn(B),re=Te.diff(Y),Ve=re<Ts?I.diff(Y)/re:0;return{target:B,origin:x,fraction:Ve}},Os=(d,P)=>{let x=P?Ns(P):null;if(x===null)return null;let I=Ms(Array.from(d.querySelectorAll(Ps))),B=I.at(0),Y=Is(I,x.hour);if(!B||!Y)return null;let re=Ot(Y)===x.hour?x.hourFraction:0;return{target:Y,origin:B,fraction:re}},As=(d,P,x,I,B)=>{let Y=P.getBoundingClientRect(),Te=x.getBoundingClientRect(),re=Y.left-Te.left,Ae=Y.top-Te.top,Ve=B==="horizontal"?re:Ae,He=B==="horizontal"?Y.width:Y.height;to(d,B,Ve+I*He)},to=(d,P,x)=>{let I=P==="horizontal"?"left":"top";d.scrollTo({[I]:x,behavior:"auto"})},eo=(d,{scrollTime:P,scrollToNow:x,axis:I})=>{let Y=(x?ks(d):null)??Os(d,P);if(Y)return As(d,Y.target,Y.origin,Y.fraction,I),!0;if(x)return to(d,I,0),!0;return!1},ar=({viewportRef:d,scrollTime:P,scrollToNow:x=!1,scrollRequest:I,enabled:B,scrollKey:Y,axis:Te="vertical"})=>{let re=Qn(null);Xn(()=>{if(!B)return;let Ve=`${Y}|${P}|${x}`;if(re.current===Ve)return;let He=d.current;if(!He)return;if(eo(He,{scrollTime:P,scrollToNow:x,axis:Te}))re.current=Ve},[B,P,x,Y,d,Te]);let Ae=Qn(I);Xn(()=>{let Ve=d.current,He=I!==Ae.current;if(!B||!Ve||!I||!He)return;if(eo(Ve,{scrollTime:I.time,scrollToNow:!1,axis:Te}))Ae.current=I},[B,I,d,Te])};import{useLayoutEffect as Hs}from"react";var Or="data-sticky-inset",sr=(d)=>d?"top":void 0,ro={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},no=new Set(["hidden","scroll","auto","overlay","clip"]),Vs=(d)=>{let P=[];for(let x=d.parentElement;x;x=x.parentElement){let{overflowX:I,overflowY:B}=getComputedStyle(x);if(no.has(I)||no.has(B))P.push(x)}return P},Fs=(d,P,x)=>{let I=P.getBoundingClientRect(),B={left:-I.left,top:-I.top};for(let Te of x){let re=Te.getBoundingClientRect();B.left=Math.max(B.left,re.left-I.left),B.top=Math.max(B.top,re.top-I.top)}let Y=d.querySelectorAll(`[${Or}]`);for(let Te of Y){let re=Te.getAttribute(Or),Ae=Te.getBoundingClientRect();if(re==="left")B.left=Math.max(B.left,Ae.right-I.left);if(re==="top")B.top=Math.max(B.top,Ae.bottom-I.top)}return{left:Math.max(0,B.left),top:Math.max(0,B.top)}},ir=(d,P,x)=>{let{currentDate:I,view:B,stickyViewHeader:Y}=r((re)=>({currentDate:re.currentDate,view:re.view,stickyViewHeader:re.stickyViewHeader})),Te=n.stickyInsets(B,I,Y,x);Hs(()=>{let re=d.current,Ae=P.current;if(!re||!Ae)return;let Ve=Vs(re),He=()=>{let ze=Fs(re,Ae,Ve);Ae.style.setProperty(ro.left,`${ze.left}px`),Ae.style.setProperty(ro.top,`${ze.top}px`)};He();let Fe,Be=()=>{if(Fe!==void 0)return;Fe=requestAnimationFrame(()=>{Fe=void 0,He()})},Ge=[...Ve,window];for(let ze of Ge)ze.addEventListener("scroll",Be,{passive:!0});window.addEventListener("resize",Be,{passive:!0});let Le=typeof ResizeObserver>"u"?void 0:new ResizeObserver(He);Le?.observe(Ae);for(let ze of re.querySelectorAll(`[${Or}]`))Le?.observe(ze);return()=>{for(let ze of Ge)ze.removeEventListener("scroll",Be);if(window.removeEventListener("resize",Be),Le?.disconnect(),Fe!==void 0)cancelAnimationFrame(Fe)}},[d,P,Te])};var Ls=(d)=>{if(d.days)return d.days;return d.day?[d.day]:[]},lr=(d,P,x)=>{let I=x.flatMap(Ls).map((Y)=>Y.toISOString()),B=[...new Set(I)].join(",");return`${d}-${P.format("YYYY-MM-DD")}-${B}`};import{memo as Bs}from"react";import{jsx as zs}from"react/jsx-runtime";var Gs=({children:d,className:P})=>{let{stickyViewHeader:x,viewHeaderClassName:I}=r((B)=>({stickyViewHeader:B.stickyViewHeader,viewHeaderClassName:B.viewHeaderClassName}));return zs("div",{className:e("flex h-12 w-fit",x&&"sticky top-0 z-21 bg-background",P,I),"data-sticky-inset":sr(x),"data-testid":"horizontal-grid-header",children:d})},oo=Bs(Gs);import{jsx as At,jsxs as so}from"react/jsx-runtime";var io=({rows:d,children:P,classes:x,allDay:I,gridType:B,variant:Y="resource",dayNumberHeight:Te})=>{let{currentDate:re,view:Ae,scrollTime:Ve,scrollToNow:He,scrollRequest:Fe}=r(),Be=ao(null),Ge=ao(null),Le=Y==="resource",ze=!Le,qe=d.flatMap((je)=>je.columns??[]),_e=lr(Ae,re,qe);ar({viewportRef:Ge,scrollTime:Ve,scrollToNow:He,scrollRequest:Fe,enabled:Le,scrollKey:_e,axis:"horizontal"}),ir(Be,Ge,d.length);let We=P&&At(oo,{className:x?.header,children:P});return so("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:Be,children:[ze&&We,so(m,{className:e("h-full",ze&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:Ge},children:[Le&&We,At("div",{className:e("flex flex-1 w-fit",x?.body),"data-testid":"horizontal-grid-body",children:At("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:d.map((je)=>At(De,{allDay:je.allDay??I,dayNumberHeight:Te,gridType:B,variant:Y,...je},je.id))})}),At(C,{className:"z-30"}),At(C,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as So}from"react";import{useDroppable as ei}from"@dnd-kit/core";import{memo as Do,useId as ti,useMemo as ri}from"react";import{memo as Zs,useMemo as Xs}from"react";import{useMemo as co}from"react";var _s=(d)=>{let P=[],x=[],I=null;for(let B of d){if(I&&B.start.isSameOrAfter(I)){if(x.length>0)P.push(x);x=[]}x.push(B),I=I?t.max(I,B.end):B.end}if(x.length>0)P.push(x);return P},Ys=(d,P)=>{let x=[],I=[],B=-1;for(let Y of d){let Te=P(Y);if(!Te)continue;if(Te.startCol>B&&I.length>0)x.push(I),I=[];I.push(Y),B=Math.max(B,Te.endCol)}if(I.length>0)x.push(I);return x},js=(d,P,x)=>{let I=x(d);if(!I)return null;let B=I.endCol-I.startCol+1;return{top:I.startCol/P*100,height:B/P*100,isTruncatedStart:I.isTruncatedStart,isTruncatedEnd:I.isTruncatedEnd}},lo=(d,{days:P,gridStart:x,totalUnits:I,gridType:B,spanDayColumns:Y})=>{if(Y)return js(d,P.length,Y);let Te=D(d.start,x,B),re=D(d.end,x,B),Ae=Te<0,Ve=re>I;if(Ae)Te=0;if(Ve)re=I;let He=Math.max(0,re-Te);if(He===0)return null;return{top:Te/I*100,height:He/I*100,isTruncatedStart:Ae,isTruncatedEnd:Ve}},Ws={2:25,3:50,4:60},$s=70,Us=(d)=>Ws[d]??$s,Ks=(d,P)=>{let x=d.length===1?d.at(0):void 0;if(x){let re=lo(x,P);if(!re)return[];return[{kind:"vertical",event:x,left:0,width:100,...re}]}let I=[...d].sort((re,Ae)=>{let Ve=Ae.end.diff(Ae.start,"minute")-re.end.diff(re.start,"minute");return Ve!==0?Ve:re.start.diff(Ae.start)}),B=I.length,Y=B>1?Us(B)/(B-1):0,Te=[];for(let re=0;re<B;re++){let Ae=I.at(re);if(!Ae)continue;let Ve=lo(Ae,P);if(!Ve)continue;let He=re===0?0:Y*re;Te.push({kind:"vertical",event:Ae,...Ve,left:He,width:100-He,zIndex:re+1})}return Te},dr=({days:d,gridType:P="hour",events:x})=>{let I=P==="day",Y=(I?x:x.filter((Ae)=>!Ae.allDay)).toSorted((Ae,Ve)=>Ae.start.diff(Ve.start));if(Y.length===0)return[];let Te={days:d,gridStart:d.at(0)||t(),totalUnits:d.length,gridType:P,spanDayColumns:I?fe(d):null};return(Te.spanDayColumns?Ys(Y,Te.spanDayColumns):_s(Y)).flatMap((Ae)=>Ks(Ae,Te))};var uo=({days:d,gridType:P,resourceId:x})=>{let{getEventsForDateRange:I}=r(),B=me(),Y=d.at(0),Te=d.at(-1),re=Y&&j(Y,"day",B).start,Ae=Te&&j(Te,"day",B).end,Ve=co(()=>{if(!re||!Ae)return[];let Fe=I(re,Ae);return pe(Fe,x)},[re,Ae,I,x]);return co(()=>dr({days:d,events:Ve,gridType:P}),[d,P,Ve])};import{jsx as qs,jsxs as mo}from"react/jsx-runtime";function po({previewPositioned:d}){let P=r((re)=>re.timeFormat),{event:x,isTruncatedStart:I,isTruncatedEnd:B}=d,Y=de(P),Te=!x.allDay;return mo(ve,{contentClassName:"px-1.5 py-1 relative",event:x,isTruncatedEnd:B,isTruncatedStart:I,orientation:"vertical",style:Ce(d),children:[Te&&mo("p",{className:"text-[10px] font-semibold sm:text-xs",children:[x.start.format(Y)," – ",x.end.format(Y)]}),qs("p",{className:e("text-[10px] font-bold sm:text-xs truncate",z.vertical),children:x.title})]})}import{jsx as fo}from"react/jsx-runtime";var go=(d,P,x,I)=>`event-${d}-${P}-${x.at(0)?.toISOString()}-${I??"no-resource"}`;function vo({positioned:d,elementId:P,range:x,resourceId:I,draggedEventId:B,hiddenDays:Y}){let{event:Te}=d,re=Te.end.diff(Te.start,"minute")<=15;return fo("div",{className:"absolute","data-testid":n.container.verticalEvent(Te.id),style:Ce(d),children:fo(_,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":re}),dragSegment:ae(Te,x,"vertical",Y),elementId:P,event:Te,isBeingDragged:B===Te.id,isTruncatedEnd:d.isTruncatedEnd,isTruncatedStart:d.isTruncatedStart,resizeGranularity:"slot",sourceResourceId:I})})}import{jsx as cr,jsxs as Js}from"react/jsx-runtime";var Qs=({days:d,gridType:P="hour",resourceId:x,resource:I,"data-testid":B})=>{let Y=p(),Te=uo({days:d,gridType:P,resourceId:x}),re=d.at(0),Ae=d.at(-1)?.add(1,P),Ve=ge(P),He=G({days:d,gridType:P,resourceId:x}),Fe=Xs(()=>{if(!He)return null;return dr({days:d,gridType:P,events:[He]}).at(0)??null},[He,d,P]);return cr(Z.Provider,{value:"vertical",children:Js("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":B,children:[cr(ye,{axis:"vertical",days:d,gridType:P,resource:I,resourceId:x}),Te.map((Be,Ge)=>{let Le=go(Be.event.id,Ge,d,x);return cr(vo,{draggedEventId:Y?.event.id,elementId:Le,hiddenDays:Ve,positioned:Be,range:{start:re,end:Ae},resourceId:x},n.listKey(Le,"wrapper"))}),Fe&&cr(po,{previewPositioned:Fe})]})})},yo=Zs(Qs);import{jsx as bt,jsxs as ii,Fragment as si}from"react/jsx-runtime";var Co=(d)=>Array.from({length:Math.floor(60/d)},(P,x)=>x*d),ni=({id:d,days:P,gridType:x,renderCell:I,resourceId:B,slotDurationMinutes:Y,slots:Te,dragPreview:re})=>{let Ae=Co(Y),Ve=Ae.length>1;return bt(si,{children:P.map((He,Fe)=>{let Be=He.format("HH");if(I){let Ge=d===n.col.time,Le=Ge?n.cell.verticalTime(Be):n.cell.vertical(He,Be,"00",B);return bt("div",{className:"min-h-[60px] bg-background","data-hour":Ge?Be:void 0,"data-testid":Le,children:I(He)},n.listKey(Fe,Be))}return bt("div",{className:"flex flex-col min-h-[60px]",children:Ae.map((Ge,Le)=>{let ze=String(Ge).padStart(2,"0"),qe=n.cell.vertical(He,Be,ze,B),_e=Ve&&Le<Ae.length-1;return bt(Q,{axis:"vertical",className:e("not-in-data-dragging:hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",_e&&"border-b border-dashed"),"data-testid":qe,day:Ve?He.minute(Ge):He,dragPreview:re,dropSlots:Te,gridType:x,hour:x==="hour"?He.hour():void 0,isSubDivider:_e,minute:Ve?Ge:void 0,resourceId:B,shouldRenderEvents:!1,slotDurationMinutes:Y,slotIndex:Fe*Ae.length+Le},n.listKey(Fe,ze))})},n.listKey(Fe,Be))})})},oi=Do(ni),ai=({id:d,days:P,resource:x,"data-testid":I,"data-sticky-inset":B,gridType:Y,className:Te,renderCell:re,noEvents:Ae,slotDurationMinutes:Ve=60})=>{let He=x?.id,Fe=Co(Ve).length,Be=P.length*Fe,Ge=ri(()=>Array.from({length:Be},()=>{return}),[Be]),Le=p(),qe=G({days:P,gridType:Y??"hour",resourceId:He})!==null?Le:null,{setNodeRef:_e}=ei({id:ti(),data:{slots:Ge},disabled:re!==void 0});return bt("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",Te),"data-sticky-inset":B,"data-testid":I||n.container.vertical.col(d),children:ii("div",{className:"w-full h-full relative grid gap-px bg-border",ref:_e,style:{gridTemplateRows:`repeat(${P.length}, minmax(0, 1fr))`},children:[bt(oi,{days:P,dragPreview:qe,gridType:Y,id:d,renderCell:re,resourceId:He,slotDurationMinutes:Ve,slots:Ge}),!Ae&&bt("div",{className:"absolute inset-0 z-10 pointer-events-none",children:bt(yo,{"data-testid":n.container.eventsLayer("vertical",d),days:P,gridType:Y,resource:x,resourceId:He})})]})})},ho=Do(ai);import{memo as li}from"react";import{jsx as Eo,jsxs as ci}from"react/jsx-runtime";var di=({children:d,classes:P,allDayRow:x,expandAllDayRow:I=!1})=>{let{stickyViewHeader:B,viewHeaderClassName:Y}=r((re)=>({stickyViewHeader:re.stickyViewHeader,viewHeaderClassName:re.viewHeaderClassName})),Te="min-w-full w-fit";return ci("div",{className:e(I&&"flex h-full flex-col",B&&"sticky top-0 z-21 bg-background",Y),"data-sticky-inset":sr(B),children:[Eo("div",{className:e("min-h-12 border-b","min-w-full w-fit",P?.header),"data-testid":"vertical-grid-header",children:d}),x&&Eo("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",I&&"flex-1 overflow-hidden",P?.allDay),"data-testid":"vertical-grid-all-day",children:x})]})},bo=li(di);import{jsx as Ht,jsxs as wo}from"react/jsx-runtime";var Ro=({columns:d,children:P,gridType:x="day",variant:I="resource",classes:B,allDayRow:Y,slotDurationMinutes:Te,style:re})=>{let Ae=I==="resource",Ve=!Ae,He=d.every((Je)=>!Je.days?.length),{currentDate:Fe,view:Be,scrollTime:Ge,scrollToNow:Le,scrollRequest:ze}=r(),qe=So(null),_e=So(null),We=!He,je=lr(Be,Fe,d);ar({viewportRef:_e,scrollTime:Ge,scrollToNow:Le,scrollRequest:ze,enabled:We,scrollKey:je}),ir(qe,_e,d.length);let Ke=P&&Ht(bo,{allDayRow:Y,classes:{header:B?.header,allDay:B?.allDay},expandAllDayRow:He,children:P});if(He&&Ke)return Ht("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:re,children:Ke});return wo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:qe,style:re,children:[Ve&&Ke,wo(m,{className:e("h-full",Ve&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:_e},children:[Ae&&Ke,Ht("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",B?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:d.map((Je,rt)=>Ht(ho,{...Je,gridType:x,slotDurationMinutes:Te},n.listKey("col",rt)))}),Ht(C,{className:"z-30"})," ",Ht(C,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as St}from"react/jsx-runtime";var ui=(d,P)=>P==="vertical",mi=({specs:d,header:P,composesResourceAxis:x,variant:I})=>{let{slotDuration:B,allDaySlot:Y}=r((Le)=>({slotDuration:Le.slotDuration,allDaySlot:Le.allDaySlot})),Te=d.some((Le)=>Le.gridType==="hour")?"hour":"day",re=d.filter((Le)=>!Le.noEvents).map((Le)=>Le.day).filter((Le)=>Boolean(Le)),Ae=d.find((Le)=>Le.noEvents),He=Boolean(Ae?.className?.includes(W))?{cell:"flex-1 min-w-0",spacer:W}:void 0,Fe;if(Te==="hour"&&Y)Fe=x?St(Me,{columns:d}):St(he,{classes:He,days:re});return St(Ro,{allDayRow:Fe,classes:x?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:d,gridType:Te,slotDurationMinutes:B,variant:I,children:P})},pi=({specs:d,header:P,composesResourceAxis:x,variant:I})=>{let B=d.some((re)=>re.columns?.some((Ae)=>Ae.gridType==="hour"))?"hour":"day",Y=d.some((re)=>re.columns?.some((Ae)=>Ae.days)),Te=x?{header:e(Y&&Ne,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return St(io,{classes:Te,dayNumberHeight:x?0:void 0,gridType:B,rows:d,variant:I,children:P})},fi=({view:d})=>{let P=d.component;if(P)return St(P,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${d.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null},To=({view:d})=>{let{currentDate:P,firstDayOfWeek:x,hiddenDays:I,businessHours:B,hideNonBusinessHours:Y,slotMinTime:Te,slotMaxTime:re,resources:Ae,hasResourceAxis:Ve,orientation:He,weekViewGranularity:Fe}=r((We)=>({currentDate:We.currentDate,firstDayOfWeek:We.firstDayOfWeek,hiddenDays:We.hiddenDays,businessHours:We.businessHours,hideNonBusinessHours:We.hideNonBusinessHours,slotMinTime:We.slotMinTime,slotMaxTime:We.slotMaxTime,resources:We.resources,hasResourceAxis:We.hasResourceAxis,orientation:We.orientation,weekViewGranularity:We.weekViewGranularity})),Be=Ar(()=>({firstDayOfWeek:x,hiddenDays:I,businessHours:B,hideNonBusinessHours:Y,slotMinTime:Te,slotMaxTime:re,resources:Ae,hasResourceAxis:Ve,orientation:He,weekViewGranularity:Fe}),[x,I,B,Y,Te,re,Ae,Ve,He,Fe]),Ge=Ar(()=>d.columns?.(P,Be),[d,P,Be]),Le=Ar(()=>d.renderHeader?.({date:P,config:Be}),[d,P,Be]);if(!Ge||!d.layout)return St(fi,{view:d});let ze=Ve&&Boolean(d.supportsResources),qe=ze?He??"horizontal":d.layout,_e=ze?"resource":"regular";if(ui(Ge,qe))return St(mi,{composesResourceAxis:ze,header:Le,specs:Ge,variant:_e});return St(pi,{composesResourceAxis:ze,header:Le,specs:Ge,variant:_e})};import{useEffect as Po}from"react";var ur=(d)=>{if(typeof process<"u"&&!1)console.warn(d)};var xo=(d,P)=>{Po(()=>{if(d&&!P)ur("[@ilamy/calendar] `orientation` was provided without `resources` — it only applies when the calendar has resources, so it is ignored.")},[d,P])},No=(d,P)=>{let{invalidProps:x}=Pe(d,P),I=x.join(", ");Po(()=>{if(I)console.warn(`[@ilamy/calendar] \`${I}\` is not a usable visible-hours range ('HH:mm' from '00:00' to '24:00', with slotMaxTime after slotMinTime), so the whole day is shown.`)},[I])};import{useMemo as gi}from"react";var Mo=(d=[],P=!0)=>{let x=new Set(d.map((I)=>T[I]));if(!P)x.add(T.sunday),x.add(T.saturday);return x.size===0?void 0:x};function Hr(d){if(!d?.length)return[];return d.map((P)=>({...P,start:t(P.start),end:t(P.end)}))}var vi=(d)=>async(P,x)=>Hr(await d(P,x)),Io=(d)=>{let P=typeof d==="function"?vi(d):void 0,x=typeof d==="function"?void 0:d;return{normalizedEvents:gi(()=>Hr(x),[x]),eventsFetcher:P}};import{useEffect as yi,useMemo as Di}from"react";var ko=(d,P)=>{let x=[...Mo(d,P)??[]].sort().join(","),I=Di(()=>x===""?void 0:new Set(x.split(",").map(Number)),[x]),B=I?.size===le;return yi(()=>{if(B)ur("[@ilamy/calendar] `hiddenDays` and `weekends` together hide every day of the week, so they are ignored.")},[B]),B?void 0:I};import{jsx as wt,jsxs as Ti}from"react/jsx-runtime";var Si=({calendarRef:d})=>{Ri(d);let{view:P,getViews:x}=r((Y)=>({view:Y.view,getViews:Y.getViews})),I=x().find((Y)=>Y.name===P);return Ti("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[wt(Zn,{className:"p-1 shrink-0 mb-1"}),wt(ln,{children:wt(a,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:P,children:wt("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:I?wt(To,{view:I},P):null})})}),wt(In,{})]})},wi=(d)=>{let P={};for(let[x,I]of Object.entries(d())){let B=typeof I==="function",Y=(...Te)=>Reflect.apply(Reflect.get(d(),x),void 0,Te);Object.defineProperty(P,x,{enumerable:!0,get:B?()=>Y:()=>Reflect.get(d(),x)})}return P},Ri=(d)=>{let P=Se(),x=bi(P);hi(()=>{x.current=P});let I=Ei(()=>wi(()=>x.current),[]);Ci(d,()=>I,[I])},Vr=({events:d,firstDayOfWeek:P="sunday",initialView:x="month",initialDate:I,eventSpacing:B=se,eventHeight:Y=ie,stickyViewHeader:Te=!0,viewHeaderClassName:re="",hideNonBusinessHours:Ae=!1,slotMinTime:Ve,slotMaxTime:He,hiddenDays:Fe,weekends:Be,resources:Ge,orientation:Le,ref:ze,...qe})=>{let _e=typeof Ge==="function"?Ge:void 0,We=typeof Ge==="function"?void 0:Ge,je=Boolean(_e)||Boolean(We?.length),{normalizedEvents:Ke,eventsFetcher:Je}=Io(d),rt=ko(Fe,Be);return xo(Le,je),No(Ve,He),wt(J,{eventHeight:Y,eventSpacing:B,events:Ke,eventsFetcher:Je,firstDayOfWeek:T[P],hiddenDays:rt,hideNonBusinessHours:Ae,initialDate:I,initialView:x,orientation:Le,resources:We,resourcesFetcher:_e,slotMaxTime:He,slotMinTime:Ve,stickyViewHeader:Te,viewHeaderClassName:re,...qe,children:wt(Si,{calendarRef:ze})})};import{jsx as xi}from"react/jsx-runtime";var Pi=(d)=>xi(Vr,{...d});export{Vr as IlamyCalendar,Pi as IlamyResourceCalendar,Br as SLOT_EVENT_FORM,Gr as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,Ee as defaultTranslations,Se as useIlamyCalendarContext};
@@ -47,6 +47,16 @@ interface CalendarEvent {
47
47
  * @example { meetingType: 'standup', attendees: ['john', 'jane'] }
48
48
  */
49
49
  data?: Record<string, unknown>;
50
+ /**
51
+ * Whether this event can be moved. Beats the calendar's
52
+ * `editable`; `startEditable` beats this one (FullCalendar
53
+ * `event.editable`).
54
+ */
55
+ editable?: boolean;
56
+ /** Whether this event can be moved. Defaults to `editable`. */
57
+ startEditable?: boolean;
58
+ /** Whether this event can be resized by its edges. Defaults to `editable`. */
59
+ durationEditable?: boolean;
50
60
  }
51
61
  /**
52
62
  * Supported days of the week for calendar configuration.
@@ -134,6 +144,13 @@ interface PluginMutationResult {
134
144
  added: CalendarEvent[];
135
145
  /** Existing rows to persist via `onEventDelete`. */
136
146
  deleted: CalendarEvent[];
147
+ /**
148
+ * The update as it was stored, when that is less than what was asked: a
149
+ * scope that keeps its own day applies only the time of day of a drop on
150
+ * another day. `delta` and `endDelta` describe these, not the request.
151
+ * Omit it when the update was stored as asked.
152
+ */
153
+ appliedUpdates?: Partial<CalendarEvent>;
137
154
  }
138
155
  /**
139
156
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
@@ -143,12 +160,23 @@ interface PluginMutationResult {
143
160
  */
144
161
  interface ViewConfig {
145
162
  firstDayOfWeek: number;
163
+ /** Weekdays (0 = Sunday) the view does not draw. Absent when none are hidden. */
146
164
  hiddenDays?: Set<number>;
147
165
  businessHours?: BusinessHours | BusinessHours[];
148
166
  hideNonBusinessHours?: boolean;
167
+ /** First visible time in hour grids, `'HH:mm'`. Unset shows from midnight. */
168
+ slotMinTime?: string;
169
+ /** End of the visible time in hour grids, exclusive, `'HH:mm'` up to `'24:00'`. */
170
+ slotMaxTime?: string;
149
171
  /** The resource axis. Set only when the calendar renders resources. */
150
172
  resources?: Resource[];
151
173
  /**
174
+ * Whether the calendar is a resource calendar: it has resources, or is still
175
+ * loading them (then `resources` is empty or absent). When absent, it is
176
+ * derived from `resources` being non-empty.
177
+ */
178
+ hasResourceAxis?: boolean;
179
+ /**
152
180
  * The calendar-level resource arrangement (the user's choice): where the
153
181
  * resource axis goes. Only meaningful when `resources` is set.
154
182
  */
@@ -200,6 +228,11 @@ interface HorizontalRowSpec {
200
228
  columns?: HorizontalCellSpec[];
201
229
  className?: string;
202
230
  showDayNumber?: boolean;
231
+ /**
232
+ * Marks the row as one calendar week, so it shows its week number at its
233
+ * start when the calendar's `weekNumbers` is `true`.
234
+ */
235
+ showWeekNumber?: boolean;
203
236
  /** Resource-axis identity when the row belongs to one resource. */
204
237
  resource?: Resource;
205
238
  }
@@ -1 +1 @@
1
- import{e,U,d,T}from"../shared/chunk-89xfgjfh.js";import{u,b,Y}from"../shared/chunk-bgegqhb4.js";import{t}from"../shared/chunk-nvtnncwx.js";import{List as L}from"lucide-react";import{createElement as M}from"react";import{useIlamyCalendarContext as F}from"@ilamy/calendar";var S={day:(a)=>({start:a.startOf("day"),end:a.endOf("day")}),week:(a,n)=>{let r=(a.day()-n+7)%7,o=a.subtract(r,"day").startOf("day");return{start:o,end:o.add(6,"day").endOf("day")}},month:(a)=>({start:a.startOf("month"),end:a.endOf("month")})},P={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},p=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return S[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return P[a]};var W=(a,n,r)=>{if(a.allDay)return d(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},V=(a,n)=>{let r=a.allDay?0:1,o=n.allDay?0:1;if(r!==o)return r-o;return a.start.valueOf()-n.start.valueOf()},v=(a,n)=>{let r=[],o=n.end.startOf("day"),s=n.start.startOf("day");while(s.isSameOrBefore(o)){let i=s.startOf("day"),y=s.endOf("day"),m=a.filter((l)=>W(l,i,y)).sort(V);if(m.length>0)r.push({key:s.format("YYYY-MM-DD"),date:i,events:m});s=s.add(1,"day")}return r};import{useIlamyCalendarContext as B}from"@ilamy/calendar";import{useIlamyCalendarContext as j}from"@ilamy/calendar";import{jsx as f,jsxs as G}from"react/jsx-runtime";var I=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:s}=j(),i=a.start.format(I(o)),y=a.allDay?r("allDay"):i,m=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(m,"day")+1,R=n.startOf("day").diff(m,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return G("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>s(a),type:"button",children:[f("span",{className:"text-muted-foreground w-20 shrink-0",children:y}),f("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),f("span",{className:"truncate",children:a.title}),x&&f("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as c,jsxs as k}from"react/jsx-runtime";var C=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=B(),o=U(a.date,t()),s;if(r)s=(i)=>r({...i,view:n});return k("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":T("agenda-day",a.key),children:[c("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:c(b,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),k("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&c(Y,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:s}),a.events.map((i)=>c(O,{day:a.date,event:i},T(a.key,i.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var h=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:s}=F(),i=p(n,a,s),y=r(i.start,i.end),m=v(y,i);if(m.length===0)return g("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-sm","data-testid":"agenda-empty",children:o("agendaNoEvents")});return g(u,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:m.map((l)=>g(C,{group:l},l.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:L,navigationStep:A(a),range:(n,r)=>p(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>M(h,{window:a})});var H=(a={})=>({name:"agenda",views:[D(a)]});export{H as agendaPlugin,D as createAgendaView};
1
+ import{e}from"../shared/chunk-8n7287tn.js";import{m,x,re}from"../shared/chunk-58t5nwpa.js";import{t,P,c,I}from"../shared/chunk-qc1dpk9c.js";import{List as K}from"lucide-react";import{createElement as q}from"react";import{useIlamyCalendarContext as z}from"@ilamy/calendar";var T={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")})},G={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 T[n](a,r)},O=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return G[a]};var L=(a,n,r)=>c(a,n,r),F=(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()},k=(a,n)=>{let r=[],o=n.end.startOf("day"),d=n.start.startOf("day");while(d.isSameOrBefore(o)){let s=d.startOf("day"),y=d.endOf("day"),l=a.filter((i)=>L(i,s,y)).sort(F);if(l.length>0)r.push({key:d.format("YYYY-MM-DD"),date:s,events:l});d=d.add(1,"day")}return r};import{useIlamyCalendarContext as H}from"@ilamy/calendar";import{useIlamyCalendarContext as B}from"@ilamy/calendar";import{jsx as f,jsxs as M}from"react/jsx-runtime";var Y=(a)=>a==="24-hour"?"HH:mm":"h:mm A",C=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:d}=B(),s=Y(o),y=a.start.startOf("day"),i=a.end.subtract(1,"millisecond").startOf("day").diff(y,"day")+1,D=n.startOf("day").diff(y,"day")+1,w=i>1,N=D===1,v=D===i,S=Boolean(a.allDay)||w&&!N&&!v,W=w&&v?a.end:a.start,V=S?r("allDay"):W.format(s),j=`(${r("day")} ${D}/${i})`,b=w?j:null;return M("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:[f("span",{className:"text-muted-foreground w-20 shrink-0",children:V}),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}),b&&f("span",{className:"text-muted-foreground shrink-0 text-xs",children:b})]})};import{jsx as u,jsxs as h}from"react/jsx-runtime";var E=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=H(),o=P(a.date,t()),d;if(r)d=(s)=>r({...s,view:n});return h("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":I("agenda-day",a.key),children:[u("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:u(x,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),h("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&u(re,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:d}),a.events.map((s)=>u(C,{day:a.date,event:s},I(a.key,s.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var R=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:d}=z(),s=p(n,a,d),y=r(s.start,s.end),l=k(y,s);if(l.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(m,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:l.map((i)=>g(E,{group:i},i.key))})})};var A=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:K,navigationStep:O(a),range:(n,r)=>p(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>q(R,{window:a})});var J=(a={})=>({name:"agenda",views:[A(a)]});export{J as agendaPlugin,A as createAgendaView};
@@ -47,6 +47,16 @@ interface CalendarEvent {
47
47
  * @example { meetingType: 'standup', attendees: ['john', 'jane'] }
48
48
  */
49
49
  data?: Record<string, unknown>;
50
+ /**
51
+ * Whether this event can be moved. Beats the calendar's
52
+ * `editable`; `startEditable` beats this one (FullCalendar
53
+ * `event.editable`).
54
+ */
55
+ editable?: boolean;
56
+ /** Whether this event can be moved. Defaults to `editable`. */
57
+ startEditable?: boolean;
58
+ /** Whether this event can be resized by its edges. Defaults to `editable`. */
59
+ durationEditable?: boolean;
50
60
  }
51
61
  /**
52
62
  * Supported days of the week for calendar configuration.
@@ -134,6 +144,13 @@ interface PluginMutationResult {
134
144
  added: CalendarEvent[];
135
145
  /** Existing rows to persist via `onEventDelete`. */
136
146
  deleted: CalendarEvent[];
147
+ /**
148
+ * The update as it was stored, when that is less than what was asked: a
149
+ * scope that keeps its own day applies only the time of day of a drop on
150
+ * another day. `delta` and `endDelta` describe these, not the request.
151
+ * Omit it when the update was stored as asked.
152
+ */
153
+ appliedUpdates?: Partial<CalendarEvent>;
137
154
  }
138
155
  /**
139
156
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
@@ -143,12 +160,23 @@ interface PluginMutationResult {
143
160
  */
144
161
  interface ViewConfig {
145
162
  firstDayOfWeek: number;
163
+ /** Weekdays (0 = Sunday) the view does not draw. Absent when none are hidden. */
146
164
  hiddenDays?: Set<number>;
147
165
  businessHours?: BusinessHours | BusinessHours[];
148
166
  hideNonBusinessHours?: boolean;
167
+ /** First visible time in hour grids, `'HH:mm'`. Unset shows from midnight. */
168
+ slotMinTime?: string;
169
+ /** End of the visible time in hour grids, exclusive, `'HH:mm'` up to `'24:00'`. */
170
+ slotMaxTime?: string;
149
171
  /** The resource axis. Set only when the calendar renders resources. */
150
172
  resources?: Resource[];
151
173
  /**
174
+ * Whether the calendar is a resource calendar: it has resources, or is still
175
+ * loading them (then `resources` is empty or absent). When absent, it is
176
+ * derived from `resources` being non-empty.
177
+ */
178
+ hasResourceAxis?: boolean;
179
+ /**
152
180
  * The calendar-level resource arrangement (the user's choice): where the
153
181
  * resource axis goes. Only meaningful when `resources` is set.
154
182
  */
@@ -200,6 +228,11 @@ interface HorizontalRowSpec {
200
228
  columns?: HorizontalCellSpec[];
201
229
  className?: string;
202
230
  showDayNumber?: boolean;
231
+ /**
232
+ * Marks the row as one calendar week, so it shows its week number at its
233
+ * start when the calendar's `weekNumbers` is `true`.
234
+ */
235
+ showWeekNumber?: boolean;
203
236
  /** Resource-axis identity when the row belongs to one resource. */
204
237
  resource?: Resource;
205
238
  }
@@ -1 +1 @@
1
- import{t}from"../shared/chunk-nvtnncwx.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,ne,oe}from"../shared/chunk-qc1dpk9c.js";import{useIlamyCalendarContext as te}from"@ilamy/calendar";import{useRef as re,useState as le}from"react";import{createPortal as ie}from"react-dom";import{useEffect as V,useRef as G}from"react";var X=(o,e)=>{let n=Math.min(o.top,e.top),l=Math.min(o.left,e.left),i=Math.max(o.left+o.width,e.left+e.width),s=Math.max(o.top+o.height,e.top+e.height);return{top:n,left:l,width:i-l,height:s-n}},I=(o,e)=>{let n=Math.max(o.top,e.top),l=Math.max(o.left,e.left),i=Math.min(o.left+o.width,e.left+e.width),s=Math.min(o.top+o.height,e.top+e.height),p=i-l,u=s-n;if(p<=0||u<=0)return null;return{top:n,left:l,width:p,height:u}},O=(o,e,n)=>{let l=0,i=0;if(o.clientY<e.top+n.edge)i=-n.speed;else if(o.clientY>e.top+e.height-n.edge)i=n.speed;if(o.clientX<e.left+n.edge)l=-n.speed;else if(o.clientX>e.left+e.width-n.edge)l=n.speed;let s=n.axis??"both";return{x:s==="y"?0:l,y:s==="x"?0:i}};var Y=new Set(["auto","scroll","overlay"]),K=(o)=>{let e=getComputedStyle(o),n=Y.has(e.overflowY)&&o.scrollHeight>o.clientHeight,l=Y.has(e.overflowX)&&o.scrollWidth>o.clientWidth;return n||l},k=(o)=>{let e=o instanceof HTMLElement?o:null;while(e){if(K(e))return e;e=e.parentElement}return null};var b=(o,e,n=2)=>Math.hypot(o,e)>=n,_=(o,e)=>{let n=o.allDay===e.allDay,l=o.resourceId===e.resourceId;return n&&l},H=(o,e)=>{let n=o.start.isAfter(e.start),l=n?e:o,i=n?o:e;return{start:l.start,end:i.end,allDay:l.allDay,resourceId:l.resourceId}};var J=400,Q=10,Z=40,ee=5;function B(o){let e=G(o);e.current=o;let n=G(null);V(()=>{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,p=()=>{if(s!==null)clearTimeout(s),s=null},u=null,m=null,f=null,C=()=>{if(f!==null)cancelAnimationFrame(f),f=null},w=()=>{f=null;let r=n.current;if(!r?.active)return;if(!u||!m)return;let c=O(m,u.getBoundingClientRect(),{edge:Z,speed:ee,axis:e.current.scrollAxis});if(c.x===0&&c.y===0)return;u.scrollBy({left:c.x,top:c.y,behavior:"instant"}),e.current.onMove(m,r.payload),f=requestAnimationFrame(w)},x=()=>{if(f===null)f=requestAnimationFrame(w)},g=(r)=>{if(n.current?.active)r.preventDefault()},E=()=>{window.removeEventListener("click",S,{capture:!0})},S=(r)=>{r.stopImmediatePropagation(),r.preventDefault(),E()},d=()=>{window.addEventListener("click",S,{capture:!0})},h=()=>{p(),C(),window.removeEventListener("touchmove",g),i(),u=null,m=null,n.current=null},a=()=>{let r=n.current!==null,c=n.current?.active===!0;if(h(),c)d();if(r)e.current.onCancel?.()},v=(r)=>{if(r.active=!0,p(),l(),window.getSelection()?.removeAllRanges(),r.pointerType==="touch")window.addEventListener("touchmove",g,{passive:!1});e.current.onStart?.(r.payload)},R=(r)=>{if(E(),r.button!==0||!r.isPrimary)return;let c=e.current.resolvePress(r);if(c===null)return;p();let y={pointerId:r.pointerId,pointerType:r.pointerType,originX:r.clientX,originY:r.clientY,payload:c,active:!1};if(n.current=y,u=k(r.target),r.pointerType==="touch"){let T=e.current.longPressMs??J;s=setTimeout(()=>{if(n.current===y)v(y)},T)}},P=(r,c)=>{let y=c.clientX-r.originX,T=c.clientY-r.originY;if(r.pointerType==="touch"){let q=e.current.touchCancelSlopPx??Q;if(b(y,T,q))a();return!1}if(!b(y,T,e.current.thresholdPx))return!1;return v(r),!0},L=(r)=>{let c=n.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active&&!P(c,r))return;m={clientX:r.clientX,clientY:r.clientY},e.current.onMove(m,c.payload),x()},M=(r)=>{let c=n.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active){h();return}d();let{payload:y}=c;h(),e.current.onEnd(y)},A=(r)=>{if(r.key==="Escape")a()};return document.addEventListener("pointerdown",R),window.addEventListener("pointermove",L),window.addEventListener("pointerup",M),window.addEventListener("pointercancel",a),window.addEventListener("blur",a),window.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",R),window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",M),window.removeEventListener("pointercancel",a),window.removeEventListener("blur",a),window.removeEventListener("keydown",A),E(),window.removeEventListener("touchmove",g),p(),C(),i()}},[])}var F=(o)=>document.elementsFromPoint(o.clientX,o.clientY).find((n)=>n.hasAttribute("data-start"))??null,N=(o,e)=>{let n=o?.closest("[data-start]");if(!n)return null;if(n.dataset.disabled==="true")return null;let l=n.dataset.start,i=n.dataset.end;if(!l||!i)return null;let s=(m)=>e?t.utc(m).tz(e):t.utc(m).local(),p=n.dataset.snapMinutes,u=n.dataset.timeAxis;return{start:s(l),end:s(i),resourceId:n.dataset.resourceId,allDay:n.dataset.allDay==="true",snapMinutes:p===void 0?void 0:Number(p),axis:u==="vertical"||u==="horizontal"?u:void 0,element:n}};var j=(o,e)=>{let{snapMinutes:n,axis:l}=o;if(n===void 0||l===void 0)return o;let i=o.element.getBoundingClientRect(),s=l==="vertical",p=s?e.clientY:e.clientX,u=s?i.top:i.left,m=s?i.height:i.width,f=ne(p,u,m),C=o.end.diff(o.start,"minute"),{index:w,count:x}=oe(f,C,n),g=o.start.add(w*n,"minute");return{...o,start:g,end:g.add(n,"minute"),slice:{from:w/x,to:(w+1)/x}}},D=(o)=>{let e=o.element.getBoundingClientRect(),{slice:n,axis:l}=o;if(!n)return{top:e.top,left:e.left,width:e.width,height:e.height};if(l==="horizontal")return{top:e.top,left:e.left+e.width*n.from,width:e.width*(n.to-n.from),height:e.height};return{top:e.top+e.height*n.from,left:e.left,width:e.width,height:e.height*(n.to-n.from)}};import{jsx as W,jsxs as ae,Fragment as ce}from"react/jsx-runtime";var U=(o,e)=>{let n=X(D(o),D(e)),l=o.element.closest("[data-calendar-scroll-content]");if(l instanceof HTMLElement){let p=l.getBoundingClientRect();return{rect:{top:n.top-p.top,left:n.left-p.left,width:n.width,height:n.height},content:l}}let i=o.element.closest("[data-calendar-viewport]");if(!i)return{rect:n,content:null};let s=I(n,i.getBoundingClientRect());if(!s)return null;return{rect:s,content:null}};function se({rect:o,content:e}){return ie(W("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:o.top,left:o.left,width:o.width,height:o.height}}),e??document.body)}function z({children:o,options:e}){let{openEventForm:n,resources:l,hasResourceAxis:i,timezone:s,orientation:p}=te(),[u,m]=le(null),f=re(null),x=i?p==="vertical"?"y":"x":"both",g=()=>{f.current=null,m(null)},E=(d,h)=>{let a=H(d,h),v=l.find((P)=>String(P.id)===a.resourceId),R={start:a.start,end:a.end,resource:v,allDay:a.allDay};if(e.onSelect)e.onSelect(R,n);else n({start:a.start,end:a.end,allDay:a.allDay,resourceId:v?.id})},S=(d,h)=>{let a=N(d,s);return a?j(a,h):null};return B({scrollAxis:x,resolvePress:(d)=>S(d.target,d),onStart:(d)=>{f.current=d,m(U(d,d))},onMove:(d,h)=>{let a=S(F(d),d);if(a&&_(h,a))f.current=a;let v=f.current??h;m(U(h,v))},onEnd:(d)=>{let h=f.current??d;E(d,h),g()},onCancel:g}),ae(ce,{children:[o,u&&W(se,{...u})]})}import{jsx as de}from"react/jsx-runtime";var ue=(o={})=>({name:"drag-to-create",provider:({children:e})=>de(z,{options:o,children:e})});export{ue as dragToCreatePlugin};
@@ -89,6 +89,16 @@ interface CalendarEvent2 {
89
89
  * @example { meetingType: 'standup', attendees: ['john', 'jane'] }
90
90
  */
91
91
  data?: Record<string, unknown>;
92
+ /**
93
+ * Whether this event can be moved. Beats the calendar's
94
+ * `editable`; `startEditable` beats this one (FullCalendar
95
+ * `event.editable`).
96
+ */
97
+ editable?: boolean;
98
+ /** Whether this event can be moved. Defaults to `editable`. */
99
+ startEditable?: boolean;
100
+ /** Whether this event can be resized by its edges. Defaults to `editable`. */
101
+ durationEditable?: boolean;
92
102
  }
93
103
  /**
94
104
  * Supported days of the week for calendar configuration.
@@ -176,6 +186,13 @@ interface PluginMutationResult {
176
186
  added: CalendarEvent2[];
177
187
  /** Existing rows to persist via `onEventDelete`. */
178
188
  deleted: CalendarEvent2[];
189
+ /**
190
+ * The update as it was stored, when that is less than what was asked: a
191
+ * scope that keeps its own day applies only the time of day of a drop on
192
+ * another day. `delta` and `endDelta` describe these, not the request.
193
+ * Omit it when the update was stored as asked.
194
+ */
195
+ appliedUpdates?: Partial<CalendarEvent2>;
179
196
  }
180
197
  /**
181
198
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
@@ -185,12 +202,23 @@ interface PluginMutationResult {
185
202
  */
186
203
  interface ViewConfig {
187
204
  firstDayOfWeek: number;
205
+ /** Weekdays (0 = Sunday) the view does not draw. Absent when none are hidden. */
188
206
  hiddenDays?: Set<number>;
189
207
  businessHours?: BusinessHours | BusinessHours[];
190
208
  hideNonBusinessHours?: boolean;
209
+ /** First visible time in hour grids, `'HH:mm'`. Unset shows from midnight. */
210
+ slotMinTime?: string;
211
+ /** End of the visible time in hour grids, exclusive, `'HH:mm'` up to `'24:00'`. */
212
+ slotMaxTime?: string;
191
213
  /** The resource axis. Set only when the calendar renders resources. */
192
214
  resources?: Resource[];
193
215
  /**
216
+ * Whether the calendar is a resource calendar: it has resources, or is still
217
+ * loading them (then `resources` is empty or absent). When absent, it is
218
+ * derived from `resources` being non-empty.
219
+ */
220
+ hasResourceAxis?: boolean;
221
+ /**
194
222
  * The calendar-level resource arrangement (the user's choice): where the
195
223
  * resource axis goes. Only meaningful when `resources` is set.
196
224
  */
@@ -242,6 +270,11 @@ interface HorizontalRowSpec {
242
270
  columns?: HorizontalCellSpec[];
243
271
  className?: string;
244
272
  showDayNumber?: boolean;
273
+ /**
274
+ * Marks the row as one calendar week, so it shows its week number at its
275
+ * start when the calendar's `weekNumbers` is `true`.
276
+ */
277
+ showWeekNumber?: boolean;
245
278
  /** Resource-axis identity when the row belongs to one resource. */
246
279
  resource?: Resource;
247
280
  }