@dayflow/core 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import e,{useMemo as t,useState as n,useCallback as a,useEffect as r,useRef as o,useContext as l,createContext as i,useLayoutEffect as s}from"react";import{Temporal as d}from"temporal-polyfill";import{__awaiter as c}from"tslib";import{jsx as u,jsxs as g,Fragment as h}from"react/jsx-runtime";import m,{createPortal as v}from"react-dom";import{SketchPicker as f,PhotoshopPicker as y}from"react-color";import{PanelRightClose as p,PanelRightOpen as b,ChevronLeft as D,ChevronRight as x,ChevronsUpDown as w,Check as C,ChevronsLeft as E,ChevronsRight as k,MoveRight as N,ChevronDown as T,Plus as S,Search as M,Loader2 as I,ArrowLeft as H,X as R,CalendarDays as O,Calendar as P,Gift as L,Heart as j,Star as A,MapPin as $}from"lucide-react";import{createRoot as z}from"react-dom/client";var Y;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(Y||(Y={}));const F=100,V=8,W=150,B=80,Z=90,U=119;class _{constructor(e=F){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const q=[{id:"blue",name:"Blue",isDefault:!0,colors:{eventColor:"#eff6ff",eventSelectedColor:"rgba(59, 130, 246)",lineColor:"#3b82f6",textColor:"#1e3a8a"},darkColors:{eventColor:"rgba(30, 64, 175, 0.8)",eventSelectedColor:"rgba(30, 58, 138, 1)",lineColor:"#3b82f6",textColor:"#dbeafe"}},{id:"green",name:"Green",isDefault:!0,colors:{eventColor:"#f0fdf4",eventSelectedColor:"rgba(16, 185, 129, 1)",lineColor:"#10b981",textColor:"#064e3b"},darkColors:{eventColor:"rgba(4, 120, 87, 0.8)",eventSelectedColor:"rgba(6, 78, 59, 1)",lineColor:"#10b981",textColor:"#d1fae5"}},{id:"purple",name:"Purple",isDefault:!0,colors:{eventColor:"#faf5ff",eventSelectedColor:"rgba(139, 92, 246, 1)",lineColor:"#8b5cf6",textColor:"#5b21b6"},darkColors:{eventColor:"rgba(109, 40, 217, 0.8)",eventSelectedColor:"rgba(91, 33, 182, 1)",lineColor:"#8b5cf6",textColor:"#ede9fe"}},{id:"yellow",name:"Yellow",isDefault:!0,colors:{eventColor:"#fefce8",eventSelectedColor:"rgba(245, 158, 11, 1)",lineColor:"#f59e0b",textColor:"#78350f"},darkColors:{eventColor:"rgba(180, 83, 9, 0.8)",eventSelectedColor:"rgba(120, 53, 15, 1)",lineColor:"#f59e0b",textColor:"#fef3c7"}},{id:"red",name:"Red",isDefault:!0,colors:{eventColor:"#fef2f2",eventSelectedColor:"rgba(239, 68, 68, 1)",lineColor:"#ef4444",textColor:"#7f1d1d"},darkColors:{eventColor:"rgba(185, 28, 28, 0.8)",eventSelectedColor:"rgba(127, 29, 29, 1)",lineColor:"#ef4444",textColor:"#fee2e2"}},{id:"orange",name:"Orange",isDefault:!0,colors:{eventColor:"#fff7edb3",eventSelectedColor:"rgba(249, 115, 22, 1)",lineColor:"#f97316",textColor:"#7c2d12"},darkColors:{eventColor:"rgba(194, 65, 12, 0.8)",eventSelectedColor:"rgba(124, 45, 18, 1)",lineColor:"#f97316",textColor:"#fed7aa"}},{id:"pink",name:"Pink",isDefault:!0,colors:{eventColor:"#fdf2f8",eventSelectedColor:"rgba(236, 72, 153, 1)",lineColor:"#ec4899",textColor:"#831843"},darkColors:{eventColor:"rgba(190, 24, 93, 0.8)",eventSelectedColor:"rgba(131, 24, 67, 1)",lineColor:"#ec4899",textColor:"#fce7f3"}},{id:"teal",name:"Teal",isDefault:!0,colors:{eventColor:"#f0fdfa",eventSelectedColor:"rgba(20, 184, 166, 1)",lineColor:"#14b8a6",textColor:"#134e4a"},darkColors:{eventColor:"rgba(15, 118, 110, 0.8)",eventSelectedColor:"rgba(19, 78, 74, 1)",lineColor:"#14b8a6",textColor:"#ccfbf1"}},{id:"indigo",name:"Indigo",isDefault:!0,colors:{eventColor:"#eef2ffb3",eventSelectedColor:"rgba(99, 102, 241, 1)",lineColor:"#6366f1",textColor:"#312e81"},darkColors:{eventColor:"rgba(67, 56, 202, 0.8)",eventSelectedColor:"rgba(49, 46, 129, 1)",lineColor:"#6366f1",textColor:"#e0e7ff"}},{id:"gray",name:"Gray",isDefault:!0,colors:{eventColor:"#f9fafbb3",eventSelectedColor:"rgba(107, 114, 128, 1)",lineColor:"#6b7280",textColor:"#1f2937"},darkColors:{eventColor:"rgba(75, 85, 99, 0.8)",eventSelectedColor:"rgba(31, 41, 55, 1)",lineColor:"#6b7280",textColor:"#f3f4f6"}}];class X{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const a=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):q.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!a&&e.isVisible}))})}register(e){this.calendars.set(e.id,e)}unregister(e){return this.calendars.delete(e)}get(e){return this.calendars.get(e)}getAll(){return Array.from(this.calendars.values())}getVisible(){return this.getAll().filter(e=>!1!==e.isVisible)}has(e){return this.calendars.has(e)}reorder(e,t){const n=Array.from(this.calendars.entries());if(e<0||e>=n.length||t<0||t>=n.length)return;const[a]=n.splice(e,1);n.splice(t,0,a),this.calendars.clear(),n.forEach(([e,t])=>{this.calendars.set(e,t)})}setVisibility(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),{isVisible:t}))}setAllVisibility(e){this.calendars.forEach((t,n)=>{this.calendars.set(n,Object.assign(Object.assign({},t),{isVisible:e}))})}updateCalendar(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),t))}setDefaultCalendar(e){if(!this.has(e))throw new Error(`Calendar type '${e}' does not exist`);this.defaultCalendarId=e}getDefaultCalendarId(){return this.defaultCalendarId}getDefaultCalendar(){const e=this.get(this.defaultCalendarId);return e||this.getAll()[0]}setTheme(e){this.currentTheme=e}getTheme(){return this.currentTheme}resolveColors(e,t){const n=t||this.currentTheme,a=this.isDarkTheme(n);let r;return e&&(r=this.get(e)),r||(r=this.getDefaultCalendar()),a&&r.darkColors?r.darkColors:r.colors}getSelectedBgColor(e,t){return this.resolveColors(e,t).eventSelectedColor}getLineColor(e,t){return this.resolveColors(e,t).lineColor}getTextColor(e,t){return this.resolveColors(e,t).textColor}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let G=new X;function K(){return G}function J(e){const t=q.find(t=>t.colors.lineColor.toLowerCase()===e.toLowerCase());return t?{colors:t.colors,darkColors:t.darkColors}:{colors:{eventColor:e+"1A",eventSelectedColor:e,lineColor:e,textColor:e},darkColors:{eventColor:e+"CC",eventSelectedColor:e,lineColor:e,textColor:"#ffffff"}}}const Q=new class{constructor(){this.isDevelopment="production"!==process.env.NODE_ENV}formatMessage(e,t,...n){if(!this.isDevelopment)return;const a=(new Date).toISOString(),r=`[DayFlow ${e.toUpperCase()}] ${a}:`;switch(e){case"log":console.log(r,t,...n);break;case"warn":console.warn(r,t,...n);break;case"error":console.error(r,t,...n);break;case"debug":console.debug(r,t,...n)}}log(e,...t){this.formatMessage("log",e,...t)}warn(e,...t){this.formatMessage("warn",e,...t)}error(e,...t){this.formatMessage("error",e,...t)}debug(e,...t){this.formatMessage("debug",e,...t)}};function ee(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const te={code:"en-US",messages:{allDay:"All day",noEvents:"No events for this day",more:"more",eventTitle:"Event Title",dateRange:"Date Range",timeRange:"Time Range",note:"Note",addNotePlaceholder:"Add a note...",setAsAllDay:"Set as All-day",setAsTimed:"Set as Timed Event",delete:"Delete",confirm:"Confirm",cancel:"Cancel",today:"Today",day:"Day",week:"Week",month:"Month",year:"Year",newEvent:"New Event",newAllDayEvent:"New All-day Event",newCalendarEvent:"New {calendarName} Event",newAllDayCalendarEvent:"New {calendarName} All-day Event",save:"Save",deleteCalendar:'Delete "{calendarName}"?',deleteCalendarMessage:'Do you want to delete "{calendarName}" or merge its events into another existing calendar?',merge:"Merge",confirmDeleteTitle:'Are you sure you want to delete the calendar "{calendarName}"?',confirmDeleteMessage:"If you delete this calendar, all events associated with the calendar will also be deleted.",mergeConfirmTitle:'Merge "{sourceName}" with "{targetName}"?',mergeConfirmMessage:'Are you sure you want to merge "{sourceName}" with "{targetName}"? Doing so will move all the events from "{sourceName}" to "{targetName}" and "{sourceName}" will be deleted. This cannot be undone.',expandSidebar:"Expand calendar sidebar",collapseSidebar:"Collapse calendar sidebar",calendars:"Calendars",createCalendar:"Create New Calendar",calendarNamePlaceholder:"e.g. Work",customColor:"Custom Color...",create:"Create",calendarOptions:"Calendar Options",untitled:"Untitled",search:"Search",noResults:"No results found",calendar:"Calendar",starts:"Starts",ends:"Ends",notes:"Notes",titlePlaceholder:"Title",notesPlaceholder:"Notes",editEvent:"Edit Event",done:"Done",quickCreateEvent:"Quick Create Event",quickCreatePlaceholder:"Movie at 7pm on Friday",noSuggestions:"Type to create",newCalendar:"New Calendar",refreshAll:"Refresh All",tomorrow:"Tomorrow"}},ne={code:"zh-CN",messages:{allDay:"全天",noEvents:"今日无日程",more:"个",eventTitle:"事件标题",dateRange:"日期范围",timeRange:"时间范围",note:"备注",addNotePlaceholder:"添加备注...",setAsAllDay:"设为全天",setAsTimed:"设为普通事件",delete:"删除",confirm:"确认",cancel:"取消",today:"今天",day:"日",week:"周",month:"月",year:"年",newEvent:"新建日程",newAllDayEvent:"新建全天日程",newCalendarEvent:"新建 {calendarName} 日程",newAllDayCalendarEvent:"新建 {calendarName} 全天日程",save:"保存",deleteCalendar:'删除日历 "{calendarName}"?',deleteCalendarMessage:'您想删除日历 "{calendarName}" 还是将其事件合并到另一个现有日历中?',merge:"合并",confirmDeleteTitle:'您确定要删除日历 "{calendarName}" 吗?',confirmDeleteMessage:"如果您删除此日历,与其关联的所有事件也将被删除。",mergeConfirmTitle:'将 "{sourceName}" 合并到 "{targetName}"?',mergeConfirmMessage:'您确定要将 "{sourceName}" 合并到 "{targetName}" 吗?这样做会将 "{sourceName}" 中的所有事件移动到 "{targetName}",并且 "{sourceName}" 将被删除。此操作无法撤销。',expandSidebar:"展开日历侧边栏",collapseSidebar:"收起日历侧边栏",calendars:"日历",createCalendar:"创建新日历",calendarNamePlaceholder:"例如:工作",customColor:"自定义颜色...",create:"创建",calendarOptions:"日历选项",untitled:"未命名",search:"搜索",noResults:"无结果",calendar:"日历",starts:"开始",ends:"结束",notes:"备注",titlePlaceholder:"标题",notesPlaceholder:"备注",editEvent:"编辑日程",done:"完成",quickCreateEvent:"快速创建日程",quickCreatePlaceholder:"周五晚7点看电影",noSuggestions:"输入内容以创建",newCalendar:"新增日历",refreshAll:"全部刷新",tomorrow:"明天"}},ae={code:"ja-JP",messages:{allDay:"終日",noEvents:"本日は予定がありません",more:"件",eventTitle:"予定名",dateRange:"日付範囲",timeRange:"時間範囲",note:"メモ",addNotePlaceholder:"メモを追加...",setAsAllDay:"終日予定に設定",setAsTimed:"時間指定の予定に設定",delete:"削除",confirm:"確認",cancel:"キャンセル",today:"今日",day:"日",week:"週",month:"月",year:"年",newEvent:"新規予定",newAllDayEvent:"新規終日予定",newCalendarEvent:"新規 {calendarName} 予定",newAllDayCalendarEvent:"新規 {calendarName} 終日予定",save:"保存",deleteCalendar:'カレンダー "{calendarName}" を削除しますか?',deleteCalendarMessage:'カレンダー "{calendarName}" を削除しますか?それともイベントを別の既存のカレンダーにマージしますか?',merge:"マージ",confirmDeleteTitle:'カレンダー "{calendarName}" を削除してもよろしいですか?',confirmDeleteMessage:"このカレンダーを削除すると、関連するすべてのイベントも削除されます。",mergeConfirmTitle:'"{sourceName}" を "{targetName}" にマージしますか?',mergeConfirmMessage:'"{sourceName}" を "{targetName}" にマージしてもよろしいですか?これにより、"{sourceName}" のすべてのイベントが "{targetName}" に移動し、"{sourceName}" は削除されます。この操作は元に戻せません。',expandSidebar:"カレンダーサイドバーを展開",collapseSidebar:"カレンダーサイドバーを折りたたむ",calendars:"カレンダー",createCalendar:"新しいカレンダーを作成",calendarNamePlaceholder:"例:仕事",customColor:"カスタムカラー...",create:"作成",calendarOptions:"カレンダーオプション",untitled:"無題",search:"検索",noResults:"結果が見つかりません",calendar:"カレンダー",starts:"開始",ends:"終了",notes:"メモ",titlePlaceholder:"予定名",notesPlaceholder:"メモ",editEvent:"予定を編集",done:"完了",quickCreateEvent:"クイック作成",quickCreatePlaceholder:"金曜日7時から映画",noSuggestions:"入力して作成",newCalendar:"新しいカレンダー",refreshAll:"すべて更新",tomorrow:"明日"}},re={code:"ko-KR",messages:{allDay:"종일",noEvents:"오늘 일정이 없습니다",more:"개",eventTitle:"일정 제목",dateRange:"날짜 범위",timeRange:"시간 범위",note:"메모",addNotePlaceholder:"메모 추가...",setAsAllDay:"종일 일정으로 설정",setAsTimed:"시간 지정 일정으로 설정",delete:"삭제",confirm:"확인",cancel:"취소",today:"오늘",day:"일",week:"주",month:"월",year:"년",newEvent:"새 일정",newAllDayEvent:"새 종일 일정",newCalendarEvent:"{calendarName}의 새 일정",newAllDayCalendarEvent:"{calendarName}의 새 종일 일정",save:"저장",deleteCalendar:'"{calendarName}" 삭제?',deleteCalendarMessage:'"{calendarName}"을(를) 삭제하시겠습니까, 아니면 이벤트를 다른 기존 캘린더로 병합하시겠습니까?',merge:"병합",confirmDeleteTitle:'"{calendarName}" 캘린더를 삭제하시겠습니까?',confirmDeleteMessage:"이 캘린더를 삭제하면 연결된 모든 이벤트도 삭제됩니다.",mergeConfirmTitle:'"{sourceName}"을(를) "{targetName}"(으)로 병합?',mergeConfirmMessage:'"{sourceName}"을(를) "{targetName}"(으)로 병합하시겠습니까? 이렇게 하면 "{sourceName}"의 모든 이벤트가 "{targetName}"(으)로 이동하고 "{sourceName}"은(는) 삭제됩니다. 이 작업은 취소할 수 없습니다.',expandSidebar:"캘린더 사이드바 펼치기",collapseSidebar:"캘린더 사이드바 접기",calendars:"캘린더",createCalendar:"새 캘린더 만들기",calendarNamePlaceholder:"예: 업무",customColor:"사용자 지정 색상...",create:"만들기",calendarOptions:"캘린더 옵션",untitled:"무제",search:"검색",noResults:"결과 없음",calendar:"캘린더",starts:"시작",ends:"종료",notes:"메모",titlePlaceholder:"제목",notesPlaceholder:"메모",editEvent:"일정 편집",done:"완료",quickCreateEvent:"빠른 일정 생성",quickCreatePlaceholder:"금요일 오후 7시에 영화",noSuggestions:"입력하여 만들기",newCalendar:"새 캘린더",refreshAll:"모두 새로 고침",tomorrow:"내일"}},oe={code:"fr-FR",messages:{allDay:"Toute la journée",noEvents:"Aucun événement aujourd'hui",more:"de plus",eventTitle:"Titre de l'événement",dateRange:"Plage de dates",timeRange:"Plage horaire",note:"Note",addNotePlaceholder:"Ajouter une note...",setAsAllDay:"Définir comme toute la journée",setAsTimed:"Définir comme événement horaire",delete:"Supprimer",confirm:"Confirmer",cancel:"Annuler",today:"Aujourd'hui",day:"Jour",week:"Semaine",month:"Mois",year:"Année",newEvent:"Nouvel événement",newAllDayEvent:"Nouvel événement toute la journée",newCalendarEvent:"Nouvel événement dans {calendarName}",newAllDayCalendarEvent:"Nouvel événement toute la journée dans {calendarName}",save:"Enregistrer",deleteCalendar:'Supprimer "{calendarName}" ?',deleteCalendarMessage:'Voulez-vous supprimer "{calendarName}" ou fusionner ses événements dans un autre calendrier existant ?',merge:"Fusionner",confirmDeleteTitle:'Êtes-vous sûr de vouloir supprimer le calendrier "{calendarName}" ?',confirmDeleteMessage:"Si vous supprimez ce calendrier, tous les événements associés seront également supprimés.",mergeConfirmTitle:'Fusionner "{sourceName}" avec "{targetName}" ?',mergeConfirmMessage:'Êtes-vous sûr de vouloir fusionner "{sourceName}" avec "{targetName}" ? Cela déplacera tous les événements de "{sourceName}" vers "{targetName}" et "{sourceName}" sera supprimé. Cette action est irréversible.',expandSidebar:"Développer la barre latérale",collapseSidebar:"Réduire la barre latérale",calendars:"Calendriers",createCalendar:"Créer un nouveau calendrier",calendarNamePlaceholder:"ex. Travail",customColor:"Couleur personnalisée...",create:"Créer",calendarOptions:"Options du calendrier",untitled:"Sans titre",search:"Rechercher",noResults:"Aucun résultat trouvé",calendar:"Calendrier",starts:"Début",ends:"Fin",notes:"Notes",titlePlaceholder:"Titre",notesPlaceholder:"Notes",editEvent:"Modifier l'événement",done:"Terminé",quickCreateEvent:"Création rapide",quickCreatePlaceholder:"Film à 19h vendredi",noSuggestions:"Tapez pour créer",newCalendar:"Nouveau calendrier",refreshAll:"Tout actualiser",tomorrow:"Demain"}},le={code:"de-DE",messages:{allDay:"Ganztägig",noEvents:"Heute keine Termine",more:"mehr",eventTitle:"Ereignistitel",dateRange:"Datumsbereich",timeRange:"Zeitbereich",note:"Notiz",addNotePlaceholder:"Notiz hinzufügen...",setAsAllDay:"Als ganztägig festlegen",setAsTimed:"Als zeitlich begrenztes Ereignis festlegen",delete:"Löschen",confirm:"Bestätigen",cancel:"Abbrechen",today:"Heute",day:"Tag",week:"Woche",month:"Monat",year:"Jahr",newEvent:"Neues Ereignis",newAllDayEvent:"Neues ganztägiges Ereignis",newCalendarEvent:"Neues Ereignis in {calendarName}",newAllDayCalendarEvent:"Neues ganztägiges Ereignis in {calendarName}",save:"Speichern",deleteCalendar:'"{calendarName}" löschen?',deleteCalendarMessage:'Möchten Sie "{calendarName}" löschen oder dessen Ereignisse in einen anderen bestehenden Kalender zusammenführen?',merge:"Zusammenführen",confirmDeleteTitle:'Sind Sie sicher, dass Sie den Kalender "{calendarName}" löschen möchten?',confirmDeleteMessage:"Wenn Sie diesen Kalender löschen, werden auch alle damit verbundenen Ereignisse gelöscht.",mergeConfirmTitle:'"{sourceName}" mit "{targetName}" zusammenführen?',mergeConfirmMessage:'Sind Sie sicher, dass Sie "{sourceName}" mit "{targetName}" zusammenführen möchten? Dadurch werden alle Ereignisse von "{sourceName}" nach "{targetName}" verschoben und "{sourceName}" wird gelöscht. Dies kann nicht rückgängig gemacht werden.',expandSidebar:"Kalender-Seitenleiste erweitern",collapseSidebar:"Kalender-Seitenleiste einklappen",calendars:"Kalender",createCalendar:"Neuen Kalender erstellen",calendarNamePlaceholder:"z.B. Arbeit",customColor:"Benutzerdefinierte Farbe...",create:"Erstellen",calendarOptions:"Kalenderoptionen",untitled:"Unbenannt",search:"Suchen",noResults:"Keine Ergebnisse gefunden",calendar:"Kalender",starts:"Beginnt",ends:"Endet",notes:"Notizen",titlePlaceholder:"Titel",notesPlaceholder:"Notizen",editEvent:"Ereignis bearbeiten",done:"Fertig",quickCreateEvent:"Ereignis schnell erstellen",quickCreatePlaceholder:"Film am Freitag um 19 Uhr",noSuggestions:"Tippen zum Erstellen",newCalendar:"Neuer Kalender",refreshAll:"Alles aktualisieren",tomorrow:"Morgen"}},ie={code:"es-ES",messages:{allDay:"Todo el día",noEvents:"No hay eventos hoy",more:"más",eventTitle:"Título del evento",dateRange:"Rango de fechas",timeRange:"Rango de tiempo",note:"Nota",addNotePlaceholder:"Añadir una nota...",setAsAllDay:"Establecer como todo el día",setAsTimed:"Establecer como evento con horario",delete:"Eliminar",confirm:"Confirmar",cancel:"Cancelar",today:"Hoy",day:"Día",week:"Semana",month:"Mes",year:"Año",newEvent:"Nuevo evento",newAllDayEvent:"Nuevo evento de todo el día",newCalendarEvent:"Nuevo evento en {calendarName}",newAllDayCalendarEvent:"Nuevo evento de todo el día en {calendarName}",save:"Guardar",deleteCalendar:'¿Eliminar "{calendarName}"?',deleteCalendarMessage:'¿Quieres eliminar "{calendarName}" o fusionar sus eventos en otro calendario existente?',merge:"Fusionar",confirmDeleteTitle:'¿Seguro que quieres eliminar el calendario "{calendarName}"?',confirmDeleteMessage:"Si eliminas este calendario, también se eliminarán todos los eventos asociados.",mergeConfirmTitle:'¿Fusionar "{sourceName}" con "{targetName}"?',mergeConfirmMessage:'¿Seguro que quieres fusionar "{sourceName}" con "{targetName}"? Esto moverá todos los eventos de "{sourceName}" a "{targetName}" y se eliminará "{sourceName}". Esta acción no se puede deshacer.',expandSidebar:"Expandir barra lateral del calendario",collapseSidebar:"Contraer barra lateral del calendario",calendars:"Calendarios",createCalendar:"Crear nuevo calendario",calendarNamePlaceholder:"ej. Trabajo",customColor:"Color personalizado...",create:"Crear",calendarOptions:"Opciones de calendario",untitled:"Sin título",search:"Buscar",noResults:"No se encontraron resultados",calendar:"Calendario",starts:"Empieza",ends:"Termina",notes:"Notas",titlePlaceholder:"Título",notesPlaceholder:"Notas",editEvent:"Editar evento",done:"Hecho",quickCreateEvent:"Creación rápida de eventos",quickCreatePlaceholder:"Película a las 7pm el viernes",noSuggestions:"Escribe para crear",newCalendar:"Nuevo calendario",refreshAll:"Actualizar todo",tomorrow:"Mañana"}},se={en:te,zh:ne,ja:ae,ko:re,fr:oe,de:le,es:ie};function de(e){const t=e.split("-")[0].toLowerCase();return t in se?t:"en"}function ce(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function ue(e){var t;return e instanceof d.PlainDate||("PlainDate"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)||!("hour"in e)&&!("timeZone"in e))}function ge(e){return e instanceof Date}function he(e,t=d.Now.timeZoneId()){return d.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function me(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function ve(e){return new Date(e.epochMilliseconds)}function fe(e,t){return ue(e)?function(e,t=d.Now.timeZoneId()){return ve(e.toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:0,minute:0})}))}(e,t):"hour"in e&&!("timeZone"in e)?new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond):ve(e)}function ye(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return ue(e)?d.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:n,minute:a}):e.with({hour:n,minute:a,second:0,millisecond:0})}function pe(e,t){const n=ue(e)?e:e.toPlainDate(),a=ue(t)?t:t.toPlainDate();return 0===d.PlainDate.compare(n,a)}function be(e,t){return!pe(e,t)}function De(e,t=d.Now.timeZoneId()){return(ue(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:0,minute:0})})}function xe(e,t=d.Now.timeZoneId()){return(ue(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function we(e,t){const n=ue(e)?e:e.toPlainDate(),a=ue(t)?t:t.toPlainDate();return n.until(a).days}function Ce(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((a.getTime()-n.getTime())/864e5)}function Ee(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ke(e=d.Now.timeZoneId()){return d.Now.zonedDateTimeISO(e)}function Ne(e=d.Now.timeZoneId()){return d.Now.plainDateISO(e)}const Te=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return ue(t=e)?0:"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:(console.warn("Warning: No hour property found in temporal object, returning 0"),0);var t,n},Se=(e,t)=>{if(e instanceof Date){const n=new Date(e),a=Math.floor(t),r=Math.round(60*(t-a));return n.setHours(a,r,0,0),n}return ye(e,t)},Me=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return De(e)},Ie=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return xe(e)},He=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return pe(e instanceof Date?d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):ue(e)?e:e.toPlainDate(),t instanceof Date?d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):ue(t)?t:t.toPlainDate())},Re=(e,t)=>!He(e,t),Oe=(e,t)=>(t||K()).resolveColors(e).eventColor,Pe=(e,t)=>(t||K()).resolveColors(e).textColor,Le=(e,t)=>(t||K()).resolveColors(e).eventSelectedColor,je=(e,t)=>(t||K()).resolveColors(e).lineColor,Ae=.25,$e=(e,t=0)=>{const n=Math.floor(e),a=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`},ze=e=>{const t=Te(e.start),n=Fe(e);return`${$e(t)} - ${$e(n)}`},Ye=e=>{const t=Ae;return Math.round(e/t)*t},Fe=e=>{if(!e.end)return 0;const t=Te(e.end);if(e.allDay||!e.start)return t;const n=fe(e.start),a=fe(e.end);if(!(n.getFullYear()!==a.getFullYear()||n.getMonth()!==a.getMonth()||n.getDate()!==a.getDate()))return t;if(0===t&&0===a.getMinutes()&&0===a.getSeconds()&&0===a.getMilliseconds()){const e=a.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},Ve=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],We=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Be=["January","February","March","April","May","June","July","August","September","October","November","December"],Ze=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ue=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);a.setDate(n),a.setHours(0,0,0,0);const r=new Date(a);return r.setDate(a.getDate()+6),r.setHours(23,59,59,999),{monday:a,sunday:r}},_e=()=>{const e=new Date,t=new Date,n=e.getDay(),a=e.getDate()-n+(0===n?-6:1);return Ve.map((n,r)=>{const o=new Date(e);return o.setDate(a+r),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},qe=e=>{const t=new Date(e),n=t.getDate(),a=t.getMonth(),r=t.getFullYear(),o=new Date;return{date:t,day:n,month:a,year:r,monthName:Be[a],shortMonthName:Ze[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},Xe=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(qe(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Ge(t)}},Ge=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,a="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,a=e)});const[r,o]=a.split("-").map(Number);return{month:Be[r],monthIndex:r,year:o}},Ke=(e,t=3)=>{const n=5*t,{monday:a}=Ue(e),r=[],o=Math.floor(n/2),l=new Date(a);l.setDate(l.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(Xe(t))}return r};function Je(e,t){const n=[],a=Math.floor(t/2),r=new Date(e),o=e.getDay(),l=0===o?6:o-1;r.setDate(e.getDate()-l),r.setHours(0,0,0,0);const i=new Date(r);i.setDate(i.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),n.push(Xe(t))}return n}const Qe=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),et=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const a=new Date(n);a.setDate(n.getDate()+e),a.setHours(0,0,0,0);const r=fe(t.start);r.setHours(0,0,0,0);const o=fe(t.end);return o.setHours(0,0,0,0),a>=r&&a<=o}),tt=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},nt=(e,t,n)=>{const a=tt(n,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?d.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):d.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:d.Now.timeZoneId()}),end:e.allDay?d.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):d.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:d.Now.timeZoneId()})})},at=(e,t)=>t?d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):d.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:d.Now.timeZoneId()}),rt=(e,t)=>{var n,a;const r=tt(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:at(r,o),end:at(r,o)})},ot=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=n.getTime()-a.getTime();return Math.floor(r/864e5)},lt=(e,t)=>{const n=ot(e,t);return n>=0&&n<=6},it=(e,t)=>e.map(e=>{const n=fe(e.start),a=ot(n,t);return Object.assign(Object.assign({},e),{day:a})}),st=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=a.getTime()-n.getTime();return Math.floor(r/864e5)},dt=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=fe(e.start);return a>=t&&a<=n}).map(e=>{const n=ot(fe(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},ct=(e,t)=>{var n,a;const r=new Date(t);r.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:at(r,o),end:at(r,o)})},ut=(e,t,n)=>{var a;const r=new Date(n);r.setDate(n.getDate()+t);const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{day:t,start:at(r,o),end:at(r,o)})},gt=(e,t)=>e===t||!(!e||!t)&&(e.title===t.title&&e.calendarId===t.calendarId&&(e.description||"")===(t.description||"")&&!!e.allDay==!!t.allDay&&e.start.toString()===t.start.toString()&&e.end.toString()===t.end.toString());function ht(){const e=new Date,t=e.getDay(),n=new Date(e),a=0===t?-6:1-t;n.setDate(e.getDate()+a),n.setHours(0,0,0,0);return[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(e=>{const t=new Date(n);if(t.setDate(n.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),r=Math.round(60*(e.startHour-a)),o=Math.floor(e.endHour),l=Math.round(60*(e.endHour-o));return{id:e.id,title:e.title,start:d.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:a,minute:r,timeZone:d.Now.timeZoneId()}),end:d.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:o,minute:l,timeZone:d.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})}function mt(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function vt(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(const r of n)if(!a.includes(r)||!vt(e[r],t[r]))return!1;return!0}const ft="240px",yt=e=>{if(!e)return{enabled:!1,width:ft,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:ft,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i}=e;return{enabled:t,width:ee(n,ft),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i}};class pt{constructor(t){var n,a,r,o,l;this.getReadOnlyConfig=()=>{var e,t;const n=this.state.readOnly;return!0===n?{draggable:!1,viewable:!1}:!1===n?{draggable:!0,viewable:!0}:{draggable:null!==(e=n.draggable)&&void 0!==e&&e,viewable:null!==(t=n.viewable)&&void 0!==t&&t}},this.isInternalEditable=()=>!0!==this.state.readOnly&&"object"!=typeof this.state.readOnly,this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,this.state.highlightedEventId=null,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e)},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate)},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const a=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===a.getFullYear()&&this.visibleMonth.getMonth()===a.getMonth()||(this.visibleMonth=a,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)))},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case Y.DAY:e.setDate(e.getDate()-1);break;case Y.WEEK:e.setDate(e.getDate()-7);break;case Y.MONTH:e.setMonth(e.getMonth()-1);break;case Y.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case Y.DAY:e.setDate(e.getDate()+1);break;case Y.WEEK:e.setDate(e.getDate()+7);break;case Y.MONTH:e.setMonth(e.getMonth()+1);break;case Y.YEAR:e.setFullYear(e.getFullYear()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.addEvent=e=>{var t,n;this.isInternalEditable()?(this.state.events=[...this.state.events,e],null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e)):Q.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void Q.warn("Cannot update event in read-only mode");if(!this.isInternalEditable())return;const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[a]),t);this.state.events=[...this.state.events.slice(0,a),r,...this.state.events.slice(a+1)]},this.deleteEvent=e=>{var t,n;if(!this.isInternalEditable())return void Q.warn("Cannot delete event in read-only mode");const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);this.state.events=[...this.state.events.slice(0,a),...this.state.events.slice(a+1)],null===(n=(t=this.callbacks).onEventDelete)||void 0===n||n.call(t,e)},this.getAllEvents=()=>[...this.state.events],this.onEventClick=e=>{var t,n;null===(n=(t=this.callbacks).onEventClick)||void 0===n||n.call(t,e)},this.onMoreEventsClick=e=>{var t,n;null===(n=(t=this.callbacks).onMoreEventsClick)||void 0===n||n.call(t,e)},this.highlightEvent=e=>{var t,n;this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{var n,a;this.calendarRegistry.reorder(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n)},this.setCalendarVisibility=(e,t)=>{var n,a;this.calendarRegistry.setVisibility(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n)},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.updateCalendar=(e,t)=>{var n,a,r,o;this.calendarRegistry.updateCalendar(e,t);const l=this.calendarRegistry.get(e);l&&(null===(a=(n=this.callbacks).onCalendarUpdate)||void 0===a||a.call(n,l)),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r)},this.createCalendar=e=>{var t,n,a,r;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a)},this.deleteCalendar=e=>{var t,n,a,r;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a)},this.mergeCalendars=(e,t)=>{var n,a,r,o;this.state.events.filter(t=>t.calendarId===e).forEach(e=>{this.updateEvent(e.id,{calendarId:t})}),this.deleteCalendar(e),null===(a=(n=this.callbacks).onCalendarMerge)||void 0===a||a.call(n,e,t),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r)},this.getSidebarConfig=()=>this.sidebarConfig,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?Q.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.render=()=>e.createElement("div",{className:"calendar-app"},"Calendar App"),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t))},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e)},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.updateConfig=e=>{var t;let n=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,n=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,n=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,n=!0),void 0===e.readOnly||vt(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,n=!0),e.callbacks&&(this.callbacks=Object.assign(Object.assign({},this.callbacks),e.callbacks)),void 0!==(null===(t=e.theme)||void 0===t?void 0:t.mode)&&e.theme.mode!==this.getTheme()&&this.setTheme(e.theme.mode),void 0!==e.useSidebar){const t=yt(e.useSidebar);vt(t,this.sidebarConfig)||(this.sidebarConfig=t,this.state.sidebar=this.sidebarConfig,n=!0)}if(void 0!==e.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=this.resolveLocale(e.locale);vt(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&this.triggerRender()},this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:t.defaultView||Y.WEEK,currentDate:t.initialDate||new Date,events:t.events||[],switcherMode:t.switcherMode||"buttons",plugins:new Map,views:new Map,locale:this.resolveLocale(t.locale),highlightedEventId:null,readOnly:t.readOnly||!1},this.callbacks=t.callbacks||{},this.themeChangeListeners=new Set,this.calendarRegistry=new X(t.calendars,t.defaultCalendar,(null===(n=t.theme)||void 0===n?void 0:n.mode)||"light"),l=this.calendarRegistry,G=l,this.sidebarConfig=yt(t.useSidebar),this.state.sidebar=this.sidebarConfig;const i=this.state.currentDate;this.visibleMonth=new Date(i.getFullYear(),i.getMonth(),1),this.useEventDetailDialog=null!==(a=t.useEventDetailDialog)&&void 0!==a&&a,this.useCalendarHeader=null===(r=t.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=t.customMobileEventRenderer,t.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(o=t.plugins)||void 0===o||o.forEach(e=>{this.installPlugin(e)})}resolveLocale(e){return e?"string"==typeof e?ce(e)?e:"en-US":e&&"object"==typeof e&&!ce(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}function bt(e){const l=t(()=>new pt(e),[]),[i,s]=n(l.state.currentView),[d,c]=n(l.state.currentDate),[u,g]=n(l.getEvents()),[h,m]=n(l.getSidebarConfig()),[,v]=n({}),f=a(()=>{v({})},[]);r(()=>{const e=l.changeView;l.changeView=t=>{e(t),s(t),f()};const t=l.setCurrentDate;l.setCurrentDate=e=>{t(e),c(new Date(e)),f()};const n=l.addEvent;l.addEvent=e=>{n(e),g([...l.getEvents()]),f()};const a=l.updateEvent;l.updateEvent=(e,t,n)=>{a(e,t,n),g([...l.getEvents()]),f()};const r=l.deleteEvent;l.deleteEvent=e=>{r(e),g([...l.getEvents()]),f()};const o=l.setCalendarVisibility;l.setCalendarVisibility=(e,t)=>{o(e,t),g([...l.getEvents()]),f()};const i=l.setAllCalendarsVisibility;l.setAllCalendarsVisibility=e=>{i(e),g([...l.getEvents()]),f()};const d=l.setVisibleMonth;l.setVisibleMonth=e=>{d(e),f()};const u=l.reorderCalendars;l.reorderCalendars=(e,t)=>{u(e,t),f()};const h=l.updateCalendar;l.updateCalendar=(e,t)=>{h(e,t),f()};const v=l.createCalendar;l.createCalendar=e=>{v(e),f()};const y=l.deleteCalendar;l.deleteCalendar=e=>{y(e),f()};const p=l.mergeCalendars;l.mergeCalendars=(e,t)=>{p(e,t),g([...l.getEvents()]),f()};const b=l.highlightEvent;l.highlightEvent=e=>{b(e),f()};const D=l.triggerRender;return l.triggerRender=()=>{D(),m(l.getSidebarConfig()),f()},()=>{}},[l,f]),r(()=>{s(l.state.currentView),c(l.state.currentDate),g(l.getEvents())},[l]);const y=o(e);r(()=>{vt(y.current,e)||(l.updateConfig(e),y.current=e)},[l,e]);const p=a(e=>{l.changeView(e)},[l]),b=a(e=>{l.setCurrentDate(e)},[l]),D=a(e=>{l.addEvent(e)},[l]),x=a((e,t,n)=>{l.updateEvent(e,t,n)},[l]),w=a(e=>{l.deleteEvent(e)},[l]),C=a(()=>{l.goToToday()},[l]),E=a(()=>{l.goToPrevious()},[l]),k=a(()=>{l.goToNext()},[l]),N=a(e=>{l.selectDate(e)},[l]),T=a((e,t)=>{l.setCalendarVisibility(e,t)},[l]),S=a(e=>{l.setAllCalendarsVisibility(e)},[l]);return{app:l,currentView:i,currentDate:d,events:u,changeView:p,setCurrentDate:b,addEvent:D,updateEvent:x,deleteEvent:w,goToToday:C,goToPrevious:E,goToNext:k,selectDate:N,getCalendars:()=>l.getCalendars(),createCalendar:e=>l.createCalendar(e),mergeCalendars:(e,t)=>l.mergeCalendars(e,t),setCalendarVisibility:T,setAllCalendarsVisibility:S,getAllEvents:()=>l.getAllEvents(),highlightEvent:e=>l.highlightEvent(e),setVisibleMonth:e=>l.setVisibleMonth(e),getVisibleMonth:()=>l.getVisibleMonth(),sidebarConfig:h,readOnlyConfig:l.getReadOnlyConfig()}}function Dt(e,t){var n,a,r,o,l;try{if("today"===e){return null!==(a=null===(n=new Intl.RelativeTimeFormat(t,{numeric:"auto"}).formatToParts(0,"day").find(e=>"literal"===e.type))||void 0===n?void 0:n.value)&&void 0!==a?a:null}if("week"===e){return null!==(o=null===(r=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===r?void 0:r.value)&&void 0!==o?o:null}return null!==(l=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==l?l:null}catch(e){return null}}function xt(e){return e.charAt(0).toUpperCase()+e.slice(1)}const wt=(e,t="short")=>{const n=[],a=new Date(2024,0,1);for(let r=0;r<7;r++){const o=new Date(a);o.setDate(a.getDate()+r);try{n.push(o.toLocaleDateString(e,{weekday:t}))}catch(e){n.push(o.toLocaleDateString("en-US",{weekday:t}))}}return n},Ct=(e,t="long")=>{const n=[];for(let a=0;a<12;a++){const r=new Date(2024,a,1);try{n.push(r.toLocaleDateString(e,{month:t}))}catch(e){n.push(r.toLocaleDateString("en-US",{month:t}))}}return n};function Et(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Dt(e,t);if(n)return xt(n)}const a=de(t),r=se[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const l=se.en.messages;return(null==l?void 0:l[e])||e}const kt=e.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Nt(){return l(kt)}const Tt=({x:e,y:t,onClose:n,children:a,className:l})=>{const i=o(null);r(()=>{const e=e=>{i.current&&!i.current.contains(e.target)&&n()};document.addEventListener("mousedown",e);const t=()=>n();return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[n]);return v(u("div",{ref:i,className:`fixed z-50 min-w-32 overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out ${l||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),children:a}),document.body)},St=({onClick:e,children:t,icon:n,danger:a})=>g("div",{className:"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-disabled:pointer-events-none data-disabled:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50 hover:bg-slate-100 dark:hover:bg-slate-800 "+(a?"text-destructive focus:text-destructive-foreground focus:bg-destructive hover:bg-destructive hover:text-destructive-foreground":"text-slate-900 dark:text-slate-50"),onClick:t=>{t.stopPropagation(),e()},children:[n&&u("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Mt=()=>u("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),It=({children:e})=>u("div",{className:"px-2 py-1.5 text-sm font-semibold text-slate-950 dark:text-slate-50",children:e}),Ht=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Rt=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Nt();return g("div",{className:"p-2",children:[u("div",{className:"grid grid-cols-7 gap-2 p-1",children:Ht.map(n=>u("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 dark:border-gray-600 hover:scale-110 transition-transform focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-primary dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-offset-1 ring-primary dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&u("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800",onClick:e=>{e.stopPropagation(),n()},children:a("customColor")})]})},Ot=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Nt();return g("div",{className:"flex items-center px-2 py-2",children:[u("button",{type:"button","aria-label":n(e?"expandSidebar":"collapseSidebar"),className:"flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",onClick:t,children:u(e?p:b,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),!e&&u("div",{className:"flex flex-1 justify-between items-center",children:u("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:n("calendars")})})]})},Pt=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Lt=({calendars:e,onToggleVisibility:t,onReorder:l,onRename:i,onContextMenu:s,editingId:d,setEditingId:c,activeContextMenuCalendarId:h,isDraggable:m=!0,isEditable:v=!0})=>{const[f,y]=n(""),p=o(null),[b,D]=n(!1),[x,w]=n(null),[C,E]=n(null),k=a((e,t)=>{if(d||!m)return void t.preventDefault();D(!0),w(e.id);const n={calendarId:e.id,calendarName:e.name,calendarColors:e.colors,calendarIcon:e.icon};t.dataTransfer.setData("application/x-dayflow-calendar",JSON.stringify(n)),t.dataTransfer.effectAllowed="copy"},[d]),N=a(()=>{D(!1),w(null),E(null)},[]),T=a((t,n)=>{if(t.preventDefault(),x===n)return void E(null);const a=e.findIndex(e=>e.id===n)===e.length-1,r=t.currentTarget.getBoundingClientRect(),o=t.clientY<r.top+r.height/2;E(a?{id:n,position:o?"top":"bottom"}:{id:n,position:"top"})},[x,e]),S=a(()=>{E(null)},[]),M=a(t=>{if(!x||!C)return;if(x===t.id)return;const n=e.findIndex(e=>e.id===x);let a=e.findIndex(e=>e.id===t.id);"bottom"===C.position&&(a+=1),a>n&&(a-=1),-1!==n&&-1!==a&&l(n,a),E(null)},[x,C,e,l]),I=a(e=>{v&&(c(e.id),y(e.name))},[c,v]),H=a(e=>{y(e.target.value)},[]),R=a(()=>{if(d&&f.trim()){const t=e.find(e=>e.id===d);t&&t.name!==f.trim()&&i(d,f.trim())}c(null),y("")},[d,f,e,i,c]),O=a(()=>{c(null),y("")},[c]),P=a(e=>{"Enter"===e.key?R():"Escape"===e.key&&O()},[R,O]);return r(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]),r(()=>{if(d){const t=e.find(e=>e.id===d);t&&y(t.name)}},[d,e]),u("div",{className:"flex-1 overflow-y-auto px-2 pb-3",children:u("ul",{className:"space-y-1 relative",children:e.map(e=>{var n;const a=!1!==e.isVisible,r=(null===(n=e.colors)||void 0===n?void 0:n.lineColor)||"#3b82f6",o=Boolean(e.icon),l=(null==C?void 0:C.id)===e.id,i=h===e.id||d===e.id;return g("li",{className:"relative",onDragOver:t=>T(t,e.id),onDragLeave:S,onDrop:()=>M(e),onContextMenu:t=>s(t,e.id),children:[l&&"top"===C.position&&u("div",{className:"absolute top-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"}),u("div",{draggable:m&&!d,onDragStart:t=>k(e,t),onDragEnd:N,className:`rounded transition ${x===e.id?"opacity-50":""} ${m?"cursor-grab":"cursor-default"}`,children:g("div",{className:"group flex items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800 "+(i?"bg-gray-100 dark:bg-slate-800":""),title:e.name,children:[u("input",{type:"checkbox",className:"calendar-checkbox cursor-pointer shrink-0",style:{"--checkbox-color":r},checked:a,onChange:n=>t(e.id,n.target.checked)}),o&&u("span",{className:"ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white","aria-hidden":"true",children:Pt(e)}),d===e.id?u("input",{ref:p,type:"text",value:f,onChange:H,onBlur:R,onKeyDown:P,className:"ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100",onClick:e=>e.stopPropagation()}):u("span",{className:"flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2",onDoubleClick:()=>I(e),children:e.name||e.id})]})}),l&&"bottom"===C.position&&u("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"})]},e.id)})})})},jt="h-full flex flex-col bg-white dark:bg-gray-900 select-none",At="p-2 flex justify-between",$t="text-2xl font-bold text-gray-900 dark:text-gray-100",zt="rounded-md bg-background border border-border px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",Yt="inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Ft="flex-1 overflow-auto will-change-scroll",Vt="relative h-[4.5rem] flex",Wt="absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Bt="h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",Zt="absolute left-0 top-0 flex pointer-events-none",Ut="ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",_t="flex items-center border-b border-gray-200 dark:border-gray-700 sticky",qt="calendar-event select-none pointer-events-auto px-0.5",Xt="rounded-xl my-0.5",Gt="font-medium text-xs truncate pr-1",Kt="absolute left-1 top-1 bottom-1 w-[3px] rounded-full",Jt="h-3 w-3 mr-1",Qt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",en="bg-primary rounded-full text-primary-foreground",tn="text-gray-600 dark:text-gray-300",nn="text-xs",an="text-sm",rn="flex flex-col",on="mr-1",ln=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:r,onDateSelect:o})=>{const{locale:l}=Nt(),i=t(()=>(new Date).toDateString(),[]),s=n.toDateString(),d=t(()=>wt(l,"narrow"),[l]),c=t(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),h=t(()=>{const t=e.getFullYear(),n=e.getMonth(),a=(new Date(t,n,1).getDay()+6)%7,r=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-a+1),l=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:l===i,isSelected:l===s})}return r},[e,s,i]);return g("div",{className:"px-3 py-3",children:[a?g("div",{className:"mb-3 flex items-center justify-between",children:[u("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(-1),"aria-label":"Previous month",children:u(D,{className:"h-4 w-4"})}),u("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),u("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(1),"aria-label":"Next month",children:u(x,{className:"h-4 w-4"})})]}):"",g("div",{className:"grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>u("div",{className:"text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6 text-gray-500 dark:text-gray-400",children:e},`weekday-${t}`)),h.map(e=>u("button",{type:"button",className:`\n text-center py-1 rounded text-xs h-6 w-6\n ${e.isToday?en:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""}\n `,onClick:()=>o(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},sn=({calendars:e,currentCalendarId:t,onMergeSelect:a})=>{const{t:l}=Nt(),[i,s]=n(!1),d=o(null),c=o(null),[m,f]=n({x:0,y:0}),y=o(),p=()=>{if(y.current&&clearTimeout(y.current),d.current){const e=d.current.getBoundingClientRect();f({x:e.right,y:e.top})}s(!0)},b=()=>{y.current=setTimeout(()=>{s(!1)},100)};r(()=>{const e=c.current;if(e){const t=e=>e.stopPropagation();return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}}},[i]);const D=e.filter(e=>e.id!==t);return 0===D.length?null:g(h,{children:[g("div",{ref:d,className:"relative flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-900 dark:text-slate-50",onMouseEnter:p,onMouseLeave:b,children:[u("span",{children:l("merge")}),u(x,{className:"h-4 w-4"})]}),i&&v(u("div",{ref:c,className:"fixed z-60 min-w-48 overflow-hidden rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-slate-800 dark:bg-slate-950 animate-in fade-in-0 zoom-in-95 duration-100",style:{top:m.y,left:m.x},onMouseEnter:p,onMouseLeave:b,onMouseDown:e=>e.stopPropagation(),children:D.map(e=>g("div",{className:"flex items-center cursor-pointer rounded-sm px-2 py-1.5 text-sm text-slate-900 hover:bg-slate-100 dark:text-slate-50 dark:hover:bg-slate-800",onClick:t=>{t.stopPropagation(),a(e.id)},children:[u("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),u("span",{className:"truncate",children:e.name||e.id})]},e.id))}),document.body)]})},dn=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:r}=Nt();return u("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:g("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("mergeConfirmTitle",{sourceName:e,targetName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:r("mergeConfirmMessage",{sourceName:e,targetName:t})}),g("div",{className:"mt-6 flex justify-end gap-3",children:[u("button",{type:"button",onClick:a,className:zt,children:r("cancel")}),u("button",{type:"button",onClick:n,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:r("merge")})]})]})})},cn=({calendarId:e,calendarName:t,calendars:a,step:r,onStepChange:o,onConfirmDelete:l,onCancel:i,onMergeSelect:s})=>{const[d,c]=n(!1),{t:m}=Nt();return u("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:u("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:g(h,"initial"===r?{children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m("deleteCalendar",{calendarName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:m("deleteCalendarMessage",{calendarName:t})}),g("div",{className:"mt-6 flex justify-between items-center",children:[g("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>c(!d),className:"flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-slate-700",children:m("merge")}),d&&u("div",{className:"absolute left-0 top-full mt-1 min-w-full w-max rounded-md border border-gray-200 bg-background shadow-lg dark:border-slate-700 z-10 max-h-60 overflow-y-auto",children:a.filter(t=>t.id!==e).map(e=>g("div",{className:"flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-slate-700 cursor-pointer",onClick:()=>{s(e.id),c(!1)},children:[u("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),u("span",{className:"whitespace-nowrap",children:e.name||e.id})]},e.id))})]}),g("div",{className:"flex gap-3",children:[u("button",{type:"button",onClick:i,className:zt,children:m("cancel")}),u("button",{type:"button",onClick:()=>o("confirm_delete"),className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:m("delete")})]})]})]}:{children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m("confirmDeleteTitle",{calendarName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:m("confirmDeleteMessage")}),g("div",{className:"mt-6 flex justify-end gap-3",children:[u("button",{type:"button",onClick:i,className:"rounded-md px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-700",children:m("cancel")}),u("button",{type:"button",onClick:l,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:m("delete")})]})]})})})},un=({app:e,calendars:t,toggleCalendarVisibility:o,isCollapsed:l,setCollapsed:i,renderCalendarContextMenu:s,editingCalendarId:d,setEditingCalendarId:c,onCreateCalendar:m})=>{var y,p,b,D;const{t:x}=Nt(),w=e.getVisibleMonth(),C=w.getFullYear(),E=w.getMonth(),[k,N]=n(null),T=void 0!==d?d:k,S=c||N,[M,I]=n(()=>new Date(C,E,1));r(()=>{I(e=>e.getFullYear()===C&&e.getMonth()===E?e:new Date(C,E,1))},[C,E]);const H=a(t=>{I(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[R,O]=n(null),[P,L]=n(null),[j,A]=n(null),[$,z]=n(null),[Y,F]=n(null),V=a((e,t)=>{e.preventDefault(),e.stopPropagation(),O({x:e.clientX,y:e.clientY,calendarId:t}),L(null)},[]),W=a(e=>{e.preventDefault(),L({x:e.clientX,y:e.clientY}),O(null)},[]),B=a(()=>{O(null)},[]),Z=a(()=>{L(null)},[]),U=a(()=>{R&&(F({calendarId:R.calendarId,step:"initial"}),B())},[R,B]),_=a(t=>{if(R){const{colors:n,darkColors:a}=J(t);e.updateCalendar(R.calendarId,{colors:n,darkColors:a}),B()}},[e,R,B]),q=a(()=>{if(R){const e=t.find(e=>e.id===R.calendarId);e&&A({x:R.x,y:R.y,calendarId:R.calendarId,initialColor:e.colors.lineColor,currentColor:e.colors.lineColor}),B()}},[R,t,B]),X=a(e=>{R&&(z({sourceId:R.calendarId,targetId:e}),B())},[R,B]),G=a(()=>{if($){const{sourceId:t,targetId:n}=$;e.mergeCalendars(t,n),z(null)}},[e,$]),K=a(()=>{Y&&(e.deleteCalendar(Y.calendarId),F(null))},[e,Y]),Q=a(e=>{Y&&(z({sourceId:Y.calendarId,targetId:e}),F(null))},[Y]),ee=$?(null===(y=t.find(e=>e.id===$.sourceId))||void 0===y?void 0:y.name)||"Unknown":"",te=$?(null===(p=t.find(e=>e.id===$.targetId))||void 0===p?void 0:p.name)||"Unknown":"",ne=Y?(null===(b=t.find(e=>e.id===Y.calendarId))||void 0===b?void 0:b.name)||"Unknown":"",ae=e.getReadOnlyConfig(),re=!e.state.readOnly,oe=!1!==ae.draggable;return g("div",{className:"flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",onContextMenu:re?W:void 0,children:[u(Ot,{isCollapsed:l,onCollapseToggle:()=>i(!l)}),l?u(Lt,{calendars:t,onToggleVisibility:o,onReorder:oe?e.reorderCalendars:()=>{},onRename:re?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:re?V:()=>{},editingId:T,setEditingId:S,activeContextMenuCalendarId:null==R?void 0:R.calendarId,isDraggable:oe,isEditable:re}):g(h,{children:[u(Lt,{calendars:t,onToggleVisibility:o,onReorder:oe?e.reorderCalendars:()=>{},onRename:re?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:re?V:()=>{},editingId:T,setEditingId:S,activeContextMenuCalendarId:null==R?void 0:R.calendarId,isDraggable:oe,isEditable:re}),u("div",{className:"border-t border-gray-200 dark:border-slate-800",children:u(ln,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:H,onDateSelect:t=>e.setCurrentDate(t)})})]}),R&&u(Tt,{x:R.x,y:R.y,onClose:B,className:"w-64 p-2",children:s?s(t.find(e=>e.id===R.calendarId),B):g(h,{children:[u(It,{children:x("calendarOptions")}),u(sn,{calendars:t,currentCalendarId:R.calendarId,onMergeSelect:X}),u(St,{onClick:U,children:x("delete")}),u(Mt,{}),u(Rt,{selectedColor:null===(D=t.find(e=>e.id===R.calendarId))||void 0===D?void 0:D.colors.lineColor,onSelect:_,onCustomColor:q})]})}),P&&v(g(Tt,{x:P.x,y:P.y,onClose:Z,className:"w-max p-2",children:[u(St,{onClick:()=>{null==m||m(),Z()},children:x("newCalendar")||"New Calendar"}),u(St,{onClick:()=>{e.triggerRender(),Z()},children:x("refreshAll")||"Refresh All"})]}),document.body),$&&v(u(dn,{sourceName:ee,targetName:te,onConfirm:G,onCancel:()=>z(null)}),document.body),Y&&v(u(cn,{calendarId:Y.calendarId,calendarName:ne,calendars:t,step:Y.step,onStepChange:e=>F(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:K,onCancel:()=>F(null),onMergeSelect:Q}),document.body),j&&v(u("div",{className:"fixed inset-0 z-50",onMouseDown:()=>A(null),children:u("div",{className:"absolute rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",style:{top:j.y,left:j.x},onMouseDown:e=>e.stopPropagation(),children:u(f,{width:"220px",color:j.currentColor,onChange:e=>{A(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=J(t.hex);e.updateCalendar(j.calendarId,{colors:n,darkColors:a})}})})}),document.body)]})},gn=({options:e,value:t,onChange:a,registry:l,variant:i="desktop"})=>{const[s,d]=n(!1),[c,h]=n({}),m=o(null),f=o(null),y=()=>{if(f.current){const e=f.current.getBoundingClientRect(),t="mobile"===i,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,h(n)}};r(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-color-picker-dropdown]")||d(!1)};return s&&(y(),window.addEventListener("mousedown",e),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[s]);const p=e=>(l||K()).resolveColors(e).lineColor,b=(e,t)=>{e.stopPropagation(),a(t),d(!1)},D=e.find(e=>e.value===t),x=()=>s&&"undefined"!=typeof window?v("mobile"===i?u("div",{"data-color-picker-dropdown":"true",style:c,className:"bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-200 origin-top-right animate-in fade-in zoom-in-95",children:e.map(e=>g("div",{className:"flex items-center px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>b(t,e.value),children:[g("div",{className:"flex items-center flex-1 min-w-0 mr-3",children:[u("div",{className:"w-5 flex justify-center mr-2",children:e.value===t&&u(C,{className:"w-4 h-4 text-primary"})}),u("span",{className:"text-sm text-gray-700 dark:text-gray-200 truncate",children:e.label})]}),u("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:p(e.value)}})]},e.value))}):u("ul",{"data-color-picker-dropdown":"true",style:c,className:"bg-white dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 overflow-hidden border border-gray-200 dark:border-gray-600 transition-all duration-200 origin-top-left animate-in fade-in zoom-in-95",children:e.map(e=>g("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors "+(t===e.value?"font-semibold":""),onClick:t=>b(t,e.value),children:[t===e.value?u("span",{className:"mr-2 text-sm text-primary",children:u(C,{width:12,height:12})}):u("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),u("span",{className:"w-3 h-3 mr-2 rounded-sm shrink-0",style:{backgroundColor:p(e.value)}}),u("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return g("div","mobile"===i?{className:"relative inline-block",ref:m,children:[g("button",{ref:f,onClick:e=>{e.stopPropagation(),d(!s)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-3 py-1.5 transition-colors",children:[u("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:p(t)}}),u("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==D?void 0:D.label)||t}),u(w,{className:"w-4 h-4 text-gray-400"})]}),x()]}:{className:"relative inline-block",ref:m,children:[g("button",{ref:f,type:"button",onClick:e=>{e.stopPropagation(),d(!s)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[u("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{backgroundColor:p(t)}}),u(w,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),x()]})},hn=/(YYYY|YY|MM|DD|HH|mm)/g,mn=e=>e.toString().padStart(2,"0"),vn=(e,t)=>{const n=(null!=t?t:"").trim(),a=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return a.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},fn=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),yn=e=>{let t,n=0,a="^";for(;null!==(t=hn.exec(e));){a+=fn(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=fn(e.slice(n))+"$",new RegExp(a)},pn=(e,t,n,a)=>{const r=e.trim();if(!r)return null;const o=r.match(t),l=null==o?void 0:o.groups;if(!l)return null;const i=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:n.year,s=l.MM?Number(l.MM):n.month,c=l.DD?Number(l.DD):n.day,u=l.HH?Number(l.HH):n.hour,g=l.mm?Number(l.mm):n.minute;try{return d.ZonedDateTime.from({timeZone:a,year:i,month:s,day:c,hour:u,minute:g,second:n.second,millisecond:n.millisecond,microsecond:n.microsecond,nanosecond:n.nanosecond})}catch(e){return null}},bn=e=>{const t=e;if(t.timeZoneId&&"string"==typeof t.timeZoneId)return t.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const n=e.timeZone;return n&&"string"==typeof n.id?n.id:"string"==typeof t.timeZone?t.timeZone:d.Now.timeZoneId()},Dn=(e,t,n)=>{var a,r,o,l,i,s,c,u,g,h,m,v,f,y,p,b,D,x,w,C,E,k,N,T;if(!e){const e=null!=t?t:n?bn(n):d.Now.timeZoneId();return null!=n?n:d.Now.zonedDateTimeISO(e)}if(ue(e)){const n=null!=t?t:d.Now.timeZoneId(),a=`${e.year}-${mn(e.month)}-${mn(e.day)}T00:00:00[${n}]`;return d.ZonedDateTime.from(a)}if("hour"in e&&!("timeZone"in e)){const n=null!=t?t:d.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(n)}catch(e){}return d.ZonedDateTime.from({timeZone:n,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:null!==(a=e.second)&&void 0!==a?a:0,millisecond:null!==(r=e.millisecond)&&void 0!==r?r:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(l=e.nanosecond)&&void 0!==l?l:0})}try{return d.ZonedDateTime.from(e)}catch(a){const r=e,o=null!==(g=null!==(u=null!==(c=null!==(s="string"==typeof(null==r?void 0:r.timeZone)?r.timeZone:null===(i=null==r?void 0:r.timeZone)||void 0===i?void 0:i.id)&&void 0!==s?s:null==r?void 0:r.timeZoneId)&&void 0!==c?c:t)&&void 0!==u?u:n?bn(n):void 0)&&void 0!==g?g:d.Now.timeZoneId();if("function"==typeof(null==r?void 0:r.toZonedDateTime))try{return r.toZonedDateTime({timeZone:o})}catch(e){}const l=null!=n?n:d.Now.zonedDateTimeISO(o);return d.ZonedDateTime.from({timeZone:o,year:null!==(h=null==r?void 0:r.year)&&void 0!==h?h:l.year,month:null!==(m=null==r?void 0:r.month)&&void 0!==m?m:l.month,day:null!==(v=null==r?void 0:r.day)&&void 0!==v?v:l.day,hour:null!==(y=null!==(f=null==r?void 0:r.hour)&&void 0!==f?f:null==n?void 0:n.hour)&&void 0!==y?y:0,minute:null!==(b=null!==(p=null==r?void 0:r.minute)&&void 0!==p?p:null==n?void 0:n.minute)&&void 0!==b?b:0,second:null!==(x=null!==(D=null==r?void 0:r.second)&&void 0!==D?D:null==n?void 0:n.second)&&void 0!==x?x:0,millisecond:null!==(C=null!==(w=null==r?void 0:r.millisecond)&&void 0!==w?w:null==n?void 0:n.millisecond)&&void 0!==C?C:0,microsecond:null!==(k=null!==(E=null==r?void 0:r.microsecond)&&void 0!==E?E:null==n?void 0:n.microsecond)&&void 0!==k?k:0,nanosecond:null!==(T=null!==(N=null==r?void 0:r.nanosecond)&&void 0!==N?N:null==n?void 0:n.nanosecond)&&void 0!==T?T:0})}},xn=(e,t,n)=>{const a=vn(t,n),r={YYYY:e.year.toString(),YY:mn(e.year%100),MM:mn(e.month),DD:mn(e.day),HH:mn(e.hour),mm:mn(e.minute)};return a.replace(hn,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},wn=Array.from({length:24},(e,t)=>t),Cn=Array.from({length:60},(e,t)=>t),En=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:a,onYearChange:r})=>g("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[g("div",{className:"flex items-center gap-1",children:[u("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(E,{width:14,height:12})}),u("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(D,{width:14,height:12})})]}),g("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),g("div",{className:"flex items-center gap-1",children:[u("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(x,{width:14,height:12})}),u("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(k,{width:14,height:12})})]})]}),kn=(e,t)=>d.PlainDate.compare(e,t),Nn=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:r,disabled:o,onDaySelect:l})=>g(h,{children:[u("div",{className:"grid grid-cols-7 gap-1 px-3 pb-3 pt-2 text-center text-[11px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:r.map((e,t)=>u("span",{children:e},t))}),u("div",{className:"grid grid-cols-7 gap-2 px-1 ",children:e.map(e=>{const r=e.month!==t.month,i=0===kn(e,n),s=0===kn(e,a),d=kn(e,n)>=0&&kn(e,a)<=0;return u("button",{type:"button",disabled:o,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${i||s?"bg-primary text-primary-foreground font-semibold":d?"bg-primary/10 text-primary":r?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"}`,children:e.day},e.toString())})})]}),Tn=({focusedField:e,draftRange:t,disabled:n,onHourSelect:a,onMinuteSelect:r,timeListRefs:o})=>{const l=e,i=t["start"===l?0:1],s=i.minute,d=Cn.includes(s)?Cn:[...Cn,s].sort((e,t)=>e-t);return g("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[u("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:g("div",{className:"text-lg py-1 text-slate-700 dark:text-gray-300",children:[i.hour.toString().padStart(2,"0"),":",i.minute.toString().padStart(2,"0")]})}),g("div",{className:"flex p-1",children:[u("div",{className:"w-14",children:u("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Hour",ref:e=>{o.current[l]&&(o.current[l].hour=e)},children:wn.map(e=>{const t=e===i.hour;return u("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:mn(e)},e)})})}),u("div",{className:"w-14",children:u("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Minute",ref:e=>{o.current[l]&&(o.current[l].minute=e)},children:d.map(e=>{const t=e===s;return u("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:mn(e)},e)})})})]})]})},Sn=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:a,draftRange:r,focusedField:o,isTimeEnabled:l,disabled:i,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:h,onYearChange:m,onDaySelect:v,onHourSelect:f,onMinuteSelect:y,onOk:p,getPopupStyle:b})=>{const D=r[0].toPlainDate(),x=r[1].toPlainDate();return u("div",{ref:d,style:b(),"data-range-picker-popup":"true",children:g("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[g("div",{className:"flex gap-1",children:[g("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[u(En,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:h,onYearChange:m}),u(Nn,{calendarDays:a,visibleMonth:e,startDate:D,endDate:x,weekDayLabels:n,disabled:i,onDaySelect:v})]}),l&&u("div",{className:"flex flex-1 justify-end sm:w-32",children:u(Tn,{focusedField:o,draftRange:r,disabled:i,onHourSelect:f,onMinuteSelect:y,timeListRefs:c})})]}),u("div",{className:"flex justify-end",children:u("button",{type:"button",onClick:p,disabled:i,className:"inline-flex items-center rounded-full bg-primary px-4 py-1.5 text-sm font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Mn=({value:e,format:l="YYYY-MM-DD HH:mm",showTimeFormat:i="HH:mm",showTime:s=!0,onChange:c,onOk:h,timeZone:v,disabled:f=!1,placement:y="bottomLeft",autoAdjustOverflow:p=!0,getPopupContainer:b,matchTriggerWidth:D=!1,locale:x="en-US"})=>{const w=t(()=>"string"==typeof x?x:(null==x?void 0:x.code)||"en-US",[x]),C=t(()=>void 0===s||("object"==typeof s||Boolean(s)),[s]),E=t(()=>Ct(w,"short"),[w]),k=t(()=>wt(w,"narrow"),[w]),T=t(()=>C?"object"==typeof s&&(null==s?void 0:s.format)?s.format:i:"",[C,s,i]),S=t(()=>vn(l,T),[l,T]),M=t(()=>yn(S),[S]),I=t(()=>{const t=null!=v?v:ue(e[0])?ue(e[1])?d.Now.timeZoneId():bn(e[1]):bn(e[0]),n=Dn(e[0],t);return[n,Dn(e[1],t,n)]},[e,v]),[H,R]=n(I),O=o(I),[P,L]=n("start"),[j,A]=n([xn(I[0],l,T),xn(I[1],l,T)]),$=o([xn(I[0],l,T),xn(I[1],l,T)]),z=o(I),[Y,F]=n(I[0].toPlainDate().with({day:1})),[V,W]=n(!1),B=a(e=>{W(e)},[]),[Z,U]=n(y),_=o(y),q=o(null),X=o(null),G=o({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=o(!1);r(()=>{$.current=j},[j]),r(()=>{z.current=H},[H]),r(()=>{const e=O.current,t=0!==d.ZonedDateTime.compare(e[0],I[0]),n=0!==d.ZonedDateTime.compare(e[1],I[1]);(t||n)&&R(I),O.current=I},[I]),r(()=>{F(I[0].toPlainDate().with({day:1}))},[I[0]]);const J=a((e,t,n=0)=>{var a;if(!e||!t)return;const r=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top+e.scrollTop-n,l=(null===(a=window.matchMedia)||void 0===a?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:l})},[]),Q=a(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const a=n.querySelector('[data-active="true"]');a&&J(n,a,0)})})})},[J]);r(()=>{V&&C&&Q(P)},[P,V,Q,C]);const ee=H[0].epochMilliseconds,te=H[0].offsetNanoseconds,ne=H[1].epochMilliseconds,ae=H[1].offsetNanoseconds;r(()=>{const[e,t]=z.current,n=xn(e,l,T),a=xn(t,l,T),[r,o]=$.current;r===n&&o===a||($.current=[n,a],A([n,a]))},[ee,te,ne,ae,l,T]),r(()=>{if(!V)return;const e=e=>{var t,n;const a=e.target;if(null===(t=q.current)||void 0===t?void 0:t.contains(a))return;if(null===(n=X.current)||void 0===n?void 0:n.contains(a))return;a.closest("[data-range-picker-popup]")||B(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[V]),r(()=>{V||(L("start"),K.current||R(I),K.current=!1)},[V,I]);const re=a(e=>{c&&c(e,[xn(e[0],l,T),xn(e[1],l,T)])},[T,l,c]),oe=a(e=>{h&&h(e,[xn(e[0],l,T),xn(e[1],l,T)])},[T,l,h]),le=a((e,t)=>{R(n=>{const a=[...n];if("start"===e){const e=Dn(a[1],bn(t),t),n=d.ZonedDateTime.compare(t,e)>0?t:e;return[t,n]}const r=Dn(a[0],bn(t),t);return[d.ZonedDateTime.compare(r,t)>0?t:r,t]})},[]),ie=e=>{if(f)return;const t=(e,t)=>{var n,a,r,o;const l=bn(e);return d.ZonedDateTime.from({timeZone:l,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(n=e.second)&&void 0!==n?n:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(r=e.microsecond)&&void 0!==r?r:0,nanosecond:null!==(o=e.nanosecond)&&void 0!==o?o:0})};if("start"===P){const n=t(H[0],e),a=H[1].epochMilliseconds-H[0].epochMilliseconds,r=n.add({milliseconds:a});return void R([n,r])}const n=t(H[1],e),a=H[1].epochMilliseconds-H[0].epochMilliseconds;if(d.ZonedDateTime.compare(n,H[0])<0){const n=t(H[0],e),r=n.add({milliseconds:a});return void R([n,r])}const r=[H[0],n];R(r),F(n.toPlainDate().with({day:1}))},se=a((e,t)=>{if(f)return;const n="start"===e?0:1;R(a=>{const r=a[n],o=r.with({hour:t,minute:r.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Dn(a[1],bn(o),o);return[o,d.ZonedDateTime.compare(o,e)>0?o:e]}const l=Dn(a[0],bn(o),o);return[d.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&J(t,n,0)})})},[f]),de=a((e,t)=>{if(f)return;const n="start"===e?0:1;R(a=>{const r=a[n].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Dn(a[1],bn(r),r);return[r,d.ZonedDateTime.compare(r,e)>0?r:e]}const o=Dn(a[0],bn(r),r);return[d.ZonedDateTime.compare(o,r)>0?r:o,r]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&J(t,n,0)})})},[f]),ce=a((e,t)=>{const n="start"===e?0:1;A(e=>{const a=[...e];return a[n]=t,a})},[]),ge=a((e,t)=>{const n="start"===e?0:1,a=H[n],r=bn(a),o=pn(t,M,a,r);if(o){le(e,o);const t=o.toPlainDate().with({day:1});return F(t),"start"===e&&L("end"),!0}return A(e=>{const t=[...e];return t[n]=xn(H[n],l,T),t}),!1},[H,T,l,M,le]),he=a(e=>t=>{ce(e,t.target.value)},[ce]),me=a(e=>t=>{var n;if(f)return;if(V)return;const a=t.relatedTarget;a&&(null===(n=q.current)||void 0===n?void 0:n.contains(a))||ge(e,t.target.value)},[ge,f,V]),ve=a(e=>t=>{"Enter"===t.key&&(t.preventDefault(),ge(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ge]),fe=()=>{K.current=!0,re(H),oe(H),B(!1)},ye=e=>{F(t=>t.add({months:e}).with({day:1}))},pe=e=>{F(t=>t.add({years:e}).with({day:1}))},be=t(()=>{const e=Y,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[Y]),De=a((e=y)=>{if(!p||!q.current)return e;const t=q.current.getBoundingClientRect(),n=D?t.width:480,a=window.innerHeight-t.bottom,r=t.top,o=window.innerWidth-t.left,l=t.right;let i=e;return i.startsWith("bottom")&&a<500&&r>a?i=i.replace("bottom","top"):i.startsWith("top")&&r<500&&a>r&&(i=i.replace("top","bottom")),i.endsWith("Left")&&o<n&&l>o?i=i.replace("Left","Right"):i.endsWith("Right")&&l<n&&o>l&&(i=i.replace("Right","Left")),i},[p,D,y]),xe=a(()=>{const e=De();_.current!==e&&(_.current=e,U(e))},[De]),we=e=>{if(f)return;L(e);const t=H["start"===e?0:1].toPlainDate().with({day:1});F(t);const n=De();_.current!==n&&(_.current=n,U(n)),B(!0)};r(()=>{if(!V)return;xe();const e=()=>xe();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[V,xe]);const Ce=()=>{if(!q.current)return{};const e=q.current.getBoundingClientRect(),t=_.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,D&&(n.width=`${e.width}px`),n};return g("div",{className:"relative max-w-100",ref:q,children:[g("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(f?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":V?"border-primary bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700"),children:[u("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:u("input",{type:"text",value:j[0],onChange:he("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:me("start"),onKeyDown:ve("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(f?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===P&&V?" bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:S,autoComplete:"off",disabled:f})}),u(N,{className:"text-slate-400 dark:text-gray-500"}),u("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:u("input",{type:"text",value:j[1],onChange:he("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:me("end"),onKeyDown:ve("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(f?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===P&&V?"bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:S,autoComplete:"off",disabled:f})})]}),V&&(b?m.createPortal(u(Sn,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:H,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:X,timeListRefs:G,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:fe,getPopupStyle:Ce}),b()):m.createPortal(u(Sn,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:H,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:X,timeListRefs:G,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:fe,getPopupStyle:Ce}),document.body))]})},In=({event:e,isOpen:a,isAllDay:o,onEventUpdate:l,onEventDelete:i,onClose:s,app:c})=>{var h;const[v,f]=n(e),{t:y}=Nt();r(()=>{f(e)},[e]);const p=t(()=>(c?c.getCalendarRegistry():K()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),b=t(()=>!gt(e,v),[e,v]),D=t(()=>ue(v.start)?v.end&&!ue(v.end)&&(v.end.timeZoneId||v.end.timeZoneId)||d.Now.timeZoneId():v.start.timeZoneId||v.start.timeZoneId||d.Now.timeZoneId(),[v.end,v.start]),x=e=>{const[t,n]=e;f(Object.assign(Object.assign({},v),{start:t.toPlainDate(),end:n.toPlainDate()}))},w=!(null==c?void 0:c.state.readOnly),C=!1!==(null==c?void 0:c.getReadOnlyConfig().viewable);if(!a||!C)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const E=g("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[u("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/80",onClick:e=>{const t=e.target;t.closest("[data-range-picker-popup]")||t===e.currentTarget&&s()}}),g("div",{className:"relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[u("button",{onClick:s,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:u("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),g("div",{children:[u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("eventTitle")}),g("div",{className:"flex items-center justify-between gap-3 mb-4",children:[u("div",{className:"flex-1",children:u("input",{type:"text",value:v.title,readOnly:!w,disabled:!w,onChange:e=>{f(Object.assign(Object.assign({},v),{title:e.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),w&&u(gn,{options:p,value:v.calendarId||"blue",onChange:e=>{f(Object.assign(Object.assign({},v),{calendarId:e}))},registry:null==c?void 0:c.getCalendarRegistry()})]}),v.allDay?g("div",{className:"mb-4",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("dateRange")}),u(Mn,{value:[v.start,v.end],format:"YYYY-MM-DD",showTime:!1,timeZone:D,matchTriggerWidth:!0,disabled:!w,onChange:x,onOk:x,locale:null==c?void 0:c.state.locale})]}):g("div",{className:"mb-4",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("timeRange")}),u(Mn,{value:[v.start,v.end],timeZone:D,disabled:!w,onChange:e=>{const[t,n]=e;f(Object.assign(Object.assign({},v),{start:t,end:n}))},onOk:e=>{const[t,n]=e;f(Object.assign(Object.assign({},v),{start:t,end:n}))},locale:null==c?void 0:c.state.locale})]}),g("div",{className:"mb-4",children:[u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("note")}),u("textarea",{value:null!==(h=v.description)&&void 0!==h?h:"",readOnly:!w,disabled:!w,onChange:e=>f(Object.assign(Object.assign({},v),{description:e.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:y("addNotePlaceholder")})]}),w&&g("div",{className:"flex space-x-2",children:[v.allDay?u("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=ue(v.start)?v.start:v.start.toPlainDate(),t=d.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:9,minute:0,timeZone:d.Now.timeZoneId()}),n=d.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:10,minute:0,timeZone:d.Now.timeZoneId()});f(Object.assign(Object.assign({},v),{allDay:!1,start:t,end:n}))},children:y("setAsTimed")}):u("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=ue(v.start)?v.start:v.start.toPlainDate();f(Object.assign(Object.assign({},v),{allDay:!0,start:e,end:e}))},children:y("setAsAllDay")}),u("button",{className:"px-3 py-2 bg-destructive border border-border text-destructive-foreground rounded-lg hover:bg-destructive/90 text-sm font-medium transition",onClick:()=>{i(e.id),s()},children:y("delete")}),u("button",{className:"px-3 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium transition ml-auto "+(b?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{l(v),s()},disabled:!b,children:y("save")})]})]})]})]}),k=document.body;return k?m.createPortal(E,k):null},Hn=({calendar:e,mode:t="buttons"})=>{const[a,l]=n(!1),i=o(null),{t:s}=Nt(),d=Array.from(e.state.views.keys()),c=e.state.currentView;return d.length<=1?null:(r(()=>{const e=e=>{i.current&&!i.current.contains(e.target)&&l(!1)};if(a)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),"select"===t?g("div",{className:"relative inline-block",ref:i,children:[g("button",{onClick:()=>l(!a),className:"flex items-center gap-2 px-3 mb-1 h-7 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-primary focus:ring-offset-1 transition-all duration-200 shadow-sm min-w-30 justify-between","aria-expanded":a,"aria-haspopup":"listbox",children:[u("span",{className:"text-gray-900 dark:text-gray-100",children:s(c)}),u("span",{className:"text-gray-500 dark:text-gray-400 transition-transform duration-200 "+(a?"rotate-180":""),children:u(T,{width:16,height:16})})]}),a&&u("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-30 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:u("div",{className:"py-1",role:"listbox",children:d.map(t=>u("button",{onClick:()=>{e.changeView(t),l(!1)},className:"w-full text-left px-3 py-2 text-sm transition-colors duration-150 "+(c===t?"bg-primary/10 text-primary font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":c===t,children:s(t)},t))})}),u("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}):u("div",{className:"inline-flex items-center gap-1 p-0.5 mb-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:d.map(t=>u("button",{className:"px-4 h-6 text-sm font-medium rounded-md transition-all duration-200 "+(c===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>e.changeView(t),children:s(t)},t))}))},Rn=0,On=1970,Pn=2100,Ln=8,jn=100,An=1200,$n=900,zn=700;class Yn{static trackScrollEvent(e=0){this.metrics.scrollEvents++,this.metrics.totalScrollDistance+=Math.abs(e),this.metrics.avgScrollDelta=this.metrics.totalScrollDistance/this.metrics.scrollEvents}static trackRenderTime(e){this.metrics.renderTime.push(e),e>16.67&&this.metrics.frameDrops++,this.metrics.renderTime.length>100&&this.metrics.renderTime.shift()}static trackCacheHit(){this.metrics.cacheHits++}static trackCacheMiss(){this.metrics.cacheMisses++}static getMetrics(){const e=this.metrics.renderTime.length>0?this.metrics.renderTime.reduce((e,t)=>e+t,0)/this.metrics.renderTime.length:0,t=this.metrics.cacheHits+this.metrics.cacheMisses>0?this.metrics.cacheHits/(this.metrics.cacheHits+this.metrics.cacheMisses)*100:0,n=Date.now()-this.metrics.startTime,a=e>0?1e3/e:0;return{scrollEvents:this.metrics.scrollEvents,avgRenderTime:Math.round(100*e)/100,cacheHitRate:Math.round(100*t)/100,uptime:Math.round(n/1e3),scrollEventsPerSecond:Math.round(this.metrics.scrollEvents/(n/1e3)*100)/100,estimatedFPS:Math.round(a),frameDrops:this.metrics.frameDrops,avgScrollDelta:Math.round(100*this.metrics.avgScrollDelta)/100}}static reset(){this.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0}}}Yn.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const Fn=()=>{const[e,t]=n({yearHeight:zn,screenSize:"desktop"});return r(()=>{const e=()=>{const e=window.innerWidth;t(e<640?{yearHeight:An,screenSize:"mobile"}:e<900?{yearHeight:$n,screenSize:"tablet"}:{yearHeight:zn,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Vn=({currentDate:e,yearHeight:l,onCurrentYearChange:i})=>{const s=e.getFullYear(),d=(s-On)*l,[c,u]=n(d),[g,h]=n(600),[m,v]=n(s),[f,y]=n(!1),p=o(null),b=o(null),D=o(0),x=o(0),w=o(l);r(()=>{if(w.current===l)return;w.current=l;const e=(m-On)*l;u(e),x.current=e,p.current&&(p.current.scrollTop=e)},[l,m]);const C=t(()=>{const e=performance.now(),t=Pn-On+1,n=t*l,a=Math.floor(c/l),r=Math.min(t-1,Math.ceil((c+g)/l)),o=Math.max(0,a-Rn),i=Math.min(t-1,r+Rn),s=[];for(let e=o;e<=i;e++)s.push({index:e,year:On+e,top:e*l,height:l});const d=performance.now()-e;return Yn.trackRenderTime(d),{totalHeight:n,visibleItems:s}},[c,g,l]),E=a(e=>{const t=performance.now();if(t-D.current<Ln)return;D.current=t;const n=e.currentTarget.scrollTop,a=Math.abs(n-x.current);x.current=n,Yn.trackScrollEvent(a),requestAnimationFrame(()=>{u(n);const e=n,t=Math.floor(On+e/l);t!==m&&t>=On&&t<=Pn&&(v(t),null==i||i(t))}),y(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{y(!1)},jn)},[g,m,l,i]);r(()=>{const e=p.current;if(!e)return;e.scrollTop=d,x.current=d;const t=new ResizeObserver(([e])=>{h(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[d]);const k=a((e,t=!0)=>{if(!p.current)return;const n=(e-On)*l;p.current.scrollTo({top:Math.max(0,n),behavior:t?"smooth":"auto"})},[l]),N=a(()=>{const e=Math.max(On,m-1);v(e),k(e)},[m,k]),T=a(()=>{const e=Math.min(Pn,m+1);v(e),k(e)},[m,k]),S=a(()=>{const e=(new Date).getFullYear();v(e),k(e)},[k]);return r(()=>()=>{b.current&&clearTimeout(b.current)},[]),{scrollTop:c,containerHeight:g,currentYear:m,isScrolling:f,virtualData:C,scrollElementRef:p,handleScroll:E,scrollToYear:k,handlePreviousYear:N,handleNextYear:T,handleToday:S,setScrollTop:u,setContainerHeight:h,setCurrentYear:v,setIsScrolling:y}},Wn=e=>{if(!e)return"";let t,n,a;e instanceof Date?(t=e.getFullYear(),n=e.getMonth()+1,a=e.getDate()):ue(e)?(t=e.year,n=e.month,a=e.day):(!function(){d.ZonedDateTime}(e),t=e.year,n=e.month,a=e.day);const r=String(n).padStart(2,"0");return`${String(a).padStart(2,"0")}/${r}/${t}`},Bn=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,Zn=e=>{const t=e.year,n=e.month;return`${e.day} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n-1]} ${t}`};function Un(e){return!("hour"in e)}function _n(e){return"hour"in e&&!("timeZone"in e)}function qn(e){return"timeZone"in e}function Xn(e){if(Un(e))return new Date(e.year,e.month-1,e.day);if(_n(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);const t=e.toInstant();return new Date(t.epochMilliseconds)}function Gn(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Kn(e){return d.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function Jn(e,t){return d.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t})}function Qn(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)}function ea(e){return new Date(e.year,e.month-1,e.day)}function ta(e){if(Un(e))return 0;return e.hour+e.minute/60}function na(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return qn(e),e.with({hour:n,minute:a,second:0,millisecond:0})}function aa(e,t){const n=Un(e)?e:(_n(e),e.toPlainDate()),a=Un(t)?t:(_n(t),t.toPlainDate());return n.equals(a)}function ra(e){return Un(e)?e:(_n(e),e.toPlainDate())}const oa=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),la={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-primary",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-primary focus:ring-primary",buttonPrimary:"bg-primary text-primary-foreground hover:bg-primary/90",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-destructive text-destructive-foreground hover:bg-destructive/90",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},ia=(e,t,n)=>e?t:n,sa=(...e)=>e.filter(Boolean).join(" "),da=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.getAttribute("data-dayflow-theme-override"),t.getAttribute("data-theme-override"),t.getAttribute("data-theme")];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e};function ca(e,t=!1){if(e instanceof d.PlainDate||e instanceof d.PlainDateTime)return e;if(e instanceof Date)return t?Gn(e):Kn(e);throw new Error("Invalid time type: "+typeof e)}function ua(e,t){if(e instanceof d.ZonedDateTime)return e;if(e instanceof Date)return Jn(e,t);throw new Error("Invalid time type: "+typeof e)}function ga(e){var t;const n=ca(e.start,e.allDay),a=ca(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:a,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function ha(e){const t=ua(e.start,e.timeZone),n=ua(e.end,e.timeZone);return{id:e.id,title:e.title,description:e.description,start:t,end:n,allDay:!1,calendarId:e.calendarId,meta:e.meta}}function ma(e){return e.map(e=>ga(e))}function va(e){return e.map(e=>ha(e))}function fa(e,t,n,a){return ga(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))}function ya(e,t,n,a,r){return ga(Object.assign({id:e,title:t,start:n,end:a},r))}function pa(e,t,n,a,r=!1,o){return ga(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))}function ba(e,t,n,a,r,o){return ha(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))}const Da=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):fe(e)}catch(e){return new Date}},xa=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},wa=(e,t,n,a)=>{const r=e.getTime()-t.getTime(),o=Math.round(r/864e5);let l="",i="text-gray-500 dark:text-gray-400";if(0===o)l=a("today")||"Today",i="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");l=e.charAt(0).toUpperCase()+e.slice(1),i="text-black dark:text-white"}catch(t){l=e.toLocaleDateString(n,{weekday:"long"})}else l=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:l,colorClass:i}},Ca=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=Da(e.start),r=xa(a),o=r.getTime();n.has(o)||n.set(o,{date:r,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const a=t.getTime();n.has(a)||n.set(a,{date:t,events:[]});return Array.from(n.values()).sort((e,t)=>e.date.getTime()-t.date.getTime())};let Ea=null;const ka=()=>{const[e,t]=n(()=>Ea||{weekHeight:U,screenSize:"desktop",weeksPerView:6});return r(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,a=Math.max(80,Math.floor(n/6)),r=e<768?{weekHeight:Math.max(B,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(Z,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(U,a),screenSize:"desktop",weeksPerView:6};Ea&&Ea.screenSize===r.screenSize&&Ea.weekHeight===r.weekHeight&&Ea.weeksPerView===r.weeksPerView||(Ea=r,t(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Na=({currentDate:e,weekHeight:l,onCurrentMonthChange:i,initialWeeksToLoad:s=104,locale:d="en-US",isEnabled:c=!0})=>{const u=o(null),g=a((e,t)=>{const n=new Date(t,e,1),a=d.startsWith("zh")||d.startsWith("ja");return n.toLocaleDateString(d,{month:a?"short":"long"})},[d]),h=t(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),Je(t,s)},[e,s]),m=t(()=>{const t=new Date(e);t.setDate(1),t.setHours(0,0,0,0);const n=h.findIndex(e=>e.days.some(e=>e.date.toDateString()===t.toDateString()));return n>0?n*l:0},[h,e,l]),[v,f]=n(m),[y,p]=n(600),[b,D]=n(g(e.getMonth(),e.getFullYear())),[x,w]=n(e.getFullYear()),[C,E]=n(!1),[k,N]=n(h),[T,S]=n(!1),M=o(!1),[I,H]=n(!1),R=o(e),O=o(null),P=o(null),L=o(new _),j=o(0),A=o(0),$=o(!1),z=a(e=>{e&&(O.current=e)},[]),Y=a(e=>{let t=L.current.get(e);return console.log("weekData",t),t||(t=Xe(e),L.current.set(e,t)),t},[]),F=a((e,t=26)=>{$.current||($.current=!0,setTimeout(()=>{try{if("future"===e){const e=k[k.length-1],n=[];for(let a=1;a<=t;a++){const t=new Date(e.startDate);t.setDate(t.getDate()+7*a),n.push(Y(t))}N(e=>[...e,...n])}else{const e=k[0],n=[];for(let a=t;a>=1;a--){const t=new Date(e.startDate);t.setDate(t.getDate()-7*a),n.push(Y(t))}const a=n.length*l;N(e=>[...n,...e]),requestAnimationFrame(()=>{f(e=>e+a),O.current&&(O.current.scrollTop+=a)})}}finally{setTimeout(()=>{$.current=!1},200)}},0))},[k,Y,l]),B=t(()=>{const e=k.length*l,t=Math.floor(v/l);let n=Math.max(0,t);n=Math.min(n,Math.max(0,k.length-6));const a=Math.min(k.length-1,n+6-1),r=Math.max(0,n-15),o=Math.min(k.length-1,a+15),i=[];for(let e=r;e<=o;e++)i.push({index:e,weekData:k[e],top:e*l,height:l});return{totalHeight:e,visibleItems:i,displayStartIndex:n}},[v,y,l,k]),Z=a(e=>{if(T||C||0===e.length||!I)return;const t=v+y/2,n=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!n)return;const a={};n.weekData.days.forEach(e=>{const t=`${g(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let r="",o=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,a]=e.split("-");r=n,o=parseInt(a)}}),r&&o&&(u.current?r===u.current.month&&o===u.current.year&&(u.current=null,r===b&&o===x||(D(r),w(o),null==i||i(r,o))):r===b&&o===x||(D(r),w(o),null==i||i(r,o)))},[y,b,x,T,C,i,v,I]),U=a(e=>{const t=performance.now();if(t-j.current<V)return;j.current=t;const n=e.currentTarget,a=n.scrollTop;A.current=a,f(a),T||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=n;a+t>e-10*l&&!$.current&&F("future",26),a<10*l&&!$.current&&F("past",26)}),E(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{E(!1)},W)},[l,F,T]),q=a((e,t=!0)=>{if(!O.current)return;S(!0),M.current=!0;const n=()=>{setTimeout(()=>{S(!1),M.current=!1},t?500:200)},a=k.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*l;return O.current.scrollTo({top:e,behavior:t?"smooth":"auto"}),void n()}const r=e.getDay(),o=0===r?6:r-1,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const s=k[0],d=k[k.length-1];let c=0,u=!1,g=!1;i<s.startDate?(c=Math.ceil((s.startDate.getTime()-i.getTime())/6048e5),u=!0):i>d.startDate&&(c=Math.ceil((i.getTime()-d.startDate.getTime())/6048e5),g=!0);const h=Math.min(c+10,52);if(u){const a=[];for(let e=h;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(Y(t))}const r=a.length*l;N(e=>[...a,...e]),requestAnimationFrame(()=>{const o=[...a,...k].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(O.current&&-1!==o){const e=o*l;O.current.scrollTop+=r,f(e=>e+r),setTimeout(()=>{O.current&&O.current.scrollTo({top:e,behavior:t?"smooth":"auto"})},50)}n()})}else if(g){const a=[];for(let e=1;e<=h;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(Y(t))}N(e=>[...e,...a]),requestAnimationFrame(()=>{const r=[...k,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(O.current&&-1!==r){const e=r*l;O.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}n()})}else n()},[k,l,Y]),X=a(()=>{const e=k[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);q(t)},[B.displayStartIndex,k,q]),G=a(()=>{const e=k[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);q(t)},[B.displayStartIndex,k,q]),K=a(()=>{const e=new Date,t=g(e.getMonth(),e.getFullYear()),n=e.getFullYear(),a=new Date(n,e.getMonth(),1);u.current={month:t,year:n},D(t),w(n),null==i||i(t,n);const r=k.findIndex(e=>e.days.some(e=>e.date.toDateString()===a.toDateString()));if(-1!==r){const e=r*l,t=O.current;t&&(S(!0),M.current=!0,requestAnimationFrame(()=>{f(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{M.current=!1,S(!1)},200))})}))}else S(!0),M.current=!0,requestAnimationFrame(()=>{q(a,!0),setTimeout(()=>{M.current=!1,S(!1)},200)})},[k,l,i,q]);return r(()=>{Z(B.visibleItems)},[B.visibleItems,Z]),r(()=>{const t=R.current,n=t.getMonth(),a=t.getFullYear(),r=e.getMonth(),o=e.getFullYear();if(n!==r||a!==o){const e=new Date(o,r,1),t=g(r,o);u.current={month:t,year:o},D(t),w(o),null==i||i(t,o),q(e,!0)}R.current=e},[e,i,q]),r(()=>{const e=O.current;if(!e)return;const t=new ResizeObserver(([e])=>{p(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r(()=>{const e=O.current;e&&!I&&c&&requestAnimationFrame(()=>{e&&m>0?(e.scrollTop=m,f(m),H(!0)):e&&H(!0)})},[I,m,c]),r(()=>()=>{P.current&&clearTimeout(P.current)},[]),{scrollTop:v,containerHeight:y,currentMonth:b,currentYear:x,isScrolling:C,virtualData:B,scrollElementRef:O,handleScroll:U,scrollToDate:q,handlePreviousMonth:X,handleNextMonth:G,handleToday:K,setScrollTop:f,setContainerHeight:p,setCurrentMonth:D,setCurrentYear:w,setIsScrolling:E,cache:L.current,scrollElementRefCallback:z,weeksData:k}},Ta=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:r,searchValue:o="",isSearchOpen:l=!1,isEditable:i=!0})=>{const s="buttons"===t,d=e.state.currentView===Y.DAY,{screenSize:c}=ka(),h="mobile"===c,{t:m}=Nt();return g("div",{className:"flex items-center justify-between px-2 pt-1 bg-white dark:bg-gray-900 transition-colors duration-200 shrink-0 border-b "+(d||l?"border-gray-200 dark:border-gray-700":"border-transparent"),children:[u("div",{className:"flex flex-1 items-center mb-1",children:n&&i&&u("button",{onClick:n,className:"flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",title:h?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:u(S,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})})}),u("div",{className:"flex-1 flex justify-center",children:s&&u(Hn,{mode:t,calendar:e})}),!s&&u(Hn,{mode:t,calendar:e}),g("div",{className:`flex ${"select"===t?"ml-2":"flex-1"} items-center justify-end gap-3 mb-1 pb-1 h-6`,children:[u("button",{onClick:r,className:"md:hidden flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",children:u(M,{width:16,height:16})}),g("div",{className:"relative hidden md:block group mt-1",children:[u("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:u("span",{className:"text-gray-400 group-focus-within:text-primary transition-colors",children:u(M,{width:16,height:16})})}),u("input",{type:"text",placeholder:"Search",value:o,onChange:e=>{null==a||a(e.target.value)},className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary transition resize-none w-48"}),o&&u("button",{onClick:()=>{null==a||a("")},className:"absolute inset-y-0 right-0 pr-2 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:g("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},Sa=i(void 0),Ma=({children:e,initialTheme:t="light",onThemeChange:o})=>{const[l,i]=n(t),[s,d]=n("light"),c="auto"===l?s:l;r(()=>{i(t)},[t]);const g=a(e=>{i(e)},[]);r(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";d(t)},n=e.matches?"dark":"light";return d(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),r(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=da(c),n="auto"===l?t:c;e.classList.remove("light","dark"),e.classList.add(n),"auto"===l?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[c,l,s]),r(()=>{o&&o(l,c)},[l,c,o]);const h={theme:l,effectiveTheme:c,setTheme:g};return u(Sa.Provider,{value:h,children:e})},Ia=()=>{const e=l(Sa);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Ha=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Ra=({onClose:e,onCreate:t})=>{const[a,r]=n(""),[o,l]=n(Ha[Math.floor(Math.random()*Ha.length)]),[i,s]=n(!1),[d,c]=n(""),{effectiveTheme:h}=Ia(),{t:m}=Nt(),f="dark"===h,p={default:{picker:{background:f?"#1e293b":"#ffffff",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",borderRadius:"0.5rem",border:f?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:f?"#1e293b":"#ffffff",borderBottom:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:f?"#1e293b":"#ffffff"},controls:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:f?"#374151":"#ffffff",color:f?"#f3f4f6":"#1f2937",border:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:f?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:v(u("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:g("div",{className:"w-full max-w-sm rounded-lg p-6 shadow-xl bg-background animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[u("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:m("createCalendar")}),g("form",{onSubmit:n=>{if(n.preventDefault(),!a.trim())return;const{colors:r,darkColors:l}=J(o),i={id:mt(),name:a.trim(),colors:r,darkColors:l,isVisible:!0,isDefault:!1};t(i),e()},children:[u("div",{className:"mb-4",children:g("div",{className:"flex items-center gap-3",children:[u("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:o}}),u("input",{type:"text",value:a,onChange:e=>r(e.target.value),className:"w-full flex-1 rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 dark:focus:border-primary dark:focus:ring-primary",placeholder:m("calendarNamePlaceholder"),autoFocus:!0})]})}),g("div",{className:"mb-6",children:[u("div",{className:"grid grid-cols-7 gap-6",children:Ha.map(e=>u("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(o===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>l(e)},e))}),g("div",{className:"mt-2 relative",children:[u("button",{type:"button",onClick:()=>{c(o),s(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800 transition-colors focus:outline-none focus:bg-slate-100 dark:focus:bg-slate-800",children:m("customColor")}),i&&u("div",{className:"absolute left-0 top-full z-10001 mt-2",children:u(y,{color:o,onChange:e=>{l(e.hex)},onAccept:()=>{s(!1)},onCancel:()=>{l(d),s(!1)},styles:p})})]})]}),g("div",{className:"flex justify-end space-x-3",children:[u("button",{type:"button",onClick:e,className:zt,children:m("cancel")}),u("button",{type:"submit",disabled:!a.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:m("create")})]})]})]})}),document.body)},Oa=({loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>{const{t:i,locale:s}=Nt(),d=t(()=>xa(new Date),[]),c=t(()=>Ca(a,d),[a,d]),h=e=>Da(e);return n?g("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[u(I,{className:"w-8 h-8 animate-spin mb-2"}),u("span",{children:"Loading..."})]}):0===a.length?r?g("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[u(Pa,{}),u("span",{className:"mt-2 text-sm",children:"string"==typeof l?l:l&&"object"==typeof l?l[s]||l.en||"No results found":i("noResults")||"No results found"})]}):null:u("div",{className:"space-y-6",children:c.map(t=>{const{title:n,colorClass:a}=wa(t.date,d,s,i);return g("div",{children:[u("h3",{className:`px-2 text-sm font-medium mb-4 sticky top-0 bg-white dark:bg-gray-900 py-1 z-10 ${a} border-b border-gray-200 dark:border-gray-700`,children:n}),u("div",{className:"flex flex-col",children:t.events.map(t=>{const n=h(t.start),a=h(t.end),r={hour:"2-digit",minute:"2-digit"},l=t.allDay?i("allDay")||"All Day":n.toLocaleTimeString(s,r),d=t.allDay?"":a.toLocaleTimeString(s,r);return g(e.Fragment,{children:[u("div",{className:"p-2 mx-2 mb-1 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer transition-colors group",onClick:()=>null==o?void 0:o(t),children:g("div",{className:"flex items-stretch gap-3",children:[u("div",{className:"w-1 rounded-full shrink-0",style:{backgroundColor:t.color||"#3b82f6"}}),g("div",{className:"flex-1 min-w-0 flex justify-between items-start",children:[u("div",{className:"font-medium text-black dark:text-white truncate pr-2 text-sm",children:t.title}),g("div",{className:"text-xs flex flex-col items-end shrink-0 leading-tight",children:[u("div",{className:"text-black dark:text-white",children:l}),d&&u("div",{className:"text-gray-500 dark:text-gray-400",children:d})]})]})]})}),u("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},t.id)})})]},t.date.getTime())})})},Pa=()=>u("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:u("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),La=({isOpen:e,onClose:t,loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>u("div",{className:"hidden md:flex relative h-full bg-white dark:bg-gray-900 transition-all duration-300 ease-in-out flex-col border-l border-gray-200 dark:border-gray-700 overflow-hidden select-none "+(e?"w-64":"w-0 border-l-0"),children:u("div",{className:"flex-1 overflow-y-auto min-w-64",children:u(Oa,{loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})})}),ja=({isOpen:e,onClose:t,keyword:n,onSearchChange:a,results:l,loading:i,onResultClick:s,emptyText:d})=>{const c=o(null),{t:h}=Nt();return r(()=>(e?(setTimeout(()=>{var e;null===(e=c.current)||void 0===e||e.focus()},100),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),e&&"undefined"!=typeof window?v(g("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[g("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[u("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:u(H,{className:"w-6 h-6"})}),g("div",{className:"flex-1 relative",children:[u("input",{ref:c,type:"text",placeholder:h("search")||"Search",value:n,onChange:e=>a(e.target.value),className:"w-full pl-3 pr-10 py-2 bg-gray-100 dark:bg-gray-800 border-none rounded-full text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary focus:outline-none"}),n&&u("button",{onClick:()=>a(""),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:u(R,{className:"w-4 h-4"})})]})]}),u("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:u(Oa,{loading:i,results:l,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},Aa=({app:e,anchorRef:a,onClose:l,isOpen:i})=>{const{t:d}=Nt(),[c,h]=n(""),[m,f]=n(0),[y,p]=n(!1),b=o(null),D=o(null);r(()=>{i||p(!1)},[i]),r(()=>{i&&(setTimeout(()=>{var e;return null===(e=b.current)||void 0===e?void 0:e.focus()},50),h(""),f(0))},[i]),r(()=>{const e=e=>{i&&D.current&&!D.current.contains(e.target)&&a.current&&!a.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i,l,a]);const[x,w]=n({top:0,left:0}),[C,E]=n("top"),[k,N]=n(0),T=t(()=>{const e=new Date,t=new Date(e);t.setHours(t.getHours()+1,0,0,0);const n=new Date(t);return n.setHours(n.getHours()+1),{start:t,end:n}},[i]),S=t(()=>{if(!c.trim())return[];const t=[],n=e.getCalendars(),a=e.getAllEvents(),r=c.toLowerCase(),o=a.find(e=>e.title.toLowerCase()===r);let l=null==o?void 0:o.calendarId;if(!l){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);l=e[t].id}else n.length>0&&(l=n[0].id)}const i=n.find(e=>e.id===l),s=(null==i?void 0:i.colors.lineColor)||"#3b82f6";t.push({type:"new",title:c,calendarId:l||"",color:s,start:T.start,end:T.end});const d=new Set;d.add(c.toLowerCase());return a.filter(e=>e.title.toLowerCase().includes(r)&&!d.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{d.add(e.title.toLowerCase());const a=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==a?void 0:a.colors.lineColor)||"#9ca3af",start:T.start,end:T.end})}),t},[c,e,T]);s(()=>{if(i&&a.current&&D.current){const e=a.current.getBoundingClientRect(),t=D.current.offsetHeight,n=340;let r=e.left+e.width/2-n/2;const o=12,l=window.innerWidth;r<o?r=o:r+n>l-o&&(r=l-n-o);const i=e.left+e.width/2;N(i-r);let s=0,d="top";e.top<t+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-t),E(d),w({top:s,left:r}),p(!0)}},[i,a,S]);const M=t=>{if(!t.calendarId)return;const n=mt(),a={id:n,title:t.title,start:he(t.start),end:he(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(n),l()};r(()=>{if(!i)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),f(e=>(e+1)%S.length)):"ArrowUp"===e.key?(e.preventDefault(),f(e=>(e-1+S.length)%S.length)):"Enter"===e.key&&(e.preventDefault(),S[m]&&M(S[m]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i,S,m]);const I=(e,t)=>{const n=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n(e)} - ${n(t)}`};return i?v(g("div",{ref:D,className:"fixed z-1000 w-85 flex flex-col bg-white dark:bg-slate-800 rounded-xl shadow-2xl border border-gray-200 dark:border-slate-700 "+(y?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:x.top,left:x.left,visibility:y?"visible":"hidden"},children:[g("div",{className:"p-4 pb-2",children:[u("div",{className:"mb-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:d("quickCreateEvent")||"Quick Create Event"}),u("div",{className:"relative",children:u("input",{ref:b,type:"text",className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:d("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:c,onChange:e=>h(e.target.value)})})]}),g("div",{className:"flex-1 overflow-y-auto max-h-75 py-1 px-2",children:[0===S.length&&c&&u("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:d("noSuggestions")||"Type to create"}),S.map((e,t)=>g("div",{className:"flex items-center px-4 py-2 cursor-pointer transition-colors rounded-lg "+(t===m?"bg-primary/10 dark:bg-primary/20 ring-1 ring-inset ring-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>M(e),onMouseEnter:()=>f(t),children:[u("div",{className:"w-1 h-8 rounded-full mr-3 shrink-0",style:{backgroundColor:e.color}}),g("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[u("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title}),u("div",{className:"flex",children:u("span",{className:"font-semibold text-[10px] px-1 bg-gray-100 dark:bg-slate-700 rounded text-gray-500 dark:text-gray-400",children:"new"===e.type?d("today"):d("tomorrow")})}),u("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:I(e.start,e.end)})]})]},`${e.type}-${t}`))]}),u("div",{className:"absolute w-3 h-3 bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 rotate-45 -translate-x-1/2 "+("top"===C?"-bottom-1.5 border-b border-r":"-top-1.5 border-t border-l"),style:{left:k}})]}),document.body):null},$a=({checked:e,onChange:t})=>u("div",{className:"w-12 h-7 flex items-center rounded-full p-1 cursor-pointer transition-colors "+(e?"bg-green-500":"bg-gray-300"),onClick:()=>t(!e),children:u("div",{className:"bg-white w-5 h-5 rounded-full shadow-md transform transition-transform "+(e?"translate-x-5":"")})}),za=({date:e,onChange:t})=>{const a=Array.from({length:24},(e,t)=>t),l=Array.from({length:12},(e,t)=>5*t),i=[...a,...a,...a],s=[...l,...l,...l],d=32,c=e.getHours(),h=5*Math.round(e.getMinutes()/5),m=(24+c)*d,v=(12+h/5)*d,[f,y]=n(m),[p,b]=n(v),D=o(null),x=o(null),w=o(null);r(()=>{D.current&&(D.current.scrollTop=m,y(m)),x.current&&(x.current.scrollTop=v,b(v))},[m,v]);const C=(n,a)=>{const r=n.currentTarget;let o=r.scrollTop;if("hour"===a){const e=768;o<320?(o+=e,r.scrollTop=o):o>1600&&(o-=e,r.scrollTop=o),y(o)}else{const e=384;o<160?(o+=e,r.scrollTop=o):o>800&&(o-=e,r.scrollTop=o),b(o)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{((n,a)=>{const r=Math.round(a/d);if("hour"===n){const n=i[r];if(void 0!==n&&n!==e.getHours()){const a=new Date(e);a.setHours(n),t(a)}}else{const n=s[r];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const a=new Date(e);a.setMinutes(n),t(a)}}})(a,o)},150)},E=(e,t)=>{const n=96+e*d+16-(t+112),a=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*a})`,opacity:1-.7*a,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return g("div",{className:"flex h-56 overflow-hidden rounded-lg mt-2 relative ",children:[u("style",{dangerouslySetInnerHTML:{__html:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}}),g("div",{ref:D,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>C(e,"hour"),children:[u("div",{style:{height:96}}),i.map((n,a)=>u("div",{className:"h-8 flex items-center justify-end pr-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setHours(n),t(o),null===(r=D.current)||void 0===r||r.scrollTo({top:a*d,behavior:"smooth"})},children:u("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===c?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:E(a,f),children:n.toString().padStart(2,"0")})},a)),u("div",{style:{height:96}})]}),g("div",{ref:x,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>C(e,"minute"),children:[u("div",{style:{height:96}}),s.map((n,a)=>u("div",{className:"h-8 flex items-center justify-start pl-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setMinutes(n),t(o),null===(r=x.current)||void 0===r||r.scrollTo({top:a*d,behavior:"smooth"})},children:u("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===h?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:E(a,p),children:n.toString().padStart(2,"0")})},a)),u("div",{style:{height:96}})]}),u("div",{className:"absolute top-24 left-2 right-2 h-8 bg-gray-300/20 dark:bg-gray-500/20 pointer-events-none border border-gray-300 dark:border-gray-600 rounded-lg"})]})},Ya=({isOpen:t,onClose:a,onSave:o,draftEvent:l,app:i})=>{const{locale:s,t:d}=Nt(),[c,h]=n(""),[m,f]=n(""),[y,p]=n(!1),[b,D]=n(new Date),[x,w]=n(new Date),[C,E]=n(""),[k,N]=n(new Date),[T,S]=n(new Date),[M,I]=n(null),[H,R]=n(t),[O,P]=n(!1),[L,j]=n(!1);r(()=>{if(!t){P(!0);const e=setTimeout(()=>{R(!1),P(!1)},300);return()=>clearTimeout(e)}R(!0),P(!1)},[t]),r(()=>{if(t&&l){const e=i.getEvents().some(e=>e.id===l.id);j(e)}},[t,l,i]);const A=i.getCalendars(),$=A.map(e=>({label:e.name,value:e.id}));r(()=>{if(t&&A.length>0){A.some(e=>e.id===m)||"blue"!==m&&""!==m||f(A[0].id)}},[A,t,m]),r(()=>(t?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""}),[t]),r(()=>{var e,n;if(t&&l){if(h(l.title||""),f(l.calendarId||(null===(e=A[0])||void 0===e?void 0:e.id)||"blue"),p(l.allDay||!1),l.start)try{const e=fe(l.start);D(e),N(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;D(t),N(t)}if(l.end)try{const e=fe(l.end);w(e),S(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;w(t),S(t)}}else if(t&&!l){f((null===(n=A[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),D(e),N(e),w(new Date(e.getTime()+36e5)),S(e)}},[t,l]);const z=e.useMemo(()=>{if(!t||!l)return!1;let e=new Date(b),n=new Date(x);y&&(e.setHours(0,0,0,0),n.setHours(0,0,0,0));const a=Object.assign(Object.assign({},l),{title:c,calendarId:m,allDay:y,description:C,start:he(e),end:he(n)});return!gt(l,a)},[t,l,c,m,y,b,x,C]);if(!H)return null;const Y=e=>{I(t=>t===e?null:e)},F=e=>e.toLocaleDateString(s,{day:"numeric",month:"short",year:"numeric"}),V=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(b.getHours(),b.getMinutes());const n=e.getTime()-b.getTime();D(e);const a=new Date(x.getTime()+n);w(a)}else{const e=new Date(t);e.setHours(x.getHours(),x.getMinutes()),w(e)}},W=(e,t)=>{"start"===e?N(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):S(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return v(g("div",{className:"fixed inset-0 z-10000 flex items-end pointer-events-none",children:[u("div",{className:"absolute inset-0 bg-black/30 pointer-events-auto transition-opacity duration-300 "+(O?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:a}),g("div",{className:"relative w-full bg-gray-100 dark:bg-gray-800 rounded-t-2xl shadow-xl h-[85vh] flex flex-col pointer-events-auto overflow-hidden "+(O?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[g("div",{className:"flex justify-between items-center p-4 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:[u("button",{onClick:a,className:"text-gray-500 hover:text-gray-700 px-2 py-1",children:d("cancel")}),u("span",{className:"font-semibold text-lg",children:d(L?"editEvent":"newEvent")}),u("button",{onClick:()=>{if(!l)return;let e=new Date(b),t=new Date(x);y&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const n=Object.assign(Object.assign({},l),{title:c,calendarId:m,allDay:y,start:he(e),end:he(t)});o(n)},disabled:!z,className:"font-bold px-2 py-1 transition-colors "+(z?"text-primary":"text-gray-400 cursor-not-allowed opacity-50"),children:d(L?"done":"create")})]}),g("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:u("input",{type:"text",placeholder:d("titlePlaceholder"),value:c,onChange:e=>h(e.target.value),className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:!0})}),A.length>0&&g("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center relative",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),u(gn,{options:$,value:m,onChange:f,registry:i.getCalendarRegistry(),variant:"mobile"})]}),g("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),u($a,{checked:y,onChange:p})]}),g("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[g("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),g("div",{className:"flex space-x-2",children:[u("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-date"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("start-date"),children:F(b)}),!y&&u("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("start-time"),children:$e(b.getHours()+b.getMinutes()/60)})]})]}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===M?"max-h-100":"max-h-0"),children:u("div",{className:"",children:u(ln,{currentDate:b,visibleMonth:k,onDateSelect:e=>V("start",e),onMonthChange:e=>W("start",e),showHeader:!0})})}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===M?"max-h-75":"max-h-0"),children:u("div",{className:"",children:u(za,{date:b,onChange:e=>{const t=x.getTime()-b.getTime();D(e),w(new Date(e.getTime()+t))}})})})]}),g("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[g("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),g("div",{className:"flex space-x-2",children:[u("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-date"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("end-date"),children:F(x)}),!y&&u("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-time"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("end-time"),children:$e(x.getHours()+x.getMinutes()/60)})]})]}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===M?"max-h-100":"max-h-0"),children:u("div",{className:"",children:u(ln,{currentDate:x,visibleMonth:T,onDateSelect:e=>V("end",e),onMonthChange:e=>W("end",e),showHeader:!0})})}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===M?"max-h-75":"max-h-0"),children:u("div",{className:"",children:u(za,{date:x,onChange:e=>{if(e<b){const t=x.getTime()-b.getTime();w(e),D(new Date(e.getTime()-t))}else w(e)}})})})]}),u("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:u("textarea",{placeholder:d("notesPlaceholder"),value:C,onChange:e=>E(e.target.value),className:"w-full bg-transparent text-base placeholder-gray-400 focus:outline-none min-h-20"})})]})]})]}),document.body)},Fa=({locale:e="en-US",messages:n,children:a})=>{const r=t(()=>{if("string"==typeof e){return{code:ce(e)?e:"en-US",messages:void 0}}return e&&!ce(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),o=t(()=>{const e=r.code;return{locale:e,t:(t,a)=>{var o,l,i;let s=null!==(i=null!==(o=null==n?void 0:n[t])&&void 0!==o?o:null===(l=r.messages)||void 0===l?void 0:l[t])&&void 0!==i?i:Et(t,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replace(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:wt,getMonthLabels:Ct,isDefault:!1}},[r,n]);return u(kt.Provider,{value:o,children:a})},Va=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Wa=({locale:e,messages:t,children:n})=>Nt().isDefault?u(Fa,{locale:e,messages:t,children:n}):u(h,{children:n}),Ba=({calendar:e,className:l,style:i,customDetailPanelContent:s,customEventDetailDialog:d,meta:h,search:m})=>{var v,f;const y=e.app,p=y.getCurrentView(),b=p.component,D=y.getSidebarConfig(),x=null!==(v=null==D?void 0:D.enabled)&&void 0!==v&&v,[w,C]=n(0),[E,k]=n(null!==(f=null==D?void 0:D.initialCollapsed)&&void 0!==f&&f),{t:N}=Nt(),[T,S]=n(!1),[M,I]=n(null),[H,R]=n(!1),O=o(null),[P,L]=n(!1),[j,A]=n(!1),[$,z]=n(null),[Y,F]=n(()=>y.getTheme()),[V,W]=n(""),[B,Z]=n(!1),[U,_]=n(!1),[q,X]=n(!1),[G,K]=n([]);r(()=>{const e=()=>{L(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),r(()=>{var e;if(!V.trim())return Z(!1),K([]),void y.highlightEvent(null);const t=null!==(e=null==m?void 0:m.debounceDelay)&&void 0!==e?e:300,n=setTimeout(()=>c(void 0,void 0,void 0,function*(){var e;X(!0),Z(!0);try{let t=[];if(null==m?void 0:m.customSearch){const e=y.getEvents().map(e=>{var t;return Object.assign(Object.assign({},e),{color:(null===(t=y.getCalendarRegistry().get(e.calendarId||""))||void 0===t?void 0:t.colors.lineColor)||y.getCalendarRegistry().resolveColors().lineColor})});t=m.customSearch({keyword:V,events:e})}else if(null==m?void 0:m.onSearch)t=yield m.onSearch(V);else{const e=V.toLowerCase();t=y.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var t;return Object.assign(Object.assign({},e),{color:(null===(t=y.getCalendarRegistry().get(e.calendarId||""))||void 0===t?void 0:t.colors.lineColor)||y.getCalendarRegistry().resolveColors().lineColor})})}K(t),null===(e=null==m?void 0:m.onSearchStateChange)||void 0===e||e.call(m,{keyword:V,loading:!1,results:t})}catch(e){console.error("Search failed",e),K([])}finally{X(!1)}}),t);return()=>clearTimeout(n)},[V,m,y]),r(()=>{B||y.highlightEvent(null)},[B,y]);const Q=e=>{let t;t=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):fe(e.start),y.setCurrentDate(t),y.highlightEvent(e.id),U&&_(!1)};r(()=>{var e;k(null!==(e=null==D?void 0:D.initialCollapsed)&&void 0!==e&&e)},[null==D?void 0:D.initialCollapsed]),r(()=>{const e=y.subscribeThemeChange(e=>{F(e)});return()=>{e()}},[y]);const te=a(e=>{y.setTheme(e)},[y]),ne=a(()=>{C(e=>e+1)},[]),ae=t(()=>y.getCalendars(),[y,w,e]),re=a((e,t)=>{y.setCalendarVisibility(e,t),ne()},[y,ne]),oe=a(e=>{y.setAllCalendarsVisibility(e),ne()},[y,ne]),le=a(()=>{if("modal"===(D.createCalendarMode||"inline"))return void S(!0);const e=Va[Math.floor(Math.random()*Va.length)],{colors:t,darkColors:n}=J(e),a=mt(),r={id:a,name:N("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};y.createCalendar(r),I(a),ne()},[y,D.createCalendarMode,N,ne]),ie=a(e=>{var t,n;if(!y.state.readOnly){if(P){const e=new Date;e.setMinutes(0,0,0),e.setHours(e.getHours()+1);const a=new Date(e);a.setHours(a.getHours()+1);const r={id:mt(),title:"",start:he(e),end:he(a),calendarId:(null===(t=y.getCalendars().find(e=>!1!==e.isVisible))||void 0===t?void 0:t.id)||(null===(n=y.getCalendars()[0])||void 0===n?void 0:n.id)};return z(r),void A(!0)}x?H?R(!1):(O.current=e.currentTarget,R(!0)):le()}},[x,P,H,le,y]),se=o(null),de=d||(y.getUseEventDetailDialog()?In:void 0),ce={app:y,config:p.config||{},customDetailPanelContent:s,customEventDetailDialog:de,switcherMode:y.state.switcherMode,calendarRef:se,meta:h},ue={app:y,calendars:ae,toggleCalendarVisibility:re,toggleAll:oe,isCollapsed:E,setCollapsed:k,renderCalendarContextMenu:D.renderCalendarContextMenu,createCalendarMode:D.createCalendarMode,renderCreateCalendarDialog:D.renderCreateCalendarDialog,editingCalendarId:M,setEditingCalendarId:I,onCreateCalendar:le},ge=ee(null==D?void 0:D.width,"240px"),me=y.getCalendarHeaderConfig(),ve={calendar:y,switcherMode:y.state.switcherMode,onAddCalendar:ie,onSearchChange:W,onSearchClick:()=>{W(""),_(!0)},searchValue:V,isSearchOpen:B,isEditable:!y.state.readOnly},ye=y.getCustomMobileEventRenderer()||Ya;return u(Ma,{initialTheme:Y,onThemeChange:te,children:g("div",{className:`calendar-container relative flex flex-row h-full overflow-hidden select-none ${null!=l?l:""}`,style:Object.assign({height:800},i),children:[x&&u("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:ge},children:x?D.render?D.render(ue):u(un,Object.assign({},ue)):null}),g("div",{className:"flex flex-col flex-1 h-full overflow-hidden relative z-10 bg-white dark:bg-gray-900 transition-all duration-250 ease-in-out border-l "+(E?"border-gray-200 dark:border-gray-700 shadow-xl":"border-transparent"),style:{marginLeft:x?E?"50px":ge:0},children:[!1===me?null:"function"==typeof me?me(ve):u(Ta,Object.assign({},ve)),g("div",{className:"flex-1 overflow-hidden relative",ref:se,children:[g("div",{className:"calendar-renderer h-full relative flex flex-row",children:[u("div",{className:"flex-1 h-full overflow-hidden",children:u(b,Object.assign({},ce))}),u(La,{isOpen:B,onClose:()=>{Z(!1),W(""),y.highlightEvent(null)},loading:q,results:G,keyword:V,onResultClick:Q,emptyText:null==m?void 0:m.emptyText})]}),u(ja,{isOpen:U,onClose:()=>{_(!1),W(""),y.highlightEvent(null)},keyword:V,onSearchChange:W,results:G,loading:q,onResultClick:Q,emptyText:null==m?void 0:m.emptyText})]})]}),u(Aa,{app:y,anchorRef:O,isOpen:H,onClose:()=>R(!1)}),u(ye,{isOpen:j,onClose:()=>{A(!1),z(null)},onSave:e=>{y.addEvent(e),A(!1),z(null)},draftEvent:$,app:y}),T&&(D.renderCreateCalendarDialog?D.renderCreateCalendarDialog({onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ne()}}):u(Ra,{onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ne()}}))]})})},Za=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return u(Wa,{locale:a.state.locale,messages:n,children:u(Ba,Object.assign({},e))})},Ua=({originalComponent:e,app:n,config:r,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i,switcherMode:s,meta:d})=>{const c=n.getPlugin("events"),g=r.enableDrag?n.getPlugin("drag"):void 0,h=n.getCurrentDate(),m=n.state.currentView,v=n.getEvents(),f=a(e=>{c?c.update(e.id,e):n.updateEvent(e.id,e)},[c,n]),y=a(e=>{c?c.delete(e):n.deleteEvent(e)},[c,n]),p=a(e=>{c?c.add(e):n.addEvent(e)},[c,n]),b=a(e=>{n.setCurrentDate(e)},[n]),D=a(e=>{n.changeView(e)},[n]),x=t(()=>{const e=r.viewConfig||{};return g&&Object.assign(e,r.dragConfig||{}),c&&Object.assign(e,r.eventsConfig||{}),e},[r,g,c]),w=t(()=>({app:n,currentDate:h,currentView:m,events:v,onEventUpdate:f,onEventDelete:y,onEventCreate:p,onDateChange:b,onViewChange:D,config:x}),[n,h,m,v,f,y,p,b,D,x]),C=t(()=>{const e={currentDate:h,events:v,setEvents:e=>{v.forEach(e=>y(e.id)),e.forEach(e=>p(e))},updateEvent:f,deleteEvent:y,addEvent:p,goToPrevious:()=>{const e=new Date(h);switch(m){case Y.DAY:e.setDate(e.getDate()-1);break;case Y.WEEK:e.setDate(e.getDate()-7);break;case Y.MONTH:e.setMonth(e.getMonth()-1)}b(e)},goToNext:()=>{const e=new Date(h);switch(m){case Y.DAY:e.setDate(e.getDate()+1);break;case Y.WEEK:e.setDate(e.getDate()+7);break;case Y.MONTH:e.setMonth(e.getMonth()+1)}b(e)},goToToday:()=>{b(new Date)},changeView:D,selectDate:b};return Object.assign(Object.assign({calendar:e},w),{eventsService:c,dragService:g,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i,switcherMode:s,meta:d})},[h,v,m,f,y,p,b,D,w,c,g,o,l,i,s,d]);return u(e,Object.assign({},C))};function _a(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:Te(e.start),_endHour:e.allDay?0:Fe(e)})}function qa(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:Te(e.start)}function Xa(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:Fe(e)}const Ga=.25,Ka=.5,Ja=25,Qa=1,er=.9;class tr{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(_a);this.clearAllParentChildRelations(n);const a=new Map,r=n.filter(e=>!e.allDay);if(0===r.length)return a;const o=this.groupOverlappingEvents(r);for(let e=0;e<o.length;e++){const n=o[e];1===n.length?this.setSingleEventLayout(n[0],a):this.calculateComplexGroupLayout(n,a,t)}return a}static clearAllParentChildRelations(e){for(const t of e)t.parentId=void 0,t.children=[]}static setParentChildRelation(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}static eventsOverlap(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(qa(e)<Xa(t)&&qa(t)<Xa(e))}static groupOverlappingEvents(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a],o=[a];for(n.add(a.id);o.length>0;){const t=o.shift();for(const a of e)n.has(a.id)||this.eventsOverlap(t,a)&&(r.push(a),o.push(a),n.add(a.id))}t.push(r)}return t}static setSingleEventLayout(e,t){t.set(e.id,{id:e.id,left:0,width:100-er,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=qa(e),a=qa(t);if(n!==a)return n-a;return Xa(t)-qa(t)-(Xa(e)-qa(e))}),r=this.analyzeParallelGroups(a),o=this.buildNestedStructure(r,e);this.calculateLayoutFromStructure(o,t,n)}static analyzeParallelGroups(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a];n.add(a.id);for(const t of e){if(n.has(t.id))continue;Math.abs(qa(a)-qa(t))<=Ga&&(r.push(t),n.add(t.id))}r.sort((e,t)=>qa(e)-qa(t));const o={events:r,startHour:Math.min(...r.map(e=>qa(e))),endHour:Math.max(...r.map(e=>Xa(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}static shouldBeParallel(e,t){if(!this.eventsOverlap(e,t))return!1;const n=Math.abs(qa(e)-qa(t));if(n<=Ga)return!0;if(n>Ga&&n<Ka)return!0;return!!this.checkExtendedEventParallel(e,t)}static checkExtendedEventParallel(e,t){return!!this.eventsOverlap(e,t)&&(!!this.isExtendedEventParallel(e,t)||!!this.isExtendedEventParallel(t,e))}static isExtendedEventParallel(e,t){const n=Xa(e)-qa(e);if(n<1.25)return!1;const a=qa(e)+.4*n,r=qa(t)>=a,o=this.eventsOverlap(e,t);return r&&o}static buildNestedStructure(e,t){const n=[],a=new Map,r=new Map;t.forEach(e=>r.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:r.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),a.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],l=o.events.map(e=>r.get(e.id));let i=!1;for(let s=n-1;s>=0&&!i;s--){const n=e[s],d={events:n.events.map(e=>r.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(this.canGroupContain(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=this.optimizeChildAssignments(l,d,t);for(const t of e){const e=a.get(t.child.id),n=a.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}i=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),this.rebalanceLoadByGroups(e,n),o}static findAlternateBranchRoot(e,t,n){const a=n.get(e.id);if(!a)return null;let r=a;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const o=r.parent;if(!o)return null;const l=o.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,s=null;for(const e of l){const t=this.calculateBranchLoad(e);t<i&&(i=t,s=e)}return s?s.event:null}static calculateBranchLoad(e){let t=0;function n(e){t++;for(const t of e.children)n(t)}for(const t of e.children)n(t);return t}static canGroupContain(e,t){const n=t.startHour-e.startHour;if(this.checkLoadBalanceParallel(e,t))return!1;if(n<Ka)return!1;let a=!1;for(const n of e.events){for(const e of t.events)if(this.canEventContain(n,e)){a=!0;break}if(a)break}return a}static checkLoadBalanceParallel(e,t){for(const n of e.events)for(const e of t.events){if(!this.eventsOverlap(n,e))continue;const t=Math.abs(qa(e)-qa(n));if(t<=Ga)return!0;if(t>Ga&&t<Ka)return!0}return!1}static canEventContain(e,t){const n=qa(e)<=qa(t)&&Xa(e)>=Xa(t),a=qa(e)<=qa(t)&&qa(t)<Xa(e)&&this.eventsOverlap(e,t);return n||a}static optimizeChildAssignments(e,t,n){const a=[];if(1===e.length){const r=this.findBestParentInGroup(e[0],t,n);return r&&(a.push({child:e[0],parent:r}),this.setParentChildRelation(r,e[0])),a}if(1===t.events.length){const n=t.events[0];for(const t of e)this.canEventContain(n,t)&&(a.push({child:t,parent:n}),this.setParentChildRelation(n,t));return a}const r=t.events.filter(t=>e.every(e=>this.canEventContain(t,e)));if(0===r.length){for(const r of e){const o=this.findBestParentInGroup(r,t,n);if(o)a.push({child:r,parent:o}),this.setParentChildRelation(o,r);else{const t=e.find(e=>e.id!==r.id&&this.eventsOverlap(e,r));if(t){const e=this.buildTempNodeMap(n),o=this.findAlternateBranchRoot(t,Array.from(e.values()),e);o&&(a.push({child:r,parent:o}),this.setParentChildRelation(o,r))}}}return a}const o=[...e].sort((e,t)=>{const n=Xa(e)-qa(e);return Xa(t)-qa(t)-n});if(o.length%r.length===0){const e=o.length/r.length;for(let t=0;t<r.length;t++){const n=r[t],l=o.slice(t*e,(t+1)*e);for(const e of l)a.push({child:e,parent:n}),this.setParentChildRelation(n,e)}return a}for(let e=0;e<o.length;e++){const t=o[e],n=this.findParentWithMinLoadFromEvents(t,r,o);n&&(a.push({child:t,parent:n}),this.setParentChildRelation(n,t))}return a}static buildTempNodeMap(e){const t=new Map;for(const n of e){const e={event:n,children:[],parent:null,depth:0,isProcessed:!1};t.set(n.id,e)}for(const n of e)if(n.parentId){const e=t.get(n.id),a=t.get(n.parentId);e&&a&&(e.parent=a,e.depth=a.depth+1,a.children.push(e))}return t}static findParentWithMinLoadFromEvents(e,t,n){if(0===t.length)return null;let a=1/0,r=[];for(const e of t){const t=e.children.length;t<a?(a=t,r=[e]):t===a&&r.push(e)}const o=r.map(e=>e.children).flat();return Xa(e)-qa(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?Xa(t)-qa(t):0}))?r[0]:r[r.length-1]}static findBestParentInGroup(e,t,n){const a=t.events.filter(t=>this.canEventContain(t,e));if(0===a.length)return null;if(1===a.length)return a[0];const r=a.map(e=>({parent:e,load:e.children.length,hasParallelSibling:!1}));for(const t of r)for(const a of t.parent.children){const r=n.find(e=>e.id===a);if(r&&this.shouldBeParallel(e,r)){t.hasParallelSibling=!0;break}}r.sort((t,n)=>{if(t.load!==n.load)return t.load-n.load;if(t.hasParallelSibling!==n.hasParallelSibling)return t.hasParallelSibling?-1:1;if(t.load!==n.load)return t.load-n.load;return Math.abs(qa(e)-qa(t.parent))-Math.abs(qa(e)-qa(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-er;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-Qa*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+Qa);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,Ja),t,n)})}}static calculateNodeLayoutWithVirtualParallel(e,t,n,a,r={}){let o=e.depth*this.getIndentStepPercent(r.viewType);if(e.isProcessed){const t=this.findBranchRootIndent(e,r.viewType);null!==t&&(o=t)}let l=0;const i="day"===r.viewType;1===e.depth?l=i?.5:1.5:2===e.depth?l=i?-.01:-1:e.depth>=3&&(l=i?.55:-3.5);const s=t+o+l;let d=n-(o+l);if(s+d>t+n&&(d=t+n-s),a.set(e.event.id,{id:e.event.id,left:s,width:d,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:o*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),0===e.children.length)return;const c=[...e.children].sort((e,t)=>{const n=Xa(e.event)-qa(e.event);return Xa(t.event)-qa(t.event)-n});if(1===c.length)this.calculateNodeLayoutWithVirtualParallel(c[0],s,d,a,r);else{this.shouldChildrenBeParallel(c.map(e=>e.event))?this.calculateParallelChildrenLayout(c,s,d,a,r):c.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,s,d,a,r)})}}static calculateParallelChildrenLayout(e,t,n,a,r={}){const o=e.length,l=e[0].depth,i=l*this.getIndentStepPercent(r.viewType);let s;const d="day"===r.viewType;s=1===l?d?.5:1.5:2===l?d?-.01:-1:d?.55:-3.5;const c=t+i+s,u=n-(i+s);if(u<=0)return void e.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,t,n,a,r)});let g;g=1===l?Qa*(d?.15:.3):Qa*(d?.1:.2);const h=(u-g*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(h+g);if(a.set(e.event.id,{id:e.event.id,left:n,width:h,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>{const n=Xa(e.event)-qa(e.event);return Xa(t.event)-qa(t.event)-n});if(1===t.length)this.calculateNodeLayoutWithVirtualParallel(t[0],n,h,a,r);else{this.shouldChildrenBeParallel(t.map(e=>e.event))?this.calculateParallelChildrenLayout(t,n,h,a,r):t.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,n,h,a,r)})}}})}static findBranchRootIndent(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;if(1===n.depth){return n.depth*this.getIndentStepPercent(t)}return null}static shouldChildrenBeParallel(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(this.shouldBeParallel(e[t],e[n]))return!0;return!1}static calculateEventImportance(e){const t=Xa(e)-qa(e);return Math.max(.1,Math.min(1,t/4))}static countDescendants(e){let t=0;for(const n of e.children)t+=1+this.countDescendants(n);return t}static findTransferableLeaf(e,t){const n=[];return this.collectLeaves(e,n),n.find(e=>this.canEventContain(t.event,e.event))||n[0]}static collectLeaves(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>this.collectLeaves(e,t))}static transferNode(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children;let a=null;for(const t of n){if(this.shouldBeParallel(e.event,t.event))break;if(this.canEventContain(t.event,e.event)){a=t;break}}a?(e.parent=a,e.depth=a.depth+1,a.children.push(e),this.setParentChildRelation(a.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),this.setParentChildRelation(t.event,e.event))}static calculateParentLoads(e,t){var n,a;const r=[],o=null===(a=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===a?void 0:a.depth;if(void 0===o)return r;const l=t.filter(e=>e.depth===o);for(const e of l){const t=this.countDescendants(e);r.push({node:e,load:t})}return r.sort((e,t)=>t.load-e.load),r}static needsRebalancing(e){if(e.length<2)return!1;return e[0].load-e[e.length-1].load>=2}static rebalanceGroupLoad(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],a=e[e.length-1];if(n.load-a.load<2)break;const r=this.findTransferableLeaf(n.node,a.node);if(!r)break;this.transferNode(r,a.node),n.load--,a.load++,t++}}static rebalanceLoadByGroups(e,t){for(let n=e.length-1;n>=1;n--){const a=e[n].events.map(e=>t.find(t=>t.event.id===e.id)),r=this.calculateParentLoads(a,t);this.needsRebalancing(r)&&this.rebalanceGroupLoad(r)}}}const nr={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>je(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const ar=e=>{const{viewType:r,onEventsUpdate:l}=e,i=r===Y.MONTH,s=o({active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,resizeDirection:null,hourOffset:null,duration:0,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}),d=o({x:0,y:0}),c=t(()=>i?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1},[i]),[u,g]=n(c),h=t(()=>function(e,t){let n=null,a=0;const r=function(...r){const o=Date.now(),l=t-(o-a);l<=0||l>t?(n&&(clearTimeout(n),n=null),a=o,e.apply(this,r)):n||(n=setTimeout(()=>{a=Date.now(),n=null,e.apply(this,r)},l))};return r.cancel=()=>{n&&(clearTimeout(n),n=null),a=0},r}((e,t)=>l(e,"resize"===t),i?16:8),[i,l]),m=a(()=>{g(i?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1}),s.current={active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,duration:0,resizeDirection:null,hourOffset:null,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}},[i]);return{dragRef:s,currentDragRef:d,dragState:u,setDragState:g,resetDragState:m,throttledSetEvents:h}},rr={renderAllDayContent:({title:e,color:t})=>g("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[u(O,{className:"h-3 w-3 mr-1 text-white"}),u("div",{className:"font-medium text-xs truncate pr-1 text-white",children:e})]}),renderRegularContent:({drag:e,title:t,layout:n,formatTime:a,getLineColor:r,getDynamicPadding:o,color:l,isMobile:i})=>g(h,{children:[u("div",{className:Kt,style:{backgroundColor:r(l||"blue")}}),g("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${o(e)}`,children:[u("div",{className:"font-medium text-xs truncate pr-1 text-white",style:{lineHeight:e.endHour-e.startHour<=.25?"1.2":"normal"},children:t}),!e.allDay&&e.endHour-e.startHour>.5&&g("div",{className:"text-xs truncate time-display text-white opacity-90",children:[a(e.startHour)," - ",a(e.endHour)]})]}),i&&g(h,{children:[u("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:r(l||"blue")}}),u("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:r(l||"blue")}})]})]}),renderDefaultContent:({drag:e,title:t,allDay:n})=>n?g("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0",children:[u("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 002 2z"})}),u("div",{className:"font-medium text-xs truncate pr-1",style:{lineHeight:1.2},children:t})]}):g(h,{children:[u("div",{className:"absolute left-0.5 top-1 bottom-1 w-0.5 rounded-full bg-primary"}),u("div",{className:"h-full flex flex-col overflow-hidden pl-3 p-1",children:u("div",{className:"font-medium text-xs truncate pr-1 text-primary",children:t})})]})},or=({drag:e,color:t,title:n,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,renderer:s=rr,isMobile:d})=>{const{t:c}=Nt(),g=n||c(r?"newAllDayEvent":"newEvent");return u("div",{className:"drag-indicator-content",children:t?r?s.renderAllDayContent({drag:e,color:t,title:g,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d}):s.renderRegularContent({drag:e,color:t,title:g,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d}):s.renderDefaultContent({drag:e,color:t,title:g,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d})})},lr=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:r})=>{const{t:o}=Nt(),l=(()=>{if(t)return{title:o("newEvent"),icon:u(P,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&r){const t=Ce(a,r)+1;return{title:e.title.replace(/ \(\d+天\)$/,""),showDateRange:!0,duration:t}}return{title:e.title,showDateRange:!1}})();return g("div",{className:"flex items-center space-x-2 text-white text-xs font-medium rounded-sm",children:[u("div",{className:"shrink-0",children:l.icon}),u("div",{className:"flex-1 min-w-0",children:u("div",{className:"truncate font-medium",children:l.title})})]})},ir=e=>{let t,n;return"touches"in e&&e.touches.length>0?(t=e.touches[0].clientX,n=e.touches[0].clientY):"changedTouches"in e&&e.changedTouches.length>0?(t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY):(t=e.clientX,n=e.clientY),{clientX:t,clientY:n}},sr=n=>{const r=t(()=>Object.assign(Object.assign(Object.assign({},nr),n),{getLineColor:e=>{var t;return n.getLineColor?n.getLineColor(e):je(e,null===(t=n.app)||void 0===t?void 0:t.getCalendarRegistry())}}),[n]),{viewType:l}=r,i=l===Y.MONTH||l===Y.YEAR,s=(e=>{const{calendarRef:n,allDayRowRef:r,viewType:o,HOUR_HEIGHT:l=72,FIRST_HOUR:i=0,LAST_HOUR:s=24,TIME_COLUMN_WIDTH:d=80,isMobile:c}=e,u=o===Y.MONTH,g=o===Y.WEEK,h=a(e=>{if(u||!n.current)return i;const t=n.current.querySelector(".calendar-content");if(!t)return i;const a=t.getBoundingClientRect(),r=t.scrollTop,o=window.getComputedStyle(t),d=parseInt(o.paddingTop,10)||0,c=(e-a.top+r-d)/l+i;return Math.max(i,Math.min(s,c))},[n,i,l,s,u]),m=a(e=>{if(u||!n.current)return 0;const t=n.current.querySelector(".calendar-content");if(!t)return 0;const a=t.getBoundingClientRect(),r=t.scrollLeft,o=a.width;if(g){const t=(c?1.75*o:o)/7,n=e-a.left+r,l=Math.floor(n/t);return Math.max(0,Math.min(6,l))}return 0},[n,u,g,c]),v=a(e=>{if(u||!n.current)return;const t=n.current.querySelector(".calendar-content");if(!t)return;const a=t.getBoundingClientRect();e<a.top?t.scrollTop+=e-a.top:e+40>a.bottom&&(t.scrollTop+=e+40-a.bottom)},[n,u]),f=a(e=>!(u||!(null==r?void 0:r.current))&&e<=r.current.getBoundingClientRect().bottom,[r,u]),y=t(()=>864e5,[]);return{pixelYToHour:h,getColumnDayIndex:m,checkIfInAllDayArea:f,handleDirectScroll:v,daysDifference:a((e,t)=>Ce(e,t),[]),addDaysToDate:a((e,t)=>Ee(e,t),[]),getTargetDateFromPosition:a((e,t)=>{if(o!==Y.MONTH&&o!==Y.YEAR||!n.current)return null;const a=document.elementFromPoint(e,t);if(!a)return null;let r=a,l=0;for(;r&&!r.hasAttribute("data-date")&&l<10;)r=r.parentElement,l++;if(r&&r.hasAttribute("data-date")){const e=r.getAttribute("data-date");if(e)return new Date(e+"T00:00:00")}return null},[n,o]),ONE_DAY_MS:y}})(r),d=ar(r),c=(t=>{const{t:n,locale:r}=Nt(),{calendarRef:l,allDayRowRef:i,viewType:s,getLineColor:d,getDynamicPadding:c,renderer:u,HOUR_HEIGHT:g=72,FIRST_HOUR:h=0,TIME_COLUMN_WIDTH:m=80,ALL_DAY_HEIGHT:v=60,app:f,isMobile:y}=t,p=s===Y.MONTH||s===Y.YEAR,b=s===Y.DAY,D=o(null),x=o(null),w=o(null),C=a(()=>{x.current&&(x.current.unmount(),x.current=null),D.current&&(D.current.remove(),D.current=null),w.current=null},[]),E=a((t,a,o,s,E)=>{var k,N,T,S,M,I,H,R,O;C();const P=document.createElement("div");if(P.style.position=p?"fixed":"absolute",P.style.pointerEvents="none",P.style.zIndex="1000",p){let l,i;if(P.style.opacity="0.9",E){const e=E.getBoundingClientRect(),n=null!==(N=null!==(k=t.currentSegmentDays)&&void 0!==k?k:t.eventDurationDays)&&void 0!==N?N:1;l=e.width/n,i=e.height,P.className=`rounded-sm shadow-sm ${E.className}`}else l=120,i=22,P.className="rounded text-xs px-2 py-1";P.style.width=`${l}px`,P.style.height=`${i}px`,P.style.left=t.startX-l/2+"px",P.style.top=t.startY-i/2+"px",document.body.appendChild(P),x.current=z(P);const s=he(new Date),d=t.originalEvent||{id:String(Date.now()),color:a||"blue",title:o||n("newEvent"),start:s,end:s,allDay:!1,day:0};x.current.render(e.createElement(Fa,{locale:r},e.createElement(lr,{event:d,isCreating:"create"===t.mode,targetDate:t.targetDate||null,startDate:t.originalStartDate||null,endDate:t.originalEndDate||null})))}else{if(E){const e=E.getBoundingClientRect();let n;if(n=t.allDay?null===(T=null==i?void 0:i.current)||void 0===T?void 0:T.getBoundingClientRect():null===(M=null===(S=l.current)||void 0===S?void 0:S.querySelector(".calendar-content"))||void 0===M?void 0:M.getBoundingClientRect(),n){if(t.allDay&&b)P.style.left=`${m}px`,P.style.top=E.offsetTop-2+"px",P.style.width=`calc(100% - ${m}px - 2px)`,P.style.height=`${e.height}px`;else if(t.allDay&&!b){const n=`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=`calc(${n} * ${t.dayIndex})`,P.style.top=E.offsetTop-2+"px",P.style.width=`calc(${n} - 2px)`,P.style.height=`${e.height}px`}else{const a=(t.startHour-h)*g,r=null===(I=l.current)||void 0===I?void 0:I.querySelector(".calendar-content"),o=(null==r?void 0:r.scrollLeft)||0;P.style.left=`${e.left-n.left+o}px`,P.style.top=`${a+3}px`,P.style.width=`${e.width}px`,P.style.height=`${e.height}px`}P.className=E.className,P.style.opacity="0.8",P.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}}else if(t.allDay)if(P.style.top="2px",P.style.height=v-4+"px",P.style.marginBottom="3px",P.className="rounded-xl shadow-sm",b)P.style.left=`${m}px`,P.style.width=`calc(100% - ${m}px - 2px)`;else{const e=`calc(${y?"175%":"100%"} / 7)`;P.style.left=`calc(${e} * ${t.dayIndex})`,P.style.width=`calc(${e} - 2px)`}else{const e=(t.startHour-h)*g,n=(t.endHour-t.startHour)*g;if(P.style.top=`${e+3}px`,P.style.height=n-4+"px",P.style.color="#fff",P.className="rounded-sm shadow-sm",s){if(b)P.style.left=`${m}px`,P.style.width=`calc(((100% - ${m}px) * ${s.width/100}) - 3px)`;else{const e=`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=`calc((${e} * ${t.dayIndex}) + (${e} * ${s.left/100}))`,P.style.width=`calc((${e} * ${(s.width-1)/100}))`}P.style.zIndex=String(1e3)}else{const e=b?`calc(100% - ${m}px)`:`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=b?`${m}px`:`calc(${e} * ${t.dayIndex})`,P.style.width=`calc(${e} - 3px)`}}t.allDay?null===(H=null==i?void 0:i.current)||void 0===H||H.appendChild(P):null===(O=null===(R=l.current)||void 0===R?void 0:R.querySelector(".calendar-content"))||void 0===O||O.appendChild(P),w.current={drag:t,color:a,title:o,layout:s},x.current=z(P),x.current.render(e.createElement(Fa,{locale:r},e.createElement(or,{drag:t,color:a,title:o,layout:s,allDay:t.allDay,formatTime:$e,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}a?(P.style.backgroundColor=Le(a,null==f?void 0:f.getCalendarRegistry()),P.style.color=Pe(a,null==f?void 0:f.getCalendarRegistry())):P.className+=" bg-primary/10 text-primary border border-dashed border-primary/50",D.current=P},[C,p,b,i,l,$e,d,c,u,m,v,h,g]),k=a((...t)=>{var n,a;const o=D.current;if(o)if(p){const[e,n]=t,a=parseFloat(o.style.width)||120,r=parseFloat(o.style.height)||22;requestAnimationFrame(()=>{o.style.left=e-a/2+"px",o.style.top=n-r/2+"px",o.style.transition="none"})}else{const[s,f,p,D=!1,C]=t;if(D&&o.parentElement!==(null==i?void 0:i.current))null===(n=null==i?void 0:i.current)||void 0===n||n.appendChild(o);else if(!D){const e=null===(a=l.current)||void 0===a?void 0:a.querySelector(".calendar-content");o.parentElement!==e&&(null==e||e.appendChild(o))}if(D){if(b)o.style.left=`${m}px`,o.style.width=`calc(100% - ${m}px - 2px)`;else{const e=`calc(${y&&!b?"175%":"100%"} / 7)`;o.style.left=`calc(${e} * ${s})`,o.style.width=`calc(${e} - 2px)`,o.style.top="2px"}o.style.height=v-4+"px",o.style.marginBottom="3px",o.className=o.className.replace("rounded-sm","rounded-xl")}else{const e=(f-h)*g,t=(p-f)*g;o.style.top=`${e+3}px`,o.style.height=t-4+"px",o.style.marginBottom="0",o.className=o.className.replace("rounded-xl","rounded-sm");const n=y&&!b?"175%":"100%";if(C){if(b)o.style.left=`${m}px`,o.style.width=`calc(((100% - ${m}px) * ${C.width/100}) - 3px)`;else{const e=`calc(${n} / 7)`;o.style.left=`calc((${e} * ${s}) + (${e} * ${C.left/100}))`,o.style.width=`calc((${e} * ${(C.width-1)/100}))`}o.style.zIndex=String(C.zIndex+10)}else{const e=b?`calc(100% - ${m}px)`:`calc(${n} / 7)`;o.style.left=b?`${m}px`:`calc(${e} * ${s})`,o.style.width=`calc(${e} - 3px)`}}if(o.style.cursor="grabbing",x.current&&w.current){const t=Object.assign(Object.assign({},w.current.drag),{dayIndex:s,startHour:f,endHour:p,allDay:D});w.current.drag=t,x.current.render(e.createElement(Fa,{locale:r},e.createElement(or,{drag:t,color:w.current.color,title:w.current.title,layout:C||w.current.layout,allDay:D,formatTime:$e,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}}},[p,i,$e,l,b,v,m,h,g,d,c,u]);return{dragIndicatorRef:D,reactRootRef:x,removeDragIndicator:C,createDragIndicator:E,updateDragIndicator:k}})(r),u=(e=>{const{t:t}=Nt(),{options:n,common:r,state:o,manager:l}=e,{viewType:i,onEventsUpdate:s,onEventCreate:d,onEventEdit:c,calculateNewEventLayout:u,calculateDragLayout:g,currentWeekStart:h,events:m,FIRST_HOUR:v=0,LAST_HOUR:f=24,MIN_DURATION:y=.25,app:p}=n,{dragRef:b,currentDragRef:D,setDragState:x,resetDragState:w,throttledSetEvents:C}=o,{removeDragIndicator:E,createDragIndicator:k,updateDragIndicator:N}=l,{pixelYToHour:T,getColumnDayIndex:S,checkIfInAllDayArea:M,handleDirectScroll:I,daysDifference:H,addDaysToDate:R,getTargetDateFromPosition:O}=r,P=i===Y.MONTH||i===Y.YEAR,L=i===Y.DAY,j=864e5,A=(e,t,n=!1)=>{const a=new Date(e);a.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);let o=Math.floor((r.getTime()-a.getTime())/j);if(o<=0)return 0;if(!n&&1===o){const n=0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds(),a=t.getTime()-e.getTime();if(n&&a<j)return 0}return o},$=a(e=>{var t,n;const a=null==p?void 0:p.getReadOnlyConfig(),r=!1!==(null==a?void 0:a.draggable),o=!(null==p?void 0:p.state.readOnly),l=b.current;if(!l)return;if("move"===l.mode&&!r)return;if(("resize"===l.mode||"create"===l.mode)&&!o)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:i,clientY:s}=ir(e);if(!l||!l.active)return;if("move"===l.mode&&!l.indicatorVisible){if(Math.hypot(i-l.startX,s-l.startY)<3)return;k(l,l.calendarId,l.title,null,l.sourceElement||void 0),l.indicatorVisible=!0}"resize"===l.mode?l.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing";const d=M(s),c=L?l.dayIndex:S(i);if(d){if(!l.allDay){l.allDay=!0,l.startHour=0,l.endHour=0,l.eventDate=h?tt(h,c):new Date,E(),l.indicatorVisible=!1;const e=null==m?void 0:m.find(e=>e.id===l.eventId);k(l,null==e?void 0:e.calendarId,null==e?void 0:e.title),l.sourceElement=null,l.indicatorVisible=!0}l.dayIndex=c,x(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:0,endHour:0,allDay:!0})),N(c,0,0,!0)}else{I(s);const e=T(s);if(null!==(t=l.startDragDayIndex)&&void 0!==t||l.originalDay,l.dayIndex,l.allDay){l.allDay=!1,l.startHour=Ye(e),l.endHour=l.startHour+1,l.duration=1,l.hourOffset=0,l.eventDate=h?tt(h,c):new Date,E(),l.indicatorVisible=!1;const t=null==m?void 0:m.find(e=>e.id===l.eventId);k(l,null==t?void 0:t.calendarId,null==t?void 0:t.title),l.sourceElement=null,l.indicatorVisible=!0}else{let t=Ye(e+(null!==(n=l.hourOffset)&&void 0!==n?n:0));t=Math.max(v,Math.min(f-l.duration,t)),l.startHour=t,l.endHour=t+l.duration}l.dayIndex=c,l.eventDate=h?tt(h,c):new Date,x(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:Ye(l.startHour),endHour:Ye(l.endHour),allDay:!1}));let a=null;if("move"===l.mode&&l.eventId&&g){const e=null==m?void 0:m.find(e=>e.id===l.eventId);e&&(a=g(e,c,Ye(l.startHour),Ye(l.endHour)))}N(c,Ye(l.startHour),Ye(l.endHour),!1,a)}},[g,M,k,h,m,v,S,I,f,L,T,E,N,b,x]),z=a(()=>{const e=b.current;if(!e||!e.active)return;const t=null==p?void 0:p.getReadOnlyConfig(),n=!1!==(null==t?void 0:t.draggable),a=!(null==p?void 0:p.state.readOnly);if("move"===e.mode&&!n)return;if(("resize"===e.mode||"create"===e.mode)&&!a)return;if(document.body.style.cursor="default","move"===e.mode&&!e.indicatorVisible)return document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",$,{capture:!0}),document.removeEventListener("touchend",z),void w();if("move"!==e.mode||!e.eventId)return;let r=e.startHour,o=e.endHour;e.allDay||(r=Ye(e.startHour),o=Ye(e.endHour),o-r<y&&(o=r+y)),null==s||s(t=>t.map(t=>{var n,a;if(t.id!==e.eventId)return t;h?tt(h,e.dayIndex):fe(t.start);const l=null!==(n=e.startDragDayIndex)&&void 0!==n?n:e.originalDay,i=e.dayIndex-l;let s,d;if(e.allDay){const n=e.originalStartDate?new Date(e.originalStartDate):fe(t.start);n.setHours(0,0,0,0);const a=new Date(n);a.setDate(a.getDate()+i);const r=new Date(a);e.eventDurationDays&&e.eventDurationDays>0&&r.setDate(r.getDate()+e.eventDurationDays),s=me(a),d=me(Ie(r))}else{const n=fe(t.start),l=fe(t.end),c=t.allDay;if(A(n,l,null!==(a=t.allDay)&&void 0!==a&&a)>0&&!c){const e=new Date(n);e.setDate(e.getDate()+i);const t=new Date(l);t.setDate(t.getDate()+i),s=he(e),d=he(t)}else{const t=h?tt(h,e.dayIndex):new Date,n=Se(t,r),a=Se(t,o);s=he(n),d=he(a)}}const c=e.originalDay+i;return Object.assign(Object.assign({},t),{day:c,start:s,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",$,{capture:!0}),document.removeEventListener("touchend",z),E(),w()},[$,E,w,s,y,h,b]),F=a(e=>{var a,r,o,l,i,s,d,c,y,D;const x=b.current;if(!x||!x.active)return;const w=null==p?void 0:p.getReadOnlyConfig(),E=!1!==(null==w?void 0:w.draggable),M=!(null==p?void 0:p.state.readOnly);if("move"===x.mode&&!E)return;if(("resize"===x.mode||"create"===x.mode)&&!M)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:j,clientY:$}=ir(e);if(x&&x.active)if("resize"===x.mode?P||x.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",P){if("resize"!==x.mode){if("move"===x.mode){const e=Math.hypot(j-x.startX,$-x.startY);!x.indicatorVisible&&e>=3&&(k(x,null===(a=x.originalEvent)||void 0===a?void 0:a.calendarId,null===(r=x.originalEvent)||void 0===r?void 0:r.title,null,x.sourceElement||void 0),x.indicatorVisible=!0)}x.indicatorVisible&&N(j,$)}const e=O(j,$);if(!e)return;if("resize"===x.mode&&x.originalEvent&&x.resizeDirection){const t=fe(x.originalEvent.start);let n,a;const r=(e,t)=>{var n,a;e&&((null===(n=x.originalEvent)||void 0===n?void 0:n.allDay)?e.setHours(0,0,0,0):t&&e.setHours(t.hour,t.minute,null!==(a=t.second)&&void 0!==a?a:0,0))},o=x.originalStartTime,l=x.originalEndTime;if("left"===x.resizeDirection){n=new Date(e),r(n,o);const i=fe(x.originalEvent.end)||t;a=new Date(i),r(a,l),n>a&&(n=a)}else{const i=fe(x.originalEvent.start)||t;n=new Date(i),r(n,o),a=new Date(e),r(a,l),a<n&&(a=n)}x.originalStartDate=new Date(n.getTime()),x.originalEndDate=new Date(a.getTime());const i=x.originalEvent.allDay?me(n):he(n),s=x.originalEvent.allDay?me(a):he(a);C(e=>e.map(e=>e.id===x.eventId?Object.assign(Object.assign({},e),{start:i,end:s,title:e.title}):e),x.mode)}else if("move"===x.mode)if(x.originalStartDate&&x.originalEndDate){const t=new Date(x.originalStartDate);t.setHours(0,0,0,0);const n=H(t,e),a=R(x.originalStartDate,n),r=R(x.originalEndDate,n);(null===(o=x.originalStartDate)||void 0===o?void 0:o.getTime())!==a.getTime()&&(x.originalStartDate=new Date(a.getTime()),x.originalEndDate=new Date(r.getTime()),x.targetDate=a)}else(null===(l=x.targetDate)||void 0===l?void 0:l.getTime())!==e.getTime()&&(x.targetDate=e)}else{I($),x.lastClientY=$;const e=T($);if("create"===x.mode&&x.allDay){const e=Math.hypot(j-x.startX,$-x.startY);if(!x.indicatorVisible){if(e<3)return;k(x,"blue",t("newAllDayEvent")),x.indicatorVisible=!0}const n=L?x.dayIndex:S(j);return x.dayIndex=n,void N(n,0,0,!0)}if("resize"===x.mode)if(x.allDay){const e=L?x.dayIndex:S(j);let t=x.originalStartDate||new Date,n=x.originalEndDate||new Date;"left"===x.resizeDirection?(t=h?tt(h,e):new Date,t>n&&(t=n)):"right"===x.resizeDirection&&(n=h?tt(h,e):new Date,n<t&&(n=t)),x.originalStartDate=new Date(t.getTime()),x.originalEndDate=new Date(n.getTime());const a=me(t),r=me(n);C(e=>e.map(e=>e.id!==x.eventId?e:Object.assign(Object.assign({},e),{start:a,end:r,allDay:!0})),x.mode)}else{let t=x.startHour,n=x.endHour;const a=null==m?void 0:m.find(e=>e.id===x.eventId);let r=x.dayIndex;if(a){const e=fe(a.start),t=fe(a.end),n=A(e,t,null!==(i=a.allDay)&&void 0!==i&&i);r=(null!==(s=a.day)&&void 0!==s?s:0)+n}let o=r,l=x.originalDay;if("top"===x.resizeDirection){const a=L?x.dayIndex:S(j),o=e+(null!==(d=null==x?void 0:x.hourOffset)&&void 0!==d?d:0);a<r?(l=a,t=Math.max(v,Math.min(f,o))):(l=r,o>x.originalEndHour?(t=x.originalEndHour,n=o,x.hourOffset=n-e):(t=Math.max(v,o),x.originalEndHour-t<Ae&&(t=x.originalEndHour-Ae)))}else if("bottom"===x.resizeDirection){const a=L?x.dayIndex:S(j),r=e+(null!==(c=null==x?void 0:x.hourOffset)&&void 0!==c?c:0);a!==x.dayIndex?(o=a,n=Math.max(v,Math.min(f,r))):r<x.originalStartHour?(n=x.originalStartHour,t=r,x.hourOffset=t-e):(n=Math.min(f,r),n-x.startHour<Ae&&(n=x.startHour+Ae))}else if("right"===x.resizeDirection){const e=L?x.dayIndex:S(j);o=Math.max(x.dayIndex,e)}o===l&&([t,n]=[Math.max(v,Math.min(t,n)),Math.min(f,Math.max(t,n))]);const[u,g]=[Ye(t),Ye(n)];x.startHour=t,x.endHour=n,x.dayIndex=l,C(e=>e.map(e=>{if(e.id!==x.eventId)return e;const t=fe(e.start),n=Se(h?tt(h,l):t,u),a=h?tt(h,o):t,r=Se(a,g),i=he(n),s=he(r);return Object.assign(Object.assign({},e),{start:i,end:s,day:l})}),x.mode),N(x.dayIndex,u,g,!1)}else if("create"===x.mode){if(n.isMobile){const t=Ye(e+(null!==(y=x.hourOffset)&&void 0!==y?y:0)),n=Math.max(v,Math.min(f-(x.duration||1),t));x.startHour=n,x.endHour=n+(x.duration||1)}else{const t=Ye(e),[n,a]=$<x.startY?[t,Math.max(t+Ae,x.endHour)]:[x.startHour,Math.max(x.startHour+Ae,t)];x.startHour=n,x.endHour=a}const t=null==u?void 0:u(x.dayIndex,x.startHour,x.endHour);N(x.dayIndex,x.startHour,x.endHour,!1,t)}else if("move"===x.mode){const t=L?x.dayIndex:S(j);let n=Ye(e+(null!==(D=x.hourOffset)&&void 0!==D?D:0));n=Math.max(v,Math.min(f-x.duration,n));const a=n+x.duration;x.dayIndex=t,x.startHour=n,x.endHour=a;let r=null;if(x.eventId&&g){const e=null==m?void 0:m.find(e=>e.id===x.eventId);e&&(r=g(e,t,Ye(n),Ye(a)))}N(t,Ye(n),Ye(a),!1,r)}}},[P,L,N,O,C,H,R,v,f,u,S,T,I,g,m,b,k]),V=a(e=>{var n,a,r;const o=b.current;if(!o||!o.active)return;const l=null==p?void 0:p.getReadOnlyConfig(),i=!1!==(null==l?void 0:l.draggable),c=!(null==p?void 0:p.state.readOnly);if("move"===o.mode&&!i)return;if(("resize"===o.mode||"create"===o.mode)&&!c)return;if(document.body.style.cursor="default",("move"===o.mode||"create"===o.mode)&&!o.indicatorVisible)return document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),void w();const{clientX:u,clientY:g}=ir(e);if(o&&o.active){if(P){if("resize"===o.mode&&o.eventId&&o.originalStartDate&&o.originalEndDate){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(n=o.originalEvent)||void 0===n?void 0:n.allDay)||!1,t=e?me(o.originalStartDate):he(o.originalStartDate),a=e?me(o.originalEndDate):he(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:a,title:e.title}):e))}else if("move"===o.mode)if(o.eventId&&o.originalStartDate&&o.originalEndDate){const e=(null===(a=o.originalEvent)||void 0===a?void 0:a.start)?fe(o.originalEvent.start):null;if(e&&e.getTime()!==o.originalStartDate.getTime()){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(r=o.originalEvent)||void 0===r?void 0:r.allDay)||!1,t=e?me(o.originalStartDate):he(o.originalStartDate),n=e?me(o.originalEndDate):he(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:n,title:e.title}):e))}}else{const e=O(u,g)||o.targetDate;o.eventId&&e&&(x(t=>"targetDate"in t?Object.assign(Object.assign({},t),{targetDate:e}):t),C(t=>t.map(t=>{if(t.id!==o.eventId)return t;const n=fe(t.start),a=fe(t.end),r=new Date(e);r.setHours(n.getHours(),n.getMinutes(),0,0);const l=new Date(e);l.setHours(a.getHours(),a.getMinutes(),0,0);const i=t.allDay?me(r):he(r),s=t.allDay?me(l):he(l);return Object.assign(Object.assign({},t),{start:i,end:s})})))}}else{let[e,n]=[Ye(o.startHour),Ye(o.endHour)];if(n-e<y&&("top"===o.resizeDirection?e=n-y:n=e+y),"create"===o.mode){const a=h?tt(h,o.dayIndex):new Date;x(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t);const r=Se(a,e),l=Se(a,n),i=o.allDay,s=i?me(r):he(r),c=i?me(l):he(l);null==d||d({id:String(Date.now()),title:t(i?"newAllDayEvent":"newEvent"),day:o.dayIndex,start:s,end:c,calendarId:"blue",allDay:i})}else"move"!==o.mode&&"resize"!==o.mode||(x(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t),"move"===o.mode&&(null==s||s(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{day:o.dayIndex}):e))))}document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[P,F,E,w,O,C,y,h,d,s,b,x]),W=a((e,...a)=>{var r;if(null==p?void 0:p.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(r=b.current)||void 0===r?void 0:r.active)return;const{clientX:o,clientY:l}=ir(e);if(P){const[e]=a,n=new Date(e);n.setHours(9,0,0,0);const r=new Date(e);r.setHours(10,0,0,0);const o=he(n),l=he(r),i={id:String(Date.now()),title:t("newEvent"),start:o,end:l,day:e.getDay(),calendarId:"blue",allDay:!1};null==d||d(i),c&&setTimeout(()=>{c(i)},50)}else{const[e,r]=a,i=b.current;if(!i)return;const s=1,d=!!n.isMobile?-s/2:0,c=Ye(r+d);Object.assign(i,{active:!0,mode:"create",eventId:null,startX:o,startY:l,dayIndex:e,startHour:c,endHour:c+s,allDay:!1,eventDate:h?tt(h,e):new Date,duration:s,hourOffset:d}),x({active:!0,mode:"create",eventId:null,dayIndex:e,startHour:i.startHour,endHour:i.endHour,allDay:!1});const g=null==u?void 0:u(e,i.startHour,i.endHour);k(i,"blue",t("newEvent"),g),i.sourceElement=null,i.indicatorVisible=!0,document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}},[P,d,c,h,u,k,F,V,b,x]),B=a((e,t)=>{var n,a,r,o;if(e.cancelable&&("touches"in e||"changedTouches"in e)&&e.preventDefault(),e.stopPropagation(),null===(n=b.current)||void 0===n?void 0:n.active)return;const{clientX:l,clientY:i}=ir(e),s=b.current;if(!s)return;const d=e.currentTarget;if(P){D.current={x:l-d.getBoundingClientRect().left,y:i-d.getBoundingClientRect().top};const e=fe(t.start),n=fe(t.end);let a=1;if(t.allDay&&t.start&&t.end){const t=new Date(e);t.setHours(0,0,0,0);const r=new Date(n);r.setHours(0,0,0,0),a=Math.floor((r.getTime()-t.getTime())/864e5+1),a=Math.max(1,a)}const r=d.getAttribute("data-segment-days"),o=r?parseInt(r,10):a;s.active=!0,s.mode="move",s.eventId=t.id,s.startX=l,s.startY=i,s.targetDate=e,s.originalDate=e,s.originalEvent=Object.assign({},t),s.lastUpdateTime=Date.now(),s.originalStartDate=e,s.originalEndDate=n,s.eventDurationDays=a,s.currentSegmentDays=o,x({active:!0,mode:"move",eventId:t.id,targetDate:e,startDate:e,endDate:n}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}else{const e=T(i),n=t._segmentInfo,c=!!n,u=c?n.dayIndex:null!==(a=t.day)&&void 0!==a?a:0,g=c?n.startHour:Te(t.start);let h=0;if(t.allDay&&t.start&&t.end){const e=fe(t.start);e.setHours(0,0,0,0);const n=fe(t.end);n.setHours(0,0,0,0),h=Math.floor((n.getTime()-e.getTime())/864e5)}const m=fe(t.start);if(Object.assign(s,{active:!0,mode:"move",eventId:t.id,startX:l,startY:i,dayIndex:u,startHour:g,endHour:c?n.endHour:Fe(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:Te(t.start),originalEndHour:Fe(t),allDay:t.allDay||!1,eventDate:m,eventDurationDays:h,startDragDayIndex:u,calendarId:t.calendarId,title:t.title}),!t.allDay){s.hourOffset=g-e;const n=fe(t.start),a=fe(t.end).getTime()-n.getTime();s.duration=a/36e5}x({active:!0,mode:"move",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:Te(t.start),endHour:Fe(t),allDay:t.allDay||!1}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",$),document.addEventListener("mouseup",z),document.addEventListener("touchmove",$,{capture:!0,passive:!1}),document.addEventListener("touchend",z)}},[P,k,V,F,$,z,T,b,D,x]),Z=a((e,t,n)=>{var a,r,o,l,i,s;if(null==p?void 0:p.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(a=b.current)||void 0===a?void 0:a.active)return;const{clientX:d,clientY:c}=ir(e),u=b.current;if(u){if(P){const e=fe(t.start),a=fe(t.start),r=fe(t.end),o={hour:a.getHours(),minute:a.getMinutes(),second:a.getSeconds()},l={hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds()};u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.targetDate="left"===n?a:r,u.originalDate=e,u.originalEvent=Object.assign({},t),u.lastUpdateTime=Date.now(),u.resizeDirection=n,u.originalStartDate=a,u.originalEndDate=r,u.originalStartTime=o,u.originalEndTime=l,x({active:!0,mode:"resize",eventId:t.id,targetDate:"left"===n?a:r,startDate:a,endDate:r})}else if(t.allDay){const e=fe(t.start),a=fe(t.end);u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.allDay=!0,u.resizeDirection=n,u.originalStartDate=e,u.originalEndDate=a,u.originalEvent=Object.assign({},t),u.dayIndex=null!==(r=t.day)&&void 0!==r?r:0,x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:0,endHour:0,allDay:!0})}else{const e=T(c);Object.assign(u,{active:!0,mode:"resize",eventId:t.id,startX:d,startY:c,dayIndex:null!==(l=t.day)&&void 0!==l?l:0,startHour:Te(t.start),endHour:Fe(t),originalDay:null!==(i=t.day)&&void 0!==i?i:0,originalStartHour:Te(t.start),originalEndHour:Fe(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?Te(t.start)-e:Fe(t)-e,allDay:!1}),x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(s=t.day)&&void 0!==s?s:0,startHour:Te(t.start),endHour:Fe(t),allDay:!1})}document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}},[P,F,V,T,b,x]);return{handleDragMove:F,handleDragEnd:V,handleCreateStart:W,handleMoveStart:B,handleResizeStart:Z,handleUniversalDragMove:$,handleUniversalDragEnd:z}})({options:r,common:s,state:d,manager:c}),g=(e=>{const{t:t}=Nt(),{options:n,common:r,state:o,manager:l,handleDragMove:i,handleDragEnd:s}=e,{viewType:d,currentWeekStart:c,app:u}=n,{dragRef:g,setDragState:h}=o,{createDragIndicator:m}=l,{pixelYToHour:v,getColumnDayIndex:f}=r,y=d===Y.MONTH;return{handleCreateAllDayEvent:a((e,a)=>{var r;if(null==u?void 0:u.state.readOnly)return;if(y)return;if(e.preventDefault(),e.stopPropagation(),"dblclick"===e.type){const e=c?tt(c,a):new Date,r=me(e),o=me(e),l={id:String(Date.now()),title:t("newAllDayEvent"),day:a,start:r,end:o,calendarId:"blue",allDay:!0};return void n.onEventCreate(l)}if(null===(r=g.current)||void 0===r?void 0:r.active)return;const o=g.current;o&&(Object.assign(o,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:a,allDay:!0,eventDate:c?tt(c,a):new Date}),h({active:!0,mode:"create",eventId:null,dayIndex:a,startHour:0,endHour:0,allDay:!0}),o.indicatorVisible=!1,o.sourceElement=null,document.addEventListener("mousemove",i),document.addEventListener("mouseup",s))},[y,c,s,i,g,h,null==u?void 0:u.state.locale,n]),pixelYToHour:v,getColumnDayIndex:f}})({options:r,common:s,state:d,manager:c,handleDragMove:u.handleDragMove,handleDragEnd:u.handleDragEnd}),h=(e=>{const{common:t}=e,{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}=t;return{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}})({common:s});return Object.assign({createDragIndicator:c.createDragIndicator,updateDragIndicator:c.updateDragIndicator,removeDragIndicator:c.removeDragIndicator,handleCreateStart:u.handleCreateStart,handleMoveStart:u.handleMoveStart,handleResizeStart:u.handleResizeStart,dragState:d.dragState,isDragging:d.dragState.active},i?{daysDifference:h.daysDifference,addDaysToDate:h.addDaysToDate,getTargetDateFromPosition:h.getTargetDateFromPosition}:{handleCreateAllDayEvent:g.handleCreateAllDayEvent,pixelYToHour:g.pixelYToHour,getColumnDayIndex:g.getColumnDayIndex})};function dr(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[Y.DAY,Y.WEEK,Y.MONTH,Y.YEAR]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{Q.log("Drag plugin installed - providing drag capabilities")},api:n}}function cr(e,t){const n=e.getPlugin("drag"),a=sr(Object.assign(Object.assign({},t),{app:e}));if(!n)return Q.warn("Drag plugin is not installed. Drag functionality will be disabled. Add createDragPlugin() to your plugins array to enable dragging."),{handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:()=>{},handleCreateAllDayEvent:void 0,dragState:a.dragState,isDragging:!1};const r=n.getConfig(),o=n.isViewSupported(t.viewType),l=!1!==e.getReadOnlyConfig().draggable,i=!e.state.readOnly;return o||console.info(`Drag functionality is not supported for ${t.viewType} view.`),{handleMoveStart:o&&r.enableDrag&&l?a.handleMoveStart:()=>{},handleCreateStart:o&&r.enableCreate&&i?a.handleCreateStart:()=>{},handleResizeStart:o&&r.enableResize&&i?a.handleResizeStart:void 0,handleCreateAllDayEvent:o&&r.enableAllDayCreate&&i?a.handleCreateAllDayEvent:()=>{},dragState:a.dragState,isDragging:!(!o||!l)&&a.isDragging}}function ur(e){const{app:t,onEventCreated:n}=e,{t:r}=Nt(),o=a(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:a((e,a,o,l)=>{e.preventDefault();const i=e.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const e=JSON.parse(i);let s,c,u=!1;l?(s=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:0,minute:0}),c=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:23,minute:59,second:59}),u=!0):void 0!==o?(s=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:o,minute:0}),c=s.add({hours:1})):(s=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:9,minute:0}),c=s.add({hours:1}));const g={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:r(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:s,end:c,calendarId:e.calendarId,allDay:u};return t.addEvent(g),null==n||n(g),g}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[t,n]),handleDragOver:o}}const gr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Nt();return g("div",{className:"flex items-center gap-1",children:[u("button",{className:"calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:e,"aria-label":"Previous month",children:u(D,{className:"h-4 w-4 transition-transform group-hover:scale-110"})}),u("button",{className:"calendar-today-button inline-flex items-center justify-center px-4 h-7 text-sm font-medium rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:t,children:a("today")}),u("button",{className:"calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:n,"aria-label":"Next month",children:u(x,{className:"h-4 w-4 transition-transform group-hover:scale-110"})})]})},hr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:r,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s})=>{const{t:d,locale:c}=Nt();return u("div",{className:"hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",children:g("div",{className:`${rn} h-full`,children:[u("div",{className:"px-2 border-b border-gray-200 dark:border-gray-700",children:g("div",{children:[g("div",{className:"flex items-center justify-end gap-2",children:[u("div",{className:At,style:{position:"relative"},children:u("div",{children:u("h1",{className:$t,children:" "})})}),u(gr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),u(ln,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:i})]})}),g("div",{className:"flex-1 p-4 overflow-y-auto",children:[u("h3",{className:"text-lg font-semibold mb-3",children:t.toLocaleDateString(c,{weekday:"long",month:"long",day:"numeric"})}),0===a.length?u("p",{className:`text-gray-500 dark:text-gray-400 ${an}`,children:d("noEvents")}):u("div",{className:"space-y-2",children:a.map(t=>g("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==r?void 0:r.id)===t.id?"bg-primary/10 border-primary":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:je(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[u("div",{className:`font-medium ${an}`,children:t.title}),!t.allDay&&g("div",{className:`${nn} ${tn}`,children:[$e(Te(t.start))," -"," ",$e(Fe(t))]}),t.allDay&&u("div",{className:`${nn} ${tn}`,children:d("allDay")})]},t.id))})]})]})})},mr=({viewType:e,currentDate:t,onPrevious:n,onNext:a,onToday:r,customTitle:o,customSubtitle:l,showTodayBox:i,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:h=0})=>{const{locale:m}=Nt(),v=void 0===i||i,f=o||(()=>{switch(e){case"day":return t.toLocaleDateString(m,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(m,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),y="day"===e?l||("day"===e?t.toLocaleDateString(m,{weekday:"long"}):null):null;return g("div",{className:At,style:{position:"relative"},children:[u("div",{className:"flex-1",children:g("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[u("h1",{className:$t,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&u("h1",{className:$t,style:{position:"absolute",top:0,left:0,transform:`translateY(${h}px)`,willChange:"transform"},children:c})]}:{children:[u("div",{className:`${$t} text-gray-900 dark:text-white`,children:f}),y&&u("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:y})]})}),v&&n&&a&&r&&u("div",{className:"flex items-center gap-2",children:u(gr,{handlePreviousMonth:n,handleNextMonth:a,handleToday:r})})]})},vr=e=>{if(!1===e.icon)return null;if(void 0!==e.icon&&"boolean"!=typeof e.icon)return e.icon;const t=e.title.toLowerCase();return t.includes("holiday")||t.includes("vacation")||t.includes("假期")?u(L,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?u(j,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?u(A,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?u($,{className:"h-3 w-3"}):u(O,{className:"h-3 w-3"})},fr=(e,t)=>{const n=[],a=new Date(t);return a.setDate(t.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{const r=fe(e.start),o=fe(e.end),l=new Date(r);l.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let s=new Date(i);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(s=new Date(i),s.setDate(s.getDate()-1))}}const d=Ce(l,s)>0;if(!d&&e.allDay){if(l<t||l>a)return;const r=Math.floor((l.getTime()-t.getTime())/864e5);return void(r>=0&&r<=6&&n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:r,endDayIndex:r,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!d)return;const c=l;let u;if(e.allDay)u=new Date(i),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(i),u.setHours(23,59,59,999)):(u=new Date(i),u.setTime(u.getTime()-1))}if(u<t||c>a)return;const g=c<t?t:c,h=u>a?a:u,m=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),v=Math.min(6,Math.floor((h.getTime()-t.getTime())/864e5)),f=c>=t,y=u<=a,p=0===m||6===v;let b;b=f&&y?"single":f?p&&6===v?"start-week-end":"start":y?p&&0===m?"end-week-start":"end":"middle";const D=Ce(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:m,endDayIndex:v,segmentType:b,totalDays:D,segmentIndex:0,isFirstSegment:f,isLastSegment:y})}),n},yr=(e,t)=>{if(e.allDay)return[];const n=fe(e.start),a=fe(e.end),r=new Date(n);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const l=Ce(r,o);if(0===l)return[];const i=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),s=a.getTime()-n.getTime();if(!e.allDay&&1===l&&!i&&s<864e5)return[];const d=i?l:Math.max(0,l-1),c=[];for(let e=0;e<=d;e++){const o=new Date(r);o.setDate(r.getDate()+e);const l=Math.floor((o.getTime()-t.getTime())/864e5);if(l<0||l>6)continue;const s=0===e,u=e===d,g=s?n.getHours()+n.getMinutes()/60:0,h=u&&i?a.getHours()+a.getMinutes()/60:24;c.push({dayIndex:l,startHour:g,endHour:h,isFirst:s,isLast:u})}return c},pr=e.memo(({segment:t,segmentIndex:n,isDragging:a,isResizing:r=!1,isSelected:o=!1,onMoveStart:l,onResizeStart:i,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:m=!0,viewable:v=!0})=>{const f=17*n,y=`calc(${t.startDayIndex/7*100}% + 2px)`,p=`calc(${(t.endDayIndex-t.startDayIndex+1)/7*100}% - 4px)`,b=e.useRef(null),D=e.useRef(null),x=e=>{const n="left"===e;return(n?t.isFirstSegment:t.isLastSegment)&&i&&m?u("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),i(e,t.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},w=t.event.calendarId||"blue",C=t.endDayIndex-t.startDayIndex+1;return g("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign(Object.assign({left:y,width:p,top:`${f}px`,height:"16px",borderRadius:(E=t.segmentType,{single:"0.25rem",start:"0.25rem 0 0 0.25rem","start-week-end":"0.25rem 0 0 0.25rem",end:"0 0.25rem 0.25rem 0","end-week-start":"0 0.25rem 0.25rem 0",middle:"0"}[E]),pointerEvents:"auto",zIndex:10},o||a?{backgroundColor:Le(w),color:"#fff"}:{backgroundColor:Oe(w),color:Pe(w)}),{cursor:c||v?"pointer":"default"}),"data-segment-days":C,onMouseDown:e=>{if(!c&&!v)return;e.preventDefault(),e.stopPropagation();!e.target.closest(".resize-handle")&&c&&l(e,t.event)},onTouchStart:e=>{if(!l||!d||!c&&!v)return;e.stopPropagation();const n=e.touches[0],a=n.clientX,r=n.clientY,o=e.currentTarget;D.current={x:a,y:r},b.current=setTimeout(()=>{s&&s(t.event.id);c&&l({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1},t.event),b.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(b.current&&D.current){const t=Math.abs(e.touches[0].clientX-D.current.x),n=Math.abs(e.touches[0].clientY-D.current.y);(t>10||n>10)&&(clearTimeout(b.current),b.current=null,D.current=null)}},onTouchEnd:()=>{b.current&&(clearTimeout(b.current),b.current=null),D.current=null},title:`${t.event.title} (${Wn(t.event.start)} - ${Wn(t.event.end)})`,children:[d&&o&&m&&g(h,{children:[t.isFirstSegment&&u("div",{className:"absolute left-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:je(w)}}),t.isLastSegment&&u("div",{className:"absolute right-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:je(w)}})]}),x("left"),u("div",{className:"flex-1 min-w-0",style:{cursor:r?"ew-resize":"pointer"},children:(()=>{const e=t.event.allDay,n=t.event.calendarId||"blue",a=Te(t.event.start),r=Fe(t.event),o=$e(a),l=$e(r);if(e){const e=()=>t.isFirstSegment?t.event.title:"middle"===t.segmentType||t.isLastSegment&&t.totalDays>1?"···":t.event.title;return g("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[t.isFirstSegment&&vr(t.event)&&u("div",{className:"shrink-0 mr-1",children:u("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:je(n),width:"12px",height:"12px"},children:vr(t.event)})}),u("div",{className:"flex-1 min-w-0",children:u("div",{className:"truncate font-medium text-xs",children:e()})}),t.isLastSegment&&"single"!==t.segmentType&&u("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:u("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const i=t.isFirstSegment||t.isLastSegment?t.event.title:"···",s=t.endDayIndex-t.startDayIndex+1,d=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return g("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[u("span",{className:"inline-block w-0.75 h-3 rounded-full shrink-0 mr-1",style:{backgroundColor:je(n)}}),u("div",{className:"flex items-center min-w-0 flex-1",children:u("span",{className:"whitespace-nowrap overflow-hidden block md:truncate mobile-mask-fade font-medium text-xs",children:i})}),t.isFirstSegment&&u("span",{className:`text-xs font-medium whitespace-nowrap ${1===s?"ml-2":""} hidden md:block`,style:d,children:o}),t.isLastSegment&&!t.event.allDay&&24!==r&&u("span",{className:"text-xs font-medium whitespace-nowrap ml-auto hidden md:inline",children:`ends ${l}`})]})})()}),x("right")]});var E});pr.displayName="MultiDayEvent";const br=({event:e,position:n,panelRef:a,isAllDay:r,eventVisibility:o,calendarRef:l,selectedEventElementRef:i,onEventUpdate:s,onEventDelete:c,app:h})=>{var v;const{effectiveTheme:f}=Ia(),y=da(f),{t:p}=Nt(),b="dark"===y||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),D=!(null==h?void 0:h.state.readOnly);if(!(!1!==(null==h?void 0:h.getReadOnlyConfig().viewable)))return null;const x=b?"#1f2937":"white",w=b?"rgb(55, 65, 81)":"rgb(229, 231, 235)",C=t(()=>(h?h.getCalendarRegistry():K()).getVisible().map(e=>({label:e.name,value:e.id})),[h,null==h?void 0:h.getCalendars()]),E=t(()=>ue(e.start)?e.end&&!ue(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||d.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||d.Now.timeZoneId(),[e.end,e.start]),k=t=>{const[n,a]=t;s(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:a.toPlainDate()}))},N=(()=>{var e;let t={};if("sticky-top"===o){const a=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=a.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${w}`:"none"),borderTop:""+(n.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${w}`),borderBottom:""+(n.isSunday?"none":`1px solid ${w}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=a.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${w}`:"none"),borderTop:""+(n.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${w}`),borderBottom:""+(n.isSunday?"none":`1px solid ${w}`)}}else if(n&&i.current&&l.current){const e=i.current.getBoundingClientRect(),r=l.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-n.top,u=a.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const h=12,m=Math.max(h,Math.min(g,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${w}`:"none"),borderTop:""+(n.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${w}`),borderBottom:""+(n.isSunday?"none":`1px solid ${w}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),T=g("div",{ref:a,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg p-4 ","data-event-detail-panel":"true",style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[u("div",{style:N}),u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("eventTitle")}),g("div",{className:"flex items-center justify-between gap-3 mb-3",children:[u("div",{className:"flex-1",children:u("input",{type:"text",value:e.title,readOnly:!D,disabled:!D,onChange:t=>{s(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),D&&u(gn,{options:C,value:e.calendarId||"blue",onChange:t=>{s(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==h?void 0:h.getCalendarRegistry()})]}),g("div",r?{className:"mb-3",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("dateRange")}),u(Mn,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!D,onChange:k,onOk:k,locale:null==h?void 0:h.state.locale})]}:{className:"mb-3",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("timeRange")}),u(Mn,{value:[e.start,e.end],timeZone:E,disabled:!D,onChange:t=>{const[n,a]=t;s(Object.assign(Object.assign({},e),{start:n,end:a}))},onOk:t=>{const[n,a]=t;s(Object.assign(Object.assign({},e),{start:n,end:a}))},locale:null==h?void 0:h.state.locale})]}),g("div",{className:"mb-3",children:[u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("note")}),u("textarea",{value:null!==(v=e.description)&&void 0!==v?v:"",readOnly:!D,disabled:!D,onChange:t=>s(Object.assign(Object.assign({},e),{description:t.target.value})),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:p("addNotePlaceholder")})]}),D&&g("div",{className:"flex space-x-2",children:[u("button",r?{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=ue(e.start)?e.start:e.start.toPlainDate(),n=d.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:d.Now.timeZoneId()}),a=d.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:d.Now.timeZoneId()});s(Object.assign(Object.assign({},e),{allDay:!1,start:n,end:a}))},children:p("setAsTimed")}:{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=ue(e.start)?e.start:e.start.toPlainDate();s(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:p("setAsAllDay")}),u("button",{className:"px-2 py-1 bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>c(e.id),children:p("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const S=document.body;return S?m.createPortal(T,S):null},Dr=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:r,calendarRef:o,selectedEventElementRef:l,onEventUpdate:i,onEventDelete:s,onClose:d,contentRenderer:c})=>{const{effectiveTheme:h}=Ia(),v=da(h),f="dark"===v?"#1f2937":"white",y="dark"===v?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=(()=>{var e;let a={};if("sticky-top"===r){const n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${y}`:"none"),borderTop:""+(t.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${y}`),borderBottom:""+(t.isSunday?"none":`1px solid ${y}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===r){const e=n.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}a={position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${y}`:"none"),borderTop:""+(t.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${y}`),borderBottom:""+(t.isSunday?"none":`1px solid ${y}`)}}else if(t&&l.current&&o.current){const e=l.current.getBoundingClientRect(),r=o.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const h=12,m=Math.max(h,Math.min(g,c));a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(t.isSunday?`1px solid ${y}`:"none"),borderTop:""+(t.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${y}`),borderBottom:""+(t.isSunday?"none":`1px solid ${y}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return a})(),b=g("div",{ref:n,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg p-3","data-event-detail-panel":"true",style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===v?"#1f2937":"#ffffff"},children:[u("div",{style:p}),u(c,{event:e,isAllDay:a,onEventUpdate:i,onEventDelete:s,onClose:d})]});return m.createPortal(b,document.body)},xr=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const r=`${Math.floor(Te(e.start)).toString().padStart(2,"0")}:${Math.round(Te(e.start)%1*60).toString().padStart(2,"0")}`;return g("div",{className:"text-xs mb-[2px] cursor-pointer flex items-center justify-between",children:[g("div",{className:"flex items-center flex-1 min-w-0",children:[u("span",{style:{backgroundColor:je(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${on} shrink-0 rounded-full`}),u("span",{className:"whitespace-nowrap overflow-hidden block md:truncate mobile-mask-fade "+(n?"text-white":""),children:e.title})]}),!a&&u("span",{className:`${nn} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:r})]})},wr=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,a="boolean"!=typeof e.icon?e.icon:null;return g("div",{className:"text-xs px-1 mb-[2px] rounded truncate cursor-pointer flex items-center",children:[n&&(a?u("div",{className:`${on} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?u("span",{className:`inline-block ${on} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):u(O,{className:`${Jt} ${t?"text-white":""}`})),u("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Cr=({event:e,isEditable:t,onResizeStart:n})=>{const a=!1!==e.icon,r="boolean"!=typeof e.icon?e.icon:null;return g("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[n&&t&&u("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),a&&(r?u("div",{className:"mr-1 shrink-0",children:r}):u(O,{className:Jt})),u("div",{className:`${Gt} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&u("div",{className:Qt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Er=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:r,isEventSelected:o,onResizeStart:l})=>{const i=n?n.startHour:Te(e.start),s=n?n.endHour:Fe(e),d=s-i,c=!n||n.isFirst,m=!n||n.isLast,v=e.calendarId||"blue";return g(h,{children:[u("div",{className:Kt,style:{backgroundColor:je(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),g("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(Fe(e)-Te(e.start)<=.25?"px-1 py-0":"p-1"),children:[u("div",{className:`${Gt} pr-1`,style:{lineHeight:d<=.25?"1.2":"normal"},children:e.title}),d>.5&&u("div",{className:"text-xs opacity-80 truncate",children:n?`${$e(i)} - ${$e(s)}`:ze(e)})]}),l&&a&&g(h,{children:[c&&u("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>l(t,e,"top")}),m&&u("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>l(t,e,"bottom")}),!c&&m&&n&&u("div",{className:Qt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),r&&o&&l&&a&&g(h,{children:[u("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:je(v,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),u("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:je(v,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},kr=({event:e,layout:t,isAllDay:l=!1,allDayHeight:i=28,calendarRef:s,isBeingDragged:d=!1,isBeingResized:c=!1,isDayView:v=!1,isMonthView:f=!1,isMultiDay:y=!1,segment:p,segmentIndex:b=0,hourHeight:D,firstHour:x,selectedEventId:w,detailPanelEventId:C,onMoveStart:E,onResizeStart:k,onEventUpdate:N,onEventDelete:T,newlyCreatedEventId:S,onDetailPanelOpen:M,onEventSelect:I,onEventLongPress:H,onDetailPanelToggle:R,customDetailPanelContent:O,customEventDetailDialog:P,multiDaySegmentInfo:L,app:j,isMobile:A=!1,enableTouch:$,hideTime:z})=>{const Y=null!=$?$:A,[F,V]=n(!1),[W,B]=n(!1),Z=y&&p?`${e.id}::${p.id}`:void 0!==(null==L?void 0:L.dayIndex)?`${e.id}::day-${L.dayIndex}`:e.id,U=C===Z,[_,q]=n(null),[X,G]=n("visible"),K=o(null),J=o(null),Q=o(null),ee=o(null),te=o(null),ne=o(null),ae=void 0!==w?w===e.id:F,re=null==j?void 0:j.getReadOnlyConfig(),oe=!(null==j?void 0:j.state.readOnly),le=!1!==(null==re?void 0:re.viewable),ie=!1!==(null==re?void 0:re.draggable),se=e=>{if(!s.current)return null;const t=s.current.getBoundingClientRect();if(f){const n=t.width/7;return{left:t.left+e*n,width:n}}const n=A?48:80;if(v){const e=t.width-n;return{left:t.left+n,width:e}}const a=(t.width-n)/7;return{left:t.left+n+e*a,width:a}},de=e=>{ee.current=e},ce=()=>{var t;if(null!==ee.current)return ee.current;if(C===Z){const e=Z.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==L?void 0:L.dayIndex)?L.dayIndex:p?p.startDayIndex:null!==(t=e.day)&&void 0!==t?t:0},ue=e=>{if(!s.current)return null;const t=s.current.getBoundingClientRect();if(f){const n=t.width/7,a=e-t.left,r=Math.floor(a/n);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const n=A?48:80,a=v?1:7,r=(t.width-n)/a,o=e-t.left-n,l=Math.floor(o/r);return Number.isFinite(l)?Math.max(0,Math.min(a-1,l)):null},ge=()=>new Promise(t=>{if(!s.current||l||f)return void t();const n=s.current.querySelector(".calendar-content");if(!n)return void t();const a=L?L.startHour:Te(e.start),r=L?L.endHour:Fe(e),o=(a-x)*D,i=o+Math.max((r-a)*D,D/4),d=n.scrollTop,c=n.clientHeight;if(o>=d&&i<=d+c)return void t();const u=((a+r)/2-x)*D-c/2,g=n.scrollHeight-c,h=Math.max(0,Math.min(g,u));n.scrollTo({top:h,behavior:"smooth"}),setTimeout(()=>{t()},300)}),he=a(()=>{if(!Q.current||!s.current||!J.current)return;const t=s.current.getBoundingClientRect(),n=ce(),a=se(n);let r,o;if(a)r=a.left,o=a.width;else if(f)o=t.width/7,r=t.left+n*o;else{const e=A?48:80;o=(t.width-e)/7,r=t.left+e+n*o}const l=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var a,o,d,c,u;if(!J.current)return;if(!Q.current)return;const g=J.current.getBoundingClientRect(),h=g.width,m=g.height;let b,w,C;if("sticky-top"===X||"sticky-bottom"===X){const t=null===(a=s.current)||void 0===a?void 0:a.querySelector(".calendar-content");if(!t)return;const n=L?L.startHour:Te(e.start),r=L?L.endHour:Fe(e),l=(n-x)*D,i=Math.max((r-n)*D,D/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+l-c,g=null===(o=K.current)||void 0===o?void 0:o.getBoundingClientRect();if(!g)return;C={top:u,bottom:u+i,left:g.left,right:g.right,width:g.width,height:i,x:g.x,y:u,toJSON:()=>({})}}else C=Q.current.getBoundingClientRect();if(f&&y&&p){const e=se(n),a=null!==(d=null==e?void 0:e.width)&&void 0!==d?d:t.width/7,r=null!==(c=null==e?void 0:e.left)&&void 0!==c?c:t.left+n*a,o=r+a;C={top:C.top,bottom:C.bottom,left:r,right:o,width:o-r,height:C.height,x:r,y:C.top,toJSON:()=>({})}}if(("sticky-top"===X||"sticky-bottom"===X)&&!f){const e=null!==(u=null==L?void 0:L.dayIndex)&&void 0!==u?u:ce(),n=A?48:80,a=v?1:7,r=(t.width-n)/a,o=se(e),l=o?o.left:t.left+n+e*r,i=o?o.width:r,s=Math.max(0,v?C.width:i-3),d=v?C.left:l;C=Object.assign(Object.assign({},C),{left:d,right:d+s,width:s})}const E=l-C.right,k=C.left-t.left;b=E>=h+20?C.right+10:k>=h+20?C.left-h-10:E>k?Math.max(t.left+10,l-h-10):t.left+10;const N=C.top-m/2+C.height/2,T=Math.max(10,t.top+10),S=i-10;w=N<T?T:N+m>S?S-m:N,q(e=>e?Object.assign(Object.assign({},e),{top:w,left:b,isSunday:b<r}):null)})},[s,e.day,e.start,e.end,X,f,x,D,y,null==p?void 0:p.startDayIndex,null==p?void 0:p.endDayIndex,null==L?void 0:L.dayIndex,C,Z]),me=a(()=>{if(!ae||!U||!K.current||!s.current||l||f)return;const t=s.current.querySelector(".calendar-content");if(!t)return;const n=L?L.startHour:Te(e.start),a=L?L.endHour:Fe(e),r=(n-x)*D,o=r+Math.max((a-n)*D,D/4),i=t.getBoundingClientRect(),d=t.scrollTop;let c=o<d+6,u=r>d+i.height-6;const g=i.bottom<0,h=i.top>window.innerHeight;g?c=!0:h&&(u=!0),G(c?"sticky-top":u?"sticky-bottom":"visible"),he()},[F,U,s,l,f,Te(e.start),Fe(e),x,D,he,null==L?void 0:L.startHour,null==L?void 0:L.endHour,null==L?void 0:L.dayIndex,C,Z]);r(()=>{var e,t;if(!ae||!U||l)return;const n=null===(e=s.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const a=()=>me(),r=()=>{me(),he()},o=[n];let i=null===(t=s.current)||void 0===t?void 0:t.parentElement;for(;i;){const e=window.getComputedStyle(i),t=e.overflowY,n=e.overflowX;"auto"!==t&&"scroll"!==t&&"auto"!==n&&"scroll"!==n||o.push(i),i=i.parentElement}o.forEach(e=>{e.addEventListener("scroll",a)}),window.addEventListener("scroll",a,!0),window.addEventListener("resize",r);let d=null;return s.current&&(d=new ResizeObserver(()=>{r()}),d.observe(s.current)),me(),()=>{o.forEach(e=>{e.removeEventListener("scroll",a)}),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",r),d&&d.disconnect()}},[ae,U,l,me,he,s,X]),r(()=>{if(!ae&&!U)return;const t=t=>{var n,a;const r=t.target,o=null===(n=K.current)||void 0===n?void 0:n.contains(r),l=null!==r.closest(`[data-event-id="${e.id}"]`),i=null===(a=J.current)||void 0===a?void 0:a.contains(r),s=r.closest("[data-event-detail-dialog]"),d=r.closest("[data-range-picker-popup]"),c=r.closest("[data-color-picker-dropdown]");U?o||l||i||s||d||c||(I&&I(null),de(null),V(!1),null==R||R(null)):!ae||o||l||c||(I&&I(null),de(null),V(!1),null==R||R(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[ae,U,I,R,e.id]),r(()=>{y&&p&&!p.isFirstSegment||S!==e.id||U||setTimeout(()=>{var t,n;if(K.current){let a=K.current;if(y){const e=K.current.querySelector("div");e&&(a=e)}y?p?de(p.startDayIndex):void 0!==(null==L?void 0:L.dayIndex)?de(L.dayIndex):de(null!==(t=e.day)&&void 0!==t?t:null):de(null!==(n=e.day)&&void 0!==n?n:null),Q.current=a,V(!0),null==R||R(Z),q({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{he()})}null==M||M()},150)},[S,e.id,U,M,he,y,p,R,Z]);const ve=o(null);r(()=>{let t,n=!0;const a=null==j?void 0:j.state.highlightedEventId;return ae&&a===e.id?ve.current!==a&&(ve.current=a,ge().then(()=>{n&&(B(!0),t=setTimeout(()=>{n&&B(!1)},150))})):B(!1),a!==e.id&&(ve.current=null),()=>{n=!1,t&&clearTimeout(t)}},[ae,null==j?void 0:j.state.highlightedEventId,e.id]);const fe=()=>p?u(pr,{segment:p,segmentIndex:null!=b?b:0,isDragging:d||ae,isResizing:c,isSelected:ae,onMoveStart:E||(()=>{}),onResizeStart:k,isMobile:A,isDraggable:ie,isEditable:oe,viewable:le}):null,ye=()=>{if(y&&p){const{segmentType:e}=p;if("single"===e||"start"===e)return Xt;if("start-week-end"===e)return"rounded-l-xl rounded-r-none my-0.5";if("end"===e||"end-week-start"===e)return"rounded-r-xl rounded-l-none my-0.5";if("middle"===e)return"rounded-none my-0.5"}return Xt},pe=e.calendarId||"blue";return g(h,{children:[u("div",{ref:K,"data-event-id":e.id,className:f?`\n ${qt}\n ${l?ye():"rounded-sm"}\n `:`\n ${qt}\n shadow-sm\n ${l?ye():"rounded-sm"}\n `,style:Object.assign(Object.assign({},(()=>{var n,a,r,o,c,u;if(f)return{opacity:d?.3:1,zIndex:ae||U?1e3:1,transform:W?"scale(1.15)":void 0,transition:"transform 0.1s ease-in-out",cursor:ie||le?"pointer":"default"};if(l){const e={height:i-4+"px",opacity:d?.3:1,zIndex:ae||U?1e3:1,transform:W?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:ie||le?"pointer":"default"},t=b*i;if(Object.assign(e,{top:`${t}px`}),v)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(y&&p){const t=(p.endDayIndex-p.startDayIndex+1)/7*100,n=p.startDayIndex/7*100,a=2,r=p.isFirstSegment?a:0,o=r+(p.isLastSegment?a:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:r>0?`calc(${n}% + ${r}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"calc(100% - 3px)",left:"0px",position:"relative"});return e}const g=L?L.startHour:Te(e.start),h=L?L.endHour:Fe(e),m={top:`${(g-x)*D+3}px`,height:Math.max((h-g)*D,D/4)-4+"px",position:"absolute",opacity:d?.3:1,zIndex:ae||U?1e3:null!==(n=null==t?void 0:t.zIndex)&&void 0!==n?n:1,transform:W?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:ie||le?"pointer":"default"};if(ae&&U&&("sticky-top"===X||"sticky-bottom"===X)){const e=null===(a=s.current)||void 0===a?void 0:a.getBoundingClientRect();if(e){const t=null!==(r=null==L?void 0:L.dayIndex)&&void 0!==r?r:ce(),n=A?48:80,a=v?1:7;let l=(e.width-n)/a,i=e.left+n+t*l;f&&(l=e.width/7,i=e.left+t*l);const d=se(t);d&&(i=d.left,l=d.width);let g=null===(o=s.current)||void 0===o?void 0:o.querySelector(".calendar-content");g||(g=null===(c=s.current)||void 0===c?void 0:c.querySelector(".calendar-renderer"));const h=null==g?void 0:g.getBoundingClientRect(),m=null===(u=K.current)||void 0===u?void 0:u.getBoundingClientRect(),y=null==m?void 0:m.left,p=null==m?void 0:m.width;if("sticky-top"===X){let t=h?h.top:e.top;return t=Math.max(t,0),t=Math.max(t,e.top),t=Math.min(t,e.bottom-6),t=Math.min(t,window.innerHeight-6),{position:"fixed",top:`${t}px`,left:`${v?y:i}px`,width:`${v?p:l-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let b=h?h.bottom:e.bottom;return b=Math.min(b,window.innerHeight),b=Math.min(b,e.bottom),b=Math.max(b,e.top+6),b=Math.max(b,6),{position:"fixed",top:b-6+"px",left:`${v?y:i}px`,width:`${v?p:l-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!l){const e=v?`calc(${t.width}% - 3px)`:t.width-1+"%";return Object.assign(Object.assign({},m),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},m),{left:"0px",right:"3px"})})()),ae?{backgroundColor:Le(pe,null==j?void 0:j.getCalendarRegistry()),color:"#fff"}:{backgroundColor:Oe(pe,null==j?void 0:j.getCalendarRegistry()),color:Pe(pe,null==j?void 0:j.getCalendarRegistry())}),onClick:Y?void 0:t=>{var n,a;if(t.preventDefault(),t.stopPropagation(),y)if(p){const e=ue(t.clientX);if(null!==e){const t=Math.min(Math.max(e,p.startDayIndex),p.endDayIndex);de(t)}else de(p.startDayIndex)}else void 0!==(null==L?void 0:L.dayIndex)?de(L.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);j&&j.onEventClick(e);I?I(e.id):le&&V(!0),null==R||R(null),q(null)},onDoubleClick:Y?void 0:t=>{var n,a;if(!le)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;if(y){const e=r.querySelector("div");e&&(r=e)}if(Q.current=r,y)if(p){const e=ue(t.clientX);if(null!==e){const t=Math.min(Math.max(e,p.startDayIndex),p.endDayIndex);de(t)}else de(p.startDayIndex)}else void 0!==(null==L?void 0:L.dayIndex)?de(L.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);ge().then(()=>{V(!0),A||(null==R||R(Z),q({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{he()}))})},onMouseDown:E?t=>{var n;if(L){const a=Object.assign(Object.assign({},e),{day:null!==(n=L.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:L});E(t,a)}else if(y&&p){const n=Object.assign(Object.assign({},e),{day:p.startDayIndex,_segmentInfo:{dayIndex:p.startDayIndex,isFirst:p.isFirstSegment,isLast:p.isLastSegment}});E(t,n)}else E(t,e)}:void 0,onTouchStart:t=>{if(!E||!Y)return;t.stopPropagation();const n=t.touches[0],a=n.clientX,r=n.clientY,o=t.currentTarget;ne.current={x:a,y:r},te.current=setTimeout(()=>{var t;H?H(e.id):V(!0);const n={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1};if(L){const a=Object.assign(Object.assign({},e),{day:null!==(t=L.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:L});E(n,a)}else if(y&&p){const t=Object.assign(Object.assign({},e),{day:p.startDayIndex,_segmentInfo:{dayIndex:p.startDayIndex,isFirst:p.isFirstSegment,isLast:p.isLastSegment}});E(n,t)}else E(n,e);te.current=null,ne.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(te.current&&ne.current){const t=Math.abs(e.touches[0].clientX-ne.current.x),n=Math.abs(e.touches[0].clientY-ne.current.y);(t>10||n>10)&&(clearTimeout(te.current),te.current=null,ne.current=null)}},onTouchEnd:t=>{te.current&&(clearTimeout(te.current),te.current=null),Y&&ne.current&&(t.preventDefault(),t.stopPropagation(),I?I(e.id):le&&V(!0),j&&j.onEventClick(e),null==R||R(null),q(null)),ne.current=null},children:f?y&&p?fe():e.allDay?y?fe():u(wr,{event:e,isEventSelected:ae}):u(xr,{event:e,app:j,isEventSelected:ae,hideTime:z}):e.allDay?u(Cr,{event:e,isEditable:!!oe,onResizeStart:k}):u(Er,{event:e,app:j,multiDaySegmentInfo:L,isEditable:!!oe,isTouchEnabled:!!Y,isEventSelected:ae,onResizeStart:k})}),U&&u("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!U)return null;const t=()=>{I&&I(null),de(null),V(!1),null==R||R(null)};if(P){const n=P,a={event:e,isOpen:U,isAllDay:l,onEventUpdate:N,onEventDelete:T,onClose:t,app:j};if("undefined"==typeof window||"undefined"==typeof document)return null;const r=document.body;return r?m.createPortal(u(n,Object.assign({},a)),r):null}return _?O?u(Dr,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:X,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,contentRenderer:O}):u(br,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:X,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,app:j}):null})()]})},Nr=({app:t,currentDate:n,currentWeekStart:a,events:r,currentDayEvents:o,organizedAllDayEvents:l,allDayAreaHeight:i,timeSlots:s,eventLayouts:d,isToday:c,currentTime:h,selectedEventId:m,setSelectedEventId:v,newlyCreatedEventId:f,setNewlyCreatedEventId:y,detailPanelEventId:p,setDetailPanelEventId:b,dragState:D,isDragging:x,handleMoveStart:w,handleResizeStart:C,handleCreateStart:E,handleCreateAllDayEvent:k,handleTouchStart:N,handleTouchEnd:T,handleTouchMove:S,handleDragOver:M,handleDrop:I,handleEventUpdate:H,handleEventDelete:R,customDetailPanelContent:O,customEventDetailDialog:P,calendarRef:L,allDayRowRef:j,switcherMode:A,isMobile:$,isTouch:z,setDraftEvent:F,setIsDrawerOpen:V,ALL_DAY_HEIGHT:W,HOUR_HEIGHT:B,FIRST_HOUR:Z,LAST_HOUR:U})=>{const{t:_,locale:q}=Nt(),X=e.useRef(t.state.highlightedEventId);return u("div",{className:`flex-none ${"buttons"===A?"":"md:w-[60%]"} w-full md:w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,children:g("div",{className:`relative ${rn} h-full`,children:[u(mr,{calendar:t,viewType:Y.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(q,{weekday:"long"})}),g("div",{className:`${_t} pt-px`,ref:j,children:[u("div",{className:"flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end select-none w-12 text-[10px] md:w-20 md:text-xs",children:_("allDay")}),u("div",{className:"flex flex-1 relative",children:u("div",{className:"w-full relative",style:{minHeight:`${i}px`},onMouseDown:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);null==k||k(e,t)},onDoubleClick:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);null==k||k(e,t)},onDragOver:M,onDrop:e=>{I(e,n,void 0,!0)},children:l.map(e=>u(kr,{event:e,isAllDay:!0,isDayView:!0,segmentIndex:e.row,allDayHeight:W,calendarRef:L,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:B,firstHour:Z,onMoveStart:w,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:p,onDetailPanelToggle:e=>b(e),selectedEventId:m,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=t.state.readOnly,o=r.find(t=>t.id===e);($||z)&&o&&n&&!a?(F(o),V(!0)):(v(e),t.state.highlightedEventId&&(t.highlightEvent(null),X.current=null))},onEventLongPress:e=>{($||z)&&v(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:t,isMobile:$,enableTouch:z},e.id))})})]}),u("div",{className:"relative overflow-y-auto calendar-content",style:{position:"relative"},children:g("div",{className:"relative flex",children:[c&&h&&(()=>{const e=h,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>U)return null;return g("div",{className:Zt,style:{top:`${(t-Z)*B}px`,width:"100%",height:0,zIndex:20},children:[g("div",{className:"flex items-center w-12 md:w-20",children:[u("div",{className:"relative w-full flex items-center"}),u("div",{className:Ut,children:$e(t)})]}),u("div",{className:"flex-1 flex items-center",children:u("div",{className:"h-0.5 w-full bg-primary relative"})})]})})(),u("div",{className:"flex-shrink-0 border-gray-200 dark:border-gray-700 w-12 md:w-20",children:s.map((e,t)=>u("div",{className:Vt,children:u("div",{className:`${Wt} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t))}),g("div",{className:"grow relative select-none",style:{WebkitTouchCallout:"none"},children:[s.map((e,t)=>u("div",{className:Bt,onDoubleClick:e=>{var t,r,o,l;const i=Math.floor((n.getTime()-a.getTime())/864e5),s=null===(r=null===(t=L.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!s)return;const d=e.clientY-s.top+(null===(l=null===(o=L.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0;null==E||E(e,i,Z+d/B)},onTouchStart:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);N(e,t)},onTouchEnd:T,onTouchMove:S,onDragOver:M,onDrop:e=>{var t,a,r,o;const l=null===(a=null===(t=L.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!l)return;const i=e.clientY-l.top+(null===(o=null===(r=L.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=Math.floor(Z+i/B);I(e,n,s)},onContextMenu:e=>$&&e.preventDefault()},t)),u("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 relative",children:u("div",{className:"absolute -top-2.5 -left-9 text-[12px] text-gray-500 dark:text-gray-400",children:"00:00"})}),u("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:o.filter(e=>!e.allDay).map(e=>{const n=d.get(e.id);return u(kr,{event:e,layout:n,isDayView:!0,calendarRef:L,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:B,firstHour:Z,onMoveStart:w,onResizeStart:C,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:p,onDetailPanelToggle:e=>b(e),selectedEventId:m,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=r.find(t=>t.id===e);($||z)&&a&&n?(F(a),V(!0)):(v(e),t.state.highlightedEventId&&(t.highlightEvent(null),X.current=null))},onEventLongPress:e=>{($||z)&&v(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:t,isMobile:$,enableTouch:z},e.id)})})]})]})})]})})},Tr=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a},Sr=({app:l,customDetailPanelContent:i,customEventDetailDialog:s,calendarRef:d,switcherMode:c="buttons"})=>{const h=l.getEvents(),{t:m,locale:v}=Nt(),{screenSize:f}=ka(),y="desktop"!==f,[p,b]=n(!1);r(()=>{b("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const D=l.getCustomMobileEventRenderer()||Ya,[x,w]=n(null),[C,E]=n(null),[k,N]=n(null),[T,S]=n(null),[M,I]=n(!1),[H,R]=n(null),O=e.useRef(null),P=l.getCurrentDate(),L=l.getVisibleMonth();L.getFullYear(),L.getMonth();const[j,A]=n(P),$=o(P.getTime());P.getTime()!==$.current&&($.current=P.getTime(),P.getFullYear()===j.getFullYear()&&P.getMonth()===j.getMonth()||A(P));const z=a(e=>{A(t=>{const n=new Date(t.getFullYear(),t.getMonth()+e,1);return l.setVisibleMonth(n),n})},[l]),{HOUR_HEIGHT:F,FIRST_HOUR:V,LAST_HOUR:W,TIME_COLUMN_WIDTH:B,ALL_DAY_HEIGHT:Z}=nr,U=e.useRef(l.state.highlightedEventId);r(()=>{var e;if(l.state.highlightedEventId!==U.current)if(l.state.highlightedEventId){const t=l.getEvents().find(e=>e.id===l.state.highlightedEventId);if(t&&(E(t),!t.allDay)){const n=Te(t.start),a=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=(n-V)*F;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else E(null);U.current=l.state.highlightedEventId},[l.state.highlightedEventId,V,F,d,l]);const _=e.useRef(null),q=t(()=>Tr(P),[P]),X=t(()=>((e,t,n)=>{const a=new Date(t);a.setHours(0,0,0,0);const r=new Date(t);return r.setHours(23,59,59,999),e.filter(e=>{const t=fe(e.start),n=fe(e.end);if(e.allDay){const e=new Date(t);e.setHours(0,0,0,0);const o=new Date(n);return o.setHours(0,0,0,0),e<=r&&o>=a}return t<r&&n>a}).map(e=>{const t=fe(e.start),a=Math.floor((t.getTime()-n.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(h,P,q),[h,P,q]),G=t(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const a=new Date(n);return a.setDate(a.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=fe(e.start),r=fe(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=he(n),i=!0),r>a&&(l=he(a),i=!0),Object.assign(Object.assign({},e),{start:i?o:e.start,end:i?l:e.end,day:0})})})(X,P),[X,P]),K=t(()=>tr.calculateDayEventLayouts(G,{viewType:"day"}),[G]),J=t(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=fe(e.start),a=fe(t.start);if(n.getTime()!==a.getTime())return n.getTime()-a.getTime();const r=fe(e.end);return fe(t.end).getTime()-r.getTime()});const n=[],a=[];return t.forEach(e=>{let t=0,r=!1;for(;!r;)n[t]?n[t].some(t=>{const n=fe(e.start),a=fe(e.end),r=fe(t.start);return n<=fe(t.end)&&r<=a})?t++:(n[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),r=!0):(n[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),r=!0)}),a})(X),[X]),Q=t(()=>{if(0===J.length)return Z;return(Math.max(...J.map(e=>e.row))+1)*Z},[J,Z]),{handleMoveStart:ee,handleCreateStart:te,handleResizeStart:ne,handleCreateAllDayEvent:ae,dragState:re,isDragging:oe}=cr(l,{calendarRef:d,allDayRowRef:_,viewType:Y.DAY,onEventsUpdate:e=>{const t=e(X),n=new Set(t.map(e=>e.id)),a=X.filter(e=>!n.has(e.id)),r=new Set(X.map(e=>e.id)),o=t.filter(e=>!r.has(e.id)),i=t.filter(e=>{if(!r.has(e.id))return!1;const t=X.find(t=>t.id===e.id);return t&&(fe(t.start).getTime()!==fe(e.start).getTime()||fe(t.end).getTime()!==fe(e.end).getTime()||t.day!==e.day||Te(t.start)!==Te(e.start)||Te(t.end)!==Te(e.end)||t.title!==e.title)});a.forEach(e=>l.deleteEvent(e.id)),o.forEach(e=>l.addEvent(e)),i.forEach(e=>l.updateEvent(e.id,e))},onEventCreate:e=>{y?(R(e),I(!0)):(l.addEvent(e),S(e.id))},onEventEdit:()=>{},currentWeekStart:q,events:X,calculateNewEventLayout:(e,t,n)=>((e,t,n,a,r)=>{const o=new Date(a),l=new Date(a);o.setHours(Math.floor(t),t%1*60,0,0),l.setHours(Math.floor(n),n%1*60,0,0);const i=[...r,{id:"-1",title:"Temp",day:0,start:he(o),end:he(l),calendarId:"blue",allDay:!1}];return tr.calculateDayEventLayouts(i,{viewType:"day"}).get("-1")||null})(0,t,n,P,G),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r,o)=>{const l=o.filter(t=>t.id!==e.id),i=new Date(r),s=new Date(i);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(i);d.setHours(Math.floor(a),a%1*60,0,0);const c=[...l,Object.assign(Object.assign({},e),{start:he(s),end:he(d),day:0})];return 0===c.length?null:tr.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,P,G),TIME_COLUMN_WIDTH:y?48:80,isMobile:y}),{handleDrop:le,handleDragOver:ie}=ur({app:l,onEventCreated:e=>{S(e.id)}}),se=Array.from({length:24},(e,t)=>({hour:t+V,label:$e(t+V)})),de=a(e=>{const t=new Date(e.getFullYear(),e.getMonth(),e.getDate());l.setCurrentDate(t),A(new Date(t.getFullYear(),t.getMonth(),1))},[l]),ce=t(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(P);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[P]);return r(()=>{w(new Date);const e=setInterval(()=>w(new Date),6e4);return()=>clearInterval(e)},[]),g("div",{className:"flex h-full bg-gray-50 dark:bg-gray-800",children:[u(Nr,{app:l,currentDate:P,currentWeekStart:q,events:h,currentDayEvents:X,organizedAllDayEvents:J,allDayAreaHeight:Q,timeSlots:se,eventLayouts:K,isToday:ce,currentTime:x,selectedEventId:C?C.id:null,setSelectedEventId:e=>{if(e){const t=h.find(t=>t.id===e);E(t||null)}else E(null)},newlyCreatedEventId:T,setNewlyCreatedEventId:S,detailPanelEventId:k,setDetailPanelEventId:N,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleCreateStart:te,handleCreateAllDayEvent:ae,handleTouchStart:(e,t)=>{if(!y&&!p)return;const n=e.touches[0],a=n.clientX,r=n.clientY,o=e.currentTarget;O.current=setTimeout(()=>{var e,n,l;const i=null===(n=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!i)return;const s=null===(l=d.current)||void 0===l?void 0:l.querySelector(".calendar-content"),c=s?s.scrollTop:0,u=r-i.top+c;null==te||te({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:r}],changedTouches:[{clientX:a,clientY:r}],target:o,currentTarget:o,cancelable:!0},t,V+u/F)},500)},handleTouchEnd:()=>{O.current&&(clearTimeout(O.current),O.current=null)},handleTouchMove:()=>{O.current&&(clearTimeout(O.current),O.current=null)},handleDragOver:ie,handleDrop:le,handleEventUpdate:e=>{l.updateEvent(e.id,e)},handleEventDelete:e=>{l.deleteEvent(e)},customDetailPanelContent:i,customEventDetailDialog:s,calendarRef:d,allDayRowRef:_,switcherMode:c,isMobile:y,isTouch:p,setDraftEvent:R,setIsDrawerOpen:I,ALL_DAY_HEIGHT:Z,HOUR_HEIGHT:F,FIRST_HOUR:V,LAST_HOUR:W}),u(hr,{app:l,currentDate:P,visibleMonth:j,currentDayEvents:X,selectedEvent:C,setSelectedEvent:E,handleMonthChange:z,handleDateSelect:de,switcherMode:c}),u(D,{isOpen:M,onClose:()=>{I(!1),R(null)},onSave:e=>{h.find(t=>t.id===e.id)?l.updateEvent(e.id,e):l.addEvent(e),I(!1),R(null)},draftEvent:H,app:l})]})},Mr={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[Y.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},Ir=(t={})=>{const n=Object.assign(Object.assign({},Mr),t),a=t=>e.createElement(Ua,{viewType:Y.DAY,originalComponent:Sr,app:t.app,config:n,className:"day-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,switcherMode:t.switcherMode,meta:t.meta});return a.displayName="DayViewAdapter",{type:Y.DAY,component:a,config:n}},Hr=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:r,timeGridWidth:o,sidebarWidth:l,allDayAreaHeight:i,organizedAllDaySegments:s,allDayLabelText:d,isMobile:c,isTouch:m,calendarRef:v,allDayRowRef:f,topFrozenContentRef:y,ALL_DAY_HEIGHT:p,HOUR_HEIGHT:b,FIRST_HOUR:D,dragState:x,isDragging:w,handleMoveStart:C,handleResizeStart:E,handleEventUpdate:k,handleEventDelete:N,newlyCreatedEventId:T,setNewlyCreatedEventId:S,selectedEventId:M,setSelectedEventId:I,detailPanelEventId:H,setDetailPanelEventId:R,handleCreateAllDayEvent:O,handleDragOver:P,handleDrop:L,customDetailPanelContent:j,customEventDetailDialog:A,events:$,setDraftEvent:z,setIsDrawerOpen:Y})=>{const F={flexShrink:0};return u("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:u("div",{ref:y,className:"flex-1 overflow-hidden relative",children:g("div",{className:"flex flex-col min-w-full",children:[g("div",{className:"flex w-full",children:[g("div",{className:"flex shrink-0",style:{width:o?o+l:"100%"},children:[u("div",{className:"w-12 md:w-20 shrink-0 sticky left-0 bg-white dark:bg-gray-900 z-20 border-b border-gray-200 dark:border-gray-700"}),u("div",{className:"flex border-b border-gray-200 dark:border-gray-700 flex-1",children:t.map((e,t)=>u("div",{className:"flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1 select-none "+(c?"flex-col gap-0":""),style:F,children:g(h,c?{children:[u("div",{className:"text-[11px] leading-tight text-gray-500 font-medium",children:n[t]}),u("div",{className:`${Yt} w-7 h-7 text-base font-medium ${a[t].isToday?en:""}`,children:a[t].date})]}:{children:[u("div",{className:"inline-flex items-center justify-center text-sm mt-1 mr-1",children:e}),u("div",{className:`${Yt} ${a[t].isToday?en:""}`,children:a[t].date})]})},t))})]}),u("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900"})]}),g("div",{className:"flex w-full",children:[g("div",{className:"flex shrink-0",style:{width:o?o+l:"100%"},children:[u("div",{className:"w-12 md:w-20 shrink-0 flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none bg-white dark:bg-gray-900 sticky left-0 z-20 ",children:d}),u("div",{className:`${_t} border-none flex-1`,ref:f,style:{minHeight:`${i}px`},children:g("div",{className:"flex flex-1 relative",style:{minHeight:`${i}px`},children:[t.map((e,n)=>{const a=new Date(r);return a.setDate(r.getDate()+n),u("div",{className:"flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(c&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${i}px`},F),onMouseDown:e=>null==O?void 0:O(e,n),onDoubleClick:e=>null==O?void 0:O(e,n),onDragOver:P,onDrop:e=>{L(e,a,void 0,!0)}},`allday-${n}`)}),u("div",{className:"absolute inset-0 pointer-events-none",children:s.map(t=>u(kr,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:p,calendarRef:v,isBeingDragged:w&&(null==x?void 0:x.eventId)===t.event.id&&"move"===(null==x?void 0:x.mode),hourHeight:b,firstHour:D,onMoveStart:C,onResizeStart:E,onEventUpdate:k,onEventDelete:N,newlyCreatedEventId:T,onDetailPanelOpen:()=>S(null),selectedEventId:M,detailPanelEventId:H,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((c||m)&&t&&n&&!a){const e=$.find(e=>e.id===t);if(e)return z(e),void Y(!0)}I(t)},onEventLongPress:e=>{(c||m)&&I(e)},onDetailPanelToggle:e=>R(e),customDetailPanelContent:j,customEventDetailDialog:A,app:e,isMobile:c,enableTouch:m},t.id))})]})})]}),u("div",{className:"flex-1 bg-white dark:bg-gray-900"})]})]})})})},Rr=({app:t,timeSlots:n,weekDaysLabels:a,currentWeekStart:r,currentWeekEvents:o,eventLayouts:l,gridWidth:i,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:h,leftFrozenContentRef:m,calendarRef:v,handleScroll:f,handleCreateStart:y,handleTouchStart:p,handleTouchEnd:b,handleTouchMove:D,handleDragOver:x,handleDrop:w,dragState:C,isDragging:E,handleMoveStart:k,handleResizeStart:N,handleEventUpdate:T,handleEventDelete:S,newlyCreatedEventId:M,setNewlyCreatedEventId:I,selectedEventId:H,setSelectedEventId:R,detailPanelEventId:O,setDetailPanelEventId:P,customDetailPanelContent:L,customEventDetailDialog:j,events:A,setDraftEvent:$,setIsDrawerOpen:z,isCurrentWeek:Y,currentTime:F,HOUR_HEIGHT:V,FIRST_HOUR:W,LAST_HOUR:B})=>{const Z={flexShrink:0},U=e.useRef(t.state.highlightedEventId);return g("div",{className:"flex flex-1 overflow-hidden relative",children:[u("div",{className:"w-12 md:w-20 shrink-0 overflow-hidden relative bg-white dark:bg-gray-900 z-10",children:g("div",{ref:m,children:[n.map((e,t)=>u("div",{className:Vt,children:u("div",{className:`${Wt} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),u("div",{className:"relative",children:u("div",{className:`${Wt} text-[10px] md:text-[12px]`,children:"00:00"})}),Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<W||t>B)return null;return u("div",{className:"absolute left-0 w-full z-20 pointer-events-none flex items-center justify-end",style:{top:`${(t-W)*V}px`,transform:"translateY(-50%)"},children:u("div",{className:Ut,children:$e(t)})})})()]})}),u("div",{ref:c,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:f,children:g("div",{ref:h,className:"relative flex",style:{width:i,minWidth:"100%"},children:[Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<W||t>B)return null;const n=e.getDay(),r=0===n?6:n-1;return g("div",{className:Zt,style:{top:`${(t-W)*V}px`,width:"100%",height:0,zIndex:20},children:[u("div",{className:"flex items-center w-0"}),u("div",{className:"flex flex-1",children:a.map((e,t)=>u("div",{className:"flex-1 flex items-center",children:u("div",{className:"h-0.5 w-full relative "+(t===r?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===r&&0!==r&&u("div",{className:"absolute w-2 h-2 bg-primary rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),g("div",{className:"grow relative",children:[n.map((e,t)=>u("div",{className:Bt,children:a.map((n,o)=>{const l=new Date(r);return l.setDate(r.getDate()+o),u("div",{className:"flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(s&&o===a.length-1?"border-r-0":""),style:Z,onDoubleClick:t=>{null==y||y(t,o,e.hour)},onTouchStart:t=>p(t,o,e.hour),onTouchEnd:b,onTouchMove:D,onDragOver:x,onDrop:t=>{w(t,l,e.hour)},onContextMenu:e=>s&&e.preventDefault()},`${t}-${o}`)})},t)),u("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 flex relative",children:a.map((e,t)=>u("div",{className:`flex-1 relative ${s&&t===a.length-1?"":"border-r"} border-gray-200 dark:border-gray-700`,style:Z},`24-${t}`))}),a.map((e,n)=>{const a=Qe(n,o),i=[];return a.forEach(e=>{const t=yr(e,r);if(t.length>0){const a=t.find(e=>e.dayIndex===n);a&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},a),{dayIndex:n})})}else i.push({event:e})}),o.forEach(e=>{if(e.allDay||e.day===n)return;const t=yr(e,r).find(e=>e.dayIndex===n);t&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),u("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*n}%)`,width:100/7+"%",height:"100%"},children:i.map(({event:e,segmentInfo:a})=>{const r=l.get(n),o=null==r?void 0:r.get(e.id);return u(kr,{event:e,layout:o,calendarRef:v,isBeingDragged:E&&(null==C?void 0:C.eventId)===e.id&&"move"===(null==C?void 0:C.mode),hourHeight:V,firstHour:W,onMoveStart:k,onResizeStart:N,onEventUpdate:T,onEventDelete:S,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),selectedEventId:H,detailPanelEventId:O,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=t.state.readOnly;if((s||d)&&e&&n&&!a){const t=A.find(t=>t.id===e);if(t)return $(t),void z(!0)}R(e),t.state.highlightedEventId&&(t.highlightEvent(null),U.current=null)},onEventLongPress:e=>{(s||d)&&R(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:L,customEventDetailDialog:j,multiDaySegmentInfo:a,app:t,isMobile:s,enableTouch:d},a?`${e.id}-seg-${n}`:e.id)})},`events-day-${n}`)})]})]})})]})},Or=({app:a,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i})=>{const{t:d,getWeekDaysLabels:c,locale:h}=Nt(),m=a.getCurrentDate(),v=a.getEvents(),{screenSize:f}=ka(),y="desktop"!==f,p="mobile"===f?48:80,[b,D]=n(0),x=e.useRef(null),[w,C]=n(!1);r(()=>{C("ontouchstart"in window||navigator.maxTouchPoints>0)},[]),s(()=>{const e=x.current;if(!e)return;const t=()=>{D(e.offsetWidth)};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const E=a.getCustomMobileEventRenderer()||Ya,k=t(()=>Tr(m),[m]),[N,T]=n(null),[S,M]=n(null),[I,H]=n(null),[R,O]=n(null),[P,L]=n(!1),[j,A]=n(null),$=e.useRef(null),{HOUR_HEIGHT:z,FIRST_HOUR:F,LAST_HOUR:V,TIME_COLUMN_WIDTH:W,ALL_DAY_HEIGHT:B}=nr,Z=e.useRef(null),U=e.useRef(null),_=e.useRef(null),q=e.useRef(null),X=t(()=>((e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=fe(e.start);a.setHours(0,0,0,0);const r=fe(e.end);return r.setHours(23,59,59,999),r>=t&&a<=n}).map(e=>{const n=fe(e.start),a=Math.floor((n.getTime()-t.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(v,k),[v,k]),G=e.useRef(a.state.highlightedEventId);r(()=>{if(a.state.highlightedEventId!==G.current)if(a.state.highlightedEventId){H(a.state.highlightedEventId);const e=X.find(e=>e.id===a.state.highlightedEventId);if(e&&!e.allDay){const t=Te(e.start),n=U.current;if(n){const e=(t-F)*z;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else H(null);G.current=a.state.highlightedEventId},[a.state.highlightedEventId,X,F,z]);const K=t(()=>((e,t)=>{const n=fr(e,t).filter(e=>e.event.allDay);n.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)a.some(n=>n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex))?t++:n=!0;a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(X,k),[X,k]),J=t(()=>{if(0===K.length)return B;const e=Math.max(...K.map(e=>e.row));return B+e*B},[K,B]),Q=t(()=>((e,t)=>{const n=new Map;for(let a=0;a<7;a++){const r=[];e.forEach(e=>{if(e.allDay)return;const n=yr(e,t);if(n.length>0){const o=n.find(e=>e.dayIndex===a);if(o){const n=o.endHour>=24?23.99:o.endHour,l=Object.assign(Object.assign({},e),{start:he(Se(tt(t,a),o.startHour)),end:he(Se(tt(t,a),n)),day:a});r.push(l)}}else e.day===a&&r.push(e)});const o=tr.calculateDayEventLayouts(r,{viewType:"week"});n.set(a,o)}return n})(X,k),[X,k]),{handleMoveStart:ee,handleCreateStart:te,handleResizeStart:ne,handleCreateAllDayEvent:ae,dragState:re,isDragging:oe}=cr(a,{calendarRef:i,allDayRowRef:Z,viewType:Y.WEEK,onEventsUpdate:(e,t)=>{const n=e(X),r=new Set(n.map(e=>e.id)),o=X.filter(e=>!r.has(e.id)),l=new Set(X.map(e=>e.id)),i=n.filter(e=>!l.has(e.id)),s=n.filter(e=>{if(!l.has(e.id))return!1;const t=X.find(t=>t.id===e.id);return t&&(fe(t.start).getTime()!==fe(e.start).getTime()||fe(t.end).getTime()!==fe(e.end).getTime()||t.day!==e.day||Te(t.start)!==Te(e.start)||Te(t.end)!==Te(e.end)||t.title!==e.title)});o.forEach(e=>a.deleteEvent(e.id)),i.forEach(e=>a.addEvent(e)),s.forEach(e=>a.updateEvent(e.id,e,t))},onEventCreate:e=>{y?(A(e),L(!0)):(a.addEvent(e),O(e.id))},onEventEdit:()=>{},currentWeekStart:k,events:X,calculateNewEventLayout:(e,t,n)=>((e,t,n,a)=>{const r=new Date,o=new Date;r.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const l={id:"-1",title:"Temp",day:e,start:he(r),end:he(o),calendarId:"blue",allDay:!1},i=[...a.filter(t=>t.day===e&&!t.allDay),l];return tr.calculateDayEventLayouts(i,{viewType:"week"}).get("-1")||null})(e,t,n,X),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r)=>{const o=r.map(r=>{if(r.id!==e.id)return r;const o=fe(r.start),l=Se(o,n),i=Se(o,a),s=he(l),d=he(i);return Object.assign(Object.assign({},r),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:tr.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,X),TIME_COLUMN_WIDTH:p,isMobile:y}),{handleDrop:le,handleDragOver:ie}=ur({app:a,onEventCreated:e=>{O(e.id)}}),se=t(()=>c(h,"short"),[h,c]),de=t(()=>{if(!y)return[];const e=h.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?c(h,"narrow"):se.map(t=>{if("en"===e){if(t.startsWith("Tu"))return"Tu";if(t.startsWith("Th"))return"Th";if(t.startsWith("Sa"))return"Sa";if(t.startsWith("Su"))return"Su"}return t.charAt(0)})},[y,h,c,se]),ce=t(()=>d("allDay"),[d]),ue=Array.from({length:24},(e,t)=>({hour:t+F,label:$e(t+F)})),ge=t(()=>{const e=new Date;return e.setHours(0,0,0,0),se.map((t,n)=>{const a=new Date(k);a.setDate(k.getDate()+n);const r=new Date(a);return r.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(h,{month:"short"}),fullDate:new Date(a),isToday:r.getTime()===e.getTime()}})},[k,se,h]),me=e=>{a.updateEvent(e.id,e)},ve=e=>{a.deleteEvent(e)},ye=t(()=>{const e=new Date,t=Tr(e);return k.getTime()===t.getTime()},[k]);r(()=>{T(new Date);const e=setInterval(()=>T(new Date),6e4);return()=>clearInterval(e)},[]);const pe=y?"175%":"100%";return g("div",{className:"relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none",children:[u(mr,{calendar:a,viewType:Y.WEEK,currentDate:m,onPrevious:()=>a.goToPrevious(),onNext:()=>a.goToNext(),onToday:()=>a.goToToday()}),u(Hr,{app:a,weekDaysLabels:se,mobileWeekDaysLabels:de,weekDates:ge,currentWeekStart:k,timeGridWidth:b,sidebarWidth:p,allDayAreaHeight:J,organizedAllDaySegments:K,allDayLabelText:ce,isMobile:y,isTouch:w,calendarRef:i,allDayRowRef:Z,topFrozenContentRef:_,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:z,FIRST_HOUR:F,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleEventUpdate:me,handleEventDelete:ve,newlyCreatedEventId:R,setNewlyCreatedEventId:O,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:S,setDetailPanelEventId:M,handleCreateAllDayEvent:ae,handleDragOver:ie,handleDrop:le,customDetailPanelContent:o,customEventDetailDialog:l,events:v,setDraftEvent:A,setIsDrawerOpen:L}),u(Rr,{app:a,timeSlots:ue,weekDaysLabels:se,currentWeekStart:k,currentWeekEvents:X,eventLayouts:Q,gridWidth:pe,isMobile:y,isTouch:w,scrollerRef:U,timeGridRef:x,leftFrozenContentRef:q,calendarRef:i,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;_.current&&(_.current.scrollLeft=n),q.current&&(q.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:te,handleTouchStart:(e,t,n)=>{if(!y&&!w)return;const a=e.touches[0],r=a.clientX,o=a.clientY,l=e.currentTarget;$.current=setTimeout(()=>{null==te||te({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{$.current&&(clearTimeout($.current),$.current=null)},handleTouchMove:()=>{$.current&&(clearTimeout($.current),$.current=null)},handleDragOver:ie,handleDrop:le,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleEventUpdate:me,handleEventDelete:ve,newlyCreatedEventId:R,setNewlyCreatedEventId:O,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:S,setDetailPanelEventId:M,customDetailPanelContent:o,customEventDetailDialog:l,events:v,setDraftEvent:A,setIsDrawerOpen:L,isCurrentWeek:ye,currentTime:N,HOUR_HEIGHT:z,FIRST_HOUR:F,LAST_HOUR:V}),u(E,{isOpen:P,onClose:()=>{L(!1),A(null)},onSave:e=>{v.find(t=>t.id===e.id)?a.updateEvent(e.id,e):a.addEvent(e),L(!1),A(null)},draftEvent:j,app:a})]})},Pr={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[Y.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},Lr=(t={})=>{const n=Object.assign(Object.assign({},Pr),t),a=t=>e.createElement(Ua,{viewType:Y.WEEK,originalComponent:Or,app:t.app,config:n,className:"week-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,switcherMode:t.switcherMode,meta:t.meta});return a.displayName="WeekViewAdapter",{type:Y.WEEK,component:a,config:n}},jr=e.memo(({currentMonth:e,currentYear:a,newlyCreatedEventId:l,screenSize:i,isScrolling:s,isDragging:c,item:h,weekHeight:m,events:v,dragState:f,calendarRef:y,onEventUpdate:p,onEventDelete:b,onMoveStart:D,onCreateStart:x,onResizeStart:w,onDetailPanelOpen:C,onMoreEventsClick:E,onChangeView:k,onSelectDate:N,selectedEventId:T,onEventSelect:S,onEventLongPress:M,detailPanelEventId:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,onCalendarDrop:P,onCalendarDragOver:L,app:j,enableTouch:A})=>{const{t:$,locale:z}=Nt(),[F,V]=n(!1),W=o(null),B=o(null),Z=o(null),U=t(()=>{const e=m-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=e-20;return{maxSlots:Math.min(4,Math.floor(e/17)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/17)))}},[m]);r(()=>s?(V(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):F?(W.current=setTimeout(()=>{V(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[s,F]);const{weekData:_}=h,q=_.days.find(e=>1===e.day),X=`${m}px`,G=t(()=>fr(v,_.startDate),[v,_.startDate]),K=t(()=>((e,t)=>{const n=[],a=new Date(t);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void Q.warn("Event missing start or end date:",e);const r=fe(e.start),o=fe(e.end),l=new Date(r);l.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let s=new Date(i);if(!e.allDay&&0===o.getHours()&&0===o.getMinutes()&&0===o.getSeconds()){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(s=new Date(i),s.setDate(s.getDate()-1))}const c=l.toDateString()!==s.toDateString();if(!c||e.allDay)if(c&&e.allDay){let l=new Date(r);l<t&&(l=new Date(t),l.setHours(0,0,0,0));const i=o>a?a:o;for(;l<=i;){const t=d.PlainDate.from({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate()});n.push(Object.assign(Object.assign({},e),{start:t,end:t,day:l.getDay()})),l.setDate(l.getDate()+1)}}else n.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:r.getDay()}))}),n})(v,_.startDate),[v,_.startDate]),J=t(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==a?a-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,a=!1;for(;!a;)n.some(n=>{var a;const r=Math.abs((null!==(a=n.yPosition)&&void 0!==a?a:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return r&&o})?t+=16:a=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const a=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);a[n]||(a[n]=[]),a[n].push(e)}),a.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),a})(G),[G]),ee=t(()=>{const e=Array(7).fill(0);return J.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)e[a]=Math.max(e[a],n+1)})}),e},[J]),te=t(()=>{for(const e of _.days){if(K.filter(t=>{if(!t.start||!t.end)return fe(t.start).toDateString()===e.date.toDateString();const n=fe(t.start),a=fe(t.end);if(!t.allDay){if(!(0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds())){const t=a.getTime()-n.getTime();if(t>0&&t<864e5)return n.toDateString()===e.date.toDateString()}}return n.toDateString()===e.date.toDateString()||a.toDateString()===e.date.toDateString()}).length>U.maxSlots)return U.maxSlotsWithMore}return U.maxSlots},[_.days,K,U.maxSlots,U.maxSlotsWithMore]),ne=t(()=>Math.max(0,17*J.length),[J]),ae=(t,n)=>{var r;const o=t.date.toLocaleDateString(z,{month:z.startsWith("zh")||z.startsWith("ja")?"short":"long"})===e&&t.year===a;var s;const d=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:Te(e.start)-Te(t.start)))((s=t.date,K.filter(e=>{if(!e.start||!e.end)return fe(e.start).toDateString()===s.toDateString();const t=fe(e.start),n=fe(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===s.toDateString()}return t.toDateString()===s.toDateString()||n.toDateString()===s.toDateString()}))),h=d.length;let m=0;m=h<=U.maxSlots?h:U.maxSlotsWithMore;const v=d.slice(0,m),F=h-m,V=F>0,W=[],_=m,q=Math.min(null!==(r=ee[n])&&void 0!==r?r:0,_);for(let e=0;e<q;e++)W.push(u("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));return v.forEach((e,t)=>{const n=J.flat().find(t=>t.originalEventId===e.id);e.allDay&&n||W.push(u(kr,{event:e,isAllDay:!!e.allDay,isMonthView:!0,isBeingDragged:c&&f.eventId===e.id&&"move"===f.mode,calendarRef:y,hourHeight:72,firstHour:0,onEventUpdate:p,onEventDelete:b,onMoveStart:D,onResizeStart:w,onDetailPanelOpen:C,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:l,selectedEventId:T,detailPanelEventId:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,app:j,isMobile:"desktop"!==i,enableTouch:A},`${e.id}-${e.day}-${Te(e.start)}-${t}`))}),g("div",{className:`\n relative flex flex-col border-r border-gray-200 dark:border-gray-700 last:border-r-0\n ${o?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,style:{height:X},"data-date":(G=t.date,`${G.getFullYear()}-${String(G.getMonth()+1).padStart(2,"0")}-${String(G.getDate()).padStart(2,"0")}`),onDoubleClick:e=>null==x?void 0:x(e,t.date),onTouchStart:e=>{if("mobile"!==i&&!A)return;const n=e.touches[0],a=n.clientX,r=n.clientY;Z.current={x:a,y:r},B.current=setTimeout(()=>{null==x||x(e,t.date),B.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(B.current&&Z.current){const t=Math.abs(e.touches[0].clientX-Z.current.x),n=Math.abs(e.touches[0].clientY-Z.current.y);(t>10||n>10)&&(clearTimeout(B.current),B.current=null)}},onTouchEnd:()=>{B.current&&(clearTimeout(B.current),B.current=null),Z.current=null},onDragOver:L,onDrop:e=>null==P?void 0:P(e,t.date),children:[g("div",{className:"flex items-center justify-between px-2 h-[33px] relative z-20",children:[u("div",{className:"flex-1"}),u("div",{className:"flex items-center",children:u("span",{className:`\n inline-flex items-center justify-center h-6 min-w-6 rounded-full text-sm font-medium whitespace-nowrap px-1\n ${t.isToday?"bg-primary text-primary-foreground":o?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:1===t.day&&"desktop"===i?t.date.toLocaleDateString(z,{month:"short",day:"numeric"}):t.day})})]}),g("div",{className:"flex-1 overflow-hidden px-1",children:[W,V&&g("div",{className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline text-center md:text-left font-medium md:font-normal relative z-20 bg-white dark:bg-gray-900",onClick:e=>{e.stopPropagation(),E?E(t.date):(null==N||N(t.date),null==k||k(Y.DAY))},children:["+",F," ",u("span",{className:"hidden md:inline",children:$("more")})]})]})]},`day-${t.date.getTime()}`);var G},re=t(()=>q?q.date.toLocaleDateString(z,{month:"long",year:"numeric"}):"",[q,z]);return g("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:X},children:[q&&u("div",{className:`\n absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${F?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},children:u("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:re})}),u("div",{className:"h-full flex flex-col",children:g("div",{className:"calendar-week relative h-full",children:[u("div",{className:"grid grid-cols-7 h-full",children:_.days.map((e,t)=>ae(e,t))}),J.length>0&&u("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${ne}px`,zIndex:10},children:J.slice(0,te).map((e,t)=>u("div",{className:"absolute inset-0",children:e.map(e=>u(kr,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:y,hourHeight:72,firstHour:0,onEventUpdate:p,onEventDelete:b,onMoveStart:D,onResizeStart:w,isBeingDragged:c&&f.eventId===e.event.id&&"move"===f.mode,isBeingResized:c&&f.eventId===e.event.id&&"resize"===f.mode,newlyCreatedEventId:l,onDetailPanelOpen:C,selectedEventId:T,onEventSelect:S,onEventLongPress:M,detailPanelEventId:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,app:j,isMobile:"desktop"!==i,enableTouch:A},e.id))},`layer-${t}`))})]})})]})});jr.displayName="WeekComponent";const Ar=({app:e,customDetailPanelContent:a,customEventDetailDialog:l,calendarRef:i})=>{const{getWeekDaysLabels:s,getMonthLabels:d,locale:c}=Nt(),h=e.getCurrentDate(),m=e.getEvents(),v=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),f=o(null),y=t(()=>{const e=f.current;return e&&e.length===m.length&&e.every((e,t)=>e===m[t])?e:(f.current=m,m)},[m]),p=t(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),a=0===n?-6:1-n;return t.setDate(t.getDate()+a),t.setHours(0,0,0,0),t},n=(t,n)=>{const a=e.get(t);a?a.push(n):e.set(t,[n])};return y.forEach(e=>{if(!e.start)return;const a=fe(e.start),r=e.end?fe(e.end):a,o=new Date(a);o.setHours(0,0,0,0);const l=new Date(r);l.setHours(0,0,0,0);let i=new Date(l);if(!e.allDay){0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds()||i.setDate(i.getDate()-1)}i<o&&(i=new Date(o));const s=t(o),d=t(i);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[y]),{screenSize:b}=ka(),[D,x]=n(!1);r(()=>{x("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const w=e.getCustomMobileEventRenderer()||Ya,[C,E]=n(119),[k,N]=n(!1),T=o(C),S=o([]),[M,I]=n(null),[H,R]=n(!1),[O,P]=n(null),[L,j]=n(null),A=o(e.state.highlightedEventId);r(()=>{e.state.highlightedEventId?j(e.state.highlightedEventId):A.current&&j(null),A.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const[$,z]=n(null),F=t(()=>{const e=h.getDay(),t=h.getDate()-e+(0===e?-6:1),n=new Date(h);return n.setDate(t),n.setHours(0,0,0,0),n},[h]),{handleMoveStart:V,handleCreateStart:W,handleResizeStart:B,dragState:Z,isDragging:U}=cr(e,{calendarRef:i,viewType:Y.MONTH,onEventsUpdate:(t,n)=>{const a=t(y),r=new Set(a.map(e=>e.id)),o=y.filter(e=>!r.has(e.id)),l=new Set(y.map(e=>e.id)),i=a.filter(e=>!l.has(e.id)),s=a.filter(e=>{if(!l.has(e.id))return!1;const t=y.find(t=>t.id===e.id);return t&&(fe(t.start).getTime()!==fe(e.start).getTime()||fe(t.end).getTime()!==fe(e.end).getTime()||t.day!==e.day||Te(t.start)!==Te(e.start)||Te(t.end)!==Te(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});o.forEach(t=>e.deleteEvent(t.id)),i.forEach(t=>e.addEvent(t)),s.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{"desktop"!==b?(P(t),R(!0)):e.addEvent(t)},onEventEdit:e=>{I(e.id)},currentWeekStart:F,events:y}),{handleDrop:_,handleDragOver:q}=ur({app:e,onEventCreated:e=>{I(e.id)}}),X=t(()=>s(c,"short"),[c,s]),{currentMonth:G,currentYear:K,isScrolling:J,virtualData:Q,scrollElementRef:ee,handleScroll:te,handlePreviousMonth:ne,handleNextMonth:ae,handleToday:re,setScrollTop:oe}=Na({currentDate:h,weekHeight:C,onCurrentMonthChange:(t,n)=>{const a=c.startsWith("zh")||c.startsWith("ja"),r=d(c,a?"short":"long").indexOf(t);r>=0&&e.setVisibleMonth(new Date(n,r,1))},initialWeeksToLoad:156,locale:c,isEnabled:k}),le=o(0),[ie,se]=n(0),de=t(()=>ie-6*C,[ie,C]),{visibleWeeks:ce,startIndex:ue}=t(()=>{const{visibleItems:e,displayStartIndex:t}=Q,n=e.findIndex(e=>e.index===t);if(-1===n)return S.current.length>0?{visibleWeeks:S.current,startIndex:le.current}:{visibleWeeks:[],startIndex:t};const a=e.slice(n,n+8);return a.length>=6&&(S.current=a,le.current=t),{visibleWeeks:a,startIndex:t}},[Q]),ge=t(()=>ue*C,[ue,C]),he=t(()=>{const e=Q.totalHeight,t=ue*C+16*C+de;return Math.max(0,e-t)},[Q.totalHeight,ue,C,de]);r(()=>{const e=ee.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(se(t),!k&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==T.current){const t=e.scrollTop;if(t>0){const a=Math.round(t/T.current)*n;e.scrollTop=a,oe(a)}}E(n),T.current=n,requestAnimationFrame(()=>{N(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[ee,k,oe]),r(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.floor(e/6));E(t)},[]);const me=t=>{e.updateEvent(t.id,t)},ve=t=>{e.deleteEvent(t)},ye=t=>{e.changeView(t)};return g("div",{className:jt,children:[u(mr,{calendar:e,viewType:Y.MONTH,currentDate:h,customTitle:c.startsWith("zh")||c.startsWith("ja")?`${K}年${G}`:`${G} ${K}`,onPrevious:()=>{e.goToPrevious(),ne()},onNext:()=>{e.goToNext(),ae()},onToday:()=>{e.goToToday(),re()}}),u("div",{className:"sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:u("div",{className:"grid grid-cols-7 px-2",children:X.map((e,t)=>u("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},t))})}),g("div",{ref:ee,className:Ft,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:k?"visible":"hidden"},onScroll:te,children:[u("div",{style:{height:ge}}),ce.map((t,n)=>{var r;const o=null!==(r=p.get(t.weekData.startDate.getTime()))&&void 0!==r?r:[],s=5===n?Object.assign(Object.assign({},t),{height:t.height+de}):t;return u(jr,{item:s,weekHeight:C,currentMonth:G,currentYear:K,screenSize:b,isScrolling:J,calendarRef:i,events:o,onEventUpdate:me,onEventDelete:ve,onMoveStart:V,onCreateStart:W,onResizeStart:B,isDragging:U,dragState:Z,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:ye,onSelectDate:e.selectDate,selectedEventId:L,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable;if(("desktop"!==b||D)&&t&&n){const e=y.find(e=>e.id===t);if(e)return P(e),void R(!0)}j(t)},onEventLongPress:e=>{("desktop"!==b||D)&&j(e)},detailPanelEventId:$,onDetailPanelToggle:z,customDetailPanelContent:a,customEventDetailDialog:l,onCalendarDrop:_,onCalendarDragOver:q,calendarSignature:v,app:e,enableTouch:D},`week-${t.weekData.startDate.getTime()}`)}),u("div",{style:{height:he}})]}),u(w,{isOpen:H,onClose:()=>{R(!1),P(null)},onSave:t=>{y.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),R(!1),P(null)},draftEvent:O,app:e})]})},$r={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[Y.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[Y.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}},zr=(t={})=>{const n=Object.assign(Object.assign({},$r),t),a=t=>e.createElement(Ua,{viewType:Y.MONTH,originalComponent:Ar,app:t.app,config:n,className:"month-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,switcherMode:t.switcherMode,meta:t.meta});return a.displayName="MonthViewAdapter",{type:Y.MONTH,component:a,config:n}};const Yr=e.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:r,onMoreEventsClick:o,moreCount:l=0})=>{const{t:i}=Nt(),s=e.getDate(),d=1===s,c=e.toLocaleDateString(n,{month:"short"}).toUpperCase(),h=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;return g("div",{className:`\n relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800\n ${d?"border-l-2 border-l-primary dark:border-l-primary":""}\n overflow-hidden bg-white dark:bg-gray-900 select-none\n `,style:{aspectRatio:"1/1"},onClick:()=>a(e),onDoubleClick:t=>null==r?void 0:r(t,e),"data-date":h,children:[g("div",{className:"flex items-center px-1 py-1 shrink-0 h-6",children:[d&&u("span",{className:"text-[9px] font-bold text-primary-foreground bg-primary px-1 py-0.5 rounded-sm leading-none",children:c}),u("span",{className:"text-[10px] font-medium ml-auto "+(t?"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center":"text-gray-700 dark:text-gray-300"),children:s})]}),l>0&&u("div",{className:"absolute bottom-0.5 left-1 z-20",children:g("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",l," ",i("more")]})})]})});Yr.displayName="YearDayCell";const Fr=({segment:e,columnsPerRow:t,isDragging:a,isSelected:l,onMoveStart:i,onResizeStart:s,onEventSelect:d,detailPanelEventId:c,onDetailPanelToggle:v,newlyCreatedEventId:f,onDetailPanelOpen:y,customDetailPanelContent:p,customEventDetailDialog:b,app:D,calendarRef:x})=>{const{event:w,startCellIndex:C,endCellIndex:E,visualRowIndex:k,isFirstSegment:N,isLastSegment:T}=e,S=o(null),M=o(null),[I,H]=n(null),R=c===e.id,O=!(null==D?void 0:D.state.readOnly),P=C/t*100,L=(E-C+1)/t*100,j=w.calendarId||"blue",A=l?Le(j):Oe(j),$=l?"#fff":Pe(j),z=je(j),Y=!!w.allDay,F=Y?vr(w):null,V=18*k,W=()=>{var t;const n=null===(t=S.current)||void 0===t?void 0:t.getBoundingClientRect();if(n){const e=200,t=300;let a=n.bottom+10,r=n.left;a+e>window.innerHeight&&(a=n.top-e-10),r+t>window.innerWidth&&(r=window.innerWidth-t-10),H({top:a,left:r,eventHeight:n.height,eventMiddleY:n.top+n.height/2})}null==v||v(e.id)};r(()=>{f===w.id&&!R&&N&&setTimeout(()=>{W(),null==y||y()},50)},[f,w.id,R,y,N]);const B=e=>{const t="left"===e,n=t?N:T;return w.allDay&&n&&s&&O?u("div",{className:`resize-handle absolute ${t?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),s(e,w,t?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null};return g(h,{children:[g("div",{ref:S,className:"df-year-event absolute z-30 text-[11px] px-1 overflow-hidden whitespace-nowrap cursor-pointer transition-colors group",style:{left:`calc(${P}% + 2px)`,top:`${V}px`,height:"16px",backgroundColor:A,color:$,opacity:a?.6:1,width:`calc(${L}% - 4px)`,pointerEvents:a?"none":"auto",borderRadius:N&&T?"0.25rem":N?"0.25rem 0 0 0.25rem":T?"0 0.25rem 0.25rem 0":"0"},"data-segment-days":E-C+1,"data-event-id":w.id,onMouseDown:e=>{e.stopPropagation(),i&&i(e,w)},onClick:e=>{e.preventDefault(),e.stopPropagation(),d&&d(w.id)},onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),W()},onTouchStart:e=>{e.stopPropagation(),d&&d(w.id),i&&i(e,w)},title:w.title,children:[B("left"),(()=>{if(w.allDay){const t=()=>e.isFirstSegment?w.title:"···";return g("div",{className:"df-year-event-content flex items-center min-w-0 w-full pointer-events-auto h-full",children:[e.isFirstSegment&&vr(w)&&u("div",{className:"df-year-event-icon shrink-0 mr-1",children:u("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:je(j),width:"12px",height:"12px"},children:vr(w)})}),u("div",{className:"flex-1 min-w-0",children:u("div",{className:"df-year-event-title font-medium text-[11px] leading-none whitespace-nowrap overflow-hidden",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t()})}),e.isLastSegment&&!e.isFirstSegment&&u("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:u("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=e.isFirstSegment?w.title:"";return g("div",{className:"df-year-event-content w-full h-full flex items-center overflow-hidden gap-1 pointer-events-auto",children:[!Y&&u("span",{style:{backgroundColor:z},className:"df-year-event-indicator inline-block w-0.75 h-3 shrink-0 rounded-full"}),Y&&F&&u("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:F}),u("span",{className:"df-year-event-title w-full block font-medium whitespace-nowrap overflow-hidden leading-none",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t})]})})(),B("right")]}),(()=>{if(!R||!x)return null;const e=()=>{null==v||v(null),d&&d(null)};if(b){const t=b,n={event:w,isOpen:R,isAllDay:Y,onClose:e,app:D,onEventUpdate:e=>null==D?void 0:D.updateEvent(e.id,e),onEventDelete:e=>null==D?void 0:D.deleteEvent(e)};if("undefined"==typeof window||"undefined"==typeof document)return null;const a=document.body;return a?m.createPortal(u(t,Object.assign({},n)),a):null}return I?p?u(Dr,{event:w,position:I,panelRef:M,isAllDay:Y,onClose:e,contentRenderer:p,onEventUpdate:e=>null==D?void 0:D.updateEvent(e.id,e),onEventDelete:e=>null==D?void 0:D.deleteEvent(e),eventVisibility:"visible",calendarRef:x,selectedEventElementRef:S}):u(br,{event:w,position:I,panelRef:M,isAllDay:Y,onClose:e,app:D,onEventUpdate:e=>null==D?void 0:D.updateEvent(e.id,e),onEventDelete:e=>null==D?void 0:D.deleteEvent(e),eventVisibility:"visible",calendarRef:x,selectedEventElementRef:S}):null})()]})},Vr=e.memo(({rowDays:e,events:n,columnsPerRow:a,app:r,calendarRef:o,locale:l,isDragging:i,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:h,selectedEventId:m,onEventSelect:v,onMoreEventsClick:f,newlyCreatedEventId:y,onDetailPanelOpen:p,detailPanelEventId:b,onDetailPanelToggle:D,customDetailPanelContent:x,customEventDetailDialog:w})=>{const C=new Date;C.setHours(0,0,0,0);const E=t(()=>function(e,t,n){if(0===t.length)return[];const a=t[0],r=t[t.length-1],o=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime(),i=e.filter(e=>{if(!e.start)return!1;const t=fe(e.start),n=e.end?fe(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=l&&r>=o});i.sort((e,t)=>{const n=fe(e.start).getTime(),a=e.end?fe(e.end).getTime():n,r=fe(t.start).getTime(),o=a-n,l=(t.end?fe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const s=[],d=[];return i.forEach(e=>{const r=fe(e.start),i=e.end?fe(e.end):r,c=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime();let g=-1,h=-1;const m=Math.round((c-o)/864e5);g=m>=0?m:0;const v=Math.round((u-o)/864e5);h=v<t.length?v:t.length-1,g=Math.max(0,Math.min(g,n-1)),h=Math.max(0,Math.min(h,n-1));const f=c>=o,y=u<=l;let p=0;for(;;){let e=!1;d[p]||(d[p]=[]);for(let t=g;t<=h;t++)if(d[p][t]){e=!0;break}if(!e){for(let e=g;e<=h;e++)d[p][e]=!0;break}p++}s.push({id:`${e.id}_${a.getTime()}`,event:e,startCellIndex:g,endCellIndex:h,isFirstSegment:f,isLastSegment:y,visualRowIndex:p})}),s}(n,e,a),[n,e,a]),{visibleSegments:k,moreCounts:N}=t(()=>{const t=new Array(e.length).fill(0);E.forEach(n=>{const a=Math.max(0,n.startCellIndex),r=Math.min(e.length-1,n.endCellIndex);for(let e=a;e<=r;e++)t[e]++});const n=[],a=new Array(e.length).fill(0);return E.forEach(r=>{let o=!0;const l=Math.max(0,r.startCellIndex),i=Math.min(e.length-1,r.endCellIndex);for(let e=l;e<=i;e++){const n=t[e]>3?1:2;if(r.visualRowIndex>n){o=!1;break}}if(o)n.push(r);else for(let e=l;e<=i;e++)a[e]++}),{visibleSegments:n,moreCounts:a}},[E,e.length]);return g("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${a}, 1fr)`},children:[e.map((e,t)=>{const n=e.getTime()===C.getTime();return u(Yr,{date:e,isToday:n,locale:l,onSelectDate:e=>{r.selectDate(e)},onCreateStart:h,onMoreEventsClick:f,moreCount:N[t]},e.getTime())}),u("div",{className:"absolute inset-0 pointer-events-none",style:{top:26,bottom:0,left:0,right:0},children:u("div",{className:"relative w-full h-full",children:k.map(e=>u("div",{className:"pointer-events-auto",children:u(Fr,{segment:e,columnsPerRow:a,isDragging:i&&s.eventId===e.event.id,isSelected:m===e.event.id,onMoveStart:d,onResizeStart:c,onEventSelect:v,onDetailPanelToggle:D,newlyCreatedEventId:y,onDetailPanelOpen:p,calendarRef:o,app:r,detailPanelEventId:b,customDetailPanelContent:x,customEventDetailDialog:w})},e.id))})})]})});Vr.displayName="YearRowComponent";const Wr=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var h;const{locale:m}=Nt(),v=e.getCurrentDate(),f=v.getFullYear(),y=e.getEvents(),p=o(null),[b,D]=n(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[x,w]=n(!1),[C,E]=n(null),[k,N]=n(null),[T,S]=n(null);r(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(E(null),N(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),r(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0].contentRect.width,n=Math.floor(t/80);D(Math.max(1,n)),w(!0)});return t.observe(e),()=>t.disconnect()},[]);const{handleMoveStart:M,handleResizeStart:I,handleCreateStart:H,dragState:R,isDragging:O}=cr(e,{calendarRef:l,viewType:Y.YEAR,onEventsUpdate:(t,n)=>{t(y).forEach(t=>{const a=y.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:y,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{S(e.id)}}),P=null!==(h=null==c?void 0:c.showTimedEventsInYearView)&&void 0!==h&&h,L=a((t,n)=>{if(P)null==H||H(t,n);else{const t=d.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),a={id:`event-${Date.now()}`,title:"",start:t,end:t,allDay:!0};e.addEvent(a),S(a.id)}},[P,H,e]),j=t(()=>{const e=[],t=new Date(f,0,1),n=new Date(f,11,31),a=new Date(t);for(;a<=n;)e.push(new Date(a)),a.setDate(a.getDate()+1);return e},[f]),A=t(()=>function(e,t){const n=[];for(let a=0;a<e.length;a+=t)n.push(e.slice(a,a+t));return n}(j,b),[j,b]),$=t(()=>{const e=new Date(f,0,1),t=new Date(f,11,31,23,59,59);return y.filter(n=>{if(!n.start)return!1;if(!P&&!n.allDay)return!1;const a=fe(n.start),r=n.end?fe(n.end):a;return a<=t&&r>=e})},[y,f,P]);return g("div",{className:jt,children:[u(mr,{calendar:e,viewType:Y.YEAR,currentDate:v,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${f}年`:`${f}`,onPrevious:()=>{const t=new Date(v);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(v);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),u("div",{ref:p,className:`${Ft}`,style:{overflow:"hidden auto"},children:u("div",{className:"w-full flex flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:x?1:0,transition:"opacity 0.2s ease"},children:A.map((t,n)=>u(Vr,{rowDays:t,events:$,columnsPerRow:b,app:e,calendarRef:l,locale:m,isDragging:O,dragState:R,onMoveStart:M,onResizeStart:I,onCreateStart:L,selectedEventId:C,onEventSelect:E,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:T,onDetailPanelOpen:()=>S(null),detailPanelEventId:k,onDetailPanelToggle:N,customDetailPanelContent:i,customEventDetailDialog:s},n))})})]})};function Br(e,t,n){const a=new Date(n,t,1),r=new Date(n,t+1,0).getDate(),o=a.getDay(),l=a.getTime(),i=new Date(n,t,r,23,59,59,999).getTime(),s=e.filter(e=>{if(!e.start)return!1;const t=fe(e.start),n=e.end?fe(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=i&&r>=l});s.sort((e,t)=>{const n=fe(e.start).getTime(),a=e.end?fe(e.end).getTime():n,r=fe(t.start).getTime(),o=a-n,l=(t.end?fe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const d=[],c=[];s.forEach(e=>{const a=fe(e.start),r=e.end?fe(e.end):a,s=new Date(Math.max(a.getTime(),l)),u=new Date(Math.min(r.getTime(),i)),g=s.getDate(),h=u.getDate(),m=o+(g-1),v=o+(h-1),f=a.getMonth()===t&&a.getFullYear()===n,y=r.getMonth()===t&&r.getFullYear()===n;let p=0;for(;;){let e=!1;c[p]||(c[p]=[]);for(let t=m;t<=v;t++)if(c[p][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)c[p][e]=!0;break}p++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:y,visualRowIndex:p,monthIndex:t})});const u=d.length>0?Math.max(...d.map(e=>e.visualRowIndex)):-1;return{segments:d,maxVisualRow:u}}const Zr=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var h;const{locale:m,getWeekDaysLabels:v}=Nt(),f=e.getCurrentDate(),y=f.getFullYear(),p=e.getEvents(),b=new Date;b.setHours(0,0,0,0);const D=o(null),x=o(null),w=o(null),[C,E]=n(0),[k,N]=n(0),[T,S]=n(null),[M,I]=n(null),[H,R]=n(null);r(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(S(null),I(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const O=t(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(y,t,1),a=new Date(y,t+1,0).getDate(),r=n.getDay()+a;r>e&&(e=r)}return e},[y]),{handleMoveStart:P,handleResizeStart:L,handleCreateStart:j,dragState:A,isDragging:$}=cr(e,{calendarRef:l,viewType:Y.YEAR,onEventsUpdate:(t,n)=>{t(p).forEach(t=>{const a=p.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:p,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{R(e.id)}}),z=null!==(h=null==c?void 0:c.showTimedEventsInYearView)&&void 0!==h&&h,F=a((t,n)=>{if(z)null==j||j(t,n);else{const t=d.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),a={id:`event-${Date.now()}`,title:"",start:t,end:t,allDay:!0};e.addEvent(a),R(a.id)}},[z,j,e]),V=t(()=>{const e=v(m,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(m.startsWith("zh"))return e.charAt(e.length-1);const t=e.substring(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),n=[];for(let e=0;e<O;e++)n.push(t[e%7]);return n},[m,v,O]),W=t(()=>{const e=new Date(y,0,1),t=new Date(y,11,31,23,59,59);return p.filter(n=>{if(!n.start)return!1;if(!z&&!n.allDay)return!1;const a=fe(n.start),r=n.end?fe(n.end):a;return a<=t&&r>=e})},[p,y,z]),B=t(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(y,t,1),a=new Date(y,t+1,0).getDate(),r=n.getDay(),o=[];for(let e=0;e<r;e++)o.push(null);for(let e=1;e<=a;e++)o.push(new Date(y,t,e));for(;o.length<O;)o.push(null);const l=n.toLocaleDateString(m,{month:"short"}),i=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Br(W,t,y),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:i,days:o,eventSegments:s,minHeight:u})}return e},[y,m,O,W]),Z=a(e=>{const t=e.currentTarget;D.current&&(D.current.scrollLeft=t.scrollLeft),x.current&&(x.current.scrollTop=t.scrollTop)},[]);r(()=>{const e=()=>{if(w.current){const e=w.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;N(e=>e!==t?t:e),E(e=>e!==n?n:e)}},t=w.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[B]);return g("div",{className:"h-full bg-white dark:bg-gray-900 overflow-hidden select-none",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},children:[u("div",{className:"col-span-2",children:u(mr,{calendar:e,viewType:Y.YEAR,currentDate:f,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${y}年`:`${y}`,onPrevious:()=>{const t=new Date(f);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(f);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),u("div",{className:"bg-gray-50 dark:bg-gray-900 border-r border-b border-gray-200 dark:border-gray-800 z-30"}),u("div",{ref:D,className:"overflow-hidden bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800",children:g("div",{className:"flex",style:{minWidth:`calc(1352px + ${C}px)`},children:[u("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${O}, minmax(0, 1fr))`,minWidth:"1352px"},children:V.map((e,t)=>{const n=t%7;return u("div",{className:"text-center py-2 text-[10px] font-bold tracking-wider border-r border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},t)})}),C>0&&u("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${C}px`}})]})}),u("div",{ref:x,className:"overflow-hidden bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700",children:g("div",{className:"flex flex-col",children:[B.map(e=>u("div",{className:"flex items-center justify-center border-b border-gray-200 dark:border-gray-700 font-bold text-[10px] text-gray-500 dark:text-gray-400",style:{height:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),k>0&&u("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${k}px`}})]})}),u("div",{ref:w,className:"overflow-auto",onScroll:Z,children:u("div",{className:"flex flex-col",style:{minWidth:"1352px"},children:B.map(t=>g("div",{className:"relative",style:{height:`${t.minHeight}px`},children:[u("div",{className:"grid absolute inset-0 z-0",style:{gridTemplateColumns:`repeat(${O}, minmax(0, 1fr))`},children:t.days.map((t,n)=>{const a=n%7,r=0===a||6===a;if(!t)return u("div",{className:"bg-gray-50/80 dark:bg-gray-800/40 border-r border-b border-gray-200 dark:border-gray-700 "+(r?"df-year-view-weekend-cell":"")},`empty-${n}`);const o=(e=>e.getTime()===b.getTime())(t),l=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return u("div",{"data-date":l,className:`\n relative flex items-start justify-end p-0.5 border-r border-b border-gray-200 dark:border-gray-700\n cursor-pointer hover:bg-blue-100 dark:hover:bg-primary/20 transition-colors\n ${r?"bg-blue-50 dark:bg-blue-900/30 df-year-view-weekend-cell":""}\n `,onClick:()=>e.selectDate(t),onDoubleClick:e=>F(e,t),children:u("span",{className:`\n text-[10px] font-medium w-5 h-5 flex items-center justify-center rounded-full\n ${o?"bg-primary text-primary-foreground font-bold shadow-sm":"text-gray-700 dark:text-gray-300"}\n `,children:t.getDate()})},t.getTime())})}),t.eventSegments.length>0&&u("div",{className:"absolute inset-0 pointer-events-none z-20",style:{top:20},children:u("div",{className:"relative w-full h-full",children:t.eventSegments.map(t=>u("div",{className:"pointer-events-auto",children:u(Fr,{segment:t,columnsPerRow:O,isDragging:$&&A.eventId===t.event.id,isSelected:T===t.event.id,onMoveStart:P,onResizeStart:L,onEventSelect:S,onDetailPanelToggle:I,newlyCreatedEventId:H,onDetailPanelOpen:()=>R(null),calendarRef:l,app:e,detailPanelEventId:M,customDetailPanelContent:i,customEventDetailDialog:s})},t.id))})})]},t.monthIndex))})})]})},Ur=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return u("fixed-week"===n?Zr:Wr,Object.assign({},e,{config:e.config}))},_r={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},qr=(t={})=>{const n=Object.assign(Object.assign({},_r),t);t.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:t.mode}));const a=t=>e.createElement(Ua,{viewType:Y.YEAR,originalComponent:Ur,app:t.app,config:n,className:"year-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,meta:t.meta});return a.displayName="YearViewAdapter",{type:Y.YEAR,component:a,config:n}},Xr={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function Gr(e={}){const t=Object.assign(Object.assign({},Xr),e);let n;const a={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=it(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const l=a.getById(e);if(!l)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},l),o);if(t.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=it(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=fe(t.start);n.setHours(0,0,0,0);const a=new Date(e);return a.setHours(0,0,0,0),n.getTime()===a.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const a=fe(n.start),r=fe(n.end);return a>=e&&a<=t||r>=e&&r<=t||a<=e&&r>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>it(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function r(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a}return{name:"events",config:t,install:e=>{n=e,Q.log("Events plugin installed - providing event management services")},api:a}}export{pt as CalendarApp,kr as CalendarEvent,X as CalendarRegistry,gn as ColorPicker,Za as DayFlowCalendar,In as DefaultEventDetailDialog,br as DefaultEventDetailPanel,Dr as EventDetailPanelWithContent,tr as EventLayoutCalculator,se as LOCALES,kt as LocaleContext,Ae as TIME_STEP,Ma as ThemeProvider,mr as ViewHeader,Y as ViewType,Ee as addDays,yn as buildParseRegExp,ot as calculateDayIndex,xt as capitalize,ia as conditionalTheme,pa as convertDateEvent,ba as convertDateEventWithTimeZone,fa as createAllDayEvent,Se as createDateWithHour,Ir as createDayView,dr as createDragPlugin,ga as createEvent,rt as createEventWithDate,ct as createEventWithRealDate,ma as createEvents,Gr as createEventsPlugin,zr as createMonthView,ye as createTemporalWithHour,ya as createTimedEvent,ha as createTimezoneEvent,va as createTimezoneEvents,Lr as createWeekView,qr as createYearView,Gn as dateToPlainDate,Kn as dateToPlainDateTime,Jn as dateToZonedDateTime,we as daysBetween,Ce as daysDifference,le as de,te as en,ie as es,Te as extractHourFromDate,ta as extractHourFromTemporal,Zn as formatDate,Wn as formatDateConsistent,ze as formatEventTimeRange,Bn as formatMonthYear,xn as formatTemporal,$e as formatTime,oe as fr,qe as generateDayData,mt as generateUniKey,Xe as generateWeekData,Je as generateWeekRange,Ke as generateWeeksData,et as getAllDayEventsForDay,_e as getCurrentWeekDates,tt as getDateByDayIndex,Da as getDateObj,st as getDayIndexByDate,Ie as getEndOfDay,xe as getEndOfTemporal,Oe as getEventBgColor,Fe as getEventEndHour,Pe as getEventTextColor,Qe as getEventsForDay,dt as getEventsForWeek,Dt as getIntlLabel,je as getLineColor,Ct as getMonthLabels,Ge as getMonthYearOfWeek,ra as getPlainDate,wa as getSearchHeaderInfo,Le as getSelectedBgColor,Me as getStartOfDay,De as getStartOfTemporal,ht as getTestEvents,wt as getWeekDaysLabels,Ue as getWeekRange,bn as getZoneId,Ca as groupSearchResults,ge as isDate,vt as isDeepEqual,gt as isEventEqual,lt as isEventInWeek,Re as isMultiDayEvent,be as isMultiDayTemporalEvent,Un as isPlainDate,_n as isPlainDateTime,He as isSameDay,pe as isSamePlainDate,aa as isSameTemporal,ce as isValidLocale,qn as isZonedDateTime,ae as ja,re as ko,sa as mergeClasses,vn as mergeFormatTemplate,Be as monthNames,ee as normalizeCssWidth,xa as normalizeDate,de as normalizeLocale,Dn as normalizeToZoned,ke as now,mn as pad,pn as parseTemporalString,Qn as plainDateTimeToDate,ea as plainDateToDate,it as recalculateEventDays,da as resolveAppliedTheme,Ye as roundToTimeStep,na as setHourInTemporal,Ze as shortMonthNames,Et as t,Xn as temporalToDate,la as themeClasses,oa as themeCn,Ne as today,nt as updateEventDateAndDay,ut as updateEventWithRealDate,bt as useCalendarApp,sr as useDrag,cr as useDragForView,Nt as useLocale,Fn as useResponsiveConfig,ka as useResponsiveMonthConfig,Ia as useTheme,Na as useVirtualMonthScroll,Vn as useVirtualScroll,Ve as weekDays,We as weekDaysFullName,ne as zh,ve as zonedDateTimeToDate};
1
+ import e,{useMemo as t,useState as n,useCallback as a,useEffect as r,useRef as o,useContext as l,createContext as i,useLayoutEffect as s}from"react";import{Temporal as d}from"temporal-polyfill";import{__awaiter as c}from"tslib";import{jsx as u,jsxs as g,Fragment as h}from"react/jsx-runtime";import m,{createPortal as v}from"react-dom";import{SketchPicker as f,PhotoshopPicker as y}from"react-color";import{PanelRightClose as p,PanelRightOpen as b,ChevronLeft as D,ChevronRight as x,ChevronsUpDown as w,Check as C,ChevronsLeft as E,ChevronsRight as k,MoveRight as N,ChevronDown as T,Plus as S,Search as M,Loader2 as I,ArrowLeft as H,X as R,CalendarDays as O,Calendar as P,Gift as L,Heart as j,Star as $,MapPin as A}from"lucide-react";import{createRoot as z}from"react-dom/client";var Y;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(Y||(Y={}));const F=100,V=8,W=150,B=80,Z=90,U=119;class _{constructor(e=F){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const q=[{id:"blue",name:"Blue",isDefault:!0,colors:{eventColor:"#eff6ff",eventSelectedColor:"rgba(59, 130, 246)",lineColor:"#3b82f6",textColor:"#1e3a8a"},darkColors:{eventColor:"rgba(30, 64, 175, 0.8)",eventSelectedColor:"rgba(30, 58, 138, 1)",lineColor:"#3b82f6",textColor:"#dbeafe"}},{id:"green",name:"Green",isDefault:!0,colors:{eventColor:"#f0fdf4",eventSelectedColor:"rgba(16, 185, 129, 1)",lineColor:"#10b981",textColor:"#064e3b"},darkColors:{eventColor:"rgba(4, 120, 87, 0.8)",eventSelectedColor:"rgba(6, 78, 59, 1)",lineColor:"#10b981",textColor:"#d1fae5"}},{id:"purple",name:"Purple",isDefault:!0,colors:{eventColor:"#faf5ff",eventSelectedColor:"rgba(139, 92, 246, 1)",lineColor:"#8b5cf6",textColor:"#5b21b6"},darkColors:{eventColor:"rgba(109, 40, 217, 0.8)",eventSelectedColor:"rgba(91, 33, 182, 1)",lineColor:"#8b5cf6",textColor:"#ede9fe"}},{id:"yellow",name:"Yellow",isDefault:!0,colors:{eventColor:"#fefce8",eventSelectedColor:"rgba(245, 158, 11, 1)",lineColor:"#f59e0b",textColor:"#78350f"},darkColors:{eventColor:"rgba(180, 83, 9, 0.8)",eventSelectedColor:"rgba(120, 53, 15, 1)",lineColor:"#f59e0b",textColor:"#fef3c7"}},{id:"red",name:"Red",isDefault:!0,colors:{eventColor:"#fef2f2",eventSelectedColor:"rgba(239, 68, 68, 1)",lineColor:"#ef4444",textColor:"#7f1d1d"},darkColors:{eventColor:"rgba(185, 28, 28, 0.8)",eventSelectedColor:"rgba(127, 29, 29, 1)",lineColor:"#ef4444",textColor:"#fee2e2"}},{id:"orange",name:"Orange",isDefault:!0,colors:{eventColor:"#fff7edb3",eventSelectedColor:"rgba(249, 115, 22, 1)",lineColor:"#f97316",textColor:"#7c2d12"},darkColors:{eventColor:"rgba(194, 65, 12, 0.8)",eventSelectedColor:"rgba(124, 45, 18, 1)",lineColor:"#f97316",textColor:"#fed7aa"}},{id:"pink",name:"Pink",isDefault:!0,colors:{eventColor:"#fdf2f8",eventSelectedColor:"rgba(236, 72, 153, 1)",lineColor:"#ec4899",textColor:"#831843"},darkColors:{eventColor:"rgba(190, 24, 93, 0.8)",eventSelectedColor:"rgba(131, 24, 67, 1)",lineColor:"#ec4899",textColor:"#fce7f3"}},{id:"teal",name:"Teal",isDefault:!0,colors:{eventColor:"#f0fdfa",eventSelectedColor:"rgba(20, 184, 166, 1)",lineColor:"#14b8a6",textColor:"#134e4a"},darkColors:{eventColor:"rgba(15, 118, 110, 0.8)",eventSelectedColor:"rgba(19, 78, 74, 1)",lineColor:"#14b8a6",textColor:"#ccfbf1"}},{id:"indigo",name:"Indigo",isDefault:!0,colors:{eventColor:"#eef2ffb3",eventSelectedColor:"rgba(99, 102, 241, 1)",lineColor:"#6366f1",textColor:"#312e81"},darkColors:{eventColor:"rgba(67, 56, 202, 0.8)",eventSelectedColor:"rgba(49, 46, 129, 1)",lineColor:"#6366f1",textColor:"#e0e7ff"}},{id:"gray",name:"Gray",isDefault:!0,colors:{eventColor:"#f9fafbb3",eventSelectedColor:"rgba(107, 114, 128, 1)",lineColor:"#6b7280",textColor:"#1f2937"},darkColors:{eventColor:"rgba(75, 85, 99, 0.8)",eventSelectedColor:"rgba(31, 41, 55, 1)",lineColor:"#6b7280",textColor:"#f3f4f6"}}];class X{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const a=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):q.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!a&&e.isVisible}))})}register(e){this.calendars.set(e.id,e)}unregister(e){return this.calendars.delete(e)}get(e){return this.calendars.get(e)}getAll(){return Array.from(this.calendars.values())}getVisible(){return this.getAll().filter(e=>!1!==e.isVisible)}has(e){return this.calendars.has(e)}reorder(e,t){const n=Array.from(this.calendars.entries());if(e<0||e>=n.length||t<0||t>=n.length)return;const[a]=n.splice(e,1);n.splice(t,0,a),this.calendars.clear(),n.forEach(([e,t])=>{this.calendars.set(e,t)})}setVisibility(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),{isVisible:t}))}setAllVisibility(e){this.calendars.forEach((t,n)=>{this.calendars.set(n,Object.assign(Object.assign({},t),{isVisible:e}))})}updateCalendar(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),t))}setDefaultCalendar(e){if(!this.has(e))throw new Error(`Calendar type '${e}' does not exist`);this.defaultCalendarId=e}getDefaultCalendarId(){return this.defaultCalendarId}getDefaultCalendar(){const e=this.get(this.defaultCalendarId);return e||this.getAll()[0]}setTheme(e){this.currentTheme=e}getTheme(){return this.currentTheme}resolveColors(e,t){const n=t||this.currentTheme,a=this.isDarkTheme(n);let r;return e&&(r=this.get(e)),r||(r=this.getDefaultCalendar()),a&&r.darkColors?r.darkColors:r.colors}getSelectedBgColor(e,t){return this.resolveColors(e,t).eventSelectedColor}getLineColor(e,t){return this.resolveColors(e,t).lineColor}getTextColor(e,t){return this.resolveColors(e,t).textColor}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let G=new X;function K(){return G}function J(e){const t=q.find(t=>t.colors.lineColor.toLowerCase()===e.toLowerCase());return t?{colors:t.colors,darkColors:t.darkColors}:{colors:{eventColor:e+"1A",eventSelectedColor:e,lineColor:e,textColor:e},darkColors:{eventColor:e+"CC",eventSelectedColor:e,lineColor:e,textColor:"#ffffff"}}}const Q=new class{constructor(){this.isDevelopment="production"!==process.env.NODE_ENV}formatMessage(e,t,...n){if(!this.isDevelopment)return;const a=(new Date).toISOString(),r=`[DayFlow ${e.toUpperCase()}] ${a}:`;switch(e){case"log":console.log(r,t,...n);break;case"warn":console.warn(r,t,...n);break;case"error":console.error(r,t,...n);break;case"debug":console.debug(r,t,...n)}}log(e,...t){this.formatMessage("log",e,...t)}warn(e,...t){this.formatMessage("warn",e,...t)}error(e,...t){this.formatMessage("error",e,...t)}debug(e,...t){this.formatMessage("debug",e,...t)}};function ee(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const te={code:"en-US",messages:{allDay:"All day",noEvents:"No events for this day",more:"more",eventTitle:"Event Title",dateRange:"Date Range",timeRange:"Time Range",note:"Note",addNotePlaceholder:"Add a note...",setAsAllDay:"Set as All-day",setAsTimed:"Set as Timed Event",delete:"Delete",confirm:"Confirm",cancel:"Cancel",today:"Today",day:"Day",week:"Week",month:"Month",year:"Year",newEvent:"New Event",newAllDayEvent:"New All-day Event",newCalendarEvent:"New {calendarName} Event",newAllDayCalendarEvent:"New {calendarName} All-day Event",save:"Save",deleteCalendar:'Delete "{calendarName}"?',deleteCalendarMessage:'Do you want to delete "{calendarName}" or merge its events into another existing calendar?',merge:"Merge",confirmDeleteTitle:'Are you sure you want to delete the calendar "{calendarName}"?',confirmDeleteMessage:"If you delete this calendar, all events associated with the calendar will also be deleted.",mergeConfirmTitle:'Merge "{sourceName}" with "{targetName}"?',mergeConfirmMessage:'Are you sure you want to merge "{sourceName}" with "{targetName}"? Doing so will move all the events from "{sourceName}" to "{targetName}" and "{sourceName}" will be deleted. This cannot be undone.',expandSidebar:"Expand calendar sidebar",collapseSidebar:"Collapse calendar sidebar",calendars:"Calendars",createCalendar:"Create New Calendar",calendarNamePlaceholder:"e.g. Work",customColor:"Custom Color...",create:"Create",calendarOptions:"Calendar Options",untitled:"Untitled",search:"Search",noResults:"No results found",calendar:"Calendar",starts:"Starts",ends:"Ends",notes:"Notes",titlePlaceholder:"Title",notesPlaceholder:"Notes",editEvent:"Edit Event",done:"Done",quickCreateEvent:"Quick Create Event",quickCreatePlaceholder:"Movie at 7pm on Friday",noSuggestions:"Type to create",newCalendar:"New Calendar",refreshAll:"Refresh All",tomorrow:"Tomorrow"}},ne={code:"zh-CN",messages:{allDay:"全天",noEvents:"今日无日程",more:"个",eventTitle:"事件标题",dateRange:"日期范围",timeRange:"时间范围",note:"备注",addNotePlaceholder:"添加备注...",setAsAllDay:"设为全天",setAsTimed:"设为普通事件",delete:"删除",confirm:"确认",cancel:"取消",today:"今天",day:"日",week:"周",month:"月",year:"年",newEvent:"新建日程",newAllDayEvent:"新建全天日程",newCalendarEvent:"新建 {calendarName} 日程",newAllDayCalendarEvent:"新建 {calendarName} 全天日程",save:"保存",deleteCalendar:'删除日历 "{calendarName}"?',deleteCalendarMessage:'您想删除日历 "{calendarName}" 还是将其事件合并到另一个现有日历中?',merge:"合并",confirmDeleteTitle:'您确定要删除日历 "{calendarName}" 吗?',confirmDeleteMessage:"如果您删除此日历,与其关联的所有事件也将被删除。",mergeConfirmTitle:'将 "{sourceName}" 合并到 "{targetName}"?',mergeConfirmMessage:'您确定要将 "{sourceName}" 合并到 "{targetName}" 吗?这样做会将 "{sourceName}" 中的所有事件移动到 "{targetName}",并且 "{sourceName}" 将被删除。此操作无法撤销。',expandSidebar:"展开日历侧边栏",collapseSidebar:"收起日历侧边栏",calendars:"日历",createCalendar:"创建新日历",calendarNamePlaceholder:"例如:工作",customColor:"自定义颜色...",create:"创建",calendarOptions:"日历选项",untitled:"未命名",search:"搜索",noResults:"无结果",calendar:"日历",starts:"开始",ends:"结束",notes:"备注",titlePlaceholder:"标题",notesPlaceholder:"备注",editEvent:"编辑日程",done:"完成",quickCreateEvent:"快速创建日程",quickCreatePlaceholder:"周五晚7点看电影",noSuggestions:"输入内容以创建",newCalendar:"新增日历",refreshAll:"全部刷新",tomorrow:"明天"}},ae={code:"ja-JP",messages:{allDay:"終日",noEvents:"本日は予定がありません",more:"件",eventTitle:"予定名",dateRange:"日付範囲",timeRange:"時間範囲",note:"メモ",addNotePlaceholder:"メモを追加...",setAsAllDay:"終日予定に設定",setAsTimed:"時間指定の予定に設定",delete:"削除",confirm:"確認",cancel:"キャンセル",today:"今日",day:"日",week:"週",month:"月",year:"年",newEvent:"新規予定",newAllDayEvent:"新規終日予定",newCalendarEvent:"新規 {calendarName} 予定",newAllDayCalendarEvent:"新規 {calendarName} 終日予定",save:"保存",deleteCalendar:'カレンダー "{calendarName}" を削除しますか?',deleteCalendarMessage:'カレンダー "{calendarName}" を削除しますか?それともイベントを別の既存のカレンダーにマージしますか?',merge:"マージ",confirmDeleteTitle:'カレンダー "{calendarName}" を削除してもよろしいですか?',confirmDeleteMessage:"このカレンダーを削除すると、関連するすべてのイベントも削除されます。",mergeConfirmTitle:'"{sourceName}" を "{targetName}" にマージしますか?',mergeConfirmMessage:'"{sourceName}" を "{targetName}" にマージしてもよろしいですか?これにより、"{sourceName}" のすべてのイベントが "{targetName}" に移動し、"{sourceName}" は削除されます。この操作は元に戻せません。',expandSidebar:"カレンダーサイドバーを展開",collapseSidebar:"カレンダーサイドバーを折りたたむ",calendars:"カレンダー",createCalendar:"新しいカレンダーを作成",calendarNamePlaceholder:"例:仕事",customColor:"カスタムカラー...",create:"作成",calendarOptions:"カレンダーオプション",untitled:"無題",search:"検索",noResults:"結果が見つかりません",calendar:"カレンダー",starts:"開始",ends:"終了",notes:"メモ",titlePlaceholder:"予定名",notesPlaceholder:"メモ",editEvent:"予定を編集",done:"完了",quickCreateEvent:"クイック作成",quickCreatePlaceholder:"金曜日7時から映画",noSuggestions:"入力して作成",newCalendar:"新しいカレンダー",refreshAll:"すべて更新",tomorrow:"明日"}},re={code:"ko-KR",messages:{allDay:"종일",noEvents:"오늘 일정이 없습니다",more:"개",eventTitle:"일정 제목",dateRange:"날짜 범위",timeRange:"시간 범위",note:"메모",addNotePlaceholder:"메모 추가...",setAsAllDay:"종일 일정으로 설정",setAsTimed:"시간 지정 일정으로 설정",delete:"삭제",confirm:"확인",cancel:"취소",today:"오늘",day:"일",week:"주",month:"월",year:"년",newEvent:"새 일정",newAllDayEvent:"새 종일 일정",newCalendarEvent:"{calendarName}의 새 일정",newAllDayCalendarEvent:"{calendarName}의 새 종일 일정",save:"저장",deleteCalendar:'"{calendarName}" 삭제?',deleteCalendarMessage:'"{calendarName}"을(를) 삭제하시겠습니까, 아니면 이벤트를 다른 기존 캘린더로 병합하시겠습니까?',merge:"병합",confirmDeleteTitle:'"{calendarName}" 캘린더를 삭제하시겠습니까?',confirmDeleteMessage:"이 캘린더를 삭제하면 연결된 모든 이벤트도 삭제됩니다.",mergeConfirmTitle:'"{sourceName}"을(를) "{targetName}"(으)로 병합?',mergeConfirmMessage:'"{sourceName}"을(를) "{targetName}"(으)로 병합하시겠습니까? 이렇게 하면 "{sourceName}"의 모든 이벤트가 "{targetName}"(으)로 이동하고 "{sourceName}"은(는) 삭제됩니다. 이 작업은 취소할 수 없습니다.',expandSidebar:"캘린더 사이드바 펼치기",collapseSidebar:"캘린더 사이드바 접기",calendars:"캘린더",createCalendar:"새 캘린더 만들기",calendarNamePlaceholder:"예: 업무",customColor:"사용자 지정 색상...",create:"만들기",calendarOptions:"캘린더 옵션",untitled:"무제",search:"검색",noResults:"결과 없음",calendar:"캘린더",starts:"시작",ends:"종료",notes:"메모",titlePlaceholder:"제목",notesPlaceholder:"메모",editEvent:"일정 편집",done:"완료",quickCreateEvent:"빠른 일정 생성",quickCreatePlaceholder:"금요일 오후 7시에 영화",noSuggestions:"입력하여 만들기",newCalendar:"새 캘린더",refreshAll:"모두 새로 고침",tomorrow:"내일"}},oe={code:"fr-FR",messages:{allDay:"Toute la journée",noEvents:"Aucun événement aujourd'hui",more:"de plus",eventTitle:"Titre de l'événement",dateRange:"Plage de dates",timeRange:"Plage horaire",note:"Note",addNotePlaceholder:"Ajouter une note...",setAsAllDay:"Définir comme toute la journée",setAsTimed:"Définir comme événement horaire",delete:"Supprimer",confirm:"Confirmer",cancel:"Annuler",today:"Aujourd'hui",day:"Jour",week:"Semaine",month:"Mois",year:"Année",newEvent:"Nouvel événement",newAllDayEvent:"Nouvel événement toute la journée",newCalendarEvent:"Nouvel événement dans {calendarName}",newAllDayCalendarEvent:"Nouvel événement toute la journée dans {calendarName}",save:"Enregistrer",deleteCalendar:'Supprimer "{calendarName}" ?',deleteCalendarMessage:'Voulez-vous supprimer "{calendarName}" ou fusionner ses événements dans un autre calendrier existant ?',merge:"Fusionner",confirmDeleteTitle:'Êtes-vous sûr de vouloir supprimer le calendrier "{calendarName}" ?',confirmDeleteMessage:"Si vous supprimez ce calendrier, tous les événements associés seront également supprimés.",mergeConfirmTitle:'Fusionner "{sourceName}" avec "{targetName}" ?',mergeConfirmMessage:'Êtes-vous sûr de vouloir fusionner "{sourceName}" avec "{targetName}" ? Cela déplacera tous les événements de "{sourceName}" vers "{targetName}" et "{sourceName}" sera supprimé. Cette action est irréversible.',expandSidebar:"Développer la barre latérale",collapseSidebar:"Réduire la barre latérale",calendars:"Calendriers",createCalendar:"Créer un nouveau calendrier",calendarNamePlaceholder:"ex. Travail",customColor:"Couleur personnalisée...",create:"Créer",calendarOptions:"Options du calendrier",untitled:"Sans titre",search:"Rechercher",noResults:"Aucun résultat trouvé",calendar:"Calendrier",starts:"Début",ends:"Fin",notes:"Notes",titlePlaceholder:"Titre",notesPlaceholder:"Notes",editEvent:"Modifier l'événement",done:"Terminé",quickCreateEvent:"Création rapide",quickCreatePlaceholder:"Film à 19h vendredi",noSuggestions:"Tapez pour créer",newCalendar:"Nouveau calendrier",refreshAll:"Tout actualiser",tomorrow:"Demain"}},le={code:"de-DE",messages:{allDay:"Ganztägig",noEvents:"Heute keine Termine",more:"mehr",eventTitle:"Ereignistitel",dateRange:"Datumsbereich",timeRange:"Zeitbereich",note:"Notiz",addNotePlaceholder:"Notiz hinzufügen...",setAsAllDay:"Als ganztägig festlegen",setAsTimed:"Als zeitlich begrenztes Ereignis festlegen",delete:"Löschen",confirm:"Bestätigen",cancel:"Abbrechen",today:"Heute",day:"Tag",week:"Woche",month:"Monat",year:"Jahr",newEvent:"Neues Ereignis",newAllDayEvent:"Neues ganztägiges Ereignis",newCalendarEvent:"Neues Ereignis in {calendarName}",newAllDayCalendarEvent:"Neues ganztägiges Ereignis in {calendarName}",save:"Speichern",deleteCalendar:'"{calendarName}" löschen?',deleteCalendarMessage:'Möchten Sie "{calendarName}" löschen oder dessen Ereignisse in einen anderen bestehenden Kalender zusammenführen?',merge:"Zusammenführen",confirmDeleteTitle:'Sind Sie sicher, dass Sie den Kalender "{calendarName}" löschen möchten?',confirmDeleteMessage:"Wenn Sie diesen Kalender löschen, werden auch alle damit verbundenen Ereignisse gelöscht.",mergeConfirmTitle:'"{sourceName}" mit "{targetName}" zusammenführen?',mergeConfirmMessage:'Sind Sie sicher, dass Sie "{sourceName}" mit "{targetName}" zusammenführen möchten? Dadurch werden alle Ereignisse von "{sourceName}" nach "{targetName}" verschoben und "{sourceName}" wird gelöscht. Dies kann nicht rückgängig gemacht werden.',expandSidebar:"Kalender-Seitenleiste erweitern",collapseSidebar:"Kalender-Seitenleiste einklappen",calendars:"Kalender",createCalendar:"Neuen Kalender erstellen",calendarNamePlaceholder:"z.B. Arbeit",customColor:"Benutzerdefinierte Farbe...",create:"Erstellen",calendarOptions:"Kalenderoptionen",untitled:"Unbenannt",search:"Suchen",noResults:"Keine Ergebnisse gefunden",calendar:"Kalender",starts:"Beginnt",ends:"Endet",notes:"Notizen",titlePlaceholder:"Titel",notesPlaceholder:"Notizen",editEvent:"Ereignis bearbeiten",done:"Fertig",quickCreateEvent:"Ereignis schnell erstellen",quickCreatePlaceholder:"Film am Freitag um 19 Uhr",noSuggestions:"Tippen zum Erstellen",newCalendar:"Neuer Kalender",refreshAll:"Alles aktualisieren",tomorrow:"Morgen"}},ie={code:"es-ES",messages:{allDay:"Todo el día",noEvents:"No hay eventos hoy",more:"más",eventTitle:"Título del evento",dateRange:"Rango de fechas",timeRange:"Rango de tiempo",note:"Nota",addNotePlaceholder:"Añadir una nota...",setAsAllDay:"Establecer como todo el día",setAsTimed:"Establecer como evento con horario",delete:"Eliminar",confirm:"Confirmar",cancel:"Cancelar",today:"Hoy",day:"Día",week:"Semana",month:"Mes",year:"Año",newEvent:"Nuevo evento",newAllDayEvent:"Nuevo evento de todo el día",newCalendarEvent:"Nuevo evento en {calendarName}",newAllDayCalendarEvent:"Nuevo evento de todo el día en {calendarName}",save:"Guardar",deleteCalendar:'¿Eliminar "{calendarName}"?',deleteCalendarMessage:'¿Quieres eliminar "{calendarName}" o fusionar sus eventos en otro calendario existente?',merge:"Fusionar",confirmDeleteTitle:'¿Seguro que quieres eliminar el calendario "{calendarName}"?',confirmDeleteMessage:"Si eliminas este calendario, también se eliminarán todos los eventos asociados.",mergeConfirmTitle:'¿Fusionar "{sourceName}" con "{targetName}"?',mergeConfirmMessage:'¿Seguro que quieres fusionar "{sourceName}" con "{targetName}"? Esto moverá todos los eventos de "{sourceName}" a "{targetName}" y se eliminará "{sourceName}". Esta acción no se puede deshacer.',expandSidebar:"Expandir barra lateral del calendario",collapseSidebar:"Contraer barra lateral del calendario",calendars:"Calendarios",createCalendar:"Crear nuevo calendario",calendarNamePlaceholder:"ej. Trabajo",customColor:"Color personalizado...",create:"Crear",calendarOptions:"Opciones de calendario",untitled:"Sin título",search:"Buscar",noResults:"No se encontraron resultados",calendar:"Calendario",starts:"Empieza",ends:"Termina",notes:"Notas",titlePlaceholder:"Título",notesPlaceholder:"Notas",editEvent:"Editar evento",done:"Hecho",quickCreateEvent:"Creación rápida de eventos",quickCreatePlaceholder:"Película a las 7pm el viernes",noSuggestions:"Escribe para crear",newCalendar:"Nuevo calendario",refreshAll:"Actualizar todo",tomorrow:"Mañana"}},se={en:te,zh:ne,ja:ae,ko:re,fr:oe,de:le,es:ie};function de(e){const t=e.split("-")[0].toLowerCase();return t in se?t:"en"}function ce(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function ue(e){var t;return e instanceof d.PlainDate||("PlainDate"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)||!("hour"in e)&&!("timeZone"in e))}function ge(e){return e instanceof Date}function he(e,t=d.Now.timeZoneId()){return d.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function me(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function ve(e){return new Date(e.epochMilliseconds)}function fe(e,t){return ue(e)?function(e,t=d.Now.timeZoneId()){return ve(e.toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:0,minute:0})}))}(e,t):"hour"in e&&!("timeZone"in e)?new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond):ve(e)}function ye(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return ue(e)?d.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:n,minute:a}):e.with({hour:n,minute:a,second:0,millisecond:0})}function pe(e,t){const n=ue(e)?e:e.toPlainDate(),a=ue(t)?t:t.toPlainDate();return 0===d.PlainDate.compare(n,a)}function be(e,t){return!pe(e,t)}function De(e,t=d.Now.timeZoneId()){return(ue(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:0,minute:0})})}function xe(e,t=d.Now.timeZoneId()){return(ue(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function we(e,t){const n=ue(e)?e:e.toPlainDate(),a=ue(t)?t:t.toPlainDate();return n.until(a).days}function Ce(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((a.getTime()-n.getTime())/864e5)}function Ee(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ke(e=d.Now.timeZoneId()){return d.Now.zonedDateTimeISO(e)}function Ne(e=d.Now.timeZoneId()){return d.Now.plainDateISO(e)}const Te=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return ue(t=e)?0:"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:(console.warn("Warning: No hour property found in temporal object, returning 0"),0);var t,n},Se=(e,t)=>{if(e instanceof Date){const n=new Date(e),a=Math.floor(t),r=Math.round(60*(t-a));return n.setHours(a,r,0,0),n}return ye(e,t)},Me=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return De(e)},Ie=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return xe(e)},He=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return pe(e instanceof Date?d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):ue(e)?e:e.toPlainDate(),t instanceof Date?d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):ue(t)?t:t.toPlainDate())},Re=(e,t)=>!He(e,t),Oe=(e,t)=>(t||K()).resolveColors(e).eventColor,Pe=(e,t)=>(t||K()).resolveColors(e).textColor,Le=(e,t)=>(t||K()).resolveColors(e).eventSelectedColor,je=(e,t)=>(t||K()).resolveColors(e).lineColor,$e=.25,Ae=(e,t=0)=>{const n=Math.floor(e),a=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`},ze=e=>{const t=Te(e.start),n=Fe(e);return`${Ae(t)} - ${Ae(n)}`},Ye=e=>{const t=$e;return Math.round(e/t)*t},Fe=e=>{if(!e.end)return 0;const t=Te(e.end);if(e.allDay||!e.start)return t;const n=fe(e.start),a=fe(e.end);if(!(n.getFullYear()!==a.getFullYear()||n.getMonth()!==a.getMonth()||n.getDate()!==a.getDate()))return t;if(0===t&&0===a.getMinutes()&&0===a.getSeconds()&&0===a.getMilliseconds()){const e=a.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},Ve=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],We=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Be=["January","February","March","April","May","June","July","August","September","October","November","December"],Ze=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ue=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);a.setDate(n),a.setHours(0,0,0,0);const r=new Date(a);return r.setDate(a.getDate()+6),r.setHours(23,59,59,999),{monday:a,sunday:r}},_e=()=>{const e=new Date,t=new Date,n=e.getDay(),a=e.getDate()-n+(0===n?-6:1);return Ve.map((n,r)=>{const o=new Date(e);return o.setDate(a+r),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},qe=e=>{const t=new Date(e),n=t.getDate(),a=t.getMonth(),r=t.getFullYear(),o=new Date;return{date:t,day:n,month:a,year:r,monthName:Be[a],shortMonthName:Ze[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},Xe=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(qe(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Ge(t)}},Ge=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,a="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,a=e)});const[r,o]=a.split("-").map(Number);return{month:Be[r],monthIndex:r,year:o}},Ke=(e,t=3)=>{const n=5*t,{monday:a}=Ue(e),r=[],o=Math.floor(n/2),l=new Date(a);l.setDate(l.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(Xe(t))}return r};function Je(e,t){const n=[],a=Math.floor(t/2),r=new Date(e),o=e.getDay(),l=0===o?6:o-1;r.setDate(e.getDate()-l),r.setHours(0,0,0,0);const i=new Date(r);i.setDate(i.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),n.push(Xe(t))}return n}const Qe=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),et=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const a=new Date(n);a.setDate(n.getDate()+e),a.setHours(0,0,0,0);const r=fe(t.start);r.setHours(0,0,0,0);const o=fe(t.end);return o.setHours(0,0,0,0),a>=r&&a<=o}),tt=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},nt=(e,t,n)=>{const a=tt(n,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?d.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):d.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:d.Now.timeZoneId()}),end:e.allDay?d.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):d.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:d.Now.timeZoneId()})})},at=(e,t)=>t?d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):d.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:d.Now.timeZoneId()}),rt=(e,t)=>{var n,a;const r=tt(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:at(r,o),end:at(r,o)})},ot=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=n.getTime()-a.getTime();return Math.floor(r/864e5)},lt=(e,t)=>{const n=ot(e,t);return n>=0&&n<=6},it=(e,t)=>e.map(e=>{const n=fe(e.start),a=ot(n,t);return Object.assign(Object.assign({},e),{day:a})}),st=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=a.getTime()-n.getTime();return Math.floor(r/864e5)},dt=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=fe(e.start);return a>=t&&a<=n}).map(e=>{const n=ot(fe(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},ct=(e,t)=>{var n,a;const r=new Date(t);r.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:at(r,o),end:at(r,o)})},ut=(e,t,n)=>{var a;const r=new Date(n);r.setDate(n.getDate()+t);const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{day:t,start:at(r,o),end:at(r,o)})},gt=(e,t)=>e===t||!(!e||!t)&&(e.title===t.title&&e.calendarId===t.calendarId&&(e.description||"")===(t.description||"")&&!!e.allDay==!!t.allDay&&e.start.toString()===t.start.toString()&&e.end.toString()===t.end.toString());function ht(){const e=new Date,t=e.getDay(),n=new Date(e),a=0===t?-6:1-t;n.setDate(e.getDate()+a),n.setHours(0,0,0,0);return[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(e=>{const t=new Date(n);if(t.setDate(n.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),r=Math.round(60*(e.startHour-a)),o=Math.floor(e.endHour),l=Math.round(60*(e.endHour-o));return{id:e.id,title:e.title,start:d.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:a,minute:r,timeZone:d.Now.timeZoneId()}),end:d.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:o,minute:l,timeZone:d.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})}function mt(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function vt(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(const r of n)if(!a.includes(r)||!vt(e[r],t[r]))return!1;return!0}const ft="240px",yt=e=>{if(!e)return{enabled:!1,width:ft,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:ft,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i}=e;return{enabled:t,width:ee(n,ft),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i}};class pt{constructor(t){var n,a,r,o,l;this.getReadOnlyConfig=()=>{var e,t;const n=this.state.readOnly;return!0===n?{draggable:!1,viewable:!1}:!1===n?{draggable:!0,viewable:!0}:{draggable:null!==(e=n.draggable)&&void 0!==e&&e,viewable:null!==(t=n.viewable)&&void 0!==t&&t}},this.isInternalEditable=()=>!0!==this.state.readOnly&&"object"!=typeof this.state.readOnly,this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,this.state.highlightedEventId=null,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e)},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate)},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const a=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===a.getFullYear()&&this.visibleMonth.getMonth()===a.getMonth()||(this.visibleMonth=a,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)))},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case Y.DAY:e.setDate(e.getDate()-1);break;case Y.WEEK:e.setDate(e.getDate()-7);break;case Y.MONTH:e.setMonth(e.getMonth()-1);break;case Y.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case Y.DAY:e.setDate(e.getDate()+1);break;case Y.WEEK:e.setDate(e.getDate()+7);break;case Y.MONTH:e.setMonth(e.getMonth()+1);break;case Y.YEAR:e.setFullYear(e.getFullYear()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.addEvent=e=>{var t,n;this.isInternalEditable()?(this.state.events=[...this.state.events,e],null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e)):Q.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void Q.warn("Cannot update event in read-only mode");if(!this.isInternalEditable())return;const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[a]),t);this.state.events=[...this.state.events.slice(0,a),r,...this.state.events.slice(a+1)]},this.deleteEvent=e=>{var t,n;if(!this.isInternalEditable())return void Q.warn("Cannot delete event in read-only mode");const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);this.state.events=[...this.state.events.slice(0,a),...this.state.events.slice(a+1)],null===(n=(t=this.callbacks).onEventDelete)||void 0===n||n.call(t,e)},this.getAllEvents=()=>[...this.state.events],this.onEventClick=e=>{var t,n;null===(n=(t=this.callbacks).onEventClick)||void 0===n||n.call(t,e)},this.onMoreEventsClick=e=>{var t,n;null===(n=(t=this.callbacks).onMoreEventsClick)||void 0===n||n.call(t,e)},this.highlightEvent=e=>{var t,n;this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{var n,a;this.calendarRegistry.reorder(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n)},this.setCalendarVisibility=(e,t)=>{var n,a;this.calendarRegistry.setVisibility(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n)},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.updateCalendar=(e,t)=>{var n,a,r,o;this.calendarRegistry.updateCalendar(e,t);const l=this.calendarRegistry.get(e);l&&(null===(a=(n=this.callbacks).onCalendarUpdate)||void 0===a||a.call(n,l)),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r)},this.createCalendar=e=>{var t,n,a,r;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a)},this.deleteCalendar=e=>{var t,n,a,r;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a)},this.mergeCalendars=(e,t)=>{var n,a,r,o;this.state.events.filter(t=>t.calendarId===e).forEach(e=>{this.updateEvent(e.id,{calendarId:t})}),this.deleteCalendar(e),null===(a=(n=this.callbacks).onCalendarMerge)||void 0===a||a.call(n,e,t),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r)},this.getSidebarConfig=()=>this.sidebarConfig,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?Q.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.render=()=>e.createElement("div",{className:"calendar-app"},"Calendar App"),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t))},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e)},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.updateConfig=e=>{var t;let n=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,n=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,n=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,n=!0),void 0===e.readOnly||vt(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,n=!0),e.callbacks&&(this.callbacks=Object.assign(Object.assign({},this.callbacks),e.callbacks)),void 0!==(null===(t=e.theme)||void 0===t?void 0:t.mode)&&e.theme.mode!==this.getTheme()&&this.setTheme(e.theme.mode),void 0!==e.useSidebar){const t=yt(e.useSidebar);vt(t,this.sidebarConfig)||(this.sidebarConfig=t,this.state.sidebar=this.sidebarConfig,n=!0)}if(void 0!==e.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=this.resolveLocale(e.locale);vt(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&this.triggerRender()},this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:t.defaultView||Y.WEEK,currentDate:t.initialDate||new Date,events:t.events||[],switcherMode:t.switcherMode||"buttons",plugins:new Map,views:new Map,locale:this.resolveLocale(t.locale),highlightedEventId:null,readOnly:t.readOnly||!1},this.callbacks=t.callbacks||{},this.themeChangeListeners=new Set,this.calendarRegistry=new X(t.calendars,t.defaultCalendar,(null===(n=t.theme)||void 0===n?void 0:n.mode)||"light"),l=this.calendarRegistry,G=l,this.sidebarConfig=yt(t.useSidebar),this.state.sidebar=this.sidebarConfig;const i=this.state.currentDate;this.visibleMonth=new Date(i.getFullYear(),i.getMonth(),1),this.useEventDetailDialog=null!==(a=t.useEventDetailDialog)&&void 0!==a&&a,this.useCalendarHeader=null===(r=t.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=t.customMobileEventRenderer,t.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(o=t.plugins)||void 0===o||o.forEach(e=>{this.installPlugin(e)})}resolveLocale(e){return e?"string"==typeof e?ce(e)?e:"en-US":e&&"object"==typeof e&&!ce(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}function bt(e){const l=t(()=>new pt(e),[]),[i,s]=n(l.state.currentView),[d,c]=n(l.state.currentDate),[u,g]=n(l.getEvents()),[h,m]=n(l.getSidebarConfig()),[,v]=n({}),f=a(()=>{v({})},[]);r(()=>{const e=l.changeView;l.changeView=t=>{e(t),s(t),f()};const t=l.setCurrentDate;l.setCurrentDate=e=>{t(e),c(new Date(e)),f()};const n=l.addEvent;l.addEvent=e=>{n(e),g([...l.getEvents()]),f()};const a=l.updateEvent;l.updateEvent=(e,t,n)=>{a(e,t,n),g([...l.getEvents()]),f()};const r=l.deleteEvent;l.deleteEvent=e=>{r(e),g([...l.getEvents()]),f()};const o=l.setCalendarVisibility;l.setCalendarVisibility=(e,t)=>{o(e,t),g([...l.getEvents()]),f()};const i=l.setAllCalendarsVisibility;l.setAllCalendarsVisibility=e=>{i(e),g([...l.getEvents()]),f()};const d=l.setVisibleMonth;l.setVisibleMonth=e=>{d(e),f()};const u=l.reorderCalendars;l.reorderCalendars=(e,t)=>{u(e,t),f()};const h=l.updateCalendar;l.updateCalendar=(e,t)=>{h(e,t),f()};const v=l.createCalendar;l.createCalendar=e=>{v(e),f()};const y=l.deleteCalendar;l.deleteCalendar=e=>{y(e),f()};const p=l.mergeCalendars;l.mergeCalendars=(e,t)=>{p(e,t),g([...l.getEvents()]),f()};const b=l.highlightEvent;l.highlightEvent=e=>{b(e),f()};const D=l.triggerRender;return l.triggerRender=()=>{D(),m(l.getSidebarConfig()),f()},()=>{}},[l,f]),r(()=>{s(l.state.currentView),c(l.state.currentDate),g(l.getEvents())},[l]);const y=o(e);r(()=>{vt(y.current,e)||(l.updateConfig(e),y.current=e)},[l,e]);const p=a(e=>{l.changeView(e)},[l]),b=a(e=>{l.setCurrentDate(e)},[l]),D=a(e=>{l.addEvent(e)},[l]),x=a((e,t,n)=>{l.updateEvent(e,t,n)},[l]),w=a(e=>{l.deleteEvent(e)},[l]),C=a(()=>{l.goToToday()},[l]),E=a(()=>{l.goToPrevious()},[l]),k=a(()=>{l.goToNext()},[l]),N=a(e=>{l.selectDate(e)},[l]),T=a((e,t)=>{l.setCalendarVisibility(e,t)},[l]),S=a(e=>{l.setAllCalendarsVisibility(e)},[l]);return{app:l,currentView:i,currentDate:d,events:u,changeView:p,setCurrentDate:b,addEvent:D,updateEvent:x,deleteEvent:w,goToToday:C,goToPrevious:E,goToNext:k,selectDate:N,getCalendars:()=>l.getCalendars(),createCalendar:e=>l.createCalendar(e),mergeCalendars:(e,t)=>l.mergeCalendars(e,t),setCalendarVisibility:T,setAllCalendarsVisibility:S,getAllEvents:()=>l.getAllEvents(),highlightEvent:e=>l.highlightEvent(e),setVisibleMonth:e=>l.setVisibleMonth(e),getVisibleMonth:()=>l.getVisibleMonth(),sidebarConfig:h,readOnlyConfig:l.getReadOnlyConfig()}}function Dt(e,t){var n,a,r,o,l;try{if("today"===e){return null!==(a=null===(n=new Intl.RelativeTimeFormat(t,{numeric:"auto"}).formatToParts(0,"day").find(e=>"literal"===e.type))||void 0===n?void 0:n.value)&&void 0!==a?a:null}if("week"===e){return null!==(o=null===(r=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===r?void 0:r.value)&&void 0!==o?o:null}return null!==(l=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==l?l:null}catch(e){return null}}function xt(e){return e.charAt(0).toUpperCase()+e.slice(1)}const wt=(e,t="short")=>{const n=[],a=new Date(2024,0,1);for(let r=0;r<7;r++){const o=new Date(a);o.setDate(a.getDate()+r);try{n.push(o.toLocaleDateString(e,{weekday:t}))}catch(e){n.push(o.toLocaleDateString("en-US",{weekday:t}))}}return n},Ct=(e,t="long")=>{const n=[];for(let a=0;a<12;a++){const r=new Date(2024,a,1);try{n.push(r.toLocaleDateString(e,{month:t}))}catch(e){n.push(r.toLocaleDateString("en-US",{month:t}))}}return n};function Et(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Dt(e,t);if(n)return xt(n)}const a=de(t),r=se[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const l=se.en.messages;return(null==l?void 0:l[e])||e}const kt=e.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Nt(){return l(kt)}const Tt=({x:e,y:t,onClose:n,children:a,className:l})=>{const i=o(null);r(()=>{const e=e=>{i.current&&!i.current.contains(e.target)&&n()};document.addEventListener("mousedown",e);const t=()=>n();return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[n]);return v(u("div",{ref:i,className:`fixed z-50 min-w-32 overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out ${l||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),children:a}),document.body)},St=({onClick:e,children:t,icon:n,danger:a})=>g("div",{className:"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-disabled:pointer-events-none data-disabled:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50 hover:bg-slate-100 dark:hover:bg-slate-800 "+(a?"text-destructive focus:text-destructive-foreground focus:bg-destructive hover:bg-destructive hover:text-destructive-foreground":"text-slate-900 dark:text-slate-50"),onClick:t=>{t.stopPropagation(),e()},children:[n&&u("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Mt=()=>u("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),It=({children:e})=>u("div",{className:"px-2 py-1.5 text-sm font-semibold text-slate-950 dark:text-slate-50",children:e}),Ht=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Rt=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Nt();return g("div",{className:"p-2",children:[u("div",{className:"grid grid-cols-7 gap-2 p-1",children:Ht.map(n=>u("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 dark:border-gray-600 hover:scale-110 transition-transform focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-primary dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-offset-1 ring-primary dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&u("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800",onClick:e=>{e.stopPropagation(),n()},children:a("customColor")})]})},Ot=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Nt();return g("div",{className:"flex items-center px-2 py-2",children:[u("button",{type:"button","aria-label":n(e?"expandSidebar":"collapseSidebar"),className:"flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",onClick:t,children:u(e?p:b,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),!e&&u("div",{className:"flex flex-1 justify-between items-center",children:u("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:n("calendars")})})]})},Pt=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Lt=({calendars:e,onToggleVisibility:t,onReorder:l,onRename:i,onContextMenu:s,editingId:d,setEditingId:c,activeContextMenuCalendarId:h,isDraggable:m=!0,isEditable:v=!0})=>{const[f,y]=n(""),p=o(null),[b,D]=n(!1),[x,w]=n(null),[C,E]=n(null),k=a((e,t)=>{if(d||!m)return void t.preventDefault();D(!0),w(e.id);const n={calendarId:e.id,calendarName:e.name,calendarColors:e.colors,calendarIcon:e.icon};t.dataTransfer.setData("application/x-dayflow-calendar",JSON.stringify(n)),t.dataTransfer.effectAllowed="copy"},[d]),N=a(()=>{D(!1),w(null),E(null)},[]),T=a((t,n)=>{if(t.preventDefault(),x===n)return void E(null);const a=e.findIndex(e=>e.id===n)===e.length-1,r=t.currentTarget.getBoundingClientRect(),o=t.clientY<r.top+r.height/2;E(a?{id:n,position:o?"top":"bottom"}:{id:n,position:"top"})},[x,e]),S=a(()=>{E(null)},[]),M=a(t=>{if(!x||!C)return;if(x===t.id)return;const n=e.findIndex(e=>e.id===x);let a=e.findIndex(e=>e.id===t.id);"bottom"===C.position&&(a+=1),a>n&&(a-=1),-1!==n&&-1!==a&&l(n,a),E(null)},[x,C,e,l]),I=a(e=>{v&&(c(e.id),y(e.name))},[c,v]),H=a(e=>{y(e.target.value)},[]),R=a(()=>{if(d&&f.trim()){const t=e.find(e=>e.id===d);t&&t.name!==f.trim()&&i(d,f.trim())}c(null),y("")},[d,f,e,i,c]),O=a(()=>{c(null),y("")},[c]),P=a(e=>{"Enter"===e.key?R():"Escape"===e.key&&O()},[R,O]);return r(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]),r(()=>{if(d){const t=e.find(e=>e.id===d);t&&y(t.name)}},[d,e]),u("div",{className:"df-calendar-list flex-1 overflow-y-auto px-2 pb-3",children:u("ul",{className:"space-y-1 relative",children:e.map(e=>{var n;const a=!1!==e.isVisible,r=(null===(n=e.colors)||void 0===n?void 0:n.lineColor)||"#3b82f6",o=Boolean(e.icon),l=(null==C?void 0:C.id)===e.id,i=h===e.id||d===e.id;return g("li",{className:"df-calendar-list-item relative",onDragOver:t=>T(t,e.id),onDragLeave:S,onDrop:()=>M(e),onContextMenu:t=>s(t,e.id),children:[l&&"top"===C.position&&u("div",{className:"absolute top-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"}),u("div",{draggable:m&&!d,onDragStart:t=>k(e,t),onDragEnd:N,className:`rounded transition ${x===e.id?"opacity-50":""} ${m?"cursor-grab":"cursor-default"}`,children:g("div",{className:"group flex items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800 "+(i?"bg-gray-100 dark:bg-slate-800":""),title:e.name,children:[u("input",{type:"checkbox",className:"calendar-checkbox cursor-pointer shrink-0",style:{"--checkbox-color":r},checked:a,onChange:n=>t(e.id,n.target.checked)}),o&&u("span",{className:"ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white","aria-hidden":"true",children:Pt(e)}),d===e.id?u("input",{ref:p,type:"text",value:f,onChange:H,onBlur:R,onKeyDown:P,className:"ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100",onClick:e=>e.stopPropagation()}):u("span",{className:"flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2",onDoubleClick:()=>I(e),children:e.name||e.id})]})}),l&&"bottom"===C.position&&u("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"})]},e.id)})})})},jt="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",$t="df-header p-2 flex justify-between",At="text-2xl font-bold text-gray-900 dark:text-gray-100",zt="rounded-md bg-background border border-border px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",Yt="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Ft="flex-1 overflow-auto will-change-scroll",Vt="df-time-slot relative h-[4.5rem] flex",Wt="df-time-label absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Bt="df-time-grid-row h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",Zt="df-current-time-line absolute left-0 top-0 flex pointer-events-none",Ut="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",_t="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",qt="rounded-xl my-0.5",Xt="df-event-title font-medium text-xs truncate pr-1",Gt="df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",Kt="h-3 w-3 mr-1",Jt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Qt="bg-primary rounded-full text-primary-foreground",en="df-nav-button calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",tn="h-4 w-4 transition-transform group-hover:scale-110",nn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",an="h-3 border-t border-gray-200 dark:border-gray-700 relative",rn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",on="text-gray-500 dark:text-gray-400",ln="text-gray-600 dark:text-gray-300",sn="text-xs",dn="text-sm",cn="flex flex-col",un="mr-1",gn=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:r,onDateSelect:o})=>{const{locale:l}=Nt(),i=t(()=>(new Date).toDateString(),[]),s=n.toDateString(),d=t(()=>wt(l,"narrow"),[l]),c=t(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),h=t(()=>{const t=e.getFullYear(),n=e.getMonth(),a=(new Date(t,n,1).getDay()+6)%7,r=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-a+1),l=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:l===i,isSelected:l===s})}return r},[e,s,i]);return g("div",{className:"px-3 py-3",children:[a?g("div",{className:"mb-3 flex items-center justify-between",children:[u("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(-1),"aria-label":"Previous month",children:u(D,{className:"h-4 w-4"})}),u("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),u("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(1),"aria-label":"Next month",children:u(x,{className:"h-4 w-4"})})]}):"",g("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>u("div",{className:"df-mini-calendar-header text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6 text-gray-500 dark:text-gray-400",children:e},`weekday-${t}`)),h.map(e=>u("button",{type:"button",className:`\n df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6\n ${e.isToday?Qt:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""}\n `,onClick:()=>o(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},hn=({calendars:e,currentCalendarId:t,onMergeSelect:a})=>{const{t:l}=Nt(),[i,s]=n(!1),d=o(null),c=o(null),[m,f]=n({x:0,y:0}),y=o(),p=()=>{if(y.current&&clearTimeout(y.current),d.current){const e=d.current.getBoundingClientRect();f({x:e.right,y:e.top})}s(!0)},b=()=>{y.current=setTimeout(()=>{s(!1)},100)};r(()=>{const e=c.current;if(e){const t=e=>e.stopPropagation();return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}}},[i]);const D=e.filter(e=>e.id!==t);return 0===D.length?null:g(h,{children:[g("div",{ref:d,className:"relative flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-900 dark:text-slate-50",onMouseEnter:p,onMouseLeave:b,children:[u("span",{children:l("merge")}),u(x,{className:"h-4 w-4"})]}),i&&v(u("div",{ref:c,className:"fixed z-60 min-w-48 overflow-hidden rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-slate-800 dark:bg-slate-950 animate-in fade-in-0 zoom-in-95 duration-100",style:{top:m.y,left:m.x},onMouseEnter:p,onMouseLeave:b,onMouseDown:e=>e.stopPropagation(),children:D.map(e=>g("div",{className:"flex items-center cursor-pointer rounded-sm px-2 py-1.5 text-sm text-slate-900 hover:bg-slate-100 dark:text-slate-50 dark:hover:bg-slate-800",onClick:t=>{t.stopPropagation(),a(e.id)},children:[u("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),u("span",{className:"truncate",children:e.name||e.id})]},e.id))}),document.body)]})},mn=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:r}=Nt();return u("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:g("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("mergeConfirmTitle",{sourceName:e,targetName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:r("mergeConfirmMessage",{sourceName:e,targetName:t})}),g("div",{className:"mt-6 flex justify-end gap-3",children:[u("button",{type:"button",onClick:a,className:zt,children:r("cancel")}),u("button",{type:"button",onClick:n,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:r("merge")})]})]})})},vn=({calendarId:e,calendarName:t,calendars:a,step:r,onStepChange:o,onConfirmDelete:l,onCancel:i,onMergeSelect:s})=>{const[d,c]=n(!1),{t:m}=Nt();return u("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:u("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:g(h,"initial"===r?{children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m("deleteCalendar",{calendarName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:m("deleteCalendarMessage",{calendarName:t})}),g("div",{className:"mt-6 flex justify-between items-center",children:[g("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>c(!d),className:"flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-slate-700",children:m("merge")}),d&&u("div",{className:"absolute left-0 top-full mt-1 min-w-full w-max rounded-md border border-gray-200 bg-background shadow-lg dark:border-slate-700 z-10 max-h-60 overflow-y-auto",children:a.filter(t=>t.id!==e).map(e=>g("div",{className:"flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-slate-700 cursor-pointer",onClick:()=>{s(e.id),c(!1)},children:[u("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),u("span",{className:"whitespace-nowrap",children:e.name||e.id})]},e.id))})]}),g("div",{className:"flex gap-3",children:[u("button",{type:"button",onClick:i,className:zt,children:m("cancel")}),u("button",{type:"button",onClick:()=>o("confirm_delete"),className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:m("delete")})]})]})]}:{children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:m("confirmDeleteTitle",{calendarName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:m("confirmDeleteMessage")}),g("div",{className:"mt-6 flex justify-end gap-3",children:[u("button",{type:"button",onClick:i,className:"rounded-md px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-700",children:m("cancel")}),u("button",{type:"button",onClick:l,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:m("delete")})]})]})})})},fn=({app:e,calendars:t,toggleCalendarVisibility:o,isCollapsed:l,setCollapsed:i,renderCalendarContextMenu:s,editingCalendarId:d,setEditingCalendarId:c,onCreateCalendar:m})=>{var y,p,b,D;const{t:x}=Nt(),w=e.getVisibleMonth(),C=w.getFullYear(),E=w.getMonth(),[k,N]=n(null),T=void 0!==d?d:k,S=c||N,[M,I]=n(()=>new Date(C,E,1));r(()=>{I(e=>e.getFullYear()===C&&e.getMonth()===E?e:new Date(C,E,1))},[C,E]);const H=a(t=>{I(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[R,O]=n(null),[P,L]=n(null),[j,$]=n(null),[A,z]=n(null),[Y,F]=n(null),V=a((e,t)=>{e.preventDefault(),e.stopPropagation(),O({x:e.clientX,y:e.clientY,calendarId:t}),L(null)},[]),W=a(e=>{e.preventDefault(),L({x:e.clientX,y:e.clientY}),O(null)},[]),B=a(()=>{O(null)},[]),Z=a(()=>{L(null)},[]),U=a(()=>{R&&(F({calendarId:R.calendarId,step:"initial"}),B())},[R,B]),_=a(t=>{if(R){const{colors:n,darkColors:a}=J(t);e.updateCalendar(R.calendarId,{colors:n,darkColors:a}),B()}},[e,R,B]),q=a(()=>{if(R){const e=t.find(e=>e.id===R.calendarId);e&&$({x:R.x,y:R.y,calendarId:R.calendarId,initialColor:e.colors.lineColor,currentColor:e.colors.lineColor}),B()}},[R,t,B]),X=a(e=>{R&&(z({sourceId:R.calendarId,targetId:e}),B())},[R,B]),G=a(()=>{if(A){const{sourceId:t,targetId:n}=A;e.mergeCalendars(t,n),z(null)}},[e,A]),K=a(()=>{Y&&(e.deleteCalendar(Y.calendarId),F(null))},[e,Y]),Q=a(e=>{Y&&(z({sourceId:Y.calendarId,targetId:e}),F(null))},[Y]),ee=A?(null===(y=t.find(e=>e.id===A.sourceId))||void 0===y?void 0:y.name)||"Unknown":"",te=A?(null===(p=t.find(e=>e.id===A.targetId))||void 0===p?void 0:p.name)||"Unknown":"",ne=Y?(null===(b=t.find(e=>e.id===Y.calendarId))||void 0===b?void 0:b.name)||"Unknown":"",ae=e.getReadOnlyConfig(),re=!e.state.readOnly,oe=!1!==ae.draggable;return g("div",{className:"df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",onContextMenu:re?W:void 0,children:[u(Ot,{isCollapsed:l,onCollapseToggle:()=>i(!l)}),l?u(Lt,{calendars:t,onToggleVisibility:o,onReorder:oe?e.reorderCalendars:()=>{},onRename:re?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:re?V:()=>{},editingId:T,setEditingId:S,activeContextMenuCalendarId:null==R?void 0:R.calendarId,isDraggable:oe,isEditable:re}):g(h,{children:[u(Lt,{calendars:t,onToggleVisibility:o,onReorder:oe?e.reorderCalendars:()=>{},onRename:re?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:re?V:()=>{},editingId:T,setEditingId:S,activeContextMenuCalendarId:null==R?void 0:R.calendarId,isDraggable:oe,isEditable:re}),u("div",{className:"border-t border-gray-200 dark:border-slate-800",children:u(gn,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:H,onDateSelect:t=>e.setCurrentDate(t)})})]}),R&&u(Tt,{x:R.x,y:R.y,onClose:B,className:"w-64 p-2",children:s?s(t.find(e=>e.id===R.calendarId),B):g(h,{children:[u(It,{children:x("calendarOptions")}),u(hn,{calendars:t,currentCalendarId:R.calendarId,onMergeSelect:X}),u(St,{onClick:U,children:x("delete")}),u(Mt,{}),u(Rt,{selectedColor:null===(D=t.find(e=>e.id===R.calendarId))||void 0===D?void 0:D.colors.lineColor,onSelect:_,onCustomColor:q})]})}),P&&v(g(Tt,{x:P.x,y:P.y,onClose:Z,className:"w-max p-2",children:[u(St,{onClick:()=>{null==m||m(),Z()},children:x("newCalendar")||"New Calendar"}),u(St,{onClick:()=>{e.triggerRender(),Z()},children:x("refreshAll")||"Refresh All"})]}),document.body),A&&v(u(mn,{sourceName:ee,targetName:te,onConfirm:G,onCancel:()=>z(null)}),document.body),Y&&v(u(vn,{calendarId:Y.calendarId,calendarName:ne,calendars:t,step:Y.step,onStepChange:e=>F(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:K,onCancel:()=>F(null),onMergeSelect:Q}),document.body),j&&v(u("div",{className:"fixed inset-0 z-50",onMouseDown:()=>$(null),children:u("div",{className:"absolute rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",style:{top:j.y,left:j.x},onMouseDown:e=>e.stopPropagation(),children:u(f,{width:"220px",color:j.currentColor,onChange:e=>{$(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=J(t.hex);e.updateCalendar(j.calendarId,{colors:n,darkColors:a})}})})}),document.body)]})},yn=({options:e,value:t,onChange:a,registry:l,variant:i="desktop"})=>{const[s,d]=n(!1),[c,h]=n({}),m=o(null),f=o(null),y=()=>{if(f.current){const e=f.current.getBoundingClientRect(),t="mobile"===i,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,h(n)}};r(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-color-picker-dropdown]")||d(!1)};return s&&(y(),window.addEventListener("mousedown",e),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[s]);const p=e=>(l||K()).resolveColors(e).lineColor,b=(e,t)=>{e.stopPropagation(),a(t),d(!1)},D=e.find(e=>e.value===t),x=()=>s&&"undefined"!=typeof window?v("mobile"===i?u("div",{"data-color-picker-dropdown":"true",style:c,className:"bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-200 origin-top-right animate-in fade-in zoom-in-95",children:e.map(e=>g("div",{className:"flex items-center px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>b(t,e.value),children:[g("div",{className:"flex items-center flex-1 min-w-0 mr-3",children:[u("div",{className:"w-5 flex justify-center mr-2",children:e.value===t&&u(C,{className:"w-4 h-4 text-primary"})}),u("span",{className:"text-sm text-gray-700 dark:text-gray-200 truncate",children:e.label})]}),u("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:p(e.value)}})]},e.value))}):u("ul",{"data-color-picker-dropdown":"true",style:c,className:"bg-white dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 overflow-hidden border border-gray-200 dark:border-gray-600 transition-all duration-200 origin-top-left animate-in fade-in zoom-in-95",children:e.map(e=>g("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors "+(t===e.value?"font-semibold":""),onClick:t=>b(t,e.value),children:[t===e.value?u("span",{className:"mr-2 text-sm text-primary",children:u(C,{width:12,height:12})}):u("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),u("span",{className:"w-3 h-3 mr-2 rounded-sm shrink-0",style:{backgroundColor:p(e.value)}}),u("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return g("div","mobile"===i?{className:"relative inline-block",ref:m,children:[g("button",{ref:f,onClick:e=>{e.stopPropagation(),d(!s)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-3 py-1.5 transition-colors",children:[u("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:p(t)}}),u("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==D?void 0:D.label)||t}),u(w,{className:"w-4 h-4 text-gray-400"})]}),x()]}:{className:"relative inline-block",ref:m,children:[g("button",{ref:f,type:"button",onClick:e=>{e.stopPropagation(),d(!s)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[u("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{backgroundColor:p(t)}}),u(w,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),x()]})},pn=/(YYYY|YY|MM|DD|HH|mm)/g,bn=e=>e.toString().padStart(2,"0"),Dn=(e,t)=>{const n=(null!=t?t:"").trim(),a=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return a.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},xn=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),wn=e=>{let t,n=0,a="^";for(;null!==(t=pn.exec(e));){a+=xn(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=xn(e.slice(n))+"$",new RegExp(a)},Cn=(e,t,n,a)=>{const r=e.trim();if(!r)return null;const o=r.match(t),l=null==o?void 0:o.groups;if(!l)return null;const i=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:n.year,s=l.MM?Number(l.MM):n.month,c=l.DD?Number(l.DD):n.day,u=l.HH?Number(l.HH):n.hour,g=l.mm?Number(l.mm):n.minute;try{return d.ZonedDateTime.from({timeZone:a,year:i,month:s,day:c,hour:u,minute:g,second:n.second,millisecond:n.millisecond,microsecond:n.microsecond,nanosecond:n.nanosecond})}catch(e){return null}},En=e=>{const t=e;if(t.timeZoneId&&"string"==typeof t.timeZoneId)return t.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const n=e.timeZone;return n&&"string"==typeof n.id?n.id:"string"==typeof t.timeZone?t.timeZone:d.Now.timeZoneId()},kn=(e,t,n)=>{var a,r,o,l,i,s,c,u,g,h,m,v,f,y,p,b,D,x,w,C,E,k,N,T;if(!e){const e=null!=t?t:n?En(n):d.Now.timeZoneId();return null!=n?n:d.Now.zonedDateTimeISO(e)}if(ue(e)){const n=null!=t?t:d.Now.timeZoneId(),a=`${e.year}-${bn(e.month)}-${bn(e.day)}T00:00:00[${n}]`;return d.ZonedDateTime.from(a)}if("hour"in e&&!("timeZone"in e)){const n=null!=t?t:d.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(n)}catch(e){}return d.ZonedDateTime.from({timeZone:n,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:null!==(a=e.second)&&void 0!==a?a:0,millisecond:null!==(r=e.millisecond)&&void 0!==r?r:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(l=e.nanosecond)&&void 0!==l?l:0})}try{return d.ZonedDateTime.from(e)}catch(a){const r=e,o=null!==(g=null!==(u=null!==(c=null!==(s="string"==typeof(null==r?void 0:r.timeZone)?r.timeZone:null===(i=null==r?void 0:r.timeZone)||void 0===i?void 0:i.id)&&void 0!==s?s:null==r?void 0:r.timeZoneId)&&void 0!==c?c:t)&&void 0!==u?u:n?En(n):void 0)&&void 0!==g?g:d.Now.timeZoneId();if("function"==typeof(null==r?void 0:r.toZonedDateTime))try{return r.toZonedDateTime({timeZone:o})}catch(e){}const l=null!=n?n:d.Now.zonedDateTimeISO(o);return d.ZonedDateTime.from({timeZone:o,year:null!==(h=null==r?void 0:r.year)&&void 0!==h?h:l.year,month:null!==(m=null==r?void 0:r.month)&&void 0!==m?m:l.month,day:null!==(v=null==r?void 0:r.day)&&void 0!==v?v:l.day,hour:null!==(y=null!==(f=null==r?void 0:r.hour)&&void 0!==f?f:null==n?void 0:n.hour)&&void 0!==y?y:0,minute:null!==(b=null!==(p=null==r?void 0:r.minute)&&void 0!==p?p:null==n?void 0:n.minute)&&void 0!==b?b:0,second:null!==(x=null!==(D=null==r?void 0:r.second)&&void 0!==D?D:null==n?void 0:n.second)&&void 0!==x?x:0,millisecond:null!==(C=null!==(w=null==r?void 0:r.millisecond)&&void 0!==w?w:null==n?void 0:n.millisecond)&&void 0!==C?C:0,microsecond:null!==(k=null!==(E=null==r?void 0:r.microsecond)&&void 0!==E?E:null==n?void 0:n.microsecond)&&void 0!==k?k:0,nanosecond:null!==(T=null!==(N=null==r?void 0:r.nanosecond)&&void 0!==N?N:null==n?void 0:n.nanosecond)&&void 0!==T?T:0})}},Nn=(e,t,n)=>{const a=Dn(t,n),r={YYYY:e.year.toString(),YY:bn(e.year%100),MM:bn(e.month),DD:bn(e.day),HH:bn(e.hour),mm:bn(e.minute)};return a.replace(pn,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},Tn=Array.from({length:24},(e,t)=>t),Sn=Array.from({length:60},(e,t)=>t),Mn=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:a,onYearChange:r})=>g("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[g("div",{className:"flex items-center gap-1",children:[u("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(E,{width:14,height:12})}),u("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(D,{width:14,height:12})})]}),g("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),g("div",{className:"flex items-center gap-1",children:[u("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(x,{width:14,height:12})}),u("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:u(k,{width:14,height:12})})]})]}),In=(e,t)=>d.PlainDate.compare(e,t),Hn=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:r,disabled:o,onDaySelect:l})=>g(h,{children:[u("div",{className:"grid grid-cols-7 gap-1 px-3 pb-3 pt-2 text-center text-[11px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:r.map((e,t)=>u("span",{children:e},t))}),u("div",{className:"grid grid-cols-7 gap-2 px-1 ",children:e.map(e=>{const r=e.month!==t.month,i=0===In(e,n),s=0===In(e,a),d=In(e,n)>=0&&In(e,a)<=0;return u("button",{type:"button",disabled:o,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${i||s?"bg-primary text-primary-foreground font-semibold":d?"bg-primary/10 text-primary":r?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"}`,children:e.day},e.toString())})})]}),Rn=({focusedField:e,draftRange:t,disabled:n,onHourSelect:a,onMinuteSelect:r,timeListRefs:o})=>{const l=e,i=t["start"===l?0:1],s=i.minute,d=Sn.includes(s)?Sn:[...Sn,s].sort((e,t)=>e-t);return g("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[u("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:g("div",{className:"text-lg py-1 text-slate-700 dark:text-gray-300",children:[i.hour.toString().padStart(2,"0"),":",i.minute.toString().padStart(2,"0")]})}),g("div",{className:"flex p-1",children:[u("div",{className:"w-14",children:u("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Hour",ref:e=>{o.current[l]&&(o.current[l].hour=e)},children:Tn.map(e=>{const t=e===i.hour;return u("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:bn(e)},e)})})}),u("div",{className:"w-14",children:u("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Minute",ref:e=>{o.current[l]&&(o.current[l].minute=e)},children:d.map(e=>{const t=e===s;return u("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:bn(e)},e)})})})]})]})},On=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:a,draftRange:r,focusedField:o,isTimeEnabled:l,disabled:i,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:h,onYearChange:m,onDaySelect:v,onHourSelect:f,onMinuteSelect:y,onOk:p,getPopupStyle:b})=>{const D=r[0].toPlainDate(),x=r[1].toPlainDate();return u("div",{ref:d,style:b(),"data-range-picker-popup":"true",children:g("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[g("div",{className:"flex gap-1",children:[g("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[u(Mn,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:h,onYearChange:m}),u(Hn,{calendarDays:a,visibleMonth:e,startDate:D,endDate:x,weekDayLabels:n,disabled:i,onDaySelect:v})]}),l&&u("div",{className:"flex flex-1 justify-end sm:w-32",children:u(Rn,{focusedField:o,draftRange:r,disabled:i,onHourSelect:f,onMinuteSelect:y,timeListRefs:c})})]}),u("div",{className:"flex justify-end",children:u("button",{type:"button",onClick:p,disabled:i,className:"inline-flex items-center rounded-full bg-primary px-4 py-1.5 text-sm font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Pn=({value:e,format:l="YYYY-MM-DD HH:mm",showTimeFormat:i="HH:mm",showTime:s=!0,onChange:c,onOk:h,timeZone:v,disabled:f=!1,placement:y="bottomLeft",autoAdjustOverflow:p=!0,getPopupContainer:b,matchTriggerWidth:D=!1,locale:x="en-US"})=>{const w=t(()=>"string"==typeof x?x:(null==x?void 0:x.code)||"en-US",[x]),C=t(()=>void 0===s||("object"==typeof s||Boolean(s)),[s]),E=t(()=>Ct(w,"short"),[w]),k=t(()=>wt(w,"narrow"),[w]),T=t(()=>C?"object"==typeof s&&(null==s?void 0:s.format)?s.format:i:"",[C,s,i]),S=t(()=>Dn(l,T),[l,T]),M=t(()=>wn(S),[S]),I=t(()=>{const t=null!=v?v:ue(e[0])?ue(e[1])?d.Now.timeZoneId():En(e[1]):En(e[0]),n=kn(e[0],t);return[n,kn(e[1],t,n)]},[e,v]),[H,R]=n(I),O=o(I),[P,L]=n("start"),[j,$]=n([Nn(I[0],l,T),Nn(I[1],l,T)]),A=o([Nn(I[0],l,T),Nn(I[1],l,T)]),z=o(I),[Y,F]=n(I[0].toPlainDate().with({day:1})),[V,W]=n(!1),B=a(e=>{W(e)},[]),[Z,U]=n(y),_=o(y),q=o(null),X=o(null),G=o({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=o(!1);r(()=>{A.current=j},[j]),r(()=>{z.current=H},[H]),r(()=>{const e=O.current,t=0!==d.ZonedDateTime.compare(e[0],I[0]),n=0!==d.ZonedDateTime.compare(e[1],I[1]);(t||n)&&R(I),O.current=I},[I]),r(()=>{F(I[0].toPlainDate().with({day:1}))},[I[0]]);const J=a((e,t,n=0)=>{var a;if(!e||!t)return;const r=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top+e.scrollTop-n,l=(null===(a=window.matchMedia)||void 0===a?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:l})},[]),Q=a(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const a=n.querySelector('[data-active="true"]');a&&J(n,a,0)})})})},[J]);r(()=>{V&&C&&Q(P)},[P,V,Q,C]);const ee=H[0].epochMilliseconds,te=H[0].offsetNanoseconds,ne=H[1].epochMilliseconds,ae=H[1].offsetNanoseconds;r(()=>{const[e,t]=z.current,n=Nn(e,l,T),a=Nn(t,l,T),[r,o]=A.current;r===n&&o===a||(A.current=[n,a],$([n,a]))},[ee,te,ne,ae,l,T]),r(()=>{if(!V)return;const e=e=>{var t,n;const a=e.target;if(null===(t=q.current)||void 0===t?void 0:t.contains(a))return;if(null===(n=X.current)||void 0===n?void 0:n.contains(a))return;a.closest("[data-range-picker-popup]")||B(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[V]),r(()=>{V||(L("start"),K.current||R(I),K.current=!1)},[V,I]);const re=a(e=>{c&&c(e,[Nn(e[0],l,T),Nn(e[1],l,T)])},[T,l,c]),oe=a(e=>{h&&h(e,[Nn(e[0],l,T),Nn(e[1],l,T)])},[T,l,h]),le=a((e,t)=>{R(n=>{const a=[...n];if("start"===e){const e=kn(a[1],En(t),t),n=d.ZonedDateTime.compare(t,e)>0?t:e;return[t,n]}const r=kn(a[0],En(t),t);return[d.ZonedDateTime.compare(r,t)>0?t:r,t]})},[]),ie=e=>{if(f)return;const t=(e,t)=>{var n,a,r,o;const l=En(e);return d.ZonedDateTime.from({timeZone:l,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(n=e.second)&&void 0!==n?n:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(r=e.microsecond)&&void 0!==r?r:0,nanosecond:null!==(o=e.nanosecond)&&void 0!==o?o:0})};if("start"===P){const n=t(H[0],e),a=H[1].epochMilliseconds-H[0].epochMilliseconds,r=n.add({milliseconds:a});return void R([n,r])}const n=t(H[1],e),a=H[1].epochMilliseconds-H[0].epochMilliseconds;if(d.ZonedDateTime.compare(n,H[0])<0){const n=t(H[0],e),r=n.add({milliseconds:a});return void R([n,r])}const r=[H[0],n];R(r),F(n.toPlainDate().with({day:1}))},se=a((e,t)=>{if(f)return;const n="start"===e?0:1;R(a=>{const r=a[n],o=r.with({hour:t,minute:r.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=kn(a[1],En(o),o);return[o,d.ZonedDateTime.compare(o,e)>0?o:e]}const l=kn(a[0],En(o),o);return[d.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&J(t,n,0)})})},[f]),de=a((e,t)=>{if(f)return;const n="start"===e?0:1;R(a=>{const r=a[n].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=kn(a[1],En(r),r);return[r,d.ZonedDateTime.compare(r,e)>0?r:e]}const o=kn(a[0],En(r),r);return[d.ZonedDateTime.compare(o,r)>0?r:o,r]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&J(t,n,0)})})},[f]),ce=a((e,t)=>{const n="start"===e?0:1;$(e=>{const a=[...e];return a[n]=t,a})},[]),ge=a((e,t)=>{const n="start"===e?0:1,a=H[n],r=En(a),o=Cn(t,M,a,r);if(o){le(e,o);const t=o.toPlainDate().with({day:1});return F(t),"start"===e&&L("end"),!0}return $(e=>{const t=[...e];return t[n]=Nn(H[n],l,T),t}),!1},[H,T,l,M,le]),he=a(e=>t=>{ce(e,t.target.value)},[ce]),me=a(e=>t=>{var n;if(f)return;if(V)return;const a=t.relatedTarget;a&&(null===(n=q.current)||void 0===n?void 0:n.contains(a))||ge(e,t.target.value)},[ge,f,V]),ve=a(e=>t=>{"Enter"===t.key&&(t.preventDefault(),ge(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ge]),fe=()=>{K.current=!0,re(H),oe(H),B(!1)},ye=e=>{F(t=>t.add({months:e}).with({day:1}))},pe=e=>{F(t=>t.add({years:e}).with({day:1}))},be=t(()=>{const e=Y,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[Y]),De=a((e=y)=>{if(!p||!q.current)return e;const t=q.current.getBoundingClientRect(),n=D?t.width:480,a=window.innerHeight-t.bottom,r=t.top,o=window.innerWidth-t.left,l=t.right;let i=e;return i.startsWith("bottom")&&a<500&&r>a?i=i.replace("bottom","top"):i.startsWith("top")&&r<500&&a>r&&(i=i.replace("top","bottom")),i.endsWith("Left")&&o<n&&l>o?i=i.replace("Left","Right"):i.endsWith("Right")&&l<n&&o>l&&(i=i.replace("Right","Left")),i},[p,D,y]),xe=a(()=>{const e=De();_.current!==e&&(_.current=e,U(e))},[De]),we=e=>{if(f)return;L(e);const t=H["start"===e?0:1].toPlainDate().with({day:1});F(t);const n=De();_.current!==n&&(_.current=n,U(n)),B(!0)};r(()=>{if(!V)return;xe();const e=()=>xe();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[V,xe]);const Ce=()=>{if(!q.current)return{};const e=q.current.getBoundingClientRect(),t=_.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,D&&(n.width=`${e.width}px`),n};return g("div",{className:"relative max-w-100",ref:q,children:[g("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(f?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":V?"border-primary bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700"),children:[u("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:u("input",{type:"text",value:j[0],onChange:he("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:me("start"),onKeyDown:ve("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(f?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===P&&V?" bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:S,autoComplete:"off",disabled:f})}),u(N,{className:"text-slate-400 dark:text-gray-500"}),u("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:u("input",{type:"text",value:j[1],onChange:he("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:me("end"),onKeyDown:ve("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(f?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===P&&V?"bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:S,autoComplete:"off",disabled:f})})]}),V&&(b?m.createPortal(u(On,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:H,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:X,timeListRefs:G,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:fe,getPopupStyle:Ce}),b()):m.createPortal(u(On,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:H,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:X,timeListRefs:G,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:fe,getPopupStyle:Ce}),document.body))]})},Ln=({event:e,isOpen:a,isAllDay:o,onEventUpdate:l,onEventDelete:i,onClose:s,app:c})=>{var h;const[v,f]=n(e),{t:y}=Nt();r(()=>{f(e)},[e]);const p=t(()=>(c?c.getCalendarRegistry():K()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),b=t(()=>!gt(e,v),[e,v]),D=t(()=>ue(v.start)?v.end&&!ue(v.end)&&(v.end.timeZoneId||v.end.timeZoneId)||d.Now.timeZoneId():v.start.timeZoneId||v.start.timeZoneId||d.Now.timeZoneId(),[v.end,v.start]),x=e=>{const[t,n]=e;f(Object.assign(Object.assign({},v),{start:t.toPlainDate(),end:n.toPlainDate()}))},w=!(null==c?void 0:c.state.readOnly),C=!1!==(null==c?void 0:c.getReadOnlyConfig().viewable);if(!a||!C)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const E=g("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[u("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/80",onClick:e=>{const t=e.target;t.closest("[data-range-picker-popup]")||t===e.currentTarget&&s()}}),g("div",{className:"df-dialog-container relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[u("button",{onClick:s,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:u("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),g("div",{children:[u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("eventTitle")}),g("div",{className:"flex items-center justify-between gap-3 mb-4",children:[u("div",{className:"flex-1",children:u("input",{type:"text",value:v.title,readOnly:!w,disabled:!w,onChange:e=>{f(Object.assign(Object.assign({},v),{title:e.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),w&&u(yn,{options:p,value:v.calendarId||"blue",onChange:e=>{f(Object.assign(Object.assign({},v),{calendarId:e}))},registry:null==c?void 0:c.getCalendarRegistry()})]}),v.allDay?g("div",{className:"mb-4",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("dateRange")}),u(Pn,{value:[v.start,v.end],format:"YYYY-MM-DD",showTime:!1,timeZone:D,matchTriggerWidth:!0,disabled:!w,onChange:x,onOk:x,locale:null==c?void 0:c.state.locale})]}):g("div",{className:"mb-4",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("timeRange")}),u(Pn,{value:[v.start,v.end],timeZone:D,disabled:!w,onChange:e=>{const[t,n]=e;f(Object.assign(Object.assign({},v),{start:t,end:n}))},onOk:e=>{const[t,n]=e;f(Object.assign(Object.assign({},v),{start:t,end:n}))},locale:null==c?void 0:c.state.locale})]}),g("div",{className:"mb-4",children:[u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("note")}),u("textarea",{value:null!==(h=v.description)&&void 0!==h?h:"",readOnly:!w,disabled:!w,onChange:e=>f(Object.assign(Object.assign({},v),{description:e.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:y("addNotePlaceholder")})]}),w&&g("div",{className:"flex space-x-2",children:[v.allDay?u("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=ue(v.start)?v.start:v.start.toPlainDate(),t=d.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:9,minute:0,timeZone:d.Now.timeZoneId()}),n=d.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:10,minute:0,timeZone:d.Now.timeZoneId()});f(Object.assign(Object.assign({},v),{allDay:!1,start:t,end:n}))},children:y("setAsTimed")}):u("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=ue(v.start)?v.start:v.start.toPlainDate();f(Object.assign(Object.assign({},v),{allDay:!0,start:e,end:e}))},children:y("setAsAllDay")}),u("button",{className:"px-3 py-2 bg-destructive border border-border text-destructive-foreground rounded-lg hover:bg-destructive/90 text-sm font-medium transition",onClick:()=>{i(e.id),s()},children:y("delete")}),u("button",{className:"px-3 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium transition ml-auto "+(b?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{l(v),s()},disabled:!b,children:y("save")})]})]})]})]}),k=document.body;return k?m.createPortal(E,k):null},jn=({calendar:e,mode:t="buttons"})=>{const[a,l]=n(!1),i=o(null),{t:s}=Nt(),d=Array.from(e.state.views.keys()),c=e.state.currentView;return d.length<=1?null:(r(()=>{const e=e=>{i.current&&!i.current.contains(e.target)&&l(!1)};if(a)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),"select"===t?g("div",{className:"relative inline-block",ref:i,children:[g("button",{onClick:()=>l(!a),className:"flex items-center gap-2 px-3 mb-1 h-7 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-primary focus:ring-offset-1 transition-all duration-200 shadow-sm min-w-30 justify-between","aria-expanded":a,"aria-haspopup":"listbox",children:[u("span",{className:"text-gray-900 dark:text-gray-100",children:s(c)}),u("span",{className:`${on} transition-transform duration-200 ${a?"rotate-180":""}`,children:u(T,{width:16,height:16})})]}),a&&u("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-30 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:u("div",{className:"py-1",role:"listbox",children:d.map(t=>u("button",{onClick:()=>{e.changeView(t),l(!1)},className:"w-full text-left px-3 py-2 text-sm transition-colors duration-150 "+(c===t?"bg-primary/10 text-primary font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":c===t,children:s(t)},t))})}),u("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}):u("div",{className:"inline-flex items-center gap-1 p-0.5 mb-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:d.map(t=>u("button",{className:"px-4 h-6 text-sm font-medium rounded-md transition-all duration-200 "+(c===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>e.changeView(t),children:s(t)},t))}))},$n=0,An=1970,zn=2100,Yn=8,Fn=100,Vn=1200,Wn=900,Bn=700;class Zn{static trackScrollEvent(e=0){this.metrics.scrollEvents++,this.metrics.totalScrollDistance+=Math.abs(e),this.metrics.avgScrollDelta=this.metrics.totalScrollDistance/this.metrics.scrollEvents}static trackRenderTime(e){this.metrics.renderTime.push(e),e>16.67&&this.metrics.frameDrops++,this.metrics.renderTime.length>100&&this.metrics.renderTime.shift()}static trackCacheHit(){this.metrics.cacheHits++}static trackCacheMiss(){this.metrics.cacheMisses++}static getMetrics(){const e=this.metrics.renderTime.length>0?this.metrics.renderTime.reduce((e,t)=>e+t,0)/this.metrics.renderTime.length:0,t=this.metrics.cacheHits+this.metrics.cacheMisses>0?this.metrics.cacheHits/(this.metrics.cacheHits+this.metrics.cacheMisses)*100:0,n=Date.now()-this.metrics.startTime,a=e>0?1e3/e:0;return{scrollEvents:this.metrics.scrollEvents,avgRenderTime:Math.round(100*e)/100,cacheHitRate:Math.round(100*t)/100,uptime:Math.round(n/1e3),scrollEventsPerSecond:Math.round(this.metrics.scrollEvents/(n/1e3)*100)/100,estimatedFPS:Math.round(a),frameDrops:this.metrics.frameDrops,avgScrollDelta:Math.round(100*this.metrics.avgScrollDelta)/100}}static reset(){this.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0}}}Zn.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const Un=()=>{const[e,t]=n({yearHeight:Bn,screenSize:"desktop"});return r(()=>{const e=()=>{const e=window.innerWidth;t(e<640?{yearHeight:Vn,screenSize:"mobile"}:e<900?{yearHeight:Wn,screenSize:"tablet"}:{yearHeight:Bn,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},_n=({currentDate:e,yearHeight:l,onCurrentYearChange:i})=>{const s=e.getFullYear(),d=(s-An)*l,[c,u]=n(d),[g,h]=n(600),[m,v]=n(s),[f,y]=n(!1),p=o(null),b=o(null),D=o(0),x=o(0),w=o(l);r(()=>{if(w.current===l)return;w.current=l;const e=(m-An)*l;u(e),x.current=e,p.current&&(p.current.scrollTop=e)},[l,m]);const C=t(()=>{const e=performance.now(),t=zn-An+1,n=t*l,a=Math.floor(c/l),r=Math.min(t-1,Math.ceil((c+g)/l)),o=Math.max(0,a-$n),i=Math.min(t-1,r+$n),s=[];for(let e=o;e<=i;e++)s.push({index:e,year:An+e,top:e*l,height:l});const d=performance.now()-e;return Zn.trackRenderTime(d),{totalHeight:n,visibleItems:s}},[c,g,l]),E=a(e=>{const t=performance.now();if(t-D.current<Yn)return;D.current=t;const n=e.currentTarget.scrollTop,a=Math.abs(n-x.current);x.current=n,Zn.trackScrollEvent(a),requestAnimationFrame(()=>{u(n);const e=n,t=Math.floor(An+e/l);t!==m&&t>=An&&t<=zn&&(v(t),null==i||i(t))}),y(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{y(!1)},Fn)},[g,m,l,i]);r(()=>{const e=p.current;if(!e)return;e.scrollTop=d,x.current=d;const t=new ResizeObserver(([e])=>{h(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[d]);const k=a((e,t=!0)=>{if(!p.current)return;const n=(e-An)*l;p.current.scrollTo({top:Math.max(0,n),behavior:t?"smooth":"auto"})},[l]),N=a(()=>{const e=Math.max(An,m-1);v(e),k(e)},[m,k]),T=a(()=>{const e=Math.min(zn,m+1);v(e),k(e)},[m,k]),S=a(()=>{const e=(new Date).getFullYear();v(e),k(e)},[k]);return r(()=>()=>{b.current&&clearTimeout(b.current)},[]),{scrollTop:c,containerHeight:g,currentYear:m,isScrolling:f,virtualData:C,scrollElementRef:p,handleScroll:E,scrollToYear:k,handlePreviousYear:N,handleNextYear:T,handleToday:S,setScrollTop:u,setContainerHeight:h,setCurrentYear:v,setIsScrolling:y}},qn=e=>{if(!e)return"";let t,n,a;e instanceof Date?(t=e.getFullYear(),n=e.getMonth()+1,a=e.getDate()):ue(e)?(t=e.year,n=e.month,a=e.day):(!function(){d.ZonedDateTime}(e),t=e.year,n=e.month,a=e.day);const r=String(n).padStart(2,"0");return`${String(a).padStart(2,"0")}/${r}/${t}`},Xn=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,Gn=e=>{const t=e.year,n=e.month;return`${e.day} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n-1]} ${t}`};function Kn(e){return!("hour"in e)}function Jn(e){return"hour"in e&&!("timeZone"in e)}function Qn(e){return"timeZone"in e}function ea(e){if(Kn(e))return new Date(e.year,e.month-1,e.day);if(Jn(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);const t=e.toInstant();return new Date(t.epochMilliseconds)}function ta(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function na(e){return d.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function aa(e,t){return d.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t})}function ra(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)}function oa(e){return new Date(e.year,e.month-1,e.day)}function la(e){if(Kn(e))return 0;return e.hour+e.minute/60}function ia(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return Qn(e),e.with({hour:n,minute:a,second:0,millisecond:0})}function sa(e,t){const n=Kn(e)?e:(Jn(e),e.toPlainDate()),a=Kn(t)?t:(Jn(t),t.toPlainDate());return n.equals(a)}function da(e){return Kn(e)?e:(Jn(e),e.toPlainDate())}const ca=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),ua={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-primary",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-primary focus:ring-primary",buttonPrimary:"bg-primary text-primary-foreground hover:bg-primary/90",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-destructive text-destructive-foreground hover:bg-destructive/90",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},ga=(e,t,n)=>e?t:n,ha=(...e)=>e.filter(Boolean).join(" "),ma=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.getAttribute("data-dayflow-theme-override"),t.getAttribute("data-theme-override"),t.getAttribute("data-theme")];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e};function va(e,t=!1){if(e instanceof d.PlainDate||e instanceof d.PlainDateTime)return e;if(e instanceof Date)return t?ta(e):na(e);throw new Error("Invalid time type: "+typeof e)}function fa(e,t){if(e instanceof d.ZonedDateTime)return e;if(e instanceof Date)return aa(e,t);throw new Error("Invalid time type: "+typeof e)}function ya(e){var t;const n=va(e.start,e.allDay),a=va(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:a,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function pa(e){const t=fa(e.start,e.timeZone),n=fa(e.end,e.timeZone);return{id:e.id,title:e.title,description:e.description,start:t,end:n,allDay:!1,calendarId:e.calendarId,meta:e.meta}}function ba(e){return e.map(e=>ya(e))}function Da(e){return e.map(e=>pa(e))}function xa(e,t,n,a){return ya(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))}function wa(e,t,n,a,r){return ya(Object.assign({id:e,title:t,start:n,end:a},r))}function Ca(e,t,n,a,r=!1,o){return ya(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))}function Ea(e,t,n,a,r,o){return pa(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))}const ka=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):fe(e)}catch(e){return new Date}},Na=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Ta=(e,t,n,a)=>{const r=e.getTime()-t.getTime(),o=Math.round(r/864e5);let l="",i="text-gray-500 dark:text-gray-400";if(0===o)l=a("today")||"Today",i="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");l=e.charAt(0).toUpperCase()+e.slice(1),i="text-black dark:text-white"}catch(t){l=e.toLocaleDateString(n,{weekday:"long"})}else l=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:l,colorClass:i}},Sa=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=ka(e.start),r=Na(a),o=r.getTime();n.has(o)||n.set(o,{date:r,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const a=t.getTime();n.has(a)||n.set(a,{date:t,events:[]});return Array.from(n.values()).sort((e,t)=>e.date.getTime()-t.date.getTime())};let Ma=null;const Ia=()=>{const[e,t]=n(()=>Ma||{weekHeight:U,screenSize:"desktop",weeksPerView:6});return r(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,a=Math.max(80,Math.floor(n/6)),r=e<768?{weekHeight:Math.max(B,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(Z,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(U,a),screenSize:"desktop",weeksPerView:6};Ma&&Ma.screenSize===r.screenSize&&Ma.weekHeight===r.weekHeight&&Ma.weeksPerView===r.weeksPerView||(Ma=r,t(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Ha=({currentDate:e,weekHeight:l,onCurrentMonthChange:i,initialWeeksToLoad:s=104,locale:d="en-US",isEnabled:c=!0})=>{const u=o(null),g=a((e,t)=>{const n=new Date(t,e,1),a=d.startsWith("zh")||d.startsWith("ja");return n.toLocaleDateString(d,{month:a?"short":"long"})},[d]),h=t(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),Je(t,s)},[e,s]),m=t(()=>{const t=new Date(e);t.setDate(1),t.setHours(0,0,0,0);const n=h.findIndex(e=>e.days.some(e=>e.date.toDateString()===t.toDateString()));return n>0?n*l:0},[h,e,l]),[v,f]=n(m),[y,p]=n(600),[b,D]=n(g(e.getMonth(),e.getFullYear())),[x,w]=n(e.getFullYear()),[C,E]=n(!1),[k,N]=n(h),[T,S]=n(!1),M=o(!1),[I,H]=n(!1),R=o(e),O=o(null),P=o(null),L=o(new _),j=o(0),$=o(0),A=o(!1),z=a(e=>{e&&(O.current=e)},[]),Y=a(e=>{let t=L.current.get(e);return console.log("weekData",t),t||(t=Xe(e),L.current.set(e,t)),t},[]),F=a((e,t=26)=>{A.current||(A.current=!0,setTimeout(()=>{try{if("future"===e){const e=k[k.length-1],n=[];for(let a=1;a<=t;a++){const t=new Date(e.startDate);t.setDate(t.getDate()+7*a),n.push(Y(t))}N(e=>[...e,...n])}else{const e=k[0],n=[];for(let a=t;a>=1;a--){const t=new Date(e.startDate);t.setDate(t.getDate()-7*a),n.push(Y(t))}const a=n.length*l;N(e=>[...n,...e]),requestAnimationFrame(()=>{f(e=>e+a),O.current&&(O.current.scrollTop+=a)})}}finally{setTimeout(()=>{A.current=!1},200)}},0))},[k,Y,l]),B=t(()=>{const e=k.length*l,t=Math.floor(v/l);let n=Math.max(0,t);n=Math.min(n,Math.max(0,k.length-6));const a=Math.min(k.length-1,n+6-1),r=Math.max(0,n-15),o=Math.min(k.length-1,a+15),i=[];for(let e=r;e<=o;e++)i.push({index:e,weekData:k[e],top:e*l,height:l});return{totalHeight:e,visibleItems:i,displayStartIndex:n}},[v,y,l,k]),Z=a(e=>{if(T||C||0===e.length||!I)return;const t=v+y/2,n=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!n)return;const a={};n.weekData.days.forEach(e=>{const t=`${g(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let r="",o=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,a]=e.split("-");r=n,o=parseInt(a)}}),r&&o&&(u.current?r===u.current.month&&o===u.current.year&&(u.current=null,r===b&&o===x||(D(r),w(o),null==i||i(r,o))):r===b&&o===x||(D(r),w(o),null==i||i(r,o)))},[y,b,x,T,C,i,v,I]),U=a(e=>{const t=performance.now();if(t-j.current<V)return;j.current=t;const n=e.currentTarget,a=n.scrollTop;$.current=a,f(a),T||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=n;a+t>e-10*l&&!A.current&&F("future",26),a<10*l&&!A.current&&F("past",26)}),E(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{E(!1)},W)},[l,F,T]),q=a((e,t=!0)=>{if(!O.current)return;S(!0),M.current=!0;const n=()=>{setTimeout(()=>{S(!1),M.current=!1},t?500:200)},a=k.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*l;return O.current.scrollTo({top:e,behavior:t?"smooth":"auto"}),void n()}const r=e.getDay(),o=0===r?6:r-1,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const s=k[0],d=k[k.length-1];let c=0,u=!1,g=!1;i<s.startDate?(c=Math.ceil((s.startDate.getTime()-i.getTime())/6048e5),u=!0):i>d.startDate&&(c=Math.ceil((i.getTime()-d.startDate.getTime())/6048e5),g=!0);const h=Math.min(c+10,52);if(u){const a=[];for(let e=h;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(Y(t))}const r=a.length*l;N(e=>[...a,...e]),requestAnimationFrame(()=>{const o=[...a,...k].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(O.current&&-1!==o){const e=o*l;O.current.scrollTop+=r,f(e=>e+r),setTimeout(()=>{O.current&&O.current.scrollTo({top:e,behavior:t?"smooth":"auto"})},50)}n()})}else if(g){const a=[];for(let e=1;e<=h;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(Y(t))}N(e=>[...e,...a]),requestAnimationFrame(()=>{const r=[...k,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(O.current&&-1!==r){const e=r*l;O.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}n()})}else n()},[k,l,Y]),X=a(()=>{const e=k[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);q(t)},[B.displayStartIndex,k,q]),G=a(()=>{const e=k[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);q(t)},[B.displayStartIndex,k,q]),K=a(()=>{const e=new Date,t=g(e.getMonth(),e.getFullYear()),n=e.getFullYear(),a=new Date(n,e.getMonth(),1);u.current={month:t,year:n},D(t),w(n),null==i||i(t,n);const r=k.findIndex(e=>e.days.some(e=>e.date.toDateString()===a.toDateString()));if(-1!==r){const e=r*l,t=O.current;t&&(S(!0),M.current=!0,requestAnimationFrame(()=>{f(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{M.current=!1,S(!1)},200))})}))}else S(!0),M.current=!0,requestAnimationFrame(()=>{q(a,!0),setTimeout(()=>{M.current=!1,S(!1)},200)})},[k,l,i,q]);return r(()=>{Z(B.visibleItems)},[B.visibleItems,Z]),r(()=>{const t=R.current,n=t.getMonth(),a=t.getFullYear(),r=e.getMonth(),o=e.getFullYear();if(n!==r||a!==o){const e=new Date(o,r,1),t=g(r,o);u.current={month:t,year:o},D(t),w(o),null==i||i(t,o),q(e,!0)}R.current=e},[e,i,q]),r(()=>{const e=O.current;if(!e)return;const t=new ResizeObserver(([e])=>{p(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r(()=>{const e=O.current;e&&!I&&c&&requestAnimationFrame(()=>{e&&m>0?(e.scrollTop=m,f(m),H(!0)):e&&H(!0)})},[I,m,c]),r(()=>()=>{P.current&&clearTimeout(P.current)},[]),{scrollTop:v,containerHeight:y,currentMonth:b,currentYear:x,isScrolling:C,virtualData:B,scrollElementRef:O,handleScroll:U,scrollToDate:q,handlePreviousMonth:X,handleNextMonth:G,handleToday:K,setScrollTop:f,setContainerHeight:p,setCurrentMonth:D,setCurrentYear:w,setIsScrolling:E,cache:L.current,scrollElementRefCallback:z,weeksData:k}},Ra=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:r,searchValue:o="",isSearchOpen:l=!1,isEditable:i=!0})=>{const s="buttons"===t,d=e.state.currentView===Y.DAY,{screenSize:c}=Ia(),h="mobile"===c,{t:m}=Nt();return g("div",{className:"flex items-center justify-between px-2 pt-1 bg-white dark:bg-gray-900 transition-colors duration-200 shrink-0 border-b "+(d||l?"border-gray-200 dark:border-gray-700":"border-transparent"),children:[u("div",{className:"flex flex-1 items-center mb-1",children:n&&i&&u("button",{onClick:n,className:rn,title:h?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:u(S,{className:`h-4 w-4 ${on}`})})}),u("div",{className:"flex-1 flex justify-center",children:s&&u(jn,{mode:t,calendar:e})}),!s&&u(jn,{mode:t,calendar:e}),g("div",{className:`flex ${"select"===t?"ml-2":"flex-1"} items-center justify-end gap-3 mb-1 pb-1 h-6`,children:[u("button",{onClick:r,className:`md:hidden ${rn}`,children:u(M,{width:16,height:16})}),g("div",{className:"relative hidden md:block group mt-1",children:[u("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:u("span",{className:"text-gray-400 group-focus-within:text-primary transition-colors",children:u(M,{width:16,height:16})})}),u("input",{type:"text",placeholder:"Search",value:o,onChange:e=>{null==a||a(e.target.value)},className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary transition resize-none w-48"}),o&&u("button",{onClick:()=>{null==a||a("")},className:"absolute inset-y-0 right-0 pr-2 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:g("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},Oa=i(void 0),Pa=({children:e,initialTheme:t="light",onThemeChange:o})=>{const[l,i]=n(t),[s,d]=n("light"),c="auto"===l?s:l;r(()=>{i(t)},[t]);const g=a(e=>{i(e)},[]);r(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";d(t)},n=e.matches?"dark":"light";return d(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),r(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=ma(c),n="auto"===l?t:c;e.classList.remove("light","dark"),e.classList.add(n),"auto"===l?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[c,l,s]),r(()=>{o&&o(l,c)},[l,c,o]);const h={theme:l,effectiveTheme:c,setTheme:g};return u(Oa.Provider,{value:h,children:e})},La=()=>{const e=l(Oa);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},ja=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],$a=({onClose:e,onCreate:t})=>{const[a,r]=n(""),[o,l]=n(ja[Math.floor(Math.random()*ja.length)]),[i,s]=n(!1),[d,c]=n(""),{effectiveTheme:h}=La(),{t:m}=Nt(),f="dark"===h,p={default:{picker:{background:f?"#1e293b":"#ffffff",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",borderRadius:"0.5rem",border:f?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:f?"#1e293b":"#ffffff",borderBottom:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:f?"#1e293b":"#ffffff"},controls:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:f?"#374151":"#ffffff",color:f?"#f3f4f6":"#1f2937",border:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:f?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:v(u("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:g("div",{className:"w-full max-w-sm rounded-lg p-6 shadow-xl bg-background animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[u("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:m("createCalendar")}),g("form",{onSubmit:n=>{if(n.preventDefault(),!a.trim())return;const{colors:r,darkColors:l}=J(o),i={id:mt(),name:a.trim(),colors:r,darkColors:l,isVisible:!0,isDefault:!1};t(i),e()},children:[u("div",{className:"mb-4",children:g("div",{className:"flex items-center gap-3",children:[u("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:o}}),u("input",{type:"text",value:a,onChange:e=>r(e.target.value),className:"w-full flex-1 rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 dark:focus:border-primary dark:focus:ring-primary",placeholder:m("calendarNamePlaceholder"),autoFocus:!0})]})}),g("div",{className:"mb-6",children:[u("div",{className:"grid grid-cols-7 gap-6",children:ja.map(e=>u("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(o===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>l(e)},e))}),g("div",{className:"mt-2 relative",children:[u("button",{type:"button",onClick:()=>{c(o),s(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800 transition-colors focus:outline-none focus:bg-slate-100 dark:focus:bg-slate-800",children:m("customColor")}),i&&u("div",{className:"absolute left-0 top-full z-10001 mt-2",children:u(y,{color:o,onChange:e=>{l(e.hex)},onAccept:()=>{s(!1)},onCancel:()=>{l(d),s(!1)},styles:p})})]})]}),g("div",{className:"flex justify-end space-x-3",children:[u("button",{type:"button",onClick:e,className:zt,children:m("cancel")}),u("button",{type:"submit",disabled:!a.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:m("create")})]})]})]})}),document.body)},Aa=({loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>{const{t:i,locale:s}=Nt(),d=t(()=>Na(new Date),[]),c=t(()=>Sa(a,d),[a,d]),h=e=>ka(e);return n?g("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[u(I,{className:"w-8 h-8 animate-spin mb-2"}),u("span",{children:"Loading..."})]}):0===a.length?r?g("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[u(za,{}),u("span",{className:"mt-2 text-sm",children:"string"==typeof l?l:l&&"object"==typeof l?l[s]||l.en||"No results found":i("noResults")||"No results found"})]}):null:u("div",{className:"space-y-6",children:c.map(t=>{const{title:n,colorClass:a}=Ta(t.date,d,s,i);return g("div",{children:[u("h3",{className:`px-2 text-sm font-medium mb-4 sticky top-0 bg-white dark:bg-gray-900 py-1 z-10 ${a} border-b border-gray-200 dark:border-gray-700`,children:n}),u("div",{className:"flex flex-col",children:t.events.map(t=>{const n=h(t.start),a=h(t.end),r={hour:"2-digit",minute:"2-digit"},l=t.allDay?i("allDay")||"All Day":n.toLocaleTimeString(s,r),d=t.allDay?"":a.toLocaleTimeString(s,r);return g(e.Fragment,{children:[u("div",{className:"p-2 mx-2 mb-1 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer transition-colors group",onClick:()=>null==o?void 0:o(t),children:g("div",{className:"flex items-stretch gap-3",children:[u("div",{className:"w-1 rounded-full shrink-0",style:{backgroundColor:t.color||"#3b82f6"}}),g("div",{className:"flex-1 min-w-0 flex justify-between items-start",children:[u("div",{className:"font-medium text-black dark:text-white truncate pr-2 text-sm",children:t.title}),g("div",{className:"text-xs flex flex-col items-end shrink-0 leading-tight",children:[u("div",{className:"text-black dark:text-white",children:l}),d&&u("div",{className:"text-gray-500 dark:text-gray-400",children:d})]})]})]})}),u("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},t.id)})})]},t.date.getTime())})})},za=()=>u("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:u("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Ya=({isOpen:e,onClose:t,loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>u("div",{className:"hidden md:flex relative h-full bg-white dark:bg-gray-900 transition-all duration-300 ease-in-out flex-col border-l border-gray-200 dark:border-gray-700 overflow-hidden select-none "+(e?"w-64":"w-0 border-l-0"),children:u("div",{className:"flex-1 overflow-y-auto min-w-64",children:u(Aa,{loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})})}),Fa=({isOpen:e,onClose:t,keyword:n,onSearchChange:a,results:l,loading:i,onResultClick:s,emptyText:d})=>{const c=o(null),{t:h}=Nt();return r(()=>(e?(setTimeout(()=>{var e;null===(e=c.current)||void 0===e||e.focus()},100),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),e&&"undefined"!=typeof window?v(g("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[g("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[u("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:u(H,{className:"w-6 h-6"})}),g("div",{className:"flex-1 relative",children:[u("input",{ref:c,type:"text",placeholder:h("search")||"Search",value:n,onChange:e=>a(e.target.value),className:"w-full pl-3 pr-10 py-2 bg-gray-100 dark:bg-gray-800 border-none rounded-full text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary focus:outline-none"}),n&&u("button",{onClick:()=>a(""),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:u(R,{className:"w-4 h-4"})})]})]}),u("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:u(Aa,{loading:i,results:l,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},Va=({app:e,anchorRef:a,onClose:l,isOpen:i})=>{const{t:d}=Nt(),[c,h]=n(""),[m,f]=n(0),[y,p]=n(!1),b=o(null),D=o(null);r(()=>{i||p(!1)},[i]),r(()=>{i&&(setTimeout(()=>{var e;return null===(e=b.current)||void 0===e?void 0:e.focus()},50),h(""),f(0))},[i]),r(()=>{const e=e=>{i&&D.current&&!D.current.contains(e.target)&&a.current&&!a.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i,l,a]);const[x,w]=n({top:0,left:0}),[C,E]=n("top"),[k,N]=n(0),T=t(()=>{const e=new Date,t=new Date(e);t.setHours(t.getHours()+1,0,0,0);const n=new Date(t);return n.setHours(n.getHours()+1),{start:t,end:n}},[i]),S=t(()=>{if(!c.trim())return[];const t=[],n=e.getCalendars(),a=e.getAllEvents(),r=c.toLowerCase(),o=a.find(e=>e.title.toLowerCase()===r);let l=null==o?void 0:o.calendarId;if(!l){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);l=e[t].id}else n.length>0&&(l=n[0].id)}const i=n.find(e=>e.id===l),s=(null==i?void 0:i.colors.lineColor)||"#3b82f6";t.push({type:"new",title:c,calendarId:l||"",color:s,start:T.start,end:T.end});const d=new Set;d.add(c.toLowerCase());return a.filter(e=>e.title.toLowerCase().includes(r)&&!d.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{d.add(e.title.toLowerCase());const a=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==a?void 0:a.colors.lineColor)||"#9ca3af",start:T.start,end:T.end})}),t},[c,e,T]);s(()=>{if(i&&a.current&&D.current){const e=a.current.getBoundingClientRect(),t=D.current.offsetHeight,n=340;let r=e.left+e.width/2-n/2;const o=12,l=window.innerWidth;r<o?r=o:r+n>l-o&&(r=l-n-o);const i=e.left+e.width/2;N(i-r);let s=0,d="top";e.top<t+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-t),E(d),w({top:s,left:r}),p(!0)}},[i,a,S]);const M=t=>{if(!t.calendarId)return;const n=mt(),a={id:n,title:t.title,start:he(t.start),end:he(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(n),l()};r(()=>{if(!i)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),f(e=>(e+1)%S.length)):"ArrowUp"===e.key?(e.preventDefault(),f(e=>(e-1+S.length)%S.length)):"Enter"===e.key&&(e.preventDefault(),S[m]&&M(S[m]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i,S,m]);const I=(e,t)=>{const n=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n(e)} - ${n(t)}`};return i?v(g("div",{ref:D,className:"fixed z-1000 w-85 flex flex-col bg-white dark:bg-slate-800 rounded-xl shadow-2xl border border-gray-200 dark:border-slate-700 "+(y?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:x.top,left:x.left,visibility:y?"visible":"hidden"},children:[g("div",{className:"p-4 pb-2",children:[u("div",{className:"mb-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:d("quickCreateEvent")||"Quick Create Event"}),u("div",{className:"relative",children:u("input",{ref:b,type:"text",className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:d("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:c,onChange:e=>h(e.target.value)})})]}),g("div",{className:"flex-1 overflow-y-auto max-h-75 py-1 px-2",children:[0===S.length&&c&&u("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:d("noSuggestions")||"Type to create"}),S.map((e,t)=>g("div",{className:"flex items-center px-4 py-2 cursor-pointer transition-colors rounded-lg "+(t===m?"bg-primary/10 dark:bg-primary/20 ring-1 ring-inset ring-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>M(e),onMouseEnter:()=>f(t),children:[u("div",{className:"w-1 h-8 rounded-full mr-3 shrink-0",style:{backgroundColor:e.color}}),g("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[u("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title}),u("div",{className:"flex",children:u("span",{className:"font-semibold text-[10px] px-1 bg-gray-100 dark:bg-slate-700 rounded text-gray-500 dark:text-gray-400",children:"new"===e.type?d("today"):d("tomorrow")})}),u("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:I(e.start,e.end)})]})]},`${e.type}-${t}`))]}),u("div",{className:"absolute w-3 h-3 bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 rotate-45 -translate-x-1/2 "+("top"===C?"-bottom-1.5 border-b border-r":"-top-1.5 border-t border-l"),style:{left:k}})]}),document.body):null},Wa=({checked:e,onChange:t})=>u("div",{className:"w-12 h-7 flex items-center rounded-full p-1 cursor-pointer transition-colors "+(e?"bg-green-500":"bg-gray-300"),onClick:()=>t(!e),children:u("div",{className:"bg-white w-5 h-5 rounded-full shadow-md transform transition-transform "+(e?"translate-x-5":"")})}),Ba=({date:e,onChange:t})=>{const a=Array.from({length:24},(e,t)=>t),l=Array.from({length:12},(e,t)=>5*t),i=[...a,...a,...a],s=[...l,...l,...l],d=32,c=e.getHours(),h=5*Math.round(e.getMinutes()/5),m=(24+c)*d,v=(12+h/5)*d,[f,y]=n(m),[p,b]=n(v),D=o(null),x=o(null),w=o(null);r(()=>{D.current&&(D.current.scrollTop=m,y(m)),x.current&&(x.current.scrollTop=v,b(v))},[m,v]);const C=(n,a)=>{const r=n.currentTarget;let o=r.scrollTop;if("hour"===a){const e=768;o<320?(o+=e,r.scrollTop=o):o>1600&&(o-=e,r.scrollTop=o),y(o)}else{const e=384;o<160?(o+=e,r.scrollTop=o):o>800&&(o-=e,r.scrollTop=o),b(o)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{((n,a)=>{const r=Math.round(a/d);if("hour"===n){const n=i[r];if(void 0!==n&&n!==e.getHours()){const a=new Date(e);a.setHours(n),t(a)}}else{const n=s[r];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const a=new Date(e);a.setMinutes(n),t(a)}}})(a,o)},150)},E=(e,t)=>{const n=96+e*d+16-(t+112),a=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*a})`,opacity:1-.7*a,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return g("div",{className:"flex h-56 overflow-hidden rounded-lg mt-2 relative ",children:[u("style",{dangerouslySetInnerHTML:{__html:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}}),g("div",{ref:D,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>C(e,"hour"),children:[u("div",{style:{height:96}}),i.map((n,a)=>u("div",{className:"h-8 flex items-center justify-end pr-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setHours(n),t(o),null===(r=D.current)||void 0===r||r.scrollTo({top:a*d,behavior:"smooth"})},children:u("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===c?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:E(a,f),children:n.toString().padStart(2,"0")})},a)),u("div",{style:{height:96}})]}),g("div",{ref:x,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>C(e,"minute"),children:[u("div",{style:{height:96}}),s.map((n,a)=>u("div",{className:"h-8 flex items-center justify-start pl-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setMinutes(n),t(o),null===(r=x.current)||void 0===r||r.scrollTo({top:a*d,behavior:"smooth"})},children:u("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===h?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:E(a,p),children:n.toString().padStart(2,"0")})},a)),u("div",{style:{height:96}})]}),u("div",{className:"absolute top-24 left-2 right-2 h-8 bg-gray-300/20 dark:bg-gray-500/20 pointer-events-none border border-gray-300 dark:border-gray-600 rounded-lg"})]})},Za=({isOpen:t,onClose:a,onSave:o,draftEvent:l,app:i})=>{const{locale:s,t:d}=Nt(),[c,h]=n(""),[m,f]=n(""),[y,p]=n(!1),[b,D]=n(new Date),[x,w]=n(new Date),[C,E]=n(""),[k,N]=n(new Date),[T,S]=n(new Date),[M,I]=n(null),[H,R]=n(t),[O,P]=n(!1),[L,j]=n(!1);r(()=>{if(!t){P(!0);const e=setTimeout(()=>{R(!1),P(!1)},300);return()=>clearTimeout(e)}R(!0),P(!1)},[t]),r(()=>{if(t&&l){const e=i.getEvents().some(e=>e.id===l.id);j(e)}},[t,l,i]);const $=i.getCalendars(),A=$.map(e=>({label:e.name,value:e.id}));r(()=>{if(t&&$.length>0){$.some(e=>e.id===m)||"blue"!==m&&""!==m||f($[0].id)}},[$,t,m]),r(()=>(t?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""}),[t]),r(()=>{var e,n;if(t&&l){if(h(l.title||""),f(l.calendarId||(null===(e=$[0])||void 0===e?void 0:e.id)||"blue"),p(l.allDay||!1),l.start)try{const e=fe(l.start);D(e),N(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;D(t),N(t)}if(l.end)try{const e=fe(l.end);w(e),S(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;w(t),S(t)}}else if(t&&!l){f((null===(n=$[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),D(e),N(e),w(new Date(e.getTime()+36e5)),S(e)}},[t,l]);const z=e.useMemo(()=>{if(!t||!l)return!1;let e=new Date(b),n=new Date(x);y&&(e.setHours(0,0,0,0),n.setHours(0,0,0,0));const a=Object.assign(Object.assign({},l),{title:c,calendarId:m,allDay:y,description:C,start:he(e),end:he(n)});return!gt(l,a)},[t,l,c,m,y,b,x,C]);if(!H)return null;const Y=e=>{I(t=>t===e?null:e)},F=e=>e.toLocaleDateString(s,{day:"numeric",month:"short",year:"numeric"}),V=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(b.getHours(),b.getMinutes());const n=e.getTime()-b.getTime();D(e);const a=new Date(x.getTime()+n);w(a)}else{const e=new Date(t);e.setHours(x.getHours(),x.getMinutes()),w(e)}},W=(e,t)=>{"start"===e?N(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):S(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return v(g("div",{className:"fixed inset-0 z-10000 flex items-end pointer-events-none",children:[u("div",{className:"absolute inset-0 bg-black/30 pointer-events-auto transition-opacity duration-300 "+(O?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:a}),g("div",{className:"relative w-full bg-gray-100 dark:bg-gray-800 rounded-t-2xl shadow-xl h-[85vh] flex flex-col pointer-events-auto overflow-hidden "+(O?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[g("div",{className:"flex justify-between items-center p-4 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:[u("button",{onClick:a,className:"text-gray-500 hover:text-gray-700 px-2 py-1",children:d("cancel")}),u("span",{className:"font-semibold text-lg",children:d(L?"editEvent":"newEvent")}),u("button",{onClick:()=>{if(!l)return;let e=new Date(b),t=new Date(x);y&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const n=Object.assign(Object.assign({},l),{title:c,calendarId:m,allDay:y,start:he(e),end:he(t)});o(n)},disabled:!z,className:"font-bold px-2 py-1 transition-colors "+(z?"text-primary":"text-gray-400 cursor-not-allowed opacity-50"),children:d(L?"done":"create")})]}),g("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:u("input",{type:"text",placeholder:d("titlePlaceholder"),value:c,onChange:e=>h(e.target.value),className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:!0})}),$.length>0&&g("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center relative",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),u(yn,{options:A,value:m,onChange:f,registry:i.getCalendarRegistry(),variant:"mobile"})]}),g("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),u(Wa,{checked:y,onChange:p})]}),g("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[g("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),g("div",{className:"flex space-x-2",children:[u("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-date"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("start-date"),children:F(b)}),!y&&u("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("start-time"),children:Ae(b.getHours()+b.getMinutes()/60)})]})]}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===M?"max-h-100":"max-h-0"),children:u("div",{className:"",children:u(gn,{currentDate:b,visibleMonth:k,onDateSelect:e=>V("start",e),onMonthChange:e=>W("start",e),showHeader:!0})})}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===M?"max-h-75":"max-h-0"),children:u("div",{className:"",children:u(Ba,{date:b,onChange:e=>{const t=x.getTime()-b.getTime();D(e),w(new Date(e.getTime()+t))}})})})]}),g("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[g("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[u("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),g("div",{className:"flex space-x-2",children:[u("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-date"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("end-date"),children:F(x)}),!y&&u("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-time"===M?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>Y("end-time"),children:Ae(x.getHours()+x.getMinutes()/60)})]})]}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===M?"max-h-100":"max-h-0"),children:u("div",{className:"",children:u(gn,{currentDate:x,visibleMonth:T,onDateSelect:e=>V("end",e),onMonthChange:e=>W("end",e),showHeader:!0})})}),u("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===M?"max-h-75":"max-h-0"),children:u("div",{className:"",children:u(Ba,{date:x,onChange:e=>{if(e<b){const t=x.getTime()-b.getTime();w(e),D(new Date(e.getTime()-t))}else w(e)}})})})]}),u("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:u("textarea",{placeholder:d("notesPlaceholder"),value:C,onChange:e=>E(e.target.value),className:"w-full bg-transparent text-base placeholder-gray-400 focus:outline-none min-h-20"})})]})]})]}),document.body)},Ua=({locale:e="en-US",messages:n,children:a})=>{const r=t(()=>{if("string"==typeof e){return{code:ce(e)?e:"en-US",messages:void 0}}return e&&!ce(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),o=t(()=>{const e=r.code;return{locale:e,t:(t,a)=>{var o,l,i;let s=null!==(i=null!==(o=null==n?void 0:n[t])&&void 0!==o?o:null===(l=r.messages)||void 0===l?void 0:l[t])&&void 0!==i?i:Et(t,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replace(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:wt,getMonthLabels:Ct,isDefault:!1}},[r,n]);return u(kt.Provider,{value:o,children:a})},_a=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],qa=({locale:e,messages:t,children:n})=>Nt().isDefault?u(Ua,{locale:e,messages:t,children:n}):u(h,{children:n}),Xa=({calendar:e,className:l,style:i,customDetailPanelContent:s,customEventDetailDialog:d,meta:h,search:m})=>{var v,f;const y=e.app,p=y.getCurrentView(),b=p.component,D=y.getSidebarConfig(),x=null!==(v=null==D?void 0:D.enabled)&&void 0!==v&&v,[w,C]=n(0),[E,k]=n(null!==(f=null==D?void 0:D.initialCollapsed)&&void 0!==f&&f),{t:N}=Nt(),[T,S]=n(!1),[M,I]=n(null),[H,R]=n(!1),O=o(null),[P,L]=n(!1),[j,$]=n(!1),[A,z]=n(null),[Y,F]=n(()=>y.getTheme()),[V,W]=n(""),[B,Z]=n(!1),[U,_]=n(!1),[q,X]=n(!1),[G,K]=n([]);r(()=>{const e=()=>{L(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),r(()=>{var e;if(!V.trim())return Z(!1),K([]),void y.highlightEvent(null);const t=null!==(e=null==m?void 0:m.debounceDelay)&&void 0!==e?e:300,n=setTimeout(()=>c(void 0,void 0,void 0,function*(){var e;X(!0),Z(!0);try{let t=[];if(null==m?void 0:m.customSearch){const e=y.getEvents().map(e=>{var t;return Object.assign(Object.assign({},e),{color:(null===(t=y.getCalendarRegistry().get(e.calendarId||""))||void 0===t?void 0:t.colors.lineColor)||y.getCalendarRegistry().resolveColors().lineColor})});t=m.customSearch({keyword:V,events:e})}else if(null==m?void 0:m.onSearch)t=yield m.onSearch(V);else{const e=V.toLowerCase();t=y.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var t;return Object.assign(Object.assign({},e),{color:(null===(t=y.getCalendarRegistry().get(e.calendarId||""))||void 0===t?void 0:t.colors.lineColor)||y.getCalendarRegistry().resolveColors().lineColor})})}K(t),null===(e=null==m?void 0:m.onSearchStateChange)||void 0===e||e.call(m,{keyword:V,loading:!1,results:t})}catch(e){console.error("Search failed",e),K([])}finally{X(!1)}}),t);return()=>clearTimeout(n)},[V,m,y]),r(()=>{B||y.highlightEvent(null)},[B,y]);const Q=e=>{let t;t=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):fe(e.start),y.setCurrentDate(t),y.highlightEvent(e.id),U&&_(!1)};r(()=>{var e;k(null!==(e=null==D?void 0:D.initialCollapsed)&&void 0!==e&&e)},[null==D?void 0:D.initialCollapsed]),r(()=>{const e=y.subscribeThemeChange(e=>{F(e)});return()=>{e()}},[y]);const te=a(e=>{y.setTheme(e)},[y]),ne=a(()=>{C(e=>e+1)},[]),ae=t(()=>y.getCalendars(),[y,w,e]),re=a((e,t)=>{y.setCalendarVisibility(e,t),ne()},[y,ne]),oe=a(e=>{y.setAllCalendarsVisibility(e),ne()},[y,ne]),le=a(()=>{if("modal"===(D.createCalendarMode||"inline"))return void S(!0);const e=_a[Math.floor(Math.random()*_a.length)],{colors:t,darkColors:n}=J(e),a=mt(),r={id:a,name:N("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};y.createCalendar(r),I(a),ne()},[y,D.createCalendarMode,N,ne]),ie=a(e=>{var t,n;if(!y.state.readOnly){if(P){const e=new Date;e.setMinutes(0,0,0),e.setHours(e.getHours()+1);const a=new Date(e);a.setHours(a.getHours()+1);const r={id:mt(),title:"",start:he(e),end:he(a),calendarId:(null===(t=y.getCalendars().find(e=>!1!==e.isVisible))||void 0===t?void 0:t.id)||(null===(n=y.getCalendars()[0])||void 0===n?void 0:n.id)};return z(r),void $(!0)}x?H?R(!1):(O.current=e.currentTarget,R(!0)):le()}},[x,P,H,le,y]),se=o(null),de=d||(y.getUseEventDetailDialog()?Ln:void 0),ce={app:y,config:p.config||{},customDetailPanelContent:s,customEventDetailDialog:de,switcherMode:y.state.switcherMode,calendarRef:se,meta:h},ue={app:y,calendars:ae,toggleCalendarVisibility:re,toggleAll:oe,isCollapsed:E,setCollapsed:k,renderCalendarContextMenu:D.renderCalendarContextMenu,createCalendarMode:D.createCalendarMode,renderCreateCalendarDialog:D.renderCreateCalendarDialog,editingCalendarId:M,setEditingCalendarId:I,onCreateCalendar:le},ge=ee(null==D?void 0:D.width,"240px"),me=y.getCalendarHeaderConfig(),ve={calendar:y,switcherMode:y.state.switcherMode,onAddCalendar:ie,onSearchChange:W,onSearchClick:()=>{W(""),_(!0)},searchValue:V,isSearchOpen:B,isEditable:!y.state.readOnly},ye=y.getCustomMobileEventRenderer()||Za;return u(Pa,{initialTheme:Y,onThemeChange:te,children:g("div",{className:`calendar-container relative flex flex-row h-full overflow-hidden select-none ${null!=l?l:""}`,style:Object.assign({height:800},i),children:[x&&u("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:ge},children:x?D.render?D.render(ue):u(fn,Object.assign({},ue)):null}),g("div",{className:"flex flex-col flex-1 h-full overflow-hidden relative z-10 bg-white dark:bg-gray-900 transition-all duration-250 ease-in-out border-l "+(E?"border-gray-200 dark:border-gray-700 shadow-xl":"border-transparent"),style:{marginLeft:x?E?"50px":ge:0},children:[!1===me?null:"function"==typeof me?me(ve):u(Ra,Object.assign({},ve)),g("div",{className:"flex-1 overflow-hidden relative",ref:se,children:[g("div",{className:"calendar-renderer h-full relative flex flex-row",children:[u("div",{className:"flex-1 h-full overflow-hidden",children:u(b,Object.assign({},ce))}),u(Ya,{isOpen:B,onClose:()=>{Z(!1),W(""),y.highlightEvent(null)},loading:q,results:G,keyword:V,onResultClick:Q,emptyText:null==m?void 0:m.emptyText})]}),u(Fa,{isOpen:U,onClose:()=>{_(!1),W(""),y.highlightEvent(null)},keyword:V,onSearchChange:W,results:G,loading:q,onResultClick:Q,emptyText:null==m?void 0:m.emptyText})]})]}),u(Va,{app:y,anchorRef:O,isOpen:H,onClose:()=>R(!1)}),u(ye,{isOpen:j,onClose:()=>{$(!1),z(null)},onSave:e=>{y.addEvent(e),$(!1),z(null)},draftEvent:A,app:y}),T&&(D.renderCreateCalendarDialog?D.renderCreateCalendarDialog({onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ne()}}):u($a,{onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ne()}}))]})})},Ga=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return u(qa,{locale:a.state.locale,messages:n,children:u(Xa,Object.assign({},e))})},Ka=({originalComponent:e,app:n,config:r,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i,switcherMode:s,meta:d})=>{const c=n.getPlugin("events"),g=r.enableDrag?n.getPlugin("drag"):void 0,h=n.getCurrentDate(),m=n.state.currentView,v=n.getEvents(),f=a(e=>{c?c.update(e.id,e):n.updateEvent(e.id,e)},[c,n]),y=a(e=>{c?c.delete(e):n.deleteEvent(e)},[c,n]),p=a(e=>{c?c.add(e):n.addEvent(e)},[c,n]),b=a(e=>{n.setCurrentDate(e)},[n]),D=a(e=>{n.changeView(e)},[n]),x=t(()=>{const e=r.viewConfig||{};return g&&Object.assign(e,r.dragConfig||{}),c&&Object.assign(e,r.eventsConfig||{}),e},[r,g,c]),w=t(()=>({app:n,currentDate:h,currentView:m,events:v,onEventUpdate:f,onEventDelete:y,onEventCreate:p,onDateChange:b,onViewChange:D,config:x}),[n,h,m,v,f,y,p,b,D,x]),C=t(()=>{const e={currentDate:h,events:v,setEvents:e=>{v.forEach(e=>y(e.id)),e.forEach(e=>p(e))},updateEvent:f,deleteEvent:y,addEvent:p,goToPrevious:()=>{const e=new Date(h);switch(m){case Y.DAY:e.setDate(e.getDate()-1);break;case Y.WEEK:e.setDate(e.getDate()-7);break;case Y.MONTH:e.setMonth(e.getMonth()-1)}b(e)},goToNext:()=>{const e=new Date(h);switch(m){case Y.DAY:e.setDate(e.getDate()+1);break;case Y.WEEK:e.setDate(e.getDate()+7);break;case Y.MONTH:e.setMonth(e.getMonth()+1)}b(e)},goToToday:()=>{b(new Date)},changeView:D,selectDate:b};return Object.assign(Object.assign({calendar:e},w),{eventsService:c,dragService:g,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i,switcherMode:s,meta:d})},[h,v,m,f,y,p,b,D,w,c,g,o,l,i,s,d]);return u(e,Object.assign({},C))};function Ja(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:Te(e.start),_endHour:e.allDay?0:Fe(e)})}function Qa(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:Te(e.start)}function er(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:Fe(e)}const tr=.25,nr=.5,ar=25,rr=1,or=.9;class lr{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(Ja);this.clearAllParentChildRelations(n);const a=new Map,r=n.filter(e=>!e.allDay);if(0===r.length)return a;const o=this.groupOverlappingEvents(r);for(let e=0;e<o.length;e++){const n=o[e];1===n.length?this.setSingleEventLayout(n[0],a):this.calculateComplexGroupLayout(n,a,t)}return a}static clearAllParentChildRelations(e){for(const t of e)t.parentId=void 0,t.children=[]}static setParentChildRelation(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}static eventsOverlap(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Qa(e)<er(t)&&Qa(t)<er(e))}static groupOverlappingEvents(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a],o=[a];for(n.add(a.id);o.length>0;){const t=o.shift();for(const a of e)n.has(a.id)||this.eventsOverlap(t,a)&&(r.push(a),o.push(a),n.add(a.id))}t.push(r)}return t}static setSingleEventLayout(e,t){t.set(e.id,{id:e.id,left:0,width:100-or,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=Qa(e),a=Qa(t);if(n!==a)return n-a;return er(t)-Qa(t)-(er(e)-Qa(e))}),r=this.analyzeParallelGroups(a),o=this.buildNestedStructure(r,e);this.calculateLayoutFromStructure(o,t,n)}static analyzeParallelGroups(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a];n.add(a.id);for(const t of e){if(n.has(t.id))continue;Math.abs(Qa(a)-Qa(t))<=tr&&(r.push(t),n.add(t.id))}r.sort((e,t)=>Qa(e)-Qa(t));const o={events:r,startHour:Math.min(...r.map(e=>Qa(e))),endHour:Math.max(...r.map(e=>er(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}static shouldBeParallel(e,t){if(!this.eventsOverlap(e,t))return!1;const n=Math.abs(Qa(e)-Qa(t));if(n<=tr)return!0;if(n>tr&&n<nr)return!0;return!!this.checkExtendedEventParallel(e,t)}static checkExtendedEventParallel(e,t){return!!this.eventsOverlap(e,t)&&(!!this.isExtendedEventParallel(e,t)||!!this.isExtendedEventParallel(t,e))}static isExtendedEventParallel(e,t){const n=er(e)-Qa(e);if(n<1.25)return!1;const a=Qa(e)+.4*n,r=Qa(t)>=a,o=this.eventsOverlap(e,t);return r&&o}static buildNestedStructure(e,t){const n=[],a=new Map,r=new Map;t.forEach(e=>r.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:r.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),a.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],l=o.events.map(e=>r.get(e.id));let i=!1;for(let s=n-1;s>=0&&!i;s--){const n=e[s],d={events:n.events.map(e=>r.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(this.canGroupContain(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=this.optimizeChildAssignments(l,d,t);for(const t of e){const e=a.get(t.child.id),n=a.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}i=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),this.rebalanceLoadByGroups(e,n),o}static findAlternateBranchRoot(e,t,n){const a=n.get(e.id);if(!a)return null;let r=a;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const o=r.parent;if(!o)return null;const l=o.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,s=null;for(const e of l){const t=this.calculateBranchLoad(e);t<i&&(i=t,s=e)}return s?s.event:null}static calculateBranchLoad(e){let t=0;function n(e){t++;for(const t of e.children)n(t)}for(const t of e.children)n(t);return t}static canGroupContain(e,t){const n=t.startHour-e.startHour;if(this.checkLoadBalanceParallel(e,t))return!1;if(n<nr)return!1;let a=!1;for(const n of e.events){for(const e of t.events)if(this.canEventContain(n,e)){a=!0;break}if(a)break}return a}static checkLoadBalanceParallel(e,t){for(const n of e.events)for(const e of t.events){if(!this.eventsOverlap(n,e))continue;const t=Math.abs(Qa(e)-Qa(n));if(t<=tr)return!0;if(t>tr&&t<nr)return!0}return!1}static canEventContain(e,t){const n=Qa(e)<=Qa(t)&&er(e)>=er(t),a=Qa(e)<=Qa(t)&&Qa(t)<er(e)&&this.eventsOverlap(e,t);return n||a}static optimizeChildAssignments(e,t,n){const a=[];if(1===e.length){const r=this.findBestParentInGroup(e[0],t,n);return r&&(a.push({child:e[0],parent:r}),this.setParentChildRelation(r,e[0])),a}if(1===t.events.length){const n=t.events[0];for(const t of e)this.canEventContain(n,t)&&(a.push({child:t,parent:n}),this.setParentChildRelation(n,t));return a}const r=t.events.filter(t=>e.every(e=>this.canEventContain(t,e)));if(0===r.length){for(const r of e){const o=this.findBestParentInGroup(r,t,n);if(o)a.push({child:r,parent:o}),this.setParentChildRelation(o,r);else{const t=e.find(e=>e.id!==r.id&&this.eventsOverlap(e,r));if(t){const e=this.buildTempNodeMap(n),o=this.findAlternateBranchRoot(t,Array.from(e.values()),e);o&&(a.push({child:r,parent:o}),this.setParentChildRelation(o,r))}}}return a}const o=[...e].sort((e,t)=>{const n=er(e)-Qa(e);return er(t)-Qa(t)-n});if(o.length%r.length===0){const e=o.length/r.length;for(let t=0;t<r.length;t++){const n=r[t],l=o.slice(t*e,(t+1)*e);for(const e of l)a.push({child:e,parent:n}),this.setParentChildRelation(n,e)}return a}for(let e=0;e<o.length;e++){const t=o[e],n=this.findParentWithMinLoadFromEvents(t,r,o);n&&(a.push({child:t,parent:n}),this.setParentChildRelation(n,t))}return a}static buildTempNodeMap(e){const t=new Map;for(const n of e){const e={event:n,children:[],parent:null,depth:0,isProcessed:!1};t.set(n.id,e)}for(const n of e)if(n.parentId){const e=t.get(n.id),a=t.get(n.parentId);e&&a&&(e.parent=a,e.depth=a.depth+1,a.children.push(e))}return t}static findParentWithMinLoadFromEvents(e,t,n){if(0===t.length)return null;let a=1/0,r=[];for(const e of t){const t=e.children.length;t<a?(a=t,r=[e]):t===a&&r.push(e)}const o=r.map(e=>e.children).flat();return er(e)-Qa(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?er(t)-Qa(t):0}))?r[0]:r[r.length-1]}static findBestParentInGroup(e,t,n){const a=t.events.filter(t=>this.canEventContain(t,e));if(0===a.length)return null;if(1===a.length)return a[0];const r=a.map(e=>({parent:e,load:e.children.length,hasParallelSibling:!1}));for(const t of r)for(const a of t.parent.children){const r=n.find(e=>e.id===a);if(r&&this.shouldBeParallel(e,r)){t.hasParallelSibling=!0;break}}r.sort((t,n)=>{if(t.load!==n.load)return t.load-n.load;if(t.hasParallelSibling!==n.hasParallelSibling)return t.hasParallelSibling?-1:1;if(t.load!==n.load)return t.load-n.load;return Math.abs(Qa(e)-Qa(t.parent))-Math.abs(Qa(e)-Qa(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-or;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-rr*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+rr);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,ar),t,n)})}}static calculateNodeLayoutWithVirtualParallel(e,t,n,a,r={}){let o=e.depth*this.getIndentStepPercent(r.viewType);if(e.isProcessed){const t=this.findBranchRootIndent(e,r.viewType);null!==t&&(o=t)}let l=0;const i="day"===r.viewType;1===e.depth?l=i?.5:1.5:2===e.depth?l=i?-.01:-1:e.depth>=3&&(l=i?.55:-3.5);const s=t+o+l;let d=n-(o+l);if(s+d>t+n&&(d=t+n-s),a.set(e.event.id,{id:e.event.id,left:s,width:d,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:o*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),0===e.children.length)return;const c=[...e.children].sort((e,t)=>{const n=er(e.event)-Qa(e.event);return er(t.event)-Qa(t.event)-n});if(1===c.length)this.calculateNodeLayoutWithVirtualParallel(c[0],s,d,a,r);else{this.shouldChildrenBeParallel(c.map(e=>e.event))?this.calculateParallelChildrenLayout(c,s,d,a,r):c.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,s,d,a,r)})}}static calculateParallelChildrenLayout(e,t,n,a,r={}){const o=e.length,l=e[0].depth,i=l*this.getIndentStepPercent(r.viewType);let s;const d="day"===r.viewType;s=1===l?d?.5:1.5:2===l?d?-.01:-1:d?.55:-3.5;const c=t+i+s,u=n-(i+s);if(u<=0)return void e.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,t,n,a,r)});let g;g=1===l?rr*(d?.15:.3):rr*(d?.1:.2);const h=(u-g*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(h+g);if(a.set(e.event.id,{id:e.event.id,left:n,width:h,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>{const n=er(e.event)-Qa(e.event);return er(t.event)-Qa(t.event)-n});if(1===t.length)this.calculateNodeLayoutWithVirtualParallel(t[0],n,h,a,r);else{this.shouldChildrenBeParallel(t.map(e=>e.event))?this.calculateParallelChildrenLayout(t,n,h,a,r):t.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,n,h,a,r)})}}})}static findBranchRootIndent(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;if(1===n.depth){return n.depth*this.getIndentStepPercent(t)}return null}static shouldChildrenBeParallel(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(this.shouldBeParallel(e[t],e[n]))return!0;return!1}static calculateEventImportance(e){const t=er(e)-Qa(e);return Math.max(.1,Math.min(1,t/4))}static countDescendants(e){let t=0;for(const n of e.children)t+=1+this.countDescendants(n);return t}static findTransferableLeaf(e,t){const n=[];return this.collectLeaves(e,n),n.find(e=>this.canEventContain(t.event,e.event))||n[0]}static collectLeaves(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>this.collectLeaves(e,t))}static transferNode(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children;let a=null;for(const t of n){if(this.shouldBeParallel(e.event,t.event))break;if(this.canEventContain(t.event,e.event)){a=t;break}}a?(e.parent=a,e.depth=a.depth+1,a.children.push(e),this.setParentChildRelation(a.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),this.setParentChildRelation(t.event,e.event))}static calculateParentLoads(e,t){var n,a;const r=[],o=null===(a=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===a?void 0:a.depth;if(void 0===o)return r;const l=t.filter(e=>e.depth===o);for(const e of l){const t=this.countDescendants(e);r.push({node:e,load:t})}return r.sort((e,t)=>t.load-e.load),r}static needsRebalancing(e){if(e.length<2)return!1;return e[0].load-e[e.length-1].load>=2}static rebalanceGroupLoad(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],a=e[e.length-1];if(n.load-a.load<2)break;const r=this.findTransferableLeaf(n.node,a.node);if(!r)break;this.transferNode(r,a.node),n.load--,a.load++,t++}}static rebalanceLoadByGroups(e,t){for(let n=e.length-1;n>=1;n--){const a=e[n].events.map(e=>t.find(t=>t.event.id===e.id)),r=this.calculateParentLoads(a,t);this.needsRebalancing(r)&&this.rebalanceGroupLoad(r)}}}const ir={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>je(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const sr=e=>{const{viewType:r,onEventsUpdate:l}=e,i=r===Y.MONTH,s=o({active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,resizeDirection:null,hourOffset:null,duration:0,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}),d=o({x:0,y:0}),c=t(()=>i?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1},[i]),[u,g]=n(c),h=t(()=>function(e,t){let n=null,a=0;const r=function(...r){const o=Date.now(),l=t-(o-a);l<=0||l>t?(n&&(clearTimeout(n),n=null),a=o,e.apply(this,r)):n||(n=setTimeout(()=>{a=Date.now(),n=null,e.apply(this,r)},l))};return r.cancel=()=>{n&&(clearTimeout(n),n=null),a=0},r}((e,t)=>l(e,"resize"===t),i?16:8),[i,l]),m=a(()=>{g(i?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1}),s.current={active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,duration:0,resizeDirection:null,hourOffset:null,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}},[i]);return{dragRef:s,currentDragRef:d,dragState:u,setDragState:g,resetDragState:m,throttledSetEvents:h}},dr={renderAllDayContent:({title:e,color:t})=>g("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[u(O,{className:"h-3 w-3 mr-1 text-white"}),u("div",{className:"font-medium text-xs truncate pr-1 text-white",children:e})]}),renderRegularContent:({drag:e,title:t,layout:n,formatTime:a,getLineColor:r,getDynamicPadding:o,color:l,isMobile:i})=>g(h,{children:[u("div",{className:Gt,style:{backgroundColor:r(l||"blue")}}),g("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${o(e)}`,children:[u("div",{className:"font-medium text-xs truncate pr-1 text-white",style:{lineHeight:e.endHour-e.startHour<=.25?"1.2":"normal"},children:t}),!e.allDay&&e.endHour-e.startHour>.5&&g("div",{className:"text-xs truncate time-display text-white opacity-90",children:[a(e.startHour)," - ",a(e.endHour)]})]}),i&&g(h,{children:[u("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:r(l||"blue")}}),u("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:r(l||"blue")}})]})]}),renderDefaultContent:({drag:e,title:t,allDay:n})=>n?g("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0",children:[u("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 002 2z"})}),u("div",{className:"font-medium text-xs truncate pr-1",style:{lineHeight:1.2},children:t})]}):g(h,{children:[u("div",{className:"absolute left-0.5 top-1 bottom-1 w-0.5 rounded-full bg-primary"}),u("div",{className:"h-full flex flex-col overflow-hidden pl-3 p-1",children:u("div",{className:"font-medium text-xs truncate pr-1 text-primary",children:t})})]})},cr=({drag:e,color:t,title:n,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,renderer:s=dr,isMobile:d})=>{const{t:c}=Nt(),g=n||c(r?"newAllDayEvent":"newEvent");return u("div",{className:"drag-indicator-content",children:t?r?s.renderAllDayContent({drag:e,color:t,title:g,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d}):s.renderRegularContent({drag:e,color:t,title:g,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d}):s.renderDefaultContent({drag:e,color:t,title:g,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d})})},ur=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:r})=>{const{t:o}=Nt(),l=(()=>{if(t)return{title:o("newEvent"),icon:u(P,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&r){const t=Ce(a,r)+1;return{title:e.title.replace(/ \(\d+天\)$/,""),showDateRange:!0,duration:t}}return{title:e.title,showDateRange:!1}})();return g("div",{className:"flex items-center space-x-2 text-white text-xs font-medium rounded-sm",children:[u("div",{className:"shrink-0",children:l.icon}),u("div",{className:"flex-1 min-w-0",children:u("div",{className:"truncate font-medium",children:l.title})})]})},gr=e=>{let t,n;return"touches"in e&&e.touches.length>0?(t=e.touches[0].clientX,n=e.touches[0].clientY):"changedTouches"in e&&e.changedTouches.length>0?(t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY):(t=e.clientX,n=e.clientY),{clientX:t,clientY:n}},hr=n=>{const r=t(()=>Object.assign(Object.assign(Object.assign({},ir),n),{getLineColor:e=>{var t;return n.getLineColor?n.getLineColor(e):je(e,null===(t=n.app)||void 0===t?void 0:t.getCalendarRegistry())}}),[n]),{viewType:l}=r,i=l===Y.MONTH||l===Y.YEAR,s=(e=>{const{calendarRef:n,allDayRowRef:r,viewType:o,HOUR_HEIGHT:l=72,FIRST_HOUR:i=0,LAST_HOUR:s=24,TIME_COLUMN_WIDTH:d=80,isMobile:c}=e,u=o===Y.MONTH,g=o===Y.WEEK,h=a(e=>{if(u||!n.current)return i;const t=n.current.querySelector(".calendar-content");if(!t)return i;const a=t.getBoundingClientRect(),r=t.scrollTop,o=window.getComputedStyle(t),d=parseInt(o.paddingTop,10)||0,c=(e-a.top+r-d)/l+i;return Math.max(i,Math.min(s,c))},[n,i,l,s,u]),m=a(e=>{if(u||!n.current)return 0;const t=n.current.querySelector(".calendar-content");if(!t)return 0;const a=t.getBoundingClientRect(),r=t.scrollLeft,o=a.width;if(g){const t=(c?1.75*o:o)/7,n=e-a.left+r,l=Math.floor(n/t);return Math.max(0,Math.min(6,l))}return 0},[n,u,g,c]),v=a(e=>{if(u||!n.current)return;const t=n.current.querySelector(".calendar-content");if(!t)return;const a=t.getBoundingClientRect();e<a.top?t.scrollTop+=e-a.top:e+40>a.bottom&&(t.scrollTop+=e+40-a.bottom)},[n,u]),f=a(e=>!(u||!(null==r?void 0:r.current))&&e<=r.current.getBoundingClientRect().bottom,[r,u]),y=t(()=>864e5,[]);return{pixelYToHour:h,getColumnDayIndex:m,checkIfInAllDayArea:f,handleDirectScroll:v,daysDifference:a((e,t)=>Ce(e,t),[]),addDaysToDate:a((e,t)=>Ee(e,t),[]),getTargetDateFromPosition:a((e,t)=>{if(o!==Y.MONTH&&o!==Y.YEAR||!n.current)return null;const a=document.elementFromPoint(e,t);if(!a)return null;let r=a,l=0;for(;r&&!r.hasAttribute("data-date")&&l<10;)r=r.parentElement,l++;if(r&&r.hasAttribute("data-date")){const e=r.getAttribute("data-date");if(e)return new Date(e+"T00:00:00")}return null},[n,o]),ONE_DAY_MS:y}})(r),d=sr(r),c=(t=>{const{t:n,locale:r}=Nt(),{calendarRef:l,allDayRowRef:i,viewType:s,getLineColor:d,getDynamicPadding:c,renderer:u,HOUR_HEIGHT:g=72,FIRST_HOUR:h=0,TIME_COLUMN_WIDTH:m=80,ALL_DAY_HEIGHT:v=60,app:f,isMobile:y}=t,p=s===Y.MONTH||s===Y.YEAR,b=s===Y.DAY,D=o(null),x=o(null),w=o(null),C=a(()=>{x.current&&(x.current.unmount(),x.current=null),D.current&&(D.current.remove(),D.current=null),w.current=null},[]),E=a((t,a,o,s,E)=>{var k,N,T,S,M,I,H,R,O;C();const P=document.createElement("div");if(P.style.position=p?"fixed":"absolute",P.style.pointerEvents="none",P.style.zIndex="1000",p){let l,i;if(P.style.opacity="0.9",E){const e=E.getBoundingClientRect(),n=null!==(N=null!==(k=t.currentSegmentDays)&&void 0!==k?k:t.eventDurationDays)&&void 0!==N?N:1;l=e.width/n,i=e.height,P.className=`rounded-sm shadow-sm ${E.className}`}else l=120,i=22,P.className="rounded text-xs px-2 py-1";P.style.width=`${l}px`,P.style.height=`${i}px`,P.style.left=t.startX-l/2+"px",P.style.top=t.startY-i/2+"px",document.body.appendChild(P),x.current=z(P);const s=he(new Date),d=t.originalEvent||{id:String(Date.now()),color:a||"blue",title:o||n("newEvent"),start:s,end:s,allDay:!1,day:0};x.current.render(e.createElement(Ua,{locale:r},e.createElement(ur,{event:d,isCreating:"create"===t.mode,targetDate:t.targetDate||null,startDate:t.originalStartDate||null,endDate:t.originalEndDate||null})))}else{if(E){const e=E.getBoundingClientRect();let n;if(n=t.allDay?null===(T=null==i?void 0:i.current)||void 0===T?void 0:T.getBoundingClientRect():null===(M=null===(S=l.current)||void 0===S?void 0:S.querySelector(".calendar-content"))||void 0===M?void 0:M.getBoundingClientRect(),n){if(t.allDay&&b)P.style.left=`${m}px`,P.style.top=E.offsetTop-2+"px",P.style.width=`calc(100% - ${m}px - 2px)`,P.style.height=`${e.height}px`;else if(t.allDay&&!b){const n=`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=`calc(${n} * ${t.dayIndex})`,P.style.top=E.offsetTop-2+"px",P.style.width=`calc(${n} - 2px)`,P.style.height=`${e.height}px`}else{const a=(t.startHour-h)*g,r=null===(I=l.current)||void 0===I?void 0:I.querySelector(".calendar-content"),o=(null==r?void 0:r.scrollLeft)||0;P.style.left=`${e.left-n.left+o}px`,P.style.top=`${a+3}px`,P.style.width=`${e.width}px`,P.style.height=`${e.height}px`}P.className=E.className,P.style.opacity="0.8",P.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}}else if(t.allDay)if(P.style.top="2px",P.style.height=v-4+"px",P.style.marginBottom="3px",P.className="rounded-xl shadow-sm",b)P.style.left=`${m}px`,P.style.width=`calc(100% - ${m}px - 2px)`;else{const e=`calc(${y?"175%":"100%"} / 7)`;P.style.left=`calc(${e} * ${t.dayIndex})`,P.style.width=`calc(${e} - 2px)`}else{const e=(t.startHour-h)*g,n=(t.endHour-t.startHour)*g;if(P.style.top=`${e+3}px`,P.style.height=n-4+"px",P.style.color="#fff",P.className="rounded-sm shadow-sm",s){if(b)P.style.left=`${m}px`,P.style.width=`calc(((100% - ${m}px) * ${s.width/100}) - 3px)`;else{const e=`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=`calc((${e} * ${t.dayIndex}) + (${e} * ${s.left/100}))`,P.style.width=`calc((${e} * ${(s.width-1)/100}))`}P.style.zIndex=String(1e3)}else{const e=b?`calc(100% - ${m}px)`:`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=b?`${m}px`:`calc(${e} * ${t.dayIndex})`,P.style.width=`calc(${e} - 3px)`}}t.allDay?null===(H=null==i?void 0:i.current)||void 0===H||H.appendChild(P):null===(O=null===(R=l.current)||void 0===R?void 0:R.querySelector(".calendar-content"))||void 0===O||O.appendChild(P),w.current={drag:t,color:a,title:o,layout:s},x.current=z(P),x.current.render(e.createElement(Ua,{locale:r},e.createElement(cr,{drag:t,color:a,title:o,layout:s,allDay:t.allDay,formatTime:Ae,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}a?(P.style.backgroundColor=Le(a,null==f?void 0:f.getCalendarRegistry()),P.style.color=Pe(a,null==f?void 0:f.getCalendarRegistry())):P.className+=" bg-primary/10 text-primary border border-dashed border-primary/50",D.current=P},[C,p,b,i,l,Ae,d,c,u,m,v,h,g]),k=a((...t)=>{var n,a;const o=D.current;if(o)if(p){const[e,n]=t,a=parseFloat(o.style.width)||120,r=parseFloat(o.style.height)||22;requestAnimationFrame(()=>{o.style.left=e-a/2+"px",o.style.top=n-r/2+"px",o.style.transition="none"})}else{const[s,f,p,D=!1,C]=t;if(D&&o.parentElement!==(null==i?void 0:i.current))null===(n=null==i?void 0:i.current)||void 0===n||n.appendChild(o);else if(!D){const e=null===(a=l.current)||void 0===a?void 0:a.querySelector(".calendar-content");o.parentElement!==e&&(null==e||e.appendChild(o))}if(D){if(b)o.style.left=`${m}px`,o.style.width=`calc(100% - ${m}px - 2px)`;else{const e=`calc(${y&&!b?"175%":"100%"} / 7)`;o.style.left=`calc(${e} * ${s})`,o.style.width=`calc(${e} - 2px)`,o.style.top="2px"}o.style.height=v-4+"px",o.style.marginBottom="3px",o.className=o.className.replace("rounded-sm","rounded-xl")}else{const e=(f-h)*g,t=(p-f)*g;o.style.top=`${e+3}px`,o.style.height=t-4+"px",o.style.marginBottom="0",o.className=o.className.replace("rounded-xl","rounded-sm");const n=y&&!b?"175%":"100%";if(C){if(b)o.style.left=`${m}px`,o.style.width=`calc(((100% - ${m}px) * ${C.width/100}) - 3px)`;else{const e=`calc(${n} / 7)`;o.style.left=`calc((${e} * ${s}) + (${e} * ${C.left/100}))`,o.style.width=`calc((${e} * ${(C.width-1)/100}))`}o.style.zIndex=String(C.zIndex+10)}else{const e=b?`calc(100% - ${m}px)`:`calc(${n} / 7)`;o.style.left=b?`${m}px`:`calc(${e} * ${s})`,o.style.width=`calc(${e} - 3px)`}}if(o.style.cursor="grabbing",x.current&&w.current){const t=Object.assign(Object.assign({},w.current.drag),{dayIndex:s,startHour:f,endHour:p,allDay:D});w.current.drag=t,x.current.render(e.createElement(Ua,{locale:r},e.createElement(cr,{drag:t,color:w.current.color,title:w.current.title,layout:C||w.current.layout,allDay:D,formatTime:Ae,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}}},[p,i,Ae,l,b,v,m,h,g,d,c,u]);return{dragIndicatorRef:D,reactRootRef:x,removeDragIndicator:C,createDragIndicator:E,updateDragIndicator:k}})(r),u=(e=>{const{t:t}=Nt(),{options:n,common:r,state:o,manager:l}=e,{viewType:i,onEventsUpdate:s,onEventCreate:d,onEventEdit:c,calculateNewEventLayout:u,calculateDragLayout:g,currentWeekStart:h,events:m,FIRST_HOUR:v=0,LAST_HOUR:f=24,MIN_DURATION:y=.25,app:p}=n,{dragRef:b,currentDragRef:D,setDragState:x,resetDragState:w,throttledSetEvents:C}=o,{removeDragIndicator:E,createDragIndicator:k,updateDragIndicator:N}=l,{pixelYToHour:T,getColumnDayIndex:S,checkIfInAllDayArea:M,handleDirectScroll:I,daysDifference:H,addDaysToDate:R,getTargetDateFromPosition:O}=r,P=i===Y.MONTH||i===Y.YEAR,L=i===Y.DAY,j=864e5,$=(e,t,n=!1)=>{const a=new Date(e);a.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);let o=Math.floor((r.getTime()-a.getTime())/j);if(o<=0)return 0;if(!n&&1===o){const n=0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds(),a=t.getTime()-e.getTime();if(n&&a<j)return 0}return o},A=a(e=>{var t,n;const a=null==p?void 0:p.getReadOnlyConfig(),r=!1!==(null==a?void 0:a.draggable),o=!(null==p?void 0:p.state.readOnly),l=b.current;if(!l)return;if("move"===l.mode&&!r)return;if(("resize"===l.mode||"create"===l.mode)&&!o)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:i,clientY:s}=gr(e);if(!l||!l.active)return;if("move"===l.mode&&!l.indicatorVisible){if(Math.hypot(i-l.startX,s-l.startY)<3)return;k(l,l.calendarId,l.title,null,l.sourceElement||void 0),l.indicatorVisible=!0}"resize"===l.mode?l.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing";const d=M(s),c=L?l.dayIndex:S(i);if(d){if(!l.allDay){l.allDay=!0,l.startHour=0,l.endHour=0,l.eventDate=h?tt(h,c):new Date,E(),l.indicatorVisible=!1;const e=null==m?void 0:m.find(e=>e.id===l.eventId);k(l,null==e?void 0:e.calendarId,null==e?void 0:e.title),l.sourceElement=null,l.indicatorVisible=!0}l.dayIndex=c,x(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:0,endHour:0,allDay:!0})),N(c,0,0,!0)}else{I(s);const e=T(s);if(null!==(t=l.startDragDayIndex)&&void 0!==t||l.originalDay,l.dayIndex,l.allDay){l.allDay=!1,l.startHour=Ye(e),l.endHour=l.startHour+1,l.duration=1,l.hourOffset=0,l.eventDate=h?tt(h,c):new Date,E(),l.indicatorVisible=!1;const t=null==m?void 0:m.find(e=>e.id===l.eventId);k(l,null==t?void 0:t.calendarId,null==t?void 0:t.title),l.sourceElement=null,l.indicatorVisible=!0}else{let t=Ye(e+(null!==(n=l.hourOffset)&&void 0!==n?n:0));t=Math.max(v,Math.min(f-l.duration,t)),l.startHour=t,l.endHour=t+l.duration}l.dayIndex=c,l.eventDate=h?tt(h,c):new Date,x(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:Ye(l.startHour),endHour:Ye(l.endHour),allDay:!1}));let a=null;if("move"===l.mode&&l.eventId&&g){const e=null==m?void 0:m.find(e=>e.id===l.eventId);e&&(a=g(e,c,Ye(l.startHour),Ye(l.endHour)))}N(c,Ye(l.startHour),Ye(l.endHour),!1,a)}},[g,M,k,h,m,v,S,I,f,L,T,E,N,b,x]),z=a(()=>{const e=b.current;if(!e||!e.active)return;const t=null==p?void 0:p.getReadOnlyConfig(),n=!1!==(null==t?void 0:t.draggable),a=!(null==p?void 0:p.state.readOnly);if("move"===e.mode&&!n)return;if(("resize"===e.mode||"create"===e.mode)&&!a)return;if(document.body.style.cursor="default","move"===e.mode&&!e.indicatorVisible)return document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",A,{capture:!0}),document.removeEventListener("touchend",z),void w();if("move"!==e.mode||!e.eventId)return;let r=e.startHour,o=e.endHour;e.allDay||(r=Ye(e.startHour),o=Ye(e.endHour),o-r<y&&(o=r+y)),null==s||s(t=>t.map(t=>{var n,a;if(t.id!==e.eventId)return t;h?tt(h,e.dayIndex):fe(t.start);const l=null!==(n=e.startDragDayIndex)&&void 0!==n?n:e.originalDay,i=e.dayIndex-l;let s,d;if(e.allDay){const n=e.originalStartDate?new Date(e.originalStartDate):fe(t.start);n.setHours(0,0,0,0);const a=new Date(n);a.setDate(a.getDate()+i);const r=new Date(a);e.eventDurationDays&&e.eventDurationDays>0&&r.setDate(r.getDate()+e.eventDurationDays),s=me(a),d=me(Ie(r))}else{const n=fe(t.start),l=fe(t.end),c=t.allDay;if($(n,l,null!==(a=t.allDay)&&void 0!==a&&a)>0&&!c){const e=new Date(n);e.setDate(e.getDate()+i);const t=new Date(l);t.setDate(t.getDate()+i),s=he(e),d=he(t)}else{const t=h?tt(h,e.dayIndex):new Date,n=Se(t,r),a=Se(t,o);s=he(n),d=he(a)}}const c=e.originalDay+i;return Object.assign(Object.assign({},t),{day:c,start:s,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",A,{capture:!0}),document.removeEventListener("touchend",z),E(),w()},[A,E,w,s,y,h,b]),F=a(e=>{var a,r,o,l,i,s,d,c,y,D;const x=b.current;if(!x||!x.active)return;const w=null==p?void 0:p.getReadOnlyConfig(),E=!1!==(null==w?void 0:w.draggable),M=!(null==p?void 0:p.state.readOnly);if("move"===x.mode&&!E)return;if(("resize"===x.mode||"create"===x.mode)&&!M)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:j,clientY:A}=gr(e);if(x&&x.active)if("resize"===x.mode?P||x.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",P){if("resize"!==x.mode){if("move"===x.mode){const e=Math.hypot(j-x.startX,A-x.startY);!x.indicatorVisible&&e>=3&&(k(x,null===(a=x.originalEvent)||void 0===a?void 0:a.calendarId,null===(r=x.originalEvent)||void 0===r?void 0:r.title,null,x.sourceElement||void 0),x.indicatorVisible=!0)}x.indicatorVisible&&N(j,A)}const e=O(j,A);if(!e)return;if("resize"===x.mode&&x.originalEvent&&x.resizeDirection){const t=fe(x.originalEvent.start);let n,a;const r=(e,t)=>{var n,a;e&&((null===(n=x.originalEvent)||void 0===n?void 0:n.allDay)?e.setHours(0,0,0,0):t&&e.setHours(t.hour,t.minute,null!==(a=t.second)&&void 0!==a?a:0,0))},o=x.originalStartTime,l=x.originalEndTime;if("left"===x.resizeDirection){n=new Date(e),r(n,o);const i=fe(x.originalEvent.end)||t;a=new Date(i),r(a,l),n>a&&(n=a)}else{const i=fe(x.originalEvent.start)||t;n=new Date(i),r(n,o),a=new Date(e),r(a,l),a<n&&(a=n)}x.originalStartDate=new Date(n.getTime()),x.originalEndDate=new Date(a.getTime());const i=x.originalEvent.allDay?me(n):he(n),s=x.originalEvent.allDay?me(a):he(a);C(e=>e.map(e=>e.id===x.eventId?Object.assign(Object.assign({},e),{start:i,end:s,title:e.title}):e),x.mode)}else if("move"===x.mode)if(x.originalStartDate&&x.originalEndDate){const t=new Date(x.originalStartDate);t.setHours(0,0,0,0);const n=H(t,e),a=R(x.originalStartDate,n),r=R(x.originalEndDate,n);(null===(o=x.originalStartDate)||void 0===o?void 0:o.getTime())!==a.getTime()&&(x.originalStartDate=new Date(a.getTime()),x.originalEndDate=new Date(r.getTime()),x.targetDate=a)}else(null===(l=x.targetDate)||void 0===l?void 0:l.getTime())!==e.getTime()&&(x.targetDate=e)}else{I(A),x.lastClientY=A;const e=T(A);if("create"===x.mode&&x.allDay){const e=Math.hypot(j-x.startX,A-x.startY);if(!x.indicatorVisible){if(e<3)return;k(x,"blue",t("newAllDayEvent")),x.indicatorVisible=!0}const n=L?x.dayIndex:S(j);return x.dayIndex=n,void N(n,0,0,!0)}if("resize"===x.mode)if(x.allDay){const e=L?x.dayIndex:S(j);let t=x.originalStartDate||new Date,n=x.originalEndDate||new Date;"left"===x.resizeDirection?(t=h?tt(h,e):new Date,t>n&&(t=n)):"right"===x.resizeDirection&&(n=h?tt(h,e):new Date,n<t&&(n=t)),x.originalStartDate=new Date(t.getTime()),x.originalEndDate=new Date(n.getTime());const a=me(t),r=me(n);C(e=>e.map(e=>e.id!==x.eventId?e:Object.assign(Object.assign({},e),{start:a,end:r,allDay:!0})),x.mode)}else{let t=x.startHour,n=x.endHour;const a=null==m?void 0:m.find(e=>e.id===x.eventId);let r=x.dayIndex;if(a){const e=fe(a.start),t=fe(a.end),n=$(e,t,null!==(i=a.allDay)&&void 0!==i&&i);r=(null!==(s=a.day)&&void 0!==s?s:0)+n}let o=r,l=x.originalDay;if("top"===x.resizeDirection){const a=L?x.dayIndex:S(j),o=e+(null!==(d=null==x?void 0:x.hourOffset)&&void 0!==d?d:0);a<r?(l=a,t=Math.max(v,Math.min(f,o))):(l=r,o>x.originalEndHour?(t=x.originalEndHour,n=o,x.hourOffset=n-e):(t=Math.max(v,o),x.originalEndHour-t<$e&&(t=x.originalEndHour-$e)))}else if("bottom"===x.resizeDirection){const a=L?x.dayIndex:S(j),r=e+(null!==(c=null==x?void 0:x.hourOffset)&&void 0!==c?c:0);a!==x.dayIndex?(o=a,n=Math.max(v,Math.min(f,r))):r<x.originalStartHour?(n=x.originalStartHour,t=r,x.hourOffset=t-e):(n=Math.min(f,r),n-x.startHour<$e&&(n=x.startHour+$e))}else if("right"===x.resizeDirection){const e=L?x.dayIndex:S(j);o=Math.max(x.dayIndex,e)}o===l&&([t,n]=[Math.max(v,Math.min(t,n)),Math.min(f,Math.max(t,n))]);const[u,g]=[Ye(t),Ye(n)];x.startHour=t,x.endHour=n,x.dayIndex=l,C(e=>e.map(e=>{if(e.id!==x.eventId)return e;const t=fe(e.start),n=Se(h?tt(h,l):t,u),a=h?tt(h,o):t,r=Se(a,g),i=he(n),s=he(r);return Object.assign(Object.assign({},e),{start:i,end:s,day:l})}),x.mode),N(x.dayIndex,u,g,!1)}else if("create"===x.mode){if(n.isMobile){const t=Ye(e+(null!==(y=x.hourOffset)&&void 0!==y?y:0)),n=Math.max(v,Math.min(f-(x.duration||1),t));x.startHour=n,x.endHour=n+(x.duration||1)}else{const t=Ye(e),[n,a]=A<x.startY?[t,Math.max(t+$e,x.endHour)]:[x.startHour,Math.max(x.startHour+$e,t)];x.startHour=n,x.endHour=a}const t=null==u?void 0:u(x.dayIndex,x.startHour,x.endHour);N(x.dayIndex,x.startHour,x.endHour,!1,t)}else if("move"===x.mode){const t=L?x.dayIndex:S(j);let n=Ye(e+(null!==(D=x.hourOffset)&&void 0!==D?D:0));n=Math.max(v,Math.min(f-x.duration,n));const a=n+x.duration;x.dayIndex=t,x.startHour=n,x.endHour=a;let r=null;if(x.eventId&&g){const e=null==m?void 0:m.find(e=>e.id===x.eventId);e&&(r=g(e,t,Ye(n),Ye(a)))}N(t,Ye(n),Ye(a),!1,r)}}},[P,L,N,O,C,H,R,v,f,u,S,T,I,g,m,b,k]),V=a(e=>{var n,a,r;const o=b.current;if(!o||!o.active)return;const l=null==p?void 0:p.getReadOnlyConfig(),i=!1!==(null==l?void 0:l.draggable),c=!(null==p?void 0:p.state.readOnly);if("move"===o.mode&&!i)return;if(("resize"===o.mode||"create"===o.mode)&&!c)return;if(document.body.style.cursor="default",("move"===o.mode||"create"===o.mode)&&!o.indicatorVisible)return document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),void w();const{clientX:u,clientY:g}=gr(e);if(o&&o.active){if(P){if("resize"===o.mode&&o.eventId&&o.originalStartDate&&o.originalEndDate){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(n=o.originalEvent)||void 0===n?void 0:n.allDay)||!1,t=e?me(o.originalStartDate):he(o.originalStartDate),a=e?me(o.originalEndDate):he(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:a,title:e.title}):e))}else if("move"===o.mode)if(o.eventId&&o.originalStartDate&&o.originalEndDate){const e=(null===(a=o.originalEvent)||void 0===a?void 0:a.start)?fe(o.originalEvent.start):null;if(e&&e.getTime()!==o.originalStartDate.getTime()){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(r=o.originalEvent)||void 0===r?void 0:r.allDay)||!1,t=e?me(o.originalStartDate):he(o.originalStartDate),n=e?me(o.originalEndDate):he(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:n,title:e.title}):e))}}else{const e=O(u,g)||o.targetDate;o.eventId&&e&&(x(t=>"targetDate"in t?Object.assign(Object.assign({},t),{targetDate:e}):t),C(t=>t.map(t=>{if(t.id!==o.eventId)return t;const n=fe(t.start),a=fe(t.end),r=new Date(e);r.setHours(n.getHours(),n.getMinutes(),0,0);const l=new Date(e);l.setHours(a.getHours(),a.getMinutes(),0,0);const i=t.allDay?me(r):he(r),s=t.allDay?me(l):he(l);return Object.assign(Object.assign({},t),{start:i,end:s})})))}}else{let[e,n]=[Ye(o.startHour),Ye(o.endHour)];if(n-e<y&&("top"===o.resizeDirection?e=n-y:n=e+y),"create"===o.mode){const a=h?tt(h,o.dayIndex):new Date;x(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t);const r=Se(a,e),l=Se(a,n),i=o.allDay,s=i?me(r):he(r),c=i?me(l):he(l);null==d||d({id:String(Date.now()),title:t(i?"newAllDayEvent":"newEvent"),day:o.dayIndex,start:s,end:c,calendarId:"blue",allDay:i})}else"move"!==o.mode&&"resize"!==o.mode||(x(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t),"move"===o.mode&&(null==s||s(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{day:o.dayIndex}):e))))}document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[P,F,E,w,O,C,y,h,d,s,b,x]),W=a((e,...a)=>{var r;if(null==p?void 0:p.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(r=b.current)||void 0===r?void 0:r.active)return;const{clientX:o,clientY:l}=gr(e);if(P){const[e]=a,n=new Date(e);n.setHours(9,0,0,0);const r=new Date(e);r.setHours(10,0,0,0);const o=he(n),l=he(r),i={id:String(Date.now()),title:t("newEvent"),start:o,end:l,day:e.getDay(),calendarId:"blue",allDay:!1};null==d||d(i),c&&setTimeout(()=>{c(i)},50)}else{const[e,r]=a,i=b.current;if(!i)return;const s=1,d=!!n.isMobile?-s/2:0,c=Ye(r+d);Object.assign(i,{active:!0,mode:"create",eventId:null,startX:o,startY:l,dayIndex:e,startHour:c,endHour:c+s,allDay:!1,eventDate:h?tt(h,e):new Date,duration:s,hourOffset:d}),x({active:!0,mode:"create",eventId:null,dayIndex:e,startHour:i.startHour,endHour:i.endHour,allDay:!1});const g=null==u?void 0:u(e,i.startHour,i.endHour);k(i,"blue",t("newEvent"),g),i.sourceElement=null,i.indicatorVisible=!0,document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}},[P,d,c,h,u,k,F,V,b,x]),B=a((e,t)=>{var n,a,r,o;if(e.cancelable&&("touches"in e||"changedTouches"in e)&&e.preventDefault(),e.stopPropagation(),null===(n=b.current)||void 0===n?void 0:n.active)return;const{clientX:l,clientY:i}=gr(e),s=b.current;if(!s)return;const d=e.currentTarget;if(P){D.current={x:l-d.getBoundingClientRect().left,y:i-d.getBoundingClientRect().top};const e=fe(t.start),n=fe(t.end);let a=1;if(t.allDay&&t.start&&t.end){const t=new Date(e);t.setHours(0,0,0,0);const r=new Date(n);r.setHours(0,0,0,0),a=Math.floor((r.getTime()-t.getTime())/864e5+1),a=Math.max(1,a)}const r=d.getAttribute("data-segment-days"),o=r?parseInt(r,10):a;s.active=!0,s.mode="move",s.eventId=t.id,s.startX=l,s.startY=i,s.targetDate=e,s.originalDate=e,s.originalEvent=Object.assign({},t),s.lastUpdateTime=Date.now(),s.originalStartDate=e,s.originalEndDate=n,s.eventDurationDays=a,s.currentSegmentDays=o,x({active:!0,mode:"move",eventId:t.id,targetDate:e,startDate:e,endDate:n}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}else{const e=T(i),n=t._segmentInfo,c=!!n,u=c?n.dayIndex:null!==(a=t.day)&&void 0!==a?a:0,g=c?n.startHour:Te(t.start);let h=0;if(t.allDay&&t.start&&t.end){const e=fe(t.start);e.setHours(0,0,0,0);const n=fe(t.end);n.setHours(0,0,0,0),h=Math.floor((n.getTime()-e.getTime())/864e5)}const m=fe(t.start);if(Object.assign(s,{active:!0,mode:"move",eventId:t.id,startX:l,startY:i,dayIndex:u,startHour:g,endHour:c?n.endHour:Fe(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:Te(t.start),originalEndHour:Fe(t),allDay:t.allDay||!1,eventDate:m,eventDurationDays:h,startDragDayIndex:u,calendarId:t.calendarId,title:t.title}),!t.allDay){s.hourOffset=g-e;const n=fe(t.start),a=fe(t.end).getTime()-n.getTime();s.duration=a/36e5}x({active:!0,mode:"move",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:Te(t.start),endHour:Fe(t),allDay:t.allDay||!1}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",A),document.addEventListener("mouseup",z),document.addEventListener("touchmove",A,{capture:!0,passive:!1}),document.addEventListener("touchend",z)}},[P,k,V,F,A,z,T,b,D,x]),Z=a((e,t,n)=>{var a,r,o,l,i,s;if(null==p?void 0:p.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(a=b.current)||void 0===a?void 0:a.active)return;const{clientX:d,clientY:c}=gr(e),u=b.current;if(u){if(P){const e=fe(t.start),a=fe(t.start),r=fe(t.end),o={hour:a.getHours(),minute:a.getMinutes(),second:a.getSeconds()},l={hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds()};u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.targetDate="left"===n?a:r,u.originalDate=e,u.originalEvent=Object.assign({},t),u.lastUpdateTime=Date.now(),u.resizeDirection=n,u.originalStartDate=a,u.originalEndDate=r,u.originalStartTime=o,u.originalEndTime=l,x({active:!0,mode:"resize",eventId:t.id,targetDate:"left"===n?a:r,startDate:a,endDate:r})}else if(t.allDay){const e=fe(t.start),a=fe(t.end);u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.allDay=!0,u.resizeDirection=n,u.originalStartDate=e,u.originalEndDate=a,u.originalEvent=Object.assign({},t),u.dayIndex=null!==(r=t.day)&&void 0!==r?r:0,x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:0,endHour:0,allDay:!0})}else{const e=T(c);Object.assign(u,{active:!0,mode:"resize",eventId:t.id,startX:d,startY:c,dayIndex:null!==(l=t.day)&&void 0!==l?l:0,startHour:Te(t.start),endHour:Fe(t),originalDay:null!==(i=t.day)&&void 0!==i?i:0,originalStartHour:Te(t.start),originalEndHour:Fe(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?Te(t.start)-e:Fe(t)-e,allDay:!1}),x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(s=t.day)&&void 0!==s?s:0,startHour:Te(t.start),endHour:Fe(t),allDay:!1})}document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}},[P,F,V,T,b,x]);return{handleDragMove:F,handleDragEnd:V,handleCreateStart:W,handleMoveStart:B,handleResizeStart:Z,handleUniversalDragMove:A,handleUniversalDragEnd:z}})({options:r,common:s,state:d,manager:c}),g=(e=>{const{t:t}=Nt(),{options:n,common:r,state:o,manager:l,handleDragMove:i,handleDragEnd:s}=e,{viewType:d,currentWeekStart:c,app:u}=n,{dragRef:g,setDragState:h}=o,{createDragIndicator:m}=l,{pixelYToHour:v,getColumnDayIndex:f}=r,y=d===Y.MONTH;return{handleCreateAllDayEvent:a((e,a)=>{var r;if(null==u?void 0:u.state.readOnly)return;if(y)return;if(e.preventDefault(),e.stopPropagation(),"dblclick"===e.type){const e=c?tt(c,a):new Date,r=me(e),o=me(e),l={id:String(Date.now()),title:t("newAllDayEvent"),day:a,start:r,end:o,calendarId:"blue",allDay:!0};return void n.onEventCreate(l)}if(null===(r=g.current)||void 0===r?void 0:r.active)return;const o=g.current;o&&(Object.assign(o,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:a,allDay:!0,eventDate:c?tt(c,a):new Date}),h({active:!0,mode:"create",eventId:null,dayIndex:a,startHour:0,endHour:0,allDay:!0}),o.indicatorVisible=!1,o.sourceElement=null,document.addEventListener("mousemove",i),document.addEventListener("mouseup",s))},[y,c,s,i,g,h,null==u?void 0:u.state.locale,n]),pixelYToHour:v,getColumnDayIndex:f}})({options:r,common:s,state:d,manager:c,handleDragMove:u.handleDragMove,handleDragEnd:u.handleDragEnd}),h=(e=>{const{common:t}=e,{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}=t;return{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}})({common:s});return Object.assign({createDragIndicator:c.createDragIndicator,updateDragIndicator:c.updateDragIndicator,removeDragIndicator:c.removeDragIndicator,handleCreateStart:u.handleCreateStart,handleMoveStart:u.handleMoveStart,handleResizeStart:u.handleResizeStart,dragState:d.dragState,isDragging:d.dragState.active},i?{daysDifference:h.daysDifference,addDaysToDate:h.addDaysToDate,getTargetDateFromPosition:h.getTargetDateFromPosition}:{handleCreateAllDayEvent:g.handleCreateAllDayEvent,pixelYToHour:g.pixelYToHour,getColumnDayIndex:g.getColumnDayIndex})};function mr(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[Y.DAY,Y.WEEK,Y.MONTH,Y.YEAR]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{Q.log("Drag plugin installed - providing drag capabilities")},api:n}}function vr(e,t){const n=e.getPlugin("drag"),a=hr(Object.assign(Object.assign({},t),{app:e}));if(!n)return Q.warn("Drag plugin is not installed. Drag functionality will be disabled. Add createDragPlugin() to your plugins array to enable dragging."),{handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:()=>{},handleCreateAllDayEvent:void 0,dragState:a.dragState,isDragging:!1};const r=n.getConfig(),o=n.isViewSupported(t.viewType),l=!1!==e.getReadOnlyConfig().draggable,i=!e.state.readOnly;return o||console.info(`Drag functionality is not supported for ${t.viewType} view.`),{handleMoveStart:o&&r.enableDrag&&l?a.handleMoveStart:()=>{},handleCreateStart:o&&r.enableCreate&&i?a.handleCreateStart:()=>{},handleResizeStart:o&&r.enableResize&&i?a.handleResizeStart:void 0,handleCreateAllDayEvent:o&&r.enableAllDayCreate&&i?a.handleCreateAllDayEvent:()=>{},dragState:a.dragState,isDragging:!(!o||!l)&&a.isDragging}}function fr(e){const{app:t,onEventCreated:n}=e,{t:r}=Nt(),o=a(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:a((e,a,o,l)=>{e.preventDefault();const i=e.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const e=JSON.parse(i);let s,c,u=!1;l?(s=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:0,minute:0}),c=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:23,minute:59,second:59}),u=!0):void 0!==o?(s=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:o,minute:0}),c=s.add({hours:1})):(s=d.PlainDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:9,minute:0}),c=s.add({hours:1}));const g={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:r(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:s,end:c,calendarId:e.calendarId,allDay:u};return t.addEvent(g),null==n||n(g),g}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[t,n]),handleDragOver:o}}const yr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Nt();return g("div",{className:"df-navigation flex items-center gap-1",children:[u("button",{className:en,onClick:e,"aria-label":"Previous month",children:u(D,{className:tn})}),u("button",{className:"df-today-button calendar-today-button inline-flex items-center justify-center px-4 h-7 text-sm font-medium rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:t,children:a("today")}),u("button",{className:en,onClick:n,"aria-label":"Next month",children:u(x,{className:tn})})]})},pr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:r,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s})=>{const{t:d,locale:c}=Nt();return u("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",children:g("div",{className:`${cn} h-full`,children:[u("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:g("div",{children:[g("div",{className:"flex items-center justify-end gap-2",children:[u("div",{className:$t,style:{position:"relative"},children:u("div",{children:u("h1",{className:At,children:" "})})}),u(yr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),u(gn,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:i})]})}),g("div",{className:"flex-1 p-4 overflow-y-auto",children:[u("h3",{className:"text-lg font-semibold mb-3",children:t.toLocaleDateString(c,{weekday:"long",month:"long",day:"numeric"})}),0===a.length?u("p",{className:`${on} ${dn}`,children:d("noEvents")}):u("div",{className:"space-y-2",children:a.map(t=>g("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==r?void 0:r.id)===t.id?"bg-primary/10 border-primary":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:je(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[u("div",{className:`font-medium ${dn}`,children:t.title}),!t.allDay&&g("div",{className:`${sn} ${ln}`,children:[Ae(Te(t.start))," -"," ",Ae(Fe(t))]}),t.allDay&&u("div",{className:`${sn} ${ln}`,children:d("allDay")})]},t.id))})]})]})})},br=({viewType:e,currentDate:t,onPrevious:n,onNext:a,onToday:r,customTitle:o,customSubtitle:l,showTodayBox:i,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:h=0})=>{const{locale:m}=Nt(),v=void 0===i||i,f=o||(()=>{switch(e){case"day":return t.toLocaleDateString(m,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(m,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),y="day"===e?l||("day"===e?t.toLocaleDateString(m,{weekday:"long"}):null):null;return g("div",{className:$t,style:{position:"relative"},children:[u("div",{className:"flex-1",children:g("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[u("h1",{className:At,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&u("h1",{className:At,style:{position:"absolute",top:0,left:0,transform:`translateY(${h}px)`,willChange:"transform"},children:c})]}:{children:[u("div",{className:`${At} text-gray-900 dark:text-white`,children:f}),y&&u("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:y})]})}),v&&n&&a&&r&&u("div",{className:"flex items-center gap-2",children:u(yr,{handlePreviousMonth:n,handleNextMonth:a,handleToday:r})})]})},Dr=e=>{if(!1===e.icon)return null;if(void 0!==e.icon&&"boolean"!=typeof e.icon)return e.icon;const t=e.title.toLowerCase();return t.includes("holiday")||t.includes("vacation")||t.includes("假期")?u(L,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?u(j,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?u($,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?u(A,{className:"h-3 w-3"}):u(O,{className:"h-3 w-3"})},xr=(e,t)=>{const n=[],a=new Date(t);return a.setDate(t.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{const r=fe(e.start),o=fe(e.end),l=new Date(r);l.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let s=new Date(i);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(s=new Date(i),s.setDate(s.getDate()-1))}}const d=Ce(l,s)>0;if(!d&&e.allDay){if(l<t||l>a)return;const r=Math.floor((l.getTime()-t.getTime())/864e5);return void(r>=0&&r<=6&&n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:r,endDayIndex:r,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!d)return;const c=l;let u;if(e.allDay)u=new Date(i),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(i),u.setHours(23,59,59,999)):(u=new Date(i),u.setTime(u.getTime()-1))}if(u<t||c>a)return;const g=c<t?t:c,h=u>a?a:u,m=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),v=Math.min(6,Math.floor((h.getTime()-t.getTime())/864e5)),f=c>=t,y=u<=a,p=0===m||6===v;let b;b=f&&y?"single":f?p&&6===v?"start-week-end":"start":y?p&&0===m?"end-week-start":"end":"middle";const D=Ce(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:m,endDayIndex:v,segmentType:b,totalDays:D,segmentIndex:0,isFirstSegment:f,isLastSegment:y})}),n},wr=(e,t)=>{if(e.allDay)return[];const n=fe(e.start),a=fe(e.end),r=new Date(n);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const l=Ce(r,o);if(0===l)return[];const i=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),s=a.getTime()-n.getTime();if(!e.allDay&&1===l&&!i&&s<864e5)return[];const d=i?l:Math.max(0,l-1),c=[];for(let e=0;e<=d;e++){const o=new Date(r);o.setDate(r.getDate()+e);const l=Math.floor((o.getTime()-t.getTime())/864e5);if(l<0||l>6)continue;const s=0===e,u=e===d,g=s?n.getHours()+n.getMinutes()/60:0,h=u&&i?a.getHours()+a.getMinutes()/60:24;c.push({dayIndex:l,startHour:g,endHour:h,isFirst:s,isLast:u})}return c},Cr=e.memo(({segment:t,segmentIndex:n,isDragging:a,isResizing:r=!1,isSelected:o=!1,onMoveStart:l,onResizeStart:i,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:m=!0,viewable:v=!0})=>{const f=17*n,y=`calc(${t.startDayIndex/7*100}% + 2px)`,p=`calc(${(t.endDayIndex-t.startDayIndex+1)/7*100}% - 4px)`,b=e.useRef(null),D=e.useRef(null),x=e=>{const n="left"===e;return(n?t.isFirstSegment:t.isLastSegment)&&i&&m?u("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),i(e,t.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},w=t.event.calendarId||"blue",C=t.endDayIndex-t.startDayIndex+1;return g("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign(Object.assign({left:y,width:p,top:`${f}px`,height:"16px",borderRadius:(E=t.segmentType,{single:"0.25rem",start:"0.25rem 0 0 0.25rem","start-week-end":"0.25rem 0 0 0.25rem",end:"0 0.25rem 0.25rem 0","end-week-start":"0 0.25rem 0.25rem 0",middle:"0"}[E]),pointerEvents:"auto",zIndex:10},o||a?{backgroundColor:Le(w),color:"#fff"}:{backgroundColor:Oe(w),color:Pe(w)}),{cursor:c||v?"pointer":"default"}),"data-segment-days":C,onMouseDown:e=>{if(!c&&!v)return;e.preventDefault(),e.stopPropagation();!e.target.closest(".resize-handle")&&c&&l(e,t.event)},onTouchStart:e=>{if(!l||!d||!c&&!v)return;e.stopPropagation();const n=e.touches[0],a=n.clientX,r=n.clientY,o=e.currentTarget;D.current={x:a,y:r},b.current=setTimeout(()=>{s&&s(t.event.id);c&&l({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1},t.event),b.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(b.current&&D.current){const t=Math.abs(e.touches[0].clientX-D.current.x),n=Math.abs(e.touches[0].clientY-D.current.y);(t>10||n>10)&&(clearTimeout(b.current),b.current=null,D.current=null)}},onTouchEnd:()=>{b.current&&(clearTimeout(b.current),b.current=null),D.current=null},title:`${t.event.title} (${qn(t.event.start)} - ${qn(t.event.end)})`,children:[d&&o&&m&&g(h,{children:[t.isFirstSegment&&u("div",{className:"absolute left-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:je(w)}}),t.isLastSegment&&u("div",{className:"absolute right-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:je(w)}})]}),x("left"),u("div",{className:"flex-1 min-w-0",style:{cursor:r?"ew-resize":"pointer"},children:(()=>{const e=t.event.allDay,n=t.event.calendarId||"blue",a=Te(t.event.start),r=Fe(t.event),o=Ae(a),l=Ae(r);if(e){const e=()=>t.isFirstSegment?t.event.title:"middle"===t.segmentType||t.isLastSegment&&t.totalDays>1?"···":t.event.title;return g("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[t.isFirstSegment&&Dr(t.event)&&u("div",{className:"shrink-0 mr-1",children:u("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:je(n),width:"12px",height:"12px"},children:Dr(t.event)})}),u("div",{className:"flex-1 min-w-0",children:u("div",{className:"truncate font-medium text-xs",children:e()})}),t.isLastSegment&&"single"!==t.segmentType&&u("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:u("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const i=t.isFirstSegment||t.isLastSegment?t.event.title:"···",s=t.endDayIndex-t.startDayIndex+1,d=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return g("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[u("span",{className:"inline-block w-0.75 h-3 rounded-full shrink-0 mr-1",style:{backgroundColor:je(n)}}),u("div",{className:"flex items-center min-w-0 flex-1",children:u("span",{className:"whitespace-nowrap overflow-hidden block md:truncate mobile-mask-fade font-medium text-xs",children:i})}),t.isFirstSegment&&u("span",{className:`text-xs font-medium whitespace-nowrap ${1===s?"ml-2":""} hidden md:block`,style:d,children:o}),t.isLastSegment&&!t.event.allDay&&24!==r&&u("span",{className:"text-xs font-medium whitespace-nowrap ml-auto hidden md:inline",children:`ends ${l}`})]})})()}),x("right")]});var E});Cr.displayName="MultiDayEvent";const Er=({event:e,position:n,panelRef:a,isAllDay:r,eventVisibility:o,calendarRef:l,selectedEventElementRef:i,onEventUpdate:s,onEventDelete:c,app:h})=>{var v;const{effectiveTheme:f}=La(),y=ma(f),{t:p}=Nt(),b="dark"===y||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),D=!(null==h?void 0:h.state.readOnly);if(!(!1!==(null==h?void 0:h.getReadOnlyConfig().viewable)))return null;const x=b?"#1f2937":"white",w=b?"rgb(55, 65, 81)":"rgb(229, 231, 235)",C=t(()=>(h?h.getCalendarRegistry():K()).getVisible().map(e=>({label:e.name,value:e.id})),[h,null==h?void 0:h.getCalendars()]),E=t(()=>ue(e.start)?e.end&&!ue(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||d.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||d.Now.timeZoneId(),[e.end,e.start]),k=t=>{const[n,a]=t;s(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:a.toPlainDate()}))},N=(()=>{var e;let t={};if("sticky-top"===o){const a=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=a.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${w}`:"none"),borderTop:""+(n.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${w}`),borderBottom:""+(n.isSunday?"none":`1px solid ${w}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=a.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${w}`:"none"),borderTop:""+(n.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${w}`),borderBottom:""+(n.isSunday?"none":`1px solid ${w}`)}}else if(n&&i.current&&l.current){const e=i.current.getBoundingClientRect(),r=l.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-n.top,u=a.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const h=12,m=Math.max(h,Math.min(g,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${w}`:"none"),borderTop:""+(n.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${w}`),borderBottom:""+(n.isSunday?"none":`1px solid ${w}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),T=g("div",{ref:a,className:`${nn} p-4`,"data-event-detail-panel":"true",style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[u("div",{style:N}),u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("eventTitle")}),g("div",{className:"flex items-center justify-between gap-3 mb-3",children:[u("div",{className:"flex-1",children:u("input",{type:"text",value:e.title,readOnly:!D,disabled:!D,onChange:t=>{s(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),D&&u(yn,{options:C,value:e.calendarId||"blue",onChange:t=>{s(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==h?void 0:h.getCalendarRegistry()})]}),g("div",r?{className:"mb-3",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("dateRange")}),u(Pn,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!D,onChange:k,onOk:k,locale:null==h?void 0:h.state.locale})]}:{className:"mb-3",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("timeRange")}),u(Pn,{value:[e.start,e.end],timeZone:E,disabled:!D,onChange:t=>{const[n,a]=t;s(Object.assign(Object.assign({},e),{start:n,end:a}))},onOk:t=>{const[n,a]=t;s(Object.assign(Object.assign({},e),{start:n,end:a}))},locale:null==h?void 0:h.state.locale})]}),g("div",{className:"mb-3",children:[u("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("note")}),u("textarea",{value:null!==(v=e.description)&&void 0!==v?v:"",readOnly:!D,disabled:!D,onChange:t=>s(Object.assign(Object.assign({},e),{description:t.target.value})),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:p("addNotePlaceholder")})]}),D&&g("div",{className:"flex space-x-2",children:[u("button",r?{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=ue(e.start)?e.start:e.start.toPlainDate(),n=d.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:d.Now.timeZoneId()}),a=d.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:d.Now.timeZoneId()});s(Object.assign(Object.assign({},e),{allDay:!1,start:n,end:a}))},children:p("setAsTimed")}:{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=ue(e.start)?e.start:e.start.toPlainDate();s(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:p("setAsAllDay")}),u("button",{className:"px-2 py-1 bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>c(e.id),children:p("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const S=document.body;return S?m.createPortal(T,S):null},kr=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:r,calendarRef:o,selectedEventElementRef:l,onEventUpdate:i,onEventDelete:s,onClose:d,contentRenderer:c})=>{const{effectiveTheme:h}=La(),v=ma(h),f="dark"===v?"#1f2937":"white",y="dark"===v?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=(()=>{var e;let a={};if("sticky-top"===r){const n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${y}`:"none"),borderTop:""+(t.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${y}`),borderBottom:""+(t.isSunday?"none":`1px solid ${y}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===r){const e=n.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}a={position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${y}`:"none"),borderTop:""+(t.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${y}`),borderBottom:""+(t.isSunday?"none":`1px solid ${y}`)}}else if(t&&l.current&&o.current){const e=l.current.getBoundingClientRect(),r=o.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const h=12,m=Math.max(h,Math.min(g,c));a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(t.isSunday?`1px solid ${y}`:"none"),borderTop:""+(t.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${y}`),borderBottom:""+(t.isSunday?"none":`1px solid ${y}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return a})(),b=g("div",{ref:n,className:`${nn} p-3`,"data-event-detail-panel":"true",style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===v?"#1f2937":"#ffffff"},children:[u("div",{style:p}),u(c,{event:e,isAllDay:a,onEventUpdate:i,onEventDelete:s,onClose:d})]});return m.createPortal(b,document.body)},Nr=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const r=`${Math.floor(Te(e.start)).toString().padStart(2,"0")}:${Math.round(Te(e.start)%1*60).toString().padStart(2,"0")}`;return g("div",{className:"text-xs mb-[2px] cursor-pointer flex items-center justify-between",children:[g("div",{className:"flex items-center flex-1 min-w-0",children:[u("span",{style:{backgroundColor:je(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${un} shrink-0 rounded-full`}),u("span",{className:"whitespace-nowrap overflow-hidden block md:truncate mobile-mask-fade "+(n?"text-white":""),children:e.title})]}),!a&&u("span",{className:`${sn} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:r})]})},Tr=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,a="boolean"!=typeof e.icon?e.icon:null;return g("div",{className:"text-xs px-1 mb-[2px] rounded truncate cursor-pointer flex items-center",children:[n&&(a?u("div",{className:`${un} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?u("span",{className:`inline-block ${un} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):u(O,{className:`${Kt} ${t?"text-white":""}`})),u("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Sr=({event:e,isEditable:t,onResizeStart:n})=>{const a=!1!==e.icon,r="boolean"!=typeof e.icon?e.icon:null;return g("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[n&&t&&u("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),a&&(r?u("div",{className:"mr-1 shrink-0",children:r}):u(O,{className:Kt})),u("div",{className:`${Xt} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&u("div",{className:Jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Mr=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:r,isEventSelected:o,onResizeStart:l})=>{const i=n?n.startHour:Te(e.start),s=n?n.endHour:Fe(e),d=s-i,c=!n||n.isFirst,m=!n||n.isLast,v=e.calendarId||"blue";return g(h,{children:[u("div",{className:Gt,style:{backgroundColor:je(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),g("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(Fe(e)-Te(e.start)<=.25?"px-1 py-0":"p-1"),children:[u("div",{className:`${Xt} pr-1`,style:{lineHeight:d<=.25?"1.2":"normal"},children:e.title}),d>.5&&u("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${Ae(i)} - ${Ae(s)}`:ze(e)})]}),l&&a&&g(h,{children:[c&&u("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>l(t,e,"top")}),m&&u("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>l(t,e,"bottom")}),!c&&m&&n&&u("div",{className:Jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),r&&o&&l&&a&&g(h,{children:[u("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:je(v,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),u("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:je(v,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},Ir=({event:e,layout:t,isAllDay:l=!1,allDayHeight:i=28,calendarRef:s,isBeingDragged:d=!1,isBeingResized:c=!1,isDayView:v=!1,isMonthView:f=!1,isMultiDay:y=!1,segment:p,segmentIndex:b=0,hourHeight:D,firstHour:x,selectedEventId:w,detailPanelEventId:C,onMoveStart:E,onResizeStart:k,onEventUpdate:N,onEventDelete:T,newlyCreatedEventId:S,onDetailPanelOpen:M,onEventSelect:I,onEventLongPress:H,onDetailPanelToggle:R,customDetailPanelContent:O,customEventDetailDialog:P,multiDaySegmentInfo:L,app:j,isMobile:$=!1,enableTouch:A,hideTime:z})=>{const Y=null!=A?A:$,[F,V]=n(!1),[W,B]=n(!1),Z=y&&p?`${e.id}::${p.id}`:void 0!==(null==L?void 0:L.dayIndex)?`${e.id}::day-${L.dayIndex}`:e.id,U=C===Z,[_,q]=n(null),[X,G]=n("visible"),K=o(null),J=o(null),Q=o(null),ee=o(null),te=o(null),ne=o(null),ae=void 0!==w?w===e.id:F,re=null==j?void 0:j.getReadOnlyConfig(),oe=!(null==j?void 0:j.state.readOnly),le=!1!==(null==re?void 0:re.viewable),ie=!1!==(null==re?void 0:re.draggable),se=e=>{if(!s.current)return null;const t=s.current.getBoundingClientRect();if(f){const n=t.width/7;return{left:t.left+e*n,width:n}}const n=$?48:80;if(v){const e=t.width-n;return{left:t.left+n,width:e}}const a=(t.width-n)/7;return{left:t.left+n+e*a,width:a}},de=e=>{ee.current=e},ce=()=>{var t;if(null!==ee.current)return ee.current;if(C===Z){const e=Z.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==L?void 0:L.dayIndex)?L.dayIndex:p?p.startDayIndex:null!==(t=e.day)&&void 0!==t?t:0},ue=e=>{if(!s.current)return null;const t=s.current.getBoundingClientRect();if(f){const n=t.width/7,a=e-t.left,r=Math.floor(a/n);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const n=$?48:80,a=v?1:7,r=(t.width-n)/a,o=e-t.left-n,l=Math.floor(o/r);return Number.isFinite(l)?Math.max(0,Math.min(a-1,l)):null},ge=()=>new Promise(t=>{if(!s.current||l||f)return void t();const n=s.current.querySelector(".calendar-content");if(!n)return void t();const a=L?L.startHour:Te(e.start),r=L?L.endHour:Fe(e),o=(a-x)*D,i=o+Math.max((r-a)*D,D/4),d=n.scrollTop,c=n.clientHeight;if(o>=d&&i<=d+c)return void t();const u=((a+r)/2-x)*D-c/2,g=n.scrollHeight-c,h=Math.max(0,Math.min(g,u));n.scrollTo({top:h,behavior:"smooth"}),setTimeout(()=>{t()},300)}),he=a(()=>{if(!Q.current||!s.current||!J.current)return;const t=s.current.getBoundingClientRect(),n=ce(),a=se(n);let r,o;if(a)r=a.left,o=a.width;else if(f)o=t.width/7,r=t.left+n*o;else{const e=$?48:80;o=(t.width-e)/7,r=t.left+e+n*o}const l=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var a,o,d,c,u;if(!J.current)return;if(!Q.current)return;const g=J.current.getBoundingClientRect(),h=g.width,m=g.height;let b,w,C;if("sticky-top"===X||"sticky-bottom"===X){const t=null===(a=s.current)||void 0===a?void 0:a.querySelector(".calendar-content");if(!t)return;const n=L?L.startHour:Te(e.start),r=L?L.endHour:Fe(e),l=(n-x)*D,i=Math.max((r-n)*D,D/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+l-c,g=null===(o=K.current)||void 0===o?void 0:o.getBoundingClientRect();if(!g)return;C={top:u,bottom:u+i,left:g.left,right:g.right,width:g.width,height:i,x:g.x,y:u,toJSON:()=>({})}}else C=Q.current.getBoundingClientRect();if(f&&y&&p){const e=se(n),a=null!==(d=null==e?void 0:e.width)&&void 0!==d?d:t.width/7,r=null!==(c=null==e?void 0:e.left)&&void 0!==c?c:t.left+n*a,o=r+a;C={top:C.top,bottom:C.bottom,left:r,right:o,width:o-r,height:C.height,x:r,y:C.top,toJSON:()=>({})}}if(("sticky-top"===X||"sticky-bottom"===X)&&!f){const e=null!==(u=null==L?void 0:L.dayIndex)&&void 0!==u?u:ce(),n=$?48:80,a=v?1:7,r=(t.width-n)/a,o=se(e),l=o?o.left:t.left+n+e*r,i=o?o.width:r,s=Math.max(0,v?C.width:i-3),d=v?C.left:l;C=Object.assign(Object.assign({},C),{left:d,right:d+s,width:s})}const E=l-C.right,k=C.left-t.left;b=E>=h+20?C.right+10:k>=h+20?C.left-h-10:E>k?Math.max(t.left+10,l-h-10):t.left+10;const N=C.top-m/2+C.height/2,T=Math.max(10,t.top+10),S=i-10;w=N<T?T:N+m>S?S-m:N,q(e=>e?Object.assign(Object.assign({},e),{top:w,left:b,isSunday:b<r}):null)})},[s,e.day,e.start,e.end,X,f,x,D,y,null==p?void 0:p.startDayIndex,null==p?void 0:p.endDayIndex,null==L?void 0:L.dayIndex,C,Z]),me=a(()=>{if(!ae||!U||!K.current||!s.current||l||f)return;const t=s.current.querySelector(".calendar-content");if(!t)return;const n=L?L.startHour:Te(e.start),a=L?L.endHour:Fe(e),r=(n-x)*D,o=r+Math.max((a-n)*D,D/4),i=t.getBoundingClientRect(),d=t.scrollTop;let c=o<d+6,u=r>d+i.height-6;const g=i.bottom<0,h=i.top>window.innerHeight;g?c=!0:h&&(u=!0),G(c?"sticky-top":u?"sticky-bottom":"visible"),he()},[F,U,s,l,f,Te(e.start),Fe(e),x,D,he,null==L?void 0:L.startHour,null==L?void 0:L.endHour,null==L?void 0:L.dayIndex,C,Z]);r(()=>{var e,t;if(!ae||!U||l)return;const n=null===(e=s.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const a=()=>me(),r=()=>{me(),he()},o=[n];let i=null===(t=s.current)||void 0===t?void 0:t.parentElement;for(;i;){const e=window.getComputedStyle(i),t=e.overflowY,n=e.overflowX;"auto"!==t&&"scroll"!==t&&"auto"!==n&&"scroll"!==n||o.push(i),i=i.parentElement}o.forEach(e=>{e.addEventListener("scroll",a)}),window.addEventListener("scroll",a,!0),window.addEventListener("resize",r);let d=null;return s.current&&(d=new ResizeObserver(()=>{r()}),d.observe(s.current)),me(),()=>{o.forEach(e=>{e.removeEventListener("scroll",a)}),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",r),d&&d.disconnect()}},[ae,U,l,me,he,s,X]),r(()=>{if(!ae&&!U)return;const t=t=>{var n,a;const r=t.target,o=null===(n=K.current)||void 0===n?void 0:n.contains(r),l=null!==r.closest(`[data-event-id="${e.id}"]`),i=null===(a=J.current)||void 0===a?void 0:a.contains(r),s=r.closest("[data-event-detail-dialog]"),d=r.closest("[data-range-picker-popup]"),c=r.closest("[data-color-picker-dropdown]");U?o||l||i||s||d||c||(I&&I(null),de(null),V(!1),null==R||R(null)):!ae||o||l||c||(I&&I(null),de(null),V(!1),null==R||R(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[ae,U,I,R,e.id]),r(()=>{y&&p&&!p.isFirstSegment||S!==e.id||U||setTimeout(()=>{var t,n;if(K.current){let a=K.current;if(y){const e=K.current.querySelector("div");e&&(a=e)}y?p?de(p.startDayIndex):void 0!==(null==L?void 0:L.dayIndex)?de(L.dayIndex):de(null!==(t=e.day)&&void 0!==t?t:null):de(null!==(n=e.day)&&void 0!==n?n:null),Q.current=a,V(!0),null==R||R(Z),q({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{he()})}null==M||M()},150)},[S,e.id,U,M,he,y,p,R,Z]);const ve=o(null);r(()=>{let t,n=!0;const a=null==j?void 0:j.state.highlightedEventId;return ae&&a===e.id?ve.current!==a&&(ve.current=a,ge().then(()=>{n&&(B(!0),t=setTimeout(()=>{n&&B(!1)},150))})):B(!1),a!==e.id&&(ve.current=null),()=>{n=!1,t&&clearTimeout(t)}},[ae,null==j?void 0:j.state.highlightedEventId,e.id]);const fe=()=>p?u(Cr,{segment:p,segmentIndex:null!=b?b:0,isDragging:d||ae,isResizing:c,isSelected:ae,onMoveStart:E||(()=>{}),onResizeStart:k,isMobile:$,isDraggable:ie,isEditable:oe,viewable:le}):null,ye=()=>{if(y&&p){const{segmentType:e}=p;if("single"===e||"start"===e)return qt;if("start-week-end"===e)return"rounded-l-xl rounded-r-none my-0.5";if("end"===e||"end-week-start"===e)return"rounded-r-xl rounded-l-none my-0.5";if("middle"===e)return"rounded-none my-0.5"}return qt},pe=e.calendarId||"blue";return g(h,{children:[u("div",{ref:K,"data-event-id":e.id,className:(()=>{let e="df-event calendar-event select-none pointer-events-auto px-0.5";return v?e+=" df-day-event":f||(e+=" df-week-event"),f?`\n ${e}\n ${l?ye():"rounded-sm"}\n `:`\n ${e}\n shadow-sm\n ${l?ye():"rounded-sm"}\n `})(),style:Object.assign(Object.assign({},(()=>{var n,a,r,o,c,u;if(f)return{opacity:d?.3:1,zIndex:ae||U?1e3:1,transform:W?"scale(1.15)":void 0,transition:"transform 0.1s ease-in-out",cursor:ie||le?"pointer":"default"};if(l){const e={height:i-4+"px",opacity:d?.3:1,zIndex:ae||U?1e3:1,transform:W?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:ie||le?"pointer":"default"},t=b*i;if(Object.assign(e,{top:`${t}px`}),v)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(y&&p){const t=(p.endDayIndex-p.startDayIndex+1)/7*100,n=p.startDayIndex/7*100,a=2,r=p.isFirstSegment?a:0,o=r+(p.isLastSegment?a:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:r>0?`calc(${n}% + ${r}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"calc(100% - 3px)",left:"0px",position:"relative"});return e}const g=L?L.startHour:Te(e.start),h=L?L.endHour:Fe(e),m={top:`${(g-x)*D+3}px`,height:Math.max((h-g)*D,D/4)-4+"px",position:"absolute",opacity:d?.3:1,zIndex:ae||U?1e3:null!==(n=null==t?void 0:t.zIndex)&&void 0!==n?n:1,transform:W?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:ie||le?"pointer":"default"};if(ae&&U&&("sticky-top"===X||"sticky-bottom"===X)){const e=null===(a=s.current)||void 0===a?void 0:a.getBoundingClientRect();if(e){const t=null!==(r=null==L?void 0:L.dayIndex)&&void 0!==r?r:ce(),n=$?48:80,a=v?1:7;let l=(e.width-n)/a,i=e.left+n+t*l;f&&(l=e.width/7,i=e.left+t*l);const d=se(t);d&&(i=d.left,l=d.width);let g=null===(o=s.current)||void 0===o?void 0:o.querySelector(".calendar-content");g||(g=null===(c=s.current)||void 0===c?void 0:c.querySelector(".calendar-renderer"));const h=null==g?void 0:g.getBoundingClientRect(),m=null===(u=K.current)||void 0===u?void 0:u.getBoundingClientRect(),y=null==m?void 0:m.left,p=null==m?void 0:m.width;if("sticky-top"===X){let t=h?h.top:e.top;return t=Math.max(t,0),t=Math.max(t,e.top),t=Math.min(t,e.bottom-6),t=Math.min(t,window.innerHeight-6),{position:"fixed",top:`${t}px`,left:`${v?y:i}px`,width:`${v?p:l-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let b=h?h.bottom:e.bottom;return b=Math.min(b,window.innerHeight),b=Math.min(b,e.bottom),b=Math.max(b,e.top+6),b=Math.max(b,6),{position:"fixed",top:b-6+"px",left:`${v?y:i}px`,width:`${v?p:l-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!l){const e=v?`calc(${t.width}% - 3px)`:t.width-1+"%";return Object.assign(Object.assign({},m),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},m),{left:"0px",right:"3px"})})()),ae?{backgroundColor:Le(pe,null==j?void 0:j.getCalendarRegistry()),color:"#fff"}:{backgroundColor:Oe(pe,null==j?void 0:j.getCalendarRegistry()),color:Pe(pe,null==j?void 0:j.getCalendarRegistry())}),onClick:Y?void 0:t=>{var n,a;if(t.preventDefault(),t.stopPropagation(),y)if(p){const e=ue(t.clientX);if(null!==e){const t=Math.min(Math.max(e,p.startDayIndex),p.endDayIndex);de(t)}else de(p.startDayIndex)}else void 0!==(null==L?void 0:L.dayIndex)?de(L.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);j&&j.onEventClick(e);I?I(e.id):le&&V(!0),null==R||R(null),q(null)},onDoubleClick:Y?void 0:t=>{var n,a;if(!le)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;if(y){const e=r.querySelector("div");e&&(r=e)}if(Q.current=r,y)if(p){const e=ue(t.clientX);if(null!==e){const t=Math.min(Math.max(e,p.startDayIndex),p.endDayIndex);de(t)}else de(p.startDayIndex)}else void 0!==(null==L?void 0:L.dayIndex)?de(L.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);ge().then(()=>{V(!0),$||(null==R||R(Z),q({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{he()}))})},onMouseDown:E?t=>{var n;if(L){const a=Object.assign(Object.assign({},e),{day:null!==(n=L.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:L});E(t,a)}else if(y&&p){const n=Object.assign(Object.assign({},e),{day:p.startDayIndex,_segmentInfo:{dayIndex:p.startDayIndex,isFirst:p.isFirstSegment,isLast:p.isLastSegment}});E(t,n)}else E(t,e)}:void 0,onTouchStart:t=>{if(!E||!Y)return;t.stopPropagation();const n=t.touches[0],a=n.clientX,r=n.clientY,o=t.currentTarget;ne.current={x:a,y:r},te.current=setTimeout(()=>{var t;H?H(e.id):V(!0);const n={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1};if(L){const a=Object.assign(Object.assign({},e),{day:null!==(t=L.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:L});E(n,a)}else if(y&&p){const t=Object.assign(Object.assign({},e),{day:p.startDayIndex,_segmentInfo:{dayIndex:p.startDayIndex,isFirst:p.isFirstSegment,isLast:p.isLastSegment}});E(n,t)}else E(n,e);te.current=null,ne.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(te.current&&ne.current){const t=Math.abs(e.touches[0].clientX-ne.current.x),n=Math.abs(e.touches[0].clientY-ne.current.y);(t>10||n>10)&&(clearTimeout(te.current),te.current=null,ne.current=null)}},onTouchEnd:t=>{te.current&&(clearTimeout(te.current),te.current=null),Y&&ne.current&&(t.preventDefault(),t.stopPropagation(),I?I(e.id):le&&V(!0),j&&j.onEventClick(e),null==R||R(null),q(null)),ne.current=null},children:f?y&&p?fe():e.allDay?y?fe():u(Tr,{event:e,isEventSelected:ae}):u(Nr,{event:e,app:j,isEventSelected:ae,hideTime:z}):e.allDay?u(Sr,{event:e,isEditable:!!oe,onResizeStart:k}):u(Mr,{event:e,app:j,multiDaySegmentInfo:L,isEditable:!!oe,isTouchEnabled:!!Y,isEventSelected:ae,onResizeStart:k})}),U&&u("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!U)return null;const t=()=>{I&&I(null),de(null),V(!1),null==R||R(null)};if(P){const n=P,a={event:e,isOpen:U,isAllDay:l,onEventUpdate:N,onEventDelete:T,onClose:t,app:j};if("undefined"==typeof window||"undefined"==typeof document)return null;const r=document.body;return r?m.createPortal(u(n,Object.assign({},a)),r):null}return _?O?u(kr,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:X,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,contentRenderer:O}):u(Er,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:X,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,app:j}):null})()]})},Hr=({app:t,currentDate:n,currentWeekStart:a,events:r,currentDayEvents:o,organizedAllDayEvents:l,allDayAreaHeight:i,timeSlots:s,eventLayouts:d,isToday:c,currentTime:h,selectedEventId:m,setSelectedEventId:v,newlyCreatedEventId:f,setNewlyCreatedEventId:y,detailPanelEventId:p,setDetailPanelEventId:b,dragState:D,isDragging:x,handleMoveStart:w,handleResizeStart:C,handleCreateStart:E,handleCreateAllDayEvent:k,handleTouchStart:N,handleTouchEnd:T,handleTouchMove:S,handleDragOver:M,handleDrop:I,handleEventUpdate:H,handleEventDelete:R,customDetailPanelContent:O,customEventDetailDialog:P,calendarRef:L,allDayRowRef:j,switcherMode:$,isMobile:A,isTouch:z,setDraftEvent:F,setIsDrawerOpen:V,ALL_DAY_HEIGHT:W,HOUR_HEIGHT:B,FIRST_HOUR:Z,LAST_HOUR:U})=>{const{t:_,locale:q}=Nt(),X=e.useRef(t.state.highlightedEventId);return u("div",{className:`flex-none ${"buttons"===$?"":"md:w-[60%]"} w-full md:w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,children:g("div",{className:`relative ${cn} h-full`,children:[u(br,{calendar:t,viewType:Y.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(q,{weekday:"long"})}),g("div",{className:`${_t} pt-px`,ref:j,children:[u("div",{className:"df-all-day-label flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end select-none w-12 text-[10px] md:w-20 md:text-xs",children:_("allDay")}),u("div",{className:"flex flex-1 relative",children:u("div",{className:"w-full relative",style:{minHeight:`${i}px`},onMouseDown:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);null==k||k(e,t)},onDoubleClick:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);null==k||k(e,t)},onDragOver:M,onDrop:e=>{I(e,n,void 0,!0)},children:l.map(e=>u(Ir,{event:e,isAllDay:!0,isDayView:!0,segmentIndex:e.row,allDayHeight:W,calendarRef:L,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:B,firstHour:Z,onMoveStart:w,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:p,onDetailPanelToggle:e=>b(e),selectedEventId:m,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=t.state.readOnly,o=r.find(t=>t.id===e);(A||z)&&o&&n&&!a?(F(o),V(!0)):(v(e),t.state.highlightedEventId&&(t.highlightEvent(null),X.current=null))},onEventLongPress:e=>{(A||z)&&v(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:t,isMobile:A,enableTouch:z},e.id))})})]}),u("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative"},children:g("div",{className:"relative flex",children:[c&&h&&(()=>{const e=h,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>U)return null;return g("div",{className:Zt,style:{top:`${(t-Z)*B}px`,width:"100%",height:0,zIndex:20},children:[g("div",{className:"flex items-center w-12 md:w-20",children:[u("div",{className:"relative w-full flex items-center"}),u("div",{className:Ut,children:Ae(t)})]}),u("div",{className:"flex-1 flex items-center",children:u("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),u("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 w-12 md:w-20",children:s.map((e,t)=>u("div",{className:Vt,children:u("div",{className:`${Wt} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t))}),g("div",{className:"grow relative select-none",style:{WebkitTouchCallout:"none"},children:[s.map((e,t)=>u("div",{className:Bt,onDoubleClick:e=>{var t,r,o,l;const i=Math.floor((n.getTime()-a.getTime())/864e5),s=null===(r=null===(t=L.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!s)return;const d=e.clientY-s.top+(null===(l=null===(o=L.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0;null==E||E(e,i,Z+d/B)},onTouchStart:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);N(e,t)},onTouchEnd:T,onTouchMove:S,onDragOver:M,onDrop:e=>{var t,a,r,o;const l=null===(a=null===(t=L.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!l)return;const i=e.clientY-l.top+(null===(o=null===(r=L.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=Math.floor(Z+i/B);I(e,n,s)},onContextMenu:e=>A&&e.preventDefault()},t)),u("div",{className:an,children:u("div",{className:"absolute -top-2.5 text-[12px] text-gray-500 dark:text-gray-400 -left-9",children:"00:00"})}),u("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:o.filter(e=>!e.allDay).map(e=>{const n=d.get(e.id);return u(Ir,{event:e,layout:n,isDayView:!0,calendarRef:L,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:B,firstHour:Z,onMoveStart:w,onResizeStart:C,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:p,onDetailPanelToggle:e=>b(e),selectedEventId:m,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=r.find(t=>t.id===e);(A||z)&&a&&n?(F(a),V(!0)):(v(e),t.state.highlightedEventId&&(t.highlightEvent(null),X.current=null))},onEventLongPress:e=>{(A||z)&&v(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:t,isMobile:A,enableTouch:z},e.id)})})]})]})})]})})},Rr=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a},Or=({app:l,customDetailPanelContent:i,customEventDetailDialog:s,calendarRef:d,switcherMode:c="buttons"})=>{const h=l.getEvents(),{t:m,locale:v}=Nt(),{screenSize:f}=Ia(),y="desktop"!==f,[p,b]=n(!1);r(()=>{b("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const D=l.getCustomMobileEventRenderer()||Za,[x,w]=n(null),[C,E]=n(null),[k,N]=n(null),[T,S]=n(null),[M,I]=n(!1),[H,R]=n(null),O=e.useRef(null),P=l.getCurrentDate(),L=l.getVisibleMonth();L.getFullYear(),L.getMonth();const[j,$]=n(P),A=o(P.getTime());P.getTime()!==A.current&&(A.current=P.getTime(),P.getFullYear()===j.getFullYear()&&P.getMonth()===j.getMonth()||$(P));const z=a(e=>{$(t=>{const n=new Date(t.getFullYear(),t.getMonth()+e,1);return l.setVisibleMonth(n),n})},[l]),{HOUR_HEIGHT:F,FIRST_HOUR:V,LAST_HOUR:W,TIME_COLUMN_WIDTH:B,ALL_DAY_HEIGHT:Z}=ir,U=e.useRef(l.state.highlightedEventId);r(()=>{var e;if(l.state.highlightedEventId!==U.current)if(l.state.highlightedEventId){const t=l.getEvents().find(e=>e.id===l.state.highlightedEventId);if(t&&(E(t),!t.allDay)){const n=Te(t.start),a=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=(n-V)*F;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else E(null);U.current=l.state.highlightedEventId},[l.state.highlightedEventId,V,F,d,l]);const _=e.useRef(null),q=t(()=>Rr(P),[P]),X=t(()=>((e,t,n)=>{const a=new Date(t);a.setHours(0,0,0,0);const r=new Date(t);return r.setHours(23,59,59,999),e.filter(e=>{const t=fe(e.start),n=fe(e.end);if(e.allDay){const e=new Date(t);e.setHours(0,0,0,0);const o=new Date(n);return o.setHours(0,0,0,0),e<=r&&o>=a}return t<r&&n>a}).map(e=>{const t=fe(e.start),a=Math.floor((t.getTime()-n.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(h,P,q),[h,P,q]),G=t(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const a=new Date(n);return a.setDate(a.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=fe(e.start),r=fe(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=he(n),i=!0),r>a&&(l=he(a),i=!0),Object.assign(Object.assign({},e),{start:i?o:e.start,end:i?l:e.end,day:0})})})(X,P),[X,P]),K=t(()=>lr.calculateDayEventLayouts(G,{viewType:"day"}),[G]),J=t(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=fe(e.start),a=fe(t.start);if(n.getTime()!==a.getTime())return n.getTime()-a.getTime();const r=fe(e.end);return fe(t.end).getTime()-r.getTime()});const n=[],a=[];return t.forEach(e=>{let t=0,r=!1;for(;!r;)n[t]?n[t].some(t=>{const n=fe(e.start),a=fe(e.end),r=fe(t.start);return n<=fe(t.end)&&r<=a})?t++:(n[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),r=!0):(n[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),r=!0)}),a})(X),[X]),Q=t(()=>{if(0===J.length)return Z;return(Math.max(...J.map(e=>e.row))+1)*Z},[J,Z]),{handleMoveStart:ee,handleCreateStart:te,handleResizeStart:ne,handleCreateAllDayEvent:ae,dragState:re,isDragging:oe}=vr(l,{calendarRef:d,allDayRowRef:_,viewType:Y.DAY,onEventsUpdate:e=>{const t=e(X),n=new Set(t.map(e=>e.id)),a=X.filter(e=>!n.has(e.id)),r=new Set(X.map(e=>e.id)),o=t.filter(e=>!r.has(e.id)),i=t.filter(e=>{if(!r.has(e.id))return!1;const t=X.find(t=>t.id===e.id);return t&&(fe(t.start).getTime()!==fe(e.start).getTime()||fe(t.end).getTime()!==fe(e.end).getTime()||t.day!==e.day||Te(t.start)!==Te(e.start)||Te(t.end)!==Te(e.end)||t.title!==e.title)});a.forEach(e=>l.deleteEvent(e.id)),o.forEach(e=>l.addEvent(e)),i.forEach(e=>l.updateEvent(e.id,e))},onEventCreate:e=>{y?(R(e),I(!0)):(l.addEvent(e),S(e.id))},onEventEdit:()=>{},currentWeekStart:q,events:X,calculateNewEventLayout:(e,t,n)=>((e,t,n,a,r)=>{const o=new Date(a),l=new Date(a);o.setHours(Math.floor(t),t%1*60,0,0),l.setHours(Math.floor(n),n%1*60,0,0);const i=[...r,{id:"-1",title:"Temp",day:0,start:he(o),end:he(l),calendarId:"blue",allDay:!1}];return lr.calculateDayEventLayouts(i,{viewType:"day"}).get("-1")||null})(0,t,n,P,G),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r,o)=>{const l=o.filter(t=>t.id!==e.id),i=new Date(r),s=new Date(i);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(i);d.setHours(Math.floor(a),a%1*60,0,0);const c=[...l,Object.assign(Object.assign({},e),{start:he(s),end:he(d),day:0})];return 0===c.length?null:lr.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,P,G),TIME_COLUMN_WIDTH:y?48:80,isMobile:y}),{handleDrop:le,handleDragOver:ie}=fr({app:l,onEventCreated:e=>{S(e.id)}}),se=Array.from({length:24},(e,t)=>({hour:t+V,label:Ae(t+V)})),de=a(e=>{const t=new Date(e.getFullYear(),e.getMonth(),e.getDate());l.setCurrentDate(t),$(new Date(t.getFullYear(),t.getMonth(),1))},[l]),ce=t(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(P);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[P]);return r(()=>{w(new Date);const e=setInterval(()=>w(new Date),6e4);return()=>clearInterval(e)},[]),g("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[u(Hr,{app:l,currentDate:P,currentWeekStart:q,events:h,currentDayEvents:X,organizedAllDayEvents:J,allDayAreaHeight:Q,timeSlots:se,eventLayouts:K,isToday:ce,currentTime:x,selectedEventId:C?C.id:null,setSelectedEventId:e=>{if(e){const t=h.find(t=>t.id===e);E(t||null)}else E(null)},newlyCreatedEventId:T,setNewlyCreatedEventId:S,detailPanelEventId:k,setDetailPanelEventId:N,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleCreateStart:te,handleCreateAllDayEvent:ae,handleTouchStart:(e,t)=>{if(!y&&!p)return;const n=e.touches[0],a=n.clientX,r=n.clientY,o=e.currentTarget;O.current=setTimeout(()=>{var e,n,l;const i=null===(n=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!i)return;const s=null===(l=d.current)||void 0===l?void 0:l.querySelector(".calendar-content"),c=s?s.scrollTop:0,u=r-i.top+c;null==te||te({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:r}],changedTouches:[{clientX:a,clientY:r}],target:o,currentTarget:o,cancelable:!0},t,V+u/F)},500)},handleTouchEnd:()=>{O.current&&(clearTimeout(O.current),O.current=null)},handleTouchMove:()=>{O.current&&(clearTimeout(O.current),O.current=null)},handleDragOver:ie,handleDrop:le,handleEventUpdate:e=>{l.updateEvent(e.id,e)},handleEventDelete:e=>{l.deleteEvent(e)},customDetailPanelContent:i,customEventDetailDialog:s,calendarRef:d,allDayRowRef:_,switcherMode:c,isMobile:y,isTouch:p,setDraftEvent:R,setIsDrawerOpen:I,ALL_DAY_HEIGHT:Z,HOUR_HEIGHT:F,FIRST_HOUR:V,LAST_HOUR:W}),u(pr,{app:l,currentDate:P,visibleMonth:j,currentDayEvents:X,selectedEvent:C,setSelectedEvent:E,handleMonthChange:z,handleDateSelect:de,switcherMode:c}),u(D,{isOpen:M,onClose:()=>{I(!1),R(null)},onSave:e=>{h.find(t=>t.id===e.id)?l.updateEvent(e.id,e):l.addEvent(e),I(!1),R(null)},draftEvent:H,app:l})]})},Pr={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[Y.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},Lr=(t={})=>{const n=Object.assign(Object.assign({},Pr),t),a=t=>e.createElement(Ka,{viewType:Y.DAY,originalComponent:Or,app:t.app,config:n,className:"day-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,switcherMode:t.switcherMode,meta:t.meta});return a.displayName="DayViewAdapter",{type:Y.DAY,component:a,config:n}},jr=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:r,timeGridWidth:o,sidebarWidth:l,allDayAreaHeight:i,organizedAllDaySegments:s,allDayLabelText:d,isMobile:c,isTouch:m,calendarRef:v,allDayRowRef:f,topFrozenContentRef:y,ALL_DAY_HEIGHT:p,HOUR_HEIGHT:b,FIRST_HOUR:D,dragState:x,isDragging:w,handleMoveStart:C,handleResizeStart:E,handleEventUpdate:k,handleEventDelete:N,newlyCreatedEventId:T,setNewlyCreatedEventId:S,selectedEventId:M,setSelectedEventId:I,detailPanelEventId:H,setDetailPanelEventId:R,handleCreateAllDayEvent:O,handleDragOver:P,handleDrop:L,customDetailPanelContent:j,customEventDetailDialog:$,events:A,setDraftEvent:z,setIsDrawerOpen:Y})=>{const F={flexShrink:0};return u("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:u("div",{ref:y,className:"flex-1 overflow-hidden relative",children:g("div",{className:"flex flex-col min-w-full",children:[g("div",{className:"flex w-full",children:[g("div",{className:"flex shrink-0",style:{width:o?o+l:"100%"},children:[u("div",{className:"w-12 md:w-20 shrink-0 sticky left-0 bg-white dark:bg-gray-900 z-20 border-b border-gray-200 dark:border-gray-700"}),u("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700 flex-1",children:t.map((e,t)=>u("div",{className:"df-week-day-cell flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1 select-none "+(c?"flex-col gap-0":""),style:F,children:g(h,c?{children:[u("div",{className:"text-[11px] leading-tight text-gray-500 font-medium",children:n[t]}),u("div",{className:`${Yt} w-7 h-7 text-base font-medium ${a[t].isToday?Qt:""}`,children:a[t].date})]}:{children:[u("div",{className:"inline-flex items-center justify-center text-sm mt-1 mr-1",children:e}),u("div",{className:`${Yt} ${a[t].isToday?Qt:""}`,children:a[t].date})]})},t))})]}),u("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900"})]}),g("div",{className:"flex w-full",children:[g("div",{className:"flex shrink-0",style:{width:o?o+l:"100%"},children:[u("div",{className:"w-12 md:w-20 shrink-0 flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none bg-white dark:bg-gray-900 sticky left-0 z-20 ",children:d}),u("div",{className:`${_t} border-none flex-1`,ref:f,style:{minHeight:`${i}px`},children:g("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${i}px`},children:[t.map((e,n)=>{const a=new Date(r);return a.setDate(r.getDate()+n),u("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(c&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${i}px`},F),onMouseDown:e=>null==O?void 0:O(e,n),onDoubleClick:e=>null==O?void 0:O(e,n),onDragOver:P,onDrop:e=>{L(e,a,void 0,!0)}},`allday-${n}`)}),u("div",{className:"absolute inset-0 pointer-events-none",children:s.map(t=>u(Ir,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:p,calendarRef:v,isBeingDragged:w&&(null==x?void 0:x.eventId)===t.event.id&&"move"===(null==x?void 0:x.mode),hourHeight:b,firstHour:D,onMoveStart:C,onResizeStart:E,onEventUpdate:k,onEventDelete:N,newlyCreatedEventId:T,onDetailPanelOpen:()=>S(null),selectedEventId:M,detailPanelEventId:H,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((c||m)&&t&&n&&!a){const e=A.find(e=>e.id===t);if(e)return z(e),void Y(!0)}I(t)},onEventLongPress:e=>{(c||m)&&I(e)},onDetailPanelToggle:e=>R(e),customDetailPanelContent:j,customEventDetailDialog:$,app:e,isMobile:c,enableTouch:m},t.id))})]})})]}),u("div",{className:"flex-1 bg-white dark:bg-gray-900"})]})]})})})},$r=({app:t,timeSlots:n,weekDaysLabels:a,currentWeekStart:r,currentWeekEvents:o,eventLayouts:l,gridWidth:i,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:h,leftFrozenContentRef:m,calendarRef:v,handleScroll:f,handleCreateStart:y,handleTouchStart:p,handleTouchEnd:b,handleTouchMove:D,handleDragOver:x,handleDrop:w,dragState:C,isDragging:E,handleMoveStart:k,handleResizeStart:N,handleEventUpdate:T,handleEventDelete:S,newlyCreatedEventId:M,setNewlyCreatedEventId:I,selectedEventId:H,setSelectedEventId:R,detailPanelEventId:O,setDetailPanelEventId:P,customDetailPanelContent:L,customEventDetailDialog:j,events:$,setDraftEvent:A,setIsDrawerOpen:z,isCurrentWeek:Y,currentTime:F,HOUR_HEIGHT:V,FIRST_HOUR:W,LAST_HOUR:B})=>{const Z={flexShrink:0},U=e.useRef(t.state.highlightedEventId);return g("div",{className:"flex flex-1 overflow-hidden relative",children:[u("div",{className:"w-12 md:w-20 shrink-0 overflow-hidden relative bg-white dark:bg-gray-900 z-10",children:g("div",{ref:m,children:[n.map((e,t)=>u("div",{className:Vt,children:u("div",{className:`${Wt} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),u("div",{className:"relative",children:u("div",{className:`${Wt} text-[10px] md:text-[12px]`,children:"00:00"})}),Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<W||t>B)return null;return u("div",{className:"absolute left-0 w-full z-20 pointer-events-none flex items-center justify-end",style:{top:`${(t-W)*V}px`,transform:"translateY(-50%)"},children:u("div",{className:Ut,children:Ae(t)})})})()]})}),u("div",{ref:c,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:f,children:g("div",{ref:h,className:"relative flex",style:{width:i,minWidth:"100%"},children:[Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<W||t>B)return null;const n=e.getDay(),r=0===n?6:n-1;return g("div",{className:Zt,style:{top:`${(t-W)*V}px`,width:"100%",height:0,zIndex:20},children:[u("div",{className:"flex items-center w-0"}),u("div",{className:"flex flex-1",children:a.map((e,t)=>u("div",{className:"flex-1 flex items-center",children:u("div",{className:"h-0.5 w-full relative "+(t===r?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===r&&0!==r&&u("div",{className:"absolute w-2 h-2 bg-primary rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),g("div",{className:"grow relative",children:[n.map((e,t)=>u("div",{className:Bt,children:a.map((n,o)=>{const l=new Date(r);return l.setDate(r.getDate()+o),u("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(s&&o===a.length-1?"border-r-0":""),style:Z,onDoubleClick:t=>{null==y||y(t,o,e.hour)},onTouchStart:t=>p(t,o,e.hour),onTouchEnd:b,onTouchMove:D,onDragOver:x,onDrop:t=>{w(t,l,e.hour)},onContextMenu:e=>s&&e.preventDefault()},`${t}-${o}`)})},t)),u("div",{className:`${an} flex`,children:a.map((e,t)=>u("div",{className:`flex-1 relative ${s&&t===a.length-1?"":"border-r"} border-gray-200 dark:border-gray-700`,style:Z},`24-${t}`))}),a.map((e,n)=>{const a=Qe(n,o),i=[];return a.forEach(e=>{const t=wr(e,r);if(t.length>0){const a=t.find(e=>e.dayIndex===n);a&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},a),{dayIndex:n})})}else i.push({event:e})}),o.forEach(e=>{if(e.allDay||e.day===n)return;const t=wr(e,r).find(e=>e.dayIndex===n);t&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),u("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*n}%)`,width:100/7+"%",height:"100%"},children:i.map(({event:e,segmentInfo:a})=>{const r=l.get(n),o=null==r?void 0:r.get(e.id);return u(Ir,{event:e,layout:o,calendarRef:v,isBeingDragged:E&&(null==C?void 0:C.eventId)===e.id&&"move"===(null==C?void 0:C.mode),hourHeight:V,firstHour:W,onMoveStart:k,onResizeStart:N,onEventUpdate:T,onEventDelete:S,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),selectedEventId:H,detailPanelEventId:O,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=t.state.readOnly;if((s||d)&&e&&n&&!a){const t=$.find(t=>t.id===e);if(t)return A(t),void z(!0)}R(e),t.state.highlightedEventId&&(t.highlightEvent(null),U.current=null)},onEventLongPress:e=>{(s||d)&&R(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:L,customEventDetailDialog:j,multiDaySegmentInfo:a,app:t,isMobile:s,enableTouch:d},a?`${e.id}-seg-${n}`:e.id)})},`events-day-${n}`)})]})]})})]})},Ar=({app:a,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i})=>{const{t:d,getWeekDaysLabels:c,locale:h}=Nt(),m=a.getCurrentDate(),v=a.getEvents(),{screenSize:f}=Ia(),y="desktop"!==f,p="mobile"===f?48:80,[b,D]=n(0),x=e.useRef(null),[w,C]=n(!1);r(()=>{C("ontouchstart"in window||navigator.maxTouchPoints>0)},[]),s(()=>{const e=x.current;if(!e)return;const t=()=>{D(e.offsetWidth)};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const E=a.getCustomMobileEventRenderer()||Za,k=t(()=>Rr(m),[m]),[N,T]=n(null),[S,M]=n(null),[I,H]=n(null),[R,O]=n(null),[P,L]=n(!1),[j,$]=n(null),A=e.useRef(null),{HOUR_HEIGHT:z,FIRST_HOUR:F,LAST_HOUR:V,TIME_COLUMN_WIDTH:W,ALL_DAY_HEIGHT:B}=ir,Z=e.useRef(null),U=e.useRef(null),_=e.useRef(null),q=e.useRef(null),X=t(()=>((e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=fe(e.start);a.setHours(0,0,0,0);const r=fe(e.end);return r.setHours(23,59,59,999),r>=t&&a<=n}).map(e=>{const n=fe(e.start),a=Math.floor((n.getTime()-t.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(v,k),[v,k]),G=e.useRef(a.state.highlightedEventId);r(()=>{if(a.state.highlightedEventId!==G.current)if(a.state.highlightedEventId){H(a.state.highlightedEventId);const e=X.find(e=>e.id===a.state.highlightedEventId);if(e&&!e.allDay){const t=Te(e.start),n=U.current;if(n){const e=(t-F)*z;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else H(null);G.current=a.state.highlightedEventId},[a.state.highlightedEventId,X,F,z]);const K=t(()=>((e,t)=>{const n=xr(e,t).filter(e=>e.event.allDay);n.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)a.some(n=>n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex))?t++:n=!0;a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(X,k),[X,k]),J=t(()=>{if(0===K.length)return B;const e=Math.max(...K.map(e=>e.row));return B+e*B},[K,B]),Q=t(()=>((e,t)=>{const n=new Map;for(let a=0;a<7;a++){const r=[];e.forEach(e=>{if(e.allDay)return;const n=wr(e,t);if(n.length>0){const o=n.find(e=>e.dayIndex===a);if(o){const n=o.endHour>=24?23.99:o.endHour,l=Object.assign(Object.assign({},e),{start:he(Se(tt(t,a),o.startHour)),end:he(Se(tt(t,a),n)),day:a});r.push(l)}}else e.day===a&&r.push(e)});const o=lr.calculateDayEventLayouts(r,{viewType:"week"});n.set(a,o)}return n})(X,k),[X,k]),{handleMoveStart:ee,handleCreateStart:te,handleResizeStart:ne,handleCreateAllDayEvent:ae,dragState:re,isDragging:oe}=vr(a,{calendarRef:i,allDayRowRef:Z,viewType:Y.WEEK,onEventsUpdate:(e,t)=>{const n=e(X),r=new Set(n.map(e=>e.id)),o=X.filter(e=>!r.has(e.id)),l=new Set(X.map(e=>e.id)),i=n.filter(e=>!l.has(e.id)),s=n.filter(e=>{if(!l.has(e.id))return!1;const t=X.find(t=>t.id===e.id);return t&&(fe(t.start).getTime()!==fe(e.start).getTime()||fe(t.end).getTime()!==fe(e.end).getTime()||t.day!==e.day||Te(t.start)!==Te(e.start)||Te(t.end)!==Te(e.end)||t.title!==e.title)});o.forEach(e=>a.deleteEvent(e.id)),i.forEach(e=>a.addEvent(e)),s.forEach(e=>a.updateEvent(e.id,e,t))},onEventCreate:e=>{y?($(e),L(!0)):(a.addEvent(e),O(e.id))},onEventEdit:()=>{},currentWeekStart:k,events:X,calculateNewEventLayout:(e,t,n)=>((e,t,n,a)=>{const r=new Date,o=new Date;r.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const l={id:"-1",title:"Temp",day:e,start:he(r),end:he(o),calendarId:"blue",allDay:!1},i=[...a.filter(t=>t.day===e&&!t.allDay),l];return lr.calculateDayEventLayouts(i,{viewType:"week"}).get("-1")||null})(e,t,n,X),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r)=>{const o=r.map(r=>{if(r.id!==e.id)return r;const o=fe(r.start),l=Se(o,n),i=Se(o,a),s=he(l),d=he(i);return Object.assign(Object.assign({},r),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:lr.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,X),TIME_COLUMN_WIDTH:p,isMobile:y}),{handleDrop:le,handleDragOver:ie}=fr({app:a,onEventCreated:e=>{O(e.id)}}),se=t(()=>c(h,"short"),[h,c]),de=t(()=>{if(!y)return[];const e=h.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?c(h,"narrow"):se.map(t=>{if("en"===e){if(t.startsWith("Tu"))return"Tu";if(t.startsWith("Th"))return"Th";if(t.startsWith("Sa"))return"Sa";if(t.startsWith("Su"))return"Su"}return t.charAt(0)})},[y,h,c,se]),ce=t(()=>d("allDay"),[d]),ue=Array.from({length:24},(e,t)=>({hour:t+F,label:Ae(t+F)})),ge=t(()=>{const e=new Date;return e.setHours(0,0,0,0),se.map((t,n)=>{const a=new Date(k);a.setDate(k.getDate()+n);const r=new Date(a);return r.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(h,{month:"short"}),fullDate:new Date(a),isToday:r.getTime()===e.getTime()}})},[k,se,h]),me=e=>{a.updateEvent(e.id,e)},ve=e=>{a.deleteEvent(e)},ye=t(()=>{const e=new Date,t=Rr(e);return k.getTime()===t.getTime()},[k]);r(()=>{T(new Date);const e=setInterval(()=>T(new Date),6e4);return()=>clearInterval(e)},[]);const pe=y?"175%":"100%";return g("div",{className:"df-calendar relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none df-week-view",children:[u(br,{calendar:a,viewType:Y.WEEK,currentDate:m,onPrevious:()=>a.goToPrevious(),onNext:()=>a.goToNext(),onToday:()=>a.goToToday()}),u(jr,{app:a,weekDaysLabels:se,mobileWeekDaysLabels:de,weekDates:ge,currentWeekStart:k,timeGridWidth:b,sidebarWidth:p,allDayAreaHeight:J,organizedAllDaySegments:K,allDayLabelText:ce,isMobile:y,isTouch:w,calendarRef:i,allDayRowRef:Z,topFrozenContentRef:_,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:z,FIRST_HOUR:F,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleEventUpdate:me,handleEventDelete:ve,newlyCreatedEventId:R,setNewlyCreatedEventId:O,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:S,setDetailPanelEventId:M,handleCreateAllDayEvent:ae,handleDragOver:ie,handleDrop:le,customDetailPanelContent:o,customEventDetailDialog:l,events:v,setDraftEvent:$,setIsDrawerOpen:L}),u($r,{app:a,timeSlots:ue,weekDaysLabels:se,currentWeekStart:k,currentWeekEvents:X,eventLayouts:Q,gridWidth:pe,isMobile:y,isTouch:w,scrollerRef:U,timeGridRef:x,leftFrozenContentRef:q,calendarRef:i,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;_.current&&(_.current.scrollLeft=n),q.current&&(q.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:te,handleTouchStart:(e,t,n)=>{if(!y&&!w)return;const a=e.touches[0],r=a.clientX,o=a.clientY,l=e.currentTarget;A.current=setTimeout(()=>{null==te||te({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{A.current&&(clearTimeout(A.current),A.current=null)},handleTouchMove:()=>{A.current&&(clearTimeout(A.current),A.current=null)},handleDragOver:ie,handleDrop:le,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleEventUpdate:me,handleEventDelete:ve,newlyCreatedEventId:R,setNewlyCreatedEventId:O,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:S,setDetailPanelEventId:M,customDetailPanelContent:o,customEventDetailDialog:l,events:v,setDraftEvent:$,setIsDrawerOpen:L,isCurrentWeek:ye,currentTime:N,HOUR_HEIGHT:z,FIRST_HOUR:F,LAST_HOUR:V}),u(E,{isOpen:P,onClose:()=>{L(!1),$(null)},onSave:e=>{v.find(t=>t.id===e.id)?a.updateEvent(e.id,e):a.addEvent(e),L(!1),$(null)},draftEvent:j,app:a})]})},zr={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[Y.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},Yr=(t={})=>{const n=Object.assign(Object.assign({},zr),t),a=t=>e.createElement(Ka,{viewType:Y.WEEK,originalComponent:Ar,app:t.app,config:n,className:"week-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,switcherMode:t.switcherMode,meta:t.meta});return a.displayName="WeekViewAdapter",{type:Y.WEEK,component:a,config:n}},Fr=e.memo(({currentMonth:e,currentYear:a,newlyCreatedEventId:l,screenSize:i,isScrolling:s,isDragging:c,item:h,weekHeight:m,events:v,dragState:f,calendarRef:y,onEventUpdate:p,onEventDelete:b,onMoveStart:D,onCreateStart:x,onResizeStart:w,onDetailPanelOpen:C,onMoreEventsClick:E,onChangeView:k,onSelectDate:N,selectedEventId:T,onEventSelect:S,onEventLongPress:M,detailPanelEventId:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,onCalendarDrop:P,onCalendarDragOver:L,app:j,enableTouch:$})=>{const{t:A,locale:z}=Nt(),[F,V]=n(!1),W=o(null),B=o(null),Z=o(null),U=t(()=>{const e=m-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=e-20;return{maxSlots:Math.min(4,Math.floor(e/17)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/17)))}},[m]);r(()=>s?(V(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):F?(W.current=setTimeout(()=>{V(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[s,F]);const{weekData:_}=h,q=_.days.find(e=>1===e.day),X=`${m}px`,G=t(()=>xr(v,_.startDate),[v,_.startDate]),K=t(()=>((e,t)=>{const n=[],a=new Date(t);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void Q.warn("Event missing start or end date:",e);const r=fe(e.start),o=fe(e.end),l=new Date(r);l.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let s=new Date(i);if(!e.allDay&&0===o.getHours()&&0===o.getMinutes()&&0===o.getSeconds()){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(s=new Date(i),s.setDate(s.getDate()-1))}const c=l.toDateString()!==s.toDateString();if(!c||e.allDay)if(c&&e.allDay){let l=new Date(r);l<t&&(l=new Date(t),l.setHours(0,0,0,0));const i=o>a?a:o;for(;l<=i;){const t=d.PlainDate.from({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate()});n.push(Object.assign(Object.assign({},e),{start:t,end:t,day:l.getDay()})),l.setDate(l.getDate()+1)}}else n.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:r.getDay()}))}),n})(v,_.startDate),[v,_.startDate]),J=t(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==a?a-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,a=!1;for(;!a;)n.some(n=>{var a;const r=Math.abs((null!==(a=n.yPosition)&&void 0!==a?a:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return r&&o})?t+=16:a=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const a=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);a[n]||(a[n]=[]),a[n].push(e)}),a.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),a})(G),[G]),ee=t(()=>{const e=Array(7).fill(0);return J.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)e[a]=Math.max(e[a],n+1)})}),e},[J]),te=t(()=>{const e=Array.from({length:7},()=>new Set);return J.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)a>=0&&a<7&&e[a].add(n)})}),e},[J]),ne=t(()=>{const e=J.flat();for(let t=0;t<_.days.length;t++){const n=_.days[t],a=K.filter(e=>{if(!e.start||!e.end)return fe(e.start).toDateString()===n.date.toDateString();const t=fe(e.start),a=fe(e.end);if(!e.allDay){if(!(0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds())){const e=a.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n.date.toDateString()}}return t.toDateString()===n.date.toDateString()||a.toDateString()===n.date.toDateString()}).filter(t=>{if(!t.allDay)return!0;return!e.some(e=>e.originalEventId===t.id)}),r=te[t],o=ee[t]-1;let l=0;for(let e=0;e<=o;e++)r.has(e)||l++;if(o+1+Math.max(0,a.length-l)>U.maxSlots)return U.maxSlotsWithMore}return U.maxSlots},[_.days,K,J,ee,te,U.maxSlots,U.maxSlotsWithMore]),ae=t(()=>Math.max(0,17*J.length),[J]),re=(t,n)=>{var r;const o=t.date.toLocaleDateString(z,{month:z.startsWith("zh")||z.startsWith("ja")?"short":"long"})===e&&t.year===a;var s;const d=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:Te(e.start)-Te(t.start)))((s=t.date,K.filter(e=>{if(!e.start||!e.end)return fe(e.start).toDateString()===s.toDateString();const t=fe(e.start),n=fe(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===s.toDateString()}return t.toDateString()===s.toDateString()||n.toDateString()===s.toDateString()}))),h=J.flat(),m=d.filter(e=>{if(!e.allDay)return!0;return!h.some(t=>t.originalEventId===e.id)}),v=te[n],F=(null!==(r=ee[n])&&void 0!==r?r:0)-1,V=[];for(let e=0;e<=F;e++)v.has(e)||V.push(e);const W=m.length,_=Math.max(0,W-V.length),q=Math.max(F+1,0)+_,G=q>U.maxSlots,Q=G?U.maxSlotsWithMore:U.maxSlots,ne=V.filter(e=>e<Q).length,ae=Math.max(0,Q-Math.max(F+1,0)),re=Math.min(W,ne+ae),oe=m.slice(0,re),le=W-re,ie=[];let se=0;const de=Math.min(Q,q);for(let e=0;e<de;e++)if(v.has(e))ie.push(u("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));else if(se<oe.length){const e=oe[se];ie.push(u(Ir,{event:e,isAllDay:!!e.allDay,isMonthView:!0,isBeingDragged:c&&f.eventId===e.id&&"move"===f.mode,calendarRef:y,hourHeight:72,firstHour:0,onEventUpdate:p,onEventDelete:b,onMoveStart:D,onResizeStart:w,onDetailPanelOpen:C,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:l,selectedEventId:T,detailPanelEventId:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,app:j,isMobile:"desktop"!==i,enableTouch:$},`${e.id}-${e.day}-${Te(e.start)}-${se}`)),se++}return g("div",{className:`\n df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700 last:border-r-0\n ${o?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,style:{height:X},"data-date":(ce=t.date,`${ce.getFullYear()}-${String(ce.getMonth()+1).padStart(2,"0")}-${String(ce.getDate()).padStart(2,"0")}`),onDoubleClick:e=>null==x?void 0:x(e,t.date),onTouchStart:e=>{if("mobile"!==i&&!$)return;const n=e.touches[0],a=n.clientX,r=n.clientY;Z.current={x:a,y:r},B.current=setTimeout(()=>{null==x||x(e,t.date),B.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(B.current&&Z.current){const t=Math.abs(e.touches[0].clientX-Z.current.x),n=Math.abs(e.touches[0].clientY-Z.current.y);(t>10||n>10)&&(clearTimeout(B.current),B.current=null)}},onTouchEnd:()=>{B.current&&(clearTimeout(B.current),B.current=null),Z.current=null},onDragOver:L,onDrop:e=>null==P?void 0:P(e,t.date),children:[g("div",{className:"df-month-date-number-container flex items-center justify-between px-2 h-[33px] relative z-20",children:[u("div",{className:"flex-1"}),u("div",{className:"flex items-center",children:u("span",{className:`\n df-month-date-number inline-flex items-center justify-center h-6 min-w-6 rounded-full text-sm font-medium whitespace-nowrap px-1\n ${t.isToday?"bg-primary text-primary-foreground":o?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:1===t.day&&"desktop"===i?t.date.toLocaleDateString(z,{month:"short",day:"numeric"}):t.day})})]}),g("div",{className:"flex-1 overflow-hidden px-1",children:[ie,G&&g("div",{className:"df-month-more-events text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline text-center md:text-left font-medium md:font-normal relative z-20 bg-white dark:bg-gray-900",onClick:e=>{e.stopPropagation(),E?E(t.date):(null==N||N(t.date),null==k||k(Y.DAY))},children:["+",le," ",u("span",{className:"hidden md:inline",children:A("more")})]})]})]},`day-${t.date.getTime()}`);var ce},oe=t(()=>q?q.date.toLocaleDateString(z,{month:"long",year:"numeric"}):"",[q,z]);return g("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:X},children:[q&&u("div",{className:`\n df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${F?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},children:u("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:oe})}),u("div",{className:"h-full flex flex-col",children:g("div",{className:"calendar-week relative h-full",children:[u("div",{className:"grid grid-cols-7 h-full",children:_.days.map((e,t)=>re(e,t))}),J.length>0&&u("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${ae}px`,zIndex:10},children:J.slice(0,ne).map((e,t)=>u("div",{className:"absolute inset-0",children:e.map(e=>u(Ir,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:y,hourHeight:72,firstHour:0,onEventUpdate:p,onEventDelete:b,onMoveStart:D,onResizeStart:w,isBeingDragged:c&&f.eventId===e.event.id&&"move"===f.mode,isBeingResized:c&&f.eventId===e.event.id&&"resize"===f.mode,newlyCreatedEventId:l,onDetailPanelOpen:C,selectedEventId:T,onEventSelect:S,onEventLongPress:M,detailPanelEventId:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,app:j,isMobile:"desktop"!==i,enableTouch:$},e.id))},`layer-${t}`))})]})})]})});Fr.displayName="WeekComponent";const Vr=({app:e,customDetailPanelContent:a,customEventDetailDialog:l,calendarRef:i})=>{const{getWeekDaysLabels:s,getMonthLabels:d,locale:c}=Nt(),h=e.getCurrentDate(),m=e.getEvents(),v=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),f=o(null),y=t(()=>{const e=f.current;return e&&e.length===m.length&&e.every((e,t)=>e===m[t])?e:(f.current=m,m)},[m]),p=t(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),a=0===n?-6:1-n;return t.setDate(t.getDate()+a),t.setHours(0,0,0,0),t},n=(t,n)=>{const a=e.get(t);a?a.push(n):e.set(t,[n])};return y.forEach(e=>{if(!e.start)return;const a=fe(e.start),r=e.end?fe(e.end):a,o=new Date(a);o.setHours(0,0,0,0);const l=new Date(r);l.setHours(0,0,0,0);let i=new Date(l);if(!e.allDay){0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds()||i.setDate(i.getDate()-1)}i<o&&(i=new Date(o));const s=t(o),d=t(i);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[y]),{screenSize:b}=Ia(),[D,x]=n(!1);r(()=>{x("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const w=e.getCustomMobileEventRenderer()||Za,[C,E]=n(119),[k,N]=n(!1),T=o(C),S=o([]),[M,I]=n(null),[H,R]=n(!1),[O,P]=n(null),[L,j]=n(null),$=o(e.state.highlightedEventId);r(()=>{e.state.highlightedEventId?j(e.state.highlightedEventId):$.current&&j(null),$.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const[A,z]=n(null),F=t(()=>{const e=h.getDay(),t=h.getDate()-e+(0===e?-6:1),n=new Date(h);return n.setDate(t),n.setHours(0,0,0,0),n},[h]),{handleMoveStart:V,handleCreateStart:W,handleResizeStart:B,dragState:Z,isDragging:U}=vr(e,{calendarRef:i,viewType:Y.MONTH,onEventsUpdate:(t,n)=>{const a=t(y),r=new Set(a.map(e=>e.id)),o=y.filter(e=>!r.has(e.id)),l=new Set(y.map(e=>e.id)),i=a.filter(e=>!l.has(e.id)),s=a.filter(e=>{if(!l.has(e.id))return!1;const t=y.find(t=>t.id===e.id);return t&&(fe(t.start).getTime()!==fe(e.start).getTime()||fe(t.end).getTime()!==fe(e.end).getTime()||t.day!==e.day||Te(t.start)!==Te(e.start)||Te(t.end)!==Te(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});o.forEach(t=>e.deleteEvent(t.id)),i.forEach(t=>e.addEvent(t)),s.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{"desktop"!==b?(P(t),R(!0)):e.addEvent(t)},onEventEdit:e=>{I(e.id)},currentWeekStart:F,events:y}),{handleDrop:_,handleDragOver:q}=fr({app:e,onEventCreated:e=>{I(e.id)}}),X=t(()=>s(c,"short"),[c,s]),{currentMonth:G,currentYear:K,isScrolling:J,virtualData:Q,scrollElementRef:ee,handleScroll:te,handlePreviousMonth:ne,handleNextMonth:ae,handleToday:re,setScrollTop:oe}=Ha({currentDate:h,weekHeight:C,onCurrentMonthChange:(t,n)=>{const a=c.startsWith("zh")||c.startsWith("ja"),r=d(c,a?"short":"long").indexOf(t);r>=0&&e.setVisibleMonth(new Date(n,r,1))},initialWeeksToLoad:156,locale:c,isEnabled:k}),le=o(0),[ie,se]=n(0),de=t(()=>ie-6*C,[ie,C]),{visibleWeeks:ce,startIndex:ue}=t(()=>{const{visibleItems:e,displayStartIndex:t}=Q,n=e.findIndex(e=>e.index===t);if(-1===n)return S.current.length>0?{visibleWeeks:S.current,startIndex:le.current}:{visibleWeeks:[],startIndex:t};const a=e.slice(n,n+8);return a.length>=6&&(S.current=a,le.current=t),{visibleWeeks:a,startIndex:t}},[Q]),ge=t(()=>ue*C,[ue,C]),he=t(()=>{const e=Q.totalHeight,t=ue*C+16*C+de;return Math.max(0,e-t)},[Q.totalHeight,ue,C,de]);r(()=>{const e=ee.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(se(t),!k&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==T.current){const t=e.scrollTop;if(t>0){const a=Math.round(t/T.current)*n;e.scrollTop=a,oe(a)}}E(n),T.current=n,requestAnimationFrame(()=>{N(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[ee,k,oe]),r(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.floor(e/6));E(t)},[]);const me=t=>{e.updateEvent(t.id,t)},ve=t=>{e.deleteEvent(t)},ye=t=>{e.changeView(t)};return g("div",{className:jt,children:[u(br,{calendar:e,viewType:Y.MONTH,currentDate:h,customTitle:c.startsWith("zh")||c.startsWith("ja")?`${K}年${G}`:`${G} ${K}`,onPrevious:()=>{e.goToPrevious(),ne()},onNext:()=>{e.goToNext(),ae()},onToday:()=>{e.goToToday(),re()}}),u("div",{className:"df-week-header-row sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:u("div",{className:"grid grid-cols-7 px-2",children:X.map((e,t)=>u("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},t))})}),g("div",{ref:ee,className:Ft,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:k?"visible":"hidden"},onScroll:te,children:[u("div",{style:{height:ge}}),ce.map((t,n)=>{var r;const o=null!==(r=p.get(t.weekData.startDate.getTime()))&&void 0!==r?r:[],s=5===n?Object.assign(Object.assign({},t),{height:t.height+de}):t;return u(Fr,{item:s,weekHeight:C,currentMonth:G,currentYear:K,screenSize:b,isScrolling:J,calendarRef:i,events:o,onEventUpdate:me,onEventDelete:ve,onMoveStart:V,onCreateStart:W,onResizeStart:B,isDragging:U,dragState:Z,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:ye,onSelectDate:e.selectDate,selectedEventId:L,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable;if(("desktop"!==b||D)&&t&&n){const e=y.find(e=>e.id===t);if(e)return P(e),void R(!0)}j(t)},onEventLongPress:e=>{("desktop"!==b||D)&&j(e)},detailPanelEventId:A,onDetailPanelToggle:z,customDetailPanelContent:a,customEventDetailDialog:l,onCalendarDrop:_,onCalendarDragOver:q,calendarSignature:v,app:e,enableTouch:D},`week-${t.weekData.startDate.getTime()}`)}),u("div",{style:{height:he}})]}),u(w,{isOpen:H,onClose:()=>{R(!1),P(null)},onSave:t=>{y.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),R(!1),P(null)},draftEvent:O,app:e})]})},Wr={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[Y.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[Y.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}},Br=(t={})=>{const n=Object.assign(Object.assign({},Wr),t),a=t=>e.createElement(Ka,{viewType:Y.MONTH,originalComponent:Vr,app:t.app,config:n,className:"month-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,switcherMode:t.switcherMode,meta:t.meta});return a.displayName="MonthViewAdapter",{type:Y.MONTH,component:a,config:n}};const Zr=e.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:r,onMoreEventsClick:o,moreCount:l=0})=>{const{t:i}=Nt(),s=e.getDate(),d=1===s,c=e.toLocaleDateString(n,{month:"short"}).toUpperCase(),h=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;return g("div",{className:`\n relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800\n ${d?"border-l-2 border-l-primary dark:border-l-primary":""}\n overflow-hidden bg-white dark:bg-gray-900 select-none\n `,style:{aspectRatio:"1/1"},onClick:()=>a(e),onDoubleClick:t=>null==r?void 0:r(t,e),"data-date":h,children:[g("div",{className:"flex items-center px-1 py-1 shrink-0 h-6",children:[d&&u("span",{className:"text-[9px] font-bold text-primary-foreground bg-primary px-1 py-0.5 rounded-sm leading-none",children:c}),u("span",{className:"text-[10px] font-medium ml-auto "+(t?"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center":"text-gray-700 dark:text-gray-300"),children:s})]}),l>0&&u("div",{className:"absolute bottom-0.5 left-1 z-20",children:g("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",l," ",i("more")]})})]})});Zr.displayName="YearDayCell";const Ur=({segment:e,columnsPerRow:t,isDragging:a,isSelected:l,onMoveStart:i,onResizeStart:s,onEventSelect:d,detailPanelEventId:c,onDetailPanelToggle:v,newlyCreatedEventId:f,onDetailPanelOpen:y,customDetailPanelContent:p,customEventDetailDialog:b,app:D,calendarRef:x})=>{const{event:w,startCellIndex:C,endCellIndex:E,visualRowIndex:k,isFirstSegment:N,isLastSegment:T}=e,S=o(null),M=o(null),[I,H]=n(null),R=c===e.id,O=!(null==D?void 0:D.state.readOnly),P=C/t*100,L=(E-C+1)/t*100,j=w.calendarId||"blue",$=l?Le(j):Oe(j),A=l?"#fff":Pe(j),z=je(j),Y=!!w.allDay,F=Y?Dr(w):null,V=18*k,W=()=>{var t;const n=null===(t=S.current)||void 0===t?void 0:t.getBoundingClientRect();if(n){const e=200,t=300;let a=n.bottom+10,r=n.left;a+e>window.innerHeight&&(a=n.top-e-10),r+t>window.innerWidth&&(r=window.innerWidth-t-10),H({top:a,left:r,eventHeight:n.height,eventMiddleY:n.top+n.height/2})}null==v||v(e.id)};r(()=>{f===w.id&&!R&&N&&setTimeout(()=>{W(),null==y||y()},50)},[f,w.id,R,y,N]);const B=e=>{const t="left"===e,n=t?N:T;return w.allDay&&n&&s&&O?u("div",{className:`resize-handle absolute ${t?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),s(e,w,t?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null};return g(h,{children:[g("div",{ref:S,className:"df-year-event absolute z-30 text-[11px] px-1 overflow-hidden whitespace-nowrap cursor-pointer transition-colors group",style:{left:`calc(${P}% + 2px)`,top:`${V}px`,height:"16px",backgroundColor:$,color:A,opacity:a?.6:1,width:`calc(${L}% - 4px)`,pointerEvents:a?"none":"auto",borderRadius:N&&T?"0.25rem":N?"0.25rem 0 0 0.25rem":T?"0 0.25rem 0.25rem 0":"0"},"data-segment-days":E-C+1,"data-event-id":w.id,onMouseDown:e=>{e.stopPropagation(),i&&i(e,w)},onClick:e=>{e.preventDefault(),e.stopPropagation(),d&&d(w.id)},onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),W()},onTouchStart:e=>{e.stopPropagation(),d&&d(w.id),i&&i(e,w)},title:w.title,children:[B("left"),(()=>{if(w.allDay){const t=()=>e.isFirstSegment?w.title:"···";return g("div",{className:"df-year-event-content flex items-center min-w-0 w-full pointer-events-auto h-full",children:[e.isFirstSegment&&Dr(w)&&u("div",{className:"df-year-event-icon shrink-0 mr-1",children:u("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:je(j),width:"12px",height:"12px"},children:Dr(w)})}),u("div",{className:"flex-1 min-w-0",children:u("div",{className:"df-year-event-title font-medium text-[11px] leading-none whitespace-nowrap overflow-hidden",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t()})}),e.isLastSegment&&!e.isFirstSegment&&u("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:u("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=e.isFirstSegment?w.title:"";return g("div",{className:"df-year-event-content w-full h-full flex items-center overflow-hidden gap-1 pointer-events-auto",children:[!Y&&u("span",{style:{backgroundColor:z},className:"df-year-event-indicator inline-block w-0.75 h-3 shrink-0 rounded-full"}),Y&&F&&u("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:F}),u("span",{className:"df-year-event-title w-full block font-medium whitespace-nowrap overflow-hidden leading-none",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t})]})})(),B("right")]}),(()=>{if(!R||!x)return null;const e=()=>{null==v||v(null),d&&d(null)};if(b){const t=b,n={event:w,isOpen:R,isAllDay:Y,onClose:e,app:D,onEventUpdate:e=>null==D?void 0:D.updateEvent(e.id,e),onEventDelete:e=>null==D?void 0:D.deleteEvent(e)};if("undefined"==typeof window||"undefined"==typeof document)return null;const a=document.body;return a?m.createPortal(u(t,Object.assign({},n)),a):null}return I?p?u(kr,{event:w,position:I,panelRef:M,isAllDay:Y,onClose:e,contentRenderer:p,onEventUpdate:e=>null==D?void 0:D.updateEvent(e.id,e),onEventDelete:e=>null==D?void 0:D.deleteEvent(e),eventVisibility:"visible",calendarRef:x,selectedEventElementRef:S}):u(Er,{event:w,position:I,panelRef:M,isAllDay:Y,onClose:e,app:D,onEventUpdate:e=>null==D?void 0:D.updateEvent(e.id,e),onEventDelete:e=>null==D?void 0:D.deleteEvent(e),eventVisibility:"visible",calendarRef:x,selectedEventElementRef:S}):null})()]})},_r=e.memo(({rowDays:e,events:n,columnsPerRow:a,app:r,calendarRef:o,locale:l,isDragging:i,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:h,selectedEventId:m,onEventSelect:v,onMoreEventsClick:f,newlyCreatedEventId:y,onDetailPanelOpen:p,detailPanelEventId:b,onDetailPanelToggle:D,customDetailPanelContent:x,customEventDetailDialog:w})=>{const C=new Date;C.setHours(0,0,0,0);const E=t(()=>function(e,t,n){if(0===t.length)return[];const a=t[0],r=t[t.length-1],o=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime(),i=e.filter(e=>{if(!e.start)return!1;const t=fe(e.start),n=e.end?fe(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=l&&r>=o});i.sort((e,t)=>{const n=fe(e.start).getTime(),a=e.end?fe(e.end).getTime():n,r=fe(t.start).getTime(),o=a-n,l=(t.end?fe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const s=[],d=[];return i.forEach(e=>{const r=fe(e.start),i=e.end?fe(e.end):r,c=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime();let g=-1,h=-1;const m=Math.round((c-o)/864e5);g=m>=0?m:0;const v=Math.round((u-o)/864e5);h=v<t.length?v:t.length-1,g=Math.max(0,Math.min(g,n-1)),h=Math.max(0,Math.min(h,n-1));const f=c>=o,y=u<=l;let p=0;for(;;){let e=!1;d[p]||(d[p]=[]);for(let t=g;t<=h;t++)if(d[p][t]){e=!0;break}if(!e){for(let e=g;e<=h;e++)d[p][e]=!0;break}p++}s.push({id:`${e.id}_${a.getTime()}`,event:e,startCellIndex:g,endCellIndex:h,isFirstSegment:f,isLastSegment:y,visualRowIndex:p})}),s}(n,e,a),[n,e,a]),{visibleSegments:k,moreCounts:N}=t(()=>{const t=new Array(e.length).fill(0);E.forEach(n=>{const a=Math.max(0,n.startCellIndex),r=Math.min(e.length-1,n.endCellIndex);for(let e=a;e<=r;e++)t[e]++});const n=[],a=new Array(e.length).fill(0);return E.forEach(r=>{let o=!0;const l=Math.max(0,r.startCellIndex),i=Math.min(e.length-1,r.endCellIndex);for(let e=l;e<=i;e++){const n=t[e]>3?1:2;if(r.visualRowIndex>n){o=!1;break}}if(o)n.push(r);else for(let e=l;e<=i;e++)a[e]++}),{visibleSegments:n,moreCounts:a}},[E,e.length]);return g("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${a}, 1fr)`},children:[e.map((e,t)=>{const n=e.getTime()===C.getTime();return u(Zr,{date:e,isToday:n,locale:l,onSelectDate:e=>{r.selectDate(e)},onCreateStart:h,onMoreEventsClick:f,moreCount:N[t]},e.getTime())}),u("div",{className:"absolute inset-0 pointer-events-none",style:{top:26,bottom:0,left:0,right:0},children:u("div",{className:"relative w-full h-full",children:k.map(e=>u("div",{className:"pointer-events-auto",children:u(Ur,{segment:e,columnsPerRow:a,isDragging:i&&s.eventId===e.event.id,isSelected:m===e.event.id,onMoveStart:d,onResizeStart:c,onEventSelect:v,onDetailPanelToggle:D,newlyCreatedEventId:y,onDetailPanelOpen:p,calendarRef:o,app:r,detailPanelEventId:b,customDetailPanelContent:x,customEventDetailDialog:w})},e.id))})})]})});_r.displayName="YearRowComponent";const qr=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var h;const{locale:m}=Nt(),v=e.getCurrentDate(),f=v.getFullYear(),y=e.getEvents(),p=o(null),[b,D]=n(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[x,w]=n(!1),[C,E]=n(null),[k,N]=n(null),[T,S]=n(null);r(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(E(null),N(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),r(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0].contentRect.width,n=Math.floor(t/80);D(Math.max(1,n)),w(!0)});return t.observe(e),()=>t.disconnect()},[]);const{handleMoveStart:M,handleResizeStart:I,handleCreateStart:H,dragState:R,isDragging:O}=vr(e,{calendarRef:l,viewType:Y.YEAR,onEventsUpdate:(t,n)=>{t(y).forEach(t=>{const a=y.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:y,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{S(e.id)}}),P=null!==(h=null==c?void 0:c.showTimedEventsInYearView)&&void 0!==h&&h,L=a((t,n)=>{if(P)null==H||H(t,n);else{const t=d.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),a={id:`event-${Date.now()}`,title:"",start:t,end:t,allDay:!0};e.addEvent(a),S(a.id)}},[P,H,e]),j=t(()=>{const e=[],t=new Date(f,0,1),n=new Date(f,11,31),a=new Date(t);for(;a<=n;)e.push(new Date(a)),a.setDate(a.getDate()+1);return e},[f]),$=t(()=>function(e,t){const n=[];for(let a=0;a<e.length;a+=t)n.push(e.slice(a,a+t));return n}(j,b),[j,b]),A=t(()=>{const e=new Date(f,0,1),t=new Date(f,11,31,23,59,59);return y.filter(n=>{if(!n.start)return!1;if(!P&&!n.allDay)return!1;const a=fe(n.start),r=n.end?fe(n.end):a;return a<=t&&r>=e})},[y,f,P]);return g("div",{className:jt,children:[u(br,{calendar:e,viewType:Y.YEAR,currentDate:v,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${f}年`:`${f}`,onPrevious:()=>{const t=new Date(v);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(v);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),u("div",{ref:p,className:`${Ft}`,style:{overflow:"hidden auto"},children:u("div",{className:"w-full flex flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:x?1:0,transition:"opacity 0.2s ease"},children:$.map((t,n)=>u(_r,{rowDays:t,events:A,columnsPerRow:b,app:e,calendarRef:l,locale:m,isDragging:O,dragState:R,onMoveStart:M,onResizeStart:I,onCreateStart:L,selectedEventId:C,onEventSelect:E,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:T,onDetailPanelOpen:()=>S(null),detailPanelEventId:k,onDetailPanelToggle:N,customDetailPanelContent:i,customEventDetailDialog:s},n))})})]})};function Xr(e,t,n){const a=new Date(n,t,1),r=new Date(n,t+1,0).getDate(),o=a.getDay(),l=a.getTime(),i=new Date(n,t,r,23,59,59,999).getTime(),s=e.filter(e=>{if(!e.start)return!1;const t=fe(e.start),n=e.end?fe(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=i&&r>=l});s.sort((e,t)=>{const n=fe(e.start).getTime(),a=e.end?fe(e.end).getTime():n,r=fe(t.start).getTime(),o=a-n,l=(t.end?fe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const d=[],c=[];s.forEach(e=>{const a=fe(e.start),r=e.end?fe(e.end):a,s=new Date(Math.max(a.getTime(),l)),u=new Date(Math.min(r.getTime(),i)),g=s.getDate(),h=u.getDate(),m=o+(g-1),v=o+(h-1),f=a.getMonth()===t&&a.getFullYear()===n,y=r.getMonth()===t&&r.getFullYear()===n;let p=0;for(;;){let e=!1;c[p]||(c[p]=[]);for(let t=m;t<=v;t++)if(c[p][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)c[p][e]=!0;break}p++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:y,visualRowIndex:p,monthIndex:t})});const u=d.length>0?Math.max(...d.map(e=>e.visualRowIndex)):-1;return{segments:d,maxVisualRow:u}}const Gr=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var h;const{locale:m,getWeekDaysLabels:v}=Nt(),f=e.getCurrentDate(),y=f.getFullYear(),p=e.getEvents(),b=new Date;b.setHours(0,0,0,0);const D=o(null),x=o(null),w=o(null),[C,E]=n(0),[k,N]=n(0),[T,S]=n(null),[M,I]=n(null),[H,R]=n(null);r(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(S(null),I(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const O=t(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(y,t,1),a=new Date(y,t+1,0).getDate(),r=n.getDay()+a;r>e&&(e=r)}return e},[y]),{handleMoveStart:P,handleResizeStart:L,handleCreateStart:j,dragState:$,isDragging:A}=vr(e,{calendarRef:l,viewType:Y.YEAR,onEventsUpdate:(t,n)=>{t(p).forEach(t=>{const a=p.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:p,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{R(e.id)}}),z=null!==(h=null==c?void 0:c.showTimedEventsInYearView)&&void 0!==h&&h,F=a((t,n)=>{if(z)null==j||j(t,n);else{const t=d.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),a={id:`event-${Date.now()}`,title:"",start:t,end:t,allDay:!0};e.addEvent(a),R(a.id)}},[z,j,e]),V=t(()=>{const e=v(m,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(m.startsWith("zh"))return e.charAt(e.length-1);const t=e.substring(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),n=[];for(let e=0;e<O;e++)n.push(t[e%7]);return n},[m,v,O]),W=t(()=>{const e=new Date(y,0,1),t=new Date(y,11,31,23,59,59);return p.filter(n=>{if(!n.start)return!1;if(!z&&!n.allDay)return!1;const a=fe(n.start),r=n.end?fe(n.end):a;return a<=t&&r>=e})},[p,y,z]),B=t(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(y,t,1),a=new Date(y,t+1,0).getDate(),r=n.getDay(),o=[];for(let e=0;e<r;e++)o.push(null);for(let e=1;e<=a;e++)o.push(new Date(y,t,e));for(;o.length<O;)o.push(null);const l=n.toLocaleDateString(m,{month:"short"}),i=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Xr(W,t,y),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:i,days:o,eventSegments:s,minHeight:u})}return e},[y,m,O,W]),Z=a(e=>{const t=e.currentTarget;D.current&&(D.current.scrollLeft=t.scrollLeft),x.current&&(x.current.scrollTop=t.scrollTop)},[]);r(()=>{const e=()=>{if(w.current){const e=w.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;N(e=>e!==t?t:e),E(e=>e!==n?n:e)}},t=w.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[B]);return g("div",{className:"h-full bg-white dark:bg-gray-900 overflow-hidden select-none",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},children:[u("div",{className:"col-span-2",children:u(br,{calendar:e,viewType:Y.YEAR,currentDate:f,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${y}年`:`${y}`,onPrevious:()=>{const t=new Date(f);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(f);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),u("div",{className:"bg-gray-50 dark:bg-gray-900 border-r border-b border-gray-200 dark:border-gray-800 z-30"}),u("div",{ref:D,className:"overflow-hidden bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800",children:g("div",{className:"flex",style:{minWidth:`calc(1352px + ${C}px)`},children:[u("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${O}, minmax(0, 1fr))`,minWidth:"1352px"},children:V.map((e,t)=>{const n=t%7;return u("div",{className:"text-center py-2 text-[10px] font-bold tracking-wider border-r border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},t)})}),C>0&&u("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${C}px`}})]})}),u("div",{ref:x,className:"overflow-hidden bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700",children:g("div",{className:"flex flex-col",children:[B.map(e=>u("div",{className:"flex items-center justify-center border-b border-gray-200 dark:border-gray-700 font-bold text-[10px] text-gray-500 dark:text-gray-400",style:{height:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),k>0&&u("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${k}px`}})]})}),u("div",{ref:w,className:"overflow-auto",onScroll:Z,children:u("div",{className:"flex flex-col",style:{minWidth:"1352px"},children:B.map(t=>g("div",{className:"relative",style:{height:`${t.minHeight}px`},children:[u("div",{className:"grid absolute inset-0 z-0",style:{gridTemplateColumns:`repeat(${O}, minmax(0, 1fr))`},children:t.days.map((t,n)=>{const a=n%7,r=0===a||6===a;if(!t)return u("div",{className:"bg-gray-50/80 dark:bg-gray-800/40 border-r border-b border-gray-200 dark:border-gray-700 "+(r?"df-year-view-weekend-cell":"")},`empty-${n}`);const o=(e=>e.getTime()===b.getTime())(t),l=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return u("div",{"data-date":l,className:`\n relative flex items-start justify-end p-0.5 border-r border-b border-gray-200 dark:border-gray-700\n cursor-pointer hover:bg-blue-100 dark:hover:bg-primary/20 transition-colors\n ${r?"bg-blue-50 dark:bg-blue-900/30 df-year-view-weekend-cell":""}\n `,onClick:()=>e.selectDate(t),onDoubleClick:e=>F(e,t),children:u("span",{className:`\n text-[10px] font-medium w-5 h-5 flex items-center justify-center rounded-full\n ${o?"bg-primary text-primary-foreground font-bold shadow-sm":"text-gray-700 dark:text-gray-300"}\n `,children:t.getDate()})},t.getTime())})}),t.eventSegments.length>0&&u("div",{className:"absolute inset-0 pointer-events-none z-20",style:{top:20},children:u("div",{className:"relative w-full h-full",children:t.eventSegments.map(t=>u("div",{className:"pointer-events-auto",children:u(Ur,{segment:t,columnsPerRow:O,isDragging:A&&$.eventId===t.event.id,isSelected:T===t.event.id,onMoveStart:P,onResizeStart:L,onEventSelect:S,onDetailPanelToggle:I,newlyCreatedEventId:H,onDetailPanelOpen:()=>R(null),calendarRef:l,app:e,detailPanelEventId:M,customDetailPanelContent:i,customEventDetailDialog:s})},t.id))})})]},t.monthIndex))})})]})},Kr=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return u("fixed-week"===n?Gr:qr,Object.assign({},e,{config:e.config}))},Jr={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},Qr=(t={})=>{const n=Object.assign(Object.assign({},Jr),t);t.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:t.mode}));const a=t=>e.createElement(Ka,{viewType:Y.YEAR,originalComponent:Kr,app:t.app,config:n,className:"year-view-factory",customDetailPanelContent:t.customDetailPanelContent,customEventDetailDialog:t.customEventDetailDialog,calendarRef:t.calendarRef,meta:t.meta});return a.displayName="YearViewAdapter",{type:Y.YEAR,component:a,config:n}},eo={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function to(e={}){const t=Object.assign(Object.assign({},eo),e);let n;const a={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=it(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const l=a.getById(e);if(!l)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},l),o);if(t.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=it(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=fe(t.start);n.setHours(0,0,0,0);const a=new Date(e);return a.setHours(0,0,0,0),n.getTime()===a.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const a=fe(n.start),r=fe(n.end);return a>=e&&a<=t||r>=e&&r<=t||a<=e&&r>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>it(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function r(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a}return{name:"events",config:t,install:e=>{n=e,Q.log("Events plugin installed - providing event management services")},api:a}}export{pt as CalendarApp,Ir as CalendarEvent,X as CalendarRegistry,yn as ColorPicker,Ga as DayFlowCalendar,Ln as DefaultEventDetailDialog,Er as DefaultEventDetailPanel,kr as EventDetailPanelWithContent,lr as EventLayoutCalculator,se as LOCALES,kt as LocaleContext,$e as TIME_STEP,Pa as ThemeProvider,br as ViewHeader,Y as ViewType,Ee as addDays,wn as buildParseRegExp,ot as calculateDayIndex,xt as capitalize,ga as conditionalTheme,Ca as convertDateEvent,Ea as convertDateEventWithTimeZone,xa as createAllDayEvent,Se as createDateWithHour,Lr as createDayView,mr as createDragPlugin,ya as createEvent,rt as createEventWithDate,ct as createEventWithRealDate,ba as createEvents,to as createEventsPlugin,Br as createMonthView,ye as createTemporalWithHour,wa as createTimedEvent,pa as createTimezoneEvent,Da as createTimezoneEvents,Yr as createWeekView,Qr as createYearView,ta as dateToPlainDate,na as dateToPlainDateTime,aa as dateToZonedDateTime,we as daysBetween,Ce as daysDifference,le as de,te as en,ie as es,Te as extractHourFromDate,la as extractHourFromTemporal,Gn as formatDate,qn as formatDateConsistent,ze as formatEventTimeRange,Xn as formatMonthYear,Nn as formatTemporal,Ae as formatTime,oe as fr,qe as generateDayData,mt as generateUniKey,Xe as generateWeekData,Je as generateWeekRange,Ke as generateWeeksData,et as getAllDayEventsForDay,_e as getCurrentWeekDates,tt as getDateByDayIndex,ka as getDateObj,st as getDayIndexByDate,Ie as getEndOfDay,xe as getEndOfTemporal,Oe as getEventBgColor,Fe as getEventEndHour,Pe as getEventTextColor,Qe as getEventsForDay,dt as getEventsForWeek,Dt as getIntlLabel,je as getLineColor,Ct as getMonthLabels,Ge as getMonthYearOfWeek,da as getPlainDate,Ta as getSearchHeaderInfo,Le as getSelectedBgColor,Me as getStartOfDay,De as getStartOfTemporal,ht as getTestEvents,wt as getWeekDaysLabels,Ue as getWeekRange,En as getZoneId,Sa as groupSearchResults,ge as isDate,vt as isDeepEqual,gt as isEventEqual,lt as isEventInWeek,Re as isMultiDayEvent,be as isMultiDayTemporalEvent,Kn as isPlainDate,Jn as isPlainDateTime,He as isSameDay,pe as isSamePlainDate,sa as isSameTemporal,ce as isValidLocale,Qn as isZonedDateTime,ae as ja,re as ko,ha as mergeClasses,Dn as mergeFormatTemplate,Be as monthNames,ee as normalizeCssWidth,Na as normalizeDate,de as normalizeLocale,kn as normalizeToZoned,ke as now,bn as pad,Cn as parseTemporalString,ra as plainDateTimeToDate,oa as plainDateToDate,it as recalculateEventDays,ma as resolveAppliedTheme,Ye as roundToTimeStep,ia as setHourInTemporal,Ze as shortMonthNames,Et as t,ea as temporalToDate,ua as themeClasses,ca as themeCn,Ne as today,nt as updateEventDateAndDay,ut as updateEventWithRealDate,bt as useCalendarApp,hr as useDrag,vr as useDragForView,Nt as useLocale,Un as useResponsiveConfig,Ia as useResponsiveMonthConfig,La as useTheme,Ha as useVirtualMonthScroll,_n as useVirtualScroll,Ve as weekDays,We as weekDaysFullName,ne as zh,ve as zonedDateTimeToDate};