PageSourceSearch

https://portal.heritageproperty.com/assets/calendar-BPz2h1wR.js

js heritageproperty.com collected 2026-09-28 05:56:35 UTC 100,563 bytes, 168 lines download raw bytes

1import{r as x,u as Ae,j as u,q as F,M as er,B as _e,I as Ye,Y as ot,W as Rr,cD as _r,aP as se,aQ as jr,n as Ue,F as we,aE as Ar,v as Or,a$ as Ir,C as Lr,ae as Yr,co as Ur,cO as qr,cP as Wr}from"./elements-5kxJS_4j.js";import{M as $r}from"./ModernPortalPage-ZOfMD2FX.js";import{A as Fr}from"./authorization-DRCBMAi9.js";import{u as Pr}from"./useRedesign-xeayEwR4.js";import{p as Pe,W as Mt,as as tr,aA as Qe,u as nt,B as le,aW as rr,m as Hr,L as zr,G as Kr,j as nr,am as Br,o as Gr,R as Rt}from"./index-CtCeyryw.js";import{a as pt,b as ne,c as b,e as Zr}from"./tslib.es6-SRej636X.js";import{u as Qr}from"./reservations-BJ4iGbMv.js";import{u as Xr,c as Vr,a as Jr,b as en,S as tn,X as ar}from"./index-DHc3Muri.js";import{D as rn}from"./datepicker-B9D4iLeH.js";import{u as nn}from"./useModalActions-Dvto1loR.js";import{a as an}from"./addDays-Le9Cqm9z.js";import{t as Be,c as sn,s as on}from"./startOfDay-AazlW55I.js";import{c as ln}from"./constructNow-BCdMewCy.js";import{i as cn}from"./isSameDay-CQTDJwZ-.js";import{e as un}from"./endOfDay-DXHghz6c.js";import{u as bt}from"./useMutation-jkV-6MpM.js";import{u as dn}from"./useAuthorization-XS6cSJ0I.js";import"./grids-DGmfp9GI.js";import"./useIsNonHomeownerBoardMember-Cs-SpCXk.js";import"./portal-requests-pSSQdVkY.js";function yn(t,e,r){const[n,s]=[+Be(t.start,r==null?void 0:r.in),+Be(t.end,r==null?void 0:r.in)].sort((i,o)=>i-o),[a,c]=[+Be(e.start,r==null?void 0:r.in),+Be(e.end,r==null?void 0:r.in)].sort((i,o)=>i-o);return n<=c&&a<=s}function mn(t,e){return cn(sn(t,t),ln(t))}var dt=["MO","TU","WE","TH","FR","SA","SU"],z=(function(){function t(e,r){if(r===0)throw new Error("Can't create weekday with n == 0");this.weekday=e,this.n=r}return t.fromStr=function(e){return new t(dt.indexOf(e))},t.prototype.nth=function(e){return this.n===e?this:new t(this.weekday,e)},t.prototype.equals=function(e){return this.weekday===e.weekday&&this.n===e.n},t.prototype.toString=function(){var e=dt[this.weekday];return this.n&&(e=(this.n>0?"+":"")+String(this.n)+e),e},t.prototype.getJsWeekday=function(){return this.weekday===6?0:this.weekday+1},t})(),q=function(t){return t!=null},ie=function(t){return typeof t=="number"},_t=function(t){return typeof t=="string"&&dt.includes(t)},Q=Array.isArray,ue=function(t,e){e===void 0&&(e=t),arguments.length===1&&(e=t,t=0);for(var r=[],n=t;n<e;n++)r.push(n);return r},_=function(t,e){var r=0,n=[];if(Q(t))for(;r<e;r++)n[r]=[].concat(t);else for(;r<e;r++)n[r]=t;return n},fn=function(t){return Q(t)?t:[t]};function Me(t,e,r){r===void 0&&(r=" ");var n=String(t);return e=e>>0,n.length>e?String(n):(e=e-n.length,e>r.length&&(r+=_(r,e/r.length)),r.slice(0,e)+String(n))}var hn=function(t,e,r){var n=t.split(e);return r?n.slice(0,r).concat([n.slice(r).join(e)]):n},J=function(t,e){var r=t%e;return r*e<0?r+e:r},lt=function(t,e){return{div:Math.floor(t/e),mod:J(t,e)}},oe=function(t){return!q(t)||t.length===0},$=function(t){return!oe(t)},I=function(t,e){return $(t)&&t.indexOf(e)!==-1},ke=function(t,e,r,n,s,a){return n===void 0&&(n=0),s===void 0&&(s=0),a===void 0&&(a=0),new Date(Date.UTC(t,e-1,r,n,s,a))},pn=[31,28,31,30,31,30,31,31,30,31,30,31],sr=1e3*60*60*24,ir=9999,or=ke(1970,1,1),bn=[6,0,1,2,3,4,5],We=function(t){return t%4===0&&t%100!==0||t%400===0},lr=function(t){return t instanceof Date},qe=function(t){return lr(t)&&!isNaN(t.getTime())},vn=function(t,e){var r=t.getTime(),n=e.getTime(),s=r-n;return Math.round(s/sr)},yt=function(t){return vn(t,or)},cr=function(t){return new Date(or.getTime()+t*sr)},gn=function(t){var e=t.getUTCMonth();return e===1&&We(t.getUTCFullYear())?29:pn[e]},je=function(t){return bn[t.getUTCDay()]},jt=function(t,e){var r=ke(t,e+1,1);return[je(r),gn(r)]},ur=function(t,e){return e=e||t,new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))},mt=function(t){var e=new Date(t.getTime());return e},At=function(t){for(var e=[],r=0;r<t.length;r++)e.push(mt(t[r]));return e},Fe=function(t){t.sort(function(e,r){return e.getTime()-r.getTime()})},vt=function(t,e){e===void 0&&(e=!0);var r=new Date(t);return[Me(r.getUTCFullYear().toString(),4,"0"),Me(r.getUTCMonth()+1,2,"0"),Me(r.getUTCDate(),2,"0"),"T",Me(r.getUTCHours(),2,"0"),Me(r.getUTCMinutes(),2,"0"),Me(r.getUTCSeconds(),2,"0"),e?"Z":""].join("")},gt=function(t){var e=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/,r=e.exec(t);if(!r)throw new Error("Invalid UNTIL value: ".concat(t));return new Date(Date.UTC(parseInt(r[1],10),parseInt(r[2],10)-1,parseInt(r[3],10),parseInt(r[5],10)||0,parseInt(r[6],10)||0,parseInt(r[7],10)||0))}
1,Ot=function(t,e){var r=t.toLocaleString("sv-SE",{timeZone:e});return r.replace(" ","T")+"Z"},wn=function(t,e){var r=Intl.DateTimeFormat().resolvedOptions().timeZone,n=new Date(Ot(t,r)),s=new Date(Ot(t,e??"UTC")),a=s.getTime()-n.getTime();return new Date(t.getTime()-a)},Re=(function(){function t(e,r){this.minDate=null,this.maxDate=null,this._result=[],this.total=0,this.method=e,this.args=r,e==="between"?(this.maxDate=r.inc?r.before:new Date(r.before.getTime()-1),this.minDate=r.inc?r.after:new Date(r.after.getTime()+1)):e==="before"?this.maxDate=r.inc?r.dt:new Date(r.dt.getTime()-1):e==="after"&&(this.minDate=r.inc?r.dt:new Date(r.dt.getTime()+1))}return t.prototype.accept=function(e){++this.total;var r=this.minDate&&e<this.minDate,n=this.maxDate&&e>this.maxDate;if(this.method==="between"){if(r)return!0;if(n)return!1}else if(this.method==="before"){if(n)return!1}else if(this.method==="after")return r?!0:(this.add(e),!1);return this.add(e)},t.prototype.add=function(e){return this._result.push(e),!0},t.prototype.getValue=function(){var e=this._result;switch(this.method){case"all":case"between":return e;case"before":case"after":default:return e.length?e[e.length-1]:null}},t.prototype.clone=function(){return new t(this.method,this.args)},t})(),It=(function(t){pt(e,t);function e(r,n,s){var a=t.call(this,r,n)||this;return a.iterator=s,a}return e.prototype.add=function(r){return this.iterator(r,this._result.length)?(this._result.push(r),!0):!1},e})(Re),Xe={dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],tokens:{SKIP:/^[ \r\n\t]+|^\.$/,number:/^[1-9][0-9]*/,numberAsText:/^(one|two|three)/i,every:/^every/i,"day(s)":/^days?/i,"weekday(s)":/^weekdays?/i,"week(s)":/^weeks?/i,"hour(s)":/^hours?/i,"minute(s)":/^minutes?/i,"month(s)":/^months?/i,"year(s)":/^years?/i,on:/^(on|in)/i,at:/^(at)/i,the:/^the/i,first:/^first/i,second:/^second/i,third:/^third/i,nth:/^([1-9][0-9]*)(\.|th|nd|rd|st)/i,last:/^last/i,for:/^for/i,"time(s)":/^times?/i,until:/^(un)?til/i,monday:/^mo(n(day)?)?/i,tuesday:/^tu(e(s(day)?)?)?/i,wednesday:/^we(d(n(esday)?)?)?/i,thursday:/^th(u(r(sday)?)?)?/i,friday:/^fr(i(day)?)?/i,saturday:/^sa(t(urday)?)?/i,sunday:/^su(n(day)?)?/i,january:/^jan(uary)?/i,february:/^feb(ruary)?/i,march:/^mar(ch)?/i,april:/^apr(il)?/i,may:/^may/i,june:/^june?/i,july:/^july?/i,august:/^aug(ust)?/i,september:/^sep(t(ember)?)?/i,october:/^oct(ober)?/i,november:/^nov(ember)?/i,december:/^dec(ember)?/i,comma:/^(,\s*|(and|or)\s*)+/i}},Lt=function(t,e){return t.indexOf(e)!==-1},xn=function(t){return t.toString()},kn=function(t,e,r){return"".concat(e," ").concat(r,", ").concat(t)},fe=(function(){function t(e,r,n,s){if(r===void 0&&(r=xn),n===void 0&&(n=Xe),s===void 0&&(s=kn),this.text=[],this.language=n||Xe,this.gettext=r,this.dateFormatter=s,this.rrule=e,this.options=e.options,this.origOptions=e.origOptions,this.origOptions.bymonthday){var a=[].concat(this.options.bymonthday),c=[].concat(this.options.bynmonthday);a.sort(function(m,y){return m-y}),c.sort(function(m,y){return y-m}),this.bymonthday=a.concat(c),this.bymonthday.length||(this.bymonthday=null)}if(q(this.origOptions.byweekday)){var i=Q(this.origOptions.byweekday)?this.origOptions.byweekday:[this.origOptions.byweekday],o=String(i);this.byweekday={allWeeks:i.filter(function(m){return!m.n}),someWeeks:i.filter(function(m){return!!m.n}),isWeekdays:o.indexOf("MO")!==-1&&o.indexOf("TU")!==-1&&o.indexOf("WE")!==-1&&o.indexOf("TH")!==-1&&o.indexOf("FR")!==-1&&o.indexOf("SA")===-1&&o.indexOf("SU")===-1,isEveryDay:o.indexOf("MO")!==-1&&o.indexOf("TU")!==-1&&o.indexOf("WE")!==-1&&o.indexOf("TH")!==-1&&o.indexOf("FR")!==-1&&o.indexOf("SA")!==-1&&o.indexOf("SU")!==-1};var f=function(m,y){return m.weekday-y.weekday};this.byweekday.allWeeks.sort(f),this.byweekday.someWeeks.sort(f),this.byweekday.allWeeks.length||(this.byweekday.allWeeks=null),this.byweekday.someWeeks.length||(this.byweekday.someWeeks=null)}else this.byweekday=null}return t.isFullyConvertible=function(e){var r=!0;
1if(!(e.options.freq in t.IMPLEMENTED)||e.origOptions.until&&e.origOptions.count)return!1;for(var n in e.origOptions){if(Lt(["dtstart","tzid","wkst","freq"],n))return!0;if(!Lt(t.IMPLEMENTED[e.options.freq],n))return!1}return r},t.prototype.isFullyConvertible=function(){return t.isFullyConvertible(this.rrule)},t.prototype.toString=function(){var e=this.gettext;if(!(this.options.freq in t.IMPLEMENTED))return e("RRule error: Unable to fully convert this rrule to text");if(this.text=[e("every")],this[C.FREQUENCIES[this.options.freq]](),this.options.until){this.add(e("until"));var r=this.options.until;this.add(this.dateFormatter(r.getUTCFullYear(),this.language.monthNames[r.getUTCMonth()],r.getUTCDate()))}else this.options.count&&this.add(e("for")).add(this.options.count.toString()).add(this.plural(this.options.count)?e("times"):e("time"));return this.isFullyConvertible()||this.add(e("(~ approximate)")),this.text.join("")},t.prototype.HOURLY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("hours"):e("hour"))},t.prototype.MINUTELY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("minutes"):e("minute"))},t.prototype.DAILY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.byweekday&&this.byweekday.isWeekdays?this.add(this.plural(this.options.interval)?e("weekdays"):e("weekday")):this.add(this.plural(this.options.interval)?e("days"):e("day")),this.origOptions.bymonth&&(this.add(e("in")),this._bymonth()),this.bymonthday?this._bymonthday():this.byweekday?this._byweekday():this.origOptions.byhour&&this._byhour()},t.prototype.WEEKLY=function(){var e=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()).add(this.plural(this.options.interval)?e("weeks"):e("week")),this.byweekday&&this.byweekday.isWeekdays?this.options.interval===1?this.add(this.plural(this.options.interval)?e("weekdays"):e("weekday")):this.add(e("on")).add(e("weekdays")):this.byweekday&&this.byweekday.isEveryDay?this.add(this.plural(this.options.interval)?e("days"):e("day")):(this.options.interval===1&&this.add(e("week")),this.origOptions.bymonth&&(this.add(e("in")),this._bymonth()),this.bymonthday?this._bymonthday():this.byweekday&&this._byweekday(),this.origOptions.byhour&&this._byhour())},t.prototype.MONTHLY=function(){var e=this.gettext;this.origOptions.bymonth?(this.options.interval!==1&&(this.add(this.options.interval.toString()).add(e("months")),this.plural(this.options.interval)&&this.add(e("in"))),this._bymonth()):(this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("months"):e("month"))),this.bymonthday?this._bymonthday():this.byweekday&&this.byweekday.isWeekdays?this.add(e("on")).add(e("weekdays")):this.byweekday&&this._byweekday()},t.prototype.YEARLY=function(){var e=this.gettext;this.origOptions.bymonth?(this.options.interval!==1&&(this.add(this.options.interval.toString()),this.add(e("years"))),this._bymonth()):(this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?e("years"):e("year"))),this.bymonthday?this._bymonthday():this.byweekday&&this._byweekday(),this.options.byyearday&&this.add(e("on the")).add(this.list(this.options.byyearday,this.nth,e("and"))).add(e("day")),this.options.byweekno&&this.add(e("in")).add(this.plural(this.options.byweekno.length)?e("weeks"):e("week")).add(this.list(this.options.byweekno,void 0,e("and")))},t.prototype._bymonthday=function(){var e=this.gettext;this.byweekday&&this.byweekday.allWeeks?this.add(e("on")).add(this.list(this.byweekday.allWeeks,this.weekdaytext,e("or"))).add(e("the")).add(this.list(this.bymonthday,this.nth,e("or"))):this.add(e("on the")).add(this.list(this.bymonthday,this.nth,e("and")))},t.prototype._byweekday=function(){var e=this.gettext;this.byweekday.allWeeks&&!this.byweekday.isWeekdays&&this.add(e("on")).add(this.list(this.byweekday.allWeeks,this.weekdaytext)),this.byweekday.someWeeks&&(this.byweekday.allWeeks&&this.add(e("and")),this.add(e("on the")).add(this.list(this.byweekday.someWeeks,this.weekdaytext,e("and"))))},t.prototype._byhour=function(){var e=this.gettext;this.add(e("at")).add(this.list(this.origOptions.byhour,void 0,e("and")))},t.prototype._bymonth=function(){this.add(this.list(this.options.bymonth,this.monthtext,this.gettext("and")))},t.prototype.nth=function(e){e=parseInt(e.toString(),10);var r,n=this.gettext;if(e===-1)return n("last");var s=Math.abs(e);switch(s){case 1:case 21:case 31:r=s+n("st");break;case 2:case 22:r=s+n("nd");break;case 3:case 23:r=s+n("rd");break;default:r=s+n("th")}return e<0?r+" "+n("last"):r},t.prototype.monthtext=function(e){return this.language.monthNames[e-1
1]},t.prototype.weekdaytext=function(e){var r=ie(e)?(e+1)%7:e.getJsWeekday();return(e.n?this.nth(e.n)+" ":"")+this.language.dayNames[r]},t.prototype.plural=function(e){return e%100!==1},t.prototype.add=function(e){return this.text.push(" "),this.text.push(e),this},t.prototype.list=function(e,r,n,s){var a=this;s===void 0&&(s=","),Q(e)||(e=[e]);var c=function(o,f,m){for(var y="",d=0;d<o.length;d++)d!==0&&(d===o.length-1?y+=" "+m+" ":y+=f+" "),y+=o[d];return y};r=r||function(o){return o.toString()};var i=function(o){return r&&r.call(a,o)};return n?c(e.map(i),s,n):e.map(i).join(s+" ")},t})(),Dn=(function(){function t(e){this.done=!0,this.rules=e}return t.prototype.start=function(e){return this.text=e,this.done=!1,this.nextSymbol()},t.prototype.isDone=function(){return this.done&&this.symbol===null},t.prototype.nextSymbol=function(){var e,r;this.symbol=null,this.value=null;do{if(this.done)return!1;var n=void 0;e=null;for(var s in this.rules){n=this.rules[s];var a=n.exec(this.text);a&&(e===null||a[0].length>e[0].length)&&(e=a,r=s)}if(e!=null&&(this.text=this.text.substr(e[0].length),this.text===""&&(this.done=!0)),e==null){this.done=!0,this.symbol=null,this.value=null;return}}while(r==="SKIP");return this.symbol=r,this.value=e,!0},t.prototype.accept=function(e){if(this.symbol===e){if(this.value){var r=this.value;return this.nextSymbol(),r}return this.nextSymbol(),!0}return!1},t.prototype.acceptNumber=function(){return this.accept("number")},t.prototype.expect=function(e){if(this.accept(e))return!0;throw new Error("expected "+e+" but found "+this.symbol)},t})();function dr(t,e){e===void 0&&(e=Xe);var r={},n=new Dn(e.tokens);if(!n.start(t))return null;return s(),r;function s(){n.expect("every");var d=n.acceptNumber();if(d&&(r.interval=parseInt(d[0],10)),n.isDone())throw new Error("Unexpected end");switch(n.symbol){case"day(s)":r.freq=C.DAILY,n.nextSymbol()&&(c(),y());break;case"weekday(s)":r.freq=C.WEEKLY,r.byweekday=[C.MO,C.TU,C.WE,C.TH,C.FR],n.nextSymbol(),c(),y();break;case"week(s)":r.freq=C.WEEKLY,n.nextSymbol()&&(a(),c(),y());break;case"hour(s)":r.freq=C.HOURLY,n.nextSymbol()&&(a(),y());break;case"minute(s)":r.freq=C.MINUTELY,n.nextSymbol()&&(a(),y());break;case"month(s)":r.freq=C.MONTHLY,n.nextSymbol()&&(a(),y());break;case"year(s)":r.freq=C.YEARLY,n.nextSymbol()&&(a(),y());break;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":r.freq=C.WEEKLY;var h=n.symbol.substr(0,2).toUpperCase();if(r.byweekday=[C[h]],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var k=o();if(!k)throw new Error("Unexpected symbol "+n.symbol+", expected weekday");r.byweekday.push(C[k]),n.nextSymbol()}c(),m(),y();break;case"january":case"february":case"march":case"april":case"may":case"june":case"july":case"august":case"september":case"october":case"november":case"december":if(r.freq=C.YEARLY,r.bymonth=[i()],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var v=i();if(!v)throw new Error("Unexpected symbol "+n.symbol+", expected month");r.bymonth.push(v),n.nextSymbol()}a(),y();break;default:throw new Error("Unknown symbol")}}function a(){var d=n.accept("on"),h=n.accept("the");if(d||h)do{var k=f(),v=o(),w=i();if(k)v?(n.nextSymbol(),r.byweekday||(r.byweekday=[]),r.byweekday.push(C[v].nth(k))):(r.bymonthday||(r.bymonthday=[]),r.bymonthday.push(k),n.accept("day(s)"));else if(v)n.nextSymbol(),r.byweekday||(r.byweekday=[]),r.byweekday.push(C[v]);else if(n.symbol==="weekday(s)")n.nextSymbol(),r.byweekday||(r.byweekday=[C.MO,C.TU,C.WE,C.TH,C.FR]);else if(n.symbol==="week(s)"){n.nextSymbol();var p=n.acceptNumber();if(!p)throw new Error("Unexpected symbol "+n.symbol+", expected week number");for(r.byweekno=[parseInt(p[0],10)];n.accept("comma");){if(p=n.acceptNumber(),!p)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");r.byweekno.push(parseInt(p[0],10))}}else if(w)n.nextSymbol(),r.bymonth||(r.bymonth=[]),r.bymonth.push(w);else return}while(n.accept("comma")||n.accept("the")||n.accept("on"))}function c(){var d=n.accept("at");if(d)do{var h=n.acceptNumber();if(!h)throw new Error("Unexpected symbol "+n.symbol+", expected hour");for(r.byhour=[parseInt(h[0],10)];n.accept("comma");){if(h=n.acceptNumber(),!h)throw new Error("Unexpected symbol "+n.symbol+"; expected hour");r.byhour.push(parseInt(h[0],10))}}while(n.accept("comma")||n.accept("at"))}function i(){switch(n.symbol){case"january":return 1;case"february":return 2;case"march":return 3;case"april":return 4;case"may":return 5;case"june":return 6;case"july":return 7;case"august":return 8;case"september":return 9;
1case"october":return 10;case"november":return 11;case"december":return 12;default:return!1}}function o(){switch(n.symbol){case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return n.symbol.substr(0,2).toUpperCase();default:return!1}}function f(){switch(n.symbol){case"last":return n.nextSymbol(),-1;case"first":return n.nextSymbol(),1;case"second":return n.nextSymbol(),n.accept("last")?-2:2;case"third":return n.nextSymbol(),n.accept("last")?-3:3;case"nth":var d=parseInt(n.value[1],10);if(d<-366||d>366)throw new Error("Nth out of range: "+d);return n.nextSymbol(),n.accept("last")?-d:d;default:return!1}}function m(){n.accept("on"),n.accept("the");var d=f();if(d)for(r.bymonthday=[d],n.nextSymbol();n.accept("comma");){if(d=f(),!d)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");r.bymonthday.push(d),n.nextSymbol()}}function y(){if(n.symbol==="until"){var d=Date.parse(n.text);if(!d)throw new Error("Cannot parse until date:"+n.text);r.until=new Date(d)}else n.accept("for")&&(r.count=parseInt(n.value[0],10),n.expect("number"))}}var j;(function(t){t[t.YEARLY=0]="YEARLY",t[t.MONTHLY=1]="MONTHLY",t[t.WEEKLY=2]="WEEKLY",t[t.DAILY=3]="DAILY",t[t.HOURLY=4]="HOURLY",t[t.MINUTELY=5]="MINUTELY",t[t.SECONDLY=6]="SECONDLY"})(j||(j={}));function wt(t){return t<j.HOURLY}var Tn=function(t,e){return e===void 0&&(e=Xe),new C(dr(t,e)||void 0)},Oe=["count","until","interval","byweekday","bymonthday","bymonth"];fe.IMPLEMENTED=[];fe.IMPLEMENTED[j.HOURLY]=Oe;fe.IMPLEMENTED[j.MINUTELY]=Oe;fe.IMPLEMENTED[j.DAILY]=["byhour"].concat(Oe);fe.IMPLEMENTED[j.WEEKLY]=Oe;fe.IMPLEMENTED[j.MONTHLY]=Oe;fe.IMPLEMENTED[j.YEARLY]=["byweekno","byyearday"].concat(Oe);var Cn=function(t,e,r,n){return new fe(t,e,r,n).toString()},En=fe.isFullyConvertible,Ve=(function(){function t(e,r,n,s){this.hour=e,this.minute=r,this.second=n,this.millisecond=s||0}return t.prototype.getHours=function(){return this.hour},t.prototype.getMinutes=function(){return this.minute},t.prototype.getSeconds=function(){return this.second},t.prototype.getMilliseconds=function(){return this.millisecond},t.prototype.getTime=function(){return(this.hour*60*60+this.minute*60+this.second)*1e3+this.millisecond},t})(),Nn=(function(t){pt(e,t);function e(r,n,s,a,c,i,o){var f=t.call(this,a,c,i,o)||this;return f.year=r,f.month=n,f.day=s,f}return e.fromDate=function(r){return new this(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.valueOf()%1e3)},e.prototype.getWeekday=function(){return je(new Date(this.getTime()))},e.prototype.getTime=function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond)).getTime()},e.prototype.getDay=function(){return this.day},e.prototype.getMonth=function(){return this.month},e.prototype.getYear=function(){return this.year},e.prototype.addYears=function(r){this.year+=r},e.prototype.addMonths=function(r){if(this.month+=r,this.month>12){var n=Math.floor(this.month/12),s=J(this.month,12);this.month=s,this.year+=n,this.month===0&&(this.month=12,--this.year)}},e.prototype.addWeekly=function(r,n){n>this.getWeekday()?this.day+=-(this.getWeekday()+1+(6-n))+r*7:this.day+=-(this.getWeekday()-n)+r*7,this.fixDay()},e.prototype.addDaily=function(r){this.day+=r,this.fixDay()},e.prototype.addHours=function(r,n,s){for(n&&(this.hour+=Math.floor((23-this.hour)/r)*r);;){this.hour+=r;var a=lt(this.hour,24),c=a.div,i=a.mod;if(c&&(this.hour=i,this.addDaily(c)),oe(s)||I(s,this.hour))break}},e.prototype.addMinutes=function(r,n,s,a){for(n&&(this.minute+=Math.floor((1439-(this.hour*60+this.minute))/r)*r);;){this.minute+=r;var c=lt(this.minute,60),i=c.div,o=c.mod;if(i&&(this.minute=o,this.addHours(i,!1,s)),(oe(s)||I(s,this.hour))&&(oe(a)||I(a,this.minute)))break}},e.prototype.addSeconds=function(r,n,s,a,c){for(n&&(this.second+=Math.floor((86399-(this.hour*3600+this.minute*60+this.second))/r)*r);;){this.second+=r;var i=lt(this.second,60),o=i.div,f=i.mod;if(o&&(this.second=f,this.addMinutes(o,!1,s,a)),(oe(s)||I(s,this.hour))&&(oe(a)||I(a,this.minute))&&(oe(c)||I(c,this.second)))break}},e.prototype.fixDay=function(){if(!(this.day<=28)){var r=jt(this.year,this.month-1)[1];if(!(this.day<=r))for(;this.day>r;){if(this.day-=r,++this.month,this.month===13&&(this.month=1,++this.year,this.year>ir))return;r=jt(this.year,this.month-1)[1]}}},e.prototype.add=function(r,n){var s=r.freq,a=r.interval,c=r.wkst,i=r.byhour,o=r.byminute,f=r.bysecond;switch(s){case j.YEARLY:return this.addYears(a);case j.MONTHLY:return this.addMonths(a);case j.WEEKLY:return this.addWeekly(a,c);case j.DAILY:return this.addDaily(a);case j.HOURLY:return this.addHours(a,n,i);case j.MINUTELY:return this.addMinutes(a,n,i,o);case j.SECONDLY:return this.addSeconds(a,n,i,o,f)}},e})(Ve);function yr(t){for(var e=[],r=Object.keys(t),n=0,s=r;n<s.length;n++){var a=s[n];I(na,a)||e.push(a),lr(t[a])&&!qe(t[a])&&e.push(a)}if(e.length)throw new Error("Invalid options: "+e.join(", "));return ne({},t)}function Sn(t){var e=ne(ne({},xt),yr(t));if(q(e.byeaster)&&(e.freq=C.YEARLY),!(q(e.freq)&&C.FREQUENCIES[e.freq]))throw new Error("Invalid frequency: ".concat(e.freq," ").concat(t.freq));if(e.dtstart||(e.dtstart=new Date(new Date().setMilliseconds(0))),q(e.wkst)?ie(e.wkst)||(e.wkst=e.wkst.weekday):e.wkst=C.MO.weekday,q(e.bysetpos)){ie(e.bysetpos)&&(e.bysetpos=[e.bysetpos]);for(var r=0;r<e.bysetpos.length;r++){var n=e.bysetpos[r];if(n===0||!(n>=-366&&n<=366))throw new Error("bysetpos must be between 1 and 366, or between -366 and -1")}}if(!(e.byweekno||$(e.byweekno)||$(e.byyearday)||e.bymonthday||$(e.bymonthday)||q(e.byweekday)||q(e.byeaster)))switch(e.freq){case C.YEARLY:e.bymonth||(e.bymonth=e.dtstart.getUTCMonth()+1),e.bymonthday=e.dtstart.getUTCDate();break;case C.MONTHLY:e.bymonthday=e.dtstart.getUTCDate();break;case C.WEEKLY:e.byweekday=[je(e.dtstart)];break}if(q(e.bymonth)&&!Q(e.bymonth)&&(e.bymonth=[e.bymonth]),q(e.byyearday)&&!Q(e.byyearday)&&ie(e.byyearday)&&(e.byyearday=[e.byyearday]),!q(e.bymonthday))e.bymonthday=[],e.bynmonthday=[];else if(Q(e.bymonthday)){for(var s=[],a=[],r=0;r<e.bymonthday.length;r++){var n=e.bymonthday[r];n>0?s.push(n):n<0&&a.push(n)}e.bymonthday=s,e.bynmonthday=a}else e.bymonthday<0?(e.bynmonthday=[e.bymonthday],e.bymonthday=[]):(e.bynmonthday=[],e.bymonthday=[e.bymonthday]);if(q(e.byweekno)&&!Q(e.byweekno)&&(e.byweekno=[e.byweekno]),!q(e.byweekday))e.bynweekday=null;else if(ie(e.byweekday))e.byweekday=[e.byweekday],e.bynweekday=null;else if(_t(e.byweekday))e.byweekday=[z.fromStr(e.byweekday).weekday],e.bynweekday=null;else if(e.byweekday instanceof z)!e.byweekday.n||e.freq>C.MONTHLY?(e.byweekday=[e.byweekday.weekday],e.bynweekday=null):(e.bynweekday=[[e.byweekday.weekday,e.byweekday.n]],e.byweekday=null);else{for(var c=[],i=[],r=0;r<e.byweekday.length;r++){var o=e.byweekday[r];if(ie(o)){c.push(o);continue}else if(_t(o)){c.push(z.fromStr(o).weekday);continue}!o.n||e.freq>C.MONTHLY?c.push(o.weekday):i.push([o.weekday,o.n])}e.byweekday=$(c)?c:null,e.bynweekday=$(i)?i:null}return q(e.byhour)?ie(e.byhour)&&(e.byhour=[e.byhour]):e.byhour=e.freq<C.HOURLY?[e.dtstart.getUTCHours()]:null,q(e.byminute)?ie(e.byminute)&&(e.byminute=[e.byminute]):e.byminute=e.freq<C.MINUTELY?[e.dtstart.getUTCMinutes()]:null,q(e.bysecond)?ie(e.bysecond)&&(e.bysecond=[e.bysecond]):e.bysecond=e.freq<C.SECONDLY?[e.dtstart.getUTCSeconds()]:null,{parsedOptions:e}}function Mn(t){var e=t.dtstart.getTime()%1e3;if(!wt(t.freq))return[];var r=[];return t.byhour.forEach(function(n){t.byminute.forEach(function(s){t.bysecond.forEac
1h(function(a){r.push(new Ve(n,s,a,e))})})}),r}function ft(t){var e=t.split(`
2`).map(Rn).filter(function(r){return r!==null});return ne(ne({},e[0]),e[1])}function Je(t){var e={},r=/DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)/i.exec(t);if(!r)return e;var n=r[1],s=r[2];return n&&(e.tzid=n),e.dtstart=gt(s),e}function Rn(t){if(t=t.replace(/^\s+|\s+$/,""),!t.length)return null;var e=/^([A-Z]+?)[:;]/.exec(t.toUpperCase());if(!e)return Yt(t);var r=e[1];switch(r.toUpperCase()){case"RRULE":case"EXRULE":return Yt(t);case"DTSTART":return Je(t);default:throw new Error("Unsupported RFC prop ".concat(r," in ").concat(t))}}function Yt(t){var e=t.replace(/^RRULE:/i,""),r=Je(e),n=t.replace(/^(?:RRULE|EXRULE):/i,"").split(";");return n.forEach(function(s){var a=s.split("="),c=a[0],i=a[1];switch(c.toUpperCase()){case"FREQ":r.freq=j[i.toUpperCase()];break;case"WKST":r.wkst=re[i.toUpperCase()];break;case"COUNT":case"INTERVAL":case"BYSETPOS":case"BYMONTH":case"BYMONTHDAY":case"BYYEARDAY":case"BYWEEKNO":case"BYHOUR":case"BYMINUTE":case"BYSECOND":var o=_n(i),f=c.toLowerCase();r[f]=o;break;case"BYWEEKDAY":case"BYDAY":r.byweekday=jn(i);break;case"DTSTART":case"TZID":var m=Je(t);r.tzid=m.tzid,r.dtstart=m.dtstart;break;case"UNTIL":r.until=gt(i);break;case"BYEASTER":r.byeaster=Number(i);break;default:throw new Error("Unknown RRULE property '"+c+"'")}}),r}function _n(t){if(t.indexOf(",")!==-1){var e=t.split(",");return e.map(Ut)}return Ut(t)}function Ut(t){return/^[+-]?\d+$/.test(t)?Number(t):t}function jn(t){var e=t.split(",");return e.map(function(r){if(r.length===2)return re[r];var n=r.match(/^([+-]?\d{1,2})([A-Z]{2})$/);if(!n||n.length<3)throw new SyntaxError("Invalid weekday string: ".concat(r));var s=Number(n[1]),a=n[2],c=re[a].weekday;return new z(c,s)})}var et=(function(){function t(e,r){if(isNaN(e.getTime()))throw new RangeError("Invalid date passed to DateWithZone");this.date=e,this.tzid=r}return Object.defineProperty(t.prototype,"isUTC",{get:function(){return!this.tzid||this.tzid.toUpperCase()==="UTC"},enumerable:!1,configurable:!0}),t.prototype.toString=function(){var e=vt(this.date.getTime(),this.isUTC);return this.isUTC?":".concat(e):";TZID=".concat(this.tzid,":").concat(e)},t.prototype.getTime=function(){return this.date.getTime()},t.prototype.rezonedDate=function(){return this.isUTC?this.date:wn(this.date,this.tzid)},t})();function ht(t){for(var e=[],r="",n=Object.keys(t),s=Object.keys(xt),a=0;a<n.length;a++)if(n[a]!=="tzid"&&I(s,n[a])){var c=n[a].toUpperCase(),i=t[n[a]],o="";if(!(!q(i)||Q(i)&&!i.length)){switch(c){case"FREQ":o=C.FREQUENCIES[t.freq];break;case"WKST":ie(i)?o=new z(i).toString():o=i.toString();break;case"BYWEEKDAY":c="BYDAY",o=fn(i).map(function(h){return h instanceof z?h:Q(h)?new z(h[0],h[1]):new z(h)}).toString();break;case"DTSTART":r=An(i,t.tzid);break;case"UNTIL":o=vt(i,!t.tzid);break;default:if(Q(i)){for(var f=[],m=0;m<i.length;m++)f[m]=String(i[m]);o=f.toString()}else o=String(i)}o&&e.push([c,o])}}var y=e.map(function(h){var k=h[0],v=h[1];return"".concat(k,"=").concat(v.toString())}).join(";"),d="";return y!==""&&(d="RRULE:".concat(y)),[r,d].filter(function(h){return!!h}).join(`
3`)}function An(t,e){return t?"DTSTART"+new et(new Date(t),e).toString():""}function On(t,e){return Array.isArray(t)?!Array.isArray(e)||t.length!==e.length?!1:t.every(function(r,n){return r.getTime()===e[n].getTime()}):t instanceof Date?e instanceof Date&&t.getTime()===e.getTime():t===e}var In=(function(){function t(){this.all=!1,this.before=[],this.after=[],this.between=[]}return t.prototype._cacheAdd=function(e,r,n){r&&(r=r instanceof Date?mt(r):At(r)),e==="all"?this.all=r:(n._value=r,this[e].push(n))},t.prototype._cacheGet=function(e,r){var n=!1,s=r?Object.keys(r):[],a=function(m){for(var y=0;y<s.length;y++){var d=s[y];if(!On(r[d],m[d]))return!0}return!1},c=this[e];if(e==="all")n=this.all;else if(Q(c))for(var i=0;i<c.length;i++){var o=c[i];if(!(s.length&&a(o))){n=o._value;break}}if(!n&&this.all){for(var f=new Re(e,r),i=0;i<this.all.length&&f.accept(this.all[i]);i++);n=f.getValue(),this._cacheAdd(e,n,r)}return Q(n)?At(n):n instanceof Date?mt(n):n},t})(),Ln=b(b(b(b(b(b(b(b(b(b(b(b(b([],_(1,31),!0),_(2,28),!0),_(3,31),!0),_(4,30),!0),_(5,31),!0),_(6,30),!0),_(7,31),!0),_(8,31),!0),_(9,30),!0),_(10,31),!0),_(11,30),!0),_(12,31),!0),_(1,7),!0),Yn=b(b(b(b(b(b(b(b(b(b(b(b(b([],_(1,31),!0),_(2,29),!0),_(3,31),!0),_(4,30),!0),_(5,31),!0),_(6,30),!0),_(7,31),!0),_(8,31),!0),_(9,30),!0),_(10,31),!0),_(11,30),!0),_(12,31),!0),_(1,7),!0),Un=ue(1,29),qn=ue(1,30),pe=ue(1,31),P=ue(1,32),Wn=b(b(b(b(b(b(b(b(b(b(b(b(b([],P,!0),qn,!0),P,!0),pe,!0),P,!0),pe,!0),P,!0),P,!0),pe,!0),P,!0),pe,!0),P,!0),P.slice(0,7),!0),$n=b(b(b(b(b(b(b(b(b(b(b(b(b([],P,!0),Un,!0),P,!0),pe,!0),P,!0),pe,!0),P,!0),P,!0),pe,!0),P,!0),pe,!0),P,!0),P.slice(0,7),!0),Fn=ue(-28,0),Pn=ue(-29,0),be=ue(-30,0),H=ue(-31,0),Hn=b(b(b(b(b(b(b(b(b(b(b(b(b([],H,!0),Pn,!0),H,!0),be,!0),H,!0),be,!0),H,!0),H,!0),be,!0),H,!0),be,!0),H,!0),H.slice(0,7),!0),zn=b(b(b(b(b(b(b(b(b(b(b(b(b([],H,!0),Fn,!0),H,!0),be,!0),H,!0),be,!0),H,!0),H,!0),be,!0),H,!0),be,!0),H,!0),H.slice(0,7),!0),Kn=[0,31,60,91,121,152,182,213,244,274,305,335,366],Bn=[0,31,59,90,120,151,181,212,243,273,304,334,365],qt=(function(){for(var t=[],e=0;e<55;e++)t=t.concat(ue(7));return t})();function Gn(t,e){var r=ke(t,1,1),n=We(t)?366:365,s=We(t+1)?366:365,a=yt(r),c=je(r),i=ne(ne({yearlen:n,nextyearlen:s,yearordinal:a,yearweekday:c},Zn(t)),{wnomask:null});if(oe(e.byweekno))return i;i.wnomask=_(0,n+7);var o,f,m=o=J(7-c+e.wkst,7);m>=4?(m=0,f=i.yearlen+J(c-e.wkst,7)):f=n-m;for(var y=Math.floor(f/7),d=J(f,7),h=Math.floor(y+d/4),k=0;k<e.byweekno.length;k++){var v=e.byweekno[k];if(v<0&&(v+=h+1),v>0&&v<=h){var w=void 0;v>1?(w=m+(v-1)*7,m!==o&&(w-=7-o)):w=m;for(var p=0;p<7&&(i.wnomask[w]=1,w++,i.wdaymask[w]!==e.wkst);p++);}}if(I(e.byweekno,1)){var w=m+h*7;if(m!==o&&(w-=7-o),w<n)for(var k=0;
3k<7&&(i.wnomask[w]=1,w+=1,i.wdaymask[w]!==e.wkst);k++);}if(m){var S=void 0;if(I(e.byweekno,-1))S=-1;else{var E=je(ke(t-1,1,1)),M=J(7-E.valueOf()+e.wkst,7),K=We(t-1)?366:365,U=void 0;M>=4?(M=0,U=K+J(E-e.wkst,7)):U=n-m,S=Math.floor(52+J(U,7)/4)}if(I(e.byweekno,S))for(var w=0;w<m;w++)i.wnomask[w]=1}return i}function Zn(t){var e=We(t)?366:365,r=ke(t,1,1),n=je(r);return e===365?{mmask:Ln,mdaymask:$n,nmdaymask:zn,wdaymask:qt.slice(n),mrange:Bn}:{mmask:Yn,mdaymask:Wn,nmdaymask:Hn,wdaymask:qt.slice(n),mrange:Kn}}function Qn(t,e,r,n,s,a){var c={lastyear:t,lastmonth:e,nwdaymask:[]},i=[];if(a.freq===C.YEARLY)if(oe(a.bymonth))i=[[0,r]];else for(var o=0;o<a.bymonth.length;o++)e=a.bymonth[o],i.push(n.slice(e-1,e+1));else a.freq===C.MONTHLY&&(i=[n.slice(e-1,e+1)]);if(oe(i))return c;c.nwdaymask=_(0,r);for(var o=0;o<i.length;o++)for(var f=i[o],m=f[0],y=f[1]-1,d=0;d<a.bynweekday.length;d++){var h=void 0,k=a.bynweekday[d],v=k[0],w=k[1];w<0?(h=y+(w+1)*7,h-=J(s[h]-v,7)):(h=m+(w-1)*7,h+=J(7-s[h]+v,7)),m<=h&&h<=y&&(c.nwdaymask[h]=1)}return c}function Xn(t,e){e===void 0&&(e=0);var r=t%19,n=Math.floor(t/100),s=t%100,a=Math.floor(n/4),c=n%4,i=Math.floor((n+8)/25),o=Math.floor((n-i+1)/3),f=Math.floor(19*r+n-a-o+15)%30,m=Math.floor(s/4),y=s%4,d=Math.floor(32+2*c+2*m-f-y)%7,h=Math.floor((r+11*f+22*d)/451),k=Math.floor((f+d-7*h+114)/31),v=(f+d-7*h+114)%31+1,w=Date.UTC(t,k-1,v+e),p=Date.UTC(t,0,1);return[Math.ceil((w-p)/(1e3*60*60*24))]}var Vn=(function(){function t(e){this.options=e}return t.prototype.rebuild=function(e,r){var n=this.options;if(e!==this.lastyear&&(this.yearinfo=Gn(e,n)),$(n.bynweekday)&&(r!==this.lastmonth||e!==this.lastyear)){var s=this.yearinfo,a=s.yearlen,c=s.mrange,i=s.wdaymask;this.monthinfo=Qn(e,r,a,c,i,n)}q(n.byeaster)&&(this.eastermask=Xn(e,n.byeaster))},Object.defineProperty(t.prototype,"lastyear",{get:function(){return this.monthinfo?this.monthinfo.lastyear:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastmonth",{get:function(){return this.monthinfo?this.monthinfo.lastmonth:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yearlen",{get:function(){return this.yearinfo.yearlen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yearordinal",{get:function(){return this.yearinfo.yearordinal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mrange",{get:function(){return this.yearinfo.mrange},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wdaymask",{get:function(){return this.yearinfo.wdaymask},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mmask",{get:function(){return this.yearinfo.mmask},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wnomask",{get:function(){return this.yearinfo.wnomask},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nwdaymask",{get:function(){return this.monthinfo?this.monthinfo.nwdaymask:[]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nextyearlen",{get:function(){return this.yearinfo.nextyearlen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mdaymask",{get:function(){return this.yearinfo.mdaymask},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nmdaymask",{get:function(){return this.yearinfo.nmdaymask},enumerable:!1,configurable:!0}),t.prototype.ydayset=function(){return[ue(this.yearlen),0,this.yearlen]},t.prototype.mdayset=function(e,r){for(var n=this.mrange[r-1],s=this.mrange[r],a=_(null,this.yearlen),c=n;c<s;c++)a[c]=c;return[a,n,s]},t.prototype.wdayset=function(e,r,n){for(var s=_(null,this.yearlen+7),a=yt(ke(e,r,n))-this.yearordinal,c=a,i=0;i<7&&(s[a]=a,++a,this.wdaymask[a]!==this.options.wkst);i++);return[s,c,a]},t.prototype.ddayset=function(e,r,n){var s=_(null,this.yearlen),a=yt(ke(e,r,n))-this.yearordinal;return s[a]=a,[s,a,a+1]},t.prototype.htimeset=function(e,r,n,s){var a=this,c=[];return this.options.byminute.forEach(function(i){c=c.concat(a.mtimeset(e,i,n,s))}),Fe(c),c},t.prototype.mtimeset=function(e,r,n,s){var a=this.options.bysecond.map(function(c){return new Ve(e,r,c,s)});return Fe(a),a},t.prototype.stimeset=function(e,r,n,s){return[new Ve(e,r,n,s)]},t.prototype.getdayset=function(e){switch(e){case j.YEARLY:return this.ydayset.bind(this);case j.MONTHLY:return this.mdayset.bind(this);case j.WEEKLY:return this.wdayset.bind(this);case j.DAILY:return this.ddayset.bind(this);default:return this.ddayset.bind(this)}},t.prototype.gettimeset=function(e){switch(e){case j.HOURLY:return this.htimeset.bind(this);case j.MINUTELY:return this.mtimeset.bind(this);case j.SECONDLY:return this.stimeset.bind(this)}},t})();function Jn(t,e,r,n,s,a){for(var c=[],i=0;i<t.length;i++){var o=void 0,f=void 0,m=t[i];m<0?(o=Math.floor(m/e.length),f=J(m,e.length)):(o=Math.floor((m-1)/e.length),f=J(m-1,e.length));for(var y=[],d=r;d<n;d++){var h=a[d];q(h)&&y.push(h)}var k=void 0;o<0?k=y.slice(o)[0]:k=y[o];var v=e[f],w=cr(s.yearordinal+k),p=ur(w,v);I(c,p)||c.push(p)}return Fe(c),c}function mr(t,e){var r=e.dtstart,n=e.freq,s=e.interval,a=e.until,c=e.bysetpos,i=e.count;if(i===0||s===0)return me(t);var o=Nn.fromDate(r),f=new Vn(e);f.rebuild(o.year,o.month);for(var m=ra(f,o,e);;){var y=f.getdayset(n)(o.year,o.month,o.day),d=y[0],h=y[1],k=y[2],v=ta(d,h,k,f,e);if($(c))for(var w=Jn(c,m,h,k,f,d),p=0;p<w.length;p++){var S=w[p];if(a&&S>a)return me(t);if(S>=r){var E=Wt(S,e);if(!t.accept(E)||i&&(--i,!i))return me(t)}}else for(var p=h;p<k;p++){var M=d[p];if(q(M))for(var K=cr(f.yearordinal+M),U=0;U<m.length;U++){var L=m[U],S=ur(K,L);if(a&&S>a)return me(t);if(S>=r){var E=Wt(S,e);if(!t.accept(E)||i&&(--i,!i))return me(t)}}}if(e.interval===0||(o.add(e,v),o.year>ir))return me(t);wt(n)||(m=f.gettimeset(n)(o.hour,o.minute,o.second,0)),f.rebuild(o.year,o.month)}}function ea(t,e,r){var n=r.bymonth,s=r.byweekno,a=r.byweekday,c=r.byeaster,i=r.bymonthday,o=r.bynmonthday,f=r.byyearday;return $(n)&&!I(n,t.mmask[e])||$(s)&&!t.wnomask[e]||$(a)&&!I(a,t.wdaymask[e])||$(t.nwdaymask)&&
3!t.nwdaymask[e]||c!==null&&!I(t.eastermask,e)||($(i)||$(o))&&!I(i,t.mdaymask[e])&&!I(o,t.nmdaymask[e])||$(f)&&(e<t.yearlen&&!I(f,e+1)&&!I(f,-t.yearlen+e)||e>=t.yearlen&&!I(f,e+1-t.yearlen)&&!I(f,-t.nextyearlen+e-t.yearlen))}function Wt(t,e){return new et(t,e.tzid).rezonedDate()}function me(t){return t.getValue()}function ta(t,e,r,n,s){for(var a=!1,c=e;c<r;c++){var i=t[c];a=ea(n,i,s),a&&(t[i]=null)}return a}function ra(t,e,r){var n=r.freq,s=r.byhour,a=r.byminute,c=r.bysecond;return wt(n)?Mn(r):n>=C.HOURLY&&$(s)&&!I(s,e.hour)||n>=C.MINUTELY&&$(a)&&!I(a,e.minute)||n>=C.SECONDLY&&$(c)&&!I(c,e.second)?[]:t.gettimeset(n)(e.hour,e.minute,e.second,e.millisecond)}var re={MO:new z(0),TU:new z(1),WE:new z(2),TH:new z(3),FR:new z(4),SA:new z(5),SU:new z(6)},xt={freq:j.YEARLY,dtstart:null,interval:1,wkst:re.MO,count:null,until:null,tzid:null,bysetpos:null,bymonth:null,bymonthday:null,bynmonthday:null,byyearday:null,byweekno:null,byweekday:null,bynweekday:null,byhour:null,byminute:null,bysecond:null,byeaster:null},na=Object.keys(xt),C=(function(){function t(e,r){e===void 0&&(e={}),r===void 0&&(r=!1),this._cache=r?null:new In,this.origOptions=yr(e);var n=Sn(e).parsedOptions;this.options=n}return t.parseText=function(e,r){return dr(e,r)},t.fromText=function(e,r){return Tn(e,r)},t.fromString=function(e){return new t(t.parseString(e)||void 0)},t.prototype._iter=function(e){return mr(e,this.options)},t.prototype._cacheGet=function(e,r){return this._cache?this._cache._cacheGet(e,r):!1},t.prototype._cacheAdd=function(e,r,n){if(this._cache)return this._cache._cacheAdd(e,r,n)},t.prototype.all=function(e){if(e)return this._iter(new It("all",{},e));var r=this._cacheGet("all");return r===!1&&(r=this._iter(new Re("all",{})),this._cacheAdd("all",r)),r},t.prototype.between=function(e,r,n,s){if(n===void 0&&(n=!1),!qe(e)||!qe(r))throw new Error("Invalid date passed in to RRule.between");var a={before:r,after:e,inc:n};if(s)return this._iter(new It("between",a,s));var c=this._cacheGet("between",a);return c===!1&&(c=this._iter(new Re("between",a)),this._cacheAdd("between",c,a)),c},t.prototype.before=function(e,r){if(r===void 0&&(r=!1),!qe(e))throw new Error("Invalid date passed in to RRule.before");var n={dt:e,inc:r},s=this._cacheGet("before",n);return s===!1&&(s=this._iter(new Re("before",n)),this._cacheAdd("before",s,n)),s},t.prototype.after=function(e,r){if(r===void 0&&(r=!1),!qe(e))throw new Error("Invalid date passed in to RRule.after");var n={dt:e,inc:r},s=this._cacheGet("after",n);return s===!1&&(s=this._iter(new Re("after",n)),this._cacheAdd("after",s,n)),s},t.prototype.count=function(){return this.all().length},t.prototype.toString=function(){return ht(this.origOptions)},t.prototype.toText=function(e,r,n){return Cn(this,e,r,n)},t.prototype.isFullyConvertibleToText=function(){return En(this)},t.prototype.clone=function(){return new t(this.origOptions)},t.FREQUENCIES=["YEARLY","MONTHLY","WEEKLY","DAILY","HOURLY","MINUTELY","SECONDLY"],t.YEARLY=j.YEARLY,t.MONTHLY=j.MONTHLY,t.WEEKLY=j.WEEKLY,t.DAILY=j.DAILY,t.HOURLY=j.HOURLY,t.MINUTELY=j.MINUTELY,t.SECONDLY=j.SECONDLY,t.MO=re.MO,t.TU=re.TU,t.WE=re.WE,t.TH=re.TH,t.FR=re.FR,t.SA=re.SA,t.SU=re.SU,t.parseString=ft,t.optionsToString=ht,t})();function aa(t,e,r,n,s,a){var c={},i=t.accept;function o(d,h){r.forEach(function(k){k.between(d,h,!0).forEach(function(v){c[Number(v)]=!0})})}s.forEach(function(d){var h=new et(d,a).rezonedDate();c[Number(h)]=!0}),t.accept=function(d){var h=Number(d);return isNaN(h)?i.call(this,d):!c[h]&&(o(new Date(h-1),new Date(h+1)),!c[h])?(c[h]=!0,i.call(this,d)):!0},t.method==="between"&&(o(t.args.after,t.args.before),t.accept=function(d){var h=Number(d);return c[h]?!0:(c[h]=!0,i.call(this,d))});for(var f=0;f<n.length;f++){var m=new et(n[f],a).rezonedDate();if(!t.accept(new Date(m.getTime())))break}e.forEach(function(d){mr(t,d.options)});var y=t._result;switch(Fe(y),t.method){case"all":case"between":return y;case"before":return y.length&&y[y.length-1]||null;case"after":default:return y.length&&y[0]||null}}var $t={dtstart:null,cache:!1,unfold:!1,forceset:!1,compatible:!1,tzid:null};function sa(t,e){var r=[],n=[],s=[],a=[],c=Je(t),i=c.dtstart,o=c.tzid,f=ua(t,e.unfold);return f.forEach(function(m){var y;if(m){var d=ca(m),h=d.name,k=d.parms,v=d.value;switch(h.toUpperCase()){case"RRULE":if(k.length)throw new Error("unsupported RRULE parm: ".concat(k.join(",")));r.push(ft(m));break;case"RDATE":var w=(y=/RDATE(?:;TZID=([^:=]+))?/i.exec(m))!==null&&y!==void 0?y:[],p=w[1];
3p&&!o&&(o=p),n=n.concat(Ft(v,k));break;case"EXRULE":if(k.length)throw new Error("unsupported EXRULE parm: ".concat(k.join(",")));s.push(ft(v));break;case"EXDATE":a=a.concat(Ft(v,k));break;case"DTSTART":break;default:throw new Error("unsupported property: "+h)}}}),{dtstart:i,tzid:o,rrulevals:r,rdatevals:n,exrulevals:s,exdatevals:a}}function ia(t,e){var r=sa(t,e),n=r.rrulevals,s=r.rdatevals,a=r.exrulevals,c=r.exdatevals,i=r.dtstart,o=r.tzid,f=e.cache===!1;if(e.compatible&&(e.forceset=!0,e.unfold=!0),e.forceset||n.length>1||s.length||a.length||c.length){var m=new ya(f);return m.dtstart(i),m.tzid(o||void 0),n.forEach(function(d){m.rrule(new C(ct(d,i,o),f))}),s.forEach(function(d){m.rdate(d)}),a.forEach(function(d){m.exrule(new C(ct(d,i,o),f))}),c.forEach(function(d){m.exdate(d)}),e.compatible&&e.dtstart&&m.rdate(i),m}var y=n[0]||{};return new C(ct(y,y.dtstart||e.dtstart||i,y.tzid||e.tzid||o),f)}function tt(t,e){return e===void 0&&(e={}),ia(t,oa(e))}function ct(t,e,r){return ne(ne({},t),{dtstart:e,tzid:r})}function oa(t){var e=[],r=Object.keys(t),n=Object.keys($t);if(r.forEach(function(s){I(n,s)||e.push(s)}),e.length)throw new Error("Invalid options: "+e.join(", "));return ne(ne({},$t),t)}function la(t){if(t.indexOf(":")===-1)return{name:"RRULE",value:t};var e=hn(t,":",1),r=e[0],n=e[1];return{name:r,value:n}}function ca(t){var e=la(t),r=e.name,n=e.value,s=r.split(";");if(!s)throw new Error("empty property name");return{name:s[0].toUpperCase(),parms:s.slice(1),value:n}}function ua(t,e){if(e===void 0&&(e=!1),t=t&&t.trim(),!t)throw new Error("Invalid empty string");if(!e)return t.split(/\s/);for(var r=t.split(`
4`),n=0;n<r.length;){var s=r[n]=r[n].replace(/\s+$/g,"");s?n>0&&s[0]===" "?(r[n-1]+=s.slice(1),r.splice(n,1)):n+=1:r.splice(n,1)}return r}function da(t){t.forEach(function(e){if(!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(e))throw new Error("unsupported RDATE/EXDATE parm: "+e)})}function Ft(t,e){return da(e),t.split(",").map(function(r){return gt(r)})}function Pt(t){var e=this;return function(r){if(r!==void 0&&(e["_".concat(t)]=r),e["_".concat(t)]!==void 0)return e["_".concat(t)];for(var n=0;n<e._rrule.length;n++){var s=e._rrule[n].origOptions[t];if(s)return s}}}var ya=(function(t){pt(e,t);function e(r){r===void 0&&(r=!1);var n=t.call(this,{},r)||this;return n.dtstart=Pt.apply(n,["dtstart"]),n.tzid=Pt.apply(n,["tzid"]),n._rrule=[],n._rdate=[],n._exrule=[],n._exdate=[],n}return e.prototype._iter=function(r){return aa(r,this._rrule,this._exrule,this._rdate,this._exdate,this.tzid())},e.prototype.rrule=function(r){Ht(r,this._rrule)},e.prototype.exrule=function(r){Ht(r,this._exrule)},e.prototype.rdate=function(r){zt(r,this._rdate)},e.prototype.exdate=function(r){zt(r,this._exdate)},e.prototype.rrules=function(){return this._rrule.map(function(r){return tt(r.toString())})},e.prototype.exrules=function(){return this._exrule.map(function(r){return tt(r.toString())})},e.prototype.rdates=function(){return this._rdate.map(function(r){return new Date(r.getTime())})},e.prototype.exdates=function(){return this._exdate.map(function(r){return new Date(r.getTime())})},e.prototype.valueOf=function(){var r=[];return!this._rrule.length&&this._dtstart&&(r=r.concat(ht({dtstart:this._dtstart}))),this._rrule.forEach(function(n){r=r.concat(n.toString().split(`
5`))}),this._exrule.forEach(function(n){r=r.concat(n.toString().split(`
6`).map(function(s){return s.replace(/^RRULE:/,"EXRULE:")}).filter(function(s){return!/^DTSTART/.test(s)}))}),this._rdate.length&&r.push(Kt("RDATE",this._rdate,this.tzid())),this._exdate.length&&r.push(Kt("EXDATE",this._exdate,this.tzid())),r},e.prototype.toString=function(){return this.valueOf().join(`
7`)},e.prototype.clone=function(){var r=new e(!!this._cache);return this._rrule.forEach(function(n){return r.rrule(n.clone())}),this._exrule.forEach(function(n){return r.exrule(n.clone())}),this._rdate.forEach(function(n){return r.rdate(new Date(n.getTime()))}),this._exdate.forEach(function(n){return r.exdate(new Date(n.getTime()))}),r},e})(C);function Ht(t,e){if(!(t instanceof C))throw new TypeError(String(t)+" is not RRule instance");I(e.map(String),String(t))||e.push(t)}function zt(t,e){if(!(t instanceof Date))throw new TypeError(String(t)+" is not Date instance");I(e.map(Number),Number(t))||(e.push(t),Fe(e))}function Kt(t,e,r){var n=!r||r.toUpperCase()==="UTC",s=n?"".concat(t,":"):"".concat(t,";TZID=").concat(r,":"),a=e.map(function(c){return vt(c.valueOf(),n)}).join(",");return"".concat(s).concat(a)}const ma={all:t=>["amenityCalendar",t],events:(t,e)=>["amenityCalendar",t,"events",e]},fa=({associationId:t,query:e,isPublic:r})=>{const n={...e,associationId:t};return Pe({queryKey:ma.events(t,n),queryFn:async()=>r?(await Mt.getPublicAmenityResourcesCalendarEvents(n)).items:Mt.getAmenityResourcesCalendarEvents(n),enabled:!!t})},ha="#6366f1",rt=t=>{const e=t instanceof Date?t:new Date(t),r=e.getTimezoneOffset()*6e4;return new Date(e.getTime()+r)},Ge=(t,e,r)=>({id:t.taskId,title:t.title||t.reservationTitle||"Reserved",start:e??rt(t.start),end:r??rt(t.end
7),color:t.displayColor??ha,isAllDay:t.isAllDay,categoryId:t.amenityCategoryId,description:t.description,recurrenceRule:t.recurrenceRule,recurrenceId:t.recurrenceId,recurrenceException:t.recurrenceException}),pa=t=>t?t.split(",").map(e=>{const r=e.trim();if(r.includes("T")){const c=parseInt(r.substring(0,4)),i=parseInt(r.substring(4,6))-1,o=parseInt(r.substring(6,8)),f=parseInt(r.substring(9,11)),m=parseInt(r.substring(11,13)),y=parseInt(r.substring(13,15));return new Date(c,i,o,f,m,y)}const n=parseInt(r.substring(0,4)),s=parseInt(r.substring(4,6))-1,a=parseInt(r.substring(6,8));return new Date(n,s,a)}):[],ba=(t,e)=>e.some(r=>t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()),va=(t,e,r)=>{const n=[],s=t.filter(i=>i.recurrenceRule&&!i.recurrenceId),a=t.filter(i=>i.recurrenceId!==null&&i.recurrenceId!==void 0),c=t.filter(i=>!i.recurrenceRule&&!i.recurrenceId);for(const i of c)n.push(Ge(i));for(const i of a)n.push(Ge(i));for(const i of s)try{const o=rt(i.start),m=rt(i.end).getTime()-o.getTime(),y=i.recurrenceRule.replace(/UNTIL=(\d{8})(?!T)/,"UNTIL=$1T235959"),h=tt(y,{dtstart:o}).between(e,r,!0),k=pa(i.recurrenceException??null);for(const v of h){if(ba(v,k))continue;const w=new Date(v.getTime()+m);n.push(Ge(i,v,w))}}catch{n.push(Ge(i))}return n};function ga({associationId:t,currentYear:e,currentMonth:r,isPublic:n,selectedCategory:s,selectedAmenityId:a}){const c=x.useMemo(()=>{const w=new Date(e,r,1),p=new Date(e,r+1,0,23,59,59),S=new Date(w);S.setDate(S.getDate()-7);const E=new Date(p);return E.setDate(E.getDate()+7),{startFrom:S,endTo:E}},[e,r]),{data:i,isLoading:o,error:f}=fa({associationId:t,isPublic:n}),{data:m=[],isLoading:y}=Qr(t),d=x.useMemo(()=>[...new Set(m.map(p=>p.category))].sort().map(p=>({name:p})),[m]),h=x.useMemo(()=>s?m.filter(w=>w.category===s).map(w=>({id:w.id,name:w.name,category:w.category})).sort((w,p)=>w.name.localeCompare(p.name)):[],[m,s]),k=x.useMemo(()=>{if(!i)return[];let w=i;return s&&(w=w.filter(p=>p.amenityCategoryName===s)),a&&(w=w.filter(p=>p.amenityId===a)),w},[i,s,a]);return{displayEvents:x.useMemo(()=>k.length===0?[]:va(k,c.startFrom,c.endTo),[k,c.startFrom,c.endTo]),isLoading:o||y,error:f,categories:d,filteredAmenities:h}}const wa=t=>!!(t.recurrenceRule||t.recurrenceId),xa=t=>!!t.recurrenceId,fr=t=>{const e=t.replace("#","");return{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16)}},ka=(t,e)=>{const{r,g:n,b:s}=fr(t),a=1-e;return`rgb(${Math.round(r*a)}, ${Math.round(n*a)}, ${Math.round(s*a)})`},kt=t=>{const{r:e,g:r,b:n}=fr(t);return{bg:`rgba(${e}, ${r}, ${n}, 0.15)`,text:ka(t,.4),border:`rgba(${e}, ${r}, ${n}, 0.4)`,dot:t}},Da=(t,e)=>yn({start:new Date(t.start),end:new Date(t.end)},{start:on(e),end:un(e)},{}),Ta=({currentDate:t,events:e,onDoubleClick:r,onEventClick:n,readOnly:s=!1})=>{const{t:a}=Ae(),c=a("main.calendar.weekdays.full",{returnObjects:!0}),i=a("main.months",{returnObjects:!0}),o=x.useMemo(()=>{const y=tr(t);return Array.from({length:7},(d,h)=>an(y,h))},[t]),f=y=>e.filter(d=>Da(d,y)).sort((d,h)=>d.isAllDay&&!h.isAllDay?-1:!d.isAllDay&&h.isAllDay?1:new Date(d.start).getTime()-new Date(h.start).getTime()),m=y=>y.isAllDay?a("main.calendar.allDay"):`${Qe(y.start,"h:mm a")} - ${Qe(y.end,"h:mm a")}`;return u.jsx("div",{className:"rounded-lg overflow-hidden border border-base-border bg-white",children:u.jsx("div",{className:"divide-y divide-base-border",children:o.map((y,d)=>{var v;const h=f(y),k=mn(y);return u.jsxs("div",{className:F("flex gap-4 p-4 bg-white transition-colors",!s&&"cursor-pointer hover:bg-base-hover/30"),onDoubleClick:s?void 0:()=>r(y),children:[u.jsxs("div",{className:"flex-shrink-0 w-16 text-center",children:[u.jsx("div",{className:F("text-3xl font-bold",k?"text-primary":"text-base-fg"),children:String(y.getDate()).padStart(2,"0")}),u.jsx("div",{className:"text-sm text-base-fg/60",children:c[y.getDay()]}),u.jsxs("div",{className:"text-xs text-base-fg/40",children:[(v=i[y.getMonth()])==null?void 0:v.substring(0,3),"."," ",y.getFullYear()]})]}),u.jsx("div",{className:"flex-1 min-w-0",children:h.length>0?u.jsx("div",{className:"space-y-2",children:h.map(w=>{var S;const p=kt(w.color);return u.jsxs("div",{className:F("group min-w-0",!s&&"cursor-pointer"),onClick:s?void 0:E=>{E.stopPropagation(),n(w)},onDoubleClick:s?void 0:E=>{E.stopPropagation(),n(w)},children:[u.jsx("span",{className:F("block rounded px-3 py-1.5 text-sm font-medium truncate",!s&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:p.bg,color:p.text,borderLeft:`3px solid ${p.dot}`},children:w.title}),u.jsxs("div",{className:"text-xs text-base-fg/60 mt-0.5 pl-1 space-y-0.5",children:[u.jsx("div",{children:m(w)}),((S=w.description)==null?void 0:S.trim())&&u.jsx("div",{className:"whitespace-pre-wrap",children:w.description.trim()})]})]},w.id)})}):u.jsx("div",{className:"text-sm text-base-fg/40 py-2",children:a("main.calendar.noEvents")})})]},d)})})})},Ca=({isOpen:t,onClose:e,onEditOccurrence:r,onEditSeries:n})=>{const{t:s}=Ae();return u.jsx(er,{open:t,dataQa:"edit-recurring-event-modal",onClose:e,title:s("main.calendar.editRecurringEvent"),actions:[],children:u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx("p",{className:"text-sm text-base-fg",children:s("main.calendar.editRecurringPrompt")}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(_e,{variant:"passive",onClick:r,"data-qa":"edit-recurring-occurrence",className:"flex-1 text-sm",children:s("main.calendar.editCurrentOccurrence")}),u.jsx(_e,{variant:"passive",onClick:n,"data-qa":"edit-recurring-series",className:"flex-1 text-sm",children:s("main.calendar.editTheSeries")})]})]})})},ce={all:t=>["communityCalendar",t],list:(t,e)=>["communityCalendar",t,"list",e],detail:(t,e)=>["communityCalendar",t,"detail",e],categories:t=>["communityCalendar",t,"categories"],category:(t,e)=>["communityCalendar",t,"category",e],permissions:t=>["communityCalendar",t,"permissions"]},Ea=({associationId:t,query:e,isPublic:r})=>{const n=r?rr:le;return Pe({queryKey:ce.list(t,e),queryFn:()=>n.getCommunityCalendarEvents(t,e),enabled:t!==0})},Na=({associationId:t,eventId:e})=>Pe({queryKey:ce.detail(t,e),queryFn:()=>le.getCommunityCalendarEvent(t,e),enabled:t!==0&&e!==0}),Sa=({associationId:t,isPublic:e})=>{const r=e?rr:le;return Pe({queryKey:ce.categories(t),queryFn:()=>r.getEventCategories(t),enabled:t!==0})},Ma=({associationId:t,enabled:e=!0})=>Pe({queryKey:ce.permissions(t),queryFn:()=>le.getCommunityCalendarPermissions(t),enabled:t!==0&&e}),Ra=({associationId:t})=>{const e=nt();return bt({mutationFn:r=>le.createCommunityCalendarEvent(t,r),onSuccess:()=>
7{e.invalidateQueries({queryKey:ce.all(t)})}})},_a=({associationId:t,eventId:e})=>{const r=nt();return bt({mutationFn:n=>le.updateCommunityCalendarEvent(t,e,n),onSuccess:()=>{r.invalidateQueries({queryKey:ce.all(t)})}})},ja=({associationId:t})=>{const e=nt();return bt({mutationFn:r=>le.deleteCommunityCalendarEvent(t,r),onSuccess:()=>{e.invalidateQueries({queryKey:ce.all(t)})}})};function hr(t){return`cal-${t.replace("#","")}`}function Bt(t){return Temporal.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds()}).toZonedDateTime("UTC")}function $e(t){return Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()})}function Gt(t){return t instanceof Temporal.PlainDate?new Date(t.year,t.month-1,t.day):new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second)}const pr=30;function Zt(t){return t.getHours()!==0||t.getMinutes()!==0||t.getSeconds()!==0||t.getMilliseconds()!==0}function Aa(t,e=pr){const r=new Date(t),n=r.getHours()*60+r.getMinutes(),s=Math.floor(n/e)*e;return r.setHours(Math.floor(s/60),s%60,0,0),r}function Qt(t,e=pr){const r=Aa(t,e),n=new Date(r);return n.setMinutes(n.getMinutes()+e),{start:r,end:n}}function Xt(t){const e=new Date(t);e.setHours(12,0,0,0);const r=new Date(t);return r.setHours(13,0,0,0),{start:e,end:r}}function Oa(t){const e=new Map,r=[];for(const n of t){const s=`${n.id}-${n.start.getTime()}`;e.set(s,n);const a=wa(n),c=xa(n),i={id:s,sourceEventId:n.id,title:n.title,calendarId:hr(n.color),isRecurring:a,isEditedOccurrence:c,eventColor:n.color};n.isAllDay?r.push({...i,start:$e(n.start),end:$e(n.end)}):r.push({...i,start:Bt(n.start),end:Bt(n.end)})}return{scheduleXEvents:r,eventLookup:e}}function Ia(t){const e={},r=new Set;for(const n of t){if(r.has(n.color))continue;r.add(n.color);const s=hr(n.color),a=kt(n.color);e[s]={colorName:n.color.replace("#",""),lightColors:{main:n.color,container:a.bg,onContainer:a.text}}}return e}const La="#f8a398",Vt=t=>u.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[t.color?u.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full border border-black/10",style:{backgroundColor:t.color},"aria-hidden":!0}):null,u.jsx("span",{className:"truncate",children:t.description})]}),xe=["SU","MO","TU","WE","TH","FR","SA"],Ya=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Ua=[{value:"1",key:"ordinalFirst"},{value:"2",key:"ordinalSecond"},{value:"3",key:"ordinalThird"},{value:"4",key:"ordinalFourth"},{value:"-1",key:"ordinalLast"}],qa=(t,e)=>{const r={frequency:"never",interval:1,weekDays:[xe[e.getDay()]],monthlyRepeatType:"date",monthlyDate:e.getDate(),monthlyOrdinal:"1",monthlyWeekday:xe[e.getDay()],yearlyRepeatType:"date",yearlyMonth:e.getMonth(),yearlyDate:e.getDate(),yearlyOrdinal:"1",yearlyWeekday:xe[e.getDay()],endType:"never",endCount:1,endDate:null};if(!t)return r;const n=t.split(";").reduce((a,c)=>{const[i,o]=c.split("=");return i&&o&&(a[i]=o),a},{}),s={...r};
7if(n.FREQ&&(s.frequency=n.FREQ.toLowerCase()),n.INTERVAL&&(s.interval=parseInt(n.INTERVAL,10)||1),n.BYDAY&&s.frequency==="weekly"&&(s.weekDays=n.BYDAY.split(",")),n.BYDAY&&(s.frequency==="monthly"||s.frequency==="yearly")){const a=n.BYDAY.match(/^(-?\d)?(SU|MO|TU|WE|TH|FR|SA)$/);if(a){const c=a[1]||"1",i=a[2];s.frequency==="monthly"?(s.monthlyRepeatType="ordinal",s.monthlyOrdinal=c,s.monthlyWeekday=i):(s.yearlyRepeatType="ordinal",s.yearlyOrdinal=c,s.yearlyWeekday=i)}}if(n.BYMONTHDAY){const a=parseInt(n.BYMONTHDAY,10);s.frequency==="monthly"?(s.monthlyRepeatType="date",s.monthlyDate=a):s.frequency==="yearly"&&(s.yearlyRepeatType="date",s.yearlyDate=a)}if(n.BYMONTH&&(s.yearlyMonth=parseInt(n.BYMONTH,10)-1),n.COUNT&&(s.endType="after",s.endCount=parseInt(n.COUNT,10)||1),n.UNTIL){s.endType="on";const a=n.UNTIL,c=parseInt(a.substring(0,4),10),i=parseInt(a.substring(4,6),10)-1,o=parseInt(a.substring(6,8),10);s.endDate=new Date(c,i,o)}return s},Wa=t=>{if(t.frequency==="never")return"";const e=[`FREQ=${t.frequency.toUpperCase()}`];if(t.interval>1&&e.push(`INTERVAL=${t.interval}`),t.frequency==="weekly"&&t.weekDays.length>0&&e.push(`BYDAY=${t.weekDays.join(",")}`),t.frequency==="monthly"&&(t.monthlyRepeatType==="date"?e.push(`BYMONTHDAY=${t.monthlyDate}`):e.push(`BYDAY=${t.monthlyOrdinal}${t.monthlyWeekday}`)),t.frequency==="yearly"&&(e.push(`BYMONTH=${t.yearlyMonth+1}`),t.yearlyRepeatType==="date"?e.push(`BYMONTHDAY=${t.yearlyDate}`):e.push(`BYDAY=${t.yearlyOrdinal}${t.yearlyWeekday}`)),t.endType==="after")e.push(`COUNT=${t.endCount}`);else if(t.endType==="on"&&t.endDate){const r=Qe(t.endDate,"yyyyMMdd'T'235959");e.push(`UNTIL=${r}`)}return e.join(";")},$a=({isOpen:t,onClose:e,initialDate:r,associationId:n,categories:s,editEvent:a,editMode:c,readOnly:i=!1})=>{const{t:o}=Ae(),f=nt(),m=o("main.months",{returnObjects:!0}),y=!!a,d=c==="series"?(a==null?void 0:a.recurrenceId)??(a==null?void 0:a.id)??0:0,{data:h}=Na({associationId:n,eventId:d}),k=x.useMemo(()=>h?typeof h=="object"&&"member"in h?h.member??null:h:null,[h]),v=x.useMemo(()=>a?c==="series"&&k?{...a,id:k.id,title:k.title,start:new Date(k.start),end:new Date(k.end),isAllDay:k.isAllDay,categoryId:k.eventCategoryId,description:k.description,recurrenceRule:k.recurrenceRule,recurrenceId:k.recurrenceId,recurrenceException:k.recurrenceException,securityLevel:k.securityLevel}:a:null,[a,c,k]),w=x.useMemo(()=>["never","daily","weekly","monthly","yearly"].map(l=>({value:l,display:o(`main.calendar.recurrence.${l}`)})),[o]),p=x.useMemo(()=>Ua.map(l=>({value:l.value,display:o(`main.calendar.recurrence.${l.key}`)})),[o]),S=x.useMemo(()=>xe.map((l,N)=>({value:l,display:o(`main.calendar.recurrence.weekdaysFull.${Ya[N]}`)})),[o]),E=x.useMemo(()=>m.map((l,N)=>({value:N,display:l})),[m]),M=x.useMemo(()=>["public","homeowner","board","internal"].map(l=>({value:l,display:o(`main.calendar.securityLevels.${l}`)})),[o]),K=Ra({associationId:n}),U=_a({associationId:n,eventId:c==="series"?(a==null?void 0:a.recurrenceId)??(a==null?void 0:a.id)??0:(a==null?void 0:a.id)??0}),L=ja({associationId:n}),[ve,ge]=x.useState(!1),de=x.useCallback(()=>{if(v)return new Date(v.start);if(r){const N=new Date(r);return Zt(N)?Qt(N).start:Xt(N).start}const l=new Date;return l.setHours(12,0,0,0),l},[v,r]),De=x.useCallback(()=>{if(v)return new Date(v.end);if(r){const N=new Date(r);return Zt(N)?Qt(N).end:Xt(N).end}const l=new Date;return l.setHours(13,0,0,0),l},[v,r]),ae=x.useCallback(()=>{const l=de();return v!=null&&v.recurrenceRule?qa(v.recurrenceRule,l):{frequency:"never",interval:1,weekDays:[xe[l.getDay()]],monthlyRepeatType:"date",monthlyDate:l.getDate(),monthlyOrdinal:"1",monthlyWeekday:xe[l.getDay()],yearlyRepeatType:"date",yearlyMonth:l.getMonth(),yearlyDate:l.getDate(),yearlyOrdinal:"1",yearlyWeekday:xe[l.getDay()],endType:"never",endCount:1,endDate:null}},[v==null?void 0:v.recurrenceRule,de]),Te=x.useCallback(()=>v?{title:v.title,start:de(),end:De(),isAllDay:v.isAllDay,description:v.description||"",categoryId:v.categoryId??null,securityLevel:v.securityLevel||"homeowner"}:{title:"",start:de(),end:De(),isAllDay:!1,description:"",categoryId:null,
7securityLevel:"homeowner"},[v,de,De]),[T,Ie]=x.useState(Te()),[D,ee]=x.useState(ae());x.useEffect(()=>{t&&(Ie(Te()),ee(ae()),ge(!1))},[v==null?void 0:v.id,t,Te,ae]);const He=x.useMemo(()=>[{id:null,description:o("main.calendar.none")},...s.map(l=>({id:l.id,description:l.description||`Category ${l.id}`,color:l.color??La}))],[s,o]),X=()=>{Ie(Te()),ee(ae()),ge(!1),e()},Ce=!!(a!=null&&a.recurrenceRule||a!=null&&a.recurrenceId),he=c==="series",Ee=c==="occurrence"&&Ce,Ne=async()=>{if(a)try{if(he){const l=a.recurrenceId??a.id;await le.deleteCommunityCalendarEvent(n,l),await f.invalidateQueries({queryKey:ce.all(n),predicate:N=>!(N.queryKey[2]==="detail"&&N.queryKey[3]===l)})}else if(Ee){const l=!!a.recurrenceId,N=a.recurrenceId??a.id,Y=Qe(a.start,"yyyyMMdd'T'HHmmss"),V=a.recurrenceException||"",it=V?`${V},${Y}`:Y;await le.updateCommunityCalendarEvent(n,N,{recurrenceException:it}),l&&await L.mutateAsync(a.id),await f.invalidateQueries({queryKey:ce.all(n)})}else await L.mutateAsync(a.id);Ue({type:"success",message:o("main.calendar.eventDeleted")}),X()}catch(l){console.error("Failed to delete event:",l),Ue({type:"error",message:o("main.calendar.eventDeleteFailed")})}},at=async()=>{try{const l=Wa(D)||void 0;if(y&&a){const N=a.recurrenceRule&&!a.recurrenceId,Y=!!a.recurrenceId;if(c==="occurrence"&&N)await K.mutateAsync({title:T.title,description:T.description||void 0,start:T.start,end:T.end,isAllDay:T.isAllDay,eventCategoryId:T.categoryId??void 0,securityLevel:T.securityLevel,recurrenceId:a.id,originalStart:a.start});else if(c==="occurrence"&&Y)await U.mutateAsync({title:T.title,description:T.description||void 0,start:T.start,end:T.end,isAllDay:T.isAllDay,eventCategoryId:T.categoryId??void 0,securityLevel:T.securityLevel});else if(c==="series"){const V=a.recurrenceId??a.id;await le.updateCommunityCalendarEvent(n,V,{title:T.title,description:T.description||void 0,start:T.start,end:T.end,isAllDay:T.isAllDay,eventCategoryId:T.categoryId??void 0,securityLevel:T.securityLevel,recurrenceRule:l??"",recurrenceException:""}),await f.invalidateQueries({queryKey:ce.all(n)})}else{const V=!Ce&&!l;await U.mutateAsync({title:T.title,description:T.description||void 0,start:T.start,end:T.end,isAllDay:T.isAllDay,eventCategoryId:T.categoryId??void 0,securityLevel:T.securityLevel,recurrenceRule:Ce?void 0:l??"",recurrenceException:V?"":void 0})}Ue({type:"success",message:o("main.calendar.eventUpdated")})}else await K.mutateAsync({title:T.title,description:T.description||void 0,start:T.start,end:T.end,isAllDay:T.isAllDay,eventCategoryId:T.categoryId??void 0,securityLevel:T.securityLevel,recurrenceRule:l}),Ue({type:"success",message:o("main.calendar.eventCreated")});X()}catch(l){console.error("Failed to save event:",l),Ue({type:"error",message:o("main.calendar.eventSaveFailed")})}},B=(l,N)=>{Ie(Y=>({...Y,[l]:N}))},O=(l,N)=>{ee(Y=>({...Y,[l]:N}))},Se=l=>{ee(N=>{const Y=N.weekDays.includes(l)?N.weekDays.filter(V=>V!==l):[...N.weekDays,l];return{...N,weekDays:Y}})},ze=K.isPending||U.isPending||L.isPending,Le=o(ve?he?"main.calendar.deleteSeriesConfirmTitle":"main.calendar.deleteConfirmTitle":i?"main.calendar.viewEvent":y?"main.calendar.editEvent":"main.calendar.createEvent"),Ke=o(ze?"main.common.saving":y?"main.calendar.updateEvent":"main.calendar.saveEvent"),st=ve?[]:i?[{text:o("main.common.close"),onClick:async()=>X(),variant:"passive"}]:[{text:Ke,onClick:async()=>at(),variant:"primary",disabled:!T.title.trim()||ze},{text:o("main.common.cancel"),onClick:async()=>X(),variant:"passive"}];return u.jsx(er,{open:t,dataQa:"event-modal",onClose:X,title:Le,actions:st,children:ve?u.jsxs("div",{className:"flex flex-col gap-6",children:[u.jsx("p",{className:"text-sm text-base-fg",children:o(he?"main.calendar.deleteSeriesConfirmMessage":"main.calendar.deleteConfirmMessage")}),u.jsxs("div",{className:"flex gap-3 justify-end",children:[u.jsx(_e,{variant:"passive",onClick:()=>ge(!1),"data-qa":"event-delete-cancel",disabled:L.isPending,children:o("main.common.cancel")}),u.jsx(_e,{variant:"danger",onClick:Ne,"data-qa":"event-delete-confirm",disabled:L.isPending,children:L.isPending?o("main.calendar.deleting"):o("main.calendar.deleteEvent")})]})]}):u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx(Ye,{type:"text",label:o("main.calendar.eventTitle"),placeholder:o("main.calendar.eventTitlePlaceholder"),value:T.title,onChange:l=>B("title",l.target.value),disabled:i}),u.jsx(ot,{id:"event-start-date","data-qa":"event-start-date",label:o("main.calendar.start"),value:T.start,onCh
7ange:l=>l&&B("start",l),showTimePicker:!T.isAllDay,popupContainer:"body",className:"w-full",disabled:i}),u.jsx(ot,{id:"event-end-date","data-qa":"event-end-date",label:o("main.calendar.end"),value:T.end,onChange:l=>l&&B("end",l),minDate:T.start,showTimePicker:!T.isAllDay,popupContainer:"body",className:"w-full",disabled:i}),u.jsx(Rr,{id:"all-day-toggle","data-qa":"event-all-day-toggle",label:o("main.calendar.allDayEvent"),value:T.isAllDay,onChange:()=>B("isAllDay",!T.isAllDay),className:"flex-row-reverse justify-between",disabled:i}),(!y||c==="series"||!Ce)&&u.jsxs(u.Fragment,{children:[u.jsx(_r,{label:o("main.calendar.repeat"),options:w,value:w.find(l=>l.value===D.frequency),deriveKey:l=>l.value,displayOption:l=>l.display,onChange:l=>O("frequency",l.value),buttonClassName:"!min-h-0 !py-2 !px-3",className:F(i&&"pointer-events-none opacity-50")}),D.frequency!=="never"&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm font-medium text-base-fg whitespace-nowrap",children:o("main.calendar.recurrence.repeatEvery")}),u.jsx(Ye,{type:"text",inputMode:"numeric",value:D.interval||"",onChange:l=>O("interval",parseInt(l.target.value,10)||0),onBlur:()=>O("interval",Math.max(1,D.interval)),disabled:i,className:"w-20"}),u.jsxs("span",{className:"text-sm text-base-fg",children:[D.frequency==="daily"&&o("main.calendar.recurrence.days"),D.frequency==="weekly"&&o("main.calendar.recurrence.weeks"),D.frequency==="monthly"&&o("main.calendar.recurrence.months"),D.frequency==="yearly"&&o("main.calendar.recurrence.years")]})]}),D.frequency==="weekly"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-base-fg mb-2",children:o("main.calendar.recurrence.repeatOn")}),u.jsx("div",{className:"flex gap-1",children:S.map(l=>u.jsx("button",{"data-qa":`event-weekday-${l.value}`,type:"button",onClick:()=>Se(l.value),disabled:i,className:F("flex-1 px-2 py-2 text-sm font-medium rounded-lg border transition-colors",D.weekDays.includes(l.value)?"bg-primary text-white border-primary":"bg-base-fill text-base-fg border-base-border hover:bg-base-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:l.display.substring(0,3)},l.value))})]}),D.frequency==="monthly"&&u.jsxs("div",{children:[u.jsx("span",{className:"block text-sm font-medium text-base-fg mb-2",children:o("main.calendar.recurrence.repeatOn")}),u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>!i&&O("monthlyRepeatType","date"),children:[u.jsx("span",{className:F("h-4 w-4 rounded-full flex items-center justify-center border",D.monthlyRepeatType==="date"?"bg-primary border-primary":"border-base-border bg-white"),children:D.monthlyRepeatType==="date"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx("span",{className:"text-sm text-base-fg",children:o("main.calendar.recurrence.date")}),u.jsx(Ye,{type:"text",inputMode:"numeric",value:D.monthlyDate||"",onChange:l=>O("monthlyDate",Math.min(31,parseInt(l.target.value,10)||0)),onBlur:()=>O("monthlyDate",Math.min(31,Math.max(1,D.monthlyDate))),disabled:i||D.monthlyRepeatType!=="date",className:"w-20"})]}),u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-wrap",onClick:()=>!i&&O("monthlyRepeatType","ordinal"),children:[u.jsx("span",{className:F("h-4 w-4 rounded-full flex items-center justify-center border",D.monthlyRepeatType==="ordinal"?"bg-primary border-primary":"border-base-border bg-white"),children:D.monthlyRepeatType==="ordinal"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx(se,{label:"",options:p,deriveKey:l=>l.value,displaySelected:()=>{var l;return((l=p.find(N=>N.value===D.monthlyOrdinal))==null?void 0:l.display)||""},displayOption:l=>l.display,value:p.find(l=>l.value===D.monthlyOrdinal),onChange:l=>O("monthlyOrdinal",l.value),className:"w-24",buttonClassName:"bg-base-fill h-8 text-sm",disabled:i||D.monthlyRepeatType!=="ordinal"}),u.jsx(se,{label:"",options:S,deriveKey:l=>l.value,displaySelected:()=>{var l;return((l=S.find(N=>
7N.value===D.monthlyWeekday))==null?void 0:l.display)||""},displayOption:l=>l.display,value:S.find(l=>l.value===D.monthlyWeekday),onChange:l=>O("monthlyWeekday",l.value),className:"w-32",buttonClassName:"bg-base-fill h-8 text-sm",disabled:i||D.monthlyRepeatType!=="ordinal"})]})]})]}),D.frequency==="yearly"&&u.jsxs("div",{children:[u.jsx("span",{className:"block text-sm font-medium text-base-fg mb-2",children:o("main.calendar.recurrence.repeatOn")}),u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-wrap",onClick:()=>!i&&O("yearlyRepeatType","date"),children:[u.jsx("span",{className:F("h-4 w-4 rounded-full flex items-center justify-center border",D.yearlyRepeatType==="date"?"bg-primary border-primary":"border-base-border bg-white"),children:D.yearlyRepeatType==="date"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx(se,{label:"",options:E,deriveKey:l=>String(l.value),displaySelected:()=>{var l;return((l=E.find(N=>N.value===D.yearlyMonth))==null?void 0:l.display)||""},displayOption:l=>l.display,value:E.find(l=>l.value===D.yearlyMonth),onChange:l=>O("yearlyMonth",l.value),className:"w-32",buttonClassName:"bg-base-fill h-8 text-sm",disabled:i||D.yearlyRepeatType!=="date"}),u.jsx(Ye,{type:"text",inputMode:"numeric",value:D.yearlyDate||"",onChange:l=>O("yearlyDate",Math.min(31,parseInt(l.target.value,10)||0)),onBlur:()=>O("yearlyDate",Math.min(31,Math.max(1,D.yearlyDate))),disabled:i||D.yearlyRepeatType!=="date",className:"w-20"})]}),u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-wrap",onClick:()=>!i&&O("yearlyRepeatType","ordinal"),children:[u.jsx("span",{className:F("h-4 w-4 rounded-full flex items-center justify-center border",D.yearlyRepeatType==="ordinal"?"bg-primary border-primary":"border-base-border bg-white"),children:D.yearlyRepeatType==="ordinal"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx(se,{label:"",options:p,deriveKey:l=>l.value,displaySelected:()=>{var l;return((l=p.find(N=>N.value===D.yearlyOrdinal))==null?void 0:l.display)||""},displayOption:l=>l.display,value:p.find(l=>l.value===D.yearlyOrdinal),onChange:l=>O("yearlyOrdinal",l.value),className:"w-24",buttonClassName:"bg-base-fill h-8 text-sm",disabled:i||D.yearlyRepeatType!=="ordinal"}),u.jsx(se,{label:"",options:S,deriveKey:l=>l.value,displaySelected:()=>{var l;return((l=S.find(N=>N.value===D.yearlyWeekday))==null?void 0:l.display)||""},displayOption:l=>l.display,value:S.find(l=>l.value===D.yearlyWeekday),onChange:l=>O("yearlyWeekday",l.value),className:"w-32",buttonClassName:"bg-base-fill h-8 text-sm",disabled:i||D.yearlyRepeatType!=="ordinal"}),u.jsx("span",{className:"text-sm text-base-fg",children:o("main.calendar.recurrence.of")}),u.jsx(se,{label:"",options:E,deriveKey:l=>String(l.value),displaySelected:()=>{var l;return((l=E.find(N=>N.value===D.yearlyMonth))==null?void 0:l.display)||""},displayOption:l=>l.display,value:E.find(l=>l.value===D.yearlyMonth),onChange:l=>O("yearlyMonth",l.value),className:"w-32",buttonClassName:"bg-base-fill h-8 text-sm",disabled:i||D.yearlyRepeatType!=="ordinal"})]})]})]}),D.frequency!=="never"&&u.jsxs("div",{children:[u.jsx("span",{className:"block text-sm font-medium text-base-fg mb-2",children:o("main.calendar.recurrence.endLabel")}),u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>!i&&O("endType","never"),children:[u.jsx("span",{className:F("h-4 w-4 rounded-full flex items-center justify-center border",D.endType==="never"?"bg-primary border-primary":"border-base-border bg-white"),children:D.endType==="never"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx("span",{className:"text-sm text-base-fg",children:o("main.calendar.recurrence.endNever")})]}),u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>!i&&O("endType","after"),children:[u.jsx("span",{className:F("h-4 w-4 rounded-full flex items-center justify-center border",D.endType==="after"?"bg-primary border-primary":"border-base-border bg-white"),children:D.endType==="after"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx("span",{className:"text-sm text-base-fg",children:o("main.calendar.recurrence.endAfter")}),u.jsx(Ye,{type:"text",inputMode:"numeric",value:D.endCount||"",onChange:l=>O("endCount",parseInt(l.target.value,10)||0),onBlur:()=>O("endCount",Math.max(1,D.endCount)),disabled:i||D.endType!=="after",className:"w-20"}),u.jsx("span",{className:"text-sm text-base-fg",children:o("main.calendar.recurrence.occurrences")})]}),u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>!i&&O("endType","on"),children:[u.jsx("span",{className:F("h-4 w-4 roun
7ded-full flex items-center justify-center border",D.endType==="on"?"bg-primary border-primary":"border-base-border bg-white"),children:D.endType==="on"&&u.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),u.jsx("span",{className:"text-sm text-base-fg",children:o("main.calendar.recurrence.endOn")}),u.jsx("div",{onClick:l=>l.stopPropagation(),children:u.jsx(ot,{id:"recurrence-end-date","data-qa":"event-recurrence-end-date",value:D.endDate||T.start,onChange:l=>l&&O("endDate",l),minDate:T.start,className:"w-40",disabled:i||D.endType!=="on"})})]})]})]})]}),u.jsx(jr,{label:o("main.calendar.description"),"data-qa":"event-description",placeholder:o("main.calendar.descriptionPlaceholder"),value:T.description,onChange:l=>B("description",l.target.value),disabled:i,className:"w-full"}),u.jsx(se,{label:o("main.calendar.category"),options:He,deriveKey:l=>String(l.id),displaySelected:l=>Vt(l),displayOption:l=>Vt(l),value:He.find(l=>l.id===T.categoryId),onChange:l=>B("categoryId",l.id),className:"w-full",buttonClassName:"bg-base-fill h-10",disabled:i,dropUp:!0}),u.jsx(se,{label:o("main.calendar.securityLevel"),options:M,deriveKey:l=>l.value,displaySelected:()=>{var l;return((l=M.find(N=>N.value===T.securityLevel))==null?void 0:l.display)||""},displayOption:l=>l.display,value:M.find(l=>l.value===T.securityLevel),onChange:l=>B("securityLevel",l.value),className:"w-full",buttonClassName:"bg-base-fill h-10",disabled:i,dropUp:!0}),y&&!i&&u.jsx("div",{className:"pt-2 border-t border-base-border",children:u.jsx(_e,{variant:"danger",onClick:()=>ge(!0),"data-qa":"event-delete-open",className:"w-full",children:o("main.calendar.deleteEvent")})})]})})},Fa={month:"month-grid",week:"week",day:"day"},Dt=t=>{const e=t==null?void 0:t.eventColor;if(e)return kt(e)},br=({calendarEvent:t})=>t!=null&&t.isRecurring?u.jsx(we,{icon:t.isEditedOccurrence?qr:Wr,className:"w-2.5 h-2.5 flex-shrink-0 opacity-70"}):null,Pa=({calendarEvent:t})=>{const e=Dt(t);return u.jsxs("div",{className:"flex items-center gap-0.5 mobile:gap-1 w-full overflow-hidden rounded px-0.5 mobile:px-1.5 py-0.5 text-[10px] mobile:text-xs font-medium",style:{backgroundColor:e==null?void 0:e.bg,color:e==null?void 0:e.text,borderLeft:`2px solid ${e==null?void 0:e.dot}`},title:t.title,"data-qa":`calendar-event-${t.sourceEventId}`,children:[u.jsx(br,{calendarEvent:t}),u.jsx("span",{className:"truncate",children:t.title})]})},Jt=t=>{if(!t)return null;if(t&&typeof t=="object"&&"hour"in t)try{const n=Number(t.hour),s=Number(t.minute??0);if(isNaN(n))return null;const a=n>=12?"PM":"AM",c=n%12||12;return s>0?`${c}:${String(s).padStart(2,"0")} ${a}`:`${c} ${a}`}catch{return null}const r=String(t).match(/(\d{2}):(\d{2})/);if(r){const n=parseInt(r[1],10),s=parseInt(r[2],10),a=n>=12?"PM":"AM",c=n%12||12;return s>0?`${c}:${String(s).padStart(2,"0")} ${a}`:`${c} ${a}`}return null},Ha=({calendarEvent:t})=>{const e=Dt(t),r=Jt(t.start),n=Jt(t.end),s=r&&n?`${r} – ${n}`:r,a=t.title||t._title;return u.jsxs("div",{className:"sx-custom-time-event w-full h-full overflow-y-hidden",style:{backgroundColor:e==null?void 0:e.bg,color:e==null?void 0:e.text,borderLeft:`3px solid ${e==null?void 0:e.dot}`,borderRadius:"4px",fontWeight:500,lineHeight:1.3},title:`${a}${s?` (${s})`:""}`,children:[a&&u.jsx("div",{className:"sx-custom-time-event__title",children:a}),s&&u.jsx("div",{className:"sx-custom-time-event__time",children:s})]})},za=({calendarEvent:t})=>{const e=Dt(t),r=t.title||t._title;return u.jsxs("div",{className:"sx-custom-date-grid-event",style:{width:"100%",height:"100%",backgroundColor:e==null?void 0:e.bg,color:e==null?void 0:e.text,borderLeft:`3px solid ${e==null?void 0:e.dot}`,borderRadius:"4px",fontWeight:500,lineHeight:1.3,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"flex",alignItems:"center"},title:r,children:[u.jsx(br,{calendarEvent:t}),u.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:r})]})},vr=({associationId:t,events:e,categories:r,isLoading:n,error:s,currentYear:a,currentMonth:c,onDateChange:i,canEditCalendar:o,readOnly:f=!1})=>{const{t:m}=Ae(),y=m("main.months",{returnObjects:!0}),d=m("main.calendar.weekdays.full",{returnObjects:!0}),h=m("main.calendar.weekdays.short",{returnObjects:!0}),{isModalOpen:k,openModal:v,closeModal:w}=nn(),[p,S]=x.useState("month"),[E,M]=x.useState(new Date(a,c,1));x.useEffect(()=>{const g=new Date(a,c,E.getDate());(g.getMonth()!==E.getMonth()||g.getFullYear()!==E.getFullYear())&&M(new Date(a,c,1))},[a,c]);const K=x.useRef(null),U=x.useRef(null);x.useEffect(()=>{if(!K.current)return;const g=K.current;
7if(!U.current){U.current=new rn(g,{autohide:!0,showOnFocus:!1});const A=R=>{if(!(R.target instanceof HTMLInputElement)||!R.target.value)return;const W=new Date(R.target.value);isNaN(W.getTime())||Et.current(W)};return g.addEventListener("changeDate",A),()=>{var R;g.removeEventListener("changeDate",A),(R=U.current)==null||R.destroy(),U.current=null}}},[]),x.useEffect(()=>{var g;(g=U.current)==null||g.setDate(E)},[E]);const L=x.useCallback(()=>{var g;(g=U.current)==null||g.show()},[]),ve=x.useRef(o),ge=x.useRef(new Map);x.useEffect(()=>{ve.current=o},[o]);const{scheduleXEvents:de,eventLookup:De}=x.useMemo(()=>Oa(e),[e]);x.useEffect(()=>{ge.current=De},[De]);const ae=x.useMemo(()=>Ia(e),[e]),Te=x.useMemo(()=>({monthGridEvent:Pa,timeGridEvent:Ha,dateGridEvent:za}),[]),[T,Ie]=x.useState(void 0),[D,ee]=x.useState(null),[He,X]=x.useState(void 0),[Ce,he]=x.useState(!1),[Ee,Ne]=x.useState(null),[at,B]=x.useState(!1),O=x.useCallback(g=>{f||!ve.current||(ee(null),X(void 0),Ie(g),B(!1),v())},[v,f]),Se=x.useCallback(g=>{if(!f){if(!ve.current){ee(g),X(void 0),B(!0),v();return}g.recurrenceRule||g.recurrenceId?(Ne(g),he(!0)):(ee(g),X(void 0),B(!1),v())}},[v,f]),ze=g=>O(g),Le=x.useRef(O),Ke=x.useRef(Se);x.useEffect(()=>{Le.current=O,Ke.current=Se},[O,Se]);const[st,l]=x.useState(!1),N={start:"08:00",end:"17:00"},Y=Xr({views:[Vr(),Jr(),en()],events:de,calendars:ae,defaultView:"month-grid",selectedDate:$e(new Date(a,c,1)),firstDayOfWeek:7,dayBoundaries:N,weekOptions:{gridHeight:600,nDays:7,eventWidth:95,eventOverlap:!1},callbacks:{onEventClick(g){const A=ge.current.get(String(g.id));A&&Ke.current(A)},onDoubleClickDateTime(g){Le.current(Gt(g))},onDoubleClickDate(g){Le.current(Gt(g))}}});x.useEffect(()=>{Y&&Y.events.set(de)},[Y,de]),x.useEffect(()=>{var Z;if(!Y||Object.keys(ae).length===0)return;const A=Y.$app;(Z=A==null?void 0:A.config)!=null&&Z.calendars&&(A.config.calendars.value=ae);const R=document.documentElement,W=[];for(const G of Object.values(ae)){const te=G.colorName;R.style.setProperty(`--sx-color-${te}`,G.lightColors.main),R.style.setProperty(`--sx-color-${te}-container`,G.lightColors.container),R.style.setProperty(`--sx-color-on-${te}-container`,G.lightColors.onContainer),W.push(`--sx-color-${te}`,`--sx-color-${te}-container`,`--sx-color-on-${te}-container`)}return()=>{W.forEach(G=>R.style.removeProperty(G))}},[Y,ae]);const V=()=>Y?Y.$app??null:null,it={start:800,end:1700},gr={start:0,end:2400},wr=x.useCallback(()=>{l(g=>{var W;const A=!g,R=V();return(W=R==null?void 0:R.config)!=null&&W.dayBoundaries&&(R.config.dayBoundaries.value=A?gr:it),A})},[Y]),Tt=x.useCallback(g=>{var W,Z,G;const A=V();if(!A)return;const R=$e(g);(W=A.datePickerState)!=null&&W.selectedDate&&(A.datePickerState.selectedDate.value=R),(G=(Z=A.calendarState)==null?void 0:Z.setRange)==null||G.call(Z,R)},[Y]),Ct=x.useCallback(g=>{var Z,G,te,St;if(g==="agenda")return;const A=V();if(!A)return;const R=Fa[g],W=((G=(Z=A.datePickerState)==null?void 0:Z.selectedDate)==null?void 0:G.value)??$e(E);(St=(te=A.calendarState)==null?void 0:te.setView)==null||St.call(te,R,W)},[Y,E]),ye=x.useCallback(g=>{M(g),i(g),Tt(g)},[i,Tt]),Et=x.useRef(ye);x.useEffect(()=>{Et.current=ye},[ye]);const xr=x.useCallback(()=>{const g=new Date(E);p==="month"?g.setMonth(g.getMonth()-1):p==="week"||p==="agenda"?g.setDate(g.getDate()-7):p==="day"&&g.setDate(g.getDate()-1),ye(g)},[E,p,ye]),kr=x.useCallback(()=>{const g=new Date(E);p==="month"?g.setMonth(g.getMonth()+1):p==="week"||p==="agenda"?g.setDate(g.getDate()+7):p==="day"&&g.setDate(g.getDate()+1),ye(g)},[E,p,ye]),Dr=x.useCallback(()=>{ye(new Date)},[ye]),Nt=x.useRef(null),Tr=x.useCallback(g=>{const A=window.scrollY,R=Nt.current;R&&(R.style.minHeight=`${R.offsetHeight}px`),S(g),Ct(g),requestAnimationFrame(()=>{window.scrollTo({top:A,behavior:"instant"}),requestAnimationFrame(()=>{window.scrollTo({top:A,behavior:"instant"}),R&&(R.style.minHeight="")})})},[Ct]),Cr=x.useMemo(()=>{const g=E.getMonth(),A=E.getFullYear();if(p==="month")return`${y[g]}, ${A}`;if(p==="week"||p==="agenda"){const R=tr(E),W=Zr(E),Z=y[R.getMonth()],G=y[W.getMonth()];return R.getMonth()===W.getMonth()?`${Z} ${String(R.getDate()).padStart(2,"0")} - ${String(W.getDate()).padStart(2,"0")}, ${R.getFullYear()}`:`${Z} ${String(R.getDate()).padStart(2,"0")} - ${G} ${String(W.getDate()).padStart(2,"0")}, ${W.getFullYear()}`}return p==="day"?`${y[g]} ${E.getDate()}, ${A}
7`:`${y[g]}, ${A}`},[p,E,y]),Er=()=>{Ee&&(ee(Ee),X("occurrence"),Ne(null),he(!1),B(!1),v())},Nr=()=>{Ee&&(ee(Ee),X("series"),Ne(null),he(!1),B(!1),v())},Sr=()=>{Ne(null),he(!1)},Mr=()=>{ee(null),X(void 0),B(!1),w()};return u.jsxs("div",{ref:Nt,className:"w-full relative","data-qa":"community-calendar-root",children:[o&&u.jsx("div",{className:"flex justify-end mb-6",children:u.jsxs(_e,{variant:"primary",onClick:()=>O(),className:"shrink-0","data-qa":"community-calendar-create-event-button",children:[u.jsx("span",{children:m("main.calendar.createEvent")}),u.jsx(we,{icon:Ar,className:"ml-2 w-3 h-3"})]})}),u.jsxs("div",{className:"flex flex-col mobile:flex-row mobile:items-center justify-between gap-4 mb-4 pb-4 border-b border-base-border",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsx("button",{onClick:xr,"data-qa":"community-calendar-previous",className:"w-8 h-8 flex items-center justify-center rounded border border-base-border hover:bg-base-hover transition-colors","aria-label":"Previous",children:u.jsx(we,{icon:Or,className:"w-3 h-3 text-base-fg"})}),u.jsx("button",{onClick:kr,"data-qa":"community-calendar-next",className:"w-8 h-8 flex items-center justify-center rounded border border-base-border hover:bg-base-hover transition-colors","aria-label":"Next",children:u.jsx(we,{icon:Ir,className:"w-3 h-3 text-base-fg"})}),u.jsx("button",{onClick:Dr,"data-qa":"community-calendar-today",className:"px-3 py-1.5 text-sm font-medium text-base-fg border border-base-border rounded hover:bg-base-hover transition-colors",children:m("main.calendar.today")}),u.jsxs("div",{className:"relative",children:[u.jsx("input",{ref:K,"data-qa":"community-calendar-date-input",type:"text",className:"sr-only absolute opacity-0 pointer-events-none",tabIndex:-1,"aria-hidden":"true"}),u.jsxs("button",{onClick:L,"data-qa":"community-calendar-open-date-picker",className:"flex items-center gap-2 px-3 py-1.5 text-sm text-base-fg rounded border border-base-border hover:bg-base-hover transition-colors cursor-pointer",children:[u.jsx(we,{icon:Lr,className:"w-4 h-4 text-base-icon"}),u.jsx("span",{className:"font-medium",children:Cr}),u.jsx(we,{icon:Yr,className:"w-3 h-3 text-base-icon"})]})]})]}),u.jsx("div",{className:"flex items-center rounded-lg border border-base-border overflow-hidden self-start",children:["agenda","month","week","day"].map(g=>u.jsx("button",{"data-qa":`community-calendar-view-${g}`,onClick:()=>Tr(g),className:F("px-3 mobile:px-4 py-1.5 text-sm font-medium transition-colors capitalize",p===g?"bg-primary text-white":"text-base-fg hover:bg-base-hover"),children:m(`main.calendar.views.${g}`)},g))})]}),p==="agenda"&&u.jsx(Ta,{currentDate:E,events:e,onDoubleClick:ze,onEventClick:Se,readOnly:f}),u.jsxs("div",{className:F("community-calendar",p==="month"&&"has-day-header",f&&"read-only",p==="agenda"&&"hidden"),children:[u.jsx("style",{children:`
8          .community-calendar {
9            overflow-x: auto;
10            width: 100%;
11          }
12          .community-calendar .sx__calendar {
13            font-family: inherit;
14            min-width: 360px;
15          }
16
17          /* Hide the built-in Schedule-X header — we use our own */
18          .community-calendar .sx__calendar-header {
19            display: none !important;
20          }
21
22          /* Hide built-in day name labels inside month grid cells */
23          .community-calendar .sx__month-grid-day__header-day-name {
24            display: none !important;
25          }
26
27          /* When in month view, remove top border-radius so grid sits flush under our day-names header */
28          .community-calendar.has-day-header .sx__calendar {
29            border-top-left-radius: 0 !important;
30            border-top-right-radius: 0 !important;
31            border-top: 0 !important;
32          }
33
34          /* Month grid */
35          .community-calendar .sx__month-grid-day {
36            min-height: 120px;
37            cursor: pointer;
38          }
39          .community-calendar .sx__month-grid-day:hover {
40            background-color: var(--sx-color-surface-dim, #f9fafb);
41          }
42          .community-calendar .sx__month-grid-day__header-date {
43            font-size: 0.8125rem;
44            font-weight: 500;
45          }
46
47          /* Events */
48          .community-calendar .sx__event {
49            cursor: pointer;
50            border-radius: 4px;
51            font-size: 0.75rem;
52          }
53          .community-calendar .sx__month-grid-event {
54            padding: 1px 6px;
55            margin-bottom: 1px;
56            border-radius: 4px;
57            font-size: 0.75rem;
58            font-weight: 500;
59          }
60
61          /* Custom time grid event */
62          .sx-custom-time-event {
63            padding: 2px 6px;
64            font-size: 0.75rem;
65          }
66          .sx-custom-time-event__title {
67            white-space: normal;
68            word-break: break-word;
69          }
70          .sx-custom-time-event__time {
71            white-space: normal;
72            word-break: break-word;
73            opacity: 0.75;
74            font-size: 0.65rem;
75          }
76
77          /* Custom date grid event (multi-day / all-day in week header) */
78          .sx-custom-date-grid-event {
79            padding: 2px 6px;
80            font-size: 0.75rem;
81            gap: 4px;
82          }
83
84          /* Week / Day grid */
85          .community-calendar .sx__time-grid-day,
86          .community-calendar .sx__week-grid__day {
87            border-color: #e5e7eb !important;
88          }
89          .community-calendar .sx__time-grid-day__time-slot {
90            cursor: pointer !important;
91          }
92          .community-calendar .sx__time-axis__time {
93            font-size: 0.7rem !important;
94          }
95          .community-calendar .sx__week-grid__day-name,
96          .community-calendar .sx__week-grid__date {
97            font-size: 0.75rem !important;
98            font-weight: 600;
99          }
100
101          /* Current-time indicator */
102          .community-calendar .sx__current-time-indicator {
103            background-color: #ef4444;
104          }
105
106          /* "+N more" link in month cells */
107          .community-calendar .sx__month-grid-day__events-more {
108            font-size: 0.7rem;
109            color: var(--sx-color-on-surface-variant, #6b7280);
110            cursor: pointer;
111          }
112
113          /* Read-only mode */
114          .community-calendar.read-only .sx__event {
115            cursor: default;
116          }
117          .community-calendar.read-only .sx__month-grid-day {
118            cursor: default;
119          }
120          .community-calendar.read-only .sx__month-grid-day:hover {
121            background-color: transparent;
122          }
123          .community-calendar.read-only .sx__time-grid-day__time-slot {
124            cursor: default !important;
125          }
126
127          /* Mobile */
128          @media (max-width: 599px) {
129            .community-calendar .sx__month-grid-day {
130              min-height: 80px;
131            }
132            .community-calendar .sx__month-grid-event {
133              padding: 1px 2px;
134              font-size: 0.625rem;
135              border-radius: 3px;
136            }
137            .community-calendar .sx__month-grid-day__header-date {
138              font-size: 0.7rem !important;
139            }
140            .community-calendar .sx__week-grid__day-name,
141            .community-calendar .sx__week-grid__date {
142              font-size: 0.625rem !important;
143            }
144            .community-calendar .sx__time-axis__time {
145              font-size: 0.6rem !important;
146            }
147            .community-calendar .sx__date-grid-event {
148              font-size: 0.625rem;
149            }
150            .sx-custom-time-event {
151              padding: 1px 3px;
152              font-size: 0.625rem;
153            }
154            .sx-custom-time-event__title {
155              white-space: nowrap;
156              overflow: hidden;
157              text-overflow: ellipsis;
158            }
159            .sx-custom-time-event__time {
160              display: none;
161            }
162            .sx-custom-date-grid-event {
163              padding: 1px 3px;
164              font-size: 0.625rem;
165              gap: 2px;
166            }
167          }
168        `}),p==="month"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"hidden mobile:grid grid-cols-7 rounded-t-lg overflow-hidden border border-b-0 border-base-border bg-gray-50",children:d.map(g=>u.jsx("div",{className:"py-3 text-center text-sm font-semibold text-base-fg border-r border-base-border last:border-r-0",children:g},g))}),u.jsx("div",{className:"mobile:hidden grid grid-cols-7 rounded-t-lg overflow-hidden border border-b-0 border-base-border bg-gray-50",children:h.map((g,A)=>u.jsx("div",{className:"py-2 text-center text-xs font-semibold text-base-fg border-r border-base-border last:border-r-0",children:g},A))})]}),u.jsx(tn,{calendarApp:Y,customComponents:Te}),(p==="week"||p==="day")&&u.jsx("button",{type:"button",onClick:wr,"data-qa":"community-calendar-toggle-full-day",className:"mt-2 text-sm text-primary hover:text-primary-dark font-medium transition-colors",children:st?m("main.calendar.showBusinessHours","Show business hours"):m("main.calendar.showFullDay","Show full day")})]}),n&&u.jsx("div",{className:"absolute inset-0 bg-white/50 flex items-center justify-center",children:u.jsx(we,{icon:Ur,className:"w-8 h-8 text-primary animate-spin"})}),s&&u.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 p-4 text-center text-red-700 mt-4","data-qa":"community-calendar-error",children:m("main.calendar.errorLoadingEvents")}),!f&&u.jsxs(u.Fragment,{children:[u.jsx(Ca,{isOpen:Ce,onClose:Sr,onEditOccurrence:Er,onEditSeries:Nr}),u.jsx($a,{isOpen:k,onClose:Mr,initialDate:T,associationId:t,categories:r,editEvent:D,editMode:He,readOnly:at})]})]})};function Ka({associationId:t,isLoggedIn:e}){const{t:r}=Ae(),n=Hr(),[s,a]=x.useState(null),[c,i]=x.useState(null),[o,f]=x.use
168State(new Date),m=o.getMonth(),y=o.getFullYear(),{displayEvents:d,isLoading:h,error:k,categories:v,filteredAmenities:w}=ga({associationId:t,currentYear:y,currentMonth:m,isPublic:!e,selectedCategory:(s==null?void 0:s.name)??null,selectedAmenityId:(c==null?void 0:c.id)??null}),p=M=>{a(M??null),i(null)},S=M=>{i(M??null)},E=M=>{f(M)};return u.jsxs("div",{children:[u.jsxs("div",{className:"flex flex-col mobile:flex-row mobile:items-end gap-3 mb-4","data-qa":"amenity-calendar-filters",children:[u.jsx("div",{className:"w-full mobile:w-64",children:u.jsx(se,{label:r("main.calendar.amenity.categoryLabel","Category").toString(),options:v,value:s??void 0,onChange:p,deriveKey:M=>M.name,displayOption:M=>M.name,displaySelected:M=>M.name,placeholder:r("main.calendar.amenity.chooseCategory","Choose a category").toString(),qaListAttribute:"amenity-calendar__category-dropdown","data-feature":"amenity-calendar__select-category"})}),u.jsx("div",{className:"w-full mobile:w-64",children:u.jsx(se,{label:r("main.calendar.amenity.amenityLabel","Amenity").toString(),options:w,value:c??void 0,onChange:S,deriveKey:M=>String(M.id),displayOption:M=>M.name,displaySelected:M=>M.name,placeholder:s?r("main.calendar.amenity.chooseAmenity","Choose an amenity").toString():r("main.calendar.amenity.selectCategoryFirst","Select a category first").toString(),disabled:!s,qaListAttribute:"amenity-calendar__amenity-dropdown","data-feature":"amenity-calendar__select-amenity"})}),!n&&u.jsx(zr,{to:"/community/requests",state:{openNewRequest:!0,requestType:"reservation"},className:"text-sm font-medium text-primary hover:text-primary-dark transition-colors whitespace-nowrap pb-1","data-qa":"new-reservation-request-link","data-feature":"amenity-calendar__new-reservation",children:r("main.calendar.amenity.newReservation","New Reservation Request").toString()})]}),u.jsx(vr,{associationId:t,events:d,categories:[],isLoading:h,error:k,currentYear:y,currentMonth:m,onDateChange:E,canEditCalendar:!1,readOnly:!0})]})}const Ba=t=>t?t.split(/[,;]/).map(e=>e.trim()).filter(e=>e.length>0).map(e=>{const r=Number.parseInt(e.substring(0,4)),n=Number.parseInt(e.substring(4,6))-1,s=Number.parseInt(e.substring(6,8));if(!e.includes("T"))return new Date(r,n,s);const a=Number.parseInt(e.substring(9,11)),c=Number.parseInt(e.substring(11,13)),i=Number.parseInt(e.substring(13,15));return e.endsWith("Z")?new Date(Date.UTC(r,n,s,a,c,i)):new Date(r,n,s,a,c,i)}):[],Ga=(t,e)=>e.some(r=>t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()),Za="#f8a398",Qa=t=>{var e;return((e=t.eventCategory)==null?void 0:e.color)||Za},Ze=(t,e,r)=>({id:t.id,title:t.title,start:e||new Date(t.start),end:r||new Date(t.end),color:Qa(t),isAllDay:t.isAllDay,categoryId:t.eventCategoryId,description:t.description,recurrenceRule:t.recurrenceRule,recurrenceId:t.recurrenceId,recurrenceException:t.recurrenceException,securityLevel:t.securityLevel,startTimezone:t.startTimezone}),Xa=t=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}},ut=(t,e)=>{const r=ar.Instant.fromEpochMilliseconds(t.getTime()).toZonedDateTimeISO(e);return new Date(Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second))},Va=(t,e)=>{const r=ar.PlainDateTime.from({year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}).toZonedDateTime(e).toInstant();return new Date(r.epochMilliseconds)},Ja=(t,e,r)=>{const n=[],s=t.filter(i=>i.recurrenceRule&&!i.recurrenceId),a=t.filter(i=>i.recurrenceId!=null);return t.filter(i=>!i.recurrenceRule&&!i.recurrenceId).forEach(i=>{n.push(Ze(i))}),a.forEach(i=>{n.push(Ze(i))}),s.forEach(i=>{try{const o=new Date(i.start),m=new Date(i.end).getTime()-o.getTime(),y=i.recurrenceRule.replace(/UNTIL=(\d{8})(?!T)/,"UNTIL=$1T235959"),d=!i.isAllDay&&i.startTimezone&&Xa(i.startTimezone)?i.startTimezone:null,h=d?ut(o,d):o,v=tt(y,{dtstart:h}).between(d?ut(e,d):e,d?ut(r,d):r,!0),w=Ba(i.recurrenceException??null);v.forEach(p=>{const S=d?Va(p,d):p;if(Ga(S,w))return;const E=new Date(S.getTime()+m);n.push(Ze(i,S,E))})}catch(o){console.error(`Failed to parse recurrence rule for event ${i.id}:`,o),n.push(Ze(i))}}),n},es=({associationId:t,currentYear:e,currentMonth:r,isPublic:n})=>{const s=x.useMemo(()=>{const m=new Date(e,r,1),y=new Date(e,r+1,0,23,59,59),d=new Date(m);d.setDate(d.getDate()-7);const h=new Date(y);return h.setDate(h.getDate()+7),{startFrom:d,endTo:h}},[e,r]),{data:a,isLoading:c,error:i}=Ea({associationId:t,query:{startTo:s.endTo,endFrom:s.startFrom,pageSize:500},isPublic:n}),{data:o=[]}=Sa({associationId:t,isPublic:n});return{displayEvents:x.useMemo(()=>a!=null&&a.member?Ja(a.member,s.startFrom,s.endTo):[],[a==null?void 0:a.member,s.startFrom,s.endTo]),isLoading:c,error:i,categories:o}},ts=({isLoggedIn:t})=>{var K,U;const{t:e}=Ae(),r=Kr(),n=nr(L=>L.userSettings),{allowAccess:s}=dn(),a=(r==null?void 0:r.id)??((U=(K=n==null?void 0:n.pages)==null?void 0:K[0])==null?void 0:U.associationId)??0,c=s({legacyController:"Homeowner_v2",legacyAction:"ResourceCalendar"}),[i,o]=x.useState("community"),[f,m]=x.useState(new Date),y=f.getMonth(),d=f.getFullYear(),{displayEvents:h,isLoading:k,error:v,categories:w}=es({associationId:a,currentYear:d,currentMonth:y,isPublic:!t}),{data:p}=Ma({associationId:a,enabled:t}),S=t&&((p==null?void 0:p.hasCalendarUpdatePermissions)??!1),E=L=>{m(L)},M=[{key:"community",label:e("main.calendar.tabs.community","Community Calendar").toString()},...c?[{key:"amenity",label:e("main.calendar.tabs.amenity","Amenity Calendar").toString()}]:[]];return u.jsxs("div",{className:"w-full px-4 mobile:px-6 py-4 bg-base-fill rounded-xl",children:[M.length>1&&u.jsx("nav",{className:"flex border-b border-base-border mb-6","aria-label":e("main.calendar.tabNavigation","Calendar navigation").toString(),"data-qa":"calendar-tabs","data-feature":"calendar-tabs",children:M.map(L=>u.jsxs("button",{type:"button",onClick:()=>o(L.key),className:F("px-4 py-3 text-sm font-medium transition-colors relative","focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",i===L.key?"text-primary":"text-base-fg/60 hover:text-base-fg"),"aria-current":i===L.key?"page":void 0,"data-qa":`calendar-tab-${L.key}`,"data-feature":`calendar-tab-${L.key}`,children:[L.label,i===L.key&&u.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary rounded-t"})]},L.key))}),i==="community"?u.jsx(vr,{associationId:a,events:h,categories:w,isLoading:k,error:v,currentYear:d,currentMonth:y,onDateChange:E,canEditCalendar:S}):c&&u.jsx(Ka,{associationId:a,isLoggedIn:t})]})},ks={title:"Community Calendar",showPropertySelector:!0,showAi:!0,redesignPage:"calendarPage",redesignHandle:{customContentId:["Calendar","Homeowner_v2"]}};function Ds(){const t=Br("calendarPage"),e=nr(s=>s.isLoggedIn),r=Pr(),n=Gr();return r&&!e&&n.pathname!=="/public/community/calendar"?u.jsx(Rt,{to:"/public/community/calendar"}):!r&&!e&&n.pathname!=="/community/calendar"||e&&n.pathname!=="/community/calendar"?u.jsx(Rt,{to:"/community/calendar"}):u.jsx(Fr,{controller:e?"Homeowner_v2":"Home_v2",action:"Calendar",requireAuth:e,children:t?u.jsx(ts,{isLoggedIn:e}):u.jsx($r,{controller:e?"Homeowner_v2":"Home_v2",action:"Calendar"})})}export{Ds as Component,ks as handle};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.