diff --git a/plugins/view-ics/ical.es5.min.cjs b/plugins/view-ics/ical.es5.min.cjs new file mode 100644 index 0000000000..f94cf97675 --- /dev/null +++ b/plugins/view-ics/ical.es5.min.cjs @@ -0,0 +1,5 @@ +/* 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,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 e(t,e,r){return e=h(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,n()?Reflect.construct(e,r||[],h(t).constructor):e.apply(t,r))}function n(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(n=function(){return!!t})()}function r(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 i(t){return i="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},i(t)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=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}}}}var v,_=function(){function t(e){a(this,t),u(this,"icaltype","binary"),this.value=e}return o(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>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(un)-(e=0){o.day=1,0!=a&&a--,s=o.day;var u=t-o.dayOfWeek();u<0&&(u+=7),s+=u,s-=t,r=t}else{o.day=i,a++,(r=o.dayOfWeek()-t)<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(t){var n,r=(this.year<<12)+(this.month<<8)+(this.day<<3)+t;if(r in e._wnCache)return e._wnCache[r];var i=this.clone();i.isDate=!0;var a=this.year;12==i.month&&i.day>25?(n=e.weekOneStarts(a+1,t),i.compare(n)<0?n=e.weekOneStarts(a,t):a++):(n=e.weekOneStarts(a,t),i.compare(n)<0&&(n=e.weekOneStarts(--a,t)));var s=H(i.subtractDate(n).toSeconds()/86400/7)+1;return e._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){var e=this.toUnixTime(),n=t.toUnixTime();return e>n?1:n>e?-1:0}},{key:"compareDateOnlyTz",value:function(t,n){var r=this.convertToZone(n),i=t.convertToZone(n),a=0;return 0!=(a=e._cmp_attr(r,i,"year"))||0!=(a=e._cmp_attr(r,i,"month"))||(a=e._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||C.convert_time(e,this.zone,t),e.zone=t,e}},{key:"utcOffset",value:function(){return this.zone==C.localTimezone||this.zone==C.utcTimezone?0:this.zone.utcOffset(this)}},{key:"toICALString",value:function(){var t=this.toString();return t.length>10?Ct.icalendar.value["date-time"].toICAL(t):Ct.icalendar.value.date.toICAL(t)}},{key:"toString",value:function(){var t=this.year+"-"+R(this.month)+"-"+R(this.day);return this.isDate||(t+="T"+R(this.hour)+":"+R(this.minute)+":"+R(this.second),this.zone===C.utcTimezone&&(t+="Z")),t}},{key:"toJSDate",value:function(){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())}},{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(t,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=H(u/60),m.second<0&&(m.second+=60,s--),l=m.minute+r+s,m.minute=l%60,o=H(l/60),m.minute<0&&(m.minute+=60,o--),h=m.hour+n+o,m.hour=h%24,d=H(h/24),m.hour<0&&(m.hour+=24,d--)),m.month>12?y=H((m.month-1)/12):m.month<1&&(y=H(m.month/12)-1),m.year+=y,m.month-=12*y,(c=m.day+t+d)>0)for(;!(c<=(f=e.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+=e.daysInMonth(m.month,m.year);return m.day=c,this._cachedUnixTime=null,this}},{key:"fromUnixTime",value:function(t){this.zone=C.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;r12||(r=[0,31,28,31,30,31,30,31,31,30,31,30,31][t],2==t&&(r+=e.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(t,n){var r=n,i=t,a=new e;a.auto_normalize=!1;var s=e.isLeapYear(r)?1:0;if(i<1)return r--,s=e.isLeapYear(r)?1:0,i+=e.daysInYearPassedMonth[s][12],e.fromDayOfYear(i,r);if(i>e.daysInYearPassedMonth[s][12])return s=e.isLeapYear(r)?1:0,i-=e.daysInYearPassedMonth[s][12],r++,e.fromDayOfYear(i,r);a.year=r,a.isDate=!0;for(var o=11;o>=0;o--)if(i>e.daysInYearPassedMonth[s][o]){a.month=o+1,a.day=i-e.daysInYearPassedMonth[s][o];break}return a.auto_normalize=!0,a}},{key:"fromStringv2",value:function(t){return new e({year:parseInt(t.slice(0,4),10),month:parseInt(t.slice(5,7),10),day:parseInt(t.slice(8,10),10),isDate:!0})}},{key:"fromDateString",value:function(t){return new e({year:L(t.slice(0,4)),month:L(t.slice(5,7)),day:L(t.slice(8,10)),isDate:!0})}},{key:"fromDateTimeString",value:function(t,n){if(t.length<19)throw new Error('invalid date-time value: "'+t+'"');var r,i;t[19]&&"Z"===t[19]?r=C.utcTimezone:n&&(i=n.getParameter("tzid"),n.parent&&("standard"===n.parent.name||"daylight"===n.parent.name?r=C.localTimezone:i&&(r=n.parent.getTimeZoneByID(i))));var a={year:L(t.slice(0,4)),month:L(t.slice(5,7)),day:L(t.slice(8,10)),hour:L(t.slice(11,13)),minute:L(t.slice(14,16)),second:L(t.slice(17,19))};return i&&!r&&(a.timezone=i),new e(a,r)}},{key:"fromString",value:function(t,n){return t.length>10?e.fromDateTimeString(t,n):e.fromDateString(t)}},{key:"fromJSDate",value:function(t,n){return(new e).fromJSDate(t,n)}},{key:"now",value:function(){return e.fromJSDate(new Date,!1)}},{key:"weekOneStarts",value:function(t,n){var r=e.fromData({year:t,month:1,day:1,isDate:!0}),i=r.dayOfWeek(),a=n||e.DEFAULT_WEEK_START;return i>e.THURSDAY&&(r.day+=7),a>e.THURSDAY&&(r.day-=7),r.day-=i-a,r}},{key:"getDominicalLetter",value:function(t){var n="GFEDCBA",r=(t+(t/4|0)+(t/400|0)-(t/100|0)-1)%7;return e.isLeapYear(t)?n[(r+6)%7]+n[r]:n[r]}},{key:"epochTime",get:function(){return t(e,this,b)._||(b._=t(e,this,e.fromData({year:1970,month:1,day:1,hour:0,minute:0,second:0,isDate:!1,timezone:"Z"}))),t(e,this,b)._}},{key:"_cmp_attr",value:function(t,e,n){return t[n]>e[n]?1:t[n]1)throw new w("invalid ical body. component began but did not end");return e=null,1==n.length?n[0]:n}S.property=function(t,e){var n={component:[[],[]],designSet:e||Ct.defaultSet};return S._handleContentLine(t,n),n.component[1][0]},S.component=function(t){return S(t)};var w=function(t){function n(t){var r;a(this,n),(r=e(this,n,[t])).name=r.constructor.name;try{throw new Error}catch(t){if(t.stack){var i=t.stack.split("\n");i.shift(),r.stack=i.join("\n")}}return r}return l(n,t),o(n)}(f(Error));S.ParserError=w,S._handleContentLine=function(t,e){var n,r,i,a,s,o,u=t.indexOf(":"),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=S._parseParameters(t.slice(Math.max(0,l)),0,e.designSet))[2])throw new w("Invalid parameters in '"+t+"'");if(h=s[0],n=s[1].length+s[2]+l,-1===(r=t.slice(Math.max(0,n)).indexOf(":")))throw new w("Missing parameter value in '"+t+"'");a=t.slice(Math.max(0,n+r+1))}else{if(-1===u)throw new w('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=Ct.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=S._parseMultiValue(a,v,o,[],p,e.designSet,v)]:p?(m=[y,h,o],S._parseMultiValue(a,p,o,m,null,e.designSet,!1)):m=v?[y,h,o,a=S._parseMultiValue(a,v,o,[],null,e.designSet,v)]:[y,h,o,a=S._parseValue(a,o,e.designSet,!1)],"vcard"!==e.component[0]||0!==e.component[1].length||"version"===i&&"4.0"===a||(e.designSet=Ct.getDesignSet("vcard3")),e.component[1].push(m)},S._parseValue=function(t,e,n,r){return e in n.value&&"fromICAL"in n.value[e]?n.value[e].fromICAL(t,r):t},S._parseParameters=function(t,e,n){for(var r,i,a,s,o,u,l=e,h=0,c={},f=-1;!1!==h&&-1!==(h=P(t,"=",h+1));){if(0==(r=t.slice(l+1,h)).length)throw new w("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=S._rfc6868Escape('"'+o+'"'))),'"'===t[h+1]){if(h=P(t,'"',f=h+2),o&&-1!=h)for(var d=!0;d;)t[h+1]==o&&'"'==t[h+2]?h=P(t,'"',h+3):d=!1;if(-1===h)throw new w('invalid line (no matching double quote) "'+t+'"');a=t.slice(f,h),-1===(l=P(t,";",h))&&(h=!1)}else{var y=P(t,";",f=h+1),m=P(t,":",f);-1!==m&&y>m?(y=m,h=!1):-1===y?(y=-1===m?t.length:m,h=!1):(l=y,h=y),a=t.slice(f,y)}if(a=S._rfc6868Escape(a),o){var p=u||o;a=S._parseMultiValue(a,p,s,[],null,n)}else a=S._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]},S._rfc6868Escape=function(t){return t.replace(/\^['n^]/g,(function(t){return A[t]}))},S._parseMultiValue=function(t,e,n,r,i,a,s){var o,u=0,l=0;if(0===e.length)return t;for(;-1!==(u=P(t,e,l));)o=t.slice(l,u),o=i?S._parseMultiValue(o,i,n,[],null,a,s):S._parseValue(o,n,a,s),r.push(o),l=u+e.length;return o=t.slice(l),o=i?S._parseMultiValue(o,i,n,[],null,a,s):S._parseValue(o,n,a,s),r.push(o),1==r.length?r[0]:r},S._eachLine=function(t,e){var n,r,i,a=t.length,s=t.search(O),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 E=["tzid","location","tznames","latitude","longitude"],C=function(){function e(t){a(this,e),u(this,"tzid",""),u(this,"location",""),u(this,"tznames",""),u(this,"latitude",0),u(this,"longitude",0),u(this,"component",null),u(this,"expandedUntilYear",0),u(this,"icalclass","icaltimezone"),this.wrappedJSObject=this,this.fromData(t)}return o(e,[{key:"fromData",value:function(t){if(this.expandedUntilYear=0,this.changes=[],t instanceof Lt)this.component=t;else{if(t&&"component"in t)if("string"==typeof t.component){var e=S(t.component);this.component=new Lt(e)}else t.component instanceof Lt?this.component=t.component:this.component=null;for(var n=0,r=E;n=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=j(o,!0);if(e.adjust_change(u,0,0,0,u.prevUtcOffset),e._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(t){var n=U(this.changes,t,e._compare_change_fn);return n>=this.changes.length?this.changes.length-1:n}},{key:"_ensureCoverage",value:function(t){if(-1==e._minimumExpansionYear){var n=k.now();e._minimumExpansionYear=n.year}var r=t;if(rn)&&f);)i.year=f.year,i.month=f.month,i.day=f.day,i.hour=f.hour,i.minute=f.minute,i.second=f.second,i.isDate=f.isDate,e.adjust_change(i,0,0,0,-i.prevUtcOffset),r.push(i)}}else(i=o()).year=a.year,i.month=a.month,i.day=a.day,i.hour=a.hour,i.minute=a.minute,i.second=a.second,e.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.yeare.year?1:t.monthe.month?1:t.daye.day?1:t.houre.hour?1:t.minutee.minute?1:t.seconde.second?1:0}},{key:"convert_time",value:function(t,n,r){if(t.isDate||n.tzid==r.tzid||n==e.localTimezone||r==e.localTimezone)return t.zone=r,t;var i=n.utcOffset(t);return t.adjust(0,0,0,-i),i=r.utcOffset(t),t.adjust(0,0,0,i),null}},{key:"fromData",value:function(t){return(new e).fromData(t)}},{key:"utcTimezone",get:function(){return t(e,this,x)._||(x._=t(e,this,e.fromData({tzid:"UTC"}))),t(e,this,x)._}},{key:"localTimezone",get:function(){return t(e,this,N)._||(N._=t(e,this,e.fromData({tzid:"floating"}))),t(e,this,N)._}},{key:"adjust_change",value:function(t,e,n,r,i){return k.prototype.adjust.call(t,e,n,r,i,t)}}])}(),x={_:null},N={_:null};u(C,"_minimumExpansionYear",-1),u(C,"EXTRA_COVERAGE",5);var I=null,B={get count(){return null===I?0:Object.keys(I).length},reset:function(){I=Object.create(null);var t=C.utcTimezone;I.Z=t,I.UTC=t,I.GMT=t},has:function(t){return null!==I&&!!I[t]},get:function(t){return null===I&&this.reset(),I[t]},register:function(t,e){if(null===I&&this.reset(),t instanceof Lt&&"vtimezone"===t.name&&(t=(e=new C(t)).tzid),!(e instanceof C))throw new TypeError("timezone must be ICAL.Timezone or ICAL.Component");I[t]=e},remove:function(t){return null===I?null:delete I[t]}};function M(t){return"number"==typeof t&&isNaN(t)}function L(t){var e=parseInt(t,10);if(M(e))throw new Error('Could not extract integer from "'+t+'"');return e}function z(t,e){if(void 0!==t)return t instanceof e?t:new e(t)}function P(t,e,n){for(;-1!==(n=t.indexOf(e,n));){if(!(n>0&&"\\"===t[n-1]))return n;n+=1}return-1}function U(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 j(t,e){if(t&&"object"==i(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;r65535?2:1:(e+=Vt.newLineChar+" "+n.slice(0,Math.max(0,r)),n=n.slice(Math.max(0,r)),r=i=0)}return e.slice(Vt.newLineChar.length+1)}function R(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 H(t){return t<0?Math.ceil(t):Math.floor(t)}function W(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 F=Object.freeze({__proto__:null,updateTimezones:function(t){var e,n,r,i,a;if(!t||"vcalendar"!==t.name)return t;for(e=t.getAllSubcomponents(),n=[],r={},a=0;an)-(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 Ct.icalendar.value["utc-offset"].toICAL(this.toString())}},{key:"toString",value:function(){return(1==this.factor?"+":"-")+R(this.hours)+":"+R(this.minutes)}}],[{key:"fromString",value:function(e){var n={};return n.factor="+"===e[0]?1:-1,n.hours=L(e.slice(1,3)),n.minutes=L(e.slice(4,6)),new t(n)}},{key:"fromSeconds",value:function(e){var n=new t;return n.fromSeconds(e),n}}])}(),q=function(t){function n(t,r,i){var s;return a(this,n),u(s=e(this,n,[t,r]),"icalclass","vcardtime"),u(s,"icaltype","date-and-or-time"),s.icaltype=i||"date-and-or-time",s}return l(n,t),o(n,[{key:"clone",value:function(){return new n(this._time,this.zone,this.icaltype)}},{key:"_normalize",value:function(){return this}},{key:"utcOffset",value:function(){return this.zone instanceof K?this.zone.toSeconds():k.prototype.utcOffset.apply(this,arguments)}},{key:"toICALString",value:function(){return Ct.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?R(e)+(o||u?"-":""):o||u?"--":"")+(o?R(n):"")+(u?"-"+R(r):""),d=(l?R(i):"-")+(l&&h?":":"")+(h?R(a):"")+(l||h?"":"-")+(h&&c?":":"")+(c?R(s):"");if(this.zone===C.utcTimezone)t="Z";else if(this.zone instanceof K)t=this.zone.toString();else if(this.zone===C.localTimezone)t="";else if(this.zone instanceof C){t=K.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,e){function r(t,e,n){return t?L(t.slice(e,e+n)):null}var i=t.split("T"),a=i[0],s=i[1],o=s?Ct.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 n({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?C.utcTimezone:u&&":"==u[3]?K.fromString(u):null,e)}}])}(k),J=function(){function t(e){a(this,t),u(this,"completed",!1),u(this,"rule",null),u(this,"dtstart",null),u(this,"last",null),u(this,"occurrence_number",0),u(this,"by_indices",null),u(this,"initialized",!1),u(this,"by_data",null),u(this,"days",null),u(this,"days_index",0),this.fromData(e)}return o(t,[{key:"fromData",value:function(t){if(this.rule=z(t.rule,tt),!this.rule)throw new Error("iterator requires a (ICAL.Recur) rule");if(this.dtstart=z(t.dtstart,k),!this.dtstart)throw new Error("iterator requires a (ICAL.Time) dtstart");t.by_data?this.by_data=t.by_data:this.by_data=j(this.rule.parts,!0),t.occurrence_number&&(this.occurrence_number=t.occurrence_number),this.days=t.days||[],t.last&&(this.last=z(t.last,k)),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()}},{key:"init",value:function(){this.initialized=!0,this.last=this.dtstart.clone();var 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);var 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){var n=d(this.ruleDayOfWeek(t.BYDAY[0],this.rule.wkst),2)[1],r=n-this.last.dayOfWeek(this.rule.wkst);(this.last.dayOfWeek(this.rule.wkst)=0||r<0)&&(this.last.day+=r)}else{var i=tt.numericDayToIcalDay(this.dtstart.dayOfWeek());t.BYDAY=[i]}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")){var a,s=null,o=this.last.clone(),u=k.daysInMonth(this.last.month,this.last.year),l=p(this.by_data.BYDAY);try{for(l.s();!(a=l.n()).done;){var h=a.value;this.last=o.clone();var c=d(this.ruleDayOfWeek(h),2),f=c[0],y=c[1],m=this.last.nthWeekDay(y,f);if(f>=6||f<=-6)throw new Error("Malformed values in BYDAY part");if(m>u||m<=0){if(s&&s.month==o.month)continue;for(;m>u||m<=0;)this.increment_month(),u=k.daysInMonth(this.last.month,this.last.year),m=this.last.nthWeekDay(y,f)}this.last.day=m,(!s||this.last.compare(s)<0)&&(s=this.last.clone())}}catch(t){l.e(t)}finally{l.f()}if(this.last=s.clone(),this.has_by_data("BYMONTHDAY")&&this._byDayAndMonthDay(!0),this.last.day>u||0==this.last.day)throw new Error("Malformed values in BYDAY part")}else if(this.has_by_data("BYMONTHDAY")){this.last.day=1;var v=k.daysInMonth(this.last.month,this.last.year);if(e<0)this.last.day=v+e+1;else if(this.by_data.BYMONTHDAY[0]>v){if(!this.next_month()&&!this.next_month()&&!this.next_month())throw new Error("No possible occurrences")}else this.last.day=e}}},{key:"next",value:function(){var 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)}},{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=k.daysInMonth(e,t),a=[],s=0,o=n.length;si)){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=k.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)&&si)f();else{var y=e[s++];if(y>=n){h=y;for(var m=0;mn&&(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());var o=k.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=k.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 k;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=k.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(){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}},{key:"_nextByYearDay",value:function(){var t=this.days[this.days_index],e=this.last.year;t<1&&(t+=1,e+=1);var n=k.fromDayOfYear(t,e);this.last.day=n.day,this.last.month=n.month}},{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=tt.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;en&&(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=H(this.last.month/12);this.last.month%=12,this.last.month++,0!=t&&this.increment_year(t)}}},{key:"increment_year",value:function(t){this.last.year+=t}},{key:"increment_generic",value:function(t,e,n,r){this.last[e]+=t;var i=H(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 k;this.days=[];for(var n={},r=0,i=["BYDAY","BYWEEKNO","BYMONTHDAY","BYMONTH","BYYEARDAY"];r0?(J=Z+7*(K-1))<=M&&this.days.push(z+J):(J=G+7*(K+1))>0&&this.days.push(z+J)}}catch(t){H.e(t)}finally{H.f()}}}}catch(t){I.e(t)}finally{I.f()}this.days.sort((function(t,e){return t-e}))}else if(2==d&&"BYDAY"in n&&"BYMONTHDAY"in n){var Q,$=p(this.expand_by_day(t));try{for($.s();!(Q=$.n()).done;){var tt=Q.value,et=k.fromDayOfYear(tt,t);this.by_data.BYMONTHDAY.indexOf(et.day)>=0&&this.days.push(tt)}}catch(t){$.e(t)}finally{$.f()}}else if(3==d&&"BYDAY"in n&&"BYMONTHDAY"in n&&"BYMONTH"in n){var nt,rt=p(this.expand_by_day(t));try{for(rt.s();!(nt=rt.n()).done;){var it=nt.value,at=k.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==d&&"BYDAY"in n&&"BYWEEKNO"in n){var st,ot=p(this.expand_by_day(t));try{for(ot.s();!(st=ot.n()).done;){var ut=st.value,lt=k.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 3==d&&"BYDAY"in n&&"BYWEEKNO"in n&&"BYMONTHDAY"in n||(this.days=1==d&&"BYYEARDAY"in n?this.days.concat(this.by_data.BYYEARDAY):[]);return 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(),s=n.dayOfYear(),o=p(this.by_data.BYDAY);try{for(o.s();!(i=o.n()).done;){var u=i.value,l=this.ruleDayOfWeek(u),h=l[0],c=l[1];if(0==h)for(var f=(c+7-r)%7+1;f<=s;f+=7)e.push(f);else if(h>0){var d=void 0;d=c>=r?c-r+1:c-r+8,e.push(d+7*(h-1))}else{var y=void 0;h=-h,y=c<=a?s-a+c:s-a+c-7,e.push(y-7*(h-1))}}}catch(t){o.e(t)}finally{o.f()}return e}},{key:"is_day_in_byday",value:function(t){if(this.by_data.BYDAY){var e,n=p(this.by_data.BYDAY);try{for(n.s();!(e=n.n()).done;){var r=e.value,i=this.ruleDayOfWeek(r),a=i[0],s=i[1],o=t.dayOfWeek();if(0==a&&s==o||t.nthWeekDay(s,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;ethis.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 s,o=p(this.by_data[e]);try{for(o.s();!(s=o.n()).done;){if(s.value==n){a=!0;break}}}catch(t){o.e(t)}finally{o.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",tt.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}}])}();u(J,"_indexMap",{BYSECOND:0,BYMINUTE:1,BYHOUR:2,BYDAY:3,BYMONTHDAY:4,BYYEARDAY:5,BYWEEKNO:6,BYMONTH:7,BYSETPOS:8}),u(J,"_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]}),u(J,"UNKNOWN",0),u(J,"CONTRACT",1),u(J,"EXPAND",2),u(J,"ILLEGAL",3);var Z=/^(SU|MO|TU|WE|TH|FR|SA)$/,G=/^([+-])?(5[0-3]|[1-4][0-9]|[1-9])?(SU|MO|TU|WE|TH|FR|SA)$/,X={SU:k.SUNDAY,MO:k.MONDAY,TU:k.TUESDAY,WE:k.WEDNESDAY,TH:k.THURSDAY,FR:k.FRIDAY,SA:k.SATURDAY},Q=Object.fromEntries(Object.entries(X).map((function(t){return t.reverse()}))),$=["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"],tt=function(){function t(e){a(this,t),u(this,"parts",null),u(this,"interval",1),u(this,"wkst",k.MONDAY),u(this,"until",null),u(this,"count",null),u(this,"freq",null),u(this,"icalclass","icalrecur"),u(this,"icaltype","recur"),this.wrappedJSObject=this,this.parts={},e&&"object"===i(e)&&this.fromData(e)}return o(t,[{key:"iterator",value:function(t){return new J({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 rt?Array.isArray(e[n])?this.parts[r]=e[n]:this.parts[r]=[e[n]]:this[n]=e[n]}this.interval&&"number"!=typeof this.interval&&nt.INTERVAL(this.interval,this),this.wkst&&"number"!=typeof this.wkst&&(this.wkst=t.icalDayToNumericDay(this.wkst)),!this.until||this.until instanceof k||(this.until=k.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);n1&&(e+=";INTERVAL="+this.interval);for(var n=0,r=Object.entries(this.parts);n7&&(n-=7),Q[n]}}])}();function et(t,e,n,r){var i=r;if("+"===r[0]&&(i=r.slice(1)),i=L(i),void 0!==e&&r '+e);if(void 0!==n&&r>n)throw new Error(t+': invalid value "'+r+'" must be < '+e);return i}var nt={FREQ:function(t,e,n){if(-1===$.indexOf(t))throw new Error('invalid frequency "'+t+'" expected: "'+$.join(", ")+'"');e.freq=t},COUNT:function(t,e,n){e.count=L(t)},INTERVAL:function(t,e,n){e.interval=L(t),e.interval<1&&(e.interval=1)},UNTIL:function(t,e,n){t.length>10?e.until=Ct.icalendar.value["date-time"].fromICAL(t):e.until=Ct.icalendar.value.date.fromICAL(t),n||(e.until=k.fromString(e.until))},WKST:function(t,e,n){if(!Z.test(t))throw new Error('invalid WKST value "'+t+'"');e.wkst=tt.icalDayToNumericDay(t)}},rt={BYSECOND:et.bind(void 0,"BYSECOND",0,60),BYMINUTE:et.bind(void 0,"BYMINUTE",0,59),BYHOUR:et.bind(void 0,"BYHOUR",0,23),BYDAY:function(t){if(G.test(t))return t;throw new Error('invalid BYDAY value "'+t+'"')},BYMONTHDAY:et.bind(void 0,"BYMONTHDAY",-31,31),BYYEARDAY:et.bind(void 0,"BYYEARDAY",-366,366),BYWEEKNO:et.bind(void 0,"BYWEEKNO",-53,53),BYMONTH:et.bind(void 0,"BYMONTH",1,12),BYSETPOS:et.bind(void 0,"BYSETPOS",-366,366)},it=function(){function t(e){if(a(this,t),u(this,"start",null),u(this,"end",null),u(this,"duration",null),u(this,"icalclass","icalperiod"),u(this,"icaltype","period"),this.wrappedJSObject=this,e&&"start"in e){if(e.start&&!(e.start instanceof k))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 k))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 o(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:"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:k.fromDateTimeString(r[0],n)},a=r[1];return T.isValueString(a)?i.duration=T.fromString(a):i.end=k.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?k.fromString(t,e):k.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)})}}])}(),at=/\\\\|\\,|\\[Nn]/g,st=/\\|,|\n/g;function ot(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,_t)}(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 ut={defaultType:"text"},lt={defaultType:"text",multiValue:","},ht={defaultType:"text",structuredValue:";"},ct={defaultType:"integer"},ft={defaultType:"date-time",allowedTypes:["date-time","date"]},dt={defaultType:"date-time"},yt={defaultType:"uri"},mt={defaultType:"utc-offset"},pt={defaultType:"recur"},vt={defaultType:"date-and-or-time",allowedTypes:["date-time","date","text"]};function _t(t){switch(t){case"\\\\":return"\\";case"\\;":return";";case"\\,":return",";case"\\n":case"\\N":return"\n";default:return t}}var gt={categories:lt,url:yt,version:ut,uid:ut},Dt={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 M(e)?0:e},toICAL:function(t){return String(t)}},integer:{fromICAL:function(t){var e=parseInt(t);return M(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 K.fromString(t)},undecorate:function(t){return t.toString()}}},Tt=W(Dt,{text:ot(/\\\\|\\;|\\,|\\[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 Ct.strict?k.fromDateString(t,e):k.fromString(t,e)},undecorate:function(t){return t.toString()},fromICAL:function(t){return!Ct.strict&&t.length>=15?Tt["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?Tt["date-time"].toICAL(t):t}},"date-time":{fromICAL:function(t){if(Ct.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 Tt.date.fromICAL(t)},toICAL:function(t){var e=t.length;if(10!=e||Ct.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 Tt.date.toICAL(t)},decorate:function(t,e){return Ct.strict?k.fromDateTimeString(t,e):k.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]=Tt["date-time"].fromICAL(e[0]),T.isValueString(e[1])||(e[1]=Tt["date-time"].fromICAL(e[1])),e},toICAL:function(t){return t=t.slice(),Ct.strict||10!=t[0].length?t[0]=Tt["date-time"].toICAL(t[0]):t[0]=Tt.date.toICAL(t[0]),T.isValueString(t[1])||(Ct.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 it.fromJSON(t,e,!Ct.strict)},undecorate:function(t){return t.toJSON()}},recur:{fromICAL:function(t){return tt._stringToData(t,!0)},toICAL:function(t){for(var e="",n=0,r=Object.entries(t);n10?Tt["date-time"].toICAL(s):Tt.date.toICAL(s):"wkst"==a?"number"==typeof s&&(s=tt.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 tt.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}}}),Yt=W(gt,{action:ut,attach:{defaultType:"uri"},attendee:{defaultType:"cal-address"},calscale:ut,class:ut,comment:ut,completed:dt,contact:ut,created:dt,description:ut,dtend:ft,dtstamp:dt,dtstart:ft,due:ft,duration:{defaultType:"duration"},exdate:{defaultType:"date-time",allowedTypes:["date-time","date"],multiValue:","},exrule:pt,freebusy:{defaultType:"period",multiValue:","},geo:{defaultType:"float",structuredValue:";"},"last-modified":dt,location:ut,method:ut,organizer:{defaultType:"cal-address"},"percent-complete":ct,priority:ct,prodid:ut,"related-to":ut,repeat:ct,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":ft,resources:lt,"request-status":ht,rrule:pt,sequence:ct,status:ut,summary:ut,transp:ut,trigger:{defaultType:"duration",allowedTypes:["duration","date-time"]},tzoffsetfrom:mt,tzoffsetto:mt,tzurl:yt,tzid:ut,tzname:ut}),kt=W(Dt,{text:ot(at,st),uri:ot(at,st),date:{decorate:function(t){return q.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 q.fromDateAndOrTimeString("T"+t,"time")},undecorate:function(t){return t.toString()},fromICAL:function(t){var e=kt.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=kt.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 q.fromDateAndOrTimeString(t,"date-time")},undecorate:function(t){return t.toString()},fromICAL:function(t){return kt["date-and-or-time"].fromICAL(t)},toICAL:function(t){return kt["date-and-or-time"].toICAL(t)}},"date-and-or-time":{decorate:function(t){return q.fromDateAndOrTimeString(t,"date-and-or-time")},undecorate:function(t){return t.toString()},fromICAL:function(t){var e=t.split("T");return(e[0]?kt.date.fromICAL(e[0]):"")+(e[1]?"T"+kt.time.fromICAL(e[1]):"")},toICAL:function(t){var e=t.split("T");return kt.date.toICAL(e[0])+(e[1]?"T"+kt.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("")}}}),bt=W(gt,{adr:{defaultType:"text",structuredValue:";",multiValue:","},anniversary:vt,bday:vt,caladruri:yt,caluri:yt,clientpidmap:ht,email:ut,fburl:yt,fn:ut,gender:ht,geo:yt,impp:yt,key:yt,kind:ut,lang:{defaultType:"language-tag"},logo:yt,member:yt,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:lt,note:ut,org:{defaultType:"text",structuredValue:";"},photo:yt,related:yt,rev:{defaultType:"timestamp"},role:ut,sound:yt,source:yt,tel:{defaultType:"uri",allowedTypes:["uri","text"]},title:ut,tz:{defaultType:"text",allowedTypes:["text","utc-offset","uri"]},xml:ut}),Ot=W(Dt,{binary:Tt.binary,date:kt.date,"date-time":kt["date-time"],"phone-number":kt["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 K.fromString(t)},undecorate:function(t){return t.toString()}}}),At=W(gt,{fn:ut,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:lt,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:ut,tel:{defaultType:"phone-number"},email:ut,mailer:ut,tz:{defaultType:"utc-offset",allowedTypes:["utc-offset","text"]},geo:{defaultType:"float",structuredValue:";"},title:ut,role:ut,logo:{defaultType:"binary",allowedTypes:["binary","uri"]},agent:{defaultType:"vcard",allowedTypes:["vcard","text","uri"]},org:ht,note:lt,prodid:ut,rev:{defaultType:"date-time",allowedTypes:["date-time","date"],detectType:function(t){return-1===t.indexOf("T")?"date":"date-time"}},"sort-string":ut,sound:{defaultType:"binary",allowedTypes:["binary","uri"]},class:ut,key:{defaultType:"binary",allowedTypes:["binary","text"]}}),St={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:Yt,propertyGroups:!1},wt={value:kt,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:bt,propertyGroups:!0},Et={value:Ot,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:At,propertyGroups:!0},Ct={strict:!0,defaultSet:St,defaultType:"unknown",components:{vcard:wt,vcard3:Et,vevent:St,vtodo:St,vjournal:St,valarm:St,vtimezone:St,daylight:St,standard:St},icalendar:St,vcard:wt,vcard3:Et,getDesignSet:function(t){return t&&t in Ct.components?Ct.components[t]:Ct.defaultSet}},xt="\r\n",Nt="unknown",It={'"':"^'","\n":"^n","^":"^^"};function Bt(t){"string"==typeof t[0]&&(t=[t]);for(var e=0,n=t.length,r="";e0&&("version"!==t[1][0][0]||"4.0"!==t[1][0][3])&&(o="vcard3"),e=e||Ct.getDesignSet(o);a0&&"object"===i(t[0])&&"icaltype"in t[0]&&this.resetType(t[0].icaltype),this.isDecorated)for(;n=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 Mt))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 Mt(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 Bt.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=p(this.getAllSubcomponents("vtimezone"));try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.getFirstProperty("tzid").getFirstValue()===t){var i=new C({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(S.component(e))}}])}(),zt=function(){return o((function t(e){a(this,t),u(this,"complete",!1),u(this,"ruleIterators",null),u(this,"ruleDates",null),u(this,"exDates",null),u(this,"ruleDateInc",0),u(this,"exDateInc",0),u(this,"exDate",null),u(this,"ruleDate",null),u(this,"dtstart",null),u(this,"last",null),this.ruleDates=[],this.exDates=[],this.fromData(e)}),[{key:"fromData",value:function(t){var e=z(t.dtstart,k);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=z(t.last,k)||e.clone(),!t.ruleIterators)throw new Error(".ruleIterators or .component must be given");this.ruleIterators=t.ruleIterators.map((function(t){return z(t,J)})),this.ruleDateInc=t.ruleDateInc,this.exDateInc=t.exDateInc,t.ruleDates&&(this.ruleDates=t.ruleDates.map((function(t){return z(t,k)})),this.ruleDate=this.ruleDates[this.ruleDateInc]),t.exDates&&(this.exDates=t.exDates.map((function(t){return z(t,k)})),this.exDate=this.exDates[this.exDateInc]),void 0!==t.complete&&(this.complete=t.complete)}}},{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.exDate.compare(this.last))<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;i0)&&(r=e);return r}}])}(),Pt=function(){function t(e,n){a(this,t),u(this,"exceptions",null),u(this,"strictExceptions",!1),e instanceof Lt||(n=e,e=null),this.component=e||new Lt("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 o(t,[{key:"relateException",value:function(e){if(this.isRecurrenceException())throw new Error("cannot relate exception to exceptions");if(e instanceof Lt&&(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=U(this.rangeExceptions,r,Ut);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=U(this.rangeExceptions,[e],Ut);if((n-=1)<0)return null;var r=this.rangeExceptions[n];return ee[0]?1:e[0]>t[0]?-1:0}u(Pt,"THISANDFUTURE","THISANDFUTURE");var jt=function(){return o((function t(e){a(this,t),u(this,"parseEvent",!0),u(this,"parseTimezone",!0),u(this,"oncomplete",(function(){})),u(this,"onerror",(function(t){})),u(this,"ontimezone",(function(t){})),u(this,"onevent",(function(t){})),void 0===e&&(e={});for(var n=0,r=Object.entries(e);nUseLangs(true); $this->addJs('message.js'); + $this->addJs('ical.es5.min.cjs'); $this->addJs('windowsZones.js'); } } diff --git a/plugins/view-ics/message.js b/plugins/view-ics/message.js index 38153361f3..d5645c5179 100644 --- a/plugins/view-ics/message.js +++ b/plugins/view-ics/message.js @@ -36,13 +36,13 @@
- - - + + + + - - - + +
Organizer
Start
End
Organizer:
Start:
End:
Location:
Attendees:
`)); @@ -88,55 +88,33 @@ }); // ICS attachment // let ics = msg.attachments.find(attachment => 'application/ics' == attachment.mimeType); + let ics = msg.attachments.find(attachment => 'text/calendar' == attachment.mimeType); if (ics && ics.download) { + // fetch it and parse the VEVENT rl.fetch(ics.linkDownload()) .then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response }))) .then(text => { - let VEVENT, - VALARM, - multiple = ['ATTACH','ATTENDEE','CATEGORIES','COMMENT','CONTACT','EXDATE', - 'EXRULE','RSTATUS','RELATED','RESOURCES','RDATE','RRULE'], - lines = text.split(/\r?\n/), - i = lines.length; - while (i--) { - let line = lines[i]; - if (VEVENT) { - while (line.startsWith(' ') && i--) { - line = lines[i] + line.slice(1); - } - if (line.startsWith('END:VALARM')) { - VALARM = {}; - continue; - } else if (line.startsWith('BEGIN:VALARM')) { - VEVENT.VALARM || (VEVENT.VALARM = []); - VEVENT.VALARM.push(VALARM); - VALARM = null; - continue; - } else if (line.startsWith('BEGIN:VEVENT')) { - break; - } - line = line.match(/^([^:;]+)[:;](.+)$/); - if (line) { - if (VALARM) { - VALARM[line[1]] = line[2]; - } else if (multiple.includes(line[1]) || 'X-' == line[1].slice(0,2)) { - VEVENT[line[1]] || (VEVENT[line[1]] = []); - VEVENT[line[1]].push(line[2]); - } else { - if ('DTSTART' === line[1] || 'DTEND' === line[1]) { - line[2] = parseDate(line[2]); - } - VEVENT[line[1]] = line[2]; - } - } - } else if (line.startsWith('END:VEVENT')) { - VEVENT = {}; - } + let jcalData = ICAL.parse(text) + var comp = new ICAL.Component(jcalData); + var vevent = comp.getFirstSubcomponent("vevent"); + var event = new ICAL.Event(vevent); + let VEVENT = {}; + if(event.organizer.startsWith("mailto:")){ + VEVENT.ORGANIZER_TXT=event.organizer.substr(7) + VEVENT.ORGANIZER_MAIL = event.organizer + } else + VEVENT.ORGANIZER_TXT=event.organizer + VEVENT.SUMMARY = event.summary; + VEVENT.DTSTART = parseDate(vevent.getFirstPropertyValue("dtstart")); + VEVENT.DTEND = parseDate(vevent.getFirstPropertyValue("dtend")); + VEVENT.LOCATION = event.location; + VEVENT.ATTENDEE = [] + for(let attendee of event.attendees){ + VEVENT.ATTENDEE.push(attendee.getFirstParameter("cn")); } -// METHOD:REPLY || METHOD:REQUEST -// console.dir({VEVENT:VEVENT}); + if (VEVENT) { VEVENT.rawText = text; VEVENT.isCancelled = () => VEVENT.STATUS?.includes('CANCELLED');