@dayflow/core 2.0.5 → 2.0.6
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/components/common/CalendarPicker.d.ts +19 -0
- package/dist/components/sidebar/components/ImportCalendarDialog.d.ts +11 -0
- package/dist/components/weekView/AllDayRow.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/locale/types.d.ts +1 -1
- package/dist/styles/classNames.d.ts +2 -2
- package/dist/styles.css +27 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
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{hexToHsl as f,lightnessToSliderValue as y,BlossomColorPicker as p,DEFAULT_COLORS as b,hslToHex as D}from"@dayflow/blossom-color-picker";import{SketchPicker as x,PhotoshopPicker as w}from"react-color";import{PanelRightClose as C,PanelRightOpen as E,ChevronLeft as k,ChevronRight as N,ChevronsUpDown as T,Check as S,ChevronsLeft as M,ChevronsRight as I,MoveRight as H,ChevronDown as R,Plus as O,Search as P,Loader2 as L,ArrowLeft as j,X as $,CalendarDays as A,Calendar as z,Gift as Y,Heart as F,Star as V,MapPin as W}from"lucide-react";import{createRoot as B}from"react-dom/client";var Z;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(Z||(Z={}));const U=100,_=8,q=150,X=80,G=90,K=119;class J{constructor(e=U){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 ee{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 te=new ee;function ne(){return te}function ae(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 re=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 oe(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const le={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"}},ie={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:"明天"}},se={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:"明日"}},de={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:"내일"}},ce={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"}},ue={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"}},ge={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"}},he={en:le,zh:ie,ja:se,ko:de,fr:ce,de:ue,es:ge};function me(e){const t=e.split("-")[0].toLowerCase();return t in he?t:"en"}function ve(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function fe(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 ye(e){return e instanceof Date}function pe(e,t=d.Now.timeZoneId()){return d.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function be(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function De(e){return new Date(e.epochMilliseconds)}function xe(e,t){return fe(e)?function(e,t=d.Now.timeZoneId()){return De(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):De(e)}function we(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return fe(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 Ce(e,t){const n=fe(e)?e:e.toPlainDate(),a=fe(t)?t:t.toPlainDate();return 0===d.PlainDate.compare(n,a)}function Ee(e,t){return!Ce(e,t)}function ke(e,t=d.Now.timeZoneId()){return(fe(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:0,minute:0})})}function Ne(e,t=d.Now.timeZoneId()){return(fe(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function Te(e,t){const n=fe(e)?e:e.toPlainDate(),a=fe(t)?t:t.toPlainDate();return n.until(a).days}function Se(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 Me(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function Ie(e=d.Now.timeZoneId()){return d.Now.zonedDateTimeISO(e)}function He(e=d.Now.timeZoneId()){return d.Now.plainDateISO(e)}const Re=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return fe(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},Oe=(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 we(e,t)},Pe=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return ke(e)},Le=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return Ne(e)},je=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Ce(e instanceof Date?d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):fe(e)?e:e.toPlainDate(),t instanceof Date?d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):fe(t)?t:t.toPlainDate())},$e=(e,t)=>!je(e,t),Ae=(e,t)=>(t||ne()).resolveColors(e).eventColor,ze=(e,t)=>(t||ne()).resolveColors(e).textColor,Ye=(e,t)=>(t||ne()).resolveColors(e).eventSelectedColor,Fe=(e,t)=>(t||ne()).resolveColors(e).lineColor,Ve=.25,We=(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")}`},Be=e=>{const t=Re(e.start),n=Ue(e);return`${We(t)} - ${We(n)}`},Ze=e=>{const t=Ve;return Math.round(e/t)*t},Ue=e=>{if(!e.end)return 0;const t=Re(e.end);if(e.allDay||!e.start)return t;const n=xe(e.start),a=xe(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},_e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],qe=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Xe=["January","February","March","April","May","June","July","August","September","October","November","December"],Ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ke=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}},Je=()=>{const e=new Date,t=new Date,n=e.getDay(),a=e.getDate()-n+(0===n?-6:1);return _e.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:Xe[a],shortMonthName:Ge[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},et=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:tt(t)}},tt=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:Xe[r],monthIndex:r,year:o}},nt=(e,t=3)=>{const n=5*t,{monday:a}=Ke(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(et(t))}return r};function at(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(et(t))}return n}const rt=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),ot=(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=xe(t.start);r.setHours(0,0,0,0);const o=xe(t.end);return o.setHours(0,0,0,0),a>=r&&a<=o}),lt=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},it=(e,t,n)=>{const a=lt(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()})})},st=(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()}),dt=(e,t)=>{var n,a;const r=lt(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:st(r,o),end:st(r,o)})},ct=(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)},ut=(e,t)=>{const n=ct(e,t);return n>=0&&n<=6},gt=(e,t)=>e.map(e=>{const n=xe(e.start),a=ct(n,t);return Object.assign(Object.assign({},e),{day:a})}),ht=(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)},mt=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=xe(e.start);return a>=t&&a<=n}).map(e=>{const n=ct(xe(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},vt=(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:st(r,o),end:st(r,o)})},ft=(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:st(r,o),end:st(r,o)})},yt=(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 pt(){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 bt(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function Dt(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)||!Dt(e[r],t[r]))return!1;return!0}const xt="240px",wt=e=>{if(!e)return{enabled:!1,width:xt,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:xt,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i,colorPickerMode:s}=e;return{enabled:t,width:oe(n,xt),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i,colorPickerMode:s}};class Ct{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 Z.DAY:e.setDate(e.getDate()-1);break;case Z.WEEK:e.setDate(e.getDate()-7);break;case Z.MONTH:e.setMonth(e.getMonth()-1);break;case Z.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case Z.DAY:e.setDate(e.getDate()+1);break;case Z.WEEK:e.setDate(e.getDate()+7);break;case Z.MONTH:e.setMonth(e.getMonth()+1);break;case Z.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)):re.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void re.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 re.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)?re.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||Dt(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=wt(e.useSidebar);Dt(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);Dt(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||Z.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 ee(t.calendars,t.defaultCalendar,(null===(n=t.theme)||void 0===n?void 0:n.mode)||"light"),l=this.calendarRegistry,te=l,this.sidebarConfig=wt(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?ve(e)?e:"en-US":e&&"object"==typeof e&&!ve(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}function Et(e){const l=t(()=>new Ct(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(()=>{Dt(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 kt(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 Nt(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Tt=(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},St=(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 Mt(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=kt(e,t);if(n)return Nt(n)}const a=me(t),r=he[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const l=he.en.messages;return(null==l?void 0:l[e])||e}const It=e.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Ht(){return l(It)}const Rt=e.forwardRef(({x:e,y:t,onClose:n,children:a,className:o},l)=>{r(()=>{const e=e=>{l&&"current"in l&&l.current&&!l.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,l]);return v(u("div",{ref:l,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 ${o||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),children:a}),document.body)});Rt.displayName="ContextMenu";const Ot=({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]}),Pt=()=>u("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Lt=({children:e})=>u("div",{className:"px-2 py-1.5 text-sm font-semibold text-slate-950 dark:text-slate-50",children:e}),jt=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],$t=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Ht();return g("div",{className:"p-2",children:[u("div",{className:"grid grid-cols-7 gap-2 p-1",children:jt.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")})]})},At=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Ht();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?C:E,{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")})})]})},zt=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Yt=({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:zt(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)})})})},Ft="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",Vt="df-header p-2 flex justify-between",Wt="text-2xl font-bold text-gray-900 dark:text-gray-100",Bt="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)",Zt="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Ut="flex-1 overflow-auto will-change-scroll",_t="df-time-slot relative h-[4.5rem] flex",qt="df-time-label absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Xt="df-time-grid-row h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",Gt="df-current-time-line absolute left-0 top-0 flex pointer-events-none",Kt="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Jt="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Qt="rounded-xl my-0.5",en="df-event-title font-medium text-xs truncate pr-1",tn="df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",nn="h-3 w-3 mr-1",an="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",rn="bg-primary rounded-full text-primary-foreground",on="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",ln="h-4 w-4 transition-transform group-hover:scale-110",sn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",dn="h-3 border-t border-gray-200 dark:border-gray-700 relative",cn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",un="text-gray-500 dark:text-gray-400",gn="text-gray-600 dark:text-gray-300",hn="text-xs",mn="text-sm",vn="flex flex-col",fn="mr-1",yn=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:r,onDateSelect:o})=>{const{locale:l}=Ht(),i=t(()=>(new Date).toDateString(),[]),s=n.toDateString(),d=t(()=>Tt(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(k,{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(N,{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?rn: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()))]})]})},pn=({calendars:e,currentCalendarId:t,onMergeSelect:a})=>{const{t:l}=Ht(),[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(N,{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)]})},bn=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:r}=Ht();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:Bt,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")})]})]})})},Dn=({calendarId:e,calendarName:t,calendars:a,step:r,onStepChange:o,onConfirmDelete:l,onCancel:i,onMergeSelect:s})=>{const[d,c]=n(!1),{t:m}=Ht();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:Bt,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")})]})]})})})},xn=({app:e,calendars:t,toggleCalendarVisibility:l,isCollapsed:i,setCollapsed:s,renderCalendarContextMenu:d,editingCalendarId:c,setEditingCalendarId:m,onCreateCalendar:b,colorPickerMode:D="default"})=>{var w,C,E,k;const{t:N}=Ht(),T=e.getVisibleMonth(),S=T.getFullYear(),M=T.getMonth(),[I,H]=n(null),R=void 0!==c?c:I,O=m||H;o(null);const P=o(null),[L,j]=n(()=>new Date(S,M,1));r(()=>{j(e=>e.getFullYear()===S&&e.getMonth()===M?e:new Date(S,M,1))},[S,M]);const $=a(t=>{j(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[A,z]=n(null),[Y,F]=n(null),[V,W]=n(null),[B,Z]=n(!1);r(()=>{if(V&&"blossom"===D){const e=setTimeout(()=>{Z(!0)},50);return()=>clearTimeout(e)}Z(!1)},[V,D]);const[U,_]=n(null),[q,X]=n(null),G=a((e,t)=>{e.preventDefault(),e.stopPropagation(),z({x:e.clientX,y:e.clientY,calendarId:t}),F(null)},[]),K=a(e=>{e.preventDefault(),F({x:e.clientX,y:e.clientY}),z(null)},[]),J=a(()=>{z(null)},[]),Q=a(()=>{F(null)},[]),ee=a(()=>{A&&(X({calendarId:A.calendarId,step:"initial"}),J())},[A,J]),te=a(t=>{if(A){const{colors:n,darkColors:a}=ae(t);e.updateCalendar(A.calendarId,{colors:n,darkColors:a}),J()}},[e,A,J]),ne=a(()=>{if(A){const e=t.find(e=>e.id===A.calendarId);if(e){const{h:t,s:n,l:a}=f(e.colors.lineColor),r=y(a);let o=A.x,l=A.y;if(P.current){const e=P.current.getBoundingClientRect();o=e.left+e.width/2,l=e.top+e.height/2}W({x:o,y:l,calendarId:A.calendarId,initialColor:{hue:t,saturation:r,lightness:a,alpha:100,layer:"outer"},currentColor:e.colors.lineColor})}J()}},[A,t,J]),re=a(e=>{A&&(_({sourceId:A.calendarId,targetId:e}),J())},[A,J]),oe=a(()=>{if(U){const{sourceId:t,targetId:n}=U;e.mergeCalendars(t,n),_(null)}},[e,U]),le=a(()=>{q&&(e.deleteCalendar(q.calendarId),X(null))},[e,q]),ie=a(e=>{q&&(_({sourceId:q.calendarId,targetId:e}),X(null))},[q]),se=U?(null===(w=t.find(e=>e.id===U.sourceId))||void 0===w?void 0:w.name)||"Unknown":"",de=U?(null===(C=t.find(e=>e.id===U.targetId))||void 0===C?void 0:C.name)||"Unknown":"",ce=q?(null===(E=t.find(e=>e.id===q.calendarId))||void 0===E?void 0:E.name)||"Unknown":"",ue=e.getReadOnlyConfig(),ge=!e.state.readOnly,he=!1!==ue.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:ge?K:void 0,children:[u(At,{isCollapsed:i,onCollapseToggle:()=>s(!i)}),i?u(Yt,{calendars:t,onToggleVisibility:l,onReorder:he?e.reorderCalendars:()=>{},onRename:ge?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ge?G:()=>{},editingId:R,setEditingId:O,activeContextMenuCalendarId:null==A?void 0:A.calendarId,isDraggable:he,isEditable:ge}):g(h,{children:[u(Yt,{calendars:t,onToggleVisibility:l,onReorder:he?e.reorderCalendars:()=>{},onRename:ge?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ge?G:()=>{},editingId:R,setEditingId:O,activeContextMenuCalendarId:null==A?void 0:A.calendarId,isDraggable:he,isEditable:ge}),u("div",{className:"border-t border-gray-200 dark:border-slate-800",children:u(yn,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:$,onDateSelect:t=>e.setCurrentDate(t)})})]}),A&&u(Rt,{ref:P,x:A.x,y:A.y,onClose:J,className:"w-64 p-2",children:d?d(t.find(e=>e.id===A.calendarId),J):g(h,{children:[u(Lt,{children:N("calendarOptions")}),u(pn,{calendars:t,currentCalendarId:A.calendarId,onMergeSelect:re}),u(Ot,{onClick:ee,children:N("delete")}),u(Pt,{}),u($t,{selectedColor:null===(k=t.find(e=>e.id===A.calendarId))||void 0===k?void 0:k.colors.lineColor,onSelect:te,onCustomColor:ne})]})}),Y&&v(g(Rt,{x:Y.x,y:Y.y,onClose:Q,className:"w-max p-2",children:[u(Ot,{onClick:()=>{null==b||b(),Q()},children:N("newCalendar")||"New Calendar"}),u(Ot,{onClick:()=>{e.triggerRender(),Q()},children:N("refreshAll")||"Refresh All"})]}),document.body),U&&v(u(bn,{sourceName:se,targetName:de,onConfirm:oe,onCancel:()=>_(null)}),document.body),q&&v(u(Dn,{calendarId:q.calendarId,calendarName:ce,calendars:t,step:q.step,onStepChange:e=>X(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:le,onCancel:()=>X(null),onMergeSelect:ie}),document.body),V&&v(u("div",{className:"fixed inset-0 z-50",onMouseDown:()=>W(null),children:u("div",{className:"absolute flex items-center justify-center",style:{top:V.y,left:V.x,transform:"translate(-50%, -50%)"},onMouseDown:e=>e.stopPropagation(),children:"blossom"===D?u(p,{defaultValue:V.initialColor,coreSize:28,petalSize:28,initialExpanded:B,openOnHover:!1,onChange:t=>{const{colors:n,darkColors:a}=ae(t.hex);e.updateCalendar(V.calendarId,{colors:n,darkColors:a})},onCollapse:()=>W(null)}):u("div",{className:"rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",children:u(x,{width:"220px",color:V.currentColor,onChange:e=>{W(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=ae(t.hex);e.updateCalendar(V.calendarId,{colors:n,darkColors:a})}})})})}),document.body)]})},wn=({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||ne()).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(S,{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(S,{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(T,{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(T,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),x()]})},Cn=/(YYYY|YY|MM|DD|HH|mm)/g,En=e=>e.toString().padStart(2,"0"),kn=(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`)},Nn=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Tn=e=>{let t,n=0,a="^";for(;null!==(t=Cn.exec(e));){a+=Nn(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=Nn(e.slice(n))+"$",new RegExp(a)},Sn=(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}},Mn=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()},In=(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?Mn(n):d.Now.timeZoneId();return null!=n?n:d.Now.zonedDateTimeISO(e)}if(fe(e)){const n=null!=t?t:d.Now.timeZoneId(),a=`${e.year}-${En(e.month)}-${En(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?Mn(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})}},Hn=(e,t,n)=>{const a=kn(t,n),r={YYYY:e.year.toString(),YY:En(e.year%100),MM:En(e.month),DD:En(e.day),HH:En(e.hour),mm:En(e.minute)};return a.replace(Cn,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},Rn=Array.from({length:24},(e,t)=>t),On=Array.from({length:60},(e,t)=>t),Pn=({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(M,{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(k,{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(N,{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(I,{width:14,height:12})})]})]}),Ln=(e,t)=>d.PlainDate.compare(e,t),jn=({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===Ln(e,n),s=0===Ln(e,a),d=Ln(e,n)>=0&&Ln(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())})})]}),$n=({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=On.includes(s)?On:[...On,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:Rn.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:En(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:En(e)},e)})})})]})]})},An=({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(Pn,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:h,onYearChange:m}),u(jn,{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($n,{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"})})]})})},zn=({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(()=>St(w,"short"),[w]),k=t(()=>Tt(w,"narrow"),[w]),N=t(()=>C?"object"==typeof s&&(null==s?void 0:s.format)?s.format:i:"",[C,s,i]),T=t(()=>kn(l,N),[l,N]),S=t(()=>Tn(T),[T]),M=t(()=>{const t=null!=v?v:fe(e[0])?fe(e[1])?d.Now.timeZoneId():Mn(e[1]):Mn(e[0]),n=In(e[0],t);return[n,In(e[1],t,n)]},[e,v]),[I,R]=n(M),O=o(M),[P,L]=n("start"),[j,$]=n([Hn(M[0],l,N),Hn(M[1],l,N)]),A=o([Hn(M[0],l,N),Hn(M[1],l,N)]),z=o(M),[Y,F]=n(M[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=I},[I]),r(()=>{const e=O.current,t=0!==d.ZonedDateTime.compare(e[0],M[0]),n=0!==d.ZonedDateTime.compare(e[1],M[1]);(t||n)&&R(M),O.current=M},[M]),r(()=>{F(M[0].toPlainDate().with({day:1}))},[M[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=I[0].epochMilliseconds,te=I[0].offsetNanoseconds,ne=I[1].epochMilliseconds,ae=I[1].offsetNanoseconds;r(()=>{const[e,t]=z.current,n=Hn(e,l,N),a=Hn(t,l,N),[r,o]=A.current;r===n&&o===a||(A.current=[n,a],$([n,a]))},[ee,te,ne,ae,l,N]),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(M),K.current=!1)},[V,M]);const re=a(e=>{c&&c(e,[Hn(e[0],l,N),Hn(e[1],l,N)])},[N,l,c]),oe=a(e=>{h&&h(e,[Hn(e[0],l,N),Hn(e[1],l,N)])},[N,l,h]),le=a((e,t)=>{R(n=>{const a=[...n];if("start"===e){const e=In(a[1],Mn(t),t),n=d.ZonedDateTime.compare(t,e)>0?t:e;return[t,n]}const r=In(a[0],Mn(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=Mn(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(I[0],e),a=I[1].epochMilliseconds-I[0].epochMilliseconds,r=n.add({milliseconds:a});return void R([n,r])}const n=t(I[1],e),a=I[1].epochMilliseconds-I[0].epochMilliseconds;if(d.ZonedDateTime.compare(n,I[0])<0){const n=t(I[0],e),r=n.add({milliseconds:a});return void R([n,r])}const r=[I[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=In(a[1],Mn(o),o);return[o,d.ZonedDateTime.compare(o,e)>0?o:e]}const l=In(a[0],Mn(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=In(a[1],Mn(r),r);return[r,d.ZonedDateTime.compare(r,e)>0?r:e]}const o=In(a[0],Mn(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})},[]),ue=a((e,t)=>{const n="start"===e?0:1,a=I[n],r=Mn(a),o=Sn(t,S,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]=Hn(I[n],l,N),t}),!1},[I,N,l,S,le]),ge=a(e=>t=>{ce(e,t.target.value)},[ce]),he=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))||ue(e,t.target.value)},[ue,f,V]),me=a(e=>t=>{"Enter"===t.key&&(t.preventDefault(),ue(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ue]),ve=()=>{K.current=!0,re(I),oe(I),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=I["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:ge("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:he("start"),onKeyDown:me("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:T,autoComplete:"off",disabled:f})}),u(H,{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:ge("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:he("end"),onKeyDown:me("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:T,autoComplete:"off",disabled:f})})]}),V&&(b?m.createPortal(u(An,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:I,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:X,timeListRefs:G,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:ve,getPopupStyle:Ce}),b()):m.createPortal(u(An,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:I,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:X,timeListRefs:G,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:ve,getPopupStyle:Ce}),document.body))]})},Yn=({event:e,isOpen:a,isAllDay:o,onEventUpdate:l,onEventDelete:i,onClose:s,app:c})=>{var h;const[v,f]=n(e),{t:y}=Ht();r(()=>{f(e)},[e]);const p=t(()=>(c?c.getCalendarRegistry():ne()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),b=t(()=>!yt(e,v),[e,v]),D=t(()=>fe(v.start)?v.end&&!fe(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(wn,{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(zn,{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(zn,{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=fe(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=fe(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},Fn=({calendar:e,mode:t="buttons"})=>{const[a,l]=n(!1),i=o(null),{t:s}=Ht(),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:`${un} transition-transform duration-200 ${a?"rotate-180":""}`,children:u(R,{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))}))},Vn=0,Wn=1970,Bn=2100,Zn=8,Un=100,_n=1200,qn=900,Xn=700;class Gn{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}}}Gn.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const Kn=()=>{const[e,t]=n({yearHeight:Xn,screenSize:"desktop"});return r(()=>{const e=()=>{const e=window.innerWidth;t(e<640?{yearHeight:_n,screenSize:"mobile"}:e<900?{yearHeight:qn,screenSize:"tablet"}:{yearHeight:Xn,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Jn=({currentDate:e,yearHeight:l,onCurrentYearChange:i})=>{const s=e.getFullYear(),d=(s-Wn)*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-Wn)*l;u(e),x.current=e,p.current&&(p.current.scrollTop=e)},[l,m]);const C=t(()=>{const e=performance.now(),t=Bn-Wn+1,n=t*l,a=Math.floor(c/l),r=Math.min(t-1,Math.ceil((c+g)/l)),o=Math.max(0,a-Vn),i=Math.min(t-1,r+Vn),s=[];for(let e=o;e<=i;e++)s.push({index:e,year:Wn+e,top:e*l,height:l});const d=performance.now()-e;return Gn.trackRenderTime(d),{totalHeight:n,visibleItems:s}},[c,g,l]),E=a(e=>{const t=performance.now();if(t-D.current<Zn)return;D.current=t;const n=e.currentTarget.scrollTop,a=Math.abs(n-x.current);x.current=n,Gn.trackScrollEvent(a),requestAnimationFrame(()=>{u(n);const e=n,t=Math.floor(Wn+e/l);t!==m&&t>=Wn&&t<=Bn&&(v(t),null==i||i(t))}),y(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{y(!1)},Un)},[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-Wn)*l;p.current.scrollTo({top:Math.max(0,n),behavior:t?"smooth":"auto"})},[l]),N=a(()=>{const e=Math.max(Wn,m-1);v(e),k(e)},[m,k]),T=a(()=>{const e=Math.min(Bn,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()):fe(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}`},ea=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,ta=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 na(e){return!("hour"in e)}function aa(e){return"hour"in e&&!("timeZone"in e)}function ra(e){return"timeZone"in e}function oa(e){if(na(e))return new Date(e.year,e.month-1,e.day);if(aa(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 la(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function ia(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 sa(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 da(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)}function ca(e){return new Date(e.year,e.month-1,e.day)}function ua(e){if(na(e))return 0;return e.hour+e.minute/60}function ga(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return ra(e),e.with({hour:n,minute:a,second:0,millisecond:0})}function ha(e,t){const n=na(e)?e:(aa(e),e.toPlainDate()),a=na(t)?t:(aa(t),t.toPlainDate());return n.equals(a)}function ma(e){return na(e)?e:(aa(e),e.toPlainDate())}const va=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),fa={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"},ya=(e,t,n)=>e?t:n,pa=(...e)=>e.filter(Boolean).join(" "),ba=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 Da(e,t=!1){if(e instanceof d.PlainDate||e instanceof d.PlainDateTime)return e;if(e instanceof Date)return t?la(e):ia(e);throw new Error("Invalid time type: "+typeof e)}function xa(e,t){if(e instanceof d.ZonedDateTime)return e;if(e instanceof Date)return sa(e,t);throw new Error("Invalid time type: "+typeof e)}function wa(e){var t;const n=Da(e.start,e.allDay),a=Da(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 Ca(e){const t=xa(e.start,e.timeZone),n=xa(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 Ea(e){return e.map(e=>wa(e))}function ka(e){return e.map(e=>Ca(e))}function Na(e,t,n,a){return wa(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))}function Ta(e,t,n,a,r){return wa(Object.assign({id:e,title:t,start:n,end:a},r))}function Sa(e,t,n,a,r=!1,o){return wa(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))}function Ma(e,t,n,a,r,o){return Ca(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))}const Ia=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):xe(e)}catch(e){return new Date}},Ha=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Ra=(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}},Oa=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=Ia(e.start),r=Ha(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 Pa=null;const La=()=>{const[e,t]=n(()=>Pa||{weekHeight:K,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(X,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(G,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(K,a),screenSize:"desktop",weeksPerView:6};Pa&&Pa.screenSize===r.screenSize&&Pa.weekHeight===r.weekHeight&&Pa.weeksPerView===r.weeksPerView||(Pa=r,t(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},ja=({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),at(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),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=et(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]),V=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]),W=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]),B=a(e=>{const t=performance.now();if(t-j.current<_)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)},q)},[l,F,T]),Z=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]),U=a(()=>{const e=k[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);Z(t)},[V.displayStartIndex,k,Z]),X=a(()=>{const e=k[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);Z(t)},[V.displayStartIndex,k,Z]),G=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(()=>{Z(a,!0),setTimeout(()=>{M.current=!1,S(!1)},200)})},[k,l,i,Z]);return r(()=>{W(V.visibleItems)},[V.visibleItems,W]),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),Z(e,!0)}R.current=e},[e,i,Z]),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:V,scrollElementRef:O,handleScroll:B,scrollToDate:Z,handlePreviousMonth:U,handleNextMonth:X,handleToday:G,setScrollTop:f,setContainerHeight:p,setCurrentMonth:D,setCurrentYear:w,setIsScrolling:E,cache:L.current,scrollElementRefCallback:z,weeksData:k}},$a=({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===Z.DAY,{screenSize:c}=La(),h="mobile"===c,{t:m}=Ht();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:cn,title:h?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:u(O,{className:`h-4 w-4 ${un}`})})}),u("div",{className:"flex-1 flex justify-center",children:s&&u(Fn,{mode:t,calendar:e})}),!s&&u(Fn,{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 ${cn}`,children:u(P,{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(P,{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"})]})})]})]})]})},Aa=i(void 0),za=({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=ba(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(Aa.Provider,{value:h,children:e})},Ya=()=>{const e=l(Aa);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Fa=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Va=({onClose:e,onCreate:a,colorPickerMode:r="default"})=>{const{t:o}=Ht(),{effectiveTheme:l}=Ya(),[i,s]=n(""),[d,c]=n(Fa[Math.floor(Math.random()*Fa.length)]),[m,f]=n(!1),[x,C]=n(""),E=t(()=>{const e=b[Math.floor(Math.random()*b.length)],t=e.layer||"outer",n=y(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[k,N]=n(null),T="dark"===l,S={default:{picker:{background:T?"#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:T?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:T?"#1e293b":"#ffffff",borderBottom:T?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:T?"#1e293b":"#ffffff"},controls:{border:T?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:T?"#374151":"#ffffff",color:T?"#f3f4f6":"#1f2937",border:T?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:T?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:T?"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-white dark:bg-slate-900 animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("blossom"===r?"mb-6":"mb-4"),children:o("createCalendar")}),g("form",{onSubmit:t=>{var n;if(t.preventDefault(),!i.trim())return;let o;o="blossom"===r?null!==(n=null==k?void 0:k.hex)&&void 0!==n?n:D(E.hue,E.saturation,E.lightness):d;const{colors:l,darkColors:s}=ae(o),c={id:bt(),name:i.trim(),colors:l,darkColors:s,isVisible:!0,isDefault:!1};a(c),e()},children:["blossom"===r?g("div",{className:"mb-8 flex items-center gap-4",children:[u("div",{className:"flex-1",children:u("input",{type:"text",value:i,onChange:e=>s(e.target.value),className:"w-full 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:o("calendarNamePlaceholder"),autoFocus:!0})}),u("div",{className:"w-9 h-9 relative shrink-0",children:u("div",{className:"absolute inset-0 flex items-center justify-center",children:u(p,{defaultValue:E,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>N(e),onCollapse:e=>N(e),className:"z-50"})})})]}):g(h,{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:d}}),u("input",{type:"text",value:i,onChange:e=>s(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:o("calendarNamePlaceholder"),autoFocus:!0})]})}),g("div",{className:"mb-6",children:[u("div",{className:"grid grid-cols-7 gap-6",children:Fa.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 "+(d===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>c(e)},e))}),g("div",{className:"mt-2 relative",children:[u("button",{type:"button",onClick:()=>{C(d),f(!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:o("customColor")}),m&&u("div",{className:"absolute left-0 top-full z-10001 mt-2",children:u(w,{color:d,onChange:e=>{c(e.hex)},onAccept:()=>{f(!1)},onCancel:()=>{c(x),f(!1)},styles:S})})]})]})]}),g("div",{className:"flex justify-end space-x-3",children:[u("button",{type:"button",onClick:e,className:Bt,children:o("cancel")}),u("button",{type:"submit",disabled:!i.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:bg-primary/90 disabled:opacity-50",children:o("create")})]})]})]})}),document.body)},Wa=({loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>{const{t:i,locale:s}=Ht(),d=t(()=>Ha(new Date),[]),c=t(()=>Oa(a,d),[a,d]),h=e=>Ia(e);return n?g("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[u(L,{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(Ba,{}),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}=Ra(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())})})},Ba=()=>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"})}),Za=({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(Wa,{loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})})}),Ua=({isOpen:e,onClose:t,keyword:n,onSearchChange:a,results:l,loading:i,onResultClick:s,emptyText:d})=>{const c=o(null),{t:h}=Ht();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(j,{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($,{className:"w-4 h-4"})})]})]}),u("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:u(Wa,{loading:i,results:l,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},_a=({app:e,anchorRef:a,onClose:l,isOpen:i})=>{const{t:d}=Ht(),[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=bt(),a={id:n,title:t.title,start:pe(t.start),end:pe(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},qa=({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":"")})}),Xa=({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"})]})},Ga=({isOpen:t,onClose:a,onSave:o,draftEvent:l,app:i})=>{const{locale:s,t:d}=Ht(),[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=xe(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=xe(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:pe(e),end:pe(n)});return!yt(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:pe(e),end:pe(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(wn,{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(qa,{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:We(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(yn,{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(Xa,{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:We(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(yn,{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(Xa,{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)},Ka=({locale:e="en-US",messages:n,children:a})=>{const r=t(()=>{if("string"==typeof e){return{code:ve(e)?e:"en-US",messages:void 0}}return e&&!ve(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:Mt(t,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replace(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:Tt,getMonthLabels:St,isDefault:!1}},[r,n]);return u(It.Provider,{value:o,children:a})},Ja=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Qa=({locale:e,messages:t,children:n})=>Ht().isDefault?u(Ka,{locale:e,messages:t,children:n}):u(h,{children:n}),er=({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}=Ht(),[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 J=e=>{let t;t=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):xe(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 Q=a(e=>{y.setTheme(e)},[y]),ee=a(()=>{C(e=>e+1)},[]),te=t(()=>y.getCalendars(),[y,w,e]),ne=a((e,t)=>{y.setCalendarVisibility(e,t),ee()},[y,ee]),re=a(e=>{y.setAllCalendarsVisibility(e),ee()},[y,ee]),le=a(()=>{if("modal"===(D.createCalendarMode||"inline"))return void S(!0);const e=Ja[Math.floor(Math.random()*Ja.length)],{colors:t,darkColors:n}=ae(e),a=bt(),r={id:a,name:N("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};y.createCalendar(r),I(a),ee()},[y,D.createCalendarMode,N,ee]),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:bt(),title:"",start:pe(e),end:pe(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()?Yn:void 0),ce={app:y,config:p.config||{},customDetailPanelContent:s,customEventDetailDialog:de,switcherMode:y.state.switcherMode,calendarRef:se,meta:h},ue={app:y,calendars:te,toggleCalendarVisibility:ne,toggleAll:re,isCollapsed:E,setCollapsed:k,renderCalendarContextMenu:D.renderCalendarContextMenu,createCalendarMode:D.createCalendarMode,renderCreateCalendarDialog:D.renderCreateCalendarDialog,editingCalendarId:M,setEditingCalendarId:I,onCreateCalendar:le,colorPickerMode:D.colorPickerMode},ge=oe(null==D?void 0:D.width,"240px"),he=y.getCalendarHeaderConfig(),me={calendar:y,switcherMode:y.state.switcherMode,onAddCalendar:ie,onSearchChange:W,onSearchClick:()=>{W(""),_(!0)},searchValue:V,isSearchOpen:B,isEditable:!y.state.readOnly},ve=y.getCustomMobileEventRenderer()||Ga;return u(za,{initialTheme:Y,onThemeChange:Q,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(xn,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===he?null:"function"==typeof he?he(me):u($a,Object.assign({},me)),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(Za,{isOpen:B,onClose:()=>{Z(!1),W(""),y.highlightEvent(null)},loading:q,results:G,keyword:V,onResultClick:J,emptyText:null==m?void 0:m.emptyText})]}),u(Ua,{isOpen:U,onClose:()=>{_(!1),W(""),y.highlightEvent(null)},keyword:V,onSearchChange:W,results:G,loading:q,onResultClick:J,emptyText:null==m?void 0:m.emptyText})]})]}),u(_a,{app:y,anchorRef:O,isOpen:H,onClose:()=>R(!1)}),u(ve,{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),ee()},colorPickerMode:D.colorPickerMode}):u(Va,{onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ee()},colorPickerMode:D.colorPickerMode}))]})})},tr=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return u(Qa,{locale:a.state.locale,messages:n,children:u(er,Object.assign({},e))})},nr=({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 Z.DAY:e.setDate(e.getDate()-1);break;case Z.WEEK:e.setDate(e.getDate()-7);break;case Z.MONTH:e.setMonth(e.getMonth()-1)}b(e)},goToNext:()=>{const e=new Date(h);switch(m){case Z.DAY:e.setDate(e.getDate()+1);break;case Z.WEEK:e.setDate(e.getDate()+7);break;case Z.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 ar(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:Re(e.start),_endHour:e.allDay?0:Ue(e)})}function rr(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:Re(e.start)}function or(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:Ue(e)}const lr=.25,ir=.5,sr=25,dr=1,cr=.9;class ur{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(ar);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&&(rr(e)<or(t)&&rr(t)<or(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-cr,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=rr(e),a=rr(t);if(n!==a)return n-a;return or(t)-rr(t)-(or(e)-rr(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(rr(a)-rr(t))<=lr&&(r.push(t),n.add(t.id))}r.sort((e,t)=>rr(e)-rr(t));const o={events:r,startHour:Math.min(...r.map(e=>rr(e))),endHour:Math.max(...r.map(e=>or(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(rr(e)-rr(t));if(n<=lr)return!0;if(n>lr&&n<ir)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=or(e)-rr(e);if(n<1.25)return!1;const a=rr(e)+.4*n,r=rr(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<ir)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(rr(e)-rr(n));if(t<=lr)return!0;if(t>lr&&t<ir)return!0}return!1}static canEventContain(e,t){const n=rr(e)<=rr(t)&&or(e)>=or(t),a=rr(e)<=rr(t)&&rr(t)<or(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=or(e)-rr(e);return or(t)-rr(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 or(e)-rr(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?or(t)-rr(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(rr(e)-rr(t.parent))-Math.abs(rr(e)-rr(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-cr;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-dr*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+dr);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,sr),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=or(e.event)-rr(e.event);return or(t.event)-rr(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?dr*(d?.15:.3):dr*(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=or(e.event)-rr(e.event);return or(t.event)-rr(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=or(e)-rr(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 gr={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>Fe(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const hr=e=>{const{viewType:r,onEventsUpdate:l}=e,i=r===Z.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}},mr={renderAllDayContent:({title:e,color:t})=>g("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[u(A,{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:tn,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})})]})},vr=({drag:e,color:t,title:n,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,renderer:s=mr,isMobile:d})=>{const{t:c}=Ht(),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})})},fr=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:r})=>{const{t:o}=Ht(),l=(()=>{if(t)return{title:o("newEvent"),icon:u(z,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&r){const t=Se(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})})]})},yr=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}},pr=n=>{const r=t(()=>Object.assign(Object.assign(Object.assign({},gr),n),{getLineColor:e=>{var t;return n.getLineColor?n.getLineColor(e):Fe(e,null===(t=n.app)||void 0===t?void 0:t.getCalendarRegistry())}}),[n]),{viewType:l}=r,i=l===Z.MONTH||l===Z.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===Z.MONTH,g=o===Z.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)=>Se(e,t),[]),addDaysToDate:a((e,t)=>Me(e,t),[]),getTargetDateFromPosition:a((e,t)=>{if(o!==Z.MONTH&&o!==Z.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=hr(r),c=(t=>{const{t:n,locale:r}=Ht(),{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===Z.MONTH||s===Z.YEAR,b=s===Z.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=B(P);const s=pe(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(Ka,{locale:r},e.createElement(fr,{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=B(P),x.current.render(e.createElement(Ka,{locale:r},e.createElement(vr,{drag:t,color:a,title:o,layout:s,allDay:t.allDay,formatTime:We,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}a?(P.style.backgroundColor=Ye(a,null==f?void 0:f.getCalendarRegistry()),P.style.color=ze(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,We,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(Ka,{locale:r},e.createElement(vr,{drag:t,color:w.current.color,title:w.current.title,layout:C||w.current.layout,allDay:D,formatTime:We,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}}},[p,i,We,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}=Ht(),{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===Z.MONTH||i===Z.YEAR,L=i===Z.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}=yr(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?lt(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=Ze(e),l.endHour=l.startHour+1,l.duration=1,l.hourOffset=0,l.eventDate=h?lt(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=Ze(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?lt(h,c):new Date,x(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:Ze(l.startHour),endHour:Ze(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,Ze(l.startHour),Ze(l.endHour)))}N(c,Ze(l.startHour),Ze(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=Ze(e.startHour),o=Ze(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?lt(h,e.dayIndex):xe(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):xe(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=be(a),d=be(Le(r))}else{const n=xe(t.start),l=xe(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=pe(e),d=pe(t)}else{const t=h?lt(h,e.dayIndex):new Date,n=Oe(t,r),a=Oe(t,o);s=pe(n),d=pe(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]),Y=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}=yr(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=xe(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=xe(x.originalEvent.end)||t;a=new Date(i),r(a,l),n>a&&(n=a)}else{const i=xe(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?be(n):pe(n),s=x.originalEvent.allDay?be(a):pe(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?lt(h,e):new Date,t>n&&(t=n)):"right"===x.resizeDirection&&(n=h?lt(h,e):new Date,n<t&&(n=t)),x.originalStartDate=new Date(t.getTime()),x.originalEndDate=new Date(n.getTime());const a=be(t),r=be(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=xe(a.start),t=xe(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<Ve&&(t=x.originalEndHour-Ve)))}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<Ve&&(n=x.startHour+Ve))}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]=[Ze(t),Ze(n)];x.startHour=t,x.endHour=n,x.dayIndex=l,C(e=>e.map(e=>{if(e.id!==x.eventId)return e;const t=xe(e.start),n=Oe(h?lt(h,l):t,u),a=h?lt(h,o):t,r=Oe(a,g),i=pe(n),s=pe(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=Ze(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=Ze(e),[n,a]=A<x.startY?[t,Math.max(t+Ve,x.endHour)]:[x.startHour,Math.max(x.startHour+Ve,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=Ze(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,Ze(n),Ze(a)))}N(t,Ze(n),Ze(a),!1,r)}}},[P,L,N,O,C,H,R,v,f,u,S,T,I,g,m,b,k]),F=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",Y),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",Y,{capture:!0}),document.removeEventListener("touchend",F),void w();const{clientX:u,clientY:g}=yr(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?be(o.originalStartDate):pe(o.originalStartDate),a=e?be(o.originalEndDate):pe(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)?xe(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?be(o.originalStartDate):pe(o.originalStartDate),n=e?be(o.originalEndDate):pe(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=xe(t.start),a=xe(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?be(r):pe(r),s=t.allDay?be(l):pe(l);return Object.assign(Object.assign({},t),{start:i,end:s})})))}}else{let[e,n]=[Ze(o.startHour),Ze(o.endHour)];if(n-e<y&&("top"===o.resizeDirection?e=n-y:n=e+y),"create"===o.mode){const a=h?lt(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=Oe(a,e),l=Oe(a,n),i=o.allDay,s=i?be(r):pe(r),c=i?be(l):pe(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",Y),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",Y,{capture:!0}),document.removeEventListener("touchend",F),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[P,Y,E,w,O,C,y,h,d,s,b,x]),V=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}=yr(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=pe(n),l=pe(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=Ze(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?lt(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",Y),document.addEventListener("mouseup",F),document.addEventListener("touchmove",Y,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}},[P,d,c,h,u,k,Y,F,b,x]),W=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}=yr(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=xe(t.start),n=xe(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",Y),document.addEventListener("mouseup",F),document.addEventListener("touchmove",Y,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}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:Re(t.start);let h=0;if(t.allDay&&t.start&&t.end){const e=xe(t.start);e.setHours(0,0,0,0);const n=xe(t.end);n.setHours(0,0,0,0),h=Math.floor((n.getTime()-e.getTime())/864e5)}const m=xe(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:Ue(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:Re(t.start),originalEndHour:Ue(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=xe(t.start),a=xe(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:Re(t.start),endHour:Ue(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,F,Y,A,z,T,b,D,x]),B=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}=yr(e),u=b.current;if(u){if(P){const e=xe(t.start),a=xe(t.start),r=xe(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=xe(t.start),a=xe(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:Re(t.start),endHour:Ue(t),originalDay:null!==(i=t.day)&&void 0!==i?i:0,originalStartHour:Re(t.start),originalEndHour:Ue(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?Re(t.start)-e:Ue(t)-e,allDay:!1}),x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(s=t.day)&&void 0!==s?s:0,startHour:Re(t.start),endHour:Ue(t),allDay:!1})}document.addEventListener("mousemove",Y),document.addEventListener("mouseup",F),document.addEventListener("touchmove",Y,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}},[P,Y,F,T,b,x]);return{handleDragMove:Y,handleDragEnd:F,handleCreateStart:V,handleMoveStart:W,handleResizeStart:B,handleUniversalDragMove:A,handleUniversalDragEnd:z}})({options:r,common:s,state:d,manager:c}),g=(e=>{const{t:t}=Ht(),{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===Z.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?lt(c,a):new Date,r=be(e),o=be(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?lt(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 br(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[Z.DAY,Z.WEEK,Z.MONTH,Z.YEAR]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{re.log("Drag plugin installed - providing drag capabilities")},api:n}}function Dr(e,t){const n=e.getPlugin("drag"),a=pr(Object.assign(Object.assign({},t),{app:e}));if(!n)return re.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 xr(e){const{app:t,onEventCreated:n}=e,{t:r}=Ht(),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 wr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Ht();return g("div",{className:"df-navigation flex items-center gap-1",children:[u("button",{className:on,onClick:e,"aria-label":"Previous month",children:u(k,{className:ln})}),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:on,onClick:n,"aria-label":"Next month",children:u(N,{className:ln})})]})},Cr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:r,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s})=>{const{t:d,locale:c}=Ht();return u("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",children:g("div",{className:`${vn} 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:Vt,style:{position:"relative"},children:u("div",{children:u("h1",{className:Wt,children:" "})})}),u(wr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),u(yn,{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:`${un} ${mn}`,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:Fe(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[u("div",{className:`font-medium ${mn}`,children:t.title}),!t.allDay&&g("div",{className:`${hn} ${gn}`,children:[We(Re(t.start))," -"," ",We(Ue(t))]}),t.allDay&&u("div",{className:`${hn} ${gn}`,children:d("allDay")})]},t.id))})]})]})})},Er=({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}=Ht(),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:Vt,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:Wt,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&u("h1",{className:Wt,style:{position:"absolute",top:0,left:0,transform:`translateY(${h}px)`,willChange:"transform"},children:c})]}:{children:[u("div",{className:`${Wt} 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(wr,{handlePreviousMonth:n,handleNextMonth:a,handleToday:r})})]})},kr=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(Y,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?u(F,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?u(V,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?u(W,{className:"h-3 w-3"}):u(A,{className:"h-3 w-3"})},Nr=(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=xe(e.start),o=xe(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=Se(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=Se(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},Tr=(e,t)=>{if(e.allDay)return[];const n=xe(e.start),a=xe(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=Se(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},Sr=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:Ye(w),color:"#fff"}:{backgroundColor:Ae(w),color:ze(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:Fe(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:Fe(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=Re(t.event.start),r=Ue(t.event),o=We(a),l=We(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&&kr(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:Fe(n),width:"12px",height:"12px"},children:kr(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:Fe(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});Sr.displayName="MultiDayEvent";const Mr=({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}=Ya(),y=ba(f),{t:p}=Ht(),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():ne()).getVisible().map(e=>({label:e.name,value:e.id})),[h,null==h?void 0:h.getCalendars()]),E=t(()=>fe(e.start)?e.end&&!fe(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:`${sn} 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(wn,{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(zn,{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(zn,{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=fe(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=fe(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},Ir=({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}=Ya(),v=ba(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:`${sn} 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)},Hr=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const r=`${Math.floor(Re(e.start)).toString().padStart(2,"0")}:${Math.round(Re(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:Fe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${fn} 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:`${hn} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:r})]})},Rr=({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:`${fn} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?u("span",{className:`inline-block ${fn} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):u(A,{className:`${nn} ${t?"text-white":""}`})),u("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Or=({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(A,{className:nn})),u("div",{className:`${en} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&u("div",{className:an,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Pr=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:r,isEventSelected:o,onResizeStart:l})=>{const i=n?n.startHour:Re(e.start),s=n?n.endHour:Ue(e),d=s-i,c=!n||n.isFirst,m=!n||n.isLast,v=e.calendarId||"blue";return g(h,{children:[u("div",{className:tn,style:{backgroundColor:Fe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),g("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(Ue(e)-Re(e.start)<=.25?"px-1 py-0":"p-1"),children:[u("div",{className:`${en} 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?`${We(i)} - ${We(s)}`:Be(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:an,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:Fe(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:Fe(v,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},Lr=({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:Re(e.start),r=L?L.endHour:Ue(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:Re(e.start),r=L?L.endHour:Ue(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:Re(e.start),a=L?L.endHour:Ue(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,Re(e.start),Ue(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(Sr,{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:Re(e.start),h=L?L.endHour:Ue(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:Ye(pe,null==j?void 0:j.getCalendarRegistry()),color:"#fff"}:{backgroundColor:Ae(pe,null==j?void 0:j.getCalendarRegistry()),color:ze(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(Rr,{event:e,isEventSelected:ae}):u(Hr,{event:e,app:j,isEventSelected:ae,hideTime:z}):e.allDay?u(Or,{event:e,isEditable:!!oe,onResizeStart:k}):u(Pr,{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(Ir,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:X,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,contentRenderer:O}):u(Mr,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:X,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,app:j}):null})()]})},jr=({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:Y,setIsDrawerOpen:F,ALL_DAY_HEIGHT:V,HOUR_HEIGHT:W,FIRST_HOUR:B,LAST_HOUR:U})=>{const{t:_,locale:q}=Ht(),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 ${vn} h-full`,children:[u(Er,{calendar:t,viewType:Z.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(q,{weekday:"long"})}),g("div",{className:`${Jt} 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(Lr,{event:e,isAllDay:!0,isDayView:!0,segmentIndex:e.row,allDayHeight:V,calendarRef:L,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:W,firstHour:B,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?(Y(o),F(!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<B||t>U)return null;return g("div",{className:Gt,style:{top:`${(t-B)*W}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:Kt,children:We(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:_t,children:u("div",{className:`${qt} 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:Xt,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,B+d/W)},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(B+i/W);I(e,n,s)},onContextMenu:e=>A&&e.preventDefault()},t)),u("div",{className:dn,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(Lr,{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:W,firstHour:B,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?(Y(a),F(!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)})})]})]})})]})})},$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},Ar=({app:l,customDetailPanelContent:i,customEventDetailDialog:s,calendarRef:d,switcherMode:c="buttons"})=>{const h=l.getEvents(),{t:m,locale:v}=Ht(),{screenSize:f}=La(),y="desktop"!==f,[p,b]=n(!1);r(()=>{b("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const D=l.getCustomMobileEventRenderer()||Ga,[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:Y,FIRST_HOUR:F,LAST_HOUR:V,TIME_COLUMN_WIDTH:W,ALL_DAY_HEIGHT:B}=gr,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=Re(t.start),a=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=(n-F)*Y;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else E(null);U.current=l.state.highlightedEventId},[l.state.highlightedEventId,F,Y,d,l]);const _=e.useRef(null),q=t(()=>$r(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=xe(e.start),n=xe(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=xe(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=xe(e.start),r=xe(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=pe(n),i=!0),r>a&&(l=pe(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(()=>ur.calculateDayEventLayouts(G,{viewType:"day"}),[G]),J=t(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=xe(e.start),a=xe(t.start);if(n.getTime()!==a.getTime())return n.getTime()-a.getTime();const r=xe(e.end);return xe(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=xe(e.start),a=xe(e.end),r=xe(t.start);return n<=xe(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 B;return(Math.max(...J.map(e=>e.row))+1)*B},[J,B]),{handleMoveStart:ee,handleCreateStart:te,handleResizeStart:ne,handleCreateAllDayEvent:ae,dragState:re,isDragging:oe}=Dr(l,{calendarRef:d,allDayRowRef:_,viewType:Z.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&&(xe(t.start).getTime()!==xe(e.start).getTime()||xe(t.end).getTime()!==xe(e.end).getTime()||t.day!==e.day||Re(t.start)!==Re(e.start)||Re(t.end)!==Re(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:pe(o),end:pe(l),calendarId:"blue",allDay:!1}];return ur.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:pe(s),end:pe(d),day:0})];return 0===c.length?null:ur.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}=xr({app:l,onEventCreated:e=>{S(e.id)}}),se=Array.from({length:24},(e,t)=>({hour:t+F,label:We(t+F)})),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(jr,{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,F+u/Y)},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:B,HOUR_HEIGHT:Y,FIRST_HOUR:F,LAST_HOUR:V}),u(Cr,{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})]})},zr={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[Z.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},Yr=(t={})=>{const n=Object.assign(Object.assign({},zr),t),a=t=>e.createElement(nr,{viewType:Z.DAY,originalComponent:Ar,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:Z.DAY,component:a,config:n}},Fr=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:r,timeGridWidth:o,allDayAreaHeight:l,organizedAllDaySegments:i,allDayLabelText:s,isMobile:d,isTouch:c,calendarRef:m,allDayRowRef:v,topFrozenContentRef:f,ALL_DAY_HEIGHT:y,HOUR_HEIGHT:p,FIRST_HOUR:b,dragState:D,isDragging:x,handleMoveStart:w,handleResizeStart:C,handleEventUpdate:E,handleEventDelete:k,newlyCreatedEventId:N,setNewlyCreatedEventId:T,selectedEventId:S,setSelectedEventId:M,detailPanelEventId:I,setDetailPanelEventId:H,handleCreateAllDayEvent:R,handleDragOver:O,handleDrop:P,customDetailPanelContent:L,customEventDetailDialog:j,events:$,setDraftEvent:A,setIsDrawerOpen:z})=>{const Y={flexShrink:0};return g("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:[g("div",{className:"w-12 md:w-20 shrink-0 bg-white dark:bg-gray-900 z-20 flex flex-col",children:[u("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700"}),u("div",{className:"flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none",style:{minHeight:`${l}px`},children:s})]}),u("div",{className:"flex-1 overflow-hidden relative",children:g("div",{ref:f,className:"flex flex-col",style:{width:o||void 0,minWidth:"100%"},children:[u("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",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 "+(d?"flex-col gap-0":""),style:Y,children:g(h,d?{children:[u("div",{className:"text-[11px] leading-tight text-gray-500 font-medium",children:n[t]}),u("div",{className:`${Zt} w-7 h-7 text-base font-medium ${a[t].isToday?rn:""}`,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:`${Zt} ${a[t].isToday?rn:""}`,children:a[t].date})]})},t))}),u("div",{className:`${Jt} border-none`,ref:v,style:{minHeight:`${l}px`},children:g("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${l}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 "+(d&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${l}px`},Y),onMouseDown:e=>null==R?void 0:R(e,n),onDoubleClick:e=>null==R?void 0:R(e,n),onDragOver:O,onDrop:e=>{P(e,a,void 0,!0)}},`allday-${n}`)}),u("div",{className:"absolute inset-0 pointer-events-none",children:i.map(t=>u(Lr,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:y,calendarRef:m,isBeingDragged:x&&(null==D?void 0:D.eventId)===t.event.id&&"move"===(null==D?void 0:D.mode),hourHeight:p,firstHour:b,onMoveStart:w,onResizeStart:C,onEventUpdate:E,onEventDelete:k,newlyCreatedEventId:N,onDetailPanelOpen:()=>T(null),selectedEventId:S,detailPanelEventId:I,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((d||c)&&t&&n&&!a){const e=$.find(e=>e.id===t);if(e)return A(e),void z(!0)}M(t)},onEventLongPress:e=>{(d||c)&&M(e)},onDetailPanelToggle:e=>H(e),customDetailPanelContent:L,customEventDetailDialog:j,app:e,isMobile:d,enableTouch:c},t.id))})]})})]})})]})},Vr=({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:_t,children:u("div",{className:`${qt} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),u("div",{className:"relative",children:u("div",{className:`${qt} 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:Kt,children:We(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:Gt,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:Xt,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:`${dn} 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=rt(n,o),i=[];return a.forEach(e=>{const t=Tr(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=Tr(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(Lr,{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}`)})]})]})})]})},Wr=({app:a,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i})=>{const{t:d,getWeekDaysLabels:c,locale:h}=Ht(),m=a.getCurrentDate(),v=a.getEvents(),{screenSize:f}=La(),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()||Ga,k=t(()=>$r(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:Y,LAST_HOUR:F,TIME_COLUMN_WIDTH:V,ALL_DAY_HEIGHT:W}=gr,B=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=xe(e.start);a.setHours(0,0,0,0);const r=xe(e.end);return r.setHours(23,59,59,999),r>=t&&a<=n}).map(e=>{const n=xe(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=Re(e.start),n=U.current;if(n){const e=(t-Y)*z;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else H(null);G.current=a.state.highlightedEventId},[a.state.highlightedEventId,X,Y,z]);const K=t(()=>((e,t)=>{const n=Nr(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 W;const e=Math.max(...K.map(e=>e.row));return W+e*W},[K,W]),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=Tr(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:pe(Oe(lt(t,a),o.startHour)),end:pe(Oe(lt(t,a),n)),day:a});r.push(l)}}else e.day===a&&r.push(e)});const o=ur.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}=Dr(a,{calendarRef:i,allDayRowRef:B,viewType:Z.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&&(xe(t.start).getTime()!==xe(e.start).getTime()||xe(t.end).getTime()!==xe(e.end).getTime()||t.day!==e.day||Re(t.start)!==Re(e.start)||Re(t.end)!==Re(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:pe(r),end:pe(o),calendarId:"blue",allDay:!1},i=[...a.filter(t=>t.day===e&&!t.allDay),l];return ur.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=xe(r.start),l=Oe(o,n),i=Oe(o,a),s=pe(l),d=pe(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:ur.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,X),TIME_COLUMN_WIDTH:p,isMobile:y}),{handleDrop:le,handleDragOver:ie}=xr({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+Y,label:We(t+Y)})),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]),he=e=>{a.updateEvent(e.id,e)},me=e=>{a.deleteEvent(e)},ve=t(()=>{const e=new Date,t=$r(e);return k.getTime()===t.getTime()},[k]);r(()=>{T(new Date);const e=setInterval(()=>T(new Date),6e4);return()=>clearInterval(e)},[]);const fe=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(Er,{calendar:a,viewType:Z.WEEK,currentDate:m,onPrevious:()=>a.goToPrevious(),onNext:()=>a.goToNext(),onToday:()=>a.goToToday()}),u(Fr,{app:a,weekDaysLabels:se,mobileWeekDaysLabels:de,weekDates:ge,currentWeekStart:k,timeGridWidth:b,allDayAreaHeight:J,organizedAllDaySegments:K,allDayLabelText:ce,isMobile:y,isTouch:w,calendarRef:i,allDayRowRef:B,topFrozenContentRef:_,ALL_DAY_HEIGHT:W,HOUR_HEIGHT:z,FIRST_HOUR:Y,dragState:re,isDragging:oe,handleMoveStart:ee,handleResizeStart:ne,handleEventUpdate:he,handleEventDelete:me,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(Vr,{app:a,timeSlots:ue,weekDaysLabels:se,currentWeekStart:k,currentWeekEvents:X,eventLayouts:Q,gridWidth:fe,isMobile:y,isTouch:w,scrollerRef:U,timeGridRef:x,leftFrozenContentRef:q,calendarRef:i,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;_.current&&(_.current.style.transform=`translateX(${-n}px)`),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:he,handleEventDelete:me,newlyCreatedEventId:R,setNewlyCreatedEventId:O,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:S,setDetailPanelEventId:M,customDetailPanelContent:o,customEventDetailDialog:l,events:v,setDraftEvent:$,setIsDrawerOpen:L,isCurrentWeek:ve,currentTime:N,HOUR_HEIGHT:z,FIRST_HOUR:Y,LAST_HOUR:F}),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})]})},Br={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[Z.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},Zr=(t={})=>{const n=Object.assign(Object.assign({},Br),t),a=t=>e.createElement(nr,{viewType:Z.WEEK,originalComponent:Wr,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:Z.WEEK,component:a,config:n}},Ur=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}=Ht(),[Y,F]=n(!1),V=o(null),W=o(null),B=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?(F(!0),V.current&&(clearTimeout(V.current),V.current=null),()=>{V.current&&(clearTimeout(V.current),V.current=null)}):Y?(V.current=setTimeout(()=>{F(!1),V.current=null},100),()=>{V.current&&(clearTimeout(V.current),V.current=null)}):void 0,[s,Y]);const{weekData:_}=h,q=_.days.find(e=>1===e.day),X=`${m}px`,G=t(()=>Nr(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 re.warn("Event missing start or end date:",e);const r=xe(e.start),o=xe(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]),Q=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]),ee=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]),te=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 xe(e.start).toDateString()===n.date.toDateString();const t=xe(e.start),a=xe(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=ee[t],o=Q[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,Q,ee,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:Re(e.start)-Re(t.start)))((s=t.date,K.filter(e=>{if(!e.start||!e.end)return xe(e.start).toDateString()===s.toDateString();const t=xe(e.start),n=xe(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=ee[n],Y=(null!==(r=Q[n])&&void 0!==r?r:0)-1,F=[];for(let e=0;e<=Y;e++)v.has(e)||F.push(e);const V=m.length,_=Math.max(0,V-F.length),q=Math.max(Y+1,0)+_,G=q>U.maxSlots,te=G?U.maxSlotsWithMore:U.maxSlots,ne=F.filter(e=>e<te).length,ae=Math.max(0,te-Math.max(Y+1,0)),re=Math.min(V,ne+ae),oe=m.slice(0,re),le=V-re,ie=[];let se=0;const de=Math.min(te,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(Lr,{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}-${Re(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;B.current={x:a,y:r},W.current=setTimeout(()=>{null==x||x(e,t.date),W.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(W.current&&B.current){const t=Math.abs(e.touches[0].clientX-B.current.x),n=Math.abs(e.touches[0].clientY-B.current.y);(t>10||n>10)&&(clearTimeout(W.current),W.current=null)}},onTouchEnd:()=>{W.current&&(clearTimeout(W.current),W.current=null),B.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(Z.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 ${Y?"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)=>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(Lr,{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}`))})]})})]})});Ur.displayName="WeekComponent";const _r=({app:e,customDetailPanelContent:a,customEventDetailDialog:l,calendarRef:i})=>{const{getWeekDaysLabels:s,getMonthLabels:d,locale:c}=Ht(),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=xe(e.start),r=e.end?xe(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}=La(),[D,x]=n(!1);r(()=>{x("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const w=e.getCustomMobileEventRenderer()||Ga,[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),Y=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:F,handleCreateStart:V,handleResizeStart:W,dragState:B,isDragging:U}=Dr(e,{calendarRef:i,viewType:Z.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&&(xe(t.start).getTime()!==xe(e.start).getTime()||xe(t.end).getTime()!==xe(e.end).getTime()||t.day!==e.day||Re(t.start)!==Re(e.start)||Re(t.end)!==Re(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:Y,events:y}),{handleDrop:_,handleDragOver:q}=xr({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}=ja({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)},fe=t=>{e.changeView(t)};return g("div",{className:Ft,children:[u(Er,{calendar:e,viewType:Z.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:Ut,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(Ur,{item:s,weekHeight:C,currentMonth:G,currentYear:K,screenSize:b,isScrolling:J,calendarRef:i,events:o,onEventUpdate:me,onEventDelete:ve,onMoveStart:F,onCreateStart:V,onResizeStart:W,isDragging:U,dragState:B,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:fe,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})]})},qr={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[Z.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[Z.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}},Xr=(t={})=>{const n=Object.assign(Object.assign({},qr),t),a=t=>e.createElement(nr,{viewType:Z.MONTH,originalComponent:_r,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:Z.MONTH,component:a,config:n}};const Gr=e.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:r,onMoreEventsClick:o,moreCount:l=0})=>{const{t:i}=Ht(),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")]})})]})});Gr.displayName="YearDayCell";const Kr=({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?Ye(j):Ae(j),A=l?"#fff":ze(j),z=Fe(j),Y=!!w.allDay,F=Y?kr(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&&kr(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:Fe(j),width:"12px",height:"12px"},children:kr(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(Ir,{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(Mr,{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})()]})},Jr=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=xe(e.start),n=e.end?xe(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=xe(e.start).getTime(),a=e.end?xe(e.end).getTime():n,r=xe(t.start).getTime(),o=a-n,l=(t.end?xe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const s=[],d=[];return i.forEach(e=>{const r=xe(e.start),i=e.end?xe(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(Gr,{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(Kr,{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))})})]})});Jr.displayName="YearRowComponent";const Qr=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var h;const{locale:m}=Ht(),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}=Dr(e,{calendarRef:l,viewType:Z.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=xe(n.start),r=n.end?xe(n.end):a;return a<=t&&r>=e})},[y,f,P]);return g("div",{className:Ft,children:[u(Er,{calendar:e,viewType:Z.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:`${Ut}`,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(Jr,{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 eo(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=xe(e.start),n=e.end?xe(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=xe(e.start).getTime(),a=e.end?xe(e.end).getTime():n,r=xe(t.start).getTime(),o=a-n,l=(t.end?xe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const d=[],c=[];s.forEach(e=>{const a=xe(e.start),r=e.end?xe(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 to=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var h;const{locale:m,getWeekDaysLabels:v}=Ht(),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}=Dr(e,{calendarRef:l,viewType:Z.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,Y=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]),F=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]),V=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=xe(n.start),r=n.end?xe(n.end):a;return a<=t&&r>=e})},[p,y,z]),W=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}=eo(V,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,V]),B=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()}},[W]);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(Er,{calendar:e,viewType:Z.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:F.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:[W.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:B,children:u("div",{className:"flex flex-col",style:{minWidth:"1352px"},children:W.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=>Y(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(Kr,{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))})})]})},no=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return u("fixed-week"===n?to:Qr,Object.assign({},e,{config:e.config}))},ao={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},ro=(t={})=>{const n=Object.assign(Object.assign({},ao),t);t.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:t.mode}));const a=t=>e.createElement(nr,{viewType:Z.YEAR,originalComponent:no,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:Z.YEAR,component:a,config:n}},oo={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function lo(e={}){const t=Object.assign(Object.assign({},oo),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=gt(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=gt(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=xe(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=xe(n.start),r=xe(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)=>gt(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,re.log("Events plugin installed - providing event management services")},api:a}}export{Ct as CalendarApp,Lr as CalendarEvent,ee as CalendarRegistry,wn as ColorPicker,tr as DayFlowCalendar,Yn as DefaultEventDetailDialog,Mr as DefaultEventDetailPanel,Ir as EventDetailPanelWithContent,ur as EventLayoutCalculator,he as LOCALES,It as LocaleContext,Ve as TIME_STEP,za as ThemeProvider,Er as ViewHeader,Z as ViewType,Me as addDays,Tn as buildParseRegExp,ct as calculateDayIndex,Nt as capitalize,ya as conditionalTheme,Sa as convertDateEvent,Ma as convertDateEventWithTimeZone,Na as createAllDayEvent,Oe as createDateWithHour,Yr as createDayView,br as createDragPlugin,wa as createEvent,dt as createEventWithDate,vt as createEventWithRealDate,Ea as createEvents,lo as createEventsPlugin,Xr as createMonthView,we as createTemporalWithHour,Ta as createTimedEvent,Ca as createTimezoneEvent,ka as createTimezoneEvents,Zr as createWeekView,ro as createYearView,la as dateToPlainDate,ia as dateToPlainDateTime,sa as dateToZonedDateTime,Te as daysBetween,Se as daysDifference,ue as de,le as en,ge as es,Re as extractHourFromDate,ua as extractHourFromTemporal,ta as formatDate,Qn as formatDateConsistent,Be as formatEventTimeRange,ea as formatMonthYear,Hn as formatTemporal,We as formatTime,ce as fr,Qe as generateDayData,bt as generateUniKey,et as generateWeekData,at as generateWeekRange,nt as generateWeeksData,ot as getAllDayEventsForDay,Je as getCurrentWeekDates,lt as getDateByDayIndex,Ia as getDateObj,ht as getDayIndexByDate,Le as getEndOfDay,Ne as getEndOfTemporal,Ae as getEventBgColor,Ue as getEventEndHour,ze as getEventTextColor,rt as getEventsForDay,mt as getEventsForWeek,kt as getIntlLabel,Fe as getLineColor,St as getMonthLabels,tt as getMonthYearOfWeek,ma as getPlainDate,Ra as getSearchHeaderInfo,Ye as getSelectedBgColor,Pe as getStartOfDay,ke as getStartOfTemporal,pt as getTestEvents,Tt as getWeekDaysLabels,Ke as getWeekRange,Mn as getZoneId,Oa as groupSearchResults,ye as isDate,Dt as isDeepEqual,yt as isEventEqual,ut as isEventInWeek,$e as isMultiDayEvent,Ee as isMultiDayTemporalEvent,na as isPlainDate,aa as isPlainDateTime,je as isSameDay,Ce as isSamePlainDate,ha as isSameTemporal,ve as isValidLocale,ra as isZonedDateTime,se as ja,de as ko,pa as mergeClasses,kn as mergeFormatTemplate,Xe as monthNames,oe as normalizeCssWidth,Ha as normalizeDate,me as normalizeLocale,In as normalizeToZoned,Ie as now,En as pad,Sn as parseTemporalString,da as plainDateTimeToDate,ca as plainDateToDate,gt as recalculateEventDays,ba as resolveAppliedTheme,Ze as roundToTimeStep,ga as setHourInTemporal,Ge as shortMonthNames,Mt as t,oa as temporalToDate,fa as themeClasses,va as themeCn,He as today,it as updateEventDateAndDay,ft as updateEventWithRealDate,Et as useCalendarApp,pr as useDrag,Dr as useDragForView,Ht as useLocale,Kn as useResponsiveConfig,La as useResponsiveMonthConfig,Ya as useTheme,ja as useVirtualMonthScroll,Jn as useVirtualScroll,_e as weekDays,qe as weekDaysFullName,ie as zh,De 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 m}from"react/jsx-runtime";import h,{createPortal as v}from"react-dom";import{hexToHsl as f,lightnessToSliderValue as y,BlossomColorPicker as p,DEFAULT_COLORS as b,hslToHex as D}from"@dayflow/blossom-color-picker";import{SketchPicker as x,PhotoshopPicker as w}from"react-color";import{PanelRightClose as C,PanelRightOpen as E,ChevronLeft as k,ChevronRight as N,ChevronsUpDown as T,Check as S,ChevronsLeft as M,ChevronsRight as I,MoveRight as H,ChevronDown as R,Plus as O,Search as P,Loader2 as $,ArrowLeft as L,X as A,CalendarDays as j,Calendar as z,Gift as Y,Heart as F,Star as V,MapPin as W}from"lucide-react";import{createRoot as Z}from"react-dom/client";var U;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(U||(U={}));const B=100,_=8,q=150,G=80,X=90,K=119;class J{constructor(e=B){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 ee{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 te=new ee;function ne(){return te}function ae(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 re=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 oe(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const le={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",importCalendar:"Import Calendar",exportCalendar:"Export Calendar",addSchedule:"Add Schedule",importCalendarMessage:"This calendar contains new events. Please select a target calendar.",ok:"OK"}},ie={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:"明天",importCalendar:"导入日历",exportCalendar:"导出日历",addSchedule:"添加日程",importCalendarMessage:"该日历包含新日程。请选取目标日历",ok:"好"}},se={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:"明日",importCalendar:"カレンダーをインポート",exportCalendar:"カレンダーをエクスポート",addSchedule:"予定を追加",importCalendarMessage:"このカレンダーには新しい予定が含まれています。ターゲットカレンダーを選択してください。",ok:"OK"}},de={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:"내일",importCalendar:"캘린더 가져오기",exportCalendar:"캘린더 내보내기",addSchedule:"일정 추가",importCalendarMessage:"이 캘린더에는 새로운 일정이 포함되어 있습니다. 대상 캘린더를 선택하세요.",ok:"확인"}},ce={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",importCalendar:"Importer un calendrier",exportCalendar:"Exporter le calendrier",addSchedule:"Ajouter un événement",importCalendarMessage:"Ce calendrier contient de nouveaux événements. Veuillez sélectionner un calendrier cible.",ok:"OK"}},ue={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",importCalendar:"Kalender importieren",exportCalendar:"Kalender exportieren",addSchedule:"Termin hinzufügen",importCalendarMessage:"Dieser Kalender enthält neue Termine. Bitte wählen Sie einen Zielkalender.",ok:"OK"}},ge={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",importCalendar:"Importar calendario",exportCalendar:"Exportar calendario",addSchedule:"Añadir evento",importCalendarMessage:"Este calendario contiene nuevos eventos. Seleccione un calendario de destino.",ok:"Aceptar"}},me={en:le,zh:ie,ja:se,ko:de,fr:ce,de:ue,es:ge};function he(e){const t=e.split("-")[0].toLowerCase();return t in me?t:"en"}function ve(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function fe(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 ye(e){return e instanceof Date}function pe(e,t=d.Now.timeZoneId()){return d.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function be(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function De(e){return new Date(e.epochMilliseconds)}function xe(e,t){return fe(e)?function(e,t=d.Now.timeZoneId()){return De(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):De(e)}function we(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return fe(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 Ce(e,t){const n=fe(e)?e:e.toPlainDate(),a=fe(t)?t:t.toPlainDate();return 0===d.PlainDate.compare(n,a)}function Ee(e,t){return!Ce(e,t)}function ke(e,t=d.Now.timeZoneId()){return(fe(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:0,minute:0})})}function Ne(e,t=d.Now.timeZoneId()){return(fe(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:d.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function Te(e,t){const n=fe(e)?e:e.toPlainDate(),a=fe(t)?t:t.toPlainDate();return n.until(a).days}function Se(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 Me(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function Ie(e=d.Now.timeZoneId()){return d.Now.zonedDateTimeISO(e)}function He(e=d.Now.timeZoneId()){return d.Now.plainDateISO(e)}const Re=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return fe(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},Oe=(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 we(e,t)},Pe=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return ke(e)},$e=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return Ne(e)},Le=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Ce(e instanceof Date?d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):fe(e)?e:e.toPlainDate(),t instanceof Date?d.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):fe(t)?t:t.toPlainDate())},Ae=(e,t)=>!Le(e,t),je=(e,t)=>(t||ne()).resolveColors(e).eventColor,ze=(e,t)=>(t||ne()).resolveColors(e).textColor,Ye=(e,t)=>(t||ne()).resolveColors(e).eventSelectedColor,Fe=(e,t)=>(t||ne()).resolveColors(e).lineColor,Ve=.25,We=(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=Re(e.start),n=Be(e);return`${We(t)} - ${We(n)}`},Ue=e=>{const t=Ve;return Math.round(e/t)*t},Be=e=>{if(!e.end)return 0;const t=Re(e.end);if(e.allDay||!e.start)return t;const n=xe(e.start),a=xe(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},_e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],qe=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ge=["January","February","March","April","May","June","July","August","September","October","November","December"],Xe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ke=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}},Je=()=>{const e=new Date,t=new Date,n=e.getDay(),a=e.getDate()-n+(0===n?-6:1);return _e.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:Ge[a],shortMonthName:Xe[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},et=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:tt(t)}},tt=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:Ge[r],monthIndex:r,year:o}},nt=(e,t=3)=>{const n=5*t,{monday:a}=Ke(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(et(t))}return r};function at(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(et(t))}return n}const rt=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),ot=(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=xe(t.start);r.setHours(0,0,0,0);const o=xe(t.end);return o.setHours(0,0,0,0),a>=r&&a<=o}),lt=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},it=(e,t,n)=>{const a=lt(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()})})},st=(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()}),dt=(e,t)=>{var n,a;const r=lt(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:st(r,o),end:st(r,o)})},ct=(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)},ut=(e,t)=>{const n=ct(e,t);return n>=0&&n<=6},gt=(e,t)=>e.map(e=>{const n=xe(e.start),a=ct(n,t);return Object.assign(Object.assign({},e),{day:a})}),mt=(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)},ht=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=xe(e.start);return a>=t&&a<=n}).map(e=>{const n=ct(xe(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},vt=(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:st(r,o),end:st(r,o)})},ft=(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:st(r,o),end:st(r,o)})},yt=(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 pt(){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 bt(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function Dt(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)||!Dt(e[r],t[r]))return!1;return!0}const xt="240px",wt=e=>{if(!e)return{enabled:!1,width:xt,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:xt,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i,colorPickerMode:s}=e;return{enabled:t,width:oe(n,xt),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i,colorPickerMode:s}};class Ct{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 U.DAY:e.setDate(e.getDate()-1);break;case U.WEEK:e.setDate(e.getDate()-7);break;case U.MONTH:e.setMonth(e.getMonth()-1);break;case U.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case U.DAY:e.setDate(e.getDate()+1);break;case U.WEEK:e.setDate(e.getDate()+7);break;case U.MONTH:e.setMonth(e.getMonth()+1);break;case U.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)):re.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void re.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 re.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)?re.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||Dt(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=wt(e.useSidebar);Dt(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);Dt(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||U.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 ee(t.calendars,t.defaultCalendar,(null===(n=t.theme)||void 0===n?void 0:n.mode)||"light"),l=this.calendarRegistry,te=l,this.sidebarConfig=wt(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?ve(e)?e:"en-US":e&&"object"==typeof e&&!ve(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}function Et(e){const l=t(()=>new Ct(e),[]),[i,s]=n(l.state.currentView),[d,c]=n(l.state.currentDate),[u,g]=n(l.getEvents()),[m,h]=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 m=l.updateCalendar;l.updateCalendar=(e,t)=>{m(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(),h(l.getSidebarConfig()),f()},()=>{}},[l,f]),r(()=>{s(l.state.currentView),c(l.state.currentDate),g(l.getEvents())},[l]);const y=o(e);r(()=>{Dt(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:m,readOnlyConfig:l.getReadOnlyConfig()}}function kt(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 Nt(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Tt=(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},St=(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 Mt(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=kt(e,t);if(n)return Nt(n)}const a=he(t),r=me[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const l=me.en.messages;return(null==l?void 0:l[e])||e}const It=e.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Ht(){return l(It)}const Rt=e.forwardRef(({x:e,y:t,onClose:n,children:a,className:l},i)=>{const s=o(null);r(()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&n()};document.body.addEventListener("mousedown",e);const t=()=>n();return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.body.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[n]);return v(u("div",{ref:e=>{s.current=e,"function"==typeof i?i(e):i&&(i.current=e)},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)});Rt.displayName="ContextMenu";const Ot=({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]}),Pt=()=>u("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),$t=({children:e})=>u("div",{className:"px-2 py-1.5 text-sm font-semibold text-slate-950 dark:text-slate-50",children:e}),Lt=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],At=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Ht();return g("div",{className:"p-2",children:[u("div",{className:"grid grid-cols-7 gap-2 p-1",children:Lt.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")})]})},jt=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Ht();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?C:E,{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")})})]})},zt=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Yt=({calendars:e,onToggleVisibility:t,onReorder:l,onRename:i,onContextMenu:s,editingId:d,setEditingId:c,activeContextMenuCalendarId:m,isDraggable:h=!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||!h)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=m===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:h&&!d,onDragStart:t=>k(e,t),onDragEnd:N,className:`rounded transition ${x===e.id?"opacity-50":""} ${h?"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:zt(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)})})})},Ft="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",Vt="df-header p-2 flex justify-between",Wt="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)",Ut="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Bt="flex-1 overflow-auto will-change-scroll",_t="df-time-slot relative h-[4.5rem] flex",qt="df-time-label absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Gt="df-time-grid-row h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",Xt="df-current-time-line absolute left-0 top-0 flex pointer-events-none",Kt="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Jt="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Qt="rounded-xl my-0.5",en="df-event-title font-medium text-xs truncate pr-1",tn="df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",nn="h-3 w-3 mr-1",an="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",rn="bg-primary rounded-full text-primary-foreground",on="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",ln="h-4 w-4 transition-transform group-hover:scale-110",sn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",dn="h-3 border-t border-gray-200 dark:border-gray-700 relative",cn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",un="text-gray-500 dark:text-gray-400",gn="text-gray-600 dark:text-gray-300",mn="text-xs",hn="text-sm",vn="flex flex-col",fn="mr-1",yn=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:r,onDateSelect:o})=>{const{locale:l}=Ht(),i=t(()=>(new Date).toDateString(),[]),s=n.toDateString(),d=t(()=>Tt(l,"narrow"),[l]),c=t(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),m=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(k,{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(N,{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}`)),m.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?rn: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()))]})]})},pn=({calendars:e,currentCalendarId:t,onMergeSelect:a})=>{const{t:l}=Ht(),[i,s]=n(!1),d=o(null),c=o(null),[h,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(m,{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(N,{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:h.y,left:h.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)]})},bn=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:r}=Ht();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")})]})]})})},Dn=({calendarId:e,calendarName:t,calendars:a,step:r,onStepChange:o,onConfirmDelete:l,onCancel:i,onMergeSelect:s})=>{const[d,c]=n(!1),{t:h}=Ht();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(m,"initial"===r?{children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:h("deleteCalendar",{calendarName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:h("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:h("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:h("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:h("delete")})]})]})]}:{children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:h("confirmDeleteTitle",{calendarName:t})}),u("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:h("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:h("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:h("delete")})]})]})})})},xn="new-calendar",wn=({calendars:e,filename:t,onConfirm:a,onCancel:l})=>{var i;const{t:s}=Ht(),[d,c]=n((null===(i=e[0])||void 0===i?void 0:i.id)||xn),[m,h]=n(!1),[f,y]=n(!1),p=o(null),b=o(null);r(()=>{if(!m){const e=setTimeout(()=>y(!1),200);return()=>clearTimeout(e)}y(!0)},[m]),r(()=>{const e=e=>{var t;!p.current||p.current.contains(e.target)||(null===(t=b.current)||void 0===t?void 0:t.contains(e.target))||h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const D=e.find(e=>e.id===d),x=d===xn,w=e=>{c(e),h(!1)};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 bg-white p-6 shadow-xl dark:bg-slate-900",children:[u("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:s("addSchedule")||"Add Schedule"}),u("p",{className:"mb-4 text-sm text-gray-600 dark:text-gray-300",children:s("importCalendarMessage")||"This calendar contains new events. Please select a target calendar."}),g("div",{className:"relative",children:[g("button",{ref:b,type:"button",className:"flex items-center w-full border border-gray-300 dark:border-gray-600 rounded-md px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shadow-sm",onClick:()=>h(!m),children:[!x&&D&&u("div",{className:"mr-3 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:D.colors.lineColor}}),u("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 flex-1 text-left truncate "+(x?"pl-0":""),children:x?`${s("newCalendar")}: ${t}`:(null==D?void 0:D.name)||(null==D?void 0:D.id)}),u(T,{className:"w-4 h-4 text-gray-400 shrink-0 ml-2"})]}),(()=>{var n;if(!f)return null;const a=null===(n=b.current)||void 0===n?void 0:n.getBoundingClientRect();return a?v(u("div",{ref:p,className:"fixed z-110 mt-1 max-h-60 overflow-y-auto rounded-md bg-white shadow-lg border border-gray-200 dark:border-slate-700 dark:bg-slate-800 transition-all duration-200 origin-top "+(m?"opacity-100 scale-100":"opacity-0 scale-95"),style:{top:a.bottom,left:a.left,width:a.width},children:g("div",{className:"py-1",children:[e.map(e=>g("div",{className:"flex items-center px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 "+(d===e.id?"bg-primary/10":""),onClick:()=>w(e.id),children:[u("div",{className:"mr-3 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:e.colors.lineColor}}),u("span",{className:"flex-1 text-sm truncate "+(d===e.id?"font-medium text-primary":"text-gray-700 dark:text-gray-200"),children:e.name||e.id}),d===e.id&&u(S,{className:"ml-2 w-4 h-4 text-primary shrink-0"})]},e.id)),u("div",{className:"border-t border-gray-100 dark:border-slate-700 my-1"}),g("div",{className:"flex items-center px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 "+(x?"bg-primary/10":""),onClick:()=>w(xn),children:[g("span",{className:"flex-1 text-sm truncate "+(x?"font-medium text-primary":"text-gray-700 dark:text-gray-200 pl-6"),children:[s("newCalendar")||"New Calendar",": ",t]}),x&&u(S,{className:"ml-2 w-4 h-4 text-primary shrink-0"})]})]})}),document.body):null})()]}),g("div",{className:"mt-8 flex justify-end gap-3",children:[u("button",{type:"button",onClick:l,className:Zt,children:s("cancel")||"Cancel"}),u("button",{type:"button",onClick:()=>a(d),className:"rounded-md bg-primary px-6 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm",children:s("ok")||"OK"})]})]})})};function Cn(e){return!("hour"in e)}function En(e){return"hour"in e&&!("timeZone"in e)}function kn(e){return"timeZone"in e}function Nn(e){if(Cn(e))return new Date(e.year,e.month-1,e.day);if(En(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 Tn(e){return d.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Sn(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 Mn(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 In(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)}function Hn(e){return new Date(e.year,e.month-1,e.day)}function Rn(e){if(Cn(e))return 0;return e.hour+e.minute/60}function On(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return kn(e),e.with({hour:n,minute:a,second:0,millisecond:0})}function Pn(e,t){const n=Cn(e)?e:(En(e),e.toPlainDate()),a=Cn(t)?t:(En(t),t.toPlainDate());return n.equals(a)}function $n(e){return Cn(e)?e:(En(e),e.toPlainDate())}const Ln=/^(\d{4})(\d{2})(\d{2})$/,An=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/,jn=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function zn(e,t,n){const a=e.trim();if("DATE"===(null==t?void 0:t.value)||Ln.test(a)){const e=a.match(Ln);if(e)return d.PlainDate.from({year:parseInt(e[1],10),month:parseInt(e[2],10),day:parseInt(e[3],10)})}if(jn.test(a)){const e=a.match(jn);if(e){const t=d.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),a=n||d.Now.timeZoneId();return t.toZonedDateTimeISO(a)}}const r=a.match(An);if(r){const e={year:parseInt(r[1],10),month:parseInt(r[2],10),day:parseInt(r[3],10),hour:parseInt(r[4],10),minute:parseInt(r[5],10),second:parseInt(r[6],10)};return(null==t?void 0:t.tzid)?d.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:t.tzid})):d.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function Yn(e,t=!1){if(t||Cn(e)){const t=Cn(e)?e:e.toPlainDate();return{value:`${t.year}${Vn(t.month)}${Vn(t.day)}`,params:{VALUE:"DATE"}}}if(kn(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Vn(t.month)}${Vn(t.day)}T${Vn(t.hour)}${Vn(t.minute)}${Vn(t.second)}Z`}}if(En(e))return{value:`${e.year}${Vn(e.month)}${Vn(e.day)}T${Vn(e.hour)}${Vn(e.minute)}${Vn(e.second)}`};throw new Error("Unsupported Temporal type")}function Fn(e){return`${e.getUTCFullYear()}${Vn(e.getUTCMonth()+1)}${Vn(e.getUTCDate())}T${Vn(e.getUTCHours())}${Vn(e.getUTCMinutes())}${Vn(e.getUTCSeconds())}Z`}function Vn(e){return String(e).padStart(2,"0")}function Wn(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const a=e.replace(/(\r\n|\n|\r)[ \t]/g,""),r=function(e){const t=[];let n=null,a=!1;for(const r of e){const e=r.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(a=!0,n=[]):e.startsWith("END:VEVENT")?(a&&n&&t.push(n),a=!1,n=null):a&&n&&n.push(r)}return t}(a.split(/\r\n|\n|\r/));n.totalParsed=r.length,r.forEach((e,a)=>{try{const a=function(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const a=n.substring(0,e),r=n.substring(e+1),[o,...l]=a.split(";"),i=o.trim().toUpperCase(),s={};switch(l.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),i){case"UID":t.uid=r.trim();break;case"SUMMARY":t.summary=Zn(r);break;case"DESCRIPTION":t.description=Zn(r);break;case"LOCATION":t.location=Zn(r);break;case"DTSTART":t.dtstart=r.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=r.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=r.split(",").map(e=>Zn(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");t.uid||(t.uid=bt());return t}(e),r=function(e,t){var n;const{calendarId:a="default",generateNewIds:r=!0,idPrefix:o="ics-",defaultTimeZone:l}=t,i=r?`${o}${bt()}`:e.uid,s=zn(e.dtstart,e.dtstartParams,l);let c;c=e.dtend?zn(e.dtend,e.dtendParams,l):Cn(s)?s.add({days:1}):s.add({hours:1});const u="DATE"===(null===(n=e.dtstartParams)||void 0===n?void 0:n.value)||Cn(s),g=l||d.Now.timeZoneId();let m,h;if(Cn(s))m=s.toZonedDateTime({timeZone:g,plainTime:"00:00:00"});else if(En(s))try{if("function"!=typeof s.toZonedDateTime)throw new Error("toZonedDateTime missing");m=s.toZonedDateTime(g)}catch(e){m=d.ZonedDateTime.from({year:s.year,month:s.month,day:s.day,hour:s.hour,minute:s.minute,second:s.second,millisecond:s.millisecond,timeZone:g})}else m=s;if(Cn(c))h=c.toZonedDateTime({timeZone:g,plainTime:"00:00:00"});else if(En(c))try{if("function"!=typeof c.toZonedDateTime)throw new Error("toZonedDateTime missing");h=c.toZonedDateTime(g)}catch(e){h=d.ZonedDateTime.from({year:c.year,month:c.month,day:c.day,hour:c.hour,minute:c.minute,second:c.second,millisecond:c.millisecond,timeZone:g})}else h=c;return{id:i,calendarId:a,title:e.summary||"(No Title)",description:e.description,start:m,end:h,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}(a,t);n.events.push(r)}catch(e){n.errors.push({line:0,message:e.message||"Unknown parsing error",eventUid:`index-${a}`})}}),n.success=0===n.errors.length,n.totalImported=n.events.length}catch(e){n.errors.push({message:`Fatal parsing error: ${e.message}`})}return n}function Zn(e){return e.replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\[nN]/g,"\n").replace(/\\\\/g,"\\")}function Un(e,t={}){const{calendarName:n="DayFlow Calendar",productId:a="-//DayFlow//DayFlow Calendar//EN",includeTimezone:r=!0}=t,o=[];return o.push("BEGIN:VCALENDAR"),o.push("VERSION:2.0"),o.push(`PRODID:${a}`),o.push("CALSCALE:GREGORIAN"),o.push("METHOD:PUBLISH"),o.push(`X-WR-CALNAME:${qn(n)}`),e.forEach(e=>{o.push(...function(e){var t,n,a;const r=[];r.push("BEGIN:VEVENT");const o=null===(t=e.meta)||void 0===t?void 0:t.originalUid,l=o||`${e.id}@dayflow`;r.push(`UID:${l}`),r.push(`DTSTAMP:${Fn(new Date)}`);const i=Yn(e.start,e.allDay),s=Yn(e.end,e.allDay);r.push(_n("DTSTART",i.value,i.params)),r.push(_n("DTEND",s.value,s.params)),r.push(_n("SUMMARY",qn(e.title))),e.description&&r.push(_n("DESCRIPTION",qn(e.description)));const d=null===(n=e.meta)||void 0===n?void 0:n.location;d&&r.push(_n("LOCATION",qn(d)));const c=null===(a=e.meta)||void 0===a?void 0:a.categories;if(c&&Array.isArray(c)){const e=c.map(qn).join(",");r.push(_n("CATEGORIES",e))}return r.push("END:VEVENT"),r}(e))}),o.push("END:VCALENDAR"),o.join("\r\n")}function Bn(e,t={}){const n=Un(e,t),a=`${t.filename||"calendar"}.ics`,r=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.setAttribute("download",a),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}function _n(e,t,n){let a=e;return n&&Object.entries(n).forEach(([e,t])=>{a+=`;${e}=${t}`}),a+=`:${t}`,function(e){if(e.length<=75)return e;const t=[];let n=e;t.push(n.slice(0,75)),n=n.slice(75);for(;n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}(a)}function qn(e){return e?e.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n"):""}function Gn(e,t){return c(this,void 0,void 0,function*(){return new Promise((n,a)=>{const r=new FileReader;r.onload=e=>{var a;try{const r=null===(a=e.target)||void 0===a?void 0:a.result;if(!r)throw new Error("File content is empty");const o=Wn(r,t);n(o)}catch(e){n({success:!1,events:[],errors:[{message:e.message||"Failed to read file"}],totalParsed:0,totalImported:0})}},r.onerror=()=>{n({success:!1,events:[],errors:[{message:"File read error"}],totalParsed:0,totalImported:0})},r.readAsText(e)})})}const Xn=({app:e,calendars:t,toggleCalendarVisibility:l,isCollapsed:i,setCollapsed:s,renderCalendarContextMenu:d,editingCalendarId:h,setEditingCalendarId:b,onCreateCalendar:D,colorPickerMode:w="default"})=>{var C,E,k,N;const{t:T}=Ht(),S=e.getVisibleMonth(),M=S.getFullYear(),I=S.getMonth(),[H,R]=n(null),O=void 0!==h?h:H,P=b||R,$=o(null),L=o(null),[A,j]=n(()=>new Date(M,I,1));r(()=>{j(e=>e.getFullYear()===M&&e.getMonth()===I?e:new Date(M,I,1))},[M,I]);const z=a(t=>{j(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[Y,F]=n(null),[V,W]=n(null),[Z,U]=n(null),[B,_]=n(!1);r(()=>{if(Z&&"blossom"===w){const e=setTimeout(()=>{_(!0)},50);return()=>clearTimeout(e)}_(!1)},[Z,w]);const[q,G]=n(null),[X,K]=n(null),[J,Q]=n(null),ee=a((e,t)=>{e.preventDefault(),e.stopPropagation(),F({x:e.clientX,y:e.clientY,calendarId:t}),W(null)},[]),te=a(e=>{e.preventDefault(),W({x:e.clientX,y:e.clientY}),F(null)},[]),ne=a(()=>{F(null)},[]),re=a(()=>{W(null)},[]),oe=a(()=>{Y&&(K({calendarId:Y.calendarId,step:"initial"}),ne())},[Y,ne]),le=a(t=>{if(Y){const{colors:n,darkColors:a}=ae(t);e.updateCalendar(Y.calendarId,{colors:n,darkColors:a}),ne()}},[e,Y,ne]),ie=a(()=>{if(Y){const e=t.find(e=>e.id===Y.calendarId);if(e){const{h:t,s:n,l:a}=f(e.colors.lineColor),r=y(a);let o=Y.x,l=Y.y;if(L.current){const e=L.current.getBoundingClientRect();o=e.left+e.width/2,l=e.top+e.height/2}U({x:o,y:l,calendarId:Y.calendarId,initialColor:{hue:t,saturation:r,lightness:a,alpha:100,layer:"outer"},currentColor:e.colors.lineColor})}ne()}},[Y,t,ne]),se=a(e=>{Y&&(G({sourceId:Y.calendarId,targetId:e}),ne())},[Y,ne]),de=a(()=>{if(q){const{sourceId:t,targetId:n}=q;e.mergeCalendars(t,n),G(null)}},[e,q]),ce=a(()=>{X&&(e.deleteCalendar(X.calendarId),K(null))},[e,X]),ue=a(e=>{X&&(G({sourceId:X.calendarId,targetId:e}),K(null))},[X]),ge=a(()=>{var e;null===(e=$.current)||void 0===e||e.click(),re()},[re]),me=a(e=>c(void 0,void 0,void 0,function*(){var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return;const a=yield Gn(n);a.events.length>0&&Q({events:a.events,filename:n.name.replace(/\.[^/.]+$/,"")}),$.current&&($.current.value="")}),[]),he=a(t=>{if(J){let n=t;if(t===xn){const t=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],a=t[Math.floor(Math.random()*t.length)],{colors:r,darkColors:o}=ae(a);n=bt(),e.createCalendar({id:n,name:J.filename,isDefault:!1,colors:r,darkColors:o,isVisible:!0})}J.events.forEach(t=>{e.addEvent(Object.assign(Object.assign({},t),{calendarId:n}))}),Q(null)}},[e,J]),ve=a(()=>{if(Y){const n=t.find(e=>e.id===Y.calendarId);if(n){Bn(e.getEvents().filter(e=>e.calendarId===n.id),{calendarName:n.name,filename:n.name||"calendar"})}ne()}},[Y,t,e,ne]),fe=q?(null===(C=t.find(e=>e.id===q.sourceId))||void 0===C?void 0:C.name)||"Unknown":"",ye=q?(null===(E=t.find(e=>e.id===q.targetId))||void 0===E?void 0:E.name)||"Unknown":"",pe=X?(null===(k=t.find(e=>e.id===X.calendarId))||void 0===k?void 0:k.name)||"Unknown":"",be=e.getReadOnlyConfig(),De=!e.state.readOnly,xe=!1!==be.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:De?te:void 0,children:[u(jt,{isCollapsed:i,onCollapseToggle:()=>s(!i)}),i?u(Yt,{calendars:t,onToggleVisibility:l,onReorder:xe?e.reorderCalendars:()=>{},onRename:De?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:De?ee:()=>{},editingId:O,setEditingId:P,activeContextMenuCalendarId:null==Y?void 0:Y.calendarId,isDraggable:xe,isEditable:De}):g(m,{children:[u(Yt,{calendars:t,onToggleVisibility:l,onReorder:xe?e.reorderCalendars:()=>{},onRename:De?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:De?ee:()=>{},editingId:O,setEditingId:P,activeContextMenuCalendarId:null==Y?void 0:Y.calendarId,isDraggable:xe,isEditable:De}),u("div",{className:"border-t border-gray-200 dark:border-slate-800",children:u(yn,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:z,onDateSelect:t=>e.setCurrentDate(t)})})]}),Y&&u(Rt,{ref:L,x:Y.x,y:Y.y,onClose:ne,className:"w-64 p-2",children:d?d(t.find(e=>e.id===Y.calendarId),ne):g(m,{children:[u($t,{children:T("calendarOptions")}),u(pn,{calendars:t,currentCalendarId:Y.calendarId,onMergeSelect:se}),u(Ot,{onClick:oe,children:T("delete")}),u(Ot,{onClick:ve,children:T("exportCalendar")||"Export Calendar"}),u(Pt,{}),u(At,{selectedColor:null===(N=t.find(e=>e.id===Y.calendarId))||void 0===N?void 0:N.colors.lineColor,onSelect:le,onCustomColor:ie})]})}),V&&v(g(Rt,{x:V.x,y:V.y,onClose:re,className:"w-max p-2",children:[u(Ot,{onClick:()=>{null==D||D(),re()},children:T("newCalendar")||"New Calendar"}),u(Ot,{onClick:ge,children:T("importCalendar")||"Import Calendar"}),u(Ot,{onClick:()=>{e.triggerRender(),re()},children:T("refreshAll")||"Refresh All"})]}),document.body),u("input",{ref:$,type:"file",accept:".ics",style:{display:"none"},onChange:me}),J&&v(u(wn,{calendars:t,filename:J.filename,onConfirm:he,onCancel:()=>Q(null)}),document.body),q&&v(u(bn,{sourceName:fe,targetName:ye,onConfirm:de,onCancel:()=>G(null)}),document.body),X&&v(u(Dn,{calendarId:X.calendarId,calendarName:pe,calendars:t,step:X.step,onStepChange:e=>K(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:ce,onCancel:()=>K(null),onMergeSelect:ue}),document.body),Z&&v(u("div",{className:"fixed inset-0 z-50",onMouseDown:()=>U(null),children:u("div",{className:"absolute flex items-center justify-center",style:{top:Z.y,left:Z.x,transform:"translate(-50%, -50%)"},onMouseDown:e=>e.stopPropagation(),children:"blossom"===w?u(p,{defaultValue:Z.initialColor,coreSize:28,petalSize:28,initialExpanded:B,openOnHover:!1,onChange:t=>{const{colors:n,darkColors:a}=ae(t.hex);e.updateCalendar(Z.calendarId,{colors:n,darkColors:a})},onCollapse:()=>U(null)}):u("div",{className:"rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",children:u(x,{width:"220px",color:Z.currentColor,onChange:e=>{U(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=ae(t.hex);e.updateCalendar(Z.calendarId,{colors:n,darkColors:a})}})})})}),document.body)]})},Kn=({options:e,value:t,onChange:a,registry:l,variant:i="desktop"})=>{const[s,d]=n(!1),[c,m]=n({}),h=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`,m(n)}};r(()=>{const e=e=>{!h.current||h.current.contains(e.target)||e.target.closest("[data-calendar-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||ne()).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-calendar-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(S,{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-calendar-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(S,{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:h,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(T,{className:"w-4 h-4 text-gray-400"})]}),x()]}:{className:"relative inline-block",ref:h,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(T,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),x()]})},Jn=/(YYYY|YY|MM|DD|HH|mm)/g,Qn=e=>e.toString().padStart(2,"0"),ea=(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`)},ta=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),na=e=>{let t,n=0,a="^";for(;null!==(t=Jn.exec(e));){a+=ta(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=ta(e.slice(n))+"$",new RegExp(a)},aa=(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}},ra=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()},oa=(e,t,n)=>{var a,r,o,l,i,s,c,u,g,m,h,v,f,y,p,b,D,x,w,C,E,k,N,T;if(!e){const e=null!=t?t:n?ra(n):d.Now.timeZoneId();return null!=n?n:d.Now.zonedDateTimeISO(e)}if(Cn(e)){const n=null!=t?t:d.Now.timeZoneId(),a=`${e.year}-${Qn(e.month)}-${Qn(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?ra(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!==(m=null==r?void 0:r.year)&&void 0!==m?m:l.year,month:null!==(h=null==r?void 0:r.month)&&void 0!==h?h: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})}},la=(e,t,n)=>{const a=ea(t,n),r={YYYY:e.year.toString(),YY:Qn(e.year%100),MM:Qn(e.month),DD:Qn(e.day),HH:Qn(e.hour),mm:Qn(e.minute)};return a.replace(Jn,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},ia=Array.from({length:24},(e,t)=>t),sa=Array.from({length:60},(e,t)=>t),da=({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(M,{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(k,{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(N,{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(I,{width:14,height:12})})]})]}),ca=(e,t)=>d.PlainDate.compare(e,t),ua=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:r,disabled:o,onDaySelect:l})=>g(m,{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===ca(e,n),s=0===ca(e,a),d=ca(e,n)>=0&&ca(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())})})]}),ga=({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=sa.includes(s)?sa:[...sa,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:ia.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:Qn(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:Qn(e)},e)})})})]})]})},ma=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:a,draftRange:r,focusedField:o,isTimeEnabled:l,disabled:i,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:m,onYearChange:h,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(da,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:m,onYearChange:h}),u(ua,{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(ga,{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"})})]})})},ha=({value:e,format:l="YYYY-MM-DD HH:mm",showTimeFormat:i="HH:mm",showTime:s=!0,onChange:c,onOk:m,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(()=>St(w,"short"),[w]),k=t(()=>Tt(w,"narrow"),[w]),N=t(()=>C?"object"==typeof s&&(null==s?void 0:s.format)?s.format:i:"",[C,s,i]),T=t(()=>ea(l,N),[l,N]),S=t(()=>na(T),[T]),M=t(()=>{const t=null!=v?v:fe(e[0])?fe(e[1])?d.Now.timeZoneId():ra(e[1]):ra(e[0]),n=oa(e[0],t);return[n,oa(e[1],t,n)]},[e,v]),[I,R]=n(M),O=o(M),[P,$]=n("start"),[L,A]=n([la(M[0],l,N),la(M[1],l,N)]),j=o([la(M[0],l,N),la(M[1],l,N)]),z=o(M),[Y,F]=n(M[0].toPlainDate().with({day:1})),[V,W]=n(!1),Z=a(e=>{W(e)},[]),[U,B]=n(y),_=o(y),q=o(null),G=o(null),X=o({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=o(!1);r(()=>{j.current=L},[L]),r(()=>{z.current=I},[I]),r(()=>{const e=O.current,t=0!==d.ZonedDateTime.compare(e[0],M[0]),n=0!==d.ZonedDateTime.compare(e[1],M[1]);(t||n)&&R(M),O.current=M},[M]),r(()=>{F(M[0].toPlainDate().with({day:1}))},[M[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=X.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=I[0].epochMilliseconds,te=I[0].offsetNanoseconds,ne=I[1].epochMilliseconds,ae=I[1].offsetNanoseconds;r(()=>{const[e,t]=z.current,n=la(e,l,N),a=la(t,l,N),[r,o]=j.current;r===n&&o===a||(j.current=[n,a],A([n,a]))},[ee,te,ne,ae,l,N]),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=G.current)||void 0===n?void 0:n.contains(a))return;a.closest("[data-range-picker-popup]")||Z(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[V]),r(()=>{V||($("start"),K.current||R(M),K.current=!1)},[V,M]);const re=a(e=>{c&&c(e,[la(e[0],l,N),la(e[1],l,N)])},[N,l,c]),oe=a(e=>{m&&m(e,[la(e[0],l,N),la(e[1],l,N)])},[N,l,m]),le=a((e,t)=>{R(n=>{const a=[...n];if("start"===e){const e=oa(a[1],ra(t),t),n=d.ZonedDateTime.compare(t,e)>0?t:e;return[t,n]}const r=oa(a[0],ra(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=ra(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(I[0],e),a=I[1].epochMilliseconds-I[0].epochMilliseconds,r=n.add({milliseconds:a});return void R([n,r])}const n=t(I[1],e),a=I[1].epochMilliseconds-I[0].epochMilliseconds;if(d.ZonedDateTime.compare(n,I[0])<0){const n=t(I[0],e),r=n.add({milliseconds:a});return void R([n,r])}const r=[I[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=oa(a[1],ra(o),o);return[o,d.ZonedDateTime.compare(o,e)>0?o:e]}const l=oa(a[0],ra(o),o);return[d.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=X.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=oa(a[1],ra(r),r);return[r,d.ZonedDateTime.compare(r,e)>0?r:e]}const o=oa(a[0],ra(r),r);return[d.ZonedDateTime.compare(o,r)>0?r:o,r]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=X.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})},[]),ue=a((e,t)=>{const n="start"===e?0:1,a=I[n],r=ra(a),o=aa(t,S,a,r);if(o){le(e,o);const t=o.toPlainDate().with({day:1});return F(t),"start"===e&&$("end"),!0}return A(e=>{const t=[...e];return t[n]=la(I[n],l,N),t}),!1},[I,N,l,S,le]),ge=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))||ue(e,t.target.value)},[ue,f,V]),he=a(e=>t=>{"Enter"===t.key&&(t.preventDefault(),ue(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ue]),ve=()=>{K.current=!0,re(I),oe(I),Z(!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,B(e))},[De]),we=e=>{if(f)return;$(e);const t=I["start"===e?0:1].toPlainDate().with({day:1});F(t);const n=De();_.current!==n&&(_.current=n,B(n)),Z(!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:L[0],onChange:ge("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:me("start"),onKeyDown:he("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:T,autoComplete:"off",disabled:f})}),u(H,{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:L[1],onChange:ge("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:me("end"),onKeyDown:he("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:T,autoComplete:"off",disabled:f})})]}),V&&(b?h.createPortal(u(ma,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:I,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:G,timeListRefs:X,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:ve,getPopupStyle:Ce}),b()):h.createPortal(u(ma,{visibleMonth:Y,monthLabels:E,weekDayLabels:k,calendarDays:be,draftRange:I,focusedField:P,isTimeEnabled:!!C,disabled:f,matchTriggerWidth:D,popupRef:G,timeListRefs:X,onMonthChange:ye,onYearChange:pe,onDaySelect:ie,onHourSelect:se,onMinuteSelect:de,onOk:ve,getPopupStyle:Ce}),document.body))]})},va=({event:e,isOpen:a,isAllDay:o,onEventUpdate:l,onEventDelete:i,onClose:s,app:c})=>{var m;const[v,f]=n(e),{t:y}=Ht();r(()=>{f(e)},[e]);const p=t(()=>(c?c.getCalendarRegistry():ne()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),b=t(()=>!yt(e,v),[e,v]),D=t(()=>fe(v.start)?v.end&&!fe(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(Kn,{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(ha,{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(ha,{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!==(m=v.description)&&void 0!==m?m:"",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=fe(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=fe(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?h.createPortal(E,k):null},fa=({calendar:e,mode:t="buttons"})=>{const[a,l]=n(!1),i=o(null),{t:s}=Ht(),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:`${un} transition-transform duration-200 ${a?"rotate-180":""}`,children:u(R,{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))}))},ya=0,pa=1970,ba=2100,Da=8,xa=100,wa=1200,Ca=900,Ea=700;class ka{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}}}ka.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const Na=()=>{const[e,t]=n({yearHeight:Ea,screenSize:"desktop"});return r(()=>{const e=()=>{const e=window.innerWidth;t(e<640?{yearHeight:wa,screenSize:"mobile"}:e<900?{yearHeight:Ca,screenSize:"tablet"}:{yearHeight:Ea,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Ta=({currentDate:e,yearHeight:l,onCurrentYearChange:i})=>{const s=e.getFullYear(),d=(s-pa)*l,[c,u]=n(d),[g,m]=n(600),[h,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=(h-pa)*l;u(e),x.current=e,p.current&&(p.current.scrollTop=e)},[l,h]);const C=t(()=>{const e=performance.now(),t=ba-pa+1,n=t*l,a=Math.floor(c/l),r=Math.min(t-1,Math.ceil((c+g)/l)),o=Math.max(0,a-ya),i=Math.min(t-1,r+ya),s=[];for(let e=o;e<=i;e++)s.push({index:e,year:pa+e,top:e*l,height:l});const d=performance.now()-e;return ka.trackRenderTime(d),{totalHeight:n,visibleItems:s}},[c,g,l]),E=a(e=>{const t=performance.now();if(t-D.current<Da)return;D.current=t;const n=e.currentTarget.scrollTop,a=Math.abs(n-x.current);x.current=n,ka.trackScrollEvent(a),requestAnimationFrame(()=>{u(n);const e=n,t=Math.floor(pa+e/l);t!==h&&t>=pa&&t<=ba&&(v(t),null==i||i(t))}),y(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{y(!1)},xa)},[g,h,l,i]);r(()=>{const e=p.current;if(!e)return;e.scrollTop=d,x.current=d;const t=new ResizeObserver(([e])=>{m(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[d]);const k=a((e,t=!0)=>{if(!p.current)return;const n=(e-pa)*l;p.current.scrollTo({top:Math.max(0,n),behavior:t?"smooth":"auto"})},[l]),N=a(()=>{const e=Math.max(pa,h-1);v(e),k(e)},[h,k]),T=a(()=>{const e=Math.min(ba,h+1);v(e),k(e)},[h,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:h,isScrolling:f,virtualData:C,scrollElementRef:p,handleScroll:E,scrollToYear:k,handlePreviousYear:N,handleNextYear:T,handleToday:S,setScrollTop:u,setContainerHeight:m,setCurrentYear:v,setIsScrolling:y}},Sa=e=>{if(!e)return"";let t,n,a;e instanceof Date?(t=e.getFullYear(),n=e.getMonth()+1,a=e.getDate()):fe(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}`},Ma=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,Ia=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}`},Ha=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),Ra={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"},Oa=(e,t,n)=>e?t:n,Pa=(...e)=>e.filter(Boolean).join(" "),$a=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 La(e,t=!1){if(e instanceof d.PlainDate||e instanceof d.PlainDateTime)return e;if(e instanceof Date)return t?Tn(e):Sn(e);throw new Error("Invalid time type: "+typeof e)}function Aa(e,t){if(e instanceof d.ZonedDateTime)return e;if(e instanceof Date)return Mn(e,t);throw new Error("Invalid time type: "+typeof e)}function ja(e){var t;const n=La(e.start,e.allDay),a=La(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 za(e){const t=Aa(e.start,e.timeZone),n=Aa(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 Ya(e){return e.map(e=>ja(e))}function Fa(e){return e.map(e=>za(e))}function Va(e,t,n,a){return ja(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))}function Wa(e,t,n,a,r){return ja(Object.assign({id:e,title:t,start:n,end:a},r))}function Za(e,t,n,a,r=!1,o){return ja(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))}function Ua(e,t,n,a,r,o){return za(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))}const Ba=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):xe(e)}catch(e){return new Date}},_a=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},qa=(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}},Ga=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=Ba(e.start),r=_a(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 Xa=null;const Ka=()=>{const[e,t]=n(()=>Xa||{weekHeight:K,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(G,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(X,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(K,a),screenSize:"desktop",weeksPerView:6};Xa&&Xa.screenSize===r.screenSize&&Xa.weekHeight===r.weekHeight&&Xa.weeksPerView===r.weeksPerView||(Xa=r,t(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Ja=({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]),m=t(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),at(t,s)},[e,s]),h=t(()=>{const t=new Date(e);t.setDate(1),t.setHours(0,0,0,0);const n=m.findIndex(e=>e.days.some(e=>e.date.toDateString()===t.toDateString()));return n>0?n*l:0},[m,e,l]),[v,f]=n(h),[y,p]=n(600),[b,D]=n(g(e.getMonth(),e.getFullYear())),[x,w]=n(e.getFullYear()),[C,E]=n(!1),[k,N]=n(m),[T,S]=n(!1),M=o(!1),[I,H]=n(!1),R=o(e),O=o(null),P=o(null),$=o(new J),L=o(0),A=o(0),j=o(!1),z=a(e=>{e&&(O.current=e)},[]),Y=a(e=>{let t=$.current.get(e);return console.log("weekData",t),t||(t=et(e),$.current.set(e,t)),t},[]),F=a((e,t=26)=>{j.current||(j.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(()=>{j.current=!1},200)}},0))},[k,Y,l]),V=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]),W=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]),Z=a(e=>{const t=performance.now();if(t-L.current<_)return;L.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&&!j.current&&F("future",26),a<10*l&&!j.current&&F("past",26)}),E(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{E(!1)},q)},[l,F,T]),U=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 m=Math.min(c+10,52);if(u){const a=[];for(let e=m;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<=m;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]),B=a(()=>{const e=k[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);U(t)},[V.displayStartIndex,k,U]),G=a(()=>{const e=k[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);U(t)},[V.displayStartIndex,k,U]),X=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(()=>{U(a,!0),setTimeout(()=>{M.current=!1,S(!1)},200)})},[k,l,i,U]);return r(()=>{W(V.visibleItems)},[V.visibleItems,W]),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),U(e,!0)}R.current=e},[e,i,U]),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&&h>0?(e.scrollTop=h,f(h),H(!0)):e&&H(!0)})},[I,h,c]),r(()=>()=>{P.current&&clearTimeout(P.current)},[]),{scrollTop:v,containerHeight:y,currentMonth:b,currentYear:x,isScrolling:C,virtualData:V,scrollElementRef:O,handleScroll:Z,scrollToDate:U,handlePreviousMonth:B,handleNextMonth:G,handleToday:X,setScrollTop:f,setContainerHeight:p,setCurrentMonth:D,setCurrentYear:w,setIsScrolling:E,cache:$.current,scrollElementRefCallback:z,weeksData:k}},Qa=({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===U.DAY,{screenSize:c}=Ka(),m="mobile"===c,{t:h}=Ht();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:cn,title:m?h("newEvent")||"New Event":h("createCalendar")||"Add Calendar",children:u(O,{className:`h-4 w-4 ${un}`})})}),u("div",{className:"flex-1 flex justify-center",children:s&&u(fa,{mode:t,calendar:e})}),!s&&u(fa,{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 ${cn}`,children:u(P,{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(P,{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"})]})})]})]})]})},er=i(void 0),tr=({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=$a(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 m={theme:l,effectiveTheme:c,setTheme:g};return u(er.Provider,{value:m,children:e})},nr=()=>{const e=l(er);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},ar=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],rr=({onClose:e,onCreate:a,colorPickerMode:r="default"})=>{const{t:o}=Ht(),{effectiveTheme:l}=nr(),[i,s]=n(""),[d,c]=n(ar[Math.floor(Math.random()*ar.length)]),[h,f]=n(!1),[x,C]=n(""),E=t(()=>{const e=b[Math.floor(Math.random()*b.length)],t=e.layer||"outer",n=y(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[k,N]=n(null),T="dark"===l,S={default:{picker:{background:T?"#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:T?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:T?"#1e293b":"#ffffff",borderBottom:T?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:T?"#1e293b":"#ffffff"},controls:{border:T?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:T?"#374151":"#ffffff",color:T?"#f3f4f6":"#1f2937",border:T?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:T?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:T?"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-white dark:bg-slate-900 animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[u("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("blossom"===r?"mb-6":"mb-4"),children:o("createCalendar")}),g("form",{onSubmit:t=>{var n;if(t.preventDefault(),!i.trim())return;let o;o="blossom"===r?null!==(n=null==k?void 0:k.hex)&&void 0!==n?n:D(E.hue,E.saturation,E.lightness):d;const{colors:l,darkColors:s}=ae(o),c={id:bt(),name:i.trim(),colors:l,darkColors:s,isVisible:!0,isDefault:!1};a(c),e()},children:["blossom"===r?g("div",{className:"mb-8 flex items-center gap-4",children:[u("div",{className:"flex-1",children:u("input",{type:"text",value:i,onChange:e=>s(e.target.value),className:"w-full 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:o("calendarNamePlaceholder"),autoFocus:!0})}),u("div",{className:"w-9 h-9 relative shrink-0",children:u("div",{className:"absolute inset-0 flex items-center justify-center",children:u(p,{defaultValue:E,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>N(e),onCollapse:e=>N(e),className:"z-50"})})})]}):g(m,{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:d}}),u("input",{type:"text",value:i,onChange:e=>s(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:o("calendarNamePlaceholder"),autoFocus:!0})]})}),g("div",{className:"mb-6",children:[u("div",{className:"grid grid-cols-7 gap-6",children:ar.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 "+(d===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>c(e)},e))}),g("div",{className:"mt-2 relative",children:[u("button",{type:"button",onClick:()=>{C(d),f(!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:o("customColor")}),h&&u("div",{className:"absolute left-0 top-full z-10001 mt-2",children:u(w,{color:d,onChange:e=>{c(e.hex)},onAccept:()=>{f(!1)},onCancel:()=>{c(x),f(!1)},styles:S})})]})]})]}),g("div",{className:"flex justify-end space-x-3",children:[u("button",{type:"button",onClick:e,className:Zt,children:o("cancel")}),u("button",{type:"submit",disabled:!i.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:bg-primary/90 disabled:opacity-50",children:o("create")})]})]})]})}),document.body)},or=({loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>{const{t:i,locale:s}=Ht(),d=t(()=>_a(new Date),[]),c=t(()=>Ga(a,d),[a,d]),m=e=>Ba(e);return n?g("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[u($,{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(lr,{}),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}=qa(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=m(t.start),a=m(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())})})},lr=()=>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"})}),ir=({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(or,{loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})})}),sr=({isOpen:e,onClose:t,keyword:n,onSearchChange:a,results:l,loading:i,onResultClick:s,emptyText:d})=>{const c=o(null),{t:m}=Ht();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(L,{className:"w-6 h-6"})}),g("div",{className:"flex-1 relative",children:[u("input",{ref:c,type:"text",placeholder:m("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(A,{className:"w-4 h-4"})})]})]}),u("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:u(or,{loading:i,results:l,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},dr=({app:e,anchorRef:a,onClose:l,isOpen:i})=>{const{t:d}=Ht(),[c,m]=n(""),[h,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),m(""),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=bt(),a={id:n,title:t.title,start:pe(t.start),end:pe(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[h]&&M(S[h]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i,S,h]);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=>m(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===h?"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},cr=({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":"")})}),ur=({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(),m=5*Math.round(e.getMinutes()/5),h=(24+c)*d,v=(12+m/5)*d,[f,y]=n(h),[p,b]=n(v),D=o(null),x=o(null),w=o(null);r(()=>{D.current&&(D.current.scrollTop=h,y(h)),x.current&&(x.current.scrollTop=v,b(v))},[h,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===m?"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"})]})},gr=({isOpen:t,onClose:a,onSave:o,draftEvent:l,app:i})=>{const{locale:s,t:d}=Ht(),[c,m]=n(""),[h,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]=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);L(e)}},[t,l,i]);const A=i.getCalendars(),j=A.map(e=>({label:e.name,value:e.id}));r(()=>{if(t&&A.length>0){A.some(e=>e.id===h)||"blue"!==h&&""!==h||f(A[0].id)}},[A,t,h]),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(m(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=xe(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=xe(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:h,allDay:y,description:C,start:pe(e),end:pe(n)});return!yt(l,a)},[t,l,c,h,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($?"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:h,allDay:y,start:pe(e),end:pe(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($?"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=>m(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(Kn,{options:j,value:h,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(cr,{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:We(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(yn,{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(ur,{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:We(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(yn,{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(ur,{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)},mr=({locale:e="en-US",messages:n,children:a})=>{const r=t(()=>{if("string"==typeof e){return{code:ve(e)?e:"en-US",messages:void 0}}return e&&!ve(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:Mt(t,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replace(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:Tt,getMonthLabels:St,isDefault:!1}},[r,n]);return u(It.Provider,{value:o,children:a})},hr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],vr=({locale:e,messages:t,children:n})=>Ht().isDefault?u(mr,{locale:e,messages:t,children:n}):u(m,{children:n}),fr=({calendar:e,className:l,style:i,customDetailPanelContent:s,customEventDetailDialog:d,meta:m,search:h})=>{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}=Ht(),[T,S]=n(!1),[M,I]=n(null),[H,R]=n(!1),O=o(null),[P,$]=n(!1),[L,A]=n(!1),[j,z]=n(null),[Y,F]=n(()=>y.getTheme()),[V,W]=n(""),[Z,U]=n(!1),[B,_]=n(!1),[q,G]=n(!1),[X,K]=n([]);r(()=>{const e=()=>{$(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),r(()=>{var e;if(!V.trim())return U(!1),K([]),void y.highlightEvent(null);const t=null!==(e=null==h?void 0:h.debounceDelay)&&void 0!==e?e:300,n=setTimeout(()=>c(void 0,void 0,void 0,function*(){var e;G(!0),U(!0);try{let t=[];if(null==h?void 0:h.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=h.customSearch({keyword:V,events:e})}else if(null==h?void 0:h.onSearch)t=yield h.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==h?void 0:h.onSearchStateChange)||void 0===e||e.call(h,{keyword:V,loading:!1,results:t})}catch(e){console.error("Search failed",e),K([])}finally{G(!1)}}),t);return()=>clearTimeout(n)},[V,h,y]),r(()=>{Z||y.highlightEvent(null)},[Z,y]);const J=e=>{let t;t=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):xe(e.start),y.setCurrentDate(t),y.highlightEvent(e.id),B&&_(!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 Q=a(e=>{y.setTheme(e)},[y]),ee=a(()=>{C(e=>e+1)},[]),te=t(()=>y.getCalendars(),[y,w,e]),ne=a((e,t)=>{y.setCalendarVisibility(e,t),ee()},[y,ee]),re=a(e=>{y.setAllCalendarsVisibility(e),ee()},[y,ee]),le=a(()=>{if("modal"===(D.createCalendarMode||"inline"))return void S(!0);const e=hr[Math.floor(Math.random()*hr.length)],{colors:t,darkColors:n}=ae(e),a=bt(),r={id:a,name:N("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};y.createCalendar(r),I(a),ee()},[y,D.createCalendarMode,N,ee]),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:bt(),title:"",start:pe(e),end:pe(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()?va:void 0),ce={app:y,config:p.config||{},customDetailPanelContent:s,customEventDetailDialog:de,switcherMode:y.state.switcherMode,calendarRef:se,meta:m},ue={app:y,calendars:te,toggleCalendarVisibility:ne,toggleAll:re,isCollapsed:E,setCollapsed:k,renderCalendarContextMenu:D.renderCalendarContextMenu,createCalendarMode:D.createCalendarMode,renderCreateCalendarDialog:D.renderCreateCalendarDialog,editingCalendarId:M,setEditingCalendarId:I,onCreateCalendar:le,colorPickerMode:D.colorPickerMode},ge=oe(null==D?void 0:D.width,"240px"),me=y.getCalendarHeaderConfig(),he={calendar:y,switcherMode:y.state.switcherMode,onAddCalendar:ie,onSearchChange:W,onSearchClick:()=>{W(""),_(!0)},searchValue:V,isSearchOpen:Z,isEditable:!y.state.readOnly},ve=y.getCustomMobileEventRenderer()||gr;return u(tr,{initialTheme:Y,onThemeChange:Q,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(Xn,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(he):u(Qa,Object.assign({},he)),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(ir,{isOpen:Z,onClose:()=>{U(!1),W(""),y.highlightEvent(null)},loading:q,results:X,keyword:V,onResultClick:J,emptyText:null==h?void 0:h.emptyText})]}),u(sr,{isOpen:B,onClose:()=>{_(!1),W(""),y.highlightEvent(null)},keyword:V,onSearchChange:W,results:X,loading:q,onResultClick:J,emptyText:null==h?void 0:h.emptyText})]})]}),u(dr,{app:y,anchorRef:O,isOpen:H,onClose:()=>R(!1)}),u(ve,{isOpen:L,onClose:()=>{A(!1),z(null)},onSave:e=>{y.addEvent(e),A(!1),z(null)},draftEvent:j,app:y}),T&&(D.renderCreateCalendarDialog?D.renderCreateCalendarDialog({onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ee()},colorPickerMode:D.colorPickerMode}):u(rr,{onClose:()=>S(!1),onCreate:e=>{y.createCalendar(e),S(!1),ee()},colorPickerMode:D.colorPickerMode}))]})})},yr=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return u(vr,{locale:a.state.locale,messages:n,children:u(fr,Object.assign({},e))})},pr=({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,m=n.getCurrentDate(),h=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:m,currentView:h,events:v,onEventUpdate:f,onEventDelete:y,onEventCreate:p,onDateChange:b,onViewChange:D,config:x}),[n,m,h,v,f,y,p,b,D,x]),C=t(()=>{const e={currentDate:m,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(m);switch(h){case U.DAY:e.setDate(e.getDate()-1);break;case U.WEEK:e.setDate(e.getDate()-7);break;case U.MONTH:e.setMonth(e.getMonth()-1)}b(e)},goToNext:()=>{const e=new Date(m);switch(h){case U.DAY:e.setDate(e.getDate()+1);break;case U.WEEK:e.setDate(e.getDate()+7);break;case U.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})},[m,v,h,f,y,p,b,D,w,c,g,o,l,i,s,d]);return u(e,Object.assign({},C))};function br(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:Re(e.start),_endHour:e.allDay?0:Be(e)})}function Dr(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:Re(e.start)}function xr(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:Be(e)}const wr=.25,Cr=.5,Er=25,kr=1,Nr=.9;class Tr{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(br);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&&(Dr(e)<xr(t)&&Dr(t)<xr(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-Nr,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=Dr(e),a=Dr(t);if(n!==a)return n-a;return xr(t)-Dr(t)-(xr(e)-Dr(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(Dr(a)-Dr(t))<=wr&&(r.push(t),n.add(t.id))}r.sort((e,t)=>Dr(e)-Dr(t));const o={events:r,startHour:Math.min(...r.map(e=>Dr(e))),endHour:Math.max(...r.map(e=>xr(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(Dr(e)-Dr(t));if(n<=wr)return!0;if(n>wr&&n<Cr)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=xr(e)-Dr(e);if(n<1.25)return!1;const a=Dr(e)+.4*n,r=Dr(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<Cr)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(Dr(e)-Dr(n));if(t<=wr)return!0;if(t>wr&&t<Cr)return!0}return!1}static canEventContain(e,t){const n=Dr(e)<=Dr(t)&&xr(e)>=xr(t),a=Dr(e)<=Dr(t)&&Dr(t)<xr(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=xr(e)-Dr(e);return xr(t)-Dr(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 xr(e)-Dr(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?xr(t)-Dr(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(Dr(e)-Dr(t.parent))-Math.abs(Dr(e)-Dr(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-Nr;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-kr*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+kr);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,Er),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=xr(e.event)-Dr(e.event);return xr(t.event)-Dr(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?kr*(d?.15:.3):kr*(d?.1:.2);const m=(u-g*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(m+g);if(a.set(e.event.id,{id:e.event.id,left:n,width:m,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=xr(e.event)-Dr(e.event);return xr(t.event)-Dr(t.event)-n});if(1===t.length)this.calculateNodeLayoutWithVirtualParallel(t[0],n,m,a,r);else{this.shouldChildrenBeParallel(t.map(e=>e.event))?this.calculateParallelChildrenLayout(t,n,m,a,r):t.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,n,m,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=xr(e)-Dr(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 Sr={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>Fe(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const Mr=e=>{const{viewType:r,onEventsUpdate:l}=e,i=r===U.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),m=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]),h=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:h,throttledSetEvents:m}},Ir={renderAllDayContent:({title:e,color:t})=>g("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[u(j,{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(m,{children:[u("div",{className:tn,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(m,{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(m,{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})})]})},Hr=({drag:e,color:t,title:n,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,renderer:s=Ir,isMobile:d})=>{const{t:c}=Ht(),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})})},Rr=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:r})=>{const{t:o}=Ht(),l=(()=>{if(t)return{title:o("newEvent"),icon:u(z,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&r){const t=Se(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})})]})},Or=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}},Pr=n=>{const r=t(()=>Object.assign(Object.assign(Object.assign({},Sr),n),{getLineColor:e=>{var t;return n.getLineColor?n.getLineColor(e):Fe(e,null===(t=n.app)||void 0===t?void 0:t.getCalendarRegistry())}}),[n]),{viewType:l}=r,i=l===U.MONTH||l===U.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===U.MONTH,g=o===U.WEEK,m=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]),h=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:m,getColumnDayIndex:h,checkIfInAllDayArea:f,handleDirectScroll:v,daysDifference:a((e,t)=>Se(e,t),[]),addDaysToDate:a((e,t)=>Me(e,t),[]),getTargetDateFromPosition:a((e,t)=>{if(o!==U.MONTH&&o!==U.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=Mr(r),c=(t=>{const{t:n,locale:r}=Ht(),{calendarRef:l,allDayRowRef:i,viewType:s,getLineColor:d,getDynamicPadding:c,renderer:u,HOUR_HEIGHT:g=72,FIRST_HOUR:m=0,TIME_COLUMN_WIDTH:h=80,ALL_DAY_HEIGHT:v=60,app:f,isMobile:y}=t,p=s===U.MONTH||s===U.YEAR,b=s===U.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=pe(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(mr,{locale:r},e.createElement(Rr,{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=`${h}px`,P.style.top=E.offsetTop-2+"px",P.style.width=`calc(100% - ${h}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-m)*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=`${h}px`,P.style.width=`calc(100% - ${h}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-m)*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=`${h}px`,P.style.width=`calc(((100% - ${h}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% - ${h}px)`:`calc(${y&&!b?"175%":"100%"} / 7)`;P.style.left=b?`${h}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(mr,{locale:r},e.createElement(Hr,{drag:t,color:a,title:o,layout:s,allDay:t.allDay,formatTime:We,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}a?(P.style.backgroundColor=Ye(a,null==f?void 0:f.getCalendarRegistry()),P.style.color=ze(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,We,d,c,u,h,v,m,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=`${h}px`,o.style.width=`calc(100% - ${h}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-m)*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=`${h}px`,o.style.width=`calc(((100% - ${h}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% - ${h}px)`:`calc(${n} / 7)`;o.style.left=b?`${h}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(mr,{locale:r},e.createElement(Hr,{drag:t,color:w.current.color,title:w.current.title,layout:C||w.current.layout,allDay:D,formatTime:We,getLineColor:d||(()=>""),getDynamicPadding:c||(()=>"0px"),renderer:u,isMobile:y})))}}},[p,i,We,l,b,v,h,m,g,d,c,u]);return{dragIndicatorRef:D,reactRootRef:x,removeDragIndicator:C,createDragIndicator:E,updateDragIndicator:k}})(r),u=(e=>{const{t:t}=Ht(),{options:n,common:r,state:o,manager:l}=e,{viewType:i,onEventsUpdate:s,onEventCreate:d,onEventEdit:c,calculateNewEventLayout:u,calculateDragLayout:g,currentWeekStart:m,events:h,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===U.MONTH||i===U.YEAR,$=i===U.DAY,L=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())/L);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<L)return 0}return o},j=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}=Or(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.dayIndex:S(i);if(d){if(!l.allDay){l.allDay=!0,l.startHour=0,l.endHour=0,l.eventDate=m?lt(m,c):new Date,E(),l.indicatorVisible=!1;const e=null==h?void 0:h.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=Ue(e),l.endHour=l.startHour+1,l.duration=1,l.hourOffset=0,l.eventDate=m?lt(m,c):new Date,E(),l.indicatorVisible=!1;const t=null==h?void 0:h.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=Ue(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=m?lt(m,c):new Date,x(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:Ue(l.startHour),endHour:Ue(l.endHour),allDay:!1}));let a=null;if("move"===l.mode&&l.eventId&&g){const e=null==h?void 0:h.find(e=>e.id===l.eventId);e&&(a=g(e,c,Ue(l.startHour),Ue(l.endHour)))}N(c,Ue(l.startHour),Ue(l.endHour),!1,a)}},[g,M,k,m,h,v,S,I,f,$,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",j),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",j,{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=Ue(e.startHour),o=Ue(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;m?lt(m,e.dayIndex):xe(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):xe(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=be(a),d=be($e(r))}else{const n=xe(t.start),l=xe(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=pe(e),d=pe(t)}else{const t=m?lt(m,e.dayIndex):new Date,n=Oe(t,r),a=Oe(t,o);s=pe(n),d=pe(a)}}const c=e.originalDay+i;return Object.assign(Object.assign({},t),{day:c,start:s,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",j,{capture:!0}),document.removeEventListener("touchend",z),E(),w()},[j,E,w,s,y,m,b]),Y=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:L,clientY:j}=Or(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(L-x.startX,j-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(L,j)}const e=O(L,j);if(!e)return;if("resize"===x.mode&&x.originalEvent&&x.resizeDirection){const t=xe(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=xe(x.originalEvent.end)||t;a=new Date(i),r(a,l),n>a&&(n=a)}else{const i=xe(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?be(n):pe(n),s=x.originalEvent.allDay?be(a):pe(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(j),x.lastClientY=j;const e=T(j);if("create"===x.mode&&x.allDay){const e=Math.hypot(L-x.startX,j-x.startY);if(!x.indicatorVisible){if(e<3)return;k(x,"blue",t("newAllDayEvent")),x.indicatorVisible=!0}const n=$?x.dayIndex:S(L);return x.dayIndex=n,void N(n,0,0,!0)}if("resize"===x.mode)if(x.allDay){const e=$?x.dayIndex:S(L);let t=x.originalStartDate||new Date,n=x.originalEndDate||new Date;"left"===x.resizeDirection?(t=m?lt(m,e):new Date,t>n&&(t=n)):"right"===x.resizeDirection&&(n=m?lt(m,e):new Date,n<t&&(n=t)),x.originalStartDate=new Date(t.getTime()),x.originalEndDate=new Date(n.getTime());const a=be(t),r=be(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==h?void 0:h.find(e=>e.id===x.eventId);let r=x.dayIndex;if(a){const e=xe(a.start),t=xe(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=$?x.dayIndex:S(L),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<Ve&&(t=x.originalEndHour-Ve)))}else if("bottom"===x.resizeDirection){const a=$?x.dayIndex:S(L),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<Ve&&(n=x.startHour+Ve))}else if("right"===x.resizeDirection){const e=$?x.dayIndex:S(L);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]=[Ue(t),Ue(n)];x.startHour=t,x.endHour=n,x.dayIndex=l,C(e=>e.map(e=>{if(e.id!==x.eventId)return e;const t=xe(e.start),n=Oe(m?lt(m,l):t,u),a=m?lt(m,o):t,r=Oe(a,g),i=pe(n),s=pe(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=Ue(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=Ue(e),[n,a]=j<x.startY?[t,Math.max(t+Ve,x.endHour)]:[x.startHour,Math.max(x.startHour+Ve,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=$?x.dayIndex:S(L);let n=Ue(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==h?void 0:h.find(e=>e.id===x.eventId);e&&(r=g(e,t,Ue(n),Ue(a)))}N(t,Ue(n),Ue(a),!1,r)}}},[P,$,N,O,C,H,R,v,f,u,S,T,I,g,h,b,k]),F=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",Y),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",Y,{capture:!0}),document.removeEventListener("touchend",F),void w();const{clientX:u,clientY:g}=Or(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?be(o.originalStartDate):pe(o.originalStartDate),a=e?be(o.originalEndDate):pe(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)?xe(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?be(o.originalStartDate):pe(o.originalStartDate),n=e?be(o.originalEndDate):pe(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=xe(t.start),a=xe(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?be(r):pe(r),s=t.allDay?be(l):pe(l);return Object.assign(Object.assign({},t),{start:i,end:s})})))}}else{let[e,n]=[Ue(o.startHour),Ue(o.endHour)];if(n-e<y&&("top"===o.resizeDirection?e=n-y:n=e+y),"create"===o.mode){const a=m?lt(m,o.dayIndex):new Date;x(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t);const r=Oe(a,e),l=Oe(a,n),i=o.allDay,s=i?be(r):pe(r),c=i?be(l):pe(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",Y),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",Y,{capture:!0}),document.removeEventListener("touchend",F),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[P,Y,E,w,O,C,y,m,d,s,b,x]),V=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}=Or(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=pe(n),l=pe(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=Ue(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:m?lt(m,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",Y),document.addEventListener("mouseup",F),document.addEventListener("touchmove",Y,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}},[P,d,c,m,u,k,Y,F,b,x]),W=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}=Or(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=xe(t.start),n=xe(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",Y),document.addEventListener("mouseup",F),document.addEventListener("touchmove",Y,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}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:Re(t.start);let m=0;if(t.allDay&&t.start&&t.end){const e=xe(t.start);e.setHours(0,0,0,0);const n=xe(t.end);n.setHours(0,0,0,0),m=Math.floor((n.getTime()-e.getTime())/864e5)}const h=xe(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:Be(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:Re(t.start),originalEndHour:Be(t),allDay:t.allDay||!1,eventDate:h,eventDurationDays:m,startDragDayIndex:u,calendarId:t.calendarId,title:t.title}),!t.allDay){s.hourOffset=g-e;const n=xe(t.start),a=xe(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:Re(t.start),endHour:Be(t),allDay:t.allDay||!1}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",j),document.addEventListener("mouseup",z),document.addEventListener("touchmove",j,{capture:!0,passive:!1}),document.addEventListener("touchend",z)}},[P,k,F,Y,j,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}=Or(e),u=b.current;if(u){if(P){const e=xe(t.start),a=xe(t.start),r=xe(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=xe(t.start),a=xe(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:Re(t.start),endHour:Be(t),originalDay:null!==(i=t.day)&&void 0!==i?i:0,originalStartHour:Re(t.start),originalEndHour:Be(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?Re(t.start)-e:Be(t)-e,allDay:!1}),x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(s=t.day)&&void 0!==s?s:0,startHour:Re(t.start),endHour:Be(t),allDay:!1})}document.addEventListener("mousemove",Y),document.addEventListener("mouseup",F),document.addEventListener("touchmove",Y,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}},[P,Y,F,T,b,x]);return{handleDragMove:Y,handleDragEnd:F,handleCreateStart:V,handleMoveStart:W,handleResizeStart:Z,handleUniversalDragMove:j,handleUniversalDragEnd:z}})({options:r,common:s,state:d,manager:c}),g=(e=>{const{t:t}=Ht(),{options:n,common:r,state:o,manager:l,handleDragMove:i,handleDragEnd:s}=e,{viewType:d,currentWeekStart:c,app:u}=n,{dragRef:g,setDragState:m}=o,{createDragIndicator:h}=l,{pixelYToHour:v,getColumnDayIndex:f}=r,y=d===U.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?lt(c,a):new Date,r=be(e),o=be(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?lt(c,a):new Date}),m({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,m,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}),m=(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:m.daysDifference,addDaysToDate:m.addDaysToDate,getTargetDateFromPosition:m.getTargetDateFromPosition}:{handleCreateAllDayEvent:g.handleCreateAllDayEvent,pixelYToHour:g.pixelYToHour,getColumnDayIndex:g.getColumnDayIndex})};function $r(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[U.DAY,U.WEEK,U.MONTH,U.YEAR]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{re.log("Drag plugin installed - providing drag capabilities")},api:n}}function Lr(e,t){const n=e.getPlugin("drag"),a=Pr(Object.assign(Object.assign({},t),{app:e}));if(!n)return re.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 Ar(e){const{app:t,onEventCreated:n}=e,{t:r}=Ht(),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 jr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Ht();return g("div",{className:"df-navigation flex items-center gap-1",children:[u("button",{className:on,onClick:e,"aria-label":"Previous month",children:u(k,{className:ln})}),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:on,onClick:n,"aria-label":"Next month",children:u(N,{className:ln})})]})},zr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:r,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s})=>{const{t:d,locale:c}=Ht();return u("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",children:g("div",{className:`${vn} 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:Vt,style:{position:"relative"},children:u("div",{children:u("h1",{className:Wt,children:" "})})}),u(jr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),u(yn,{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:`${un} ${hn}`,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:Fe(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[u("div",{className:`font-medium ${hn}`,children:t.title}),!t.allDay&&g("div",{className:`${mn} ${gn}`,children:[We(Re(t.start))," -"," ",We(Be(t))]}),t.allDay&&u("div",{className:`${mn} ${gn}`,children:d("allDay")})]},t.id))})]})]})})},Yr=({viewType:e,currentDate:t,onPrevious:n,onNext:a,onToday:r,customTitle:o,customSubtitle:l,showTodayBox:i,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:m=0})=>{const{locale:h}=Ht(),v=void 0===i||i,f=o||(()=>{switch(e){case"day":return t.toLocaleDateString(h,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(h,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),y="day"===e?l||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return g("div",{className:Vt,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:Wt,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&u("h1",{className:Wt,style:{position:"absolute",top:0,left:0,transform:`translateY(${m}px)`,willChange:"transform"},children:c})]}:{children:[u("div",{className:`${Wt} 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(jr,{handlePreviousMonth:n,handleNextMonth:a,handleToday:r})})]})},Fr=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(Y,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?u(F,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?u(V,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?u(W,{className:"h-3 w-3"}):u(j,{className:"h-3 w-3"})},Vr=(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=xe(e.start),o=xe(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=Se(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,m=u>a?a:u,h=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),v=Math.min(6,Math.floor((m.getTime()-t.getTime())/864e5)),f=c>=t,y=u<=a,p=0===h||6===v;let b;b=f&&y?"single":f?p&&6===v?"start-week-end":"start":y?p&&0===h?"end-week-start":"end":"middle";const D=Se(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:h,endDayIndex:v,segmentType:b,totalDays:D,segmentIndex:0,isFirstSegment:f,isLastSegment:y})}),n},Wr=(e,t)=>{if(e.allDay)return[];const n=xe(e.start),a=xe(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=Se(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,m=u&&i?a.getHours()+a.getMinutes()/60:24;c.push({dayIndex:l,startHour:g,endHour:m,isFirst:s,isLast:u})}return c},Zr=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:h=!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&&h?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:Ye(w),color:"#fff"}:{backgroundColor:je(w),color:ze(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} (${Sa(t.event.start)} - ${Sa(t.event.end)})`,children:[d&&o&&h&&g(m,{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:Fe(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:Fe(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=Re(t.event.start),r=Be(t.event),o=We(a),l=We(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&&Fr(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:Fe(n),width:"12px",height:"12px"},children:Fr(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:Fe(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});Zr.displayName="MultiDayEvent";const Ur=({event:e,position:n,panelRef:a,isAllDay:r,eventVisibility:o,calendarRef:l,selectedEventElementRef:i,onEventUpdate:s,onEventDelete:c,app:m})=>{var v;const{effectiveTheme:f}=nr(),y=$a(f),{t:p}=Ht(),b="dark"===y||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),D=!(null==m?void 0:m.state.readOnly);if(!(!1!==(null==m?void 0:m.getReadOnlyConfig().viewable)))return null;const x=b?"#1f2937":"white",w=b?"rgb(55, 65, 81)":"rgb(229, 231, 235)",C=t(()=>(m?m.getCalendarRegistry():ne()).getVisible().map(e=>({label:e.name,value:e.id})),[m,null==m?void 0:m.getCalendars()]),E=t(()=>fe(e.start)?e.end&&!fe(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 m=12,h=Math.max(m,Math.min(g,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:h-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:`${sn} 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(Kn,{options:C,value:e.calendarId||"blue",onChange:t=>{s(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==m?void 0:m.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(ha,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!D,onChange:k,onOk:k,locale:null==m?void 0:m.state.locale})]}:{className:"mb-3",children:[u("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("timeRange")}),u(ha,{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==m?void 0:m.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=fe(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=fe(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?h.createPortal(T,S):null},Br=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:r,calendarRef:o,selectedEventElementRef:l,onEventUpdate:i,onEventDelete:s,onClose:d,contentRenderer:c})=>{const{effectiveTheme:m}=nr(),v=$a(m),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 m=12,h=Math.max(m,Math.min(g,c));a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:h-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:`${sn} 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 h.createPortal(b,document.body)},_r=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const r=`${Math.floor(Re(e.start)).toString().padStart(2,"0")}:${Math.round(Re(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:Fe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${fn} 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:`${mn} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:r})]})},qr=({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:`${fn} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?u("span",{className:`inline-block ${fn} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):u(j,{className:`${nn} ${t?"text-white":""}`})),u("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Gr=({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(j,{className:nn})),u("div",{className:`${en} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&u("div",{className:an,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Xr=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:r,isEventSelected:o,onResizeStart:l})=>{const i=n?n.startHour:Re(e.start),s=n?n.endHour:Be(e),d=s-i,c=!n||n.isFirst,h=!n||n.isLast,v=e.calendarId||"blue";return g(m,{children:[u("div",{className:tn,style:{backgroundColor:Fe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),g("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(Be(e)-Re(e.start)<=.25?"px-1 py-0":"p-1"),children:[u("div",{className:`${en} 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?`${We(i)} - ${We(s)}`:Ze(e)})]}),l&&a&&g(m,{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")}),h&&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&&h&&n&&u("div",{className:an,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),r&&o&&l&&a&&g(m,{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:Fe(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:Fe(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:$,app:L,isMobile:A=!1,enableTouch:j,hideTime:z})=>{const Y=null!=j?j:A,[F,V]=n(!1),[W,Z]=n(!1),U=y&&p?`${e.id}::${p.id}`:void 0!==(null==$?void 0:$.dayIndex)?`${e.id}::day-${$.dayIndex}`:e.id,B=C===U,[_,q]=n(null),[G,X]=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==L?void 0:L.getReadOnlyConfig(),oe=!(null==L?void 0:L.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===U){const e=U.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==$?void 0:$.dayIndex)?$.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=$?$.startHour:Re(e.start),r=$?$.endHour:Be(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,m=Math.max(0,Math.min(g,u));n.scrollTo({top:m,behavior:"smooth"}),setTimeout(()=>{t()},300)}),me=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(),m=g.width,h=g.height;let b,w,C;if("sticky-top"===G||"sticky-bottom"===G){const t=null===(a=s.current)||void 0===a?void 0:a.querySelector(".calendar-content");if(!t)return;const n=$?$.startHour:Re(e.start),r=$?$.endHour:Be(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"===G||"sticky-bottom"===G)&&!f){const e=null!==(u=null==$?void 0:$.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>=m+20?C.right+10:k>=m+20?C.left-m-10:E>k?Math.max(t.left+10,l-m-10):t.left+10;const N=C.top-h/2+C.height/2,T=Math.max(10,t.top+10),S=i-10;w=N<T?T:N+h>S?S-h:N,q(e=>e?Object.assign(Object.assign({},e),{top:w,left:b,isSunday:b<r}):null)})},[s,e.day,e.start,e.end,G,f,x,D,y,null==p?void 0:p.startDayIndex,null==p?void 0:p.endDayIndex,null==$?void 0:$.dayIndex,C,U]),he=a(()=>{if(!ae||!B||!K.current||!s.current||l||f)return;const t=s.current.querySelector(".calendar-content");if(!t)return;const n=$?$.startHour:Re(e.start),a=$?$.endHour:Be(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,m=i.top>window.innerHeight;g?c=!0:m&&(u=!0),X(c?"sticky-top":u?"sticky-bottom":"visible"),me()},[F,B,s,l,f,Re(e.start),Be(e),x,D,me,null==$?void 0:$.startHour,null==$?void 0:$.endHour,null==$?void 0:$.dayIndex,C,U]);r(()=>{var e,t;if(!ae||!B||l)return;const n=null===(e=s.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const a=()=>he(),r=()=>{he(),me()},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)),he(),()=>{o.forEach(e=>{e.removeEventListener("scroll",a)}),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",r),d&&d.disconnect()}},[ae,B,l,he,me,s,G]),r(()=>{if(!ae&&!B)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-calendar-picker-dropdown]");B?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,B,I,R,e.id]),r(()=>{y&&p&&!p.isFirstSegment||S!==e.id||B||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==$?void 0:$.dayIndex)?de($.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(U),q({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()})}null==M||M()},150)},[S,e.id,B,M,me,y,p,R,U]);const ve=o(null);r(()=>{let t,n=!0;const a=null==L?void 0:L.state.highlightedEventId;return ae&&a===e.id?ve.current!==a&&(ve.current=a,ge().then(()=>{n&&(Z(!0),t=setTimeout(()=>{n&&Z(!1)},150))})):Z(!1),a!==e.id&&(ve.current=null),()=>{n=!1,t&&clearTimeout(t)}},[ae,null==L?void 0:L.state.highlightedEventId,e.id]);const fe=()=>p?u(Zr,{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 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(m,{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||B?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||B?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=$?$.startHour:Re(e.start),m=$?$.endHour:Be(e),h={top:`${(g-x)*D+3}px`,height:Math.max((m-g)*D,D/4)-4+"px",position:"absolute",opacity:d?.3:1,zIndex:ae||B?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&&B&&("sticky-top"===G||"sticky-bottom"===G)){const e=null===(a=s.current)||void 0===a?void 0:a.getBoundingClientRect();if(e){const t=null!==(r=null==$?void 0:$.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 m=null==g?void 0:g.getBoundingClientRect(),h=null===(u=K.current)||void 0===u?void 0:u.getBoundingClientRect(),y=null==h?void 0:h.left,p=null==h?void 0:h.width;if("sticky-top"===G){let t=m?m.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=m?m.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({},h),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},h),{left:"0px",right:"3px"})})()),ae?{backgroundColor:Ye(pe,null==L?void 0:L.getCalendarRegistry()),color:"#fff"}:{backgroundColor:je(pe,null==L?void 0:L.getCalendarRegistry()),color:ze(pe,null==L?void 0:L.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==$?void 0:$.dayIndex)?de($.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);L&&L.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==$?void 0:$.dayIndex)?de($.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(U),q({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()}))})},onMouseDown:E?t=>{var n;if($){const a=Object.assign(Object.assign({},e),{day:null!==(n=$.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:$});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($){const a=Object.assign(Object.assign({},e),{day:null!==(t=$.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:$});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),L&&L.onEventClick(e),null==R||R(null),q(null)),ne.current=null},children:f?y&&p?fe():e.allDay?y?fe():u(qr,{event:e,isEventSelected:ae}):u(_r,{event:e,app:L,isEventSelected:ae,hideTime:z}):e.allDay?u(Gr,{event:e,isEditable:!!oe,onResizeStart:k}):u(Xr,{event:e,app:L,multiDaySegmentInfo:$,isEditable:!!oe,isTouchEnabled:!!Y,isEventSelected:ae,onResizeStart:k})}),B&&u("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!B)return null;const t=()=>{I&&I(null),de(null),V(!1),null==R||R(null)};if(P){const n=P,a={event:e,isOpen:B,isAllDay:l,onEventUpdate:N,onEventDelete:T,onClose:t,app:L};if("undefined"==typeof window||"undefined"==typeof document)return null;const r=document.body;return r?h.createPortal(u(n,Object.assign({},a)),r):null}return _?O?u(Br,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:G,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,contentRenderer:O}):u(Ur,{event:e,position:_,panelRef:J,isAllDay:l,eventVisibility:G,calendarRef:s,selectedEventElementRef:Q,onEventUpdate:N,onEventDelete:T,onClose:t,app:L}):null})()]})},Jr=({app:t,currentDate:n,currentWeekStart:a,events:r,currentDayEvents:o,organizedAllDayEvents:l,allDayAreaHeight:i,timeSlots:s,eventLayouts:d,isToday:c,currentTime:m,selectedEventId:h,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:$,allDayRowRef:L,switcherMode:A,isMobile:j,isTouch:z,setDraftEvent:Y,setIsDrawerOpen:F,ALL_DAY_HEIGHT:V,HOUR_HEIGHT:W,FIRST_HOUR:Z,LAST_HOUR:B})=>{const{t:_,locale:q}=Ht(),G=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 ${vn} h-full`,children:[u(Yr,{calendar:t,viewType:U.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(q,{weekday:"long"})}),g("div",{className:`${Jt} pt-px`,ref:L,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(Kr,{event:e,isAllDay:!0,isDayView:!0,segmentIndex:e.row,allDayHeight:V,calendarRef:$,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:W,firstHour:Z,onMoveStart:w,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:p,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=t.state.readOnly,o=r.find(t=>t.id===e);(j||z)&&o&&n&&!a?(Y(o),F(!0)):(v(e),t.state.highlightedEventId&&(t.highlightEvent(null),G.current=null))},onEventLongPress:e=>{(j||z)&&v(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:t,isMobile:j,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&&m&&(()=>{const e=m,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>B)return null;return g("div",{className:Xt,style:{top:`${(t-Z)*W}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:Kt,children:We(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:_t,children:u("div",{className:`${qt} 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:Gt,onDoubleClick:e=>{var t,r,o,l;const i=Math.floor((n.getTime()-a.getTime())/864e5),s=null===(r=null===(t=$.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=$.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/W)},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=$.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=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=Math.floor(Z+i/W);I(e,n,s)},onContextMenu:e=>j&&e.preventDefault()},t)),u("div",{className:dn,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(Kr,{event:e,layout:n,isDayView:!0,calendarRef:$,isBeingDragged:x&&(null==D?void 0:D.eventId)===e.id&&"move"===(null==D?void 0:D.mode),hourHeight:W,firstHour:Z,onMoveStart:w,onResizeStart:C,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:p,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:e=>{const n=!1!==t.getReadOnlyConfig().viewable,a=r.find(t=>t.id===e);(j||z)&&a&&n?(Y(a),F(!0)):(v(e),t.state.highlightedEventId&&(t.highlightEvent(null),G.current=null))},onEventLongPress:e=>{(j||z)&&v(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:t,isMobile:j,enableTouch:z},e.id)})})]})]})})]})})},Qr=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},eo=({app:l,customDetailPanelContent:i,customEventDetailDialog:s,calendarRef:d,switcherMode:c="buttons"})=>{const m=l.getEvents(),{t:h,locale:v}=Ht(),{screenSize:f}=Ka(),y="desktop"!==f,[p,b]=n(!1);r(()=>{b("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const D=l.getCustomMobileEventRenderer()||gr,[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.getVisibleMonth();$.getFullYear(),$.getMonth();const[L,A]=n(P),j=o(P.getTime());P.getTime()!==j.current&&(j.current=P.getTime(),P.getFullYear()===L.getFullYear()&&P.getMonth()===L.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:Y,FIRST_HOUR:F,LAST_HOUR:V,TIME_COLUMN_WIDTH:W,ALL_DAY_HEIGHT:Z}=Sr,B=e.useRef(l.state.highlightedEventId);r(()=>{var e;if(l.state.highlightedEventId!==B.current)if(l.state.highlightedEventId){const t=l.getEvents().find(e=>e.id===l.state.highlightedEventId);if(t&&(E(t),!t.allDay)){const n=Re(t.start),a=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=(n-F)*Y;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else E(null);B.current=l.state.highlightedEventId},[l.state.highlightedEventId,F,Y,d,l]);const _=e.useRef(null),q=t(()=>Qr(P),[P]),G=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=xe(e.start),n=xe(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=xe(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})})})(m,P,q),[m,P,q]),X=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=xe(e.start),r=xe(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=pe(n),i=!0),r>a&&(l=pe(a),i=!0),Object.assign(Object.assign({},e),{start:i?o:e.start,end:i?l:e.end,day:0})})})(G,P),[G,P]),K=t(()=>Tr.calculateDayEventLayouts(X,{viewType:"day"}),[X]),J=t(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=xe(e.start),a=xe(t.start);if(n.getTime()!==a.getTime())return n.getTime()-a.getTime();const r=xe(e.end);return xe(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=xe(e.start),a=xe(e.end),r=xe(t.start);return n<=xe(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})(G),[G]),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}=Lr(l,{calendarRef:d,allDayRowRef:_,viewType:U.DAY,onEventsUpdate:e=>{const t=e(G),n=new Set(t.map(e=>e.id)),a=G.filter(e=>!n.has(e.id)),r=new Set(G.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=G.find(t=>t.id===e.id);return t&&(xe(t.start).getTime()!==xe(e.start).getTime()||xe(t.end).getTime()!==xe(e.end).getTime()||t.day!==e.day||Re(t.start)!==Re(e.start)||Re(t.end)!==Re(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:G,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:pe(o),end:pe(l),calendarId:"blue",allDay:!1}];return Tr.calculateDayEventLayouts(i,{viewType:"day"}).get("-1")||null})(0,t,n,P,X),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:pe(s),end:pe(d),day:0})];return 0===c.length?null:Tr.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,P,X),TIME_COLUMN_WIDTH:y?48:80,isMobile:y}),{handleDrop:le,handleDragOver:ie}=Ar({app:l,onEventCreated:e=>{S(e.id)}}),se=Array.from({length:24},(e,t)=>({hour:t+F,label:We(t+F)})),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:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[u(Jr,{app:l,currentDate:P,currentWeekStart:q,events:m,currentDayEvents:G,organizedAllDayEvents:J,allDayAreaHeight:Q,timeSlots:se,eventLayouts:K,isToday:ce,currentTime:x,selectedEventId:C?C.id:null,setSelectedEventId:e=>{if(e){const t=m.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,F+u/Y)},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:Y,FIRST_HOUR:F,LAST_HOUR:V}),u(zr,{app:l,currentDate:P,visibleMonth:L,currentDayEvents:G,selectedEvent:C,setSelectedEvent:E,handleMonthChange:z,handleDateSelect:de,switcherMode:c}),u(D,{isOpen:M,onClose:()=>{I(!1),R(null)},onSave:e=>{m.find(t=>t.id===e.id)?l.updateEvent(e.id,e):l.addEvent(e),I(!1),R(null)},draftEvent:H,app:l})]})},to={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[U.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},no=(t={})=>{const n=Object.assign(Object.assign({},to),t),a=t=>e.createElement(pr,{viewType:U.DAY,originalComponent:eo,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:U.DAY,component:a,config:n}},ao=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:r,gridWidth:o,allDayAreaHeight:l,organizedAllDaySegments:i,allDayLabelText:s,isMobile:d,isTouch:c,calendarRef:h,allDayRowRef:v,topFrozenContentRef:f,ALL_DAY_HEIGHT:y,HOUR_HEIGHT:p,FIRST_HOUR:b,dragState:D,isDragging:x,handleMoveStart:w,handleResizeStart:C,handleEventUpdate:E,handleEventDelete:k,newlyCreatedEventId:N,setNewlyCreatedEventId:T,selectedEventId:S,setSelectedEventId:M,detailPanelEventId:I,setDetailPanelEventId:H,handleCreateAllDayEvent:R,handleDragOver:O,handleDrop:P,customDetailPanelContent:$,customEventDetailDialog:L,events:A,setDraftEvent:j,setIsDrawerOpen:z})=>{const Y={flexShrink:0};return g("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:[g("div",{className:"w-12 md:w-20 shrink-0 bg-white dark:bg-gray-900 z-20 flex flex-col",children:[u("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700"}),u("div",{className:"flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none",style:{minHeight:`${l}px`},children:s})]}),u("div",{className:"flex-1 overflow-x-hidden overflow-y-auto relative",style:{scrollbarGutter:"stable"},children:g("div",{ref:f,className:"flex flex-col",style:{width:o,minWidth:"100%"},children:[u("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:"-50px",paddingRight:"50px"},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 "+(d?"flex-col gap-0":""),style:Y,children:g(m,d?{children:[u("div",{className:"text-[11px] leading-tight text-gray-500 font-medium",children:n[t]}),u("div",{className:`${Ut} w-7 h-7 text-base font-medium ${a[t].isToday?rn:""}`,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:`${Ut} ${a[t].isToday?rn:""}`,children:a[t].date})]})},t))}),u("div",{className:`${Jt} border-none`,ref:v,style:{minHeight:`${l}px`},children:g("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${l}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 "+(d&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${l}px`},Y),onMouseDown:e=>null==R?void 0:R(e,n),onDoubleClick:e=>null==R?void 0:R(e,n),onDragOver:O,onDrop:e=>{P(e,a,void 0,!0)}},`allday-${n}`)}),u("div",{className:"absolute inset-0 pointer-events-none",children:i.map(t=>u(Kr,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:y,calendarRef:h,isBeingDragged:x&&(null==D?void 0:D.eventId)===t.event.id&&"move"===(null==D?void 0:D.mode),hourHeight:p,firstHour:b,onMoveStart:w,onResizeStart:C,onEventUpdate:E,onEventDelete:k,newlyCreatedEventId:N,onDetailPanelOpen:()=>T(null),selectedEventId:S,detailPanelEventId:I,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((d||c)&&t&&n&&!a){const e=A.find(e=>e.id===t);if(e)return j(e),void z(!0)}M(t)},onEventLongPress:e=>{(d||c)&&M(e)},onDetailPanelToggle:e=>H(e),customDetailPanelContent:$,customEventDetailDialog:L,app:e,isMobile:d,enableTouch:c},t.id))})]})})]})})]})},ro=({app:t,timeSlots:n,weekDaysLabels:a,currentWeekStart:r,currentWeekEvents:o,eventLayouts:l,gridWidth:i,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:m,leftFrozenContentRef:h,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:$,customEventDetailDialog:L,events:A,setDraftEvent:j,setIsDrawerOpen:z,isCurrentWeek:Y,currentTime:F,HOUR_HEIGHT:V,FIRST_HOUR:W,LAST_HOUR:Z})=>{const U={flexShrink:0},B=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:h,children:[n.map((e,t)=>u("div",{className:_t,children:u("div",{className:`${qt} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),u("div",{className:"relative",children:u("div",{className:`${qt} text-[10px] md:text-[12px]`,children:"00:00"})}),Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<W||t>Z)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:Kt,children:We(t)})})})()]})}),u("div",{ref:c,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:f,children:g("div",{ref:m,className:"relative flex",style:{width:i,minWidth:"100%"},children:[Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<W||t>Z)return null;const n=e.getDay(),r=0===n?6:n-1;return g("div",{className:Xt,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:Gt,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:U,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:`${dn} 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:U},`24-${t}`))}),a.map((e,n)=>{const a=rt(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(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 j(t),void z(!0)}R(e),t.state.highlightedEventId&&(t.highlightEvent(null),B.current=null)},onEventLongPress:e=>{(s||d)&&R(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:$,customEventDetailDialog:L,multiDaySegmentInfo:a,app:t,isMobile:s,enableTouch:d},a?`${e.id}-seg-${n}`:e.id)})},`events-day-${n}`)})]})]})})]})},oo=({app:a,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i})=>{const{t:s,getWeekDaysLabels:d,locale:c}=Ht(),m=a.getCurrentDate(),h=a.getEvents(),{screenSize:v}=Ka(),f="desktop"!==v,y="mobile"===v?48:80,p=e.useRef(null),[b,D]=n(!1);r(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const x=a.getCustomMobileEventRenderer()||gr,w=t(()=>Qr(m),[m]),[C,E]=n(null),[k,N]=n(null),[T,S]=n(null),[M,I]=n(null),[H,R]=n(!1),[O,P]=n(null),$=e.useRef(null),{HOUR_HEIGHT:L,FIRST_HOUR:A,LAST_HOUR:j,TIME_COLUMN_WIDTH:z,ALL_DAY_HEIGHT:Y}=Sr,F=e.useRef(null),V=e.useRef(null),W=e.useRef(null),Z=e.useRef(null),B=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=xe(e.start);a.setHours(0,0,0,0);const r=xe(e.end);return r.setHours(23,59,59,999),r>=t&&a<=n}).map(e=>{const n=xe(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})})})(h,w),[h,w]),_=e.useRef(a.state.highlightedEventId);r(()=>{if(a.state.highlightedEventId!==_.current)if(a.state.highlightedEventId){S(a.state.highlightedEventId);const e=B.find(e=>e.id===a.state.highlightedEventId);if(e&&!e.allDay){const t=Re(e.start),n=V.current;if(n){const e=(t-A)*L;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,e-100),behavior:"smooth"})})}}}else S(null);_.current=a.state.highlightedEventId},[a.state.highlightedEventId,B,A,L]);const q=t(()=>((e,t)=>{const n=Vr(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})(B,w),[B,w]),G=t(()=>{if(0===q.length)return Y;const e=Math.max(...q.map(e=>e.row));return Y+e*Y},[q,Y]),X=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:pe(Oe(lt(t,a),o.startHour)),end:pe(Oe(lt(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})(B,w),[B,w]),{handleMoveStart:K,handleCreateStart:J,handleResizeStart:Q,handleCreateAllDayEvent:ee,dragState:te,isDragging:ne}=Lr(a,{calendarRef:i,allDayRowRef:F,viewType:U.WEEK,onEventsUpdate:(e,t)=>{const n=e(B),r=new Set(n.map(e=>e.id)),o=B.filter(e=>!r.has(e.id)),l=new Set(B.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=B.find(t=>t.id===e.id);return t&&(xe(t.start).getTime()!==xe(e.start).getTime()||xe(t.end).getTime()!==xe(e.end).getTime()||t.day!==e.day||Re(t.start)!==Re(e.start)||Re(t.end)!==Re(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=>{f?(P(e),R(!0)):(a.addEvent(e),I(e.id))},onEventEdit:()=>{},currentWeekStart:w,events:B,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:pe(r),end:pe(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,B),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r)=>{const o=r.map(r=>{if(r.id!==e.id)return r;const o=xe(r.start),l=Oe(o,n),i=Oe(o,a),s=pe(l),d=pe(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,B),TIME_COLUMN_WIDTH:y,isMobile:f}),{handleDrop:ae,handleDragOver:re}=Ar({app:a,onEventCreated:e=>{I(e.id)}}),oe=t(()=>d(c,"short"),[c,d]),le=t(()=>{if(!f)return[];const e=c.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?d(c,"narrow"):oe.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)})},[f,c,d,oe]),ie=t(()=>s("allDay"),[s]),se=Array.from({length:24},(e,t)=>({hour:t+A,label:We(t+A)})),de=t(()=>{const e=new Date;return e.setHours(0,0,0,0),oe.map((t,n)=>{const a=new Date(w);a.setDate(w.getDate()+n);const r=new Date(a);return r.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(c,{month:"short"}),fullDate:new Date(a),isToday:r.getTime()===e.getTime()}})},[w,oe,c]),ce=e=>{a.updateEvent(e.id,e)},ue=e=>{a.deleteEvent(e)},ge=t(()=>{const e=new Date,t=Qr(e);return w.getTime()===t.getTime()},[w]);r(()=>{E(new Date);const e=setInterval(()=>E(new Date),6e4);return()=>clearInterval(e)},[]);const me=f?"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(Yr,{calendar:a,viewType:U.WEEK,currentDate:m,onPrevious:()=>a.goToPrevious(),onNext:()=>a.goToNext(),onToday:()=>a.goToToday()}),u(ao,{app:a,weekDaysLabels:oe,mobileWeekDaysLabels:le,weekDates:de,currentWeekStart:w,gridWidth:me,allDayAreaHeight:G,organizedAllDaySegments:q,allDayLabelText:ie,isMobile:f,isTouch:b,calendarRef:i,allDayRowRef:F,topFrozenContentRef:W,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:L,FIRST_HOUR:A,dragState:te,isDragging:ne,handleMoveStart:K,handleResizeStart:Q,handleEventUpdate:ce,handleEventDelete:ue,newlyCreatedEventId:M,setNewlyCreatedEventId:I,selectedEventId:T,setSelectedEventId:S,detailPanelEventId:k,setDetailPanelEventId:N,handleCreateAllDayEvent:ee,handleDragOver:re,handleDrop:ae,customDetailPanelContent:o,customEventDetailDialog:l,events:h,setDraftEvent:P,setIsDrawerOpen:R}),u(ro,{app:a,timeSlots:se,weekDaysLabels:oe,currentWeekStart:w,currentWeekEvents:B,eventLayouts:X,gridWidth:me,isMobile:f,isTouch:b,scrollerRef:V,timeGridRef:p,leftFrozenContentRef:Z,calendarRef:i,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;W.current&&(W.current.style.transform=`translateX(${-n}px)`),Z.current&&(Z.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:J,handleTouchStart:(e,t,n)=>{if(!f&&!b)return;const a=e.touches[0],r=a.clientX,o=a.clientY,l=e.currentTarget;$.current=setTimeout(()=>{null==J||J({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:re,handleDrop:ae,dragState:te,isDragging:ne,handleMoveStart:K,handleResizeStart:Q,handleEventUpdate:ce,handleEventDelete:ue,newlyCreatedEventId:M,setNewlyCreatedEventId:I,selectedEventId:T,setSelectedEventId:S,detailPanelEventId:k,setDetailPanelEventId:N,customDetailPanelContent:o,customEventDetailDialog:l,events:h,setDraftEvent:P,setIsDrawerOpen:R,isCurrentWeek:ge,currentTime:C,HOUR_HEIGHT:L,FIRST_HOUR:A,LAST_HOUR:j}),u(x,{isOpen:H,onClose:()=>{R(!1),P(null)},onSave:e=>{h.find(t=>t.id===e.id)?a.updateEvent(e.id,e):a.addEvent(e),R(!1),P(null)},draftEvent:O,app:a})]})},lo={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[U.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},io=(t={})=>{const n=Object.assign(Object.assign({},lo),t),a=t=>e.createElement(pr,{viewType:U.WEEK,originalComponent:oo,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:U.WEEK,component:a,config:n}},so=e.memo(({currentMonth:e,currentYear:a,newlyCreatedEventId:l,screenSize:i,isScrolling:s,isDragging:c,item:m,weekHeight:h,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:$,app:L,enableTouch:A})=>{const{t:j,locale:z}=Ht(),[Y,F]=n(!1),V=o(null),W=o(null),Z=o(null),B=t(()=>{const e=h-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)))}},[h]);r(()=>s?(F(!0),V.current&&(clearTimeout(V.current),V.current=null),()=>{V.current&&(clearTimeout(V.current),V.current=null)}):Y?(V.current=setTimeout(()=>{F(!1),V.current=null},100),()=>{V.current&&(clearTimeout(V.current),V.current=null)}):void 0,[s,Y]);const{weekData:_}=m,q=_.days.find(e=>1===e.day),G=`${h}px`,X=t(()=>Vr(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 re.warn("Event missing start or end date:",e);const r=xe(e.start),o=xe(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})(X),[X]),Q=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]),ee=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]),te=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 xe(e.start).toDateString()===n.date.toDateString();const t=xe(e.start),a=xe(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=ee[t],o=Q[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)>B.maxSlots)return B.maxSlotsWithMore}return B.maxSlots},[_.days,K,J,Q,ee,B.maxSlots,B.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:Re(e.start)-Re(t.start)))((s=t.date,K.filter(e=>{if(!e.start||!e.end)return xe(e.start).toDateString()===s.toDateString();const t=xe(e.start),n=xe(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()}))),m=J.flat(),h=d.filter(e=>{if(!e.allDay)return!0;return!m.some(t=>t.originalEventId===e.id)}),v=ee[n],Y=(null!==(r=Q[n])&&void 0!==r?r:0)-1,F=[];for(let e=0;e<=Y;e++)v.has(e)||F.push(e);const V=h.length,_=Math.max(0,V-F.length),q=Math.max(Y+1,0)+_,X=q>B.maxSlots,te=X?B.maxSlotsWithMore:B.maxSlots,ne=F.filter(e=>e<te).length,ae=Math.max(0,te-Math.max(Y+1,0)),re=Math.min(V,ne+ae),oe=h.slice(0,re),le=V-re,ie=[];let se=0;const de=Math.min(te,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(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:L,isMobile:"desktop"!==i,enableTouch:A},`${e.id}-${e.day}-${Re(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:G},"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&&!A)return;const n=e.touches[0],a=n.clientX,r=n.clientY;Z.current={x:a,y:r},W.current=setTimeout(()=>{null==x||x(e,t.date),W.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(W.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(W.current),W.current=null)}},onTouchEnd:()=>{W.current&&(clearTimeout(W.current),W.current=null),Z.current=null},onDragOver:$,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,X&&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(U.DAY))},children:["+",le," ",u("span",{className:"hidden md:inline",children:j("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:G},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 ${Y?"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)=>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:L,isMobile:"desktop"!==i,enableTouch:A},e.id))},`layer-${t}`))})]})})]})});so.displayName="WeekComponent";const co=({app:e,customDetailPanelContent:a,customEventDetailDialog:l,calendarRef:i})=>{const{getWeekDaysLabels:s,getMonthLabels:d,locale:c}=Ht(),m=e.getCurrentDate(),h=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===h.length&&e.every((e,t)=>e===h[t])?e:(f.current=h,h)},[h]),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=xe(e.start),r=e.end?xe(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()||gr,[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]=n(null),A=o(e.state.highlightedEventId);r(()=>{e.state.highlightedEventId?L(e.state.highlightedEventId):A.current&&L(null),A.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const[j,z]=n(null),Y=t(()=>{const e=m.getDay(),t=m.getDate()-e+(0===e?-6:1),n=new Date(m);return n.setDate(t),n.setHours(0,0,0,0),n},[m]),{handleMoveStart:F,handleCreateStart:V,handleResizeStart:W,dragState:Z,isDragging:B}=Lr(e,{calendarRef:i,viewType:U.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&&(xe(t.start).getTime()!==xe(e.start).getTime()||xe(t.end).getTime()!==xe(e.end).getTime()||t.day!==e.day||Re(t.start)!==Re(e.start)||Re(t.end)!==Re(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:Y,events:y}),{handleDrop:_,handleDragOver:q}=Ar({app:e,onEventCreated:e=>{I(e.id)}}),G=t(()=>s(c,"short"),[c,s]),{currentMonth:X,currentYear:K,isScrolling:J,virtualData:Q,scrollElementRef:ee,handleScroll:te,handlePreviousMonth:ne,handleNextMonth:ae,handleToday:re,setScrollTop:oe}=Ja({currentDate:m,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]),me=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 he=t=>{e.updateEvent(t.id,t)},ve=t=>{e.deleteEvent(t)},fe=t=>{e.changeView(t)};return g("div",{className:Ft,children:[u(Yr,{calendar:e,viewType:U.MONTH,currentDate:m,customTitle:c.startsWith("zh")||c.startsWith("ja")?`${K}年${X}`:`${X} ${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:G.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:Bt,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(so,{item:s,weekHeight:C,currentMonth:X,currentYear:K,screenSize:b,isScrolling:J,calendarRef:i,events:o,onEventUpdate:he,onEventDelete:ve,onMoveStart:F,onCreateStart:V,onResizeStart:W,isDragging:B,dragState:Z,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:fe,onSelectDate:e.selectDate,selectedEventId:$,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)}L(t)},onEventLongPress:e=>{("desktop"!==b||D)&&L(e)},detailPanelEventId:j,onDetailPanelToggle:z,customDetailPanelContent:a,customEventDetailDialog:l,onCalendarDrop:_,onCalendarDragOver:q,calendarSignature:v,app:e,enableTouch:D},`week-${t.weekData.startDate.getTime()}`)}),u("div",{style:{height:me}})]}),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})]})},uo={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[U.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[U.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}},go=(t={})=>{const n=Object.assign(Object.assign({},uo),t),a=t=>e.createElement(pr,{viewType:U.MONTH,originalComponent:co,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:U.MONTH,component:a,config:n}};const mo=e.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:r,onMoreEventsClick:o,moreCount:l=0})=>{const{t:i}=Ht(),s=e.getDate(),d=1===s,c=e.toLocaleDateString(n,{month:"short"}).toUpperCase(),m=`${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":m,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")]})})]})});mo.displayName="YearDayCell";const ho=({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,$=(E-C+1)/t*100,L=w.calendarId||"blue",A=l?Ye(L):je(L),j=l?"#fff":ze(L),z=Fe(L),Y=!!w.allDay,F=Y?Fr(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 Z=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(m,{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:j,opacity:a?.6:1,width:`calc(${$}% - 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:[Z("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&&Fr(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:Fe(L),width:"12px",height:"12px"},children:Fr(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})]})})(),Z("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?h.createPortal(u(t,Object.assign({},n)),a):null}return I?p?u(Br,{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(Ur,{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})()]})},vo=e.memo(({rowDays:e,events:n,columnsPerRow:a,app:r,calendarRef:o,locale:l,isDragging:i,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:m,selectedEventId:h,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=xe(e.start),n=e.end?xe(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=xe(e.start).getTime(),a=e.end?xe(e.end).getTime():n,r=xe(t.start).getTime(),o=a-n,l=(t.end?xe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const s=[],d=[];return i.forEach(e=>{const r=xe(e.start),i=e.end?xe(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,m=-1;const h=Math.round((c-o)/864e5);g=h>=0?h:0;const v=Math.round((u-o)/864e5);m=v<t.length?v:t.length-1,g=Math.max(0,Math.min(g,n-1)),m=Math.max(0,Math.min(m,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<=m;t++)if(d[p][t]){e=!0;break}if(!e){for(let e=g;e<=m;e++)d[p][e]=!0;break}p++}s.push({id:`${e.id}_${a.getTime()}`,event:e,startCellIndex:g,endCellIndex:m,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(mo,{date:e,isToday:n,locale:l,onSelectDate:e=>{r.selectDate(e)},onCreateStart:m,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(ho,{segment:e,columnsPerRow:a,isDragging:i&&s.eventId===e.event.id,isSelected:h===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))})})]})});vo.displayName="YearRowComponent";const fo=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var m;const{locale:h}=Ht(),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}=Lr(e,{calendarRef:l,viewType:U.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!==(m=null==c?void 0:c.showTimedEventsInYearView)&&void 0!==m&&m,$=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]),L=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}(L,b),[L,b]),j=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=xe(n.start),r=n.end?xe(n.end):a;return a<=t&&r>=e})},[y,f,P]);return g("div",{className:Ft,children:[u(Yr,{calendar:e,viewType:U.YEAR,currentDate:v,customTitle:h.startsWith("zh")||h.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:`${Bt}`,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(vo,{rowDays:t,events:j,columnsPerRow:b,app:e,calendarRef:l,locale:h,isDragging:O,dragState:R,onMoveStart:M,onResizeStart:I,onCreateStart:$,selectedEventId:C,onEventSelect:E,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:T,onDetailPanelOpen:()=>S(null),detailPanelEventId:k,onDetailPanelToggle:N,customDetailPanelContent:i,customEventDetailDialog:s},n))})})]})};function yo(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=xe(e.start),n=e.end?xe(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=xe(e.start).getTime(),a=e.end?xe(e.end).getTime():n,r=xe(t.start).getTime(),o=a-n,l=(t.end?xe(t.end).getTime():r)-r;return o!==l?l-o:n-r});const d=[],c=[];s.forEach(e=>{const a=xe(e.start),r=e.end?xe(e.end):a,s=new Date(Math.max(a.getTime(),l)),u=new Date(Math.min(r.getTime(),i)),g=s.getDate(),m=u.getDate(),h=o+(g-1),v=o+(m-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=h;t<=v;t++)if(c[p][t]){e=!0;break}if(!e){for(let e=h;e<=v;e++)c[p][e]=!0;break}p++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:h,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 po=({app:e,calendarRef:l,customDetailPanelContent:i,customEventDetailDialog:s,config:c})=>{var m;const{locale:h,getWeekDaysLabels:v}=Ht(),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:$,handleCreateStart:L,dragState:A,isDragging:j}=Lr(e,{calendarRef:l,viewType:U.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!==(m=null==c?void 0:c.showTimedEventsInYearView)&&void 0!==m&&m,Y=a((t,n)=>{if(z)null==L||L(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,L,e]),F=t(()=>{const e=v(h,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(h.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},[h,v,O]),V=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=xe(n.start),r=n.end?xe(n.end):a;return a<=t&&r>=e})},[p,y,z]),W=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(h,{month:"short"}),i=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=yo(V,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,h,O,V]),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()}},[W]);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(Yr,{calendar:e,viewType:U.YEAR,currentDate:f,customTitle:h.startsWith("zh")||h.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:F.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:[W.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:W.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=>Y(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(ho,{segment:t,columnsPerRow:O,isDragging:j&&A.eventId===t.event.id,isSelected:T===t.event.id,onMoveStart:P,onResizeStart:$,onEventSelect:S,onDetailPanelToggle:I,newlyCreatedEventId:H,onDetailPanelOpen:()=>R(null),calendarRef:l,app:e,detailPanelEventId:M,customDetailPanelContent:i,customEventDetailDialog:s})},t.id))})})]},t.monthIndex))})})]})},bo=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return u("fixed-week"===n?po:fo,Object.assign({},e,{config:e.config}))},Do={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},xo=(t={})=>{const n=Object.assign(Object.assign({},Do),t);t.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:t.mode}));const a=t=>e.createElement(pr,{viewType:U.YEAR,originalComponent:bo,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:U.YEAR,component:a,config:n}},wo={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function Co(e={}){const t=Object.assign(Object.assign({},wo),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=gt(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=gt(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=xe(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=xe(n.start),r=xe(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)=>gt(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,re.log("Events plugin installed - providing event management services")},api:a}}export{Ct as CalendarApp,Kr as CalendarEvent,Kn as CalendarPicker,ee as CalendarRegistry,yr as DayFlowCalendar,va as DefaultEventDetailDialog,Ur as DefaultEventDetailPanel,Br as EventDetailPanelWithContent,Tr as EventLayoutCalculator,me as LOCALES,It as LocaleContext,Ve as TIME_STEP,tr as ThemeProvider,Yr as ViewHeader,U as ViewType,Me as addDays,na as buildParseRegExp,ct as calculateDayIndex,Nt as capitalize,Oa as conditionalTheme,Za as convertDateEvent,Ua as convertDateEventWithTimeZone,Va as createAllDayEvent,Oe as createDateWithHour,no as createDayView,$r as createDragPlugin,ja as createEvent,dt as createEventWithDate,vt as createEventWithRealDate,Ya as createEvents,Co as createEventsPlugin,go as createMonthView,we as createTemporalWithHour,Wa as createTimedEvent,za as createTimezoneEvent,Fa as createTimezoneEvents,io as createWeekView,xo as createYearView,Tn as dateToPlainDate,Sn as dateToPlainDateTime,Mn as dateToZonedDateTime,Te as daysBetween,Se as daysDifference,ue as de,Bn as downloadICS,le as en,ge as es,Re as extractHourFromDate,Rn as extractHourFromTemporal,Ia as formatDate,Sa as formatDateConsistent,Fn as formatDateToICSTimestamp,Ze as formatEventTimeRange,Yn as formatICSDate,Ma as formatMonthYear,la as formatTemporal,We as formatTime,ce as fr,Qe as generateDayData,Un as generateICS,bt as generateUniKey,et as generateWeekData,at as generateWeekRange,nt as generateWeeksData,ot as getAllDayEventsForDay,Je as getCurrentWeekDates,lt as getDateByDayIndex,Ba as getDateObj,mt as getDayIndexByDate,$e as getEndOfDay,Ne as getEndOfTemporal,je as getEventBgColor,Be as getEventEndHour,ze as getEventTextColor,rt as getEventsForDay,ht as getEventsForWeek,kt as getIntlLabel,Fe as getLineColor,St as getMonthLabels,tt as getMonthYearOfWeek,$n as getPlainDate,qa as getSearchHeaderInfo,Ye as getSelectedBgColor,Pe as getStartOfDay,ke as getStartOfTemporal,pt as getTestEvents,Tt as getWeekDaysLabels,Ke as getWeekRange,ra as getZoneId,Ga as groupSearchResults,Gn as importICSFile,ye as isDate,Dt as isDeepEqual,yt as isEventEqual,ut as isEventInWeek,Ae as isMultiDayEvent,Ee as isMultiDayTemporalEvent,Cn as isPlainDate,En as isPlainDateTime,Le as isSameDay,Ce as isSamePlainDate,Pn as isSameTemporal,ve as isValidLocale,kn as isZonedDateTime,se as ja,de as ko,Pa as mergeClasses,ea as mergeFormatTemplate,Ge as monthNames,oe as normalizeCssWidth,_a as normalizeDate,he as normalizeLocale,oa as normalizeToZoned,Ie as now,Qn as pad,Wn as parseICS,zn as parseICSDate,aa as parseTemporalString,In as plainDateTimeToDate,Hn as plainDateToDate,gt as recalculateEventDays,$a as resolveAppliedTheme,Ue as roundToTimeStep,On as setHourInTemporal,Xe as shortMonthNames,Mt as t,Nn as temporalToDate,Ra as themeClasses,Ha as themeCn,He as today,it as updateEventDateAndDay,ft as updateEventWithRealDate,Et as useCalendarApp,Pr as useDrag,Lr as useDragForView,Ht as useLocale,Na as useResponsiveConfig,Ka as useResponsiveMonthConfig,nr as useTheme,Ja as useVirtualMonthScroll,Ta as useVirtualScroll,_e as weekDays,qe as weekDaysFullName,ie as zh,De as zonedDateTimeToDate};
|