@forcecalendar/interface 1.0.19 → 1.0.21

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.
@@ -1,4 +1,4 @@
1
- (function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.ForceCalendarInterface={}))})(this,function(m){"use strict";var ne=Object.defineProperty;var re=(m,v,M)=>v in m?ne(m,v,{enumerable:!0,configurable:!0,writable:!0,value:M}):m[v]=M;var R=(m,v,M)=>re(m,typeof v!="symbol"?v+"":v,M);class v extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._listeners=[],this._state=null,this._props=new Map,this._initialized=!1}connectedCallback(){this._initialized||(this.initialize(),this._initialized=!0),this.mount()}disconnectedCallback(){this.unmount(),this.cleanup()}initialize(){}mount(){this.render()}unmount(){}cleanup(){this._listeners.forEach(({element:e,event:t,handler:s})=>{e.removeEventListener(t,s)}),this._listeners=[]}setState(e){const t=this._state;this._state={...this._state,...e},this.stateChanged(t,this._state),this.render()}getState(){return this._state}stateChanged(e,t){}setProp(e,t){const s=this._props.get(e);this._props.set(e,t),this.propChanged(e,s,t)}getProp(e){return this._props.get(e)}propChanged(e,t,s){}addListener(e,t,s){if(!e||!t||!s){console.warn("addListener called with invalid parameters",{element:e,event:t,handler:s});return}const i=s.bind(this);e.addEventListener(t,i),this._listeners.push({element:e,event:t,handler:i})}emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}getStyles(){return""}getBaseStyles(){return`
1
+ (function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.ForceCalendarInterface={}))})(this,function(m){"use strict";var ne=Object.defineProperty;var ae=(m,v,M)=>v in m?ne(m,v,{enumerable:!0,configurable:!0,writable:!0,value:M}):m[v]=M;var R=(m,v,M)=>ae(m,typeof v!="symbol"?v+"":v,M);class v extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._listeners=[],this._state=null,this._props=new Map,this._initialized=!1}connectedCallback(){this._initialized||(this.initialize(),this._initialized=!0),this.mount()}disconnectedCallback(){this.unmount(),this.cleanup()}initialize(){}mount(){this.render()}unmount(){}cleanup(){this._listeners.forEach(({element:e,event:t,handler:s})=>{e.removeEventListener(t,s)}),this._listeners=[]}setState(e){const t=this._state;this._state={...this._state,...e},this.stateChanged(t,this._state),this.render()}getState(){return this._state}stateChanged(e,t){}setProp(e,t){const s=this._props.get(e);this._props.set(e,t),this.propChanged(e,s,t)}getProp(e){return this._props.get(e)}propChanged(e,t,s){}addListener(e,t,s){if(!e||!t||!s){console.warn("addListener called with invalid parameters",{element:e,event:t,handler:s});return}const i=s.bind(this);e.addEventListener(t,i),this._listeners.push({element:e,event:t,handler:i})}emit(e,t={}){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}getStyles(){return""}getBaseStyles(){return`
2
2
  :host {
3
3
  display: block;
4
4
  box-sizing: border-box;
@@ -12,7 +12,7 @@
12
12
  ${this.getBaseStyles()}
13
13
  ${this.getStyles()}
14
14
  </style>
15
- `,t=this.template();this.shadowRoot.innerHTML=e+t,this.afterRender()}template(){return""}afterRender(){}$(e){return this.shadowRoot.querySelector(e)}$$(e){return this.shadowRoot.querySelectorAll(e)}static get observedAttributes(){return[]}attributeChangedCallback(e,t,s){this.setProp(e,s),this._initialized&&this.render()}}class M{constructor(){this.timezones={UTC:{offset:0,dst:null},GMT:{offset:0,dst:null},"Africa/Abidjan":{offset:0,dst:null},"Africa/Accra":{offset:0,dst:null},"Africa/Addis_Ababa":{offset:180,dst:null},"Africa/Algiers":{offset:60,dst:null},"Africa/Cairo":{offset:120,dst:null},"Africa/Casablanca":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Africa/Johannesburg":{offset:120,dst:null},"Africa/Lagos":{offset:60,dst:null},"Africa/Nairobi":{offset:180,dst:null},"America/Anchorage":{offset:-540,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Argentina/Buenos_Aires":{offset:-180,dst:null},"America/Bogota":{offset:-300,dst:null},"America/Caracas":{offset:-240,dst:null},"America/Chicago":{offset:-360,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Denver":{offset:-420,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Detroit":{offset:-300,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Halifax":{offset:-240,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Los_Angeles":{offset:-480,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Mexico_City":{offset:-360,dst:{start:{month:4,week:1,day:0},end:{month:10,week:-1,day:0},offset:60}},"America/New_York":{offset:-300,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Phoenix":{offset:-420,dst:null},"America/Regina":{offset:-360,dst:null},"America/Santiago":{offset:-180,dst:{start:{month:9,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"America/Sao_Paulo":{offset:-180,dst:{start:{month:10,week:3,day:0},end:{month:2,week:3,day:0},offset:60}},"America/St_Johns":{offset:-210,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Toronto":{offset:-300,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Vancouver":{offset:-480,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"Asia/Baghdad":{offset:180,dst:null},"Asia/Bangkok":{offset:420,dst:null},"Asia/Dubai":{offset:240,dst:null},"Asia/Hong_Kong":{offset:480,dst:null},"Asia/Jakarta":{offset:420,dst:null},"Asia/Jerusalem":{offset:120,dst:{start:{month:3,week:-1,day:5},end:{month:10,week:-1,day:0},offset:60}},"Asia/Karachi":{offset:300,dst:null},"Asia/Kolkata":{offset:330,dst:null},"Asia/Kuala_Lumpur":{offset:480,dst:null},"Asia/Manila":{offset:480,dst:null},"Asia/Seoul":{offset:540,dst:null},"Asia/Shanghai":{offset:480,dst:null},"Asia/Singapore":{offset:480,dst:null},"Asia/Taipei":{offset:480,dst:null},"Asia/Tehran":{offset:210,dst:{start:{month:3,week:4,day:0},end:{month:9,week:4,day:0},offset:60}},"Asia/Tokyo":{offset:540,dst:null},"Atlantic/Azores":{offset:-60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Atlantic/Bermuda":{offset:-240,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"Atlantic/Reykjavik":{offset:0,dst:null},"Australia/Adelaide":{offset:570,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Australia/Brisbane":{offset:600,dst:null},"Australia/Darwin":{offset:570,dst:null},"Australia/Hobart":{offset:600,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Australia/Melbourne":{offset:600,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Australia/Perth":{offset:480,dst:null},"Australia/Sydney":{offset:600,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Europe/Amsterdam":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Athens":{offset:120,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Berlin":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Brussels":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Budapest":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Copenhagen":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Dublin":{offset:0,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Helsinki":{offset:120,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Istanbul":{offset:180,dst:null},"Europe/Kiev":{offset:120,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Lisbon":{offset:0,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/London":{offset:0,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Madrid":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Moscow":{offset:180,dst:null},"Europe/Oslo":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Paris":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Prague":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Rome":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Stockholm":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Vienna":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Warsaw":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Zurich":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Indian/Maldives":{offset:300,dst:null},"Indian/Mauritius":{offset:240,dst:null},"Pacific/Auckland":{offset:720,dst:{start:{month:9,week:-1,day:0},end:{month:4,week:1,day:0},offset:60}},"Pacific/Fiji":{offset:720,dst:{start:{month:11,week:1,day:0},end:{month:1,week:3,day:0},offset:60}},"Pacific/Guam":{offset:600,dst:null},"Pacific/Honolulu":{offset:-600,dst:null},"Pacific/Midway":{offset:-660,dst:null},"Pacific/Noumea":{offset:660,dst:null},"Pacific/Pago_Pago":{offset:-660,dst:null},"Pacific/Port_Moresby":{offset:600,dst:null},"Pacific/Tahiti":{offset:-600,dst:null}},this.aliases={EST:"America/New_York",EDT:"America/New_York",CST:"America/Chicago",CDT:"America/Chicago",MST:"America/Denver",MDT:"America/Denver",PST:"America/Los_Angeles",PDT:"America/Los_Angeles",AKST:"America/Anchorage",AKDT:"America/Anchorage",HST:"Pacific/Honolulu",AST:"America/Halifax",ADT:"America/Halifax",NST:"America/St_Johns",NDT:"America/St_Johns",BST:"Europe/London",IST:"Asia/Kolkata",WET:"Europe/Lisbon",WEST:"Europe/Lisbon",CET:"Europe/Paris",CEST:"Europe/Paris",EET:"Europe/Athens",EEST:"Europe/Athens",MSK:"Europe/Moscow",JST:"Asia/Tokyo",KST:"Asia/Seoul",CST_CN:"Asia/Shanghai",HKT:"Asia/Hong_Kong",SGT:"Asia/Singapore",AEST:"Australia/Sydney",AEDT:"Australia/Sydney",ACST:"Australia/Adelaide",ACDT:"Australia/Adelaide",AWST:"Australia/Perth",NZST:"Pacific/Auckland",NZDT:"Pacific/Auckland","US/Eastern":"America/New_York","US/Central":"America/Chicago","US/Mountain":"America/Denver","US/Pacific":"America/Los_Angeles","US/Alaska":"America/Anchorage","US/Hawaii":"Pacific/Honolulu","Canada/Eastern":"America/Toronto","Canada/Central":"America/Regina","Canada/Mountain":"America/Denver","Canada/Pacific":"America/Vancouver","Canada/Atlantic":"America/Halifax","Canada/Newfoundland":"America/St_Johns","Mexico/General":"America/Mexico_City","Brazil/East":"America/Sao_Paulo","Chile/Continental":"America/Santiago",GB:"Europe/London","GB-Eire":"Europe/London",Eire:"Europe/Dublin",Israel:"Asia/Jerusalem",Japan:"Asia/Tokyo",Singapore:"Asia/Singapore",Hongkong:"Asia/Hong_Kong",ROK:"Asia/Seoul",PRC:"Asia/Shanghai","Australia/NSW":"Australia/Sydney","Australia/Victoria":"Australia/Melbourne","Australia/Queensland":"Australia/Brisbane","Australia/South":"Australia/Adelaide","Australia/Tasmania":"Australia/Hobart","Australia/West":"Australia/Perth","Australia/North":"Australia/Darwin",NZ:"Pacific/Auckland"}}getTimezone(e){return this.aliases[e]&&(e=this.aliases[e]),this.timezones[e]||null}getAllTimezones(){return Object.keys(this.timezones)}isValidTimezone(e){return this.aliases[e]!==void 0||this.timezones[e]!==void 0}resolveAlias(e){return this.aliases[e]||e}getTimezonesByOffset(e){return Object.entries(this.timezones).filter(([t,s])=>s.offset===e).map(([t,s])=>t)}getCommonTimezones(){return{Americas:["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Mexico_City","America/Sao_Paulo"],Europe:["Europe/London","Europe/Paris","Europe/Berlin","Europe/Moscow","Europe/Rome","Europe/Madrid","Europe/Amsterdam"],Asia:["Asia/Tokyo","Asia/Shanghai","Asia/Hong_Kong","Asia/Singapore","Asia/Kolkata","Asia/Dubai","Asia/Seoul"],"Australia/Pacific":["Australia/Sydney","Australia/Melbourne","Australia/Brisbane","Australia/Perth","Pacific/Auckland","Pacific/Honolulu"],Africa:["Africa/Cairo","Africa/Lagos","Africa/Johannesburg","Africa/Nairobi"]}}}let A=null;class I{static getInstance(){return A||(A=new I),A}static _resetInstance(){A&&A.clearCache(),A=null}constructor(){this.database=new M,this.offsetCache=new Map,this.dstCache=new Map,this.maxCacheSize=1e3,this.cacheHits=0,this.cacheMisses=0}convertTimezone(e,t,s){if(!e)return null;if(t===s)return new Date(e);const i=this.getTimezoneOffset(e,t),r=(this.getTimezoneOffset(e,s)-i)*60*1e3;return new Date(e.getTime()+r)}toUTC(e,t){if(!e)return null;if(t==="UTC")return new Date(e);const s=this.getTimezoneOffset(e,t);return new Date(e.getTime()+s*60*1e3)}fromUTC(e,t){if(!e)return null;if(t==="UTC")return new Date(e);const s=this.getTimezoneOffset(e,t);return new Date(e.getTime()-s*60*1e3)}getTimezoneOffset(e,t){t=this.database.resolveAlias(t);const s=`${t}_${e.getFullYear()}_${e.getMonth()}_${e.getDate()}`;if(this.offsetCache.has(s))return this.cacheHits++,this._manageCacheSize(),this.offsetCache.get(s);if(this.cacheMisses++,typeof Intl<"u"&&Intl.DateTimeFormat)try{const a=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),c=(new Date(a.find(l=>l.type==="year").value,a.find(l=>l.type==="month").value-1,a.find(l=>l.type==="day").value,a.find(l=>l.type==="hour").value,a.find(l=>l.type==="minute").value,a.find(l=>l.type==="second").value).getTime()-e.getTime())/(1e3*60);return this.offsetCache.set(s,-c),this._manageCacheSize(),-c}catch{}const i=this.database.getTimezone(t);if(!i)throw new Error(`Unknown timezone: ${t}`);let n=i.offset;return i.dst&&this.isDST(e,t,i.dst)&&(n+=i.dst.offset),this.offsetCache.set(s,n),this._manageCacheSize(),n}isDST(e,t,s=null){if(!s){const a=this.database.getTimezone(t);if(!a||!a.dst)return!1;s=a.dst}const i=e.getFullYear(),n=this.getNthWeekdayOfMonth(i,s.start.month,s.start.week,s.start.day),r=this.getNthWeekdayOfMonth(i,s.end.month,s.end.week,s.end.day);return n>r?e>=n||e<r:e>=n&&e<r}getNthWeekdayOfMonth(e,t,s,i){const n=new Date(e,t,1),r=n.getDay();let a=i-r;if(a<0&&(a+=7),s>0)n.setDate(1+a+(s-1)*7);else{const o=new Date(e,t+1,0).getDate();n.setDate(o);let l=n.getDay()-i;l<0&&(l+=7),n.setDate(o-l+(s+1)*7)}return n}getCommonTimezones(){const e=new Date;return[{value:"America/New_York",label:"Eastern Time (New York)",region:"Americas"},{value:"America/Chicago",label:"Central Time (Chicago)",region:"Americas"},{value:"America/Denver",label:"Mountain Time (Denver)",region:"Americas"},{value:"America/Phoenix",label:"Mountain Time - Arizona (Phoenix)",region:"Americas"},{value:"America/Los_Angeles",label:"Pacific Time (Los Angeles)",region:"Americas"},{value:"America/Anchorage",label:"Alaska Time (Anchorage)",region:"Americas"},{value:"Pacific/Honolulu",label:"Hawaii Time (Honolulu)",region:"Pacific"},{value:"America/Toronto",label:"Eastern Time (Toronto)",region:"Americas"},{value:"America/Vancouver",label:"Pacific Time (Vancouver)",region:"Americas"},{value:"America/Mexico_City",label:"Central Time (Mexico City)",region:"Americas"},{value:"America/Sao_Paulo",label:"Brasilia Time (São Paulo)",region:"Americas"},{value:"Europe/London",label:"GMT/BST (London)",region:"Europe"},{value:"Europe/Paris",label:"Central European Time (Paris)",region:"Europe"},{value:"Europe/Berlin",label:"Central European Time (Berlin)",region:"Europe"},{value:"Europe/Moscow",label:"Moscow Time",region:"Europe"},{value:"Asia/Dubai",label:"Gulf Time (Dubai)",region:"Asia"},{value:"Asia/Kolkata",label:"India Time (Mumbai)",region:"Asia"},{value:"Asia/Shanghai",label:"China Time (Shanghai)",region:"Asia"},{value:"Asia/Tokyo",label:"Japan Time (Tokyo)",region:"Asia"},{value:"Asia/Seoul",label:"Korea Time (Seoul)",region:"Asia"},{value:"Asia/Singapore",label:"Singapore Time",region:"Asia"},{value:"Australia/Sydney",label:"Australian Eastern Time (Sydney)",region:"Oceania"},{value:"Australia/Melbourne",label:"Australian Eastern Time (Melbourne)",region:"Oceania"},{value:"Pacific/Auckland",label:"New Zealand Time (Auckland)",region:"Oceania"},{value:"UTC",label:"UTC",region:"UTC"}].map(s=>{const i=this.getTimezoneOffset(e,s.value),n=-i/60,r=Math.floor(Math.abs(n)),a=Math.round(Math.abs(n%1)*60),c=`UTC${n>=0?"+":"-"}${r.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;return{...s,offset:c,offsetMinutes:-i}}).sort((s,i)=>s.offsetMinutes-i.offsetMinutes)}formatInTimezone(e,t,s={}){if(!e)return"";const n={...{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:t},...s};try{return new Intl.DateTimeFormat("en-US",n).format(e)}catch{return this.fromUTC(this.toUTC(e,"UTC"),t).toLocaleString("en-US",s)}}getSystemTimezone(){if(typeof Intl<"u"&&Intl.DateTimeFormat)try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}const t=-new Date().getTimezoneOffset()/60;for(const[s,i]of Object.entries(this.database.timezones))if(i.offset/60===t)return s;return"UTC"}parseTimezone(e){if(!e)return"UTC";if(Object.prototype.hasOwnProperty.call(this.database.timezones,e))return e;const t=e.toUpperCase();if(this.database.abbreviations&&Object.prototype.hasOwnProperty.call(this.database.abbreviations,t))return this.database.abbreviations[t];const s=e.match(/^([+-])(\d{2}):?(\d{2})$/);if(s){const i=s[1]==="+"?1:-1,n=parseInt(s[2],10),r=parseInt(s[3],10),a=i*(n+r/60);for(const[o,c]of Object.entries(this.database.timezones))if(c.offset/60===a)return o}return"UTC"}getTimezoneDifference(e,t,s=new Date){const i=this.getTimezoneOffset(s,e);return(this.getTimezoneOffset(s,t)-i)/60}clearCache(){this.offsetCache.clear(),this.dstCache.clear(),this.cacheHits=0,this.cacheMisses=0}isValidTimezone(e){return this.database.isValidTimezone(e)}getCacheStats(){const e=this.cacheHits+this.cacheMisses>0?(this.cacheHits/(this.cacheHits+this.cacheMisses)*100).toFixed(2):0;return{offsetCacheSize:this.offsetCache.size,dstCacheSize:this.dstCache.size,maxCacheSize:this.maxCacheSize,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,hitRate:`${e}%`}}_manageCacheSize(){if(this.offsetCache.size>this.maxCacheSize){const e=Math.floor(this.offsetCache.size/2),t=Array.from(this.offsetCache.keys());for(let s=0;s<e;s++)this.offsetCache.delete(t[s])}if(this.dstCache.size>this.maxCacheSize/2){const e=Math.floor(this.dstCache.size/2),t=Array.from(this.dstCache.keys());for(let s=0;s<e;s++)this.dstCache.delete(t[s])}}}class x{static normalize(e){const t={...e};return t.start&&(t.start=new Date(t.start)),t.end&&(t.end=new Date(t.end)),t.end||(t.end=t.start?new Date(t.start):null),t.allDay&&t.start&&(t.start.setHours(0,0,0,0),t.end&&t.end.setHours(23,59,59,999)),t.id=String(t.id||"").trim(),t.title=String(t.title||"").trim(),t.description=String(t.description||"").trim(),t.location=String(t.location||"").trim(),t.attendees=Array.isArray(t.attendees)?t.attendees:[],t.reminders=Array.isArray(t.reminders)?t.reminders:[],e.category&&!e.categories?t.categories=[e.category]:t.categories?t.categories=Array.isArray(t.categories)?t.categories:[]:t.categories=[],t.attachments=Array.isArray(t.attachments)?t.attachments:[],["confirmed","tentative","cancelled"].includes(t.status)||(t.status="confirmed"),["public","private","confidential"].includes(t.visibility)||(t.visibility="public"),t.color&&!t.backgroundColor&&(t.backgroundColor=t.color),t.color&&!t.borderColor&&(t.borderColor=t.color),t}static validate(e){if(!e.id)throw new Error("Event must have an id");if(!e.title)throw new Error("Event must have a title");if(!e.start)throw new Error("Event must have a start date");if(!(e.start instanceof Date)||isNaN(e.start.getTime()))throw new Error("Invalid start date");if(e.end&&(!(e.end instanceof Date)||isNaN(e.end.getTime())))throw new Error("Invalid end date");if(e.end&&e.start&&e.end<e.start)throw new Error("Event end time cannot be before start time");if(e.recurring&&!e.recurrenceRule)throw new Error("Recurring events must have a recurrence rule");if(e.attendees&&e.attendees.length>0&&e.attendees.forEach((t,s)=>{if(!t.email||!t.name)throw new Error(`Attendee at index ${s} must have email and name`);if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.email))throw new Error(`Invalid email for attendee: ${t.email}`)}),e.reminders&&e.reminders.length>0&&e.reminders.forEach((t,s)=>{if(!t.method||t.minutesBefore==null)throw new Error(`Reminder at index ${s} must have method and minutesBefore`);if(t.minutesBefore<0)throw new Error("Reminder minutesBefore must be non-negative")}),e.timeZone)try{new Intl.DateTimeFormat("en-US",{timeZone:e.timeZone})}catch{throw new Error(`Invalid timezone: ${e.timeZone}`)}}constructor({id:e,title:t,start:s,end:i,allDay:n=!1,description:r="",location:a="",color:o=null,backgroundColor:c=null,borderColor:l=null,textColor:d=null,recurring:h=!1,recurrenceRule:p=null,timeZone:w=null,endTimeZone:D=null,status:$="confirmed",visibility:S="public",organizer:C=null,attendees:_=[],reminders:O=[],category:J,categories:X,attachments:ee=[],conferenceData:te=null,metadata:se={},...ie}){const u=x.normalize({id:e,title:t,start:s,end:i,allDay:n,description:r,location:a,color:o,backgroundColor:c,borderColor:l,textColor:d,recurring:h,recurrenceRule:p,timeZone:w,endTimeZone:D,status:$,visibility:S,organizer:C,attendees:_,reminders:O,category:J,categories:X,attachments:ee,conferenceData:te,metadata:se,...ie});x.validate(u),this.id=u.id,this.title=u.title,this._timezoneManager=I.getInstance(),this.timeZone=u.timeZone||this._timezoneManager.getSystemTimezone(),this.endTimeZone=u.endTimeZone||this.timeZone,this.start=u.start,this.end=u.end,this.startUTC=this._timezoneManager.toUTC(this.start,this.timeZone),this.endUTC=this._timezoneManager.toUTC(this.end,this.endTimeZone),this.allDay=u.allDay,this.description=u.description,this.location=u.location,this.color=u.color,this.backgroundColor=u.backgroundColor,this.borderColor=u.borderColor,this.textColor=u.textColor,this.recurring=u.recurring,this.recurrenceRule=u.recurrenceRule,this._originalTimeZone=u.timeZone||null,this.status=u.status,this.visibility=u.visibility,this.organizer=u.organizer,this.attendees=[...u.attendees],this.reminders=[...u.reminders],this.categories=u.categories?[...u.categories]:[],this.attachments=[...u.attachments],this.conferenceData=u.conferenceData,this.metadata={...u.metadata},this._cache={},this._validateAttendees(),this._validateReminders()}get duration(){return this._cache.duration||(this._cache.duration=this.endUTC.getTime()-this.startUTC.getTime()),this._cache.duration}getStartInTimezone(e){return e===this.timeZone?new Date(this.start):this._timezoneManager.fromUTC(this.startUTC,e)}getEndInTimezone(e){return e===this.endTimeZone?new Date(this.end):this._timezoneManager.fromUTC(this.endUTC,e)}updateTimes(e,t,s){if(s||this.timeZone,this.start=e instanceof Date?e:new Date(e),this.end=t instanceof Date?t:new Date(t),s&&(this.timeZone=s,this.endTimeZone=s),this.startUTC=this._timezoneManager.toUTC(this.start,this.timeZone),this.endUTC=this._timezoneManager.toUTC(this.end,this.endTimeZone),this._cache={},this.endUTC<this.startUTC)throw new Error("Event end time cannot be before start time")}get durationMinutes(){return Math.floor(this.duration/(1e3*60))}get durationHours(){return this.duration/(1e3*60*60)}get isMultiDay(){if(!Object.prototype.hasOwnProperty.call(this._cache,"isMultiDay")){const e=this.start.toDateString(),t=this.end.toDateString();this._cache.isMultiDay=e!==t}return this._cache.isMultiDay}isRecurring(){return this.recurring&&this.recurrenceRule!==null}occursOn(e){e instanceof Date||(e=new Date(e));const t=e.toDateString(),s=this.start.toDateString(),i=this.end.toDateString();if(this.allDay)return e>=new Date(s)&&e<=new Date(i);if(this.isMultiDay){const n=new Date(t),r=new Date(t);return r.setHours(23,59,59,999),this.start<=r&&this.end>=n}return s===t}overlaps(e){if(e instanceof x)return!(this.end<=e.start||this.start>=e.end);if(e&&e.start&&e.end)return!(this.end<=e.start||this.start>=e.end);throw new Error("Parameter must be an Event instance or have start/end properties")}contains(e){return e instanceof Date||(e=new Date(e)),e>=this.start&&e<=this.end}clone(e={}){return new x({id:this.id,title:this.title,start:new Date(this.start),end:new Date(this.end),allDay:this.allDay,description:this.description,location:this.location,color:this.color,backgroundColor:this.backgroundColor,borderColor:this.borderColor,textColor:this.textColor,recurring:this.recurring,recurrenceRule:this.recurrenceRule,timeZone:this.timeZone,status:this.status,visibility:this.visibility,organizer:this.organizer?{...this.organizer}:null,attendees:this.attendees.map(t=>({...t})),reminders:this.reminders.map(t=>({...t})),categories:[...this.categories],attachments:this.attachments.map(t=>({...t})),conferenceData:this.conferenceData?{...this.conferenceData}:null,metadata:{...this.metadata},...e})}toObject(){return{id:this.id,title:this.title,start:this.start.toISOString(),end:this.end.toISOString(),allDay:this.allDay,description:this.description,location:this.location,color:this.color,backgroundColor:this.backgroundColor,borderColor:this.borderColor,textColor:this.textColor,recurring:this.recurring,recurrenceRule:this.recurrenceRule,timeZone:this.timeZone,status:this.status,visibility:this.visibility,organizer:this.organizer,attendees:this.attendees,reminders:this.reminders,categories:this.categories,attachments:this.attachments,conferenceData:this.conferenceData,metadata:{...this.metadata}}}static fromObject(e){return new x(e)}equals(e){return e instanceof x?this.id===e.id&&this.title===e.title&&this.start.getTime()===e.start.getTime()&&this.end.getTime()===e.end.getTime()&&this.allDay===e.allDay&&this.description===e.description&&this.location===e.location&&this.recurring===e.recurring&&this.recurrenceRule===e.recurrenceRule&&this.status===e.status:!1}addAttendee(e){if(!e||!e.email)throw new Error("Attendee must have an email");return this.hasAttendee(e.email)?!1:(e.id||(e.id=`attendee_${Date.now()}_${Math.random().toString(36).substr(2,9)}`),e.responseStatus=e.responseStatus||"needs-action",e.role=e.role||"required",this.attendees.push(e),!0)}removeAttendee(e){const t=this.attendees.findIndex(s=>s.email===e||s.id===e);return t!==-1?(this.attendees.splice(t,1),!0):!1}updateAttendeeResponse(e,t){const s=this.getAttendee(e);return s?(s.responseStatus=t,s.responseTime=new Date,!0):!1}getAttendee(e){return this.attendees.find(t=>t.email===e)||null}hasAttendee(e){return this.attendees.some(t=>t.email===e)}getAttendeesByStatus(e){return this.attendees.filter(t=>t.responseStatus===e)}getAttendeeCounts(){return this.attendees.reduce((e,t)=>{const s=t.responseStatus||"needs-action";return e[s]=(e[s]||0)+1,e},{})}addReminder(e){if(!e||typeof e.minutesBefore!="number")throw new Error("Reminder must have minutesBefore property");return e.id||(e.id=`reminder_${Date.now()}_${Math.random().toString(36).substr(2,9)}`),e.method=e.method||"popup",e.enabled=e.enabled!==!1,this.reminders.some(s=>s.method===e.method&&s.minutesBefore===e.minutesBefore)?!1:(this.reminders.push(e),!0)}removeReminder(e){const t=this.reminders.findIndex(s=>s.id===e);return t!==-1?(this.reminders.splice(t,1),!0):!1}getActiveReminders(){return this.reminders.filter(e=>e.enabled!==!1)}getReminderTriggerTimes(){return this.getActiveReminders().map(e=>{const t=new Date(this.start);return t.setMinutes(t.getMinutes()-e.minutesBefore),t})}addCategory(e){if(!e||typeof e!="string")throw new Error("Category must be a non-empty string");const t=e.trim().toLowerCase();return this.hasCategory(t)?!1:(this.categories.push(t),!0)}removeCategory(e){const t=e.trim().toLowerCase(),s=this.categories.findIndex(i=>i.toLowerCase()===t);return s!==-1?(this.categories.splice(s,1),!0):!1}get category(){return this.categories&&this.categories.length>0?this.categories[0]:null}hasCategory(e){const t=e.trim().toLowerCase();return this.categories.some(s=>s.toLowerCase()===t)}hasAnyCategory(e){return e.some(t=>this.hasCategory(t))}hasAllCategories(e){return e.every(t=>this.hasCategory(t))}_validateAttendees(){for(const e of this.attendees){if(!e.email)throw new Error("All attendees must have an email address");if(e.name||(e.name=e.email),!this._isValidEmail(e.email))throw new Error(`Invalid attendee email: ${e.email}`)}}_validateReminders(){for(const e of this.reminders){if(typeof e.minutesBefore!="number"||e.minutesBefore<0)throw new Error("Reminder minutesBefore must be a positive number");if(!["email","popup","sms"].includes(e.method))throw new Error(`Invalid reminder method: ${e.method}`)}}_isValidEmail(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}get isCancelled(){return this.status==="cancelled"}get isTentative(){return this.status==="tentative"}get isConfirmed(){return this.status==="confirmed"}get isPrivate(){return this.visibility==="private"}get isPublic(){return this.visibility==="public"}get hasAttendees(){return this.attendees.length>0}get hasReminders(){return this.reminders.length>0}get isMeeting(){return this.hasAttendees||this.conferenceData!==null}get isVirtual(){return this.conferenceData!==null}}let f=class b{static startOfDay(e){const t=new Date(e);return t.setHours(0,0,0,0),t}static endOfDay(e){const t=new Date(e);return t.setHours(23,59,59,999),t}static startOfWeek(e,t=0){const s=new Date(e),i=s.getDay(),n=(i<t?7:0)+i-t;return s.setDate(s.getDate()-n),s.setHours(0,0,0,0),s}static endOfWeek(e,t=0){const s=b.startOfWeek(e,t);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}static startOfMonth(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}static endOfMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}static startOfYear(e){return new Date(e.getFullYear(),0,1,0,0,0,0)}static endOfYear(e){return new Date(e.getFullYear(),11,31,23,59,59,999)}static addDays(e,t){const s=new Date(e);return s.setDate(s.getDate()+t),s}static addWeeks(e,t){return b.addDays(e,t*7)}static addMonths(e,t){const s=new Date(e),i=s.getDate();return s.setMonth(s.getMonth()+t),s.getDate()!==i&&s.setDate(0),s}static addYears(e,t){const s=new Date(e);return s.setFullYear(s.getFullYear()+t),s}static getUTCDateString(e){const t=e.getUTCFullYear(),s=String(e.getUTCMonth()+1).padStart(2,"0"),i=String(e.getUTCDate()).padStart(2,"0");return`${t}-${s}-${i}`}static getLocalDateString(e){const t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${s}-${i}`}static isToday(e){const t=new Date;return e.toDateString()===t.toDateString()}static isPast(e){return e<new Date}static isFuture(e){return e>new Date}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static isSameWeek(e,t,s=0){const i=b.startOfWeek(e,s),n=b.startOfWeek(t,s);return i.toDateString()===n.toDateString()}static isSameMonth(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}static isSameYear(e,t){return e.getFullYear()===t.getFullYear()}static differenceInDays(e,t){const s=e.getTime()-t.getTime();return Math.floor(s/(1e3*60*60*24))}static differenceInWeeks(e,t){return Math.floor(b.differenceInDays(e,t)/7)}static differenceInMonths(e,t){const s=e.getFullYear()-t.getFullYear(),i=e.getMonth()-t.getMonth();return s*12+i}static getWeekNumber(e){const t=new Date(e.getFullYear(),0,1),s=(e-t)/864e5;return Math.ceil((s+t.getDay()+1)/7)}static getDayOfWeek(e,t=0){return(e.getDay()-t+7)%7}static getDaysInMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}static format(e,t="en-US",s={}){return new Intl.DateTimeFormat(t,s).format(e)}static getMonthName(e,t="en-US",s="long"){return b.format(e,t,{month:s})}static getDayName(e,t="en-US",s="long"){return b.format(e,t,{weekday:s})}static formatTime(e,t="en-US",s=!1){return b.format(e,t,{hour:"numeric",minute:"2-digit",hour12:!s})}static parseTime(e){const[t,s]=e.split(":").map(Number);return{hours:t,minutes:s}}static setTime(e,t){const s=new Date(e),{hours:i,minutes:n}=b.parseTime(t);return s.setHours(i,n,0,0),s}static isLeapYear(e){return e%4===0&&e%100!==0||e%400===0}static getDateRange(e,t){const s=[],i=new Date(e),n=t.getTime();for(;i.getTime()<=n;)s.push(new Date(i)),i.setDate(i.getDate()+1);return s}static clone(e){return new Date(e)}static isValidDate(e){return e instanceof Date&&!isNaN(e.getTime())}static toTimeZone(e,t){const i=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),n={};return i.forEach(r=>{r.type!=="literal"&&(n[r.type]=r.value)}),new Date(`${n.year}-${n.month}-${n.day}T${n.hour}:${n.minute}:${n.second}`)}static getTimezoneOffset(e,t){const s=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),i=new Date(e.toLocaleString("en-US",{timeZone:t}));return(s.getTime()-i.getTime())/6e4}static isDST(e,t){const s=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear(),6,1),n=b.getTimezoneOffset(s,t),r=b.getTimezoneOffset(i,t),a=b.getTimezoneOffset(e,t);return Math.max(n,r)===a}static addHoursWithDST(e,t,s){const i=new Date(e),n=b.getTimezoneOffset(e,s);i.setTime(i.getTime()+t*60*60*1e3);const r=b.getTimezoneOffset(i,s);if(n!==r){const a=(r-n)*6e4;i.setTime(i.getTime()+a)}return i}static createInTimeZone(e,t,s,i=0,n=0,r=0,a){const o=`${e}-${String(t+1).padStart(2,"0")}-${String(s).padStart(2,"0")}`,c=`${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`,l=new Date(`${o}T${c}`),d=b.getTimezoneOffset(l,a),h=l.getTime()+d*6e4;return new Date(h)}};class P{static parse(e){if(typeof e=="object")return this.validateRule(e);const t={freq:null,interval:1,count:null,until:null,byDay:[],byWeekNo:[],byMonth:[],byMonthDay:[],byYearDay:[],bySetPos:[],byHour:[],byMinute:[],bySecond:[],wkst:"MO",exceptions:[],tzid:null},s=e.toUpperCase().split(";");for(const i of s){const[n,r]=i.split("=");switch(n){case"FREQ":t.freq=this.parseFrequency(r);break;case"INTERVAL":t.interval=parseInt(r,10),t.interval<1&&(t.interval=1);break;case"COUNT":t.count=parseInt(r,10);break;case"UNTIL":t.until=this.parseDateTime(r);break;case"BYDAY":t.byDay=this.parseByDay(r);break;case"BYWEEKNO":t.byWeekNo=this.parseIntList(r);break;case"BYMONTH":t.byMonth=this.parseIntList(r);break;case"BYMONTHDAY":t.byMonthDay=this.parseIntList(r);break;case"BYYEARDAY":t.byYearDay=this.parseIntList(r);break;case"BYSETPOS":t.bySetPos=this.parseIntList(r);break;case"BYHOUR":t.byHour=this.parseIntList(r);break;case"BYMINUTE":t.byMinute=this.parseIntList(r);break;case"BYSECOND":t.bySecond=this.parseIntList(r);break;case"WKST":t.wkst=r;break;case"EXDATE":t.exceptions=this.parseExceptionDates(r);break;case"TZID":t.tzid=r;break}}return this.validateRule(t)}static parseFrequency(e){return["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"].includes(e)?e:"DAILY"}static parseByDay(e){const t=e.split(","),s=["SU","MO","TU","WE","TH","FR","SA"],i=[];for(const n of t){const a=n.trim().toUpperCase().match(/^([+-]?\d*)([A-Z]{2})$/);if(a){const[o,c,l]=a;s.includes(l)&&i.push(c?`${c}${l}`:l)}}return i}static parseIntList(e){return e.split(",").map(t=>parseInt(t.trim(),10)).filter(t=>!isNaN(t))}static parseDateTime(e){if(e.length===8){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10);return new Date(t,s,i)}if(e.length===15&&e[8]==="T"){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),n=parseInt(e.substr(9,2),10),r=parseInt(e.substr(11,2),10),a=parseInt(e.substr(13,2),10);return new Date(t,s,i,n,r,a)}if(e.length===16&&e[8]==="T"&&e[15]==="Z"){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),n=parseInt(e.substr(9,2),10),r=parseInt(e.substr(11,2),10),a=parseInt(e.substr(13,2),10);return new Date(Date.UTC(t,s,i,n,r,a))}return new Date(e)}static parseExceptionDates(e){return e.split(",").map(s=>this.parseDateTime(s.trim()))}static validateRule(e){if(e.freq||(e.freq="DAILY"),e.count&&e.until)throw new Error("RRULE cannot have both COUNT and UNTIL");e.interval<1&&(e.interval=1);const t=(s,i,n)=>s.filter(r=>r>=i&&r<=n);return e.byMonth=t(e.byMonth||[],1,12),e.byMonthDay=t(e.byMonthDay||[],-31,31).filter(s=>s!==0),e.byYearDay=t(e.byYearDay||[],-366,366).filter(s=>s!==0),e.byWeekNo=t(e.byWeekNo||[],-53,53).filter(s=>s!==0),e.byHour=t(e.byHour||[],0,23),e.byMinute=t(e.byMinute||[],0,59),e.bySecond=t(e.bySecond||[],0,59),e}static buildRRule(e){const t=[];if(t.push(`FREQ=${e.freq}`),e.interval&&e.interval>1&&t.push(`INTERVAL=${e.interval}`),e.count?t.push(`COUNT=${e.count}`):e.until&&t.push(`UNTIL=${this.formatDateTime(e.until)}`),e.byDay&&e.byDay.length>0){const s=e.byDay.map(i=>typeof i=="string"?i:i.nth?`${i.nth}${i.weekday}`:i.weekday).join(",");t.push(`BYDAY=${s}`)}return e.byMonth&&e.byMonth.length>0&&t.push(`BYMONTH=${e.byMonth.join(",")}`),e.byMonthDay&&e.byMonthDay.length>0&&t.push(`BYMONTHDAY=${e.byMonthDay.join(",")}`),e.byYearDay&&e.byYearDay.length>0&&t.push(`BYYEARDAY=${e.byYearDay.join(",")}`),e.byWeekNo&&e.byWeekNo.length>0&&t.push(`BYWEEKNO=${e.byWeekNo.join(",")}`),e.bySetPos&&e.bySetPos.length>0&&t.push(`BYSETPOS=${e.bySetPos.join(",")}`),e.byHour&&e.byHour.length>0&&t.push(`BYHOUR=${e.byHour.join(",")}`),e.byMinute&&e.byMinute.length>0&&t.push(`BYMINUTE=${e.byMinute.join(",")}`),e.bySecond&&e.bySecond.length>0&&t.push(`BYSECOND=${e.bySecond.join(",")}`),e.wkst&&e.wkst!=="MO"&&t.push(`WKST=${e.wkst}`),t.join(";")}static formatDateTime(e){const t=e.getUTCFullYear(),s=String(e.getUTCMonth()+1).padStart(2,"0"),i=String(e.getUTCDate()).padStart(2,"0"),n=String(e.getUTCHours()).padStart(2,"0"),r=String(e.getUTCMinutes()).padStart(2,"0"),a=String(e.getUTCSeconds()).padStart(2,"0");return`${t}${s}${i}T${n}${r}${a}Z`}static getDescription(e){const t={SECONDLY:"second",MINUTELY:"minute",HOURLY:"hour",DAILY:"day",WEEKLY:"week",MONTHLY:"month",YEARLY:"year"},s={SU:"Sunday",MO:"Monday",TU:"Tuesday",WE:"Wednesday",TH:"Thursday",FR:"Friday",SA:"Saturday"},i={1:"first",2:"second",3:"third",4:"fourth",5:"fifth","-1":"last","-2":"second to last"};let n="Every";if(e.interval>1&&(n+=` ${e.interval}`),n+=` ${t[e.freq]}`,e.interval>1&&(n+="s"),e.byDay&&e.byDay.length>0){const r=a=>{if(typeof a=="string"){const o=a.match(/^(-?\d+)?([A-Z]{2})$/);return o?{nth:o[1]?parseInt(o[1],10):null,weekday:o[2]}:{nth:null,weekday:a}}return a};if(e.freq==="WEEKLY"){const a=e.byDay.map(o=>s[r(o).weekday]).join(", ");n+=` on ${a}`}else if(e.freq==="MONTHLY"||e.freq==="YEARLY"){const a=e.byDay.map(o=>{const c=r(o);return c.nth?`the ${i[c.nth]||c.nth} ${s[c.weekday]}`:s[c.weekday]}).join(", ");n+=` on ${a}`}}if(e.byMonthDay&&e.byMonthDay.length>0){const r=e.byMonthDay.map(a=>a<0?`${Math.abs(a)} day(s) from the end`:`day ${a}`).join(", ");n+=` on ${r}`}if(e.byMonth&&e.byMonth.length>0){const r=["January","February","March","April","May","June","July","August","September","October","November","December"],a=e.byMonth.map(o=>r[o-1]).join(", ");n+=` in ${a}`}return e.count?n+=`, ${e.count} time${e.count>1?"s":""}`:e.until&&(n+=`, until ${e.until.toLocaleDateString()}`),n}}class V{static expandEvent(e,t,s,i=365,n=null){if(!e.recurring||!e.recurrenceRule)return[{start:e.start,end:e.end,timezone:e.timeZone}];const r=this.parseRule(e.recurrenceRule),a=[],o=e.end-e.start,c=n||e.timeZone||"UTC",l=I.getInstance();let d=new Date(e.start),h=0;r.until&&r.until<s&&(s=r.until);let p=l.getTimezoneOffset(d,c),w=0;const D=3;for(;d<=s&&h<i;){if(d>=t){const S=new Date(d),C=new Date(d.getTime()+o),_=l.getTimezoneOffset(S,c);if(_!==p){const O=p-_;S.setMinutes(S.getMinutes()+O),C.setMinutes(C.getMinutes()+O)}p=_,this.isException(S,r,e.id)||a.push({start:S,end:C,recurringEventId:e.id,timezone:c,originalStart:e.start})}const $=d.getTime();if(d=this.getNextOccurrence(d,r,c),h++,d.getTime()===$){if(w++,w>=D){console.warn("RecurrenceEngine: Date not advancing, breaking to prevent infinite loop");break}}else w=0;if(r.count&&h>=r.count)break}return a}static parseRule(e){return P.parse(e)}static getNextOccurrence(e,t,s="UTC"){const i=new Date(e);switch(t.freq){case"DAILY":i.setDate(i.getDate()+t.interval);break;case"WEEKLY":if(t.byDay&&t.byDay.length>0){let r=0;const a=i.getDate();for(i.setDate(i.getDate()+1);!this.matchesByDay(i,t.byDay)&&r<8;)i.setDate(i.getDate()+1),r++;r>=8&&(console.warn("RecurrenceEngine: Invalid byDay rule, falling back to weekly interval"),i.setDate(a+7*t.interval))}else i.setDate(i.getDate()+7*t.interval);break;case"MONTHLY":if(t.byMonthDay&&t.byMonthDay.length>0){const n=i.getMonth();i.setMonth(n+t.interval),i.setDate(t.byMonthDay[0])}else t.byDay&&t.byDay.length>0?(i.setMonth(i.getMonth()+t.interval),this.setToWeekdayOfMonth(i,t.byDay[0],t.bySetPos[0]||1)):i.setMonth(i.getMonth()+t.interval);break;case"YEARLY":t.byMonth&&t.byMonth.length>0?(i.setFullYear(i.getFullYear()+t.interval),i.setMonth(t.byMonth[0]-1)):i.setFullYear(i.getFullYear()+t.interval);break;default:i.setTime(i.getTime()+24*60*60*1e3)}return i}static matchesByDay(e,t){const s={SU:0,MO:1,TU:2,WE:3,TH:4,FR:5,SA:6},i=e.getDay();return t.some(n=>{const r=n.match(/^(-?\d+)?([A-Z]{2})$/);if(r){const a=r[2];return s[a]===i}return!1})}static setToWeekdayOfMonth(e,t,s=1){const i={SU:0,MO:1,TU:2,WE:3,TH:4,FR:5,SA:6},n=t.match(/^(-?\d+)?([A-Z]{2})$/),r=n?n[2]:t,a=i[r];for(e.setDate(1);e.getDay()!==a;)e.setDate(e.getDate()+1);if(s>1)e.setDate(e.getDate()+7*(s-1));else if(s===-1){const o=new Date(e);for(o.setMonth(o.getMonth()+1),o.setDate(0);o.getDay()!==a;)o.setDate(o.getDate()-1);e.setTime(o.getTime())}}static isException(e,t,s=null){if(!t.exceptions||t.exceptions.length===0)return!1;const i=e.toDateString(),n=e.getTime();return t.exceptions.some(r=>{if(typeof r=="object"&&r.date){const o=r.date instanceof Date?r.date:new Date(r.date);return r.matchTime?Math.abs(o.getTime()-n)<1e3:o.toDateString()===i}return(r instanceof Date?r:new Date(r)).toDateString()===i})}static addExceptions(e,t,s={}){return e.exceptions||(e.exceptions=[]),(Array.isArray(t)?t:[t]).forEach(n=>{s.reason||s.matchTime?e.exceptions.push({date:n,reason:s.reason,matchTime:s.matchTime||!1}):e.exceptions.push(n)}),e}static parseDate(e){if(e.length===8){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10);return new Date(t,s,i)}else if(e.length===15||e.length===16){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),n=parseInt(e.substr(9,2),10),r=parseInt(e.substr(11,2),10),a=parseInt(e.substr(13,2),10);return e.endsWith("Z")?new Date(Date.UTC(t,s,i,n,r,a)):new Date(t,s,i,n,r,a)}return new Date(e)}static getDescription(e){typeof e=="string"&&(e=this.parseRule(e));let t="";const s=e.interval||1;switch(e.freq){case"DAILY":t=s===1?"Daily":`Every ${s} days`;break;case"WEEKLY":if(t=s===1?"Weekly":`Every ${s} weeks`,e.byDay&&e.byDay.length>0){const i=e.byDay.map(n=>this.getDayName(n)).join(", ");t+=` on ${i}`}break;case"MONTHLY":t=s===1?"Monthly":`Every ${s} months`,e.byMonthDay&&e.byMonthDay.length>0&&(t+=` on day ${e.byMonthDay.join(", ")}`);break;case"YEARLY":t=s===1?"Yearly":`Every ${s} years`;break}return e.count?t+=`, ${e.count} times`:e.until&&(t+=`, until ${e.until.toLocaleDateString()}`),t}static getDayName(e){const t={SU:"Sunday",MO:"Monday",TU:"Tuesday",WE:"Wednesday",TH:"Thursday",FR:"Friday",SA:"Saturday"},s=e.match(/^(-?\d+)?([A-Z]{2})$/),i=s?s[2]:e,n=s&&s[1]?parseInt(s[1],10):null;let r=t[i]||e;return n&&(r=`${n===-1?"Last":["","1st","2nd","3rd","4th","5th"][n]||`${n}th`} ${r}`),r}}class B{constructor(e=100){this.capacity=e,this.cache=new Map,this.hits=0,this.misses=0,this.evictions=0}get(e){if(!this.cache.has(e)){this.misses++;return}const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),this.hits++,t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const s=this.cache.keys().next().value;this.cache.delete(s),this.evictions++}this.cache.set(e,t)}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0,this.evictions=0}getStats(){const e=this.hits+this.misses>0?(this.hits/(this.hits+this.misses)*100).toFixed(2):0;return{size:this.cache.size,capacity:this.capacity,hits:this.hits,misses:this.misses,evictions:this.evictions,hitRate:`${e}%`}}keys(){return Array.from(this.cache.keys())}get size(){return this.cache.size}}class W{constructor(e={}){this.config={checkInterval:3e4,memoryThreshold:.8,criticalThreshold:.95,minCacheSize:10,maxCacheSize:1e4,adaptiveScaling:!0,...e},this.caches=new Map,this.stats={adjustments:0,emergencyClears:0,lastMemoryUsage:0,lastCheckTime:null,cacheResizes:[]},this.monitoringInterval=null,this.config.adaptiveScaling&&this.startMonitoring()}registerCache(e,t,s={}){this.caches.set(e,{cache:t,priority:s.priority||1,currentCapacity:s.initialCapacity||100,minCapacity:s.minCapacity||this.config.minCacheSize,maxCapacity:s.maxCapacity||this.config.maxCacheSize,scaleFactor:s.scaleFactor||.5,lastAccess:Date.now()})}unregisterCache(e){this.caches.delete(e)}startMonitoring(){this.monitoringInterval||(this.monitoringInterval=setInterval(()=>{this.checkMemoryPressure()},this.config.checkInterval),this.checkMemoryPressure())}stopMonitoring(){this.monitoringInterval&&(clearInterval(this.monitoringInterval),this.monitoringInterval=null)}async checkMemoryPressure(){const e=await this.getMemoryUsage();this.stats.lastMemoryUsage=e,this.stats.lastCheckTime=new Date,e>this.config.criticalThreshold?this.emergencyClear():e>this.config.memoryThreshold?this.reduceCacheSizes(e):e<this.config.memoryThreshold-.2&&this.increaseCacheSizes()}async getMemoryUsage(){if(typeof performance<"u"&&performance.memory){const e=performance.memory;if(e.jsHeapSizeLimit&&e.usedJSHeapSize)return e.usedJSHeapSize/e.jsHeapSizeLimit}try{const e=typeof globalThis<"u"?globalThis:{},t="process",s="memoryUsage",i=e[t];if(i&&typeof i=="object"){const n=i[s];if(typeof n=="function"){const r=n.call(i);return r.heapUsed/r.heapTotal}}}catch{}return this.estimateMemoryUsage()}estimateMemoryUsage(){let e=0,t=0;for(const[s,i]of this.caches)i.cache.size!==void 0&&(e+=i.cache.size,t+=i.maxCapacity);return t>0?e/t:.5}reduceCacheSizes(e){const t=(e-this.config.memoryThreshold)/(this.config.criticalThreshold-this.config.memoryThreshold),s=Array.from(this.caches.entries()).sort((i,n)=>i[1].priority-n[1].priority);for(const[i,n]of s){const r=Math.floor(n.currentCapacity*n.scaleFactor*t),a=Math.max(n.minCapacity,n.currentCapacity-r);a<n.currentCapacity&&this.resizeCache(i,n,a)}this.stats.adjustments++}increaseCacheSizes(){for(const[e,t]of this.caches)if(Date.now()-t.lastAccess<6e4){const i=Math.floor(t.currentCapacity*.2),n=Math.min(t.maxCapacity,t.currentCapacity+i);n>t.currentCapacity&&this.resizeCache(e,t,n)}}resizeCache(e,t,s){const i=t.currentCapacity;t.currentCapacity=s,t.cache.capacity!==void 0&&(t.cache.capacity=s),t.cache.size>s&&this.evictExcessItems(t.cache,s),this.stats.cacheResizes.push({cache:e,timestamp:new Date,oldCapacity:i,newCapacity:s,reason:s<i?"pressure":"available"}),this.stats.cacheResizes.length>100&&this.stats.cacheResizes.shift()}evictExcessItems(e,t){if(e.size<=t)return;const s=e.size-t;if(e.keys){const i=Array.from(e.keys());for(let n=0;n<s;n++)e.delete(i[n])}else e.clear&&e.clear()}emergencyClear(){for(const[e,t]of this.caches)t.cache.clear&&t.cache.clear(),t.currentCapacity=t.minCapacity;this.stats.emergencyClears++,console.warn("AdaptiveMemoryManager: Emergency cache clear triggered")}touchCache(e){const t=this.caches.get(e);t&&(t.lastAccess=Date.now())}getStats(){const e={};for(const[t,s]of this.caches)e[t]={size:s.cache.size||0,capacity:s.currentCapacity,priority:s.priority,lastAccess:new Date(s.lastAccess)};return{...this.stats,memoryUsagePercent:`${(this.stats.lastMemoryUsage*100).toFixed(2)}%`,totalCaches:this.caches.size,cacheStats:e,monitoring:this.monitoringInterval!==null}}async checkNow(){await this.checkMemoryPressure()}setThresholds(e){e.memoryThreshold!==void 0&&(this.config.memoryThreshold=Math.max(.5,Math.min(.95,e.memoryThreshold))),e.criticalThreshold!==void 0&&(this.config.criticalThreshold=Math.max(this.config.memoryThreshold+.05,Math.min(1,e.criticalThreshold)))}destroy(){this.stopMonitoring(),this.caches.clear()}}class j{constructor(e={}){this.config={enableCache:!0,cacheCapacity:500,maxIndexDays:365,batchSize:100,enableMetrics:!0,cleanupInterval:36e5,maxIndexAge:30*24*60*60*1e3,enableAdaptiveMemory:!0,...e},this.eventCache=new B(this.config.cacheCapacity),this.queryCache=new B(Math.floor(this.config.cacheCapacity/2)),this.dateRangeCache=new B(Math.floor(this.config.cacheCapacity/4)),this.config.enableAdaptiveMemory&&(this.memoryManager=new W({checkInterval:3e4,memoryThreshold:.75,criticalThreshold:.9}),this.memoryManager.registerCache("events",this.eventCache,{priority:3,initialCapacity:this.config.cacheCapacity,minCapacity:50,maxCapacity:2e3}),this.memoryManager.registerCache("queries",this.queryCache,{priority:2,initialCapacity:Math.floor(this.config.cacheCapacity/2),minCapacity:25,maxCapacity:1e3}),this.memoryManager.registerCache("dateRanges",this.dateRangeCache,{priority:1,initialCapacity:Math.floor(this.config.cacheCapacity/4),minCapacity:10,maxCapacity:500})),this.lazyIndexes=new Map,this.pendingIndexes=new Map,this.batchQueue=[],this.batchTimer=null,this.batchCallbacks=[],this.metrics={operations:{},averageTimes:{},slowQueries:[]},this.cleanupTimer=null,this.config.cleanupInterval>0&&this.startCleanupTimer()}measure(e,t){if(!this.config.enableMetrics)return t();const s=performance.now();try{const i=t(),n=performance.now()-s;return this.recordMetric(e,n),i}catch(i){const n=performance.now()-s;throw this.recordMetric(e,n,!0),i}}async measureAsync(e,t){if(!this.config.enableMetrics)return await t();const s=performance.now();try{const i=await t(),n=performance.now()-s;return this.recordMetric(e,n),i}catch(i){const n=performance.now()-s;throw this.recordMetric(e,n,!0),i}}recordMetric(e,t,s=!1){this.metrics.operations[e]||(this.metrics.operations[e]={count:0,totalTime:0,errors:0,min:1/0,max:0});const i=this.metrics.operations[e];i.count++,i.totalTime+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),s&&i.errors++,this.metrics.averageTimes[e]=i.totalTime/i.count,t>100&&(this.metrics.slowQueries.push({operation:e,duration:t,timestamp:new Date,isError:s}),this.metrics.slowQueries.length>100&&this.metrics.slowQueries.shift())}getMetrics(){const e={cacheStats:{event:this.eventCache.getStats(),query:this.queryCache.getStats(),dateRange:this.dateRangeCache.getStats()},operations:{},slowestOperations:[],recentSlowQueries:this.metrics.slowQueries.slice(-10),memoryManagement:this.memoryManager?this.memoryManager.getStats():null};for(const[t,s]of Object.entries(this.metrics.operations))e.operations[t]={count:s.count,avgTime:`${(s.totalTime/s.count).toFixed(2)}ms`,minTime:`${s.min.toFixed(2)}ms`,maxTime:`${s.max.toFixed(2)}ms`,totalTime:`${s.totalTime.toFixed(2)}ms`,errors:s.errors,errorRate:`${(s.errors/s.count*100).toFixed(2)}%`};return e.slowestOperations=Object.entries(this.metrics.averageTimes).sort((t,s)=>s[1]-t[1]).slice(0,5).map(([t,s])=>({operation:t,avgTime:`${s.toFixed(2)}ms`})),e}shouldUseLazyIndexing(e){return Math.ceil((e.end-e.start)/864e5)>this.config.maxIndexDays}createLazyIndexMarkers(e){const t={eventId:e.id,start:e.start,end:e.end,indexed:new Set,pending:!1},s=new Date(e.start.getFullYear(),e.start.getMonth(),1),i=new Date(e.end.getFullYear(),e.end.getMonth(),1);return t.indexed.add(this.getMonthKey(s)),this.getMonthKey(s)!==this.getMonthKey(i)&&t.indexed.add(this.getMonthKey(i)),this.lazyIndexes.set(e.id,t),t}async expandLazyIndex(e,t,s){const i=this.lazyIndexes.get(e);if(!i)return new Set;if(i.pending)return this.pendingIndexes.get(e);i.pending=!0;const n=new Promise(r=>{setTimeout(()=>{const a=new Set,o=new Date(t);for(;o<=s;){const c=o.toDateString();i.indexed.has(c)||(a.add(c),i.indexed.add(c)),o.setDate(o.getDate()+1)}i.pending=!1,this.pendingIndexes.delete(e),r(a)},0)});return this.pendingIndexes.set(e,n),n}getMonthKey(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}cache(e,t,s="event"){if(!this.config.enableCache)return;let i,n;switch(s){case"event":i=this.eventCache,n="events";break;case"query":i=this.queryCache,n="queries";break;case"dateRange":i=this.dateRangeCache,n="dateRanges";break;default:return}i.put(e,t),this.memoryManager&&this.memoryManager.touchCache(n)}getFromCache(e,t="event"){if(!this.config.enableCache)return;let s,i;switch(t){case"event":s=this.eventCache.get(e),i="events";break;case"query":s=this.queryCache.get(e),i="queries";break;case"dateRange":s=this.dateRangeCache.get(e),i="dateRanges";break;default:return}return s!==void 0&&this.memoryManager&&this.memoryManager.touchCache(i),s}invalidateEventCaches(e){this.eventCache.delete(e),this.queryCache.clear(),this.dateRangeCache.clear()}batch(e){return new Promise((t,s)=>{this.batchQueue.push(e),this.batchCallbacks.push({resolve:t,reject:s}),this.batchQueue.length>=this.config.batchSize?this.processBatch():this.batchTimer||(this.batchTimer=setTimeout(()=>this.processBatch(),10))})}processBatch(){if(this.batchTimer&&(clearTimeout(this.batchTimer),this.batchTimer=null),this.batchQueue.length===0)return;const e=this.batchQueue.splice(0),t=this.batchCallbacks.splice(0),s=[],i=[];e.forEach((n,r)=>{try{s[r]=n()}catch(a){i[r]=a}}),t.forEach((n,r)=>{i[r]?n.reject(i[r]):n.resolve(s[r])})}startCleanupTimer(){this.cleanupTimer=setInterval(()=>{this.cleanupOldIndexes()},this.config.cleanupInterval)}cleanupOldIndexes(){const e=Date.now(),t=this.config.maxIndexAge;for(const[s,i]of this.lazyIndexes)i.end.getTime()<e-t&&this.lazyIndexes.delete(s);this.metrics.slowQueries.length>100&&(this.metrics.slowQueries=this.metrics.slowQueries.slice(-100))}optimizeQuery(e,t){const s=this.getFromCache(e,"query");if(s!==void 0)return s;const i=this.measure(`query:${e}`,t);return this.cache(e,i,"query"),i}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null),this.batchTimer&&(clearTimeout(this.batchTimer),this.batchTimer=null),this.eventCache.clear(),this.queryCache.clear(),this.dateRangeCache.clear(),this.lazyIndexes.clear(),this.pendingIndexes.clear()}}class Z{constructor(e){this.eventStore=e,this.conflictIdCounter=0}checkConflicts(e,t={}){const s={checkAttendees:!0,checkResources:!0,checkLocation:!0,ignoreAllDay:!1,excludeEventIds:[],includeStatuses:["confirmed","tentative"],bufferMinutes:0,...t};if(!e.start||!e.end)throw new Error("Event must have start and end dates");const i=[],n=new Set,r=new Set,a=new Date(e.start.getTime()-s.bufferMinutes*6e4),o=new Date(e.end.getTime()+s.bufferMinutes*6e4),c=this.eventStore.getEventsInRange(a,o,!1).filter(l=>!(l.id===e.id||s.excludeEventIds.includes(l.id)||!s.includeStatuses.includes(l.status)||s.ignoreAllDay&&(l.allDay||e.allDay)||l.status==="cancelled"));for(const l of c){const d=this._detectEventConflicts(e,l,s);d.length>0&&(i.push(...d),n.add(e.id),n.add(l.id),e.attendees&&e.attendees.forEach(h=>r.add(h.email)),l.attendees&&l.attendees.forEach(h=>r.add(h.email)))}return this._buildConflictSummary(i,n,r)}checkEventPairConflicts(e,t,s={}){const i={checkAttendees:!0,checkResources:!0,checkLocation:!0,bufferMinutes:0,...s};return this._detectEventConflicts(e,t,i)}getBusyPeriods(e,t,s,i={}){const n={includeStatuses:["confirmed","tentative"],mergePeriods:!0,...i},r=[];return this.eventStore.getEventsInRange(t,s,!1).filter(c=>!n.includeStatuses.includes(c.status)||c.status==="cancelled"?!1:c.attendees&&c.attendees.some(l=>e.includes(l.email))).forEach(c=>{r.push({start:c.start,end:c.end,eventIds:[c.id]})}),n.mergePeriods&&r.length>1?this._mergeBusyPeriods(r):r.sort((c,l)=>c.start-l.start)}getFreePeriods(e,t,s,i={}){const n={attendeeEmails:[],businessHoursOnly:!1,businessHours:{start:"09:00",end:"17:00"},excludeWeekends:!1,...i},r=[],a=n.attendeeEmails.length>0?this.getBusyPeriods(n.attendeeEmails,e,t):this._getAllBusyPeriods(e,t);let o=new Date(e);for(const c of a)o<c.start&&(c.start-o)/6e4>=s&&(!n.businessHoursOnly||this._isWithinBusinessHours(o,c.start,n))&&r.push({start:new Date(o),end:new Date(c.start)}),o=new Date(Math.max(o.getTime(),c.end.getTime()));return o<t&&(t-o)/6e4>=s&&(!n.businessHoursOnly||this._isWithinBusinessHours(o,t,n))&&r.push({start:new Date(o),end:new Date(t)}),r}_detectEventConflicts(e,t,s){const i=[];if(this._checkTimeOverlap(e,t,s.bufferMinutes)){const r=this._createTimeConflict(e,t);if(i.push(r),s.checkAttendees){const a=this._checkAttendeeConflicts(e,t);i.push(...a)}if(s.checkResources){const a=this._checkResourceConflicts(e,t);i.push(...a)}if(s.checkLocation){const a=this._checkLocationConflict(e,t);a&&i.push(a)}}return i}_checkTimeOverlap(e,t,s=0){const i=s*6e4,n=e.start.getTime()-i,r=e.end.getTime()+i,a=t.start.getTime(),o=t.end.getTime();return!(r<=a||o<=n)}_createTimeConflict(e,t){const s=new Date(Math.max(e.start.getTime(),t.start.getTime())),i=new Date(Math.min(e.end.getTime(),t.end.getTime())),n=(i-s)/6e4;let r="low";return n>=60?r="high":n>=30&&(r="medium"),e.status==="confirmed"&&t.status==="confirmed"&&(r=r==="low"?"medium":r==="medium"?"high":"critical"),{id:`conflict_${++this.conflictIdCounter}`,type:"time",severity:r,eventId:e.id,conflictingEventId:t.id,description:`Time overlap: ${e.title} conflicts with ${t.title}`,overlapStart:s,overlapEnd:i,overlapMinutes:n,metadata:{event1Title:e.title,event2Title:t.title,event1Status:e.status,event2Status:t.status}}}_checkAttendeeConflicts(e,t){const s=[];if(!e.attendees||!t.attendees)return s;const i=[];for(const n of e.attendees)for(const r of t.attendees)n.email===r.email&&i.push(n.email);if(i.length>0){let n="medium";i.some(a=>{const o=e.attendees.find(l=>l.email===a),c=t.attendees.find(l=>l.email===a);return(o==null?void 0:o.responseStatus)==="accepted"&&(c==null?void 0:c.responseStatus)==="accepted"})&&(n="critical"),s.push({id:`conflict_${++this.conflictIdCounter}`,type:"attendee",severity:n,eventId:e.id,conflictingEventId:t.id,description:`Attendee conflict: ${i.length} attendee(s) double-booked`,conflictingAttendees:i,metadata:{attendeeCount:i.length,attendeeEmails:i}})}return s}_checkResourceConflicts(e,t){var r,a;const s=[],i=((r=e.attendees)==null?void 0:r.filter(o=>o.resource))||[],n=((a=t.attendees)==null?void 0:a.filter(o=>o.resource))||[];for(const o of i)for(const c of n)o.email===c.email&&s.push({id:`conflict_${++this.conflictIdCounter}`,type:"resource",severity:"critical",eventId:e.id,conflictingEventId:t.id,description:`Resource conflict: ${o.name} is double-booked`,conflictingResource:o.email,metadata:{resourceName:o.name,resourceEmail:o.email}});return s}_checkLocationConflict(e,t){if(!e.location||!t.location)return null;const s=e.location.trim().toLowerCase(),i=t.location.trim().toLowerCase();return s===i?{id:`conflict_${++this.conflictIdCounter}`,type:"location",severity:"high",eventId:e.id,conflictingEventId:t.id,description:`Location conflict: ${e.location} is double-booked`,metadata:{location:e.location}}:null}_buildConflictSummary(e,t,s){const i={},n={};for(const r of e)i[r.type]=(i[r.type]||0)+1,n[r.severity]=(n[r.severity]||0)+1;return{hasConflicts:e.length>0,totalConflicts:e.length,conflicts:e,conflictsByType:i,conflictsBySeverity:n,affectedEventIds:Array.from(t),affectedAttendees:Array.from(s)}}_mergeBusyPeriods(e){if(e.length<=1)return e;e.sort((s,i)=>s.start-i.start);const t=[e[0]];for(let s=1;s<e.length;s++){const i=e[s],n=t[t.length-1];i.start<=n.end?(n.end=new Date(Math.max(n.end.getTime(),i.end.getTime())),n.eventIds.push(...i.eventIds)):t.push(i)}return t}_getAllBusyPeriods(e,t){return this.eventStore.getEventsInRange(e,t,!1).filter(i=>i.status!=="cancelled").map(i=>({start:i.start,end:i.end,eventIds:[i.id]})).sort((i,n)=>i.start-n.start)}_isWithinBusinessHours(e,t,s){const i=e.getHours(),n=t.getHours(),r=parseInt(s.businessHours.start.split(":")[0]),a=parseInt(s.businessHours.end.split(":")[0]);return i>=r&&n<=a}}class q{constructor(e={}){this.events=new Map,this.indices={byDate:new Map,byMonth:new Map,recurring:new Set,byCategory:new Map,byStatus:new Map},this.timezoneManager=I.getInstance(),this.defaultTimezone=e.timezone||this.timezoneManager.getSystemTimezone(),this.optimizer=new j(e.performance),this.conflictDetector=new Z(this),this.isBatchMode=!1,this.batchNotifications=[],this.batchBackup=null,this.version=0,this.listeners=new Set}addEvent(e){return this.optimizer.measure("addEvent",()=>{if(e instanceof x||(e=new x(e)),this.events.has(e.id))throw new Error(`Event with id ${e.id} already exists`);return this.events.set(e.id,e),this.optimizer.cache(e.id,e,"event"),this._indexEvent(e),this.isBatchMode?this.batchNotifications.push({type:"add",event:e,version:++this.version}):this._notifyChange({type:"add",event:e,version:++this.version}),e})}updateEvent(e,t){const s=this.events.get(e);if(!s)throw new Error(`Event with id ${e} not found`);this._unindexEvent(s);const i=s.clone(t);return this.events.set(e,i),this._indexEvent(i),this._notifyChange({type:"update",event:i,oldEvent:s,version:++this.version}),i}removeEvent(e){const t=this.events.get(e);return t?(this.events.delete(e),this._unindexEvent(t),this._notifyChange({type:"remove",event:t,version:++this.version}),!0):!1}getEvent(e){const t=this.optimizer.getFromCache(e,"event");if(t)return t;const s=this.events.get(e)||null;return s&&this.optimizer.cache(e,s,"event"),s}getAllEvents(){return Array.from(this.events.values())}queryEvents(e={}){let t=Array.from(this.events.values());if(e.start||e.end){const s=e.start?new Date(e.start):null,i=e.end?new Date(e.end):null;t=t.filter(n=>!(s&&n.end<s||i&&n.start>i))}if(e.date){const s=new Date(e.date);t=t.filter(i=>i.occursOn(s))}if(e.month&&e.year){const s=`${e.year}-${String(e.month).padStart(2,"0")}`,i=this.indices.byMonth.get(s)||new Set;t=t.filter(n=>i.has(n.id))}return Object.prototype.hasOwnProperty.call(e,"allDay")&&(t=t.filter(s=>s.allDay===e.allDay)),Object.prototype.hasOwnProperty.call(e,"recurring")&&(t=t.filter(s=>s.recurring===e.recurring)),e.status&&(t=t.filter(s=>s.status===e.status)),e.categories&&e.categories.length>0&&(t=t.filter(s=>e.matchAllCategories?s.hasAllCategories(e.categories):s.hasAnyCategory(e.categories))),Object.prototype.hasOwnProperty.call(e,"hasAttendees")&&(t=t.filter(s=>e.hasAttendees?s.hasAttendees:!s.hasAttendees)),e.organizerEmail&&(t=t.filter(s=>s.organizer&&s.organizer.email===e.organizerEmail)),e.sort&&t.sort((s,i)=>{switch(e.sort){case"start":return s.start-i.start;case"end":return s.end-i.end;case"duration":return s.duration-i.duration;case"title":return s.title.localeCompare(i.title);default:return 0}}),t}getEventsForDate(e,t=null){t=t||this.defaultTimezone,f.getLocalDateString(e);const s=new Set,i=new Date(e);for(let l=-1;l<=1;l++){const d=new Date(i);d.setDate(d.getDate()+l);const h=f.getLocalDateString(d),p=this.indices.byDate.get(h);p&&p.forEach(w=>s.add(w))}const n=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,r=this.indices.byMonth.get(n);r&&r.forEach(l=>s.add(l));const a=[],o=new Date(e);o.setHours(0,0,0,0);const c=new Date(e);c.setHours(23,59,59,999);for(const l of s){const d=this.events.get(l);if(d){const h=d.getStartInTimezone(t),p=d.getEndInTimezone(t);h<=c&&p>=o&&a.push(d)}}return a.sort((l,d)=>{const h=l.getStartInTimezone(t),p=d.getStartInTimezone(t),w=h-p;return w!==0?w:d.duration-l.duration})}getOverlappingEvents(e,t,s=null){const i=[],n=f.startOfDay(e),r=f.endOfDay(t),a=f.getDateRange(n,r),o=new Set;return a.forEach(c=>{const l=f.getLocalDateString(c);(this.indices.byDate.get(l)||new Set).forEach(h=>{if(!o.has(h)&&h!==s){o.add(h);const p=this.events.get(h);p&&p.overlaps({start:e,end:t})&&i.push(p)}})}),i.sort((c,l)=>c.start-l.start)}hasConflicts(e,t,s=null){return this.getOverlappingEvents(e,t,s).length>0}getOverlapGroups(e,t=!0){let s=this.getEventsForDate(e);t&&(s=s.filter(r=>!r.allDay));const i=[],n=new Set;return s.forEach(r=>{if(n.has(r.id))return;const a=[r];n.add(r.id);let o=0;for(;o<a.length;){const c=a[o];s.forEach(l=>{!n.has(l.id)&&c.overlaps(l)&&(a.push(l),n.add(l.id))}),o++}i.push(a)}),i}calculateEventPositions(e){const t=new Map;if(e.length===0)return t;e.sort((n,r)=>{const a=n.start-r.start;return a!==0?a:r.end-r.start-(n.end-n.start)});const s=[];e.forEach(n=>{let r=0;for(;r<s.length&&s[r].some(c=>c.overlaps(n));)r++;s[r]||(s[r]=[]),s[r].push(n),t.set(n.id,{column:r,totalColumns:0})});const i=s.length;return t.forEach(n=>{n.totalColumns=i}),t}getEventsInRange(e,t,s=!0,i=null){typeof s=="string"&&(i=s,s=!0),i=i||this.defaultTimezone;const n=this.timezoneManager.toUTC(e,i),r=this.timezoneManager.toUTC(t,i),a=this.queryEvents({start:n,end:r,sort:"start"});if(!s)return a;const o=[];return a.forEach(c=>{if(c.recurring&&c.recurrenceRule){const l=this.expandRecurringEvent(c,e,t,i);o.push(...l)}else o.push(c)}),o.sort((c,l)=>{const d=c.getStartInTimezone(i),h=l.getStartInTimezone(i);return d-h})}expandRecurringEvent(e,t,s,i=null){if(!e.recurring||!e.recurrenceRule)return[e];i=i||this.defaultTimezone;const n=e.timeZone||i;return V.expandEvent(e,t,s).map((a,o)=>e.clone({id:`${e.id}_occurrence_${o}`,start:a.start,end:a.end,timeZone:n,metadata:{...e.metadata,recurringEventId:e.id,occurrenceIndex:o}}))}clear(){const e=this.getAllEvents();this.events.clear(),this.indices.byDate.clear(),this.indices.byMonth.clear(),this.indices.recurring.clear(),this._notifyChange({type:"clear",oldEvents:e,version:++this.version})}loadEvents(e){this.clear();for(const t of e)this.addEvent(t)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}_indexEvent(e){if(this.optimizer.shouldUseLazyIndexing(e)){this._indexEventLazy(e);return}const t=e.getStartInTimezone(e.timeZone),s=e.getEndInTimezone(e.endTimeZone||e.timeZone),i=f.startOfDay(t),n=f.endOfDay(s);f.getDateRange(i,n).forEach(o=>{const c=f.getLocalDateString(o);this.indices.byDate.has(c)||this.indices.byDate.set(c,new Set),this.indices.byDate.get(c).add(e.id)}),`${i.getFullYear()}${String(i.getMonth()+1).padStart(2,"0")}`,`${n.getFullYear()}${String(n.getMonth()+1).padStart(2,"0")}`;const a=new Date(i.getFullYear(),i.getMonth(),1);for(;a<=n;){const o=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}`;this.indices.byMonth.has(o)||this.indices.byMonth.set(o,new Set),this.indices.byMonth.get(o).add(e.id),a.setMonth(a.getMonth()+1)}e.categories&&e.categories.length>0&&e.categories.forEach(o=>{this.indices.byCategory.has(o)||this.indices.byCategory.set(o,new Set),this.indices.byCategory.get(o).add(e.id)}),e.status&&(this.indices.byStatus.has(e.status)||this.indices.byStatus.set(e.status,new Set),this.indices.byStatus.get(e.status).add(e.id)),e.recurring&&this.indices.recurring.add(e.id)}_indexEventLazy(e){this.optimizer.createLazyIndexMarkers(e);const t=e.getStartInTimezone(e.timeZone),s=e.getEndInTimezone(e.endTimeZone||e.timeZone),i=f.startOfDay(t),n=f.endOfDay(s),r=new Date(i);if(r.setDate(r.getDate()+7),f.getDateRange(i,r<n?r:n).forEach(c=>{const l=f.getLocalDateString(c);this.indices.byDate.has(l)||this.indices.byDate.set(l,new Set),this.indices.byDate.get(l).add(e.id)}),n>r){const c=new Date(n);c.setDate(c.getDate()-7),f.getDateRange(c>i?c:i,n).forEach(d=>{const h=f.getLocalDateString(d);this.indices.byDate.has(h)||this.indices.byDate.set(h,new Set),this.indices.byDate.get(h).add(e.id)})}const o=new Date(i.getFullYear(),i.getMonth(),1);for(;o<=n;){const c=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`;this.indices.byMonth.has(c)||this.indices.byMonth.set(c,new Set),this.indices.byMonth.get(c).add(e.id),o.setMonth(o.getMonth()+1)}e.categories&&e.categories.length>0&&e.categories.forEach(c=>{this.indices.byCategory.has(c)||this.indices.byCategory.set(c,new Set),this.indices.byCategory.get(c).add(e.id)}),e.status&&(this.indices.byStatus.has(e.status)||this.indices.byStatus.set(e.status,new Set),this.indices.byStatus.get(e.status).add(e.id)),e.recurring&&this.indices.recurring.add(e.id)}_unindexEvent(e){for(const[t,s]of this.indices.byDate)s.delete(e.id),s.size===0&&this.indices.byDate.delete(t);for(const[t,s]of this.indices.byMonth)s.delete(e.id),s.size===0&&this.indices.byMonth.delete(t);this.indices.recurring.delete(e.id)}_notifyChange(e){for(const t of this.listeners)try{t(e)}catch(s){console.error("Error in EventStore listener:",s)}}getStats(){return{totalEvents:this.events.size,recurringEvents:this.indices.recurring.size,indexedDates:this.indices.byDate.size,indexedMonths:this.indices.byMonth.size,indexedCategories:this.indices.byCategory.size,indexedStatuses:this.indices.byStatus.size,version:this.version,performanceMetrics:this.optimizer.getMetrics()}}startBatch(e=!1){this.isBatchMode=!0,this.batchNotifications=[],e&&(this.batchBackup={events:new Map(this.events),indices:{byDate:new Map(Array.from(this.indices.byDate.entries()).map(([t,s])=>[t,new Set(s)])),byMonth:new Map(Array.from(this.indices.byMonth.entries()).map(([t,s])=>[t,new Set(s)])),recurring:new Set(this.indices.recurring),byCategory:new Map(Array.from(this.indices.byCategory.entries()).map(([t,s])=>[t,new Set(s)])),byStatus:new Map(Array.from(this.indices.byStatus.entries()).map(([t,s])=>[t,new Set(s)]))},version:this.version})}commitBatch(){this.isBatchMode&&(this.isBatchMode=!1,this.batchBackup=null,this.batchNotifications.length>0&&this._notifyChange({type:"batch",changes:this.batchNotifications,count:this.batchNotifications.length,version:++this.version}),this.batchNotifications=[])}rollbackBatch(){this.isBatchMode&&(this.isBatchMode=!1,this.batchBackup&&(this.events=this.batchBackup.events,this.indices=this.batchBackup.indices,this.version=this.batchBackup.version,this.batchBackup=null,this.optimizer.clearCache()),this.batchNotifications=[])}async executeBatch(e,t=!0){this.startBatch(t);try{const s=await e();return this.commitBatch(),s}catch(s){throw t&&this.rollbackBatch(),s}}addEvents(e){return this.optimizer.measure("addEvents",()=>{this.startBatch();const t=[],s=[];for(const i of e)try{t.push(this.addEvent(i))}catch(n){s.push({event:i,error:n.message})}return this.commitBatch(),s.length>0&&console.warn(`Failed to add ${s.length} events:`,s),t})}updateEvents(e){return this.optimizer.measure("updateEvents",()=>{this.startBatch();const t=[],s=[];for(const{id:i,updates:n}of e)try{t.push(this.updateEvent(i,n))}catch(r){s.push({id:i,error:r.message})}return this.commitBatch(),s.length>0&&console.warn(`Failed to update ${s.length} events:`,s),t})}removeEvents(e){return this.optimizer.measure("removeEvents",()=>{this.startBatch();let t=0;for(const s of e)this.removeEvent(s)&&t++;return this.commitBatch(),t})}getPerformanceMetrics(){return this.optimizer.getMetrics()}clearCaches(){this.optimizer.eventCache.clear(),this.optimizer.queryCache.clear(),this.optimizer.dateRangeCache.clear()}optimizeIndices(e){e||(e=new Date,e.setMonth(e.getMonth()-6)),e.toDateString();let t=0;for(const[s,i]of this.indices.byDate)if(new Date(s)<e){let r=!1;for(const a of i){const o=this.events.get(a);if(o&&o.end>=e){r=!0;break}}r||(this.indices.byDate.delete(s),t++)}return console.log(`Optimized indices: removed ${t} old date entries`),t}destroy(){this.clear(),this.optimizer.destroy(),this.listeners.clear()}checkConflicts(e,t={}){return this.conflictDetector.checkConflicts(e,t)}checkEventPairConflicts(e,t,s={}){const i=this.getEvent(e),n=this.getEvent(t);if(!i||!n)throw new Error("One or both events not found");return this.conflictDetector.checkEventPairConflicts(i,n,s)}getAllConflicts(e,t,s={}){const i=this.getEventsInRange(e,t,!1),n=[],r=new Set;for(let a=0;a<i.length;a++)for(let o=a+1;o<i.length;o++){const c=`${i[a].id}-${i[o].id}`;if(!r.has(c)){r.add(c);const l=this.conflictDetector.checkEventPairConflicts(i[a],i[o],s);n.push(...l)}}return this.conflictDetector._buildConflictSummary(n,new Set(i.map(a=>a.id)),new Set)}getBusyPeriods(e,t,s,i={}){return this.conflictDetector.getBusyPeriods(e,t,s,i)}getFreePeriods(e,t,s,i={}){return this.conflictDetector.getFreePeriods(e,t,s,i)}addEventWithConflictCheck(e,t=!0){const s=this.checkConflicts(e);if(!t&&s.hasConflicts)throw new Error(`Cannot add event: ${s.totalConflicts} conflicts detected`);return{event:this.addEvent(e),conflicts:s}}findEventsWithConflicts(e={}){const t=[],s=this.getAllEvents();for(const i of s){const n=this.checkConflicts(i,e);n.hasConflicts&&t.push({event:i,conflicts:n.conflicts})}return t}}let K=class{constructor(e={}){this.state={view:"month",currentDate:new Date,selectedEventId:null,selectedDate:null,hoveredEventId:null,hoveredDate:null,weekStartsOn:0,showWeekNumbers:!1,showWeekends:!0,fixedWeekCount:!0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,locale:"en-US",hourFormat:"12h",businessHours:{start:"09:00",end:"17:00"},filters:{searchTerm:"",categories:[],showAllDay:!0,showTimed:!0},isDragging:!1,isResizing:!1,isCreating:!1,isLoading:!1,loadingMessage:"",error:null,metadata:{},...e},this.listeners=new Map,this.globalListeners=new Set,this.history=[],this.historyIndex=-1,this.maxHistorySize=50}getState(){return Object.freeze({...this.state})}get(e){return this.state[e]}setState(e){const t=this.state;typeof e=="function"&&(e=e(t));const s={...t,...e,filters:e.filters?{...t.filters,...e.filters}:t.filters,businessHours:e.businessHours?{...t.businessHours,...e.businessHours}:t.businessHours,metadata:e.metadata?{...t.metadata,...e.metadata}:t.metadata};this._hasChanged(t,s)&&(this.state=s,this._addToHistory(s),this._notifyListeners(t,s))}setView(e){const t=["month","week","day","list"];if(!t.includes(e))throw new Error(`Invalid view: ${e}. Must be one of: ${t.join(", ")}`);this.setState({view:e})}setCurrentDate(e){if(e instanceof Date||(e=new Date(e)),isNaN(e.getTime()))throw new Error("Invalid date");this.setState({currentDate:e})}navigateNext(){const{view:e,currentDate:t}=this.state,s=new Date(t);switch(e){case"month":s.setMonth(s.getMonth()+1);break;case"week":s.setDate(s.getDate()+7);break;case"day":s.setDate(s.getDate()+1);break}this.setCurrentDate(s)}navigatePrevious(){const{view:e,currentDate:t}=this.state,s=new Date(t);switch(e){case"month":s.setMonth(s.getMonth()-1);break;case"week":s.setDate(s.getDate()-7);break;case"day":s.setDate(s.getDate()-1);break}this.setCurrentDate(s)}navigateToday(){this.setCurrentDate(new Date)}selectEvent(e){this.setState({selectedEventId:e})}clearEventSelection(){this.setState({selectedEventId:null})}selectDate(e){e instanceof Date||(e=new Date(e)),this.setState({selectedDate:e})}clearDateSelection(){this.setState({selectedDate:null})}setLoading(e,t=""){this.setState({isLoading:e,loadingMessage:t})}setError(e){this.setState({error:e?e instanceof Error?e.message:e:null})}updateFilters(e){this.setState({filters:{...this.state.filters,...e}})}subscribe(e){return this.globalListeners.add(e),()=>{this.globalListeners.delete(e)}}watch(e,t){const s=Array.isArray(e)?e:[e];return s.forEach(i=>{this.listeners.has(i)||this.listeners.set(i,new Set),this.listeners.get(i).add(t)}),()=>{s.forEach(i=>{const n=this.listeners.get(i);n&&(n.delete(t),n.size===0&&this.listeners.delete(i))})}}canUndo(){return this.historyIndex>0}canRedo(){return this.historyIndex<this.history.length-1}getUndoCount(){return this.historyIndex}getRedoCount(){return this.history.length-1-this.historyIndex}undo(){if(!this.canUndo())return!1;this.historyIndex--;const e=this.history[this.historyIndex],t=this.state;return this.state={...e},this._notifyListeners(t,this.state),!0}redo(){if(!this.canRedo())return!1;this.historyIndex++;const e=this.history[this.historyIndex],t=this.state;return this.state={...e},this._notifyListeners(t,this.state),!0}reset(){const e=this.history[0]||{};this.setState(e),this.history=[e],this.historyIndex=0}_hasChanged(e,t){return!this._deepEqual(e,t)}_deepEqual(e,t,s=new Set){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e!="object")return e===t;if(s.has(e)||s.has(t))return!1;if(s.add(e),s.add(t),Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return s.delete(e),s.delete(t),!1;for(let r=0;r<e.length;r++)if(!this._deepEqual(e[r],t[r],s))return s.delete(e),s.delete(t),!1;return s.delete(e),s.delete(t),!0}if(e instanceof Date&&t instanceof Date){const r=e.getTime()===t.getTime();return s.delete(e),s.delete(t),r}const i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return s.delete(e),s.delete(t),!1;i.sort(),n.sort();for(let r=0;r<i.length;r++)if(i[r]!==n[r])return s.delete(e),s.delete(t),!1;for(const r of i)if(!this._deepEqual(e[r],t[r],s))return s.delete(e),s.delete(t),!1;return s.delete(e),s.delete(t),!0}_addToHistory(e){this.historyIndex<this.history.length-1&&(this.history=this.history.slice(0,this.historyIndex+1));const t=this._deepClone(e);this.history.push(t),this.historyIndex++,this.history.length>this.maxHistorySize&&(this.history.shift(),this.historyIndex--)}_deepClone(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return e.map(s=>this._deepClone(s));const t={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=this._deepClone(e[s]));return t}_notifyListeners(e,t){for(const s of this.globalListeners)try{s(t,e)}catch(i){console.error("Error in state listener:",i)}for(const[s,i]of this.listeners)if(e[s]!==t[s])for(const n of i)try{n(t[s],e[s],t,e)}catch(r){console.error(`Error in state listener for key "${s}":`,r)}}};class G{constructor(e={}){this.timezoneManager=I.getInstance(),this.config={view:"month",date:new Date,weekStartsOn:0,locale:"en-US",timeZone:e.timeZone||this.timezoneManager.getSystemTimezone(),showWeekNumbers:!1,showWeekends:!0,fixedWeekCount:!0,businessHours:{start:"09:00",end:"17:00"},...e},this.eventStore=new q({timezone:this.config.timeZone}),this.state=new K({view:this.config.view,currentDate:this.config.date,weekStartsOn:this.config.weekStartsOn,locale:this.config.locale,timeZone:this.config.timeZone,showWeekNumbers:this.config.showWeekNumbers,showWeekends:this.config.showWeekends,fixedWeekCount:this.config.fixedWeekCount,businessHours:this.config.businessHours}),this.listeners=new Map,this.plugins=new Set,this.views=new Map,this._setupInternalListeners(),e.events&&this.setEvents(e.events)}setView(e,t=null){this.state.setView(e),t&&this.state.setCurrentDate(t),this._emit("viewChange",{view:e,date:t||this.state.get("currentDate")})}getView(){return this.state.get("view")}next(){this.state.navigateNext(),this._emit("navigate",{direction:"next",date:this.state.get("currentDate"),view:this.state.get("view")})}previous(){this.state.navigatePrevious(),this._emit("navigate",{direction:"previous",date:this.state.get("currentDate"),view:this.state.get("view")})}today(){this.state.navigateToday(),this._emit("navigate",{direction:"today",date:this.state.get("currentDate"),view:this.state.get("view")})}goToDate(e){this.state.setCurrentDate(e),this._emit("navigate",{direction:"goto",date:e,view:this.state.get("view")})}setDate(e){this.goToDate(e)}getCurrentDate(){return new Date(this.state.get("currentDate"))}addEvent(e){!(e instanceof x)&&!e.timeZone&&(e={...e,timeZone:this.config.timeZone});const t=this.eventStore.addEvent(e);return this._emit("eventAdd",{event:t}),t}updateEvent(e,t){const s=this.eventStore.getEvent(e),i=this.eventStore.updateEvent(e,t);return this._emit("eventUpdate",{event:i,oldEvent:s}),i}removeEvent(e){const t=this.eventStore.getEvent(e),s=this.eventStore.removeEvent(e);return s&&this._emit("eventRemove",{event:t}),s}deleteEvent(e){return this.removeEvent(e)}getEvent(e){return this.eventStore.getEvent(e)}getEvents(){return this.eventStore.getAllEvents()}setEvents(e){this.eventStore.loadEvents(e),this._emit("eventsSet",{events:this.getEvents()})}queryEvents(e){return this.eventStore.queryEvents(e)}getEventsForDate(e,t=null){return this.eventStore.getEventsForDate(e,t||this.config.timeZone)}getEventsInRange(e,t,s=null){return this.eventStore.getEventsInRange(e,t,!0,s||this.config.timeZone)}setTimezone(e){const t=this.timezoneManager.parseTimezone(e),s=this.config.timeZone;this.config.timeZone=t,this.eventStore.defaultTimezone=t,this.state.setState({timeZone:t}),this._emit("timezoneChange",{timezone:t,previousTimezone:s})}getTimezone(){return this.config.timeZone}setLocale(e){this.config.locale=e,this.state.setState({locale:e}),this._emit("localeChange",{locale:e})}setWeekStartsOn(e){this.config.weekStartsOn=e,this.state.setState({weekStartsOn:e}),this._emit("weekStartsOnChange",{weekStartsOn:e})}convertTimezone(e,t,s){return this.timezoneManager.convertTimezone(e,t,s)}toCalendarTimezone(e,t){return this.timezoneManager.convertTimezone(e,t,this.config.timeZone)}fromCalendarTimezone(e,t){return this.timezoneManager.convertTimezone(e,this.config.timeZone,t)}formatInTimezone(e,t=null,s={}){return this.timezoneManager.formatInTimezone(e,t||this.config.timeZone,s)}getTimezones(){return this.timezoneManager.getCommonTimezones()}getOverlapGroups(e,t=!0){return this.eventStore.getOverlapGroups(e,t)}calculateEventPositions(e){return this.eventStore.calculateEventPositions(e)}getViewData(){const e=this.state.get("view"),t=this.state.get("currentDate");switch(e){case"month":return this._getMonthViewData(t);case"week":return this._getWeekViewData(t);case"day":return this._getDayViewData(t);case"list":return this._getListViewData(t);default:return null}}_getMonthViewData(e){const t=e.getFullYear(),s=e.getMonth(),i=this.state.get("weekStartsOn"),n=this.state.get("fixedWeekCount"),r=new Date(t,s,1),a=new Date(t,s+1,0),o=f.startOfWeek(r,i),c=[];let l=new Date(o);const d=n?6:Math.ceil((a.getDate()+f.getDayOfWeek(r,i))/7);for(let h=0;h<d;h++){const p={weekNumber:f.getWeekNumber(l),days:[]};for(let w=0;w<7;w++){const D=new Date(l),$=D.getMonth()===s,S=f.isToday(D),C=D.getDay()===0||D.getDay()===6;p.days.push({date:D,dayOfMonth:D.getDate(),isCurrentMonth:$,isToday:S,isWeekend:C,events:this.getEventsForDate(D)}),l=f.addDays(l,1)}c.push(p)}return{type:"month",year:t,month:s,monthName:f.getMonthName(e,this.state.get("locale")),weeks:c,startDate:o,endDate:new Date(l.getTime()-1)}}_getWeekViewData(e){const t=this.state.get("weekStartsOn"),s=f.startOfWeek(e,t),i=f.endOfWeek(e,t),n=[],r=new Date(s);for(let a=0;a<7;a++){const o=new Date(r);n.push({date:o,dayOfMonth:o.getDate(),dayOfWeek:o.getDay(),dayName:f.getDayName(o,this.state.get("locale")),isToday:f.isToday(o),isWeekend:o.getDay()===0||o.getDay()===6,events:this.getEventsForDate(o),overlapGroups:this.eventStore.getOverlapGroups(o,!0),getEventPositions:c=>this.eventStore.calculateEventPositions(c)}),r.setDate(r.getDate()+1)}return{type:"week",weekNumber:f.getWeekNumber(s),startDate:s,endDate:i,days:n}}_getDayViewData(e){const t=this.getEventsForDate(e),s=t.filter(r=>r.allDay),i=t.filter(r=>!r.allDay),n=[];for(let r=0;r<24;r++){const a=new Date(e);a.setHours(r,0,0,0);const o=new Date(e);o.setHours(r+1,0,0,0),n.push({hour:r,time:f.formatTime(a,this.state.get("locale")),events:i.filter(c=>c.start<o&&c.end>a)})}return{type:"day",date:e,dayName:f.getDayName(e,this.state.get("locale")),isToday:f.isToday(e),allDayEvents:s,hours:n}}_getListViewData(e){const t=new Date(e);t.setHours(0,0,0,0);const s=new Date(t);s.setDate(s.getDate()+30);const i=this.getEventsInRange(t,s),n=new Map;i.forEach(a=>{const o=a.start.toDateString();n.has(o)||n.set(o,{date:new Date(a.start),events:[]}),n.get(o).events.push(a)});const r=Array.from(n.values()).sort((a,o)=>a.date-o.date).map(a=>({...a,dayName:f.getDayName(a.date,this.state.get("locale")),isToday:f.isToday(a.date)}));return{type:"list",startDate:t,endDate:s,days:r,totalEvents:i.length}}selectEvent(e){const t=this.getEvent(e);t&&(this.state.selectEvent(e),this._emit("eventSelect",{event:t}))}clearEventSelection(){const e=this.state.get("selectedEventId");this.state.clearEventSelection(),e&&this._emit("eventDeselect",{eventId:e})}selectDate(e){this.state.selectDate(e),this._emit("dateSelect",{date:e})}clearDateSelection(){const e=this.state.get("selectedDate");this.state.clearDateSelection(),e&&this._emit("dateDeselect",{date:e})}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){const s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e))}_emit(e,t){const s=this.listeners.get(e);s&&s.forEach(i=>{try{i(t)}catch(n){console.error(`Error in event listener for "${e}":`,n)}})}_setupInternalListeners(){this.state.subscribe((e,t)=>{this._emit("stateChange",{newState:e,oldState:t})}),this.eventStore.subscribe(e=>{this._emit("eventStoreChange",e)})}use(e){if(this.plugins.has(e)){console.warn("Plugin already installed");return}if(typeof e.install=="function")e.install(this),this.plugins.add(e);else throw new Error("Plugin must have an install method")}destroy(){this.listeners.clear(),this.eventStore.destroy(),this.plugins.forEach(e=>{typeof e.uninstall=="function"&&e.uninstall(this)}),this.plugins.clear(),this.views.clear(),this._emit("destroy")}}class U{constructor(){this.events=new Map,this.wildcardHandlers=new Set}on(e,t,s={}){const{once:i=!1,priority:n=0}=s;if(e.includes("*")){const o={pattern:e,handler:t,once:i,priority:n};return this.wildcardHandlers.add(o),()=>this.wildcardHandlers.delete(o)}this.events.has(e)||this.events.set(e,[]);const r={handler:t,once:i,priority:n},a=this.events.get(e);return a.push(r),a.sort((o,c)=>c.priority-o.priority),()=>{const o=a.indexOf(r);o>-1&&a.splice(o,1)}}once(e,t,s={}){return this.on(e,t,{...s,once:!0})}off(e,t){if(e.includes("*")){for(const n of this.wildcardHandlers)if(n.pattern===e&&n.handler===t){this.wildcardHandlers.delete(n);return}return}if(!this.events.has(e))return;const s=this.events.get(e),i=s.findIndex(n=>n.handler===t);i>-1&&s.splice(i,1),s.length===0&&this.events.delete(e)}offWildcard(e){for(const t of[...this.wildcardHandlers])t.pattern===e&&this.wildcardHandlers.delete(t)}offAll(e){for(const[t,s]of this.events){const i=s.findIndex(n=>n.handler===e);i>-1&&s.splice(i,1),s.length===0&&this.events.delete(t)}for(const t of[...this.wildcardHandlers])t.handler===e&&this.wildcardHandlers.delete(t)}async emit(e,t){const s=[];if(this.events.has(e)){const n=[...this.events.get(e)];for(const r of n){const{handler:a,once:o}=r;o&&this.off(e,a);try{const c=a(t,e);c instanceof Promise&&s.push(c)}catch(c){console.error(`Error in event handler for ${e}:`,c)}}}const i=[];for(const n of[...this.wildcardHandlers])if(this.matchesPattern(e,n.pattern)){const{handler:r,once:a}=n;a&&i.push(n);try{const o=r(t,e);o instanceof Promise&&s.push(o)}catch(o){console.error(`Error in wildcard handler for ${e}:`,o)}}return i.forEach(n=>this.wildcardHandlers.delete(n)),Promise.all(s)}matchesPattern(e,t){return new RegExp("^"+t.replace(/\*/g,".*")+"$").test(e)}clear(){this.events.clear(),this.wildcardHandlers.clear()}getEventNames(){return Array.from(this.events.keys())}getHandlerCount(e){return this.events.has(e)?this.events.get(e).length:0}getWildcardHandlerCount(){return this.wildcardHandlers.size}getTotalHandlerCount(){let e=this.wildcardHandlers.size;for(const t of this.events.values())e+=t.length;return e}}const g=new U;class Y{constructor(e={}){this.calendar=new G({view:e.view||"month",date:e.date||new Date,weekStartsOn:e.weekStartsOn??0,locale:e.locale||"en-US",timeZone:e.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone,...e}),this.state={view:this.calendar.getView(),currentDate:this.calendar.getCurrentDate(),events:[],selectedEvent:null,selectedDate:null,loading:!1,error:null,config:{...e}},this.subscribers=new Set,this.subscribe=this.subscribe.bind(this),this.unsubscribe=this.unsubscribe.bind(this),this.setState=this.setState.bind(this),this._syncEventsFromCore({silent:!0})}_syncEventsFromCore(e={}){const t=this.calendar.getEvents()||[];return(this.state.events.length!==t.length||!this._eventsMatch(this.state.events,t))&&this.setState({events:[...t]},e),t}_eventsMatch(e,t){if(e.length!==t.length)return!1;const s=new Set(e.map(i=>i.id));return t.every(i=>s.has(i.id))}getState(){return{...this.state}}setState(e,t={}){const{silent:s=!1}=t,i={...this.state};return this.state={...this.state,...e},s||(this.notifySubscribers(i,this.state),this.emitStateChange(i,this.state)),this.state}subscribe(e,t=null){return this.subscribers.add(e),t&&(this._subscriberIds||(this._subscriberIds=new Map),this._subscriberIds.set(t,e)),()=>this.unsubscribe(e,t)}unsubscribe(e,t=null){this.subscribers.delete(e),t&&this._subscriberIds&&this._subscriberIds.delete(t)}unsubscribeById(e){if(!this._subscriberIds)return!1;const t=this._subscriberIds.get(e);return t?(this.subscribers.delete(t),this._subscriberIds.delete(e),!0):!1}getSubscriberCount(){return this.subscribers.size}notifySubscribers(e,t){this.subscribers.forEach(s=>{try{s(t,e)}catch(i){console.error("Error in state subscriber:",i)}})}emitStateChange(e,t){const s=Object.keys(t).filter(i=>e[i]!==t[i]);s.forEach(i=>{g.emit(`state:${i}:changed`,{oldValue:e[i],newValue:t[i],state:t})}),s.length>0&&g.emit("state:changed",{oldState:e,newState:t,changedKeys:s})}setView(e){this.calendar.setView(e),this.setState({view:e}),g.emit("view:changed",{view:e})}getView(){return this.state.view}setDate(e){this.calendar.goToDate(e),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("date:changed",{date:this.state.currentDate})}getCurrentDate(){return this.state.currentDate}next(){this.calendar.next(),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:next",{date:this.state.currentDate})}previous(){this.calendar.previous(),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:previous",{date:this.state.currentDate})}today(){this.calendar.today(),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:today",{date:this.state.currentDate})}goToDate(e){this.calendar.goToDate(e),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:goto",{date:this.state.currentDate})}addEvent(e){const t=this.calendar.addEvent(e);return t?(this._syncEventsFromCore(),g.emit("event:added",{event:t}),t):(console.error("Failed to add event to calendar"),g.emit("event:error",{action:"add",event:e,error:"Failed to add event"}),null)}updateEvent(e,t){this._syncEventsFromCore({silent:!0});const s=this.calendar.updateEvent(e,t);return s?(this._syncEventsFromCore(),g.emit("event:updated",{event:s}),s):(console.error(`Failed to update event: ${e}`),g.emit("event:error",{action:"update",eventId:e,updates:t,error:"Event not found in calendar"}),null)}deleteEvent(e){return this._syncEventsFromCore({silent:!0}),this.calendar.removeEvent(e)?(this._syncEventsFromCore(),g.emit("event:deleted",{eventId:e}),!0):(console.error(`Failed to delete event: ${e}`),g.emit("event:error",{action:"delete",eventId:e,error:"Event not found"}),!1)}getEvents(){return this.calendar.getEvents()||[]}syncEvents(){return this._syncEventsFromCore()}getEventsForDate(e){return this.calendar.getEventsForDate(e)}getEventsInRange(e,t){return this.calendar.getEventsInRange(e,t)}getViewData(){const e=this.calendar.getViewData();return this.enrichViewData(e)}enrichViewData(e){var s;const t=(s=this.state.selectedDate)==null?void 0:s.toDateString();if(e.weeks&&(e.weeks=e.weeks.map(i=>({...i,days:i.days.map(n=>{const r=new Date(n.date);return{...n,isSelected:r.toDateString()===t,events:n.events||this.getEventsForDate(r)}})}))),e.days&&(e.days=e.days.map(i=>{const n=new Date(i.date);return{...i,isSelected:n.toDateString()===t,events:i.events||this.getEventsForDate(n)}})),e.date&&!e.days&&!e.weeks){const i=new Date(e.date);e.isSelected=i.toDateString()===t,e.events=e.events||this.getEventsForDate(i)}return e}selectEvent(e){this.setState({selectedEvent:e}),g.emit("event:selected",{event:e})}selectEventById(e){const t=this.state.events.find(s=>s.id===e);t&&this.selectEvent(t)}deselectEvent(){this.setState({selectedEvent:null}),g.emit("event:deselected",{})}selectDate(e){this.setState({selectedDate:e}),g.emit("date:selected",{date:e})}deselectDate(){this.setState({selectedDate:null}),g.emit("date:deselected",{})}isToday(e){const t=new Date;return e.toDateString()===t.toDateString()}isSelectedDate(e){return this.state.selectedDate&&e.toDateString()===this.state.selectedDate.toDateString()}isWeekend(e){const t=e.getDay();return t===0||t===6}setLoading(e){this.setState({loading:e})}setError(e){this.setState({error:e}),e&&g.emit("error",{error:e})}clearError(){this.setState({error:null})}updateConfig(e){this.setState({config:{...this.state.config,...e}}),e.weekStartsOn!==void 0&&this.calendar.setWeekStartsOn(e.weekStartsOn),e.locale!==void 0&&this.calendar.setLocale(e.locale),e.timeZone!==void 0&&this.calendar.setTimezone(e.timeZone)}destroy(){this.subscribers.clear(),this._subscriberIds&&(this._subscriberIds.clear(),this._subscriberIds=null),this.state=null,this.calendar=null}}class k extends f{static formatDate(e,t="default",s="en-US"){if(!e)return"";const i={default:{year:"numeric",month:"long",day:"numeric"},short:{year:"numeric",month:"short",day:"numeric"},long:{weekday:"long",year:"numeric",month:"long",day:"numeric"},month:{year:"numeric",month:"long"},monthShort:{year:"numeric",month:"short"},day:{weekday:"long",day:"numeric"},dayShort:{weekday:"short",day:"numeric"},time:{hour:"numeric",minute:"2-digit"},timeShort:{hour:"numeric"},datetime:{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}},n=i[t]||i.default;return new Intl.DateTimeFormat(s,n).format(e)}static formatTime(e,t=!0,s=!1,i="en-US"){if(!e)return"";const n={hour:"numeric",minute:t?"2-digit":void 0,hour12:!s};return new Intl.DateTimeFormat(i,n).format(e)}static formatDateRange(e,t,s="en-US"){if(!e)return"";if(!t||this.isSameDay(e,t))return this.formatDate(e,"default",s);const i=this.isSameYear(e,t)?"short":"default";return`${this.formatDate(e,i,s)} - ${this.formatDate(t,"default",s)}`}static formatTimeRange(e,t,s="en-US"){if(!e)return"";const i=this.formatTime(e,!0,!1,s);if(!t)return i;const n=this.formatTime(t,!0,!1,s);return`${i} - ${n}`}static getRelativeTime(e,t=new Date,s="en-US"){const i=new Intl.RelativeTimeFormat(s,{numeric:"auto"}),n=e-t,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),c=Math.floor(o/24),l=Math.floor(c/7),d=Math.floor(c/30),h=Math.floor(c/365);return Math.abs(r)<60?i.format(r,"second"):Math.abs(a)<60?i.format(a,"minute"):Math.abs(o)<24?i.format(o,"hour"):Math.abs(c)<7?i.format(c,"day"):Math.abs(l)<4?i.format(l,"week"):Math.abs(d)<12?i.format(d,"month"):i.format(h,"year")}static isToday(e){const t=new Date;return this.isSameDay(e,t)}static isPast(e){return e<new Date}static isFuture(e){return e>new Date}static getWeekNumber(e){const t=new Date(e.getFullYear(),0,1),s=(e-t)/864e5;return Math.ceil((s+t.getDay()+1)/7)}static getDayAbbreviation(e,t="en-US"){const s=new Date(2024,0,7+e);return new Intl.DateTimeFormat(t,{weekday:"short"}).format(s)}static getMonthName(e,t="long",s="en-US"){const i=new Date(2024,e,1);return new Intl.DateTimeFormat(s,{month:t}).format(i)}static parseTimeString(e,t=new Date){const s=new Date(t),[i,n]=e.split(/\s+/),[r,a]=i.split(":").map(Number);let o=r;return n&&(n.toLowerCase()==="pm"&&r<12?o=r+12:n.toLowerCase()==="am"&&r===12&&(o=0)),s.setHours(o,a||0,0,0),s}}class z{static createElement(e,t={},s=[]){const i=document.createElement(e);return Object.entries(t).forEach(([n,r])=>{if(n==="className")i.className=r;else if(n==="style"&&typeof r=="object")Object.assign(i.style,r);else if(n.startsWith("data-"))i.setAttribute(n,r);else if(n.startsWith("on")&&typeof r=="function"){const a=n.slice(2).toLowerCase();i.addEventListener(a,r)}else i[n]=r}),s.forEach(n=>{typeof n=="string"?i.appendChild(document.createTextNode(n)):n instanceof Node&&i.appendChild(n)}),i}static addEventListeners(e,t){return Object.entries(t).forEach(([s,i])=>{e.addEventListener(s,i)}),()=>{Object.entries(t).forEach(([s,i])=>{e.removeEventListener(s,i)})}}static delegate(e,t,s,i){const n=r=>{const a=r.target.closest(t);a&&e.contains(a)&&i.call(a,r)};return e.addEventListener(s,n),()=>e.removeEventListener(s,n)}static getPosition(e){const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX,bottom:t.bottom+window.scrollY,right:t.right+window.scrollX,width:t.width,height:t.height}}static isInViewport(e,t=0){const s=e.getBoundingClientRect();return s.top>=-t&&s.left>=-t&&s.bottom<=(window.innerHeight||document.documentElement.clientHeight)+t&&s.right<=(window.innerWidth||document.documentElement.clientWidth)+t}static scrollToElement(e,t={}){const{behavior:s="smooth",block:i="start",inline:n="nearest"}=t;e.scrollIntoView({behavior:s,block:i,inline:n})}static getStyle(e,t){return window.getComputedStyle(e).getPropertyValue(t)}static setStyles(e,t){Object.assign(e.style,t)}static async animateClass(e,t,s=300){e.classList.add(t),await this.wait(s),e.classList.remove(t)}static waitForAnimation(e,t="animationend"){return new Promise(s=>{const i=()=>{e.removeEventListener(t,i),s()};e.addEventListener(t,i)})}static wait(e){return new Promise(t=>setTimeout(t,e))}static parseHTML(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}static escapeHTML(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}static debounce(e,t=250){let s;return function(...n){const r=()=>{clearTimeout(s),e(...n)};clearTimeout(s),s=setTimeout(r,t)}}static throttle(e,t=250){let s;return function(...i){s||(e.apply(this,i),s=!0,setTimeout(()=>s=!1,t))}}static closest(e,t){return e.closest(t)}static parents(e,t){const s=[];let i=e.parentElement;for(;i;)i.matches(t)&&s.push(i),i=i.parentElement;return s}static getOuterDimensions(e){const t=window.getComputedStyle(e),s={top:parseInt(t.marginTop),right:parseInt(t.marginRight),bottom:parseInt(t.marginBottom),left:parseInt(t.marginLeft)};return{width:e.offsetWidth+s.left+s.right,height:e.offsetHeight+s.top+s.bottom,margin:s}}static cloneWithEvents(e,t=!0){return e.cloneNode(t)}static trapFocus(e){const t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(t.length===0)return e.setAttribute("tabindex","-1"),e.focus(),()=>e.removeAttribute("tabindex");const s=t[0],i=t[t.length-1],n=r=>{r.key==="Tab"&&(r.shiftKey?document.activeElement===s&&(i==null||i.focus(),r.preventDefault()):document.activeElement===i&&(s==null||s.focus(),r.preventDefault()))};return e.addEventListener("keydown",n),s==null||s.focus(),()=>e.removeEventListener("keydown",n)}}class T{static getCSSVariable(e,t=document.documentElement){return getComputedStyle(t).getPropertyValue(e).trim()}static setCSSVariables(e,t=document.documentElement){Object.entries(e).forEach(([s,i])=>{t.style.setProperty(s,i)})}static getBaseStyles(){return`
15
+ `,t=this.template();this.shadowRoot.innerHTML=e+t,this.afterRender()}template(){return""}afterRender(){}$(e){return this.shadowRoot.querySelector(e)}$$(e){return this.shadowRoot.querySelectorAll(e)}static get observedAttributes(){return[]}attributeChangedCallback(e,t,s){this.setProp(e,s),this._initialized&&this.render()}}class M{constructor(){this.timezones={UTC:{offset:0,dst:null},GMT:{offset:0,dst:null},"Africa/Abidjan":{offset:0,dst:null},"Africa/Accra":{offset:0,dst:null},"Africa/Addis_Ababa":{offset:180,dst:null},"Africa/Algiers":{offset:60,dst:null},"Africa/Cairo":{offset:120,dst:null},"Africa/Casablanca":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Africa/Johannesburg":{offset:120,dst:null},"Africa/Lagos":{offset:60,dst:null},"Africa/Nairobi":{offset:180,dst:null},"America/Anchorage":{offset:-540,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Argentina/Buenos_Aires":{offset:-180,dst:null},"America/Bogota":{offset:-300,dst:null},"America/Caracas":{offset:-240,dst:null},"America/Chicago":{offset:-360,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Denver":{offset:-420,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Detroit":{offset:-300,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Halifax":{offset:-240,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Los_Angeles":{offset:-480,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Mexico_City":{offset:-360,dst:{start:{month:4,week:1,day:0},end:{month:10,week:-1,day:0},offset:60}},"America/New_York":{offset:-300,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Phoenix":{offset:-420,dst:null},"America/Regina":{offset:-360,dst:null},"America/Santiago":{offset:-180,dst:{start:{month:9,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"America/Sao_Paulo":{offset:-180,dst:{start:{month:10,week:3,day:0},end:{month:2,week:3,day:0},offset:60}},"America/St_Johns":{offset:-210,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Toronto":{offset:-300,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"America/Vancouver":{offset:-480,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"Asia/Baghdad":{offset:180,dst:null},"Asia/Bangkok":{offset:420,dst:null},"Asia/Dubai":{offset:240,dst:null},"Asia/Hong_Kong":{offset:480,dst:null},"Asia/Jakarta":{offset:420,dst:null},"Asia/Jerusalem":{offset:120,dst:{start:{month:3,week:-1,day:5},end:{month:10,week:-1,day:0},offset:60}},"Asia/Karachi":{offset:300,dst:null},"Asia/Kolkata":{offset:330,dst:null},"Asia/Kuala_Lumpur":{offset:480,dst:null},"Asia/Manila":{offset:480,dst:null},"Asia/Seoul":{offset:540,dst:null},"Asia/Shanghai":{offset:480,dst:null},"Asia/Singapore":{offset:480,dst:null},"Asia/Taipei":{offset:480,dst:null},"Asia/Tehran":{offset:210,dst:{start:{month:3,week:4,day:0},end:{month:9,week:4,day:0},offset:60}},"Asia/Tokyo":{offset:540,dst:null},"Atlantic/Azores":{offset:-60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Atlantic/Bermuda":{offset:-240,dst:{start:{month:3,week:2,day:0},end:{month:11,week:1,day:0},offset:60}},"Atlantic/Reykjavik":{offset:0,dst:null},"Australia/Adelaide":{offset:570,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Australia/Brisbane":{offset:600,dst:null},"Australia/Darwin":{offset:570,dst:null},"Australia/Hobart":{offset:600,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Australia/Melbourne":{offset:600,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Australia/Perth":{offset:480,dst:null},"Australia/Sydney":{offset:600,dst:{start:{month:10,week:1,day:0},end:{month:4,week:1,day:0},offset:60}},"Europe/Amsterdam":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Athens":{offset:120,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Berlin":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Brussels":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Budapest":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Copenhagen":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Dublin":{offset:0,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Helsinki":{offset:120,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Istanbul":{offset:180,dst:null},"Europe/Kiev":{offset:120,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Lisbon":{offset:0,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/London":{offset:0,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Madrid":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Moscow":{offset:180,dst:null},"Europe/Oslo":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Paris":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Prague":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Rome":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Stockholm":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Vienna":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Warsaw":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Europe/Zurich":{offset:60,dst:{start:{month:3,week:-1,day:0},end:{month:10,week:-1,day:0},offset:60}},"Indian/Maldives":{offset:300,dst:null},"Indian/Mauritius":{offset:240,dst:null},"Pacific/Auckland":{offset:720,dst:{start:{month:9,week:-1,day:0},end:{month:4,week:1,day:0},offset:60}},"Pacific/Fiji":{offset:720,dst:{start:{month:11,week:1,day:0},end:{month:1,week:3,day:0},offset:60}},"Pacific/Guam":{offset:600,dst:null},"Pacific/Honolulu":{offset:-600,dst:null},"Pacific/Midway":{offset:-660,dst:null},"Pacific/Noumea":{offset:660,dst:null},"Pacific/Pago_Pago":{offset:-660,dst:null},"Pacific/Port_Moresby":{offset:600,dst:null},"Pacific/Tahiti":{offset:-600,dst:null}},this.aliases={EST:"America/New_York",EDT:"America/New_York",CST:"America/Chicago",CDT:"America/Chicago",MST:"America/Denver",MDT:"America/Denver",PST:"America/Los_Angeles",PDT:"America/Los_Angeles",AKST:"America/Anchorage",AKDT:"America/Anchorage",HST:"Pacific/Honolulu",AST:"America/Halifax",ADT:"America/Halifax",NST:"America/St_Johns",NDT:"America/St_Johns",BST:"Europe/London",IST:"Asia/Kolkata",WET:"Europe/Lisbon",WEST:"Europe/Lisbon",CET:"Europe/Paris",CEST:"Europe/Paris",EET:"Europe/Athens",EEST:"Europe/Athens",MSK:"Europe/Moscow",JST:"Asia/Tokyo",KST:"Asia/Seoul",CST_CN:"Asia/Shanghai",HKT:"Asia/Hong_Kong",SGT:"Asia/Singapore",AEST:"Australia/Sydney",AEDT:"Australia/Sydney",ACST:"Australia/Adelaide",ACDT:"Australia/Adelaide",AWST:"Australia/Perth",NZST:"Pacific/Auckland",NZDT:"Pacific/Auckland","US/Eastern":"America/New_York","US/Central":"America/Chicago","US/Mountain":"America/Denver","US/Pacific":"America/Los_Angeles","US/Alaska":"America/Anchorage","US/Hawaii":"Pacific/Honolulu","Canada/Eastern":"America/Toronto","Canada/Central":"America/Regina","Canada/Mountain":"America/Denver","Canada/Pacific":"America/Vancouver","Canada/Atlantic":"America/Halifax","Canada/Newfoundland":"America/St_Johns","Mexico/General":"America/Mexico_City","Brazil/East":"America/Sao_Paulo","Chile/Continental":"America/Santiago",GB:"Europe/London","GB-Eire":"Europe/London",Eire:"Europe/Dublin",Israel:"Asia/Jerusalem",Japan:"Asia/Tokyo",Singapore:"Asia/Singapore",Hongkong:"Asia/Hong_Kong",ROK:"Asia/Seoul",PRC:"Asia/Shanghai","Australia/NSW":"Australia/Sydney","Australia/Victoria":"Australia/Melbourne","Australia/Queensland":"Australia/Brisbane","Australia/South":"Australia/Adelaide","Australia/Tasmania":"Australia/Hobart","Australia/West":"Australia/Perth","Australia/North":"Australia/Darwin",NZ:"Pacific/Auckland"}}getTimezone(e){return this.aliases[e]&&(e=this.aliases[e]),this.timezones[e]||null}getAllTimezones(){return Object.keys(this.timezones)}isValidTimezone(e){return this.aliases[e]!==void 0||this.timezones[e]!==void 0}resolveAlias(e){return this.aliases[e]||e}getTimezonesByOffset(e){return Object.entries(this.timezones).filter(([t,s])=>s.offset===e).map(([t,s])=>t)}getCommonTimezones(){return{Americas:["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Mexico_City","America/Sao_Paulo"],Europe:["Europe/London","Europe/Paris","Europe/Berlin","Europe/Moscow","Europe/Rome","Europe/Madrid","Europe/Amsterdam"],Asia:["Asia/Tokyo","Asia/Shanghai","Asia/Hong_Kong","Asia/Singapore","Asia/Kolkata","Asia/Dubai","Asia/Seoul"],"Australia/Pacific":["Australia/Sydney","Australia/Melbourne","Australia/Brisbane","Australia/Perth","Pacific/Auckland","Pacific/Honolulu"],Africa:["Africa/Cairo","Africa/Lagos","Africa/Johannesburg","Africa/Nairobi"]}}}let A=null;class I{static getInstance(){return A||(A=new I),A}static _resetInstance(){A&&A.clearCache(),A=null}constructor(){this.database=new M,this.offsetCache=new Map,this.dstCache=new Map,this.maxCacheSize=1e3,this.cacheHits=0,this.cacheMisses=0}convertTimezone(e,t,s){if(!e)return null;if(t===s)return new Date(e);const i=this.getTimezoneOffset(e,t),n=(this.getTimezoneOffset(e,s)-i)*60*1e3;return new Date(e.getTime()+n)}toUTC(e,t){if(!e)return null;if(t==="UTC")return new Date(e);const s=this.getTimezoneOffset(e,t);return new Date(e.getTime()+s*60*1e3)}fromUTC(e,t){if(!e)return null;if(t==="UTC")return new Date(e);const s=this.getTimezoneOffset(e,t);return new Date(e.getTime()-s*60*1e3)}getTimezoneOffset(e,t){t=this.database.resolveAlias(t);const s=`${t}_${e.getFullYear()}_${e.getMonth()}_${e.getDate()}`;if(this.offsetCache.has(s))return this.cacheHits++,this._manageCacheSize(),this.offsetCache.get(s);if(this.cacheMisses++,typeof Intl<"u"&&Intl.DateTimeFormat)try{const a=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),c=(new Date(a.find(l=>l.type==="year").value,a.find(l=>l.type==="month").value-1,a.find(l=>l.type==="day").value,a.find(l=>l.type==="hour").value,a.find(l=>l.type==="minute").value,a.find(l=>l.type==="second").value).getTime()-e.getTime())/(1e3*60);return this.offsetCache.set(s,-c),this._manageCacheSize(),-c}catch{}const i=this.database.getTimezone(t);if(!i)throw new Error(`Unknown timezone: ${t}`);let r=i.offset;return i.dst&&this.isDST(e,t,i.dst)&&(r+=i.dst.offset),this.offsetCache.set(s,r),this._manageCacheSize(),r}isDST(e,t,s=null){if(!s){const a=this.database.getTimezone(t);if(!a||!a.dst)return!1;s=a.dst}const i=e.getFullYear(),r=this.getNthWeekdayOfMonth(i,s.start.month,s.start.week,s.start.day),n=this.getNthWeekdayOfMonth(i,s.end.month,s.end.week,s.end.day);return r>n?e>=r||e<n:e>=r&&e<n}getNthWeekdayOfMonth(e,t,s,i){const r=new Date(e,t,1),n=r.getDay();let a=i-n;if(a<0&&(a+=7),s>0)r.setDate(1+a+(s-1)*7);else{const o=new Date(e,t+1,0).getDate();r.setDate(o);let l=r.getDay()-i;l<0&&(l+=7),r.setDate(o-l+(s+1)*7)}return r}getCommonTimezones(){const e=new Date;return[{value:"America/New_York",label:"Eastern Time (New York)",region:"Americas"},{value:"America/Chicago",label:"Central Time (Chicago)",region:"Americas"},{value:"America/Denver",label:"Mountain Time (Denver)",region:"Americas"},{value:"America/Phoenix",label:"Mountain Time - Arizona (Phoenix)",region:"Americas"},{value:"America/Los_Angeles",label:"Pacific Time (Los Angeles)",region:"Americas"},{value:"America/Anchorage",label:"Alaska Time (Anchorage)",region:"Americas"},{value:"Pacific/Honolulu",label:"Hawaii Time (Honolulu)",region:"Pacific"},{value:"America/Toronto",label:"Eastern Time (Toronto)",region:"Americas"},{value:"America/Vancouver",label:"Pacific Time (Vancouver)",region:"Americas"},{value:"America/Mexico_City",label:"Central Time (Mexico City)",region:"Americas"},{value:"America/Sao_Paulo",label:"Brasilia Time (São Paulo)",region:"Americas"},{value:"Europe/London",label:"GMT/BST (London)",region:"Europe"},{value:"Europe/Paris",label:"Central European Time (Paris)",region:"Europe"},{value:"Europe/Berlin",label:"Central European Time (Berlin)",region:"Europe"},{value:"Europe/Moscow",label:"Moscow Time",region:"Europe"},{value:"Asia/Dubai",label:"Gulf Time (Dubai)",region:"Asia"},{value:"Asia/Kolkata",label:"India Time (Mumbai)",region:"Asia"},{value:"Asia/Shanghai",label:"China Time (Shanghai)",region:"Asia"},{value:"Asia/Tokyo",label:"Japan Time (Tokyo)",region:"Asia"},{value:"Asia/Seoul",label:"Korea Time (Seoul)",region:"Asia"},{value:"Asia/Singapore",label:"Singapore Time",region:"Asia"},{value:"Australia/Sydney",label:"Australian Eastern Time (Sydney)",region:"Oceania"},{value:"Australia/Melbourne",label:"Australian Eastern Time (Melbourne)",region:"Oceania"},{value:"Pacific/Auckland",label:"New Zealand Time (Auckland)",region:"Oceania"},{value:"UTC",label:"UTC",region:"UTC"}].map(s=>{const i=this.getTimezoneOffset(e,s.value),r=-i/60,n=Math.floor(Math.abs(r)),a=Math.round(Math.abs(r%1)*60),c=`UTC${r>=0?"+":"-"}${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;return{...s,offset:c,offsetMinutes:-i}}).sort((s,i)=>s.offsetMinutes-i.offsetMinutes)}formatInTimezone(e,t,s={}){if(!e)return"";const r={...{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:t},...s};try{return new Intl.DateTimeFormat("en-US",r).format(e)}catch{return this.fromUTC(this.toUTC(e,"UTC"),t).toLocaleString("en-US",s)}}getSystemTimezone(){if(typeof Intl<"u"&&Intl.DateTimeFormat)try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}const t=-new Date().getTimezoneOffset()/60;for(const[s,i]of Object.entries(this.database.timezones))if(i.offset/60===t)return s;return"UTC"}parseTimezone(e){if(!e)return"UTC";if(Object.prototype.hasOwnProperty.call(this.database.timezones,e))return e;const t=e.toUpperCase();if(this.database.abbreviations&&Object.prototype.hasOwnProperty.call(this.database.abbreviations,t))return this.database.abbreviations[t];const s=e.match(/^([+-])(\d{2}):?(\d{2})$/);if(s){const i=s[1]==="+"?1:-1,r=parseInt(s[2],10),n=parseInt(s[3],10),a=i*(r+n/60);for(const[o,c]of Object.entries(this.database.timezones))if(c.offset/60===a)return o}return"UTC"}getTimezoneDifference(e,t,s=new Date){const i=this.getTimezoneOffset(s,e);return(this.getTimezoneOffset(s,t)-i)/60}clearCache(){this.offsetCache.clear(),this.dstCache.clear(),this.cacheHits=0,this.cacheMisses=0}isValidTimezone(e){return this.database.isValidTimezone(e)}getCacheStats(){const e=this.cacheHits+this.cacheMisses>0?(this.cacheHits/(this.cacheHits+this.cacheMisses)*100).toFixed(2):0;return{offsetCacheSize:this.offsetCache.size,dstCacheSize:this.dstCache.size,maxCacheSize:this.maxCacheSize,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,hitRate:`${e}%`}}_manageCacheSize(){if(this.offsetCache.size>this.maxCacheSize){const e=Math.floor(this.offsetCache.size/2),t=Array.from(this.offsetCache.keys());for(let s=0;s<e;s++)this.offsetCache.delete(t[s])}if(this.dstCache.size>this.maxCacheSize/2){const e=Math.floor(this.dstCache.size/2),t=Array.from(this.dstCache.keys());for(let s=0;s<e;s++)this.dstCache.delete(t[s])}}}class x{static normalize(e){const t={...e};return t.start&&(t.start=new Date(t.start)),t.end&&(t.end=new Date(t.end)),t.end||(t.end=t.start?new Date(t.start):null),t.allDay&&t.start&&(t.start.setHours(0,0,0,0),t.end&&t.end.setHours(23,59,59,999)),t.id=String(t.id||"").trim(),t.title=String(t.title||"").trim(),t.description=String(t.description||"").trim(),t.location=String(t.location||"").trim(),t.attendees=Array.isArray(t.attendees)?t.attendees:[],t.reminders=Array.isArray(t.reminders)?t.reminders:[],e.category&&!e.categories?t.categories=[e.category]:t.categories?t.categories=Array.isArray(t.categories)?t.categories:[]:t.categories=[],t.attachments=Array.isArray(t.attachments)?t.attachments:[],t.recurrence&&!t.recurrenceRule&&(t.recurrenceRule=t.recurrence),t.recurrenceRule&&(t.recurring=!0),["confirmed","tentative","cancelled"].includes(t.status)||(t.status="confirmed"),["public","private","confidential"].includes(t.visibility)||(t.visibility="public"),t.color&&!t.backgroundColor&&(t.backgroundColor=t.color),t.color&&!t.borderColor&&(t.borderColor=t.color),t}static validate(e){if(!e.id)throw new Error("Event must have an id");if(!e.title)throw new Error("Event must have a title");if(!e.start)throw new Error("Event must have a start date");if(!(e.start instanceof Date)||isNaN(e.start.getTime()))throw new Error("Invalid start date");if(e.end&&(!(e.end instanceof Date)||isNaN(e.end.getTime())))throw new Error("Invalid end date");if(e.end&&e.start&&e.end<e.start)throw new Error("Event end time cannot be before start time");if(e.recurring&&!e.recurrenceRule)throw new Error("Recurring events must have a recurrence rule");if(e.attendees&&e.attendees.length>0&&e.attendees.forEach((t,s)=>{if(!t.email||!t.name)throw new Error(`Attendee at index ${s} must have email and name`);if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.email))throw new Error(`Invalid email for attendee: ${t.email}`)}),e.reminders&&e.reminders.length>0&&e.reminders.forEach((t,s)=>{if(!t.method||t.minutesBefore==null)throw new Error(`Reminder at index ${s} must have method and minutesBefore`);if(t.minutesBefore<0)throw new Error("Reminder minutesBefore must be non-negative")}),e.timeZone)try{new Intl.DateTimeFormat("en-US",{timeZone:e.timeZone})}catch{throw new Error(`Invalid timezone: ${e.timeZone}`)}}constructor({id:e,title:t,start:s,end:i,allDay:r=!1,description:n="",location:a="",color:o=null,backgroundColor:c=null,borderColor:l=null,textColor:h=null,recurring:d=!1,recurrenceRule:p=null,recurrence:w=null,timeZone:D=null,endTimeZone:_=null,status:k="confirmed",visibility:C="public",organizer:$=null,attendees:O=[],reminders:J=[],category:X,categories:ee,attachments:te=[],conferenceData:se=null,metadata:ie={},...re}){const u=x.normalize({id:e,title:t,start:s,end:i,allDay:r,description:n,location:a,color:o,backgroundColor:c,borderColor:l,textColor:h,recurring:d,recurrenceRule:p,recurrence:w,timeZone:D,endTimeZone:_,status:k,visibility:C,organizer:$,attendees:O,reminders:J,category:X,categories:ee,attachments:te,conferenceData:se,metadata:ie,...re});x.validate(u),this.id=u.id,this.title=u.title,this._timezoneManager=I.getInstance(),this.timeZone=u.timeZone||this._timezoneManager.getSystemTimezone(),this.endTimeZone=u.endTimeZone||this.timeZone,this.start=u.start,this.end=u.end,this.startUTC=this._timezoneManager.toUTC(this.start,this.timeZone),this.endUTC=this._timezoneManager.toUTC(this.end,this.endTimeZone),this.allDay=u.allDay,this.description=u.description,this.location=u.location,this.color=u.color,this.backgroundColor=u.backgroundColor,this.borderColor=u.borderColor,this.textColor=u.textColor,this.recurring=u.recurring,this.recurrenceRule=u.recurrenceRule,this._originalTimeZone=u.timeZone||null,this.status=u.status,this.visibility=u.visibility,this.organizer=u.organizer,this.attendees=[...u.attendees],this.reminders=[...u.reminders],this.categories=u.categories?[...u.categories]:[],this.attachments=[...u.attachments],this.conferenceData=u.conferenceData,this.metadata={...u.metadata},this._cache={},this._validateAttendees(),this._validateReminders()}get duration(){return this._cache.duration||(this._cache.duration=this.endUTC.getTime()-this.startUTC.getTime()),this._cache.duration}getStartInTimezone(e){return e===this.timeZone?new Date(this.start):this._timezoneManager.fromUTC(this.startUTC,e)}getEndInTimezone(e){return e===this.endTimeZone?new Date(this.end):this._timezoneManager.fromUTC(this.endUTC,e)}updateTimes(e,t,s){if(s||this.timeZone,this.start=e instanceof Date?e:new Date(e),this.end=t instanceof Date?t:new Date(t),s&&(this.timeZone=s,this.endTimeZone=s),this.startUTC=this._timezoneManager.toUTC(this.start,this.timeZone),this.endUTC=this._timezoneManager.toUTC(this.end,this.endTimeZone),this._cache={},this.endUTC<this.startUTC)throw new Error("Event end time cannot be before start time")}get durationMinutes(){return Math.floor(this.duration/(1e3*60))}get durationHours(){return this.duration/(1e3*60*60)}get isMultiDay(){if(!Object.prototype.hasOwnProperty.call(this._cache,"isMultiDay")){const e=this.start.toDateString(),t=this.end.toDateString();this._cache.isMultiDay=e!==t}return this._cache.isMultiDay}isRecurring(){return this.recurring&&this.recurrenceRule!==null}get recurrence(){return this.recurrenceRule}occursOn(e){e instanceof Date||(e=new Date(e));const t=e.toDateString(),s=this.start.toDateString(),i=this.end.toDateString();if(this.allDay)return e>=new Date(s)&&e<=new Date(i);if(this.isMultiDay){const r=new Date(t),n=new Date(t);return n.setHours(23,59,59,999),this.start<=n&&this.end>=r}return s===t}overlaps(e){if(e instanceof x)return!(this.end<=e.start||this.start>=e.end);if(e&&e.start&&e.end)return!(this.end<=e.start||this.start>=e.end);throw new Error("Parameter must be an Event instance or have start/end properties")}contains(e){return e instanceof Date||(e=new Date(e)),e>=this.start&&e<=this.end}clone(e={}){return new x({id:this.id,title:this.title,start:new Date(this.start),end:new Date(this.end),allDay:this.allDay,description:this.description,location:this.location,color:this.color,backgroundColor:this.backgroundColor,borderColor:this.borderColor,textColor:this.textColor,recurring:this.recurring,recurrenceRule:this.recurrenceRule,recurrence:this.recurrenceRule,timeZone:this.timeZone,status:this.status,visibility:this.visibility,organizer:this.organizer?{...this.organizer}:null,attendees:this.attendees.map(t=>({...t})),reminders:this.reminders.map(t=>({...t})),categories:[...this.categories],attachments:this.attachments.map(t=>({...t})),conferenceData:this.conferenceData?{...this.conferenceData}:null,metadata:{...this.metadata},...e})}toObject(){return{id:this.id,title:this.title,start:this.start.toISOString(),end:this.end.toISOString(),allDay:this.allDay,description:this.description,location:this.location,color:this.color,backgroundColor:this.backgroundColor,borderColor:this.borderColor,textColor:this.textColor,recurring:this.recurring,recurrenceRule:this.recurrenceRule,timeZone:this.timeZone,status:this.status,visibility:this.visibility,organizer:this.organizer,attendees:this.attendees,reminders:this.reminders,categories:this.categories,attachments:this.attachments,conferenceData:this.conferenceData,metadata:{...this.metadata}}}static fromObject(e){return new x(e)}equals(e){return e instanceof x?this.id===e.id&&this.title===e.title&&this.start.getTime()===e.start.getTime()&&this.end.getTime()===e.end.getTime()&&this.allDay===e.allDay&&this.description===e.description&&this.location===e.location&&this.recurring===e.recurring&&this.recurrenceRule===e.recurrenceRule&&this.status===e.status:!1}addAttendee(e){if(!e||!e.email)throw new Error("Attendee must have an email");return this.hasAttendee(e.email)?!1:(e.id||(e.id=`attendee_${Date.now()}_${Math.random().toString(36).substr(2,9)}`),e.responseStatus=e.responseStatus||"needs-action",e.role=e.role||"required",this.attendees.push(e),!0)}removeAttendee(e){const t=this.attendees.findIndex(s=>s.email===e||s.id===e);return t!==-1?(this.attendees.splice(t,1),!0):!1}updateAttendeeResponse(e,t){const s=this.getAttendee(e);return s?(s.responseStatus=t,s.responseTime=new Date,!0):!1}getAttendee(e){return this.attendees.find(t=>t.email===e)||null}hasAttendee(e){return this.attendees.some(t=>t.email===e)}getAttendeesByStatus(e){return this.attendees.filter(t=>t.responseStatus===e)}getAttendeeCounts(){return this.attendees.reduce((e,t)=>{const s=t.responseStatus||"needs-action";return e[s]=(e[s]||0)+1,e},{})}addReminder(e){if(!e||typeof e.minutesBefore!="number")throw new Error("Reminder must have minutesBefore property");return e.id||(e.id=`reminder_${Date.now()}_${Math.random().toString(36).substr(2,9)}`),e.method=e.method||"popup",e.enabled=e.enabled!==!1,this.reminders.some(s=>s.method===e.method&&s.minutesBefore===e.minutesBefore)?!1:(this.reminders.push(e),!0)}removeReminder(e){const t=this.reminders.findIndex(s=>s.id===e);return t!==-1?(this.reminders.splice(t,1),!0):!1}getActiveReminders(){return this.reminders.filter(e=>e.enabled!==!1)}getReminderTriggerTimes(){return this.getActiveReminders().map(e=>{const t=new Date(this.start);return t.setMinutes(t.getMinutes()-e.minutesBefore),t})}addCategory(e){if(!e||typeof e!="string")throw new Error("Category must be a non-empty string");const t=e.trim().toLowerCase();return this.hasCategory(t)?!1:(this.categories.push(t),!0)}removeCategory(e){const t=e.trim().toLowerCase(),s=this.categories.findIndex(i=>i.toLowerCase()===t);return s!==-1?(this.categories.splice(s,1),!0):!1}get category(){return this.categories&&this.categories.length>0?this.categories[0]:null}hasCategory(e){const t=e.trim().toLowerCase();return this.categories.some(s=>s.toLowerCase()===t)}hasAnyCategory(e){return e.some(t=>this.hasCategory(t))}hasAllCategories(e){return e.every(t=>this.hasCategory(t))}_validateAttendees(){for(const e of this.attendees){if(!e.email)throw new Error("All attendees must have an email address");if(e.name||(e.name=e.email),!this._isValidEmail(e.email))throw new Error(`Invalid attendee email: ${e.email}`)}}_validateReminders(){for(const e of this.reminders){if(typeof e.minutesBefore!="number"||e.minutesBefore<0)throw new Error("Reminder minutesBefore must be a positive number");if(!["email","popup","sms"].includes(e.method))throw new Error(`Invalid reminder method: ${e.method}`)}}_isValidEmail(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}get isCancelled(){return this.status==="cancelled"}get isTentative(){return this.status==="tentative"}get isConfirmed(){return this.status==="confirmed"}get isPrivate(){return this.visibility==="private"}get isPublic(){return this.visibility==="public"}get hasAttendees(){return this.attendees.length>0}get hasReminders(){return this.reminders.length>0}get isMeeting(){return this.hasAttendees||this.conferenceData!==null}get isVirtual(){return this.conferenceData!==null}}let f=class b{static startOfDay(e){const t=new Date(e);return t.setHours(0,0,0,0),t}static endOfDay(e){const t=new Date(e);return t.setHours(23,59,59,999),t}static startOfWeek(e,t=0){const s=new Date(e),i=s.getDay(),r=(i<t?7:0)+i-t;return s.setDate(s.getDate()-r),s.setHours(0,0,0,0),s}static endOfWeek(e,t=0){const s=b.startOfWeek(e,t);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}static startOfMonth(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}static endOfMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}static startOfYear(e){return new Date(e.getFullYear(),0,1,0,0,0,0)}static endOfYear(e){return new Date(e.getFullYear(),11,31,23,59,59,999)}static addDays(e,t){const s=new Date(e);return s.setDate(s.getDate()+t),s}static addWeeks(e,t){return b.addDays(e,t*7)}static addMonths(e,t){const s=new Date(e),i=s.getDate();return s.setMonth(s.getMonth()+t),s.getDate()!==i&&s.setDate(0),s}static addYears(e,t){const s=new Date(e);return s.setFullYear(s.getFullYear()+t),s}static getUTCDateString(e){const t=e.getUTCFullYear(),s=String(e.getUTCMonth()+1).padStart(2,"0"),i=String(e.getUTCDate()).padStart(2,"0");return`${t}-${s}-${i}`}static getLocalDateString(e){const t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${s}-${i}`}static isToday(e){const t=new Date;return e.toDateString()===t.toDateString()}static isPast(e){return e<new Date}static isFuture(e){return e>new Date}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static isSameWeek(e,t,s=0){const i=b.startOfWeek(e,s),r=b.startOfWeek(t,s);return i.toDateString()===r.toDateString()}static isSameMonth(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}static isSameYear(e,t){return e.getFullYear()===t.getFullYear()}static differenceInDays(e,t){const s=e.getTime()-t.getTime();return Math.floor(s/(1e3*60*60*24))}static differenceInWeeks(e,t){return Math.floor(b.differenceInDays(e,t)/7)}static differenceInMonths(e,t){const s=e.getFullYear()-t.getFullYear(),i=e.getMonth()-t.getMonth();return s*12+i}static getWeekNumber(e){const t=new Date(e.getFullYear(),0,1),s=(e-t)/864e5;return Math.ceil((s+t.getDay()+1)/7)}static getDayOfWeek(e,t=0){return(e.getDay()-t+7)%7}static getDaysInMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}static format(e,t="en-US",s={}){return new Intl.DateTimeFormat(t,s).format(e)}static getMonthName(e,t="en-US",s="long"){return b.format(e,t,{month:s})}static getDayName(e,t="en-US",s="long"){return b.format(e,t,{weekday:s})}static formatTime(e,t="en-US",s=!1){return b.format(e,t,{hour:"numeric",minute:"2-digit",hour12:!s})}static parseTime(e){const[t,s]=e.split(":").map(Number);return{hours:t,minutes:s}}static setTime(e,t){const s=new Date(e),{hours:i,minutes:r}=b.parseTime(t);return s.setHours(i,r,0,0),s}static isLeapYear(e){return e%4===0&&e%100!==0||e%400===0}static getDateRange(e,t){const s=[],i=new Date(e),r=t.getTime();for(;i.getTime()<=r;)s.push(new Date(i)),i.setDate(i.getDate()+1);return s}static clone(e){return new Date(e)}static isValidDate(e){return e instanceof Date&&!isNaN(e.getTime())}static toTimeZone(e,t){const i=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),r={};return i.forEach(n=>{n.type!=="literal"&&(r[n.type]=n.value)}),new Date(`${r.year}-${r.month}-${r.day}T${r.hour}:${r.minute}:${r.second}`)}static getTimezoneOffset(e,t){const s=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),i=new Date(e.toLocaleString("en-US",{timeZone:t}));return(s.getTime()-i.getTime())/6e4}static isDST(e,t){const s=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear(),6,1),r=b.getTimezoneOffset(s,t),n=b.getTimezoneOffset(i,t),a=b.getTimezoneOffset(e,t);return Math.max(r,n)===a}static addHoursWithDST(e,t,s){const i=new Date(e),r=b.getTimezoneOffset(e,s);i.setTime(i.getTime()+t*60*60*1e3);const n=b.getTimezoneOffset(i,s);if(r!==n){const a=(n-r)*6e4;i.setTime(i.getTime()+a)}return i}static createInTimeZone(e,t,s,i=0,r=0,n=0,a){const o=`${e}-${String(t+1).padStart(2,"0")}-${String(s).padStart(2,"0")}`,c=`${String(i).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`,l=new Date(`${o}T${c}`),h=b.getTimezoneOffset(l,a),d=l.getTime()+h*6e4;return new Date(d)}};class N{static parse(e){if(typeof e=="object")return this.validateRule(e);const t={freq:null,interval:1,count:null,until:null,byDay:[],byWeekNo:[],byMonth:[],byMonthDay:[],byYearDay:[],bySetPos:[],byHour:[],byMinute:[],bySecond:[],wkst:"MO",exceptions:[],tzid:null},s=e.toUpperCase().split(";");for(const i of s){const[r,n]=i.split("=");switch(r){case"FREQ":t.freq=this.parseFrequency(n);break;case"INTERVAL":t.interval=parseInt(n,10),t.interval<1&&(t.interval=1);break;case"COUNT":t.count=parseInt(n,10);break;case"UNTIL":t.until=this.parseDateTime(n);break;case"BYDAY":t.byDay=this.parseByDay(n);break;case"BYWEEKNO":t.byWeekNo=this.parseIntList(n);break;case"BYMONTH":t.byMonth=this.parseIntList(n);break;case"BYMONTHDAY":t.byMonthDay=this.parseIntList(n);break;case"BYYEARDAY":t.byYearDay=this.parseIntList(n);break;case"BYSETPOS":t.bySetPos=this.parseIntList(n);break;case"BYHOUR":t.byHour=this.parseIntList(n);break;case"BYMINUTE":t.byMinute=this.parseIntList(n);break;case"BYSECOND":t.bySecond=this.parseIntList(n);break;case"WKST":t.wkst=n;break;case"EXDATE":t.exceptions=this.parseExceptionDates(n);break;case"TZID":t.tzid=n;break}}return this.validateRule(t)}static parseFrequency(e){return["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"].includes(e)?e:"DAILY"}static parseByDay(e){const t=e.split(","),s=["SU","MO","TU","WE","TH","FR","SA"],i=[];for(const r of t){const a=r.trim().toUpperCase().match(/^([+-]?\d*)([A-Z]{2})$/);if(a){const[o,c,l]=a;s.includes(l)&&i.push(c?`${c}${l}`:l)}}return i}static parseIntList(e){return e.split(",").map(t=>parseInt(t.trim(),10)).filter(t=>!isNaN(t))}static parseDateTime(e){if(e.length===8){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10);return new Date(t,s,i)}if(e.length===15&&e[8]==="T"){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),r=parseInt(e.substr(9,2),10),n=parseInt(e.substr(11,2),10),a=parseInt(e.substr(13,2),10);return new Date(t,s,i,r,n,a)}if(e.length===16&&e[8]==="T"&&e[15]==="Z"){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),r=parseInt(e.substr(9,2),10),n=parseInt(e.substr(11,2),10),a=parseInt(e.substr(13,2),10);return new Date(Date.UTC(t,s,i,r,n,a))}return new Date(e)}static parseExceptionDates(e){return e.split(",").map(s=>this.parseDateTime(s.trim()))}static validateRule(e){if(e.freq||(e.freq="DAILY"),e.count&&e.until)throw new Error("RRULE cannot have both COUNT and UNTIL");e.interval<1&&(e.interval=1);const t=(s,i,r)=>s.filter(n=>n>=i&&n<=r);return e.byMonth=t(e.byMonth||[],1,12),e.byMonthDay=t(e.byMonthDay||[],-31,31).filter(s=>s!==0),e.byYearDay=t(e.byYearDay||[],-366,366).filter(s=>s!==0),e.byWeekNo=t(e.byWeekNo||[],-53,53).filter(s=>s!==0),e.byHour=t(e.byHour||[],0,23),e.byMinute=t(e.byMinute||[],0,59),e.bySecond=t(e.bySecond||[],0,59),e}static buildRRule(e){const t=[];if(t.push(`FREQ=${e.freq}`),e.interval&&e.interval>1&&t.push(`INTERVAL=${e.interval}`),e.count?t.push(`COUNT=${e.count}`):e.until&&t.push(`UNTIL=${this.formatDateTime(e.until)}`),e.byDay&&e.byDay.length>0){const s=e.byDay.map(i=>typeof i=="string"?i:i.nth?`${i.nth}${i.weekday}`:i.weekday).join(",");t.push(`BYDAY=${s}`)}return e.byMonth&&e.byMonth.length>0&&t.push(`BYMONTH=${e.byMonth.join(",")}`),e.byMonthDay&&e.byMonthDay.length>0&&t.push(`BYMONTHDAY=${e.byMonthDay.join(",")}`),e.byYearDay&&e.byYearDay.length>0&&t.push(`BYYEARDAY=${e.byYearDay.join(",")}`),e.byWeekNo&&e.byWeekNo.length>0&&t.push(`BYWEEKNO=${e.byWeekNo.join(",")}`),e.bySetPos&&e.bySetPos.length>0&&t.push(`BYSETPOS=${e.bySetPos.join(",")}`),e.byHour&&e.byHour.length>0&&t.push(`BYHOUR=${e.byHour.join(",")}`),e.byMinute&&e.byMinute.length>0&&t.push(`BYMINUTE=${e.byMinute.join(",")}`),e.bySecond&&e.bySecond.length>0&&t.push(`BYSECOND=${e.bySecond.join(",")}`),e.wkst&&e.wkst!=="MO"&&t.push(`WKST=${e.wkst}`),t.join(";")}static formatDateTime(e){const t=e.getUTCFullYear(),s=String(e.getUTCMonth()+1).padStart(2,"0"),i=String(e.getUTCDate()).padStart(2,"0"),r=String(e.getUTCHours()).padStart(2,"0"),n=String(e.getUTCMinutes()).padStart(2,"0"),a=String(e.getUTCSeconds()).padStart(2,"0");return`${t}${s}${i}T${r}${n}${a}Z`}static getDescription(e){const t={SECONDLY:"second",MINUTELY:"minute",HOURLY:"hour",DAILY:"day",WEEKLY:"week",MONTHLY:"month",YEARLY:"year"},s={SU:"Sunday",MO:"Monday",TU:"Tuesday",WE:"Wednesday",TH:"Thursday",FR:"Friday",SA:"Saturday"},i={1:"first",2:"second",3:"third",4:"fourth",5:"fifth","-1":"last","-2":"second to last"};let r="Every";if(e.interval>1&&(r+=` ${e.interval}`),r+=` ${t[e.freq]}`,e.interval>1&&(r+="s"),e.byDay&&e.byDay.length>0){const n=a=>{if(typeof a=="string"){const o=a.match(/^(-?\d+)?([A-Z]{2})$/);return o?{nth:o[1]?parseInt(o[1],10):null,weekday:o[2]}:{nth:null,weekday:a}}return a};if(e.freq==="WEEKLY"){const a=e.byDay.map(o=>s[n(o).weekday]).join(", ");r+=` on ${a}`}else if(e.freq==="MONTHLY"||e.freq==="YEARLY"){const a=e.byDay.map(o=>{const c=n(o);return c.nth?`the ${i[c.nth]||c.nth} ${s[c.weekday]}`:s[c.weekday]}).join(", ");r+=` on ${a}`}}if(e.byMonthDay&&e.byMonthDay.length>0){const n=e.byMonthDay.map(a=>a<0?`${Math.abs(a)} day(s) from the end`:`day ${a}`).join(", ");r+=` on ${n}`}if(e.byMonth&&e.byMonth.length>0){const n=["January","February","March","April","May","June","July","August","September","October","November","December"],a=e.byMonth.map(o=>n[o-1]).join(", ");r+=` in ${a}`}return e.count?r+=`, ${e.count} time${e.count>1?"s":""}`:e.until&&(r+=`, until ${e.until.toLocaleDateString()}`),r}}class V{static expandEvent(e,t,s,i=365,r=null){if(!e.recurring||!e.recurrenceRule)return[{start:e.start,end:e.end,timezone:e.timeZone}];const n=this.parseRule(e.recurrenceRule),a=[],o=e.end-e.start,c=r||e.timeZone||"UTC",l=I.getInstance();let h=new Date(e.start),d=0;n.until&&n.until<s&&(s=n.until);let p=l.getTimezoneOffset(h,c),w=0;const D=3;for(;h<=s&&d<i;){if(h>=t){const k=new Date(h),C=new Date(h.getTime()+o),$=l.getTimezoneOffset(k,c);if($!==p){const O=p-$;k.setMinutes(k.getMinutes()+O),C.setMinutes(C.getMinutes()+O)}p=$,this.isException(k,n,e.id)||a.push({start:k,end:C,recurringEventId:e.id,timezone:c,originalStart:e.start})}const _=h.getTime();if(h=this.getNextOccurrence(h,n,c),d++,h.getTime()===_){if(w++,w>=D){console.warn("RecurrenceEngine: Date not advancing, breaking to prevent infinite loop");break}}else w=0;if(n.count&&d>=n.count)break}return a}static parseRule(e){return N.parse(e)}static getNextOccurrence(e,t,s="UTC"){const i=new Date(e);switch(t.freq){case"DAILY":i.setDate(i.getDate()+t.interval);break;case"WEEKLY":if(t.byDay&&t.byDay.length>0){let n=0;const a=i.getDate();for(i.setDate(i.getDate()+1);!this.matchesByDay(i,t.byDay)&&n<8;)i.setDate(i.getDate()+1),n++;n>=8&&(console.warn("RecurrenceEngine: Invalid byDay rule, falling back to weekly interval"),i.setDate(a+7*t.interval))}else i.setDate(i.getDate()+7*t.interval);break;case"MONTHLY":if(t.byMonthDay&&t.byMonthDay.length>0){const r=i.getMonth();i.setMonth(r+t.interval),i.setDate(t.byMonthDay[0])}else t.byDay&&t.byDay.length>0?(i.setMonth(i.getMonth()+t.interval),this.setToWeekdayOfMonth(i,t.byDay[0],t.bySetPos[0]||1)):i.setMonth(i.getMonth()+t.interval);break;case"YEARLY":t.byMonth&&t.byMonth.length>0?(i.setFullYear(i.getFullYear()+t.interval),i.setMonth(t.byMonth[0]-1)):i.setFullYear(i.getFullYear()+t.interval);break;default:i.setTime(i.getTime()+24*60*60*1e3)}return i}static matchesByDay(e,t){const s={SU:0,MO:1,TU:2,WE:3,TH:4,FR:5,SA:6},i=e.getDay();return t.some(r=>{const n=r.match(/^(-?\d+)?([A-Z]{2})$/);if(n){const a=n[2];return s[a]===i}return!1})}static setToWeekdayOfMonth(e,t,s=1){const i={SU:0,MO:1,TU:2,WE:3,TH:4,FR:5,SA:6},r=t.match(/^(-?\d+)?([A-Z]{2})$/),n=r?r[2]:t,a=i[n];for(e.setDate(1);e.getDay()!==a;)e.setDate(e.getDate()+1);if(s>1)e.setDate(e.getDate()+7*(s-1));else if(s===-1){const o=new Date(e);for(o.setMonth(o.getMonth()+1),o.setDate(0);o.getDay()!==a;)o.setDate(o.getDate()-1);e.setTime(o.getTime())}}static isException(e,t,s=null){if(!t.exceptions||t.exceptions.length===0)return!1;const i=e.toDateString(),r=e.getTime();return t.exceptions.some(n=>{if(typeof n=="object"&&n.date){const o=n.date instanceof Date?n.date:new Date(n.date);return n.matchTime?Math.abs(o.getTime()-r)<1e3:o.toDateString()===i}return(n instanceof Date?n:new Date(n)).toDateString()===i})}static addExceptions(e,t,s={}){return e.exceptions||(e.exceptions=[]),(Array.isArray(t)?t:[t]).forEach(r=>{s.reason||s.matchTime?e.exceptions.push({date:r,reason:s.reason,matchTime:s.matchTime||!1}):e.exceptions.push(r)}),e}static parseDate(e){if(e.length===8){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10);return new Date(t,s,i)}else if(e.length===15||e.length===16){const t=parseInt(e.substr(0,4),10),s=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),r=parseInt(e.substr(9,2),10),n=parseInt(e.substr(11,2),10),a=parseInt(e.substr(13,2),10);return e.endsWith("Z")?new Date(Date.UTC(t,s,i,r,n,a)):new Date(t,s,i,r,n,a)}return new Date(e)}static getDescription(e){typeof e=="string"&&(e=this.parseRule(e));let t="";const s=e.interval||1;switch(e.freq){case"DAILY":t=s===1?"Daily":`Every ${s} days`;break;case"WEEKLY":if(t=s===1?"Weekly":`Every ${s} weeks`,e.byDay&&e.byDay.length>0){const i=e.byDay.map(r=>this.getDayName(r)).join(", ");t+=` on ${i}`}break;case"MONTHLY":t=s===1?"Monthly":`Every ${s} months`,e.byMonthDay&&e.byMonthDay.length>0&&(t+=` on day ${e.byMonthDay.join(", ")}`);break;case"YEARLY":t=s===1?"Yearly":`Every ${s} years`;break}return e.count?t+=`, ${e.count} times`:e.until&&(t+=`, until ${e.until.toLocaleDateString()}`),t}static getDayName(e){const t={SU:"Sunday",MO:"Monday",TU:"Tuesday",WE:"Wednesday",TH:"Thursday",FR:"Friday",SA:"Saturday"},s=e.match(/^(-?\d+)?([A-Z]{2})$/),i=s?s[2]:e,r=s&&s[1]?parseInt(s[1],10):null;let n=t[i]||e;return r&&(n=`${r===-1?"Last":["","1st","2nd","3rd","4th","5th"][r]||`${r}th`} ${n}`),n}}class B{constructor(e=100){this.capacity=e,this.cache=new Map,this.hits=0,this.misses=0,this.evictions=0}get(e){if(!this.cache.has(e)){this.misses++;return}const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),this.hits++,t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const s=this.cache.keys().next().value;this.cache.delete(s),this.evictions++}this.cache.set(e,t)}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0,this.evictions=0}getStats(){const e=this.hits+this.misses>0?(this.hits/(this.hits+this.misses)*100).toFixed(2):0;return{size:this.cache.size,capacity:this.capacity,hits:this.hits,misses:this.misses,evictions:this.evictions,hitRate:`${e}%`}}keys(){return Array.from(this.cache.keys())}get size(){return this.cache.size}}class W{constructor(e={}){this.config={checkInterval:3e4,memoryThreshold:.8,criticalThreshold:.95,minCacheSize:10,maxCacheSize:1e4,adaptiveScaling:!0,...e},this.caches=new Map,this.stats={adjustments:0,emergencyClears:0,lastMemoryUsage:0,lastCheckTime:null,cacheResizes:[]},this.monitoringInterval=null,this.config.adaptiveScaling&&this.startMonitoring()}registerCache(e,t,s={}){this.caches.set(e,{cache:t,priority:s.priority||1,currentCapacity:s.initialCapacity||100,minCapacity:s.minCapacity||this.config.minCacheSize,maxCapacity:s.maxCapacity||this.config.maxCacheSize,scaleFactor:s.scaleFactor||.5,lastAccess:Date.now()})}unregisterCache(e){this.caches.delete(e)}startMonitoring(){this.monitoringInterval||(this.monitoringInterval=setInterval(()=>{this.checkMemoryPressure()},this.config.checkInterval),this.checkMemoryPressure())}stopMonitoring(){this.monitoringInterval&&(clearInterval(this.monitoringInterval),this.monitoringInterval=null)}async checkMemoryPressure(){const e=await this.getMemoryUsage();this.stats.lastMemoryUsage=e,this.stats.lastCheckTime=new Date,e>this.config.criticalThreshold?this.emergencyClear():e>this.config.memoryThreshold?this.reduceCacheSizes(e):e<this.config.memoryThreshold-.2&&this.increaseCacheSizes()}async getMemoryUsage(){if(typeof performance<"u"&&performance.memory){const e=performance.memory;if(e.jsHeapSizeLimit&&e.usedJSHeapSize)return e.usedJSHeapSize/e.jsHeapSizeLimit}try{const e=typeof globalThis<"u"?globalThis:{},t="process",s="memoryUsage",i=e[t];if(i&&typeof i=="object"){const r=i[s];if(typeof r=="function"){const n=r.call(i);return n.heapUsed/n.heapTotal}}}catch{}return this.estimateMemoryUsage()}estimateMemoryUsage(){let e=0,t=0;for(const[s,i]of this.caches)i.cache.size!==void 0&&(e+=i.cache.size,t+=i.maxCapacity);return t>0?e/t:.5}reduceCacheSizes(e){const t=(e-this.config.memoryThreshold)/(this.config.criticalThreshold-this.config.memoryThreshold),s=Array.from(this.caches.entries()).sort((i,r)=>i[1].priority-r[1].priority);for(const[i,r]of s){const n=Math.floor(r.currentCapacity*r.scaleFactor*t),a=Math.max(r.minCapacity,r.currentCapacity-n);a<r.currentCapacity&&this.resizeCache(i,r,a)}this.stats.adjustments++}increaseCacheSizes(){for(const[e,t]of this.caches)if(Date.now()-t.lastAccess<6e4){const i=Math.floor(t.currentCapacity*.2),r=Math.min(t.maxCapacity,t.currentCapacity+i);r>t.currentCapacity&&this.resizeCache(e,t,r)}}resizeCache(e,t,s){const i=t.currentCapacity;t.currentCapacity=s,t.cache.capacity!==void 0&&(t.cache.capacity=s),t.cache.size>s&&this.evictExcessItems(t.cache,s),this.stats.cacheResizes.push({cache:e,timestamp:new Date,oldCapacity:i,newCapacity:s,reason:s<i?"pressure":"available"}),this.stats.cacheResizes.length>100&&this.stats.cacheResizes.shift()}evictExcessItems(e,t){if(e.size<=t)return;const s=e.size-t;if(e.keys){const i=Array.from(e.keys());for(let r=0;r<s;r++)e.delete(i[r])}else e.clear&&e.clear()}emergencyClear(){for(const[e,t]of this.caches)t.cache.clear&&t.cache.clear(),t.currentCapacity=t.minCapacity;this.stats.emergencyClears++,console.warn("AdaptiveMemoryManager: Emergency cache clear triggered")}touchCache(e){const t=this.caches.get(e);t&&(t.lastAccess=Date.now())}getStats(){const e={};for(const[t,s]of this.caches)e[t]={size:s.cache.size||0,capacity:s.currentCapacity,priority:s.priority,lastAccess:new Date(s.lastAccess)};return{...this.stats,memoryUsagePercent:`${(this.stats.lastMemoryUsage*100).toFixed(2)}%`,totalCaches:this.caches.size,cacheStats:e,monitoring:this.monitoringInterval!==null}}async checkNow(){await this.checkMemoryPressure()}setThresholds(e){e.memoryThreshold!==void 0&&(this.config.memoryThreshold=Math.max(.5,Math.min(.95,e.memoryThreshold))),e.criticalThreshold!==void 0&&(this.config.criticalThreshold=Math.max(this.config.memoryThreshold+.05,Math.min(1,e.criticalThreshold)))}destroy(){this.stopMonitoring(),this.caches.clear()}}class j{constructor(e={}){this.config={enableCache:!0,cacheCapacity:500,maxIndexDays:365,batchSize:100,enableMetrics:!0,cleanupInterval:36e5,maxIndexAge:30*24*60*60*1e3,enableAdaptiveMemory:!0,...e},this.eventCache=new B(this.config.cacheCapacity),this.queryCache=new B(Math.floor(this.config.cacheCapacity/2)),this.dateRangeCache=new B(Math.floor(this.config.cacheCapacity/4)),this.config.enableAdaptiveMemory&&(this.memoryManager=new W({checkInterval:3e4,memoryThreshold:.75,criticalThreshold:.9}),this.memoryManager.registerCache("events",this.eventCache,{priority:3,initialCapacity:this.config.cacheCapacity,minCapacity:50,maxCapacity:2e3}),this.memoryManager.registerCache("queries",this.queryCache,{priority:2,initialCapacity:Math.floor(this.config.cacheCapacity/2),minCapacity:25,maxCapacity:1e3}),this.memoryManager.registerCache("dateRanges",this.dateRangeCache,{priority:1,initialCapacity:Math.floor(this.config.cacheCapacity/4),minCapacity:10,maxCapacity:500})),this.lazyIndexes=new Map,this.pendingIndexes=new Map,this.batchQueue=[],this.batchTimer=null,this.batchCallbacks=[],this.metrics={operations:{},averageTimes:{},slowQueries:[]},this.cleanupTimer=null,this.config.cleanupInterval>0&&this.startCleanupTimer()}measure(e,t){if(!this.config.enableMetrics)return t();const s=performance.now();try{const i=t(),r=performance.now()-s;return this.recordMetric(e,r),i}catch(i){const r=performance.now()-s;throw this.recordMetric(e,r,!0),i}}async measureAsync(e,t){if(!this.config.enableMetrics)return await t();const s=performance.now();try{const i=await t(),r=performance.now()-s;return this.recordMetric(e,r),i}catch(i){const r=performance.now()-s;throw this.recordMetric(e,r,!0),i}}recordMetric(e,t,s=!1){this.metrics.operations[e]||(this.metrics.operations[e]={count:0,totalTime:0,errors:0,min:1/0,max:0});const i=this.metrics.operations[e];i.count++,i.totalTime+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),s&&i.errors++,this.metrics.averageTimes[e]=i.totalTime/i.count,t>100&&(this.metrics.slowQueries.push({operation:e,duration:t,timestamp:new Date,isError:s}),this.metrics.slowQueries.length>100&&this.metrics.slowQueries.shift())}getMetrics(){const e={cacheStats:{event:this.eventCache.getStats(),query:this.queryCache.getStats(),dateRange:this.dateRangeCache.getStats()},operations:{},slowestOperations:[],recentSlowQueries:this.metrics.slowQueries.slice(-10),memoryManagement:this.memoryManager?this.memoryManager.getStats():null};for(const[t,s]of Object.entries(this.metrics.operations))e.operations[t]={count:s.count,avgTime:`${(s.totalTime/s.count).toFixed(2)}ms`,minTime:`${s.min.toFixed(2)}ms`,maxTime:`${s.max.toFixed(2)}ms`,totalTime:`${s.totalTime.toFixed(2)}ms`,errors:s.errors,errorRate:`${(s.errors/s.count*100).toFixed(2)}%`};return e.slowestOperations=Object.entries(this.metrics.averageTimes).sort((t,s)=>s[1]-t[1]).slice(0,5).map(([t,s])=>({operation:t,avgTime:`${s.toFixed(2)}ms`})),e}shouldUseLazyIndexing(e){return Math.ceil((e.end-e.start)/864e5)>this.config.maxIndexDays}createLazyIndexMarkers(e){const t={eventId:e.id,start:e.start,end:e.end,indexed:new Set,pending:!1},s=new Date(e.start.getFullYear(),e.start.getMonth(),1),i=new Date(e.end.getFullYear(),e.end.getMonth(),1);return t.indexed.add(this.getMonthKey(s)),this.getMonthKey(s)!==this.getMonthKey(i)&&t.indexed.add(this.getMonthKey(i)),this.lazyIndexes.set(e.id,t),t}async expandLazyIndex(e,t,s){const i=this.lazyIndexes.get(e);if(!i)return new Set;if(i.pending)return this.pendingIndexes.get(e);i.pending=!0;const r=new Promise(n=>{setTimeout(()=>{const a=new Set,o=new Date(t);for(;o<=s;){const c=o.toDateString();i.indexed.has(c)||(a.add(c),i.indexed.add(c)),o.setDate(o.getDate()+1)}i.pending=!1,this.pendingIndexes.delete(e),n(a)},0)});return this.pendingIndexes.set(e,r),r}getMonthKey(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}cache(e,t,s="event"){if(!this.config.enableCache)return;let i,r;switch(s){case"event":i=this.eventCache,r="events";break;case"query":i=this.queryCache,r="queries";break;case"dateRange":i=this.dateRangeCache,r="dateRanges";break;default:return}i.put(e,t),this.memoryManager&&this.memoryManager.touchCache(r)}getFromCache(e,t="event"){if(!this.config.enableCache)return;let s,i;switch(t){case"event":s=this.eventCache.get(e),i="events";break;case"query":s=this.queryCache.get(e),i="queries";break;case"dateRange":s=this.dateRangeCache.get(e),i="dateRanges";break;default:return}return s!==void 0&&this.memoryManager&&this.memoryManager.touchCache(i),s}invalidateEventCaches(e){this.eventCache.delete(e),this.queryCache.clear(),this.dateRangeCache.clear()}batch(e){return new Promise((t,s)=>{this.batchQueue.push(e),this.batchCallbacks.push({resolve:t,reject:s}),this.batchQueue.length>=this.config.batchSize?this.processBatch():this.batchTimer||(this.batchTimer=setTimeout(()=>this.processBatch(),10))})}processBatch(){if(this.batchTimer&&(clearTimeout(this.batchTimer),this.batchTimer=null),this.batchQueue.length===0)return;const e=this.batchQueue.splice(0),t=this.batchCallbacks.splice(0),s=[],i=[];e.forEach((r,n)=>{try{s[n]=r()}catch(a){i[n]=a}}),t.forEach((r,n)=>{i[n]?r.reject(i[n]):r.resolve(s[n])})}startCleanupTimer(){this.cleanupTimer=setInterval(()=>{this.cleanupOldIndexes()},this.config.cleanupInterval)}cleanupOldIndexes(){const e=Date.now(),t=this.config.maxIndexAge;for(const[s,i]of this.lazyIndexes)i.end.getTime()<e-t&&this.lazyIndexes.delete(s);this.metrics.slowQueries.length>100&&(this.metrics.slowQueries=this.metrics.slowQueries.slice(-100))}optimizeQuery(e,t){const s=this.getFromCache(e,"query");if(s!==void 0)return s;const i=this.measure(`query:${e}`,t);return this.cache(e,i,"query"),i}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null),this.batchTimer&&(clearTimeout(this.batchTimer),this.batchTimer=null),this.eventCache.clear(),this.queryCache.clear(),this.dateRangeCache.clear(),this.lazyIndexes.clear(),this.pendingIndexes.clear()}}class Z{constructor(e){this.eventStore=e,this.conflictIdCounter=0}checkConflicts(e,t={}){const s={checkAttendees:!0,checkResources:!0,checkLocation:!0,ignoreAllDay:!1,excludeEventIds:[],includeStatuses:["confirmed","tentative"],bufferMinutes:0,...t};if(!e.start||!e.end)throw new Error("Event must have start and end dates");const i=[],r=new Set,n=new Set,a=new Date(e.start.getTime()-s.bufferMinutes*6e4),o=new Date(e.end.getTime()+s.bufferMinutes*6e4),c=this.eventStore.getEventsInRange(a,o,!1).filter(l=>!(l.id===e.id||s.excludeEventIds.includes(l.id)||!s.includeStatuses.includes(l.status)||s.ignoreAllDay&&(l.allDay||e.allDay)||l.status==="cancelled"));for(const l of c){const h=this._detectEventConflicts(e,l,s);h.length>0&&(i.push(...h),r.add(e.id),r.add(l.id),e.attendees&&e.attendees.forEach(d=>n.add(d.email)),l.attendees&&l.attendees.forEach(d=>n.add(d.email)))}return this._buildConflictSummary(i,r,n)}checkEventPairConflicts(e,t,s={}){const i={checkAttendees:!0,checkResources:!0,checkLocation:!0,bufferMinutes:0,...s};return this._detectEventConflicts(e,t,i)}getBusyPeriods(e,t,s,i={}){const r={includeStatuses:["confirmed","tentative"],mergePeriods:!0,...i},n=[];return this.eventStore.getEventsInRange(t,s,!1).filter(c=>!r.includeStatuses.includes(c.status)||c.status==="cancelled"?!1:c.attendees&&c.attendees.some(l=>e.includes(l.email))).forEach(c=>{n.push({start:c.start,end:c.end,eventIds:[c.id]})}),r.mergePeriods&&n.length>1?this._mergeBusyPeriods(n):n.sort((c,l)=>c.start-l.start)}getFreePeriods(e,t,s,i={}){const r={attendeeEmails:[],businessHoursOnly:!1,businessHours:{start:"09:00",end:"17:00"},excludeWeekends:!1,...i},n=[],a=r.attendeeEmails.length>0?this.getBusyPeriods(r.attendeeEmails,e,t):this._getAllBusyPeriods(e,t);let o=new Date(e);for(const c of a)o<c.start&&(c.start-o)/6e4>=s&&(!r.businessHoursOnly||this._isWithinBusinessHours(o,c.start,r))&&n.push({start:new Date(o),end:new Date(c.start)}),o=new Date(Math.max(o.getTime(),c.end.getTime()));return o<t&&(t-o)/6e4>=s&&(!r.businessHoursOnly||this._isWithinBusinessHours(o,t,r))&&n.push({start:new Date(o),end:new Date(t)}),n}_detectEventConflicts(e,t,s){const i=[];if(this._checkTimeOverlap(e,t,s.bufferMinutes)){const n=this._createTimeConflict(e,t);if(i.push(n),s.checkAttendees){const a=this._checkAttendeeConflicts(e,t);i.push(...a)}if(s.checkResources){const a=this._checkResourceConflicts(e,t);i.push(...a)}if(s.checkLocation){const a=this._checkLocationConflict(e,t);a&&i.push(a)}}return i}_checkTimeOverlap(e,t,s=0){const i=s*6e4,r=e.start.getTime()-i,n=e.end.getTime()+i,a=t.start.getTime(),o=t.end.getTime();return!(n<=a||o<=r)}_createTimeConflict(e,t){const s=new Date(Math.max(e.start.getTime(),t.start.getTime())),i=new Date(Math.min(e.end.getTime(),t.end.getTime())),r=(i-s)/6e4;let n="low";return r>=60?n="high":r>=30&&(n="medium"),e.status==="confirmed"&&t.status==="confirmed"&&(n=n==="low"?"medium":n==="medium"?"high":"critical"),{id:`conflict_${++this.conflictIdCounter}`,type:"time",severity:n,eventId:e.id,conflictingEventId:t.id,description:`Time overlap: ${e.title} conflicts with ${t.title}`,overlapStart:s,overlapEnd:i,overlapMinutes:r,metadata:{event1Title:e.title,event2Title:t.title,event1Status:e.status,event2Status:t.status}}}_checkAttendeeConflicts(e,t){const s=[];if(!e.attendees||!t.attendees)return s;const i=[];for(const r of e.attendees)for(const n of t.attendees)r.email===n.email&&i.push(r.email);if(i.length>0){let r="medium";i.some(a=>{const o=e.attendees.find(l=>l.email===a),c=t.attendees.find(l=>l.email===a);return(o==null?void 0:o.responseStatus)==="accepted"&&(c==null?void 0:c.responseStatus)==="accepted"})&&(r="critical"),s.push({id:`conflict_${++this.conflictIdCounter}`,type:"attendee",severity:r,eventId:e.id,conflictingEventId:t.id,description:`Attendee conflict: ${i.length} attendee(s) double-booked`,conflictingAttendees:i,metadata:{attendeeCount:i.length,attendeeEmails:i}})}return s}_checkResourceConflicts(e,t){var n,a;const s=[],i=((n=e.attendees)==null?void 0:n.filter(o=>o.resource))||[],r=((a=t.attendees)==null?void 0:a.filter(o=>o.resource))||[];for(const o of i)for(const c of r)o.email===c.email&&s.push({id:`conflict_${++this.conflictIdCounter}`,type:"resource",severity:"critical",eventId:e.id,conflictingEventId:t.id,description:`Resource conflict: ${o.name} is double-booked`,conflictingResource:o.email,metadata:{resourceName:o.name,resourceEmail:o.email}});return s}_checkLocationConflict(e,t){if(!e.location||!t.location)return null;const s=e.location.trim().toLowerCase(),i=t.location.trim().toLowerCase();return s===i?{id:`conflict_${++this.conflictIdCounter}`,type:"location",severity:"high",eventId:e.id,conflictingEventId:t.id,description:`Location conflict: ${e.location} is double-booked`,metadata:{location:e.location}}:null}_buildConflictSummary(e,t,s){const i={},r={};for(const n of e)i[n.type]=(i[n.type]||0)+1,r[n.severity]=(r[n.severity]||0)+1;return{hasConflicts:e.length>0,totalConflicts:e.length,conflicts:e,conflictsByType:i,conflictsBySeverity:r,affectedEventIds:Array.from(t),affectedAttendees:Array.from(s)}}_mergeBusyPeriods(e){if(e.length<=1)return e;e.sort((s,i)=>s.start-i.start);const t=[e[0]];for(let s=1;s<e.length;s++){const i=e[s],r=t[t.length-1];i.start<=r.end?(r.end=new Date(Math.max(r.end.getTime(),i.end.getTime())),r.eventIds.push(...i.eventIds)):t.push(i)}return t}_getAllBusyPeriods(e,t){return this.eventStore.getEventsInRange(e,t,!1).filter(i=>i.status!=="cancelled").map(i=>({start:i.start,end:i.end,eventIds:[i.id]})).sort((i,r)=>i.start-r.start)}_isWithinBusinessHours(e,t,s){const i=e.getHours(),r=t.getHours(),n=parseInt(s.businessHours.start.split(":")[0]),a=parseInt(s.businessHours.end.split(":")[0]);return i>=n&&r<=a}}class q{constructor(e={}){this.events=new Map,this.indices={byDate:new Map,byMonth:new Map,recurring:new Set,byCategory:new Map,byStatus:new Map},this.timezoneManager=I.getInstance(),this.defaultTimezone=e.timezone||this.timezoneManager.getSystemTimezone(),this.optimizer=new j(e.performance),this.conflictDetector=new Z(this),this.isBatchMode=!1,this.batchNotifications=[],this.batchBackup=null,this._batchLock=null,this._batchLockResolve=null,this.version=0,this.listeners=new Set}addEvent(e){return this.optimizer.measure("addEvent",()=>{if(e instanceof x||(e=new x(e)),this.events.has(e.id))throw new Error(`Event with id ${e.id} already exists`);return this.events.set(e.id,e),this.optimizer.cache(e.id,e,"event"),this._indexEvent(e),this.isBatchMode?this.batchNotifications.push({type:"add",event:e,version:++this.version}):this._notifyChange({type:"add",event:e,version:++this.version}),e})}updateEvent(e,t){const s=this.events.get(e);if(!s)throw new Error(`Event with id ${e} not found`);this._unindexEvent(s);const i=s.clone(t);return this.events.set(e,i),this._indexEvent(i),this._notifyChange({type:"update",event:i,oldEvent:s,version:++this.version}),i}removeEvent(e){const t=this.events.get(e);return t?(this.events.delete(e),this._unindexEvent(t),this._notifyChange({type:"remove",event:t,version:++this.version}),!0):!1}getEvent(e){const t=this.optimizer.getFromCache(e,"event");if(t)return t;const s=this.events.get(e)||null;return s&&this.optimizer.cache(e,s,"event"),s}getAllEvents(){return Array.from(this.events.values())}queryEvents(e={}){let t=Array.from(this.events.values());if(e.start||e.end){const s=e.start?new Date(e.start):null,i=e.end?new Date(e.end):null;t=t.filter(r=>!(s&&r.end<s||i&&r.start>i))}if(e.date){const s=new Date(e.date);t=t.filter(i=>i.occursOn(s))}if(e.month&&e.year){const s=`${e.year}-${String(e.month).padStart(2,"0")}`,i=this.indices.byMonth.get(s)||new Set;t=t.filter(r=>i.has(r.id))}return Object.prototype.hasOwnProperty.call(e,"allDay")&&(t=t.filter(s=>s.allDay===e.allDay)),Object.prototype.hasOwnProperty.call(e,"recurring")&&(t=t.filter(s=>s.recurring===e.recurring)),e.status&&(t=t.filter(s=>s.status===e.status)),e.categories&&e.categories.length>0&&(t=t.filter(s=>e.matchAllCategories?s.hasAllCategories(e.categories):s.hasAnyCategory(e.categories))),Object.prototype.hasOwnProperty.call(e,"hasAttendees")&&(t=t.filter(s=>e.hasAttendees?s.hasAttendees:!s.hasAttendees)),e.organizerEmail&&(t=t.filter(s=>s.organizer&&s.organizer.email===e.organizerEmail)),e.sort&&t.sort((s,i)=>{switch(e.sort){case"start":return s.start-i.start;case"end":return s.end-i.end;case"duration":return s.duration-i.duration;case"title":return s.title.localeCompare(i.title);default:return 0}}),t}getEventsForDate(e,t=null){t=t||this.defaultTimezone,f.getLocalDateString(e);const s=new Set,i=new Date(e);for(let l=-1;l<=1;l++){const h=new Date(i);h.setDate(h.getDate()+l);const d=f.getLocalDateString(h),p=this.indices.byDate.get(d);p&&p.forEach(w=>s.add(w))}const r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,n=this.indices.byMonth.get(r);n&&n.forEach(l=>s.add(l));const a=[],o=new Date(e);o.setHours(0,0,0,0);const c=new Date(e);c.setHours(23,59,59,999);for(const l of s){const h=this.events.get(l);if(h){const d=h.getStartInTimezone(t),p=h.getEndInTimezone(t);d<=c&&p>=o&&a.push(h)}}return a.sort((l,h)=>{const d=l.getStartInTimezone(t),p=h.getStartInTimezone(t),w=d-p;return w!==0?w:h.duration-l.duration})}getOverlappingEvents(e,t,s=null){const i=[],r=f.startOfDay(e),n=f.endOfDay(t),a=f.getDateRange(r,n),o=new Set;return a.forEach(c=>{const l=f.getLocalDateString(c);(this.indices.byDate.get(l)||new Set).forEach(d=>{if(!o.has(d)&&d!==s){o.add(d);const p=this.events.get(d);p&&p.overlaps({start:e,end:t})&&i.push(p)}})}),i.sort((c,l)=>c.start-l.start)}hasConflicts(e,t,s=null){return this.getOverlappingEvents(e,t,s).length>0}getOverlapGroups(e,t=!0){let s=this.getEventsForDate(e);t&&(s=s.filter(n=>!n.allDay));const i=[],r=new Set;return s.forEach(n=>{if(r.has(n.id))return;const a=[n];r.add(n.id);let o=0;for(;o<a.length;){const c=a[o];s.forEach(l=>{!r.has(l.id)&&c.overlaps(l)&&(a.push(l),r.add(l.id))}),o++}i.push(a)}),i}calculateEventPositions(e){const t=new Map;if(e.length===0)return t;e.sort((r,n)=>{const a=r.start-n.start;return a!==0?a:n.end-n.start-(r.end-r.start)});const s=[];e.forEach(r=>{let n=0;for(;n<s.length&&s[n].some(c=>c.overlaps(r));)n++;s[n]||(s[n]=[]),s[n].push(r),t.set(r.id,{column:n,totalColumns:0})});const i=s.length;return t.forEach(r=>{r.totalColumns=i}),t}getEventsInRange(e,t,s=!0,i=null){typeof s=="string"&&(i=s,s=!0),i=i||this.defaultTimezone;const r=this.timezoneManager.toUTC(e,i),n=this.timezoneManager.toUTC(t,i),a=this.queryEvents({start:r,end:n,sort:"start"});if(!s)return a;const o=[];return a.forEach(c=>{if(c.recurring&&c.recurrenceRule){const l=this.expandRecurringEvent(c,e,t,i);o.push(...l)}else o.push(c)}),o.sort((c,l)=>{const h=c.getStartInTimezone(i),d=l.getStartInTimezone(i);return h-d})}expandRecurringEvent(e,t,s,i=null){if(!e.recurring||!e.recurrenceRule)return[e];i=i||this.defaultTimezone;const r=e.timeZone||i;return V.expandEvent(e,t,s).map((a,o)=>e.clone({id:`${e.id}_occurrence_${o}`,start:a.start,end:a.end,timeZone:r,metadata:{...e.metadata,recurringEventId:e.id,occurrenceIndex:o}}))}clear(){const e=this.getAllEvents();this.events.clear(),this.indices.byDate.clear(),this.indices.byMonth.clear(),this.indices.recurring.clear(),this._notifyChange({type:"clear",oldEvents:e,version:++this.version})}loadEvents(e){this.clear();for(const t of e)this.addEvent(t)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}_indexEvent(e){if(this.optimizer.shouldUseLazyIndexing(e)){this._indexEventLazy(e);return}const t=e.getStartInTimezone(e.timeZone),s=e.getEndInTimezone(e.endTimeZone||e.timeZone),i=f.startOfDay(t),r=f.endOfDay(s);f.getDateRange(i,r).forEach(o=>{const c=f.getLocalDateString(o);this.indices.byDate.has(c)||this.indices.byDate.set(c,new Set),this.indices.byDate.get(c).add(e.id)}),`${i.getFullYear()}${String(i.getMonth()+1).padStart(2,"0")}`,`${r.getFullYear()}${String(r.getMonth()+1).padStart(2,"0")}`;const a=new Date(i.getFullYear(),i.getMonth(),1);for(;a<=r;){const o=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}`;this.indices.byMonth.has(o)||this.indices.byMonth.set(o,new Set),this.indices.byMonth.get(o).add(e.id),a.setMonth(a.getMonth()+1)}e.categories&&e.categories.length>0&&e.categories.forEach(o=>{this.indices.byCategory.has(o)||this.indices.byCategory.set(o,new Set),this.indices.byCategory.get(o).add(e.id)}),e.status&&(this.indices.byStatus.has(e.status)||this.indices.byStatus.set(e.status,new Set),this.indices.byStatus.get(e.status).add(e.id)),e.recurring&&this.indices.recurring.add(e.id)}_indexEventLazy(e){this.optimizer.createLazyIndexMarkers(e);const t=e.getStartInTimezone(e.timeZone),s=e.getEndInTimezone(e.endTimeZone||e.timeZone),i=f.startOfDay(t),r=f.endOfDay(s),n=new Date(i);if(n.setDate(n.getDate()+7),f.getDateRange(i,n<r?n:r).forEach(c=>{const l=f.getLocalDateString(c);this.indices.byDate.has(l)||this.indices.byDate.set(l,new Set),this.indices.byDate.get(l).add(e.id)}),r>n){const c=new Date(r);c.setDate(c.getDate()-7),f.getDateRange(c>i?c:i,r).forEach(h=>{const d=f.getLocalDateString(h);this.indices.byDate.has(d)||this.indices.byDate.set(d,new Set),this.indices.byDate.get(d).add(e.id)})}const o=new Date(i.getFullYear(),i.getMonth(),1);for(;o<=r;){const c=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`;this.indices.byMonth.has(c)||this.indices.byMonth.set(c,new Set),this.indices.byMonth.get(c).add(e.id),o.setMonth(o.getMonth()+1)}e.categories&&e.categories.length>0&&e.categories.forEach(c=>{this.indices.byCategory.has(c)||this.indices.byCategory.set(c,new Set),this.indices.byCategory.get(c).add(e.id)}),e.status&&(this.indices.byStatus.has(e.status)||this.indices.byStatus.set(e.status,new Set),this.indices.byStatus.get(e.status).add(e.id)),e.recurring&&this.indices.recurring.add(e.id)}_unindexEvent(e){for(const[t,s]of this.indices.byDate)s.delete(e.id),s.size===0&&this.indices.byDate.delete(t);for(const[t,s]of this.indices.byMonth)s.delete(e.id),s.size===0&&this.indices.byMonth.delete(t);for(const[t,s]of this.indices.byCategory)s.delete(e.id),s.size===0&&this.indices.byCategory.delete(t);for(const[t,s]of this.indices.byStatus)s.delete(e.id),s.size===0&&this.indices.byStatus.delete(t);this.indices.recurring.delete(e.id)}_notifyChange(e){for(const t of this.listeners)try{t(e)}catch(s){console.error("Error in EventStore listener:",s)}}getStats(){return{totalEvents:this.events.size,recurringEvents:this.indices.recurring.size,indexedDates:this.indices.byDate.size,indexedMonths:this.indices.byMonth.size,indexedCategories:this.indices.byCategory.size,indexedStatuses:this.indices.byStatus.size,version:this.version,performanceMetrics:this.optimizer.getMetrics()}}startBatch(e=!1){this.isBatchMode=!0,this.batchNotifications=[],e&&(this.batchBackup={events:new Map(this.events),indices:{byDate:new Map(Array.from(this.indices.byDate.entries()).map(([t,s])=>[t,new Set(s)])),byMonth:new Map(Array.from(this.indices.byMonth.entries()).map(([t,s])=>[t,new Set(s)])),recurring:new Set(this.indices.recurring),byCategory:new Map(Array.from(this.indices.byCategory.entries()).map(([t,s])=>[t,new Set(s)])),byStatus:new Map(Array.from(this.indices.byStatus.entries()).map(([t,s])=>[t,new Set(s)]))},version:this.version})}commitBatch(){this.isBatchMode&&(this.isBatchMode=!1,this.batchBackup=null,this.batchNotifications.length>0&&this._notifyChange({type:"batch",changes:this.batchNotifications,count:this.batchNotifications.length,version:++this.version}),this.batchNotifications=[])}rollbackBatch(){this.isBatchMode&&(this.isBatchMode=!1,this.batchBackup&&(this.events=this.batchBackup.events,this.indices=this.batchBackup.indices,this.version=this.batchBackup.version,this.batchBackup=null,this.optimizer.clearCache()),this.batchNotifications=[])}async executeBatch(e,t=!0){for(;this._batchLock;)await this._batchLock;this._batchLock=new Promise(s=>{this._batchLockResolve=s});try{this.startBatch(t);try{const s=await e();return this.commitBatch(),s}catch(s){throw t&&this.rollbackBatch(),s}}finally{const s=this._batchLockResolve;this._batchLock=null,this._batchLockResolve=null,s&&s()}}addEvents(e){return this.optimizer.measure("addEvents",()=>{this.startBatch();const t=[],s=[];for(const i of e)try{t.push(this.addEvent(i))}catch(r){s.push({event:i,error:r.message})}return this.commitBatch(),s.length>0&&console.warn(`Failed to add ${s.length} events:`,s),t})}updateEvents(e){return this.optimizer.measure("updateEvents",()=>{this.startBatch();const t=[],s=[];for(const{id:i,updates:r}of e)try{t.push(this.updateEvent(i,r))}catch(n){s.push({id:i,error:n.message})}return this.commitBatch(),s.length>0&&console.warn(`Failed to update ${s.length} events:`,s),t})}removeEvents(e){return this.optimizer.measure("removeEvents",()=>{this.startBatch();let t=0;for(const s of e)this.removeEvent(s)&&t++;return this.commitBatch(),t})}getPerformanceMetrics(){return this.optimizer.getMetrics()}clearCaches(){this.optimizer.eventCache.clear(),this.optimizer.queryCache.clear(),this.optimizer.dateRangeCache.clear()}optimizeIndices(e){e||(e=new Date,e.setMonth(e.getMonth()-6)),e.toDateString();let t=0;for(const[s,i]of this.indices.byDate)if(new Date(s)<e){let n=!1;for(const a of i){const o=this.events.get(a);if(o&&o.end>=e){n=!0;break}}n||(this.indices.byDate.delete(s),t++)}return console.log(`Optimized indices: removed ${t} old date entries`),t}destroy(){this.clear(),this.optimizer.destroy(),this.listeners.clear()}checkConflicts(e,t={}){return this.conflictDetector.checkConflicts(e,t)}checkEventPairConflicts(e,t,s={}){const i=this.getEvent(e),r=this.getEvent(t);if(!i||!r)throw new Error("One or both events not found");return this.conflictDetector.checkEventPairConflicts(i,r,s)}getAllConflicts(e,t,s={}){const i=this.getEventsInRange(e,t,!1),r=[],n=new Set;for(let a=0;a<i.length;a++)for(let o=a+1;o<i.length;o++){const c=`${i[a].id}-${i[o].id}`;if(!n.has(c)){n.add(c);const l=this.conflictDetector.checkEventPairConflicts(i[a],i[o],s);r.push(...l)}}return this.conflictDetector._buildConflictSummary(r,new Set(i.map(a=>a.id)),new Set)}getBusyPeriods(e,t,s,i={}){return this.conflictDetector.getBusyPeriods(e,t,s,i)}getFreePeriods(e,t,s,i={}){return this.conflictDetector.getFreePeriods(e,t,s,i)}addEventWithConflictCheck(e,t=!0){const s=this.checkConflicts(e);if(!t&&s.hasConflicts)throw new Error(`Cannot add event: ${s.totalConflicts} conflicts detected`);return{event:this.addEvent(e),conflicts:s}}findEventsWithConflicts(e={}){const t=[],s=this.getAllEvents();for(const i of s){const r=this.checkConflicts(i,e);r.hasConflicts&&t.push({event:i,conflicts:r.conflicts})}return t}}let K=class{constructor(e={}){this.state={view:"month",currentDate:new Date,selectedEventId:null,selectedDate:null,hoveredEventId:null,hoveredDate:null,weekStartsOn:0,showWeekNumbers:!1,showWeekends:!0,fixedWeekCount:!0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,locale:"en-US",hourFormat:"12h",businessHours:{start:"09:00",end:"17:00"},filters:{searchTerm:"",categories:[],showAllDay:!0,showTimed:!0},isDragging:!1,isResizing:!1,isCreating:!1,isLoading:!1,loadingMessage:"",error:null,metadata:{},...e},this.listeners=new Map,this.globalListeners=new Set,this.history=[],this.historyIndex=-1,this.maxHistorySize=50}getState(){return Object.freeze({...this.state})}get(e){return this.state[e]}setState(e){const t=this.state;typeof e=="function"&&(e=e(t));const s={...t,...e,filters:e.filters?{...t.filters,...e.filters}:t.filters,businessHours:e.businessHours?{...t.businessHours,...e.businessHours}:t.businessHours,metadata:e.metadata?{...t.metadata,...e.metadata}:t.metadata};this._hasChanged(t,s)&&(this.state=s,this._addToHistory(s),this._notifyListeners(t,s))}setView(e){const t=["month","week","day","list"];if(!t.includes(e))throw new Error(`Invalid view: ${e}. Must be one of: ${t.join(", ")}`);this.setState({view:e})}setCurrentDate(e){if(e instanceof Date||(e=new Date(e)),isNaN(e.getTime()))throw new Error("Invalid date");this.setState({currentDate:e})}navigateNext(){const{view:e,currentDate:t}=this.state,s=new Date(t);switch(e){case"month":s.setMonth(s.getMonth()+1);break;case"week":s.setDate(s.getDate()+7);break;case"day":s.setDate(s.getDate()+1);break}this.setCurrentDate(s)}navigatePrevious(){const{view:e,currentDate:t}=this.state,s=new Date(t);switch(e){case"month":s.setMonth(s.getMonth()-1);break;case"week":s.setDate(s.getDate()-7);break;case"day":s.setDate(s.getDate()-1);break}this.setCurrentDate(s)}navigateToday(){this.setCurrentDate(new Date)}selectEvent(e){this.setState({selectedEventId:e})}clearEventSelection(){this.setState({selectedEventId:null})}selectDate(e){e instanceof Date||(e=new Date(e)),this.setState({selectedDate:e})}clearDateSelection(){this.setState({selectedDate:null})}setLoading(e,t=""){this.setState({isLoading:e,loadingMessage:t})}setError(e){this.setState({error:e?e instanceof Error?e.message:e:null})}updateFilters(e){this.setState({filters:{...this.state.filters,...e}})}subscribe(e){return this.globalListeners.add(e),()=>{this.globalListeners.delete(e)}}watch(e,t){const s=Array.isArray(e)?e:[e];return s.forEach(i=>{this.listeners.has(i)||this.listeners.set(i,new Set),this.listeners.get(i).add(t)}),()=>{s.forEach(i=>{const r=this.listeners.get(i);r&&(r.delete(t),r.size===0&&this.listeners.delete(i))})}}canUndo(){return this.historyIndex>0}canRedo(){return this.historyIndex<this.history.length-1}getUndoCount(){return this.historyIndex}getRedoCount(){return this.history.length-1-this.historyIndex}undo(){if(!this.canUndo())return!1;this.historyIndex--;const e=this.history[this.historyIndex],t=this.state;return this.state={...e},this._notifyListeners(t,this.state),!0}redo(){if(!this.canRedo())return!1;this.historyIndex++;const e=this.history[this.historyIndex],t=this.state;return this.state={...e},this._notifyListeners(t,this.state),!0}reset(){const e=this.history[0]||{};this.setState(e),this.history=[e],this.historyIndex=0}_hasChanged(e,t){return!this._deepEqual(e,t)}_deepEqual(e,t,s=new Set){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e!="object")return e===t;if(s.has(e)||s.has(t))return!1;if(s.add(e),s.add(t),Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return s.delete(e),s.delete(t),!1;for(let n=0;n<e.length;n++)if(!this._deepEqual(e[n],t[n],s))return s.delete(e),s.delete(t),!1;return s.delete(e),s.delete(t),!0}if(e instanceof Date&&t instanceof Date){const n=e.getTime()===t.getTime();return s.delete(e),s.delete(t),n}const i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return s.delete(e),s.delete(t),!1;i.sort(),r.sort();for(let n=0;n<i.length;n++)if(i[n]!==r[n])return s.delete(e),s.delete(t),!1;for(const n of i)if(!this._deepEqual(e[n],t[n],s))return s.delete(e),s.delete(t),!1;return s.delete(e),s.delete(t),!0}_addToHistory(e){this.historyIndex<this.history.length-1&&(this.history=this.history.slice(0,this.historyIndex+1));const t=this._deepClone(e);this.history.push(t),this.historyIndex++,this.history.length>this.maxHistorySize&&(this.history.shift(),this.historyIndex--)}_deepClone(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return e.map(s=>this._deepClone(s));const t={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=this._deepClone(e[s]));return t}_notifyListeners(e,t){for(const s of this.globalListeners)try{s(t,e)}catch(i){console.error("Error in state listener:",i)}for(const[s,i]of this.listeners)if(e[s]!==t[s])for(const r of i)try{r(t[s],e[s],t,e)}catch(n){console.error(`Error in state listener for key "${s}":`,n)}}};class G{constructor(e={}){this.timezoneManager=I.getInstance(),this.config={view:"month",date:new Date,weekStartsOn:0,locale:"en-US",timeZone:e.timeZone||this.timezoneManager.getSystemTimezone(),showWeekNumbers:!1,showWeekends:!0,fixedWeekCount:!0,businessHours:{start:"09:00",end:"17:00"},...e},this.eventStore=new q({timezone:this.config.timeZone}),this.state=new K({view:this.config.view,currentDate:this.config.date,weekStartsOn:this.config.weekStartsOn,locale:this.config.locale,timeZone:this.config.timeZone,showWeekNumbers:this.config.showWeekNumbers,showWeekends:this.config.showWeekends,fixedWeekCount:this.config.fixedWeekCount,businessHours:this.config.businessHours}),this.listeners=new Map,this.plugins=new Set,this.views=new Map,this._setupInternalListeners(),e.events&&this.setEvents(e.events)}setView(e,t=null){this.state.setView(e),t&&this.state.setCurrentDate(t),this._emit("viewChange",{view:e,date:t||this.state.get("currentDate")})}getView(){return this.state.get("view")}next(){this.state.navigateNext(),this._emit("navigate",{direction:"next",date:this.state.get("currentDate"),view:this.state.get("view")})}previous(){this.state.navigatePrevious(),this._emit("navigate",{direction:"previous",date:this.state.get("currentDate"),view:this.state.get("view")})}today(){this.state.navigateToday(),this._emit("navigate",{direction:"today",date:this.state.get("currentDate"),view:this.state.get("view")})}goToDate(e){this.state.setCurrentDate(e),this._emit("navigate",{direction:"goto",date:e,view:this.state.get("view")})}setDate(e){this.goToDate(e)}getCurrentDate(){return new Date(this.state.get("currentDate"))}addEvent(e){!(e instanceof x)&&!e.timeZone&&(e={...e,timeZone:this.config.timeZone});const t=this.eventStore.addEvent(e);return this._emit("eventAdd",{event:t}),t}updateEvent(e,t){const s=this.eventStore.getEvent(e),i=this.eventStore.updateEvent(e,t);return this._emit("eventUpdate",{event:i,oldEvent:s}),i}removeEvent(e){const t=this.eventStore.getEvent(e),s=this.eventStore.removeEvent(e);return s&&this._emit("eventRemove",{event:t}),s}deleteEvent(e){return this.removeEvent(e)}getEvent(e){return this.eventStore.getEvent(e)}getEvents(){return this.eventStore.getAllEvents()}setEvents(e){this.eventStore.loadEvents(e),this._emit("eventsSet",{events:this.getEvents()})}queryEvents(e){return this.eventStore.queryEvents(e)}getEventsForDate(e,t=null){return this.eventStore.getEventsForDate(e,t||this.config.timeZone)}getEventsInRange(e,t,s=null){return this.eventStore.getEventsInRange(e,t,!0,s||this.config.timeZone)}setTimezone(e){const t=this.timezoneManager.parseTimezone(e),s=this.config.timeZone;this.config.timeZone=t,this.eventStore.defaultTimezone=t,this.state.setState({timeZone:t}),this._emit("timezoneChange",{timezone:t,previousTimezone:s})}getTimezone(){return this.config.timeZone}setLocale(e){this.config.locale=e,this.state.setState({locale:e}),this._emit("localeChange",{locale:e})}setWeekStartsOn(e){this.config.weekStartsOn=e,this.state.setState({weekStartsOn:e}),this._emit("weekStartsOnChange",{weekStartsOn:e})}convertTimezone(e,t,s){return this.timezoneManager.convertTimezone(e,t,s)}toCalendarTimezone(e,t){return this.timezoneManager.convertTimezone(e,t,this.config.timeZone)}fromCalendarTimezone(e,t){return this.timezoneManager.convertTimezone(e,this.config.timeZone,t)}formatInTimezone(e,t=null,s={}){return this.timezoneManager.formatInTimezone(e,t||this.config.timeZone,s)}getTimezones(){return this.timezoneManager.getCommonTimezones()}getOverlapGroups(e,t=!0){return this.eventStore.getOverlapGroups(e,t)}calculateEventPositions(e){return this.eventStore.calculateEventPositions(e)}getViewData(){const e=this.state.get("view"),t=this.state.get("currentDate");switch(e){case"month":return this._getMonthViewData(t);case"week":return this._getWeekViewData(t);case"day":return this._getDayViewData(t);case"list":return this._getListViewData(t);default:return null}}_getMonthViewData(e){const t=e.getFullYear(),s=e.getMonth(),i=this.state.get("weekStartsOn"),r=this.state.get("fixedWeekCount"),n=new Date(t,s,1),a=new Date(t,s+1,0),o=f.startOfWeek(n,i),c=[];let l=new Date(o);const h=r?6:Math.ceil((a.getDate()+f.getDayOfWeek(n,i))/7);for(let d=0;d<h;d++){const p={weekNumber:f.getWeekNumber(l),days:[]};for(let w=0;w<7;w++){const D=new Date(l),_=D.getMonth()===s,k=f.isToday(D),C=D.getDay()===0||D.getDay()===6;p.days.push({date:D,dayOfMonth:D.getDate(),isCurrentMonth:_,isToday:k,isWeekend:C,events:this.getEventsForDate(D)}),l=f.addDays(l,1)}c.push(p)}return{type:"month",year:t,month:s,monthName:f.getMonthName(e,this.state.get("locale")),weeks:c,startDate:o,endDate:new Date(l.getTime()-1)}}_getWeekViewData(e){const t=this.state.get("weekStartsOn"),s=f.startOfWeek(e,t),i=f.endOfWeek(e,t),r=[],n=new Date(s);for(let a=0;a<7;a++){const o=new Date(n);r.push({date:o,dayOfMonth:o.getDate(),dayOfWeek:o.getDay(),dayName:f.getDayName(o,this.state.get("locale")),isToday:f.isToday(o),isWeekend:o.getDay()===0||o.getDay()===6,events:this.getEventsForDate(o),overlapGroups:this.eventStore.getOverlapGroups(o,!0),getEventPositions:c=>this.eventStore.calculateEventPositions(c)}),n.setDate(n.getDate()+1)}return{type:"week",weekNumber:f.getWeekNumber(s),startDate:s,endDate:i,days:r}}_getDayViewData(e){const t=this.getEventsForDate(e),s=t.filter(n=>n.allDay),i=t.filter(n=>!n.allDay),r=[];for(let n=0;n<24;n++){const a=new Date(e);a.setHours(n,0,0,0);const o=new Date(e);o.setHours(n+1,0,0,0),r.push({hour:n,time:f.formatTime(a,this.state.get("locale")),events:i.filter(c=>c.start<o&&c.end>a)})}return{type:"day",date:e,dayName:f.getDayName(e,this.state.get("locale")),isToday:f.isToday(e),allDayEvents:s,hours:r}}_getListViewData(e){const t=new Date(e);t.setHours(0,0,0,0);const s=new Date(t);s.setDate(s.getDate()+30);const i=this.getEventsInRange(t,s),r=new Map;i.forEach(a=>{const o=a.start.toDateString();r.has(o)||r.set(o,{date:new Date(a.start),events:[]}),r.get(o).events.push(a)});const n=Array.from(r.values()).sort((a,o)=>a.date-o.date).map(a=>({...a,dayName:f.getDayName(a.date,this.state.get("locale")),isToday:f.isToday(a.date)}));return{type:"list",startDate:t,endDate:s,days:n,totalEvents:i.length}}selectEvent(e){const t=this.getEvent(e);t&&(this.state.selectEvent(e),this._emit("eventSelect",{event:t}))}clearEventSelection(){const e=this.state.get("selectedEventId");this.state.clearEventSelection(),e&&this._emit("eventDeselect",{eventId:e})}selectDate(e){this.state.selectDate(e),this._emit("dateSelect",{date:e})}clearDateSelection(){const e=this.state.get("selectedDate");this.state.clearDateSelection(),e&&this._emit("dateDeselect",{date:e})}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){const s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e))}_emit(e,t){const s=this.listeners.get(e);s&&s.forEach(i=>{try{i(t)}catch(r){console.error(`Error in event listener for "${e}":`,r)}})}_setupInternalListeners(){this.state.subscribe((e,t)=>{this._emit("stateChange",{newState:e,oldState:t})}),this.eventStore.subscribe(e=>{this._emit("eventStoreChange",e)})}use(e){if(this.plugins.has(e)){console.warn("Plugin already installed");return}if(typeof e.install=="function")e.install(this),this.plugins.add(e);else throw new Error("Plugin must have an install method")}destroy(){this.listeners.clear(),this.eventStore.destroy(),this.plugins.forEach(e=>{typeof e.uninstall=="function"&&e.uninstall(this)}),this.plugins.clear(),this.views.clear(),this._emit("destroy")}}class U{constructor(){this.events=new Map,this.wildcardHandlers=new Set}on(e,t,s={}){const{once:i=!1,priority:r=0}=s;if(e.includes("*")){const o={pattern:e,handler:t,once:i,priority:r};return this.wildcardHandlers.add(o),()=>this.wildcardHandlers.delete(o)}this.events.has(e)||this.events.set(e,[]);const n={handler:t,once:i,priority:r},a=this.events.get(e);return a.push(n),a.sort((o,c)=>c.priority-o.priority),()=>{const o=a.indexOf(n);o>-1&&a.splice(o,1)}}once(e,t,s={}){return this.on(e,t,{...s,once:!0})}off(e,t){if(e.includes("*")){for(const r of this.wildcardHandlers)if(r.pattern===e&&r.handler===t){this.wildcardHandlers.delete(r);return}return}if(!this.events.has(e))return;const s=this.events.get(e),i=s.findIndex(r=>r.handler===t);i>-1&&s.splice(i,1),s.length===0&&this.events.delete(e)}offWildcard(e){for(const t of[...this.wildcardHandlers])t.pattern===e&&this.wildcardHandlers.delete(t)}offAll(e){for(const[t,s]of this.events){const i=s.findIndex(r=>r.handler===e);i>-1&&s.splice(i,1),s.length===0&&this.events.delete(t)}for(const t of[...this.wildcardHandlers])t.handler===e&&this.wildcardHandlers.delete(t)}async emit(e,t){const s=[];if(this.events.has(e)){const r=[...this.events.get(e)];for(const n of r){const{handler:a,once:o}=n;o&&this.off(e,a);try{const c=a(t,e);c instanceof Promise&&s.push(c)}catch(c){console.error(`Error in event handler for ${e}:`,c)}}}const i=[];for(const r of[...this.wildcardHandlers])if(this.matchesPattern(e,r.pattern)){const{handler:n,once:a}=r;a&&i.push(r);try{const o=n(t,e);o instanceof Promise&&s.push(o)}catch(o){console.error(`Error in wildcard handler for ${e}:`,o)}}return i.forEach(r=>this.wildcardHandlers.delete(r)),Promise.all(s)}matchesPattern(e,t){return new RegExp("^"+t.replace(/\*/g,".*")+"$").test(e)}clear(){this.events.clear(),this.wildcardHandlers.clear()}getEventNames(){return Array.from(this.events.keys())}getHandlerCount(e){return this.events.has(e)?this.events.get(e).length:0}getWildcardHandlerCount(){return this.wildcardHandlers.size}getTotalHandlerCount(){let e=this.wildcardHandlers.size;for(const t of this.events.values())e+=t.length;return e}}const g=new U;class Y{constructor(e={}){this.calendar=new G({view:e.view||"month",date:e.date||new Date,weekStartsOn:e.weekStartsOn??0,locale:e.locale||"en-US",timeZone:e.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone,...e}),this.state={view:this.calendar.getView(),currentDate:this.calendar.getCurrentDate(),events:[],selectedEvent:null,selectedDate:null,loading:!1,error:null,config:{...e}},this.subscribers=new Set,this.subscribe=this.subscribe.bind(this),this.unsubscribe=this.unsubscribe.bind(this),this.setState=this.setState.bind(this),this._syncEventsFromCore({silent:!0})}_syncEventsFromCore(e={}){const t=this.calendar.getEvents()||[];return(this.state.events.length!==t.length||!this._eventsMatch(this.state.events,t))&&this.setState({events:[...t]},e),t}_eventsMatch(e,t){if(e.length!==t.length)return!1;const s=new Set(e.map(i=>i.id));return t.every(i=>s.has(i.id))}getState(){return{...this.state}}setState(e,t={}){const{silent:s=!1}=t,i={...this.state};return this.state={...this.state,...e},s||(this.notifySubscribers(i,this.state),this.emitStateChange(i,this.state)),this.state}subscribe(e,t=null){return this.subscribers.add(e),t&&(this._subscriberIds||(this._subscriberIds=new Map),this._subscriberIds.set(t,e)),()=>this.unsubscribe(e,t)}unsubscribe(e,t=null){this.subscribers.delete(e),t&&this._subscriberIds&&this._subscriberIds.delete(t)}unsubscribeById(e){if(!this._subscriberIds)return!1;const t=this._subscriberIds.get(e);return t?(this.subscribers.delete(t),this._subscriberIds.delete(e),!0):!1}getSubscriberCount(){return this.subscribers.size}notifySubscribers(e,t){this.subscribers.forEach(s=>{try{s(t,e)}catch(i){console.error("Error in state subscriber:",i)}})}emitStateChange(e,t){const s=Object.keys(t).filter(i=>e[i]!==t[i]);s.forEach(i=>{g.emit(`state:${i}:changed`,{oldValue:e[i],newValue:t[i],state:t})}),s.length>0&&g.emit("state:changed",{oldState:e,newState:t,changedKeys:s})}setView(e){this.calendar.setView(e),this.setState({view:e}),g.emit("view:changed",{view:e})}getView(){return this.state.view}setDate(e){this.calendar.goToDate(e),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("date:changed",{date:this.state.currentDate})}getCurrentDate(){return this.state.currentDate}next(){this.calendar.next(),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:next",{date:this.state.currentDate})}previous(){this.calendar.previous(),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:previous",{date:this.state.currentDate})}today(){this.calendar.today(),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:today",{date:this.state.currentDate})}goToDate(e){this.calendar.goToDate(e),this.setState({currentDate:this.calendar.getCurrentDate()}),g.emit("navigation:goto",{date:this.state.currentDate})}addEvent(e){const t=this.calendar.addEvent(e);return t?(this._syncEventsFromCore(),g.emit("event:added",{event:t}),t):(console.error("Failed to add event to calendar"),g.emit("event:error",{action:"add",event:e,error:"Failed to add event"}),null)}updateEvent(e,t){this._syncEventsFromCore({silent:!0});const s=this.calendar.updateEvent(e,t);return s?(this._syncEventsFromCore(),g.emit("event:updated",{event:s}),s):(console.error(`Failed to update event: ${e}`),g.emit("event:error",{action:"update",eventId:e,updates:t,error:"Event not found in calendar"}),null)}deleteEvent(e){return this._syncEventsFromCore({silent:!0}),this.calendar.removeEvent(e)?(this._syncEventsFromCore(),g.emit("event:deleted",{eventId:e}),!0):(console.error(`Failed to delete event: ${e}`),g.emit("event:error",{action:"delete",eventId:e,error:"Event not found"}),!1)}getEvents(){return this.calendar.getEvents()||[]}syncEvents(){return this._syncEventsFromCore()}getEventsForDate(e){return this.calendar.getEventsForDate(e)}getEventsInRange(e,t){return this.calendar.getEventsInRange(e,t)}getViewData(){const e=this.calendar.getViewData();return this.enrichViewData(e)}enrichViewData(e){var s;const t=(s=this.state.selectedDate)==null?void 0:s.toDateString();if(e.weeks&&(e.weeks=e.weeks.map(i=>({...i,days:i.days.map(r=>{const n=new Date(r.date);return{...r,isSelected:n.toDateString()===t,events:r.events||this.getEventsForDate(n)}})}))),e.days&&(e.days=e.days.map(i=>{const r=new Date(i.date);return{...i,isSelected:r.toDateString()===t,events:i.events||this.getEventsForDate(r)}})),e.date&&!e.days&&!e.weeks){const i=new Date(e.date);e.isSelected=i.toDateString()===t,e.events=e.events||this.getEventsForDate(i)}return e}selectEvent(e){this.setState({selectedEvent:e}),g.emit("event:selected",{event:e})}selectEventById(e){const t=this.state.events.find(s=>s.id===e);t&&this.selectEvent(t)}deselectEvent(){this.setState({selectedEvent:null}),g.emit("event:deselected",{})}selectDate(e){this.setState({selectedDate:e}),g.emit("date:selected",{date:e})}deselectDate(){this.setState({selectedDate:null}),g.emit("date:deselected",{})}isToday(e){const t=new Date;return e.toDateString()===t.toDateString()}isSelectedDate(e){return this.state.selectedDate&&e.toDateString()===this.state.selectedDate.toDateString()}isWeekend(e){const t=e.getDay();return t===0||t===6}setLoading(e){this.setState({loading:e})}setError(e){this.setState({error:e}),e&&g.emit("error",{error:e})}clearError(){this.setState({error:null})}updateConfig(e){this.setState({config:{...this.state.config,...e}}),e.weekStartsOn!==void 0&&this.calendar.setWeekStartsOn(e.weekStartsOn),e.locale!==void 0&&this.calendar.setLocale(e.locale),e.timeZone!==void 0&&this.calendar.setTimezone(e.timeZone)}destroy(){this.subscribers.clear(),this._subscriberIds&&(this._subscriberIds.clear(),this._subscriberIds=null),this.state=null,this.calendar=null}}class S extends f{static formatDate(e,t="default",s="en-US"){if(!e)return"";const i={default:{year:"numeric",month:"long",day:"numeric"},short:{year:"numeric",month:"short",day:"numeric"},long:{weekday:"long",year:"numeric",month:"long",day:"numeric"},month:{year:"numeric",month:"long"},monthShort:{year:"numeric",month:"short"},day:{weekday:"long",day:"numeric"},dayShort:{weekday:"short",day:"numeric"},time:{hour:"numeric",minute:"2-digit"},timeShort:{hour:"numeric"},datetime:{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}},r=i[t]||i.default;return new Intl.DateTimeFormat(s,r).format(e)}static formatTime(e,t=!0,s=!1,i="en-US"){if(!e)return"";const r={hour:"numeric",minute:t?"2-digit":void 0,hour12:!s};return new Intl.DateTimeFormat(i,r).format(e)}static formatDateRange(e,t,s="en-US"){if(!e)return"";if(!t||this.isSameDay(e,t))return this.formatDate(e,"default",s);const i=this.isSameYear(e,t)?"short":"default";return`${this.formatDate(e,i,s)} - ${this.formatDate(t,"default",s)}`}static formatTimeRange(e,t,s="en-US"){if(!e)return"";const i=this.formatTime(e,!0,!1,s);if(!t)return i;const r=this.formatTime(t,!0,!1,s);return`${i} - ${r}`}static getRelativeTime(e,t=new Date,s="en-US"){const i=new Intl.RelativeTimeFormat(s,{numeric:"auto"}),r=e-t,n=Math.floor(r/1e3),a=Math.floor(n/60),o=Math.floor(a/60),c=Math.floor(o/24),l=Math.floor(c/7),h=Math.floor(c/30),d=Math.floor(c/365);return Math.abs(n)<60?i.format(n,"second"):Math.abs(a)<60?i.format(a,"minute"):Math.abs(o)<24?i.format(o,"hour"):Math.abs(c)<7?i.format(c,"day"):Math.abs(l)<4?i.format(l,"week"):Math.abs(h)<12?i.format(h,"month"):i.format(d,"year")}static isToday(e){const t=new Date;return this.isSameDay(e,t)}static isPast(e){return e<new Date}static isFuture(e){return e>new Date}static getWeekNumber(e){const t=new Date(e.getFullYear(),0,1),s=(e-t)/864e5;return Math.ceil((s+t.getDay()+1)/7)}static getDayAbbreviation(e,t="en-US"){const s=new Date(2024,0,7+e);return new Intl.DateTimeFormat(t,{weekday:"short"}).format(s)}static getMonthName(e,t="long",s="en-US"){const i=new Date(2024,e,1);return new Intl.DateTimeFormat(s,{month:t}).format(i)}static parseTimeString(e,t=new Date){const s=new Date(t),[i,r]=e.split(/\s+/),[n,a]=i.split(":").map(Number);let o=n;return r&&(r.toLowerCase()==="pm"&&n<12?o=n+12:r.toLowerCase()==="am"&&n===12&&(o=0)),s.setHours(o,a||0,0,0),s}}class z{static createElement(e,t={},s=[]){const i=document.createElement(e);return Object.entries(t).forEach(([r,n])=>{if(r==="className")i.className=n;else if(r==="style"&&typeof n=="object")Object.assign(i.style,n);else if(r.startsWith("data-"))i.setAttribute(r,n);else if(r.startsWith("on")&&typeof n=="function"){const a=r.slice(2).toLowerCase();i.addEventListener(a,n)}else i[r]=n}),s.forEach(r=>{typeof r=="string"?i.appendChild(document.createTextNode(r)):r instanceof Node&&i.appendChild(r)}),i}static addEventListeners(e,t){return Object.entries(t).forEach(([s,i])=>{e.addEventListener(s,i)}),()=>{Object.entries(t).forEach(([s,i])=>{e.removeEventListener(s,i)})}}static delegate(e,t,s,i){const r=n=>{const a=n.target.closest(t);a&&e.contains(a)&&i.call(a,n)};return e.addEventListener(s,r),()=>e.removeEventListener(s,r)}static getPosition(e){const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX,bottom:t.bottom+window.scrollY,right:t.right+window.scrollX,width:t.width,height:t.height}}static isInViewport(e,t=0){const s=e.getBoundingClientRect();return s.top>=-t&&s.left>=-t&&s.bottom<=(window.innerHeight||document.documentElement.clientHeight)+t&&s.right<=(window.innerWidth||document.documentElement.clientWidth)+t}static scrollToElement(e,t={}){const{behavior:s="smooth",block:i="start",inline:r="nearest"}=t;e.scrollIntoView({behavior:s,block:i,inline:r})}static getStyle(e,t){return window.getComputedStyle(e).getPropertyValue(t)}static setStyles(e,t){Object.assign(e.style,t)}static async animateClass(e,t,s=300){e.classList.add(t),await this.wait(s),e.classList.remove(t)}static waitForAnimation(e,t="animationend"){return new Promise(s=>{const i=()=>{e.removeEventListener(t,i),s()};e.addEventListener(t,i)})}static wait(e){return new Promise(t=>setTimeout(t,e))}static parseHTML(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}static escapeHTML(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}static debounce(e,t=250){let s;return function(...r){const n=()=>{clearTimeout(s),e(...r)};clearTimeout(s),s=setTimeout(n,t)}}static throttle(e,t=250){let s;return function(...i){s||(e.apply(this,i),s=!0,setTimeout(()=>s=!1,t))}}static closest(e,t){return e.closest(t)}static parents(e,t){const s=[];let i=e.parentElement;for(;i;)i.matches(t)&&s.push(i),i=i.parentElement;return s}static getOuterDimensions(e){const t=window.getComputedStyle(e),s={top:parseInt(t.marginTop),right:parseInt(t.marginRight),bottom:parseInt(t.marginBottom),left:parseInt(t.marginLeft)};return{width:e.offsetWidth+s.left+s.right,height:e.offsetHeight+s.top+s.bottom,margin:s}}static cloneWithEvents(e,t=!0){return e.cloneNode(t)}static trapFocus(e){const t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(t.length===0)return e.setAttribute("tabindex","-1"),e.focus(),()=>e.removeAttribute("tabindex");const s=t[0],i=t[t.length-1],r=n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===s&&(i==null||i.focus(),n.preventDefault()):document.activeElement===i&&(s==null||s.focus(),n.preventDefault()))};return e.addEventListener("keydown",r),s==null||s.focus(),()=>e.removeEventListener("keydown",r)}}class T{static getCSSVariable(e,t=document.documentElement){return getComputedStyle(t).getPropertyValue(e).trim()}static setCSSVariables(e,t=document.documentElement){Object.entries(e).forEach(([s,i])=>{t.style.setProperty(s,i)})}static getBaseStyles(){return`
16
16
  :host {
17
17
  /* Apply CSS variables */
18
18
  ${Object.entries(this.cssVariables).map(([e,t])=>`${e}: ${t};`).join(`
@@ -149,7 +149,7 @@
149
149
  padding: 0;
150
150
  border-radius: var(--fc-border-radius-full);
151
151
  }
152
- `}static darken(e,t){const s=parseInt(e.replace("#",""),16),i=Math.round(2.55*t),n=(s>>16)-i,r=(s>>8&255)-i,a=(s&255)-i;return"#"+(16777216+(n<255?n<1?0:n:255)*65536+(r<255?r<1?0:r:255)*256+(a<255?a<1?0:a:255)).toString(16).slice(1)}static lighten(e,t){const s=parseInt(e.replace("#",""),16),i=Math.round(2.55*t),n=(s>>16)+i,r=(s>>8&255)+i,a=(s&255)+i;return"#"+(16777216+(n<255?n<1?0:n:255)*65536+(r<255?r<1?0:r:255)*256+(a<255?a<1?0:a:255)).toString(16).slice(1)}static getContrastColor(e){const t=e.replace("#",""),s=parseInt(t.substr(0,2),16),i=parseInt(t.substr(2,2),16),n=parseInt(t.substr(4,2),16);return(s*299+i*587+n*114)/1e3>=128?"#000000":"#FFFFFF"}static sanitizeColor(e,t="var(--fc-primary-color)"){if(!e||typeof e!="string")return t;const s=e.trim();return/[;{}()<>\"\'\\]/.test(s)?t:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(s)||/^var\(--[a-zA-Z0-9-]+\)$/.test(s)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*(0|1|0?\.\d+))?\s*\)$/.test(s)||["transparent","currentColor","inherit","black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","navy","teal","aqua","maroon","olive","silver","fuchsia"].includes(s.toLowerCase())?s:t}static hexToRgba(e,t=1){const s=e.replace("#",""),i=parseInt(s.substr(0,2),16),n=parseInt(s.substr(2,2),16),r=parseInt(s.substr(4,2),16);return`rgba(${i}, ${n}, ${r}, ${t})`}static getGridStyles(){return`
152
+ `}static darken(e,t){const s=parseInt(e.replace("#",""),16),i=Math.round(2.55*t),r=(s>>16)-i,n=(s>>8&255)-i,a=(s&255)-i;return"#"+(16777216+(r<255?r<1?0:r:255)*65536+(n<255?n<1?0:n:255)*256+(a<255?a<1?0:a:255)).toString(16).slice(1)}static lighten(e,t){const s=parseInt(e.replace("#",""),16),i=Math.round(2.55*t),r=(s>>16)+i,n=(s>>8&255)+i,a=(s&255)+i;return"#"+(16777216+(r<255?r<1?0:r:255)*65536+(n<255?n<1?0:n:255)*256+(a<255?a<1?0:a:255)).toString(16).slice(1)}static getContrastColor(e){const t=e.replace("#",""),s=parseInt(t.substr(0,2),16),i=parseInt(t.substr(2,2),16),r=parseInt(t.substr(4,2),16);return(s*299+i*587+r*114)/1e3>=128?"#000000":"#FFFFFF"}static sanitizeColor(e,t="var(--fc-primary-color)"){if(!e||typeof e!="string")return t;const s=e.trim();return/[;{}()<>\"\'\\]/.test(s)?t:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(s)||/^var\(--[a-zA-Z0-9-]+\)$/.test(s)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*(0|1|0?\.\d+))?\s*\)$/.test(s)||["transparent","currentColor","inherit","black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","navy","teal","aqua","maroon","olive","silver","fuchsia"].includes(s.toLowerCase())?s:t}static hexToRgba(e,t=1){const s=e.replace("#",""),i=parseInt(s.substr(0,2),16),r=parseInt(s.substr(2,2),16),n=parseInt(s.substr(4,2),16);return`rgba(${i}, ${r}, ${n}, ${t})`}static getGridStyles(){return`
153
153
  .fc-grid {
154
154
  display: grid;
155
155
  gap: 1px;
@@ -235,10 +235,10 @@
235
235
  .fc-scale-in {
236
236
  animation: fc-scale-in var(--fc-transition);
237
237
  }
238
- `}}R(T,"colors",{primary:"#3B82F6",secondary:"#64748B",accent:"#F59E0B",danger:"#EF4444",warning:"#F97316",info:"#06B6D4",success:"#22C55E",light:"#F8FAFC",dark:"#0F172A",white:"#FFFFFF",gray:{50:"#F8FAFC",100:"#F1F5F9",200:"#E2E8F0",300:"#CBD5E1",400:"#94A3B8",500:"#64748B",600:"#475569",700:"#334155",800:"#1E293B",900:"#0F172A"}}),R(T,"cssVariables",{"--fc-primary-color":"#2563EB","--fc-primary-hover":"#1D4ED8","--fc-primary-light":"#EFF6FF","--fc-text-color":"#111827","--fc-text-secondary":"#6B7280","--fc-text-light":"#9CA3AF","--fc-border-color":"#E5E7EB","--fc-border-color-hover":"#D1D5DB","--fc-background":"#FFFFFF","--fc-background-alt":"#FAFAFA","--fc-background-hover":"#F3F4F6","--fc-background-active":"#E5E7EB","--fc-accent-color":"#F59E0B","--fc-danger-color":"#EF4444","--fc-success-color":"#10B981","--fc-font-family":'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',"--fc-font-size-xs":"11px","--fc-font-size-sm":"12px","--fc-font-size-base":"13px","--fc-font-size-lg":"15px","--fc-font-size-xl":"18px","--fc-font-size-2xl":"24px","--fc-line-height":"1.4","--fc-font-weight-normal":"400","--fc-font-weight-medium":"500","--fc-font-weight-semibold":"600","--fc-font-weight-bold":"700","--fc-spacing-xs":"2px","--fc-spacing-sm":"6px","--fc-spacing-md":"10px","--fc-spacing-lg":"14px","--fc-spacing-xl":"20px","--fc-spacing-2xl":"28px","--fc-border-width":"1px","--fc-border-radius-sm":"3px","--fc-border-radius":"5px","--fc-border-radius-lg":"8px","--fc-border-radius-full":"9999px","--fc-shadow-sm":"0 1px 1px rgba(0,0,0,0.05)","--fc-shadow":"0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)","--fc-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1)","--fc-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1)","--fc-transition-fast":"100ms ease-out","--fc-transition":"150ms ease-out","--fc-transition-slow":"250ms ease-out","--fc-z-dropdown":"1000","--fc-z-modal":"2000","--fc-z-tooltip":"3000"}),R(T,"breakpoints",{xs:"320px",sm:"576px",md:"768px",lg:"992px",xl:"1200px","2xl":"1400px"});class F{constructor(e,t){this.container=e,this.stateManager=t,this._listeners=[],this._scrolled=!1}render(){throw new Error("render() must be implemented by subclass")}cleanup(){this._listeners.forEach(({element:e,event:t,handler:s})=>{e.removeEventListener(t,s)}),this._listeners=[]}addListener(e,t,s){const i=s.bind(this);e.addEventListener(t,i),this._listeners.push({element:e,event:t,handler:i})}escapeHTML(e){return e==null?"":z.escapeHTML(String(e))}isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}isSameDay(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}formatHour(e){const t=e>=12?"PM":"AM";return`${e%12||12} ${t}`}formatTime(e){const t=e.getHours(),s=e.getMinutes(),i=t>=12?"PM":"AM",n=t%12||12;return s===0?`${n} ${i}`:`${n}:${s.toString().padStart(2,"0")} ${i}`}getContrastingTextColor(e){if(!e||typeof e!="string")return"white";const t=e.charAt(0)==="#"?e.substring(1):e;if(!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t))return"white";const s=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,i=parseInt(s.substring(0,2),16),n=parseInt(s.substring(2,4),16),r=parseInt(s.substring(4,6),16);if(isNaN(i)||isNaN(n)||isNaN(r))return"white";const o=[i/255,n/255,r/255].map(l=>l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4));return .2126*o[0]+.7152*o[1]+.0722*o[2]>.179?"black":"white"}renderNowIndicator(){const e=new Date;return`<div class="fc-now-indicator" style="position: absolute; left: 0; right: 0; top: ${e.getHours()*60+e.getMinutes()}px; height: 2px; background: #dc2626; z-index: 15; pointer-events: none;"></div>`}renderTimedEvent(e,t={}){const{compact:s=!0}=t,i=new Date(e.start),n=new Date(e.end),r=i.getHours()*60+i.getMinutes(),a=Math.max((n-i)/(1e3*60),s?20:30),o=e.backgroundColor||"#2563eb",c=s?"4px 8px":"8px 12px",l=s?"11px":"13px",d=s?"2px":"12px",h=s?"2px":"24px",p=s?"4px":"6px";return`
238
+ `}}R(T,"colors",{primary:"#3B82F6",secondary:"#64748B",accent:"#F59E0B",danger:"#EF4444",warning:"#F97316",info:"#06B6D4",success:"#22C55E",light:"#F8FAFC",dark:"#0F172A",white:"#FFFFFF",gray:{50:"#F8FAFC",100:"#F1F5F9",200:"#E2E8F0",300:"#CBD5E1",400:"#94A3B8",500:"#64748B",600:"#475569",700:"#334155",800:"#1E293B",900:"#0F172A"}}),R(T,"cssVariables",{"--fc-primary-color":"#2563EB","--fc-primary-hover":"#1D4ED8","--fc-primary-light":"#EFF6FF","--fc-text-color":"#111827","--fc-text-secondary":"#6B7280","--fc-text-light":"#9CA3AF","--fc-border-color":"#E5E7EB","--fc-border-color-hover":"#D1D5DB","--fc-background":"#FFFFFF","--fc-background-alt":"#FAFAFA","--fc-background-hover":"#F3F4F6","--fc-background-active":"#E5E7EB","--fc-accent-color":"#F59E0B","--fc-danger-color":"#EF4444","--fc-success-color":"#10B981","--fc-font-family":'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',"--fc-font-size-xs":"11px","--fc-font-size-sm":"12px","--fc-font-size-base":"13px","--fc-font-size-lg":"15px","--fc-font-size-xl":"18px","--fc-font-size-2xl":"24px","--fc-line-height":"1.4","--fc-font-weight-normal":"400","--fc-font-weight-medium":"500","--fc-font-weight-semibold":"600","--fc-font-weight-bold":"700","--fc-spacing-xs":"2px","--fc-spacing-sm":"6px","--fc-spacing-md":"10px","--fc-spacing-lg":"14px","--fc-spacing-xl":"20px","--fc-spacing-2xl":"28px","--fc-border-width":"1px","--fc-border-radius-sm":"3px","--fc-border-radius":"5px","--fc-border-radius-lg":"8px","--fc-border-radius-full":"9999px","--fc-shadow-sm":"0 1px 1px rgba(0,0,0,0.05)","--fc-shadow":"0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)","--fc-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1)","--fc-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1)","--fc-transition-fast":"100ms ease-out","--fc-transition":"150ms ease-out","--fc-transition-slow":"250ms ease-out","--fc-z-dropdown":"1000","--fc-z-modal":"2000","--fc-z-tooltip":"3000"}),R(T,"breakpoints",{xs:"320px",sm:"576px",md:"768px",lg:"992px",xl:"1200px","2xl":"1400px"});class L{constructor(e,t){this.container=e,this.stateManager=t,this._listeners=[],this._scrolled=!1}render(){throw new Error("render() must be implemented by subclass")}cleanup(){this._listeners.forEach(({element:e,event:t,handler:s})=>{e.removeEventListener(t,s)}),this._listeners=[]}addListener(e,t,s){const i=s.bind(this);e.addEventListener(t,i),this._listeners.push({element:e,event:t,handler:i})}escapeHTML(e){return e==null?"":z.escapeHTML(String(e))}isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}isSameDay(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}formatHour(e){const t=e>=12?"PM":"AM";return`${e%12||12} ${t}`}formatTime(e){const t=e.getHours(),s=e.getMinutes(),i=t>=12?"PM":"AM",r=t%12||12;return s===0?`${r} ${i}`:`${r}:${s.toString().padStart(2,"0")} ${i}`}getContrastingTextColor(e){if(!e||typeof e!="string")return"white";const t=e.charAt(0)==="#"?e.substring(1):e;if(!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t))return"white";const s=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,i=parseInt(s.substring(0,2),16),r=parseInt(s.substring(2,4),16),n=parseInt(s.substring(4,6),16);if(isNaN(i)||isNaN(r)||isNaN(n))return"white";const o=[i/255,r/255,n/255].map(l=>l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4));return .2126*o[0]+.7152*o[1]+.0722*o[2]>.179?"black":"white"}renderNowIndicator(){const e=new Date;return`<div class="fc-now-indicator" style="position: absolute; left: 0; right: 0; top: ${e.getHours()*60+e.getMinutes()}px; height: 2px; background: #dc2626; z-index: 15; pointer-events: none;"></div>`}renderTimedEvent(e,t={}){const{compact:s=!0}=t,i=new Date(e.start),r=new Date(e.end),n=i.getHours()*60+i.getMinutes(),a=Math.max((r-i)/(1e3*60),s?20:30),o=e.backgroundColor||"#2563eb",c=s?"4px 8px":"8px 12px",l=s?"11px":"13px",h=s?"2px":"12px",d=s?"2px":"24px",p=s?"4px":"6px";return`
239
239
  <div class="fc-event fc-timed-event" data-event-id="${this.escapeHTML(e.id)}"
240
- style="position: absolute; top: ${r}px; height: ${a}px;
241
- left: ${d}; right: ${h};
240
+ style="position: absolute; top: ${n}px; height: ${a}px;
241
+ left: ${h}; right: ${d};
242
242
  background-color: ${o}; border-radius: ${p};
243
243
  padding: ${c}; font-size: ${l};
244
244
  font-weight: 500; color: white; overflow: hidden;
@@ -248,19 +248,19 @@
248
248
  ${this.escapeHTML(e.title)}
249
249
  </div>
250
250
  <div style="font-size: ${s?"10px":"11px"}; opacity: 0.9;">
251
- ${this.formatTime(i)}${s?"":" - "+this.formatTime(n)}
251
+ ${this.formatTime(i)}${s?"":" - "+this.formatTime(r)}
252
252
  </div>
253
253
  </div>
254
- `}attachCommonEventHandlers(){this.container.querySelectorAll(".fc-event").forEach(e=>{this.addListener(e,"click",t=>{t.stopPropagation();const s=e.dataset.eventId,i=this.stateManager.getEvents().find(n=>n.id===s);i&&this.stateManager.selectEvent(i)})})}}class E extends F{constructor(e,t){super(e,t),this.maxEventsToShow=3}render(){if(!this.container||!this.stateManager)return;const e=this.stateManager.getViewData();if(!e||!e.weeks){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">No data available for month view.</div>';return}this.cleanup();const t=this.stateManager.getState().config,s=this._renderMonthView(e,t);this.container.innerHTML=s,this._attachEventHandlers()}_renderMonthView(e,t){const s=t.weekStartsOn||0;let n=`
254
+ `}attachCommonEventHandlers(){this.container.querySelectorAll(".fc-event").forEach(e=>{this.addListener(e,"click",t=>{t.stopPropagation();const s=e.dataset.eventId,i=this.stateManager.getEvents().find(r=>r.id===s);i&&this.stateManager.selectEvent(i)})})}}class E extends L{constructor(e,t){super(e,t),this.maxEventsToShow=3}render(){if(!this.container||!this.stateManager)return;const e=this.stateManager.getViewData();if(!e||!e.weeks){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">No data available for month view.</div>';return}this.cleanup();const t=this.stateManager.getState().config,s=this._renderMonthView(e,t);this.container.innerHTML=s,this._attachEventHandlers()}_renderMonthView(e,t){const s=t.weekStartsOn||0;let r=`
255
255
  <div class="fc-month-view" style="display: flex; flex-direction: column; height: 100%; min-height: 400px; background: #fff; border: 1px solid #e5e7eb;">
256
256
  <div class="fc-month-header" style="display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #f9fafb;">
257
- ${this._getDayNames(s).map(r=>`<div class="fc-month-header-cell" style="padding: 12px 8px; text-align: center; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase;">${r}</div>`).join("")}
257
+ ${this._getDayNames(s).map(n=>`<div class="fc-month-header-cell" style="padding: 12px 8px; text-align: center; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase;">${n}</div>`).join("")}
258
258
  </div>
259
259
  <div class="fc-month-body" style="display: flex; flex-direction: column; flex: 1;">
260
- `;return e.weeks.forEach(r=>{n+=this._renderWeek(r)}),n+="</div></div>",n}_getDayNames(e){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=[];for(let i=0;i<7;i++){const n=(e+i)%7;s.push(t[n])}return s}_renderWeek(e){let t='<div class="fc-month-week" style="display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; min-height: 80px;">';return e.days.forEach(s=>{t+=this._renderDay(s)}),t+="</div>",t}_renderDay(e){const t=!e.isCurrentMonth,s=e.isToday,i=t?"#f3f4f6":"#fff",n=t?"#9ca3af":"#111827",r=s?"background: #2563eb; color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;":"",a=e.events||[],o=a.slice(0,this.maxEventsToShow),c=a.length-this.maxEventsToShow;return`
260
+ `;return e.weeks.forEach(n=>{r+=this._renderWeek(n)}),r+="</div></div>",r}_getDayNames(e){const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=[];for(let i=0;i<7;i++){const r=(e+i)%7;s.push(t[r])}return s}_renderWeek(e){let t='<div class="fc-month-week" style="display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; min-height: 80px;">';return e.days.forEach(s=>{t+=this._renderDay(s)}),t+="</div>",t}_renderDay(e){const t=!e.isCurrentMonth,s=e.isToday,i=t?"#f3f4f6":"#fff",r=t?"#9ca3af":"#111827",n=s?"background: #2563eb; color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;":"",a=e.events||[],o=a.slice(0,this.maxEventsToShow),c=a.length-this.maxEventsToShow;return`
261
261
  <div class="fc-month-day" data-date="${e.date}"
262
262
  style="background: ${i}; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: 4px; min-height: 80px; cursor: pointer; display: flex; flex-direction: column;">
263
- <div class="fc-day-number" style="font-size: 13px; font-weight: 500; color: ${n}; padding: 2px 4px; margin-bottom: 4px; ${r}">
263
+ <div class="fc-day-number" style="font-size: 13px; font-weight: 500; color: ${r}; padding: 2px 4px; margin-bottom: 4px; ${n}">
264
264
  ${e.dayOfMonth}
265
265
  </div>
266
266
  <div class="fc-day-events" style="display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden;">
@@ -273,11 +273,11 @@
273
273
  style="background-color: ${t}; font-size: 11px; padding: 2px 6px; border-radius: 3px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;">
274
274
  ${this.escapeHTML(e.title)}
275
275
  </div>
276
- `}_attachEventHandlers(){this.container.querySelectorAll(".fc-month-day").forEach(e=>{this.addListener(e,"click",t=>{if(t.target.closest(".fc-event"))return;const s=new Date(e.dataset.date);this.stateManager.selectDate(s)})}),this.attachCommonEventHandlers()}}class L extends F{constructor(e,t){super(e,t),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const e=this.stateManager.getViewData();if(!e||!e.days||e.days.length===0){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">No data available for week view.</div>';return}this.cleanup();const t=this.stateManager.getState().config,s=this._renderWeekView(e,t);this.container.innerHTML=s,this._attachEventHandlers(),this._scrollToCurrentTime()}_renderWeekView(e,t){const s=e.days,i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=Array.from({length:24},(a,o)=>o),r=s.map(a=>{const o=new Date(a.date),c=a.events||[];return{...a,date:o,dayName:i[o.getDay()],dayOfMonth:o.getDate(),isToday:this.isToday(o),timedEvents:c.filter(l=>!l.allDay),allDayEvents:c.filter(l=>l.allDay)}});return`
276
+ `}_attachEventHandlers(){this.container.querySelectorAll(".fc-month-day").forEach(e=>{this.addListener(e,"click",t=>{if(t.target.closest(".fc-event"))return;const s=new Date(e.dataset.date);this.stateManager.selectDate(s)})}),this.attachCommonEventHandlers()}}class F extends L{constructor(e,t){super(e,t),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const e=this.stateManager.getViewData();if(!e||!e.days||e.days.length===0){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">No data available for week view.</div>';return}this.cleanup();const t=this.stateManager.getState().config,s=this._renderWeekView(e,t);this.container.innerHTML=s,this._attachEventHandlers(),this._scrollToCurrentTime()}_renderWeekView(e,t){const s=e.days,i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=Array.from({length:24},(a,o)=>o),n=s.map(a=>{const o=new Date(a.date),c=a.events||[];return{...a,date:o,dayName:i[o.getDay()],dayOfMonth:o.getDate(),isToday:this.isToday(o),timedEvents:c.filter(l=>!l.allDay),allDayEvents:c.filter(l=>l.allDay)}});return`
277
277
  <div class="fc-week-view" style="display: flex; flex-direction: column; height: 100%; background: #fff; overflow: hidden;">
278
- ${this._renderHeader(r)}
279
- ${this._renderAllDayRow(r)}
280
- ${this._renderTimeGrid(r,n)}
278
+ ${this._renderHeader(n)}
279
+ ${this._renderAllDayRow(n)}
280
+ ${this._renderTimeGrid(n,r)}
281
281
  </div>
282
282
  `}_renderHeader(e){return`
283
283
  <div class="fc-week-header" style="display: grid; grid-template-columns: 60px repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0;">
@@ -335,13 +335,13 @@
335
335
  <!-- Timed events -->
336
336
  ${e.timedEvents.map(s=>this.renderTimedEvent(s,{compact:!0})).join("")}
337
337
  </div>
338
- `}_attachEventHandlers(){this.container.querySelectorAll(".fc-week-day-column").forEach(e=>{this.addListener(e,"click",t=>{if(t.target.closest(".fc-event"))return;const s=new Date(e.dataset.date),i=e.getBoundingClientRect(),n=this.container.querySelector("#week-scroll-container"),r=t.clientY-i.top+(n?n.scrollTop:0);s.setHours(Math.floor(r/this.hourHeight),Math.floor(r%this.hourHeight/(this.hourHeight/60)),0,0),this.stateManager.selectDate(s)})}),this.attachCommonEventHandlers()}_scrollToCurrentTime(){if(this._scrolled)return;const e=this.container.querySelector("#week-scroll-container");e&&(e.scrollTop=8*this.hourHeight-50,this._scrolled=!0)}}class H extends F{constructor(e,t){super(e,t),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const e=this.stateManager.getViewData();if(!e){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">No data available for day view.</div>';return}this.cleanup();const t=this.stateManager.getState().config,s=this._renderDayView(e,t);this.container.innerHTML=s,this._attachEventHandlers(),this._scrollToCurrentTime()}_renderDayView(e,t){var d,h;const s=((h=(d=this.stateManager)==null?void 0:d.getState())==null?void 0:h.currentDate)||new Date,i=this._extractDayData(e,s);if(!i)return'<div style="padding: 20px; text-align: center; color: #666;">No data available for day view.</div>';const{dayDate:n,dayName:r,isToday:a,allDayEvents:o,timedEvents:c}=i,l=Array.from({length:24},(p,w)=>w);return`
338
+ `}_attachEventHandlers(){this.container.querySelectorAll(".fc-week-day-column").forEach(e=>{this.addListener(e,"click",t=>{if(t.target.closest(".fc-event"))return;const s=new Date(e.dataset.date),i=e.getBoundingClientRect(),r=this.container.querySelector("#week-scroll-container"),n=t.clientY-i.top+(r?r.scrollTop:0);s.setHours(Math.floor(n/this.hourHeight),Math.floor(n%this.hourHeight/(this.hourHeight/60)),0,0),this.stateManager.selectDate(s)})}),this.attachCommonEventHandlers()}_scrollToCurrentTime(){if(this._scrolled)return;const e=this.container.querySelector("#week-scroll-container");e&&(e.scrollTop=8*this.hourHeight-50,this._scrolled=!0)}}class H extends L{constructor(e,t){super(e,t),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const e=this.stateManager.getViewData();if(!e){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">No data available for day view.</div>';return}this.cleanup();const t=this.stateManager.getState().config,s=this._renderDayView(e,t);this.container.innerHTML=s,this._attachEventHandlers(),this._scrollToCurrentTime()}_renderDayView(e,t){var h,d;const s=((d=(h=this.stateManager)==null?void 0:h.getState())==null?void 0:d.currentDate)||new Date,i=this._extractDayData(e,s);if(!i)return'<div style="padding: 20px; text-align: center; color: #666;">No data available for day view.</div>';const{dayDate:r,dayName:n,isToday:a,allDayEvents:o,timedEvents:c}=i,l=Array.from({length:24},(p,w)=>w);return`
339
339
  <div class="fc-day-view" style="display: flex; flex-direction: column; height: 100%; background: #fff; overflow: hidden;">
340
- ${this._renderHeader(n,r,a)}
341
- ${this._renderAllDayRow(o,n)}
342
- ${this._renderTimeGrid(c,a,n,l)}
340
+ ${this._renderHeader(r,n,a)}
341
+ ${this._renderAllDayRow(o,r)}
342
+ ${this._renderTimeGrid(c,a,r,l)}
343
343
  </div>
344
- `}_extractDayData(e,t){let s,i,n,r,a;const o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];if(e.type==="day"&&e.date)if(s=new Date(e.date),i=e.dayName||o[s.getDay()],n=e.isToday!==void 0?e.isToday:this.isToday(s),r=e.allDayEvents||[],e.hours&&Array.isArray(e.hours)){const c=new Map;e.hours.forEach(l=>{(l.events||[]).forEach(d=>{c.has(d.id)||c.set(d.id,d)})}),a=Array.from(c.values())}else a=[];else if(e.days&&e.days.length>0){const c=e.days.find(d=>this.isSameDay(new Date(d.date),t))||e.days[0];s=new Date(c.date),i=o[s.getDay()],n=this.isToday(s);const l=c.events||[];r=l.filter(d=>d.allDay),a=l.filter(d=>!d.allDay)}else return null;return{dayDate:s,dayName:i,isToday:n,allDayEvents:r,timedEvents:a}}_renderHeader(e,t,s){return`
344
+ `}_extractDayData(e,t){let s,i,r,n,a;const o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];if(e.type==="day"&&e.date)if(s=new Date(e.date),i=e.dayName||o[s.getDay()],r=e.isToday!==void 0?e.isToday:this.isToday(s),n=e.allDayEvents||[],e.hours&&Array.isArray(e.hours)){const c=new Map;e.hours.forEach(l=>{(l.events||[]).forEach(h=>{c.has(h.id)||c.set(h.id,h)})}),a=Array.from(c.values())}else a=[];else if(e.days&&e.days.length>0){const c=e.days.find(h=>this.isSameDay(new Date(h.date),t))||e.days[0];s=new Date(c.date),i=o[s.getDay()],r=this.isToday(s);const l=c.events||[];n=l.filter(h=>h.allDay),a=l.filter(h=>!h.allDay)}else return null;return{dayDate:s,dayName:i,isToday:r,allDayEvents:n,timedEvents:a}}_renderHeader(e,t,s){return`
345
345
  <div class="fc-day-header" style="display: grid; grid-template-columns: 60px 1fr; border-bottom: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0;">
346
346
  <div style="border-right: 1px solid #e5e7eb;"></div>
347
347
  <div style="padding: 16px 24px;">
@@ -391,9 +391,9 @@
391
391
  ${t?this.renderNowIndicator():""}
392
392
 
393
393
  <!-- Timed events -->
394
- ${e.map(n=>this.renderTimedEvent(n,{compact:!1})).join("")}
394
+ ${e.map(r=>this.renderTimedEvent(r,{compact:!1})).join("")}
395
395
  </div>
396
- `}_attachEventHandlers(){this.container.querySelectorAll(".fc-day-column").forEach(e=>{this.addListener(e,"click",t=>{if(t.target.closest(".fc-event"))return;const s=new Date(e.dataset.date),i=e.getBoundingClientRect(),n=this.container.querySelector("#day-scroll-container"),r=t.clientY-i.top+(n?n.scrollTop:0);s.setHours(Math.floor(r/this.hourHeight),Math.floor(r%this.hourHeight/(this.hourHeight/60)),0,0),this.stateManager.selectDate(s)})}),this.attachCommonEventHandlers()}_scrollToCurrentTime(){if(this._scrolled)return;const e=this.container.querySelector("#day-scroll-container");e&&(e.scrollTop=8*this.hourHeight-50,this._scrolled=!0)}}class Q extends v{constructor(){super(),this._isVisible=!1,this._cleanupFocusTrap=null,this.config={title:"New Event",defaultDuration:60,colors:[{color:"#2563EB",label:"Blue"},{color:"#10B981",label:"Green"},{color:"#F59E0B",label:"Amber"},{color:"#EF4444",label:"Red"},{color:"#8B5CF6",label:"Purple"},{color:"#6B7280",label:"Gray"}]},this._formData={title:"",start:new Date,end:new Date,allDay:!1,color:this.config.colors[0].color}}static get observedAttributes(){return["open"]}attributeChangedCallback(e,t,s){e==="open"&&(s!==null?this.open():this.close())}getStyles(){return`
396
+ `}_attachEventHandlers(){this.container.querySelectorAll(".fc-day-column").forEach(e=>{this.addListener(e,"click",t=>{if(t.target.closest(".fc-event"))return;const s=new Date(e.dataset.date),i=e.getBoundingClientRect(),r=this.container.querySelector("#day-scroll-container"),n=t.clientY-i.top+(r?r.scrollTop:0);s.setHours(Math.floor(n/this.hourHeight),Math.floor(n%this.hourHeight/(this.hourHeight/60)),0,0),this.stateManager.selectDate(s)})}),this.attachCommonEventHandlers()}_scrollToCurrentTime(){if(this._scrolled)return;const e=this.container.querySelector("#day-scroll-container");e&&(e.scrollTop=8*this.hourHeight-50,this._scrolled=!0)}}class Q extends v{constructor(){super(),this._isVisible=!1,this._cleanupFocusTrap=null,this.config={title:"New Event",defaultDuration:60,colors:[{color:"#2563EB",label:"Blue"},{color:"#10B981",label:"Green"},{color:"#F59E0B",label:"Amber"},{color:"#EF4444",label:"Red"},{color:"#8B5CF6",label:"Purple"},{color:"#6B7280",label:"Gray"}]},this._formData={title:"",start:new Date,end:new Date,allDay:!1,color:this.config.colors[0].color}}static get observedAttributes(){return["open"]}attributeChangedCallback(e,t,s){e==="open"&&(s!==null?this.open():this.close())}getStyles(){return`
397
397
  ${T.getBaseStyles()}
398
398
  ${T.getButtonStyles()}
399
399
 
@@ -615,7 +615,7 @@
615
615
  <button class="fc-btn fc-btn-primary" id="save-btn">Save Event</button>
616
616
  </footer>
617
617
  </div>
618
- `}afterRender(){this.modalContent=this.$(".modal-content"),this.titleInput=this.$("#event-title"),this.startInput=this.$("#event-start"),this.endInput=this.$("#event-end"),this.colorContainer=this.$("#color-picker"),this.titleGroup=this.$("#title-group"),this.endGroup=this.$("#end-group"),this.addListener(this.$("#close-x"),"click",()=>this.close()),this.addListener(this.$("#cancel-btn"),"click",()=>this.close()),this.addListener(this.$("#save-btn"),"click",()=>this.save()),this.colorContainer.querySelectorAll(".color-btn").forEach(e=>{this.addListener(e,"click",t=>{this._formData.color=t.currentTarget.dataset.color,this.updateColorSelection()})}),this.addListener(this,"click",e=>{e.target===this&&this.close()}),this._keydownListenerAdded||(this._handleKeyDown=e=>{e.key==="Escape"&&this.hasAttribute("open")&&this.close()},window.addEventListener("keydown",this._handleKeyDown),this._keydownListenerAdded=!0)}updateColorSelection(){this.colorContainer.querySelectorAll(".color-btn").forEach(t=>{const s=t.dataset.color===this._formData.color;t.classList.toggle("selected",s),t.setAttribute("aria-checked",s?"true":"false")})}open(e=new Date){this.hasAttribute("open")||this.setAttribute("open",""),this.titleGroup.classList.remove("has-error"),this.endGroup.classList.remove("has-error"),this._formData.start=e,this._formData.end=new Date(e.getTime()+this.config.defaultDuration*60*1e3),this._formData.title="",this._formData.color=this.config.colors[0].color,this.startInput&&(this.titleInput.value="",this.startInput.value=this.formatDateForInput(this._formData.start),this.endInput.value=this.formatDateForInput(this._formData.end),this.updateColorSelection(),this._cleanupFocusTrap=z.trapFocus(this.modalContent))}close(){this.removeAttribute("open"),this._cleanupFocusTrap&&(this._cleanupFocusTrap(),this._cleanupFocusTrap=null)}validate(){let e=!0;this.titleGroup.classList.remove("has-error"),this.endGroup.classList.remove("has-error"),this.titleInput.value.trim()||(this.titleGroup.classList.add("has-error"),e=!1);const t=new Date(this.startInput.value);return new Date(this.endInput.value)<=t&&(this.endGroup.classList.add("has-error"),e=!1),e}save(){if(!this.validate())return;const e={title:this.titleInput.value.trim(),start:new Date(this.startInput.value),end:new Date(this.endInput.value),backgroundColor:this._formData.color};this.emit("save",e),this.close()}formatDateForInput(e){const t=o=>String(o).padStart(2,"0"),s=e.getFullYear(),i=t(e.getMonth()+1),n=t(e.getDate()),r=t(e.getHours()),a=t(e.getMinutes());return`${s}-${i}-${n}T${r}:${a}`}unmount(){this._cleanupFocusTrap&&this._cleanupFocusTrap(),this._handleKeyDown&&(window.removeEventListener("keydown",this._handleKeyDown),this._handleKeyDown=null,this._keydownListenerAdded=!1)}}customElements.get("forcecal-event-form")||customElements.define("forcecal-event-form",Q);class N extends v{static get observedAttributes(){return["view","date","locale","timezone","week-starts-on","height"]}constructor(){super(),this.stateManager=null,this.currentView=null,this._hasRendered=!1,this._cachedStyles=null}initialize(){const e={view:this.getAttribute("view")||"month",date:this.getAttribute("date")?new Date(this.getAttribute("date")):new Date,locale:this.getAttribute("locale")||"en-US",timeZone:this.getAttribute("timezone")||Intl.DateTimeFormat().resolvedOptions().timeZone,weekStartsOn:parseInt(this.getAttribute("week-starts-on")||"0")};this.stateManager=new Y(e),this.stateManager.subscribe(this.handleStateChange.bind(this)),this.setupEventListeners()}setupEventListeners(){g.on("navigation:*",(e,t)=>{this.emit("calendar-navigate",{action:t.split(":")[1],...e})}),g.on("view:changed",e=>{this.emit("calendar-view-change",e)}),g.on("event:*",(e,t)=>{this.emit(`calendar-event-${t.split(":")[1]}`,e)}),g.on("date:selected",e=>{this.emit("calendar-date-select",e)})}handleStateChange(e,t){var o,c;if(!this._hasRendered)return;const s=e.view!==(t==null?void 0:t.view),i=((o=e.currentDate)==null?void 0:o.getTime())!==((c=t==null?void 0:t.currentDate)==null?void 0:c.getTime()),n=e.events!==(t==null?void 0:t.events),r=e.loading!==(t==null?void 0:t.loading),a=e.error!==(t==null?void 0:t.error);if(r||a){this.render();return}s&&(this.currentView=e.view),s?(this._updateTitle(),this._updateViewButtons(),this._switchView()):i?(this._updateTitle(),this._updateViewContent()):n&&this._updateViewContent()}_updateTitle(){const e=this.$(".fc-title");if(e){const t=this.stateManager.getState();e.textContent=this.getTitle(t.currentDate,t.view)}}_updateViewButtons(){const e=this.stateManager.getState();this.$$("[data-view]").forEach(t=>{const s=t.dataset.view===e.view;t.classList.toggle("active",s)})}_switchView(){const e=this.$("#calendar-view-container");if(e){this._currentViewInstance&&this._currentViewInstance.cleanup&&this._currentViewInstance.cleanup();try{const s={month:E,week:L,day:H}[this.currentView]||E,i=new s(e,this.stateManager);i._viewType=this.currentView,this._currentViewInstance=i,i.render()}catch(t){console.error("[ForceCalendar] Error switching view:",t)}}}_updateViewContent(){this._currentViewInstance&&this._currentViewInstance.render&&this._currentViewInstance.render()}mount(){super.mount(),this.loadView(this.stateManager.getView())}loadView(e){this.currentView=e,this.render()}getStyles(){const e=this.getAttribute("height")||"800px";return`
618
+ `}afterRender(){this.modalContent=this.$(".modal-content"),this.titleInput=this.$("#event-title"),this.startInput=this.$("#event-start"),this.endInput=this.$("#event-end"),this.colorContainer=this.$("#color-picker"),this.titleGroup=this.$("#title-group"),this.endGroup=this.$("#end-group"),this.addListener(this.$("#close-x"),"click",()=>this.close()),this.addListener(this.$("#cancel-btn"),"click",()=>this.close()),this.addListener(this.$("#save-btn"),"click",()=>this.save()),this.colorContainer.querySelectorAll(".color-btn").forEach(e=>{this.addListener(e,"click",t=>{this._formData.color=t.currentTarget.dataset.color,this.updateColorSelection()})}),this.addListener(this,"click",e=>{e.target===this&&this.close()}),this._keydownListenerAdded||(this._handleKeyDown=e=>{e.key==="Escape"&&this.hasAttribute("open")&&this.close()},window.addEventListener("keydown",this._handleKeyDown),this._keydownListenerAdded=!0)}updateColorSelection(){this.colorContainer.querySelectorAll(".color-btn").forEach(t=>{const s=t.dataset.color===this._formData.color;t.classList.toggle("selected",s),t.setAttribute("aria-checked",s?"true":"false")})}open(e=new Date){this.hasAttribute("open")||this.setAttribute("open",""),this.titleGroup.classList.remove("has-error"),this.endGroup.classList.remove("has-error"),this._formData.start=e,this._formData.end=new Date(e.getTime()+this.config.defaultDuration*60*1e3),this._formData.title="",this._formData.color=this.config.colors[0].color,this.startInput&&(this.titleInput.value="",this.startInput.value=this.formatDateForInput(this._formData.start),this.endInput.value=this.formatDateForInput(this._formData.end),this.updateColorSelection(),this._cleanupFocusTrap=z.trapFocus(this.modalContent))}close(){this.removeAttribute("open"),this._cleanupFocusTrap&&(this._cleanupFocusTrap(),this._cleanupFocusTrap=null)}validate(){let e=!0;this.titleGroup.classList.remove("has-error"),this.endGroup.classList.remove("has-error"),this.titleInput.value.trim()||(this.titleGroup.classList.add("has-error"),e=!1);const t=new Date(this.startInput.value);return new Date(this.endInput.value)<=t&&(this.endGroup.classList.add("has-error"),e=!1),e}save(){if(!this.validate())return;const e={title:this.titleInput.value.trim(),start:new Date(this.startInput.value),end:new Date(this.endInput.value),backgroundColor:this._formData.color};this.emit("save",e),this.close()}formatDateForInput(e){const t=o=>String(o).padStart(2,"0"),s=e.getFullYear(),i=t(e.getMonth()+1),r=t(e.getDate()),n=t(e.getHours()),a=t(e.getMinutes());return`${s}-${i}-${r}T${n}:${a}`}unmount(){this._cleanupFocusTrap&&this._cleanupFocusTrap(),this._handleKeyDown&&(window.removeEventListener("keydown",this._handleKeyDown),this._handleKeyDown=null,this._keydownListenerAdded=!1)}}customElements.get("forcecal-event-form")||customElements.define("forcecal-event-form",Q);class P extends v{static get observedAttributes(){return["view","date","locale","timezone","week-starts-on","height"]}constructor(){super(),this.stateManager=null,this.currentView=null,this._hasRendered=!1,this._cachedStyles=null}initialize(){const e={view:this.getAttribute("view")||"month",date:this.getAttribute("date")?new Date(this.getAttribute("date")):new Date,locale:this.getAttribute("locale")||"en-US",timeZone:this.getAttribute("timezone")||Intl.DateTimeFormat().resolvedOptions().timeZone,weekStartsOn:parseInt(this.getAttribute("week-starts-on")||"0")};this.stateManager=new Y(e),this.stateManager.subscribe(this.handleStateChange.bind(this)),this.setupEventListeners()}setupEventListeners(){g.on("navigation:*",(e,t)=>{this.emit("calendar-navigate",{action:t.split(":")[1],...e})}),g.on("view:changed",e=>{this.emit("calendar-view-change",e)}),g.on("event:*",(e,t)=>{this.emit(`calendar-event-${t.split(":")[1]}`,e)}),g.on("date:selected",e=>{this.emit("calendar-date-select",e)})}handleStateChange(e,t){var o,c;if(!this._hasRendered)return;const s=e.view!==(t==null?void 0:t.view),i=((o=e.currentDate)==null?void 0:o.getTime())!==((c=t==null?void 0:t.currentDate)==null?void 0:c.getTime()),r=e.events!==(t==null?void 0:t.events),n=e.loading!==(t==null?void 0:t.loading),a=e.error!==(t==null?void 0:t.error);if(n||a){this.render();return}s&&(this.currentView=e.view),s?(this._updateTitle(),this._updateViewButtons(),this._switchView()):i?(this._updateTitle(),this._updateViewContent()):r&&this._updateViewContent()}_updateTitle(){const e=this.$(".fc-title");if(e){const t=this.stateManager.getState();e.textContent=this.getTitle(t.currentDate,t.view)}}_updateViewButtons(){const e=this.stateManager.getState();this.$$("[data-view]").forEach(t=>{const s=t.dataset.view===e.view;t.classList.toggle("active",s)})}_switchView(){const e=this.$("#calendar-view-container");if(e){this._currentViewInstance&&this._currentViewInstance.cleanup&&this._currentViewInstance.cleanup();try{const s={month:E,week:F,day:H}[this.currentView]||E,i=new s(e,this.stateManager);i._viewType=this.currentView,this._currentViewInstance=i,i.render()}catch(t){console.error("[ForceCalendar] Error switching view:",t)}}}_updateViewContent(){this._currentViewInstance&&this._currentViewInstance.render&&this._currentViewInstance.render()}mount(){super.mount(),this.loadView(this.stateManager.getView())}loadView(e){this.currentView=e,this.render()}getStyles(){const e=this.getAttribute("height")||"800px";return`
619
619
  ${T.getBaseStyles()}
620
620
  ${T.getButtonStyles()}
621
621
  ${T.getGridStyles()}
@@ -1000,13 +1000,13 @@
1000
1000
  height: 100%;
1001
1001
  background: var(--fc-background);
1002
1002
  }
1003
- `}template(){const e=this.stateManager.getState(),{currentDate:t,view:s,loading:i,error:n}=e;if(n)return`
1003
+ `}template(){const e=this.stateManager.getState(),{currentDate:t,view:s,loading:i,error:r}=e;if(r)return`
1004
1004
  <div class="force-calendar">
1005
1005
  <div class="fc-error">
1006
- <p><strong>Error:</strong> ${z.escapeHTML(n.message||"An error occurred")}</p>
1006
+ <p><strong>Error:</strong> ${z.escapeHTML(r.message||"An error occurred")}</p>
1007
1007
  </div>
1008
1008
  </div>
1009
- `;const r=this.getTitle(t,s);return`
1009
+ `;const n=this.getTitle(t,s);return`
1010
1010
  <div class="force-calendar">
1011
1011
  <header class="fc-header">
1012
1012
  <div class="fc-header-left">
@@ -1019,7 +1019,7 @@
1019
1019
  <button class="fc-nav-arrow" data-action="previous" title="Previous">
1020
1020
  ${this.getIcon("chevron-left")}
1021
1021
  </button>
1022
- <h2 class="fc-title">${r}</h2>
1022
+ <h2 class="fc-title">${n}</h2>
1023
1023
  <button class="fc-nav-arrow" data-action="next" title="Next">
1024
1024
  ${this.getIcon("chevron-right")}
1025
1025
  </button>
@@ -1055,7 +1055,7 @@
1055
1055
 
1056
1056
  <forcecal-event-form id="event-modal"></forcecal-event-form>
1057
1057
  </div>
1058
- `}renderView(){return'<div id="calendar-view-container"></div>'}afterRender(){const e=this.$("#calendar-view-container");if(e&&this.stateManager&&this.currentView){if(this._currentViewInstance&&this._currentViewInstance._viewType===this.currentView&&e.children.length>0)return;this._currentViewInstance&&(this._currentViewInstance.cleanup&&this._currentViewInstance.cleanup(),this._viewUnsubscribe&&(this._viewUnsubscribe(),this._viewUnsubscribe=null));try{const n={month:E,week:L,day:H}[this.currentView]||E,r=new n(e,this.stateManager);r._viewType=this.currentView,this._currentViewInstance=r,r.render()}catch(i){console.error("[ForceCalendar] Error creating/rendering view:",i)}}this.$$("[data-action]").forEach(i=>{this.addListener(i,"click",this.handleNavigation)}),this.$$("[data-view]").forEach(i=>{this.addListener(i,"click",this.handleViewChange)});const t=this.$("#event-modal"),s=this.$("#create-event-btn");s&&t&&this.addListener(s,"click",()=>{t.open(new Date)}),this.addListener(this.shadowRoot,"day-click",i=>{t&&t.open(i.detail.date)}),t&&this.addListener(t,"save",i=>{const n=i.detail,r=window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():Math.random().toString(36).substring(2,15);this.stateManager.addEvent({id:r,...n})}),this._hasRendered=!0}_createViewRenderer(e){const s={month:E,week:L,day:H}[e]||E;return new s(null,null)}handleNavigation(e){switch(e.currentTarget.dataset.action){case"today":this.stateManager.today();break;case"previous":this.stateManager.previous();break;case"next":this.stateManager.next();break}}handleViewChange(e){const t=e.currentTarget.dataset.view;this.stateManager.setView(t)}getTitle(e,t){const s=this.stateManager.state.config.locale;switch(t){case"month":return k.formatDate(e,"month",s);case"week":const i=k.startOfWeek(e),n=k.endOfWeek(e);return k.formatDateRange(i,n,s);case"day":return k.formatDate(e,"long",s);default:return k.formatDate(e,"month",s)}}getIcon(e){return{"chevron-left":`
1058
+ `}renderView(){return'<div id="calendar-view-container"></div>'}afterRender(){const e=this.$("#calendar-view-container");if(e&&this.stateManager&&this.currentView){if(this._currentViewInstance&&this._currentViewInstance._viewType===this.currentView&&e.children.length>0)return;this._currentViewInstance&&(this._currentViewInstance.cleanup&&this._currentViewInstance.cleanup(),this._viewUnsubscribe&&(this._viewUnsubscribe(),this._viewUnsubscribe=null));try{const r={month:E,week:F,day:H}[this.currentView]||E,n=new r(e,this.stateManager);n._viewType=this.currentView,this._currentViewInstance=n,n.render()}catch(i){console.error("[ForceCalendar] Error creating/rendering view:",i)}}this.$$("[data-action]").forEach(i=>{this.addListener(i,"click",this.handleNavigation)}),this.$$("[data-view]").forEach(i=>{this.addListener(i,"click",this.handleViewChange)});const t=this.$("#event-modal"),s=this.$("#create-event-btn");s&&t&&this.addListener(s,"click",()=>{t.open(new Date)}),this.addListener(this.shadowRoot,"day-click",i=>{t&&t.open(i.detail.date)}),t&&this.addListener(t,"save",i=>{const r=i.detail,n=window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():Math.random().toString(36).substring(2,15);this.stateManager.addEvent({id:n,...r})}),this._hasRendered=!0}_createViewRenderer(e){const s={month:E,week:F,day:H}[e]||E;return new s(null,null)}handleNavigation(e){switch(e.currentTarget.dataset.action){case"today":this.stateManager.today();break;case"previous":this.stateManager.previous();break;case"next":this.stateManager.next();break}}handleViewChange(e){const t=e.currentTarget.dataset.view;this.stateManager.setView(t)}getTitle(e,t){const s=this.stateManager.state.config.locale;switch(t){case"month":return S.formatDate(e,"month",s);case"week":const i=S.startOfWeek(e),r=S.endOfWeek(e);return S.formatDateRange(i,r,s);case"day":return S.formatDate(e,"long",s);default:return S.formatDate(e,"month",s)}}getIcon(e){return{"chevron-left":`
1059
1059
  <svg class="fc-icon" viewBox="0 0 24 24">
1060
1060
  <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
1061
1061
  </svg>
@@ -1067,5 +1067,5 @@
1067
1067
  <svg class="fc-icon" viewBox="0 0 24 24">
1068
1068
  <path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"/>
1069
1069
  </svg>
1070
- `}[e]||""}addEvent(e){return this.stateManager.addEvent(e)}updateEvent(e,t){return this.stateManager.updateEvent(e,t)}deleteEvent(e){return this.stateManager.deleteEvent(e)}getEvents(){return this.stateManager.getEvents()}setView(e){this.stateManager.setView(e)}setDate(e){this.stateManager.setDate(e)}next(){this.stateManager.next()}previous(){this.stateManager.previous()}today(){this.stateManager.today()}destroy(){this.stateManager&&this.stateManager.destroy(),g.clear(),super.cleanup()}}customElements.get("forcecal-main")||customElements.define("forcecal-main",N),typeof window<"u"&&typeof customElements<"u"&&console.log("Force Calendar Interface loading..."),m.BaseComponent=v,m.BaseViewRenderer=F,m.DOMUtils=z,m.DateUtils=k,m.DayViewRenderer=H,m.EventBus=U,m.ForceCalendar=N,m.MonthViewRenderer=E,m.StateManager=Y,m.StyleUtils=T,m.WeekViewRenderer=L,m.eventBus=g,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
1070
+ `}[e]||""}addEvent(e){return this.stateManager.addEvent(e)}updateEvent(e,t){return this.stateManager.updateEvent(e,t)}deleteEvent(e){return this.stateManager.deleteEvent(e)}getEvents(){return this.stateManager.getEvents()}setView(e){this.stateManager.setView(e)}setDate(e){this.stateManager.setDate(e)}next(){this.stateManager.next()}previous(){this.stateManager.previous()}today(){this.stateManager.today()}destroy(){this.stateManager&&this.stateManager.destroy(),g.clear(),super.cleanup()}}customElements.get("forcecal-main")||customElements.define("forcecal-main",P),typeof window<"u"&&typeof customElements<"u"&&console.log("Force Calendar Interface loading..."),m.BaseComponent=v,m.BaseViewRenderer=L,m.DOMUtils=z,m.DateUtils=S,m.DayViewRenderer=H,m.EventBus=U,m.ForceCalendar=P,m.MonthViewRenderer=E,m.StateManager=Y,m.StyleUtils=T,m.WeekViewRenderer=F,m.eventBus=g,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
1071
1071
  //# sourceMappingURL=force-calendar-interface.umd.js.map