@ilamy/calendar 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,11 @@
1
1
  import { RRule, Weekday } from "rrule";
2
2
  import { Options } from "rrule";
3
3
  /**
4
+ * Scope options for recurring event operations (Google Calendar style)
5
+ * Determines how many events in a recurring series should be affected
6
+ */
7
+ type RecurrenceEditScope = "this" | "following" | "all";
8
+ /**
4
9
  * Re-rrule.js Options with practical TypeScript interface.
5
10
  * Makes all properties optional except freq and dtstart (which are required by RFC 5545).
6
11
  * This allows clean object creation without needing explicit null values.
@@ -362,8 +367,8 @@ interface IlamyPlugin {
362
367
  children: ReactNode2;
363
368
  }>;
364
369
  }
365
- import dayjs from "dayjs";
366
- type Dayjs3 = dayjs.Dayjs3;
370
+ import { Dayjs as DayjsInstance } from "dayjs";
371
+ type Dayjs3 = DayjsInstance;
367
372
  /**
368
373
  * Returns the recurrence-specific VEVENT property lines for an event: an
369
374
  * `RRULE:` line when the event has an rrule, an `EXDATE:` line when it has
@@ -384,4 +389,4 @@ interface GenerateRecurringEventsProps {
384
389
  }
385
390
  declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent2[];
386
391
  declare const isRecurringEvent: (event: CalendarEvent2) => boolean;
387
- export { RRule, RRuleOptions, RecurrenceAugmentation, Weekday, generateRecurringEvents, isRecurringEvent, recurrenceICalProperties, recurrencePlugin };
392
+ export { RRule, RRuleOptions, RecurrenceAugmentation, RecurrenceEditScope, Weekday, generateRecurringEvents, isRecurringEvent, recurrenceICalProperties, recurrencePlugin };
@@ -1,2 +1,2 @@
1
- import{t}from"../shared/chunk-4jynmg6d.js";import{e,N,u,S}from"../shared/chunk-d7599sry.js";import{n,y,m,a,g,v,C,D,p}from"../shared/chunk-4yfcvykw.js";import{b,R,x,A,w,V}from"../shared/chunk-n7xt0j3a.js";import{RRule as Gn,Weekday as Jn}from"rrule";import{RRule as et}from"rrule";var Se=(r,o=!1)=>{if(o)return r.format("YYYYMMDD");return r.utc().format("YYYYMMDD[T]HHmmss[Z]")},tt=(r)=>{try{return new et(r).toString().split(`
2
- `).find((s)=>s.startsWith("RRULE:"))||""}catch{return""}},me=(r)=>{let o=[],s=r.rrule?tt(r.rrule):"";if(s)o.push(s);if(r.exdates?.length){let i=r.exdates.map((l)=>Se(t(l),r.allDay)).join(",");o.push(`EXDATE:${i}`)}if(r.recurrenceId){let i=Se(t(r.recurrenceId),r.allDay);o.push(`RECURRENCE-ID:${i}`)}return o};import"@ilamy/calendar";import{SLOT_EVENT_FORM as jt,SLOT_EVENT_MUTATION_SCOPE as Vt}from"@ilamy/calendar";import{useIlamyCalendarContext as rt}from"@ilamy/calendar";import{jsx as B,jsxs as oe}from"react/jsx-runtime";var nt=[{scope:"this",title:"thisEvent",editKey:"onlyChangeThis",deleteKey:"onlyDeleteThis"},{scope:"following",title:"thisAndFollowingEvents",editKey:"changeThisAndFuture",deleteKey:"deleteThisAndFuture"},{scope:"all",title:"allEvents",editKey:"changeEntireSeries",deleteKey:"deleteEntireSeries"}];function De({isOpen:r,onClose:o,onConfirm:s,operationType:i,eventTitle:l}){let{t:c}=rt(),d=(h)=>{s(h),o()},f=i==="edit",E=c("deleteRecurringEvent"),O=c("deleteRecurringEventQuestion");if(f)E=c("editRecurringEvent"),O=c("editRecurringEventQuestion");return B(b,{onOpenChange:(h)=>{if(!h)o()},open:r,children:oe(R,{className:"max-w-md",children:[oe(x,{children:[B(w,{children:E}),oe(V,{children:['"',l,'" ',O]})]}),B("div",{className:"space-y-3",children:nt.map(({scope:h,title:k,editKey:M,deleteKey:F})=>B(n,{className:"w-full justify-start h-auto p-4",onClick:()=>d(h),variant:"outline",children:oe("div",{className:"text-left",children:[B("div",{className:"font-medium",children:c(k)}),B("div",{className:"text-sm text-muted-foreground",children:c(f?M:F)})]})},h))}),B(A,{children:B(n,{onClick:o,variant:"outline",children:c("cancel")})})]})})}import{useIlamyCalendarContext as Tt}from"@ilamy/calendar";import{useState as kt}from"react";import{useIlamyCalendarContext as Pt}from"@ilamy/calendar";import{jsx as ae}from"react/jsx-runtime";function xe({className:r,...o}){return ae("div",{className:e("text-card-foreground flex flex-col gap-1 rounded-xl border shadow-sm",r),"data-slot":"card",...o})}function Oe({className:r,...o}){return ae("div",{className:e("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 p-4 pb-0 has-data-[slot=card-action]:grid-cols-[1fr_auto]",r),"data-slot":"card-header",...o})}function Pe({className:r,...o}){return ae("div",{className:e("leading-none font-semibold",r),"data-slot":"card-title",...o})}function we({className:r,...o}){return ae("div",{className:e("p-4 pt-0",r),"data-slot":"card-content",...o})}import{useEffect as wt,useState as Re}from"react";import{RRule as $e}from"rrule";import{createContext as ot,useContext as at}from"react";var Ie=ot(null),Te=Ie.Provider,L=()=>{let r=at(Ie);if(!r)throw Error("useRecurrenceEditor must be used within a RecurrenceEditor");return r};import{RRule as U}from"rrule";var st=[U.SU,U.MO,U.TU,U.WE,U.TH,U.FR,U.SA],it=[U.MO,U.TU,U.WE,U.TH,U.FR],lt=["first","second","third","fourth"],ke=(r)=>st.at(t(r).day())??U.SU,Me=(r)=>{let o=t(r);return o.add(7,"day").month()!==o.month()?-1:Math.ceil(o.date()/7)},ct={daily:()=>({freq:U.DAILY}),weekdays:()=>({freq:U.WEEKLY,byweekday:it}),weeklyOnDay:(r)=>({freq:U.WEEKLY,byweekday:[ke(r)]}),monthlyOnDay:(r)=>({freq:U.MONTHLY,bymonthday:t(r).date()}),monthlyOnWeekday:(r)=>({freq:U.MONTHLY,byweekday:[ke(r).nth(Me(r))]})},G=(r,o)=>{let s=ct[r];if(!s)return null;return{interval:1,dtstart:o,...s(o)}},be=(r)=>{if(r==null)return"";return(Array.isArray(r)?r:[r]).map((s)=>typeof s==="object"?`${s.weekday}:${s.n??""}`:`${s}:`).sort().join(",")},dt=(r,o)=>{if(!o)return!1;let s=r.freq===o.freq,i=be(r.byweekday)===be(o.byweekday),l=(r.bymonthday??null)===(o.bymonthday??null);return s&&i&&l},ut=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday"],J=(r,o)=>{if(!r)return"once";if(Boolean(r.interval)&&r.interval!==1)return"customize";return ut.find((l)=>dt(r,G(l,o)))??"customize"},X=(r,o,s)=>{let i=t(o).format("dddd"),l=Me(o),c=l===-1?"last":lt.at(l-1)??"last",d=s(c);return{daily:s("daily"),weekdays:s("everyWeekday"),weeklyOnDay:`${s("weeklyOn")} ${i}`,monthlyOnDay:`${s("monthlyOnDay")} ${t(o).date()}`,monthlyOnWeekday:`${s("monthlyOnThe")} ${d} ${i}`}[r]??s("customRecurrence")},z=(r)=>{if(Array.isArray(r))return r;return r?[r]:[]};import{useIlamyCalendarContext as ft}from"@ilamy/calendar";import{jsx as pt}from"react/jsx-runtime";var mt="YYYY-MM-DD",Ne=({date:r,onChange:o,className:s})=>{let i=r?t(r).format(mt):"",l=(c)=>{let d=c.target.value;if(!d){o?.(void 0);return}let f=t(d);o?.(f.isValid()?f.toDate():void 0)};return pt("input",{className:e("flex h-9 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-shadow focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",s),onChange:l,type:"date",value:i})};import{jsx as K,jsxs as pe,Fragment as gt}from"react/jsx-runtime";var yt=[{type:"never",id:"never",labelKey:"never"},{type:"count",id:"after",labelKey:"after"},{type:"until",id:"on",labelKey:"on"}],Rt=(r)=>Math.max(1,Number.parseInt(r,10)||1),Ue=()=>{let{t:r}=ft(),{opts:o,update:s,setEndType:i,setUntil:l}=L(),c="never";if(o?.until)c="until";else if(o?.count)c="count";let d=o?.count||1,f=o?.until??void 0;return pe("div",{children:[K(a,{className:"text-xs",children:r("ends")}),K("div",{className:"space-y-2 mt-1",children:yt.map(({type:E,id:O,labelKey:h})=>{let k=E==="count"&&c==="count",M=E==="until"&&c==="until";return pe("div",{className:"flex items-center space-x-2",children:[K(y,{checked:c===E,id:O,onCheckedChange:()=>i(E)}),K(a,{className:"text-xs",htmlFor:O,children:r(h)}),k&&pe(gt,{children:[K(m,{className:"h-6 w-16 text-xs","data-testid":"count-input",min:"1",onChange:(F)=>s({count:Rt(F.target.value)}),type:"number",value:d}),K("span",{className:"text-xs",children:r("occurrences")})]}),M&&K(Ne,{className:"h-6",date:f,onChange:l})]},E)})})]})};import{useIlamyCalendarContext as Et}from"@ilamy/calendar";import{RRule as Z}from"rrule";import{jsx as j,jsxs as se}from"react/jsx-runtime";var fe={DAILY:Z.DAILY,WEEKLY:Z.WEEKLY,MONTHLY:Z.MONTHLY,YEARLY:Z.YEARLY},vt=Object.fromEntries(Object.entries(fe).map(([r,o])=>[o,r])),Ct=(r)=>Math.max(1,Number.parseInt(r,10)||1),Fe=()=>{let{t:r}=Et(),{opts:o,custom:s,update:i}=L();if(!s)return null;let l=vt[o?.freq??Z.DAILY]||"DAILY",c=o?.interval||1;return se("div",{className:"grid grid-cols-2 gap-4",children:[se("div",{children:[j(a,{className:"text-xs",htmlFor:"frequency",children:r("frequency")}),se(g,{onValueChange:(d)=>i({freq:fe[d]}),value:l,children:[j(C,{className:"h-8 w-full","data-testid":"frequency-select",id:"frequency",children:j(v,{})}),j(D,{children:Object.keys(fe).map((d)=>j(p,{value:d,children:r(d.toLowerCase())},d))})]})]}),se("div",{children:[j(a,{className:"text-xs",htmlFor:"interval",children:r("every")}),j(m,{className:"h-8",id:"interval",min:"1",onChange:(d)=>i({interval:Ct(d.target.value)}),type:"number",value:c})]})]})};import{useIlamyCalendarContext as ht}from"@ilamy/calendar";import{RRule as St}from"rrule";import{jsx as ee,jsxs as ye}from"react/jsx-runtime";var Le=()=>{let{t:r}=ht(),{opts:o,custom:s,reference:i,setMonthlyMode:l}=L();if(!s||o?.freq!==St.MONTHLY)return null;let d=z(o?.byweekday).some((f)=>typeof f==="object"&&f.n!=null)?"weekday":"day";return ye("div",{children:[ee(a,{className:"text-xs",htmlFor:"monthly-mode",children:r("repeatOn")}),ye(g,{onValueChange:(f)=>l(f),value:d,children:[ee(C,{className:"h-8 w-full","data-testid":"monthly-mode-select",id:"monthly-mode",children:ee(v,{})}),ye(D,{children:[ee(p,{value:"day",children:X("monthlyOnDay",i,r)}),ee(p,{value:"weekday",children:X("monthlyOnWeekday",i,r)})]})]})]})};import{useIlamyCalendarContext as Dt}from"@ilamy/calendar";import{jsx as te,jsxs as Ae}from"react/jsx-runtime";var xt=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday","customize"],Ye=()=>{let{t:r}=Dt(),{opts:o,custom:s,reference:i,selectPreset:l}=L(),c=s?"customize":J(o,i);return Ae("div",{children:[te(a,{className:"text-xs",htmlFor:"recurrence-preset",children:r("repeats")}),Ae(g,{onValueChange:(d)=>l(d),value:c,children:[te(C,{className:"h-8 w-full","data-testid":"preset-select",id:"recurrence-preset",children:te(v,{})}),te(D,{children:xt.map((d)=>te(p,{value:d,children:X(d,i,r)},d))})]})]})};import{useIlamyCalendarContext as Ot}from"@ilamy/calendar";import{RRule as _}from"rrule";import{jsx as ie,jsxs as Be}from"react/jsx-runtime";var We=[_.SU,_.MO,_.TU,_.WE,_.TH,_.FR,_.SA],_e=()=>{let{t:r,firstDayOfWeek:o}=Ot(),{opts:s,custom:i,toggleDay:l}=L();if(!i||s?.freq!==_.WEEKLY)return null;let c=z(s?.byweekday),d=We.map((E,O)=>({value:E,label:t().day(O).format("ddd")})),f=We.map((E,O)=>d[(O+o)%7]);return Be("div",{children:[ie(a,{className:"text-xs",children:r("repeatOn")}),ie("div",{className:"flex flex-wrap gap-1 mt-1",children:f.map((E,O)=>Be("div",{className:"flex items-center space-x-1",children:[ie(y,{checked:c.includes(E.value),id:S("day",O),onCheckedChange:()=>l(E.value)}),ie(a,{className:"text-xs cursor-pointer",htmlFor:S("day",O),children:E.label})]},S("weekday",O)))})]})};import{jsx as Y,jsxs as le}from"react/jsx-runtime";var It=(r,o)=>{if(!r)return o("customRecurrence");try{let s=new $e(r).toText();if(!(Boolean(s)&&!s.toLowerCase().includes("error")))return o("customRecurrence");return s.charAt(0).toUpperCase()+s.slice(1)}catch{return o("customRecurrence")}},qe=({value:r,onChange:o,referenceDate:s})=>{let{t:i}=Pt(),l=(P)=>P?.dtstart??s??t().toDate(),[c,d]=Re(Boolean(r)),[f,E]=Re(()=>r||null),[O,h]=Re(()=>J(r??null,l(r??null))==="customize");wt(()=>{if(d(Boolean(r)),r){E(r);let P=r.dtstart??s??t().toDate();h(J(r,P)==="customize")}},[r,s]);let k=l(f),M=(P)=>{if(!f)return;let I={...f,...P};E(I),o(c?I:null)},F=(P)=>{if(d(P),!P){o(null);return}if(f){o(f);return}let I={freq:$e.DAILY,interval:1};E(I),h(!1),o(I)},ue={opts:f,custom:O,reference:k,update:M,selectPreset:(P)=>{if(P==="customize"){h(!0);return}h(!1);let I=G(P,k);if(!I)return;let H={...I,count:f?.count,until:f?.until};E(H),o(H)},toggleDay:(P)=>{let I=z(f?.byweekday),ne=I.includes(P)?I.filter((he)=>he!==P):[...I,P];M({byweekday:ne.length?ne:void 0})},setMonthlyMode:(P)=>{if(P==="weekday"){let H=G("monthlyOnWeekday",k);M({byweekday:H?.byweekday,bymonthday:void 0});return}let I=G("monthlyOnDay",k);M({bymonthday:I?.bymonthday,byweekday:void 0})},setEndType:(P)=>{let I={count:void 0,until:void 0};if(P==="count")I.count=f?.count||1;if(P==="until")I.until=f?.until||t().add(1,"month").endOf("day").toDate();M(I)},setUntil:(P)=>{let I=P?t(P).endOf("day").toDate():void 0;M({until:I})}},Ce=Boolean(c&&r);return Y(Te,{value:ue,children:le(xe,{"data-testid":"recurrence-editor",children:[le(Oe,{className:"pb-3",children:[le("div",{className:"flex items-center space-x-2",children:[Y(y,{checked:c,"data-testid":"toggle-recurrence",id:"recurring",onCheckedChange:F}),Y(Pe,{className:"text-sm",children:i("repeat")})]}),Ce&&Y("p",{className:"text-xs text-muted-foreground",children:It(r??null,i)})]}),c&&Y(we,{className:"pt-0",children:le("div",{className:"space-y-4",children:[Y(Ye,{}),Y(Fe,{}),Y(_e,{}),Y(Le,{}),Y(Ue,{})]})})]})})};import{jsx as bt}from"react/jsx-runtime";var He=({event:r,onChange:o})=>{let{rawEvents:s}=Tt(),i=r.uid,l;if(i)l=s.find((E)=>(E.uid||`${E.id}@ilamy.calendar`)===i&&Boolean(E.rrule));let[c,d]=kt(r.rrule??l?.rrule??null);return bt(qe,{onChange:(E)=>{if(!E){d(null),o({rrule:void 0});return}let O=E.dtstart??r.start?.toDate(),h=O?{...E,dtstart:O}:E;d(h),o({rrule:h})},referenceDate:r.start?.toDate(),value:c})};var ge=(r)=>Boolean(r.rrule||r.recurrenceId||r.uid),T=(r)=>r.uid||`${r.id}@ilamy.calendar`,ce=(r,o)=>{let s=T(o),i=r.findIndex((l)=>{let c=T(l)===s,d=Boolean(l.rrule)&&!l.recurrenceId;return c&&d});if(i===-1)throw Error("Base recurring event not found");return i},de=(r)=>r.start.subtract(1,"day").endOf("day").toDate(),Ee=(r)=>r.recurrenceId??r.start.toISOString(),Ke=(r,o)=>{let s=Ee(o),i=r.exdates||[],l=i.includes(s)?i:[...i,s];return{baseEvent:{...r,exdates:l},targetEventStartISO:s}};var Mt=({targetEvent:r,updatedEvents:o,baseEventIndex:s,baseEvent:i})=>{let l=Ee(r),c=T(i),{baseEvent:d}=Ke(i,r);o[s]=d;let f=(h)=>{let k=Boolean(h.recurrenceId),M=T(h)===c,F=h.recurrenceId===l;return k&&M&&F},E=o.find(f);return{events:o.filter((h)=>!f(h)),updated:E?[]:[d],added:[],deleted:E?[E]:[]}},Nt=({targetEvent:r,updatedEvents:o,baseEventIndex:s,baseEvent:i})=>{let l={...i,rrule:{...i.rrule,until:de(r)}};return o[s]=l,{events:o,updated:[l],added:[],deleted:[]}},Ut=({targetEvent:r,updatedEvents:o})=>{let s=T(r),i=o.filter((c)=>T(c)===s);return{events:o.filter((c)=>T(c)!==s),updated:[],added:[],deleted:i}},Ft={this:Mt,following:Nt,all:Ut},je=({targetEvent:r,currentEvents:o,scope:s})=>{let i=[...o],l=ce(i,r),c=i[l],d=Ft[s];if(!d)throw Error(`Invalid scope: ${s}. Must be 'this', 'following', or 'all'`);return d({targetEvent:r,updatedEvents:i,baseEventIndex:l,baseEvent:c})};import{RRule as Lt}from"rrule";var re=(r)=>new Date(Date.UTC(r.year(),r.month(),r.date(),r.hour(),r.minute(),r.second(),r.millisecond())),Ve=(r,o)=>o.year(r.getUTCFullYear()).month(r.getUTCMonth()).date(r.getUTCDate()).hour(r.getUTCHours()).minute(r.getUTCMinutes()).second(r.getUTCSeconds()).millisecond(r.getUTCMilliseconds());var ve=({event:r,currentEvents:o,startDate:s,endDate:i})=>{if(!r.rrule)return[];try{let l=re(r.start),c;if(r.rrule.until)c=re(t(r.rrule.until));let d={...r.rrule,dtstart:l,until:c},f=new Lt(d),E=T(r),O=o.filter((W)=>{let Q=Boolean(W.recurrenceId),q=T(W)===E;return Q&&q}),h=r.end.diff(r.start),k=re(s.subtract(h,"millisecond")),M=re(i);return f.between(k,M,!0).map((W,Q)=>{let q=Ve(W,r.start);if(O.some((Ze)=>N(Ze.recurrenceId)?.isSame(q)))return;let ue=q.toISOString();if(r.exdates?.includes(ue)??!1)return;let P=r.end.diff(r.start),I=q.add(P,"millisecond"),H=`${r.id}_${Q}`,ne=T(r);return{...r,id:H,start:q,end:I,uid:ne,rrule:void 0}}).filter((W)=>W!==void 0).filter((W)=>u(W,s,i))}catch(l){throw Error(`Invalid RRULE options: ${JSON.stringify(r.rrule)}. Error: ${l instanceof Error?l.message:"Unknown error"}`)}};var ze=(r,o)=>{let s=o.diff(o.startOf("day"),"millisecond");return r.startOf("day").add(s,"millisecond")},At=(r,o,s)=>{let i=r.end.diff(r.start),l=s.start||o.start,c=s.end||l.add(i),d=`${r.id}_following`,f=`${d}@ilamy.calendar`;return{...r,...s,rrule:{...r.rrule,...s.rrule,dtstart:l.toDate()},id:d,uid:f,start:l,end:c,recurrenceId:void 0}},Yt=(r,o)=>(s)=>{let i=Boolean(s.recurrenceId)&&!s.rrule,l=T(s)===r,c=Boolean(s.recurrenceId)&&t(s.recurrenceId).isAfter(o);return i&&l&&c},Wt=(r,o)=>{let s=r.start;if(o.start)s=ze(r.start,o.start);let i=r.end;if(o.start&&o.end)i=s.add(o.end.diff(o.start),"millisecond");else if(o.start)i=s.add(r.end.diff(r.start),"millisecond");else if(o.end)i=ze(r.end,o.end);let l=o.rrule??r.rrule,c;if(l)c={...l,dtstart:s.toDate()};return{start:s,end:i,rrule:c}},Bt=(r,o)=>{if(o&&r.recurrenceId)return r.recurrenceId;return r.start.toISOString()},_t=({updatedEvents:r,targetEvent:o,detachedOverride:s,updatedBaseEvent:i,baseChanged:l})=>{let c=r.findIndex((d)=>d.id===o.id);if(c===-1)throw Error("Detached override not found");return r[c]=s,{events:r,updated:l?[i,s]:[s],added:[],deleted:[]}},$t=({targetEvent:r,updates:o,updatedEvents:s,baseEventIndex:i,baseEvent:l})=>{let c=T(l),d=Boolean(r.recurrenceId&&!r.rrule),f=Bt(r,d),E=l.exdates||[],O=E.includes(f)?E:[...E,f],h=O!==E||l.uid!==c,k={...l,exdates:O,uid:c};s[i]=k;let M={...r,...o,recurrenceId:f,rrule:void 0,uid:c};if(d)return _t({updatedEvents:s,targetEvent:r,detachedOverride:M,updatedBaseEvent:k,baseChanged:h});let F={...M,id:`${l.id}_modified_${Date.now()}`};return s.push(F),{events:s,updated:[k],added:[F],deleted:[]}},qt=({targetEvent:r,updates:o,updatedEvents:s,baseEventIndex:i,baseEvent:l})=>{let c=de(r),d=T(l),f=Yt(d,c),E=(l.exdates??[]).filter((F)=>!t(F).isAfter(c)),O={...l,exdates:E,rrule:{...l.rrule,until:c}};s[i]=O;let h=At(l,r,o);s.push(h);let k=s.filter(f);return{events:s.filter((F)=>!f(F)),updated:[O],added:[h],deleted:k}},Ht=({updates:r,updatedEvents:o,baseEventIndex:s,baseEvent:i})=>{let l=T(i),c=Wt(i,r),d={...i,...r,start:c.start,end:c.end,rrule:c.rrule,exdates:void 0,uid:l};o[s]=d;let f=(h)=>{let k=Boolean(h.recurrenceId)&&!h.rrule,M=T(h)===l;return k&&M},E=o.filter((h)=>!f(h)),O=o.filter(f);return{events:E,updated:[d],added:[],deleted:O}},Kt={this:$t,following:qt,all:Ht},Qe=({targetEvent:r,updates:o,currentEvents:s,scope:i})=>{let l=[...s],c=ce(l,r),d=l[c],f=Kt[i];if(!f)throw Error(`Invalid scope: ${i}. Must be 'this', 'following', or 'all'`);return f({targetEvent:r,updates:o,updatedEvents:l,baseEventIndex:c,baseEvent:d})};import{jsx as Ge}from"react/jsx-runtime";var zt=()=>({name:"recurrence",transformEvents:(r,o)=>{let s=new Map;for(let i of r)if(i.rrule)s.set(T(i),i);return r.flatMap((i)=>{if(i.rrule)return ve({event:i,currentEvents:r,startDate:o.start,endDate:o.end});if(i.recurrenceId){let l=s.get(T(i));if(l)return[{...l,...i,rrule:void 0}]}return[i]})},managesEvent:(r)=>ge(r),applyEdit:({event:r,updates:o,currentEvents:s,scope:i})=>Qe({targetEvent:r,updates:o??{},currentEvents:s,scope:i}),applyDelete:({event:r,currentEvents:o,scope:s})=>je({targetEvent:r,currentEvents:o,scope:s}),contribute:(r,o)=>{if(r!=="ical:vevent-properties")return[];return me(o)},renderSlot:(r,o)=>{if(r===jt){let{event:s,onChange:i}=o;return Ge(He,{event:s,onChange:i})}if(r===Vt){let{event:s,operation:i,resolve:l,cancel:c}=o;return Ge(De,{eventTitle:s.title||"",isOpen:!0,onClose:c,onConfirm:(d)=>l(d),operationType:i})}return null}});export{Gn as RRule,Jn as Weekday,ve as generateRecurringEvents,ge as isRecurringEvent,me as recurrenceICalProperties,zt as recurrencePlugin};
1
+ import{t}from"../shared/chunk-cn24081x.js";import{e,V,d,T}from"../shared/chunk-tfk3a0d4.js";import{o,v,m,s,C,D,E,h,f}from"../shared/chunk-p26ryh5z.js";import{k,R,w,S,G,P,W}from"../shared/chunk-1x8xjsbq.js";import{RRule as ao,Weekday as so}from"rrule";import{RRule as nt}from"rrule";var Oe=(r,n=!1)=>{if(n)return r.format("YYYYMMDD");return r.utc().format("YYYYMMDD[T]HHmmss[Z]")},ot=(r)=>{try{return new nt(r).toString().split(`
2
+ `).find((a)=>a.startsWith("RRULE:"))||""}catch{return""}},ye=(r)=>{let n=[],a=r.rrule?ot(r.rrule):"";if(a)n.push(a);if(r.exdates?.length){let i=r.exdates.map((c)=>Oe(t(c),r.allDay)).join(",");n.push(`EXDATE:${i}`)}if(r.recurrenceId){let i=Oe(t(r.recurrenceId),r.allDay);n.push(`RECURRENCE-ID:${i}`)}return n};import"@ilamy/calendar";import{SLOT_EVENT_FORM as Zt,SLOT_EVENT_MUTATION_SCOPE as Xt}from"@ilamy/calendar";import{useIlamyCalendarContext as at}from"@ilamy/calendar";import{jsx as _,jsxs as ae}from"react/jsx-runtime";var st=[{scope:"this",title:"thisEvent",editKey:"onlyChangeThis",deleteKey:"onlyDeleteThis"},{scope:"following",title:"thisAndFollowingEvents",editKey:"changeThisAndFuture",deleteKey:"deleteThisAndFuture"},{scope:"all",title:"allEvents",editKey:"changeEntireSeries",deleteKey:"deleteEntireSeries"}];function xe({isOpen:r,onClose:n,onConfirm:a,operationType:i,eventTitle:c}){let{t:l}=at(),u=(g)=>{a(g),n()},p=i==="edit",y=l("deleteRecurringEvent"),O=l("deleteRecurringEventQuestion");if(p)y=l("editRecurringEvent"),O=l("editRecurringEventQuestion");return _(R,{onOpenChange:(g)=>{if(!g)n()},open:r,children:ae(w,{className:"max-w-md",children:[ae(S,{children:[_(P,{children:y}),ae(W,{children:['"',c,'" ',O]})]}),_("div",{className:"space-y-3",children:st.map(({scope:g,title:M,editKey:N,deleteKey:F})=>_(o,{className:"w-full justify-start h-auto p-4",onClick:()=>u(g),variant:"outline",children:ae("div",{className:"text-left",children:[_("div",{className:"font-medium",children:l(M)}),_("div",{className:"text-sm text-muted-foreground",children:l(p?N:F)})]})},g))}),_(G,{children:_(o,{onClick:n,variant:"outline",children:l("cancel")})})]})})}import{useIlamyCalendarContext as Mt}from"@ilamy/calendar";import{useState as kt}from"react";import{useIlamyCalendarContext as Pt}from"@ilamy/calendar";import{jsx as se}from"react/jsx-runtime";function we({className:r,...n}){return se("div",{className:e("text-card-foreground flex flex-col gap-1 rounded-xl border shadow-sm",r),"data-slot":"card",...n})}function Ie({className:r,...n}){return se("div",{className:e("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 p-4 pb-0 has-data-[slot=card-action]:grid-cols-[1fr_auto]",r),"data-slot":"card-header",...n})}function Pe({className:r,...n}){return se("div",{className:e("leading-none font-semibold",r),"data-slot":"card-title",...n})}function be({className:r,...n}){return se("div",{className:e("p-4 pt-0",r),"data-slot":"card-content",...n})}import{useEffect as bt,useState as ve}from"react";import{RRule as $e}from"rrule";import{createContext as it}from"react";var Te=it(void 0),Me=Te.Provider,A=()=>k(Te,"useRecurrenceEditor","RecurrenceEditor");import{RRule as U}from"rrule";var ct=[U.SU,U.MO,U.TU,U.WE,U.TH,U.FR,U.SA],lt=[U.MO,U.TU,U.WE,U.TH,U.FR],dt=["first","second","third","fourth"],ke=(r)=>ct.at(t(r).day())??U.SU,Ue=(r)=>{let n=t(r);return n.add(7,"day").month()!==n.month()?-1:Math.ceil(n.date()/7)},ut={daily:()=>({freq:U.DAILY}),weekdays:()=>({freq:U.WEEKLY,byweekday:lt}),weeklyOnDay:(r)=>({freq:U.WEEKLY,byweekday:[ke(r)]}),monthlyOnDay:(r)=>({freq:U.MONTHLY,bymonthday:t(r).date()}),monthlyOnWeekday:(r)=>({freq:U.MONTHLY,byweekday:[ke(r).nth(Ue(r))]})},Z=(r,n)=>{let a=ut[r];if(!a)return null;return{interval:1,dtstart:n,...a(n)}},Ne=(r)=>{if(r==null)return"";return(Array.isArray(r)?r:[r]).map((a)=>typeof a==="object"?`${a.weekday}:${a.n??""}`:`${a}:`).sort().join(",")},pt=(r,n)=>{if(!n)return!1;let a=r.freq===n.freq,i=Ne(r.byweekday)===Ne(n.byweekday),c=(r.bymonthday??null)===(n.bymonthday??null);return a&&i&&c},mt=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday"],X=(r,n)=>{if(!r)return"once";if(Boolean(r.interval)&&r.interval!==1)return"customize";return mt.find((c)=>pt(r,Z(c,n)))??"customize"},J=(r,n,a)=>{let i=t(n).format("dddd"),c=Ue(n),l=c===-1?"last":dt.at(c-1)??"last",u=a(l);return{daily:a("daily"),weekdays:a("everyWeekday"),weeklyOnDay:`${a("weeklyOn")} ${i}`,monthlyOnDay:`${a("monthlyOnDay")} ${t(n).date()}`,monthlyOnWeekday:`${a("monthlyOnThe")} ${u} ${i}`}[r]??a("customRecurrence")},Q=(r)=>{if(Array.isArray(r))return r;return r?[r]:[]};import{useIlamyCalendarContext as Rt}from"@ilamy/calendar";import{jsx as yt}from"react/jsx-runtime";var ft="YYYY-MM-DD",Fe=({date:r,onChange:n,className:a})=>{let i=r?t(r).format(ft):"",c=(l)=>{let u=l.target.value;if(!u){n?.(void 0);return}let p=t(u);n?.(p.isValid()?p.toDate():void 0)};return yt("input",{className:e("flex h-9 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-shadow focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",a),onChange:c,type:"date",value:i})};import{jsx as H,jsxs as Re,Fragment as vt}from"react/jsx-runtime";var gt=[{type:"never",id:"never",labelKey:"never"},{type:"count",id:"after",labelKey:"after"},{type:"until",id:"on",labelKey:"on"}],Et=(r)=>Math.max(1,Number.parseInt(r,10)||1),Le=()=>{let{t:r}=Rt(),{opts:n,update:a,setEndType:i,setUntil:c}=A(),l="never";if(n?.until)l="until";else if(n?.count)l="count";let u=n?.count||1,p=n?.until??void 0;return Re("div",{children:[H(s,{className:"text-xs",children:r("ends")}),H("div",{className:"space-y-2 mt-1",children:gt.map(({type:y,id:O,labelKey:g})=>{let M=y==="count"&&l==="count",N=y==="until"&&l==="until";return Re("div",{className:"flex items-center space-x-2",children:[H(v,{checked:l===y,id:O,onCheckedChange:()=>i(y)}),H(s,{className:"text-xs",htmlFor:O,children:r(g)}),M&&Re(vt,{children:[H(m,{className:"h-6 w-16 text-xs","data-testid":"count-input",min:"1",onChange:(F)=>a({count:Et(F.target.value)}),type:"number",value:u}),H("span",{className:"text-xs",children:r("occurrences")})]}),N&&H(Fe,{className:"h-6",date:p,onChange:c})]},y)})})]})};import{useIlamyCalendarContext as Ct}from"@ilamy/calendar";import{RRule as ee}from"rrule";import{jsx as z,jsxs as ie}from"react/jsx-runtime";var ge={DAILY:ee.DAILY,WEEKLY:ee.WEEKLY,MONTHLY:ee.MONTHLY,YEARLY:ee.YEARLY},St=Object.fromEntries(Object.entries(ge).map(([r,n])=>[n,r])),ht=(r)=>Math.max(1,Number.parseInt(r,10)||1),Ae=()=>{let{t:r}=Ct(),{opts:n,custom:a,update:i}=A();if(!a)return null;let c=St[n?.freq??ee.DAILY]||"DAILY",l=n?.interval||1;return ie("div",{className:"grid grid-cols-2 gap-4",children:[ie("div",{children:[z(s,{className:"text-xs",htmlFor:"frequency",children:r("frequency")}),ie(C,{onValueChange:(u)=>i({freq:ge[u]}),value:c,children:[z(E,{className:"h-8 w-full","data-testid":"frequency-select",id:"frequency",children:z(D,{})}),z(h,{children:Object.keys(ge).map((u)=>z(f,{value:u,children:r(u.toLowerCase())},u))})]})]}),ie("div",{children:[z(s,{className:"text-xs",htmlFor:"interval",children:r("every")}),z(m,{className:"h-8",id:"interval",min:"1",onChange:(u)=>i({interval:ht(u.target.value)}),type:"number",value:l})]})]})};import{useIlamyCalendarContext as Dt}from"@ilamy/calendar";import{RRule as Ot}from"rrule";import{jsx as te,jsxs as Ee}from"react/jsx-runtime";var We=()=>{let{t:r}=Dt(),{opts:n,custom:a,reference:i,setMonthlyMode:c}=A();if(!a||n?.freq!==Ot.MONTHLY)return null;let u=Q(n?.byweekday).some((p)=>typeof p==="object"&&p.n!=null)?"weekday":"day";return Ee("div",{children:[te(s,{className:"text-xs",htmlFor:"monthly-mode",children:r("repeatOn")}),Ee(C,{onValueChange:(p)=>c(p),value:u,children:[te(E,{className:"h-8 w-full","data-testid":"monthly-mode-select",id:"monthly-mode",children:te(D,{})}),Ee(h,{children:[te(f,{value:"day",children:J("monthlyOnDay",i,r)}),te(f,{value:"weekday",children:J("monthlyOnWeekday",i,r)})]})]})]})};import{useIlamyCalendarContext as xt}from"@ilamy/calendar";import{jsx as re,jsxs as Ye}from"react/jsx-runtime";var wt=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday","customize"],Be=()=>{let{t:r}=xt(),{opts:n,custom:a,reference:i,selectPreset:c}=A(),l=a?"customize":X(n,i);return Ye("div",{children:[re(s,{className:"text-xs",htmlFor:"recurrence-preset",children:r("repeats")}),Ye(C,{onValueChange:(u)=>c(u),value:l,children:[re(E,{className:"h-8 w-full","data-testid":"preset-select",id:"recurrence-preset",children:re(D,{})}),re(h,{children:wt.map((u)=>re(f,{value:u,children:J(u,i,r)},u))})]})]})};import{useIlamyCalendarContext as It}from"@ilamy/calendar";import{RRule as j}from"rrule";import{jsx as ce,jsxs as je}from"react/jsx-runtime";var _e=[j.SU,j.MO,j.TU,j.WE,j.TH,j.FR,j.SA],qe=()=>{let{t:r,firstDayOfWeek:n}=It(),{opts:a,custom:i,toggleDay:c}=A();if(!i||a?.freq!==j.WEEKLY)return null;let l=Q(a?.byweekday),u=_e.map((y,O)=>({value:y,label:t().day(O).format("ddd")})),p=_e.map((y,O)=>u[(O+n)%7]);return je("div",{children:[ce(s,{className:"text-xs",children:r("repeatOn")}),ce("div",{className:"flex flex-wrap gap-1 mt-1",children:p.map((y,O)=>je("div",{className:"flex items-center space-x-1",children:[ce(v,{checked:l.includes(y.value),id:T("day",O),onCheckedChange:()=>c(y.value)}),ce(s,{className:"text-xs cursor-pointer",htmlFor:T("day",O),children:y.label})]},T("weekday",O)))})]})};import{jsx as Y,jsxs as le}from"react/jsx-runtime";var Tt=(r,n)=>{if(!r)return n("customRecurrence");try{let a=new $e(r).toText();if(!(Boolean(a)&&!a.toLowerCase().includes("error")))return n("customRecurrence");return a.charAt(0).toUpperCase()+a.slice(1)}catch{return n("customRecurrence")}},Ke=({value:r,onChange:n,referenceDate:a})=>{let{t:i}=Pt(),c=(x)=>x?.dtstart??a??t().toDate(),[l,u]=ve(Boolean(r)),[p,y]=ve(()=>r||null),[O,g]=ve(()=>X(r??null,c(r??null))==="customize");bt(()=>{if(u(Boolean(r)),r){y(r);let x=r.dtstart??a??t().toDate();g(X(r,x)==="customize")}},[r,a]);let M=c(p),N=(x)=>{if(!p)return;let I={...p,...x};y(I),n(l?I:null)},F=(x)=>{if(u(x),!x){n(null);return}if(p){n(p);return}let I={freq:$e.DAILY,interval:1};y(I),g(!1),n(I)},De={opts:p,custom:O,reference:M,update:N,selectPreset:(x)=>{if(x==="customize"){g(!0);return}g(!1);let I=Z(x,M);if(!I)return;let K={...I,count:p?.count,until:p?.until};y(K),n(K)},toggleDay:(x)=>{let I=Q(p?.byweekday),oe=I.includes(x)?I.filter((fe)=>fe!==x):[...I,x];N({byweekday:oe.length?oe:void 0})},setMonthlyMode:(x)=>{if(x==="weekday"){let K=Z("monthlyOnWeekday",M);N({byweekday:K?.byweekday,bymonthday:void 0});return}let I=Z("monthlyOnDay",M);N({bymonthday:I?.bymonthday,byweekday:void 0})},setEndType:(x)=>{let I={count:void 0,until:void 0};if(x==="count")I.count=p?.count||1;if(x==="until")I.until=p?.until||t().add(1,"month").endOf("day").toDate();N(I)},setUntil:(x)=>{let I=x?t(x).endOf("day").toDate():void 0;N({until:I})}},me=Boolean(l&&r);return Y(Me,{value:De,children:le(we,{"data-testid":"recurrence-editor",children:[le(Ie,{className:"pb-3",children:[le("div",{className:"flex items-center space-x-2",children:[Y(v,{checked:l,"data-testid":"toggle-recurrence",id:"recurring",onCheckedChange:F}),Y(Pe,{className:"text-sm",children:i("repeat")})]}),me&&Y("p",{className:"text-xs text-muted-foreground",children:Tt(r??null,i)})]}),l&&Y(be,{className:"pt-0",children:le("div",{className:"space-y-4",children:[Y(Be,{}),Y(Ae,{}),Y(qe,{}),Y(We,{}),Y(Le,{})]})})]})})};import{jsx as Nt}from"react/jsx-runtime";var He=({event:r,onChange:n})=>{let{rawEvents:a}=Mt(),i=r.uid,c;if(i)c=a.find((y)=>(y.uid||`${y.id}@ilamy.calendar`)===i&&Boolean(y.rrule));let[l,u]=kt(r.rrule??c?.rrule??null);return Nt(Ke,{onChange:(y)=>{if(!y){u(null),n({rrule:void 0});return}let O=y.dtstart??r.start?.toDate(),g=O?{...y,dtstart:O}:y;u(g),n({rrule:g})},referenceDate:r.start?.toDate(),value:l})};var Ce=(r)=>Boolean(r.rrule||r.recurrenceId||r.uid),b=(r)=>r.uid||`${r.id}@ilamy.calendar`,de=(r,n)=>{let a=b(n),i=r.findIndex((c)=>{let l=b(c)===a,u=Boolean(c.rrule)&&!c.recurrenceId;return l&&u});if(i===-1)throw Error("Base recurring event not found");return i},ue=(r)=>r.start.subtract(1,"day").endOf("day").toDate(),pe=(r,n)=>(a)=>{let i=Boolean(a.recurrenceId)&&!a.rrule,c=b(a)===r,l=Boolean(a.recurrenceId)&&t(a.recurrenceId).isAfter(n);return i&&c&&l},Se=(r)=>r.recurrenceId??r.start.toISOString(),Ve=(r,n)=>{let a=Se(n),i=r.exdates||[],c=i.includes(a)?i:[...i,a];return{baseEvent:{...r,exdates:c},targetEventStartISO:a}};var Ut=({targetEvent:r,updatedEvents:n,baseEventIndex:a,baseEvent:i})=>{let c=Se(r),l=b(i),{baseEvent:u}=Ve(i,r);n[a]=u;let p=(g)=>{let M=Boolean(g.recurrenceId),N=b(g)===l,F=g.recurrenceId===c;return M&&N&&F},y=n.find(p);return{events:n.filter((g)=>!p(g)),updated:y?[]:[u],added:[],deleted:y?[y]:[]}},Ft=({targetEvent:r,updatedEvents:n,baseEventIndex:a,baseEvent:i})=>{let c=ue(r),l={...i,rrule:{...i.rrule,until:c}};n[a]=l;let u=b(i),p=pe(u,c),y=n.filter(p);return{events:n.filter((g)=>!p(g)),updated:[l],added:[],deleted:y}},Lt=({targetEvent:r,updatedEvents:n})=>{let a=b(r),i=n.filter((l)=>b(l)===a);return{events:n.filter((l)=>b(l)!==a),updated:[],added:[],deleted:i}},At={this:Ut,following:Ft,all:Lt},ze=({targetEvent:r,currentEvents:n,scope:a})=>{let i=[...n],c=de(i,r),l=i[c],u=At[a];if(!u)throw Error(`Invalid scope: ${a}. Must be 'this', 'following', or 'all'`);return u({targetEvent:r,updatedEvents:i,baseEventIndex:c,baseEvent:l})};import{RRule as Wt}from"rrule";var ne=(r)=>new Date(Date.UTC(r.year(),r.month(),r.date(),r.hour(),r.minute(),r.second(),r.millisecond())),Qe=(r,n)=>{let a=r.toISOString().replace("Z","");return t(a).locale(n.locale())};var Ge=42,Yt=4096,Ze=new WeakMap,Bt=({event:r,rrule:n,ruleOptions:a,floatingUntil:i})=>{let c=i?.getTime(),l=Ze.get(r),u=l?.rruleOptions===n,p=l?.start===r.start,y=l?.floatingUntilMs===c;if(l&&u&&p&&y)return l;let O={rruleOptions:n,start:r.start,floatingUntilMs:c,rule:new Wt(a),windowStartMs:Number.POSITIVE_INFINITY,windowEndMs:Number.NEGATIVE_INFINITY,windowOccurrences:[],instants:new Map};return Ze.set(r,O),O},_t=(r,n,a)=>{let i=n.getTime(),c=a.getTime();if(Number.isNaN(i)||Number.isNaN(c))return r.rule.between(n,a,!0).map((g)=>g.getTime());let u=i>=r.windowStartMs,p=c<=r.windowEndMs;if(!(u&&p))r.windowStartMs=t.utc(i).subtract(Ge,"day").valueOf(),r.windowEndMs=t.utc(c).add(Ge,"day").valueOf(),r.windowOccurrences=r.rule.between(new Date(r.windowStartMs),new Date(r.windowEndMs),!0).map((g)=>g.getTime());let O=[];for(let g of r.windowOccurrences){if(g>c)break;if(g>=i)O.push(g)}return O},jt=(r,n,a)=>{let i=r.instants.get(n);if(i)return i;if(r.instants.size>=Yt)r.instants.clear();let c=Qe(new Date(n),a);return r.instants.set(n,c),c},he=({event:r,currentEvents:n,startDate:a,endDate:i})=>{if(!r.rrule)return[];try{let c=ne(r.start),l;if(r.rrule.until)l=ne(t(r.rrule.until));let u={...r.rrule,dtstart:c,until:l},p=Bt({event:r,rrule:r.rrule,ruleOptions:u,floatingUntil:l}),y=b(r),O=n.filter((L)=>{let B=Boolean(L.recurrenceId),q=b(L)===y;return B&&q}),g=new Set;for(let L of O){let B=V(L.recurrenceId);if(B)g.add(B.valueOf())}let M=r.end.diff(r.start),N=ne(a.subtract(M,"millisecond")),F=ne(i);return _t(p,N,F).map((L,B)=>{let q=jt(p,L,r.start);if(g.has(q.valueOf()))return;let me=q.toISOString();if(r.exdates?.includes(me)??!1)return;let I=r.end.diff(r.start),K=q.add(I,"millisecond"),oe=`${r.id}_${B}`,fe=b(r);return{...r,id:oe,start:q,end:K,uid:fe,rrule:void 0}}).filter((L)=>L!==void 0).filter((L)=>d(L,a,i))}catch(c){throw Error(`Invalid RRULE options: ${JSON.stringify(r.rrule)}. Error: ${c instanceof Error?c.message:"Unknown error"}`)}};var Xe=(r,n)=>{let a=n.diff(n.startOf("day"),"millisecond");return r.startOf("day").add(a,"millisecond")},qt=(r,n,a)=>{let i=r.end.diff(r.start),c=a.start||n.start,l=a.end||c.add(i),u=`${r.id}_following`,p=`${u}@ilamy.calendar`;return{...r,...a,rrule:{...r.rrule,...a.rrule,dtstart:c.toDate()},id:u,uid:p,start:c,end:l,recurrenceId:void 0}},$t=(r,n)=>{let a=r.start;if(n.start)a=Xe(r.start,n.start);let i=r.end;if(n.start&&n.end)i=a.add(n.end.diff(n.start),"millisecond");else if(n.start)i=a.add(r.end.diff(r.start),"millisecond");else if(n.end)i=Xe(r.end,n.end);let c=n.rrule??r.rrule,l;if(c)l={...c,dtstart:a.toDate()};return{start:a,end:i,rrule:l}},Kt=(r,n)=>{if(n&&r.recurrenceId)return r.recurrenceId;return r.start.toISOString()},Ht=({updatedEvents:r,targetEvent:n,detachedOverride:a,updatedBaseEvent:i,baseChanged:c})=>{let l=r.findIndex((u)=>u.id===n.id);if(l===-1)throw Error("Detached override not found");return r[l]=a,{events:r,updated:c?[i,a]:[a],added:[],deleted:[]}},Vt=({targetEvent:r,updates:n,updatedEvents:a,baseEventIndex:i,baseEvent:c})=>{let l=b(c),u=Boolean(r.recurrenceId&&!r.rrule),p=Kt(r,u),y=c.exdates||[],O=y.includes(p)?y:[...y,p],g=O!==y||c.uid!==l,M={...c,exdates:O,uid:l};a[i]=M;let N={...r,...n,recurrenceId:p,rrule:void 0,uid:l};if(u)return Ht({updatedEvents:a,targetEvent:r,detachedOverride:N,updatedBaseEvent:M,baseChanged:g});let F={...N,id:`${c.id}_modified_${Date.now()}`};return a.push(F),{events:a,updated:[M],added:[F],deleted:[]}},zt=({targetEvent:r,updates:n,updatedEvents:a,baseEventIndex:i,baseEvent:c})=>{let l=ue(r),u=b(c),p=pe(u,l),y=(c.exdates??[]).filter((F)=>!t(F).isAfter(l)),O={...c,exdates:y,rrule:{...c.rrule,until:l}};a[i]=O;let g=qt(c,r,n);a.push(g);let M=a.filter(p);return{events:a.filter((F)=>!p(F)),updated:[O],added:[g],deleted:M}},Qt=({updates:r,updatedEvents:n,baseEventIndex:a,baseEvent:i})=>{let c=b(i),l=$t(i,r),u={...i,...r,start:l.start,end:l.end,rrule:l.rrule,exdates:void 0,uid:c};n[a]=u;let p=(g)=>{let M=Boolean(g.recurrenceId)&&!g.rrule,N=b(g)===c;return M&&N},y=n.filter((g)=>!p(g)),O=n.filter(p);return{events:y,updated:[u],added:[],deleted:O}},Gt={this:Vt,following:zt,all:Qt},Je=({targetEvent:r,updates:n,currentEvents:a,scope:i})=>{let c=[...a],l=de(c,r),u=c[l],p=Gt[i];if(!p)throw Error(`Invalid scope: ${i}. Must be 'this', 'following', or 'all'`);return p({targetEvent:r,updates:n,updatedEvents:c,baseEventIndex:l,baseEvent:u})};import{jsx as et}from"react/jsx-runtime";var Jt=()=>({name:"recurrence",transformEvents:(r,n)=>{let a=new Map;for(let i of r)if(i.rrule)a.set(b(i),i);return r.flatMap((i)=>{if(i.rrule)return he({event:i,currentEvents:r,startDate:n.start,endDate:n.end});if(i.recurrenceId){let c=a.get(b(i));if(c)return[{...c,...i,rrule:void 0}]}return[i]})},managesEvent:(r)=>Ce(r),applyEdit:({event:r,updates:n,currentEvents:a,scope:i})=>Je({targetEvent:r,updates:n??{},currentEvents:a,scope:i}),applyDelete:({event:r,currentEvents:n,scope:a})=>ze({targetEvent:r,currentEvents:n,scope:a}),contribute:(r,n)=>{if(r!=="ical:vevent-properties")return[];return ye(n)},renderSlot:(r,n)=>{if(r===Zt){let{event:a,onChange:i}=n;return et(He,{event:a,onChange:i})}if(r===Xt){let{event:a,operation:i,resolve:c,cancel:l}=n;return et(xe,{eventTitle:a.title||"",isOpen:!0,onClose:l,onConfirm:(u)=>c(u),operationType:i})}return null}});export{ao as RRule,so as Weekday,he as generateRecurringEvents,Ce as isRecurringEvent,ye as recurrenceICalProperties,Jt as recurrencePlugin};
@@ -0,0 +1,2 @@
1
+ import{e}from"./chunk-tfk3a0d4.js";import{useContext as s}from"react";var k=(t,a,n)=>{let l=s(t);if(l===void 0)throw Error(`${a} must be used within a ${n}`);return l};import*as o from"@radix-ui/react-dialog";import{XIcon as d}from"lucide-react";import{jsx as i,jsxs as r}from"react/jsx-runtime";function R({...t}){return i(o.Root,{"data-slot":"dialog",...t})}function g({...t}){return i(o.Portal,{"data-slot":"dialog-portal",...t})}function m({className:t,...a}){return i(o.Overlay,{className:e("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),"data-slot":"dialog-overlay",...a})}function w({className:t,children:a,...n}){return r(g,{"data-slot":"dialog-portal",children:[i(m,{}),r(o.Content,{className:e("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg max-h-[90%]",t),"data-slot":"dialog-content",...n,children:[a,r(o.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[i(d,{}),i("span",{className:"sr-only",children:"Close"})]})]})]})}function S({className:t,...a}){return i("div",{className:e("flex flex-col gap-2 text-center sm:text-left",t),"data-slot":"dialog-header",...a})}function G({className:t,...a}){return i("div",{className:e("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),"data-slot":"dialog-footer",...a})}function P({className:t,...a}){return i(o.Title,{className:e("text-lg leading-none font-semibold",t),"data-slot":"dialog-title",...a})}function W({className:t,...a}){return i(o.Description,{className:e("text-muted-foreground text-sm",t),"data-slot":"dialog-description",...a})}
2
+ export{k,R,w,S,G,P,W};
@@ -0,0 +1,2 @@
1
+ import e from"dayjs";import l from"dayjs/plugin/isSameOrAfter.js";import D from"dayjs/plugin/isSameOrBefore.js";import O from"dayjs/plugin/localeData.js";import g from"dayjs/plugin/localizedFormat.js";import T from"dayjs/plugin/minMax.js";import x from"dayjs/plugin/timezone.js";import b from"dayjs/plugin/utc.js";import z from"dayjs/plugin/weekday.js";import C from"dayjs/plugin/weekOfYear.js";var u,S=(o,a,f)=>{let y=a.prototype,n=f.tz.setDefault;f.tz.setDefault=(r)=>(u=r,n(r));let{startOf:s,endOf:c}=y;function p(r,i){let m=r.$x?.$timezone||u;if(!m)return i;let j=f.tz(i.format("YYYY-MM-DDTHH:mm:ss"),m).utcOffset();if(i.utcOffset()!==j)return i.tz(m,!0);return i}y.startOf=function(r,i){let m=s.call(this,r,i);return p(this,m)},y.endOf=c},I=(o,a)=>{let f=a.prototype,y={isBefore:(n,s)=>n<s,isAfter:(n,s)=>n>s,isSame:(n,s)=>n===s,isSameOrBefore:(n,s)=>n<=s,isSameOrAfter:(n,s)=>n>=s};for(let[n,s]of Object.entries(y)){let c=f[n];f[n]=function(p,r){if(r===void 0&&e.isDayjs(p))return s(this.valueOf(),p.valueOf());return c.call(this,p,r)}}};e.extend(z);e.extend(C);e.extend(l);e.extend(D);e.extend(T);e.extend(x);e.extend(b);e.extend(O);e.extend(g);e.extend(S);e.extend(I);var M=/(?:Z|[+-]\d{2}:?\d{2})$/i,h=(o)=>{let a=o.split(/[Tt\s]/).at(1);if(!a)return!1;return M.test(a)},le=(o)=>typeof o==="string"&&!h(o),d=(o)=>{let a=e(o);if(!a.isValid())return a;if(le(o))return e.tz(o);if(!u)return a;return a.tz(u)};Object.assign(d,e);var t=d;
2
+ export{le,t};
@@ -0,0 +1,2 @@
1
+ import{k,R,w,S,P}from"./chunk-1x8xjsbq.js";import{le,t}from"./chunk-cn24081x.js";import{e,V,c,Y,d,N}from"./chunk-tfk3a0d4.js";import{u,y,b,U}from"./chunk-xf8cy2gp.js";var se={today:"Today",create:"Create",new:"New",update:"Update",delete:"Delete",cancel:"Cancel",export:"Export",previous:"Previous",next:"Next",event:"Event",events:"Events",newEvent:"New Event",title:"Title",description:"Description",location:"Location",allDay:"All day",startDate:"Start Date",endDate:"End Date",startTime:"Start Time",searchTime:"Search time...",endTime:"End Time",color:"Color",createEvent:"Create Event",editEvent:"Edit Event",addNewEvent:"Add a new event to your calendar",editEventDetails:"Edit your event details",eventTitlePlaceholder:"Event title",eventDescriptionPlaceholder:"Event description (optional)",eventLocationPlaceholder:"Event location (optional)",repeat:"Repeat",repeats:"Repeats",customRecurrence:"Custom recurrence",frequency:"Frequency",everyWeekday:"Every weekday",weeklyOn:"Weekly on",monthlyOnDay:"Monthly on day",monthlyOnThe:"Monthly on the",first:"first",second:"second",third:"third",fourth:"fourth",last:"last",daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly",interval:"Interval",repeatOn:"Repeat on",never:"Never",count:"Count",every:"Every",ends:"Ends",after:"After",occurrences:"occurrences",on:"On",editRecurringEvent:"Edit recurring event",deleteRecurringEvent:"Delete recurring event",editRecurringEventQuestion:"is a recurring event. How would you like to edit it?",deleteRecurringEventQuestion:"is a recurring event. How would you like to delete it?",thisEvent:"This event",thisEventDescription:"Only change this specific occurrence",thisAndFollowingEvents:"This and following events",thisAndFollowingEventsDescription:"Edit this and all future occurrences",allEvents:"All events",allEventsDescription:"Edit the entire recurring series",onlyChangeThis:"Only change this specific occurrence",changeThisAndFuture:"Change this and all future occurrences",changeEntireSeries:"Change the entire recurring series",onlyDeleteThis:"Only delete this specific occurrence",deleteThisAndFuture:"Delete this and all future occurrences",deleteEntireSeries:"Delete the entire recurring series",month:"Month",week:"Week",day:"Day",year:"Year",agenda:"Agenda",agendaNoEvents:"No upcoming events",more:"more",resources:"Resources",resource:"Resource",selectResource:"Select a resource",time:"Time",date:"Date",noResourcesVisible:"No resources visible",addResourcesOrShowExisting:"Add resources or show existing ones"};import{createContext as kn}from"react";var vt=kn(void 0);var Hn=[];function r(o){let s=k(vt,"useSmartCalendarContext","CalendarProvider");return o?o(s):s}function fe(){let o=r();return{currentDate:o.currentDate,currentRange:o.currentRange,view:o.view,events:o.events,rawEvents:o.rawEvents,isEventFormOpen:o.isEventFormOpen,selectedEvent:o.selectedEvent,selectedDate:o.selectedDate,firstDayOfWeek:o.firstDayOfWeek,resources:o.resources??Hn,orientation:o.orientation,setCurrentDate:o.setCurrentDate,selectDate:o.selectDate,setView:o.setView,nextPeriod:o.nextPeriod,prevPeriod:o.prevPeriod,today:o.today,addEvent:o.addEvent,updateEvent:o.updateEvent,deleteEvent:o.deleteEvent,openEventForm:o.openEventForm,closeEventForm:o.closeEventForm,onEventClick:o.onEventClick,renderCurrentTimeIndicator:o.renderCurrentTimeIndicator,getEventsForResource:o.getEventsForResource,businessHours:o.businessHours,t:o.t,timeFormat:o.timeFormat,timezone:o.timezone,currentLocale:o.currentLocale,getEventsForDateRange:o.getEventsForDateRange,applyScopedEdit:o.applyScopedEdit,applyScopedDelete:o.applyScopedDelete,getEventManager:o.getEventManager,renderSlot:o.renderSlot,collect:o.collect,getViews:o.getViews}}import{useMemo as Fa}from"react";var Z=1,ar=24,Q=24,sr=4,ir="bg-[color-mix(in_oklch,var(--background),var(--foreground)_3%)] text-muted-foreground pointer-events-none",H={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6},gt="h-12",Ct="bg-blue-50 text-blue-600 font-medium",ue="h-24";import{useEffect as yn,useMemo as fn,useRef as vn,useState as Pa}from"react";import{useMemo as On}from"react";import{useCallback as Lt}from"react";var it=(o,s)=>({...o,added:o.action==="add"?[s]:[],updated:o.action==="update"?[s]:[],deleted:o.action==="delete"?[s]:[]}),zt=(o,s,m)=>{if(!Array.isArray(o))return o;let{added:v,updated:C,deleted:E}=it(s,m);return{events:o,added:v,updated:C,deleted:E}},_t=(o,s,{onEventUpdate:m,onEventAdd:f,onEventDelete:v,onEventsChange:C,setCurrentEvents:E})=>{for(let D of o.updated)m?.(D);for(let D of o.added)f?.(D);for(let D of o.deleted)v?.(D);E(o.events),C?.({...s,added:o.added,updated:o.updated,deleted:o.deleted})};var lr=({currentEvents:o,setCurrentEvents:s,onEventAdd:m,onEventUpdate:f,onEventDelete:v,onEventsChange:C})=>{let E=Lt((h)=>{s((W)=>[...W,h]),m?.(h),C?.(it({action:"add",event:h},h))},[s,m,C]),D=Lt((h,W)=>{let ye=o.find((ve)=>ve.id===h);if(!ye)return;let ge={...ye,...W};s((ve)=>ve.map((pe)=>pe.id===h?ge:pe)),f?.(ge),C?.(it({action:"update",event:ye},ge))},[o,s,f,C]),G=Lt((h)=>{let W=o.find((ge)=>ge.id===h);if(!W)return;s((ge)=>ge.filter((T)=>T.id!==h)),v?.(W),C?.(it({action:"delete",event:W},W))},[o,s,v,C]);return{addEvent:E,updateEvent:D,deleteEvent:G}};import{useCallback as Nn,useEffect as Tn,useMemo as Pn,useRef as In,useState as jn}from"react";var dr=({events:o,pluginRuntime:s,getCurrentViewRange:m})=>{let[f,v]=jn(o),C=In(o);Tn(()=>{if(o!==C.current)v(o),C.current=o},[o]);let E=Nn((G,h)=>s.transformEvents(f,{start:G,end:h}),[f,s]),D=Pn(()=>{let{start:G,end:h}=m();return E(G,h)},[E,m]);return{currentEvents:f,setCurrentEvents:v,getEventsForDateRange:E,processedEvents:D}};import{useCallback as cr,useMemo as Mn}from"react";var ur=({currentEvents:o,pluginRuntime:s,setCurrentEvents:m,onEventAdd:f,onEventUpdate:v,onEventDelete:C,onEventsChange:E})=>{let D=Mn(()=>({setCurrentEvents:m,onEventAdd:f,onEventUpdate:v,onEventDelete:C,onEventsChange:E}),[m,f,v,C,E]),G=cr((W,ye,ge)=>{let T=s.getEventManager(W);if(!T?.applyEdit)return;let ve=T.applyEdit({event:W,updates:ye,currentEvents:o,scope:ge}),pe={action:"update",event:W,scope:ge},Ce={...W,...ye},Ee=zt(ve,pe,Ce);_t(Ee,pe,D)},[o,s,D]),h=cr((W,ye)=>{let ge=s.getEventManager(W);if(!ge?.applyDelete)return;let T=ge.applyDelete({event:W,currentEvents:o,scope:ye}),ve={action:"delete",event:W,scope:ye},pe=zt(T,ve,W);_t(pe,ve,D)},[o,s,D]);return{applyScopedEdit:G,applyScopedDelete:h}};import{useCallback as Gt}from"react";var lt=(o)=>{if(o.resourceIds)return o.resourceIds;if(o.resourceId!==void 0)return[o.resourceId];return[]};function x(o,s){if(s===void 0)return o;return o.filter((m)=>lt(m).includes(s))}var An=(o)=>(o.resourceIds?.length??0)>1,mr=(o,s)=>{let m=Gt((C)=>x(o,C),[o]),f=Gt((C)=>o.filter((E)=>lt(E).some((D)=>C.includes(D))),[o]),v=Gt((C)=>{if(C===void 0)return;return s.find((E)=>E.id===C)},[s]);return{getEventsForResource:m,getEventsForResources:f,getResourceById:v,isEventCrossResource:An}};var pr=({events:o,pluginRuntime:s,getCurrentViewRange:m,resources:f,onEventAdd:v,onEventUpdate:C,onEventDelete:E,onEventsChange:D})=>{let G=dr({events:o,pluginRuntime:s,getCurrentViewRange:m}),{currentEvents:h,setCurrentEvents:W,getEventsForDateRange:ye,processedEvents:ge}=G,T={setCurrentEvents:W,onEventAdd:v,onEventUpdate:C,onEventDelete:E,onEventsChange:D},{addEvent:ve,updateEvent:pe,deleteEvent:Ce}=lr({currentEvents:h,...T}),{applyScopedEdit:Ee,applyScopedDelete:he}=ur({currentEvents:h,pluginRuntime:s,...T}),{getEventsForResource:Re,getEventsForResources:be,getResourceById:De,isEventCrossResource:we}=mr(ge,f);return On(()=>({events:ge,rawEvents:h,setCurrentEvents:W,getEventsForDateRange:ye,addEvent:ve,updateEvent:pe,deleteEvent:Ce,applyScopedEdit:Ee,applyScopedDelete:he,getEventsForResource:Re,getEventsForResources:be,getResourceById:De,isEventCrossResource:we}),[ge,h,W,ye,ve,pe,Ce,Ee,he,Re,be,De,we])};import{useMemo as yr,useState as Vn}from"react";var fr=({firstDayOfWeek:o,dayMaxEvents:s=sr,businessHours:m,locale:f,translations:v,translator:C,resources:E,orientation:D="horizontal",weekViewGranularity:G="hourly"})=>{let[h,W]=Vn(f||"en"),ye=yr(()=>{if(C)return C;let ge=v||se;return(T)=>ge[T]||T},[v,C]);return yr(()=>({firstDayOfWeek:o,dayMaxEvents:s,businessHours:m,currentLocale:h,setCurrentLocale:W,t:ye,resources:E,orientation:D,weekViewGranularity:G}),[o,s,m,h,ye,E,D,G])};import{useCallback as dt,useMemo as Bn,useState as Wt}from"react";var Fn=(o)=>o,vr=({currentDate:o,t:s,disableEventClick:m,disableCellClick:f,onEventClick:v,onCellClick:C})=>{let[E,D]=Wt(!1),[G,h]=Wt(null),[W,ye]=Wt(null),ge=dt((Ee={})=>{let{start:he,end:Re,resourceId:be,resource:De,allDay:we}=Ee;if(he)ye(he);let ke=(he??o).second(0).millisecond(0);h(Fn({title:s("newEvent"),start:ke,end:Re??ke.add(1,"hour"),resourceId:be??De?.id,description:"",allDay:we??!1})),D(!0)},[o,s]),T=dt(()=>{ye(null),h(null),D(!1)},[]),ve=dt((Ee)=>{h(Ee),D(!0)},[]),pe=dt((Ee)=>{if(m)return;if(v)v(Ee);else ve(Ee)},[m,v,ve]),Ce=dt((Ee)=>{if(f)return;if(C)C(Ee);else ge(Ee)},[C,f,ge]);return Bn(()=>({isEventFormOpen:E,selectedEvent:G,selectedDate:W,setIsEventFormOpen:D,setSelectedEvent:h,setSelectedDate:ye,openEventForm:ge,closeEventForm:T,handleEventClick:pe,handleDateClick:Ce}),[E,G,W,ge,T,pe,Ce])};import{useCallback as je,useMemo as wa,useRef as Ra,useState as xa}from"react";import{Square as Jo}from"lucide-react";import{jsx as zn}from"react/jsx-runtime";var l=({children:o,transitionKey:s,delay:m=0,className:f,direction:v="vertical","data-testid":C,ref:E,style:D,...G})=>zn("div",{className:e("inline-block w-full animate-in fade-in fill-mode-backwards duration-500 ease-in-out",v==="horizontal"?"slide-in-from-right-2.5":"slide-in-from-top-2.5",f),"data-testid":C,ref:E,style:{animationDelay:`${m}s`,...D},...G,children:o},s);l.displayName="AnimatedSection";import{jsx as Cr,Fragment as gr}from"react/jsx-runtime";var Et=({date:o})=>{let{renderHour:s,timeFormat:m}=r();if(s)return Cr(gr,{children:s(o)});return Cr(gr,{children:o.format(m==="12-hour"?"h A":"H")})};function a(o){return Y(o,t())}function i(o,s){let m=o.startOf("week").day(s).startOf("day"),f=o.isBefore(m)?m.subtract(1,"week"):m;return Array.from({length:7},(v,C)=>f.add(C,"day"))}function L(o,s){let m=o.startOf("month"),v=i(m,s).at(0)??m;return Array.from({length:6},(C,E)=>{let D=v.add(E,"week").startOf("day");return i(D,s)})}function Dt(o){let s=o.daysInMonth(),m=o.startOf("month");return Array.from({length:s},(f,v)=>m.add(v,"day"))}function Er({referenceDate:o=t(),length:s=24}={}){let m=o.startOf("day");return Array.from({length:s},(f,v)=>m.hour(v).minute(0).second(0).millisecond(0))}var bt=(o,s)=>{let m=L(o,s),f=m.at(0)?.at(0)??o,v=m.at(-1)?.at(-1)??o;return{start:f.startOf("day"),end:v.endOf("day")}},q=(o)=>o==="12-hour"?"h:mma":"HH:mm";var Je=(o)=>String(o).padStart(2,"0"),_n=(o)=>typeof o==="number"?Je(o):o,n={col:{time:"time-col",date:"date-col",day:(o,s)=>{let m=`day-col-${c(o)}`;return s!=null?`${m}-resource-${s}`:m},resource:(o,s)=>`${o}-col-resource-${s}`,allDay:(o,s)=>`all-day-col-${c(o)}-${s}`,events:(o)=>`col-events-${o.toISOString()}`},cell:{day:(o,s,m=0)=>{let f=c(o);return s!=null?`day-cell-${f}-${Je(s)}-${Je(m)}`:`day-cell-${f}`},verticalTime:(o)=>`vertical-time-${Je(o)}`,vertical:(o,s,m,f)=>{let v=`vertical-cell-${c(o)}-${Je(s)}-${Je(m)}`;return f!=null?`${v}-resource-${f}`:v}},container:{vertical:{col:(o)=>`vertical-col-${o}`},horizontal:{row:(o)=>`horizontal-row-${o}`,rowLabel:(o)=>`horizontal-row-label-${o}`,event:(o)=>`horizontal-event-${o}`},verticalEvent:(o)=>`vertical-event-${o}`,eventsLayer:(o,s)=>`${o}-events-${s}`},header:{resource:{weekDay:"resource-week-day-header",columnsHeader:"resource-columns-header",monthDay:(o)=>`resource-month-header-${o.toISOString()}`,timeLabel:(o,s)=>`resource-${o}-time-label-${_n(s)}`},weekday:(o,s)=>`${o}-header-weekday-${s.toLowerCase()}`,week:{day:(o)=>`week-header-day-${o.toISOString()}`,hour:(o,s)=>`week-header-hour-${o.toISOString()}-${s}`,resource:(o)=>`week-header-resource-${o}`},year:{month:(o,s)=>s?`year-month-${s}-${o}`:`year-month-${o}`,day:(o,s)=>`year-day-${o}-${s}`}},allDayRow:(o)=>`allday-row-${o??"main"}`,listKey:(...o)=>o.join("-"),dayNumber:(o)=>a(o)?"day-number-today":`day-number-${o.format("D")}`,stickyInsets:(o,s,m,f)=>`sticky-insets-${o}-${c(s)}-${m?"sticky":"static"}-${f}`,dragPreview:(o)=>`event-drag-preview-${o}`,timePicker:(o)=>`time-picker-${o??""}`};import{jsx as Dr}from"react/jsx-runtime";var qe="w-16 min-w-16 max-w-16",br="w-[calc(100%-4rem)]",j="w-10 sm:w-16 min-w-10 sm:min-w-16 max-w-10 sm:max-w-16",Ae="shadow-[1px_0_0_0_color-mix(in_oklch,var(--background),var(--foreground)_10%)]",Fe=({days:o,gridType:s,renderLabel:m,widthClassName:f=qe,showsToday:v=!1})=>{let C=s==="hour";return{id:C?n.col.time:n.col.date,day:void 0,days:o,className:e("shrink-0",f,"sticky left-0 bg-background z-20",Ae),"data-sticky-inset":"left",gridType:s,noEvents:!0,renderCell:(E)=>{let D=t().hour(),G=E.hour()===D,h=C&&v&&G,W=h?Ct:"text-muted-foreground",ye=h?"time":void 0,ge=m?m(E):Dr(Et,{date:E});return Dr("div",{"aria-current":ye,className:e("h-full p-2 text-right text-[10px] sm:text-xs flex flex-col items-center",W),children:ge})}}};var B=(o,s)=>{if(!s)return!0;let m=!1;return ht(s,{date:o,onMatch:()=>{m=!0}}),m},Ln=/^(\d{1,2}):(\d{2})$/,Ut=(o,s)=>{if(typeof o==="number")return Math.round(o)*60;if(typeof o==="string"){let m=o.match(Ln);if(m){let f=Number(m[1]),v=Number(m[2]),C=f*60+v<=1440;if(v<=59&&C)return f*60+v}}return s*60},hr=(o,s)=>{let m=Ut(o,s);return m===0?1440:m},wr=({date:o,hour:s,minute:m=0,durationMinutes:f,businessHours:v})=>{if(!v)return!0;if(s===void 0)return B(o,v);let C=!1,E=s*60+m;return ht(v,{date:o,onMatch:(D)=>{let G=Ut(D.startTime,9),h=hr(D.endTime,17),W=E>=G,ye=f?E+f<=h:E<h;if(W&&ye)C=!0}}),C},ht=(o,s)=>{let{date:m,onMatch:f}=s;if(!o)return;let v=Array.isArray(o)?o:[o];for(let C of v)if(m&&C.daysOfWeek){let E=m.day();if(C.daysOfWeek.some((D)=>H[D]===E))f(C)}else f(C)},J=(o)=>{let{allDates:s,businessHours:m,resourceBusinessHours:f=[],hideNonBusinessHours:v}=o,C=24,E=0,D=!1,G=(W)=>{D=!0,C=Math.min(C,Ut(W.startTime,9)/60),E=Math.max(E,hr(W.endTime,17)/60)},h=(W)=>{ht(m,{date:W,onMatch:G});for(let ye of f)ht(ye,{date:W,onMatch:G})};for(let W of s)h(W);if(!D&&v){if(h(),!D)C=9,E=17,D=!0}return{minStart:C,maxEnd:E,hasBusinessHours:D}};function wt(o){return o.flatMap((s)=>s.businessHours?[s.businessHours]:[])}function Rt({referenceDate:o,businessHours:s,hideNonBusinessHours:m,allDates:f=[o],resourceBusinessHours:v=[]}){let C=Er({referenceDate:o}),E=Boolean(s)||v.length>0;if(!(m&&E))return C;let{minStart:G,maxEnd:h,hasBusinessHours:W}=J({allDates:f,businessHours:s,resourceBusinessHours:v,hideNonBusinessHours:m});if(!W)return C;if(G>=h)return[];let ye=Math.floor(G),ge=Math.ceil(h);return C.filter((T)=>{let ve=T.hour();return ve>=ye&&ve<ge})}import{memo as Gn}from"react";import{jsx as Rr}from"react/jsx-runtime";var Wn=({className:o})=>{let{t:s}=r();return Rr("div",{className:e("w-16 shrink-0 sticky left-0 bg-background z-20 flex items-center justify-center px-1 text-xs text-muted-foreground",Ae,o),"data-sticky-inset":"left",children:Rr("span",{className:"truncate",children:s("allDay")})})},xt=Gn(Wn);import{memo as Xo}from"react";import{memo as Yr,useMemo as $o}from"react";import{useMemo as $t}from"react";var Un=(o,s)=>{let m=(D)=>D.end.subtract(1,"millisecond").startOf(s).isAfter(D.start.startOf(s)),f=o.filter(m),v=o.filter((D)=>!m(D)),C=[...f].sort((D,G)=>{let h=D.start.diff(G.start);if(h!==0)return h;return G.end.diff(G.start)-D.end.diff(D.start)}),E=[...v].sort((D,G)=>D.start.diff(G.start));return{sortedMultiUnit:C,sortedSingleUnit:E}},xr=(o,{firstUnit:s,lastUnit:m,unitCount:f,gridType:v})=>{let C=t.max(o.start.startOf(v),s),E=o.end.subtract(1,"millisecond"),D=t.min(E.startOf(v),m),G=Math.trunc(N(C,s,v)),h=Math.trunc(N(D,s,v));return{startCol:Math.max(0,G),endCol:Math.min(f-1,h),isTruncatedStart:o.start.startOf(v).isBefore(s),isTruncatedEnd:E.startOf(v).isAfter(m)}},Kn=(o,s,m,{columns:f,gridType:v})=>{let C={start:s,end:m+1},E=f.at(s),D=f.at(m);if(v==="day"||!E||!D)return C;let h=o.start.diff(E,"hour",!0),W=o.end.diff(D,"hour",!0),ye=Math.min(Math.max(h,0),1),ge=Math.min(Math.max(W,0),1),T=s+ye,ve=m+ge;return ve>T?{start:T,end:ve}:C},Kt=(o,s,m)=>{for(let f=0;f<o.length;f++){let v=!0;for(let C=s;C<=m;C++)if(o[f][C]){v=!1;break}if(v)return f}return-1},St=({days:o,events:s,dayMaxEvents:m,gridType:f="day"})=>{let v=o.at(0),C=o.at(-1);if(!v||!C)return[];let E={firstUnit:f==="hour"?v.startOf("hour"):v.startOf("day"),lastUnit:f==="hour"?C.endOf("hour"):C.endOf("day"),unitCount:o.length,gridType:f},{sortedMultiUnit:D,sortedSingleUnit:G}=Un(s,f),h=Array.from({length:m},()=>Array.from({length:E.unitCount},()=>!1)),W=[],ye=({row:ge,startCol:T,endCol:ve,event:pe,isTruncatedStart:Ce,isTruncatedEnd:Ee})=>{for(let be=T;be<=ve;be++)h[ge][be]=!0;let he=Kn(pe,T,ve,{columns:o,gridType:f}),Re=he.end-he.start;W.push({kind:"horizontal",event:pe,left:he.start/E.unitCount*100,width:Re/E.unitCount*100,row:ge,isTruncatedStart:Ce,isTruncatedEnd:Ee})};for(let ge of D){let T=xr(ge,E),ve=Kt(h,T.startCol,T.endCol);if(ve!==-1){ye({row:ve,event:ge,...T});continue}for(let pe=T.startCol+1;pe<=T.endCol;pe++){let Ce=Kt(h,pe,T.endCol);if(Ce!==-1){ye({row:Ce,startCol:pe,endCol:T.endCol,event:ge,isTruncatedStart:!0,isTruncatedEnd:T.isTruncatedEnd});break}}}for(let ge of G){let ve=xr(ge,E).startCol,pe=Kt(h,ve,ve);if(pe!==-1)ye({row:pe,startCol:ve,endCol:ve,event:ge,isTruncatedStart:!1,isTruncatedEnd:!1})}return W};var Yt=({days:o,allDay:s,resourceId:m,gridType:f})=>{let{getEventsForDateRange:v,dayMaxEvents:C}=r(),E=o.at(0),D=o.at(-1),G=E?.startOf("day"),h=D?.endOf("day"),W=$t(()=>{if(!G||!h)return[];let T=v(G,h),ve=x(T,m);if(s)ve=ve.filter((pe)=>Boolean(pe.allDay));return ve},[v,G,h,m,s]),ye=$t(()=>{let T=new Map,ve=f??"day",pe=W.length===0;for(let Ce of o){if(pe){T.set(n.col.events(Ce),[]);continue}let Ee=Ce.startOf(ve),he=Ce.endOf(ve),Re=W.filter((be)=>d(be,Ee,he));T.set(n.col.events(Ce),Re)}return T},[o,W,f]);return{positionedEvents:$t(()=>St({days:o,events:W,dayMaxEvents:C,gridType:f}),[o,C,W,f]),columnEventsMap:ye}};import{memo as No,useRef as To}from"react";import{useMemo as qn}from"react";import{createContext as $n}from"react";var kt=$n(void 0);var Ge=()=>k(kt,"useCalendarCellContext","CalendarProvider");import{useMemo as Yn}from"react";var X=(o)=>{let{businessHours:s,getResourceById:m}=Ge();return Yn(()=>{if(o!=null){let f=m(o);if(f?.businessHours)return f.businessHours}return s},[o,m,s])};var Sr=({day:o,gridType:s,slotDurationMinutes:m,resourceId:f})=>{let{currentDate:v,view:C}=Ge(),E=X(f),D=C==="month",G=o.month()!==v.month(),h=D&&G;return!qn(()=>{if(s==="hour")return wr({date:o,hour:o.hour(),minute:o.minute(),durationMinutes:m,businessHours:E});return B(o,E)},[s,o,m,E])||h};import{useDroppable as Zn}from"@dnd-kit/core";import{useId as Jn}from"react";import{createContext as Xn,useContext as Qn}from"react";var ie=Xn(null),p=()=>Qn(ie);var qt=(o,{rangeStart:s,rangeEnd:m,resourceId:f,allDay:v})=>{if(!o||!s||!m)return!1;if(Boolean(v)&&!o.allDay)return!1;let E=o.resourceId!==void 0,D=f!==void 0,G=o.resourceId!==f;if(E&&D&&G)return!1;let ye={start:o.start,end:o.end};return d(ye,s,m)},kr=(o,s)=>{if(!o||!qt(o,s))return null;return{...o.event,start:o.start,end:o.end,allDay:o.allDay}},ce=(o)=>o?.isDropAllowed===!1?"not-allowed":void 0;import{jsx as Nr,jsxs as io}from"react/jsx-runtime";function eo(o,s,m,f){let v=o.hour(s??0).minute(m??0);if(s!==void 0&&m!==void 0)return{start:v,end:v.add(f,"minute")};if(s!==void 0)return{start:v,end:v.hour(s+1).minute(0)};return{start:v,end:v.add(1,"day").startOf("day")}}var to="rgba(188, 232, 241, 0.3)",ro=()=>Nr("div",{"aria-hidden":"true",className:"absolute inset-0 pointer-events-none",style:{backgroundColor:to}}),no=(o,s,m)=>{let f=p();return qt(f,{rangeStart:o.start,rangeEnd:o.end.subtract(1,"millisecond"),resourceId:s,allDay:m})},oo=({data:o,cellRange:s,disableDragAndDrop:m})=>{let{isOver:f,setNodeRef:v}=Zn({id:Jn(),data:o,disabled:m}),C=no(s,o.resourceId,o.allDay);return{setNodeRef:v,showDropHighlight:(f||C)&&!m}},ao=({allDay:o,cellDisabled:s,showDropHighlight:m,isSubDivider:f,range:v,resourceId:C,dataTestId:E,view:D})=>({"data-all-day":o?"true":void 0,"data-disabled":s.toString(),"data-drop-target":m?"true":void 0,"data-end":v.end.toISOString(),"data-resource-id":C,"data-slot-divider":f?"true":void 0,"data-start":v.start.toISOString(),"data-testid":E,"data-view":D}),so=({className:o,customClassName:s,disabledClass:m,clickBlocked:f,cellDisabled:v})=>e("droppable-cell relative",o,s,f?"cursor-default":"cursor-pointer",v&&m);function Hr({type:o,date:s,hour:m,minute:f,slotDurationMinutes:v,resourceId:C,allDay:E,children:D,className:G,style:h,"data-testid":W,disabled:ye=!1,isSubDivider:ge=!1}){let{onCellClick:T,isCellDisabled:ve,getCellClassName:pe,getResourceById:Ce,disableDragAndDrop:Ee,disableCellClick:he,classesOverride:Re,view:be}=Ge(),{start:De,end:we}=eo(s,m,f,v),ke=Ce?.(C),Se={start:De,end:we,resource:ke,allDay:E},He=ye||Boolean(ve?.(Se)),xe=he||He,{setNodeRef:_e,showDropHighlight:Pe}=oo({data:{type:o,date:s,hour:m,minute:f,resourceId:C,allDay:E,disabled:He},cellRange:{start:De,end:we},disableDragAndDrop:Boolean(Ee)}),Ie=(Le)=>{if(Le.stopPropagation(),xe)return;T(Se)};return io("div",{className:so({className:G,customClassName:pe?.(Se),disabledClass:Re?.disabledCell||ir,clickBlocked:xe,cellDisabled:He}),...ao({allDay:E,cellDisabled:He,showDropHighlight:Pe,isSubDivider:ge,range:{start:De,end:we},resourceId:C,dataTestId:W,view:be}),onClick:Ie,ref:_e,style:h,children:[Pe&&Nr(ro,{}),D]})}import{useImperativeHandle as bo,useState as jr}from"react";import{useDraggable as mo}from"@dnd-kit/core";import{memo as po,useRef as yo}from"react";import{createContext as lo,useContext as co}from"react";var F=lo("horizontal"),Tr=()=>co(F);var O=(o)=>e(o.backgroundColor||"bg-blue-500",o.color||"text-white"),I=(o)=>({backgroundColor:o.backgroundColor,color:o.color}),Ht=({axis:o,isTruncatedStart:s,isTruncatedEnd:m})=>{if(o==="vertical")return"rounded-md";if(s&&m)return"rounded-none";if(s)return"rounded-r-md rounded-l-none";if(m)return"rounded-l-md rounded-r-none";return"rounded-md"},M={horizontal:"sticky left-[calc(var(--ilamy-sticky-left)+--spacing(1))] inline-block max-w-full align-top",vertical:"sticky top-[calc(var(--ilamy-sticky-top)+--spacing(0.5))]"};import{jsx as Xt,jsxs as uo}from"react/jsx-runtime";function Pr({event:o,isTruncatedStart:s,isTruncatedEnd:m}){let f=Tr(),v=f==="horizontal",C=v&&s,E=v&&m;return uo("div",{className:e(O(o),"h-full w-full px-1 border-[1.5px] border-card text-left overflow-clip relative",Ht({axis:f,isTruncatedStart:s,isTruncatedEnd:m})),style:I(o),children:[C&&Xt("div",{className:"absolute left-0 top-0 bottom-0 w-0.5 bg-foreground/25"}),Xt("p",{className:e("text-[10px] font-semibold sm:text-xs mt-0.5",M[f],C&&"pl-1",E&&"pr-1"),children:o.title}),E&&Xt("div",{className:"absolute right-0 top-0 bottom-0 w-0.5 bg-foreground/25"})]})}import{jsx as Ir}from"react/jsx-runtime";var fo=({isDragDisabled:o,disableEventClick:s,isSourceOfDrag:m})=>({cursorClass:o?s?"cursor-default":"cursor-pointer":"cursor-grab",draggingClass:m&&!o&&"cursor-grabbing opacity-50 select-none"}),vo=({renderEvent:o,event:s,segment:m,isTruncatedStart:f,isTruncatedEnd:v})=>{if(o)return o(s,m);return Ir(Pr,{event:s,isTruncatedEnd:v,isTruncatedStart:f})};function go({elementId:o,event:s,className:m,style:f,disableDrag:v=!1,isTruncatedStart:C=!1,isTruncatedEnd:E=!1,sourceResourceId:D,dragSegment:G,isBeingDragged:h=!1}){let{onEventClick:W,renderEvent:ye,disableEventClick:ge,disableDragAndDrop:T}=r(),ve=yo(null),{attributes:pe,listeners:Ce,setNodeRef:Ee,isDragging:he}=mo({id:o,data:{event:s,type:"calendar-event",sourceResourceId:D,dragSegment:G,getBarRect:()=>ve.current?.getBoundingClientRect()},disabled:v||T}),Re=(Se)=>{ve.current=Se,Ee(Se)},{cursorClass:be,draggingClass:De}=fo({isDragDisabled:Boolean(v||T),disableEventClick:Boolean(ge),isSourceOfDrag:he||h}),ke=vo({renderEvent:ye,event:s,segment:{isStart:!C,isEnd:!E},isTruncatedStart:C,isTruncatedEnd:E});return Ir(l,{className:e("overflow-clip text-ellipsis whitespace-nowrap h-full w-full",be,De,m),onClick:(Se)=>{Se.stopPropagation(),W(s)},ref:Re,style:f,transitionKey:o,...pe,...Ce,children:ke})}var Co=(o,s)=>{if(!o||!s)return o===s;return o.start.isSame(s.start)&&o.end.isSame(s.end)&&o.axis===s.axis},Eo=(o,s)=>{if(!o||!s)return o===s;return[...new Set([...Object.keys(o),...Object.keys(s)])].every((f)=>o[f]===s[f])},Do=["elementId","disableDrag","className","event","isTruncatedStart","isTruncatedEnd","isBeingDragged"],A=po(go,(o,s)=>{let m=Do.every((C)=>o[C]===s[C]),f=Co(o.dragSegment,s.dragSegment),v=Eo(o.style,s.style);return m&&f&&v});import{jsx as ct,jsxs as ho}from"react/jsx-runtime";var Mr=({ref:o})=>{let[s,m]=jr(!1),[f,v]=jr(null),{eventHeight:C}=r();return bo(o,()=>({open:()=>m(!0),close:()=>m(!1),setSelectedDayEvents:(E)=>v(E)})),ct(R,{onOpenChange:m,open:s,children:ho(w,{className:"max-h-[80vh] max-w-md overflow-y-auto",children:[ct(S,{children:ct(P,{children:f?.day.format("MMMM D, YYYY")})}),ct("div",{className:"mt-4 space-y-3",children:f?.events.map((E)=>ct(A,{className:"relative my-1",elementId:`all-events-dialog-event-${E.id}`,event:E,style:{height:`${C}px`}},E.id))})]})})};import{jsx as wo,jsxs as Ro}from"react/jsx-runtime";var Ar=({day:o,showDayNumber:s,children:m})=>{let{eventSpacing:f}=Ge();return Ro("div",{className:"flex flex-col h-full w-full","data-testid":"grid-cell-content",style:{gap:`${f}px`},children:[s&&wo(b,{className:"items-start","data-testid":n.dayNumber(o),dayNumber:o.format("D"),today:a(o)}),m]})};import{useMemo as So}from"react";import{jsxs as xo}from"react/jsx-runtime";var Or=({hiddenCount:o,label:s,onOpen:m})=>xo("div",{className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] whitespace-nowrap sm:text-xs shrink-0 mt-1",onClick:(f)=>{f.stopPropagation(),m()},onKeyDown:(f)=>{let v=f.key==="Enter",C=f.key===" ";if(v||C)f.preventDefault(),f.stopPropagation(),m()},role:"button",tabIndex:0,children:["+",o," ",s]});import{jsx as Vr,jsxs as Ho,Fragment as ko}from"react/jsx-runtime";var Br=({allEventsDialogRef:o,day:s,gridType:m,allDay:f,resourceId:v,precomputedEvents:C})=>{let{dayMaxEvents:E=0,getEventsForDateRange:D,t:G,eventHeight:h,onMoreEventsClick:W}=r(),ye=So(()=>{if(C)return C;let Ce=D(s.startOf(m),s.endOf(m));if(f)Ce=Ce.filter((Ee)=>Ee.allDay);return x(Ce,v)},[C,s,v,D,m,f]),ge=()=>{if(W){W(s,ye);return}o.current?.setSelectedDayEvents({day:s,events:ye}),o.current?.open()},T=ye.length-E,ve=T>0,pe=ye.slice(0,E);return Ho(ko,{children:[pe.map((Ce,Ee)=>Vr("div",{className:"w-full shrink-0","data-testid":Ce?.title,style:{height:`${h}px`}},n.listKey("empty",Ee,Ce.id))),ve&&Vr(Or,{hiddenCount:T,label:G("more"),onOpen:ge})]})};import{jsx as Qt,jsxs as Fr,Fragment as jo}from"react/jsx-runtime";var Po=(o,s,m)=>{if(m)return m;if(s==="hour")return n.cell.day(o,o.format("HH"),o.format("mm"));return n.cell.day(o)},Io=({day:o,hour:s,minute:m,slotDurationMinutes:f=60,className:v="",resourceId:C,gridType:E="day",shouldRenderEvents:D=!0,allDay:G=!1,precomputedEvents:h,"data-testid":W,showDayNumber:ye=!1,isSubDivider:ge=!1,children:T})=>{let ve=To(null),pe=Sr({day:o,gridType:E,slotDurationMinutes:f,resourceId:C}),Ce=Po(o,E,W);return Fr(jo,{children:[Qt(Hr,{allDay:G,className:e("cursor-pointer overflow-clip p-1 bg-background not-in-data-dragging:hover:bg-accent min-h-[60px] relative min-w-0",v),"data-testid":Ce,date:o,disabled:pe,hour:s,isSubDivider:ge,minute:m,resourceId:C,slotDurationMinutes:f,type:"day-cell",children:Fr(Ar,{day:o,showDayNumber:ye,children:[D&&Qt(Br,{allDay:G,allEventsDialogRef:ve,day:o,gridType:E,precomputedEvents:h,resourceId:C}),T]})}),D&&Qt(Mr,{ref:ve})]})},z=No(Io);import{jsx as zr}from"react/jsx-runtime";var et=({resource:o,className:s,children:m,"data-testid":f,"data-sticky-inset":v})=>{let{renderResource:C}=r();return zr("div",{className:e("flex items-center justify-center p-2",s),"data-sticky-inset":v,"data-testid":f,style:{color:o.color,backgroundColor:o.backgroundColor},children:C?C(o):m??zr("div",{className:"text-sm font-medium truncate",children:o.title})})};import{memo as Lo,useMemo as Go}from"react";import{memo as Mo}from"react";import{jsx as Oo}from"react/jsx-runtime";var Ao=({rangeStart:o,rangeEnd:s,now:m,resource:f,axis:v="vertical",withDot:C})=>{let{renderCurrentTimeIndicator:E,view:D}=r((h)=>({renderCurrentTimeIndicator:h.renderCurrentTimeIndicator,view:h.view})),G;if(E)G=(h)=>E({...h,resource:f,view:D});return Oo(U,{axis:v,now:m,rangeEnd:s,rangeStart:o,render:G,withDot:C})},ee=Mo(Ao);import{useMemo as _r}from"react";var te=({days:o,gridType:s,resourceId:m,allDay:f})=>{let v=p(),C=_r(()=>({rangeStart:o.at(0),rangeEnd:o.at(-1)?.add(1,s).subtract(1,"millisecond")}),[o,s]);return _r(()=>kr(v,{...C,resourceId:m,allDay:f}),[v,C,m,f])};import{jsx as Lr}from"react/jsx-runtime";function re({orientation:o,event:s,style:m,isTruncatedStart:f,isTruncatedEnd:v,contentClassName:C,children:E}){return Lr("div",{className:e("absolute z-20 pointer-events-none transition-none overflow-clip","shadow-xl inset-ring-2 inset-ring-foreground border-[1.5px] border-card",Ht({axis:o,isTruncatedStart:f,isTruncatedEnd:v}),O(s)),"data-testid":n.dragPreview(o),style:{...m,...I(s)},children:Lr("div",{className:e("h-full w-full text-left overflow-clip",C),children:E})})}var Nt=(o,s,m)=>({left:`calc(${o.left}% + var(--spacing) * 0.25)`,width:`calc(${o.width}% - var(--spacing) * 1)`,minWidth:"calc(var(--spacing) * 8)",top:`${s}px`,height:`${m}px`}),ne=(o)=>({left:`${o.left}%`,width:`calc(${o.width}% - var(--spacing) * 2)`,top:`${o.top}%`,height:`${o.height}%`});import{jsx as Gr,jsxs as Vo}from"react/jsx-runtime";function Wr({previewPositioned:o,top:s}){let{timeFormat:m,eventHeight:f}=r((D)=>({timeFormat:D.timeFormat,eventHeight:D.eventHeight})),{event:v,isTruncatedStart:C,isTruncatedEnd:E}=o;return Vo(re,{contentClassName:"px-1.5 flex items-center gap-1",event:v,isTruncatedEnd:E,isTruncatedStart:C,orientation:"horizontal",style:Nt(o,s,f),children:[!v.allDay&&Gr("span",{className:"text-[10px] font-semibold sm:text-xs",children:v.start.format(q(m))}),Gr("span",{className:e("text-[10px] font-bold sm:text-xs truncate",M.horizontal),children:v.title})]})}var g={minutes:0,days:0},K=(o,s,m)=>{if(!s.start||!s.end)return;let f=o.start.isBefore(s.start)?s.start:o.start,v=o.end.isAfter(s.end)?s.end:o.end;return{start:f,end:v,axis:m}},Bo=(o,s,m)=>{let f=Math.max(0,o-s);return Math.min(1,f/m)},de=({activeEvent:o,initialRect:s,activatorEvent:m,segment:f,slotDurationMinutes:v})=>{let{clientX:C,clientY:E}=m,D=f.axis==="vertical",G=D?E:C,h=D?s?.top:s?.left,W=D?s?.height:s?.width;if(G===void 0||h===void 0)return g;if(W===void 0||W<=0)return g;let ye=Bo(G,h,W),ge=f.end.diff(f.start,"minute"),T=f.start.add(ye*ge,"minute"),ve=Fo(f,ye),pe=D?T:ve;return{minutes:zo(o,T,v),days:_o(o,pe)}},Fo=(o,s)=>{let m=o.start.startOf("day"),v=o.end.subtract(1,"millisecond").startOf("day").diff(m,"day")+1,C=Math.floor(s*v),E=Math.min(Math.max(0,C),v-1);return m.add(E,"day")},zo=(o,s,m)=>{let f=o.end.diff(o.start,"minute"),v=Math.max(0,f-m),C=s.diff(o.start,"minute"),E=Math.floor(C/m)*m;return Math.min(Math.max(0,E),v)},_o=(o,s)=>{let m=o.start.startOf("day"),f=o.end.subtract(1,"millisecond").startOf("day"),v=Math.max(0,f.diff(m,"day")),C=s.startOf("day").diff(m,"day");return Math.min(Math.max(0,C),v)};import{jsx as Ur}from"react/jsx-runtime";var Kr=(o,s,m)=>`${o.event.id}-${o.row}-${s?.toISOString()}-${m??"no-resource"}`;function $r({positioned:o,elementId:s,top:m,eventHeight:f,range:v,resourceId:C,draggedEventId:E}){let{event:D,left:G,width:h}=o;return Ur("div",{className:"absolute z-10 pointer-events-auto overflow-clip","data-left":G,"data-testid":n.container.horizontal.event(D.id),"data-top":m,"data-width":h,style:Nt(o,m,f),children:Ur(A,{className:"h-full w-full shadow",dragSegment:K(D,v,"horizontal"),elementId:s,event:D,isBeingDragged:E===D.id,isTruncatedEnd:o.isTruncatedEnd,isTruncatedStart:o.isTruncatedStart,sourceResourceId:C})})}import{jsx as Tt,jsxs as Ko}from"react/jsx-runtime";var Wo=1,Uo=({gridType:o="day",days:s,resourceId:m,resource:f,"data-testid":v,positionedEvents:C,dayNumberHeight:E=ar,allDay:D})=>{let{eventHeight:G,eventSpacing:h,resources:W}=r(),ye=p(),ge=s.at(0)?.startOf("day"),ve=m===void 0||W?.at(0)?.id===m,pe=s.at(0),Ce=s.at(-1)?.add(1,o),Ee=o==="hour"&&Boolean(pe&&Ce),he=(De)=>E+h+De*(G+h),Re=te({days:s,gridType:o,resourceId:m,allDay:D}),be=Go(()=>{if(!Re)return null;return St({days:s,gridType:o,events:[Re],dayMaxEvents:Wo}).at(0)??null},[Re,s,o]);return Tt(F.Provider,{value:"horizontal",children:Ko("div",{className:"absolute inset-0 pointer-events-none z-10 overflow-clip","data-testid":v,children:[Ee&&pe&&Ce&&Tt(ee,{axis:"horizontal",rangeEnd:Ce,rangeStart:pe,resource:f,withDot:ve}),C.map((De)=>{let we=Kr(De,ge,m);return Tt($r,{draggedEventId:ye?.event.id,elementId:we,eventHeight:G,positioned:De,range:{start:pe,end:Ce},resourceId:m,top:he(De.row)},n.listKey(we,"wrapper"))}),be&&Tt(Wr,{previewPositioned:be,top:he(be.row)})]})})},Zt=Lo(Uo);import{jsx as Oe,jsxs as Jt}from"react/jsx-runtime";var Yo=({id:o,resource:s,gridType:m="day",variant:f="resource",dayNumberHeight:v,className:C,columns:E=[],allDay:D,showDayNumber:G=!1})=>{let{renderResource:h}=r(),W=f==="resource",ye=E.some((pe)=>pe.days),ge=$o(()=>{if(ye)return[];return E.map((pe)=>pe.day).filter((pe)=>Boolean(pe))},[E,ye]),{positionedEvents:T,columnEventsMap:ve}=Yt({days:ge,gridType:m,resourceId:s?.id,allDay:D});return Jt("div",{className:e("flex flex-1 relative min-w-0",C),"data-testid":n.container.horizontal.row(o),children:[W&&s&&Oe(et,{className:"w-20 sm:w-40 border-r sticky left-0 bg-background z-20 h-full","data-sticky-inset":"left","data-testid":n.container.horizontal.rowLabel(s.id),resource:s,children:h?h(s):Oe("div",{className:"wrap-break-word text-sm",children:s.title})}),Jt("div",{className:"relative flex-1 flex min-w-0",children:[Oe("div",{className:"flex w-full min-w-0 gap-px bg-border",children:E.map((pe,Ce)=>{let Ee=n.listKey("col",Ce);if(pe.days)return Oe(qo,{allDay:D,col:pe,dayNumberHeight:v,gridType:m,id:o,resource:s,resourceId:s?.id,showDayNumber:G},Ee);return pe.day?Oe(z,{allDay:D,className:e("flex-1 w-20",pe.className),day:pe.day,gridType:m,hour:m==="hour"?pe.day.hour():void 0,precomputedEvents:ve.get(n.col.events(pe.day)),resourceId:s?.id,showDayNumber:G},Ee):null})}),!ye&&Oe("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Oe(Zt,{allDay:D,"data-testid":n.container.eventsLayer("horizontal",o),dayNumberHeight:v,days:ge,gridType:m,positionedEvents:T,resource:s,resourceId:s?.id})})]})]})},qo=Yr(({col:o,gridType:s="day",allDay:m,resource:f,resourceId:v,dayNumberHeight:C,showDayNumber:E,id:D})=>{let G=o.days??[],{positionedEvents:h}=Yt({days:G,gridType:s,resourceId:v,allDay:m});return Jt("div",{className:"flex relative w-full",children:[Oe("div",{className:"flex w-full gap-px bg-border",children:G.map((W,ye)=>Oe(z,{allDay:m,className:e("flex-1 w-20",o.className),day:W,gridType:s,hour:s==="hour"?W.hour():void 0,resourceId:v,showDayNumber:E},n.listKey("day",ye)))}),Oe("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Oe(Zt,{allDay:m,"data-testid":n.container.eventsLayer("horizontal",D),dayNumberHeight:C,days:G,gridType:s,positionedEvents:h,resource:f,resourceId:v})})]})}),oe=Yr(Yo);import{jsx as qr,jsxs as Zo}from"react/jsx-runtime";var Qo=({days:o,classes:s,resource:m,showSpacer:f=!0})=>{let v=o.map((C,E)=>({id:n.col.allDay(C,E),day:C,gridType:"day",className:e("h-full min-h-12 bg-background",s?.cell)}));return Zo("div",{className:e("flex w-full gap-px bg-border",s?.row),"data-testid":"all-day-row",children:[f&&qr(xt,{className:s?.spacer}),qr(oe,{allDay:!0,className:"flex-1 min-h-fit",columns:v,dayNumberHeight:0,gridType:"day",id:n.allDayRow(m?.id),resource:m,variant:"regular"})]})},ae=Xo(Qo);import{jsx as tt,jsxs as Xr}from"react/jsx-runtime";var Ne="min-w-20 flex-1",Xe=({resources:o,days:s,gridType:m,cellClassName:f})=>{let v=s.map((C)=>{let E=Array.isArray(C),D=E?C.at(0):C;return{id:D?n.col.day(D):"day-col-unknown",day:E?void 0:C,days:E?C:void 0,className:f,gridType:m}});return o.map((C)=>({id:String(C.id),resource:C,columns:v}))},Qe=({resources:o,gutter:s,columnsFor:m})=>[s,...o.flatMap((f)=>{let v=m(f);return(Array.isArray(v)?v:[v]).map((E)=>({...E,resource:f}))})],Pt=({resources:o})=>Xr("div",{className:"flex gap-px bg-border h-12 flex-1","data-testid":n.header.resource.columnsHeader,children:[tt("div",{className:e("shrink-0 sticky top-0 left-0 bg-background z-20",qe,Ae)}),o.map((s)=>tt(et,{className:e(Ne,"bg-background"),resource:s},n.listKey("resource-cell",s.id)))]}),rt=()=>{let{t:o}=r((s)=>({t:s.t}));return tt("div",{className:"w-20 sm:w-40 border-b border-r shrink-0 flex justify-center items-center sticky top-0 left-0 bg-background z-20",children:tt("div",{className:"text-sm truncate px-1 min-w-0",children:o("resources")})})},me=({columns:o})=>{let s=[],m=new Map;for(let f of o){if(!f.resource||f.noEvents||!f.day)continue;let v=m.get(f.resource.id);if(!v)v={resource:f.resource,days:[],seenDayKeys:new Set},m.set(f.resource.id,v),s.push(v);let C=c(f.day);if(!v.seenDayKeys.has(C))v.seenDayKeys.add(C),v.days.push(f.day)}return Xr("div",{className:"flex w-full gap-px bg-border",children:[tt(xt,{}),s.map(({resource:f,days:v})=>tt(ae,{classes:{cell:e("min-w-20",v.length>1&&"flex-1")},days:v,resource:f,showSpacer:!1},n.allDayRow(f.id)))]})};import{jsx as It}from"react/jsx-runtime";var jt=({hours:o,view:s})=>It("div",{className:e("flex gap-px bg-border border-b",gt),children:o.map((m,f)=>{let v=m.isSame(t(),"hour"),C=v?"time":void 0,E=m.format("HH"),D=n.listKey("time-header-hour",E,f);return It("div",{"aria-current":C,className:e(Ne,"bg-background flex items-center justify-center text-xs shrink-0",v&&Ct),"data-hour":E,"data-testid":n.header.resource.timeLabel(s,E),children:It(l,{className:"text-center",transitionKey:D,children:It(Et,{date:m})})},D)})});import{jsx as We,jsxs as Jr,Fragment as na}from"react/jsx-runtime";var ea=({date:o})=>{let{t:s}=r((f)=>({t:f.t})),m=a(o);return We("div",{className:"flex flex-1 justify-center items-center min-h-12","data-testid":"day-view-header",children:Jr(l,{className:e("flex justify-center items-center text-center text-sm font-semibold sm:text-xl",m&&"text-primary"),transitionKey:c(o),children:[o.format("dddd, LL"),m&&We("span",{className:"bg-primary text-primary-foreground ml-2 rounded-full px-1 py-0.5 text-xs sm:px-2 sm:text-sm",children:s("today")})]})})},Qr=(o,s)=>Rt({referenceDate:o,businessHours:s.businessHours,hideNonBusinessHours:s.hideNonBusinessHours,allDates:[o],resourceBusinessHours:wt(s.resources??[])}),ta=({date:o,config:s})=>{let m=Qr(o,s);return Jr(na,{children:[We(rt,{}),We("div",{className:"flex-1 flex flex-col",children:We(jt,{hours:m,view:"day"})})]})},ra=(o,s)=>{let m=s.resources??[],f=Qr(o,s),v=a(o);if(!m.length)return[Fe({days:f,gridType:"hour",showsToday:v}),{id:n.col.day(o),day:o,days:f,className:e(br,"flex-1"),gridType:"hour"}];if(s.orientation==="vertical")return Qe({resources:m,gutter:Fe({days:f,gridType:"hour",showsToday:v}),columnsFor:(C)=>({id:n.col.day(o,C.id),days:f,day:o,gridType:"hour"})});return Xe({resources:m,days:f,gridType:"hour",cellClassName:Ne})},Zr={name:"day",label:"day",icon:Jo,navigationUnit:"day",layout:"vertical",supportsResources:!0,range:(o)=>({start:o.startOf("day"),end:o.endOf("day")}),columns:ra,renderHeader:({date:o,config:s})=>{let m=s.resources??[];if(!m.length)return We(ea,{date:o});if(s.orientation==="vertical")return We(Pt,{resources:m});return We(ta,{config:s,date:o})}};import{Grid3x3 as oa}from"lucide-react";import{jsx as er}from"react/jsx-runtime";var ze=({today:o,dayNumber:s,weekday:m,className:f})=>er(b,{className:f,dayNumber:er(l,{className:"w-auto",transitionKey:s,children:s}),today:o,weekday:m==null?void 0:er(l,{transitionKey:m,children:m})});import{jsx as Mt}from"react/jsx-runtime";var en=({className:o})=>{let{firstDayOfWeek:s,stickyViewHeader:m,viewHeaderClassName:f,currentDate:v}=r(),C=i(v,s);return Mt("div",{className:e("flex w-full gap-px bg-border border-b",m&&"sticky top-0 z-20",f,o),"data-testid":"month-header",children:C.map((E)=>{let D=E.format("ddd");return Mt("div",{className:"py-2 text-center font-medium bg-background flex-1 min-w-0 flex items-center justify-center","data-testid":n.header.weekday("month",D),children:Mt(l,{transitionKey:D,children:Mt("span",{className:"text-sm capitalize truncate w-full block",children:D})})},D)})})};import{jsx as Ue,jsxs as da,Fragment as la}from"react/jsx-runtime";var aa=(o,s)=>{let m=Dt(o);return Qe({resources:s,gutter:Fe({days:m,gridType:"day",renderLabel:(f)=>Ue(ze,{className:"flex-col-reverse",dayNumber:f.format("D"),today:a(f),weekday:f.format("ddd")})}),columnsFor:(f)=>({id:n.col.resource("month",f.id),day:void 0,days:m,gridType:"day"})})},sa=({date:o})=>{let s=Dt(o);return da(la,{children:[Ue(rt,{}),Ue("div",{className:"flex flex-1 gap-px bg-border border-b",children:s.map((m,f)=>{let v=n.listKey("resource-month-day",f),C=a(m);return Ue("div",{className:"flex-1 w-20 bg-background shrink-0 flex items-center justify-center flex-col",children:Ue(ze,{className:"flex-col-reverse",dayNumber:m.format("D"),today:C,weekday:m.format("ddd")})},v)})})]})},ia=(o,s)=>{let m=s.resources??[];if(m.length){if(s.orientation==="vertical")return aa(o,m);return Xe({resources:m,days:Dt(o),gridType:"day"})}return L(o,s.firstDayOfWeek).map((f,v)=>({id:n.listKey("week",v),columns:f.map((C)=>({id:n.col.day(C),day:C,className:"w-auto",gridType:"day"})),className:"flex-1",showDayNumber:!0}))},tn={name:"month",label:"month",icon:oa,navigationUnit:"month",layout:"horizontal",supportsResources:!0,range:(o,s)=>bt(o,s.firstDayOfWeek),columns:ia,renderHeader:({date:o,config:s})=>{let m=s.resources??[];if(!m.length)return Ue(en,{className:"h-12"});if(s.orientation==="vertical")return Ue(Pt,{resources:m});return Ue(sa,{date:o})}};import{Columns3 as ua}from"lucide-react";import{jsx as tr}from"react/jsx-runtime";var rn=({days:o})=>{let{weekViewGranularity:s}=r(),m=s==="hourly";return tr("div",{className:e("flex gap-px bg-border border-b",gt),children:o.map((f,v)=>{let C=a(f),E=n.listKey("resource-week-day",v);return tr("div",{className:e("shrink-0 bg-background flex-1 flex items-center text-center font-medium min-w-20"),"data-testid":n.header.resource.weekDay,children:tr(ze,{className:e(m?"sticky left-1/2 px-2":"w-full text-center"),dayNumber:f.format("D"),today:C,weekday:f.format("ddd")})},E)})})};import{jsx as At,jsxs as ca}from"react/jsx-runtime";var nn=({columns:o})=>{let{currentDate:s}=r();return ca("div",{className:"flex h-12 gap-px bg-border",children:[At("div",{className:e("shrink-0 z-20 bg-background sticky left-0",qe,Ae),children:At("span",{className:"px-2 h-full w-full flex justify-center items-start font-medium",children:s.week()})}),o.map((m,f)=>{let v=m.day;if(!v)return null;let C=a(v),E=n.listKey("resource-week-day",m.resourceId??"",f);return At("div",{className:e(Ne,"flex flex-col items-center justify-center text-xs shrink-0 bg-background"),"data-testid":n.header.resource.timeLabel("week",v.format("HH")),children:At(ze,{dayNumber:v.format("D"),today:C,weekday:v.format("ddd")})},E)})]})};import{jsx as ut,jsxs as on}from"react/jsx-runtime";var an=({resources:o})=>{let{weekViewGranularity:s,t:m,currentDate:f}=r(),v=s==="hourly";return on("div",{className:"flex h-12 gap-px bg-border",children:[ut("div",{className:e("shrink-0 z-20 bg-background sticky left-0",qe,Ae),children:on("span",{className:e("px-2 h-full w-full flex flex-col justify-center text-xs text-muted-foreground text-center min-w-0",v?"justify-end":"justify-center"),children:[ut("span",{className:"truncate w-full",children:m("week")}),!v&&ut("span",{className:"font-medium text-foreground truncate w-full",children:f.week()})]})}),o.map((C)=>ut(et,{className:e(Ne,"bg-background border-b"),resource:C,children:ut("div",{className:e("sticky text-sm font-medium truncate",v?"left-1/4":"left-1"),children:C.title})},n.listKey("resource-cell",C.id)))]})};import{jsx as Te,jsxs as mt,Fragment as Ca}from"react/jsx-runtime";var Ot=(o,s)=>{let m=i(o,s.firstDayOfWeek),{hiddenDays:f}=s;if(!f)return m;return m.filter((v)=>!f.has(v.day()))},Vt=(o)=>(o.weekViewGranularity??"hourly")==="hourly",ma=({date:o,config:s})=>{let{t:m,selectDate:f,openEventForm:v}=r((D)=>({t:D.t,selectDate:D.selectDate,openEventForm:D.openEventForm})),C=Ot(o,s),E=String(o.week());return mt("div",{className:"flex h-18 flex-1 gap-px bg-border","data-testid":"week-view-header",children:[Te("div",{className:e(j,"h-full shrink-0 items-center justify-center bg-background p-2 flex",Ae),children:mt("div",{className:"flex flex-col items-center justify-center min-w-0 w-full",children:[Te("span",{className:"text-muted-foreground text-xs truncate w-full text-center",children:m("week")}),Te(l,{className:"font-medium truncate w-full text-center",transitionKey:E,children:E})]})}),C.map((D,G)=>{let h=a(D),W=n.listKey("week-header-day",G);return Te("div",{className:e("hover:bg-accent bg-background flex-1 min-w-0 flex flex-col justify-center cursor-pointer p-1 text-center sm:p-2 w-20 h-full"),"data-testid":n.header.weekday("week",D.format("dddd")),onClick:()=>{f(D),v({start:D})},children:Te(ze,{dayNumber:D.format("D"),today:h,weekday:D.format("ddd")})},W)})]})},nt=(o,s,m)=>Rt({referenceDate:o,businessHours:s.businessHours,hideNonBusinessHours:s.hideNonBusinessHours,allDates:m,resourceBusinessHours:wt(s.resources??[])}),pa=(o,s,m)=>{let f=i(o,s.firstDayOfWeek);if(Vt(s)){let v=Ot(o,s),C=v.some((E)=>a(E));return Qe({resources:m,gutter:Fe({days:nt(o,s,f),gridType:"hour",showsToday:C}),columnsFor:(E)=>v.map((D)=>({id:n.col.day(D,E.id),className:Ne,day:D,days:nt(D,s,f),gridType:"hour"}))})}return Qe({resources:m,gutter:Fe({days:f,gridType:"day",renderLabel:(v)=>Te(b,{dayNumber:v.format("D"),today:a(v),weekday:v.format("ddd")})}),columnsFor:(v)=>({id:n.col.resource("week",v.id),className:Ne,day:void 0,days:f,gridType:"day"})})},ya=(o,s,m)=>{let f=i(o,s.firstDayOfWeek);if(Vt(s)){let v=f.map((C)=>nt(C,s));return Xe({resources:m,days:v,gridType:"hour",cellClassName:Ne})}return Xe({resources:m,days:f,gridType:"day",cellClassName:Ne})},fa=({date:o,config:s,resources:m})=>{let f=Ot(o,s),v=Vt(s),C=v?m.flatMap((E)=>f.map((D)=>({day:D,resourceId:E.id}))):[];return mt("div",{className:"flex-1 flex flex-col",children:[Te(an,{resources:m}),v&&Te(nn,{columns:C})]})},va=({date:o,config:s})=>{let m=i(o,s.firstDayOfWeek),f=Vt(s),v=f?m.flatMap((C)=>nt(C,s)):[];return mt(Ca,{children:[Te(rt,{}),mt("div",{className:"flex-1 flex flex-col",children:[Te(rn,{days:m}),f&&Te(jt,{hours:v,view:"week"})]})]})},ga=(o,s)=>{let m=s.resources??[];if(m.length){if(s.orientation==="vertical")return pa(o,s,m);return ya(o,s,m)}let f=i(o,s.firstDayOfWeek),v=Ot(o,s),C=v.some((E)=>a(E));return[Fe({days:nt(o,s,f),gridType:"hour",widthClassName:j,showsToday:C}),...v.map((E)=>({id:n.col.day(E),day:E,days:nt(E,s,f),className:"flex-1 min-w-0",gridType:"hour"}))]},sn={name:"week",label:"week",icon:ua,navigationUnit:"week",layout:"vertical",supportsResources:!0,range:(o,s)=>{let m=i(o,s.firstDayOfWeek),f=m.at(0)??o,v=m.at(-1)??o;return{start:f.startOf("day"),end:v.endOf("day")}},columns:ga,renderHeader:({date:o,config:s})=>{let m=s.resources??[];if(!m.length)return Te(ma,{config:s,date:o});if(s.orientation==="vertical")return Te(fa,{config:s,date:o,resources:m});return Te(va,{config:s,date:o,resources:m})}};import{Grid2x2 as ha}from"lucide-react";import{useMemo as Ea}from"react";import{jsx as Ke,jsxs as pt}from"react/jsx-runtime";var Da=["bg-primary","bg-blue-500","bg-green-500"],ba=42,ln=()=>{let{currentDate:o,setView:s,getEventsForDateRange:m,t:f,firstDayOfWeek:v}=r(),C=o.year(),E=i(t(),v).map((T)=>({id:T.day().toString(),label:T.format("dd")})),D=Ea(()=>{let T=c(t()),ve=c(o),pe=Array.from({length:12},(be,De)=>t().year(C).month(De).startOf("month")),Ce=pe.map((be)=>{let we=i(be,v).at(0)??be;return Array.from({length:ba},(ke,Se)=>we.add(Se,"day"))}),Ee=Ce.at(0)?.at(0),he=Ce.at(-1)?.at(-1),Re=[];if(Ee&&he)Re=m(Ee.startOf("day"),he.endOf("day"));return pe.map((be,De)=>{let ke=(Ce.at(De)??[]).map((xe)=>{let _e=xe.startOf("day"),Pe=xe.endOf("day"),Ie=c(xe),Le=Re.filter((Ze)=>d(Ze,_e,Pe));return{date:xe,dayKey:Ie,isInCurrentMonth:xe.month()===be.month(),isToday:Ie===T,isSelected:Ie===ve,eventCount:Le.length}}),Se=be.endOf("month"),He=Re.filter((xe)=>d(xe,be,Se));return{date:be,name:be.format("MMMM"),eventCount:He.length,monthKey:be.format("MM"),days:ke}})},[C,o,v,m]),G=(T,ve,pe)=>{pe?.stopPropagation(),s(ve,T)},h=(T)=>{let ve=T===1?f("event"):f("events");return`${T} ${ve}`},W=(T)=>{let pe=T.isInCurrentMonth?"":"text-muted-foreground opacity-50",Ce=T.isToday?"bg-primary text-primary-foreground rounded-full":"",Ee=T.isSelected&&!T.isToday?"bg-muted rounded-full font-bold":"",he=T.eventCount>0&&!T.isToday&&!T.isSelected?"font-medium":"";return e("relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center hover:bg-accent rounded-sm transition-colors duration-200",pe,Ce,Ee,he)},ye=(T,ve)=>e("h-[3px] w-[3px] rounded-full",ve?"bg-primary-foreground":T),ge=(T)=>{if(T===0)return"";return h(T)};return pt(u,{className:"h-full","data-testid":"year-view",children:[Ke("div",{className:"grid auto-rows-fr grid-cols-1 gap-4 p-4 sm:grid-cols-2 lg:grid-cols-3","data-testid":"year-grid",children:D.map((T)=>{let ve=T.days;return pt("div",{className:"hover:border-primary flex flex-col rounded-lg border p-3 text-left transition-all duration-200 hover:shadow-md","data-testid":n.header.year.month(T.monthKey),children:[pt(l,{className:"mb-2 flex items-center justify-between",transitionKey:n.listKey("month",T.monthKey),children:[Ke("button",{className:"text-lg font-medium hover:underline cursor-pointer","data-testid":n.header.year.month(T.monthKey,"title"),onClick:()=>G(T.date,"month"),type:"button",children:T.name}),T.eventCount>0&&Ke("span",{className:"bg-primary text-primary-foreground rounded-full px-2 py-1 text-xs","data-testid":n.header.year.month(T.monthKey,"count"),children:h(T.eventCount)})]},n.listKey("month",T.monthKey)),pt("div",{className:"grid grid-cols-7 gap-px text-[0.6rem]","data-testid":n.header.year.month(T.monthKey,"mini"),children:[E.map((pe)=>Ke("div",{className:"text-muted-foreground h-3 text-center",children:pe.label},n.listKey("header",T.monthKey,pe.id))),ve.map((pe)=>{let Ce=n.header.year.day(T.date.format("YYYY-MM"),pe.dayKey),Ee=pe.eventCount>0,he=Math.min(pe.eventCount,3),Re=Da.slice(0,he);return pt("button",{className:W(pe),"data-testid":Ce,onClick:(be)=>G(pe.date,"day",be),title:ge(pe.eventCount),type:"button",children:[Ke("span",{className:"text-center leading-none",children:pe.date.date()}),Ee&&Ke("div",{className:e("absolute bottom-0 flex w-full justify-center space-x-px",pe.isToday&&"bottom-px"),children:Re.map((be)=>Ke("span",{className:ye(be,pe.isToday)},be))})]},pe.dayKey)})]})]},T.monthKey)})}),Ke(y,{className:"z-30"})]})};var dn={name:"year",label:"year",icon:ha,navigationUnit:"year",supportsResources:!1,range:(o)=>({start:o.startOf("year"),end:o.endOf("year")}),component:ln};var cn=[Zr,sn,tn,dn];var un=(o,s,m)=>s?.range?.(o,{firstDayOfWeek:m})??bt(o,m),mn=({initialDate:o,initialView:s,firstDayOfWeek:m,onDateChange:f,onViewChange:v,pluginRuntime:C})=>{let[E,D]=xa(()=>({date:t(o),view:s})),G=Ra(E),h=je((De)=>{let we={...G.current,...De};return G.current=we,D(we),we},[]),W=je(()=>[...cn,...C.getViews()],[C]),ye=je((De)=>W().find((we)=>we.name===De),[W]),ge=je(()=>un(E.date,ye(E.view),m),[E,m,ye]),T=je((De)=>{let we=un(De.date,ye(De.view),m);f?.(De.date,we)},[f,m,ye]),ve=je((De)=>{T(h({date:De}))},[h,T]),pe=je((De)=>{let{date:we,view:ke}=G.current,Se=ye(ke),He=Se?.navigationStep??{amount:1,unit:Se?.navigationUnit??"day"},xe=we.add(De*He.amount,He.unit);T(h({date:xe}))},[h,T,ye]),Ce=je(()=>pe(1),[pe]),Ee=je(()=>pe(-1),[pe]),he=je(()=>T(h({date:t()})),[h,T]),Re=je((De,we)=>{let ke=h(we?{view:De,date:we}:{view:De});v?.(De),T(ke)},[h,v,T]),be=je((De)=>{let we=typeof De==="function"?De(G.current.date):De;h({date:we})},[h]);return wa(()=>({currentDate:E.date,setCurrentDate:be,view:E.view,setView:Re,selectDate:ve,nextPeriod:Ce,prevPeriod:Ee,today:he,getCurrentViewRange:ge,getAllViews:W}),[E,be,Re,ve,Ce,Ee,he,ge,W])};import{useCallback as Sa,useInsertionEffect as ka,useRef as Ha}from"react";var Ve=(o)=>{let s=Ha(o);ka(()=>{s.current=o});let m=Sa((...v)=>s.current?.(...v),[]);return o!==void 0?m:void 0};import{createElement as Na,Fragment as Ta}from"react";var pn=(o)=>({transformEvents:(s,m)=>o.reduce((v,C)=>C.transformEvents?C.transformEvents(v,m):v,s).filter((v)=>d(v,m.start,m.end)),getEventManager:(s)=>o.find((m)=>m.managesEvent?.(s)),collect:(s,m)=>o.flatMap((f)=>f.contribute?.(s,m)??[]),renderSlot:(s,m)=>{let f=[];for(let v of o){let C=v.renderSlot?.(s,m);if(C!==null&&C!==void 0)f.push(Na(Ta,{key:v.name},C))}return f},getViews:()=>o.flatMap((s)=>s.views??[]),getProviders:()=>o.map((s)=>s.provider).filter((s)=>Boolean(s))});var Ia=[],ja=[],Ma=(o,s)=>{if(!s)return V(o)??t();if(!o)return t().tz(s);if(le(o))return t.tz(o,s);return(V(o)??t()).tz(s)},Aa=(o)=>({onEventAdd:Ve(o.onEventAdd),onEventUpdate:Ve(o.onEventUpdate),onEventDelete:Ve(o.onEventDelete),onEventsChange:Ve(o.onEventsChange),onDateChange:Ve(o.onDateChange),onViewChange:Ve(o.onViewChange),onEventClick:Ve(o.onEventClick),onCellClick:Ve(o.onCellClick)}),gn=(o)=>{let{events:s,firstDayOfWeek:m=0,initialView:f="month",initialDate:v,dayMaxEvents:C,businessHours:E,locale:D,timezone:G,translations:h,translator:W,disableEventClick:ye,disableCellClick:ge,resources:T,orientation:ve,weekViewGranularity:pe}=o,{onEventAdd:Ce,onEventUpdate:Ee,onEventDelete:he,onEventsChange:Re,onDateChange:be,onViewChange:De,onEventClick:we,onCellClick:ke}=Aa(o),{plugins:Se=ja}=o,He=fr({firstDayOfWeek:m,dayMaxEvents:C,businessHours:E,locale:D,translations:h,translator:W,resources:T,orientation:ve,weekViewGranularity:pe}),xe=fn(()=>pn(Se),[Se]),[_e]=Pa(()=>Ma(v,G)),Pe=mn({initialDate:_e,initialView:f,firstDayOfWeek:m,onDateChange:be,onViewChange:De,pluginRuntime:xe}),Ie=pr({events:s,pluginRuntime:xe,getCurrentViewRange:Pe.getCurrentViewRange,resources:He.resources??Ia,onEventAdd:Ce,onEventUpdate:Ee,onEventDelete:he,onEventsChange:Re}),Le=vr({currentDate:Pe.currentDate,t:He.t,disableEventClick:ye,disableCellClick:ge,onEventClick:we,onCellClick:ke}),{setCurrentLocale:Ze}=He,{setCurrentDate:$e}=Pe,{setCurrentEvents:ot}=Ie,at=vn(void 0);yn(()=>{if(D&&D!==at.current)Ze(D),t.locale(D),$e((Be)=>Be.locale(D)),at.current=D},[D,Ze,$e]);let st=vn(void 0);return yn(()=>{if(G!==st.current){t.tz.setDefault(G);let Be=(Me)=>G?Me.tz(G):Me.local();$e((Me)=>Be(Me)),ot((Me)=>Me.map((Ye)=>({...Ye,start:Be(Ye.start),end:Be(Ye.end)}))),st.current=G}},[G,$e,ot]),fn(()=>{let{setCurrentLocale:Be,...Me}=He,{getCurrentViewRange:Ye,getAllViews:yt,...ft}=Pe,{setCurrentEvents:Bt,...Ft}=Ie;return{...Me,...ft,...Ft,...Le,getViews:yt,getEventManager:xe.getEventManager,renderSlot:xe.renderSlot,collect:xe.collect,getProviders:xe.getProviders,getEventResourceIds:lt,currentRange:Pe.getCurrentViewRange()}},[He,Pe,Ie,Le,xe])};import{jsx as Oa}from"react/jsx-runtime";var Cn=(o,s)=>o.reduceRight((m,f,v)=>Oa(f,{children:m},v),s);import{useMemo as Va}from"react";import{jsx as Ba}from"react/jsx-runtime";var En=({children:o})=>{let{currentDate:s,view:m,eventSpacing:f,businessHours:v,getResourceById:C,onCellClick:E,isCellDisabled:D,getCellClassName:G,disableDragAndDrop:h,disableCellClick:W,classesOverride:ye}=r(),ge=Va(()=>({currentDate:s,view:m,eventSpacing:f,businessHours:v,getResourceById:C,onCellClick:E,isCellDisabled:D,getCellClassName:G,disableDragAndDrop:h,disableCellClick:W,classesOverride:ye}),[s,m,f,v,C,E,D,G,h,W,ye]);return Ba(kt.Provider,{value:ge,children:o})};import{jsx as Dn}from"react/jsx-runtime";var za=[],_a=(o)=>{let{events:s=za,firstDayOfWeek:m=0,initialView:f="month",initialDate:v,renderEvent:C,onEventClick:E,onCellClick:D,isCellDisabled:G,getCellClassName:h,onViewChange:W,onEventAdd:ye,onEventUpdate:ge,onEventDelete:T,onEventsChange:ve,onDateChange:pe,locale:Ce,timezone:Ee,disableCellClick:he,disableEventClick:Re,disableDragAndDrop:be,dayMaxEvents:De,eventSpacing:we=Z,eventHeight:ke=Q,stickyViewHeader:Se=!0,viewHeaderClassName:He="",headerComponent:xe,headerClassName:_e,businessHours:Pe,renderEventForm:Ie,translations:Le,translator:Ze,timeFormat:$e="12-hour",classesOverride:ot,renderCurrentTimeIndicator:at,renderHour:st,hideNonBusinessHours:Be=!1,hideExportButton:Me=!1,hiddenDays:Ye,slotDuration:yt=60,scrollTime:ft,scrollToNow:Bt,plugins:Ft,resources:bn,renderResource:rr,orientation:hn,weekViewGranularity:wn}=o,nr=Ve(o.onMoreEventsClick),or=gn({events:s,firstDayOfWeek:m,initialView:f,initialDate:v,dayMaxEvents:De,businessHours:Pe,onEventAdd:ye,onEventUpdate:ge,onEventDelete:T,onEventsChange:ve,onDateChange:pe,onViewChange:W,locale:Ce,timezone:Ee,translations:Le,translator:Ze,plugins:Ft,onEventClick:E,onCellClick:D,disableEventClick:Re,disableCellClick:he,resources:bn,orientation:hn,weekViewGranularity:wn});return Fa(()=>{let{handleEventClick:Rn,handleDateClick:xn,...Sn}=or;return{...Sn,renderEvent:C,onEventClick:Rn,onCellClick:xn,isCellDisabled:G,getCellClassName:h,locale:Ce,timezone:Ee,disableCellClick:he,disableEventClick:Re,disableDragAndDrop:be,eventSpacing:we,eventHeight:ke,stickyViewHeader:Se,viewHeaderClassName:He,headerComponent:xe,headerClassName:_e,renderEventForm:Ie,onMoreEventsClick:nr,timeFormat:$e,classesOverride:ot,renderCurrentTimeIndicator:at,renderHour:st,hideNonBusinessHours:Be,hideExportButton:Me,hiddenDays:Ye,slotDuration:yt,scrollTime:ft,scrollToNow:Bt,renderResource:rr}},[or,C,rr,G,h,Ce,Ee,he,Re,be,we,ke,Se,He,xe,_e,Ie,nr,$e,ot,at,st,Be,Me,Ye,yt,ft,Bt])},_=({children:o,...s})=>{let m=_a(s),f=Cn(m.getProviders(),o);return Dn(vt.Provider,{value:m,children:Dn(En,{children:f})})};
2
+ export{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,_};
@@ -1,2 +1,2 @@
1
- import{e}from"./chunk-d7599sry.js";import{Slot as h}from"@radix-ui/react-slot";import{cva as P}from"class-variance-authority";import{jsx as k}from"react/jsx-runtime";var S=P("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function n({className:i,variant:r,size:s,asChild:l=!1,...d}){return k(l?h:"button",{className:e(S({variant:r,size:s,className:i})),"data-slot":"button",...d})}import*as c from"@radix-ui/react-checkbox";import{CheckIcon as w}from"lucide-react";import{jsx as u}from"react/jsx-runtime";function y({className:i,...r}){return u(c.Root,{className:e("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",i),"data-slot":"checkbox",...r,children:u(c.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:u(w,{className:"size-3.5"})})})}import{jsx as R}from"react/jsx-runtime";function m({className:i,type:r,...s}){return R("input",{className:e("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),"data-slot":"input",type:r,...s})}import*as b from"@radix-ui/react-label";import{jsx as z}from"react/jsx-runtime";function a({className:i,...r}){return z(b.Root,{className:e("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",i),"data-slot":"label",...r})}import*as t from"@radix-ui/react-select";import{CheckIcon as I,ChevronDownIcon as x,ChevronUpIcon as N}from"lucide-react";import{jsx as o,jsxs as f}from"react/jsx-runtime";function g({...i}){return o(t.Root,{"data-slot":"select",...i})}function v({...i}){return o(t.Value,{"data-slot":"select-value",...i})}function C({className:i,size:r="default",children:s,...l}){return f(t.Trigger,{className:e("cursor-pointer border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",i),"data-size":r,"data-slot":"select-trigger",...l,children:[s,o(t.Icon,{asChild:!0,children:o(x,{className:"size-4 opacity-50"})})]})}function D({className:i,children:r,position:s="popper",align:l="center",...d}){return o(t.Portal,{children:f(t.Content,{align:l,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 relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",i),"data-slot":"select-content",position:s,...d,children:[o(_,{}),o(t.Viewport,{className:e("p-1",s==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1"),children:r}),o(V,{})]})})}function p({className:i,children:r,...s}){return f(t.Item,{className:e("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",i),"data-slot":"select-item",...s,children:[o("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o(t.ItemIndicator,{children:o(I,{className:"size-4"})})}),o(t.ItemText,{children:r})]})}function _({className:i,...r}){return o(t.ScrollUpButton,{className:e("flex cursor-default items-center justify-center py-1",i),"data-slot":"select-scroll-up-button",...r,children:o(N,{className:"size-4"})})}function V({className:i,...r}){return o(t.ScrollDownButton,{className:e("flex cursor-default items-center justify-center py-1",i),"data-slot":"select-scroll-down-button",...r,children:o(x,{className:"size-4"})})}
2
- export{n,y,m,a,g,v,C,D,p};
1
+ import{e}from"./chunk-tfk3a0d4.js";import{Slot as x}from"@radix-ui/react-slot";import{cva as P}from"class-variance-authority";import{jsx as S}from"react/jsx-runtime";var y=P("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function o({className:i,variant:r,size:n,asChild:l=!1,...d}){return S(l?x:"button",{className:e(y({variant:r,size:n,className:i})),"data-slot":"button",...d})}import*as c from"@radix-ui/react-checkbox";import{CheckIcon as k}from"lucide-react";import{jsx as p}from"react/jsx-runtime";function v({className:i,...r}){return p(c.Root,{className:e("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",i),"data-slot":"checkbox",...r,children:p(c.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:p(k,{className:"size-3.5"})})})}import{jsx as w}from"react/jsx-runtime";function m({className:i,type:r,...n}){return w("input",{className:e("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),"data-slot":"input",type:r,...n})}import*as g from"@radix-ui/react-label";import{jsx as R}from"react/jsx-runtime";function s({className:i,...r}){return R(g.Root,{className:e("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",i),"data-slot":"label",...r})}import*as t from"@radix-ui/react-select";import{CheckIcon as z,ChevronDownIcon as b,ChevronUpIcon as I}from"lucide-react";import{jsx as a,jsxs as u}from"react/jsx-runtime";function C({...i}){return a(t.Root,{"data-slot":"select",...i})}function D({...i}){return a(t.Value,{"data-slot":"select-value",...i})}function E({className:i,size:r="default",children:n,...l}){return u(t.Trigger,{className:e("cursor-pointer border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",i),"data-size":r,"data-slot":"select-trigger",...l,children:[n,a(t.Icon,{asChild:!0,children:a(b,{className:"size-4 opacity-50"})})]})}function h({className:i,children:r,position:n="popper",align:l="center",...d}){return a(t.Portal,{children:u(t.Content,{align:l,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 relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",i),"data-slot":"select-content",position:n,...d,children:[a(N,{}),a(t.Viewport,{className:e("p-1",n==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1"),children:r}),a(_,{})]})})}function f({className:i,children:r,...n}){return u(t.Item,{className:e("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",i),"data-slot":"select-item",...n,children:[a("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:a(t.ItemIndicator,{children:a(z,{className:"size-4"})})}),a(t.ItemText,{children:r})]})}function N({className:i,...r}){return a(t.ScrollUpButton,{className:e("flex cursor-default items-center justify-center py-1",i),"data-slot":"select-scroll-up-button",...r,children:a(I,{className:"size-4"})})}function _({className:i,...r}){return a(t.ScrollDownButton,{className:e("flex cursor-default items-center justify-center py-1",i),"data-slot":"select-scroll-down-button",...r,children:a(b,{className:"size-4"})})}
2
+ export{o,v,m,s,C,D,E,h,f};
@@ -0,0 +1,2 @@
1
+ import{t}from"./chunk-cn24081x.js";function V(s){if(s===void 0)return;if(t.isDayjs(s))return s;let n=t(s);return n.isValid()?n:void 0}var c=(s)=>s.format("YYYY-MM-DD"),Y=(s,n)=>c(s)===c(n);function d(s,n,r){let o=s.start.isSameOrAfter(n)&&s.start.isSameOrBefore(r),a=s.end.isAfter(n)&&s.end.isSameOrBefore(r),f=s.start.isBefore(n)&&s.end.isAfter(r);return o||a||f}var u=(s)=>{let n=s.utcOffset();return s.utc().add(n,"minute")},N=(s,n,r)=>{let o=u(s),a=u(n);return o.diff(a,r,!0)},T=(...s)=>s.join("-");function pe(s){let n=s.replace("#",""),r=n.length===3?n.split("").map((i)=>i+i).join(""):n;if(!/^[0-9a-fA-F]{6}$/.test(r))return"#000000";let o=Number.parseInt(r.slice(0,2),16),a=Number.parseInt(r.slice(2,4),16),f=Number.parseInt(r.slice(4,6),16);return(o*299+a*587+f*114)/1000>=128?"#000000":"#ffffff"}import{clsx as l}from"clsx";import{twMerge as y}from"tailwind-merge";function e(...s){return y(l(s))}
2
+ export{e,V,c,Y,d,N,T,pe};
@@ -0,0 +1,2 @@
1
+ import{e}from"./chunk-tfk3a0d4.js";import*as c from"@radix-ui/react-scroll-area";import{jsx as x,jsxs as z}from"react/jsx-runtime";function u({className:t,children:r,viewPortProps:i,...n}){return z(c.Root,{className:e("relative",t),"data-slot":"scroll-area",...n,children:[x(c.Viewport,{...i,className:e("focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",i?.className),"data-slot":"scroll-area-viewport",children:r}),x(y,{}),x(c.Corner,{})]})}function y({className:t,orientation:r="vertical",...i}){return x(c.ScrollAreaScrollbar,{className:e("flex touch-none p-px transition-colors select-none",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",t),"data-slot":"scroll-area-scrollbar",orientation:r,...i,children:x(c.ScrollAreaThumb,{className:"bg-border relative flex-1 rounded-full","data-slot":"scroll-area-thumb"})})}import{jsx as N,jsxs as j}from"react/jsx-runtime";var b=({today:t,dayNumber:r,weekday:i,className:n,"data-testid":o})=>j("div",{className:e("flex flex-col items-center",n),"data-testid":o,"data-today":t?"true":void 0,children:[i!=null&&N("div",{className:e("w-full truncate text-center text-xs text-muted-foreground",t&&"text-primary"),children:i}),N("div",{className:e("flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs font-medium",t&&"bg-primary text-primary-foreground"),children:r})]});import l from"dayjs";import w from"dayjs/plugin/isSameOrAfter.js";import C from"dayjs/plugin/isSameOrBefore.js";import T from"dayjs/plugin/localeData.js";import I from"dayjs/plugin/localizedFormat.js";import Y from"dayjs/plugin/minMax.js";import k from"dayjs/plugin/timezone.js";import M from"dayjs/plugin/utc.js";import B from"dayjs/plugin/weekday.js";import V from"dayjs/plugin/weekOfYear.js";var h,F=(t,r,i)=>{let n=r.prototype,o=i.tz.setDefault;i.tz.setDefault=(s)=>(h=s,o(s));let{startOf:a,endOf:d}=n;function f(s,m){let p=s.$x?.$timezone||h;if(!p)return m;let v=i.tz(m.format("YYYY-MM-DDTHH:mm:ss"),p).utcOffset();if(m.utcOffset()!==v)return m.tz(p,!0);return m}n.startOf=function(s,m){let p=a.call(this,s,m);return f(this,p)},n.endOf=d},L=(t,r)=>{let i=r.prototype,n={isBefore:(o,a)=>o<a,isAfter:(o,a)=>o>a,isSame:(o,a)=>o===a,isSameOrBefore:(o,a)=>o<=a,isSameOrAfter:(o,a)=>o>=a};for(let[o,a]of Object.entries(n)){let d=i[o];i[o]=function(f,s){if(s===void 0&&l.isDayjs(f))return a(this.valueOf(),f.valueOf());return d.call(this,f,s)}}};l.extend(B);l.extend(V);l.extend(w);l.extend(C);l.extend(Y);l.extend(k);l.extend(M);l.extend(T);l.extend(I);l.extend(F);l.extend(L);var W=/(?:Z|[+-]\d{2}:?\d{2})$/i,H=(t)=>{let r=t.split(/[Tt\s]/).at(1);if(!r)return!1;return W.test(r)},g=(t)=>typeof t==="string"&&!H(t),P=(t)=>{let r=l(t);if(!r.isValid())return r;if(g(t))return l.tz(t);if(!h)return r;return r.tz(h)};Object.assign(P,l);var A=P;var O=(t)=>{let r=t.utcOffset();return t.utc().add(r,"minute")},D=(t,r,i)=>{let n=O(t),o=O(r);return n.diff(o,i,!0)};import{memo as K}from"react";import{jsx as S,jsxs as R,Fragment as q}from"react/jsx-runtime";var Z=({rangeStart:t,rangeEnd:r,now:i,axis:n="vertical",render:o,withDot:a=!0})=>{let d=i??A(),f=d.valueOf();if(!(f>=t.valueOf()&&f<r.valueOf()))return null;let m=D(r,t,"minute"),v=D(d,t,"minute")/m*100;if(o)return S(q,{children:o({currentTime:d,rangeStart:t,rangeEnd:r,progress:v,axis:n})});if(n==="horizontal")return R("div",{className:"absolute top-0 bottom-0 z-50 flex -translate-x-1/2 flex-col items-center pointer-events-none","data-testid":"current-time-indicator",style:{left:`${v}%`},children:[a&&S("div",{className:"size-2 shrink-0 rounded-full bg-red-500","data-testid":"current-time-dot"}),S("div",{className:"w-0.5 flex-1 bg-red-500"})]});return R("div",{className:"absolute right-0 left-0 z-50 flex -translate-y-1/2 items-center pointer-events-none","data-testid":"current-time-indicator",style:{top:`${v}%`},children:[a&&S("div",{className:"size-2 shrink-0 rounded-full bg-red-500","data-testid":"current-time-dot"}),S("div",{className:"h-0.5 flex-1 bg-red-500"})]})},U=K(Z);
2
+ export{u,y,b,U};
@@ -1,5 +1,5 @@
1
1
  import { ReactNode as ReactNode4 } from "react";
2
- import { ComponentType, ReactNode as ReactNode2 } from "react";
2
+ import { ComponentType, ReactNode } from "react";
3
3
  import { Dayjs as Dayjs2, ManipulateType as ManipulateType2 } from "dayjs";
4
4
  /**
5
5
  * Core calendar event interface representing a single calendar event.
@@ -130,6 +130,32 @@ interface PluginMutationResult {
130
130
  deleted: CalendarEvent[];
131
131
  }
132
132
  /**
133
+ * One user action and every stored row it touched, reported once through
134
+ * `onEventsChange` (#309). A recurring edit touches several rows (the series,
135
+ * an override, deleted overrides) that the per-row callbacks report one by
136
+ * one; this reports them together so they can be saved, or refused, as a unit.
137
+ * FullCalendar reports an action once the same way (`eventChange` with
138
+ * `relatedEvents`).
139
+ */
140
+ interface EventsChange {
141
+ /** What the user did. */
142
+ action: "add" | "update" | "delete";
143
+ /** The event the user acted on, as it was shown (an occurrence, for a series). */
144
+ event: CalendarEvent;
145
+ /**
146
+ * The scope chosen in the plugin's scope dialog, when a plugin manages the
147
+ * event; otherwise undefined. The recurrence plugin passes its
148
+ * `RecurrenceEditScope` (`'this' | 'following' | 'all'`).
149
+ */
150
+ scope?: unknown;
151
+ /** New rows, the same ones passed to `onEventAdd`. */
152
+ added: CalendarEvent[];
153
+ /** Changed rows, the same ones passed to `onEventUpdate`. */
154
+ updated: CalendarEvent[];
155
+ /** Removed rows, the same ones passed to `onEventDelete`. */
156
+ deleted: CalendarEvent[];
157
+ }
158
+ /**
133
159
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
134
160
  * Carries the resource axis (`resources`, `orientation`) so a resource-capable
135
161
  * view can compose both arrangements. `range()` receives only the
@@ -168,7 +194,7 @@ interface VerticalColumnSpec {
168
194
  className?: string;
169
195
  /** Label-only column (e.g. the time gutter): renders no events. */
