@forcecalendar/interface 1.0.57 → 1.0.58

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(d,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@forcecalendar/core")):typeof define=="function"&&define.amd?define(["exports","@forcecalendar/core"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.ForceCalendarInterface={},d.ForceCalendarCore))})(this,function(d,f){"use strict";var A=Object.defineProperty;var R=(d,f,v)=>f in d?A(d,f,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[f]=v;var x=(d,f,v)=>R(d,typeof f!="symbol"?f+"":f,v);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(),this._styleEl=null,this._contentWrapper=null}initialize(){}mount(){this.render()}unmount(){}cleanup(){this._listeners.forEach(({element:t,event:e,handler:r})=>{t.removeEventListener(e,r)}),this._listeners=[]}setState(t){const e=this._state;this._state={...this._state,...t},this.stateChanged(e,this._state),this.render()}getState(){return this._state}stateChanged(t,e){}setProp(t,e){const r=this._props.get(t);this._props.set(t,e),this.propChanged(t,r,e)}getProp(t){return this._props.get(t)}propChanged(t,e,r){}addListener(t,e,r){if(!t||!e||!r){console.warn("addListener called with invalid parameters",{element:t,event:e,handler:r});return}const i=r.bind(this);t.addEventListener(e,i),this._listeners.push({element:t,event:e,handler:i})}emit(t,e={}){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}getStyles(){return""}getBaseStyles(){return`
1
+ (function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@forcecalendar/core")):typeof define=="function"&&define.amd?define(["exports","@forcecalendar/core"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.ForceCalendarInterface={},d.ForceCalendarCore))})(this,function(d,f){"use strict";var A=Object.defineProperty;var R=(d,f,v)=>f in d?A(d,f,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[f]=v;var w=(d,f,v)=>R(d,typeof f!="symbol"?f+"":f,v);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(),this._styleEl=null,this._contentWrapper=null}initialize(){}mount(){this.render()}unmount(){}cleanup(){this._listeners.forEach(({element:t,event:e,handler:r})=>{t.removeEventListener(e,r)}),this._listeners=[]}setState(t){const e=this._state;this._state={...this._state,...t},this.stateChanged(e,this._state),this.render()}getState(){return this._state}stateChanged(t,e){}setProp(t,e){const r=this._props.get(t);this._props.set(t,e),this.propChanged(t,r,e)}getProp(t){return this._props.get(t)}propChanged(t,e,r){}addListener(t,e,r){if(!t||!e||!r){console.warn("addListener called with invalid parameters",{element:t,event:e,handler:r});return}const i=r.bind(this);t.addEventListener(e,i),this._listeners.push({element:t,event:e,handler:i})}emit(t,e={}){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}getStyles(){return""}getBaseStyles(){return`
2
2
  :host {
3
3
  display: block;
4
4
  box-sizing: border-box;
@@ -8,7 +8,7 @@
8
8
  box-sizing: inherit;
9
9
  }
10
10
  `}render(){this.cleanup();const t=this.template();this._styleEl||(this._styleEl=document.createElement("style"),this.shadowRoot.appendChild(this._styleEl),this._contentWrapper=document.createElement("div"),this._contentWrapper.setAttribute("id","fc-root"),this._contentWrapper.style.display="contents",this.shadowRoot.appendChild(this._contentWrapper)),this._styleEl.textContent=this.getBaseStyles()+`
11
- `+this.getStyles();const e=this._saveScrollPositions(),r=this._getActiveElementSelector();this._contentWrapper.innerHTML=t,this._restoreScrollPositions(e),this._restoreFocus(r),this.afterRender()}_saveScrollPositions(){const t=new Map;return this._contentWrapper&&this._contentWrapper.querySelectorAll("[id]").forEach(r=>{(r.scrollTop!==0||r.scrollLeft!==0)&&t.set(r.id,{top:r.scrollTop,left:r.scrollLeft})}),t}_restoreScrollPositions(t){!this._contentWrapper||t.size===0||t.forEach((e,r)=>{const i=this._contentWrapper.querySelector(`[id="${CSS.escape(r)}"]`);i&&(i.scrollTop=e.top,i.scrollLeft=e.left)})}_getActiveElementSelector(){const t=this.shadowRoot.activeElement;return!t||t===this._contentWrapper?null:t.id?`[id="${CSS.escape(t.id)}"]`:t.dataset&&t.dataset.action?`[data-action="${CSS.escape(t.dataset.action)}"]`:t.dataset&&t.dataset.view?`[data-view="${CSS.escape(t.dataset.view)}"]`:t.tagName?t.tagName.toLowerCase():null}_restoreFocus(t){if(!(!t||!this._contentWrapper))try{const e=this._contentWrapper.querySelector(t);e&&typeof e.focus=="function"&&e.focus()}catch{}}template(){return""}afterRender(){}$(t){return this.shadowRoot.querySelector(t)}$$(t){return this.shadowRoot.querySelectorAll(t)}static get observedAttributes(){return[]}attributeChangedCallback(t,e,r){this.setProp(t,r),this._initialized&&this.render()}}class M{constructor(){this.events=new Map,this.wildcardHandlers=new Set}on(t,e,r={}){const{once:i=!1,priority:s=0}=r;if(t.includes("*")){const o={pattern:t,handler:e,once:i,priority:s};return this.wildcardHandlers.add(o),()=>this.wildcardHandlers.delete(o)}this.events.has(t)||this.events.set(t,[]);const n={handler:e,once:i,priority:s},a=this.events.get(t);return a.push(n),a.sort((o,c)=>c.priority-o.priority),()=>{const o=a.indexOf(n);o>-1&&a.splice(o,1)}}once(t,e,r={}){return this.on(t,e,{...r,once:!0})}off(t,e){if(t.includes("*")){for(const s of this.wildcardHandlers)if(s.pattern===t&&s.handler===e){this.wildcardHandlers.delete(s);return}return}if(!this.events.has(t))return;const r=this.events.get(t),i=r.findIndex(s=>s.handler===e);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(t)}offWildcard(t){for(const e of[...this.wildcardHandlers])e.pattern===t&&this.wildcardHandlers.delete(e)}offAll(t){for(const[e,r]of this.events){const i=r.findIndex(s=>s.handler===t);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(e)}for(const e of[...this.wildcardHandlers])e.handler===t&&this.wildcardHandlers.delete(e)}emit(t,e){if(this.events.has(t)){const i=[...this.events.get(t)];for(const s of i){const{handler:n,once:a}=s;a&&this.off(t,n);try{n(e,t)}catch(o){console.error(`Error in event handler for ${t}:`,o)}}}const r=[];for(const i of[...this.wildcardHandlers])if(this.matchesPattern(t,i.pattern)){const{handler:s,once:n}=i;n&&r.push(i);try{s(e,t)}catch(a){console.error(`Error in wildcard handler for ${t}:`,a)}}r.forEach(i=>this.wildcardHandlers.delete(i))}matchesPattern(t,e){return new RegExp("^"+e.replace(/\*/g,".*")+"$").test(t)}clear(){this.events.clear(),this.wildcardHandlers.clear()}getEventNames(){return Array.from(this.events.keys())}getHandlerCount(t){return this.events.has(t)?this.events.get(t).length:0}getWildcardHandlerCount(){return this.wildcardHandlers.size}getTotalHandlerCount(){let t=this.wildcardHandlers.size;for(const e of this.events.values())t+=e.length;return t}}const I=new M;class T{constructor(t={}){this.eventBus=new M,this.calendar=new f.Calendar({view:t.view||"month",date:t.date||new Date,weekStartsOn:t.weekStartsOn??0,locale:t.locale||"en-US",timeZone:t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone,...t}),this.state={view:this.calendar.getView(),currentDate:this.calendar.getCurrentDate(),events:[],selectedEvent:null,selectedDate:null,loading:!1,error:null,config:{...t}},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(t={}){const{force:e=!1}=t,r=this.calendar.getEvents()||[];return(e||this.state.events.length!==r.length||!this._eventsMatch(this.state.events,r))&&this.setState({events:[...r]},t),r}_eventsMatch(t,e){if(t.length!==e.length)return!1;const r=new Set(t.map(i=>i.id));return e.every(i=>r.has(i.id))}getState(){return{...this.state,config:{...this.state.config},events:[...this.state.events]}}setState(t,e={}){const{silent:r=!1}=e,i={...this.state};return this.state={...this.state,...t},r||(this.notifySubscribers(i,this.state),this.emitStateChange(i,this.state)),this.state}subscribe(t,e=null){return this.subscribers.add(t),e&&(this._subscriberIds||(this._subscriberIds=new Map),this._subscriberIds.set(e,t)),()=>this.unsubscribe(t,e)}unsubscribe(t,e=null){this.subscribers.delete(t),e&&this._subscriberIds&&this._subscriberIds.delete(e)}unsubscribeById(t){if(!this._subscriberIds)return!1;const e=this._subscriberIds.get(t);return e?(this.subscribers.delete(e),this._subscriberIds.delete(t),!0):!1}getSubscriberCount(){return this.subscribers.size}notifySubscribers(t,e){this.subscribers.forEach(r=>{try{r(e,t)}catch(i){console.error("Error in state subscriber:",i)}})}emitStateChange(t,e){const r=Object.keys(e).filter(i=>t[i]!==e[i]);r.forEach(i=>{this.eventBus.emit(`state:${i}:changed`,{oldValue:t[i],newValue:e[i],state:e})}),r.length>0&&this.eventBus.emit("state:changed",{oldState:t,newState:e,changedKeys:r})}setView(t){this.calendar.setView(t),this.setState({view:t}),this.eventBus.emit("view:changed",{view:t})}getView(){return this.state.view}setDate(t){this.calendar.goToDate(t),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("date:changed",{date:this.state.currentDate})}getCurrentDate(){return this.state.currentDate}next(){this.calendar.next(),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:next",{date:this.state.currentDate})}previous(){this.calendar.previous(),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:previous",{date:this.state.currentDate})}today(){this.calendar.today(),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:today",{date:this.state.currentDate})}goToDate(t){this.calendar.goToDate(t),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:goto",{date:this.state.currentDate})}addEvent(t){const e=this.calendar.addEvent(t);return e?(this._syncEventsFromCore(),this.eventBus.emit("event:add",{event:e}),this.eventBus.emit("event:added",{event:e}),e):(console.error("Failed to add event to calendar"),this.eventBus.emit("event:error",{action:"add",event:t,error:"Failed to add event"}),null)}updateEvent(t,e){this._syncEventsFromCore({silent:!0});const r=this.calendar.updateEvent(t,e);return r?(this._syncEventsFromCore({force:!0}),this.eventBus.emit("event:update",{event:r}),this.eventBus.emit("event:updated",{event:r}),r):(console.error(`Failed to update event: ${t}`),this.eventBus.emit("event:error",{action:"update",eventId:t,updates:e,error:"Event not found in calendar"}),null)}deleteEvent(t){return this._syncEventsFromCore({silent:!0}),this.calendar.removeEvent(t)?(this._syncEventsFromCore(),this.eventBus.emit("event:remove",{eventId:t}),this.eventBus.emit("event:deleted",{eventId:t}),!0):(console.error(`Failed to delete event: ${t}`),this.eventBus.emit("event:error",{action:"delete",eventId:t,error:"Event not found"}),!1)}getEvents(){return this.calendar.getEvents()||[]}syncEvents(){return this._syncEventsFromCore()}getEventsForDate(t){return this.calendar.getEventsForDate(t)}getEventsInRange(t,e){return this.calendar.getEventsInRange(t,e)}getViewData(){const t=this.calendar.getViewData();return this.enrichViewData(t)}enrichViewData(t){var i;const e={...t},r=(i=this.state.selectedDate)==null?void 0:i.toDateString();if(e.weeks&&(e.weeks=e.weeks.map(s=>({...s,days:s.days.map(n=>{const a=new Date(n.date);return{...n,isSelected:a.toDateString()===r,events:n.events||this.getEventsForDate(a)}})}))),e.days&&(e.days=e.days.map(s=>{const n=new Date(s.date);return{...s,isSelected:n.toDateString()===r,events:s.events||this.getEventsForDate(n)}})),e.date&&!e.days&&!e.weeks){const s=new Date(e.date);e.isSelected=s.toDateString()===r,e.events=e.events||this.getEventsForDate(s)}return e}selectEvent(t){this.setState({selectedEvent:t}),this.eventBus.emit("event:selected",{event:t})}selectEventById(t){const e=this.state.events.find(r=>r.id===t);e&&this.selectEvent(e)}deselectEvent(){this.setState({selectedEvent:null}),this.eventBus.emit("event:deselected",{})}selectDate(t){this.setState({selectedDate:t}),this.eventBus.emit("date:selected",{date:t})}deselectDate(){this.setState({selectedDate:null}),this.eventBus.emit("date:deselected",{})}isToday(t){const e=new Date;return t.toDateString()===e.toDateString()}isSelectedDate(t){return this.state.selectedDate&&t.toDateString()===this.state.selectedDate.toDateString()}isWeekend(t){const e=t.getDay();return e===0||e===6}setLoading(t){this.setState({loading:t})}setError(t){this.setState({error:t}),t&&this.eventBus.emit("error",{error:t})}clearError(){this.setState({error:null})}updateConfig(t){this.setState({config:{...this.state.config,...t}}),t.weekStartsOn!==void 0&&this.calendar.setWeekStartsOn(t.weekStartsOn),t.locale!==void 0&&this.calendar.setLocale(t.locale),t.timeZone!==void 0&&this.calendar.setTimezone(t.timeZone)}destroy(){this.subscribers.clear(),this._subscriberIds&&(this._subscriberIds.clear(),this._subscriberIds=null),this.eventBus&&(this.eventBus.clear(),this.eventBus=null),this.state=null,this.calendar=null}}class p extends f.DateUtils{static formatDate(t,e="default",r="en-US"){if(!t)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"}},s=i[e]||i.default;return new Intl.DateTimeFormat(r,s).format(t)}static formatTime(t,e=!0,r=!1,i="en-US"){if(!t)return"";const s={hour:"numeric",minute:e?"2-digit":void 0,hour12:!r};return new Intl.DateTimeFormat(i,s).format(t)}static formatDateRange(t,e,r="en-US"){if(!t)return"";if(!e||this.isSameDay(t,e))return this.formatDate(t,"default",r);const i=this.isSameYear(t,e)?"short":"default";return`${this.formatDate(t,i,r)} - ${this.formatDate(e,"default",r)}`}static formatTimeRange(t,e,r="en-US"){if(!t)return"";const i=this.formatTime(t,!0,!1,r);if(!e)return i;const s=this.formatTime(e,!0,!1,r);return`${i} - ${s}`}static getRelativeTime(t,e=new Date,r="en-US"){const i=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),s=t-e,n=Math.floor(s/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),m=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(m,"year")}static isToday(t){const e=new Date;return this.isSameDay(t,e)}static isPast(t){return t<new Date}static isFuture(t){return t>new Date}static getWeekNumber(t){const e=new Date(t.getFullYear(),0,1),r=(t-e)/864e5;return Math.ceil((r+e.getDay()+1)/7)}static getDayAbbreviation(t,e="en-US"){const r=new Date(2024,0,7+t);return new Intl.DateTimeFormat(e,{weekday:"short"}).format(r)}static getDayName(t,e="en-US"){const r=new Date(2024,0,7+t);return new Intl.DateTimeFormat(e,{weekday:"long"}).format(r)}static getMonthName(t,e="long",r="en-US"){const i=new Date(2024,t,1);return new Intl.DateTimeFormat(r,{month:e}).format(i)}static parseTimeString(t,e=new Date){const r=new Date(e),[i,s]=t.split(/\s+/),[n,a]=i.split(":").map(Number);let o=n;return s&&(s.toLowerCase()==="pm"&&n<12?o=n+12:s.toLowerCase()==="am"&&n===12&&(o=0)),r.setHours(o,a||0,0,0),r}}class b{static createElement(t,e={},r=[]){const i=document.createElement(t);return Object.entries(e).forEach(([s,n])=>{if(s==="className")i.className=n;else if(s==="style"&&typeof n=="object")Object.assign(i.style,n);else if(s.startsWith("data-"))i.setAttribute(s,n);else if(s.startsWith("on")&&typeof n=="function"){const a=s.slice(2).toLowerCase();i.addEventListener(a,n)}else i[s]=n}),r.forEach(s=>{typeof s=="string"?i.appendChild(document.createTextNode(s)):s instanceof Node&&i.appendChild(s)}),i}static addEventListeners(t,e){return Object.entries(e).forEach(([r,i])=>{t.addEventListener(r,i)}),()=>{Object.entries(e).forEach(([r,i])=>{t.removeEventListener(r,i)})}}static delegate(t,e,r,i){const s=n=>{const a=n.target.closest(e);a&&t.contains(a)&&i.call(a,n)};return t.addEventListener(r,s),()=>t.removeEventListener(r,s)}static getPosition(t){const e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX,bottom:e.bottom+window.scrollY,right:e.right+window.scrollX,width:e.width,height:e.height}}static isInViewport(t,e=0){const r=t.getBoundingClientRect();return r.top>=-e&&r.left>=-e&&r.bottom<=(window.innerHeight||document.documentElement.clientHeight)+e&&r.right<=(window.innerWidth||document.documentElement.clientWidth)+e}static scrollToElement(t,e={}){const{behavior:r="smooth",block:i="start",inline:s="nearest"}=e;t.scrollIntoView({behavior:r,block:i,inline:s})}static getStyle(t,e){return window.getComputedStyle(t).getPropertyValue(e)}static setStyles(t,e){Object.assign(t.style,e)}static async animateClass(t,e,r=300){t.classList.add(e),await this.wait(r),t.classList.remove(e)}static waitForAnimation(t,e="animationend"){return new Promise(r=>{const i=()=>{t.removeEventListener(e,i),r()};t.addEventListener(e,i)})}static wait(t){return new Promise(e=>setTimeout(e,t))}static parseHTML(t){const e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}static escapeHTML(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}static debounce(t,e=250){let r;return function(...s){clearTimeout(r),r=setTimeout(()=>t.apply(this,s),e)}}static throttle(t,e=250){let r;return function(...i){r||(t.apply(this,i),r=!0,setTimeout(()=>r=!1,e))}}static closest(t,e){return t.closest(e)}static parents(t,e){const r=[];let i=t.parentElement;for(;i;)i.matches(e)&&r.push(i),i=i.parentElement;return r}static getOuterDimensions(t){const e=window.getComputedStyle(t),r={top:parseInt(e.marginTop),right:parseInt(e.marginRight),bottom:parseInt(e.marginBottom),left:parseInt(e.marginLeft)};return{width:t.offsetWidth+r.left+r.right,height:t.offsetHeight+r.top+r.bottom,margin:r}}static cloneWithEvents(t,e=!0){return t.cloneNode(e)}static trapFocus(t){const e=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(e.length===0)return t.setAttribute("tabindex","-1"),t.focus(),()=>t.removeAttribute("tabindex");const r=e[0],i=e[e.length-1],s=n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===r&&(i==null||i.focus(),n.preventDefault()):document.activeElement===i&&(r==null||r.focus(),n.preventDefault()))};return t.addEventListener("keydown",s),r==null||r.focus(),()=>t.removeEventListener("keydown",s)}}class u{static getCSSVariable(t,e=document.documentElement){return getComputedStyle(e).getPropertyValue(t).trim()}static setCSSVariables(t,e=document.documentElement){Object.entries(t).forEach(([r,i])=>{e.style.setProperty(r,i)})}static getBaseStyles(){return`
11
+ `+this.getStyles();const e=this._saveScrollPositions(),r=this._getActiveElementSelector();this._contentWrapper.innerHTML=t,this._restoreScrollPositions(e),this._restoreFocus(r),this.afterRender()}_saveScrollPositions(){const t=new Map;return this._contentWrapper&&this._contentWrapper.querySelectorAll("[id]").forEach(r=>{(r.scrollTop!==0||r.scrollLeft!==0)&&t.set(r.id,{top:r.scrollTop,left:r.scrollLeft})}),t}_restoreScrollPositions(t){!this._contentWrapper||t.size===0||t.forEach((e,r)=>{const i=this._contentWrapper.querySelector(`[id="${CSS.escape(r)}"]`);i&&(i.scrollTop=e.top,i.scrollLeft=e.left)})}_getActiveElementSelector(){const t=this.shadowRoot.activeElement;return!t||t===this._contentWrapper?null:t.id?`[id="${CSS.escape(t.id)}"]`:t.dataset&&t.dataset.action?`[data-action="${CSS.escape(t.dataset.action)}"]`:t.dataset&&t.dataset.view?`[data-view="${CSS.escape(t.dataset.view)}"]`:t.tagName?t.tagName.toLowerCase():null}_restoreFocus(t){if(!(!t||!this._contentWrapper))try{const e=this._contentWrapper.querySelector(t);e&&typeof e.focus=="function"&&e.focus()}catch{}}template(){return""}afterRender(){}$(t){return this.shadowRoot.querySelector(t)}$$(t){return this.shadowRoot.querySelectorAll(t)}static get observedAttributes(){return[]}attributeChangedCallback(t,e,r){this.setProp(t,r),this._initialized&&this.render()}}class ${constructor(){this.events=new Map,this.wildcardHandlers=new Set}on(t,e,r={}){const{once:i=!1,priority:s=0}=r;if(t.includes("*")){const o={pattern:t,handler:e,once:i,priority:s};return this.wildcardHandlers.add(o),()=>this.wildcardHandlers.delete(o)}this.events.has(t)||this.events.set(t,[]);const n={handler:e,once:i,priority:s},a=this.events.get(t);return a.push(n),a.sort((o,c)=>c.priority-o.priority),()=>{const o=a.indexOf(n);o>-1&&a.splice(o,1)}}once(t,e,r={}){return this.on(t,e,{...r,once:!0})}off(t,e){if(t.includes("*")){for(const s of this.wildcardHandlers)if(s.pattern===t&&s.handler===e){this.wildcardHandlers.delete(s);return}return}if(!this.events.has(t))return;const r=this.events.get(t),i=r.findIndex(s=>s.handler===e);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(t)}offWildcard(t){for(const e of[...this.wildcardHandlers])e.pattern===t&&this.wildcardHandlers.delete(e)}offAll(t){for(const[e,r]of this.events){const i=r.findIndex(s=>s.handler===t);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(e)}for(const e of[...this.wildcardHandlers])e.handler===t&&this.wildcardHandlers.delete(e)}emit(t,e){if(this.events.has(t)){const i=[...this.events.get(t)];for(const s of i){const{handler:n,once:a}=s;a&&this.off(t,n);try{n(e,t)}catch(o){console.error(`Error in event handler for ${t}:`,o)}}}const r=[];for(const i of[...this.wildcardHandlers])if(this.matchesPattern(t,i.pattern)){const{handler:s,once:n}=i;n&&r.push(i);try{s(e,t)}catch(a){console.error(`Error in wildcard handler for ${t}:`,a)}}r.forEach(i=>this.wildcardHandlers.delete(i))}matchesPattern(t,e){const r=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+r.replace(/\*/g,".*")+"$").test(t)}clear(){this.events.clear(),this.wildcardHandlers.clear()}getEventNames(){return Array.from(this.events.keys())}getHandlerCount(t){return this.events.has(t)?this.events.get(t).length:0}getWildcardHandlerCount(){return this.wildcardHandlers.size}getTotalHandlerCount(){let t=this.wildcardHandlers.size;for(const e of this.events.values())t+=e.length;return t}}const I=new $;class T{constructor(t={}){this.eventBus=new $,this.calendar=new f.Calendar({view:t.view||"month",date:t.date||new Date,weekStartsOn:t.weekStartsOn??0,locale:t.locale||"en-US",timeZone:t.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone,...t}),this.state={view:this.calendar.getView(),currentDate:this.calendar.getCurrentDate(),events:[],selectedEvent:null,selectedDate:null,loading:!1,error:null,config:{...t}},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(t={}){const{force:e=!1}=t,r=this.calendar.getEvents()||[];return(e||this.state.events.length!==r.length||!this._eventsMatch(this.state.events,r))&&this.setState({events:[...r]},t),r}_eventsMatch(t,e){if(t.length!==e.length)return!1;const r=new Set(t.map(i=>i.id));return e.every(i=>r.has(i.id))}getState(){return{...this.state,config:{...this.state.config},events:[...this.state.events]}}setState(t,e={}){const{silent:r=!1}=e,i={...this.state};return this.state={...this.state,...t},r||(this.notifySubscribers(i,this.state),this.emitStateChange(i,this.state)),this.state}subscribe(t,e=null){return this.subscribers.add(t),e&&(this._subscriberIds||(this._subscriberIds=new Map),this._subscriberIds.set(e,t)),()=>this.unsubscribe(t,e)}unsubscribe(t,e=null){this.subscribers.delete(t),e&&this._subscriberIds&&this._subscriberIds.delete(e)}unsubscribeById(t){if(!this._subscriberIds)return!1;const e=this._subscriberIds.get(t);return e?(this.subscribers.delete(e),this._subscriberIds.delete(t),!0):!1}getSubscriberCount(){return this.subscribers.size}notifySubscribers(t,e){this.subscribers.forEach(r=>{try{r(e,t)}catch(i){console.error("Error in state subscriber:",i)}})}emitStateChange(t,e){const r=Object.keys(e).filter(i=>t[i]!==e[i]);r.forEach(i=>{this.eventBus.emit(`state:${i}:changed`,{oldValue:t[i],newValue:e[i],state:e})}),r.length>0&&this.eventBus.emit("state:changed",{oldState:t,newState:e,changedKeys:r})}setView(t){this.calendar.setView(t),this.setState({view:t}),this.eventBus.emit("view:changed",{view:t})}getView(){return this.state.view}setDate(t){this.calendar.goToDate(t),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("date:changed",{date:this.state.currentDate})}getCurrentDate(){return this.state.currentDate}next(){this.calendar.next(),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:next",{date:this.state.currentDate})}previous(){this.calendar.previous(),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:previous",{date:this.state.currentDate})}today(){this.calendar.today(),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:today",{date:this.state.currentDate})}goToDate(t){this.calendar.goToDate(t),this.setState({currentDate:this.calendar.getCurrentDate()}),this.eventBus.emit("navigation:goto",{date:this.state.currentDate})}addEvent(t){const e=this.calendar.addEvent(t);return e?(this._syncEventsFromCore(),this.eventBus.emit("event:add",{event:e}),this.eventBus.emit("event:added",{event:e}),e):(console.error("Failed to add event to calendar"),this.eventBus.emit("event:error",{action:"add",event:t,error:"Failed to add event"}),null)}updateEvent(t,e){this._syncEventsFromCore({silent:!0});const r=this.calendar.updateEvent(t,e);return r?(this._syncEventsFromCore({force:!0}),this.eventBus.emit("event:update",{event:r}),this.eventBus.emit("event:updated",{event:r}),r):(console.error(`Failed to update event: ${t}`),this.eventBus.emit("event:error",{action:"update",eventId:t,updates:e,error:"Event not found in calendar"}),null)}deleteEvent(t){return this._syncEventsFromCore({silent:!0}),this.calendar.removeEvent(t)?(this._syncEventsFromCore(),this.eventBus.emit("event:remove",{eventId:t}),this.eventBus.emit("event:deleted",{eventId:t}),!0):(console.error(`Failed to delete event: ${t}`),this.eventBus.emit("event:error",{action:"delete",eventId:t,error:"Event not found"}),!1)}getEvents(){return this.calendar.getEvents()||[]}syncEvents(){return this._syncEventsFromCore()}getEventsForDate(t){return this.calendar.getEventsForDate(t)}getEventsInRange(t,e){return this.calendar.getEventsInRange(t,e)}getViewData(){const t=this.calendar.getViewData();return this.enrichViewData(t)}enrichViewData(t){var i;const e={...t},r=(i=this.state.selectedDate)==null?void 0:i.toDateString();if(e.weeks&&(e.weeks=e.weeks.map(s=>({...s,days:s.days.map(n=>{const a=new Date(n.date);return{...n,isSelected:a.toDateString()===r,events:n.events||this.getEventsForDate(a)}})}))),e.days&&(e.days=e.days.map(s=>{const n=new Date(s.date);return{...s,isSelected:n.toDateString()===r,events:s.events||this.getEventsForDate(n)}})),e.date&&!e.days&&!e.weeks){const s=new Date(e.date);e.isSelected=s.toDateString()===r,e.events=e.events||this.getEventsForDate(s)}return e}selectEvent(t){this.setState({selectedEvent:t}),this.eventBus.emit("event:selected",{event:t})}selectEventById(t){const e=this.state.events.find(r=>r.id===t);e&&this.selectEvent(e)}deselectEvent(){this.setState({selectedEvent:null}),this.eventBus.emit("event:deselected",{})}selectDate(t){this.setState({selectedDate:t}),this.eventBus.emit("date:selected",{date:t})}deselectDate(){this.setState({selectedDate:null}),this.eventBus.emit("date:deselected",{})}isToday(t){const e=new Date;return t.toDateString()===e.toDateString()}isSelectedDate(t){return this.state.selectedDate&&t.toDateString()===this.state.selectedDate.toDateString()}isWeekend(t){const e=t.getDay();return e===0||e===6}setLoading(t){this.setState({loading:t})}setError(t){this.setState({error:t}),t&&this.eventBus.emit("error",{error:t})}clearError(){this.setState({error:null})}updateConfig(t){this.setState({config:{...this.state.config,...t}}),t.weekStartsOn!==void 0&&this.calendar.setWeekStartsOn(t.weekStartsOn),t.locale!==void 0&&this.calendar.setLocale(t.locale),t.timeZone!==void 0&&this.calendar.setTimezone(t.timeZone)}destroy(){this.subscribers.clear(),this._subscriberIds&&(this._subscriberIds.clear(),this._subscriberIds=null),this.eventBus&&(this.eventBus.clear(),this.eventBus=null),this.state=null,this.calendar=null}}class p extends f.DateUtils{static formatDate(t,e="default",r="en-US"){if(!t)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"}},s=i[e]||i.default;return new Intl.DateTimeFormat(r,s).format(t)}static formatTime(t,e=!0,r=!1,i="en-US"){if(!t)return"";const s={hour:"numeric",minute:e?"2-digit":void 0,hour12:!r};return new Intl.DateTimeFormat(i,s).format(t)}static formatDateRange(t,e,r="en-US"){if(!t)return"";if(!e||this.isSameDay(t,e))return this.formatDate(t,"default",r);const i=this.isSameYear(t,e)?"short":"default";return`${this.formatDate(t,i,r)} - ${this.formatDate(e,"default",r)}`}static formatTimeRange(t,e,r="en-US"){if(!t)return"";const i=this.formatTime(t,!0,!1,r);if(!e)return i;const s=this.formatTime(e,!0,!1,r);return`${i} - ${s}`}static getRelativeTime(t,e=new Date,r="en-US"){const i=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),s=t-e,n=Math.floor(s/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),m=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(m,"year")}static isToday(t){const e=new Date;return this.isSameDay(t,e)}static isPast(t){return t<new Date}static isFuture(t){return t>new Date}static getWeekNumber(t){const e=new Date(t.getFullYear(),0,1),r=(t-e)/864e5;return Math.ceil((r+e.getDay()+1)/7)}static getDayAbbreviation(t,e="en-US"){const r=new Date(2024,0,7+t);return new Intl.DateTimeFormat(e,{weekday:"short"}).format(r)}static getDayName(t,e="en-US"){const r=new Date(2024,0,7+t);return new Intl.DateTimeFormat(e,{weekday:"long"}).format(r)}static getMonthName(t,e="long",r="en-US"){const i=new Date(2024,t,1);return new Intl.DateTimeFormat(r,{month:e}).format(i)}static parseTimeString(t,e=new Date){const r=new Date(e),[i,s]=t.split(/\s+/),[n,a]=i.split(":").map(Number);let o=n;return s&&(s.toLowerCase()==="pm"&&n<12?o=n+12:s.toLowerCase()==="am"&&n===12&&(o=0)),r.setHours(o,a||0,0,0),r}}class b{static createElement(t,e={},r=[]){const i=document.createElement(t);return Object.entries(e).forEach(([s,n])=>{if(s==="className")i.className=n;else if(s==="style"&&typeof n=="object")Object.assign(i.style,n);else if(s.startsWith("data-"))i.setAttribute(s,n);else if(s.startsWith("on")&&typeof n=="function"){const a=s.slice(2).toLowerCase();i.addEventListener(a,n)}else i[s]=n}),r.forEach(s=>{typeof s=="string"?i.appendChild(document.createTextNode(s)):s instanceof Node&&i.appendChild(s)}),i}static addEventListeners(t,e){return Object.entries(e).forEach(([r,i])=>{t.addEventListener(r,i)}),()=>{Object.entries(e).forEach(([r,i])=>{t.removeEventListener(r,i)})}}static delegate(t,e,r,i){const s=n=>{const a=n.target.closest(e);a&&t.contains(a)&&i.call(a,n)};return t.addEventListener(r,s),()=>t.removeEventListener(r,s)}static getPosition(t){const e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX,bottom:e.bottom+window.scrollY,right:e.right+window.scrollX,width:e.width,height:e.height}}static isInViewport(t,e=0){const r=t.getBoundingClientRect();return r.top>=-e&&r.left>=-e&&r.bottom<=(window.innerHeight||document.documentElement.clientHeight)+e&&r.right<=(window.innerWidth||document.documentElement.clientWidth)+e}static scrollToElement(t,e={}){const{behavior:r="smooth",block:i="start",inline:s="nearest"}=e;t.scrollIntoView({behavior:r,block:i,inline:s})}static getStyle(t,e){return window.getComputedStyle(t).getPropertyValue(e)}static setStyles(t,e){Object.assign(t.style,e)}static async animateClass(t,e,r=300){t.classList.add(e),await this.wait(r),t.classList.remove(e)}static waitForAnimation(t,e="animationend"){return new Promise(r=>{const i=()=>{t.removeEventListener(e,i),r()};t.addEventListener(e,i)})}static wait(t){return new Promise(e=>setTimeout(e,t))}static parseHTML(t){const e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}static escapeHTML(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}static debounce(t,e=250){let r;return function(...s){clearTimeout(r),r=setTimeout(()=>t.apply(this,s),e)}}static throttle(t,e=250){let r;return function(...i){r||(t.apply(this,i),r=!0,setTimeout(()=>r=!1,e))}}static closest(t,e){return t.closest(e)}static parents(t,e){const r=[];let i=t.parentElement;for(;i;)i.matches(e)&&r.push(i),i=i.parentElement;return r}static getOuterDimensions(t){const e=window.getComputedStyle(t),r={top:parseInt(e.marginTop),right:parseInt(e.marginRight),bottom:parseInt(e.marginBottom),left:parseInt(e.marginLeft)};return{width:t.offsetWidth+r.left+r.right,height:t.offsetHeight+r.top+r.bottom,margin:r}}static cloneWithEvents(t,e=!0){return t.cloneNode(e)}static trapFocus(t){const e=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(e.length===0)return t.setAttribute("tabindex","-1"),t.focus(),()=>t.removeAttribute("tabindex");const r=e[0],i=e[e.length-1],s=n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===r&&(i==null||i.focus(),n.preventDefault()):document.activeElement===i&&(r==null||r.focus(),n.preventDefault()))};return t.addEventListener("keydown",s),r==null||r.focus(),()=>t.removeEventListener("keydown",s)}}class u{static getCSSVariable(t,e=document.documentElement){return getComputedStyle(e).getPropertyValue(t).trim()}static setCSSVariables(t,e=document.documentElement){Object.entries(t).forEach(([r,i])=>{e.style.setProperty(r,i)})}static getBaseStyles(){return`
12
12
  :host {
13
13
  /* Apply CSS variables */
14
14
  ${Object.entries(this.cssVariables).map(([t,e])=>`${t}: ${e};`).join(`
@@ -231,10 +231,10 @@
231
231
  .fc-scale-in {
232
232
  animation: fc-scale-in var(--fc-transition);
233
233
  }
234
- `}}x(u,"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"}}),x(u,"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"}),x(u,"breakpoints",{xs:"320px",sm:"576px",md:"768px",lg:"992px",xl:"1200px","2xl":"1400px"});class _{constructor(t,e){this.container=t,this.stateManager=e,this._listeners=[],this._scrolled=!1,this._nowIndicatorTimer=null}render(){throw new Error("render() must be implemented by subclass")}cleanup(){this._listeners.forEach(({element:t,event:e,handler:r})=>{t.removeEventListener(e,r)}),this._listeners=[],this._nowIndicatorTimer&&(clearInterval(this._nowIndicatorTimer),this._nowIndicatorTimer=null)}addListener(t,e,r){const i=r.bind(this);t.addEventListener(e,i),this._listeners.push({element:t,event:e,handler:i})}escapeHTML(t){return t==null?"":b.escapeHTML(String(t))}isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}isSameDay(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}formatHour(t){const e=t>=12?"PM":"AM";return`${t%12||12} ${e}`}formatTime(t){const e=t.getHours(),r=t.getMinutes(),i=e>=12?"PM":"AM",s=e%12||12;return r===0?`${s} ${i}`:`${s}:${r.toString().padStart(2,"0")} ${i}`}getContrastingTextColor(t){return!t||typeof t!="string"||t.charAt(0)!=="#"?"white":u.getContrastColor(t)}renderNowIndicator(){const t=new Date;return`<div class="fc-now-indicator" style="position: absolute; left: 0; right: 0; top: ${t.getHours()*60+t.getMinutes()}px; height: 2px; background: var(--fc-danger-color); z-index: 15; pointer-events: none;"></div>`}startNowIndicatorTimer(){this._nowIndicatorTimer&&clearInterval(this._nowIndicatorTimer),this._nowIndicatorTimer=setInterval(()=>{const t=this.container.querySelector(".fc-now-indicator");if(t){const e=new Date;t.style.top=`${e.getHours()*60+e.getMinutes()}px`}},6e4)}computeOverlapLayout(t){if(!t||t.length===0)return new Map;const e=t.map(o=>{const c=new Date(o.start),l=new Date(o.end),h=c.getHours()*60+c.getMinutes(),m=Math.max(h+1,l.getHours()*60+l.getMinutes());return{id:o.id,startMin:h,endMin:m}});e.sort((o,c)=>o.startMin-c.startMin||c.endMin-c.startMin-(o.endMin-o.startMin));const r=[],i=new Map;for(const o of e){let c=!1;for(let l=0;l<r.length;l++)if(r[l]<=o.startMin){r[l]=o.endMin,i.set(o.id,{column:l,totalColumns:0}),c=!0;break}c||(i.set(o.id,{column:r.length,totalColumns:0}),r.push(o.endMin))}const s=[];let n=[],a=0;for(const o of e)n.length===0||o.startMin<a?(n.push(o),a=Math.max(a,o.endMin)):(s.push(n),n=[o],a=o.endMin);n.length>0&&s.push(n);for(const o of s){const c=Math.max(...o.map(l=>i.get(l.id).column))+1;for(const l of o)i.get(l.id).totalColumns=c}return i}renderTimedEvent(t,e={}){const{compact:r=!0,overlapLayout:i=null}=e,s=new Date(t.start),n=new Date(t.end),a=s.getHours()*60+s.getMinutes(),o=Math.max((n-s)/(1e3*60),r?20:30),c=this.getEventColor(t),l=this.getContrastingTextColor(c),h=r?"4px 8px":"8px 12px",m=r?"11px":"13px",w=r?2:12,E=r?2:24,z=r?"4px":"6px";let $,S;if(i&&i.has(t.id)){const{column:B,totalColumns:F}=i.get(t.id),L=`(100% - ${w+E}px)`;$=`calc(${w}px + ${B} * ${L} / ${F})`,S=`calc(${L} / ${F})`}else $=`${w}px`,S=`calc(100% - ${w+E}px)`;return`
234
+ `}}w(u,"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"}}),w(u,"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"}),w(u,"breakpoints",{xs:"320px",sm:"576px",md:"768px",lg:"992px",xl:"1200px","2xl":"1400px"});class _{constructor(t,e){this.container=t,this.stateManager=e,this._listeners=[],this._scrolled=!1,this._nowIndicatorTimer=null}render(){throw new Error("render() must be implemented by subclass")}cleanup(){this._listeners.forEach(({element:t,event:e,handler:r})=>{t.removeEventListener(e,r)}),this._listeners=[],this._nowIndicatorTimer&&(clearInterval(this._nowIndicatorTimer),this._nowIndicatorTimer=null)}addListener(t,e,r){const i=r.bind(this);t.addEventListener(e,i),this._listeners.push({element:t,event:e,handler:i})}escapeHTML(t){return t==null?"":b.escapeHTML(String(t))}isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}isSameDay(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}formatHour(t){const e=t>=12?"PM":"AM";return`${t%12||12} ${e}`}formatTime(t){const e=t.getHours(),r=t.getMinutes(),i=e>=12?"PM":"AM",s=e%12||12;return r===0?`${s} ${i}`:`${s}:${r.toString().padStart(2,"0")} ${i}`}getContrastingTextColor(t){return!t||typeof t!="string"||t.charAt(0)!=="#"?"white":u.getContrastColor(t)}renderNowIndicator(){const t=new Date;return`<div class="fc-now-indicator" style="position: absolute; left: 0; right: 0; top: ${t.getHours()*60+t.getMinutes()}px; height: 2px; background: var(--fc-danger-color); z-index: 15; pointer-events: none;"></div>`}startNowIndicatorTimer(){this._nowIndicatorTimer&&clearInterval(this._nowIndicatorTimer),this._nowIndicatorTimer=setInterval(()=>{const t=this.container.querySelector(".fc-now-indicator");if(t){const e=new Date;t.style.top=`${e.getHours()*60+e.getMinutes()}px`}},6e4)}computeOverlapLayout(t){if(!t||t.length===0)return new Map;const e=t.map(o=>{const c=new Date(o.start),l=new Date(o.end),h=c.getHours()*60+c.getMinutes(),m=Math.max(h+1,l.getHours()*60+l.getMinutes());return{id:o.id,startMin:h,endMin:m}});e.sort((o,c)=>o.startMin-c.startMin||c.endMin-c.startMin-(o.endMin-o.startMin));const r=[],i=new Map;for(const o of e){let c=!1;for(let l=0;l<r.length;l++)if(r[l]<=o.startMin){r[l]=o.endMin,i.set(o.id,{column:l,totalColumns:0}),c=!0;break}c||(i.set(o.id,{column:r.length,totalColumns:0}),r.push(o.endMin))}const s=[];let n=[],a=0;for(const o of e)n.length===0||o.startMin<a?(n.push(o),a=Math.max(a,o.endMin)):(s.push(n),n=[o],a=o.endMin);n.length>0&&s.push(n);for(const o of s){const c=Math.max(...o.map(l=>i.get(l.id).column))+1;for(const l of o)i.get(l.id).totalColumns=c}return i}renderTimedEvent(t,e={}){const{compact:r=!0,overlapLayout:i=null}=e,s=new Date(t.start),n=new Date(t.end),a=s.getHours()*60+s.getMinutes(),o=Math.max((n-s)/(1e3*60),r?20:30),c=this.getEventColor(t),l=this.getContrastingTextColor(c),h=r?"4px 8px":"8px 12px",m=r?"11px":"13px",x=r?2:12,E=r?2:24,z=r?"4px":"6px";let M,S;if(i&&i.has(t.id)){const{column:B,totalColumns:F}=i.get(t.id),L=`(100% - ${x+E}px)`;M=`calc(${x}px + ${B} * ${L} / ${F})`,S=`calc(${L} / ${F})`}else M=`${x}px`,S=`calc(100% - ${x+E}px)`;return`
235
235
  <div class="fc-event fc-timed-event" data-event-id="${this.escapeHTML(t.id)}"
236
236
  style="position: absolute; top: ${a}px; height: ${o}px;
237
- left: ${$}; width: ${S};
237
+ left: ${M}; width: ${S};
238
238
  background-color: ${c}; border-radius: ${z};
239
239
  padding: ${h}; font-size: ${m};
240
240
  font-weight: 500; color: ${l}; overflow: hidden;
@@ -264,9 +264,9 @@
264
264
  ${c>0?`<div class="fc-more-events" style="font-size: 10px; color: var(--fc-text-light); padding: 2px 4px; font-weight: 500;">+${c} more</div>`:""}
265
265
  </div>
266
266
  </div>
267
- `}_renderEvent(t){const e=this.getEventColor(t);return`
267
+ `}_renderEvent(t){const e=this.getEventColor(t),r=this.getContrastingTextColor(e);return`
268
268
  <div class="fc-event" data-event-id="${this.escapeHTML(t.id)}"
269
- style="background-color: ${e}; font-size: 11px; padding: 2px 6px; border-radius: 3px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;">
269
+ style="background-color: ${e}; font-size: 11px; padding: 2px 6px; border-radius: 3px; color: ${r}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;">
270
270
  ${this.escapeHTML(t.title)}
271
271
  </div>
272
272
  `}_attachEventHandlers(){this.addListener(this.container,"click",t=>{const e=t.target.closest(".fc-month-day");if(!e||!this.container.contains(e)||t.target.closest(".fc-event"))return;const r=new Date(e.dataset.date);this.stateManager.selectDate(r)}),this.attachCommonEventHandlers()}}class C extends _{constructor(t,e){super(t,e),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const t=this.stateManager.getViewData();if(!t||!t.days||t.days.length===0){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for week view.</div>';return}this.cleanup(),this._scrolled=!1;const e=this.stateManager.getState().config,r=this._renderWeekView(t,e);this.container.innerHTML=r,this._attachEventHandlers(),this._scrollToCurrentTime(),this.startNowIndicatorTimer()}_renderWeekView(t,e){const r=t.days,i=this.stateManager.getState().config.locale||"en-US",s=Array.from({length:24},(a,o)=>o),n=r.map(a=>{const o=new Date(a.date),c=a.events||[];return{...a,date:o,dayName:p.getDayAbbreviation(o.getDay(),i),dayOfMonth:o.getDate(),isToday:this.isToday(o),timedEvents:c.filter(l=>!l.allDay),allDayEvents:c.filter(l=>l.allDay)}});return`
@@ -331,7 +331,7 @@
331
331
  <!-- Timed events -->
332
332
  ${(()=>{const r=this.computeOverlapLayout(t.timedEvents);return t.timedEvents.map(i=>this.renderTimedEvent(i,{compact:!0,overlapLayout:r})).join("")})()}
333
333
  </div>
334
- `}_attachEventHandlers(){this.addListener(this.container,"click",t=>{const e=t.target.closest(".fc-week-day-column");if(!e||!this.container.contains(e)||t.target.closest(".fc-event"))return;const r=new Date(e.dataset.date),i=this.container.querySelector("#week-scroll-container"),s=e.offsetTop,n=t.clientY-e.getBoundingClientRect().top+(i?i.scrollTop:0)-s,a=Math.max(0,Math.min(n+s,this.totalHeight));r.setHours(Math.floor(a/this.hourHeight),Math.floor(a%this.hourHeight/(this.hourHeight/60)),0,0),this.stateManager.selectDate(r)}),this.attachCommonEventHandlers()}_scrollToCurrentTime(){if(this._scrolled)return;const t=this.container.querySelector("#week-scroll-container");t&&(t.scrollTop=8*this.hourHeight-50,this._scrolled=!0)}}class H extends _{constructor(t,e){super(t,e),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const t=this.stateManager.getViewData();if(!t){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for day view.</div>';return}this.cleanup(),this._scrolled=!1;const e=this.stateManager.getState().config,r=this._renderDayView(t,e);this.container.innerHTML=r,this._attachEventHandlers(),this._scrollToCurrentTime(),this.startNowIndicatorTimer()}_renderDayView(t,e){var h,m;const r=((m=(h=this.stateManager)==null?void 0:h.getState())==null?void 0:m.currentDate)||new Date,i=this._extractDayData(t,r);if(!i)return'<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for day view.</div>';const{dayDate:s,dayName:n,isToday:a,allDayEvents:o,timedEvents:c}=i,l=Array.from({length:24},(w,E)=>E);return`
334
+ `}_attachEventHandlers(){this.addListener(this.container,"click",t=>{const e=t.target.closest(".fc-week-day-column");if(!e||!this.container.contains(e)||t.target.closest(".fc-event"))return;const r=new Date(e.dataset.date),i=this.container.querySelector("#week-scroll-container"),s=e.offsetTop,n=t.clientY-e.getBoundingClientRect().top+(i?i.scrollTop:0)-s,a=Math.max(0,Math.min(n+s,this.totalHeight));r.setHours(Math.floor(a/this.hourHeight),Math.floor(a%this.hourHeight/(this.hourHeight/60)),0,0),this.stateManager.selectDate(r)}),this.attachCommonEventHandlers()}_scrollToCurrentTime(){if(this._scrolled)return;const t=this.container.querySelector("#week-scroll-container");t&&(t.scrollTop=8*this.hourHeight-50,this._scrolled=!0)}}class H extends _{constructor(t,e){super(t,e),this.hourHeight=60,this.totalHeight=24*this.hourHeight}render(){if(!this.container||!this.stateManager)return;const t=this.stateManager.getViewData();if(!t){this.container.innerHTML='<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for day view.</div>';return}this.cleanup(),this._scrolled=!1;const e=this.stateManager.getState().config,r=this._renderDayView(t,e);this.container.innerHTML=r,this._attachEventHandlers(),this._scrollToCurrentTime(),this.startNowIndicatorTimer()}_renderDayView(t,e){var h,m;const r=((m=(h=this.stateManager)==null?void 0:h.getState())==null?void 0:m.currentDate)||new Date,i=this._extractDayData(t,r);if(!i)return'<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for day view.</div>';const{dayDate:s,dayName:n,isToday:a,allDayEvents:o,timedEvents:c}=i,l=Array.from({length:24},(x,E)=>E);return`
335
335
  <div class="fc-day-view" style="display: flex; flex-direction: column; height: 100%; background: var(--fc-background); overflow: hidden;">
336
336
  ${this._renderHeader(s,n,a)}
337
337
  ${this._renderAllDayRow(o,s)}
@@ -1060,5 +1060,5 @@
1060
1060
  <svg class="fc-icon" viewBox="0 0 24 24">
1061
1061
  <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"/>
1062
1062
  </svg>
1063
- `}[t]||""}addEvent(t){return this.stateManager.addEvent(t)}updateEvent(t,e){return this.stateManager.updateEvent(t,e)}deleteEvent(t){return this.stateManager.deleteEvent(t)}getEvents(){return this.stateManager.getEvents()}setView(t){this.stateManager.setView(t)}setDate(t){this.stateManager.setDate(t)}next(){this.stateManager.next()}previous(){this.stateManager.previous()}today(){this.stateManager.today()}unmount(){this.destroy()}destroy(){this._busUnsubscribers.forEach(t=>t()),this._busUnsubscribers=[],this._stateUnsubscribe&&(this._stateUnsubscribe(),this._stateUnsubscribe=null),this._currentViewInstance&&this._currentViewInstance.cleanup&&(this._currentViewInstance.cleanup(),this._currentViewInstance=null),this.stateManager&&this.stateManager.destroy(),super.cleanup()}};x(y,"RENDERERS",{month:D,week:C,day:H});let k=y;customElements.get("forcecal-main")||customElements.define("forcecal-main",k),d.BaseComponent=v,d.BaseViewRenderer=_,d.DOMUtils=b,d.DateUtils=p,d.DayViewRenderer=H,d.EventBus=M,d.ForceCalendar=k,d.MonthViewRenderer=D,d.StateManager=T,d.StyleUtils=u,d.WeekViewRenderer=C,d.eventBus=I,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1063
+ `}[t]||""}addEvent(t){return this.stateManager.addEvent(t)}updateEvent(t,e){return this.stateManager.updateEvent(t,e)}deleteEvent(t){return this.stateManager.deleteEvent(t)}getEvents(){return this.stateManager.getEvents()}setView(t){this.stateManager.setView(t)}setDate(t){this.stateManager.setDate(t)}next(){this.stateManager.next()}previous(){this.stateManager.previous()}today(){this.stateManager.today()}unmount(){this.destroy()}destroy(){this._busUnsubscribers.forEach(t=>t()),this._busUnsubscribers=[],this._stateUnsubscribe&&(this._stateUnsubscribe(),this._stateUnsubscribe=null),this._currentViewInstance&&this._currentViewInstance.cleanup&&(this._currentViewInstance.cleanup(),this._currentViewInstance=null),this.stateManager&&this.stateManager.destroy(),super.cleanup()}};w(y,"RENDERERS",{month:D,week:C,day:H});let k=y;customElements.get("forcecal-main")||customElements.define("forcecal-main",k),d.BaseComponent=v,d.BaseViewRenderer=_,d.DOMUtils=b,d.DateUtils=p,d.DayViewRenderer=H,d.EventBus=$,d.ForceCalendar=k,d.MonthViewRenderer=D,d.StateManager=T,d.StyleUtils=u,d.WeekViewRenderer=C,d.eventBus=I,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1064
1064
  //# sourceMappingURL=force-calendar-interface.umd.js.map