@dayflow/core 3.4.1 → 3.4.2
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.d.ts +52 -12
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +0 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__rest as t}from"tslib";import{Temporal as n}from"temporal-polyfill";import{options as r,createContext as a,Fragment as o,h as i,render as l,isValidElement as s,cloneElement as d}from"preact";import{createPortal as c,forwardRef as u,memo as h}from"preact/compat";export{createPortal}from"preact/compat";import{useState as g,useEffect as m,useRef as v,useCallback as f,useMemo as p,useLayoutEffect as y,useContext as b}from"preact/hooks";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}?\nDoing so will move all the events from {sourceName} to {targetName} and {sourceName} will be deleted.\nThis 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",subscribeCalendar:"Subscribe to Calendar",subscribeCalendarTitle:"Enter the URL of the calendar you want to subscribe to.",calendarUrl:"Calendar URL",calendarUrlPlaceholder:"https://example.com/calendar.ics",subscribe:"Subscribe",fetchingCalendar:"Fetching calendar...",subscribeError:"Failed to fetch calendar. Please check the URL and try again."}},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",e.RESOURCE="resource"}(I||(I={}));const O={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 R{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=R.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=R.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 A;function P(e){var t;if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;if(e instanceof n.PlainDate)return!0;const r=e;return"PlainDate"===(null===(t=r.constructor)||void 0===t?void 0:t.name)||!("hour"in r)&&!("timeZone"in r)&&"year"in r&&"month"in r&&"day"in r}function L(e){return e instanceof Date}function $(e,t=n.Now.timeZoneId()){return n.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function j(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 Y(e,t){if(e instanceof Date)return e;if(P(e))return function(e,t=n.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime)try{return j(e.toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(e.year,e.month-1,e.day)}(e,t);if(e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)){const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}if(e&&"object"==typeof e&&"year"in e){return j(e)}return new Date(e)}function F(e,t){const r=Math.floor(t),a=Math.round(60*(t-r));if(P(e))return n.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:r,minute:a});if("function"==typeof e.with)return e.with({hour:r,minute:a,second:0,millisecond:0});const o=e;return n.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function Z(e,t){if(e instanceof Date&&t instanceof Date)return e.toDateString()===t.toDateString();const r=e=>{if(e instanceof Date)return t=e,n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()});var t;if(P(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const r=e;return n.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(e),o=r(t);return 0===n.PlainDate.compare(a,o)}function z(e,t){return!Z(e,t)}function U(e,t=n.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(P(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:0,minute:0})})}const r=e;return(P(e)?e:n.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:0,minute:0})})}function W(e,t=n.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(P(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=e;return(P(e)?e:n.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function _(e,t){const r=e=>{if(P(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const t=e;return n.PlainDate.from({year:t.year,month:t.month,day:t.day})},a=r(e),o=r(t);return a.until(o).days}function B(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 V(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function G(e=n.Now.timeZoneId()){return n.Now.zonedDateTimeISO(e)}function K(e=n.Now.timeZoneId()){return n.Now.plainDateISO(e)}!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.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.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.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.KARACHI="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.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"}(A||(A={}));const q=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(P(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)},X=(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 F(e,t)},J=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return U(e)},Q=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return W(e)},ee=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)},te=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Z(e instanceof Date?n.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):P(e)?e:e.toPlainDate(),t instanceof Date?n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):P(t)?t:t.toPlainDate())},ne=(e,t)=>!te(e,t),re=[{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 ae{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)}):re.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=ae.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 oe=new ae;function ie(){return oe}function le(e){const t=re.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 se=(e,t)=>(t||ie()).resolveColors(e).eventColor,de=(e,t)=>(t||ie()).resolveColors(e).textColor,ce=(e,t)=>(t||ie()).resolveColors(e).eventSelectedColor,ue=(e,t)=>(t||ie()).resolveColors(e).lineColor;const he=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)}},ge=new Map;function me(e){try{return new Intl.DateTimeFormat("en",{timeZone:e}).resolvedOptions().timeZone}catch(e){return}}function ve(e){if(!e||"string"!=typeof e)return;const t=e.trim();if(!t)return;const n=ge.get(t);if(n)return n;const r=me(t);if(r)return ge.set(t,r),r;const a=Object.values(A).find(e=>e.toLowerCase()===t.toLowerCase());if(a){const e=me(a);return e?(ge.set(t,e),e):(ge.set(t,a),a)}if("function"==typeof Intl.supportedValuesOf){const e=Intl.supportedValuesOf("timeZone").find(e=>e.toLowerCase()===t.toLowerCase());if(e)return ge.set(t,e),e}const o=me(t.split("/").map(e=>e.split("_").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("_")).join("/"));if(o)return ge.set(t,o),o;const i=me(t.split("/").map((e,t)=>0===t?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("/"));return i?(ge.set(t,i),i):t}function fe(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function pe(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&!("timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function ye(e){return null!==e&&"object"==typeof e&&("timeZone"in e||"timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function be(e){if(e instanceof Date)return e;if(fe(e))return new Date(e.year,e.month-1,e.day);if(pe(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(ye(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):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 we(e,t){if(e instanceof Date)return e;if(!t)return be(e);const r=ve(t);if(!r)return be(e);try{if(ye(e)){const t=("function"==typeof e.withTimeZone?e:n.ZonedDateTime.from(e)).withTimeZone(r);return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}if(pe(e)){const t="function"==typeof e.toZonedDateTime?e:n.PlainDateTime.from(e),a=t.toZonedDateTime(n.Now.timeZoneId()).withTimeZone(r);return new Date(a.year,a.month-1,a.day,a.hour,a.minute,a.second||0,a.millisecond||0)}}catch(e){he.error("Failed to shift visual timezone:",e)}return be(e)}function De(e,t){if(!t)return e;const r=ve(t);if(!r)return e;try{if(ye(e)){return("function"==typeof e.withTimeZone?e:n.ZonedDateTime.from(e)).withTimeZone(r)}if(pe(e)){return("function"==typeof e.toZonedDateTime?e:n.PlainDateTime.from(e)).toZonedDateTime(n.Now.timeZoneId()).withTimeZone(r)}}catch(e){he.error("Failed to shift visual temporal:",e)}return e}function xe(e){return n.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Ee(e){return n.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function Ce(e,t=n.Now.timeZoneId()){return n.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t})}function ke(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}function Te(e){return new Date(e.year,e.month-1,e.day)}function Ne(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(fe(e))return 0;const t=e;return t.hour+t.minute/60}function Se(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return ye(e),e.with({hour:n,minute:r,second:0,millisecond:0})}function Me(e){return e instanceof Date?xe(e):fe(e)?e:(pe(e),e.toPlainDate())}function Ie(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=Me(e),r=Me(t);return n.equals(r)}const Oe=e=>new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,Math.floor(e.millisecond)),He=.25,Re=(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")}`},Ae=e=>{if(!e.end)return 0;const t=q(e.end);if(e.allDay||!e.start)return t;const n=Y(e.start),r=Y(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},Pe=(e,t="24h")=>{const n=q(e.start),r=Ae(e);return`${Re(n,0,t)} - ${Re(r,0,t)}`},Le=e=>.25*Math.round(e/.25),$e=(e,t,r="24h",a=new Date,o)=>{const i=ve(t);if(!i)return e.map(()=>"");const l=null!=o?o:n.Now.timeZoneId(),s=a.getFullYear(),d=a.getMonth()+1,c=a.getDate();return e.map(e=>{try{const t=e.hour%24,a=n.ZonedDateTime.from({year:s,month:d,day:c,hour:t,minute:0,second:0,timeZone:l}).withTimeZone(i);return Re(a.hour,a.minute,r)}catch(e){return""}})},je=(e,t=new Date)=>{var n,r;const a=ve(e);if(!a)return"";try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:a,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:a}catch(e){return a}},Ye=e=>{var t;const r=null!==(t=e?ve(e):void 0)&&void 0!==t?t:n.Now.timeZoneId();return Oe(n.Now.zonedDateTimeISO(r))},Fe=e=>{var t;const r=null!==(t=e?ve(e):void 0)&&void 0!==t?t:n.Now.timeZoneId(),a=n.Now.plainDateISO(r);return new Date(a.year,a.month-1,a.day)},Ze=e=>{var t;const r=null!==(t=e?ve(e):void 0)&&void 0!==t?t:n.Now.timeZoneId(),a=n.Now.zonedDateTimeISO(r).add({hours:1}).with({minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{start:Oe(a),end:Oe(a.add({hours:1}))}},ze=(e,t,r)=>{var a,o;const i=Y(e);if(ye(t)){const e=null!==(a=ve(r))&&void 0!==a?a:n.Now.timeZoneId(),o=(e=>{var t;const r=e;return r.timeZoneId||("string"==typeof r.timeZone?r.timeZone:null===(t=r.timeZone)||void 0===t?void 0:t.id)||n.Now.timeZoneId()})(t);return Ce(i,e).toInstant().toZonedDateTimeISO(o)}return pe(t)?Ee(i):ye(e)?e:Ce(i,null!==(o=ve(r))&&void 0!==o?o:n.Now.timeZoneId())},Ue=(e,t,n)=>t.allDay?Object.assign(Object.assign({},t),{allDay:!0,start:fe(t.start)?t.start:xe(Y(t.start)),end:fe(t.end)?t.end:xe(Y(t.end))}):Object.assign(Object.assign({},t),{allDay:!1,start:ze(t.start,e.allDay?t.start:e.start,n),end:ze(t.end,e.allDay?t.end:e.end,n)}),We=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],_e=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Be=["January","February","March","April","May","June","July","August","September","October","November","December"],Ve=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ge=(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}},Ke=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return We.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()}})},qe=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:Be[r],shortMonthName:Ve[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},Xe=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:Be[a],monthIndex:a,year:o}},Je=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(qe(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Xe(t)}},Qe=(e,t=3)=>{const n=5*t,{monday:r}=Ge(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(Je(t))}return a};function et(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(Je(t))}return r}const tt=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),nt=(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=Y(t.start);a.setHours(0,0,0,0);const o=Y(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),rt=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},at=(e,t,r)=>{const a=rt(r,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?n.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):n.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:n.Now.timeZoneId()}),end:e.allDay?n.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):n.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:n.Now.timeZoneId()})})},ot=(e,t)=>t?n.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):n.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:n.Now.timeZoneId()}),it=(e,t)=>{var n,r;const a=rt(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:ot(a,o),end:ot(a,o)})},lt=(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)},st=(e,t)=>{const n=lt(e,t);return n>=0&&n<=6},dt=(e,t)=>e.map(e=>{const n=Y(e.start),r=lt(n,t);return Object.assign(Object.assign({},e),{day:r})}),ct=(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)},ut=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=Y(e.start);return r>=t&&r<=n}).map(e=>{const n=lt(Y(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},ht=(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:ot(a,o),end:ot(a,o)})},gt=(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:ot(a,o),end:ot(a,o)})},mt=(e,t)=>{var r,a;const o=rt(t,null!==(r=e.day)&&void 0!==r?r:0);if(null!==(a=e.allDay)&&void 0!==a&&a){const t=n.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},e),{start:t,end:t})}const i=n.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({},e),{start:i,end:i})},vt=(e,t,r)=>{var a,o;const i=rt(t,null!==(a=e.day)&&void 0!==a?a:0);if(null!==(o=e.allDay)&&void 0!==o&&o){const t=n.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},e),{start:t,end:t})}const l=n.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({},e),{start:l,end:l})},ft=(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()),pt=(e,t)=>Y(e.start).getTime()!==Y(t.start).getTime()||Y(e.end).getTime()!==Y(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function yt(){const e=new Date,t=e.getDay(),r=new Date(e),a=0===t?-6:1-t;r.setDate(e.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(e=>{const t=new Date(r);if(t.setDate(r.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),o=Math.round(60*(e.startHour-a)),i=Math.floor(e.endHour),l=Math.round(60*(e.endHour-i));return{id:e.id,title:e.title,start:n.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:a,minute:o,timeZone:n.Now.timeZoneId()}),end:n.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:i,minute:l,timeZone:n.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})}function bt(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function wt(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)||!wt(a[e],o[e]))return!1;return!0}class Dt{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=Dt.normalizeChanges(this.pendingChanges);return this.isInTransaction=!1,this.pendingChanges=[],t.length>0?null===(e=this.onEventBatchChange)||void 0===e?void 0:e.call(this,t):void 0}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);return 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);return this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);if(t)return 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;if(!this.isInTransaction)return null===(t=this.onEventChange)||void 0===t?void 0:t.call(this,e);this.pendingChanges.push(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 xt{constructor(e,t,n,r,a,o){this.state=e,this.registry=t,this.getCallbacks=n,this.notify=r,this.triggerRender=a,this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.externalEvents=new Map,this.MAX_UNDO_STACK=50,this.store=new Dt(o),this.setupStoreListeners()}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a;this.syncExternalEventsToState();let o=null;return"create"===e.type?o=null===(n=(t=this.getCallbacks()).onEventCreate)||void 0===n?void 0:n.call(t,e.event):"update"===e.type&&(o=null===(a=(r=this.getCallbacks()).onEventUpdate)||void 0===a?void 0:a.call(r,e.after)),this.triggerRender(),this.notify(),null!=o?o:void 0},this.store.onEventBatchChange=e=>{var t,n;this.syncExternalEventsToState();let r=null;return"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(r=null===(n=(t=this.getCallbacks()).onEventBatchChange)||void 0===n?void 0:n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify(),null!=r?r:void 0}}getStore(){return this.store}pushToUndo(e){this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()}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 Dt(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())}applyEventsChanges(e,t,n){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){he.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){he.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}addEvent(e){this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)}addExternalEvents(e,t){const n=t.map(t=>Object.assign(Object.assign({},t),{calendarId:e}));this.externalEvents.set(e,n),this.syncExternalEventsToState(),this.notify()}syncExternalEventsToState(){const e=this.store.getAllEvents(),t=new Map;if(e.forEach(e=>t.set(e.id,e)),this.externalEvents.size>0)for(const e of this.externalEvents.values())e.forEach(e=>t.set(e.id,e));this.state.events=Array.from(t.values())}updateEvent(t,n,r,a){return e(this,void 0,void 0,function*(){if(a&&(this.pendingChangeSource=a),r?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),r){const e=this.state.events.findIndex(e=>e.id===t);if(-1===e)throw new Error(`Event with id ${t} not found`);const r=Object.assign(Object.assign({},this.state.events[e]),n);return this.state.events=[...this.state.events.slice(0,e),r,...this.state.events.slice(e+1)],void this.notify()}yield this.store.updateEvent(t,n)})}deleteEvent(t){return e(this,void 0,void 0,function*(){var e,n;yield null===(n=(e=this.getCallbacks()).onEventDelete)||void 0===n?void 0:n.call(e,t),this.pendingSnapshot=null,this.pushToUndo(),yield this.store.deleteEvent(t)})}getAllEvents(){return[...this.state.events]}getEvents(){const e=this.state.events||[],t=new Set(this.registry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!!e.calendarId&&t.has(e.calendarId))}onEventClick(e){var t,n;null===(n=(t=this.getCallbacks()).onEventClick)||void 0===n||n.call(t,e)}onMoreEventsClick(e){var t,n;null===(n=(t=this.getCallbacks()).onMoreEventsClick)||void 0===n||n.call(t,e)}highlightEvent(e){var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}selectEvent(e){var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}dismissUI(){var e,t;null===(t=(e=this.getCallbacks()).onDismissUI)||void 0===t||t.call(e),this.notify()}}class Et{constructor(e,t,n,r){this.state=e,this.getCallbacks=t,this.notify=n,this.visibleMonth=new Date(r.getFullYear(),r.getMonth(),1)}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.getCallbacks()).onViewChange)||void 0===n||n.call(t,e),this.handleVisibleRangeChange("viewChange"),this.notify()}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}emitVisibleRange(e,t,n="navigation"){var r,a;null===(a=(r=this.getCallbacks()).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)}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}=Ge(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}=Ge(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}}}setCurrentDate(e){var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.handleVisibleRangeChange("navigation"),this.notify()}getCurrentDate(){return new Date(this.state.currentDate)}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.getCallbacks()).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())}getVisibleMonth(){return new Date(this.visibleMonth)}goToToday(){const e=n.Now.plainDateISO(this.state.timeZone),t=new Date(e.year,e.month-1,e.day);this.setCurrentDate(t)}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)}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)}selectDate(e){var t,n;this.setCurrentDate(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,new Date(e))}}class Ct{constructor(e,t){this.state=e,this.notify=t}install(e,t){this.state.plugins.has(e.name)?he.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(t))}getPlugin(e){const t=this.state.plugins.get(e);return null==t?void 0:t.api}hasPlugin(e){return this.state.plugins.has(e)}getPluginConfig(e){const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}}updatePluginConfig(e,t){const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())}}class kt{constructor(t){var r,a,o,i,l;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.changeView=e=>this.navigation.changeView(e),this.getCurrentView=()=>this.navigation.getCurrentView(),this.emitVisibleRange=(e,t,n)=>this.navigation.emitVisibleRange(e,t,n),this.handleVisibleRangeChange=e=>this.navigation.handleVisibleRangeChange(e),this.setCurrentDate=e=>this.navigation.setCurrentDate(e),this.getCurrentDate=()=>this.navigation.getCurrentDate(),this.setVisibleMonth=e=>this.navigation.setVisibleMonth(e),this.getVisibleMonth=()=>this.navigation.getVisibleMonth(),this.goToToday=()=>this.navigation.goToToday(),this.goToPrevious=()=>this.navigation.goToPrevious(),this.goToNext=()=>this.navigation.goToNext(),this.selectDate=e=>this.navigation.selectDate(e),this.undo=()=>this.eventManager.undo(),this.applyEventsChanges=(e,t,n)=>this.eventManager.applyEventsChanges(e,t,n),this.addEvent=e=>this.eventManager.addEvent(e),this.addExternalEvents=(e,t)=>this.eventManager.addExternalEvents(e,t),this.updateEvent=(e,t,n,r)=>this.eventManager.updateEvent(e,t,n,r),this.deleteEvent=e=>this.eventManager.deleteEvent(e),this.getAllEvents=()=>this.eventManager.getAllEvents(),this.getEvents=()=>this.eventManager.getEvents(),this.onEventClick=e=>this.eventManager.onEventClick(e),this.onMoreEventsClick=e=>this.eventManager.onMoreEventsClick(e),this.highlightEvent=e=>this.eventManager.highlightEvent(e),this.selectEvent=e=>this.eventManager.selectEvent(e),this.dismissUI=()=>this.eventManager.dismissUI(),this.getReadOnlyConfig=e=>function(e,t,n,r){var a,o;let i=!0,l=!0;if(!0===e?(i=!1,l=!1):!1!==e&&(i=null===(a=e.draggable)||void 0===a||a,l=null===(o=e.viewable)||void 0===o||o),t&&(i||l)){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);o&&(!0===o.readOnly&&(i=!1),o.subscription&&void 0===o.readOnly&&(i=!1))}return{draggable:i,viewable:l}}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.canMutateFromUI=e=>function(e,t,n,r){if(!1!==e)return!1;if(t){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);if(o){if(void 0!==o.readOnly)return!o.readOnly;if(o.subscription)return!1}}return!0}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{this.calendarRegistry.reorder(e,t),this.triggerRender()},this.setCalendarVisibility=(e,t)=>{this.calendarRegistry.setVisibility(e,t),this.triggerRender()},this.setAllCalendarsVisibility=e=>{this.calendarRegistry.setAllVisibility(e),this.triggerRender()},this.updateCalendar=(e,t,n)=>{var r,a;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const o=this.calendarRegistry.get(e);o&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,o)),this.triggerRender()},this.createCalendar=t=>e(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.register(t),yield null===(n=(e=this.callbacks).onCalendarCreate)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.deleteCalendar=t=>e(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.unregister(t),yield null===(n=(e=this.callbacks).onCalendarDelete)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.mergeCalendars=(t,n)=>e(this,void 0,void 0,function*(){var e,r;const a=this.eventManager.getStore(),o=a.getAllEvents().filter(e=>e.calendarId===t);this.eventManager.pushToUndo(),a.beginTransaction(),o.forEach(e=>a.updateEvent(e.id,{calendarId:n})),yield a.endTransaction(),yield this.deleteCalendar(t),yield null===(r=(e=this.callbacks).onCalendarMerge)||void 0===r?void 0:r.call(e,t,n)}),this.getPlugin=e=>this.pluginManager.getPlugin(e),this.hasPlugin=e=>this.pluginManager.hasPlugin(e),this.getPluginConfig=e=>this.pluginManager.getPluginConfig(e),this.updatePluginConfig=(e,t)=>this.pluginManager.updatePluginConfig(e,t),this.setTheme=e=>{this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>t(e)),this.triggerRender()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>this.unsubscribeThemeChange(e)),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.setOverrides=e=>{this.state.overrides=e,this.triggerRender()},this.updateConfig=e=>{var t,n;let r=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,r=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,r=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,r=!0),void 0===e.readOnly||wt(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,r=!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,r=!0),void 0!==e.locale){const t=kt.resolveLocale(e.locale);wt(t,this.state.locale)||(this.state.locale=t,r=!0)}if(void 0!==e.allDaySortComparator&&e.allDaySortComparator!==this.state.allDaySortComparator&&(this.state.allDaySortComparator=e.allDaySortComparator,r=!0),void 0!==e.timeZone){const t=null!==(n=ve(e.timeZone))&&void 0!==n?n:Intl.DateTimeFormat().resolvedOptions().timeZone;t!==this.state.timeZone&&(this.state.timeZone=t,r=!0)}if(void 0!==e.views){const t=new Map(this.state.views);let n=!1;e.views.forEach(e=>{const r=t.get(e.type);r&&wt(e.config,r.config)||(t.set(e.type,e),n=!0)}),n&&(this.state.views=t,r=!0)}if(void 0!==e.calendars){let t=!1;for(const n of e.calendars){const e=this.calendarRegistry.get(n.id);e&&e.source!==n.source&&(this.calendarRegistry.updateCalendar(n.id,{source:n.source}),t=!0)}t&&(r=!0)}r&&this.triggerRender()};const s=null!==(r=ve(t.timeZone))&&void 0!==r?r:Intl.DateTimeFormat().resolvedOptions().timeZone,d=(()=>{const e=n.Now.plainDateISO(s);return new Date(e.year,e.month-1,e.day)})();var c;this.state={currentView:t.defaultView||I.WEEK,currentDate:t.initialDate||d,events:t.events||[],switcherMode:t.switcherMode||"buttons",plugins:new Map,views:new Map,locale:kt.resolveLocale(t.locale),highlightedEventId:null,selectedEventId:null,readOnly:t.readOnly||!1,overrides:[],allDaySortComparator:t.allDaySortComparator,timeZone:s},this.callbacks=t.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.calendarRegistry=new ae(t.calendars,t.defaultCalendar,(null===(a=t.theme)||void 0===a?void 0:a.mode)||"light"),c=this.calendarRegistry,oe=c,this.eventManager=new xt(this.state,this.calendarRegistry,()=>this.callbacks,this.notify,this.triggerRender,t.events||[]),this.navigation=new Et(this.state,()=>this.callbacks,this.notify,this.state.currentDate),this.pluginManager=new Ct(this.state,this.notify),this.useEventDetailDialog=null!==(o=t.useEventDetailDialog)&&void 0!==o&&o,this.useCalendarHeader=null===(i=t.useCalendarHeader)||void 0===i||i,this.customMobileEventRenderer=t.customMobileEventRenderer,t.views.forEach(e=>this.state.views.set(e.type,e)),null===(l=t.plugins)||void 0===l||l.forEach(e=>this.pluginManager.install(e,this)),this.handleVisibleRangeChange("initial")}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"}get timeZone(){return this.state.timeZone}}var Tt=0;function Nt(e,t,n,a,o,i){t||(t={});var l,s,d=t;if("ref"in d)for(s in d={},t)"ref"==s?l=t[s]:d[s]=t[s];var c={type:e,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Tt,__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 r.vnode&&r.vnode(c),c}const St=e=>{if(!e)return"";let t,r,a;e instanceof Date?(a=e.getFullYear(),r=e.getMonth()+1,t=e.getDate()):P(e)?(a=e.year,r=e.month,t=e.day):(!function(e){if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;const t=e;n.ZonedDateTime}(e),a=e.year,r=e.month,t=e.day);const o=String(r).padStart(2,"0");return`${String(t).padStart(2,"0")}/${o}/${a}`},Mt=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,It=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}`},Ot=/(YYYY|YY|MM|DD|HH|mm)/g,Ht=e=>e.toString().padStart(2,"0"),Rt=(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`)},At=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Pt=e=>{let t,n=0,r="^";for(;null!==(t=Ot.exec(e));){r+=At(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=At(e.slice(n))+"$",new RegExp(r)},Lt=(e,t,r,a)=>{const o=e.trim();if(!o)return null;const i=o.match(t),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 n.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}},$t=e=>{const t=e;return t.timeZoneId&&"string"==typeof t.timeZoneId?t.timeZoneId:t.timeZone&&"string"==typeof t.timeZone.id?t.timeZone.id:"string"==typeof t.timeZone?t.timeZone:n.Now.timeZoneId()},jt=(e,t,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(!e){const e=null!=t?t:r?$t(r):n.Now.timeZoneId();return null!=r?r:n.Now.zonedDateTimeISO(e)}if(fe(e)){const r=null!=t?t:n.Now.timeZoneId(),a=`${e.year}-${Ht(e.month)}-${Ht(e.day)}T00:00:00[${r}]`;return n.ZonedDateTime.from(a)}const S=e;if("hour"in S&&!("timeZoneId"in S)){const r=null!=t?t:n.Now.timeZoneId();if("function"==typeof S.toZonedDateTime)try{return e.toZonedDateTime(r)}catch(e){}return n.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 n.ZonedDateTime.from(e)}catch(e){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:t)&&void 0!==u?u:r?$t(r):void 0)&&void 0!==h?h:n.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:n.Now.zonedDateTimeISO(o);return n.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})}},Yt=(e,t,n)=>{const r=Rt(t,n),a={YYYY:e.year.toString(),YY:Ht(e.year%100),MM:Ht(e.month),DD:Ht(e.day),HH:Ht(e.hour),mm:Ht(e.minute)};return r.replace(Ot,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function Ft(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}let Zt=null;function zt(){if("undefined"==typeof document)return!1;if(null!==Zt)return Zt;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(),Zt=r,r}const Ut=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),Wt={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:"df-focus-ring-only",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"df-focus-ring",buttonPrimary:"df-fill-primary df-hover-primary-solid",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:"df-fill-destructive df-hover-destructive",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"},_t=(e,t,n)=>e?t:n,Bt=(...e)=>e.filter(Boolean).join(" "),Vt=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.dataset.dfThemeOverride,t.dataset.dfTheme,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 Gt(e,t=!1){if(e instanceof n.PlainDate||e instanceof n.PlainDateTime)return e;if(e instanceof Date)return t?xe(e):Ee(e);throw new Error("Invalid time type: "+typeof e)}function Kt(e,t){if(e instanceof n.ZonedDateTime)return e;if(e instanceof Date)return Ce(e,t);throw new Error("Invalid time type: "+typeof e)}function qt(e){var t;const n=Gt(e.start,e.allDay),r=Gt(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 Xt(e){const t=Kt(e.start,e.timeZone),n=Kt(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=>qt(e))}function Qt(e){return e.map(e=>Xt(e))}function en(e,t,n,r){return qt(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))}function tn(e,t,n,r,a){return qt(Object.assign({id:e,title:t,start:n,end:r},a))}function nn(e,t,n,r,a=!1,o){return qt(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))}function rn(e,t,n,r,a,o){return Xt(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))}const an=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):Y(e)}catch(e){return new Date}},on=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},ln=(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="df-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}},sn=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=an(e.start),a=on(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 dn=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 cn(e){return String(e).padStart(2,"0")}function un(e,t,r){const a=e.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==t?void 0:t.value)||o.test(a)){const e=a.match(o);if(e)return n.PlainDate.from({year:Number.parseInt(e[1],10),month:Number.parseInt(e[2],10),day:Number.parseInt(e[3],10)})}if(i.test(a)){const e=a.match(i);if(e){const t=n.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),a=r||n.Now.timeZoneId();return t.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const e={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==t?void 0:t.tzid)?n.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:t.tzid})):n.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function hn(e,t=!1){if(t||fe(e)){const t=fe(e)?e:e.toPlainDate();return{value:`${t.year}${cn(t.month)}${cn(t.day)}`,params:{VALUE:"DATE"}}}if(ye(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${cn(t.month)}${cn(t.day)}T${cn(t.hour)}${cn(t.minute)}${cn(t.second)}Z`}}if(pe(e))return{value:`${e.year}${cn(e.month)}${cn(e.day)}T${cn(e.hour)}${cn(e.minute)}${cn(e.second)}`};throw new Error("Unsupported Temporal type")}function gn(e){return`${e.getUTCFullYear()}${cn(e.getUTCMonth()+1)}${cn(e.getUTCDate())}T${cn(e.getUTCHours())}${cn(e.getUTCMinutes())}${cn(e.getUTCSeconds())}Z`}function mn(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function vn(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function fn(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 pn(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,fn(r)}function yn(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:${gn(new Date)}`);const i=hn(e.start,e.allDay);let l;if(e.allDay){const t=(fe(e.end)?e.end:e.end.toPlainDate()).add({days:1});l={value:`${t.year}${cn(t.month)}${cn(t.day)}`,params:{VALUE:"DATE"}}}else l=hn(e.end,!1);if(a.push(pn("DTSTART",i.value,i.params)),a.push(pn("DTEND",l.value,l.params)),a.push(pn("SUMMARY",mn(e.title))),e.description&&a.push(pn("DESCRIPTION",mn(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(pn("LOCATION",mn(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(mn).join(",");a.push(pn("CATEGORIES",t))}return a.push("END:VEVENT"),a}function bn(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 wn(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=vn(a);break;case"DESCRIPTION":t.description=vn(a);break;case"LOCATION":t.location=vn(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=>vn(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=bt()),t}function Dn(e,t){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=t,s=o?`${i}${bt()}`:e.uid,d=un(e.dtstart,e.dtstartParams,l);let c;c=e.dtend?un(e.dtend,e.dtendParams,l):fe(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=e.dtstartParams)||void 0===r?void 0:r.value)||fe(d),h=l||n.Now.timeZoneId();let g,m;if(fe(d))g=d;else if(pe(d))try{g=d.toZonedDateTime(h)}catch(e){g=n.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(fe(c))m=c.subtract({days:1});else if(pe(c))try{m=c.toZonedDateTime(h)}catch(e){m=n.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:e.summary||"(No Title)",description:e.description,start:g,end:m,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}function xn(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=bn(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=Dn(wn(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 En(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:${mn(n)}`];return e.forEach(e=>{a.push(...yn(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}function Cn(e,t={}){const n=En(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 kn(t,n){return e(this,void 0,void 0,function*(){try{const e=yield t.text();if(!e)throw new Error("File content is empty");return xn(e,n)}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}}})}const Tn=e=>{const t=Y(e.start);t.setHours(0,0,0,0);const n=Y(e.end);return n.setHours(0,0,0,0),{startDay:t,endDay:n,isMultiDay:n.getTime()>t.getTime()}},Nn=(e,t)=>e.title.localeCompare(t.title),Sn=(e,t,n)=>{const r=Tn(e),a=Tn(t);if(r.isMultiDay!==a.isMultiDay)return r.isMultiDay?-1:1;if(r.isMultiDay&&a.isMultiDay){const e=r.startDay.getTime()-a.startDay.getTime();if(0!==e)return e;const t=a.endDay.getTime()-r.endDay.getTime();if(0!==t)return t}if(n){const r=n(e,t);if(0!==r)return r}return r.startDay.getTime()-a.startDay.getTime()},Mn=(e,t)=>{const n=new Map;return e.forEach(e=>{const{isMultiDay:t,startDay:r}=Tn(e),a=n.get(e.calendarId);a?t&&(a.hasMultiDay=!0,a.earliestMultiDayStart=Math.min(a.earliestMultiDayStart,r.getTime())):n.set(e.calendarId,{hasMultiDay:t,earliestMultiDayStart:t?r.getTime():Number.POSITIVE_INFINITY})}),(e,r)=>{var a,o,i,l,s,d;const c=n.get(e.calendarId),u=n.get(r.calendarId);if((null!==(a=null==c?void 0:c.hasMultiDay)&&void 0!==a&&a)!==(null!==(o=null==u?void 0:u.hasMultiDay)&&void 0!==o&&o))return(null==c?void 0:c.hasMultiDay)?-1:1;if(null!==(i=null==c?void 0:c.hasMultiDay)&&void 0!==i&&i&&null!==(l=null==u?void 0:u.hasMultiDay)&&void 0!==l&&l&&e.calendarId!==r.calendarId){const e=(null!==(s=null==c?void 0:c.earliestMultiDayStart)&&void 0!==s?s:Number.POSITIVE_INFINITY)-(null!==(d=null==u?void 0:u.earliestMultiDayStart)&&void 0!==d?d:Number.POSITIVE_INFINITY);if(0!==e)return e}return e.calendarId,r.calendarId,Sn(e,r,t)}},In=({wasOriginallyAllDay:e,mouseHour:t,hourOffset:n,duration:r,originalStartHour:a,originalEndHour:o,firstHour:i,lastHour:l,minDuration:s,roundToTimeStep:d})=>{const c=e?1:Math.max(s,r||o-a||1);let u=d(e?t:t+(null!=n?n:0));return u=Math.max(i,Math.min(l-c,u)),{startHour:u,endHour:u+c,duration:c,hourOffset:e?0:null!=n?n:0}};let On=null;const Hn=()=>{const[e,t]=g(()=>On||{weekHeight:H.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return m(()=>{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};On=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},Rn=a({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function An(){return b(Rn)}const Pn="df-month-view h-full flex flex-col select-none",Ln="p-2 flex justify-between",$n="text-2xl font-bold text-gray-900 dark:text-gray-100",jn="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)",Yn="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Fn="flex-1 overflow-auto will-change-scroll overscroll-contain",Zn="df-scrollbar-hide",zn="df-time-slot relative h-[4.5rem] flex",Un="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Wn="df-time-grid-row h-[4.5rem] border-t flex",_n="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",Bn="df-current-time-label ml-2 df-fill-primary text-xs font-bold px-1.5 rounded-sm",Vn="df-all-day-row flex items-center border-b",Gn="rounded-xl my-0.5",Kn="rounded-sm",qn="df-event-title font-medium text-xs truncate pr-1",Xn="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Jn="h-3 w-3 mr-1",Qn="resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",er="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",tr="df-fill-primary rounded-full",nr="df-nav-button df-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",rr="h-4 w-4 transition-transform group-hover:scale-110",ar="df-event-detail-panel df-portal fixed shadow-lg border rounded-lg",or="df-portal 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 df-animate-in df-fade-in df-zoom-in-95",ir="df-time-grid-boundary h-3 border-t relative",lr="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",sr="df-sidebar flex h-full flex-col border-r",dr="df-sidebar-header flex items-center px-2 py-1",cr="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",ur="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",hr="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",gr="text-gray-500 dark:text-gray-400",mr="text-gray-600 dark:text-gray-300",vr="text-xs",fr="text-sm",pr="flex flex-col",yr="mr-1",br=(...e)=>e.filter(Boolean).join(" "),wr=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("path",{d:"m15 18-6-6 6-6"})}),Dr=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("path",{d:"m9 18 6-6-6-6"})}),xr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"m11 17-5-5 5-5"}),Nt("path",{d:"m18 17-5-5 5-5"})]}),Er=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"m6 17 5-5-5-5"}),Nt("path",{d:"m13 17 5-5-5-5"})]}),Cr=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("path",{d:"m6 9 6 6 6-6"})}),kr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"M5 12h14"}),Nt("path",{d:"M12 5v14"})]}),Tr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("circle",{cx:"11",cy:"11",r:"8"}),Nt("path",{d:"m21 21-4.3-4.3"})]}),Nr=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("path",{d:"M20 6 9 17l-5-5"})}),Sr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"m7 15 5 5 5-5"}),Nt("path",{d:"m7 9 5-5 5 5"})]}),Mr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"M18 6 6 18"}),Nt("path",{d:"m6 6 12 12"})]}),Ir=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"M8 2v4"}),Nt("path",{d:"M16 2v4"}),Nt("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Nt("path",{d:"M3 10h18"}),Nt("path",{d:"M8 14h.01"}),Nt("path",{d:"M12 14h.01"}),Nt("path",{d:"M16 14h.01"}),Nt("path",{d:"M8 18h.01"}),Nt("path",{d:"M12 18h.01"}),Nt("path",{d:"M16 18h.01"})]}),Or=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"M18 8L22 12L18 16"}),Nt("path",{d:"M2 12H22"})]}),Hr=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Rr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),Nt("path",{d:"M12 5a3 3 0 1 0-3 3"}),Nt("path",{d:"M12 5a3 3 0 1 1 3 3"}),Nt("path",{d:"M3 12h18"}),Nt("path",{d:"M12 22V8"})]}),Ar=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("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"})}),Pr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),Nt("circle",{cx:"12",cy:"10",r:"3"})]}),Lr=({className:e,width:t=24,height:n=24})=>Nt("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:Nt("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"})}),$r=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),Nt("path",{d:"M15 3v18"}),Nt("path",{d:"m8 9 3 3-3 3"})]}),jr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),Nt("path",{d:"M15 3v18"}),Nt("path",{d:"m10 15-3-3 3-3"})]}),Yr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"m12 19-7-7 7-7"}),Nt("path",{d:"M19 12H5"})]}),Fr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("path",{d:"M4 11a9 9 0 0 1 9 9"}),Nt("path",{d:"M4 4a16 16 0 0 1 16 16"}),Nt("circle",{cx:"5",cy:"19",r:"1"})]}),Zr=({className:e,width:t=24,height:n=24})=>Nt("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:[Nt("circle",{cx:"12",cy:"12",r:"10"}),Nt("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),Nt("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]});function zr(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 Ur(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Wr=(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},_r=(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 Br(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=zr(e,t);if(n)return Ur(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 Vr=({locale:e="en-US",messages:t,children:n})=>{const r=p(()=>{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=p(()=>{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:Br(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:Wr,getMonthLabels:_r,isDefault:!1}},[r,t]);return Nt(Rn.Provider,{value:a,children:n})},Gr=(e,t,n)=>{var r;const a=null===(r=t.state.views.get(e))||void 0===r?void 0:r.label;if(a)return a;const o=n(e);return o!==e?o:e.split(/[-_]/g).map(e=>e?e.charAt(0).toUpperCase()+e.slice(1):e).join(" ")},Kr=({calendar:e,mode:t="buttons"})=>{const[n,r]=g(!1),a=v(null),{t:o}=An(),i=Array.from(e.state.views.keys()),l=e.state.currentView;return m(()=>{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:Nt("div","select"===t?{className:"relative inline-block",ref:a,children:[Nt("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:[Nt("span",{className:"text-gray-900 dark:text-gray-100",children:Gr(l,e,o)}),Nt("span",{className:`${gr} transition-transform duration-200 ${n?"rotate-180":""}`,children:Nt(Cr,{width:16,height:16})})]}),n&&Nt("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 df-animate-in",children:Nt("div",{className:"p-1",role:"listbox",children:i.map(t=>Nt("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?"df-tint-primary font-medium":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:Gr(t,e,o)},t))})}),Nt("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 .df-animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}:{className:"inline-flex h-7 items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:i.map(t=>Nt("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:Gr(t,e,o)},t))})},qr=({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}=Hn(),h="mobile"===u,{t:g}=An(),m=f(e=>{const t=e.currentTarget.value;t!==o&&(null==r||r(t))},[r,o]);return Nt("div",{className:"df-header flex shrink-0 items-center justify-between border-b py-1 pr-2 transition-colors duration-200 "+(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:[Nt("div",{className:"df-header-left flex items-center",children:n&&l&&Nt("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:hr,title:h?g("newEvent")||"New Event":g("createCalendar")||"Add Calendar",children:Nt(kr,{className:`h-4 w-4 ${gr}`})})}),Nt("div",{className:"df-header-mid flex flex-1 items-center justify-center",children:d&&Nt(Kr,{mode:t,calendar:e})}),Nt("div",{className:"df-header-right flex items-center justify-end gap-3",children:[!d&&Nt(Kr,{mode:t,calendar:e}),Nt("button",{type:"button",onClick:a,className:`md:hidden ${hr}`,title:g("search")||"Search",children:Nt(Tr,{width:16,height:16})}),Nt("div",{className:"df-search-group group relative hidden md:block",children:[Nt("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:Nt("span",{className:"df-search-focus-within-primary text-gray-400 transition-colors",children:Nt(Tr,{width:16,height:16})})}),Nt("input",{id:"dayflow-search-input",type:"text",placeholder:g("search")||"Search",value:o,onChange:m,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 df-focus-ring transition resize-none w-48"}),o&&Nt("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:Nt("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Nt("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Nt("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},Xr=a(void 0),Jr=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,a]=g(t),[o,i]=g(()=>"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),l="auto"===r?o:r;m(()=>{a(t)},[t]);const s=f(e=>{a(e)},[]);m(()=>{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)};return e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),y(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Vt(l),n="auto"===r?t:l;e.classList.contains(n)||(e.classList.remove("light","dark"),e.classList.add(n)),"auto"===r?e.dataset.dfThemeOverride&&delete e.dataset.dfThemeOverride:e.dataset.dfThemeOverride!==n&&(e.dataset.dfThemeOverride=n),e.dataset.dfTheme!==n&&(e.dataset.dfTheme=n)},[l,r,o]),m(()=>{n&&n(r,l)},[r,l,n]);const d=p(()=>({theme:r,effectiveTheme:l,setTheme:s}),[r,l,s]);return Nt(Xr.Provider,{value:d,children:e})},Qr=()=>{const e=b(Xr);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},ea=a(null);let ta=0;function na({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const a=v(null),o=b(ea),i=r||o,l=v(null),[,s]=g(0);l.current||(l.current="df-slot-"+ta++),m(()=>{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]),m(()=>{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,u=!!e&&(null==i?void 0:i.isOverridden(e));return Nt("div",{ref:a,className:"df-content-slot "+(d||c?"flex h-full flex-1 flex-col":""),children:!u&&n})}const ra=e=>{const n=v(null),r=v(null);return m(()=>{if(n.current){const a=t(e,[]);r.current=new w(n.current,a),a.initialExpanded&&r.current.expand()}return()=>{r.current&&(r.current.destroy(),r.current=null)}},[]),m(()=>{if(r.current){const n=t(e,[]);r.current.setOptions(n)}},[e]),Nt("div",{ref:n,className:e.className})},aa=({color:e,onChange:t,onClose:n})=>{const r=p(()=>{const{h:t,l:n}=D(e);return{hue:t,saturation:x(n),lightness:n,alpha:100,layer:"outer"}},[e]);return Nt("div",{className:"flex justify-center",children:Nt(ra,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},oa=n=>{var{children:r,onClick:a,loading:i,loadingText:l,disabled:s,className:d,type:c="button"}=n,u=t(n,["children","onClick","loading","loadingText","disabled","className","type"]);const[h,m]=g(!1),v=i||h,f=Nt(o,{children:[v&&Nt("svg",{className:"mr-2 h-4 w-4 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Nt("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Nt("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),Nt("span",{className:"inline-flex items-center",children:v&&l?l:r})]}),p=Object.assign(Object.assign({},u),{disabled:s||v,onClick:t=>e(void 0,void 0,void 0,function*(){if(!v&&a){const e=a(t);if(e&&"object"==typeof e&&"then"in e){m(!0);try{yield e}finally{m(!1)}}}}),className:`relative inline-flex items-center justify-center transition-all ${d} ${v?"cursor-not-allowed opacity-70":""}`});return Nt("button","submit"===c?Object.assign({},p,{type:"submit",children:f}):"reset"===c?Object.assign({},p,{type:"reset",children:f}):Object.assign({},p,{type:"button",children:f}))},ia=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],la=({onClose:t,onCreate:n,app:r})=>{const{t:a}=An(),{effectiveTheme:i}=Qr(),[l,s]=g(""),[d,u]=g(!1),h=r.state.overrides.includes("createCalendarDialogColorPicker"),[m,v]=g(ia[Math.floor(Math.random()*ia.length)]),[f,y]=g(!1),[b,w]=g(""),D=p(()=>{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}},[]),[k,T]=g(null),N=e=>{v(e.hex)},S=()=>{y(!1)},M=()=>{v(b),y(!1)},I="dark"===i,O={default:{picker:{background:I?"#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:I?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:I?"#1e293b":"#ffffff",borderBottom:I?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:I?"#1e293b":"#ffffff"},controls:{border:I?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:I?"#374151":"#ffffff",color:I?"#f3f4f6":"#1f2937",border:I?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:I?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:I?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:c(Nt("div",{className:"df-portal fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:Nt("div",{className:"df-animate-in df-fade-in df-zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-gray-900",onClick:e=>e.stopPropagation(),children:[Nt("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+(h?"mb-4":"mb-6"),children:a("createCalendar")}),Nt("form",{onSubmit:r=>e(void 0,void 0,void 0,function*(){var e;if(r.preventDefault(),l.trim()&&!d){u(!0);try{let r;r=h?m:null!==(e=null==k?void 0:k.hex)&&void 0!==e?e:C(D.hue,D.saturation,D.lightness);const{colors:a,darkColors:o}=le(r),i={id:bt(),name:l.trim(),colors:a,darkColors:o,isVisible:!0,isDefault:!1};yield n(i),t()}finally{u(!1)}}}),children:[h?Nt(o,{children:[Nt("div",{className:"mb-4",children:Nt("div",{className:"flex items-center gap-3",children:[Nt("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:m}}),Nt("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:l,onChange:e=>s(e.target.value),className:"df-focus-ring w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})]})}),Nt("div",{className:"mb-6",children:[Nt("div",{className:"mb-4 grid grid-cols-7 gap-4",children:ia.map(e=>Nt("button",{type:"button",className:"df-focus-ring-only h-7 w-7 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(m===e?"df-ring-primary-solid scale-110 ring-2 ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>v(e)},e))}),Nt("div",{className:"relative",children:[Nt("button",{type:"button",onClick:()=>{w(m),y(!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")}),f&&Nt("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:M,children:Nt("div",{className:"df-animate-in df-fade-in df-zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:Nt(na,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:m,onChange:N,onAccept:S,onCancel:M,styles:O},defaultContent:Nt("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-2xl dark:border-slate-700 dark:bg-gray-900",children:[Nt(aa,{color:m,onChange:N}),Nt("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[Nt("button",{type:"button",onClick:M,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")}),Nt("button",{type:"button",onClick:S,className:"df-fill-primary rounded-md px-3 py-1.5 text-xs font-medium shadow-sm hover:opacity-90",children:"OK"})]})]})})})})]})]})]}):Nt("div",{className:"mb-8 flex items-center gap-4",children:[Nt("div",{className:"flex-1",children:Nt("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:l,onChange:e=>s(e.target.value),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})}),Nt("div",{className:"relative h-9 w-9 shrink-0",children:Nt("div",{className:"absolute inset-0 flex items-center justify-center",children:Nt(ra,{defaultValue:D,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>T(e),onCollapse:e=>T(e),className:"z-50"})})})]}),Nt("div",{className:"flex justify-end space-x-2",children:[Nt("button",{type:"button",onClick:t,disabled:d,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")}),Nt(oa,{type:"submit",disabled:!l.trim(),loading:d,className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition disabled:opacity-50",children:a("create")})]})]})]})}),document.body)},sa=(e,t)=>n.PlainDate.compare(e,t),da=({calendarDays:e,visibleMonth:t,startDate:n,endDate:r,weekDayLabels:a,disabled:i,onDaySelect:l})=>Nt(o,{children:[Nt("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:a.map(e=>Nt("span",{children:e},e))}),Nt("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const a=e.month!==t.month,o=0===sa(e,n),s=0===sa(e,r),d=sa(e,n)>=0&&sa(e,r)<=0;return Nt("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?"df-fill-primary font-semibold":d?"df-tint-primary":a?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 df-hover-primary"}`,children:e.day},e.toString())})})]}),ca=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>Nt("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:[Nt("div",{className:"flex items-center gap-1",children:[Nt("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:Nt(xr,{width:14,height:12})}),Nt("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:Nt(wr,{width:14,height:12})})]}),Nt("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),Nt("div",{className:"flex items-center gap-1",children:[Nt("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:Nt(Dr,{width:14,height:12})}),Nt("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:Nt(Er,{width:14,height:12})})]})]}),ua=Array.from({length:24},(e,t)=>t),ha=Array.from({length:60},(e,t)=>t),ga=({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=ha.includes(s)?ha:[...ha,s].toSorted((e,t)=>e-t);return Nt("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:[Nt("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:Nt("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")]})}),Nt("div",{className:"flex p-1",children:[Nt("div",{className:"w-14",children:Nt("div",{className:`h-72 overflow-y-auto ${Zn} 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:ua.map(e=>{const t=e===l.hour;return Nt("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?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:Ht(e)},e)})})}),Nt("div",{className:"w-14",children:Nt("div",{className:`h-72 overflow-y-auto ${Zn} 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 Nt("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?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:Ht(e)},e)})})})]})]})},ma=({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 Nt("div",{ref:d,className:"df-range-picker",style:p(),"data-range-picker-popup":"true",children:Nt("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:[Nt("div",{className:"flex gap-1",children:[Nt("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:[Nt(ca,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),Nt(da,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&Nt("div",{className:"flex flex-1 justify-end sm:w-32",children:Nt(ga,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),Nt("div",{className:"flex justify-end",children:Nt("button",{type:"button",onClick:f,disabled:l,className:"df-fill-primary df-hover-primary-solid inline-flex items-center rounded-full px-4 py-1.5 text-sm font-semibold shadow-sm transition disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},va=({value:e,format:t="YYYY-MM-DD HH:mm",showTimeFormat:r="HH:mm",showTime:a=!0,onChange:o,onOk:i,timeZone:l,disabled:s=!1,placement:d="bottomLeft",autoAdjustOverflow:u=!0,getPopupContainer:h,matchTriggerWidth:y=!1,locale:b="en-US"})=>{const w=p(()=>"string"==typeof b?b:(null==b?void 0:b.code)||"en-US",[b]),D=p(()=>void 0===a||("object"==typeof a||Boolean(a)),[a]),x=p(()=>_r(w,"short"),[w]),E=p(()=>Wr(w,"narrow"),[w]),C=p(()=>D?"object"==typeof a&&(null==a?void 0:a.format)?a.format:r:"",[D,a,r]),k=p(()=>Rt(t,C),[t,C]),T=p(()=>Pt(k),[k]),N=p(()=>{const t=null!=l?l:P(e[0])?P(e[1])?n.Now.timeZoneId():$t(e[1]):$t(e[0]),r=jt(e[0],t).withTimeZone(t);return[r,jt(e[1],t,r).withTimeZone(t)]},[e,l]),[S,M]=g(N),I=v(N),[O,H]=g("start"),[R,A]=g([Yt(N[0],t,C),Yt(N[1],t,C)]),L=v([Yt(N[0],t,C),Yt(N[1],t,C)]),$=v(N),[j,Y]=g(N[0].toPlainDate().with({day:1})),[F,Z]=g(!1),z=f(e=>{Z(e)},[]),[U,W]=g(d),_=v(d),B=v(null),V=v(null),G=v({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=v(!1),q=v(!1);m(()=>{L.current=R},[R]),m(()=>{$.current=S},[S]),m(()=>{const e=I.current,t=0!==n.ZonedDateTime.compare(e[0],N[0])||e[0].timeZoneId!==N[0].timeZoneId,r=0!==n.ZonedDateTime.compare(e[1],N[1])||e[1].timeZoneId!==N[1].timeZoneId;(t||r)&&M(N),I.current=N},[N]),m(()=>{Y(N[0].toPlainDate().with({day:1}))},[N[0]]);const X=f((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=f(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]);m(()=>{F&&D&&J(O)},[O,F,J,D]);const Q=S[0].epochMilliseconds,ee=S[0].offsetNanoseconds,te=S[1].epochMilliseconds,ne=S[1].offsetNanoseconds;m(()=>{if(q.current)return;const[e,n]=$.current,r=Yt(e,t,C),a=Yt(n,t,C),[o,i]=L.current;o===r&&i===a||(L.current=[r,a],A([r,a]))},[Q,ee,te,ne,t,C]),m(()=>{if(!F)return;const e=e=>{var t,n;const r=e.target;if(null===(t=B.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]")||z(!1)};return document.addEventListener("pointerdown",e,!0),()=>{document.removeEventListener("pointerdown",e,!0)}},[F]),m(()=>{F||(H("start"),K.current||M(N),K.current=!1)},[F,N]);const re=f(e=>{o&&o(e,[Yt(e[0],t,C),Yt(e[1],t,C)])},[C,t,o]),ae=f(e=>{i&&i(e,[Yt(e[0],t,C),Yt(e[1],t,C)])},[C,t,i]),oe=f((e,t)=>{M(r=>{const a=[...r];if("start"===e){const e=jt(a[1],$t(t),t),r=n.ZonedDateTime.compare(t,e)>0?t:e;return[t,r]}const o=jt(a[0],$t(t),t);return[n.ZonedDateTime.compare(o,t)>0?t:o,t]})},[]),ie=e=>{if(s)return;const t=(e,t)=>{var r,a,o,i;const l=$t(e);return n.ZonedDateTime.from({timeZone:l,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=e.nanosecond)&&void 0!==i?i:0})};if("start"===O){const n=t(S[0],e),r=S[1].epochMilliseconds-S[0].epochMilliseconds,a=n.add({milliseconds:r});return void M([n,a])}const r=t(S[1],e),a=S[1].epochMilliseconds-S[0].epochMilliseconds;if(n.ZonedDateTime.compare(r,S[0])<0){const n=t(S[0],e),r=n.add({milliseconds:a});return void M([n,r])}const o=[S[0],r];M(o),Y(r.toPlainDate().with({day:1}))},le=f((e,t)=>{if(s)return;const r="start"===e?0:1;M(a=>{const o=a[r],i=o.with({hour:t,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=jt(a[1],$t(i),i);return[i,n.ZonedDateTime.compare(i,e)>0?i:e]}const l=jt(a[0],$t(i),i);return[n.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&X(t,n,0)})})},[s]),se=f((e,t)=>{if(s)return;const r="start"===e?0:1;M(a=>{const o=a[r].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=jt(a[1],$t(o),o);return[o,n.ZonedDateTime.compare(o,e)>0?o:e]}const i=jt(a[0],$t(o),o);return[n.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&X(t,n,0)})})},[s]),de=f((e,t)=>{const n="start"===e?0:1;A(e=>{const r=[...e];return r[n]=t,r})},[]),ce=f((e,n)=>{const r="start"===e?0:1,a=S[r],o=$t(a),i=Lt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});return Y(t),"start"===e&&H("end"),!0}return A(e=>{const n=[...e];return n[r]=Yt(S[r],t,C),n}),!1},[S,C,t,T,oe]),ue=f(e=>t=>{const n=t.currentTarget.value;q.current=!0,de(e,n);const r="start"===e?0:1,a=$.current[r],o=$t(a),i=Lt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});Y(t),J(e)}},[de,T,oe,J]),he=f(e=>n=>{var r;if(s)return;if(q.current=!1,F){const n="start"===e?0:1,r=Yt($.current[n],t,C);return void A(e=>{const t=[...e];return t[n]=r,t})}const a=n.relatedTarget;a&&(null===(r=B.current)||void 0===r?void 0:r.contains(a))||ce(e,n.currentTarget.value)},[ce,s,F,t,C]),ge=f(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),z(!1)},ve=e=>{Y(t=>t.add({months:e}).with({day:1}))},fe=e=>{Y(t=>t.add({years:e}).with({day:1}))},pe=p(()=>{const e=j,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[j]),ye=f((e=d)=>{if(!u||!B.current)return e;const t=B.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},[u,y,d]),be=f(()=>{const e=ye();_.current!==e&&(_.current=e,W(e))},[ye]),we=e=>{if(s)return;H(e);const t=S["start"===e?0:1].toPlainDate().with({day:1});Y(t);const n=ye();_.current!==n&&(_.current=n,W(n)),z(!0)};m(()=>{if(!F)return;be();const e=()=>be();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[F,be]);const De=()=>{if(!B.current)return{};const e=B.current.getBoundingClientRect(),t={position:"fixed",zIndex:9999};return _.current.startsWith("bottom")?t.top=e.bottom+8:t.bottom=window.innerHeight-e.top+8,d.endsWith("Left")?t.left=e.left:t.right=window.innerWidth-e.right,y&&(t.width=`${e.width}px`),t};return Nt("div",{className:"df-range-picker relative w-full min-w-0",ref:B,children:[Nt("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(s?"cursor-not-allowed border-slate-200 bg-white text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":F?"df-border-primary bg-white shadow-md dark:bg-gray-700":"border-slate-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[Nt("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:Nt("input",{type:"text",name:"range-start",value:R[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 "+(s?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===O&&F?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:s})}),Nt(Or,{className:"text-slate-400 dark:text-gray-500"}),Nt("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:Nt("input",{type:"text",name:"range-end",value:R[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 "+(s?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===O&&F?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:s})})]}),F&&c(Nt(ma,{visibleMonth:j,monthLabels:x,weekDayLabels:E,calendarDays:pe,draftRange:S,focusedField:O,isTimeEnabled:!!D,disabled:s,matchTriggerWidth:y,popupRef:V,timeListRefs:G,onMonthChange:ve,onYearChange:fe,onDaySelect:ie,onHourSelect:le,onMinuteSelect:se,onOk:me,getPopupStyle:De}),h?h():document.body)]})},fa=({options:e,value:t,onChange:n,registry:r,variant:a="desktop",disabled:o=!1})=>{const[i,l]=g(!1),[s,d]=g({}),u=v(null),h=v(null),f=()=>{if(h.current){const e=h.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`,d(n)}};m(()=>{const e=e=>{!u.current||u.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||ie()).resolveColors(e).lineColor,y=(e,t)=>{e.stopPropagation(),n(t),l(!1)},b=e.find(e=>e.value===t),w=()=>i&&"undefined"!=typeof window?c("mobile"===a?Nt("div",{"data-calendar-picker-dropdown":"true",style:s,className:or,children:e.map(e=>Nt("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:[Nt("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[Nt("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&Nt(Nr,{className:"df-text-primary h-4 w-4"})}),Nt("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),Nt("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}):Nt("ul",{"data-calendar-picker-dropdown":"true",style:s,className:"df-portal df-animate-in df-fade-in df-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=>Nt("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?Nt("span",{className:"df-text-primary mr-2 text-sm",children:Nt(Nr,{width:12,height:12})}):Nt("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),Nt("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),Nt("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return Nt("div","mobile"===a?{className:"relative inline-block",ref:u,children:[Nt("button",{type:"button",ref:h,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:[Nt("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),Nt("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==b?void 0:b.label)||t}),Nt(Sr,{className:"h-4 w-4 text-gray-400"})]}),w()]}:{className:"relative inline-block",ref:u,children:[Nt("button",{ref:h,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:[Nt("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),Nt(Sr,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),w()]})},pa=({event:t,isOpen:r,onEventUpdate:a,onEventDelete:o,onClose:i,app:l})=>{var s,d;const[u,h]=g(t),[f,y]=g(!1),[b,w]=g(!1),D=v(t.id),{t:x}=An();m(()=>{h(t),D.current!==t.id&&(y(!1),w(!1),D.current=t.id)},[t]);const E=p(()=>(l?l.getCalendarRegistry():ie()).getVisible().map(e=>({label:e.name,value:e.id})),[l,null==l?void 0:l.getCalendars()]),C=p(()=>!ft(t,u),[t,u]),k=p(()=>{var e;return null!==(e=null==l?void 0:l.timeZone)&&void 0!==e?e:n.Now.timeZoneId()},[l]),T=e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t.toPlainDate(),end:n.toPlainDate()}))},N=null!==(s=null==l?void 0:l.canMutateFromUI(t.id))&&void 0!==s&&s,S=null==l?void 0:l.getReadOnlyConfig(t.id),M=!1!==(null==S?void 0:S.viewable),I=f||b,O=!p(()=>{if(!t.calendarId)return!1;const e=null==l?void 0:l.getCalendarRegistry().get(t.calendarId);return!!(null==e?void 0:e.subscription)},[l,t.calendarId])||""!==(u.description||"").trim();if(!r||!M)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const H=Nt("div",{className:"df-portal fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[Nt("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&&i()}}),Nt("div",{className:"df-dialog-container relative shadow-2xl border rounded-lg p-6 max-w-md w-full mx-4",children:[Nt("button",{type:"button",onClick:i,disabled:I,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 disabled:opacity-50 dark:text-gray-500 dark:hover:text-gray-200","aria-label":"Close",children:Nt("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:Nt("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),Nt("div",{children:[Nt("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("eventTitle")}),Nt("div",{className:"mb-4 flex items-center justify-between gap-3",children:[Nt("div",{className:"flex-1",children:Nt("input",{id:`event-dialog-title-${u.id}`,name:"title",type:"text",value:u.title,readOnly:!N||I,disabled:!N||I,onChange:e=>{h(Object.assign(Object.assign({},u),{title:e.target.value}))},className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),N&&Nt(fa,{options:E,value:u.calendarId||"blue",disabled:I,onChange:e=>{h(Object.assign(Object.assign({},u),{calendarId:e}))},registry:null==l?void 0:l.getCalendarRegistry()})]}),u.allDay?Nt("div",{className:"mb-4",children:[Nt("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("dateRange")}),Nt(va,{value:[u.start,u.end],format:"YYYY-MM-DD",showTime:!1,timeZone:k,matchTriggerWidth:!0,disabled:!N||I,onChange:T,onOk:T,locale:null==l?void 0:l.state.locale})]}):Nt("div",{className:"mb-4",children:[Nt("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("timeRange")}),Nt(va,{value:[u.start,u.end],timeZone:k,disabled:!N||I,onChange:e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t,end:n}))},onOk:e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t,end:n}))},locale:null==l?void 0:l.state.locale})]}),O&&Nt("div",{className:"mb-4",children:[Nt("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("note")}),Nt("textarea",{id:`event-dialog-note-${u.id}`,name:"note",value:null!==(d=u.description)&&void 0!==d?d:"",readOnly:!N||I,disabled:!N||I,onChange:e=>h(Object.assign(Object.assign({},u),{description:e.target.value})),rows:4,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:x("addNotePlaceholder")})]}),N&&Nt("div",{className:"flex space-x-2",children:[u.allDay?Nt("button",{type:"button",disabled:I,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{var e;const t=P(u.start)?u.start:u.start.toPlainDate(),r=null!==(e=null==l?void 0:l.timeZone)&&void 0!==e?e:n.Now.timeZoneId(),a=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:r}),o=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:r});h(Object.assign(Object.assign({},u),{allDay:!1,start:a,end:o}))},children:x("setAsTimed")}):Nt("button",{type:"button",disabled:I,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{const e=P(u.start)?u.start:u.start.toPlainDate();h(Object.assign(Object.assign({},u),{allDay:!0,start:e,end:e}))},children:x("setAsAllDay")}),Nt(oa,{type:"button",disabled:I,className:"df-fill-destructive df-hover-destructive rounded-lg border border-border px-3 py-2 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>e(void 0,void 0,void 0,function*(){if(!f&&!b){w(!0);try{yield o(t.id),i()}finally{w(!1)}}}),loading:b,children:x("delete")}),Nt(oa,{type:"button",className:"df-fill-primary ml-auto rounded-lg px-3 py-2 text-xs font-medium transition "+(C?"df-shadow-primary df-hover-primary-solid shadow-lg":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>e(void 0,void 0,void 0,function*(){if(!f&&!b){y(!0);try{yield a(Ue(t,u,null==l?void 0:l.timeZone)),i()}finally{y(!1)}}}),disabled:!C||I,loading:f,children:x("save")})]})]})]})]}),R=document.body;return R?c(H,R):null},ya=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),ba=({app:e,anchorRef:t,onClose:n,isOpen:r})=>{const{t:a}=An(),[o,i]=g(""),[l,s]=g(0),[d,u]=g(!1),h=v(null),f=v(null);m(()=>{r||u(!1)},[r]),m(()=>{r&&(setTimeout(()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.focus()},50),i(""),s(0))},[r]),m(()=>{const e=e=>{r&&f.current&&!f.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]=g({top:0,left:0}),[D,x]=g("top"),[E,C]=g(0),k=p(()=>Ze(e.timeZone),[e.timeZone,r]),T=p(()=>{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]);y(()=>{if(r&&t.current&&f.current){const e=t.current.getBoundingClientRect(),n=f.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}),u(!0)}},[r,t,T]);const N=t=>{if(!t.calendarId)return;const r=bt(),a={id:r,title:t.title,start:Ce(t.start,e.timeZone),end:Ce(t.end,e.timeZone),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return m(()=>{if(!r)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),s(e=>(e+1)%T.length)):"ArrowUp"===e.key?(e.preventDefault(),s(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?c(Nt("div",{ref:f,className:"df-portal 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 "+(d?"df-animate-in df-fade-in df-zoom-in-95 duration-100":""),style:{top:b.top,left:b.left,visibility:d?"visible":"hidden"},children:[Nt("div",{className:"p-4 pb-2",children:[Nt("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:a("quickCreateEvent")||"Quick Create Event"}),Nt("div",{className:"relative",children:Nt("input",{ref:h,type:"text",className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 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)})})]}),Nt("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===T.length&&o&&Nt("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:a("noSuggestions")||"Type to create"}),T.map((e,t)=>{return Nt("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===l?"df-tint-primary df-dark-tint-primary-md df-ring-primary ring-1 ring-inset":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>N(e),onMouseEnter:()=>s(t),children:[Nt("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),Nt("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Nt("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),Nt("div",{className:"flex",children:Nt("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")})}),Nt("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${ya(n)} - ${ya(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),Nt("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},wa=({visibleMonth:e,currentDate:t,showHeader:r=!1,onMonthChange:a,onDateSelect:o,events:i=[],showEventDots:l=!1,calendarRegistry:s,timeZone:d})=>{const{locale:c}=An(),u=p(()=>{const e=d?n.Now.plainDateISO(d):n.Now.plainDateISO();return new Date(e.year,e.month-1,e.day).toDateString()},[d]),h=t.toDateString(),g=p(()=>Wr(c,"narrow"),[c]),m=p(()=>e.toLocaleDateString(c,{month:"long",year:"numeric"}),[e,c]),v=p(()=>{if(!l||!(null==i?void 0:i.length))return null;const e=new Map;return i.forEach(t=>{var n;const r=we(t.start,d),a=t.end?we(t.end,d):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(!t.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 c=ue(t.calendarId||"default",s).toLowerCase();for(let t=new Date(o);t<=l;t=new Date(t.getTime()+864e5)){const r=t.toDateString(),a=null!==(n=e.get(r))&&void 0!==n?n:[];!a.includes(c)&&a.length<4&&e.set(r,[...a,c])}}),e},[l,i,d,s]),f=p(()=>{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),i=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:i===u,isSelected:i===h})}return a},[e,h,u]);return Nt("div",{className:"px-3 py-3",children:[r?Nt("div",{className:"mb-3 flex items-center justify-between",children:[Nt("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:()=>a(-1),"aria-label":"Previous month",children:Nt(wr,{className:"h-4 w-4"})}),Nt("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:m}),Nt("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:()=>a(1),"aria-label":"Next month",children:Nt(Dr,{className:"h-4 w-4"})})]}):"",Nt("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[g.map((e,t)=>Nt("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}`)),f.map(e=>{var t;const n=null!==(t=null==v?void 0:v.get(e.fullDate.toDateString()))&&void 0!==t?t:[];return Nt("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?tr:e.isSelected?"df-fill-secondary rounded-full font-medium":e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} relative flex flex-col items-center justify-center pt-1 pb-1`,onClick:()=>o(e.fullDate),children:[Nt("span",{className:"z-10",children:e.date}),l&&n.length>0&&Nt("div",{className:"absolute bottom-0.5 flex gap-px",children:n.slice(0,4).map((e,t)=>Nt("div",{"data-mini-calendar-dot":"true",className:"h-1 w-1 rounded-full",style:{backgroundColor:e}},`${e}-${t}`))})]},e.fullDate.getTime())})]})]})},Da=({checked:e,onChange:t,disabled:n})=>Nt("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:Nt("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),xa=({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,[u,h]=g(d),[f,p]=g(c),y=v(null),b=v(null),w=v(null);m(()=>{y.current&&(y.current.scrollTop=d,h(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),h(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 Nt("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[Nt("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),Nt("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:[Nt("div",{style:{height:96}}),a.map((n,r)=>Nt("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:Nt("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,u),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),Nt("div",{style:{height:96}})]}),Nt("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:[Nt("div",{style:{height:96}}),o.map((n,r)=>Nt("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:Nt("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}`)),Nt("div",{style:{height:96}})]}),Nt("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"})]})},Ea=({isOpen:e,onClose:t,onSave:n,onEventDelete:r,draftEvent:a,app:o,timeFormat:i="24h"})=>{const{locale:l,t:s}=An(),d=o.getReadOnlyConfig(null==a?void 0:a.id),u=o.canMutateFromUI(null==a?void 0:a.id),h=!1!==d.viewable,[v,f]=g(""),y=!p(()=>{if(!(null==a?void 0:a.calendarId))return!1;const e=o.getCalendarRegistry().get(a.calendarId);return!!(null==e?void 0:e.subscription)},[o,null==a?void 0:a.calendarId])||""!==v.trim(),[b,w]=g(""),[D,x]=g(""),[E,C]=g(!1),[k,T]=g(new Date),[N,S]=g(new Date),[M,I]=g(new Date),[O,H]=g(new Date),[R,A]=g(null),[P,L]=g(e),[j,F]=g(!1),[Z,z]=g(!1);m(()=>{if(!e){F(!0);const e=setTimeout(()=>{L(!1),F(!1)},300);return()=>clearTimeout(e)}L(!0),F(!1)},[e]),m(()=>{if(e&&a){const e=o.getEvents().some(e=>e.id===a.id);z(e)}},[e,a,o]);const U=o.getCalendars(),W=U.map(e=>({label:e.name,value:e.id}));m(()=>{if(e&&U.length>0){U.some(e=>e.id===D)||"blue"!==D&&""!==D||x(U[0].id)}},[U,e,D]),m(()=>(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]),m(()=>{var t,n;if(e&&a){if(w(a.title||""),x(a.calendarId||(null===(t=U[0])||void 0===t?void 0:t.id)||"blue"),C(a.allDay||!1),a.start)try{const e=Y(a.start);T(e),I(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;T(t),I(t)}if(a.end)try{const e=Y(a.end);S(e),H(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;S(t),H(t)}}else if(e&&!a){x((null===(n=U[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),T(e),I(e),S(new Date(e.getTime()+36e5)),H(e)}},[e,a]);const _=p(()=>{if(!e||!a)return!1;const t=new Date(k),n=new Date(N),r=Object.assign(Object.assign({},a),{title:b,calendarId:D,allDay:E,description:v,start:E?xe(t):$(t,o.timeZone),end:E?xe(n):$(n,o.timeZone)});return!ft(a,Ue(a,r,o.timeZone))},[e,a,b,D,E,k,N,v]);if(!P||!h)return null;const B=e=>{A(t=>t===e?null:e)},V=e=>e.toLocaleDateString(l,{day:"numeric",month:"short",year:"numeric"}),G=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(k.getHours(),k.getMinutes());const n=e.getTime()-k.getTime();T(e);const r=new Date(N.getTime()+n);S(r)}else{const e=new Date(t);e.setHours(N.getHours(),N.getMinutes()),S(e)}},K=(e,t)=>{"start"===e?I(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 c(Nt("div",{className:"df-portal pointer-events-none fixed inset-0 z-10000 flex items-end",children:[Nt("div",{className:"pointer-events-auto absolute inset-0 bg-black/30 transition-opacity duration-300 "+(j?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),Nt("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 "+(j?"df-animate-slide-down":"df-animate-slide-up"),onClick:e=>e.stopPropagation(),children:[Nt("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:[Nt("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:s("cancel")}),Nt("span",{className:"text-lg font-semibold",children:s(!u&&Z?"viewEvent":Z?"editEvent":"newEvent")}),u&&Nt("button",{type:"button",onClick:()=>{if(!a)return;const e=new Date(k),t=new Date(N),r=Object.assign(Object.assign({},a),{title:b,calendarId:D,allDay:E,start:E?xe(e):$(e,o.timeZone),end:E?xe(t):$(t,o.timeZone)});n(Ue(a,r,o.timeZone))},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"df-text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:s(Z?"done":"create")}),!u&&Nt("span",{className:"w-12"})]}),Nt("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[Nt("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:Nt("input",{type:"text",placeholder:s("titlePlaceholder"),value:b,onChange:e=>u&&w(e.currentTarget.value),readOnly:!u,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:u})}),U.length>0&&Nt("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[Nt("span",{className:"text-gray-700 dark:text-gray-300",children:s("calendar")}),Nt(fa,{options:W,value:D,onChange:u?x:()=>{},registry:o.getCalendarRegistry(),variant:"mobile",disabled:!u})]}),Nt("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[Nt("span",{className:"text-gray-700 dark:text-gray-300",children:s("allDay")}),Nt(Da,{checked:E,onChange:u?C:()=>{},disabled:!u})]}),Nt("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[Nt("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[Nt("span",{className:"text-gray-700 dark:text-gray-300",children:s("starts")}),Nt("div",{className:"flex space-x-2",children:[Nt("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-date"===R?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("start-date"),disabled:!u,children:V(k)}),!E&&Nt("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===R?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("start-time"),disabled:!u,children:Re(k.getHours()+k.getMinutes()/60,0,i)})]})]}),Nt("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===R?"max-h-100":"max-h-0"),children:Nt("div",{className:"",children:Nt(wa,{currentDate:k,visibleMonth:M,onDateSelect:e=>G("start",e),onMonthChange:e=>K("start",e),showHeader:!0,events:o.getEvents(),calendarRegistry:o.getCalendarRegistry(),timeZone:o.timeZone})})}),Nt("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===R?"max-h-75":"max-h-0"),children:Nt("div",{className:"",children:Nt(xa,{date:k,onChange:e=>{const t=N.getTime()-k.getTime();T(e),S(new Date(e.getTime()+t))},timeFormat:i})})})]}),Nt("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[Nt("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[Nt("span",{className:"text-gray-700 dark:text-gray-300",children:s("ends")}),Nt("div",{className:"flex space-x-2",children:[Nt("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-date"===R?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("end-date"),disabled:!u,children:V(N)}),!E&&Nt("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===R?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("end-time"),disabled:!u,children:Re(N.getHours()+N.getMinutes()/60,0,i)})]})]}),Nt("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===R?"max-h-100":"max-h-0"),children:Nt("div",{className:"",children:Nt(wa,{currentDate:N,visibleMonth:O,onDateSelect:e=>G("end",e),onMonthChange:e=>K("end",e),showHeader:!0,events:o.getEvents(),calendarRegistry:o.getCalendarRegistry(),timeZone:o.timeZone})})}),Nt("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===R?"max-h-75":"max-h-0"),children:Nt("div",{className:"",children:Nt(xa,{date:N,onChange:e=>{if(e<k){const t=N.getTime()-k.getTime();S(e),T(new Date(e.getTime()-t))}else S(e)},timeFormat:i})})})]}),y&&Nt("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:Nt("textarea",{placeholder:s("notesPlaceholder"),value:v,onChange:e=>u&&f(e.currentTarget.value),readOnly:!u,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),u&&Z&&r&&a&&Nt("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:s("delete")})]})]})]}),document.body)},Ca=()=>Nt("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Nt("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ka=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:a})=>{const{t:o,locale:i}=An(),l=p(()=>on(new Date),[]),s=p(()=>sn(t,l),[t,l]),d=e=>an(e);return e?Nt("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[Nt(Hr,{className:"mb-2 h-8 w-8 animate-spin"}),Nt("span",{children:"Loading..."})]}):0===t.length?n?Nt("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[Nt(Ca,{}),Nt("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:Nt("div",{className:"space-y-6",children:s.map(e=>{const{title:t,colorClass:n}=ln(e.date,l,i,o);return Nt("div",{children:[Nt("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}),Nt("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 Nt("div",{children:[Nt("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:Nt("div",{className:"flex items-stretch gap-3",children:[Nt("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),Nt("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[Nt("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),Nt("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[Nt("div",{className:"text-black dark:text-white",children:l}),s&&Nt("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),Nt("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},Ta=({isOpen:e,onClose:t,keyword:n,onSearchChange:r,results:a,loading:o,onResultClick:i,emptyText:l})=>{const s=v(null),{t:d}=An();return m(()=>(e?(setTimeout(()=>{var e;null===(e=s.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?c(Nt("div",{className:"df-portal fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[Nt("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[Nt("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:Nt(Yr,{className:"h-6 w-6"})}),Nt("div",{className:"relative flex-1",children:[Nt("input",{ref:s,type:"text",placeholder:d("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&r(t)},className:"df-focus-ring-only w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&Nt("button",{type:"button",onClick:()=>{""!==n&&r("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:Nt(Mr,{className:"h-4 w-4"})})]})]}),Nt("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:Nt(ka,{loading:o,results:a,keyword:n,onResultClick:e=>{null==i||i(e)},emptyText:l})})]}),document.body):null},Na=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>Nt("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:Nt("div",{className:"min-w-64 flex-1 overflow-y-auto",children:Nt(ka,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let Sa=null;function Ma(e){Sa=e}const Ia={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Oa(e){return Sa&&e.hasPlugin("sidebar")?Sa(e):Ia}const Ha=({locale:e,messages:t,children:n})=>An().isDefault?Nt(Vr,{locale:e,messages:t,children:n}):n,Ra=({app:t,customDetailPanelContent:n,customEventDetailDialog:r,meta:a,customMessages:o,search:l,titleBarSlot:s,collapsedSafeAreaLeft:d})=>{const u=b(ea),{tick:h,selectedEventId:y}=function(e){const[t,n]=g(0),[r,a]=g(null);return m(()=>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}}(t),{isMobile:w}=function(){const[e,t]=g(!1);return m(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),D=function(t,n){const[r,a]=g(""),[o,i]=g(!1),[l,s]=g(!1),[d,c]=g(!1),[u,h]=g([]),p=v(""),y=v(!1);m(()=>{t.state.highlightedEventId&&t.selectEvent(t.state.highlightedEventId)},[t.state.highlightedEventId,t]),m(()=>{y.current&&!o&&null!==t.state.highlightedEventId&&t.highlightEvent(null),y.current=o},[o,t]),m(()=>{var a;if(!r.trim())return i(!1),h([]),p.current.trim()&&null!==t.state.highlightedEventId&&t.highlightEvent(null),void(p.current=r);const o=null!==(a=null==n?void 0:n.debounceDelay)&&void 0!==a?a:300,l=setTimeout(()=>e(this,void 0,void 0,function*(){var e;c(!0),i(!0);try{let a=[];if(null==n?void 0:n.customSearch){const e=t.getEvents().map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})});a=n.customSearch({keyword:r,events:e})}else if(null==n?void 0:n.onSearch)a=yield n.onSearch(r);else{const e=r.toLowerCase();a=t.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})})}h(a),null===(e=null==n?void 0:n.onSearchStateChange)||void 0===e||e.call(n,{keyword:r,loading:!1,results:a})}catch(e){console.error("Search failed",e),h([])}finally{c(!1)}}),o);return p.current=r,()=>clearTimeout(l)},[r,n,t]);const b=f((e,r="desktop")=>{const a=()=>{let n;n=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):Y(e.start),t.setCurrentDate(n),t.highlightEvent(e.id),l&&s(!1)},o=()=>{"mobile"===r?s(!1):i(!1),t.highlightEvent(null)};(null==n?void 0:n.onResultClick)?n.onResultClick({event:e,app:t,source:r,defaultAction:a,closeSearch:o}):a()},[t,l,n]),w=f(()=>{a(""),s(!0)},[]),D=f(()=>{i(!1),a(""),t.highlightEvent(null)},[t]),x=f(()=>{s(!1),a(""),t.highlightEvent(null)},[t]);return{searchKeyword:r,setSearchKeyword:a,isSearchOpen:o,setIsSearchOpen:i,isMobileSearchOpen:l,setIsMobileSearchOpen:s,searchLoading:d,searchResults:u,handleSearchResultClick:b,handleSearchClick:w,handleSearchClose:D,handleMobileSearchClose:x}}(t,l),x=r||(t.getUseEventDetailDialog()?pa:void 0),E=function(t,n,r){const[a,o]=g(null),i=v(null);m(()=>{o(null),i.current=null},[t]);const l=f(()=>{o(null),i.current=null,t.selectEvent(null)},[t]),s=f(e=>t.updateEvent(e.id,e),[t]),d=f(n=>e(this,void 0,void 0,function*(){yield t.deleteEvent(n),o(null),t.selectEvent(null)}),[t]),c=p(()=>{var e;if(!n||!a)return null;const r=a.split("::")[0],o=t.getEvents().find(e=>e.id===r);o&&(i.current=o);const c=null!=o?o:(null===(e=i.current)||void 0===e?void 0:e.id)===r?i.current:null;return c?{event:c,isOpen:!0,isAllDay:P(c.start),onEventUpdate:s,onEventDelete:d,onClose:l,app:t}:null},[r,a,n,l,s,d,t]);return{detailPanelEventId:a,setDetailPanelEventId:o,dialogProps:c}}(t,x,h),C=Oa(t),k=function(e,t,n){const[r,a]=g(!1),o=v(null),[i,l]=g(!1),[s,d]=g(null),[c,u]=g(!1),h=f(()=>{u(!0)},[]),m=f(i=>{var s,c;if(e.canMutateFromUI()){if(t){const{start:t,end:n}=Ze(e.timeZone),r={id:bt(),title:"",start:Ce(t,e.timeZone),end:Ce(n,e.timeZone),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)):h()}},[t,r,e,n,h]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:a,quickCreateAnchorRef:o,isMobileDrawerOpen:i,setIsMobileDrawerOpen:l,mobileDraftEvent:s,setMobileDraftEvent:d,handleAddButtonClick:m,isCreateCalendarOpen:c,setIsCreateCalendarOpen:u}}(t,w,C.enabled),[T,N]=g(()=>t.getTheme());m(()=>t.subscribeThemeChange(e=>N(e)),[t]);const S=f(e=>t.setTheme(e),[t]);m(()=>{const e=t.callbacks,n=e.onDismissUI;return e.onDismissUI=()=>{E.detailPanelEventId&&E.setDetailPanelEventId(null),k.isMobileDrawerOpen&&k.setIsMobileDrawerOpen(!1),null==n||n()},()=>{e.onDismissUI=n}},[t,E,k]),m(()=>{if(!w||!E.detailPanelEventId)return;const e=E.detailPanelEventId.split("::")[0],n=t.getEvents().find(t=>t.id===e);n&&(k.setMobileDraftEvent(n),k.setIsMobileDrawerOpen(!0)),E.setDetailPanelEventId(null)},[E.detailPanelEventId,w]);const M=f(e=>{t.setCurrentDate(e),t.selectEvent(null)},[t]),I=f(e=>t.selectEvent(e),[t]),O=v(null),H={app:t,config:t.getCurrentView().config||{},customDetailPanelContent:n,customEventDetailDialog:x,switcherMode:t.state.switcherMode,calendarRef:O,meta:a,selectedEventId:y,onEventSelect:I,onDateChange:M,detailPanelEventId:E.detailPanelEventId,onDetailPanelToggle:E.setDetailPanelEventId},R=p(()=>({isCollapsed:C.isCollapsed,toggleCollapsed:C.toggleCollapsed}),[C.isCollapsed,C.toggleCollapsed]),A=void 0!==d,L=A?"0px":C.miniWidth,$=A&&C.isCollapsed?d:C.safeAreaLeft,j=t.getCalendarHeaderConfig(),F=Object.assign({calendar:t,switcherMode:t.state.switcherMode,onAddCalendar:k.handleAddButtonClick,onSearchChange:D.setSearchKeyword,onSearchClick:D.handleSearchClick,searchValue:D.searchKeyword,isSearchOpen:D.isSearchOpen,isEditable:t.canMutateFromUI()},$>0?{safeAreaLeft:$}:{}),Z=t.getCurrentView().component,z=t.getCustomMobileEventRenderer()||Ea;return Nt(Jr,{initialTheme:T,onThemeChange:S,children:Nt(Ha,{locale:t.state.locale,messages:o,children:Nt("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[Nt(na,{store:u,generatorName:"titleBarSlot",generatorArgs:R,defaultContent:s&&("function"==typeof s?s(R):s)}),C.enabled&&Nt("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:C.width},children:C.content}),Nt("div",{className:"relative z-10 flex h-full flex-1 flex-col overflow-hidden border-l bg-white transition-all duration-200 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?L:C.width:0},children:[!1===j?null:Nt(na,{store:u,generatorName:"calendarHeader",generatorArgs:F,defaultContent:i(qr,F)}),Nt("div",{className:"relative flex-1 overflow-hidden",ref:O,children:[Nt("div",{className:"calendar-renderer relative flex h-full flex-row",children:[Nt("div",{className:"h-full flex-1 overflow-hidden",children:Nt(Z,Object.assign({},H))}),Nt(Na,{isOpen:D.isSearchOpen,onClose:D.handleSearchClose,loading:D.searchLoading,results:D.searchResults,keyword:D.searchKeyword,onResultClick:e=>D.handleSearchResultClick(e,"desktop"),emptyText:null==l?void 0:l.emptyText})]}),Nt(Ta,{isOpen:D.isMobileSearchOpen,onClose:D.handleMobileSearchClose,keyword:D.searchKeyword,onSearchChange:D.setSearchKeyword,results:D.searchResults,loading:D.searchLoading,onResultClick:e=>D.handleSearchResultClick(e,"mobile"),emptyText:null==l?void 0:l.emptyText})]})]}),Nt(ba,{app:t,anchorRef:k.quickCreateAnchorRef,isOpen:k.isQuickCreateOpen,onClose:()=>k.setIsQuickCreateOpen(!1)}),Nt(z,{isOpen:k.isMobileDrawerOpen,onClose:()=>{k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onSave:e=>{t.getEvents().some(t=>t.id===e.id)?t.updateEvent(e.id,e):t.addEvent(e),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onEventDelete:e=>{t.deleteEvent(e),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},draftEvent:k.mobileDraftEvent,app:t}),C.extraContent,k.isCreateCalendarOpen&&Nt(la,{app:t,onClose:()=>k.setIsCreateCalendarOpen(!1),onCreate:n=>e(void 0,void 0,void 0,function*(){yield t.createCalendar(n),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==u?void 0:u.isOverridden("eventDetailDialog");return Nt(na,{store:u,generatorName:"eventDetailDialog",generatorArgs:E.dialogProps,defaultContent:n?null:c(i(e,E.dialogProps),t)})})()]})})})};class Aa{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 Pa{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new Aa(t),t&&this.app.setOverrides(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){wt(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.render()}unmount(){this.container&&(l(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&l(i(ea.Provider,{value:this.customRenderingStore},i(Ra,Object.assign({app:this.app},this.extraProps))),this.container)}}function La(t){return e(this,void 0,void 0,function*(){const e=yield fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=yield e.text(),r=xn(n),a=n.match(/X-WR-CALNAME[^:]*:([^\r\n]+)/),o=a?a[1].trim():new URL(t).hostname,i=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],l=i[Math.floor(Math.random()*i.length)],{colors:s,darkColors:d}=le(l);return{calendar:{id:bt(),name:o,isVisible:!0,colors:s,darkColors:d,subscription:{url:t,status:"ready"}},events:r.events}})}const $a=u(({x:e,y:t,onClose:n,children:r,className:a},o)=>{const i=v(null);m(()=>{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 c(Nt("div",{ref:e=>{i.current=e,"function"==typeof o?o(e):o&&"current"in o&&(o.current=e)},className:`df-portal df-animate-in df-fade-in df-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)});$a.displayName="ContextMenu";const ja=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>Nt("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-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)]"} ${r?"df-text-destructive df-hover-fill-destructive df-focus-fill-destructive":"text-[var(--df-color-foreground)]"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&Nt("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Ya=()=>Nt("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Fa=({children:e})=>Nt("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),Za=({children:e})=>{const[t,n]=g(!1),r=v(null);return m(()=>()=>{r.current&&clearTimeout(r.current)},[]),Nt("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=>s(e)?d(e,{isOpen:t}):e)})},za=({children:e,icon:t,isOpen:n})=>Nt("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors outline-none select-none hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)] "+(n?"bg-[var(--df-color-primary)] text-[var(--df-color-primary-foreground)]":""),children:[t&&Nt("span",{className:"mr-2 h-4 w-4",children:t}),Nt("span",{className:"grow text-left",children:e}),Nt(Dr,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),Ua=({children:e,isOpen:t})=>{const n=v(null),[r,a]=g("right");return m(()=>{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?Nt("div",{ref:n,className:"df-portal df-animate-in df-fade-in df-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},Wa=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],_a=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=An();return Nt("div",{children:[Nt("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:Wa.map(n=>Nt("button",{type:"button",className:"df-focus-ring-only h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 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()?"df-ring-primary-solid ring-2 ring-offset-1 dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&Nt("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)]",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},Ba=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:i,viewType:l})=>{const{t:s}=An();if(!o.canMutateFromUI())return null;const d=dn.hasEvent();return Nt($a,{x:t,y:n,onClose:a,className:"df-context-menu",children:[Nt(ja,{onClick:()=>{i(),a()},children:s("newEvent")||"New Event"}),Nt(ja,{onClick:()=>e(void 0,void 0,void 0,function*(){yield((t,n,r)=>e(void 0,void 0,void 0,function*(){if(dn.hasEvent())try{let e=dn.getEvent();if(!e){const t=yield navigator.clipboard.readText();t&&(e=JSON.parse(t))}if(e&&"object"==typeof e&&"title"in e){const a=e,o=be(a.start),i=be(a.end).getTime()-o.getTime(),l=e,s=new Date(n),d=r===I.MONTH||r===I.YEAR,c=0===s.getHours()&&0===s.getMinutes(),u=0!==o.getHours()||0!==o.getMinutes();!a.allDay&&(d||c&&u)&&s.setHours(o.getHours(),o.getMinutes(),o.getSeconds(),o.getMilliseconds());const h=new Date(s.getTime()+(i>0?i:36e5)),g=Object.assign(Object.assign({},l),{title:a.title,id:bt(),start:a.allDay?xe(s):Ce(s,t.timeZone),end:a.allDay?xe(h):Ce(h,t.timeZone),calendarId:a.calendarId&&t.getCalendarRegistry().has(a.calendarId)?a.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(g)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,l),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},Va=({event:t,x:n,y:r,onClose:a,app:i})=>{var l;const{t:s}=An();if(!i.canMutateFromUI(t.id))return null;const d=i.getCalendars(),c=i.callbacks,u=null===(l=null==c?void 0:c.renderEventContextMenu)||void 0===l?void 0:l.call(c,t,a);return Nt($a,{x:n,y:r,onClose:a,children:[Nt(Za,{children:[Nt(za,{children:s("calendars")||"Calendars"}),Nt(Ua,{children:d.map(e=>{const n=e.id===t.calendarId;return Nt(ja,{onClick:()=>{return n=e.id,i.updateEvent(t.id,{calendarId:n}),void a();var n},children:Nt("div",{className:"flex w-full items-center",children:[Nt("div",{className:"w-4 shrink-0",children:n&&Nt(Nr,{className:"df-text-primary h-3 w-3"})}),Nt("div",{className:"flex min-w-0 items-center gap-1.5",children:[Nt("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:e.colors.lineColor}}),Nt("span",{className:"truncate "+(n?"font-semibold":""),children:e.name})]})]})},e.id)})})]}),Nt(Ya,{}),Nt(ja,{onClick:()=>{i.deleteEvent(t.id),a()},danger:!0,children:s("delete")||"Delete"}),Nt(ja,{onClick:()=>e(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),dn.setEvent(t),i.deleteEvent(t.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:s("cut")||"Cut"}),Nt(ja,{onClick:()=>e(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),dn.setEvent(t)}catch(e){console.error("Failed to copy event: ",e)}a()}),children:s("copy")||"Copy"}),u&&Nt(o,{children:[Nt(Ya,{}),u]})]})},Ga=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("假期")?Nt(Rr,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?Nt(Ar,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?Nt(Lr,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?Nt(Pr,{className:"h-3 w-3"}):Nt(Ir,{className:"h-3 w-3"})},Ka=(e,t,n=7,r)=>{const a=[],o=new Date(t);return o.setDate(t.getDate()+(n-1)),o.setHours(23,59,59,999),e.forEach(e=>{const i=we(e.start,r),l=e.end?we(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay){if(!(0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds())){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}}const u=B(s,c)>0;if(!u&&e.allDay){if(s<t||s>o)return;const r=Math.floor((s.getTime()-t.getTime())/864e5);return void(r>=0&&r<=n-1&&a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:r,endDayIndex:r,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!u)return;const h=s;let g;if(e.allDay)g=new Date(d),g.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds()?(g=new Date(d),g.setHours(23,59,59,999)):(g=new Date(d),g.setTime(g.getTime()-1))}if(g<t||h>o)return;const m=h<t?t:h,v=g>o?o:g,f=Math.max(0,Math.floor((m.getTime()-t.getTime())/864e5)),p=Math.min(n-1,Math.floor((v.getTime()-t.getTime())/864e5)),y=h>=t,b=g<=o,w=0===f||p===n-1;let D;D=y&&b?"single":y?w&&p===n-1?"start-week-end":"start":b?w&&0===f?"end-week-start":"end":"middle";const x=B(h,g)+1;a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:f,endDayIndex:p,segmentType:D,totalDays:x,segmentIndex:0,isFirstSegment:y,isLastSegment:b})}),a},qa=(e,t,n=7,r)=>{if(e.allDay)return[];const a=we(e.start,r),o=e.end?we(e.end,r):a,i=new Date(a);i.setHours(0,0,0,0);const l=new Date(o);l.setHours(0,0,0,0);const s=B(i,l);if(0===s)return[];const d=0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()||0!==o.getMilliseconds(),c=o.getTime()-a.getTime();if(!e.allDay&&1===s&&!d&&c<864e5)return[];const u=d?s:Math.max(0,s-1),h=[];for(let e=0;e<=u;e++){const r=new Date(i);r.setDate(i.getDate()+e);const l=Math.floor((r.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const s=0===e,c=e===u,g=s?a.getHours()+a.getMinutes()/60:0,m=c&&d?o.getHours()+o.getMinutes()/60:24;h.push({dayIndex:l,startHour:g,endHour:m,isFirst:s,isLast:c})}return h},Xa=h(({segment:e,segmentIndex:t,isDragging:n,isResizing:r=!1,isSelected:a=!1,onMoveStart:i,onResizeStart:l,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:u=!0,viewable:h=!0,isPopping:m,renderSlot:f,appTimeZone:y})=>{const[b,w]=g(!1),D=p(()=>{if(!y||e.event.allDay)return e.event;const t=De(e.event.start,y),n=e.event.end?De(e.event.end,y):void 0;return Object.assign(Object.assign({},e.event),{start:t,end:n})},[e.event,y]),x=17*t,E=`calc(${e.startDayIndex/7*100}% + 2px)`,C=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,k=v(null),T=v(null),N=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&l&&u?Nt("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},S=()=>{const t=D.allDay,n=D.calendarId||"blue",r=q(D.start),a=Ae(D),o=Re(r),i=Re(a);if(t){const t=()=>e.isFirstSegment?D.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":D.title;return Nt("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&Ga(D)&&Nt("div",{className:"mr-1 shrink-0",children:Nt("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:ue(n),width:"12px",height:"12px"},children:Ga(D)})}),Nt("div",{className:"min-w-0 flex-1",children:Nt("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&Nt("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:Nt("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?D.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 Nt("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[Nt("div",{className:Xn,style:{backgroundColor:ue(n)}}),Nt("div",{className:"flex min-w-0 flex-1 items-center",children:Nt("span",{className:`block overflow-hidden whitespace-nowrap ${d?"df-mobile-mask-fade":"truncate"} text-xs font-medium`,children:l})}),e.isFirstSegment&&!d&&Nt("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:c,children:o}),e.isLastSegment&&!D.allDay&&24!==a&&!d&&Nt("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})},M=e.event.calendarId||"blue",I=e.endDayIndex-e.startDayIndex+1;return Nt("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:E,width:C,top:`${x}px`,height:"16px",borderRadius:(O=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"}[O]),pointerEvents:"auto",zIndex:10,transform:m?"scale(1.02)":"scale(1)",transition:"transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",willChange:"transform"},a||n||b?{backgroundColor:ce(M),color:"#fff"}:{backgroundColor:se(M),color:de(M)}),{cursor:c||h?"pointer":"default"}),"data-segment-days":I,onMouseDown:t=>{if(!c&&!h)return;t.preventDefault(),t.stopPropagation(),w(!0);!t.target.closest(".resize-handle")&&c&&(null==i||i(t,e.event))},onMouseUp:()=>{w(!1)},onMouseLeave:()=>{w(!1)},onTouchStart:t=>{if(!i||!d||!c&&!h)return;t.stopPropagation(),w(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;T.current={x:r,y:a},k.current=setTimeout(()=>{s&&s(e.event.id);c&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),k.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(k.current&&T.current){const t=Math.abs(e.touches[0].clientX-T.current.x),n=Math.abs(e.touches[0].clientY-T.current.y);(t>10||n>10)&&(clearTimeout(k.current),k.current=null,T.current=null,w(!1))}},onTouchEnd:()=>{w(!1),k.current&&(clearTimeout(k.current),k.current=null),T.current=null},title:`${D.title} (${St(D.start)} - ${St(D.end)})`,children:[d&&a&&u&&Nt(o,{children:[e.isFirstSegment&&Nt("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:ue(M)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"left")}}),e.isLastSegment&&Nt("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:ue(M)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"right")}})]}),N("left"),Nt("div",{className:"min-w-0 flex-1",style:{cursor:r?"ew-resize":"pointer"},children:f?f(S()):S()}),N("right")]});var O});Xa.displayName="MultiDayEvent";const Ja=({event:e,isEditable:t,onResizeStart:n,isMultiDay:r,segment:a,isSlidingView:i,renderSlot:l})=>{const s=!1!==e.icon,d="boolean"==typeof e.icon?null:e.icon,c=(()=>{if(!i||!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{}})(),u=Nt("div",{className:"flex h-full flex-1 items-center overflow-hidden",children:[s&&(d?Nt("div",{className:"mr-1 shrink-0",children:d}):Nt(Ir,{className:Jn})),Nt("div",{className:`${qn} pr-1`,style:{lineHeight:"1.2"},children:e.title})]});return Nt("div",{className:"absolute inset-0 flex items-center overflow-hidden pl-3 px-1 group py-0",style:c,children:[l?l(u):u,n&&t&&Nt(o,{children:[Nt("div",{className:Qn,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),Nt("div",{className:er,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},Qa=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return Nt("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?Nt("div",{className:`${yr} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?Nt("span",{className:`inline-block ${yr} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):Nt(Ir,{className:`${Jn} ${t?"text-white":""}`})),Nt("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},eo=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(q(e.start)).toString().padStart(2,"0")}:${Math.round(q(e.start)%1*60).toString().padStart(2,"0")}`;return Nt("div",{className:"text-xs cursor-pointer flex items-center justify-between px-0.5",children:[Nt("div",{className:"flex min-w-0 flex-1 items-center",children:[Nt("div",{style:{backgroundColor:ue(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Xn}),Nt("span",{className:`block overflow-hidden whitespace-nowrap ${a?"df-mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&Nt("span",{className:`${vr} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},to=({event:e,app:t,multiDaySegmentInfo:n,isEditable:r,isTouchEnabled:a,isEventSelected:i,onResizeStart:l,timeFormat:s="24h",resizeHandleOrientation:d="vertical",renderSlot:c})=>{const u=n?n.startHour:q(e.start),h=n?n.endHour:Ae(e),g=h-u,m=!n||n.isFirst,v=!n||n.isLast,f=e.calendarId||"blue",p=!n&&g<=.25?"px-1 py-0":"p-1",y=Nt(o,{children:[Nt("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:ue(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),Nt("div",{className:`flex h-full flex-col overflow-hidden pl-3 ${p}`,children:[Nt("div",{className:`${qn} pr-1`,style:{lineHeight:g<=.25?"1.2":"normal"},children:e.title}),g>.5&&Nt("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${Re(u,0,s)} - ${Re(h,0,s)}`:Pe(e,s)})]})]});return Nt(o,{children:[c?c(y):y,l&&r&&"vertical"===d&&Nt(o,{children:[m&&Nt("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")}),v&&Nt("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")}),!m&&v&&n&&Nt("div",{className:er,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),a&&i&&l&&r&&"vertical"===d&&Nt(o,{children:[Nt("div",{className:"absolute -top-1.5 right-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:ue(f,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),Nt("div",{className:"absolute -bottom-1.5 left-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:ue(f,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]}),l&&r&&"horizontal"===d&&Nt(o,{children:[Nt("div",{className:Qn,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),Nt("div",{className:er,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},no=({event:e,segment:t,isEditable:n,onMoveStart:r,onResizeStart:a,renderSlot:i})=>{const l=!!e.allDay,s=e.calendarId||"blue",d=ue(s),c=l?Ga(e):null,{isFirstSegment:u,isLastSegment:h}=t,g=t=>{const r="left"===t,o=r?u:h;return e.allDay&&o&&a&&n?Nt("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(),a(t,e,r?"left":"right")},onTouchStart:t=>{t.stopPropagation(),a(t,e,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},m=()=>{if(l){const n=()=>t.isFirstSegment?e.title:"···";return Nt("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full min-w-0 items-center",onMouseDown:t=>{r&&(t.stopPropagation(),r(t,e))},children:[t.isFirstSegment&&Ga(e)&&Nt("div",{className:"df-year-event-icon mr-1 shrink-0",children:Nt("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:ue(s),width:"12px",height:"12px"},children:Ga(e)})}),Nt("div",{className:"min-w-0 flex-1",children:Nt("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&&Nt("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:Nt("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const n=t.isFirstSegment?e.title:"";return Nt("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full items-center gap-1 overflow-hidden",onMouseDown:t=>{r&&(t.stopPropagation(),r(t,e))},children:[!l&&Nt("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),l&&c&&Nt("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:c}),Nt("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 Nt(o,{children:[g("left"),i?i(m()):m(),g("right")]})};const ro=({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",appTimeZone:k,renderVisualContent:T,resizeHandleOrientation:N})=>{const S=t===I.MONTH,M=t===I.YEAR,O=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),H=e=>T?T(e):e;if(S&&r&&a)return Nt(Xa,{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,appTimeZone:k,renderSlot:e=>Nt(na,{store:x,generatorName:O,generatorArgs:E,defaultContent:H(e)})});if(M&&o)return Nt(no,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:w,renderSlot:e=>Nt(na,{store:x,generatorName:O,generatorArgs:E,defaultContent:H(e)})});if(S){const t=e.allDay?Nt(Qa,{event:e,isEventSelected:d}):Nt(eo,{event:e,app:y,isEventSelected:d,hideTime:v,isMobile:f});return Nt(na,{store:x,generatorName:O,generatorArgs:E,defaultContent:H(t)})}const R=e=>Nt(na,{store:x,generatorName:O,generatorArgs:E,defaultContent:H(e)});return n?Nt(Ja,{event:e,isEditable:u,onResizeStart:w,isMultiDay:r,segment:a,isSlidingView:p,renderSlot:R}):Nt(to,{event:e,app:y,multiDaySegmentInfo:D,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:w,timeFormat:C,resizeHandleOrientation:N,renderSlot:R})},ao=({event:t,position:r,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:u,onClose:h,app:y})=>{var b,w;const{effectiveTheme:D}=Qr(),x=Vt(D),{t:E}=An(),[C,k]=g(t),[T,N]=g(!1),S=v(t),M=v(t),I=v(!1),O=f(()=>{if(I.current)return;const e=S.current,t=M.current;if(ft(e,t))return;const n=Ue(e,t,null==y?void 0:y.timeZone);S.current=n,M.current=n;const r=d(n);r&&Promise.resolve(r).catch(e=>{he.error("Failed to commit deferred event detail panel update",e)})},[null==y?void 0:y.timeZone,d]),H=f(e=>{if(!ft(M.current,e)&&(M.current=e,k(e),y)){const t=y.updateEvent(e.id,e,!0);t&&Promise.resolve(t).catch(e=>{he.error("Failed to apply pending event detail panel update",e)})}},[y]);m(()=>{if(!(S.current.id===t.id))return O(),I.current=!1,S.current=t,M.current=t,void k(t);ft(S.current,M.current)&&(S.current=t,M.current=t,k(t))},[t,O]),m(()=>()=>{O()},[O]);const R=p(()=>{var e;return null!==(e=null==y?void 0:y.timeZone)&&void 0!==e?e:n.Now.timeZoneId()},[y]),A=p(()=>(y?y.getCalendarRegistry():ie()).getVisible().map(e=>({label:e.name,value:e.id})),[y,null==y?void 0:y.getCalendars()]),L="dark"===x||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),$=null!==(b=null==y?void 0:y.canMutateFromUI(t.id))&&void 0!==b&&b,j=null==y?void 0:y.getReadOnlyConfig(t.id),Y=!1!==(null==j?void 0:j.viewable),F=!!C.allDay,Z=!p(()=>{if(!t.calendarId)return!1;const e=null==y?void 0:y.getCalendarRegistry().get(t.calendarId);return!!(null==e?void 0:e.subscription)},[y,t.calendarId])||""!==(C.description||"").trim();if(!Y)return null;const z=L?"#1f2937":"white",U=L?"rgb(55, 65, 81)":"rgb(229, 231, 235)",W=(()=>{var e;let t={};if("sticky-top"===i){const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(n){const e=n.getBoundingClientRect().top+3-r.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:z,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(r.isSunday?`1px solid ${U}`:"none"),borderTop:""+(r.isSunday?`1px solid ${U}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${U}`),borderBottom:""+(r.isSunday?"none":`1px solid ${U}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const e=a.current;let n=200;if(e){const t=e.getBoundingClientRect(),r=window.getComputedStyle(e),a=Number.parseInt(r.paddingBottom,10)||0,o=Number.parseInt(r.borderBottomWidth,10)||0;n=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:z,transform:"rotate(45deg)",transformOrigin:"center",top:`${n}px`,left:r.isSunday?void 0:"-6px",right:r.isSunday?"-6px":void 0,borderRight:""+(r.isSunday?`1px solid ${U}`:"none"),borderTop:""+(r.isSunday?`1px solid ${U}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${U}`),borderBottom:""+(r.isSunday?"none":`1px solid ${U}`)}}else if(r&&s.current&&l.current){const e=s.current.getBoundingClientRect(),n=l.current.querySelector(".df-calendar-content");if(n){const o=n.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-r.top,u=a.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:z,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(r.isSunday?`1px solid ${U}`:"none"),borderTop:""+(r.isSunday?`1px solid ${U}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${U}`),borderBottom:""+(r.isSunday?"none":`1px solid ${U}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),_=Nt("div",{ref:a,className:`${ar} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${r.top}px`,left:`${r.left}px`,zIndex:9999,pointerEvents:"auto"},children:[Nt("div",{style:W}),Nt("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:E("eventTitle")}),Nt("div",{className:"mb-3 flex items-center justify-between gap-3",children:[Nt("div",{className:"flex-1",children:Nt("input",{id:`event-title-${C.id}`,name:"title",type:"text",value:C.title,readOnly:!$||T,disabled:!$||T,onChange:e=>H(Object.assign(Object.assign({},C),{title:e.target.value})),onInput:e=>H(Object.assign(Object.assign({},C),{title:e.target.value})),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),$&&Nt(fa,{options:A,value:C.calendarId||"blue",disabled:T,onChange:e=>{H(Object.assign(Object.assign({},C),{calendarId:e}))},registry:null==y?void 0:y.getCalendarRegistry()})]}),Nt("div",F?{className:"mb-3",children:[Nt("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:E("dateRange")}),Nt(va,{value:[C.start,C.end],format:"YYYY-MM-DD",showTime:!1,timeZone:R,matchTriggerWidth:!0,disabled:!$||T,onChange:e=>{if(T)return;const[t,n]=e;H(Object.assign(Object.assign({},C),{start:t.toPlainDate(),end:n.toPlainDate()}))},locale:null==y?void 0:y.state.locale})]}:{className:"mb-3",children:[Nt("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:E("timeRange")}),Nt(va,{value:[C.start,C.end],timeZone:R,disabled:!$||T,onChange:e=>{if(T)return;const[t,n]=e;H(Object.assign(Object.assign({},C),{start:t,end:n}))},locale:null==y?void 0:y.state.locale})]}),Z&&Nt("div",{className:"mb-3",children:[Nt("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:E("note")}),Nt("textarea",{id:`event-note-${C.id}`,name:"note",value:null!==(w=C.description)&&void 0!==w?w:"",readOnly:!$||T,disabled:!$||T,onChange:e=>H(Object.assign(Object.assign({},C),{description:e.target.value})),onInput:e=>H(Object.assign(Object.assign({},C),{description:e.target.value})),rows:3,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:E("addNotePlaceholder")})]}),$&&Nt("div",{className:"flex space-x-2",children:[Nt(oa,F?{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{var e;if(T)return;const t=P(C.start)?C.start:C.start.toPlainDate(),r=null!==(e=null==y?void 0:y.timeZone)&&void 0!==e?e:n.Now.timeZoneId(),a=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:r}),o=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:r});H(Object.assign(Object.assign({},C),{allDay:!1,start:a,end:o}))},loading:T,children:E("setAsTimed")}:{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{if(T)return;const e=P(C.start)?C.start:C.start.toPlainDate(),t=P(C.end)?C.end:C.end.toPlainDate();H(Object.assign(Object.assign({},C),{allDay:!0,start:e,end:t}))},loading:T,children:E("setAsAllDay")}),Nt(oa,{type:"button",className:"df-fill-destructive df-hover-destructive rounded px-2 py-1 text-xs font-medium transition",onClick:()=>e(void 0,void 0,void 0,function*(){if(!T){I.current=!0,N(!0);try{yield u(C.id)}finally{N(!1)}}}),loading:T,children:E("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const B=document.body;return B?c(_,B):null},oo=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:a,calendarRef:o,selectedEventElementRef:i,onEventUpdate:l,onEventDelete:s,onClose:d,contentRenderer:u})=>{const{effectiveTheme:h}=Qr(),g=Vt(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(".df-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(".df-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=Nt("div",{ref:n,className:`${ar} 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:[Nt("div",{style:f}),Nt(u,{event:e,isAllDay:r,onEventUpdate:l,onEventDelete:s,onClose:d})]});return c(p,document.body)},io=({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"))?Nt(oo,Object.assign({},f,{contentRenderer:g})):m?Nt(oo,Object.assign({},f,{contentRenderer:m})):Nt(ao,Object.assign({},f,{app:v}))},lo=(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},so=(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 Gn;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 Gn};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():Kn}\n `;return n||(e+=" mb-[2px] last:mb-0"),e}return`\n ${o}\n shadow-sm\n ${t?d():Kn}\n `},co="transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",uo=({event:e,layout:t,isAllDay:n=!1,allDayHeight:r=28,calendarRef:a,isBeingDragged:i=!1,isBeingResized:l=!1,viewType:s,isMultiDay:d=!1,segment:c,yearSegment:u,columnsPerRow:h,segmentIndex:y=0,hourHeight:w,firstHour:D,selectedEventId:x,detailPanelEventId:E,onMoveStart:C,onResizeStart:k,onEventUpdate:T,onEventDelete:N,newlyCreatedEventId:S,onDetailPanelOpen:M,onEventSelect:O,onEventLongPress:H,onDetailPanelToggle:R,customDetailPanelContent:A,customEventDetailDialog:P,multiDaySegmentInfo:L,app:$,isMobile:j=!1,isSlidingView:Y=!1,enableTouch:F,hideTime:Z,timeFormat:z="24h",styleOverride:U,className:W,disableDefaultStyle:_=!1,renderVisualContent:B,resizeHandleOrientation:V,appTimeZone:G})=>{var K;const X=b(ea),J=null!=F?F:j,Q=s===I.YEAR,ee=p(()=>{if(!G||e.allDay)return e;const t=De(e.start,G),n=e.end?De(e.end,G):void 0;return Object.assign(Object.assign({},e),{start:t,end:n})},[e,G]),[te,ne]=g(null),[re,ae]=g(!1),oe=v(null),ie=v(null),le=v(null),ue=v(null),he=d&&c?`${e.id}::${c.id}`:void 0===(null==L?void 0:L.dayIndex)?Q&&u?u.id:e.id:`${e.id}::day-${L.dayIndex}`,ge=E===he,me=ge&&!P,ve=null==$?void 0:$.getReadOnlyConfig(e.id),fe=null!==(K=null==$?void 0:$.canMutateFromUI(e.id))&&void 0!==K&&K,pe=!1!==(null==ve?void 0:ve.viewable),ye=!1!==(null==ve?void 0:ve.draggable),{isSelected:be,setIsSelected:we,isPressed:xe,setIsPressed:Ee,handleTouchStart:Ce,handleTouchMove:ke,handleTouchEnd:Te}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:a,canOpenDetail:o,app:i,multiDaySegmentInfo:l,isMultiDay:s,segment:d,detailPanelKey:c})=>{const[u,h]=g(!1),[m,f]=g(!1),p=v(null),y=v(null);return{isSelected:u,setIsSelected:h,isPressed:m,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):h(!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:J,onMoveStart:C,onEventLongPress:H,onDetailPanelToggle:R,canOpenDetail:pe,app:$,multiDaySegmentInfo:L,isMultiDay:d,segment:c,detailPanelKey:he}),[Ne,Se]=g("visible"),Me=e=>{ue.current=e},Ie=f(()=>((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,he,ue.current,L,c),[e,E,he,L,c]),Oe=f(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=lo(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,a,s,j),[a,s,j]),He=f(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=lo(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,a,s,j),[a,s,j]),{detailPanelPosition:Re,setDetailPanelPosition:Pe,updatePanelPosition:Le}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,multiDaySegmentInfo:o,calendarRef:i,eventRef:l,detailPanelRef:s,selectedEventElementRef:d,isMobile:c,eventVisibility:u,firstHour:h,hourHeight:v,columnsPerRow:p,showDetailPanel:y,detailPanelEventId:b,detailPanelKey:w,getActiveDayIdx:D,getDayMetricsWrapper:x})=>{const[E,C]=g(null),k=t===I.DAY,T=t===I.MONTH,N=t===I.YEAR,S=f(()=>{if(!d.current||!i.current||!s.current)return;const e=i.current.getBoundingClientRect(),t=D(),a=x(t);let o,h;if(a)o=a.left,h=a.width;else if(T)h=e.width/7,o=e.left+t*h;else{const n=lo(i,c);h=(e.width-n)/7,o=e.left+n+t*h}const g=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 h=s.current.getBoundingClientRect(),v=h.width,f=h.height;let p,y,b;if("sticky-top"===u||"sticky-bottom"===u){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=g-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,g-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,u,T,h,v,n,r,o,b,w,c,k,N,a,p,D,x,d,s,l]);return m(()=>{!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:u,multiDaySegmentInfo:L,calendarRef:a,eventRef:oe,detailPanelRef:ie,selectedEventElementRef:le,isMobile:j,eventVisibility:Ne,firstHour:D,hourHeight:w,columnsPerRow:h,showDetailPanel:ge,detailPanelEventId:E,detailPanelKey:he,getActiveDayIdx:Ie,getDayMetricsWrapper:He}),{handleClick:$e,handleDoubleClick:je,handleContextMenu:Ye,hasPendingSelection:Fe}=(({event:e,timingEvent:t,viewType:n,isAllDay:r,isMultiDay:a,segment:o,multiDaySegmentInfo:i,calendarRef:l,firstHour:s,hourHeight:d,isMobile:c,canOpenDetail:u,detailPanelKey:h,app:p,onEventSelect:y,onDetailPanelToggle:b,setIsSelected:w,setDetailPanelPosition:D,setContextMenuPosition:x,setActiveDayIndex:E,getClickedDayIdx:C,updatePanelPosition:k,selectedEventElementRef:T})=>{const N=n===I.MONTH,S=n===I.YEAR,M=null!=t?t:e,O=v(null),[H,R]=g(!1),A=f(()=>{O.current&&(clearTimeout(O.current),O.current=null,R(!1))},[]);m(()=>()=>A(),[A]);const P=f(()=>new Promise(e=>{if(!l.current||r||N||S)return void e();const t=l.current.querySelector(".df-calendar-content");if(!t)return void e();const n=i?i.startHour:q(M.start),a=i?i.endHour:Ae(M),o=(n-s)*d,c=o+Math.max((a-n)*d,d/4),u=t.scrollTop,h=t.clientHeight;if(o>=u&&c<=u+h)return void e();const g=((n+a)/2-s)*d-h/2,m=t.scrollHeight-h;t.scrollTo({top:Math.max(0,Math.min(m,g)),behavior:"smooth"}),setTimeout(()=>e(),300)}),[l,r,N,S,i,M.start,M.end,s,d]),L=f(t=>{A(),t.preventDefault(),t.stopPropagation(),p&&!p.canMutateFromUI(e.id)||(y&&y(e.id),x({x:t.clientX,y:t.clientY}))},[p,A,e.id,y,x]),$=f(t=>{var n,r,l;if(a){const a=C(t);E(null===a?null!==(r=null!==(n=null==i?void 0:i.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null:o?Math.min(Math.max(a,o.startDayIndex),o.endDayIndex):a)}else E(null!==(l=e.day)&&void 0!==l?l:null);p&&p.onEventClick(e),y?y(e.id):u&&w(!0),null==b||b(null),D(null)},[a,C,E,null==i?void 0:i.dayIndex,e,o,p,y,u,w,b,D]),j=f(t=>{var n,r,i,l,s;if(A(),t.preventDefault(),t.stopPropagation(),!u)return;let d=t.currentTarget;if(a){const e=d.querySelector("div");e&&(d=e)}if(T.current=d,a){const a=C(t.clientX);E(null===a?null!==(r=null!==(n=null==o?void 0:o.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:0:Math.min(Math.max(a,null!==(i=null==o?void 0:o.startDayIndex)&&void 0!==i?i:0),null!==(l=null==o?void 0:o.endDayIndex)&&void 0!==l?l:6))}else E(null!==(s=e.day)&&void 0!==s?s:null);P().then(()=>{w(!0),null==y||y(e.id),c||(null==b||b(h),D({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>k()))})},[A,u,a,T,C,E,null==o?void 0:o.startDayIndex,null==o?void 0:o.endDayIndex,e.day,P,w,S,c,b,h,D,k]);return{handleClick:f(e=>{e.preventDefault(),e.stopPropagation();const t=e.clientX;if(S&&!c)return A(),R(!0),void(O.current=setTimeout(()=>{$(t),O.current=null,R(!1)},180));$(t)},[A,S,c,$]),handleDoubleClick:j,handleContextMenu:L,hasPendingSelection:H,scrollEventToCenter:P}})({event:e,timingEvent:ee,viewType:s,isAllDay:n,isMultiDay:d,segment:c,multiDaySegmentInfo:L,calendarRef:a,firstHour:D,hourHeight:w,isMobile:j,canOpenDetail:pe,detailPanelKey:he,app:$,onEventSelect:O,onDetailPanelToggle:R,setIsSelected:we,setDetailPanelPosition:Pe,setContextMenuPosition:ne,setActiveDayIndex:Me,getClickedDayIdx:Oe,updatePanelPosition:Le,selectedEventElementRef:le}),Ze=(void 0===x?be:x===e.id)||Fe||!J&&xe||i,{calculateEventStyle:ze}=(({event:e,timingEvent:t,layout:n,isAllDay:r,allDayHeight:a,viewType:o,isMultiDay:i,segment:l,yearSegment:s,columnsPerRow:d,segmentIndex:c,hourHeight:u,firstHour:h,isEventSelected:g,showDetailPanel:m,isPopping:v,isDraggable:f,canOpenDetail:p,eventVisibility:y,calendarRef:b,isMobile:w,eventRef:D,getActiveDayIdx:x,getDayMetricsWrapper:E,multiDaySegmentInfo:C})=>{const k=o===I.DAY,T=o===I.MONTH,N=o===I.YEAR,S=null!=t?t:e;return{calculateEventStyle:()=>{var e,t,o,M,I,O,H,R;if(N&&s&&d){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=s,r=2;return{position:"absolute",left:`calc(${e/d*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/d*100}% - ${2*r}px)`,height:"16px",opacity:1,zIndex:g||m?1e3:1,transform:v?"scale(1.05)":"scale(1)",transition:co,cursor:f||p?"pointer":"default"}}if(T)return i&&l?{opacity:1,zIndex:g||m?1e3:1,cursor:f||p?"pointer":"default"}:{opacity:1,zIndex:g||m?1e3:1,transform:v?"scale(1.05)":"scale(1)",transition:co,cursor:f||p?"pointer":"default"};if(r){const e={height:a-4+"px",opacity:1,zIndex:g||m?1e3:1,transform:v?"scale(1.05)":"scale(1)",transition:co,cursor:f||p?"pointer":"default"},t=c*a;if(Object.assign(e,{top:`${t}px`}),k)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(i&&l){const t=d||7,n=(l.endDayIndex-l.startDayIndex+1)/t*100,r=l.startDayIndex/t*100,a=2,o=l.isFirstSegment?a:0,i=o+(l.isLastSegment?a:0);Object.assign(e,{width:i>0?`calc(${n}% - ${i}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 A=C?C.startHour:q(S.start),P=C?C.endHour:Ae(S),L={top:(A-h)*u+3+"px",height:Math.max((P-A)*u,u/4)-4+"px",position:"absolute",opacity:1,zIndex:g||m?1e3:null!==(e=null==n?void 0:n.zIndex)&&void 0!==e?e:1,transform:v?"scale(1.05)":"scale(1)",transition:co,cursor:f||p?"pointer":"default"};if(g&&m&&("sticky-top"===y||"sticky-bottom"===y)){const e=null===(t=b.current)||void 0===t?void 0:t.getBoundingClientRect();if(e){const t=x(),r=lo(b,w),a=k?1:d||7;let i=(e.width-r)/a,l=e.left+r+(k?0:t*i);T&&(i=e.width/7,l=e.left+t*i);const s=E(t);s&&(l=s.left,i=s.width);let c=null===(o=b.current)||void 0===o?void 0:o.querySelector(".df-calendar-content");c||(c=null===(M=b.current)||void 0===M?void 0:M.querySelector(".calendar-renderer"));const u=null==c?void 0:c.getBoundingClientRect(),h=null===(O=null===(I=D.current)||void 0===I?void 0:I.parentElement)||void 0===O?void 0:O.getBoundingClientRect();let g,m;if(h&&h.width>0)n?(g=h.left+n.left/100*h.width,m=k?n.width/100*h.width:(n.width-1)/100*h.width):(g=h.left,m=k?h.width:h.width-3);else{const e=E(t),r=null!==(H=null==e?void 0:e.left)&&void 0!==H?H:l,a=null!==(R=null==e?void 0:e.width)&&void 0!==R?R:i;g=r,m=a-3,n&&(g=r+n.left/100*a,m=k?n.width/100*a:(n.width-1)/100*a)}if("sticky-top"===y){let t=u?u.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:`${g}px`,width:`${m}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let v=u?u.bottom:e.bottom;return v=Math.min(v,window.innerHeight),v=Math.min(v,e.bottom),v=Math.max(v,e.top+6),v=Math.max(v,6),{position:"fixed",top:v-6+"px",left:`${g}px`,width:`${m}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(n&&!r){const e=k?`${n.width}%`:n.width-1+"%";return Object.assign(Object.assign({},L),{left:`${n.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},L),{left:"0px",right:k?"0px":"3px"})}}})({event:e,timingEvent:ee,layout:t,isAllDay:n,allDayHeight:r,viewType:s,isMultiDay:d,segment:c,yearSegment:u,columnsPerRow:h,segmentIndex:y,hourHeight:w,firstHour:D,isEventSelected:Ze,showDetailPanel:ge,isPopping:re,isDraggable:ye,canOpenDetail:pe,eventVisibility:Ne,calendarRef:a,isMobile:j,eventRef:oe,getActiveDayIdx:Ie,getDayMetricsWrapper:He,multiDaySegmentInfo:L});(({event:e,timingEvent:t,isEventSelected:n,showDetailPanel:r,eventRef:a,calendarRef:o,isAllDay:i,viewType:l,multiDaySegmentInfo:s,firstHour:d,hourHeight:c,updatePanelPosition:u,eventVisibility:h,setEventVisibility:g})=>{const v=l===I.MONTH,p=l===I.YEAR,y=null!=t?t:e,b=f(()=>{if(!n||!r||!a.current||!o.current||i||v||p)return;const e=o.current.querySelector(".df-calendar-content");if(!e)return;const t=s?s.startHour:q(y.start),l=s?s.endHour:Ae(y),m=(t-d)*c,f=m+Math.max((l-t)*c,c/4),b=e.getBoundingClientRect(),w=e.scrollTop,D=w+b.height,x=b.bottom<0,E=b.top>window.innerHeight;let C=h;x?C="sticky-top":E?C="sticky-bottom":"visible"===h?f<w?C="sticky-top":m>D-20&&(C="sticky-bottom"):"sticky-top"===h?f>=w&&(C="visible"):"sticky-bottom"===h&&m<=D-20&&(C="visible"),C!==h&&g(C),u()},[n,r,o,i,v,y.start,y.end,d,c,u,s,h,g]);m(()=>{var e,t;if(!n||!r||i)return;const a=null===(e=o.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(!a)return;const l=()=>b(),s=()=>{b(),u()},d=[a];let c=null===(t=o.current)||void 0===t?void 0:t.parentElement;for(;c;){const e=window.getComputedStyle(c);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||d.push(c),c=c.parentElement}d.forEach(e=>{e.addEventListener("scroll",l)}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",s);let h=null;return o.current&&(h=new ResizeObserver(()=>{s()}),h.observe(o.current)),b(),()=>{d.forEach(e=>{e.removeEventListener("scroll",l)}),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",s),h&&h.disconnect()}},[n,r,i,b,u,o])})({event:e,timingEvent:ee,isEventSelected:Ze,showDetailPanel:ge,eventRef:oe,calendarRef:a,isAllDay:n,viewType:s,multiDaySegmentInfo:L,firstHour:D,hourHeight:w,updatePanelPosition:Le,eventVisibility:Ne,setEventVisibility:Se});const Ue=ge&&!!P;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:a,onEventSelect:o,onDetailPanelToggle:i,setIsSelected:l,setActiveDayIndex:s})=>{m(()=>{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:oe,detailPanelRef:ie,eventId:e.id,isEventSelected:!Ue&&Ze,showDetailPanel:me,onEventSelect:O,onDetailPanelToggle:R,setIsSelected:we,setActiveDayIndex:Me});const We=f(()=>{O&&O(null),ue.current=null,we(!1),null==R||R(null)},[O,R,we]),_e=p(()=>({event:e,isAllDay:n,onEventUpdate:T,onEventDelete:N,onClose:We}),[e,n,T,N,We]),Be=p(()=>({event:e,viewType:s,isAllDay:n,isMobile:j,isSelected:Ze,isDragging:i,segment:c,layout:t}),[e,s,n,j,Ze,i,c,t]),Ve=f(()=>Nt(na,{store:X,generatorName:"eventDetailContent",generatorArgs:_e}),[X,_e]);m(()=>{if((null==$?void 0:$.state.highlightedEventId)===e.id){ae(!0);const e=setTimeout(()=>{ae(!1)},650);return()=>{clearTimeout(e),ae(!1)}}},[null==$?void 0:$.state.highlightedEventId,e.id]),m(()=>{fe||ne(null)},[fe]),m(()=>{const t=d&&(null==c?void 0:c.isFirstSegment)||Q&&(null==u?void 0:u.isFirstSegment)||!d&&!Q;S===e.id&&!ge&&t&&setTimeout(()=>{null==R||R(he),null==M||M()},50)},[S,e.id,ge,d,c,Q,u,R,M,he]);const Ge=e.calendarId||"blue",Ke=null==$?void 0:$.getCalendarRegistry();return Nt(o,{children:[Nt("div",{ref:oe,"data-event-id":e.id,className:`${so(s,n,d,c,u)} ${n&&S===e.id?"df-all-day-event-animate":""} ${null!=W?W:""}`,style:Object.assign(Object.assign(Object.assign({},_?{}:ze()),{backgroundColor:Ze?ce(Ge,Ke):se(Ge,Ke),color:Ze?"#fff":de(Ge,Ke)}),U),onClick:$e,onContextMenu:Ye,onDblClick:je,onMouseDown:t=>{var n;if(J||Ee(!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:()=>!J&&Ee(!1),onMouseLeave:()=>!J&&Ee(!1),onTouchStart:Ce,onTouchMove:ke,onTouchEnd:Te,children:Nt(ro,{event:ee,viewType:s,isAllDay:n,isMultiDay:d,segment:c,yearSegment:u,segmentIndex:y,isBeingDragged:i,isBeingResized:l,isEventSelected:Ze,isPopping:re,isEditable:fe,isDraggable:ye,canOpenDetail:pe,isTouchEnabled:J,hideTime:Z,isMobile:j,isSlidingView:Y,app:$,onMoveStart:C,onResizeStart:k,multiDaySegmentInfo:L,customRenderingStore:X,eventContentSlotArgs:Be,timeFormat:z,appTimeZone:G,renderVisualContent:B,resizeHandleOrientation:V})}),ge&&!P&&Nt("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),Nt(io,{showDetailPanel:ge,customEventDetailDialog:P,detailPanelPosition:Re,event:e,detailPanelRef:ie,isAllDay:n,eventVisibility:Ne,calendarRef:a,selectedEventElementRef:le,onEventUpdate:T,onEventDelete:N,handlePanelClose:We,customRenderingStore:X,contentSlotRenderer:Ve,customDetailPanelContent:A,app:$}),te&&$&&fe&&Nt(Va,{event:e,x:te.x,y:te.y,onClose:()=>ne(null),app:$,onDetailPanelToggle:R,detailPanelKey:he})]})},ho=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=An();return Nt("div",{className:"df-navigation flex items-center gap-1",children:[Nt("button",{type:"button",className:nr,onClick:e,"aria-label":"Previous month",children:Nt(wr,{className:rr})}),Nt("button",{type:"button",className:"df-today-button df-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")}),Nt("button",{type:"button",className:nr,onClick:n,"aria-label":"Next month",children:Nt(Dr,{className:rr})})]})},go=({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}=An(),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 Nt("div",{className:Ln,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[Nt("div",{className:"flex-1",children:Nt("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[Nt("h1",{className:$n,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&Nt("h1",{className:$n,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[Nt("div",{className:`${$n} text-gray-900 dark:text-white`,children:m}),v&&Nt("div",{className:"mt-3 leading-6 text-gray-600 dark:text-gray-400",children:v})]})}),g&&n&&r&&a&&Nt("div",{className:"flex items-center gap-2",children:Nt(ho,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})};function mo(e,t,n,r,a){if(r||0!==e.button)return;let o=!0;const i={move(r){if(!o)return;Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY)>=5&&(o=!1,document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),null==a||a(e,t,n),document.dispatchEvent(new MouseEvent("mousemove",{clientX:r.clientX,clientY:r.clientY,bubbles:!0,cancelable:!1})))},up(){o=!1,document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up)}};document.addEventListener("mousemove",i.move),document.addEventListener("mouseup",i.up)}function vo(){document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!1}))}const fo=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:a,organizedAllDayEvents:o,allDayAreaHeight:i,timeSlots:l,eventLayouts:s,isToday:d,currentTime:c,selectedEventId:u,setSelectedEventId:h,newlyCreatedEventId:f,setNewlyCreatedEventId:y,detailPanelEventId:b,setDetailPanelEventId:w,dragState:D,isDragging:x,handleMoveStart:E,handleResizeStart:C,handleCreateStart:k,handleCreateAllDayEvent:T,handleTouchStart:N,handleTouchEnd:S,handleTouchMove:M,handleDragOver:O,handleDrop:H,handleEventUpdate:R,handleEventDelete:A,onDateChange:P,customDetailPanelContent:L,customEventDetailDialog:$,calendarRef:j,allDayRowRef:Y,timeGridRef:F,switcherMode:Z,isMobile:z,isTouch:U,setDraftEvent:W,setIsDrawerOpen:_,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:V,FIRST_HOUR:G,LAST_HOUR:K,showAllDay:q,showStartOfDayLabel:X,timeFormat:J="24h",secondaryTimeSlots:Q,primaryTzLabel:ee,secondaryTzLabel:te,appTimeZone:ne})=>{var re;const ae=!!Q&&Q.length>0&&!z,{t:oe}=An(),ie=v(e.state.highlightedEventId),[le,se]=g(null),de=p(()=>zt(),[]),ce=()=>{var e;const t=null===(e=j.current)||void 0===e?void 0:e.querySelector(".df-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},ue=e=>{var t;const n=null===(t=j.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(!n)return null;const r=n.getBoundingClientRect(),a=n.scrollTop||0;return G+(e-r.top+a-ce())/V},he=e.canMutateFromUI();m(()=>{he||se(null)},[he]);const ge=(e,n)=>{var r,a,o,i;if(e.preventDefault(),z||!he)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=j.current)||void 0===r?void 0:r.querySelector(".df-calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=j.current)||void 0===o?void 0:o.querySelector(".df-calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=ce(),a=(e.clientY-t.top+n-r)/V+G,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)}}se({x:e.clientX,y:e.clientY,date:l})};return Nt("div",{className:`flex-none ${"buttons"===Z?"":"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:[Nt("div",{className:`relative ${pr} h-full`,children:[Nt("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:z||!de?"0px":"15px"},children:Nt(go,{calendar:e,viewType:I.DAY,currentDate:t})}),Nt("div",q?{className:br(Vn,"relative items-stretch border-t border-gray-200 dark:border-gray-700"),ref:Y,style:{paddingRight:z||!de?"0px":"0.6875rem"},onContextMenu:e=>ge(e,!0),children:[Nt("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:oe("allDay")}),Nt("div",{className:br("relative flex flex-1 self-stretch",!z&&de?"border-r border-gray-200 dark:border-gray-700":""),children:Nt("div",{className:"relative w-full",style:{minHeight:`${i}px`},onClick:()=>null==P?void 0:P(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==T||T(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==T||T(e,r)},onDragOver:O,onDrop:e=>{H(e,t,void 0,!0)},children:o.map(t=>Nt(uo,{event:t,isAllDay:!0,viewType:I.DAY,segmentIndex:t.row,allDayHeight:B,calendarRef:j,isBeingDragged:x&&(null==D?void 0:D.eventId)===t.id&&"move"===(null==D?void 0:D.mode),hourHeight:V,firstHour:G,onMoveStart:E,onEventUpdate:R,onEventDelete:A,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:b,onDetailPanelToggle:e=>w(e),selectedEventId:u,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.canMutateFromUI(),o=r.find(e=>e.id===t);(z||U)&&o&&n&&a?(W(o),_(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),ie.current=null))},onEventLongPress:e=>{(z||U)&&h(e)},customDetailPanelContent:L,customEventDetailDialog:$,app:e,isMobile:z,enableTouch:U,appTimeZone:ne},t.id))})})]}:{className:!z&&de?"pr-2.75":""}),Nt("div",{className:"relative overflow-y-auto df-calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:Nt("div",{className:"relative flex",children:[d&&c&&(()=>{const e=c,t=e.getHours()+e.getMinutes()/60;if(t<G||t>K)return null;return Nt("div",{className:_n,style:{top:`${(t-G)*V}px`,width:"100%",height:0,zIndex:20,marginTop:ae?"2rem":"0.75rem"},children:[Nt("div",{className:"flex w-12 items-center md:w-20",children:[Nt("div",{className:"relative flex w-full items-center"}),Nt("div",{className:Bn,children:Re(t,0,J,!1)})]}),Nt("div",{className:"flex flex-1 items-center",children:Nt("div",{className:"df-current-time-bar h-0.5 w-full df-fill-primary relative"})})]})})(),Nt("div",{className:"df-time-column flex-shrink-0 "+(ae?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[Nt("div",{className:ae?"h-8":"h-3",children:ae&&Nt("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[Nt("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:te}),Nt("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:ee})]})}),l.map((e,t)=>{var n;return Nt("div",{className:zn,children:Nt("div",ae?{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:[Nt("span",{className:"text-[10px] md:text-[12px]",children:X&&0===t?"":null!==(n=null==Q?void 0:Q[t])&&void 0!==n?n:""}),Nt("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:X&&0===t?"":e.label})]}:{className:`${Un} text-[10px] md:text-[12px]`,children:X&&0===t?"":e.label})},t)})]}),Nt("div",{className:"grow select-none",children:[Nt("div",{className:br(ir,!z&&de?"border-r":"","border-t-0"),style:ae?{height:"2rem"}:void 0,children:Nt("div",{className:`${lr} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:X?Re(G,0,J):""})}),Nt("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:F,children:[l.map((e,r)=>Nt("div",{className:br(Wn,!z&&de?"border-r":""),onClick:()=>null==P?void 0:P(t),onMouseDown:e=>{const r=ue(e.clientY);if(null===r)return;mo(e,Math.floor((t.getTime()-n.getTime())/864e5),r,U,k)},onDblClick:e=>{const r=ue(e.clientY);if(null===r)return;const a=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,a,r),vo()},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);N(e,r)},onTouchEnd:S,onTouchMove:M,onDragOver:O,onDrop:e=>{var n,r,a,o;const i=null===(r=null===(n=j.current)||void 0===n?void 0:n.querySelector(".df-calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=j.current)||void 0===a?void 0:a.querySelector(".df-calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=ce(),d=e.clientY-i.top+l-s,c=Math.floor(G+d/V);H(e,t,c)},onContextMenu:e=>ge(e,!1)},r)),Nt("div",{className:br(ir,!z&&de?"border-r":""),children:Nt("div",ae?{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:[Nt("span",{children:null!==(re=null==Q?void 0:Q[0])&&void 0!==re?re:""}),Nt("span",{children:Re(0,0,J)})]}:{className:`${lr} -left-9.5`,children:Re(0,0,J)})}),Nt("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 Nt(uo,{event:t,layout:n,viewType:I.DAY,calendarRef:j,isBeingDragged:x&&(null==D?void 0:D.eventId)===t.id&&"move"===(null==D?void 0:D.mode),hourHeight:V,firstHour:G,onMoveStart:E,onResizeStart:C,onEventUpdate:R,onEventDelete:A,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:b,onDetailPanelToggle:e=>w(e),selectedEventId:u,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(z||U)&&a&&n?(W(a),_(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),ie.current=null))},onEventLongPress:e=>{(z||U)&&h(e)},customDetailPanelContent:L,customEventDetailDialog:$,app:e,isMobile:z,enableTouch:U,appTimeZone:ne},t.id)})})]})]})]})})]}),he&&le&&Nt(Ba,{x:le.x,y:le.y,date:le.date,viewType:I.DAY,onClose:()=>se(null),app:e,onCreateEvent:()=>{if(k){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===le.date.getHours()&&0===le.date.getMinutes())null==T||T({clientX:le.x,clientY:le.y},e);else{const t=le.date.getHours()+le.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:le.x,clientY:le.y};k(n,e,t)}}}})]})},po=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h",showEventDots:c=!0,appTimeZone:u})=>{const{t:h,locale:g}=An(),m=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return Nt("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:Nt("div",{className:`${pr} h-full`,children:[Nt("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:Nt("div",{children:[Nt("div",{className:"flex items-center justify-end gap-2",children:[Nt("div",{className:Ln,style:{position:"relative"},children:Nt("div",{children:Nt("h1",{className:$n,children:" "})})}),Nt(ho,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),Nt(wa,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l,events:e.getEvents(),showEventDots:c,calendarRegistry:e.getCalendarRegistry(),timeZone:e.timeZone})]})}),Nt("div",{className:"flex-1 overflow-y-auto",children:Nt("div",{className:"p-4",children:[Nt("h3",{className:"text-lg font-semibold mb-3 sticky top-0 z-10 bg-white py-2 dark:bg-gray-900",children:t.toLocaleDateString(g,{weekday:"long",month:"long",day:"numeric"})}),0===m.length?Nt("p",{className:`${gr} ${fr}`,children:h("noEvents")}):Nt("div",{className:"space-y-2",children:m.map(t=>{var n;return Nt("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"df-border-primary df-tint-primary":"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:ue(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[Nt("div",{className:`font-medium ${fr}`,children:t.title}),!t.allDay&&Nt("div",{className:`${vr} ${mr}`,children:[Re(q(u?we(t.start,u):t.start),0,d)," ","-"," ",Re(u?q(we(null!==(n=t.end)&&void 0!==n?n:t.start,u)):Ae(t),0,d)]}),t.allDay&&Nt("div",{className:`${vr} ${mr}`,children:h("allDay")})]},t.id)})})]})})]})})},yo={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function bo(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:q(e.start),_endHour:e.allDay?0:Ae(e)})}function wo(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:q(e.start)}function Do(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:Ae(e)}function xo(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(wo(e)<Do(t)&&wo(t)<Do(e))}function Eo(e,t){const n=Do(e)-wo(e);if(n<1.25)return!1;const r=wo(e)+.4*n,a=wo(t)>=r,o=xo(e,t);return a&&o}function Co(e,t,n=yo){if(!xo(e,t))return!1;const r=Math.abs(wo(e)-wo(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!xo(e,t)||!Eo(e,t)&&!Eo(t,e))}(e,t))}function ko(e,t){const n=wo(e)<=wo(t)&&Do(e)>=Do(t),r=wo(e)<=wo(t)&&wo(t)<Do(e)&&xo(e,t);return n||r}function To(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(wo(r)-wo(t))<=yo.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>wo(e)-wo(t));const o={events:a,startHour:Math.min(...a.map(e=>wo(e))),endHour:Math.max(...a.map(e=>Do(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function No(e){return"day"===e?.5:2.5}function So(e){const t=Do(e)-wo(e);return Math.max(.1,Math.min(1,t/4))}function Mo(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(Co(e[t],e[n],yo))return!0;return!1}function Io(e,t,n,r,a={}){const o=No(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*No(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:So(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Do(t.event)-wo(t.event)-(Do(e.event)-wo(e.event)));1===u.length?Io(u[0],d,c,r,a):Mo(u.map(e=>e.event))?Oo(u,d,c,r,a):u.forEach(e=>Io(e,d,c,r,a))}function Oo(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*No(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=>Io(e,t,n,r,a));let h=yo.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:So(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Do(t.event)-wo(t.event)-(Do(e.event)-wo(e.event)));1===t.length?Io(t[0],n,g,r,a):Mo(t.map(e=>e.event))?Oo(t,n,g,r,a):t.forEach(e=>Io(e,n,g,r,a))}})}function Ho(e,t,n={}){const r=100-("day"===n.viewType?0:yo.EDGE_MARGIN_PERCENT);if(1===e.length)Io(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-yo.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{Io(e,r*(o+yo.MARGIN_BETWEEN),Math.max(o,yo.MIN_WIDTH),t,n)})}}function Ro(e){let t=0;for(const n of e.children)t+=1+Ro(n);return t}function Ao(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:Ro(e)})).toSorted((e,t)=>t.load-e.load)}function Po(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 $o(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>ko(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 jo(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>jo(e,t))}function Yo(e,t){const n=[];return jo(e,n),n.find(e=>ko(t.event,e.event))||n[0]||null}function Fo(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=Yo(n.node,r.node);if(!a)break;$o(a,r.node),n.load--,r.load++,t++}}function Zo(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(xo(n,e)&&Math.abs(wo(e)-wo(n))<yo.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<yo.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(ko(n,e))return!0;return!1}function zo(e,t,n){const r=t.events.filter(t=>ko(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&&Co(e,r,yo)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(wo(e)-wo(t.parent))-Math.abs(wo(e)-wo(n.parent))),a[0].parent}function Uo(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=Do(e)-wo(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Do(t)-wo(t):0}),0)?a[0]:a.at(-1)||null}function Wo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function _o(e){let t=0;for(const n of e.children)t+=1+_o(n);return t}function Bo(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 Vo(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=_o(e);t<i&&(i=t,l=e)}return l?l.event:null}function Go(e,t,n){const r=[];if(1===e.length){const a=zo(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),Wo(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>ko(t,e)));if(0===a.length){for(const a of e){const o=zo(a,t,n);if(o)r.push({child:a,parent:o}),Wo(o,a);else{const t=e.find(e=>e.id!==a.id&&xo(e,a));if(t){const e=Vo(t,Bo(n));e&&(r.push({child:a,parent:e}),Wo(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Do(t)-wo(t)-(Do(e)-wo(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}),Wo(n,e)}}else for(const e of o){const t=Uo(e,a,o);t&&(r.push({child:e,parent:t}),Wo(t,e))}return r}function Ko(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(Zo(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=Go(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=Ao(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);Po(r)&&Fo(r)}}(e,n),o}const qo={calculateDayEventLayouts(e,t={}){const n=e.map(bo);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)||xo(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:yo.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{Ho(Ko(To([...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}},Xo=(e,t,n=7,r)=>{const a=new Map;for(let o=0;o<n;o++){const i=[];e.forEach(e=>{var a;if(e.allDay)return;const l=qa(e,t,n,r);if(l.length>0){const n=l.find(e=>e.dayIndex===o);if(n){const r=n.endHour>=24?23.99:n.endHour,a=Object.assign(Object.assign({},e),{start:Ce(X(rt(t,o),n.startHour)),end:Ce(X(rt(t,o),r)),day:o});i.push(a)}}else if(e.day===o){const t=e=>r?we(e,r):be(e);i.push(Object.assign(Object.assign({},e),{start:Ce(t(e.start),r),end:Ce(t(null!==(a=e.end)&&void 0!==a?a:e.start),r),day:o}))}});const l=qo.calculateDayEventLayouts(i,{viewType:"week"});a.set(o,l)}return a},Jo=(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},Qo={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ei(e){const{app:t,onEventCreated:r}=e,{t:a}=An(),o=f(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:f((e,o,i,l)=>{if(e.preventDefault(),!e.dataTransfer)return null;const s=e.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const e=JSON.parse(s);let d,c,u=!1;if(l){const e=n.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});d=e,c=e,u=!0}else if(void 0===i){const e=new Date(o);e.setHours(9,0,0,0);const n=new Date(e);n.setHours(10,0,0,0),d=Ce(e,t.timeZone),c=Ce(n,t.timeZone)}else{const e=new Date(o);e.setHours(i,0,0,0);const n=new Date(e);n.setHours(i+1,0,0,0),d=Ce(e,t.timeZone),c=Ce(n,t.timeZone)}const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:a(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return t.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[t,r]),handleDragOver:o}}let ti=null;function ni(e){ti=e}const ri={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function ai(e,t){return ti?ti(e,t):ri}const oi=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,switcherMode:o="buttons",selectedEventId:i,onEventSelect:l,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{const u=e.getEvents(),{screenSize:h}=Hn(),b="desktop"!==h,[w,D]=g(!1),{hourHeight:x=Qo.HOUR_HEIGHT,firstHour:E=Qo.FIRST_HOUR,lastHour:C=Qo.LAST_HOUR,allDayHeight:k=Qo.ALL_DAY_HEIGHT,showAllDay:T=!0,timeFormat:N="24h",secondaryTimeZone:S,showEventDots:M=!0}=t,O=x,H=E,R=C,A=k,P=!T;m(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const L=e.getCustomMobileEventRenderer()||Ea,[$,j]=g(null),[Y,F]=g(null),[Z,z]=g(null),U=void 0===i?Y:i,W=void 0===d?Z:d,_=p(()=>U&&u.find(e=>e.id===U)||null,[U,u]),B=e=>{l?l(e):F(e)},[V,G]=g(null),[K,X]=g(!1),[J,Q]=g(null),ee=v(null),te=e.getCurrentDate(),[ne,re]=g(te),ae=v(te.getTime());te.getTime()!==ae.current&&(ae.current=te.getTime(),te.getFullYear()===ne.getFullYear()&&te.getMonth()===ne.getMonth()||re(te));const oe=f(t=>{re(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),ie=v(e.state.highlightedEventId);m(()=>{var t;if(e.state.highlightedEventId!==ie.current)if(e.state.highlightedEventId){B(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=q(n.start),r=null===(t=a.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(r){const t=(e-H)*O;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else B(null);ie.current=e.state.highlightedEventId},[e.state.highlightedEventId,H,O,a,e]);const le=v(null),se=v(null),de=p(()=>Jo(te),[te]),ce=e.timeZone,ue=p(()=>((e,t,n,r)=>{const a=new Date(t);a.setHours(0,0,0,0);const o=new Date(t);o.setHours(23,59,59,999);const i=e=>r?we(e,r):be(e);return e.filter(e=>{var t;const n=i(e.start),r=i(null!==(t=e.end)&&void 0!==t?t:e.start);if(e.allDay){const e=new Date(n);e.setHours(0,0,0,0);const t=new Date(r);return t.setHours(0,0,0,0),e<=o&&t>=a}return n<o&&r>a}).map(e=>{const t=i(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})})})(u,te,de,ce),[u,te,de,ce]),he=p(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(r);a.setDate(a.getDate()+1);const o=e=>n?we(e,n):be(e);return e.filter(e=>!e.allDay).map(e=>{var t;const i=o(e.start),l=o(null!==(t=e.end)&&void 0!==t?t:e.start);let s=Ce(i,n),d=Ce(l,n);return i<r&&(s=Ce(r,n)),l>a&&(d=Ce(a,n)),Object.assign(Object.assign({},e),{start:s,end:d,day:0})})})(ue,te,ce),[ue,te,ce]),ge=p(()=>qo.calculateDayEventLayouts(he,{viewType:"day"}),[he]),me=p(()=>((e,t)=>{const n=e.filter(e=>e.allDay);if(t)n.sort(t);else{const e=new Map;n.forEach(t=>{e.has(t.calendarId)||e.set(t.calendarId,e.size)}),n.sort(Mn(n,(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)}))}const r=[],a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)r[t]?r[t].some(t=>{const n=be(e.start),r=be(e.end),a=be(t.start);return n<=be(t.end)&&a<=r})?t++:(r[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),n=!0):(r[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),n=!0)}),a})(ue,e.state.allDaySortComparator),[ue,e.state.allDaySortComparator]),ve=p(()=>{if(0===me.length)return A;return(Math.max(...me.map(e=>e.row))+1)*A},[me,A]),{handleMoveStart:fe,handleCreateStart:pe,handleResizeStart:ye,handleCreateAllDayEvent:De,dragState:xe,isDragging:Ee}=ai(e,{calendarRef:a,allDayRowRef:T?le:void 0,timeGridRef:se,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=u.find(t=>t.id===e.id);return t&&pt(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),G(t.id))},onEventEdit:()=>{},currentWeekStart:de,events:ue,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a,o)=>{const i=new Date(r),l=new Date(r);i.setHours(Math.floor(t),t%1*60,0,0),l.setHours(Math.floor(n),n%1*60,0,0);const s=[...a,{id:"-1",title:"Temp",day:0,start:Ce(i,o),end:Ce(l,o),calendarId:"blue",allDay:!1}];return qo.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null})(0,t,n,te,he,ce),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o,i)=>{const l=o.filter(t=>t.id!==e.id),s=new Date(a),d=new Date(s);d.setHours(Math.floor(n),n%1*60,0,0);const c=new Date(s);c.setHours(Math.floor(r),r%1*60,0,0);const u=[...l,Object.assign(Object.assign({},e),{start:Ce(d,i),end:Ce(c,i),day:0})];return 0===u.length?null:qo.calculateDayEventLayouts(u,{viewType:"day"}).get(e.id)||null})(e,0,n,r,te,he,ce),TIME_COLUMN_WIDTH:S&&!b?88:b?48:80,isMobile:b}),{handleDrop:ke,handleDragOver:Te}=ei({app:e,onEventCreated:e=>{G(e.id)}}),Ne=Array.from({length:24},(e,t)=>({hour:t+H,label:Re(t+H,0,N)})),Se=p(()=>S?$e(Ne,S,N,te,ce):void 0,[S,N,H,te,ce]),Me=p(()=>S?je(ce,te):void 0,[S,ce,te]),Ie=p(()=>S?je(S,te):void 0,[S,te]),Oe=f(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),re(new Date(n.getFullYear(),n.getMonth(),1))},[e]),He=p(()=>{const e=Fe(ce);return te.toDateString()===e.toDateString()},[te,ce]);return y(()=>{var e;if(t.scrollToCurrentTime){const t=null===(e=a.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(t){const e=Ye(ce),n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-H)*O-r/2)}}},[ce,t.scrollToCurrentTime,H,O]),m(()=>{j(Ye(ce));const e=setInterval(()=>j(Ye(ce)),6e4);return()=>clearInterval(e)},[ce]),Nt("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[Nt(fo,{app:e,currentDate:te,currentWeekStart:de,events:u,currentDayEvents:ue,organizedAllDayEvents:me,allDayAreaHeight:ve,timeSlots:Ne,eventLayouts:ge,isToday:He,currentTime:$,selectedEventId:U,setSelectedEventId:B,newlyCreatedEventId:V,setNewlyCreatedEventId:G,detailPanelEventId:W,setDetailPanelEventId:e=>{c?c(e):z(e)},dragState:xe,isDragging:Ee,handleMoveStart:fe,handleResizeStart:ye,handleCreateStart:pe,handleCreateAllDayEvent:De,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(".df-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(".df-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/O)},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:le,timeGridRef:se,switcherMode:o,isMobile:b,isTouch:w,setDraftEvent:Q,setIsDrawerOpen:X,ALL_DAY_HEIGHT:A,HOUR_HEIGHT:O,FIRST_HOUR:H,LAST_HOUR:R,showAllDay:T,showStartOfDayLabel:P,timeFormat:N,secondaryTimeSlots:Se,primaryTzLabel:Me,secondaryTzLabel:Ie,appTimeZone:ce}),Nt(po,{app:e,currentDate:te,visibleMonth:ne,currentDayEvents:ue,selectedEvent:_,setSelectedEvent:e=>B(e?e.id:null),handleMonthChange:oe,handleDateSelect:Oe,switcherMode:o,timeFormat:N,showEventDots:M,appTimeZone:ce}),Nt(L,{isOpen:K,onClose:()=>{X(!1),Q(null)},onSave:t=>{u.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),X(!1),Q(null)},draftEvent:J,app:e,timeFormat:N})]})},ii=({originalComponent:e,app:t,viewType:n,config:r,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:i,switcherMode:l,meta:s,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDateChange:h,onDetailPanelToggle:g})=>{const m=t.getPlugin("events"),v=t.getPlugin("drag"),y=t.getCurrentDate(),b=t.state.currentView,w=t.getEvents(),D=f(e=>m?m.update(e.id,e):t.updateEvent(e.id,e),[m,t]),x=f(e=>m?m.delete(e):t.deleteEvent(e),[m,t]),E=f(e=>{m?m.add(e):t.addEvent(e)},[m,t]),C=f(e=>{h?h(e):t.setCurrentDate(e)},[t,h]),k=f(e=>{t.changeView(e)},[t]),T=p(()=>{const e=t.getViewConfig(n);return Object.assign(Object.assign({},e),r)},[r,t.state.views,n]),N=p(()=>({app:t,currentDate:y,currentView:b,events:w,onEventUpdate:D,onEventDelete:x,onEventCreate:E,onDateChange:C,onViewChange:k,config:T,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:i,switcherMode:l,meta:s,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDetailPanelToggle:g}),[t,y,b,w,D,x,E,C,k,T,a,o,i,l,s,d,c,u,g]),S=p(()=>{const e={currentDate:y,events:w,setEvents:e=>{w.forEach(e=>x(e.id)),e.forEach(e=>E(e))},updateEvent:D,deleteEvent:x,addEvent:E,goToPrevious:()=>{const e=new Date(y);switch(b){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)}C(e)},goToNext:()=>{const e=new Date(y);switch(b){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)}C(e)},goToToday:()=>{C(new Date)},changeView:k,selectDate:C};return Object.assign(Object.assign({calendar:e},N),{eventsService:m,dragService:v})},[y,w,b,D,x,E,C,k,N,m,v]);return Nt(e,Object.assign({},S))},li={},si=e=>i(ii,Object.assign(Object.assign({},e),{viewType:I.DAY,originalComponent:oi,className:"day-view-factory"}));si.displayName="DayViewAdapter";const di=(e={})=>{const t=Object.assign(Object.assign({},li),e);return{type:I.DAY,component:si,config:t}},ci=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)},ui=({app:e,fullWeekDates:t=[],mobilePageStart:n,onDateChange:r})=>Nt("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:[Nt("div",{className:"mb-1 grid grid-cols-7",children:t.map((e,t)=>Nt("div",{className:"flex justify-center",children:Nt("span",{className:"text-[10px] font-medium "+(e.isToday?"df-text-primary":"text-gray-500"),children:ci(e.dayName)})},`label-${t}`))}),Nt("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!n)return null;const a=t.findIndex(e=>e.fullDate.getTime()===n.getTime());return Nt(o,{children:[Nt("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:-1===a?"0":`calc(${(a+.5)/7*100}% - 16px)`,top:0,width:`calc(${1/7*100}% + 32px)`,height:"32px"}}),t.map((t,n)=>{const o=t.isCurrent,i=n>=a&&n<a+2;return Nt("div",{className:"relative z-10 flex cursor-pointer items-center justify-center",style:{height:"32px"},onClick:()=>{e.setCurrentDate(t.fullDate),null==r||r(t.fullDate)},children:Nt("div",{className:`relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-all duration-300 ${o?"bg-gray-900 text-white shadow-sm dark:bg-gray-100 dark:text-gray-900":t.isToday?"df-text-primary font-bold":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!o&&Nt("div",{className:"df-fill-primary absolute bottom-1 h-1 w-1 rounded-full"})]})},`date-${n}`)})]})})()})]}),hi=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:r,fullWeekDates:a,isSlidingView:i,mobilePageStart:l,currentWeekStart:s,gridWidth:d,allDayAreaHeight:c,organizedAllDaySegments:u,allDayLabelText:h,isMobile:v,isTouch:f,showAllDay:y=!0,calendarRef:b,allDayRowRef:w,topFrozenContentRef:D,ALL_DAY_HEIGHT:x,HOUR_HEIGHT:E,FIRST_HOUR:C,dragState:k,isDragging:T,primaryTzLabel:N,secondaryTzLabel:S,secondaryTimeSlots:M,handleMoveStart:O,handleResizeStart:H,handleEventUpdate:R,handleEventDelete:A,onDateChange:P,newlyCreatedEventId:L,setNewlyCreatedEventId:$,selectedEventId:j,setSelectedEventId:Y,detailPanelEventId:F,setDetailPanelEventId:Z,handleCreateAllDayEvent:z,handleDragOver:U,handleDrop:W,customDetailPanelContent:_,customEventDetailDialog:B})=>{const V={flexShrink:0},[G,K]=g(null),q=p(()=>zt(),[]),X=!!M&&M.length>0&&!v,J=e.canMutateFromUI();m(()=>{J||K(null)},[J]);return Nt("div",{className:"flex w-full flex-col",children:[i&&a&&l&&Nt(ui,{app:e,fullWeekDates:a,mobilePageStart:l,onDateChange:P}),Nt("div",{className:`flex flex-none ${y?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[y&&Nt("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:[Nt("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:X&&Nt("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[Nt("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:S}),Nt("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:N})]})}),Nt("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:h})]}),Nt("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:y?`${c+(i?0:36)}px`:"auto"},children:Nt("div",{ref:D,className:"flex flex-col",style:{width:d,minWidth:"100%",transform:i?"translateX(calc(-100% / 3))":void 0},children:[!i&&Nt("div",{className:"df-week-header flex border-b",style:{marginRight:q?"-50px":"0px",paddingRight:q?"50px":"0px"},children:t.map((e,t)=>Nt("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 "+(v?"flex-col gap-0":""),style:V,children:Nt(o,v?{children:[Nt("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:n[t]}),Nt("div",{className:`${Yn} h-7 w-7 text-base font-medium ${r[t].isToday?tr:""}`,children:r[t].date})]}:{children:[Nt("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),Nt("div",{className:`${Yn} ${r[t].isToday?tr:""}`,children:r[t].date})]})},t))}),y&&Nt("div",{className:`${Vn} relative border-none transition-[min-height] duration-300 ease-in-out`,ref:w,style:{minHeight:`${c}px`},children:Nt("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),Nt("div",{className:"df-all-day-cell flex-1 border-r relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!v&&q?"":"border-r-0"),style:Object.assign({minHeight:`${c}px`},V),onMouseDown:e=>null==z?void 0:z(e,n),onDblClick:e=>null==z?void 0:z(e,n),onDragOver:U,onDrop:e=>{W(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),v||!J)return;const n=new Date(s);n.setDate(s.getDate()+t),n.setHours(0,0,0,0),K({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),Nt("div",{className:"pointer-events-none absolute inset-0",children:u.map(n=>Nt(uo,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:x,calendarRef:b,viewType:I.WEEK,columnsPerRow:t.length,isBeingDragged:T&&(null==k?void 0:k.eventId)===n.event.id&&"move"===(null==k?void 0:k.mode),hourHeight:E,firstHour:C,onMoveStart:O,onResizeStart:H,onEventUpdate:R,onEventDelete:A,newlyCreatedEventId:L,onDetailPanelOpen:()=>$(null),selectedEventId:j,detailPanelEventId:F,onEventSelect:e=>{Y(e)},onEventLongPress:e=>{(v||f)&&Y(e)},onDetailPanelToggle:e=>Z(e),customDetailPanelContent:_,customEventDetailDialog:B,app:e,isMobile:v,isSlidingView:i,enableTouch:f},n.event.id))})]})})]})}),J&&G&&Nt(Ba,{x:G.x,y:G.y,date:G.date,viewType:I.WEEK,onClose:()=>K(null),app:e,onCreateEvent:()=>{const e=Math.floor((G.date.getTime()-s.getTime())/864e5);null==z||z({clientX:G.x,clientY:G.y},e)}})]})]})},gi=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:r,currentWeekEvents:a,eventLayouts:i,gridWidth:l,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:u,leftFrozenContentRef:h,swipeContentRef:f,calendarRef:y,handleScroll:b,handleCreateStart:w,handleTouchStart:D,handleTouchEnd:x,handleTouchMove:E,handleDragOver:C,handleDrop:k,dragState:T,isDragging:N,handleMoveStart:S,handleResizeStart:M,handleEventUpdate:O,handleEventDelete:H,onDateChange:R,newlyCreatedEventId:A,setNewlyCreatedEventId:P,selectedEventId:L,setSelectedEventId:$,detailPanelEventId:j,setDetailPanelEventId:Y,customDetailPanelContent:F,customEventDetailDialog:Z,isSlidingView:z,isCurrentWeek:U,currentTime:W,HOUR_HEIGHT:_,FIRST_HOUR:B,LAST_HOUR:V,showStartOfDayLabel:G,timeFormat:K="24h",secondaryTimeSlots:q,appTimeZone:X})=>{var J,Q;const ee=!!q&&q.length>0&&!s,te={flexShrink:0},ne=v(e.state.highlightedEventId),[re,ae]=g(null),oe=p(()=>zt(),[]),ie=e.canMutateFromUI();m(()=>{ie||ae(null)},[ie]);const le=e=>{if(!u.current)return B;const t=u.current.getBoundingClientRect();return B+(e-t.top)/_};return Nt("div",{className:"relative flex flex-1 overflow-hidden",children:[Nt("div",{ref:c,className:"df-calendar-content relative flex-1 overflow-auto "+("300%"===l?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:b,children:[Nt("div",{ref:h,className:"sticky left-0 z-10 w-12 shrink-0 bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[Nt("div",{className:"relative h-3",children:ee?Nt(o,{children:Nt("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[Nt("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G&&null!==(J=null==q?void 0:q[0])&&void 0!==J?J:""}),Nt("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G?Re(B,0,K):""})]})}):Nt("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:G?Re(B,0,K):""})}),t.map((e,t)=>{var n;return Nt("div",{className:zn,children:Nt("div",ee?{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:[Nt("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":null!==(n=null==q?void 0:q[t])&&void 0!==n?n:""}),Nt("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":e.label})]}:{className:`${Un} text-[10px] md:text-[12px]`,children:G&&0===t?"":e.label})},t)}),Nt("div",{className:"relative",children:Nt("div",ee?{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:[Nt("span",{className:"text-[10px] md:text-[12px]",children:null!==(Q=null==q?void 0:q[0])&&void 0!==Q?Q:""}),Nt("span",{className:"text-[10px] md:text-[12px]",children:Re(0,0,K)})]}:{className:`${Un} text-[10px] md:text-[12px]`,children:Re(0,0,K)})}),U&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>V)return null;return Nt("div",{className:"pointer-events-none absolute left-0 z-20 flex w-full items-center justify-end",style:{top:`${(t-B)*_}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:Nt("div",{className:Bn,children:Re(t,0,K,!1)})})})()]}),Nt("div",{ref:f,className:"flex",style:{width:l,minWidth:"100%",transform:z?"translateX(calc(-100% / 3))":void 0},children:Nt("div",{className:"grow",children:[Nt("div",{className:`${ir} flex border-t-0`,children:n.map((e,t)=>Nt("div",{className:`relative flex-1 ${t!==n.length-1||!s&&oe?"border-r":""} border-gray-200 dark:border-gray-700`,style:te},`top-${t}`))}),Nt("div",{ref:u,className:"relative",children:[U&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>V)return null;const a=new Date(e);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);const i=a.getTime()-o.getTime(),l=Math.round(i/864e5);return Nt("div",{className:_n,style:{top:`${(t-B)*_}px`,width:"100%",height:0,zIndex:20},children:[Nt("div",{className:"flex w-0 items-center"}),Nt("div",{className:"flex flex-1",children:n.map((e,t)=>Nt("div",{className:"flex flex-1 items-center",children:Nt("div",{className:"relative h-0.5 w-full "+(t===l?"df-fill-primary":"df-tint-primary-lg"),style:{zIndex:9999},children:t===l&&0!==l&&Nt("div",{className:"df-fill-primary absolute h-2 w-2 rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>Nt("div",{className:Wn,children:n.map((a,o)=>{const i=new Date(r);return i.setDate(r.getDate()+o),Nt("div",{className:"df-time-grid-cell flex-1 relative border-r select-none snap-start "+(o!==n.length-1||!s&&oe?"":"border-r-0"),style:te,onClick:()=>{const e=new Date(r);e.setDate(r.getDate()+o),null==R||R(e)},onMouseDown:e=>{mo(e,o,le(e.clientY),d,w)},onDblClick:e=>{null==w||w(e,o,le(e.clientY)),vo()},onTouchStart:t=>D(t,o,e.hour),onTouchEnd:x,onTouchMove:E,onDragOver:C,onDrop:t=>{k(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),s||!ie)return;const a=new Date(r);if(a.setDate(r.getDate()+t),u.current){const t=u.current.getBoundingClientRect(),n=(e.clientY-t.top)/_+B,r=Math.floor(n),o=Math.floor(60*(n-r)),i=15*Math.round(o/15),l=60===i?r+1:r,s=60===i?0:i;a.setHours(l,s,0,0)}else a.setHours(n,0,0,0);ae({x:e.clientX,y:e.clientY,date:a})})(t,o,e.hour)},`${t}-${o}`)})},t)),Nt("div",{className:`${ir} flex`,children:n.map((e,t)=>Nt("div",{className:`relative flex-1 ${t!==n.length-1||!s&&oe?"border-r":""} border-gray-200 dark:border-gray-700`,style:te},`24-${t}`))}),n.map((t,o)=>{const l=n.length,c=tt(o,a),u=[];return c.forEach(e=>{const t=qa(e,r,n.length,X);if(t.length>0){const n=t.find(e=>e.dayIndex===o);n&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:o})})}else u.push({event:e})}),a.forEach(e=>{if(e.allDay||e.day===o)return;const t=qa(e,r,n.length,X).find(e=>e.dayIndex===o);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:o})})}),Nt("div",{className:"pointer-events-none absolute top-0",style:{left:`calc(${100/l*o}%)`,width:100/l+"%",height:"100%"},children:u.map(({event:t,segmentInfo:n})=>{const r=i.get(o),a=null==r?void 0:r.get(t.id);return Nt(uo,{event:t,layout:a,viewType:I.WEEK,calendarRef:y,columnsPerRow:l,isBeingDragged:N&&(null==T?void 0:T.eventId)===t.id&&"move"===(null==T?void 0:T.mode),hourHeight:_,firstHour:B,onMoveStart:S,onResizeStart:M,onEventUpdate:O,onEventDelete:H,newlyCreatedEventId:A,onDetailPanelOpen:()=>P(null),selectedEventId:L,detailPanelEventId:j,onEventSelect:t=>{$(t),e.state.highlightedEventId&&(e.highlightEvent(null),ne.current=null)},onEventLongPress:e=>{(s||d)&&$(e)},onDetailPanelToggle:e=>Y(e),customDetailPanelContent:F,customEventDetailDialog:Z,multiDaySegmentInfo:n,app:e,isMobile:s,isSlidingView:z,enableTouch:d,appTimeZone:X},n?`${t.id}-seg-${o}`:t.id)})},`events-day-${o}`)})]})]})})]}),ie&&re&&Nt(Ba,{x:re.x,y:re.y,date:re.date,viewType:I.WEEK,onClose:()=>ae(null),app:e,onCreateEvent:()=>{if(w){const e=new Date(r);e.setHours(0,0,0,0);const t=new Date(re.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),a=Math.round(n/864e5),o=re.date.getHours()+re.date.getMinutes()/60,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:re.x,clientY:re.y};w(i,a,o)}}})]})},mi=({app:e,config:t,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,selectedEventId:i,onEventSelect:l,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,getWeekDaysLabels:b,locale:w}=An(),D=e.getCurrentDate(),x=p(()=>D,[D.getTime()]),E=e.getEvents(),{screenSize:C}=Hn(),k="desktop"!==C,T=v(null),[N,S]=g(!1),{hourHeight:M=Qo.HOUR_HEIGHT,firstHour:O=Qo.FIRST_HOUR,lastHour:H=Qo.LAST_HOUR,allDayHeight:R=Qo.ALL_DAY_HEIGHT,showAllDay:A=!0,timeFormat:P="24h",secondaryTimeZone:L}=t,$=L&&"mobile"!==C?88:"mobile"===C?48:80,j=M,Y=O,F=H,Z=R,z=!A;m(()=>{S("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const U=e.getCustomMobileEventRenderer()||Ea,W="desktop"!==C,_=W?2:7,B=W,V=null!==(u=t.startOfWeek)&&void 0!==u?u:1,G=B?"300%":"100%",K=p(()=>Jo(x,V),[x,V]),[J,Q]=g(()=>{const e=new Date(x);return e.setHours(0,0,0,0),e});m(()=>{B&&Q(e=>{const t=new Date(x);t.setHours(0,0,0,0);const n=new Date(e),r=new Date(e);return r.setDate(r.getDate()+_-1),t>=n&&t<=r?e:t})},[x,B,_]);const ee=B?J:K,te=B?3*_:7,ne=p(()=>{if(!B)return ee;const e=new Date(ee);return e.setDate(e.getDate()-_),e},[ee,B,_]),[re,ae]=g(null),[oe,ie]=g(null),[le,se]=g(null),de=void 0===i?oe:i,ce=void 0===d?le:d,ue=e=>{l?l(e):ie(e)},he=e=>{c?c(e):se(e)},[ge,me]=g(null),[ve,fe]=g(!1),[pe,ye]=g(null),De=v(null),[xe,Ee]=g(0),[ke,Te]=g(!1),Ne=v(null),Se=v(null),Me=v(null),Ie=v(null),Oe=v(null),He=v({x:0,y:0}),Ae=v(!1),Pe=v(0);m(()=>{if(!B)return;const t=Se.current;if(!t)return;const n=e=>{He.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Ae.current=!1,Pe.current=0,Te(!1)},r=e=>{if(ke)return;const n=e.touches[0].clientX-He.current.x,r=e.touches[0].clientY-He.current.y;if(!Ae.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(Ae.current=!0),Ae.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),Oe.current&&(Oe.current.style.transition="none",Oe.current.style.transform=o),Pe.current=a}},a=()=>{var n;if(!Ae.current)return void(Pe.current=0);const r=Pe.current,a=((null===(n=Oe.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/te;r>100?(Te(!0),Ee(a),setTimeout(()=>{const t=new Date(J);t.setDate(t.getDate()-1),Q(t),e.setCurrentDate(t),Ee(0),Pe.current=0,Te(!1)},300)):r<-100?(Te(!0),Ee(-a),setTimeout(()=>{const t=new Date(J);t.setDate(t.getDate()+1),Q(t),e.setCurrentDate(t),Ee(0),Pe.current=0,Te(!1)},300)):(Te(!0),Ee(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)}},[B,e,ee,ke,_,te]);const Le=e.timeZone,Ze=p(()=>((e,t,n=7,r)=>{const a=new Date(t);a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999);const o=e=>r?we(e,r):be(e);return e.filter(e=>{var n;const r=o(e.start);r.setHours(0,0,0,0);const i=o(null!==(n=e.end)&&void 0!==n?n:e.start);return i.setHours(23,59,59,999),i>=t&&r<=a}).map(e=>{const r=o(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),i=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:i})})})(E,ne,te,Le),[E,ne,te,Le]),ze=v(e.state.highlightedEventId);m(()=>{if(e.state.highlightedEventId!==ze.current)if(e.state.highlightedEventId){ue(e.state.highlightedEventId);const t=Ze.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=q(t.start),n=Se.current;if(n){const t=(e-Y)*j;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ue(null);ze.current=e.state.highlightedEventId},[e.state.highlightedEventId,Ze,Y,j]);const Ue=p(()=>((e,t,n=7,r)=>{const a=Ka(e,t,n).filter(e=>e.event.allDay);if(r)a.sort((e,t)=>r(e.event,t.event));else{const e=new Map;a.forEach(t=>{const n=t.event.calendarId;e.has(n)||e.set(n,e.size)});const t=Mn(a.map(e=>e.event),(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)});a.sort((e,n)=>t(e.event,n.event))}const o=[];return a.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of o)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}o.push(Object.assign(Object.assign({},e),{row:t}))}),o})(Ze,ne,te,e.state.allDaySortComparator),[Ze,ne,te,e.state.allDaySortComparator]),We=p(()=>{const e=B?Ue.filter(e=>e.endDayIndex>=_&&e.startDayIndex<=2*_-1):Ue;if(0===e.length)return Z;const t=Math.max(...e.map(e=>e.row));return Z+t*Z},[Ue,Z,B,_]),_e=p(()=>Xo(Ze,ne,te,Le),[Ze,ne,te,Le]),Be=f((t,n,r)=>{const a=t(Ze),o=new Set(a.map(e=>e.id)),i=Ze.filter(e=>!o.has(e.id)),l=new Set(Ze.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=Ze.find(t=>t.id===e.id);return t&&pt(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},[Ze,e]),Ve=f(t=>{k?(ye(t),fe(!0)):(e.addEvent(t),me(t.id))},[k,e]),Ge=f(()=>{},[]),Ke=f((e,t,n)=>((e,t,n,r,a,o=7,i)=>{var l;const s=rt(a,e),d=rt(a,e);s.setHours(Math.floor(t),t%1*60,0,0),d.setHours(Math.floor(n),n%1*60,0,0);const c={id:"-1",title:"Temp",day:e,start:Ce(s,i),end:Ce(d,i),calendarId:"blue",allDay:!1};return(null===(l=Xo([...r,c],a,o,i).get(e))||void 0===l?void 0:l.get("-1"))||null})(e,t,n,Ze,ne,te,Le),[Ze,ne,te,Le]),qe=f((e,t,n,r)=>((e,t,n,r,a,o,i=7,l)=>{var s;const d=a.map(a=>{if(a.id!==e.id)return a;const i=rt(o,t),s=X(i,n),d=X(i,r),c=Ce(s,l),u=Ce(d,l);return Object.assign(Object.assign({},a),{day:t,start:c,end:u})});return(null===(s=Xo(d,o,i,l).get(t))||void 0===s?void 0:s.get(e.id))||null})(e,t,n,r,Ze,ne,te,Le),[Ze,ne,te,Le]),Xe=p(()=>({calendarRef:o,allDayRowRef:A?Ne:void 0,timeGridRef:T,viewType:I.WEEK,onEventsUpdate:Be,onEventCreate:Ve,onEventEdit:Ge,currentWeekStart:ne,events:Ze,calculateNewEventLayout:Ke,calculateDragLayout:qe,TIME_COLUMN_WIDTH:$,isMobile:k,gridWidth:G,displayDays:te}),[o,A,Be,Ve,Ge,ne,Ze,Ke,qe,$,k,G,te]),{handleMoveStart:Je,handleCreateStart:Qe,handleResizeStart:et,handleCreateAllDayEvent:tt,dragState:nt,isDragging:at}=ai(e,Xe),{handleDrop:ot,handleDragOver:it}=ei({app:e,onEventCreated:e=>{me(e.id)}}),lt=p(()=>B?Array.from({length:te},(e,t)=>{const n=new Date(ne);return n.setDate(n.getDate()+t),n.toLocaleDateString(w,{weekday:"short"})}):b(w,"short",V),[w,b,B,ne,te,V]),st=p(()=>{if(!k)return[];const e=w.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?b(w,"narrow"):lt.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)})},[k,w,b,lt]),dt=p(()=>h("allDay"),[h]),ct=Array.from({length:24},(e,t)=>({hour:t+Y,label:Re(t+Y,0,P)})),ut=p(()=>L?$e(ct,L,P,x,Le):void 0,[L,P,Y,x,Le]),ht=p(()=>L?je(Le,x):void 0,[L,Le,x]),gt=p(()=>L?je(L,x):void 0,[L,x]),mt=p(()=>{const e=n.Now.plainDateISO(Le),t=new Date(e.year,e.month-1,e.day).toDateString();return lt.map((e,n)=>{const r=new Date(ne);return r.setDate(ne.getDate()+n),{date:r.getDate(),month:r.toLocaleString(w,{month:"short"}),fullDate:new Date(r),isToday:r.toDateString()===t}})},[ne,lt,w,Le]),vt=p(()=>{const e=n.Now.plainDateISO(Le),t=new Date(e.year,e.month-1,e.day).toDateString(),r=new Date(x.getFullYear(),x.getMonth(),x.getDate()).getTime(),a=K;return Array.from({length:7},(e,n)=>{const o=new Date(a);o.setDate(a.getDate()+n);const i=new Date(o.getFullYear(),o.getMonth(),o.getDate());return{date:o.getDate(),month:o.toLocaleString(w,{month:"short"}),fullDate:new Date(o),isToday:o.toDateString()===t,isCurrent:i.getTime()===r,dayName:o.toLocaleDateString(w,{weekday:"short"})}})},[K,w,x,Le]);m(()=>{if(!B)return Me.current&&(Me.current.style.transform="",Me.current.style.transition=""),void(Oe.current&&(Oe.current.style.transform="",Oe.current.style.transition=""));const e=ke?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${xe}px))`;Me.current&&(Me.current.style.transition=e,Me.current.style.transform=t),Oe.current&&(Oe.current.style.transition=e,Oe.current.style.transform=t)},[xe,ke,B]);const ft=t=>e.updateEvent(t.id,t),yt=t=>e.deleteEvent(t),bt=p(()=>{const e=Fe(Le);e.setHours(0,0,0,0);const t=new Date(ne);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+te),e>=t&&e<n},[ne,te,Le]);return y(()=>{if(t.scrollToCurrentTime&&Se.current){const e=Se.current,t=Ye(Le),n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-Y)*j-r/2)}},[Le,t.scrollToCurrentTime,Y,j]),m(()=>{ae(Ye(Le));const e=setInterval(()=>ae(Ye(Le)),6e4);return()=>clearInterval(e)},[Le]),Nt("div",{className:"df-calendar relative flex flex-col w-full overflow-hidden h-full select-none df-week-view",children:[Nt(go,{calendar:e,viewType:I.WEEK,currentDate:x,onPrevious:()=>{if(B){const t=new Date(x);t.setDate(t.getDate()-1),Q(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(B){const t=new Date(x);t.setDate(t.getDate()+1),Q(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),Nt(hi,{app:e,weekDaysLabels:lt,mobileWeekDaysLabels:st,weekDates:mt,fullWeekDates:vt,isSlidingView:B,mobilePageStart:J,currentWeekStart:ne,gridWidth:G,allDayAreaHeight:We,organizedAllDaySegments:Ue,allDayLabelText:dt,isMobile:k,isTouch:N,showAllDay:A,calendarRef:o,allDayRowRef:Ne,topFrozenContentRef:Me,ALL_DAY_HEIGHT:Z,HOUR_HEIGHT:j,FIRST_HOUR:Y,dragState:nt,isDragging:at,secondaryTimeSlots:ut,primaryTzLabel:ht,secondaryTzLabel:gt,handleMoveStart:Je,handleResizeStart:et,handleEventUpdate:ft,handleEventDelete:yt,onDateChange:s,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,handleCreateAllDayEvent:tt,handleDragOver:it,handleDrop:ot,customDetailPanelContent:r,customEventDetailDialog:a}),Nt(gi,{app:e,timeSlots:ct,weekDaysLabels:lt,currentWeekStart:ne,currentWeekEvents:Ze,eventLayouts:_e,gridWidth:G,isMobile:k,isSlidingView:B,isTouch:N,scrollerRef:Se,timeGridRef:T,leftFrozenContentRef:Ie,swipeContentRef:Oe,calendarRef:o,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Me.current){const e=B?"calc(-100% / 3)":"0px",n=B?`${xe}px`:`-${t}px`;Me.current.style.transform=`translateX(calc(${e} + ${n}))`,Me.current.style.transition=B&&ke?"transform 0.3s ease-out":"none"}},handleCreateStart:Qe,handleTouchStart:(e,t,n)=>{if(!k&&!N)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;De.current=setTimeout(()=>{null==Qe||Qe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{De.current&&(clearTimeout(De.current),De.current=null)},handleTouchMove:()=>{De.current&&(clearTimeout(De.current),De.current=null)},handleDragOver:it,handleDrop:ot,dragState:nt,isDragging:at,handleMoveStart:Je,handleResizeStart:et,handleEventUpdate:ft,handleEventDelete:yt,onDateChange:s,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,customDetailPanelContent:r,customEventDetailDialog:a,isCurrentWeek:bt,currentTime:re,HOUR_HEIGHT:j,FIRST_HOUR:Y,LAST_HOUR:F,showStartOfDayLabel:z,timeFormat:P,secondaryTimeSlots:ut,appTimeZone:Le}),Nt(U,{isOpen:ve,onClose:()=>{fe(!1),ye(null)},onSave:t=>{E.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),fe(!1),ye(null)},draftEvent:pe,app:e,timeFormat:P})]})},vi={startOfWeek:1},fi=e=>i(ii,Object.assign(Object.assign({},e),{viewType:I.WEEK,originalComponent:mi,className:"week-view-factory"}));fi.displayName="WeekViewAdapter";const pi=(e={})=>{const t=Object.assign(Object.assign({},vi),e);return{type:I.WEEK,component:fi,config:t}},yi=17,bi=h(({currentMonth:e,currentYear:t,newlyCreatedEventId:r,screenSize:a,isScrolling:o,isDragging:i,showWeekNumbers:l,showMonthIndicator:s=!0,item:d,weekHeight:c,events:u,dragState:h,calendarRef:f,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:O,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:A,onCalendarDrop:P,onCalendarDragOver:L,app:$,enableTouch:j,appTimeZone:Y})=>{const{t:F,locale:Z}=An(),[z,U]=g(!1),W=v(null),_=v(null),B=v(null),[V,G]=g(null),K=$.canMutateFromUI();m(()=>{K||G(null)},[K]);const X=p(()=>{const e=c-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=Math.floor(e/yi),n=e-20,r=Math.max(0,Math.floor(n/yi));return{maxSlots:t,maxSlotsWithMore:t>0?Math.min(r,t-1):r}},[c]);m(()=>o?(U(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):z?(W.current=setTimeout(()=>{U(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[o,z]);const{weekData:J}=d,Q=J.days.find(e=>1===e.day),te=`${c}px`,ne=p(()=>zt(),[]),re=p(()=>Ka(u,J.startDate,7,Y),[u,J.startDate,Y]),ae=p(()=>((e,t,r)=>{const a=[],o=new Date(t);return o.setDate(o.getDate()+6),o.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void he.warn("Event missing start or end date:",e);const i=we(e.start,r),l=e.end?we(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}const u=s.toDateString()!==c.toDateString();if(!u||e.allDay)if(u&&e.allDay){let r=new Date(i);r<t&&(r=new Date(t),r.setHours(0,0,0,0));const s=l>o?o:l;for(let o=i.getTime();o<=s.getTime();o+=864e5){const i=new Date(o);if(i<t)continue;const l=n.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});a.push(Object.assign(Object.assign({},e),{start:l,end:l,day:r.getDay()}))}}else a.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:i.getDay()}))}),a})(u,J.startDate,Y),[u,J.startDate,Y]),oe=p(()=>{const e=new Map;return J.days.forEach(t=>{const n=t.date.toDateString();e.set(n,ae.filter(e=>{if(!e.start||!e.end)return we(e.start,Y).toDateString()===n;const t=we(e.start,Y),r=we(e.end,Y);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},[ae,J.days,Y]),ie=p(()=>((e,t)=>{const n=t||Mn(e.map(e=>e.event),(()=>{const t=new Map;return e.forEach(e=>{const n=e.event.calendarId;t.has(n)||t.set(n,t.size)}),(e,n)=>{var r,a;return(null!==(r=t.get(e.calendarId))&&void 0!==r?r:0)-(null!==(a=t.get(n.calendarId))&&void 0!==a?a:0)}})()),r=[...e].toSorted((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}const r=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:r!==a?a-r:e.startDayIndex-t.startDayIndex}),a=[];r.forEach(e=>{var t;let n=0,r=!1;for(;!r;){let o=!1;for(const r of a){const a=Math.abs((null!==(t=r.yPosition)&&void 0!==t?t:0)-n)<16,i=!(e.endDayIndex<r.startDayIndex||e.startDayIndex>r.endDayIndex);if(a&&i){o=!0;break}}o?n+=16:r=!0}a.push(Object.assign(Object.assign({},e),{yPosition:n}))});const o=[];return a.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);o[n]||(o[n]=[]),o[n].push(e)}),o.forEach(e=>{e.sort((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}return e.startDayIndex-t.startDayIndex})}),o})(re,$.state.allDaySortComparator),[re,$.state.allDaySortComparator]),le=p(()=>ie.flat(),[ie]),se=p(()=>{const e=Array.from({length:7}).fill(0);return ie.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ie]),de=p(()=>{const e=Array.from({length:7},()=>new Set);return ie.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ie]),ce=p(()=>{const{maxSlots:e,maxSlotsWithMore:t}=X,n=J.days.map((n,r)=>{var a,o;const i=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:q(e.start)-q(t.start)))(null!==(a=oe.get(n.date.toDateString()))&&void 0!==a?a:[]),l=i.filter(e=>{if(!e.allDay)return!0;return!le.some(t=>t.originalEventId===e.id)}),s=(null!==(o=se[r])&&void 0!==o?o:0)-1,d=de[r],c=[];for(let e=0;e<=s;e++)d.has(e)||c.push(e);const u=l.length,h=Math.max(0,u-c.length),g=Math.max(s+1,0)+h,m=g>e;return{totalSlotsNeeded:g,hasMore:m,limit:m?t:e,timedEventsOnly:l,gapLayers:c,occupiedLayers:d,maxOccupiedLayer:s}}),r=new Set;return ie.forEach((e,t)=>{e.forEach(e=>{for(let a=e.startDayIndex;a<=e.endDayIndex;a++)if(a>=0&&a<7&&t>=n[a].limit){r.add(e.id);break}})}),n.map((n,a)=>{let o=!1;le.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&r.has(e.id)&&(o=!0)});const i=n.hasMore||o,l=i?t:e;return Object.assign(Object.assign({},n),{hasMore:i,limit:l,segmentIsHidden:r})})},[X,J.days,oe,le,se,de,ie]),ue=p(()=>Math.min(ie.length,X.maxSlots),[ie.length,X.maxSlots]),ge=p(()=>Math.max(0,ue*yi),[ue]),me=(n,o)=>{const s=n.date.toLocaleDateString(Z,{month:Z.startsWith("zh")||Z.startsWith("ja")?"short":"long"})===e&&n.year===t,{hasMore:d,limit:c,timedEventsOnly:u,gapLayers:g,occupiedLayers:m,maxOccupiedLayer:v,totalSlotsNeeded:p}=ce[o];let z=0;ie.slice(c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=o&&e.endDayIndex>=o&&z++})}),ie.slice(0,c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=o&&e.endDayIndex>=o&&ce[o].segmentIsHidden.has(e.id)&&z++})});const U=g.filter(e=>e<c).length,W=ie.slice(0,c).filter(e=>e.some(e=>e.startDayIndex<=o&&e.endDayIndex>=o&&ce[o].segmentIsHidden.has(e.id))).length,V=Math.max(0,c-Math.max(v+1,0)),X=Math.min(u.length,U+V+W),J=u.slice(0,X),Q=z+(u.length-X),re=d&&ue>c,ae=(ue-c)*yi,oe=[];let le=0;const se=Math.min(c,p);for(let e=0;e<se;e++)if(m.has(e)&&!ie[e].some(e=>e.startDayIndex<=o&&e.endDayIndex>=o&&ce[o].segmentIsHidden.has(e.id)))oe.push(Nt("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${n.date.getTime()}`));else if(le<J.length){const e=J[le];oe.push(Nt(uo,{event:e,isAllDay:!!e.allDay,viewType:I.MONTH,isBeingDragged:i&&h.eventId===e.id&&"move"===h.mode,calendarRef:f,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,onDetailPanelOpen:E,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:r,selectedEventId:N,detailPanelEventId:O,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:A,app:$,isMobile:"desktop"!==a,enableTouch:j,appTimeZone:Y},`${e.id}-${e.day}-${q(e.start)}-${le}`)),le++}return Nt("div",{className:br("df-month-day-cell relative flex flex-col border-r",s?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===o?ne?"last:border-r":"border-r-0":""),style:{height:te},"data-date":(de=n.date,`${de.getFullYear()}-${String(de.getMonth()+1).padStart(2,"0")}-${String(de.getDate()).padStart(2,"0")}`),onClick:()=>s&&(null==T?void 0:T(n.date)),onDblClick:e=>null==D?void 0:D(e,n.date),onTouchStart:e=>{if("mobile"!==a&&!j)return;const t=e.touches[0],r=t.clientX,o=t.clientY;B.current={x:r,y:o},_.current=setTimeout(()=>{null==D||D(e,n.date),_.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(_.current&&B.current){const t=Math.abs(e.touches[0].clientX-B.current.x),n=Math.abs(e.touches[0].clientY-B.current.y);(t>10||n>10)&&(clearTimeout(_.current),_.current=null)}},onTouchEnd:()=>{_.current&&(clearTimeout(_.current),_.current=null),B.current=null},onDragOver:L,onDrop:e=>null==P?void 0:P(e,n.date),onContextMenu:e=>((e,t)=>{e.preventDefault(),"mobile"!==a&&K&&G({x:e.clientX,y:e.clientY,date:t})})(e,n.date),children:[Nt("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&&Nt("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:ee(n.date)}),Nt("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 ${n.isToday?tr:s?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===n.day&&"desktop"===a?n.date.toLocaleDateString(Z,{month:"short",day:"numeric"}):n.day})]}),Nt("div",{className:"pointer-events-none relative flex-1 overflow-hidden px-1",children:[re&&Nt("div",{className:"pointer-events-none absolute right-0 left-0 z-[100] bg-white dark:bg-gray-900",style:{top:c*yi+"px",height:`${ae}px`}}),oe,d&&Nt("div",{className:br("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","desktop"===a?"text-left font-normal":"text-center font-medium","pointer-events-auto","z-[100]"),onClick:e=>{e.stopPropagation(),C?C(n.date):(null==T||T(n.date),null==k||k(I.DAY))},children:["+",Q,"desktop"===a?` ${F("more")}`:""]})]})]},`day-${n.date.getTime()}`);var de},ve=p(()=>Q?Q.date.toLocaleDateString(Z,{month:"long",year:"numeric"}):"",[Q,Z]);return Nt("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:te},children:[s&&Q&&Nt("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:Nt("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ve})}),Nt("div",{className:"flex h-full flex-col",children:Nt("div",{className:"calendar-week relative h-full",children:[Nt("div",{className:"grid h-full grid-cols-7",children:J.days.map((e,t)=>me(e,t))}),ie.length>0&&Nt("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ge}px`},children:ie.slice(0,ue).map((e,t)=>Nt("div",{className:"absolute inset-0",children:e.filter(e=>!ce[0].segmentIsHidden.has(e.id)).map(e=>Nt(uo,{event:e.event,isAllDay:!0,segment:e,segmentIndex:t,viewType:I.MONTH,isMultiDay:!0,calendarRef:f,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,isBeingDragged:i&&h.eventId===e.event.id&&"move"===h.mode,isBeingResized:i&&h.eventId===e.event.id&&"resize"===h.mode,newlyCreatedEventId:r,onDetailPanelOpen:E,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:O,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:A,app:$,isMobile:"desktop"!==a,enableTouch:j,appTimeZone:Y},e.id))},`layer-${t}`))})]})}),K&&V&&Nt(Ba,{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)}}})]})});bi.displayName="WeekComponent";const wi=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,detailPanelEventId:l,onDetailPanelToggle:s})=>{var d,c,u;const{getWeekDaysLabels:h,getMonthLabels:b,locale:w}=An(),D=e.getCurrentDate(),x=e.getEvents(),E=null!==(d=t.startOfWeek)&&void 0!==d?d:1,C=e.timeZone,k=!0===(null===(c=t.scroll)||void 0===c?void 0:c.disabled),T=k&&"fade"===(null===(u=t.scroll)||void 0===u?void 0:u.transition),[N,S]=g(D),[M,O]=g(!1),[A,P]=g("forward"),L=v(D),$=v(null),j=D.getFullYear(),Y=D.getMonth();m(()=>{if(!T)return;if(j===L.current.getFullYear()&&Y===L.current.getMonth())return;const e=D>L.current;return L.current=D,P(e?"forward":"backward"),$.current&&clearTimeout($.current),O(!0),$.current=setTimeout(()=>{S(D),O(!1)},300),()=>{$.current&&clearTimeout($.current)}},[j,Y,T]);const F=p(()=>T?((e,t)=>{const n=new Date(e.getFullYear(),e.getMonth(),1),r=(n.getDay()-t+7)%7,a=new Date(n);a.setDate(n.getDate()-r),a.setHours(0,0,0,0);const o=[];for(let e=0;e<6;e++){const t=new Date(a);t.setDate(a.getDate()+7*e),o.push(Je(t))}return o})(N,E):[],[T,N,E]),Z=p(()=>({opacity:M?0:1,transform:M?`translateX(${"forward"===A?"-6%":"6%"})`:"translateX(0)",transition:"opacity 300ms ease, transform 300ms ease"}),[M,A]),z=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),U=v(null),W=p(()=>{const e=U.current;return e&&e.length===x.length&&e.every((e,t)=>e===x[t])?e:(U.current=x,x)},[x]),_=p(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-E+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 W.forEach(e=>{if(!e.start)return;const r=we(e.start,C),a=e.end?we(e.end,C):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},[W,E,C]),{screenSize:B}=Hn(),[V,G]=g(!1);m(()=>{G("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const K=e.getCustomMobileEventRenderer()||Ea,[q,X]=g(()=>{if("undefined"==typeof window)return 119;const e=window.innerHeight-150;return Math.max(80,Math.ceil(e/6))}),[J,Q]=g(()=>"undefined"!=typeof window),ee=v(q),te=v([]),[ne,re]=g(null),[ae,oe]=g(!1),[ie,le]=g(null),[se,de]=g(null),[ce,ue]=g(null),he=void 0===o?se:o,ge=void 0===l?ce:l,me=f(e=>{i?i(e):de(e)},[i]),ve=f(e=>{s?s(e):ue(e)},[s]),fe=v(e.state.highlightedEventId);m(()=>{e.state.highlightedEventId?me(e.state.highlightedEventId):fe.current&&me(null),fe.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const pe=p(()=>{const e=(D.getDay()-E+7)%7,t=new Date(D);return t.setDate(D.getDate()-e),t.setHours(0,0,0,0),t},[D,E]),{handleMoveStart:ye,handleCreateStart:be,handleResizeStart:De,dragState:xe,isDragging:Ee}=ai(e,{calendarRef:a,viewType:I.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(W),o=new Set(a.map(e=>e.id)),i=W.filter(e=>!o.has(e.id)),l=new Set(W.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=W.find(t=>t.id===e.id);return t&&pt(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"===B?e.addEvent(t):(le(t),oe(!0))},onEventEdit:e=>{re(e.id)},currentWeekStart:pe,events:W,isMobile:"desktop"!==B}),{handleDrop:Ce,handleDragOver:ke}=ei({app:e,onEventCreated:e=>{re(e.id)}}),Te=p(()=>h(w,"short",E),[w,h,E]),{currentMonth:Ne,currentYear:Se,isScrolling:Me,virtualData:Ie,weeksData:Oe,scrollElementRef:He,isNavigating:Re,handleScroll:Ae,handlePreviousMonth:Pe,handleNextMonth:Le,handleToday:$e,setScrollTop:je}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:a="en-US",startOfWeek:o=1,isEnabled:i=!0,snapToMonth:l=!1})=>{const s=v(null),d=f((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]),c=p(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),et(t,r,o)},[e,r,o]),u=p(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=c.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[c,e,t]),[h,b]=g(u),[w,D]=g(600),[x,E]=g(d(e.getMonth(),e.getFullYear())),[C,k]=g(e.getFullYear()),[T,N]=g(!1),[S,M]=g(c),[I,O]=g(!1),A=v(!1),[P,L]=g(!1),$=v(e),j=v(null),Y=v(null),F=v(new R),Z=v(0),z=v(0),U=v(!1),W=f(e=>{e&&(j.current=e)},[]),_=f(e=>{let t=F.current.get(e);return t||(t=Je(e),F.current.set(e,t)),t},[]),B=f((e,n=26)=>{U.current||(U.current=!0,setTimeout(()=>{try{if("future"===e){const e=S.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(_(n))}M(e=>[...e,...t])}else{const e=S[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(_(n))}const a=r.length*t;M(e=>[...r,...e]),requestAnimationFrame(()=>{b(e=>e+a),j.current&&(j.current.scrollTop+=a)})}}finally{setTimeout(()=>{U.current=!1},200)}},0))},[S,_,t]),V=p(()=>{const e=S.length*t,n=Math.floor(h/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,S.length-6));const a=Math.min(S.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(S.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:S[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[h,w,t,S]),G=f(e=>{if(I||T||0===e.length||!P)return;const t=h+w/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=`${d(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",i=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(s.current?o===s.current.month&&i===s.current.year&&(s.current=null,o===x&&i===C||(E(o),k(i),null==n||n(o,i))):o===x&&i===C||(E(o),k(i),null==n||n(o,i)))},[w,x,C,I,T,n,h,P]),K=f(e=>{const n=performance.now();if(n-Z.current<H.SCROLL_THROTTLE)return;Z.current=n;const r=e.currentTarget,a=r.scrollTop;z.current=a,b(a),I||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!U.current&&B("future",26),a<10*t&&!U.current&&B("past",26)}),N(!0),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{N(!1)},H.SCROLL_DEBOUNCE)},[t,B,I]),q=f((e,n=!0)=>{if(!j.current)return;O(!0),A.current=!0;const r=()=>{setTimeout(()=>{O(!1),A.current=!1},n?500:200)},a=S.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return j.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=S[0],d=S.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(_(t))}const o=a.length*t;M(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...S].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(j.current&&-1!==i){const e=i*t;j.current.scrollTop+=o,b(e=>e+o),setTimeout(()=>{j.current&&j.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(_(t))}M(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...S,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(j.current&&-1!==o){const e=o*t;j.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[S,t,_]),X=f(()=>{var e;const t=V.displayStartIndex,n=Math.min(S.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=S[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a-1,1);q(l)},[V.displayStartIndex,S,q]),J=f(()=>{var e;const t=V.displayStartIndex,n=Math.min(S.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=S[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a+1,1);q(l)},[V.displayStartIndex,S,q]),Q=f(()=>{const e=new Date,r=d(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);s.current={month:r,year:a},E(r),k(a),null==n||n(r,a);const i=S.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)O(!0),A.current=!0,requestAnimationFrame(()=>{q(o,!0),setTimeout(()=>{A.current=!1,O(!1)},200)});else{const e=i*t,n=j.current;n&&(O(!0),A.current=!0,requestAnimationFrame(()=>{b(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{A.current=!1,O(!1)},200))})}))}},[S,t,n,q]);return m(()=>{G(V.visibleItems)},[V.visibleItems,G]),m(()=>{const t=$.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){const e=6,t=V.displayStartIndex,r=Math.min(S.length-1,t+e-1),a={};for(let e=t;e<=r;e++){const t=S[e];t&&t.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1})}let l="",c=0;for(const[e,t]of Object.entries(a))t>c&&(c=t,l=e);if(l!==`${o}-${i}`){const e=new Date(i,o,1),t=d(o,i);s.current={month:t,year:i},E(t),k(i),null==n||n(t,i),q(e,!0)}}$.current=e},[e,n,q,V,S,d]),m(()=>{const e=j.current;if(!e)return;const t=new ResizeObserver(([e])=>{D(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),y(()=>{const e=j.current;e&&!P&&i&&(u>0&&(e.scrollTop=u),L(!0))},[P,u,i]),m(()=>{var e;if(!l||T||I||!P)return;const n=Math.floor(h/t),r=Math.min(S.length-1,n+5),a={};for(let t=n;t<=r;t++)null===(e=S[t])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1});let o=0,i=0,s=0;for(const[e,t]of Object.entries(a))t>s&&(s=t,[o,i]=e.split("-").map(Number));const d=new Date(i,o,1),c=S.findIndex(e=>e.days.some(e=>e.date.toDateString()===d.toDateString()));if(-1===c)return;const u=c*t;if(Math.abs(u-h)>5){const e=setTimeout(()=>{q(d,!0)},200);return()=>clearTimeout(e)}},[T,l,I,P,h,t,S,q]),m(()=>()=>{Y.current&&clearTimeout(Y.current)},[]),{scrollTop:h,containerHeight:w,currentMonth:x,currentYear:C,isScrolling:T,isNavigating:I,virtualData:V,scrollElementRef:j,handleScroll:K,scrollToDate:q,handlePreviousMonth:X,handleNextMonth:J,handleToday:Q,setScrollTop:b,setContainerHeight:D,setCurrentMonth:E,setCurrentYear:k,setIsScrolling:N,cache:F.current,scrollElementRefCallback:W,weeksData:S}})({currentDate:D,weekHeight:q,onCurrentMonthChange:(t,n)=>{const r=w.startsWith("zh")||w.startsWith("ja"),a=b(w,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:w,startOfWeek:E,isEnabled:J,snapToMonth:t.snapToMonth}),Ye=v(0),[Fe,Ze]=g(0),ze=p(()=>Fe-6*q,[Fe,q]),{visibleWeeks:Ue,startIndex:We}=p(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=Ie,a=n.findIndex(e=>e.index===r);if(-1===a)return te.current.length>0?{visibleWeeks:te.current,startIndex:Ye.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&&(te.current=i,Ye.current=l),{visibleWeeks:i,startIndex:l}},[Ie]),_e=p(()=>We*q,[We,q]),Be=v(!0),Ve=v(!1),Ge=((e,t)=>{const[n,r]=g(e);return m(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(Ie.displayStartIndex,250);m(()=>{Re&&(Ve.current=!0)},[Re]),m(()=>{if(Be.current)return void(Be.current=!1);const t=Oe[Ge];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,Ve.current?"navigation":"scroll"),Ve.current=!1},[e,Oe,Ge]);const Ke=p(()=>{const e=Ie.totalHeight,t=We*q+Ue.length*q+ze;return Math.max(0,e-t)},[Ie.totalHeight,We,q,ze,Ue.length]);m(()=>{const e=He.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Ze(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==ee.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/ee.current)*n;e.scrollTop=r,je(r)}X(n),ee.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[He,je]),y(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));X(t),ee.current=t,Q(!0)},[]),m(()=>{if(T||!k)return;const e=He.current;if(!e)return;const t=e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t)}},[T,k,He]);const qe=f(t=>e.updateEvent(t.id,t),[e]),Xe=f(t=>e.deleteEvent(t),[e]),Qe=t=>{e.changeView(t)},tt=f(()=>re(null),[]),nt=f(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==B||V)&&t&&n){const e=W.find(e=>e.id===t);if(e)return le(e),void oe(!0)}me(t)},[B,V,W,me,e]),rt=f(e=>{("desktop"!==B||V)&&me(e)},[B,V,me]);return Nt("div",{className:Pn,children:[Nt(go,{calendar:e,viewType:I.MONTH,currentDate:D,customTitle:(()=>{const e=w.startsWith("zh")||w.startsWith("ja");if(T){const t=b(w,e?"short":"long")[N.getMonth()],n=N.getFullYear();return e?`${n}年${t}`:`${t} ${n}`}return e?`${Se}年${Ne}`:`${Ne} ${Se}`})(),onPrevious:()=>{e.goToPrevious(),T||Pe()},onNext:()=>{e.goToNext(),T||Le()},onToday:()=>{e.goToToday(),T||$e()}}),Nt("div",{className:"df-week-header-row sticky top-0 z-10 border-b",onContextMenu:e=>e.preventDefault(),children:Nt("div",{className:"grid grid-cols-7 px-2",children:Te.map((e,t)=>Nt("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),Nt("div",T?{ref:He,className:Fn,style:{overflow:"hidden",visibility:J?"visible":"hidden"},children:Nt("div",{style:Z,children:F.map((o,i)=>{var l;const s=null!==(l=_.get(o.startDate.getTime()))&&void 0!==l?l:[],d={index:i,weekData:o,top:i*q,height:q},c=5===i?Object.assign(Object.assign({},d),{height:d.height+ze}):d;return Nt(bi,{item:c,weekHeight:q,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:!1,currentMonth:"",currentYear:0,screenSize:B,isScrolling:!1,calendarRef:a,events:s,onEventUpdate:qe,onEventDelete:Xe,onMoveStart:ye,onCreateStart:be,onResizeStart:De,isDragging:Ee,dragState:xe,newlyCreatedEventId:ne,onDetailPanelOpen:tt,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Qe,onSelectDate:e.selectDate,selectedEventId:he,onEventSelect:nt,onEventLongPress:rt,detailPanelEventId:ge,onDetailPanelToggle:ve,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:Ce,onCalendarDragOver:ke,calendarSignature:z,app:e,enableTouch:V,appTimeZone:C},`week-${o.startDate.getTime()}`)})})}:{ref:He,className:Fn,style:{overflow:"hidden auto",overscrollBehavior:"contain",visibility:J?"visible":"hidden"},onScroll:Ae,children:[Nt("div",{style:{height:_e}}),Ue.map((o,i)=>{var l;const s=null!==(l=_.get(o.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===i?Object.assign(Object.assign({},o),{height:o.height+ze}):o,c=!(!1===t.showMonthIndicator||!o.weekData.days.some(e=>1===e.day))&&Me;return Nt(bi,{item:d,weekHeight:q,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:Ne,currentYear:Se,screenSize:B,isScrolling:c,calendarRef:a,events:s,onEventUpdate:qe,onEventDelete:Xe,onMoveStart:ye,onCreateStart:be,onResizeStart:De,isDragging:Ee,dragState:xe,newlyCreatedEventId:ne,onDetailPanelOpen:tt,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Qe,onSelectDate:e.selectDate,selectedEventId:he,onEventSelect:nt,onEventLongPress:rt,detailPanelEventId:ge,onDetailPanelToggle:ve,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:Ce,onCalendarDragOver:ke,calendarSignature:z,app:e,enableTouch:V,appTimeZone:C},`week-${o.weekData.startDate.getTime()}`)}),Nt("div",{style:{height:Ke}})]}),Nt(K,{isOpen:ae,onClose:()=>{oe(!1),le(null)},onSave:t=>{W.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),oe(!1),le(null)},draftEvent:ie,app:e})]})},Di={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},xi=e=>i(ii,Object.assign(Object.assign({},e),{viewType:I.MONTH,originalComponent:wi,className:"month-view-factory"}));xi.displayName="MonthViewAdapter";const Ei=(e={})=>{const t=Object.assign(Object.assign({},Di),e);return{type:I.MONTH,component:xi,config:t}};const Ci=h(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=An(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return Nt("div",{className:`relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800 ${c?"border-l-2 border-l-(--df-color-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:[Nt("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&Nt("span",{className:"df-fill-primary rounded-sm px-1 py-0.5 text-[9px] leading-none font-bold",children:u}),Nt("span",{className:"ml-auto text-[10px] font-medium "+(t?"df-fill-primary flex h-5 w-5 items-center justify-center rounded-full":"text-gray-700 dark:text-gray-300"),children:d})]}),i>0&&Nt("div",{className:"absolute bottom-0.5 left-1 z-20",children:Nt("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")]})})]})});Ci.displayName="YearDayCell";const ki=h(({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:v,detailPanelEventId:y,onDetailPanelToggle:b,customDetailPanelContent:w,customEventDetailDialog:D,onContextMenu:x,appTimeZone:E})=>{const C=p(()=>{const e=Fe(E);return e.setHours(0,0,0,0),e},[E]),k=f((e,t)=>{e.preventDefault(),e.stopPropagation(),x({x:e.clientX,y:e.clientY,date:t})},[x]),T=f(e=>{r.selectDate(e)},[r]),N=p(()=>function(e,t,n,r,a){if(0===t.length)return[];const o=t[0],i=t.at(-1);if(!o||!i)return[];const l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),s=new Date(i.getFullYear(),i.getMonth(),i.getDate(),23,59,59,999).getTime(),d=e.map(e=>{const t=we(e.start,a),n=e.end?we(e.end,a):t;return{event:e,startMs:new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),endMs:new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()}}).filter(e=>e.startMs<=s&&e.endMs>=l);if(0===d.length)return[];const c=Mn(d.map(e=>e.event),r);d.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:c(e.event,t.event)});const u=[],h=[];return d.forEach(({event:e,startMs:t,endMs:r})=>{let a=Math.round((t-l)/864e5),o=Math.round((r-l)/864e5);a=Math.max(0,Math.min(a,n-1)),o=Math.max(0,Math.min(o,n-1));const i=t>=l,d=r<=s;let c=0;for(;;){h[c]||(h[c]=[]);let e=!1;for(let t=a;t<=o;t++)if(h[c][t]){e=!0;break}if(!e){for(let e=a;e<=o;e++)h[c][e]=!0;break}c++}u.push({id:`${e.id}::year-${l}`,event:e,startCellIndex:a,endCellIndex:o,isFirstSegment:i,isLastSegment:d,visualRowIndex:c})}),u}(t,e,n,r.state.allDaySortComparator,E),[t,e,n,r.state.allDaySortComparator,E]),{visibleSegments:S,moreCounts:M}=p(()=>{const t=Array.from({length:e.length}).fill(0);N.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 N.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}},[N,e.length]);return Nt("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()===C.getTime();return Nt(Ci,{date:e,isToday:n,locale:o,onSelectDate:T,onCreateStart:c,onMoreEventsClick:g,moreCount:M[t],onContextMenu:k},e.getTime())}),Nt("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:Nt("div",{className:"relative h-full w-full",children:S.map(e=>Nt("div",{className:"pointer-events-auto",children:Nt(uo,{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:b,newlyCreatedEventId:m,onDetailPanelOpen:v,calendarRef:a,app:r,detailPanelEventId:y,customDetailPanelContent:w,customEventDetailDialog:D,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e),appTimeZone:E})},e.id))})})]})});ki.displayName="YearRowComponent";const Ti=({app:e,calendarRef:t,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:u,locale:h}=An(),b=e.getCurrentDate(),w=b.getFullYear(),D=e.getEvents(),x=e.timeZone,E=v(null),[C,k]=g(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[T,N]=g(()=>"undefined"!=typeof window),[S,M]=g(()=>"undefined"!=typeof window&&window.innerWidth<768),[O,H]=g(null),[R,A]=g(null),P=void 0===i?O:i,L=void 0===s?R:s,[$,j]=g(null),Y=f(e=>{l?l(e):H(e)},[l]),F=f(e=>{d?d(e):A(e)},[d]),Z=f(()=>{j(null)},[]),[z,U]=g(null),W=e.canMutateFromUI();m(()=>{W||U(null)},[W]),m(()=>{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||(Y(null),F(null),U(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const _=v(null);y(()=>{const e=E.current;if(!e)return;const t=new ResizeObserver(e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);k(Math.max(1,n)),M(t<768),N(!0)},60)});return t.observe(e),()=>{t.disconnect(),_.current&&clearTimeout(_.current)}},[]);const B=v(e.state.highlightedEventId);m(()=>{e.state.highlightedEventId?(Y(e.state.highlightedEventId),requestAnimationFrame(()=>{const t=E.current;if(!t)return;const n=t.querySelector(`[data-event-id="${e.state.highlightedEventId}"]`);null==n||n.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})})):B.current&&Y(null),B.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const{handleMoveStart:V,handleResizeStart:G,handleCreateStart:K,dragState:q,isDragging:X}=ai(e,{calendarRef:t,viewType:I.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(D).filter(e=>{const t=D.find(t=>t.id===e.id);return t&&pt(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:D,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{j(e.id)},isMobile:S}),J=null!==(c=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==c&&c,Q=f((t,r)=>{if(J)null==K||K(t,r);else{const t=n.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:u("newEvent")||"New Event",start:t,end:t,allDay:!0,calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"};e.addEvent(a),j(a.id)}},[J,K,e,u]),ee=p(()=>{const e=[],t=new Date(w,0,1),n=new Date(w,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[w]),te=p(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(ee,C),[ee,C]),ne=p(()=>{const e=new Date(w,0,1),t=new Date(w,11,31,23,59,59);return D.filter(n=>{if(!n.start)return!1;if(!J&&!n.allDay)return!1;const r=we(n.start,x),a=n.end?we(n.end,x):r;return r<=t&&a>=e})},[D,w,J,x]),re=p(()=>{const e=ne.map(e=>{const t=we(e.start,x),n=e.end?we(e.end,x):t;return{event:e,startMs:new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),endMs:new Date(n.getFullYear(),n.getMonth(),n.getDate(),23,59,59,999).getTime()}});return te.map(t=>{if(0===t.length)return[];const n=t[0],r=t.at(-1);if(!n||!r)return[];const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime();return e.filter(e=>e.startMs<=o&&e.endMs>=a).map(e=>e.event)})},[te,ne,x]);return Nt("div",{className:Pn,onContextMenu:e=>e.preventDefault(),children:[Nt(go,{calendar:e,viewType:I.YEAR,currentDate:b,customTitle:h.startsWith("zh")||h.startsWith("ja")?`${w}年`:`${w}`,onPrevious:()=>{const t=new Date(b);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(b);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),Nt("div",{ref:E,className:`${Fn} ${Zn}`,style:{overflow:"hidden auto"},children:Nt("div",{className:"flex w-full flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:T?1:0,transition:"opacity 0.2s ease"},children:te.map((n,o)=>Nt(ki,{rowDays:n,events:re[o],columnsPerRow:C,app:e,calendarRef:t,locale:h,isDragging:X,dragState:q,onMoveStart:V,onResizeStart:G,onCreateStart:Q,selectedEventId:P,onEventSelect:Y,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:$,onDetailPanelOpen:Z,detailPanelEventId:L,onDetailPanelToggle:F,customDetailPanelContent:r,customEventDetailDialog:a,onContextMenu:e=>{W&&U(e)},appTimeZone:x},o))})}),W&&z&&Nt(Ba,{x:z.x,y:z.y,date:z.date,viewType:I.YEAR,onClose:()=>U(null),app:e,onCreateEvent:()=>{if(z&&z.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:z.x,clientY:z.y};Q(e,z.date)}}})]})};function Ni(e,t,n,r=1,a){const o=new Date(n,t,1),i=new Date(n,t+1,0).getDate(),l=(o.getDay()-r+7)%7,s=o.getTime(),d=new Date(n,t,i,23,59,59,999).getTime(),c=e.filter(e=>!!e.start).map(e=>{const t=we(e.start,a),n=e.end?we(e.end,a):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate());return{event:e,startMs:r.getTime(),endMs:o.getTime(),eventStartDay:r,eventEndDay:o}}).filter(e=>e.startMs<=d&&e.endMs>=s);if(0===c.length)return{segments:[],maxVisualRow:-1};const u=Mn(c.map(e=>e.event));c.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:u(e.event,t.event)});const h=[],g=[];c.forEach(({event:e,startMs:r,endMs:a,eventStartDay:o,eventEndDay:i})=>{const c=Math.max(r,s),u=Math.min(a,d),m=new Date(c).getDate(),v=new Date(u).getDate(),f=l+(m-1),p=l+(v-1),y=o.getMonth()===t&&o.getFullYear()===n,b=i.getMonth()===t&&i.getFullYear()===n;let w=0;for(;;){g[w]||(g[w]=[]);let e=!1;for(let t=f;t<=p;t++)if(g[w][t]){e=!0;break}if(!e){for(let e=f;e<=p;e++)g[w][e]=!0;break}w++}h.push({id:`${e.id}::month-${t}`,event:e,startCellIndex:f,endCellIndex:p,isFirstSegment:y,isLastSegment:b,visualRowIndex:w,monthIndex:t})});const m=h.length>0?Math.max(...h.map(e=>e.visualRowIndex)):-1;return{segments:h,maxVisualRow:m}}const Si=({app:e,calendarRef:t,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,u;const{t:h,locale:y,getWeekDaysLabels:b}=An(),w=e.getCurrentDate(),D=w.getFullYear(),x=e.getEvents(),E=e.timeZone,C=Fe(E);C.setHours(0,0,0,0);const k=null!==(c=null==o?void 0:o.startOfWeek)&&void 0!==c?c:1,T=v(null),N=v(null),S=v(null),[M,O]=g(0),[H,R]=g(0),[A,P]=g(null),[L,$]=g(null),j=void 0===i?A:i,Y=void 0===s?L:s,F=e=>{l?l(e):P(e)},Z=e=>{d?d(e):$(e)},[z,U]=g(null),[W,_]=g(null),B=e.canMutateFromUI();m(()=>{B||_(null)},[B]),m(()=>{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||(F(null),Z(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const V=p(()=>{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()-k+7)%7+r;a>e&&(e=a)}return e},[D,k]),{handleMoveStart:G,handleResizeStart:K,handleCreateStart:q,dragState:X,isDragging:J}=ai(e,{calendarRef:t,viewType:I.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(x).filter(e=>{const t=x.find(t=>t.id===e.id);return t&&pt(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:x,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{U(e.id)}}),Q=null!==(u=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==u&&u,ee=f((t,r)=>{if(Q)null==q||q(t,r);else{const t=n.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:t,end:t,allDay:!0};e.addEvent(a),U(a.id)}},[Q,q,e,h]),te=p(()=>{const e=b(y,"short",k).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<V;n++)t.push(e[n%7]);return t},[y,b,V,k]),ne=p(()=>{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(!Q&&!n.allDay)return!1;const r=we(n.start,E),a=n.end?we(n.end,E):r;return r<=t&&a>=e})},[x,D,Q,E]),re=p(()=>{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()-k+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<V;)o.push(null);const i=n.toLocaleDateString(y,{month:"short"}),l=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Ni(ne,t,D,k,E),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,V,ne,k,E]),ae=f(e=>{const t=e.currentTarget;T.current&&(T.current.scrollLeft=t.scrollLeft),N.current&&(N.current.scrollTop=t.scrollTop)},[]);m(()=>{const e=()=>{if(S.current){const e=S.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;R(e=>e===t?e:t),O(e=>e===n?e:n)}},t=S.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[re]);return Nt("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:[Nt("div",{className:"col-span-2",children:Nt(go,{calendar:e,viewType:I.YEAR,currentDate:w,customTitle:y.startsWith("zh")||y.startsWith("ja")?`${D}年`:`${D}`,onPrevious:()=>{const t=new Date(w);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(w);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),Nt("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),Nt("div",{ref:T,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:Nt("div",{className:"flex",style:{minWidth:`calc(1352px + ${M}px)`},children:[Nt("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${V}, minmax(0, 1fr))`,minWidth:"1352px"},children:te.map((e,t)=>{const n=(t+k)%7;return Nt("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}`)})}),M>0&&Nt("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${M}px`}})]})}),Nt("div",{ref:N,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:Nt("div",{className:"flex min-h-full flex-col",children:[re.map(e=>Nt("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&&Nt("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${H}px`}})]})}),Nt("div",{ref:S,className:`overflow-auto ${Zn}`,onScroll:ae,children:Nt("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:re.map(n=>Nt("div",{className:"relative shrink-0 grow",style:{minHeight:`${n.minHeight}px`},children:[Nt("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${V}, minmax(0, 1fr))`},children:n.days.map((t,r)=>{const a=(r+k)%7,o=0===a||6===a;if(!t)return Nt("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-${n.monthIndex}-${r}`);const i=(e=>e.getTime()===C.getTime())(t);return Nt("div",{"data-date":`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,className:`df-hover-primary-dark-md 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 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>e.selectDate(t),onDblClick:e=>ee(e,t),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),B&&_({x:e.clientX,y:e.clientY,date:t})})(e,t),children:Nt("span",{className:`flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium ${i?"df-fill-primary font-bold shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:t.getDate()})},t.getTime())})}),n.eventSegments.length>0&&Nt("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:Nt("div",{className:"relative h-full w-full",children:n.eventSegments.map(n=>Nt("div",{className:"pointer-events-auto",children:Nt(uo,{event:n.event,isAllDay:!!n.event.allDay,viewType:I.YEAR,yearSegment:n,columnsPerRow:V,isBeingDragged:J&&X.eventId===n.event.id,selectedEventId:j,onMoveStart:G,onResizeStart:K,onEventSelect:F,onDetailPanelToggle:Z,newlyCreatedEventId:z,onDetailPanelOpen:()=>U(null),calendarRef:t,app:e,detailPanelEventId:Y,customDetailPanelContent:r,customEventDetailDialog:a,firstHour:0,hourHeight:0,onEventUpdate:t=>e.updateEvent(t.id,t),onEventDelete:t=>e.deleteEvent(t),appTimeZone:E})},n.id))})})]},n.monthIndex))})}),B&&W&&Nt(Ba,{x:W.x,y:W.y,date:W.date,viewType:I.YEAR,onClose:()=>_(null),app:e,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:W.x,clientY:W.y};ee(e,W.date)}})]})},Mi=({date:e,events:t,anchorEl:n,position:r,onClose:a,locale:i,app:l,customContent:s,appTimeZone:d})=>{const{t:u}=An(),h=v(null);m(()=>{const e=e=>{const t=e.target;!h.current||h.current.contains(t)||n.contains(t)||a()},t=e=>{"Escape"===e.key&&a()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n,a]);const g=l.getCalendars(),f=new Map(g.map(e=>[e.id,e])),p=e.toLocaleDateString(i,{weekday:"long",month:"long",day:"numeric"}),y=Nt(o,{children:[Nt("div",{className:"border-b border-gray-100 px-4 py-3 dark:border-gray-700",children:Nt("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:p})}),Nt("div",{className:"max-h-60 overflow-y-auto py-1",children:0===t.length?Nt("div",{className:"px-4 py-3 text-center text-xs text-gray-400",children:"No events"}):t.map(e=>{var t,n;const r=e.calendarId?f.get(e.calendarId):void 0,a=null!==(n=null===(t=null==r?void 0:r.colors)||void 0===t?void 0:t.lineColor)&&void 0!==n?n:"#3b82f6";let o="";if(!e.allDay&&e.start){if(o=we(e.start,d).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1}),e.end){o+=` – ${we(e.end,d).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1})}`}}return Nt("div",{className:"flex items-start gap-2.5 rounded px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800",children:[Nt("div",{className:"mt-1.5 h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:a}}),Nt("div",{className:"min-w-0 flex-1",children:[Nt("div",{className:"truncate text-xs font-medium text-gray-900 dark:text-gray-100",children:e.title}),e.allDay&&Nt("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:u("allDay")}),o&&Nt("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:o})]})]},e.id)})})]});return c(Nt("div",{ref:h,"data-grid-day-popup":!0,className:"animate-in fade-in zoom-in-95 fixed z-50 w-64 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl duration-100 dark:border-gray-700 dark:bg-gray-900",style:{top:r.top,left:r.left},children:s?s(e,t):y}),document.body)};function Ii(e,t,n,r){const a=new Map,o=new Date(t,0,1);o.setHours(0,0,0,0);const i=new Date(t,11,31,23,59,59,999);for(const l of e){if(!l.start)continue;if(!n&&!l.allDay)continue;const e=we(l.start,r),s=l.end?we(l.end,r):new Date(e);if(e.setHours(0,0,0,0),s.setHours(0,0,0,0),e>i||s<o)continue;const d=e<o?new Date(o):new Date(e),c=s>i?new Date(t,11,31):new Date(s);d.setHours(0,0,0,0),c.setHours(0,0,0,0);const u=864e5,h=d.getTime(),g=Math.round((c.getTime()-h)/u);for(let e=0;e<=g;e++){const t=new Date(h+e*u),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=a.get(n);r?r.push(l):a.set(n,[l])}}return a}function Oi(e){const t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;let a=t.right+8;a+256>n-8&&(a=t.left-256-8),a=Math.max(8,Math.min(a,n-256-8));let o=t.top;return o+220>r-8&&(o=r-220-8),o=Math.max(8,o),{top:o,left:a}}const Hi=({app:e,config:t})=>{var n,r,a;const{locale:o,getWeekDaysLabels:i}=An(),l=e.getCurrentDate(),s=l.getFullYear(),d=e.getEvents(),c=null!==(n=null==t?void 0:t.startOfWeek)&&void 0!==n?n:1,u=null!==(r=null==t?void 0:t.showTimedEventsInYearView)&&void 0!==r&&r,h=null!==(a=null==t?void 0:t.gridHeatmapLevels)&&void 0!==a?a:5,v=e.timeZone,y=p(()=>{const e=Fe(v);return e.setHours(0,0,0,0),e},[v]),[b,w]=g(null);m(()=>{if(!b)return;const e=e=>{const t=e.target;t.closest("[data-grid-day-popup]")||t.closest("[data-grid-day-cell]")||w(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]);const D=p(()=>Ii(d,s,u,v),[d,s,u,v]),x=p(()=>Ii(d,s,!0,v),[d,s,v]),E=p(()=>i(o,"narrow",c).map(e=>o.startsWith("zh")?e.at(-1):e.charAt(0).toUpperCase()),[o,i,c]),C=p(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(s,t,1),r=new Date(s,t+1,0).getDate(),a=[];for(let e=(n.getDay()-c+7)%7-1;e>=0;e--)a.push({date:new Date(s,t,-e),isCurrentMonth:!1});for(let e=1;e<=r;e++)a.push({date:new Date(s,t,e),isCurrentMonth:!0});let i=1;for(;a.length<42;)a.push({date:new Date(s,t+1,i++),isCurrentMonth:!1});const l=n.toLocaleDateString(o,{month:"long"}),d=l.charAt(0).toUpperCase()+l.slice(1);e.push({monthIndex:t,monthName:d,cells:a})}return e},[s,o,c]),k=f((n,r,a)=>{var o,i;const l=null!==(o=null==t?void 0:t.gridDateClick)&&void 0!==o?o:"popup";if("function"==typeof l){const e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`;return void l(r,null!==(i=x.get(e))&&void 0!==i?i:[])}if("popup"===l){const e=n.currentTarget;b&&b.date.getTime()===r.getTime()&&b.monthIndex===a?w(null):w({date:r,monthIndex:a,anchorEl:e,position:Oi(e)})}else"day-view"===l&&(e.setCurrentDate(r),e.changeView(I.DAY))},[t,e,b,x]),T=f(n=>{var r,a;const o=null!==(r=null==t?void 0:t.gridDateDoubleClick)&&void 0!==r?r:"day-view";if("function"==typeof o){const e=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`;return void o(n,null!==(a=x.get(e))&&void 0!==a?a:[])}"day-view"===o&&(w(null),e.setCurrentDate(n),e.changeView(I.DAY))},[t,e,x]),N=p(()=>{var e;if(!b)return[];const t=`${b.date.getFullYear()}-${String(b.date.getMonth()+1).padStart(2,"0")}-${String(b.date.getDate()).padStart(2,"0")}`;return[...null!==(e=x.get(t))&&void 0!==e?e:[]].toSorted((e,t)=>{const n=!!e.allDay;return n!==!!t.allDay?n?-1:1:0})},[b,x]);return Nt("div",{className:Pn,children:[Nt(go,{calendar:e,viewType:I.YEAR,currentDate:l,customTitle:o.startsWith("zh")||o.startsWith("ja")?`${s}年`:`${s}`,onPrevious:()=>{const t=new Date(l);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(l);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>e.goToToday()}),Nt("div",{className:"grid min-h-0 flex-1 gap-3 p-3",style:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(3, 1fr)"},children:C.map(e=>Nt("div",{className:"df-year-grid-month flex h-full min-h-0 flex-col rounded-lg border border-gray-100 bg-white p-2 dark:border-gray-800 dark:bg-gray-900",children:[Nt("div",{className:"mb-1 shrink-0 text-xs font-semibold text-gray-900 dark:text-gray-100",children:e.monthName}),Nt("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:Nt("div",{className:"grid h-full w-full gap-px",style:{gridTemplateColumns:"repeat(7, 1fr)",gridTemplateRows:"repeat(7, 1fr)"},children:[E.map((e,t)=>Nt("div",{className:"flex items-center justify-center text-[9px] font-medium text-gray-400 dark:text-gray-500",children:e},t)),e.cells.map(({date:t,isCurrentMonth:n},r)=>{var a,o;const i=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,l=n&&null!==(o=null===(a=D.get(i))||void 0===a?void 0:a.length)&&void 0!==o?o:0;var s,d;return Nt("div",{"data-grid-day-cell":!0,className:"cursor-pointer rounded-sm transition-colors hover:opacity-80",style:n?(d=h,0===(s=l)?{}:{backgroundColor:`var(--heat-${Math.min(s,d)})`}):{},onClick:n=>k(n,t,e.monthIndex),onDblClick:()=>T(t),children:Nt("div",{className:"flex h-full w-full items-center justify-center",children:Nt("span",{className:"flex h-4 w-4 items-center justify-center rounded-full text-[9px] font-medium "+(t.getTime()===y.getTime()?"df-fill-primary font-bold":n?l>0?l>=4?"text-white":"text-gray-800 dark:text-gray-100":"text-gray-500 dark:text-gray-400":"text-gray-300 dark:text-gray-600"),children:t.getDate()})})},`${e.monthIndex}-${r}`)})]})})]},e.monthIndex))}),b&&Nt(Mi,{date:b.date,events:N,anchorEl:b.anchorEl,position:b.position,onClose:()=>w(null),locale:o,app:e,customContent:null==t?void 0:t.gridPopupContent,appTimeZone:v})]})},Ri=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return"fixed-week"===n?Nt(Si,Object.assign({},e)):"grid"===n?Nt(Hi,{app:e.app,config:e.config}):Nt(Ti,Object.assign({},e))},Ai={},Pi=e=>i(ii,Object.assign(Object.assign({},e),{viewType:I.YEAR,originalComponent:Ri,className:"year-view-factory"}));Pi.displayName="YearViewAdapter";const Li=(e={})=>{const t=Object.assign(Object.assign({},Ai),e);return{type:I.YEAR,component:Pi,config:t}};function $i(e){return[di(null==e?void 0:e.day),pi(null==e?void 0:e.week),Ei(null==e?void 0:e.month)]}const ji={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function Yi(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 Fi(t={}){const n=Object.assign(Object.assign({},ji),t);let r;const a={getAll:()=>r.getAllEvents(),getById:e=>r.getAllEvents().find(t=>t.id===e),add:e=>{if(n.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(n.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,r.getCurrentDate()).length>=n.maxEventsPerDay)throw new Error(`Maximum events per day (${n.maxEventsPerDay}) exceeded`)}if(r.addEvent(e),n.enableAutoRecalculate){const e=Yi(r.getCurrentDate());r.state.events=dt(r.getAllEvents(),e)}},update:(t,o)=>e(this,void 0,void 0,function*(){const e=a.getById(t);if(!e)throw new Error(`Event with id ${t} not found`);const i=Object.assign(Object.assign({},e),o);if(n.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(yield r.updateEvent(t,o),n.enableAutoRecalculate){const e=Yi(r.getCurrentDate());r.state.events=dt(r.getAllEvents(),e)}}),delete:t=>e(this,void 0,void 0,function*(){yield r.deleteEvent(t)}),getByDate:e=>r.getAllEvents().filter(t=>{const n=Y(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)=>r.getAllEvents().filter(n=>{const r=Y(n.start),a=Y(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>r.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>dt(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"),t},filterEvents:(e,t)=>e.filter(t)};return{name:"events",config:n,install:e=>{r=e},api:a}}export{Zr as AlertCircle,Fr as AudioLines,ra as BlossomColorPicker,kt as CalendarApp,uo as CalendarEvent,ae as CalendarRegistry,Pa as CalendarRenderer,Nr as Check,Cr as ChevronDown,Dr as ChevronRight,Sr as ChevronsUpDown,na as ContentSlot,$a as ContextMenu,_a as ContextMenuColorPicker,ja as ContextMenuItem,Fa as ContextMenuLabel,Ya as ContextMenuSeparator,la as CreateCalendarDialog,Aa as CustomRenderingStore,va as DayflowRangePicker,aa as DefaultColorPicker,pa as DefaultEventDetailDialog,ao as DefaultEventDetailPanel,Va as EventContextMenu,Ba as GridContextMenu,O as LAYOUT_CONFIG,T as LOCALES,Hr as Loader2,oa as LoadingButton,Rn as LocaleContext,Vr as LocaleProvider,wa as MiniCalendar,$r as PanelRightClose,jr as PanelRightOpen,kr as Plus,He as TIME_STEP,A as TimeZone,H as VIRTUAL_MONTH_SCROLL_CONFIG,I as ViewType,R as WeekDataCache,V as addDays,Pt as buildParseRegExp,lt as calculateDayIndex,or as calendarPickerDropdown,jn as cancelButton,Ur as capitalize,dn as clipboardStore,Sn as compareAllDayDisplayPriority,_t as conditionalTheme,nn as convertDateEvent,rn as convertDateEventWithTimeZone,Dn as convertToDayFlowEvent,Mn as createAllDayDisplayComparator,en as createAllDayEvent,X as createDateWithHour,di as createDayView,qt as createEvent,it as createEventWithDate,mt as createEventWithPlainDateTime,ht as createEventWithRealDate,vt as createEventWithZonedDateTime,Jt as createEvents,Fi as createEventsPlugin,Ei as createMonthView,$i as createStandardViews,F as createTemporalWithHour,tn as createTimedEvent,Xt as createTimezoneEvent,Qt as createTimezoneEvents,pi as createWeekView,Li as createYearView,xe as dateToPlainDate,Ee as dateToPlainDateTime,Ce as dateToZonedDateTime,_ as daysBetween,B as daysDifference,Cn as downloadICS,k as en,mn as escapeICSValue,q as extractHourFromDate,Ne as extractHourFromTemporal,bn as extractVEvents,fn as foldLine,It as formatDate,St as formatDateConsistent,gn as formatDateToICSTimestamp,Pe as formatEventTimeRange,hn as formatICSDate,Mt as formatMonthYear,pn as formatProperty,Yt as formatTemporal,Re as formatTime,qe as generateDayData,En as generateICS,$e as generateSecondaryTimeSlots,bt as generateUniKey,yn as generateVEvent,Je as generateWeekData,et as generateWeekRange,Qe as generateWeeksData,nt as getAllDayEventsForDay,Tn as getAllDayRangeMetrics,le as getCalendarColorsForHex,Ke as getCurrentWeekDates,rt as getDateByDayIndex,an as getDateObj,ct as getDayIndexByDate,Q as getEndOfDay,W as getEndOfTemporal,se as getEventBgColor,Ae as getEventEndHour,de as getEventTextColor,tt as getEventsForDay,ut as getEventsForWeek,zr as getIntlLabel,ue as getLineColor,_r as getMonthLabels,Xe as getMonthYearOfWeek,Ze as getNextHourRangeInTimeZone,Ye as getNowInTimeZone,Me as getPlainDate,ln as getSearchHeaderInfo,ce as getSelectedBgColor,J as getStartOfDay,U as getStartOfTemporal,yt as getTestEvents,je as getTimezoneDisplayLabel,Fe as getTodayInTimeZone,Wr as getWeekDaysLabels,ee as getWeekNumber,Ge as getWeekRange,$t as getZoneId,sn as groupSearchResults,pt as hasEventChanged,kn as importICSFile,L as isDate,wt as isDeepEqual,ft as isEventDeepEqual,st as isEventInWeek,ne as isMultiDayEvent,z as isMultiDayTemporalEvent,fe as isPlainDate,pe as isPlainDateTime,te as isSameDay,Z as isSamePlainDate,Ie as isSameTemporal,M as isValidLocale,ye as isZonedDateTime,Bt as mergeClasses,Rt as mergeFormatTemplate,Be as monthNames,Ft as normalizeCssWidth,on as normalizeDate,S as normalizeLocale,ve as normalizeTimeZoneValue,jt as normalizeToZoned,G as now,Ht as pad,cn as pad2,xn as parseICS,un as parseICSDate,Lt as parseTemporalString,wn as parseVEventLines,ke as plainDateTimeToDate,Te as plainDateToDate,dt as recalculateEventDays,ni as registerDragImplementation,N as registerLocale,Ma as registerSidebarImplementation,Vt as resolveAppliedTheme,In as restoreTimedDragFromAllDayTransition,Ue as restoreVisualEventToCanonical,ze as restoreVisualTimedTemporalToCanonical,Le as roundToTimeStep,zt as scrollbarTakesSpace,Se as setHourInTemporal,Ve as shortMonthNames,sr as sidebarContainer,dr as sidebarHeader,ur as sidebarHeaderTitle,cr as sidebarHeaderToggle,Nn as sortAllDayByTitle,La as subscribeCalendar,Br as t,be as temporalToDate,we as temporalToVisualDate,De as temporalToVisualTemporal,Wt as themeClasses,Ut as themeCn,K as today,vn as unescapeICSValue,at as updateEventDateAndDay,gt as updateEventWithRealDate,ai as useDragForView,An as useLocale,Oa as useSidebarBridge,We as weekDays,_e as weekDaysFullName,j as zonedDateTimeToDate};
|
|
1
|
+
import{__awaiter as e,__rest as t}from"tslib";import{Temporal as n}from"temporal-polyfill";import{options as r,createContext as a,Fragment as o,h as i,render as l,isValidElement as s,cloneElement as d}from"preact";import{createPortal as c,forwardRef as u,memo as h}from"preact/compat";export{createPortal}from"preact/compat";import{useState as g,useEffect as m,useRef as v,useCallback as f,useMemo as p,useLayoutEffect as y,useContext as b}from"preact/hooks";import{BlossomColorPicker as D,hexToHsl as w,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}?\nDoing so will move all the events from {sourceName} to {targetName} and {sourceName} will be deleted.\nThis 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",subscribeCalendar:"Subscribe to Calendar",subscribeCalendarTitle:"Enter the URL of the calendar you want to subscribe to.",calendarUrl:"Calendar URL",calendarUrlPlaceholder:"https://example.com/calendar.ics",subscribe:"Subscribe",fetchingCalendar:"Fetching calendar...",subscribeError:"Failed to fetch calendar. Please check the URL and try again."}},T={en:k};function M(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 N(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",e.RESOURCE="resource"}(I||(I={}));const O={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},R={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 H{constructor(e=R.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=H.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=H.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 A;function P(e){var t;if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;if(e instanceof n.PlainDate)return!0;const r=e;return"PlainDate"===(null===(t=r.constructor)||void 0===t?void 0:t.name)||!("hour"in r)&&!("timeZone"in r)&&"year"in r&&"month"in r&&"day"in r}function L(e){return e instanceof Date}function $(e,t=n.Now.timeZoneId()){return n.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function j(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 Y(e,t){if(e instanceof Date)return e;if(P(e))return function(e,t=n.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime)try{return j(e.toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(e.year,e.month-1,e.day)}(e,t);if(e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)){const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}if(e&&"object"==typeof e&&"year"in e){return j(e)}return new Date(e)}function F(e,t){const r=Math.floor(t),a=Math.round(60*(t-r));if(P(e))return n.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:r,minute:a});if("function"==typeof e.with)return e.with({hour:r,minute:a,second:0,millisecond:0});const o=e;return n.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function Z(e,t){if(e instanceof Date&&t instanceof Date)return e.toDateString()===t.toDateString();const r=e=>{if(e instanceof Date)return t=e,n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()});var t;if(P(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const r=e;return n.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(e),o=r(t);return 0===n.PlainDate.compare(a,o)}function z(e,t){return!Z(e,t)}function U(e,t=n.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(P(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:0,minute:0})})}const r=e;return(P(e)?e:n.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:0,minute:0})})}function W(e,t=n.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(P(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=e;return(P(e)?e:n.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:t,plainTime:n.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function _(e,t){const r=e=>{if(P(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const t=e;return n.PlainDate.from({year:t.year,month:t.month,day:t.day})},a=r(e),o=r(t);return a.until(o).days}function B(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 V(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function G(e=n.Now.timeZoneId()){return n.Now.zonedDateTimeISO(e)}function K(e=n.Now.timeZoneId()){return n.Now.plainDateISO(e)}!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.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.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.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.KARACHI="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.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"}(A||(A={}));const q=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(P(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)},X=(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 F(e,t)},J=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return U(e)},Q=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return W(e)},ee=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)},te=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Z(e instanceof Date?n.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):P(e)?e:e.toPlainDate(),t instanceof Date?n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):P(t)?t:t.toPlainDate())},ne=(e,t)=>!te(e,t),re=e=>!e.readOnly&&!e.subscription,ae=[{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 oe{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)}):ae.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]}getDefaultWritableCalendar(){const e=this.getDefaultCalendar();return e&&re(e)?e:this.getAll().find(re)}setTheme(e){this.currentTheme=e}getTheme(){return this.currentTheme}resolveColors(e,t){const n=t||this.currentTheme,r=oe.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 ie=new oe;function le(){return ie}function se(e){const t=ae.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 de=(e,t)=>(t||le()).resolveColors(e).eventColor,ce=(e,t)=>(t||le()).resolveColors(e).textColor,ue=(e,t)=>(t||le()).resolveColors(e).eventSelectedColor,he=(e,t)=>(t||le()).resolveColors(e).lineColor;const ge=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)}},me=new Map;function ve(e){try{return new Intl.DateTimeFormat("en",{timeZone:e}).resolvedOptions().timeZone}catch(e){return}}function fe(e){if(!e||"string"!=typeof e)return;const t=e.trim();if(!t)return;const n=me.get(t);if(n)return n;const r=ve(t);if(r)return me.set(t,r),r;const a=Object.values(A).find(e=>e.toLowerCase()===t.toLowerCase());if(a){const e=ve(a);return e?(me.set(t,e),e):(me.set(t,a),a)}if("function"==typeof Intl.supportedValuesOf){const e=Intl.supportedValuesOf("timeZone").find(e=>e.toLowerCase()===t.toLowerCase());if(e)return me.set(t,e),e}const o=ve(t.split("/").map(e=>e.split("_").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("_")).join("/"));if(o)return me.set(t,o),o;const i=ve(t.split("/").map((e,t)=>0===t?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("/"));return i?(me.set(t,i),i):t}function pe(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function ye(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&!("timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function be(e){return null!==e&&"object"==typeof e&&("timeZone"in e||"timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function De(e){if(e instanceof Date)return e;if(pe(e))return new Date(e.year,e.month-1,e.day);if(ye(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(be(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):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 we(e,t){if(e instanceof Date)return e;if(!t)return De(e);const r=fe(t);if(!r)return De(e);try{if(be(e)){const t=("function"==typeof e.withTimeZone?e:n.ZonedDateTime.from(e)).withTimeZone(r);return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}if(ye(e)){const t="function"==typeof e.toZonedDateTime?e:n.PlainDateTime.from(e),a=t.toZonedDateTime(n.Now.timeZoneId()).withTimeZone(r);return new Date(a.year,a.month-1,a.day,a.hour,a.minute,a.second||0,a.millisecond||0)}}catch(e){ge.error("Failed to shift visual timezone:",e)}return De(e)}function xe(e,t){if(!t)return e;const r=fe(t);if(!r)return e;try{if(be(e)){return("function"==typeof e.withTimeZone?e:n.ZonedDateTime.from(e)).withTimeZone(r)}if(ye(e)){return("function"==typeof e.toZonedDateTime?e:n.PlainDateTime.from(e)).toZonedDateTime(n.Now.timeZoneId()).withTimeZone(r)}}catch(e){ge.error("Failed to shift visual temporal:",e)}return e}function Ee(e){return n.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Ce(e){return n.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function ke(e,t=n.Now.timeZoneId()){return n.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t})}function Te(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}function Me(e){return new Date(e.year,e.month-1,e.day)}function Se(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(pe(e))return 0;const t=e;return t.hour+t.minute/60}function Ne(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return be(e),e.with({hour:n,minute:r,second:0,millisecond:0})}function Ie(e){return e instanceof Date?Ee(e):pe(e)?e:(ye(e),e.toPlainDate())}function Oe(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=Ie(e),r=Ie(t);return n.equals(r)}const Re=e=>new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,Math.floor(e.millisecond)),He=.25,Ae=(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")}`},Pe=e=>{if(!e.end)return 0;const t=q(e.end);if(e.allDay||!e.start)return t;const n=Y(e.start),r=Y(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},Le=(e,t="24h")=>{const n=q(e.start),r=Pe(e);return`${Ae(n,0,t)} - ${Ae(r,0,t)}`},$e=e=>.25*Math.round(e/.25),je=(e,t,r="24h",a=new Date,o)=>{const i=fe(t);if(!i)return e.map(()=>"");const l=null!=o?o:n.Now.timeZoneId(),s=a.getFullYear(),d=a.getMonth()+1,c=a.getDate();return e.map(e=>{try{const t=e.hour%24,a=n.ZonedDateTime.from({year:s,month:d,day:c,hour:t,minute:0,second:0,timeZone:l}).withTimeZone(i);return Ae(a.hour,a.minute,r)}catch(e){return""}})},Ye=(e,t=new Date)=>{var n,r;const a=fe(e);if(!a)return"";try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:a,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:a}catch(e){return a}},Fe=e=>{var t;const r=null!==(t=e?fe(e):void 0)&&void 0!==t?t:n.Now.timeZoneId();return Re(n.Now.zonedDateTimeISO(r))},Ze=e=>{var t;const r=null!==(t=e?fe(e):void 0)&&void 0!==t?t:n.Now.timeZoneId(),a=n.Now.plainDateISO(r);return new Date(a.year,a.month-1,a.day)},ze=e=>{var t;const r=null!==(t=e?fe(e):void 0)&&void 0!==t?t:n.Now.timeZoneId(),a=n.Now.zonedDateTimeISO(r).add({hours:1}).with({minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{start:Re(a),end:Re(a.add({hours:1}))}},Ue=(e,t,r)=>{var a,o;const i=Y(e);if(be(t)){const e=null!==(a=fe(r))&&void 0!==a?a:n.Now.timeZoneId(),o=(e=>{var t;const r=e;return r.timeZoneId||("string"==typeof r.timeZone?r.timeZone:null===(t=r.timeZone)||void 0===t?void 0:t.id)||n.Now.timeZoneId()})(t);return ke(i,e).toInstant().toZonedDateTimeISO(o)}return ye(t)?Ce(i):be(e)?e:ke(i,null!==(o=fe(r))&&void 0!==o?o:n.Now.timeZoneId())},We=(e,t,n)=>t.allDay?Object.assign(Object.assign({},t),{allDay:!0,start:pe(t.start)?t.start:Ee(Y(t.start)),end:pe(t.end)?t.end:Ee(Y(t.end))}):Object.assign(Object.assign({},t),{allDay:!1,start:Ue(t.start,e.allDay?t.start:e.start,n),end:Ue(t.end,e.allDay?t.end:e.end,n)}),_e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Be=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ve=["January","February","March","April","May","June","July","August","September","October","November","December"],Ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ke=(e,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}},qe=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return _e.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()}})},Xe=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:Ve[r],shortMonthName:Ge[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},Je=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:Ve[a],monthIndex:a,year:o}},Qe=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(Xe(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Je(t)}},et=(e,t=3)=>{const n=5*t,{monday:r}=Ke(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(Qe(t))}return a};function tt(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(Qe(t))}return r}const nt=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),rt=(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=Y(t.start);a.setHours(0,0,0,0);const o=Y(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),at=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},ot=(e,t,r)=>{const a=at(r,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?n.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):n.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:n.Now.timeZoneId()}),end:e.allDay?n.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):n.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:n.Now.timeZoneId()})})},it=(e,t)=>t?n.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):n.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:n.Now.timeZoneId()}),lt=(e,t)=>{var n,r;const a=at(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:it(a,o),end:it(a,o)})},st=(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)},dt=(e,t)=>{const n=st(e,t);return n>=0&&n<=6},ct=(e,t)=>e.map(e=>{const n=Y(e.start),r=st(n,t);return Object.assign(Object.assign({},e),{day:r})}),ut=(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)},ht=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=Y(e.start);return r>=t&&r<=n}).map(e=>{const n=st(Y(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},gt=(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:it(a,o),end:it(a,o)})},mt=(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:it(a,o),end:it(a,o)})},vt=(e,t)=>{var r,a;const o=at(t,null!==(r=e.day)&&void 0!==r?r:0);if(null!==(a=e.allDay)&&void 0!==a&&a){const t=n.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},e),{start:t,end:t})}const i=n.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({},e),{start:i,end:i})},ft=(e,t,r)=>{var a,o;const i=at(t,null!==(a=e.day)&&void 0!==a?a:0);if(null!==(o=e.allDay)&&void 0!==o&&o){const t=n.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},e),{start:t,end:t})}const l=n.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({},e),{start:l,end:l})},pt=(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()),yt=(e,t)=>Y(e.start).getTime()!==Y(t.start).getTime()||Y(e.end).getTime()!==Y(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function bt(){const e=new Date,t=e.getDay(),r=new Date(e),a=0===t?-6:1-t;r.setDate(e.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(e=>{const t=new Date(r);if(t.setDate(r.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:n.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),o=Math.round(60*(e.startHour-a)),i=Math.floor(e.endHour),l=Math.round(60*(e.endHour-i));return{id:e.id,title:e.title,start:n.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:a,minute:o,timeZone:n.Now.timeZoneId()}),end:n.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:i,minute:l,timeZone:n.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})}function Dt(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function wt(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)||!wt(a[e],o[e]))return!1;return!0}function xt(e){return{allDaySortComparator:e.allDaySortComparator,calendars:e.calendars,customMobileEventRenderer:e.customMobileEventRenderer,locale:e.locale,readOnly:e.readOnly,switcherMode:e.switcherMode,theme:e.theme,timeZone:e.timeZone,useCalendarHeader:e.useCalendarHeader,useEventDetailDialog:e.useEventDetailDialog,views:e.views}}function Et(e){return{callbacks:e.callbacks,syncableConfig:xt(e)}}function Ct(e,t){return e===t?null:{callbacks:t}}function kt(e,t){const n={};return e.views!==t.views&&(n.views=t.views),wt(e.calendars,t.calendars)||(n.calendars=t.calendars),wt(e.theme,t.theme)||(n.theme=t.theme),e.useEventDetailDialog!==t.useEventDetailDialog&&(n.useEventDetailDialog=t.useEventDetailDialog),e.useCalendarHeader!==t.useCalendarHeader&&(n.useCalendarHeader=t.useCalendarHeader),e.customMobileEventRenderer!==t.customMobileEventRenderer&&(n.customMobileEventRenderer=t.customMobileEventRenderer),e.switcherMode!==t.switcherMode&&(n.switcherMode=t.switcherMode),wt(e.locale,t.locale)||(n.locale=t.locale),wt(e.readOnly,t.readOnly)||(n.readOnly=t.readOnly),e.allDaySortComparator!==t.allDaySortComparator&&(n.allDaySortComparator=t.allDaySortComparator),e.timeZone!==t.timeZone&&(n.timeZone=t.timeZone),n}function Tt(e,t,n){const r=Et(n),a=Ct(t.callbacks,r.callbacks);a&&e.updateConfig(a);const o=kt(t.syncableConfig,r.syncableConfig);return Object.keys(o).length>0&&e.updateConfig(o),r}function Mt(e){let t=e().allDaySortComparator;const n=(e,n)=>{var r;return null!==(r=null==t?void 0:t(e,n))&&void 0!==r?r:0};return()=>{const r=e();return t=r.allDaySortComparator,Object.assign(Object.assign({},r),{allDaySortComparator:r.allDaySortComparator?n:void 0})}}const St={hasChanges:!1,requiresRender:!1},Nt=(e,t)=>{if(e===t)return St;const n=typeof e,r=typeof t;if("function"===n||"function"===r)return"function"===n&&"function"===r?{hasChanges:!0,requiresRender:!1}:{hasChanges:!0,requiresRender:!0};if(e instanceof Date&&t instanceof Date){const n=e.getTime()!==t.getTime();return{hasChanges:n,requiresRender:n}}if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t))return{hasChanges:!0,requiresRender:!0};if(e.length!==t.length)return{hasChanges:!0,requiresRender:!0};let n=!1,r=!1;return e.forEach((e,a)=>{const o=Nt(e,t[a]);n=n||o.hasChanges,r=r||o.requiresRender}),{hasChanges:n,requiresRender:r}}if("object"!==n||null===e||"object"!==r||null===t)return{hasChanges:!0,requiresRender:!0};if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return{hasChanges:!0,requiresRender:!0};const a=e,o=t,i=Object.keys(a),l=Object.keys(o);if(i.length!==l.length)return{hasChanges:!0,requiresRender:!0};let s=!1,d=!1;for(const e of i){if(!l.includes(e))return{hasChanges:!0,requiresRender:!0};const t=Nt(a[e],o[e]);s=s||t.hasChanges,d=d||t.requiresRender}return{hasChanges:s,requiresRender:d}},It=(e,t)=>e?e.component!==t.component||e.label!==t.label?{hasChanges:!0,requiresRender:!0}:Nt(e.config,t.config):{hasChanges:!0,requiresRender:!0};class Ot{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=Ot.normalizeChanges(this.pendingChanges);return this.isInTransaction=!1,this.pendingChanges=[],t.length>0?null===(e=this.onEventBatchChange)||void 0===e?void 0:e.call(this,t):void 0}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);return 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);return this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);if(t)return 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;if(!this.isInTransaction)return null===(t=this.onEventChange)||void 0===t?void 0:t.call(this,e);this.pendingChanges.push(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 Rt{constructor(e,t,n,r,a,o){this.state=e,this.registry=t,this.getCallbacks=n,this.notify=r,this.triggerRender=a,this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.externalEvents=new Map,this.MAX_UNDO_STACK=50,this.store=new Ot(o),this.setupStoreListeners()}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a;this.syncExternalEventsToState();let o=null;return"create"===e.type?o=null===(n=(t=this.getCallbacks()).onEventCreate)||void 0===n?void 0:n.call(t,e.event):"update"===e.type&&(o=null===(a=(r=this.getCallbacks()).onEventUpdate)||void 0===a?void 0:a.call(r,e.after)),this.triggerRender(),this.notify(),null!=o?o:void 0},this.store.onEventBatchChange=e=>{var t,n;this.syncExternalEventsToState();let r=null;return"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(r=null===(n=(t=this.getCallbacks()).onEventBatchChange)||void 0===n?void 0:n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify(),null!=r?r:void 0}}getStore(){return this.store}pushToUndo(e){this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()}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 Ot(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())}applyEventsChanges(e,t,n){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){ge.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){ge.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}addEvent(e){this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)}addExternalEvents(e,t){const n=t.map(t=>Object.assign(Object.assign({},t),{calendarId:e}));this.externalEvents.set(e,n),this.syncExternalEventsToState(),this.notify()}syncExternalEventsToState(){const e=this.store.getAllEvents(),t=new Map;if(e.forEach(e=>t.set(e.id,e)),this.externalEvents.size>0)for(const e of this.externalEvents.values())e.forEach(e=>t.set(e.id,e));this.state.events=Array.from(t.values())}updateEvent(t,n,r,a){return e(this,void 0,void 0,function*(){if(a&&(this.pendingChangeSource=a),r?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),r){const e=this.state.events.findIndex(e=>e.id===t);if(-1===e)throw new Error(`Event with id ${t} not found`);const r=Object.assign(Object.assign({},this.state.events[e]),n);return this.state.events=[...this.state.events.slice(0,e),r,...this.state.events.slice(e+1)],void this.notify()}yield this.store.updateEvent(t,n)})}deleteEvent(t){return e(this,void 0,void 0,function*(){var e,n;yield null===(n=(e=this.getCallbacks()).onEventDelete)||void 0===n?void 0:n.call(e,t),this.pendingSnapshot=null,this.pushToUndo(),yield this.store.deleteEvent(t)})}getAllEvents(){return[...this.state.events]}getEvents(){const e=this.state.events||[],t=new Set(this.registry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!!e.calendarId&&t.has(e.calendarId))}onEventClick(e){var t,n;null===(n=(t=this.getCallbacks()).onEventClick)||void 0===n||n.call(t,e)}onMoreEventsClick(e){var t,n;null===(n=(t=this.getCallbacks()).onMoreEventsClick)||void 0===n||n.call(t,e)}highlightEvent(e){var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}selectEvent(e){var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}dismissUI(){var e,t;null===(t=(e=this.getCallbacks()).onDismissUI)||void 0===t||t.call(e),this.notify()}}class Ht{constructor(e,t,n,r){this.state=e,this.getCallbacks=t,this.notify=n,this.visibleMonth=new Date(r.getFullYear(),r.getMonth(),1)}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.getCallbacks()).onViewChange)||void 0===n||n.call(t,e),this.handleVisibleRangeChange("viewChange"),this.notify()}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}emitVisibleRange(e,t,n="navigation"){var r,a;null===(a=(r=this.getCallbacks()).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)}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}=Ke(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}=Ke(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}}}setCurrentDate(e){var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.handleVisibleRangeChange("navigation"),this.notify()}getCurrentDate(){return new Date(this.state.currentDate)}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.getCallbacks()).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())}getVisibleMonth(){return new Date(this.visibleMonth)}goToToday(){const e=n.Now.plainDateISO(this.state.timeZone),t=new Date(e.year,e.month-1,e.day);this.setCurrentDate(t)}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)}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)}selectDate(e){var t,n;this.setCurrentDate(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,new Date(e))}}class At{constructor(e,t){this.state=e,this.notify=t}install(e,t){this.state.plugins.has(e.name)?ge.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(t))}getPlugin(e){const t=this.state.plugins.get(e);return null==t?void 0:t.api}hasPlugin(e){return this.state.plugins.has(e)}getPluginConfig(e){const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}}updatePluginConfig(e,t){const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())}}class Pt{constructor(t){var r,a,o,i,l;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.changeView=e=>this.navigation.changeView(e),this.getCurrentView=()=>this.navigation.getCurrentView(),this.emitVisibleRange=(e,t,n)=>this.navigation.emitVisibleRange(e,t,n),this.handleVisibleRangeChange=e=>this.navigation.handleVisibleRangeChange(e),this.setCurrentDate=e=>this.navigation.setCurrentDate(e),this.getCurrentDate=()=>this.navigation.getCurrentDate(),this.setVisibleMonth=e=>this.navigation.setVisibleMonth(e),this.getVisibleMonth=()=>this.navigation.getVisibleMonth(),this.goToToday=()=>this.navigation.goToToday(),this.goToPrevious=()=>this.navigation.goToPrevious(),this.goToNext=()=>this.navigation.goToNext(),this.selectDate=e=>this.navigation.selectDate(e),this.undo=()=>this.eventManager.undo(),this.applyEventsChanges=(e,t,n)=>this.eventManager.applyEventsChanges(e,t,n),this.addEvent=e=>this.eventManager.addEvent(e),this.addExternalEvents=(e,t)=>this.eventManager.addExternalEvents(e,t),this.updateEvent=(e,t,n,r)=>this.eventManager.updateEvent(e,t,n,r),this.deleteEvent=e=>this.eventManager.deleteEvent(e),this.getAllEvents=()=>this.eventManager.getAllEvents(),this.getEvents=()=>this.eventManager.getEvents(),this.onEventClick=e=>this.eventManager.onEventClick(e),this.onMoreEventsClick=e=>this.eventManager.onMoreEventsClick(e),this.highlightEvent=e=>this.eventManager.highlightEvent(e),this.selectEvent=e=>this.eventManager.selectEvent(e),this.dismissUI=()=>this.eventManager.dismissUI(),this.getReadOnlyConfig=e=>function(e,t,n,r){var a,o;let i=!0,l=!0;if(!0===e?(i=!1,l=!1):!1!==e&&(i=null===(a=e.draggable)||void 0===a||a,l=null===(o=e.viewable)||void 0===o||o),t&&(i||l)){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);o&&(!0===o.readOnly&&(i=!1),o.subscription&&void 0===o.readOnly&&(i=!1))}return{draggable:i,viewable:l}}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.canMutateFromUI=e=>function(e,t,n,r){if(!1!==e)return!1;if(t){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);if(o){if(void 0!==o.readOnly)return!o.readOnly;if(o.subscription)return!1}}return!0}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{this.calendarRegistry.reorder(e,t),this.triggerRender()},this.setCalendarVisibility=(e,t)=>{this.calendarRegistry.setVisibility(e,t),this.triggerRender()},this.setAllCalendarsVisibility=e=>{this.calendarRegistry.setAllVisibility(e),this.triggerRender()},this.updateCalendar=(e,t,n)=>{var r,a;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const o=this.calendarRegistry.get(e);o&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,o)),this.triggerRender()},this.createCalendar=t=>e(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.register(t),yield null===(n=(e=this.callbacks).onCalendarCreate)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.deleteCalendar=t=>e(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.unregister(t),yield null===(n=(e=this.callbacks).onCalendarDelete)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.mergeCalendars=(t,n)=>e(this,void 0,void 0,function*(){var e,r;const a=this.eventManager.getStore(),o=a.getAllEvents().filter(e=>e.calendarId===t);this.eventManager.pushToUndo(),a.beginTransaction(),o.forEach(e=>a.updateEvent(e.id,{calendarId:n})),yield a.endTransaction(),yield this.deleteCalendar(t),yield null===(r=(e=this.callbacks).onCalendarMerge)||void 0===r?void 0:r.call(e,t,n)}),this.getPlugin=e=>this.pluginManager.getPlugin(e),this.hasPlugin=e=>this.pluginManager.hasPlugin(e),this.getPluginConfig=e=>this.pluginManager.getPluginConfig(e),this.updatePluginConfig=(e,t)=>this.pluginManager.updatePluginConfig(e,t),this.setTheme=e=>{this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>t(e)),this.triggerRender()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>this.unsubscribeThemeChange(e)),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.setOverrides=e=>{this.state.overrides=e,this.triggerRender()},this.updateConfig=e=>{var t,n;let r=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,r=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,r=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,r=!0),void 0===e.readOnly||wt(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,r=!0),void 0!==e.callbacks&&(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,r=!0),void 0!==e.locale){const t=Pt.resolveLocale(e.locale);wt(t,this.state.locale)||(this.state.locale=t,r=!0)}if(void 0!==e.allDaySortComparator&&e.allDaySortComparator!==this.state.allDaySortComparator&&(this.state.allDaySortComparator=e.allDaySortComparator,r=!0),void 0!==e.timeZone){const t=null!==(n=fe(e.timeZone))&&void 0!==n?n:Intl.DateTimeFormat().resolvedOptions().timeZone;t!==this.state.timeZone&&(this.state.timeZone=t,r=!0)}if(void 0!==e.views){const t=new Map(this.state.views);let n=!1,a=!1;e.views.forEach(e=>{const r=t.get(e.type),o=It(r,e);o.hasChanges&&(t.set(e.type,e),a=!0),n=n||o.requiresRender}),a&&(this.state.views=t),n&&(r=!0)}if(void 0!==e.calendars){let t=!1;for(const n of e.calendars){const e=this.calendarRegistry.get(n.id);e&&e.source!==n.source&&(this.calendarRegistry.updateCalendar(n.id,{source:n.source}),t=!0)}t&&(r=!0)}r&&this.triggerRender()};const s=null!==(r=fe(t.timeZone))&&void 0!==r?r:Intl.DateTimeFormat().resolvedOptions().timeZone,d=(()=>{const e=n.Now.plainDateISO(s);return new Date(e.year,e.month-1,e.day)})();var c;this.state={currentView:t.defaultView||I.WEEK,currentDate:t.initialDate||d,events:t.events||[],switcherMode:t.switcherMode||"buttons",plugins:new Map,views:new Map,locale:Pt.resolveLocale(t.locale),highlightedEventId:null,selectedEventId:null,readOnly:t.readOnly||!1,overrides:[],allDaySortComparator:t.allDaySortComparator,timeZone:s},this.callbacks=t.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.calendarRegistry=new oe(t.calendars,t.defaultCalendar,(null===(a=t.theme)||void 0===a?void 0:a.mode)||"light"),c=this.calendarRegistry,ie=c,this.eventManager=new Rt(this.state,this.calendarRegistry,()=>this.callbacks,this.notify,this.triggerRender,t.events||[]),this.navigation=new Ht(this.state,()=>this.callbacks,this.notify,this.state.currentDate),this.pluginManager=new At(this.state,this.notify),this.useEventDetailDialog=null!==(o=t.useEventDetailDialog)&&void 0!==o&&o,this.useCalendarHeader=null===(i=t.useCalendarHeader)||void 0===i||i,this.customMobileEventRenderer=t.customMobileEventRenderer,t.views.forEach(e=>this.state.views.set(e.type,e)),null===(l=t.plugins)||void 0===l||l.forEach(e=>this.pluginManager.install(e,this)),this.handleVisibleRangeChange("initial")}static resolveLocale(e){return e?"string"==typeof e?N(e)?e:"en-US":e&&"object"==typeof e&&!N(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}get timeZone(){return this.state.timeZone}}var Lt=0;function $t(e,t,n,a,o,i){t||(t={});var l,s,d=t;if("ref"in d)for(s in d={},t)"ref"==s?l=t[s]:d[s]=t[s];var c={type:e,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__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 r.vnode&&r.vnode(c),c}const jt=e=>{if(!e)return"";let t,r,a;e instanceof Date?(a=e.getFullYear(),r=e.getMonth()+1,t=e.getDate()):P(e)?(a=e.year,r=e.month,t=e.day):(!function(e){if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;const t=e;n.ZonedDateTime}(e),a=e.year,r=e.month,t=e.day);const o=String(r).padStart(2,"0");return`${String(t).padStart(2,"0")}/${o}/${a}`},Yt=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,Ft=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}`},Zt=/(YYYY|YY|MM|DD|HH|mm)/g,zt=e=>e.toString().padStart(2,"0"),Ut=(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,"\\$&"),_t=e=>{let t,n=0,r="^";for(;null!==(t=Zt.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)},Bt=(e,t,r,a)=>{const o=e.trim();if(!o)return null;const i=o.match(t),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 n.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}},Vt=e=>{const t=e;return t.timeZoneId&&"string"==typeof t.timeZoneId?t.timeZoneId:t.timeZone&&"string"==typeof t.timeZone.id?t.timeZone.id:"string"==typeof t.timeZone?t.timeZone:n.Now.timeZoneId()},Gt=(e,t,r)=>{var a,o,i,l,s,d,c,u,h,g,m,v,f,p,y,b,D,w,x,E,C,k,T,M;if(!e){const e=null!=t?t:r?Vt(r):n.Now.timeZoneId();return null!=r?r:n.Now.zonedDateTimeISO(e)}if(pe(e)){const r=null!=t?t:n.Now.timeZoneId(),a=`${e.year}-${zt(e.month)}-${zt(e.day)}T00:00:00[${r}]`;return n.ZonedDateTime.from(a)}const S=e;if("hour"in S&&!("timeZoneId"in S)){const r=null!=t?t:n.Now.timeZoneId();if("function"==typeof S.toZonedDateTime)try{return e.toZonedDateTime(r)}catch(e){}return n.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 n.ZonedDateTime.from(e)}catch(e){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:t)&&void 0!==u?u:r?Vt(r):void 0)&&void 0!==h?h:n.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:n.Now.zonedDateTimeISO(o);return n.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!==(w=null!==(D=null==a?void 0:a.second)&&void 0!==D?D:null==r?void 0:r.second)&&void 0!==w?w: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!==(M=null!==(T=null==a?void 0:a.nanosecond)&&void 0!==T?T:null==r?void 0:r.nanosecond)&&void 0!==M?M:0})}},Kt=(e,t,n)=>{const r=Ut(t,n),a={YYYY:e.year.toString(),YY:zt(e.year%100),MM:zt(e.month),DD:zt(e.day),HH:zt(e.hour),mm:zt(e.minute)};return r.replace(Zt,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function qt(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}let Xt=null;function Jt(){if("undefined"==typeof document)return!1;if(null!==Xt)return Xt;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(),Xt=r,r}const Qt=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),en={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:"df-focus-ring-only",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"df-focus-ring",buttonPrimary:"df-fill-primary df-hover-primary-solid",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:"df-fill-destructive df-hover-destructive",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"},tn=(e,t,n)=>e?t:n,nn=(...e)=>e.filter(Boolean).join(" "),rn=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.dataset.dfThemeOverride,t.dataset.dfTheme,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 an(e,t=!1){if(e instanceof n.PlainDate||e instanceof n.PlainDateTime)return e;if(e instanceof Date)return t?Ee(e):Ce(e);throw new Error("Invalid time type: "+typeof e)}function on(e,t){if(e instanceof n.ZonedDateTime)return e;if(e instanceof Date)return ke(e,t);throw new Error("Invalid time type: "+typeof e)}function ln(e){var t;const n=an(e.start,e.allDay),r=an(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 sn(e){const t=on(e.start,e.timeZone),n=on(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 dn(e){return e.map(e=>ln(e))}function cn(e){return e.map(e=>sn(e))}function un(e,t,n,r){return ln(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))}function hn(e,t,n,r,a){return ln(Object.assign({id:e,title:t,start:n,end:r},a))}function gn(e,t,n,r,a=!1,o){return ln(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))}function mn(e,t,n,r,a,o){return sn(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))}const vn=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):Y(e)}catch(e){return new Date}},fn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},pn=(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="df-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}},yn=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=vn(e.start),a=fn(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 bn=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 Dn(e){return String(e).padStart(2,"0")}function wn(e,t,r){const a=e.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==t?void 0:t.value)||o.test(a)){const e=a.match(o);if(e)return n.PlainDate.from({year:Number.parseInt(e[1],10),month:Number.parseInt(e[2],10),day:Number.parseInt(e[3],10)})}if(i.test(a)){const e=a.match(i);if(e){const t=n.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),a=r||n.Now.timeZoneId();return t.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const e={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==t?void 0:t.tzid)?n.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:t.tzid})):n.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function xn(e,t=!1){if(t||pe(e)){const t=pe(e)?e:e.toPlainDate();return{value:`${t.year}${Dn(t.month)}${Dn(t.day)}`,params:{VALUE:"DATE"}}}if(be(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Dn(t.month)}${Dn(t.day)}T${Dn(t.hour)}${Dn(t.minute)}${Dn(t.second)}Z`}}if(ye(e))return{value:`${e.year}${Dn(e.month)}${Dn(e.day)}T${Dn(e.hour)}${Dn(e.minute)}${Dn(e.second)}`};throw new Error("Unsupported Temporal type")}function En(e){return`${e.getUTCFullYear()}${Dn(e.getUTCMonth()+1)}${Dn(e.getUTCDate())}T${Dn(e.getUTCHours())}${Dn(e.getUTCMinutes())}${Dn(e.getUTCSeconds())}Z`}function Cn(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function kn(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 Mn(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,Tn(r)}function Sn(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:${En(new Date)}`);const i=xn(e.start,e.allDay);let l;if(e.allDay){const t=(pe(e.end)?e.end:e.end.toPlainDate()).add({days:1});l={value:`${t.year}${Dn(t.month)}${Dn(t.day)}`,params:{VALUE:"DATE"}}}else l=xn(e.end,!1);if(a.push(Mn("DTSTART",i.value,i.params)),a.push(Mn("DTEND",l.value,l.params)),a.push(Mn("SUMMARY",Cn(e.title))),e.description&&a.push(Mn("DESCRIPTION",Cn(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(Mn("LOCATION",Cn(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(Cn).join(",");a.push(Mn("CATEGORIES",t))}return a.push("END:VEVENT"),a}function Nn(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 In(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=kn(a);break;case"DESCRIPTION":t.description=kn(a);break;case"LOCATION":t.location=kn(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=>kn(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=Dt()),t}function On(e,t){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=t,s=o?`${i}${Dt()}`:e.uid,d=wn(e.dtstart,e.dtstartParams,l);let c;c=e.dtend?wn(e.dtend,e.dtendParams,l):pe(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=e.dtstartParams)||void 0===r?void 0:r.value)||pe(d),h=l||n.Now.timeZoneId();let g,m;if(pe(d))g=d;else if(ye(d))try{g=d.toZonedDateTime(h)}catch(e){g=n.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(pe(c))m=c.subtract({days:1});else if(ye(c))try{m=c.toZonedDateTime(h)}catch(e){m=n.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:e.summary||"(No Title)",description:e.description,start:g,end:m,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}function Rn(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=Nn(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=On(In(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 Hn(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:${Cn(n)}`];return e.forEach(e=>{a.push(...Sn(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}function An(e,t={}){const n=Hn(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 Pn(t,n){return e(this,void 0,void 0,function*(){try{const e=yield t.text();if(!e)throw new Error("File content is empty");return Rn(e,n)}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}}})}const Ln=e=>{const t=Y(e.start);t.setHours(0,0,0,0);const n=Y(e.end);return n.setHours(0,0,0,0),{startDay:t,endDay:n,isMultiDay:n.getTime()>t.getTime()}},$n=(e,t)=>e.title.localeCompare(t.title),jn=(e,t,n)=>{const r=Ln(e),a=Ln(t);if(r.isMultiDay!==a.isMultiDay)return r.isMultiDay?-1:1;if(r.isMultiDay&&a.isMultiDay){const e=r.startDay.getTime()-a.startDay.getTime();if(0!==e)return e;const t=a.endDay.getTime()-r.endDay.getTime();if(0!==t)return t}if(n){const r=n(e,t);if(0!==r)return r}return r.startDay.getTime()-a.startDay.getTime()},Yn=(e,t)=>{const n=new Map;return e.forEach(e=>{const{isMultiDay:t,startDay:r}=Ln(e),a=n.get(e.calendarId);a?t&&(a.hasMultiDay=!0,a.earliestMultiDayStart=Math.min(a.earliestMultiDayStart,r.getTime())):n.set(e.calendarId,{hasMultiDay:t,earliestMultiDayStart:t?r.getTime():Number.POSITIVE_INFINITY})}),(e,r)=>{var a,o,i,l,s,d;const c=n.get(e.calendarId),u=n.get(r.calendarId);if((null!==(a=null==c?void 0:c.hasMultiDay)&&void 0!==a&&a)!==(null!==(o=null==u?void 0:u.hasMultiDay)&&void 0!==o&&o))return(null==c?void 0:c.hasMultiDay)?-1:1;if(null!==(i=null==c?void 0:c.hasMultiDay)&&void 0!==i&&i&&null!==(l=null==u?void 0:u.hasMultiDay)&&void 0!==l&&l&&e.calendarId!==r.calendarId){const e=(null!==(s=null==c?void 0:c.earliestMultiDayStart)&&void 0!==s?s:Number.POSITIVE_INFINITY)-(null!==(d=null==u?void 0:u.earliestMultiDayStart)&&void 0!==d?d:Number.POSITIVE_INFINITY);if(0!==e)return e}return e.calendarId,r.calendarId,jn(e,r,t)}},Fn=({wasOriginallyAllDay:e,mouseHour:t,hourOffset:n,duration:r,originalStartHour:a,originalEndHour:o,firstHour:i,lastHour:l,minDuration:s,roundToTimeStep:d})=>{const c=e?1:Math.max(s,r||o-a||1);let u=d(e?t:t+(null!=n?n:0));return u=Math.max(i,Math.min(l-c,u)),{startHour:u,endHour:u+c,duration:c,hourOffset:e?0:null!=n?n:0}};let Zn=null;const zn=()=>{const[e,t]=g(()=>Zn||{weekHeight:R.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return m(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(R.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(R.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(R.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};Zn=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},Un=a({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Wn(){return b(Un)}const _n="df-month-view h-full flex flex-col select-none",Bn="p-2 flex justify-between",Vn="text-2xl font-bold text-gray-900 dark:text-gray-100",Gn="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)",Kn="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",qn="flex-1 overflow-auto will-change-scroll overscroll-contain",Xn="df-scrollbar-hide",Jn="df-time-slot relative h-[4.5rem] flex",Qn="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",er="df-time-grid-row h-[4.5rem] border-t flex",tr="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",nr="df-current-time-label ml-2 df-fill-primary text-xs font-bold px-1.5 rounded-sm",rr="df-all-day-row flex items-center border-b",ar="rounded-xl my-0.5",or="rounded-sm",ir="df-event-title font-medium text-xs truncate pr-1",lr="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",sr="h-3 w-3 mr-1",dr="resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",cr="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",ur="df-fill-primary rounded-full",hr="df-nav-button df-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",gr="h-4 w-4 transition-transform group-hover:scale-110",mr="df-event-detail-panel df-portal fixed shadow-lg border rounded-lg",vr="df-portal 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 df-animate-in df-fade-in df-zoom-in-95",fr="df-time-grid-boundary h-3 border-t relative",pr="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",yr="df-sidebar flex h-full flex-col border-r",br="df-sidebar-header flex items-center px-2 py-1",Dr="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",wr="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",xr="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Er="text-gray-500 dark:text-gray-400",Cr="text-gray-600 dark:text-gray-300",kr="text-xs",Tr="text-sm",Mr="flex flex-col",Sr="mr-1",Nr=(...e)=>e.filter(Boolean).join(" "),Ir=({className:e,width:t=24,height:n=24})=>$t("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:$t("path",{d:"m15 18-6-6 6-6"})}),Or=({className:e,width:t=24,height:n=24})=>$t("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:$t("path",{d:"m9 18 6-6-6-6"})}),Rr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"m11 17-5-5 5-5"}),$t("path",{d:"m18 17-5-5 5-5"})]}),Hr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"m6 17 5-5-5-5"}),$t("path",{d:"m13 17 5-5-5-5"})]}),Ar=({className:e,width:t=24,height:n=24})=>$t("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:$t("path",{d:"m6 9 6 6 6-6"})}),Pr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"M5 12h14"}),$t("path",{d:"M12 5v14"})]}),Lr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("circle",{cx:"11",cy:"11",r:"8"}),$t("path",{d:"m21 21-4.3-4.3"})]}),$r=({className:e,width:t=24,height:n=24})=>$t("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:$t("path",{d:"M20 6 9 17l-5-5"})}),jr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"m7 15 5 5 5-5"}),$t("path",{d:"m7 9 5-5 5 5"})]}),Yr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"M18 6 6 18"}),$t("path",{d:"m6 6 12 12"})]}),Fr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"M8 2v4"}),$t("path",{d:"M16 2v4"}),$t("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),$t("path",{d:"M3 10h18"}),$t("path",{d:"M8 14h.01"}),$t("path",{d:"M12 14h.01"}),$t("path",{d:"M16 14h.01"}),$t("path",{d:"M8 18h.01"}),$t("path",{d:"M12 18h.01"}),$t("path",{d:"M16 18h.01"})]}),Zr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"M18 8L22 12L18 16"}),$t("path",{d:"M2 12H22"})]}),zr=({className:e,width:t=24,height:n=24})=>$t("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:$t("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Ur=({className:e,width:t=24,height:n=24})=>$t("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:[$t("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),$t("path",{d:"M12 5a3 3 0 1 0-3 3"}),$t("path",{d:"M12 5a3 3 0 1 1 3 3"}),$t("path",{d:"M3 12h18"}),$t("path",{d:"M12 22V8"})]}),Wr=({className:e,width:t=24,height:n=24})=>$t("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:$t("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"})}),_r=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),$t("circle",{cx:"12",cy:"10",r:"3"})]}),Br=({className:e,width:t=24,height:n=24})=>$t("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:$t("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"})}),Vr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),$t("path",{d:"M15 3v18"}),$t("path",{d:"m8 9 3 3-3 3"})]}),Gr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),$t("path",{d:"M15 3v18"}),$t("path",{d:"m10 15-3-3 3-3"})]}),Kr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"m12 19-7-7 7-7"}),$t("path",{d:"M19 12H5"})]}),qr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("path",{d:"M4 11a9 9 0 0 1 9 9"}),$t("path",{d:"M4 4a16 16 0 0 1 16 16"}),$t("circle",{cx:"5",cy:"19",r:"1"})]}),Xr=({className:e,width:t=24,height:n=24})=>$t("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:[$t("circle",{cx:"12",cy:"12",r:"10"}),$t("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),$t("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]});function Jr(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 Qr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const ea=(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},ta=(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 na(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Jr(e,t);if(n)return Qr(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 ra=({locale:e="en-US",messages:t,children:n})=>{const r=p(()=>{if("string"==typeof e){return{code:N(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!N(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),a=p(()=>{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:na(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:ea,getMonthLabels:ta,isDefault:!1}},[r,t]);return $t(Un.Provider,{value:a,children:n})},aa=(e,t,n)=>{var r;const a=null===(r=t.state.views.get(e))||void 0===r?void 0:r.label;if(a)return a;const o=n(e);return o!==e?o:e.split(/[-_]/g).map(e=>e?e.charAt(0).toUpperCase()+e.slice(1):e).join(" ")},oa=({calendar:e,mode:t="buttons"})=>{const[n,r]=g(!1),a=v(null),{t:o}=Wn(),i=Array.from(e.state.views.keys()),l=e.state.currentView;return m(()=>{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:$t("div","select"===t?{className:"relative inline-block",ref:a,children:[$t("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:[$t("span",{className:"text-gray-900 dark:text-gray-100",children:aa(l,e,o)}),$t("span",{className:`${Er} transition-transform duration-200 ${n?"rotate-180":""}`,children:$t(Ar,{width:16,height:16})})]}),n&&$t("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 df-animate-in",children:$t("div",{className:"p-1",role:"listbox",children:i.map(t=>$t("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?"df-tint-primary font-medium":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:aa(t,e,o)},t))})}),$t("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 .df-animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}:{className:"inline-flex h-7 items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:i.map(t=>$t("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:aa(t,e,o)},t))})},ia=({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}=zn(),h="mobile"===u,{t:g}=Wn(),m=f(e=>{const t=e.currentTarget.value;t!==o&&(null==r||r(t))},[r,o]);return $t("div",{className:"df-header flex shrink-0 items-center justify-between border-b py-1 pr-2 transition-colors duration-200 "+(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:[$t("div",{className:"df-header-left flex items-center",children:n&&l&&$t("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:xr,title:h?g("newEvent")||"New Event":g("createCalendar")||"Add Calendar",children:$t(Pr,{className:`h-4 w-4 ${Er}`})})}),$t("div",{className:"df-header-mid flex flex-1 items-center justify-center",children:d&&$t(oa,{mode:t,calendar:e})}),$t("div",{className:"df-header-right flex items-center justify-end gap-3",children:[!d&&$t(oa,{mode:t,calendar:e}),$t("button",{type:"button",onClick:a,className:`md:hidden ${xr}`,title:g("search")||"Search",children:$t(Lr,{width:16,height:16})}),$t("div",{className:"df-search-group group relative hidden md:block",children:[$t("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:$t("span",{className:"df-search-focus-within-primary text-gray-400 transition-colors",children:$t(Lr,{width:16,height:16})})}),$t("input",{id:"dayflow-search-input",type:"text",placeholder:g("search")||"Search",value:o,onChange:m,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 df-focus-ring transition resize-none w-48"}),o&&$t("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:$t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[$t("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),$t("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},la=a(void 0),sa=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,a]=g(t),[o,i]=g(()=>"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),l="auto"===r?o:r;m(()=>{a(t)},[t]);const s=f(e=>{a(e)},[]);m(()=>{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)};return e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),y(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=rn(l),n="auto"===r?t:l;e.classList.contains(n)||(e.classList.remove("light","dark"),e.classList.add(n)),"auto"===r?e.dataset.dfThemeOverride&&delete e.dataset.dfThemeOverride:e.dataset.dfThemeOverride!==n&&(e.dataset.dfThemeOverride=n),e.dataset.dfTheme!==n&&(e.dataset.dfTheme=n)},[l,r,o]),m(()=>{n&&n(r,l)},[r,l,n]);const d=p(()=>({theme:r,effectiveTheme:l,setTheme:s}),[r,l,s]);return $t(la.Provider,{value:d,children:e})},da=()=>{const e=b(la);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},ca=a(null);let ua=0;function ha({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const a=v(null),o=b(ca),i=r||o,l=v(null),[s,d]=g(()=>{var t;return!!e&&(null!==(t=null==i?void 0:i.isOverridden(e))&&void 0!==t&&t)});l.current||(l.current="df-slot-"+ua++),m(()=>{if(!a.current||!i||!e)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t});const r=i.subscribeToOverrides(()=>{d(i.isOverridden(e))});return()=>{i.unregister(n),r()}},[i,e]),m(()=>{if(!i||!l.current||!e)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t})},[e,t]);const c=null==e?void 0:e.startsWith("eventContent");return $t("div",{ref:a,className:"df-content-slot "+(c||"sidebar"===e?"flex h-full flex-1 flex-col":""),children:!s&&n})}const ga=e=>{const n=v(null),r=v(null);return m(()=>{if(n.current){const a=t(e,[]);r.current=new D(n.current,a),a.initialExpanded&&r.current.expand()}return()=>{r.current&&(r.current.destroy(),r.current=null)}},[]),m(()=>{if(r.current){const n=t(e,[]);r.current.setOptions(n)}},[e]),$t("div",{ref:n,className:e.className})},ma=({color:e,onChange:t,onClose:n})=>{const r=p(()=>{const{h:t,l:n}=w(e);return{hue:t,saturation:x(n),lightness:n,alpha:100,layer:"outer"}},[e]);return $t("div",{className:"flex justify-center",children:$t(ga,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},va=n=>{var{children:r,onClick:a,loading:i,loadingText:l,disabled:s,className:d,type:c="button"}=n,u=t(n,["children","onClick","loading","loadingText","disabled","className","type"]);const[h,m]=g(!1),v=i||h,f=$t(o,{children:[v&&$t("svg",{className:"mr-2 h-4 w-4 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[$t("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),$t("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),$t("span",{className:"inline-flex items-center",children:v&&l?l:r})]}),p=Object.assign(Object.assign({},u),{disabled:s||v,onClick:t=>e(void 0,void 0,void 0,function*(){if(!v&&a){const e=a(t);if(e&&"object"==typeof e&&"then"in e){m(!0);try{yield e}finally{m(!1)}}}}),className:`relative inline-flex items-center justify-center transition-all ${d} ${v?"cursor-not-allowed opacity-70":""}`});return $t("button","submit"===c?Object.assign({},p,{type:"submit",children:f}):"reset"===c?Object.assign({},p,{type:"reset",children:f}):Object.assign({},p,{type:"button",children:f}))},fa=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],pa=({onClose:t,onCreate:n,app:r})=>{const{t:a}=Wn(),{effectiveTheme:i}=da(),[l,s]=g(""),[d,u]=g(!1),h=r.state.overrides.includes("createCalendarDialogColorPicker"),[m,v]=g(fa[Math.floor(Math.random()*fa.length)]),[f,y]=g(!1),[b,D]=g(""),w=p(()=>{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}},[]),[k,T]=g(null),M=e=>{v(e.hex)},S=()=>{y(!1)},N=()=>{v(b),y(!1)},I="dark"===i,O={default:{picker:{background:I?"#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:I?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:I?"#1e293b":"#ffffff",borderBottom:I?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:I?"#1e293b":"#ffffff"},controls:{border:I?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:I?"#374151":"#ffffff",color:I?"#f3f4f6":"#1f2937",border:I?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:I?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:I?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:c($t("div",{className:"df-portal fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:$t("div",{className:"df-animate-in df-fade-in df-zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-gray-900",onClick:e=>e.stopPropagation(),children:[$t("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+(h?"mb-4":"mb-6"),children:a("createCalendar")}),$t("form",{onSubmit:r=>e(void 0,void 0,void 0,function*(){var e;if(r.preventDefault(),l.trim()&&!d){u(!0);try{let r;r=h?m:null!==(e=null==k?void 0:k.hex)&&void 0!==e?e:C(w.hue,w.saturation,w.lightness);const{colors:a,darkColors:o}=se(r),i={id:Dt(),name:l.trim(),colors:a,darkColors:o,isVisible:!0,isDefault:!1};yield n(i),t()}finally{u(!1)}}}),children:[h?$t(o,{children:[$t("div",{className:"mb-4",children:$t("div",{className:"flex items-center gap-3",children:[$t("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:m}}),$t("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:l,onChange:e=>s(e.target.value),className:"df-focus-ring w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})]})}),$t("div",{className:"mb-6",children:[$t("div",{className:"mb-4 grid grid-cols-7 gap-4",children:fa.map(e=>$t("button",{type:"button",className:"df-focus-ring-only h-7 w-7 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(m===e?"df-ring-primary-solid scale-110 ring-2 ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>v(e)},e))}),$t("div",{className:"relative",children:[$t("button",{type:"button",onClick:()=>{D(m),y(!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")}),f&&$t("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:N,children:$t("div",{className:"df-animate-in df-fade-in df-zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:$t(ha,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:m,onChange:M,onAccept:S,onCancel:N,styles:O},defaultContent:$t("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-2xl dark:border-slate-700 dark:bg-gray-900",children:[$t(ma,{color:m,onChange:M}),$t("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[$t("button",{type:"button",onClick:N,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")}),$t("button",{type:"button",onClick:S,className:"df-fill-primary rounded-md px-3 py-1.5 text-xs font-medium shadow-sm hover:opacity-90",children:"OK"})]})]})})})})]})]})]}):$t("div",{className:"mb-8 flex items-center gap-4",children:[$t("div",{className:"flex-1",children:$t("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:l,onChange:e=>s(e.target.value),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})}),$t("div",{className:"relative h-9 w-9 shrink-0",children:$t("div",{className:"absolute inset-0 flex items-center justify-center",children:$t(ga,{defaultValue:w,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>T(e),onCollapse:e=>T(e),className:"z-50"})})})]}),$t("div",{className:"flex justify-end space-x-2",children:[$t("button",{type:"button",onClick:t,disabled:d,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")}),$t(va,{type:"submit",disabled:!l.trim(),loading:d,className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition disabled:opacity-50",children:a("create")})]})]})]})}),document.body)},ya=(e,t)=>n.PlainDate.compare(e,t),ba=({calendarDays:e,visibleMonth:t,startDate:n,endDate:r,weekDayLabels:a,disabled:i,onDaySelect:l})=>$t(o,{children:[$t("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:a.map(e=>$t("span",{children:e},e))}),$t("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const a=e.month!==t.month,o=0===ya(e,n),s=0===ya(e,r),d=ya(e,n)>=0&&ya(e,r)<=0;return $t("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?"df-fill-primary font-semibold":d?"df-tint-primary":a?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 df-hover-primary"}`,children:e.day},e.toString())})})]}),Da=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>$t("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:[$t("div",{className:"flex items-center gap-1",children:[$t("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:$t(Rr,{width:14,height:12})}),$t("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:$t(Ir,{width:14,height:12})})]}),$t("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),$t("div",{className:"flex items-center gap-1",children:[$t("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:$t(Or,{width:14,height:12})}),$t("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:$t(Hr,{width:14,height:12})})]})]}),wa=Array.from({length:24},(e,t)=>t),xa=Array.from({length:60},(e,t)=>t),Ea=({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=xa.includes(s)?xa:[...xa,s].toSorted((e,t)=>e-t);return $t("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:[$t("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:$t("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")]})}),$t("div",{className:"flex p-1",children:[$t("div",{className:"w-14",children:$t("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:wa.map(e=>{const t=e===l.hour;return $t("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?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:zt(e)},e)})})}),$t("div",{className:"w-14",children:$t("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 $t("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?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:zt(e)},e)})})})]})]})},Ca=({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 $t("div",{ref:d,className:"df-range-picker",style:p(),"data-range-picker-popup":"true",children:$t("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:[$t("div",{className:"flex gap-1",children:[$t("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:[$t(Da,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),$t(ba,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&$t("div",{className:"flex flex-1 justify-end sm:w-32",children:$t(Ea,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),$t("div",{className:"flex justify-end",children:$t("button",{type:"button",onClick:f,disabled:l,className:"df-fill-primary df-hover-primary-solid inline-flex items-center rounded-full px-4 py-1.5 text-sm font-semibold shadow-sm transition disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},ka=({value:e,format:t="YYYY-MM-DD HH:mm",showTimeFormat:r="HH:mm",showTime:a=!0,onChange:o,onOk:i,timeZone:l,disabled:s=!1,placement:d="bottomLeft",autoAdjustOverflow:u=!0,getPopupContainer:h,matchTriggerWidth:y=!1,locale:b="en-US"})=>{const D=p(()=>"string"==typeof b?b:(null==b?void 0:b.code)||"en-US",[b]),w=p(()=>void 0===a||("object"==typeof a||Boolean(a)),[a]),x=p(()=>ta(D,"short"),[D]),E=p(()=>ea(D,"narrow"),[D]),C=p(()=>w?"object"==typeof a&&(null==a?void 0:a.format)?a.format:r:"",[w,a,r]),k=p(()=>Ut(t,C),[t,C]),T=p(()=>_t(k),[k]),M=p(()=>{const t=null!=l?l:P(e[0])?P(e[1])?n.Now.timeZoneId():Vt(e[1]):Vt(e[0]),r=Gt(e[0],t).withTimeZone(t);return[r,Gt(e[1],t,r).withTimeZone(t)]},[e,l]),[S,N]=g(M),I=v(M),[O,R]=g("start"),[H,A]=g([Kt(M[0],t,C),Kt(M[1],t,C)]),L=v([Kt(M[0],t,C),Kt(M[1],t,C)]),$=v(M),[j,Y]=g(M[0].toPlainDate().with({day:1})),[F,Z]=g(!1),z=f(e=>{Z(e)},[]),[U,W]=g(d),_=v(d),B=v(null),V=v(null),G=v({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=v(!1),q=v(!1);m(()=>{L.current=H},[H]),m(()=>{$.current=S},[S]),m(()=>{const e=I.current,t=0!==n.ZonedDateTime.compare(e[0],M[0])||e[0].timeZoneId!==M[0].timeZoneId,r=0!==n.ZonedDateTime.compare(e[1],M[1])||e[1].timeZoneId!==M[1].timeZoneId;(t||r)&&N(M),I.current=M},[M]),m(()=>{Y(M[0].toPlainDate().with({day:1}))},[M[0]]);const X=f((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=f(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]);m(()=>{F&&w&&J(O)},[O,F,J,w]);const Q=S[0].epochMilliseconds,ee=S[0].offsetNanoseconds,te=S[1].epochMilliseconds,ne=S[1].offsetNanoseconds;m(()=>{if(q.current)return;const[e,n]=$.current,r=Kt(e,t,C),a=Kt(n,t,C),[o,i]=L.current;o===r&&i===a||(L.current=[r,a],A([r,a]))},[Q,ee,te,ne,t,C]),m(()=>{if(!F)return;const e=e=>{var t,n;const r=e.target;if(null===(t=B.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]")||z(!1)};return document.addEventListener("pointerdown",e,!0),()=>{document.removeEventListener("pointerdown",e,!0)}},[F]),m(()=>{F||(R("start"),K.current||N(M),K.current=!1)},[F,M]);const re=f(e=>{o&&o(e,[Kt(e[0],t,C),Kt(e[1],t,C)])},[C,t,o]),ae=f(e=>{i&&i(e,[Kt(e[0],t,C),Kt(e[1],t,C)])},[C,t,i]),oe=f((e,t)=>{N(r=>{const a=[...r];if("start"===e){const e=Gt(a[1],Vt(t),t),r=n.ZonedDateTime.compare(t,e)>0?t:e;return[t,r]}const o=Gt(a[0],Vt(t),t);return[n.ZonedDateTime.compare(o,t)>0?t:o,t]})},[]),ie=e=>{if(s)return;const t=(e,t)=>{var r,a,o,i;const l=Vt(e);return n.ZonedDateTime.from({timeZone:l,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=e.nanosecond)&&void 0!==i?i:0})};if("start"===O){const n=t(S[0],e),r=S[1].epochMilliseconds-S[0].epochMilliseconds,a=n.add({milliseconds:r});return void N([n,a])}const r=t(S[1],e),a=S[1].epochMilliseconds-S[0].epochMilliseconds;if(n.ZonedDateTime.compare(r,S[0])<0){const n=t(S[0],e),r=n.add({milliseconds:a});return void N([n,r])}const o=[S[0],r];N(o),Y(r.toPlainDate().with({day:1}))},le=f((e,t)=>{if(s)return;const r="start"===e?0:1;N(a=>{const o=a[r],i=o.with({hour:t,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Gt(a[1],Vt(i),i);return[i,n.ZonedDateTime.compare(i,e)>0?i:e]}const l=Gt(a[0],Vt(i),i);return[n.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&X(t,n,0)})})},[s]),se=f((e,t)=>{if(s)return;const r="start"===e?0:1;N(a=>{const o=a[r].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Gt(a[1],Vt(o),o);return[o,n.ZonedDateTime.compare(o,e)>0?o:e]}const i=Gt(a[0],Vt(o),o);return[n.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&X(t,n,0)})})},[s]),de=f((e,t)=>{const n="start"===e?0:1;A(e=>{const r=[...e];return r[n]=t,r})},[]),ce=f((e,n)=>{const r="start"===e?0:1,a=S[r],o=Vt(a),i=Bt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});return Y(t),"start"===e&&R("end"),!0}return A(e=>{const n=[...e];return n[r]=Kt(S[r],t,C),n}),!1},[S,C,t,T,oe]),ue=f(e=>t=>{const n=t.currentTarget.value;q.current=!0,de(e,n);const r="start"===e?0:1,a=$.current[r],o=Vt(a),i=Bt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});Y(t),J(e)}},[de,T,oe,J]),he=f(e=>n=>{var r;if(s)return;if(q.current=!1,F){const n="start"===e?0:1,r=Kt($.current[n],t,C);return void A(e=>{const t=[...e];return t[n]=r,t})}const a=n.relatedTarget;a&&(null===(r=B.current)||void 0===r?void 0:r.contains(a))||ce(e,n.currentTarget.value)},[ce,s,F,t,C]),ge=f(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),z(!1)},ve=e=>{Y(t=>t.add({months:e}).with({day:1}))},fe=e=>{Y(t=>t.add({years:e}).with({day:1}))},pe=p(()=>{const e=j,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[j]),ye=f((e=d)=>{if(!u||!B.current)return e;const t=B.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},[u,y,d]),be=f(()=>{const e=ye();_.current!==e&&(_.current=e,W(e))},[ye]),De=e=>{if(s)return;R(e);const t=S["start"===e?0:1].toPlainDate().with({day:1});Y(t);const n=ye();_.current!==n&&(_.current=n,W(n)),z(!0)};m(()=>{if(!F)return;be();const e=()=>be();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[F,be]);const we=()=>{if(!B.current)return{};const e=B.current.getBoundingClientRect(),t={position:"fixed",zIndex:9999};return _.current.startsWith("bottom")?t.top=e.bottom+8:t.bottom=window.innerHeight-e.top+8,d.endsWith("Left")?t.left=e.left:t.right=window.innerWidth-e.right,y&&(t.width=`${e.width}px`),t};return $t("div",{className:"df-range-picker relative w-full min-w-0",ref:B,children:[$t("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(s?"cursor-not-allowed border-slate-200 bg-white text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":F?"df-border-primary bg-white shadow-md dark:bg-gray-700":"border-slate-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[$t("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:$t("input",{type:"text",name:"range-start",value:H[0],onChange:ue("start"),onFocus:()=>De("start"),onClick:()=>De("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 "+(s?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===O&&F?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:s})}),$t(Zr,{className:"text-slate-400 dark:text-gray-500"}),$t("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:$t("input",{type:"text",name:"range-end",value:H[1],onChange:ue("end"),onFocus:()=>De("end"),onClick:()=>De("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 "+(s?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===O&&F?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:s})})]}),F&&c($t(Ca,{visibleMonth:j,monthLabels:x,weekDayLabels:E,calendarDays:pe,draftRange:S,focusedField:O,isTimeEnabled:!!w,disabled:s,matchTriggerWidth:y,popupRef:V,timeListRefs:G,onMonthChange:ve,onYearChange:fe,onDaySelect:ie,onHourSelect:le,onMinuteSelect:se,onOk:me,getPopupStyle:we}),h?h():document.body)]})},Ta=({options:e,value:t,onChange:n,registry:r,variant:a="desktop",disabled:o=!1})=>{const[i,l]=g(!1),[s,d]=g({}),u=v(null),h=v(null),f=()=>{if(h.current){const e=h.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`,d(n)}};m(()=>{const e=e=>{!u.current||u.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||le()).resolveColors(e).lineColor,y=(e,t)=>{e.stopPropagation(),n(t),l(!1)},b=e.find(e=>e.value===t),D=()=>i&&"undefined"!=typeof window?c("mobile"===a?$t("div",{"data-calendar-picker-dropdown":"true",style:s,className:vr,children:e.map(e=>$t("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:[$t("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[$t("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&$t($r,{className:"df-text-primary h-4 w-4"})}),$t("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),$t("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}):$t("ul",{"data-calendar-picker-dropdown":"true",style:s,className:"df-portal df-animate-in df-fade-in df-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=>$t("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?$t("span",{className:"df-text-primary mr-2 text-sm",children:$t($r,{width:12,height:12})}):$t("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),$t("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),$t("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return $t("div","mobile"===a?{className:"relative inline-block",ref:u,children:[$t("button",{type:"button",ref:h,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:[$t("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),$t("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==b?void 0:b.label)||t}),$t(jr,{className:"h-4 w-4 text-gray-400"})]}),D()]}:{className:"relative inline-block",ref:u,children:[$t("button",{ref:h,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:[$t("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),$t(jr,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),D()]})},Ma=({event:t,isOpen:r,onEventUpdate:a,onEventDelete:o,onClose:i,app:l})=>{var s,d;const[u,h]=g(t),[f,y]=g(!1),[b,D]=g(!1),w=v(t.id),{t:x}=Wn();m(()=>{h(t),w.current!==t.id&&(y(!1),D(!1),w.current=t.id)},[t]);const E=p(()=>(l?l.getCalendarRegistry():le()).getVisible().map(e=>({label:e.name,value:e.id})),[l,null==l?void 0:l.getCalendars()]),C=p(()=>!pt(t,u),[t,u]),k=p(()=>{var e;return null!==(e=null==l?void 0:l.timeZone)&&void 0!==e?e:n.Now.timeZoneId()},[l]),T=e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t.toPlainDate(),end:n.toPlainDate()}))},M=null!==(s=null==l?void 0:l.canMutateFromUI(t.id))&&void 0!==s&&s,S=null==l?void 0:l.getReadOnlyConfig(t.id),N=!1!==(null==S?void 0:S.viewable),I=f||b,O=!p(()=>{if(!t.calendarId)return!1;const e=null==l?void 0:l.getCalendarRegistry().get(t.calendarId);return!!(null==e?void 0:e.subscription)},[l,t.calendarId])||""!==(u.description||"").trim();if(!r||!N)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const R=$t("div",{className:"df-portal fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[$t("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&&i()}}),$t("div",{className:"df-dialog-container relative shadow-2xl border rounded-lg p-6 max-w-md w-full mx-4",children:[$t("button",{type:"button",onClick:i,disabled:I,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 disabled:opacity-50 dark:text-gray-500 dark:hover:text-gray-200","aria-label":"Close",children:$t("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:$t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),$t("div",{children:[$t("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("eventTitle")}),$t("div",{className:"mb-4 flex items-center justify-between gap-3",children:[$t("div",{className:"flex-1",children:$t("input",{id:`event-dialog-title-${u.id}`,name:"title",type:"text",value:u.title,readOnly:!M||I,disabled:!M||I,onChange:e=>{h(Object.assign(Object.assign({},u),{title:e.target.value}))},className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),M&&$t(Ta,{options:E,value:u.calendarId||"blue",disabled:I,onChange:e=>{h(Object.assign(Object.assign({},u),{calendarId:e}))},registry:null==l?void 0:l.getCalendarRegistry()})]}),u.allDay?$t("div",{className:"mb-4",children:[$t("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("dateRange")}),$t(ka,{value:[u.start,u.end],format:"YYYY-MM-DD",showTime:!1,timeZone:k,matchTriggerWidth:!0,disabled:!M||I,onChange:T,onOk:T,locale:null==l?void 0:l.state.locale})]}):$t("div",{className:"mb-4",children:[$t("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("timeRange")}),$t(ka,{value:[u.start,u.end],timeZone:k,disabled:!M||I,onChange:e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t,end:n}))},onOk:e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t,end:n}))},locale:null==l?void 0:l.state.locale})]}),O&&$t("div",{className:"mb-4",children:[$t("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("note")}),$t("textarea",{id:`event-dialog-note-${u.id}`,name:"note",value:null!==(d=u.description)&&void 0!==d?d:"",readOnly:!M||I,disabled:!M||I,onChange:e=>h(Object.assign(Object.assign({},u),{description:e.target.value})),rows:4,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:x("addNotePlaceholder")})]}),M&&$t("div",{className:"flex space-x-2",children:[u.allDay?$t("button",{type:"button",disabled:I,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{var e;const t=P(u.start)?u.start:u.start.toPlainDate(),r=null!==(e=null==l?void 0:l.timeZone)&&void 0!==e?e:n.Now.timeZoneId(),a=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:r}),o=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:r});h(Object.assign(Object.assign({},u),{allDay:!1,start:a,end:o}))},children:x("setAsTimed")}):$t("button",{type:"button",disabled:I,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{const e=P(u.start)?u.start:u.start.toPlainDate();h(Object.assign(Object.assign({},u),{allDay:!0,start:e,end:e}))},children:x("setAsAllDay")}),$t(va,{type:"button",disabled:I,className:"df-fill-destructive df-hover-destructive rounded-lg border border-border px-3 py-2 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>e(void 0,void 0,void 0,function*(){if(!f&&!b){D(!0);try{yield o(t.id),i()}finally{D(!1)}}}),loading:b,children:x("delete")}),$t(va,{type:"button",className:"df-fill-primary ml-auto rounded-lg px-3 py-2 text-xs font-medium transition "+(C?"df-shadow-primary df-hover-primary-solid shadow-lg":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>e(void 0,void 0,void 0,function*(){if(!f&&!b){y(!0);try{yield a(We(t,u,null==l?void 0:l.timeZone)),i()}finally{y(!1)}}}),disabled:!C||I,loading:f,children:x("save")})]})]})]})]}),H=document.body;return H?c(R,H):null},Sa=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),Na=({app:e,anchorRef:t,onClose:n,isOpen:r})=>{const{t:a}=Wn(),[o,i]=g(""),[l,s]=g(0),[d,u]=g(!1),h=v(null),f=v(null);m(()=>{r||u(!1)},[r]),m(()=>{r&&(setTimeout(()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.focus()},50),i(""),s(0))},[r]),m(()=>{const e=e=>{r&&f.current&&!f.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,D]=g({top:0,left:0}),[w,x]=g("top"),[E,C]=g(0),k=p(()=>ze(e.timeZone),[e.timeZone,r]),T=p(()=>{var t,n;if(!o.trim())return[];const r=[],a=e.getCalendars(),i=e.getAllEvents(),l=o.toLowerCase(),s=i.find(e=>e.title.toLowerCase()===l);let d=null==s?void 0:s.calendarId;if(d||(d=null===(t=e.getCalendarRegistry().getDefaultWritableCalendar())||void 0===t?void 0:t.id),d){const t=e.getCalendarRegistry().get(d);((null==t?void 0:t.readOnly)||(null==t?void 0:t.subscription))&&(d=null===(n=e.getCalendarRegistry().getDefaultWritableCalendar())||void 0===n?void 0:n.id)}const c=a.find(e=>e.id===d),u=(null==c?void 0:c.colors.lineColor)||"#3b82f6";r.push({type:"new",title:o,calendarId:d||"",color:u,start:k.start,end:k.end});const h=new Set([o.toLowerCase()]),g=i.filter(t=>{var n;if(!t.title.toLowerCase().includes(l))return!1;if(h.has(t.title.toLowerCase()))return!1;const r=e.getCalendarRegistry().get(null!==(n=t.calendarId)&&void 0!==n?n:"");return!((null==r?void 0:r.readOnly)||(null==r?void 0:r.subscription))});return g.slice(0,5).forEach(e=>{h.add(e.title.toLowerCase());const t=a.find(t=>t.id===e.calendarId);r.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==t?void 0:t.colors.lineColor)||"#9ca3af",start:k.start,end:k.end})}),r},[o,e,k]);y(()=>{if(r&&t.current&&f.current){const e=t.current.getBoundingClientRect(),n=f.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),D({top:s,left:a}),u(!0)}},[r,t,T]);const M=t=>{if(!t.calendarId)return;const r=Dt(),a={id:r,title:t.title,start:ke(t.start,e.timeZone),end:ke(t.end,e.timeZone),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return m(()=>{if(!r)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),s(e=>(e+1)%T.length)):"ArrowUp"===e.key?(e.preventDefault(),s(e=>(e-1+T.length)%T.length)):"Enter"===e.key&&(e.preventDefault(),T[l]&&M(T[l]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,T,l]),r?c($t("div",{ref:f,className:"df-portal 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 "+(d?"df-animate-in df-fade-in df-zoom-in-95 duration-100":""),style:{top:b.top,left:b.left,visibility:d?"visible":"hidden"},children:[$t("div",{className:"p-4 pb-2",children:[$t("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:a("quickCreateEvent")||"Quick Create Event"}),$t("div",{className:"relative",children:$t("input",{ref:h,type:"text",className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 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)})})]}),$t("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===T.length&&o&&$t("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:a("noSuggestions")||"Type to create"}),T.map((e,t)=>{return $t("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===l?"df-tint-primary df-dark-tint-primary-md df-ring-primary ring-1 ring-inset":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>M(e),onMouseEnter:()=>s(t),children:[$t("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),$t("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[$t("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),$t("div",{className:"flex",children:$t("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")})}),$t("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Sa(n)} - ${Sa(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),$t("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"===w?"-bottom-1.5 border-r border-b":"-top-1.5 border-t border-l"),style:{left:E}})]}),document.body):null},Ia=({visibleMonth:e,currentDate:t,showHeader:r=!1,onMonthChange:a,onDateSelect:o,events:i=[],showEventDots:l=!1,calendarRegistry:s,timeZone:d})=>{const{locale:c}=Wn(),u=p(()=>{const e=d?n.Now.plainDateISO(d):n.Now.plainDateISO();return new Date(e.year,e.month-1,e.day).toDateString()},[d]),h=t.toDateString(),g=p(()=>ea(c,"narrow"),[c]),m=p(()=>e.toLocaleDateString(c,{month:"long",year:"numeric"}),[e,c]),v=p(()=>{if(!l||!(null==i?void 0:i.length))return null;const e=new Map;return i.forEach(t=>{var n;const r=we(t.start,d),a=t.end?we(t.end,d):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(!t.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 c=he(t.calendarId||"default",s).toLowerCase();for(let t=new Date(o);t<=l;t=new Date(t.getTime()+864e5)){const r=t.toDateString(),a=null!==(n=e.get(r))&&void 0!==n?n:[];!a.includes(c)&&a.length<4&&e.set(r,[...a,c])}}),e},[l,i,d,s]),f=p(()=>{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),i=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:i===u,isSelected:i===h})}return a},[e,h,u]);return $t("div",{className:"px-3 py-3",children:[r?$t("div",{className:"mb-3 flex items-center justify-between",children:[$t("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:()=>a(-1),"aria-label":"Previous month",children:$t(Ir,{className:"h-4 w-4"})}),$t("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:m}),$t("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:()=>a(1),"aria-label":"Next month",children:$t(Or,{className:"h-4 w-4"})})]}):"",$t("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[g.map((e,t)=>$t("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}`)),f.map(e=>{var t;const n=null!==(t=null==v?void 0:v.get(e.fullDate.toDateString()))&&void 0!==t?t:[];return $t("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?ur:e.isSelected?"df-fill-secondary rounded-full font-medium":e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} relative flex flex-col items-center justify-center pt-1 pb-1`,onClick:()=>o(e.fullDate),children:[$t("span",{className:"z-10",children:e.date}),l&&n.length>0&&$t("div",{className:"absolute bottom-0.5 flex gap-px",children:n.slice(0,4).map((e,t)=>$t("div",{"data-mini-calendar-dot":"true",className:"h-1 w-1 rounded-full",style:{backgroundColor:e}},`${e}-${t}`))})]},e.fullDate.getTime())})]})]})},Oa=({checked:e,onChange:t,disabled:n})=>$t("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:$t("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),Ra=({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,[u,h]=g(d),[f,p]=g(c),y=v(null),b=v(null),D=v(null);m(()=>{y.current&&(y.current.scrollTop=d,h(d)),b.current&&(b.current.scrollTop=c,p(c))},[d,c]);const w=(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),h(s)}else{const e=384;s<160?(s+=e,l.scrollTop=s):s>800&&(s-=e,l.scrollTop=s),p(s)}D.current&&clearTimeout(D.current),D.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 $t("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[$t("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),$t("div",{ref:y,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>w(e,"hour"),children:[$t("div",{style:{height:96}}),a.map((n,r)=>$t("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:$t("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,u),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),$t("div",{style:{height:96}})]}),$t("div",{ref:b,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>w(e,"minute"),children:[$t("div",{style:{height:96}}),o.map((n,r)=>$t("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:$t("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}`)),$t("div",{style:{height:96}})]}),$t("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"})]})},Ha=({isOpen:e,onClose:t,onSave:n,onEventDelete:r,draftEvent:a,app:o,timeFormat:i="24h"})=>{const{locale:l,t:s}=Wn(),d=o.getReadOnlyConfig(null==a?void 0:a.id),u=o.canMutateFromUI(null==a?void 0:a.id),h=!1!==d.viewable,[v,f]=g(""),y=!p(()=>{if(!(null==a?void 0:a.calendarId))return!1;const e=o.getCalendarRegistry().get(a.calendarId);return!!(null==e?void 0:e.subscription)},[o,null==a?void 0:a.calendarId])||""!==v.trim(),[b,D]=g(""),[w,x]=g(""),[E,C]=g(!1),[k,T]=g(new Date),[M,S]=g(new Date),[N,I]=g(new Date),[O,R]=g(new Date),[H,A]=g(null),[P,L]=g(e),[j,F]=g(!1),[Z,z]=g(!1);m(()=>{if(!e){F(!0);const e=setTimeout(()=>{L(!1),F(!1)},300);return()=>clearTimeout(e)}L(!0),F(!1)},[e]),m(()=>{if(e&&a){const e=o.getEvents().some(e=>e.id===a.id);z(e)}},[e,a,o]);const U=o.getCalendars(),W=U.map(e=>({label:e.name,value:e.id}));m(()=>{if(e&&U.length>0){U.some(e=>e.id===w)||"blue"!==w&&""!==w||x(U[0].id)}},[U,e,w]),m(()=>(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]),m(()=>{var t,n;if(e&&a){if(D(a.title||""),x(a.calendarId||(null===(t=U[0])||void 0===t?void 0:t.id)||"blue"),C(a.allDay||!1),a.start)try{const e=Y(a.start);T(e),I(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;T(t),I(t)}if(a.end)try{const e=Y(a.end);S(e),R(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;S(t),R(t)}}else if(e&&!a){x((null===(n=U[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),T(e),I(e),S(new Date(e.getTime()+36e5)),R(e)}},[e,a]);const _=p(()=>{if(!e||!a)return!1;const t=new Date(k),n=new Date(M),r=Object.assign(Object.assign({},a),{title:b,calendarId:w,allDay:E,description:v,start:E?Ee(t):$(t,o.timeZone),end:E?Ee(n):$(n,o.timeZone)});return!pt(a,We(a,r,o.timeZone))},[e,a,b,w,E,k,M,v]);if(!P||!h)return null;const B=e=>{A(t=>t===e?null:e)},V=e=>e.toLocaleDateString(l,{day:"numeric",month:"short",year:"numeric"}),G=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(k.getHours(),k.getMinutes());const n=e.getTime()-k.getTime();T(e);const r=new Date(M.getTime()+n);S(r)}else{const e=new Date(t);e.setHours(M.getHours(),M.getMinutes()),S(e)}},K=(e,t)=>{"start"===e?I(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):R(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return c($t("div",{className:"df-portal pointer-events-none fixed inset-0 z-10000 flex items-end",children:[$t("div",{className:"pointer-events-auto absolute inset-0 bg-black/30 transition-opacity duration-300 "+(j?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),$t("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 "+(j?"df-animate-slide-down":"df-animate-slide-up"),onClick:e=>e.stopPropagation(),children:[$t("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:[$t("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:s("cancel")}),$t("span",{className:"text-lg font-semibold",children:s(!u&&Z?"viewEvent":Z?"editEvent":"newEvent")}),u&&$t("button",{type:"button",onClick:()=>{if(!a)return;const e=new Date(k),t=new Date(M),r=Object.assign(Object.assign({},a),{title:b,calendarId:w,allDay:E,start:E?Ee(e):$(e,o.timeZone),end:E?Ee(t):$(t,o.timeZone)});n(We(a,r,o.timeZone))},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"df-text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:s(Z?"done":"create")}),!u&&$t("span",{className:"w-12"})]}),$t("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[$t("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:$t("input",{type:"text",placeholder:s("titlePlaceholder"),value:b,onChange:e=>u&&D(e.currentTarget.value),readOnly:!u,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:u})}),U.length>0&&$t("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[$t("span",{className:"text-gray-700 dark:text-gray-300",children:s("calendar")}),$t(Ta,{options:W,value:w,onChange:u?x:()=>{},registry:o.getCalendarRegistry(),variant:"mobile",disabled:!u})]}),$t("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[$t("span",{className:"text-gray-700 dark:text-gray-300",children:s("allDay")}),$t(Oa,{checked:E,onChange:u?C:()=>{},disabled:!u})]}),$t("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[$t("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[$t("span",{className:"text-gray-700 dark:text-gray-300",children:s("starts")}),$t("div",{className:"flex space-x-2",children:[$t("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-date"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("start-date"),disabled:!u,children:V(k)}),!E&&$t("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("start-time"),disabled:!u,children:Ae(k.getHours()+k.getMinutes()/60,0,i)})]})]}),$t("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===H?"max-h-100":"max-h-0"),children:$t("div",{className:"",children:$t(Ia,{currentDate:k,visibleMonth:N,onDateSelect:e=>G("start",e),onMonthChange:e=>K("start",e),showHeader:!0,events:o.getEvents(),calendarRegistry:o.getCalendarRegistry(),timeZone:o.timeZone})})}),$t("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===H?"max-h-75":"max-h-0"),children:$t("div",{className:"",children:$t(Ra,{date:k,onChange:e=>{const t=M.getTime()-k.getTime();T(e),S(new Date(e.getTime()+t))},timeFormat:i})})})]}),$t("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[$t("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[$t("span",{className:"text-gray-700 dark:text-gray-300",children:s("ends")}),$t("div",{className:"flex space-x-2",children:[$t("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-date"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("end-date"),disabled:!u,children:V(M)}),!E&&$t("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>u&&B("end-time"),disabled:!u,children:Ae(M.getHours()+M.getMinutes()/60,0,i)})]})]}),$t("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===H?"max-h-100":"max-h-0"),children:$t("div",{className:"",children:$t(Ia,{currentDate:M,visibleMonth:O,onDateSelect:e=>G("end",e),onMonthChange:e=>K("end",e),showHeader:!0,events:o.getEvents(),calendarRegistry:o.getCalendarRegistry(),timeZone:o.timeZone})})}),$t("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===H?"max-h-75":"max-h-0"),children:$t("div",{className:"",children:$t(Ra,{date:M,onChange:e=>{if(e<k){const t=M.getTime()-k.getTime();S(e),T(new Date(e.getTime()-t))}else S(e)},timeFormat:i})})})]}),y&&$t("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:$t("textarea",{placeholder:s("notesPlaceholder"),value:v,onChange:e=>u&&f(e.currentTarget.value),readOnly:!u,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),u&&Z&&r&&a&&$t("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:s("delete")})]})]})]}),document.body)},Aa=()=>$t("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:$t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Pa=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:a})=>{const{t:o,locale:i}=Wn(),l=p(()=>fn(new Date),[]),s=p(()=>yn(t,l),[t,l]),d=e=>vn(e);return e?$t("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[$t(zr,{className:"mb-2 h-8 w-8 animate-spin"}),$t("span",{children:"Loading..."})]}):0===t.length?n?$t("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[$t(Aa,{}),$t("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:$t("div",{className:"space-y-6",children:s.map(e=>{const{title:t,colorClass:n}=pn(e.date,l,i,o);return $t("div",{children:[$t("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}),$t("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 $t("div",{children:[$t("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:$t("div",{className:"flex items-stretch gap-3",children:[$t("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),$t("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[$t("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),$t("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[$t("div",{className:"text-black dark:text-white",children:l}),s&&$t("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),$t("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},La=({isOpen:e,onClose:t,keyword:n,onSearchChange:r,results:a,loading:o,onResultClick:i,emptyText:l})=>{const s=v(null),{t:d}=Wn();return m(()=>(e?(setTimeout(()=>{var e;null===(e=s.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?c($t("div",{className:"df-portal fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[$t("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[$t("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:$t(Kr,{className:"h-6 w-6"})}),$t("div",{className:"relative flex-1",children:[$t("input",{ref:s,type:"text",placeholder:d("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&r(t)},className:"df-focus-ring-only w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&$t("button",{type:"button",onClick:()=>{""!==n&&r("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:$t(Yr,{className:"h-4 w-4"})})]})]}),$t("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:$t(Pa,{loading:o,results:a,keyword:n,onResultClick:e=>{null==i||i(e)},emptyText:l})})]}),document.body):null},$a=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>$t("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:$t("div",{className:"min-w-64 flex-1 overflow-y-auto",children:$t(Pa,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let ja=null;function Ya(e){ja=e}const Fa={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Za(e){return ja&&e.hasPlugin("sidebar")?ja(e):Fa}const za=({locale:e,messages:t,children:n})=>Wn().isDefault?$t(ra,{locale:e,messages:t,children:n}):n,Ua=({app:t,customDetailPanelContent:n,customEventDetailDialog:r,meta:a,customMessages:o,search:l,titleBarSlot:s,collapsedSafeAreaLeft:d})=>{const u=b(ca),{tick:h,selectedEventId:y}=function(e){const[t,n]=g(0),[r,a]=g(null);return m(()=>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}}(t),{isMobile:D}=function(){const[e,t]=g(!1);return m(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),w=function(t,n){const[r,a]=g(""),[o,i]=g(!1),[l,s]=g(!1),[d,c]=g(!1),[u,h]=g([]),p=v(""),y=v(!1);m(()=>{t.state.highlightedEventId&&t.selectEvent(t.state.highlightedEventId)},[t.state.highlightedEventId,t]),m(()=>{y.current&&!o&&null!==t.state.highlightedEventId&&t.highlightEvent(null),y.current=o},[o,t]),m(()=>{var a;if(!r.trim())return i(!1),h([]),p.current.trim()&&null!==t.state.highlightedEventId&&t.highlightEvent(null),void(p.current=r);const o=null!==(a=null==n?void 0:n.debounceDelay)&&void 0!==a?a:300,l=setTimeout(()=>e(this,void 0,void 0,function*(){var e;c(!0),i(!0);try{let a=[];if(null==n?void 0:n.customSearch){const e=t.getEvents().map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})});a=n.customSearch({keyword:r,events:e})}else if(null==n?void 0:n.onSearch)a=yield n.onSearch(r);else{const e=r.toLowerCase();a=t.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})})}h(a),null===(e=null==n?void 0:n.onSearchStateChange)||void 0===e||e.call(n,{keyword:r,loading:!1,results:a})}catch(e){console.error("Search failed",e),h([])}finally{c(!1)}}),o);return p.current=r,()=>clearTimeout(l)},[r,n,t]);const b=f((e,r="desktop")=>{const a=()=>{let n;n=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):Y(e.start),t.setCurrentDate(n),t.highlightEvent(e.id),l&&s(!1)},o=()=>{"mobile"===r?s(!1):i(!1)};(null==n?void 0:n.onResultClick)?n.onResultClick({event:e,app:t,source:r,defaultAction:a,closeSearch:o}):a()},[t,l,n]),D=f(()=>{a(""),s(!0)},[]),w=f(()=>{i(!1),a(""),t.highlightEvent(null)},[t]),x=f(()=>{s(!1),a(""),t.highlightEvent(null)},[t]);return{searchKeyword:r,setSearchKeyword:a,isSearchOpen:o,setIsSearchOpen:i,isMobileSearchOpen:l,setIsMobileSearchOpen:s,searchLoading:d,searchResults:u,handleSearchResultClick:b,handleSearchClick:D,handleSearchClose:w,handleMobileSearchClose:x}}(t,l),x=r||(t.getUseEventDetailDialog()?Ma:void 0),E=function(t,n,r){const[a,o]=g(null),i=v(null);m(()=>{o(null),i.current=null},[t]);const l=f(()=>{o(null),i.current=null,t.selectEvent(null)},[t]),s=f(e=>t.updateEvent(e.id,e),[t]),d=f(n=>e(this,void 0,void 0,function*(){yield t.deleteEvent(n),o(null),t.selectEvent(null)}),[t]),c=p(()=>{var e;if(!n||!a)return null;const r=a.split("::")[0],o=t.getEvents().find(e=>e.id===r);o&&(i.current=o);const c=null!=o?o:(null===(e=i.current)||void 0===e?void 0:e.id)===r?i.current:null;return c?{event:c,isOpen:!0,isAllDay:P(c.start),onEventUpdate:s,onEventDelete:d,onClose:l,app:t}:null},[r,a,n,l,s,d,t]);return{detailPanelEventId:a,setDetailPanelEventId:o,dialogProps:c}}(t,x,h),C=Za(t),k=function(e,t,n){const[r,a]=g(!1),o=v(null),[i,l]=g(!1),[s,d]=g(null),[c,u]=g(!1),h=f(()=>{u(!0)},[]),m=f(i=>{if(!e.canMutateFromUI())return;const s=e.getCalendarRegistry().getDefaultWritableCalendar();if(s){if(t){const{start:t,end:n}=ze(e.timeZone),r={id:Dt(),title:"",start:ke(t,e.timeZone),end:ke(n,e.timeZone),calendarId:s.id};return d(r),void l(!0)}n?r?a(!1):(o.current=i.currentTarget,a(!0)):h()}},[t,r,e,n,h]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:a,quickCreateAnchorRef:o,isMobileDrawerOpen:i,setIsMobileDrawerOpen:l,mobileDraftEvent:s,setMobileDraftEvent:d,handleAddButtonClick:m,isCreateCalendarOpen:c,setIsCreateCalendarOpen:u}}(t,D,C.enabled),[T,M]=g(()=>t.getTheme());m(()=>t.subscribeThemeChange(e=>M(e)),[t]);const S=f(e=>t.setTheme(e),[t]);m(()=>{const e=t.callbacks,n=e.onDismissUI;return e.onDismissUI=()=>{E.detailPanelEventId&&E.setDetailPanelEventId(null),k.isMobileDrawerOpen&&k.setIsMobileDrawerOpen(!1),null==n||n()},()=>{e.onDismissUI=n}},[t,E,k]),m(()=>{if(!D||!E.detailPanelEventId)return;const e=E.detailPanelEventId.split("::")[0],n=t.getEvents().find(t=>t.id===e);n&&(k.setMobileDraftEvent(n),k.setIsMobileDrawerOpen(!0)),E.setDetailPanelEventId(null)},[E.detailPanelEventId,D]);const N=f(e=>{t.setCurrentDate(e),t.selectEvent(null)},[t]),I=f(e=>t.selectEvent(e),[t]),O=v(null),R={app:t,config:t.getCurrentView().config||{},customDetailPanelContent:n,customEventDetailDialog:x,switcherMode:t.state.switcherMode,calendarRef:O,meta:a,selectedEventId:y,onEventSelect:I,onDateChange:N,detailPanelEventId:E.detailPanelEventId,onDetailPanelToggle:E.setDetailPanelEventId},H=p(()=>({isCollapsed:C.isCollapsed,toggleCollapsed:C.toggleCollapsed}),[C.isCollapsed,C.toggleCollapsed]),A=void 0!==d,L=A?"0px":C.miniWidth,$=A&&C.isCollapsed?d:C.safeAreaLeft,j=t.getCalendarHeaderConfig(),F=Object.assign({calendar:t,switcherMode:t.state.switcherMode,onAddCalendar:k.handleAddButtonClick,onSearchChange:w.setSearchKeyword,onSearchClick:w.handleSearchClick,searchValue:w.searchKeyword,isSearchOpen:w.isSearchOpen,isEditable:t.canMutateFromUI()},$>0?{safeAreaLeft:$}:{}),Z=t.getCurrentView().component,z=t.getCustomMobileEventRenderer()||Ha;return $t(sa,{initialTheme:T,onThemeChange:S,children:$t(za,{locale:t.state.locale,messages:o,children:$t("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[$t(ha,{store:u,generatorName:"titleBarSlot",generatorArgs:H,defaultContent:s&&("function"==typeof s?s(H):s)}),C.enabled&&$t("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:C.width},children:C.content}),$t("div",{className:"relative z-10 flex h-full flex-1 flex-col overflow-hidden border-l bg-white transition-all duration-200 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?L:C.width:0},children:[!1===j?null:$t(ha,{store:u,generatorName:"calendarHeader",generatorArgs:F,defaultContent:i(ia,F)}),$t("div",{className:"relative flex-1 overflow-hidden",ref:O,children:[$t("div",{className:"calendar-renderer relative flex h-full flex-row",children:[$t("div",{className:"h-full flex-1 overflow-hidden",children:$t(Z,Object.assign({},R))}),$t($a,{isOpen:w.isSearchOpen,onClose:w.handleSearchClose,loading:w.searchLoading,results:w.searchResults,keyword:w.searchKeyword,onResultClick:e=>w.handleSearchResultClick(e,"desktop"),emptyText:null==l?void 0:l.emptyText})]}),$t(La,{isOpen:w.isMobileSearchOpen,onClose:w.handleMobileSearchClose,keyword:w.searchKeyword,onSearchChange:w.setSearchKeyword,results:w.searchResults,loading:w.searchLoading,onResultClick:e=>w.handleSearchResultClick(e,"mobile"),emptyText:null==l?void 0:l.emptyText})]})]}),$t(Na,{app:t,anchorRef:k.quickCreateAnchorRef,isOpen:k.isQuickCreateOpen,onClose:()=>k.setIsQuickCreateOpen(!1)}),$t(z,{isOpen:k.isMobileDrawerOpen,onClose:()=>{k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onSave:e=>{t.getEvents().some(t=>t.id===e.id)?t.updateEvent(e.id,e):t.addEvent(e),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onEventDelete:e=>{t.deleteEvent(e),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},draftEvent:k.mobileDraftEvent,app:t}),C.extraContent,k.isCreateCalendarOpen&&$t(pa,{app:t,onClose:()=>k.setIsCreateCalendarOpen(!1),onCreate:n=>e(void 0,void 0,void 0,function*(){yield t.createCalendar(n),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==u?void 0:u.isOverridden("eventDetailDialog");return $t(ha,{store:u,generatorName:"eventDetailDialog",generatorArgs:E.dialogProps,defaultContent:n?null:c(i(e,E.dialogProps),t)})})()]})})})};class Wa{constructor(e){this.renderings=new Map,this.overrides=new Set,this.listeners=new Set,this.overrideListeners=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(),this.notifyOverrides()}isOverridden(e){return this.overrides.has(e)}subscribe(e){return this.listeners.add(e),e(this.renderings),()=>{this.listeners.delete(e)}}subscribeToOverrides(e){return this.overrideListeners.add(e),e(),()=>{this.overrideListeners.delete(e)}}notify(){this.listeners.forEach(e=>e(this.renderings))}notifyOverrides(){this.overrideListeners.forEach(e=>e())}}class _a{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new Wa(t),t&&this.app.setOverrides(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){wt(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.render()}unmount(){this.container&&(l(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&l(i(ca.Provider,{value:this.customRenderingStore},i(Ua,Object.assign({app:this.app},this.extraProps))),this.container)}}function Ba(t){return e(this,void 0,void 0,function*(){const e=yield fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=yield e.text(),r=Rn(n),a=n.match(/X-WR-CALNAME[^:]*:([^\r\n]+)/),o=a?a[1].trim():new URL(t).hostname,i=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],l=i[Math.floor(Math.random()*i.length)],{colors:s,darkColors:d}=se(l);return{calendar:{id:Dt(),name:o,isVisible:!0,colors:s,darkColors:d,subscription:{url:t,status:"ready"}},events:r.events}})}const Va=u(({x:e,y:t,onClose:n,children:r,className:a},o)=>{const i=v(null);m(()=>{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 c($t("div",{ref:e=>{i.current=e,"function"==typeof o?o(e):o&&"current"in o&&(o.current=e)},className:`df-portal df-animate-in df-fade-in df-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)});Va.displayName="ContextMenu";const Ga=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>$t("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-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)]"} ${r?"df-text-destructive df-hover-fill-destructive df-focus-fill-destructive":"text-[var(--df-color-foreground)]"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&$t("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Ka=()=>$t("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),qa=({children:e})=>$t("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),Xa=({children:e})=>{const[t,n]=g(!1),r=v(null);return m(()=>()=>{r.current&&clearTimeout(r.current)},[]),$t("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=>s(e)?d(e,{isOpen:t}):e)})},Ja=({children:e,icon:t,isOpen:n})=>$t("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors outline-none select-none hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)] "+(n?"bg-[var(--df-color-primary)] text-[var(--df-color-primary-foreground)]":""),children:[t&&$t("span",{className:"mr-2 h-4 w-4",children:t}),$t("span",{className:"grow text-left",children:e}),$t(Or,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),Qa=({children:e,isOpen:t})=>{const n=v(null),[r,a]=g("right");return m(()=>{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?$t("div",{ref:n,className:"df-portal df-animate-in df-fade-in df-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},eo=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],to=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=Wn();return $t("div",{children:[$t("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:eo.map(n=>$t("button",{type:"button",className:"df-focus-ring-only h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 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()?"df-ring-primary-solid ring-2 ring-offset-1 dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&$t("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)]",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},no=({x:t,y:n,date:r,onClose:a,app:i,onCreateEvent:l,viewType:s})=>{const{t:d}=Wn();if(!i.canMutateFromUI())return null;const c=bn.hasEvent(),u=$t(o,{children:[$t(Ga,{onClick:()=>{l(),a()},children:d("newEvent")||"New Event"}),$t(Ga,{onClick:()=>e(void 0,void 0,void 0,function*(){yield((t,n,r)=>e(void 0,void 0,void 0,function*(){if(bn.hasEvent())try{let e=bn.getEvent();if(!e){const t=yield navigator.clipboard.readText();t&&(e=JSON.parse(t))}if(e&&"object"==typeof e&&"title"in e){const a=e,o=De(a.start),i=De(a.end).getTime()-o.getTime(),l=e,s=new Date(n),d=r===I.MONTH||r===I.YEAR,c=0===s.getHours()&&0===s.getMinutes(),u=0!==o.getHours()||0!==o.getMinutes();!a.allDay&&(d||c&&u)&&s.setHours(o.getHours(),o.getMinutes(),o.getSeconds(),o.getMilliseconds());const h=new Date(s.getTime()+(i>0?i:36e5)),g=Object.assign(Object.assign({},l),{title:a.title,id:Dt(),start:a.allDay?Ee(s):ke(s,t.timeZone),end:a.allDay?Ee(h):ke(h,t.timeZone),calendarId:a.calendarId&&t.getCalendarRegistry().has(a.calendarId)?a.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(g)}}catch(e){console.error("Failed to paste event:",e)}}))(i,r,s),a()}),disabled:!c,children:d("pasteHere")||"Paste Here"})]});return $t(Va,{x:t,y:n,onClose:a,className:"df-context-menu",children:$t(ha,{generatorName:"gridContextMenu",generatorArgs:{date:r,viewType:s,onClose:a},defaultContent:u})})},ro=({event:t,x:n,y:r,onClose:a,app:i})=>{const{t:l}=Wn();if(!i.canMutateFromUI(t.id))return null;const s=i.getCalendars(),d=$t(o,{children:[$t(Xa,{children:[$t(Ja,{children:l("calendars")||"Calendars"}),$t(Qa,{children:s.map(e=>{const n=e.id===t.calendarId;return $t(Ga,{onClick:()=>{return n=e.id,i.updateEvent(t.id,{calendarId:n}),void a();var n},children:$t("div",{className:"flex w-full items-center",children:[$t("div",{className:"w-4 shrink-0",children:n&&$t($r,{className:"df-text-primary h-3 w-3"})}),$t("div",{className:"flex min-w-0 items-center gap-1.5",children:[$t("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:e.colors.lineColor}}),$t("span",{className:"truncate "+(n?"font-semibold":""),children:e.name})]})]})},e.id)})})]}),$t(Ka,{}),$t(Ga,{onClick:()=>{i.deleteEvent(t.id),a()},danger:!0,children:l("delete")||"Delete"}),$t(Ga,{onClick:()=>e(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),bn.setEvent(t),i.deleteEvent(t.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:l("cut")||"Cut"}),$t(Ga,{onClick:()=>e(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),bn.setEvent(t)}catch(e){console.error("Failed to copy event: ",e)}a()}),children:l("copy")||"Copy"})]});return $t(Va,{x:n,y:r,onClose:a,children:$t(ha,{generatorName:"eventContextMenu",generatorArgs:{event:t,onClose:a},defaultContent:d})})},ao=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("假期")?$t(Ur,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?$t(Wr,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?$t(Br,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?$t(_r,{className:"h-3 w-3"}):$t(Fr,{className:"h-3 w-3"})},oo=(e,t,n=7,r)=>{const a=[],o=new Date(t);return o.setDate(t.getDate()+(n-1)),o.setHours(23,59,59,999),e.forEach(e=>{const i=we(e.start,r),l=e.end?we(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay){if(!(0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds())){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}}const u=B(s,c)>0;if(!u&&e.allDay){if(s<t||s>o)return;const r=Math.floor((s.getTime()-t.getTime())/864e5);return void(r>=0&&r<=n-1&&a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:r,endDayIndex:r,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!u)return;const h=s;let g;if(e.allDay)g=new Date(d),g.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds()?(g=new Date(d),g.setHours(23,59,59,999)):(g=new Date(d),g.setTime(g.getTime()-1))}if(g<t||h>o)return;const m=h<t?t:h,v=g>o?o:g,f=Math.max(0,Math.floor((m.getTime()-t.getTime())/864e5)),p=Math.min(n-1,Math.floor((v.getTime()-t.getTime())/864e5)),y=h>=t,b=g<=o,D=0===f||p===n-1;let w;w=y&&b?"single":y?D&&p===n-1?"start-week-end":"start":b?D&&0===f?"end-week-start":"end":"middle";const x=B(h,g)+1;a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:f,endDayIndex:p,segmentType:w,totalDays:x,segmentIndex:0,isFirstSegment:y,isLastSegment:b})}),a},io=(e,t,n=7,r)=>{if(e.allDay)return[];const a=we(e.start,r),o=e.end?we(e.end,r):a,i=new Date(a);i.setHours(0,0,0,0);const l=new Date(o);l.setHours(0,0,0,0);const s=B(i,l);if(0===s)return[];const d=0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()||0!==o.getMilliseconds(),c=o.getTime()-a.getTime();if(!e.allDay&&1===s&&!d&&c<864e5)return[];const u=d?s:Math.max(0,s-1),h=[];for(let e=0;e<=u;e++){const r=new Date(i);r.setDate(i.getDate()+e);const l=Math.floor((r.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const s=0===e,c=e===u,g=s?a.getHours()+a.getMinutes()/60:0,m=c&&d?o.getHours()+o.getMinutes()/60:24;h.push({dayIndex:l,startHour:g,endHour:m,isFirst:s,isLast:c})}return h},lo=h(({segment:e,segmentIndex:t,isDragging:n,isResizing:r=!1,isSelected:a=!1,onMoveStart:i,onResizeStart:l,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:u=!0,viewable:h=!0,isPopping:m,renderSlot:f,appTimeZone:y})=>{const[b,D]=g(!1),w=p(()=>{if(!y||e.event.allDay)return e.event;const t=xe(e.event.start,y),n=e.event.end?xe(e.event.end,y):void 0;return Object.assign(Object.assign({},e.event),{start:t,end:n})},[e.event,y]),x=17*t,E=`calc(${e.startDayIndex/7*100}% + 2px)`,C=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,k=v(null),T=v(null),M=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&l&&u?$t("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},S=()=>{const t=w.allDay,n=w.calendarId||"blue",r=q(w.start),a=Pe(w),o=Ae(r),i=Ae(a);if(t){const t=()=>e.isFirstSegment?w.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":w.title;return $t("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&ao(w)&&$t("div",{className:"mr-1 shrink-0",children:$t("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:he(n),width:"12px",height:"12px"},children:ao(w)})}),$t("div",{className:"min-w-0 flex-1",children:$t("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&$t("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:$t("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?w.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 $t("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[$t("div",{className:lr,style:{backgroundColor:he(n)}}),$t("div",{className:"flex min-w-0 flex-1 items-center",children:$t("span",{className:`block overflow-hidden whitespace-nowrap ${d?"df-mobile-mask-fade":"truncate"} text-xs font-medium`,children:l})}),e.isFirstSegment&&!d&&$t("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:c,children:o}),e.isLastSegment&&!w.allDay&&24!==a&&!d&&$t("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})},N=e.event.calendarId||"blue",I=e.endDayIndex-e.startDayIndex+1;return $t("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:E,width:C,top:`${x}px`,height:"16px",borderRadius:(O=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"}[O]),pointerEvents:"auto",zIndex:10,transform:m?"scale(1.02)":"scale(1)",transition:"transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",willChange:"transform"},a||n||b?{backgroundColor:ue(N),color:"#fff"}:{backgroundColor:de(N),color:ce(N)}),{cursor:c||h?"pointer":"default"}),"data-segment-days":I,onMouseDown:t=>{if(!c&&!h)return;t.preventDefault(),t.stopPropagation(),D(!0);!t.target.closest(".resize-handle")&&c&&(null==i||i(t,e.event))},onMouseUp:()=>{D(!1)},onMouseLeave:()=>{D(!1)},onTouchStart:t=>{if(!i||!d||!c&&!h)return;t.stopPropagation(),D(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;T.current={x:r,y:a},k.current=setTimeout(()=>{s&&s(e.event.id);c&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),k.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(k.current&&T.current){const t=Math.abs(e.touches[0].clientX-T.current.x),n=Math.abs(e.touches[0].clientY-T.current.y);(t>10||n>10)&&(clearTimeout(k.current),k.current=null,T.current=null,D(!1))}},onTouchEnd:()=>{D(!1),k.current&&(clearTimeout(k.current),k.current=null),T.current=null},title:`${w.title} (${jt(w.start)} - ${jt(w.end)})`,children:[d&&a&&u&&$t(o,{children:[e.isFirstSegment&&$t("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:he(N)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"left")}}),e.isLastSegment&&$t("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:he(N)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"right")}})]}),M("left"),$t("div",{className:"min-w-0 flex-1",style:{cursor:r?"ew-resize":"pointer"},children:f?f(S()):S()}),M("right")]});var O});lo.displayName="MultiDayEvent";const so=({event:e,isEditable:t,onResizeStart:n,isMultiDay:r,segment:a,isSlidingView:i,renderSlot:l})=>{const s=!1!==e.icon,d="boolean"==typeof e.icon?null:e.icon,c=(()=>{if(!i||!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{}})(),u=$t("div",{className:"flex h-full flex-1 items-center overflow-hidden",children:[s&&(d?$t("div",{className:"mr-1 shrink-0",children:d}):$t(Fr,{className:sr})),$t("div",{className:`${ir} pr-1`,style:{lineHeight:"1.2"},children:e.title})]});return $t("div",{className:"absolute inset-0 flex items-center overflow-hidden pl-3 px-1 group py-0",style:c,children:[l?l(u):u,n&&t&&$t(o,{children:[$t("div",{className:dr,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),$t("div",{className:cr,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},co=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return $t("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?$t("div",{className:`${Sr} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?$t("span",{className:`inline-block ${Sr} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):$t(Fr,{className:`${sr} ${t?"text-white":""}`})),$t("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},uo=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(q(e.start)).toString().padStart(2,"0")}:${Math.round(q(e.start)%1*60).toString().padStart(2,"0")}`;return $t("div",{className:"text-xs cursor-pointer flex items-center justify-between px-0.5",children:[$t("div",{className:"flex min-w-0 flex-1 items-center",children:[$t("div",{style:{backgroundColor:he(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:lr}),$t("span",{className:`block overflow-hidden whitespace-nowrap ${a?"df-mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&$t("span",{className:`${kr} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},ho=({event:e,app:t,multiDaySegmentInfo:n,isEditable:r,isTouchEnabled:a,isEventSelected:i,onResizeStart:l,timeFormat:s="24h",resizeHandleOrientation:d="vertical",renderSlot:c})=>{const u=n?n.startHour:q(e.start),h=n?n.endHour:Pe(e),g=h-u,m=!n||n.isFirst,v=!n||n.isLast,f=e.calendarId||"blue",p=!n&&g<=.25?"px-1 py-0":"p-1",y=$t(o,{children:[$t("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:he(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),$t("div",{className:`flex h-full flex-col overflow-hidden pl-3 ${p}`,children:[$t("div",{className:`${ir} pr-1`,style:{lineHeight:g<=.25?"1.2":"normal"},children:e.title}),g>.5&&$t("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${Ae(u,0,s)} - ${Ae(h,0,s)}`:Le(e,s)})]})]});return $t(o,{children:[c?c(y):y,l&&r&&"vertical"===d&&$t(o,{children:[m&&$t("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")}),v&&$t("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")}),!m&&v&&n&&$t("div",{className:cr,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),a&&i&&l&&r&&"vertical"===d&&$t(o,{children:[$t("div",{className:"absolute -top-1.5 right-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:he(f,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),$t("div",{className:"absolute -bottom-1.5 left-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:he(f,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]}),l&&r&&"horizontal"===d&&$t(o,{children:[$t("div",{className:dr,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),$t("div",{className:cr,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},go=({event:e,segment:t,isEditable:n,onMoveStart:r,onResizeStart:a,renderSlot:i})=>{const l=!!e.allDay,s=e.calendarId||"blue",d=he(s),c=l?ao(e):null,{isFirstSegment:u,isLastSegment:h}=t,g=t=>{const r="left"===t,o=r?u:h;return e.allDay&&o&&a&&n?$t("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(),a(t,e,r?"left":"right")},onTouchStart:t=>{t.stopPropagation(),a(t,e,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},m=()=>{if(l){const n=()=>t.isFirstSegment?e.title:"···";return $t("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full min-w-0 items-center",onMouseDown:t=>{r&&(t.stopPropagation(),r(t,e))},children:[t.isFirstSegment&&ao(e)&&$t("div",{className:"df-year-event-icon mr-1 shrink-0",children:$t("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:he(s),width:"12px",height:"12px"},children:ao(e)})}),$t("div",{className:"min-w-0 flex-1",children:$t("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&&$t("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:$t("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const n=t.isFirstSegment?e.title:"";return $t("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full items-center gap-1 overflow-hidden",onMouseDown:t=>{r&&(t.stopPropagation(),r(t,e))},children:[!l&&$t("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),l&&c&&$t("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:c}),$t("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 $t(o,{children:[g("left"),i?i(m()):m(),g("right")]})};const mo=({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:D,multiDaySegmentInfo:w,customRenderingStore:x,eventContentSlotArgs:E,timeFormat:C="24h",appTimeZone:k,renderVisualContent:T,resizeHandleOrientation:M})=>{const S=t===I.MONTH,N=t===I.YEAR,O=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),R=e=>T?T(e):e;if(S&&r&&a)return $t(lo,{segment:a,segmentIndex:null!=i?i:0,isDragging:l||d,isResizing:s,isSelected:d,onMoveStart:b,onResizeStart:D,isMobile:f,isDraggable:h,isEditable:u,viewable:g,isPopping:c,appTimeZone:k,renderSlot:e=>$t(ha,{store:x,generatorName:O,generatorArgs:E,defaultContent:R(e)})});if(N&&o)return $t(go,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:D,renderSlot:e=>$t(ha,{store:x,generatorName:O,generatorArgs:E,defaultContent:R(e)})});if(S){const t=e.allDay?$t(co,{event:e,isEventSelected:d}):$t(uo,{event:e,app:y,isEventSelected:d,hideTime:v,isMobile:f});return $t(ha,{store:x,generatorName:O,generatorArgs:E,defaultContent:R(t)})}const H=e=>$t(ha,{store:x,generatorName:O,generatorArgs:E,defaultContent:R(e)});return n?$t(so,{event:e,isEditable:u,onResizeStart:D,isMultiDay:r,segment:a,isSlidingView:p,renderSlot:H}):$t(ho,{event:e,app:y,multiDaySegmentInfo:w,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:D,timeFormat:C,resizeHandleOrientation:M,renderSlot:H})},vo=(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},fo=e=>{var t;const n=e.current;if(!n)return null;const r=n.matches(".df-calendar-content")?n:null,a=n.querySelector(".df-calendar-content"),o=n.closest(".df-calendar-content");return null!==(t=null!=r?r:a)&&void 0!==t?t:o},po=(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 ar;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 ar};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():or}\n `;return n||(e+=" mb-[2px] last:mb-0"),e}return`\n ${o}\n shadow-sm\n ${t?d():or}\n `},yo=({event:t,position:r,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:u,onClose:h,app:y})=>{var b,D;const{effectiveTheme:w}=da(),x=rn(w),{t:E}=Wn(),[C,k]=g(t),[T,M]=g(!1),S=v(t),N=v(t),I=v(!1),O=f(()=>{if(I.current)return;const e=S.current,t=N.current;if(pt(e,t))return;const n=We(e,t,null==y?void 0:y.timeZone);S.current=n,N.current=n;const r=d(n);r&&Promise.resolve(r).catch(e=>{ge.error("Failed to commit deferred event detail panel update",e)})},[null==y?void 0:y.timeZone,d]),R=f(e=>{if(!pt(N.current,e)&&(N.current=e,k(e),y)){const t=y.updateEvent(e.id,e,!0);t&&Promise.resolve(t).catch(e=>{ge.error("Failed to apply pending event detail panel update",e)})}},[y]);m(()=>{if(!(S.current.id===t.id))return O(),I.current=!1,S.current=t,N.current=t,void k(t);pt(S.current,N.current)&&(S.current=t,N.current=t,k(t))},[t,O]),m(()=>()=>{O()},[O]);const H=p(()=>{var e;return null!==(e=null==y?void 0:y.timeZone)&&void 0!==e?e:n.Now.timeZoneId()},[y]),A=p(()=>(y?y.getCalendarRegistry():le()).getVisible().map(e=>({label:e.name,value:e.id})),[y,null==y?void 0:y.getCalendars()]),L="dark"===x||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),$=null!==(b=null==y?void 0:y.canMutateFromUI(t.id))&&void 0!==b&&b,j=null==y?void 0:y.getReadOnlyConfig(t.id),Y=!1!==(null==j?void 0:j.viewable),F=!!C.allDay,Z=!p(()=>{if(!t.calendarId)return!1;const e=null==y?void 0:y.getCalendarRegistry().get(t.calendarId);return!!(null==e?void 0:e.subscription)},[y,t.calendarId])||""!==(C.description||"").trim();if(!Y)return null;const z=L?"#1f2937":"white",U=L?"rgb(55, 65, 81)":"rgb(229, 231, 235)",W=(()=>{let e={};if("sticky-top"===i){const t=fo(l);if(t){const n=t.getBoundingClientRect().top+3-r.top;e=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:z,transform:"rotate(45deg)",transformOrigin:"center",top:n-6+"px",borderRight:""+(r.isSunday?`1px solid ${U}`:"none"),borderTop:""+(r.isSunday?`1px solid ${U}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${U}`),borderBottom:""+(r.isSunday?"none":`1px solid ${U}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const t=a.current;let n=200;if(t){const e=t.getBoundingClientRect(),r=window.getComputedStyle(t),a=Number.parseInt(r.paddingBottom,10)||0,o=Number.parseInt(r.borderBottomWidth,10)||0;n=e.height-a-o-6+11}e={position:"absolute",width:"12px",height:"12px",backgroundColor:z,transform:"rotate(45deg)",transformOrigin:"center",top:`${n}px`,left:r.isSunday?void 0:"-6px",right:r.isSunday?"-6px":void 0,borderRight:""+(r.isSunday?`1px solid ${U}`:"none"),borderTop:""+(r.isSunday?`1px solid ${U}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${U}`),borderBottom:""+(r.isSunday?"none":`1px solid ${U}`)}}else if(r&&s.current&&l.current){const t=s.current.getBoundingClientRect(),n=fo(l);if(n){const o=n.getBoundingClientRect(),i=Math.max(t.top,o.top),l=Math.min(t.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===t.height?t.top+t.height/2:s>0?i+s/2:t.top+t.height/2;const c=d-r.top,u=a.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));e=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:z,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(r.isSunday?`1px solid ${U}`:"none"),borderTop:""+(r.isSunday?`1px solid ${U}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${U}`),borderBottom:""+(r.isSunday?"none":`1px solid ${U}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}return e})(),_=$t("div",{ref:a,className:`${mr} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${r.top}px`,left:`${r.left}px`,zIndex:9999,pointerEvents:"auto"},children:[$t("div",{style:W}),$t("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:E("eventTitle")}),$t("div",{className:"mb-3 flex items-center justify-between gap-3",children:[$t("div",{className:"flex-1",children:$t("input",{id:`event-title-${C.id}`,name:"title",type:"text",value:C.title,readOnly:!$||T,disabled:!$||T,onChange:e=>R(Object.assign(Object.assign({},C),{title:e.target.value})),onInput:e=>R(Object.assign(Object.assign({},C),{title:e.target.value})),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),$&&$t(Ta,{options:A,value:C.calendarId||"blue",disabled:T,onChange:e=>{R(Object.assign(Object.assign({},C),{calendarId:e}))},registry:null==y?void 0:y.getCalendarRegistry()})]}),$t("div",F?{className:"mb-3",children:[$t("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:E("dateRange")}),$t(ka,{value:[C.start,C.end],format:"YYYY-MM-DD",showTime:!1,timeZone:H,matchTriggerWidth:!0,disabled:!$||T,onChange:e=>{if(T)return;const[t,n]=e;R(Object.assign(Object.assign({},C),{start:t.toPlainDate(),end:n.toPlainDate()}))},locale:null==y?void 0:y.state.locale})]}:{className:"mb-3",children:[$t("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:E("timeRange")}),$t(ka,{value:[C.start,C.end],timeZone:H,disabled:!$||T,onChange:e=>{if(T)return;const[t,n]=e;R(Object.assign(Object.assign({},C),{start:t,end:n}))},locale:null==y?void 0:y.state.locale})]}),Z&&$t("div",{className:"mb-3",children:[$t("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:E("note")}),$t("textarea",{id:`event-note-${C.id}`,name:"note",value:null!==(D=C.description)&&void 0!==D?D:"",readOnly:!$||T,disabled:!$||T,onChange:e=>R(Object.assign(Object.assign({},C),{description:e.target.value})),onInput:e=>R(Object.assign(Object.assign({},C),{description:e.target.value})),rows:3,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:E("addNotePlaceholder")})]}),$&&$t("div",{className:"flex space-x-2",children:[$t(va,F?{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{var e;if(T)return;const t=P(C.start)?C.start:C.start.toPlainDate(),r=null!==(e=null==y?void 0:y.timeZone)&&void 0!==e?e:n.Now.timeZoneId(),a=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:r}),o=n.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:r});R(Object.assign(Object.assign({},C),{allDay:!1,start:a,end:o}))},loading:T,children:E("setAsTimed")}:{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{if(T)return;const e=P(C.start)?C.start:C.start.toPlainDate(),t=P(C.end)?C.end:C.end.toPlainDate();R(Object.assign(Object.assign({},C),{allDay:!0,start:e,end:t}))},loading:T,children:E("setAsAllDay")}),$t(va,{type:"button",className:"df-fill-destructive df-hover-destructive rounded px-2 py-1 text-xs font-medium transition",onClick:()=>e(void 0,void 0,void 0,function*(){if(!T){I.current=!0,M(!0);try{yield u(C.id)}finally{M(!1)}}}),loading:T,children:E("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const B=document.body;return B?c(_,B):null},bo=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:a,calendarRef:o,selectedEventElementRef:i,onEventUpdate:l,onEventDelete:s,onClose:d,contentRenderer:u})=>{const{effectiveTheme:h}=da(),g=rn(h),m="dark"===g?"#1f2937":"white",v="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{let e={};if("sticky-top"===a){const n=fo(o);if(n){const r=n.getBoundingClientRect().top+3-t.top;e=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:r-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 r=n.current;let a=200;if(r){const e=r.getBoundingClientRect(),t=window.getComputedStyle(r),n=Number.parseInt(t.paddingBottom,10)||0,o=Number.parseInt(t.borderBottomWidth,10)||0;a=e.height-n-o-6+11}e={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 r=i.current.getBoundingClientRect(),a=fo(o);if(a){const o=a.getBoundingClientRect(),i=Math.max(r.top,o.top),l=Math.min(r.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===r.height?r.top+r.height/2:s>0?i+s/2:r.top+r.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));e=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 e})(),p=$t("div",{ref:n,className:`${mr} 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:[$t("div",{style:f}),$t(u,{event:e,isAllDay:r,onEventUpdate:l,onEventDelete:s,onClose:d})]});return c(p,document.body)},Do=({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"))?$t(bo,Object.assign({},f,{contentRenderer:g})):m?$t(bo,Object.assign({},f,{contentRenderer:m})):$t(yo,Object.assign({},f,{app:v}))},wo="transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",xo=({event:e,layout:t,isAllDay:n=!1,allDayHeight:r=28,calendarRef:a,isBeingDragged:i=!1,isBeingResized:l=!1,viewType:s,isMultiDay:d=!1,segment:c,yearSegment:u,columnsPerRow:h,segmentIndex:y=0,hourHeight:D,firstHour:w,selectedEventId:x,detailPanelEventId:E,onMoveStart:C,onResizeStart:k,onEventUpdate:T,onEventDelete:M,newlyCreatedEventId:S,onDetailPanelOpen:N,onEventSelect:O,onEventLongPress:R,onDetailPanelToggle:H,customDetailPanelContent:A,customEventDetailDialog:P,multiDaySegmentInfo:L,app:$,isMobile:j=!1,isSlidingView:Y=!1,enableTouch:F,hideTime:Z,timeFormat:z="24h",styleOverride:U,className:W,disableDefaultStyle:_=!1,renderVisualContent:B,resizeHandleOrientation:V,appTimeZone:G})=>{var K;const X=b(ca),J=null!=F?F:j,Q=s===I.YEAR,ee=p(()=>{if(!G||e.allDay)return e;const t=xe(e.start,G),n=e.end?xe(e.end,G):void 0;return Object.assign(Object.assign({},e),{start:t,end:n})},[e,G]),[te,ne]=g(null),[re,ae]=g(!1),oe=v(null),ie=v(null),le=v(null),se=v(null),he=d&&c?`${e.id}::${c.id}`:void 0===(null==L?void 0:L.dayIndex)?Q&&u?u.id:e.id:`${e.id}::day-${L.dayIndex}`,ge=E===he,me=ge&&!P,ve=null==$?void 0:$.getReadOnlyConfig(e.id),fe=null!==(K=null==$?void 0:$.canMutateFromUI(e.id))&&void 0!==K&&K,pe=!1!==(null==ve?void 0:ve.viewable),ye=!1!==(null==ve?void 0:ve.draggable),{isSelected:be,setIsSelected:De,isPressed:we,setIsPressed:Ee,handleTouchStart:Ce,handleTouchMove:ke,handleTouchEnd:Te}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:a,canOpenDetail:o,app:i,multiDaySegmentInfo:l,isMultiDay:s,segment:d,detailPanelKey:c})=>{const[u,h]=g(!1),[m,f]=g(!1),p=v(null),y=v(null);return{isSelected:u,setIsSelected:h,isPressed:m,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):h(!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:J,onMoveStart:ye?C:void 0,onEventLongPress:R,onDetailPanelToggle:H,canOpenDetail:pe,app:$,multiDaySegmentInfo:L,isMultiDay:d,segment:c,detailPanelKey:he}),[Me,Se]=g("visible"),Ne=e=>{se.current=e},Ie=f(()=>((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,he,se.current,L,c),[e,E,he,L,c]),Oe=f(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=vo(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,a,s,j),[a,s,j]),Re=f(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=vo(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,a,s,j),[a,s,j]),{detailPanelPosition:He,setDetailPanelPosition:Ae,updatePanelPosition:Le}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,multiDaySegmentInfo:o,calendarRef:i,eventRef:l,detailPanelRef:s,selectedEventElementRef:d,isMobile:c,eventVisibility:u,firstHour:h,hourHeight:v,columnsPerRow:p,showDetailPanel:y,detailPanelEventId:b,detailPanelKey:D,getActiveDayIdx:w,getDayMetricsWrapper:x})=>{const[E,C]=g(null),k=t===I.DAY,T=t===I.MONTH,M=t===I.YEAR,S=t===I.RESOURCE,N=f(()=>{if(!d.current||!i.current||!s.current)return;const e=i.current.getBoundingClientRect(),t=w(),a=x(t);let o,h;if(a)o=a.left,h=a.width;else if(T)h=e.width/7,o=e.left+t*h;else{const n=vo(i,c);h=(e.width-n)/7,o=e.left+n+t*h}const g=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 h=s.current.getBoundingClientRect(),v=h.width,f=h.height;let p,y,b;if("sticky-top"===u||"sticky-bottom"===u||"sticky-left"===u||"sticky-right"===u){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 D=g-b.right,w=b.left-e.left;p=D>=v+20?b.right+10:w>=v+20?b.left-v-10:D>w?Math.max(e.left+10,g-v-10):e.left+10;const E=b.top-f/2+b.height/2,k=Math.max(10,e.top+10),N=m-10;y=E<k?k:E+f>N?N-f:E,C(e=>{if(!e)return null;let t=p<o;return(M||S)&&(t=p<b.left),Object.assign(Object.assign({},e),{top:y,left:p,isSunday:t})})})},[i,e.day,e.start,e.end,u,T,h,v,n,r,o,b,D,c,k,M,a,p,w,x,d,s,l]);return m(()=>{!y||E||c||(C({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>N()))},[y,E,N,c]),{detailPanelPosition:E,setDetailPanelPosition:C,updatePanelPosition:N}})({event:e,viewType:s,isMultiDay:d,segment:c,yearSegment:u,multiDaySegmentInfo:L,calendarRef:a,eventRef:oe,detailPanelRef:ie,selectedEventElementRef:le,isMobile:j,eventVisibility:Me,firstHour:w,hourHeight:D,columnsPerRow:h,showDetailPanel:ge,detailPanelEventId:E,detailPanelKey:he,getActiveDayIdx:Ie,getDayMetricsWrapper:Re}),{handleClick:$e,handleDoubleClick:je,handleContextMenu:Ye,hasPendingSelection:Fe}=(({event:e,timingEvent:t,viewType:n,isAllDay:r,isMultiDay:a,segment:o,multiDaySegmentInfo:i,calendarRef:l,firstHour:s,hourHeight:d,isMobile:c,canOpenDetail:u,detailPanelKey:h,app:p,onEventSelect:y,onDetailPanelToggle:b,setIsSelected:D,setDetailPanelPosition:w,setContextMenuPosition:x,setActiveDayIndex:E,getClickedDayIdx:C,updatePanelPosition:k,selectedEventElementRef:T})=>{const M=n===I.MONTH,S=n===I.YEAR,N=n===I.RESOURCE,O=null!=t?t:e,R=v(null),[H,A]=g(!1),P=f(()=>{R.current&&(clearTimeout(R.current),R.current=null,A(!1))},[]);m(()=>()=>P(),[P]);const L=f((e,t,n)=>new Promise(r=>{let a=0,o=0,i=t,l=n;const s=()=>{const t=e.scrollLeft,n=e.scrollTop,d=Math.abs(t-i)>1||Math.abs(n-l)>1;a=d?0:a+40,o+=40,i=t,l=n,a>=120||o>=600?r():setTimeout(s,40)};setTimeout(s,40)}),[]),$=f(()=>new Promise(e=>{if(!l.current||r||M||S)return void e();const t=fo(l);if(!t)return void e();if(N&&T.current){const n=T.current.getBoundingClientRect(),r=t.getBoundingClientRect();if(n.left>=r.left&&n.right<=r.right&&n.top>=r.top&&n.bottom<=r.bottom)return void e();const a=t.scrollLeft,o=t.scrollTop,i=a+(n.left-r.left)-(t.clientWidth-n.width)/2,l=o+(n.top-r.top)-(t.clientHeight-n.height)/2,s=Math.max(0,t.scrollWidth-t.clientWidth),d=Math.max(0,t.scrollHeight-t.clientHeight),c=Math.max(0,Math.min(s,i)),u=Math.max(0,Math.min(d,l));return Math.abs(c-a)>1||Math.abs(u-o)>1?(t.scrollTo({left:c,top:u,behavior:"smooth"}),void L(t,a,o).then(e)):void e()}const n=i?i.startHour:q(O.start),a=i?i.endHour:Pe(O),o=(n-s)*d,c=o+Math.max((a-n)*d,d/4),u=t.scrollTop,h=t.clientHeight;if(o>=u&&c<=u+h)return void e();const g=((n+a)/2-s)*d-h/2,m=t.scrollHeight-h,v=Math.max(0,Math.min(m,g));Math.abs(v-u)<=1?e():(t.scrollTo({top:v,behavior:"smooth"}),L(t,t.scrollLeft,u).then(e))}),[l,r,M,S,N,i,O.start,O.end,s,d,T,L]),j=f(t=>{P(),t.preventDefault(),t.stopPropagation(),p&&!p.canMutateFromUI(e.id)||(y&&y(e.id),x({x:t.clientX,y:t.clientY}))},[p,P,e.id,y,x]),Y=f(t=>{var n,r,l;if(a){const a=C(t);E(null===a?null!==(r=null!==(n=null==i?void 0:i.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null:o?Math.min(Math.max(a,o.startDayIndex),o.endDayIndex):a)}else E(null!==(l=e.day)&&void 0!==l?l:null);p&&p.onEventClick(e),y?y(e.id):u&&D(!0),null==b||b(null),w(null)},[a,C,E,null==i?void 0:i.dayIndex,e,o,p,y,u,D,b,w]),F=f(t=>{var n,r,i,l,s;if(P(),t.preventDefault(),t.stopPropagation(),!u)return;let d=t.currentTarget;if(a){const e=d.querySelector("div");e&&(d=e)}if(T.current=d,a){const a=C(t.clientX);E(null===a?null!==(r=null!==(n=null==o?void 0:o.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:0:Math.min(Math.max(a,null!==(i=null==o?void 0:o.startDayIndex)&&void 0!==i?i:0),null!==(l=null==o?void 0:o.endDayIndex)&&void 0!==l?l:6))}else E(null!==(s=e.day)&&void 0!==s?s:null);p&&p.onEventClick(e),D(!0),null==y||y(e.id),$().then(()=>{c||(null==b||b(h),w({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>k()))})},[P,u,a,T,C,E,null==o?void 0:o.startDayIndex,null==o?void 0:o.endDayIndex,e.day,p,e,$,D,S,c,y,b,h,w,k]);return{handleClick:f(e=>{e.preventDefault(),e.stopPropagation();const t=e.clientX;if((S||N)&&!c)return P(),A(!0),void(R.current=setTimeout(()=>{Y(t),R.current=null,A(!1)},180));Y(t)},[P,S,N,c,Y]),handleDoubleClick:F,handleContextMenu:j,hasPendingSelection:H,scrollEventToCenter:$}})({event:e,timingEvent:ee,viewType:s,isAllDay:n,isMultiDay:d,segment:c,multiDaySegmentInfo:L,calendarRef:a,firstHour:w,hourHeight:D,isMobile:j,canOpenDetail:pe,detailPanelKey:he,app:$,onEventSelect:O,onDetailPanelToggle:H,setIsSelected:De,setDetailPanelPosition:Ae,setContextMenuPosition:ne,setActiveDayIndex:Ne,getClickedDayIdx:Oe,updatePanelPosition:Le,selectedEventElementRef:le}),Ze=(void 0===x?be:x===e.id)||Fe||!J&&we||i,{calculateEventStyle:ze}=(({event:e,timingEvent:t,layout:n,isBeingDragged:r,isAllDay:a,allDayHeight:o,viewType:i,isMultiDay:l,segment:s,yearSegment:d,columnsPerRow:c,segmentIndex:u,hourHeight:h,firstHour:g,isEventSelected:m,showDetailPanel:v,isPopping:f,isDraggable:p,canOpenDetail:y,eventVisibility:b,calendarRef:D,isMobile:w,eventRef:x,getActiveDayIdx:E,getDayMetricsWrapper:C,multiDaySegmentInfo:k})=>{const T=i===I.DAY,M=i===I.MONTH,S=i===I.YEAR,N=null!=t?t:e;return{calculateEventStyle:()=>{var e,t,i,I,O,R,H,A,P,L,$;if(S&&d&&c){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=d,a=2;return{position:"absolute",left:`calc(${e/c*100}% + ${a}px)`,top:18*n+"px",width:`calc(${(t-e+1)/c*100}% - ${2*a}px)`,height:"16px",opacity:1,zIndex:m||v?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:r?["left 90ms cubic-bezier(0.22, 1, 0.36, 1)","top 90ms cubic-bezier(0.22, 1, 0.36, 1)","width 90ms cubic-bezier(0.22, 1, 0.36, 1)",wo].join(", "):wo,willChange:r?"left, top, width, transform":"transform",cursor:p||y?"pointer":"default"}}if(M)return l&&s?{opacity:1,zIndex:m||v?1e3:1,cursor:p||y?"pointer":"default"}:{opacity:1,zIndex:m||v?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:wo,cursor:p||y?"pointer":"default"};if(a){const e={height:o-4+"px",opacity:1,zIndex:m||v?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:wo,cursor:p||y?"pointer":"default"},t=u*o;if(Object.assign(e,{top:`${t}px`}),T)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(l&&s){const t=c||7,n=(s.endDayIndex-s.startDayIndex+1)/t*100,r=s.startDayIndex/t*100,a=2,o=s.isFirstSegment?a:0,i=o+(s.isLastSegment?a:0);Object.assign(e,{width:i>0?`calc(${n}% - ${i}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 j=k?k.startHour:q(N.start),Y=k?k.endHour:Pe(N),F=(j-g)*h,Z=Math.max((Y-j)*h,h/4),z={top:`${F+3}px`,height:Z-4+"px",position:"absolute",opacity:1,zIndex:m||v?1e3:null!==(e=null==n?void 0:n.zIndex)&&void 0!==e?e:1,transform:f?"scale(1.05)":"scale(1)",transition:wo,cursor:p||y?"pointer":"default"};if(m&&v&&("sticky-left"===b||"sticky-right"===b)){const e=fo(D),n=null==e?void 0:e.getBoundingClientRect();if(n){const e=vo(D,w),r=n.left+e,a=n.right,o=null===(i=null===(t=x.current)||void 0===t?void 0:t.parentElement)||void 0===i?void 0:i.getBoundingClientRect(),l=(null!==(I=null==o?void 0:o.top)&&void 0!==I?I:n.top)+(j-g)*h+3,s=Math.max(l,n.top),d=Math.min(l+Z-4,n.bottom);if(d<=s)return{display:"none"};const c={position:"fixed",top:`${s}px`,height:d-s+"px",width:"6px",zIndex:1e3,overflow:"hidden"};return"sticky-left"===b?Object.assign(Object.assign({},c),{left:`${r}px`}):Object.assign(Object.assign({},c),{left:a-6+"px"})}}if(m&&v&&("sticky-top"===b||"sticky-bottom"===b)){const e=null===(O=D.current)||void 0===O?void 0:O.getBoundingClientRect();if(e){const t=E(),r=vo(D,w),a=T?1:c||7;let o=(e.width-r)/a,i=e.left+r+(T?0:t*o);M&&(o=e.width/7,i=e.left+t*o);const l=C(t);l&&(i=l.left,o=l.width);let s=fo(D);s||(s=null!==(H=null===(R=D.current)||void 0===R?void 0:R.querySelector(".calendar-renderer"))&&void 0!==H?H:null);const d=null==s?void 0:s.getBoundingClientRect(),u=null===(P=null===(A=x.current)||void 0===A?void 0:A.parentElement)||void 0===P?void 0:P.getBoundingClientRect();let h,g;if(u&&u.width>0)n?(h=u.left+n.left/100*u.width,g=T?n.width/100*u.width:(n.width-1)/100*u.width):(h=u.left,g=T?u.width:u.width-3);else{const e=C(t),r=null!==(L=null==e?void 0:e.left)&&void 0!==L?L:i,a=null!==($=null==e?void 0:e.width)&&void 0!==$?$:o;h=r,g=a-3,n&&(h=r+n.left/100*a,g=T?n.width/100*a:(n.width-1)/100*a)}const m=e.left+r;if(h<m&&(g=Math.max(0,g-(m-h)),h=m),h+g>e.right&&(g=Math.max(0,e.right-h)),"sticky-top"===b){let t=d?d.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 v=d?d.bottom:e.bottom;return v=Math.min(v,window.innerHeight),v=Math.min(v,e.bottom),v=Math.max(v,e.top+6),v=Math.max(v,6),{position:"fixed",top:v-6+"px",left:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(n&&!a){const e=T?`${n.width}%`:n.width-1+"%";return Object.assign(Object.assign({},z),{left:`${n.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},z),{left:"0px",right:T?"0px":"3px"})}}})({event:e,timingEvent:ee,layout:t,isBeingDragged:i,isAllDay:n,allDayHeight:r,viewType:s,isMultiDay:d,segment:c,yearSegment:u,columnsPerRow:h,segmentIndex:y,hourHeight:D,firstHour:w,isEventSelected:Ze,showDetailPanel:ge,isPopping:re,isDraggable:ye,canOpenDetail:pe,eventVisibility:Me,calendarRef:a,isMobile:j,eventRef:oe,getActiveDayIdx:Ie,getDayMetricsWrapper:Re,multiDaySegmentInfo:L});(({event:e,timingEvent:t,isEventSelected:n,showDetailPanel:r,eventRef:a,calendarRef:o,isAllDay:i,viewType:l,isMobile:s=!1,multiDaySegmentInfo:d,firstHour:c,hourHeight:u,updatePanelPosition:h,eventVisibility:g,setEventVisibility:v})=>{const p=l===I.MONTH,y=l===I.YEAR,b=l===I.RESOURCE,D=null!=t?t:e,w=f(()=>{var e,t;if(!n||!r||!a.current||!o.current||i||p||y)return;const l=fo(o);if(!l)return;const m=d?d.startHour:q(D.start),f=d?d.endHour:Pe(D),w=(m-c)*u,x=w+Math.max((f-m)*u,u/4),E=l.getBoundingClientRect(),C=l.scrollTop,k=C+E.height,T=E.bottom<0,M=E.top>window.innerHeight;let S=g;if(T)S="sticky-top";else if(M)S="sticky-bottom";else{const n="sticky-left"===g||"sticky-right"===g?"visible":g;let r;if(r="visible"===n?x<C?"sticky-top":w>k-20?"sticky-bottom":"visible":"sticky-top"===n?x>=C?"visible":"sticky-top":w<=k-20?"visible":"sticky-bottom","visible"!==r)S=r;else if(b){const n=null===(t=null===(e=a.current)||void 0===e?void 0:e.parentElement)||void 0===t?void 0:t.getBoundingClientRect();if(n){const e=vo(o,s),t=E.left+e,r=E.right;S=n.right<=t?"sticky-left":n.left>=r?"sticky-right":"visible"}else S="visible"}else S="visible"}S===g?h():(v(S),setTimeout(h,0))},[n,r,o,i,p,b,s,D.start,D.end,c,u,h,d,g,v]);m(()=>{var e;if(!n||!r||i)return;const t=fo(o);if(!t)return;const a=()=>w(),l=()=>{w(),h()},s=[t];let d=null===(e=o.current)||void 0===e?void 0:e.parentElement;for(;d;){const e=window.getComputedStyle(d);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||s.push(d),d=d.parentElement}s.forEach(e=>{e.addEventListener("scroll",a)}),window.addEventListener("scroll",a,!0),window.addEventListener("resize",l);let c=null;return o.current&&(c=new ResizeObserver(()=>{l()}),c.observe(o.current)),w(),()=>{s.forEach(e=>{e.removeEventListener("scroll",a)}),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",l),c&&c.disconnect()}},[n,r,i,w,h,o])})({event:e,timingEvent:ee,isEventSelected:Ze,showDetailPanel:ge,eventRef:oe,calendarRef:a,isAllDay:n,viewType:s,isMobile:j,multiDaySegmentInfo:L,firstHour:w,hourHeight:D,updatePanelPosition:Le,eventVisibility:Me,setEventVisibility:Se});const Ue=ge&&!!P;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:a,onEventSelect:o,onDetailPanelToggle:i,setIsSelected:l,setActiveDayIndex:s})=>{m(()=>{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:oe,detailPanelRef:ie,eventId:e.id,isEventSelected:!Ue&&Ze,showDetailPanel:me,onEventSelect:O,onDetailPanelToggle:H,setIsSelected:De,setActiveDayIndex:Ne});const We=f(()=>{O&&O(null),se.current=null,De(!1),null==H||H(null)},[O,H,De]),_e=p(()=>({event:e,isAllDay:n,onEventUpdate:T,onEventDelete:M,onClose:We}),[e,n,T,M,We]),Be=p(()=>({event:e,viewType:s,isAllDay:n,isMobile:j,isSelected:Ze,isDragging:i,segment:c,layout:t}),[e,s,n,j,Ze,i,c,t]),Ve=f(()=>$t(ha,{store:X,generatorName:"eventDetailContent",generatorArgs:_e}),[X,_e]);m(()=>{if((null==$?void 0:$.state.highlightedEventId)===e.id){ae(!0);const e=setTimeout(()=>{ae(!1)},650);return()=>{clearTimeout(e),ae(!1)}}},[null==$?void 0:$.state.highlightedEventId,e.id]),m(()=>{fe||ne(null)},[fe]),m(()=>{const t=d&&(null==c?void 0:c.isFirstSegment)||Q&&(null==u?void 0:u.isFirstSegment)||!d&&!Q;S===e.id&&!ge&&t&&setTimeout(()=>{null==H||H(he),null==N||N()},50)},[S,e.id,ge,d,c,Q,u,H,N,he]);const Ge=e.calendarId||"blue",Ke=null==$?void 0:$.getCalendarRegistry();return $t(o,{children:[$t("div",{ref:oe,"data-event-id":e.id,className:`${po(s,n,d,c,u)} ${n&&S===e.id?"df-all-day-event-animate":""} ${null!=W?W:""}`,style:Object.assign(Object.assign(Object.assign({},_?{}:ze()),{backgroundColor:Ze?ue(Ge,Ke):de(Ge,Ke),color:Ze?"#fff":ce(Ge,Ke)}),U),onClick:$e,onContextMenu:Ye,onDblClick:je,onMouseDown:t=>{var n;if(J||Ee(!0),C&&ye){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:()=>!J&&Ee(!1),onMouseLeave:()=>!J&&Ee(!1),onTouchStart:Ce,onTouchMove:ke,onTouchEnd:Te,children:$t(mo,{event:ee,viewType:s,isAllDay:n,isMultiDay:d,segment:c,yearSegment:u,segmentIndex:y,isBeingDragged:i,isBeingResized:l,isEventSelected:Ze,isPopping:re,isEditable:fe,isDraggable:ye,canOpenDetail:pe,isTouchEnabled:J,hideTime:Z,isMobile:j,isSlidingView:Y,app:$,onMoveStart:C,onResizeStart:k,multiDaySegmentInfo:L,customRenderingStore:X,eventContentSlotArgs:Be,timeFormat:z,appTimeZone:G,renderVisualContent:B,resizeHandleOrientation:V})}),ge&&!P&&$t("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),$t(Do,{showDetailPanel:ge,customEventDetailDialog:P,detailPanelPosition:He,event:e,detailPanelRef:ie,isAllDay:n,eventVisibility:Me,calendarRef:a,selectedEventElementRef:le,onEventUpdate:T,onEventDelete:M,handlePanelClose:We,customRenderingStore:X,contentSlotRenderer:Ve,customDetailPanelContent:A,app:$}),te&&$&&fe&&$t(ro,{event:e,x:te.x,y:te.y,onClose:()=>ne(null),app:$,onDetailPanelToggle:H,detailPanelKey:he})]})},Eo=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=Wn();return $t("div",{className:"df-navigation flex items-center gap-1",children:[$t("button",{type:"button",className:hr,onClick:e,"aria-label":"Previous month",children:$t(Ir,{className:gr})}),$t("button",{type:"button",className:"df-today-button df-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")}),$t("button",{type:"button",className:hr,onClick:n,"aria-label":"Next month",children:$t(Or,{className:gr})})]})},Co=({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}=Wn(),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 $t("div",{className:Bn,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[$t("div",{className:"flex-1",children:$t("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[$t("h1",{className:Vn,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&$t("h1",{className:Vn,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[$t("div",{className:`${Vn} text-gray-900 dark:text-white`,children:m}),v&&$t("div",{className:"mt-3 leading-6 text-gray-600 dark:text-gray-400",children:v})]})}),g&&n&&r&&a&&$t("div",{className:"flex items-center gap-2",children:$t(Eo,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})};function ko(e,t,n,r,a){if(r||0!==e.button)return;let o=!0;const i={move(r){if(!o)return;Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY)>=5&&(o=!1,document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),null==a||a(e,t,n),document.dispatchEvent(new MouseEvent("mousemove",{clientX:r.clientX,clientY:r.clientY,bubbles:!0,cancelable:!1})))},up(){o=!1,document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up)}};document.addEventListener("mousemove",i.move),document.addEventListener("mouseup",i.up)}function To(){document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!1}))}const Mo=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:a,organizedAllDayEvents:o,allDayAreaHeight:i,timeSlots:l,eventLayouts:s,isToday:d,currentTime:c,selectedEventId:u,setSelectedEventId:h,newlyCreatedEventId:f,setNewlyCreatedEventId:y,detailPanelEventId:b,setDetailPanelEventId:D,dragState:w,isDragging:x,handleMoveStart:E,handleResizeStart:C,handleCreateStart:k,handleCreateAllDayEvent:T,handleTouchStart:M,handleTouchEnd:S,handleTouchMove:N,handleDragOver:O,handleDrop:R,handleEventUpdate:H,handleEventDelete:A,onDateChange:P,customDetailPanelContent:L,customEventDetailDialog:$,calendarRef:j,allDayRowRef:Y,timeGridRef:F,switcherMode:Z,isMobile:z,isTouch:U,setDraftEvent:W,setIsDrawerOpen:_,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:V,FIRST_HOUR:G,LAST_HOUR:K,showAllDay:q,showStartOfDayLabel:X,timeFormat:J="24h",secondaryTimeSlots:Q,primaryTzLabel:ee,secondaryTzLabel:te,appTimeZone:ne})=>{var re;const ae=!!Q&&Q.length>0&&!z,{t:oe}=Wn(),ie=v(e.state.highlightedEventId),[le,se]=g(null),de=p(()=>Jt(),[]),ce=()=>{var e;const t=null===(e=j.current)||void 0===e?void 0:e.querySelector(".df-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},ue=e=>{var t;const n=null===(t=j.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(!n)return null;const r=n.getBoundingClientRect(),a=n.scrollTop||0;return G+(e-r.top+a-ce())/V},he=e.canMutateFromUI();m(()=>{he||se(null)},[he]);const ge=(e,n)=>{var r,a,o,i;if(e.preventDefault(),z||!he)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=j.current)||void 0===r?void 0:r.querySelector(".df-calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=j.current)||void 0===o?void 0:o.querySelector(".df-calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=ce(),a=(e.clientY-t.top+n-r)/V+G,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)}}se({x:e.clientX,y:e.clientY,date:l})};return $t("div",{className:`flex-none ${"buttons"===Z?"":"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:[$t("div",{className:`relative ${Mr} h-full`,children:[$t("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:z||!de?"0px":"15px"},children:$t(Co,{calendar:e,viewType:I.DAY,currentDate:t})}),$t("div",q?{className:Nr(rr,"relative items-stretch border-t border-gray-200 dark:border-gray-700"),ref:Y,style:{paddingRight:z||!de?"0px":"0.6875rem"},onContextMenu:e=>ge(e,!0),children:[$t("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:oe("allDay")}),$t("div",{className:Nr("relative flex flex-1 self-stretch",!z&&de?"border-r border-gray-200 dark:border-gray-700":""),children:$t("div",{className:"relative w-full",style:{minHeight:`${i}px`},onClick:()=>null==P?void 0:P(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==T||T(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==T||T(e,r)},onDragOver:O,onDrop:e=>{R(e,t,void 0,!0)},children:o.map(t=>$t(xo,{event:t,isAllDay:!0,viewType:I.DAY,segmentIndex:t.row,allDayHeight:B,calendarRef:j,isBeingDragged:x&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:V,firstHour:G,onMoveStart:E,onEventUpdate:H,onEventDelete:A,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:b,onDetailPanelToggle:e=>D(e),selectedEventId:u,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.canMutateFromUI(),o=r.find(e=>e.id===t);(z||U)&&o&&n&&a?(W(o),_(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),ie.current=null))},onEventLongPress:e=>{(z||U)&&h(e)},customDetailPanelContent:L,customEventDetailDialog:$,app:e,isMobile:z,enableTouch:U,appTimeZone:ne},t.id))})})]}:{className:!z&&de?"pr-2.75":""}),$t("div",{className:"relative overflow-y-auto df-calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:$t("div",{className:"relative flex",children:[d&&c&&(()=>{const e=c,t=e.getHours()+e.getMinutes()/60;if(t<G||t>K)return null;return $t("div",{className:tr,style:{top:`${(t-G)*V}px`,width:"100%",height:0,zIndex:20,marginTop:ae?"2rem":"0.75rem"},children:[$t("div",{className:"flex w-12 items-center md:w-20",children:[$t("div",{className:"relative flex w-full items-center"}),$t("div",{className:nr,children:Ae(t,0,J,!1)})]}),$t("div",{className:"flex flex-1 items-center",children:$t("div",{className:"df-current-time-bar h-0.5 w-full df-fill-primary relative"})})]})})(),$t("div",{className:"df-time-column flex-shrink-0 "+(ae?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[$t("div",{className:ae?"h-8":"h-3",children:ae&&$t("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[$t("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:te}),$t("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:ee})]})}),l.map((e,t)=>{var n;return $t("div",{className:Jn,children:$t("div",ae?{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:[$t("span",{className:"text-[10px] md:text-[12px]",children:X&&0===t?"":null!==(n=null==Q?void 0:Q[t])&&void 0!==n?n:""}),$t("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:X&&0===t?"":e.label})]}:{className:`${Qn} text-[10px] md:text-[12px]`,children:X&&0===t?"":e.label})},t)})]}),$t("div",{className:"grow select-none",children:[$t("div",{className:Nr(fr,!z&&de?"border-r":"","border-t-0"),style:ae?{height:"2rem"}:void 0,children:$t("div",{className:`${pr} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:X?Ae(G,0,J):""})}),$t("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:F,children:[l.map((e,r)=>$t("div",{className:Nr(er,!z&&de?"border-r":""),onClick:()=>null==P?void 0:P(t),onMouseDown:e=>{const r=ue(e.clientY);if(null===r)return;ko(e,Math.floor((t.getTime()-n.getTime())/864e5),r,U,k)},onDblClick:e=>{const r=ue(e.clientY);if(null===r)return;const a=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,a,r),To()},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);M(e,r)},onTouchEnd:S,onTouchMove:N,onDragOver:O,onDrop:e=>{var n,r,a,o;const i=null===(r=null===(n=j.current)||void 0===n?void 0:n.querySelector(".df-calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=j.current)||void 0===a?void 0:a.querySelector(".df-calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=ce(),d=e.clientY-i.top+l-s,c=Math.floor(G+d/V);R(e,t,c)},onContextMenu:e=>ge(e,!1)},r)),$t("div",{className:Nr(fr,!z&&de?"border-r":""),children:$t("div",ae?{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:[$t("span",{children:null!==(re=null==Q?void 0:Q[0])&&void 0!==re?re:""}),$t("span",{children:Ae(0,0,J)})]}:{className:`${pr} -left-9.5`,children:Ae(0,0,J)})}),$t("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 $t(xo,{event:t,layout:n,viewType:I.DAY,calendarRef:j,isBeingDragged:x&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:V,firstHour:G,onMoveStart:E,onResizeStart:C,onEventUpdate:H,onEventDelete:A,newlyCreatedEventId:f,onDetailPanelOpen:()=>y(null),detailPanelEventId:b,onDetailPanelToggle:e=>D(e),selectedEventId:u,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(z||U)&&a&&n?(W(a),_(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),ie.current=null))},onEventLongPress:e=>{(z||U)&&h(e)},customDetailPanelContent:L,customEventDetailDialog:$,app:e,isMobile:z,enableTouch:U,appTimeZone:ne},t.id)})})]})]})]})})]}),he&&le&&$t(no,{x:le.x,y:le.y,date:le.date,viewType:I.DAY,onClose:()=>se(null),app:e,onCreateEvent:()=>{if(k){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===le.date.getHours()&&0===le.date.getMinutes())null==T||T({clientX:le.x,clientY:le.y},e);else{const t=le.date.getHours()+le.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:le.x,clientY:le.y};k(n,e,t)}}}})]})},So=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h",showEventDots:c=!0,appTimeZone:u})=>{const{t:h,locale:g}=Wn(),m=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return $t("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:$t("div",{className:`${Mr} h-full`,children:[$t("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:$t("div",{children:[$t("div",{className:"flex items-center justify-end gap-2",children:[$t("div",{className:Bn,style:{position:"relative"},children:$t("div",{children:$t("h1",{className:Vn,children:" "})})}),$t(Eo,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),$t(Ia,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l,events:e.getEvents(),showEventDots:c,calendarRegistry:e.getCalendarRegistry(),timeZone:e.timeZone})]})}),$t("div",{className:"flex-1 overflow-y-auto",children:$t("div",{className:"p-4",children:[$t("h3",{className:"text-lg font-semibold mb-3 sticky top-0 z-10 bg-white py-2 dark:bg-gray-900",children:t.toLocaleDateString(g,{weekday:"long",month:"long",day:"numeric"})}),0===m.length?$t("p",{className:`${Er} ${Tr}`,children:h("noEvents")}):$t("div",{className:"space-y-2",children:m.map(t=>{var n;return $t("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"df-border-primary df-tint-primary":"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:he(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[$t("div",{className:`font-medium ${Tr}`,children:t.title}),!t.allDay&&$t("div",{className:`${kr} ${Cr}`,children:[Ae(q(u?we(t.start,u):t.start),0,d)," ","-"," ",Ae(u?q(we(null!==(n=t.end)&&void 0!==n?n:t.start,u)):Pe(t),0,d)]}),t.allDay&&$t("div",{className:`${kr} ${Cr}`,children:h("allDay")})]},t.id)})})]})})]})})},No={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function Io(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:q(e.start),_endHour:e.allDay?0:Pe(e)})}function Oo(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:q(e.start)}function Ro(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:Pe(e)}function Ho(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Oo(e)<Ro(t)&&Oo(t)<Ro(e))}function Ao(e,t){const n=Ro(e)-Oo(e);if(n<1.25)return!1;const r=Oo(e)+.4*n,a=Oo(t)>=r,o=Ho(e,t);return a&&o}function Po(e,t,n=No){if(!Ho(e,t))return!1;const r=Math.abs(Oo(e)-Oo(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Ho(e,t)||!Ao(e,t)&&!Ao(t,e))}(e,t))}function Lo(e,t){const n=Oo(e)<=Oo(t)&&Ro(e)>=Ro(t),r=Oo(e)<=Oo(t)&&Oo(t)<Ro(e)&&Ho(e,t);return n||r}function $o(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(Oo(r)-Oo(t))<=No.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Oo(e)-Oo(t));const o={events:a,startHour:Math.min(...a.map(e=>Oo(e))),endHour:Math.max(...a.map(e=>Ro(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function jo(e){return"day"===e?.5:2.5}function Yo(e){const t=Ro(e)-Oo(e);return Math.max(.1,Math.min(1,t/4))}function Fo(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(Po(e[t],e[n],No))return!0;return!1}function Zo(e,t,n,r,a={}){const o=jo(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*jo(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:Yo(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Ro(t.event)-Oo(t.event)-(Ro(e.event)-Oo(e.event)));1===u.length?Zo(u[0],d,c,r,a):Fo(u.map(e=>e.event))?zo(u,d,c,r,a):u.forEach(e=>Zo(e,d,c,r,a))}function zo(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*jo(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=>Zo(e,t,n,r,a));let h=No.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:Yo(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Ro(t.event)-Oo(t.event)-(Ro(e.event)-Oo(e.event)));1===t.length?Zo(t[0],n,g,r,a):Fo(t.map(e=>e.event))?zo(t,n,g,r,a):t.forEach(e=>Zo(e,n,g,r,a))}})}function Uo(e,t,n={}){const r=100-("day"===n.viewType?0:No.EDGE_MARGIN_PERCENT);if(1===e.length)Zo(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-No.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{Zo(e,r*(o+No.MARGIN_BETWEEN),Math.max(o,No.MIN_WIDTH),t,n)})}}function Wo(e){let t=0;for(const n of e.children)t+=1+Wo(n);return t}function _o(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:Wo(e)})).toSorted((e,t)=>t.load-e.load)}function Bo(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function Vo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Go(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>Lo(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),Vo(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),Vo(t.event,e.event))}function Ko(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>Ko(e,t))}function qo(e,t){const n=[];return Ko(e,n),n.find(e=>Lo(t.event,e.event))||n[0]||null}function Xo(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=qo(n.node,r.node);if(!a)break;Go(a,r.node),n.load--,r.load++,t++}}function Jo(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(Ho(n,e)&&Math.abs(Oo(e)-Oo(n))<No.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<No.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(Lo(n,e))return!0;return!1}function Qo(e,t,n){const r=t.events.filter(t=>Lo(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&&Po(e,r,No)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Oo(e)-Oo(t.parent))-Math.abs(Oo(e)-Oo(n.parent))),a[0].parent}function ei(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=Ro(e)-Oo(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Ro(t)-Oo(t):0}),0)?a[0]:a.at(-1)||null}function ti(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function ni(e){let t=0;for(const n of e.children)t+=1+ni(n);return t}function ri(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 ai(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=ni(e);t<i&&(i=t,l=e)}return l?l.event:null}function oi(e,t,n){const r=[];if(1===e.length){const a=Qo(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),ti(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>Lo(t,e)));if(0===a.length){for(const a of e){const o=Qo(a,t,n);if(o)r.push({child:a,parent:o}),ti(o,a);else{const t=e.find(e=>e.id!==a.id&&Ho(e,a));if(t){const e=ai(t,ri(n));e&&(r.push({child:a,parent:e}),ti(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Ro(t)-Oo(t)-(Ro(e)-Oo(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}),ti(n,e)}}else for(const e of o){const t=ei(e,a,o);t&&(r.push({child:e,parent:t}),ti(t,e))}return r}function ii(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(Jo(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=oi(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=_o(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);Bo(r)&&Xo(r)}}(e,n),o}const li={calculateDayEventLayouts(e,t={}){const n=e.map(Io);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)||Ho(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:No.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{Uo(ii($o([...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}},si=(e,t,n=7,r)=>{const a=new Map;for(let o=0;o<n;o++){const i=[];e.forEach(e=>{var a;if(e.allDay)return;const l=io(e,t,n,r);if(l.length>0){const n=l.find(e=>e.dayIndex===o);if(n){const r=n.endHour>=24?23.99:n.endHour,a=Object.assign(Object.assign({},e),{start:ke(X(at(t,o),n.startHour)),end:ke(X(at(t,o),r)),day:o});i.push(a)}}else if(e.day===o){const t=e=>r?we(e,r):De(e);i.push(Object.assign(Object.assign({},e),{start:ke(t(e.start),r),end:ke(t(null!==(a=e.end)&&void 0!==a?a:e.start),r),day:o}))}});const l=li.calculateDayEventLayouts(i,{viewType:"week"});a.set(o,l)}return a},di=(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},ci={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ui(e){const{app:t,onEventCreated:r}=e,{t:a}=Wn(),o=f(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:f((e,o,i,l)=>{if(e.preventDefault(),!e.dataTransfer)return null;const s=e.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const e=JSON.parse(s);let d,c,u=!1;if(l){const e=n.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});d=e,c=e,u=!0}else if(void 0===i){const e=new Date(o);e.setHours(9,0,0,0);const n=new Date(e);n.setHours(10,0,0,0),d=ke(e,t.timeZone),c=ke(n,t.timeZone)}else{const e=new Date(o);e.setHours(i,0,0,0);const n=new Date(e);n.setHours(i+1,0,0,0),d=ke(e,t.timeZone),c=ke(n,t.timeZone)}const h=t.getCalendarRegistry().get(e.calendarId);if((null==h?void 0:h.readOnly)||(null==h?void 0:h.subscription))return null;const g={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:a(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return t.addEvent(g),null==r||r(g),g}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[t,r]),handleDragOver:o}}let hi=null;function gi(e){hi=e}const mi={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function vi(e,t){return hi?hi(e,t):mi}const fi=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,switcherMode:o="buttons",selectedEventId:i,onEventSelect:l,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{const u=e.getEvents(),{screenSize:h}=zn(),b="desktop"!==h,[D,w]=g(!1),{hourHeight:x=ci.HOUR_HEIGHT,firstHour:E=ci.FIRST_HOUR,lastHour:C=ci.LAST_HOUR,allDayHeight:k=ci.ALL_DAY_HEIGHT,showAllDay:T=!0,timeFormat:M="24h",secondaryTimeZone:S,showEventDots:N=!0}=t,O=x,R=E,H=C,A=k,P=!T;m(()=>{w("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const L=e.getCustomMobileEventRenderer()||Ha,[$,j]=g(null),[Y,F]=g(null),[Z,z]=g(null),U=void 0===i?Y:i,W=void 0===d?Z:d,_=p(()=>U&&u.find(e=>e.id===U)||null,[U,u]),B=e=>{l?l(e):F(e)},[V,G]=g(null),[K,X]=g(!1),[J,Q]=g(null),ee=v(null),te=e.getCurrentDate(),[ne,re]=g(te),ae=v(te.getTime());te.getTime()!==ae.current&&(ae.current=te.getTime(),te.getFullYear()===ne.getFullYear()&&te.getMonth()===ne.getMonth()||re(te));const oe=f(t=>{re(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),ie=v(e.state.highlightedEventId);m(()=>{var t;if(e.state.highlightedEventId!==ie.current)if(e.state.highlightedEventId){B(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=q(n.start),r=null===(t=a.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(r){const t=(e-R)*O;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else B(null);ie.current=e.state.highlightedEventId},[e.state.highlightedEventId,R,O,a,e]);const le=v(null),se=v(null),de=p(()=>di(te),[te]),ce=e.timeZone,ue=p(()=>((e,t,n,r)=>{const a=new Date(t);a.setHours(0,0,0,0);const o=new Date(t);o.setHours(23,59,59,999);const i=e=>r?we(e,r):De(e);return e.filter(e=>{var t;const n=i(e.start),r=i(null!==(t=e.end)&&void 0!==t?t:e.start);if(e.allDay){const e=new Date(n);e.setHours(0,0,0,0);const t=new Date(r);return t.setHours(0,0,0,0),e<=o&&t>=a}return n<o&&r>a}).map(e=>{const t=i(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})})})(u,te,de,ce),[u,te,de,ce]),he=p(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(r);a.setDate(a.getDate()+1);const o=e=>n?we(e,n):De(e);return e.filter(e=>!e.allDay).map(e=>{var t;const i=o(e.start),l=o(null!==(t=e.end)&&void 0!==t?t:e.start);let s=ke(i,n),d=ke(l,n);return i<r&&(s=ke(r,n)),l>a&&(d=ke(a,n)),Object.assign(Object.assign({},e),{start:s,end:d,day:0})})})(ue,te,ce),[ue,te,ce]),ge=p(()=>li.calculateDayEventLayouts(he,{viewType:"day"}),[he]),me=p(()=>((e,t)=>{const n=e.filter(e=>e.allDay);if(t)n.sort(t);else{const e=new Map;n.forEach(t=>{e.has(t.calendarId)||e.set(t.calendarId,e.size)}),n.sort(Yn(n,(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)}))}const r=[],a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)r[t]?r[t].some(t=>{const n=De(e.start),r=De(e.end),a=De(t.start);return n<=De(t.end)&&a<=r})?t++:(r[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),n=!0):(r[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),n=!0)}),a})(ue,e.state.allDaySortComparator),[ue,e.state.allDaySortComparator]),ve=p(()=>{if(0===me.length)return A;return(Math.max(...me.map(e=>e.row))+1)*A},[me,A]),{handleMoveStart:fe,handleCreateStart:pe,handleResizeStart:ye,handleCreateAllDayEvent:be,dragState:xe,isDragging:Ee}=vi(e,{calendarRef:a,allDayRowRef:T?le:void 0,timeGridRef:se,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=u.find(t=>t.id===e.id);return t&&yt(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),G(t.id))},onEventEdit:()=>{},currentWeekStart:de,events:ue,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a,o)=>{const i=new Date(r),l=new Date(r);i.setHours(Math.floor(t),t%1*60,0,0),l.setHours(Math.floor(n),n%1*60,0,0);const s=[...a,{id:"-1",title:"Temp",day:0,start:ke(i,o),end:ke(l,o),calendarId:"blue",allDay:!1}];return li.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null})(0,t,n,te,he,ce),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o,i)=>{const l=o.filter(t=>t.id!==e.id),s=new Date(a),d=new Date(s);d.setHours(Math.floor(n),n%1*60,0,0);const c=new Date(s);c.setHours(Math.floor(r),r%1*60,0,0);const u=[...l,Object.assign(Object.assign({},e),{start:ke(d,i),end:ke(c,i),day:0})];return 0===u.length?null:li.calculateDayEventLayouts(u,{viewType:"day"}).get(e.id)||null})(e,0,n,r,te,he,ce),TIME_COLUMN_WIDTH:S&&!b?88:b?48:80,isMobile:b}),{handleDrop:Ce,handleDragOver:Te}=ui({app:e,onEventCreated:e=>{G(e.id)}}),Me=Array.from({length:24},(e,t)=>({hour:t+R,label:Ae(t+R,0,M)})),Se=p(()=>S?je(Me,S,M,te,ce):void 0,[S,M,R,te,ce]),Ne=p(()=>S?Ye(ce,te):void 0,[S,ce,te]),Ie=p(()=>S?Ye(S,te):void 0,[S,te]),Oe=f(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),re(new Date(n.getFullYear(),n.getMonth(),1))},[e]),Re=p(()=>{const e=Ze(ce);return te.toDateString()===e.toDateString()},[te,ce]);return y(()=>{var e;if(t.scrollToCurrentTime){const t=null===(e=a.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(t){const e=Fe(ce),n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-R)*O-r/2)}}},[ce,t.scrollToCurrentTime,R,O]),m(()=>{j(Fe(ce));const e=setInterval(()=>j(Fe(ce)),6e4);return()=>clearInterval(e)},[ce]),$t("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[$t(Mo,{app:e,currentDate:te,currentWeekStart:de,events:u,currentDayEvents:ue,organizedAllDayEvents:me,allDayAreaHeight:ve,timeSlots:Me,eventLayouts:ge,isToday:Re,currentTime:$,selectedEventId:U,setSelectedEventId:B,newlyCreatedEventId:V,setNewlyCreatedEventId:G,detailPanelEventId:W,setDetailPanelEventId:e=>{c?c(e):z(e)},dragState:xe,isDragging:Ee,handleMoveStart:fe,handleResizeStart:ye,handleCreateStart:pe,handleCreateAllDayEvent:be,handleTouchStart:(e,t)=>{if(!b&&!D)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(".df-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(".df-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,R+u/O)},500)},handleTouchEnd:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleTouchMove:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleDragOver:Te,handleDrop:Ce,handleEventUpdate:t=>e.updateEvent(t.id,t),handleEventDelete:t=>e.deleteEvent(t),onDateChange:s,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,allDayRowRef:le,timeGridRef:se,switcherMode:o,isMobile:b,isTouch:D,setDraftEvent:Q,setIsDrawerOpen:X,ALL_DAY_HEIGHT:A,HOUR_HEIGHT:O,FIRST_HOUR:R,LAST_HOUR:H,showAllDay:T,showStartOfDayLabel:P,timeFormat:M,secondaryTimeSlots:Se,primaryTzLabel:Ne,secondaryTzLabel:Ie,appTimeZone:ce}),$t(So,{app:e,currentDate:te,visibleMonth:ne,currentDayEvents:ue,selectedEvent:_,setSelectedEvent:e=>B(e?e.id:null),handleMonthChange:oe,handleDateSelect:Oe,switcherMode:o,timeFormat:M,showEventDots:N,appTimeZone:ce}),$t(L,{isOpen:K,onClose:()=>{X(!1),Q(null)},onSave:t=>{u.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),X(!1),Q(null)},draftEvent:J,app:e,timeFormat:M})]})},pi=({originalComponent:e,app:t,viewType:n,config:r,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:i,switcherMode:l,meta:s,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDateChange:h,onDetailPanelToggle:g})=>{const m=t.getPlugin("events"),v=t.getPlugin("drag"),y=t.getCurrentDate(),b=t.state.currentView,D=t.getEvents(),w=f(e=>m?m.update(e.id,e):t.updateEvent(e.id,e),[m,t]),x=f(e=>m?m.delete(e):t.deleteEvent(e),[m,t]),E=f(e=>{m?m.add(e):t.addEvent(e)},[m,t]),C=f(e=>{h?h(e):t.setCurrentDate(e)},[t,h]),k=f(e=>{t.changeView(e)},[t]),T=p(()=>{const e=t.getViewConfig(n);return Object.assign(Object.assign({},e),r)},[r,t.state.views,n]),M=p(()=>({app:t,currentDate:y,currentView:b,events:D,onEventUpdate:w,onEventDelete:x,onEventCreate:E,onDateChange:C,onViewChange:k,config:T,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:i,switcherMode:l,meta:s,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDetailPanelToggle:g}),[t,y,b,D,w,x,E,C,k,T,a,o,i,l,s,d,c,u,g]),S=p(()=>{const e={currentDate:y,events:D,setEvents:e=>{D.forEach(e=>x(e.id)),e.forEach(e=>E(e))},updateEvent:w,deleteEvent:x,addEvent:E,goToPrevious:()=>{const e=new Date(y);switch(b){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)}C(e)},goToNext:()=>{const e=new Date(y);switch(b){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)}C(e)},goToToday:()=>{C(new Date)},changeView:k,selectDate:C};return Object.assign(Object.assign({calendar:e},M),{eventsService:m,dragService:v})},[y,D,b,w,x,E,C,k,M,m,v]);return $t(e,Object.assign({},S))},yi={},bi=e=>i(pi,Object.assign(Object.assign({},e),{viewType:I.DAY,originalComponent:fi,className:"day-view-factory"}));bi.displayName="DayViewAdapter";const Di=(e={})=>{const t=Object.assign(Object.assign({},yi),e);return{type:I.DAY,component:bi,config:t}},wi=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)},xi=({app:e,fullWeekDates:t=[],mobilePageStart:n,onDateChange:r})=>$t("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:[$t("div",{className:"mb-1 grid grid-cols-7",children:t.map((e,t)=>$t("div",{className:"flex justify-center",children:$t("span",{className:"text-[10px] font-medium "+(e.isToday?"df-text-primary":"text-gray-500"),children:wi(e.dayName)})},`label-${t}`))}),$t("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!n)return null;const a=t.findIndex(e=>e.fullDate.getTime()===n.getTime());return $t(o,{children:[$t("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:-1===a?"0":`calc(${(a+.5)/7*100}% - 16px)`,top:0,width:`calc(${1/7*100}% + 32px)`,height:"32px"}}),t.map((t,n)=>{const o=t.isCurrent,i=n>=a&&n<a+2;return $t("div",{className:"relative z-10 flex cursor-pointer items-center justify-center",style:{height:"32px"},onClick:()=>{e.setCurrentDate(t.fullDate),null==r||r(t.fullDate)},children:$t("div",{className:`relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-all duration-300 ${o?"bg-gray-900 text-white shadow-sm dark:bg-gray-100 dark:text-gray-900":t.isToday?"df-text-primary font-bold":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!o&&$t("div",{className:"df-fill-primary absolute bottom-1 h-1 w-1 rounded-full"})]})},`date-${n}`)})]})})()})]}),Ei=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:r,fullWeekDates:a,isSlidingView:i,mobilePageStart:l,currentWeekStart:s,gridWidth:d,allDayAreaHeight:c,organizedAllDaySegments:u,allDayLabelText:h,isMobile:v,isTouch:f,showAllDay:y=!0,calendarRef:b,allDayRowRef:D,topFrozenContentRef:w,ALL_DAY_HEIGHT:x,HOUR_HEIGHT:E,FIRST_HOUR:C,dragState:k,isDragging:T,primaryTzLabel:M,secondaryTzLabel:S,secondaryTimeSlots:N,handleMoveStart:O,handleResizeStart:R,handleEventUpdate:H,handleEventDelete:A,onDateChange:P,newlyCreatedEventId:L,setNewlyCreatedEventId:$,selectedEventId:j,setSelectedEventId:Y,detailPanelEventId:F,setDetailPanelEventId:Z,handleCreateAllDayEvent:z,handleDragOver:U,handleDrop:W,customDetailPanelContent:_,customEventDetailDialog:B})=>{const V={flexShrink:0},[G,K]=g(null),q=p(()=>Jt(),[]),X=!!N&&N.length>0&&!v,J=e.canMutateFromUI();m(()=>{J||K(null)},[J]);return $t("div",{className:"flex w-full flex-col",children:[i&&a&&l&&$t(xi,{app:e,fullWeekDates:a,mobilePageStart:l,onDateChange:P}),$t("div",{className:`flex flex-none ${y?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[y&&$t("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:[$t("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:X&&$t("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[$t("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:S}),$t("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:M})]})}),$t("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:h})]}),$t("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:y?`${c+(i?0:36)}px`:"auto"},children:$t("div",{ref:w,className:"flex flex-col",style:{width:d,minWidth:"100%",transform:i?"translateX(calc(-100% / 3))":void 0},children:[!i&&$t("div",{className:"df-week-header flex border-b",style:{marginRight:q?"-50px":"0px",paddingRight:q?"50px":"0px"},children:t.map((e,t)=>$t("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 "+(v?"flex-col gap-0":""),style:V,children:$t(o,v?{children:[$t("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:n[t]}),$t("div",{className:`${Kn} h-7 w-7 text-base font-medium ${r[t].isToday?ur:""}`,children:r[t].date})]}:{children:[$t("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),$t("div",{className:`${Kn} ${r[t].isToday?ur:""}`,children:r[t].date})]})},t))}),y&&$t("div",{className:`${rr} relative border-none transition-[min-height] duration-300 ease-in-out`,ref:D,style:{minHeight:`${c}px`},children:$t("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),$t("div",{className:"df-all-day-cell flex-1 border-r relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!v&&q?"":"border-r-0"),style:Object.assign({minHeight:`${c}px`},V),onMouseDown:e=>null==z?void 0:z(e,n),onDblClick:e=>null==z?void 0:z(e,n),onDragOver:U,onDrop:e=>{W(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),v||!J)return;const n=new Date(s);n.setDate(s.getDate()+t),n.setHours(0,0,0,0),K({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),$t("div",{className:"pointer-events-none absolute inset-0",children:u.map(n=>$t(xo,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:x,calendarRef:b,viewType:I.WEEK,columnsPerRow:t.length,isBeingDragged:T&&(null==k?void 0:k.eventId)===n.event.id&&"move"===(null==k?void 0:k.mode),hourHeight:E,firstHour:C,onMoveStart:O,onResizeStart:R,onEventUpdate:H,onEventDelete:A,newlyCreatedEventId:L,onDetailPanelOpen:()=>$(null),selectedEventId:j,detailPanelEventId:F,onEventSelect:e=>{Y(e)},onEventLongPress:e=>{(v||f)&&Y(e)},onDetailPanelToggle:e=>Z(e),customDetailPanelContent:_,customEventDetailDialog:B,app:e,isMobile:v,isSlidingView:i,enableTouch:f},n.event.id))})]})})]})}),J&&G&&$t(no,{x:G.x,y:G.y,date:G.date,viewType:I.WEEK,onClose:()=>K(null),app:e,onCreateEvent:()=>{const e=Math.floor((G.date.getTime()-s.getTime())/864e5);null==z||z({clientX:G.x,clientY:G.y},e)}})]})]})},Ci=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:r,currentWeekEvents:a,eventLayouts:i,gridWidth:l,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:u,leftFrozenContentRef:h,swipeContentRef:f,calendarRef:y,handleScroll:b,handleCreateStart:D,handleTouchStart:w,handleTouchEnd:x,handleTouchMove:E,handleDragOver:C,handleDrop:k,dragState:T,isDragging:M,handleMoveStart:S,handleResizeStart:N,handleEventUpdate:O,handleEventDelete:R,onDateChange:H,newlyCreatedEventId:A,setNewlyCreatedEventId:P,selectedEventId:L,setSelectedEventId:$,detailPanelEventId:j,setDetailPanelEventId:Y,customDetailPanelContent:F,customEventDetailDialog:Z,isSlidingView:z,isCurrentWeek:U,currentTime:W,HOUR_HEIGHT:_,FIRST_HOUR:B,LAST_HOUR:V,showStartOfDayLabel:G,timeFormat:K="24h",secondaryTimeSlots:q,appTimeZone:X})=>{var J,Q;const ee=!!q&&q.length>0&&!s,te={flexShrink:0},ne=v(e.state.highlightedEventId),[re,ae]=g(null),oe=p(()=>Jt(),[]),ie=e.canMutateFromUI();m(()=>{ie||ae(null)},[ie]);const le=e=>{if(!u.current)return B;const t=u.current.getBoundingClientRect();return B+(e-t.top)/_};return $t("div",{className:"relative flex flex-1 overflow-hidden",children:[$t("div",{ref:c,className:"df-calendar-content relative flex-1 overflow-auto "+("300%"===l?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:b,children:[$t("div",{ref:h,className:"sticky left-0 z-10 w-12 shrink-0 bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[$t("div",{className:"relative h-3",children:ee?$t(o,{children:$t("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[$t("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G&&null!==(J=null==q?void 0:q[0])&&void 0!==J?J:""}),$t("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G?Ae(B,0,K):""})]})}):$t("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:G?Ae(B,0,K):""})}),t.map((e,t)=>{var n;return $t("div",{className:Jn,children:$t("div",ee?{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:[$t("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":null!==(n=null==q?void 0:q[t])&&void 0!==n?n:""}),$t("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":e.label})]}:{className:`${Qn} text-[10px] md:text-[12px]`,children:G&&0===t?"":e.label})},t)}),$t("div",{className:"relative",children:$t("div",ee?{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:[$t("span",{className:"text-[10px] md:text-[12px]",children:null!==(Q=null==q?void 0:q[0])&&void 0!==Q?Q:""}),$t("span",{className:"text-[10px] md:text-[12px]",children:Ae(0,0,K)})]}:{className:`${Qn} text-[10px] md:text-[12px]`,children:Ae(0,0,K)})}),U&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>V)return null;return $t("div",{className:"pointer-events-none absolute left-0 z-20 flex w-full items-center justify-end",style:{top:`${(t-B)*_}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:$t("div",{className:nr,children:Ae(t,0,K,!1)})})})()]}),$t("div",{ref:f,className:"flex",style:{width:l,minWidth:"100%",transform:z?"translateX(calc(-100% / 3))":void 0},children:$t("div",{className:"grow",children:[$t("div",{className:`${fr} flex border-t-0`,children:n.map((e,t)=>$t("div",{className:`relative flex-1 ${t!==n.length-1||!s&&oe?"border-r":""} border-gray-200 dark:border-gray-700`,style:te},`top-${t}`))}),$t("div",{ref:u,className:"relative",children:[U&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>V)return null;const a=new Date(e);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);const i=a.getTime()-o.getTime(),l=Math.round(i/864e5);return $t("div",{className:tr,style:{top:`${(t-B)*_}px`,width:"100%",height:0,zIndex:20},children:[$t("div",{className:"flex w-0 items-center"}),$t("div",{className:"flex flex-1",children:n.map((e,t)=>$t("div",{className:"flex flex-1 items-center",children:$t("div",{className:"relative h-0.5 w-full "+(t===l?"df-fill-primary":"df-tint-primary-lg"),style:{zIndex:9999},children:t===l&&0!==l&&$t("div",{className:"df-fill-primary absolute h-2 w-2 rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>$t("div",{className:er,children:n.map((a,o)=>{const i=new Date(r);return i.setDate(r.getDate()+o),$t("div",{className:"df-time-grid-cell flex-1 relative border-r select-none snap-start "+(o!==n.length-1||!s&&oe?"":"border-r-0"),style:te,onClick:()=>{const e=new Date(r);e.setDate(r.getDate()+o),null==H||H(e)},onMouseDown:e=>{ko(e,o,le(e.clientY),d,D)},onDblClick:e=>{null==D||D(e,o,le(e.clientY)),To()},onTouchStart:t=>w(t,o,e.hour),onTouchEnd:x,onTouchMove:E,onDragOver:C,onDrop:t=>{k(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),s||!ie)return;const a=new Date(r);if(a.setDate(r.getDate()+t),u.current){const t=u.current.getBoundingClientRect(),n=(e.clientY-t.top)/_+B,r=Math.floor(n),o=Math.floor(60*(n-r)),i=15*Math.round(o/15),l=60===i?r+1:r,s=60===i?0:i;a.setHours(l,s,0,0)}else a.setHours(n,0,0,0);ae({x:e.clientX,y:e.clientY,date:a})})(t,o,e.hour)},`${t}-${o}`)})},t)),$t("div",{className:`${fr} flex`,children:n.map((e,t)=>$t("div",{className:`relative flex-1 ${t!==n.length-1||!s&&oe?"border-r":""} border-gray-200 dark:border-gray-700`,style:te},`24-${t}`))}),n.map((t,o)=>{const l=n.length,c=nt(o,a),u=[];return c.forEach(e=>{const t=io(e,r,n.length,X);if(t.length>0){const n=t.find(e=>e.dayIndex===o);n&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:o})})}else u.push({event:e})}),a.forEach(e=>{if(e.allDay||e.day===o)return;const t=io(e,r,n.length,X).find(e=>e.dayIndex===o);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:o})})}),$t("div",{className:"pointer-events-none absolute top-0",style:{left:`calc(${100/l*o}%)`,width:100/l+"%",height:"100%"},children:u.map(({event:t,segmentInfo:n})=>{const r=i.get(o),a=null==r?void 0:r.get(t.id);return $t(xo,{event:t,layout:a,viewType:I.WEEK,calendarRef:y,columnsPerRow:l,isBeingDragged:M&&(null==T?void 0:T.eventId)===t.id&&"move"===(null==T?void 0:T.mode),hourHeight:_,firstHour:B,onMoveStart:S,onResizeStart:N,onEventUpdate:O,onEventDelete:R,newlyCreatedEventId:A,onDetailPanelOpen:()=>P(null),selectedEventId:L,detailPanelEventId:j,onEventSelect:t=>{$(t),e.state.highlightedEventId&&(e.highlightEvent(null),ne.current=null)},onEventLongPress:e=>{(s||d)&&$(e)},onDetailPanelToggle:e=>Y(e),customDetailPanelContent:F,customEventDetailDialog:Z,multiDaySegmentInfo:n,app:e,isMobile:s,isSlidingView:z,enableTouch:d,appTimeZone:X},n?`${t.id}-seg-${o}`:t.id)})},`events-day-${o}`)})]})]})})]}),ie&&re&&$t(no,{x:re.x,y:re.y,date:re.date,viewType:I.WEEK,onClose:()=>ae(null),app:e,onCreateEvent:()=>{if(D){const e=new Date(r);e.setHours(0,0,0,0);const t=new Date(re.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),a=Math.round(n/864e5),o=re.date.getHours()+re.date.getMinutes()/60,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:re.x,clientY:re.y};D(i,a,o)}}})]})},ki=e=>{const t=n.Now.plainDateISO(e);return new Date(t.year,t.month-1,t.day).toDateString()},Ti=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,onDateChange:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:u,getWeekDaysLabels:h,locale:b}=Wn(),D=e.getCurrentDate(),w=p(()=>D,[D.getTime()]),x=e.getEvents(),{screenSize:E}=zn(),C="desktop"!==E,k=v(null),[T,M]=g(!1),{hourHeight:S=ci.HOUR_HEIGHT,firstHour:N=ci.FIRST_HOUR,lastHour:O=ci.LAST_HOUR,allDayHeight:R=ci.ALL_DAY_HEIGHT,showAllDay:H=!0,timeFormat:A="24h",secondaryTimeZone:P}=t,L=P&&"mobile"!==E?88:"mobile"===E?48:80,$=S,j=N,Y=O,F=R,Z=!H;m(()=>{M("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const z=e.getCustomMobileEventRenderer()||Ha,U="desktop"!==E,W=U?2:7,_=U,B=null!==(c=t.startOfWeek)&&void 0!==c?c:1,V=_?"300%":"100%",G=p(()=>di(w,B),[w,B]),K=_?3*W:7,[J,Q]=g(null),[ee,te]=g(null),[ne,re]=g(null),ae=void 0===o?ee:o,oe=void 0===s?ne:s,ie=e=>{i?i(e):te(e)},le=e=>{d?d(e):re(e)},[se,de]=g(null),[ce,ue]=g(!1),[he,ge]=g(null),me=v(null),ve=v(null),fe=v(null),pe=v(null),ye=v(null),be=v(null),{handleScroll:xe,goToNext:Ee,goToPrevious:Ce,mobilePageStart:Te}=(({app:e,columnsPerPage:t,currentDate:n,displayDays:r,isSlidingView:a,scrollerRef:o,swipeContentRef:i,topFrozenContentRef:l})=>{const[s,d]=g(()=>{const e=new Date(n);return e.setHours(0,0,0,0),e}),[c,u]=g(0),[h,p]=g(!1),y=v({x:0,y:0}),b=v(!1),D=v(0);m(()=>{a&&d(e=>{const r=new Date(n);r.setHours(0,0,0,0);const a=new Date(e),o=new Date(e);return o.setDate(o.getDate()+t-1),r>=a&&r<=o?e:r})},[t,n,a]);const w=f(e=>{const{scrollLeft:t}=e.currentTarget;if(!l.current)return;const n=a?"calc(-100% / 3)":"0px",r=a?`${c}px`:`-${t}px`;l.current.style.transform=`translateX(calc(${n} + ${r}))`,l.current.style.transition=a&&h?"transform 0.3s ease-out":"none"},[a,h,c,l]);m(()=>{if(!a)return;const t=o.current;if(!t)return;const n=e=>{y.current={x:e.touches[0].clientX,y:e.touches[0].clientY},b.current=!1,D.current=0,p(!1)},c=e=>{if(h)return;const n=e.touches[0].clientX-y.current.x,r=e.touches[0].clientY-y.current.y;if(!b.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(b.current=!0),b.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))`;l.current&&(l.current.style.transition="none",l.current.style.transform=o),i.current&&(i.current.style.transition="none",i.current.style.transform=o),D.current=a}},g=()=>{var n;if(!b.current)return void(D.current=0);const a=D.current,o=((null===(n=i.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/r;a>100?(p(!0),u(o),setTimeout(()=>{const t=new Date(s);t.setDate(t.getDate()-1),d(t),e.setCurrentDate(t),u(0),D.current=0,p(!1)},300)):a<-100?(p(!0),u(-o),setTimeout(()=>{const t=new Date(s);t.setDate(t.getDate()+1),d(t),e.setCurrentDate(t),u(0),D.current=0,p(!1)},300)):(p(!0),u(0),D.current=0,setTimeout(()=>{p(!1)},300))};return t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchmove",c,{passive:!1}),t.addEventListener("touchend",g,{passive:!0}),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchmove",c),t.removeEventListener("touchend",g)}},[e,r,a,h,s,o,i,l]),m(()=>{if(!a)return l.current&&(l.current.style.transform="",l.current.style.transition=""),void(i.current&&(i.current.style.transform="",i.current.style.transition=""));const e=h?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${c}px))`;l.current&&(l.current.style.transition=e,l.current.style.transform=t),i.current&&(i.current.style.transition=e,i.current.style.transform=t)},[a,h,i,c,l]);const x=f(()=>{if(!a)return!1;const t=new Date(n);return t.setDate(t.getDate()-1),d(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t),!0},[e,n,a]);return{handleScroll:w,goToNext:f(()=>{if(!a)return!1;const t=new Date(n);return t.setDate(t.getDate()+1),d(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t),!0},[e,n,a]),goToPrevious:x,mobilePageStart:s}})({app:e,columnsPerPage:W,currentDate:w,displayDays:K,isSlidingView:_,scrollerRef:fe,swipeContentRef:be,topFrozenContentRef:pe}),Me=_?Te:G,Se=p(()=>{if(!_)return Me;const e=new Date(Me);return e.setDate(e.getDate()-W),e},[W,Me,_]),Ne=e.timeZone,Ie=p(()=>((e,t,n=7,r)=>{const a=new Date(t);a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999);const o=e=>r?we(e,r):De(e);return e.filter(e=>{var n;const r=o(e.start);r.setHours(0,0,0,0);const i=o(null!==(n=e.end)&&void 0!==n?n:e.start);return i.setHours(23,59,59,999),i>=t&&r<=a}).map(e=>{const r=o(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),i=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:i})})})(x,Se,K,Ne),[x,Se,K,Ne]),Oe=v(e.state.highlightedEventId);m(()=>{if(e.state.highlightedEventId!==Oe.current)if(e.state.highlightedEventId){ie(e.state.highlightedEventId);const t=Ie.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=q(t.start),n=fe.current;if(n){const t=(e-j)*$;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ie(null);Oe.current=e.state.highlightedEventId},[e.state.highlightedEventId,Ie,j,$]);const Re=p(()=>((e,t,n=7,r)=>{const a=oo(e,t,n).filter(e=>e.event.allDay);if(r)a.sort((e,t)=>r(e.event,t.event));else{const e=new Map;a.forEach(t=>{const n=t.event.calendarId;e.has(n)||e.set(n,e.size)});const t=Yn(a.map(e=>e.event),(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)});a.sort((e,n)=>t(e.event,n.event))}const o=[];return a.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of o)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}o.push(Object.assign(Object.assign({},e),{row:t}))}),o})(Ie,Se,K,e.state.allDaySortComparator),[Ie,Se,K,e.state.allDaySortComparator]),He=p(()=>{const e=_?Re.filter(e=>e.endDayIndex>=W&&e.startDayIndex<=2*W-1):Re;if(0===e.length)return F;const t=Math.max(...e.map(e=>e.row));return F+t*F},[Re,F,_,W]),Pe=p(()=>si(Ie,Se,K,Ne),[Ie,Se,K,Ne]),Le=f((t,n,r)=>{const a=t(Ie),o=new Set(a.map(e=>e.id)),i=Ie.filter(e=>!o.has(e.id)),l=new Set(Ie.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=Ie.find(t=>t.id===e.id);return t&&yt(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},[Ie,e]),$e=f(t=>{C?(ge(t),ue(!0)):(e.addEvent(t),de(t.id))},[C,e]),ze=f(()=>{},[]),Ue=f((e,t,n)=>((e,t,n,r,a,o=7,i)=>{var l;const s=at(a,e),d=at(a,e);s.setHours(Math.floor(t),t%1*60,0,0),d.setHours(Math.floor(n),n%1*60,0,0);const c={id:"-1",title:"Temp",day:e,start:ke(s,i),end:ke(d,i),calendarId:"blue",allDay:!1};return(null===(l=si([...r,c],a,o,i).get(e))||void 0===l?void 0:l.get("-1"))||null})(e,t,n,Ie,Se,K,Ne),[Ie,Se,K,Ne]),We=f((e,t,n,r)=>((e,t,n,r,a,o,i=7,l)=>{var s;const d=a.map(a=>{if(a.id!==e.id)return a;const i=at(o,t),s=X(i,n),d=X(i,r),c=ke(s,l),u=ke(d,l);return Object.assign(Object.assign({},a),{day:t,start:c,end:u})});return(null===(s=si(d,o,i,l).get(t))||void 0===s?void 0:s.get(e.id))||null})(e,t,n,r,Ie,Se,K,Ne),[Ie,Se,K,Ne]),_e=p(()=>({calendarRef:a,allDayRowRef:H?ve:void 0,timeGridRef:k,viewType:I.WEEK,onEventsUpdate:Le,onEventCreate:$e,onEventEdit:ze,currentWeekStart:Se,events:Ie,calculateNewEventLayout:Ue,calculateDragLayout:We,TIME_COLUMN_WIDTH:L,isMobile:C,gridWidth:V,displayDays:K}),[a,H,Le,$e,ze,Se,Ie,Ue,We,L,C,V,K]),{handleMoveStart:Be,handleCreateStart:Ve,handleResizeStart:Ge,handleCreateAllDayEvent:Ke,dragState:qe,isDragging:Xe}=vi(e,_e),{handleDrop:Je,handleDragOver:Qe}=ui({app:e,onEventCreated:e=>{de(e.id)}}),et=p(()=>(({displayDays:e,displayStart:t,getWeekDaysLabels:n,isSlidingView:r,locale:a,startOfWeek:o})=>r?Array.from({length:e},(e,n)=>{const r=new Date(t);return r.setDate(r.getDate()+n),r.toLocaleDateString(a,{weekday:"short"})}):n(a,"short",o))({displayDays:K,displayStart:Se,getWeekDaysLabels:h,isSlidingView:_,locale:b,startOfWeek:B}),[K,Se,h,_,b,B]),tt=p(()=>((e,t,n,r)=>{if(!e)return[];const a=t.split("-")[0].toLowerCase();return"zh"===a||"ja"===a?n(t,"narrow"):r.map(e=>{if("en"===a){if(e.startsWith("Tu"))return"Tu";if(e.startsWith("Th"))return"Th";if(e.startsWith("Sa"))return"Sa";if(e.startsWith("Su"))return"Su"}return e.charAt(0)})})(C,b,h,et),[h,C,b,et]),nt=p(()=>u("allDay"),[u]),rt=Array.from({length:24},(e,t)=>({hour:t+j,label:Ae(t+j,0,A)})),ot=p(()=>P?je(rt,P,A,w,Ne):void 0,[P,A,j,w,Ne]),it=p(()=>P?Ye(Ne,w):void 0,[P,Ne,w]),lt=p(()=>P?Ye(P,w):void 0,[P,w]),st=p(()=>((e,t,n,r)=>{const a=ki(r);return t.map((t,r)=>{const o=new Date(e);return o.setDate(e.getDate()+r),{date:o.getDate(),month:o.toLocaleString(n,{month:"short"}),fullDate:new Date(o),isToday:o.toDateString()===a}})})(Se,et,b,Ne),[Ne,Se,b,et]),dt=p(()=>((e,t,n,r)=>{const a=ki(r),o=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return Array.from({length:7},(n,r)=>{const i=new Date(e);i.setDate(e.getDate()+r);const l=new Date(i.getFullYear(),i.getMonth(),i.getDate());return{date:i.getDate(),month:i.toLocaleString(t,{month:"short"}),fullDate:new Date(i),isToday:i.toDateString()===a,isCurrent:l.getTime()===o,dayName:i.toLocaleDateString(t,{weekday:"short"})}})})(G,b,w,Ne),[Ne,w,b,G]),ct=t=>e.updateEvent(t.id,t),ut=t=>e.deleteEvent(t),ht=p(()=>{const e=Ze(Ne);e.setHours(0,0,0,0);const t=new Date(Se);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+K),e>=t&&e<n},[Se,K,Ne]);return y(()=>{if(t.scrollToCurrentTime&&fe.current){const e=fe.current,t=Fe(Ne),n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-j)*$-r/2)}},[Ne,t.scrollToCurrentTime,j,$]),m(()=>{Q(Fe(Ne));const e=setInterval(()=>Q(Fe(Ne)),6e4);return()=>clearInterval(e)},[Ne]),$t("div",{className:"df-calendar relative flex flex-col w-full overflow-hidden h-full select-none df-week-view",children:[$t(Co,{calendar:e,viewType:I.WEEK,currentDate:w,onPrevious:()=>{Ce()||e.goToPrevious()},onNext:()=>{Ee()||e.goToNext()},onToday:()=>e.goToToday()}),$t(Ei,{app:e,weekDaysLabels:et,mobileWeekDaysLabels:tt,weekDates:st,fullWeekDates:dt,isSlidingView:_,mobilePageStart:Te,currentWeekStart:Se,gridWidth:V,allDayAreaHeight:He,organizedAllDaySegments:Re,allDayLabelText:nt,isMobile:C,isTouch:T,showAllDay:H,calendarRef:a,allDayRowRef:ve,topFrozenContentRef:pe,ALL_DAY_HEIGHT:F,HOUR_HEIGHT:$,FIRST_HOUR:j,dragState:qe,isDragging:Xe,secondaryTimeSlots:ot,primaryTzLabel:it,secondaryTzLabel:lt,handleMoveStart:Be,handleResizeStart:Ge,handleEventUpdate:ct,handleEventDelete:ut,onDateChange:l,newlyCreatedEventId:se,setNewlyCreatedEventId:de,selectedEventId:ae,setSelectedEventId:ie,detailPanelEventId:oe,setDetailPanelEventId:le,handleCreateAllDayEvent:Ke,handleDragOver:Qe,handleDrop:Je,customDetailPanelContent:n,customEventDetailDialog:r}),$t(Ci,{app:e,timeSlots:rt,weekDaysLabels:et,currentWeekStart:Se,currentWeekEvents:Ie,eventLayouts:Pe,gridWidth:V,isMobile:C,isSlidingView:_,isTouch:T,scrollerRef:fe,timeGridRef:k,leftFrozenContentRef:ye,swipeContentRef:be,calendarRef:a,handleScroll:xe,handleCreateStart:Ve,handleTouchStart:(e,t,n)=>{if(!C&&!T)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;me.current=setTimeout(()=>{null==Ve||Ve({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{me.current&&(clearTimeout(me.current),me.current=null)},handleTouchMove:()=>{me.current&&(clearTimeout(me.current),me.current=null)},handleDragOver:Qe,handleDrop:Je,dragState:qe,isDragging:Xe,handleMoveStart:Be,handleResizeStart:Ge,handleEventUpdate:ct,handleEventDelete:ut,onDateChange:l,newlyCreatedEventId:se,setNewlyCreatedEventId:de,selectedEventId:ae,setSelectedEventId:ie,detailPanelEventId:oe,setDetailPanelEventId:le,customDetailPanelContent:n,customEventDetailDialog:r,isCurrentWeek:ht,currentTime:J,HOUR_HEIGHT:$,FIRST_HOUR:j,LAST_HOUR:Y,showStartOfDayLabel:Z,timeFormat:A,secondaryTimeSlots:ot,appTimeZone:Ne}),$t(z,{isOpen:ce,onClose:()=>{ue(!1),ge(null)},onSave:t=>{x.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),ue(!1),ge(null)},draftEvent:he,app:e,timeFormat:A})]})},Mi={startOfWeek:1},Si=e=>i(pi,Object.assign(Object.assign({},e),{viewType:I.WEEK,originalComponent:Ti,className:"week-view-factory"}));Si.displayName="WeekViewAdapter";const Ni=(e={})=>{const t=Object.assign(Object.assign({},Mi),e);return{type:I.WEEK,component:Si,config:t}},Ii=({app:e,appTimeZone:t,calendarRef:n,currentMonth:r,currentYear:a,customDetailPanelContent:o,customEventDetailDialog:i,day:l,dayIndex:s,dayLayout:d,detailPanelEventId:c,dragState:u,enableTouch:h,hasScrollbarSpace:g,isDragging:m,locale:f,moreLabel:p,newlyCreatedEventId:y,onCalendarDragOver:b,onCalendarDrop:D,onChangeView:w,onContextMenu:x,onCreateStart:E,onDetailPanelOpen:C,onDetailPanelToggle:k,onEventDelete:T,onEventLongPress:M,onEventSelect:S,onEventUpdate:N,onMoreEventsClick:O,onMoveStart:R,onResizeStart:H,onSelectDate:A,organizedMultiDaySegments:P,overlayVisibleLayerCount:L,screenSize:$,selectedEventId:j,showWeekNumbers:Y,totalSlotsNeeded:F,weekHeightPx:Z})=>{const z=v(null),U=v(null),W=l.date.toLocaleDateString(f,{month:f.startsWith("zh")||f.startsWith("ja")?"short":"long"})===r&&l.year===a,{hasMore:_,limit:B,timedEventsOnly:V,gapLayers:G,occupiedLayers:K,maxOccupiedLayer:X,segmentIsHidden:J}=d;let Q=0;P.slice(B).forEach(e=>{e.forEach(e=>{e.startDayIndex<=s&&e.endDayIndex>=s&&Q++})}),P.slice(0,B).forEach(e=>{e.forEach(e=>{e.startDayIndex<=s&&e.endDayIndex>=s&&J.has(e.id)&&Q++})});const te=G.filter(e=>e<B).length,ne=P.slice(0,B).filter(e=>e.some(e=>e.startDayIndex<=s&&e.endDayIndex>=s&&J.has(e.id))).length,re=Math.max(0,B-Math.max(X+1,0)),ae=Math.min(V.length,te+re+ne),oe=V.slice(0,ae),ie=Q+(V.length-ae),le=_&&L>B,se=17*(L-B),de=m&&u.eventId?u.eventId:null,ce=de?oe.find(e=>e.id===de):null,ue=de&&!ce?V.find(e=>e.id===de):null,he=ce?[ce,...oe.filter(e=>e.id!==de)]:ue&&oe.length>0?[ue,...oe.slice(0,-1)]:ue?[ue]:oe,ge=[];let me=0;const ve=Math.min(B,F);for(let r=0;r<ve;r++)if(K.has(r)&&!P[r].some(e=>e.startDayIndex<=s&&e.endDayIndex>=s&&J.has(e.id)))ge.push($t("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${r}-${l.date.getTime()}`));else if(me<he.length){const r=he[me];ge.push($t(xo,{event:r,isAllDay:!!r.allDay,viewType:I.MONTH,isBeingDragged:m&&u.eventId===r.id&&"move"===u.mode,calendarRef:n,hourHeight:72,firstHour:0,onEventUpdate:N,onEventDelete:T,onMoveStart:R,onResizeStart:H,onDetailPanelOpen:C,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:y,selectedEventId:j,detailPanelEventId:c,onDetailPanelToggle:k,customDetailPanelContent:o,customEventDetailDialog:i,app:e,isMobile:"desktop"!==$,enableTouch:h,appTimeZone:t},`${r.id}-${r.day}-${q(r.start)}-${me}`)),me++}return $t("div",{className:Nr("df-month-day-cell relative flex flex-col border-r",W?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===s?g?"last:border-r":"border-r-0":""),style:{height:Z},"data-date":(fe=l.date,`${fe.getFullYear()}-${String(fe.getMonth()+1).padStart(2,"0")}-${String(fe.getDate()).padStart(2,"0")}`),onClick:()=>W&&(null==A?void 0:A(l.date)),onDblClick:e=>null==E?void 0:E(e,l.date),onTouchStart:e=>{if("mobile"!==$&&!h)return;const t=e.touches[0];U.current={x:t.clientX,y:t.clientY},z.current=setTimeout(()=>{null==E||E(e,l.date),z.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(z.current&&U.current){const t=Math.abs(e.touches[0].clientX-U.current.x),n=Math.abs(e.touches[0].clientY-U.current.y);(t>10||n>10)&&(clearTimeout(z.current),z.current=null)}},onTouchEnd:()=>{z.current&&(clearTimeout(z.current),z.current=null),U.current=null},onDragOver:b,onDrop:e=>null==D?void 0:D(e,l.date),onContextMenu:e=>x(e,l.date),children:[$t("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[Y&&0===s&&"mobile"!==$&&$t("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:ee(l.date)}),$t("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 ${l.isToday?ur:W?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===l.day&&"desktop"===$?l.date.toLocaleDateString(f,{month:"short",day:"numeric"}):l.day})]}),$t("div",{className:"pointer-events-none relative flex-1 overflow-hidden px-1",children:[le&&$t("div",{className:"pointer-events-none absolute right-0 left-0 z-100 bg-white dark:bg-gray-900",style:{top:17*B+"px",height:`${se}px`}}),ge,_&&$t("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","desktop"===$?"text-left font-normal":"text-center font-medium","pointer-events-auto","z-100"),onClick:e=>{e.stopPropagation(),O?O(l.date):(null==A||A(l.date),null==w||w(I.DAY))},children:["+",ie,"desktop"===$?` ${p}`:""]})]})]},`day-${l.date.getTime()}`);var fe},Oi=h(({currentMonth:e,currentYear:t,newlyCreatedEventId:r,screenSize:a,isScrolling:o,isDragging:i,showWeekNumbers:l,showMonthIndicator:s=!0,item:d,weekHeight:c,events:u,dragState:h,calendarRef:f,onEventUpdate:y,onEventDelete:b,onMoveStart:D,onCreateStart:w,onResizeStart:x,onDetailPanelOpen:E,onMoreEventsClick:C,onChangeView:k,onSelectDate:T,selectedEventId:M,onEventSelect:S,onEventLongPress:N,detailPanelEventId:O,onDetailPanelToggle:R,customDetailPanelContent:H,customEventDetailDialog:A,onCalendarDrop:P,onCalendarDragOver:L,app:$,enableTouch:j,appTimeZone:Y})=>{const{t:F,locale:Z}=Wn(),[z,U]=g(!1),W=v(null),[_,B]=g(null),V=$.canMutateFromUI();m(()=>{V||B(null)},[V]);const G=(e,t)=>{e.preventDefault(),"mobile"!==a&&V&&B({x:e.clientX,y:e.clientY,date:t})},K=p(()=>{const e=c-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=Math.floor(e/17),n=e-20,r=Math.max(0,Math.floor(n/17));return{maxSlots:t,maxSlotsWithMore:t>0?Math.min(r,t-1):r}},[c]);m(()=>o?(U(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):z?(W.current=setTimeout(()=>{U(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[o,z]);const{weekData:X}=d,J=X.days.find(e=>1===e.day),Q=`${c}px`,ee=p(()=>Jt(),[]),te=p(()=>oo(u,X.startDate,7,Y),[u,X.startDate,Y]),ne=p(()=>((e,t,r)=>{const a=[],o=new Date(t);return o.setDate(o.getDate()+6),o.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void ge.warn("Event missing start or end date:",e);const i=we(e.start,r),l=e.end?we(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}const u=s.toDateString()!==c.toDateString();if(!u||e.allDay)if(u&&e.allDay){let r=new Date(i);r<t&&(r=new Date(t),r.setHours(0,0,0,0));const s=l>o?o:l;for(let o=i.getTime();o<=s.getTime();o+=864e5){const i=new Date(o);if(i<t)continue;const l=n.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});a.push(Object.assign(Object.assign({},e),{start:l,end:l,day:r.getDay()}))}}else a.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:i.getDay()}))}),a})(u,X.startDate,Y),[u,X.startDate,Y]),re=p(()=>{const e=new Map;return X.days.forEach(t=>{const n=t.date.toDateString();e.set(n,ne.filter(e=>{if(!e.start||!e.end)return we(e.start,Y).toDateString()===n;const t=we(e.start,Y),r=we(e.end,Y);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},[ne,X.days,Y]),ae=p(()=>((e,t)=>{const n=t||Yn(e.map(e=>e.event),(()=>{const t=new Map;return e.forEach(e=>{const n=e.event.calendarId;t.has(n)||t.set(n,t.size)}),(e,n)=>{var r,a;return(null!==(r=t.get(e.calendarId))&&void 0!==r?r:0)-(null!==(a=t.get(n.calendarId))&&void 0!==a?a:0)}})()),r=[...e].toSorted((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}const r=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:r!==a?a-r:e.startDayIndex-t.startDayIndex}),a=[];r.forEach(e=>{var t;let n=0,r=!1;for(;!r;){let o=!1;for(const r of a){const a=Math.abs((null!==(t=r.yPosition)&&void 0!==t?t:0)-n)<16,i=!(e.endDayIndex<r.startDayIndex||e.startDayIndex>r.endDayIndex);if(a&&i){o=!0;break}}o?n+=16:r=!0}a.push(Object.assign(Object.assign({},e),{yPosition:n}))});const o=[];return a.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);o[n]||(o[n]=[]),o[n].push(e)}),o.forEach(e=>{e.sort((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}return e.startDayIndex-t.startDayIndex})}),o})(te,$.state.allDaySortComparator),[te,$.state.allDaySortComparator]),oe=p(()=>ae.flat(),[ae]),ie=p(()=>{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]),le=p(()=>{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]),se=p(()=>{const{maxSlots:e,maxSlotsWithMore:t}=K,n=X.days.map((n,r)=>{var a,o;const i=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:q(e.start)-q(t.start)))(null!==(a=re.get(n.date.toDateString()))&&void 0!==a?a:[]),l=i.filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),s=(null!==(o=ie[r])&&void 0!==o?o:0)-1,d=le[r],c=[];for(let e=0;e<=s;e++)d.has(e)||c.push(e);const u=l.length,h=Math.max(0,u-c.length),g=Math.max(s+1,0)+h,m=g>e;return{totalSlotsNeeded:g,hasMore:m,limit:m?t:e,timedEventsOnly:l,gapLayers:c,occupiedLayers:d,maxOccupiedLayer:s}}),r=new Set;return ae.forEach((e,t)=>{e.forEach(e=>{for(let a=e.startDayIndex;a<=e.endDayIndex;a++)if(a>=0&&a<7&&t>=n[a].limit){r.add(e.id);break}})}),n.map((n,a)=>{let o=!1;oe.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&r.has(e.id)&&(o=!0)});const i=n.hasMore||o,l=i?t:e;return Object.assign(Object.assign({},n),{hasMore:i,limit:l,segmentIsHidden:r})})},[K,X.days,re,oe,ie,le,ae]),de=p(()=>Math.min(ae.length,K.maxSlots),[ae.length,K.maxSlots]),ce=p(()=>Math.max(0,17*de),[de]),ue=p(()=>J?J.date.toLocaleDateString(Z,{month:"long",year:"numeric"}):"",[J,Z]);return $t("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:Q},children:[s&&J&&$t("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:$t("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ue})}),$t("div",{className:"flex h-full flex-col",children:$t("div",{className:"calendar-week relative h-full",children:[$t("div",{className:"grid h-full grid-cols-7",children:X.days.map((n,o)=>$t(Ii,{app:$,appTimeZone:Y,calendarRef:f,currentMonth:e,currentYear:t,customDetailPanelContent:H,customEventDetailDialog:A,day:n,dayIndex:o,dayLayout:se[o],detailPanelEventId:O,dragState:h,enableTouch:j,hasScrollbarSpace:ee,isDragging:i,locale:Z,moreLabel:F("more"),newlyCreatedEventId:r,onCalendarDragOver:L,onCalendarDrop:P,onChangeView:k,onContextMenu:G,onCreateStart:w,onDetailPanelOpen:E,onDetailPanelToggle:R,onEventDelete:b,onEventLongPress:N,onEventSelect:S,onEventUpdate:y,onMoreEventsClick:C,onMoveStart:D,onResizeStart:x,onSelectDate:T,organizedMultiDaySegments:ae,overlayVisibleLayerCount:de,screenSize:a,selectedEventId:M,showWeekNumbers:l,totalSlotsNeeded:se[o].totalSlotsNeeded,weekHeightPx:Q},`day-${n.date.getTime()}`))}),ae.length>0&&$t("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ce}px`},children:ae.slice(0,de).map((e,t)=>$t("div",{className:"absolute inset-0",children:e.filter(e=>!se[0].segmentIsHidden.has(e.id)).map(e=>$t(xo,{event:e.event,isAllDay:!0,segment:e,segmentIndex:t,viewType:I.MONTH,isMultiDay:!0,calendarRef:f,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:D,onResizeStart:x,isBeingDragged:i&&h.eventId===e.event.id&&"move"===h.mode,isBeingResized:i&&h.eventId===e.event.id&&"resize"===h.mode,newlyCreatedEventId:r,onDetailPanelOpen:E,selectedEventId:M,onEventSelect:S,onEventLongPress:N,detailPanelEventId:O,onDetailPanelToggle:R,customDetailPanelContent:H,customEventDetailDialog:A,app:$,isMobile:"desktop"!==a,enableTouch:j,appTimeZone:Y},e.id))},`layer-${t}`))})]})}),V&&_&&$t(no,{x:_.x,y:_.y,date:_.date,viewType:I.MONTH,onClose:()=>B(null),app:$,onCreateEvent:()=>{if(w){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:_.x,clientY:_.y};w(e,_.date)}}})]})},(e,t)=>e.currentMonth===t.currentMonth&&e.currentYear===t.currentYear&&e.newlyCreatedEventId===t.newlyCreatedEventId&&e.screenSize===t.screenSize&&e.isScrolling===t.isScrolling&&e.showWeekNumbers===t.showWeekNumbers&&e.showMonthIndicator===t.showMonthIndicator&&e.item.weekData===t.item.weekData&&e.weekHeight===t.weekHeight&&e.events===t.events&&e.calendarRef===t.calendarRef&&e.onEventUpdate===t.onEventUpdate&&e.onEventDelete===t.onEventDelete&&e.onMoveStart===t.onMoveStart&&e.onCreateStart===t.onCreateStart&&e.onResizeStart===t.onResizeStart&&e.onDetailPanelOpen===t.onDetailPanelOpen&&e.onMoreEventsClick===t.onMoreEventsClick&&e.onChangeView===t.onChangeView&&e.onSelectDate===t.onSelectDate&&e.selectedEventId===t.selectedEventId&&e.onEventSelect===t.onEventSelect&&e.onEventLongPress===t.onEventLongPress&&e.detailPanelEventId===t.detailPanelEventId&&e.onDetailPanelToggle===t.onDetailPanelToggle&&e.customDetailPanelContent===t.customDetailPanelContent&&e.customEventDetailDialog===t.customEventDetailDialog&&e.onCalendarDrop===t.onCalendarDrop&&e.onCalendarDragOver===t.onCalendarDragOver&&e.app===t.app&&e.enableTouch===t.enableTouch&&e.appTimeZone===t.appTimeZone);Oi.displayName="WeekComponent";const Ri=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=(n.getDay()-t+7)%7;return n.setDate(n.getDate()-r),n.setHours(0,0,0,0),n},Hi=(e,t,n,r)=>{const{startDate:a,adjustedEnd:o}=((e,t)=>{const n=we(e.start,t),r=e.end?we(e.end,t):n,a=new Date(n);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);let i=new Date(o);e.allDay||0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds()||i.setDate(i.getDate()-1);return i<a&&(i=new Date(a)),{startDate:a,adjustedEnd:i}})(e,r),i=Ri(a,n).getTime(),l=Ri(o,n).getTime(),s=Ri(t,n).getTime();return s>=i&&s<=l},Ai=[],Pi=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,detailPanelEventId:l,onDetailPanelToggle:s})=>{var d,c,u;const{getWeekDaysLabels:h,getMonthLabels:b,locale:D}=Wn(),w=e.getCurrentDate(),x=e.getEvents(),E=null!==(d=t.startOfWeek)&&void 0!==d?d:1,C=e.timeZone,k=!0===(null===(c=t.scroll)||void 0===c?void 0:c.disabled),T=k&&"fade"===(null===(u=t.scroll)||void 0===u?void 0:u.transition),[M,S]=g(w),[N,O]=g(!1),[A,P]=g("forward"),L=v(w),$=v(null),j=w.getFullYear(),Y=w.getMonth();m(()=>{if(!T)return;if(j===L.current.getFullYear()&&Y===L.current.getMonth())return;const e=w>L.current;return L.current=w,P(e?"forward":"backward"),$.current&&clearTimeout($.current),O(!0),$.current=setTimeout(()=>{S(w),O(!1)},300),()=>{$.current&&clearTimeout($.current)}},[j,Y,T]);const F=p(()=>T?((e,t)=>{const n=new Date(e.getFullYear(),e.getMonth(),1),r=(n.getDay()-t+7)%7,a=new Date(n);a.setDate(n.getDate()-r),a.setHours(0,0,0,0);const o=[];for(let e=0;e<6;e++){const t=new Date(a);t.setDate(a.getDate()+7*e),o.push(Qe(t))}return o})(M,E):[],[T,M,E]),Z=p(()=>({opacity:N?0:1,transform:N?`translateX(${"forward"===A?"-6%":"6%"})`:"translateX(0)",transition:"opacity 300ms ease, transform 300ms ease"}),[N,A]),z=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),U=v(null),W=p(()=>{const e=U.current;return e&&e.length===x.length&&e.every((e,t)=>e===x[t])?e:(U.current=x,x)},[x]),_=p(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-E+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 W.forEach(e=>{if(!e.start)return;const r=we(e.start,C),a=e.end?we(e.end,C):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},[W,E,C]),{screenSize:B}=zn(),[V,G]=g(!1);m(()=>{G("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const K=e.getCustomMobileEventRenderer()||Ha,[q,X]=g(()=>{if("undefined"==typeof window)return 119;const e=window.innerHeight-150;return Math.max(80,Math.ceil(e/6))}),[J,Q]=g(()=>"undefined"!=typeof window),ee=v(q),te=v([]),[ne,re]=g(null),[ae,oe]=g(!1),[ie,le]=g(null),[se,de]=g(null),[ce,ue]=g(null),he=void 0===o?se:o,ge=void 0===l?ce:l,me=f(e=>{i?i(e):de(e)},[i]),ve=f(e=>{s?s(e):ue(e)},[s]),fe=v(e.state.highlightedEventId);m(()=>{e.state.highlightedEventId?me(e.state.highlightedEventId):fe.current&&me(null),fe.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const pe=p(()=>{const e=(w.getDay()-E+7)%7,t=new Date(w);return t.setDate(w.getDate()-e),t.setHours(0,0,0,0),t},[w,E]),{handleMoveStart:ye,handleCreateStart:be,handleResizeStart:De,dragState:xe,isDragging:Ce}=vi(e,{calendarRef:a,viewType:I.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(W),o=new Set(a.map(e=>e.id)),i=W.filter(e=>!o.has(e.id)),l=new Set(W.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=W.find(t=>t.id===e.id);return t&&yt(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"===B?e.addEvent(t):(le(t),oe(!0))},onEventEdit:e=>{re(e.id)},currentWeekStart:pe,events:W,isMobile:"desktop"!==B}),Te=xe,{handleDrop:Me,handleDragOver:Se}=ui({app:e,onEventCreated:e=>{re(e.id)}}),Ne=p(()=>h(D,"short",E),[D,h,E]),Ie=p(()=>{if(!Ce||!Te.eventId||!Te.startDate||!Te.endDate||"move"!==Te.mode&&"resize"!==Te.mode)return null;const e=W.find(e=>e.id===Te.eventId);return e?Object.assign(Object.assign({},e),{start:e.allDay?Ee(Te.startDate):ke(Te.startDate,C),end:e.allDay?Ee(Te.endDate):ke(Te.endDate,C)}):null},[Ce,Te.eventId,Te.startDate,Te.endDate,Te.mode,W,C]),Oe=f(e=>{var t;const n=null!==(t=_.get(e.getTime()))&&void 0!==t?t:Ai;if(!Ie)return n;const r=n.some(e=>e.id===Ie.id),a=Hi(Ie,e,E,C);if(!r&&!a)return n;const o=n.filter(e=>e.id!==Ie.id);return a&&o.push(Ie),o},[_,Ie,E,C]),{currentMonth:Re,currentYear:He,isScrolling:Ae,virtualData:Pe,weeksData:Le,scrollElementRef:$e,isNavigating:je,handleScroll:Ye,handlePreviousMonth:Fe,handleNextMonth:Ze,handleToday:ze,setScrollTop:Ue}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:a="en-US",startOfWeek:o=1,isEnabled:i=!0,snapToMonth:l=!1})=>{const s=v(null),d=f((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]),c=p(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),tt(t,r,o)},[e,r,o]),u=p(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=c.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[c,e,t]),[h,b]=g(u),[D,w]=g(600),[x,E]=g(d(e.getMonth(),e.getFullYear())),[C,k]=g(e.getFullYear()),[T,M]=g(!1),[S,N]=g(c),[I,O]=g(!1),A=v(!1),[P,L]=g(!1),$=v(e),j=v(null),Y=v(null),F=v(new H),Z=v(0),z=v(0),U=v(!1),W=f(e=>{e&&(j.current=e)},[]),_=f(e=>{let t=F.current.get(e);return t||(t=Qe(e),F.current.set(e,t)),t},[]),B=f((e,n=26)=>{U.current||(U.current=!0,setTimeout(()=>{try{if("future"===e){const e=S.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(_(n))}N(e=>[...e,...t])}else{const e=S[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(_(n))}const a=r.length*t;N(e=>[...r,...e]),requestAnimationFrame(()=>{b(e=>e+a),j.current&&(j.current.scrollTop+=a)})}}finally{setTimeout(()=>{U.current=!1},200)}},0))},[S,_,t]),V=p(()=>{const e=S.length*t,n=Math.floor(h/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,S.length-6));const a=Math.min(S.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(S.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:S[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[h,D,t,S]),G=f(e=>{if(I||T||0===e.length||!P)return;const t=h+D/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=`${d(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",i=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(s.current?o===s.current.month&&i===s.current.year&&(s.current=null,o===x&&i===C||(E(o),k(i),null==n||n(o,i))):o===x&&i===C||(E(o),k(i),null==n||n(o,i)))},[D,x,C,I,T,n,h,P]),K=f(e=>{const n=performance.now();if(n-Z.current<R.SCROLL_THROTTLE)return;Z.current=n;const r=e.currentTarget,a=r.scrollTop;z.current=a,b(a),I||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!U.current&&B("future",26),a<10*t&&!U.current&&B("past",26)}),M(!0),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{M(!1)},R.SCROLL_DEBOUNCE)},[t,B,I]),q=f((e,n=!0)=>{if(!j.current)return;O(!0),A.current=!0;const r=()=>{setTimeout(()=>{O(!1),A.current=!1},n?500:200)},a=S.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return j.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=S[0],d=S.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(_(t))}const o=a.length*t;N(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...S].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(j.current&&-1!==i){const e=i*t;j.current.scrollTop+=o,b(e=>e+o),setTimeout(()=>{j.current&&j.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(_(t))}N(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...S,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(j.current&&-1!==o){const e=o*t;j.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[S,t,_]),X=f(()=>{var e;const t=V.displayStartIndex,n=Math.min(S.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=S[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a-1,1);q(l)},[V.displayStartIndex,S,q]),J=f(()=>{var e;const t=V.displayStartIndex,n=Math.min(S.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=S[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a+1,1);q(l)},[V.displayStartIndex,S,q]),Q=f(()=>{const e=new Date,r=d(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);s.current={month:r,year:a},E(r),k(a),null==n||n(r,a);const i=S.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)O(!0),A.current=!0,requestAnimationFrame(()=>{q(o,!0),setTimeout(()=>{A.current=!1,O(!1)},200)});else{const e=i*t,n=j.current;n&&(O(!0),A.current=!0,requestAnimationFrame(()=>{b(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{A.current=!1,O(!1)},200))})}))}},[S,t,n,q]);return m(()=>{G(V.visibleItems)},[V.visibleItems,G]),m(()=>{const t=$.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){const e=6,t=V.displayStartIndex,r=Math.min(S.length-1,t+e-1),a={};for(let e=t;e<=r;e++){const t=S[e];t&&t.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1})}let l="",c=0;for(const[e,t]of Object.entries(a))t>c&&(c=t,l=e);if(l!==`${o}-${i}`){const e=new Date(i,o,1),t=d(o,i);s.current={month:t,year:i},E(t),k(i),null==n||n(t,i),q(e,!0)}}$.current=e},[e,n,q,V,S,d]),m(()=>{const e=j.current;if(!e)return;const t=new ResizeObserver(([e])=>{w(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),y(()=>{const e=j.current;e&&!P&&i&&(u>0&&(e.scrollTop=u),L(!0))},[P,u,i]),m(()=>{var e;if(!l||T||I||!P)return;const n=Math.floor(h/t),r=Math.min(S.length-1,n+5),a={};for(let t=n;t<=r;t++)null===(e=S[t])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1});let o=0,i=0,s=0;for(const[e,t]of Object.entries(a))t>s&&(s=t,[o,i]=e.split("-").map(Number));const d=new Date(i,o,1),c=S.findIndex(e=>e.days.some(e=>e.date.toDateString()===d.toDateString()));if(-1===c)return;const u=c*t;if(Math.abs(u-h)>5){const e=setTimeout(()=>{q(d,!0)},200);return()=>clearTimeout(e)}},[T,l,I,P,h,t,S,q]),m(()=>()=>{Y.current&&clearTimeout(Y.current)},[]),{scrollTop:h,containerHeight:D,currentMonth:x,currentYear:C,isScrolling:T,isNavigating:I,virtualData:V,scrollElementRef:j,handleScroll:K,scrollToDate:q,handlePreviousMonth:X,handleNextMonth:J,handleToday:Q,setScrollTop:b,setContainerHeight:w,setCurrentMonth:E,setCurrentYear:k,setIsScrolling:M,cache:F.current,scrollElementRefCallback:W,weeksData:S}})({currentDate:w,weekHeight:q,onCurrentMonthChange:(t,n)=>{const r=D.startsWith("zh")||D.startsWith("ja"),a=b(D,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:D,startOfWeek:E,isEnabled:J,snapToMonth:t.snapToMonth}),We=v(0),[_e,Be]=g(0),Ve=p(()=>_e-6*q,[_e,q]),{visibleWeeks:Ge,startIndex:Ke}=p(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=Pe,a=n.findIndex(e=>e.index===r);if(-1===a)return te.current.length>0?{visibleWeeks:te.current,startIndex:We.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&&(te.current=i,We.current=l),{visibleWeeks:i,startIndex:l}},[Pe]),qe=p(()=>Ke*q,[Ke,q]),Xe=v(!0),Je=v(!1),et=((e,t)=>{const[n,r]=g(e);return m(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(Pe.displayStartIndex,250);m(()=>{je&&(Je.current=!0)},[je]),m(()=>{if(Xe.current)return void(Xe.current=!1);const t=Le[et];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,Je.current?"navigation":"scroll"),Je.current=!1},[e,Le,et]);const nt=p(()=>{const e=Pe.totalHeight,t=Ke*q+Ge.length*q+Ve;return Math.max(0,e-t)},[Pe.totalHeight,Ke,q,Ve,Ge.length]);m(()=>{const e=$e.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Be(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==ee.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/ee.current)*n;e.scrollTop=r,Ue(r)}X(n),ee.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[$e,Ue]),y(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));X(t),ee.current=t,Q(!0)},[]),m(()=>{if(T||!k)return;const e=$e.current;if(!e)return;const t=e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t)}},[T,k,$e]);const rt=f(t=>e.updateEvent(t.id,t),[e]),at=f(t=>e.deleteEvent(t),[e]),ot=t=>{e.changeView(t)},it=f(()=>re(null),[]),lt=f(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==B||V)&&t&&n){const e=W.find(e=>e.id===t);if(e)return le(e),void oe(!0)}me(t)},[B,V,W,me,e]),st=f(e=>{("desktop"!==B||V)&&me(e)},[B,V,me]);return $t("div",{className:_n,children:[$t(Co,{calendar:e,viewType:I.MONTH,currentDate:w,customTitle:(()=>{const e=D.startsWith("zh")||D.startsWith("ja");if(T){const t=b(D,e?"short":"long")[M.getMonth()],n=M.getFullYear();return e?`${n}年${t}`:`${t} ${n}`}return e?`${He}年${Re}`:`${Re} ${He}`})(),onPrevious:()=>{e.goToPrevious(),T||Fe()},onNext:()=>{e.goToNext(),T||Ze()},onToday:()=>{e.goToToday(),T||ze()}}),$t("div",{className:"df-week-header-row sticky top-0 z-10 border-b",onContextMenu:e=>e.preventDefault(),children:$t("div",{className:"grid grid-cols-7 px-2",children:Ne.map((e,t)=>$t("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),$t("div",T?{ref:$e,className:qn,style:{overflow:"hidden",visibility:J?"visible":"hidden"},children:$t("div",{style:Z,children:F.map((o,i)=>{const l=Oe(o.startDate),s={index:i,weekData:o,top:i*q,height:q},d=5===i?Object.assign(Object.assign({},s),{height:s.height+Ve}):s;return $t(Oi,{item:d,weekHeight:q,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:!1,currentMonth:"",currentYear:0,screenSize:B,isScrolling:!1,calendarRef:a,events:l,onEventUpdate:rt,onEventDelete:at,onMoveStart:ye,onCreateStart:be,onResizeStart:De,isDragging:Ce,dragState:Te,newlyCreatedEventId:ne,onDetailPanelOpen:it,onMoreEventsClick:e.onMoreEventsClick,onChangeView:ot,onSelectDate:e.selectDate,selectedEventId:he,onEventSelect:lt,onEventLongPress:st,detailPanelEventId:ge,onDetailPanelToggle:ve,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:Me,onCalendarDragOver:Se,calendarSignature:z,app:e,enableTouch:V,appTimeZone:C},`week-${o.startDate.getTime()}`)})})}:{ref:$e,className:qn,style:{overflow:"hidden auto",overscrollBehavior:"contain",visibility:J?"visible":"hidden"},onScroll:Ye,children:[$t("div",{style:{height:qe}}),Ge.map((o,i)=>{const l=Oe(o.weekData.startDate),s=5===i?Object.assign(Object.assign({},o),{height:o.height+Ve}):o,d=!(!1===t.showMonthIndicator||!o.weekData.days.some(e=>1===e.day))&&Ae;return $t(Oi,{item:s,weekHeight:q,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:Re,currentYear:He,screenSize:B,isScrolling:d,calendarRef:a,events:l,onEventUpdate:rt,onEventDelete:at,onMoveStart:ye,onCreateStart:be,onResizeStart:De,isDragging:Ce,dragState:Te,newlyCreatedEventId:ne,onDetailPanelOpen:it,onMoreEventsClick:e.onMoreEventsClick,onChangeView:ot,onSelectDate:e.selectDate,selectedEventId:he,onEventSelect:lt,onEventLongPress:st,detailPanelEventId:ge,onDetailPanelToggle:ve,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:Me,onCalendarDragOver:Se,calendarSignature:z,app:e,enableTouch:V,appTimeZone:C},`week-${o.weekData.startDate.getTime()}`)}),$t("div",{style:{height:nt}})]}),$t(K,{isOpen:ae,onClose:()=>{oe(!1),le(null)},onSave:t=>{W.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),oe(!1),le(null)},draftEvent:ie,app:e})]})},Li={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},$i=e=>i(pi,Object.assign(Object.assign({},e),{viewType:I.MONTH,originalComponent:Pi,className:"month-view-factory"}));$i.displayName="MonthViewAdapter";const ji=(e={})=>{const t=Object.assign(Object.assign({},Li),e);return{type:I.MONTH,component:$i,config:t}};function Yi(e,t,n,r,a){if(0===t.length)return[];const o=t[0],i=t.at(-1);if(!o||!i)return[];const l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),s=new Date(i.getFullYear(),i.getMonth(),i.getDate(),23,59,59,999).getTime(),d=e.map(e=>{const t=we(e.start,a),n=e.end?we(e.end,a):t;return{event:e,startMs:new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),endMs:new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()}}).filter(e=>e.startMs<=s&&e.endMs>=l);if(0===d.length)return[];const c=Yn(d.map(e=>e.event),r);d.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:c(e.event,t.event)});const u=[],h=[];return d.forEach(({event:e,startMs:t,endMs:r})=>{let a=Math.round((t-l)/864e5),o=Math.round((r-l)/864e5);a=Math.max(0,Math.min(a,n-1)),o=Math.max(0,Math.min(o,n-1));const i=t>=l,d=r<=s;let c=0;for(;;){h[c]||(h[c]=[]);let e=!1;for(let t=a;t<=o;t++)if(h[c][t]){e=!0;break}if(!e){for(let e=a;e<=o;e++)h[c][e]=!0;break}c++}u.push({id:`${e.id}::year-${l}`,event:e,startCellIndex:a,endCellIndex:o,isFirstSegment:i,isLastSegment:d,visualRowIndex:c})}),u}const Fi=(e,t,n,r)=>{if(!e)return!1;const a=new Date(t,n,1).getTime(),o=new Date(t,n+1,0,23,59,59,999).getTime(),i=we(e.start,r),l=e.end?we(e.end,r):i,s=new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime(),d=new Date(l.getFullYear(),l.getMonth(),l.getDate(),23,59,59,999).getTime();return s<=o&&d>=a};function Zi(e,t,n,r=1,a){const o=new Date(n,t,1),i=new Date(n,t+1,0).getDate(),l=(o.getDay()-r+7)%7,s=o.getTime(),d=new Date(n,t,i,23,59,59,999).getTime(),c=e.filter(e=>!!e.start).map(e=>{const t=we(e.start,a),n=e.end?we(e.end,a):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate());return{event:e,startMs:r.getTime(),endMs:o.getTime(),eventStartDay:r,eventEndDay:o}}).filter(e=>e.startMs<=d&&e.endMs>=s);if(0===c.length)return{segments:[],maxVisualRow:-1};const u=Yn(c.map(e=>e.event));c.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:u(e.event,t.event)});const h=[],g=[];c.forEach(({event:e,startMs:r,endMs:a,eventStartDay:o,eventEndDay:i})=>{const c=Math.max(r,s),u=Math.min(a,d),m=new Date(c).getDate(),v=new Date(u).getDate(),f=l+(m-1),p=l+(v-1),y=o.getMonth()===t&&o.getFullYear()===n,b=i.getMonth()===t&&i.getFullYear()===n;let D=0;for(;;){g[D]||(g[D]=[]);let e=!1;for(let t=f;t<=p;t++)if(g[D][t]){e=!0;break}if(!e){for(let e=f;e<=p;e++)g[D][e]=!0;break}D++}h.push({id:`${e.id}::month-${t}`,event:e,startCellIndex:f,endCellIndex:p,isFirstSegment:y,isLastSegment:b,visualRowIndex:D,monthIndex:t})});const m=h.length>0?Math.max(...h.map(e=>e.visualRowIndex)):-1;return{segments:h,maxVisualRow:m}}const zi=h(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=Wn(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return $t("div",{className:`relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800 ${c?"border-l-2 border-l-(--df-color-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:[$t("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&$t("span",{className:"df-fill-primary rounded-sm px-1 py-0.5 text-[9px] leading-none font-bold",children:u}),$t("span",{className:"ml-auto text-[10px] font-medium "+(t?"df-fill-primary flex h-5 w-5 items-center justify-center rounded-full":"text-gray-700 dark:text-gray-300"),children:d})]}),i>0&&$t("div",{className:"absolute bottom-0.5 left-1 z-20",children:$t("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")]})})]})});zi.displayName="YearDayCell";const Ui=(e,t,n)=>{if(!e||0===t.length)return!1;const r=t[0],a=t.at(-1);if(!r||!a)return!1;const 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=we(e.start,n),s=e.end?we(e.end,n):l,d=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),c=new Date(s.getFullYear(),s.getMonth(),s.getDate(),23,59,59,999).getTime();return d<=i&&c>=o},Wi=h(({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:v,detailPanelEventId:y,onDetailPanelToggle:b,customDetailPanelContent:D,customEventDetailDialog:w,onContextMenu:x,appTimeZone:E,dragPreviewEvent:C})=>{const k=p(()=>{const e=Ze(E);return e.setHours(0,0,0,0),e},[E]),T=f((e,t)=>{e.preventDefault(),e.stopPropagation(),x({x:e.clientX,y:e.clientY,date:t})},[x]),M=f(e=>{r.selectDate(e)},[r]),S=p(()=>Yi(t,e,n,r.state.allDaySortComparator,E),[t,e,n,r.state.allDaySortComparator,E]),N=i&&"move"===l.mode&&!!C&&C.id===l.eventId,O=p(()=>{if(!C)return S;if(N)return S;const a=t.filter(e=>e.id!==C.id);return Ui(C,e,E)&&a.push(C),Yi(a,e,n,r.state.allDaySortComparator,E)},[C,N,S,t,e,n,r.state.allDaySortComparator,E]),R=p(()=>N?((e,t,n,r)=>{if(!e||0===t.length)return null;const a=t[0],o=t.at(-1);if(!a||!o)return null;const i=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),l=new Date(o.getFullYear(),o.getMonth(),o.getDate(),23,59,59,999).getTime(),s=we(e.start,r),d=e.end?we(e.end,r):s,c=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),u=new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime();if(c>l||u<i)return null;let h=Math.round((Math.max(c,i)-i)/864e5),g=Math.round((Math.min(u,l)-i)/864e5);return h=Math.max(0,Math.min(h,n-1)),g=Math.max(0,Math.min(g,n-1)),{id:`${e.id}::preview-year-${i}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:c>=i,isLastSegment:u<=l,visualRowIndex:0}})(C,e,n,E):null,[N,C,e,n,E]),{visibleSegments:H,moreCounts:A}=p(()=>{const t=Array.from({length:e.length}).fill(0);O.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 O.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}},[O,e.length]),P=p(()=>{if(!N||!l.eventId)return O;const e=O.filter(e=>e.event.id!==l.eventId);return R?[...e,R]:e},[N,l.eventId,O,R]);return $t("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()===k.getTime();return $t(zi,{date:e,isToday:n,locale:o,onSelectDate:M,onCreateStart:c,onMoreEventsClick:g,moreCount:A[t],onContextMenu:T},e.getTime())}),$t("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:$t("div",{className:"relative h-full w-full",children:(N&&l.eventId?P.filter(e=>H.some(t=>t.id===e.id)||e.id===(null==R?void 0:R.id)):H).map(e=>$t("div",{className:"pointer-events-auto",children:$t(xo,{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:b,newlyCreatedEventId:m,onDetailPanelOpen:v,calendarRef:a,app:r,detailPanelEventId:y,customDetailPanelContent:D,customEventDetailDialog:w,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e),appTimeZone:E})},e.id))})})]})},(e,t)=>{var n,r;const a=null===(n=e.dragPreviewEvent)||void 0===n?void 0:n.id,o=null===(r=t.dragPreviewEvent)||void 0===r?void 0:r.id,i=!!a&&e.events.some(e=>e.id===a)||!!o&&t.events.some(e=>e.id===o),l=Ui(e.dragPreviewEvent,e.rowDays,e.appTimeZone),s=Ui(t.dragPreviewEvent,t.rowDays,t.appTimeZone);return!(i||l||s)&&(e.rowDays===t.rowDays&&e.events===t.events&&e.columnsPerRow===t.columnsPerRow&&e.app===t.app&&e.calendarRef===t.calendarRef&&e.locale===t.locale&&e.onMoveStart===t.onMoveStart&&e.onResizeStart===t.onResizeStart&&e.onCreateStart===t.onCreateStart&&e.selectedEventId===t.selectedEventId&&e.onEventSelect===t.onEventSelect&&e.onMoreEventsClick===t.onMoreEventsClick&&e.newlyCreatedEventId===t.newlyCreatedEventId&&e.onDetailPanelOpen===t.onDetailPanelOpen&&e.detailPanelEventId===t.detailPanelEventId&&e.onDetailPanelToggle===t.onDetailPanelToggle&&e.customDetailPanelContent===t.customDetailPanelContent&&e.customEventDetailDialog===t.customEventDetailDialog&&e.onContextMenu===t.onContextMenu&&e.appTimeZone===t.appTimeZone)});Wi.displayName="YearRowComponent";const _i=({app:e,calendarRef:t,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:u,locale:h}=Wn(),b=e.getCurrentDate(),D=b.getFullYear(),w=e.getEvents(),x=e.timeZone,E=v(null),[C,k]=g(7),[T,M]=g(!1),[S,N]=g(()=>"undefined"!=typeof window&&window.innerWidth<768),[O,R]=g(null),[H,A]=g(null),P=void 0===i?O:i,L=void 0===s?H:s,[$,j]=g(null),Y=f(e=>{l?l(e):R(e)},[l]),F=f(e=>{d?d(e):A(e)},[d]),Z=f(()=>{j(null)},[]),[z,U]=g(null),W=e.canMutateFromUI();m(()=>{W||U(null)},[W]),m(()=>{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||(Y(null),F(null),U(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const _=v(null);y(()=>{const e=E.current;if(!e)return;const t=e=>{if(e<=0)return;const t=Math.max(1,Math.floor(e/80));k(t),N(e<768),M(!0)};t(e.clientWidth);const n=new ResizeObserver(e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{const n=e[0].contentRect.width;t(n)},60)});return n.observe(e),()=>{n.disconnect(),_.current&&clearTimeout(_.current)}},[]);const B=v(e.state.highlightedEventId);m(()=>{e.state.highlightedEventId?(Y(e.state.highlightedEventId),requestAnimationFrame(()=>{const t=E.current;if(!t)return;const n=t.querySelector(`[data-event-id="${e.state.highlightedEventId}"]`);if(!n)return;const r=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=a.top-r.top+t.scrollTop-t.clientHeight/2+a.height/2;t.scrollTo({top:Math.max(0,o),behavior:"smooth"})})):B.current&&Y(null),B.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const{handleMoveStart:V,handleResizeStart:G,handleCreateStart:K,dragState:q,isDragging:X}=vi(e,{calendarRef:t,viewType:I.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(w).filter(e=>{const t=w.find(t=>t.id===e.id);return t&&yt(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:w,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{j(e.id)},isMobile:S}),J=q,Q=null!==(c=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==c&&c,ee=f((t,r)=>{if(Q)null==K||K(t,r);else{const t=n.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:u("newEvent")||"New Event",start:t,end:t,allDay:!0,calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"};e.addEvent(a),j(a.id)}},[Q,K,e,u]),te=p(()=>{const e=[],t=new Date(D,0,1),n=new Date(D,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[D]),ne=p(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(te,C),[te,C]),re=p(()=>{const e=new Date(D,0,1),t=new Date(D,11,31,23,59,59);return w.filter(n=>{if(!n.start)return!1;if(!Q&&!n.allDay)return!1;const r=we(n.start,x),a=n.end?we(n.end,x):r;return r<=t&&a>=e})},[w,D,Q,x]),ae=p(()=>{const e=re.map(e=>{const t=we(e.start,x),n=e.end?we(e.end,x):t;return{event:e,startMs:new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),endMs:new Date(n.getFullYear(),n.getMonth(),n.getDate(),23,59,59,999).getTime()}});return ne.map(t=>{if(0===t.length)return[];const n=t[0],r=t.at(-1);if(!n||!r)return[];const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime();return e.filter(e=>e.startMs<=o&&e.endMs>=a).map(e=>e.event)})},[ne,re,x]),oe=p(()=>{if(!X||!J.eventId||!J.startDate||!J.endDate||"move"!==J.mode&&"resize"!==J.mode)return null;const e=re.find(e=>e.id===J.eventId);return e?Object.assign(Object.assign({},e),{start:e.allDay?Ee(J.startDate):ke(J.startDate,x),end:e.allDay?Ee(J.endDate):ke(J.endDate,x)}):null},[X,J.eventId,J.startDate,J.endDate,J.mode,re,x]);return $t("div",{className:_n,onContextMenu:e=>e.preventDefault(),children:[$t(Co,{calendar:e,viewType:I.YEAR,currentDate:b,customTitle:h.startsWith("zh")||h.startsWith("ja")?`${D}年`:`${D}`,onPrevious:()=>{const t=new Date(b);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(b);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),$t("div",{ref:E,className:`${qn} ${Xn}`,style:{overflow:"hidden auto"},children:$t("div",{className:"flex w-full flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:T?1:0,transition:"opacity 0.2s ease"},children:ne.map((n,o)=>$t(Wi,{rowDays:n,events:ae[o],columnsPerRow:C,app:e,calendarRef:t,locale:h,isDragging:X,dragState:J,dragPreviewEvent:oe,onMoveStart:V,onResizeStart:G,onCreateStart:ee,selectedEventId:P,onEventSelect:Y,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:$,onDetailPanelOpen:Z,detailPanelEventId:L,onDetailPanelToggle:F,customDetailPanelContent:r,customEventDetailDialog:a,onContextMenu:e=>{W&&U(e)},appTimeZone:x},o))})}),W&&z&&$t(no,{x:z.x,y:z.y,date:z.date,viewType:I.YEAR,onClose:()=>U(null),app:e,onCreateEvent:()=>{if(z&&z.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:z.x,clientY:z.y};ee(e,z.date)}}})]})},Bi=({app:e,calendarRef:t,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,u;const{t:h,locale:y,getWeekDaysLabels:b}=Wn(),D=e.getCurrentDate(),w=D.getFullYear(),x=e.getEvents(),E=e.timeZone,C=Ze(E);C.setHours(0,0,0,0);const k=null!==(c=null==o?void 0:o.startOfWeek)&&void 0!==c?c:1,T=v(null),M=v(null),S=v(null),[N,O]=g(0),[R,H]=g(0),[A,P]=g(null),[L,$]=g(null),j=void 0===i?A:i,Y=void 0===s?L:s,F=e=>{l?l(e):P(e)},Z=e=>{d?d(e):$(e)},[z,U]=g(null),[W,_]=g(null),B=e.canMutateFromUI();m(()=>{B||_(null)},[B]),m(()=>{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||(F(null),Z(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const V=v(e.state.highlightedEventId);m(()=>{e.state.highlightedEventId?(F(e.state.highlightedEventId),requestAnimationFrame(()=>{const t=S.current;if(!t)return;const n=t.querySelector(`[data-event-id="${e.state.highlightedEventId}"]`);if(!n)return;const r=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=a.top-r.top+t.scrollTop-t.clientHeight/2+a.height/2,i=a.left-r.left+t.scrollLeft-t.clientWidth/2+a.width/2;t.scrollTo({top:Math.max(0,o),left:Math.max(0,i),behavior:"smooth"})})):V.current&&F(null),V.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const G=p(()=>((e,t)=>{let n=0;for(let r=0;r<12;r++){const a=new Date(e,r,1),o=new Date(e,r+1,0).getDate(),i=(a.getDay()-t+7)%7+o;i>n&&(n=i)}return n})(w,k),[w,k]),{handleMoveStart:K,handleResizeStart:q,handleCreateStart:X,dragState:J,isDragging:Q}=vi(e,{calendarRef:t,viewType:I.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(x).filter(e=>{const t=x.find(t=>t.id===e.id);return t&&yt(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:x,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{U(e.id)}}),ee=J,te=null!==(u=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==u&&u,ne=f((t,r)=>{if(te)null==X||X(t,r);else{const t=n.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:t,end:t,allDay:!0};e.addEvent(a),U(a.id)}},[te,X,e,h]),re=p(()=>(({locale:e,totalColumns:t,startOfWeek:n,getWeekDaysLabels:r})=>{const a=r(e,"short",n).map(t=>{var n;if(e.startsWith("zh"))return null!==(n=t.at(-1))&&void 0!==n?n:t;const r=t.slice(0,2);return r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()}),o=[];for(let e=0;e<t;e++)o.push(a[e%7]);return o})({locale:y,totalColumns:G,startOfWeek:k,getWeekDaysLabels:b}),[y,G,k,b]),ae=p(()=>{const e=new Date(w,0,1),t=new Date(w,11,31,23,59,59);return x.filter(n=>{if(!n.start)return!1;if(!te&&!n.allDay)return!1;const r=we(n.start,E),a=n.end?we(n.end,E):r;return r<=t&&a>=e})},[x,w,te,E]),oe=p(()=>(({currentYear:e,locale:t,totalColumns:n,yearEvents:r,startOfWeek:a,appTimeZone:o})=>{const i=[];for(let l=0;l<12;l++){const s=new Date(e,l,1),d=new Date(e,l+1,0).getDate(),c=(s.getDay()-a+7)%7,u=[];for(let e=0;e<c;e++)u.push(null);for(let t=1;t<=d;t++)u.push(new Date(e,l,t));for(;u.length<n;)u.push(null);const h=s.toLocaleDateString(t,{month:"short"}),g=h.charAt(0).toUpperCase()+h.slice(1).toLowerCase(),{segments:m,maxVisualRow:v}=Zi(r,l,e,a,o),f=v+1,p=Math.max(60,20+18*f);i.push({monthIndex:l,monthName:g,days:u,monthEvents:r.filter(t=>Fi(t,e,l,o)),eventSegments:m,minHeight:p})}return i})({currentYear:w,locale:y,totalColumns:G,yearEvents:ae,startOfWeek:k,appTimeZone:E}),[w,y,G,ae,k,E]),ie=p(()=>(({isDragging:e,dragState:t,yearEvents:n,appTimeZone:r})=>{if(!e||!t.eventId||!t.startDate||!t.endDate||"move"!==t.mode&&"resize"!==t.mode)return null;const a=n.find(e=>e.id===t.eventId);return a?Object.assign(Object.assign({},a),{start:a.allDay?Ee(t.startDate):ke(t.startDate,r),end:a.allDay?Ee(t.endDate):ke(t.endDate,r)}):null})({isDragging:Q,dragState:ee,yearEvents:ae,appTimeZone:E}),[Q,ee,ae,E]),le=Q&&"move"===ee.mode&&!!ie&&ie.id===ee.eventId,se=p(()=>(({monthsData:e,dragPreviewEvent:t,isMovePreviewActive:n,currentYear:r,startOfWeek:a,appTimeZone:o})=>e.map(e=>{if(n)return e;if(!t||!e.monthEvents.some(e=>e.id===t.id)&&!Fi(t,r,e.monthIndex,o))return e;const i=e.monthEvents.filter(e=>e.id!==(null==t?void 0:t.id));t&&Fi(t,r,e.monthIndex,o)&&i.push(t);const{segments:l,maxVisualRow:s}=Zi(i,e.monthIndex,r,a,o);return Object.assign(Object.assign({},e),{eventSegments:l,minHeight:Math.max(60,20+18*(s+1))})}))({monthsData:oe,dragPreviewEvent:ie,isMovePreviewActive:le,currentYear:w,startOfWeek:k,appTimeZone:E}),[oe,ie,le,w,k,E]),de=f(e=>{const t=e.currentTarget;T.current&&(T.current.scrollLeft=t.scrollLeft),M.current&&(M.current.scrollTop=t.scrollTop)},[]);m(()=>{const e=()=>{if(S.current){const e=S.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;H(e=>e===t?e:t),O(e=>e===n?e:n)}},t=S.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[se]);return $t("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:[$t("div",{className:"col-span-2",children:$t(Co,{calendar:e,viewType:I.YEAR,currentDate:D,customTitle:y.startsWith("zh")||y.startsWith("ja")?`${w}年`:`${w}`,onPrevious:()=>{const t=new Date(D);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(D);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),$t("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),$t("div",{ref:T,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:$t("div",{className:"flex",style:{minWidth:`calc(1352px + ${N}px)`},children:[$t("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${G}, minmax(0, 1fr))`,minWidth:"1352px"},children:re.map((e,t)=>{const n=(t+k)%7;return $t("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}`)})}),N>0&&$t("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${N}px`}})]})}),$t("div",{ref:M,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:$t("div",{className:"flex min-h-full flex-col",children:[se.map(e=>$t("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`,transition:"min-height 180ms cubic-bezier(0.22, 1, 0.36, 1)"},children:e.monthName},e.monthIndex)),R>0&&$t("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${R}px`}})]})}),$t("div",{ref:S,className:`overflow-auto ${Xn}`,onScroll:de,children:$t("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:se.map(n=>{const o=le&&ie?((e,t,n,r=1,a)=>{if(!e)return null;const o=new Date(n,t,1),i=new Date(n,t+1,0).getDate(),l=(o.getDay()-r+7)%7,s=o.getTime(),d=new Date(n,t,i,23,59,59,999).getTime(),c=we(e.start,a),u=e.end?we(e.end,a):c,h=new Date(c.getFullYear(),c.getMonth(),c.getDate()),g=new Date(u.getFullYear(),u.getMonth(),u.getDate()),m=h.getTime(),v=g.getTime();if(m>d||v<s)return null;const f=Math.max(m,s),p=Math.min(v,d);return{id:`${e.id}::preview-month-${t}`,event:e,startCellIndex:l+(new Date(f).getDate()-1),endCellIndex:l+(new Date(p).getDate()-1),isFirstSegment:h.getMonth()===t&&h.getFullYear()===n,isLastSegment:g.getMonth()===t&&g.getFullYear()===n,visualRowIndex:0,monthIndex:t}})(ie,n.monthIndex,w,k,E):null,i=le&&ee.eventId?[...n.eventSegments.filter(e=>e.event.id!==ee.eventId),...o?[o]:[]]:n.eventSegments;return $t("div",{className:"relative shrink-0 grow",style:{minHeight:`${n.minHeight}px`,transition:"min-height 180ms cubic-bezier(0.22, 1, 0.36, 1)"},children:[$t("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${G}, minmax(0, 1fr))`},children:n.days.map((t,r)=>{const a=(r+k)%7,o=0===a||6===a;if(!t)return $t("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-${n.monthIndex}-${r}`);const i=(e=>e.getTime()===C.getTime())(t);return $t("div",{"data-date":`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,className:`df-hover-primary-dark-md relative flex cursor-pointer items-start justify-end border-r border-b border-gray-200 p-0.5 transition-colors ${Q?"":"hover:bg-blue-100"} dark:border-gray-700 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>e.selectDate(t),onDblClick:e=>ne(e,t),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),B&&_({x:e.clientX,y:e.clientY,date:t})})(e,t),children:$t("span",{className:`flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium ${i?"df-fill-primary font-bold shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:t.getDate()})},t.getTime())})}),i.length>0&&$t("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:$t("div",{className:"relative h-full w-full",children:i.map(n=>$t("div",{className:"pointer-events-auto",children:$t(xo,{event:n.event,isAllDay:!!n.event.allDay,viewType:I.YEAR,yearSegment:n,columnsPerRow:G,isBeingDragged:Q&&ee.eventId===n.event.id,selectedEventId:j,onMoveStart:K,onResizeStart:q,onEventSelect:F,onDetailPanelToggle:Z,newlyCreatedEventId:z,onDetailPanelOpen:()=>U(null),calendarRef:t,app:e,detailPanelEventId:Y,customDetailPanelContent:r,customEventDetailDialog:a,firstHour:0,hourHeight:0,onEventUpdate:t=>e.updateEvent(t.id,t),onEventDelete:t=>e.deleteEvent(t),appTimeZone:E})},n.id))})})]},n.monthIndex)})})}),B&&W&&$t(no,{x:W.x,y:W.y,date:W.date,viewType:I.YEAR,onClose:()=>_(null),app:e,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:W.x,clientY:W.y};ne(e,W.date)}})]})},Vi=({date:e,events:t,anchorEl:n,position:r,onClose:a,locale:i,app:l,customContent:s,appTimeZone:d})=>{const{t:u}=Wn(),h=v(null);m(()=>{const e=e=>{const t=e.target;!h.current||h.current.contains(t)||n.contains(t)||a()},t=e=>{"Escape"===e.key&&a()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n,a]);const g=l.getCalendars(),f=new Map(g.map(e=>[e.id,e])),p=e.toLocaleDateString(i,{weekday:"long",month:"long",day:"numeric"}),y=$t(o,{children:[$t("div",{className:"border-b border-gray-100 px-4 py-3 dark:border-gray-700",children:$t("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:p})}),$t("div",{className:"max-h-60 overflow-y-auto py-1",children:0===t.length?$t("div",{className:"px-4 py-3 text-center text-xs text-gray-400",children:"No events"}):t.map(e=>{var t,n;const r=e.calendarId?f.get(e.calendarId):void 0,a=null!==(n=null===(t=null==r?void 0:r.colors)||void 0===t?void 0:t.lineColor)&&void 0!==n?n:"#3b82f6";let o="";if(!e.allDay&&e.start){if(o=we(e.start,d).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1}),e.end){o+=` – ${we(e.end,d).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1})}`}}return $t("div",{className:"flex items-start gap-2.5 rounded px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800",children:[$t("div",{className:"mt-1.5 h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:a}}),$t("div",{className:"min-w-0 flex-1",children:[$t("div",{className:"truncate text-xs font-medium text-gray-900 dark:text-gray-100",children:e.title}),e.allDay&&$t("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:u("allDay")}),o&&$t("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:o})]})]},e.id)})})]});return c($t("div",{ref:h,"data-grid-day-popup":!0,className:"animate-in fade-in zoom-in-95 fixed z-50 w-64 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl duration-100 dark:border-gray-700 dark:bg-gray-900",style:{top:r.top,left:r.left},children:s?s(e,t):y}),document.body)};function Gi(e,t,n,r){const a=new Map,o=new Date(t,0,1);o.setHours(0,0,0,0);const i=new Date(t,11,31,23,59,59,999);for(const l of e){if(!l.start)continue;if(!n&&!l.allDay)continue;const e=we(l.start,r),s=l.end?we(l.end,r):new Date(e);if(e.setHours(0,0,0,0),s.setHours(0,0,0,0),e>i||s<o)continue;const d=e<o?new Date(o):new Date(e),c=s>i?new Date(t,11,31):new Date(s);d.setHours(0,0,0,0),c.setHours(0,0,0,0);const u=864e5,h=d.getTime(),g=Math.round((c.getTime()-h)/u);for(let e=0;e<=g;e++){const t=new Date(h+e*u),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=a.get(n);r?r.push(l):a.set(n,[l])}}return a}function Ki(e){const t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;let a=t.right+8;a+256>n-8&&(a=t.left-256-8),a=Math.max(8,Math.min(a,n-256-8));let o=t.top;return o+220>r-8&&(o=r-220-8),o=Math.max(8,o),{top:o,left:a}}const qi=({app:e,config:t})=>{var n,r,a;const{locale:o,getWeekDaysLabels:i}=Wn(),l=e.getCurrentDate(),s=l.getFullYear(),d=e.getEvents(),c=null!==(n=null==t?void 0:t.startOfWeek)&&void 0!==n?n:1,u=null!==(r=null==t?void 0:t.showTimedEventsInYearView)&&void 0!==r&&r,h=null!==(a=null==t?void 0:t.gridHeatmapLevels)&&void 0!==a?a:5,v=e.timeZone,y=p(()=>{const e=Ze(v);return e.setHours(0,0,0,0),e},[v]),[b,D]=g(null);m(()=>{if(!b)return;const e=e=>{const t=e.target;t.closest("[data-grid-day-popup]")||t.closest("[data-grid-day-cell]")||D(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]);const w=p(()=>Gi(d,s,u,v),[d,s,u,v]),x=p(()=>Gi(d,s,!0,v),[d,s,v]),E=p(()=>i(o,"narrow",c).map(e=>o.startsWith("zh")?e.at(-1):e.charAt(0).toUpperCase()),[o,i,c]),C=p(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(s,t,1),r=new Date(s,t+1,0).getDate(),a=[];for(let e=(n.getDay()-c+7)%7-1;e>=0;e--)a.push({date:new Date(s,t,-e),isCurrentMonth:!1});for(let e=1;e<=r;e++)a.push({date:new Date(s,t,e),isCurrentMonth:!0});let i=1;for(;a.length<42;)a.push({date:new Date(s,t+1,i++),isCurrentMonth:!1});const l=n.toLocaleDateString(o,{month:"long"}),d=l.charAt(0).toUpperCase()+l.slice(1);e.push({monthIndex:t,monthName:d,cells:a})}return e},[s,o,c]),k=f((n,r,a)=>{var o,i;const l=null!==(o=null==t?void 0:t.gridDateClick)&&void 0!==o?o:"popup";if("function"==typeof l){const e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`;return void l(r,null!==(i=x.get(e))&&void 0!==i?i:[])}if("popup"===l){const e=n.currentTarget;b&&b.date.getTime()===r.getTime()&&b.monthIndex===a?D(null):D({date:r,monthIndex:a,anchorEl:e,position:Ki(e)})}else"day-view"===l&&(e.setCurrentDate(r),e.changeView(I.DAY))},[t,e,b,x]),T=f(n=>{var r,a;const o=null!==(r=null==t?void 0:t.gridDateDoubleClick)&&void 0!==r?r:"day-view";if("function"==typeof o){const e=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`;return void o(n,null!==(a=x.get(e))&&void 0!==a?a:[])}"day-view"===o&&(D(null),e.setCurrentDate(n),e.changeView(I.DAY))},[t,e,x]),M=p(()=>{var e;if(!b)return[];const t=`${b.date.getFullYear()}-${String(b.date.getMonth()+1).padStart(2,"0")}-${String(b.date.getDate()).padStart(2,"0")}`;return[...null!==(e=x.get(t))&&void 0!==e?e:[]].toSorted((e,t)=>{const n=!!e.allDay;return n!==!!t.allDay?n?-1:1:0})},[b,x]);return $t("div",{className:_n,children:[$t(Co,{calendar:e,viewType:I.YEAR,currentDate:l,customTitle:o.startsWith("zh")||o.startsWith("ja")?`${s}年`:`${s}`,onPrevious:()=>{const t=new Date(l);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(l);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>e.goToToday()}),$t("div",{className:"grid min-h-0 flex-1 gap-3 p-3",style:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(3, 1fr)"},children:C.map(e=>$t("div",{className:"df-year-grid-month flex h-full min-h-0 flex-col rounded-lg border border-gray-100 bg-white p-2 dark:border-gray-800 dark:bg-gray-900",children:[$t("div",{className:"mb-1 shrink-0 text-xs font-semibold text-gray-900 dark:text-gray-100",children:e.monthName}),$t("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:$t("div",{className:"grid h-full w-full gap-px",style:{gridTemplateColumns:"repeat(7, 1fr)",gridTemplateRows:"repeat(7, 1fr)"},children:[E.map((e,t)=>$t("div",{className:"flex items-center justify-center text-[9px] font-medium text-gray-400 dark:text-gray-500",children:e},t)),e.cells.map(({date:t,isCurrentMonth:n},r)=>{var a,o;const i=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,l=n&&null!==(o=null===(a=w.get(i))||void 0===a?void 0:a.length)&&void 0!==o?o:0;var s,d;return $t("div",{"data-grid-day-cell":!0,className:"cursor-pointer rounded-sm transition-colors hover:opacity-80",style:n?(d=h,0===(s=l)?{}:{backgroundColor:`var(--heat-${Math.min(s,d)})`}):{},onClick:n=>k(n,t,e.monthIndex),onDblClick:()=>T(t),children:$t("div",{className:"flex h-full w-full items-center justify-center",children:$t("span",{className:"flex h-4 w-4 items-center justify-center rounded-full text-[9px] font-medium "+(t.getTime()===y.getTime()?"df-fill-primary font-bold":n?l>0?l>=4?"text-white":"text-gray-800 dark:text-gray-100":"text-gray-500 dark:text-gray-400":"text-gray-300 dark:text-gray-600"),children:t.getDate()})})},`${e.monthIndex}-${r}`)})]})})]},e.monthIndex))}),b&&$t(Vi,{date:b.date,events:M,anchorEl:b.anchorEl,position:b.position,onClose:()=>D(null),locale:o,app:e,customContent:null==t?void 0:t.gridPopupContent,appTimeZone:v})]})},Xi=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return"fixed-week"===n?$t(Bi,Object.assign({},e)):"grid"===n?$t(qi,{app:e.app,config:e.config}):$t(_i,Object.assign({},e))},Ji={},Qi=e=>i(pi,Object.assign(Object.assign({},e),{viewType:I.YEAR,originalComponent:Xi,className:"year-view-factory"}));Qi.displayName="YearViewAdapter";const el=(e={})=>{const t=Object.assign(Object.assign({},Ji),e);return{type:I.YEAR,component:Qi,config:t}};function tl(e){return[Di(null==e?void 0:e.day),Ni(null==e?void 0:e.week),ji(null==e?void 0:e.month)]}const nl={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function rl(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 al(t={}){const n=Object.assign(Object.assign({},nl),t);let r;const a={getAll:()=>r.getAllEvents(),getById:e=>r.getAllEvents().find(t=>t.id===e),add:e=>{if(n.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(n.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,r.getCurrentDate()).length>=n.maxEventsPerDay)throw new Error(`Maximum events per day (${n.maxEventsPerDay}) exceeded`)}if(r.addEvent(e),n.enableAutoRecalculate){const e=rl(r.getCurrentDate());r.state.events=ct(r.getAllEvents(),e)}},update:(t,o)=>e(this,void 0,void 0,function*(){const e=a.getById(t);if(!e)throw new Error(`Event with id ${t} not found`);const i=Object.assign(Object.assign({},e),o);if(n.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(yield r.updateEvent(t,o),n.enableAutoRecalculate){const e=rl(r.getCurrentDate());r.state.events=ct(r.getAllEvents(),e)}}),delete:t=>e(this,void 0,void 0,function*(){yield r.deleteEvent(t)}),getByDate:e=>r.getAllEvents().filter(t=>{const n=Y(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)=>r.getAllEvents().filter(n=>{const r=Y(n.start),a=Y(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>r.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>ct(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"),t},filterEvents:(e,t)=>e.filter(t)};return{name:"events",config:n,install:e=>{r=e},api:a}}export{Xr as AlertCircle,qr as AudioLines,ga as BlossomColorPicker,Pt as CalendarApp,xo as CalendarEvent,oe as CalendarRegistry,_a as CalendarRenderer,$r as Check,Ar as ChevronDown,Or as ChevronRight,jr as ChevronsUpDown,ha as ContentSlot,Va as ContextMenu,to as ContextMenuColorPicker,Ga as ContextMenuItem,qa as ContextMenuLabel,Ka as ContextMenuSeparator,pa as CreateCalendarDialog,Wa as CustomRenderingStore,ka as DayflowRangePicker,ma as DefaultColorPicker,Ma as DefaultEventDetailDialog,yo as DefaultEventDetailPanel,ro as EventContextMenu,no as GridContextMenu,O as LAYOUT_CONFIG,T as LOCALES,zr as Loader2,va as LoadingButton,Un as LocaleContext,ra as LocaleProvider,Ia as MiniCalendar,Vr as PanelRightClose,Gr as PanelRightOpen,Pr as Plus,He as TIME_STEP,A as TimeZone,R as VIRTUAL_MONTH_SCROLL_CONFIG,I as ViewType,H as WeekDataCache,V as addDays,_t as buildParseRegExp,st as calculateDayIndex,vr as calendarPickerDropdown,Gn as cancelButton,Qr as capitalize,bn as clipboardStore,jn as compareAllDayDisplayPriority,It as compareViews,tn as conditionalTheme,gn as convertDateEvent,mn as convertDateEventWithTimeZone,On as convertToDayFlowEvent,Yn as createAllDayDisplayComparator,un as createAllDayEvent,Et as createConfigSyncSnapshot,X as createDateWithHour,Di as createDayView,ln as createEvent,lt as createEventWithDate,vt as createEventWithPlainDateTime,gt as createEventWithRealDate,ft as createEventWithZonedDateTime,dn as createEvents,al as createEventsPlugin,ji as createMonthView,Mt as createNormalizedCalendarAppConfigGetter,tl as createStandardViews,F as createTemporalWithHour,hn as createTimedEvent,sn as createTimezoneEvent,cn as createTimezoneEvents,Ni as createWeekView,el as createYearView,Ee as dateToPlainDate,Ce as dateToPlainDateTime,ke as dateToZonedDateTime,_ as daysBetween,B as daysDifference,An as downloadICS,k as en,Cn as escapeICSValue,q as extractHourFromDate,Se as extractHourFromTemporal,Nn as extractVEvents,Tn as foldLine,Ft as formatDate,jt as formatDateConsistent,En as formatDateToICSTimestamp,Le as formatEventTimeRange,xn as formatICSDate,Yt as formatMonthYear,Mn as formatProperty,Kt as formatTemporal,Ae as formatTime,Xe as generateDayData,Hn as generateICS,je as generateSecondaryTimeSlots,Dt as generateUniKey,Sn as generateVEvent,Qe as generateWeekData,tt as generateWeekRange,et as generateWeeksData,rt as getAllDayEventsForDay,Ln as getAllDayRangeMetrics,se as getCalendarColorsForHex,Ct as getCallbackConfigUpdate,qe as getCurrentWeekDates,at as getDateByDayIndex,vn as getDateObj,ut as getDayIndexByDate,Q as getEndOfDay,W as getEndOfTemporal,de as getEventBgColor,Pe as getEventEndHour,ce as getEventTextColor,nt as getEventsForDay,ht as getEventsForWeek,Jr as getIntlLabel,he as getLineColor,ta as getMonthLabels,Je as getMonthYearOfWeek,ze as getNextHourRangeInTimeZone,Fe as getNowInTimeZone,Ie as getPlainDate,pn as getSearchHeaderInfo,ue as getSelectedBgColor,J as getStartOfDay,U as getStartOfTemporal,kt as getSyncConfigUpdates,bt as getTestEvents,Ye as getTimezoneDisplayLabel,Ze as getTodayInTimeZone,ea as getWeekDaysLabels,ee as getWeekNumber,Ke as getWeekRange,Vt as getZoneId,yn as groupSearchResults,yt as hasEventChanged,Pn as importICSFile,L as isDate,wt as isDeepEqual,pt as isEventDeepEqual,dt as isEventInWeek,ne as isMultiDayEvent,z as isMultiDayTemporalEvent,pe as isPlainDate,ye as isPlainDateTime,te as isSameDay,Z as isSamePlainDate,Oe as isSameTemporal,N as isValidLocale,be as isZonedDateTime,nn as mergeClasses,Ut as mergeFormatTemplate,Ve as monthNames,qt as normalizeCssWidth,fn as normalizeDate,S as normalizeLocale,fe as normalizeTimeZoneValue,Gt as normalizeToZoned,G as now,zt as pad,Dn as pad2,Rn as parseICS,wn as parseICSDate,Bt as parseTemporalString,In as parseVEventLines,xt as pickSyncableConfig,Te as plainDateTimeToDate,Me as plainDateToDate,ct as recalculateEventDays,gi as registerDragImplementation,M as registerLocale,Ya as registerSidebarImplementation,rn as resolveAppliedTheme,Fn as restoreTimedDragFromAllDayTransition,We as restoreVisualEventToCanonical,Ue as restoreVisualTimedTemporalToCanonical,$e as roundToTimeStep,Jt as scrollbarTakesSpace,Ne as setHourInTemporal,Ge as shortMonthNames,yr as sidebarContainer,br as sidebarHeader,wr as sidebarHeaderTitle,Dr as sidebarHeaderToggle,$n as sortAllDayByTitle,Ba as subscribeCalendar,Tt as syncCalendarAppConfig,na as t,De as temporalToDate,we as temporalToVisualDate,xe as temporalToVisualTemporal,en as themeClasses,Qt as themeCn,K as today,kn as unescapeICSValue,ot as updateEventDateAndDay,mt as updateEventWithRealDate,vi as useDragForView,Wn as useLocale,Za as useSidebarBridge,_e as weekDays,Be as weekDaysFullName,j as zonedDateTimeToDate};
|