170
196
  noEvents?: boolean;
171
- renderCell?: (date: Dayjs2) => ReactNode2;
197
+ renderCell?: (date: Dayjs2) => ReactNode;
172
198
  /**
173
199
  * Resource-axis identity when the column belongs to one resource. The
174
200
  * single carrier: consumers derive the id from `resource.id`.
@@ -269,7 +295,7 @@ interface PluginView {
269
295
  */
270
296
  layout?: "vertical" | "horizontal";
271
297
  /** Header row content rendered above the grid by the shared renderer. */
272
- renderHeader?: (ctx: ViewHeaderContext) => ReactNode2;
298
+ renderHeader?: (ctx: ViewHeaderContext) => ReactNode;
273
299
  /**
274
300
  * Whether `columns()` composes the resource axis when `config.resources`
275
301
  * is set. Defaults to false; the view switcher hides resource-incapable
@@ -305,7 +331,7 @@ interface IlamyPlugin {
305
331
  managesEvent?: (event: CalendarEvent) => boolean;
306
332
  applyEdit?: (args: PluginMutationArgs) => CalendarEvent[] | PluginMutationResult;
307
333
  applyDelete?: (args: PluginMutationArgs) => CalendarEvent[] | PluginMutationResult;
308
- renderSlot?: (slotName: string, context: unknown) => ReactNode2;
334
+ renderSlot?: (slotName: string, context: unknown) => ReactNode;
309
335
  /**
310
336
  * Contributes arbitrary data to a named point. Additive: all plugins may
311
337
  * contribute to the same point; the runtime aggregates all results via
@@ -323,21 +349,12 @@ interface IlamyPlugin {
323
349
  * among all plugin providers.
324
350
  */
