@dayflow/core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=require("react"),n=require("react/jsx-runtime"),r=require("lucide-react"),a=require("react-dom"),o=require("react-dom/client");exports.ViewType=void 0,(e=exports.ViewType||(exports.ViewType={})).DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year";const s=100,i=8,l=150,c=80,d=90,u=119;class h{constructor(e=s){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const g=[{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 f{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)}):g.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)}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}))})}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=this.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}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let m=new f;function v(){return m}const y=new class{constructor(){this.isDevelopment="production"!==process.env.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)}};function p(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const x="240px";class b{constructor(e){var n,r,a,o;this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e)},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate)},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const r=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===r.getFullYear()&&this.visibleMonth.getMonth()===r.getMonth()||(this.visibleMonth=r,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)))},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.addEvent=e=>{var t,n;this.state.events=[...this.state.events,e],null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e)},this.updateEvent=(e,t,n)=>{var r,a;const o=this.state.events.findIndex(t=>t.id===e);if(-1===o)throw new Error(`Event with id ${e} not found`);const s=Object.assign(Object.assign({},this.state.events[o]),t);this.state.events=[...this.state.events.slice(0,o),s,...this.state.events.slice(o+1)],n||null===(a=(r=this.callbacks).onEventUpdate)||void 0===a||a.call(r,s)},this.deleteEvent=e=>{var t,n;const r=this.state.events.findIndex(t=>t.id===e);if(-1===r)throw new Error(`Event with id ${e} not found`);this.state.events=[...this.state.events.slice(0,r),...this.state.events.slice(r+1)],null===(n=(t=this.callbacks).onEventDelete)||void 0===n||n.call(t,e)},this.getAllEvents=()=>[...this.state.events],this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.setCalendarVisibility=(e,t)=>{var n,r;this.calendarRegistry.setVisibility(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n)},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getSidebarConfig=()=>this.sidebarConfig,this.installPlugin=e=>{this.state.plugins.has(e.name)?y.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.render=()=>t.createElement("div",{className:"calendar-app"},"Calendar App"),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t))},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e)},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:e.defaultView||exports.ViewType.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.calendarRegistry=new f(e.calendars,e.defaultCalendar,(null===(n=e.theme)||void 0===n?void 0:n.mode)||"light"),o=this.calendarRegistry,m=o,this.sidebarConfig=(e=>{if(!e)return{enabled:!1,width:x,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:x,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:r=!1,render:a}=e;return{enabled:t,width:p(n,x),initialCollapsed:r,render:a}})(e.useSidebar),this.state.sidebar=this.sidebarConfig;const s=this.state.currentDate;this.visibleMonth=new Date(s.getFullYear(),s.getMonth(),1),this.useEventDetailDialog=null!==(r=e.useEventDetailDialog)&&void 0!==r&&r,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(a=e.plugins)||void 0===a||a.forEach(e=>{this.installPlugin(e)})}}const D="p-2 flex justify-between",w="text-2xl font-semibold text-gray-900 dark:text-gray-100",C="relative overflow-y-auto calendar-content",E="w-20 flex-shrink-0 border-gray-200 dark:border-gray-700",M="relative h-[4.5rem] flex",k="absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400",T="h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",j="absolute left-0 top-0 flex pointer-events-none",S="ml-2 text-white text-xs font-bold px-1.5 bg-red-500 rounded-sm",N="flex items-center border-b border-gray-200 dark:border-gray-700 sticky",I="w-20 flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end",H="calendar-event select-none pointer-events-auto px-0.5",O="rounded-xl my-0.5",R="font-medium text-xs truncate pr-1",P="absolute left-1 top-1 bottom-1 w-[3px] rounded-full",$="h-3 w-3 mr-1",Y="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",L="grid grid-cols-7 gap-1 text-xs justify-items-center",V="text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6",A="text-center py-1 rounded text-xs h-6 w-6",Z="text-gray-900 dark:text-gray-100",F="text-gray-400 dark:text-gray-600",z="bg-blue-500 rounded-full text-white",B="bg-red-100 text-red-600 rounded-full font-medium",W="text-gray-600 dark:text-gray-300",U="text-xs",q="text-sm",_="flex flex-col",G="mr-1";function X(e,t,n,r,a){return J(t,((e,t)=>{const n=e[t];if(void 0===n)throw new TypeError(po(t));return n})(e,t),n,r,a)}function J(e,t,n,r,a,o){const s=ye(t,n,r);if(a&&t!==s)throw new RangeError(vo(e,t,n,r,o));return s}function K(e){return null!==e&&/object|function/.test(typeof e)}function Q(e,t=Map){const n=new t;return(t,...r)=>{if(n.has(t))return n.get(t);const a=e(t,...r);return n.set(t,a),a}}function ee(e){return te({name:e},1)}function te(e,t){return oe(e=>({value:e,configurable:1,writable:!t}),e)}function ne(e){return oe(e=>({get:e,configurable:1}),e)}function re(e){return{[Symbol.toStringTag]:{value:e,configurable:1}}}function ae(e,t){const n={};let r=e.length;for(const a of t)n[e[--r]]=a;return n}function oe(e,t,n){const r={};for(const a in t)r[a]=e(t[a],a,n);return r}function se(e,t,n){const r={};for(let a=0;a<t.length;a++){const o=t[a];r[o]=e(o,a,n)}return r}function ie(e,t,n){const r={};for(let a=0;a<e.length;a++)r[t[a]]=n[e[a]];return r}function le(e,t){const n=Object.create(null);for(const r of e)n[r]=t[r];return n}function ce(e,t){for(const n of t)if(n in e)return 1;return 0}function de(e,t,n){for(const r of e)if(t[r]!==n[r])return 0;return 1}function ue(e,t,n){const r={...n};for(let n=0;n<t;n++)r[e[n]]=0;return r}function he(e,...t){return(...n)=>e(...t,...n)}function ge(e){return e[0].toUpperCase()+e.substring(1)}function fe(e){return e.slice().sort()}function me(e,t){return String(t).padStart(e,"0")}function ve(e,t){return Math.sign(e-t)}function ye(e,t,n){return Math.min(Math.max(e,t),n)}function pe(e,t){return[Math.floor(e/t),xe(e,t)]}function xe(e,t){return(e%t+t)%t}function be(e,t){return[De(e,t),we(e,t)]}function De(e,t){return Math.trunc(e/t)||0}function we(e,t){return e%t||0}function Ce(e){return.5===Math.abs(e%1)}function Ee(e,t,n){let r=0,a=0;for(let o=0;o<=t;o++){const t=e[n[o]],s=gs[o],i=hs/s,[l,c]=be(t,i);r+=c*s,a+=l}const[o,s]=be(r,hs);return[a+o,s]}function Me(e,t,n){const r={};for(let a=t;a>=0;a--){const t=gs[a];r[n[a]]=De(e,t),e=we(e,t)}return r}function ke(e){if(void 0!==e)return je(e)}function Te(e){return Oe(je(e))}function je(e){return He(As(e))}function Se(e,t){if(null==t)throw new RangeError(po(e));return t}function Ne(e){if(!K(e))throw new TypeError(mo);return e}function Ie(e,t,n=e){if(typeof t!==e)throw new TypeError(yo(n,t));return t}function He(e,t="number"){if(!Number.isInteger(e))throw new RangeError(lo(t,e));return e||0}function Oe(e,t="number"){if(e<=0)throw new RangeError(co(t,e));return e}function Re(e){if("symbol"==typeof e)throw new TypeError(fo);return String(e)}function Pe(e,t){return K(e)?String(e):Ls(e,t)}function $e(e){if("string"==typeof e)return BigInt(e);if("bigint"!=typeof e)throw new TypeError(go(e));return e}function Ye(e,t="number"){if("bigint"==typeof e)throw new TypeError(ho(t));if(e=Number(e),!Number.isFinite(e))throw new RangeError(uo(t,e));return e}function Le(e,t){return Math.trunc(Ye(e,t))||0}function Ve(e,t){return He(Ye(e,t),t)}function Ae(e,t){return Oe(Le(e,t),t)}function Ze(e,t){let[n,r]=be(t,hs),a=e+n;const o=Math.sign(a);return o&&o===-Math.sign(r)&&(a-=o,r+=o*hs),[a,r]}function Fe(e,t,n=1){return Ze(e[0]+t[0]*n,e[1]+t[1]*n)}function ze(e,t){return Ze(e[0],e[1]+t)}function Be(e,t){return Fe(t,e,-1)}function We(e,t){return ve(e[0],t[0])||ve(e[1],t[1])}function Ue(e,t,n){return-1===We(e,t)||1===We(e,n)}function qe(e,t=1){const n=BigInt(hs/t);return[Number(e/n),Number(e%n)*t]}function _e(e,t=1){const n=hs/t,[r,a]=be(e,n);return[r,a*t]}function Ge(e,t=1,n){const[r,a]=e,[o,s]=be(a,t);return r*(hs/t)+(o+(n?s/t:0))}function Xe(e,t,n=pe){const[r,a]=e,[o,s]=n(a,t);return[r*(hs/t)+o,s]}function Je(e){return X(e,"isoYear",ci,li,1),e.isoYear===ci?X(e,"isoMonth",4,12,1):e.isoYear===li&&X(e,"isoMonth",1,9,1),e}function Ke(e){return Qe({...e,...ni,isoHour:12}),e}function Qe(e){const t=X(e,"isoYear",ci,li,1),n=t===ci?1:t===li?-1:0;return n&&et(ot({...e,isoDay:e.isoDay+n,isoNanosecond:e.isoNanosecond-n})),e}function et(e){if(!e||Ue(e,ii,si))throw new RangeError(zo);return e}function tt(e){return Ee(e,5,Xs)[1]}function nt(e){const[t,n]=pe(e,hs);return[Me(n,5,Xs),t]}function rt(e){return Xe(e,cs)}function at(e){return lt(e.isoYear,e.isoMonth,e.isoDay,e.isoHour,e.isoMinute,e.isoSecond,e.isoMillisecond)}function ot(e){const t=at(e);if(void 0!==t){const[n,r]=be(t,os);return[n,r*ls+(e.isoMicrosecond||0)*is+(e.isoNanosecond||0)]}}function st(e,t){const[n,r]=nt(tt(e)-t);return et(ot({...e,isoDay:e.isoDay+r,...n}))}function it(...e){return lt(...e)/ss}function lt(...e){const[t,n]=ct(...e),r=t.valueOf();if(!isNaN(r))return r-n*os}function ct(e,t=1,n=1,r=0,a=0,o=0,s=0){const i=e===ci?1:e===li?-1:0,l=new Date;return l.setUTCHours(r,a,o,s),l.setUTCFullYear(e,t-1,n+i),[l,i]}function dt(e,t){let[n,r]=ze(e,t);r<0&&(r+=hs,n-=1);const[a,o]=pe(r,ls),[s,i]=pe(o,is);return ut(n*os+a,s,i)}function ut(e,t=0,n=0){const r=Math.ceil(Math.max(0,Math.abs(e)-oi)/os)*Math.sign(e),a=new Date(e-r*os);return ae(Ks,[a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate()+r,a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds(),t,n])}function ht(e,t){if(t<-oi)throw new RangeError(zo);const n=e.formatToParts(t),r={};for(const e of n)r[e.type]=e.value;return r}function gt(e){return[e.isoYear,e.isoMonth,e.isoDay]}function ft(e,t){return[t,0]}function mt(){return fi}function vt(e,t){switch(t){case 2:return pt(e)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function yt(e){return pt(e)?366:365}function pt(e){return e%4==0&&(e%100!=0||e%400==0)}function xt(e){const[t,n]=ct(e.isoYear,e.isoMonth,e.isoDay);return xe(t.getUTCDay()-n,7)||7}function bt(e){return this.id===Os?(({isoYear:e})=>e<1?["gregory-inverse",1-e]:["gregory",e])(e):this.id===Rs?vi(e):[]}function Dt(e){const t=at(e);if(t<mi){const{isoYear:t}=e;return t<1?["japanese-inverse",1-t]:["japanese",t]}const n=ht(Tl(Rs),t),{era:r,eraYear:a}=ka(n,Rs);return[r,a]}function wt(e){return Ct(e),kt(e,1),e}function Ct(e){return Mt(e,1),e}function Et(e){return de(Js,e,Mt(e))}function Mt(e,t){const{isoYear:n}=e,r=X(e,"isoMonth",1,mt(),t);return{isoYear:n,isoMonth:r,isoDay:X(e,"isoDay",1,vt(n,r),t)}}function kt(e,t){return ae(Xs,[X(e,"isoHour",0,23,t),X(e,"isoMinute",0,59,t),X(e,"isoSecond",0,59,t),X(e,"isoMillisecond",0,999,t),X(e,"isoMicrosecond",0,999,t),X(e,"isoNanosecond",0,999,t)])}function Tt(e){return void 0===e?0:Pi(Ne(e))}function jt(e,t=0){e=Lt(e);const n=$i(e),r=Yi(e,t);return[Pi(e),r,n]}function St(e,t,n,r=9,a=0,o=4){t=Lt(t);let s=Oi(t,r,a),i=Pt(t),l=Zi(t,o);const c=Hi(t,r,a,1);return null==s?s=Math.max(n,c):zt(s,c),i=$t(i,c,1),e&&(l=(e=>e<4?(e+2)%4:e)(l)),[s,c,i,l]}function Nt(e,t=6,n){let r=Pt(e=Vt(e,yi));const a=Zi(e,7);let o=Hi(e,t);return o=Se(yi,o),r=$t(r,o,void 0,n),[o,r,a]}function It(e){return Li(Lt(e))}function Ht(e,t){return Ot(Lt(e),t)}function Ot(e,t=4){const n=Yt(e);return[Zi(e,4),...Rt(Hi(e,t),n)]}function Rt(e,t){return null!=e?[gs[e],e<4?9-3*e:-1]:[void 0===t?1:10**(9-t),t]}function Pt(e){const t=e[xi];return void 0===t?1:Le(t,xi)}function $t(e,t,n,r){const a=r?hs:gs[t+1];if(a){const n=gs[t];if(a%((e=J(xi,e,1,a/n-(r?0:1),1))*n))throw new RangeError(yo(xi,e))}else e=J(xi,e,1,n?10**9:1,1);return e}function Yt(e){let t=e[bi];if(void 0!==t){if("number"!=typeof t){if("auto"===Re(t))return;throw new RangeError(yo(bi,t))}t=J(bi,Math.floor(t),0,9,1)}return t}function Lt(e){return void 0===e?{}:Ne(e)}function Vt(e,t){return"string"==typeof e?{[t]:e}:Ne(e)}function At(e){return{overflow:Ei[e]}}function Zt(e,t,n=9,r=0,a){let o=t[e];if(void 0===o)return a?r:void 0;if(o=Re(o),"auto"===o)return a?r:null;let s=rs[o];if(void 0===s&&(s=Us[o]),void 0===s)throw new RangeError(wo(e,o,rs));return J(e,s,r,n,1,as),s}function Ft(e,t,n,r=0){const a=n[e];if(void 0===a)return r;const o=Re(a),s=t[o];if(void 0===s)throw new RangeError(wo(e,o,t));return s}function zt(e,t){if(t>e)throw new RangeError(Go)}function Bt(e){return{branding:_i,epochNanoseconds:e}}function Wt(e,t,n){return{branding:qi,calendar:n,timeZone:t,epochNanoseconds:e}}function Ut(e,t=e.calendar){return{branding:Wi,calendar:t,...le(ti,e)}}function qt(e,t=e.calendar){return{branding:Bi,calendar:t,...le(Qs,e)}}function _t(e,t=e.calendar){return{branding:Fi,calendar:t,...le(Qs,e)}}function Gt(e,t=e.calendar){return{branding:zi,calendar:t,...le(Qs,e)}}function Xt(e){return{branding:Ui,...le(ei,e)}}function Jt(e){return{branding:Gi,sign:hr(e),...le(Fs,e)}}function Kt(e){return Xe(e.epochNanoseconds,ls)[0]}function Qt(e){return e.epochNanoseconds}function en(e,t){return Ge(mr(e),gs[t],1)}function tn(e,t,n,r,a,o,s){const i=Zs[n],l={...t,[i]:t[i]+r},c=s(e,a,t),d=s(e,a,l);return[o(c),o(d)]}function nn(e,t,n){const r=Ge(Be(t,n));if(!r)throw new RangeError(Oo);return Ge(Be(t,e))/r}function rn(e,t,n,r){return an(e,ln(t,n),r)}function an(e,t,n){const[r,a]=on(e,t,n);return Qe({...nr(e,a),...r})}function on(e,t,n){return nt(mn(tt(e),t,n))}function sn(e){return mn(e,ds,7)}function ln(e,t){return gs[e]*t}function cn(e){const t=dn(e);return[t,nr(t,1)]}function dn(e){return ri(6,e)}function un(e,t,n){const r=Math.min(xr(e),6);return vr(fn(mr(e,r),t,n),r)}function hn(e,t,n,r,a,o,s,i,l,c){if(0===r&&1===a)return e;const d=lr(r,i)?ir(i)&&r<6&&n>=6?pn:yn:xn;let[u,h,g]=d(e,t,n,r,a,o,s,i,l,c);return g&&7!==r&&(u=((e,t,n,r,a,o,s,i)=>{const l=hr(e);for(let c=r+1;c<=n;c++){if(7===c&&7!==n)continue;const r=Gs(c,e);r[Zs[c]]+=l;const d=Ge(Be(s(i(a,o,r)),t));if(d&&Math.sign(d)!==l)break;e=r}return e})(u,h,n,Math.max(6,r),s,i,l,c)),u}function gn(e,t,n,r,a){if(6===t){const t=(e=>e[0]+e[1]/hs)(e);return[mn(t,n,r),0]}return fn(e,ln(t,n),r,a)}function fn(e,t,n,r){let[a,o]=e;r&&o<0&&(o+=hs,a-=1);const[s,i]=pe(mn(o,t,n),hs);return Ze(a+s,i)}function mn(e,t,n){return vn(e/t,n)*t}function vn(e,t){return Xi[t](e)}function yn(e,t,n,r,a,o){const s=hr(e),i=mr(e),l=gn(i,r,a,o),c=Be(i,l),d=Math.sign(l[0]-i[0])===s,u=vr(l,Math.min(n,6));return[{...e,...u},Fe(t,c),d]}function pn(e,t,n,r,a,o,s,i,l,c){const d=hr(e)||1,u=Ge(mr(e,5)),h=ln(r,a);let g=mn(u,h,o);const[f,m]=tn(s,{...e,..._s},6,d,i,l,c),v=g-Ge(Be(f,m));let y=0;v&&Math.sign(v)!==d?t=ze(f,g):(y+=d,g=mn(v,h,o),t=ze(m,g));const p=yr(g);return[{...e,...p,days:e.days+y},t,Boolean(y)]}function xn(e,t,n,r,a,o,s,i,l,c){const d=hr(e),u=Zs[r],h=Gs(r,e);7===r&&(e={...e,weeks:e.weeks+Math.trunc(e.days/7)});const g=De(e[u],a)*a;h[u]=g;const[f,m]=tn(s,h,r,a*d,i,l,c),v=g+nn(t,f,m)*d*a,y=mn(v,a,o),p=Math.sign(y-v)===d;return h[u]=y,[h,p?m:f,p]}function bn(e,t,n,r){const[a,o,s,i]=(e=>{const t=Ot(e=Lt(e));return[e.timeZone,...t]})(r),l=void 0!==a;return((e,t,n,r,a,o)=>{n=fn(n,a,r,1);const s=t.R(n);return Nn(dt(n,s),o)+(e?Pn(sn(s)):"Z")})(l,t(l?e(a):Ji),n.epochNanoseconds,o,s,i)}function Dn(e,t,n){const[r,a,o,s,i,l]=(e=>{e=Lt(e);const t=Li(e),n=Yt(e),r=Ai(e),a=Zi(e,4),o=Hi(e,4);return[t,Vi(e),r,a,...Rt(o,n)]})(n);return((e,t,n,r,a,o,s,i,l,c)=>{r=fn(r,l,i,1);const d=e(n).R(r);return Nn(dt(r,d),c)+Pn(sn(d),s)+((e,t)=>1!==t?"["+(2===t?"!":"")+e+"]":"")(n,o)+$n(t,a)})(e,t.calendar,t.timeZone,t.epochNanoseconds,r,a,o,s,i,l)}function wn(e,t){const[n,r,a,o]=(e=>(e=Lt(e),[Li(e),...Ot(e)]))(t);return s=e.calendar,i=n,l=o,Nn(an(e,a,r),l)+$n(s,i);var s,i,l}function Cn(e,t){return n=e.calendar,r=e,a=It(t),In(r)+$n(n,a);var n,r,a}function En(e,t){return jn(e.calendar,Hn,e,It(t))}function Mn(e,t){return jn(e.calendar,On,e,It(t))}function kn(e,t){const[n,r,a]=Ht(t);return o=a,Rn(on(e,r,n)[0],o);var o}function Tn(e,t){const[n,r,a]=Ht(t,3);return r>1&&gr(e={...e,...un(e,r,n)}),((e,t)=>{const{sign:n}=e,r=-1===n?ur(e):e,{hours:a,minutes:o}=r,[s,i]=Xe(mr(r,3),cs,be);fr(s);const l=Ln(i,t),c=t>=0||!n||l;return(n<0?"-":"")+"P"+Sn({Y:An(r.years),M:An(r.months),W:An(r.weeks),D:An(r.days)})+(a||o||s||c?"T"+Sn({H:An(a),M:An(o),S:An(s,c)+l}):"")})(e,a)}function jn(e,t,n,r){const a=r>1||0===r&&e!==Hs;return 1===r?e===Hs?t(n):In(n):a?In(n)+Yn(e,2===r):t(n)}function Sn(e){const t=[];for(const n in e){const r=e[n];r&&t.push(r,n)}return t.join("")}function Nn(e,t){return In(e)+"T"+Rn(e,t)}function In(e){return Hn(e)+"-"+ns(e.isoDay)}function Hn(e){const{isoYear:t}=e;return(t<0||t>9999?Vn(t)+me(6,Math.abs(t)):me(4,t))+"-"+ns(e.isoMonth)}function On(e){return ns(e.isoMonth)+"-"+ns(e.isoDay)}function Rn(e,t){const n=[ns(e.isoHour),ns(e.isoMinute)];return-1!==t&&n.push(ns(e.isoSecond)+((e,t,n,r)=>Ln(e*ls+t*is+n,r))(e.isoMillisecond,e.isoMicrosecond,e.isoNanosecond,t)),n.join(":")}function Pn(e,t=0){if(1===t)return"";const[n,r]=pe(Math.abs(e),us),[a,o]=pe(r,ds),[s,i]=pe(o,cs);return Vn(e)+ns(n)+":"+ns(a)+(s||i?":"+ns(s)+Ln(i):"")}function $n(e,t){return 1!==t&&(t>1||0===t&&e!==Hs)?Yn(e,2===t):""}function Yn(e,t){return"["+(t?"!":"")+"u-ca="+e+"]"}function Ln(e,t){let n=me(9,e);return n=void 0===t?n.replace(tl,""):n.slice(0,t),n?"."+n:""}function Vn(e){return e<0?"-":"+"}function An(e,t){return e||t?e.toLocaleString("fullwide",{useGrouping:0}):""}function Zn(e,t){const{epochNanoseconds:n}=e,r=(t.R?t:t(e.timeZone)).R(n),a=dt(n,r);return{calendar:e.calendar,...a,offsetNanoseconds:r}}function Fn(e,t,n,r=0,a=0,o,s){if(void 0!==n&&1===r&&(1===r||s))return st(t,n);const i=e.I(t);if(void 0!==n&&3!==r){const e=((e,t,n,r)=>{const a=ot(t);r&&(n=sn(n));for(const t of e){let e=Ge(Be(t,a));if(r&&(e=sn(e)),e===n)return t}})(i,t,n,o);if(void 0!==e)return e;if(0===r)throw new RangeError(Zo)}return s?ot(t):zn(e,t,a,i)}function zn(e,t,n=0,r=e.I(t)){if(1===r.length)return r[0];if(1===n)throw new RangeError(Fo);if(r.length)return r[3===n?1:0];const a=ot(t),o=((e,t)=>{const n=e.R(ze(t,-hs));return(e=>{if(e>hs)throw new RangeError(Ao);return e})(e.R(ze(t,hs))-n)})(e,a),s=o*(2===n?-1:1);return(r=e.I(dt(a,s)))[2===n?0:r.length-1]}function Bn(e,t){const n=e.I(t);if(n.length)return n[0];const r=ze(ot(t),-hs);return e.O(r,1)}function Wn(e,t,n){return Bt(et(Fe(t.epochNanoseconds,(e=>{if(pr(e))throw new RangeError(qo);return mr(e,5)})(e?ur(n):n))))}function Un(e,t,n,r,a,o=Object.create(null)){const s=t(r.timeZone),i=e(r.calendar);return{...r,...Jn(s,i,r,n?ur(a):a,o)}}function qn(e,t,n,r,a=Object.create(null)){const{calendar:o}=n;return Ut(Kn(e(o),n,t?ur(r):r,a),o)}function _n(e,t,n,r,a){const{calendar:o}=n;return qt(Qn(e(o),n,t?ur(r):r,a),o)}function Gn(e,t,n,r,a){const o=n.calendar,s=e(o);let i=Ke(er(s,n));t&&(r=dr(r)),r.sign<0&&(i=s.P(i,{...qs,months:1}),i=nr(i,-1));const l=s.P(i,r,a);return _t(er(s,l),o)}function Xn(e,t,n){return Xt(tr(t,e?ur(n):n)[0])}function Jn(e,t,n,r,a){const o=mr(r,5);let s=n.epochNanoseconds;if(pr(r)){const i=nl(n,e);s=Fe(zn(e,{...Qn(t,i,{...r,..._s},a),...le(Xs,i)}),o)}else s=Fe(s,o),Tt(a);return{epochNanoseconds:et(s)}}function Kn(e,t,n,r){const[a,o]=tr(t,n);return Qe({...Qn(e,t,{...n,..._s,days:n.days+o},r),...a})}function Qn(e,t,n,r){if(n.years||n.months||n.weeks)return e.P(t,n,r);Tt(r);const a=n.days+mr(n,5)[0];return a?Ke(nr(t,a)):t}function er(e,t,n=1){return nr(t,n-e.day(t))}function tr(e,t){const[n,r]=mr(t,5),[a,o]=nt(tt(e)+r);return[a,n+o]}function nr(e,t){return t?{...e,...ut(at(e)+t*os)}:e}function rr(e,t,n){const r=e(n.calendar);return ir(n)?[n,r,t(n.timeZone)]:[{...n,...ni},r]}function ar(e){return e?Qt:ot}function or(e){return e?he(Jn,e):Kn}function sr(e){return e?he(na,e):ra}function ir(e){return e&&e.epochNanoseconds}function lr(e,t){return e<=6-(ir(t)?1:0)}function cr(e,t,n,r,a,o,s){const i=e(Lt(s).relativeTo),l=Math.max(xr(a),xr(o));if(lr(l,i))return Jt(gr(((e,t,n,r)=>{const a=Fe(mr(e),mr(t),r?-1:1);if(!Number.isFinite(a[0]))throw new RangeError(zo);return{...qs,...vr(a,n)}})(a,o,l,r)));if(!i)throw new RangeError(Uo);r&&(o=ur(o));const[c,d,u]=rr(t,n,i),h=or(u),g=sr(u),f=h(d,c,a);return Jt(g(d,c,h(d,f,o),l))}function dr(e){return Jt(ur(e))}function ur(e){const t={};for(const n of Zs)t[n]=-1*e[n]||0;return t}function hr(e,t=Zs){let n=0;for(const r of t){const t=Math.sign(e[r]);if(t){if(n&&n!==t)throw new RangeError(Wo);n=t}}return n}function gr(e){for(const t of Ws)J(t,e[t],-rl,rl,1);return fr(Ge(mr(e),cs)),e}function fr(e){if(!Number.isSafeInteger(e))throw new RangeError(Bo)}function mr(e,t=6){return Ee(e,t,Zs)}function vr(e,t=6){const[n,r]=e,a=Me(r,t,Zs);if(a[Zs[t]]+=n*(hs/gs[t]),!Number.isFinite(a[Zs[t]]))throw new RangeError(zo);return a}function yr(e,t=5){return Me(e,t,Zs)}function pr(e){return Boolean(hr(e,Bs))}function xr(e){let t=9;for(;t>0&&!e[Zs[t]];t--);return t}function br(e,t){return[e,t]}function Dr(e){const t=Math.floor(e/Ki)*Ki;return[t,t+Ki]}function wr(e){const t=Hr(e);if(void 0===t)throw new RangeError(Xo(e));return t}function Cr(e,t,n){let r=Sr(Ls(e));if(!r||r.j)throw new RangeError(Xo(e));return t?r.calendar===Hs&&(r=-271821===r.isoYear&&4===r.isoMonth?{...r,isoDay:20,...ni}:{...r,isoDay:1,...ni}):n&&r.calendar===Hs&&(r={...r,isoYear:gi}),qt(r.C?kr(r):Tr(r))}function Er(e){if(e.calendar!==Hs)throw new RangeError(Jo(e.calendar))}function Mr(e,t,n=0,r=0){const a=Ar(e.timeZone),o=al(a);let s;return wt(e),s=e.C?Fn(o,e,t,n,r,!o.$,e.j):Bn(o,e),Wt(s,a,La(e.calendar))}function kr(e){return jr(Qe(wt(e)))}function Tr(e){return jr(Ke(Ct(e)))}function jr(e){return{...e,calendar:La(e.calendar)}}function Sr(e){const t=yl.exec(e);return t?(e=>{const t=e[10],n="Z"===(t||"").toUpperCase();return{isoYear:Or(e),isoMonth:parseInt(e[4]),isoDay:parseInt(e[5]),...Rr(e.slice(5)),...Pr(e[16]),C:Boolean(e[6]),j:n,offset:n?void 0:t}})(t):void 0}function Nr(e){const t=ml.exec(e);return t?(e=>({isoYear:Or(e),isoMonth:parseInt(e[4]),isoDay:1,...Pr(e[5])}))(t):void 0}function Ir(e){const t=vl.exec(e);return t?(e=>({isoYear:gi,isoMonth:parseInt(e[1]),isoDay:parseInt(e[2]),...Pr(e[3])}))(t):void 0}function Hr(e,t){const n=xl.exec(e);return n?((e,t)=>{const n=e[4]||e[5];if(t&&n)throw new RangeError(Jo(n));return(e=>{if(Math.abs(e)>=hs)throw new RangeError(Vo);return e})((Vr(e[2])*us+Vr(e[3])*ds+Vr(e[4])*cs+$r(e[5]||""))*Lr(e[1]))})(n,t):void 0}function Or(e){const t=Lr(e[1]),n=parseInt(e[2]||e[3]);if(t<0&&!n)throw new RangeError(Jo(-0));return t*n}function Rr(e){const t=Vr(e[3]);return{...nt($r(e[4]||""))[0],isoHour:Vr(e[1]),isoMinute:Vr(e[2]),isoSecond:60===t?59:t}}function Pr(e){let t,n;const r=[];if(e.replace(bl,(e,a,o)=>{const s=Boolean(a),[i,l]=o.split("=").reverse();if(l){if("u-ca"===l)r.push(i),t||(t=s);else if(s||/[A-Z]/.test(l))throw new RangeError(Jo(e))}else{if(n)throw new RangeError(Jo(e));n=i}return""}),r.length>1&&t)throw new RangeError(Jo(e));return{timeZone:n,calendar:r[0]||Hs}}function $r(e){return parseInt(e.padEnd(9,"0"))}function Yr(e){return new RegExp(`^${e}$`,"i")}function Lr(e){return e&&"+"!==e?-1:1}function Vr(e){return void 0===e?0:parseInt(e)}function Ar(e){const t=Fr(e);return"number"==typeof t?Pn(t):t?(e=>{if(El.test(e))throw new RangeError($o(e));if(Cl.test(e))throw new RangeError(Lo);return e.toLowerCase().split("/").map((e,t)=>(e.length<=3||/\d/.test(e))&&!/etc|yap/.test(e)?e.toUpperCase():e.replace(/baja|dumont|[a-z]+/g,(e,n)=>e.length<=2&&!t||"in"===e||"chat"===e?e.toUpperCase():e.length>2||!n?ge(e).replace(/island|noronha|murdo|rivadavia|urville/,ge):e)).join("/")})(e):Ji}function Zr(e){const t=Fr(e);return"number"==typeof t?t:t?t.resolvedOptions().timeZone:Ji}function Fr(e){const t=Hr(e=e.toUpperCase(),1);return void 0!==t?t:e!==Ji?wl(e):void 0}function zr(e,t){return We(e.epochNanoseconds,t.epochNanoseconds)}function Br(e,t){return We(e.epochNanoseconds,t.epochNanoseconds)}function Wr(e,t){return Ur(e,t)||qr(e,t)}function Ur(e,t){return ve(at(e),at(t))}function qr(e,t){return ve(tt(e),tt(t))}function _r(e,t){if(e===t)return 1;try{return Zr(e)===Zr(t)}catch(e){}}function Gr(e,t,n,r){const a=St(e,r,3,5),o=sa(t.epochNanoseconds,n.epochNanoseconds,...a);return Jt(e?ur(o):o)}function Xr(e,t,n,r,a,o){const s=ua(r.calendar,a.calendar),[i,l,c,d]=St(n,o,5),u=r.epochNanoseconds,h=a.epochNanoseconds,g=We(h,u);let f;if(g)if(i<6)f=sa(u,h,i,l,c,d);else{const n=t(((e,t)=>{if(!_r(e,t))throw new RangeError(Yo);return e})(r.timeZone,a.timeZone)),u=e(s);f=aa(u,n,r,a,g,i,o),f=hn(f,h,i,l,c,d,u,r,Qt,he(Jn,n))}else f=qs;return Jt(n?ur(f):f)}function Jr(e,t,n,r,a){const o=ua(n.calendar,r.calendar),[s,i,l,c]=St(t,a,6),d=ot(n),u=ot(r),h=We(u,d);let g;if(h)if(s<=6)g=sa(d,u,s,i,l,c);else{const t=e(o);g=oa(t,n,r,h,s,a),g=hn(g,u,s,i,l,c,t,n,ot,Kn)}else g=qs;return Jt(t?ur(g):g)}function Kr(e,t,n,r,a){const o=ua(n.calendar,r.calendar);return ea(t,()=>e(o),n,r,...St(t,a,6,9,6))}function Qr(e,t,n,r,a){const o=ua(n.calendar,r.calendar),s=St(t,a,9,9,8),i=e(o),l=er(i,n),c=er(i,r);return l.isoYear===c.isoYear&&l.isoMonth===c.isoMonth&&l.isoDay===c.isoDay?Jt(qs):ea(t,()=>i,Ke(l),Ke(c),...s,8)}function ea(e,t,n,r,a,o,s,i,l=6){const c=ot(n),d=ot(r);if(void 0===c||void 0===d)throw new RangeError(zo);let u;if(We(d,c))if(6===a)u=sa(c,d,a,o,s,i);else{const e=t();u=e.N(n,r,a),o===l&&1===s||(u=hn(u,d,a,o,s,i,e,n,ot,Qn))}else u=qs;return Jt(e?ur(u):u)}function ta(e,t,n,r){const[a,o,s,i]=St(e,r,5,5),l=mn(da(t,n),ln(o,s),i),c={...qs,...yr(l,a)};return Jt(e?ur(c):c)}function na(e,t,n,r,a,o){const s=We(r.epochNanoseconds,n.epochNanoseconds);return s?a<6?ia(n.epochNanoseconds,r.epochNanoseconds,a):aa(t,e,n,r,s,a,o):qs}function ra(e,t,n,r,a){const o=ot(t),s=ot(n),i=We(s,o);return i?r<=6?ia(o,s,r):oa(e,t,n,i,r,a):qs}function aa(e,t,n,r,a,o,s){const[i,l,c]=((e,t,n,r)=>{function a(){return u={...nr(i,c++*-r),...s},h=zn(e,u),We(l,h)===-r}const o=nl(t,e),s=le(Xs,o),i=nl(n,e),l=n.epochNanoseconds;let c=0;const d=da(o,i);let u,h;if(Math.sign(d)===-r&&c++,a()&&(-1===r||a()))throw new RangeError(Oo);const g=Ge(Be(h,l));return[o,u,g]})(t,n,r,a);var d,u;return{...6===o?(d=i,u=l,{...qs,days:la(d,u)}):e.N(i,l,o,s),...yr(c)}}function oa(e,t,n,r,a,o){const[s,i,l]=((e,t,n)=>{let r=t,a=da(e,t);return Math.sign(a)===-n&&(r=nr(t,-n),a+=hs*n),[e,r,a]})(t,n,r);return{...e.N(s,i,a,o),...yr(l)}}function sa(e,t,n,r,a,o){return{...qs,...vr(gn(Be(e,t),r,a,o),n)}}function ia(e,t,n){return{...qs,...vr(Be(e,t),n)}}function la(e,t){return ca(at(e),at(t))}function ca(e,t){return Math.trunc((t-e)/os)}function da(e,t){return tt(t)-tt(e)}function ua(e,t){if(e!==t)throw new RangeError(Po);return e}function ha(e){return this.m(e)[0]}function ga(e){return this.m(e)[1]}function fa(e){const[t]=this.v(e);return ca(this.p(t),at(e))+1}function ma(e){const t=Ml.exec(e);if(!t)throw new RangeError(So(e));return[parseInt(t[1]),Boolean(t[2])]}function va(e,t){return"M"+ns(e)+(t?"L":"")}function ya(e,t,n){return e+(t||n&&e>=n?1:0)}function pa(e,t){return e-(t&&e>=t?1:0)}function xa(e,t){return(t+e)*(Math.sign(t)||1)||0}function ba(e){return Ps[wa(e)]}function Da(e){return Ys[wa(e)]}function wa(e){return Va(e.id||Hs)}function Ca(e){function t(e){return((e,t)=>({...ka(e,t),o:e.month,day:parseInt(e.day)}))(ht(n,e),r)}const n=Tl(e),r=Va(e);return{id:e,h:Ea(t),l:Ma(t)}}function Ea(e){return Q(t=>{const n=at(t);return e(n)},WeakMap)}function Ma(e){const t=e(0).year-hi;return Q(n=>{let r,a=lt(n-t),o=0;const s=[],i=[];do{a+=400*os}while((r=e(a)).year<=n);do{if(a+=(1-r.day)*os,r.year===n&&(s.push(a),i.push(r.o)),a-=os,++o>100||a<-oi)throw new RangeError(Oo)}while((r=e(a)).year>=n);return{i:s.reverse(),u:es(i.reverse())}})}function ka(e,t){let n,r,a=Ta(e);if(e.era){const o=Ps[t],s=$s[t]||{};void 0!==o&&(n="islamic"===t?"ah":e.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),"bc"===n||"b"===n?n="bce":"ad"===n||"a"===n?n="ce":"beforeroc"===n&&(n="broc"),n=s[n]||n,r=a,a=xa(r,o[n]||0))}return{era:n,eraYear:r,year:a}}function Ta(e){return parseInt(e.relatedYear||e.year)}function ja(e){const{year:t,o:n,day:r}=this.h(e),{u:a}=this.l(t);return[t,a[n]+1,r]}function Sa(e,t=1,n=1){return this.l(e).i[t-1]+(n-1)*os}function Na(e,t){const n=Ia.call(this,e);return[pa(t,n),n===t]}function Ia(e){const t=$a(this,e),n=$a(this,e-1),r=t.length;if(r>n.length){const e=Da(this);if(e<0)return-e;for(let e=0;e<r;e++)if(t[e]!==n[e])return e+1}}function Ha(e){return ca(Sa.call(this,e),Sa.call(this,e+1))}function Oa(e,t){const{i:n}=this.l(e);let r=t+1,a=n;return r>n.length&&(r=1,a=this.l(e+1).i),ca(n[t-1],a[r-1])}function Ra(e){return this.l(e).i.length}function Pa(e){const t=this.h(e);return[t.era,t.eraYear]}function $a(e,t){return Object.keys(e.l(t).u)}function Ya(e){return La(Ls(e))}function La(e){if((e=e.toLowerCase())!==Hs&&e!==Os){const t=Tl(e).resolvedOptions().calendar;if(Va(e)!==Va(t))throw new RangeError(Ro(e));return t}return e}function Va(e){return"islamicc"===e&&(e="islamic"),e.split("-")[0]}function Aa(e,t){return n=>n===Hs?e:n===Os||n===Rs?Object.assign(Object.create(e),{id:n}):Object.assign(Object.create(t),kl(n))}function Za(e,t,n,r){const a=Fa(n,r,js,[],xs);if(void 0!==a.timeZone){const r=n.F(a),o=Ba(a),s=e(a.timeZone);return{epochNanoseconds:Fn(t(s),{...r,...o},void 0!==a.offset?wr(a.offset):void 0),timeZone:s}}return{...n.F(a),...ni}}function Fa(e,t,n,r=[],a=[]){return za(t,[...e.fields(n),...a].sort(),r)}function za(e,t,n,r=!n){const a={};let o,s=0;for(const r of t){if(r===o)throw new RangeError(bo(r));if("constructor"===r||"__proto__"===r)throw new RangeError(xo(r));let t=e[r];if(void 0!==t)s=1,Ll[r]&&(t=Ll[r](t,r)),a[r]=t;else if(n){if(n.includes(r))throw new TypeError(po(r));a[r]=Is[r]}o=r}if(r&&!s)throw new TypeError(Do(t));return a}function Ba(e,t){return kt(Vl({...Is,...e}),t)}function Wa(e,t,n,r,a){t=le(n=e.fields(n),t),r=za(r,a=e.fields(a),[]);let o=e.k(t,r);return o=za(o,[...n,...a].sort(),[]),e.F(o)}function Ua(e,t){const n=ba(e),r=$s[e.id||""]||{};let{era:a,eraYear:o,year:s}=t;if(void 0!==a||void 0!==o){if(void 0===a||void 0===o)throw new TypeError(Mo);if(!n)throw new RangeError(Eo);const e=n[r[a]||a];if(void 0===e)throw new RangeError(To(a));const t=xa(o,e);if(void 0!==s&&s!==t)throw new RangeError(ko);s=t}else if(void 0===s)throw new TypeError(jo(n));return s}function qa(e,t,n,r){let{month:a,monthCode:o}=t;if(void 0!==o){const t=((e,t,n,r)=>{const a=e.L(n),[o,s]=ma(t);let i=ya(o,s,a);if(s){const t=Da(e);if(void 0===t)throw new RangeError(Ho);if(t>0){if(i>t)throw new RangeError(Ho);if(void 0===a){if(1===r)throw new RangeError(Ho);i--}}else{if(i!==-t)throw new RangeError(Ho);if(void 0===a&&1===r)throw new RangeError(Ho)}}return i})(e,o,n,r);if(void 0!==a&&a!==t)throw new RangeError(No);a=t,r=1}else if(void 0===a)throw new TypeError(Io);return J("month",a,1,e.B(n),r)}function _a(e,t,n,r,a){return X(t,"day",1,e.U(r,n),a)}function Ga(e,t,n,r){let a=0;const o=[];for(const e of n)void 0!==t[e]?a=1:o.push(e);if(Object.assign(e,t),a)for(const t of r||o)delete e[t]}function Xa(e){const t=$l(e.calendar),[n,r,a]=t.v(e),[o,s]=t.q(n,r);return{year:n,monthCode:va(o,s),day:a}}function Ja(e,t){return Ut(nl(t,e))}function Ka(e,t){return qt(nl(t,e))}function Qa(e,t){return Xt(nl(t,e))}function eo(e,t,n){const r=new Set(n);return(a,o)=>{const s=n&&ce(a,n);if(!ce(a=((e,t)=>{const n={};for(const r in t)e.has(r)||(n[r]=t[r]);return n})(r,a),e)){if(o&&s)throw new TypeError("Invalid formatting options");a={...t,...a}}return n&&(a.timeZone=Ji,["full","long"].includes(a.J)&&(a.J="medium")),a}}function to(e,t=no,n=0){const[r,,,a]=e;return(o,s=vc,...i)=>{const l=t(a&&a(...i),o,s,r,n),c=l.resolvedOptions();return[l,...ro(e,c,i)]}}function no(e,t,n,r,a){if(n=r(n,a),e){if(void 0!==n.timeZone)throw new TypeError(Qo);n.timeZone=e}return new di(t,n)}function ro(e,t,n){const[,r,a]=e;return n.map(e=>(e.calendar&&((e,t,n)=>{if((n||e!==Hs)&&e!==t)throw new RangeError(Po)})(e.calendar,t.calendar,a),r(e,t)))}function ao(e,t){return{...e,calendar:t}}function oo(e){const t=so();return dt(t,e.R(t))}function so(){return _e(Date.now(),ls)}function io(){return Mc||(Mc=(new di).resolvedOptions().timeZone)}const lo=(e,t)=>`Non-integer ${e}: ${t}`,co=(e,t)=>`Non-positive ${e}: ${t}`,uo=(e,t)=>`Non-finite ${e}: ${t}`,ho=e=>`Cannot convert bigint to ${e}`,go=e=>`Invalid bigint: ${e}`,fo="Cannot convert Symbol to string",mo="Invalid object",vo=(e,t,n,r,a)=>a?vo(e,a[t],a[n],a[r]):yo(e,t)+`; must be between ${n}-${r}`,yo=(e,t)=>`Invalid ${e}: ${t}`,po=e=>`Missing ${e}`,xo=e=>`Invalid field ${e}`,bo=e=>`Duplicate field ${e}`,Do=e=>"No valid fields: "+e.join(),wo=(e,t,n)=>yo(e,t)+"; must be "+Object.keys(n).join(),Co="Invalid calling context",Eo="Forbidden era/eraYear",Mo="Mismatching era/eraYear",ko="Mismatching year/eraYear",To=e=>`Invalid era: ${e}`,jo=e=>"Missing year"+(e?"/era/eraYear":""),So=e=>`Invalid monthCode: ${e}`,No="Mismatching month/monthCode",Io="Missing month/monthCode",Ho="Invalid leap month",Oo="Invalid protocol results",Ro=e=>yo("Calendar",e),Po="Mismatching Calendars",$o=e=>yo("TimeZone",e),Yo="Mismatching TimeZones",Lo="Forbidden ICU TimeZone",Vo="Out-of-bounds offset",Ao="Out-of-bounds TimeZone gap",Zo="Invalid TimeZone offset",Fo="Ambiguous offset",zo="Out-of-bounds date",Bo="Out-of-bounds duration",Wo="Cannot mix duration signs",Uo="Missing relativeTo",qo="Cannot use large units",_o="Required smallestUnit or largestUnit",Go="smallestUnit > largestUnit",Xo=e=>`Cannot parse: ${e}`,Jo=e=>`Invalid substring: ${e}`,Ko="Mismatching types for formatting",Qo="Cannot specify TimeZone",es=he(se,(e,t)=>t),ts=he(se,(e,t,n)=>n),ns=he(me,2),rs={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},as=Object.keys(rs),os=864e5,ss=1e3,is=1e3,ls=1e6,cs=1e9,ds=6e10,us=36e11,hs=864e11,gs=[1,is,ls,cs,ds,us,hs],fs=as.slice(0,6),ms=fe(fs),vs=["offset"],ys=["timeZone"],ps=fs.concat(vs),xs=ps.concat(ys),bs=["era","eraYear"],Ds=bs.concat(["year"]),ws=["year"],Cs=["monthCode"],Es=["month"].concat(Cs),Ms=["day"],ks=Es.concat(ws),Ts=Cs.concat(ws),js=Ms.concat(ks),Ss=Ms.concat(Es),Ns=Ms.concat(Cs),Is=ts(fs,0),Hs="iso8601",Os="gregory",Rs="japanese",Ps={[Os]:{"gregory-inverse":-1,gregory:0},[Rs]:{"japanese-inverse":-1,japanese:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethiopic:{ethioaa:0,ethiopic:5500},coptic:{"coptic-inverse":-1,coptic:0},roc:{"roc-inverse":-1,roc:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},$s={[Os]:{bce:"gregory-inverse",ce:"gregory"},[Rs]:{bce:"japanese-inverse",ce:"japanese"},ethiopic:{era0:"ethioaa",era1:"ethiopic"},coptic:{era0:"coptic-inverse",era1:"coptic"},roc:{broc:"roc-inverse",minguo:"roc"}},Ys={chinese:13,dangi:13,hebrew:-6},Ls=he(Ie,"string"),Vs=he(Ie,"boolean"),As=he(Ie,"number"),Zs=as.map(e=>e+"s"),Fs=fe(Zs),zs=Zs.slice(0,6),Bs=Zs.slice(6),Ws=Bs.slice(1),Us=es(Zs),qs=ts(Zs,0),_s=ts(zs,0),Gs=he(ue,Zs),Xs=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],Js=["isoDay","isoMonth","isoYear"],Ks=Xs.concat(Js),Qs=fe(Js),ei=fe(Xs),ti=fe(Ks),ni=ts(ei,0),ri=he(ue,Ks),ai=1e8,oi=ai*os,si=[ai,0],ii=[-ai,0],li=275760,ci=-271821,di=Intl.DateTimeFormat,ui="en-GB",hi=1970,gi=1972,fi=12,mi=lt(1868,9,8),vi=Q(Dt,WeakMap),yi="smallestUnit",pi="unit",xi="roundingIncrement",bi="fractionalSecondDigits",Di="relativeTo",wi="direction",Ci={constrain:0,reject:1},Ei=Object.keys(Ci),Mi={compatible:0,reject:1,earlier:2,later:3},ki={reject:0,use:1,prefer:2,ignore:3},Ti={auto:0,never:1,critical:2,always:3},ji={auto:0,never:1,critical:2},Si={auto:0,never:1},Ni={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},Ii={previous:-1,next:1},Hi=he(Zt,yi),Oi=he(Zt,"largestUnit"),Ri=he(Zt,pi),Pi=he(Ft,"overflow",Ci),$i=he(Ft,"disambiguation",Mi),Yi=he(Ft,"offset",ki),Li=he(Ft,"calendarName",Ti),Vi=he(Ft,"timeZoneName",ji),Ai=he(Ft,"offset",Si),Zi=he(Ft,"roundingMode",Ni),Fi="PlainYearMonth",zi="PlainMonthDay",Bi="PlainDate",Wi="PlainDateTime",Ui="PlainTime",qi="ZonedDateTime",_i="Instant",Gi="Duration",Xi=[Math.floor,e=>Ce(e)?Math.floor(e):Math.round(e),Math.ceil,e=>Ce(e)?Math.ceil(e):Math.round(e),Math.trunc,e=>Ce(e)?Math.trunc(e)||0:Math.round(e),e=>e<0?Math.floor(e):Math.ceil(e),e=>Math.sign(e)*Math.round(Math.abs(e))||0,e=>Ce(e)?(e=Math.trunc(e)||0)+e%2:Math.round(e)],Ji="UTC",Ki=5184e3,Qi=it(1847),el=it((new Date).getUTCFullYear()+10),tl=/0+$/,nl=Q(Zn,WeakMap),rl=2**32-1,al=Q(e=>{const t=Fr(e);return"object"==typeof t?new sl(t):new ol(t||0)});class ol{constructor(e){this.$=e}R(){return this.$}I(e){return(e=>{const t=ot({...e,...ni});if(!t||Math.abs(t[0])>1e8)throw new RangeError(zo)})(e),[st(e,this.$)]}O(){}}class sl{constructor(e){this.nn=(e=>{function t(e){const t=ye(e,o,s),[i,l]=Dr(t),c=r(i),d=r(l);return c===d?c:n(a(i,l),c,d,e)}function n(t,n,r,a){let o,s;for(;(void 0===a||void 0===(o=a<t[0]?n:a>=t[1]?r:void 0))&&(s=t[1]-t[0]);){const n=t[0]+Math.floor(s/2);e(n)===r?t[1]=n:t[0]=n+1}return o}const r=Q(e),a=Q(br);let o=Qi,s=el;return{tn(e){const n=t(e-86400),r=t(e+86400),a=e-n,o=e-r;if(n===r)return[a];const s=t(a);return s===t(o)?[e-s]:n>r?[a,o]:[]},rn:t,O(e,t){const i=ye(e,o,s);let[l,c]=Dr(i);const d=Ki*t,u=t<0?()=>c>o||(o=i,0):()=>l<s||(s=i,0);for(;u();){const o=r(l),s=r(c);if(o!==s){const r=a(l,c);n(r,o,s);const i=r[0];if((ve(i,e)||1)===t)return i}l+=d,c+=d}}}})((e=>t=>{const n=ht(e,t*ss);return it(Ta(n),parseInt(n.month),parseInt(n.day),parseInt(n.hour),parseInt(n.minute),parseInt(n.second))-t})(e))}R(e){return this.nn.rn((e=>rt(e)[0])(e))*cs}I(e){const[t,n]=[it((r=e).isoYear,r.isoMonth,r.isoDay,r.isoHour,r.isoMinute,r.isoSecond),r.isoMillisecond*ls+r.isoMicrosecond*is+r.isoNanosecond];var r;return this.nn.tn(t).map(e=>et(ze(_e(e,cs),n)))}O(e,t){const[n,r]=rt(e),a=this.nn.O(n+(t>0||r?1:0),t);if(void 0!==a)return _e(a,cs)}}const il="([+-])",ll="(?:[.,](\\d{1,9}))?",cl=`(?:(?:${il}(\\d{6}))|(\\d{4}))-?(\\d{2})`,dl="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+ll+")?)?",ul=il+dl,hl=cl+"-?(\\d{2})(?:[T ]"+dl+"(Z|"+ul+")?)?",gl="\\[(!?)([^\\]]*)\\]",fl=`((?:${gl}){0,9})`,ml=Yr(cl+fl),vl=Yr("(?:--)?(\\d{2})-?(\\d{2})"+fl),yl=Yr(hl+fl),pl=Yr("T?"+dl+"(?:"+ul+")?"+fl),xl=Yr(ul),bl=new RegExp(gl,"g"),Dl=Yr(`${il}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${ll}H)?(?:(\\d+)${ll}M)?(?:(\\d+)${ll}S)?)?`),wl=Q(e=>new di(ui,{timeZone:e,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),Cl=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,El=/[^\w\/:+-]+/,Ml=/^M(\d{2})(L?)$/,kl=Q(Ca),Tl=Q(e=>new di(ui,{calendar:e,timeZone:Ji,era:"short",year:"numeric",month:"short",day:"numeric"})),jl={P(e,t,n){const r=Tt(n);let a,{years:o,months:s,weeks:i,days:l}=t;if(l+=mr(t,5)[0],o||s)a=((e,t,n,r,a)=>{let[o,s,i]=e.v(t);if(n){const[t,r]=e.q(o,s);o+=n,s=ya(t,r,e.L(o)),s=J("month",s,1,e.B(o),a)}return r&&([o,s]=e.un(o,s,r)),i=J("day",i,1,e.U(o,s),a),e.p(o,s,i)})(this,e,o,s,r);else{if(!i&&!l)return e;a=at(e)}if(void 0===a)throw new RangeError(zo);return a+=(7*i+l)*os,Ke(ut(a))},N(e,t,n){if(n<=7){let r=0,a=la({...e,...ni},{...t,...ni});return 7===n&&([r,a]=be(a,7)),{...qs,weeks:r,days:a}}const r=this.v(e),a=this.v(t);let[o,s,i]=((e,t,n,r,a,o,s)=>{let i=a-t,l=o-n,c=s-r;if(i||l){const d=Math.sign(i||l);let u=e.U(a,o),h=0;if(Math.sign(c)===-d){const r=u;[a,o]=e.un(a,o,-d),i=a-t,l=o-n,u=e.U(a,o),h=d<0?-r:u}if(c=s-Math.min(r,u)+h,i){const[r,s]=e.q(t,n),[c,u]=e.q(a,o);if(l=c-r||Number(u)-Number(s),Math.sign(l)===-d){const n=d<0&&-e.B(a);i=(a-=d)-t,l=o-ya(r,s,e.L(a))+(n||e.B(a))}}}return[i,l,c]})(this,...r,...a);return 8===n&&(s+=this.cn(o,r[0]),o=0),{...qs,years:o,months:s,days:i}},F(e,t){const n=Tt(t),r=Ua(this,e),a=qa(this,e,r,n),o=_a(this,e,a,r,n);return qt(Ke(this.V(r,a,o)),this.id||Hs)},K(e,t){const n=Tt(t),r=Ua(this,e),a=qa(this,e,r,n);return _t(Je(this.V(r,a,1)),this.id||Hs)},_(e,t){const n=Tt(t);let r,a,o,s=void 0!==e.eraYear||void 0!==e.year?Ua(this,e):void 0;const i=!this.id;if(void 0===s&&i&&(s=gi),void 0!==s){const t=qa(this,e,s,n);r=_a(this,e,t,s,n);const i=this.L(s);a=pa(t,i),o=t===i}else{if(void 0===e.monthCode)throw new TypeError(Io);if([a,o]=ma(e.monthCode),this.id&&this.id!==Os&&this.id!==Rs)if(this.id&&"coptic"===Va(this.id)&&0===n){const t=o||13!==a?30:6;r=e.day,r=ye(r,1,t)}else if(this.id&&"chinese"===Va(this.id)&&0===n){const t=!o||1!==a&&9!==a&&10!==a&&11!==a&&12!==a?30:29;r=e.day,r=ye(r,1,t)}else r=e.day;else r=_a(this,e,qa(this,e,gi,n),gi,n)}const l=this.G(a,o,r);if(!l)throw new RangeError("Cannot guess year");const[c,d]=l;return Gt(Ke(this.V(c,d,r)),this.id||Hs)},fields(e){return ba(this)&&e.includes("year")?[...e,...bs]:e},k(e,t){const n=Object.assign(Object.create(null),e);return Ga(n,t,Es),ba(this)&&(Ga(n,t,Ds),this.id===Rs&&Ga(n,t,Ss,bs)),n},inLeapYear(e){const[t]=this.v(e);return this.sn(t)},monthsInYear(e){const[t]=this.v(e);return this.B(t)},daysInMonth(e){const[t,n]=this.v(e);return this.U(t,n)},daysInYear(e){const[t]=this.v(e);return this.fn(t)},dayOfYear:fa,era(e){return this.hn(e)[0]},eraYear(e){return this.hn(e)[1]},monthCode(e){const[t,n]=this.v(e),[r,a]=this.q(t,n);return va(r,a)},dayOfWeek:xt,daysInWeek:()=>7},Sl={v:gt,hn:bt,q:ft},Nl={dayOfYear:fa,v:gt,p:lt},Il=Object.assign({},Nl,{weekOfYear:ha,yearOfWeek:ga,m(e){function t(e){return(7-e<r?7:0)-e}function n(e){const n=yt(h+e),r=e||1,a=t(xe(l+n*r,7));return d=(n+(a-c)*r)/7}const r=this.id?1:4,a=xt(e),o=this.dayOfYear(e),s=xe(a-1,7),i=o-1,l=xe(s-i,7),c=t(l);let d,u=Math.floor((i-c)/7)+1,h=e.isoYear;return u?u>n(0)&&(u=1,h++):(u=n(-1),h--),[u,h,d]}}),Hl=Object.assign({},jl,Il,{v:gt,hn:bt,q:ft,G(e,t){if(!t)return[gi,e]},sn:pt,L(){},B:mt,cn:e=>e*fi,U:vt,fn:yt,V:(e,t,n)=>({isoYear:e,isoMonth:t,isoDay:n}),p:lt,un:(e,t,n)=>(e+=De(n,fi),(t+=we(n,fi))<1?(e--,t+=fi):t>fi&&(e++,t-=fi),[e,t]),year:e=>e.isoYear,month:e=>e.isoMonth,day:e=>e.isoDay}),Ol={v:ja,hn:Pa,q:Na},Rl={dayOfYear:fa,v:ja,p:Sa,weekOfYear:ha,yearOfWeek:ga,m:()=>[]},Pl=Object.assign({},jl,Rl,{v:ja,hn:Pa,q:Na,G(e,t,n){const r=this.id&&"chinese"===Va(this.id)?((e,t,n)=>{if(t)switch(e){case 1:return 1651;case 2:return n<30?1947:1765;case 3:return n<30?1966:1955;case 4:return n<30?1963:1944;case 5:return n<30?1971:1952;case 6:return n<30?1960:1941;case 7:return n<30?1968:1938;case 8:return n<30?1957:1718;case 9:return 1832;case 10:return 1870;case 11:return 1814;case 12:return 1890}return 1972})(e,t,n):gi;let[a,o,s]=ja.call(this,{isoYear:r,isoMonth:fi,isoDay:31});const i=Ia.call(this,a),l=o===i;1===(ve(e,pa(o,i))||ve(Number(t),Number(l))||ve(n,s))&&a--;for(let r=0;r<100;r++){const o=a-r,s=Ia.call(this,o),i=ya(e,t,s);if(t===(i===s)&&n<=Oa.call(this,o,i))return[o,i]}},sn(e){const t=Ha.call(this,e);return t>Ha.call(this,e-1)&&t>Ha.call(this,e+1)},L:Ia,B:Ra,cn(e,t){const n=t+e,r=Math.sign(e),a=r<0?-1:0;let o=0;for(let e=t;e!==n;e+=r)o+=Ra.call(this,e+a);return o},U:Oa,fn:Ha,V(e,t,n){return ut(Sa.call(this,e,t,n))},p:Sa,un(e,t,n){if(n){if(t+=n,!Number.isSafeInteger(t))throw new RangeError(zo);if(n<0)for(;t<1;)t+=Ra.call(this,--e);else{let n;for(;t>(n=Ra.call(this,e));)t-=n,e++}}return[e,t]},year(e){return this.h(e).year},month(e){const{year:t,o:n}=this.h(e),{u:r}=this.l(t);return r[n]+1},day(e){return this.h(e).day}}),$l=Aa(Sl,Ol),Yl=Aa(Hl,Pl),Ll={...{era:Pe,eraYear:Le,year:Le,month:Ae,monthCode(e){const t=Pe(e);return ma(t),t},day:Ae},...ts(fs,Le),...ts(Zs,Ve),offset(e){const t=Pe(e);return wr(t),t}},Vl=he(ie,fs,Xs),Al=he(ie,Xs,fs),Zl="numeric",Fl=["timeZoneName"],zl={month:Zl,day:Zl},Bl={year:Zl,month:Zl},Wl=Object.assign({},Bl,{day:Zl}),Ul={hour:Zl,minute:Zl,second:Zl},ql=Object.assign({},Wl,Ul),_l=Object.assign({},ql,{timeZoneName:"short"}),Gl=Object.keys(Bl),Xl=Object.keys(zl),Jl=Object.keys(Wl),Kl=Object.keys(Ul),Ql=["dateStyle"],ec=Gl.concat(Ql),tc=Xl.concat(Ql),nc=Jl.concat(Ql,["weekday"]),rc=Kl.concat(["dayPeriod","timeStyle","fractionalSecondDigits"]),ac=nc.concat(rc),oc=Fl.concat(rc),sc=Fl.concat(nc),ic=Fl.concat(["day","weekday"],rc),lc=Fl.concat(["year","weekday"],rc),cc=eo(ac,ql),dc=eo(ac,_l),uc=eo(ac,ql,Fl),hc=eo(nc,Wl,oc),gc=eo(rc,Ul,sc),fc=eo(ec,Bl,ic),mc=eo(tc,zl,lc),vc={},yc=new di(void 0,{calendar:Hs}).resolvedOptions().calendar===Hs,pc=[cc,Kt],xc=[dc,Kt,0,(e,t)=>{const n=e.timeZone;if(t&&t.timeZone!==n)throw new RangeError(Yo);return n}],bc=[uc,at],Dc=[hc,at],wc=[gc,e=>tt(e)/ls],Cc=[fc,at,yc],Ec=[mc,at,yc];let Mc;function kc(e,t,n,r,a){function o(...e){if(!(this instanceof o))throw new TypeError(Co);Kc(this,t(...e))}function s(e,t){return Object.defineProperties(function(...t){return e.call(this,i(this),...t)},ee(t))}function i(t){const n=Jc(t);if(!n||n.branding!==e)throw new TypeError(Co);return n}return Object.defineProperties(o.prototype,{...ne(oe(s,n)),...te(oe(s,r)),...re("Temporal."+e)}),Object.defineProperties(o,{...te(a),...ee(e)}),[o,e=>{const t=Object.create(o.prototype);return Kc(t,e),t},i]}function Tc(e){if(Jc(e)||void 0!==e.calendar||void 0!==e.timeZone)throw new TypeError("Invalid bag");return e}function jc(e){return Sc(e)||Hs}function Sc(e){const{calendar:t}=e;if(void 0!==t)return Nc(t)}function Nc(e){if(K(e)){const{calendar:t}=Jc(e)||{};if(!t)throw new TypeError(Ro(e));return t}return(e=>La(function(e){const t=Sr(e)||Nr(e)||Ir(e);return t?t.calendar:e}(Ls(e))))(e)}function Ic(e){const t={};for(const n in e)t[n]=e=>{const{calendar:t}=e;return Yl(t)[n](e)};return t}function Hc(){throw new TypeError("Cannot use valueOf")}function Oc(e){if(K(e)){const{timeZone:t}=Jc(e)||{};if(!t)throw new TypeError($o(e));return t}return(e=>Ar(function(e){const t=Sr(e);return t&&(t.timeZone||t.j&&Ji||t.offset)||e}(Ls(e))))(e)}function Rc(e){if(K(e)){const t=Jc(e);return t&&t.branding===Gi?t:function(e){const t=za(e,Fs);return Jt(gr({...qs,...t}))}(e)}return function(e){const t=(e=>{const t=Dl.exec(e);return t?(e=>{function t(e,t,o){let s=0,i=0;if(o&&([s,a]=pe(a,gs[o])),void 0!==e){if(r)throw new RangeError(Jo(e));i=(e=>{const t=parseInt(e);if(!Number.isFinite(t))throw new RangeError(Jo(e));return t})(e),n=1,t&&(a=$r(t)*(gs[o]/cs),r=1)}return s+i}let n=0,r=0,a=0,o={...ae(Zs,[t(e[2]),t(e[3]),t(e[4]),t(e[5]),t(e[6],e[7],5),t(e[8],e[9],4),t(e[10],e[11],3)]),...Me(a,2,Zs)};if(!n)throw new RangeError(Do(Zs));return Lr(e[1])<0&&(o=ur(o)),o})(t):void 0})(Ls(e));if(!t)throw new RangeError(Xo(e));return Jt(gr(t))}(e)}function Pc(e){if(void 0!==e){if(K(e)){const t=Jc(e)||{};switch(t.branding){case qi:case Bi:return t;case Wi:return qt(t)}const n=jc(e);return{...Za(Oc,al,Yl(n),e),calendar:n}}return function(e){const t=Sr(Ls(e));if(!t)throw new RangeError(Xo(e));if(t.timeZone)return Mr(t,t.offset?wr(t.offset):void 0);if(t.j)throw new RangeError(Xo(e));return Tr(t)}(e)}}function $c(e,t){if(K(e)){const n=Jc(e)||{};switch(n.branding){case Ui:return Tt(t),n;case Wi:return Tt(t),Xt(n);case qi:return Tt(t),Qa(al,n)}return function(e,t){return Xt(Ba(za(e,ms,[],1),Tt(t)))}(e,t)}const n=function(e){let t,n=(e=>{const t=pl.exec(e);return t?(Pr(t[10]),Rr(t)):void 0})(Ls(e));if(!n){if(n=Sr(e),!n)throw new RangeError(Xo(e));if(!n.C)throw new RangeError(Xo(e));if(n.j)throw new RangeError(Jo("Z"));Er(n)}if((t=Nr(e))&&Et(t))throw new RangeError(Xo(e));if((t=Ir(e))&&Et(t))throw new RangeError(Xo(e));return Xt(kt(n,1))}(e);return Tt(t),n}function Yc(e){return void 0===e?void 0:$c(e)}function Lc(e,t){if(K(e)){const n=Jc(e)||{};switch(n.branding){case Wi:return Tt(t),n;case Bi:return Tt(t),Ut({...n,...ni});case qi:return Tt(t),Ja(al,n)}return function(e,t,n){const r=Fa(e,t,js,[],fs),a=Tt(n);return Ut(Qe({...e.F(r,At(a)),...Ba(r,a)}))}(Yl(jc(e)),e,t)}const n=function(e){const t=Sr(Ls(e));if(!t||t.j)throw new RangeError(Xo(e));return Ut(kr(t))}(e);return Tt(t),n}function Vc(e,t){if(K(e)){const n=Jc(e);if(n&&n.branding===zi)return Tt(t),n;const r=Sc(e);return function(e,t,n,r){const a=Fa(e,n,js,Ms);return t&&void 0!==a.month&&void 0===a.monthCode&&void 0===a.year&&(a.year=gi),e._(a,r)}(Yl(r||Hs),!r,e,t)}const n=function(e,t){const n=Ir(Ls(t));if(n)return Er(n),Gt(Ct(n));const r=Cr(t,0,1),{calendar:a}=r,o=e(a),[s,i,l]=o.v(r),[c,d]=o.q(s,i),[u,h]=o.G(c,d,l);return Gt(Ke(o.V(u,h,l)),a)}(Yl,e);return Tt(t),n}function Ac(e,t){if(K(e)){const n=Jc(e);return n&&n.branding===Fi?(Tt(t),n):function(e,t,n,r){const a=Fa(e,t,ks,r);return e.K(a,n)}(Yl(jc(e)),e,t)}const n=function(e,t){const n=Nr(Ls(t));if(n)return Er(n),_t(Je(Ct(n)));const r=Cr(t,1);return _t(er(e(r.calendar),r))}(Yl,e);return Tt(t),n}function Zc(e,t){if(K(e)){const n=Jc(e)||{};switch(n.branding){case Bi:return Tt(t),n;case Wi:return Tt(t),qt(n);case qi:return Tt(t),Ka(al,n)}return function(e,t,n,r=[]){const a=Fa(e,t,js,r);return e.F(a,n)}(Yl(jc(e)),e,t)}const n=Cr(e);return Tt(t),n}function Fc(e,t){if(K(e)){const n=Jc(e);if(n&&n.branding===qi)return jt(t),n;const r=jc(e);return function(e,t,n,r,a,o){const s=Fa(n,a,js,ys,xs),i=e(s.timeZone),[l,c,d]=jt(o),u=n.F(s,At(l)),h=Ba(s,l);return Wt(Fn(t(i),{...u,...h},void 0!==s.offset?wr(s.offset):void 0,c,d),i,r)}(Oc,al,Yl(r),r,e,t)}return function(e,t){const n=Sr(Ls(e));if(!n||!n.timeZone)throw new RangeError(Xo(e));const{offset:r}=n,a=r?wr(r):void 0,[,o,s]=jt(t);return Mr(n,a,o,s)}(e,t)}function zc(e){return oe(e=>t=>e(Bc(t)),e)}function Bc(e){return nl(e,al)}function Wc(e){if(K(e)){const t=Jc(e);if(t)switch(t.branding){case _i:return t;case qi:return Bt(t.epochNanoseconds)}}return function(e){const t=Sr(e=Pe(e));if(!t)throw new RangeError(Xo(e));let n;if(t.j)n=0;else{if(!t.offset)throw new RangeError(Xo(e));n=wr(t.offset)}return t.timeZone&&Hr(t.timeZone,1),Bt(st(wt(t),n))}(e)}function Uc(){function e(e,n){return new t(e,n)}function t(e,t=Object.create(null)){Yd.set(this,((e,t)=>{const n=new di(e,t),r=n.resolvedOptions(),a=r.locale,o=le(Object.keys(t),r),s=Q(Gc),i=(e,...t)=>{if(e){if(2!==t.length)throw new TypeError(Ko);for(const e of t)if(void 0===e)throw new TypeError(Ko)}e||void 0!==t[0]||(t=[]);const r=t.map(e=>Jc(e)||Number(e));let i,l=0;for(const e of r){const t="object"==typeof e?e.branding:void 0;if(l++&&t!==i)throw new TypeError(Ko);i=t}return i?s(i)(a,o,...r):[n,...r]};return i.X=n,i})(e,t))}const n=di.prototype,r=Object.getOwnPropertyDescriptors(n),a=Object.getOwnPropertyDescriptors(di);for(const t in r){const n=r[t],a=t.startsWith("format")&&qc(t);"function"==typeof n.value?n.value="constructor"===t?e:a||_c(t):a&&(n.get=function(){if(!Yd.has(this))throw new TypeError(Co);return(...e)=>a.apply(this,e)},Object.defineProperties(n.get,ee(`get ${t}`)))}return a.prototype.value=t.prototype=Object.create({},r),Object.defineProperties(e,a),e}function qc(e){return Object.defineProperties(function(...t){const n=Yd.get(this),[r,...a]=n(e.includes("Range"),...t);return r[e](...a)},ee(e))}function _c(e){return Object.defineProperties(function(...t){return Yd.get(this).X[e](...t)},ee(e))}function Gc(e){const t=hd[e];if(!t)throw new TypeError((e=>`Cannot format ${e}`)(e));return to(t,Q(no),1)}const Xc=new WeakMap,Jc=Xc.get.bind(Xc),Kc=Xc.set.bind(Xc),Qc={era:function(e){if(void 0!==e)return Ls(e)},eraYear:ke,year:je,month:Te,daysInMonth:Te,daysInYear:Te,inLeapYear:Vs,monthsInYear:Te},ed={monthCode:Ls},td={day:Te},nd={dayOfWeek:Te,dayOfYear:Te,weekOfYear:function(e){if(void 0!==e)return Te(e)},yearOfWeek:ke,daysInWeek:Te},rd=Ic(Object.assign({},Qc,ed,td,nd)),ad=Ic({...Qc,...ed}),od=Ic({...ed,...td}),sd={calendarId:e=>e.calendar},id=se(e=>t=>t[e],Zs.concat("sign")),ld=se((e,t)=>e=>e[Xs[t]],fs),cd={epochMilliseconds:Kt,epochNanoseconds:function(e){return((e,t=1)=>{const[n,r]=e,a=Math.floor(r/t),o=hs/t;return BigInt(n)*BigInt(o)+BigInt(a)})(e.epochNanoseconds)}},[dd,ud]=kc(Gi,function(e=0,t=0,n=0,r=0,a=0,o=0,s=0,i=0,l=0,c=0){return Jt(gr(oe(Ve,ae(Zs,[e,t,n,r,a,o,s,i,l,c]))))},{...id,blank:function(e){return!e.sign}},{with:(e,t)=>ud(function(e,t){return Jt((n=e,r=t,gr({...n,...za(r,Fs)})));var n,r}(e,t)),negated:e=>ud(dr(e)),abs:e=>ud(function(e){return-1===e.sign?dr(e):e}(e)),add:(e,t,n)=>ud(cr(Pc,Yl,al,0,e,Rc(t),n)),subtract:(e,t,n)=>ud(cr(Pc,Yl,al,1,e,Rc(t),n)),round:(e,t)=>ud(function(e,t,n,r,a){const o=xr(r),[s,i,l,c,d]=((e,t,n)=>{e=Vt(e,yi);let r=Oi(e);const a=n(e[Di]);let o=Pt(e);const s=Zi(e,7);let i=Hi(e);if(void 0===r&&void 0===i)throw new RangeError(_o);if(null==i&&(i=0),null==r&&(r=Math.max(i,t)),zt(r,i),o=$t(o,i,1),o>1&&i>5&&r!==i)throw new RangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit");return[r,i,o,s,a]})(a,o,e),u=Math.max(o,s);if(!d&&u<=6)return Jt(gr(((e,t,n,r,a)=>{const o=gn(mr(e),n,r,a);return{...qs,...vr(o,t)}})(r,s,i,l,c)));if(!ir(d)&&!r.sign)return r;if(!d)throw new RangeError(Uo);const[h,g,f]=rr(t,n,d),m=ar(f),v=or(f),y=sr(f),p=v(g,h,r);ir(d)||(Qe(h),Qe(p));let x=y(g,h,p,s);const b=r.sign,D=hr(x);if(b&&D&&b!==D)throw new RangeError(Oo);return x=hn(x,m(p),s,i,l,c,g,h,m,v),Jt(x)}(Pc,Yl,al,e,t)),total:(e,t)=>function(e,t,n,r,a){const o=xr(r),[s,i]=((e,t)=>{const n=t((e=Vt(e,pi))[Di]);let r=Ri(e);return r=Se(pi,r),[r,n]})(a,e),l=Math.max(s,o);if(!i&&lr(l,i))return en(r,s);if(!i)throw new RangeError(Uo);if(!r.sign)return 0;const[c,d,u]=rr(t,n,i),h=ar(u),g=or(u),f=sr(u),m=g(d,c,r);ir(i)||(Qe(c),Qe(m));const v=f(d,c,m,s);return lr(s,i)?en(v,s):((e,t,n,r,a,o,s)=>{const i=hr(e),[l,c]=tn(r,Gs(n,e),n,i,a,o,s),d=nn(t,l,c);return e[Zs[n]]+d*i})(v,h(m),s,d,c,h,g)}(Pc,Yl,al,e,t),toLocaleString(e,t,n){return Intl.DurationFormat?new Intl.DurationFormat(t,n).format(this):Tn(e)},toString:Tn,toJSON:e=>Tn(e),valueOf:Hc},{from:e=>ud(Rc(e)),compare:(e,t,n)=>function(e,t,n,r,a,o){const s=e(Lt(o).relativeTo),i=Math.max(xr(r),xr(a));if(de(Zs,r,a))return 0;if(lr(i,s))return We(mr(r),mr(a));if(!s)throw new RangeError(Uo);const[l,c,d]=rr(t,n,s),u=ar(d),h=or(d);return We(u(h(c,l,r)),u(h(c,l,a)))}(Pc,Yl,al,Rc(e),Rc(t),n)}),hd={Instant:pc,PlainDateTime:bc,PlainDate:Dc,PlainTime:wc,PlainYearMonth:Cc,PlainMonthDay:Ec},gd=to(pc),fd=to(xc),md=to(bc),vd=to(Dc),yd=to(wc),pd=to(Cc),xd=to(Ec),[bd,Dd]=kc(Ui,function(e=0,t=0,n=0,r=0,a=0,o=0){return Xt(kt(oe(Le,ae(Xs,[e,t,n,r,a,o])),1))},ld,{with(e,t,n){return Dd(function(e,t,n){return Xt(((e,t,n)=>Ba({...le(ms,e),...za(t,ms)},Tt(n)))(e,t,n))}(this,Tc(t),n))},add:(e,t)=>Dd(Xn(0,e,Rc(t))),subtract:(e,t)=>Dd(Xn(1,e,Rc(t))),until:(e,t,n)=>ud(ta(0,e,$c(t),n)),since:(e,t,n)=>ud(ta(1,e,$c(t),n)),round:(e,t)=>Dd(function(e,t){const[n,r,a]=Nt(t,5);var o;return Xt((o=a,on(e,ln(n,r),o)[0]))}(e,t)),equals:(e,t)=>function(e,t){return!qr(e,t)}(e,$c(t)),toLocaleString(e,t,n){const[r,a]=yd(t,n,e);return r.format(a)},toString:kn,toJSON:e=>kn(e),valueOf:Hc},{from:(e,t)=>Dd($c(e,t)),compare:(e,t)=>qr($c(e),$c(t))}),[wd,Cd]=kc(Wi,he(function(e,t,n,r,a=0,o=0,s=0,i=0,l=0,c=0,d=Hs){return Ut(Qe(wt(oe(Le,ae(Ks,[t,n,r,a,o,s,i,l,c])))),e(d))},Ya),{...sd,...rd,...ld},{with:(e,t,n)=>Cd(function(e,t,n,r){const a=e(t.calendar),o=[...a.fields(js),...fs].sort(),s={...Xa(i=t),hour:i.isoHour,minute:i.isoMinute,second:i.isoSecond,millisecond:i.isoMillisecond,microsecond:i.isoMicrosecond,nanosecond:i.isoNanosecond};var i;const l=za(n,o),c=Tt(r),d=a.k(s,l),u={...s,...l};return Ut(Qe({...a.F(d,At(c)),...kt(Vl(u),c)}))}(Yl,e,Tc(t),n)),withCalendar:(e,t)=>Cd(ao(e,Nc(t))),withPlainTime:(e,t)=>Cd(function(e,t=ni){return Ut(Qe({...e,...t}))}(e,Yc(t))),add:(e,t,n)=>Cd(qn(Yl,0,e,Rc(t),n)),subtract:(e,t,n)=>Cd(qn(Yl,1,e,Rc(t),n)),until:(e,t,n)=>ud(Jr(Yl,0,e,Lc(t),n)),since:(e,t,n)=>ud(Jr(Yl,1,e,Lc(t),n)),round:(e,t)=>Cd(function(e,t){return Ut(rn(e,...Nt(t)),e.calendar)}(e,t)),equals:(e,t)=>function(e,t){return!Wr(e,t)&&e.calendar===t.calendar}(e,Lc(t)),toZonedDateTime:(e,t,n)=>Id(function(e,t,n,r){const a=((e,t,n,r)=>{const a=(e=>$i(Lt(e)))(r);return zn(e(t),n,a)})(e,n,t,r);return Wt(et(a),n,t.calendar)}(al,e,Oc(t),n)),toPlainDate:e=>Sd(qt(e)),toPlainTime:e=>Dd(Xt(e)),toLocaleString(e,t,n){const[r,a]=md(t,n,e);return r.format(a)},toString:wn,toJSON:e=>wn(e),valueOf:Hc},{from:(e,t)=>Cd(Lc(e,t)),compare:(e,t)=>Wr(Lc(e),Lc(t))}),[Ed,Md]=kc(zi,he(function(e,t,n,r=Hs,a=gi){const o=Le(t),s=Le(n),i=e(r);return Gt(Ke(Ct({isoYear:Le(a),isoMonth:o,isoDay:s})),i)},Ya),{...sd,...od},{with:(e,t,n)=>Md(function(e,t,n,r){const a=e(t.calendar),o=a.fields(js).sort(),s=(e=>{const t=$l(e.calendar),[n,r,a]=t.v(e),[o,s]=t.q(n,r);return{monthCode:va(o,s),day:a}})(t),i=za(n,o),l=a.k(s,i);return a._(l,r)}(Yl,e,Tc(t),n)),equals:(e,t)=>function(e,t){return!Ur(e,t)&&e.calendar===t.calendar}(e,Vc(t)),toPlainDate(e,t){return Sd(function(e,t,n,r){return((e,t,n)=>Wa(e,t,Ns,Ne(n),ws))(e(t.calendar),n,r)}(Yl,e,this,t))},toLocaleString(e,t,n){const[r,a]=xd(t,n,e);return r.format(a)},toString:Mn,toJSON:e=>Mn(e),valueOf:Hc},{from:(e,t)=>Md(Vc(e,t))}),[kd,Td]=kc(Fi,he(function(e,t,n,r=Hs,a=1){const o=Le(t),s=Le(n),i=e(r);return _t(Je(Ct({isoYear:o,isoMonth:s,isoDay:Le(a)})),i)},Ya),{...sd,...ad},{with:(e,t,n)=>Td(function(e,t,n,r){const a=e(t.calendar),o=a.fields(ks).sort(),s=(e=>{const t=$l(e.calendar),[n,r]=t.v(e),[a,o]=t.q(n,r);return{year:n,monthCode:va(a,o)}})(t),i=za(n,o),l=a.k(s,i);return a.K(l,r)}(Yl,e,Tc(t),n)),add:(e,t,n)=>Td(Gn(Yl,0,e,Rc(t),n)),subtract:(e,t,n)=>Td(Gn(Yl,1,e,Rc(t),n)),until:(e,t,n)=>ud(Qr(Yl,0,e,Ac(t),n)),since:(e,t,n)=>ud(Qr(Yl,1,e,Ac(t),n)),equals:(e,t)=>function(e,t){return!Ur(e,t)&&e.calendar===t.calendar}(e,Ac(t)),toPlainDate(e,t){return Sd(function(e,t,n,r){return((e,t,n)=>Wa(e,t,Ts,Ne(n),Ms))(e(t.calendar),n,r)}(Yl,e,this,t))},toLocaleString(e,t,n){const[r,a]=pd(t,n,e);return r.format(a)},toString:En,toJSON:e=>En(e),valueOf:Hc},{from:(e,t)=>Td(Ac(e,t)),compare:(e,t)=>Ur(Ac(e),Ac(t))}),[jd,Sd]=kc(Bi,he(function(e,t,n,r,a=Hs){return qt(Ke(Ct(oe(Le,{isoYear:t,isoMonth:n,isoDay:r}))),e(a))},Ya),{...sd,...rd},{with:(e,t,n)=>Sd(function(e,t,n,r){const a=e(t.calendar),o=a.fields(js).sort(),s=Xa(t),i=za(n,o),l=a.k(s,i);return a.F(l,r)}(Yl,e,Tc(t),n)),withCalendar:(e,t)=>Sd(ao(e,Nc(t))),add:(e,t,n)=>Sd(_n(Yl,0,e,Rc(t),n)),subtract:(e,t,n)=>Sd(_n(Yl,1,e,Rc(t),n)),until:(e,t,n)=>ud(Kr(Yl,0,e,Zc(t),n)),since:(e,t,n)=>ud(Kr(Yl,1,e,Zc(t),n)),equals:(e,t)=>function(e,t){return!Ur(e,t)&&e.calendar===t.calendar}(e,Zc(t)),toZonedDateTime(e,t){const n=K(t)?t:{timeZone:t};return Id(function(e,t,n,r,a){const o=e(a.timeZone),s=a.plainTime,i=void 0!==s?t(s):void 0,l=n(o);let c;return c=i?zn(l,{...r,...i}):Bn(l,{...r,...ni}),Wt(c,o,r.calendar)}(Oc,$c,al,e,n))},toPlainDateTime:(e,t)=>Cd(function(e,t=ni){return Ut(Qe({...e,...t}))}(e,Yc(t))),toPlainYearMonth(e){return Td(function(e,t,n){return((e,t)=>{const n=Fa(e,t,Ts);return e.K(n,void 0)})(e(t.calendar),n)}(Yl,e,this))},toPlainMonthDay(e){return Md(function(e,t,n){return((e,t)=>{const n=Fa(e,t,Ns);return e._(n)})(e(t.calendar),n)}(Yl,e,this))},toLocaleString(e,t,n){const[r,a]=vd(t,n,e);return r.format(a)},toString:Cn,toJSON:e=>Cn(e),valueOf:Hc},{from:(e,t)=>Sd(Zc(e,t)),compare:(e,t)=>Ur(Zc(e),Zc(t))}),[Nd,Id]=kc(qi,he(function(e,t,n,r,a=Hs){return Wt(et(qe($e(n))),t(r),e(a))},Ya,function(e){return Ar(Ls(e))}),{...cd,...sd,...zc(rd),...zc(ld),offset:e=>Pn(Bc(e).offsetNanoseconds),offsetNanoseconds:e=>Bc(e).offsetNanoseconds,timeZoneId:e=>e.timeZone,hoursInDay:e=>function(e,t){const n=e(t.timeZone),r=nl(t,n),[a,o]=cn(r),s=Ge(Be(Bn(n,a),Bn(n,o)),us,1);if(s<=0)throw new RangeError(Oo);return s}(al,e)},{with:(e,t,n)=>Id(function(e,t,n,r,a){const{calendar:o,timeZone:s}=n,i=e(o),l=t(s),c=[...i.fields(js),...ps].sort(),d=(e=>{const t=nl(e,al),n=Pn(t.offsetNanoseconds),r=$l(e.calendar),[a,o,s]=r.v(t),[i,l]=r.q(a,o),c=va(i,l);return{...Al(t),year:a,monthCode:c,day:s,offset:n}})(n),u=za(r,c),h=i.k(d,u),g={...d,...u},[f,m,v]=jt(a,2);return Wt(Fn(l,{...i.F(h,At(f)),...kt(Vl(g),f)},wr(g.offset),m,v),s,o)}(Yl,al,e,Tc(t),n)),withCalendar:(e,t)=>Id(ao(e,Nc(t))),withTimeZone:(e,t)=>Id(function(e,t){return{...e,timeZone:t}}(e,Oc(t))),withPlainTime:(e,t)=>Id(function(e,t,n){const r=t.timeZone,a=e(r),o={...nl(t,a),...n||ni};let s;return s=n?Fn(a,o,o.offsetNanoseconds,2):Bn(a,o),Wt(s,r,t.calendar)}(al,e,Yc(t))),add:(e,t,n)=>Id(Un(Yl,al,0,e,Rc(t),n)),subtract:(e,t,n)=>Id(Un(Yl,al,1,e,Rc(t),n)),until:(e,t,n)=>ud(Jt(Xr(Yl,al,0,e,Fc(t),n))),since:(e,t,n)=>ud(Jt(Xr(Yl,al,1,e,Fc(t),n))),round:(e,t)=>Id(function(e,t,n){let{epochNanoseconds:r,timeZone:a,calendar:o}=t;const[s,i,l]=Nt(n);if(0===s&&1===i)return t;const c=e(a);if(6===s)r=((e,t,n,r)=>{const a=nl(n,t),[o,s]=e(a),i=n.epochNanoseconds,l=Bn(t,o),c=Bn(t,s);if(Ue(i,l,c))throw new RangeError(Oo);return vn(nn(i,l,c),r)?c:l})(cn,c,t,l);else{const e=c.R(r);r=Fn(c,rn(dt(r,e),s,i,l),e,2,0,1)}return Wt(r,a,o)}(al,e,t)),startOfDay:e=>Id(function(e,t){const{timeZone:n,calendar:r}=t,a=((e,t,n)=>Bn(t,e(nl(n,t))))(dn,e(n),t);return Wt(a,n,r)}(al,e)),equals:(e,t)=>function(e,t){return!Br(e,t)&&!!_r(e.timeZone,t.timeZone)&&e.calendar===t.calendar}(e,Fc(t)),toInstant:e=>Od(function(e){return Bt(e.epochNanoseconds)}(e)),toPlainDateTime:e=>Cd(Ja(al,e)),toPlainDate:e=>Sd(Ka(al,e)),toPlainTime:e=>Dd(Qa(al,e)),toLocaleString(e,t,n={}){const[r,a]=fd(t,n,e);return r.format(a)},toString:(e,t)=>Dn(al,e,t),toJSON:e=>Dn(al,e),valueOf:Hc,getTimeZoneTransition(e,t){const{timeZone:n,epochNanoseconds:r}=e,a=function(e){const t=Vt(e,wi),n=Ft(wi,Ii,t,0);if(!n)throw new RangeError(yo(wi,n));return n}(t),o=al(n).O(r,a);return o?Id({...e,epochNanoseconds:o}):null}},{from:(e,t)=>Id(Fc(e,t)),compare:(e,t)=>Br(Fc(e),Fc(t))}),[Hd,Od]=kc(_i,function(e){return Bt(et(qe($e(e))))},cd,{add:(e,t)=>Od(Wn(0,e,Rc(t))),subtract:(e,t)=>Od(Wn(1,e,Rc(t))),until:(e,t,n)=>ud(Gr(0,e,Wc(t),n)),since:(e,t,n)=>ud(Gr(1,e,Wc(t),n)),round:(e,t)=>Od(function(e,t){const[n,r,a]=Nt(t,5,1);return Bt(gn(e.epochNanoseconds,n,r,a,1))}(e,t)),equals:(e,t)=>function(e,t){return!zr(e,t)}(e,Wc(t)),toZonedDateTimeISO:(e,t)=>Id(function(e,t,n=Hs){return Wt(e.epochNanoseconds,t,n)}(e,Oc(t))),toLocaleString(e,t,n){const[r,a]=gd(t,n,e);return r.format(a)},toString:(e,t)=>bn(Oc,al,e,t),toJSON:e=>bn(Oc,al,e),valueOf:Hc},{from:e=>Od(Wc(e)),fromEpochMilliseconds:e=>Od(function(e){return Bt(et(_e(Ve(e),ls)))}(e)),fromEpochNanoseconds:e=>Od(function(e){return Bt(et(qe($e(e))))}(e)),compare:(e,t)=>zr(Wc(e),Wc(t))}),Rd=Object.defineProperties({},{...re("Temporal.Now"),...te({timeZoneId:()=>io(),instant:()=>Od(Bt(so())),zonedDateTimeISO:(e=io())=>Id(Wt(so(),Oc(e),Hs)),plainDateTimeISO:(e=io())=>Cd(Ut(oo(al(Oc(e))),Hs)),plainDateISO:(e=io())=>Sd(qt(oo(al(Oc(e))),Hs)),plainTimeISO:(e=io())=>Dd(Xt(oo(al(Oc(e)))))})}),Pd=Object.defineProperties({},{...re("Temporal"),...te({PlainYearMonth:kd,PlainMonthDay:Ed,PlainDate:jd,PlainTime:bd,PlainDateTime:wd,ZonedDateTime:Nd,Instant:Hd,Duration:dd,Now:Rd})}),$d=Uc(),Yd=new WeakMap;function Ld(e){var t;return e instanceof Pd.PlainDate||("PlainDate"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)||!("hour"in e)&&!("timeZone"in e))}function Vd(e,t=Pd.Now.timeZoneId()){return Pd.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function Ad(e){return Pd.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Zd(e){return new Date(e.epochMilliseconds)}function Fd(e,t){return Ld(e)?function(e,t=Pd.Now.timeZoneId()){return Zd(e.toZonedDateTime({timeZone:t,plainTime:Pd.PlainTime.from({hour:0,minute:0})}))}(e,t):"hour"in e&&!("timeZone"in e)?new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond):Zd(e)}function zd(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return Ld(e)?Pd.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:n,minute:r}):e.with({hour:n,minute:r,second:0,millisecond:0})}function Bd(e,t){const n=Ld(e)?e:e.toPlainDate(),r=Ld(t)?t:t.toPlainDate();return 0===Pd.PlainDate.compare(n,r)}function Wd(e,t=Pd.Now.timeZoneId()){return(Ld(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:Pd.PlainTime.from({hour:0,minute:0})})}function Ud(e,t=Pd.Now.timeZoneId()){return(Ld(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:Pd.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function qd(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 _d(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}Object.create(Intl),te({DateTimeFormat:$d});const Gd=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return Ld(t=e)?0:"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:(console.warn("Warning: No hour property found in temporal object, returning 0"),0);var t,n},Xd=(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 zd(e,t)},Jd=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return Ud(e)},Kd=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Bd(e instanceof Date?Pd.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):Ld(e)?e:e.toPlainDate(),t instanceof Date?Pd.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):Ld(t)?t:t.toPlainDate())},Qd=e=>v().resolveColors(e).eventColor,eu=e=>v().resolveColors(e).textColor,tu=e=>v().resolveColors(e).eventSelectedColor,nu=e=>v().resolveColors(e).lineColor,ru=.25,au=(e,t=0)=>{const n=Math.floor(e),r=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},ou=e=>{if(e.allDay)return"All day";const t=Gd(e.start),n=iu(e);return`${au(t)} - ${au(n)}`},su=e=>{const t=ru;return Math.round(e/t)*t},iu=e=>{if(!e.end)return 0;const t=Gd(e.end);if(e.allDay||!e.start)return t;const n=Fd(e.start),r=Fd(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},lu=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],cu=["January","February","March","April","May","June","July","August","September","October","November","December"],du=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],uu=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);r.setDate(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}},hu=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:cu[r],shortMonthName:du[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},gu=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(hu(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:fu(t)}},fu=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:cu[a],monthIndex:a,year:o}};function mu(e,t){const n=[],r=Math.floor(t/2),a=new Date(e),o=e.getDay(),s=0===o?6:o-1;a.setDate(e.getDate()-s),a.setHours(0,0,0,0);const i=new Date(a);i.setDate(i.getDate()-7*r);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),n.push(gu(t))}return n}const vu=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),yu=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},pu=(e,t)=>t?Pd.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):Pd.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:Pd.Now.timeZoneId()}),xu=(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)},bu=(e,t)=>e.map(e=>{const n=Fd(e.start),r=xu(n,t);return Object.assign(Object.assign({},e),{day:r})});function Du(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}const wu=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Cu=({app:e,calendars:a,toggleCalendarVisibility:o,isCollapsed:s,setCollapsed:i})=>{const l=e.getCurrentDate(),c=e.getVisibleMonth(),d=c.getFullYear(),u=c.getMonth(),[h,g]=t.useState(()=>new Date(d,u,1));t.useEffect(()=>{g(e=>e.getFullYear()===d&&e.getMonth()===u?e:new Date(d,u,1))},[d,u]);const f=t.useMemo(()=>(new Date).toDateString(),[]),m=l.toDateString(),v=t.useMemo(()=>lu.map(e=>e.charAt(0)),[]),y=t.useMemo(()=>{const e=h.getFullYear(),t=h.getMonth(),n=(new Date(e,t,1).getDay()+6)%7,r=[];for(let a=0;a<42;a++){const o=new Date(e,t,a-n+1),s=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===t,isToday:s===f,isSelected:s===m})}return r},[h,m,f]),p=t.useMemo(()=>h.toLocaleDateString(void 0,{month:"long",year:"numeric"}),[h]),x=t.useCallback(t=>{g(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),b=t.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),g(new Date(n.getFullYear(),n.getMonth(),1))},[e]);return n.jsxs("div",{className:"flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",children:[n.jsxs("div",{className:"flex items-center px-2 py-2",children:[n.jsx("button",{type:"button","aria-label":s?"Expand calendar sidebar":"Collapse calendar sidebar",className:"flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",onClick:()=>i(!s),children:s?n.jsx(r.PanelRightClose,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"}):n.jsx(r.PanelRightOpen,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),!s&&n.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Calendars"})]}),s?n.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-3",children:n.jsx("ul",{className:"space-y-1",children:a.map(e=>{var t;const r=!1!==e.isVisible,a=(null===(t=e.colors)||void 0===t?void 0:t.lineColor)||"#3b82f6";return Boolean(e.icon),n.jsx("li",{children:n.jsxs("label",{className:"group flex cursor-pointer items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800",title:e.name,children:[n.jsx("input",{type:"checkbox",className:"calendar-checkbox",style:{"--checkbox-color":a},checked:r,onChange:t=>o(e.id,t.target.checked)}),n.jsx("span",{className:"flex-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white",children:" "})]})},e.id)})})}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-3",children:n.jsx("ul",{className:"space-y-1",children:a.map(e=>{var t;const r=!1!==e.isVisible,a=(null===(t=e.colors)||void 0===t?void 0:t.lineColor)||"#3b82f6",s=Boolean(e.icon);return n.jsx("li",{children:n.jsxs("label",{className:"group flex cursor-pointer items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800",title:e.name,children:[n.jsx("input",{type:"checkbox",className:"calendar-checkbox",style:{"--checkbox-color":a},checked:r,onChange:t=>o(e.id,t.target.checked)}),s&&n.jsx("span",{className:"mr-2 flex h-5 w-5 flex-shrink-0 items-center justify-center text-xs font-semibold text-white","aria-hidden":"true",children:wu(e)}),n.jsx("span",{className:"flex-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white",children:e.name||e.id})]})},e.id)})})}),n.jsxs("div",{className:"border-t border-gray-200 px-3 py-3 dark:border-slate-800",children:[n.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[n.jsx("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:()=>x(-1),"aria-label":"Previous month",children:n.jsx(r.ChevronLeft,{className:"h-4 w-4"})}),n.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:p}),n.jsx("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:()=>x(1),"aria-label":"Next month",children:n.jsx(r.ChevronRight,{className:"h-4 w-4"})})]}),n.jsxs("div",{className:L,children:[v.map(e=>n.jsx("div",{className:`${V} text-gray-500 dark:text-gray-400`,children:e},Du())),y.map(e=>n.jsx("button",{type:"button",className:`\n ${A}\n ${e.isCurrentMonth?Z:F}\n ${e.isToday?z:""}\n ${e.isSelected&&!e.isToday?B:""}\n `,onClick:()=>b(e.fullDate),children:e.date},Du()))]})]})]})]})},Eu=({options:e,value:a,onChange:o})=>{const[s,i]=t.useState(!1),l=t.useRef(null);t.useEffect(()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),e.find(e=>e.value===a);const c=e=>v().resolveColors(e).lineColor;return n.jsxs("div",{className:"relative inline-block",ref:l,children:[n.jsxs("button",{type:"button",onClick:()=>i(!s),className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[n.jsx("span",{className:"w-4 h-4 rounded-sm flex-shrink-0",style:{backgroundColor:c(a)}}),n.jsx(r.ChevronsUpDown,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),s&&n.jsx("ul",{className:"absolute mt-1 w-full min-w-max bg-gray-100 dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 z-10 overflow-hidden border dark:border-gray-600",children:e.map(e=>n.jsxs("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors "+(a===e.value?"font-semibold":""),onClick:()=>{return t=e.value,o(t),void i(!1);var t},children:[a===e.value?n.jsx("span",{className:"mr-2 text-sm",children:n.jsx(r.Check,{width:12,height:12})}):n.jsx("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),n.jsx("span",{className:"w-3 h-3 mr-2 rounded-sm flex-shrink-0",style:{backgroundColor:c(e.value)}}),n.jsx("span",{className:"text-sm whitespace-nowrap",children:e.label})]},e.value))})]})},Mu=/(YYYY|YY|MM|DD|HH|mm)/g,ku=e=>e.toString().padStart(2,"0"),Tu=(e,t)=>{const n=(null!=t?t:"").trim(),r=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return r.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},ju=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Su=e=>{let t,n=0,r="^";for(;null!==(t=Mu.exec(e));){r+=ju(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=ju(e.slice(n))+"$",new RegExp(r)},Nu=(e,t,n,r)=>{const a=e.trim();if(!a)return null;const o=a.match(t),s=null==o?void 0:o.groups;if(!s)return null;const i=s.YYYY?Number(s.YYYY):s.YY?Number(s.YY)+2e3:n.year,l=s.MM?Number(s.MM):n.month,c=s.DD?Number(s.DD):n.day,d=s.HH?Number(s.HH):n.hour,u=s.mm?Number(s.mm):n.minute;try{return Pd.ZonedDateTime.from({timeZone:r,year:i,month:l,day:c,hour:d,minute:u,second:n.second,millisecond:n.millisecond,microsecond:n.microsecond,nanosecond:n.nanosecond})}catch(e){return null}},Iu=e=>{const t=e;if(t.timeZoneId&&"string"==typeof t.timeZoneId)return t.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const n=e.timeZone;return n&&"string"==typeof n.id?n.id:"string"==typeof t.timeZone?t.timeZone:Pd.Now.timeZoneId()},Hu=(e,t,n)=>{var r,a,o,s,i,l,c,d,u,h,g,f,m,v,y,p,x,b,D,w,C,E,M,k;if(!e){const e=null!=t?t:n?Iu(n):Pd.Now.timeZoneId();return null!=n?n:Pd.Now.zonedDateTimeISO(e)}if(Ld(e)){const n=null!=t?t:Pd.Now.timeZoneId(),r=`${e.year}-${ku(e.month)}-${ku(e.day)}T00:00:00[${n}]`;return Pd.ZonedDateTime.from(r)}if("hour"in e&&!("timeZone"in e)){const n=null!=t?t:Pd.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(n)}catch(e){}return Pd.ZonedDateTime.from({timeZone:n,year:e.year,month:e.month,day:e.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!==(s=e.nanosecond)&&void 0!==s?s:0})}try{return Pd.ZonedDateTime.from(e)}catch(r){const a=e,o=null!==(u=null!==(d=null!==(c=null!==(l="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(i=null==a?void 0:a.timeZone)||void 0===i?void 0:i.id)&&void 0!==l?l:null==a?void 0:a.timeZoneId)&&void 0!==c?c:t)&&void 0!==d?d:n?Iu(n):void 0)&&void 0!==u?u:Pd.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const s=null!=n?n:Pd.Now.zonedDateTimeISO(o);return Pd.ZonedDateTime.from({timeZone:o,year:null!==(h=null==a?void 0:a.year)&&void 0!==h?h:s.year,month:null!==(g=null==a?void 0:a.month)&&void 0!==g?g:s.month,day:null!==(f=null==a?void 0:a.day)&&void 0!==f?f:s.day,hour:null!==(v=null!==(m=null==a?void 0:a.hour)&&void 0!==m?m:null==n?void 0:n.hour)&&void 0!==v?v:0,minute:null!==(p=null!==(y=null==a?void 0:a.minute)&&void 0!==y?y:null==n?void 0:n.minute)&&void 0!==p?p:0,second:null!==(b=null!==(x=null==a?void 0:a.second)&&void 0!==x?x:null==n?void 0:n.second)&&void 0!==b?b:0,millisecond:null!==(w=null!==(D=null==a?void 0:a.millisecond)&&void 0!==D?D:null==n?void 0:n.millisecond)&&void 0!==w?w:0,microsecond:null!==(E=null!==(C=null==a?void 0:a.microsecond)&&void 0!==C?C:null==n?void 0:n.microsecond)&&void 0!==E?E:0,nanosecond:null!==(k=null!==(M=null==a?void 0:a.nanosecond)&&void 0!==M?M:null==n?void 0:n.nanosecond)&&void 0!==k?k:0})}},Ou=(e,t,n)=>{const r=Tu(t,n),a={YYYY:e.year.toString(),YY:ku(e.year%100),MM:ku(e.month),DD:ku(e.day),HH:ku(e.hour),mm:ku(e.minute)};return r.replace(Mu,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})},Ru=Array.from({length:24},(e,t)=>t),Pu=Array.from({length:60},(e,t)=>t),$u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Yu=(e,t)=>Pd.PlainDate.compare(e,t),Lu=({value:e,format:o="YYYY-MM-DD HH:mm",showTimeFormat:s="HH:mm",showTime:i=!0,onChange:l,onOk:c,timeZone:d,disabled:u=!1,placement:h="bottomLeft",autoAdjustOverflow:g=!0,getPopupContainer:f,matchTriggerWidth:m=!1})=>{const v=t.useMemo(()=>void 0===i||("object"==typeof i||Boolean(i)),[i]),y=t.useMemo(()=>v?"object"==typeof i&&(null==i?void 0:i.format)?i.format:s:"",[v,i,s]),p=t.useMemo(()=>Tu(o,y),[o,y]),x=t.useMemo(()=>Su(p),[p]),b=t.useMemo(()=>{const t=null!=d?d:Ld(e[0])?Ld(e[1])?Pd.Now.timeZoneId():Iu(e[1]):Iu(e[0]),n=Hu(e[0],t);return[n,Hu(e[1],t,n)]},[e,d]),[D,w]=t.useState(b),C=t.useRef(b),[E,M]=t.useState("start"),[k,T]=t.useState([Ou(b[0],o,y),Ou(b[1],o,y)]),j=t.useRef([Ou(b[0],o,y),Ou(b[1],o,y)]),S=t.useRef(b),[N,I]=t.useState(b[0].toPlainDate().with({day:1})),[H,O]=t.useState(!1),R=t.useCallback(e=>{O(e)},[]),[P,$]=t.useState(h),Y=t.useRef(h),L=t.useRef(null),V=t.useRef(null),A=t.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),Z=t.useRef(!1);t.useEffect(()=>{j.current=k},[k]),t.useEffect(()=>{S.current=D},[D]),t.useEffect(()=>{const e=C.current,t=0!==Pd.ZonedDateTime.compare(e[0],b[0]),n=0!==Pd.ZonedDateTime.compare(e[1],b[1]);(t||n)&&w(b),C.current=b},[b]),t.useEffect(()=>{I(b[0].toPlainDate().with({day:1}))},[b[0]]);const F=t.useCallback((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,s=(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:s})},[]),z=t.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=A.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&F(n,r,0)})})})},[F]);t.useEffect(()=>{H&&v&&z(E)},[E,H,z,v]);const B=D[0].epochMilliseconds,W=D[0].offsetNanoseconds,U=D[1].epochMilliseconds,q=D[1].offsetNanoseconds;t.useEffect(()=>{const[e,t]=S.current,n=Ou(e,o,y),r=Ou(t,o,y),[a,s]=j.current;a===n&&s===r||(j.current=[n,r],T([n,r]))},[B,W,U,q,o,y]),t.useEffect(()=>{if(!H)return;const e=e=>{var t,n;const r=e.target;if(null===(t=L.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-rangepicker-popup]")||R(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[H]),t.useEffect(()=>{H||(M("start"),Z.current||w(b),Z.current=!1)},[H,b]);const _=t.useCallback(e=>{l&&l(e,[Ou(e[0],o,y),Ou(e[1],o,y)])},[y,o,l]),G=t.useCallback(e=>{c&&c(e,[Ou(e[0],o,y),Ou(e[1],o,y)])},[y,o,c]),X=t.useCallback((e,t)=>{w(n=>{const r=[...n];if("start"===e){const e=Hu(r[1],Iu(t),t),n=Pd.ZonedDateTime.compare(t,e)>0?t:e;return[t,n]}const a=Hu(r[0],Iu(t),t);return[Pd.ZonedDateTime.compare(a,t)>0?t:a,t]})},[]),J=t.useCallback((e,t)=>{if(u)return;const n="start"===e?0:1;w(r=>{const a=r[n],o=a.with({hour:t,minute:a.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Hu(r[1],Iu(o),o);return[o,Pd.ZonedDateTime.compare(o,e)>0?o:e]}const s=Hu(r[0],Iu(o),o);return[Pd.ZonedDateTime.compare(s,o)>0?o:s,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=A.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&F(t,n,0)})})},[u]),K=t.useCallback((e,t)=>{if(u)return;const n="start"===e?0:1;w(r=>{const a=r[n].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Hu(r[1],Iu(a),a);return[a,Pd.ZonedDateTime.compare(a,e)>0?a:e]}const o=Hu(r[0],Iu(a),a);return[Pd.ZonedDateTime.compare(o,a)>0?a:o,a]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=A.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&F(t,n,0)})})},[u]),Q=t.useCallback((e,t)=>{const n="start"===e?0:1;T(e=>{const r=[...e];return r[n]=t,r})},[]),ee=t.useCallback((e,t)=>{const n="start"===e?0:1,r=D[n],a=Iu(r),s=Nu(t,x,r,a);if(s){X(e,s);const t=s.toPlainDate().with({day:1});return I(t),"start"===e&&M("end"),!0}return T(e=>{const t=[...e];return t[n]=Ou(D[n],o,y),t}),!1},[D,y,o,x,X]),te=t.useCallback(e=>t=>{Q(e,t.target.value)},[Q]),ne=t.useCallback(e=>t=>{var n;if(u)return;if(H)return;const r=t.relatedTarget;r&&(null===(n=L.current)||void 0===n?void 0:n.contains(r))||ee(e,t.target.value)},[ee,u,H]),re=t.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),ee(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ee]),ae=e=>{I(t=>t.add({months:e}).with({day:1}))},oe=e=>{I(t=>t.add({years:e}).with({day:1}))},se=t.useMemo(()=>{const e=N,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[N]),ie=D[0].toPlainDate(),le=D[1].toPlainDate(),ce=t.useCallback((e=h)=>{if(!g||!L.current)return e;const t=L.current.getBoundingClientRect(),n=m?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,s=t.right;let i=e;return i.startsWith("bottom")&&r<500&&a>r?i=i.replace("bottom","top"):i.startsWith("top")&&a<500&&r>a&&(i=i.replace("top","bottom")),i.endsWith("Left")&&o<n&&s>o?i=i.replace("Left","Right"):i.endsWith("Right")&&s<n&&o>s&&(i=i.replace("Right","Left")),i},[g,m,h]),de=t.useCallback(()=>{const e=ce();Y.current!==e&&(Y.current=e,$(e))},[ce]),ue=e=>{if(u)return;M(e);const t=D["start"===e?0:1].toPlainDate().with({day:1});I(t);const n=ce();Y.current!==n&&(Y.current=n,$(n)),R(!0)};t.useEffect(()=>{if(!H)return;de();const e=()=>de();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[H,de]);const he=n.jsx("div",{ref:V,style:(()=>{if(!L.current)return{};const e=L.current.getBoundingClientRect(),t=Y.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,m&&(n.width=`${e.width}px`),n})(),"data-rangepicker-popup":"true",children:n.jsxs("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:m?"100%":void 0},children:[n.jsxs("div",{className:"flex gap-1",children:[n.jsxs("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{type:"button",disabled:u,onClick:()=>oe(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronsLeft,{width:14,height:12})}),n.jsx("button",{type:"button",disabled:u,onClick:()=>ae(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronLeft,{width:14,height:12})})]}),n.jsxs("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[$u[N.month-1]," ",N.year]}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{type:"button",disabled:u,onClick:()=>ae(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronRight,{width:14,height:12})}),n.jsx("button",{type:"button",disabled:u,onClick:()=>oe(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronsRight,{width:14,height:12})})]})]}),n.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pb-3 pt-2 text-center text-[11px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(e=>n.jsx("span",{children:e},e))}),n.jsx("div",{className:"grid grid-cols-7 gap-2 px-1 ",children:se.map(e=>{const t=e.month!==N.month,r=0===Yu(e,ie),a=0===Yu(e,le),o=Yu(e,ie)>=0&&Yu(e,le)<=0,s=r||a?"bg-blue-500 text-white font-semibold":o?"bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-300":t?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/30 hover:text-blue-600 dark:hover:text-blue-300";return n.jsx("button",{type:"button",disabled:u,onClick:()=>(e=>{if(u)return;const t=(e,t)=>{var n,r,a,o;const s=Iu(e);return Pd.ZonedDateTime.from({timeZone:s,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(n=e.second)&&void 0!==n?n:0,millisecond:null!==(r=e.millisecond)&&void 0!==r?r:0,microsecond:null!==(a=e.microsecond)&&void 0!==a?a:0,nanosecond:null!==(o=e.nanosecond)&&void 0!==o?o:0})};if("start"===E){const n=t(D[0],e),r=D[1].epochMilliseconds-D[0].epochMilliseconds,a=n.add({milliseconds:r});return void w([n,a])}const n=t(D[1],e),r=D[1].epochMilliseconds-D[0].epochMilliseconds;if(Pd.ZonedDateTime.compare(n,D[0])<0){const n=t(D[0],e),a=n.add({milliseconds:r});return void w([n,a])}const a=[D[0],n];w(a),I(n.toPlainDate().with({day:1}))})(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${s}`,children:e.day},e.toString())})})]}),v&&n.jsx("div",{className:"flex flex-1 justify-end sm:w-32",children:(()=>{const e=E,t=D["start"===e?0:1],r=t.minute,a=Pu.includes(r)?Pu:[...Pu,r].sort((e,t)=>e-t);return n.jsxs("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[n.jsx("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:n.jsxs("div",{className:"text-lg py-1 text-slate-700 dark:text-gray-300",children:[t.hour.toString().padStart(2,"0"),":",t.minute.toString().padStart(2,"0")]})}),n.jsxs("div",{className:"flex p-1",children:[n.jsx("div",{className:"w-14",children:n.jsx("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Hour",ref:t=>{A.current[e].hour=t},children:Ru.map(r=>{const a=r===t.hour;return n.jsx("button",{type:"button",role:"option","aria-selected":a,disabled:u,onClick:()=>J(e,r),className:"flex h-8 w-full items-center justify-center text-sm transition "+(a?"bg-blue-500 text-white font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/30 hover:text-blue-600 dark:hover:text-blue-300"),"data-active":a?"true":void 0,children:ku(r)},r)})})}),n.jsx("div",{className:"w-14",children:n.jsx("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Minute",ref:t=>{A.current[e].minute=t},children:a.map(t=>{const a=t===r;return n.jsx("button",{type:"button",role:"option","aria-selected":a,disabled:u,onClick:()=>K(e,t),className:"flex h-8 w-full items-center justify-center text-sm transition "+(a?"bg-blue-500 text-white font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/30 hover:text-blue-600 dark:hover:text-blue-300"),"data-active":a?"true":void 0,children:ku(t)},t)})})})]})]})})()})]}),n.jsx("div",{className:"flex justify-end",children:n.jsx("button",{type:"button",onClick:()=>{Z.current=!0,_(D),G(D),R(!1)},disabled:u,className:"inline-flex items-center rounded-full bg-blue-500 px-4 py-1.5 text-sm font-semibold text-white shadow-sm transition hover:bg-blue-400 disabled:cursor-not-allowed disabled:bg-slate-300",children:"OK"})})]})});return n.jsxs("div",{className:"relative max-w-[400px]",ref:L,children:[n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(u?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":H?"border-blue-500 bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-blue-300 dark:hover:border-blue-500"),children:[n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:n.jsx("input",{type:"text",value:k[0],onChange:te("start"),onFocus:()=>ue("start"),onClick:()=>ue("start"),onBlur:ne("start"),onKeyDown:re("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-0 "+(u?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===E&&H?" bg-white dark:bg-gray-700 text-blue-600 dark:text-blue-400":"border-transparent bg-transparent text-slate-700 dark:text-gray-300 hover:border-blue-200 dark:hover:border-blue-400"),placeholder:p,autoComplete:"off",disabled:u})}),n.jsx(r.MoveRight,{className:"text-slate-400 dark:text-gray-500"}),n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:n.jsx("input",{type:"text",value:k[1],onChange:te("end"),onFocus:()=>ue("end"),onClick:()=>ue("end"),onBlur:ne("end"),onKeyDown:re("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-0 "+(u?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===E&&H?"bg-white dark:bg-gray-700 text-blue-600 dark:text-blue-400":"border-transparent bg-transparent text-slate-700 dark:text-gray-300 hover:border-blue-200 dark:hover:border-blue-400"),placeholder:p,autoComplete:"off",disabled:u})})]}),H&&(f?a.createPortal(he,f()):a.createPortal(he,document.body))]})},Vu=({event:e,isOpen:r,isAllDay:o,onEventUpdate:s,onEventDelete:i,onClose:l})=>{var c;const d=t.useMemo(()=>v().getVisible().map(e=>({label:e.name,value:e.id})),[]),u=t.useMemo(()=>Ld(e.start)?e.end&&!Ld(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||Pd.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||Pd.Now.timeZoneId(),[e.end,e.start]),h=t=>{const[n,r]=t;s(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:r.toPlainDate()}))};if(!r)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const g=n.jsxs("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[n.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/80",onClick:e=>{const t=e.target;t.closest("[data-rangepicker-popup]")||t===e.currentTarget&&l()}}),n.jsxs("div",{className:"relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[n.jsx("button",{onClick:l,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),n.jsxs("div",{className:"pr-8",children:[n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Event Title"}),n.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[n.jsx("div",{className:"flex-1",children:n.jsx("input",{type:"text",value:e.title,onChange:t=>{s(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition"})}),n.jsx(Eu,{options:d,value:e.calendarId||"blue",onChange:t=>{s(Object.assign(Object.assign({},e),{calendarId:t}))}})]}),o?n.jsxs("div",{className:"mb-4",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Date Range"}),n.jsx(Lu,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:u,matchTriggerWidth:!0,onChange:h,onOk:h})]}):n.jsxs("div",{className:"mb-4",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Time Range"}),n.jsx(Lu,{value:[e.start,e.end],timeZone:u,onChange:t=>{const[n,r]=t;s(Object.assign(Object.assign({},e),{start:n,end:r}))},onOk:t=>{const[n,r]=t;s(Object.assign(Object.assign({},e),{start:n,end:r}))}})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Note"}),n.jsx("textarea",{value:null!==(c=e.description)&&void 0!==c?c:"",onChange:t=>s(Object.assign(Object.assign({},e),{description:t.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition resize-none",placeholder:"Add a note..."})]}),n.jsxs("div",{className:"flex space-x-2",children:[o?n.jsx("button",{className:"px-3 py-2 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded-lg hover:bg-blue-200 dark:hover:bg-blue-800 text-sm font-medium transition",onClick:()=>{const t=Ld(e.start)?e.start:e.start.toPlainDate(),n=Pd.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:Pd.Now.timeZoneId()}),r=Pd.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:Pd.Now.timeZoneId()});s(Object.assign(Object.assign({},e),{allDay:!1,start:n,end:r}))},children:"Set as Timed Event"}):n.jsx("button",{className:"px-3 py-2 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded-lg hover:bg-blue-200 dark:hover:bg-blue-800 text-sm font-medium transition",onClick:()=>{const t=Ld(e.start)?e.start:e.start.toPlainDate();s(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:"Set as All-day"}),n.jsx("button",{className:"px-3 py-2 bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 rounded-lg hover:bg-red-200 dark:hover:bg-red-800 text-sm font-medium transition",onClick:()=>{i(e.id),l()},children:"Delete"})]})]})]})]}),f=document.body;return f?a.createPortal(g,f):null},Au=t.createContext(void 0),Zu=()=>"undefined"==typeof window?"light":window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Fu=({children:e,initialTheme:r="light",onThemeChange:a})=>{const[o,s]=t.useState(r),[i,l]=t.useState(Zu),c="auto"===o?i:o;t.useEffect(()=>{s(r)},[r]);const d=t.useCallback(e=>{s(e)},[]);t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";l(t)},n=e.matches?"dark":"light";return l(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),t.useEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement;e.classList.remove("light","dark"),e.classList.add(c),e.setAttribute("data-theme",c)},[c,o,i]),t.useEffect(()=>{a&&a(o,c)},[o,c,a]);const u={theme:o,effectiveTheme:c,setTheme:d};return n.jsx(Au.Provider,{value:u,children:e})},zu=()=>{const e=t.useContext(Au);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Bu=({originalComponent:e,app:r,config:a,customDetailPanelContent:o,customEventDetailDialog:s,calendarRef:i,switcherMode:l,meta:c})=>{const d=r.getPlugin("events"),u=a.enableDrag?r.getPlugin("drag"):void 0,h=r.getCurrentDate(),g=r.state.currentView,f=r.getEvents(),m=t.useCallback(e=>{d?d.update(e.id,e):r.updateEvent(e.id,e)},[d,r]),v=t.useCallback(e=>{d?d.delete(e):r.deleteEvent(e)},[d,r]),y=t.useCallback(e=>{d?d.add(e):r.addEvent(e)},[d,r]),p=t.useCallback(e=>{r.setCurrentDate(e)},[r]),x=t.useCallback(e=>{r.changeView(e)},[r]),b=t.useMemo(()=>{const e=a.viewConfig||{};return u&&Object.assign(e,a.dragConfig||{}),d&&Object.assign(e,a.eventsConfig||{}),e},[a,u,d]),D=t.useMemo(()=>({app:r,currentDate:h,currentView:g,events:f,onEventUpdate:m,onEventDelete:v,onEventCreate:y,onDateChange:p,onViewChange:x,config:b}),[r,h,g,f,m,v,y,p,x,b]),w=t.useMemo(()=>{const e={currentDate:h,events:f,setEvents:e=>{f.forEach(e=>v(e.id)),e.forEach(e=>y(e))},updateEvent:m,deleteEvent:v,addEvent:y,goToPrevious:()=>{const e=new Date(h);switch(g){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}p(e)},goToNext:()=>{const e=new Date(h);switch(g){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}p(e)},goToToday:()=>{p(new Date)},changeView:x,selectDate:p};return Object.assign(Object.assign({calendar:e},D),{eventsService:d,dragService:u,customDetailPanelContent:o,customEventDetailDialog:s,calendarRef:i,switcherMode:l,meta:c})},[h,f,g,m,v,y,p,x,D,d,u,o,s,i,l,c]);return n.jsx(e,Object.assign({},w))},Wu=e=>{if(!e)return"";let t,n,r;e instanceof Date?(t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate()):Ld(e)?(t=e.year,n=e.month,r=e.day):(!function(){Pd.ZonedDateTime}(e),t=e.year,n=e.month,r=e.day);const a=String(n).padStart(2,"0");return`${String(r).padStart(2,"0")}/${a}/${t}`};function Uu(e){return!("hour"in e)}function qu(e){return"hour"in e&&!("timeZone"in e)}function _u(e){return"timeZone"in e}function Gu(e){return Pd.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Xu(e){return Pd.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 Ju(e,t){return Pd.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 Ku(e,t=!1){if(e instanceof Pd.PlainDate||e instanceof Pd.PlainDateTime)return e;if(e instanceof Date)return t?Gu(e):Xu(e);throw new Error("Invalid time type: "+typeof e)}function Qu(e,t){if(e instanceof Pd.ZonedDateTime)return e;if(e instanceof Date)return Ju(e,t);throw new Error("Invalid time type: "+typeof e)}function eh(e){var t;const n=Ku(e.start,e.allDay),r=Ku(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 th(e){const t=Qu(e.start,e.timeZone),n=Qu(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}}const nh=e=>{const t=e.title.toLowerCase();return t.includes("holiday")||t.includes("vacation")||t.includes("假期")?n.jsx(r.Gift,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?n.jsx(r.Heart,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?n.jsx(r.Star,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?n.jsx(r.MapPin,{className:"h-3 w-3"}):n.jsx(r.CalendarDays,{className:"h-3 w-3"})},rh=(e,t)=>{const n=[],r=new Date(t);return r.setDate(t.getDate()+6),r.setHours(23,59,59,999),e.forEach(e=>{const a=Fd(e.start),o=Fd(e.end),s=new Date(a);s.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-a.getTime();e>0&&e<864e5&&(l=new Date(i),l.setDate(l.getDate()-1))}}const c=qd(s,l)>0;if(!c&&e.allDay){if(s<t||s>r)return;const a=Math.floor((s.getTime()-t.getTime())/864e5);return void(a>=0&&a<=6&&n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:a,endDayIndex:a,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!c)return;const d=s;let u;if(e.allDay)u=new Date(i),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(i),u.setHours(23,59,59,999)):(u=new Date(i),u.setTime(u.getTime()-1))}if(u<t||d>r)return;const h=d<t?t:d,g=u>r?r:u,f=Math.max(0,Math.floor((h.getTime()-t.getTime())/864e5)),m=Math.min(6,Math.floor((g.getTime()-t.getTime())/864e5)),v=d>=t,y=u<=r,p=0===f||6===m;let x;x=v&&y?"single":v?p&&6===m?"start-week-end":"start":y?p&&0===f?"end-week-start":"end":"middle";const b=qd(d,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:f,endDayIndex:m,segmentType:x,totalDays:b,segmentIndex:0,isFirstSegment:v,isLastSegment:y})}),n},ah=(e,t)=>{if(e.allDay)return[];const n=Fd(e.start),r=Fd(e.end),a=new Date(n);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);const s=qd(a,o);if(0===s)return[];const i=0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds(),l=r.getTime()-n.getTime();if(!e.allDay&&1===s&&!i&&l<864e5)return[];const c=i?s:Math.max(0,s-1),d=[];for(let e=0;e<=c;e++){const o=new Date(a);o.setDate(a.getDate()+e);const s=Math.floor((o.getTime()-t.getTime())/864e5);if(s<0||s>6)continue;const l=0===e,u=e===c,h=l?n.getHours()+n.getMinutes()/60:0,g=u&&i?r.getHours()+r.getMinutes()/60:24;d.push({dayIndex:s,startHour:h,endHour:g,isFirst:l,isLast:u})}return d},oh=t.memo(({segment:e,segmentIndex:t,isDragging:r,isResizing:a=!1,isSelected:o=!1,onMoveStart:s,onResizeStart:i})=>{const l=17*t,c=`calc(${e.startDayIndex/7*100}% + 2px)`,d=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,u=t=>{const r="left"===t;return(r?e.isFirstSegment:e.isLastSegment)&&i?n.jsx("div",{className:`resize-handle absolute ${r?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e.event,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},h=e.event.calendarId||"blue",g=e.endDayIndex-e.startDayIndex+1;return n.jsxs("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign({left:c,width:d,top:l-2+"px",height:"16px",borderRadius:(f=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"}[f]),pointerEvents:"auto",zIndex:10},o||r?{backgroundColor:tu(h),color:"#fff"}:{backgroundColor:Qd(h),color:eu(h)}),"data-segment-days":g,onMouseDown:t=>{t.preventDefault(),t.stopPropagation();t.target.closest(".resize-handle")||s(t,e.event)},title:`${e.event.title} (${Wu(e.event.start)} - ${Wu(e.event.end)})`,children:[u("left"),n.jsx("div",{className:"flex-1 min-w-0",style:{cursor:a?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,r=e.event.calendarId||"blue",a=Gd(e.event.start),o=iu(e.event),s=au(a),i=au(o);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return n.jsxs("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[e.isFirstSegment&&n.jsx("div",{className:"flex-shrink-0 mr-1",children:n.jsx("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:nu(r),width:"12px",height:"12px"},children:nh(e.event)})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"truncate font-medium text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&n.jsx("div",{className:"flex-shrink-0 ml-1 text-white/80 dark:text-white/90",children:n.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?e.event.title:"···",c=e.endDayIndex-e.startDayIndex+1,d=c>1?{position:"absolute",right:`calc(${c>1?(c-1)/c*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return n.jsxs("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[n.jsx("span",{className:"inline-block w-[3px] h-3 rounded-full flex-shrink-0 mr-1",style:{backgroundColor:nu(r)}}),n.jsx("div",{className:"flex items-center min-w-0 flex-1",children:n.jsx("span",{className:"truncate font-medium text-xs",children:l})}),e.isFirstSegment&&n.jsx("span",{className:"text-xs font-medium whitespace-nowrap "+(1===c?"ml-2":""),style:d,children:s}),e.isLastSegment&&!e.event.allDay&&24!==o&&n.jsx("span",{className:"text-xs font-medium whitespace-nowrap ml-auto",children:`ends ${i}`})]})})()}),u("right")]});var f});oh.displayName="MultiDayEvent";const sh=({event:e,position:r,panelRef:o,isAllDay:s,eventVisibility:i,calendarRef:l,selectedEventElementRef:c,onEventUpdate:d,onEventDelete:u})=>{var h;const{effectiveTheme:g}=zu(),f="dark"===g?"#1f2937":"white",m="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",y=t.useMemo(()=>v().getVisible().map(e=>({label:e.name,value:e.id})),[]),p=t.useMemo(()=>Ld(e.start)?e.end&&!Ld(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||Pd.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||Pd.Now.timeZoneId(),[e.end,e.start]),x=t=>{const[n,r]=t;d(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:r.toPlainDate()}))},b=(()=>{var e;let t={};if("sticky-top"===i){const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-r.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(r.isSunday?`1px solid ${m}`:"none"),borderTop:""+(r.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${m}`),borderBottom:""+(r.isSunday?"none":`1px solid ${m}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const e=o.current;let n=200;if(e){const t=e.getBoundingClientRect(),r=window.getComputedStyle(e),a=parseInt(r.paddingBottom,10)||0,o=parseInt(r.borderBottomWidth,10)||0;n=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:f,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 ${m}`:"none"),borderTop:""+(r.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${m}`),borderBottom:""+(r.isSunday?"none":`1px solid ${m}`)}}else if(r&&c.current&&l.current){const e=c.current.getBoundingClientRect(),n=l.current.querySelector(".calendar-content");if(n){const a=n.getBoundingClientRect(),s=Math.max(e.top,a.top),i=Math.min(e.bottom,a.bottom),l=Math.max(0,i-s);let c;c=l===e.height?e.top+e.height/2:l>0?s+l/2:e.top+e.height/2;const d=c-r.top,u=o.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,r=parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,v=Math.max(g,Math.min(h,d));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:v-6+"px",borderRight:""+(r.isSunday?`1px solid ${m}`:"none"),borderTop:""+(r.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${m}`),borderBottom:""+(r.isSunday?"none":`1px solid ${m}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),D=n.jsxs("div",{ref:o,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg p-4 ","data-event-detail-panel":"true",style:{top:`${r.top}px`,left:`${r.left}px`,zIndex:9999,pointerEvents:"auto"},children:[n.jsx("div",{style:b}),n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Event Title"}),n.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[n.jsx("div",{className:"flex-1",children:n.jsx("input",{type:"text",value:e.title,onChange:t=>{d(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition"})}),n.jsx(Eu,{options:y,value:e.calendarId||"blue",onChange:t=>{d(Object.assign(Object.assign({},e),{calendarId:t}))}})]}),s?n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Date Range"}),n.jsx(Lu,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,onChange:x,onOk:x})]}):n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Time Range"}),n.jsx(Lu,{value:[e.start,e.end],timeZone:p,onChange:t=>{const[n,r]=t;d(Object.assign(Object.assign({},e),{start:n,end:r}))},onOk:t=>{const[n,r]=t;d(Object.assign(Object.assign({},e),{start:n,end:r}))}})]}),n.jsxs("div",{className:"mb-3",children:[n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Note"}),n.jsx("textarea",{value:null!==(h=e.description)&&void 0!==h?h:"",onChange:t=>d(Object.assign(Object.assign({},e),{description:t.target.value})),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition resize-none",placeholder:"Add a note..."})]}),n.jsxs("div",{className:"flex space-x-2",children:[s?n.jsx("button",{className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded hover:bg-blue-200 dark:hover:bg-blue-800 text-xs font-medium transition",onClick:()=>{const t=Ld(e.start)?e.start:e.start.toPlainDate(),n=Pd.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:Pd.Now.timeZoneId()}),r=Pd.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:Pd.Now.timeZoneId()});d(Object.assign(Object.assign({},e),{allDay:!1,start:n,end:r}))},children:"Set as Timed Event"}):n.jsx("button",{className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded hover:bg-blue-200 dark:hover:bg-blue-800 text-xs font-medium transition",onClick:()=>{const t=Ld(e.start)?e.start:e.start.toPlainDate();d(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:"Set as All-day"}),n.jsx("button",{className:"px-2 py-1 bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 rounded hover:bg-red-200 dark:hover:bg-red-800 text-xs font-medium transition",onClick:()=>u(e.id),children:"Delete"})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const w=document.body;return w?a.createPortal(D,w):null},ih=({event:e,position:t,panelRef:r,isAllDay:o,eventVisibility:s,calendarRef:i,selectedEventElementRef:l,onEventUpdate:c,onEventDelete:d,onClose:u,contentRenderer:h})=>{const{effectiveTheme:g}=zu(),f="dark"===g?"#1f2937":"white",m="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",v=(()=>{var e;let n={};if("sticky-top"===s){const r=null===(e=i.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(r){const e=r.getBoundingClientRect().top+3-t.top;n=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${m}`:"none"),borderTop:""+(t.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${m}`),borderBottom:""+(t.isSunday?"none":`1px solid ${m}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===s){const e=r.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}n={position:"absolute",width:"12px",height:"12px",backgroundColor:f,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 ${m}`:"none"),borderTop:""+(t.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${m}`),borderBottom:""+(t.isSunday?"none":`1px solid ${m}`)}}else if(t&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),s=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),l=Math.max(0,i-s);let c;c=l===e.height?e.top+e.height/2:l>0?s+l/2:e.top+e.height/2;const d=c-t.top,u=r.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,r=parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,v=Math.max(g,Math.min(h,d));n=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:v-6+"px",borderRight:""+(t.isSunday?`1px solid ${m}`:"none"),borderTop:""+(t.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${m}`),borderBottom:""+(t.isSunday?"none":`1px solid ${m}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return n})(),y=n.jsxs("div",{ref:r,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg p-3","data-event-detail-panel":"true",style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===g?"#1f2937":"#ffffff"},children:[n.jsx("div",{style:v}),n.jsx(h,{event:e,isAllDay:o,onEventUpdate:c,onEventDelete:d,onClose:u})]});return a.createPortal(y,document.body)},lh=({event:e,layout:o,isAllDay:s=!1,allDayHeight:i=28,calendarRef:l,isBeingDragged:c=!1,isBeingResized:d=!1,isDayView:u=!1,isMonthView:h=!1,isMultiDay:g=!1,segment:f,segmentIndex:m=0,hourHeight:v,firstHour:y,selectedEventId:p,detailPanelEventId:x,onMoveStart:b,onResizeStart:D,onEventUpdate:w,onEventDelete:C,newlyCreatedEventId:E,onDetailPanelOpen:M,onEventSelect:k,onDetailPanelToggle:T,customDetailPanelContent:j,customEventDetailDialog:S,multiDaySegmentInfo:N})=>{const[I,L]=t.useState(!1),V=g&&f?`${e.id}::${f.id}`:void 0!==(null==N?void 0:N.dayIndex)?`${e.id}::day-${N.dayIndex}`:e.id,A=x===V,[Z,F]=t.useState(null),[z,B]=t.useState("visible"),W=t.useRef(null),q=t.useRef(null),_=t.useRef(null),X=t.useRef(null),J=void 0!==p?p===e.id:I,K=e=>{if(!l.current)return null;const t=l.current.getBoundingClientRect();if(h){const n=t.width/7,r=e-t.left,a=Math.floor(r/n);return Number.isFinite(a)?Math.max(0,Math.min(6,a)):null}const n=u?1:7,r=(t.width-80)/n,a=e-t.left-80,o=Math.floor(a/r);return Number.isFinite(o)?Math.max(0,Math.min(n-1,o)):null},Q=e=>{if(!l.current)return null;const t=l.current.getBoundingClientRect();if(h){const n=t.width/7;return{left:t.left+e*n,width:n}}if(u){const e=t.width-80;return{left:t.left+80,width:e}}const n=(t.width-80)/7;return{left:t.left+80+e*n,width:n}},ee=e=>{X.current=e},te=()=>{var t;if(null!==X.current)return X.current;if(x===V){const e=V.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==N?void 0:N.dayIndex)?N.dayIndex:f?f.startDayIndex:null!==(t=e.day)&&void 0!==t?t:0},ne=t.useCallback(()=>{if(!_.current||!l.current||!q.current)return;const t=l.current.getBoundingClientRect(),n=te(),r=Q(n);let a,o;if(r)a=r.left,o=r.width;else if(h)o=t.width/7,a=t.left+n*o;else{const e=80;o=(t.width-e)/7,a=t.left+e+n*o}const s=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var r,o,c,d,m;if(!q.current)return;if(!_.current)return;const p=q.current.getBoundingClientRect(),x=p.width,b=p.height;let D,w,C;if("sticky-top"===z||"sticky-bottom"===z){const t=null===(r=l.current)||void 0===r?void 0:r.querySelector(".calendar-content");if(!t)return;const n=N?N.startHour:Gd(e.start),a=N?N.endHour:iu(e),s=(n-y)*v,i=Math.max((a-n)*v,v/4),c=t.getBoundingClientRect(),d=t.scrollTop,u=c.top+s-d,h=null===(o=W.current)||void 0===o?void 0:o.getBoundingClientRect();if(!h)return;C={top:u,bottom:u+i,left:h.left,right:h.right,width:h.width,height:i,x:h.x,y:u,toJSON:()=>({})}}else C=_.current.getBoundingClientRect();if(h&&g&&f){const e=Q(n),r=null!==(c=null==e?void 0:e.width)&&void 0!==c?c:t.width/7,a=null!==(d=null==e?void 0:e.left)&&void 0!==d?d:t.left+n*r,o=a+r;C={top:C.top,bottom:C.bottom,left:a,right:o,width:o-a,height:C.height,x:a,y:C.top,toJSON:()=>({})}}if(("sticky-top"===z||"sticky-bottom"===z)&&!h){const e=null!==(m=null==N?void 0:N.dayIndex)&&void 0!==m?m:te(),n=80,r=u?1:7,a=(t.width-n)/r,o=Q(e),s=o?o.left:t.left+n+e*a,i=o?o.width:a,l=Math.max(0,u?C.width:i-3),c=u?C.left:s;C=Object.assign(Object.assign({},C),{left:c,right:c+l,width:l})}const E=s-C.right,M=C.left-t.left;D=E>=x+20?C.right+10:M>=x+20?C.left-x-10:E>M?Math.max(t.left+10,s-x-10):t.left+10;const k=C.top-b/2+C.height/2,T=Math.max(10,t.top+10),j=i-10;w=k<T?T:k+b>j?j-b:k,F(e=>e?Object.assign(Object.assign({},e),{top:w,left:D,isSunday:D<a}):null)})},[l,e.day,e.start,e.end,z,h,y,v,g,null==f?void 0:f.startDayIndex,null==f?void 0:f.endDayIndex,null==N?void 0:N.dayIndex,x,V]),re=t.useCallback(()=>{if(!I||!A||!W.current||!l.current||s||h)return;const t=l.current.querySelector(".calendar-content");if(!t)return;const n=N?N.startHour:Gd(e.start),r=N?N.endHour:iu(e),a=(n-y)*v,o=a+Math.max((r-n)*v,v/4),i=t.getBoundingClientRect(),c=t.scrollTop;let d=o<c+6,u=a>c+i.height-6;const g=i.bottom<0,f=i.top>window.innerHeight;g?d=!0:f&&(u=!0),B(d?"sticky-top":u?"sticky-bottom":"visible"),ne()},[I,A,l,s,h,Gd(e.start),iu(e),y,v,ne,null==N?void 0:N.startHour,null==N?void 0:N.endHour,null==N?void 0:N.dayIndex,x,V]);t.useEffect(()=>{var e,t;if(!I||!A||s)return;const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const r=()=>re(),a=()=>{re(),ne()},o=[n];let i=null===(t=l.current)||void 0===t?void 0:t.parentElement;for(;i;){const e=window.getComputedStyle(i),t=e.overflowY,n=e.overflowX;"auto"!==t&&"scroll"!==t&&"auto"!==n&&"scroll"!==n||o.push(i),i=i.parentElement}return o.forEach(e=>{e.addEventListener("scroll",r)}),window.addEventListener("scroll",r,!0),window.addEventListener("resize",a),re(),()=>{o.forEach(e=>{e.removeEventListener("scroll",r)}),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",a)}},[I,A,s,re,ne,l,z]),t.useEffect(()=>{if(!J&&!A)return;const e=e=>{var t,n;const r=e.target,a=null===(t=W.current)||void 0===t?void 0:t.contains(r),o=null===(n=q.current)||void 0===n?void 0:n.contains(r),s=r.closest("[data-event-detail-dialog]"),i=r.closest("[data-rangepicker-popup]");A?a||o||s||i||(k&&k(null),ee(null),L(!1),null==T||T(null)):J&&!a&&(k&&k(null),ee(null),L(!1),null==T||T(null))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[J,A,k,T]),t.useEffect(()=>{g&&f&&!f.isFirstSegment||E!==e.id||A||setTimeout(()=>{var t,n;if(W.current){let r=W.current;if(g){const e=W.current.querySelector("div");e&&(r=e)}g?f?ee(f.startDayIndex):void 0!==(null==N?void 0:N.dayIndex)?ee(N.dayIndex):ee(null!==(t=e.day)&&void 0!==t?t:null):ee(null!==(n=e.day)&&void 0!==n?n:null),_.current=r,L(!0),null==T||T(V),F({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{ne()})}null==M||M()},150)},[E,e.id,A,M,ne,g,f,T,V]);const ae=()=>f?n.jsx(oh,{segment:f,segmentIndex:null!=m?m:0,isDragging:c||J,isResizing:d,isSelected:J,onMoveStart:b||(()=>{}),onResizeStart:D}):null,oe=()=>{if(g&&f){const{segmentType:e}=f;if("single"===e||"start"===e)return O;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 O},se=e.calendarId||"blue";return n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:W,"data-event-id":e.id,className:h?`\n ${H}\n ${s?oe():"rounded-sm"}\n `:`\n ${H}\n shadow-sm\n ${s?oe():"rounded-sm"}\n `,style:Object.assign(Object.assign({},(()=>{var t,n,r,a,d,p;if(h)return{opacity:c?.3:1,zIndex:J||A?1e3:1};if(s){const e={height:i-4+"px",opacity:c?.3:1,zIndex:J||A?1e3:1},t=m*i;if(Object.assign(e,{top:`${t}px`}),u)Object.assign(e,{width:"100%",left:"0px",right:"2px"});else if(g&&f){const t=(f.endDayIndex-f.startDayIndex+1)/7*100,n=f.startDayIndex/7*100,r=2,a=f.isFirstSegment?r:0,o=a+(f.isLastSegment?r:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:a>0?`calc(${n}% + ${a}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"calc(100% - 3px)",left:"0px",position:"relative"});return e}const x=N?N.startHour:Gd(e.start),b=N?N.endHour:iu(e),D={top:`${(x-y)*v+3}px`,height:Math.max((b-x)*v,v/4)-4+"px",position:"absolute",opacity:c?.3:1,zIndex:J||A?1e3:null!==(t=null==o?void 0:o.zIndex)&&void 0!==t?t:1};if(J&&A&&("sticky-top"===z||"sticky-bottom"===z)){const e=null===(n=l.current)||void 0===n?void 0:n.getBoundingClientRect();if(e){const t=null!==(r=null==N?void 0:N.dayIndex)&&void 0!==r?r:te(),n=80,o=u?1:7;let s=(e.width-n)/o,i=e.left+n+t*s;h&&(s=e.width/7,i=e.left+t*s);const c=Q(t);c&&(i=c.left,s=c.width);let g=null===(a=l.current)||void 0===a?void 0:a.querySelector(".calendar-content");g||(g=null===(d=l.current)||void 0===d?void 0:d.querySelector(".calendar-renderer"));const f=null==g?void 0:g.getBoundingClientRect(),m=null===(p=W.current)||void 0===p?void 0:p.getBoundingClientRect(),v=null==m?void 0:m.left,y=null==m?void 0:m.width;if("sticky-top"===z){let t=f?f.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:`${u?v:i}px`,width:`${u?y:s-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let x=f?f.bottom:e.bottom;return x=Math.min(x,window.innerHeight),x=Math.min(x,e.bottom),x=Math.max(x,e.top+6),x=Math.max(x,6),{position:"fixed",top:x-6+"px",left:`${u?v:i}px`,width:`${u?y:s-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}return o&&!s?Object.assign(Object.assign({},D),{left:`${o.left}%`,width:o.width-1+"%",right:"auto"}):Object.assign(Object.assign({},D),{left:"0px",right:"3px"})})()),J?{backgroundColor:tu(se),color:"#fff"}:{backgroundColor:Qd(se),color:eu(se)}),onClick:t=>{var n,r;if(t.preventDefault(),t.stopPropagation(),g)if(f){const e=K(t.clientX);if(null!==e){const t=Math.min(Math.max(e,f.startDayIndex),f.endDayIndex);ee(t)}else ee(f.startDayIndex)}else void 0!==(null==N?void 0:N.dayIndex)?ee(N.dayIndex):ee(null!==(n=e.day)&&void 0!==n?n:null);else ee(null!==(r=e.day)&&void 0!==r?r:null);k?k(e.id):L(!0),null==T||T(null),F(null)},onDoubleClick:t=>{var n,r;t.preventDefault(),t.stopPropagation();let a=t.currentTarget;if(g){const e=a.querySelector("div");e&&(a=e)}if(_.current=a,g)if(f){const e=K(t.clientX);if(null!==e){const t=Math.min(Math.max(e,f.startDayIndex),f.endDayIndex);ee(t)}else ee(f.startDayIndex)}else void 0!==(null==N?void 0:N.dayIndex)?ee(N.dayIndex):ee(null!==(n=e.day)&&void 0!==n?n:null);else ee(null!==(r=e.day)&&void 0!==r?r:null);new Promise(t=>{if(!l.current||s||h)return void t();const n=l.current.querySelector(".calendar-content");if(!n)return void t();const r=N?N.startHour:Gd(e.start),a=N?N.endHour:iu(e),o=(r-y)*v,i=o+Math.max((a-r)*v,v/4),c=n.scrollTop,d=n.clientHeight;if(o>=c&&i<=c+d)return void t();const u=((r+a)/2-y)*v-d/2,g=n.scrollHeight-d,f=Math.max(0,Math.min(g,u));n.scrollTo({top:f,behavior:"smooth"}),setTimeout(()=>{t()},300)}).then(()=>{L(!0),null==T||T(V),F({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{ne()})})},onMouseDown:b?t=>{var n;if(N){const r=Object.assign(Object.assign({},e),{day:null!==(n=N.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:N});b(t,r)}else b(t,e)}:void 0,children:h?g&&f?ae():e.allDay?g?ae():n.jsxs("div",{className:"text-xs px-1 mb-0.5 rounded truncate cursor-pointer flex items-center",children:[e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?n.jsx("span",{className:`inline-block ${G} flex-shrink-0 ${J?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):n.jsx(r.CalendarDays,{className:`${$} ${J?"text-white":""}`}),n.jsx("span",{className:"truncate "+(J?"text-white":""),children:e.title})]}):(()=>{const t=`${Math.floor(Gd(e.start)).toString().padStart(2,"0")}:${Math.round(Gd(e.start)%1*60).toString().padStart(2,"0")}`;return n.jsxs("div",{className:"text-xs mb-0.5 cursor-pointer flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[n.jsx("span",{style:{backgroundColor:nu(e.calendarId||"blue")},className:`inline-block w-[3px] h-3 ${G} flex-shrink-0 rounded-full`}),n.jsx("span",{className:"truncate "+(J?"text-white":""),children:e.title})]}),n.jsx("span",{className:`${U} ml-1 flex-shrink-0 ${J?"text-white":""}`,style:J?void 0:{opacity:.8},children:t})]})})():e.allDay?n.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[D&&n.jsx("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),D(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),n.jsx(r.CalendarDays,{className:$}),n.jsx("div",{className:`${R} pr-1`,style:{lineHeight:"1.2"},children:e.title}),D&&n.jsx("div",{className:Y,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),D(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}):(()=>{const t=N?N.startHour:Gd(e.start),r=N?N.endHour:iu(e),a=r-t,o=!N||N.isFirst,s=!N||N.isLast;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:P,style:{backgroundColor:nu(e.calendarId||"blue")}}),n.jsxs("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(iu(e)-Gd(e.start)<=.25?"px-1 py-0":"p-1"),children:[n.jsx("div",{className:`${R} pr-1`,style:{lineHeight:a<=.25?"1.2":"normal"},children:e.title}),a>.5&&n.jsx("div",{className:"text-xs opacity-80 truncate",children:N?`${au(t)} - ${au(r)}`:ou(e)})]}),D&&n.jsxs(n.Fragment,{children:[o&&n.jsx("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>D(t,e,"top")}),s&&n.jsx("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>D(t,e,"bottom")}),!o&&s&&N&&n.jsx("div",{className:Y,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),D(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})})()}),A&&n.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!A)return null;const t=()=>{k&&k(null),ee(null),L(!1),null==T||T(null)};if(S){const r=S,o={event:e,isOpen:A,isAllDay:s,onEventUpdate:w,onEventDelete:C,onClose:t};if("undefined"==typeof window||"undefined"==typeof document)return null;const i=document.body;return i?a.createPortal(n.jsx(r,Object.assign({},o)),i):null}return Z?j?n.jsx(ih,{event:e,position:Z,panelRef:q,isAllDay:s,eventVisibility:z,calendarRef:l,selectedEventElementRef:_,onEventUpdate:w,onEventDelete:C,onClose:t,contentRenderer:j}):n.jsx(sh,{event:e,position:Z,panelRef:q,isAllDay:s,eventVisibility:z,calendarRef:l,selectedEventElementRef:_,onEventUpdate:w,onEventDelete:C,onClose:t}):null})()]})};function ch(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:Gd(e.start),_endHour:e.allDay?0:iu(e)})}function dh(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:Gd(e.start)}function uh(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:iu(e)}const hh=.25,gh=.5,fh=25,mh=1,vh=.9;class yh{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(ch);this.clearAllParentChildRelations(n);const r=new Map,a=n.filter(e=>!e.allDay);if(0===a.length)return r;const o=this.groupOverlappingEvents(a);for(let e=0;e<o.length;e++){const n=o[e];1===n.length?this.setSingleEventLayout(n[0],r):this.calculateComplexGroupLayout(n,r,t)}return r}static clearAllParentChildRelations(e){for(const t of e)t.parentId=void 0,t.children=[]}static setParentChildRelation(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}static eventsOverlap(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(dh(e)<uh(t)&&dh(t)<uh(e))}static groupOverlappingEvents(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)||this.eventsOverlap(t,r)&&(a.push(r),o.push(r),n.add(r.id))}t.push(a)}return t}static setSingleEventLayout(e,t){t.set(e.id,{id:e.id,left:0,width:100-vh,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const r=[...e].sort((e,t)=>{const n=dh(e),r=dh(t);if(n!==r)return n-r;return uh(t)-dh(t)-(uh(e)-dh(e))}),a=this.analyzeParallelGroups(r),o=this.buildNestedStructure(a,e);this.calculateLayoutFromStructure(o,t,n)}static analyzeParallelGroups(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(dh(r)-dh(t))<=hh&&(a.push(t),n.add(t.id))}a.sort((e,t)=>dh(e)-dh(t));const o={events:a,startHour:Math.min(...a.map(e=>dh(e))),endHour:Math.max(...a.map(e=>uh(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}static shouldBeParallel(e,t){if(!this.eventsOverlap(e,t))return!1;const n=Math.abs(dh(e)-dh(t));if(n<=hh)return!0;if(n>hh&&n<gh)return!0;return!!this.checkExtendedEventParallel(e,t)}static checkExtendedEventParallel(e,t){return!!this.eventsOverlap(e,t)&&(!!this.isExtendedEventParallel(e,t)||!!this.isExtendedEventParallel(t,e))}static isExtendedEventParallel(e,t){const n=uh(e)-dh(e);if(n<1.25)return!1;const r=dh(e)+.4*n,a=dh(t)>=r,o=this.eventsOverlap(e,t);return a&&o}static buildNestedStructure(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],s=o.events.map(e=>a.get(e.id));let i=!1;for(let l=n-1;l>=0&&!i;l--){const n=e[l],c=n.events.map(e=>a.get(e.id)),d={events:c,startHour:n.startHour,endHour:n.endHour};if(this.canGroupContain(d,{events:s,startHour:o.startHour,endHour:o.endHour})){const e=this.optimizeChildAssignments(s,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)}i=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),this.rebalanceLoadByGroups(e,n),o}static findAlternateBranchRoot(e,t,n){const r=n.get(e.id);if(!r)return null;let a=r;for(;a.parent&&a.depth>1;)a=a.parent;if(1!==a.depth)return null;const o=a.parent;if(!o)return null;const s=o.children.filter(e=>1===e.depth&&e.event.id!==a.event.id);let i=1/0,l=null;for(const e of s){const t=this.calculateBranchLoad(e);t<i&&(i=t,l=e)}return l?l.event:null}static calculateBranchLoad(e){let t=0;function n(e){t++;for(const t of e.children)n(t)}for(const t of e.children)n(t);return t}static canGroupContain(e,t){const n=t.startHour-e.startHour;if(this.checkLoadBalanceParallel(e,t))return!1;if(n<gh)return!1;let r=!1;for(const n of e.events){for(const e of t.events)if(this.canEventContain(n,e)){r=!0;break}if(r)break}return r}static checkLoadBalanceParallel(e,t){for(const n of e.events)for(const e of t.events){if(!this.eventsOverlap(n,e))continue;const t=Math.abs(dh(e)-dh(n));if(t<=hh)return!0;if(t>hh&&t<gh)return!0}return!1}static canEventContain(e,t){const n=dh(e)<=dh(t)&&uh(e)>=uh(t),r=dh(e)<=dh(t)&&dh(t)<uh(e)&&this.eventsOverlap(e,t);return n||r}static optimizeChildAssignments(e,t,n){const r=[];if(1===e.length){const a=this.findBestParentInGroup(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),this.setParentChildRelation(a,e[0])),r}if(1===t.events.length){const n=t.events[0];for(const t of e)this.canEventContain(n,t)&&(r.push({child:t,parent:n}),this.setParentChildRelation(n,t));return r}const a=t.events.filter(t=>e.every(e=>this.canEventContain(t,e)));if(0===a.length){for(const a of e){const o=this.findBestParentInGroup(a,t,n);if(o)r.push({child:a,parent:o}),this.setParentChildRelation(o,a);else{const t=e.find(e=>e.id!==a.id&&this.eventsOverlap(e,a));if(t){const e=this.buildTempNodeMap(n),o=this.findAlternateBranchRoot(t,Array.from(e.values()),e);o&&(r.push({child:a,parent:o}),this.setParentChildRelation(o,a))}}}return r}const o=[...e].sort((e,t)=>{const n=uh(e)-dh(e);return uh(t)-dh(t)-n});if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],s=o.slice(t*e,(t+1)*e);for(const e of s)r.push({child:e,parent:n}),this.setParentChildRelation(n,e)}return r}for(let e=0;e<o.length;e++){const t=o[e],n=this.findParentWithMinLoadFromEvents(t,a,o);n&&(r.push({child:t,parent:n}),this.setParentChildRelation(n,t))}return r}static buildTempNodeMap(e){const t=new Map;for(const n of e){const e={event:n,children:[],parent:null,depth:0,isProcessed:!1};t.set(n.id,e)}for(const n of e)if(n.parentId){const e=t.get(n.id),r=t.get(n.parentId);e&&r&&(e.parent=r,e.depth=r.depth+1,r.children.push(e))}return t}static findParentWithMinLoadFromEvents(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=a.map(e=>e.children).flat(),s=uh(e)-dh(e),i=s>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?uh(t)-dh(t):0}));n.every(e=>uh(e)-dh(e)===s);return i?a[0]:a[a.length-1]}static findBestParentInGroup(e,t,n){const r=t.events.filter(t=>this.canEventContain(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(e=>({parent:e,load:e.children.length,hasParallelSibling:!1}));for(const t of a)for(const r of t.parent.children){const a=n.find(e=>e.id===r);if(a&&this.shouldBeParallel(e,a)){t.hasParallelSibling=!0;break}}a.sort((t,n)=>{if(t.load!==n.load)return t.load-n.load;if(t.hasParallelSibling!==n.hasParallelSibling)return t.hasParallelSibling?-1:1;if(t.load!==n.load)return t.load-n.load;return Math.abs(dh(e)-dh(t.parent))-Math.abs(dh(e)-dh(n.parent))});return a[0].parent}static calculateLayoutFromStructure(e,t,n={}){const r=100-vh;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,r,t,n);else{const a=e.length,o=(r-mh*(a-1))/a;e.forEach((e,r)=>{const a=r*(o+mh);this.calculateNodeLayoutWithVirtualParallel(e,a,Math.max(o,fh),t,n)})}}static calculateNodeLayoutWithVirtualParallel(e,t,n,r,a={}){let o=e.depth*this.getIndentStepPercent(a.viewType);if(e.isProcessed){const t=this.findBranchRootIndent(e,a.viewType);null!==t&&(o=t)}let s=0;const i="day"===a.viewType;1===e.depth?s=i?.5:1.5:2===e.depth?s=i?-.01:-1:e.depth>=3&&(s=i?.55:-3.5);const l=t+o+s;let c=n-(o+s);if(l+c>t+n&&(c=t+n-l,console.warn(`⚠️ ${e.event.title}'s width exceeds parent event range, adjusted to: ${c.toFixed(1)}%`)),r.set(e.event.id,{id:e.event.id,left:l,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:o*(a.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),0===e.children.length)return;const d=[...e.children].sort((e,t)=>{const n=uh(e.event)-dh(e.event);return uh(t.event)-dh(t.event)-n});if(1===d.length)this.calculateNodeLayoutWithVirtualParallel(d[0],l,c,r,a);else{const e=this.shouldChildrenBeParallel(d.map(e=>e.event));e?this.calculateParallelChildrenLayout(d,l,c,r,a):d.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,l,c,r,a)})}}static calculateParallelChildrenLayout(e,t,n,r,a={}){const o=e.length,s=e[0].depth,i=s*this.getIndentStepPercent(a.viewType);let l;const c="day"===a.viewType;l=1===s?c?.5:1.5:2===s?c?-.01:-1:c?.55:-3.5;const d=t+i+l,u=n-(i+l);if(u<=0)return void e.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,t,n,r,a)});let h;h=1===s?mh*(c?.15:.3):mh*(c?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=d+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:i*(a.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>{const n=uh(e.event)-dh(e.event);return uh(t.event)-dh(t.event)-n});if(1===t.length)this.calculateNodeLayoutWithVirtualParallel(t[0],n,g,r,a);else{const e=this.shouldChildrenBeParallel(t.map(e=>e.event));e?this.calculateParallelChildrenLayout(t,n,g,r,a):t.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,n,g,r,a)})}}})}static findBranchRootIndent(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;if(1===n.depth){return n.depth*this.getIndentStepPercent(t)}return null}static shouldChildrenBeParallel(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(this.shouldBeParallel(e[t],e[n]))return!0;return!1}static calculateEventImportance(e){const t=uh(e)-dh(e);return Math.max(.1,Math.min(1,t/4))}static countDescendants(e){let t=0;for(const n of e.children)t+=1+this.countDescendants(n);return t}static findTransferableLeaf(e,t){const n=[];return this.collectLeaves(e,n),n.find(e=>this.canEventContain(t.event,e.event))||n[0]}static collectLeaves(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>this.collectLeaves(e,t))}static transferNode(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children;let r=null;for(const t of n){if(this.shouldBeParallel(e.event,t.event))break;if(this.canEventContain(t.event,e.event)){r=t;break}}r?(e.parent=r,e.depth=r.depth+1,r.children.push(e),this.setParentChildRelation(r.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),this.setParentChildRelation(t.event,e.event))}static calculateParentLoads(e,t){var n,r;const a=[],o=null===(r=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===r?void 0:r.depth;if(void 0===o)return a;const s=t.filter(e=>e.depth===o);for(const e of s){const t=this.countDescendants(e);a.push({node:e,load:t})}return a.sort((e,t)=>t.load-e.load),a}static needsRebalancing(e){if(e.length<2)return!1;return e[0].load-e[e.length-1].load>=2}static rebalanceGroupLoad(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],r=e[e.length-1];if(n.load-r.load<2)break;const a=this.findTransferableLeaf(n.node,r.node);if(!a)break;this.transferNode(a,r.node),n.load--,r.load++,t++}}static rebalanceLoadByGroups(e,t){for(let n=e.length-1;n>=1;n--){const r=e[n].events.map(e=>t.find(t=>t.event.id===e.id)),a=this.calculateParentLoads(r,t);this.needsRebalancing(a)&&this.rebalanceGroupLoad(a)}}}const ph={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>nu(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const xh=e=>{const{viewType:n,onEventsUpdate:r}=e,a=n===exports.ViewType.MONTH,o=t.useRef({active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,resizeDirection:null,hourOffset:null,duration:0,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}),s=t.useRef({x:0,y:0}),i=t.useMemo(()=>a?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1},[a]),[l,c]=t.useState(i),d=t.useMemo(()=>function(e,t){let n=null,r=0;const a=function(...a){const o=Date.now(),s=t-(o-r);s<=0||s>t?(n&&(clearTimeout(n),n=null),r=o,e.apply(this,a)):n||(n=setTimeout(()=>{r=Date.now(),n=null,e.apply(this,a)},s))};return a.cancel=()=>{n&&(clearTimeout(n),n=null),r=0},a}((e,t)=>r(e,"resize"===t),a?16:8),[a,r]),u=t.useCallback(()=>{c(a?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1}),o.current={active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,duration:0,resizeDirection:null,hourOffset:null,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}},[a]);return{dragRef:o,currentDragRef:s,dragState:l,setDragState:c,resetDragState:u,throttledSetEvents:d}},bh={renderAllDayContent:({title:e,color:t})=>n.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[n.jsx(r.CalendarDays,{className:"h-3 w-3 mr-1 text-white"}),n.jsx("div",{className:"font-medium text-xs truncate pr-1 text-white",children:e})]}),renderRegularContent:({drag:e,title:t,layout:r,formatTime:a,getLineColor:o,getDynamicPadding:s,color:i})=>n.jsxs(n.Fragment,{children:[n.jsx("div",{className:P,style:{backgroundColor:o(i||"blue")}}),n.jsxs("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${s(e)}`,children:[n.jsx("div",{className:"font-medium text-xs truncate pr-1 text-white",style:{lineHeight:e.endHour-e.startHour<=.25?"1.2":"normal"},children:t}),!e.allDay&&e.endHour-e.startHour>.5&&n.jsxs("div",{className:"text-xs truncate time-display text-white opacity-90",children:[a(e.startHour)," - ",a(e.endHour)]})]})]}),renderDefaultContent:({drag:e,title:t,allDay:r})=>r?n.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0",children:[n.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 002 2z"})}),n.jsx("div",{className:"font-medium text-xs truncate pr-1",style:{lineHeight:1.2},children:t})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute left-0.5 top-1 bottom-1 w-0.5 rounded-full bg-blue-600 dark:bg-blue-400"}),n.jsx("div",{className:"h-full flex flex-col overflow-hidden pl-3 p-1",children:n.jsx("div",{className:"font-medium text-xs truncate pr-1 text-blue-900 dark:text-blue-100",children:t})})]})},Dh=({drag:e,color:t,title:r,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l,renderer:c=bh})=>{const d=r||(o?"New All-day Event":"New Event");return n.jsx("div",{className:"drag-indicator-content",children:t?o?c.renderAllDayContent({drag:e,color:t,title:d,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l}):c.renderRegularContent({drag:e,color:t,title:d,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l}):c.renderDefaultContent({drag:e,color:t,title:d,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l})})},wh=({event:e,isCreating:t,isMultiDay:a=!1,startDate:o,endDate:s})=>{const i=(()=>{if(t)return{title:"New Event",icon:n.jsx(r.Calendar,{className:"h-3 w-3"}),showDateRange:!1};if(a&&o&&s){const t=qd(o,s)+1;return{title:e.title.replace(/ \(\d+天\)$/,""),showDateRange:!0,duration:t}}return{title:e.title,showDateRange:!1}})();return n.jsxs("div",{className:"flex items-center space-x-2 text-white text-xs font-medium rounded-sm",children:[n.jsx("div",{className:"flex-shrink-0",children:i.icon}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"truncate font-medium",children:i.title})})]})},Ch=e=>{const n=t.useMemo(()=>Object.assign(Object.assign({},ph),e),[e]),{viewType:r}=n,a=r===exports.ViewType.MONTH,s=(e=>{const{calendarRef:n,allDayRowRef:r,viewType:a,HOUR_HEIGHT:o=72,FIRST_HOUR:s=0,LAST_HOUR:i=24,TIME_COLUMN_WIDTH:l=80}=e,c=a===exports.ViewType.MONTH,d=a===exports.ViewType.WEEK,u=t.useCallback(e=>{if(c||!n.current)return s;const t=n.current.querySelector(".calendar-content");if(!t)return s;const r=t.getBoundingClientRect(),a=t.scrollTop,l=window.getComputedStyle(t),d=parseInt(l.paddingTop,10)||0,u=(e-r.top+a-d)/o+s;return Math.max(s,Math.min(i,u))},[n,s,o,i,c]),h=t.useCallback(e=>{if(c||!n.current)return 0;const t=n.current.getBoundingClientRect(),r=(t.width-l)/(d?7:1),a=e-t.left-l,o=Math.floor(a/r);return Math.max(0,Math.min(d?6:0,o))},[n,l,c,d]),g=t.useCallback(e=>{if(c||!n.current)return;const t=n.current.querySelector(".calendar-content");if(!t)return;const r=t.getBoundingClientRect();e<r.top?t.scrollTop+=e-r.top:e+40>r.bottom&&(t.scrollTop+=e+40-r.bottom)},[n,c]),f=t.useCallback(e=>{if(c||!(null==r?void 0:r.current))return!1;const t=r.current.getBoundingClientRect();return e>=t.top&&e<=t.bottom},[r,c]),m=t.useMemo(()=>864e5,[]);return{pixelYToHour:u,getColumnDayIndex:h,checkIfInAllDayArea:f,handleDirectScroll:g,daysDifference:t.useCallback((e,t)=>qd(e,t),[]),addDaysToDate:t.useCallback((e,t)=>_d(e,t),[]),getTargetDateFromPosition:t.useCallback((e,t)=>{if(a!==exports.ViewType.MONTH||!n.current)return null;const r=document.elementFromPoint(e,t);if(!r)return null;let o=r,s=0;for(;o&&!o.hasAttribute("data-date")&&s<10;)o=o.parentElement,s++;if(o&&o.hasAttribute("data-date")){const e=o.getAttribute("data-date");if(e)return new Date(e+"T00:00:00")}return null},[n,a]),ONE_DAY_MS:m}})(n),i=xh(n),l=(e=>{const{calendarRef:n,allDayRowRef:r,viewType:a,getLineColor:s,getDynamicPadding:i,renderer:l,HOUR_HEIGHT:c=72,FIRST_HOUR:d=0,TIME_COLUMN_WIDTH:u=80,ALL_DAY_HEIGHT:h=60}=e,g=a===exports.ViewType.MONTH,f=a===exports.ViewType.DAY,m=t.useRef(null),v=t.useRef(null),y=t.useRef(null),p=t.useCallback(()=>{v.current&&(v.current.unmount(),v.current=null),m.current&&(m.current.remove(),m.current=null),y.current=null},[]),x=t.useCallback((e,a,x,b,D)=>{var w,C,E,M,k,T,j,S,N;p();const I=document.createElement("div");if(I.style.position=g?"fixed":"absolute",I.style.pointerEvents="none",I.style.zIndex="1000",g){let n,r;if(I.style.opacity="0.9",D){const t=D.getBoundingClientRect(),a=null!==(C=null!==(w=e.currentSegmentDays)&&void 0!==w?w:e.eventDurationDays)&&void 0!==C?C:1;n=t.width/a,r=t.height,I.className=`rounded-sm shadow-sm ${D.className}`}else n=120,r=22,I.className="rounded text-xs px-2 py-1";I.style.width=`${n}px`,I.style.height=`${r}px`,I.style.left=e.startX-n/2+"px",I.style.top=e.startY-r/2+"px",document.body.appendChild(I),v.current=o.createRoot(I);const s=Vd(new Date),i=e.originalEvent||{id:String(Date.now()),color:a||"blue",title:x||"New Event",start:s,end:s,allDay:!1,day:0};v.current.render(t.createElement(wh,{event:i,isCreating:"create"===e.mode,targetDate:e.targetDate||null,startDate:e.originalStartDate||null,endDate:e.originalEndDate||null}))}else{if(D){const t=D.getBoundingClientRect();let a;if(a=e.allDay?null===(E=null==r?void 0:r.current)||void 0===E?void 0:E.getBoundingClientRect():null===(k=null===(M=n.current)||void 0===M?void 0:M.querySelector(".calendar-content"))||void 0===k?void 0:k.getBoundingClientRect(),a){if(e.allDay&&f)I.style.left=`${u}px`,I.style.top=D.offsetTop-2+"px",I.style.width=`calc(100% - ${u}px - 2px)`,I.style.height=`${t.height}px`;else if(e.allDay&&!f){const r=null===(T=n.current)||void 0===T?void 0:T.getBoundingClientRect();if(r){const n=(r.width-u)/7;I.style.left=`${u+e.dayIndex*n}px`,I.style.top=D.offsetTop-2+"px",I.style.width=n-2+"px",I.style.height=`${t.height}px`}}else{const n=(e.startHour-d)*c;I.style.left=t.left-a.left+"px",I.style.top=`${n+3}px`,I.style.width=`${t.width}px`,I.style.height=`${t.height}px`}I.className=D.className,I.style.opacity="0.8",I.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}}else if(e.allDay){const t=f?"100%":`calc((100% - ${u}px) / 7)`;I.style.top="2px",I.style.height=h-4+"px",I.style.marginBottom="3px",f?(I.style.left=`${u}px`,I.style.width=`calc(100% - ${u}px - 2px)`):(I.style.left=`calc(${u}px + (${t} * ${e.dayIndex}))`,I.style.width=`calc(${t} - 2px)`),I.className="rounded-xl shadow-sm"}else{const t=(e.startHour-d)*c,n=(e.endHour-e.startHour)*c;if(I.style.top=`${t+3}px`,I.style.height=n-4+"px",I.style.color="#fff",I.className="rounded-sm shadow-sm",b){if(f)I.style.left=`${u}px`,I.style.width=`calc(100% - ${u}px)`;else{const t=`calc((100% - ${u}px) / 7)`;I.style.left=`calc(${u}px + (${t} * ${e.dayIndex}) + (${t} * ${b.left/100}))`,I.style.width=`calc((${t} * ${b.width/100}))`}I.style.zIndex=String(1e3)}else{const t=f?`calc(100% - ${u}px)`:`calc((100% - ${u}px) / 7)`;I.style.left=f?`${u}px`:`calc(${u}px + (${t} * ${e.dayIndex}))`,I.style.width=t}}e.allDay?null===(j=null==r?void 0:r.current)||void 0===j||j.appendChild(I):null===(N=null===(S=n.current)||void 0===S?void 0:S.querySelector(".calendar-content"))||void 0===N||N.appendChild(I),y.current={drag:e,color:a,title:x,layout:b},v.current=o.createRoot(I),v.current.render(t.createElement(Dh,{drag:e,color:a,title:x,layout:b,allDay:e.allDay,formatTime:au,getLineColor:s||(()=>""),getDynamicPadding:i||(()=>"0px"),renderer:l}))}a?(I.style.backgroundColor=tu(a),I.style.color=eu(a)):I.className+=" bg-blue-50/70 text-blue-900 border border-dashed border-blue-400",m.current=I},[p,g,f,r,n,au,s,i,l,u,h,d,c]),b=t.useCallback((...e)=>{var a,o;const p=m.current;if(p)if(g){const[t,n]=e,r=parseFloat(p.style.width)||120,a=parseFloat(p.style.height)||22;requestAnimationFrame(()=>{p.style.left=t-r/2+"px",p.style.top=n-a/2+"px",p.style.transition="none"})}else{const[g,m,x,b=!1,D]=e;if(b&&p.parentElement!==(null==r?void 0:r.current))null===(a=null==r?void 0:r.current)||void 0===a||a.appendChild(p);else if(!b){const e=null===(o=n.current)||void 0===o?void 0:o.querySelector(".calendar-content");p.parentElement!==e&&(null==e||e.appendChild(p))}if(b){if(f)p.style.left=`${u}px`,p.style.width=`calc(100% - ${u}px - 2px)`;else{const e=`calc((100% - ${u}px) / 7)`;p.style.left=`calc(${u}px + (${e} * ${g}))`,p.style.width=`calc(${e} - 2px)`,p.style.top="2px"}p.style.height=h-4+"px",p.style.marginBottom="3px",p.className=p.className.replace("rounded-sm","rounded-xl")}else{const e=(m-d)*c,t=(x-m)*c;if(p.style.top=`${e+3}px`,p.style.height=t-4+"px",p.style.marginBottom="0",p.className=p.className.replace("rounded-xl","rounded-sm"),D){if(f)p.style.left=`${u}px`,p.style.width=`calc(100% - ${u}px)`;else{const e=`calc((100% - ${u}px) / 7)`;p.style.left=`calc(${u}px + (${e} * ${g}) + (${e} * ${D.left/100}))`,p.style.width=`calc((${e} * ${D.width/100}))`}p.style.zIndex=String(D.zIndex+10)}else{const e=f?`calc(100% - ${u}px)`:`calc((100% - ${u}px) / 7)`;p.style.left=f?`${u}px`:`calc(${u}px + (${e} * ${g}))`,p.style.width=e}}if(p.style.cursor="grabbing",v.current&&y.current){const e=Object.assign(Object.assign({},y.current.drag),{dayIndex:g,startHour:m,endHour:x,allDay:b});y.current.drag=e,v.current.render(t.createElement(Dh,{drag:e,color:y.current.color,title:y.current.title,layout:D||y.current.layout,allDay:b,formatTime:au,getLineColor:s||(()=>""),getDynamicPadding:i||(()=>"0px"),renderer:l}))}}},[g,r,au,n,f,h,u,d,c,s,i,l]);return{dragIndicatorRef:m,reactRootRef:v,removeDragIndicator:p,createDragIndicator:x,updateDragIndicator:b}})(n),c=(e=>{const{options:n,common:r,state:a,manager:o}=e,{viewType:s,onEventsUpdate:i,onEventCreate:l,onEventEdit:c,calculateNewEventLayout:d,calculateDragLayout:u,currentWeekStart:h,events:g,FIRST_HOUR:f=0,LAST_HOUR:m=24,MIN_DURATION:v=.25}=n,{dragRef:y,currentDragRef:p,setDragState:x,resetDragState:b,throttledSetEvents:D}=a,{removeDragIndicator:w,createDragIndicator:C,updateDragIndicator:E}=o,{pixelYToHour:M,getColumnDayIndex:k,checkIfInAllDayArea:T,handleDirectScroll:j,daysDifference:S,addDaysToDate:N,getTargetDateFromPosition:I}=r,H=s===exports.ViewType.MONTH,O=s===exports.ViewType.DAY,R=864e5,P=(e,t,n=!1)=>{const r=new Date(e);r.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);let o=Math.floor((a.getTime()-r.getTime())/R);if(o<=0)return 0;if(!n&&1===o){const n=0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds(),r=t.getTime()-e.getTime();if(n&&r<R)return 0}return o},$=t.useCallback(e=>{var t,n;e.preventDefault();const r=y.current;if(!r.active)return;"resize"===r.mode?r.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing";const a=T(e.clientY),o=O?r.dayIndex:k(e.clientX);if(a){if(!r.allDay){r.allDay=!0,r.startHour=0,r.endHour=0,r.eventDate=h?yu(h,o):new Date,w(),r.indicatorVisible=!1;const e=null==g?void 0:g.find(e=>e.id===r.eventId);C(r,null==e?void 0:e.calendarId,null==e?void 0:e.title),r.sourceElement=null,r.indicatorVisible=!0}r.dayIndex=o,x(e=>Object.assign(Object.assign({},e),{dayIndex:o,startHour:0,endHour:0,allDay:!0})),E(o,0,0,!0)}else{j(e.clientY);const a=M(e.clientY);if(null!==(t=r.startDragDayIndex)&&void 0!==t||r.originalDay,r.dayIndex,r.allDay){r.allDay=!1,r.startHour=su(a),r.endHour=r.startHour+1,r.duration=1,r.hourOffset=0,r.eventDate=h?yu(h,o):new Date,w(),r.indicatorVisible=!1;const e=null==g?void 0:g.find(e=>e.id===r.eventId);C(r,null==e?void 0:e.calendarId,null==e?void 0:e.title),r.sourceElement=null,r.indicatorVisible=!0}else{let e=su(a+(null!==(n=r.hourOffset)&&void 0!==n?n:0));e=Math.max(f,Math.min(m-r.duration,e)),r.startHour=e,r.endHour=e+r.duration}r.dayIndex=o,r.eventDate=h?yu(h,o):new Date,x(e=>Object.assign(Object.assign({},e),{dayIndex:o,startHour:su(r.startHour),endHour:su(r.endHour),allDay:!1}));let s=null;if("move"===r.mode&&r.eventId&&u){const e=null==g?void 0:g.find(e=>e.id===r.eventId);e&&(s=u(e,o,su(r.startHour),su(r.endHour)))}E(o,su(r.startHour),su(r.endHour),!1,s)}},[u,T,C,h,g,f,k,j,m,O,M,w,E,y,x]),Y=t.useCallback(()=>{document.body.style.cursor="default";const e=y.current;if(!e.active||"move"!==e.mode||!e.eventId)return;let t=e.startHour,n=e.endHour;e.allDay||(t=su(e.startHour),n=su(e.endHour),n-t<v&&(n=t+v)),null==i||i(r=>r.map(r=>{var a,o;if(r.id!==e.eventId)return r;h?yu(h,e.dayIndex):Fd(r.start);const s=null!==(a=e.startDragDayIndex)&&void 0!==a?a:e.originalDay,i=e.dayIndex-s;let l,c;if(e.allDay){const t=e.originalStartDate?new Date(e.originalStartDate):Fd(r.start);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()+i);const a=new Date(n);e.eventDurationDays&&e.eventDurationDays>0&&a.setDate(a.getDate()+e.eventDurationDays),l=Ad(n),c=Ad(Jd(a))}else{const a=Fd(r.start),s=Fd(r.end);if(P(a,s,null!==(o=r.allDay)&&void 0!==o&&o)>0){const e=new Date(a);e.setDate(e.getDate()+i);const t=new Date(s);t.setDate(t.getDate()+i),l=Vd(e),c=Vd(t)}else{const r=h?yu(h,e.dayIndex):new Date,a=Xd(r,t),o=Xd(r,n);l=Vd(a),c=Vd(o)}}const d=e.originalDay+i;return Object.assign(Object.assign({},r),{day:d,start:l,end:c,allDay:e.allDay})})),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",Y),w(),b()},[$,w,b,i,v,h,y]),L=t.useCallback(e=>{var t,n,r,a,o,s,i,l,c;e.preventDefault();const v=y.current;if(v.active)if("resize"===v.mode?H||v.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",H){if("resize"!==v.mode){if("move"===v.mode){const r=Math.hypot(e.clientX-v.startX,e.clientY-v.startY);!v.indicatorVisible&&r>=3&&(C(v,null===(t=v.originalEvent)||void 0===t?void 0:t.calendarId,null===(n=v.originalEvent)||void 0===n?void 0:n.title,null,v.sourceElement||void 0),v.indicatorVisible=!0)}v.indicatorVisible&&E(e.clientX,e.clientY)}const o=I(e.clientX,e.clientY);if(!o)return;if("resize"===v.mode&&v.originalEvent&&v.resizeDirection){const e=Fd(v.originalEvent.start);let t,n;const r=(e,t)=>{var n,r;e&&((null===(n=v.originalEvent)||void 0===n?void 0:n.allDay)?e.setHours(0,0,0,0):t&&e.setHours(t.hour,t.minute,null!==(r=t.second)&&void 0!==r?r:0,0))},a=v.originalStartTime,s=v.originalEndTime;if("left"===v.resizeDirection){t=new Date(o),r(t,a);const i=Fd(v.originalEvent.end)||e;n=new Date(i),r(n,s),t>n&&(t=n)}else{const i=Fd(v.originalEvent.start)||e;t=new Date(i),r(t,a),n=new Date(o),r(n,s),n<t&&(n=t)}v.originalStartDate=new Date(t.getTime()),v.originalEndDate=new Date(n.getTime());const i=v.originalEvent.allDay?Ad(t):Vd(t),l=v.originalEvent.allDay?Ad(n):Vd(n);D(e=>e.map(e=>e.id===v.eventId?Object.assign(Object.assign({},e),{start:i,end:l,title:e.title}):e),v.mode)}else if("move"===v.mode)if(v.originalStartDate&&v.originalEndDate){const e=S(v.originalStartDate,o),t=N(v.originalStartDate,e),n=N(v.originalEndDate,e);(null===(r=v.originalStartDate)||void 0===r?void 0:r.getTime())!==t.getTime()&&(v.originalStartDate=new Date(t.getTime()),v.originalEndDate=new Date(n.getTime()),v.targetDate=t)}else(null===(a=v.targetDate)||void 0===a?void 0:a.getTime())!==o.getTime()&&(v.targetDate=o)}else{j(e.clientY),v.lastClientY=e.clientY;const t=M(e.clientY);if("resize"===v.mode)if(v.allDay){const t=O?v.dayIndex:k(e.clientX);let n=v.originalStartDate||new Date,r=v.originalEndDate||new Date;"left"===v.resizeDirection?(n=h?yu(h,t):new Date,n>r&&(n=r)):"right"===v.resizeDirection&&(r=h?yu(h,t):new Date,r<n&&(r=n)),v.originalStartDate=new Date(n.getTime()),v.originalEndDate=new Date(r.getTime());const a=Ad(n),o=Ad(r);D(e=>e.map(e=>e.id!==v.eventId?e:Object.assign(Object.assign({},e),{start:a,end:o,allDay:!0})),v.mode)}else{let n=v.startHour,r=v.endHour;const a=null==g?void 0:g.find(e=>e.id===v.eventId);let c=v.dayIndex;if(a){const e=Fd(a.start),t=Fd(a.end),n=P(e,t,null!==(o=a.allDay)&&void 0!==o&&o);c=(null!==(s=a.day)&&void 0!==s?s:0)+n}let d=c,u=v.originalDay;if("top"===v.resizeDirection){const a=O?v.dayIndex:k(e.clientX),o=t+(null!==(i=null==v?void 0:v.hourOffset)&&void 0!==i?i:0);a<c?(u=a,n=Math.max(f,Math.min(m,o))):(u=c,o>v.originalEndHour?(n=v.originalEndHour,r=o,v.hourOffset=r-t):(n=Math.max(f,o),v.originalEndHour-n<ru&&(n=v.originalEndHour-ru)))}else if("bottom"===v.resizeDirection){const a=O?v.dayIndex:k(e.clientX),o=t+(null!==(l=null==v?void 0:v.hourOffset)&&void 0!==l?l:0);a!==v.dayIndex?(d=a,r=Math.max(f,Math.min(m,o))):o<v.originalStartHour?(r=v.originalStartHour,n=o,v.hourOffset=n-t):(r=Math.min(m,o),r-v.startHour<ru&&(r=v.startHour+ru))}else if("right"===v.resizeDirection){const t=O?v.dayIndex:k(e.clientX);d=Math.max(v.dayIndex,t)}d===u&&([n,r]=[Math.max(f,Math.min(n,r)),Math.min(m,Math.max(n,r))]);const[y,p]=[su(n),su(r)];v.startHour=n,v.endHour=r,v.dayIndex=u,D(e=>e.map(e=>{if(e.id!==v.eventId)return e;const t=Fd(e.start),n=Xd(h?yu(h,u):t,y),r=h?yu(h,d):t,a=Xd(r,p),o=Vd(n),s=Vd(a);return Object.assign(Object.assign({},e),{start:o,end:s,day:u})}),v.mode),E(v.dayIndex,y,p,!1)}else if("create"===v.mode){const n=su(t),[r,a]=e.clientY<v.startY?[n,Math.max(n+ru,v.endHour)]:[v.startHour,Math.max(v.startHour+ru,n)];v.startHour=r,v.endHour=a;const o=null==d?void 0:d(v.dayIndex,r,a);E(v.dayIndex,r,a,!1,o)}else if("move"===v.mode){const n=O?v.dayIndex:k(e.clientX);let r=su(t+(null!==(c=v.hourOffset)&&void 0!==c?c:0));r=Math.max(f,Math.min(m-v.duration,r));const a=r+v.duration;v.dayIndex=n,v.startHour=r,v.endHour=a;let o=null;if(v.eventId&&u){const e=null==g?void 0:g.find(e=>e.id===v.eventId);e&&(o=u(e,n,su(r),su(a)))}E(n,su(r),su(a),!1,o)}}},[H,O,E,I,D,S,N,f,m,d,k,M,j,u,g,y,C]),V=t.useCallback(e=>{var t,n;document.body.style.cursor="default";const r=y.current;if(r.active){if(H){if("resize"===r.mode&&r.eventId&&r.originalStartDate&&r.originalEndDate){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:r.originalStartDate,startDate:r.originalStartDate,endDate:r.originalEndDate}):e);const e=(null===(t=r.originalEvent)||void 0===t?void 0:t.allDay)||!1,n=e?Ad(r.originalStartDate):Vd(r.originalStartDate),a=e?Ad(r.originalEndDate):Vd(r.originalEndDate);D(e=>e.map(e=>e.id===r.eventId?Object.assign(Object.assign({},e),{start:n,end:a,title:e.title}):e))}else if("move"===r.mode)if(r.eventId&&r.originalStartDate&&r.originalEndDate){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:r.originalStartDate,startDate:r.originalStartDate,endDate:r.originalEndDate}):e);const e=(null===(n=r.originalEvent)||void 0===n?void 0:n.allDay)||!1,t=e?Ad(r.originalStartDate):Vd(r.originalStartDate),a=e?Ad(r.originalEndDate):Vd(r.originalEndDate);D(e=>e.map(e=>e.id===r.eventId?Object.assign(Object.assign({},e),{start:t,end:a,title:e.title}):e))}else{const t=I(e.clientX,e.clientY)||r.targetDate;r.eventId&&t&&(x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:t}):e),D(e=>e.map(e=>{if(e.id!==r.eventId)return e;const n=Fd(e.start),a=Fd(e.end),o=new Date(t);o.setHours(n.getHours(),n.getMinutes(),0,0);const s=new Date(t);s.setHours(a.getHours(),a.getMinutes(),0,0);const i=e.allDay?Ad(o):Vd(o),l=e.allDay?Ad(s):Vd(s);return Object.assign(Object.assign({},e),{start:i,end:l})})))}}else{let[e,t]=[su(r.startHour),su(r.endHour)];if(t-e<v&&("top"===r.resizeDirection?e=t-v:t=e+v),"create"===r.mode){const n=h?yu(h,r.dayIndex):new Date;x(n=>"dayIndex"in n?Object.assign(Object.assign({},n),{dayIndex:r.dayIndex,startHour:e,endHour:t}):n);const a=Xd(n,e),o=Xd(n,t),s=Vd(a),i=Vd(o);null==l||l({id:String(Date.now()),title:"New Event",day:r.dayIndex,start:s,end:i,calendarId:"blue",allDay:!1})}else"move"!==r.mode&&"resize"!==r.mode||(x(n=>"dayIndex"in n?Object.assign(Object.assign({},n),{dayIndex:r.dayIndex,startHour:e,endHour:t}):n),"move"===r.mode&&(null==i||i(e=>e.map(e=>e.id===r.eventId?Object.assign(Object.assign({},e),{day:r.dayIndex}):e))))}document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",V),w(),r.indicatorVisible=!1,r.sourceElement=null,b()}},[H,L,w,b,I,D,v,h,l,i,y,x]),A=t.useCallback((e,...t)=>{if(e.preventDefault(),e.stopPropagation(),!y.current.active)if(H){const[e]=t,n=new Date(e);n.setHours(9,0,0,0);const r=new Date(e);r.setHours(10,0,0,0);const a=Vd(n),o=Vd(r),s={id:String(Date.now()),title:"New Event",start:a,end:o,day:e.getDay(),calendarId:"blue",allDay:!1};null==l||l(s),c&&setTimeout(()=>{c(s)},50)}else{const[n,r]=t,a=y.current,o=su(r);Object.assign(a,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:n,startHour:o,endHour:o+1,allDay:!1,eventDate:h?yu(h,n):new Date}),x({active:!0,mode:"create",eventId:null,dayIndex:n,startHour:a.startHour,endHour:a.endHour,allDay:!1});const s=null==d?void 0:d(n,a.startHour,a.endHour);C(a,"blue","New Event",s),a.sourceElement=null,a.indicatorVisible=!0,document.addEventListener("mousemove",L),document.addEventListener("mouseup",V)}},[H,l,c,h,d,C,L,V,y,x]),Z=t.useCallback((e,t)=>{var n,r,a;if(e.preventDefault(),e.stopPropagation(),y.current.active)return;const o=y.current,s=e.currentTarget;if(H){p.current={x:e.clientX-s.getBoundingClientRect().left,y:e.clientY-s.getBoundingClientRect().top};const n=Fd(t.start),r=Fd(t.end);let a=1;if(t.allDay&&t.start&&t.end){const e=new Date(n);e.setHours(0,0,0,0);const t=new Date(r);t.setHours(0,0,0,0),a=Math.floor((t.getTime()-e.getTime())/864e5+1),a=Math.max(1,a)}const i=s.getAttribute("data-segment-days"),l=i?parseInt(i,10):a;o.active=!0,o.mode="move",o.eventId=t.id,o.startX=e.clientX,o.startY=e.clientY,o.targetDate=n,o.originalDate=n,o.originalEvent=Object.assign({},t),o.lastUpdateTime=Date.now(),o.originalStartDate=n,o.originalEndDate=r,o.eventDurationDays=a,o.currentSegmentDays=l,x({active:!0,mode:"move",eventId:t.id,targetDate:n,startDate:n,endDate:r}),o.sourceElement=s,o.indicatorVisible=!1,document.addEventListener("mousemove",L),document.addEventListener("mouseup",V)}else{const i=M(e.clientY),l=t._segmentInfo,c=!!l,d=c?l.dayIndex:null!==(n=t.day)&&void 0!==n?n:0,u=c?l.startHour:Gd(t.start);let h=0;if(t.allDay&&t.start&&t.end){const e=Fd(t.start);e.setHours(0,0,0,0);const n=Fd(t.end);n.setHours(0,0,0,0),h=Math.floor((n.getTime()-e.getTime())/864e5)}const g=Fd(t.start);if(Object.assign(o,{active:!0,mode:"move",eventId:t.id,startX:e.clientX,startY:e.clientY,dayIndex:d,startHour:u,endHour:c?l.endHour:iu(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:Gd(t.start),originalEndHour:iu(t),allDay:t.allDay||!1,eventDate:g,eventDurationDays:h,startDragDayIndex:d}),!t.allDay){o.hourOffset=u-i;const e=Fd(t.start),n=Fd(t.end).getTime()-e.getTime();o.duration=n/36e5}x({active:!0,mode:"move",eventId:t.id,dayIndex:null!==(a=t.day)&&void 0!==a?a:0,startHour:Gd(t.start),endHour:iu(t),allDay:t.allDay||!1}),C(o,t.calendarId,t.title,null,s),o.sourceElement=s,o.indicatorVisible=!0,document.addEventListener("mousemove",$),document.addEventListener("mouseup",Y)}},[H,C,V,L,$,Y,M,y,p,x]),F=t.useCallback((e,t,n)=>{var r,a,o,s,i;if(e.preventDefault(),e.stopPropagation(),y.current.active)return;const l=y.current;if(H){const r=Fd(t.start),a=Fd(t.start),o=Fd(t.end),s={hour:a.getHours(),minute:a.getMinutes(),second:a.getSeconds()},i={hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds()};l.active=!0,l.mode="resize",l.eventId=t.id,l.startX=e.clientX,l.startY=e.clientY,l.targetDate="left"===n?a:o,l.originalDate=r,l.originalEvent=Object.assign({},t),l.lastUpdateTime=Date.now(),l.resizeDirection=n,l.originalStartDate=a,l.originalEndDate=o,l.originalStartTime=s,l.originalEndTime=i,x({active:!0,mode:"resize",eventId:t.id,targetDate:"left"===n?a:o,startDate:a,endDate:o})}else if(t.allDay){const o=Fd(t.start),s=Fd(t.end);l.active=!0,l.mode="resize",l.eventId=t.id,l.startX=e.clientX,l.startY=e.clientY,l.allDay=!0,l.resizeDirection=n,l.originalStartDate=o,l.originalEndDate=s,l.originalEvent=Object.assign({},t),l.dayIndex=null!==(r=t.day)&&void 0!==r?r:0,x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(a=t.day)&&void 0!==a?a:0,startHour:0,endHour:0,allDay:!0})}else{const r=M(e.clientY);Object.assign(l,{active:!0,mode:"resize",eventId:t.id,startX:e.clientX,startY:e.clientY,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:Gd(t.start),endHour:iu(t),originalDay:null!==(s=t.day)&&void 0!==s?s:0,originalStartHour:Gd(t.start),originalEndHour:iu(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:r,hourOffset:"top"===n?Gd(t.start)-r:iu(t)-r,allDay:!1}),x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(i=t.day)&&void 0!==i?i:0,startHour:Gd(t.start),endHour:iu(t),allDay:!1})}document.addEventListener("mousemove",L),document.addEventListener("mouseup",V)},[H,L,V,M,y,x]);return{handleDragMove:L,handleDragEnd:V,handleCreateStart:A,handleMoveStart:Z,handleResizeStart:F,handleUniversalDragMove:$,handleUniversalDragEnd:Y}})({options:n,common:s,state:i,manager:l}),d=(e=>{const{options:n,common:r,state:a,manager:o,handleDragMove:s,handleDragEnd:i}=e,{viewType:l,currentWeekStart:c}=n,{dragRef:d,setDragState:u}=a,{createDragIndicator:h}=o,{pixelYToHour:g,getColumnDayIndex:f}=r,m=l===exports.ViewType.MONTH,v=t.useCallback((e,t)=>{if(m)return;if(e.preventDefault(),e.stopPropagation(),d.current.active)return;const n=d.current;Object.assign(n,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:t,allDay:!0,eventDate:c?yu(c,t):new Date}),u({active:!0,mode:"create",eventId:null,dayIndex:t,startHour:0,endHour:0,allDay:!0}),h(n,"blue","New All-day Event"),document.addEventListener("mousemove",s),document.addEventListener("mouseup",i)},[m,h,c,i,s,d,u]);return{handleCreateAllDayEvent:v,pixelYToHour:g,getColumnDayIndex:f}})({options:n,common:s,state:i,manager:l,handleDragMove:c.handleDragMove,handleDragEnd:c.handleDragEnd}),u=(e=>{const{common:t}=e,{daysDifference:n,addDaysToDate:r,getTargetDateFromPosition:a}=t;return{daysDifference:n,addDaysToDate:r,getTargetDateFromPosition:a}})({common:s});return Object.assign({createDragIndicator:l.createDragIndicator,updateDragIndicator:l.updateDragIndicator,removeDragIndicator:l.removeDragIndicator,handleCreateStart:c.handleCreateStart,handleMoveStart:c.handleMoveStart,handleResizeStart:c.handleResizeStart,dragState:i.dragState,isDragging:i.dragState.active},a?{daysDifference:u.daysDifference,addDaysToDate:u.addDaysToDate,getTargetDateFromPosition:u.getTargetDateFromPosition}:{handleCreateAllDayEvent:d.handleCreateAllDayEvent,pixelYToHour:d.pixelYToHour,getColumnDayIndex:d.getColumnDayIndex})};function Eh(e,t){const n=e.getPlugin("drag"),r=Ch(t);if(!n)return y.warn("Drag plugin is not installed. Drag functionality will be disabled. Add createDragPlugin() to your plugins array to enable dragging."),{handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:()=>{},handleCreateAllDayEvent:void 0,dragState:r.dragState,isDragging:!1};const a=n.getConfig(),o=n.isViewSupported(t.viewType);return o||console.info(`ℹ️ Drag functionality is not supported for ${t.viewType} view.`),{handleMoveStart:o&&a.enableDrag?r.handleMoveStart:()=>{},handleCreateStart:o&&a.enableCreate?r.handleCreateStart:()=>{},handleResizeStart:o&&a.enableResize?r.handleResizeStart:()=>{},handleCreateAllDayEvent:o&&a.enableAllDayCreate?r.handleCreateAllDayEvent:void 0,dragState:r.dragState,isDragging:!!o&&r.isDragging}}const Mh=({handlePreviousMonth:e,handleToday:t,handleNextMonth:a})=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{className:"calendar-nav-button group relative inline-flex items-center justify-center w-8 h-8 rounded-lg 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 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",onClick:e,"aria-label":"Previous month",children:n.jsx(r.ChevronLeft,{className:"h-4 w-4 transition-transform group-hover:scale-110"})}),n.jsx("button",{className:"calendar-today-button inline-flex items-center justify-center px-4 py-[5px] text-sm font-medium rounded-lg 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 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 min-w-[70px]",onClick:t,children:"Today"}),n.jsx("button",{className:"calendar-nav-button group relative inline-flex items-center justify-center w-8 h-8 rounded-lg 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 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",onClick:a,"aria-label":"Next month",children:n.jsx(r.ChevronRight,{className:"h-4 w-4 transition-transform group-hover:scale-110"})})]}),kh={[exports.ViewType.DAY]:"Day",[exports.ViewType.WEEK]:"Week",[exports.ViewType.MONTH]:"Month",[exports.ViewType.YEAR]:"Year"},Th=()=>n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-transform duration-200",children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),jh=({calendar:e,mode:r="buttons"})=>{const[a,o]=t.useState(!1),s=t.useRef(null),i=Array.from(e.state.views.keys()),l=e.state.currentView;return t.useEffect(()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),"select"===r?n.jsxs("div",{className:"relative inline-block",ref:s,children:[n.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 px-3 py-1 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 transition-all duration-200 shadow-sm min-w-[120px] justify-between","aria-expanded":a,"aria-haspopup":"listbox",children:[n.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:kh[l]}),n.jsx("span",{className:"text-gray-500 dark:text-gray-400 transition-transform duration-200 "+(a?"rotate-180":""),children:n.jsx(Th,{})})]}),a&&n.jsx("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-[120px] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:n.jsx("div",{className:"py-1",role:"listbox",children:i.map(t=>n.jsx("button",{onClick:()=>{e.changeView(t),o(!1)},className:"w-full text-left px-3 py-2 text-sm transition-colors duration-150 "+(l===t?"bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:kh[t]},t))})}),n.jsx("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}):n.jsx("div",{className:"inline-flex items-center gap-1 p-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:i.map(t=>n.jsx("button",{className:"px-4 py-1.5 text-sm font-medium rounded-md transition-all duration-200 "+(l===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>e.changeView(t),children:kh[t]},t))})},Sh=({calendar:e,viewType:t,currentDate:r,onPrevious:a,onNext:o,onToday:s,customTitle:i,customSubtitle:l,showTodayBox:c,switcherMode:d="buttons"})=>{const u=void 0!==c?c:"day"!==t,h="buttons"===d,g=i||(()=>{switch(t){case"day":return r.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return r.toLocaleDateString("en-US",{month:"long",year:"numeric"});default:return""}})(),f="day"===t?l||("day"===t?r.toLocaleDateString("en-US",{weekday:"long"}):null):null;return"day"===t?n.jsxs("div",{className:D,style:{position:"relative"},children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:`${w} text-gray-900 dark:text-white`,children:g}),f&&n.jsx("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:f})]}),h&&n.jsx("div",{className:"absolute -translate-x-1/2",style:{left:"calc(5 / 7 * 100% + 0.5px)"},children:n.jsx(jh,{mode:d,calendar:e})}),!h&&n.jsx("div",{className:"flex items-center gap-2",children:u&&a&&o&&s&&n.jsx(Mh,{handlePreviousMonth:a,handleNextMonth:o,handleToday:s})})]}):n.jsxs("div",{className:D,style:{position:"relative"},children:[n.jsx("div",{children:n.jsx("h1",{className:w,children:g})}),h&&n.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:n.jsx(jh,{mode:d,calendar:e})}),(u||!h)&&a&&o&&s&&n.jsxs("div",{className:"flex items-center gap-2",children:[!h&&n.jsx(jh,{mode:d,calendar:e}),u&&n.jsx(Mh,{handlePreviousMonth:a,handleNextMonth:o,handleToday:s})]})]})},Nh=({app:e,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const i=e.getCurrentDate(),l=e.getEvents(),[c,d]=t.useState(new Date),[u,h]=t.useState(null),[g,f]=t.useState(null),{HOUR_HEIGHT:m,FIRST_HOUR:v,LAST_HOUR:y,TIME_COLUMN_WIDTH:p,ALL_DAY_HEIGHT:x}=ph,b=t.useRef(null),H=t.useMemo(()=>(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})(i),[i]),O=t.useMemo(()=>l.filter(e=>{const t=Fd(e.start);t.setHours(0,0,0,0);const n=new Date(i);return n.setHours(0,0,0,0),t.getTime()===n.getTime()}).map(e=>{const t=Fd(e.start),n=Math.floor((t.getTime()-H.getTime())/864e5),r=Math.max(0,Math.min(6,n));return Object.assign(Object.assign({},e),{day:r})}),[l,i,H]),R=t.useMemo(()=>yh.calculateDayEventLayouts(O,{viewType:"day"}),[O]),{handleMoveStart:P,handleCreateStart:$,handleResizeStart:Y,handleCreateAllDayEvent:G,dragState:X,isDragging:J}=Eh(e,{calendarRef:o,allDayRowRef:b,viewType:exports.ViewType.DAY,onEventsUpdate:t=>{const n=t(O),r=new Set(n.map(e=>e.id)),a=O.filter(e=>!r.has(e.id)),o=new Set(O.map(e=>e.id)),s=n.filter(e=>!o.has(e.id)),i=n.filter(e=>{if(!o.has(e.id))return!1;const t=O.find(t=>t.id===e.id);return t&&(Fd(t.start).getTime()!==Fd(e.start).getTime()||Fd(t.end).getTime()!==Fd(e.end).getTime()||t.day!==e.day||Gd(t.start)!==Gd(e.start)||Gd(t.end)!==Gd(e.end)||t.title!==e.title)});a.forEach(t=>e.deleteEvent(t.id)),s.forEach(t=>e.addEvent(t)),i.forEach(t=>e.updateEvent(t.id,t))},onEventCreate:t=>{e.addEvent(t)},onEventEdit:()=>{},currentWeekStart:H,events:O,calculateNewEventLayout:(e,t,n)=>{const r=new Date(i),a=new Date(i);r.setHours(Math.floor(t),t%1*60,0,0),a.setHours(Math.floor(n),n%1*60,0,0);const o={id:"-1",title:"Temp",day:e,start:Vd(r),end:Vd(a),calendarId:"blue",allDay:!1},s=[...O.filter(e=>!e.allDay),o];return yh.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null},calculateDragLayout:(e,t,n,r)=>{const a=O.map(a=>{if(a.id!==e.id)return a;const o=Fd(a.start),s=Xd(o,n),i=Xd(o,r),l=Vd(s),c=Vd(i);return Object.assign(Object.assign({},a),{day:t,start:l,end:c})}),o=a.filter(e=>!e.allDay);if(0===o.length)return null;return yh.calculateDayEventLayouts(o,{viewType:"day"}).get(e.id)||null}}),K=t=>{e.updateEvent(t.id,t)},Q=t=>{e.deleteEvent(t)},ee=Array.from({length:24},(e,t)=>({hour:t+v,label:au(t+v)})),te=(()=>{const t=e.getCurrentDate().getFullYear(),n=e.getCurrentDate().getMonth(),r=new Date(t,n,1),a=new Date(t,n+1,0),o=[];for(let e=(0===r.getDay()?6:r.getDay()-1)-1;e>=0;e--){const r=new Date(t,n,-e);o.push({date:r.getDate(),isCurrentMonth:!1,isToday:!1,isSelected:!1,fullDate:r})}for(let e=1;e<=a.getDate();e++){const r=new Date(t,n,e),a=r.toDateString()===(new Date).toDateString(),s=r.toDateString()===i.toDateString();o.push({date:e,isCurrentMonth:!0,isToday:a,isSelected:s,fullDate:r})}const s=42-o.length;for(let e=1;e<=s;e++){const r=new Date(t,n+1,e);o.push({date:e,isCurrentMonth:!1,isToday:!1,isSelected:!1,fullDate:r})}return o})(),ne=t.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(i);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[i]);return t.useEffect(()=>{const e=setInterval(()=>d(new Date),6e4);return()=>clearInterval(e)},[]),n.jsxs("div",{className:"flex h-full bg-gray-50 dark:bg-gray-800",children:[n.jsx("div",{className:`flex-none ${"buttons"===s?"":"md:w-[60%]"} w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,children:n.jsxs("div",{className:`relative ${_} h-full`,children:[n.jsx(Sh,{calendar:e,viewType:exports.ViewType.DAY,currentDate:i,switcherMode:s,customSubtitle:c.toLocaleDateString("en-US",{weekday:"long"})}),n.jsxs("div",{className:N,ref:b,children:[n.jsx("div",{className:I,children:"all-day"}),n.jsx("div",{className:"flex flex-1 relative",children:n.jsx("div",{className:"w-full relative",style:{minHeight:`${x}px`},onDoubleClick:e=>{const t=Math.floor((i.getTime()-H.getTime())/864e5);null==G||G(e,t)},children:O.filter(e=>e.allDay).map(e=>n.jsx(lh,{event:e,isAllDay:!0,isDayView:!0,allDayHeight:x,calendarRef:o,isBeingDragged:J&&(null==X?void 0:X.eventId)===e.id&&"move"===(null==X?void 0:X.mode),hourHeight:m,firstHour:v,onMoveStart:P,onEventUpdate:K,onEventDelete:Q,detailPanelEventId:g,onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a},e.id))})})]}),n.jsx("div",{className:C,style:{position:"relative"},children:n.jsxs("div",{className:"relative flex",children:[ne&&(()=>{const e=c,t=e.getHours()+e.getMinutes()/60;if(t<v||t>y)return null;const r=(t-v)*m;return n.jsxs("div",{className:j,style:{top:`${r}px`,width:"100%",height:0,zIndex:20},children:[n.jsxs("div",{className:"flex items-center",style:{width:`${p}px`},children:[n.jsx("div",{className:"relative w-full flex items-center"}),n.jsx("div",{className:S,children:au(t)})]}),n.jsx("div",{className:"flex-1 flex items-center",children:n.jsx("div",{className:"h-0.5 w-full bg-red-600 relative"})})]})})(),n.jsx("div",{className:E,children:ee.map((e,t)=>n.jsx("div",{className:M,children:n.jsx("div",{className:k,children:0===t?"":e.label})},t))}),n.jsxs("div",{className:"flex-grow relative",children:[ee.map((e,t)=>n.jsx("div",{className:T,onDoubleClick:e=>{var t,n,r,a;const s=Math.floor((i.getTime()-H.getTime())/864e5),l=null===(n=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!l)return;const c=e.clientY-l.top+(null===(a=null===(r=o.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.scrollTop)||0;$(e,s,v+c/m)}},t)),n.jsx("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 relative",children:n.jsx("div",{className:"absolute -top-2.5 -left-9 text-[12px] text-gray-500 dark:text-gray-400",children:"00.00"})}),n.jsx("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:O.filter(e=>!e.allDay).map(e=>{const t=R.get(e.id);return n.jsx(lh,{event:e,layout:t,isDayView:!0,calendarRef:o,isBeingDragged:J&&(null==X?void 0:X.eventId)===e.id&&"move"===(null==X?void 0:X.mode),hourHeight:m,firstHour:v,onMoveStart:P,onResizeStart:Y,onEventUpdate:K,onEventDelete:Q,detailPanelEventId:g,onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a},e.id)})})]})]})})]})}),n.jsx("div",{className:`flex-none ${"buttons"===s?"":"md:w-[40%]"} w-[30%] bg-white dark:bg-gray-900`,children:n.jsxs("div",{className:`${_} h-full`,children:[n.jsx("div",{className:"px-2 border-b border-gray-200 dark:border-gray-700",children:n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n.jsx("div",{className:D,style:{position:"relative"},children:n.jsx("div",{children:n.jsx("h1",{className:w,children:" "})})}),"select"===s?n.jsx(jh,{mode:s,calendar:e}):null,n.jsx(Mh,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),n.jsxs("div",{className:L,children:[lu.map(e=>n.jsx("div",{className:V,children:e.charAt(0)},e)),te.map((t,r)=>n.jsx("button",{className:`\n ${A}\n ${t.isCurrentMonth?Z:F}\n ${t.isToday?z:""}\n ${t.isSelected&&!t.isToday?B:""}\n `,onClick:()=>{return n=t.fullDate,void e.setCurrentDate(n);var n},children:t.date},r))]})]})}),n.jsxs("div",{className:"flex-1 p-4 overflow-y-auto",children:[n.jsx("h3",{className:"text-lg font-semibold mb-3",children:i.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})}),0===O.length?n.jsx("p",{className:`text-gray-500 dark:text-gray-400 ${q}`,children:"No events for this day"}):n.jsx("div",{className:"space-y-2",children:O.map(e=>n.jsxs("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==u?void 0:u.id)===e.id?"bg-blue-50 dark:bg-blue-900/30 border-blue-500":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:nu(e.calendarId||"blue")},onClick:()=>h(e),children:[n.jsx("div",{className:`font-medium ${q}`,children:e.title}),!e.allDay&&n.jsxs("div",{className:`${U} ${W}`,children:[au(Gd(e.start))," -"," ",au(iu(e))]}),e.allDay&&n.jsx("div",{className:`${U} ${W}`,children:"All day"})]},e.id))})]})]})})]})},Ih={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},Hh=({app:e,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const i=e.getCurrentDate(),l=e.getEvents(),c=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},d=t.useMemo(()=>c(i),[i]),[u,h]=t.useState(new Date),[g,f]=t.useState(null),[m,v]=t.useState(null),{HOUR_HEIGHT:y,FIRST_HOUR:p,LAST_HOUR:x,TIME_COLUMN_WIDTH:b,ALL_DAY_HEIGHT:D}=ph,w=t.useRef(null),H=t.useMemo(()=>{const e=new Date(d);e.setDate(d.getDate()+6),e.setHours(23,59,59,999);return l.filter(t=>{const n=Fd(t.start);n.setHours(0,0,0,0);const r=Fd(t.end);return r.setHours(23,59,59,999),r>=d&&n<=e}).map(e=>{const t=Fd(e.start),n=Math.floor((t.getTime()-d.getTime())/864e5),r=Math.max(0,Math.min(6,n));return Object.assign(Object.assign({},e),{day:r})})},[l,d]),O=t.useMemo(()=>rh(H,d),[H,d]),R=t.useMemo(()=>{const e=O.filter(e=>e.event.allDay);e.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const t=[];return e.forEach(e=>{let n=0,r=!1;for(;!r;){t.some(t=>t.row===n&&!(e.endDayIndex<t.startDayIndex||e.startDayIndex>t.endDayIndex))?n++:r=!0}t.push(Object.assign(Object.assign({},e),{row:n}))}),t},[O]),P=t.useMemo(()=>{if(0===R.length)return D;const e=Math.max(...R.map(e=>e.row));return D+e*D},[R,D]),$=t.useMemo(()=>{const e=new Map;for(let t=0;t<7;t++){const n=[];H.forEach(e=>{if(e.allDay)return;const r=ah(e,d);if(r.length>0){const a=r.find(e=>e.dayIndex===t);if(a){const r=a.endHour>=24?23.99:a.endHour,o=Object.assign(Object.assign({},e),{start:Vd(Xd(yu(d,t),a.startHour)),end:Vd(Xd(yu(d,t),r)),day:t});n.push(o)}}else e.day===t&&n.push(e)});const r=yh.calculateDayEventLayouts(n,{viewType:"week"});e.set(t,r)}return e},[H,d]),{handleMoveStart:Y,handleCreateStart:L,handleResizeStart:V,handleCreateAllDayEvent:A,dragState:Z,isDragging:F}=Eh(e,{calendarRef:o,allDayRowRef:w,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const r=t(H),a=new Set(r.map(e=>e.id)),o=H.filter(e=>!a.has(e.id)),s=new Set(H.map(e=>e.id)),i=r.filter(e=>!s.has(e.id)),l=r.filter(e=>{if(!s.has(e.id))return!1;const t=H.find(t=>t.id===e.id);return t&&(Fd(t.start).getTime()!==Fd(e.start).getTime()||Fd(t.end).getTime()!==Fd(e.end).getTime()||t.day!==e.day||Gd(t.start)!==Gd(e.start)||Gd(t.end)!==Gd(e.end)||t.title!==e.title)});o.forEach(t=>e.deleteEvent(t.id)),i.forEach(t=>e.addEvent(t)),l.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{e.addEvent(t)},onEventEdit:()=>{},currentWeekStart:d,events:H,calculateNewEventLayout:(e,t,n)=>{const r=new Date,a=new Date;r.setHours(Math.floor(t),t%1*60,0,0),a.setHours(Math.floor(n),n%1*60,0,0);const o={id:"-1",title:"Temp",day:e,start:Vd(r),end:Vd(a),calendarId:"blue",allDay:!1},s=[...H.filter(t=>t.day===e&&!t.allDay),o];return yh.calculateDayEventLayouts(s,{viewType:"week"}).get("-1")||null},calculateDragLayout:(e,t,n,r)=>{const a=H.map(a=>{if(a.id!==e.id)return a;const o=Fd(a.start),s=Xd(o,n),i=Xd(o,r),l=Vd(s),c=Vd(i);return Object.assign(Object.assign({},a),{day:t,start:l,end:c})}),o=a.filter(e=>e.day===t&&!e.allDay);if(0===o.length)return null;return yh.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null}}),z=t.useMemo(()=>["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],[]),B=Array.from({length:24},(e,t)=>({hour:t+p,label:au(t+p)})),W=t.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),z.map((t,n)=>{const r=new Date(d);r.setDate(d.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString("default",{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[d,z]),U=t=>{e.updateEvent(t.id,t)},q=t=>{e.deleteEvent(t)},_=t.useMemo(()=>{const e=new Date,t=c(e);return d.getTime()===t.getTime()},[d]);return t.useEffect(()=>{const e=setInterval(()=>h(new Date),6e4);return()=>clearInterval(e)},[]),n.jsxs("div",{className:"relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full",children:[n.jsx(Sh,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:i,switcherMode:s,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),n.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[n.jsx("div",{className:"w-20 p-2"}),z.map((e,t)=>n.jsxs("div",{className:"flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1",children:[n.jsx("div",{className:"inline-flex items-center justify-center text-sm h-6 w-6 mt-1 mr-1",children:e}),n.jsx("div",{className:"inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1",children:W[t].date})]},t))]}),n.jsxs("div",{className:N,ref:w,children:[n.jsx("div",{className:I,children:"all-day"}),n.jsxs("div",{className:"flex flex-1 relative",style:{minHeight:`${P}px`},children:[z.map((e,t)=>n.jsx("div",{className:"flex-1 border-r border-gray-200 dark:border-gray-700 relative",style:{minHeight:`${P}px`},onDoubleClick:e=>null==A?void 0:A(e,t)},`allday-${t}`)),n.jsx("div",{className:"absolute inset-0 pointer-events-none",children:R.map(e=>n.jsx(lh,{event:e.event,segment:e,segmentIndex:e.row,isAllDay:!0,isMultiDay:!0,allDayHeight:D,calendarRef:o,isBeingDragged:F&&(null==Z?void 0:Z.eventId)===e.event.id&&"move"===(null==Z?void 0:Z.mode),hourHeight:y,firstHour:p,onMoveStart:Y,onResizeStart:V,onEventUpdate:U,onEventDelete:q,selectedEventId:m,detailPanelEventId:g,onEventSelect:e=>v(e),onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a},e.id))})]})]}),n.jsx("div",{className:C,style:{position:"relative"},children:n.jsxs("div",{className:"relative flex",children:[_&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<p||t>x)return null;const r=e.getDay(),a=0===r?6:r-1,o=(t-p)*y;return n.jsxs("div",{className:j,style:{top:`${o}px`,width:"100%",height:0,zIndex:20},children:[n.jsxs("div",{className:"flex items-center",style:{width:`${b}px`},children:[n.jsx("div",{className:"relative w-full flex items-center"}),n.jsx("div",{className:S,children:au(t)})]}),n.jsx("div",{className:"flex flex-1",children:z.map((e,t)=>n.jsx("div",{className:"flex-1 flex items-center",children:n.jsx("div",{className:"h-0.5 w-full relative "+(t===a?"bg-red-600 dark:bg-red-500":"bg-red-100 dark:bg-red-900/30"),style:{zIndex:9999},children:t===a&&0!==a&&n.jsx("div",{className:"absolute w-2 h-2 bg-red-700 dark:bg-red-500 rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),n.jsx("div",{className:E,children:B.map((e,t)=>n.jsx("div",{className:M,children:n.jsx("div",{className:k,children:0===t?"":e.label})},t))}),n.jsxs("div",{className:"flex-grow relative",children:[B.map((e,t)=>n.jsx("div",{className:T,children:z.map((r,a)=>n.jsx("div",{className:"flex-1 relative border-r border-gray-200 dark:border-gray-700",onDoubleClick:t=>{L(t,a,e.hour)}},`${t}-${a}`))},t)),n.jsxs("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 flex relative",children:[n.jsx("div",{className:"absolute -top-2.5 -left-9 text-[12px] text-gray-500 dark:text-gray-400",children:"00.00"}),z.map((e,t)=>n.jsx("div",{className:"flex-1 relative border-r border-gray-200 dark:border-gray-700"},`24-${t}`))]}),z.map((e,t)=>{const s=vu(t,H),i=[];return s.forEach(e=>{const n=ah(e,d);if(n.length>0){const r=n.find(e=>e.dayIndex===t);r&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},r),{dayIndex:t})})}else i.push({event:e})}),H.forEach(e=>{if(e.allDay||e.day===t)return;const n=ah(e,d).find(e=>e.dayIndex===t);n&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:t})})}),n.jsx("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*t}%)`,width:100/7+"%",height:"100%"},children:i.map(({event:e,segmentInfo:s})=>{const i=$.get(t),l=null==i?void 0:i.get(e.id);return n.jsx(lh,{event:e,layout:l,calendarRef:o,isBeingDragged:F&&(null==Z?void 0:Z.eventId)===e.id&&"move"===(null==Z?void 0:Z.mode),hourHeight:y,firstHour:p,onMoveStart:Y,onResizeStart:V,onEventUpdate:U,onEventDelete:q,selectedEventId:m,detailPanelEventId:g,onEventSelect:e=>v(e),onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a,multiDaySegmentInfo:s},s?`${e.id}-seg-${t}`:e.id)})},`events-day-${t}`)})]})]})})]})},Oh={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},Rh=2,Ph=50,$h=1900,Yh=2200,Lh=8,Vh=150,Ah=1400,Zh=1e3,Fh=900;class zh{static trackScrollEvent(e=0){this.metrics.scrollEvents++,this.metrics.totalScrollDistance+=Math.abs(e),this.metrics.avgScrollDelta=this.metrics.totalScrollDistance/this.metrics.scrollEvents}static trackRenderTime(e){this.metrics.renderTime.push(e),e>16.67&&this.metrics.frameDrops++,this.metrics.renderTime.length>100&&this.metrics.renderTime.shift()}static trackCacheHit(){this.metrics.cacheHits++}static trackCacheMiss(){this.metrics.cacheMisses++}static getMetrics(){const e=this.metrics.renderTime.length>0?this.metrics.renderTime.reduce((e,t)=>e+t,0)/this.metrics.renderTime.length:0,t=this.metrics.cacheHits+this.metrics.cacheMisses>0?this.metrics.cacheHits/(this.metrics.cacheHits+this.metrics.cacheMisses)*100:0,n=Date.now()-this.metrics.startTime,r=e>0?1e3/e:0;return{scrollEvents:this.metrics.scrollEvents,avgRenderTime:Math.round(100*e)/100,cacheHitRate:Math.round(100*t)/100,uptime:Math.round(n/1e3),scrollEventsPerSecond:Math.round(this.metrics.scrollEvents/(n/1e3)*100)/100,estimatedFPS:Math.round(r),frameDrops:this.metrics.frameDrops,avgScrollDelta:Math.round(100*this.metrics.avgScrollDelta)/100}}static reset(){this.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0}}}zh.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};class Bh{constructor(e=Ph){this.cache=new Map,this.accessOrder=[],this.maxSize=e}get(e){const t=this.cache.get(e);if(t)return zh.trackCacheHit(),this.updateAccessOrder(e),t;zh.trackCacheMiss()}set(e,t){if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(e,t),this.updateAccessOrder(e)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}getHitRate(){return zh.getMetrics().cacheHitRate}clear(){this.cache.clear(),this.accessOrder=[]}}const Wh=()=>{const[e,n]=t.useState({yearHeight:Fh,screenSize:"desktop"});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth;n(e<768?{yearHeight:Ah,screenSize:"mobile"}:e<1024?{yearHeight:Zh,screenSize:"tablet"}:{yearHeight:Fh,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Uh=({currentDate:e,yearHeight:n,onCurrentYearChange:r})=>{const a=e.getFullYear(),o=(a-$h)*n,[s,i]=t.useState(o),[l,c]=t.useState(600),[d,u]=t.useState(a),[h,g]=t.useState(!1),f=t.useRef(document.createElement("div")),m=t.useRef(null),v=t.useRef(0),y=t.useRef(0),p=t.useMemo(()=>{const e=performance.now(),t=Yh-$h+1,r=t*n,a=Math.floor(s/n),o=Math.min(t-1,Math.ceil((s+l)/n)),i=Math.max(0,a-Rh),c=Math.min(t-1,o+Rh),d=[];for(let e=i;e<=c;e++)d.push({index:e,year:$h+e,top:e*n,height:n});const u=performance.now()-e;return zh.trackRenderTime(u),{totalHeight:r,visibleItems:d}},[s,l,n]),x=t.useCallback(e=>{const t=performance.now();if(t-v.current<Lh)return;v.current=t;const a=e.currentTarget.scrollTop,o=Math.abs(a-y.current);y.current=a,zh.trackScrollEvent(o),requestAnimationFrame(()=>{i(a);const e=a+l/2,t=Math.round($h+e/n);t!==d&&t>=$h&&t<=Yh&&(u(t),null==r||r(t))}),g(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{g(!1)},Vh)},[l,d,n,r]);t.useEffect(()=>{const e=f.current;if(!e)return;e.scrollTop=o;const t=new ResizeObserver(([e])=>{c(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[o]);const b=t.useCallback((e,t=!0)=>{if(!f.current)return;const r=(e-$h)*n-l/2+n/2;f.current.scrollTo({top:Math.max(0,r),behavior:t?"smooth":"auto"})},[n,l]),D=t.useCallback(()=>{const e=Math.max($h,d-1);u(e),b(e)},[d,b]),w=t.useCallback(()=>{const e=Math.min(Yh,d+1);u(e),b(e)},[d,b]),C=t.useCallback(()=>{const e=(new Date).getFullYear();u(e),b(e)},[b]);return t.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),{scrollTop:s,containerHeight:l,currentYear:d,isScrolling:h,virtualData:p,scrollElementRef:f,handleScroll:x,scrollToYear:b,handlePreviousYear:D,handleNextYear:w,handleToday:C,setScrollTop:i,setContainerHeight:c,setCurrentYear:u,setIsScrolling:g}},qh=()=>{const[e,n]=t.useState({weekHeight:u,screenSize:"desktop",weeksPerView:6});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth,t=window.innerHeight-150,r=Math.max(80,Math.floor(t/6)),a=e<768?{weekHeight:Math.max(c,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(d,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(u,r),screenSize:"desktop",weeksPerView:6};n(a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},_h=({currentDate:e,weekHeight:n,onCurrentMonthChange:r,initialWeeksToLoad:a=104})=>{const o=t.useRef(null),s=t.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),mu(t,a)},[e,a]),c=t.useMemo(()=>{const t=new Date(e);t.setDate(1),t.setHours(0,0,0,0);const r=s.findIndex(e=>e.days.some(e=>e.date.toDateString()===t.toDateString()));return r>0?r*n:0},[s,e,n]),[d,u]=t.useState(c),[g,f]=t.useState(600),[m,v]=t.useState(cu[e.getMonth()]),[y,p]=t.useState(e.getFullYear()),[x,b]=t.useState(!1),[D,w]=t.useState(s),[C,E]=t.useState(!1),M=t.useRef(!1),[k,T]=t.useState(!1),j=t.useRef(e),S=t.useRef(null),N=t.useRef(null),I=t.useRef(new h),H=t.useRef(0),O=t.useRef(0),R=t.useRef(!1),P=t.useCallback(e=>{e&&(S.current=e)},[]),$=t.useCallback(e=>{let t=I.current.get(e);return t||(t=gu(e),I.current.set(e,t)),t},[]),Y=t.useCallback((e,t=26)=>{R.current||(R.current=!0,setTimeout(()=>{try{if("future"===e){const e=D[D.length-1],n=[];for(let r=1;r<=t;r++){const t=new Date(e.startDate);t.setDate(t.getDate()+7*r),n.push($(t))}w(e=>[...e,...n])}else{const e=D[0],r=[];for(let n=t;n>=1;n--){const t=new Date(e.startDate);t.setDate(t.getDate()-7*n),r.push($(t))}const a=r.length*n;w(e=>[...r,...e]),requestAnimationFrame(()=>{u(e=>e+a),S.current&&(S.current.scrollTop+=a)})}}finally{setTimeout(()=>{R.current=!1},200)}},0))},[D,$,n]),L=t.useMemo(()=>{const e=D.length*n,t=Math.floor(d/n);let r=Math.max(0,t);r=Math.min(r,Math.max(0,D.length-6));const a=Math.min(D.length-1,r+6-1),o=Math.max(0,r-15),s=Math.min(D.length-1,a+15),i=[];for(let e=o;e<=s;e++)i.push({index:e,weekData:D[e],top:e*n,height:n});return{totalHeight:e,visibleItems:i,displayStartIndex:r}},[d,g,n,D]),V=t.useCallback(e=>{if(C||x||0===e.length||!k)return;const t=d+g/2,n=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!n)return;const a={};n.weekData.days.forEach(e=>{const t=`${cu[e.month]}-${e.year}`;a[t]=(a[t]||0)+1});let s="",i=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,r]=e.split("-");s=n,i=parseInt(r)}}),s&&i&&(o.current?s===o.current.month&&i===o.current.year&&(o.current=null,s===m&&i===y||(v(s),p(i),null==r||r(s,i))):s===m&&i===y||(v(s),p(i),null==r||r(s,i)))},[g,m,y,C,x,r,d,k]),A=t.useCallback(e=>{const t=performance.now();if(t-H.current<i)return;H.current=t;const r=e.currentTarget,a=r.scrollTop;O.current=a,u(a),C||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=r;a+t>e-10*n&&!R.current&&Y("future",26),a<10*n&&!R.current&&Y("past",26)}),b(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{b(!1)},l)},[n,Y,C]),Z=t.useCallback((e,t=!0)=>{if(!S.current)return;E(!0),M.current=!0;const r=()=>{setTimeout(()=>{E(!1),M.current=!1},t?500:200)},a=D.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*n;return S.current.scrollTo({top:e,behavior:t?"smooth":"auto"}),void r()}const o=e.getDay(),s=0===o?6:o-1,i=new Date(e);i.setDate(e.getDate()-s),i.setHours(0,0,0,0);const l=D[0],c=D[D.length-1];let d=0,h=!1,g=!1;i<l.startDate?(d=Math.ceil((l.startDate.getTime()-i.getTime())/6048e5),h=!0):i>c.startDate&&(d=Math.ceil((i.getTime()-c.startDate.getTime())/6048e5),g=!0);const f=Math.min(d+10,52);if(h){const a=[];for(let e=f;e>=1;e--){const t=new Date(l.startDate);t.setDate(t.getDate()-7*e),a.push($(t))}const o=a.length*n;w(e=>[...a,...e]),requestAnimationFrame(()=>{const s=[...a,...D].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(S.current&&-1!==s){const e=s*n;S.current.scrollTop+=o,u(e=>e+o),setTimeout(()=>{S.current&&S.current.scrollTo({top:e,behavior:t?"smooth":"auto"})},50)}r()})}else if(g){const a=[];for(let e=1;e<=f;e++){const t=new Date(c.startDate);t.setDate(t.getDate()+7*e),a.push($(t))}w(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...D,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(S.current&&-1!==o){const e=o*n;S.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}r()})}else r()},[D,n,$]),F=t.useCallback(()=>{const e="January"===m?11:cu.indexOf(m)-1,t=new Date("January"===m?y-1:y,e,1);Z(t)},[m,y,Z]),z=t.useCallback(()=>{const e="December"===m?0:cu.indexOf(m)+1,t=new Date("December"===m?y+1:y,e,1);Z(t)},[m,y,Z]),B=t.useCallback(()=>{const e=new Date,t=cu[e.getMonth()],a=e.getFullYear(),s=new Date(a,e.getMonth(),1);o.current={month:t,year:a},v(t),p(a),null==r||r(t,a);const i=D.findIndex(e=>e.days.some(e=>e.date.toDateString()===s.toDateString()));if(-1!==i){const e=i*n,t=S.current;t&&(E(!0),M.current=!0,requestAnimationFrame(()=>{u(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{M.current=!1,E(!1)},200))})}))}else E(!0),M.current=!0,requestAnimationFrame(()=>{Z(s,!0),setTimeout(()=>{M.current=!1,E(!1)},200)})},[D,n,r,Z]);return t.useEffect(()=>{V(L.visibleItems)},[L.visibleItems,V]),t.useEffect(()=>{const t=j.current,n=t.getMonth(),a=t.getFullYear(),s=e.getMonth(),i=e.getFullYear();if(n!==s||a!==i){const e=new Date(i,s,1),t=cu[s];o.current={month:t,year:i},v(t),p(i),null==r||r(t,i),Z(e,!0)}j.current=e},[e,r,Z]),t.useEffect(()=>{const e=S.current;if(!e)return;const t=new ResizeObserver(([e])=>{f(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),t.useEffect(()=>{const e=S.current;e&&!k&&requestAnimationFrame(()=>{e&&c>0?(e.scrollTop=c,T(!0)):e&&T(!0)})},[k,c]),t.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]),{scrollTop:d,containerHeight:g,currentMonth:m,currentYear:y,isScrolling:x,virtualData:L,scrollElementRef:S,handleScroll:A,scrollToDate:Z,handlePreviousMonth:F,handleNextMonth:z,handleToday:B,setScrollTop:u,setContainerHeight:f,setCurrentMonth:v,setCurrentYear:p,setIsScrolling:b,cache:I.current,scrollElementRefCallback:P,weeksData:D}},Gh=t.memo(({currentMonth:e,currentYear:r,newlyCreatedEventId:a,isScrolling:o,isDragging:s,item:i,weekHeight:l,events:c,dragState:d,calendarRef:u,onEventUpdate:h,onEventDelete:g,onMoveStart:f,onCreateStart:m,onResizeStart:v,onDetailPanelOpen:p,onMoreEventsClick:x,onChangeView:b,onSelectDate:D,selectedEventId:w,onEventSelect:C,detailPanelEventId:E,onDetailPanelToggle:M,customDetailPanelContent:k,customEventDetailDialog:T})=>{const[j,S]=t.useState(!1),N=t.useRef(null),I=t.useMemo(()=>(e=>{const t=e-33-20,n=Math.floor(t/17);return Math.max(0,Math.min(4,n))})(l),[l]);t.useEffect(()=>o?(S(!0),N.current&&(clearTimeout(N.current),N.current=null),()=>{N.current&&(clearTimeout(N.current),N.current=null)}):j?(N.current=setTimeout(()=>{S(!1),N.current=null},100),()=>{N.current&&(clearTimeout(N.current),N.current=null)}):void 0,[o,j]);const{weekData:H}=i,O=H.days.find(e=>1===e.day),R=`${l}px`,P=t.useMemo(()=>rh(c,H.startDate),[c,H.startDate]),$=t.useMemo(()=>(e=>{const t=[];return e.forEach(e=>{if(!e.start||!e.end)return void y.warn("Event missing start or end date:",e);const n=Fd(e.start),r=Fd(e.end),a=new Date(n);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);let s=new Date(o);if(!e.allDay&&0===r.getHours()&&0===r.getMinutes()&&0===r.getSeconds()){const e=r.getTime()-n.getTime();e>0&&e<864e5&&(s=new Date(o),s.setDate(s.getDate()-1))}const i=a.toDateString()!==s.toDateString();if(!i||e.allDay)if(i&&e.allDay){const a=new Date(n);for(;a<=r;){const n=Pd.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()});t.push(Object.assign(Object.assign({},e),{start:n,end:n,day:a.getDay()})),a.setDate(a.getDate()+1)}}else t.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:n.getDay()}))}),t})(c),[c]),Y=t.useMemo(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,r=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==r?r-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,r=!1;for(;!r;)n.some(n=>{var r;const a=Math.abs((null!==(r=n.yPosition)&&void 0!==r?r:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return a&&o})?t+=16:r=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const r=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);r[n]||(r[n]=[]),r[n].push(e)}),r.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),r})(P),[P]),L=t.useMemo(()=>{const e=Array(7).fill(0);return Y.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[Y]),V=t.useMemo(()=>Math.max(0,17*Y.length),[Y]),A=(t,o)=>{var i;const l=t.month===cu.indexOf(e)&&t.year===r;var c;const y=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:Gd(e.start)-Gd(t.start)))((c=t.date,$.filter(e=>{if(!e.start||!e.end)return Fd(e.start).toDateString()===c.toDateString();const t=Fd(e.start),n=Fd(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===c.toDateString()}return t.toDateString()===c.toDateString()||n.toDateString()===c.toDateString()}))),j=y.slice(0,I),S=y.length-j.length,N=S>0,H=[],O=null!==(i=L[o])&&void 0!==i?i:0;for(let e=0;e<O;e++)H.push(n.jsx("div",{className:"flex-shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));return j.forEach((e,t)=>{const r=Y.flat().find(t=>t.originalEventId===e.id);e.allDay&&r||H.push(n.jsx(lh,{event:e,isAllDay:!!e.allDay,isMonthView:!0,calendarRef:u,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:g,onMoveStart:f,onResizeStart:v,isBeingDragged:s&&d.eventId===e.id&&"move"===d.mode,newlyCreatedEventId:a,onDetailPanelOpen:p,selectedEventId:w,onEventSelect:C,detailPanelEventId:E,onDetailPanelToggle:M,customDetailPanelContent:k,customEventDetailDialog:T},`${e.id}-${e.day}-${Gd(e.start)}-${t}`))}),n.jsxs("div",{className:`\n relative flex flex-col border-r border-gray-200 dark:border-gray-700 last:border-r-0\n ${l?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,style:{height:R},"data-date":(P=t.date,`${P.getFullYear()}-${String(P.getMonth()+1).padStart(2,"0")}-${String(P.getDate()).padStart(2,"0")}`),onDoubleClick:e=>m(e,t.date),children:[n.jsxs("div",{className:"flex items-start justify-between p-2 pb-1 relative z-20",children:[n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("span",{className:`\n inline-flex items-center justify-center h-5 w-5 rounded-full text-sm font-medium\n ${t.isToday?"bg-blue-500 text-white":l?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:t.day}),1===t.day&&n.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 ml-1",children:t.shortMonthName})]})]}),n.jsxs("div",{className:"flex-1 overflow-hidden px-1",children:[H,N&&n.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:e=>{e.stopPropagation(),x?x(t.date):(null==D||D(t.date),null==b||b(exports.ViewType.DAY))},children:["+",S," more"]})]})]},`day-${t.date.getTime()}`);var P};return n.jsxs("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:R},children:[O&&n.jsx("div",{className:`\n absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${j?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},children:n.jsxs("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:[O.monthName," ",O.year]})}),n.jsx("div",{className:"h-full flex flex-col",children:n.jsxs("div",{className:"calendar-week relative h-full",children:[n.jsx("div",{className:"grid grid-cols-7 h-full",children:H.days.map((e,t)=>A(e,t))}),Y.length>0&&n.jsx("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${V}px`,zIndex:10},children:Y.map((e,t)=>n.jsx("div",{className:"absolute inset-0",children:e.map(e=>n.jsx(lh,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:u,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:g,onMoveStart:f,onResizeStart:v,isBeingDragged:s&&d.eventId===e.event.id&&"move"===d.mode,isBeingResized:s&&d.eventId===e.event.id&&"resize"===d.mode,newlyCreatedEventId:a,onDetailPanelOpen:p,selectedEventId:w,onEventSelect:C,detailPanelEventId:E,onDetailPanelToggle:M,customDetailPanelContent:k,customEventDetailDialog:T},e.id))},`layer-${t}`))})]})})]})});Gh.displayName="WeekComponent";const Xh=({app:e,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const i=e.getCurrentDate(),l=e.getEvents(),c=t.useRef(null),d=t.useMemo(()=>{const e=c.current;return e&&e.length===l.length&&e.every((e,t)=>e===l[t])?e:(c.current=l,l)},[l]),u=t.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),r=0===n?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t},n=(t,n)=>{const r=e.get(t);r?r.push(n):e.set(t,[n])};return d.forEach(e=>{if(!e.start)return;const r=Fd(e.start),a=e.end?Fd(e.end):r,o=new Date(r);o.setHours(0,0,0,0);const s=new Date(a);s.setHours(0,0,0,0);let i=new Date(s);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||i.setDate(i.getDate()-1)}i<o&&(i=new Date(o));const l=t(o),c=t(i);let d=l.getTime();const u=c.getTime();for(;d<=u;){n(d,e);const t=new Date(d);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),d=t.getTime()}}),e},[d]),{screenSize:h}=qh(),[g,f]=t.useState(()=>{if("undefined"!=typeof window){const e=150,t=window.innerHeight-e;return Math.max(80,Math.floor(t/6))}return 119}),[m,v]=t.useState(!1),y=t.useRef(g),p=t.useRef([]),[x,b]=t.useState(null),[D,w]=t.useState(null),[C,E]=t.useState(null),M=t.useMemo(()=>{const e=i.getDay(),t=i.getDate()-e+(0===e?-6:1),n=new Date(i);return n.setDate(t),n.setHours(0,0,0,0),n},[i]),{handleMoveStart:k,handleCreateStart:T,handleResizeStart:j,dragState:S,isDragging:N}=Eh(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n)=>{const r=t(d),a=new Set(r.map(e=>e.id)),o=d.filter(e=>!a.has(e.id)),s=new Set(d.map(e=>e.id)),i=r.filter(e=>!s.has(e.id)),l=r.filter(e=>{if(!s.has(e.id))return!1;const t=d.find(t=>t.id===e.id);return t&&(Fd(t.start).getTime()!==Fd(e.start).getTime()||Fd(t.end).getTime()!==Fd(e.end).getTime()||t.day!==e.day||Gd(t.start)!==Gd(e.start)||Gd(t.end)!==Gd(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});o.forEach(t=>e.deleteEvent(t.id)),i.forEach(t=>e.addEvent(t)),l.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{b(e.id)},currentWeekStart:M,events:d}),{currentMonth:I,currentYear:H,isScrolling:O,virtualData:R,scrollElementRef:P,handleScroll:$,handlePreviousMonth:Y,handleNextMonth:L,handleToday:V,setScrollTop:A}=_h({currentDate:i,weekHeight:g,onCurrentMonthChange:(t,n)=>{const r=cu.indexOf(t);r>=0&&e.setVisibleMonth(new Date(n,r,1))},initialWeeksToLoad:156}),Z=t.useRef(0),[F,z]=t.useState(0),B=t.useMemo(()=>F-6*g,[F,g]),{visibleWeeks:W,startIndex:U}=t.useMemo(()=>{const{visibleItems:e,displayStartIndex:t}=R,n=e.findIndex(e=>e.index===t);if(-1===n)return p.current.length>0?{visibleWeeks:p.current,startIndex:Z.current}:{visibleWeeks:[],startIndex:t};const r=e.slice(n,n+8);return r.length>=6&&(p.current=r,Z.current=t),{visibleWeeks:r,startIndex:t}},[R]),q=t.useMemo(()=>U*g,[U,g]),_=t.useMemo(()=>{const e=R.totalHeight,t=U*g+16*g+B;return Math.max(0,e-t)},[R.totalHeight,U,g,B]);t.useEffect(()=>{const e=P.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(z(t),!m&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==y.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/y.current)*n;e.scrollTop=r,A(r)}}f(n),y.current=n,requestAnimationFrame(()=>{v(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[P,m,A]);const G=t=>{e.updateEvent(t.id,t)},X=t=>{e.deleteEvent(t)},J=t=>{e.changeView(t)};return n.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900",children:[n.jsx(Sh,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:i,customTitle:`${I} ${H}`,onPrevious:Y,onNext:L,onToday:V,switcherMode:s}),n.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:n.jsx("div",{className:"grid grid-cols-7 px-2",children:lu.map((e,t)=>n.jsx("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2",children:e},t))})}),n.jsxs("div",{ref:P,className:"flex-1 overflow-auto will-change-scroll",style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:m?"visible":"hidden"},onScroll:$,children:[n.jsx("div",{style:{height:q}}),W.map((t,s)=>{var i;const l=null!==(i=u.get(t.weekData.startDate.getTime()))&&void 0!==i?i:[],c=5===s?Object.assign(Object.assign({},t),{height:t.height+B}):t;return n.jsx(Gh,{item:c,weekHeight:g,currentMonth:I,currentYear:H,screenSize:h,isScrolling:O,calendarRef:o,events:l,onEventUpdate:G,onEventDelete:X,onMoveStart:k,onCreateStart:T,onResizeStart:j,isDragging:N,dragState:S,newlyCreatedEventId:x,onDetailPanelOpen:()=>b(null),onChangeView:J,onSelectDate:e.selectDate,selectedEventId:D,onEventSelect:w,detailPanelEventId:C,onDetailPanelToggle:E,customDetailPanelContent:r,customEventDetailDialog:a},`week-${t.weekData.startDate.getTime()}`)}),n.jsx("div",{style:{height:_}})]})]})},Jh={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[exports.ViewType.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[exports.ViewType.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}},Kh=({app:e})=>{const a=e.getCurrentDate(),{yearHeight:o,screenSize:s}=Wh(),[i,l]=t.useState(!1),c=t.useRef(new Bh),d=t.useRef(new Date),{currentYear:u,isScrolling:h,virtualData:g,scrollElementRef:f,handleScroll:m,scrollToYear:v,handlePreviousYear:y,handleNextYear:p,handleToday:x}=Uh({currentDate:a,yearHeight:o}),b=t.useCallback((e,t)=>{const n=new Date(e,t,1),r=0===n.getDay()?6:n.getDay()-1,o=[],s=d.current,i=a;for(let n=0;n<42;n++){const a=new Date(e,t,n-r+1),l=a.getDate(),c=a.getMonth()===t;o.push({date:l,isCurrentMonth:c,isToday:c&&a.toDateString()===s.toDateString(),isSelected:c&&a.toDateString()===i.toDateString(),fullDate:a})}return{year:e,month:t,monthName:cu[t],days:o}},[a]),D=t.useCallback(e=>{let t=c.current.get(e);if(!t){const n=[];for(let t=0;t<12;t++)n.push(b(e,t));t={year:e,months:n},c.current.set(e,t)}return t},[b]),w=t.useCallback(()=>{e.goToToday(),x()},[e,x]);t.useEffect(()=>{const e=e=>{if(!e.repeat)switch(e.key){case"ArrowUp":e.preventDefault(),y();break;case"ArrowDown":e.preventDefault(),p();break;case"Home":e.preventDefault(),w();break;case"PageUp":e.preventDefault();const t=Math.max($h,u-5);v(t);break;case"PageDown":e.preventDefault();const n=Math.min(Yh,u+5);v(n);break;case"F12":e.shiftKey&&(e.preventDefault(),l(!i))}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u,y,p,w,v,i]);const C=t.memo(({monthData:t})=>n.jsxs("div",{className:"h-fit",children:[n.jsx("div",{className:`text-red-600 font-semibold mb-2 sm:mb-3 ${"mobile"===s?"text-xs":"text-xs sm:text-sm"} `,children:t.monthName}),n.jsx("div",{className:"grid grid-cols-7 gap-0 mb-1 sm:mb-2",children:["M","T","W","T","F","S","S"].map((e,t)=>n.jsx("div",{className:"text-center text-gray-500 py-0.5 text-xs w-10",children:e},t))}),n.jsx("div",{className:"grid grid-cols-7 gap-0",children:t.days.map((t,r)=>n.jsx("button",{className:`\n text-center rounded-sm transition-colors\n w-10\n ${"mobile"===s?"text-xs py-1 min-h-[18px]":"text-xs py-1 sm:py-1.5 min-h-[20px] sm:min-h-[26px]"}\n ${t.isCurrentMonth?"text-gray-900 font-medium hover:bg-gray-100 active:bg-gray-200":"text-gray-300 cursor-not-allowed"}\n ${t.isToday?"bg-red-500 text-white hover:bg-red-600 font-bold shadow-sm ring-2 ring-red-200":""}\n ${t.isSelected&&!t.isToday?"bg-red-100 text-red-600 font-semibold ring-1 ring-red-300":""}\n `,onClick:()=>t.isCurrentMonth&&e.selectDate(t.fullDate),disabled:!t.isCurrentMonth,children:t.date},r))})]})),E=t.memo(({item:e})=>{const t=D(e.year);return n.jsx("div",{className:"absolute w-full",style:{top:e.top,height:e.height,contain:"layout style paint"},children:n.jsx("div",{className:"px-4 py-2 bg-white",children:n.jsx("div",{className:"mx-auto px-8",children:n.jsx("div",{className:"grid gap-3 lg:gap-8 "+("mobile"===s?"grid-cols-2 grid-rows-6":"tablet"===s?"grid-cols-3 grid-rows-4":"grid-cols-4 grid-rows-3"),children:t.months.map(e=>n.jsx(C,{monthData:e},`${e.year}-${e.month}`))})})})})});return C.displayName="MonthComponent",E.displayName="VirtualYearItem",n.jsxs("div",{className:"relative flex flex-col bg-white shadow-md w-full overflow-hidden h-full",children:[n.jsx("div",{className:"p-2 bg-white",children:n.jsxs("div",{className:"flex justify-between items-center",children:[n.jsx("h1",{className:"text-2xl font-semibold",children:u}),n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("button",{className:"p-1 text-gray-600 hover:bg-gray-100 rounded",onClick:()=>e.goToPrevious(),title:"Previous week",children:n.jsx(r.ChevronLeft,{className:"h-5 w-5"})}),n.jsx("button",{className:"px-4 py-1 text-sm text-gray-700 hover:bg-gray-100 rounded",onClick:()=>e.goToToday(),title:"Go to today",children:"Today"}),n.jsx("button",{className:"p-1 text-gray-600 hover:bg-gray-100 rounded",onClick:()=>e.goToNext(),title:"Next week",children:n.jsx(r.ChevronRight,{className:"h-5 w-5"})})]})]})}),h&&n.jsx("div",{className:"absolute top-24 left-1/2 transform -translate-x-1/2 z-40 bg-white/95 backdrop-blur-sm py-2 px-4 rounded-lg shadow-lg border border-gray-200 transition-all duration-200 pointer-events-none",children:n.jsx("span",{className:"text-xl font-bold text-gray-900",children:u})}),n.jsx("div",{ref:f,className:"flex-1 overflow-auto bg-gray-50",onScroll:m,style:{contain:"layout style paint",scrollBehavior:"auto"},children:n.jsx("div",{className:"relative",style:{height:g.totalHeight},children:g.visibleItems.map(e=>n.jsx(E,{item:e},e.year))})}),n.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 opacity-30 hover:opacity-70 transition-opacity",children:n.jsxs("div",{className:"bg-gray-800 text-white text-xs px-2 py-1 rounded",children:[Math.round((u-$h)/(Yh-$h)*100),"%"]})})]})},Qh={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},eg={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};exports.CalendarApp=b,exports.CalendarEvent=lh,exports.CalendarRegistry=f,exports.ColorPicker=Eu,exports.DayFlowCalendar=({calendar:e,className:r,style:a,customDetailPanelContent:o,customEventDetailDialog:s,meta:i})=>{var l,c;const d=e.app,u=d.getCurrentView(),h=u.component,g=d.getSidebarConfig(),f=null!==(l=null==g?void 0:g.enabled)&&void 0!==l&&l,[m,v]=t.useState(0),[y,x]=t.useState(null!==(c=null==g?void 0:g.initialCollapsed)&&void 0!==c&&c),[b,D]=t.useState(()=>d.getTheme());t.useEffect(()=>{var e;x(null!==(e=null==g?void 0:g.initialCollapsed)&&void 0!==e&&e)},[null==g?void 0:g.initialCollapsed]),t.useEffect(()=>{const e=d.subscribeThemeChange(e=>{D(e)});return()=>{e()}},[d]);const w=t.useCallback(e=>{d.setTheme(e)},[d]),C=t.useCallback(()=>{v(e=>e+1)},[]),E=t.useMemo(()=>d.getCalendars(),[d,m]),M=t.useCallback((e,t)=>{d.setCalendarVisibility(e,t),C()},[d,C]),k=t.useCallback(e=>{d.setAllCalendarsVisibility(e),C()},[d,C]),T=t.useRef(null),j=s||(d.getUseEventDetailDialog()?Vu:void 0),S={app:d,config:u.config||{},customDetailPanelContent:o,customEventDetailDialog:j,switcherMode:d.state.switcherMode,calendarRef:T,meta:i},N={app:d,calendars:E,toggleCalendarVisibility:M,toggleAll:k,isCollapsed:y,setCollapsed:x},I=y?"60px":p(null==g?void 0:g.width,"240px");return n.jsx(Fu,{initialTheme:b,onThemeChange:w,children:n.jsx("div",{className:`calendar-container ${null!=r?r:""}`,style:Object.assign({height:800},a),children:n.jsxs("div",{className:"flex h-full",children:[f&&n.jsx("aside",{className:"shrink-0",style:{width:I},children:f?g.render?g.render(N):n.jsx(Cu,Object.assign({},N)):null}),n.jsx("div",{className:"flex flex-col flex-1 h-full",ref:T,children:n.jsx("div",{className:"calendar-renderer h-full",children:n.jsx(h,Object.assign({},S))})})]})})})},exports.DefaultEventDetailDialog=Vu,exports.DefaultEventDetailPanel=sh,exports.EventDetailPanelWithContent=ih,exports.EventLayoutCalculator=yh,exports.TIME_STEP=ru,exports.ThemeProvider=Fu,exports.ViewHeader=Sh,exports.addDays=_d,exports.buildParseRegExp=Su,exports.calculateDayIndex=xu,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,r,a=!1,o){return eh(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))},exports.convertDateEventWithTimeZone=function(e,t,n,r,a,o){return th(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))},exports.createAllDayEvent=function(e,t,n,r){return eh(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))},exports.createDateWithHour=Xd,exports.createDayView=(e={})=>{const n=Object.assign(Object.assign({},Ih),e),r=e=>t.createElement(Bu,{viewType:exports.ViewType.DAY,originalComponent:Nh,app:e.app,config:n,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return r.displayName="DayViewAdapter",{type:exports.ViewType.DAY,component:r,config:n}},exports.createDragPlugin=function(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[exports.ViewType.DAY,exports.ViewType.WEEK,exports.ViewType.MONTH]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{y.log("Drag plugin installed - providing drag capabilities")},api:n}},exports.createEvent=eh,exports.createEventWithDate=(e,t)=>{var n,r;const a=yu(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:pu(a,o),end:pu(a,o)})},exports.createEventWithRealDate=(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:pu(a,o),end:pu(a,o)})},exports.createEvents=function(e){return e.map(e=>eh(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},eg),e);let n;const r={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=r.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(r.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=a(n.getCurrentDate()),t=bu(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const s=r.getById(e);if(!s)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},s),o);if(t.enableValidation){const e=r.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=a(n.getCurrentDate()),t=bu(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=Fd(t.start);n.setHours(0,0,0,0);const r=new Date(e);return r.setHours(0,0,0,0),n.getTime()===r.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const r=Fd(n.start),a=Fd(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>bu(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function a(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}return{name:"events",config:t,install:e=>{n=e,y.log("Events plugin installed - providing event management services")},api:r}},exports.createMonthView=(e={})=>{const n=Object.assign(Object.assign({},Jh),e),r=e=>t.createElement(Bu,{viewType:exports.ViewType.MONTH,originalComponent:Xh,app:e.app,config:n,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return r.displayName="MonthViewAdapter",{type:exports.ViewType.MONTH,component:r,config:n}},exports.createTemporalWithHour=zd,exports.createTimedEvent=function(e,t,n,r,a){return eh(Object.assign({id:e,title:t,start:n,end:r},a))},exports.createTimezoneEvent=th,exports.createTimezoneEvents=function(e){return e.map(e=>th(e))},exports.createWeekView=(e={})=>{const n=Object.assign(Object.assign({},Oh),e),r=e=>t.createElement(Bu,{viewType:exports.ViewType.WEEK,originalComponent:Hh,app:e.app,config:n,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return r.displayName="WeekViewAdapter",{type:exports.ViewType.WEEK,component:r,config:n}},exports.createYearView=(e={})=>{const n=Object.assign(Object.assign({},Qh),e),r=e=>t.createElement(Bu,{viewType:exports.ViewType.YEAR,originalComponent:Kh,app:e.app,config:n,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta});return r.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:r,config:n}},exports.dateToPlainDate=Gu,exports.dateToPlainDateTime=Xu,exports.dateToZonedDateTime=Ju,exports.daysBetween=function(e,t){const n=Ld(e)?e:e.toPlainDate(),r=Ld(t)?t:t.toPlainDate();return n.until(r).days},exports.daysDifference=qd,exports.extractHourFromDate=Gd,exports.extractHourFromTemporal=function(e){return Uu(e)?0:e.hour+e.minute/60},exports.formatDate=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}`},exports.formatDateConsistent=Wu,exports.formatEventTimeRange=ou,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=Ou,exports.formatTime=au,exports.generateDayData=hu,exports.generateUniKey=Du,exports.generateWeekData=gu,exports.generateWeekRange=mu,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:r}=uu(e),a=[],o=Math.floor(n/2),s=new Date(r);s.setDate(s.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(s);t.setDate(t.getDate()+7*e),a.push(gu(t))}return a},exports.getAllDayEventsForDay=(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=Fd(t.start);a.setHours(0,0,0,0);const o=Fd(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getCurrentWeekDates=()=>{const e=new Date,t=new Date,n=e.getDay(),r=e.getDate()-n+(0===n?-6:1);return lu.map((n,a)=>{const o=new Date(e);return o.setDate(r+a),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},exports.getDateByDayIndex=yu,exports.getDayIndexByDate=(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)},exports.getEndOfDay=Jd,exports.getEndOfTemporal=Ud,exports.getEventBgColor=Qd,exports.getEventEndHour=iu,exports.getEventTextColor=eu,exports.getEventsForDay=vu,exports.getEventsForWeek=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=Fd(e.start);return r>=t&&r<=n}).map(e=>{const n=xu(Fd(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getLineColor=nu,exports.getMonthYearOfWeek=fu,exports.getPlainDate=function(e){return Uu(e)?e:(qu(e),e.toPlainDate())},exports.getSelectedBgColor=tu,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return Wd(e)},exports.getStartOfTemporal=Wd,exports.getTestEvents=function(){const e=new Date,t=e.getDay(),n=new Date(e),r=0===t?-6:1-t;n.setDate(e.getDate()+r),n.setHours(0,0,0,0);const a=[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(e=>{const t=new Date(n);if(t.setDate(n.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:Pd.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:Pd.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const r=Math.floor(e.startHour),a=Math.round(60*(e.startHour-r)),o=Math.floor(e.endHour),s=Math.round(60*(e.endHour-o));return{id:e.id,title:e.title,start:Pd.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:r,minute:a,timeZone:Pd.Now.timeZoneId()}),end:Pd.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:o,minute:s,timeZone:Pd.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}});return a},exports.getWeekRange=uu,exports.getZoneId=Iu,exports.isDate=function(e){return e instanceof Date},exports.isEventInWeek=(e,t)=>{const n=xu(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!Kd(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!Bd(e,t)},exports.isPlainDate=Uu,exports.isPlainDateTime=qu,exports.isSameDay=Kd,exports.isSamePlainDate=Bd,exports.isSameTemporal=function(e,t){const n=Uu(e)?e:(qu(e),e.toPlainDate()),r=Uu(t)?t:(qu(t),t.toPlainDate());return n.equals(r)},exports.isZonedDateTime=_u,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=Tu,exports.monthNames=cu,exports.normalizeCssWidth=p,exports.normalizeToZoned=Hu,exports.now=function(e=Pd.Now.timeZoneId()){return Pd.Now.zonedDateTimeISO(e)},exports.pad=ku,exports.parseTemporalString=Nu,exports.plainDateTimeToDate=function(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)},exports.plainDateToDate=function(e){return new Date(e.year,e.month-1,e.day)},exports.recalculateEventDays=bu,exports.roundToTimeStep=su,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return _u(e),e.with({hour:n,minute:r,second:0,millisecond:0})},exports.shortMonthNames=du,exports.temporalToDate=function(e){if(Uu(e))return new Date(e.year,e.month-1,e.day);if(qu(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);const t=e.toInstant();return new Date(t.epochMilliseconds)},exports.themeClasses={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-blue-500 dark:focus:ring-blue-400",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-blue-500 dark:focus:border-blue-400 focus:ring-blue-500 dark:focus:ring-blue-400",buttonPrimary:"bg-blue-500 dark:bg-blue-600 text-white hover:bg-blue-600 dark:hover:bg-blue-700",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 hover:bg-red-200 dark:hover:bg-red-800",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"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=Pd.Now.timeZoneId()){return Pd.Now.plainDateISO(e)},exports.updateEventDateAndDay=(e,t,n)=>{const r=yu(n,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?Pd.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):Pd.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:Pd.Now.timeZoneId()}),end:e.allDay?Pd.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):Pd.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:Pd.Now.timeZoneId()})})},exports.updateEventWithRealDate=(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:pu(a,o),end:pu(a,o)})},exports.useCalendarApp=function(e){const n=t.useMemo(()=>new b(e),[]),[r,a]=t.useState(n.state.currentView),[o,s]=t.useState(n.state.currentDate),[i,l]=t.useState(n.getEvents()),[,c]=t.useState({}),d=t.useCallback(()=>{c({})},[]);t.useEffect(()=>{const e=n.changeView;n.changeView=t=>{e(t),a(t),d()};const t=n.setCurrentDate;n.setCurrentDate=e=>{t(e),s(new Date(e)),d()};const r=n.addEvent;n.addEvent=e=>{r(e),l([...n.getEvents()]),d()};const o=n.updateEvent;n.updateEvent=(e,t,r)=>{o(e,t,r),l([...n.getEvents()]),d()};const i=n.deleteEvent;n.deleteEvent=e=>{i(e),l([...n.getEvents()]),d()};const c=n.setCalendarVisibility;n.setCalendarVisibility=(e,t)=>{c(e,t),l([...n.getEvents()]),d()};const u=n.setAllCalendarsVisibility;n.setAllCalendarsVisibility=e=>{u(e),l([...n.getEvents()]),d()};const h=n.setVisibleMonth;return n.setVisibleMonth=e=>{h(e),d()},()=>{}},[n,d]),t.useEffect(()=>{a(n.state.currentView),s(n.state.currentDate),l(n.getEvents())},[n]);const u=t.useCallback(e=>{n.changeView(e)},[n]),h=t.useCallback(e=>{n.setCurrentDate(e)},[n]),g=t.useCallback(e=>{n.addEvent(e)},[n]),f=t.useCallback((e,t,r)=>{n.updateEvent(e,t,r)},[n]),m=t.useCallback(e=>{n.deleteEvent(e)},[n]),v=t.useCallback(()=>{n.goToToday()},[n]),y=t.useCallback(()=>{n.goToPrevious()},[n]),p=t.useCallback(()=>{n.goToNext()},[n]),x=t.useCallback(e=>{n.selectDate(e)},[n]),D=t.useCallback((e,t)=>{n.setCalendarVisibility(e,t)},[n]),w=t.useCallback(e=>{n.setAllCalendarsVisibility(e)},[n]);return{app:n,currentView:r,currentDate:o,events:i,changeView:u,setCurrentDate:h,addEvent:g,updateEvent:f,deleteEvent:m,goToToday:v,goToPrevious:y,goToNext:p,selectDate:x,getCalendars:()=>n.getCalendars(),setCalendarVisibility:D,setAllCalendarsVisibility:w,getAllEvents:()=>n.getAllEvents(),setVisibleMonth:e=>n.setVisibleMonth(e),getVisibleMonth:()=>n.getVisibleMonth(),sidebarConfig:n.getSidebarConfig()}},exports.useDrag=Ch,exports.useDragForView=Eh,exports.useResponsiveConfig=Wh,exports.useResponsiveMonthConfig=qh,exports.useTheme=zu,exports.useVirtualMonthScroll=_h,exports.useVirtualScroll=Uh,exports.weekDays=lu,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=Zd;
1
+ "use strict";var e,t=require("react"),n=require("react/jsx-runtime"),r=require("lucide-react"),a=require("react-dom"),o=require("react-dom/client");exports.ViewType=void 0,(e=exports.ViewType||(exports.ViewType={})).DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year";const s=100,i=8,l=150,d=80,c=90,u=119;class h{constructor(e=s){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const g=[{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 f{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)}):g.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)}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}))})}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=this.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}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let m=new f;function v(){return m}const y=new class{constructor(){this.isDevelopment="production"!==process.env.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)}};function p(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const x="240px";class b{constructor(e){var n,r,a,o;this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e)},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate)},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const r=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===r.getFullYear()&&this.visibleMonth.getMonth()===r.getMonth()||(this.visibleMonth=r,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)))},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.addEvent=e=>{var t,n;this.state.events=[...this.state.events,e],null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e)},this.updateEvent=(e,t,n)=>{var r,a;const o=this.state.events.findIndex(t=>t.id===e);if(-1===o)throw new Error(`Event with id ${e} not found`);const s=Object.assign(Object.assign({},this.state.events[o]),t);this.state.events=[...this.state.events.slice(0,o),s,...this.state.events.slice(o+1)],n||null===(a=(r=this.callbacks).onEventUpdate)||void 0===a||a.call(r,s)},this.deleteEvent=e=>{var t,n;const r=this.state.events.findIndex(t=>t.id===e);if(-1===r)throw new Error(`Event with id ${e} not found`);this.state.events=[...this.state.events.slice(0,r),...this.state.events.slice(r+1)],null===(n=(t=this.callbacks).onEventDelete)||void 0===n||n.call(t,e)},this.getAllEvents=()=>[...this.state.events],this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.setCalendarVisibility=(e,t)=>{var n,r;this.calendarRegistry.setVisibility(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n)},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getSidebarConfig=()=>this.sidebarConfig,this.installPlugin=e=>{this.state.plugins.has(e.name)?y.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.render=()=>t.createElement("div",{className:"calendar-app"},"Calendar App"),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t))},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e)},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:e.defaultView||exports.ViewType.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.calendarRegistry=new f(e.calendars,e.defaultCalendar,(null===(n=e.theme)||void 0===n?void 0:n.mode)||"light"),o=this.calendarRegistry,m=o,this.sidebarConfig=(e=>{if(!e)return{enabled:!1,width:x,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:x,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:r=!1,render:a}=e;return{enabled:t,width:p(n,x),initialCollapsed:r,render:a}})(e.useSidebar),this.state.sidebar=this.sidebarConfig;const s=this.state.currentDate;this.visibleMonth=new Date(s.getFullYear(),s.getMonth(),1),this.useEventDetailDialog=null!==(r=e.useEventDetailDialog)&&void 0!==r&&r,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(a=e.plugins)||void 0===a||a.forEach(e=>{this.installPlugin(e)})}}const D="p-2 flex justify-between",w="text-2xl font-semibold text-gray-900 dark:text-gray-100",C="relative overflow-y-auto calendar-content",E="w-20 flex-shrink-0 border-gray-200 dark:border-gray-700",M="relative h-[4.5rem] flex",k="absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400",T="h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",j="absolute left-0 top-0 flex pointer-events-none",S="ml-2 text-white text-xs font-bold px-1.5 bg-red-500 rounded-sm",N="flex items-center border-b border-gray-200 dark:border-gray-700 sticky",I="w-20 flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end",H="calendar-event select-none pointer-events-auto px-0.5",O="rounded-xl my-0.5",R="font-medium text-xs truncate pr-1",P="absolute left-1 top-1 bottom-1 w-[3px] rounded-full",$="h-3 w-3 mr-1",Y="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",A="grid grid-cols-7 gap-1 text-xs justify-items-center",L="text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6",V="text-center py-1 rounded text-xs h-6 w-6",Z="text-gray-900 dark:text-gray-100",F="text-gray-400 dark:text-gray-600",z="bg-blue-500 rounded-full text-white",B="bg-red-100 text-red-600 rounded-full font-medium",W="text-gray-600 dark:text-gray-300",U="text-xs",q="text-sm",_="flex flex-col",G="mr-1";function X(e,t,n,r,a){return J(t,((e,t)=>{const n=e[t];if(void 0===n)throw new TypeError(po(t));return n})(e,t),n,r,a)}function J(e,t,n,r,a,o){const s=ye(t,n,r);if(a&&t!==s)throw new RangeError(vo(e,t,n,r,o));return s}function K(e){return null!==e&&/object|function/.test(typeof e)}function Q(e,t=Map){const n=new t;return(t,...r)=>{if(n.has(t))return n.get(t);const a=e(t,...r);return n.set(t,a),a}}function ee(e){return te({name:e},1)}function te(e,t){return oe(e=>({value:e,configurable:1,writable:!t}),e)}function ne(e){return oe(e=>({get:e,configurable:1}),e)}function re(e){return{[Symbol.toStringTag]:{value:e,configurable:1}}}function ae(e,t){const n={};let r=e.length;for(const a of t)n[e[--r]]=a;return n}function oe(e,t,n){const r={};for(const a in t)r[a]=e(t[a],a,n);return r}function se(e,t,n){const r={};for(let a=0;a<t.length;a++){const o=t[a];r[o]=e(o,a,n)}return r}function ie(e,t,n){const r={};for(let a=0;a<e.length;a++)r[t[a]]=n[e[a]];return r}function le(e,t){const n=Object.create(null);for(const r of e)n[r]=t[r];return n}function de(e,t){for(const n of t)if(n in e)return 1;return 0}function ce(e,t,n){for(const r of e)if(t[r]!==n[r])return 0;return 1}function ue(e,t,n){const r={...n};for(let n=0;n<t;n++)r[e[n]]=0;return r}function he(e,...t){return(...n)=>e(...t,...n)}function ge(e){return e[0].toUpperCase()+e.substring(1)}function fe(e){return e.slice().sort()}function me(e,t){return String(t).padStart(e,"0")}function ve(e,t){return Math.sign(e-t)}function ye(e,t,n){return Math.min(Math.max(e,t),n)}function pe(e,t){return[Math.floor(e/t),xe(e,t)]}function xe(e,t){return(e%t+t)%t}function be(e,t){return[De(e,t),we(e,t)]}function De(e,t){return Math.trunc(e/t)||0}function we(e,t){return e%t||0}function Ce(e){return.5===Math.abs(e%1)}function Ee(e,t,n){let r=0,a=0;for(let o=0;o<=t;o++){const t=e[n[o]],s=gs[o],i=hs/s,[l,d]=be(t,i);r+=d*s,a+=l}const[o,s]=be(r,hs);return[a+o,s]}function Me(e,t,n){const r={};for(let a=t;a>=0;a--){const t=gs[a];r[n[a]]=De(e,t),e=we(e,t)}return r}function ke(e){if(void 0!==e)return je(e)}function Te(e){return Oe(je(e))}function je(e){return He(Vs(e))}function Se(e,t){if(null==t)throw new RangeError(po(e));return t}function Ne(e){if(!K(e))throw new TypeError(mo);return e}function Ie(e,t,n=e){if(typeof t!==e)throw new TypeError(yo(n,t));return t}function He(e,t="number"){if(!Number.isInteger(e))throw new RangeError(lo(t,e));return e||0}function Oe(e,t="number"){if(e<=0)throw new RangeError(co(t,e));return e}function Re(e){if("symbol"==typeof e)throw new TypeError(fo);return String(e)}function Pe(e,t){return K(e)?String(e):As(e,t)}function $e(e){if("string"==typeof e)return BigInt(e);if("bigint"!=typeof e)throw new TypeError(go(e));return e}function Ye(e,t="number"){if("bigint"==typeof e)throw new TypeError(ho(t));if(e=Number(e),!Number.isFinite(e))throw new RangeError(uo(t,e));return e}function Ae(e,t){return Math.trunc(Ye(e,t))||0}function Le(e,t){return He(Ye(e,t),t)}function Ve(e,t){return Oe(Ae(e,t),t)}function Ze(e,t){let[n,r]=be(t,hs),a=e+n;const o=Math.sign(a);return o&&o===-Math.sign(r)&&(a-=o,r+=o*hs),[a,r]}function Fe(e,t,n=1){return Ze(e[0]+t[0]*n,e[1]+t[1]*n)}function ze(e,t){return Ze(e[0],e[1]+t)}function Be(e,t){return Fe(t,e,-1)}function We(e,t){return ve(e[0],t[0])||ve(e[1],t[1])}function Ue(e,t,n){return-1===We(e,t)||1===We(e,n)}function qe(e,t=1){const n=BigInt(hs/t);return[Number(e/n),Number(e%n)*t]}function _e(e,t=1){const n=hs/t,[r,a]=be(e,n);return[r,a*t]}function Ge(e,t=1,n){const[r,a]=e,[o,s]=be(a,t);return r*(hs/t)+(o+(n?s/t:0))}function Xe(e,t,n=pe){const[r,a]=e,[o,s]=n(a,t);return[r*(hs/t)+o,s]}function Je(e){return X(e,"isoYear",di,li,1),e.isoYear===di?X(e,"isoMonth",4,12,1):e.isoYear===li&&X(e,"isoMonth",1,9,1),e}function Ke(e){return Qe({...e,...ni,isoHour:12}),e}function Qe(e){const t=X(e,"isoYear",di,li,1),n=t===di?1:t===li?-1:0;return n&&et(ot({...e,isoDay:e.isoDay+n,isoNanosecond:e.isoNanosecond-n})),e}function et(e){if(!e||Ue(e,ii,si))throw new RangeError(zo);return e}function tt(e){return Ee(e,5,Xs)[1]}function nt(e){const[t,n]=pe(e,hs);return[Me(n,5,Xs),t]}function rt(e){return Xe(e,ds)}function at(e){return lt(e.isoYear,e.isoMonth,e.isoDay,e.isoHour,e.isoMinute,e.isoSecond,e.isoMillisecond)}function ot(e){const t=at(e);if(void 0!==t){const[n,r]=be(t,os);return[n,r*ls+(e.isoMicrosecond||0)*is+(e.isoNanosecond||0)]}}function st(e,t){const[n,r]=nt(tt(e)-t);return et(ot({...e,isoDay:e.isoDay+r,...n}))}function it(...e){return lt(...e)/ss}function lt(...e){const[t,n]=dt(...e),r=t.valueOf();if(!isNaN(r))return r-n*os}function dt(e,t=1,n=1,r=0,a=0,o=0,s=0){const i=e===di?1:e===li?-1:0,l=new Date;return l.setUTCHours(r,a,o,s),l.setUTCFullYear(e,t-1,n+i),[l,i]}function ct(e,t){let[n,r]=ze(e,t);r<0&&(r+=hs,n-=1);const[a,o]=pe(r,ls),[s,i]=pe(o,is);return ut(n*os+a,s,i)}function ut(e,t=0,n=0){const r=Math.ceil(Math.max(0,Math.abs(e)-oi)/os)*Math.sign(e),a=new Date(e-r*os);return ae(Ks,[a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate()+r,a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds(),t,n])}function ht(e,t){if(t<-oi)throw new RangeError(zo);const n=e.formatToParts(t),r={};for(const e of n)r[e.type]=e.value;return r}function gt(e){return[e.isoYear,e.isoMonth,e.isoDay]}function ft(e,t){return[t,0]}function mt(){return fi}function vt(e,t){switch(t){case 2:return pt(e)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function yt(e){return pt(e)?366:365}function pt(e){return e%4==0&&(e%100!=0||e%400==0)}function xt(e){const[t,n]=dt(e.isoYear,e.isoMonth,e.isoDay);return xe(t.getUTCDay()-n,7)||7}function bt(e){return this.id===Os?(({isoYear:e})=>e<1?["gregory-inverse",1-e]:["gregory",e])(e):this.id===Rs?vi(e):[]}function Dt(e){const t=at(e);if(t<mi){const{isoYear:t}=e;return t<1?["japanese-inverse",1-t]:["japanese",t]}const n=ht(Tl(Rs),t),{era:r,eraYear:a}=ka(n,Rs);return[r,a]}function wt(e){return Ct(e),kt(e,1),e}function Ct(e){return Mt(e,1),e}function Et(e){return ce(Js,e,Mt(e))}function Mt(e,t){const{isoYear:n}=e,r=X(e,"isoMonth",1,mt(),t);return{isoYear:n,isoMonth:r,isoDay:X(e,"isoDay",1,vt(n,r),t)}}function kt(e,t){return ae(Xs,[X(e,"isoHour",0,23,t),X(e,"isoMinute",0,59,t),X(e,"isoSecond",0,59,t),X(e,"isoMillisecond",0,999,t),X(e,"isoMicrosecond",0,999,t),X(e,"isoNanosecond",0,999,t)])}function Tt(e){return void 0===e?0:Pi(Ne(e))}function jt(e,t=0){e=At(e);const n=$i(e),r=Yi(e,t);return[Pi(e),r,n]}function St(e,t,n,r=9,a=0,o=4){t=At(t);let s=Oi(t,r,a),i=Pt(t),l=Zi(t,o);const d=Hi(t,r,a,1);return null==s?s=Math.max(n,d):zt(s,d),i=$t(i,d,1),e&&(l=(e=>e<4?(e+2)%4:e)(l)),[s,d,i,l]}function Nt(e,t=6,n){let r=Pt(e=Lt(e,yi));const a=Zi(e,7);let o=Hi(e,t);return o=Se(yi,o),r=$t(r,o,void 0,n),[o,r,a]}function It(e){return Ai(At(e))}function Ht(e,t){return Ot(At(e),t)}function Ot(e,t=4){const n=Yt(e);return[Zi(e,4),...Rt(Hi(e,t),n)]}function Rt(e,t){return null!=e?[gs[e],e<4?9-3*e:-1]:[void 0===t?1:10**(9-t),t]}function Pt(e){const t=e[xi];return void 0===t?1:Ae(t,xi)}function $t(e,t,n,r){const a=r?hs:gs[t+1];if(a){const n=gs[t];if(a%((e=J(xi,e,1,a/n-(r?0:1),1))*n))throw new RangeError(yo(xi,e))}else e=J(xi,e,1,n?10**9:1,1);return e}function Yt(e){let t=e[bi];if(void 0!==t){if("number"!=typeof t){if("auto"===Re(t))return;throw new RangeError(yo(bi,t))}t=J(bi,Math.floor(t),0,9,1)}return t}function At(e){return void 0===e?{}:Ne(e)}function Lt(e,t){return"string"==typeof e?{[t]:e}:Ne(e)}function Vt(e){return{overflow:Ei[e]}}function Zt(e,t,n=9,r=0,a){let o=t[e];if(void 0===o)return a?r:void 0;if(o=Re(o),"auto"===o)return a?r:null;let s=rs[o];if(void 0===s&&(s=Us[o]),void 0===s)throw new RangeError(wo(e,o,rs));return J(e,s,r,n,1,as),s}function Ft(e,t,n,r=0){const a=n[e];if(void 0===a)return r;const o=Re(a),s=t[o];if(void 0===s)throw new RangeError(wo(e,o,t));return s}function zt(e,t){if(t>e)throw new RangeError(Go)}function Bt(e){return{branding:_i,epochNanoseconds:e}}function Wt(e,t,n){return{branding:qi,calendar:n,timeZone:t,epochNanoseconds:e}}function Ut(e,t=e.calendar){return{branding:Wi,calendar:t,...le(ti,e)}}function qt(e,t=e.calendar){return{branding:Bi,calendar:t,...le(Qs,e)}}function _t(e,t=e.calendar){return{branding:Fi,calendar:t,...le(Qs,e)}}function Gt(e,t=e.calendar){return{branding:zi,calendar:t,...le(Qs,e)}}function Xt(e){return{branding:Ui,...le(ei,e)}}function Jt(e){return{branding:Gi,sign:hr(e),...le(Fs,e)}}function Kt(e){return Xe(e.epochNanoseconds,ls)[0]}function Qt(e){return e.epochNanoseconds}function en(e,t){return Ge(mr(e),gs[t],1)}function tn(e,t,n,r,a,o,s){const i=Zs[n],l={...t,[i]:t[i]+r},d=s(e,a,t),c=s(e,a,l);return[o(d),o(c)]}function nn(e,t,n){const r=Ge(Be(t,n));if(!r)throw new RangeError(Oo);return Ge(Be(t,e))/r}function rn(e,t,n,r){return an(e,ln(t,n),r)}function an(e,t,n){const[r,a]=on(e,t,n);return Qe({...nr(e,a),...r})}function on(e,t,n){return nt(mn(tt(e),t,n))}function sn(e){return mn(e,cs,7)}function ln(e,t){return gs[e]*t}function dn(e){const t=cn(e);return[t,nr(t,1)]}function cn(e){return ri(6,e)}function un(e,t,n){const r=Math.min(xr(e),6);return vr(fn(mr(e,r),t,n),r)}function hn(e,t,n,r,a,o,s,i,l,d){if(0===r&&1===a)return e;const c=lr(r,i)?ir(i)&&r<6&&n>=6?pn:yn:xn;let[u,h,g]=c(e,t,n,r,a,o,s,i,l,d);return g&&7!==r&&(u=((e,t,n,r,a,o,s,i)=>{const l=hr(e);for(let d=r+1;d<=n;d++){if(7===d&&7!==n)continue;const r=Gs(d,e);r[Zs[d]]+=l;const c=Ge(Be(s(i(a,o,r)),t));if(c&&Math.sign(c)!==l)break;e=r}return e})(u,h,n,Math.max(6,r),s,i,l,d)),u}function gn(e,t,n,r,a){if(6===t){const t=(e=>e[0]+e[1]/hs)(e);return[mn(t,n,r),0]}return fn(e,ln(t,n),r,a)}function fn(e,t,n,r){let[a,o]=e;r&&o<0&&(o+=hs,a-=1);const[s,i]=pe(mn(o,t,n),hs);return Ze(a+s,i)}function mn(e,t,n){return vn(e/t,n)*t}function vn(e,t){return Xi[t](e)}function yn(e,t,n,r,a,o){const s=hr(e),i=mr(e),l=gn(i,r,a,o),d=Be(i,l),c=Math.sign(l[0]-i[0])===s,u=vr(l,Math.min(n,6));return[{...e,...u},Fe(t,d),c]}function pn(e,t,n,r,a,o,s,i,l,d){const c=hr(e)||1,u=Ge(mr(e,5)),h=ln(r,a);let g=mn(u,h,o);const[f,m]=tn(s,{...e,..._s},6,c,i,l,d),v=g-Ge(Be(f,m));let y=0;v&&Math.sign(v)!==c?t=ze(f,g):(y+=c,g=mn(v,h,o),t=ze(m,g));const p=yr(g);return[{...e,...p,days:e.days+y},t,Boolean(y)]}function xn(e,t,n,r,a,o,s,i,l,d){const c=hr(e),u=Zs[r],h=Gs(r,e);7===r&&(e={...e,weeks:e.weeks+Math.trunc(e.days/7)});const g=De(e[u],a)*a;h[u]=g;const[f,m]=tn(s,h,r,a*c,i,l,d),v=g+nn(t,f,m)*c*a,y=mn(v,a,o),p=Math.sign(y-v)===c;return h[u]=y,[h,p?m:f,p]}function bn(e,t,n,r){const[a,o,s,i]=(e=>{const t=Ot(e=At(e));return[e.timeZone,...t]})(r),l=void 0!==a;return((e,t,n,r,a,o)=>{n=fn(n,a,r,1);const s=t.R(n);return Nn(ct(n,s),o)+(e?Pn(sn(s)):"Z")})(l,t(l?e(a):Ji),n.epochNanoseconds,o,s,i)}function Dn(e,t,n){const[r,a,o,s,i,l]=(e=>{e=At(e);const t=Ai(e),n=Yt(e),r=Vi(e),a=Zi(e,4),o=Hi(e,4);return[t,Li(e),r,a,...Rt(o,n)]})(n);return((e,t,n,r,a,o,s,i,l,d)=>{r=fn(r,l,i,1);const c=e(n).R(r);return Nn(ct(r,c),d)+Pn(sn(c),s)+((e,t)=>1!==t?"["+(2===t?"!":"")+e+"]":"")(n,o)+$n(t,a)})(e,t.calendar,t.timeZone,t.epochNanoseconds,r,a,o,s,i,l)}function wn(e,t){const[n,r,a,o]=(e=>(e=At(e),[Ai(e),...Ot(e)]))(t);return s=e.calendar,i=n,l=o,Nn(an(e,a,r),l)+$n(s,i);var s,i,l}function Cn(e,t){return n=e.calendar,r=e,a=It(t),In(r)+$n(n,a);var n,r,a}function En(e,t){return jn(e.calendar,Hn,e,It(t))}function Mn(e,t){return jn(e.calendar,On,e,It(t))}function kn(e,t){const[n,r,a]=Ht(t);return o=a,Rn(on(e,r,n)[0],o);var o}function Tn(e,t){const[n,r,a]=Ht(t,3);return r>1&&gr(e={...e,...un(e,r,n)}),((e,t)=>{const{sign:n}=e,r=-1===n?ur(e):e,{hours:a,minutes:o}=r,[s,i]=Xe(mr(r,3),ds,be);fr(s);const l=An(i,t),d=t>=0||!n||l;return(n<0?"-":"")+"P"+Sn({Y:Vn(r.years),M:Vn(r.months),W:Vn(r.weeks),D:Vn(r.days)})+(a||o||s||d?"T"+Sn({H:Vn(a),M:Vn(o),S:Vn(s,d)+l}):"")})(e,a)}function jn(e,t,n,r){const a=r>1||0===r&&e!==Hs;return 1===r?e===Hs?t(n):In(n):a?In(n)+Yn(e,2===r):t(n)}function Sn(e){const t=[];for(const n in e){const r=e[n];r&&t.push(r,n)}return t.join("")}function Nn(e,t){return In(e)+"T"+Rn(e,t)}function In(e){return Hn(e)+"-"+ns(e.isoDay)}function Hn(e){const{isoYear:t}=e;return(t<0||t>9999?Ln(t)+me(6,Math.abs(t)):me(4,t))+"-"+ns(e.isoMonth)}function On(e){return ns(e.isoMonth)+"-"+ns(e.isoDay)}function Rn(e,t){const n=[ns(e.isoHour),ns(e.isoMinute)];return-1!==t&&n.push(ns(e.isoSecond)+((e,t,n,r)=>An(e*ls+t*is+n,r))(e.isoMillisecond,e.isoMicrosecond,e.isoNanosecond,t)),n.join(":")}function Pn(e,t=0){if(1===t)return"";const[n,r]=pe(Math.abs(e),us),[a,o]=pe(r,cs),[s,i]=pe(o,ds);return Ln(e)+ns(n)+":"+ns(a)+(s||i?":"+ns(s)+An(i):"")}function $n(e,t){return 1!==t&&(t>1||0===t&&e!==Hs)?Yn(e,2===t):""}function Yn(e,t){return"["+(t?"!":"")+"u-ca="+e+"]"}function An(e,t){let n=me(9,e);return n=void 0===t?n.replace(tl,""):n.slice(0,t),n?"."+n:""}function Ln(e){return e<0?"-":"+"}function Vn(e,t){return e||t?e.toLocaleString("fullwide",{useGrouping:0}):""}function Zn(e,t){const{epochNanoseconds:n}=e,r=(t.R?t:t(e.timeZone)).R(n),a=ct(n,r);return{calendar:e.calendar,...a,offsetNanoseconds:r}}function Fn(e,t,n,r=0,a=0,o,s){if(void 0!==n&&1===r&&(1===r||s))return st(t,n);const i=e.I(t);if(void 0!==n&&3!==r){const e=((e,t,n,r)=>{const a=ot(t);r&&(n=sn(n));for(const t of e){let e=Ge(Be(t,a));if(r&&(e=sn(e)),e===n)return t}})(i,t,n,o);if(void 0!==e)return e;if(0===r)throw new RangeError(Zo)}return s?ot(t):zn(e,t,a,i)}function zn(e,t,n=0,r=e.I(t)){if(1===r.length)return r[0];if(1===n)throw new RangeError(Fo);if(r.length)return r[3===n?1:0];const a=ot(t),o=((e,t)=>{const n=e.R(ze(t,-hs));return(e=>{if(e>hs)throw new RangeError(Vo);return e})(e.R(ze(t,hs))-n)})(e,a),s=o*(2===n?-1:1);return(r=e.I(ct(a,s)))[2===n?0:r.length-1]}function Bn(e,t){const n=e.I(t);if(n.length)return n[0];const r=ze(ot(t),-hs);return e.O(r,1)}function Wn(e,t,n){return Bt(et(Fe(t.epochNanoseconds,(e=>{if(pr(e))throw new RangeError(qo);return mr(e,5)})(e?ur(n):n))))}function Un(e,t,n,r,a,o=Object.create(null)){const s=t(r.timeZone),i=e(r.calendar);return{...r,...Jn(s,i,r,n?ur(a):a,o)}}function qn(e,t,n,r,a=Object.create(null)){const{calendar:o}=n;return Ut(Kn(e(o),n,t?ur(r):r,a),o)}function _n(e,t,n,r,a){const{calendar:o}=n;return qt(Qn(e(o),n,t?ur(r):r,a),o)}function Gn(e,t,n,r,a){const o=n.calendar,s=e(o);let i=Ke(er(s,n));t&&(r=cr(r)),r.sign<0&&(i=s.P(i,{...qs,months:1}),i=nr(i,-1));const l=s.P(i,r,a);return _t(er(s,l),o)}function Xn(e,t,n){return Xt(tr(t,e?ur(n):n)[0])}function Jn(e,t,n,r,a){const o=mr(r,5);let s=n.epochNanoseconds;if(pr(r)){const i=nl(n,e);s=Fe(zn(e,{...Qn(t,i,{...r,..._s},a),...le(Xs,i)}),o)}else s=Fe(s,o),Tt(a);return{epochNanoseconds:et(s)}}function Kn(e,t,n,r){const[a,o]=tr(t,n);return Qe({...Qn(e,t,{...n,..._s,days:n.days+o},r),...a})}function Qn(e,t,n,r){if(n.years||n.months||n.weeks)return e.P(t,n,r);Tt(r);const a=n.days+mr(n,5)[0];return a?Ke(nr(t,a)):t}function er(e,t,n=1){return nr(t,n-e.day(t))}function tr(e,t){const[n,r]=mr(t,5),[a,o]=nt(tt(e)+r);return[a,n+o]}function nr(e,t){return t?{...e,...ut(at(e)+t*os)}:e}function rr(e,t,n){const r=e(n.calendar);return ir(n)?[n,r,t(n.timeZone)]:[{...n,...ni},r]}function ar(e){return e?Qt:ot}function or(e){return e?he(Jn,e):Kn}function sr(e){return e?he(na,e):ra}function ir(e){return e&&e.epochNanoseconds}function lr(e,t){return e<=6-(ir(t)?1:0)}function dr(e,t,n,r,a,o,s){const i=e(At(s).relativeTo),l=Math.max(xr(a),xr(o));if(lr(l,i))return Jt(gr(((e,t,n,r)=>{const a=Fe(mr(e),mr(t),r?-1:1);if(!Number.isFinite(a[0]))throw new RangeError(zo);return{...qs,...vr(a,n)}})(a,o,l,r)));if(!i)throw new RangeError(Uo);r&&(o=ur(o));const[d,c,u]=rr(t,n,i),h=or(u),g=sr(u),f=h(c,d,a);return Jt(g(c,d,h(c,f,o),l))}function cr(e){return Jt(ur(e))}function ur(e){const t={};for(const n of Zs)t[n]=-1*e[n]||0;return t}function hr(e,t=Zs){let n=0;for(const r of t){const t=Math.sign(e[r]);if(t){if(n&&n!==t)throw new RangeError(Wo);n=t}}return n}function gr(e){for(const t of Ws)J(t,e[t],-rl,rl,1);return fr(Ge(mr(e),ds)),e}function fr(e){if(!Number.isSafeInteger(e))throw new RangeError(Bo)}function mr(e,t=6){return Ee(e,t,Zs)}function vr(e,t=6){const[n,r]=e,a=Me(r,t,Zs);if(a[Zs[t]]+=n*(hs/gs[t]),!Number.isFinite(a[Zs[t]]))throw new RangeError(zo);return a}function yr(e,t=5){return Me(e,t,Zs)}function pr(e){return Boolean(hr(e,Bs))}function xr(e){let t=9;for(;t>0&&!e[Zs[t]];t--);return t}function br(e,t){return[e,t]}function Dr(e){const t=Math.floor(e/Ki)*Ki;return[t,t+Ki]}function wr(e){const t=Hr(e);if(void 0===t)throw new RangeError(Xo(e));return t}function Cr(e,t,n){let r=Sr(As(e));if(!r||r.j)throw new RangeError(Xo(e));return t?r.calendar===Hs&&(r=-271821===r.isoYear&&4===r.isoMonth?{...r,isoDay:20,...ni}:{...r,isoDay:1,...ni}):n&&r.calendar===Hs&&(r={...r,isoYear:gi}),qt(r.C?kr(r):Tr(r))}function Er(e){if(e.calendar!==Hs)throw new RangeError(Jo(e.calendar))}function Mr(e,t,n=0,r=0){const a=Vr(e.timeZone),o=al(a);let s;return wt(e),s=e.C?Fn(o,e,t,n,r,!o.$,e.j):Bn(o,e),Wt(s,a,Aa(e.calendar))}function kr(e){return jr(Qe(wt(e)))}function Tr(e){return jr(Ke(Ct(e)))}function jr(e){return{...e,calendar:Aa(e.calendar)}}function Sr(e){const t=yl.exec(e);return t?(e=>{const t=e[10],n="Z"===(t||"").toUpperCase();return{isoYear:Or(e),isoMonth:parseInt(e[4]),isoDay:parseInt(e[5]),...Rr(e.slice(5)),...Pr(e[16]),C:Boolean(e[6]),j:n,offset:n?void 0:t}})(t):void 0}function Nr(e){const t=ml.exec(e);return t?(e=>({isoYear:Or(e),isoMonth:parseInt(e[4]),isoDay:1,...Pr(e[5])}))(t):void 0}function Ir(e){const t=vl.exec(e);return t?(e=>({isoYear:gi,isoMonth:parseInt(e[1]),isoDay:parseInt(e[2]),...Pr(e[3])}))(t):void 0}function Hr(e,t){const n=xl.exec(e);return n?((e,t)=>{const n=e[4]||e[5];if(t&&n)throw new RangeError(Jo(n));return(e=>{if(Math.abs(e)>=hs)throw new RangeError(Lo);return e})((Lr(e[2])*us+Lr(e[3])*cs+Lr(e[4])*ds+$r(e[5]||""))*Ar(e[1]))})(n,t):void 0}function Or(e){const t=Ar(e[1]),n=parseInt(e[2]||e[3]);if(t<0&&!n)throw new RangeError(Jo(-0));return t*n}function Rr(e){const t=Lr(e[3]);return{...nt($r(e[4]||""))[0],isoHour:Lr(e[1]),isoMinute:Lr(e[2]),isoSecond:60===t?59:t}}function Pr(e){let t,n;const r=[];if(e.replace(bl,(e,a,o)=>{const s=Boolean(a),[i,l]=o.split("=").reverse();if(l){if("u-ca"===l)r.push(i),t||(t=s);else if(s||/[A-Z]/.test(l))throw new RangeError(Jo(e))}else{if(n)throw new RangeError(Jo(e));n=i}return""}),r.length>1&&t)throw new RangeError(Jo(e));return{timeZone:n,calendar:r[0]||Hs}}function $r(e){return parseInt(e.padEnd(9,"0"))}function Yr(e){return new RegExp(`^${e}$`,"i")}function Ar(e){return e&&"+"!==e?-1:1}function Lr(e){return void 0===e?0:parseInt(e)}function Vr(e){const t=Fr(e);return"number"==typeof t?Pn(t):t?(e=>{if(El.test(e))throw new RangeError($o(e));if(Cl.test(e))throw new RangeError(Ao);return e.toLowerCase().split("/").map((e,t)=>(e.length<=3||/\d/.test(e))&&!/etc|yap/.test(e)?e.toUpperCase():e.replace(/baja|dumont|[a-z]+/g,(e,n)=>e.length<=2&&!t||"in"===e||"chat"===e?e.toUpperCase():e.length>2||!n?ge(e).replace(/island|noronha|murdo|rivadavia|urville/,ge):e)).join("/")})(e):Ji}function Zr(e){const t=Fr(e);return"number"==typeof t?t:t?t.resolvedOptions().timeZone:Ji}function Fr(e){const t=Hr(e=e.toUpperCase(),1);return void 0!==t?t:e!==Ji?wl(e):void 0}function zr(e,t){return We(e.epochNanoseconds,t.epochNanoseconds)}function Br(e,t){return We(e.epochNanoseconds,t.epochNanoseconds)}function Wr(e,t){return Ur(e,t)||qr(e,t)}function Ur(e,t){return ve(at(e),at(t))}function qr(e,t){return ve(tt(e),tt(t))}function _r(e,t){if(e===t)return 1;try{return Zr(e)===Zr(t)}catch(e){}}function Gr(e,t,n,r){const a=St(e,r,3,5),o=sa(t.epochNanoseconds,n.epochNanoseconds,...a);return Jt(e?ur(o):o)}function Xr(e,t,n,r,a,o){const s=ua(r.calendar,a.calendar),[i,l,d,c]=St(n,o,5),u=r.epochNanoseconds,h=a.epochNanoseconds,g=We(h,u);let f;if(g)if(i<6)f=sa(u,h,i,l,d,c);else{const n=t(((e,t)=>{if(!_r(e,t))throw new RangeError(Yo);return e})(r.timeZone,a.timeZone)),u=e(s);f=aa(u,n,r,a,g,i,o),f=hn(f,h,i,l,d,c,u,r,Qt,he(Jn,n))}else f=qs;return Jt(n?ur(f):f)}function Jr(e,t,n,r,a){const o=ua(n.calendar,r.calendar),[s,i,l,d]=St(t,a,6),c=ot(n),u=ot(r),h=We(u,c);let g;if(h)if(s<=6)g=sa(c,u,s,i,l,d);else{const t=e(o);g=oa(t,n,r,h,s,a),g=hn(g,u,s,i,l,d,t,n,ot,Kn)}else g=qs;return Jt(t?ur(g):g)}function Kr(e,t,n,r,a){const o=ua(n.calendar,r.calendar);return ea(t,()=>e(o),n,r,...St(t,a,6,9,6))}function Qr(e,t,n,r,a){const o=ua(n.calendar,r.calendar),s=St(t,a,9,9,8),i=e(o),l=er(i,n),d=er(i,r);return l.isoYear===d.isoYear&&l.isoMonth===d.isoMonth&&l.isoDay===d.isoDay?Jt(qs):ea(t,()=>i,Ke(l),Ke(d),...s,8)}function ea(e,t,n,r,a,o,s,i,l=6){const d=ot(n),c=ot(r);if(void 0===d||void 0===c)throw new RangeError(zo);let u;if(We(c,d))if(6===a)u=sa(d,c,a,o,s,i);else{const e=t();u=e.N(n,r,a),o===l&&1===s||(u=hn(u,c,a,o,s,i,e,n,ot,Qn))}else u=qs;return Jt(e?ur(u):u)}function ta(e,t,n,r){const[a,o,s,i]=St(e,r,5,5),l=mn(ca(t,n),ln(o,s),i),d={...qs,...yr(l,a)};return Jt(e?ur(d):d)}function na(e,t,n,r,a,o){const s=We(r.epochNanoseconds,n.epochNanoseconds);return s?a<6?ia(n.epochNanoseconds,r.epochNanoseconds,a):aa(t,e,n,r,s,a,o):qs}function ra(e,t,n,r,a){const o=ot(t),s=ot(n),i=We(s,o);return i?r<=6?ia(o,s,r):oa(e,t,n,i,r,a):qs}function aa(e,t,n,r,a,o,s){const[i,l,d]=((e,t,n,r)=>{function a(){return u={...nr(i,d++*-r),...s},h=zn(e,u),We(l,h)===-r}const o=nl(t,e),s=le(Xs,o),i=nl(n,e),l=n.epochNanoseconds;let d=0;const c=ca(o,i);let u,h;if(Math.sign(c)===-r&&d++,a()&&(-1===r||a()))throw new RangeError(Oo);const g=Ge(Be(h,l));return[o,u,g]})(t,n,r,a);var c,u;return{...6===o?(c=i,u=l,{...qs,days:la(c,u)}):e.N(i,l,o,s),...yr(d)}}function oa(e,t,n,r,a,o){const[s,i,l]=((e,t,n)=>{let r=t,a=ca(e,t);return Math.sign(a)===-n&&(r=nr(t,-n),a+=hs*n),[e,r,a]})(t,n,r);return{...e.N(s,i,a,o),...yr(l)}}function sa(e,t,n,r,a,o){return{...qs,...vr(gn(Be(e,t),r,a,o),n)}}function ia(e,t,n){return{...qs,...vr(Be(e,t),n)}}function la(e,t){return da(at(e),at(t))}function da(e,t){return Math.trunc((t-e)/os)}function ca(e,t){return tt(t)-tt(e)}function ua(e,t){if(e!==t)throw new RangeError(Po);return e}function ha(e){return this.m(e)[0]}function ga(e){return this.m(e)[1]}function fa(e){const[t]=this.v(e);return da(this.p(t),at(e))+1}function ma(e){const t=Ml.exec(e);if(!t)throw new RangeError(So(e));return[parseInt(t[1]),Boolean(t[2])]}function va(e,t){return"M"+ns(e)+(t?"L":"")}function ya(e,t,n){return e+(t||n&&e>=n?1:0)}function pa(e,t){return e-(t&&e>=t?1:0)}function xa(e,t){return(t+e)*(Math.sign(t)||1)||0}function ba(e){return Ps[wa(e)]}function Da(e){return Ys[wa(e)]}function wa(e){return La(e.id||Hs)}function Ca(e){function t(e){return((e,t)=>({...ka(e,t),o:e.month,day:parseInt(e.day)}))(ht(n,e),r)}const n=Tl(e),r=La(e);return{id:e,h:Ea(t),l:Ma(t)}}function Ea(e){return Q(t=>{const n=at(t);return e(n)},WeakMap)}function Ma(e){const t=e(0).year-hi;return Q(n=>{let r,a=lt(n-t),o=0;const s=[],i=[];do{a+=400*os}while((r=e(a)).year<=n);do{if(a+=(1-r.day)*os,r.year===n&&(s.push(a),i.push(r.o)),a-=os,++o>100||a<-oi)throw new RangeError(Oo)}while((r=e(a)).year>=n);return{i:s.reverse(),u:es(i.reverse())}})}function ka(e,t){let n,r,a=Ta(e);if(e.era){const o=Ps[t],s=$s[t]||{};void 0!==o&&(n="islamic"===t?"ah":e.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),"bc"===n||"b"===n?n="bce":"ad"===n||"a"===n?n="ce":"beforeroc"===n&&(n="broc"),n=s[n]||n,r=a,a=xa(r,o[n]||0))}return{era:n,eraYear:r,year:a}}function Ta(e){return parseInt(e.relatedYear||e.year)}function ja(e){const{year:t,o:n,day:r}=this.h(e),{u:a}=this.l(t);return[t,a[n]+1,r]}function Sa(e,t=1,n=1){return this.l(e).i[t-1]+(n-1)*os}function Na(e,t){const n=Ia.call(this,e);return[pa(t,n),n===t]}function Ia(e){const t=$a(this,e),n=$a(this,e-1),r=t.length;if(r>n.length){const e=Da(this);if(e<0)return-e;for(let e=0;e<r;e++)if(t[e]!==n[e])return e+1}}function Ha(e){return da(Sa.call(this,e),Sa.call(this,e+1))}function Oa(e,t){const{i:n}=this.l(e);let r=t+1,a=n;return r>n.length&&(r=1,a=this.l(e+1).i),da(n[t-1],a[r-1])}function Ra(e){return this.l(e).i.length}function Pa(e){const t=this.h(e);return[t.era,t.eraYear]}function $a(e,t){return Object.keys(e.l(t).u)}function Ya(e){return Aa(As(e))}function Aa(e){if((e=e.toLowerCase())!==Hs&&e!==Os){const t=Tl(e).resolvedOptions().calendar;if(La(e)!==La(t))throw new RangeError(Ro(e));return t}return e}function La(e){return"islamicc"===e&&(e="islamic"),e.split("-")[0]}function Va(e,t){return n=>n===Hs?e:n===Os||n===Rs?Object.assign(Object.create(e),{id:n}):Object.assign(Object.create(t),kl(n))}function Za(e,t,n,r){const a=Fa(n,r,js,[],xs);if(void 0!==a.timeZone){const r=n.F(a),o=Ba(a),s=e(a.timeZone);return{epochNanoseconds:Fn(t(s),{...r,...o},void 0!==a.offset?wr(a.offset):void 0),timeZone:s}}return{...n.F(a),...ni}}function Fa(e,t,n,r=[],a=[]){return za(t,[...e.fields(n),...a].sort(),r)}function za(e,t,n,r=!n){const a={};let o,s=0;for(const r of t){if(r===o)throw new RangeError(bo(r));if("constructor"===r||"__proto__"===r)throw new RangeError(xo(r));let t=e[r];if(void 0!==t)s=1,Al[r]&&(t=Al[r](t,r)),a[r]=t;else if(n){if(n.includes(r))throw new TypeError(po(r));a[r]=Is[r]}o=r}if(r&&!s)throw new TypeError(Do(t));return a}function Ba(e,t){return kt(Ll({...Is,...e}),t)}function Wa(e,t,n,r,a){t=le(n=e.fields(n),t),r=za(r,a=e.fields(a),[]);let o=e.k(t,r);return o=za(o,[...n,...a].sort(),[]),e.F(o)}function Ua(e,t){const n=ba(e),r=$s[e.id||""]||{};let{era:a,eraYear:o,year:s}=t;if(void 0!==a||void 0!==o){if(void 0===a||void 0===o)throw new TypeError(Mo);if(!n)throw new RangeError(Eo);const e=n[r[a]||a];if(void 0===e)throw new RangeError(To(a));const t=xa(o,e);if(void 0!==s&&s!==t)throw new RangeError(ko);s=t}else if(void 0===s)throw new TypeError(jo(n));return s}function qa(e,t,n,r){let{month:a,monthCode:o}=t;if(void 0!==o){const t=((e,t,n,r)=>{const a=e.L(n),[o,s]=ma(t);let i=ya(o,s,a);if(s){const t=Da(e);if(void 0===t)throw new RangeError(Ho);if(t>0){if(i>t)throw new RangeError(Ho);if(void 0===a){if(1===r)throw new RangeError(Ho);i--}}else{if(i!==-t)throw new RangeError(Ho);if(void 0===a&&1===r)throw new RangeError(Ho)}}return i})(e,o,n,r);if(void 0!==a&&a!==t)throw new RangeError(No);a=t,r=1}else if(void 0===a)throw new TypeError(Io);return J("month",a,1,e.B(n),r)}function _a(e,t,n,r,a){return X(t,"day",1,e.U(r,n),a)}function Ga(e,t,n,r){let a=0;const o=[];for(const e of n)void 0!==t[e]?a=1:o.push(e);if(Object.assign(e,t),a)for(const t of r||o)delete e[t]}function Xa(e){const t=$l(e.calendar),[n,r,a]=t.v(e),[o,s]=t.q(n,r);return{year:n,monthCode:va(o,s),day:a}}function Ja(e,t){return Ut(nl(t,e))}function Ka(e,t){return qt(nl(t,e))}function Qa(e,t){return Xt(nl(t,e))}function eo(e,t,n){const r=new Set(n);return(a,o)=>{const s=n&&de(a,n);if(!de(a=((e,t)=>{const n={};for(const r in t)e.has(r)||(n[r]=t[r]);return n})(r,a),e)){if(o&&s)throw new TypeError("Invalid formatting options");a={...t,...a}}return n&&(a.timeZone=Ji,["full","long"].includes(a.J)&&(a.J="medium")),a}}function to(e,t=no,n=0){const[r,,,a]=e;return(o,s=vd,...i)=>{const l=t(a&&a(...i),o,s,r,n),d=l.resolvedOptions();return[l,...ro(e,d,i)]}}function no(e,t,n,r,a){if(n=r(n,a),e){if(void 0!==n.timeZone)throw new TypeError(Qo);n.timeZone=e}return new ci(t,n)}function ro(e,t,n){const[,r,a]=e;return n.map(e=>(e.calendar&&((e,t,n)=>{if((n||e!==Hs)&&e!==t)throw new RangeError(Po)})(e.calendar,t.calendar,a),r(e,t)))}function ao(e,t){return{...e,calendar:t}}function oo(e){const t=so();return ct(t,e.R(t))}function so(){return _e(Date.now(),ls)}function io(){return Md||(Md=(new ci).resolvedOptions().timeZone)}const lo=(e,t)=>`Non-integer ${e}: ${t}`,co=(e,t)=>`Non-positive ${e}: ${t}`,uo=(e,t)=>`Non-finite ${e}: ${t}`,ho=e=>`Cannot convert bigint to ${e}`,go=e=>`Invalid bigint: ${e}`,fo="Cannot convert Symbol to string",mo="Invalid object",vo=(e,t,n,r,a)=>a?vo(e,a[t],a[n],a[r]):yo(e,t)+`; must be between ${n}-${r}`,yo=(e,t)=>`Invalid ${e}: ${t}`,po=e=>`Missing ${e}`,xo=e=>`Invalid field ${e}`,bo=e=>`Duplicate field ${e}`,Do=e=>"No valid fields: "+e.join(),wo=(e,t,n)=>yo(e,t)+"; must be "+Object.keys(n).join(),Co="Invalid calling context",Eo="Forbidden era/eraYear",Mo="Mismatching era/eraYear",ko="Mismatching year/eraYear",To=e=>`Invalid era: ${e}`,jo=e=>"Missing year"+(e?"/era/eraYear":""),So=e=>`Invalid monthCode: ${e}`,No="Mismatching month/monthCode",Io="Missing month/monthCode",Ho="Invalid leap month",Oo="Invalid protocol results",Ro=e=>yo("Calendar",e),Po="Mismatching Calendars",$o=e=>yo("TimeZone",e),Yo="Mismatching TimeZones",Ao="Forbidden ICU TimeZone",Lo="Out-of-bounds offset",Vo="Out-of-bounds TimeZone gap",Zo="Invalid TimeZone offset",Fo="Ambiguous offset",zo="Out-of-bounds date",Bo="Out-of-bounds duration",Wo="Cannot mix duration signs",Uo="Missing relativeTo",qo="Cannot use large units",_o="Required smallestUnit or largestUnit",Go="smallestUnit > largestUnit",Xo=e=>`Cannot parse: ${e}`,Jo=e=>`Invalid substring: ${e}`,Ko="Mismatching types for formatting",Qo="Cannot specify TimeZone",es=he(se,(e,t)=>t),ts=he(se,(e,t,n)=>n),ns=he(me,2),rs={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},as=Object.keys(rs),os=864e5,ss=1e3,is=1e3,ls=1e6,ds=1e9,cs=6e10,us=36e11,hs=864e11,gs=[1,is,ls,ds,cs,us,hs],fs=as.slice(0,6),ms=fe(fs),vs=["offset"],ys=["timeZone"],ps=fs.concat(vs),xs=ps.concat(ys),bs=["era","eraYear"],Ds=bs.concat(["year"]),ws=["year"],Cs=["monthCode"],Es=["month"].concat(Cs),Ms=["day"],ks=Es.concat(ws),Ts=Cs.concat(ws),js=Ms.concat(ks),Ss=Ms.concat(Es),Ns=Ms.concat(Cs),Is=ts(fs,0),Hs="iso8601",Os="gregory",Rs="japanese",Ps={[Os]:{"gregory-inverse":-1,gregory:0},[Rs]:{"japanese-inverse":-1,japanese:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethiopic:{ethioaa:0,ethiopic:5500},coptic:{"coptic-inverse":-1,coptic:0},roc:{"roc-inverse":-1,roc:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},$s={[Os]:{bce:"gregory-inverse",ce:"gregory"},[Rs]:{bce:"japanese-inverse",ce:"japanese"},ethiopic:{era0:"ethioaa",era1:"ethiopic"},coptic:{era0:"coptic-inverse",era1:"coptic"},roc:{broc:"roc-inverse",minguo:"roc"}},Ys={chinese:13,dangi:13,hebrew:-6},As=he(Ie,"string"),Ls=he(Ie,"boolean"),Vs=he(Ie,"number"),Zs=as.map(e=>e+"s"),Fs=fe(Zs),zs=Zs.slice(0,6),Bs=Zs.slice(6),Ws=Bs.slice(1),Us=es(Zs),qs=ts(Zs,0),_s=ts(zs,0),Gs=he(ue,Zs),Xs=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],Js=["isoDay","isoMonth","isoYear"],Ks=Xs.concat(Js),Qs=fe(Js),ei=fe(Xs),ti=fe(Ks),ni=ts(ei,0),ri=he(ue,Ks),ai=1e8,oi=ai*os,si=[ai,0],ii=[-ai,0],li=275760,di=-271821,ci=Intl.DateTimeFormat,ui="en-GB",hi=1970,gi=1972,fi=12,mi=lt(1868,9,8),vi=Q(Dt,WeakMap),yi="smallestUnit",pi="unit",xi="roundingIncrement",bi="fractionalSecondDigits",Di="relativeTo",wi="direction",Ci={constrain:0,reject:1},Ei=Object.keys(Ci),Mi={compatible:0,reject:1,earlier:2,later:3},ki={reject:0,use:1,prefer:2,ignore:3},Ti={auto:0,never:1,critical:2,always:3},ji={auto:0,never:1,critical:2},Si={auto:0,never:1},Ni={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},Ii={previous:-1,next:1},Hi=he(Zt,yi),Oi=he(Zt,"largestUnit"),Ri=he(Zt,pi),Pi=he(Ft,"overflow",Ci),$i=he(Ft,"disambiguation",Mi),Yi=he(Ft,"offset",ki),Ai=he(Ft,"calendarName",Ti),Li=he(Ft,"timeZoneName",ji),Vi=he(Ft,"offset",Si),Zi=he(Ft,"roundingMode",Ni),Fi="PlainYearMonth",zi="PlainMonthDay",Bi="PlainDate",Wi="PlainDateTime",Ui="PlainTime",qi="ZonedDateTime",_i="Instant",Gi="Duration",Xi=[Math.floor,e=>Ce(e)?Math.floor(e):Math.round(e),Math.ceil,e=>Ce(e)?Math.ceil(e):Math.round(e),Math.trunc,e=>Ce(e)?Math.trunc(e)||0:Math.round(e),e=>e<0?Math.floor(e):Math.ceil(e),e=>Math.sign(e)*Math.round(Math.abs(e))||0,e=>Ce(e)?(e=Math.trunc(e)||0)+e%2:Math.round(e)],Ji="UTC",Ki=5184e3,Qi=it(1847),el=it((new Date).getUTCFullYear()+10),tl=/0+$/,nl=Q(Zn,WeakMap),rl=2**32-1,al=Q(e=>{const t=Fr(e);return"object"==typeof t?new sl(t):new ol(t||0)});class ol{constructor(e){this.$=e}R(){return this.$}I(e){return(e=>{const t=ot({...e,...ni});if(!t||Math.abs(t[0])>1e8)throw new RangeError(zo)})(e),[st(e,this.$)]}O(){}}class sl{constructor(e){this.nn=(e=>{function t(e){const t=ye(e,o,s),[i,l]=Dr(t),d=r(i),c=r(l);return d===c?d:n(a(i,l),d,c,e)}function n(t,n,r,a){let o,s;for(;(void 0===a||void 0===(o=a<t[0]?n:a>=t[1]?r:void 0))&&(s=t[1]-t[0]);){const n=t[0]+Math.floor(s/2);e(n)===r?t[1]=n:t[0]=n+1}return o}const r=Q(e),a=Q(br);let o=Qi,s=el;return{tn(e){const n=t(e-86400),r=t(e+86400),a=e-n,o=e-r;if(n===r)return[a];const s=t(a);return s===t(o)?[e-s]:n>r?[a,o]:[]},rn:t,O(e,t){const i=ye(e,o,s);let[l,d]=Dr(i);const c=Ki*t,u=t<0?()=>d>o||(o=i,0):()=>l<s||(s=i,0);for(;u();){const o=r(l),s=r(d);if(o!==s){const r=a(l,d);n(r,o,s);const i=r[0];if((ve(i,e)||1)===t)return i}l+=c,d+=c}}}})((e=>t=>{const n=ht(e,t*ss);return it(Ta(n),parseInt(n.month),parseInt(n.day),parseInt(n.hour),parseInt(n.minute),parseInt(n.second))-t})(e))}R(e){return this.nn.rn((e=>rt(e)[0])(e))*ds}I(e){const[t,n]=[it((r=e).isoYear,r.isoMonth,r.isoDay,r.isoHour,r.isoMinute,r.isoSecond),r.isoMillisecond*ls+r.isoMicrosecond*is+r.isoNanosecond];var r;return this.nn.tn(t).map(e=>et(ze(_e(e,ds),n)))}O(e,t){const[n,r]=rt(e),a=this.nn.O(n+(t>0||r?1:0),t);if(void 0!==a)return _e(a,ds)}}const il="([+-])",ll="(?:[.,](\\d{1,9}))?",dl=`(?:(?:${il}(\\d{6}))|(\\d{4}))-?(\\d{2})`,cl="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+ll+")?)?",ul=il+cl,hl=dl+"-?(\\d{2})(?:[T ]"+cl+"(Z|"+ul+")?)?",gl="\\[(!?)([^\\]]*)\\]",fl=`((?:${gl}){0,9})`,ml=Yr(dl+fl),vl=Yr("(?:--)?(\\d{2})-?(\\d{2})"+fl),yl=Yr(hl+fl),pl=Yr("T?"+cl+"(?:"+ul+")?"+fl),xl=Yr(ul),bl=new RegExp(gl,"g"),Dl=Yr(`${il}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${ll}H)?(?:(\\d+)${ll}M)?(?:(\\d+)${ll}S)?)?`),wl=Q(e=>new ci(ui,{timeZone:e,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),Cl=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,El=/[^\w\/:+-]+/,Ml=/^M(\d{2})(L?)$/,kl=Q(Ca),Tl=Q(e=>new ci(ui,{calendar:e,timeZone:Ji,era:"short",year:"numeric",month:"short",day:"numeric"})),jl={P(e,t,n){const r=Tt(n);let a,{years:o,months:s,weeks:i,days:l}=t;if(l+=mr(t,5)[0],o||s)a=((e,t,n,r,a)=>{let[o,s,i]=e.v(t);if(n){const[t,r]=e.q(o,s);o+=n,s=ya(t,r,e.L(o)),s=J("month",s,1,e.B(o),a)}return r&&([o,s]=e.un(o,s,r)),i=J("day",i,1,e.U(o,s),a),e.p(o,s,i)})(this,e,o,s,r);else{if(!i&&!l)return e;a=at(e)}if(void 0===a)throw new RangeError(zo);return a+=(7*i+l)*os,Ke(ut(a))},N(e,t,n){if(n<=7){let r=0,a=la({...e,...ni},{...t,...ni});return 7===n&&([r,a]=be(a,7)),{...qs,weeks:r,days:a}}const r=this.v(e),a=this.v(t);let[o,s,i]=((e,t,n,r,a,o,s)=>{let i=a-t,l=o-n,d=s-r;if(i||l){const c=Math.sign(i||l);let u=e.U(a,o),h=0;if(Math.sign(d)===-c){const r=u;[a,o]=e.un(a,o,-c),i=a-t,l=o-n,u=e.U(a,o),h=c<0?-r:u}if(d=s-Math.min(r,u)+h,i){const[r,s]=e.q(t,n),[d,u]=e.q(a,o);if(l=d-r||Number(u)-Number(s),Math.sign(l)===-c){const n=c<0&&-e.B(a);i=(a-=c)-t,l=o-ya(r,s,e.L(a))+(n||e.B(a))}}}return[i,l,d]})(this,...r,...a);return 8===n&&(s+=this.cn(o,r[0]),o=0),{...qs,years:o,months:s,days:i}},F(e,t){const n=Tt(t),r=Ua(this,e),a=qa(this,e,r,n),o=_a(this,e,a,r,n);return qt(Ke(this.V(r,a,o)),this.id||Hs)},K(e,t){const n=Tt(t),r=Ua(this,e),a=qa(this,e,r,n);return _t(Je(this.V(r,a,1)),this.id||Hs)},_(e,t){const n=Tt(t);let r,a,o,s=void 0!==e.eraYear||void 0!==e.year?Ua(this,e):void 0;const i=!this.id;if(void 0===s&&i&&(s=gi),void 0!==s){const t=qa(this,e,s,n);r=_a(this,e,t,s,n);const i=this.L(s);a=pa(t,i),o=t===i}else{if(void 0===e.monthCode)throw new TypeError(Io);if([a,o]=ma(e.monthCode),this.id&&this.id!==Os&&this.id!==Rs)if(this.id&&"coptic"===La(this.id)&&0===n){const t=o||13!==a?30:6;r=e.day,r=ye(r,1,t)}else if(this.id&&"chinese"===La(this.id)&&0===n){const t=!o||1!==a&&9!==a&&10!==a&&11!==a&&12!==a?30:29;r=e.day,r=ye(r,1,t)}else r=e.day;else r=_a(this,e,qa(this,e,gi,n),gi,n)}const l=this.G(a,o,r);if(!l)throw new RangeError("Cannot guess year");const[d,c]=l;return Gt(Ke(this.V(d,c,r)),this.id||Hs)},fields(e){return ba(this)&&e.includes("year")?[...e,...bs]:e},k(e,t){const n=Object.assign(Object.create(null),e);return Ga(n,t,Es),ba(this)&&(Ga(n,t,Ds),this.id===Rs&&Ga(n,t,Ss,bs)),n},inLeapYear(e){const[t]=this.v(e);return this.sn(t)},monthsInYear(e){const[t]=this.v(e);return this.B(t)},daysInMonth(e){const[t,n]=this.v(e);return this.U(t,n)},daysInYear(e){const[t]=this.v(e);return this.fn(t)},dayOfYear:fa,era(e){return this.hn(e)[0]},eraYear(e){return this.hn(e)[1]},monthCode(e){const[t,n]=this.v(e),[r,a]=this.q(t,n);return va(r,a)},dayOfWeek:xt,daysInWeek:()=>7},Sl={v:gt,hn:bt,q:ft},Nl={dayOfYear:fa,v:gt,p:lt},Il=Object.assign({},Nl,{weekOfYear:ha,yearOfWeek:ga,m(e){function t(e){return(7-e<r?7:0)-e}function n(e){const n=yt(h+e),r=e||1,a=t(xe(l+n*r,7));return c=(n+(a-d)*r)/7}const r=this.id?1:4,a=xt(e),o=this.dayOfYear(e),s=xe(a-1,7),i=o-1,l=xe(s-i,7),d=t(l);let c,u=Math.floor((i-d)/7)+1,h=e.isoYear;return u?u>n(0)&&(u=1,h++):(u=n(-1),h--),[u,h,c]}}),Hl=Object.assign({},jl,Il,{v:gt,hn:bt,q:ft,G(e,t){if(!t)return[gi,e]},sn:pt,L(){},B:mt,cn:e=>e*fi,U:vt,fn:yt,V:(e,t,n)=>({isoYear:e,isoMonth:t,isoDay:n}),p:lt,un:(e,t,n)=>(e+=De(n,fi),(t+=we(n,fi))<1?(e--,t+=fi):t>fi&&(e++,t-=fi),[e,t]),year:e=>e.isoYear,month:e=>e.isoMonth,day:e=>e.isoDay}),Ol={v:ja,hn:Pa,q:Na},Rl={dayOfYear:fa,v:ja,p:Sa,weekOfYear:ha,yearOfWeek:ga,m:()=>[]},Pl=Object.assign({},jl,Rl,{v:ja,hn:Pa,q:Na,G(e,t,n){const r=this.id&&"chinese"===La(this.id)?((e,t,n)=>{if(t)switch(e){case 1:return 1651;case 2:return n<30?1947:1765;case 3:return n<30?1966:1955;case 4:return n<30?1963:1944;case 5:return n<30?1971:1952;case 6:return n<30?1960:1941;case 7:return n<30?1968:1938;case 8:return n<30?1957:1718;case 9:return 1832;case 10:return 1870;case 11:return 1814;case 12:return 1890}return 1972})(e,t,n):gi;let[a,o,s]=ja.call(this,{isoYear:r,isoMonth:fi,isoDay:31});const i=Ia.call(this,a),l=o===i;1===(ve(e,pa(o,i))||ve(Number(t),Number(l))||ve(n,s))&&a--;for(let r=0;r<100;r++){const o=a-r,s=Ia.call(this,o),i=ya(e,t,s);if(t===(i===s)&&n<=Oa.call(this,o,i))return[o,i]}},sn(e){const t=Ha.call(this,e);return t>Ha.call(this,e-1)&&t>Ha.call(this,e+1)},L:Ia,B:Ra,cn(e,t){const n=t+e,r=Math.sign(e),a=r<0?-1:0;let o=0;for(let e=t;e!==n;e+=r)o+=Ra.call(this,e+a);return o},U:Oa,fn:Ha,V(e,t,n){return ut(Sa.call(this,e,t,n))},p:Sa,un(e,t,n){if(n){if(t+=n,!Number.isSafeInteger(t))throw new RangeError(zo);if(n<0)for(;t<1;)t+=Ra.call(this,--e);else{let n;for(;t>(n=Ra.call(this,e));)t-=n,e++}}return[e,t]},year(e){return this.h(e).year},month(e){const{year:t,o:n}=this.h(e),{u:r}=this.l(t);return r[n]+1},day(e){return this.h(e).day}}),$l=Va(Sl,Ol),Yl=Va(Hl,Pl),Al={...{era:Pe,eraYear:Ae,year:Ae,month:Ve,monthCode(e){const t=Pe(e);return ma(t),t},day:Ve},...ts(fs,Ae),...ts(Zs,Le),offset(e){const t=Pe(e);return wr(t),t}},Ll=he(ie,fs,Xs),Vl=he(ie,Xs,fs),Zl="numeric",Fl=["timeZoneName"],zl={month:Zl,day:Zl},Bl={year:Zl,month:Zl},Wl=Object.assign({},Bl,{day:Zl}),Ul={hour:Zl,minute:Zl,second:Zl},ql=Object.assign({},Wl,Ul),_l=Object.assign({},ql,{timeZoneName:"short"}),Gl=Object.keys(Bl),Xl=Object.keys(zl),Jl=Object.keys(Wl),Kl=Object.keys(Ul),Ql=["dateStyle"],ed=Gl.concat(Ql),td=Xl.concat(Ql),nd=Jl.concat(Ql,["weekday"]),rd=Kl.concat(["dayPeriod","timeStyle","fractionalSecondDigits"]),ad=nd.concat(rd),od=Fl.concat(rd),sd=Fl.concat(nd),id=Fl.concat(["day","weekday"],rd),ld=Fl.concat(["year","weekday"],rd),dd=eo(ad,ql),cd=eo(ad,_l),ud=eo(ad,ql,Fl),hd=eo(nd,Wl,od),gd=eo(rd,Ul,sd),fd=eo(ed,Bl,id),md=eo(td,zl,ld),vd={},yd=new ci(void 0,{calendar:Hs}).resolvedOptions().calendar===Hs,pd=[dd,Kt],xd=[cd,Kt,0,(e,t)=>{const n=e.timeZone;if(t&&t.timeZone!==n)throw new RangeError(Yo);return n}],bd=[ud,at],Dd=[hd,at],wd=[gd,e=>tt(e)/ls],Cd=[fd,at,yd],Ed=[md,at,yd];let Md;function kd(e,t,n,r,a){function o(...e){if(!(this instanceof o))throw new TypeError(Co);Kd(this,t(...e))}function s(e,t){return Object.defineProperties(function(...t){return e.call(this,i(this),...t)},ee(t))}function i(t){const n=Jd(t);if(!n||n.branding!==e)throw new TypeError(Co);return n}return Object.defineProperties(o.prototype,{...ne(oe(s,n)),...te(oe(s,r)),...re("Temporal."+e)}),Object.defineProperties(o,{...te(a),...ee(e)}),[o,e=>{const t=Object.create(o.prototype);return Kd(t,e),t},i]}function Td(e){if(Jd(e)||void 0!==e.calendar||void 0!==e.timeZone)throw new TypeError("Invalid bag");return e}function jd(e){return Sd(e)||Hs}function Sd(e){const{calendar:t}=e;if(void 0!==t)return Nd(t)}function Nd(e){if(K(e)){const{calendar:t}=Jd(e)||{};if(!t)throw new TypeError(Ro(e));return t}return(e=>Aa(function(e){const t=Sr(e)||Nr(e)||Ir(e);return t?t.calendar:e}(As(e))))(e)}function Id(e){const t={};for(const n in e)t[n]=e=>{const{calendar:t}=e;return Yl(t)[n](e)};return t}function Hd(){throw new TypeError("Cannot use valueOf")}function Od(e){if(K(e)){const{timeZone:t}=Jd(e)||{};if(!t)throw new TypeError($o(e));return t}return(e=>Vr(function(e){const t=Sr(e);return t&&(t.timeZone||t.j&&Ji||t.offset)||e}(As(e))))(e)}function Rd(e){if(K(e)){const t=Jd(e);return t&&t.branding===Gi?t:function(e){const t=za(e,Fs);return Jt(gr({...qs,...t}))}(e)}return function(e){const t=(e=>{const t=Dl.exec(e);return t?(e=>{function t(e,t,o){let s=0,i=0;if(o&&([s,a]=pe(a,gs[o])),void 0!==e){if(r)throw new RangeError(Jo(e));i=(e=>{const t=parseInt(e);if(!Number.isFinite(t))throw new RangeError(Jo(e));return t})(e),n=1,t&&(a=$r(t)*(gs[o]/ds),r=1)}return s+i}let n=0,r=0,a=0,o={...ae(Zs,[t(e[2]),t(e[3]),t(e[4]),t(e[5]),t(e[6],e[7],5),t(e[8],e[9],4),t(e[10],e[11],3)]),...Me(a,2,Zs)};if(!n)throw new RangeError(Do(Zs));return Ar(e[1])<0&&(o=ur(o)),o})(t):void 0})(As(e));if(!t)throw new RangeError(Xo(e));return Jt(gr(t))}(e)}function Pd(e){if(void 0!==e){if(K(e)){const t=Jd(e)||{};switch(t.branding){case qi:case Bi:return t;case Wi:return qt(t)}const n=jd(e);return{...Za(Od,al,Yl(n),e),calendar:n}}return function(e){const t=Sr(As(e));if(!t)throw new RangeError(Xo(e));if(t.timeZone)return Mr(t,t.offset?wr(t.offset):void 0);if(t.j)throw new RangeError(Xo(e));return Tr(t)}(e)}}function $d(e,t){if(K(e)){const n=Jd(e)||{};switch(n.branding){case Ui:return Tt(t),n;case Wi:return Tt(t),Xt(n);case qi:return Tt(t),Qa(al,n)}return function(e,t){return Xt(Ba(za(e,ms,[],1),Tt(t)))}(e,t)}const n=function(e){let t,n=(e=>{const t=pl.exec(e);return t?(Pr(t[10]),Rr(t)):void 0})(As(e));if(!n){if(n=Sr(e),!n)throw new RangeError(Xo(e));if(!n.C)throw new RangeError(Xo(e));if(n.j)throw new RangeError(Jo("Z"));Er(n)}if((t=Nr(e))&&Et(t))throw new RangeError(Xo(e));if((t=Ir(e))&&Et(t))throw new RangeError(Xo(e));return Xt(kt(n,1))}(e);return Tt(t),n}function Yd(e){return void 0===e?void 0:$d(e)}function Ad(e,t){if(K(e)){const n=Jd(e)||{};switch(n.branding){case Wi:return Tt(t),n;case Bi:return Tt(t),Ut({...n,...ni});case qi:return Tt(t),Ja(al,n)}return function(e,t,n){const r=Fa(e,t,js,[],fs),a=Tt(n);return Ut(Qe({...e.F(r,Vt(a)),...Ba(r,a)}))}(Yl(jd(e)),e,t)}const n=function(e){const t=Sr(As(e));if(!t||t.j)throw new RangeError(Xo(e));return Ut(kr(t))}(e);return Tt(t),n}function Ld(e,t){if(K(e)){const n=Jd(e);if(n&&n.branding===zi)return Tt(t),n;const r=Sd(e);return function(e,t,n,r){const a=Fa(e,n,js,Ms);return t&&void 0!==a.month&&void 0===a.monthCode&&void 0===a.year&&(a.year=gi),e._(a,r)}(Yl(r||Hs),!r,e,t)}const n=function(e,t){const n=Ir(As(t));if(n)return Er(n),Gt(Ct(n));const r=Cr(t,0,1),{calendar:a}=r,o=e(a),[s,i,l]=o.v(r),[d,c]=o.q(s,i),[u,h]=o.G(d,c,l);return Gt(Ke(o.V(u,h,l)),a)}(Yl,e);return Tt(t),n}function Vd(e,t){if(K(e)){const n=Jd(e);return n&&n.branding===Fi?(Tt(t),n):function(e,t,n,r){const a=Fa(e,t,ks,r);return e.K(a,n)}(Yl(jd(e)),e,t)}const n=function(e,t){const n=Nr(As(t));if(n)return Er(n),_t(Je(Ct(n)));const r=Cr(t,1);return _t(er(e(r.calendar),r))}(Yl,e);return Tt(t),n}function Zd(e,t){if(K(e)){const n=Jd(e)||{};switch(n.branding){case Bi:return Tt(t),n;case Wi:return Tt(t),qt(n);case qi:return Tt(t),Ka(al,n)}return function(e,t,n,r=[]){const a=Fa(e,t,js,r);return e.F(a,n)}(Yl(jd(e)),e,t)}const n=Cr(e);return Tt(t),n}function Fd(e,t){if(K(e)){const n=Jd(e);if(n&&n.branding===qi)return jt(t),n;const r=jd(e);return function(e,t,n,r,a,o){const s=Fa(n,a,js,ys,xs),i=e(s.timeZone),[l,d,c]=jt(o),u=n.F(s,Vt(l)),h=Ba(s,l);return Wt(Fn(t(i),{...u,...h},void 0!==s.offset?wr(s.offset):void 0,d,c),i,r)}(Od,al,Yl(r),r,e,t)}return function(e,t){const n=Sr(As(e));if(!n||!n.timeZone)throw new RangeError(Xo(e));const{offset:r}=n,a=r?wr(r):void 0,[,o,s]=jt(t);return Mr(n,a,o,s)}(e,t)}function zd(e){return oe(e=>t=>e(Bd(t)),e)}function Bd(e){return nl(e,al)}function Wd(e){if(K(e)){const t=Jd(e);if(t)switch(t.branding){case _i:return t;case qi:return Bt(t.epochNanoseconds)}}return function(e){const t=Sr(e=Pe(e));if(!t)throw new RangeError(Xo(e));let n;if(t.j)n=0;else{if(!t.offset)throw new RangeError(Xo(e));n=wr(t.offset)}return t.timeZone&&Hr(t.timeZone,1),Bt(st(wt(t),n))}(e)}function Ud(){function e(e,n){return new t(e,n)}function t(e,t=Object.create(null)){Yc.set(this,((e,t)=>{const n=new ci(e,t),r=n.resolvedOptions(),a=r.locale,o=le(Object.keys(t),r),s=Q(Gd),i=(e,...t)=>{if(e){if(2!==t.length)throw new TypeError(Ko);for(const e of t)if(void 0===e)throw new TypeError(Ko)}e||void 0!==t[0]||(t=[]);const r=t.map(e=>Jd(e)||Number(e));let i,l=0;for(const e of r){const t="object"==typeof e?e.branding:void 0;if(l++&&t!==i)throw new TypeError(Ko);i=t}return i?s(i)(a,o,...r):[n,...r]};return i.X=n,i})(e,t))}const n=ci.prototype,r=Object.getOwnPropertyDescriptors(n),a=Object.getOwnPropertyDescriptors(ci);for(const t in r){const n=r[t],a=t.startsWith("format")&&qd(t);"function"==typeof n.value?n.value="constructor"===t?e:a||_d(t):a&&(n.get=function(){if(!Yc.has(this))throw new TypeError(Co);return(...e)=>a.apply(this,e)},Object.defineProperties(n.get,ee(`get ${t}`)))}return a.prototype.value=t.prototype=Object.create({},r),Object.defineProperties(e,a),e}function qd(e){return Object.defineProperties(function(...t){const n=Yc.get(this),[r,...a]=n(e.includes("Range"),...t);return r[e](...a)},ee(e))}function _d(e){return Object.defineProperties(function(...t){return Yc.get(this).X[e](...t)},ee(e))}function Gd(e){const t=hc[e];if(!t)throw new TypeError((e=>`Cannot format ${e}`)(e));return to(t,Q(no),1)}const Xd=new WeakMap,Jd=Xd.get.bind(Xd),Kd=Xd.set.bind(Xd),Qd={era:function(e){if(void 0!==e)return As(e)},eraYear:ke,year:je,month:Te,daysInMonth:Te,daysInYear:Te,inLeapYear:Ls,monthsInYear:Te},ec={monthCode:As},tc={day:Te},nc={dayOfWeek:Te,dayOfYear:Te,weekOfYear:function(e){if(void 0!==e)return Te(e)},yearOfWeek:ke,daysInWeek:Te},rc=Id(Object.assign({},Qd,ec,tc,nc)),ac=Id({...Qd,...ec}),oc=Id({...ec,...tc}),sc={calendarId:e=>e.calendar},ic=se(e=>t=>t[e],Zs.concat("sign")),lc=se((e,t)=>e=>e[Xs[t]],fs),dc={epochMilliseconds:Kt,epochNanoseconds:function(e){return((e,t=1)=>{const[n,r]=e,a=Math.floor(r/t),o=hs/t;return BigInt(n)*BigInt(o)+BigInt(a)})(e.epochNanoseconds)}},[cc,uc]=kd(Gi,function(e=0,t=0,n=0,r=0,a=0,o=0,s=0,i=0,l=0,d=0){return Jt(gr(oe(Le,ae(Zs,[e,t,n,r,a,o,s,i,l,d]))))},{...ic,blank:function(e){return!e.sign}},{with:(e,t)=>uc(function(e,t){return Jt((n=e,r=t,gr({...n,...za(r,Fs)})));var n,r}(e,t)),negated:e=>uc(cr(e)),abs:e=>uc(function(e){return-1===e.sign?cr(e):e}(e)),add:(e,t,n)=>uc(dr(Pd,Yl,al,0,e,Rd(t),n)),subtract:(e,t,n)=>uc(dr(Pd,Yl,al,1,e,Rd(t),n)),round:(e,t)=>uc(function(e,t,n,r,a){const o=xr(r),[s,i,l,d,c]=((e,t,n)=>{e=Lt(e,yi);let r=Oi(e);const a=n(e[Di]);let o=Pt(e);const s=Zi(e,7);let i=Hi(e);if(void 0===r&&void 0===i)throw new RangeError(_o);if(null==i&&(i=0),null==r&&(r=Math.max(i,t)),zt(r,i),o=$t(o,i,1),o>1&&i>5&&r!==i)throw new RangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit");return[r,i,o,s,a]})(a,o,e),u=Math.max(o,s);if(!c&&u<=6)return Jt(gr(((e,t,n,r,a)=>{const o=gn(mr(e),n,r,a);return{...qs,...vr(o,t)}})(r,s,i,l,d)));if(!ir(c)&&!r.sign)return r;if(!c)throw new RangeError(Uo);const[h,g,f]=rr(t,n,c),m=ar(f),v=or(f),y=sr(f),p=v(g,h,r);ir(c)||(Qe(h),Qe(p));let x=y(g,h,p,s);const b=r.sign,D=hr(x);if(b&&D&&b!==D)throw new RangeError(Oo);return x=hn(x,m(p),s,i,l,d,g,h,m,v),Jt(x)}(Pd,Yl,al,e,t)),total:(e,t)=>function(e,t,n,r,a){const o=xr(r),[s,i]=((e,t)=>{const n=t((e=Lt(e,pi))[Di]);let r=Ri(e);return r=Se(pi,r),[r,n]})(a,e),l=Math.max(s,o);if(!i&&lr(l,i))return en(r,s);if(!i)throw new RangeError(Uo);if(!r.sign)return 0;const[d,c,u]=rr(t,n,i),h=ar(u),g=or(u),f=sr(u),m=g(c,d,r);ir(i)||(Qe(d),Qe(m));const v=f(c,d,m,s);return lr(s,i)?en(v,s):((e,t,n,r,a,o,s)=>{const i=hr(e),[l,d]=tn(r,Gs(n,e),n,i,a,o,s),c=nn(t,l,d);return e[Zs[n]]+c*i})(v,h(m),s,c,d,h,g)}(Pd,Yl,al,e,t),toLocaleString(e,t,n){return Intl.DurationFormat?new Intl.DurationFormat(t,n).format(this):Tn(e)},toString:Tn,toJSON:e=>Tn(e),valueOf:Hd},{from:e=>uc(Rd(e)),compare:(e,t,n)=>function(e,t,n,r,a,o){const s=e(At(o).relativeTo),i=Math.max(xr(r),xr(a));if(ce(Zs,r,a))return 0;if(lr(i,s))return We(mr(r),mr(a));if(!s)throw new RangeError(Uo);const[l,d,c]=rr(t,n,s),u=ar(c),h=or(c);return We(u(h(d,l,r)),u(h(d,l,a)))}(Pd,Yl,al,Rd(e),Rd(t),n)}),hc={Instant:pd,PlainDateTime:bd,PlainDate:Dd,PlainTime:wd,PlainYearMonth:Cd,PlainMonthDay:Ed},gc=to(pd),fc=to(xd),mc=to(bd),vc=to(Dd),yc=to(wd),pc=to(Cd),xc=to(Ed),[bc,Dc]=kd(Ui,function(e=0,t=0,n=0,r=0,a=0,o=0){return Xt(kt(oe(Ae,ae(Xs,[e,t,n,r,a,o])),1))},lc,{with(e,t,n){return Dc(function(e,t,n){return Xt(((e,t,n)=>Ba({...le(ms,e),...za(t,ms)},Tt(n)))(e,t,n))}(this,Td(t),n))},add:(e,t)=>Dc(Xn(0,e,Rd(t))),subtract:(e,t)=>Dc(Xn(1,e,Rd(t))),until:(e,t,n)=>uc(ta(0,e,$d(t),n)),since:(e,t,n)=>uc(ta(1,e,$d(t),n)),round:(e,t)=>Dc(function(e,t){const[n,r,a]=Nt(t,5);var o;return Xt((o=a,on(e,ln(n,r),o)[0]))}(e,t)),equals:(e,t)=>function(e,t){return!qr(e,t)}(e,$d(t)),toLocaleString(e,t,n){const[r,a]=yc(t,n,e);return r.format(a)},toString:kn,toJSON:e=>kn(e),valueOf:Hd},{from:(e,t)=>Dc($d(e,t)),compare:(e,t)=>qr($d(e),$d(t))}),[wc,Cc]=kd(Wi,he(function(e,t,n,r,a=0,o=0,s=0,i=0,l=0,d=0,c=Hs){return Ut(Qe(wt(oe(Ae,ae(Ks,[t,n,r,a,o,s,i,l,d])))),e(c))},Ya),{...sc,...rc,...lc},{with:(e,t,n)=>Cc(function(e,t,n,r){const a=e(t.calendar),o=[...a.fields(js),...fs].sort(),s={...Xa(i=t),hour:i.isoHour,minute:i.isoMinute,second:i.isoSecond,millisecond:i.isoMillisecond,microsecond:i.isoMicrosecond,nanosecond:i.isoNanosecond};var i;const l=za(n,o),d=Tt(r),c=a.k(s,l),u={...s,...l};return Ut(Qe({...a.F(c,Vt(d)),...kt(Ll(u),d)}))}(Yl,e,Td(t),n)),withCalendar:(e,t)=>Cc(ao(e,Nd(t))),withPlainTime:(e,t)=>Cc(function(e,t=ni){return Ut(Qe({...e,...t}))}(e,Yd(t))),add:(e,t,n)=>Cc(qn(Yl,0,e,Rd(t),n)),subtract:(e,t,n)=>Cc(qn(Yl,1,e,Rd(t),n)),until:(e,t,n)=>uc(Jr(Yl,0,e,Ad(t),n)),since:(e,t,n)=>uc(Jr(Yl,1,e,Ad(t),n)),round:(e,t)=>Cc(function(e,t){return Ut(rn(e,...Nt(t)),e.calendar)}(e,t)),equals:(e,t)=>function(e,t){return!Wr(e,t)&&e.calendar===t.calendar}(e,Ad(t)),toZonedDateTime:(e,t,n)=>Ic(function(e,t,n,r){const a=((e,t,n,r)=>{const a=(e=>$i(At(e)))(r);return zn(e(t),n,a)})(e,n,t,r);return Wt(et(a),n,t.calendar)}(al,e,Od(t),n)),toPlainDate:e=>Sc(qt(e)),toPlainTime:e=>Dc(Xt(e)),toLocaleString(e,t,n){const[r,a]=mc(t,n,e);return r.format(a)},toString:wn,toJSON:e=>wn(e),valueOf:Hd},{from:(e,t)=>Cc(Ad(e,t)),compare:(e,t)=>Wr(Ad(e),Ad(t))}),[Ec,Mc]=kd(zi,he(function(e,t,n,r=Hs,a=gi){const o=Ae(t),s=Ae(n),i=e(r);return Gt(Ke(Ct({isoYear:Ae(a),isoMonth:o,isoDay:s})),i)},Ya),{...sc,...oc},{with:(e,t,n)=>Mc(function(e,t,n,r){const a=e(t.calendar),o=a.fields(js).sort(),s=(e=>{const t=$l(e.calendar),[n,r,a]=t.v(e),[o,s]=t.q(n,r);return{monthCode:va(o,s),day:a}})(t),i=za(n,o),l=a.k(s,i);return a._(l,r)}(Yl,e,Td(t),n)),equals:(e,t)=>function(e,t){return!Ur(e,t)&&e.calendar===t.calendar}(e,Ld(t)),toPlainDate(e,t){return Sc(function(e,t,n,r){return((e,t,n)=>Wa(e,t,Ns,Ne(n),ws))(e(t.calendar),n,r)}(Yl,e,this,t))},toLocaleString(e,t,n){const[r,a]=xc(t,n,e);return r.format(a)},toString:Mn,toJSON:e=>Mn(e),valueOf:Hd},{from:(e,t)=>Mc(Ld(e,t))}),[kc,Tc]=kd(Fi,he(function(e,t,n,r=Hs,a=1){const o=Ae(t),s=Ae(n),i=e(r);return _t(Je(Ct({isoYear:o,isoMonth:s,isoDay:Ae(a)})),i)},Ya),{...sc,...ac},{with:(e,t,n)=>Tc(function(e,t,n,r){const a=e(t.calendar),o=a.fields(ks).sort(),s=(e=>{const t=$l(e.calendar),[n,r]=t.v(e),[a,o]=t.q(n,r);return{year:n,monthCode:va(a,o)}})(t),i=za(n,o),l=a.k(s,i);return a.K(l,r)}(Yl,e,Td(t),n)),add:(e,t,n)=>Tc(Gn(Yl,0,e,Rd(t),n)),subtract:(e,t,n)=>Tc(Gn(Yl,1,e,Rd(t),n)),until:(e,t,n)=>uc(Qr(Yl,0,e,Vd(t),n)),since:(e,t,n)=>uc(Qr(Yl,1,e,Vd(t),n)),equals:(e,t)=>function(e,t){return!Ur(e,t)&&e.calendar===t.calendar}(e,Vd(t)),toPlainDate(e,t){return Sc(function(e,t,n,r){return((e,t,n)=>Wa(e,t,Ts,Ne(n),Ms))(e(t.calendar),n,r)}(Yl,e,this,t))},toLocaleString(e,t,n){const[r,a]=pc(t,n,e);return r.format(a)},toString:En,toJSON:e=>En(e),valueOf:Hd},{from:(e,t)=>Tc(Vd(e,t)),compare:(e,t)=>Ur(Vd(e),Vd(t))}),[jc,Sc]=kd(Bi,he(function(e,t,n,r,a=Hs){return qt(Ke(Ct(oe(Ae,{isoYear:t,isoMonth:n,isoDay:r}))),e(a))},Ya),{...sc,...rc},{with:(e,t,n)=>Sc(function(e,t,n,r){const a=e(t.calendar),o=a.fields(js).sort(),s=Xa(t),i=za(n,o),l=a.k(s,i);return a.F(l,r)}(Yl,e,Td(t),n)),withCalendar:(e,t)=>Sc(ao(e,Nd(t))),add:(e,t,n)=>Sc(_n(Yl,0,e,Rd(t),n)),subtract:(e,t,n)=>Sc(_n(Yl,1,e,Rd(t),n)),until:(e,t,n)=>uc(Kr(Yl,0,e,Zd(t),n)),since:(e,t,n)=>uc(Kr(Yl,1,e,Zd(t),n)),equals:(e,t)=>function(e,t){return!Ur(e,t)&&e.calendar===t.calendar}(e,Zd(t)),toZonedDateTime(e,t){const n=K(t)?t:{timeZone:t};return Ic(function(e,t,n,r,a){const o=e(a.timeZone),s=a.plainTime,i=void 0!==s?t(s):void 0,l=n(o);let d;return d=i?zn(l,{...r,...i}):Bn(l,{...r,...ni}),Wt(d,o,r.calendar)}(Od,$d,al,e,n))},toPlainDateTime:(e,t)=>Cc(function(e,t=ni){return Ut(Qe({...e,...t}))}(e,Yd(t))),toPlainYearMonth(e){return Tc(function(e,t,n){return((e,t)=>{const n=Fa(e,t,Ts);return e.K(n,void 0)})(e(t.calendar),n)}(Yl,e,this))},toPlainMonthDay(e){return Mc(function(e,t,n){return((e,t)=>{const n=Fa(e,t,Ns);return e._(n)})(e(t.calendar),n)}(Yl,e,this))},toLocaleString(e,t,n){const[r,a]=vc(t,n,e);return r.format(a)},toString:Cn,toJSON:e=>Cn(e),valueOf:Hd},{from:(e,t)=>Sc(Zd(e,t)),compare:(e,t)=>Ur(Zd(e),Zd(t))}),[Nc,Ic]=kd(qi,he(function(e,t,n,r,a=Hs){return Wt(et(qe($e(n))),t(r),e(a))},Ya,function(e){return Vr(As(e))}),{...dc,...sc,...zd(rc),...zd(lc),offset:e=>Pn(Bd(e).offsetNanoseconds),offsetNanoseconds:e=>Bd(e).offsetNanoseconds,timeZoneId:e=>e.timeZone,hoursInDay:e=>function(e,t){const n=e(t.timeZone),r=nl(t,n),[a,o]=dn(r),s=Ge(Be(Bn(n,a),Bn(n,o)),us,1);if(s<=0)throw new RangeError(Oo);return s}(al,e)},{with:(e,t,n)=>Ic(function(e,t,n,r,a){const{calendar:o,timeZone:s}=n,i=e(o),l=t(s),d=[...i.fields(js),...ps].sort(),c=(e=>{const t=nl(e,al),n=Pn(t.offsetNanoseconds),r=$l(e.calendar),[a,o,s]=r.v(t),[i,l]=r.q(a,o),d=va(i,l);return{...Vl(t),year:a,monthCode:d,day:s,offset:n}})(n),u=za(r,d),h=i.k(c,u),g={...c,...u},[f,m,v]=jt(a,2);return Wt(Fn(l,{...i.F(h,Vt(f)),...kt(Ll(g),f)},wr(g.offset),m,v),s,o)}(Yl,al,e,Td(t),n)),withCalendar:(e,t)=>Ic(ao(e,Nd(t))),withTimeZone:(e,t)=>Ic(function(e,t){return{...e,timeZone:t}}(e,Od(t))),withPlainTime:(e,t)=>Ic(function(e,t,n){const r=t.timeZone,a=e(r),o={...nl(t,a),...n||ni};let s;return s=n?Fn(a,o,o.offsetNanoseconds,2):Bn(a,o),Wt(s,r,t.calendar)}(al,e,Yd(t))),add:(e,t,n)=>Ic(Un(Yl,al,0,e,Rd(t),n)),subtract:(e,t,n)=>Ic(Un(Yl,al,1,e,Rd(t),n)),until:(e,t,n)=>uc(Jt(Xr(Yl,al,0,e,Fd(t),n))),since:(e,t,n)=>uc(Jt(Xr(Yl,al,1,e,Fd(t),n))),round:(e,t)=>Ic(function(e,t,n){let{epochNanoseconds:r,timeZone:a,calendar:o}=t;const[s,i,l]=Nt(n);if(0===s&&1===i)return t;const d=e(a);if(6===s)r=((e,t,n,r)=>{const a=nl(n,t),[o,s]=e(a),i=n.epochNanoseconds,l=Bn(t,o),d=Bn(t,s);if(Ue(i,l,d))throw new RangeError(Oo);return vn(nn(i,l,d),r)?d:l})(dn,d,t,l);else{const e=d.R(r);r=Fn(d,rn(ct(r,e),s,i,l),e,2,0,1)}return Wt(r,a,o)}(al,e,t)),startOfDay:e=>Ic(function(e,t){const{timeZone:n,calendar:r}=t,a=((e,t,n)=>Bn(t,e(nl(n,t))))(cn,e(n),t);return Wt(a,n,r)}(al,e)),equals:(e,t)=>function(e,t){return!Br(e,t)&&!!_r(e.timeZone,t.timeZone)&&e.calendar===t.calendar}(e,Fd(t)),toInstant:e=>Oc(function(e){return Bt(e.epochNanoseconds)}(e)),toPlainDateTime:e=>Cc(Ja(al,e)),toPlainDate:e=>Sc(Ka(al,e)),toPlainTime:e=>Dc(Qa(al,e)),toLocaleString(e,t,n={}){const[r,a]=fc(t,n,e);return r.format(a)},toString:(e,t)=>Dn(al,e,t),toJSON:e=>Dn(al,e),valueOf:Hd,getTimeZoneTransition(e,t){const{timeZone:n,epochNanoseconds:r}=e,a=function(e){const t=Lt(e,wi),n=Ft(wi,Ii,t,0);if(!n)throw new RangeError(yo(wi,n));return n}(t),o=al(n).O(r,a);return o?Ic({...e,epochNanoseconds:o}):null}},{from:(e,t)=>Ic(Fd(e,t)),compare:(e,t)=>Br(Fd(e),Fd(t))}),[Hc,Oc]=kd(_i,function(e){return Bt(et(qe($e(e))))},dc,{add:(e,t)=>Oc(Wn(0,e,Rd(t))),subtract:(e,t)=>Oc(Wn(1,e,Rd(t))),until:(e,t,n)=>uc(Gr(0,e,Wd(t),n)),since:(e,t,n)=>uc(Gr(1,e,Wd(t),n)),round:(e,t)=>Oc(function(e,t){const[n,r,a]=Nt(t,5,1);return Bt(gn(e.epochNanoseconds,n,r,a,1))}(e,t)),equals:(e,t)=>function(e,t){return!zr(e,t)}(e,Wd(t)),toZonedDateTimeISO:(e,t)=>Ic(function(e,t,n=Hs){return Wt(e.epochNanoseconds,t,n)}(e,Od(t))),toLocaleString(e,t,n){const[r,a]=gc(t,n,e);return r.format(a)},toString:(e,t)=>bn(Od,al,e,t),toJSON:e=>bn(Od,al,e),valueOf:Hd},{from:e=>Oc(Wd(e)),fromEpochMilliseconds:e=>Oc(function(e){return Bt(et(_e(Le(e),ls)))}(e)),fromEpochNanoseconds:e=>Oc(function(e){return Bt(et(qe($e(e))))}(e)),compare:(e,t)=>zr(Wd(e),Wd(t))}),Rc=Object.defineProperties({},{...re("Temporal.Now"),...te({timeZoneId:()=>io(),instant:()=>Oc(Bt(so())),zonedDateTimeISO:(e=io())=>Ic(Wt(so(),Od(e),Hs)),plainDateTimeISO:(e=io())=>Cc(Ut(oo(al(Od(e))),Hs)),plainDateISO:(e=io())=>Sc(qt(oo(al(Od(e))),Hs)),plainTimeISO:(e=io())=>Dc(Xt(oo(al(Od(e)))))})}),Pc=Object.defineProperties({},{...re("Temporal"),...te({PlainYearMonth:kc,PlainMonthDay:Ec,PlainDate:jc,PlainTime:bc,PlainDateTime:wc,ZonedDateTime:Nc,Instant:Hc,Duration:cc,Now:Rc})}),$c=Ud(),Yc=new WeakMap;function Ac(e){var t;return e instanceof Pc.PlainDate||("PlainDate"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)||!("hour"in e)&&!("timeZone"in e))}function Lc(e,t=Pc.Now.timeZoneId()){return Pc.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function Vc(e){return Pc.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Zc(e){return new Date(e.epochMilliseconds)}function Fc(e,t){return Ac(e)?function(e,t=Pc.Now.timeZoneId()){return Zc(e.toZonedDateTime({timeZone:t,plainTime:Pc.PlainTime.from({hour:0,minute:0})}))}(e,t):"hour"in e&&!("timeZone"in e)?new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond):Zc(e)}function zc(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return Ac(e)?Pc.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:n,minute:r}):e.with({hour:n,minute:r,second:0,millisecond:0})}function Bc(e,t){const n=Ac(e)?e:e.toPlainDate(),r=Ac(t)?t:t.toPlainDate();return 0===Pc.PlainDate.compare(n,r)}function Wc(e,t=Pc.Now.timeZoneId()){return(Ac(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:Pc.PlainTime.from({hour:0,minute:0})})}function Uc(e,t=Pc.Now.timeZoneId()){return(Ac(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:Pc.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function qc(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 _c(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}Object.create(Intl),te({DateTimeFormat:$c});const Gc=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return Ac(t=e)?0:"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:(console.warn("Warning: No hour property found in temporal object, returning 0"),0);var t,n},Xc=(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 zc(e,t)},Jc=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return Uc(e)},Kc=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Bc(e instanceof Date?Pc.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):Ac(e)?e:e.toPlainDate(),t instanceof Date?Pc.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):Ac(t)?t:t.toPlainDate())},Qc=e=>v().resolveColors(e).eventColor,eu=e=>v().resolveColors(e).textColor,tu=e=>v().resolveColors(e).eventSelectedColor,nu=e=>v().resolveColors(e).lineColor,ru=.25,au=(e,t=0)=>{const n=Math.floor(e),r=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},ou=e=>{if(e.allDay)return"All day";const t=Gc(e.start),n=iu(e);return`${au(t)} - ${au(n)}`},su=e=>{const t=ru;return Math.round(e/t)*t},iu=e=>{if(!e.end)return 0;const t=Gc(e.end);if(e.allDay||!e.start)return t;const n=Fc(e.start),r=Fc(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},lu=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],du=["January","February","March","April","May","June","July","August","September","October","November","December"],cu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],uu=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);r.setDate(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}},hu=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:du[r],shortMonthName:cu[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},gu=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(hu(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:fu(t)}},fu=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:du[a],monthIndex:a,year:o}};function mu(e,t){const n=[],r=Math.floor(t/2),a=new Date(e),o=e.getDay(),s=0===o?6:o-1;a.setDate(e.getDate()-s),a.setHours(0,0,0,0);const i=new Date(a);i.setDate(i.getDate()-7*r);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),n.push(gu(t))}return n}const vu=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),yu=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},pu=(e,t)=>t?Pc.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):Pc.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:Pc.Now.timeZoneId()}),xu=(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)},bu=(e,t)=>e.map(e=>{const n=Fc(e.start),r=xu(n,t);return Object.assign(Object.assign({},e),{day:r})});function Du(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}const wu=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Cu=({app:e,calendars:a,toggleCalendarVisibility:o,isCollapsed:s,setCollapsed:i})=>{const l=e.getCurrentDate(),d=e.getVisibleMonth(),c=d.getFullYear(),u=d.getMonth(),[h,g]=t.useState(!1),[f,m]=t.useState(null),v=t.useCallback((e,t)=>{g(!0),m(e.id);const n={calendarId:e.id,calendarName:e.name,calendarColors:e.colors,calendarIcon:e.icon};t.dataTransfer.setData("application/x-dayflow-calendar",JSON.stringify(n)),t.dataTransfer.effectAllowed="copy"},[]),y=t.useCallback(()=>{g(!1),m(null)},[]),[p,x]=t.useState(()=>new Date(c,u,1));t.useEffect(()=>{x(e=>e.getFullYear()===c&&e.getMonth()===u?e:new Date(c,u,1))},[c,u]);const b=t.useMemo(()=>(new Date).toDateString(),[]),D=l.toDateString(),w=t.useMemo(()=>lu.map(e=>e.charAt(0)),[]),C=t.useMemo(()=>{const e=p.getFullYear(),t=p.getMonth(),n=(new Date(e,t,1).getDay()+6)%7,r=[];for(let a=0;a<42;a++){const o=new Date(e,t,a-n+1),s=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===t,isToday:s===b,isSelected:s===D})}return r},[p,D,b]),E=t.useMemo(()=>p.toLocaleDateString(void 0,{month:"long",year:"numeric"}),[p]),M=t.useCallback(t=>{x(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),k=t.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),x(new Date(n.getFullYear(),n.getMonth(),1))},[e]);return n.jsxs("div",{className:"flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",children:[n.jsxs("div",{className:"flex items-center px-2 py-2",children:[n.jsx("button",{type:"button","aria-label":s?"Expand calendar sidebar":"Collapse calendar sidebar",className:"flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",onClick:()=>i(!s),children:s?n.jsx(r.PanelRightClose,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"}):n.jsx(r.PanelRightOpen,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),!s&&n.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Calendars"})]}),s?n.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-3",children:n.jsx("ul",{className:"space-y-1",children:a.map(e=>{var t;const r=!1!==e.isVisible,a=(null===(t=e.colors)||void 0===t?void 0:t.lineColor)||"#3b82f6";return Boolean(e.icon),n.jsx("li",{children:n.jsx("div",{draggable:!0,onDragStart:t=>v(e,t),onDragEnd:y,className:"rounded transition "+(f===e.id?"opacity-50":""),children:n.jsxs("label",{className:"group flex cursor-pointer items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800",title:e.name,children:[n.jsx("input",{type:"checkbox",className:"calendar-checkbox",style:{"--checkbox-color":a},checked:r,onChange:t=>o(e.id,t.target.checked)}),n.jsx("span",{className:"flex-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white",children:" "})]})})},e.id)})})}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-3",children:n.jsx("ul",{className:"space-y-1",children:a.map(e=>{var t;const r=!1!==e.isVisible,a=(null===(t=e.colors)||void 0===t?void 0:t.lineColor)||"#3b82f6",s=Boolean(e.icon);return n.jsx("li",{children:n.jsx("div",{draggable:!0,onDragStart:t=>v(e,t),onDragEnd:y,className:"rounded transition "+(f===e.id?"opacity-50":""),children:n.jsxs("label",{className:"group flex cursor-pointer items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800",title:e.name,children:[n.jsx("input",{type:"checkbox",className:"calendar-checkbox",style:{"--checkbox-color":a},checked:r,onChange:t=>o(e.id,t.target.checked)}),s&&n.jsx("span",{className:"mr-2 flex h-5 w-5 flex-shrink-0 items-center justify-center text-xs font-semibold text-white","aria-hidden":"true",children:wu(e)}),n.jsx("span",{className:"flex-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white",children:e.name||e.id})]})})},e.id)})})}),n.jsxs("div",{className:"border-t border-gray-200 px-3 py-3 dark:border-slate-800",children:[n.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[n.jsx("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:()=>M(-1),"aria-label":"Previous month",children:n.jsx(r.ChevronLeft,{className:"h-4 w-4"})}),n.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:E}),n.jsx("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:()=>M(1),"aria-label":"Next month",children:n.jsx(r.ChevronRight,{className:"h-4 w-4"})})]}),n.jsxs("div",{className:A,children:[w.map(e=>n.jsx("div",{className:`${L} text-gray-500 dark:text-gray-400`,children:e},Du())),C.map(e=>n.jsx("button",{type:"button",className:`\n ${V}\n ${e.isCurrentMonth?Z:F}\n ${e.isToday?z:""}\n ${e.isSelected&&!e.isToday?B:""}\n `,onClick:()=>k(e.fullDate),children:e.date},Du()))]})]})]})]})},Eu=({options:e,value:a,onChange:o})=>{const[s,i]=t.useState(!1),l=t.useRef(null);t.useEffect(()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),e.find(e=>e.value===a);const d=e=>v().resolveColors(e).lineColor;return n.jsxs("div",{className:"relative inline-block",ref:l,children:[n.jsxs("button",{type:"button",onClick:()=>i(!s),className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[n.jsx("span",{className:"w-4 h-4 rounded-sm flex-shrink-0",style:{backgroundColor:d(a)}}),n.jsx(r.ChevronsUpDown,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),s&&n.jsx("ul",{className:"absolute mt-1 w-full min-w-max bg-gray-100 dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 z-10 overflow-hidden border dark:border-gray-600",children:e.map(e=>n.jsxs("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors "+(a===e.value?"font-semibold":""),onClick:()=>{return t=e.value,o(t),void i(!1);var t},children:[a===e.value?n.jsx("span",{className:"mr-2 text-sm",children:n.jsx(r.Check,{width:12,height:12})}):n.jsx("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),n.jsx("span",{className:"w-3 h-3 mr-2 rounded-sm flex-shrink-0",style:{backgroundColor:d(e.value)}}),n.jsx("span",{className:"text-sm whitespace-nowrap",children:e.label})]},e.value))})]})},Mu=/(YYYY|YY|MM|DD|HH|mm)/g,ku=e=>e.toString().padStart(2,"0"),Tu=(e,t)=>{const n=(null!=t?t:"").trim(),r=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return r.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},ju=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Su=e=>{let t,n=0,r="^";for(;null!==(t=Mu.exec(e));){r+=ju(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=ju(e.slice(n))+"$",new RegExp(r)},Nu=(e,t,n,r)=>{const a=e.trim();if(!a)return null;const o=a.match(t),s=null==o?void 0:o.groups;if(!s)return null;const i=s.YYYY?Number(s.YYYY):s.YY?Number(s.YY)+2e3:n.year,l=s.MM?Number(s.MM):n.month,d=s.DD?Number(s.DD):n.day,c=s.HH?Number(s.HH):n.hour,u=s.mm?Number(s.mm):n.minute;try{return Pc.ZonedDateTime.from({timeZone:r,year:i,month:l,day:d,hour:c,minute:u,second:n.second,millisecond:n.millisecond,microsecond:n.microsecond,nanosecond:n.nanosecond})}catch(e){return null}},Iu=e=>{const t=e;if(t.timeZoneId&&"string"==typeof t.timeZoneId)return t.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const n=e.timeZone;return n&&"string"==typeof n.id?n.id:"string"==typeof t.timeZone?t.timeZone:Pc.Now.timeZoneId()},Hu=(e,t,n)=>{var r,a,o,s,i,l,d,c,u,h,g,f,m,v,y,p,x,b,D,w,C,E,M,k;if(!e){const e=null!=t?t:n?Iu(n):Pc.Now.timeZoneId();return null!=n?n:Pc.Now.zonedDateTimeISO(e)}if(Ac(e)){const n=null!=t?t:Pc.Now.timeZoneId(),r=`${e.year}-${ku(e.month)}-${ku(e.day)}T00:00:00[${n}]`;return Pc.ZonedDateTime.from(r)}if("hour"in e&&!("timeZone"in e)){const n=null!=t?t:Pc.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(n)}catch(e){}return Pc.ZonedDateTime.from({timeZone:n,year:e.year,month:e.month,day:e.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!==(s=e.nanosecond)&&void 0!==s?s:0})}try{return Pc.ZonedDateTime.from(e)}catch(r){const a=e,o=null!==(u=null!==(c=null!==(d=null!==(l="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(i=null==a?void 0:a.timeZone)||void 0===i?void 0:i.id)&&void 0!==l?l:null==a?void 0:a.timeZoneId)&&void 0!==d?d:t)&&void 0!==c?c:n?Iu(n):void 0)&&void 0!==u?u:Pc.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const s=null!=n?n:Pc.Now.zonedDateTimeISO(o);return Pc.ZonedDateTime.from({timeZone:o,year:null!==(h=null==a?void 0:a.year)&&void 0!==h?h:s.year,month:null!==(g=null==a?void 0:a.month)&&void 0!==g?g:s.month,day:null!==(f=null==a?void 0:a.day)&&void 0!==f?f:s.day,hour:null!==(v=null!==(m=null==a?void 0:a.hour)&&void 0!==m?m:null==n?void 0:n.hour)&&void 0!==v?v:0,minute:null!==(p=null!==(y=null==a?void 0:a.minute)&&void 0!==y?y:null==n?void 0:n.minute)&&void 0!==p?p:0,second:null!==(b=null!==(x=null==a?void 0:a.second)&&void 0!==x?x:null==n?void 0:n.second)&&void 0!==b?b:0,millisecond:null!==(w=null!==(D=null==a?void 0:a.millisecond)&&void 0!==D?D:null==n?void 0:n.millisecond)&&void 0!==w?w:0,microsecond:null!==(E=null!==(C=null==a?void 0:a.microsecond)&&void 0!==C?C:null==n?void 0:n.microsecond)&&void 0!==E?E:0,nanosecond:null!==(k=null!==(M=null==a?void 0:a.nanosecond)&&void 0!==M?M:null==n?void 0:n.nanosecond)&&void 0!==k?k:0})}},Ou=(e,t,n)=>{const r=Tu(t,n),a={YYYY:e.year.toString(),YY:ku(e.year%100),MM:ku(e.month),DD:ku(e.day),HH:ku(e.hour),mm:ku(e.minute)};return r.replace(Mu,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})},Ru=Array.from({length:24},(e,t)=>t),Pu=Array.from({length:60},(e,t)=>t),$u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Yu=(e,t)=>Pc.PlainDate.compare(e,t),Au=({value:e,format:o="YYYY-MM-DD HH:mm",showTimeFormat:s="HH:mm",showTime:i=!0,onChange:l,onOk:d,timeZone:c,disabled:u=!1,placement:h="bottomLeft",autoAdjustOverflow:g=!0,getPopupContainer:f,matchTriggerWidth:m=!1})=>{const v=t.useMemo(()=>void 0===i||("object"==typeof i||Boolean(i)),[i]),y=t.useMemo(()=>v?"object"==typeof i&&(null==i?void 0:i.format)?i.format:s:"",[v,i,s]),p=t.useMemo(()=>Tu(o,y),[o,y]),x=t.useMemo(()=>Su(p),[p]),b=t.useMemo(()=>{const t=null!=c?c:Ac(e[0])?Ac(e[1])?Pc.Now.timeZoneId():Iu(e[1]):Iu(e[0]),n=Hu(e[0],t);return[n,Hu(e[1],t,n)]},[e,c]),[D,w]=t.useState(b),C=t.useRef(b),[E,M]=t.useState("start"),[k,T]=t.useState([Ou(b[0],o,y),Ou(b[1],o,y)]),j=t.useRef([Ou(b[0],o,y),Ou(b[1],o,y)]),S=t.useRef(b),[N,I]=t.useState(b[0].toPlainDate().with({day:1})),[H,O]=t.useState(!1),R=t.useCallback(e=>{O(e)},[]),[P,$]=t.useState(h),Y=t.useRef(h),A=t.useRef(null),L=t.useRef(null),V=t.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),Z=t.useRef(!1);t.useEffect(()=>{j.current=k},[k]),t.useEffect(()=>{S.current=D},[D]),t.useEffect(()=>{const e=C.current,t=0!==Pc.ZonedDateTime.compare(e[0],b[0]),n=0!==Pc.ZonedDateTime.compare(e[1],b[1]);(t||n)&&w(b),C.current=b},[b]),t.useEffect(()=>{I(b[0].toPlainDate().with({day:1}))},[b[0]]);const F=t.useCallback((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,s=(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:s})},[]),z=t.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=V.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&F(n,r,0)})})})},[F]);t.useEffect(()=>{H&&v&&z(E)},[E,H,z,v]);const B=D[0].epochMilliseconds,W=D[0].offsetNanoseconds,U=D[1].epochMilliseconds,q=D[1].offsetNanoseconds;t.useEffect(()=>{const[e,t]=S.current,n=Ou(e,o,y),r=Ou(t,o,y),[a,s]=j.current;a===n&&s===r||(j.current=[n,r],T([n,r]))},[B,W,U,q,o,y]),t.useEffect(()=>{if(!H)return;const e=e=>{var t,n;const r=e.target;if(null===(t=A.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=L.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-rangepicker-popup]")||R(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[H]),t.useEffect(()=>{H||(M("start"),Z.current||w(b),Z.current=!1)},[H,b]);const _=t.useCallback(e=>{l&&l(e,[Ou(e[0],o,y),Ou(e[1],o,y)])},[y,o,l]),G=t.useCallback(e=>{d&&d(e,[Ou(e[0],o,y),Ou(e[1],o,y)])},[y,o,d]),X=t.useCallback((e,t)=>{w(n=>{const r=[...n];if("start"===e){const e=Hu(r[1],Iu(t),t),n=Pc.ZonedDateTime.compare(t,e)>0?t:e;return[t,n]}const a=Hu(r[0],Iu(t),t);return[Pc.ZonedDateTime.compare(a,t)>0?t:a,t]})},[]),J=t.useCallback((e,t)=>{if(u)return;const n="start"===e?0:1;w(r=>{const a=r[n],o=a.with({hour:t,minute:a.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Hu(r[1],Iu(o),o);return[o,Pc.ZonedDateTime.compare(o,e)>0?o:e]}const s=Hu(r[0],Iu(o),o);return[Pc.ZonedDateTime.compare(s,o)>0?o:s,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=V.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&F(t,n,0)})})},[u]),K=t.useCallback((e,t)=>{if(u)return;const n="start"===e?0:1;w(r=>{const a=r[n].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Hu(r[1],Iu(a),a);return[a,Pc.ZonedDateTime.compare(a,e)>0?a:e]}const o=Hu(r[0],Iu(a),a);return[Pc.ZonedDateTime.compare(o,a)>0?a:o,a]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=V.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&F(t,n,0)})})},[u]),Q=t.useCallback((e,t)=>{const n="start"===e?0:1;T(e=>{const r=[...e];return r[n]=t,r})},[]),ee=t.useCallback((e,t)=>{const n="start"===e?0:1,r=D[n],a=Iu(r),s=Nu(t,x,r,a);if(s){X(e,s);const t=s.toPlainDate().with({day:1});return I(t),"start"===e&&M("end"),!0}return T(e=>{const t=[...e];return t[n]=Ou(D[n],o,y),t}),!1},[D,y,o,x,X]),te=t.useCallback(e=>t=>{Q(e,t.target.value)},[Q]),ne=t.useCallback(e=>t=>{var n;if(u)return;if(H)return;const r=t.relatedTarget;r&&(null===(n=A.current)||void 0===n?void 0:n.contains(r))||ee(e,t.target.value)},[ee,u,H]),re=t.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),ee(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ee]),ae=e=>{I(t=>t.add({months:e}).with({day:1}))},oe=e=>{I(t=>t.add({years:e}).with({day:1}))},se=t.useMemo(()=>{const e=N,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[N]),ie=D[0].toPlainDate(),le=D[1].toPlainDate(),de=t.useCallback((e=h)=>{if(!g||!A.current)return e;const t=A.current.getBoundingClientRect(),n=m?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,s=t.right;let i=e;return i.startsWith("bottom")&&r<500&&a>r?i=i.replace("bottom","top"):i.startsWith("top")&&a<500&&r>a&&(i=i.replace("top","bottom")),i.endsWith("Left")&&o<n&&s>o?i=i.replace("Left","Right"):i.endsWith("Right")&&s<n&&o>s&&(i=i.replace("Right","Left")),i},[g,m,h]),ce=t.useCallback(()=>{const e=de();Y.current!==e&&(Y.current=e,$(e))},[de]),ue=e=>{if(u)return;M(e);const t=D["start"===e?0:1].toPlainDate().with({day:1});I(t);const n=de();Y.current!==n&&(Y.current=n,$(n)),R(!0)};t.useEffect(()=>{if(!H)return;ce();const e=()=>ce();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[H,ce]);const he=n.jsx("div",{ref:L,style:(()=>{if(!A.current)return{};const e=A.current.getBoundingClientRect(),t=Y.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,m&&(n.width=`${e.width}px`),n})(),"data-rangepicker-popup":"true",children:n.jsxs("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:m?"100%":void 0},children:[n.jsxs("div",{className:"flex gap-1",children:[n.jsxs("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{type:"button",disabled:u,onClick:()=>oe(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronsLeft,{width:14,height:12})}),n.jsx("button",{type:"button",disabled:u,onClick:()=>ae(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronLeft,{width:14,height:12})})]}),n.jsxs("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[$u[N.month-1]," ",N.year]}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{type:"button",disabled:u,onClick:()=>ae(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronRight,{width:14,height:12})}),n.jsx("button",{type:"button",disabled:u,onClick:()=>oe(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:n.jsx(r.ChevronsRight,{width:14,height:12})})]})]}),n.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pb-3 pt-2 text-center text-[11px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(e=>n.jsx("span",{children:e},e))}),n.jsx("div",{className:"grid grid-cols-7 gap-2 px-1 ",children:se.map(e=>{const t=e.month!==N.month,r=0===Yu(e,ie),a=0===Yu(e,le),o=Yu(e,ie)>=0&&Yu(e,le)<=0,s=r||a?"bg-blue-500 text-white font-semibold":o?"bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-300":t?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/30 hover:text-blue-600 dark:hover:text-blue-300";return n.jsx("button",{type:"button",disabled:u,onClick:()=>(e=>{if(u)return;const t=(e,t)=>{var n,r,a,o;const s=Iu(e);return Pc.ZonedDateTime.from({timeZone:s,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(n=e.second)&&void 0!==n?n:0,millisecond:null!==(r=e.millisecond)&&void 0!==r?r:0,microsecond:null!==(a=e.microsecond)&&void 0!==a?a:0,nanosecond:null!==(o=e.nanosecond)&&void 0!==o?o:0})};if("start"===E){const n=t(D[0],e),r=D[1].epochMilliseconds-D[0].epochMilliseconds,a=n.add({milliseconds:r});return void w([n,a])}const n=t(D[1],e),r=D[1].epochMilliseconds-D[0].epochMilliseconds;if(Pc.ZonedDateTime.compare(n,D[0])<0){const n=t(D[0],e),a=n.add({milliseconds:r});return void w([n,a])}const a=[D[0],n];w(a),I(n.toPlainDate().with({day:1}))})(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${s}`,children:e.day},e.toString())})})]}),v&&n.jsx("div",{className:"flex flex-1 justify-end sm:w-32",children:(()=>{const e=E,t=D["start"===e?0:1],r=t.minute,a=Pu.includes(r)?Pu:[...Pu,r].sort((e,t)=>e-t);return n.jsxs("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[n.jsx("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:n.jsxs("div",{className:"text-lg py-1 text-slate-700 dark:text-gray-300",children:[t.hour.toString().padStart(2,"0"),":",t.minute.toString().padStart(2,"0")]})}),n.jsxs("div",{className:"flex p-1",children:[n.jsx("div",{className:"w-14",children:n.jsx("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Hour",ref:t=>{V.current[e].hour=t},children:Ru.map(r=>{const a=r===t.hour;return n.jsx("button",{type:"button",role:"option","aria-selected":a,disabled:u,onClick:()=>J(e,r),className:"flex h-8 w-full items-center justify-center text-sm transition "+(a?"bg-blue-500 text-white font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/30 hover:text-blue-600 dark:hover:text-blue-300"),"data-active":a?"true":void 0,children:ku(r)},r)})})}),n.jsx("div",{className:"w-14",children:n.jsx("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Minute",ref:t=>{V.current[e].minute=t},children:a.map(t=>{const a=t===r;return n.jsx("button",{type:"button",role:"option","aria-selected":a,disabled:u,onClick:()=>K(e,t),className:"flex h-8 w-full items-center justify-center text-sm transition "+(a?"bg-blue-500 text-white font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/30 hover:text-blue-600 dark:hover:text-blue-300"),"data-active":a?"true":void 0,children:ku(t)},t)})})})]})]})})()})]}),n.jsx("div",{className:"flex justify-end",children:n.jsx("button",{type:"button",onClick:()=>{Z.current=!0,_(D),G(D),R(!1)},disabled:u,className:"inline-flex items-center rounded-full bg-blue-500 px-4 py-1.5 text-sm font-semibold text-white shadow-sm transition hover:bg-blue-400 disabled:cursor-not-allowed disabled:bg-slate-300",children:"OK"})})]})});return n.jsxs("div",{className:"relative max-w-[400px]",ref:A,children:[n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(u?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":H?"border-blue-500 bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-blue-300 dark:hover:border-blue-500"),children:[n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:n.jsx("input",{type:"text",value:k[0],onChange:te("start"),onFocus:()=>ue("start"),onClick:()=>ue("start"),onBlur:ne("start"),onKeyDown:re("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-0 "+(u?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===E&&H?" bg-white dark:bg-gray-700 text-blue-600 dark:text-blue-400":"border-transparent bg-transparent text-slate-700 dark:text-gray-300 hover:border-blue-200 dark:hover:border-blue-400"),placeholder:p,autoComplete:"off",disabled:u})}),n.jsx(r.MoveRight,{className:"text-slate-400 dark:text-gray-500"}),n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:n.jsx("input",{type:"text",value:k[1],onChange:te("end"),onFocus:()=>ue("end"),onClick:()=>ue("end"),onBlur:ne("end"),onKeyDown:re("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-0 "+(u?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===E&&H?"bg-white dark:bg-gray-700 text-blue-600 dark:text-blue-400":"border-transparent bg-transparent text-slate-700 dark:text-gray-300 hover:border-blue-200 dark:hover:border-blue-400"),placeholder:p,autoComplete:"off",disabled:u})})]}),H&&(f?a.createPortal(he,f()):a.createPortal(he,document.body))]})},Lu=({event:e,isOpen:r,isAllDay:o,onEventUpdate:s,onEventDelete:i,onClose:l})=>{var d;const c=t.useMemo(()=>v().getVisible().map(e=>({label:e.name,value:e.id})),[]),u=t.useMemo(()=>Ac(e.start)?e.end&&!Ac(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||Pc.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||Pc.Now.timeZoneId(),[e.end,e.start]),h=t=>{const[n,r]=t;s(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:r.toPlainDate()}))};if(!r)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const g=n.jsxs("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[n.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/80",onClick:e=>{const t=e.target;t.closest("[data-rangepicker-popup]")||t===e.currentTarget&&l()}}),n.jsxs("div",{className:"relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[n.jsx("button",{onClick:l,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),n.jsxs("div",{className:"pr-8",children:[n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Event Title"}),n.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[n.jsx("div",{className:"flex-1",children:n.jsx("input",{type:"text",value:e.title,onChange:t=>{s(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition"})}),n.jsx(Eu,{options:c,value:e.calendarId||"blue",onChange:t=>{s(Object.assign(Object.assign({},e),{calendarId:t}))}})]}),o?n.jsxs("div",{className:"mb-4",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Date Range"}),n.jsx(Au,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:u,matchTriggerWidth:!0,onChange:h,onOk:h})]}):n.jsxs("div",{className:"mb-4",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Time Range"}),n.jsx(Au,{value:[e.start,e.end],timeZone:u,onChange:t=>{const[n,r]=t;s(Object.assign(Object.assign({},e),{start:n,end:r}))},onOk:t=>{const[n,r]=t;s(Object.assign(Object.assign({},e),{start:n,end:r}))}})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Note"}),n.jsx("textarea",{value:null!==(d=e.description)&&void 0!==d?d:"",onChange:t=>s(Object.assign(Object.assign({},e),{description:t.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition resize-none",placeholder:"Add a note..."})]}),n.jsxs("div",{className:"flex space-x-2",children:[o?n.jsx("button",{className:"px-3 py-2 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded-lg hover:bg-blue-200 dark:hover:bg-blue-800 text-sm font-medium transition",onClick:()=>{const t=Ac(e.start)?e.start:e.start.toPlainDate(),n=Pc.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:Pc.Now.timeZoneId()}),r=Pc.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:Pc.Now.timeZoneId()});s(Object.assign(Object.assign({},e),{allDay:!1,start:n,end:r}))},children:"Set as Timed Event"}):n.jsx("button",{className:"px-3 py-2 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded-lg hover:bg-blue-200 dark:hover:bg-blue-800 text-sm font-medium transition",onClick:()=>{const t=Ac(e.start)?e.start:e.start.toPlainDate();s(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:"Set as All-day"}),n.jsx("button",{className:"px-3 py-2 bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 rounded-lg hover:bg-red-200 dark:hover:bg-red-800 text-sm font-medium transition",onClick:()=>{i(e.id),l()},children:"Delete"})]})]})]})]}),f=document.body;return f?a.createPortal(g,f):null},Vu=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.getAttribute("data-dayflow-theme-override"),t.getAttribute("data-theme-override"),t.getAttribute("data-theme")];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e},Zu=t.createContext(void 0),Fu=()=>"undefined"==typeof window?"light":window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",zu=({children:e,initialTheme:r="light",onThemeChange:a})=>{const[o,s]=t.useState(r),[i,l]=t.useState(Fu),d="auto"===o?i:o;t.useEffect(()=>{s(r)},[r]);const c=t.useCallback(e=>{s(e)},[]);t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";l(t)},n=e.matches?"dark":"light";return l(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),t.useEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Vu(d),n="auto"===o?t:d;e.classList.remove("light","dark"),e.classList.add(n),"auto"===o?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[d,o,i]),t.useEffect(()=>{a&&a(o,d)},[o,d,a]);const u={theme:o,effectiveTheme:d,setTheme:c};return n.jsx(Zu.Provider,{value:u,children:e})},Bu=()=>{const e=t.useContext(Zu);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Wu=({originalComponent:e,app:r,config:a,customDetailPanelContent:o,customEventDetailDialog:s,calendarRef:i,switcherMode:l,meta:d})=>{const c=r.getPlugin("events"),u=a.enableDrag?r.getPlugin("drag"):void 0,h=r.getCurrentDate(),g=r.state.currentView,f=r.getEvents(),m=t.useCallback(e=>{c?c.update(e.id,e):r.updateEvent(e.id,e)},[c,r]),v=t.useCallback(e=>{c?c.delete(e):r.deleteEvent(e)},[c,r]),y=t.useCallback(e=>{c?c.add(e):r.addEvent(e)},[c,r]),p=t.useCallback(e=>{r.setCurrentDate(e)},[r]),x=t.useCallback(e=>{r.changeView(e)},[r]),b=t.useMemo(()=>{const e=a.viewConfig||{};return u&&Object.assign(e,a.dragConfig||{}),c&&Object.assign(e,a.eventsConfig||{}),e},[a,u,c]),D=t.useMemo(()=>({app:r,currentDate:h,currentView:g,events:f,onEventUpdate:m,onEventDelete:v,onEventCreate:y,onDateChange:p,onViewChange:x,config:b}),[r,h,g,f,m,v,y,p,x,b]),w=t.useMemo(()=>{const e={currentDate:h,events:f,setEvents:e=>{f.forEach(e=>v(e.id)),e.forEach(e=>y(e))},updateEvent:m,deleteEvent:v,addEvent:y,goToPrevious:()=>{const e=new Date(h);switch(g){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}p(e)},goToNext:()=>{const e=new Date(h);switch(g){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}p(e)},goToToday:()=>{p(new Date)},changeView:x,selectDate:p};return Object.assign(Object.assign({calendar:e},D),{eventsService:c,dragService:u,customDetailPanelContent:o,customEventDetailDialog:s,calendarRef:i,switcherMode:l,meta:d})},[h,f,g,m,v,y,p,x,D,c,u,o,s,i,l,d]);return n.jsx(e,Object.assign({},w))},Uu=e=>{if(!e)return"";let t,n,r;e instanceof Date?(t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate()):Ac(e)?(t=e.year,n=e.month,r=e.day):(!function(){Pc.ZonedDateTime}(e),t=e.year,n=e.month,r=e.day);const a=String(n).padStart(2,"0");return`${String(r).padStart(2,"0")}/${a}/${t}`};function qu(e){return!("hour"in e)}function _u(e){return"hour"in e&&!("timeZone"in e)}function Gu(e){return"timeZone"in e}function Xu(e){return Pc.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Ju(e){return Pc.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 Ku(e,t){return Pc.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 Qu(e,t=!1){if(e instanceof Pc.PlainDate||e instanceof Pc.PlainDateTime)return e;if(e instanceof Date)return t?Xu(e):Ju(e);throw new Error("Invalid time type: "+typeof e)}function eh(e,t){if(e instanceof Pc.ZonedDateTime)return e;if(e instanceof Date)return Ku(e,t);throw new Error("Invalid time type: "+typeof e)}function th(e){var t;const n=Qu(e.start,e.allDay),r=Qu(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 nh(e){const t=eh(e.start,e.timeZone),n=eh(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}}const rh=e=>{const t=e.title.toLowerCase();return t.includes("holiday")||t.includes("vacation")||t.includes("假期")?n.jsx(r.Gift,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?n.jsx(r.Heart,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?n.jsx(r.Star,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?n.jsx(r.MapPin,{className:"h-3 w-3"}):n.jsx(r.CalendarDays,{className:"h-3 w-3"})},ah=(e,t)=>{const n=[],r=new Date(t);return r.setDate(t.getDate()+6),r.setHours(23,59,59,999),e.forEach(e=>{const a=Fc(e.start),o=Fc(e.end),s=new Date(a);s.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-a.getTime();e>0&&e<864e5&&(l=new Date(i),l.setDate(l.getDate()-1))}}const d=qc(s,l)>0;if(!d&&e.allDay){if(s<t||s>r)return;const a=Math.floor((s.getTime()-t.getTime())/864e5);return void(a>=0&&a<=6&&n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:a,endDayIndex:a,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!d)return;const c=s;let u;if(e.allDay)u=new Date(i),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(i),u.setHours(23,59,59,999)):(u=new Date(i),u.setTime(u.getTime()-1))}if(u<t||c>r)return;const h=c<t?t:c,g=u>r?r:u,f=Math.max(0,Math.floor((h.getTime()-t.getTime())/864e5)),m=Math.min(6,Math.floor((g.getTime()-t.getTime())/864e5)),v=c>=t,y=u<=r,p=0===f||6===m;let x;x=v&&y?"single":v?p&&6===m?"start-week-end":"start":y?p&&0===f?"end-week-start":"end":"middle";const b=qc(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:f,endDayIndex:m,segmentType:x,totalDays:b,segmentIndex:0,isFirstSegment:v,isLastSegment:y})}),n},oh=(e,t)=>{if(e.allDay)return[];const n=Fc(e.start),r=Fc(e.end),a=new Date(n);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);const s=qc(a,o);if(0===s)return[];const i=0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds(),l=r.getTime()-n.getTime();if(!e.allDay&&1===s&&!i&&l<864e5)return[];const d=i?s:Math.max(0,s-1),c=[];for(let e=0;e<=d;e++){const o=new Date(a);o.setDate(a.getDate()+e);const s=Math.floor((o.getTime()-t.getTime())/864e5);if(s<0||s>6)continue;const l=0===e,u=e===d,h=l?n.getHours()+n.getMinutes()/60:0,g=u&&i?r.getHours()+r.getMinutes()/60:24;c.push({dayIndex:s,startHour:h,endHour:g,isFirst:l,isLast:u})}return c},sh=t.memo(({segment:e,segmentIndex:t,isDragging:r,isResizing:a=!1,isSelected:o=!1,onMoveStart:s,onResizeStart:i})=>{const l=17*t,d=`calc(${e.startDayIndex/7*100}% + 2px)`,c=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,u=t=>{const r="left"===t;return(r?e.isFirstSegment:e.isLastSegment)&&i?n.jsx("div",{className:`resize-handle absolute ${r?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e.event,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},h=e.event.calendarId||"blue",g=e.endDayIndex-e.startDayIndex+1;return n.jsxs("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign({left:d,width:c,top:l-2+"px",height:"16px",borderRadius:(f=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"}[f]),pointerEvents:"auto",zIndex:10},o||r?{backgroundColor:tu(h),color:"#fff"}:{backgroundColor:Qc(h),color:eu(h)}),"data-segment-days":g,onMouseDown:t=>{t.preventDefault(),t.stopPropagation();t.target.closest(".resize-handle")||s(t,e.event)},title:`${e.event.title} (${Uu(e.event.start)} - ${Uu(e.event.end)})`,children:[u("left"),n.jsx("div",{className:"flex-1 min-w-0",style:{cursor:a?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,r=e.event.calendarId||"blue",a=Gc(e.event.start),o=iu(e.event),s=au(a),i=au(o);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return n.jsxs("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[e.isFirstSegment&&n.jsx("div",{className:"flex-shrink-0 mr-1",children:n.jsx("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:nu(r),width:"12px",height:"12px"},children:rh(e.event)})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"truncate font-medium text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&n.jsx("div",{className:"flex-shrink-0 ml-1 text-white/80 dark:text-white/90",children:n.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?e.event.title:"···",d=e.endDayIndex-e.startDayIndex+1,c=d>1?{position:"absolute",right:`calc(${d>1?(d-1)/d*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return n.jsxs("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[n.jsx("span",{className:"inline-block w-[3px] h-3 rounded-full flex-shrink-0 mr-1",style:{backgroundColor:nu(r)}}),n.jsx("div",{className:"flex items-center min-w-0 flex-1",children:n.jsx("span",{className:"truncate font-medium text-xs",children:l})}),e.isFirstSegment&&n.jsx("span",{className:"text-xs font-medium whitespace-nowrap "+(1===d?"ml-2":""),style:c,children:s}),e.isLastSegment&&!e.event.allDay&&24!==o&&n.jsx("span",{className:"text-xs font-medium whitespace-nowrap ml-auto",children:`ends ${i}`})]})})()}),u("right")]});var f});sh.displayName="MultiDayEvent";const ih=({event:e,position:r,panelRef:o,isAllDay:s,eventVisibility:i,calendarRef:l,selectedEventElementRef:d,onEventUpdate:c,onEventDelete:u})=>{var h;const{effectiveTheme:g}=Bu(),f=Vu(g),m="dark"===f?"#1f2937":"white",y="dark"===f?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=t.useMemo(()=>v().getVisible().map(e=>({label:e.name,value:e.id})),[]),x=t.useMemo(()=>Ac(e.start)?e.end&&!Ac(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||Pc.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||Pc.Now.timeZoneId(),[e.end,e.start]),b=t=>{const[n,r]=t;c(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:r.toPlainDate()}))},D=(()=>{var e;let t={};if("sticky-top"===i){const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-r.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(r.isSunday?`1px solid ${y}`:"none"),borderTop:""+(r.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${y}`),borderBottom:""+(r.isSunday?"none":`1px solid ${y}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const e=o.current;let n=200;if(e){const t=e.getBoundingClientRect(),r=window.getComputedStyle(e),a=parseInt(r.paddingBottom,10)||0,o=parseInt(r.borderBottomWidth,10)||0;n=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:m,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 ${y}`:"none"),borderTop:""+(r.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${y}`),borderBottom:""+(r.isSunday?"none":`1px solid ${y}`)}}else if(r&&d.current&&l.current){const e=d.current.getBoundingClientRect(),n=l.current.querySelector(".calendar-content");if(n){const a=n.getBoundingClientRect(),s=Math.max(e.top,a.top),i=Math.min(e.bottom,a.bottom),l=Math.max(0,i-s);let d;d=l===e.height?e.top+e.height/2:l>0?s+l/2:e.top+e.height/2;const c=d-r.top,u=o.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,r=parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,f=Math.max(g,Math.min(h,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(r.isSunday?`1px solid ${y}`:"none"),borderTop:""+(r.isSunday?`1px solid ${y}`:"none"),borderLeft:""+(r.isSunday?"none":`1px solid ${y}`),borderBottom:""+(r.isSunday?"none":`1px solid ${y}`)},r.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),w=n.jsxs("div",{ref:o,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg p-4 ","data-event-detail-panel":"true",style:{top:`${r.top}px`,left:`${r.left}px`,zIndex:9999,pointerEvents:"auto"},children:[n.jsx("div",{style:D}),n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Event Title"}),n.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[n.jsx("div",{className:"flex-1",children:n.jsx("input",{type:"text",value:e.title,onChange:t=>{c(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition"})}),n.jsx(Eu,{options:p,value:e.calendarId||"blue",onChange:t=>{c(Object.assign(Object.assign({},e),{calendarId:t}))}})]}),s?n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Date Range"}),n.jsx(Au,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:x,matchTriggerWidth:!0,onChange:b,onOk:b})]}):n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Time Range"}),n.jsx(Au,{value:[e.start,e.end],timeZone:x,onChange:t=>{const[n,r]=t;c(Object.assign(Object.assign({},e),{start:n,end:r}))},onOk:t=>{const[n,r]=t;c(Object.assign(Object.assign({},e),{start:n,end:r}))}})]}),n.jsxs("div",{className:"mb-3",children:[n.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:"Note"}),n.jsx("textarea",{value:null!==(h=e.description)&&void 0!==h?h:"",onChange:t=>c(Object.assign(Object.assign({},e),{description:t.target.value})),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 focus:border-blue-400 dark:focus:border-blue-500 transition resize-none",placeholder:"Add a note..."})]}),n.jsxs("div",{className:"flex space-x-2",children:[s?n.jsx("button",{className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded hover:bg-blue-200 dark:hover:bg-blue-800 text-xs font-medium transition",onClick:()=>{const t=Ac(e.start)?e.start:e.start.toPlainDate(),n=Pc.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:Pc.Now.timeZoneId()}),r=Pc.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:Pc.Now.timeZoneId()});c(Object.assign(Object.assign({},e),{allDay:!1,start:n,end:r}))},children:"Set as Timed Event"}):n.jsx("button",{className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded hover:bg-blue-200 dark:hover:bg-blue-800 text-xs font-medium transition",onClick:()=>{const t=Ac(e.start)?e.start:e.start.toPlainDate();c(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:"Set as All-day"}),n.jsx("button",{className:"px-2 py-1 bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 rounded hover:bg-red-200 dark:hover:bg-red-800 text-xs font-medium transition",onClick:()=>u(e.id),children:"Delete"})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const C=document.body;return C?a.createPortal(w,C):null},lh=({event:e,position:t,panelRef:r,isAllDay:o,eventVisibility:s,calendarRef:i,selectedEventElementRef:l,onEventUpdate:d,onEventDelete:c,onClose:u,contentRenderer:h})=>{const{effectiveTheme:g}=Bu(),f=Vu(g),m="dark"===f?"#1f2937":"white",v="dark"===f?"rgb(55, 65, 81)":"rgb(229, 231, 235)",y=(()=>{var e;let n={};if("sticky-top"===s){const r=null===(e=i.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(r){const e=r.getBoundingClientRect().top+3-t.top;n=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"===s){const e=r.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}n={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&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),s=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),l=Math.max(0,i-s);let d;d=l===e.height?e.top+e.height/2:l>0?s+l/2:e.top+e.height/2;const c=d-t.top,u=r.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,r=parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,f=Math.max(g,Math.min(h,c));n=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 n})(),p=n.jsxs("div",{ref:r,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg p-3","data-event-detail-panel":"true",style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===f?"#1f2937":"#ffffff"},children:[n.jsx("div",{style:y}),n.jsx(h,{event:e,isAllDay:o,onEventUpdate:d,onEventDelete:c,onClose:u})]});return a.createPortal(p,document.body)},dh=({event:e,layout:o,isAllDay:s=!1,allDayHeight:i=28,calendarRef:l,isBeingDragged:d=!1,isBeingResized:c=!1,isDayView:u=!1,isMonthView:h=!1,isMultiDay:g=!1,segment:f,segmentIndex:m=0,hourHeight:v,firstHour:y,selectedEventId:p,detailPanelEventId:x,onMoveStart:b,onResizeStart:D,onEventUpdate:w,onEventDelete:C,newlyCreatedEventId:E,onDetailPanelOpen:M,onEventSelect:k,onDetailPanelToggle:T,customDetailPanelContent:j,customEventDetailDialog:S,multiDaySegmentInfo:N})=>{const[I,A]=t.useState(!1),L=g&&f?`${e.id}::${f.id}`:void 0!==(null==N?void 0:N.dayIndex)?`${e.id}::day-${N.dayIndex}`:e.id,V=x===L,[Z,F]=t.useState(null),[z,B]=t.useState("visible"),W=t.useRef(null),q=t.useRef(null),_=t.useRef(null),X=t.useRef(null),J=void 0!==p?p===e.id:I,K=e=>{if(!l.current)return null;const t=l.current.getBoundingClientRect();if(h){const n=t.width/7,r=e-t.left,a=Math.floor(r/n);return Number.isFinite(a)?Math.max(0,Math.min(6,a)):null}const n=u?1:7,r=(t.width-80)/n,a=e-t.left-80,o=Math.floor(a/r);return Number.isFinite(o)?Math.max(0,Math.min(n-1,o)):null},Q=e=>{if(!l.current)return null;const t=l.current.getBoundingClientRect();if(h){const n=t.width/7;return{left:t.left+e*n,width:n}}if(u){const e=t.width-80;return{left:t.left+80,width:e}}const n=(t.width-80)/7;return{left:t.left+80+e*n,width:n}},ee=e=>{X.current=e},te=()=>{var t;if(null!==X.current)return X.current;if(x===L){const e=L.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==N?void 0:N.dayIndex)?N.dayIndex:f?f.startDayIndex:null!==(t=e.day)&&void 0!==t?t:0},ne=t.useCallback(()=>{if(!_.current||!l.current||!q.current)return;const t=l.current.getBoundingClientRect(),n=te(),r=Q(n);let a,o;if(r)a=r.left,o=r.width;else if(h)o=t.width/7,a=t.left+n*o;else{const e=80;o=(t.width-e)/7,a=t.left+e+n*o}const s=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var r,o,d,c,m;if(!q.current)return;if(!_.current)return;const p=q.current.getBoundingClientRect(),x=p.width,b=p.height;let D,w,C;if("sticky-top"===z||"sticky-bottom"===z){const t=null===(r=l.current)||void 0===r?void 0:r.querySelector(".calendar-content");if(!t)return;const n=N?N.startHour:Gc(e.start),a=N?N.endHour:iu(e),s=(n-y)*v,i=Math.max((a-n)*v,v/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+s-c,h=null===(o=W.current)||void 0===o?void 0:o.getBoundingClientRect();if(!h)return;C={top:u,bottom:u+i,left:h.left,right:h.right,width:h.width,height:i,x:h.x,y:u,toJSON:()=>({})}}else C=_.current.getBoundingClientRect();if(h&&g&&f){const e=Q(n),r=null!==(d=null==e?void 0:e.width)&&void 0!==d?d:t.width/7,a=null!==(c=null==e?void 0:e.left)&&void 0!==c?c:t.left+n*r,o=a+r;C={top:C.top,bottom:C.bottom,left:a,right:o,width:o-a,height:C.height,x:a,y:C.top,toJSON:()=>({})}}if(("sticky-top"===z||"sticky-bottom"===z)&&!h){const e=null!==(m=null==N?void 0:N.dayIndex)&&void 0!==m?m:te(),n=80,r=u?1:7,a=(t.width-n)/r,o=Q(e),s=o?o.left:t.left+n+e*a,i=o?o.width:a,l=Math.max(0,u?C.width:i-3),d=u?C.left:s;C=Object.assign(Object.assign({},C),{left:d,right:d+l,width:l})}const E=s-C.right,M=C.left-t.left;D=E>=x+20?C.right+10:M>=x+20?C.left-x-10:E>M?Math.max(t.left+10,s-x-10):t.left+10;const k=C.top-b/2+C.height/2,T=Math.max(10,t.top+10),j=i-10;w=k<T?T:k+b>j?j-b:k,F(e=>e?Object.assign(Object.assign({},e),{top:w,left:D,isSunday:D<a}):null)})},[l,e.day,e.start,e.end,z,h,y,v,g,null==f?void 0:f.startDayIndex,null==f?void 0:f.endDayIndex,null==N?void 0:N.dayIndex,x,L]),re=t.useCallback(()=>{if(!I||!V||!W.current||!l.current||s||h)return;const t=l.current.querySelector(".calendar-content");if(!t)return;const n=N?N.startHour:Gc(e.start),r=N?N.endHour:iu(e),a=(n-y)*v,o=a+Math.max((r-n)*v,v/4),i=t.getBoundingClientRect(),d=t.scrollTop;let c=o<d+6,u=a>d+i.height-6;const g=i.bottom<0,f=i.top>window.innerHeight;g?c=!0:f&&(u=!0),B(c?"sticky-top":u?"sticky-bottom":"visible"),ne()},[I,V,l,s,h,Gc(e.start),iu(e),y,v,ne,null==N?void 0:N.startHour,null==N?void 0:N.endHour,null==N?void 0:N.dayIndex,x,L]);t.useEffect(()=>{var e,t;if(!I||!V||s)return;const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const r=()=>re(),a=()=>{re(),ne()},o=[n];let i=null===(t=l.current)||void 0===t?void 0:t.parentElement;for(;i;){const e=window.getComputedStyle(i),t=e.overflowY,n=e.overflowX;"auto"!==t&&"scroll"!==t&&"auto"!==n&&"scroll"!==n||o.push(i),i=i.parentElement}return o.forEach(e=>{e.addEventListener("scroll",r)}),window.addEventListener("scroll",r,!0),window.addEventListener("resize",a),re(),()=>{o.forEach(e=>{e.removeEventListener("scroll",r)}),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",a)}},[I,V,s,re,ne,l,z]),t.useEffect(()=>{if(!J&&!V)return;const e=e=>{var t,n;const r=e.target,a=null===(t=W.current)||void 0===t?void 0:t.contains(r),o=null===(n=q.current)||void 0===n?void 0:n.contains(r),s=r.closest("[data-event-detail-dialog]"),i=r.closest("[data-rangepicker-popup]");V?a||o||s||i||(k&&k(null),ee(null),A(!1),null==T||T(null)):J&&!a&&(k&&k(null),ee(null),A(!1),null==T||T(null))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[J,V,k,T]),t.useEffect(()=>{g&&f&&!f.isFirstSegment||E!==e.id||V||setTimeout(()=>{var t,n;if(W.current){let r=W.current;if(g){const e=W.current.querySelector("div");e&&(r=e)}g?f?ee(f.startDayIndex):void 0!==(null==N?void 0:N.dayIndex)?ee(N.dayIndex):ee(null!==(t=e.day)&&void 0!==t?t:null):ee(null!==(n=e.day)&&void 0!==n?n:null),_.current=r,A(!0),null==T||T(L),F({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{ne()})}null==M||M()},150)},[E,e.id,V,M,ne,g,f,T,L]);const ae=()=>f?n.jsx(sh,{segment:f,segmentIndex:null!=m?m:0,isDragging:d||J,isResizing:c,isSelected:J,onMoveStart:b||(()=>{}),onResizeStart:D}):null,oe=()=>{if(g&&f){const{segmentType:e}=f;if("single"===e||"start"===e)return O;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 O},se=e.calendarId||"blue";return n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:W,"data-event-id":e.id,className:h?`\n ${H}\n ${s?oe():"rounded-sm"}\n `:`\n ${H}\n shadow-sm\n ${s?oe():"rounded-sm"}\n `,style:Object.assign(Object.assign({},(()=>{var t,n,r,a,c,p;if(h)return{opacity:d?.3:1,zIndex:J||V?1e3:1};if(s){const e={height:i-4+"px",opacity:d?.3:1,zIndex:J||V?1e3:1},t=m*i;if(Object.assign(e,{top:`${t}px`}),u)Object.assign(e,{width:"100%",left:"0px",right:"2px"});else if(g&&f){const t=(f.endDayIndex-f.startDayIndex+1)/7*100,n=f.startDayIndex/7*100,r=2,a=f.isFirstSegment?r:0,o=a+(f.isLastSegment?r:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:a>0?`calc(${n}% + ${a}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"calc(100% - 3px)",left:"0px",position:"relative"});return e}const x=N?N.startHour:Gc(e.start),b=N?N.endHour:iu(e),D={top:`${(x-y)*v+3}px`,height:Math.max((b-x)*v,v/4)-4+"px",position:"absolute",opacity:d?.3:1,zIndex:J||V?1e3:null!==(t=null==o?void 0:o.zIndex)&&void 0!==t?t:1};if(J&&V&&("sticky-top"===z||"sticky-bottom"===z)){const e=null===(n=l.current)||void 0===n?void 0:n.getBoundingClientRect();if(e){const t=null!==(r=null==N?void 0:N.dayIndex)&&void 0!==r?r:te(),n=80,o=u?1:7;let s=(e.width-n)/o,i=e.left+n+t*s;h&&(s=e.width/7,i=e.left+t*s);const d=Q(t);d&&(i=d.left,s=d.width);let g=null===(a=l.current)||void 0===a?void 0:a.querySelector(".calendar-content");g||(g=null===(c=l.current)||void 0===c?void 0:c.querySelector(".calendar-renderer"));const f=null==g?void 0:g.getBoundingClientRect(),m=null===(p=W.current)||void 0===p?void 0:p.getBoundingClientRect(),v=null==m?void 0:m.left,y=null==m?void 0:m.width;if("sticky-top"===z){let t=f?f.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:`${u?v:i}px`,width:`${u?y:s-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let x=f?f.bottom:e.bottom;return x=Math.min(x,window.innerHeight),x=Math.min(x,e.bottom),x=Math.max(x,e.top+6),x=Math.max(x,6),{position:"fixed",top:x-6+"px",left:`${u?v:i}px`,width:`${u?y:s-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}return o&&!s?Object.assign(Object.assign({},D),{left:`${o.left}%`,width:o.width-1+"%",right:"auto"}):Object.assign(Object.assign({},D),{left:"0px",right:"3px"})})()),J?{backgroundColor:tu(se),color:"#fff"}:{backgroundColor:Qc(se),color:eu(se)}),onClick:t=>{var n,r;if(t.preventDefault(),t.stopPropagation(),g)if(f){const e=K(t.clientX);if(null!==e){const t=Math.min(Math.max(e,f.startDayIndex),f.endDayIndex);ee(t)}else ee(f.startDayIndex)}else void 0!==(null==N?void 0:N.dayIndex)?ee(N.dayIndex):ee(null!==(n=e.day)&&void 0!==n?n:null);else ee(null!==(r=e.day)&&void 0!==r?r:null);k?k(e.id):A(!0),null==T||T(null),F(null)},onDoubleClick:t=>{var n,r;t.preventDefault(),t.stopPropagation();let a=t.currentTarget;if(g){const e=a.querySelector("div");e&&(a=e)}if(_.current=a,g)if(f){const e=K(t.clientX);if(null!==e){const t=Math.min(Math.max(e,f.startDayIndex),f.endDayIndex);ee(t)}else ee(f.startDayIndex)}else void 0!==(null==N?void 0:N.dayIndex)?ee(N.dayIndex):ee(null!==(n=e.day)&&void 0!==n?n:null);else ee(null!==(r=e.day)&&void 0!==r?r:null);new Promise(t=>{if(!l.current||s||h)return void t();const n=l.current.querySelector(".calendar-content");if(!n)return void t();const r=N?N.startHour:Gc(e.start),a=N?N.endHour:iu(e),o=(r-y)*v,i=o+Math.max((a-r)*v,v/4),d=n.scrollTop,c=n.clientHeight;if(o>=d&&i<=d+c)return void t();const u=((r+a)/2-y)*v-c/2,g=n.scrollHeight-c,f=Math.max(0,Math.min(g,u));n.scrollTo({top:f,behavior:"smooth"}),setTimeout(()=>{t()},300)}).then(()=>{A(!0),null==T||T(L),F({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{ne()})})},onMouseDown:b?t=>{var n;if(N){const r=Object.assign(Object.assign({},e),{day:null!==(n=N.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:N});b(t,r)}else b(t,e)}:void 0,children:h?g&&f?ae():e.allDay?g?ae():n.jsxs("div",{className:"text-xs px-1 mb-0.5 rounded truncate cursor-pointer flex items-center",children:[e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?n.jsx("span",{className:`inline-block ${G} flex-shrink-0 ${J?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):n.jsx(r.CalendarDays,{className:`${$} ${J?"text-white":""}`}),n.jsx("span",{className:"truncate "+(J?"text-white":""),children:e.title})]}):(()=>{const t=`${Math.floor(Gc(e.start)).toString().padStart(2,"0")}:${Math.round(Gc(e.start)%1*60).toString().padStart(2,"0")}`;return n.jsxs("div",{className:"text-xs mb-0.5 cursor-pointer flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[n.jsx("span",{style:{backgroundColor:nu(e.calendarId||"blue")},className:`inline-block w-[3px] h-3 ${G} flex-shrink-0 rounded-full`}),n.jsx("span",{className:"truncate "+(J?"text-white":""),children:e.title})]}),n.jsx("span",{className:`${U} ml-1 flex-shrink-0 ${J?"text-white":""}`,style:J?void 0:{opacity:.8},children:t})]})})():e.allDay?n.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[D&&n.jsx("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),D(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),n.jsx(r.CalendarDays,{className:$}),n.jsx("div",{className:`${R} pr-1`,style:{lineHeight:"1.2"},children:e.title}),D&&n.jsx("div",{className:Y,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),D(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}):(()=>{const t=N?N.startHour:Gc(e.start),r=N?N.endHour:iu(e),a=r-t,o=!N||N.isFirst,s=!N||N.isLast;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:P,style:{backgroundColor:nu(e.calendarId||"blue")}}),n.jsxs("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(iu(e)-Gc(e.start)<=.25?"px-1 py-0":"p-1"),children:[n.jsx("div",{className:`${R} pr-1`,style:{lineHeight:a<=.25?"1.2":"normal"},children:e.title}),a>.5&&n.jsx("div",{className:"text-xs opacity-80 truncate",children:N?`${au(t)} - ${au(r)}`:ou(e)})]}),D&&n.jsxs(n.Fragment,{children:[o&&n.jsx("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>D(t,e,"top")}),s&&n.jsx("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>D(t,e,"bottom")}),!o&&s&&N&&n.jsx("div",{className:Y,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),D(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})})()}),V&&n.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!V)return null;const t=()=>{k&&k(null),ee(null),A(!1),null==T||T(null)};if(S){const r=S,o={event:e,isOpen:V,isAllDay:s,onEventUpdate:w,onEventDelete:C,onClose:t};if("undefined"==typeof window||"undefined"==typeof document)return null;const i=document.body;return i?a.createPortal(n.jsx(r,Object.assign({},o)),i):null}return Z?j?n.jsx(lh,{event:e,position:Z,panelRef:q,isAllDay:s,eventVisibility:z,calendarRef:l,selectedEventElementRef:_,onEventUpdate:w,onEventDelete:C,onClose:t,contentRenderer:j}):n.jsx(ih,{event:e,position:Z,panelRef:q,isAllDay:s,eventVisibility:z,calendarRef:l,selectedEventElementRef:_,onEventUpdate:w,onEventDelete:C,onClose:t}):null})()]})};function ch(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:Gc(e.start),_endHour:e.allDay?0:iu(e)})}function uh(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:Gc(e.start)}function hh(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:iu(e)}const gh=.25,fh=.5,mh=25,vh=1,yh=.9;class ph{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(ch);this.clearAllParentChildRelations(n);const r=new Map,a=n.filter(e=>!e.allDay);if(0===a.length)return r;const o=this.groupOverlappingEvents(a);for(let e=0;e<o.length;e++){const n=o[e];1===n.length?this.setSingleEventLayout(n[0],r):this.calculateComplexGroupLayout(n,r,t)}return r}static clearAllParentChildRelations(e){for(const t of e)t.parentId=void 0,t.children=[]}static setParentChildRelation(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}static eventsOverlap(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(uh(e)<hh(t)&&uh(t)<hh(e))}static groupOverlappingEvents(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)||this.eventsOverlap(t,r)&&(a.push(r),o.push(r),n.add(r.id))}t.push(a)}return t}static setSingleEventLayout(e,t){t.set(e.id,{id:e.id,left:0,width:100-yh,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const r=[...e].sort((e,t)=>{const n=uh(e),r=uh(t);if(n!==r)return n-r;return hh(t)-uh(t)-(hh(e)-uh(e))}),a=this.analyzeParallelGroups(r),o=this.buildNestedStructure(a,e);this.calculateLayoutFromStructure(o,t,n)}static analyzeParallelGroups(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(uh(r)-uh(t))<=gh&&(a.push(t),n.add(t.id))}a.sort((e,t)=>uh(e)-uh(t));const o={events:a,startHour:Math.min(...a.map(e=>uh(e))),endHour:Math.max(...a.map(e=>hh(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}static shouldBeParallel(e,t){if(!this.eventsOverlap(e,t))return!1;const n=Math.abs(uh(e)-uh(t));if(n<=gh)return!0;if(n>gh&&n<fh)return!0;return!!this.checkExtendedEventParallel(e,t)}static checkExtendedEventParallel(e,t){return!!this.eventsOverlap(e,t)&&(!!this.isExtendedEventParallel(e,t)||!!this.isExtendedEventParallel(t,e))}static isExtendedEventParallel(e,t){const n=hh(e)-uh(e);if(n<1.25)return!1;const r=uh(e)+.4*n,a=uh(t)>=r,o=this.eventsOverlap(e,t);return a&&o}static buildNestedStructure(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],s=o.events.map(e=>a.get(e.id));let i=!1;for(let l=n-1;l>=0&&!i;l--){const n=e[l],d=n.events.map(e=>a.get(e.id)),c={events:d,startHour:n.startHour,endHour:n.endHour};if(this.canGroupContain(c,{events:s,startHour:o.startHour,endHour:o.endHour})){const e=this.optimizeChildAssignments(s,c,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)}i=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),this.rebalanceLoadByGroups(e,n),o}static findAlternateBranchRoot(e,t,n){const r=n.get(e.id);if(!r)return null;let a=r;for(;a.parent&&a.depth>1;)a=a.parent;if(1!==a.depth)return null;const o=a.parent;if(!o)return null;const s=o.children.filter(e=>1===e.depth&&e.event.id!==a.event.id);let i=1/0,l=null;for(const e of s){const t=this.calculateBranchLoad(e);t<i&&(i=t,l=e)}return l?l.event:null}static calculateBranchLoad(e){let t=0;function n(e){t++;for(const t of e.children)n(t)}for(const t of e.children)n(t);return t}static canGroupContain(e,t){const n=t.startHour-e.startHour;if(this.checkLoadBalanceParallel(e,t))return!1;if(n<fh)return!1;let r=!1;for(const n of e.events){for(const e of t.events)if(this.canEventContain(n,e)){r=!0;break}if(r)break}return r}static checkLoadBalanceParallel(e,t){for(const n of e.events)for(const e of t.events){if(!this.eventsOverlap(n,e))continue;const t=Math.abs(uh(e)-uh(n));if(t<=gh)return!0;if(t>gh&&t<fh)return!0}return!1}static canEventContain(e,t){const n=uh(e)<=uh(t)&&hh(e)>=hh(t),r=uh(e)<=uh(t)&&uh(t)<hh(e)&&this.eventsOverlap(e,t);return n||r}static optimizeChildAssignments(e,t,n){const r=[];if(1===e.length){const a=this.findBestParentInGroup(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),this.setParentChildRelation(a,e[0])),r}if(1===t.events.length){const n=t.events[0];for(const t of e)this.canEventContain(n,t)&&(r.push({child:t,parent:n}),this.setParentChildRelation(n,t));return r}const a=t.events.filter(t=>e.every(e=>this.canEventContain(t,e)));if(0===a.length){for(const a of e){const o=this.findBestParentInGroup(a,t,n);if(o)r.push({child:a,parent:o}),this.setParentChildRelation(o,a);else{const t=e.find(e=>e.id!==a.id&&this.eventsOverlap(e,a));if(t){const e=this.buildTempNodeMap(n),o=this.findAlternateBranchRoot(t,Array.from(e.values()),e);o&&(r.push({child:a,parent:o}),this.setParentChildRelation(o,a))}}}return r}const o=[...e].sort((e,t)=>{const n=hh(e)-uh(e);return hh(t)-uh(t)-n});if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],s=o.slice(t*e,(t+1)*e);for(const e of s)r.push({child:e,parent:n}),this.setParentChildRelation(n,e)}return r}for(let e=0;e<o.length;e++){const t=o[e],n=this.findParentWithMinLoadFromEvents(t,a,o);n&&(r.push({child:t,parent:n}),this.setParentChildRelation(n,t))}return r}static buildTempNodeMap(e){const t=new Map;for(const n of e){const e={event:n,children:[],parent:null,depth:0,isProcessed:!1};t.set(n.id,e)}for(const n of e)if(n.parentId){const e=t.get(n.id),r=t.get(n.parentId);e&&r&&(e.parent=r,e.depth=r.depth+1,r.children.push(e))}return t}static findParentWithMinLoadFromEvents(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=a.map(e=>e.children).flat(),s=hh(e)-uh(e),i=s>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?hh(t)-uh(t):0}));n.every(e=>hh(e)-uh(e)===s);return i?a[0]:a[a.length-1]}static findBestParentInGroup(e,t,n){const r=t.events.filter(t=>this.canEventContain(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(e=>({parent:e,load:e.children.length,hasParallelSibling:!1}));for(const t of a)for(const r of t.parent.children){const a=n.find(e=>e.id===r);if(a&&this.shouldBeParallel(e,a)){t.hasParallelSibling=!0;break}}a.sort((t,n)=>{if(t.load!==n.load)return t.load-n.load;if(t.hasParallelSibling!==n.hasParallelSibling)return t.hasParallelSibling?-1:1;if(t.load!==n.load)return t.load-n.load;return Math.abs(uh(e)-uh(t.parent))-Math.abs(uh(e)-uh(n.parent))});return a[0].parent}static calculateLayoutFromStructure(e,t,n={}){const r=100-yh;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,r,t,n);else{const a=e.length,o=(r-vh*(a-1))/a;e.forEach((e,r)=>{const a=r*(o+vh);this.calculateNodeLayoutWithVirtualParallel(e,a,Math.max(o,mh),t,n)})}}static calculateNodeLayoutWithVirtualParallel(e,t,n,r,a={}){let o=e.depth*this.getIndentStepPercent(a.viewType);if(e.isProcessed){const t=this.findBranchRootIndent(e,a.viewType);null!==t&&(o=t)}let s=0;const i="day"===a.viewType;1===e.depth?s=i?.5:1.5:2===e.depth?s=i?-.01:-1:e.depth>=3&&(s=i?.55:-3.5);const l=t+o+s;let d=n-(o+s);if(l+d>t+n&&(d=t+n-l,console.warn(`⚠️ ${e.event.title}'s width exceeds parent event range, adjusted to: ${d.toFixed(1)}%`)),r.set(e.event.id,{id:e.event.id,left:l,width:d,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:o*(a.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),0===e.children.length)return;const c=[...e.children].sort((e,t)=>{const n=hh(e.event)-uh(e.event);return hh(t.event)-uh(t.event)-n});if(1===c.length)this.calculateNodeLayoutWithVirtualParallel(c[0],l,d,r,a);else{const e=this.shouldChildrenBeParallel(c.map(e=>e.event));e?this.calculateParallelChildrenLayout(c,l,d,r,a):c.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,l,d,r,a)})}}static calculateParallelChildrenLayout(e,t,n,r,a={}){const o=e.length,s=e[0].depth,i=s*this.getIndentStepPercent(a.viewType);let l;const d="day"===a.viewType;l=1===s?d?.5:1.5:2===s?d?-.01:-1:d?.55:-3.5;const c=t+i+l,u=n-(i+l);if(u<=0)return void e.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,t,n,r,a)});let h;h=1===s?vh*(d?.15:.3):vh*(d?.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:i*(a.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>{const n=hh(e.event)-uh(e.event);return hh(t.event)-uh(t.event)-n});if(1===t.length)this.calculateNodeLayoutWithVirtualParallel(t[0],n,g,r,a);else{const e=this.shouldChildrenBeParallel(t.map(e=>e.event));e?this.calculateParallelChildrenLayout(t,n,g,r,a):t.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,n,g,r,a)})}}})}static findBranchRootIndent(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;if(1===n.depth){return n.depth*this.getIndentStepPercent(t)}return null}static shouldChildrenBeParallel(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(this.shouldBeParallel(e[t],e[n]))return!0;return!1}static calculateEventImportance(e){const t=hh(e)-uh(e);return Math.max(.1,Math.min(1,t/4))}static countDescendants(e){let t=0;for(const n of e.children)t+=1+this.countDescendants(n);return t}static findTransferableLeaf(e,t){const n=[];return this.collectLeaves(e,n),n.find(e=>this.canEventContain(t.event,e.event))||n[0]}static collectLeaves(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>this.collectLeaves(e,t))}static transferNode(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children;let r=null;for(const t of n){if(this.shouldBeParallel(e.event,t.event))break;if(this.canEventContain(t.event,e.event)){r=t;break}}r?(e.parent=r,e.depth=r.depth+1,r.children.push(e),this.setParentChildRelation(r.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),this.setParentChildRelation(t.event,e.event))}static calculateParentLoads(e,t){var n,r;const a=[],o=null===(r=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===r?void 0:r.depth;if(void 0===o)return a;const s=t.filter(e=>e.depth===o);for(const e of s){const t=this.countDescendants(e);a.push({node:e,load:t})}return a.sort((e,t)=>t.load-e.load),a}static needsRebalancing(e){if(e.length<2)return!1;return e[0].load-e[e.length-1].load>=2}static rebalanceGroupLoad(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],r=e[e.length-1];if(n.load-r.load<2)break;const a=this.findTransferableLeaf(n.node,r.node);if(!a)break;this.transferNode(a,r.node),n.load--,r.load++,t++}}static rebalanceLoadByGroups(e,t){for(let n=e.length-1;n>=1;n--){const r=e[n].events.map(e=>t.find(t=>t.event.id===e.id)),a=this.calculateParentLoads(r,t);this.needsRebalancing(a)&&this.rebalanceGroupLoad(a)}}}const xh={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>nu(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const bh=e=>{const{viewType:n,onEventsUpdate:r}=e,a=n===exports.ViewType.MONTH,o=t.useRef({active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,resizeDirection:null,hourOffset:null,duration:0,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}),s=t.useRef({x:0,y:0}),i=t.useMemo(()=>a?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1},[a]),[l,d]=t.useState(i),c=t.useMemo(()=>function(e,t){let n=null,r=0;const a=function(...a){const o=Date.now(),s=t-(o-r);s<=0||s>t?(n&&(clearTimeout(n),n=null),r=o,e.apply(this,a)):n||(n=setTimeout(()=>{r=Date.now(),n=null,e.apply(this,a)},s))};return a.cancel=()=>{n&&(clearTimeout(n),n=null),r=0},a}((e,t)=>r(e,"resize"===t),a?16:8),[a,r]),u=t.useCallback(()=>{d(a?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1}),o.current={active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,duration:0,resizeDirection:null,hourOffset:null,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}},[a]);return{dragRef:o,currentDragRef:s,dragState:l,setDragState:d,resetDragState:u,throttledSetEvents:c}},Dh={renderAllDayContent:({title:e,color:t})=>n.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[n.jsx(r.CalendarDays,{className:"h-3 w-3 mr-1 text-white"}),n.jsx("div",{className:"font-medium text-xs truncate pr-1 text-white",children:e})]}),renderRegularContent:({drag:e,title:t,layout:r,formatTime:a,getLineColor:o,getDynamicPadding:s,color:i})=>n.jsxs(n.Fragment,{children:[n.jsx("div",{className:P,style:{backgroundColor:o(i||"blue")}}),n.jsxs("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${s(e)}`,children:[n.jsx("div",{className:"font-medium text-xs truncate pr-1 text-white",style:{lineHeight:e.endHour-e.startHour<=.25?"1.2":"normal"},children:t}),!e.allDay&&e.endHour-e.startHour>.5&&n.jsxs("div",{className:"text-xs truncate time-display text-white opacity-90",children:[a(e.startHour)," - ",a(e.endHour)]})]})]}),renderDefaultContent:({drag:e,title:t,allDay:r})=>r?n.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0",children:[n.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 002 2z"})}),n.jsx("div",{className:"font-medium text-xs truncate pr-1",style:{lineHeight:1.2},children:t})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute left-0.5 top-1 bottom-1 w-0.5 rounded-full bg-blue-600 dark:bg-blue-400"}),n.jsx("div",{className:"h-full flex flex-col overflow-hidden pl-3 p-1",children:n.jsx("div",{className:"font-medium text-xs truncate pr-1 text-blue-900 dark:text-blue-100",children:t})})]})},wh=({drag:e,color:t,title:r,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l,renderer:d=Dh})=>{const c=r||(o?"New All-day Event":"New Event");return n.jsx("div",{className:"drag-indicator-content",children:t?o?d.renderAllDayContent({drag:e,color:t,title:c,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l}):d.renderRegularContent({drag:e,color:t,title:c,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l}):d.renderDefaultContent({drag:e,color:t,title:c,layout:a,allDay:o,formatTime:s,getLineColor:i,getDynamicPadding:l})})},Ch=({event:e,isCreating:t,isMultiDay:a=!1,startDate:o,endDate:s})=>{const i=(()=>{if(t)return{title:"New Event",icon:n.jsx(r.Calendar,{className:"h-3 w-3"}),showDateRange:!1};if(a&&o&&s){const t=qc(o,s)+1;return{title:e.title.replace(/ \(\d+天\)$/,""),showDateRange:!0,duration:t}}return{title:e.title,showDateRange:!1}})();return n.jsxs("div",{className:"flex items-center space-x-2 text-white text-xs font-medium rounded-sm",children:[n.jsx("div",{className:"flex-shrink-0",children:i.icon}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"truncate font-medium",children:i.title})})]})},Eh=e=>{const n=t.useMemo(()=>Object.assign(Object.assign({},xh),e),[e]),{viewType:r}=n,a=r===exports.ViewType.MONTH,s=(e=>{const{calendarRef:n,allDayRowRef:r,viewType:a,HOUR_HEIGHT:o=72,FIRST_HOUR:s=0,LAST_HOUR:i=24,TIME_COLUMN_WIDTH:l=80}=e,d=a===exports.ViewType.MONTH,c=a===exports.ViewType.WEEK,u=t.useCallback(e=>{if(d||!n.current)return s;const t=n.current.querySelector(".calendar-content");if(!t)return s;const r=t.getBoundingClientRect(),a=t.scrollTop,l=window.getComputedStyle(t),c=parseInt(l.paddingTop,10)||0,u=(e-r.top+a-c)/o+s;return Math.max(s,Math.min(i,u))},[n,s,o,i,d]),h=t.useCallback(e=>{if(d||!n.current)return 0;const t=n.current.getBoundingClientRect(),r=(t.width-l)/(c?7:1),a=e-t.left-l,o=Math.floor(a/r);return Math.max(0,Math.min(c?6:0,o))},[n,l,d,c]),g=t.useCallback(e=>{if(d||!n.current)return;const t=n.current.querySelector(".calendar-content");if(!t)return;const r=t.getBoundingClientRect();e<r.top?t.scrollTop+=e-r.top:e+40>r.bottom&&(t.scrollTop+=e+40-r.bottom)},[n,d]),f=t.useCallback(e=>{if(d||!(null==r?void 0:r.current))return!1;const t=r.current.getBoundingClientRect();return e>=t.top&&e<=t.bottom},[r,d]),m=t.useMemo(()=>864e5,[]);return{pixelYToHour:u,getColumnDayIndex:h,checkIfInAllDayArea:f,handleDirectScroll:g,daysDifference:t.useCallback((e,t)=>qc(e,t),[]),addDaysToDate:t.useCallback((e,t)=>_c(e,t),[]),getTargetDateFromPosition:t.useCallback((e,t)=>{if(a!==exports.ViewType.MONTH||!n.current)return null;const r=document.elementFromPoint(e,t);if(!r)return null;let o=r,s=0;for(;o&&!o.hasAttribute("data-date")&&s<10;)o=o.parentElement,s++;if(o&&o.hasAttribute("data-date")){const e=o.getAttribute("data-date");if(e)return new Date(e+"T00:00:00")}return null},[n,a]),ONE_DAY_MS:m}})(n),i=bh(n),l=(e=>{const{calendarRef:n,allDayRowRef:r,viewType:a,getLineColor:s,getDynamicPadding:i,renderer:l,HOUR_HEIGHT:d=72,FIRST_HOUR:c=0,TIME_COLUMN_WIDTH:u=80,ALL_DAY_HEIGHT:h=60}=e,g=a===exports.ViewType.MONTH,f=a===exports.ViewType.DAY,m=t.useRef(null),v=t.useRef(null),y=t.useRef(null),p=t.useCallback(()=>{v.current&&(v.current.unmount(),v.current=null),m.current&&(m.current.remove(),m.current=null),y.current=null},[]),x=t.useCallback((e,a,x,b,D)=>{var w,C,E,M,k,T,j,S,N;p();const I=document.createElement("div");if(I.style.position=g?"fixed":"absolute",I.style.pointerEvents="none",I.style.zIndex="1000",g){let n,r;if(I.style.opacity="0.9",D){const t=D.getBoundingClientRect(),a=null!==(C=null!==(w=e.currentSegmentDays)&&void 0!==w?w:e.eventDurationDays)&&void 0!==C?C:1;n=t.width/a,r=t.height,I.className=`rounded-sm shadow-sm ${D.className}`}else n=120,r=22,I.className="rounded text-xs px-2 py-1";I.style.width=`${n}px`,I.style.height=`${r}px`,I.style.left=e.startX-n/2+"px",I.style.top=e.startY-r/2+"px",document.body.appendChild(I),v.current=o.createRoot(I);const s=Lc(new Date),i=e.originalEvent||{id:String(Date.now()),color:a||"blue",title:x||"New Event",start:s,end:s,allDay:!1,day:0};v.current.render(t.createElement(Ch,{event:i,isCreating:"create"===e.mode,targetDate:e.targetDate||null,startDate:e.originalStartDate||null,endDate:e.originalEndDate||null}))}else{if(D){const t=D.getBoundingClientRect();let a;if(a=e.allDay?null===(E=null==r?void 0:r.current)||void 0===E?void 0:E.getBoundingClientRect():null===(k=null===(M=n.current)||void 0===M?void 0:M.querySelector(".calendar-content"))||void 0===k?void 0:k.getBoundingClientRect(),a){if(e.allDay&&f)I.style.left=`${u}px`,I.style.top=D.offsetTop-2+"px",I.style.width=`calc(100% - ${u}px - 2px)`,I.style.height=`${t.height}px`;else if(e.allDay&&!f){const r=null===(T=n.current)||void 0===T?void 0:T.getBoundingClientRect();if(r){const n=(r.width-u)/7;I.style.left=`${u+e.dayIndex*n}px`,I.style.top=D.offsetTop-2+"px",I.style.width=n-2+"px",I.style.height=`${t.height}px`}}else{const n=(e.startHour-c)*d;I.style.left=t.left-a.left+"px",I.style.top=`${n+3}px`,I.style.width=`${t.width}px`,I.style.height=`${t.height}px`}I.className=D.className,I.style.opacity="0.8",I.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}}else if(e.allDay){const t=f?"100%":`calc((100% - ${u}px) / 7)`;I.style.top="2px",I.style.height=h-4+"px",I.style.marginBottom="3px",f?(I.style.left=`${u}px`,I.style.width=`calc(100% - ${u}px - 2px)`):(I.style.left=`calc(${u}px + (${t} * ${e.dayIndex}))`,I.style.width=`calc(${t} - 2px)`),I.className="rounded-xl shadow-sm"}else{const t=(e.startHour-c)*d,n=(e.endHour-e.startHour)*d;if(I.style.top=`${t+3}px`,I.style.height=n-4+"px",I.style.color="#fff",I.className="rounded-sm shadow-sm",b){if(f)I.style.left=`${u}px`,I.style.width=`calc(100% - ${u}px)`;else{const t=`calc((100% - ${u}px) / 7)`;I.style.left=`calc(${u}px + (${t} * ${e.dayIndex}) + (${t} * ${b.left/100}))`,I.style.width=`calc((${t} * ${b.width/100}))`}I.style.zIndex=String(1e3)}else{const t=f?`calc(100% - ${u}px)`:`calc((100% - ${u}px) / 7)`;I.style.left=f?`${u}px`:`calc(${u}px + (${t} * ${e.dayIndex}))`,I.style.width=t}}e.allDay?null===(j=null==r?void 0:r.current)||void 0===j||j.appendChild(I):null===(N=null===(S=n.current)||void 0===S?void 0:S.querySelector(".calendar-content"))||void 0===N||N.appendChild(I),y.current={drag:e,color:a,title:x,layout:b},v.current=o.createRoot(I),v.current.render(t.createElement(wh,{drag:e,color:a,title:x,layout:b,allDay:e.allDay,formatTime:au,getLineColor:s||(()=>""),getDynamicPadding:i||(()=>"0px"),renderer:l}))}a?(I.style.backgroundColor=tu(a),I.style.color=eu(a)):I.className+=" bg-blue-50/70 text-blue-900 border border-dashed border-blue-400",m.current=I},[p,g,f,r,n,au,s,i,l,u,h,c,d]),b=t.useCallback((...e)=>{var a,o;const p=m.current;if(p)if(g){const[t,n]=e,r=parseFloat(p.style.width)||120,a=parseFloat(p.style.height)||22;requestAnimationFrame(()=>{p.style.left=t-r/2+"px",p.style.top=n-a/2+"px",p.style.transition="none"})}else{const[g,m,x,b=!1,D]=e;if(b&&p.parentElement!==(null==r?void 0:r.current))null===(a=null==r?void 0:r.current)||void 0===a||a.appendChild(p);else if(!b){const e=null===(o=n.current)||void 0===o?void 0:o.querySelector(".calendar-content");p.parentElement!==e&&(null==e||e.appendChild(p))}if(b){if(f)p.style.left=`${u}px`,p.style.width=`calc(100% - ${u}px - 2px)`;else{const e=`calc((100% - ${u}px) / 7)`;p.style.left=`calc(${u}px + (${e} * ${g}))`,p.style.width=`calc(${e} - 2px)`,p.style.top="2px"}p.style.height=h-4+"px",p.style.marginBottom="3px",p.className=p.className.replace("rounded-sm","rounded-xl")}else{const e=(m-c)*d,t=(x-m)*d;if(p.style.top=`${e+3}px`,p.style.height=t-4+"px",p.style.marginBottom="0",p.className=p.className.replace("rounded-xl","rounded-sm"),D){if(f)p.style.left=`${u}px`,p.style.width=`calc(100% - ${u}px)`;else{const e=`calc((100% - ${u}px) / 7)`;p.style.left=`calc(${u}px + (${e} * ${g}) + (${e} * ${D.left/100}))`,p.style.width=`calc((${e} * ${D.width/100}))`}p.style.zIndex=String(D.zIndex+10)}else{const e=f?`calc(100% - ${u}px)`:`calc((100% - ${u}px) / 7)`;p.style.left=f?`${u}px`:`calc(${u}px + (${e} * ${g}))`,p.style.width=e}}if(p.style.cursor="grabbing",v.current&&y.current){const e=Object.assign(Object.assign({},y.current.drag),{dayIndex:g,startHour:m,endHour:x,allDay:b});y.current.drag=e,v.current.render(t.createElement(wh,{drag:e,color:y.current.color,title:y.current.title,layout:D||y.current.layout,allDay:b,formatTime:au,getLineColor:s||(()=>""),getDynamicPadding:i||(()=>"0px"),renderer:l}))}}},[g,r,au,n,f,h,u,c,d,s,i,l]);return{dragIndicatorRef:m,reactRootRef:v,removeDragIndicator:p,createDragIndicator:x,updateDragIndicator:b}})(n),d=(e=>{const{options:n,common:r,state:a,manager:o}=e,{viewType:s,onEventsUpdate:i,onEventCreate:l,onEventEdit:d,calculateNewEventLayout:c,calculateDragLayout:u,currentWeekStart:h,events:g,FIRST_HOUR:f=0,LAST_HOUR:m=24,MIN_DURATION:v=.25}=n,{dragRef:y,currentDragRef:p,setDragState:x,resetDragState:b,throttledSetEvents:D}=a,{removeDragIndicator:w,createDragIndicator:C,updateDragIndicator:E}=o,{pixelYToHour:M,getColumnDayIndex:k,checkIfInAllDayArea:T,handleDirectScroll:j,daysDifference:S,addDaysToDate:N,getTargetDateFromPosition:I}=r,H=s===exports.ViewType.MONTH,O=s===exports.ViewType.DAY,R=864e5,P=(e,t,n=!1)=>{const r=new Date(e);r.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);let o=Math.floor((a.getTime()-r.getTime())/R);if(o<=0)return 0;if(!n&&1===o){const n=0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds(),r=t.getTime()-e.getTime();if(n&&r<R)return 0}return o},$=t.useCallback(e=>{var t,n;e.preventDefault();const r=y.current;if(!r.active)return;"resize"===r.mode?r.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing";const a=T(e.clientY),o=O?r.dayIndex:k(e.clientX);if(a){if(!r.allDay){r.allDay=!0,r.startHour=0,r.endHour=0,r.eventDate=h?yu(h,o):new Date,w(),r.indicatorVisible=!1;const e=null==g?void 0:g.find(e=>e.id===r.eventId);C(r,null==e?void 0:e.calendarId,null==e?void 0:e.title),r.sourceElement=null,r.indicatorVisible=!0}r.dayIndex=o,x(e=>Object.assign(Object.assign({},e),{dayIndex:o,startHour:0,endHour:0,allDay:!0})),E(o,0,0,!0)}else{j(e.clientY);const a=M(e.clientY);if(null!==(t=r.startDragDayIndex)&&void 0!==t||r.originalDay,r.dayIndex,r.allDay){r.allDay=!1,r.startHour=su(a),r.endHour=r.startHour+1,r.duration=1,r.hourOffset=0,r.eventDate=h?yu(h,o):new Date,w(),r.indicatorVisible=!1;const e=null==g?void 0:g.find(e=>e.id===r.eventId);C(r,null==e?void 0:e.calendarId,null==e?void 0:e.title),r.sourceElement=null,r.indicatorVisible=!0}else{let e=su(a+(null!==(n=r.hourOffset)&&void 0!==n?n:0));e=Math.max(f,Math.min(m-r.duration,e)),r.startHour=e,r.endHour=e+r.duration}r.dayIndex=o,r.eventDate=h?yu(h,o):new Date,x(e=>Object.assign(Object.assign({},e),{dayIndex:o,startHour:su(r.startHour),endHour:su(r.endHour),allDay:!1}));let s=null;if("move"===r.mode&&r.eventId&&u){const e=null==g?void 0:g.find(e=>e.id===r.eventId);e&&(s=u(e,o,su(r.startHour),su(r.endHour)))}E(o,su(r.startHour),su(r.endHour),!1,s)}},[u,T,C,h,g,f,k,j,m,O,M,w,E,y,x]),Y=t.useCallback(()=>{document.body.style.cursor="default";const e=y.current;if(!e.active||"move"!==e.mode||!e.eventId)return;let t=e.startHour,n=e.endHour;e.allDay||(t=su(e.startHour),n=su(e.endHour),n-t<v&&(n=t+v)),null==i||i(r=>r.map(r=>{var a,o;if(r.id!==e.eventId)return r;h?yu(h,e.dayIndex):Fc(r.start);const s=null!==(a=e.startDragDayIndex)&&void 0!==a?a:e.originalDay,i=e.dayIndex-s;let l,d;if(e.allDay){const t=e.originalStartDate?new Date(e.originalStartDate):Fc(r.start);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()+i);const a=new Date(n);e.eventDurationDays&&e.eventDurationDays>0&&a.setDate(a.getDate()+e.eventDurationDays),l=Vc(n),d=Vc(Jc(a))}else{const a=Fc(r.start),s=Fc(r.end);if(P(a,s,null!==(o=r.allDay)&&void 0!==o&&o)>0){const e=new Date(a);e.setDate(e.getDate()+i);const t=new Date(s);t.setDate(t.getDate()+i),l=Lc(e),d=Lc(t)}else{const r=h?yu(h,e.dayIndex):new Date,a=Xc(r,t),o=Xc(r,n);l=Lc(a),d=Lc(o)}}const c=e.originalDay+i;return Object.assign(Object.assign({},r),{day:c,start:l,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",Y),w(),b()},[$,w,b,i,v,h,y]),A=t.useCallback(e=>{var t,n,r,a,o,s,i,l,d;e.preventDefault();const v=y.current;if(v.active)if("resize"===v.mode?H||v.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",H){if("resize"!==v.mode){if("move"===v.mode){const r=Math.hypot(e.clientX-v.startX,e.clientY-v.startY);!v.indicatorVisible&&r>=3&&(C(v,null===(t=v.originalEvent)||void 0===t?void 0:t.calendarId,null===(n=v.originalEvent)||void 0===n?void 0:n.title,null,v.sourceElement||void 0),v.indicatorVisible=!0)}v.indicatorVisible&&E(e.clientX,e.clientY)}const o=I(e.clientX,e.clientY);if(!o)return;if("resize"===v.mode&&v.originalEvent&&v.resizeDirection){const e=Fc(v.originalEvent.start);let t,n;const r=(e,t)=>{var n,r;e&&((null===(n=v.originalEvent)||void 0===n?void 0:n.allDay)?e.setHours(0,0,0,0):t&&e.setHours(t.hour,t.minute,null!==(r=t.second)&&void 0!==r?r:0,0))},a=v.originalStartTime,s=v.originalEndTime;if("left"===v.resizeDirection){t=new Date(o),r(t,a);const i=Fc(v.originalEvent.end)||e;n=new Date(i),r(n,s),t>n&&(t=n)}else{const i=Fc(v.originalEvent.start)||e;t=new Date(i),r(t,a),n=new Date(o),r(n,s),n<t&&(n=t)}v.originalStartDate=new Date(t.getTime()),v.originalEndDate=new Date(n.getTime());const i=v.originalEvent.allDay?Vc(t):Lc(t),l=v.originalEvent.allDay?Vc(n):Lc(n);D(e=>e.map(e=>e.id===v.eventId?Object.assign(Object.assign({},e),{start:i,end:l,title:e.title}):e),v.mode)}else if("move"===v.mode)if(v.originalStartDate&&v.originalEndDate){const e=S(v.originalStartDate,o),t=N(v.originalStartDate,e),n=N(v.originalEndDate,e);(null===(r=v.originalStartDate)||void 0===r?void 0:r.getTime())!==t.getTime()&&(v.originalStartDate=new Date(t.getTime()),v.originalEndDate=new Date(n.getTime()),v.targetDate=t)}else(null===(a=v.targetDate)||void 0===a?void 0:a.getTime())!==o.getTime()&&(v.targetDate=o)}else{j(e.clientY),v.lastClientY=e.clientY;const t=M(e.clientY);if("resize"===v.mode)if(v.allDay){const t=O?v.dayIndex:k(e.clientX);let n=v.originalStartDate||new Date,r=v.originalEndDate||new Date;"left"===v.resizeDirection?(n=h?yu(h,t):new Date,n>r&&(n=r)):"right"===v.resizeDirection&&(r=h?yu(h,t):new Date,r<n&&(r=n)),v.originalStartDate=new Date(n.getTime()),v.originalEndDate=new Date(r.getTime());const a=Vc(n),o=Vc(r);D(e=>e.map(e=>e.id!==v.eventId?e:Object.assign(Object.assign({},e),{start:a,end:o,allDay:!0})),v.mode)}else{let n=v.startHour,r=v.endHour;const a=null==g?void 0:g.find(e=>e.id===v.eventId);let d=v.dayIndex;if(a){const e=Fc(a.start),t=Fc(a.end),n=P(e,t,null!==(o=a.allDay)&&void 0!==o&&o);d=(null!==(s=a.day)&&void 0!==s?s:0)+n}let c=d,u=v.originalDay;if("top"===v.resizeDirection){const a=O?v.dayIndex:k(e.clientX),o=t+(null!==(i=null==v?void 0:v.hourOffset)&&void 0!==i?i:0);a<d?(u=a,n=Math.max(f,Math.min(m,o))):(u=d,o>v.originalEndHour?(n=v.originalEndHour,r=o,v.hourOffset=r-t):(n=Math.max(f,o),v.originalEndHour-n<ru&&(n=v.originalEndHour-ru)))}else if("bottom"===v.resizeDirection){const a=O?v.dayIndex:k(e.clientX),o=t+(null!==(l=null==v?void 0:v.hourOffset)&&void 0!==l?l:0);a!==v.dayIndex?(c=a,r=Math.max(f,Math.min(m,o))):o<v.originalStartHour?(r=v.originalStartHour,n=o,v.hourOffset=n-t):(r=Math.min(m,o),r-v.startHour<ru&&(r=v.startHour+ru))}else if("right"===v.resizeDirection){const t=O?v.dayIndex:k(e.clientX);c=Math.max(v.dayIndex,t)}c===u&&([n,r]=[Math.max(f,Math.min(n,r)),Math.min(m,Math.max(n,r))]);const[y,p]=[su(n),su(r)];v.startHour=n,v.endHour=r,v.dayIndex=u,D(e=>e.map(e=>{if(e.id!==v.eventId)return e;const t=Fc(e.start),n=Xc(h?yu(h,u):t,y),r=h?yu(h,c):t,a=Xc(r,p),o=Lc(n),s=Lc(a);return Object.assign(Object.assign({},e),{start:o,end:s,day:u})}),v.mode),E(v.dayIndex,y,p,!1)}else if("create"===v.mode){const n=su(t),[r,a]=e.clientY<v.startY?[n,Math.max(n+ru,v.endHour)]:[v.startHour,Math.max(v.startHour+ru,n)];v.startHour=r,v.endHour=a;const o=null==c?void 0:c(v.dayIndex,r,a);E(v.dayIndex,r,a,!1,o)}else if("move"===v.mode){const n=O?v.dayIndex:k(e.clientX);let r=su(t+(null!==(d=v.hourOffset)&&void 0!==d?d:0));r=Math.max(f,Math.min(m-v.duration,r));const a=r+v.duration;v.dayIndex=n,v.startHour=r,v.endHour=a;let o=null;if(v.eventId&&u){const e=null==g?void 0:g.find(e=>e.id===v.eventId);e&&(o=u(e,n,su(r),su(a)))}E(n,su(r),su(a),!1,o)}}},[H,O,E,I,D,S,N,f,m,c,k,M,j,u,g,y,C]),L=t.useCallback(e=>{var t,n;document.body.style.cursor="default";const r=y.current;if(r.active){if(H){if("resize"===r.mode&&r.eventId&&r.originalStartDate&&r.originalEndDate){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:r.originalStartDate,startDate:r.originalStartDate,endDate:r.originalEndDate}):e);const e=(null===(t=r.originalEvent)||void 0===t?void 0:t.allDay)||!1,n=e?Vc(r.originalStartDate):Lc(r.originalStartDate),a=e?Vc(r.originalEndDate):Lc(r.originalEndDate);D(e=>e.map(e=>e.id===r.eventId?Object.assign(Object.assign({},e),{start:n,end:a,title:e.title}):e))}else if("move"===r.mode)if(r.eventId&&r.originalStartDate&&r.originalEndDate){x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:r.originalStartDate,startDate:r.originalStartDate,endDate:r.originalEndDate}):e);const e=(null===(n=r.originalEvent)||void 0===n?void 0:n.allDay)||!1,t=e?Vc(r.originalStartDate):Lc(r.originalStartDate),a=e?Vc(r.originalEndDate):Lc(r.originalEndDate);D(e=>e.map(e=>e.id===r.eventId?Object.assign(Object.assign({},e),{start:t,end:a,title:e.title}):e))}else{const t=I(e.clientX,e.clientY)||r.targetDate;r.eventId&&t&&(x(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:t}):e),D(e=>e.map(e=>{if(e.id!==r.eventId)return e;const n=Fc(e.start),a=Fc(e.end),o=new Date(t);o.setHours(n.getHours(),n.getMinutes(),0,0);const s=new Date(t);s.setHours(a.getHours(),a.getMinutes(),0,0);const i=e.allDay?Vc(o):Lc(o),l=e.allDay?Vc(s):Lc(s);return Object.assign(Object.assign({},e),{start:i,end:l})})))}}else{let[e,t]=[su(r.startHour),su(r.endHour)];if(t-e<v&&("top"===r.resizeDirection?e=t-v:t=e+v),"create"===r.mode){const n=h?yu(h,r.dayIndex):new Date;x(n=>"dayIndex"in n?Object.assign(Object.assign({},n),{dayIndex:r.dayIndex,startHour:e,endHour:t}):n);const a=Xc(n,e),o=Xc(n,t),s=Lc(a),i=Lc(o);null==l||l({id:String(Date.now()),title:"New Event",day:r.dayIndex,start:s,end:i,calendarId:"blue",allDay:!1})}else"move"!==r.mode&&"resize"!==r.mode||(x(n=>"dayIndex"in n?Object.assign(Object.assign({},n),{dayIndex:r.dayIndex,startHour:e,endHour:t}):n),"move"===r.mode&&(null==i||i(e=>e.map(e=>e.id===r.eventId?Object.assign(Object.assign({},e),{day:r.dayIndex}):e))))}document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",L),w(),r.indicatorVisible=!1,r.sourceElement=null,b()}},[H,A,w,b,I,D,v,h,l,i,y,x]),V=t.useCallback((e,...t)=>{if(e.preventDefault(),e.stopPropagation(),!y.current.active)if(H){const[e]=t,n=new Date(e);n.setHours(9,0,0,0);const r=new Date(e);r.setHours(10,0,0,0);const a=Lc(n),o=Lc(r),s={id:String(Date.now()),title:"New Event",start:a,end:o,day:e.getDay(),calendarId:"blue",allDay:!1};null==l||l(s),d&&setTimeout(()=>{d(s)},50)}else{const[n,r]=t,a=y.current,o=su(r);Object.assign(a,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:n,startHour:o,endHour:o+1,allDay:!1,eventDate:h?yu(h,n):new Date}),x({active:!0,mode:"create",eventId:null,dayIndex:n,startHour:a.startHour,endHour:a.endHour,allDay:!1});const s=null==c?void 0:c(n,a.startHour,a.endHour);C(a,"blue","New Event",s),a.sourceElement=null,a.indicatorVisible=!0,document.addEventListener("mousemove",A),document.addEventListener("mouseup",L)}},[H,l,d,h,c,C,A,L,y,x]),Z=t.useCallback((e,t)=>{var n,r,a;if(e.preventDefault(),e.stopPropagation(),y.current.active)return;const o=y.current,s=e.currentTarget;if(H){p.current={x:e.clientX-s.getBoundingClientRect().left,y:e.clientY-s.getBoundingClientRect().top};const n=Fc(t.start),r=Fc(t.end);let a=1;if(t.allDay&&t.start&&t.end){const e=new Date(n);e.setHours(0,0,0,0);const t=new Date(r);t.setHours(0,0,0,0),a=Math.floor((t.getTime()-e.getTime())/864e5+1),a=Math.max(1,a)}const i=s.getAttribute("data-segment-days"),l=i?parseInt(i,10):a;o.active=!0,o.mode="move",o.eventId=t.id,o.startX=e.clientX,o.startY=e.clientY,o.targetDate=n,o.originalDate=n,o.originalEvent=Object.assign({},t),o.lastUpdateTime=Date.now(),o.originalStartDate=n,o.originalEndDate=r,o.eventDurationDays=a,o.currentSegmentDays=l,x({active:!0,mode:"move",eventId:t.id,targetDate:n,startDate:n,endDate:r}),o.sourceElement=s,o.indicatorVisible=!1,document.addEventListener("mousemove",A),document.addEventListener("mouseup",L)}else{const i=M(e.clientY),l=t._segmentInfo,d=!!l,c=d?l.dayIndex:null!==(n=t.day)&&void 0!==n?n:0,u=d?l.startHour:Gc(t.start);let h=0;if(t.allDay&&t.start&&t.end){const e=Fc(t.start);e.setHours(0,0,0,0);const n=Fc(t.end);n.setHours(0,0,0,0),h=Math.floor((n.getTime()-e.getTime())/864e5)}const g=Fc(t.start);if(Object.assign(o,{active:!0,mode:"move",eventId:t.id,startX:e.clientX,startY:e.clientY,dayIndex:c,startHour:u,endHour:d?l.endHour:iu(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:Gc(t.start),originalEndHour:iu(t),allDay:t.allDay||!1,eventDate:g,eventDurationDays:h,startDragDayIndex:c}),!t.allDay){o.hourOffset=u-i;const e=Fc(t.start),n=Fc(t.end).getTime()-e.getTime();o.duration=n/36e5}x({active:!0,mode:"move",eventId:t.id,dayIndex:null!==(a=t.day)&&void 0!==a?a:0,startHour:Gc(t.start),endHour:iu(t),allDay:t.allDay||!1}),C(o,t.calendarId,t.title,null,s),o.sourceElement=s,o.indicatorVisible=!0,document.addEventListener("mousemove",$),document.addEventListener("mouseup",Y)}},[H,C,L,A,$,Y,M,y,p,x]),F=t.useCallback((e,t,n)=>{var r,a,o,s,i;if(e.preventDefault(),e.stopPropagation(),y.current.active)return;const l=y.current;if(H){const r=Fc(t.start),a=Fc(t.start),o=Fc(t.end),s={hour:a.getHours(),minute:a.getMinutes(),second:a.getSeconds()},i={hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds()};l.active=!0,l.mode="resize",l.eventId=t.id,l.startX=e.clientX,l.startY=e.clientY,l.targetDate="left"===n?a:o,l.originalDate=r,l.originalEvent=Object.assign({},t),l.lastUpdateTime=Date.now(),l.resizeDirection=n,l.originalStartDate=a,l.originalEndDate=o,l.originalStartTime=s,l.originalEndTime=i,x({active:!0,mode:"resize",eventId:t.id,targetDate:"left"===n?a:o,startDate:a,endDate:o})}else if(t.allDay){const o=Fc(t.start),s=Fc(t.end);l.active=!0,l.mode="resize",l.eventId=t.id,l.startX=e.clientX,l.startY=e.clientY,l.allDay=!0,l.resizeDirection=n,l.originalStartDate=o,l.originalEndDate=s,l.originalEvent=Object.assign({},t),l.dayIndex=null!==(r=t.day)&&void 0!==r?r:0,x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(a=t.day)&&void 0!==a?a:0,startHour:0,endHour:0,allDay:!0})}else{const r=M(e.clientY);Object.assign(l,{active:!0,mode:"resize",eventId:t.id,startX:e.clientX,startY:e.clientY,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:Gc(t.start),endHour:iu(t),originalDay:null!==(s=t.day)&&void 0!==s?s:0,originalStartHour:Gc(t.start),originalEndHour:iu(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:r,hourOffset:"top"===n?Gc(t.start)-r:iu(t)-r,allDay:!1}),x({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(i=t.day)&&void 0!==i?i:0,startHour:Gc(t.start),endHour:iu(t),allDay:!1})}document.addEventListener("mousemove",A),document.addEventListener("mouseup",L)},[H,A,L,M,y,x]);return{handleDragMove:A,handleDragEnd:L,handleCreateStart:V,handleMoveStart:Z,handleResizeStart:F,handleUniversalDragMove:$,handleUniversalDragEnd:Y}})({options:n,common:s,state:i,manager:l}),c=(e=>{const{options:n,common:r,state:a,manager:o,handleDragMove:s,handleDragEnd:i}=e,{viewType:l,currentWeekStart:d}=n,{dragRef:c,setDragState:u}=a,{createDragIndicator:h}=o,{pixelYToHour:g,getColumnDayIndex:f}=r,m=l===exports.ViewType.MONTH,v=t.useCallback((e,t)=>{if(m)return;if(e.preventDefault(),e.stopPropagation(),c.current.active)return;const n=c.current;Object.assign(n,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:t,allDay:!0,eventDate:d?yu(d,t):new Date}),u({active:!0,mode:"create",eventId:null,dayIndex:t,startHour:0,endHour:0,allDay:!0}),h(n,"blue","New All-day Event"),document.addEventListener("mousemove",s),document.addEventListener("mouseup",i)},[m,h,d,i,s,c,u]);return{handleCreateAllDayEvent:v,pixelYToHour:g,getColumnDayIndex:f}})({options:n,common:s,state:i,manager:l,handleDragMove:d.handleDragMove,handleDragEnd:d.handleDragEnd}),u=(e=>{const{common:t}=e,{daysDifference:n,addDaysToDate:r,getTargetDateFromPosition:a}=t;return{daysDifference:n,addDaysToDate:r,getTargetDateFromPosition:a}})({common:s});return Object.assign({createDragIndicator:l.createDragIndicator,updateDragIndicator:l.updateDragIndicator,removeDragIndicator:l.removeDragIndicator,handleCreateStart:d.handleCreateStart,handleMoveStart:d.handleMoveStart,handleResizeStart:d.handleResizeStart,dragState:i.dragState,isDragging:i.dragState.active},a?{daysDifference:u.daysDifference,addDaysToDate:u.addDaysToDate,getTargetDateFromPosition:u.getTargetDateFromPosition}:{handleCreateAllDayEvent:c.handleCreateAllDayEvent,pixelYToHour:c.pixelYToHour,getColumnDayIndex:c.getColumnDayIndex})};function Mh(e,t){const n=e.getPlugin("drag"),r=Eh(t);if(!n)return y.warn("Drag plugin is not installed. Drag functionality will be disabled. Add createDragPlugin() to your plugins array to enable dragging."),{handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:()=>{},handleCreateAllDayEvent:void 0,dragState:r.dragState,isDragging:!1};const a=n.getConfig(),o=n.isViewSupported(t.viewType);return o||console.info(`ℹ️ Drag functionality is not supported for ${t.viewType} view.`),{handleMoveStart:o&&a.enableDrag?r.handleMoveStart:()=>{},handleCreateStart:o&&a.enableCreate?r.handleCreateStart:()=>{},handleResizeStart:o&&a.enableResize?r.handleResizeStart:()=>{},handleCreateAllDayEvent:o&&a.enableAllDayCreate?r.handleCreateAllDayEvent:void 0,dragState:r.dragState,isDragging:!!o&&r.isDragging}}const kh=({handlePreviousMonth:e,handleToday:t,handleNextMonth:a})=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{className:"calendar-nav-button group relative inline-flex items-center justify-center w-8 h-8 rounded-lg 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 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",onClick:e,"aria-label":"Previous month",children:n.jsx(r.ChevronLeft,{className:"h-4 w-4 transition-transform group-hover:scale-110"})}),n.jsx("button",{className:"calendar-today-button inline-flex items-center justify-center px-4 py-[5px] text-sm font-medium rounded-lg 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 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 min-w-[70px]",onClick:t,children:"Today"}),n.jsx("button",{className:"calendar-nav-button group relative inline-flex items-center justify-center w-8 h-8 rounded-lg 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 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",onClick:a,"aria-label":"Next month",children:n.jsx(r.ChevronRight,{className:"h-4 w-4 transition-transform group-hover:scale-110"})})]}),Th={[exports.ViewType.DAY]:"Day",[exports.ViewType.WEEK]:"Week",[exports.ViewType.MONTH]:"Month",[exports.ViewType.YEAR]:"Year"},jh=()=>n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-transform duration-200",children:n.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Sh=({calendar:e,mode:r="buttons"})=>{const[a,o]=t.useState(!1),s=t.useRef(null),i=Array.from(e.state.views.keys()),l=e.state.currentView;return t.useEffect(()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),"select"===r?n.jsxs("div",{className:"relative inline-block",ref:s,children:[n.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 px-3 py-1 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 transition-all duration-200 shadow-sm min-w-[120px] justify-between","aria-expanded":a,"aria-haspopup":"listbox",children:[n.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:Th[l]}),n.jsx("span",{className:"text-gray-500 dark:text-gray-400 transition-transform duration-200 "+(a?"rotate-180":""),children:n.jsx(jh,{})})]}),a&&n.jsx("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-[120px] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:n.jsx("div",{className:"py-1",role:"listbox",children:i.map(t=>n.jsx("button",{onClick:()=>{e.changeView(t),o(!1)},className:"w-full text-left px-3 py-2 text-sm transition-colors duration-150 "+(l===t?"bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:Th[t]},t))})}),n.jsx("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}):n.jsx("div",{className:"inline-flex items-center gap-1 p-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:i.map(t=>n.jsx("button",{className:"px-4 py-1.5 text-sm font-medium rounded-md transition-all duration-200 "+(l===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>e.changeView(t),children:Th[t]},t))})},Nh=({calendar:e,viewType:t,currentDate:r,onPrevious:a,onNext:o,onToday:s,customTitle:i,customSubtitle:l,showTodayBox:d,switcherMode:c="buttons",stickyYear:u,stickyYearOffset:h=0,nextYear:g,nextYearOffset:f=0})=>{const m=void 0!==d?d:"day"!==t,v="buttons"===c,y=i||(()=>{switch(t){case"day":return r.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return r.toLocaleDateString("en-US",{month:"long",year:"numeric"});case"year":return r.getFullYear().toString();default:return""}})(),p="day"===t?l||("day"===t?r.toLocaleDateString("en-US",{weekday:"long"}):null):null;return"day"===t?n.jsxs("div",{className:D,style:{position:"relative"},children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:`${w} text-gray-900 dark:text-white`,children:y}),p&&n.jsx("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:p})]}),v&&n.jsx("div",{className:"absolute -translate-x-1/2",style:{left:"calc(5 / 7 * 100% + 0.5px)"},children:n.jsx(Sh,{mode:c,calendar:e})}),!v&&n.jsx("div",{className:"flex items-center gap-2",children:m&&a&&o&&s&&n.jsx(kh,{handlePreviousMonth:a,handleNextMonth:o,handleToday:s})})]}):n.jsxs("div",{className:D,style:{position:"relative"},children:[n.jsx("div",{children:"year"===t&&u?n.jsxs("div",{style:{position:"relative",overflow:"hidden"},children:[n.jsx("h1",{className:w,style:{position:"absolute",top:0,left:0,transform:`translateY(-${h}px)`,willChange:"transform"},children:u}),g&&n.jsx("h1",{className:w,style:{position:"absolute",top:0,left:0,transform:`translateY(${f}px)`,willChange:"transform"},children:g})]}):n.jsx("h1",{className:w,children:y})}),v&&n.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:n.jsx(Sh,{mode:c,calendar:e})}),(m||!v)&&a&&o&&s&&n.jsxs("div",{className:"flex items-center gap-2",children:[!v&&n.jsx(Sh,{mode:c,calendar:e}),m&&n.jsx(kh,{handlePreviousMonth:a,handleNextMonth:o,handleToday:s})]})]})};function Ih(e){const{app:n,onEventCreated:r}=e,a=t.useCallback(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]),o=t.useCallback((e,t,a,o)=>{e.preventDefault();const s=e.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const e=JSON.parse(s);let i,l,d=!1;o?(i=Pc.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:0,minute:0}),l=Pc.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:23,minute:59,second:59}),d=!0):void 0!==a?(i=Pc.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:a,minute:0}),l=i.add({hours:1})):(i=Pc.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:9,minute:0}),l=i.add({hours:1}));const c={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:`New ${e.calendarName} Event`,description:"",start:i,end:l,calendarId:e.calendarId,allDay:d};return n.addEvent(c),null==r||r(c),c}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]);return{handleDrop:o,handleDragOver:a}}const Hh=({app:e,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const i=e.getCurrentDate(),l=e.getEvents(),[d,c]=t.useState(new Date),[u,h]=t.useState(null),[g,f]=t.useState(null),[m,v]=t.useState(null),{HOUR_HEIGHT:y,FIRST_HOUR:p,LAST_HOUR:x,TIME_COLUMN_WIDTH:b,ALL_DAY_HEIGHT:H}=xh,O=t.useRef(null),R=t.useMemo(()=>(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})(i),[i]),P=t.useMemo(()=>l.filter(e=>{const t=Fc(e.start);t.setHours(0,0,0,0);const n=new Date(i);return n.setHours(0,0,0,0),t.getTime()===n.getTime()}).map(e=>{const t=Fc(e.start),n=Math.floor((t.getTime()-R.getTime())/864e5),r=Math.max(0,Math.min(6,n));return Object.assign(Object.assign({},e),{day:r})}),[l,i,R]),$=t.useMemo(()=>ph.calculateDayEventLayouts(P,{viewType:"day"}),[P]),{handleMoveStart:Y,handleCreateStart:G,handleResizeStart:X,handleCreateAllDayEvent:J,dragState:K,isDragging:Q}=Mh(e,{calendarRef:o,allDayRowRef:O,viewType:exports.ViewType.DAY,onEventsUpdate:t=>{const n=t(P),r=new Set(n.map(e=>e.id)),a=P.filter(e=>!r.has(e.id)),o=new Set(P.map(e=>e.id)),s=n.filter(e=>!o.has(e.id)),i=n.filter(e=>{if(!o.has(e.id))return!1;const t=P.find(t=>t.id===e.id);return t&&(Fc(t.start).getTime()!==Fc(e.start).getTime()||Fc(t.end).getTime()!==Fc(e.end).getTime()||t.day!==e.day||Gc(t.start)!==Gc(e.start)||Gc(t.end)!==Gc(e.end)||t.title!==e.title)});a.forEach(t=>e.deleteEvent(t.id)),s.forEach(t=>e.addEvent(t)),i.forEach(t=>e.updateEvent(t.id,t))},onEventCreate:t=>{e.addEvent(t)},onEventEdit:()=>{},currentWeekStart:R,events:P,calculateNewEventLayout:(e,t,n)=>{const r=new Date(i),a=new Date(i);r.setHours(Math.floor(t),t%1*60,0,0),a.setHours(Math.floor(n),n%1*60,0,0);const o={id:"-1",title:"Temp",day:e,start:Lc(r),end:Lc(a),calendarId:"blue",allDay:!1},s=[...P.filter(e=>!e.allDay),o];return ph.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null},calculateDragLayout:(e,t,n,r)=>{const a=P.map(a=>{if(a.id!==e.id)return a;const o=Fc(a.start),s=Xc(o,n),i=Xc(o,r),l=Lc(s),d=Lc(i);return Object.assign(Object.assign({},a),{day:t,start:l,end:d})}),o=a.filter(e=>!e.allDay);if(0===o.length)return null;return ph.calculateDayEventLayouts(o,{viewType:"day"}).get(e.id)||null}}),{handleDrop:ee,handleDragOver:te}=Ih({app:e,onEventCreated:e=>{v(e.id)}}),ne=t=>{e.updateEvent(t.id,t)},re=t=>{e.deleteEvent(t)},ae=Array.from({length:24},(e,t)=>({hour:t+p,label:au(t+p)})),oe=(()=>{const t=e.getCurrentDate().getFullYear(),n=e.getCurrentDate().getMonth(),r=new Date(t,n,1),a=new Date(t,n+1,0),o=[];for(let e=(0===r.getDay()?6:r.getDay()-1)-1;e>=0;e--){const r=new Date(t,n,-e);o.push({date:r.getDate(),isCurrentMonth:!1,isToday:!1,isSelected:!1,fullDate:r})}for(let e=1;e<=a.getDate();e++){const r=new Date(t,n,e),a=r.toDateString()===(new Date).toDateString(),s=r.toDateString()===i.toDateString();o.push({date:e,isCurrentMonth:!0,isToday:a,isSelected:s,fullDate:r})}const s=42-o.length;for(let e=1;e<=s;e++){const r=new Date(t,n+1,e);o.push({date:e,isCurrentMonth:!1,isToday:!1,isSelected:!1,fullDate:r})}return o})(),se=t.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(i);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[i]);return t.useEffect(()=>{const e=setInterval(()=>c(new Date),6e4);return()=>clearInterval(e)},[]),n.jsxs("div",{className:"flex h-full bg-gray-50 dark:bg-gray-800",children:[n.jsx("div",{className:`flex-none ${"buttons"===s?"":"md:w-[60%]"} w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,children:n.jsxs("div",{className:`relative ${_} h-full`,children:[n.jsx(Nh,{calendar:e,viewType:exports.ViewType.DAY,currentDate:i,switcherMode:s,customSubtitle:d.toLocaleDateString("en-US",{weekday:"long"})}),n.jsxs("div",{className:N,ref:O,children:[n.jsx("div",{className:I,children:"all-day"}),n.jsx("div",{className:"flex flex-1 relative",children:n.jsx("div",{className:"w-full relative",style:{minHeight:`${H}px`},onDoubleClick:e=>{const t=Math.floor((i.getTime()-R.getTime())/864e5);null==J||J(e,t)},onDragOver:te,onDrop:e=>{ee(e,i,void 0,!0)},children:P.filter(e=>e.allDay).map(e=>n.jsx(dh,{event:e,isAllDay:!0,isDayView:!0,allDayHeight:H,calendarRef:o,isBeingDragged:Q&&(null==K?void 0:K.eventId)===e.id&&"move"===(null==K?void 0:K.mode),hourHeight:y,firstHour:p,onMoveStart:Y,onEventUpdate:ne,onEventDelete:re,newlyCreatedEventId:m,onDetailPanelOpen:()=>v(null),detailPanelEventId:g,onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a},e.id))})})]}),n.jsx("div",{className:C,style:{position:"relative"},children:n.jsxs("div",{className:"relative flex",children:[se&&(()=>{const e=d,t=e.getHours()+e.getMinutes()/60;if(t<p||t>x)return null;const r=(t-p)*y;return n.jsxs("div",{className:j,style:{top:`${r}px`,width:"100%",height:0,zIndex:20},children:[n.jsxs("div",{className:"flex items-center",style:{width:`${b}px`},children:[n.jsx("div",{className:"relative w-full flex items-center"}),n.jsx("div",{className:S,children:au(t)})]}),n.jsx("div",{className:"flex-1 flex items-center",children:n.jsx("div",{className:"h-0.5 w-full bg-red-600 relative"})})]})})(),n.jsx("div",{className:E,children:ae.map((e,t)=>n.jsx("div",{className:M,children:n.jsx("div",{className:k,children:0===t?"":e.label})},t))}),n.jsxs("div",{className:"flex-grow relative",children:[ae.map((e,t)=>n.jsx("div",{className:T,onDoubleClick:e=>{var t,n,r,a;const s=Math.floor((i.getTime()-R.getTime())/864e5),l=null===(n=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!l)return;const d=e.clientY-l.top+(null===(a=null===(r=o.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.scrollTop)||0;G(e,s,p+d/y)},onDragOver:te,onDrop:e=>{var t,n,r,a;const s=null===(n=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const l=e.clientY-s.top+(null===(a=null===(r=o.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.scrollTop)||0,d=Math.floor(p+l/y);ee(e,i,d)}},t)),n.jsx("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 relative",children:n.jsx("div",{className:"absolute -top-2.5 -left-9 text-[12px] text-gray-500 dark:text-gray-400",children:"00.00"})}),n.jsx("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:P.filter(e=>!e.allDay).map(e=>{const t=$.get(e.id);return n.jsx(dh,{event:e,layout:t,isDayView:!0,calendarRef:o,isBeingDragged:Q&&(null==K?void 0:K.eventId)===e.id&&"move"===(null==K?void 0:K.mode),hourHeight:y,firstHour:p,onMoveStart:Y,onResizeStart:X,onEventUpdate:ne,onEventDelete:re,newlyCreatedEventId:m,onDetailPanelOpen:()=>v(null),detailPanelEventId:g,onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a},e.id)})})]})]})})]})}),n.jsx("div",{className:`flex-none ${"buttons"===s?"":"md:w-[40%]"} w-[30%] bg-white dark:bg-gray-900`,children:n.jsxs("div",{className:`${_} h-full`,children:[n.jsx("div",{className:"px-2 border-b border-gray-200 dark:border-gray-700",children:n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n.jsx("div",{className:D,style:{position:"relative"},children:n.jsx("div",{children:n.jsx("h1",{className:w,children:" "})})}),"select"===s?n.jsx(Sh,{mode:s,calendar:e}):null,n.jsx(kh,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),n.jsxs("div",{className:A,children:[lu.map(e=>n.jsx("div",{className:L,children:e.charAt(0)},e)),oe.map((t,r)=>n.jsx("button",{className:`\n ${V}\n ${t.isCurrentMonth?Z:F}\n ${t.isToday?z:""}\n ${t.isSelected&&!t.isToday?B:""}\n `,onClick:()=>{return n=t.fullDate,void e.setCurrentDate(n);var n},children:t.date},r))]})]})}),n.jsxs("div",{className:"flex-1 p-4 overflow-y-auto",children:[n.jsx("h3",{className:"text-lg font-semibold mb-3",children:i.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})}),0===P.length?n.jsx("p",{className:`text-gray-500 dark:text-gray-400 ${q}`,children:"No events for this day"}):n.jsx("div",{className:"space-y-2",children:P.map(e=>n.jsxs("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==u?void 0:u.id)===e.id?"bg-blue-50 dark:bg-blue-900/30 border-blue-500":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:nu(e.calendarId||"blue")},onClick:()=>h(e),children:[n.jsx("div",{className:`font-medium ${q}`,children:e.title}),!e.allDay&&n.jsxs("div",{className:`${U} ${W}`,children:[au(Gc(e.start))," -"," ",au(iu(e))]}),e.allDay&&n.jsx("div",{className:`${U} ${W}`,children:"All day"})]},e.id))})]})]})})]})},Oh={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},Rh=({app:e,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const i=e.getCurrentDate(),l=e.getEvents(),d=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},c=t.useMemo(()=>d(i),[i]),[u,h]=t.useState(new Date),[g,f]=t.useState(null),[m,v]=t.useState(null),[y,p]=t.useState(null),{HOUR_HEIGHT:x,FIRST_HOUR:b,LAST_HOUR:D,TIME_COLUMN_WIDTH:w,ALL_DAY_HEIGHT:H}=xh,O=t.useRef(null),R=t.useMemo(()=>{const e=new Date(c);e.setDate(c.getDate()+6),e.setHours(23,59,59,999);return l.filter(t=>{const n=Fc(t.start);n.setHours(0,0,0,0);const r=Fc(t.end);return r.setHours(23,59,59,999),r>=c&&n<=e}).map(e=>{const t=Fc(e.start),n=Math.floor((t.getTime()-c.getTime())/864e5),r=Math.max(0,Math.min(6,n));return Object.assign(Object.assign({},e),{day:r})})},[l,c]),P=t.useMemo(()=>ah(R,c),[R,c]),$=t.useMemo(()=>{const e=P.filter(e=>e.event.allDay);e.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const t=[];return e.forEach(e=>{let n=0,r=!1;for(;!r;){t.some(t=>t.row===n&&!(e.endDayIndex<t.startDayIndex||e.startDayIndex>t.endDayIndex))?n++:r=!0}t.push(Object.assign(Object.assign({},e),{row:n}))}),t},[P]),Y=t.useMemo(()=>{if(0===$.length)return H;const e=Math.max(...$.map(e=>e.row));return H+e*H},[$,H]),A=t.useMemo(()=>{const e=new Map;for(let t=0;t<7;t++){const n=[];R.forEach(e=>{if(e.allDay)return;const r=oh(e,c);if(r.length>0){const a=r.find(e=>e.dayIndex===t);if(a){const r=a.endHour>=24?23.99:a.endHour,o=Object.assign(Object.assign({},e),{start:Lc(Xc(yu(c,t),a.startHour)),end:Lc(Xc(yu(c,t),r)),day:t});n.push(o)}}else e.day===t&&n.push(e)});const r=ph.calculateDayEventLayouts(n,{viewType:"week"});e.set(t,r)}return e},[R,c]),{handleMoveStart:L,handleCreateStart:V,handleResizeStart:Z,handleCreateAllDayEvent:F,dragState:z,isDragging:B}=Mh(e,{calendarRef:o,allDayRowRef:O,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const r=t(R),a=new Set(r.map(e=>e.id)),o=R.filter(e=>!a.has(e.id)),s=new Set(R.map(e=>e.id)),i=r.filter(e=>!s.has(e.id)),l=r.filter(e=>{if(!s.has(e.id))return!1;const t=R.find(t=>t.id===e.id);return t&&(Fc(t.start).getTime()!==Fc(e.start).getTime()||Fc(t.end).getTime()!==Fc(e.end).getTime()||t.day!==e.day||Gc(t.start)!==Gc(e.start)||Gc(t.end)!==Gc(e.end)||t.title!==e.title)});o.forEach(t=>e.deleteEvent(t.id)),i.forEach(t=>e.addEvent(t)),l.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{e.addEvent(t)},onEventEdit:()=>{},currentWeekStart:c,events:R,calculateNewEventLayout:(e,t,n)=>{const r=new Date,a=new Date;r.setHours(Math.floor(t),t%1*60,0,0),a.setHours(Math.floor(n),n%1*60,0,0);const o={id:"-1",title:"Temp",day:e,start:Lc(r),end:Lc(a),calendarId:"blue",allDay:!1},s=[...R.filter(t=>t.day===e&&!t.allDay),o];return ph.calculateDayEventLayouts(s,{viewType:"week"}).get("-1")||null},calculateDragLayout:(e,t,n,r)=>{const a=R.map(a=>{if(a.id!==e.id)return a;const o=Fc(a.start),s=Xc(o,n),i=Xc(o,r),l=Lc(s),d=Lc(i);return Object.assign(Object.assign({},a),{day:t,start:l,end:d})}),o=a.filter(e=>e.day===t&&!e.allDay);if(0===o.length)return null;return ph.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null}}),{handleDrop:W,handleDragOver:U}=Ih({app:e,onEventCreated:e=>{p(e.id)}}),q=t.useMemo(()=>["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],[]),_=Array.from({length:24},(e,t)=>({hour:t+b,label:au(t+b)})),G=t.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),q.map((t,n)=>{const r=new Date(c);r.setDate(c.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString("default",{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[c,q]),X=t=>{e.updateEvent(t.id,t)},J=t=>{e.deleteEvent(t)},K=t.useMemo(()=>{const e=new Date,t=d(e);return c.getTime()===t.getTime()},[c]);return t.useEffect(()=>{const e=setInterval(()=>h(new Date),6e4);return()=>clearInterval(e)},[]),n.jsxs("div",{className:"relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full",children:[n.jsx(Nh,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:i,switcherMode:s,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),n.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[n.jsx("div",{className:"w-20 p-2"}),q.map((e,t)=>n.jsxs("div",{className:"flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1",children:[n.jsx("div",{className:"inline-flex items-center justify-center text-sm h-6 w-6 mt-1 mr-1",children:e}),n.jsx("div",{className:"inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1",children:G[t].date})]},t))]}),n.jsxs("div",{className:N,ref:O,children:[n.jsx("div",{className:I,children:"all-day"}),n.jsxs("div",{className:"flex flex-1 relative",style:{minHeight:`${Y}px`},children:[q.map((e,t)=>{const r=new Date(c);return r.setDate(c.getDate()+t),n.jsx("div",{className:"flex-1 border-r border-gray-200 dark:border-gray-700 relative",style:{minHeight:`${Y}px`},onDoubleClick:e=>null==F?void 0:F(e,t),onDragOver:U,onDrop:e=>{W(e,r,void 0,!0)}},`allday-${t}`)}),n.jsx("div",{className:"absolute inset-0 pointer-events-none",children:$.map(e=>n.jsx(dh,{event:e.event,segment:e,segmentIndex:e.row,isAllDay:!0,isMultiDay:!0,allDayHeight:H,calendarRef:o,isBeingDragged:B&&(null==z?void 0:z.eventId)===e.event.id&&"move"===(null==z?void 0:z.mode),hourHeight:x,firstHour:b,onMoveStart:L,onResizeStart:Z,onEventUpdate:X,onEventDelete:J,newlyCreatedEventId:y,onDetailPanelOpen:()=>p(null),selectedEventId:m,detailPanelEventId:g,onEventSelect:e=>v(e),onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a},e.id))})]})]}),n.jsx("div",{className:C,style:{position:"relative"},children:n.jsxs("div",{className:"relative flex",children:[K&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<b||t>D)return null;const r=e.getDay(),a=0===r?6:r-1,o=(t-b)*x;return n.jsxs("div",{className:j,style:{top:`${o}px`,width:"100%",height:0,zIndex:20},children:[n.jsxs("div",{className:"flex items-center",style:{width:`${w}px`},children:[n.jsx("div",{className:"relative w-full flex items-center"}),n.jsx("div",{className:S,children:au(t)})]}),n.jsx("div",{className:"flex flex-1",children:q.map((e,t)=>n.jsx("div",{className:"flex-1 flex items-center",children:n.jsx("div",{className:"h-0.5 w-full relative "+(t===a?"bg-red-600 dark:bg-red-500":"bg-red-100 dark:bg-red-900/30"),style:{zIndex:9999},children:t===a&&0!==a&&n.jsx("div",{className:"absolute w-2 h-2 bg-red-700 dark:bg-red-500 rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),n.jsx("div",{className:E,children:_.map((e,t)=>n.jsx("div",{className:M,children:n.jsx("div",{className:k,children:0===t?"":e.label})},t))}),n.jsxs("div",{className:"flex-grow relative",children:[_.map((e,t)=>n.jsx("div",{className:T,children:q.map((r,a)=>{const o=new Date(c);return o.setDate(c.getDate()+a),n.jsx("div",{className:"flex-1 relative border-r border-gray-200 dark:border-gray-700",onDoubleClick:t=>{V(t,a,e.hour)},onDragOver:U,onDrop:t=>{W(t,o,e.hour)}},`${t}-${a}`)})},t)),n.jsxs("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 flex relative",children:[n.jsx("div",{className:"absolute -top-2.5 -left-9 text-[12px] text-gray-500 dark:text-gray-400",children:"00.00"}),q.map((e,t)=>n.jsx("div",{className:"flex-1 relative border-r border-gray-200 dark:border-gray-700"},`24-${t}`))]}),q.map((e,t)=>{const s=vu(t,R),i=[];return s.forEach(e=>{const n=oh(e,c);if(n.length>0){const r=n.find(e=>e.dayIndex===t);r&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},r),{dayIndex:t})})}else i.push({event:e})}),R.forEach(e=>{if(e.allDay||e.day===t)return;const n=oh(e,c).find(e=>e.dayIndex===t);n&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:t})})}),n.jsx("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*t}%)`,width:100/7+"%",height:"100%"},children:i.map(({event:e,segmentInfo:s})=>{const i=A.get(t),l=null==i?void 0:i.get(e.id);return n.jsx(dh,{event:e,layout:l,calendarRef:o,isBeingDragged:B&&(null==z?void 0:z.eventId)===e.id&&"move"===(null==z?void 0:z.mode),hourHeight:x,firstHour:b,onMoveStart:L,onResizeStart:Z,onEventUpdate:X,onEventDelete:J,newlyCreatedEventId:y,onDetailPanelOpen:()=>p(null),selectedEventId:m,detailPanelEventId:g,onEventSelect:e=>v(e),onDetailPanelToggle:e=>f(e),customDetailPanelContent:r,customEventDetailDialog:a,multiDaySegmentInfo:s},s?`${e.id}-seg-${t}`:e.id)})},`events-day-${t}`)})]})]})})]})},Ph={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},$h=1,Yh=30,Ah=1970,Lh=2100,Vh=16,Zh=150,Fh=1200,zh=850,Bh=680;class Wh{static trackScrollEvent(e=0){this.metrics.scrollEvents++,this.metrics.totalScrollDistance+=Math.abs(e),this.metrics.avgScrollDelta=this.metrics.totalScrollDistance/this.metrics.scrollEvents}static trackRenderTime(e){this.metrics.renderTime.push(e),e>16.67&&this.metrics.frameDrops++,this.metrics.renderTime.length>100&&this.metrics.renderTime.shift()}static trackCacheHit(){this.metrics.cacheHits++}static trackCacheMiss(){this.metrics.cacheMisses++}static getMetrics(){const e=this.metrics.renderTime.length>0?this.metrics.renderTime.reduce((e,t)=>e+t,0)/this.metrics.renderTime.length:0,t=this.metrics.cacheHits+this.metrics.cacheMisses>0?this.metrics.cacheHits/(this.metrics.cacheHits+this.metrics.cacheMisses)*100:0,n=Date.now()-this.metrics.startTime,r=e>0?1e3/e:0;return{scrollEvents:this.metrics.scrollEvents,avgRenderTime:Math.round(100*e)/100,cacheHitRate:Math.round(100*t)/100,uptime:Math.round(n/1e3),scrollEventsPerSecond:Math.round(this.metrics.scrollEvents/(n/1e3)*100)/100,estimatedFPS:Math.round(r),frameDrops:this.metrics.frameDrops,avgScrollDelta:Math.round(100*this.metrics.avgScrollDelta)/100}}static reset(){this.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0}}}Wh.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};class Uh{constructor(e=Yh){this.cache=new Map,this.accessOrder=[],this.maxSize=e}get(e){const t=this.cache.get(e);if(t)return Wh.trackCacheHit(),this.updateAccessOrder(e),t;Wh.trackCacheMiss()}set(e,t){if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(e,t),this.updateAccessOrder(e)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}getHitRate(){return Wh.getMetrics().cacheHitRate}clear(){this.cache.clear(),this.accessOrder=[]}}const qh=()=>{const[e,n]=t.useState({yearHeight:Bh,screenSize:"desktop"});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth;n(e<640?{yearHeight:Fh,screenSize:"mobile"}:e<900?{yearHeight:zh,screenSize:"tablet"}:{yearHeight:Bh,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},_h=({currentDate:e,yearHeight:n,onCurrentYearChange:r})=>{const a=e.getFullYear(),o=(a-Ah)*n,[s,i]=t.useState(o),[l,d]=t.useState(600),[c,u]=t.useState(a),[h,g]=t.useState(!1),f=t.useRef(document.createElement("div")),m=t.useRef(null),v=t.useRef(0),y=t.useRef(0),p=t.useMemo(()=>{const e=performance.now(),t=Lh-Ah+1,r=t*n,a=Math.floor(s/n),o=Math.min(t-1,Math.ceil((s+l)/n)),i=Math.max(0,a-$h),d=Math.min(t-1,o+$h),c=[];for(let e=i;e<=d;e++)c.push({index:e,year:Ah+e,top:e*n,height:n});const u=performance.now()-e;return Wh.trackRenderTime(u),{totalHeight:r,visibleItems:c}},[s,l,n]),x=t.useCallback(e=>{const t=performance.now();if(t-v.current<Vh)return;v.current=t;const a=e.currentTarget.scrollTop,o=Math.abs(a-y.current);y.current=a,Wh.trackScrollEvent(o),requestAnimationFrame(()=>{i(a);const e=a,t=Math.floor(Ah+e/n);t!==c&&t>=Ah&&t<=Lh&&(u(t),null==r||r(t))}),g(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{g(!1)},Zh)},[l,c,n,r]);t.useEffect(()=>{const e=f.current;if(!e)return;e.scrollTop=o;const t=new ResizeObserver(([e])=>{d(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[o]);const b=t.useCallback((e,t=!0)=>{if(!f.current)return;const r=(e-Ah)*n-l/2+n/2;f.current.scrollTo({top:Math.max(0,r),behavior:t?"smooth":"auto"})},[n,l]),D=t.useCallback(()=>{const e=Math.max(Ah,c-1);u(e),b(e)},[c,b]),w=t.useCallback(()=>{const e=Math.min(Lh,c+1);u(e),b(e)},[c,b]),C=t.useCallback(()=>{const e=(new Date).getFullYear();u(e),b(e)},[b]);return t.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),{scrollTop:s,containerHeight:l,currentYear:c,isScrolling:h,virtualData:p,scrollElementRef:f,handleScroll:x,scrollToYear:b,handlePreviousYear:D,handleNextYear:w,handleToday:C,setScrollTop:i,setContainerHeight:d,setCurrentYear:u,setIsScrolling:g}},Gh=()=>{const[e,n]=t.useState({weekHeight:u,screenSize:"desktop",weeksPerView:6});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth,t=window.innerHeight-150,r=Math.max(80,Math.floor(t/6)),a=e<768?{weekHeight:Math.max(d,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(c,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(u,r),screenSize:"desktop",weeksPerView:6};n(a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Xh=({currentDate:e,weekHeight:n,onCurrentMonthChange:r,initialWeeksToLoad:a=104})=>{const o=t.useRef(null),s=t.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),mu(t,a)},[e,a]),d=t.useMemo(()=>{const t=new Date(e);t.setDate(1),t.setHours(0,0,0,0);const r=s.findIndex(e=>e.days.some(e=>e.date.toDateString()===t.toDateString()));return r>0?r*n:0},[s,e,n]),[c,u]=t.useState(d),[g,f]=t.useState(600),[m,v]=t.useState(du[e.getMonth()]),[y,p]=t.useState(e.getFullYear()),[x,b]=t.useState(!1),[D,w]=t.useState(s),[C,E]=t.useState(!1),M=t.useRef(!1),[k,T]=t.useState(!1),j=t.useRef(e),S=t.useRef(null),N=t.useRef(null),I=t.useRef(new h),H=t.useRef(0),O=t.useRef(0),R=t.useRef(!1),P=t.useCallback(e=>{e&&(S.current=e)},[]),$=t.useCallback(e=>{let t=I.current.get(e);return t||(t=gu(e),I.current.set(e,t)),t},[]),Y=t.useCallback((e,t=26)=>{R.current||(R.current=!0,setTimeout(()=>{try{if("future"===e){const e=D[D.length-1],n=[];for(let r=1;r<=t;r++){const t=new Date(e.startDate);t.setDate(t.getDate()+7*r),n.push($(t))}w(e=>[...e,...n])}else{const e=D[0],r=[];for(let n=t;n>=1;n--){const t=new Date(e.startDate);t.setDate(t.getDate()-7*n),r.push($(t))}const a=r.length*n;w(e=>[...r,...e]),requestAnimationFrame(()=>{u(e=>e+a),S.current&&(S.current.scrollTop+=a)})}}finally{setTimeout(()=>{R.current=!1},200)}},0))},[D,$,n]),A=t.useMemo(()=>{const e=D.length*n,t=Math.floor(c/n);let r=Math.max(0,t);r=Math.min(r,Math.max(0,D.length-6));const a=Math.min(D.length-1,r+6-1),o=Math.max(0,r-15),s=Math.min(D.length-1,a+15),i=[];for(let e=o;e<=s;e++)i.push({index:e,weekData:D[e],top:e*n,height:n});return{totalHeight:e,visibleItems:i,displayStartIndex:r}},[c,g,n,D]),L=t.useCallback(e=>{if(C||x||0===e.length||!k)return;const t=c+g/2,n=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!n)return;const a={};n.weekData.days.forEach(e=>{const t=`${du[e.month]}-${e.year}`;a[t]=(a[t]||0)+1});let s="",i=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,r]=e.split("-");s=n,i=parseInt(r)}}),s&&i&&(o.current?s===o.current.month&&i===o.current.year&&(o.current=null,s===m&&i===y||(v(s),p(i),null==r||r(s,i))):s===m&&i===y||(v(s),p(i),null==r||r(s,i)))},[g,m,y,C,x,r,c,k]),V=t.useCallback(e=>{const t=performance.now();if(t-H.current<i)return;H.current=t;const r=e.currentTarget,a=r.scrollTop;O.current=a,u(a),C||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=r;a+t>e-10*n&&!R.current&&Y("future",26),a<10*n&&!R.current&&Y("past",26)}),b(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{b(!1)},l)},[n,Y,C]),Z=t.useCallback((e,t=!0)=>{if(!S.current)return;E(!0),M.current=!0;const r=()=>{setTimeout(()=>{E(!1),M.current=!1},t?500:200)},a=D.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*n;return S.current.scrollTo({top:e,behavior:t?"smooth":"auto"}),void r()}const o=e.getDay(),s=0===o?6:o-1,i=new Date(e);i.setDate(e.getDate()-s),i.setHours(0,0,0,0);const l=D[0],d=D[D.length-1];let c=0,h=!1,g=!1;i<l.startDate?(c=Math.ceil((l.startDate.getTime()-i.getTime())/6048e5),h=!0):i>d.startDate&&(c=Math.ceil((i.getTime()-d.startDate.getTime())/6048e5),g=!0);const f=Math.min(c+10,52);if(h){const a=[];for(let e=f;e>=1;e--){const t=new Date(l.startDate);t.setDate(t.getDate()-7*e),a.push($(t))}const o=a.length*n;w(e=>[...a,...e]),requestAnimationFrame(()=>{const s=[...a,...D].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(S.current&&-1!==s){const e=s*n;S.current.scrollTop+=o,u(e=>e+o),setTimeout(()=>{S.current&&S.current.scrollTo({top:e,behavior:t?"smooth":"auto"})},50)}r()})}else if(g){const a=[];for(let e=1;e<=f;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push($(t))}w(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...D,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(S.current&&-1!==o){const e=o*n;S.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}r()})}else r()},[D,n,$]),F=t.useCallback(()=>{const e="January"===m?11:du.indexOf(m)-1,t=new Date("January"===m?y-1:y,e,1);Z(t)},[m,y,Z]),z=t.useCallback(()=>{const e="December"===m?0:du.indexOf(m)+1,t=new Date("December"===m?y+1:y,e,1);Z(t)},[m,y,Z]),B=t.useCallback(()=>{const e=new Date,t=du[e.getMonth()],a=e.getFullYear(),s=new Date(a,e.getMonth(),1);o.current={month:t,year:a},v(t),p(a),null==r||r(t,a);const i=D.findIndex(e=>e.days.some(e=>e.date.toDateString()===s.toDateString()));if(-1!==i){const e=i*n,t=S.current;t&&(E(!0),M.current=!0,requestAnimationFrame(()=>{u(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{M.current=!1,E(!1)},200))})}))}else E(!0),M.current=!0,requestAnimationFrame(()=>{Z(s,!0),setTimeout(()=>{M.current=!1,E(!1)},200)})},[D,n,r,Z]);return t.useEffect(()=>{L(A.visibleItems)},[A.visibleItems,L]),t.useEffect(()=>{const t=j.current,n=t.getMonth(),a=t.getFullYear(),s=e.getMonth(),i=e.getFullYear();if(n!==s||a!==i){const e=new Date(i,s,1),t=du[s];o.current={month:t,year:i},v(t),p(i),null==r||r(t,i),Z(e,!0)}j.current=e},[e,r,Z]),t.useEffect(()=>{const e=S.current;if(!e)return;const t=new ResizeObserver(([e])=>{f(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),t.useEffect(()=>{const e=S.current;e&&!k&&requestAnimationFrame(()=>{e&&d>0?(e.scrollTop=d,T(!0)):e&&T(!0)})},[k,d]),t.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]),{scrollTop:c,containerHeight:g,currentMonth:m,currentYear:y,isScrolling:x,virtualData:A,scrollElementRef:S,handleScroll:V,scrollToDate:Z,handlePreviousMonth:F,handleNextMonth:z,handleToday:B,setScrollTop:u,setContainerHeight:f,setCurrentMonth:v,setCurrentYear:p,setIsScrolling:b,cache:I.current,scrollElementRefCallback:P,weeksData:D}},Jh=t.memo(({currentMonth:e,currentYear:r,newlyCreatedEventId:a,isScrolling:o,isDragging:s,item:i,weekHeight:l,events:d,dragState:c,calendarRef:u,onEventUpdate:h,onEventDelete:g,onMoveStart:f,onCreateStart:m,onResizeStart:v,onDetailPanelOpen:p,onMoreEventsClick:x,onChangeView:b,onSelectDate:D,selectedEventId:w,onEventSelect:C,detailPanelEventId:E,onDetailPanelToggle:M,customDetailPanelContent:k,customEventDetailDialog:T,onCalendarDrop:j,onCalendarDragOver:S})=>{const[N,I]=t.useState(!1),H=t.useRef(null),O=t.useMemo(()=>(e=>{const t=e-33;if(t<=0)return 0;const n=Math.floor(t/17),r=Math.max(0,Math.min(4,n));return r===n&&t-17*r<20?Math.max(0,r-1):r})(l),[l]);t.useEffect(()=>o?(I(!0),H.current&&(clearTimeout(H.current),H.current=null),()=>{H.current&&(clearTimeout(H.current),H.current=null)}):N?(H.current=setTimeout(()=>{I(!1),H.current=null},100),()=>{H.current&&(clearTimeout(H.current),H.current=null)}):void 0,[o,N]);const{weekData:R}=i,P=R.days.find(e=>1===e.day),$=`${l}px`,Y=t.useMemo(()=>ah(d,R.startDate),[d,R.startDate]),A=t.useMemo(()=>(e=>{const t=[];return e.forEach(e=>{if(!e.start||!e.end)return void y.warn("Event missing start or end date:",e);const n=Fc(e.start),r=Fc(e.end),a=new Date(n);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);let s=new Date(o);if(!e.allDay&&0===r.getHours()&&0===r.getMinutes()&&0===r.getSeconds()){const e=r.getTime()-n.getTime();e>0&&e<864e5&&(s=new Date(o),s.setDate(s.getDate()-1))}const i=a.toDateString()!==s.toDateString();if(!i||e.allDay)if(i&&e.allDay){const a=new Date(n);for(;a<=r;){const n=Pc.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()});t.push(Object.assign(Object.assign({},e),{start:n,end:n,day:a.getDay()})),a.setDate(a.getDate()+1)}}else t.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:n.getDay()}))}),t})(d),[d]),L=t.useMemo(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,r=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==r?r-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,r=!1;for(;!r;)n.some(n=>{var r;const a=Math.abs((null!==(r=n.yPosition)&&void 0!==r?r:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return a&&o})?t+=16:r=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const r=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);r[n]||(r[n]=[]),r[n].push(e)}),r.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),r})(Y),[Y]),V=t.useMemo(()=>{const e=Array(7).fill(0);return L.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[L]),Z=t.useMemo(()=>Math.max(0,17*L.length),[L]),F=(t,o)=>{var i;const l=t.month===du.indexOf(e)&&t.year===r;var d;const y=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:Gc(e.start)-Gc(t.start)))((d=t.date,A.filter(e=>{if(!e.start||!e.end)return Fc(e.start).toDateString()===d.toDateString();const t=Fc(e.start),n=Fc(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===d.toDateString()}return t.toDateString()===d.toDateString()||n.toDateString()===d.toDateString()}))),N=y.slice(0,O),I=y.length-N.length,H=I>0,R=[],P=null!==(i=V[o])&&void 0!==i?i:0;for(let e=0;e<P;e++)R.push(n.jsx("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));return N.forEach((e,t)=>{const r=L.flat().find(t=>t.originalEventId===e.id);e.allDay&&r||R.push(n.jsx(dh,{event:e,isAllDay:!!e.allDay,isMonthView:!0,calendarRef:u,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:g,onMoveStart:f,onResizeStart:v,isBeingDragged:s&&c.eventId===e.id&&"move"===c.mode,newlyCreatedEventId:a,onDetailPanelOpen:p,selectedEventId:w,onEventSelect:C,detailPanelEventId:E,onDetailPanelToggle:M,customDetailPanelContent:k,customEventDetailDialog:T},`${e.id}-${e.day}-${Gc(e.start)}-${t}`))}),n.jsxs("div",{className:`\n relative flex flex-col border-r border-gray-200 dark:border-gray-700 last:border-r-0\n ${l?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,style:{height:$},"data-date":(Y=t.date,`${Y.getFullYear()}-${String(Y.getMonth()+1).padStart(2,"0")}-${String(Y.getDate()).padStart(2,"0")}`),onDoubleClick:e=>m(e,t.date),onDragOver:S,onDrop:e=>null==j?void 0:j(e,t.date),children:[n.jsxs("div",{className:"flex items-start justify-between p-2 pb-1 relative z-20",children:[n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("span",{className:`\n inline-flex items-center justify-center h-5 w-5 rounded-full text-sm font-medium\n ${t.isToday?"bg-blue-500 text-white":l?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:t.day}),1===t.day&&n.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 ml-1",children:t.shortMonthName})]})]}),n.jsxs("div",{className:"flex-1 overflow-hidden px-1",children:[R,H&&n.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:e=>{e.stopPropagation(),x?x(t.date):(null==D||D(t.date),null==b||b(exports.ViewType.DAY))},children:["+",I," more"]})]})]},`day-${t.date.getTime()}`);var Y};return n.jsxs("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:$},children:[P&&n.jsx("div",{className:`\n absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${N?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},children:n.jsxs("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:[P.monthName," ",P.year]})}),n.jsx("div",{className:"h-full flex flex-col",children:n.jsxs("div",{className:"calendar-week relative h-full",children:[n.jsx("div",{className:"grid grid-cols-7 h-full",children:R.days.map((e,t)=>F(e,t))}),L.length>0&&n.jsx("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${Z}px`,zIndex:10},children:L.map((e,t)=>n.jsx("div",{className:"absolute inset-0",children:e.map(e=>n.jsx(dh,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:u,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:g,onMoveStart:f,onResizeStart:v,isBeingDragged:s&&c.eventId===e.event.id&&"move"===c.mode,isBeingResized:s&&c.eventId===e.event.id&&"resize"===c.mode,newlyCreatedEventId:a,onDetailPanelOpen:p,selectedEventId:w,onEventSelect:C,detailPanelEventId:E,onDetailPanelToggle:M,customDetailPanelContent:k,customEventDetailDialog:T},e.id))},`layer-${t}`))})]})})]})});Jh.displayName="WeekComponent";const Kh=({app:e,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const i=e.getCurrentDate(),l=e.getEvents(),d=t.useRef(null),c=t.useMemo(()=>{const e=d.current;return e&&e.length===l.length&&e.every((e,t)=>e===l[t])?e:(d.current=l,l)},[l]),u=t.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),r=0===n?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t},n=(t,n)=>{const r=e.get(t);r?r.push(n):e.set(t,[n])};return c.forEach(e=>{if(!e.start)return;const r=Fc(e.start),a=e.end?Fc(e.end):r,o=new Date(r);o.setHours(0,0,0,0);const s=new Date(a);s.setHours(0,0,0,0);let i=new Date(s);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||i.setDate(i.getDate()-1)}i<o&&(i=new Date(o));const l=t(o),d=t(i);let c=l.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},[c]),{screenSize:h}=Gh(),[g,f]=t.useState(()=>{if("undefined"!=typeof window){const e=150,t=window.innerHeight-e;return Math.max(80,Math.floor(t/6))}return 119}),[m,v]=t.useState(!1),y=t.useRef(g),p=t.useRef([]),[x,b]=t.useState(null),[D,w]=t.useState(null),[C,E]=t.useState(null),M=t.useMemo(()=>{const e=i.getDay(),t=i.getDate()-e+(0===e?-6:1),n=new Date(i);return n.setDate(t),n.setHours(0,0,0,0),n},[i]),{handleMoveStart:k,handleCreateStart:T,handleResizeStart:j,dragState:S,isDragging:N}=Mh(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n)=>{const r=t(c),a=new Set(r.map(e=>e.id)),o=c.filter(e=>!a.has(e.id)),s=new Set(c.map(e=>e.id)),i=r.filter(e=>!s.has(e.id)),l=r.filter(e=>{if(!s.has(e.id))return!1;const t=c.find(t=>t.id===e.id);return t&&(Fc(t.start).getTime()!==Fc(e.start).getTime()||Fc(t.end).getTime()!==Fc(e.end).getTime()||t.day!==e.day||Gc(t.start)!==Gc(e.start)||Gc(t.end)!==Gc(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});o.forEach(t=>e.deleteEvent(t.id)),i.forEach(t=>e.addEvent(t)),l.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{b(e.id)},currentWeekStart:M,events:c}),{handleDrop:I,handleDragOver:H}=Ih({app:e,onEventCreated:e=>{b(e.id)}}),{currentMonth:O,currentYear:R,isScrolling:P,virtualData:$,scrollElementRef:Y,handleScroll:A,handlePreviousMonth:L,handleNextMonth:V,handleToday:Z,setScrollTop:F}=Xh({currentDate:i,weekHeight:g,onCurrentMonthChange:(t,n)=>{const r=du.indexOf(t);r>=0&&e.setVisibleMonth(new Date(n,r,1))},initialWeeksToLoad:156}),z=t.useRef(0),[B,W]=t.useState(0),U=t.useMemo(()=>B-6*g,[B,g]),{visibleWeeks:q,startIndex:_}=t.useMemo(()=>{const{visibleItems:e,displayStartIndex:t}=$,n=e.findIndex(e=>e.index===t);if(-1===n)return p.current.length>0?{visibleWeeks:p.current,startIndex:z.current}:{visibleWeeks:[],startIndex:t};const r=e.slice(n,n+8);return r.length>=6&&(p.current=r,z.current=t),{visibleWeeks:r,startIndex:t}},[$]),G=t.useMemo(()=>_*g,[_,g]),X=t.useMemo(()=>{const e=$.totalHeight,t=_*g+16*g+U;return Math.max(0,e-t)},[$.totalHeight,_,g,U]);t.useEffect(()=>{const e=Y.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(W(t),!m&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==y.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/y.current)*n;e.scrollTop=r,F(r)}}f(n),y.current=n,requestAnimationFrame(()=>{v(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[Y,m,F]);const J=t=>{e.updateEvent(t.id,t)},K=t=>{e.deleteEvent(t)},Q=t=>{e.changeView(t)};return n.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900",children:[n.jsx(Nh,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:i,customTitle:`${O} ${R}`,onPrevious:L,onNext:V,onToday:Z,switcherMode:s}),n.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:n.jsx("div",{className:"grid grid-cols-7 px-2",children:lu.map((e,t)=>n.jsx("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2",children:e},t))})}),n.jsxs("div",{ref:Y,className:"flex-1 overflow-auto will-change-scroll",style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:m?"visible":"hidden"},onScroll:A,children:[n.jsx("div",{style:{height:G}}),q.map((t,s)=>{var i;const l=null!==(i=u.get(t.weekData.startDate.getTime()))&&void 0!==i?i:[],d=5===s?Object.assign(Object.assign({},t),{height:t.height+U}):t;return n.jsx(Jh,{item:d,weekHeight:g,currentMonth:O,currentYear:R,screenSize:h,isScrolling:P,calendarRef:o,events:l,onEventUpdate:J,onEventDelete:K,onMoveStart:k,onCreateStart:T,onResizeStart:j,isDragging:N,dragState:S,newlyCreatedEventId:x,onDetailPanelOpen:()=>b(null),onChangeView:Q,onSelectDate:e.selectDate,selectedEventId:D,onEventSelect:w,detailPanelEventId:C,onDetailPanelToggle:E,customDetailPanelContent:r,customEventDetailDialog:a,onCalendarDrop:I,onCalendarDragOver:H},`week-${t.weekData.startDate.getTime()}`)}),n.jsx("div",{style:{height:X}})]})]})},Qh={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[exports.ViewType.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[exports.ViewType.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}},eg=({app:e,switcherMode:r="buttons"})=>{const a=e.getCurrentDate(),{yearHeight:o,screenSize:s}=qh(),[i,l]=t.useState(!1);t.useRef(0),t.useRef(0),t.useRef(!1);const[d,c]=t.useState({stickyOffset:0,nextOffset:0,showNext:!1}),u=t.useRef(new Uh),h=t.useRef(new Date),{currentYear:g,isScrolling:f,virtualData:m,scrollElementRef:v,handleScroll:y,scrollToYear:p,handlePreviousYear:x,handleNextYear:b,handleToday:D}=_h({currentDate:a,yearHeight:o}),w=t.useCallback((e,t)=>{const n=new Date(e,t,1),r=0===n.getDay()?6:n.getDay()-1,o=[],s=h.current,i=a;for(let n=0;n<42;n++){const a=new Date(e,t,n-r+1),l=a.getDate(),d=a.getMonth()===t;o.push({date:l,isCurrentMonth:d,isToday:d&&a.toDateString()===s.toDateString(),isSelected:d&&a.toDateString()===i.toDateString(),fullDate:a})}return{year:e,month:t,monthName:du[t],days:o}},[a]),C=t.useCallback(e=>{let t=u.current.get(e);if(!t){const n=[];for(let t=0;t<12;t++)n.push(w(e,t));t={year:e,months:n},u.current.set(e,t)}return t},[w]),E=t.useCallback(()=>{e.goToToday(),D()},[e,D]);t.useEffect(()=>{const e=e=>{if(!e.repeat)switch(e.key){case"ArrowUp":e.preventDefault(),x();break;case"ArrowDown":e.preventDefault(),b();break;case"Home":e.preventDefault(),E();break;case"PageUp":e.preventDefault();const t=Math.max(Ah,g-5);p(t);break;case"PageDown":e.preventDefault();const n=Math.min(Lh,g+5);p(n);break;case"F12":e.shiftKey&&(e.preventDefault(),l(!i))}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,x,b,E,p,i]);const M=t.memo(({monthData:t})=>n.jsxs("div",{className:"h-fit",children:[n.jsx("div",{className:`text-red-600 font-semibold mb-2 sm:mb-3 ${"mobile"===s?"text-xs":"text-xs sm:text-sm"} `,children:t.monthName}),n.jsx("div",{className:"grid grid-cols-7 gap-0 mb-1 sm:mb-2",children:["M","T","W","T","F","S","S"].map((e,t)=>n.jsx("div",{className:"text-center text-gray-500 py-0.5 text-xs w-10",children:e},t))}),n.jsx("div",{className:"grid grid-cols-7 gap-0",children:t.days.map((t,r)=>n.jsx("button",{className:`\n text-center rounded-sm transition-colors\n w-10\n ${"mobile"===s?"text-xs py-1 min-h-[18px]":"text-xs py-1 sm:py-1.5 min-h-[20px] sm:min-h-[26px]"}\n ${t.isCurrentMonth?"text-gray-900 font-medium hover:bg-gray-100 active:bg-gray-200":"text-gray-300 cursor-not-allowed"}\n ${t.isToday?"bg-red-500 text-white hover:bg-red-600 font-bold shadow-sm ring-2 ring-red-200":""}\n ${t.isSelected&&!t.isToday?"bg-red-100 text-red-600 font-semibold ring-1 ring-red-300":""}\n `,onClick:()=>t.isCurrentMonth&&e.selectDate(t.fullDate),disabled:!t.isCurrentMonth,children:t.date},r))})]})),k=t.memo(({item:e})=>{const t=C(e.year);return n.jsx("div",{className:"absolute w-full",style:{top:e.top,height:e.height,contain:"layout style paint"},children:n.jsxs("div",{className:"px-4 bg-white",children:[n.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 py-3 px-2",children:e.year}),n.jsx("div",{className:"mx-auto px-2",children:n.jsx("div",{className:"grid "+("mobile"===s?"grid-cols-2 grid-rows-6 gap-2":"tablet"===s?"grid-cols-3 grid-rows-4 gap-3":"grid-cols-4 grid-rows-3 gap-4"),children:t.months.map(e=>n.jsx(M,{monthData:e},`${e.year}-${e.month}`))})})]})})});return M.displayName="MonthComponent",k.displayName="VirtualYearItem",n.jsxs("div",{className:"relative flex flex-col bg-white shadow-md w-full overflow-hidden h-full",children:[n.jsx(Nh,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:a,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday(),switcherMode:r,stickyYear:g,stickyYearOffset:0,nextYear:null,nextYearOffset:0}),f&&n.jsx("div",{className:"absolute top-24 left-1/2 transform -translate-x-1/2 z-40 bg-white/95 backdrop-blur-sm py-2 px-4 rounded-lg shadow-lg border border-gray-200 transition-all duration-200 pointer-events-none",children:n.jsx("span",{className:"text-xl font-bold text-gray-900",children:g})}),n.jsx("div",{ref:v,className:"flex-1 overflow-auto bg-gray-50",onScroll:y,style:{contain:"layout style paint",scrollBehavior:"auto"},children:n.jsx("div",{className:"relative",style:{height:m.totalHeight},children:m.visibleItems.map(e=>n.jsx(k,{item:e},e.year))})}),n.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 opacity-30 hover:opacity-70 transition-opacity",children:n.jsxs("div",{className:"bg-gray-800 text-white text-xs px-2 py-1 rounded",children:[Math.round((g-Ah)/(Lh-Ah)*100),"%"]})})]})},tg={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},ng={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};exports.CalendarApp=b,exports.CalendarEvent=dh,exports.CalendarRegistry=f,exports.ColorPicker=Eu,exports.DayFlowCalendar=({calendar:e,className:r,style:a,customDetailPanelContent:o,customEventDetailDialog:s,meta:i})=>{var l,d;const c=e.app,u=c.getCurrentView(),h=u.component,g=c.getSidebarConfig(),f=null!==(l=null==g?void 0:g.enabled)&&void 0!==l&&l,[m,v]=t.useState(0),[y,x]=t.useState(null!==(d=null==g?void 0:g.initialCollapsed)&&void 0!==d&&d),[b,D]=t.useState(()=>c.getTheme());t.useEffect(()=>{var e;x(null!==(e=null==g?void 0:g.initialCollapsed)&&void 0!==e&&e)},[null==g?void 0:g.initialCollapsed]),t.useEffect(()=>{const e=c.subscribeThemeChange(e=>{D(e)});return()=>{e()}},[c]);const w=t.useCallback(e=>{c.setTheme(e)},[c]),C=t.useCallback(()=>{v(e=>e+1)},[]),E=t.useMemo(()=>c.getCalendars(),[c,m]),M=t.useCallback((e,t)=>{c.setCalendarVisibility(e,t),C()},[c,C]),k=t.useCallback(e=>{c.setAllCalendarsVisibility(e),C()},[c,C]),T=t.useRef(null),j=s||(c.getUseEventDetailDialog()?Lu:void 0),S={app:c,config:u.config||{},customDetailPanelContent:o,customEventDetailDialog:j,switcherMode:c.state.switcherMode,calendarRef:T,meta:i},N={app:c,calendars:E,toggleCalendarVisibility:M,toggleAll:k,isCollapsed:y,setCollapsed:x},I=y?"60px":p(null==g?void 0:g.width,"240px");return n.jsx(zu,{initialTheme:b,onThemeChange:w,children:n.jsx("div",{className:`calendar-container ${null!=r?r:""}`,style:Object.assign({height:800},a),children:n.jsxs("div",{className:"flex h-full",children:[f&&n.jsx("aside",{className:"shrink-0",style:{width:I},children:f?g.render?g.render(N):n.jsx(Cu,Object.assign({},N)):null}),n.jsx("div",{className:"flex flex-col flex-1 h-full",ref:T,children:n.jsx("div",{className:"calendar-renderer h-full",children:n.jsx(h,Object.assign({},S))})})]})})})},exports.DefaultEventDetailDialog=Lu,exports.DefaultEventDetailPanel=ih,exports.EventDetailPanelWithContent=lh,exports.EventLayoutCalculator=ph,exports.TIME_STEP=ru,exports.ThemeProvider=zu,exports.ViewHeader=Nh,exports.addDays=_c,exports.buildParseRegExp=Su,exports.calculateDayIndex=xu,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,r,a=!1,o){return th(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))},exports.convertDateEventWithTimeZone=function(e,t,n,r,a,o){return nh(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))},exports.createAllDayEvent=function(e,t,n,r){return th(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))},exports.createDateWithHour=Xc,exports.createDayView=(e={})=>{const n=Object.assign(Object.assign({},Oh),e),r=e=>t.createElement(Wu,{viewType:exports.ViewType.DAY,originalComponent:Hh,app:e.app,config:n,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return r.displayName="DayViewAdapter",{type:exports.ViewType.DAY,component:r,config:n}},exports.createDragPlugin=function(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[exports.ViewType.DAY,exports.ViewType.WEEK,exports.ViewType.MONTH]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{y.log("Drag plugin installed - providing drag capabilities")},api:n}},exports.createEvent=th,exports.createEventWithDate=(e,t)=>{var n,r;const a=yu(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:pu(a,o),end:pu(a,o)})},exports.createEventWithRealDate=(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:pu(a,o),end:pu(a,o)})},exports.createEvents=function(e){return e.map(e=>th(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},ng),e);let n;const r={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=r.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(r.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=a(n.getCurrentDate()),t=bu(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const s=r.getById(e);if(!s)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},s),o);if(t.enableValidation){const e=r.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=a(n.getCurrentDate()),t=bu(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=Fc(t.start);n.setHours(0,0,0,0);const r=new Date(e);return r.setHours(0,0,0,0),n.getTime()===r.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const r=Fc(n.start),a=Fc(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>bu(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function a(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}return{name:"events",config:t,install:e=>{n=e,y.log("Events plugin installed - providing event management services")},api:r}},exports.createMonthView=(e={})=>{const n=Object.assign(Object.assign({},Qh),e),r=e=>t.createElement(Wu,{viewType:exports.ViewType.MONTH,originalComponent:Kh,app:e.app,config:n,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return r.displayName="MonthViewAdapter",{type:exports.ViewType.MONTH,component:r,config:n}},exports.createTemporalWithHour=zc,exports.createTimedEvent=function(e,t,n,r,a){return th(Object.assign({id:e,title:t,start:n,end:r},a))},exports.createTimezoneEvent=nh,exports.createTimezoneEvents=function(e){return e.map(e=>nh(e))},exports.createWeekView=(e={})=>{const n=Object.assign(Object.assign({},Ph),e),r=e=>t.createElement(Wu,{viewType:exports.ViewType.WEEK,originalComponent:Rh,app:e.app,config:n,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return r.displayName="WeekViewAdapter",{type:exports.ViewType.WEEK,component:r,config:n}},exports.createYearView=(e={})=>{const n=Object.assign(Object.assign({},tg),e),r=e=>t.createElement(Wu,{viewType:exports.ViewType.YEAR,originalComponent:eg,app:e.app,config:n,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta});return r.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:r,config:n}},exports.dateToPlainDate=Xu,exports.dateToPlainDateTime=Ju,exports.dateToZonedDateTime=Ku,exports.daysBetween=function(e,t){const n=Ac(e)?e:e.toPlainDate(),r=Ac(t)?t:t.toPlainDate();return n.until(r).days},exports.daysDifference=qc,exports.extractHourFromDate=Gc,exports.extractHourFromTemporal=function(e){return qu(e)?0:e.hour+e.minute/60},exports.formatDate=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}`},exports.formatDateConsistent=Uu,exports.formatEventTimeRange=ou,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=Ou,exports.formatTime=au,exports.generateDayData=hu,exports.generateUniKey=Du,exports.generateWeekData=gu,exports.generateWeekRange=mu,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:r}=uu(e),a=[],o=Math.floor(n/2),s=new Date(r);s.setDate(s.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(s);t.setDate(t.getDate()+7*e),a.push(gu(t))}return a},exports.getAllDayEventsForDay=(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=Fc(t.start);a.setHours(0,0,0,0);const o=Fc(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getCurrentWeekDates=()=>{const e=new Date,t=new Date,n=e.getDay(),r=e.getDate()-n+(0===n?-6:1);return lu.map((n,a)=>{const o=new Date(e);return o.setDate(r+a),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},exports.getDateByDayIndex=yu,exports.getDayIndexByDate=(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)},exports.getEndOfDay=Jc,exports.getEndOfTemporal=Uc,exports.getEventBgColor=Qc,exports.getEventEndHour=iu,exports.getEventTextColor=eu,exports.getEventsForDay=vu,exports.getEventsForWeek=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=Fc(e.start);return r>=t&&r<=n}).map(e=>{const n=xu(Fc(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getLineColor=nu,exports.getMonthYearOfWeek=fu,exports.getPlainDate=function(e){return qu(e)?e:(_u(e),e.toPlainDate())},exports.getSelectedBgColor=tu,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return Wc(e)},exports.getStartOfTemporal=Wc,exports.getTestEvents=function(){const e=new Date,t=e.getDay(),n=new Date(e),r=0===t?-6:1-t;n.setDate(e.getDate()+r),n.setHours(0,0,0,0);const a=[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(e=>{const t=new Date(n);if(t.setDate(n.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:Pc.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:Pc.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const r=Math.floor(e.startHour),a=Math.round(60*(e.startHour-r)),o=Math.floor(e.endHour),s=Math.round(60*(e.endHour-o));return{id:e.id,title:e.title,start:Pc.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:r,minute:a,timeZone:Pc.Now.timeZoneId()}),end:Pc.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:o,minute:s,timeZone:Pc.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}});return a},exports.getWeekRange=uu,exports.getZoneId=Iu,exports.isDate=function(e){return e instanceof Date},exports.isEventInWeek=(e,t)=>{const n=xu(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!Kc(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!Bc(e,t)},exports.isPlainDate=qu,exports.isPlainDateTime=_u,exports.isSameDay=Kc,exports.isSamePlainDate=Bc,exports.isSameTemporal=function(e,t){const n=qu(e)?e:(_u(e),e.toPlainDate()),r=qu(t)?t:(_u(t),t.toPlainDate());return n.equals(r)},exports.isZonedDateTime=Gu,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=Tu,exports.monthNames=du,exports.normalizeCssWidth=p,exports.normalizeToZoned=Hu,exports.now=function(e=Pc.Now.timeZoneId()){return Pc.Now.zonedDateTimeISO(e)},exports.pad=ku,exports.parseTemporalString=Nu,exports.plainDateTimeToDate=function(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)},exports.plainDateToDate=function(e){return new Date(e.year,e.month-1,e.day)},exports.recalculateEventDays=bu,exports.resolveAppliedTheme=Vu,exports.roundToTimeStep=su,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return Gu(e),e.with({hour:n,minute:r,second:0,millisecond:0})},exports.shortMonthNames=cu,exports.temporalToDate=function(e){if(qu(e))return new Date(e.year,e.month-1,e.day);if(_u(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);const t=e.toInstant();return new Date(t.epochMilliseconds)},exports.themeClasses={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-blue-500 dark:focus:ring-blue-400",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-blue-500 dark:focus:border-blue-400 focus:ring-blue-500 dark:focus:ring-blue-400",buttonPrimary:"bg-blue-500 dark:bg-blue-600 text-white hover:bg-blue-600 dark:hover:bg-blue-700",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-200 hover:bg-red-200 dark:hover:bg-red-800",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"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=Pc.Now.timeZoneId()){return Pc.Now.plainDateISO(e)},exports.updateEventDateAndDay=(e,t,n)=>{const r=yu(n,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?Pc.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):Pc.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:Pc.Now.timeZoneId()}),end:e.allDay?Pc.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):Pc.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:Pc.Now.timeZoneId()})})},exports.updateEventWithRealDate=(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:pu(a,o),end:pu(a,o)})},exports.useCalendarApp=function(e){const n=t.useMemo(()=>new b(e),[]),[r,a]=t.useState(n.state.currentView),[o,s]=t.useState(n.state.currentDate),[i,l]=t.useState(n.getEvents()),[,d]=t.useState({}),c=t.useCallback(()=>{d({})},[]);t.useEffect(()=>{const e=n.changeView;n.changeView=t=>{e(t),a(t),c()};const t=n.setCurrentDate;n.setCurrentDate=e=>{t(e),s(new Date(e)),c()};const r=n.addEvent;n.addEvent=e=>{r(e),l([...n.getEvents()]),c()};const o=n.updateEvent;n.updateEvent=(e,t,r)=>{o(e,t,r),l([...n.getEvents()]),c()};const i=n.deleteEvent;n.deleteEvent=e=>{i(e),l([...n.getEvents()]),c()};const d=n.setCalendarVisibility;n.setCalendarVisibility=(e,t)=>{d(e,t),l([...n.getEvents()]),c()};const u=n.setAllCalendarsVisibility;n.setAllCalendarsVisibility=e=>{u(e),l([...n.getEvents()]),c()};const h=n.setVisibleMonth;return n.setVisibleMonth=e=>{h(e),c()},()=>{}},[n,c]),t.useEffect(()=>{a(n.state.currentView),s(n.state.currentDate),l(n.getEvents())},[n]);const u=t.useCallback(e=>{n.changeView(e)},[n]),h=t.useCallback(e=>{n.setCurrentDate(e)},[n]),g=t.useCallback(e=>{n.addEvent(e)},[n]),f=t.useCallback((e,t,r)=>{n.updateEvent(e,t,r)},[n]),m=t.useCallback(e=>{n.deleteEvent(e)},[n]),v=t.useCallback(()=>{n.goToToday()},[n]),y=t.useCallback(()=>{n.goToPrevious()},[n]),p=t.useCallback(()=>{n.goToNext()},[n]),x=t.useCallback(e=>{n.selectDate(e)},[n]),D=t.useCallback((e,t)=>{n.setCalendarVisibility(e,t)},[n]),w=t.useCallback(e=>{n.setAllCalendarsVisibility(e)},[n]);return{app:n,currentView:r,currentDate:o,events:i,changeView:u,setCurrentDate:h,addEvent:g,updateEvent:f,deleteEvent:m,goToToday:v,goToPrevious:y,goToNext:p,selectDate:x,getCalendars:()=>n.getCalendars(),setCalendarVisibility:D,setAllCalendarsVisibility:w,getAllEvents:()=>n.getAllEvents(),setVisibleMonth:e=>n.setVisibleMonth(e),getVisibleMonth:()=>n.getVisibleMonth(),sidebarConfig:n.getSidebarConfig()}},exports.useDrag=Eh,exports.useDragForView=Mh,exports.useResponsiveConfig=qh,exports.useResponsiveMonthConfig=Gh,exports.useTheme=Bu,exports.useVirtualMonthScroll=Xh,exports.useVirtualScroll=_h,exports.weekDays=lu,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=Zc;