/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * Portions Copyright (C) Philipp Kewisch */ class t{static fromString(e){return new t(e)}constructor(t){this.value=t}icaltype="binary";decodeValue(){return this._b64_decode(this.value)}setEncodedValue(t){this.value=this._b64_encode(t)}_b64_encode(t){let e,i,r,n,s,a,o,l,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,c=0,d="",m=[];if(!t)return t;do{e=t.charCodeAt(u++),i=t.charCodeAt(u++),r=t.charCodeAt(u++),l=e<<16|i<<8|r,n=l>>18&63,s=l>>12&63,a=l>>6&63,o=63&l,m[c++]=h.charAt(n)+h.charAt(s)+h.charAt(a)+h.charAt(o)}while(u>16&255,i=l>>8&255,r=255&l,m[c++]=64==a?String.fromCharCode(e):64==o?String.fromCharCode(e,i):String.fromCharCode(e,i,r)}while(ui)-(e12||(i=[0,31,28,31,30,31,30,31,31,30,31,30,31][t],2==t&&(i+=s.isLeapYear(e))),i}static isLeapYear(t){return t<=1752?t%4==0:t%4==0&&t%100!=0||t%400==0}static fromDayOfYear(t,e){let i=e,r=t,n=new s;n.auto_normalize=!1;let a=s.isLeapYear(i)?1:0;if(r<1)return i--,a=s.isLeapYear(i)?1:0,r+=s.daysInYearPassedMonth[a][12],s.fromDayOfYear(r,i);if(r>s.daysInYearPassedMonth[a][12])return a=s.isLeapYear(i)?1:0,r-=s.daysInYearPassedMonth[a][12],i++,s.fromDayOfYear(r,i);n.year=i,n.isDate=!0;for(let t=11;t>=0;t--)if(r>s.daysInYearPassedMonth[a][t]){n.month=t+1,n.day=r-s.daysInYearPassedMonth[a][t];break}return n.auto_normalize=!0,n}static fromStringv2(t){return new s({year:parseInt(t.slice(0,4),10),month:parseInt(t.slice(5,7),10),day:parseInt(t.slice(8,10),10),isDate:!0})}static fromDateString(t){return new s({year:p(t.slice(0,4)),month:p(t.slice(5,7)),day:p(t.slice(8,10)),isDate:!0})}static fromDateTimeString(t,e){if(t.length<19)throw new Error('invalid date-time value: "'+t+'"');let i,r;t[19]&&"Z"===t[19]?i=c.utcTimezone:e&&(r=e.getParameter("tzid"),e.parent&&("standard"===e.parent.name||"daylight"===e.parent.name?i=c.localTimezone:r&&(i=e.parent.getTimeZoneByID(r))));const n={year:p(t.slice(0,4)),month:p(t.slice(5,7)),day:p(t.slice(8,10)),hour:p(t.slice(11,13)),minute:p(t.slice(14,16)),second:p(t.slice(17,19))};return r&&!i&&(n.timezone=r),new s(n,i)}static fromString(t,e){return t.length>10?s.fromDateTimeString(t,e):s.fromDateString(t)}static fromJSDate(t,e){return(new s).fromJSDate(t,e)}static fromData=function(t,e){return(new s).fromData(t,e)};static now(){return s.fromJSDate(new Date,!1)}static weekOneStarts(t,e){let i=s.fromData({year:t,month:1,day:1,isDate:!0}),r=i.dayOfWeek(),n=e||s.DEFAULT_WEEK_START;return r>s.THURSDAY&&(i.day+=7),n>s.THURSDAY&&(i.day-=7),i.day-=r-n,i}static getDominicalLetter(t){let e="GFEDCBA",i=(t+(t/4|0)+(t/400|0)-(t/100|0)-1)%7;return s.isLeapYear(t)?e[(i+6)%7]+e[i]:e[i]}static#t=null;static get epochTime(){return this.#t||(this.#t=s.fromData({year:1970,month:1,day:1,hour:0,minute:0,second:0,isDate:!1,timezone:"Z"})),this.#t}static _cmp_attr(t,e,i){return t[i]>e[i]?1:t[i]=0){o.day=1,0!=n&&n--,a=o.day;let e=t-o.dayOfWeek();e<0&&(e+=7),a+=e,a-=t,i=t}else{o.day=r,n++,i=o.dayOfWeek()-t,i<0&&(i+=7),i=r-i}return i+=7*n,a+i}isNthWeekDay(t,e){let i=this.dayOfWeek();return 0===e&&i===t||this.nthWeekDay(t,e)===this.day}weekNumber(t){let e,i=(this.year<<12)+(this.month<<8)+(this.day<<3)+t;if(i in s._wnCache)return s._wnCache[i];let r=this.clone();r.isDate=!0;let n=this.year;12==r.month&&r.day>25?(e=s.weekOneStarts(n+1,t),r.compare(e)<0?e=s.weekOneStarts(n,t):n++):(e=s.weekOneStarts(n,t),r.compare(e)<0&&(e=s.weekOneStarts(--n,t)));let a=A(r.subtractDate(e).toSeconds()/86400/7)+1;return s._wnCache[i]=a,a}addDuration(t){let e=t.isNegative?-1:1,i=this.second,r=this.minute,n=this.hour,s=this.day;i+=e*t.seconds,r+=e*t.minutes,n+=e*t.hours,s+=e*t.days,s+=7*e*t.weeks,this.second=i,this.minute=r,this.hour=n,this.day=s,this._cachedUnixTime=null}subtractDate(t){let e=this.toUnixTime()+this.utcOffset(),i=t.toUnixTime()+t.utcOffset();return r.fromSeconds(e-i)}subtractDateTz(t){let e=this.toUnixTime(),i=t.toUnixTime();return r.fromSeconds(e-i)}compare(t){let e=this.toUnixTime(),i=t.toUnixTime();return e>i?1:i>e?-1:0}compareDateOnlyTz(t,e){let i=this.convertToZone(e),r=t.convertToZone(e),n=0;return 0!=(n=s._cmp_attr(i,r,"year"))||0!=(n=s._cmp_attr(i,r,"month"))||(n=s._cmp_attr(i,r,"day")),n}convertToZone(t){let e=this.clone(),i=this.zone.tzid==t.tzid;return this.isDate||i||c.convert_time(e,this.zone,t),e.zone=t,e}utcOffset(){return this.zone==c.localTimezone||this.zone==c.utcTimezone?0:this.zone.utcOffset(this)}toICALString(){let t=this.toString();return t.length>10?ut.icalendar.value["date-time"].toICAL(t):ut.icalendar.value.date.toICAL(t)}toString(){let t=this.year+"-"+Y(this.month)+"-"+Y(this.day);return this.isDate||(t+="T"+Y(this.hour)+":"+Y(this.minute)+":"+Y(this.second),this.zone===c.utcTimezone&&(t+="Z")),t}toJSDate(){return this.zone==c.localTimezone?this.isDate?new Date(this.year,this.month-1,this.day):new Date(this.year,this.month-1,this.day,this.hour,this.minute,this.second,0):new Date(1e3*this.toUnixTime())}_normalize(){return this._time.isDate&&(this._time.hour=0,this._time.minute=0,this._time.second=0),this.adjust(0,0,0,0),this}adjust(t,e,i,r,n){let a,o,l,h,u,c,d,m=0,f=0,p=n||this._time;if(p.isDate||(l=p.second+r,p.second=l%60,a=A(l/60),p.second<0&&(p.second+=60,a--),h=p.minute+i+a,p.minute=h%60,o=A(h/60),p.minute<0&&(p.minute+=60,o--),u=p.hour+e+o,p.hour=u%24,m=A(u/24),p.hour<0&&(p.hour+=24,m--)),p.month>12?f=A((p.month-1)/12):p.month<1&&(f=A(p.month/12)-1),p.year+=f,p.month-=12*f,c=p.day+t+m,c>0)for(;d=s.daysInMonth(p.month,p.year),!(c<=d);)p.month++,p.month>12&&(p.year++,p.month=1),c-=d;else for(;c<=0;)1==p.month?(p.year--,p.month=12):p.month--,c+=s.daysInMonth(p.month,p.year);return p.day=c,this._cachedUnixTime=null,this}fromUnixTime(t){this.zone=c.utcTimezone;let e=new Date(1e3*t);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this._time.isDate?(this.hour=0,this.minute=0,this.second=0):(this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()),this._cachedUnixTime=null}toUnixTime(){if(null!==this._cachedUnixTime)return this._cachedUnixTime;let t=this.utcOffset(),e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second-t);return this._cachedUnixTime=e/1e3,this._cachedUnixTime}toJSON(){let t,e=["year","month","day","hour","minute","second","isDate"],i=Object.create(null),r=0,n=e.length;for(;r1)throw new h("invalid ical body. component began but did not end");return e=null,1==i.length?i[0]:i}l.property=function(t,e){let i={component:[[],[]],designSet:e||ut.defaultSet};return l._handleContentLine(t,i),i.component[1][0]},l.component=function(t){return l(t)};class h extends Error{constructor(t){super(t),this.name=this.constructor.name;try{throw new Error}catch(t){if(t.stack){let e=t.stack.split("\n");e.shift(),this.stack=e.join("\n")}}}}l.ParserError=h,l._handleContentLine=function(t,e){let i,r,n,s,a,o,u=t.indexOf(":"),c=t.indexOf(";"),d={};if(-1!==c&&-1!==u&&c>u&&(c=-1),-1!==c){if(n=t.slice(0,Math.max(0,c)).toLowerCase(),a=l._parseParameters(t.slice(Math.max(0,c)),0,e.designSet),-1==a[2])throw new h("Invalid parameters in '"+t+"'");if(d=a[0],i=a[1].length+a[2]+c,-1===(r=t.slice(Math.max(0,i)).indexOf(":")))throw new h("Missing parameter value in '"+t+"'");s=t.slice(Math.max(0,i+r+1))}else{if(-1===u)throw new h('invalid line (no token ";" or ":") "'+t+'"');if(n=t.slice(0,Math.max(0,u)).toLowerCase(),s=t.slice(Math.max(0,u+1)),"begin"===n){let t=[s.toLowerCase(),[],[]];return 1===e.stack.length?e.component.push(t):e.component[2].push(t),e.stack.push(e.component),e.component=t,void(e.designSet||(e.designSet=ut.getDesignSet(e.component[0])))}if("end"===n)return void(e.component=e.stack.pop())}let m,f,p,y,_=!1,g=!1;e.designSet.propertyGroups&&-1!==n.indexOf(".")?(f=n.split("."),d.group=f[0],p=f[1]):p=n,p in e.designSet.property&&(m=e.designSet.property[p],"multiValue"in m&&(_=m.multiValue),"structuredValue"in m&&(g=m.structuredValue),s&&"detectType"in m&&(o=m.detectType(s))),o||(o="value"in d?d.value.toLowerCase():m?m.defaultType:"unknown"),delete d.value,_&&g?(s=l._parseMultiValue(s,g,o,[],_,e.designSet,g),y=[p,d,o,s]):_?(y=[p,d,o],l._parseMultiValue(s,_,o,y,null,e.designSet,!1)):g?(s=l._parseMultiValue(s,g,o,[],null,e.designSet,g),y=[p,d,o,s]):(s=l._parseValue(s,o,e.designSet,!1),y=[p,d,o,s]),"vcard"!==e.component[0]||0!==e.component[1].length||"version"===n&&"4.0"===s||(e.designSet=ut.getDesignSet("vcard3")),e.component[1].push(y)},l._parseValue=function(t,e,i,r){return e in i.value&&"fromICAL"in i.value[e]?i.value[e].fromICAL(t,r):t},l._parseParameters=function(t,e,i){let r,n,s,a,o,u,c=e,d=0,m={},f=-1;for(;!1!==d&&-1!==(d=_(t,"=",d+1));){if(r=t.slice(c+1,d),0==r.length)throw new h("Empty parameter name in '"+t+"'");if(n=r.toLowerCase(),u=!1,o=!1,a=n in i.param&&i.param[n].valueType?i.param[n].valueType:"text",n in i.param&&(o=i.param[n].multiValue,i.param[n].multiValueSeparateDQuote&&(u=l._rfc6868Escape('"'+o+'"'))),'"'===t[d+1]){if(f=d+2,d=_(t,'"',f),o&&-1!=d){let e=!0;for(;e;)t[d+1]==o&&'"'==t[d+2]?d=_(t,'"',d+3):e=!1}if(-1===d)throw new h('invalid line (no matching double quote) "'+t+'"');s=t.slice(f,d),c=_(t,";",d),-1===c&&(d=!1)}else{f=d+1;let e=_(t,";",f),i=_(t,":",f);-1!==i&&e>i?(e=i,d=!1):-1===e?(e=-1===i?t.length:i,d=!1):(c=e,d=e),s=t.slice(f,e)}if(s=l._rfc6868Escape(s),o){let t=u||o;s=l._parseMultiValue(s,t,a,[],null,i)}else s=l._parseValue(s,a,i);o&&n in m?Array.isArray(m[n])?m[n].push(s):m[n]=[m[n],s]:m[n]=s}return[m,s,f]},l._rfc6868Escape=function(t){return t.replace(/\^['n^]/g,(function(t){return o[t]}))},l._parseMultiValue=function(t,e,i,r,n,s,a){let o,h=0,u=0;if(0===e.length)return t;for(;-1!==(h=_(t,e,u));)o=t.slice(u,h),o=n?l._parseMultiValue(o,n,i,[],null,s,a):l._parseValue(o,i,s,a),r.push(o),u=h+e.length;return o=t.slice(u),o=n?l._parseMultiValue(o,n,i,[],null,s,a):l._parseValue(o,i,s,a),r.push(o),1==r.length?r[0]:r},l._eachLine=function(t,e){let i,r,n,s=t.length,o=t.search(a),l=o;do{l=t.indexOf("\n",o)+1,n=l>1&&"\r"===t[l-2]?2:1,0===l&&(l=s,n=0),r=t[o]," "===r||"\t"===r?i+=t.slice(o+1,l-n):(i&&e(null,i),i=t.slice(o,l-n)),o=l}while(l!==s);i=i.trim(),i.length&&e(null,i)};const u=["tzid","location","tznames","latitude","longitude"];class c{static _compare_change_fn(t,e){return t.yeare.year?1:t.monthe.month?1:t.daye.day?1:t.houre.hour?1:t.minutee.minute?1:t.seconde.second?1:0}static convert_time(t,e,i){if(t.isDate||e.tzid==i.tzid||e==c.localTimezone||i==c.localTimezone)return t.zone=i,t;let r=e.utcOffset(t);return t.adjust(0,0,0,-r),r=i.utcOffset(t),t.adjust(0,0,0,r),null}static fromData(t){return(new c).fromData(t)}static#e=null;static get utcTimezone(){return this.#e||(this.#e=c.fromData({tzid:"UTC"})),this.#e}static#i=null;static get localTimezone(){return this.#i||(this.#i=c.fromData({tzid:"floating"})),this.#i}static adjust_change(t,e,i,r,n){return s.prototype.adjust.call(t,e,i,r,n,t)}static _minimumExpansionYear=-1;static EXTRA_COVERAGE=5;constructor(t){this.wrappedJSObject=this,this.fromData(t)}tzid="";location="";tznames="";latitude=0;longitude=0;component=null;expandedUntilYear=0;icalclass="icaltimezone";fromData(t){if(this.expandedUntilYear=0,this.changes=[],t instanceof yt)this.component=t;else{if(t&&"component"in t)if("string"==typeof t.component){let e=l(t.component);this.component=new yt(e)}else t.component instanceof yt?this.component=t.component:this.component=null;for(let e of u)t&&e in t&&(this[e]=t[e])}return this.component instanceof yt&&!this.tzid&&(this.tzid=this.component.getFirstPropertyValue("tzid")),this}utcOffset(t){if(this==c.utcTimezone||this==c.localTimezone)return 0;if(this._ensureCoverage(t.year),!this.changes.length)return 0;let e={year:t.year,month:t.month,day:t.day,hour:t.hour,minute:t.minute,second:t.second},i=this._findNearbyChange(e),r=-1,n=1;for(;;){let t=D(this.changes[i],!0);if(t.utcOffset=0?r=i:n=-1,-1==n&&-1!=r)break;if(i+=n,i<0)return 0;if(i>=this.changes.length)break}let s=this.changes[r];if(s.utcOffset-s.prevUtcOffset<0&&r>0){let t=D(s,!0);if(c.adjust_change(t,0,0,0,t.prevUtcOffset),c._compare_change_fn(e,t)<0){let t=this.changes[r-1],e=!1;s.is_daylight!=e&&t.is_daylight==e&&(s=t)}}return s.utcOffset}_findNearbyChange(t){let e=g(this.changes,t,c._compare_change_fn);return e>=this.changes.length?this.changes.length-1:e}_ensureCoverage(t){if(-1==c._minimumExpansionYear){let t=s.now();c._minimumExpansionYear=t.year}let e=t;if(ee)&&t);)r.year=t.year,r.month=t.month,r.day=t.day,r.hour=t.hour,r.minute=t.minute,r.second=t.second,r.isDate=t.isDate,c.adjust_change(r,0,0,0,-r.prevUtcOffset),i.push(r)}}else r=a(),r.year=n.year,r.month=n.month,r.day=n.day,r.hour=n.hour,r.minute=n.minute,r.second=n.second,c.adjust_change(r,0,0,0,-r.prevUtcOffset),i.push(r);return i}toString(){return this.tznames?this.tznames:this.tzid}}let d=null;const m={get count(){return null===d?0:Object.keys(d).length},reset:function(){d=Object.create(null);let t=c.utcTimezone;d.Z=t,d.UTC=t,d.GMT=t},has:function(t){return null!==d&&!!d[t]},get:function(t){return null===d&&this.reset(),d[t]},register:function(t,e){if(null===d&&this.reset(),t instanceof yt&&"vtimezone"===t.name&&(t=(e=new c(t)).tzid),!(e instanceof c))throw new TypeError("timezone must be ICAL.Timezone or ICAL.Component");d[t]=e},remove:function(t){return null===d?null:delete d[t]}};function f(t){return"number"==typeof t&&isNaN(t)}function p(t){let e=parseInt(t,10);if(f(e))throw new Error('Could not extract integer from "'+t+'"');return e}function y(t,e){if(void 0!==t)return t instanceof e?t:new e(t)}function _(t,e,i){for(;-1!==(i=t.indexOf(e,i));){if(!(i>0&&"\\"===t[i-1]))return i;i+=1}return-1}function g(t,e,i){if(!t.length)return 0;let r,n,s=0,a=t.length-1;for(;s<=a;)if(r=s+Math.floor((a-s)/2),n=i(e,t[r]),n<0)a=r-1;else{if(!(n>0))break;s=r+1}return n<0?r:n>0?r+1:r}function D(t,e){if(t&&"object"==typeof t){if(t instanceof Date)return new Date(t.getTime());if("clone"in t)return t.clone();if(Array.isArray(t)){let i=[];for(let r=0;r65535?2:1:(e+=Tt.newLineChar+" "+i.slice(0,Math.max(0,r)),i=i.slice(Math.max(0,r)),r=n=0)}return e.slice(Tt.newLineChar.length+1)}function Y(t){switch("string"!=typeof t&&("number"==typeof t&&(t=parseInt(t)),t=String(t)),t.length){case 0:return"00";case 1:return"0"+t;default:return t}}function A(t){return t<0?Math.ceil(t):Math.floor(t)}function O(t,e){for(let i in t){let r=Object.getOwnPropertyDescriptor(t,i);r&&!Object.getOwnPropertyDescriptor(e,i)&&Object.defineProperty(e,i,r)}return e}var b=Object.freeze({__proto__:null,updateTimezones:function(t){let e,i,r,n,s;if(!t||"vcalendar"!==t.name)return t;for(e=t.getAllSubcomponents(),i=[],r={},s=0;si)-(i>e)}_normalize(){let t=this.toSeconds(),e=this.factor;for(;t<-43200;)t+=97200;for(;t>50400;)t-=97200;this.fromSeconds(t),0==t&&(this.factor=e)}toICALString(){return ut.icalendar.value["utc-offset"].toICAL(this.toString())}toString(){return(1==this.factor?"+":"-")+Y(this.hours)+":"+Y(this.minutes)}}class E extends s{static fromDateAndOrTimeString(t,e){function i(t,e,i){return t?p(t.slice(e,e+i)):null}let r=t.split("T"),n=r[0],s=r[1],a=s?ut.vcard.value.time._splitZone(s):[],o=a[0],l=a[1],h=n?n.length:0,u=l?l.length:0,d=n&&"-"==n[0]&&"-"==n[1],m=l&&"-"==l[0],f={year:d?null:i(n,0,4),month:!d||4!=h&&7!=h?7==h||10==h?i(n,5,2):null:i(n,2,2),day:5==h?i(n,3,2):7==h&&d?i(n,5,2):10==h?i(n,8,2):null,hour:m?null:i(l,0,2),minute:m&&3==u?i(l,1,2):u>4?i(l,m?1:3,2):null,second:4==u?i(l,2,2):6==u?i(l,4,2):8==u?i(l,6,2):null};return o="Z"==o?c.utcTimezone:o&&":"==o[3]?S.fromString(o):null,new E(f,o,e)}constructor(t,e,i){super(t,e),this.icaltype=i||"date-and-or-time"}icalclass="vcardtime";icaltype="date-and-or-time";clone(){return new E(this._time,this.zone,this.icaltype)}_normalize(){return this}utcOffset(){return this.zone instanceof S?this.zone.toSeconds():s.prototype.utcOffset.apply(this,arguments)}toICALString(){return ut.vcard.value[this.icaltype].toICAL(this.toString())}toString(){let t,e=this.year,i=this.month,r=this.day,n=this.hour,s=this.minute,a=this.second,o=null!==i,l=null!==r,h=null!==n,u=null!==s,d=null!==a,m=(null!==e?Y(e)+(o||l?"-":""):o||l?"--":"")+(o?Y(i):"")+(l?"-"+Y(r):""),f=(h?Y(n):"-")+(h&&u?":":"")+(u?Y(s):"")+(h||u?"":"-")+(u&&d?":":"")+(d?Y(a):"");if(this.zone===c.utcTimezone)t="Z";else if(this.zone instanceof S)t=this.zone.toString();else if(this.zone===c.localTimezone)t="";else if(this.zone instanceof c){t=S.fromSeconds(this.zone.utcOffset(this)).toString()}else t="";switch(this.icaltype){case"time":return f+t;case"date-and-or-time":case"date-time":return m+("--"==f?"":"T"+f+t);case"date":return m}return null}}class C{static _indexMap={BYSECOND:0,BYMINUTE:1,BYHOUR:2,BYDAY:3,BYMONTHDAY:4,BYYEARDAY:5,BYWEEKNO:6,BYMONTH:7,BYSETPOS:8};static _expandMap={SECONDLY:[1,1,1,1,1,1,1,1],MINUTELY:[2,1,1,1,1,1,1,1],HOURLY:[2,2,1,1,1,1,1,1],DAILY:[2,2,2,1,1,1,1,1],WEEKLY:[2,2,2,2,3,3,1,1],MONTHLY:[2,2,2,2,2,3,3,1],YEARLY:[2,2,2,2,2,2,2,2]};static UNKNOWN=0;static CONTRACT=1;static EXPAND=2;static ILLEGAL=3;constructor(t){this.fromData(t)}completed=!1;rule=null;dtstart=null;last=null;occurrence_number=0;by_indices=null;initialized=!1;by_data=null;days=null;days_index=0;fromData(t){if(this.rule=y(t.rule,B),!this.rule)throw new Error("iterator requires a (ICAL.Recur) rule");if(this.dtstart=y(t.dtstart,s),!this.dtstart)throw new Error("iterator requires a (ICAL.Time) dtstart");t.by_data?this.by_data=t.by_data:this.by_data=D(this.rule.parts,!0),t.occurrence_number&&(this.occurrence_number=t.occurrence_number),this.days=t.days||[],t.last&&(this.last=y(t.last,s)),this.by_indices=t.by_indices,this.by_indices||(this.by_indices={BYSECOND:0,BYMINUTE:0,BYHOUR:0,BYDAY:0,BYMONTH:0,BYWEEKNO:0,BYMONTHDAY:0}),this.initialized=t.initialized||!1,this.initialized||this.init()}init(){this.initialized=!0,this.last=this.dtstart.clone();let t=this.by_data;if("BYDAY"in t&&this.sort_byday_rules(t.BYDAY),"BYYEARDAY"in t&&("BYMONTH"in t||"BYWEEKNO"in t||"BYMONTHDAY"in t||"BYDAY"in t))throw new Error("Invalid BYYEARDAY rule");if("BYWEEKNO"in t&&"BYMONTHDAY"in t)throw new Error("BYWEEKNO does not fit to BYMONTHDAY");if("MONTHLY"==this.rule.freq&&("BYYEARDAY"in t||"BYWEEKNO"in t))throw new Error("For MONTHLY recurrences neither BYYEARDAY nor BYWEEKNO may appear");if("WEEKLY"==this.rule.freq&&("BYYEARDAY"in t||"BYMONTHDAY"in t))throw new Error("For WEEKLY recurrences neither BYMONTHDAY nor BYYEARDAY may appear");if("YEARLY"!=this.rule.freq&&"BYYEARDAY"in t)throw new Error("BYYEARDAY may only appear in YEARLY rules");this.last.second=this.setup_defaults("BYSECOND","SECONDLY",this.dtstart.second),this.last.minute=this.setup_defaults("BYMINUTE","MINUTELY",this.dtstart.minute),this.last.hour=this.setup_defaults("BYHOUR","HOURLY",this.dtstart.hour);let e=this.last.day=this.setup_defaults("BYMONTHDAY","DAILY",this.dtstart.day);if(this.last.month=this.setup_defaults("BYMONTH","MONTHLY",this.dtstart.month),"WEEKLY"==this.rule.freq)if("BYDAY"in t){let[,e]=this.ruleDayOfWeek(t.BYDAY[0],this.rule.wkst),i=e-this.last.dayOfWeek(this.rule.wkst);(this.last.dayOfWeek(this.rule.wkst)=0||i<0)&&(this.last.day+=i)}else{let e=B.numericDayToIcalDay(this.dtstart.dayOfWeek());t.BYDAY=[e]}if("YEARLY"==this.rule.freq){for(;this.expand_year_days(this.last.year),!(this.days.length>0);)this.increment_year(this.rule.interval);this._nextByYearDay()}if("MONTHLY"==this.rule.freq&&this.has_by_data("BYDAY")){let t=null,e=this.last.clone(),i=s.daysInMonth(this.last.month,this.last.year);for(let r of this.by_data.BYDAY){this.last=e.clone();let[n,a]=this.ruleDayOfWeek(r),o=this.last.nthWeekDay(a,n);if(n>=6||n<=-6)throw new Error("Malformed values in BYDAY part");if(o>i||o<=0){if(t&&t.month==e.month)continue;for(;o>i||o<=0;)this.increment_month(),i=s.daysInMonth(this.last.month,this.last.year),o=this.last.nthWeekDay(a,n)}this.last.day=o,(!t||this.last.compare(t)<0)&&(t=this.last.clone())}if(this.last=t.clone(),this.has_by_data("BYMONTHDAY")&&this._byDayAndMonthDay(!0),this.last.day>i||0==this.last.day)throw new Error("Malformed values in BYDAY part")}else if(this.has_by_data("BYMONTHDAY")){this.last.day=1;let t=s.daysInMonth(this.last.month,this.last.year);if(e<0)this.last.day=t+e+1;else if(this.by_data.BYMONTHDAY[0]>t){if(!this.next_month()&&!this.next_month()&&!this.next_month())throw new Error("No possible occurrences")}else this.last.day=e}}next(){let t,e=this.last?this.last.clone():null;if(this.rule.count&&this.occurrence_number>=this.rule.count||this.rule.until&&this.last.compare(this.rule.until)>0)return this.completed=!0,null;if(0==this.occurrence_number&&this.last.compare(this.dtstart)>=0)return this.occurrence_number++,this.last;do{switch(t=1,this.rule.freq){case"SECONDLY":this.next_second();break;case"MINUTELY":this.next_minute();break;case"HOURLY":this.next_hour();break;case"DAILY":this.next_day();break;case"WEEKLY":this.next_week();break;case"MONTHLY":t=this.next_month();break;case"YEARLY":this.next_year();break;default:return null}}while(!this.check_contracting_rules()||this.last.compare(this.dtstart)<0||!t);if(0==this.last.compare(e))throw new Error("Same occurrence found twice, protecting you from death by recursion");return this.rule.until&&this.last.compare(this.rule.until)>0?(this.completed=!0,null):(this.occurrence_number++,this.last)}next_second(){return this.next_generic("BYSECOND","SECONDLY","second","minute")}increment_second(t){return this.increment_generic(t,"second",60,"minute")}next_minute(){return this.next_generic("BYMINUTE","MINUTELY","minute","hour","next_second")}increment_minute(t){return this.increment_generic(t,"minute",60,"hour")}next_hour(){return this.next_generic("BYHOUR","HOURLY","hour","monthday","next_minute")}increment_hour(t){this.increment_generic(t,"hour",24,"monthday")}next_day(){let t="DAILY"==this.rule.freq;return 0==this.next_hour()||(t?this.increment_monthday(this.rule.interval):this.increment_monthday(1)),0}next_week(){let t=0;if(0==this.next_weekday_by_week())return t;if(this.has_by_data("BYWEEKNO")){this.by_indices.BYWEEKNO++,this.by_indices.BYWEEKNO==this.by_data.BYWEEKNO.length&&(this.by_indices.BYWEEKNO=0,t=1),this.last.month=1,this.last.day=1;let e=this.by_data.BYWEEKNO[this.by_indices.BYWEEKNO];this.last.day+=7*e,t&&this.increment_year(1)}else this.increment_monthday(7*this.rule.interval);return t}normalizeByMonthDayRules(t,e,i){let r,n=s.daysInMonth(e,t),a=[],o=0,l=i.length;for(;on)){if(r<0)r=n+(r+1);else if(0===r)continue;-1===a.indexOf(r)&&a.push(r)}return a.sort((function(t,e){return t-e}))}_byDayAndMonthDay(t){let e,i,r,n,a=this.by_data.BYDAY,o=0,l=a.length,h=0,u=this,c=this.last.day;function d(){for(n=s.daysInMonth(u.last.month,u.last.year),e=u.normalizeByMonthDayRules(u.last.year,u.last.month,u.by_data.BYMONTHDAY),r=e.length;e[o]<=c&&(!t||e[o]!=c)&&on){m();continue}let t=e[o++];if(t>=i){c=t;for(let t=0;ti&&(this.last.day=1,this.increment_month(),this.is_day_in_byday(this.last)?this.has_by_data("BYSETPOS")&&!this.check_set_position(1)||(t=1):t=0)}else if(this.has_by_data("BYMONTHDAY")){this.by_indices.BYMONTHDAY++,this.by_indices.BYMONTHDAY>=this.by_data.BYMONTHDAY.length&&(this.by_indices.BYMONTHDAY=0,this.increment_month());let e=s.daysInMonth(this.last.month,this.last.year),i=this.by_data.BYMONTHDAY[this.by_indices.BYMONTHDAY];i<0&&(i=e+i+1),i>e?(this.last.day=1,t=this.is_day_in_byday(this.last)):this.last.day=i}else{this.increment_month();let e=s.daysInMonth(this.last.month,this.last.year);this.by_data.BYMONTHDAY[0]>e?t=0:this.last.day=this.by_data.BYMONTHDAY[0]}return t}next_weekday_by_week(){let t=0;if(0==this.next_hour())return t;if(!this.has_by_data("BYDAY"))return 1;for(;;){let e=new s;this.by_indices.BYDAY++,this.by_indices.BYDAY==Object.keys(this.by_data.BYDAY).length&&(this.by_indices.BYDAY=0,t=1);let i=this.by_data.BYDAY[this.by_indices.BYDAY],r=this.ruleDayOfWeek(i)[1];r-=this.rule.wkst,r<0&&(r+=7),e.year=this.last.year,e.month=this.last.month,e.day=this.last.day;let n=e.startDoyWeek(this.rule.wkst);if(r+n<1&&!t)continue;let a=s.fromDayOfYear(n+r,this.last.year);return this.last.year=a.year,this.last.month=a.month,this.last.day=a.day,t}}next_year(){if(0==this.next_hour())return 0;if(++this.days_index==this.days.length){this.days_index=0;do{this.increment_year(this.rule.interval),this.expand_year_days(this.last.year)}while(0==this.days.length)}return this._nextByYearDay(),1}_nextByYearDay(){let t=this.days[this.days_index],e=this.last.year;t<1&&(t+=1,e+=1);let i=s.fromDayOfYear(t,e);this.last.day=i.day,this.last.month=i.month}ruleDayOfWeek(t,e){let i=t.match(/([+-]?[0-9])?(MO|TU|WE|TH|FR|SA|SU)/);if(i){return[parseInt(i[1]||0,10),t=B.icalDayToNumericDay(i[2],e)]}return[0,0]}next_generic(t,e,i,r,n){let s=t in this.by_data,a=this.rule.freq==e,o=0;if(n&&0==this[n]())return o;if(s){this.by_indices[t]++;let e=this.by_data[t];this.by_indices[t]==e.length&&(this.by_indices[t]=0,o=1),this.last[i]=e[this.by_indices[t]]}else a&&this["increment_"+i](this.rule.interval);return s&&o&&a&&this["increment_"+r](1),o}increment_monthday(t){for(let e=0;et&&(this.last.day-=t,this.increment_month())}}increment_month(){if(this.last.day=1,this.has_by_data("BYMONTH"))this.by_indices.BYMONTH++,this.by_indices.BYMONTH==this.by_data.BYMONTH.length&&(this.by_indices.BYMONTH=0,this.increment_year(1)),this.last.month=this.by_data.BYMONTH[this.by_indices.BYMONTH];else{"MONTHLY"==this.rule.freq?this.last.month+=this.rule.interval:this.last.month++,this.last.month--;let t=A(this.last.month/12);this.last.month%=12,this.last.month++,0!=t&&this.increment_year(t)}}increment_year(t){this.last.year+=t}increment_generic(t,e,i,r){this.last[e]+=t;let n=A(this.last[e]/i);this.last[e]%=i,0!=n&&this["increment_"+r](n)}has_by_data(t){return t in this.rule.parts}expand_year_days(t){let e=new s;this.days=[];let i={},r=["BYDAY","BYWEEKNO","BYMONTHDAY","BYMONTH","BYYEARDAY"];for(let t of r)t in this.rule.parts&&(i[t]=this.rule.parts[t]);if("BYMONTH"in i&&"BYWEEKNO"in i){let r=1,n={};e.year=t,e.isDate=!0;for(let i=0;i0?(e=h+7*(s-1),e<=r&&this.days.push(a+e)):(e=u+7*(s+1),e>0&&this.days.push(a+e))}}this.days.sort((function(t,e){return t-e}))}else if(2==n&&"BYDAY"in i&&"BYMONTHDAY"in i){let e=this.expand_by_day(t);for(let i of e){let e=s.fromDayOfYear(i,t);this.by_data.BYMONTHDAY.indexOf(e.day)>=0&&this.days.push(i)}}else if(3==n&&"BYDAY"in i&&"BYMONTHDAY"in i&&"BYMONTH"in i){let e=this.expand_by_day(t);for(let i of e){let e=s.fromDayOfYear(i,t);this.by_data.BYMONTH.indexOf(e.month)>=0&&this.by_data.BYMONTHDAY.indexOf(e.day)>=0&&this.days.push(i)}}else if(2==n&&"BYDAY"in i&&"BYWEEKNO"in i){let e=this.expand_by_day(t);for(let i of e){let e=s.fromDayOfYear(i,t).weekNumber(this.rule.wkst);this.by_data.BYWEEKNO.indexOf(e)&&this.days.push(i)}}else 3==n&&"BYDAY"in i&&"BYWEEKNO"in i&&"BYMONTHDAY"in i||(this.days=1==n&&"BYYEARDAY"in i?this.days.concat(this.by_data.BYYEARDAY):[]);return 0}expand_by_day(t){let e=[],i=this.last.clone();i.year=t,i.month=1,i.day=1,i.isDate=!0;let r=i.dayOfWeek();i.month=12,i.day=31,i.isDate=!0;let n=i.dayOfWeek(),s=i.dayOfYear();for(let t of this.by_data.BYDAY){let i=this.ruleDayOfWeek(t),a=i[0],o=i[1];if(0==a){for(let t=(o+7-r)%7+1;t<=s;t+=7)e.push(t)}else if(a>0){let t;t=o>=r?o-r+1:o-r+8,e.push(t+7*(a-1))}else{let t;a=-a,t=o<=n?s-n+o:s-n+o-7,e.push(t-7*(a-1))}}return e}is_day_in_byday(t){if(this.by_data.BYDAY)for(let e of this.by_data.BYDAY){let i=this.ruleDayOfWeek(e),r=i[0],n=i[1],s=t.dayOfWeek();if(0==r&&n==s||t.nthWeekDay(n,r)==t.day)return 1}return 0}check_set_position(t){if(this.has_by_data("BYSETPOS")){return-1!==this.by_data.BYSETPOS.indexOf(t)}return!1}sort_byday_rules(t){for(let e=0;ethis.ruleDayOfWeek(t[e],this.rule.wkst)[1]){let r=t[e];t[e]=t[i],t[i]=r}}}check_contract_restriction(t,e){let i=C._indexMap[t],r=C._expandMap[this.rule.freq][i],n=!1;if(t in this.by_data&&r==C.CONTRACT){let i=this.by_data[t];for(let t of i)if(t==e){n=!0;break}}else n=!0;return n}check_contracting_rules(){let t=this.last.dayOfWeek(),e=this.last.weekNumber(this.rule.wkst),i=this.last.dayOfYear();return this.check_contract_restriction("BYSECOND",this.last.second)&&this.check_contract_restriction("BYMINUTE",this.last.minute)&&this.check_contract_restriction("BYHOUR",this.last.hour)&&this.check_contract_restriction("BYDAY",B.numericDayToIcalDay(t))&&this.check_contract_restriction("BYWEEKNO",e)&&this.check_contract_restriction("BYMONTHDAY",this.last.day)&&this.check_contract_restriction("BYMONTH",this.last.month)&&this.check_contract_restriction("BYYEARDAY",i)}setup_defaults(t,e,i){let r=C._indexMap[t];return C._expandMap[this.rule.freq][r]!=C.CONTRACT&&(t in this.by_data||(this.by_data[t]=[i]),this.rule.freq!=e)?this.by_data[t][0]:i}toJSON(){let t=Object.create(null);return t.initialized=this.initialized,t.rule=this.rule.toJSON(),t.dtstart=this.dtstart.toJSON(),t.by_data=this.by_data,t.days=this.days,t.last=this.last.toJSON(),t.by_indices=this.by_indices,t.occurrence_number=this.occurrence_number,t}}const w=/^(SU|MO|TU|WE|TH|FR|SA)$/,x=/^([+-])?(5[0-3]|[1-4][0-9]|[1-9])?(SU|MO|TU|WE|TH|FR|SA)$/,v={SU:s.SUNDAY,MO:s.MONDAY,TU:s.TUESDAY,WE:s.WEDNESDAY,TH:s.THURSDAY,FR:s.FRIDAY,SA:s.SATURDAY},N=Object.fromEntries(Object.entries(v).map((t=>t.reverse()))),I=["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"];class B{static fromString(t){let e=this._stringToData(t,!1);return new B(e)}static fromData(t){return new B(t)}static _stringToData(t,e){let i=Object.create(null),r=t.split(";"),n=r.length;for(let t=0;t7&&(i-=7),N[i]}constructor(t){this.wrappedJSObject=this,this.parts={},t&&"object"==typeof t&&this.fromData(t)}parts=null;interval=1;wkst=s.MONDAY;until=null;count=null;freq=null;icalclass="icalrecur";icaltype="recur";iterator(t){return new C({rule:this,dtstart:t})}clone(){return new B(this.toJSON())}isFinite(){return!(!this.count&&!this.until)}isByCount(){return!(!this.count||this.until)}addComponent(t,e){let i=t.toUpperCase();i in this.parts?this.parts[i].push(e):this.parts[i]=[e]}setComponent(t,e){this.parts[t.toUpperCase()]=e.slice()}getComponent(t){let e=t.toUpperCase();return e in this.parts?this.parts[e].slice():[]}getNextOccurrence(t,e){let i,r=this.iterator(t);do{i=r.next()}while(i&&i.compare(e)<=0);return i&&e.zone&&(i.zone=e.zone),i}fromData(t){for(let e in t){let i=e.toUpperCase();i in L?Array.isArray(t[e])?this.parts[i]=t[e]:this.parts[i]=[t[e]]:this[e]=t[e]}this.interval&&"number"!=typeof this.interval&&M.INTERVAL(this.interval,this),this.wkst&&"number"!=typeof this.wkst&&(this.wkst=B.icalDayToNumericDay(this.wkst)),!this.until||this.until instanceof s||(this.until=s.fromString(this.until))}toJSON(){let t=Object.create(null);t.freq=this.freq,this.count&&(t.count=this.count),this.interval>1&&(t.interval=this.interval);for(let[e,i]of Object.entries(this.parts))Array.isArray(i)&&1==i.length?t[e.toLowerCase()]=i[0]:t[e.toLowerCase()]=D(i);return this.until&&(t.until=this.until.toString()),"wkst"in this&&this.wkst!==s.DEFAULT_WEEK_START&&(t.wkst=B.numericDayToIcalDay(this.wkst)),t}toString(){let t="FREQ="+this.freq;this.count&&(t+=";COUNT="+this.count),this.interval>1&&(t+=";INTERVAL="+this.interval);for(let[e,i]of Object.entries(this.parts))t+=";"+e+"="+i;return this.until&&(t+=";UNTIL="+this.until.toICALString()),"wkst"in this&&this.wkst!==s.DEFAULT_WEEK_START&&(t+=";WKST="+B.numericDayToIcalDay(this.wkst)),t}}function z(t,e,i,r){let n=r;if("+"===r[0]&&(n=r.slice(1)),n=p(n),void 0!==e&&r '+e);if(void 0!==i&&r>i)throw new Error(t+': invalid value "'+r+'" must be < '+e);return n}const M={FREQ:function(t,e,i){if(-1===I.indexOf(t))throw new Error('invalid frequency "'+t+'" expected: "'+I.join(", ")+'"');e.freq=t},COUNT:function(t,e,i){e.count=p(t)},INTERVAL:function(t,e,i){e.interval=p(t),e.interval<1&&(e.interval=1)},UNTIL:function(t,e,i){t.length>10?e.until=ut.icalendar.value["date-time"].fromICAL(t):e.until=ut.icalendar.value.date.fromICAL(t),i||(e.until=s.fromString(e.until))},WKST:function(t,e,i){if(!w.test(t))throw new Error('invalid WKST value "'+t+'"');e.wkst=B.icalDayToNumericDay(t)}},L={BYSECOND:z.bind(void 0,"BYSECOND",0,60),BYMINUTE:z.bind(void 0,"BYMINUTE",0,59),BYHOUR:z.bind(void 0,"BYHOUR",0,23),BYDAY:function(t){if(x.test(t))return t;throw new Error('invalid BYDAY value "'+t+'"')},BYMONTHDAY:z.bind(void 0,"BYMONTHDAY",-31,31),BYYEARDAY:z.bind(void 0,"BYYEARDAY",-366,366),BYWEEKNO:z.bind(void 0,"BYWEEKNO",-53,53),BYMONTH:z.bind(void 0,"BYMONTH",1,12),BYSETPOS:z.bind(void 0,"BYSETPOS",-366,366)};class k{static fromString(t,e){let i=t.split("/");if(2!==i.length)throw new Error('Invalid string value: "'+t+'" must contain a "/" char.');let n={start:s.fromDateTimeString(i[0],e)},a=i[1];return r.isValueString(a)?n.duration=r.fromString(a):n.end=s.fromDateTimeString(a,e),new k(n)}static fromData(t){return new k(t)}static fromJSON(t,e,i){function n(t,e){return i?s.fromString(t,e):s.fromDateTimeString(t,e)}return r.isValueString(t[1])?k.fromData({start:n(t[0],e),duration:r.fromString(t[1])}):k.fromData({start:n(t[0],e),end:n(t[1],e)})}constructor(t){if(this.wrappedJSObject=this,t&&"start"in t){if(t.start&&!(t.start instanceof s))throw new TypeError(".start must be an instance of ICAL.Time");this.start=t.start}if(t&&t.end&&t.duration)throw new Error("cannot accept both end and duration");if(t&&"end"in t){if(t.end&&!(t.end instanceof s))throw new TypeError(".end must be an instance of ICAL.Time");this.end=t.end}if(t&&"duration"in t){if(t.duration&&!(t.duration instanceof r))throw new TypeError(".duration must be an instance of ICAL.Duration");this.duration=t.duration}}start=null;end=null;duration=null;icalclass="icalperiod";icaltype="period";clone(){return k.fromData({start:this.start?this.start.clone():null,end:this.end?this.end.clone():null,duration:this.duration?this.duration.clone():null})}getDuration(){return this.duration?this.duration:this.end.subtractDate(this.start)}getEnd(){if(this.end)return this.end;{let t=this.start.clone();return t.addDuration(this.duration),t}}toString(){return this.start+"/"+(this.end||this.duration)}toJSON(){return[this.start.toString(),(this.end||this.duration).toString()]}toICALString(){return this.start.toICALString()+"/"+(this.end||this.duration).toICALString()}}const P=/\\\\|\\,|\\[Nn]/g,U=/\\|,|\n/g;function j(t,e){return{matches:/.*/,fromICAL:function(e,i){return function(t,e,i){if(-1===t.indexOf("\\"))return t;i&&(e=new RegExp(e.source+"|\\\\"+i,e.flags));return t.replace(e,X)}(e,t,i)},toICAL:function(t,i){let r=e;return i&&(r=new RegExp(r.source+"|"+i,r.flags)),t.replace(r,(function(t){switch(t){case"\\":return"\\\\";case";":return"\\;";case",":return"\\,";case"\n":return"\\n";default:return t}}))}}}const V={defaultType:"text"},H={defaultType:"text",multiValue:","},R={defaultType:"text",structuredValue:";"},W={defaultType:"integer"},F={defaultType:"date-time",allowedTypes:["date-time","date"]},K={defaultType:"date-time"},q={defaultType:"uri"},J={defaultType:"utc-offset"},Z={defaultType:"recur"},G={defaultType:"date-and-or-time",allowedTypes:["date-time","date","text"]};function X(t){switch(t){case"\\\\":return"\\";case"\\;":return";";case"\\,":return",";case"\\n":case"\\N":return"\n";default:return t}}let Q={categories:H,url:q,version:V,uid:V},$={boolean:{values:["TRUE","FALSE"],fromICAL:function(t){return"TRUE"===t},toICAL:function(t){return t?"TRUE":"FALSE"}},float:{matches:/^[+-]?\d+\.\d+$/,fromICAL:function(t){let e=parseFloat(t);return f(e)?0:e},toICAL:function(t){return String(t)}},integer:{fromICAL:function(t){let e=parseInt(t);return f(e)?0:e},toICAL:function(t){return String(t)}},"utc-offset":{toICAL:function(t){return t.length<7?t.slice(0,3)+t.slice(4,6):t.slice(0,3)+t.slice(4,6)+t.slice(7,9)},fromICAL:function(t){return t.length<6?t.slice(0,3)+":"+t.slice(3,5):t.slice(0,3)+":"+t.slice(3,5)+":"+t.slice(5,7)},decorate:function(t){return S.fromString(t)},undecorate:function(t){return t.toString()}}};const tt=O($,{text:j(/\\\\|\\;|\\,|\\[Nn]/g,/\\|;|,|\n/g),uri:{},binary:{decorate:function(e){return t.fromString(e)},undecorate:function(t){return t.toString()}},"cal-address":{},date:{decorate:function(t,e){return ht.strict?s.fromDateString(t,e):s.fromString(t,e)},undecorate:function(t){return t.toString()},fromICAL:function(t){return!ht.strict&&t.length>=15?tt["date-time"].fromICAL(t):t.slice(0,4)+"-"+t.slice(4,6)+"-"+t.slice(6,8)},toICAL:function(t){let e=t.length;return 10==e?t.slice(0,4)+t.slice(5,7)+t.slice(8,10):e>=19?tt["date-time"].toICAL(t):t}},"date-time":{fromICAL:function(t){if(ht.strict||8!=t.length){let e=t.slice(0,4)+"-"+t.slice(4,6)+"-"+t.slice(6,8)+"T"+t.slice(9,11)+":"+t.slice(11,13)+":"+t.slice(13,15);return t[15]&&"Z"===t[15]&&(e+="Z"),e}return tt.date.fromICAL(t)},toICAL:function(t){let e=t.length;if(10!=e||ht.strict){if(e>=19){let e=t.slice(0,4)+t.slice(5,7)+t.slice(8,13)+t.slice(14,16)+t.slice(17,19);return t[19]&&"Z"===t[19]&&(e+="Z"),e}return t}return tt.date.toICAL(t)},decorate:function(t,e){return ht.strict?s.fromDateTimeString(t,e):s.fromString(t,e)},undecorate:function(t){return t.toString()}},duration:{decorate:function(t){return r.fromString(t)},undecorate:function(t){return t.toString()}},period:{fromICAL:function(t){let e=t.split("/");return e[0]=tt["date-time"].fromICAL(e[0]),r.isValueString(e[1])||(e[1]=tt["date-time"].fromICAL(e[1])),e},toICAL:function(t){return t=t.slice(),ht.strict||10!=t[0].length?t[0]=tt["date-time"].toICAL(t[0]):t[0]=tt.date.toICAL(t[0]),r.isValueString(t[1])||(ht.strict||10!=t[1].length?t[1]=tt["date-time"].toICAL(t[1]):t[1]=tt.date.toICAL(t[1])),t.join("/")},decorate:function(t,e){return k.fromJSON(t,e,!ht.strict)},undecorate:function(t){return t.toJSON()}},recur:{fromICAL:function(t){return B._stringToData(t,!0)},toICAL:function(t){let e="";for(let[i,r]of Object.entries(t))"until"==i?r=r.length>10?tt["date-time"].toICAL(r):tt.date.toICAL(r):"wkst"==i?"number"==typeof r&&(r=B.numericDayToIcalDay(r)):Array.isArray(r)&&(r=r.join(",")),e+=i.toUpperCase()+"="+r+";";return e.slice(0,Math.max(0,e.length-1))},decorate:function(t){return B.fromData(t)},undecorate:function(t){return t.toJSON()}},time:{fromICAL:function(t){if(t.length<6)return t;let e=t.slice(0,2)+":"+t.slice(2,4)+":"+t.slice(4,6);return"Z"===t[6]&&(e+="Z"),e},toICAL:function(t){if(t.length<8)return t;let e=t.slice(0,2)+t.slice(3,5)+t.slice(6,8);return"Z"===t[8]&&(e+="Z"),e}}});let et=O(Q,{action:V,attach:{defaultType:"uri"},attendee:{defaultType:"cal-address"},calscale:V,class:V,comment:V,completed:K,contact:V,created:K,description:V,dtend:F,dtstamp:K,dtstart:F,due:F,duration:{defaultType:"duration"},exdate:{defaultType:"date-time",allowedTypes:["date-time","date"],multiValue:","},exrule:Z,freebusy:{defaultType:"period",multiValue:","},geo:{defaultType:"float",structuredValue:";"},"last-modified":K,location:V,method:V,organizer:{defaultType:"cal-address"},"percent-complete":W,priority:W,prodid:V,"related-to":V,repeat:W,rdate:{defaultType:"date-time",allowedTypes:["date-time","date","period"],multiValue:",",detectType:function(t){return-1!==t.indexOf("/")?"period":-1===t.indexOf("T")?"date":"date-time"}},"recurrence-id":F,resources:H,"request-status":R,rrule:Z,sequence:W,status:V,summary:V,transp:V,trigger:{defaultType:"duration",allowedTypes:["duration","date-time"]},tzoffsetfrom:J,tzoffsetto:J,tzurl:q,tzid:V,tzname:V});const it=O($,{text:j(P,U),uri:j(P,U),date:{decorate:function(t){return E.fromDateAndOrTimeString(t,"date")},undecorate:function(t){return t.toString()},fromICAL:function(t){return 8==t.length?tt.date.fromICAL(t):"-"==t[0]&&6==t.length?t.slice(0,4)+"-"+t.slice(4):t},toICAL:function(t){return 10==t.length?tt.date.toICAL(t):"-"==t[0]&&7==t.length?t.slice(0,4)+t.slice(5):t}},time:{decorate:function(t){return E.fromDateAndOrTimeString("T"+t,"time")},undecorate:function(t){return t.toString()},fromICAL:function(t){let e=it.time._splitZone(t,!0),i=e[0],r=e[1];return 6==r.length?r=r.slice(0,2)+":"+r.slice(2,4)+":"+r.slice(4,6):4==r.length&&"-"!=r[0]?r=r.slice(0,2)+":"+r.slice(2,4):5==r.length&&(r=r.slice(0,3)+":"+r.slice(3,5)),5!=i.length||"-"!=i[0]&&"+"!=i[0]||(i=i.slice(0,3)+":"+i.slice(3)),r+i},toICAL:function(t){let e=it.time._splitZone(t),i=e[0],r=e[1];return 8==r.length?r=r.slice(0,2)+r.slice(3,5)+r.slice(6,8):5==r.length&&"-"!=r[0]?r=r.slice(0,2)+r.slice(3,5):6==r.length&&(r=r.slice(0,3)+r.slice(4,6)),6!=i.length||"-"!=i[0]&&"+"!=i[0]||(i=i.slice(0,3)+i.slice(4)),r+i},_splitZone:function(t,e){let i,r,n=t.length-1,s=t.length-(e?5:6),a=t[s];return"Z"==t[n]?(i=t[n],r=t.slice(0,Math.max(0,n))):t.length>6&&("-"==a||"+"==a)?(i=t.slice(s),r=t.slice(0,Math.max(0,s))):(i="",r=t),[i,r]}},"date-time":{decorate:function(t){return E.fromDateAndOrTimeString(t,"date-time")},undecorate:function(t){return t.toString()},fromICAL:function(t){return it["date-and-or-time"].fromICAL(t)},toICAL:function(t){return it["date-and-or-time"].toICAL(t)}},"date-and-or-time":{decorate:function(t){return E.fromDateAndOrTimeString(t,"date-and-or-time")},undecorate:function(t){return t.toString()},fromICAL:function(t){let e=t.split("T");return(e[0]?it.date.fromICAL(e[0]):"")+(e[1]?"T"+it.time.fromICAL(e[1]):"")},toICAL:function(t){let e=t.split("T");return it.date.toICAL(e[0])+(e[1]?"T"+it.time.toICAL(e[1]):"")}},timestamp:tt["date-time"],"language-tag":{matches:/^[a-zA-Z0-9-]+$/},"phone-number":{fromICAL:function(t){return Array.from(t).filter((function(t){return"\\"===t?void 0:t})).join("")},toICAL:function(t){return Array.from(t).map((function(t){return","===t||";"===t?"\\"+t:t})).join("")}}});let rt=O(Q,{adr:{defaultType:"text",structuredValue:";",multiValue:","},anniversary:G,bday:G,caladruri:q,caluri:q,clientpidmap:R,email:V,fburl:q,fn:V,gender:R,geo:q,impp:q,key:q,kind:V,lang:{defaultType:"language-tag"},logo:q,member:q,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:H,note:V,org:{defaultType:"text",structuredValue:";"},photo:q,related:q,rev:{defaultType:"timestamp"},role:V,sound:q,source:q,tel:{defaultType:"uri",allowedTypes:["uri","text"]},title:V,tz:{defaultType:"text",allowedTypes:["text","utc-offset","uri"]},xml:V}),nt=O($,{binary:tt.binary,date:it.date,"date-time":it["date-time"],"phone-number":it["phone-number"],uri:tt.uri,text:tt.text,time:tt.time,vcard:tt.text,"utc-offset":{toICAL:function(t){return t.slice(0,7)},fromICAL:function(t){return t.slice(0,7)},decorate:function(t){return S.fromString(t)},undecorate:function(t){return t.toString()}}}),st=O(Q,{fn:V,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:H,photo:{defaultType:"binary",allowedTypes:["binary","uri"]},bday:{defaultType:"date-time",allowedTypes:["date-time","date"],detectType:function(t){return-1===t.indexOf("T")?"date":"date-time"}},adr:{defaultType:"text",structuredValue:";",multiValue:","},label:V,tel:{defaultType:"phone-number"},email:V,mailer:V,tz:{defaultType:"utc-offset",allowedTypes:["utc-offset","text"]},geo:{defaultType:"float",structuredValue:";"},title:V,role:V,logo:{defaultType:"binary",allowedTypes:["binary","uri"]},agent:{defaultType:"vcard",allowedTypes:["vcard","text","uri"]},org:R,note:H,prodid:V,rev:{defaultType:"date-time",allowedTypes:["date-time","date"],detectType:function(t){return-1===t.indexOf("T")?"date":"date-time"}},"sort-string":V,sound:{defaultType:"binary",allowedTypes:["binary","uri"]},class:V,key:{defaultType:"binary",allowedTypes:["binary","text"]}}),at={value:tt,param:{cutype:{values:["INDIVIDUAL","GROUP","RESOURCE","ROOM","UNKNOWN"],allowXName:!0,allowIanaToken:!0},"delegated-from":{valueType:"cal-address",multiValue:",",multiValueSeparateDQuote:!0},"delegated-to":{valueType:"cal-address",multiValue:",",multiValueSeparateDQuote:!0},encoding:{values:["8BIT","BASE64"]},fbtype:{values:["FREE","BUSY","BUSY-UNAVAILABLE","BUSY-TENTATIVE"],allowXName:!0,allowIanaToken:!0},member:{valueType:"cal-address",multiValue:",",multiValueSeparateDQuote:!0},partstat:{values:["NEEDS-ACTION","ACCEPTED","DECLINED","TENTATIVE","DELEGATED","COMPLETED","IN-PROCESS"],allowXName:!0,allowIanaToken:!0},range:{values:["THISANDFUTURE"]},related:{values:["START","END"]},reltype:{values:["PARENT","CHILD","SIBLING"],allowXName:!0,allowIanaToken:!0},role:{values:["REQ-PARTICIPANT","CHAIR","OPT-PARTICIPANT","NON-PARTICIPANT"],allowXName:!0,allowIanaToken:!0},rsvp:{values:["TRUE","FALSE"]},"sent-by":{valueType:"cal-address"},tzid:{matches:/^\//},value:{values:["binary","boolean","cal-address","date","date-time","duration","float","integer","period","recur","text","time","uri","utc-offset"],allowXName:!0,allowIanaToken:!0}},property:et,propertyGroups:!1},ot={value:it,param:{type:{valueType:"text",multiValue:","},value:{values:["text","uri","date","time","date-time","date-and-or-time","timestamp","boolean","integer","float","utc-offset","language-tag"],allowXName:!0,allowIanaToken:!0}},property:rt,propertyGroups:!0},lt={value:nt,param:{type:{valueType:"text",multiValue:","},value:{values:["text","uri","date","date-time","phone-number","time","boolean","integer","float","utc-offset","vcard","binary"],allowXName:!0,allowIanaToken:!0}},property:st,propertyGroups:!0};const ht={strict:!0,defaultSet:at,defaultType:"unknown",components:{vcard:ot,vcard3:lt,vevent:at,vtodo:at,vjournal:at,valarm:at,vtimezone:at,daylight:at,standard:at},icalendar:at,vcard:ot,vcard3:lt,getDesignSet:function(t){return t&&t in ht.components?ht.components[t]:ht.defaultSet}};var ut=ht;const ct="\r\n",dt="unknown",mt={'"':"^'","\n":"^n","^":"^^"};function ft(t){"string"==typeof t[0]&&(t=[t]);let e=0,i=t.length,r="";for(;e0&&("version"!==t[1][0][0]||"4.0"!==t[1][0][3])&&(o="vcard3"),e=e||ut.getDesignSet(o);s0&&"object"==typeof t[0]&&"icaltype"in t[0]&&this.resetType(t[0].icaltype),this.isDecorated)for(;i=0;s--)i&&n[s][0]!==i||this._removeObjectByIndex(t,r,s)}addSubcomponent(t){this._components||(this._components=[],this._hydratedComponentCount=0),t.parent&&t.parent.removeSubcomponent(t);let e=this.jCal[2].push(t.jCal);return this._components[e-1]=t,this._hydratedComponentCount++,t.parent=this,t}removeSubcomponent(t){let e=this._removeObject(2,"_components",t);return e&&this._hydratedComponentCount--,e}removeAllSubcomponents(t){let e=this._removeAllObjects(2,"_components",t);return this._hydratedComponentCount=0,e}addProperty(t){if(!(t instanceof pt))throw new TypeError("must be instance of ICAL.Property");this._properties||(this._properties=[],this._hydratedPropertyCount=0),t.parent&&t.parent.removeProperty(t);let e=this.jCal[1].push(t.jCal);return this._properties[e-1]=t,this._hydratedPropertyCount++,t.parent=this,t}addPropertyWithValue(t,e){let i=new pt(t);return i.setValue(e),this.addProperty(i),i}updatePropertyWithValue(t,e){let i=this.getFirstProperty(t);return i?i.setValue(e):i=this.addPropertyWithValue(t,e),i}removeProperty(t){let e=this._removeObject(1,"_properties",t);return e&&this._hydratedPropertyCount--,e}removeAllProperties(t){let e=this._removeAllObjects(1,"_properties",t);return this._hydratedPropertyCount=0,e}toJSON(){return this.jCal}toString(){return ft.component(this.jCal,this._designSet)}getTimeZoneByID(t){if(this.parent)return this.parent.getTimeZoneByID(t);if(!this._timezoneCache)return null;if(this._timezoneCache.has(t))return this._timezoneCache.get(t);const e=this.getAllSubcomponents("vtimezone");for(const i of e)if(i.getFirstProperty("tzid").getFirstValue()===t){const e=new c({component:i,tzid:t});return this._timezoneCache.set(t,e),e}return null}}class _t{constructor(t){this.ruleDates=[],this.exDates=[],this.fromData(t)}complete=!1;ruleIterators=null;ruleDates=null;exDates=null;ruleDateInc=0;exDateInc=0;exDate=null;ruleDate=null;dtstart=null;last=null;fromData(t){let e=y(t.dtstart,s);if(!e)throw new Error(".dtstart (ICAL.Time) must be given");if(this.dtstart=e,t.component)this._init(t.component);else{if(this.last=y(t.last,s)||e.clone(),!t.ruleIterators)throw new Error(".ruleIterators or .component must be given");this.ruleIterators=t.ruleIterators.map((function(t){return y(t,C)})),this.ruleDateInc=t.ruleDateInc,this.exDateInc=t.exDateInc,t.ruleDates&&(this.ruleDates=t.ruleDates.map((t=>y(t,s))),this.ruleDate=this.ruleDates[this.ruleDateInc]),t.exDates&&(this.exDates=t.exDates.map((t=>y(t,s))),this.exDate=this.exDates[this.exDateInc]),void 0!==t.complete&&(this.complete=t.complete)}}next(){let t,e,i,r=0;for(;;){if(r++>500)throw new Error("max tries have occurred, rule may be impossible to fulfill.");if(e=this.ruleDate,t=this._nextRecurrenceIter(this.last),!e&&!t){this.complete=!0;break}if((!e||t&&e.compare(t.last)>0)&&(e=t.last.clone(),t.next()),this.ruleDate===e&&this._nextRuleDay(),this.last=e,!this.exDate||(i=this.exDate.compare(this.last),i<0&&this._nextExDay(),0!==i))return this.last;this._nextExDay()}}toJSON(){function t(t){return t.toJSON()}let e=Object.create(null);return e.ruleIterators=this.ruleIterators.map(t),this.ruleDates&&(e.ruleDates=this.ruleDates.map(t)),this.exDates&&(e.exDates=this.exDates.map(t)),e.ruleDateInc=this.ruleDateInc,e.exDateInc=this.exDateInc,e.last=this.last.toJSON(),e.dtstart=this.dtstart.toJSON(),e.complete=this.complete,e}_extractDates(t,e){let i=[],r=t.getAllProperties(e);for(let t=0,e=r.length;tt.compare(e)));i.splice(t,0,e)}return i}_init(t){if(this.ruleIterators=[],this.last=this.dtstart.clone(),!t.hasProperty("rdate")&&!t.hasProperty("rrule")&&!t.hasProperty("recurrence-id"))return this.ruleDate=this.last.clone(),void(this.complete=!0);if(t.hasProperty("rdate")&&(this.ruleDates=this._extractDates(t,"rdate"),this.ruleDates[0]&&this.ruleDates[0].compare(this.dtstart)<0?(this.ruleDateInc=0,this.last=this.ruleDates[0].clone()):this.ruleDateInc=g(this.ruleDates,this.last,((t,e)=>t.compare(e))),this.ruleDate=this.ruleDates[this.ruleDateInc]),t.hasProperty("rrule")){let e,i,r=t.getAllProperties("rrule"),n=0,s=r.length;for(;nt.compare(e))),this.exDate=this.exDates[this.exDateInc])}_nextExDay(){this.exDate=this.exDates[++this.exDateInc]}_nextRuleDay(){this.ruleDate=this.ruleDates[++this.ruleDateInc]}_nextRecurrenceIter(){let t=this.ruleIterators;if(0===t.length)return null;let e,i,r,n=t.length,s=0;for(;s0)&&(r=e);return r}}class gt{constructor(t,e){t instanceof yt||(e=t,t=null),this.component=t||new yt("vevent"),this._rangeExceptionCache=Object.create(null),this.exceptions=Object.create(null),this.rangeExceptions=[],e&&e.strictExceptions&&(this.strictExceptions=e.strictExceptions),e&&e.exceptions?e.exceptions.forEach(this.relateException,this):this.component.parent&&!this.isRecurrenceException()&&this.component.parent.getAllSubcomponents("vevent").forEach((function(t){t.hasProperty("recurrence-id")&&this.relateException(t)}),this)}static THISANDFUTURE="THISANDFUTURE";exceptions=null;strictExceptions=!1;relateException(t){if(this.isRecurrenceException())throw new Error("cannot relate exception to exceptions");if(t instanceof yt&&(t=new gt(t)),this.strictExceptions&&t.uid!==this.uid)throw new Error("attempted to relate unrelated exception");let e=t.recurrenceId.toString();if(this.exceptions[e]=t,t.modifiesFuture()){let i=[t.recurrenceId.toUnixTime(),e],r=g(this.rangeExceptions,i,Dt);this.rangeExceptions.splice(r,0,i)}}modifiesFuture(){if(!this.component.hasProperty("recurrence-id"))return!1;return this.component.getFirstProperty("recurrence-id").getParameter("range")===gt.THISANDFUTURE}findRangeException(t){if(!this.rangeExceptions.length)return null;let e=t.toUnixTime(),i=g(this.rangeExceptions,[e],Dt);if(i-=1,i<0)return null;let r=this.rangeExceptions[i];return ee[0]?1:e[0]>t[0]?-1:0}var Tt={foldLength:75,debug:!1,newLineChar:"\r\n",Binary:t,Component:yt,ComponentParser:class{constructor(t){void 0===t&&(t={});for(let[e,i]of Object.entries(t))this[e]=i}parseEvent=!0;parseTimezone=!0;oncomplete=function(){};onerror=function(t){};ontimezone=function(t){};onevent=function(t){};process(t){"string"==typeof t&&(t=l(t)),t instanceof yt||(t=new yt(t));let e,i=t.getAllSubcomponents(),r=0,n=i.length;for(;r