@dayflow/core 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{Temporal as e}from"temporal-polyfill";import{options as t,createContext as n,Fragment as r,h as a,render as o,isValidElement as i,cloneElement as l}from"preact";import{createPortal as s,forwardRef as d,memo as c}from"preact/compat";export{createPortal}from"preact/compat";import{useState as u,useEffect as h,useRef as g,useCallback as m,useMemo as v,useContext as f,useLayoutEffect as p}from"preact/hooks";import{__awaiter as y,__rest as b}from"tslib";import{BlossomColorPicker as w,hexToHsl as D,lightnessToSliderValue as x,DEFAULT_COLORS as E,hslToHex as C}from"@dayflow/blossom-color-picker";const k={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",viewEvent:"View 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",cut:"Cut",copy:"Copy",pasteHere:"Paste Here",eventSummary:"Summary"}},T={en:k};function N(e){const t=e.code.split("-")[0].toLowerCase();T[t]=e}function S(e){const t=e.split("-")[0].toLowerCase();return t in T?t:"en"}function M(e){try{new Intl.DateTimeFormat(e);return!0}catch(e){return!1}}var I;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(I||(I={}));const H={INDENT_STEP:2,MIN_WIDTH:25,MARGIN_BETWEEN:2,CONTAINER_WIDTH:320,OVERLAP_THRESHOLD:.25,EDGE_MARGIN:3,MAX_LOAD_IMBALANCE:0,REBALANCE_THRESHOLD:2},A={OVERSCAN:6,BUFFER_SIZE:100,MIN_YEAR:1900,MAX_YEAR:2200,SCROLL_THROTTLE:8,SCROLL_DEBOUNCE:150,CACHE_CLEANUP_THRESHOLD:200,MOBILE_WEEK_HEIGHT:80,TABLET_WEEK_HEIGHT:90,WEEK_HEIGHT:119};class O{constructor(e=A.BUFFER_SIZE){this.cache=new Map,this.accessOrder=[],this.maxSize=e}static getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=O.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=O.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=[]}}var R;!function(e){e.UTC="UTC",e.NEW_YORK="America/New_York",e.CHICAGO="America/Chicago",e.DENVER="America/Denver",e.LOS_ANGELES="America/Los_Angeles",e.TORONTO="America/Toronto",e.VANCOUVER="America/Vancouver",e.PHOENIX="America/Phoenix",e.ANCHORAGE="America/Anchorage",e.HONOLULU="Pacific/Honolulu",e.MEXICO_CITY="America/Mexico_City",e.WINNIPEG="America/Winnipeg",e.HALIFAX="America/Halifax",e.ST_JOHNS="America/St_Johns",e.DETROIT="America/Detroit",e.MIAMI="America/Miami",e.SEATTLE="America/Los_Angeles",e.ATLANTA="America/New_York",e.DALLAS="America/Chicago",e.HOUSTON="America/Chicago",e.LAS_VEGAS="America/Los_Angeles",e.SAN_FRANCISCO="America/Los_Angeles",e.LONDON="Europe/London",e.PARIS="Europe/Paris",e.BERLIN="Europe/Berlin",e.MADRID="Europe/Madrid",e.ROME="Europe/Rome",e.AMSTERDAM="Europe/Amsterdam",e.ZURICH="Europe/Zurich",e.STOCKHOLM="Europe/Stockholm",e.OSLO="Europe/Oslo",e.COPENHAGEN="Europe/Copenhagen",e.MOSCOW="Europe/Moscow",e.ISTANBUL="Europe/Istanbul",e.DUBLIN="Europe/Dublin",e.LISBON="Europe/Lisbon",e.PRAGUE="Europe/Prague",e.VIENNA="Europe/Vienna",e.WARSAW="Europe/Warsaw",e.BRUSSELS="Europe/Brussels",e.ATHENS="Europe/Athens",e.BUCHAREST="Europe/Bucharest",e.HELSINKI="Europe/Helsinki",e.KYIV="Europe/Kyiv",e.BUDAPEST="Europe/Budapest",e.BELGRADE="Europe/Belgrade",e.LUXEMBOURG="Europe/Luxembourg",e.MONACO="Europe/Monaco",e.REYKJAVIK="Atlantic/Reykjavik",e.TOKYO="Asia/Tokyo",e.SHANGHAI="Asia/Shanghai",e.BEIJING="Asia/Shanghai",e.HONG_KONG="Asia/Hong_Kong",e.TAIPEI="Asia/Taipei",e.SEOUL="Asia/Seoul",e.SINGAPORE="Asia/Singapore",e.HANOI="Asia/Ho_Chi_Minh",e.BANGKOK="Asia/Bangkok",e.JAKARTA="Asia/Jakarta",e.KUALA_LUMPUR="Asia/Kuala_Lumpur",e.MANILA="Asia/Manila",e.DUBAI="Asia/Dubai",e.KOLKATA="Asia/Kolkata",e.MUMBAI="Asia/Kolkata",e.RIYADH="Asia/Riyadh",e.TEHRAN="Asia/Tehran",e.JERUSALEM="Asia/Jerusalem",e.TEL_AVIV="Asia/Tel_Aviv",e.BAGHDAD="Asia/Baghdad",e.DHAKA="Asia/Dhaka",e.KARA_CHI="Asia/Karachi",e.KABUL="Asia/Kabul",e.KATHMANDU="Asia/Kathmandu",e.COLOMBO="Asia/Colombo",e.TASHKENT="Asia/Tashkent",e.ALMATY="Asia/Almaty",e.PHNOM_PENH="Asia/Phnom_Penh",e.VIENTIANE="Asia/Vientiane",e.MUSCAT="Asia/Muscat",e.SYDNEY="Australia/Sydney",e.MELBOURNE="Australia/Melbourne",e.BRISBANE="Australia/Brisbane",e.PERTH="Australia/Perth",e.ADELAIDE="Australia/Adelaide",e.DARWIN="Australia/Darwin",e.HOBART="Australia/Hobart",e.AUCKLAND="Pacific/Auckland",e.FIJI="Pacific/Fiji",e.GUAM="Pacific/Guam",e.NOUMEA="Pacific/Noumea",e.PAGO_PAGO="Pacific/Pago_Pago",e.PORT_MORESBY="Pacific/Port_Moresby",e.SAO_PAULO="America/Sao_Paulo",e.RIO_DE_JANEIRO="America/Sao_Paulo",e.BUENOS_AIRES="America/Argentina/Buenos_Aires",e.SANTIAGO="America/Santiago",e.LIMA="America/Lima",e.BOGOTA="America/Bogota",e.CARACAS="America/Caracas",e.LA_PAZ="America/La_Paz",e.MONTEVIDEO="America/Montevideo",e.QUITO="America/Quito",e.ASUNCION="America/Asuncion",e.GEORGETOWN="America/Guyana",e.CAIRO="Africa/Cairo",e.JOHANNESBURG="Africa/Johannesburg",e.LAGOS="Africa/Lagos",e.NAIROBI="Africa/Nairobi",e.CASABLANCA="Africa/Casablanca",e.ALGIERS="Africa/Algiers",e.TUNIS="Africa/Tunis",e.ADDIS_ABABA="Africa/Addis_Ababa",e.ACCRA="Africa/Accra",e.DAKAR="Africa/Dakar",e.LUANDA="Africa/Luanda",e.ANTANANARIVO="Indian/Antananarivo",e.KINSHASA="Africa/Kinshasa",e.DAR_ES_SALAAM="Africa/Dar_es_Salaam",e.MCMURDO="Antarctica/McMurdo",e.CASEY="Antarctica/Casey"}(R||(R={}));const P=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],L=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],$=["January","February","March","April","May","June","July","August","September","October","November","December"],j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Y=(e,t=1)=>{const n=(e.getDay()-t+7)%7,r=new Date(e);r.setDate(e.getDate()-n),r.setHours(0,0,0,0);const a=new Date(r);return a.setDate(r.getDate()+6),a.setHours(23,59,59,999),{monday:r,sunday:a}},F=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return P.map((e,a)=>{const o=new Date(t);return o.setDate(t.getDate()-r+a),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===n.getDate()&&o.getMonth()===n.getMonth()&&o.getFullYear()===n.getFullYear()}})};function z(t){var n;if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;if(t instanceof e.PlainDate)return!0;const r=t;return"PlainDate"===(null===(n=r.constructor)||void 0===n?void 0:n.name)||!("hour"in r)&&!("timeZone"in r)&&"year"in r&&"month"in r&&"day"in r}function _(e){return e instanceof Date}function W(t,n=e.Now.timeZoneId()){return e.Instant.fromEpochMilliseconds(t.getTime()).toZonedDateTimeISO(n)}function U(e){if("number"==typeof e.epochMilliseconds)return new Date(e.epochMilliseconds);const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute)}function B(t,n){if(t instanceof Date)return t;if(z(t))return function(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime)try{return U(t.toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(t.year,t.month-1,t.day)}(t,n);if(t&&"object"==typeof t&&"hour"in t&&!("timeZone"in t)){const e=t;return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}return t&&"object"==typeof t&&"year"in t?U(t):new Date(t)}function Z(t,n){const r=Math.floor(n),a=Math.round(60*(n-r));if(z(t))return e.PlainDateTime.from({year:t.year,month:t.month,day:t.day,hour:r,minute:a});if("function"==typeof t.with)return t.with({hour:r,minute:a,second:0,millisecond:0});const o=t;return e.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function V(t,n){if(t instanceof Date&&n instanceof Date)return t.toDateString()===n.toDateString();const r=t=>{if(t instanceof Date)return n=t,e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()});var n;if(z(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const r=t;return e.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(t),o=r(n);return 0===e.PlainDate.compare(a,o)}function G(e,t){return!V(e,t)}function K(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}const r=t;return(z(t)?t:e.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}function q(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=t;return(z(t)?t:e.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function X(t,n){const r=t=>{if(z(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const n=t;return e.PlainDate.from({year:n.year,month:n.month,day:n.day})},a=r(t),o=r(n);return a.until(o).days}function J(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((r.getTime()-n.getTime())/864e5)}function Q(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ee(t=e.Now.timeZoneId()){return e.Now.zonedDateTimeISO(t)}function te(t=e.Now.timeZoneId()){return e.Now.plainDateISO(t)}const ne=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return function(e){var t;if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(z(e))return 0;if(null===e||"object"!=typeof e||!("hour"in e)||void 0===e.hour)return 0;const n=e;return n.hour+(null!==(t=n.minute)&&void 0!==t?t:0)/60}(e)},re=(e,t)=>{if(e instanceof Date){const n=new Date(e),r=Math.floor(t),a=Math.round(60*(t-r));return n.setHours(r,a,0,0),n}return Z(e,t)},ae=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return K(e)},oe=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return q(e)},ie=e=>{const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);const r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)},le=(t,n)=>{if(t instanceof Date&&n instanceof Date)return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return V(t instanceof Date?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):z(t)?t:t.toPlainDate(),n instanceof Date?e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):z(n)?n:n.toPlainDate())},se=(e,t)=>!le(e,t),de=[{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 ce{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const r=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):de.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!r&&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[r]=n.splice(e,1);n.splice(t,0,r),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,r=ce.isDarkTheme(n);let a;return e&&(a=this.get(e)),a||(a=this.getDefaultCalendar()),r&&a.darkColors?a.darkColors:a.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}static isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}static 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 ue=new ce;function he(){return ue}function ge(e){const t=de.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 me=(e,t)=>(t||he()).resolveColors(e).eventColor,ve=(e,t)=>(t||he()).resolveColors(e).textColor,fe=(e,t)=>(t||he()).resolveColors(e).eventSelectedColor,pe=(e,t)=>(t||he()).resolveColors(e).lineColor,ye=.25,be=(e,t=0,n="24h",r=!0)=>{const a=Math.floor(e),o=t||Math.round(60*(e-a));if("12h"===n){const e=a>=12?"PM":"AM",t=a%12||12;return 0===o?`${t}${r?` ${e}`:""}`:`${t}:${o.toString().padStart(2,"0")}${r?` ${e}`:""}`}return`${a.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`},we=e=>{if(!e.end)return 0;const t=ne(e.end);if(e.allDay||!e.start)return t;const n=B(e.start),r=B(e.end);if(!(n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()||n.getDate()!==r.getDate()))return t;if(0===t&&0===r.getMinutes()&&0===r.getSeconds()&&0===r.getMilliseconds()){const e=r.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},De=(e,t="24h")=>{const n=ne(e.start),r=we(e);return`${be(n,0,t)} - ${be(r,0,t)}`},xe=e=>.25*Math.round(e/.25),Ee=(t,n,r="24h",a=new Date)=>{const o=e.Now.timeZoneId(),i=a.getFullYear(),l=a.getMonth()+1,s=a.getDate();return t.map(t=>{try{const a=t.hour%24,d=e.ZonedDateTime.from({year:i,month:l,day:s,hour:a,minute:0,second:0,timeZone:o}).withTimeZone(n);return be(d.hour,d.minute,r)}catch(e){return""}})},Ce=(e,t=new Date)=>{var n,r;try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:e}catch(t){return e}},ke=e=>{const t=new Date(e),n=t.getDate(),r=t.getMonth(),a=t.getFullYear(),o=new Date;return{date:t,day:n,month:r,year:a,monthName:$[r],shortMonthName:j[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},Te=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,r="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,r=e)});const[a,o]=r.split("-").map(Number);return{month:$[a],monthIndex:a,year:o}},Ne=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(ke(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Te(t)}},Se=(e,t=3)=>{const n=5*t,{monday:r}=Y(e),a=[],o=Math.floor(n/2),i=new Date(r);i.setDate(i.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),a.push(Ne(t))}return a};function Me(e,t,n=1){const r=[],a=Math.floor(t/2),o=(e.getDay()-n+7)%7,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const l=new Date(i);l.setDate(l.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(Ne(t))}return r}const Ie=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),He=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const r=new Date(n);r.setDate(n.getDate()+e),r.setHours(0,0,0,0);const a=B(t.start);a.setHours(0,0,0,0);const o=B(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),Ae=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},Oe=(t,n,r)=>{const a=Ae(r,n);return Object.assign(Object.assign({},t),{day:n,start:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()}),end:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()})})},Re=(t,n)=>n?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:e.Now.timeZoneId()}),Pe=(e,t)=>{var n,r;const a=Ae(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},Le=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=n.getTime()-r.getTime();return Math.floor(a/864e5)},$e=(e,t)=>{const n=Le(e,t);return n>=0&&n<=6},je=(e,t)=>e.map(e=>{const n=B(e.start),r=Le(n,t);return Object.assign(Object.assign({},e),{day:r})}),Ye=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=r.getTime()-n.getTime();return Math.floor(a/864e5)},Fe=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=B(e.start);return r>=t&&r<=n}).map(e=>{const n=Le(B(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},ze=(e,t)=>{var n,r;const a=new Date(t);a.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},_e=(e,t,n)=>{var r;const a=new Date(n);a.setDate(n.getDate()+t);const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{day:t,start:Re(a,o),end:Re(a,o)})},We=(t,n)=>{var r,a;const o=Ae(n,null!==(r=t.day)&&void 0!==r?r:0);if(null!==(a=t.allDay)&&void 0!==a&&a){const n=e.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const i=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds(),millisecond:o.getMilliseconds()});return Object.assign(Object.assign({},t),{start:i,end:i})},Ue=(t,n,r)=>{var a,o;const i=Ae(n,null!==(a=t.day)&&void 0!==a?a:0);if(null!==(o=t.allDay)&&void 0!==o&&o){const n=e.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const l=e.ZonedDateTime.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate(),hour:i.getHours(),minute:i.getMinutes(),second:i.getSeconds(),millisecond:i.getMilliseconds(),timeZone:r});return Object.assign(Object.assign({},t),{start:l,end:l})},Be=(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()),Ze=(e,t)=>B(e.start).getTime()!==B(t.start).getTime()||B(e.end).getTime()!==B(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function Ve(){const t=new Date,n=t.getDay(),r=new Date(t),a=0===n?-6:1-n;r.setDate(t.getDate()+a),r.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(t=>{const n=new Date(r);if(n.setDate(r.getDate()+t.day),t.allDay)return{id:t.id,title:t.title,start:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:t.calendarId,day:t.day};const a=Math.floor(t.startHour),o=Math.round(60*(t.startHour-a)),i=Math.floor(t.endHour),l=Math.round(60*(t.endHour-i));return{id:t.id,title:t.title,start:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:e.Now.timeZoneId()}),end:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:i,minute:l,timeZone:e.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})}function Ge(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function Ke(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),r=Object.keys(t);if(n.length!==r.length)return!1;const a=e,o=t;for(const e of n)if(!r.includes(e)||!Ke(a[e],o[e]))return!1;return!0}const qe=new class{constructor(){var e,t;this.isDevelopment="production"!==(null===(t=null===(e=globalThis.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV)}formatMessage(e,t,...n){if(!this.isDevelopment)return;const r=(new Date).toISOString(),a=`[DayFlow ${e.toUpperCase()}] ${r}:`;switch(e){case"log":console.log(a,t,...n);break;case"warn":console.warn(a,t,...n);break;case"error":console.error(a,t,...n);break;case"debug":console.debug(a,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)}};class Xe{constructor(e=[]){this.events=new Map,this.isInTransaction=!1,this.pendingChanges=[],e.forEach(e=>this.events.set(e.id,e))}beginTransaction(){this.isInTransaction?console.warn("Transaction already in progress. Nested transactions are not supported."):(this.isInTransaction=!0,this.pendingChanges=[])}endTransaction(){var e;if(!this.isInTransaction)return;const t=Xe.normalizeChanges(this.pendingChanges);this.isInTransaction=!1,this.pendingChanges=[],t.length>0&&(null===(e=this.onEventBatchChange)||void 0===e||e.call(this,t))}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);this.events.set(e.id,e),this.emitChange({type:"create",event:e})}updateEvent(e,t){const n=this.events.get(e);if(!n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},n),t);this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);t&&(this.events.delete(e),this.emitChange({type:"delete",event:t}))}getEvent(e){return this.events.get(e)}getAllEvents(){return Array.from(this.events.values())}emitChange(e){var t;this.isInTransaction?this.pendingChanges.push(e):null===(t=this.onEventChange)||void 0===t||t.call(this,e)}static normalizeChanges(e){const t=new Map;for(const n of e){const e="delete"===n.type?n.event.id:"update"===n.type?n.after.id:n.event.id,r=t.get(e);r?"create"===r.type?"update"===n.type?t.set(e,{type:"create",event:n.after}):"delete"===n.type&&t.delete(e):"update"===r.type?"update"===n.type?t.set(e,{type:"update",before:r.before,after:n.after}):"delete"===n.type&&t.set(e,{type:"delete",event:r.before}):"delete"===r.type&&"create"===n.type&&t.set(e,{type:"update",before:r.event,after:n.event}):t.set(e,n)}return Array.from(t.values())}}class Je{constructor(e){var t,n,r,a,o;this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.MAX_UNDO_STACK=50,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.pushToUndo=e=>{this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()},this.undo=()=>{if(0===this.undoStack.length)return;const e=this.undoStack.pop();"events_snapshot"===(null==e?void 0:e.type)&&(this.state.events=e.data,this.store=new Xe(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())},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.handleVisibleRangeChange("viewChange"),this.notify()},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.emitVisibleRange=(e,t,n="navigation")=>{var r,a;null===(a=(r=this.callbacks).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)},this.handleVisibleRangeChange=e=>{var t,n,r,a;const o=this.state.views.get(this.state.currentView);switch(null==o?void 0:o.type){case I.DAY:{const t=new Date(this.state.currentDate);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}case I.WEEK:{const r=null!==(n=null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.startOfWeek)&&void 0!==n?n:1,{monday:a}=Y(this.state.currentDate,r),i=new Date(a),l=new Date(a);l.setDate(l.getDate()+7),this.emitVisibleRange(i,l,e);break}case I.MONTH:{if("navigation"===e)break;const t=new Date(this.state.currentDate.getFullYear(),this.state.currentDate.getMonth(),1),n=null!==(a=null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.startOfWeek)&&void 0!==a?a:1,{monday:i}=Y(t,n),l=new Date(i),s=new Date(i);s.setDate(s.getDate()+42),this.emitVisibleRange(l,s,e);break}case I.YEAR:{const t=new Date(this.state.currentDate.getFullYear(),0,1);t.setHours(0,0,0,0);const n=new Date(this.state.currentDate.getFullYear(),11,31);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}}},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.handleVisibleRangeChange("navigation"),this.notify()},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const r=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===r.getFullYear()&&this.visibleMonth.getMonth()===r.getMonth()||(this.visibleMonth=r,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())},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 I.DAY:e.setDate(e.getDate()-1);break;case I.WEEK:e.setDate(e.getDate()-7);break;case I.MONTH:e.setMonth(e.getMonth()-1);break;case I.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case I.DAY:e.setDate(e.getDate()+1);break;case I.WEEK:e.setDate(e.getDate()+7);break;case I.MONTH:e.setMonth(e.getMonth()+1);break;case I.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.applyEventsChanges=(e,t,n)=>{if(this.isInternalEditable()||t){if(t?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),t){let t=[...this.state.events];if(e.delete){const n=new Set(e.delete);t=t.filter(e=>!n.has(e.id))}return e.update&&e.update.forEach(({id:e,updates:n})=>{const r=t.findIndex(t=>t.id===e);-1!==r&&(t[r]=Object.assign(Object.assign({},t[r]),n))}),e.add&&(t=[...t,...e.add]),this.state.events=t,void this.notify()}n&&(this.pendingChangeSource=n),this.store.beginTransaction(),e.delete&&e.delete.forEach(e=>this.store.deleteEvent(e)),e.update&&e.update.forEach(({id:e,updates:t})=>{try{this.store.updateEvent(e,t)}catch(t){console.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){console.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}},this.addEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)):qe.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n,r)=>{if(this.isInternalEditable()||n){if(this.isInternalEditable()){if(r&&(this.pendingChangeSource=r),n?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),n){const n=this.state.events.findIndex(t=>t.id===e);if(-1===n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[n]),t);return this.state.events=[...this.state.events.slice(0,n),r,...this.state.events.slice(n+1)],void this.notify()}this.store.updateEvent(e,t)}}else qe.warn("Cannot update event in read-only mode")},this.deleteEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.deleteEvent(e)):qe.warn("Cannot delete event in read-only mode")},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&&(this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.selectEvent=e=>{var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.dismissUI=()=>{var e,t;null===(t=(e=this.callbacks).onDismissUI)||void 0===t||t.call(e),this.notify()},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,r;this.calendarRegistry.reorder(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setCalendarVisibility=(e,t)=>{var n,r;this.calendarRegistry.setVisibility(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.updateCalendar=(e,t,n)=>{var r,a,o,i;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const l=this.calendarRegistry.get(e);l&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,l)),null===(i=(o=this.callbacks).onRender)||void 0===i||i.call(o),this.notify()},this.createCalendar=e=>{var t,n,r,a;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.deleteCalendar=e=>{var t,n,r,a;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.mergeCalendars=(e,t)=>{var n,r;const a=this.store.getAllEvents().filter(t=>t.calendarId===e);this.pushToUndo(),this.store.beginTransaction(),a.forEach(e=>{this.store.updateEvent(e.id,{calendarId:t})}),this.store.endTransaction(),this.deleteCalendar(e),null===(r=(n=this.callbacks).onCalendarMerge)||void 0===r||r.call(n,e,t)},this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?qe.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.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.notify())},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.notify()},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||Ke(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.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=Je.resolveLocale(e.locale);Ke(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&(this.triggerRender(),this.notify())},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.notify()},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:e.defaultView||I.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:Je.resolveLocale(e.locale),highlightedEventId:null,selectedEventId:null,readOnly:e.readOnly||!1},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.store=new Xe(this.state.events),this.setupStoreListeners(),this.calendarRegistry=new ce(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,ue=o;const i=this.state.currentDate;this.visibleMonth=new Date(i.getFullYear(),i.getMonth(),1),this.useEventDetailDialog=null!==(n=e.useEventDetailDialog)&&void 0!==n&&n,this.useCalendarHeader=null===(r=e.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=e.customMobileEventRenderer,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(a=e.plugins)||void 0===a||a.forEach(e=>{this.installPlugin(e)}),this.handleVisibleRangeChange("initial")}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a,o,i;this.state.events=this.store.getAllEvents(),"create"===e.type?null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e.event):"update"===e.type?null===(a=(r=this.callbacks).onEventUpdate)||void 0===a||a.call(r,e.after):"delete"===e.type&&(null===(i=(o=this.callbacks).onEventDelete)||void 0===i||i.call(o,e.event.id)),this.triggerRender(),this.notify()},this.store.onEventBatchChange=e=>{var t,n;this.state.events=this.store.getAllEvents(),"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(null===(n=(t=this.callbacks).onEventBatchChange)||void 0===n||n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify()}}static resolveLocale(e){return e?"string"==typeof e?M(e)?e:"en-US":e&&"object"==typeof e&&!M(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}var Qe=0;function et(e,n,r,a,o,i){n||(n={});var l,s,d=n;if("ref"in d)for(s in d={},n)"ref"==s?l=n[s]:d[s]=n[s];var c={type:e,props:d,key:r,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Qe,__i:-1,__u:0,__source:o,__self:i};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===d[s]&&(d[s]=l[s]);return t.vnode&&t.vnode(c),c}const tt=t=>{if(!t)return"";let n,r,a;t instanceof Date?(a=t.getFullYear(),r=t.getMonth()+1,n=t.getDate()):z(t)?(a=t.year,r=t.month,n=t.day):(!function(t){if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;const n=t;e.ZonedDateTime}(t),a=t.year,r=t.month,n=t.day);const o=String(r).padStart(2,"0");return`${String(n).padStart(2,"0")}/${o}/${a}`},nt=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,rt=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 at(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function ot(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function it(e){return null!==e&&"object"==typeof e&&"timeZone"in e&&"year"in e&&!(e instanceof Date)}function lt(e){if(e instanceof Date)return e;if(at(e))return new Date(e.year,e.month-1,e.day);if(ot(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(it(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}catch(t){return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}return new Date(e)}function st(t){return e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()})}function dt(t){return e.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds()})}function ct(t,n=e.Now.timeZoneId()){return e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:n})}function ut(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}function ht(e){return new Date(e.year,e.month-1,e.day)}function gt(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(at(e))return 0;const t=e;return t.hour+t.minute/60}function mt(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return it(e),e.with({hour:n,minute:r,second:0,millisecond:0})}function vt(e){return e instanceof Date?st(e):at(e)?e:(ot(e),e.toPlainDate())}function ft(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=vt(e),r=vt(t);return n.equals(r)}const pt=/(YYYY|YY|MM|DD|HH|mm)/g,yt=e=>e.toString().padStart(2,"0"),bt=(e,t)=>{const n=(null!=t?t:"").trim(),r=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return r.replaceAll(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},wt=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Dt=e=>{let t,n=0,r="^";for(;null!==(t=pt.exec(e));){r+=wt(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=wt(e.slice(n))+"$",new RegExp(r)},xt=(t,n,r,a)=>{const o=t.trim();if(!o)return null;const i=o.match(n),l=null==i?void 0:i.groups;if(!l)return null;const s=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:r.year,d=l.MM?Number(l.MM):r.month,c=l.DD?Number(l.DD):r.day,u=l.HH?Number(l.HH):r.hour,h=l.mm?Number(l.mm):r.minute;try{return e.ZonedDateTime.from({timeZone:a,year:s,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},Et=t=>{const n=t;return n.timeZoneId&&"string"==typeof n.timeZoneId?n.timeZoneId:n.timeZone&&"string"==typeof n.timeZone.id?n.timeZone.id:"string"==typeof n.timeZone?n.timeZone:e.Now.timeZoneId()},Ct=(t,n,r)=>{var a,o,i,l,s,d,c,u,h,g,m,v,f,p,y,b,w,D,x,E,C,k,T,N;if(!t){const t=null!=n?n:r?Et(r):e.Now.timeZoneId();return null!=r?r:e.Now.zonedDateTimeISO(t)}if(at(t)){const r=null!=n?n:e.Now.timeZoneId(),a=`${t.year}-${yt(t.month)}-${yt(t.day)}T00:00:00[${r}]`;return e.ZonedDateTime.from(a)}const S=t;if("hour"in S&&!("timeZone"in S)){const r=null!=n?n:e.Now.timeZoneId();if("function"==typeof S.toZonedDateTime)try{return t.toZonedDateTime(r)}catch(e){}return e.ZonedDateTime.from({timeZone:r,year:S.year,month:S.month,day:S.day,hour:S.hour,minute:S.minute,second:null!==(a=S.second)&&void 0!==a?a:0,millisecond:null!==(o=S.millisecond)&&void 0!==o?o:0,microsecond:null!==(i=S.microsecond)&&void 0!==i?i:0,nanosecond:null!==(l=S.nanosecond)&&void 0!==l?l:0})}try{return e.ZonedDateTime.from(t)}catch(t){const a=S,o=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(s=null==a?void 0:a.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==a?void 0:a.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?Et(r):void 0)&&void 0!==h?h:e.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:e.Now.zonedDateTimeISO(o);return e.ZonedDateTime.from({timeZone:o,year:null!==(g=null==a?void 0:a.year)&&void 0!==g?g:i.year,month:null!==(m=null==a?void 0:a.month)&&void 0!==m?m:i.month,day:null!==(v=null==a?void 0:a.day)&&void 0!==v?v:i.day,hour:null!==(p=null!==(f=null==a?void 0:a.hour)&&void 0!==f?f:null==r?void 0:r.hour)&&void 0!==p?p:0,minute:null!==(b=null!==(y=null==a?void 0:a.minute)&&void 0!==y?y:null==r?void 0:r.minute)&&void 0!==b?b:0,second:null!==(D=null!==(w=null==a?void 0:a.second)&&void 0!==w?w:null==r?void 0:r.second)&&void 0!==D?D:0,millisecond:null!==(E=null!==(x=null==a?void 0:a.millisecond)&&void 0!==x?x:null==r?void 0:r.millisecond)&&void 0!==E?E:0,microsecond:null!==(k=null!==(C=null==a?void 0:a.microsecond)&&void 0!==C?C:null==r?void 0:r.microsecond)&&void 0!==k?k:0,nanosecond:null!==(N=null!==(T=null==a?void 0:a.nanosecond)&&void 0!==T?T:null==r?void 0:r.nanosecond)&&void 0!==N?N:0})}},kt=(e,t,n)=>{const r=bt(t,n),a={YYYY:e.year.toString(),YY:yt(e.year%100),MM:yt(e.month),DD:yt(e.day),HH:yt(e.hour),mm:yt(e.minute)};return r.replace(pt,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function Tt(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}let Nt=null;function St(){if("undefined"==typeof document)return!1;if(null!==Nt)return Nt;const e=document.createElement("style");e.textContent=".df-calendar-container .__df_measure__::-webkit-scrollbar { display: block !important; }",document.head.append(e);const t=document.createElement("div");t.className="df-calendar-container",t.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:hidden";const n=document.createElement("div");n.className="__df_measure__",n.style.cssText="width:100px;height:100px;overflow:scroll",t.append(n),document.body.append(t);const r=n.offsetWidth-n.clientWidth>0;return t.remove(),e.remove(),Nt=r,r}const Mt=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),It={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"},Ht=(e,t,n)=>e?t:n,At=(...e)=>e.filter(Boolean).join(" "),Ot=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.dataset.dayflowThemeOverride,t.dataset.themeOverride,t.dataset.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 Rt(t,n=!1){if(t instanceof e.PlainDate||t instanceof e.PlainDateTime)return t;if(t instanceof Date)return n?st(t):dt(t);throw new Error("Invalid time type: "+typeof t)}function Pt(t,n){if(t instanceof e.ZonedDateTime)return t;if(t instanceof Date)return ct(t,n);throw new Error("Invalid time type: "+typeof t)}function Lt(e){var t;const n=Rt(e.start,e.allDay),r=Rt(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:r,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function $t(e){const t=Pt(e.start,e.timeZone),n=Pt(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 jt(e){return e.map(e=>Lt(e))}function Yt(e){return e.map(e=>$t(e))}function Ft(e,t,n,r){return Lt(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))}function zt(e,t,n,r,a){return Lt(Object.assign({id:e,title:t,start:n,end:r},a))}function _t(e,t,n,r,a=!1,o){return Lt(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))}function Wt(e,t,n,r,a,o){return $t(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))}const Ut=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):B(e)}catch(e){return new Date}},Bt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Zt=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let i="",l="text-gray-500 dark:text-gray-400";if(0===o)i=r("today")||"Today",l="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");i=e.charAt(0).toUpperCase()+e.slice(1),l="text-black dark:text-white"}catch(t){i=e.toLocaleDateString(n,{weekday:"long"})}else i=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:i,colorClass:l}},Vt=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Ut(e.start),a=Bt(r),o=a.getTime();n.has(o)||n.set(o,{date:a,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const r=t.getTime();n.has(r)||n.set(r,{date:t,events:[]});return Array.from(n.values()).toSorted((e,t)=>e.date.getTime()-t.date.getTime())};const Gt=new class{constructor(){this.lastCopiedEvent=null}setEvent(e){this.lastCopiedEvent=e}getEvent(){return this.lastCopiedEvent}hasEvent(){return null!==this.lastCopiedEvent}clear(){this.lastCopiedEvent=null}};function Kt(e){return String(e).padStart(2,"0")}function qt(t,n,r){const a=t.trim(),o=/^(\d{4})(\d{2})(\d{2})$/,i=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;if("DATE"===(null==n?void 0:n.value)||o.test(a)){const t=a.match(o);if(t)return e.PlainDate.from({year:Number.parseInt(t[1],10),month:Number.parseInt(t[2],10),day:Number.parseInt(t[3],10)})}if(i.test(a)){const t=a.match(i);if(t){const n=e.Instant.from(`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}Z`),a=r||e.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const t={year:Number.parseInt(l[1],10),month:Number.parseInt(l[2],10),day:Number.parseInt(l[3],10),hour:Number.parseInt(l[4],10),minute:Number.parseInt(l[5],10),second:Number.parseInt(l[6],10)};return(null==n?void 0:n.tzid)?e.ZonedDateTime.from(Object.assign(Object.assign({},t),{timeZone:n.tzid})):e.PlainDateTime.from(t)}throw new Error(`Invalid ICS date format: ${t}`)}function Xt(e,t=!1){if(t||at(e)){const t=at(e)?e:e.toPlainDate();return{value:`${t.year}${Kt(t.month)}${Kt(t.day)}`,params:{VALUE:"DATE"}}}if(it(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Kt(t.month)}${Kt(t.day)}T${Kt(t.hour)}${Kt(t.minute)}${Kt(t.second)}Z`}}if(ot(e))return{value:`${e.year}${Kt(e.month)}${Kt(e.day)}T${Kt(e.hour)}${Kt(e.minute)}${Kt(e.second)}`};throw new Error("Unsupported Temporal type")}function Jt(e){return`${e.getUTCFullYear()}${Kt(e.getUTCMonth()+1)}${Kt(e.getUTCDate())}T${Kt(e.getUTCHours())}${Kt(e.getUTCMinutes())}${Kt(e.getUTCSeconds())}Z`}function Qt(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function en(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function tn(e){if(e.length<=75)return e;const t=[];let n=e;for(t.push(n.slice(0,75)),n=n.slice(75);n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}function nn(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,tn(r)}function rn(e){var t,n,r;const a=["BEGIN:VEVENT"],o=(null===(t=e.meta)||void 0===t?void 0:t.originalUid)||`${e.id}@dayflow`;a.push(`UID:${o}`),a.push(`DTSTAMP:${Jt(new Date)}`);const i=Xt(e.start,e.allDay),l=Xt(e.end,e.allDay);if(a.push(nn("DTSTART",i.value,i.params)),a.push(nn("DTEND",l.value,l.params)),a.push(nn("SUMMARY",Qt(e.title))),e.description&&a.push(nn("DESCRIPTION",Qt(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(nn("LOCATION",Qt(e.meta.location))),(null===(r=e.meta)||void 0===r?void 0:r.categories)&&Array.isArray(e.meta.categories)){const t=e.meta.categories.map(Qt).join(",");a.push(nn("CATEGORIES",t))}return a.push("END:VEVENT"),a}function an(e){const t=[];let n=null,r=!1;for(const a of e){const e=a.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(r=!0,n=[]):e.startsWith("END:VEVENT")?(r&&n&&t.push(n),r=!1,n=null):r&&n&&n.push(a)}return t}function on(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e),a=n.slice(e+1),[o,...i]=r.split(";"),l=o.trim().toUpperCase(),s={};switch(i.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),l){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=en(a);break;case"DESCRIPTION":t.description=en(a);break;case"LOCATION":t.location=en(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>en(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=Ge()),t}function ln(t,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=n,s=o?`${i}${Ge()}`:t.uid,d=qt(t.dtstart,t.dtstartParams,l);let c;c=t.dtend?qt(t.dtend,t.dtendParams,l):at(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=t.dtstartParams)||void 0===r?void 0:r.value)||at(d),h=l||e.Now.timeZoneId();let g,m;if(at(d))g=d.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ot(d))try{g=d.toZonedDateTime(h)}catch(t){g=e.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(at(c))m=c.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ot(c))try{m=c.toZonedDateTime(h)}catch(t){m=e.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:t.summary||"(No Title)",description:t.description,start:g,end:m,allDay:u,meta:{location:t.location,originalUid:t.uid,categories:t.categories}}}function sn(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=an(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=ln(on(e),t);n.events.push(r)}catch(e){n.errors.push({line:0,message:e instanceof Error?e.message:"Unknown parsing error",eventUid:`index-${r}`})}}),n.success=0===n.errors.length,n.totalImported=n.events.length}catch(e){n.errors.push({message:`Fatal parsing error: ${e instanceof Error?e.message:"Unknown error"}`})}return n}function dn(e,t={}){const{calendarName:n="DayFlow Calendar",productId:r="-//DayFlow//DayFlow Calendar//EN"}=t,a=["BEGIN:VCALENDAR","VERSION:2.0",`PRODID:${r}`,"CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${Qt(n)}`];return e.forEach(e=>{a.push(...rn(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}function cn(e,t={}){const n=dn(e,t),r=`${t.filename||"calendar"}.ics`,a=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.setAttribute("download",r),document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(o)}function un(e,t){return y(this,void 0,void 0,function*(){try{const n=yield e.text();if(!n)throw new Error("File content is empty");return sn(n,t)}catch(e){return{success:!1,events:[],errors:[{message:e instanceof Error?e.message:"string"==typeof e?e:"Failed to read file"}],totalParsed:0,totalImported:0}}})}let hn=null;const gn=()=>{const[e,t]=u(()=>hn||{weekHeight:A.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return h(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(A.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(A.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(A.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};hn=a,t(e=>e.screenSize===a.screenSize&&e.weekHeight===a.weekHeight&&e.weeksPerView===a.weeksPerView?e:a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},mn=n({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function vn(){return f(mn)}const fn=n(null);let pn=0;function yn({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const a=g(null),o=f(fn),i=r||o,l=g(null),[,s]=u(0);l.current||(l.current="df-slot-"+pn++),h(()=>{if(!a.current||!i)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t});const r=i.subscribe(()=>{s(e=>e+1)});return()=>{i.unregister(n),r()}},[i]),h(()=>{if(!i||!l.current)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t})},[e,t]);const d="eventContent"===e,c="sidebar"===e,m=null==i?void 0:i.isOverridden(e);return et("div",{ref:a,className:"df-content-slot "+(d||c?"flex h-full flex-1 flex-col":""),children:!m&&n})}const bn="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",wn="p-2 flex justify-between",Dn="text-2xl font-bold text-gray-900 dark:text-gray-100",xn="rounded-md bg-background border border-border px-3 py-2 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",En="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Cn="flex-1 overflow-auto will-change-scroll",kn="scrollbar-hide",Tn="df-time-slot relative h-[4.5rem] flex",Nn="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Sn="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",Mn="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",In="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Hn="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",An="rounded-xl my-0.5",On="rounded-sm",Rn="df-event-title font-medium text-xs truncate pr-1",Pn="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Ln="h-3 w-3 mr-1",$n="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",jn="bg-primary rounded-full text-primary-foreground",Yn="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",Fn="h-4 w-4 transition-transform group-hover:scale-110",zn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",_n="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",Wn="h-3 border-t border-gray-200 dark:border-gray-700 relative",Un="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Bn="df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",Zn="df-sidebar-header flex items-center px-2 py-1",Vn="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",Gn="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",Kn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",qn="text-gray-500 dark:text-gray-400",Xn="text-gray-600 dark:text-gray-300",Jn="text-xs",Qn="text-sm",er="flex flex-col",tr="mr-1",nr=(...e)=>e.filter(Boolean).join(" "),rr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m15 18-6-6 6-6"})}),ar=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m9 18 6-6-6-6"})}),or=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m11 17-5-5 5-5"}),et("path",{d:"m18 17-5-5 5-5"})]}),ir=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m6 17 5-5-5-5"}),et("path",{d:"m13 17 5-5-5-5"})]}),lr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m6 9 6 6 6-6"})}),sr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M5 12h14"}),et("path",{d:"M12 5v14"})]}),dr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("circle",{cx:"11",cy:"11",r:"8"}),et("path",{d:"m21 21-4.3-4.3"})]}),cr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M20 6 9 17l-5-5"})}),ur=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m7 15 5 5 5-5"}),et("path",{d:"m7 9 5-5 5 5"})]}),hr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M18 6 6 18"}),et("path",{d:"m6 6 12 12"})]}),gr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M8 2v4"}),et("path",{d:"M16 2v4"}),et("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),et("path",{d:"M3 10h18"}),et("path",{d:"M8 14h.01"}),et("path",{d:"M12 14h.01"}),et("path",{d:"M16 14h.01"}),et("path",{d:"M8 18h.01"}),et("path",{d:"M12 18h.01"}),et("path",{d:"M16 18h.01"})]}),mr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M18 8L22 12L18 16"}),et("path",{d:"M2 12H22"})]}),vr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),fr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),et("path",{d:"M12 5a3 3 0 1 0-3 3"}),et("path",{d:"M12 5a3 3 0 1 1 3 3"}),et("path",{d:"M3 12h18"}),et("path",{d:"M12 22V8"})]}),pr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})}),yr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),et("circle",{cx:"12",cy:"10",r:"3"})]}),br=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),wr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),et("path",{d:"M15 3v18"}),et("path",{d:"m8 9 3 3-3 3"})]}),Dr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),et("path",{d:"M15 3v18"}),et("path",{d:"m10 15-3-3 3-3"})]}),xr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m12 19-7-7 7-7"}),et("path",{d:"M19 12H5"})]});function Er(e,t){var n,r,a,o,i;try{if("today"===e){return null!==(r=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!==r?r:null}if("week"===e){return null!==(o=null===(a=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===a?void 0:a.value)&&void 0!==o?o:null}return null!==(i=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==i?i:null}catch(e){return null}}function Cr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const kr=(e,t="short",n=1)=>{const r=[],a=new Date(2024,0,7);for(let o=0;o<7;o++){const i=new Date(a);i.setDate(a.getDate()+n+o);try{r.push(i.toLocaleDateString(e,{weekday:t}))}catch(e){r.push(i.toLocaleDateString("en-US",{weekday:t}))}}return r},Tr=(e,t="long")=>{const n=[];for(let r=0;r<12;r++){const a=new Date(2024,r,1);try{n.push(a.toLocaleDateString(e,{month:t}))}catch(e){n.push(a.toLocaleDateString("en-US",{month:t}))}}return n};function Nr(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Er(e,t);if(n)return Cr(n)}const r=S(t),a=T[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const i=T.en.messages;return(null==i?void 0:i[e])||e}const Sr=({locale:e="en-US",messages:t,children:n})=>{const r=v(()=>{if("string"==typeof e){return{code:M(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!M(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),a=v(()=>{const e=r.code;return{locale:e,t:(n,a)=>{var o,i,l;let s=null!==(l=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(i=r.messages)||void 0===i?void 0:i[n])&&void 0!==l?l:Nr(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:kr,getMonthLabels:Tr,isDefault:!1}},[r,t]);return et(mn.Provider,{value:a,children:n})},Mr=({calendar:e,mode:t="buttons"})=>{const[n,r]=u(!1),a=g(null),{t:o}=vn(),i=Array.from(e.state.views.keys()),l=e.state.currentView;return h(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&r(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),i.length<=1?null:et("div","select"===t?{className:"relative inline-block",ref:a,children:[et("button",{type:"button",onClick:()=>r(!n),className:"flex h-7 min-w-30 items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm font-medium shadow-sm transition-all duration-200 hover:bg-gray-50 focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:hover:bg-gray-700","aria-expanded":n,"aria-haspopup":"listbox",children:[et("span",{className:"text-gray-900 dark:text-gray-100",children:o(l)}),et("span",{className:`${qn} transition-transform duration-200 ${n?"rotate-180":""}`,children:et(lr,{width:16,height:16})})]}),n&&et("div",{className:"absolute top-full left-0 z-50 mt-1 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:et("div",{className:"p-1",role:"listbox",children:i.map(t=>et("button",{type:"button",onClick:()=>{e.changeView(t),r(!1),e.triggerRender()},className:"w-full rounded px-3 py-0.5 text-left text-sm transition-colors duration-150 focus:outline-none "+(l===t?"bg-primary/10 font-medium text-primary":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:o(t)},t))})}),et("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 "})]}:{className:"mb-1 inline-flex items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:i.map(t=>et("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(l===t?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-gray-100":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100"),onClick:()=>{e.changeView(t),e.triggerRender()},children:o(t)},t))})},Ir=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o="",isSearchOpen:i=!1,isEditable:l=!0,safeAreaLeft:s})=>{const d=f(fn),c="buttons"===t,u=e.state.currentView===I.DAY,{screenSize:h}=gn(),g="mobile"===h,{t:p}=vn(),y=m(e=>{const t=e.currentTarget.value;t!==o&&(null==r||r(t))},[r,o]);return et(yn,{store:d,generatorName:"headerContent",generatorArgs:v(()=>({calendar:e,switcherMode:t,onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o,isSearchOpen:i,isEditable:l,safeAreaLeft:s}),[e,t,n,r,a,o,i,l,s]),defaultContent:et("div",{className:"df-header flex shrink-0 items-center justify-between border-b bg-white pt-1 pr-2 transition-colors duration-200 dark:bg-gray-900 "+(u||i?"border-gray-200 dark:border-gray-700":"border-transparent"),style:{paddingLeft:s||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"df-header-left mb-1 flex items-center",children:n&&l&&et("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Kn,title:g?p("newEvent")||"New Event":p("createCalendar")||"Add Calendar",children:et(sr,{className:`h-4 w-4 ${qn}`})})}),et("div",{className:"df-header-mid flex flex-1 justify-center",children:c&&et(Mr,{mode:t,calendar:e})}),et("div",{className:"df-header-right mb-1 flex items-center justify-end gap-3 pb-1",children:[!c&&et(Mr,{mode:t,calendar:e}),et("button",{type:"button",onClick:a,className:`md:hidden ${Kn}`,title:p("search")||"Search",children:et(dr,{width:16,height:16})}),et("div",{className:"group relative hidden md:block",children:[et("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:et("span",{className:"text-gray-400 transition-colors group-focus-within:text-primary",children:et(dr,{width:16,height:16})})}),et("input",{id:"dayflow-search-input",type:"text",placeholder:p("search")||"Search",value:o,onChange:y,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&&et("button",{type:"button",onClick:()=>{null==r||r("")},className:"absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:et("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[et("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),et("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})})},Hr=n(void 0),Ar=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,a]=u(t),[o,i]=u("light"),l="auto"===r?o:r;h(()=>{a(t)},[t]);const s=m(e=>{a(e)},[]);h(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";i(t)},n=e.matches?"dark":"light";return i(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),h(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Ot(l),n="auto"===r?t:l;e.classList.remove("light","dark"),e.classList.add(n),"auto"===r?delete e.dataset.dayflowThemeOverride:e.dataset.dayflowThemeOverride=n,e.dataset.theme=n},[l,r,o]),h(()=>{n&&n(r,l)},[r,l,n]);const d=v(()=>({theme:r,effectiveTheme:l,setTheme:s}),[r,l,s]);return et(Hr.Provider,{value:d,children:e})},Or=()=>{const e=f(Hr);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Rr=e=>{const t=g(null),n=g(null);return h(()=>{if(t.current){const r=b(e,[]);n.current=new w(t.current,r),r.initialExpanded&&n.current.expand()}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),h(()=>{if(n.current){const t=b(e,[]);n.current.setOptions(t)}},[e]),et("div",{ref:t,className:e.className})},Pr=({color:e,onChange:t,onClose:n})=>{const r=v(()=>{const{h:t,l:n}=D(e);return{hue:t,saturation:x(n),lightness:n,alpha:100,layer:"outer"}},[e]);return et("div",{className:"flex justify-center",children:et(Rr,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Lr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],$r=({onClose:e,onCreate:t,colorPickerMode:n="default"})=>{const{t:a}=vn(),{effectiveTheme:o}=Or(),[i,l]=u(""),[d,c]=u(Lr[Math.floor(Math.random()*Lr.length)]),[h,g]=u(!1),[m,f]=u(""),p=v(()=>{const e=E[Math.floor(Math.random()*E.length)],t=e.layer||"outer",n=x(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[y,b]=u(null),w=e=>{c(e.hex)},D="dark"===o,k={default:{picker:{background:D?"#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:D?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:D?"#1e293b":"#ffffff",borderBottom:D?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:D?"#1e293b":"#ffffff"},controls:{border:D?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:D?"#374151":"#ffffff",color:D?"#f3f4f6":"#1f2937",border:D?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:D?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:D?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:s(et("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:et("div",{className:"animate-in fade-in zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-slate-900",onClick:e=>e.stopPropagation(),children:[et("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("default"===n?"mb-6":"mb-4"),children:a("createCalendar")}),et("form",{onSubmit:r=>{var a;if(r.preventDefault(),!i.trim())return;let o;o="default"===n?null!==(a=null==y?void 0:y.hex)&&void 0!==a?a:C(p.hue,p.saturation,p.lightness):d;const{colors:l,darkColors:s}=ge(o),c={id:Ge(),name:i.trim(),colors:l,darkColors:s,isVisible:!0,isDefault:!1};t(c),e()},children:["default"===n?et("div",{className:"mb-8 flex items-center gap-4",children:[et("div",{className:"flex-1",children:et("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:i,onChange:e=>l(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})}),et("div",{className:"relative h-9 w-9 shrink-0",children:et("div",{className:"absolute inset-0 flex items-center justify-center",children:et(Rr,{defaultValue:p,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>b(e),onCollapse:e=>b(e),className:"z-50"})})})]}):et(r,{children:[et("div",{className:"mb-4",children:et("div",{className:"flex items-center gap-3",children:[et("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:d}}),et("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:i,onChange:e=>l(e.target.value),className:"w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})]})}),et("div",{className:"mb-6",children:[et("div",{className:"grid grid-cols-7 gap-6",children:Lr.map(e=>et("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none 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))}),et("div",{className:"relative mt-2",children:[et("button",{type:"button",onClick:()=>{f(d),g(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 transition-colors hover:bg-slate-100 focus:bg-slate-100 focus:outline-none dark:text-slate-200 dark:hover:bg-slate-800 dark:focus:bg-slate-800",children:a("customColor")}),h&&et("div",{className:"absolute top-full left-0 z-10001 mt-2",children:et(yn,{generatorName:"colorPickerWrapper",generatorArgs:{variant:"photoshop",color:d,onChange:w,onAccept:()=>{g(!1)},onCancel:()=>{c(m),g(!1)},styles:k},defaultContent:et("div",{children:et(Pr,{color:d,onChange:w})})})})]})]})]}),et("div",{className:"flex justify-end space-x-2",children:[et("button",{type:"button",onClick:e,className:"rounded border border-slate-200 px-2 py-1 text-xs font-medium text-gray-700 transition hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",children:a("cancel")}),et("button",{type:"submit",disabled:!i.trim(),className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-50",children:a("create")})]})]})]})}),document.body)},jr=(t,n)=>e.PlainDate.compare(t,n),Yr=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:o,disabled:i,onDaySelect:l})=>et(r,{children:[et("div",{className:"grid grid-cols-7 gap-1 px-1 pt-2 pb-3 text-center text-[12px] tracking-wide text-slate-400 uppercase dark:text-gray-500",children:o.map(e=>et("span",{children:e},e))}),et("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const r=e.month!==t.month,o=0===jr(e,n),s=0===jr(e,a),d=jr(e,n)>=0&&jr(e,a)<=0;return et("button",{type:"button",disabled:i,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||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())})})]}),Fr=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>et("div",{className:"flex items-center justify-between border-b border-slate-100 px-3 py-2 text-sm font-medium text-slate-700 dark:border-gray-600 dark:text-gray-300",children:[et("div",{className:"flex items-center gap-1",children:[et("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(or,{width:14,height:12})}),et("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(rr,{width:14,height:12})})]}),et("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),et("div",{className:"flex items-center gap-1",children:[et("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(ar,{width:14,height:12})}),et("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(ir,{width:14,height:12})})]})]}),zr=Array.from({length:24},(e,t)=>t),_r=Array.from({length:60},(e,t)=>t),Wr=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const i=e,l=t["start"===i?0:1],s=l.minute,d=_r.includes(s)?_r:[..._r,s].toSorted((e,t)=>e-t);return et("div",{className:"flex flex-col rounded-xl border border-slate-200 bg-white shadow-sm sm:w-28 dark:border-gray-600 dark:bg-gray-800",children:[et("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:et("div",{className:"py-1.5 text-base text-slate-700 dark:text-gray-300",children:[l.hour.toString().padStart(2,"0"),":",l.minute.toString().padStart(2,"0")]})}),et("div",{className:"flex p-1",children:[et("div",{className:"w-14",children:et("div",{className:`h-72 overflow-y-auto ${kn} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[i]&&(o.current[i].hour=e)},children:zr.map(e=>{const t=e===l.hour;return et("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary font-semibold text-primary-foreground":"text-slate-600 hover:bg-primary/10 hover:text-primary dark:text-gray-300"),"data-active":t?"true":void 0,children:yt(e)},e)})})}),et("div",{className:"w-14",children:et("div",{className:`h-72 overflow-y-auto ${kn} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[i]&&(o.current[i].minute=e)},children:d.map(e=>{const t=e===s;return et("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary font-semibold text-primary-foreground":"text-slate-600 hover:bg-primary/10 hover:text-primary dark:text-gray-300"),"data-active":t?"true":void 0,children:yt(e)},e)})})})]})]})},Ur=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:i,disabled:l,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:v,onOk:f,getPopupStyle:p})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return et("div",{ref:d,style:p(),"data-range-picker-popup":"true",children:et("div",{className:"space-y-3 rounded-xl border border-slate-200 bg-white p-3 dark:border-gray-600 dark:bg-gray-800",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[et("div",{className:"flex gap-1",children:[et("div",{className:"w-full flex-3 rounded-xl border border-slate-200 bg-white shadow-sm dark:border-gray-600 dark:bg-gray-800",children:[et(Fr,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),et(Yr,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&et("div",{className:"flex flex-1 justify-end sm:w-32",children:et(Wr,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),et("div",{className:"flex justify-end",children:et("button",{type:"button",onClick:f,disabled:l,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"})})]})})},Br=({value:t,format:n="YYYY-MM-DD HH:mm",showTimeFormat:r="HH:mm",showTime:a=!0,onChange:o,onOk:i,timeZone:l,disabled:d=!1,placement:c="bottomLeft",autoAdjustOverflow:f=!0,getPopupContainer:p,matchTriggerWidth:y=!1,locale:b="en-US"})=>{const w=v(()=>"string"==typeof b?b:(null==b?void 0:b.code)||"en-US",[b]),D=v(()=>void 0===a||("object"==typeof a||Boolean(a)),[a]),x=v(()=>Tr(w,"short"),[w]),E=v(()=>kr(w,"narrow"),[w]),C=v(()=>D?"object"==typeof a&&(null==a?void 0:a.format)?a.format:r:"",[D,a,r]),k=v(()=>bt(n,C),[n,C]),T=v(()=>Dt(k),[k]),N=v(()=>{const n=null!=l?l:z(t[0])?z(t[1])?e.Now.timeZoneId():Et(t[1]):Et(t[0]),r=Ct(t[0],n);return[r,Ct(t[1],n,r)]},[t,l]),[S,M]=u(N),I=g(N),[H,A]=u("start"),[O,R]=u([kt(N[0],n,C),kt(N[1],n,C)]),P=g([kt(N[0],n,C),kt(N[1],n,C)]),L=g(N),[$,j]=u(N[0].toPlainDate().with({day:1})),[Y,F]=u(!1),_=m(e=>{F(e)},[]),[W,U]=u(c),B=g(c),Z=g(null),V=g(null),G=g({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=g(!1),q=g(!1);h(()=>{P.current=O},[O]),h(()=>{L.current=S},[S]),h(()=>{const t=I.current,n=0!==e.ZonedDateTime.compare(t[0],N[0]),r=0!==e.ZonedDateTime.compare(t[1],N[1]);(n||r)&&M(N),I.current=N},[N]),h(()=>{j(N[0].toPlainDate().with({day:1}))},[N[0]]);const X=m((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,i=(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:i})},[]),J=m(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&X(n,r,0)})})})},[X]);h(()=>{Y&&D&&J(H)},[H,Y,J,D]);const Q=S[0].epochMilliseconds,ee=S[0].offsetNanoseconds,te=S[1].epochMilliseconds,ne=S[1].offsetNanoseconds;h(()=>{if(q.current)return;const[e,t]=L.current,r=kt(e,n,C),a=kt(t,n,C),[o,i]=P.current;o===r&&i===a||(P.current=[r,a],R([r,a]))},[Q,ee,te,ne,n,C]),h(()=>{if(!Y)return;const e=e=>{var t,n;const r=e.target;if(null===(t=Z.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=V.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-range-picker-popup]")||_(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[Y]),h(()=>{Y||(A("start"),K.current||M(N),K.current=!1)},[Y,N]);const re=m(e=>{o&&o(e,[kt(e[0],n,C),kt(e[1],n,C)])},[C,n,o]),ae=m(e=>{i&&i(e,[kt(e[0],n,C),kt(e[1],n,C)])},[C,n,i]),oe=m((t,n)=>{M(r=>{const a=[...r];if("start"===t){const t=Ct(a[1],Et(n),n),r=e.ZonedDateTime.compare(n,t)>0?n:t;return[n,r]}const o=Ct(a[0],Et(n),n);return[e.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ie=t=>{if(d)return;const n=(t,n)=>{var r,a,o,i;const l=Et(t);return e.ZonedDateTime.from({timeZone:l,year:n.year,month:n.month,day:n.day,hour:t.hour,minute:t.minute,second:null!==(r=t.second)&&void 0!==r?r:0,millisecond:null!==(a=t.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=t.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=t.nanosecond)&&void 0!==i?i:0})};if("start"===H){const e=n(S[0],t),r=S[1].epochMilliseconds-S[0].epochMilliseconds,a=e.add({milliseconds:r});return void M([e,a])}const r=n(S[1],t),a=S[1].epochMilliseconds-S[0].epochMilliseconds;if(e.ZonedDateTime.compare(r,S[0])<0){const e=n(S[0],t),r=e.add({milliseconds:a});return void M([e,r])}const o=[S[0],r];M(o),j(r.toPlainDate().with({day:1}))},le=m((t,n)=>{if(d)return;const r="start"===t?0:1;M(a=>{const o=a[r],i=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Ct(a[1],Et(i),i);return[i,e.ZonedDateTime.compare(i,t)>0?i:t]}const l=Ct(a[0],Et(i),i);return[e.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=G.current[t].hour;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[d]),se=m((t,n)=>{if(d)return;const r="start"===t?0:1;M(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Ct(a[1],Et(o),o);return[o,e.ZonedDateTime.compare(o,t)>0?o:t]}const i=Ct(a[0],Et(o),o);return[e.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=G.current[t].minute;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[d]),de=m((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),ce=m((e,t)=>{const r="start"===e?0:1,a=S[r],o=Et(a),i=xt(t,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});return j(t),"start"===e&&A("end"),!0}return R(e=>{const t=[...e];return t[r]=kt(S[r],n,C),t}),!1},[S,C,n,T,oe]),ue=m(e=>t=>{const n=t.currentTarget.value;q.current=!0,de(e,n);const r="start"===e?0:1,a=L.current[r],o=Et(a),i=xt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});j(t),J(e)}},[de,T,oe,J]),he=m(e=>t=>{var r;if(d)return;if(q.current=!1,Y){const t="start"===e?0:1,r=kt(L.current[t],n,C);return void R(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=Z.current)||void 0===r?void 0:r.contains(a))||ce(e,t.currentTarget.value)},[ce,d,Y,n,C]),ge=m(e=>t=>{"Enter"===t.key&&(t.preventDefault(),q.current=!1,ce(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ce]),me=()=>{K.current=!0,re(S),ae(S),_(!1)},ve=e=>{j(t=>t.add({months:e}).with({day:1}))},fe=e=>{j(t=>t.add({years:e}).with({day:1}))},pe=v(()=>{const e=$,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[$]),ye=m((e=c)=>{if(!f||!Z.current)return e;const t=Z.current.getBoundingClientRect(),n=y?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,i=t.right;let l=e;return l.startsWith("bottom")&&r<500&&a>r?l=l.replace("bottom","top"):l.startsWith("top")&&a<500&&r>a&&(l=l.replace("top","bottom")),l.endsWith("Left")&&o<n&&i>o?l=l.replace("Left","Right"):l.endsWith("Right")&&i<n&&o>i&&(l=l.replace("Right","Left")),l},[f,y,c]),be=m(()=>{const e=ye();B.current!==e&&(B.current=e,U(e))},[ye]),we=e=>{if(d)return;A(e);const t=S["start"===e?0:1].toPlainDate().with({day:1});j(t);const n=ye();B.current!==n&&(B.current=n,U(n)),_(!0)};h(()=>{if(!Y)return;be();const e=()=>be();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[Y,be]);const De=()=>{if(!Z.current)return{};const e=Z.current.getBoundingClientRect(),t={position:"fixed",zIndex:9999};return B.current.startsWith("bottom")?t.top=e.bottom+8:t.bottom=window.innerHeight-e.top+8,c.endsWith("Left")?t.left=e.left:t.right=window.innerWidth-e.right,y&&(t.width=`${e.width}px`),t};return et("div",{className:"relative max-w-100",ref:Z,children:[et("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(d?"cursor-not-allowed border-slate-200 bg-slate-50 text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":Y?"border-primary bg-white shadow-md dark:bg-gray-700":"border-slate-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[et("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:et("input",{type:"text",name:"range-start",value:O[0],onChange:ue("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:he("start"),onKeyDown:ge("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(d?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===H&&Y?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:d})}),et(mr,{className:"text-slate-400 dark:text-gray-500"}),et("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:et("input",{type:"text",name:"range-end",value:O[1],onChange:ue("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:he("end"),onKeyDown:ge("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(d?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===H&&Y?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:d})})]}),Y&&s(et(Ur,{visibleMonth:$,monthLabels:x,weekDayLabels:E,calendarDays:pe,draftRange:S,focusedField:H,isTimeEnabled:!!D,disabled:d,matchTriggerWidth:y,popupRef:V,timeListRefs:G,onMonthChange:ve,onYearChange:fe,onDaySelect:ie,onHourSelect:le,onMinuteSelect:se,onOk:me,getPopupStyle:De}),p?p():document.body)]})},Zr=({options:e,value:t,onChange:n,registry:r,variant:a="desktop",disabled:o=!1})=>{const[i,l]=u(!1),[d,c]=u({}),m=g(null),v=g(null),f=()=>{if(v.current){const e=v.current.getBoundingClientRect(),t="mobile"===a,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`,c(n)}};h(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||l(!1)};return i&&(f(),window.addEventListener("mousedown",e),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[i]);const p=e=>(r||he()).resolveColors(e).lineColor,y=(e,t)=>{e.stopPropagation(),n(t),l(!1)},b=e.find(e=>e.value===t),w=()=>i&&"undefined"!=typeof window?s("mobile"===a?et("div",{"data-calendar-picker-dropdown":"true",style:d,className:_n,children:e.map(e=>et("div",{className:"flex cursor-pointer items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>y(t,e.value),children:[et("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[et("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&et(cr,{className:"h-4 w-4 text-primary"})}),et("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),et("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}):et("ul",{"data-calendar-picker-dropdown":"true",style:d,className:"animate-in fade-in zoom-in-95 origin-top-left overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg transition-all duration-200 dark:border-gray-600 dark:bg-gray-700 dark:shadow-gray-900/50",children:e.map(e=>et("li",{className:"flex cursor-pointer items-center px-2 py-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 "+(t===e.value?"font-semibold":""),onClick:t=>y(t,e.value),children:[t===e.value?et("span",{className:"mr-2 text-sm text-primary",children:et(cr,{width:12,height:12})}):et("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),et("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),et("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return et("div","mobile"===a?{className:"relative inline-block",ref:m,children:[et("button",{type:"button",ref:v,disabled:o,onClick:e=>{e.stopPropagation(),o||l(!i)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(o?"cursor-default opacity-50":""),children:[et("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),et("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==b?void 0:b.label)||t}),et(ur,{className:"h-4 w-4 text-gray-400"})]}),w()]}:{className:"relative inline-block",ref:m,children:[et("button",{ref:v,type:"button",onClick:e=>{e.stopPropagation(),l(!i)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[et("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),et(ur,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),w()]})},Vr=({event:t,isOpen:n,onEventUpdate:r,onEventDelete:a,onClose:o,app:i})=>{var l;const[d,c]=u(t),{t:g}=vn();h(()=>{c(t)},[t]);const m=v(()=>(i?i.getCalendarRegistry():he()).getVisible().map(e=>({label:e.name,value:e.id})),[i,null==i?void 0:i.getCalendars()]),f=v(()=>!Be(t,d),[t,d]),p=v(()=>z(d.start)?d.end&&!z(d.end)&&d.end.timeZoneId||e.Now.timeZoneId():d.start.timeZoneId||e.Now.timeZoneId(),[d.end,d.start]),y=e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t.toPlainDate(),end:n.toPlainDate()}))},b=!(null==i?void 0:i.state.readOnly),w=!1!==(null==i?void 0:i.getReadOnlyConfig().viewable);if(!n||!w)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const D=et("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[et("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&&o()}}),et("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:[et("button",{type:"button",onClick:o,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-200","aria-label":"Close",children:et("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:et("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),et("div",{children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:g("eventTitle")}),et("div",{className:"mb-4 flex items-center justify-between gap-3",children:[et("div",{className:"flex-1",children:et("input",{id:`event-dialog-title-${d.id}`,name:"title",type:"text",value:d.title,readOnly:!b,disabled:!b,onChange:e=>{c(Object.assign(Object.assign({},d),{title:e.target.value}))},className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),b&&et(Zr,{options:m,value:d.calendarId||"blue",onChange:e=>{c(Object.assign(Object.assign({},d),{calendarId:e}))},registry:null==i?void 0:i.getCalendarRegistry()})]}),d.allDay?et("div",{className:"mb-4",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:g("dateRange")}),et(Br,{value:[d.start,d.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!b,onChange:y,onOk:y,locale:null==i?void 0:i.state.locale})]}):et("div",{className:"mb-4",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:g("timeRange")}),et(Br,{value:[d.start,d.end],timeZone:p,disabled:!b,onChange:e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t,end:n}))},onOk:e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t,end:n}))},locale:null==i?void 0:i.state.locale})]}),et("div",{className:"mb-4",children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:g("note")}),et("textarea",{id:`event-dialog-note-${d.id}`,name:"note",value:null!==(l=d.description)&&void 0!==l?l:"",readOnly:!b,disabled:!b,onChange:e=>c(Object.assign(Object.assign({},d),{description:e.target.value})),rows:4,className:"w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:g("addNotePlaceholder")})]}),b&&et("div",{className:"flex space-x-2",children:[d.allDay?et("button",{type:"button",className:"rounded-lg bg-secondary/10 px-3 py-2 text-xs font-medium text-secondary transition hover:bg-secondary/20",onClick:()=>{const t=z(d.start)?d.start:d.start.toPlainDate(),n=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),r=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});c(Object.assign(Object.assign({},d),{allDay:!1,start:n,end:r}))},children:g("setAsTimed")}):et("button",{type:"button",className:"rounded-lg bg-secondary/10 px-3 py-2 text-xs font-medium text-secondary transition hover:bg-secondary/20",onClick:()=>{const e=z(d.start)?d.start:d.start.toPlainDate();c(Object.assign(Object.assign({},d),{allDay:!0,start:e,end:e}))},children:g("setAsAllDay")}),et("button",{type:"button",className:"rounded-lg border border-border bg-destructive px-3 py-2 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>{a(t.id),o()},children:g("delete")}),et("button",{type:"button",className:"ml-auto rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground transition "+(f?"shadow-lg shadow-primary/20 hover:bg-primary/90":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>{r(d),o()},disabled:!f,children:g("save")})]})]})]})]}),x=document.body;return x?s(D,x):null},Gr=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),Kr=({app:e,anchorRef:t,onClose:n,isOpen:r})=>{const{t:a}=vn(),[o,i]=u(""),[l,d]=u(0),[c,m]=u(!1),f=g(null),y=g(null);h(()=>{r||m(!1)},[r]),h(()=>{r&&(setTimeout(()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()},50),i(""),d(0))},[r]),h(()=>{const e=e=>{r&&y.current&&!y.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,n,t]);const[b,w]=u({top:0,left:0}),[D,x]=u("top"),[E,C]=u(0),k=v(()=>{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}},[r]),T=v(()=>{if(!o.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=o.toLowerCase(),i=r.find(e=>e.title.toLowerCase()===a);let l=null==i?void 0:i.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 s=n.find(e=>e.id===l),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:o,calendarId:l||"",color:d,start:k.start,end:k.end});const c=new Set([o.toLowerCase()]);return r.filter(e=>e.title.toLowerCase().includes(a)&&!c.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{c.add(e.title.toLowerCase());const r=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==r?void 0:r.colors.lineColor)||"#9ca3af",start:k.start,end:k.end})}),t},[o,e,k]);p(()=>{if(r&&t.current&&y.current){const e=t.current.getBoundingClientRect(),n=y.current.offsetHeight,r=340;let a=e.left+e.width/2-r/2;const o=12,i=window.innerWidth;a<o?a=o:a+r>i-o&&(a=i-r-o);const l=e.left+e.width/2;C(l-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),x(d),w({top:s,left:a}),m(!0)}},[r,t,T]);const N=t=>{if(!t.calendarId)return;const r=Ge(),a={id:r,title:t.title,start:W(t.start),end:W(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return h(()=>{if(!r)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),d(e=>(e+1)%T.length)):"ArrowUp"===e.key?(e.preventDefault(),d(e=>(e-1+T.length)%T.length)):"Enter"===e.key&&(e.preventDefault(),T[l]&&N(T[l]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,T,l]),r?s(et("div",{ref:y,className:"fixed z-1000 flex w-85 flex-col rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-800 "+(c?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:b.top,left:b.left,visibility:c?"visible":"hidden"},children:[et("div",{className:"p-4 pb-2",children:[et("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:a("quickCreateEvent")||"Quick Create Event"}),et("div",{className:"relative",children:et("input",{ref:f,type:"text",className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:o,onChange:e=>i(e.target.value)})})]}),et("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===T.length&&o&&et("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:a("noSuggestions")||"Type to create"}),T.map((e,t)=>{return et("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===l?"bg-primary/10 ring-1 ring-primary/20 ring-inset dark:bg-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>N(e),onMouseEnter:()=>d(t),children:[et("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),et("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[et("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),et("div",{className:"flex",children:et("span",{className:"rounded bg-gray-100 px-1 text-[10px] font-semibold text-gray-500 dark:bg-slate-700 dark:text-gray-400",children:"new"===e.type?a("today"):a("tomorrow")})}),et("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Gr(n)} - ${Gr(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),et("div",{className:"absolute h-3 w-3 -translate-x-1/2 rotate-45 border-gray-200 bg-white dark:border-slate-700 dark:bg-slate-800 "+("top"===D?"-bottom-1.5 border-r border-b":"-top-1.5 border-t border-l"),style:{left:E}})]}),document.body):null},qr=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:r,onDateSelect:a})=>{const{locale:o}=vn(),i=v(()=>(new Date).toDateString(),[]),l=t.toDateString(),s=v(()=>kr(o,"narrow"),[o]),d=v(()=>e.toLocaleDateString(o,{month:"long",year:"numeric"}),[e,o]),c=v(()=>{const t=e.getFullYear(),n=e.getMonth(),r=(new Date(t,n,1).getDay()+6)%7,a=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-r+1),s=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:s===i,isSelected:s===l})}return a},[e,l,i]);return et("div",{className:"px-3 py-3",children:[n?et("div",{className:"mb-3 flex items-center justify-between",children:[et("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:et(rr,{className:"h-4 w-4"})}),et("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:d}),et("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:et(ar,{className:"h-4 w-4"})})]}):"",et("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[s.map((e,t)=>et("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}`)),c.map(e=>et("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?jn:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""} `,onClick:()=>a(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},Xr=({checked:e,onChange:t,disabled:n})=>et("div",{className:`flex h-7 w-12 items-center rounded-full p-1 transition-colors ${n?"cursor-default opacity-50":"cursor-pointer"} ${e?"bg-green-500":"bg-gray-300"}`,onClick:()=>!n&&t(!e),children:et("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),Jr=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),r=Array.from({length:12},(e,t)=>5*t),a=[...n,...n,...n],o=[...r,...r,...r],i=32,l=e.getHours(),s=5*Math.round(e.getMinutes()/5),d=(24+l)*i,c=(12+s/5)*i,[m,v]=u(d),[f,p]=u(c),y=g(null),b=g(null),w=g(null);h(()=>{y.current&&(y.current.scrollTop=d,v(d)),b.current&&(b.current.scrollTop=c,p(c))},[d,c]);const D=(n,r)=>{const l=n.currentTarget;let s=l.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,l.scrollTop=s):s>1600&&(s-=e,l.scrollTop=s),v(s)}else{const e=384;s<160?(s+=e,l.scrollTop=s):s>800&&(s-=e,l.scrollTop=s),p(s)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{((n,r)=>{const l=Math.round(r/i);if("hour"===n){const n=a[l];if(void 0!==n&&n!==e.getHours()){const r=new Date(e);r.setHours(n),t(r)}}else{const n=o[l];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,s)},150)},x=(e,t)=>{const n=96+e*i+16-(t+112),r=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*r})`,opacity:1-.7*r,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return et("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[et("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),et("div",{ref:y,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>D(e,"hour"),children:[et("div",{style:{height:96}}),a.map((n,r)=>et("div",{className:"flex h-8 cursor-pointer snap-center items-center justify-end pr-5",onClick:()=>{var a;const o=new Date(e);o.setHours(n),t(o),null===(a=y.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:et("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===l?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,m),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),et("div",{style:{height:96}})]}),et("div",{ref:b,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>D(e,"minute"),children:[et("div",{style:{height:96}}),o.map((n,r)=>et("div",{className:"flex h-8 cursor-pointer snap-center items-center justify-start pl-5",onClick:()=>{var a;const o=new Date(e);o.setMinutes(n),t(o),null===(a=b.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:et("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===s?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,f),children:n.toString().padStart(2,"0")})},`m-${r}-${n}`)),et("div",{style:{height:96}})]}),et("div",{className:"pointer-events-none absolute top-24 right-2 left-2 h-8 rounded-lg border border-gray-300 bg-gray-300/20 dark:border-gray-600 dark:bg-gray-500/20"})]})},Qr=({isOpen:e,onClose:t,onSave:n,onEventDelete:r,draftEvent:a,app:o,timeFormat:i="24h"})=>{const{locale:l,t:d}=vn(),c=o.getReadOnlyConfig(),g=!o.state.readOnly,m=!1!==c.viewable,[f,p]=u(""),[y,b]=u(""),[w,D]=u(!1),[x,E]=u(new Date),[C,k]=u(new Date),[T,N]=u(""),[S,M]=u(new Date),[I,H]=u(new Date),[A,O]=u(null),[R,P]=u(e),[L,$]=u(!1),[j,Y]=u(!1);h(()=>{if(!e){$(!0);const e=setTimeout(()=>{P(!1),$(!1)},300);return()=>clearTimeout(e)}P(!0),$(!1)},[e]),h(()=>{if(e&&a){const e=o.getEvents().some(e=>e.id===a.id);Y(e)}},[e,a,o]);const F=o.getCalendars(),z=F.map(e=>({label:e.name,value:e.id}));h(()=>{if(e&&F.length>0){F.some(e=>e.id===y)||"blue"!==y&&""!==y||b(F[0].id)}},[F,e,y]),h(()=>(e?(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=""}),[e]),h(()=>{var t,n;if(e&&a){if(p(a.title||""),b(a.calendarId||(null===(t=F[0])||void 0===t?void 0:t.id)||"blue"),D(a.allDay||!1),a.start)try{const e=B(a.start);E(e),M(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;E(t),M(t)}if(a.end)try{const e=B(a.end);k(e),H(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;k(t),H(t)}}else if(e&&!a){b((null===(n=F[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),E(e),M(e),k(new Date(e.getTime()+36e5)),H(e)}},[e,a]);const _=v(()=>{if(!e||!a)return!1;let t=new Date(x),n=new Date(C);w&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:f,calendarId:y,allDay:w,description:T,start:W(t),end:W(n)});return!Be(a,r)},[e,a,f,y,w,x,C,T]);if(!R||!m)return null;const U=e=>{O(t=>t===e?null:e)},Z=e=>e.toLocaleDateString(l,{day:"numeric",month:"short",year:"numeric"}),V=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(x.getHours(),x.getMinutes());const n=e.getTime()-x.getTime();E(e);const r=new Date(C.getTime()+n);k(r)}else{const e=new Date(t);e.setHours(C.getHours(),C.getMinutes()),k(e)}},G=(e,t)=>{"start"===e?M(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):H(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return s(et("div",{className:"pointer-events-none fixed inset-0 z-10000 flex items-end",children:[et("div",{className:"pointer-events-auto absolute inset-0 bg-black/30 transition-opacity duration-300 "+(L?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),et("div",{className:"pointer-events-auto relative flex h-[85vh] w-full flex-col overflow-hidden rounded-t-2xl bg-gray-100 shadow-xl dark:bg-gray-800 "+(L?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[et("div",{className:"flex items-center justify-between border-b border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900",children:[et("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:d("cancel")}),et("span",{className:"text-lg font-semibold",children:d(!g&&j?"viewEvent":j?"editEvent":"newEvent")}),g&&et("button",{type:"button",onClick:()=>{if(!a)return;let e=new Date(x),t=new Date(C);w&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:f,calendarId:y,allDay:w,start:W(e),end:W(t)});n(r)},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:d(j?"done":"create")}),!g&&et("span",{className:"w-12"})]}),et("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[et("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:et("input",{type:"text",placeholder:d("titlePlaceholder"),value:f,onChange:e=>g&&p(e.currentTarget.value),readOnly:!g,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:g})}),F.length>0&&et("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),et(Zr,{options:z,value:y,onChange:g?b:()=>{},registry:o.getCalendarRegistry(),variant:"mobile",disabled:!g})]}),et("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),et(Xr,{checked:w,onChange:g?D:()=>{},disabled:!g})]}),et("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[et("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),et("div",{className:"flex space-x-2",children:[et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-date"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("start-date"),disabled:!g,children:Z(x)}),!w&&et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("start-time"),disabled:!g,children:be(x.getHours()+x.getMinutes()/60,0,i)})]})]}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===A?"max-h-100":"max-h-0"),children:et("div",{className:"",children:et(qr,{currentDate:x,visibleMonth:S,onDateSelect:e=>V("start",e),onMonthChange:e=>G("start",e),showHeader:!0})})}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===A?"max-h-75":"max-h-0"),children:et("div",{className:"",children:et(Jr,{date:x,onChange:e=>{const t=C.getTime()-x.getTime();E(e),k(new Date(e.getTime()+t))},timeFormat:i})})})]}),et("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[et("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),et("div",{className:"flex space-x-2",children:[et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-date"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("end-date"),disabled:!g,children:Z(C)}),!w&&et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("end-time"),disabled:!g,children:be(C.getHours()+C.getMinutes()/60,0,i)})]})]}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===A?"max-h-100":"max-h-0"),children:et("div",{className:"",children:et(qr,{currentDate:C,visibleMonth:I,onDateSelect:e=>V("end",e),onMonthChange:e=>G("end",e),showHeader:!0})})}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===A?"max-h-75":"max-h-0"),children:et("div",{className:"",children:et(Jr,{date:C,onChange:e=>{if(e<x){const t=C.getTime()-x.getTime();k(e),E(new Date(e.getTime()-t))}else k(e)},timeFormat:i})})})]}),et("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:et("textarea",{placeholder:d("notesPlaceholder"),value:T,onChange:e=>g&&N(e.currentTarget.value),readOnly:!g,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),g&&j&&r&&a&&et("button",{type:"button",onClick:()=>r(a.id),className:"w-full rounded-lg bg-white px-4 py-3 text-left font-medium text-red-500 dark:bg-gray-900",children:d("delete")})]})]})]}),document.body)},ea=()=>et("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:et("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ta=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:a})=>{const{t:o,locale:i}=vn(),l=v(()=>Bt(new Date),[]),s=v(()=>Vt(t,l),[t,l]),d=e=>Ut(e);return e?et("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[et(vr,{className:"mb-2 h-8 w-8 animate-spin"}),et("span",{children:"Loading..."})]}):0===t.length?n?et("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[et(ea,{}),et("span",{className:"mt-2 text-sm",children:"string"==typeof a?a:a&&"object"==typeof a?a[i]||a.en||"No results found":o("noResults")||"No results found"})]}):null:et("div",{className:"space-y-6",children:s.map(e=>{const{title:t,colorClass:n}=Zt(e.date,l,i,o);return et("div",{children:[et("h3",{className:`sticky top-0 z-10 mb-4 bg-white px-2 py-1 text-sm font-medium dark:bg-gray-900 ${n} border-b border-gray-200 dark:border-gray-700`,children:t}),et("div",{className:"flex flex-col",children:e.events.map(e=>{const t=d(e.start),n=d(e.end),a={hour:"2-digit",minute:"2-digit"},l=e.allDay?o("allDay")||"All Day":t.toLocaleTimeString(i,a),s=e.allDay?"":n.toLocaleTimeString(i,a);return et("div",{children:[et("div",{className:"group mx-2 mb-1 cursor-pointer rounded-lg p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",onClick:()=>null==r?void 0:r(e),children:et("div",{className:"flex items-stretch gap-3",children:[et("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),et("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[et("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),et("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[et("div",{className:"text-black dark:text-white",children:l}),s&&et("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),et("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},na=({isOpen:e,onClose:t,keyword:n,onSearchChange:r,results:a,loading:o,onResultClick:i,emptyText:l})=>{const d=g(null),{t:c}=vn();return h(()=>(e?(setTimeout(()=>{var e;null===(e=d.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?s(et("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[et("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[et("button",{type:"button",onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:et(xr,{className:"h-6 w-6"})}),et("div",{className:"relative flex-1",children:[et("input",{ref:d,type:"text",placeholder:c("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&r(t)},className:"w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:ring-primary focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&et("button",{type:"button",onClick:()=>{""!==n&&r("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:et(hr,{className:"h-4 w-4"})})]})]}),et("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:et(ta,{loading:o,results:a,keyword:n,onResultClick:e=>{null==i||i(e)},emptyText:l})})]}),document.body):null},ra=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>et("div",{className:"relative hidden h-full flex-col overflow-hidden border-l border-gray-200 bg-white transition-all duration-300 ease-in-out select-none md:flex dark:border-gray-700 dark:bg-gray-900 "+(e?"w-64":"w-0 border-l-0"),children:et("div",{className:"min-w-64 flex-1 overflow-y-auto",children:et(ta,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let aa=null;function oa(e){aa=e}const ia={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function la(e){return aa&&e.hasPlugin("sidebar")?aa(e):ia}const sa=({locale:e,messages:t,children:n})=>vn().isDefault?et(Sr,{locale:e,messages:t,children:n}):n,da=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,meta:r,customMessages:o,search:i,titleBarSlot:l,collapsedSafeAreaLeft:d})=>{const c=f(fn),{tick:p,selectedEventId:b}=function(e){const[t,n]=u(0),[r,a]=u(null);return h(()=>e.subscribe(e=>{n(e=>e+1),a(t=>{var n;const r=null!==(n=e.state.selectedEventId)&&void 0!==n?n:null;return t===r?t:r})}),[e]),{tick:t,selectedEventId:r}}(e),{isMobile:w}=function(){const[e,t]=u(!1);return h(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),D=function(e,t){const[n,r]=u(""),[a,o]=u(!1),[i,l]=u(!1),[s,d]=u(!1),[c,g]=u([]);h(()=>{e.state.highlightedEventId&&e.selectEvent(e.state.highlightedEventId)},[e.state.highlightedEventId,e]),h(()=>{a||null===e.state.highlightedEventId||e.highlightEvent(null)},[a,e]),h(()=>{var r;if(!n.trim())return o(!1),g([]),void(null!==e.state.highlightedEventId&&e.highlightEvent(null));const a=null!==(r=null==t?void 0:t.debounceDelay)&&void 0!==r?r:300,i=setTimeout(()=>y(this,void 0,void 0,function*(){var r;d(!0),o(!0);try{let a=[];if(null==t?void 0:t.customSearch){const r=e.getEvents().map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})});a=t.customSearch({keyword:n,events:r})}else if(null==t?void 0:t.onSearch)a=yield t.onSearch(n);else{const t=n.toLowerCase();a=e.getEvents().filter(e=>e.title.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)).map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})})}g(a),null===(r=null==t?void 0:t.onSearchStateChange)||void 0===r||r.call(t,{keyword:n,loading:!1,results:a})}catch(e){console.error("Search failed",e),g([])}finally{d(!1)}}),a);return()=>clearTimeout(i)},[n,t,e]);const v=m(t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):B(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),i&&l(!1)},[e,i]),f=m(()=>{r(""),l(!0)},[]),p=m(()=>{o(!1),r(""),e.highlightEvent(null)},[e]),b=m(()=>{l(!1),r(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:r,isSearchOpen:a,setIsSearchOpen:o,isMobileSearchOpen:i,setIsMobileSearchOpen:l,searchLoading:s,searchResults:c,handleSearchResultClick:v,handleSearchClick:f,handleSearchClose:p,handleMobileSearchClose:b}}(e,i),x=n||(e.getUseEventDetailDialog()?Vr:void 0),E=function(e,t,n){const[r,a]=u(null);h(()=>{a(null)},[e]);const o=m(()=>{a(null),e.selectEvent(null)},[e]),i=m(t=>e.updateEvent(t.id,t),[e]),l=m(t=>{e.deleteEvent(t),a(null),e.selectEvent(null)},[e]),s=v(()=>{if(!t||!r)return null;const n=r.split("::")[0],a=e.getEvents().find(e=>e.id===n);return a?{event:a,isOpen:!0,isAllDay:z(a.start),onEventUpdate:i,onEventDelete:l,onClose:o,app:e}:null},[n,r,t,o,i,l,e]);return{detailPanelEventId:r,setDetailPanelEventId:a,dialogProps:s}}(e,x,p),C=la(e),k=function(e,t,n){const[r,a]=u(!1),o=g(null),[i,l]=u(!1),[s,d]=u(null),[c,h]=u(!1),v=m(()=>{h(!0)},[]),f=m(i=>{var s,c;if(!e.state.readOnly){if(t){const t=new Date;t.setMinutes(0,0,0),t.setHours(t.getHours()+1);const n=new Date(t);n.setHours(n.getHours()+1);const r={id:Ge(),title:"",start:W(t),end:W(n),calendarId:(null===(s=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===s?void 0:s.id)||(null===(c=e.getCalendars()[0])||void 0===c?void 0:c.id)};return d(r),void l(!0)}n?r?a(!1):(o.current=i.currentTarget,a(!0)):v()}},[t,r,e,n,v]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:a,quickCreateAnchorRef:o,isMobileDrawerOpen:i,setIsMobileDrawerOpen:l,mobileDraftEvent:s,setMobileDraftEvent:d,handleAddButtonClick:f,isCreateCalendarOpen:c,setIsCreateCalendarOpen:h}}(e,w,C.enabled),[T,N]=u(()=>e.getTheme());h(()=>e.subscribeThemeChange(e=>N(e)),[e]);const S=m(t=>e.setTheme(t),[e]);h(()=>{const t=e.callbacks,n=t.onDismissUI;return t.onDismissUI=()=>{E.detailPanelEventId&&E.setDetailPanelEventId(null),k.isMobileDrawerOpen&&k.setIsMobileDrawerOpen(!1),null==n||n()},()=>{t.onDismissUI=n}},[e,E,k]),h(()=>{if(!w||!E.detailPanelEventId)return;const t=E.detailPanelEventId.split("::")[0],n=e.getEvents().find(e=>e.id===t);n&&(k.setMobileDraftEvent(n),k.setIsMobileDrawerOpen(!0)),E.setDetailPanelEventId(null)},[E.detailPanelEventId,w]);const M=m(t=>{e.setCurrentDate(t),e.selectEvent(null)},[e]),I=m(t=>e.selectEvent(t),[e]),H=g(null),A={app:e,config:e.getCurrentView().config||{},customDetailPanelContent:t,customEventDetailDialog:x,switcherMode:e.state.switcherMode,calendarRef:H,meta:r,selectedEventId:b,onEventSelect:I,onDateChange:M,detailPanelEventId:E.detailPanelEventId,onDetailPanelToggle:E.setDetailPanelEventId},O=v(()=>({isCollapsed:C.isCollapsed,toggleCollapsed:C.toggleCollapsed}),[C.isCollapsed,C.toggleCollapsed]),R=void 0!==d,P=R?"0px":C.miniWidth,L=R&&C.isCollapsed?d:C.safeAreaLeft,$=e.getCalendarHeaderConfig(),j=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:k.handleAddButtonClick,onSearchChange:D.setSearchKeyword,onSearchClick:D.handleSearchClick,searchValue:D.searchKeyword,isSearchOpen:D.isSearchOpen,isEditable:!e.state.readOnly},L>0?{safeAreaLeft:L}:{}),Y=e.getCurrentView().component,F=e.getCustomMobileEventRenderer()||Qr;return et(Ar,{initialTheme:T,onThemeChange:S,children:et(sa,{locale:e.state.locale,messages:o,children:et("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[et(yn,{store:c,generatorName:"titleBarSlot",generatorArgs:O,defaultContent:l&&("function"==typeof l?l(O):l)}),C.enabled&&et("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:C.width},children:C.content}),et("div",{className:"relative z-10 flex h-full flex-1 flex-col overflow-hidden border-l bg-white transition-all duration-250 ease-in-out dark:bg-gray-900 "+(C.isCollapsed?"border-gray-200 shadow-xl dark:border-gray-700":"border-transparent"),style:{marginLeft:C.enabled?C.isCollapsed?P:C.width:0},children:[!1===$?null:"function"==typeof $?$(j):a(Ir,j),et("div",{className:"relative flex-1 overflow-hidden",ref:H,children:[et("div",{className:"calendar-renderer relative flex h-full flex-row",children:[et("div",{className:"h-full flex-1 overflow-hidden",children:et(Y,Object.assign({},A))}),et(ra,{isOpen:D.isSearchOpen,onClose:D.handleSearchClose,loading:D.searchLoading,results:D.searchResults,keyword:D.searchKeyword,onResultClick:D.handleSearchResultClick,emptyText:null==i?void 0:i.emptyText})]}),et(na,{isOpen:D.isMobileSearchOpen,onClose:D.handleMobileSearchClose,keyword:D.searchKeyword,onSearchChange:D.setSearchKeyword,results:D.searchResults,loading:D.searchLoading,onResultClick:D.handleSearchResultClick,emptyText:null==i?void 0:i.emptyText})]})]}),et(Kr,{app:e,anchorRef:k.quickCreateAnchorRef,isOpen:k.isQuickCreateOpen,onClose:()=>k.setIsQuickCreateOpen(!1)}),et(F,{isOpen:k.isMobileDrawerOpen,onClose:()=>{k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onSave:t=>{e.getEvents().some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onEventDelete:t=>{e.deleteEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},draftEvent:k.mobileDraftEvent,app:e}),C.extraContent,k.isCreateCalendarOpen&&et($r,{onClose:()=>k.setIsCreateCalendarOpen(!1),onCreate:t=>{e.createCalendar(t),k.setIsCreateCalendarOpen(!1)}}),(()=>{if(!E.dialogProps)return null;const e=x,t="undefined"==typeof document?null:document.body;if(!t)return null;const n=null==c?void 0:c.isOverridden("eventDetailDialog");return et(yn,{store:c,generatorName:"eventDetailDialog",generatorArgs:E.dialogProps,defaultContent:n?null:s(a(e,E.dialogProps),t)})})()]})})})};class ca{constructor(e){this.renderings=new Map,this.overrides=new Set,this.listeners=new Set,e&&e.length>0&&(this.overrides=new Set(e))}register(e){this.renderings.set(e.id,e),this.notify()}unregister(e){this.renderings.delete(e)&&this.notify()}setOverrides(e){this.overrides=new Set(e),this.notify()}isOverridden(e){return this.overrides.has(e)}subscribe(e){return this.listeners.add(e),e(this.renderings),()=>{this.listeners.delete(e)}}notify(){this.listeners.forEach(e=>e(this.renderings))}}class ua{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new ca(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){Ke(this.extraProps,e)||(this.extraProps=e,this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.requestRender()}unmount(){this.container&&(o(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&o(a(fn.Provider,{value:this.customRenderingStore},a(da,Object.assign({app:this.app},this.extraProps))),this.container)}}const ha=d(({x:e,y:t,onClose:n,children:r,className:a},o)=>{const i=g(null);h(()=>{const e=()=>n(),t=e=>{if(i.current&&!i.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;n()}};window.dispatchEvent(new CustomEvent("dayflow-close-all-menus")),window.addEventListener("dayflow-close-all-menus",e),document.body.addEventListener("mousedown",t,{capture:!0}),document.body.addEventListener("contextmenu",t,{capture:!0});const r=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",r);const a=()=>n();return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",r),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n]);return s(et("div",{ref:e=>{i.current=e,"function"==typeof o?o(e):o&&"current"in o&&(o.current=e)},className:`animate-in fade-in-0 zoom-in-95 fixed z-50 min-w-32 overflow-visible rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md duration-100 ease-out dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 ${a||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:r}),document.body)});ha.displayName="ContextMenu";const ga=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>et("div",{className:`group relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] transition-colors outline-none select-none ${a?"pointer-events-none opacity-50":"hover:bg-primary hover:text-white focus:bg-primary focus:text-white dark:hover:bg-primary dark:hover:text-white dark:focus:bg-primary dark:focus:text-white"} ${r?"text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground":"text-slate-900 dark:text-slate-50"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&et("span",{className:"mr-2 h-4 w-4",children:n}),t]}),ma=()=>et("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),va=({children:e})=>et("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),fa=({children:e})=>{const[t,n]=u(!1),r=g(null);return h(()=>()=>{r.current&&clearTimeout(r.current)},[]),et("div",{className:"relative",onMouseEnter:()=>{r.current&&(clearTimeout(r.current),r.current=null),n(!0)},onMouseLeave:()=>{r.current=setTimeout(()=>{n(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>i(e)?l(e,{isOpen:t}):e)})},pa=({children:e,icon:t,isOpen:n})=>et("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] transition-colors outline-none select-none hover:bg-primary hover:text-white focus:bg-primary focus:text-white dark:hover:bg-primary dark:hover:text-white dark:focus:bg-primary dark:focus:text-white "+(n?"bg-primary text-white":""),children:[t&&et("span",{className:"mr-2 h-4 w-4",children:t}),et("span",{className:"grow text-left",children:e}),et(ar,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),ya=({children:e,isOpen:t})=>{const n=g(null),[r,a]=u("right");return h(()=>{var e;if(t&&n.current){const t=n.current.getBoundingClientRect(),r=null===(e=n.current.parentElement)||void 0===e?void 0:e.getBoundingClientRect();r&&(r.right+t.width>window.innerWidth?a("left"):a("right"))}},[t]),t?et("div",{ref:n,className:"animate-in fade-in-0 zoom-in-95 absolute top-0 z-50 min-w-32 overflow-hidden rounded-md border border-slate-200 bg-white p-1 whitespace-nowrap text-slate-950 shadow-md duration-100 ease-out dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",style:{left:"right"===r?"100%":"auto",right:"left"===r?"100%":"auto",marginLeft:"right"===r?"0.25rem":0,marginRight:"left"===r?"0.25rem":0},"data-submenu-content":"true",children:e}):null},ba=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],wa=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=vn();return et("div",{children:[et("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:ba.map(n=>et("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-primary focus:ring-offset-1 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-primary ring-offset-1 dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&et("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-slate-700 transition-colors hover:bg-primary hover:text-white dark:text-slate-200 dark:hover:bg-primary dark:hover:text-white",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},Da=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:i,viewType:l})=>{const{t:s}=vn(),d=Gt.hasEvent();return et(ha,{x:t,y:n,onClose:a,className:"df-context-menu",children:[et(ga,{onClick:()=>{i(),a()},children:s("newEvent")||"New Event"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){yield((t,n,r)=>y(void 0,void 0,void 0,function*(){if(Gt.hasEvent())try{let a=Gt.getEvent();if(!a){const e=yield navigator.clipboard.readText();e&&(a=JSON.parse(e))}if(a&&"object"==typeof a&&"title"in a){const o=a,i=lt(o.start),l=lt(o.end).getTime()-i.getTime(),s=a,d=new Date(n),c=r===I.MONTH||r===I.YEAR,u=0===d.getHours()&&0===d.getMinutes(),h=0!==i.getHours()||0!==i.getMinutes();!o.allDay&&(c||u&&h)&&d.setHours(i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds());const g=new Date(d.getTime()+(l>0?l:36e5)),m=Object.assign(Object.assign({},s),{title:o.title,id:Ge(),start:o.allDay?st(d):ct(d,e.Now.timeZoneId()),end:o.allDay?st(g):ct(g,e.Now.timeZoneId()),calendarId:o.calendarId&&t.getCalendarRegistry().has(o.calendarId)?o.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(m)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,l),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},xa=({event:e,x:t,y:n,onClose:a,app:o})=>{var i;const{t:l}=vn(),s=o.getCalendars(),d=o.callbacks,c=null===(i=null==d?void 0:d.renderEventContextMenu)||void 0===i?void 0:i.call(d,e,a);return et(ha,{x:t,y:n,onClose:a,children:[et(fa,{children:[et(pa,{children:l("calendars")||"Calendars"}),et(ya,{children:s.map(t=>{const n=t.id===e.calendarId;return et(ga,{onClick:()=>{return n=t.id,o.updateEvent(e.id,{calendarId:n}),void a();var n},children:et("div",{className:"flex w-full items-center",children:[et("div",{className:"w-4 shrink-0",children:n&&et(cr,{className:"h-3 w-3 text-primary"})}),et("div",{className:"flex min-w-0 items-center gap-1.5",children:[et("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:t.colors.lineColor}}),et("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),et(ma,{}),et(ga,{onClick:()=>{o.deleteEvent(e.id),a()},danger:!0,children:l("delete")||"Delete"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e),o.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:l("cut")||"Cut"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e)}catch(e){console.error("Failed to copy event: ",e)}a()}),children:l("copy")||"Copy"}),c&&et(r,{children:[et(ma,{}),c]})]})},Ea=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("假期")?et(fr,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?et(pr,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?et(br,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?et(yr,{className:"h-3 w-3"}):et(gr,{className:"h-3 w-3"})},Ca=(e,t,n=7)=>{const r=[],a=new Date(t);return a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999),e.forEach(e=>{const o=B(e.start),i=B(e.end),l=new Date(o);l.setHours(0,0,0,0);const s=new Date(i);s.setHours(0,0,0,0);let d=new Date(s);if(!e.allDay){if(!(0!==i.getHours()||0!==i.getMinutes()||0!==i.getSeconds())){const e=i.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}}const c=J(l,d)>0;if(!c&&e.allDay){if(l<t||l>a)return;const o=Math.floor((l.getTime()-t.getTime())/864e5);return void(o>=0&&o<=n-1&&r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:o,endDayIndex:o,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!c)return;const u=l;let h;if(e.allDay)h=new Date(s),h.setHours(23,59,59,999);else{0!==i.getHours()||0!==i.getMinutes()||0!==i.getSeconds()?(h=new Date(s),h.setHours(23,59,59,999)):(h=new Date(s),h.setTime(h.getTime()-1))}if(h<t||u>a)return;const g=u<t?t:u,m=h>a?a:h,v=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),f=Math.min(n-1,Math.floor((m.getTime()-t.getTime())/864e5)),p=u>=t,y=h<=a,b=0===v||f===n-1;let w;w=p&&y?"single":p?b&&f===n-1?"start-week-end":"start":y?b&&0===v?"end-week-start":"end":"middle";const D=J(u,h)+1;r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:v,endDayIndex:f,segmentType:w,totalDays:D,segmentIndex:0,isFirstSegment:p,isLastSegment:y})}),r},ka=(e,t,n=7)=>{if(e.allDay)return[];const r=B(e.start),a=B(e.end),o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);const l=J(o,i);if(0===l)return[];const s=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),d=a.getTime()-r.getTime();if(!e.allDay&&1===l&&!s&&d<864e5)return[];const c=s?l:Math.max(0,l-1),u=[];for(let e=0;e<=c;e++){const i=new Date(o);i.setDate(o.getDate()+e);const l=Math.floor((i.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const d=0===e,h=e===c,g=d?r.getHours()+r.getMinutes()/60:0,m=h&&s?a.getHours()+a.getMinutes()/60:24;u.push({dayIndex:l,startHour:g,endHour:m,isFirst:d,isLast:h})}return u},Ta=c(({segment:e,segmentIndex:t,isDragging:n,isResizing:a=!1,isSelected:o=!1,onMoveStart:i,onResizeStart:l,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:h=!0,viewable:m=!0,isPopping:v})=>{const[f,p]=u(!1),y=17*t,b=`calc(${e.startDayIndex/7*100}% + 2px)`,w=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,D=g(null),x=g(null),E=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&l&&h?et("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 z-20 w-1 cursor-ew-resize opacity-0 transition-opacity group-hover:opacity-100`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},C=e.event.calendarId||"blue",k=e.endDayIndex-e.startDayIndex+1;return et("div",{className:"group absolute flex items-center px-1 text-xs transition-all duration-200 select-none hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20",style:Object.assign(Object.assign({left:b,width:w,top:`${y}px`,height:"16px",borderRadius:(T=e.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"}[T]),pointerEvents:"auto",zIndex:10,transform:v?"scale(1.02)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},o||n||f?{backgroundColor:fe(C),color:"#fff"}:{backgroundColor:me(C),color:ve(C)}),{cursor:c||m?"pointer":"default"}),"data-segment-days":k,onMouseDown:t=>{if(!c&&!m)return;t.preventDefault(),t.stopPropagation(),p(!0);!t.target.closest(".resize-handle")&&c&&(null==i||i(t,e.event))},onMouseUp:()=>{p(!1)},onMouseLeave:()=>{p(!1)},onTouchStart:t=>{if(!i||!d||!c&&!m)return;t.stopPropagation(),p(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;x.current={x:r,y:a},D.current=setTimeout(()=>{s&&s(e.event.id);c&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),D.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(D.current&&x.current){const t=Math.abs(e.touches[0].clientX-x.current.x),n=Math.abs(e.touches[0].clientY-x.current.y);(t>10||n>10)&&(clearTimeout(D.current),D.current=null,x.current=null,p(!1))}},onTouchEnd:()=>{p(!1),D.current&&(clearTimeout(D.current),D.current=null),x.current=null},title:`${e.event.title} (${tt(e.event.start)} - ${tt(e.event.end)})`,children:[d&&o&&h&&et(r,{children:[e.isFirstSegment&&et("div",{className:"pointer-events-auto absolute top-1/2 left-5 z-50 h-2.5 w-2.5 -translate-y-1/2 rounded-full border-2 bg-white",style:{borderColor:pe(C)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"left")}}),e.isLastSegment&&et("div",{className:"pointer-events-auto absolute top-1/2 right-5 z-50 h-2.5 w-2.5 -translate-y-1/2 rounded-full border-2 bg-white",style:{borderColor:pe(C)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"right")}})]}),E("left"),et("div",{className:"min-w-0 flex-1",style:{cursor:a?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",r=ne(e.event.start),a=we(e.event),o=be(r),i=be(a);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return et("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&Ea(e.event)&&et("div",{className:"mr-1 shrink-0",children:et("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:pe(n),width:"12px",height:"12px"},children:Ea(e.event)})}),et("div",{className:"min-w-0 flex-1",children:et("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&et("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:et("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?e.event.title:"···",s=e.endDayIndex-e.startDayIndex+1,c=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return et("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[et("div",{className:Pn,style:{backgroundColor:pe(n)}}),et("div",{className:"flex min-w-0 flex-1 items-center",children:et("span",{className:`block overflow-hidden whitespace-nowrap ${d?"mobile-mask-fade":"truncate"} text-xs font-medium`,children:l})}),e.isFirstSegment&&!d&&et("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:c,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!d&&et("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})})()}),E("right")]});var T});Ta.displayName="MultiDayEvent";const Na=({event:e,isEditable:t,onResizeStart:n,isMultiDay:r,segment:a,isSlidingView:o})=>{const i=!1!==e.icon,l="boolean"==typeof e.icon?null:e.icon;return et("div",{className:"flex h-full items-center overflow-hidden pl-3 px-1 group relative py-0",style:(()=>{if(!o||!r||!a)return{};if(a.startDayIndex<2&&a.endDayIndex>=2){return{paddingLeft:`calc(${(2-a.startDayIndex)/(a.endDayIndex-a.startDayIndex+1)*100}% + 0.75rem)`}}return{}})(),children:[n&&t&&et("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()}}),i&&(l?et("div",{className:"mr-1 shrink-0",children:l}):et(gr,{className:Ln})),et("div",{className:`${Rn} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&et("div",{className:$n,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Sa=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return et("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?et("div",{className:`${tr} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?et("span",{className:`inline-block ${tr} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):et(gr,{className:`${Ln} ${t?"text-white":""}`})),et("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Ma=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(ne(e.start)).toString().padStart(2,"0")}:${Math.round(ne(e.start)%1*60).toString().padStart(2,"0")}`;return et("div",{className:"text-xs cursor-pointer flex items-center justify-between",children:[et("div",{className:"flex min-w-0 flex-1 items-center",children:[et("div",{style:{backgroundColor:pe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Pn}),et("span",{className:`block overflow-hidden whitespace-nowrap ${a?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&et("span",{className:`${Jn} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Ia=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:i,onResizeStart:l,timeFormat:s="24h"})=>{const d=n?n.startHour:ne(e.start),c=n?n.endHour:we(e),u=c-d,h=!n||n.isFirst,g=!n||n.isLast,m=e.calendarId||"blue";return et(r,{children:[et("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:pe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),et("div",{className:"flex h-full flex-col overflow-hidden pl-3 "+(we(e)-ne(e.start)<=.25?"px-1 py-0":"p-1"),children:[et("div",{className:`${Rn} pr-1`,style:{lineHeight:u<=.25?"1.2":"normal"},children:e.title}),u>.5&&et("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${be(d,0,s)} - ${be(c,0,s)}`:De(e,s)})]}),l&&a&&et(r,{children:[h&&et("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")}),g&&et("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")}),!h&&g&&n&&et("div",{className:$n,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&i&&l&&a&&et(r,{children:[et("div",{className:"absolute -top-1.5 right-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:pe(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),et("div",{className:"absolute -bottom-1.5 left-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:pe(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},Ha=({event:e,segment:t,isEditable:n,onMoveStart:a,onResizeStart:o})=>{const i=!!e.allDay,l=e.calendarId||"blue",s=pe(l),d=i?Ea(e):null,{isFirstSegment:c,isLastSegment:u}=t,h=t=>{const r="left"===t,a=r?c:u;return e.allDay&&a&&o&&n?et("div",{className:`resize-handle absolute ${r?"left-0":"right-0"} top-0 bottom-0 z-20 w-1 cursor-ew-resize opacity-0 transition-opacity group-hover:opacity-100`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),o(t,e,r?"left":"right")},onTouchStart:t=>{t.stopPropagation(),o(t,e,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null};return et(r,{children:[h("left"),(()=>{if(i){const n=()=>t.isFirstSegment?e.title:"···";return et("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full min-w-0 items-center",onMouseDown:t=>{a&&(t.stopPropagation(),a(t,e))},children:[t.isFirstSegment&&Ea(e)&&et("div",{className:"df-year-event-icon mr-1 shrink-0",children:et("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:pe(l),width:"12px",height:"12px"},children:Ea(e)})}),et("div",{className:"min-w-0 flex-1",children:et("div",{className:"df-year-event-title overflow-hidden text-[12px] leading-none whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:n()})}),t.isLastSegment&&!t.isFirstSegment&&et("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:et("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const n=t.isFirstSegment?e.title:"";return et("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full items-center gap-1 overflow-hidden",onMouseDown:t=>{a&&(t.stopPropagation(),a(t,e))},children:[!i&&et("span",{style:{backgroundColor:s},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),i&&d&&et("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:d}),et("span",{className:"df-year-event-title block w-full overflow-hidden text-[12px] leading-none font-medium whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:n})]})})(),h("right")]})},Aa=({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,segmentIndex:o,isBeingDragged:i,isBeingResized:l,isEventSelected:s,isPopping:d,isEditable:c,isDraggable:u,canOpenDetail:h,isTouchEnabled:g,hideTime:m,isMobile:v,isSlidingView:f,app:p,onMoveStart:y,onResizeStart:b,multiDaySegmentInfo:w,customRenderingStore:D,eventContentSlotArgs:x,timeFormat:E="24h"})=>{const C=t===I.MONTH;let k;return k=t===I.YEAR&&a?et(Ha,{event:e,segment:a,isEditable:c,onMoveStart:y,onResizeStart:b}):C?n&&r?et(Ta,{segment:r,segmentIndex:null!=o?o:0,isDragging:i||s,isResizing:l,isSelected:s,onMoveStart:y,onResizeStart:b,isMobile:v,isDraggable:u,isEditable:c,viewable:h,isPopping:d}):e.allDay?et(Sa,{event:e,isEventSelected:s}):et(Ma,{event:e,app:p,isEventSelected:s,hideTime:m,isMobile:v}):e.allDay?et(Na,{event:e,isEditable:c,onResizeStart:b,isMultiDay:n,segment:r,isSlidingView:f}):et(Ia,{event:e,app:p,multiDaySegmentInfo:w,isEditable:c,isTouchEnabled:g,isEventSelected:s,onResizeStart:b,timeFormat:E}),et(yn,{store:D,generatorName:"eventContent",generatorArgs:x,defaultContent:k})},Oa=({event:t,position:n,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:i,selectedEventElementRef:l,onEventUpdate:d,onEventDelete:c,app:g})=>{var m;const{effectiveTheme:f}=Or(),p=Ot(f),{t:y}=vn(),[b,w]=u(t.title),[D,x]=u(null!==(m=t.description)&&void 0!==m?m:"");h(()=>{w(t.title)},[t.title]),h(()=>{var e;x(null!==(e=t.description)&&void 0!==e?e:"")},[t.description]),h(()=>{const e=setTimeout(()=>{b!==t.title&&d(Object.assign(Object.assign({},t),{title:b}))},500);return()=>clearTimeout(e)},[b,t]),h(()=>{const e=setTimeout(()=>{var e;const n=null!==(e=t.description)&&void 0!==e?e:"";D!==n&&d(Object.assign(Object.assign({},t),{description:D}))},500);return()=>clearTimeout(e)},[D,t]);const E=v(()=>z(t.start)?t.end&&!z(t.end)&&t.end.timeZoneId||e.Now.timeZoneId():t.start.timeZoneId||e.Now.timeZoneId(),[t.end,t.start]),C=v(()=>(g?g.getCalendarRegistry():he()).getVisible().map(e=>({label:e.name,value:e.id})),[g,null==g?void 0:g.getCalendars()]),k="dark"===p||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),T=!(null==g?void 0:g.state.readOnly);if(!(!1!==(null==g?void 0:g.getReadOnlyConfig().viewable)))return null;const N=k?"#1f2937":"white",S=k?"rgb(55, 65, 81)":"rgb(229, 231, 235)",M=(()=>{var e;let t={};if("sticky-top"===o){const r=null===(e=i.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(r){const e=r.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=r.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)}}else if(n&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-n.top,u=r.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,m=Math.max(g,Math.min(h,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),I=et("div",{ref:r,className:`${zn} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[et("div",{style:M}),et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:y("eventTitle")}),et("div",{className:"mb-3 flex items-center justify-between gap-3",children:[et("div",{className:"flex-1",children:et("input",{id:`event-title-${t.id}`,name:"title",type:"text",value:b,readOnly:!T,disabled:!T,onChange:e=>w(e.target.value),onInput:e=>w(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),T&&et(Zr,{options:C,value:t.calendarId||"blue",onChange:e=>{d(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==g?void 0:g.getCalendarRegistry()})]}),et("div",a?{className:"mb-3",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:y("dateRange")}),et(Br,{value:[t.start,t.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!T,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n.toPlainDate(),end:r.toPlainDate()}))},locale:null==g?void 0:g.state.locale})]}:{className:"mb-3",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:y("timeRange")}),et(Br,{value:[t.start,t.end],timeZone:E,disabled:!T,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n,end:r}))},locale:null==g?void 0:g.state.locale})]}),et("div",{className:"mb-3",children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:y("note")}),et("textarea",{id:`event-note-${t.id}`,name:"note",value:D,readOnly:!T,disabled:!T,onChange:e=>x(e.target.value),onInput:e=>x(e.target.value),rows:3,className:"w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:y("addNotePlaceholder")})]}),T&&et("div",{className:"flex space-x-2",children:[et("button",a?{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const n=z(t.start)?t.start:t.start.toPlainDate(),r=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),a=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});d(Object.assign(Object.assign({},t),{allDay:!1,start:r,end:a}))},children:y("setAsTimed")}:{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const e=z(t.start)?t.start:t.start.toPlainDate();d(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:e}))},children:y("setAsAllDay")}),et("button",{type:"button",className:"rounded bg-destructive px-2 py-1 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>c(t.id),children:y("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const H=document.body;return H?s(I,H):null},Ra=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:a,calendarRef:o,selectedEventElementRef:i,onEventUpdate:l,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=Or(),g=Ot(h),m="dark"===g?"#1f2937":"white",v="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let r={};if("sticky-top"===a){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;r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===a){const e=n.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}r={position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)}}else if(t&&i.current&&o.current){const e=i.current.getBoundingClientRect(),a=o.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,f=Math.max(g,Math.min(h,c));r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),p=et("div",{ref:n,className:`${zn} p-3`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===g?"#1f2937":"#ffffff"},children:[et("div",{style:f}),et(u,{event:e,isAllDay:r,onEventUpdate:l,onEventDelete:d,onClose:c})]});return s(p,document.body)},Pa=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,handlePanelClose:u,customRenderingStore:h,contentSlotRenderer:g,customDetailPanelContent:m,app:v})=>{if(!e)return null;if(t)return null;if(!n)return null;const f={event:r,position:n,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?et(Ra,Object.assign({},f,{contentRenderer:g})):m?et(Ra,Object.assign({},f,{contentRenderer:m})):et(Oa,Object.assign({},f,{app:v}))},La=(e,t)=>{if(!e.current)return t?48:80;const n=e.current.querySelector(".df-time-column");return n?n.getBoundingClientRect().width:t?48:80},$a=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto px-0.5";const i=e===I.DAY,l=e===I.MONTH,s=e===I.YEAR;i?o+=" df-day-event flex flex-col":l||s?s&&(o+=" df-year-event transition-colors group px-1 overflow-hidden whitespace-nowrap cursor-pointer"):o+=" df-week-event flex flex-col";const d=()=>{if(n&&r){const{segmentType:e}=r;if("single"===e||"start"===e)return An;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 An};if(s)return`${o} ${(()=>{if(a){const{isFirstSegment:e,isLastSegment:t}=a;return e&&t?"rounded":e?"rounded-l rounded-r-none":t?"rounded-r rounded-l-none":"rounded-none"}return"rounded"})()}`;if(l){let e=`\n ${o}\n ${t?d():On}\n `;return n||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${t?d():On}\n `},ja=({event:e,layout:t,isAllDay:n=!1,allDayHeight:a=28,calendarRef:o,isBeingDragged:i=!1,isBeingResized:l=!1,viewType:s,isMultiDay:d=!1,segment:c,yearSegment:p,columnsPerRow:y,segmentIndex:b=0,hourHeight:w,firstHour:D,selectedEventId:x,detailPanelEventId:E,onMoveStart:C,onResizeStart:k,onEventUpdate:T,onEventDelete:N,newlyCreatedEventId:S,onDetailPanelOpen:M,onEventSelect:H,onEventLongPress:A,onDetailPanelToggle:O,customDetailPanelContent:R,customEventDetailDialog:P,multiDaySegmentInfo:L,app:$,isMobile:j=!1,isSlidingView:Y=!1,enableTouch:F,hideTime:z,timeFormat:_="24h"})=>{const W=f(fn),U=null!=F?F:j,B=s===I.YEAR,[Z,V]=u(null),[G,K]=u(!1),q=g(null),X=g(null),J=g(null),Q=g(null),ee=d&&c?`${e.id}::${c.id}`:void 0===(null==L?void 0:L.dayIndex)?B&&p?p.id:e.id:`${e.id}::day-${L.dayIndex}`,te=E===ee,re=te&&!P,ae=null==$?void 0:$.getReadOnlyConfig(),oe=!(null==$?void 0:$.state.readOnly),ie=!1!==(null==ae?void 0:ae.viewable),le=!1!==(null==ae?void 0:ae.draggable),{isSelected:se,setIsSelected:de,isPressed:ce,setIsPressed:ue,handleTouchStart:he,handleTouchMove:ge,handleTouchEnd:pe}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:a,canOpenDetail:o,app:i,multiDaySegmentInfo:l,isMultiDay:s,segment:d,detailPanelKey:c})=>{const[h,m]=u(!1),[v,f]=u(!1),p=g(null),y=g(null);return{isSelected:h,setIsSelected:m,isPressed:v,setIsPressed:f,handleTouchStart:a=>{if(!n||!t)return;f(!0);const o=a.touches[0],i=o.clientX,c=o.clientY,u=a.currentTarget;y.current={x:i,y:c},p.current=setTimeout(()=>{var t;r?r(e.id):m(!0);const a={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:i,clientY:c}],cancelable:!1};if(l){const r=Object.assign(Object.assign({},e),{day:null!==(t=l.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:l});n(a,r)}else if(s&&d){const t=Object.assign(Object.assign({},e),{day:d.startDayIndex,_segmentInfo:{dayIndex:d.startDayIndex,isFirst:d.isFirstSegment,isLast:d.isLastSegment}});n(a,t)}else n(a,e);p.current=null,y.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(p.current&&y.current){const t=Math.abs(e.touches[0].clientX-y.current.x),n=Math.abs(e.touches[0].clientY-y.current.y);(t>10||n>10)&&(clearTimeout(p.current),p.current=null,y.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),p.current&&(clearTimeout(p.current),p.current=null),t&&y.current&&(n.preventDefault(),n.stopPropagation(),i&&i.onEventClick(e),o?null==a||a(c):null==a||a(null)),y.current=null}}})({event:e,isTouchEnabled:U,onMoveStart:C,onEventLongPress:A,onDetailPanelToggle:O,canOpenDetail:ie,app:$,multiDaySegmentInfo:L,isMultiDay:d,segment:c,detailPanelKey:ee}),ye=(void 0===x?se:x===e.id)||!U&&ce||i,[be,De]=u("visible"),xe=e=>{Q.current=e},Ee=m(()=>((e,t,n,r,a,o)=>{var i;if(null!==r)return r;if(t===n){const e=n.split("::").at(-1);if(e&&e.startsWith("day-")){const t=Number(e.replace("day-",""));if(!Number.isNaN(t))return t}}return void 0!==(null==a?void 0:a.dayIndex)?a.dayIndex:o?o.startDayIndex:null!==(i=e.day)&&void 0!==i?i:0})(e,E||void 0,ee,Q.current,L,c),[e,E,ee,L,c]),Ce=m(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===I.MONTH){const t=a.width/7,n=e-a.left,r=Math.floor(n/t);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const o=La(t,r),i=n===I.DAY?1:7,l=(a.width-o)/i,s=e-a.left-o,d=Math.floor(s/l);return Number.isFinite(d)?Math.max(0,Math.min(i-1,d)):null})(e,o,s,j),[o,s,j]),ke=m(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===I.MONTH){const t=a.width/7;return{left:a.left+e*t,width:t}}const o=La(t,r);if(n===I.DAY){const e=a.width-o;return{left:a.left+o,width:e}}const i=(a.width-o)/7;return{left:a.left+o+e*i,width:i}})(e,o,s,j),[o,s,j]),{detailPanelPosition:Te,setDetailPanelPosition:Ne,updatePanelPosition:Se}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,multiDaySegmentInfo:o,calendarRef:i,eventRef:l,detailPanelRef:s,selectedEventElementRef:d,isMobile:c,eventVisibility:g,firstHour:v,hourHeight:f,columnsPerRow:p,showDetailPanel:y,detailPanelEventId:b,detailPanelKey:w,getActiveDayIdx:D,getDayMetricsWrapper:x})=>{const[E,C]=u(null),k=t===I.DAY,T=t===I.MONTH,N=t===I.YEAR,S=m(()=>{if(!d.current||!i.current||!s.current)return;const e=i.current.getBoundingClientRect(),t=D(),a=x(t);let o,u;if(a)o=a.left,u=a.width;else if(T)u=e.width/7,o=e.left+t*u;else{const n=La(i,c);u=(e.width-n)/7,o=e.left+n+t*u}const h=Math.min(window.innerWidth,e.right),m=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{var a,i,c;if(!s.current)return;if(!d.current)return;const u=s.current.getBoundingClientRect(),v=u.width,f=u.height;let p,y,b;if("sticky-top"===g||"sticky-bottom"===g){const e=null===(a=l.current)||void 0===a?void 0:a.getBoundingClientRect();if(!e)return;b=e}else b=d.current.getBoundingClientRect();if(T&&n&&r){const n=x(t),r=null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e.width/7,a=null!==(c=null==n?void 0:n.left)&&void 0!==c?c:e.left+t*r,o=a+r;b={top:b.top,bottom:b.bottom,left:a,right:o,width:o-a,height:b.height,x:a,y:b.top,toJSON:()=>({})}}const w=h-b.right,D=b.left-e.left;p=w>=v+20?b.right+10:D>=v+20?b.left-v-10:w>D?Math.max(e.left+10,h-v-10):e.left+10;const E=b.top-f/2+b.height/2,k=Math.max(10,e.top+10),S=m-10;y=E<k?k:E+f>S?S-f:E,C(e=>{if(!e)return null;let t=p<o;return N&&(t=p<b.left),Object.assign(Object.assign({},e),{top:y,left:p,isSunday:t})})})},[i,e.day,e.start,e.end,g,T,v,f,n,r,o,b,w,c,k,N,a,p,D,x,d,s,l]);return h(()=>{!y||E||c||(C({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>S()))},[y,E,S,c]),{detailPanelPosition:E,setDetailPanelPosition:C,updatePanelPosition:S}})({event:e,viewType:s,isMultiDay:d,segment:c,yearSegment:p,multiDaySegmentInfo:L,calendarRef:o,eventRef:q,detailPanelRef:X,selectedEventElementRef:J,isMobile:j,eventVisibility:be,firstHour:D,hourHeight:w,columnsPerRow:y,showDetailPanel:te,detailPanelEventId:E,detailPanelKey:ee,getActiveDayIdx:Ee,getDayMetricsWrapper:ke}),{handleClick:Me,handleDoubleClick:Ie,handleContextMenu:He}=(({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,multiDaySegmentInfo:o,calendarRef:i,firstHour:l,hourHeight:s,isMobile:d,canOpenDetail:c,detailPanelKey:u,app:h,onEventSelect:g,onDetailPanelToggle:v,setIsSelected:f,setDetailPanelPosition:p,setContextMenuPosition:y,setActiveDayIndex:b,getClickedDayIdx:w,updatePanelPosition:D,selectedEventElementRef:x})=>{const E=t===I.MONTH,C=t===I.YEAR,k=m(()=>new Promise(t=>{if(!i.current||n||E||C)return void t();const r=i.current.querySelector(".calendar-content");if(!r)return void t();const a=o?o.startHour:ne(e.start),d=o?o.endHour:we(e),c=(a-l)*s,u=c+Math.max((d-a)*s,s/4),h=r.scrollTop,g=r.clientHeight;if(c>=h&&u<=h+g)return void t();const m=((a+d)/2-l)*s-g/2,v=r.scrollHeight-g;r.scrollTo({top:Math.max(0,Math.min(v,m)),behavior:"smooth"}),setTimeout(()=>t(),300)}),[i,n,E,C,o,e.start,e.end,l,s]),T=m(t=>{t.preventDefault(),t.stopPropagation(),g&&g(e.id),y({x:t.clientX,y:t.clientY})},[e.id,g,y]),N=m(t=>{var n,o,i,l,s;if(!c)return;t.preventDefault(),t.stopPropagation();let h=t.currentTarget;if(r){const e=h.querySelector("div");e&&(h=e)}if(x.current=h,r){const r=w(t.clientX);b(null===r?null!==(o=null!==(n=null==a?void 0:a.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==o?o:0:Math.min(Math.max(r,null!==(i=null==a?void 0:a.startDayIndex)&&void 0!==i?i:0),null!==(l=null==a?void 0:a.endDayIndex)&&void 0!==l?l:6))}else b(null!==(s=e.day)&&void 0!==s?s:null);k().then(()=>{f(!0),d||(null==v||v(u),p({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>D()))})},[c,r,x,w,b,null==a?void 0:a.startDayIndex,null==a?void 0:a.endDayIndex,e.day,k,f,d,v,u,p,D]);return{handleClick:m(t=>{var n,i,l;if(t.preventDefault(),t.stopPropagation(),r){const r=w(t.clientX);b(null===r?null!==(i=null!==(n=null==o?void 0:o.dayIndex)&&void 0!==n?n:e.day)&&void 0!==i?i:null:a?Math.min(Math.max(r,a.startDayIndex),a.endDayIndex):r)}else b(null!==(l=e.day)&&void 0!==l?l:null);h&&h.onEventClick(e),g?g(e.id):c&&f(!0),null==v||v(null),p(null)},[r,w,b,a,null==o?void 0:o.dayIndex,e,h,g,c,f,v,p]),handleDoubleClick:N,handleContextMenu:T,scrollEventToCenter:k}})({event:e,viewType:s,isAllDay:n,isMultiDay:d,segment:c,multiDaySegmentInfo:L,calendarRef:o,firstHour:D,hourHeight:w,isMobile:j,canOpenDetail:ie,detailPanelKey:ee,app:$,onEventSelect:H,onDetailPanelToggle:O,setIsSelected:de,setDetailPanelPosition:Ne,setContextMenuPosition:V,setActiveDayIndex:xe,getClickedDayIdx:Ce,updatePanelPosition:Se,selectedEventElementRef:J}),{calculateEventStyle:Ae}=(({event:e,layout:t,isAllDay:n,allDayHeight:r,viewType:a,isMultiDay:o,segment:i,yearSegment:l,columnsPerRow:s,segmentIndex:d,hourHeight:c,firstHour:u,isEventSelected:h,showDetailPanel:g,isPopping:m,isDraggable:v,canOpenDetail:f,eventVisibility:p,calendarRef:y,isMobile:b,eventRef:w,getActiveDayIdx:D,getDayMetricsWrapper:x,multiDaySegmentInfo:E})=>{const C=a===I.DAY,k=a===I.MONTH,T=a===I.YEAR;return{calculateEventStyle:()=>{var a,N,S,M,I,H,A,O;if(T&&l&&s){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=l,r=2;return{position:"absolute",left:`calc(${e/s*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/s*100}% - ${2*r}px)`,height:"16px",opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"}}if(k)return o&&i?{opacity:1,zIndex:h||g?1e3:1,cursor:v||f?"pointer":"default"}:{opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"};if(n){const e={height:r-4+"px",opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"},t=d*r;if(Object.assign(e,{top:`${t}px`}),C)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(o&&i){const t=s||7,n=(i.endDayIndex-i.startDayIndex+1)/t*100,r=i.startDayIndex/t*100,a=2,o=i.isFirstSegment?a:0,l=o+(i.isLastSegment?a:0);Object.assign(e,{width:l>0?`calc(${n}% - ${l}px)`:`${n}%`,left:o>0?`calc(${r}% + ${o}px)`:`${r}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const R=E?E.startHour:ne(e.start),P=E?E.endHour:we(e),L={top:(R-u)*c+3+"px",height:Math.max((P-R)*c,c/4)-4+"px",position:"absolute",opacity:1,zIndex:h||g?1e3:null!==(a=null==t?void 0:t.zIndex)&&void 0!==a?a:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"};if(h&&g&&("sticky-top"===p||"sticky-bottom"===p)){const e=null===(N=y.current)||void 0===N?void 0:N.getBoundingClientRect();if(e){const n=D(),r=La(y,b),a=C?1:s||7;let o=(e.width-r)/a,i=e.left+r+(C?0:n*o);k&&(o=e.width/7,i=e.left+n*o);const l=x(n);l&&(i=l.left,o=l.width);let d=null===(S=y.current)||void 0===S?void 0:S.querySelector(".calendar-content");d||(d=null===(M=y.current)||void 0===M?void 0:M.querySelector(".calendar-renderer"));const c=null==d?void 0:d.getBoundingClientRect(),u=null===(H=null===(I=w.current)||void 0===I?void 0:I.parentElement)||void 0===H?void 0:H.getBoundingClientRect();let h,g;if(u&&u.width>0)t?(h=u.left+t.left/100*u.width,g=C?t.width/100*u.width:(t.width-1)/100*u.width):(h=u.left,g=C?u.width:u.width-3);else{const e=x(n),r=null!==(A=null==e?void 0:e.left)&&void 0!==A?A:i,a=null!==(O=null==e?void 0:e.width)&&void 0!==O?O:o;h=r,g=a-3,t&&(h=r+t.left/100*a,g=C?t.width/100*a:(t.width-1)/100*a)}if("sticky-top"===p){let t=c?c.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:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let m=c?c.bottom:e.bottom;return m=Math.min(m,window.innerHeight),m=Math.min(m,e.bottom),m=Math.max(m,e.top+6),m=Math.max(m,6),{position:"fixed",top:m-6+"px",left:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!n){const e=C?`${t.width}%`:t.width-1+"%";return Object.assign(Object.assign({},L),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},L),{left:"0px",right:C?"0px":"3px"})}}})({event:e,layout:t,isAllDay:n,allDayHeight:a,viewType:s,isMultiDay:d,segment:c,yearSegment:p,columnsPerRow:y,segmentIndex:b,hourHeight:w,firstHour:D,isEventSelected:ye,showDetailPanel:te,isPopping:G,isDraggable:le,canOpenDetail:ie,eventVisibility:be,calendarRef:o,isMobile:j,eventRef:q,getActiveDayIdx:Ee,getDayMetricsWrapper:ke,multiDaySegmentInfo:L});(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:r,calendarRef:a,isAllDay:o,viewType:i,multiDaySegmentInfo:l,firstHour:s,hourHeight:d,updatePanelPosition:c,eventVisibility:u,setEventVisibility:g})=>{const v=i===I.MONTH,f=i===I.YEAR,p=m(()=>{if(!t||!n||!r.current||!a.current||o||v||f)return;const i=a.current.querySelector(".calendar-content");if(!i)return;const h=l?l.startHour:ne(e.start),m=l?l.endHour:we(e),p=(h-s)*d,y=p+Math.max((m-h)*d,d/4),b=i.getBoundingClientRect(),w=i.scrollTop,D=w+b.height,x=b.bottom<0,E=b.top>window.innerHeight;let C=u;x?C="sticky-top":E?C="sticky-bottom":"visible"===u?y<w?C="sticky-top":p>D-20&&(C="sticky-bottom"):"sticky-top"===u?y>=w&&(C="visible"):"sticky-bottom"===u&&p<=D-20&&(C="visible"),C!==u&&g(C),c()},[t,n,a,o,v,e.start,e.end,s,d,c,l,u,g]);h(()=>{var e,r;if(!t||!n||o)return;const i=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!i)return;const l=()=>p(),s=()=>{p(),c()},d=[i];let u=null===(r=a.current)||void 0===r?void 0:r.parentElement;for(;u;){const e=window.getComputedStyle(u);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||d.push(u),u=u.parentElement}d.forEach(e=>{e.addEventListener("scroll",l)}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",s);let h=null;return a.current&&(h=new ResizeObserver(()=>{s()}),h.observe(a.current)),p(),()=>{d.forEach(e=>{e.removeEventListener("scroll",l)}),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",s),h&&h.disconnect()}},[t,n,o,p,c,a])})({event:e,isEventSelected:ye,showDetailPanel:te,eventRef:q,calendarRef:o,isAllDay:n,viewType:s,multiDaySegmentInfo:L,firstHour:D,hourHeight:w,updatePanelPosition:Se,eventVisibility:be,setEventVisibility:De});const Oe=te&&!!P;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:a,onEventSelect:o,onDetailPanelToggle:i,setIsSelected:l,setActiveDayIndex:s})=>{h(()=>{if(!r&&!a)return;const d=d=>{var c,u;const h=d.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),v=null===(u=t.current)||void 0===u?void 0:u.contains(h),f=h.closest("[data-event-detail-dialog]"),p=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");a?g||m||v||f||p||y||(null==o||o(null),s(null),l(!1),null==i||i(null)):!r||g||m||f||p||y||(null==o||o(null),s(null),l(!1),null==i||i(null))};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[r,a,o,i,n])})({eventRef:q,detailPanelRef:X,eventId:e.id,isEventSelected:!Oe&&ye,showDetailPanel:re,onEventSelect:H,onDetailPanelToggle:O,setIsSelected:de,setActiveDayIndex:xe});const Re=m(()=>{H&&H(null),Q.current=null,de(!1),null==O||O(null)},[H,O,de]),Pe=v(()=>({event:e,isAllDay:n,onEventUpdate:T,onEventDelete:N,onClose:Re}),[e,n,T,N,Re]),Le=v(()=>({event:e,isAllDay:n,isMobile:j,isMonthView:s===I.MONTH,segment:c,layout:t}),[e,n,j,s,c,t]),$e=m(()=>et(yn,{store:W,generatorName:"eventDetailContent",generatorArgs:Pe}),[W,Pe]);h(()=>{if((null==$?void 0:$.state.highlightedEventId)===e.id){K(!0);const e=setTimeout(()=>{K(!1)},300);return()=>{clearTimeout(e),K(!1)}}},[null==$?void 0:$.state.highlightedEventId,e.id]),h(()=>{const t=d&&(null==c?void 0:c.isFirstSegment)||B&&(null==p?void 0:p.isFirstSegment)||!d&&!B;S===e.id&&!te&&t&&setTimeout(()=>{null==O||O(ee),null==M||M()},50)},[S,e.id,te,d,c,B,p,O,M,ee]);const je=e.calendarId||"blue",Ye=null==$?void 0:$.getCalendarRegistry();return et(r,{children:[et("div",{ref:q,"data-event-id":e.id,className:`${$a(s,n,d,c,p)} ${n&&S===e.id?"df-all-day-event-animate":""}`,style:Object.assign(Object.assign({},Ae()),{backgroundColor:ye?fe(je,Ye):me(je,Ye),color:ye?"#fff":ve(je,Ye)}),onClick:U?void 0:Me,onContextMenu:U?void 0:He,onDblClick:U?void 0:Ie,onMouseDown:t=>{var n;if(U||ue(!0),C){const r=t;C(r,L?Object.assign(Object.assign({},e),{day:null!==(n=L.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:L}):d&&c?Object.assign(Object.assign({},e),{day:c.startDayIndex,_segmentInfo:{dayIndex:c.startDayIndex,isFirst:c.isFirstSegment,isLast:c.isLastSegment}}):e)}},onMouseUp:()=>!U&&ue(!1),onMouseLeave:()=>!U&&ue(!1),onTouchStart:he,onTouchMove:ge,onTouchEnd:pe,children:et(Aa,{event:e,viewType:s,isMultiDay:d,segment:c,yearSegment:p,segmentIndex:b,isBeingDragged:i,isBeingResized:l,isEventSelected:ye,isPopping:G,isEditable:oe,isDraggable:le,canOpenDetail:ie,isTouchEnabled:U,hideTime:z,isMobile:j,isSlidingView:Y,app:$,onMoveStart:C,onResizeStart:k,multiDaySegmentInfo:L,customRenderingStore:W,eventContentSlotArgs:Le,layout:t,timeFormat:_})}),te&&!P&&et("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),et(Pa,{showDetailPanel:te,customEventDetailDialog:P,detailPanelPosition:Te,event:e,detailPanelRef:X,isAllDay:n,eventVisibility:be,calendarRef:o,selectedEventElementRef:J,onEventUpdate:T,onEventDelete:N,handlePanelClose:Re,customRenderingStore:W,contentSlotRenderer:$e,customDetailPanelContent:R,app:$}),Z&&$&&et(xa,{event:e,x:Z.x,y:Z.y,onClose:()=>V(null),app:$,onDetailPanelToggle:O,detailPanelKey:ee})]})},Ya=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=vn();return et("div",{className:"df-navigation flex items-center gap-1",children:[et("button",{type:"button",className:Yn,onClick:e,"aria-label":"Previous month",children:et(rr,{className:Fn})}),et("button",{type:"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:r("today")}),et("button",{type:"button",className:Yn,onClick:n,"aria-label":"Next month",children:et(ar,{className:Fn})})]})},Fa=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:i,showTodayBox:l,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=vn(),g=void 0===l||l,m=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""}})(),v="day"===e?i||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return et("div",{className:wn,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"flex-1",children:et("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[et("h1",{className:Dn,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&et("h1",{className:Dn,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[et("div",{className:`${Dn} text-gray-900 dark:text-white`,children:m}),v&&et("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:v})]})}),g&&n&&r&&a&&et("div",{className:"flex items-center gap-2",children:et(Ya,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})},za=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:a,organizedAllDayEvents:o,allDayAreaHeight:i,timeSlots:l,eventLayouts:s,isToday:d,currentTime:c,selectedEventId:h,setSelectedEventId:m,newlyCreatedEventId:f,setNewlyCreatedEventId:p,detailPanelEventId:y,setDetailPanelEventId:b,dragState:w,isDragging:D,handleMoveStart:x,handleResizeStart:E,handleCreateStart:C,handleCreateAllDayEvent:k,handleTouchStart:T,handleTouchEnd:N,handleTouchMove:S,handleDragOver:M,handleDrop:H,handleEventUpdate:A,handleEventDelete:O,onDateChange:R,customDetailPanelContent:P,customEventDetailDialog:L,calendarRef:$,allDayRowRef:j,timeGridRef:Y,switcherMode:F,isMobile:z,isTouch:_,setDraftEvent:W,setIsDrawerOpen:U,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:Z,FIRST_HOUR:V,LAST_HOUR:G,showAllDay:K,showStartOfDayLabel:q,timeFormat:X="24h",secondaryTimeSlots:J,primaryTzLabel:Q,secondaryTzLabel:ee})=>{var te;const ne=!!J&&J.length>0&&!z,{t:re,locale:ae}=vn(),oe=g(e.state.highlightedEventId),[ie,le]=u(null),se=v(()=>St(),[]),de=()=>{var e;const t=null===(e=$.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!t)return 0;const n=t.querySelector(".df-time-grid-row");return n?n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop:0},ce=(e,n)=>{var r,a,o,i;if(e.preventDefault(),z)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=$.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=de(),a=(e.clientY-t.top+n-r)/Z+V,s=Math.floor(a),d=Math.floor(60*(a-s)),c=15*Math.round(d/15),u=60===c?s+1:s,h=60===c?0:c;l.setHours(u,h,0,0)}}le({x:e.clientX,y:e.clientY,date:l})};return et("div",{className:`flex-none ${"buttons"===F?"":"md:w-[60%]"} w-full border-r border-gray-200 bg-white md:w-[70%] dark:border-gray-700 dark:bg-gray-900`,onContextMenu:e=>e.preventDefault(),children:[et("div",{className:`relative ${er} h-full`,children:[et("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:z||!se?"0px":"15px"},children:et(Fa,{calendar:e,viewType:I.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(ae,{weekday:"long"})})}),et("div",K?{className:nr(Hn,"items-stretch border-t border-gray-200 dark:border-gray-700"),ref:j,style:{paddingRight:z||!se?"0px":"0.6875rem"},onContextMenu:e=>ce(e,!0),children:[et("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 flex w-12 items-center text-[10px] md:w-20 md:text-xs",onContextMenu:e=>e.preventDefault(),children:re("allDay")}),et("div",{className:nr("relative flex flex-1 self-stretch",!z&&se?"border-r border-gray-200 dark:border-gray-700":""),children:et("div",{className:"relative w-full",style:{minHeight:`${i}px`},onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,r)},onDragOver:M,onDrop:e=>{H(e,t,void 0,!0)},children:o.map(t=>et(ja,{event:t,isAllDay:!0,viewType:I.DAY,segmentIndex:t.row,allDayHeight:B,calendarRef:$,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:Z,firstHour:V,onMoveStart:x,onEventUpdate:A,onEventDelete:O,newlyCreatedEventId:f,onDetailPanelOpen:()=>p(null),detailPanelEventId:y,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.state.readOnly,o=r.find(e=>e.id===t);(z||_)&&o&&n&&!a?(W(o),U(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),oe.current=null))},onEventLongPress:e=>{(z||_)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:z,enableTouch:_},t.id))})})]}:{className:nr("border-b border-gray-200 dark:border-gray-700",!z&&se?"pr-2.75":"")}),et("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:et("div",{className:"relative flex",children:[d&&c&&(()=>{const e=c,t=e.getHours()+e.getMinutes()/60;if(t<V||t>G)return null;return et("div",{className:Mn,style:{top:`${(t-V)*Z}px`,width:"100%",height:0,zIndex:20,marginTop:ne?"2rem":"0.75rem"},children:[et("div",{className:"flex w-12 items-center md:w-20",children:[et("div",{className:"relative flex w-full items-center"}),et("div",{className:In,children:be(t,0,X,!1)})]}),et("div",{className:"flex flex-1 items-center",children:et("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),et("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 "+(ne?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[et("div",{className:ne?"h-8":"h-3",children:ne&&et("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[et("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:ee}),et("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:Q})]})}),l.map((e,t)=>{var n;return et("div",{className:Tn,children:et("div",ne?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly gap-1 text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:q&&0===t?"":null!==(n=null==J?void 0:J[t])&&void 0!==n?n:""}),et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:q&&0===t?"":e.label})]}:{className:`${Nn} text-[10px] md:text-[12px]`,children:q&&0===t?"":e.label})},t)})]}),et("div",{className:"grow select-none",children:[et("div",{className:nr(Wn,!z&&se?"border-r":"","border-t-0"),style:ne?{height:"2rem"}:void 0,children:et("div",{className:`${Un} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:q?be(V,0,X):""})}),et("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:Y,children:[l.map((e,r)=>et("div",{className:nr(Sn,!z&&se?"border-r":""),onClick:()=>null==R?void 0:R(t),onDblClick:e=>{var r,a,o,i;const l=Math.floor((t.getTime()-n.getTime())/864e5),s=null===(a=null===(r=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!s)return;const d=(null===(i=null===(o=$.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===i?void 0:i.scrollTop)||0,c=de(),u=e.clientY-s.top+d-c;null==C||C(e,l,V+u/Z)},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);T(e,r)},onTouchEnd:N,onTouchMove:S,onDragOver:M,onDrop:e=>{var n,r,a,o;const i=null===(r=null===(n=$.current)||void 0===n?void 0:n.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=$.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=de(),d=e.clientY-i.top+l-s,c=Math.floor(V+d/Z);H(e,t,c)},onContextMenu:e=>ce(e,!1)},r)),et("div",{className:nr(Wn,!z&&se?"border-r":""),children:et("div",ne?{className:"absolute -top-2.5 flex items-center justify-evenly text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",style:{left:z?"-5rem":"-5.5rem",width:z?"5rem":"5.5rem"},children:[et("span",{children:null!==(te=null==J?void 0:J[0])&&void 0!==te?te:""}),et("span",{children:be(0,0,X)})]}:{className:`${Un} -left-9.5`,children:be(0,0,X)})}),et("div",{className:"pointer-events-none absolute top-0 right-0 bottom-0 left-0",children:a.filter(e=>!e.allDay).map(t=>{const n=s.get(t.id);return et(ja,{event:t,layout:n,viewType:I.DAY,calendarRef:$,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:Z,firstHour:V,onMoveStart:x,onResizeStart:E,onEventUpdate:A,onEventDelete:O,newlyCreatedEventId:f,onDetailPanelOpen:()=>p(null),detailPanelEventId:y,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(z||_)&&a&&n?(W(a),U(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),oe.current=null))},onEventLongPress:e=>{(z||_)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:z,enableTouch:_},t.id)})})]})]})]})})]}),ie&&et(Da,{x:ie.x,y:ie.y,date:ie.date,viewType:I.DAY,onClose:()=>le(null),app:e,onCreateEvent:()=>{if(C){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===ie.date.getHours()&&0===ie.date.getMinutes())null==k||k({clientX:ie.x,clientY:ie.y},e);else{const t=ie.date.getHours()+ie.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:ie.x,clientY:ie.y};C(n,e,t)}}}})]})},_a=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h"})=>{const{t:c,locale:u}=vn(),h=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return et("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:et("div",{className:`${er} h-full`,children:[et("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:et("div",{children:[et("div",{className:"flex items-center justify-end gap-2",children:[et("div",{className:wn,style:{position:"relative"},children:et("div",{children:et("h1",{className:Dn,children:" "})})}),et(Ya,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),et(qr,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l})]})}),et("div",{className:"flex-1 overflow-y-auto",children:et("div",{className:"p-4",children:[et("h3",{className:"text-lg font-semibold mb-3 sticky top-0 z-10 bg-white py-2 dark:bg-gray-900",children:t.toLocaleDateString(u,{weekday:"long",month:"long",day:"numeric"})}),0===h.length?et("p",{className:`${qn} ${Qn}`,children:c("noEvents")}):et("div",{className:"space-y-2",children:h.map(t=>et("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"border-primary bg-primary/10":"border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-800"} hover:bg-gray-100 dark:hover:bg-gray-700`,style:{borderLeftColor:pe(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[et("div",{className:`font-medium ${Qn}`,children:t.title}),!t.allDay&&et("div",{className:`${Jn} ${Xn}`,children:[be(ne(t.start),0,d)," ","- ",be(we(t),0,d)]}),t.allDay&&et("div",{className:`${Jn} ${Xn}`,children:c("allDay")})]},t.id))})]})})]})})},Wa={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function Ua(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:ne(e.start),_endHour:e.allDay?0:we(e)})}function Ba(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:ne(e.start)}function Za(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:we(e)}function Va(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Ba(e)<Za(t)&&Ba(t)<Za(e))}function Ga(e,t){const n=Za(e)-Ba(e);if(n<1.25)return!1;const r=Ba(e)+.4*n,a=Ba(t)>=r,o=Va(e,t);return a&&o}function Ka(e,t,n=Wa){if(!Va(e,t))return!1;const r=Math.abs(Ba(e)-Ba(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Va(e,t)||!Ga(e,t)&&!Ga(t,e))}(e,t))}function qa(e,t){const n=Ba(e)<=Ba(t)&&Za(e)>=Za(t),r=Ba(e)<=Ba(t)&&Ba(t)<Za(e)&&Va(e,t);return n||r}function Xa(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r];n.add(r.id);for(const t of e){if(n.has(t.id))continue;Math.abs(Ba(r)-Ba(t))<=Wa.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Ba(e)-Ba(t));const o={events:a,startHour:Math.min(...a.map(e=>Ba(e))),endHour:Math.max(...a.map(e=>Za(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Ja(e){return"day"===e?.5:2.5}function Qa(e){const t=Za(e)-Ba(e);return Math.max(.1,Math.min(1,t/4))}function eo(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(Ka(e[t],e[n],Wa))return!0;return!1}function to(e,t,n,r,a={}){const o=Ja(a.viewType);let i=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*Ja(t):null}(e,a.viewType);null!==t&&(i=t)}const l="day"===a.viewType;let s=0;1===e.depth?s=l?.5:1.5:2===e.depth?s=l?-.01:-1:e.depth>=3&&(s=l?.55:-3.5);const d=t+i+s;let c=n-(i+s);if(d+c>t+n&&(c=t+n-d),r.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(a.containerWidth||320)/100,importance:Qa(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Za(t.event)-Ba(t.event)-(Za(e.event)-Ba(e.event)));1===u.length?to(u[0],d,c,r,a):eo(u.map(e=>e.event))?no(u,d,c,r,a):u.forEach(e=>to(e,d,c,r,a))}function no(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*Ja(a.viewType),s="day"===a.viewType;let d=1===i?s?.5:1.5:2===i?s?-.01:-1:s?.55:-3.5;const c=t+l+d,u=n-(l+d);if(u<=0)return void e.forEach(e=>to(e,t,n,r,a));let h=Wa.MARGIN_BETWEEN*(1===i?s?.15:.3:s?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(g+h);if(r.set(e.event.id,{id:e.event.id,left:n,width:g,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(a.containerWidth||320)/100,importance:Qa(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Za(t.event)-Ba(t.event)-(Za(e.event)-Ba(e.event)));1===t.length?to(t[0],n,g,r,a):eo(t.map(e=>e.event))?no(t,n,g,r,a):t.forEach(e=>to(e,n,g,r,a))}})}function ro(e,t,n={}){const r=100-("day"===n.viewType?0:Wa.EDGE_MARGIN_PERCENT);if(1===e.length)to(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-Wa.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{to(e,r*(o+Wa.MARGIN_BETWEEN),Math.max(o,Wa.MIN_WIDTH),t,n)})}}function ao(e){let t=0;for(const n of e.children)t+=1+ao(n);return t}function oo(e,t){var n,r;const a=null===(r=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===r?void 0:r.depth;return void 0===a?[]:t.filter(e=>e.depth===a).map(e=>({node:e,load:ao(e)})).toSorted((e,t)=>t.load-e.load)}function io(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function lo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function so(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>qa(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),lo(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),lo(t.event,e.event))}function co(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>co(e,t))}function uo(e,t){const n=[];return co(e,n),n.find(e=>qa(t.event,e.event))||n[0]||null}function ho(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],r=e.at(-1);if(n.load-r.load<2)break;const a=uo(n.node,r.node);if(!a)break;so(a,r.node),n.load--,r.load++,t++}}function go(e,t){const n=t.startHour-e.startHour;if(function(e,t){for(const n of e.events)for(const e of t.events)if(Va(n,e)&&Math.abs(Ba(e)-Ba(n))<Wa.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<Wa.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(qa(n,e))return!0;return!1}function mo(e,t,n){const r=t.events.filter(t=>qa(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const r=n.find(e=>e.id===t);return r&&Ka(e,r,Wa)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Ba(e)-Ba(t.parent))-Math.abs(Ba(e)-Ba(n.parent))),a[0].parent}function vo(e,t,n){if(0===t.length)return null;let r=1/0,a=[];for(const e of t){const t=e.children.length;t<r?(r=t,a=[e]):t===r&&a.push(e)}const o=Za(e)-Ba(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Za(t)-Ba(t):0}),0)?a[0]:a.at(-1)||null}function fo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function po(e){let t=0;for(const n of e.children)t+=1+po(n);return t}function yo(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),r=t.get(n.parentId);e&&r&&(e.parent=r,e.depth=r.depth+1,r.children.push(e))}return t}function bo(e,t){const n=t.get(e.id);if(!n)return null;let r=n;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const a=r.parent;if(!a)return null;const o=a.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,l=null;for(const e of o){const t=po(e);t<i&&(i=t,l=e)}return l?l.event:null}function wo(e,t,n){const r=[];if(1===e.length){const a=mo(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),fo(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>qa(t,e)));if(0===a.length){for(const a of e){const o=mo(a,t,n);if(o)r.push({child:a,parent:o}),fo(o,a);else{const t=e.find(e=>e.id!==a.id&&Va(e,a));if(t){const e=bo(t,yo(n));e&&(r.push({child:a,parent:e}),fo(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Za(t)-Ba(t)-(Za(e)-Ba(e)));if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],i=o.slice(t*e,(t+1)*e);for(const e of i)r.push({child:e,parent:n}),fo(n,e)}}else for(const e of o){const t=vo(e,a,o);t&&(r.push({child:e,parent:t}),fo(t,e))}return r}function Do(e,t){const n=[],r=new Map,a=new Map;t.forEach(e=>a.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:a.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),r.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],i=o.events.map(e=>a.get(e.id));let l=!1;for(let s=n-1;s>=0&&!l;s--){const n=e[s],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(go(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=wo(i,d,t);for(const t of e){const e=r.get(t.child.id),n=r.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}l=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const r=oo(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);io(r)&&ho(r)}}(e,n),o}const xo={calculateDayEventLayouts(e,t={}){const n=e.map(Ua);for(const e of n)e.parentId=void 0,e.children=[];const r=new Map,a=n.filter(e=>!e.allDay);if(0===a.length)return r;const o=function(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r],o=[r];for(n.add(r.id);o.length>0;){const t=o.shift();for(const r of e)n.has(r.id)||Va(t,r)&&(a.push(r),o.push(r),n.add(r.id))}t.push(a)}return t}(a);for(const e of o)if(1===e.length){const n="day"===t.viewType?0:Wa.EDGE_MARGIN_PERCENT;r.set(e[0].id,{id:e[0].id,left:0,width:100-n,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:Math.max(.1,Math.min(1,(e[0]._endHour-e[0]._startHour)/4))})}else{ro(Do(Xa([...e].toSorted((e,t)=>e._startHour!==t._startHour?e._startHour-t._startHour:t._endHour-t._startHour-(e._endHour-e._startHour))),e),r,t)}return r}},Eo=(e,t=1)=>{const n=(e.getDay()-t+7)%7,r=new Date(e);return r.setDate(e.getDate()-n),r.setHours(0,0,0,0),r},Co={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ko(t){const{app:n,onEventCreated:r}=t,{t:a}=vn(),o=m(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:m((t,o,i,l)=>{if(t.preventDefault(),!t.dataTransfer)return null;const s=t.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const t=JSON.parse(s);let d,c,u=!1;l?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:0,minute:0}),c=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:23,minute:59,second:59}),u=!0):void 0===i?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:9,minute:0}),c=d.add({hours:1})):(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:i,minute:0}),c=d.add({hours:1}));const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:a(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:t.calendarName}),description:"",start:d,end:c,calendarId:t.calendarId,allDay:u};return n.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]),handleDragOver:o}}let To=null;function No(e){To=e}const So={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function Mo(e,t){return To?To(e,t):So}const Io=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,switcherMode:o="buttons",selectedEventId:i,onEventSelect:l,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{const f=e.getEvents(),{screenSize:y}=gn(),b="desktop"!==y,[w,D]=u(!1),{hourHeight:x=Co.HOUR_HEIGHT,firstHour:E=Co.FIRST_HOUR,lastHour:C=Co.LAST_HOUR,allDayHeight:k=Co.ALL_DAY_HEIGHT,showAllDay:T=!0,timeFormat:N="24h",secondaryTimeZone:S}=t,M=x,H=E,A=C,O=k,R=!T;h(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const P=e.getCustomMobileEventRenderer()||Qr,[L,$]=u(null),[j,Y]=u(null),[F,z]=u(null),_=void 0===i?j:i,U=void 0===d?F:d,Z=v(()=>_&&f.find(e=>e.id===_)||null,[_,f]),V=e=>{l?l(e):Y(e)},[G,K]=u(null),[q,X]=u(!1),[J,Q]=u(null),ee=g(null),te=e.getCurrentDate(),[re,ae]=u(te),oe=g(te.getTime());te.getTime()!==oe.current&&(oe.current=te.getTime(),te.getFullYear()===re.getFullYear()&&te.getMonth()===re.getMonth()||ae(te));const ie=m(t=>{ae(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),le=g(e.state.highlightedEventId);h(()=>{var t;if(e.state.highlightedEventId!==le.current)if(e.state.highlightedEventId){V(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=ne(n.start),r=null===(t=a.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(r){const t=(e-H)*M;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else V(null);le.current=e.state.highlightedEventId},[e.state.highlightedEventId,H,M,a,e]);const se=g(null),de=g(null),ce=v(()=>Eo(te),[te]),ue=v(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(t);return a.setHours(23,59,59,999),e.filter(e=>{const t=B(e.start),n=B(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<=a&&o>=r}return t<a&&n>r}).map(e=>{const t=B(e.start),r=Math.floor((t.getTime()-n.getTime())/864e5),a=Math.max(0,Math.min(6,r));return Object.assign(Object.assign({},e),{day:a})})})(f,te,ce),[f,te,ce]),he=v(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const r=new Date(n);return r.setDate(r.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=B(e.start),a=B(e.end);let o=e.start,i=e.end,l=!1;return t<n&&(o=W(n),l=!0),a>r&&(i=W(r),l=!0),Object.assign(Object.assign({},e),{start:l?o:e.start,end:l?i:e.end,day:0})})})(ue,te),[ue,te]),ge=v(()=>xo.calculateDayEventLayouts(he,{viewType:"day"}),[he]),me=v(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=B(e.start),r=B(t.start);if(n.getTime()!==r.getTime())return n.getTime()-r.getTime();const a=B(e.end);return B(t.end).getTime()-a.getTime()});const n=[],r=[];return t.forEach(e=>{let t=0,a=!1;for(;!a;)n[t]?n[t].some(t=>{const n=B(e.start),r=B(e.end),a=B(t.start);return n<=B(t.end)&&a<=r})?t++:(n[t].push(e),r.push(Object.assign(Object.assign({},e),{row:t})),a=!0):(n[t]=[e],r.push(Object.assign(Object.assign({},e),{row:t})),a=!0)}),r})(ue),[ue]),ve=v(()=>{if(0===me.length)return O;return(Math.max(...me.map(e=>e.row))+1)*O},[me,O]),{handleMoveStart:fe,handleCreateStart:pe,handleResizeStart:ye,handleCreateAllDayEvent:we,dragState:De,isDragging:xe}=Mo(e,{calendarRef:a,allDayRowRef:T?se:void 0,timeGridRef:de,viewType:I.DAY,onEventsUpdate:(t,n,r)=>{const a=t(ue),o=new Set(a.map(e=>e.id)),i=ue.filter(e=>!o.has(e.id)),l=new Set(ue.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=f.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},void 0,r)},onEventCreate:t=>{b?(Q(t),X(!0)):(e.addEvent(t),K(t.id))},onEventEdit:()=>{},currentWeekStart:ce,events:ue,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a)=>{const o=new Date(r),i=new Date(r);o.setHours(Math.floor(t),t%1*60,0,0),i.setHours(Math.floor(n),n%1*60,0,0);const l=[...a,{id:"-1",title:"Temp",day:0,start:W(o),end:W(i),calendarId:"blue",allDay:!1}];return xo.calculateDayEventLayouts(l,{viewType:"day"}).get("-1")||null})(0,t,n,te,he),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o)=>{const i=o.filter(t=>t.id!==e.id),l=new Date(a),s=new Date(l);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(l);d.setHours(Math.floor(r),r%1*60,0,0);const c=[...i,Object.assign(Object.assign({},e),{start:W(s),end:W(d),day:0})];return 0===c.length?null:xo.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,r,te,he),TIME_COLUMN_WIDTH:S&&!b?88:b?48:80,isMobile:b}),{handleDrop:ke,handleDragOver:Te}=ko({app:e,onEventCreated:e=>{K(e.id)}}),Ne=Array.from({length:24},(e,t)=>({hour:t+H,label:be(t+H,0,N)})),Se=v(()=>S?Ee(Ne,S,N):void 0,[S,N,H]),Me=v(()=>S?Ce(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[S]),Ie=v(()=>S?Ce(S):void 0,[S]),He=m(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),ae(new Date(n.getFullYear(),n.getMonth(),1))},[e]),Ae=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(te);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[te]);return p(()=>{var e;if(t.scrollToCurrentTime){const t=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(t){const e=new Date,n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-H)*M-r/2)}}},[]),h(()=>{$(new Date);const e=setInterval(()=>$(new Date),6e4);return()=>clearInterval(e)},[]),et("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[et(za,{app:e,currentDate:te,currentWeekStart:ce,events:f,currentDayEvents:ue,organizedAllDayEvents:me,allDayAreaHeight:ve,timeSlots:Ne,eventLayouts:ge,isToday:Ae,currentTime:L,selectedEventId:_,setSelectedEventId:V,newlyCreatedEventId:G,setNewlyCreatedEventId:K,detailPanelEventId:U,setDetailPanelEventId:e=>{c?c(e):z(e)},dragState:De,isDragging:xe,handleMoveStart:fe,handleResizeStart:ye,handleCreateStart:pe,handleCreateAllDayEvent:we,handleTouchStart:(e,t)=>{if(!b&&!w)return;const n=e.touches[0],r=n.clientX,o=n.clientY,i=e.currentTarget;ee.current=setTimeout(()=>{var e,n,l;const s=null===(n=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(l=a.current)||void 0===l?void 0:l.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=o-s.top+c;null==pe||pe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,H+u/M)},500)},handleTouchEnd:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleTouchMove:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleDragOver:Te,handleDrop:ke,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:s,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,allDayRowRef:se,timeGridRef:de,switcherMode:o,isMobile:b,isTouch:w,setDraftEvent:Q,setIsDrawerOpen:X,ALL_DAY_HEIGHT:O,HOUR_HEIGHT:M,FIRST_HOUR:H,LAST_HOUR:A,showAllDay:T,showStartOfDayLabel:R,timeFormat:N,secondaryTimeSlots:Se,primaryTzLabel:Me,secondaryTzLabel:Ie}),et(_a,{app:e,currentDate:te,visibleMonth:re,currentDayEvents:ue,selectedEvent:Z,setSelectedEvent:e=>V(e?e.id:null),handleMonthChange:ie,handleDateSelect:He,switcherMode:o,timeFormat:N}),et(P,{isOpen:q,onClose:()=>{X(!1),Q(null)},onSave:t=>{f.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),X(!1),Q(null)},draftEvent:J,app:e,timeFormat:N})]})},Ho=({originalComponent:e,app:t,config:n,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:i,meta:l,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDateChange:u,onDetailPanelToggle:h})=>{const g=t.getPlugin("events"),f=t.getPlugin("drag"),p=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),w=m(e=>{g?g.update(e.id,e):t.updateEvent(e.id,e)},[g,t]),D=m(e=>{g?g.delete(e):t.deleteEvent(e)},[g,t]),x=m(e=>{g?g.add(e):t.addEvent(e)},[g,t]),E=m(e=>{u?u(e):t.setCurrentDate(e)},[t,u]),C=m(e=>{t.changeView(e)},[t]),k=v(()=>Object.assign({},n),[n]),T=v(()=>({app:t,currentDate:p,currentView:y,events:b,onEventUpdate:w,onEventDelete:D,onEventCreate:x,onDateChange:E,onViewChange:C,config:k,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:i,meta:l,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDetailPanelToggle:h}),[t,p,y,b,w,D,x,E,C,k,r,a,o,i,l,s,d,c,h]),N=v(()=>{const e={currentDate:p,events:b,setEvents:e=>{b.forEach(e=>D(e.id)),e.forEach(e=>x(e))},updateEvent:w,deleteEvent:D,addEvent:x,goToPrevious:()=>{const e=new Date(p);switch(y){case I.DAY:e.setDate(e.getDate()-1);break;case I.WEEK:e.setDate(e.getDate()-7);break;case I.MONTH:e.setMonth(e.getMonth()-1)}E(e)},goToNext:()=>{const e=new Date(p);switch(y){case I.DAY:e.setDate(e.getDate()+1);break;case I.WEEK:e.setDate(e.getDate()+7);break;case I.MONTH:e.setMonth(e.getMonth()+1)}E(e)},goToToday:()=>{E(new Date)},changeView:C,selectDate:E};return Object.assign(Object.assign({calendar:e},T),{eventsService:g,dragService:f})},[p,b,y,w,D,x,E,C,T,g,f]);return et(e,Object.assign({},N))},Ao={showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},Oo=(e={})=>{const t=Object.assign(Object.assign({},Ao),e),n=e=>a(Ho,{viewType:I.DAY,originalComponent:Io,app:e.app,config:t,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,onEventSelect:e.onEventSelect,detailPanelEventId:e.detailPanelEventId,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="DayViewAdapter",{type:I.DAY,component:n,config:t}},Ro=e=>{const t=e.toLowerCase();return t.startsWith("tu")||t.startsWith("th")||t.startsWith("sa")||t.startsWith("su")?e.slice(0,2):e.slice(0,1)},Po=({app:e,fullWeekDates:t=[],mobilePageStart:n,onDateChange:a})=>et("div",{className:"flex w-full flex-col border-b border-gray-200 bg-white py-3 dark:border-gray-700 dark:bg-gray-900",children:[et("div",{className:"mb-1 grid grid-cols-7",children:t.map((e,t)=>et("div",{className:"flex justify-center",children:et("span",{className:"text-[10px] font-medium "+(e.isToday?"text-primary":"text-gray-500"),children:Ro(e.dayName)})},`label-${t}`))}),et("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!n)return null;const o=t.findIndex(e=>e.fullDate.getTime()===n.getTime());return et(r,{children:[et("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:-1===o?"0":`calc(${(o+.5)/7*100}% - 16px)`,top:0,width:`calc(${1/7*100}% + 32px)`,height:"32px"}}),t.map((t,n)=>{const r=t.isCurrent,i=n>=o&&n<o+2;return et("div",{className:"relative z-10 flex cursor-pointer items-center justify-center",style:{height:"32px"},onClick:()=>{e.setCurrentDate(t.fullDate),null==a||a(t.fullDate)},children:et("div",{className:`relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-all duration-300 ${r?"bg-gray-900 text-white shadow-sm dark:bg-gray-100 dark:text-gray-900":t.isToday?"font-bold text-primary":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!r&&et("div",{className:"absolute bottom-1 h-1 w-1 rounded-full bg-primary"})]})},`date-${n}`)})]})})()})]}),Lo=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,fullWeekDates:o,isSlidingView:i,mobilePageStart:l,currentWeekStart:s,gridWidth:d,allDayAreaHeight:c,organizedAllDaySegments:h,allDayLabelText:g,isMobile:m,isTouch:f,showAllDay:p=!0,calendarRef:y,allDayRowRef:b,topFrozenContentRef:w,ALL_DAY_HEIGHT:D,HOUR_HEIGHT:x,FIRST_HOUR:E,dragState:C,isDragging:k,primaryTzLabel:T,secondaryTzLabel:N,secondaryTimeSlots:S,handleMoveStart:M,handleResizeStart:H,handleEventUpdate:A,handleEventDelete:O,onDateChange:R,newlyCreatedEventId:P,setNewlyCreatedEventId:L,selectedEventId:$,setSelectedEventId:j,detailPanelEventId:Y,setDetailPanelEventId:F,handleCreateAllDayEvent:z,handleDragOver:_,handleDrop:W,customDetailPanelContent:U,customEventDetailDialog:B})=>{const Z={flexShrink:0},[V,G]=u(null),K=v(()=>St(),[]),q=!!S&&S.length>0&&!m;return et("div",{className:"flex w-full flex-col",children:[i&&o&&l&&et(Po,{app:e,fullWeekDates:o,mobilePageStart:l,onDateChange:R}),et("div",{className:`flex flex-none ${p?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[p&&et("div",{className:"z-20 flex w-12 shrink-0 flex-col bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"flex flex-1 items-center border-b border-gray-200 transition-all duration-300 ease-in-out dark:border-gray-700 "+(i?"hidden":""),children:q&&et("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[et("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:N}),et("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:T})]})}),et("div",{className:"flex items-center justify-end p-1 text-[10px] font-medium text-gray-500 transition-[min-height] duration-300 ease-in-out select-none md:text-xs dark:text-gray-400",style:{minHeight:`${c}px`},children:g})]}),et("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:p?`${c+(i?0:36)}px`:"auto"},children:et("div",{ref:w,className:"flex flex-col",style:{width:d,minWidth:"100%",transform:i?"translateX(calc(-100% / 3))":void 0},children:[!i&&et("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:K?"-50px":"0px",paddingRight:K?"50px":"0px"},children:t.map((e,t)=>et("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 "+(m?"flex-col gap-0":""),style:Z,children:et(r,m?{children:[et("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:n[t]}),et("div",{className:`${En} h-7 w-7 text-base font-medium ${a[t].isToday?jn:""}`,children:a[t].date})]}:{children:[et("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),et("div",{className:`${En} ${a[t].isToday?jn:""}`,children:a[t].date})]})},t))}),p&&et("div",{className:`${Hn} border-none transition-[min-height] duration-300 ease-in-out`,ref:b,style:{minHeight:`${c}px`},children:et("div",{className:"df-all-day-content flex flex-1 relative transition-[min-height] duration-300 ease-in-out",style:{minHeight:`${c}px`},children:[t.map((e,n)=>{const r=new Date(s);return r.setDate(s.getDate()+n),et("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!m&&K?"":"border-r-0"),style:Object.assign({minHeight:`${c}px`},Z),onMouseDown:e=>null==z?void 0:z(e,n),onDblClick:e=>null==z?void 0:z(e,n),onDragOver:_,onDrop:e=>{W(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),m)return;const n=new Date(s);n.setDate(s.getDate()+t),n.setHours(0,0,0,0),G({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),et("div",{className:"pointer-events-none absolute inset-0",children:h.map(n=>et(ja,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:D,calendarRef:y,viewType:I.WEEK,columnsPerRow:t.length,isBeingDragged:k&&(null==C?void 0:C.eventId)===n.event.id&&"move"===(null==C?void 0:C.mode),hourHeight:x,firstHour:E,onMoveStart:M,onResizeStart:H,onEventUpdate:A,onEventDelete:O,newlyCreatedEventId:P,onDetailPanelOpen:()=>L(null),selectedEventId:$,detailPanelEventId:Y,onEventSelect:e=>{j(e)},onEventLongPress:e=>{(m||f)&&j(e)},onDetailPanelToggle:e=>F(e),customDetailPanelContent:U,customEventDetailDialog:B,app:e,isMobile:m,isSlidingView:i,enableTouch:f},n.event.id))})]})})]})}),V&&et(Da,{x:V.x,y:V.y,date:V.date,viewType:I.WEEK,onClose:()=>G(null),app:e,onCreateEvent:()=>{const e=Math.floor((V.date.getTime()-s.getTime())/864e5);null==z||z({clientX:V.x,clientY:V.y},e)}})]})]})},$o=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:a,currentWeekEvents:o,eventLayouts:i,gridWidth:l,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:h,leftFrozenContentRef:m,swipeContentRef:f,calendarRef:p,handleScroll:y,handleCreateStart:b,handleTouchStart:w,handleTouchEnd:D,handleTouchMove:x,handleDragOver:E,handleDrop:C,dragState:k,isDragging:T,handleMoveStart:N,handleResizeStart:S,handleEventUpdate:M,handleEventDelete:H,onDateChange:A,newlyCreatedEventId:O,setNewlyCreatedEventId:R,selectedEventId:P,setSelectedEventId:L,detailPanelEventId:$,setDetailPanelEventId:j,customDetailPanelContent:Y,customEventDetailDialog:F,isSlidingView:z,isCurrentWeek:_,currentTime:W,HOUR_HEIGHT:U,FIRST_HOUR:B,LAST_HOUR:Z,showStartOfDayLabel:V,timeFormat:G="24h",secondaryTimeSlots:K})=>{var q,X;const J=!!K&&K.length>0&&!s,Q={flexShrink:0},ee=g(e.state.highlightedEventId),[te,ne]=u(null),re=v(()=>St(),[]);return et("div",{className:"relative flex flex-1 overflow-hidden",children:[et("div",{ref:c,className:"calendar-content relative flex-1 overflow-auto "+("300%"===l?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:y,children:[et("div",{ref:m,className:"sticky left-0 z-10 w-12 shrink-0 bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"relative h-3",children:J?et(r,{children:et("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:V&&null!==(q=null==K?void 0:K[0])&&void 0!==q?q:""}),et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:V?be(B,0,G):""})]})}):et("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:V?be(B,0,G):""})}),t.map((e,t)=>{var n;return et("div",{className:Tn,children:et("div",J?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:V&&0===t?"":null!==(n=null==K?void 0:K[t])&&void 0!==n?n:""}),et("span",{className:"text-[10px] md:text-[12px]",children:V&&0===t?"":e.label})]}:{className:`${Nn} text-[10px] md:text-[12px]`,children:V&&0===t?"":e.label})},t)}),et("div",{className:"relative",children:et("div",J?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:null!==(X=null==K?void 0:K[0])&&void 0!==X?X:""}),et("span",{className:"text-[10px] md:text-[12px]",children:be(0,0,G)})]}:{className:`${Nn} text-[10px] md:text-[12px]`,children:be(0,0,G)})}),_&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>Z)return null;return et("div",{className:"pointer-events-none absolute left-0 z-20 flex w-full items-center justify-end",style:{top:`${(t-B)*U}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:et("div",{className:In,children:be(t,0,G,!1)})})})()]}),et("div",{ref:f,className:"flex",style:{width:l,minWidth:"100%",transform:z?"translateX(calc(-100% / 3))":void 0},children:et("div",{className:"grow",children:[et("div",{className:`${Wn} flex border-t-0`,children:n.map((e,t)=>et("div",{className:`relative flex-1 ${t!==n.length-1||!s&&re?"border-r":""} border-gray-200 dark:border-gray-700`,style:Q},`top-${t}`))}),et("div",{ref:h,className:"relative",children:[_&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>Z)return null;const r=new Date(e);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const i=r.getTime()-o.getTime(),l=Math.round(i/864e5);return et("div",{className:Mn,style:{top:`${(t-B)*U}px`,width:"100%",height:0,zIndex:20},children:[et("div",{className:"flex w-0 items-center"}),et("div",{className:"flex flex-1",children:n.map((e,t)=>et("div",{className:"flex flex-1 items-center",children:et("div",{className:"relative h-0.5 w-full "+(t===l?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===l&&0!==l&&et("div",{className:"absolute h-2 w-2 rounded-full bg-primary",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>et("div",{className:Sn,children:n.map((r,o)=>{const i=new Date(a);return i.setDate(a.getDate()+o),et("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(o!==n.length-1||!s&&re?"":"border-r-0"),style:Q,onClick:()=>{const e=new Date(a);e.setDate(a.getDate()+o),null==A||A(e)},onDblClick:t=>{null==b||b(t,o,e.hour)},onTouchStart:t=>w(t,o,e.hour),onTouchEnd:D,onTouchMove:x,onDragOver:E,onDrop:t=>{C(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),s)return;const r=new Date(a);if(r.setDate(a.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/U+B,a=Math.floor(n),o=Math.floor(60*(n-a)),i=15*Math.round(o/15),l=60===i?a+1:a,s=60===i?0:i;r.setHours(l,s,0,0)}else r.setHours(n,0,0,0);ne({x:e.clientX,y:e.clientY,date:r})})(t,o,e.hour)},`${t}-${o}`)})},t)),et("div",{className:`${Wn} flex`,children:n.map((e,t)=>et("div",{className:`relative flex-1 ${t!==n.length-1||!s&&re?"border-r":""} border-gray-200 dark:border-gray-700`,style:Q},`24-${t}`))}),n.map((t,r)=>{const l=n.length,c=Ie(r,o),u=[];return c.forEach(e=>{const t=ka(e,a);if(t.length>0){const n=t.find(e=>e.dayIndex===r);n&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:r})})}else u.push({event:e})}),o.forEach(e=>{if(e.allDay||e.day===r)return;const t=ka(e,a).find(e=>e.dayIndex===r);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:r})})}),et("div",{className:"pointer-events-none absolute top-0",style:{left:`calc(${100/l*r}%)`,width:100/l+"%",height:"100%"},children:u.map(({event:t,segmentInfo:n})=>{const a=i.get(r),o=null==a?void 0:a.get(t.id);return et(ja,{event:t,layout:o,viewType:I.WEEK,calendarRef:p,columnsPerRow:l,isBeingDragged:T&&(null==k?void 0:k.eventId)===t.id&&"move"===(null==k?void 0:k.mode),hourHeight:U,firstHour:B,onMoveStart:N,onResizeStart:S,onEventUpdate:M,onEventDelete:H,newlyCreatedEventId:O,onDetailPanelOpen:()=>R(null),selectedEventId:P,detailPanelEventId:$,onEventSelect:t=>{L(t),e.state.highlightedEventId&&(e.highlightEvent(null),ee.current=null)},onEventLongPress:e=>{(s||d)&&L(e)},onDetailPanelToggle:e=>j(e),customDetailPanelContent:Y,customEventDetailDialog:F,multiDaySegmentInfo:n,app:e,isMobile:s,isSlidingView:z,enableTouch:d},n?`${t.id}-seg-${r}`:t.id)})},`events-day-${r}`)})]})]})})]}),te&&et(Da,{x:te.x,y:te.y,date:te.date,viewType:I.WEEK,onClose:()=>ne(null),app:e,onCreateEvent:()=>{if(b){const e=new Date(a);e.setHours(0,0,0,0);const t=new Date(te.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),r=Math.round(n/864e5),o=te.date.getHours()+te.date.getMinutes()/60,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:te.x,clientY:te.y};b(i,r,o)}}})]})},jo=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,onDateChange:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:m,getWeekDaysLabels:f,locale:y}=vn(),b=e.getCurrentDate(),w=v(()=>b,[b.getTime()]),D=e.getEvents(),{screenSize:x}=gn(),E="desktop"!==x,C=g(null),[k,T]=u(!1),{hourHeight:N=Co.HOUR_HEIGHT,firstHour:S=Co.FIRST_HOUR,lastHour:M=Co.LAST_HOUR,allDayHeight:H=Co.ALL_DAY_HEIGHT,showAllDay:A=!0,timeFormat:O="24h",secondaryTimeZone:R}=t,P=R&&"mobile"!==x?88:"mobile"===x?48:80,L=N,$=S,j=M,Y=H,F=!A;h(()=>{T("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const z=e.getCustomMobileEventRenderer()||Qr,_="desktop"!==x,U=_?2:7,Z=_,V=null!==(c=t.startOfWeek)&&void 0!==c?c:1,G=Z?"300%":"100%",K=v(()=>Eo(w,V),[w,V]),[q,X]=u(()=>{const e=new Date(w);return e.setHours(0,0,0,0),e});h(()=>{Z&&X(e=>{const t=new Date(w);t.setHours(0,0,0,0);const n=new Date(e),r=new Date(e);return r.setDate(r.getDate()+U-1),t>=n&&t<=r?e:t})},[w,Z,U]);const J=Z?q:K,Q=Z?3*U:7,ee=v(()=>{if(!Z)return J;const e=new Date(J);return e.setDate(e.getDate()-U),e},[J,Z,U]),[te,ae]=u(null),[oe,ie]=u(null),[le,se]=u(null),de=void 0===o?oe:o,ce=void 0===s?le:s,ue=e=>{i?i(e):ie(e)},he=e=>{d?d(e):se(e)},[ge,me]=u(null),[ve,fe]=u(!1),[pe,ye]=u(null),we=g(null),[De,xe]=u(0),[ke,Te]=u(!1),Ne=g(null),Se=g(null),Me=g(null),Ie=g(null),He=g(null),Oe=g({x:0,y:0}),Re=g(!1),Pe=g(0);h(()=>{if(!Z)return;const t=Se.current;if(!t)return;const n=e=>{Oe.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Re.current=!1,Pe.current=0,Te(!1)},r=e=>{if(ke)return;const n=e.touches[0].clientX-Oe.current.x,r=e.touches[0].clientY-Oe.current.y;if(!Re.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(Re.current=!0),Re.current){e.cancelable&&e.preventDefault();const r=t.clientWidth/2,a=Math.max(-r,Math.min(r,n)),o=`translateX(calc(-100% / 3 + ${a}px))`;Me.current&&(Me.current.style.transition="none",Me.current.style.transform=o),He.current&&(He.current.style.transition="none",He.current.style.transform=o),Pe.current=a}},a=()=>{var n;if(!Re.current)return void(Pe.current=0);const r=Pe.current,a=((null===(n=He.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/Q;r>100?(Te(!0),xe(a),setTimeout(()=>{const t=new Date(q);t.setDate(t.getDate()-1),X(t),e.setCurrentDate(t),xe(0),Pe.current=0,Te(!1)},300)):r<-100?(Te(!0),xe(-a),setTimeout(()=>{const t=new Date(q);t.setDate(t.getDate()+1),X(t),e.setCurrentDate(t),xe(0),Pe.current=0,Te(!1)},300)):(Te(!0),xe(0),Pe.current=0,setTimeout(()=>{Te(!1)},300))};return t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),t.addEventListener("touchend",a,{passive:!0}),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchmove",r),t.removeEventListener("touchend",a)}},[Z,e,J,ke,U,Q]);const Le=v(()=>((e,t,n=7)=>{const r=new Date(t);return r.setDate(t.getDate()+(n-1)),r.setHours(23,59,59,999),e.filter(e=>{const n=B(e.start);n.setHours(0,0,0,0);const a=B(e.end);return a.setHours(23,59,59,999),a>=t&&n<=r}).map(e=>{const r=B(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),o=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:o})})})(D,ee,Q),[D,ee,Q]),$e=g(e.state.highlightedEventId);h(()=>{if(e.state.highlightedEventId!==$e.current)if(e.state.highlightedEventId){ue(e.state.highlightedEventId);const t=Le.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=ne(t.start),n=Se.current;if(n){const t=(e-$)*L;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ue(null);$e.current=e.state.highlightedEventId},[e.state.highlightedEventId,Le,$,L]);const je=v(()=>((e,t,n=7)=>{const r=Ca(e,t,n).filter(e=>e.event.allDay);r.sort((e,t)=>{const n=B(e.event.start).getTime(),r=B(t.event.start).getTime();if(n!==r)return n-r;const a=e.totalDays;return t.totalDays-a});const a=[];return r.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of a)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(Le,ee,Q),[Le,ee,Q]),Ye=v(()=>{const e=Z?je.filter(e=>e.endDayIndex>=U&&e.startDayIndex<=2*U-1):je;if(0===e.length)return Y;const t=Math.max(...e.map(e=>e.row));return Y+t*Y},[je,Y,Z,U]),Fe=v(()=>((e,t,n=7)=>{const r=new Map;for(let a=0;a<n;a++){const o=[];e.forEach(e=>{if(e.allDay)return;const r=ka(e,t,n);if(r.length>0){const n=r.find(e=>e.dayIndex===a);if(n){const r=n.endHour>=24?23.99:n.endHour,i=Object.assign(Object.assign({},e),{start:W(re(Ae(t,a),n.startHour)),end:W(re(Ae(t,a),r)),day:a});o.push(i)}}else e.day===a&&o.push(e)});const i=xo.calculateDayEventLayouts(o,{viewType:"week"});r.set(a,i)}return r})(Le,ee,Q),[Le,ee,Q]),{handleMoveStart:ze,handleCreateStart:_e,handleResizeStart:We,handleCreateAllDayEvent:Ue,dragState:Be,isDragging:Ve}=Mo(e,{calendarRef:a,allDayRowRef:A?Ne:void 0,timeGridRef:C,viewType:I.WEEK,onEventsUpdate:(t,n,r)=>{const a=t(Le),o=new Set(a.map(e=>e.id)),i=Le.filter(e=>!o.has(e.id)),l=new Set(Le.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=Le.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{E?(ye(t),fe(!0)):(e.addEvent(t),me(t.id))},onEventEdit:()=>{},currentWeekStart:ee,events:Le,calculateNewEventLayout:(e,t,n)=>((e,t,n,r)=>{const a=new Date,o=new Date;a.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const i={id:"-1",title:"Temp",day:e,start:W(a),end:W(o),calendarId:"blue",allDay:!1},l=[...r.filter(t=>t.day===e&&!t.allDay),i];return xo.calculateDayEventLayouts(l,{viewType:"week"}).get("-1")||null})(e,t,n,Le),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=B(a.start),i=re(o,n),l=re(o,r),s=W(i),d=W(l);return Object.assign(Object.assign({},a),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:xo.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,Le),TIME_COLUMN_WIDTH:P,isMobile:E,gridWidth:G,displayDays:Q}),{handleDrop:Ge,handleDragOver:Ke}=ko({app:e,onEventCreated:e=>{me(e.id)}}),qe=v(()=>Z?Array.from({length:Q},(e,t)=>{const n=new Date(ee);return n.setDate(n.getDate()+t),n.toLocaleDateString(y,{weekday:"short"})}):f(y,"short",V),[y,f,Z,ee,Q,V]),Xe=v(()=>{if(!E)return[];const e=y.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?f(y,"narrow"):qe.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)})},[E,y,f,qe]),Je=v(()=>m("allDay"),[m]),Qe=Array.from({length:24},(e,t)=>({hour:t+$,label:be(t+$,0,O)})),tt=v(()=>R?Ee(Qe,R,O):void 0,[R,O,$]),nt=v(()=>R?Ce(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[R]),rt=v(()=>R?Ce(R):void 0,[R]),at=v(()=>{const e=new Date;return e.setHours(0,0,0,0),qe.map((t,n)=>{const r=new Date(ee);r.setDate(ee.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString(y,{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[ee,qe,y]),ot=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=K;return Array.from({length:7},(n,r)=>{const a=new Date(t);a.setDate(t.getDate()+r);const o=new Date(a);return o.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(y,{month:"short"}),fullDate:new Date(a),isToday:o.getTime()===e.getTime(),isCurrent:o.getTime()===new Date(w).setHours(0,0,0,0),dayName:a.toLocaleDateString(y,{weekday:"short"})}})},[K,y,w]);h(()=>{if(!Z)return Me.current&&(Me.current.style.transform="",Me.current.style.transition=""),void(He.current&&(He.current.style.transform="",He.current.style.transition=""));const e=ke?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${De}px))`;Me.current&&(Me.current.style.transition=e,Me.current.style.transform=t),He.current&&(He.current.style.transition=e,He.current.style.transform=t)},[De,ke,Z]);const it=t=>{e.updateEvent(t.id,t)},lt=t=>{e.deleteEvent(t)},st=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(ee);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+Q),e>=t&&e<n},[ee,Q]);return p(()=>{if(t.scrollToCurrentTime&&Se.current){const e=Se.current,t=new Date,n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-$)*L-r/2)}},[]),h(()=>{ae(new Date);const e=setInterval(()=>ae(new Date),6e4);return()=>clearInterval(e)},[]),et("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:[et(Fa,{calendar:e,viewType:I.WEEK,currentDate:w,onPrevious:()=>{if(Z){const t=new Date(w);t.setDate(t.getDate()-1),X(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(Z){const t=new Date(w);t.setDate(t.getDate()+1),X(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),et(Lo,{app:e,weekDaysLabels:qe,mobileWeekDaysLabels:Xe,weekDates:at,fullWeekDates:ot,isSlidingView:Z,mobilePageStart:q,currentWeekStart:ee,gridWidth:G,allDayAreaHeight:Ye,organizedAllDaySegments:je,allDayLabelText:Je,isMobile:E,isTouch:k,showAllDay:A,calendarRef:a,allDayRowRef:Ne,topFrozenContentRef:Me,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:L,FIRST_HOUR:$,dragState:Be,isDragging:Ve,secondaryTimeSlots:tt,primaryTzLabel:nt,secondaryTzLabel:rt,handleMoveStart:ze,handleResizeStart:We,handleEventUpdate:it,handleEventDelete:lt,onDateChange:l,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,handleCreateAllDayEvent:Ue,handleDragOver:Ke,handleDrop:Ge,customDetailPanelContent:n,customEventDetailDialog:r}),et($o,{app:e,timeSlots:Qe,weekDaysLabels:qe,currentWeekStart:ee,currentWeekEvents:Le,eventLayouts:Fe,gridWidth:G,isMobile:E,isSlidingView:Z,isTouch:k,scrollerRef:Se,timeGridRef:C,leftFrozenContentRef:Ie,swipeContentRef:He,calendarRef:a,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Me.current){const e=Z?"calc(-100% / 3)":"0px",n=Z?`${De}px`:`-${t}px`;Me.current.style.transform=`translateX(calc(${e} + ${n}))`,Me.current.style.transition=Z&&ke?"transform 0.3s ease-out":"none"}},handleCreateStart:_e,handleTouchStart:(e,t,n)=>{if(!E&&!k)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;we.current=setTimeout(()=>{null==_e||_e({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{we.current&&(clearTimeout(we.current),we.current=null)},handleTouchMove:()=>{we.current&&(clearTimeout(we.current),we.current=null)},handleDragOver:Ke,handleDrop:Ge,dragState:Be,isDragging:Ve,handleMoveStart:ze,handleResizeStart:We,handleEventUpdate:it,handleEventDelete:lt,onDateChange:l,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,customDetailPanelContent:n,customEventDetailDialog:r,isCurrentWeek:st,currentTime:te,HOUR_HEIGHT:L,FIRST_HOUR:$,LAST_HOUR:j,showStartOfDayLabel:F,timeFormat:O,secondaryTimeSlots:tt}),et(z,{isOpen:ve,onClose:()=>{fe(!1),ye(null)},onSave:t=>{D.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),fe(!1),ye(null)},draftEvent:pe,app:e,timeFormat:O})]})},Yo={showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},Fo=(e={})=>{const t=Object.assign(Object.assign({},Yo),e),n=e=>a(Ho,{viewType:I.WEEK,originalComponent:jo,app:e.app,config:t,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="WeekViewAdapter",{type:I.WEEK,component:n,config:t}},zo=c(({currentMonth:t,currentYear:n,newlyCreatedEventId:r,screenSize:a,isScrolling:o,isDragging:i,showWeekNumbers:l,showMonthIndicator:s=!0,item:d,weekHeight:c,events:m,dragState:f,calendarRef:p,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onCreateStart:D,onResizeStart:x,onDetailPanelOpen:E,onMoreEventsClick:C,onChangeView:k,onSelectDate:T,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:H,onDetailPanelToggle:A,customDetailPanelContent:O,customEventDetailDialog:R,onCalendarDrop:P,onCalendarDragOver:L,app:$,enableTouch:j})=>{const{t:Y,locale:F}=vn(),[z,_]=u(!1),W=g(null),U=g(null),Z=g(null),[V,G]=u(null),K=v(()=>{const e=c-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)))}},[c]);h(()=>o?(_(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):z?(W.current=setTimeout(()=>{_(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[o,z]);const{weekData:q}=d,X=q.days.find(e=>1===e.day),J=`${c}px`,Q=v(()=>St(),[]),ee=v(()=>Ca(m,q.startDate),[m,q.startDate]),te=v(()=>((t,n)=>{const r=[],a=new Date(n);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),t.forEach(t=>{if(!t.start||!t.end)return void qe.warn("Event missing start or end date:",t);const o=B(t.start),i=B(t.end),l=new Date(o);l.setHours(0,0,0,0);const s=new Date(i);s.setHours(0,0,0,0);let d=new Date(s);if(!t.allDay&&0===i.getHours()&&0===i.getMinutes()&&0===i.getSeconds()){const e=i.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}const c=l.toDateString()!==d.toDateString();if(!c||t.allDay)if(c&&t.allDay){let l=new Date(o);l<n&&(l=new Date(n),l.setHours(0,0,0,0));const s=i>a?a:i;for(let a=o.getTime();a<=s.getTime();a+=864e5){const o=new Date(a);if(o<n)continue;const i=e.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});r.push(Object.assign(Object.assign({},t),{start:i,end:i,day:l.getDay()}))}}else r.push(Object.assign(Object.assign({},t),{start:t.start,end:t.end,day:o.getDay()}))}),r})(m,q.startDate),[m,q.startDate]),re=v(()=>{const e=new Map;return q.days.forEach(t=>{const n=t.date.toDateString();e.set(n,te.filter(e=>{if(!e.start||!e.end)return B(e.start).toDateString()===n;const t=B(e.start),r=B(e.end);if(!e.allDay){if(!(0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds())){const e=r.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n}}return t.toDateString()===n||r.toDateString()===n}))}),e},[te,q.days]),ae=v(()=>(e=>{const t=[...e].toSorted((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,r=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==r?r-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{var t;let r=0,a=!1;for(;!a;){let o=!1;for(const a of n){const n=Math.abs((null!==(t=a.yPosition)&&void 0!==t?t:0)-r)<16,i=!(e.endDayIndex<a.startDayIndex||e.startDayIndex>a.endDayIndex);if(n&&i){o=!0;break}}o?r+=16:a=!0}n.push(Object.assign(Object.assign({},e),{yPosition:r}))});const r=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);r[n]||(r[n]=[]),r[n].push(e)}),r.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),r})(ee),[ee]),oe=v(()=>ae.flat(),[ae]),le=v(()=>{const e=Array.from({length:7}).fill(0);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ae]),se=v(()=>{const e=Array.from({length:7},()=>new Set);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ae]),de=v(()=>{var e;for(let t=0;t<q.days.length;t++){const n=q.days[t],r=(null!==(e=re.get(n.date.toDateString()))&&void 0!==e?e:[]).filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),a=se[t],o=le[t]-1;let i=0;for(let e=0;e<=o;e++)a.has(e)||i++;if(o+1+Math.max(0,r.length-i)>K.maxSlots)return K.maxSlotsWithMore}return K.maxSlots},[q.days,re,oe,le,se,K.maxSlots,K.maxSlotsWithMore]),ce=v(()=>Math.max(0,17*ae.length),[ae]),ue=(e,o)=>{var s,d;const c=e.date.toLocaleDateString(F,{month:F.startsWith("zh")||F.startsWith("ja")?"short":"long"})===t&&e.year===n,u=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:ne(e.start)-ne(t.start)))(null!==(s=re.get(e.date.toDateString()))&&void 0!==s?s:[]),h=u.filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),g=se[o],m=(null!==(d=le[o])&&void 0!==d?d:0)-1,v=[];for(let e=0;e<=m;e++)g.has(e)||v.push(e);const z=h.length,_=Math.max(0,z-v.length),W=Math.max(m+1,0)+_,B=W>K.maxSlots,V=B?K.maxSlotsWithMore:K.maxSlots,q=v.filter(e=>e<V).length,X=Math.max(0,V-Math.max(m+1,0)),ee=Math.min(z,q+X),te=h.slice(0,ee),ae=z-ee,de=[];let ce=0;const ue=Math.min(V,W);for(let t=0;t<ue;t++)if(g.has(t))de.push(et("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(ce<te.length){const e=te[ce];de.push(et(ja,{event:e,isAllDay:!!e.allDay,viewType:I.MONTH,isBeingDragged:i&&f.eventId===e.id&&"move"===f.mode,calendarRef:p,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,onDetailPanelOpen:E,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:r,selectedEventId:N,detailPanelEventId:H,onDetailPanelToggle:A,customDetailPanelContent:O,customEventDetailDialog:R,app:$,isMobile:"desktop"!==a,enableTouch:j},`${e.id}-${e.day}-${ne(e.start)}-${ce}`)),ce++}return et("div",{className:nr("df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700",c?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===o?Q?"last:border-r":"border-r-0":""),style:{height:J},"data-date":(he=e.date,`${he.getFullYear()}-${String(he.getMonth()+1).padStart(2,"0")}-${String(he.getDate()).padStart(2,"0")}`),onClick:()=>null==T?void 0:T(e.date),onDblClick:t=>null==D?void 0:D(t,e.date),onTouchStart:t=>{if("mobile"!==a&&!j)return;const n=t.touches[0],r=n.clientX,o=n.clientY;Z.current={x:r,y:o},U.current=setTimeout(()=>{null==D||D(t,e.date),U.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(U.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(U.current),U.current=null)}},onTouchEnd:()=>{U.current&&(clearTimeout(U.current),U.current=null),Z.current=null},onDragOver:L,onDrop:t=>null==P?void 0:P(t,e.date),onContextMenu:t=>((e,t)=>{e.preventDefault(),"mobile"!==a&&G({x:e.clientX,y:e.clientY,date:t})})(t,e.date),children:[et("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[l&&0===o&&"mobile"!==a&&et("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:ie(e.date)}),et("span",{className:` 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 ${e.isToday?"bg-primary text-primary-foreground":c?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===e.day&&"desktop"===a?e.date.toLocaleDateString(F,{month:"short",day:"numeric"}):e.day})]}),et("div",{className:"flex-1 overflow-hidden px-1",children:[de,B&&et("div",{className:nr("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 relative z-20 bg-white dark:bg-gray-900","desktop"===a?"text-left font-normal":"text-center font-medium"),onClick:t=>{t.stopPropagation(),C?C(e.date):(null==T||T(e.date),null==k||k(I.DAY))},children:["+",ae,"desktop"===a?` ${Y("more")}`:""]})]})]},`day-${e.date.getTime()}`);var he},he=v(()=>X?X.date.toLocaleDateString(F,{month:"long",year:"numeric"}):"",[X,F]);return et("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:J},children:[s&&X&&et("div",{className:` df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300 ${z?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"} `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},onContextMenu:e=>e.preventDefault(),children:et("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:he})}),et("div",{className:"flex h-full flex-col",children:et("div",{className:"calendar-week relative h-full",children:[et("div",{className:"grid h-full grid-cols-7",children:q.days.map((e,t)=>ue(e,t))}),ae.length>0&&et("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ce}px`,zIndex:10},children:ae.slice(0,de).map((e,t)=>et("div",{className:"absolute inset-0",children:e.map(e=>et(ja,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,viewType:I.MONTH,isMultiDay:!0,calendarRef:p,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,isBeingDragged:i&&f.eventId===e.event.id&&"move"===f.mode,isBeingResized:i&&f.eventId===e.event.id&&"resize"===f.mode,newlyCreatedEventId:r,onDetailPanelOpen:E,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:H,onDetailPanelToggle:A,customDetailPanelContent:O,customEventDetailDialog:R,app:$,isMobile:"desktop"!==a,enableTouch:j},e.id))},`layer-${t}`))})]})}),V&&et(Da,{x:V.x,y:V.y,date:V.date,viewType:I.MONTH,onClose:()=>G(null),app:$,onCreateEvent:()=>{if(D){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:V.x,clientY:V.y};D(e,V.date)}}})]})});zo.displayName="WeekComponent";const _o=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,detailPanelEventId:l,onDetailPanelToggle:s})=>{var d;const{getWeekDaysLabels:c,getMonthLabels:f,locale:p}=vn(),y=e.getCurrentDate(),b=e.getEvents(),w=null!==(d=t.startOfWeek)&&void 0!==d?d:1,D=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),x=g(null),E=v(()=>{const e=x.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:(x.current=b,b)},[b]),C=v(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-w+7)%7;return t.setDate(t.getDate()-n),t.setHours(0,0,0,0),t},n=(t,n)=>{const r=e.get(t);r?r.push(n):e.set(t,[n])};return E.forEach(e=>{if(!e.start)return;const r=B(e.start),a=e.end?B(e.end):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=t(o),d=t(l);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},[E,w]),{screenSize:k}=gn(),[T,N]=u(!1);h(()=>{N("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const S=e.getCustomMobileEventRenderer()||Qr,[M,H]=u(119),[R,P]=u(!1),L=g(M),$=g([]),[j,Y]=u(null),[F,z]=u(!1),[_,W]=u(null),[U,Z]=u(null),[V,G]=u(null),K=void 0===o?U:o,q=void 0===l?V:l,X=m(e=>{i?i(e):Z(e)},[i]),J=m(e=>{s?s(e):G(e)},[s]),Q=g(e.state.highlightedEventId);h(()=>{e.state.highlightedEventId?X(e.state.highlightedEventId):Q.current&&X(null),Q.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const ee=v(()=>{const e=(y.getDay()-w+7)%7,t=new Date(y);return t.setDate(y.getDate()-e),t.setHours(0,0,0,0),t},[y,w]),{handleMoveStart:te,handleCreateStart:ne,handleResizeStart:re,dragState:ae,isDragging:oe}=Mo(e,{calendarRef:a,viewType:I.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(E),o=new Set(a.map(e=>e.id)),i=E.filter(e=>!o.has(e.id)),l=new Set(E.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=E.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===k?e.addEvent(t):(W(t),z(!0))},onEventEdit:e=>{Y(e.id)},currentWeekStart:ee,events:E}),{handleDrop:ie,handleDragOver:le}=ko({app:e,onEventCreated:e=>{Y(e.id)}}),se=v(()=>c(p,"short",w),[p,c,w]),{currentMonth:de,currentYear:ce,isScrolling:ue,virtualData:he,weeksData:ge,scrollElementRef:me,isNavigating:ve,handleScroll:fe,handlePreviousMonth:pe,handleNextMonth:ye,handleToday:be,setScrollTop:we}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:a="en-US",startOfWeek:o=1,isEnabled:i=!0})=>{const l=g(null),s=m((e,t)=>{const n=new Date(t,e,1),r=a.startsWith("zh")||a.startsWith("ja");return n.toLocaleDateString(a,{month:r?"short":"long"})},[a]),d=v(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),Me(t,r,o)},[e,r,o]),c=v(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=d.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[d,e,t]),[f,p]=u(c),[y,b]=u(600),[w,D]=u(s(e.getMonth(),e.getFullYear())),[x,E]=u(e.getFullYear()),[C,k]=u(!1),[T,N]=u(d),[S,M]=u(!1),I=g(!1),[H,R]=u(!1),P=g(e),L=g(null),$=g(null),j=g(new O),Y=g(0),F=g(0),z=g(!1),_=m(e=>{e&&(L.current=e)},[]),W=m(e=>{let t=j.current.get(e);return t||(t=Ne(e),j.current.set(e,t)),t},[]),U=m((e,n=26)=>{z.current||(z.current=!0,setTimeout(()=>{try{if("future"===e){const e=T.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(W(n))}N(e=>[...e,...t])}else{const e=T[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(W(n))}const a=r.length*t;N(e=>[...r,...e]),requestAnimationFrame(()=>{p(e=>e+a),L.current&&(L.current.scrollTop+=a)})}}finally{setTimeout(()=>{z.current=!1},200)}},0))},[T,W,t]),B=v(()=>{const e=T.length*t,n=Math.floor(f/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(T.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[f,y,t,T]),Z=m(e=>{if(S||C||0===e.length||!H)return;const t=f+y/2,r=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!r)return;const a={};r.weekData.days.forEach(e=>{const t=`${s(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",i=0,d=0;Object.entries(a).forEach(([e,t])=>{if(t>d){d=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(l.current?o===l.current.month&&i===l.current.year&&(l.current=null,o===w&&i===x||(D(o),E(i),null==n||n(o,i))):o===w&&i===x||(D(o),E(i),null==n||n(o,i)))},[y,w,x,S,C,n,f,H]),V=m(e=>{const n=performance.now();if(n-Y.current<A.SCROLL_THROTTLE)return;Y.current=n;const r=e.currentTarget,a=r.scrollTop;F.current=a,p(a),S||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!z.current&&U("future",26),a<10*t&&!z.current&&U("past",26)}),k(!0),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{k(!1)},A.SCROLL_DEBOUNCE)},[t,U,S]),G=m((e,n=!0)=>{if(!L.current)return;M(!0),I.current=!0;const r=()=>{setTimeout(()=>{M(!1),I.current=!1},n?500:200)},a=T.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return L.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const i=(e.getDay()-o+7)%7,l=new Date(e);l.setDate(e.getDate()-i),l.setHours(0,0,0,0);const s=T[0],d=T.at(-1);let c=0,u=!1,h=!1;l<s.startDate?(c=Math.ceil((s.startDate.getTime()-l.getTime())/6048e5),u=!0):l>d.startDate&&(c=Math.ceil((l.getTime()-d.startDate.getTime())/6048e5),h=!0);const g=Math.min(c+10,52);if(u){const a=[];for(let e=g;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(W(t))}const o=a.length*t;N(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==i){const e=i*t;L.current.scrollTop+=o,p(e=>e+o),setTimeout(()=>{L.current&&L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}r()})}else if(h){const a=[];for(let e=1;e<=g;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(W(t))}N(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==o){const e=o*t;L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,W]),K=m(()=>{const e=T[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);G(t)},[B.displayStartIndex,T,G]),q=m(()=>{const e=T[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);G(t)},[B.displayStartIndex,T,G]),X=m(()=>{const e=new Date,r=s(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);l.current={month:r,year:a},D(r),E(a),null==n||n(r,a);const i=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)M(!0),I.current=!0,requestAnimationFrame(()=>{G(o,!0),setTimeout(()=>{I.current=!1,M(!1)},200)});else{const e=i*t,n=L.current;n&&(M(!0),I.current=!0,requestAnimationFrame(()=>{p(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{I.current=!1,M(!1)},200))})}))}},[T,t,n,G]);return h(()=>{Z(B.visibleItems)},[B.visibleItems,Z]),h(()=>{const t=P.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){const t=6,r=B.displayStartIndex,a=Math.min(T.length-1,r+t-1);let d=!1;for(let t=r;t<=a;t++){const n=T[t];if(n&&n.days.some(t=>t.date.toDateString()===e.toDateString())){d=!0;break}}if(!d){const e=new Date(i,o,1),t=s(o,i);l.current={month:t,year:i},D(t),E(i),null==n||n(t,i),G(e,!0)}}P.current=e},[e,n,G,B,T,s]),h(()=>{const e=L.current;if(!e)return;const t=new ResizeObserver(([e])=>{b(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),h(()=>{const e=L.current;e&&!H&&i&&requestAnimationFrame(()=>{e&&c>0?(e.scrollTop=c,p(c),R(!0)):e&&R(!0)})},[H,c,i]),h(()=>()=>{$.current&&clearTimeout($.current)},[]),{scrollTop:f,containerHeight:y,currentMonth:w,currentYear:x,isScrolling:C,isNavigating:S,virtualData:B,scrollElementRef:L,handleScroll:V,scrollToDate:G,handlePreviousMonth:K,handleNextMonth:q,handleToday:X,setScrollTop:p,setContainerHeight:b,setCurrentMonth:D,setCurrentYear:E,setIsScrolling:k,cache:j.current,scrollElementRefCallback:_,weeksData:T}})({currentDate:y,weekHeight:M,onCurrentMonthChange:(t,n)=>{const r=p.startsWith("zh")||p.startsWith("ja"),a=f(p,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:p,startOfWeek:w,isEnabled:R}),De=g(0),[xe,Ee]=u(0),Ce=v(()=>xe-6*M,[xe,M]),{visibleWeeks:ke,startIndex:Te}=v(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=he,a=n.findIndex(e=>e.index===r);if(-1===a)return $.current.length>0?{visibleWeeks:$.current,startIndex:De.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),i=n.slice(o,a+8),l=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return i.length>=6&&($.current=i,De.current=l),{visibleWeeks:i,startIndex:l}},[he]),Se=v(()=>Te*M,[Te,M]),Ie=g(!0),He=g(!1),Ae=((e,t)=>{const[n,r]=u(e);return h(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(he.displayStartIndex,250);h(()=>{ve&&(He.current=!0)},[ve]),h(()=>{if(Ie.current)return void(Ie.current=!1);const t=ge[Ae];if(!t)return;const n=new Date(t.startDate);n.setHours(0,0,0,0);const r=new Date(n);r.setDate(r.getDate()+42+7),e.emitVisibleRange(n,r,He.current?"navigation":"scroll"),He.current=!1},[e,ge,Ae]);const Oe=v(()=>{const e=he.totalHeight,t=Te*M+ke.length*M+Ce;return Math.max(0,e-t)},[he.totalHeight,Te,M,Ce,ke.length]);h(()=>{const e=me.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Ee(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==L.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/L.current)*n;e.scrollTop=r,we(r)}H(n),L.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[me,we]),h(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));H(t),L.current=t,P(!0)},[]);const Re=m(t=>{e.updateEvent(t.id,t)},[e]),Pe=m(t=>{e.deleteEvent(t)},[e]),Le=t=>{e.changeView(t)},$e=m(()=>Y(null),[]),je=m(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==k||T)&&t&&n){const e=E.find(e=>e.id===t);if(e)return W(e),void z(!0)}X(t)},[k,T,E,X,e]),Ye=m(e=>{("desktop"!==k||T)&&X(e)},[k,T,X]);return et("div",{className:bn,children:[et(Fa,{calendar:e,viewType:I.MONTH,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${ce}年${de}`:`${de} ${ce}`,onPrevious:()=>{e.goToPrevious(),pe()},onNext:()=>{e.goToNext(),ye()},onToday:()=>{e.goToToday(),be()}}),et("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",onContextMenu:e=>e.preventDefault(),children:et("div",{className:"grid grid-cols-7 px-2",children:se.map((e,t)=>et("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),et("div",{ref:me,className:Cn,style:{overflow:"hidden auto",visibility:R?"visible":"hidden"},onScroll:fe,children:[et("div",{style:{height:Se}}),ke.map((o,i)=>{var l;const s=null!==(l=C.get(o.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===i?Object.assign(Object.assign({},o),{height:o.height+Ce}):o,c=!(!1===t.showMonthIndicator||!o.weekData.days.some(e=>1===e.day))&&ue;return et(zo,{item:d,weekHeight:M,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:de,currentYear:ce,screenSize:k,isScrolling:c,calendarRef:a,events:s,onEventUpdate:Re,onEventDelete:Pe,onMoveStart:te,onCreateStart:ne,onResizeStart:re,isDragging:oe,dragState:ae,newlyCreatedEventId:j,onDetailPanelOpen:$e,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Le,onSelectDate:e.selectDate,selectedEventId:K,onEventSelect:je,onEventLongPress:Ye,detailPanelEventId:q,onDetailPanelToggle:J,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:ie,onCalendarDragOver:le,calendarSignature:D,app:e,enableTouch:T},`week-${o.weekData.startDate.getTime()}`)}),et("div",{style:{height:Oe}})]}),et(S,{isOpen:F,onClose:()=>{z(!1),W(null)},onSave:t=>{E.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),z(!1),W(null)},draftEvent:_,app:e})]})},Wo={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Uo=(e={})=>{const t=Object.assign(Object.assign({},Wo),e),n=e=>a(Ho,{viewType:I.MONTH,originalComponent:_o,app:e.app,config:t,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="MonthViewAdapter",{type:I.MONTH,component:n,config:t}};const Bo=c(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=vn(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return et("div",{className:`relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800 ${c?"border-l-2 border-l-primary dark:border-l-primary":""} overflow-hidden bg-white select-none dark:bg-gray-900`,style:{aspectRatio:"1/1"},onClick:()=>r(e),onDblClick:t=>null==a?void 0:a(t,e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),null==l||l(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[et("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&et("span",{className:"rounded-sm bg-primary px-1 py-0.5 text-[9px] leading-none font-bold text-primary-foreground",children:u}),et("span",{className:"ml-auto text-[10px] font-medium "+(t?"flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground":"text-gray-700 dark:text-gray-300"),children:d})]}),i>0&&et("div",{className:"absolute bottom-0.5 left-1 z-20",children:et("span",{className:"cursor-pointer text-xs font-medium text-gray-500 hover:text-gray-700 hover:underline dark:text-gray-400 dark:hover:text-gray-200",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",i," ",s("more")]})})]})});Bo.displayName="YearDayCell";const Zo=c(({rowDays:e,events:t,columnsPerRow:n,app:r,calendarRef:a,locale:o,isDragging:i,dragState:l,onMoveStart:s,onResizeStart:d,onCreateStart:c,selectedEventId:u,onEventSelect:h,onMoreEventsClick:g,newlyCreatedEventId:m,onDetailPanelOpen:f,detailPanelEventId:p,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:w,onContextMenu:D})=>{const x=new Date;x.setHours(0,0,0,0);const E=(e,t)=>{e.preventDefault(),e.stopPropagation(),D({x:e.clientX,y:e.clientY,date:t})},C=v(()=>function(e,t,n){if(0===t.length)return[];const r=t[0],a=t.at(-1),o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),i=new Date(a.getFullYear(),a.getMonth(),a.getDate(),23,59,59,999).getTime(),l=e.filter(e=>{if(!e.start)return!1;const t=B(e.start),n=e.end?B(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=i&&a>=o});l.sort((e,t)=>{const n=B(e.start).getTime(),r=e.end?B(e.end).getTime():n,a=B(t.start).getTime(),o=r-n,i=(t.end?B(t.end).getTime():a)-a;return o!==i?i-o:n-a});const s=[],d=[];return l.forEach(e=>{const a=B(e.start),l=e.end?B(e.end):a,c=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();let h=-1,g=-1;const m=Math.round((c-o)/864e5);h=m>=0?m:0;const v=Math.round((u-o)/864e5);g=v<t.length?v:t.length-1,h=Math.max(0,Math.min(h,n-1)),g=Math.max(0,Math.min(g,n-1));const f=c>=o,p=u<=i;let y=0;for(;;){let e=!1;d[y]||(d[y]=[]);for(let t=h;t<=g;t++)if(d[y][t]){e=!0;break}if(!e){for(let e=h;e<=g;e++)d[y][e]=!0;break}y++}s.push({id:`${e.id}_${r.getTime()}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:f,isLastSegment:p,visualRowIndex:y})}),s}(t,e,n),[t,e,n]),{visibleSegments:k,moreCounts:T}=v(()=>{const t=Array.from({length:e.length}).fill(0);C.forEach(n=>{const r=Math.max(0,n.startCellIndex),a=Math.min(e.length-1,n.endCellIndex);for(let e=r;e<=a;e++)t[e]++});const n=[],r=Array.from({length:e.length}).fill(0);return C.forEach(a=>{let o=!0;const i=Math.max(0,a.startCellIndex),l=Math.min(e.length-1,a.endCellIndex);for(let e=i;e<=l;e++){const n=t[e]>3?1:2;if(a.visualRowIndex>n){o=!1;break}}if(o)n.push(a);else for(let e=i;e<=l;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[C,e.length]);return et("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`},onContextMenu:e=>e.preventDefault(),children:[e.map((e,t)=>{const n=e.getTime()===x.getTime();return et(Bo,{date:e,isToday:n,locale:o,onSelectDate:e=>{r.selectDate(e)},onCreateStart:c,onMoreEventsClick:g,moreCount:T[t],onContextMenu:E},e.getTime())}),et("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:et("div",{className:"relative h-full w-full",children:k.map(e=>et("div",{className:"pointer-events-auto",children:et(ja,{event:e.event,viewType:I.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:i&&l.eventId===e.event.id,selectedEventId:u,onMoveStart:s,onResizeStart:d,onEventSelect:h,onDetailPanelToggle:y,newlyCreatedEventId:m,onDetailPanelOpen:f,calendarRef:a,app:r,detailPanelEventId:p,customDetailPanelContent:b,customEventDetailDialog:w,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e)})},e.id))})})]})});Zo.displayName="YearRowComponent";const Vo=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:f,locale:p}=vn(),y=t.getCurrentDate(),b=y.getFullYear(),w=t.getEvents(),D=g(null),[x,E]=u(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[C,k]=u(!1),[T,N]=u(null),[S,M]=u(null),H=void 0===i?T:i,A=void 0===s?S:s,O=e=>{l?l(e):N(e)},R=e=>{d?d(e):M(e)},[P,L]=u(null),[$,j]=u(null);h(()=>{const e=e=>{if(2===e.button)return;const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),i=t.closest("[data-calendar-picker-dropdown]"),l=t.closest(".df-context-menu");n||r||a||o||i||l||(O(null),R(null),j(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=g(null);h(()=>{const e=D.current;if(!e)return;const t=new ResizeObserver(e=>{Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);E(Math.max(1,n)),k(!0)},60)});return t.observe(e),()=>{t.disconnect(),Y.current&&clearTimeout(Y.current)}},[]);const F=g(t.state.highlightedEventId);h(()=>{t.state.highlightedEventId?O(t.state.highlightedEventId):F.current&&O(null),F.current=t.state.highlightedEventId},[t.state.highlightedEventId]);const{handleMoveStart:z,handleResizeStart:_,handleCreateStart:W,dragState:U,isDragging:Z}=Mo(t,{calendarRef:n,viewType:I.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(w).filter(e=>{const t=w.find(t=>t.id===e.id);return t&&Ze(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:w,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{L(e.id)}}),V=null!==(c=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==c&&c,G=m((n,r)=>{if(V)null==W||W(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:f("newEvent")||"New Event",start:n,end:n,allDay:!0,calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"};t.addEvent(a),L(a.id)}},[V,W,t,f]),K=v(()=>{const e=[],t=new Date(b,0,1),n=new Date(b,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[b]),q=v(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(K,x),[K,x]),X=v(()=>{const e=new Date(b,0,1),t=new Date(b,11,31,23,59,59);return w.filter(n=>{if(!n.start)return!1;if(!V&&!n.allDay)return!1;const r=B(n.start),a=n.end?B(n.end):r;return r<=t&&a>=e})},[w,b,V]);return et("div",{className:bn,onContextMenu:e=>e.preventDefault(),children:[et(Fa,{calendar:t,viewType:I.YEAR,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${b}年`:`${b}`,onPrevious:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}}),et("div",{ref:D,className:`${Cn} ${kn}`,style:{overflow:"hidden auto"},children:et("div",{className:"flex w-full flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:C?1:0,transition:"opacity 0.2s ease"},children:q.map((e,o)=>et(Zo,{rowDays:e,events:X,columnsPerRow:x,app:t,calendarRef:n,locale:p,isDragging:Z,dragState:U,onMoveStart:z,onResizeStart:_,onCreateStart:G,selectedEventId:H,onEventSelect:O,onMoreEventsClick:t.onMoreEventsClick,newlyCreatedEventId:P,onDetailPanelOpen:()=>L(null),detailPanelEventId:A,onDetailPanelToggle:R,customDetailPanelContent:r,customEventDetailDialog:a,onContextMenu:j},o))})}),$&&et(Da,{x:$.x,y:$.y,date:$.date,viewType:I.YEAR,onClose:()=>j(null),app:t,onCreateEvent:()=>{if($&&$.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:$.x,clientY:$.y};G(e,$.date)}}})]})};function Go(e,t,n,r=1){const a=new Date(n,t,1),o=new Date(n,t+1,0).getDate(),i=(a.getDay()-r+7)%7,l=a.getTime(),s=new Date(n,t,o,23,59,59,999).getTime(),d=e.filter(e=>{if(!e.start)return!1;const t=B(e.start),n=e.end?B(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=s&&a>=l});d.sort((e,t)=>{const n=B(e.start).getTime(),r=e.end?B(e.end).getTime():n,a=B(t.start).getTime(),o=r-n,i=(t.end?B(t.end).getTime():a)-a;return o!==i?i-o:n-a});const c=[],u=[];d.forEach(e=>{const r=B(e.start),a=e.end?B(e.end):r,o=new Date(Math.max(r.getTime(),l)),d=new Date(Math.min(a.getTime(),s)),h=o.getDate(),g=d.getDate(),m=i+(h-1),v=i+(g-1),f=r.getMonth()===t&&r.getFullYear()===n,p=a.getMonth()===t&&a.getFullYear()===n;let y=0;for(;;){let e=!1;u[y]||(u[y]=[]);for(let t=m;t<=v;t++)if(u[y][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)u[y][e]=!0;break}y++}c.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:p,visualRowIndex:y,monthIndex:t})});const h=c.length>0?Math.max(...c.map(e=>e.visualRowIndex)):-1;return{segments:c,maxVisualRow:h}}const Ko=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,f;const{t:p,locale:y,getWeekDaysLabels:b}=vn(),w=t.getCurrentDate(),D=w.getFullYear(),x=t.getEvents(),E=new Date;E.setHours(0,0,0,0);const C=null!==(c=null==o?void 0:o.startOfWeek)&&void 0!==c?c:1,k=g(null),T=g(null),N=g(null),[S,M]=u(0),[H,A]=u(0),[O,R]=u(null),[P,L]=u(null),$=void 0===i?O:i,j=void 0===s?P:s,Y=e=>{l?l(e):R(e)},F=e=>{d?d(e):L(e)},[z,_]=u(null),[W,U]=u(null);h(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),i=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||i||(Y(null),F(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Z=v(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(D,t,1),r=new Date(D,t+1,0).getDate(),a=(n.getDay()-C+7)%7+r;a>e&&(e=a)}return e},[D,C]),{handleMoveStart:V,handleResizeStart:G,handleCreateStart:K,dragState:q,isDragging:X}=Mo(t,{calendarRef:n,viewType:I.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(x).filter(e=>{const t=x.find(t=>t.id===e.id);return t&&Ze(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:x,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{_(e.id)}}),J=null!==(f=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==f&&f,Q=m((n,r)=>{if(J)null==K||K(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:p("newEvent")||"New Event",start:n,end:n,allDay:!0};t.addEvent(a),_(a.id)}},[J,K,t]),ee=v(()=>{const e=b(y,"short",C).map(e=>{if(y.startsWith("zh"))return e.at(-1);const t=e.slice(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),t=[];for(let n=0;n<Z;n++)t.push(e[n%7]);return t},[y,b,Z,C]),te=v(()=>{const e=new Date(D,0,1),t=new Date(D,11,31,23,59,59);return x.filter(n=>{if(!n.start)return!1;if(!J&&!n.allDay)return!1;const r=B(n.start),a=n.end?B(n.end):r;return r<=t&&a>=e})},[x,D,J]),ne=v(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(D,t,1),r=new Date(D,t+1,0).getDate(),a=(n.getDay()-C+7)%7,o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=r;e++)o.push(new Date(D,t,e));for(;o.length<Z;)o.push(null);const i=n.toLocaleDateString(y,{month:"short"}),l=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Go(te,t,D,C),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:l,days:o,eventSegments:s,minHeight:u})}return e},[D,y,Z,te,C]),re=m(e=>{const t=e.currentTarget;k.current&&(k.current.scrollLeft=t.scrollLeft),T.current&&(T.current.scrollTop=t.scrollTop)},[]);h(()=>{const e=()=>{if(N.current){const e=N.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;A(e=>e===t?e:t),M(e=>e===n?e:n)}},t=N.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[ne]);return et("div",{className:"h-full overflow-hidden bg-white select-none dark:bg-gray-900",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"col-span-2",children:et(Fa,{calendar:t,viewType:I.YEAR,currentDate:w,customTitle:y.startsWith("zh")||y.startsWith("ja")?`${D}年`:`${D}`,onPrevious:()=>{const e=new Date(w);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(w);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}})}),et("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),et("div",{ref:k,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:et("div",{className:"flex",style:{minWidth:`calc(1352px + ${S}px)`},children:[et("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`,minWidth:"1352px"},children:ee.map((e,t)=>{const n=(t+C)%7;return et("div",{className:"border-r border-gray-200 py-2 text-center text-[10px] font-bold tracking-wider text-gray-500 dark:border-gray-700 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},`label-${t}`)})}),S>0&&et("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${S}px`}})]})}),et("div",{ref:T,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:et("div",{className:"flex min-h-full flex-col",children:[ne.map(e=>et("div",{className:"flex shrink-0 grow items-center justify-center border-b border-gray-200 text-[10px] font-bold text-gray-500 dark:border-gray-700 dark:text-gray-400",style:{minHeight:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),H>0&&et("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${H}px`}})]})}),et("div",{ref:N,className:`overflow-auto ${kn}`,onScroll:re,children:et("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:ne.map(e=>et("div",{className:"relative shrink-0 grow",style:{minHeight:`${e.minHeight}px`},children:[et("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:e.days.map((n,r)=>{const a=(r+C)%7,o=0===a||6===a;if(!n)return et("div",{className:"border-r border-b border-gray-200 bg-gray-50/80 dark:border-gray-700 dark:bg-gray-800/40 "+(o?"df-year-view-weekend-cell":"")},`empty-${e.monthIndex}-${r}`);const i=(e=>e.getTime()===E.getTime())(n);return et("div",{"data-date":`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,className:`relative flex cursor-pointer items-start justify-end border-r border-b border-gray-200 p-0.5 transition-colors hover:bg-blue-100 dark:border-gray-700 dark:hover:bg-primary/20 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>t.selectDate(n),onDblClick:e=>Q(e,n),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),U({x:e.clientX,y:e.clientY,date:t})})(e,n),children:et("span",{className:`flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium ${i?"bg-primary font-bold text-primary-foreground shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:n.getDate()})},n.getTime())})}),e.eventSegments.length>0&&et("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:et("div",{className:"relative h-full w-full",children:e.eventSegments.map(e=>et("div",{className:"pointer-events-auto",children:et(ja,{event:e.event,viewType:I.YEAR,yearSegment:e,columnsPerRow:Z,isBeingDragged:X&&q.eventId===e.event.id,selectedEventId:$,onMoveStart:V,onResizeStart:G,onEventSelect:Y,onDetailPanelToggle:F,newlyCreatedEventId:z,onDetailPanelOpen:()=>_(null),calendarRef:n,app:t,detailPanelEventId:j,customDetailPanelContent:r,customEventDetailDialog:a,firstHour:0,hourHeight:0,onEventUpdate:e=>t.updateEvent(e.id,e),onEventDelete:e=>t.deleteEvent(e)})},e.id))})})]},e.monthIndex))})}),W&&et(Da,{x:W.x,y:W.y,date:W.date,viewType:I.YEAR,onClose:()=>U(null),app:t,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:W.x,clientY:W.y};Q(e,W.date)}})]})},qo=e=>{var t;return et("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?Ko:Vo,Object.assign({},e))},Xo={startOfWeek:1},Jo=(e={})=>{const t=Object.assign(Object.assign({},Xo),e),n=e=>a(Ho,{viewType:I.YEAR,originalComponent:qo,app:e.app,config:t,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="YearViewAdapter",{type:I.YEAR,component:n,config:t}};function Qo(e){return[Oo(null==e?void 0:e.day),Fo(null==e?void 0:e.week),Uo(null==e?void 0:e.month)]}const ei={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function ti(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);return r.setDate(n),r.setHours(0,0,0,0),r}function ni(e={}){const t=Object.assign(Object.assign({},ei),e);let n;const r={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=r.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(r.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=ti(n.getCurrentDate()),t=je(n.getAllEvents(),e);n.state.events=t}},update:(e,a)=>{const o=r.getById(e);if(!o)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},o),a);if(t.enableValidation){const e=r.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,a),t.enableAutoRecalculate){const e=ti(n.getCurrentDate()),t=je(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=B(t.start);n.setHours(0,0,0,0);const r=new Date(e);return r.setHours(0,0,0,0),n.getTime()===r.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const r=B(n.start),a=B(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=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)=>je(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)};return{name:"events",config:t,install:e=>{n=e},api:r}}export{Rr as BlossomColorPicker,Je as CalendarApp,ce as CalendarRegistry,ua as CalendarRenderer,cr as Check,ar as ChevronRight,ur as ChevronsUpDown,yn as ContentSlot,ha as ContextMenu,wa as ContextMenuColorPicker,ga as ContextMenuItem,va as ContextMenuLabel,ma as ContextMenuSeparator,$r as CreateCalendarDialog,ca as CustomRenderingStore,Pr as DefaultColorPicker,H as LAYOUT_CONFIG,T as LOCALES,mn as LocaleContext,Sr as LocaleProvider,qr as MiniCalendar,wr as PanelRightClose,Dr as PanelRightOpen,sr as Plus,ye as TIME_STEP,R as TimeZone,A as VIRTUAL_MONTH_SCROLL_CONFIG,I as ViewType,O as WeekDataCache,Q as addDays,Dt as buildParseRegExp,Le as calculateDayIndex,_n as calendarPickerDropdown,xn as cancelButton,Cr as capitalize,Gt as clipboardStore,Ht as conditionalTheme,_t as convertDateEvent,Wt as convertDateEventWithTimeZone,ln as convertToDayFlowEvent,Ft as createAllDayEvent,re as createDateWithHour,Oo as createDayView,Lt as createEvent,Pe as createEventWithDate,We as createEventWithPlainDateTime,ze as createEventWithRealDate,Ue as createEventWithZonedDateTime,jt as createEvents,ni as createEventsPlugin,Uo as createMonthView,Qo as createStandardViews,Z as createTemporalWithHour,zt as createTimedEvent,$t as createTimezoneEvent,Yt as createTimezoneEvents,Fo as createWeekView,Jo as createYearView,st as dateToPlainDate,dt as dateToPlainDateTime,ct as dateToZonedDateTime,X as daysBetween,J as daysDifference,cn as downloadICS,k as en,Qt as escapeICSValue,ne as extractHourFromDate,gt as extractHourFromTemporal,an as extractVEvents,tn as foldLine,rt as formatDate,tt as formatDateConsistent,Jt as formatDateToICSTimestamp,De as formatEventTimeRange,Xt as formatICSDate,nt as formatMonthYear,nn as formatProperty,kt as formatTemporal,be as formatTime,ke as generateDayData,dn as generateICS,Ee as generateSecondaryTimeSlots,Ge as generateUniKey,rn as generateVEvent,Ne as generateWeekData,Me as generateWeekRange,Se as generateWeeksData,He as getAllDayEventsForDay,ge as getCalendarColorsForHex,F as getCurrentWeekDates,Ae as getDateByDayIndex,Ut as getDateObj,Ye as getDayIndexByDate,oe as getEndOfDay,q as getEndOfTemporal,me as getEventBgColor,we as getEventEndHour,ve as getEventTextColor,Ie as getEventsForDay,Fe as getEventsForWeek,Er as getIntlLabel,pe as getLineColor,Tr as getMonthLabels,Te as getMonthYearOfWeek,vt as getPlainDate,Zt as getSearchHeaderInfo,fe as getSelectedBgColor,ae as getStartOfDay,K as getStartOfTemporal,Ve as getTestEvents,Ce as getTimezoneDisplayLabel,kr as getWeekDaysLabels,ie as getWeekNumber,Y as getWeekRange,Et as getZoneId,Vt as groupSearchResults,Ze as hasEventChanged,un as importICSFile,_ as isDate,Ke as isDeepEqual,Be as isEventDeepEqual,$e as isEventInWeek,se as isMultiDayEvent,G as isMultiDayTemporalEvent,at as isPlainDate,ot as isPlainDateTime,le as isSameDay,V as isSamePlainDate,ft as isSameTemporal,M as isValidLocale,it as isZonedDateTime,At as mergeClasses,bt as mergeFormatTemplate,$ as monthNames,Tt as normalizeCssWidth,Bt as normalizeDate,S as normalizeLocale,Ct as normalizeToZoned,ee as now,yt as pad,Kt as pad2,sn as parseICS,qt as parseICSDate,xt as parseTemporalString,on as parseVEventLines,ut as plainDateTimeToDate,ht as plainDateToDate,je as recalculateEventDays,No as registerDragImplementation,N as registerLocale,oa as registerSidebarImplementation,Ot as resolveAppliedTheme,xe as roundToTimeStep,St as scrollbarTakesSpace,mt as setHourInTemporal,j as shortMonthNames,Bn as sidebarContainer,Zn as sidebarHeader,Gn as sidebarHeaderTitle,Vn as sidebarHeaderToggle,Nr as t,lt as temporalToDate,It as themeClasses,Mt as themeCn,te as today,en as unescapeICSValue,Oe as updateEventDateAndDay,_e as updateEventWithRealDate,Mo as useDragForView,vn as useLocale,la as useSidebarBridge,P as weekDays,L as weekDaysFullName,U as zonedDateTimeToDate};
1
+ import{Temporal as e}from"temporal-polyfill";import{options as t,createContext as n,Fragment as r,h as a,render as o,isValidElement as i,cloneElement as l}from"preact";import{createPortal as s,forwardRef as d,memo as c}from"preact/compat";export{createPortal}from"preact/compat";import{useState as u,useEffect as h,useRef as g,useCallback as m,useMemo as v,useContext as f,useLayoutEffect as p}from"preact/hooks";import{__awaiter as y,__rest as b}from"tslib";import{BlossomColorPicker as w,hexToHsl as D,lightnessToSliderValue as x,DEFAULT_COLORS as E,hslToHex as C}from"@dayflow/blossom-color-picker";const k={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",viewEvent:"View 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",cut:"Cut",copy:"Copy",pasteHere:"Paste Here",eventSummary:"Summary"}},T={en:k};function N(e){const t=e.code.split("-")[0].toLowerCase();T[t]=e}function S(e){const t=e.split("-")[0].toLowerCase();return t in T?t:"en"}function M(e){try{new Intl.DateTimeFormat(e);return!0}catch(e){return!1}}var I;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(I||(I={}));const A={INDENT_STEP:2,MIN_WIDTH:25,MARGIN_BETWEEN:2,CONTAINER_WIDTH:320,OVERLAP_THRESHOLD:.25,EDGE_MARGIN:3,MAX_LOAD_IMBALANCE:0,REBALANCE_THRESHOLD:2},H={OVERSCAN:6,BUFFER_SIZE:100,MIN_YEAR:1900,MAX_YEAR:2200,SCROLL_THROTTLE:8,SCROLL_DEBOUNCE:150,CACHE_CLEANUP_THRESHOLD:200,MOBILE_WEEK_HEIGHT:80,TABLET_WEEK_HEIGHT:90,WEEK_HEIGHT:119};class O{constructor(e=H.BUFFER_SIZE){this.cache=new Map,this.accessOrder=[],this.maxSize=e}static getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=O.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=O.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=[]}}var R;!function(e){e.UTC="UTC",e.NEW_YORK="America/New_York",e.CHICAGO="America/Chicago",e.DENVER="America/Denver",e.LOS_ANGELES="America/Los_Angeles",e.TORONTO="America/Toronto",e.VANCOUVER="America/Vancouver",e.PHOENIX="America/Phoenix",e.ANCHORAGE="America/Anchorage",e.HONOLULU="Pacific/Honolulu",e.MEXICO_CITY="America/Mexico_City",e.WINNIPEG="America/Winnipeg",e.HALIFAX="America/Halifax",e.ST_JOHNS="America/St_Johns",e.DETROIT="America/Detroit",e.MIAMI="America/Miami",e.SEATTLE="America/Los_Angeles",e.ATLANTA="America/New_York",e.DALLAS="America/Chicago",e.HOUSTON="America/Chicago",e.LAS_VEGAS="America/Los_Angeles",e.SAN_FRANCISCO="America/Los_Angeles",e.LONDON="Europe/London",e.PARIS="Europe/Paris",e.BERLIN="Europe/Berlin",e.MADRID="Europe/Madrid",e.ROME="Europe/Rome",e.AMSTERDAM="Europe/Amsterdam",e.ZURICH="Europe/Zurich",e.STOCKHOLM="Europe/Stockholm",e.OSLO="Europe/Oslo",e.COPENHAGEN="Europe/Copenhagen",e.MOSCOW="Europe/Moscow",e.ISTANBUL="Europe/Istanbul",e.DUBLIN="Europe/Dublin",e.LISBON="Europe/Lisbon",e.PRAGUE="Europe/Prague",e.VIENNA="Europe/Vienna",e.WARSAW="Europe/Warsaw",e.BRUSSELS="Europe/Brussels",e.ATHENS="Europe/Athens",e.BUCHAREST="Europe/Bucharest",e.HELSINKI="Europe/Helsinki",e.KYIV="Europe/Kyiv",e.BUDAPEST="Europe/Budapest",e.BELGRADE="Europe/Belgrade",e.LUXEMBOURG="Europe/Luxembourg",e.MONACO="Europe/Monaco",e.REYKJAVIK="Atlantic/Reykjavik",e.TOKYO="Asia/Tokyo",e.SHANGHAI="Asia/Shanghai",e.BEIJING="Asia/Shanghai",e.HONG_KONG="Asia/Hong_Kong",e.TAIPEI="Asia/Taipei",e.SEOUL="Asia/Seoul",e.SINGAPORE="Asia/Singapore",e.HANOI="Asia/Ho_Chi_Minh",e.BANGKOK="Asia/Bangkok",e.JAKARTA="Asia/Jakarta",e.KUALA_LUMPUR="Asia/Kuala_Lumpur",e.MANILA="Asia/Manila",e.DUBAI="Asia/Dubai",e.KOLKATA="Asia/Kolkata",e.MUMBAI="Asia/Kolkata",e.RIYADH="Asia/Riyadh",e.TEHRAN="Asia/Tehran",e.JERUSALEM="Asia/Jerusalem",e.TEL_AVIV="Asia/Tel_Aviv",e.BAGHDAD="Asia/Baghdad",e.DHAKA="Asia/Dhaka",e.KARA_CHI="Asia/Karachi",e.KABUL="Asia/Kabul",e.KATHMANDU="Asia/Kathmandu",e.COLOMBO="Asia/Colombo",e.TASHKENT="Asia/Tashkent",e.ALMATY="Asia/Almaty",e.PHNOM_PENH="Asia/Phnom_Penh",e.VIENTIANE="Asia/Vientiane",e.MUSCAT="Asia/Muscat",e.SYDNEY="Australia/Sydney",e.MELBOURNE="Australia/Melbourne",e.BRISBANE="Australia/Brisbane",e.PERTH="Australia/Perth",e.ADELAIDE="Australia/Adelaide",e.DARWIN="Australia/Darwin",e.HOBART="Australia/Hobart",e.AUCKLAND="Pacific/Auckland",e.FIJI="Pacific/Fiji",e.GUAM="Pacific/Guam",e.NOUMEA="Pacific/Noumea",e.PAGO_PAGO="Pacific/Pago_Pago",e.PORT_MORESBY="Pacific/Port_Moresby",e.SAO_PAULO="America/Sao_Paulo",e.RIO_DE_JANEIRO="America/Sao_Paulo",e.BUENOS_AIRES="America/Argentina/Buenos_Aires",e.SANTIAGO="America/Santiago",e.LIMA="America/Lima",e.BOGOTA="America/Bogota",e.CARACAS="America/Caracas",e.LA_PAZ="America/La_Paz",e.MONTEVIDEO="America/Montevideo",e.QUITO="America/Quito",e.ASUNCION="America/Asuncion",e.GEORGETOWN="America/Guyana",e.CAIRO="Africa/Cairo",e.JOHANNESBURG="Africa/Johannesburg",e.LAGOS="Africa/Lagos",e.NAIROBI="Africa/Nairobi",e.CASABLANCA="Africa/Casablanca",e.ALGIERS="Africa/Algiers",e.TUNIS="Africa/Tunis",e.ADDIS_ABABA="Africa/Addis_Ababa",e.ACCRA="Africa/Accra",e.DAKAR="Africa/Dakar",e.LUANDA="Africa/Luanda",e.ANTANANARIVO="Indian/Antananarivo",e.KINSHASA="Africa/Kinshasa",e.DAR_ES_SALAAM="Africa/Dar_es_Salaam",e.MCMURDO="Antarctica/McMurdo",e.CASEY="Antarctica/Casey"}(R||(R={}));const P=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],L=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],$=["January","February","March","April","May","June","July","August","September","October","November","December"],j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Y=(e,t=1)=>{const n=(e.getDay()-t+7)%7,r=new Date(e);r.setDate(e.getDate()-n),r.setHours(0,0,0,0);const a=new Date(r);return a.setDate(r.getDate()+6),a.setHours(23,59,59,999),{monday:r,sunday:a}},F=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return P.map((e,a)=>{const o=new Date(t);return o.setDate(t.getDate()-r+a),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===n.getDate()&&o.getMonth()===n.getMonth()&&o.getFullYear()===n.getFullYear()}})};function z(t){var n;if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;if(t instanceof e.PlainDate)return!0;const r=t;return"PlainDate"===(null===(n=r.constructor)||void 0===n?void 0:n.name)||!("hour"in r)&&!("timeZone"in r)&&"year"in r&&"month"in r&&"day"in r}function _(e){return e instanceof Date}function W(t,n=e.Now.timeZoneId()){return e.Instant.fromEpochMilliseconds(t.getTime()).toZonedDateTimeISO(n)}function U(e){if("number"==typeof e.epochMilliseconds)return new Date(e.epochMilliseconds);const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute)}function B(t,n){if(t instanceof Date)return t;if(z(t))return function(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime)try{return U(t.toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(t.year,t.month-1,t.day)}(t,n);if(t&&"object"==typeof t&&"hour"in t&&!("timeZone"in t)){const e=t;return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}return t&&"object"==typeof t&&"year"in t?U(t):new Date(t)}function Z(t,n){const r=Math.floor(n),a=Math.round(60*(n-r));if(z(t))return e.PlainDateTime.from({year:t.year,month:t.month,day:t.day,hour:r,minute:a});if("function"==typeof t.with)return t.with({hour:r,minute:a,second:0,millisecond:0});const o=t;return e.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function V(t,n){if(t instanceof Date&&n instanceof Date)return t.toDateString()===n.toDateString();const r=t=>{if(t instanceof Date)return n=t,e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()});var n;if(z(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const r=t;return e.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(t),o=r(n);return 0===e.PlainDate.compare(a,o)}function G(e,t){return!V(e,t)}function K(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}const r=t;return(z(t)?t:e.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}function q(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=t;return(z(t)?t:e.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function X(t,n){const r=t=>{if(z(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const n=t;return e.PlainDate.from({year:n.year,month:n.month,day:n.day})},a=r(t),o=r(n);return a.until(o).days}function J(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((r.getTime()-n.getTime())/864e5)}function Q(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ee(t=e.Now.timeZoneId()){return e.Now.zonedDateTimeISO(t)}function te(t=e.Now.timeZoneId()){return e.Now.plainDateISO(t)}const ne=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return function(e){var t;if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(z(e))return 0;if(null===e||"object"!=typeof e||!("hour"in e)||void 0===e.hour)return 0;const n=e;return n.hour+(null!==(t=n.minute)&&void 0!==t?t:0)/60}(e)},re=(e,t)=>{if(e instanceof Date){const n=new Date(e),r=Math.floor(t),a=Math.round(60*(t-r));return n.setHours(r,a,0,0),n}return Z(e,t)},ae=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return K(e)},oe=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return q(e)},ie=e=>{const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);const r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)},le=(t,n)=>{if(t instanceof Date&&n instanceof Date)return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return V(t instanceof Date?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):z(t)?t:t.toPlainDate(),n instanceof Date?e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):z(n)?n:n.toPlainDate())},se=(e,t)=>!le(e,t),de=[{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 ce{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const r=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):de.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!r&&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[r]=n.splice(e,1);n.splice(t,0,r),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,r=ce.isDarkTheme(n);let a;return e&&(a=this.get(e)),a||(a=this.getDefaultCalendar()),r&&a.darkColors?a.darkColors:a.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}static isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}static 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 ue=new ce;function he(){return ue}function ge(e){const t=de.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 me=(e,t)=>(t||he()).resolveColors(e).eventColor,ve=(e,t)=>(t||he()).resolveColors(e).textColor,fe=(e,t)=>(t||he()).resolveColors(e).eventSelectedColor,pe=(e,t)=>(t||he()).resolveColors(e).lineColor,ye=.25,be=(e,t=0,n="24h",r=!0)=>{const a=Math.floor(e),o=t||Math.round(60*(e-a));if("12h"===n){const e=a>=12?"PM":"AM",t=a%12||12;return 0===o?`${t}${r?` ${e}`:""}`:`${t}:${o.toString().padStart(2,"0")}${r?` ${e}`:""}`}return`${a.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`},we=e=>{if(!e.end)return 0;const t=ne(e.end);if(e.allDay||!e.start)return t;const n=B(e.start),r=B(e.end);if(!(n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()||n.getDate()!==r.getDate()))return t;if(0===t&&0===r.getMinutes()&&0===r.getSeconds()&&0===r.getMilliseconds()){const e=r.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},De=(e,t="24h")=>{const n=ne(e.start),r=we(e);return`${be(n,0,t)} - ${be(r,0,t)}`},xe=e=>.25*Math.round(e/.25),Ee=(t,n,r="24h",a=new Date)=>{const o=e.Now.timeZoneId(),i=a.getFullYear(),l=a.getMonth()+1,s=a.getDate();return t.map(t=>{try{const a=t.hour%24,d=e.ZonedDateTime.from({year:i,month:l,day:s,hour:a,minute:0,second:0,timeZone:o}).withTimeZone(n);return be(d.hour,d.minute,r)}catch(e){return""}})},Ce=(e,t=new Date)=>{var n,r;try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:e}catch(t){return e}},ke=e=>{const t=new Date(e),n=t.getDate(),r=t.getMonth(),a=t.getFullYear(),o=new Date;return{date:t,day:n,month:r,year:a,monthName:$[r],shortMonthName:j[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},Te=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,r="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,r=e)});const[a,o]=r.split("-").map(Number);return{month:$[a],monthIndex:a,year:o}},Ne=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(ke(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Te(t)}},Se=(e,t=3)=>{const n=5*t,{monday:r}=Y(e),a=[],o=Math.floor(n/2),i=new Date(r);i.setDate(i.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),a.push(Ne(t))}return a};function Me(e,t,n=1){const r=[],a=Math.floor(t/2),o=(e.getDay()-n+7)%7,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const l=new Date(i);l.setDate(l.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(Ne(t))}return r}const Ie=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),Ae=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const r=new Date(n);r.setDate(n.getDate()+e),r.setHours(0,0,0,0);const a=B(t.start);a.setHours(0,0,0,0);const o=B(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),He=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},Oe=(t,n,r)=>{const a=He(r,n);return Object.assign(Object.assign({},t),{day:n,start:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()}),end:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()})})},Re=(t,n)=>n?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:e.Now.timeZoneId()}),Pe=(e,t)=>{var n,r;const a=He(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},Le=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=n.getTime()-r.getTime();return Math.floor(a/864e5)},$e=(e,t)=>{const n=Le(e,t);return n>=0&&n<=6},je=(e,t)=>e.map(e=>{const n=B(e.start),r=Le(n,t);return Object.assign(Object.assign({},e),{day:r})}),Ye=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=r.getTime()-n.getTime();return Math.floor(a/864e5)},Fe=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=B(e.start);return r>=t&&r<=n}).map(e=>{const n=Le(B(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},ze=(e,t)=>{var n,r;const a=new Date(t);a.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},_e=(e,t,n)=>{var r;const a=new Date(n);a.setDate(n.getDate()+t);const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{day:t,start:Re(a,o),end:Re(a,o)})},We=(t,n)=>{var r,a;const o=He(n,null!==(r=t.day)&&void 0!==r?r:0);if(null!==(a=t.allDay)&&void 0!==a&&a){const n=e.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const i=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds(),millisecond:o.getMilliseconds()});return Object.assign(Object.assign({},t),{start:i,end:i})},Ue=(t,n,r)=>{var a,o;const i=He(n,null!==(a=t.day)&&void 0!==a?a:0);if(null!==(o=t.allDay)&&void 0!==o&&o){const n=e.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const l=e.ZonedDateTime.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate(),hour:i.getHours(),minute:i.getMinutes(),second:i.getSeconds(),millisecond:i.getMilliseconds(),timeZone:r});return Object.assign(Object.assign({},t),{start:l,end:l})},Be=(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()),Ze=(e,t)=>B(e.start).getTime()!==B(t.start).getTime()||B(e.end).getTime()!==B(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function Ve(){const t=new Date,n=t.getDay(),r=new Date(t),a=0===n?-6:1-n;r.setDate(t.getDate()+a),r.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(t=>{const n=new Date(r);if(n.setDate(r.getDate()+t.day),t.allDay)return{id:t.id,title:t.title,start:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:t.calendarId,day:t.day};const a=Math.floor(t.startHour),o=Math.round(60*(t.startHour-a)),i=Math.floor(t.endHour),l=Math.round(60*(t.endHour-i));return{id:t.id,title:t.title,start:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:e.Now.timeZoneId()}),end:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:i,minute:l,timeZone:e.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})}function Ge(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function Ke(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),r=Object.keys(t);if(n.length!==r.length)return!1;const a=e,o=t;for(const e of n)if(!r.includes(e)||!Ke(a[e],o[e]))return!1;return!0}const qe=new class{constructor(){var e,t;this.isDevelopment="production"!==(null===(t=null===(e=globalThis.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV)}formatMessage(e,t,...n){if(!this.isDevelopment)return;const r=(new Date).toISOString(),a=`[DayFlow ${e.toUpperCase()}] ${r}:`;switch(e){case"log":console.log(a,t,...n);break;case"warn":console.warn(a,t,...n);break;case"error":console.error(a,t,...n);break;case"debug":console.debug(a,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)}};class Xe{constructor(e=[]){this.events=new Map,this.isInTransaction=!1,this.pendingChanges=[],e.forEach(e=>this.events.set(e.id,e))}beginTransaction(){this.isInTransaction?console.warn("Transaction already in progress. Nested transactions are not supported."):(this.isInTransaction=!0,this.pendingChanges=[])}endTransaction(){var e;if(!this.isInTransaction)return;const t=Xe.normalizeChanges(this.pendingChanges);this.isInTransaction=!1,this.pendingChanges=[],t.length>0&&(null===(e=this.onEventBatchChange)||void 0===e||e.call(this,t))}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);this.events.set(e.id,e),this.emitChange({type:"create",event:e})}updateEvent(e,t){const n=this.events.get(e);if(!n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},n),t);this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);t&&(this.events.delete(e),this.emitChange({type:"delete",event:t}))}getEvent(e){return this.events.get(e)}getAllEvents(){return Array.from(this.events.values())}emitChange(e){var t;this.isInTransaction?this.pendingChanges.push(e):null===(t=this.onEventChange)||void 0===t||t.call(this,e)}static normalizeChanges(e){const t=new Map;for(const n of e){const e="delete"===n.type?n.event.id:"update"===n.type?n.after.id:n.event.id,r=t.get(e);r?"create"===r.type?"update"===n.type?t.set(e,{type:"create",event:n.after}):"delete"===n.type&&t.delete(e):"update"===r.type?"update"===n.type?t.set(e,{type:"update",before:r.before,after:n.after}):"delete"===n.type&&t.set(e,{type:"delete",event:r.before}):"delete"===r.type&&"create"===n.type&&t.set(e,{type:"update",before:r.event,after:n.event}):t.set(e,n)}return Array.from(t.values())}}class Je{constructor(e){var t,n,r,a,o;this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.MAX_UNDO_STACK=50,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.pushToUndo=e=>{this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()},this.undo=()=>{if(0===this.undoStack.length)return;const e=this.undoStack.pop();"events_snapshot"===(null==e?void 0:e.type)&&(this.state.events=e.data,this.store=new Xe(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())},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.handleVisibleRangeChange("viewChange"),this.notify()},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.emitVisibleRange=(e,t,n="navigation")=>{var r,a;null===(a=(r=this.callbacks).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)},this.handleVisibleRangeChange=e=>{var t,n,r,a;const o=this.state.views.get(this.state.currentView);switch(null==o?void 0:o.type){case I.DAY:{const t=new Date(this.state.currentDate);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}case I.WEEK:{const r=null!==(n=null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.startOfWeek)&&void 0!==n?n:1,{monday:a}=Y(this.state.currentDate,r),i=new Date(a),l=new Date(a);l.setDate(l.getDate()+7),this.emitVisibleRange(i,l,e);break}case I.MONTH:{if("navigation"===e)break;const t=new Date(this.state.currentDate.getFullYear(),this.state.currentDate.getMonth(),1),n=null!==(a=null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.startOfWeek)&&void 0!==a?a:1,{monday:i}=Y(t,n),l=new Date(i),s=new Date(i);s.setDate(s.getDate()+42),this.emitVisibleRange(l,s,e);break}case I.YEAR:{const t=new Date(this.state.currentDate.getFullYear(),0,1);t.setHours(0,0,0,0);const n=new Date(this.state.currentDate.getFullYear(),11,31);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}}},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.handleVisibleRangeChange("navigation"),this.notify()},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const r=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===r.getFullYear()&&this.visibleMonth.getMonth()===r.getMonth()||(this.visibleMonth=r,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())},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 I.DAY:e.setDate(e.getDate()-1);break;case I.WEEK:e.setDate(e.getDate()-7);break;case I.MONTH:e.setMonth(e.getMonth()-1);break;case I.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case I.DAY:e.setDate(e.getDate()+1);break;case I.WEEK:e.setDate(e.getDate()+7);break;case I.MONTH:e.setMonth(e.getMonth()+1);break;case I.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.applyEventsChanges=(e,t,n)=>{if(this.isInternalEditable()||t){if(t?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),t){let t=[...this.state.events];if(e.delete){const n=new Set(e.delete);t=t.filter(e=>!n.has(e.id))}return e.update&&e.update.forEach(({id:e,updates:n})=>{const r=t.findIndex(t=>t.id===e);-1!==r&&(t[r]=Object.assign(Object.assign({},t[r]),n))}),e.add&&(t=[...t,...e.add]),this.state.events=t,void this.notify()}n&&(this.pendingChangeSource=n),this.store.beginTransaction(),e.delete&&e.delete.forEach(e=>this.store.deleteEvent(e)),e.update&&e.update.forEach(({id:e,updates:t})=>{try{this.store.updateEvent(e,t)}catch(t){console.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){console.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}},this.addEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)):qe.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n,r)=>{if(this.isInternalEditable()||n){if(this.isInternalEditable()){if(r&&(this.pendingChangeSource=r),n?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),n){const n=this.state.events.findIndex(t=>t.id===e);if(-1===n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[n]),t);return this.state.events=[...this.state.events.slice(0,n),r,...this.state.events.slice(n+1)],void this.notify()}this.store.updateEvent(e,t)}}else qe.warn("Cannot update event in read-only mode")},this.deleteEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.deleteEvent(e)):qe.warn("Cannot delete event in read-only mode")},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&&(this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.selectEvent=e=>{var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.dismissUI=()=>{var e,t;null===(t=(e=this.callbacks).onDismissUI)||void 0===t||t.call(e),this.notify()},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,r;this.calendarRegistry.reorder(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setCalendarVisibility=(e,t)=>{var n,r;this.calendarRegistry.setVisibility(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.updateCalendar=(e,t,n)=>{var r,a,o,i;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const l=this.calendarRegistry.get(e);l&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,l)),null===(i=(o=this.callbacks).onRender)||void 0===i||i.call(o),this.notify()},this.createCalendar=e=>{var t,n,r,a;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.deleteCalendar=e=>{var t,n,r,a;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.mergeCalendars=(e,t)=>{var n,r;const a=this.store.getAllEvents().filter(t=>t.calendarId===e);this.pushToUndo(),this.store.beginTransaction(),a.forEach(e=>{this.store.updateEvent(e.id,{calendarId:t})}),this.store.endTransaction(),this.deleteCalendar(e),null===(r=(n=this.callbacks).onCalendarMerge)||void 0===r||r.call(n,e,t)},this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?qe.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.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.notify())},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.notify()},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||Ke(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.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=Je.resolveLocale(e.locale);Ke(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&(this.triggerRender(),this.notify())},this.setOverrides=e=>{this.state.overrides=e,this.triggerRender(),this.notify()},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.notify()},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:e.defaultView||I.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:Je.resolveLocale(e.locale),highlightedEventId:null,selectedEventId:null,readOnly:e.readOnly||!1,overrides:[]},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.store=new Xe(this.state.events),this.setupStoreListeners(),this.calendarRegistry=new ce(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,ue=o;const i=this.state.currentDate;this.visibleMonth=new Date(i.getFullYear(),i.getMonth(),1),this.useEventDetailDialog=null!==(n=e.useEventDetailDialog)&&void 0!==n&&n,this.useCalendarHeader=null===(r=e.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=e.customMobileEventRenderer,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(a=e.plugins)||void 0===a||a.forEach(e=>{this.installPlugin(e)}),this.handleVisibleRangeChange("initial")}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a,o,i;this.state.events=this.store.getAllEvents(),"create"===e.type?null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e.event):"update"===e.type?null===(a=(r=this.callbacks).onEventUpdate)||void 0===a||a.call(r,e.after):"delete"===e.type&&(null===(i=(o=this.callbacks).onEventDelete)||void 0===i||i.call(o,e.event.id)),this.triggerRender(),this.notify()},this.store.onEventBatchChange=e=>{var t,n;this.state.events=this.store.getAllEvents(),"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(null===(n=(t=this.callbacks).onEventBatchChange)||void 0===n||n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify()}}static resolveLocale(e){return e?"string"==typeof e?M(e)?e:"en-US":e&&"object"==typeof e&&!M(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}var Qe=0;function et(e,n,r,a,o,i){n||(n={});var l,s,d=n;if("ref"in d)for(s in d={},n)"ref"==s?l=n[s]:d[s]=n[s];var c={type:e,props:d,key:r,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Qe,__i:-1,__u:0,__source:o,__self:i};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===d[s]&&(d[s]=l[s]);return t.vnode&&t.vnode(c),c}const tt=t=>{if(!t)return"";let n,r,a;t instanceof Date?(a=t.getFullYear(),r=t.getMonth()+1,n=t.getDate()):z(t)?(a=t.year,r=t.month,n=t.day):(!function(t){if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;const n=t;e.ZonedDateTime}(t),a=t.year,r=t.month,n=t.day);const o=String(r).padStart(2,"0");return`${String(n).padStart(2,"0")}/${o}/${a}`},nt=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,rt=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 at(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function ot(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function it(e){return null!==e&&"object"==typeof e&&"timeZone"in e&&"year"in e&&!(e instanceof Date)}function lt(e){if(e instanceof Date)return e;if(at(e))return new Date(e.year,e.month-1,e.day);if(ot(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(it(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}catch(t){return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}return new Date(e)}function st(t){return e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()})}function dt(t){return e.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds()})}function ct(t,n=e.Now.timeZoneId()){return e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:n})}function ut(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}function ht(e){return new Date(e.year,e.month-1,e.day)}function gt(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(at(e))return 0;const t=e;return t.hour+t.minute/60}function mt(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return it(e),e.with({hour:n,minute:r,second:0,millisecond:0})}function vt(e){return e instanceof Date?st(e):at(e)?e:(ot(e),e.toPlainDate())}function ft(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=vt(e),r=vt(t);return n.equals(r)}const pt=/(YYYY|YY|MM|DD|HH|mm)/g,yt=e=>e.toString().padStart(2,"0"),bt=(e,t)=>{const n=(null!=t?t:"").trim(),r=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return r.replaceAll(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},wt=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Dt=e=>{let t,n=0,r="^";for(;null!==(t=pt.exec(e));){r+=wt(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=wt(e.slice(n))+"$",new RegExp(r)},xt=(t,n,r,a)=>{const o=t.trim();if(!o)return null;const i=o.match(n),l=null==i?void 0:i.groups;if(!l)return null;const s=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:r.year,d=l.MM?Number(l.MM):r.month,c=l.DD?Number(l.DD):r.day,u=l.HH?Number(l.HH):r.hour,h=l.mm?Number(l.mm):r.minute;try{return e.ZonedDateTime.from({timeZone:a,year:s,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},Et=t=>{const n=t;return n.timeZoneId&&"string"==typeof n.timeZoneId?n.timeZoneId:n.timeZone&&"string"==typeof n.timeZone.id?n.timeZone.id:"string"==typeof n.timeZone?n.timeZone:e.Now.timeZoneId()},Ct=(t,n,r)=>{var a,o,i,l,s,d,c,u,h,g,m,v,f,p,y,b,w,D,x,E,C,k,T,N;if(!t){const t=null!=n?n:r?Et(r):e.Now.timeZoneId();return null!=r?r:e.Now.zonedDateTimeISO(t)}if(at(t)){const r=null!=n?n:e.Now.timeZoneId(),a=`${t.year}-${yt(t.month)}-${yt(t.day)}T00:00:00[${r}]`;return e.ZonedDateTime.from(a)}const S=t;if("hour"in S&&!("timeZone"in S)){const r=null!=n?n:e.Now.timeZoneId();if("function"==typeof S.toZonedDateTime)try{return t.toZonedDateTime(r)}catch(e){}return e.ZonedDateTime.from({timeZone:r,year:S.year,month:S.month,day:S.day,hour:S.hour,minute:S.minute,second:null!==(a=S.second)&&void 0!==a?a:0,millisecond:null!==(o=S.millisecond)&&void 0!==o?o:0,microsecond:null!==(i=S.microsecond)&&void 0!==i?i:0,nanosecond:null!==(l=S.nanosecond)&&void 0!==l?l:0})}try{return e.ZonedDateTime.from(t)}catch(t){const a=S,o=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(s=null==a?void 0:a.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==a?void 0:a.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?Et(r):void 0)&&void 0!==h?h:e.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:e.Now.zonedDateTimeISO(o);return e.ZonedDateTime.from({timeZone:o,year:null!==(g=null==a?void 0:a.year)&&void 0!==g?g:i.year,month:null!==(m=null==a?void 0:a.month)&&void 0!==m?m:i.month,day:null!==(v=null==a?void 0:a.day)&&void 0!==v?v:i.day,hour:null!==(p=null!==(f=null==a?void 0:a.hour)&&void 0!==f?f:null==r?void 0:r.hour)&&void 0!==p?p:0,minute:null!==(b=null!==(y=null==a?void 0:a.minute)&&void 0!==y?y:null==r?void 0:r.minute)&&void 0!==b?b:0,second:null!==(D=null!==(w=null==a?void 0:a.second)&&void 0!==w?w:null==r?void 0:r.second)&&void 0!==D?D:0,millisecond:null!==(E=null!==(x=null==a?void 0:a.millisecond)&&void 0!==x?x:null==r?void 0:r.millisecond)&&void 0!==E?E:0,microsecond:null!==(k=null!==(C=null==a?void 0:a.microsecond)&&void 0!==C?C:null==r?void 0:r.microsecond)&&void 0!==k?k:0,nanosecond:null!==(N=null!==(T=null==a?void 0:a.nanosecond)&&void 0!==T?T:null==r?void 0:r.nanosecond)&&void 0!==N?N:0})}},kt=(e,t,n)=>{const r=bt(t,n),a={YYYY:e.year.toString(),YY:yt(e.year%100),MM:yt(e.month),DD:yt(e.day),HH:yt(e.hour),mm:yt(e.minute)};return r.replace(pt,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function Tt(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}let Nt=null;function St(){if("undefined"==typeof document)return!1;if(null!==Nt)return Nt;const e=document.createElement("style");e.textContent=".df-calendar-container .__df_measure__::-webkit-scrollbar { display: block !important; }",document.head.append(e);const t=document.createElement("div");t.className="df-calendar-container",t.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:hidden";const n=document.createElement("div");n.className="__df_measure__",n.style.cssText="width:100px;height:100px;overflow:scroll",t.append(n),document.body.append(t);const r=n.offsetWidth-n.clientWidth>0;return t.remove(),e.remove(),Nt=r,r}const Mt=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),It={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"},At=(e,t,n)=>e?t:n,Ht=(...e)=>e.filter(Boolean).join(" "),Ot=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.dataset.dayflowThemeOverride,t.dataset.themeOverride,t.dataset.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 Rt(t,n=!1){if(t instanceof e.PlainDate||t instanceof e.PlainDateTime)return t;if(t instanceof Date)return n?st(t):dt(t);throw new Error("Invalid time type: "+typeof t)}function Pt(t,n){if(t instanceof e.ZonedDateTime)return t;if(t instanceof Date)return ct(t,n);throw new Error("Invalid time type: "+typeof t)}function Lt(e){var t;const n=Rt(e.start,e.allDay),r=Rt(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:r,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function $t(e){const t=Pt(e.start,e.timeZone),n=Pt(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 jt(e){return e.map(e=>Lt(e))}function Yt(e){return e.map(e=>$t(e))}function Ft(e,t,n,r){return Lt(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))}function zt(e,t,n,r,a){return Lt(Object.assign({id:e,title:t,start:n,end:r},a))}function _t(e,t,n,r,a=!1,o){return Lt(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))}function Wt(e,t,n,r,a,o){return $t(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))}const Ut=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):B(e)}catch(e){return new Date}},Bt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Zt=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let i="",l="text-gray-500 dark:text-gray-400";if(0===o)i=r("today")||"Today",l="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");i=e.charAt(0).toUpperCase()+e.slice(1),l="text-black dark:text-white"}catch(t){i=e.toLocaleDateString(n,{weekday:"long"})}else i=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:i,colorClass:l}},Vt=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Ut(e.start),a=Bt(r),o=a.getTime();n.has(o)||n.set(o,{date:a,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const r=t.getTime();n.has(r)||n.set(r,{date:t,events:[]});return Array.from(n.values()).toSorted((e,t)=>e.date.getTime()-t.date.getTime())};const Gt=new class{constructor(){this.lastCopiedEvent=null}setEvent(e){this.lastCopiedEvent=e}getEvent(){return this.lastCopiedEvent}hasEvent(){return null!==this.lastCopiedEvent}clear(){this.lastCopiedEvent=null}};function Kt(e){return String(e).padStart(2,"0")}function qt(t,n,r){const a=t.trim(),o=/^(\d{4})(\d{2})(\d{2})$/,i=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;if("DATE"===(null==n?void 0:n.value)||o.test(a)){const t=a.match(o);if(t)return e.PlainDate.from({year:Number.parseInt(t[1],10),month:Number.parseInt(t[2],10),day:Number.parseInt(t[3],10)})}if(i.test(a)){const t=a.match(i);if(t){const n=e.Instant.from(`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}Z`),a=r||e.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const t={year:Number.parseInt(l[1],10),month:Number.parseInt(l[2],10),day:Number.parseInt(l[3],10),hour:Number.parseInt(l[4],10),minute:Number.parseInt(l[5],10),second:Number.parseInt(l[6],10)};return(null==n?void 0:n.tzid)?e.ZonedDateTime.from(Object.assign(Object.assign({},t),{timeZone:n.tzid})):e.PlainDateTime.from(t)}throw new Error(`Invalid ICS date format: ${t}`)}function Xt(e,t=!1){if(t||at(e)){const t=at(e)?e:e.toPlainDate();return{value:`${t.year}${Kt(t.month)}${Kt(t.day)}`,params:{VALUE:"DATE"}}}if(it(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Kt(t.month)}${Kt(t.day)}T${Kt(t.hour)}${Kt(t.minute)}${Kt(t.second)}Z`}}if(ot(e))return{value:`${e.year}${Kt(e.month)}${Kt(e.day)}T${Kt(e.hour)}${Kt(e.minute)}${Kt(e.second)}`};throw new Error("Unsupported Temporal type")}function Jt(e){return`${e.getUTCFullYear()}${Kt(e.getUTCMonth()+1)}${Kt(e.getUTCDate())}T${Kt(e.getUTCHours())}${Kt(e.getUTCMinutes())}${Kt(e.getUTCSeconds())}Z`}function Qt(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function en(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function tn(e){if(e.length<=75)return e;const t=[];let n=e;for(t.push(n.slice(0,75)),n=n.slice(75);n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}function nn(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,tn(r)}function rn(e){var t,n,r;const a=["BEGIN:VEVENT"],o=(null===(t=e.meta)||void 0===t?void 0:t.originalUid)||`${e.id}@dayflow`;a.push(`UID:${o}`),a.push(`DTSTAMP:${Jt(new Date)}`);const i=Xt(e.start,e.allDay),l=Xt(e.end,e.allDay);if(a.push(nn("DTSTART",i.value,i.params)),a.push(nn("DTEND",l.value,l.params)),a.push(nn("SUMMARY",Qt(e.title))),e.description&&a.push(nn("DESCRIPTION",Qt(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(nn("LOCATION",Qt(e.meta.location))),(null===(r=e.meta)||void 0===r?void 0:r.categories)&&Array.isArray(e.meta.categories)){const t=e.meta.categories.map(Qt).join(",");a.push(nn("CATEGORIES",t))}return a.push("END:VEVENT"),a}function an(e){const t=[];let n=null,r=!1;for(const a of e){const e=a.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(r=!0,n=[]):e.startsWith("END:VEVENT")?(r&&n&&t.push(n),r=!1,n=null):r&&n&&n.push(a)}return t}function on(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e),a=n.slice(e+1),[o,...i]=r.split(";"),l=o.trim().toUpperCase(),s={};switch(i.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),l){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=en(a);break;case"DESCRIPTION":t.description=en(a);break;case"LOCATION":t.location=en(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>en(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=Ge()),t}function ln(t,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=n,s=o?`${i}${Ge()}`:t.uid,d=qt(t.dtstart,t.dtstartParams,l);let c;c=t.dtend?qt(t.dtend,t.dtendParams,l):at(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=t.dtstartParams)||void 0===r?void 0:r.value)||at(d),h=l||e.Now.timeZoneId();let g,m;if(at(d))g=d.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ot(d))try{g=d.toZonedDateTime(h)}catch(t){g=e.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(at(c))m=c.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ot(c))try{m=c.toZonedDateTime(h)}catch(t){m=e.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:t.summary||"(No Title)",description:t.description,start:g,end:m,allDay:u,meta:{location:t.location,originalUid:t.uid,categories:t.categories}}}function sn(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=an(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=ln(on(e),t);n.events.push(r)}catch(e){n.errors.push({line:0,message:e instanceof Error?e.message:"Unknown parsing error",eventUid:`index-${r}`})}}),n.success=0===n.errors.length,n.totalImported=n.events.length}catch(e){n.errors.push({message:`Fatal parsing error: ${e instanceof Error?e.message:"Unknown error"}`})}return n}function dn(e,t={}){const{calendarName:n="DayFlow Calendar",productId:r="-//DayFlow//DayFlow Calendar//EN"}=t,a=["BEGIN:VCALENDAR","VERSION:2.0",`PRODID:${r}`,"CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${Qt(n)}`];return e.forEach(e=>{a.push(...rn(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}function cn(e,t={}){const n=dn(e,t),r=`${t.filename||"calendar"}.ics`,a=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.setAttribute("download",r),document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(o)}function un(e,t){return y(this,void 0,void 0,function*(){try{const n=yield e.text();if(!n)throw new Error("File content is empty");return sn(n,t)}catch(e){return{success:!1,events:[],errors:[{message:e instanceof Error?e.message:"string"==typeof e?e:"Failed to read file"}],totalParsed:0,totalImported:0}}})}let hn=null;const gn=()=>{const[e,t]=u(()=>hn||{weekHeight:H.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return h(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(H.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(H.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(H.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};hn=a,t(e=>e.screenSize===a.screenSize&&e.weekHeight===a.weekHeight&&e.weeksPerView===a.weeksPerView?e:a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},mn=n({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function vn(){return f(mn)}const fn="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",pn="p-2 flex justify-between",yn="text-2xl font-bold text-gray-900 dark:text-gray-100",bn="rounded-md bg-background border border-border px-3 py-2 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",wn="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Dn="flex-1 overflow-auto will-change-scroll",xn="scrollbar-hide",En="df-time-slot relative h-[4.5rem] flex",Cn="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",kn="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",Tn="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",Nn="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Sn="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Mn="rounded-xl my-0.5",In="rounded-sm",An="df-event-title font-medium text-xs truncate pr-1",Hn="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",On="h-3 w-3 mr-1",Rn="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Pn="bg-primary rounded-full text-primary-foreground",Ln="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",$n="h-4 w-4 transition-transform group-hover:scale-110",jn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",Yn="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",Fn="h-3 border-t border-gray-200 dark:border-gray-700 relative",zn="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",_n="df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",Wn="df-sidebar-header flex items-center px-2 py-1",Un="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",Bn="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",Zn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Vn="text-gray-500 dark:text-gray-400",Gn="text-gray-600 dark:text-gray-300",Kn="text-xs",qn="text-sm",Xn="flex flex-col",Jn="mr-1",Qn=(...e)=>e.filter(Boolean).join(" "),er=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m15 18-6-6 6-6"})}),tr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m9 18 6-6-6-6"})}),nr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m11 17-5-5 5-5"}),et("path",{d:"m18 17-5-5 5-5"})]}),rr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m6 17 5-5-5-5"}),et("path",{d:"m13 17 5-5-5-5"})]}),ar=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m6 9 6 6 6-6"})}),or=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M5 12h14"}),et("path",{d:"M12 5v14"})]}),ir=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("circle",{cx:"11",cy:"11",r:"8"}),et("path",{d:"m21 21-4.3-4.3"})]}),lr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M20 6 9 17l-5-5"})}),sr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m7 15 5 5 5-5"}),et("path",{d:"m7 9 5-5 5 5"})]}),dr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M18 6 6 18"}),et("path",{d:"m6 6 12 12"})]}),cr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M8 2v4"}),et("path",{d:"M16 2v4"}),et("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),et("path",{d:"M3 10h18"}),et("path",{d:"M8 14h.01"}),et("path",{d:"M12 14h.01"}),et("path",{d:"M16 14h.01"}),et("path",{d:"M8 18h.01"}),et("path",{d:"M12 18h.01"}),et("path",{d:"M16 18h.01"})]}),ur=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M18 8L22 12L18 16"}),et("path",{d:"M2 12H22"})]}),hr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),gr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),et("path",{d:"M12 5a3 3 0 1 0-3 3"}),et("path",{d:"M12 5a3 3 0 1 1 3 3"}),et("path",{d:"M3 12h18"}),et("path",{d:"M12 22V8"})]}),mr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})}),vr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),et("circle",{cx:"12",cy:"10",r:"3"})]}),fr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),pr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),et("path",{d:"M15 3v18"}),et("path",{d:"m8 9 3 3-3 3"})]}),yr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),et("path",{d:"M15 3v18"}),et("path",{d:"m10 15-3-3 3-3"})]}),br=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m12 19-7-7 7-7"}),et("path",{d:"M19 12H5"})]});function wr(e,t){var n,r,a,o,i;try{if("today"===e){return null!==(r=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!==r?r:null}if("week"===e){return null!==(o=null===(a=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===a?void 0:a.value)&&void 0!==o?o:null}return null!==(i=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==i?i:null}catch(e){return null}}function Dr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const xr=(e,t="short",n=1)=>{const r=[],a=new Date(2024,0,7);for(let o=0;o<7;o++){const i=new Date(a);i.setDate(a.getDate()+n+o);try{r.push(i.toLocaleDateString(e,{weekday:t}))}catch(e){r.push(i.toLocaleDateString("en-US",{weekday:t}))}}return r},Er=(e,t="long")=>{const n=[];for(let r=0;r<12;r++){const a=new Date(2024,r,1);try{n.push(a.toLocaleDateString(e,{month:t}))}catch(e){n.push(a.toLocaleDateString("en-US",{month:t}))}}return n};function Cr(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=wr(e,t);if(n)return Dr(n)}const r=S(t),a=T[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const i=T.en.messages;return(null==i?void 0:i[e])||e}const kr=({locale:e="en-US",messages:t,children:n})=>{const r=v(()=>{if("string"==typeof e){return{code:M(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!M(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),a=v(()=>{const e=r.code;return{locale:e,t:(n,a)=>{var o,i,l;let s=null!==(l=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(i=r.messages)||void 0===i?void 0:i[n])&&void 0!==l?l:Cr(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:xr,getMonthLabels:Er,isDefault:!1}},[r,t]);return et(mn.Provider,{value:a,children:n})},Tr=({calendar:e,mode:t="buttons"})=>{const[n,r]=u(!1),a=g(null),{t:o}=vn(),i=Array.from(e.state.views.keys()),l=e.state.currentView;return h(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&r(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),i.length<=1?null:et("div","select"===t?{className:"relative inline-block",ref:a,children:[et("button",{type:"button",onClick:()=>r(!n),className:"flex h-7 min-w-30 items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm font-medium shadow-sm transition-all duration-200 hover:bg-gray-50 focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:hover:bg-gray-700","aria-expanded":n,"aria-haspopup":"listbox",children:[et("span",{className:"text-gray-900 dark:text-gray-100",children:o(l)}),et("span",{className:`${Vn} transition-transform duration-200 ${n?"rotate-180":""}`,children:et(ar,{width:16,height:16})})]}),n&&et("div",{className:"absolute top-full left-0 z-50 mt-1 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:et("div",{className:"p-1",role:"listbox",children:i.map(t=>et("button",{type:"button",onClick:()=>{e.changeView(t),r(!1),e.triggerRender()},className:"w-full rounded px-3 py-0.5 text-left text-sm transition-colors duration-150 focus:outline-none "+(l===t?"bg-primary/10 font-medium text-primary":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:o(t)},t))})}),et("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 "})]}:{className:"mb-1 inline-flex items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:i.map(t=>et("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(l===t?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-gray-100":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100"),onClick:()=>{e.changeView(t),e.triggerRender()},children:o(t)},t))})},Nr=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o="",isSearchOpen:i=!1,isEditable:l=!0,safeAreaLeft:s})=>{const d="buttons"===t,c=e.state.currentView===I.DAY,{screenSize:u}=gn(),h="mobile"===u,{t:g}=vn(),v=m(e=>{const t=e.currentTarget.value;t!==o&&(null==r||r(t))},[r,o]);return et("div",{className:"df-header flex shrink-0 items-center justify-between border-b bg-white pt-1 pr-2 transition-colors duration-200 dark:bg-gray-900 "+(c||i?"border-gray-200 dark:border-gray-700":"border-transparent"),style:{paddingLeft:s||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"df-header-left mb-1 flex items-center",children:n&&l&&et("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Zn,title:h?g("newEvent")||"New Event":g("createCalendar")||"Add Calendar",children:et(or,{className:`h-4 w-4 ${Vn}`})})}),et("div",{className:"df-header-mid flex flex-1 justify-center",children:d&&et(Tr,{mode:t,calendar:e})}),et("div",{className:"df-header-right mb-1 flex items-center justify-end gap-3 pb-1",children:[!d&&et(Tr,{mode:t,calendar:e}),et("button",{type:"button",onClick:a,className:`md:hidden ${Zn}`,title:g("search")||"Search",children:et(ir,{width:16,height:16})}),et("div",{className:"group relative hidden md:block",children:[et("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:et("span",{className:"text-gray-400 transition-colors group-focus-within:text-primary",children:et(ir,{width:16,height:16})})}),et("input",{id:"dayflow-search-input",type:"text",placeholder:g("search")||"Search",value:o,onChange:v,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&&et("button",{type:"button",onClick:()=>{null==r||r("")},className:"absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:et("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[et("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),et("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},Sr=n(void 0),Mr=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,a]=u(t),[o,i]=u("light"),l="auto"===r?o:r;h(()=>{a(t)},[t]);const s=m(e=>{a(e)},[]);h(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";i(t)},n=e.matches?"dark":"light";return i(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),h(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Ot(l),n="auto"===r?t:l;e.classList.remove("light","dark"),e.classList.add(n),"auto"===r?delete e.dataset.dayflowThemeOverride:e.dataset.dayflowThemeOverride=n,e.dataset.theme=n},[l,r,o]),h(()=>{n&&n(r,l)},[r,l,n]);const d=v(()=>({theme:r,effectiveTheme:l,setTheme:s}),[r,l,s]);return et(Sr.Provider,{value:d,children:e})},Ir=()=>{const e=f(Sr);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Ar=n(null);let Hr=0;function Or({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const a=g(null),o=f(Ar),i=r||o,l=g(null),[,s]=u(0);l.current||(l.current="df-slot-"+Hr++),h(()=>{if(!a.current||!i||!e)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t});const r=i.subscribe(()=>{s(e=>e+1)});return()=>{i.unregister(n),r()}},[i,e]),h(()=>{if(!i||!l.current||!e)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t})},[e,t]);const d=null==e?void 0:e.startsWith("eventContent"),c="sidebar"===e,m=!!e&&(null==i?void 0:i.isOverridden(e));return et("div",{ref:a,className:"df-content-slot "+(d||c?"flex h-full flex-1 flex-col":""),children:!m&&n})}const Rr=e=>{const t=g(null),n=g(null);return h(()=>{if(t.current){const r=b(e,[]);n.current=new w(t.current,r),r.initialExpanded&&n.current.expand()}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),h(()=>{if(n.current){const t=b(e,[]);n.current.setOptions(t)}},[e]),et("div",{ref:t,className:e.className})},Pr=({color:e,onChange:t,onClose:n})=>{const r=v(()=>{const{h:t,l:n}=D(e);return{hue:t,saturation:x(n),lightness:n,alpha:100,layer:"outer"}},[e]);return et("div",{className:"flex justify-center",children:et(Rr,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Lr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],$r=({onClose:e,onCreate:t,app:n})=>{const{t:a}=vn(),{effectiveTheme:o}=Ir(),[i,l]=u(""),d=n.state.overrides.includes("createCalendarDialogColorPicker"),[c,h]=u(Lr[Math.floor(Math.random()*Lr.length)]),[g,m]=u(!1),[f,p]=u(""),y=v(()=>{const e=E[Math.floor(Math.random()*E.length)],t=e.layer||"outer",n=x(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[b,w]=u(null),D=e=>{h(e.hex)},k=()=>{m(!1)},T=()=>{h(f),m(!1)},N="dark"===o,S={default:{picker:{background:N?"#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:N?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:N?"#1e293b":"#ffffff",borderBottom:N?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:N?"#1e293b":"#ffffff"},controls:{border:N?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:N?"#374151":"#ffffff",color:N?"#f3f4f6":"#1f2937",border:N?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:N?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:N?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:s(et("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:et("div",{className:"animate-in fade-in zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-slate-900",onClick:e=>e.stopPropagation(),children:[et("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+(d?"mb-4":"mb-6"),children:a("createCalendar")}),et("form",{onSubmit:n=>{var r;if(n.preventDefault(),!i.trim())return;let a;a=d?c:null!==(r=null==b?void 0:b.hex)&&void 0!==r?r:C(y.hue,y.saturation,y.lightness);const{colors:o,darkColors:l}=ge(a),s={id:Ge(),name:i.trim(),colors:o,darkColors:l,isVisible:!0,isDefault:!1};t(s),e()},children:[d?et(r,{children:[et("div",{className:"mb-4",children:et("div",{className:"flex items-center gap-3",children:[et("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:c}}),et("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:i,onChange:e=>l(e.target.value),className:"w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})]})}),et("div",{className:"mb-6",children:[et("div",{className:"mb-4 grid grid-cols-7 gap-4",children:Lr.map(e=>et("button",{type:"button",className:"h-7 w-7 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(c===e?"scale-110 ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>h(e)},e))}),et("div",{className:"relative",children:[et("button",{type:"button",onClick:()=>{p(c),m(!0)},className:"flex w-full items-center gap-2 rounded-md border border-slate-200 px-2 py-1 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 focus:outline-none dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800",children:a("customColor")}),g&&et("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:T,children:et("div",{className:"animate-in fade-in zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:et(Or,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:c,onChange:D,onAccept:k,onCancel:T,styles:S},defaultContent:et("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-2xl dark:border-slate-700 dark:bg-slate-900",children:[et(Pr,{color:c,onChange:D}),et("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[et("button",{type:"button",onClick:T,className:"rounded-md border border-gray-200 px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-gray-100 dark:border-gray-600 dark:text-slate-300 dark:hover:bg-gray-800",children:a("cancel")}),et("button",{type:"button",onClick:k,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:opacity-90",children:"OK"})]})]})})})})]})]})]}):et("div",{className:"mb-8 flex items-center gap-4",children:[et("div",{className:"flex-1",children:et("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:i,onChange:e=>l(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})}),et("div",{className:"relative h-9 w-9 shrink-0",children:et("div",{className:"absolute inset-0 flex items-center justify-center",children:et(Rr,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>w(e),onCollapse:e=>w(e),className:"z-50"})})})]}),et("div",{className:"flex justify-end space-x-2",children:[et("button",{type:"button",onClick:e,className:"rounded border border-slate-200 px-2 py-1 text-xs font-medium text-gray-700 transition hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",children:a("cancel")}),et("button",{type:"submit",disabled:!i.trim(),className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-50",children:a("create")})]})]})]})}),document.body)},jr=(t,n)=>e.PlainDate.compare(t,n),Yr=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:o,disabled:i,onDaySelect:l})=>et(r,{children:[et("div",{className:"grid grid-cols-7 gap-1 px-1 pt-2 pb-3 text-center text-[12px] tracking-wide text-slate-400 uppercase dark:text-gray-500",children:o.map(e=>et("span",{children:e},e))}),et("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const r=e.month!==t.month,o=0===jr(e,n),s=0===jr(e,a),d=jr(e,n)>=0&&jr(e,a)<=0;return et("button",{type:"button",disabled:i,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||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())})})]}),Fr=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>et("div",{className:"flex items-center justify-between border-b border-slate-100 px-3 py-2 text-sm font-medium text-slate-700 dark:border-gray-600 dark:text-gray-300",children:[et("div",{className:"flex items-center gap-1",children:[et("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(nr,{width:14,height:12})}),et("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(er,{width:14,height:12})})]}),et("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),et("div",{className:"flex items-center gap-1",children:[et("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(tr,{width:14,height:12})}),et("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(rr,{width:14,height:12})})]})]}),zr=Array.from({length:24},(e,t)=>t),_r=Array.from({length:60},(e,t)=>t),Wr=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const i=e,l=t["start"===i?0:1],s=l.minute,d=_r.includes(s)?_r:[..._r,s].toSorted((e,t)=>e-t);return et("div",{className:"flex flex-col rounded-xl border border-slate-200 bg-white shadow-sm sm:w-28 dark:border-gray-600 dark:bg-gray-800",children:[et("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:et("div",{className:"py-1.5 text-base text-slate-700 dark:text-gray-300",children:[l.hour.toString().padStart(2,"0"),":",l.minute.toString().padStart(2,"0")]})}),et("div",{className:"flex p-1",children:[et("div",{className:"w-14",children:et("div",{className:`h-72 overflow-y-auto ${xn} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[i]&&(o.current[i].hour=e)},children:zr.map(e=>{const t=e===l.hour;return et("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary font-semibold text-primary-foreground":"text-slate-600 hover:bg-primary/10 hover:text-primary dark:text-gray-300"),"data-active":t?"true":void 0,children:yt(e)},e)})})}),et("div",{className:"w-14",children:et("div",{className:`h-72 overflow-y-auto ${xn} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[i]&&(o.current[i].minute=e)},children:d.map(e=>{const t=e===s;return et("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary font-semibold text-primary-foreground":"text-slate-600 hover:bg-primary/10 hover:text-primary dark:text-gray-300"),"data-active":t?"true":void 0,children:yt(e)},e)})})})]})]})},Ur=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:i,disabled:l,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:v,onOk:f,getPopupStyle:p})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return et("div",{ref:d,style:p(),"data-range-picker-popup":"true",children:et("div",{className:"space-y-3 rounded-xl border border-slate-200 bg-white p-3 dark:border-gray-600 dark:bg-gray-800",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[et("div",{className:"flex gap-1",children:[et("div",{className:"w-full flex-3 rounded-xl border border-slate-200 bg-white shadow-sm dark:border-gray-600 dark:bg-gray-800",children:[et(Fr,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),et(Yr,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&et("div",{className:"flex flex-1 justify-end sm:w-32",children:et(Wr,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),et("div",{className:"flex justify-end",children:et("button",{type:"button",onClick:f,disabled:l,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"})})]})})},Br=({value:t,format:n="YYYY-MM-DD HH:mm",showTimeFormat:r="HH:mm",showTime:a=!0,onChange:o,onOk:i,timeZone:l,disabled:d=!1,placement:c="bottomLeft",autoAdjustOverflow:f=!0,getPopupContainer:p,matchTriggerWidth:y=!1,locale:b="en-US"})=>{const w=v(()=>"string"==typeof b?b:(null==b?void 0:b.code)||"en-US",[b]),D=v(()=>void 0===a||("object"==typeof a||Boolean(a)),[a]),x=v(()=>Er(w,"short"),[w]),E=v(()=>xr(w,"narrow"),[w]),C=v(()=>D?"object"==typeof a&&(null==a?void 0:a.format)?a.format:r:"",[D,a,r]),k=v(()=>bt(n,C),[n,C]),T=v(()=>Dt(k),[k]),N=v(()=>{const n=null!=l?l:z(t[0])?z(t[1])?e.Now.timeZoneId():Et(t[1]):Et(t[0]),r=Ct(t[0],n);return[r,Ct(t[1],n,r)]},[t,l]),[S,M]=u(N),I=g(N),[A,H]=u("start"),[O,R]=u([kt(N[0],n,C),kt(N[1],n,C)]),P=g([kt(N[0],n,C),kt(N[1],n,C)]),L=g(N),[$,j]=u(N[0].toPlainDate().with({day:1})),[Y,F]=u(!1),_=m(e=>{F(e)},[]),[W,U]=u(c),B=g(c),Z=g(null),V=g(null),G=g({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=g(!1),q=g(!1);h(()=>{P.current=O},[O]),h(()=>{L.current=S},[S]),h(()=>{const t=I.current,n=0!==e.ZonedDateTime.compare(t[0],N[0]),r=0!==e.ZonedDateTime.compare(t[1],N[1]);(n||r)&&M(N),I.current=N},[N]),h(()=>{j(N[0].toPlainDate().with({day:1}))},[N[0]]);const X=m((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,i=(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:i})},[]),J=m(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&X(n,r,0)})})})},[X]);h(()=>{Y&&D&&J(A)},[A,Y,J,D]);const Q=S[0].epochMilliseconds,ee=S[0].offsetNanoseconds,te=S[1].epochMilliseconds,ne=S[1].offsetNanoseconds;h(()=>{if(q.current)return;const[e,t]=L.current,r=kt(e,n,C),a=kt(t,n,C),[o,i]=P.current;o===r&&i===a||(P.current=[r,a],R([r,a]))},[Q,ee,te,ne,n,C]),h(()=>{if(!Y)return;const e=e=>{var t,n;const r=e.target;if(null===(t=Z.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=V.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-range-picker-popup]")||_(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[Y]),h(()=>{Y||(H("start"),K.current||M(N),K.current=!1)},[Y,N]);const re=m(e=>{o&&o(e,[kt(e[0],n,C),kt(e[1],n,C)])},[C,n,o]),ae=m(e=>{i&&i(e,[kt(e[0],n,C),kt(e[1],n,C)])},[C,n,i]),oe=m((t,n)=>{M(r=>{const a=[...r];if("start"===t){const t=Ct(a[1],Et(n),n),r=e.ZonedDateTime.compare(n,t)>0?n:t;return[n,r]}const o=Ct(a[0],Et(n),n);return[e.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ie=t=>{if(d)return;const n=(t,n)=>{var r,a,o,i;const l=Et(t);return e.ZonedDateTime.from({timeZone:l,year:n.year,month:n.month,day:n.day,hour:t.hour,minute:t.minute,second:null!==(r=t.second)&&void 0!==r?r:0,millisecond:null!==(a=t.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=t.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=t.nanosecond)&&void 0!==i?i:0})};if("start"===A){const e=n(S[0],t),r=S[1].epochMilliseconds-S[0].epochMilliseconds,a=e.add({milliseconds:r});return void M([e,a])}const r=n(S[1],t),a=S[1].epochMilliseconds-S[0].epochMilliseconds;if(e.ZonedDateTime.compare(r,S[0])<0){const e=n(S[0],t),r=e.add({milliseconds:a});return void M([e,r])}const o=[S[0],r];M(o),j(r.toPlainDate().with({day:1}))},le=m((t,n)=>{if(d)return;const r="start"===t?0:1;M(a=>{const o=a[r],i=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Ct(a[1],Et(i),i);return[i,e.ZonedDateTime.compare(i,t)>0?i:t]}const l=Ct(a[0],Et(i),i);return[e.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=G.current[t].hour;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[d]),se=m((t,n)=>{if(d)return;const r="start"===t?0:1;M(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Ct(a[1],Et(o),o);return[o,e.ZonedDateTime.compare(o,t)>0?o:t]}const i=Ct(a[0],Et(o),o);return[e.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=G.current[t].minute;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[d]),de=m((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),ce=m((e,t)=>{const r="start"===e?0:1,a=S[r],o=Et(a),i=xt(t,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});return j(t),"start"===e&&H("end"),!0}return R(e=>{const t=[...e];return t[r]=kt(S[r],n,C),t}),!1},[S,C,n,T,oe]),ue=m(e=>t=>{const n=t.currentTarget.value;q.current=!0,de(e,n);const r="start"===e?0:1,a=L.current[r],o=Et(a),i=xt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});j(t),J(e)}},[de,T,oe,J]),he=m(e=>t=>{var r;if(d)return;if(q.current=!1,Y){const t="start"===e?0:1,r=kt(L.current[t],n,C);return void R(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=Z.current)||void 0===r?void 0:r.contains(a))||ce(e,t.currentTarget.value)},[ce,d,Y,n,C]),ge=m(e=>t=>{"Enter"===t.key&&(t.preventDefault(),q.current=!1,ce(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ce]),me=()=>{K.current=!0,re(S),ae(S),_(!1)},ve=e=>{j(t=>t.add({months:e}).with({day:1}))},fe=e=>{j(t=>t.add({years:e}).with({day:1}))},pe=v(()=>{const e=$,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[$]),ye=m((e=c)=>{if(!f||!Z.current)return e;const t=Z.current.getBoundingClientRect(),n=y?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,i=t.right;let l=e;return l.startsWith("bottom")&&r<500&&a>r?l=l.replace("bottom","top"):l.startsWith("top")&&a<500&&r>a&&(l=l.replace("top","bottom")),l.endsWith("Left")&&o<n&&i>o?l=l.replace("Left","Right"):l.endsWith("Right")&&i<n&&o>i&&(l=l.replace("Right","Left")),l},[f,y,c]),be=m(()=>{const e=ye();B.current!==e&&(B.current=e,U(e))},[ye]),we=e=>{if(d)return;H(e);const t=S["start"===e?0:1].toPlainDate().with({day:1});j(t);const n=ye();B.current!==n&&(B.current=n,U(n)),_(!0)};h(()=>{if(!Y)return;be();const e=()=>be();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[Y,be]);const De=()=>{if(!Z.current)return{};const e=Z.current.getBoundingClientRect(),t={position:"fixed",zIndex:9999};return B.current.startsWith("bottom")?t.top=e.bottom+8:t.bottom=window.innerHeight-e.top+8,c.endsWith("Left")?t.left=e.left:t.right=window.innerWidth-e.right,y&&(t.width=`${e.width}px`),t};return et("div",{className:"relative max-w-100",ref:Z,children:[et("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(d?"cursor-not-allowed border-slate-200 bg-slate-50 text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":Y?"border-primary bg-white shadow-md dark:bg-gray-700":"border-slate-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[et("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:et("input",{type:"text",name:"range-start",value:O[0],onChange:ue("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:he("start"),onKeyDown:ge("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(d?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===A&&Y?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:d})}),et(ur,{className:"text-slate-400 dark:text-gray-500"}),et("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:et("input",{type:"text",name:"range-end",value:O[1],onChange:ue("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:he("end"),onKeyDown:ge("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(d?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===A&&Y?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:d})})]}),Y&&s(et(Ur,{visibleMonth:$,monthLabels:x,weekDayLabels:E,calendarDays:pe,draftRange:S,focusedField:A,isTimeEnabled:!!D,disabled:d,matchTriggerWidth:y,popupRef:V,timeListRefs:G,onMonthChange:ve,onYearChange:fe,onDaySelect:ie,onHourSelect:le,onMinuteSelect:se,onOk:me,getPopupStyle:De}),p?p():document.body)]})},Zr=({options:e,value:t,onChange:n,registry:r,variant:a="desktop",disabled:o=!1})=>{const[i,l]=u(!1),[d,c]=u({}),m=g(null),v=g(null),f=()=>{if(v.current){const e=v.current.getBoundingClientRect(),t="mobile"===a,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`,c(n)}};h(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||l(!1)};return i&&(f(),window.addEventListener("mousedown",e),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[i]);const p=e=>(r||he()).resolveColors(e).lineColor,y=(e,t)=>{e.stopPropagation(),n(t),l(!1)},b=e.find(e=>e.value===t),w=()=>i&&"undefined"!=typeof window?s("mobile"===a?et("div",{"data-calendar-picker-dropdown":"true",style:d,className:Yn,children:e.map(e=>et("div",{className:"flex cursor-pointer items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>y(t,e.value),children:[et("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[et("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&et(lr,{className:"h-4 w-4 text-primary"})}),et("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),et("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}):et("ul",{"data-calendar-picker-dropdown":"true",style:d,className:"animate-in fade-in zoom-in-95 origin-top-left overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg transition-all duration-200 dark:border-gray-600 dark:bg-gray-700 dark:shadow-gray-900/50",children:e.map(e=>et("li",{className:"flex cursor-pointer items-center px-2 py-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 "+(t===e.value?"font-semibold":""),onClick:t=>y(t,e.value),children:[t===e.value?et("span",{className:"mr-2 text-sm text-primary",children:et(lr,{width:12,height:12})}):et("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),et("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),et("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return et("div","mobile"===a?{className:"relative inline-block",ref:m,children:[et("button",{type:"button",ref:v,disabled:o,onClick:e=>{e.stopPropagation(),o||l(!i)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(o?"cursor-default opacity-50":""),children:[et("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),et("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==b?void 0:b.label)||t}),et(sr,{className:"h-4 w-4 text-gray-400"})]}),w()]}:{className:"relative inline-block",ref:m,children:[et("button",{ref:v,type:"button",onClick:e=>{e.stopPropagation(),l(!i)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[et("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),et(sr,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),w()]})},Vr=({event:t,isOpen:n,onEventUpdate:r,onEventDelete:a,onClose:o,app:i})=>{var l;const[d,c]=u(t),{t:g}=vn();h(()=>{c(t)},[t]);const m=v(()=>(i?i.getCalendarRegistry():he()).getVisible().map(e=>({label:e.name,value:e.id})),[i,null==i?void 0:i.getCalendars()]),f=v(()=>!Be(t,d),[t,d]),p=v(()=>z(d.start)?d.end&&!z(d.end)&&d.end.timeZoneId||e.Now.timeZoneId():d.start.timeZoneId||e.Now.timeZoneId(),[d.end,d.start]),y=e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t.toPlainDate(),end:n.toPlainDate()}))},b=!(null==i?void 0:i.state.readOnly),w=!1!==(null==i?void 0:i.getReadOnlyConfig().viewable);if(!n||!w)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const D=et("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[et("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&&o()}}),et("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:[et("button",{type:"button",onClick:o,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-200","aria-label":"Close",children:et("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:et("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),et("div",{children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:g("eventTitle")}),et("div",{className:"mb-4 flex items-center justify-between gap-3",children:[et("div",{className:"flex-1",children:et("input",{id:`event-dialog-title-${d.id}`,name:"title",type:"text",value:d.title,readOnly:!b,disabled:!b,onChange:e=>{c(Object.assign(Object.assign({},d),{title:e.target.value}))},className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),b&&et(Zr,{options:m,value:d.calendarId||"blue",onChange:e=>{c(Object.assign(Object.assign({},d),{calendarId:e}))},registry:null==i?void 0:i.getCalendarRegistry()})]}),d.allDay?et("div",{className:"mb-4",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:g("dateRange")}),et(Br,{value:[d.start,d.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!b,onChange:y,onOk:y,locale:null==i?void 0:i.state.locale})]}):et("div",{className:"mb-4",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:g("timeRange")}),et(Br,{value:[d.start,d.end],timeZone:p,disabled:!b,onChange:e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t,end:n}))},onOk:e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t,end:n}))},locale:null==i?void 0:i.state.locale})]}),et("div",{className:"mb-4",children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:g("note")}),et("textarea",{id:`event-dialog-note-${d.id}`,name:"note",value:null!==(l=d.description)&&void 0!==l?l:"",readOnly:!b,disabled:!b,onChange:e=>c(Object.assign(Object.assign({},d),{description:e.target.value})),rows:4,className:"w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:g("addNotePlaceholder")})]}),b&&et("div",{className:"flex space-x-2",children:[d.allDay?et("button",{type:"button",className:"rounded-lg bg-secondary/10 px-3 py-2 text-xs font-medium text-secondary transition hover:bg-secondary/20",onClick:()=>{const t=z(d.start)?d.start:d.start.toPlainDate(),n=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),r=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});c(Object.assign(Object.assign({},d),{allDay:!1,start:n,end:r}))},children:g("setAsTimed")}):et("button",{type:"button",className:"rounded-lg bg-secondary/10 px-3 py-2 text-xs font-medium text-secondary transition hover:bg-secondary/20",onClick:()=>{const e=z(d.start)?d.start:d.start.toPlainDate();c(Object.assign(Object.assign({},d),{allDay:!0,start:e,end:e}))},children:g("setAsAllDay")}),et("button",{type:"button",className:"rounded-lg border border-border bg-destructive px-3 py-2 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>{a(t.id),o()},children:g("delete")}),et("button",{type:"button",className:"ml-auto rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground transition "+(f?"shadow-lg shadow-primary/20 hover:bg-primary/90":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>{r(d),o()},disabled:!f,children:g("save")})]})]})]})]}),x=document.body;return x?s(D,x):null},Gr=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),Kr=({app:e,anchorRef:t,onClose:n,isOpen:r})=>{const{t:a}=vn(),[o,i]=u(""),[l,d]=u(0),[c,m]=u(!1),f=g(null),y=g(null);h(()=>{r||m(!1)},[r]),h(()=>{r&&(setTimeout(()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()},50),i(""),d(0))},[r]),h(()=>{const e=e=>{r&&y.current&&!y.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,n,t]);const[b,w]=u({top:0,left:0}),[D,x]=u("top"),[E,C]=u(0),k=v(()=>{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}},[r]),T=v(()=>{if(!o.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=o.toLowerCase(),i=r.find(e=>e.title.toLowerCase()===a);let l=null==i?void 0:i.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 s=n.find(e=>e.id===l),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:o,calendarId:l||"",color:d,start:k.start,end:k.end});const c=new Set([o.toLowerCase()]);return r.filter(e=>e.title.toLowerCase().includes(a)&&!c.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{c.add(e.title.toLowerCase());const r=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==r?void 0:r.colors.lineColor)||"#9ca3af",start:k.start,end:k.end})}),t},[o,e,k]);p(()=>{if(r&&t.current&&y.current){const e=t.current.getBoundingClientRect(),n=y.current.offsetHeight,r=340;let a=e.left+e.width/2-r/2;const o=12,i=window.innerWidth;a<o?a=o:a+r>i-o&&(a=i-r-o);const l=e.left+e.width/2;C(l-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),x(d),w({top:s,left:a}),m(!0)}},[r,t,T]);const N=t=>{if(!t.calendarId)return;const r=Ge(),a={id:r,title:t.title,start:W(t.start),end:W(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return h(()=>{if(!r)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),d(e=>(e+1)%T.length)):"ArrowUp"===e.key?(e.preventDefault(),d(e=>(e-1+T.length)%T.length)):"Enter"===e.key&&(e.preventDefault(),T[l]&&N(T[l]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,T,l]),r?s(et("div",{ref:y,className:"fixed z-1000 flex w-85 flex-col rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-800 "+(c?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:b.top,left:b.left,visibility:c?"visible":"hidden"},children:[et("div",{className:"p-4 pb-2",children:[et("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:a("quickCreateEvent")||"Quick Create Event"}),et("div",{className:"relative",children:et("input",{ref:f,type:"text",className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:o,onChange:e=>i(e.target.value)})})]}),et("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===T.length&&o&&et("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:a("noSuggestions")||"Type to create"}),T.map((e,t)=>{return et("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===l?"bg-primary/10 ring-1 ring-primary/20 ring-inset dark:bg-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>N(e),onMouseEnter:()=>d(t),children:[et("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),et("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[et("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),et("div",{className:"flex",children:et("span",{className:"rounded bg-gray-100 px-1 text-[10px] font-semibold text-gray-500 dark:bg-slate-700 dark:text-gray-400",children:"new"===e.type?a("today"):a("tomorrow")})}),et("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Gr(n)} - ${Gr(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),et("div",{className:"absolute h-3 w-3 -translate-x-1/2 rotate-45 border-gray-200 bg-white dark:border-slate-700 dark:bg-slate-800 "+("top"===D?"-bottom-1.5 border-r border-b":"-top-1.5 border-t border-l"),style:{left:E}})]}),document.body):null},qr=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:r,onDateSelect:a})=>{const{locale:o}=vn(),i=v(()=>(new Date).toDateString(),[]),l=t.toDateString(),s=v(()=>xr(o,"narrow"),[o]),d=v(()=>e.toLocaleDateString(o,{month:"long",year:"numeric"}),[e,o]),c=v(()=>{const t=e.getFullYear(),n=e.getMonth(),r=(new Date(t,n,1).getDay()+6)%7,a=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-r+1),s=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:s===i,isSelected:s===l})}return a},[e,l,i]);return et("div",{className:"px-3 py-3",children:[n?et("div",{className:"mb-3 flex items-center justify-between",children:[et("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:et(er,{className:"h-4 w-4"})}),et("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:d}),et("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:et(tr,{className:"h-4 w-4"})})]}):"",et("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[s.map((e,t)=>et("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}`)),c.map(e=>et("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?Pn:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""} `,onClick:()=>a(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},Xr=({checked:e,onChange:t,disabled:n})=>et("div",{className:`flex h-7 w-12 items-center rounded-full p-1 transition-colors ${n?"cursor-default opacity-50":"cursor-pointer"} ${e?"bg-green-500":"bg-gray-300"}`,onClick:()=>!n&&t(!e),children:et("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),Jr=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),r=Array.from({length:12},(e,t)=>5*t),a=[...n,...n,...n],o=[...r,...r,...r],i=32,l=e.getHours(),s=5*Math.round(e.getMinutes()/5),d=(24+l)*i,c=(12+s/5)*i,[m,v]=u(d),[f,p]=u(c),y=g(null),b=g(null),w=g(null);h(()=>{y.current&&(y.current.scrollTop=d,v(d)),b.current&&(b.current.scrollTop=c,p(c))},[d,c]);const D=(n,r)=>{const l=n.currentTarget;let s=l.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,l.scrollTop=s):s>1600&&(s-=e,l.scrollTop=s),v(s)}else{const e=384;s<160?(s+=e,l.scrollTop=s):s>800&&(s-=e,l.scrollTop=s),p(s)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{((n,r)=>{const l=Math.round(r/i);if("hour"===n){const n=a[l];if(void 0!==n&&n!==e.getHours()){const r=new Date(e);r.setHours(n),t(r)}}else{const n=o[l];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,s)},150)},x=(e,t)=>{const n=96+e*i+16-(t+112),r=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*r})`,opacity:1-.7*r,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return et("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[et("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),et("div",{ref:y,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>D(e,"hour"),children:[et("div",{style:{height:96}}),a.map((n,r)=>et("div",{className:"flex h-8 cursor-pointer snap-center items-center justify-end pr-5",onClick:()=>{var a;const o=new Date(e);o.setHours(n),t(o),null===(a=y.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:et("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===l?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,m),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),et("div",{style:{height:96}})]}),et("div",{ref:b,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>D(e,"minute"),children:[et("div",{style:{height:96}}),o.map((n,r)=>et("div",{className:"flex h-8 cursor-pointer snap-center items-center justify-start pl-5",onClick:()=>{var a;const o=new Date(e);o.setMinutes(n),t(o),null===(a=b.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:et("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===s?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,f),children:n.toString().padStart(2,"0")})},`m-${r}-${n}`)),et("div",{style:{height:96}})]}),et("div",{className:"pointer-events-none absolute top-24 right-2 left-2 h-8 rounded-lg border border-gray-300 bg-gray-300/20 dark:border-gray-600 dark:bg-gray-500/20"})]})},Qr=({isOpen:e,onClose:t,onSave:n,onEventDelete:r,draftEvent:a,app:o,timeFormat:i="24h"})=>{const{locale:l,t:d}=vn(),c=o.getReadOnlyConfig(),g=!o.state.readOnly,m=!1!==c.viewable,[f,p]=u(""),[y,b]=u(""),[w,D]=u(!1),[x,E]=u(new Date),[C,k]=u(new Date),[T,N]=u(""),[S,M]=u(new Date),[I,A]=u(new Date),[H,O]=u(null),[R,P]=u(e),[L,$]=u(!1),[j,Y]=u(!1);h(()=>{if(!e){$(!0);const e=setTimeout(()=>{P(!1),$(!1)},300);return()=>clearTimeout(e)}P(!0),$(!1)},[e]),h(()=>{if(e&&a){const e=o.getEvents().some(e=>e.id===a.id);Y(e)}},[e,a,o]);const F=o.getCalendars(),z=F.map(e=>({label:e.name,value:e.id}));h(()=>{if(e&&F.length>0){F.some(e=>e.id===y)||"blue"!==y&&""!==y||b(F[0].id)}},[F,e,y]),h(()=>(e?(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=""}),[e]),h(()=>{var t,n;if(e&&a){if(p(a.title||""),b(a.calendarId||(null===(t=F[0])||void 0===t?void 0:t.id)||"blue"),D(a.allDay||!1),a.start)try{const e=B(a.start);E(e),M(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;E(t),M(t)}if(a.end)try{const e=B(a.end);k(e),A(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;k(t),A(t)}}else if(e&&!a){b((null===(n=F[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),E(e),M(e),k(new Date(e.getTime()+36e5)),A(e)}},[e,a]);const _=v(()=>{if(!e||!a)return!1;let t=new Date(x),n=new Date(C);w&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:f,calendarId:y,allDay:w,description:T,start:W(t),end:W(n)});return!Be(a,r)},[e,a,f,y,w,x,C,T]);if(!R||!m)return null;const U=e=>{O(t=>t===e?null:e)},Z=e=>e.toLocaleDateString(l,{day:"numeric",month:"short",year:"numeric"}),V=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(x.getHours(),x.getMinutes());const n=e.getTime()-x.getTime();E(e);const r=new Date(C.getTime()+n);k(r)}else{const e=new Date(t);e.setHours(C.getHours(),C.getMinutes()),k(e)}},G=(e,t)=>{"start"===e?M(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):A(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return s(et("div",{className:"pointer-events-none fixed inset-0 z-10000 flex items-end",children:[et("div",{className:"pointer-events-auto absolute inset-0 bg-black/30 transition-opacity duration-300 "+(L?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),et("div",{className:"pointer-events-auto relative flex h-[85vh] w-full flex-col overflow-hidden rounded-t-2xl bg-gray-100 shadow-xl dark:bg-gray-800 "+(L?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[et("div",{className:"flex items-center justify-between border-b border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900",children:[et("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:d("cancel")}),et("span",{className:"text-lg font-semibold",children:d(!g&&j?"viewEvent":j?"editEvent":"newEvent")}),g&&et("button",{type:"button",onClick:()=>{if(!a)return;let e=new Date(x),t=new Date(C);w&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:f,calendarId:y,allDay:w,start:W(e),end:W(t)});n(r)},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:d(j?"done":"create")}),!g&&et("span",{className:"w-12"})]}),et("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[et("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:et("input",{type:"text",placeholder:d("titlePlaceholder"),value:f,onChange:e=>g&&p(e.currentTarget.value),readOnly:!g,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:g})}),F.length>0&&et("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),et(Zr,{options:z,value:y,onChange:g?b:()=>{},registry:o.getCalendarRegistry(),variant:"mobile",disabled:!g})]}),et("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),et(Xr,{checked:w,onChange:g?D:()=>{},disabled:!g})]}),et("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[et("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),et("div",{className:"flex space-x-2",children:[et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-date"===H?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("start-date"),disabled:!g,children:Z(x)}),!w&&et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===H?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("start-time"),disabled:!g,children:be(x.getHours()+x.getMinutes()/60,0,i)})]})]}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===H?"max-h-100":"max-h-0"),children:et("div",{className:"",children:et(qr,{currentDate:x,visibleMonth:S,onDateSelect:e=>V("start",e),onMonthChange:e=>G("start",e),showHeader:!0})})}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===H?"max-h-75":"max-h-0"),children:et("div",{className:"",children:et(Jr,{date:x,onChange:e=>{const t=C.getTime()-x.getTime();E(e),k(new Date(e.getTime()+t))},timeFormat:i})})})]}),et("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[et("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),et("div",{className:"flex space-x-2",children:[et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-date"===H?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("end-date"),disabled:!g,children:Z(C)}),!w&&et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===H?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("end-time"),disabled:!g,children:be(C.getHours()+C.getMinutes()/60,0,i)})]})]}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===H?"max-h-100":"max-h-0"),children:et("div",{className:"",children:et(qr,{currentDate:C,visibleMonth:I,onDateSelect:e=>V("end",e),onMonthChange:e=>G("end",e),showHeader:!0})})}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===H?"max-h-75":"max-h-0"),children:et("div",{className:"",children:et(Jr,{date:C,onChange:e=>{if(e<x){const t=C.getTime()-x.getTime();k(e),E(new Date(e.getTime()-t))}else k(e)},timeFormat:i})})})]}),et("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:et("textarea",{placeholder:d("notesPlaceholder"),value:T,onChange:e=>g&&N(e.currentTarget.value),readOnly:!g,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),g&&j&&r&&a&&et("button",{type:"button",onClick:()=>r(a.id),className:"w-full rounded-lg bg-white px-4 py-3 text-left font-medium text-red-500 dark:bg-gray-900",children:d("delete")})]})]})]}),document.body)},ea=()=>et("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:et("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ta=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:a})=>{const{t:o,locale:i}=vn(),l=v(()=>Bt(new Date),[]),s=v(()=>Vt(t,l),[t,l]),d=e=>Ut(e);return e?et("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[et(hr,{className:"mb-2 h-8 w-8 animate-spin"}),et("span",{children:"Loading..."})]}):0===t.length?n?et("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[et(ea,{}),et("span",{className:"mt-2 text-sm",children:"string"==typeof a?a:a&&"object"==typeof a?a[i]||a.en||"No results found":o("noResults")||"No results found"})]}):null:et("div",{className:"space-y-6",children:s.map(e=>{const{title:t,colorClass:n}=Zt(e.date,l,i,o);return et("div",{children:[et("h3",{className:`sticky top-0 z-10 mb-4 bg-white px-2 py-1 text-sm font-medium dark:bg-gray-900 ${n} border-b border-gray-200 dark:border-gray-700`,children:t}),et("div",{className:"flex flex-col",children:e.events.map(e=>{const t=d(e.start),n=d(e.end),a={hour:"2-digit",minute:"2-digit"},l=e.allDay?o("allDay")||"All Day":t.toLocaleTimeString(i,a),s=e.allDay?"":n.toLocaleTimeString(i,a);return et("div",{children:[et("div",{className:"group mx-2 mb-1 cursor-pointer rounded-lg p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",onClick:()=>null==r?void 0:r(e),children:et("div",{className:"flex items-stretch gap-3",children:[et("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),et("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[et("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),et("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[et("div",{className:"text-black dark:text-white",children:l}),s&&et("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),et("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},na=({isOpen:e,onClose:t,keyword:n,onSearchChange:r,results:a,loading:o,onResultClick:i,emptyText:l})=>{const d=g(null),{t:c}=vn();return h(()=>(e?(setTimeout(()=>{var e;null===(e=d.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?s(et("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[et("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[et("button",{type:"button",onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:et(br,{className:"h-6 w-6"})}),et("div",{className:"relative flex-1",children:[et("input",{ref:d,type:"text",placeholder:c("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&r(t)},className:"w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:ring-primary focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&et("button",{type:"button",onClick:()=>{""!==n&&r("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:et(dr,{className:"h-4 w-4"})})]})]}),et("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:et(ta,{loading:o,results:a,keyword:n,onResultClick:e=>{null==i||i(e)},emptyText:l})})]}),document.body):null},ra=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>et("div",{className:"relative hidden h-full flex-col overflow-hidden border-l border-gray-200 bg-white transition-all duration-300 ease-in-out select-none md:flex dark:border-gray-700 dark:bg-gray-900 "+(e?"w-64":"w-0 border-l-0"),children:et("div",{className:"min-w-64 flex-1 overflow-y-auto",children:et(ta,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let aa=null;function oa(e){aa=e}const ia={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function la(e){return aa&&e.hasPlugin("sidebar")?aa(e):ia}const sa=({locale:e,messages:t,children:n})=>vn().isDefault?et(kr,{locale:e,messages:t,children:n}):n,da=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,meta:r,customMessages:o,search:i,titleBarSlot:l,collapsedSafeAreaLeft:d})=>{const c=f(Ar),{tick:p,selectedEventId:b}=function(e){const[t,n]=u(0),[r,a]=u(null);return h(()=>e.subscribe(e=>{n(e=>e+1),a(t=>{var n;const r=null!==(n=e.state.selectedEventId)&&void 0!==n?n:null;return t===r?t:r})}),[e]),{tick:t,selectedEventId:r}}(e),{isMobile:w}=function(){const[e,t]=u(!1);return h(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),D=function(e,t){const[n,r]=u(""),[a,o]=u(!1),[i,l]=u(!1),[s,d]=u(!1),[c,g]=u([]);h(()=>{e.state.highlightedEventId&&e.selectEvent(e.state.highlightedEventId)},[e.state.highlightedEventId,e]),h(()=>{a||null===e.state.highlightedEventId||e.highlightEvent(null)},[a,e]),h(()=>{var r;if(!n.trim())return o(!1),g([]),void(null!==e.state.highlightedEventId&&e.highlightEvent(null));const a=null!==(r=null==t?void 0:t.debounceDelay)&&void 0!==r?r:300,i=setTimeout(()=>y(this,void 0,void 0,function*(){var r;d(!0),o(!0);try{let a=[];if(null==t?void 0:t.customSearch){const r=e.getEvents().map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})});a=t.customSearch({keyword:n,events:r})}else if(null==t?void 0:t.onSearch)a=yield t.onSearch(n);else{const t=n.toLowerCase();a=e.getEvents().filter(e=>e.title.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)).map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})})}g(a),null===(r=null==t?void 0:t.onSearchStateChange)||void 0===r||r.call(t,{keyword:n,loading:!1,results:a})}catch(e){console.error("Search failed",e),g([])}finally{d(!1)}}),a);return()=>clearTimeout(i)},[n,t,e]);const v=m(t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):B(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),i&&l(!1)},[e,i]),f=m(()=>{r(""),l(!0)},[]),p=m(()=>{o(!1),r(""),e.highlightEvent(null)},[e]),b=m(()=>{l(!1),r(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:r,isSearchOpen:a,setIsSearchOpen:o,isMobileSearchOpen:i,setIsMobileSearchOpen:l,searchLoading:s,searchResults:c,handleSearchResultClick:v,handleSearchClick:f,handleSearchClose:p,handleMobileSearchClose:b}}(e,i),x=n||(e.getUseEventDetailDialog()?Vr:void 0),E=function(e,t,n){const[r,a]=u(null);h(()=>{a(null)},[e]);const o=m(()=>{a(null),e.selectEvent(null)},[e]),i=m(t=>e.updateEvent(t.id,t),[e]),l=m(t=>{e.deleteEvent(t),a(null),e.selectEvent(null)},[e]),s=v(()=>{if(!t||!r)return null;const n=r.split("::")[0],a=e.getEvents().find(e=>e.id===n);return a?{event:a,isOpen:!0,isAllDay:z(a.start),onEventUpdate:i,onEventDelete:l,onClose:o,app:e}:null},[n,r,t,o,i,l,e]);return{detailPanelEventId:r,setDetailPanelEventId:a,dialogProps:s}}(e,x,p),C=la(e),k=function(e,t,n){const[r,a]=u(!1),o=g(null),[i,l]=u(!1),[s,d]=u(null),[c,h]=u(!1),v=m(()=>{h(!0)},[]),f=m(i=>{var s,c;if(!e.state.readOnly){if(t){const t=new Date;t.setMinutes(0,0,0),t.setHours(t.getHours()+1);const n=new Date(t);n.setHours(n.getHours()+1);const r={id:Ge(),title:"",start:W(t),end:W(n),calendarId:(null===(s=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===s?void 0:s.id)||(null===(c=e.getCalendars()[0])||void 0===c?void 0:c.id)};return d(r),void l(!0)}n?r?a(!1):(o.current=i.currentTarget,a(!0)):v()}},[t,r,e,n,v]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:a,quickCreateAnchorRef:o,isMobileDrawerOpen:i,setIsMobileDrawerOpen:l,mobileDraftEvent:s,setMobileDraftEvent:d,handleAddButtonClick:f,isCreateCalendarOpen:c,setIsCreateCalendarOpen:h}}(e,w,C.enabled),[T,N]=u(()=>e.getTheme());h(()=>e.subscribeThemeChange(e=>N(e)),[e]);const S=m(t=>e.setTheme(t),[e]);h(()=>{const t=e.callbacks,n=t.onDismissUI;return t.onDismissUI=()=>{E.detailPanelEventId&&E.setDetailPanelEventId(null),k.isMobileDrawerOpen&&k.setIsMobileDrawerOpen(!1),null==n||n()},()=>{t.onDismissUI=n}},[e,E,k]),h(()=>{if(!w||!E.detailPanelEventId)return;const t=E.detailPanelEventId.split("::")[0],n=e.getEvents().find(e=>e.id===t);n&&(k.setMobileDraftEvent(n),k.setIsMobileDrawerOpen(!0)),E.setDetailPanelEventId(null)},[E.detailPanelEventId,w]);const M=m(t=>{e.setCurrentDate(t),e.selectEvent(null)},[e]),I=m(t=>e.selectEvent(t),[e]),A=g(null),H={app:e,config:e.getCurrentView().config||{},customDetailPanelContent:t,customEventDetailDialog:x,switcherMode:e.state.switcherMode,calendarRef:A,meta:r,selectedEventId:b,onEventSelect:I,onDateChange:M,detailPanelEventId:E.detailPanelEventId,onDetailPanelToggle:E.setDetailPanelEventId},O=v(()=>({isCollapsed:C.isCollapsed,toggleCollapsed:C.toggleCollapsed}),[C.isCollapsed,C.toggleCollapsed]),R=void 0!==d,P=R?"0px":C.miniWidth,L=R&&C.isCollapsed?d:C.safeAreaLeft,$=e.getCalendarHeaderConfig(),j=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:k.handleAddButtonClick,onSearchChange:D.setSearchKeyword,onSearchClick:D.handleSearchClick,searchValue:D.searchKeyword,isSearchOpen:D.isSearchOpen,isEditable:!e.state.readOnly},L>0?{safeAreaLeft:L}:{}),Y=e.getCurrentView().component,F=e.getCustomMobileEventRenderer()||Qr;return et(Mr,{initialTheme:T,onThemeChange:S,children:et(sa,{locale:e.state.locale,messages:o,children:et("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[et(Or,{store:c,generatorName:"titleBarSlot",generatorArgs:O,defaultContent:l&&("function"==typeof l?l(O):l)}),C.enabled&&et("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:C.width},children:C.content}),et("div",{className:"relative z-10 flex h-full flex-1 flex-col overflow-hidden border-l bg-white transition-all duration-250 ease-in-out dark:bg-gray-900 "+(C.isCollapsed?"border-gray-200 shadow-xl dark:border-gray-700":"border-transparent"),style:{marginLeft:C.enabled?C.isCollapsed?P:C.width:0},children:[!1===$?null:"function"==typeof $?$(j):a(Nr,j),et("div",{className:"relative flex-1 overflow-hidden",ref:A,children:[et("div",{className:"calendar-renderer relative flex h-full flex-row",children:[et("div",{className:"h-full flex-1 overflow-hidden",children:et(Y,Object.assign({},H))}),et(ra,{isOpen:D.isSearchOpen,onClose:D.handleSearchClose,loading:D.searchLoading,results:D.searchResults,keyword:D.searchKeyword,onResultClick:D.handleSearchResultClick,emptyText:null==i?void 0:i.emptyText})]}),et(na,{isOpen:D.isMobileSearchOpen,onClose:D.handleMobileSearchClose,keyword:D.searchKeyword,onSearchChange:D.setSearchKeyword,results:D.searchResults,loading:D.searchLoading,onResultClick:D.handleSearchResultClick,emptyText:null==i?void 0:i.emptyText})]})]}),et(Kr,{app:e,anchorRef:k.quickCreateAnchorRef,isOpen:k.isQuickCreateOpen,onClose:()=>k.setIsQuickCreateOpen(!1)}),et(F,{isOpen:k.isMobileDrawerOpen,onClose:()=>{k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onSave:t=>{e.getEvents().some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onEventDelete:t=>{e.deleteEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},draftEvent:k.mobileDraftEvent,app:e}),C.extraContent,k.isCreateCalendarOpen&&et($r,{app:e,onClose:()=>k.setIsCreateCalendarOpen(!1),onCreate:t=>{e.createCalendar(t),k.setIsCreateCalendarOpen(!1)}}),(()=>{if(!E.dialogProps)return null;const e=x,t="undefined"==typeof document?null:document.body;if(!t)return null;const n=null==c?void 0:c.isOverridden("eventDetailDialog");return et(Or,{store:c,generatorName:"eventDetailDialog",generatorArgs:E.dialogProps,defaultContent:n?null:s(a(e,E.dialogProps),t)})})()]})})})};class ca{constructor(e){this.renderings=new Map,this.overrides=new Set,this.listeners=new Set,e&&e.length>0&&(this.overrides=new Set(e))}register(e){this.renderings.set(e.id,e),this.notify()}unregister(e){this.renderings.delete(e)&&this.notify()}setOverrides(e){this.overrides=new Set(e),this.notify()}isOverridden(e){return this.overrides.has(e)}subscribe(e){return this.listeners.add(e),e(this.renderings),()=>{this.listeners.delete(e)}}notify(){this.listeners.forEach(e=>e(this.renderings))}}class ua{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new ca(t),t&&this.app.setOverrides(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){Ke(this.extraProps,e)||(this.extraProps=e,this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.requestRender()}unmount(){this.container&&(o(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&o(a(Ar.Provider,{value:this.customRenderingStore},a(da,Object.assign({app:this.app},this.extraProps))),this.container)}}const ha=d(({x:e,y:t,onClose:n,children:r,className:a},o)=>{const i=g(null);h(()=>{const e=()=>n(),t=e=>{if(i.current&&!i.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;n()}};window.dispatchEvent(new CustomEvent("dayflow-close-all-menus")),window.addEventListener("dayflow-close-all-menus",e),document.body.addEventListener("mousedown",t,{capture:!0}),document.body.addEventListener("contextmenu",t,{capture:!0});const r=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",r);const a=()=>n();return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",r),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n]);return s(et("div",{ref:e=>{i.current=e,"function"==typeof o?o(e):o&&"current"in o&&(o.current=e)},className:`animate-in fade-in-0 zoom-in-95 fixed z-50 min-w-32 overflow-visible rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md duration-100 ease-out dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 ${a||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:r}),document.body)});ha.displayName="ContextMenu";const ga=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>et("div",{className:`group relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] transition-colors outline-none select-none ${a?"pointer-events-none opacity-50":"hover:bg-primary hover:text-white focus:bg-primary focus:text-white dark:hover:bg-primary dark:hover:text-white dark:focus:bg-primary dark:focus:text-white"} ${r?"text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground":"text-slate-900 dark:text-slate-50"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&et("span",{className:"mr-2 h-4 w-4",children:n}),t]}),ma=()=>et("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),va=({children:e})=>et("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),fa=({children:e})=>{const[t,n]=u(!1),r=g(null);return h(()=>()=>{r.current&&clearTimeout(r.current)},[]),et("div",{className:"relative",onMouseEnter:()=>{r.current&&(clearTimeout(r.current),r.current=null),n(!0)},onMouseLeave:()=>{r.current=setTimeout(()=>{n(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>i(e)?l(e,{isOpen:t}):e)})},pa=({children:e,icon:t,isOpen:n})=>et("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] transition-colors outline-none select-none hover:bg-primary hover:text-white focus:bg-primary focus:text-white dark:hover:bg-primary dark:hover:text-white dark:focus:bg-primary dark:focus:text-white "+(n?"bg-primary text-white":""),children:[t&&et("span",{className:"mr-2 h-4 w-4",children:t}),et("span",{className:"grow text-left",children:e}),et(tr,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),ya=({children:e,isOpen:t})=>{const n=g(null),[r,a]=u("right");return h(()=>{var e;if(t&&n.current){const t=n.current.getBoundingClientRect(),r=null===(e=n.current.parentElement)||void 0===e?void 0:e.getBoundingClientRect();r&&(r.right+t.width>window.innerWidth?a("left"):a("right"))}},[t]),t?et("div",{ref:n,className:"animate-in fade-in-0 zoom-in-95 absolute top-0 z-50 min-w-32 overflow-hidden rounded-md border border-slate-200 bg-white p-1 whitespace-nowrap text-slate-950 shadow-md duration-100 ease-out dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",style:{left:"right"===r?"100%":"auto",right:"left"===r?"100%":"auto",marginLeft:"right"===r?"0.25rem":0,marginRight:"left"===r?"0.25rem":0},"data-submenu-content":"true",children:e}):null},ba=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],wa=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=vn();return et("div",{children:[et("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:ba.map(n=>et("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-primary focus:ring-offset-1 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-primary ring-offset-1 dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&et("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-slate-700 transition-colors hover:bg-primary hover:text-white dark:text-slate-200 dark:hover:bg-primary dark:hover:text-white",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},Da=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:i,viewType:l})=>{const{t:s}=vn(),d=Gt.hasEvent();return et(ha,{x:t,y:n,onClose:a,className:"df-context-menu",children:[et(ga,{onClick:()=>{i(),a()},children:s("newEvent")||"New Event"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){yield((t,n,r)=>y(void 0,void 0,void 0,function*(){if(Gt.hasEvent())try{let a=Gt.getEvent();if(!a){const e=yield navigator.clipboard.readText();e&&(a=JSON.parse(e))}if(a&&"object"==typeof a&&"title"in a){const o=a,i=lt(o.start),l=lt(o.end).getTime()-i.getTime(),s=a,d=new Date(n),c=r===I.MONTH||r===I.YEAR,u=0===d.getHours()&&0===d.getMinutes(),h=0!==i.getHours()||0!==i.getMinutes();!o.allDay&&(c||u&&h)&&d.setHours(i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds());const g=new Date(d.getTime()+(l>0?l:36e5)),m=Object.assign(Object.assign({},s),{title:o.title,id:Ge(),start:o.allDay?st(d):ct(d,e.Now.timeZoneId()),end:o.allDay?st(g):ct(g,e.Now.timeZoneId()),calendarId:o.calendarId&&t.getCalendarRegistry().has(o.calendarId)?o.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(m)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,l),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},xa=({event:e,x:t,y:n,onClose:a,app:o})=>{var i;const{t:l}=vn(),s=o.getCalendars(),d=o.callbacks,c=null===(i=null==d?void 0:d.renderEventContextMenu)||void 0===i?void 0:i.call(d,e,a);return et(ha,{x:t,y:n,onClose:a,children:[et(fa,{children:[et(pa,{children:l("calendars")||"Calendars"}),et(ya,{children:s.map(t=>{const n=t.id===e.calendarId;return et(ga,{onClick:()=>{return n=t.id,o.updateEvent(e.id,{calendarId:n}),void a();var n},children:et("div",{className:"flex w-full items-center",children:[et("div",{className:"w-4 shrink-0",children:n&&et(lr,{className:"h-3 w-3 text-primary"})}),et("div",{className:"flex min-w-0 items-center gap-1.5",children:[et("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:t.colors.lineColor}}),et("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),et(ma,{}),et(ga,{onClick:()=>{o.deleteEvent(e.id),a()},danger:!0,children:l("delete")||"Delete"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e),o.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:l("cut")||"Cut"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e)}catch(e){console.error("Failed to copy event: ",e)}a()}),children:l("copy")||"Copy"}),c&&et(r,{children:[et(ma,{}),c]})]})},Ea=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("假期")?et(gr,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?et(mr,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?et(fr,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?et(vr,{className:"h-3 w-3"}):et(cr,{className:"h-3 w-3"})},Ca=(e,t,n=7)=>{const r=[],a=new Date(t);return a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999),e.forEach(e=>{const o=B(e.start),i=B(e.end),l=new Date(o);l.setHours(0,0,0,0);const s=new Date(i);s.setHours(0,0,0,0);let d=new Date(s);if(!e.allDay){if(!(0!==i.getHours()||0!==i.getMinutes()||0!==i.getSeconds())){const e=i.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}}const c=J(l,d)>0;if(!c&&e.allDay){if(l<t||l>a)return;const o=Math.floor((l.getTime()-t.getTime())/864e5);return void(o>=0&&o<=n-1&&r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:o,endDayIndex:o,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!c)return;const u=l;let h;if(e.allDay)h=new Date(s),h.setHours(23,59,59,999);else{0!==i.getHours()||0!==i.getMinutes()||0!==i.getSeconds()?(h=new Date(s),h.setHours(23,59,59,999)):(h=new Date(s),h.setTime(h.getTime()-1))}if(h<t||u>a)return;const g=u<t?t:u,m=h>a?a:h,v=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),f=Math.min(n-1,Math.floor((m.getTime()-t.getTime())/864e5)),p=u>=t,y=h<=a,b=0===v||f===n-1;let w;w=p&&y?"single":p?b&&f===n-1?"start-week-end":"start":y?b&&0===v?"end-week-start":"end":"middle";const D=J(u,h)+1;r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:v,endDayIndex:f,segmentType:w,totalDays:D,segmentIndex:0,isFirstSegment:p,isLastSegment:y})}),r},ka=(e,t,n=7)=>{if(e.allDay)return[];const r=B(e.start),a=B(e.end),o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);const l=J(o,i);if(0===l)return[];const s=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),d=a.getTime()-r.getTime();if(!e.allDay&&1===l&&!s&&d<864e5)return[];const c=s?l:Math.max(0,l-1),u=[];for(let e=0;e<=c;e++){const i=new Date(o);i.setDate(o.getDate()+e);const l=Math.floor((i.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const d=0===e,h=e===c,g=d?r.getHours()+r.getMinutes()/60:0,m=h&&s?a.getHours()+a.getMinutes()/60:24;u.push({dayIndex:l,startHour:g,endHour:m,isFirst:d,isLast:h})}return u},Ta=c(({segment:e,segmentIndex:t,isDragging:n,isResizing:a=!1,isSelected:o=!1,onMoveStart:i,onResizeStart:l,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:h=!0,viewable:m=!0,isPopping:v,renderSlot:f})=>{const[p,y]=u(!1),b=17*t,w=`calc(${e.startDayIndex/7*100}% + 2px)`,D=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,x=g(null),E=g(null),C=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&l&&h?et("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 z-20 w-1 cursor-ew-resize opacity-0 transition-opacity group-hover:opacity-100`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},k=()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",r=ne(e.event.start),a=we(e.event),o=be(r),i=be(a);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return et("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&Ea(e.event)&&et("div",{className:"mr-1 shrink-0",children:et("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:pe(n),width:"12px",height:"12px"},children:Ea(e.event)})}),et("div",{className:"min-w-0 flex-1",children:et("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&et("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:et("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?e.event.title:"···",s=e.endDayIndex-e.startDayIndex+1,c=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return et("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[et("div",{className:Hn,style:{backgroundColor:pe(n)}}),et("div",{className:"flex min-w-0 flex-1 items-center",children:et("span",{className:`block overflow-hidden whitespace-nowrap ${d?"mobile-mask-fade":"truncate"} text-xs font-medium`,children:l})}),e.isFirstSegment&&!d&&et("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:c,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!d&&et("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})},T=e.event.calendarId||"blue",N=e.endDayIndex-e.startDayIndex+1;return et("div",{className:"group absolute flex items-center px-1 text-xs transition-all duration-200 select-none hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20",style:Object.assign(Object.assign({left:w,width:D,top:`${b}px`,height:"16px",borderRadius:(S=e.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"}[S]),pointerEvents:"auto",zIndex:10,transform:v?"scale(1.02)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},o||n||p?{backgroundColor:fe(T),color:"#fff"}:{backgroundColor:me(T),color:ve(T)}),{cursor:c||m?"pointer":"default"}),"data-segment-days":N,onMouseDown:t=>{if(!c&&!m)return;t.preventDefault(),t.stopPropagation(),y(!0);!t.target.closest(".resize-handle")&&c&&(null==i||i(t,e.event))},onMouseUp:()=>{y(!1)},onMouseLeave:()=>{y(!1)},onTouchStart:t=>{if(!i||!d||!c&&!m)return;t.stopPropagation(),y(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;E.current={x:r,y:a},x.current=setTimeout(()=>{s&&s(e.event.id);c&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),x.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(x.current&&E.current){const t=Math.abs(e.touches[0].clientX-E.current.x),n=Math.abs(e.touches[0].clientY-E.current.y);(t>10||n>10)&&(clearTimeout(x.current),x.current=null,E.current=null,y(!1))}},onTouchEnd:()=>{y(!1),x.current&&(clearTimeout(x.current),x.current=null),E.current=null},title:`${e.event.title} (${tt(e.event.start)} - ${tt(e.event.end)})`,children:[d&&o&&h&&et(r,{children:[e.isFirstSegment&&et("div",{className:"pointer-events-auto absolute top-1/2 left-5 z-50 h-2.5 w-2.5 -translate-y-1/2 rounded-full border-2 bg-white",style:{borderColor:pe(T)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"left")}}),e.isLastSegment&&et("div",{className:"pointer-events-auto absolute top-1/2 right-5 z-50 h-2.5 w-2.5 -translate-y-1/2 rounded-full border-2 bg-white",style:{borderColor:pe(T)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"right")}})]}),C("left"),et("div",{className:"min-w-0 flex-1",style:{cursor:a?"ew-resize":"pointer"},children:f?f(k()):k()}),C("right")]});var S});Ta.displayName="MultiDayEvent";const Na=({event:e,isEditable:t,onResizeStart:n,isMultiDay:r,segment:a,isSlidingView:o})=>{const i=!1!==e.icon,l="boolean"==typeof e.icon?null:e.icon;return et("div",{className:"absolute inset-0 flex items-center overflow-hidden pl-3 px-1 group py-0",style:(()=>{if(!o||!r||!a)return{};if(a.startDayIndex<2&&a.endDayIndex>=2){return{paddingLeft:`calc(${(2-a.startDayIndex)/(a.endDayIndex-a.startDayIndex+1)*100}% + 0.75rem)`}}return{}})(),children:[n&&t&&et("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()}}),i&&(l?et("div",{className:"mr-1 shrink-0",children:l}):et(cr,{className:On})),et("div",{className:`${An} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&et("div",{className:Rn,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Sa=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return et("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?et("div",{className:`${Jn} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?et("span",{className:`inline-block ${Jn} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):et(cr,{className:`${On} ${t?"text-white":""}`})),et("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Ma=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(ne(e.start)).toString().padStart(2,"0")}:${Math.round(ne(e.start)%1*60).toString().padStart(2,"0")}`;return et("div",{className:"text-xs cursor-pointer flex items-center justify-between px-0.5",children:[et("div",{className:"flex min-w-0 flex-1 items-center",children:[et("div",{style:{backgroundColor:pe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Hn}),et("span",{className:`block overflow-hidden whitespace-nowrap ${a?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&et("span",{className:`${Kn} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Ia=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:i,onResizeStart:l,timeFormat:s="24h"})=>{const d=n?n.startHour:ne(e.start),c=n?n.endHour:we(e),u=c-d,h=!n||n.isFirst,g=!n||n.isLast,m=e.calendarId||"blue";return et(r,{children:[et("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:pe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),et("div",{className:"flex h-full flex-col overflow-hidden pl-3 "+(we(e)-ne(e.start)<=.25?"px-1 py-0":"p-1"),children:[et("div",{className:`${An} pr-1`,style:{lineHeight:u<=.25?"1.2":"normal"},children:e.title}),u>.5&&et("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${be(d,0,s)} - ${be(c,0,s)}`:De(e,s)})]}),l&&a&&et(r,{children:[h&&et("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")}),g&&et("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")}),!h&&g&&n&&et("div",{className:Rn,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&i&&l&&a&&et(r,{children:[et("div",{className:"absolute -top-1.5 right-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:pe(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),et("div",{className:"absolute -bottom-1.5 left-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:pe(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},Aa=({event:e,segment:t,isEditable:n,onMoveStart:a,onResizeStart:o,renderSlot:i})=>{const l=!!e.allDay,s=e.calendarId||"blue",d=pe(s),c=l?Ea(e):null,{isFirstSegment:u,isLastSegment:h}=t,g=t=>{const r="left"===t,a=r?u:h;return e.allDay&&a&&o&&n?et("div",{className:`resize-handle absolute ${r?"left-0":"right-0"} top-0 bottom-0 z-20 w-1 cursor-ew-resize opacity-0 transition-opacity group-hover:opacity-100`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),o(t,e,r?"left":"right")},onTouchStart:t=>{t.stopPropagation(),o(t,e,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},m=()=>{if(l){const n=()=>t.isFirstSegment?e.title:"···";return et("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full min-w-0 items-center",onMouseDown:t=>{a&&(t.stopPropagation(),a(t,e))},children:[t.isFirstSegment&&Ea(e)&&et("div",{className:"df-year-event-icon mr-1 shrink-0",children:et("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:pe(s),width:"12px",height:"12px"},children:Ea(e)})}),et("div",{className:"min-w-0 flex-1",children:et("div",{className:"df-year-event-title overflow-hidden text-[12px] leading-[16px] whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:n()})}),t.isLastSegment&&!t.isFirstSegment&&et("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:et("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const n=t.isFirstSegment?e.title:"";return et("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full items-center gap-1 overflow-hidden",onMouseDown:t=>{a&&(t.stopPropagation(),a(t,e))},children:[!l&&et("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),l&&c&&et("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:c}),et("span",{className:"df-year-event-title block w-full overflow-hidden text-[12px] leading-[16px] font-medium whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:n})]})};return et(r,{children:[g("left"),i?i(m()):m(),g("right")]})};const Ha=({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,yearSegment:o,segmentIndex:i,isBeingDragged:l,isBeingResized:s,isEventSelected:d,isPopping:c,isEditable:u,isDraggable:h,canOpenDetail:g,isTouchEnabled:m,hideTime:v,isMobile:f,isSlidingView:p,app:y,onMoveStart:b,onResizeStart:w,multiDaySegmentInfo:D,customRenderingStore:x,eventContentSlotArgs:E,timeFormat:C="24h"})=>{const k=t===I.MONTH,T=t===I.YEAR,N=function(e,t,n){const r=t.charAt(0).toUpperCase()+t.slice(1),a=n?`eventContentAllDay${r}`:`eventContent${r}`;return(null==e?void 0:e.isOverridden(a))?a:null}(x,t,n);if(k&&r&&a)return et(Ta,{segment:a,segmentIndex:null!=i?i:0,isDragging:l||d,isResizing:s,isSelected:d,onMoveStart:b,onResizeStart:w,isMobile:f,isDraggable:h,isEditable:u,viewable:g,isPopping:c,renderSlot:e=>et(Or,{store:x,generatorName:N,generatorArgs:E,defaultContent:e})});if(T&&o)return et(Aa,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:w,renderSlot:e=>et(Or,{store:x,generatorName:N,generatorArgs:E,defaultContent:e})});let S;return S=k?e.allDay?et(Sa,{event:e,isEventSelected:d}):et(Ma,{event:e,app:y,isEventSelected:d,hideTime:v,isMobile:f}):e.allDay?et(Na,{event:e,isEditable:u,onResizeStart:w,isMultiDay:r,segment:a,isSlidingView:p}):et(Ia,{event:e,app:y,multiDaySegmentInfo:D,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:w,timeFormat:C}),et(Or,{store:x,generatorName:N,generatorArgs:E,defaultContent:S})},Oa=({event:t,position:n,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:i,selectedEventElementRef:l,onEventUpdate:d,onEventDelete:c,app:g})=>{var m;const{effectiveTheme:f}=Ir(),p=Ot(f),{t:y}=vn(),[b,w]=u(t.title),[D,x]=u(null!==(m=t.description)&&void 0!==m?m:"");h(()=>{w(t.title)},[t.title]),h(()=>{var e;x(null!==(e=t.description)&&void 0!==e?e:"")},[t.description]),h(()=>{const e=setTimeout(()=>{b!==t.title&&d(Object.assign(Object.assign({},t),{title:b}))},500);return()=>clearTimeout(e)},[b,t]),h(()=>{const e=setTimeout(()=>{var e;const n=null!==(e=t.description)&&void 0!==e?e:"";D!==n&&d(Object.assign(Object.assign({},t),{description:D}))},500);return()=>clearTimeout(e)},[D,t]);const E=v(()=>z(t.start)?t.end&&!z(t.end)&&t.end.timeZoneId||e.Now.timeZoneId():t.start.timeZoneId||e.Now.timeZoneId(),[t.end,t.start]),C=v(()=>(g?g.getCalendarRegistry():he()).getVisible().map(e=>({label:e.name,value:e.id})),[g,null==g?void 0:g.getCalendars()]),k="dark"===p||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),T=!(null==g?void 0:g.state.readOnly);if(!(!1!==(null==g?void 0:g.getReadOnlyConfig().viewable)))return null;const N=k?"#1f2937":"white",S=k?"rgb(55, 65, 81)":"rgb(229, 231, 235)",M=(()=>{var e;let t={};if("sticky-top"===o){const r=null===(e=i.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(r){const e=r.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=r.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)}}else if(n&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-n.top,u=r.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,m=Math.max(g,Math.min(h,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),I=et("div",{ref:r,className:`${jn} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[et("div",{style:M}),et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:y("eventTitle")}),et("div",{className:"mb-3 flex items-center justify-between gap-3",children:[et("div",{className:"flex-1",children:et("input",{id:`event-title-${t.id}`,name:"title",type:"text",value:b,readOnly:!T,disabled:!T,onChange:e=>w(e.target.value),onInput:e=>w(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),T&&et(Zr,{options:C,value:t.calendarId||"blue",onChange:e=>{d(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==g?void 0:g.getCalendarRegistry()})]}),et("div",a?{className:"mb-3",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:y("dateRange")}),et(Br,{value:[t.start,t.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!T,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n.toPlainDate(),end:r.toPlainDate()}))},locale:null==g?void 0:g.state.locale})]}:{className:"mb-3",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:y("timeRange")}),et(Br,{value:[t.start,t.end],timeZone:E,disabled:!T,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n,end:r}))},locale:null==g?void 0:g.state.locale})]}),et("div",{className:"mb-3",children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:y("note")}),et("textarea",{id:`event-note-${t.id}`,name:"note",value:D,readOnly:!T,disabled:!T,onChange:e=>x(e.target.value),onInput:e=>x(e.target.value),rows:3,className:"w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:y("addNotePlaceholder")})]}),T&&et("div",{className:"flex space-x-2",children:[et("button",a?{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const n=z(t.start)?t.start:t.start.toPlainDate(),r=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),a=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});d(Object.assign(Object.assign({},t),{allDay:!1,start:r,end:a}))},children:y("setAsTimed")}:{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const e=z(t.start)?t.start:t.start.toPlainDate();d(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:e}))},children:y("setAsAllDay")}),et("button",{type:"button",className:"rounded bg-destructive px-2 py-1 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>c(t.id),children:y("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const A=document.body;return A?s(I,A):null},Ra=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:a,calendarRef:o,selectedEventElementRef:i,onEventUpdate:l,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=Ir(),g=Ot(h),m="dark"===g?"#1f2937":"white",v="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let r={};if("sticky-top"===a){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;r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===a){const e=n.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}r={position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)}}else if(t&&i.current&&o.current){const e=i.current.getBoundingClientRect(),a=o.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,f=Math.max(g,Math.min(h,c));r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),p=et("div",{ref:n,className:`${jn} p-3`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===g?"#1f2937":"#ffffff"},children:[et("div",{style:f}),et(u,{event:e,isAllDay:r,onEventUpdate:l,onEventDelete:d,onClose:c})]});return s(p,document.body)},Pa=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,handlePanelClose:u,customRenderingStore:h,contentSlotRenderer:g,customDetailPanelContent:m,app:v})=>{if(!e)return null;if(t)return null;if(!n)return null;const f={event:r,position:n,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?et(Ra,Object.assign({},f,{contentRenderer:g})):m?et(Ra,Object.assign({},f,{contentRenderer:m})):et(Oa,Object.assign({},f,{app:v}))},La=(e,t)=>{if(!e.current)return t?48:80;const n=e.current.querySelector(".df-time-column");return n?n.getBoundingClientRect().width:t?48:80},$a=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto";const i=e===I.DAY,l=e===I.MONTH,s=e===I.YEAR;i?o+=" df-day-event flex flex-col":l||s?s&&(o+=" df-year-event transition-colors group px-1 overflow-hidden whitespace-nowrap cursor-pointer"):o+=" df-week-event flex flex-col";const d=()=>{if(n&&r){const{segmentType:e}=r;if("single"===e||"start"===e)return Mn;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 Mn};if(s)return`${o} ${(()=>{if(a){const{isFirstSegment:e,isLastSegment:t}=a;return e&&t?"rounded":e?"rounded-l rounded-r-none":t?"rounded-r rounded-l-none":"rounded-none"}return"rounded"})()}`;if(l){let e=`\n ${o}\n ${t?d():In}\n `;return n||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${t?d():In}\n `},ja=({event:e,layout:t,isAllDay:n=!1,allDayHeight:a=28,calendarRef:o,isBeingDragged:i=!1,isBeingResized:l=!1,viewType:s,isMultiDay:d=!1,segment:c,yearSegment:p,columnsPerRow:y,segmentIndex:b=0,hourHeight:w,firstHour:D,selectedEventId:x,detailPanelEventId:E,onMoveStart:C,onResizeStart:k,onEventUpdate:T,onEventDelete:N,newlyCreatedEventId:S,onDetailPanelOpen:M,onEventSelect:A,onEventLongPress:H,onDetailPanelToggle:O,customDetailPanelContent:R,customEventDetailDialog:P,multiDaySegmentInfo:L,app:$,isMobile:j=!1,isSlidingView:Y=!1,enableTouch:F,hideTime:z,timeFormat:_="24h"})=>{const W=f(Ar),U=null!=F?F:j,B=s===I.YEAR,[Z,V]=u(null),[G,K]=u(!1),q=g(null),X=g(null),J=g(null),Q=g(null),ee=d&&c?`${e.id}::${c.id}`:void 0===(null==L?void 0:L.dayIndex)?B&&p?p.id:e.id:`${e.id}::day-${L.dayIndex}`,te=E===ee,re=te&&!P,ae=null==$?void 0:$.getReadOnlyConfig(),oe=!(null==$?void 0:$.state.readOnly),ie=!1!==(null==ae?void 0:ae.viewable),le=!1!==(null==ae?void 0:ae.draggable),{isSelected:se,setIsSelected:de,isPressed:ce,setIsPressed:ue,handleTouchStart:he,handleTouchMove:ge,handleTouchEnd:pe}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:a,canOpenDetail:o,app:i,multiDaySegmentInfo:l,isMultiDay:s,segment:d,detailPanelKey:c})=>{const[h,m]=u(!1),[v,f]=u(!1),p=g(null),y=g(null);return{isSelected:h,setIsSelected:m,isPressed:v,setIsPressed:f,handleTouchStart:a=>{if(!n||!t)return;f(!0);const o=a.touches[0],i=o.clientX,c=o.clientY,u=a.currentTarget;y.current={x:i,y:c},p.current=setTimeout(()=>{var t;r?r(e.id):m(!0);const a={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:i,clientY:c}],cancelable:!1};if(l){const r=Object.assign(Object.assign({},e),{day:null!==(t=l.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:l});n(a,r)}else if(s&&d){const t=Object.assign(Object.assign({},e),{day:d.startDayIndex,_segmentInfo:{dayIndex:d.startDayIndex,isFirst:d.isFirstSegment,isLast:d.isLastSegment}});n(a,t)}else n(a,e);p.current=null,y.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(p.current&&y.current){const t=Math.abs(e.touches[0].clientX-y.current.x),n=Math.abs(e.touches[0].clientY-y.current.y);(t>10||n>10)&&(clearTimeout(p.current),p.current=null,y.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),p.current&&(clearTimeout(p.current),p.current=null),t&&y.current&&(n.preventDefault(),n.stopPropagation(),i&&i.onEventClick(e),o?null==a||a(c):null==a||a(null)),y.current=null}}})({event:e,isTouchEnabled:U,onMoveStart:C,onEventLongPress:H,onDetailPanelToggle:O,canOpenDetail:ie,app:$,multiDaySegmentInfo:L,isMultiDay:d,segment:c,detailPanelKey:ee}),ye=(void 0===x?se:x===e.id)||!U&&ce||i,[be,De]=u("visible"),xe=e=>{Q.current=e},Ee=m(()=>((e,t,n,r,a,o)=>{var i;if(null!==r)return r;if(t===n){const e=n.split("::").at(-1);if(e&&e.startsWith("day-")){const t=Number(e.replace("day-",""));if(!Number.isNaN(t))return t}}return void 0!==(null==a?void 0:a.dayIndex)?a.dayIndex:o?o.startDayIndex:null!==(i=e.day)&&void 0!==i?i:0})(e,E||void 0,ee,Q.current,L,c),[e,E,ee,L,c]),Ce=m(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===I.MONTH){const t=a.width/7,n=e-a.left,r=Math.floor(n/t);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const o=La(t,r),i=n===I.DAY?1:7,l=(a.width-o)/i,s=e-a.left-o,d=Math.floor(s/l);return Number.isFinite(d)?Math.max(0,Math.min(i-1,d)):null})(e,o,s,j),[o,s,j]),ke=m(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===I.MONTH){const t=a.width/7;return{left:a.left+e*t,width:t}}const o=La(t,r);if(n===I.DAY){const e=a.width-o;return{left:a.left+o,width:e}}const i=(a.width-o)/7;return{left:a.left+o+e*i,width:i}})(e,o,s,j),[o,s,j]),{detailPanelPosition:Te,setDetailPanelPosition:Ne,updatePanelPosition:Se}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,multiDaySegmentInfo:o,calendarRef:i,eventRef:l,detailPanelRef:s,selectedEventElementRef:d,isMobile:c,eventVisibility:g,firstHour:v,hourHeight:f,columnsPerRow:p,showDetailPanel:y,detailPanelEventId:b,detailPanelKey:w,getActiveDayIdx:D,getDayMetricsWrapper:x})=>{const[E,C]=u(null),k=t===I.DAY,T=t===I.MONTH,N=t===I.YEAR,S=m(()=>{if(!d.current||!i.current||!s.current)return;const e=i.current.getBoundingClientRect(),t=D(),a=x(t);let o,u;if(a)o=a.left,u=a.width;else if(T)u=e.width/7,o=e.left+t*u;else{const n=La(i,c);u=(e.width-n)/7,o=e.left+n+t*u}const h=Math.min(window.innerWidth,e.right),m=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{var a,i,c;if(!s.current)return;if(!d.current)return;const u=s.current.getBoundingClientRect(),v=u.width,f=u.height;let p,y,b;if("sticky-top"===g||"sticky-bottom"===g){const e=null===(a=l.current)||void 0===a?void 0:a.getBoundingClientRect();if(!e)return;b=e}else b=d.current.getBoundingClientRect();if(T&&n&&r){const n=x(t),r=null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e.width/7,a=null!==(c=null==n?void 0:n.left)&&void 0!==c?c:e.left+t*r,o=a+r;b={top:b.top,bottom:b.bottom,left:a,right:o,width:o-a,height:b.height,x:a,y:b.top,toJSON:()=>({})}}const w=h-b.right,D=b.left-e.left;p=w>=v+20?b.right+10:D>=v+20?b.left-v-10:w>D?Math.max(e.left+10,h-v-10):e.left+10;const E=b.top-f/2+b.height/2,k=Math.max(10,e.top+10),S=m-10;y=E<k?k:E+f>S?S-f:E,C(e=>{if(!e)return null;let t=p<o;return N&&(t=p<b.left),Object.assign(Object.assign({},e),{top:y,left:p,isSunday:t})})})},[i,e.day,e.start,e.end,g,T,v,f,n,r,o,b,w,c,k,N,a,p,D,x,d,s,l]);return h(()=>{!y||E||c||(C({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>S()))},[y,E,S,c]),{detailPanelPosition:E,setDetailPanelPosition:C,updatePanelPosition:S}})({event:e,viewType:s,isMultiDay:d,segment:c,yearSegment:p,multiDaySegmentInfo:L,calendarRef:o,eventRef:q,detailPanelRef:X,selectedEventElementRef:J,isMobile:j,eventVisibility:be,firstHour:D,hourHeight:w,columnsPerRow:y,showDetailPanel:te,detailPanelEventId:E,detailPanelKey:ee,getActiveDayIdx:Ee,getDayMetricsWrapper:ke}),{handleClick:Me,handleDoubleClick:Ie,handleContextMenu:Ae}=(({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,multiDaySegmentInfo:o,calendarRef:i,firstHour:l,hourHeight:s,isMobile:d,canOpenDetail:c,detailPanelKey:u,app:h,onEventSelect:g,onDetailPanelToggle:v,setIsSelected:f,setDetailPanelPosition:p,setContextMenuPosition:y,setActiveDayIndex:b,getClickedDayIdx:w,updatePanelPosition:D,selectedEventElementRef:x})=>{const E=t===I.MONTH,C=t===I.YEAR,k=m(()=>new Promise(t=>{if(!i.current||n||E||C)return void t();const r=i.current.querySelector(".calendar-content");if(!r)return void t();const a=o?o.startHour:ne(e.start),d=o?o.endHour:we(e),c=(a-l)*s,u=c+Math.max((d-a)*s,s/4),h=r.scrollTop,g=r.clientHeight;if(c>=h&&u<=h+g)return void t();const m=((a+d)/2-l)*s-g/2,v=r.scrollHeight-g;r.scrollTo({top:Math.max(0,Math.min(v,m)),behavior:"smooth"}),setTimeout(()=>t(),300)}),[i,n,E,C,o,e.start,e.end,l,s]),T=m(t=>{t.preventDefault(),t.stopPropagation(),g&&g(e.id),y({x:t.clientX,y:t.clientY})},[e.id,g,y]),N=m(t=>{var n,o,i,l,s;if(t.preventDefault(),t.stopPropagation(),!c)return;let h=t.currentTarget;if(r){const e=h.querySelector("div");e&&(h=e)}if(x.current=h,r){const r=w(t.clientX);b(null===r?null!==(o=null!==(n=null==a?void 0:a.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==o?o:0:Math.min(Math.max(r,null!==(i=null==a?void 0:a.startDayIndex)&&void 0!==i?i:0),null!==(l=null==a?void 0:a.endDayIndex)&&void 0!==l?l:6))}else b(null!==(s=e.day)&&void 0!==s?s:null);k().then(()=>{f(!0),d||(null==v||v(u),p({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>D()))})},[c,r,x,w,b,null==a?void 0:a.startDayIndex,null==a?void 0:a.endDayIndex,e.day,k,f,d,v,u,p,D]);return{handleClick:m(t=>{var n,i,l;if(t.preventDefault(),t.stopPropagation(),r){const r=w(t.clientX);b(null===r?null!==(i=null!==(n=null==o?void 0:o.dayIndex)&&void 0!==n?n:e.day)&&void 0!==i?i:null:a?Math.min(Math.max(r,a.startDayIndex),a.endDayIndex):r)}else b(null!==(l=e.day)&&void 0!==l?l:null);h&&h.onEventClick(e),g?g(e.id):c&&f(!0),null==v||v(null),p(null)},[r,w,b,a,null==o?void 0:o.dayIndex,e,h,g,c,f,v,p]),handleDoubleClick:N,handleContextMenu:T,scrollEventToCenter:k}})({event:e,viewType:s,isAllDay:n,isMultiDay:d,segment:c,multiDaySegmentInfo:L,calendarRef:o,firstHour:D,hourHeight:w,isMobile:j,canOpenDetail:ie,detailPanelKey:ee,app:$,onEventSelect:A,onDetailPanelToggle:O,setIsSelected:de,setDetailPanelPosition:Ne,setContextMenuPosition:V,setActiveDayIndex:xe,getClickedDayIdx:Ce,updatePanelPosition:Se,selectedEventElementRef:J}),{calculateEventStyle:He}=(({event:e,layout:t,isAllDay:n,allDayHeight:r,viewType:a,isMultiDay:o,segment:i,yearSegment:l,columnsPerRow:s,segmentIndex:d,hourHeight:c,firstHour:u,isEventSelected:h,showDetailPanel:g,isPopping:m,isDraggable:v,canOpenDetail:f,eventVisibility:p,calendarRef:y,isMobile:b,eventRef:w,getActiveDayIdx:D,getDayMetricsWrapper:x,multiDaySegmentInfo:E})=>{const C=a===I.DAY,k=a===I.MONTH,T=a===I.YEAR;return{calculateEventStyle:()=>{var a,N,S,M,I,A,H,O;if(T&&l&&s){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=l,r=2;return{position:"absolute",left:`calc(${e/s*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/s*100}% - ${2*r}px)`,height:"16px",opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"}}if(k)return o&&i?{opacity:1,zIndex:h||g?1e3:1,cursor:v||f?"pointer":"default"}:{opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"};if(n){const e={height:r-4+"px",opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"},t=d*r;if(Object.assign(e,{top:`${t}px`}),C)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(o&&i){const t=s||7,n=(i.endDayIndex-i.startDayIndex+1)/t*100,r=i.startDayIndex/t*100,a=2,o=i.isFirstSegment?a:0,l=o+(i.isLastSegment?a:0);Object.assign(e,{width:l>0?`calc(${n}% - ${l}px)`:`${n}%`,left:o>0?`calc(${r}% + ${o}px)`:`${r}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const R=E?E.startHour:ne(e.start),P=E?E.endHour:we(e),L={top:(R-u)*c+3+"px",height:Math.max((P-R)*c,c/4)-4+"px",position:"absolute",opacity:1,zIndex:h||g?1e3:null!==(a=null==t?void 0:t.zIndex)&&void 0!==a?a:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"};if(h&&g&&("sticky-top"===p||"sticky-bottom"===p)){const e=null===(N=y.current)||void 0===N?void 0:N.getBoundingClientRect();if(e){const n=D(),r=La(y,b),a=C?1:s||7;let o=(e.width-r)/a,i=e.left+r+(C?0:n*o);k&&(o=e.width/7,i=e.left+n*o);const l=x(n);l&&(i=l.left,o=l.width);let d=null===(S=y.current)||void 0===S?void 0:S.querySelector(".calendar-content");d||(d=null===(M=y.current)||void 0===M?void 0:M.querySelector(".calendar-renderer"));const c=null==d?void 0:d.getBoundingClientRect(),u=null===(A=null===(I=w.current)||void 0===I?void 0:I.parentElement)||void 0===A?void 0:A.getBoundingClientRect();let h,g;if(u&&u.width>0)t?(h=u.left+t.left/100*u.width,g=C?t.width/100*u.width:(t.width-1)/100*u.width):(h=u.left,g=C?u.width:u.width-3);else{const e=x(n),r=null!==(H=null==e?void 0:e.left)&&void 0!==H?H:i,a=null!==(O=null==e?void 0:e.width)&&void 0!==O?O:o;h=r,g=a-3,t&&(h=r+t.left/100*a,g=C?t.width/100*a:(t.width-1)/100*a)}if("sticky-top"===p){let t=c?c.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:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let m=c?c.bottom:e.bottom;return m=Math.min(m,window.innerHeight),m=Math.min(m,e.bottom),m=Math.max(m,e.top+6),m=Math.max(m,6),{position:"fixed",top:m-6+"px",left:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!n){const e=C?`${t.width}%`:t.width-1+"%";return Object.assign(Object.assign({},L),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},L),{left:"0px",right:C?"0px":"3px"})}}})({event:e,layout:t,isAllDay:n,allDayHeight:a,viewType:s,isMultiDay:d,segment:c,yearSegment:p,columnsPerRow:y,segmentIndex:b,hourHeight:w,firstHour:D,isEventSelected:ye,showDetailPanel:te,isPopping:G,isDraggable:le,canOpenDetail:ie,eventVisibility:be,calendarRef:o,isMobile:j,eventRef:q,getActiveDayIdx:Ee,getDayMetricsWrapper:ke,multiDaySegmentInfo:L});(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:r,calendarRef:a,isAllDay:o,viewType:i,multiDaySegmentInfo:l,firstHour:s,hourHeight:d,updatePanelPosition:c,eventVisibility:u,setEventVisibility:g})=>{const v=i===I.MONTH,f=i===I.YEAR,p=m(()=>{if(!t||!n||!r.current||!a.current||o||v||f)return;const i=a.current.querySelector(".calendar-content");if(!i)return;const h=l?l.startHour:ne(e.start),m=l?l.endHour:we(e),p=(h-s)*d,y=p+Math.max((m-h)*d,d/4),b=i.getBoundingClientRect(),w=i.scrollTop,D=w+b.height,x=b.bottom<0,E=b.top>window.innerHeight;let C=u;x?C="sticky-top":E?C="sticky-bottom":"visible"===u?y<w?C="sticky-top":p>D-20&&(C="sticky-bottom"):"sticky-top"===u?y>=w&&(C="visible"):"sticky-bottom"===u&&p<=D-20&&(C="visible"),C!==u&&g(C),c()},[t,n,a,o,v,e.start,e.end,s,d,c,l,u,g]);h(()=>{var e,r;if(!t||!n||o)return;const i=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!i)return;const l=()=>p(),s=()=>{p(),c()},d=[i];let u=null===(r=a.current)||void 0===r?void 0:r.parentElement;for(;u;){const e=window.getComputedStyle(u);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||d.push(u),u=u.parentElement}d.forEach(e=>{e.addEventListener("scroll",l)}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",s);let h=null;return a.current&&(h=new ResizeObserver(()=>{s()}),h.observe(a.current)),p(),()=>{d.forEach(e=>{e.removeEventListener("scroll",l)}),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",s),h&&h.disconnect()}},[t,n,o,p,c,a])})({event:e,isEventSelected:ye,showDetailPanel:te,eventRef:q,calendarRef:o,isAllDay:n,viewType:s,multiDaySegmentInfo:L,firstHour:D,hourHeight:w,updatePanelPosition:Se,eventVisibility:be,setEventVisibility:De});const Oe=te&&!!P;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:a,onEventSelect:o,onDetailPanelToggle:i,setIsSelected:l,setActiveDayIndex:s})=>{h(()=>{if(!r&&!a)return;const d=d=>{var c,u;const h=d.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),v=null===(u=t.current)||void 0===u?void 0:u.contains(h),f=h.closest("[data-event-detail-dialog]"),p=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");a?g||m||v||f||p||y||(null==o||o(null),s(null),l(!1),null==i||i(null)):!r||g||m||f||p||y||(null==o||o(null),s(null),l(!1),null==i||i(null))};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[r,a,o,i,n])})({eventRef:q,detailPanelRef:X,eventId:e.id,isEventSelected:!Oe&&ye,showDetailPanel:re,onEventSelect:A,onDetailPanelToggle:O,setIsSelected:de,setActiveDayIndex:xe});const Re=m(()=>{A&&A(null),Q.current=null,de(!1),null==O||O(null)},[A,O,de]),Pe=v(()=>({event:e,isAllDay:n,onEventUpdate:T,onEventDelete:N,onClose:Re}),[e,n,T,N,Re]),Le=v(()=>({event:e,viewType:s,isAllDay:n,isMobile:j,isSelected:ye,isDragging:i,segment:c,layout:t}),[e,s,n,j,ye,i,c,t]),$e=m(()=>et(Or,{store:W,generatorName:"eventDetailContent",generatorArgs:Pe}),[W,Pe]);h(()=>{if((null==$?void 0:$.state.highlightedEventId)===e.id){K(!0);const e=setTimeout(()=>{K(!1)},300);return()=>{clearTimeout(e),K(!1)}}},[null==$?void 0:$.state.highlightedEventId,e.id]),h(()=>{const t=d&&(null==c?void 0:c.isFirstSegment)||B&&(null==p?void 0:p.isFirstSegment)||!d&&!B;S===e.id&&!te&&t&&setTimeout(()=>{null==O||O(ee),null==M||M()},50)},[S,e.id,te,d,c,B,p,O,M,ee]);const je=e.calendarId||"blue",Ye=null==$?void 0:$.getCalendarRegistry();return et(r,{children:[et("div",{ref:q,"data-event-id":e.id,className:`${$a(s,n,d,c,p)} ${n&&S===e.id?"df-all-day-event-animate":""}`,style:Object.assign(Object.assign({},He()),{backgroundColor:ye?fe(je,Ye):me(je,Ye),color:ye?"#fff":ve(je,Ye)}),onClick:Me,onContextMenu:Ae,onDblClick:Ie,onMouseDown:t=>{var n;if(U||ue(!0),C){const r=t;C(r,L?Object.assign(Object.assign({},e),{day:null!==(n=L.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:L}):d&&c?Object.assign(Object.assign({},e),{day:c.startDayIndex,_segmentInfo:{dayIndex:c.startDayIndex,isFirst:c.isFirstSegment,isLast:c.isLastSegment}}):e)}},onMouseUp:()=>!U&&ue(!1),onMouseLeave:()=>!U&&ue(!1),onTouchStart:he,onTouchMove:ge,onTouchEnd:pe,children:et(Ha,{event:e,viewType:s,isAllDay:n,isMultiDay:d,segment:c,yearSegment:p,segmentIndex:b,isBeingDragged:i,isBeingResized:l,isEventSelected:ye,isPopping:G,isEditable:oe,isDraggable:le,canOpenDetail:ie,isTouchEnabled:U,hideTime:z,isMobile:j,isSlidingView:Y,app:$,onMoveStart:C,onResizeStart:k,multiDaySegmentInfo:L,customRenderingStore:W,eventContentSlotArgs:Le,layout:t,timeFormat:_})}),te&&!P&&et("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),et(Pa,{showDetailPanel:te,customEventDetailDialog:P,detailPanelPosition:Te,event:e,detailPanelRef:X,isAllDay:n,eventVisibility:be,calendarRef:o,selectedEventElementRef:J,onEventUpdate:T,onEventDelete:N,handlePanelClose:Re,customRenderingStore:W,contentSlotRenderer:$e,customDetailPanelContent:R,app:$}),Z&&$&&et(xa,{event:e,x:Z.x,y:Z.y,onClose:()=>V(null),app:$,onDetailPanelToggle:O,detailPanelKey:ee})]})},Ya=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=vn();return et("div",{className:"df-navigation flex items-center gap-1",children:[et("button",{type:"button",className:Ln,onClick:e,"aria-label":"Previous month",children:et(er,{className:$n})}),et("button",{type:"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:r("today")}),et("button",{type:"button",className:Ln,onClick:n,"aria-label":"Next month",children:et(tr,{className:$n})})]})},Fa=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:i,showTodayBox:l,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=vn(),g=void 0===l||l,m=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""}})(),v="day"===e?i||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return et("div",{className:pn,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"flex-1",children:et("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[et("h1",{className:yn,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&et("h1",{className:yn,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[et("div",{className:`${yn} text-gray-900 dark:text-white`,children:m}),v&&et("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:v})]})}),g&&n&&r&&a&&et("div",{className:"flex items-center gap-2",children:et(Ya,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})},za=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:a,organizedAllDayEvents:o,allDayAreaHeight:i,timeSlots:l,eventLayouts:s,isToday:d,currentTime:c,selectedEventId:h,setSelectedEventId:m,newlyCreatedEventId:f,setNewlyCreatedEventId:p,detailPanelEventId:y,setDetailPanelEventId:b,dragState:w,isDragging:D,handleMoveStart:x,handleResizeStart:E,handleCreateStart:C,handleCreateAllDayEvent:k,handleTouchStart:T,handleTouchEnd:N,handleTouchMove:S,handleDragOver:M,handleDrop:A,handleEventUpdate:H,handleEventDelete:O,onDateChange:R,customDetailPanelContent:P,customEventDetailDialog:L,calendarRef:$,allDayRowRef:j,timeGridRef:Y,switcherMode:F,isMobile:z,isTouch:_,setDraftEvent:W,setIsDrawerOpen:U,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:Z,FIRST_HOUR:V,LAST_HOUR:G,showAllDay:K,showStartOfDayLabel:q,timeFormat:X="24h",secondaryTimeSlots:J,primaryTzLabel:Q,secondaryTzLabel:ee})=>{var te;const ne=!!J&&J.length>0&&!z,{t:re,locale:ae}=vn(),oe=g(e.state.highlightedEventId),[ie,le]=u(null),se=v(()=>St(),[]),de=()=>{var e;const t=null===(e=$.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!t)return 0;const n=t.querySelector(".df-time-grid-row");return n?n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop:0},ce=(e,n)=>{var r,a,o,i;if(e.preventDefault(),z)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=$.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=de(),a=(e.clientY-t.top+n-r)/Z+V,s=Math.floor(a),d=Math.floor(60*(a-s)),c=15*Math.round(d/15),u=60===c?s+1:s,h=60===c?0:c;l.setHours(u,h,0,0)}}le({x:e.clientX,y:e.clientY,date:l})};return et("div",{className:`flex-none ${"buttons"===F?"":"md:w-[60%]"} w-full border-r border-gray-200 bg-white md:w-[70%] dark:border-gray-700 dark:bg-gray-900`,onContextMenu:e=>e.preventDefault(),children:[et("div",{className:`relative ${Xn} h-full`,children:[et("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:z||!se?"0px":"15px"},children:et(Fa,{calendar:e,viewType:I.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(ae,{weekday:"long"})})}),et("div",K?{className:Qn(Sn,"items-stretch border-t border-gray-200 dark:border-gray-700"),ref:j,style:{paddingRight:z||!se?"0px":"0.6875rem"},onContextMenu:e=>ce(e,!0),children:[et("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 flex w-12 items-center text-[10px] md:w-20 md:text-xs",onContextMenu:e=>e.preventDefault(),children:re("allDay")}),et("div",{className:Qn("relative flex flex-1 self-stretch",!z&&se?"border-r border-gray-200 dark:border-gray-700":""),children:et("div",{className:"relative w-full",style:{minHeight:`${i}px`},onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,r)},onDragOver:M,onDrop:e=>{A(e,t,void 0,!0)},children:o.map(t=>et(ja,{event:t,isAllDay:!0,viewType:I.DAY,segmentIndex:t.row,allDayHeight:B,calendarRef:$,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:Z,firstHour:V,onMoveStart:x,onEventUpdate:H,onEventDelete:O,newlyCreatedEventId:f,onDetailPanelOpen:()=>p(null),detailPanelEventId:y,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.state.readOnly,o=r.find(e=>e.id===t);(z||_)&&o&&n&&!a?(W(o),U(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),oe.current=null))},onEventLongPress:e=>{(z||_)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:z,enableTouch:_},t.id))})})]}:{className:Qn("border-b border-gray-200 dark:border-gray-700",!z&&se?"pr-2.75":"")}),et("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:et("div",{className:"relative flex",children:[d&&c&&(()=>{const e=c,t=e.getHours()+e.getMinutes()/60;if(t<V||t>G)return null;return et("div",{className:Tn,style:{top:`${(t-V)*Z}px`,width:"100%",height:0,zIndex:20,marginTop:ne?"2rem":"0.75rem"},children:[et("div",{className:"flex w-12 items-center md:w-20",children:[et("div",{className:"relative flex w-full items-center"}),et("div",{className:Nn,children:be(t,0,X,!1)})]}),et("div",{className:"flex flex-1 items-center",children:et("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),et("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 "+(ne?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[et("div",{className:ne?"h-8":"h-3",children:ne&&et("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[et("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:ee}),et("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:Q})]})}),l.map((e,t)=>{var n;return et("div",{className:En,children:et("div",ne?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly gap-1 text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:q&&0===t?"":null!==(n=null==J?void 0:J[t])&&void 0!==n?n:""}),et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:q&&0===t?"":e.label})]}:{className:`${Cn} text-[10px] md:text-[12px]`,children:q&&0===t?"":e.label})},t)})]}),et("div",{className:"grow select-none",children:[et("div",{className:Qn(Fn,!z&&se?"border-r":"","border-t-0"),style:ne?{height:"2rem"}:void 0,children:et("div",{className:`${zn} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:q?be(V,0,X):""})}),et("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:Y,children:[l.map((e,r)=>et("div",{className:Qn(kn,!z&&se?"border-r":""),onClick:()=>null==R?void 0:R(t),onDblClick:e=>{var r,a,o,i;const l=Math.floor((t.getTime()-n.getTime())/864e5),s=null===(a=null===(r=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!s)return;const d=(null===(i=null===(o=$.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===i?void 0:i.scrollTop)||0,c=de(),u=e.clientY-s.top+d-c;null==C||C(e,l,V+u/Z)},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);T(e,r)},onTouchEnd:N,onTouchMove:S,onDragOver:M,onDrop:e=>{var n,r,a,o;const i=null===(r=null===(n=$.current)||void 0===n?void 0:n.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=$.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=de(),d=e.clientY-i.top+l-s,c=Math.floor(V+d/Z);A(e,t,c)},onContextMenu:e=>ce(e,!1)},r)),et("div",{className:Qn(Fn,!z&&se?"border-r":""),children:et("div",ne?{className:"absolute -top-2.5 flex items-center justify-evenly text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",style:{left:z?"-5rem":"-5.5rem",width:z?"5rem":"5.5rem"},children:[et("span",{children:null!==(te=null==J?void 0:J[0])&&void 0!==te?te:""}),et("span",{children:be(0,0,X)})]}:{className:`${zn} -left-9.5`,children:be(0,0,X)})}),et("div",{className:"pointer-events-none absolute top-0 right-0 bottom-0 left-0",children:a.filter(e=>!e.allDay).map(t=>{const n=s.get(t.id);return et(ja,{event:t,layout:n,viewType:I.DAY,calendarRef:$,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:Z,firstHour:V,onMoveStart:x,onResizeStart:E,onEventUpdate:H,onEventDelete:O,newlyCreatedEventId:f,onDetailPanelOpen:()=>p(null),detailPanelEventId:y,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(z||_)&&a&&n?(W(a),U(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),oe.current=null))},onEventLongPress:e=>{(z||_)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:z,enableTouch:_},t.id)})})]})]})]})})]}),ie&&et(Da,{x:ie.x,y:ie.y,date:ie.date,viewType:I.DAY,onClose:()=>le(null),app:e,onCreateEvent:()=>{if(C){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===ie.date.getHours()&&0===ie.date.getMinutes())null==k||k({clientX:ie.x,clientY:ie.y},e);else{const t=ie.date.getHours()+ie.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:ie.x,clientY:ie.y};C(n,e,t)}}}})]})},_a=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h"})=>{const{t:c,locale:u}=vn(),h=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return et("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:et("div",{className:`${Xn} h-full`,children:[et("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:et("div",{children:[et("div",{className:"flex items-center justify-end gap-2",children:[et("div",{className:pn,style:{position:"relative"},children:et("div",{children:et("h1",{className:yn,children:" "})})}),et(Ya,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),et(qr,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l})]})}),et("div",{className:"flex-1 overflow-y-auto",children:et("div",{className:"p-4",children:[et("h3",{className:"text-lg font-semibold mb-3 sticky top-0 z-10 bg-white py-2 dark:bg-gray-900",children:t.toLocaleDateString(u,{weekday:"long",month:"long",day:"numeric"})}),0===h.length?et("p",{className:`${Vn} ${qn}`,children:c("noEvents")}):et("div",{className:"space-y-2",children:h.map(t=>et("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"border-primary bg-primary/10":"border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-800"} hover:bg-gray-100 dark:hover:bg-gray-700`,style:{borderLeftColor:pe(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[et("div",{className:`font-medium ${qn}`,children:t.title}),!t.allDay&&et("div",{className:`${Kn} ${Gn}`,children:[be(ne(t.start),0,d)," ","- ",be(we(t),0,d)]}),t.allDay&&et("div",{className:`${Kn} ${Gn}`,children:c("allDay")})]},t.id))})]})})]})})},Wa={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function Ua(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:ne(e.start),_endHour:e.allDay?0:we(e)})}function Ba(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:ne(e.start)}function Za(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:we(e)}function Va(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Ba(e)<Za(t)&&Ba(t)<Za(e))}function Ga(e,t){const n=Za(e)-Ba(e);if(n<1.25)return!1;const r=Ba(e)+.4*n,a=Ba(t)>=r,o=Va(e,t);return a&&o}function Ka(e,t,n=Wa){if(!Va(e,t))return!1;const r=Math.abs(Ba(e)-Ba(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Va(e,t)||!Ga(e,t)&&!Ga(t,e))}(e,t))}function qa(e,t){const n=Ba(e)<=Ba(t)&&Za(e)>=Za(t),r=Ba(e)<=Ba(t)&&Ba(t)<Za(e)&&Va(e,t);return n||r}function Xa(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r];n.add(r.id);for(const t of e){if(n.has(t.id))continue;Math.abs(Ba(r)-Ba(t))<=Wa.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Ba(e)-Ba(t));const o={events:a,startHour:Math.min(...a.map(e=>Ba(e))),endHour:Math.max(...a.map(e=>Za(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Ja(e){return"day"===e?.5:2.5}function Qa(e){const t=Za(e)-Ba(e);return Math.max(.1,Math.min(1,t/4))}function eo(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(Ka(e[t],e[n],Wa))return!0;return!1}function to(e,t,n,r,a={}){const o=Ja(a.viewType);let i=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*Ja(t):null}(e,a.viewType);null!==t&&(i=t)}const l="day"===a.viewType;let s=0;1===e.depth?s=l?.5:1.5:2===e.depth?s=l?-.01:-1:e.depth>=3&&(s=l?.55:-3.5);const d=t+i+s;let c=n-(i+s);if(d+c>t+n&&(c=t+n-d),r.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(a.containerWidth||320)/100,importance:Qa(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Za(t.event)-Ba(t.event)-(Za(e.event)-Ba(e.event)));1===u.length?to(u[0],d,c,r,a):eo(u.map(e=>e.event))?no(u,d,c,r,a):u.forEach(e=>to(e,d,c,r,a))}function no(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*Ja(a.viewType),s="day"===a.viewType;let d=1===i?s?.5:1.5:2===i?s?-.01:-1:s?.55:-3.5;const c=t+l+d,u=n-(l+d);if(u<=0)return void e.forEach(e=>to(e,t,n,r,a));let h=Wa.MARGIN_BETWEEN*(1===i?s?.15:.3:s?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(g+h);if(r.set(e.event.id,{id:e.event.id,left:n,width:g,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(a.containerWidth||320)/100,importance:Qa(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Za(t.event)-Ba(t.event)-(Za(e.event)-Ba(e.event)));1===t.length?to(t[0],n,g,r,a):eo(t.map(e=>e.event))?no(t,n,g,r,a):t.forEach(e=>to(e,n,g,r,a))}})}function ro(e,t,n={}){const r=100-("day"===n.viewType?0:Wa.EDGE_MARGIN_PERCENT);if(1===e.length)to(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-Wa.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{to(e,r*(o+Wa.MARGIN_BETWEEN),Math.max(o,Wa.MIN_WIDTH),t,n)})}}function ao(e){let t=0;for(const n of e.children)t+=1+ao(n);return t}function oo(e,t){var n,r;const a=null===(r=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===r?void 0:r.depth;return void 0===a?[]:t.filter(e=>e.depth===a).map(e=>({node:e,load:ao(e)})).toSorted((e,t)=>t.load-e.load)}function io(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function lo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function so(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>qa(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),lo(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),lo(t.event,e.event))}function co(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>co(e,t))}function uo(e,t){const n=[];return co(e,n),n.find(e=>qa(t.event,e.event))||n[0]||null}function ho(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],r=e.at(-1);if(n.load-r.load<2)break;const a=uo(n.node,r.node);if(!a)break;so(a,r.node),n.load--,r.load++,t++}}function go(e,t){const n=t.startHour-e.startHour;if(function(e,t){for(const n of e.events)for(const e of t.events)if(Va(n,e)&&Math.abs(Ba(e)-Ba(n))<Wa.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<Wa.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(qa(n,e))return!0;return!1}function mo(e,t,n){const r=t.events.filter(t=>qa(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const r=n.find(e=>e.id===t);return r&&Ka(e,r,Wa)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Ba(e)-Ba(t.parent))-Math.abs(Ba(e)-Ba(n.parent))),a[0].parent}function vo(e,t,n){if(0===t.length)return null;let r=1/0,a=[];for(const e of t){const t=e.children.length;t<r?(r=t,a=[e]):t===r&&a.push(e)}const o=Za(e)-Ba(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Za(t)-Ba(t):0}),0)?a[0]:a.at(-1)||null}function fo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function po(e){let t=0;for(const n of e.children)t+=1+po(n);return t}function yo(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),r=t.get(n.parentId);e&&r&&(e.parent=r,e.depth=r.depth+1,r.children.push(e))}return t}function bo(e,t){const n=t.get(e.id);if(!n)return null;let r=n;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const a=r.parent;if(!a)return null;const o=a.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,l=null;for(const e of o){const t=po(e);t<i&&(i=t,l=e)}return l?l.event:null}function wo(e,t,n){const r=[];if(1===e.length){const a=mo(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),fo(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>qa(t,e)));if(0===a.length){for(const a of e){const o=mo(a,t,n);if(o)r.push({child:a,parent:o}),fo(o,a);else{const t=e.find(e=>e.id!==a.id&&Va(e,a));if(t){const e=bo(t,yo(n));e&&(r.push({child:a,parent:e}),fo(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Za(t)-Ba(t)-(Za(e)-Ba(e)));if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],i=o.slice(t*e,(t+1)*e);for(const e of i)r.push({child:e,parent:n}),fo(n,e)}}else for(const e of o){const t=vo(e,a,o);t&&(r.push({child:e,parent:t}),fo(t,e))}return r}function Do(e,t){const n=[],r=new Map,a=new Map;t.forEach(e=>a.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:a.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),r.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],i=o.events.map(e=>a.get(e.id));let l=!1;for(let s=n-1;s>=0&&!l;s--){const n=e[s],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(go(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=wo(i,d,t);for(const t of e){const e=r.get(t.child.id),n=r.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}l=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const r=oo(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);io(r)&&ho(r)}}(e,n),o}const xo={calculateDayEventLayouts(e,t={}){const n=e.map(Ua);for(const e of n)e.parentId=void 0,e.children=[];const r=new Map,a=n.filter(e=>!e.allDay);if(0===a.length)return r;const o=function(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r],o=[r];for(n.add(r.id);o.length>0;){const t=o.shift();for(const r of e)n.has(r.id)||Va(t,r)&&(a.push(r),o.push(r),n.add(r.id))}t.push(a)}return t}(a);for(const e of o)if(1===e.length){const n="day"===t.viewType?0:Wa.EDGE_MARGIN_PERCENT;r.set(e[0].id,{id:e[0].id,left:0,width:100-n,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:Math.max(.1,Math.min(1,(e[0]._endHour-e[0]._startHour)/4))})}else{ro(Do(Xa([...e].toSorted((e,t)=>e._startHour!==t._startHour?e._startHour-t._startHour:t._endHour-t._startHour-(e._endHour-e._startHour))),e),r,t)}return r}},Eo=(e,t=1)=>{const n=(e.getDay()-t+7)%7,r=new Date(e);return r.setDate(e.getDate()-n),r.setHours(0,0,0,0),r},Co={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ko(t){const{app:n,onEventCreated:r}=t,{t:a}=vn(),o=m(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:m((t,o,i,l)=>{if(t.preventDefault(),!t.dataTransfer)return null;const s=t.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const t=JSON.parse(s);let d,c,u=!1;l?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:0,minute:0}),c=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:23,minute:59,second:59}),u=!0):void 0===i?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:9,minute:0}),c=d.add({hours:1})):(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:i,minute:0}),c=d.add({hours:1}));const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:a(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:t.calendarName}),description:"",start:d,end:c,calendarId:t.calendarId,allDay:u};return n.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]),handleDragOver:o}}let To=null;function No(e){To=e}const So={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function Mo(e,t){return To?To(e,t):So}const Io=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,switcherMode:o="buttons",selectedEventId:i,onEventSelect:l,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{const f=e.getEvents(),{screenSize:y}=gn(),b="desktop"!==y,[w,D]=u(!1),{hourHeight:x=Co.HOUR_HEIGHT,firstHour:E=Co.FIRST_HOUR,lastHour:C=Co.LAST_HOUR,allDayHeight:k=Co.ALL_DAY_HEIGHT,showAllDay:T=!0,timeFormat:N="24h",secondaryTimeZone:S}=t,M=x,A=E,H=C,O=k,R=!T;h(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const P=e.getCustomMobileEventRenderer()||Qr,[L,$]=u(null),[j,Y]=u(null),[F,z]=u(null),_=void 0===i?j:i,U=void 0===d?F:d,Z=v(()=>_&&f.find(e=>e.id===_)||null,[_,f]),V=e=>{l?l(e):Y(e)},[G,K]=u(null),[q,X]=u(!1),[J,Q]=u(null),ee=g(null),te=e.getCurrentDate(),[re,ae]=u(te),oe=g(te.getTime());te.getTime()!==oe.current&&(oe.current=te.getTime(),te.getFullYear()===re.getFullYear()&&te.getMonth()===re.getMonth()||ae(te));const ie=m(t=>{ae(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),le=g(e.state.highlightedEventId);h(()=>{var t;if(e.state.highlightedEventId!==le.current)if(e.state.highlightedEventId){V(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=ne(n.start),r=null===(t=a.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(r){const t=(e-A)*M;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else V(null);le.current=e.state.highlightedEventId},[e.state.highlightedEventId,A,M,a,e]);const se=g(null),de=g(null),ce=v(()=>Eo(te),[te]),ue=v(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(t);return a.setHours(23,59,59,999),e.filter(e=>{const t=B(e.start),n=B(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<=a&&o>=r}return t<a&&n>r}).map(e=>{const t=B(e.start),r=Math.floor((t.getTime()-n.getTime())/864e5),a=Math.max(0,Math.min(6,r));return Object.assign(Object.assign({},e),{day:a})})})(f,te,ce),[f,te,ce]),he=v(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const r=new Date(n);return r.setDate(r.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=B(e.start),a=B(e.end);let o=e.start,i=e.end,l=!1;return t<n&&(o=W(n),l=!0),a>r&&(i=W(r),l=!0),Object.assign(Object.assign({},e),{start:l?o:e.start,end:l?i:e.end,day:0})})})(ue,te),[ue,te]),ge=v(()=>xo.calculateDayEventLayouts(he,{viewType:"day"}),[he]),me=v(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=B(e.start),r=B(t.start);if(n.getTime()!==r.getTime())return n.getTime()-r.getTime();const a=B(e.end);return B(t.end).getTime()-a.getTime()});const n=[],r=[];return t.forEach(e=>{let t=0,a=!1;for(;!a;)n[t]?n[t].some(t=>{const n=B(e.start),r=B(e.end),a=B(t.start);return n<=B(t.end)&&a<=r})?t++:(n[t].push(e),r.push(Object.assign(Object.assign({},e),{row:t})),a=!0):(n[t]=[e],r.push(Object.assign(Object.assign({},e),{row:t})),a=!0)}),r})(ue),[ue]),ve=v(()=>{if(0===me.length)return O;return(Math.max(...me.map(e=>e.row))+1)*O},[me,O]),{handleMoveStart:fe,handleCreateStart:pe,handleResizeStart:ye,handleCreateAllDayEvent:we,dragState:De,isDragging:xe}=Mo(e,{calendarRef:a,allDayRowRef:T?se:void 0,timeGridRef:de,viewType:I.DAY,onEventsUpdate:(t,n,r)=>{const a=t(ue),o=new Set(a.map(e=>e.id)),i=ue.filter(e=>!o.has(e.id)),l=new Set(ue.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=f.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},void 0,r)},onEventCreate:t=>{b?(Q(t),X(!0)):(e.addEvent(t),K(t.id))},onEventEdit:()=>{},currentWeekStart:ce,events:ue,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a)=>{const o=new Date(r),i=new Date(r);o.setHours(Math.floor(t),t%1*60,0,0),i.setHours(Math.floor(n),n%1*60,0,0);const l=[...a,{id:"-1",title:"Temp",day:0,start:W(o),end:W(i),calendarId:"blue",allDay:!1}];return xo.calculateDayEventLayouts(l,{viewType:"day"}).get("-1")||null})(0,t,n,te,he),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o)=>{const i=o.filter(t=>t.id!==e.id),l=new Date(a),s=new Date(l);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(l);d.setHours(Math.floor(r),r%1*60,0,0);const c=[...i,Object.assign(Object.assign({},e),{start:W(s),end:W(d),day:0})];return 0===c.length?null:xo.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,r,te,he),TIME_COLUMN_WIDTH:S&&!b?88:b?48:80,isMobile:b}),{handleDrop:ke,handleDragOver:Te}=ko({app:e,onEventCreated:e=>{K(e.id)}}),Ne=Array.from({length:24},(e,t)=>({hour:t+A,label:be(t+A,0,N)})),Se=v(()=>S?Ee(Ne,S,N):void 0,[S,N,A]),Me=v(()=>S?Ce(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[S]),Ie=v(()=>S?Ce(S):void 0,[S]),Ae=m(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),ae(new Date(n.getFullYear(),n.getMonth(),1))},[e]),He=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(te);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[te]);return p(()=>{var e;if(t.scrollToCurrentTime){const t=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(t){const e=new Date,n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-A)*M-r/2)}}},[]),h(()=>{$(new Date);const e=setInterval(()=>$(new Date),6e4);return()=>clearInterval(e)},[]),et("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[et(za,{app:e,currentDate:te,currentWeekStart:ce,events:f,currentDayEvents:ue,organizedAllDayEvents:me,allDayAreaHeight:ve,timeSlots:Ne,eventLayouts:ge,isToday:He,currentTime:L,selectedEventId:_,setSelectedEventId:V,newlyCreatedEventId:G,setNewlyCreatedEventId:K,detailPanelEventId:U,setDetailPanelEventId:e=>{c?c(e):z(e)},dragState:De,isDragging:xe,handleMoveStart:fe,handleResizeStart:ye,handleCreateStart:pe,handleCreateAllDayEvent:we,handleTouchStart:(e,t)=>{if(!b&&!w)return;const n=e.touches[0],r=n.clientX,o=n.clientY,i=e.currentTarget;ee.current=setTimeout(()=>{var e,n,l;const s=null===(n=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(l=a.current)||void 0===l?void 0:l.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=o-s.top+c;null==pe||pe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,A+u/M)},500)},handleTouchEnd:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleTouchMove:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleDragOver:Te,handleDrop:ke,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:s,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,allDayRowRef:se,timeGridRef:de,switcherMode:o,isMobile:b,isTouch:w,setDraftEvent:Q,setIsDrawerOpen:X,ALL_DAY_HEIGHT:O,HOUR_HEIGHT:M,FIRST_HOUR:A,LAST_HOUR:H,showAllDay:T,showStartOfDayLabel:R,timeFormat:N,secondaryTimeSlots:Se,primaryTzLabel:Me,secondaryTzLabel:Ie}),et(_a,{app:e,currentDate:te,visibleMonth:re,currentDayEvents:ue,selectedEvent:Z,setSelectedEvent:e=>V(e?e.id:null),handleMonthChange:ie,handleDateSelect:Ae,switcherMode:o,timeFormat:N}),et(P,{isOpen:q,onClose:()=>{X(!1),Q(null)},onSave:t=>{f.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),X(!1),Q(null)},draftEvent:J,app:e,timeFormat:N})]})},Ao=({originalComponent:e,app:t,config:n,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:i,meta:l,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDateChange:u,onDetailPanelToggle:h})=>{const g=t.getPlugin("events"),f=t.getPlugin("drag"),p=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),w=m(e=>{g?g.update(e.id,e):t.updateEvent(e.id,e)},[g,t]),D=m(e=>{g?g.delete(e):t.deleteEvent(e)},[g,t]),x=m(e=>{g?g.add(e):t.addEvent(e)},[g,t]),E=m(e=>{u?u(e):t.setCurrentDate(e)},[t,u]),C=m(e=>{t.changeView(e)},[t]),k=v(()=>Object.assign({},n),[n]),T=v(()=>({app:t,currentDate:p,currentView:y,events:b,onEventUpdate:w,onEventDelete:D,onEventCreate:x,onDateChange:E,onViewChange:C,config:k,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:i,meta:l,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDetailPanelToggle:h}),[t,p,y,b,w,D,x,E,C,k,r,a,o,i,l,s,d,c,h]),N=v(()=>{const e={currentDate:p,events:b,setEvents:e=>{b.forEach(e=>D(e.id)),e.forEach(e=>x(e))},updateEvent:w,deleteEvent:D,addEvent:x,goToPrevious:()=>{const e=new Date(p);switch(y){case I.DAY:e.setDate(e.getDate()-1);break;case I.WEEK:e.setDate(e.getDate()-7);break;case I.MONTH:e.setMonth(e.getMonth()-1)}E(e)},goToNext:()=>{const e=new Date(p);switch(y){case I.DAY:e.setDate(e.getDate()+1);break;case I.WEEK:e.setDate(e.getDate()+7);break;case I.MONTH:e.setMonth(e.getMonth()+1)}E(e)},goToToday:()=>{E(new Date)},changeView:C,selectDate:E};return Object.assign(Object.assign({calendar:e},T),{eventsService:g,dragService:f})},[p,b,y,w,D,x,E,C,T,g,f]);return et(e,Object.assign({},N))},Ho={showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},Oo=(e={})=>{const t=Object.assign(Object.assign({},Ho),e),n=e=>a(Ao,{viewType:I.DAY,originalComponent:Io,app:e.app,config:t,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,onEventSelect:e.onEventSelect,detailPanelEventId:e.detailPanelEventId,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="DayViewAdapter",{type:I.DAY,component:n,config:t}},Ro=e=>{const t=e.toLowerCase();return t.startsWith("tu")||t.startsWith("th")||t.startsWith("sa")||t.startsWith("su")?e.slice(0,2):e.slice(0,1)},Po=({app:e,fullWeekDates:t=[],mobilePageStart:n,onDateChange:a})=>et("div",{className:"flex w-full flex-col border-b border-gray-200 bg-white py-3 dark:border-gray-700 dark:bg-gray-900",children:[et("div",{className:"mb-1 grid grid-cols-7",children:t.map((e,t)=>et("div",{className:"flex justify-center",children:et("span",{className:"text-[10px] font-medium "+(e.isToday?"text-primary":"text-gray-500"),children:Ro(e.dayName)})},`label-${t}`))}),et("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!n)return null;const o=t.findIndex(e=>e.fullDate.getTime()===n.getTime());return et(r,{children:[et("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:-1===o?"0":`calc(${(o+.5)/7*100}% - 16px)`,top:0,width:`calc(${1/7*100}% + 32px)`,height:"32px"}}),t.map((t,n)=>{const r=t.isCurrent,i=n>=o&&n<o+2;return et("div",{className:"relative z-10 flex cursor-pointer items-center justify-center",style:{height:"32px"},onClick:()=>{e.setCurrentDate(t.fullDate),null==a||a(t.fullDate)},children:et("div",{className:`relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-all duration-300 ${r?"bg-gray-900 text-white shadow-sm dark:bg-gray-100 dark:text-gray-900":t.isToday?"font-bold text-primary":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!r&&et("div",{className:"absolute bottom-1 h-1 w-1 rounded-full bg-primary"})]})},`date-${n}`)})]})})()})]}),Lo=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,fullWeekDates:o,isSlidingView:i,mobilePageStart:l,currentWeekStart:s,gridWidth:d,allDayAreaHeight:c,organizedAllDaySegments:h,allDayLabelText:g,isMobile:m,isTouch:f,showAllDay:p=!0,calendarRef:y,allDayRowRef:b,topFrozenContentRef:w,ALL_DAY_HEIGHT:D,HOUR_HEIGHT:x,FIRST_HOUR:E,dragState:C,isDragging:k,primaryTzLabel:T,secondaryTzLabel:N,secondaryTimeSlots:S,handleMoveStart:M,handleResizeStart:A,handleEventUpdate:H,handleEventDelete:O,onDateChange:R,newlyCreatedEventId:P,setNewlyCreatedEventId:L,selectedEventId:$,setSelectedEventId:j,detailPanelEventId:Y,setDetailPanelEventId:F,handleCreateAllDayEvent:z,handleDragOver:_,handleDrop:W,customDetailPanelContent:U,customEventDetailDialog:B})=>{const Z={flexShrink:0},[V,G]=u(null),K=v(()=>St(),[]),q=!!S&&S.length>0&&!m;return et("div",{className:"flex w-full flex-col",children:[i&&o&&l&&et(Po,{app:e,fullWeekDates:o,mobilePageStart:l,onDateChange:R}),et("div",{className:`flex flex-none ${p?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[p&&et("div",{className:"z-20 flex w-12 shrink-0 flex-col bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"flex flex-1 items-center border-b border-gray-200 transition-all duration-300 ease-in-out dark:border-gray-700 "+(i?"hidden":""),children:q&&et("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[et("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:N}),et("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:T})]})}),et("div",{className:"flex items-center justify-end p-1 text-[10px] font-medium text-gray-500 transition-[min-height] duration-300 ease-in-out select-none md:text-xs dark:text-gray-400",style:{minHeight:`${c}px`},children:g})]}),et("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:p?`${c+(i?0:36)}px`:"auto"},children:et("div",{ref:w,className:"flex flex-col",style:{width:d,minWidth:"100%",transform:i?"translateX(calc(-100% / 3))":void 0},children:[!i&&et("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:K?"-50px":"0px",paddingRight:K?"50px":"0px"},children:t.map((e,t)=>et("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 "+(m?"flex-col gap-0":""),style:Z,children:et(r,m?{children:[et("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:n[t]}),et("div",{className:`${wn} h-7 w-7 text-base font-medium ${a[t].isToday?Pn:""}`,children:a[t].date})]}:{children:[et("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),et("div",{className:`${wn} ${a[t].isToday?Pn:""}`,children:a[t].date})]})},t))}),p&&et("div",{className:`${Sn} border-none transition-[min-height] duration-300 ease-in-out`,ref:b,style:{minHeight:`${c}px`},children:et("div",{className:"df-all-day-content flex flex-1 relative transition-[min-height] duration-300 ease-in-out",style:{minHeight:`${c}px`},children:[t.map((e,n)=>{const r=new Date(s);return r.setDate(s.getDate()+n),et("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!m&&K?"":"border-r-0"),style:Object.assign({minHeight:`${c}px`},Z),onMouseDown:e=>null==z?void 0:z(e,n),onDblClick:e=>null==z?void 0:z(e,n),onDragOver:_,onDrop:e=>{W(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),m)return;const n=new Date(s);n.setDate(s.getDate()+t),n.setHours(0,0,0,0),G({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),et("div",{className:"pointer-events-none absolute inset-0",children:h.map(n=>et(ja,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:D,calendarRef:y,viewType:I.WEEK,columnsPerRow:t.length,isBeingDragged:k&&(null==C?void 0:C.eventId)===n.event.id&&"move"===(null==C?void 0:C.mode),hourHeight:x,firstHour:E,onMoveStart:M,onResizeStart:A,onEventUpdate:H,onEventDelete:O,newlyCreatedEventId:P,onDetailPanelOpen:()=>L(null),selectedEventId:$,detailPanelEventId:Y,onEventSelect:e=>{j(e)},onEventLongPress:e=>{(m||f)&&j(e)},onDetailPanelToggle:e=>F(e),customDetailPanelContent:U,customEventDetailDialog:B,app:e,isMobile:m,isSlidingView:i,enableTouch:f},n.event.id))})]})})]})}),V&&et(Da,{x:V.x,y:V.y,date:V.date,viewType:I.WEEK,onClose:()=>G(null),app:e,onCreateEvent:()=>{const e=Math.floor((V.date.getTime()-s.getTime())/864e5);null==z||z({clientX:V.x,clientY:V.y},e)}})]})]})},$o=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:a,currentWeekEvents:o,eventLayouts:i,gridWidth:l,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:h,leftFrozenContentRef:m,swipeContentRef:f,calendarRef:p,handleScroll:y,handleCreateStart:b,handleTouchStart:w,handleTouchEnd:D,handleTouchMove:x,handleDragOver:E,handleDrop:C,dragState:k,isDragging:T,handleMoveStart:N,handleResizeStart:S,handleEventUpdate:M,handleEventDelete:A,onDateChange:H,newlyCreatedEventId:O,setNewlyCreatedEventId:R,selectedEventId:P,setSelectedEventId:L,detailPanelEventId:$,setDetailPanelEventId:j,customDetailPanelContent:Y,customEventDetailDialog:F,isSlidingView:z,isCurrentWeek:_,currentTime:W,HOUR_HEIGHT:U,FIRST_HOUR:B,LAST_HOUR:Z,showStartOfDayLabel:V,timeFormat:G="24h",secondaryTimeSlots:K})=>{var q,X;const J=!!K&&K.length>0&&!s,Q={flexShrink:0},ee=g(e.state.highlightedEventId),[te,ne]=u(null),re=v(()=>St(),[]);return et("div",{className:"relative flex flex-1 overflow-hidden",children:[et("div",{ref:c,className:"calendar-content relative flex-1 overflow-auto "+("300%"===l?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:y,children:[et("div",{ref:m,className:"sticky left-0 z-10 w-12 shrink-0 bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"relative h-3",children:J?et(r,{children:et("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:V&&null!==(q=null==K?void 0:K[0])&&void 0!==q?q:""}),et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:V?be(B,0,G):""})]})}):et("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:V?be(B,0,G):""})}),t.map((e,t)=>{var n;return et("div",{className:En,children:et("div",J?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:V&&0===t?"":null!==(n=null==K?void 0:K[t])&&void 0!==n?n:""}),et("span",{className:"text-[10px] md:text-[12px]",children:V&&0===t?"":e.label})]}:{className:`${Cn} text-[10px] md:text-[12px]`,children:V&&0===t?"":e.label})},t)}),et("div",{className:"relative",children:et("div",J?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:null!==(X=null==K?void 0:K[0])&&void 0!==X?X:""}),et("span",{className:"text-[10px] md:text-[12px]",children:be(0,0,G)})]}:{className:`${Cn} text-[10px] md:text-[12px]`,children:be(0,0,G)})}),_&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>Z)return null;return et("div",{className:"pointer-events-none absolute left-0 z-20 flex w-full items-center justify-end",style:{top:`${(t-B)*U}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:et("div",{className:Nn,children:be(t,0,G,!1)})})})()]}),et("div",{ref:f,className:"flex",style:{width:l,minWidth:"100%",transform:z?"translateX(calc(-100% / 3))":void 0},children:et("div",{className:"grow",children:[et("div",{className:`${Fn} flex border-t-0`,children:n.map((e,t)=>et("div",{className:`relative flex-1 ${t!==n.length-1||!s&&re?"border-r":""} border-gray-200 dark:border-gray-700`,style:Q},`top-${t}`))}),et("div",{ref:h,className:"relative",children:[_&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>Z)return null;const r=new Date(e);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const i=r.getTime()-o.getTime(),l=Math.round(i/864e5);return et("div",{className:Tn,style:{top:`${(t-B)*U}px`,width:"100%",height:0,zIndex:20},children:[et("div",{className:"flex w-0 items-center"}),et("div",{className:"flex flex-1",children:n.map((e,t)=>et("div",{className:"flex flex-1 items-center",children:et("div",{className:"relative h-0.5 w-full "+(t===l?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===l&&0!==l&&et("div",{className:"absolute h-2 w-2 rounded-full bg-primary",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>et("div",{className:kn,children:n.map((r,o)=>{const i=new Date(a);return i.setDate(a.getDate()+o),et("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(o!==n.length-1||!s&&re?"":"border-r-0"),style:Q,onClick:()=>{const e=new Date(a);e.setDate(a.getDate()+o),null==H||H(e)},onDblClick:t=>{null==b||b(t,o,e.hour)},onTouchStart:t=>w(t,o,e.hour),onTouchEnd:D,onTouchMove:x,onDragOver:E,onDrop:t=>{C(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),s)return;const r=new Date(a);if(r.setDate(a.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/U+B,a=Math.floor(n),o=Math.floor(60*(n-a)),i=15*Math.round(o/15),l=60===i?a+1:a,s=60===i?0:i;r.setHours(l,s,0,0)}else r.setHours(n,0,0,0);ne({x:e.clientX,y:e.clientY,date:r})})(t,o,e.hour)},`${t}-${o}`)})},t)),et("div",{className:`${Fn} flex`,children:n.map((e,t)=>et("div",{className:`relative flex-1 ${t!==n.length-1||!s&&re?"border-r":""} border-gray-200 dark:border-gray-700`,style:Q},`24-${t}`))}),n.map((t,r)=>{const l=n.length,c=Ie(r,o),u=[];return c.forEach(e=>{const t=ka(e,a);if(t.length>0){const n=t.find(e=>e.dayIndex===r);n&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:r})})}else u.push({event:e})}),o.forEach(e=>{if(e.allDay||e.day===r)return;const t=ka(e,a).find(e=>e.dayIndex===r);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:r})})}),et("div",{className:"pointer-events-none absolute top-0",style:{left:`calc(${100/l*r}%)`,width:100/l+"%",height:"100%"},children:u.map(({event:t,segmentInfo:n})=>{const a=i.get(r),o=null==a?void 0:a.get(t.id);return et(ja,{event:t,layout:o,viewType:I.WEEK,calendarRef:p,columnsPerRow:l,isBeingDragged:T&&(null==k?void 0:k.eventId)===t.id&&"move"===(null==k?void 0:k.mode),hourHeight:U,firstHour:B,onMoveStart:N,onResizeStart:S,onEventUpdate:M,onEventDelete:A,newlyCreatedEventId:O,onDetailPanelOpen:()=>R(null),selectedEventId:P,detailPanelEventId:$,onEventSelect:t=>{L(t),e.state.highlightedEventId&&(e.highlightEvent(null),ee.current=null)},onEventLongPress:e=>{(s||d)&&L(e)},onDetailPanelToggle:e=>j(e),customDetailPanelContent:Y,customEventDetailDialog:F,multiDaySegmentInfo:n,app:e,isMobile:s,isSlidingView:z,enableTouch:d},n?`${t.id}-seg-${r}`:t.id)})},`events-day-${r}`)})]})]})})]}),te&&et(Da,{x:te.x,y:te.y,date:te.date,viewType:I.WEEK,onClose:()=>ne(null),app:e,onCreateEvent:()=>{if(b){const e=new Date(a);e.setHours(0,0,0,0);const t=new Date(te.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),r=Math.round(n/864e5),o=te.date.getHours()+te.date.getMinutes()/60,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:te.x,clientY:te.y};b(i,r,o)}}})]})},jo=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,onDateChange:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:m,getWeekDaysLabels:f,locale:y}=vn(),b=e.getCurrentDate(),w=v(()=>b,[b.getTime()]),D=e.getEvents(),{screenSize:x}=gn(),E="desktop"!==x,C=g(null),[k,T]=u(!1),{hourHeight:N=Co.HOUR_HEIGHT,firstHour:S=Co.FIRST_HOUR,lastHour:M=Co.LAST_HOUR,allDayHeight:A=Co.ALL_DAY_HEIGHT,showAllDay:H=!0,timeFormat:O="24h",secondaryTimeZone:R}=t,P=R&&"mobile"!==x?88:"mobile"===x?48:80,L=N,$=S,j=M,Y=A,F=!H;h(()=>{T("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const z=e.getCustomMobileEventRenderer()||Qr,_="desktop"!==x,U=_?2:7,Z=_,V=null!==(c=t.startOfWeek)&&void 0!==c?c:1,G=Z?"300%":"100%",K=v(()=>Eo(w,V),[w,V]),[q,X]=u(()=>{const e=new Date(w);return e.setHours(0,0,0,0),e});h(()=>{Z&&X(e=>{const t=new Date(w);t.setHours(0,0,0,0);const n=new Date(e),r=new Date(e);return r.setDate(r.getDate()+U-1),t>=n&&t<=r?e:t})},[w,Z,U]);const J=Z?q:K,Q=Z?3*U:7,ee=v(()=>{if(!Z)return J;const e=new Date(J);return e.setDate(e.getDate()-U),e},[J,Z,U]),[te,ae]=u(null),[oe,ie]=u(null),[le,se]=u(null),de=void 0===o?oe:o,ce=void 0===s?le:s,ue=e=>{i?i(e):ie(e)},he=e=>{d?d(e):se(e)},[ge,me]=u(null),[ve,fe]=u(!1),[pe,ye]=u(null),we=g(null),[De,xe]=u(0),[ke,Te]=u(!1),Ne=g(null),Se=g(null),Me=g(null),Ie=g(null),Ae=g(null),Oe=g({x:0,y:0}),Re=g(!1),Pe=g(0);h(()=>{if(!Z)return;const t=Se.current;if(!t)return;const n=e=>{Oe.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Re.current=!1,Pe.current=0,Te(!1)},r=e=>{if(ke)return;const n=e.touches[0].clientX-Oe.current.x,r=e.touches[0].clientY-Oe.current.y;if(!Re.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(Re.current=!0),Re.current){e.cancelable&&e.preventDefault();const r=t.clientWidth/2,a=Math.max(-r,Math.min(r,n)),o=`translateX(calc(-100% / 3 + ${a}px))`;Me.current&&(Me.current.style.transition="none",Me.current.style.transform=o),Ae.current&&(Ae.current.style.transition="none",Ae.current.style.transform=o),Pe.current=a}},a=()=>{var n;if(!Re.current)return void(Pe.current=0);const r=Pe.current,a=((null===(n=Ae.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/Q;r>100?(Te(!0),xe(a),setTimeout(()=>{const t=new Date(q);t.setDate(t.getDate()-1),X(t),e.setCurrentDate(t),xe(0),Pe.current=0,Te(!1)},300)):r<-100?(Te(!0),xe(-a),setTimeout(()=>{const t=new Date(q);t.setDate(t.getDate()+1),X(t),e.setCurrentDate(t),xe(0),Pe.current=0,Te(!1)},300)):(Te(!0),xe(0),Pe.current=0,setTimeout(()=>{Te(!1)},300))};return t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),t.addEventListener("touchend",a,{passive:!0}),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchmove",r),t.removeEventListener("touchend",a)}},[Z,e,J,ke,U,Q]);const Le=v(()=>((e,t,n=7)=>{const r=new Date(t);return r.setDate(t.getDate()+(n-1)),r.setHours(23,59,59,999),e.filter(e=>{const n=B(e.start);n.setHours(0,0,0,0);const a=B(e.end);return a.setHours(23,59,59,999),a>=t&&n<=r}).map(e=>{const r=B(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),o=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:o})})})(D,ee,Q),[D,ee,Q]),$e=g(e.state.highlightedEventId);h(()=>{if(e.state.highlightedEventId!==$e.current)if(e.state.highlightedEventId){ue(e.state.highlightedEventId);const t=Le.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=ne(t.start),n=Se.current;if(n){const t=(e-$)*L;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ue(null);$e.current=e.state.highlightedEventId},[e.state.highlightedEventId,Le,$,L]);const je=v(()=>((e,t,n=7)=>{const r=Ca(e,t,n).filter(e=>e.event.allDay);r.sort((e,t)=>{const n=B(e.event.start).getTime(),r=B(t.event.start).getTime();if(n!==r)return n-r;const a=e.totalDays;return t.totalDays-a});const a=[];return r.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of a)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(Le,ee,Q),[Le,ee,Q]),Ye=v(()=>{const e=Z?je.filter(e=>e.endDayIndex>=U&&e.startDayIndex<=2*U-1):je;if(0===e.length)return Y;const t=Math.max(...e.map(e=>e.row));return Y+t*Y},[je,Y,Z,U]),Fe=v(()=>((e,t,n=7)=>{const r=new Map;for(let a=0;a<n;a++){const o=[];e.forEach(e=>{if(e.allDay)return;const r=ka(e,t,n);if(r.length>0){const n=r.find(e=>e.dayIndex===a);if(n){const r=n.endHour>=24?23.99:n.endHour,i=Object.assign(Object.assign({},e),{start:W(re(He(t,a),n.startHour)),end:W(re(He(t,a),r)),day:a});o.push(i)}}else e.day===a&&o.push(e)});const i=xo.calculateDayEventLayouts(o,{viewType:"week"});r.set(a,i)}return r})(Le,ee,Q),[Le,ee,Q]),{handleMoveStart:ze,handleCreateStart:_e,handleResizeStart:We,handleCreateAllDayEvent:Ue,dragState:Be,isDragging:Ve}=Mo(e,{calendarRef:a,allDayRowRef:H?Ne:void 0,timeGridRef:C,viewType:I.WEEK,onEventsUpdate:(t,n,r)=>{const a=t(Le),o=new Set(a.map(e=>e.id)),i=Le.filter(e=>!o.has(e.id)),l=new Set(Le.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=Le.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{E?(ye(t),fe(!0)):(e.addEvent(t),me(t.id))},onEventEdit:()=>{},currentWeekStart:ee,events:Le,calculateNewEventLayout:(e,t,n)=>((e,t,n,r)=>{const a=new Date,o=new Date;a.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const i={id:"-1",title:"Temp",day:e,start:W(a),end:W(o),calendarId:"blue",allDay:!1},l=[...r.filter(t=>t.day===e&&!t.allDay),i];return xo.calculateDayEventLayouts(l,{viewType:"week"}).get("-1")||null})(e,t,n,Le),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=B(a.start),i=re(o,n),l=re(o,r),s=W(i),d=W(l);return Object.assign(Object.assign({},a),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:xo.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,Le),TIME_COLUMN_WIDTH:P,isMobile:E,gridWidth:G,displayDays:Q}),{handleDrop:Ge,handleDragOver:Ke}=ko({app:e,onEventCreated:e=>{me(e.id)}}),qe=v(()=>Z?Array.from({length:Q},(e,t)=>{const n=new Date(ee);return n.setDate(n.getDate()+t),n.toLocaleDateString(y,{weekday:"short"})}):f(y,"short",V),[y,f,Z,ee,Q,V]),Xe=v(()=>{if(!E)return[];const e=y.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?f(y,"narrow"):qe.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)})},[E,y,f,qe]),Je=v(()=>m("allDay"),[m]),Qe=Array.from({length:24},(e,t)=>({hour:t+$,label:be(t+$,0,O)})),tt=v(()=>R?Ee(Qe,R,O):void 0,[R,O,$]),nt=v(()=>R?Ce(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[R]),rt=v(()=>R?Ce(R):void 0,[R]),at=v(()=>{const e=new Date;return e.setHours(0,0,0,0),qe.map((t,n)=>{const r=new Date(ee);r.setDate(ee.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString(y,{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[ee,qe,y]),ot=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=K;return Array.from({length:7},(n,r)=>{const a=new Date(t);a.setDate(t.getDate()+r);const o=new Date(a);return o.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(y,{month:"short"}),fullDate:new Date(a),isToday:o.getTime()===e.getTime(),isCurrent:o.getTime()===new Date(w).setHours(0,0,0,0),dayName:a.toLocaleDateString(y,{weekday:"short"})}})},[K,y,w]);h(()=>{if(!Z)return Me.current&&(Me.current.style.transform="",Me.current.style.transition=""),void(Ae.current&&(Ae.current.style.transform="",Ae.current.style.transition=""));const e=ke?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${De}px))`;Me.current&&(Me.current.style.transition=e,Me.current.style.transform=t),Ae.current&&(Ae.current.style.transition=e,Ae.current.style.transform=t)},[De,ke,Z]);const it=t=>{e.updateEvent(t.id,t)},lt=t=>{e.deleteEvent(t)},st=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(ee);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+Q),e>=t&&e<n},[ee,Q]);return p(()=>{if(t.scrollToCurrentTime&&Se.current){const e=Se.current,t=new Date,n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-$)*L-r/2)}},[]),h(()=>{ae(new Date);const e=setInterval(()=>ae(new Date),6e4);return()=>clearInterval(e)},[]),et("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:[et(Fa,{calendar:e,viewType:I.WEEK,currentDate:w,onPrevious:()=>{if(Z){const t=new Date(w);t.setDate(t.getDate()-1),X(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(Z){const t=new Date(w);t.setDate(t.getDate()+1),X(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),et(Lo,{app:e,weekDaysLabels:qe,mobileWeekDaysLabels:Xe,weekDates:at,fullWeekDates:ot,isSlidingView:Z,mobilePageStart:q,currentWeekStart:ee,gridWidth:G,allDayAreaHeight:Ye,organizedAllDaySegments:je,allDayLabelText:Je,isMobile:E,isTouch:k,showAllDay:H,calendarRef:a,allDayRowRef:Ne,topFrozenContentRef:Me,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:L,FIRST_HOUR:$,dragState:Be,isDragging:Ve,secondaryTimeSlots:tt,primaryTzLabel:nt,secondaryTzLabel:rt,handleMoveStart:ze,handleResizeStart:We,handleEventUpdate:it,handleEventDelete:lt,onDateChange:l,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,handleCreateAllDayEvent:Ue,handleDragOver:Ke,handleDrop:Ge,customDetailPanelContent:n,customEventDetailDialog:r}),et($o,{app:e,timeSlots:Qe,weekDaysLabels:qe,currentWeekStart:ee,currentWeekEvents:Le,eventLayouts:Fe,gridWidth:G,isMobile:E,isSlidingView:Z,isTouch:k,scrollerRef:Se,timeGridRef:C,leftFrozenContentRef:Ie,swipeContentRef:Ae,calendarRef:a,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Me.current){const e=Z?"calc(-100% / 3)":"0px",n=Z?`${De}px`:`-${t}px`;Me.current.style.transform=`translateX(calc(${e} + ${n}))`,Me.current.style.transition=Z&&ke?"transform 0.3s ease-out":"none"}},handleCreateStart:_e,handleTouchStart:(e,t,n)=>{if(!E&&!k)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;we.current=setTimeout(()=>{null==_e||_e({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{we.current&&(clearTimeout(we.current),we.current=null)},handleTouchMove:()=>{we.current&&(clearTimeout(we.current),we.current=null)},handleDragOver:Ke,handleDrop:Ge,dragState:Be,isDragging:Ve,handleMoveStart:ze,handleResizeStart:We,handleEventUpdate:it,handleEventDelete:lt,onDateChange:l,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,customDetailPanelContent:n,customEventDetailDialog:r,isCurrentWeek:st,currentTime:te,HOUR_HEIGHT:L,FIRST_HOUR:$,LAST_HOUR:j,showStartOfDayLabel:F,timeFormat:O,secondaryTimeSlots:tt}),et(z,{isOpen:ve,onClose:()=>{fe(!1),ye(null)},onSave:t=>{D.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),fe(!1),ye(null)},draftEvent:pe,app:e,timeFormat:O})]})},Yo={showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},Fo=(e={})=>{const t=Object.assign(Object.assign({},Yo),e),n=e=>a(Ao,{viewType:I.WEEK,originalComponent:jo,app:e.app,config:t,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="WeekViewAdapter",{type:I.WEEK,component:n,config:t}},zo=c(({currentMonth:t,currentYear:n,newlyCreatedEventId:r,screenSize:a,isScrolling:o,isDragging:i,showWeekNumbers:l,showMonthIndicator:s=!0,item:d,weekHeight:c,events:m,dragState:f,calendarRef:p,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onCreateStart:D,onResizeStart:x,onDetailPanelOpen:E,onMoreEventsClick:C,onChangeView:k,onSelectDate:T,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:A,onDetailPanelToggle:H,customDetailPanelContent:O,customEventDetailDialog:R,onCalendarDrop:P,onCalendarDragOver:L,app:$,enableTouch:j})=>{const{t:Y,locale:F}=vn(),[z,_]=u(!1),W=g(null),U=g(null),Z=g(null),[V,G]=u(null),K=v(()=>{const e=c-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)))}},[c]);h(()=>o?(_(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):z?(W.current=setTimeout(()=>{_(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[o,z]);const{weekData:q}=d,X=q.days.find(e=>1===e.day),J=`${c}px`,Q=v(()=>St(),[]),ee=v(()=>Ca(m,q.startDate),[m,q.startDate]),te=v(()=>((t,n)=>{const r=[],a=new Date(n);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),t.forEach(t=>{if(!t.start||!t.end)return void qe.warn("Event missing start or end date:",t);const o=B(t.start),i=B(t.end),l=new Date(o);l.setHours(0,0,0,0);const s=new Date(i);s.setHours(0,0,0,0);let d=new Date(s);if(!t.allDay&&0===i.getHours()&&0===i.getMinutes()&&0===i.getSeconds()){const e=i.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}const c=l.toDateString()!==d.toDateString();if(!c||t.allDay)if(c&&t.allDay){let l=new Date(o);l<n&&(l=new Date(n),l.setHours(0,0,0,0));const s=i>a?a:i;for(let a=o.getTime();a<=s.getTime();a+=864e5){const o=new Date(a);if(o<n)continue;const i=e.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});r.push(Object.assign(Object.assign({},t),{start:i,end:i,day:l.getDay()}))}}else r.push(Object.assign(Object.assign({},t),{start:t.start,end:t.end,day:o.getDay()}))}),r})(m,q.startDate),[m,q.startDate]),re=v(()=>{const e=new Map;return q.days.forEach(t=>{const n=t.date.toDateString();e.set(n,te.filter(e=>{if(!e.start||!e.end)return B(e.start).toDateString()===n;const t=B(e.start),r=B(e.end);if(!e.allDay){if(!(0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds())){const e=r.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n}}return t.toDateString()===n||r.toDateString()===n}))}),e},[te,q.days]),ae=v(()=>(e=>{const t=[...e].toSorted((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,r=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==r?r-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{var t;let r=0,a=!1;for(;!a;){let o=!1;for(const a of n){const n=Math.abs((null!==(t=a.yPosition)&&void 0!==t?t:0)-r)<16,i=!(e.endDayIndex<a.startDayIndex||e.startDayIndex>a.endDayIndex);if(n&&i){o=!0;break}}o?r+=16:a=!0}n.push(Object.assign(Object.assign({},e),{yPosition:r}))});const r=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);r[n]||(r[n]=[]),r[n].push(e)}),r.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),r})(ee),[ee]),oe=v(()=>ae.flat(),[ae]),le=v(()=>{const e=Array.from({length:7}).fill(0);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ae]),se=v(()=>{const e=Array.from({length:7},()=>new Set);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ae]),de=v(()=>{var e;for(let t=0;t<q.days.length;t++){const n=q.days[t],r=(null!==(e=re.get(n.date.toDateString()))&&void 0!==e?e:[]).filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),a=se[t],o=le[t]-1;let i=0;for(let e=0;e<=o;e++)a.has(e)||i++;if(o+1+Math.max(0,r.length-i)>K.maxSlots)return K.maxSlotsWithMore}return K.maxSlots},[q.days,re,oe,le,se,K.maxSlots,K.maxSlotsWithMore]),ce=v(()=>Math.max(0,17*ae.length),[ae]),ue=(e,o)=>{var s,d;const c=e.date.toLocaleDateString(F,{month:F.startsWith("zh")||F.startsWith("ja")?"short":"long"})===t&&e.year===n,u=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:ne(e.start)-ne(t.start)))(null!==(s=re.get(e.date.toDateString()))&&void 0!==s?s:[]),h=u.filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),g=se[o],m=(null!==(d=le[o])&&void 0!==d?d:0)-1,v=[];for(let e=0;e<=m;e++)g.has(e)||v.push(e);const z=h.length,_=Math.max(0,z-v.length),W=Math.max(m+1,0)+_,B=W>K.maxSlots,V=B?K.maxSlotsWithMore:K.maxSlots,q=v.filter(e=>e<V).length,X=Math.max(0,V-Math.max(m+1,0)),ee=Math.min(z,q+X),te=h.slice(0,ee),ae=z-ee,de=[];let ce=0;const ue=Math.min(V,W);for(let t=0;t<ue;t++)if(g.has(t))de.push(et("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(ce<te.length){const e=te[ce];de.push(et(ja,{event:e,isAllDay:!!e.allDay,viewType:I.MONTH,isBeingDragged:i&&f.eventId===e.id&&"move"===f.mode,calendarRef:p,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,onDetailPanelOpen:E,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:r,selectedEventId:N,detailPanelEventId:A,onDetailPanelToggle:H,customDetailPanelContent:O,customEventDetailDialog:R,app:$,isMobile:"desktop"!==a,enableTouch:j},`${e.id}-${e.day}-${ne(e.start)}-${ce}`)),ce++}return et("div",{className:Qn("df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700",c?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===o?Q?"last:border-r":"border-r-0":""),style:{height:J},"data-date":(he=e.date,`${he.getFullYear()}-${String(he.getMonth()+1).padStart(2,"0")}-${String(he.getDate()).padStart(2,"0")}`),onClick:()=>null==T?void 0:T(e.date),onDblClick:t=>null==D?void 0:D(t,e.date),onTouchStart:t=>{if("mobile"!==a&&!j)return;const n=t.touches[0],r=n.clientX,o=n.clientY;Z.current={x:r,y:o},U.current=setTimeout(()=>{null==D||D(t,e.date),U.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(U.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(U.current),U.current=null)}},onTouchEnd:()=>{U.current&&(clearTimeout(U.current),U.current=null),Z.current=null},onDragOver:L,onDrop:t=>null==P?void 0:P(t,e.date),onContextMenu:t=>((e,t)=>{e.preventDefault(),"mobile"!==a&&G({x:e.clientX,y:e.clientY,date:t})})(t,e.date),children:[et("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[l&&0===o&&"mobile"!==a&&et("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:ie(e.date)}),et("span",{className:` 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 ${e.isToday?"bg-primary text-primary-foreground":c?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===e.day&&"desktop"===a?e.date.toLocaleDateString(F,{month:"short",day:"numeric"}):e.day})]}),et("div",{className:"flex-1 overflow-hidden px-1",children:[de,B&&et("div",{className:Qn("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 relative z-20 bg-white dark:bg-gray-900","desktop"===a?"text-left font-normal":"text-center font-medium"),onClick:t=>{t.stopPropagation(),C?C(e.date):(null==T||T(e.date),null==k||k(I.DAY))},children:["+",ae,"desktop"===a?` ${Y("more")}`:""]})]})]},`day-${e.date.getTime()}`);var he},he=v(()=>X?X.date.toLocaleDateString(F,{month:"long",year:"numeric"}):"",[X,F]);return et("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:J},children:[s&&X&&et("div",{className:` df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300 ${z?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"} `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},onContextMenu:e=>e.preventDefault(),children:et("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:he})}),et("div",{className:"flex h-full flex-col",children:et("div",{className:"calendar-week relative h-full",children:[et("div",{className:"grid h-full grid-cols-7",children:q.days.map((e,t)=>ue(e,t))}),ae.length>0&&et("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ce}px`,zIndex:10},children:ae.slice(0,de).map((e,t)=>et("div",{className:"absolute inset-0",children:e.map(e=>et(ja,{event:e.event,isAllDay:!0,segment:e,segmentIndex:t,viewType:I.MONTH,isMultiDay:!0,calendarRef:p,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,isBeingDragged:i&&f.eventId===e.event.id&&"move"===f.mode,isBeingResized:i&&f.eventId===e.event.id&&"resize"===f.mode,newlyCreatedEventId:r,onDetailPanelOpen:E,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:A,onDetailPanelToggle:H,customDetailPanelContent:O,customEventDetailDialog:R,app:$,isMobile:"desktop"!==a,enableTouch:j},e.id))},`layer-${t}`))})]})}),V&&et(Da,{x:V.x,y:V.y,date:V.date,viewType:I.MONTH,onClose:()=>G(null),app:$,onCreateEvent:()=>{if(D){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:V.x,clientY:V.y};D(e,V.date)}}})]})});zo.displayName="WeekComponent";const _o=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,detailPanelEventId:l,onDetailPanelToggle:s})=>{var d;const{getWeekDaysLabels:c,getMonthLabels:f,locale:p}=vn(),y=e.getCurrentDate(),b=e.getEvents(),w=null!==(d=t.startOfWeek)&&void 0!==d?d:1,D=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),x=g(null),E=v(()=>{const e=x.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:(x.current=b,b)},[b]),C=v(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-w+7)%7;return t.setDate(t.getDate()-n),t.setHours(0,0,0,0),t},n=(t,n)=>{const r=e.get(t);r?r.push(n):e.set(t,[n])};return E.forEach(e=>{if(!e.start)return;const r=B(e.start),a=e.end?B(e.end):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=t(o),d=t(l);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},[E,w]),{screenSize:k}=gn(),[T,N]=u(!1);h(()=>{N("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const S=e.getCustomMobileEventRenderer()||Qr,[M,A]=u(119),[R,P]=u(!1),L=g(M),$=g([]),[j,Y]=u(null),[F,z]=u(!1),[_,W]=u(null),[U,Z]=u(null),[V,G]=u(null),K=void 0===o?U:o,q=void 0===l?V:l,X=m(e=>{i?i(e):Z(e)},[i]),J=m(e=>{s?s(e):G(e)},[s]),Q=g(e.state.highlightedEventId);h(()=>{e.state.highlightedEventId?X(e.state.highlightedEventId):Q.current&&X(null),Q.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const ee=v(()=>{const e=(y.getDay()-w+7)%7,t=new Date(y);return t.setDate(y.getDate()-e),t.setHours(0,0,0,0),t},[y,w]),{handleMoveStart:te,handleCreateStart:ne,handleResizeStart:re,dragState:ae,isDragging:oe}=Mo(e,{calendarRef:a,viewType:I.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(E),o=new Set(a.map(e=>e.id)),i=E.filter(e=>!o.has(e.id)),l=new Set(E.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=E.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===k?e.addEvent(t):(W(t),z(!0))},onEventEdit:e=>{Y(e.id)},currentWeekStart:ee,events:E}),{handleDrop:ie,handleDragOver:le}=ko({app:e,onEventCreated:e=>{Y(e.id)}}),se=v(()=>c(p,"short",w),[p,c,w]),{currentMonth:de,currentYear:ce,isScrolling:ue,virtualData:he,weeksData:ge,scrollElementRef:me,isNavigating:ve,handleScroll:fe,handlePreviousMonth:pe,handleNextMonth:ye,handleToday:be,setScrollTop:we}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:a="en-US",startOfWeek:o=1,isEnabled:i=!0})=>{const l=g(null),s=m((e,t)=>{const n=new Date(t,e,1),r=a.startsWith("zh")||a.startsWith("ja");return n.toLocaleDateString(a,{month:r?"short":"long"})},[a]),d=v(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),Me(t,r,o)},[e,r,o]),c=v(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=d.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[d,e,t]),[f,p]=u(c),[y,b]=u(600),[w,D]=u(s(e.getMonth(),e.getFullYear())),[x,E]=u(e.getFullYear()),[C,k]=u(!1),[T,N]=u(d),[S,M]=u(!1),I=g(!1),[A,R]=u(!1),P=g(e),L=g(null),$=g(null),j=g(new O),Y=g(0),F=g(0),z=g(!1),_=m(e=>{e&&(L.current=e)},[]),W=m(e=>{let t=j.current.get(e);return t||(t=Ne(e),j.current.set(e,t)),t},[]),U=m((e,n=26)=>{z.current||(z.current=!0,setTimeout(()=>{try{if("future"===e){const e=T.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(W(n))}N(e=>[...e,...t])}else{const e=T[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(W(n))}const a=r.length*t;N(e=>[...r,...e]),requestAnimationFrame(()=>{p(e=>e+a),L.current&&(L.current.scrollTop+=a)})}}finally{setTimeout(()=>{z.current=!1},200)}},0))},[T,W,t]),B=v(()=>{const e=T.length*t,n=Math.floor(f/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(T.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[f,y,t,T]),Z=m(e=>{if(S||C||0===e.length||!A)return;const t=f+y/2,r=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!r)return;const a={};r.weekData.days.forEach(e=>{const t=`${s(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",i=0,d=0;Object.entries(a).forEach(([e,t])=>{if(t>d){d=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(l.current?o===l.current.month&&i===l.current.year&&(l.current=null,o===w&&i===x||(D(o),E(i),null==n||n(o,i))):o===w&&i===x||(D(o),E(i),null==n||n(o,i)))},[y,w,x,S,C,n,f,A]),V=m(e=>{const n=performance.now();if(n-Y.current<H.SCROLL_THROTTLE)return;Y.current=n;const r=e.currentTarget,a=r.scrollTop;F.current=a,p(a),S||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!z.current&&U("future",26),a<10*t&&!z.current&&U("past",26)}),k(!0),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{k(!1)},H.SCROLL_DEBOUNCE)},[t,U,S]),G=m((e,n=!0)=>{if(!L.current)return;M(!0),I.current=!0;const r=()=>{setTimeout(()=>{M(!1),I.current=!1},n?500:200)},a=T.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return L.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const i=(e.getDay()-o+7)%7,l=new Date(e);l.setDate(e.getDate()-i),l.setHours(0,0,0,0);const s=T[0],d=T.at(-1);let c=0,u=!1,h=!1;l<s.startDate?(c=Math.ceil((s.startDate.getTime()-l.getTime())/6048e5),u=!0):l>d.startDate&&(c=Math.ceil((l.getTime()-d.startDate.getTime())/6048e5),h=!0);const g=Math.min(c+10,52);if(u){const a=[];for(let e=g;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(W(t))}const o=a.length*t;N(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==i){const e=i*t;L.current.scrollTop+=o,p(e=>e+o),setTimeout(()=>{L.current&&L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}r()})}else if(h){const a=[];for(let e=1;e<=g;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(W(t))}N(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==o){const e=o*t;L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,W]),K=m(()=>{const e=T[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);G(t)},[B.displayStartIndex,T,G]),q=m(()=>{const e=T[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);G(t)},[B.displayStartIndex,T,G]),X=m(()=>{const e=new Date,r=s(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);l.current={month:r,year:a},D(r),E(a),null==n||n(r,a);const i=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)M(!0),I.current=!0,requestAnimationFrame(()=>{G(o,!0),setTimeout(()=>{I.current=!1,M(!1)},200)});else{const e=i*t,n=L.current;n&&(M(!0),I.current=!0,requestAnimationFrame(()=>{p(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{I.current=!1,M(!1)},200))})}))}},[T,t,n,G]);return h(()=>{Z(B.visibleItems)},[B.visibleItems,Z]),h(()=>{const t=P.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){const t=6,r=B.displayStartIndex,a=Math.min(T.length-1,r+t-1);let d=!1;for(let t=r;t<=a;t++){const n=T[t];if(n&&n.days.some(t=>t.date.toDateString()===e.toDateString())){d=!0;break}}if(!d){const e=new Date(i,o,1),t=s(o,i);l.current={month:t,year:i},D(t),E(i),null==n||n(t,i),G(e,!0)}}P.current=e},[e,n,G,B,T,s]),h(()=>{const e=L.current;if(!e)return;const t=new ResizeObserver(([e])=>{b(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),h(()=>{const e=L.current;e&&!A&&i&&requestAnimationFrame(()=>{e&&c>0?(e.scrollTop=c,p(c),R(!0)):e&&R(!0)})},[A,c,i]),h(()=>()=>{$.current&&clearTimeout($.current)},[]),{scrollTop:f,containerHeight:y,currentMonth:w,currentYear:x,isScrolling:C,isNavigating:S,virtualData:B,scrollElementRef:L,handleScroll:V,scrollToDate:G,handlePreviousMonth:K,handleNextMonth:q,handleToday:X,setScrollTop:p,setContainerHeight:b,setCurrentMonth:D,setCurrentYear:E,setIsScrolling:k,cache:j.current,scrollElementRefCallback:_,weeksData:T}})({currentDate:y,weekHeight:M,onCurrentMonthChange:(t,n)=>{const r=p.startsWith("zh")||p.startsWith("ja"),a=f(p,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:p,startOfWeek:w,isEnabled:R}),De=g(0),[xe,Ee]=u(0),Ce=v(()=>xe-6*M,[xe,M]),{visibleWeeks:ke,startIndex:Te}=v(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=he,a=n.findIndex(e=>e.index===r);if(-1===a)return $.current.length>0?{visibleWeeks:$.current,startIndex:De.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),i=n.slice(o,a+8),l=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return i.length>=6&&($.current=i,De.current=l),{visibleWeeks:i,startIndex:l}},[he]),Se=v(()=>Te*M,[Te,M]),Ie=g(!0),Ae=g(!1),He=((e,t)=>{const[n,r]=u(e);return h(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(he.displayStartIndex,250);h(()=>{ve&&(Ae.current=!0)},[ve]),h(()=>{if(Ie.current)return void(Ie.current=!1);const t=ge[He];if(!t)return;const n=new Date(t.startDate);n.setHours(0,0,0,0);const r=new Date(n);r.setDate(r.getDate()+42+7),e.emitVisibleRange(n,r,Ae.current?"navigation":"scroll"),Ae.current=!1},[e,ge,He]);const Oe=v(()=>{const e=he.totalHeight,t=Te*M+ke.length*M+Ce;return Math.max(0,e-t)},[he.totalHeight,Te,M,Ce,ke.length]);h(()=>{const e=me.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Ee(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==L.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/L.current)*n;e.scrollTop=r,we(r)}A(n),L.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[me,we]),h(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));A(t),L.current=t,P(!0)},[]);const Re=m(t=>{e.updateEvent(t.id,t)},[e]),Pe=m(t=>{e.deleteEvent(t)},[e]),Le=t=>{e.changeView(t)},$e=m(()=>Y(null),[]),je=m(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==k||T)&&t&&n){const e=E.find(e=>e.id===t);if(e)return W(e),void z(!0)}X(t)},[k,T,E,X,e]),Ye=m(e=>{("desktop"!==k||T)&&X(e)},[k,T,X]);return et("div",{className:fn,children:[et(Fa,{calendar:e,viewType:I.MONTH,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${ce}年${de}`:`${de} ${ce}`,onPrevious:()=>{e.goToPrevious(),pe()},onNext:()=>{e.goToNext(),ye()},onToday:()=>{e.goToToday(),be()}}),et("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",onContextMenu:e=>e.preventDefault(),children:et("div",{className:"grid grid-cols-7 px-2",children:se.map((e,t)=>et("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),et("div",{ref:me,className:Dn,style:{overflow:"hidden auto",visibility:R?"visible":"hidden"},onScroll:fe,children:[et("div",{style:{height:Se}}),ke.map((o,i)=>{var l;const s=null!==(l=C.get(o.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===i?Object.assign(Object.assign({},o),{height:o.height+Ce}):o,c=!(!1===t.showMonthIndicator||!o.weekData.days.some(e=>1===e.day))&&ue;return et(zo,{item:d,weekHeight:M,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:de,currentYear:ce,screenSize:k,isScrolling:c,calendarRef:a,events:s,onEventUpdate:Re,onEventDelete:Pe,onMoveStart:te,onCreateStart:ne,onResizeStart:re,isDragging:oe,dragState:ae,newlyCreatedEventId:j,onDetailPanelOpen:$e,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Le,onSelectDate:e.selectDate,selectedEventId:K,onEventSelect:je,onEventLongPress:Ye,detailPanelEventId:q,onDetailPanelToggle:J,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:ie,onCalendarDragOver:le,calendarSignature:D,app:e,enableTouch:T},`week-${o.weekData.startDate.getTime()}`)}),et("div",{style:{height:Oe}})]}),et(S,{isOpen:F,onClose:()=>{z(!1),W(null)},onSave:t=>{E.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),z(!1),W(null)},draftEvent:_,app:e})]})},Wo={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Uo=(e={})=>{const t=Object.assign(Object.assign({},Wo),e),n=e=>a(Ao,{viewType:I.MONTH,originalComponent:_o,app:e.app,config:t,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="MonthViewAdapter",{type:I.MONTH,component:n,config:t}};const Bo=c(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=vn(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return et("div",{className:`relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800 ${c?"border-l-2 border-l-primary dark:border-l-primary":""} overflow-hidden bg-white select-none dark:bg-gray-900`,style:{aspectRatio:"1/1"},onClick:()=>r(e),onDblClick:t=>null==a?void 0:a(t,e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),null==l||l(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[et("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&et("span",{className:"rounded-sm bg-primary px-1 py-0.5 text-[9px] leading-none font-bold text-primary-foreground",children:u}),et("span",{className:"ml-auto text-[10px] font-medium "+(t?"flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground":"text-gray-700 dark:text-gray-300"),children:d})]}),i>0&&et("div",{className:"absolute bottom-0.5 left-1 z-20",children:et("span",{className:"cursor-pointer text-xs font-medium text-gray-500 hover:text-gray-700 hover:underline dark:text-gray-400 dark:hover:text-gray-200",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",i," ",s("more")]})})]})});Bo.displayName="YearDayCell";const Zo=c(({rowDays:e,events:t,columnsPerRow:n,app:r,calendarRef:a,locale:o,isDragging:i,dragState:l,onMoveStart:s,onResizeStart:d,onCreateStart:c,selectedEventId:u,onEventSelect:h,onMoreEventsClick:g,newlyCreatedEventId:m,onDetailPanelOpen:f,detailPanelEventId:p,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:w,onContextMenu:D})=>{const x=new Date;x.setHours(0,0,0,0);const E=(e,t)=>{e.preventDefault(),e.stopPropagation(),D({x:e.clientX,y:e.clientY,date:t})},C=v(()=>function(e,t,n){if(0===t.length)return[];const r=t[0],a=t.at(-1),o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),i=new Date(a.getFullYear(),a.getMonth(),a.getDate(),23,59,59,999).getTime(),l=e.filter(e=>{if(!e.start)return!1;const t=B(e.start),n=e.end?B(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=i&&a>=o});l.sort((e,t)=>{const n=B(e.start).getTime(),r=e.end?B(e.end).getTime():n,a=B(t.start).getTime(),o=r-n,i=(t.end?B(t.end).getTime():a)-a;return o!==i?i-o:n-a});const s=[],d=[];return l.forEach(e=>{const a=B(e.start),l=e.end?B(e.end):a,c=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();let h=-1,g=-1;const m=Math.round((c-o)/864e5);h=m>=0?m:0;const v=Math.round((u-o)/864e5);g=v<t.length?v:t.length-1,h=Math.max(0,Math.min(h,n-1)),g=Math.max(0,Math.min(g,n-1));const f=c>=o,p=u<=i;let y=0;for(;;){let e=!1;d[y]||(d[y]=[]);for(let t=h;t<=g;t++)if(d[y][t]){e=!0;break}if(!e){for(let e=h;e<=g;e++)d[y][e]=!0;break}y++}s.push({id:`${e.id}_${r.getTime()}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:f,isLastSegment:p,visualRowIndex:y})}),s}(t,e,n),[t,e,n]),{visibleSegments:k,moreCounts:T}=v(()=>{const t=Array.from({length:e.length}).fill(0);C.forEach(n=>{const r=Math.max(0,n.startCellIndex),a=Math.min(e.length-1,n.endCellIndex);for(let e=r;e<=a;e++)t[e]++});const n=[],r=Array.from({length:e.length}).fill(0);return C.forEach(a=>{let o=!0;const i=Math.max(0,a.startCellIndex),l=Math.min(e.length-1,a.endCellIndex);for(let e=i;e<=l;e++){const n=t[e]>3?1:2;if(a.visualRowIndex>n){o=!1;break}}if(o)n.push(a);else for(let e=i;e<=l;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[C,e.length]);return et("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`},onContextMenu:e=>e.preventDefault(),children:[e.map((e,t)=>{const n=e.getTime()===x.getTime();return et(Bo,{date:e,isToday:n,locale:o,onSelectDate:e=>{r.selectDate(e)},onCreateStart:c,onMoreEventsClick:g,moreCount:T[t],onContextMenu:E},e.getTime())}),et("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:et("div",{className:"relative h-full w-full",children:k.map(e=>et("div",{className:"pointer-events-auto",children:et(ja,{event:e.event,isAllDay:!!e.event.allDay,viewType:I.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:i&&l.eventId===e.event.id,selectedEventId:u,onMoveStart:s,onResizeStart:d,onEventSelect:h,onDetailPanelToggle:y,newlyCreatedEventId:m,onDetailPanelOpen:f,calendarRef:a,app:r,detailPanelEventId:p,customDetailPanelContent:b,customEventDetailDialog:w,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e)})},e.id))})})]})});Zo.displayName="YearRowComponent";const Vo=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:f,locale:p}=vn(),y=t.getCurrentDate(),b=y.getFullYear(),w=t.getEvents(),D=g(null),[x,E]=u(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[C,k]=u(!1),[T,N]=u(null),[S,M]=u(null),A=void 0===i?T:i,H=void 0===s?S:s,O=e=>{l?l(e):N(e)},R=e=>{d?d(e):M(e)},[P,L]=u(null),[$,j]=u(null);h(()=>{const e=e=>{if(2===e.button)return;const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),i=t.closest("[data-calendar-picker-dropdown]"),l=t.closest(".df-context-menu");n||r||a||o||i||l||(O(null),R(null),j(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=g(null);h(()=>{const e=D.current;if(!e)return;const t=new ResizeObserver(e=>{Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);E(Math.max(1,n)),k(!0)},60)});return t.observe(e),()=>{t.disconnect(),Y.current&&clearTimeout(Y.current)}},[]);const F=g(t.state.highlightedEventId);h(()=>{t.state.highlightedEventId?O(t.state.highlightedEventId):F.current&&O(null),F.current=t.state.highlightedEventId},[t.state.highlightedEventId]);const{handleMoveStart:z,handleResizeStart:_,handleCreateStart:W,dragState:U,isDragging:Z}=Mo(t,{calendarRef:n,viewType:I.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(w).filter(e=>{const t=w.find(t=>t.id===e.id);return t&&Ze(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:w,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{L(e.id)}}),V=null!==(c=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==c&&c,G=m((n,r)=>{if(V)null==W||W(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:f("newEvent")||"New Event",start:n,end:n,allDay:!0,calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"};t.addEvent(a),L(a.id)}},[V,W,t,f]),K=v(()=>{const e=[],t=new Date(b,0,1),n=new Date(b,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[b]),q=v(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(K,x),[K,x]),X=v(()=>{const e=new Date(b,0,1),t=new Date(b,11,31,23,59,59);return w.filter(n=>{if(!n.start)return!1;if(!V&&!n.allDay)return!1;const r=B(n.start),a=n.end?B(n.end):r;return r<=t&&a>=e})},[w,b,V]);return et("div",{className:fn,onContextMenu:e=>e.preventDefault(),children:[et(Fa,{calendar:t,viewType:I.YEAR,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${b}年`:`${b}`,onPrevious:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}}),et("div",{ref:D,className:`${Dn} ${xn}`,style:{overflow:"hidden auto"},children:et("div",{className:"flex w-full flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:C?1:0,transition:"opacity 0.2s ease"},children:q.map((e,o)=>et(Zo,{rowDays:e,events:X,columnsPerRow:x,app:t,calendarRef:n,locale:p,isDragging:Z,dragState:U,onMoveStart:z,onResizeStart:_,onCreateStart:G,selectedEventId:A,onEventSelect:O,onMoreEventsClick:t.onMoreEventsClick,newlyCreatedEventId:P,onDetailPanelOpen:()=>L(null),detailPanelEventId:H,onDetailPanelToggle:R,customDetailPanelContent:r,customEventDetailDialog:a,onContextMenu:j},o))})}),$&&et(Da,{x:$.x,y:$.y,date:$.date,viewType:I.YEAR,onClose:()=>j(null),app:t,onCreateEvent:()=>{if($&&$.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:$.x,clientY:$.y};G(e,$.date)}}})]})};function Go(e,t,n,r=1){const a=new Date(n,t,1),o=new Date(n,t+1,0).getDate(),i=(a.getDay()-r+7)%7,l=a.getTime(),s=new Date(n,t,o,23,59,59,999).getTime(),d=e.filter(e=>{if(!e.start)return!1;const t=B(e.start),n=e.end?B(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=s&&a>=l});d.sort((e,t)=>{const n=B(e.start).getTime(),r=e.end?B(e.end).getTime():n,a=B(t.start).getTime(),o=r-n,i=(t.end?B(t.end).getTime():a)-a;return o!==i?i-o:n-a});const c=[],u=[];d.forEach(e=>{const r=B(e.start),a=e.end?B(e.end):r,o=new Date(Math.max(r.getTime(),l)),d=new Date(Math.min(a.getTime(),s)),h=o.getDate(),g=d.getDate(),m=i+(h-1),v=i+(g-1),f=r.getMonth()===t&&r.getFullYear()===n,p=a.getMonth()===t&&a.getFullYear()===n;let y=0;for(;;){let e=!1;u[y]||(u[y]=[]);for(let t=m;t<=v;t++)if(u[y][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)u[y][e]=!0;break}y++}c.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:p,visualRowIndex:y,monthIndex:t})});const h=c.length>0?Math.max(...c.map(e=>e.visualRowIndex)):-1;return{segments:c,maxVisualRow:h}}const Ko=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,f;const{t:p,locale:y,getWeekDaysLabels:b}=vn(),w=t.getCurrentDate(),D=w.getFullYear(),x=t.getEvents(),E=new Date;E.setHours(0,0,0,0);const C=null!==(c=null==o?void 0:o.startOfWeek)&&void 0!==c?c:1,k=g(null),T=g(null),N=g(null),[S,M]=u(0),[A,H]=u(0),[O,R]=u(null),[P,L]=u(null),$=void 0===i?O:i,j=void 0===s?P:s,Y=e=>{l?l(e):R(e)},F=e=>{d?d(e):L(e)},[z,_]=u(null),[W,U]=u(null);h(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),i=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||i||(Y(null),F(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Z=v(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(D,t,1),r=new Date(D,t+1,0).getDate(),a=(n.getDay()-C+7)%7+r;a>e&&(e=a)}return e},[D,C]),{handleMoveStart:V,handleResizeStart:G,handleCreateStart:K,dragState:q,isDragging:X}=Mo(t,{calendarRef:n,viewType:I.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(x).filter(e=>{const t=x.find(t=>t.id===e.id);return t&&Ze(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:x,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{_(e.id)}}),J=null!==(f=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==f&&f,Q=m((n,r)=>{if(J)null==K||K(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:p("newEvent")||"New Event",start:n,end:n,allDay:!0};t.addEvent(a),_(a.id)}},[J,K,t]),ee=v(()=>{const e=b(y,"short",C).map(e=>{if(y.startsWith("zh"))return e.at(-1);const t=e.slice(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),t=[];for(let n=0;n<Z;n++)t.push(e[n%7]);return t},[y,b,Z,C]),te=v(()=>{const e=new Date(D,0,1),t=new Date(D,11,31,23,59,59);return x.filter(n=>{if(!n.start)return!1;if(!J&&!n.allDay)return!1;const r=B(n.start),a=n.end?B(n.end):r;return r<=t&&a>=e})},[x,D,J]),ne=v(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(D,t,1),r=new Date(D,t+1,0).getDate(),a=(n.getDay()-C+7)%7,o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=r;e++)o.push(new Date(D,t,e));for(;o.length<Z;)o.push(null);const i=n.toLocaleDateString(y,{month:"short"}),l=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Go(te,t,D,C),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:l,days:o,eventSegments:s,minHeight:u})}return e},[D,y,Z,te,C]),re=m(e=>{const t=e.currentTarget;k.current&&(k.current.scrollLeft=t.scrollLeft),T.current&&(T.current.scrollTop=t.scrollTop)},[]);h(()=>{const e=()=>{if(N.current){const e=N.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;H(e=>e===t?e:t),M(e=>e===n?e:n)}},t=N.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[ne]);return et("div",{className:"h-full overflow-hidden bg-white select-none dark:bg-gray-900",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"col-span-2",children:et(Fa,{calendar:t,viewType:I.YEAR,currentDate:w,customTitle:y.startsWith("zh")||y.startsWith("ja")?`${D}年`:`${D}`,onPrevious:()=>{const e=new Date(w);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(w);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}})}),et("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),et("div",{ref:k,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:et("div",{className:"flex",style:{minWidth:`calc(1352px + ${S}px)`},children:[et("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`,minWidth:"1352px"},children:ee.map((e,t)=>{const n=(t+C)%7;return et("div",{className:"border-r border-gray-200 py-2 text-center text-[10px] font-bold tracking-wider text-gray-500 dark:border-gray-700 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},`label-${t}`)})}),S>0&&et("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${S}px`}})]})}),et("div",{ref:T,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:et("div",{className:"flex min-h-full flex-col",children:[ne.map(e=>et("div",{className:"flex shrink-0 grow items-center justify-center border-b border-gray-200 text-[10px] font-bold text-gray-500 dark:border-gray-700 dark:text-gray-400",style:{minHeight:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),A>0&&et("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${A}px`}})]})}),et("div",{ref:N,className:`overflow-auto ${xn}`,onScroll:re,children:et("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:ne.map(e=>et("div",{className:"relative shrink-0 grow",style:{minHeight:`${e.minHeight}px`},children:[et("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:e.days.map((n,r)=>{const a=(r+C)%7,o=0===a||6===a;if(!n)return et("div",{className:"border-r border-b border-gray-200 bg-gray-50/80 dark:border-gray-700 dark:bg-gray-800/40 "+(o?"df-year-view-weekend-cell":"")},`empty-${e.monthIndex}-${r}`);const i=(e=>e.getTime()===E.getTime())(n);return et("div",{"data-date":`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,className:`relative flex cursor-pointer items-start justify-end border-r border-b border-gray-200 p-0.5 transition-colors hover:bg-blue-100 dark:border-gray-700 dark:hover:bg-primary/20 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>t.selectDate(n),onDblClick:e=>Q(e,n),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),U({x:e.clientX,y:e.clientY,date:t})})(e,n),children:et("span",{className:`flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium ${i?"bg-primary font-bold text-primary-foreground shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:n.getDate()})},n.getTime())})}),e.eventSegments.length>0&&et("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:et("div",{className:"relative h-full w-full",children:e.eventSegments.map(e=>et("div",{className:"pointer-events-auto",children:et(ja,{event:e.event,isAllDay:!!e.event.allDay,viewType:I.YEAR,yearSegment:e,columnsPerRow:Z,isBeingDragged:X&&q.eventId===e.event.id,selectedEventId:$,onMoveStart:V,onResizeStart:G,onEventSelect:Y,onDetailPanelToggle:F,newlyCreatedEventId:z,onDetailPanelOpen:()=>_(null),calendarRef:n,app:t,detailPanelEventId:j,customDetailPanelContent:r,customEventDetailDialog:a,firstHour:0,hourHeight:0,onEventUpdate:e=>t.updateEvent(e.id,e),onEventDelete:e=>t.deleteEvent(e)})},e.id))})})]},e.monthIndex))})}),W&&et(Da,{x:W.x,y:W.y,date:W.date,viewType:I.YEAR,onClose:()=>U(null),app:t,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:W.x,clientY:W.y};Q(e,W.date)}})]})},qo=e=>{var t;return et("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?Ko:Vo,Object.assign({},e))},Xo={startOfWeek:1},Jo=(e={})=>{const t=Object.assign(Object.assign({},Xo),e),n=e=>a(Ao,{viewType:I.YEAR,originalComponent:qo,app:e.app,config:t,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="YearViewAdapter",{type:I.YEAR,component:n,config:t}};function Qo(e){return[Oo(null==e?void 0:e.day),Fo(null==e?void 0:e.week),Uo(null==e?void 0:e.month)]}const ei={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function ti(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);return r.setDate(n),r.setHours(0,0,0,0),r}function ni(e={}){const t=Object.assign(Object.assign({},ei),e);let n;const r={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=r.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(r.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=ti(n.getCurrentDate()),t=je(n.getAllEvents(),e);n.state.events=t}},update:(e,a)=>{const o=r.getById(e);if(!o)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},o),a);if(t.enableValidation){const e=r.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,a),t.enableAutoRecalculate){const e=ti(n.getCurrentDate()),t=je(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=B(t.start);n.setHours(0,0,0,0);const r=new Date(e);return r.setHours(0,0,0,0),n.getTime()===r.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const r=B(n.start),a=B(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=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)=>je(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)};return{name:"events",config:t,install:e=>{n=e},api:r}}export{Rr as BlossomColorPicker,Je as CalendarApp,ce as CalendarRegistry,ua as CalendarRenderer,lr as Check,tr as ChevronRight,sr as ChevronsUpDown,Or as ContentSlot,ha as ContextMenu,wa as ContextMenuColorPicker,ga as ContextMenuItem,va as ContextMenuLabel,ma as ContextMenuSeparator,$r as CreateCalendarDialog,ca as CustomRenderingStore,Pr as DefaultColorPicker,A as LAYOUT_CONFIG,T as LOCALES,mn as LocaleContext,kr as LocaleProvider,qr as MiniCalendar,pr as PanelRightClose,yr as PanelRightOpen,or as Plus,ye as TIME_STEP,R as TimeZone,H as VIRTUAL_MONTH_SCROLL_CONFIG,I as ViewType,O as WeekDataCache,Q as addDays,Dt as buildParseRegExp,Le as calculateDayIndex,Yn as calendarPickerDropdown,bn as cancelButton,Dr as capitalize,Gt as clipboardStore,At as conditionalTheme,_t as convertDateEvent,Wt as convertDateEventWithTimeZone,ln as convertToDayFlowEvent,Ft as createAllDayEvent,re as createDateWithHour,Oo as createDayView,Lt as createEvent,Pe as createEventWithDate,We as createEventWithPlainDateTime,ze as createEventWithRealDate,Ue as createEventWithZonedDateTime,jt as createEvents,ni as createEventsPlugin,Uo as createMonthView,Qo as createStandardViews,Z as createTemporalWithHour,zt as createTimedEvent,$t as createTimezoneEvent,Yt as createTimezoneEvents,Fo as createWeekView,Jo as createYearView,st as dateToPlainDate,dt as dateToPlainDateTime,ct as dateToZonedDateTime,X as daysBetween,J as daysDifference,cn as downloadICS,k as en,Qt as escapeICSValue,ne as extractHourFromDate,gt as extractHourFromTemporal,an as extractVEvents,tn as foldLine,rt as formatDate,tt as formatDateConsistent,Jt as formatDateToICSTimestamp,De as formatEventTimeRange,Xt as formatICSDate,nt as formatMonthYear,nn as formatProperty,kt as formatTemporal,be as formatTime,ke as generateDayData,dn as generateICS,Ee as generateSecondaryTimeSlots,Ge as generateUniKey,rn as generateVEvent,Ne as generateWeekData,Me as generateWeekRange,Se as generateWeeksData,Ae as getAllDayEventsForDay,ge as getCalendarColorsForHex,F as getCurrentWeekDates,He as getDateByDayIndex,Ut as getDateObj,Ye as getDayIndexByDate,oe as getEndOfDay,q as getEndOfTemporal,me as getEventBgColor,we as getEventEndHour,ve as getEventTextColor,Ie as getEventsForDay,Fe as getEventsForWeek,wr as getIntlLabel,pe as getLineColor,Er as getMonthLabels,Te as getMonthYearOfWeek,vt as getPlainDate,Zt as getSearchHeaderInfo,fe as getSelectedBgColor,ae as getStartOfDay,K as getStartOfTemporal,Ve as getTestEvents,Ce as getTimezoneDisplayLabel,xr as getWeekDaysLabels,ie as getWeekNumber,Y as getWeekRange,Et as getZoneId,Vt as groupSearchResults,Ze as hasEventChanged,un as importICSFile,_ as isDate,Ke as isDeepEqual,Be as isEventDeepEqual,$e as isEventInWeek,se as isMultiDayEvent,G as isMultiDayTemporalEvent,at as isPlainDate,ot as isPlainDateTime,le as isSameDay,V as isSamePlainDate,ft as isSameTemporal,M as isValidLocale,it as isZonedDateTime,Ht as mergeClasses,bt as mergeFormatTemplate,$ as monthNames,Tt as normalizeCssWidth,Bt as normalizeDate,S as normalizeLocale,Ct as normalizeToZoned,ee as now,yt as pad,Kt as pad2,sn as parseICS,qt as parseICSDate,xt as parseTemporalString,on as parseVEventLines,ut as plainDateTimeToDate,ht as plainDateToDate,je as recalculateEventDays,No as registerDragImplementation,N as registerLocale,oa as registerSidebarImplementation,Ot as resolveAppliedTheme,xe as roundToTimeStep,St as scrollbarTakesSpace,mt as setHourInTemporal,j as shortMonthNames,_n as sidebarContainer,Wn as sidebarHeader,Bn as sidebarHeaderTitle,Un as sidebarHeaderToggle,Cr as t,lt as temporalToDate,It as themeClasses,Mt as themeCn,te as today,en as unescapeICSValue,Oe as updateEventDateAndDay,_e as updateEventWithRealDate,Mo as useDragForView,vn as useLocale,la as useSidebarBridge,P as weekDays,L as weekDaysFullName,U as zonedDateTimeToDate};