325
351
  provider?: ComponentType<{
326
- children: ReactNode2;
352
+ children: ReactNode;
327
353
  }>;
328
354
  }
329
- import dayjs from "dayjs";
330
- type Dayjs3 = dayjs.Dayjs3;
331
- import React3 from "react";
355
+ import { Dayjs as DayjsInstance } from "dayjs";
356
+ type Dayjs3 = DayjsInstance;
332
357
  import { ReactNode as ReactNode3 } from "react";
333
- interface EventFormProps {
334
- open?: boolean;
335
- selectedEvent?: CalendarEvent | null;
336
- onAdd?: (event: CalendarEvent) => void;
337
- onUpdate?: (event: CalendarEvent) => void;
338
- onDelete?: (event: CalendarEvent) => void;
339
- onClose: () => void;
340
- }
341
358
  declare const defaultTranslations: {
342
359
  today: string;
343
360
  create: string;
@@ -429,6 +446,14 @@ declare const defaultTranslations: {
429
446
  type Translations = Record<keyof typeof defaultTranslations, string>;
430
447
  type TranslationKey = keyof Translations;
431
448
  type TranslatorFunction = (key: TranslationKey | string) => string;
449
+ interface EventFormProps {
450
+ open?: boolean;
451
+ selectedEvent?: CalendarEvent | null;
452
+ onAdd?: (event: CalendarEvent) => void;
453
+ onUpdate?: (event: CalendarEvent) => void;
454
+ onDelete?: (event: CalendarEvent) => void;
455
+ onClose: () => void;
456
+ }
432
457
  /**
433
458
  * Available calendar view types. The built-in views (day, week, month, year)
434
459
  * are `PluginView` specs in `features/calendar/components/views`; plugins may
@@ -545,6 +570,7 @@ interface CalendarProviderProps {
545
570
  onEventAdd?: (event: CalendarEvent) => void;
546
571
  onEventUpdate?: (event: CalendarEvent) => void;
547
572
  onEventDelete?: (event: CalendarEvent) => void;
573
+ onEventsChange?: (change: EventsChange) => void;
548
574
  onDateChange?: (date: Dayjs3, range: DateRange) => void;
549
575
  locale?: string;
550
576
  timezone?: string;
@@ -573,11 +599,12 @@ interface CalendarProviderProps {
573
599
  hiddenDays?: Set<number>;
574
600
  slotDuration?: SlotDuration;
575
601
  scrollTime?: string;
602
+ scrollToNow?: boolean;
576
603
  plugins?: IlamyPlugin[];
577
604
  /** The resource axis. Absent/empty → a regular calendar (no filtering, no resource columns). */
578
605
  resources?: Resource[];
579
606
  /** Custom render for resource header cells. */
580
- renderResource?: (resource: Resource) => React3.ReactNode3;
607
+ renderResource?: (resource: Resource) => ReactNode3;
581
608
  /** Resource arrangement preference. Only applies when `resources` is set. @default 'horizontal' */
582
609
  orientation?: "horizontal" | "vertical";
583
610
  /** Week-view granularity for resource weeks. @default 'hourly' */
@@ -1 +1 @@
1
- import"../shared/chunk-4jynmg6d.js";import{M}from"../shared/chunk-79d4xe20.js";import"../shared/chunk-d7599sry.js";import"../shared/chunk-w4nsrq2y.js";import"../shared/chunk-n7xt0j3a.js";import{jsx as a}from"react/jsx-runtime";var d=({children:r,...e})=>a(M,{dayMaxEvents:5,...e,children:r});export{d as CalendarTestProvider};
1
+ import"../shared/chunk-cn24081x.js";import{_}from"../shared/chunk-mn44xvnt.js";import"../shared/chunk-tfk3a0d4.js";import"../shared/chunk-1x8xjsbq.js";import"../shared/chunk-xf8cy2gp.js";import{jsx as a}from"react/jsx-runtime";var d=({children:r,...e})=>a(_,{dayMaxEvents:5,...e,children:r});export{d as CalendarTestProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilamy/calendar",
3
- "version": "3.0.1",
3
+ "version": "3.2.0",
4
4
  "description": "A full-featured React calendar component library built with Shadcn-Ui, Tailwind CSS, and TypeScript.",
5
5
  "author": "Sujeet Kc",
6
6
  "license": "MIT",
@@ -62,6 +62,7 @@
62
62
  "test": "bun test",
63
63
  "test:coverage": "bun test --coverage",
64
64
  "type-check": "bunx tsc --noEmit",
65
+ "check:dist-types": "bunx tsc -p tsconfig.dist.json",
65
66
  "lint": "bunx biome lint . --diagnostic-level=error",
66
67
  "check": "bunx biome check . --diagnostic-level=error",
67
68
  "check:fix": "bunx biome check --write .",
@@ -1,2 +0,0 @@
1
- import e from"dayjs";import l from"dayjs/plugin/isSameOrAfter.js";import O from"dayjs/plugin/isSameOrBefore.js";import D from"dayjs/plugin/localeData.js";import g from"dayjs/plugin/localizedFormat.js";import x from"dayjs/plugin/minMax.js";import T from"dayjs/plugin/timezone.js";import b from"dayjs/plugin/utc.js";import z from"dayjs/plugin/weekday.js";import S from"dayjs/plugin/weekOfYear.js";var d,C=(a,o,f)=>{let y=o.prototype,n=f.tz.setDefault;f.tz.setDefault=(r)=>(d=r,n(r));let{startOf:s,endOf:u}=y;function p(r,i){let m=r.$x?.$timezone||d;if(!m)return i;let j=f.tz(i.format("YYYY-MM-DDTHH:mm:ss"),m).utcOffset();if(i.utcOffset()!==j)return i.tz(m,!0);return i}y.startOf=function(r,i){let m=s.call(this,r,i);return p(this,m)},y.endOf=u},h=(a,o)=>{let f=o.prototype,y={isBefore:(n,s)=>n<s,isAfter:(n,s)=>n>s,isSame:(n,s)=>n===s,isSameOrBefore:(n,s)=>n<=s,isSameOrAfter:(n,s)=>n>=s};for(let[n,s]of Object.entries(y)){let u=f[n];f[n]=function(p,r){if(r===void 0&&e.isDayjs(p))return s(this.valueOf(),p.valueOf());return u.call(this,p,r)}}};e.extend(z);e.extend(S);e.extend(l);e.extend(O);e.extend(x);e.extend(T);e.extend(b);e.extend(D);e.extend(g);e.extend(C);e.extend(h);var k=/(?:Z|[+-]\d{2}:?\d{2})$/i,I=(a)=>{let o=a.split(/[Tt\s]/).at(1);if(!o)return!1;return k.test(o)},K=(a)=>typeof a==="string"&&!I(a),c=(a)=>{let o=e(a);if(!o.isValid())return o;if(K(a))return e.tz(a);if(!d)return o;return o.tz(d)};Object.assign(c,e);var t=c;
2
- export{K,t};