This repository has been archived on 2026-08-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openclaw/cron/scripts/node_modules/ical.js/dist/ical.es5.min.cjs
T

6 lines
90 KiB
JavaScript

/* 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 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ICAL=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=u(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,h()?Reflect.construct(e,n||[],u(t).constructor):e.apply(t,n))}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=p(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function o(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(h=function(){return!!t})()}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function f(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,a,s,o=[],u=!0,l=!1;try{if(a=(n=n.call(t)).next,0===e);else for(;!(u=(r=a.call(n)).done)&&(o.push(r.value),o.length!==e);u=!0);}catch(t){l=!0,i=t}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw i}}return o}}(t,e)||p(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function p(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function v(t){var e="function"==typeof Map?new Map:void 0;return v=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(h())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&c(i,n.prototype),i}(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},v(t)}var _=function(){function t(e){r(this,t),o(this,"icaltype","binary"),this.value=e}return a(t,[{key:"decodeValue",value:function(){return this._b64_decode(this.value)}},{key:"setEncodedValue",value:function(t){this.value=this._b64_encode(t)}},{key:"_b64_encode",value:function(t){var e,n,r,i,a,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,l="",h=[];if(!t)return t;do{e=(a=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>18&63,n=a>>12&63,r=a>>6&63,i=63&a,h[u++]=s.charAt(e)+s.charAt(n)+s.charAt(r)+s.charAt(i)}while(o<t.length);l=h.join("");var c=t.length%3;return(c?l.slice(0,c-3):l)+"===".slice(c||3)}},{key:"_b64_decode",value:function(t){var e,n,r,i,a,s,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,l=0,h=[];if(!t)return t;t+="";do{e=(s=o.indexOf(t.charAt(u++))<<18|o.indexOf(t.charAt(u++))<<12|(i=o.indexOf(t.charAt(u++)))<<6|(a=o.indexOf(t.charAt(u++))))>>16&255,n=s>>8&255,r=255&s,h[l++]=64==i?String.fromCharCode(e):64==a?String.fromCharCode(e,n):String.fromCharCode(e,n,r)}while(u<t.length);return h.join("")}},{key:"toString",value:function(){return this.value}}],[{key:"fromString",value:function(e){return new t(e)}}])}(),g=/([PDWHMTS]{1,1})/,D=["weeks","days","hours","minutes","seconds","isNegative"],T=function(){function t(e){r(this,t),o(this,"weeks",0),o(this,"days",0),o(this,"hours",0),o(this,"minutes",0),o(this,"seconds",0),o(this,"isNegative",!1),o(this,"icalclass","icalduration"),o(this,"icaltype","duration"),this.wrappedJSObject=this,this.fromData(e)}return a(t,[{key:"clone",value:function(){return t.fromData(this)}},{key:"toSeconds",value:function(){var t=this.seconds+60*this.minutes+3600*this.hours+86400*this.days+604800*this.weeks;return this.isNegative?-t:t}},{key:"fromSeconds",value:function(t){var e=Math.abs(t);return this.isNegative=t<0,this.days=K(e/86400),this.days%7==0?(this.weeks=this.days/7,this.days=0):this.weeks=0,e-=86400*(this.days+7*this.weeks),this.hours=K(e/3600),e-=3600*this.hours,this.minutes=K(e/60),e-=60*this.minutes,this.seconds=e,this}},{key:"fromData",value:function(t){for(var e=0,n=D;e<n.length;e++){var r=n[e];this[r]=t&&r in t?t[r]:0}}},{key:"reset",value:function(){this.isNegative=!1,this.weeks=0,this.days=0,this.hours=0,this.minutes=0,this.seconds=0}},{key:"compare",value:function(t){var e=this.toSeconds(),n=t.toSeconds();return(e>n)-(e<n)}},{key:"normalize",value:function(){this.fromSeconds(this.toSeconds())}},{key:"toString",value:function(){if(0==this.toSeconds())return"PT0S";var t="";this.isNegative&&(t+="-"),t+="P";var e=!1;return this.weeks?this.days||this.hours||this.minutes||this.seconds?t+=7*this.weeks+this.days+"D":(t+=this.weeks+"W",e=!0):this.days&&(t+=this.days+"D"),e||(this.hours||this.minutes||this.seconds)&&(t+="T",this.hours&&(t+=this.hours+"H"),this.minutes&&(t+=this.minutes+"M"),this.seconds&&(t+=this.seconds+"S")),t}},{key:"toICALString",value:function(){return this.toString()}}],[{key:"fromSeconds",value:function(e){return(new t).fromSeconds(e)}},{key:"isValueString",value:function(t){return"P"===t[0]||"P"===t[1]}},{key:"fromString",value:function(e){for(var n=0,r=Object.create(null),i=0;-1!==(n=e.search(g));){var a=e[n],s=e.slice(0,Math.max(0,n));e=e.slice(n+1),i+=Y(a,s,r)}if(i<2)throw new Error('invalid duration value: Not enough duration components in "'+e+'"');return new t(r)}},{key:"fromData",value:function(e){return new t(e)}}])}();function Y(t,e,n){var r;switch(t){case"P":n.isNegative=!(!e||"-"!==e);break;case"D":r="days";break;case"W":r="weeks";break;case"H":r="hours";break;case"M":r="minutes";break;case"S":r="seconds";break;default:return 0}if(r){if(!e&&0!==e)throw new Error('invalid duration value: Missing number before "'+t+'"');var i=parseInt(e,10);if(P(i))throw new Error('invalid duration value: Invalid number "'+e+'" before "'+t+'"');n[r]=i}return 1}var k,A=function(){function t(e){if(r(this,t),o(this,"start",null),o(this,"end",null),o(this,"duration",null),o(this,"icalclass","icalperiod"),o(this,"icaltype","period"),this.wrappedJSObject=this,e&&"start"in e){if(e.start&&!(e.start instanceof b))throw new TypeError(".start must be an instance of ICAL.Time");this.start=e.start}if(e&&e.end&&e.duration)throw new Error("cannot accept both end and duration");if(e&&"end"in e){if(e.end&&!(e.end instanceof b))throw new TypeError(".end must be an instance of ICAL.Time");this.end=e.end}if(e&&"duration"in e){if(e.duration&&!(e.duration instanceof T))throw new TypeError(".duration must be an instance of ICAL.Duration");this.duration=e.duration}}return a(t,[{key:"clone",value:function(){return t.fromData({start:this.start?this.start.clone():null,end:this.end?this.end.clone():null,duration:this.duration?this.duration.clone():null})}},{key:"getDuration",value:function(){return this.duration?this.duration:this.end.subtractDate(this.start)}},{key:"getEnd",value:function(){if(this.end)return this.end;var t=this.start.clone();return t.addDuration(this.duration),t}},{key:"compare",value:function(t){return t.compare(this.start)<0?1:t.compare(this.getEnd())>0?-1:0}},{key:"toString",value:function(){return this.start+"/"+(this.end||this.duration)}},{key:"toJSON",value:function(){return[this.start.toString(),(this.end||this.duration).toString()]}},{key:"toICALString",value:function(){return this.start.toICALString()+"/"+(this.end||this.duration).toICALString()}}],[{key:"fromString",value:function(e,n){var r=e.split("/");if(2!==r.length)throw new Error('Invalid string value: "'+e+'" must contain a "/" char.');var i={start:b.fromDateTimeString(r[0],n)},a=r[1];return T.isValueString(a)?i.duration=T.fromString(a):i.end=b.fromDateTimeString(a,n),new t(i)}},{key:"fromData",value:function(e){return new t(e)}},{key:"fromJSON",value:function(e,n,r){function i(t,e){return r?b.fromString(t,e):b.fromDateTimeString(t,e)}return T.isValueString(e[1])?t.fromData({start:i(e[0],n),duration:T.fromString(e[1])}):t.fromData({start:i(e[0],n),end:i(e[1],n)})}}])}(),b=function(){function t(e,n){r(this,t),o(this,"icalclass","icaltime"),o(this,"_cachedUnixTime",null),o(this,"zone",null),o(this,"_pendingNormalization",!1),this.wrappedJSObject=this,this._time=Object.create(null),this._time.year=0,this._time.month=1,this._time.day=1,this._time.hour=0,this._time.minute=0,this._time.second=0,this._time.isDate=!1,this.fromData(e,n)}return a(t,[{key:"icaltype",get:function(){return this.isDate?"date":"date-time"}},{key:"year",get:function(){return this._getTimeAttr("year")},set:function(t){this._setTimeAttr("year",t)}},{key:"month",get:function(){return this._getTimeAttr("month")},set:function(t){this._setTimeAttr("month",t)}},{key:"day",get:function(){return this._getTimeAttr("day")},set:function(t){this._setTimeAttr("day",t)}},{key:"hour",get:function(){return this._getTimeAttr("hour")},set:function(t){this._setTimeAttr("hour",t)}},{key:"minute",get:function(){return this._getTimeAttr("minute")},set:function(t){this._setTimeAttr("minute",t)}},{key:"second",get:function(){return this._getTimeAttr("second")},set:function(t){this._setTimeAttr("second",t)}},{key:"isDate",get:function(){return this._getTimeAttr("isDate")},set:function(t){this._setTimeAttr("isDate",t)}},{key:"_getTimeAttr",value:function(t){return this._pendingNormalization&&(this._normalize(),this._pendingNormalization=!1),this._time[t]}},{key:"_setTimeAttr",value:function(t,e){"isDate"===t&&e&&!this._time.isDate&&this.adjust(0,0,0,0),this._cachedUnixTime=null,this._pendingNormalization=!0,this._time[t]=e}},{key:"clone",value:function(){return new t(this._time,this.zone)}},{key:"reset",value:function(){this.fromData(t.epochTime),this.zone=I.utcTimezone}},{key:"resetTo",value:function(t,e,n,r,i,a,s){this.fromData({year:t,month:e,day:n,hour:r,minute:i,second:a,zone:s})}},{key:"fromJSDate",value:function(t,e){return t?e?(this.zone=I.utcTimezone,this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()):(this.zone=I.localTimezone,this.year=t.getFullYear(),this.month=t.getMonth()+1,this.day=t.getDate(),this.hour=t.getHours(),this.minute=t.getMinutes(),this.second=t.getSeconds()):this.reset(),this._cachedUnixTime=null,this}},{key:"fromData",value:function(t,e){if(t)for(var n=0,r=Object.entries(t);n<r.length;n++){var i=f(r[n],2),a=i[0],s=i[1];"icaltype"!==a&&(this[a]=s)}if(e&&(this.zone=e),t&&!("isDate"in t)?this.isDate=!("hour"in t):t&&"isDate"in t&&(this.isDate=t.isDate),t&&"timezone"in t){var o=L.get(t.timezone);this.zone=o||I.localTimezone}return t&&"zone"in t&&(this.zone=t.zone),this.zone||(this.zone=I.localTimezone),this._cachedUnixTime=null,this}},{key:"dayOfWeek",value:function(e){var n=e||t.SUNDAY,r=(this.year<<12)+(this.month<<8)+(this.day<<3)+n;if(r in t._dowCache)return t._dowCache[r];var i=this.day,a=this.month+(this.month<3?12:0),s=this.year-(this.month<3?1:0),o=i+s+K(26*(a+1)/10)+K(s/4);return o=((o+=6*K(s/100)+K(s/400))+7-n)%7+1,t._dowCache[r]=o,o}},{key:"dayOfYear",value:function(){var e=t.isLeapYear(this.year)?1:0;return t.daysInYearPassedMonth[e][this.month-1]+this.day}},{key:"startOfWeek",value:function(e){var n=e||t.SUNDAY,r=this.clone();return r.day-=(this.dayOfWeek()+7-n)%7,r.isDate=!0,r.hour=0,r.minute=0,r.second=0,r}},{key:"endOfWeek",value:function(e){var n=e||t.SUNDAY,r=this.clone();return r.day+=(7-this.dayOfWeek()+n-t.SUNDAY)%7,r.isDate=!0,r.hour=0,r.minute=0,r.second=0,r}},{key:"startOfMonth",value:function(){var t=this.clone();return t.day=1,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}},{key:"endOfMonth",value:function(){var e=this.clone();return e.day=t.daysInMonth(e.month,e.year),e.isDate=!0,e.hour=0,e.minute=0,e.second=0,e}},{key:"startOfYear",value:function(){var t=this.clone();return t.day=1,t.month=1,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}},{key:"endOfYear",value:function(){var t=this.clone();return t.day=31,t.month=12,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}},{key:"startDoyWeek",value:function(e){var n=e||t.SUNDAY,r=this.dayOfWeek()-n;return r<0&&(r+=7),this.dayOfYear()-r}},{key:"getDominicalLetter",value:function(){return t.getDominicalLetter(this.year)}},{key:"nthWeekDay",value:function(e,n){var r,i=t.daysInMonth(this.month,this.year),a=n,s=0,o=this.clone();if(a>=0){o.day=1,0!=a&&a--,s=o.day;var u=e-o.dayOfWeek();u<0&&(u+=7),s+=u,s-=e,r=e}else{o.day=i,a++,(r=o.dayOfWeek()-e)<0&&(r+=7),r=i-r}return s+(r+=7*a)}},{key:"isNthWeekDay",value:function(t,e){var n=this.dayOfWeek();return 0===e&&n===t||this.nthWeekDay(t,e)===this.day}},{key:"weekNumber",value:function(e){var n,r=(this.year<<12)+(this.month<<8)+(this.day<<3)+e;if(r in t._wnCache)return t._wnCache[r];var i=this.clone();i.isDate=!0;var a=this.year;12==i.month&&i.day>25?(n=t.weekOneStarts(a+1,e),i.compare(n)<0?n=t.weekOneStarts(a,e):a++):(n=t.weekOneStarts(a,e),i.compare(n)<0&&(n=t.weekOneStarts(--a,e)));var s=K(i.subtractDate(n).toSeconds()/86400/7)+1;return t._wnCache[r]=s,s}},{key:"addDuration",value:function(t){var e=t.isNegative?-1:1,n=this.second,r=this.minute,i=this.hour,a=this.day;n+=e*t.seconds,r+=e*t.minutes,i+=e*t.hours,a+=e*t.days,a+=7*e*t.weeks,this.second=n,this.minute=r,this.hour=i,this.day=a,this._cachedUnixTime=null}},{key:"subtractDate",value:function(t){var e=this.toUnixTime()+this.utcOffset(),n=t.toUnixTime()+t.utcOffset();return T.fromSeconds(e-n)}},{key:"subtractDateTz",value:function(t){var e=this.toUnixTime(),n=t.toUnixTime();return T.fromSeconds(e-n)}},{key:"compare",value:function(t){if(t instanceof A)return-1*t.compare(this);var e=this.toUnixTime(),n=t.toUnixTime();return e>n?1:n>e?-1:0}},{key:"compareDateOnlyTz",value:function(e,n){var r=this.convertToZone(n),i=e.convertToZone(n),a=0;return 0!=(a=t._cmp_attr(r,i,"year"))||0!=(a=t._cmp_attr(r,i,"month"))||(a=t._cmp_attr(r,i,"day")),a}},{key:"convertToZone",value:function(t){var e=this.clone(),n=this.zone.tzid==t.tzid;return this.isDate||n||I.convert_time(e,this.zone,t),e.zone=t,e}},{key:"utcOffset",value:function(){return this.zone==I.localTimezone||this.zone==I.utcTimezone?0:this.zone.utcOffset(this)}},{key:"toICALString",value:function(){var t=this.toString();return t.length>10?It.icalendar.value["date-time"].toICAL(t):It.icalendar.value.date.toICAL(t)}},{key:"toString",value:function(){var t=this.year+"-"+F(this.month)+"-"+F(this.day);return this.isDate||(t+="T"+F(this.hour)+":"+F(this.minute)+":"+F(this.second),this.zone===I.utcTimezone&&(t+="Z")),t}},{key:"toJSDate",value:function(){return this.zone==I.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())}},{key:"_normalize",value:function(){return this._time.isDate&&(this._time.hour=0,this._time.minute=0,this._time.second=0),this.adjust(0,0,0,0),this}},{key:"adjust",value:function(e,n,r,i,a){var s,o,u,l,h,c,f,d=0,y=0,m=a||this._time;if(m.isDate||(u=m.second+i,m.second=u%60,s=K(u/60),m.second<0&&(m.second+=60,s--),l=m.minute+r+s,m.minute=l%60,o=K(l/60),m.minute<0&&(m.minute+=60,o--),h=m.hour+n+o,m.hour=h%24,d=K(h/24),m.hour<0&&(m.hour+=24,d--)),m.month>12?y=K((m.month-1)/12):m.month<1&&(y=K(m.month/12)-1),m.year+=y,m.month-=12*y,(c=m.day+e+d)>0)for(;!(c<=(f=t.daysInMonth(m.month,m.year)));)m.month++,m.month>12&&(m.year++,m.month=1),c-=f;else for(;c<=0;)1==m.month?(m.year--,m.month=12):m.month--,c+=t.daysInMonth(m.month,m.year);return m.day=c,this._cachedUnixTime=null,this}},{key:"fromUnixTime",value:function(t){this.zone=I.utcTimezone;var 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}},{key:"toUnixTime",value:function(){if(null!==this._cachedUnixTime)return this._cachedUnixTime;var 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}},{key:"toJSON",value:function(){for(var t,e=["year","month","day","hour","minute","second","isDate"],n=Object.create(null),r=0,i=e.length;r<i;r++)n[t=e[r]]=this[t];return this.zone&&(n.timezone=this.zone.tzid),n}}],[{key:"daysInMonth",value:function(e,n){var r=30;return e<1||e>12||(r=[0,31,28,31,30,31,30,31,31,30,31,30,31][e],2==e&&(r+=t.isLeapYear(n))),r}},{key:"isLeapYear",value:function(t){return t<=1752?t%4==0:t%4==0&&t%100!=0||t%400==0}},{key:"fromDayOfYear",value:function(e,n){var r=n,i=e,a=new t;a.auto_normalize=!1;var s=t.isLeapYear(r)?1:0;if(i<1)return r--,s=t.isLeapYear(r)?1:0,i+=t.daysInYearPassedMonth[s][12],t.fromDayOfYear(i,r);if(i>t.daysInYearPassedMonth[s][12])return s=t.isLeapYear(r)?1:0,i-=t.daysInYearPassedMonth[s][12],r++,t.fromDayOfYear(i,r);a.year=r,a.isDate=!0;for(var o=11;o>=0;o--)if(i>t.daysInYearPassedMonth[s][o]){a.month=o+1,a.day=i-t.daysInYearPassedMonth[s][o];break}return a.auto_normalize=!0,a}},{key:"fromStringv2",value:function(e){return new t({year:parseInt(e.slice(0,4),10),month:parseInt(e.slice(5,7),10),day:parseInt(e.slice(8,10),10),isDate:!0})}},{key:"fromDateString",value:function(e){return new t({year:U(e.slice(0,4)),month:U(e.slice(5,7)),day:U(e.slice(8,10)),isDate:!0})}},{key:"fromDateTimeString",value:function(e,n){if(e.length<19)throw new Error('invalid date-time value: "'+e+'"');var r,i;"Z"===e.slice(-1)?r=I.utcTimezone:n&&(i=n.getParameter("tzid"),n.parent&&("standard"===n.parent.name||"daylight"===n.parent.name?r=I.localTimezone:i&&(r=n.parent.getTimeZoneByID(i))));var a={year:U(e.slice(0,4)),month:U(e.slice(5,7)),day:U(e.slice(8,10)),hour:U(e.slice(11,13)),minute:U(e.slice(14,16)),second:U(e.slice(17,19))};return i&&!r&&(a.timezone=i),new t(a,r)}},{key:"fromString",value:function(e,n){return e.length>10?t.fromDateTimeString(e,n):t.fromDateString(e)}},{key:"fromJSDate",value:function(e,n){return(new t).fromJSDate(e,n)}},{key:"now",value:function(){return t.fromJSDate(new Date,!1)}},{key:"weekOneStarts",value:function(e,n){var r=t.fromData({year:e,month:1,day:1,isDate:!0}),i=r.dayOfWeek(),a=n||t.DEFAULT_WEEK_START;return i>t.THURSDAY&&(r.day+=7),a>t.THURSDAY&&(r.day-=7),r.day-=i-a,r}},{key:"getDominicalLetter",value:function(e){var n="GFEDCBA",r=(e+(e/4|0)+(e/400|0)-(e/100|0)-1)%7;return t.isLeapYear(e)?n[(r+6)%7]+n[r]:n[r]}},{key:"epochTime",get:function(){return e(t,this,O)._||(O._=e(t,this,t.fromData({year:1970,month:1,day:1,hour:0,minute:0,second:0,isDate:!1,timezone:"Z"}))),e(t,this,O)._}},{key:"_cmp_attr",value:function(t,e,n){return t[n]>e[n]?1:t[n]<e[n]?-1:0}}])}();k=b,o(b,"_dowCache",{}),o(b,"_wnCache",{}),o(b,"fromData",(function(t,e){return(new k).fromData(t,e)}));var O={_:null};o(b,"daysInYearPassedMonth",[[0,31,59,90,120,151,181,212,243,273,304,334,365],[0,31,60,91,121,152,182,213,244,274,305,335,366]]),o(b,"SUNDAY",1),o(b,"MONDAY",2),o(b,"TUESDAY",3),o(b,"WEDNESDAY",4),o(b,"THURSDAY",5),o(b,"FRIDAY",6),o(b,"SATURDAY",7),o(b,"DEFAULT_WEEK_START",2);var S=/[^ \t]/,w=":",E={"^'":'"',"^n":"\n","^^":"^"};function C(t){var e={},n=e.component=[];if(e.stack=[n],C._eachLine(t,(function(t,n){C._handleContentLine(n,e)})),e.stack.length>1)throw new x("invalid ical body. component began but did not end");return e=null,1==n.length?n[0]:n}C.property=function(t,e){var n={component:[[],[]],designSet:e||It.defaultSet};return C._handleContentLine(t,n),n.component[1][0]},C.component=function(t){return C(t)};var x=function(t){function e(){var t;r(this,e);for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return o(t=n(this,e,[].concat(a)),"name",t.constructor.name),t}return l(e,t),a(e)}(v(Error));C.ParserError=x,C._handleContentLine=function(t,e){var n,r,i,a,s,o,u=t.indexOf(w),l=t.indexOf(";"),h={};if(-1!==l&&-1!==u&&l>u&&(l=-1),-1!==l){if(i=t.slice(0,Math.max(0,l)).toLowerCase(),-1==(s=C._parseParameters(t.slice(Math.max(0,l)),0,e.designSet))[2])throw new x("Invalid parameters in '"+t+"'");if(h=s[0],n=("string"==typeof s[1]?s[1].length:s[1].reduce((function(t,e){return t+e.length}),0))+s[2]+l,-1===(r=t.slice(Math.max(0,n)).indexOf(w)))throw new x("Missing parameter value in '"+t+"'");a=t.slice(Math.max(0,n+r+1))}else{if(-1===u)throw new x('invalid line (no token ";" or ":") "'+t+'"');if(i=t.slice(0,Math.max(0,u)).toLowerCase(),a=t.slice(Math.max(0,u+1)),"begin"===i){var c=[a.toLowerCase(),[],[]];return 1===e.stack.length?e.component.push(c):e.component[2].push(c),e.stack.push(e.component),e.component=c,void(e.designSet||(e.designSet=It.getDesignSet(e.component[0])))}if("end"===i)return void(e.component=e.stack.pop())}var f,d,y,m,p=!1,v=!1;e.designSet.propertyGroups&&-1!==i.indexOf(".")?(d=i.split("."),h.group=d[0],y=d[1]):y=i,y in e.designSet.property&&("multiValue"in(f=e.designSet.property[y])&&(p=f.multiValue),"structuredValue"in f&&(v=f.structuredValue),a&&"detectType"in f&&(o=f.detectType(a))),o||(o="value"in h?h.value.toLowerCase():f?f.defaultType:"unknown"),delete h.value,p&&v?m=[y,h,o,a=C._parseMultiValue(a,v,o,[],p,e.designSet,v)]:p?(m=[y,h,o],C._parseMultiValue(a,p,o,m,null,e.designSet,!1)):m=v?[y,h,o,a=C._parseMultiValue(a,v,o,[],null,e.designSet,v)]:[y,h,o,a=C._parseValue(a,o,e.designSet,!1)],"vcard"!==e.component[0]||0!==e.component[1].length||"version"===i&&"4.0"===a||(e.designSet=It.getDesignSet("vcard3")),e.component[1].push(m)},C._parseValue=function(t,e,n,r){return e in n.value&&"fromICAL"in n.value[e]?n.value[e].fromICAL(t,r):t},C._parseParameters=function(t,e,n){for(var r,i,a,s,o,u,l=e,h=0,c={},f=-1;!1!==h&&-1!==(h=t.indexOf("=",h+1));){if(0==(r=t.slice(l+1,h)).length)throw new x("Empty parameter name in '"+t+"'");if(u=!1,o=!1,s=(i=r.toLowerCase())in n.param&&n.param[i].valueType?n.param[i].valueType:"text",i in n.param&&(o=n.param[i].multiValue,n.param[i].multiValueSeparateDQuote&&(u=C._rfc6868Escape('"'+o+'"'))),'"'===t[h+1]){if(f=h+2,h=t.indexOf('"',f),o&&-1!=h)for(var d=!0;d;)t[h+1]==o&&'"'==t[h+2]?h=t.indexOf('"',h+3):d=!1;if(-1===h)throw new x('invalid line (no matching double quote) "'+t+'"');a=t.slice(f,h),l=t.indexOf(";",h);var y=t.indexOf(w,h);(-1===l||-1!==y&&l>y)&&(h=!1)}else{f=h+1;var m=t.indexOf(";",f),p=t.indexOf(w,f);-1!==p&&m>p?(m=p,h=!1):-1===m?(m=-1===p?t.length:p,h=!1):(l=m,h=m),a=t.slice(f,m)}if(f+=a.length-(a=C._rfc6868Escape(a)).length,o){var v=u||o;a=C._parseMultiValue(a,v,s,[],null,n)}else a=C._parseValue(a,s,n);o&&i in c?Array.isArray(c[i])?c[i].push(a):c[i]=[c[i],a]:c[i]=a}return[c,a,f]},C._rfc6868Escape=function(t){return t.replace(/\^['n^]/g,(function(t){return E[t]}))},C._parseMultiValue=function(t,e,n,r,i,a,s){var o,u=0,l=0;if(0===e.length)return t;for(;-1!==(u=V(t,e,l));)o=t.slice(l,u),o=i?C._parseMultiValue(o,i,n,[],null,a,s):C._parseValue(o,n,a,s),r.push(o),l=u+e.length;return o=t.slice(l),o=i?C._parseMultiValue(o,i,n,[],null,a,s):C._parseValue(o,n,a,s),r.push(o),1==r.length?r[0]:r},C._eachLine=function(t,e){var n,r,i,a=t.length,s=t.search(S),o=s;do{i=(o=t.indexOf("\n",s)+1)>1&&"\r"===t[o-2]?2:1,0===o&&(o=a,i=0)," "===(r=t[s])||"\t"===r?n+=t.slice(s+1,o-i):(n&&e(null,n),n=t.slice(s,o-i)),s=o}while(o!==a);(n=n.trim()).length&&e(null,n)};var N=["tzid","location","tznames","latitude","longitude"],I=function(){function t(e){r(this,t),o(this,"tzid",""),o(this,"location",""),o(this,"tznames",""),o(this,"latitude",0),o(this,"longitude",0),o(this,"component",null),o(this,"expandedUntilYear",0),o(this,"icalclass","icaltimezone"),this.wrappedJSObject=this,this.fromData(e)}return a(t,[{key:"fromData",value:function(t){if(this.expandedUntilYear=0,this.changes=[],t instanceof Ut)this.component=t;else{if(t&&"component"in t)if("string"==typeof t.component){var e=C(t.component);this.component=new Ut(e)}else t.component instanceof Ut?this.component=t.component:this.component=null;for(var n=0,r=N;n<r.length;n++){var i=r[n];t&&i in t&&(this[i]=t[i])}}return this.component instanceof Ut&&!this.tzid&&(this.tzid=this.component.getFirstPropertyValue("tzid")),this}},{key:"utcOffset",value:function(e){if(this==t.utcTimezone||this==t.localTimezone)return 0;if(this._ensureCoverage(e.year),!this.changes.length)return 0;for(var n={year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:e.second},r=this._findNearbyChange(n),i=-1,a=1;;){var s=R(this.changes[r],!0);if(s.utcOffset<s.prevUtcOffset?t.adjust_change(s,0,0,0,s.utcOffset):t.adjust_change(s,0,0,0,s.prevUtcOffset),t._compare_change_fn(n,s)>=0?i=r:a=-1,-1==a&&-1!=i)break;if((r+=a)<0)return 0;if(r>=this.changes.length)break}var o=this.changes[i];if(o.utcOffset-o.prevUtcOffset<0&&i>0){var u=R(o,!0);if(t.adjust_change(u,0,0,0,u.prevUtcOffset),t._compare_change_fn(n,u)<0){var l=this.changes[i-1],h=!1;o.is_daylight!=h&&l.is_daylight==h&&(o=l)}}return o.utcOffset}},{key:"_findNearbyChange",value:function(e){var n=H(this.changes,e,t._compare_change_fn);return n>=this.changes.length?this.changes.length-1:n}},{key:"_ensureCoverage",value:function(e){if(-1==t._minimumExpansionYear){var n=b.now();t._minimumExpansionYear=n.year}var r=e;if(r<t._minimumExpansionYear&&(r=t._minimumExpansionYear),r+=t.EXTRA_COVERAGE,!this.changes.length||this.expandedUntilYear<e){for(var i=this.component.getAllSubcomponents(),a=i.length,s=0;s<a;s++)this._expandComponent(i[s],r,this.changes);this.changes.sort(t._compare_change_fn),this.expandedUntilYear=r}}},{key:"_expandComponent",value:function(e,n,r){if(!e.hasProperty("dtstart")||!e.hasProperty("tzoffsetto")||!e.hasProperty("tzoffsetfrom"))return null;var i,a=e.getFirstProperty("dtstart").getFirstValue();function o(t){return t.factor*(3600*t.hours+60*t.minutes)}function u(){var t={};return t.is_daylight="daylight"==e.name,t.utcOffset=o(e.getFirstProperty("tzoffsetto").getFirstValue()),t.prevUtcOffset=o(e.getFirstProperty("tzoffsetfrom").getFirstValue()),t}if(e.hasProperty("rrule")||e.hasProperty("rdate")){var l,h=s(e.getAllProperties("rdate"));try{for(h.s();!(l=h.n()).done;){var c=l.value.getFirstValue();(i=u()).year=c.year,i.month=c.month,i.day=c.day,c.isDate?(i.hour=a.hour,i.minute=a.minute,i.second=a.second,a.zone!=t.utcTimezone&&t.adjust_change(i,0,0,0,-i.prevUtcOffset)):(i.hour=c.hour,i.minute=c.minute,i.second=c.second,c.zone!=t.utcTimezone&&t.adjust_change(i,0,0,0,-i.prevUtcOffset)),r.push(i)}}catch(t){h.e(t)}finally{h.f()}var f=e.getFirstProperty("rrule");if(f){f=f.getFirstValue(),i=u(),f.until&&f.until.zone==t.utcTimezone&&(f.until.adjust(0,0,0,i.prevUtcOffset),f.until.zone=t.localTimezone);for(var d,y=f.iterator(a);(d=y.next())&&(i=u(),!(d.year>n)&&d);)i.year=d.year,i.month=d.month,i.day=d.day,i.hour=d.hour,i.minute=d.minute,i.second=d.second,i.isDate=d.isDate,t.adjust_change(i,0,0,0,-i.prevUtcOffset),r.push(i)}}else(i=u()).year=a.year,i.month=a.month,i.day=a.day,i.hour=a.hour,i.minute=a.minute,i.second=a.second,t.adjust_change(i,0,0,0,-i.prevUtcOffset),r.push(i);return r}},{key:"toString",value:function(){return this.tznames?this.tznames:this.tzid}}],[{key:"_compare_change_fn",value:function(t,e){return t.year<e.year?-1:t.year>e.year?1:t.month<e.month?-1:t.month>e.month?1:t.day<e.day?-1:t.day>e.day?1:t.hour<e.hour?-1:t.hour>e.hour?1:t.minute<e.minute?-1:t.minute>e.minute?1:t.second<e.second?-1:t.second>e.second?1:0}},{key:"convert_time",value:function(e,n,r){if(e.isDate||n.tzid==r.tzid||n==t.localTimezone||r==t.localTimezone)return e.zone=r,e;var i=n.utcOffset(e);return e.adjust(0,0,0,-i),i=r.utcOffset(e),e.adjust(0,0,0,i),null}},{key:"fromData",value:function(e){return(new t).fromData(e)}},{key:"utcTimezone",get:function(){return e(t,this,B)._||(B._=e(t,this,t.fromData({tzid:"UTC"}))),e(t,this,B)._}},{key:"localTimezone",get:function(){return e(t,this,M)._||(M._=e(t,this,t.fromData({tzid:"floating"}))),e(t,this,M)._}},{key:"adjust_change",value:function(t,e,n,r,i){return b.prototype.adjust.call(t,e,n,r,i,t)}}])}(),B={_:null},M={_:null};o(I,"_minimumExpansionYear",-1),o(I,"EXTRA_COVERAGE",5);var z=null,L={get count(){return null===z?0:Object.keys(z).length},reset:function(){z=Object.create(null);var t=I.utcTimezone;z.Z=t,z.UTC=t,z.GMT=t},_hard_reset:function(){z=null},has:function(t){return null!==z&&!!z[t]},get:function(t){return null===z&&this.reset(),z[t]},register:function(t,e){if(null===z&&this.reset(),"string"==typeof t&&e instanceof I){var n=[e,t];t=n[0],e=n[1]}if(e||(t instanceof I?e=t.tzid:"vtimezone"===t.name&&(e=(t=new I(t)).tzid)),!e)throw new TypeError("Neither a timezone nor a name was passed");if(!(t instanceof I))throw new TypeError("timezone must be ICAL.Timezone or ICAL.Component");z[e]=t},remove:function(t){return null===z?null:delete z[t]}};function P(t){return"number"==typeof t&&isNaN(t)}function U(t){var e=parseInt(t,10);if(P(e))throw new Error('Could not extract integer from "'+t+'"');return e}function j(t,e){if(void 0!==t)return t instanceof e?t:new e(t)}function V(t,e,n){for(;-1!==(n=t.indexOf(e,n));){if(!(n>0&&"\\"===t[n-1]))return n;n+=1}return-1}function H(t,e,n){if(!t.length)return 0;for(var r,i,a=0,s=t.length-1;a<=s;)if((i=n(e,t[r=a+Math.floor((s-a)/2)]))<0)s=r-1;else{if(!(i>0))break;a=r+1}return i<0?r:i>0?r+1:r}function R(t,e){if(t&&"object"==m(t)){if(t instanceof Date)return new Date(t.getTime());if("clone"in t)return t.clone();if(Array.isArray(t)){for(var n=[],r=0;r<t.length;r++)n.push(e?R(t[r],!0):t[r]);return n}for(var i={},a=0,s=Object.entries(t);a<s.length;a++){var o=f(s[a],2),u=o[0],l=o[1];i[u]=e?R(l,!0):l}return i}return t}function W(t){for(var e="",n=t||"",r=0,i=0;n.length;){var a=n.codePointAt(r);a<128?++i:i+=a<2048?2:a<65536?3:4,i<Wt.foldLength+1?r+=a>65535?2:1:(e+=Wt.newLineChar+" "+n.slice(0,Math.max(0,r)),n=n.slice(Math.max(0,r)),r=i=0)}return e.slice(Wt.newLineChar.length+1)}function F(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 K(t){return t<0?Math.ceil(t):Math.floor(t)}function q(t,e){for(var n in t){var r=Object.getOwnPropertyDescriptor(t,n);r&&!Object.getOwnPropertyDescriptor(e,n)&&Object.defineProperty(e,n,r)}return e}var J=Object.freeze({__proto__:null,binsearchInsert:H,clone:R,extend:q,foldline:W,formatClassType:j,isStrictlyNaN:P,pad2:F,strictParseInt:U,trunc:K,unescapedIndexOf:V,updateTimezones:function(t){var e,n,r,i,a;if(!t||"vcalendar"!==t.name)return t;for(e=t.getAllSubcomponents(),n=[],r={},a=0;a<e.length;a++){if("vtimezone"===e[a].name)r[e[a].getFirstProperty("tzid").getFirstValue()]=e[a];else n=n.concat(e[a].getAllProperties())}for(i={},a=0;a<n.length;a++){var s=n[a].getParameter("tzid");s&&(i[s]=!0)}for(var o=0,u=Object.entries(r);o<u.length;o++){var l=f(u[o],2),h=l[0],c=l[1];i[h]||t.removeSubcomponent(c)}for(var d=0,y=Object.keys(i);d<y.length;d++){var m=y[d];!r[m]&&L.has(m)&&t.addSubcomponent(L.get(m).component)}return t}}),Z=function(){function t(e){r(this,t),o(this,"hours",0),o(this,"minutes",0),o(this,"factor",1),o(this,"icaltype","utc-offset"),this.fromData(e)}return a(t,[{key:"clone",value:function(){return t.fromSeconds(this.toSeconds())}},{key:"fromData",value:function(t){if(t)for(var e=0,n=Object.entries(t);e<n.length;e++){var r=f(n[e],2),i=r[0],a=r[1];this[i]=a}this._normalize()}},{key:"fromSeconds",value:function(t){var e=Math.abs(t);return this.factor=t<0?-1:1,this.hours=K(e/3600),e-=3600*this.hours,this.minutes=K(e/60),this}},{key:"toSeconds",value:function(){return this.factor*(60*this.minutes+3600*this.hours)}},{key:"compare",value:function(t){var e=this.toSeconds(),n=t.toSeconds();return(e>n)-(n>e)}},{key:"_normalize",value:function(){for(var t=this.toSeconds(),e=this.factor;t<-43200;)t+=97200;for(;t>50400;)t-=97200;this.fromSeconds(t),0==t&&(this.factor=e)}},{key:"toICALString",value:function(){return It.icalendar.value["utc-offset"].toICAL(this.toString())}},{key:"toString",value:function(){return(1==this.factor?"+":"-")+F(this.hours)+":"+F(this.minutes)}}],[{key:"fromString",value:function(e){var n={};return n.factor="+"===e[0]?1:-1,n.hours=U(e.slice(1,3)),n.minutes=U(e.slice(4,6)),new t(n)}},{key:"fromSeconds",value:function(e){var n=new t;return n.fromSeconds(e),n}}])}(),G=function(t){function e(t,i,a){var s;return r(this,e),o(s=n(this,e,[t,i]),"icalclass","vcardtime"),o(s,"icaltype","date-and-or-time"),s.icaltype=a||"date-and-or-time",s}return l(e,t),a(e,[{key:"clone",value:function(){return new e(this._time,this.zone,this.icaltype)}},{key:"_normalize",value:function(){return this}},{key:"utcOffset",value:function(){return this.zone instanceof Z?this.zone.toSeconds():b.prototype.utcOffset.apply(this,arguments)}},{key:"toICALString",value:function(){return It.vcard.value[this.icaltype].toICAL(this.toString())}},{key:"toString",value:function(){var t,e=this.year,n=this.month,r=this.day,i=this.hour,a=this.minute,s=this.second,o=null!==n,u=null!==r,l=null!==i,h=null!==a,c=null!==s,f=(null!==e?F(e)+(o||u?"-":""):o||u?"--":"")+(o?F(n):"")+(u?"-"+F(r):""),d=(l?F(i):"-")+(l&&h?":":"")+(h?F(a):"")+(l||h?"":"-")+(h&&c?":":"")+(c?F(s):"");if(this.zone===I.utcTimezone)t="Z";else if(this.zone instanceof Z)t=this.zone.toString();else if(this.zone===I.localTimezone)t="";else if(this.zone instanceof I){t=Z.fromSeconds(this.zone.utcOffset(this)).toString()}else t="";switch(this.icaltype){case"time":return d+t;case"date-and-or-time":case"date-time":return f+("--"==d?"":"T"+d+t);case"date":return f}return null}}],[{key:"fromDateAndOrTimeString",value:function(t,n){function r(t,e,n){return t?U(t.slice(e,e+n)):null}var i=t.split("T"),a=i[0],s=i[1],o=s?It.vcard.value.time._splitZone(s):[],u=o[0],l=o[1],h=a?a.length:0,c=l?l.length:0,f=a&&"-"==a[0]&&"-"==a[1],d=l&&"-"==l[0];return new e({year:f?null:r(a,0,4),month:!f||4!=h&&7!=h?7==h||10==h?r(a,5,2):null:r(a,2,2),day:5==h?r(a,3,2):7==h&&f?r(a,5,2):10==h?r(a,8,2):null,hour:d?null:r(l,0,2),minute:d&&3==c?r(l,1,2):c>4?r(l,d?1:3,2):null,second:4==c?r(l,2,2):6==c?r(l,4,2):8==c?r(l,6,2):null},u="Z"==u?I.utcTimezone:u&&":"==u[3]?Z.fromString(u):null,n)}}])}(b),X=function(){function t(e){r(this,t),o(this,"completed",!1),o(this,"rule",null),o(this,"dtstart",null),o(this,"last",null),o(this,"occurrence_number",0),o(this,"by_indices",null),o(this,"initialized",!1),o(this,"by_data",null),o(this,"days",null),o(this,"days_index",0),this.fromData(e)}return a(t,[{key:"fromData",value:function(t){if(this.rule=j(t.rule,it),!this.rule)throw new Error("iterator requires a (ICAL.Recur) rule");if(this.dtstart=j(t.dtstart,b),!this.dtstart)throw new Error("iterator requires a (ICAL.Time) dtstart");if(t.by_data?this.by_data=t.by_data:this.by_data=R(this.rule.parts,!0),t.occurrence_number&&(this.occurrence_number=t.occurrence_number),this.days=t.days||[],t.last&&(this.last=j(t.last,b)),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)try{this.init()}catch(t){if(!(t instanceof Q))throw t;this.completed=!0}}},{key:"init",value:function(){var t=this;this.initialized=!0,this.last=this.dtstart.clone();var e=this.by_data;if("BYDAY"in e&&this.sort_byday_rules(e.BYDAY),"BYYEARDAY"in e&&("BYMONTH"in e||"BYWEEKNO"in e||"BYMONTHDAY"in e))throw new Error("Invalid BYYEARDAY rule");if("BYWEEKNO"in e&&"BYMONTHDAY"in e)throw new Error("BYWEEKNO does not fit to BYMONTHDAY");if("MONTHLY"==this.rule.freq&&("BYYEARDAY"in e||"BYWEEKNO"in e))throw new Error("For MONTHLY recurrences neither BYYEARDAY nor BYWEEKNO may appear");if("WEEKLY"==this.rule.freq&&("BYYEARDAY"in e||"BYMONTHDAY"in e))throw new Error("For WEEKLY recurrences neither BYMONTHDAY nor BYYEARDAY may appear");if("YEARLY"!=this.rule.freq&&"BYYEARDAY"in e)throw new Error("BYYEARDAY may only appear in YEARLY rules");if(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),this.last.day=this.setup_defaults("BYMONTHDAY","DAILY",this.dtstart.day),this.last.month=this.setup_defaults("BYMONTH","MONTHLY",this.dtstart.month),"WEEKLY"==this.rule.freq)if("BYDAY"in e){var n=f(this.ruleDayOfWeek(e.BYDAY[0],this.rule.wkst),2)[1],r=n-this.last.dayOfWeek(this.rule.wkst);(this.last.dayOfWeek(this.rule.wkst)<n&&r>=0||r<0)&&(this.last.day+=r)}else{var i=it.numericDayToIcalDay(this.dtstart.dayOfWeek());e.BYDAY=[i]}if("YEARLY"==this.rule.freq){for(var a=this.rule.until?this.rule.until.year:2e4;this.last.year<=a&&(this.expand_year_days(this.last.year),!(this.days.length>0));)this.increment_year(this.rule.interval);if(0==this.days.length)throw new Q;if(!(this._nextByYearDay()||this.next_year()||this.next_year()||this.next_year()))throw new Q}if("MONTHLY"==this.rule.freq)if(this.has_by_data("BYDAY")){var o,u=null,l=this.last.clone(),h=b.daysInMonth(this.last.month,this.last.year),c=s(this.by_data.BYDAY);try{for(c.s();!(o=c.n()).done;){var d=o.value;this.last=l.clone();var y=f(this.ruleDayOfWeek(d),2),m=y[0],p=y[1],v=this.last.nthWeekDay(p,m);if(m>=6||m<=-6)throw new Error("Malformed values in BYDAY part");if(v>h||v<=0){if(u&&u.month==l.month)continue;for(;v>h||v<=0;)this.increment_month(),h=b.daysInMonth(this.last.month,this.last.year),v=this.last.nthWeekDay(p,m)}this.last.day=v,(!u||this.last.compare(u)<0)&&(u=this.last.clone())}}catch(t){c.e(t)}finally{c.f()}if(this.last=u.clone(),this.has_by_data("BYMONTHDAY")&&this._byDayAndMonthDay(!0),this.last.day>h||0==this.last.day)throw new Error("Malformed values in BYDAY part")}else if(this.has_by_data("BYMONTHDAY")){this.last.day=1;var _=this.normalizeByMonthDayRules(this.last.year,this.last.month,this.rule.parts.BYMONTHDAY).filter((function(e){return e>=t.last.day}));if(_.length)this.last.day=_[0],this.by_data.BYMONTHDAY=_;else if(!this.next_month()&&!this.next_month()&&!this.next_month())throw new Q}}},{key:"next",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=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)&&(this.completed=!0),this.completed)return null;if(0==this.occurrence_number&&this.last.compare(this.dtstart)>=0)return this.occurrence_number++,this.last;var r=0;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":if(t=this.next_month())r=0;else if(336==++r)return this.completed=!0,null;break;case"YEARLY":if(t=this.next_year())r=0;else if(28==++r)return this.completed=!0,null;break;default:return null}}while(!this.check_contracting_rules()||this.last.compare(this.dtstart)<0||!t);if(0==this.last.compare(n)){if(e)throw new Error("Same occurrence found twice, protecting you from death by recursion");this.next(!0)}return this.rule.until&&this.last.compare(this.rule.until)>0?(this.completed=!0,null):(this.occurrence_number++,this.last)}},{key:"next_second",value:function(){return this.next_generic("BYSECOND","SECONDLY","second","minute")}},{key:"increment_second",value:function(t){return this.increment_generic(t,"second",60,"minute")}},{key:"next_minute",value:function(){return this.next_generic("BYMINUTE","MINUTELY","minute","hour","next_second")}},{key:"increment_minute",value:function(t){return this.increment_generic(t,"minute",60,"hour")}},{key:"next_hour",value:function(){return this.next_generic("BYHOUR","HOURLY","hour","monthday","next_minute")}},{key:"increment_hour",value:function(t){this.increment_generic(t,"hour",24,"monthday")}},{key:"next_day",value:function(){var t="DAILY"==this.rule.freq;return 0==this.next_hour()||(t?this.increment_monthday(this.rule.interval):this.increment_monthday(1)),0}},{key:"next_week",value:function(){var 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;var 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}},{key:"normalizeByMonthDayRules",value:function(t,e,n){for(var r,i=b.daysInMonth(e,t),a=[],s=0,o=n.length;s<o;s++){if(r=parseInt(n[s],10),isNaN(r))throw new Error("Invalid BYMONTHDAY value");if(!(Math.abs(r)>i)){if(r<0)r=i+(r+1);else if(0===r)continue;-1===a.indexOf(r)&&a.push(r)}}return a.sort((function(t,e){return t-e}))}},{key:"_byDayAndMonthDay",value:function(t){var e,n,r,i,a=this.by_data.BYDAY,s=0,o=a.length,u=0,l=this,h=this.last.day;function c(){for(i=b.daysInMonth(l.last.month,l.last.year),e=l.normalizeByMonthDayRules(l.last.year,l.last.month,l.by_data.BYMONTHDAY),r=e.length;e[s]<=h&&(!t||e[s]!=h)&&s<r-1;)s++}function f(){h=0,l.increment_month(),s=0,c()}c(),t&&(h-=1);for(var d=48;!u&&d;)if(d--,(n=h+1)>i)f();else{var y=e[s++];if(y>=n){h=y;for(var m=0;m<o;m++){var p=this.ruleDayOfWeek(a[m]),v=p[0],_=p[1];if(this.last.day=h,this.last.isNthWeekDay(_,v)){u=1;break}}u||s!==r||f()}else f()}if(d<=0)throw new Error("Malformed values in BYDAY combined with BYMONTHDAY parts");return u}},{key:"next_month",value:function(){var t=1;if(0==this.next_hour())return t;if(this.has_by_data("BYDAY")&&this.has_by_data("BYMONTHDAY"))t=this._byDayAndMonthDay();else if(this.has_by_data("BYDAY")){var e,n=b.daysInMonth(this.last.month,this.last.year),r=0,i=0;if(this.has_by_data("BYSETPOS")){for(var a=this.last.day,s=1;s<=n;s++)this.last.day=s,this.is_day_in_byday(this.last)&&(i++,s<=a&&r++);this.last.day=a}for(t=0,e=this.last.day+1;e<=n;e++)if(this.last.day=e,this.is_day_in_byday(this.last)&&(!this.has_by_data("BYSETPOS")||this.check_set_position(++r)||this.check_set_position(r-i-1))){t=1;break}e>n&&(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")){if(this.by_indices.BYMONTHDAY++,this.by_indices.BYMONTHDAY>=this.by_data.BYMONTHDAY.length&&(this.by_indices.BYMONTHDAY=0,this.increment_month(),this.by_indices.BYMONTHDAY>=this.by_data.BYMONTHDAY.length))return 0;var o=b.daysInMonth(this.last.month,this.last.year),u=this.by_data.BYMONTHDAY[this.by_indices.BYMONTHDAY];u<0&&(u=o+u+1),u>o?(this.last.day=1,t=this.is_day_in_byday(this.last)):this.last.day=u}else{this.increment_month();var l=b.daysInMonth(this.last.month,this.last.year);this.by_data.BYMONTHDAY[0]>l?t=0:this.last.day=this.by_data.BYMONTHDAY[0]}return t}},{key:"next_weekday_by_week",value:function(){var t=0;if(0==this.next_hour())return t;if(!this.has_by_data("BYDAY"))return 1;for(;;){var e=new b;this.by_indices.BYDAY++,this.by_indices.BYDAY==Object.keys(this.by_data.BYDAY).length&&(this.by_indices.BYDAY=0,t=1);var n=this.by_data.BYDAY[this.by_indices.BYDAY],r=this.ruleDayOfWeek(n)[1];(r-=this.rule.wkst)<0&&(r+=7),e.year=this.last.year,e.month=this.last.month,e.day=this.last.day;var i=e.startDoyWeek(this.rule.wkst);if(!(r+i<1)||t){var a=b.fromDayOfYear(i+r,this.last.year);return this.last.year=a.year,this.last.month=a.month,this.last.day=a.day,t}}}},{key:"next_year",value:function(){return 0==this.next_hour()?0:0!=this.days.length&&++this.days_index!=this.days.length||(this.days_index=0,this.increment_year(this.rule.interval),this.has_by_data("BYMONTHDAY")&&(this.by_data.BYMONTHDAY=this.normalizeByMonthDayRules(this.last.year,this.last.month,this.rule.parts.BYMONTHDAY)),this.expand_year_days(this.last.year),0!=this.days.length)?this._nextByYearDay():0}},{key:"_nextByYearDay",value:function(){var t=this.days[this.days_index],e=this.last.year;if(366==Math.abs(t)&&!b.isLeapYear(this.last.year))return 0;t<1&&(t+=1,e+=1);var n=b.fromDayOfYear(t,e);return this.last.day=n.day,this.last.month=n.month,1}},{key:"ruleDayOfWeek",value:function(t,e){var n=t.match(/([+-]?[0-9])?(MO|TU|WE|TH|FR|SA|SU)/);return n?[parseInt(n[1]||0,10),t=it.icalDayToNumericDay(n[2],e)]:[0,0]}},{key:"next_generic",value:function(t,e,n,r,i){var a=t in this.by_data,s=this.rule.freq==e,o=0;if(i&&0==this[i]())return o;if(a){this.by_indices[t]++;var u=this.by_data[t];this.by_indices[t]==u.length&&(this.by_indices[t]=0,o=1),this.last[n]=u[this.by_indices[t]]}else s&&this["increment_"+n](this.rule.interval);return a&&o&&s&&this["increment_"+r](1),o}},{key:"increment_monthday",value:function(t){for(var e=0;e<t;e++){var n=b.daysInMonth(this.last.month,this.last.year);this.last.day++,this.last.day>n&&(this.last.day-=n,this.increment_month())}}},{key:"increment_month",value:function(){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--;var t=K(this.last.month/12);this.last.month%=12,this.last.month++,0!=t&&this.increment_year(t)}this.has_by_data("BYMONTHDAY")&&(this.by_data.BYMONTHDAY=this.normalizeByMonthDayRules(this.last.year,this.last.month,this.rule.parts.BYMONTHDAY))}},{key:"increment_year",value:function(t){this.last.day=1,this.last.year+=t}},{key:"increment_generic",value:function(t,e,n,r){this.last[e]+=t;var i=K(this.last[e]/n);this.last[e]%=n,0!=i&&this["increment_"+r](i)}},{key:"has_by_data",value:function(t){return t in this.rule.parts}},{key:"expand_year_days",value:function(t){var e=new b;this.days=[];for(var n={},r=0,i=["BYDAY","BYWEEKNO","BYMONTHDAY","BYMONTH","BYYEARDAY"];r<i.length;r++){var a=i[r];a in this.rule.parts&&(n[a]=this.rule.parts[a])}if("BYMONTH"in n&&"BYWEEKNO"in n){var o=1,u={};e.year=t,e.isDate=!0;for(var l=0;l<this.by_data.BYMONTH.length;l++){var h=this.by_data.BYMONTH[l];e.month=h,e.day=1;var c=e.weekNumber(this.rule.wkst);e.day=b.daysInMonth(h,t);var f=e.weekNumber(this.rule.wkst);for(l=c;l<f;l++)u[l]=1}for(var d=0;d<this.by_data.BYWEEKNO.length&&o;d++){this.by_data.BYWEEKNO[d]<52?o&=u[d]:o=0}o?delete n.BYMONTH:delete n.BYWEEKNO}var y=Object.keys(n).length;if(0==y){var m=this.dtstart.clone();m.year=this.last.year,this.days.push(m.dayOfYear())}else if(1==y&&"BYMONTH"in n){var p,v=s(this.by_data.BYMONTH);try{for(v.s();!(p=v.n()).done;){var _=p.value,g=this.dtstart.clone();g.year=t,g.month=_,g.isDate=!0,this.days.push(g.dayOfYear())}}catch(t){v.e(t)}finally{v.f()}}else if(1==y&&"BYMONTHDAY"in n){var D,T=s(this.by_data.BYMONTHDAY);try{for(T.s();!(D=T.n()).done;){var Y=D.value,k=this.dtstart.clone();if(Y<0)Y=Y+b.daysInMonth(k.month,t)+1;k.day=Y,k.year=t,k.isDate=!0,this.days.push(k.dayOfYear())}}catch(t){T.e(t)}finally{T.f()}}else if(2==y&&"BYMONTHDAY"in n&&"BYMONTH"in n){var A,O=s(this.by_data.BYMONTH);try{for(O.s();!(A=O.n()).done;){var S,w=A.value,E=b.daysInMonth(w,t),C=s(this.by_data.BYMONTHDAY);try{for(C.s();!(S=C.n()).done;){var x=S.value;x<0&&(x=x+E+1),e.day=x,e.month=w,e.year=t,e.isDate=!0,this.days.push(e.dayOfYear())}}catch(t){C.e(t)}finally{C.f()}}}catch(t){O.e(t)}finally{O.f()}}else if(1==y&&"BYWEEKNO"in n);else if(2==y&&"BYWEEKNO"in n&&"BYMONTHDAY"in n);else if(1==y&&"BYDAY"in n)this.days=this.days.concat(this.expand_by_day(t));else if(2==y&&"BYDAY"in n&&"BYMONTH"in n){var N,I=s(this.by_data.BYMONTH);try{for(I.s();!(N=I.n()).done;){var B=N.value,M=b.daysInMonth(B,t);e.year=t,e.month=B,e.day=1,e.isDate=!0;var z=e.dayOfWeek(),L=e.dayOfYear()-1;e.day=M;var P=e.dayOfWeek();if(this.has_by_data("BYSETPOS")){for(var U=[],j=1;j<=M;j++)e.day=j,this.is_day_in_byday(e)&&U.push(j);for(var V=0;V<U.length;V++)(this.check_set_position(V+1)||this.check_set_position(V-U.length))&&this.days.push(L+U[V])}else{var H,R=s(this.by_data.BYDAY);try{for(R.s();!(H=R.n()).done;){var W=H.value,F=this.ruleDayOfWeek(W),K=F[0],q=F[1],J=void 0,Z=(q+7-z)%7+1,G=M-(P+7-q)%7;if(0==K)for(var X=Z;X<=M;X+=7)this.days.push(L+X);else K>0?(J=Z+7*(K-1))<=M&&this.days.push(L+J):(J=G+7*(K+1))>0&&this.days.push(L+J)}}catch(t){R.e(t)}finally{R.f()}}}}catch(t){I.e(t)}finally{I.f()}this.days.sort((function(t,e){return t-e}))}else if(2==y&&"BYDAY"in n&&"BYMONTHDAY"in n){var Q,$=s(this.expand_by_day(t));try{for($.s();!(Q=$.n()).done;){var tt=Q.value,et=b.fromDayOfYear(tt,t);this.by_data.BYMONTHDAY.indexOf(et.day)>=0&&this.days.push(tt)}}catch(t){$.e(t)}finally{$.f()}}else if(3==y&&"BYDAY"in n&&"BYMONTHDAY"in n&&"BYMONTH"in n){var nt,rt=s(this.expand_by_day(t));try{for(rt.s();!(nt=rt.n()).done;){var it=nt.value,at=b.fromDayOfYear(it,t);this.by_data.BYMONTH.indexOf(at.month)>=0&&this.by_data.BYMONTHDAY.indexOf(at.day)>=0&&this.days.push(it)}}catch(t){rt.e(t)}finally{rt.f()}}else if(2==y&&"BYDAY"in n&&"BYWEEKNO"in n){var st,ot=s(this.expand_by_day(t));try{for(ot.s();!(st=ot.n()).done;){var ut=st.value,lt=b.fromDayOfYear(ut,t).weekNumber(this.rule.wkst);this.by_data.BYWEEKNO.indexOf(lt)&&this.days.push(ut)}}catch(t){ot.e(t)}finally{ot.f()}}else if(3==y&&"BYDAY"in n&&"BYWEEKNO"in n&&"BYMONTHDAY"in n);else if(1==y&&"BYYEARDAY"in n)this.days=this.days.concat(this.by_data.BYYEARDAY);else if(2==y&&"BYYEARDAY"in n&&"BYDAY"in n){var ht,ct=b.isLeapYear(t)?366:365,ft=new Set(this.expand_by_day(t)),dt=s(this.by_data.BYYEARDAY);try{for(dt.s();!(ht=dt.n()).done;){var yt=ht.value;yt<0&&(yt+=ct+1),ft.has(yt)&&this.days.push(yt)}}catch(t){dt.e(t)}finally{dt.f()}}else this.days=[];var mt=b.isLeapYear(t)?366:365;return this.days.sort((function(t,e){return t<0&&(t+=mt+1),e<0&&(e+=mt+1),t-e})),0}},{key:"expand_by_day",value:function(t){var e=[],n=this.last.clone();n.year=t,n.month=1,n.day=1,n.isDate=!0;var r=n.dayOfWeek();n.month=12,n.day=31,n.isDate=!0;var i,a=n.dayOfWeek(),o=n.dayOfYear(),u=s(this.by_data.BYDAY);try{for(u.s();!(i=u.n()).done;){var l=i.value,h=this.ruleDayOfWeek(l),c=h[0],f=h[1];if(0==c)for(var d=(f+7-r)%7+1;d<=o;d+=7)e.push(d);else if(c>0){var y=void 0;y=f>=r?f-r+1:f-r+8,e.push(y+7*(c-1))}else{var m=void 0;c=-c,m=f<=a?o-a+f:o-a+f-7,e.push(m-7*(c-1))}}}catch(t){u.e(t)}finally{u.f()}return e}},{key:"is_day_in_byday",value:function(t){if(this.by_data.BYDAY){var e,n=s(this.by_data.BYDAY);try{for(n.s();!(e=n.n()).done;){var r=e.value,i=this.ruleDayOfWeek(r),a=i[0],o=i[1],u=t.dayOfWeek();if(0==a&&o==u||t.nthWeekDay(o,a)==t.day)return 1}}catch(t){n.e(t)}finally{n.f()}}return 0}},{key:"check_set_position",value:function(t){return!!this.has_by_data("BYSETPOS")&&-1!==this.by_data.BYSETPOS.indexOf(t)}},{key:"sort_byday_rules",value:function(t){for(var e=0;e<t.length;e++)for(var n=0;n<e;n++){if(this.ruleDayOfWeek(t[n],this.rule.wkst)[1]>this.ruleDayOfWeek(t[e],this.rule.wkst)[1]){var r=t[e];t[e]=t[n],t[n]=r}}}},{key:"check_contract_restriction",value:function(e,n){var r=t._indexMap[e],i=t._expandMap[this.rule.freq][r],a=!1;if(e in this.by_data&&i==t.CONTRACT){var o,u=s(this.by_data[e]);try{for(u.s();!(o=u.n()).done;){if(o.value==n){a=!0;break}}}catch(t){u.e(t)}finally{u.f()}}else a=!0;return a}},{key:"check_contracting_rules",value:function(){var t=this.last.dayOfWeek(),e=this.last.weekNumber(this.rule.wkst),n=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",it.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",n)}},{key:"setup_defaults",value:function(e,n,r){var i=t._indexMap[e];return t._expandMap[this.rule.freq][i]!=t.CONTRACT&&(e in this.by_data||(this.by_data[e]=[r]),this.rule.freq!=n)?this.by_data[e][0]:r}},{key:"toJSON",value:function(){var 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}}])}();o(X,"_indexMap",{BYSECOND:0,BYMINUTE:1,BYHOUR:2,BYDAY:3,BYMONTHDAY:4,BYYEARDAY:5,BYWEEKNO:6,BYMONTH:7,BYSETPOS:8}),o(X,"_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]}),o(X,"UNKNOWN",0),o(X,"CONTRACT",1),o(X,"EXPAND",2),o(X,"ILLEGAL",3);var Q=function(t){function e(){return r(this,e),n(this,e,["Recurrence rule has no valid occurrences"])}return l(e,t),a(e)}(v(Error)),$=/^(SU|MO|TU|WE|TH|FR|SA)$/,tt=/^([+-])?(5[0-3]|[1-4][0-9]|[1-9])?(SU|MO|TU|WE|TH|FR|SA)$/,et={SU:b.SUNDAY,MO:b.MONDAY,TU:b.TUESDAY,WE:b.WEDNESDAY,TH:b.THURSDAY,FR:b.FRIDAY,SA:b.SATURDAY},nt=Object.fromEntries(Object.entries(et).map((function(t){return t.reverse()}))),rt=["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"],it=function(){function t(e){r(this,t),o(this,"parts",null),o(this,"interval",1),o(this,"wkst",b.MONDAY),o(this,"until",null),o(this,"count",null),o(this,"freq",null),o(this,"icalclass","icalrecur"),o(this,"icaltype","recur"),this.wrappedJSObject=this,this.parts={},e&&"object"===m(e)&&this.fromData(e)}return a(t,[{key:"iterator",value:function(t){return new X({rule:this,dtstart:t})}},{key:"clone",value:function(){return new t(this.toJSON())}},{key:"isFinite",value:function(){return!(!this.count&&!this.until)}},{key:"isByCount",value:function(){return!(!this.count||this.until)}},{key:"addComponent",value:function(t,e){var n=t.toUpperCase();n in this.parts?this.parts[n].push(e):this.parts[n]=[e]}},{key:"setComponent",value:function(t,e){this.parts[t.toUpperCase()]=e.slice()}},{key:"getComponent",value:function(t){var e=t.toUpperCase();return e in this.parts?this.parts[e].slice():[]}},{key:"getNextOccurrence",value:function(t,e){var n,r=this.iterator(t);do{n=r.next()}while(n&&n.compare(e)<=0);return n&&e.zone&&(n.zone=e.zone),n}},{key:"fromData",value:function(e){for(var n in e){var r=n.toUpperCase();r in ot?Array.isArray(e[n])?this.parts[r]=e[n]:this.parts[r]=[e[n]]:this[n]=e[n]}this.interval&&"number"!=typeof this.interval&&st.INTERVAL(this.interval,this),this.wkst&&"number"!=typeof this.wkst&&(this.wkst=t.icalDayToNumericDay(this.wkst)),!this.until||this.until instanceof b||(this.until=b.fromString(this.until))}},{key:"toJSON",value:function(){var e=Object.create(null);e.freq=this.freq,this.count&&(e.count=this.count),this.interval>1&&(e.interval=this.interval);for(var n=0,r=Object.entries(this.parts);n<r.length;n++){var i=f(r[n],2),a=i[0],s=i[1];Array.isArray(s)&&1==s.length?e[a.toLowerCase()]=s[0]:e[a.toLowerCase()]=R(s)}return this.until&&(e.until=this.until.toString()),"wkst"in this&&this.wkst!==b.DEFAULT_WEEK_START&&(e.wkst=t.numericDayToIcalDay(this.wkst)),e}},{key:"toString",value:function(){var e="FREQ="+this.freq;this.count&&(e+=";COUNT="+this.count),this.interval>1&&(e+=";INTERVAL="+this.interval);for(var n=0,r=Object.entries(this.parts);n<r.length;n++){var i=f(r[n],2);e+=";"+i[0]+"="+i[1]}return this.until&&(e+=";UNTIL="+this.until.toICALString()),"wkst"in this&&this.wkst!==b.DEFAULT_WEEK_START&&(e+=";WKST="+t.numericDayToIcalDay(this.wkst)),e}}],[{key:"fromString",value:function(e){return new t(this._stringToData(e,!1))}},{key:"fromData",value:function(e){return new t(e)}},{key:"_stringToData",value:function(t,e){for(var n=Object.create(null),r=t.split(";"),i=r.length,a=0;a<i;a++){var o=r[a].split("="),u=o[0].toUpperCase(),l=o[0].toLowerCase(),h=e?l:u,c=o[1];if(u in ot){var f,y=c.split(","),m=new Set,p=s(y);try{for(p.s();!(f=p.n()).done;){var v=f.value;m.add(ot[u](v))}}catch(t){p.e(t)}finally{p.f()}y=d(m),n[h]=1==y.length?y[0]:y}else u in st?st[u](c,n,e):n[l]=c}return n}},{key:"icalDayToNumericDay",value:function(t,e){var n=e||b.SUNDAY;return(et[t]-n+7)%7+1}},{key:"numericDayToIcalDay",value:function(t,e){var n=t+(e||b.SUNDAY)-b.SUNDAY;return n>7&&(n-=7),nt[n]}}])}();function at(t,e,n,r){var i=r;if("+"===r[0]&&(i=r.slice(1)),i=U(i),void 0!==e&&r<e)throw new Error(t+': invalid value "'+r+'" must be > '+e);if(void 0!==n&&r>n)throw new Error(t+': invalid value "'+r+'" must be < '+e);return i}var st={FREQ:function(t,e,n){if(-1===rt.indexOf(t))throw new Error('invalid frequency "'+t+'" expected: "'+rt.join(", ")+'"');e.freq=t},COUNT:function(t,e,n){e.count=U(t)},INTERVAL:function(t,e,n){e.interval=U(t),e.interval<1&&(e.interval=1)},UNTIL:function(t,e,n){t.length>10?e.until=It.icalendar.value["date-time"].fromICAL(t):e.until=It.icalendar.value.date.fromICAL(t),n||(e.until=b.fromString(e.until))},WKST:function(t,e,n){if(!$.test(t))throw new Error('invalid WKST value "'+t+'"');e.wkst=it.icalDayToNumericDay(t)}},ot={BYSECOND:at.bind(void 0,"BYSECOND",0,60),BYMINUTE:at.bind(void 0,"BYMINUTE",0,59),BYHOUR:at.bind(void 0,"BYHOUR",0,23),BYDAY:function(t){if(tt.test(t))return t;throw new Error('invalid BYDAY value "'+t+'"')},BYMONTHDAY:at.bind(void 0,"BYMONTHDAY",-31,31),BYYEARDAY:at.bind(void 0,"BYYEARDAY",-366,366),BYWEEKNO:at.bind(void 0,"BYWEEKNO",-53,53),BYMONTH:at.bind(void 0,"BYMONTH",1,12),BYSETPOS:at.bind(void 0,"BYSETPOS",-366,366)},ut=/\\\\|\\,|\\[Nn]/g,lt=/\\|,|\n/g;function ht(t,e){return{matches:/.*/,fromICAL:function(e,n){return function(t,e,n){if(-1===t.indexOf("\\"))return t;n&&(e=new RegExp(e.source+"|\\\\"+n,e.flags));return t.replace(e,Tt)}(e,t,n)},toICAL:function(t,n){var r=e;return n&&(r=new RegExp(r.source+"|"+n,r.flags)),t.replace(r,(function(t){switch(t){case"\\":return"\\\\";case";":return"\\;";case",":return"\\,";case"\n":return"\\n";default:return t}}))}}}var ct={defaultType:"text"},ft={defaultType:"text",multiValue:","},dt={defaultType:"text",structuredValue:";"},yt={defaultType:"integer"},mt={defaultType:"date-time",allowedTypes:["date-time","date"]},pt={defaultType:"date-time"},vt={defaultType:"uri"},_t={defaultType:"utc-offset"},gt={defaultType:"recur"},Dt={defaultType:"date-and-or-time",allowedTypes:["date-time","date","text"]};function Tt(t){switch(t){case"\\\\":return"\\";case"\\;":return";";case"\\,":return",";case"\\n":case"\\N":return"\n";default:return t}}var Yt={categories:ft,url:vt,version:ct,uid:ct},kt={boolean:{values:["TRUE","FALSE"],fromICAL:function(t){return"TRUE"===t},toICAL:function(t){return t?"TRUE":"FALSE"}},float:{matches:/^[+-]?\d+\.\d+$/,fromICAL:function(t){var e=parseFloat(t);return P(e)?0:e},toICAL:function(t){return String(t)}},integer:{fromICAL:function(t){var e=parseInt(t);return P(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 Z.fromString(t)},undecorate:function(t){return t.toString()}}},At=q(kt,{text:ht(/\\\\|\\;|\\,|\\[Nn]/g,/\\|;|,|\n/g),uri:{},binary:{decorate:function(t){return _.fromString(t)},undecorate:function(t){return t.toString()}},"cal-address":{},date:{decorate:function(t,e){return It.strict?b.fromDateString(t,e):b.fromString(t,e)},undecorate:function(t){return t.toString()},fromICAL:function(t){return!It.strict&&t.length>=15?At["date-time"].fromICAL(t):t.slice(0,4)+"-"+t.slice(4,6)+"-"+t.slice(6,8)},toICAL:function(t){var e=t.length;return 10==e?t.slice(0,4)+t.slice(5,7)+t.slice(8,10):e>=19?At["date-time"].toICAL(t):t}},"date-time":{fromICAL:function(t){if(It.strict||8!=t.length){var 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 At.date.fromICAL(t)},toICAL:function(t){var e=t.length;if(10!=e||It.strict){if(e>=19){var n=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]&&(n+="Z"),n}return t}return At.date.toICAL(t)},decorate:function(t,e){return It.strict?b.fromDateTimeString(t,e):b.fromString(t,e)},undecorate:function(t){return t.toString()}},duration:{decorate:function(t){return T.fromString(t)},undecorate:function(t){return t.toString()}},period:{fromICAL:function(t){var e=t.split("/");return e[0]=At["date-time"].fromICAL(e[0]),T.isValueString(e[1])||(e[1]=At["date-time"].fromICAL(e[1])),e},toICAL:function(t){return t=t.slice(),It.strict||10!=t[0].length?t[0]=At["date-time"].toICAL(t[0]):t[0]=At.date.toICAL(t[0]),T.isValueString(t[1])||(It.strict||10!=t[1].length?t[1]=At["date-time"].toICAL(t[1]):t[1]=At.date.toICAL(t[1])),t.join("/")},decorate:function(t,e){return A.fromJSON(t,e,!It.strict)},undecorate:function(t){return t.toJSON()}},recur:{fromICAL:function(t){return it._stringToData(t,!0)},toICAL:function(t){for(var e="",n=0,r=Object.entries(t);n<r.length;n++){var i=f(r[n],2),a=i[0],s=i[1];"until"==a?s=s.length>10?At["date-time"].toICAL(s):At.date.toICAL(s):"wkst"==a?"number"==typeof s&&(s=it.numericDayToIcalDay(s)):Array.isArray(s)&&(s=s.join(",")),e+=a.toUpperCase()+"="+s+";"}return e.slice(0,Math.max(0,e.length-1))},decorate:function(t){return it.fromData(t)},undecorate:function(t){return t.toJSON()}},time:{fromICAL:function(t){if(t.length<6)return t;var 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;var e=t.slice(0,2)+t.slice(3,5)+t.slice(6,8);return"Z"===t[8]&&(e+="Z"),e}}}),bt=q(Yt,{action:ct,attach:{defaultType:"uri"},attendee:{defaultType:"cal-address"},calscale:ct,class:ct,comment:ct,completed:pt,contact:ct,created:pt,description:ct,dtend:mt,dtstamp:pt,dtstart:mt,due:mt,duration:{defaultType:"duration"},exdate:{defaultType:"date-time",allowedTypes:["date-time","date"],multiValue:","},exrule:gt,freebusy:{defaultType:"period",multiValue:","},geo:{defaultType:"float",structuredValue:";"},"last-modified":pt,location:ct,method:ct,organizer:{defaultType:"cal-address"},"percent-complete":yt,priority:yt,prodid:ct,"related-to":ct,repeat:yt,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":mt,resources:ft,"request-status":dt,rrule:gt,sequence:yt,status:ct,summary:ct,transp:ct,trigger:{defaultType:"duration",allowedTypes:["duration","date-time"]},tzoffsetfrom:_t,tzoffsetto:_t,tzurl:vt,tzid:ct,tzname:ct}),Ot=q(kt,{text:ht(ut,lt),uri:ht(ut,lt),date:{decorate:function(t){return G.fromDateAndOrTimeString(t,"date")},undecorate:function(t){return t.toString()},fromICAL:function(t){return 8==t.length?At.date.fromICAL(t):"-"==t[0]&&6==t.length?t.slice(0,4)+"-"+t.slice(4):t},toICAL:function(t){return 10==t.length?At.date.toICAL(t):"-"==t[0]&&7==t.length?t.slice(0,4)+t.slice(5):t}},time:{decorate:function(t){return G.fromDateAndOrTimeString("T"+t,"time")},undecorate:function(t){return t.toString()},fromICAL:function(t){var e=Ot.time._splitZone(t,!0),n=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!=n.length||"-"!=n[0]&&"+"!=n[0]||(n=n.slice(0,3)+":"+n.slice(3)),r+n},toICAL:function(t){var e=Ot.time._splitZone(t),n=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!=n.length||"-"!=n[0]&&"+"!=n[0]||(n=n.slice(0,3)+n.slice(4)),r+n},_splitZone:function(t,e){var n,r,i=t.length-1,a=t.length-(e?5:6),s=t[a];return"Z"==t[i]?(n=t[i],r=t.slice(0,Math.max(0,i))):t.length>6&&("-"==s||"+"==s)?(n=t.slice(a),r=t.slice(0,Math.max(0,a))):(n="",r=t),[n,r]}},"date-time":{decorate:function(t){return G.fromDateAndOrTimeString(t,"date-time")},undecorate:function(t){return t.toString()},fromICAL:function(t){return Ot["date-and-or-time"].fromICAL(t)},toICAL:function(t){return Ot["date-and-or-time"].toICAL(t)}},"date-and-or-time":{decorate:function(t){return G.fromDateAndOrTimeString(t,"date-and-or-time")},undecorate:function(t){return t.toString()},fromICAL:function(t){var e=t.split("T");return(e[0]?Ot.date.fromICAL(e[0]):"")+(e[1]?"T"+Ot.time.fromICAL(e[1]):"")},toICAL:function(t){var e=t.split("T");return Ot.date.toICAL(e[0])+(e[1]?"T"+Ot.time.toICAL(e[1]):"")}},timestamp:At["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("")}}}),St=q(Yt,{adr:{defaultType:"text",structuredValue:";",multiValue:","},anniversary:Dt,bday:Dt,caladruri:vt,caluri:vt,clientpidmap:dt,email:ct,fburl:vt,fn:ct,gender:dt,geo:vt,impp:vt,key:vt,kind:ct,lang:{defaultType:"language-tag"},logo:vt,member:vt,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:ft,note:ct,org:{defaultType:"text",structuredValue:";"},photo:vt,related:vt,rev:{defaultType:"timestamp"},role:ct,sound:vt,source:vt,tel:{defaultType:"uri",allowedTypes:["uri","text"]},title:ct,tz:{defaultType:"text",allowedTypes:["text","utc-offset","uri"]},xml:ct}),wt=q(kt,{binary:At.binary,date:Ot.date,"date-time":Ot["date-time"],"phone-number":Ot["phone-number"],uri:At.uri,text:Ot.text,time:At.time,vcard:At.text,"utc-offset":{toICAL:function(t){return t.slice(0,7)},fromICAL:function(t){return t.slice(0,7)},decorate:function(t){return Z.fromString(t)},undecorate:function(t){return t.toString()}}}),Et=q(Yt,{fn:ct,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:ft,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:ct,tel:{defaultType:"phone-number"},email:ct,mailer:ct,tz:{defaultType:"utc-offset",allowedTypes:["utc-offset","text"]},geo:{defaultType:"float",structuredValue:";"},title:ct,role:ct,logo:{defaultType:"binary",allowedTypes:["binary","uri"]},agent:{defaultType:"vcard",allowedTypes:["vcard","text","uri"]},org:dt,note:ft,prodid:ct,rev:{defaultType:"date-time",allowedTypes:["date-time","date"],detectType:function(t){return-1===t.indexOf("T")?"date":"date-time"}},"sort-string":ct,sound:{defaultType:"binary",allowedTypes:["binary","uri"]},class:ct,key:{defaultType:"binary",allowedTypes:["binary","text"]}}),Ct={name:"ical",value:At,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:bt,propertyGroups:!1},xt={name:"vcard4",value:Ot,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:St,propertyGroups:!0},Nt={name:"vcard3",value:wt,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:Et,propertyGroups:!0},It={strict:!0,defaultSet:Ct,defaultType:"unknown",components:{vcard:xt,vcard3:Nt,vevent:Ct,vtodo:Ct,vjournal:Ct,valarm:Ct,vtimezone:Ct,daylight:Ct,standard:Ct},icalendar:Ct,vcard:xt,vcard3:Nt,getDesignSet:function(t){return t&&t in It.components?It.components[t]:It.defaultSet}},Bt="\r\n",Mt="unknown",zt={'"':"^'","\n":"^n","^":"^^"};function Lt(t){"string"==typeof t[0]&&(t=[t]);for(var e=0,n=t.length,r="";e<n;e++)r+=Lt.component(t[e])+Bt;return r}Lt.component=function(t,e){var n=t[0].toUpperCase(),r="BEGIN:"+n+Bt,i=t[1],a=0,s=i.length,o=t[0];for("vcard"===o&&t[1].length>0&&("version"!==t[1][0][0]||"4.0"!==t[1][0][3])&&(o="vcard3"),e=e||It.getDesignSet(o);a<s;a++)r+=Lt.property(i[a],e)+Bt;for(var u=t[2]||[],l=0,h=u.length;l<h;l++)r+=Lt.component(u[l],e)+Bt;return r+="END:"+n},Lt.property=function(t,e,n){var r=t[0].toUpperCase(),i=t[0],a=t[1];e||(e=It.defaultSet);var s,o=a.group;s=e.propertyGroups&&o?o.toUpperCase()+"."+r:r;for(var u=function(){var t=f(h[l],2),n=t[0],r=t[1];if(e.propertyGroups&&"group"==n)return 1;var i=e.param[n],a=i&&i.multiValue;a&&Array.isArray(r)?(r=r.map((function(t){return t=Lt._rfc6868Unescape(t),t=Lt.paramPropertyValue(t,i.multiValueSeparateDQuote)})),r=Lt.multiValue(r,a,"unknown",null,e)):(r=Lt._rfc6868Unescape(r),r=Lt.paramPropertyValue(r)),s+=";"+n.toUpperCase()+"="+r},l=0,h=Object.entries(a);l<h.length;l++)u();if(3===t.length)return s+":";var c,d=t[2],y=!1,m=!1,p=!1;return i in e.property?("multiValue"in(c=e.property[i])&&(y=c.multiValue),"structuredValue"in c&&Array.isArray(t[3])&&(m=c.structuredValue),"defaultType"in c?d===c.defaultType&&(p=!0):d===Mt&&(p=!0)):d===Mt&&(p=!0),p||(s+=";VALUE="+d.toUpperCase()),s+=":",s+=y&&m?Lt.multiValue(t[3],m,d,y,e,m):y?Lt.multiValue(t.slice(3),y,d,null,e,!1):m?Lt.multiValue(t[3],m,d,null,e,m):Lt.value(t[3],d,e,!1),n?s:W(s)},Lt.paramPropertyValue=function(t,e){return e||-1!==t.indexOf(",")||-1!==t.indexOf(":")||-1!==t.indexOf(";")?'"'+t+'"':t},Lt.multiValue=function(t,e,n,r,i,a){for(var s="",o=t.length,u=0;u<o;u++)r&&Array.isArray(t[u])?s+=Lt.multiValue(t[u],r,n,null,i,a):s+=Lt.value(t[u],n,i,a),u!==o-1&&(s+=e);return s},Lt.value=function(t,e,n,r){return e in n.value&&"toICAL"in n.value[e]?n.value[e].toICAL(t,r):t},Lt._rfc6868Unescape=function(t){return t.replace(/[\n^"]/g,(function(t){return zt[t]}))};var Pt=function(){function t(e,n){r(this,t),this._parent=n||null,"string"==typeof e?(this.jCal=[e,{},It.defaultType],this.jCal[2]=this.getDefaultType()):this.jCal=e,this._updateType()}return a(t,[{key:"type",get:function(){return this.jCal[2]}},{key:"name",get:function(){return this.jCal[0]}},{key:"parent",get:function(){return this._parent},set:function(t){var e=!this._parent||t&&t._designSet!=this._parent._designSet;this._parent=t,this.type==It.defaultType&&e&&(this.jCal[2]=this.getDefaultType(),this._updateType())}},{key:"_designSet",get:function(){return this.parent?this.parent._designSet:It.defaultSet}},{key:"_updateType",value:function(){var t=this._designSet;this.type in t.value&&("decorate"in t.value[this.type]?this.isDecorated=!0:this.isDecorated=!1,this.name in t.property&&(this.isMultiValue="multiValue"in t.property[this.name],this.isStructuredValue="structuredValue"in t.property[this.name]))}},{key:"_hydrateValue",value:function(t){return this._values&&this._values[t]?this._values[t]:this.jCal.length<=3+t?null:this.isDecorated?(this._values||(this._values=[]),this._values[t]=this._decorate(this.jCal[3+t])):this.jCal[3+t]}},{key:"_decorate",value:function(t){return this._designSet.value[this.type].decorate(t,this)}},{key:"_undecorate",value:function(t){return this._designSet.value[this.type].undecorate(t,this)}},{key:"_setDecoratedValue",value:function(t,e){this._values||(this._values=[]),"object"===m(t)&&"icaltype"in t?(this.jCal[3+e]=this._undecorate(t),this._values[e]=t):(this.jCal[3+e]=t,this._values[e]=this._decorate(t))}},{key:"getParameter",value:function(t){return t in this.jCal[1]?this.jCal[1][t]:void 0}},{key:"getFirstParameter",value:function(t){var e=this.getParameter(t);return Array.isArray(e)?e[0]:e}},{key:"setParameter",value:function(t,e){var n=t.toLowerCase();"string"==typeof e&&n in this._designSet.param&&"multiValue"in this._designSet.param[n]&&(e=[e]),this.jCal[1][t]=e}},{key:"removeParameter",value:function(t){delete this.jCal[1][t]}},{key:"getDefaultType",value:function(){var t=this.jCal[0],e=this._designSet;if(t in e.property){var n=e.property[t];if("defaultType"in n)return n.defaultType}return It.defaultType}},{key:"resetType",value:function(t){this.removeAllValues(),this.jCal[2]=t,this._updateType()}},{key:"getFirstValue",value:function(){return this._hydrateValue(0)}},{key:"getValues",value:function(){var t=this.jCal.length-3;if(t<1)return[];for(var e=0,n=[];e<t;e++)n[e]=this._hydrateValue(e);return n}},{key:"removeAllValues",value:function(){this._values&&(this._values.length=0),this.jCal.length=3}},{key:"setValues",value:function(t){if(!this.isMultiValue)throw new Error(this.name+": does not not support mulitValue.\noverride isMultiValue");var e=t.length,n=0;if(this.removeAllValues(),e>0&&"object"===m(t[0])&&"icaltype"in t[0]&&this.resetType(t[0].icaltype),this.isDecorated)for(;n<e;n++)this._setDecoratedValue(t[n],n);else for(;n<e;n++)this.jCal[3+n]=t[n]}},{key:"setValue",value:function(t){this.removeAllValues(),"object"===m(t)&&"icaltype"in t&&this.resetType(t.icaltype),this.isDecorated?this._setDecoratedValue(t,0):this.jCal[3]=t}},{key:"toJSON",value:function(){return this.jCal}},{key:"toICALString",value:function(){return Lt.property(this.jCal,this._designSet,!0)}}],[{key:"fromString",value:function(e,n){return new t(C.property(e,n))}}])}(),Ut=function(){function t(e,n){r(this,t),o(this,"_hydratedPropertyCount",0),o(this,"_hydratedComponentCount",0),o(this,"_timezoneCache",null),o(this,"_components",null),o(this,"_properties",null),"string"==typeof e&&(e=[e,[],[]]),this.jCal=e,this.parent=n||null,this.parent||"vcalendar"!==this.name||(this._timezoneCache=new Map)}return a(t,[{key:"name",get:function(){return this.jCal[0]}},{key:"_designSet",get:function(){var t=this.parent&&this.parent._designSet;if(!t&&"vcard"==this.name){var e,n=null===(e=this.jCal[1])||void 0===e?void 0:e[0];if(n&&"version"==n[0]&&"3.0"==n[3])return It.getDesignSet("vcard3")}return t||It.getDesignSet(this.name)}},{key:"_hydrateComponent",value:function(e){if(this._components||(this._components=[],this._hydratedComponentCount=0),this._components[e])return this._components[e];var n=new t(this.jCal[2][e],this);return this._hydratedComponentCount++,this._components[e]=n}},{key:"_hydrateProperty",value:function(t){if(this._properties||(this._properties=[],this._hydratedPropertyCount=0),this._properties[t])return this._properties[t];var e=new Pt(this.jCal[1][t],this);return this._hydratedPropertyCount++,this._properties[t]=e}},{key:"getFirstSubcomponent",value:function(t){if(t)for(var e=0,n=this.jCal[2],r=n.length;e<r;e++){if(n[e][0]===t)return this._hydrateComponent(e)}else if(this.jCal[2].length)return this._hydrateComponent(0);return null}},{key:"getAllSubcomponents",value:function(t){var e=this.jCal[2].length,n=0;if(t){for(var r=this.jCal[2],i=[];n<e;n++)t===r[n][0]&&i.push(this._hydrateComponent(n));return i}if(!this._components||this._hydratedComponentCount!==e)for(;n<e;n++)this._hydrateComponent(n);return this._components||[]}},{key:"hasProperty",value:function(t){for(var e=this.jCal[1],n=e.length,r=0;r<n;r++)if(e[r][0]===t)return!0;return!1}},{key:"getFirstProperty",value:function(t){if(t)for(var e=0,n=this.jCal[1],r=n.length;e<r;e++){if(n[e][0]===t)return this._hydrateProperty(e)}else if(this.jCal[1].length)return this._hydrateProperty(0);return null}},{key:"getFirstPropertyValue",value:function(t){var e=this.getFirstProperty(t);return e?e.getFirstValue():null}},{key:"getAllProperties",value:function(t){var e=this.jCal[1].length,n=0;if(t){for(var r=this.jCal[1],i=[];n<e;n++)t===r[n][0]&&i.push(this._hydrateProperty(n));return i}if(!this._properties||this._hydratedPropertyCount!==e)for(;n<e;n++)this._hydrateProperty(n);return this._properties||[]}},{key:"_removeObjectByIndex",value:function(t,e,n){if((e=e||[])[n]){var r=e[n];"parent"in r&&(r.parent=null)}e.splice(n,1),this.jCal[t].splice(n,1)}},{key:"_removeObject",value:function(t,e,n){var r=0,i=this.jCal[t],a=i.length,s=this[e];if("string"==typeof n){for(;r<a;r++)if(i[r][0]===n)return this._removeObjectByIndex(t,s,r),!0}else if(s)for(;r<a;r++)if(s[r]&&s[r]===n)return this._removeObjectByIndex(t,s,r),!0;return!1}},{key:"_removeAllObjects",value:function(t,e,n){for(var r=this[e],i=this.jCal[t],a=i.length-1;a>=0;a--)n&&i[a][0]!==n||this._removeObjectByIndex(t,r,a)}},{key:"addSubcomponent",value:function(t){this._components||(this._components=[],this._hydratedComponentCount=0),t.parent&&t.parent.removeSubcomponent(t);var e=this.jCal[2].push(t.jCal);return this._components[e-1]=t,this._hydratedComponentCount++,t.parent=this,t}},{key:"removeSubcomponent",value:function(t){var e=this._removeObject(2,"_components",t);return e&&this._hydratedComponentCount--,e}},{key:"removeAllSubcomponents",value:function(t){var e=this._removeAllObjects(2,"_components",t);return this._hydratedComponentCount=0,e}},{key:"addProperty",value:function(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);var e=this.jCal[1].push(t.jCal);return this._properties[e-1]=t,this._hydratedPropertyCount++,t.parent=this,t}},{key:"addPropertyWithValue",value:function(t,e){var n=new Pt(t);return n.setValue(e),this.addProperty(n),n}},{key:"updatePropertyWithValue",value:function(t,e){var n=this.getFirstProperty(t);return n?n.setValue(e):n=this.addPropertyWithValue(t,e),n}},{key:"removeProperty",value:function(t){var e=this._removeObject(1,"_properties",t);return e&&this._hydratedPropertyCount--,e}},{key:"removeAllProperties",value:function(t){var e=this._removeAllObjects(1,"_properties",t);return this._hydratedPropertyCount=0,e}},{key:"toJSON",value:function(){return this.jCal}},{key:"toString",value:function(){return Lt.component(this.jCal,this._designSet)}},{key:"getTimeZoneByID",value:function(t){if(this.parent)return this.parent.getTimeZoneByID(t);if(!this._timezoneCache)return null;if(this._timezoneCache.has(t))return this._timezoneCache.get(t);var e,n=s(this.getAllSubcomponents("vtimezone"));try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.getFirstProperty("tzid").getFirstValue()===t){var i=new I({component:r,tzid:t});return this._timezoneCache.set(t,i),i}}}catch(t){n.e(t)}finally{n.f()}return null}}],[{key:"fromString",value:function(e){return new t(C.component(e))}}])}(),jt=function(){return a((function t(e){r(this,t),o(this,"complete",!1),o(this,"ruleIterators",null),o(this,"ruleDates",null),o(this,"exDates",null),o(this,"ruleDateInc",0),o(this,"exDateInc",0),o(this,"exDate",null),o(this,"ruleDate",null),o(this,"dtstart",null),o(this,"last",null),this.ruleDates=[],this.exDates=[],this.fromData(e)}),[{key:"fromData",value:function(t){var e=j(t.dtstart,b);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=j(t.last,b)||e.clone(),!t.ruleIterators)throw new Error(".ruleIterators or .component must be given");this.ruleIterators=t.ruleIterators.map((function(t){return j(t,X)})),this.ruleDateInc=t.ruleDateInc,this.exDateInc=t.exDateInc,t.ruleDates&&(this.ruleDates=t.ruleDates.map((function(t){return j(t,b)})),this.ruleDate=this.ruleDates[this.ruleDateInc]),t.exDates&&(this.exDates=t.exDates.map((function(t){return j(t,b)})),this.exDate=this.exDates[this.exDateInc]),void 0!==t.complete&&(this.complete=t.complete)}}},{key:"_compare_special",value:function(t,e){return!t.isDate&&e.isDate?new b({year:t.year,month:t.month,day:t.day}).compare(e):t.compare(e)}},{key:"next",value:function(){for(var t,e,n,r=0;;){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||((n=this._compare_special(this.last,this.exDate))>0&&this._nextExDay(),0!==n))return this.last;this._nextExDay()}}},{key:"toJSON",value:function(){function t(t){return t.toJSON()}var 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}},{key:"_extractDates",value:function(t,e){for(var n=[],r=t.getAllProperties(e),i=0,a=r.length;i<a;i++){var o,u=s(r[i].getValues());try{for(u.s();!(o=u.n()).done;){var l=o.value,h=H(n,l,(function(t,e){return t.compare(e)}));n.splice(h,0,l)}}catch(t){u.e(t)}finally{u.f()}}return n}},{key:"_init",value:function(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=H(this.ruleDates,this.last,(function(t,e){return t.compare(e)})),this.ruleDate=this.ruleDates[this.ruleDateInc]),t.hasProperty("rrule"))for(var e,n=t.getAllProperties("rrule"),r=0,i=n.length;r<i;r++)e=n[r].getFirstValue().iterator(this.dtstart),this.ruleIterators.push(e),e.next();t.hasProperty("exdate")&&(this.exDates=this._extractDates(t,"exdate"),this.exDateInc=H(this.exDates,this.last,this._compare_special),this.exDate=this.exDates[this.exDateInc])}},{key:"_nextExDay",value:function(){this.exDate=this.exDates[++this.exDateInc]}},{key:"_nextRuleDay",value:function(){this.ruleDate=this.ruleDates[++this.ruleDateInc]}},{key:"_nextRecurrenceIter",value:function(){var t=this.ruleIterators;if(0===t.length)return null;for(var e,n,r,i=t.length,a=0;a<i;a++)n=(e=t[a]).last,e.completed?(i--,0!==a&&a--,t.splice(a,1)):(!r||r.last.compare(n)>0)&&(r=e);return r}}])}(),Vt=function(){function t(e,n){r(this,t),o(this,"exceptions",null),o(this,"strictExceptions",!1),e instanceof Ut||(n=e,e=null),this.component=e||new Ut("vevent"),this._rangeExceptionCache=Object.create(null),this.exceptions=Object.create(null),this.rangeExceptions=[],n&&n.strictExceptions&&(this.strictExceptions=n.strictExceptions),n&&n.exceptions?n.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)}return a(t,[{key:"relateException",value:function(e){if(this.isRecurrenceException())throw new Error("cannot relate exception to exceptions");if(e instanceof Ut&&(e=new t(e)),this.strictExceptions&&e.uid!==this.uid)throw new Error("attempted to relate unrelated exception");var n=e.recurrenceId.toString();if(this.exceptions[n]=e,e.modifiesFuture()){var r=[e.recurrenceId.toUnixTime(),n],i=H(this.rangeExceptions,r,Ht);this.rangeExceptions.splice(i,0,r)}}},{key:"modifiesFuture",value:function(){return!!this.component.hasProperty("recurrence-id")&&this.component.getFirstProperty("recurrence-id").getParameter("range")===t.THISANDFUTURE}},{key:"findRangeException",value:function(t){if(!this.rangeExceptions.length)return null;var e=t.toUnixTime(),n=H(this.rangeExceptions,[e],Ht);if((n-=1)<0)return null;var r=this.rangeExceptions[n];return e<r[0]?null:r[1]}},{key:"getOccurrenceDetails",value:function(t){var e,n=t.toString(),r=t.convertToZone(I.utcTimezone).toString(),i={recurrenceId:t};if(n in this.exceptions)e=i.item=this.exceptions[n],i.startDate=e.startDate,i.endDate=e.endDate,i.item=e;else if(r in this.exceptions)e=this.exceptions[r],i.startDate=e.startDate,i.endDate=e.endDate,i.item=e;else{var a,s=this.findRangeException(t);if(s){var o=this.exceptions[s];i.item=o;var u=this._rangeExceptionCache[s];if(!u){var l=o.recurrenceId.clone(),h=o.startDate.clone();l.zone=h.zone,u=h.subtractDate(l),this._rangeExceptionCache[s]=u}var c=t.clone();c.zone=o.startDate.zone,c.addDuration(u),(a=c.clone()).addDuration(o.duration),i.startDate=c,i.endDate=a}else(a=t.clone()).addDuration(this.duration),i.endDate=a,i.startDate=t,i.item=this}return i}},{key:"iterator",value:function(t){return new jt({component:this.component,dtstart:t||this.startDate})}},{key:"isRecurring",value:function(){var t=this.component;return t.hasProperty("rrule")||t.hasProperty("rdate")}},{key:"isRecurrenceException",value:function(){return this.component.hasProperty("recurrence-id")}},{key:"getRecurrenceTypes",value:function(){for(var t=this.component.getAllProperties("rrule"),e=0,n=t.length,r=Object.create(null);e<n;e++){r[t[e].getFirstValue().freq]=!0}return r}},{key:"uid",get:function(){return this._firstProp("uid")},set:function(t){this._setProp("uid",t)}},{key:"startDate",get:function(){return this._firstProp("dtstart")},set:function(t){this._setTime("dtstart",t)}},{key:"endDate",get:function(){var t=this._firstProp("dtend");if(!t){var e=this._firstProp("duration");t=this.startDate.clone(),e?t.addDuration(e):t.isDate&&(t.day+=1)}return t},set:function(t){this.component.hasProperty("duration")&&this.component.removeProperty("duration"),this._setTime("dtend",t)}},{key:"duration",get:function(){var t=this._firstProp("duration");return t||this.endDate.subtractDateTz(this.startDate)},set:function(t){this.component.hasProperty("dtend")&&this.component.removeProperty("dtend"),this._setProp("duration",t)}},{key:"location",get:function(){return this._firstProp("location")},set:function(t){this._setProp("location",t)}},{key:"attendees",get:function(){return this.component.getAllProperties("attendee")}},{key:"summary",get:function(){return this._firstProp("summary")},set:function(t){this._setProp("summary",t)}},{key:"description",get:function(){return this._firstProp("description")},set:function(t){this._setProp("description",t)}},{key:"color",get:function(){return this._firstProp("color")},set:function(t){this._setProp("color",t)}},{key:"organizer",get:function(){return this._firstProp("organizer")},set:function(t){this._setProp("organizer",t)}},{key:"sequence",get:function(){return this._firstProp("sequence")},set:function(t){this._setProp("sequence",t)}},{key:"recurrenceId",get:function(){return this._firstProp("recurrence-id")},set:function(t){this._setTime("recurrence-id",t)}},{key:"_setTime",value:function(t,e){var n=this.component.getFirstProperty(t);n||(n=new Pt(t),this.component.addProperty(n)),e.zone===I.localTimezone||e.zone===I.utcTimezone?n.removeParameter("tzid"):n.setParameter("tzid",e.zone.tzid),n.setValue(e)}},{key:"_setProp",value:function(t,e){this.component.updatePropertyWithValue(t,e)}},{key:"_firstProp",value:function(t){return this.component.getFirstPropertyValue(t)}},{key:"toString",value:function(){return this.component.toString()}}])}();function Ht(t,e){return t[0]>e[0]?1:e[0]>t[0]?-1:0}o(Vt,"THISANDFUTURE","THISANDFUTURE");var Rt=function(){return a((function t(e){r(this,t),o(this,"parseEvent",!0),o(this,"parseTimezone",!0),o(this,"oncomplete",(function(){})),o(this,"onerror",(function(t){})),o(this,"ontimezone",(function(t){})),o(this,"onevent",(function(t){})),void 0===e&&(e={});for(var n=0,i=Object.entries(e);n<i.length;n++){var a=f(i[n],2),s=a[0],u=a[1];this[s]=u}}),[{key:"process",value:function(t){"string"==typeof t&&(t=C(t)),t instanceof Ut||(t=new Ut(t));for(var e,n=t.getAllSubcomponents(),r=0,i=n.length;r<i;r++)switch((e=n[r]).name){case"vtimezone":if(this.parseTimezone){var a=e.getFirstPropertyValue("tzid");a&&this.ontimezone(new I({tzid:a,component:e}))}break;case"vevent":this.parseEvent&&this.onevent(new Vt(e));break;default:continue}this.oncomplete()}}])}(),Wt={foldLength:75,debug:!1,newLineChar:"\r\n",Binary:_,Component:Ut,ComponentParser:Rt,Duration:T,Event:Vt,Period:A,Property:Pt,Recur:it,RecurExpansion:jt,RecurIterator:X,Time:b,Timezone:I,TimezoneService:L,UtcOffset:Z,VCardTime:G,parse:C,stringify:Lt,design:It,helpers:J};return Wt}));