Files
silverbullet-icalendar/icalendar.plug.js
sstent 8710d92e3d
All checks were successful
Build SilverBullet Plug / build (push) Successful in 14s
fix type error - v0.4.8 [skip-ci]
2026-02-25 05:49:23 -08:00

18 lines
138 KiB
JavaScript

var zr=Object.defineProperty;var Mt=(e,t)=>{for(var r in t)zr(e,r,{get:t[r],enumerable:!0})};function Re(e){let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function se(e){typeof e=="string"&&(e=new TextEncoder().encode(e));let t="",r=e.byteLength;for(let n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var eo=new Uint8Array(16);var ue=class{constructor(t="",r=1e3){this.prefix=t;this.maxCaptureSize=r;this.prefix=t,this.originalConsole={log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console)},this.patchConsole()}originalConsole;logBuffer=[];patchConsole(){let t=r=>(...n)=>{let i=this.prefix?[this.prefix,...n]:n;this.originalConsole[r](...i),this.captureLog(r,n)};console.log=t("log"),console.info=t("info"),console.warn=t("warn"),console.error=t("error"),console.debug=t("debug")}captureLog(t,r){let n={level:t,timestamp:Date.now(),message:r.map(i=>{if(typeof i=="string")return i;try{return JSON.stringify(i)}catch{return String(i)}}).join(" ")};this.logBuffer.push(n),this.logBuffer.length>this.maxCaptureSize&&this.logBuffer.shift()}async postToServer(t,r){if(this.logBuffer.length>0){let i=[...this.logBuffer];this.logBuffer=[];try{if(!(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i.map(o=>({...o,source:r})))})).ok)throw new Error("Failed to post logs to server")}catch(a){console.warn("Could not post logs to server",a.message),this.logBuffer.unshift(...i)}}}},Be;function je(e=""){return Be=new ue(e),Be}var Ut=e=>{throw new Error("Not initialized yet")},de=typeof window>"u"&&typeof globalThis.WebSocketPair>"u";typeof Deno>"u"&&(self.Deno={args:[],build:{arch:"x86_64"},env:{get(){}}});var ce=new Map,le=0;de&&(globalThis.syscall=async(e,...t)=>await new Promise((r,n)=>{le++,ce.set(le,{resolve:r,reject:n}),Ut({type:"sys",id:le,name:e,args:t})}));function ze(e,t,r){de&&(Ut=r,self.addEventListener("message",n=>{(async()=>{let i=n.data;switch(i.type){case"inv":{let a=e[i.name];if(!a)throw new Error(`Function not loaded: ${i.name}`);try{let o=await Promise.resolve(a(...i.args||[]));Ut({type:"invr",id:i.id,result:o})}catch(o){console.error("An exception was thrown as a result of invoking function",i.name,"error:",o.message),Ut({type:"invr",id:i.id,error:o.message})}}break;case"sysr":{let a=i.id,o=ce.get(a);if(!o)throw Error("Invalid request id");ce.delete(a),i.error?o.reject(new Error(i.error)):o.resolve(i.result)}break}})().catch(console.error)}),Ut({type:"manifest",manifest:t}),je(`[${t.name} plug]`))}async function Wr(e,t){if(typeof e!="string"){let r=new Uint8Array(await e.arrayBuffer()),n=r.length>0?se(r):void 0;t={method:e.method,headers:Object.fromEntries(e.headers.entries()),base64Body:n},e=e.url}return syscall("sandboxFetch.fetch",e,t)}globalThis.nativeFetch=globalThis.fetch;function Fr(){globalThis.fetch=async function(e,t){let r=t&&t.body?se(new Uint8Array(await new Response(t.body).arrayBuffer())):void 0,n=await Wr(e,t&&{method:t.method,headers:t.headers,base64Body:r});return new Response(n.base64Body?Re(n.base64Body):null,{status:n.status,headers:n.headers})}}de&&Fr();var ct={};Mt(ct,{alert:()=>On,configureVimMode:()=>Vn,confirm:()=>En,copyToClipboard:()=>Bn,deleteLine:()=>jn,dispatch:()=>Dn,downloadFile:()=>fn,filterBox:()=>pn,flashNotification:()=>mn,fold:()=>kn,foldAll:()=>Un,getCurrentEditor:()=>$r,getCurrentPage:()=>Hr,getCurrentPageMeta:()=>Vr,getCurrentPath:()=>Kr,getCursor:()=>Jr,getRecentlyOpenedPages:()=>qr,getSelection:()=>Qr,getText:()=>Zr,getUiOption:()=>Cn,goHistory:()=>hn,hidePanel:()=>bn,insertAtCursor:()=>_n,insertAtPos:()=>Tn,invokeCommand:()=>tn,isMobile:()=>qn,moveCursor:()=>Sn,moveCursorToLine:()=>xn,moveLineDown:()=>Fn,moveLineUp:()=>Wn,navigate:()=>rn,newWindow:()=>dn,openCommandPalette:()=>an,openPageNavigator:()=>nn,openSearchPanel:()=>Rn,openUrl:()=>cn,prompt:()=>An,rebuildEditorState:()=>un,redo:()=>Ln,reloadConfigAndCommands:()=>ln,reloadPage:()=>on,reloadUI:()=>sn,replaceRange:()=>vn,save:()=>en,sendMessage:()=>Kn,setSelection:()=>Xr,setText:()=>Gr,setUiOption:()=>Yn,showPanel:()=>gn,showProgress:()=>wn,toggleComment:()=>zn,toggleFold:()=>Mn,undo:()=>In,unfold:()=>Pn,unfoldAll:()=>Nn,uploadFile:()=>yn,vimEx:()=>Hn});typeof self>"u"&&(self={syscall:()=>{throw new Error("Not implemented here")}});function m(e,...t){return globalThis.syscall(e,...t)}function Hr(){return m("editor.getCurrentPage")}function Vr(){return m("editor.getCurrentPageMeta")}function Kr(){return m("editor.getCurrentPath")}function qr(){return m("editor.getRecentlyOpenedPages")}function $r(){return m("editor.getCurrentEditor")}function Zr(){return m("editor.getText")}function Gr(e,t=!1){return m("editor.setText",e,t)}function Jr(){return m("editor.getCursor")}function Qr(){return m("editor.getSelection")}function Xr(e,t){return m("editor.setSelection",e,t)}function tn(e,t){return m("editor.invokeCommand",e,t)}function en(){return m("editor.save")}function rn(e,t=!1,r=!1){return m("editor.navigate",e,t,r)}function nn(e="page"){return m("editor.openPageNavigator",e)}function an(){return m("editor.openCommandPalette")}function on(){return m("editor.reloadPage")}function sn(){return m("editor.reloadUI")}function un(){return m("editor.rebuildEditorState")}function ln(){return m("editor.reloadConfigAndCommands")}function cn(e,t=!1){return m("editor.openUrl",e,t)}function dn(){return m("editor.newWindow")}function hn(e){return m("editor.goHistory",e)}function fn(e,t){return m("editor.downloadFile",e,t)}function yn(e,t){return m("editor.uploadFile",e,t)}function mn(e,t="info"){return m("editor.flashNotification",e,t)}function pn(e,t,r="",n=""){return m("editor.filterBox",e,t,r,n)}function gn(e,t,r,n=""){return m("editor.showPanel",e,t,r,n)}function bn(e){return m("editor.hidePanel",e)}function wn(e,t){return m("editor.showProgress",e,t)}function Tn(e,t){return m("editor.insertAtPos",e,t)}function vn(e,t,r){return m("editor.replaceRange",e,t,r)}function Sn(e,t=!1){return m("editor.moveCursor",e,t)}function xn(e,t=1,r=!1){return m("editor.moveCursorToLine",e,t,r)}function _n(e,t=!1,r=!1){return m("editor.insertAtCursor",e,t,r)}function Dn(e){return m("editor.dispatch",e)}function An(e,t=""){return m("editor.prompt",e,t)}function En(e){return m("editor.confirm",e)}function On(e){return m("editor.alert",e)}function Cn(e){return m("editor.getUiOption",e)}function Yn(e,t){return m("editor.setUiOption",e,t)}function kn(){return m("editor.fold")}function Pn(){return m("editor.unfold")}function Mn(){return m("editor.toggleFold")}function Un(){return m("editor.foldAll")}function Nn(){return m("editor.unfoldAll")}function In(){return m("editor.undo")}function Ln(){return m("editor.redo")}function Rn(){return m("editor.openSearchPanel")}function Bn(e){return m("editor.copyToClipboard",e)}function jn(){return m("editor.deleteLine")}function zn(){return m("editor.toggleComment")}function Wn(){return m("editor.moveLineUp")}function Fn(){return m("editor.moveLineDown")}function Hn(e){return m("editor.vimEx",e)}function Vn(){return m("editor.configureVimMode")}function Kn(e,t){return m("editor.sendMessage",e,t)}function qn(){return m("editor.isMobile")}var Nt={};Mt(Nt,{del:()=>Xn,get:()=>Qn,set:()=>Jn});function Jn(e,t){return m("clientStore.set",e,t)}function Qn(e){return m("clientStore.get",e)}function Xn(e){return m("clientStore.delete",e)}var go=new Uint8Array(16);var It={};Mt(It,{batchDel:()=>hi,batchDeletePrefix:()=>mi,batchGet:()=>ci,batchSet:()=>ui,del:()=>di,get:()=>li,listFunctions:()=>gi,query:()=>fi,queryDelete:()=>pi,queryLua:()=>yi,set:()=>si});function si(e,t){return m("datastore.set",e,t)}function ui(e){return m("datastore.batchSet",e)}function li(e){return m("datastore.get",e)}function ci(e){return m("datastore.batchGet",e)}function di(e){return m("datastore.delete",e)}function hi(e){return m("datastore.batchDelete",e)}function fi(e){return m("datastore.query",e)}function yi(e,t,r){return m("datastore.queryLua",e,t,r)}function mi(e){return m("datastore.batchDeletePrefix",e)}function pi(e,t){return m("datastore.queryDelete",e,t)}function gi(){return m("datastore.listFunctions")}var qt={};Mt(qt,{define:()=>_i,get:()=>Ti,has:()=>xi,insert:()=>Si,set:()=>vi});function Ti(e,t){return m("config.get",e,t)}function vi(e,t){return m("config.set",e,t)}function Si(e,t){return m("config.insert",e,t)}function xi(e){return m("config.has",e)}function _i(e,t){return m("config.define",e,t)}var $t={};Mt($t,{ensureFullIndex:()=>Oi,getObjectByRef:()=>Ei,indexObjects:()=>Di,queryLuaObjects:()=>Ai});function Di(e,t){return m("index.indexObjects",e,t)}function Ai(e,t,r,n){return m("index.queryLuaObjects",e,t,r,n)}function Ei(e,t,r){return m("index.getObjectByRef",e,t,r)}function Oi(){return m("index.ensureFullIndex")}var Xe=class tr{static fromString(t){return new tr(t)}constructor(t){this.value=t}icaltype="binary";decodeValue(){return this._b64_decode(this.value)}setEncodedValue(t){this.value=this._b64_encode(t)}_b64_encode(t){let r,n,i,a,o,s,u,l,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=0,h=0,f="",y=[];if(!t)return t;do r=t.charCodeAt(d++),n=t.charCodeAt(d++),i=t.charCodeAt(d++),l=r<<16|n<<8|i,a=l>>18&63,o=l>>12&63,s=l>>6&63,u=63&l,y[h++]=c.charAt(a)+c.charAt(o)+c.charAt(s)+c.charAt(u);while(d<t.length);f=y.join("");let p=t.length%3;return(p?f.slice(0,p-3):f)+"===".slice(p||3)}_b64_decode(t){let r,n,i,a,o,s,u,l,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=0,h=0,f="",y=[];if(!t)return t;t+="";do a=c.indexOf(t.charAt(d++)),o=c.indexOf(t.charAt(d++)),s=c.indexOf(t.charAt(d++)),u=c.indexOf(t.charAt(d++)),l=a<<18|o<<12|s<<6|u,r=l>>16&255,n=l>>8&255,i=255&l,y[h++]=s==64?String.fromCharCode(r):u==64?String.fromCharCode(r,n):String.fromCharCode(r,n,i);while(d<t.length);return f=y.join(""),f}toString(){return this.value}},Ci=/([PDWHMTS]{1,1})/,Yi=["weeks","days","hours","minutes","seconds","isNegative"],X=class Lt{static fromSeconds(t){return new Lt().fromSeconds(t)}static isValueString(t){return t[0]==="P"||t[1]==="P"}static fromString(t){let r=0,n=Object.create(null),i=0;for(;(r=t.search(Ci))!==-1;){let a=t[r],o=t.slice(0,Math.max(0,r));t=t.slice(r+1),i+=ki(a,o,n)}if(i<2)throw new Error('invalid duration value: Not enough duration components in "'+t+'"');return new Lt(n)}static fromData(t){return new Lt(t)}constructor(t){this.wrappedJSObject=this,this.fromData(t)}weeks=0;days=0;hours=0;minutes=0;seconds=0;isNegative=!1;icalclass="icalduration";icaltype="duration";clone(){return Lt.fromData(this)}toSeconds(){let t=this.seconds+60*this.minutes+3600*this.hours+86400*this.days+604800*this.weeks;return this.isNegative?-t:t}fromSeconds(t){let r=Math.abs(t);return this.isNegative=t<0,this.days=U(r/86400),this.days%7==0?(this.weeks=this.days/7,this.days=0):this.weeks=0,r-=86400*(this.days+7*this.weeks),this.hours=U(r/3600),r-=3600*this.hours,this.minutes=U(r/60),r-=60*this.minutes,this.seconds=r,this}fromData(t){for(let r of Yi)this[r]=t&&r in t?t[r]:0}reset(){this.isNegative=!1,this.weeks=0,this.days=0,this.hours=0,this.minutes=0,this.seconds=0}compare(t){let r=this.toSeconds(),n=t.toSeconds();return(r>n)-(r<n)}normalize(){this.fromSeconds(this.toSeconds())}toString(){if(this.toSeconds()==0)return"PT0S";{let t="";return this.isNegative&&(t+="-"),t+="P",this.weeks&&(t+=this.weeks+"W"),this.days&&(t+=this.days+"D"),(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}}toICALString(){return this.toString()}};function ki(e,t,r){let n;switch(e){case"P":r.isNegative=!(!t||t!=="-");break;case"D":n="days";break;case"W":n="weeks";break;case"H":n="hours";break;case"M":n="minutes";break;case"S":n="seconds";break;default:return 0}if(n){if(!t&&t!==0)throw new Error('invalid duration value: Missing number before "'+e+'"');let i=parseInt(t,10);if(jt(i))throw new Error('invalid duration value: Invalid number "'+t+'" before "'+e+'"');r[n]=i}return 1}var w=class T{static _dowCache={};static _wnCache={};static daysInMonth(t,r){let n=30;return t<1||t>12||(n=[0,31,28,31,30,31,30,31,31,30,31,30,31][t],t==2&&(n+=T.isLeapYear(r))),n}static isLeapYear(t){return t<=1752?t%4==0:t%4==0&&t%100!=0||t%400==0}static fromDayOfYear(t,r){let n=r,i=t,a=new T;a.auto_normalize=!1;let o=T.isLeapYear(n)?1:0;if(i<1)return n--,o=T.isLeapYear(n)?1:0,i+=T.daysInYearPassedMonth[o][12],T.fromDayOfYear(i,n);if(i>T.daysInYearPassedMonth[o][12])return o=T.isLeapYear(n)?1:0,i-=T.daysInYearPassedMonth[o][12],n++,T.fromDayOfYear(i,n);a.year=n,a.isDate=!0;for(let s=11;s>=0;s--)if(i>T.daysInYearPassedMonth[o][s]){a.month=s+1,a.day=i-T.daysInYearPassedMonth[o][s];break}return a.auto_normalize=!0,a}static fromStringv2(t){return new T({year:parseInt(t.slice(0,4),10),month:parseInt(t.slice(5,7),10),day:parseInt(t.slice(8,10),10),isDate:!0})}static fromDateString(t){return new T({year:R(t.slice(0,4)),month:R(t.slice(5,7)),day:R(t.slice(8,10)),isDate:!0})}static fromDateTimeString(t,r){if(t.length<19)throw new Error('invalid date-time value: "'+t+'"');let n,i;t[19]&&t[19]==="Z"?n=C.utcTimezone:r&&(i=r.getParameter("tzid"),r.parent&&(r.parent.name==="standard"||r.parent.name==="daylight"?n=C.localTimezone:i&&(n=r.parent.getTimeZoneByID(i))));let a={year:R(t.slice(0,4)),month:R(t.slice(5,7)),day:R(t.slice(8,10)),hour:R(t.slice(11,13)),minute:R(t.slice(14,16)),second:R(t.slice(17,19))};return i&&!n&&(a.timezone=i),new T(a,n)}static fromString(t,r){return t.length>10?T.fromDateTimeString(t,r):T.fromDateString(t)}static fromJSDate(t,r){return new T().fromJSDate(t,r)}static fromData=function(t,r){return new T().fromData(t,r)};static now(){return T.fromJSDate(new Date,!1)}static weekOneStarts(t,r){let n=T.fromData({year:t,month:1,day:1,isDate:!0}),i=n.dayOfWeek(),a=r||T.DEFAULT_WEEK_START;return i>T.THURSDAY&&(n.day+=7),a>T.THURSDAY&&(n.day-=7),n.day-=i-a,n}static getDominicalLetter(t){let r="GFEDCBA",n=(t+(t/4|0)+(t/400|0)-(t/100|0)-1)%7;return T.isLeapYear(t)?r[(n+6)%7]+r[n]:r[n]}static#t=null;static get epochTime(){return this.#t||(this.#t=T.fromData({year:1970,month:1,day:1,hour:0,minute:0,second:0,isDate:!1,timezone:"Z"})),this.#t}static _cmp_attr(t,r,n){return t[n]>r[n]?1:t[n]<r[n]?-1:0}static 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]];static SUNDAY=1;static MONDAY=2;static TUESDAY=3;static WEDNESDAY=4;static THURSDAY=5;static FRIDAY=6;static SATURDAY=7;static DEFAULT_WEEK_START=2;constructor(t,r){this.wrappedJSObject=this;let n=this._time=Object.create(null);n.year=0,n.month=1,n.day=1,n.hour=0,n.minute=0,n.second=0,n.isDate=!1,this.fromData(t,r)}icalclass="icaltime";_cachedUnixTime=null;get icaltype(){return this.isDate?"date":"date-time"}zone=null;_pendingNormalization=!1;clone(){return new T(this._time,this.zone)}reset(){this.fromData(T.epochTime),this.zone=C.utcTimezone}resetTo(t,r,n,i,a,o,s){this.fromData({year:t,month:r,day:n,hour:i,minute:a,second:o,zone:s})}fromJSDate(t,r){return t?r?(this.zone=C.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=C.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}fromData(t,r){if(t)for(let[n,i]of Object.entries(t))n!=="icaltype"&&(this[n]=i);if(r&&(this.zone=r),t&&!("isDate"in t)?this.isDate=!("hour"in t):t&&"isDate"in t&&(this.isDate=t.isDate),t&&"timezone"in t){let n=te.get(t.timezone);this.zone=n||C.localTimezone}return t&&"zone"in t&&(this.zone=t.zone),this.zone||(this.zone=C.localTimezone),this._cachedUnixTime=null,this}dayOfWeek(t){let r=t||T.SUNDAY,n=(this.year<<12)+(this.month<<8)+(this.day<<3)+r;if(n in T._dowCache)return T._dowCache[n];let i=this.day,a=this.month+(this.month<3?12:0),o=this.year-(this.month<3?1:0),s=i+o+U(26*(a+1)/10)+U(o/4);return s+=6*U(o/100)+U(o/400),s=(s+7-r)%7+1,T._dowCache[n]=s,s}dayOfYear(){let t=T.isLeapYear(this.year)?1:0;return T.daysInYearPassedMonth[t][this.month-1]+this.day}startOfWeek(t){let r=t||T.SUNDAY,n=this.clone();return n.day-=(this.dayOfWeek()+7-r)%7,n.isDate=!0,n.hour=0,n.minute=0,n.second=0,n}endOfWeek(t){let r=t||T.SUNDAY,n=this.clone();return n.day+=(7-this.dayOfWeek()+r-T.SUNDAY)%7,n.isDate=!0,n.hour=0,n.minute=0,n.second=0,n}startOfMonth(){let t=this.clone();return t.day=1,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}endOfMonth(){let t=this.clone();return t.day=T.daysInMonth(t.month,t.year),t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}startOfYear(){let t=this.clone();return t.day=1,t.month=1,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}endOfYear(){let t=this.clone();return t.day=31,t.month=12,t.isDate=!0,t.hour=0,t.minute=0,t.second=0,t}startDoyWeek(t){let r=t||T.SUNDAY,n=this.dayOfWeek()-r;return n<0&&(n+=7),this.dayOfYear()-n}getDominicalLetter(){return T.getDominicalLetter(this.year)}nthWeekDay(t,r){let n,i=T.daysInMonth(this.month,this.year),a=r,o=0,s=this.clone();if(a>=0){s.day=1,a!=0&&a--,o=s.day;let u=t-s.dayOfWeek();u<0&&(u+=7),o+=u,o-=t,n=t}else s.day=i,a++,n=s.dayOfWeek()-t,n<0&&(n+=7),n=i-n;return n+=7*a,o+n}isNthWeekDay(t,r){let n=this.dayOfWeek();return r===0&&n===t||this.nthWeekDay(t,r)===this.day}weekNumber(t){let r,n=(this.year<<12)+(this.month<<8)+(this.day<<3)+t;if(n in T._wnCache)return T._wnCache[n];let i=this.clone();i.isDate=!0;let a=this.year;i.month==12&&i.day>25?(r=T.weekOneStarts(a+1,t),i.compare(r)<0?r=T.weekOneStarts(a,t):a++):(r=T.weekOneStarts(a,t),i.compare(r)<0&&(r=T.weekOneStarts(--a,t)));let o=U(i.subtractDate(r).toSeconds()/86400/7)+1;return T._wnCache[n]=o,o}addDuration(t){let r=t.isNegative?-1:1,n=this.second,i=this.minute,a=this.hour,o=this.day;n+=r*t.seconds,i+=r*t.minutes,a+=r*t.hours,o+=r*t.days,o+=7*r*t.weeks,this.second=n,this.minute=i,this.hour=a,this.day=o,this._cachedUnixTime=null}subtractDate(t){let r=this.toUnixTime()+this.utcOffset(),n=t.toUnixTime()+t.utcOffset();return X.fromSeconds(r-n)}subtractDateTz(t){let r=this.toUnixTime(),n=t.toUnixTime();return X.fromSeconds(r-n)}compare(t){let r=this.toUnixTime(),n=t.toUnixTime();return r>n?1:n>r?-1:0}compareDateOnlyTz(t,r){let n=this.convertToZone(r),i=t.convertToZone(r),a=0;return(a=T._cmp_attr(n,i,"year"))!=0||(a=T._cmp_attr(n,i,"month"))!=0||(a=T._cmp_attr(n,i,"day")),a}convertToZone(t){let r=this.clone(),n=this.zone.tzid==t.tzid;return this.isDate||n||C.convert_time(r,this.zone,t),r.zone=t,r}utcOffset(){return this.zone==C.localTimezone||this.zone==C.utcTimezone?0:this.zone.utcOffset(this)}toICALString(){let t=this.toString();return t.length>10?N.icalendar.value["date-time"].toICAL(t):N.icalendar.value.date.toICAL(t)}toString(){let t=this.year+"-"+V(this.month)+"-"+V(this.day);return this.isDate||(t+="T"+V(this.hour)+":"+V(this.minute)+":"+V(this.second),this.zone===C.utcTimezone&&(t+="Z")),t}toJSDate(){return this.zone==C.localTimezone?this.isDate?new Date(this.year,this.month-1,this.day):new Date(this.year,this.month-1,this.day,this.hour,this.minute,this.second,0):new Date(1e3*this.toUnixTime())}_normalize(){return this._time.isDate&&(this._time.hour=0,this._time.minute=0,this._time.second=0),this.adjust(0,0,0,0),this}adjust(t,r,n,i,a){let o,s,u,l,c,d,h,f=0,y=0,p=a||this._time;if(p.isDate||(u=p.second+i,p.second=u%60,o=U(u/60),p.second<0&&(p.second+=60,o--),l=p.minute+n+o,p.minute=l%60,s=U(l/60),p.minute<0&&(p.minute+=60,s--),c=p.hour+r+s,p.hour=c%24,f=U(c/24),p.hour<0&&(p.hour+=24,f--)),p.month>12?y=U((p.month-1)/12):p.month<1&&(y=U(p.month/12)-1),p.year+=y,p.month-=12*y,d=p.day+t+f,d>0)for(;h=T.daysInMonth(p.month,p.year),!(d<=h);)p.month++,p.month>12&&(p.year++,p.month=1),d-=h;else for(;d<=0;)p.month==1?(p.year--,p.month=12):p.month--,d+=T.daysInMonth(p.month,p.year);return p.day=d,this._cachedUnixTime=null,this}fromUnixTime(t){this.zone=C.utcTimezone;let r=new Date(1e3*t);this.year=r.getUTCFullYear(),this.month=r.getUTCMonth()+1,this.day=r.getUTCDate(),this._time.isDate?(this.hour=0,this.minute=0,this.second=0):(this.hour=r.getUTCHours(),this.minute=r.getUTCMinutes(),this.second=r.getUTCSeconds()),this._cachedUnixTime=null}toUnixTime(){if(this._cachedUnixTime!==null)return this._cachedUnixTime;let t=this.utcOffset(),r=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second-t);return this._cachedUnixTime=r/1e3,this._cachedUnixTime}toJSON(){let t,r=["year","month","day","hour","minute","second","isDate"],n=Object.create(null),i=0,a=r.length;for(;i<a;i++)t=r[i],n[t]=this[t];return this.zone&&(n.timezone=this.zone.tzid),n}};(function(){function e(t){Object.defineProperty(w.prototype,t,{get:function(){return this._pendingNormalization&&(this._normalize(),this._pendingNormalization=!1),this._time[t]},set:function(r){t==="isDate"&&r&&!this._time.isDate&&this.adjust(0,0,0,0),this._cachedUnixTime=null,this._pendingNormalization=!0,this._time[t]=r}})}e("year"),e("month"),e("day"),e("hour"),e("minute"),e("second"),e("isDate")})();var Pi=/[^ \t]/,Mi={"^'":'"',"^n":`
`,"^^":"^"};function A(e){let t={},r=t.component=[];if(t.stack=[r],A._eachLine(e,function(n,i){A._handleContentLine(i,t)}),t.stack.length>1)throw new pt("invalid ical body. component began but did not end");return t=null,r.length==1?r[0]:r}A.property=function(e,t){let r={component:[[],[]],designSet:t||N.defaultSet};return A._handleContentLine(e,r),r.component[1][0]},A.component=function(e){return A(e)};var pt=class extends Error{constructor(e){super(e),this.name=this.constructor.name;try{throw new Error}catch(t){if(t.stack){let r=t.stack.split(`
`);r.shift(),this.stack=r.join(`
`)}}}};A.ParserError=pt,A._handleContentLine=function(e,t){let r,n,i,a,o,s,u=e.indexOf(":"),l=e.indexOf(";"),c={};if(l!==-1&&u!==-1&&l>u&&(l=-1),l!==-1){if(i=e.slice(0,Math.max(0,l)).toLowerCase(),o=A._parseParameters(e.slice(Math.max(0,l)),0,t.designSet),o[2]==-1)throw new pt("Invalid parameters in '"+e+"'");if(c=o[0],r=o[1].length+o[2]+l,(n=e.slice(Math.max(0,r)).indexOf(":"))===-1)throw new pt("Missing parameter value in '"+e+"'");a=e.slice(Math.max(0,r+n+1))}else{if(u===-1)throw new pt('invalid line (no token ";" or ":") "'+e+'"');if(i=e.slice(0,Math.max(0,u)).toLowerCase(),a=e.slice(Math.max(0,u+1)),i==="begin"){let S=[a.toLowerCase(),[],[]];return t.stack.length===1?t.component.push(S):t.component[2].push(S),t.stack.push(t.component),t.component=S,void(t.designSet||(t.designSet=N.getDesignSet(t.component[0])))}if(i==="end")return void(t.component=t.stack.pop())}let d,h,f,y,p=!1,b=!1;t.designSet.propertyGroups&&i.indexOf(".")!==-1?(h=i.split("."),c.group=h[0],f=h[1]):f=i,f in t.designSet.property&&(d=t.designSet.property[f],"multiValue"in d&&(p=d.multiValue),"structuredValue"in d&&(b=d.structuredValue),a&&"detectType"in d&&(s=d.detectType(a))),s||(s="value"in c?c.value.toLowerCase():d?d.defaultType:"unknown"),delete c.value,p&&b?(a=A._parseMultiValue(a,b,s,[],p,t.designSet,b),y=[f,c,s,a]):p?(y=[f,c,s],A._parseMultiValue(a,p,s,y,null,t.designSet,!1)):b?(a=A._parseMultiValue(a,b,s,[],null,t.designSet,b),y=[f,c,s,a]):(a=A._parseValue(a,s,t.designSet,!1),y=[f,c,s,a]),t.component[0]!=="vcard"||t.component[1].length!==0||i==="version"&&a==="4.0"||(t.designSet=N.getDesignSet("vcard3")),t.component[1].push(y)},A._parseValue=function(e,t,r,n){return t in r.value&&"fromICAL"in r.value[t]?r.value[t].fromICAL(e,n):e},A._parseParameters=function(e,t,r){let n,i,a,o,s,u,l=t,c=0,d={},h=-1;for(;c!==!1&&(c=Q(e,"=",c+1))!==-1;){if(n=e.slice(l+1,c),n.length==0)throw new pt("Empty parameter name in '"+e+"'");if(i=n.toLowerCase(),u=!1,s=!1,o=i in r.param&&r.param[i].valueType?r.param[i].valueType:"text",i in r.param&&(s=r.param[i].multiValue,r.param[i].multiValueSeparateDQuote&&(u=A._rfc6868Escape('"'+s+'"'))),e[c+1]==='"'){if(h=c+2,c=Q(e,'"',h),s&&c!=-1){let f=!0;for(;f;)e[c+1]==s&&e[c+2]=='"'?c=Q(e,'"',c+3):f=!1}if(c===-1)throw new pt('invalid line (no matching double quote) "'+e+'"');a=e.slice(h,c),l=Q(e,";",c),l===-1&&(c=!1)}else{h=c+1;let f=Q(e,";",h),y=Q(e,":",h);y!==-1&&f>y?(f=y,c=!1):f===-1?(f=y===-1?e.length:y,c=!1):(l=f,c=f),a=e.slice(h,f)}if(a=A._rfc6868Escape(a),s){let f=u||s;a=A._parseMultiValue(a,f,o,[],null,r)}else a=A._parseValue(a,o,r);s&&i in d?Array.isArray(d[i])?d[i].push(a):d[i]=[d[i],a]:d[i]=a}return[d,a,h]},A._rfc6868Escape=function(e){return e.replace(/\^['n^]/g,function(t){return Mi[t]})},A._parseMultiValue=function(e,t,r,n,i,a,o){let s,u=0,l=0;if(t.length===0)return e;for(;(u=Q(e,t,l))!==-1;)s=e.slice(l,u),s=i?A._parseMultiValue(s,i,r,[],null,a,o):A._parseValue(s,r,a,o),n.push(s),l=u+t.length;return s=e.slice(l),s=i?A._parseMultiValue(s,i,r,[],null,a,o):A._parseValue(s,r,a,o),n.push(s),n.length==1?n[0]:n},A._eachLine=function(e,t){let r,n,i,a=e.length,o=e.search(Pi),s=o;do s=e.indexOf(`
`,o)+1,i=s>1&&e[s-2]==="\r"?2:1,s===0&&(s=a,i=0),n=e[o],n===" "||n===" "?r+=e.slice(o+1,s-i):(r&&t(null,r),r=e.slice(o,s-i)),o=s;while(s!==a);r=r.trim(),r.length&&t(null,r)};var Ui=["tzid","location","tznames","latitude","longitude"],C=class E{static _compare_change_fn(t,r){return t.year<r.year?-1:t.year>r.year?1:t.month<r.month?-1:t.month>r.month?1:t.day<r.day?-1:t.day>r.day?1:t.hour<r.hour?-1:t.hour>r.hour?1:t.minute<r.minute?-1:t.minute>r.minute?1:t.second<r.second?-1:t.second>r.second?1:0}static convert_time(t,r,n){if(t.isDate||r.tzid==n.tzid||r==E.localTimezone||n==E.localTimezone)return t.zone=n,t;let i=r.utcOffset(t);return t.adjust(0,0,0,-i),i=n.utcOffset(t),t.adjust(0,0,0,i),null}static fromData(t){return new E().fromData(t)}static#t=null;static get utcTimezone(){return this.#t||(this.#t=E.fromData({tzid:"UTC"})),this.#t}static#e=null;static get localTimezone(){return this.#e||(this.#e=E.fromData({tzid:"floating"})),this.#e}static adjust_change(t,r,n,i,a){return w.prototype.adjust.call(t,r,n,i,a,t)}static _minimumExpansionYear=-1;static EXTRA_COVERAGE=5;constructor(t){this.wrappedJSObject=this,this.fromData(t)}tzid="";location="";tznames="";latitude=0;longitude=0;component=null;expandedUntilYear=0;icalclass="icaltimezone";fromData(t){if(this.expandedUntilYear=0,this.changes=[],t instanceof tt)this.component=t;else{if(t&&"component"in t)if(typeof t.component=="string"){let r=A(t.component);this.component=new tt(r)}else t.component instanceof tt?this.component=t.component:this.component=null;for(let r of Ui)t&&r in t&&(this[r]=t[r])}return this.component instanceof tt&&!this.tzid&&(this.tzid=this.component.getFirstPropertyValue("tzid")),this}utcOffset(t){if(this==E.utcTimezone||this==E.localTimezone||(this._ensureCoverage(t.year),!this.changes.length))return 0;let r={year:t.year,month:t.month,day:t.day,hour:t.hour,minute:t.minute,second:t.second},n=this._findNearbyChange(r),i=-1,a=1;for(;;){let s=vt(this.changes[n],!0);if(s.utcOffset<s.prevUtcOffset?E.adjust_change(s,0,0,0,s.utcOffset):E.adjust_change(s,0,0,0,s.prevUtcOffset),E._compare_change_fn(r,s)>=0?i=n:a=-1,a==-1&&i!=-1)break;if(n+=a,n<0)return 0;if(n>=this.changes.length)break}let o=this.changes[i];if(o.utcOffset-o.prevUtcOffset<0&&i>0){let s=vt(o,!0);if(E.adjust_change(s,0,0,0,s.prevUtcOffset),E._compare_change_fn(r,s)<0){let u=this.changes[i-1],l=!1;o.is_daylight!=l&&u.is_daylight==l&&(o=u)}}return o.utcOffset}_findNearbyChange(t){let r=Tt(this.changes,t,E._compare_change_fn);return r>=this.changes.length?this.changes.length-1:r}_ensureCoverage(t){if(E._minimumExpansionYear==-1){let n=w.now();E._minimumExpansionYear=n.year}let r=t;if(r<E._minimumExpansionYear&&(r=E._minimumExpansionYear),r+=E.EXTRA_COVERAGE,!this.changes.length||this.expandedUntilYear<t){let n=this.component.getAllSubcomponents(),i=n.length,a=0;for(;a<i;a++)this._expandComponent(n[a],r,this.changes);this.changes.sort(E._compare_change_fn),this.expandedUntilYear=r}}_expandComponent(t,r,n){if(!t.hasProperty("dtstart")||!t.hasProperty("tzoffsetto")||!t.hasProperty("tzoffsetfrom"))return null;let i,a=t.getFirstProperty("dtstart").getFirstValue();function o(u){return u.factor*(3600*u.hours+60*u.minutes)}function s(){let u={};return u.is_daylight=t.name=="daylight",u.utcOffset=o(t.getFirstProperty("tzoffsetto").getFirstValue()),u.prevUtcOffset=o(t.getFirstProperty("tzoffsetfrom").getFirstValue()),u}if(t.hasProperty("rrule")||t.hasProperty("rdate")){let u=t.getAllProperties("rdate");for(let c of u){let d=c.getFirstValue();i=s(),i.year=d.year,i.month=d.month,i.day=d.day,d.isDate?(i.hour=a.hour,i.minute=a.minute,i.second=a.second,a.zone!=E.utcTimezone&&E.adjust_change(i,0,0,0,-i.prevUtcOffset)):(i.hour=d.hour,i.minute=d.minute,i.second=d.second,d.zone!=E.utcTimezone&&E.adjust_change(i,0,0,0,-i.prevUtcOffset)),n.push(i)}let l=t.getFirstProperty("rrule");if(l){l=l.getFirstValue(),i=s(),l.until&&l.until.zone==E.utcTimezone&&(l.until.adjust(0,0,0,i.prevUtcOffset),l.until.zone=E.localTimezone);let c,d=l.iterator(a);for(;(c=d.next())&&(i=s(),!(c.year>r)&&c);)i.year=c.year,i.month=c.month,i.day=c.day,i.hour=c.hour,i.minute=c.minute,i.second=c.second,i.isDate=c.isDate,E.adjust_change(i,0,0,0,-i.prevUtcOffset),n.push(i)}}else i=s(),i.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),n.push(i);return n}toString(){return this.tznames?this.tznames:this.tzid}},F=null,te={get count(){return F===null?0:Object.keys(F).length},reset:function(){F=Object.create(null);let e=C.utcTimezone;F.Z=e,F.UTC=e,F.GMT=e},has:function(e){return F!==null&&!!F[e]},get:function(e){return F===null&&this.reset(),F[e]},register:function(e,t){if(F===null&&this.reset(),e instanceof tt&&e.name==="vtimezone"&&(e=(t=new C(e)).tzid),!(t instanceof C))throw new TypeError("timezone must be ICAL.Timezone or ICAL.Component");F[e]=t},remove:function(e){return F===null?null:delete F[e]}};function jt(e){return typeof e=="number"&&isNaN(e)}function R(e){let t=parseInt(e,10);if(jt(t))throw new Error('Could not extract integer from "'+e+'"');return t}function st(e,t){if(e!==void 0)return e instanceof t?e:new t(e)}function Q(e,t,r){for(;(r=e.indexOf(t,r))!==-1;){if(!(r>0&&e[r-1]==="\\"))return r;r+=1}return-1}function Tt(e,t,r){if(!e.length)return 0;let n,i,a=0,o=e.length-1;for(;a<=o;)if(n=a+Math.floor((o-a)/2),i=r(t,e[n]),i<0)o=n-1;else{if(!(i>0))break;a=n+1}return i<0?n:i>0?n+1:n}function vt(e,t){if(e&&typeof e=="object"){if(e instanceof Date)return new Date(e.getTime());if("clone"in e)return e.clone();if(Array.isArray(e)){let r=[];for(let n=0;n<e.length;n++)r.push(t?vt(e[n],!0):e[n]);return r}{let r={};for(let[n,i]of Object.entries(e))r[n]=t?vt(i,!0):i;return r}}return e}function er(e){let t="",r=e||"",n=0,i=0;for(;r.length;){let a=r.codePointAt(n);a<128?++i:i+=a<2048?2:a<65536?3:4,i<ht.foldLength+1?n+=a>65535?2:1:(t+=ht.newLineChar+" "+r.slice(0,Math.max(0,n)),r=r.slice(Math.max(0,n)),n=i=0)}return t.slice(ht.newLineChar.length+1)}function V(e){switch(typeof e!="string"&&(typeof e=="number"&&(e=parseInt(e)),e=String(e)),e.length){case 0:return"00";case 1:return"0"+e;default:return e}}function U(e){return e<0?Math.ceil(e):Math.floor(e)}function St(e,t){for(let r in e){let n=Object.getOwnPropertyDescriptor(e,r);n&&!Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,n)}return t}var Ni=Object.freeze({__proto__:null,updateTimezones:function(e){let t,r,n,i,a;if(!e||e.name!=="vcalendar")return e;for(t=e.getAllSubcomponents(),r=[],n={},a=0;a<t.length;a++)t[a].name==="vtimezone"?n[t[a].getFirstProperty("tzid").getFirstValue()]=t[a]:r=r.concat(t[a].getAllProperties());for(i={},a=0;a<r.length;a++){let o=r[a].getParameter("tzid");o&&(i[o]=!0)}for(let[o,s]of Object.entries(n))i[o]||e.removeSubcomponent(s);for(let o of Object.keys(i))!n[o]&&te.has(o)&&e.addSubcomponent(te.get(o).component);return e},isStrictlyNaN:jt,strictParseInt:R,formatClassType:st,unescapedIndexOf:Q,binsearchInsert:Tt,clone:vt,foldline:er,pad2:V,trunc:U,extend:St}),wt=class Qt{static fromString(t){let r={};return r.factor=t[0]==="+"?1:-1,r.hours=R(t.slice(1,3)),r.minutes=R(t.slice(4,6)),new Qt(r)}static fromSeconds(t){let r=new Qt;return r.fromSeconds(t),r}constructor(t){this.fromData(t)}hours=0;minutes=0;factor=1;icaltype="utc-offset";clone(){return Qt.fromSeconds(this.toSeconds())}fromData(t){if(t)for(let[r,n]of Object.entries(t))this[r]=n;this._normalize()}fromSeconds(t){let r=Math.abs(t);return this.factor=t<0?-1:1,this.hours=U(r/3600),r-=3600*this.hours,this.minutes=U(r/60),this}toSeconds(){return this.factor*(60*this.minutes+3600*this.hours)}compare(t){let r=this.toSeconds(),n=t.toSeconds();return(r>n)-(n>r)}_normalize(){let t=this.toSeconds(),r=this.factor;for(;t<-43200;)t+=97200;for(;t>50400;)t-=97200;this.fromSeconds(t),t==0&&(this.factor=r)}toICALString(){return N.icalendar.value["utc-offset"].toICAL(this.toString())}toString(){return(this.factor==1?"+":"-")+V(this.hours)+":"+V(this.minutes)}},Rt=class ye extends w{static fromDateAndOrTimeString(t,r){function n(p,b,S){return p?R(p.slice(b,b+S)):null}let i=t.split("T"),a=i[0],o=i[1],s=o?N.vcard.value.time._splitZone(o):[],u=s[0],l=s[1],c=a?a.length:0,d=l?l.length:0,h=a&&a[0]=="-"&&a[1]=="-",f=l&&l[0]=="-",y={year:h?null:n(a,0,4),month:!h||c!=4&&c!=7?c==7||c==10?n(a,5,2):null:n(a,2,2),day:c==5?n(a,3,2):c==7&&h?n(a,5,2):c==10?n(a,8,2):null,hour:f?null:n(l,0,2),minute:f&&d==3?n(l,1,2):d>4?n(l,f?1:3,2):null,second:d==4?n(l,2,2):d==6?n(l,4,2):d==8?n(l,6,2):null};return u=u=="Z"?C.utcTimezone:u&&u[3]==":"?wt.fromString(u):null,new ye(y,u,r)}constructor(t,r,n){super(t,r),this.icaltype=n||"date-and-or-time"}icalclass="vcardtime";icaltype="date-and-or-time";clone(){return new ye(this._time,this.zone,this.icaltype)}_normalize(){return this}utcOffset(){return this.zone instanceof wt?this.zone.toSeconds():w.prototype.utcOffset.apply(this,arguments)}toICALString(){return N.vcard.value[this.icaltype].toICAL(this.toString())}toString(){let t,r=this.year,n=this.month,i=this.day,a=this.hour,o=this.minute,s=this.second,u=n!==null,l=i!==null,c=a!==null,d=o!==null,h=s!==null,f=(r!==null?V(r)+(u||l?"-":""):u||l?"--":"")+(u?V(n):"")+(l?"-"+V(i):""),y=(c?V(a):"-")+(c&&d?":":"")+(d?V(o):"")+(c||d?"":"-")+(d&&h?":":"")+(h?V(s):"");switch(this.zone===C.utcTimezone?t="Z":this.zone instanceof wt?t=this.zone.toString():this.zone===C.localTimezone?t="":this.zone instanceof C?t=wt.fromSeconds(this.zone.utcOffset(this)).toString():t="",this.icaltype){case"time":return y+t;case"date-and-or-time":case"date-time":return f+(y=="--"?"":"T"+y+t);case"date":return f}return null}},be=class gt{static _indexMap={BYSECOND:0,BYMINUTE:1,BYHOUR:2,BYDAY:3,BYMONTHDAY:4,BYYEARDAY:5,BYWEEKNO:6,BYMONTH:7,BYSETPOS:8};static _expandMap={SECONDLY:[1,1,1,1,1,1,1,1],MINUTELY:[2,1,1,1,1,1,1,1],HOURLY:[2,2,1,1,1,1,1,1],DAILY:[2,2,2,1,1,1,1,1],WEEKLY:[2,2,2,2,3,3,1,1],MONTHLY:[2,2,2,2,2,3,3,1],YEARLY:[2,2,2,2,2,2,2,2]};static UNKNOWN=0;static CONTRACT=1;static EXPAND=2;static ILLEGAL=3;constructor(t){this.fromData(t)}completed=!1;rule=null;dtstart=null;last=null;occurrence_number=0;by_indices=null;initialized=!1;by_data=null;days=null;days_index=0;fromData(t){if(this.rule=st(t.rule,ut),!this.rule)throw new Error("iterator requires a (ICAL.Recur) rule");if(this.dtstart=st(t.dtstart,w),!this.dtstart)throw new Error("iterator requires a (ICAL.Time) dtstart");t.by_data?this.by_data=t.by_data:this.by_data=vt(this.rule.parts,!0),t.occurrence_number&&(this.occurrence_number=t.occurrence_number),this.days=t.days||[],t.last&&(this.last=st(t.last,w)),this.by_indices=t.by_indices,this.by_indices||(this.by_indices={BYSECOND:0,BYMINUTE:0,BYHOUR:0,BYDAY:0,BYMONTH:0,BYWEEKNO:0,BYMONTHDAY:0}),this.initialized=t.initialized||!1,this.initialized||this.init()}init(){this.initialized=!0,this.last=this.dtstart.clone();let t=this.by_data;if("BYDAY"in t&&this.sort_byday_rules(t.BYDAY),"BYYEARDAY"in t&&("BYMONTH"in t||"BYWEEKNO"in t||"BYMONTHDAY"in t||"BYDAY"in t))throw new Error("Invalid BYYEARDAY rule");if("BYWEEKNO"in t&&"BYMONTHDAY"in t)throw new Error("BYWEEKNO does not fit to BYMONTHDAY");if(this.rule.freq=="MONTHLY"&&("BYYEARDAY"in t||"BYWEEKNO"in t))throw new Error("For MONTHLY recurrences neither BYYEARDAY nor BYWEEKNO may appear");if(this.rule.freq=="WEEKLY"&&("BYYEARDAY"in t||"BYMONTHDAY"in t))throw new Error("For WEEKLY recurrences neither BYMONTHDAY nor BYYEARDAY may appear");if(this.rule.freq!="YEARLY"&&"BYYEARDAY"in t)throw new Error("BYYEARDAY may only appear in YEARLY rules");this.last.second=this.setup_defaults("BYSECOND","SECONDLY",this.dtstart.second),this.last.minute=this.setup_defaults("BYMINUTE","MINUTELY",this.dtstart.minute),this.last.hour=this.setup_defaults("BYHOUR","HOURLY",this.dtstart.hour);let r=this.last.day=this.setup_defaults("BYMONTHDAY","DAILY",this.dtstart.day);if(this.last.month=this.setup_defaults("BYMONTH","MONTHLY",this.dtstart.month),this.rule.freq=="WEEKLY")if("BYDAY"in t){let[,n]=this.ruleDayOfWeek(t.BYDAY[0],this.rule.wkst),i=n-this.last.dayOfWeek(this.rule.wkst);(this.last.dayOfWeek(this.rule.wkst)<n&&i>=0||i<0)&&(this.last.day+=i)}else{let n=ut.numericDayToIcalDay(this.dtstart.dayOfWeek());t.BYDAY=[n]}if(this.rule.freq=="YEARLY"){for(;this.expand_year_days(this.last.year),!(this.days.length>0);)this.increment_year(this.rule.interval);this._nextByYearDay()}if(this.rule.freq=="MONTHLY"&&this.has_by_data("BYDAY")){let n=null,i=this.last.clone(),a=w.daysInMonth(this.last.month,this.last.year);for(let o of this.by_data.BYDAY){this.last=i.clone();let[s,u]=this.ruleDayOfWeek(o),l=this.last.nthWeekDay(u,s);if(s>=6||s<=-6)throw new Error("Malformed values in BYDAY part");if(l>a||l<=0){if(n&&n.month==i.month)continue;for(;l>a||l<=0;)this.increment_month(),a=w.daysInMonth(this.last.month,this.last.year),l=this.last.nthWeekDay(u,s)}this.last.day=l,(!n||this.last.compare(n)<0)&&(n=this.last.clone())}if(this.last=n.clone(),this.has_by_data("BYMONTHDAY")&&this._byDayAndMonthDay(!0),this.last.day>a||this.last.day==0)throw new Error("Malformed values in BYDAY part")}else if(this.has_by_data("BYMONTHDAY")){this.last.day=1;let n=w.daysInMonth(this.last.month,this.last.year);if(r<0)this.last.day=n+r+1;else if(this.by_data.BYMONTHDAY[0]>n){if(!this.next_month()&&!this.next_month()&&!this.next_month())throw new Error("No possible occurrences")}else this.last.day=r}}next(){let t,r=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(this.occurrence_number==0&&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(this.last.compare(r)==0)throw new Error("Same occurrence found twice, protecting you from death by recursion");return this.rule.until&&this.last.compare(this.rule.until)>0?(this.completed=!0,null):(this.occurrence_number++,this.last)}next_second(){return this.next_generic("BYSECOND","SECONDLY","second","minute")}increment_second(t){return this.increment_generic(t,"second",60,"minute")}next_minute(){return this.next_generic("BYMINUTE","MINUTELY","minute","hour","next_second")}increment_minute(t){return this.increment_generic(t,"minute",60,"hour")}next_hour(){return this.next_generic("BYHOUR","HOURLY","hour","monthday","next_minute")}increment_hour(t){this.increment_generic(t,"hour",24,"monthday")}next_day(){let t=this.rule.freq=="DAILY";return this.next_hour()==0||(t?this.increment_monthday(this.rule.interval):this.increment_monthday(1)),0}next_week(){let t=0;if(this.next_weekday_by_week()==0)return t;if(this.has_by_data("BYWEEKNO")){this.by_indices.BYWEEKNO++,this.by_indices.BYWEEKNO==this.by_data.BYWEEKNO.length&&(this.by_indices.BYWEEKNO=0,t=1),this.last.month=1,this.last.day=1;let r=this.by_data.BYWEEKNO[this.by_indices.BYWEEKNO];this.last.day+=7*r,t&&this.increment_year(1)}else this.increment_monthday(7*this.rule.interval);return t}normalizeByMonthDayRules(t,r,n){let i,a=w.daysInMonth(r,t),o=[],s=0,u=n.length;for(;s<u;s++)if(i=n[s],!(Math.abs(i)>a)){if(i<0)i=a+(i+1);else if(i===0)continue;o.indexOf(i)===-1&&o.push(i)}return o.sort(function(l,c){return l-c})}_byDayAndMonthDay(t){let r,n,i,a,o=this.by_data.BYDAY,s=0,u=o.length,l=0,c=this,d=this.last.day;function h(){for(a=w.daysInMonth(c.last.month,c.last.year),r=c.normalizeByMonthDayRules(c.last.year,c.last.month,c.by_data.BYMONTHDAY),i=r.length;r[s]<=d&&(!t||r[s]!=d)&&s<i-1;)s++}function f(){d=0,c.increment_month(),s=0,h()}h(),t&&(d-=1);let y=48;for(;!l&&y;){if(y--,n=d+1,n>a){f();continue}let p=r[s++];if(p>=n){d=p;for(let b=0;b<u;b++){let S=this.ruleDayOfWeek(o[b]),M=S[0],J=S[1];if(this.last.day=d,this.last.isNthWeekDay(J,M)){l=1;break}}l||s!==i||f()}else f()}if(y<=0)throw new Error("Malformed values in BYDAY combined with BYMONTHDAY parts");return l}next_month(){let t=1;if(this.next_hour()==0)return t;if(this.has_by_data("BYDAY")&&this.has_by_data("BYMONTHDAY"))t=this._byDayAndMonthDay();else if(this.has_by_data("BYDAY")){let r,n=w.daysInMonth(this.last.month,this.last.year),i=0,a=0;if(this.has_by_data("BYSETPOS")){let o=this.last.day;for(let s=1;s<=n;s++)this.last.day=s,this.is_day_in_byday(this.last)&&(a++,s<=o&&i++);this.last.day=o}for(t=0,r=this.last.day+1;r<=n;r++)if(this.last.day=r,this.is_day_in_byday(this.last)&&(!this.has_by_data("BYSETPOS")||this.check_set_position(++i)||this.check_set_position(i-a-1))){t=1;break}r>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")){this.by_indices.BYMONTHDAY++,this.by_indices.BYMONTHDAY>=this.by_data.BYMONTHDAY.length&&(this.by_indices.BYMONTHDAY=0,this.increment_month());let r=w.daysInMonth(this.last.month,this.last.year),n=this.by_data.BYMONTHDAY[this.by_indices.BYMONTHDAY];n<0&&(n=r+n+1),n>r?(this.last.day=1,t=this.is_day_in_byday(this.last)):this.last.day=n}else{this.increment_month();let r=w.daysInMonth(this.last.month,this.last.year);this.by_data.BYMONTHDAY[0]>r?t=0:this.last.day=this.by_data.BYMONTHDAY[0]}return t}next_weekday_by_week(){let t=0;if(this.next_hour()==0)return t;if(!this.has_by_data("BYDAY"))return 1;for(;;){let r=new w;this.by_indices.BYDAY++,this.by_indices.BYDAY==Object.keys(this.by_data.BYDAY).length&&(this.by_indices.BYDAY=0,t=1);let n=this.by_data.BYDAY[this.by_indices.BYDAY],i=this.ruleDayOfWeek(n)[1];i-=this.rule.wkst,i<0&&(i+=7),r.year=this.last.year,r.month=this.last.month,r.day=this.last.day;let a=r.startDoyWeek(this.rule.wkst);if(i+a<1&&!t)continue;let o=w.fromDayOfYear(a+i,this.last.year);return this.last.year=o.year,this.last.month=o.month,this.last.day=o.day,t}}next_year(){if(this.next_hour()==0)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(this.days.length==0)}return this._nextByYearDay(),1}_nextByYearDay(){let t=this.days[this.days_index],r=this.last.year;t<1&&(t+=1,r+=1);let n=w.fromDayOfYear(t,r);this.last.day=n.day,this.last.month=n.month}ruleDayOfWeek(t,r){let n=t.match(/([+-]?[0-9])?(MO|TU|WE|TH|FR|SA|SU)/);return n?[parseInt(n[1]||0,10),t=ut.icalDayToNumericDay(n[2],r)]:[0,0]}next_generic(t,r,n,i,a){let o=t in this.by_data,s=this.rule.freq==r,u=0;if(a&&this[a]()==0)return u;if(o){this.by_indices[t]++;let l=this.by_data[t];this.by_indices[t]==l.length&&(this.by_indices[t]=0,u=1),this.last[n]=l[this.by_indices[t]]}else s&&this["increment_"+n](this.rule.interval);return o&&u&&s&&this["increment_"+i](1),u}increment_monthday(t){for(let r=0;r<t;r++){let n=w.daysInMonth(this.last.month,this.last.year);this.last.day++,this.last.day>n&&(this.last.day-=n,this.increment_month())}}increment_month(){if(this.last.day=1,this.has_by_data("BYMONTH"))this.by_indices.BYMONTH++,this.by_indices.BYMONTH==this.by_data.BYMONTH.length&&(this.by_indices.BYMONTH=0,this.increment_year(1)),this.last.month=this.by_data.BYMONTH[this.by_indices.BYMONTH];else{this.rule.freq=="MONTHLY"?this.last.month+=this.rule.interval:this.last.month++,this.last.month--;let t=U(this.last.month/12);this.last.month%=12,this.last.month++,t!=0&&this.increment_year(t)}}increment_year(t){this.last.year+=t}increment_generic(t,r,n,i){this.last[r]+=t;let a=U(this.last[r]/n);this.last[r]%=n,a!=0&&this["increment_"+i](a)}has_by_data(t){return t in this.rule.parts}expand_year_days(t){let r=new w;this.days=[];let n={},i=["BYDAY","BYWEEKNO","BYMONTHDAY","BYMONTH","BYYEARDAY"];for(let o of i)o in this.rule.parts&&(n[o]=this.rule.parts[o]);if("BYMONTH"in n&&"BYWEEKNO"in n){let o=1,s={};r.year=t,r.isDate=!0;for(let u=0;u<this.by_data.BYMONTH.length;u++){let l=this.by_data.BYMONTH[u];r.month=l,r.day=1;let c=r.weekNumber(this.rule.wkst);r.day=w.daysInMonth(l,t);let d=r.weekNumber(this.rule.wkst);for(u=c;u<d;u++)s[u]=1}for(let u=0;u<this.by_data.BYWEEKNO.length&&o;u++)this.by_data.BYWEEKNO[u]<52?o&=s[u]:o=0;o?delete n.BYMONTH:delete n.BYWEEKNO}let a=Object.keys(n).length;if(a==0){let o=this.dtstart.clone();o.year=this.last.year,this.days.push(o.dayOfYear())}else if(a==1&&"BYMONTH"in n)for(let o of this.by_data.BYMONTH){let s=this.dtstart.clone();s.year=t,s.month=o,s.isDate=!0,this.days.push(s.dayOfYear())}else if(a==1&&"BYMONTHDAY"in n)for(let o of this.by_data.BYMONTHDAY){let s=this.dtstart.clone();o<0&&(o=o+w.daysInMonth(s.month,t)+1),s.day=o,s.year=t,s.isDate=!0,this.days.push(s.dayOfYear())}else if(a==2&&"BYMONTHDAY"in n&&"BYMONTH"in n)for(let o of this.by_data.BYMONTH){let s=w.daysInMonth(o,t);for(let u of this.by_data.BYMONTHDAY)u<0&&(u=u+s+1),r.day=u,r.month=o,r.year=t,r.isDate=!0,this.days.push(r.dayOfYear())}else if(!(a==1&&"BYWEEKNO"in n)&&!(a==2&&"BYWEEKNO"in n&&"BYMONTHDAY"in n))if(a==1&&"BYDAY"in n)this.days=this.days.concat(this.expand_by_day(t));else if(a==2&&"BYDAY"in n&&"BYMONTH"in n){for(let o of this.by_data.BYMONTH){let s=w.daysInMonth(o,t);r.year=t,r.month=o,r.day=1,r.isDate=!0;let u=r.dayOfWeek(),l=r.dayOfYear()-1;r.day=s;let c=r.dayOfWeek();if(this.has_by_data("BYSETPOS")){let d=[];for(let h=1;h<=s;h++)r.day=h,this.is_day_in_byday(r)&&d.push(h);for(let h=0;h<d.length;h++)(this.check_set_position(h+1)||this.check_set_position(h-d.length))&&this.days.push(l+d[h])}else for(let d of this.by_data.BYDAY){let h,f=this.ruleDayOfWeek(d),y=f[0],p=f[1],b=(p+7-u)%7+1,S=s-(c+7-p)%7;if(y==0)for(let M=b;M<=s;M+=7)this.days.push(l+M);else y>0?(h=b+7*(y-1),h<=s&&this.days.push(l+h)):(h=S+7*(y+1),h>0&&this.days.push(l+h))}}this.days.sort(function(o,s){return o-s})}else if(a==2&&"BYDAY"in n&&"BYMONTHDAY"in n){let o=this.expand_by_day(t);for(let s of o){let u=w.fromDayOfYear(s,t);this.by_data.BYMONTHDAY.indexOf(u.day)>=0&&this.days.push(s)}}else if(a==3&&"BYDAY"in n&&"BYMONTHDAY"in n&&"BYMONTH"in n){let o=this.expand_by_day(t);for(let s of o){let u=w.fromDayOfYear(s,t);this.by_data.BYMONTH.indexOf(u.month)>=0&&this.by_data.BYMONTHDAY.indexOf(u.day)>=0&&this.days.push(s)}}else if(a==2&&"BYDAY"in n&&"BYWEEKNO"in n){let o=this.expand_by_day(t);for(let s of o){let u=w.fromDayOfYear(s,t).weekNumber(this.rule.wkst);this.by_data.BYWEEKNO.indexOf(u)&&this.days.push(s)}}else a==3&&"BYDAY"in n&&"BYWEEKNO"in n&&"BYMONTHDAY"in n||(this.days=a==1&&"BYYEARDAY"in n?this.days.concat(this.by_data.BYYEARDAY):[]);return 0}expand_by_day(t){let r=[],n=this.last.clone();n.year=t,n.month=1,n.day=1,n.isDate=!0;let i=n.dayOfWeek();n.month=12,n.day=31,n.isDate=!0;let a=n.dayOfWeek(),o=n.dayOfYear();for(let s of this.by_data.BYDAY){let u=this.ruleDayOfWeek(s),l=u[0],c=u[1];if(l==0)for(let d=(c+7-i)%7+1;d<=o;d+=7)r.push(d);else if(l>0){let d;d=c>=i?c-i+1:c-i+8,r.push(d+7*(l-1))}else{let d;l=-l,d=c<=a?o-a+c:o-a+c-7,r.push(d-7*(l-1))}}return r}is_day_in_byday(t){if(this.by_data.BYDAY)for(let r of this.by_data.BYDAY){let n=this.ruleDayOfWeek(r),i=n[0],a=n[1],o=t.dayOfWeek();if(i==0&&a==o||t.nthWeekDay(a,i)==t.day)return 1}return 0}check_set_position(t){return this.has_by_data("BYSETPOS")?this.by_data.BYSETPOS.indexOf(t)!==-1:!1}sort_byday_rules(t){for(let r=0;r<t.length;r++)for(let n=0;n<r;n++)if(this.ruleDayOfWeek(t[n],this.rule.wkst)[1]>this.ruleDayOfWeek(t[r],this.rule.wkst)[1]){let i=t[r];t[r]=t[n],t[n]=i}}check_contract_restriction(t,r){let n=gt._indexMap[t],i=gt._expandMap[this.rule.freq][n],a=!1;if(t in this.by_data&&i==gt.CONTRACT){let o=this.by_data[t];for(let s of o)if(s==r){a=!0;break}}else a=!0;return a}check_contracting_rules(){let t=this.last.dayOfWeek(),r=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",ut.numericDayToIcalDay(t))&&this.check_contract_restriction("BYWEEKNO",r)&&this.check_contract_restriction("BYMONTHDAY",this.last.day)&&this.check_contract_restriction("BYMONTH",this.last.month)&&this.check_contract_restriction("BYYEARDAY",n)}setup_defaults(t,r,n){let i=gt._indexMap[t];return gt._expandMap[this.rule.freq][i]!=gt.CONTRACT&&(t in this.by_data||(this.by_data[t]=[n]),this.rule.freq!=r)?this.by_data[t][0]:n}toJSON(){let t=Object.create(null);return t.initialized=this.initialized,t.rule=this.rule.toJSON(),t.dtstart=this.dtstart.toJSON(),t.by_data=this.by_data,t.days=this.days,t.last=this.last.toJSON(),t.by_indices=this.by_indices,t.occurrence_number=this.occurrence_number,t}},Ii=/^(SU|MO|TU|WE|TH|FR|SA)$/,Li=/^([+-])?(5[0-3]|[1-4][0-9]|[1-9])?(SU|MO|TU|WE|TH|FR|SA)$/,rr={SU:w.SUNDAY,MO:w.MONDAY,TU:w.TUESDAY,WE:w.WEDNESDAY,TH:w.THURSDAY,FR:w.FRIDAY,SA:w.SATURDAY},Ri=Object.fromEntries(Object.entries(rr).map(e=>e.reverse())),We=["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"],ut=class bt{static fromString(t){let r=this._stringToData(t,!1);return new bt(r)}static fromData(t){return new bt(t)}static _stringToData(t,r){let n=Object.create(null),i=t.split(";"),a=i.length;for(let o=0;o<a;o++){let s=i[o].split("="),u=s[0].toUpperCase(),l=s[0].toLowerCase(),c=r?l:u,d=s[1];if(u in fe){let h=d.split(","),f=0,y=h.length;for(;f<y;f++)h[f]=fe[u](h[f]);n[c]=h.length==1?h[0]:h}else u in he?he[u](d,n,r):n[l]=d}return n}static icalDayToNumericDay(t,r){let n=r||w.SUNDAY;return(rr[t]-n+7)%7+1}static numericDayToIcalDay(t,r){let n=t+(r||w.SUNDAY)-w.SUNDAY;return n>7&&(n-=7),Ri[n]}constructor(t){this.wrappedJSObject=this,this.parts={},t&&typeof t=="object"&&this.fromData(t)}parts=null;interval=1;wkst=w.MONDAY;until=null;count=null;freq=null;icalclass="icalrecur";icaltype="recur";iterator(t){return new be({rule:this,dtstart:t})}clone(){return new bt(this.toJSON())}isFinite(){return!(!this.count&&!this.until)}isByCount(){return!(!this.count||this.until)}addComponent(t,r){let n=t.toUpperCase();n in this.parts?this.parts[n].push(r):this.parts[n]=[r]}setComponent(t,r){this.parts[t.toUpperCase()]=r.slice()}getComponent(t){let r=t.toUpperCase();return r in this.parts?this.parts[r].slice():[]}getNextOccurrence(t,r){let n,i=this.iterator(t);do n=i.next();while(n&&n.compare(r)<=0);return n&&r.zone&&(n.zone=r.zone),n}fromData(t){for(let r in t){let n=r.toUpperCase();n in fe?Array.isArray(t[r])?this.parts[n]=t[r]:this.parts[n]=[t[r]]:this[r]=t[r]}this.interval&&typeof this.interval!="number"&&he.INTERVAL(this.interval,this),this.wkst&&typeof this.wkst!="number"&&(this.wkst=bt.icalDayToNumericDay(this.wkst)),!this.until||this.until instanceof w||(this.until=w.fromString(this.until))}toJSON(){let t=Object.create(null);t.freq=this.freq,this.count&&(t.count=this.count),this.interval>1&&(t.interval=this.interval);for(let[r,n]of Object.entries(this.parts))Array.isArray(n)&&n.length==1?t[r.toLowerCase()]=n[0]:t[r.toLowerCase()]=vt(n);return this.until&&(t.until=this.until.toString()),"wkst"in this&&this.wkst!==w.DEFAULT_WEEK_START&&(t.wkst=bt.numericDayToIcalDay(this.wkst)),t}toString(){let t="FREQ="+this.freq;this.count&&(t+=";COUNT="+this.count),this.interval>1&&(t+=";INTERVAL="+this.interval);for(let[r,n]of Object.entries(this.parts))t+=";"+r+"="+n;return this.until&&(t+=";UNTIL="+this.until.toICALString()),"wkst"in this&&this.wkst!==w.DEFAULT_WEEK_START&&(t+=";WKST="+bt.numericDayToIcalDay(this.wkst)),t}};function dt(e,t,r,n){let i=n;if(n[0]==="+"&&(i=n.slice(1)),i=R(i),t!==void 0&&n<t)throw new Error(e+': invalid value "'+n+'" must be > '+t);if(r!==void 0&&n>r)throw new Error(e+': invalid value "'+n+'" must be < '+t);return i}var he={FREQ:function(e,t,r){if(We.indexOf(e)===-1)throw new Error('invalid frequency "'+e+'" expected: "'+We.join(", ")+'"');t.freq=e},COUNT:function(e,t,r){t.count=R(e)},INTERVAL:function(e,t,r){t.interval=R(e),t.interval<1&&(t.interval=1)},UNTIL:function(e,t,r){e.length>10?t.until=N.icalendar.value["date-time"].fromICAL(e):t.until=N.icalendar.value.date.fromICAL(e),r||(t.until=w.fromString(t.until))},WKST:function(e,t,r){if(!Ii.test(e))throw new Error('invalid WKST value "'+e+'"');t.wkst=ut.icalDayToNumericDay(e)}},fe={BYSECOND:dt.bind(void 0,"BYSECOND",0,60),BYMINUTE:dt.bind(void 0,"BYMINUTE",0,59),BYHOUR:dt.bind(void 0,"BYHOUR",0,23),BYDAY:function(e){if(Li.test(e))return e;throw new Error('invalid BYDAY value "'+e+'"')},BYMONTHDAY:dt.bind(void 0,"BYMONTHDAY",-31,31),BYYEARDAY:dt.bind(void 0,"BYYEARDAY",-366,366),BYWEEKNO:dt.bind(void 0,"BYWEEKNO",-53,53),BYMONTH:dt.bind(void 0,"BYMONTH",1,12),BYSETPOS:dt.bind(void 0,"BYSETPOS",-366,366)},nr=class Dt{static fromString(t,r){let n=t.split("/");if(n.length!==2)throw new Error('Invalid string value: "'+t+'" must contain a "/" char.');let i={start:w.fromDateTimeString(n[0],r)},a=n[1];return X.isValueString(a)?i.duration=X.fromString(a):i.end=w.fromDateTimeString(a,r),new Dt(i)}static fromData(t){return new Dt(t)}static fromJSON(t,r,n){function i(a,o){return n?w.fromString(a,o):w.fromDateTimeString(a,o)}return X.isValueString(t[1])?Dt.fromData({start:i(t[0],r),duration:X.fromString(t[1])}):Dt.fromData({start:i(t[0],r),end:i(t[1],r)})}constructor(t){if(this.wrappedJSObject=this,t&&"start"in t){if(t.start&&!(t.start instanceof w))throw new TypeError(".start must be an instance of ICAL.Time");this.start=t.start}if(t&&t.end&&t.duration)throw new Error("cannot accept both end and duration");if(t&&"end"in t){if(t.end&&!(t.end instanceof w))throw new TypeError(".end must be an instance of ICAL.Time");this.end=t.end}if(t&&"duration"in t){if(t.duration&&!(t.duration instanceof X))throw new TypeError(".duration must be an instance of ICAL.Duration");this.duration=t.duration}}start=null;end=null;duration=null;icalclass="icalperiod";icaltype="period";clone(){return Dt.fromData({start:this.start?this.start.clone():null,end:this.end?this.end.clone():null,duration:this.duration?this.duration.clone():null})}getDuration(){return this.duration?this.duration:this.end.subtractDate(this.start)}getEnd(){if(this.end)return this.end;{let t=this.start.clone();return t.addDuration(this.duration),t}}toString(){return this.start+"/"+(this.end||this.duration)}toJSON(){return[this.start.toString(),(this.end||this.duration).toString()]}toICALString(){return this.start.toICALString()+"/"+(this.end||this.duration).toICALString()}},Fe=/\\\\|\\,|\\[Nn]/g,He=/\\|,|\n/g;function me(e,t){return{matches:/.*/,fromICAL:function(r,n){return function(i,a,o){return i.indexOf("\\")===-1?i:(o&&(a=new RegExp(a.source+"|\\\\"+o,a.flags)),i.replace(a,Bi))}(r,e,n)},toICAL:function(r,n){let i=t;return n&&(i=new RegExp(i.source+"|"+n,i.flags)),r.replace(i,function(a){switch(a){case"\\":return"\\\\";case";":return"\\;";case",":return"\\,";case`
`:return"\\n";default:return a}})}}}var x={defaultType:"text"},zt={defaultType:"text",multiValue:","},ee={defaultType:"text",structuredValue:";"},Zt={defaultType:"integer"},Gt={defaultType:"date-time",allowedTypes:["date-time","date"]},Jt={defaultType:"date-time"},H={defaultType:"uri"},Ve={defaultType:"utc-offset"},Ke={defaultType:"recur"},qe={defaultType:"date-and-or-time",allowedTypes:["date-time","date","text"]};function Bi(e){switch(e){case"\\\\":return"\\";case"\\;":return";";case"\\,":return",";case"\\n":case"\\N":return`
`;default:return e}}var we={categories:zt,url:H,version:x,uid:x},Te={boolean:{values:["TRUE","FALSE"],fromICAL:function(e){return e==="TRUE"},toICAL:function(e){return e?"TRUE":"FALSE"}},float:{matches:/^[+-]?\d+\.\d+$/,fromICAL:function(e){let t=parseFloat(e);return jt(t)?0:t},toICAL:function(e){return String(e)}},integer:{fromICAL:function(e){let t=parseInt(e);return jt(t)?0:t},toICAL:function(e){return String(e)}},"utc-offset":{toICAL:function(e){return e.length<7?e.slice(0,3)+e.slice(4,6):e.slice(0,3)+e.slice(4,6)+e.slice(7,9)},fromICAL:function(e){return e.length<6?e.slice(0,3)+":"+e.slice(3,5):e.slice(0,3)+":"+e.slice(3,5)+":"+e.slice(5,7)},decorate:function(e){return wt.fromString(e)},undecorate:function(e){return e.toString()}}},k=St(Te,{text:me(/\\\\|\\;|\\,|\\[Nn]/g,/\\|;|,|\n/g),uri:{},binary:{decorate:function(e){return Xe.fromString(e)},undecorate:function(e){return e.toString()}},"cal-address":{},date:{decorate:function(e,t){return Z.strict?w.fromDateString(e,t):w.fromString(e,t)},undecorate:function(e){return e.toString()},fromICAL:function(e){return!Z.strict&&e.length>=15?k["date-time"].fromICAL(e):e.slice(0,4)+"-"+e.slice(4,6)+"-"+e.slice(6,8)},toICAL:function(e){let t=e.length;return t==10?e.slice(0,4)+e.slice(5,7)+e.slice(8,10):t>=19?k["date-time"].toICAL(e):e}},"date-time":{fromICAL:function(e){if(Z.strict||e.length!=8){let t=e.slice(0,4)+"-"+e.slice(4,6)+"-"+e.slice(6,8)+"T"+e.slice(9,11)+":"+e.slice(11,13)+":"+e.slice(13,15);return e[15]&&e[15]==="Z"&&(t+="Z"),t}return k.date.fromICAL(e)},toICAL:function(e){let t=e.length;if(t!=10||Z.strict){if(t>=19){let r=e.slice(0,4)+e.slice(5,7)+e.slice(8,13)+e.slice(14,16)+e.slice(17,19);return e[19]&&e[19]==="Z"&&(r+="Z"),r}return e}return k.date.toICAL(e)},decorate:function(e,t){return Z.strict?w.fromDateTimeString(e,t):w.fromString(e,t)},undecorate:function(e){return e.toString()}},duration:{decorate:function(e){return X.fromString(e)},undecorate:function(e){return e.toString()}},period:{fromICAL:function(e){let t=e.split("/");return t[0]=k["date-time"].fromICAL(t[0]),X.isValueString(t[1])||(t[1]=k["date-time"].fromICAL(t[1])),t},toICAL:function(e){return e=e.slice(),Z.strict||e[0].length!=10?e[0]=k["date-time"].toICAL(e[0]):e[0]=k.date.toICAL(e[0]),X.isValueString(e[1])||(Z.strict||e[1].length!=10?e[1]=k["date-time"].toICAL(e[1]):e[1]=k.date.toICAL(e[1])),e.join("/")},decorate:function(e,t){return nr.fromJSON(e,t,!Z.strict)},undecorate:function(e){return e.toJSON()}},recur:{fromICAL:function(e){return ut._stringToData(e,!0)},toICAL:function(e){let t="";for(let[r,n]of Object.entries(e))r=="until"?n=n.length>10?k["date-time"].toICAL(n):k.date.toICAL(n):r=="wkst"?typeof n=="number"&&(n=ut.numericDayToIcalDay(n)):Array.isArray(n)&&(n=n.join(",")),t+=r.toUpperCase()+"="+n+";";return t.slice(0,Math.max(0,t.length-1))},decorate:function(e){return ut.fromData(e)},undecorate:function(e){return e.toJSON()}},time:{fromICAL:function(e){if(e.length<6)return e;let t=e.slice(0,2)+":"+e.slice(2,4)+":"+e.slice(4,6);return e[6]==="Z"&&(t+="Z"),t},toICAL:function(e){if(e.length<8)return e;let t=e.slice(0,2)+e.slice(3,5)+e.slice(6,8);return e[8]==="Z"&&(t+="Z"),t}}}),ji=St(we,{action:x,attach:{defaultType:"uri"},attendee:{defaultType:"cal-address"},calscale:x,class:x,comment:x,completed:Jt,contact:x,created:Jt,description:x,dtend:Gt,dtstamp:Jt,dtstart:Gt,due:Gt,duration:{defaultType:"duration"},exdate:{defaultType:"date-time",allowedTypes:["date-time","date"],multiValue:","},exrule:Ke,freebusy:{defaultType:"period",multiValue:","},geo:{defaultType:"float",structuredValue:";"},"last-modified":Jt,location:x,method:x,organizer:{defaultType:"cal-address"},"percent-complete":Zt,priority:Zt,prodid:x,"related-to":x,repeat:Zt,rdate:{defaultType:"date-time",allowedTypes:["date-time","date","period"],multiValue:",",detectType:function(e){return e.indexOf("/")!==-1?"period":e.indexOf("T")===-1?"date":"date-time"}},"recurrence-id":Gt,resources:zt,"request-status":ee,rrule:Ke,sequence:Zt,status:x,summary:x,transp:x,trigger:{defaultType:"duration",allowedTypes:["duration","date-time"]},tzoffsetfrom:Ve,tzoffsetto:Ve,tzurl:H,tzid:x,tzname:x}),$=St(Te,{text:me(Fe,He),uri:me(Fe,He),date:{decorate:function(e){return Rt.fromDateAndOrTimeString(e,"date")},undecorate:function(e){return e.toString()},fromICAL:function(e){return e.length==8?k.date.fromICAL(e):e[0]=="-"&&e.length==6?e.slice(0,4)+"-"+e.slice(4):e},toICAL:function(e){return e.length==10?k.date.toICAL(e):e[0]=="-"&&e.length==7?e.slice(0,4)+e.slice(5):e}},time:{decorate:function(e){return Rt.fromDateAndOrTimeString("T"+e,"time")},undecorate:function(e){return e.toString()},fromICAL:function(e){let t=$.time._splitZone(e,!0),r=t[0],n=t[1];return n.length==6?n=n.slice(0,2)+":"+n.slice(2,4)+":"+n.slice(4,6):n.length==4&&n[0]!="-"?n=n.slice(0,2)+":"+n.slice(2,4):n.length==5&&(n=n.slice(0,3)+":"+n.slice(3,5)),r.length!=5||r[0]!="-"&&r[0]!="+"||(r=r.slice(0,3)+":"+r.slice(3)),n+r},toICAL:function(e){let t=$.time._splitZone(e),r=t[0],n=t[1];return n.length==8?n=n.slice(0,2)+n.slice(3,5)+n.slice(6,8):n.length==5&&n[0]!="-"?n=n.slice(0,2)+n.slice(3,5):n.length==6&&(n=n.slice(0,3)+n.slice(4,6)),r.length!=6||r[0]!="-"&&r[0]!="+"||(r=r.slice(0,3)+r.slice(4)),n+r},_splitZone:function(e,t){let r,n,i=e.length-1,a=e.length-(t?5:6),o=e[a];return e[i]=="Z"?(r=e[i],n=e.slice(0,Math.max(0,i))):e.length>6&&(o=="-"||o=="+")?(r=e.slice(a),n=e.slice(0,Math.max(0,a))):(r="",n=e),[r,n]}},"date-time":{decorate:function(e){return Rt.fromDateAndOrTimeString(e,"date-time")},undecorate:function(e){return e.toString()},fromICAL:function(e){return $["date-and-or-time"].fromICAL(e)},toICAL:function(e){return $["date-and-or-time"].toICAL(e)}},"date-and-or-time":{decorate:function(e){return Rt.fromDateAndOrTimeString(e,"date-and-or-time")},undecorate:function(e){return e.toString()},fromICAL:function(e){let t=e.split("T");return(t[0]?$.date.fromICAL(t[0]):"")+(t[1]?"T"+$.time.fromICAL(t[1]):"")},toICAL:function(e){let t=e.split("T");return $.date.toICAL(t[0])+(t[1]?"T"+$.time.toICAL(t[1]):"")}},timestamp:k["date-time"],"language-tag":{matches:/^[a-zA-Z0-9-]+$/},"phone-number":{fromICAL:function(e){return Array.from(e).filter(function(t){return t==="\\"?void 0:t}).join("")},toICAL:function(e){return Array.from(e).map(function(t){return t===","||t===";"?"\\"+t:t}).join("")}}}),zi=St(we,{adr:{defaultType:"text",structuredValue:";",multiValue:","},anniversary:qe,bday:qe,caladruri:H,caluri:H,clientpidmap:ee,email:x,fburl:H,fn:x,gender:ee,geo:H,impp:H,key:H,kind:x,lang:{defaultType:"language-tag"},logo:H,member:H,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:zt,note:x,org:{defaultType:"text",structuredValue:";"},photo:H,related:H,rev:{defaultType:"timestamp"},role:x,sound:H,source:H,tel:{defaultType:"uri",allowedTypes:["uri","text"]},title:x,tz:{defaultType:"text",allowedTypes:["text","utc-offset","uri"]},xml:x}),Wi=St(Te,{binary:k.binary,date:$.date,"date-time":$["date-time"],"phone-number":$["phone-number"],uri:k.uri,text:k.text,time:k.time,vcard:k.text,"utc-offset":{toICAL:function(e){return e.slice(0,7)},fromICAL:function(e){return e.slice(0,7)},decorate:function(e){return wt.fromString(e)},undecorate:function(e){return e.toString()}}}),Fi=St(we,{fn:x,n:{defaultType:"text",structuredValue:";",multiValue:","},nickname:zt,photo:{defaultType:"binary",allowedTypes:["binary","uri"]},bday:{defaultType:"date-time",allowedTypes:["date-time","date"],detectType:function(e){return e.indexOf("T")===-1?"date":"date-time"}},adr:{defaultType:"text",structuredValue:";",multiValue:","},label:x,tel:{defaultType:"phone-number"},email:x,mailer:x,tz:{defaultType:"utc-offset",allowedTypes:["utc-offset","text"]},geo:{defaultType:"float",structuredValue:";"},title:x,role:x,logo:{defaultType:"binary",allowedTypes:["binary","uri"]},agent:{defaultType:"vcard",allowedTypes:["vcard","text","uri"]},org:ee,note:zt,prodid:x,rev:{defaultType:"date-time",allowedTypes:["date-time","date"],detectType:function(e){return e.indexOf("T")===-1?"date":"date-time"}},"sort-string":x,sound:{defaultType:"binary",allowedTypes:["binary","uri"]},class:x,key:{defaultType:"binary",allowedTypes:["binary","text"]}}),ot={value:k,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:ji,propertyGroups:!1},$e={value:$,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:zi,propertyGroups:!0},Ze={value:Wi,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:Fi,propertyGroups:!0},Z={strict:!0,defaultSet:ot,defaultType:"unknown",components:{vcard:$e,vcard3:Ze,vevent:ot,vtodo:ot,vjournal:ot,valarm:ot,vtimezone:ot,daylight:ot,standard:ot},icalendar:ot,vcard:$e,vcard3:Ze,getDesignSet:function(e){return e&&e in Z.components?Z.components[e]:Z.defaultSet}},N=Z,Xt=`\r
`,Ge="unknown",Hi={'"':"^'","\n":"^n","^":"^^"};function Y(e){typeof e[0]=="string"&&(e=[e]);let t=0,r=e.length,n="";for(;t<r;t++)n+=Y.component(e[t])+Xt;return n}Y.component=function(e,t){let r=e[0].toUpperCase(),n="BEGIN:"+r+Xt,i=e[1],a=0,o=i.length,s=e[0];for(s==="vcard"&&e[1].length>0&&(e[1][0][0]!=="version"||e[1][0][3]!=="4.0")&&(s="vcard3"),t=t||N.getDesignSet(s);a<o;a++)n+=Y.property(i[a],t)+Xt;let u=e[2]||[],l=0,c=u.length;for(;l<c;l++)n+=Y.component(u[l],t)+Xt;return n+="END:"+r,n},Y.property=function(e,t,r){let n=e[0].toUpperCase(),i=e[0],a=e[1];t||(t=N.defaultSet);let o,s=a.group;o=t.propertyGroups&&s?s.toUpperCase()+"."+n:n;for(let[f,y]of Object.entries(a)){if(t.propertyGroups&&f=="group")continue;let p=t.param[f],b=p&&p.multiValue;b&&Array.isArray(y)?(y=y.map(function(S){return S=Y._rfc6868Unescape(S),S=Y.paramPropertyValue(S,p.multiValueSeparateDQuote)}),y=Y.multiValue(y,b,"unknown",null,t)):(y=Y._rfc6868Unescape(y),y=Y.paramPropertyValue(y)),o+=";"+f.toUpperCase()+"="+y}if(e.length===3)return o+":";let u,l=e[2],c=!1,d=!1,h=!1;return i in t.property?(u=t.property[i],"multiValue"in u&&(c=u.multiValue),"structuredValue"in u&&Array.isArray(e[3])&&(d=u.structuredValue),"defaultType"in u?l===u.defaultType&&(h=!0):l===Ge&&(h=!0)):l===Ge&&(h=!0),h||(o+=";VALUE="+l.toUpperCase()),o+=":",o+=c&&d?Y.multiValue(e[3],d,l,c,t,d):c?Y.multiValue(e.slice(3),c,l,null,t,!1):d?Y.multiValue(e[3],d,l,null,t,d):Y.value(e[3],l,t,!1),r?o:er(o)},Y.paramPropertyValue=function(e,t){return t||Q(e,",")!==-1||Q(e,":")!==-1||Q(e,";")!==-1?'"'+e+'"':e},Y.multiValue=function(e,t,r,n,i,a){let o="",s=e.length,u=0;for(;u<s;u++)n&&Array.isArray(e[u])?o+=Y.multiValue(e[u],n,r,null,i,a):o+=Y.value(e[u],r,i,a),u!==s-1&&(o+=t);return o},Y.value=function(e,t,r,n){return t in r.value&&"toICAL"in r.value[t]?r.value[t].toICAL(e,n):e},Y._rfc6868Unescape=function(e){return e.replace(/[\n^"]/g,function(t){return Hi[t]})};var Bt=class ir{static fromString(t,r){return new ir(A.property(t,r))}constructor(t,r){this._parent=r||null,typeof t=="string"?(this.jCal=[t,{},N.defaultType],this.jCal[2]=this.getDefaultType()):this.jCal=t,this._updateType()}get type(){return this.jCal[2]}get name(){return this.jCal[0]}get parent(){return this._parent}set parent(t){let r=!this._parent||t&&t._designSet!=this._parent._designSet;this._parent=t,this.type==N.defaultType&&r&&(this.jCal[2]=this.getDefaultType(),this._updateType())}get _designSet(){return this.parent?this.parent._designSet:N.defaultSet}_updateType(){let 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]))}_hydrateValue(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]}_decorate(t){return this._designSet.value[this.type].decorate(t,this)}_undecorate(t){return this._designSet.value[this.type].undecorate(t,this)}_setDecoratedValue(t,r){this._values||(this._values=[]),typeof t=="object"&&"icaltype"in t?(this.jCal[3+r]=this._undecorate(t),this._values[r]=t):(this.jCal[3+r]=t,this._values[r]=this._decorate(t))}getParameter(t){return t in this.jCal[1]?this.jCal[1][t]:void 0}getFirstParameter(t){let r=this.getParameter(t);return Array.isArray(r)?r[0]:r}setParameter(t,r){let n=t.toLowerCase();typeof r=="string"&&n in this._designSet.param&&"multiValue"in this._designSet.param[n]&&(r=[r]),this.jCal[1][t]=r}removeParameter(t){delete this.jCal[1][t]}getDefaultType(){let t=this.jCal[0],r=this._designSet;if(t in r.property){let n=r.property[t];if("defaultType"in n)return n.defaultType}return N.defaultType}resetType(t){this.removeAllValues(),this.jCal[2]=t,this._updateType()}getFirstValue(){return this._hydrateValue(0)}getValues(){let t=this.jCal.length-3;if(t<1)return[];let r=0,n=[];for(;r<t;r++)n[r]=this._hydrateValue(r);return n}removeAllValues(){this._values&&(this._values.length=0),this.jCal.length=3}setValues(t){if(!this.isMultiValue)throw new Error(this.name+`: does not not support mulitValue.
override isMultiValue`);let r=t.length,n=0;if(this.removeAllValues(),r>0&&typeof t[0]=="object"&&"icaltype"in t[0]&&this.resetType(t[0].icaltype),this.isDecorated)for(;n<r;n++)this._setDecoratedValue(t[n],n);else for(;n<r;n++)this.jCal[3+n]=t[n]}setValue(t){this.removeAllValues(),typeof t=="object"&&"icaltype"in t&&this.resetType(t.icaltype),this.isDecorated?this._setDecoratedValue(t,0):this.jCal[3]=t}toJSON(){return this.jCal}toICALString(){return Y.property(this.jCal,this._designSet,!0)}},tt=class pe{static fromString(t){return new pe(A.component(t))}constructor(t,r){typeof t=="string"&&(t=[t,[],[]]),this.jCal=t,this.parent=r||null,this.parent||this.name!=="vcalendar"||(this._timezoneCache=new Map)}_hydratedPropertyCount=0;_hydratedComponentCount=0;_timezoneCache=null;get name(){return this.jCal[0]}get _designSet(){return this.parent&&this.parent._designSet||N.getDesignSet(this.name)}_hydrateComponent(t){if(this._components||(this._components=[],this._hydratedComponentCount=0),this._components[t])return this._components[t];let r=new pe(this.jCal[2][t],this);return this._hydratedComponentCount++,this._components[t]=r}_hydrateProperty(t){if(this._properties||(this._properties=[],this._hydratedPropertyCount=0),this._properties[t])return this._properties[t];let r=new Bt(this.jCal[1][t],this);return this._hydratedPropertyCount++,this._properties[t]=r}getFirstSubcomponent(t){if(t){let r=0,n=this.jCal[2],i=n.length;for(;r<i;r++)if(n[r][0]===t)return this._hydrateComponent(r)}else if(this.jCal[2].length)return this._hydrateComponent(0);return null}getAllSubcomponents(t){let r=this.jCal[2].length,n=0;if(t){let i=this.jCal[2],a=[];for(;n<r;n++)t===i[n][0]&&a.push(this._hydrateComponent(n));return a}if(!this._components||this._hydratedComponentCount!==r)for(;n<r;n++)this._hydrateComponent(n);return this._components||[]}hasProperty(t){let r=this.jCal[1],n=r.length,i=0;for(;i<n;i++)if(r[i][0]===t)return!0;return!1}getFirstProperty(t){if(t){let r=0,n=this.jCal[1],i=n.length;for(;r<i;r++)if(n[r][0]===t)return this._hydrateProperty(r)}else if(this.jCal[1].length)return this._hydrateProperty(0);return null}getFirstPropertyValue(t){let r=this.getFirstProperty(t);return r?r.getFirstValue():null}getAllProperties(t){let r=this.jCal[1].length,n=0;if(t){let i=this.jCal[1],a=[];for(;n<r;n++)t===i[n][0]&&a.push(this._hydrateProperty(n));return a}if(!this._properties||this._hydratedPropertyCount!==r)for(;n<r;n++)this._hydrateProperty(n);return this._properties||[]}_removeObjectByIndex(t,r,n){if((r=r||[])[n]){let i=r[n];"parent"in i&&(i.parent=null)}r.splice(n,1),this.jCal[t].splice(n,1)}_removeObject(t,r,n){let i=0,a=this.jCal[t],o=a.length,s=this[r];if(typeof n=="string"){for(;i<o;i++)if(a[i][0]===n)return this._removeObjectByIndex(t,s,i),!0}else if(s){for(;i<o;i++)if(s[i]&&s[i]===n)return this._removeObjectByIndex(t,s,i),!0}return!1}_removeAllObjects(t,r,n){let i=this[r],a=this.jCal[t],o=a.length-1;for(;o>=0;o--)n&&a[o][0]!==n||this._removeObjectByIndex(t,i,o)}addSubcomponent(t){this._components||(this._components=[],this._hydratedComponentCount=0),t.parent&&t.parent.removeSubcomponent(t);let r=this.jCal[2].push(t.jCal);return this._components[r-1]=t,this._hydratedComponentCount++,t.parent=this,t}removeSubcomponent(t){let r=this._removeObject(2,"_components",t);return r&&this._hydratedComponentCount--,r}removeAllSubcomponents(t){let r=this._removeAllObjects(2,"_components",t);return this._hydratedComponentCount=0,r}addProperty(t){if(!(t instanceof Bt))throw new TypeError("must be instance of ICAL.Property");this._properties||(this._properties=[],this._hydratedPropertyCount=0),t.parent&&t.parent.removeProperty(t);let r=this.jCal[1].push(t.jCal);return this._properties[r-1]=t,this._hydratedPropertyCount++,t.parent=this,t}addPropertyWithValue(t,r){let n=new Bt(t);return n.setValue(r),this.addProperty(n),n}updatePropertyWithValue(t,r){let n=this.getFirstProperty(t);return n?n.setValue(r):n=this.addPropertyWithValue(t,r),n}removeProperty(t){let r=this._removeObject(1,"_properties",t);return r&&this._hydratedPropertyCount--,r}removeAllProperties(t){let r=this._removeAllObjects(1,"_properties",t);return this._hydratedPropertyCount=0,r}toJSON(){return this.jCal}toString(){return Y.component(this.jCal,this._designSet)}getTimeZoneByID(t){if(this.parent)return this.parent.getTimeZoneByID(t);if(!this._timezoneCache)return null;if(this._timezoneCache.has(t))return this._timezoneCache.get(t);let r=this.getAllSubcomponents("vtimezone");for(let n of r)if(n.getFirstProperty("tzid").getFirstValue()===t){let i=new C({component:n,tzid:t});return this._timezoneCache.set(t,i),i}return null}},ar=class{constructor(e){this.ruleDates=[],this.exDates=[],this.fromData(e)}complete=!1;ruleIterators=null;ruleDates=null;exDates=null;ruleDateInc=0;exDateInc=0;exDate=null;ruleDate=null;dtstart=null;last=null;fromData(e){let t=st(e.dtstart,w);if(!t)throw new Error(".dtstart (ICAL.Time) must be given");if(this.dtstart=t,e.component)this._init(e.component);else{if(this.last=st(e.last,w)||t.clone(),!e.ruleIterators)throw new Error(".ruleIterators or .component must be given");this.ruleIterators=e.ruleIterators.map(function(r){return st(r,be)}),this.ruleDateInc=e.ruleDateInc,this.exDateInc=e.exDateInc,e.ruleDates&&(this.ruleDates=e.ruleDates.map(r=>st(r,w)),this.ruleDate=this.ruleDates[this.ruleDateInc]),e.exDates&&(this.exDates=e.exDates.map(r=>st(r,w)),this.exDate=this.exDates[this.exDateInc]),e.complete!==void 0&&(this.complete=e.complete)}}next(){let e,t,r,n=0;for(;;){if(n++>500)throw new Error("max tries have occurred, rule may be impossible to fulfill.");if(t=this.ruleDate,e=this._nextRecurrenceIter(this.last),!t&&!e){this.complete=!0;break}if((!t||e&&t.compare(e.last)>0)&&(t=e.last.clone(),e.next()),this.ruleDate===t&&this._nextRuleDay(),this.last=t,!this.exDate||(r=this.exDate.compare(this.last),r<0&&this._nextExDay(),r!==0))return this.last;this._nextExDay()}}toJSON(){function e(r){return r.toJSON()}let t=Object.create(null);return t.ruleIterators=this.ruleIterators.map(e),this.ruleDates&&(t.ruleDates=this.ruleDates.map(e)),this.exDates&&(t.exDates=this.exDates.map(e)),t.ruleDateInc=this.ruleDateInc,t.exDateInc=this.exDateInc,t.last=this.last.toJSON(),t.dtstart=this.dtstart.toJSON(),t.complete=this.complete,t}_extractDates(e,t){let r=[],n=e.getAllProperties(t);for(let i=0,a=n.length;i<a;i++)for(let o of n[i].getValues()){let s=Tt(r,o,(u,l)=>u.compare(l));r.splice(s,0,o)}return r}_init(e){if(this.ruleIterators=[],this.last=this.dtstart.clone(),!e.hasProperty("rdate")&&!e.hasProperty("rrule")&&!e.hasProperty("recurrence-id"))return this.ruleDate=this.last.clone(),void(this.complete=!0);if(e.hasProperty("rdate")&&(this.ruleDates=this._extractDates(e,"rdate"),this.ruleDates[0]&&this.ruleDates[0].compare(this.dtstart)<0?(this.ruleDateInc=0,this.last=this.ruleDates[0].clone()):this.ruleDateInc=Tt(this.ruleDates,this.last,(t,r)=>t.compare(r)),this.ruleDate=this.ruleDates[this.ruleDateInc]),e.hasProperty("rrule")){let t,r,n=e.getAllProperties("rrule"),i=0,a=n.length;for(;i<a;i++)t=n[i].getFirstValue(),r=t.iterator(this.dtstart),this.ruleIterators.push(r),r.next()}e.hasProperty("exdate")&&(this.exDates=this._extractDates(e,"exdate"),this.exDateInc=Tt(this.exDates,this.last,(t,r)=>t.compare(r)),this.exDate=this.exDates[this.exDateInc])}_nextExDay(){this.exDate=this.exDates[++this.exDateInc]}_nextRuleDay(){this.ruleDate=this.ruleDates[++this.ruleDateInc]}_nextRecurrenceIter(){let e=this.ruleIterators;if(e.length===0)return null;let t,r,n,i=e.length,a=0;for(;a<i;a++)t=e[a],r=t.last,t.completed?(i--,a!==0&&a--,e.splice(a,1)):(!n||n.last.compare(r)>0)&&(n=t);return n}},Je=class ge{constructor(t,r){t instanceof tt||(r=t,t=null),this.component=t||new tt("vevent"),this._rangeExceptionCache=Object.create(null),this.exceptions=Object.create(null),this.rangeExceptions=[],r&&r.strictExceptions&&(this.strictExceptions=r.strictExceptions),r&&r.exceptions?r.exceptions.forEach(this.relateException,this):this.component.parent&&!this.isRecurrenceException()&&this.component.parent.getAllSubcomponents("vevent").forEach(function(n){n.hasProperty("recurrence-id")&&this.relateException(n)},this)}static THISANDFUTURE="THISANDFUTURE";exceptions=null;strictExceptions=!1;relateException(t){if(this.isRecurrenceException())throw new Error("cannot relate exception to exceptions");if(t instanceof tt&&(t=new ge(t)),this.strictExceptions&&t.uid!==this.uid)throw new Error("attempted to relate unrelated exception");let r=t.recurrenceId.toString();if(this.exceptions[r]=t,t.modifiesFuture()){let n=[t.recurrenceId.toUnixTime(),r],i=Tt(this.rangeExceptions,n,Qe);this.rangeExceptions.splice(i,0,n)}}modifiesFuture(){return this.component.hasProperty("recurrence-id")?this.component.getFirstProperty("recurrence-id").getParameter("range")===ge.THISANDFUTURE:!1}findRangeException(t){if(!this.rangeExceptions.length)return null;let r=t.toUnixTime(),n=Tt(this.rangeExceptions,[r],Qe);if(n-=1,n<0)return null;let i=this.rangeExceptions[n];return r<i[0]?null:i[1]}getOccurrenceDetails(t){let r,n=t.toString(),i=t.convertToZone(C.utcTimezone).toString(),a={recurrenceId:t};if(n in this.exceptions)r=a.item=this.exceptions[n],a.startDate=r.startDate,a.endDate=r.endDate,a.item=r;else if(i in this.exceptions)r=this.exceptions[i],a.startDate=r.startDate,a.endDate=r.endDate,a.item=r;else{let o,s=this.findRangeException(t);if(s){let u=this.exceptions[s];a.item=u;let l=this._rangeExceptionCache[s];if(!l){let d=u.recurrenceId.clone(),h=u.startDate.clone();d.zone=h.zone,l=h.subtractDate(d),this._rangeExceptionCache[s]=l}let c=t.clone();c.zone=u.startDate.zone,c.addDuration(l),o=c.clone(),o.addDuration(u.duration),a.startDate=c,a.endDate=o}else o=t.clone(),o.addDuration(this.duration),a.endDate=o,a.startDate=t,a.item=this}return a}iterator(t){return new ar({component:this.component,dtstart:t||this.startDate})}isRecurring(){let t=this.component;return t.hasProperty("rrule")||t.hasProperty("rdate")}isRecurrenceException(){return this.component.hasProperty("recurrence-id")}getRecurrenceTypes(){let t=this.component.getAllProperties("rrule"),r=0,n=t.length,i=Object.create(null);for(;r<n;r++)i[t[r].getFirstValue().freq]=!0;return i}get uid(){return this._firstProp("uid")}set uid(t){this._setProp("uid",t)}get startDate(){return this._firstProp("dtstart")}set startDate(t){this._setTime("dtstart",t)}get endDate(){let t=this._firstProp("dtend");if(!t){let r=this._firstProp("duration");t=this.startDate.clone(),r?t.addDuration(r):t.isDate&&(t.day+=1)}return t}set endDate(t){this.component.hasProperty("duration")&&this.component.removeProperty("duration"),this._setTime("dtend",t)}get duration(){return this._firstProp("duration")||this.endDate.subtractDateTz(this.startDate)}set duration(t){this.component.hasProperty("dtend")&&this.component.removeProperty("dtend"),this._setProp("duration",t)}get location(){return this._firstProp("location")}set location(t){this._setProp("location",t)}get attendees(){return this.component.getAllProperties("attendee")}get summary(){return this._firstProp("summary")}set summary(t){this._setProp("summary",t)}get description(){return this._firstProp("description")}set description(t){this._setProp("description",t)}get color(){return this._firstProp("color")}set color(t){this._setProp("color",t)}get organizer(){return this._firstProp("organizer")}set organizer(t){this._setProp("organizer",t)}get sequence(){return this._firstProp("sequence")}set sequence(t){this._setProp("sequence",t)}get recurrenceId(){return this._firstProp("recurrence-id")}set recurrenceId(t){this._setTime("recurrence-id",t)}_setTime(t,r){let n=this.component.getFirstProperty(t);n||(n=new Bt(t),this.component.addProperty(n)),r.zone===C.localTimezone||r.zone===C.utcTimezone?n.removeParameter("tzid"):n.setParameter("tzid",r.zone.tzid),n.setValue(r)}_setProp(t,r){this.component.updatePropertyWithValue(t,r)}_firstProp(t){return this.component.getFirstPropertyValue(t)}toString(){return this.component.toString()}};function Qe(e,t){return e[0]>t[0]?1:t[0]>e[0]?-1:0}var ht={foldLength:75,debug:!1,newLineChar:`\r
`,Binary:Xe,Component:tt,ComponentParser:class{constructor(e){e===void 0&&(e={});for(let[t,r]of Object.entries(e))this[t]=r}parseEvent=!0;parseTimezone=!0;oncomplete=function(){};onerror=function(e){};ontimezone=function(e){};onevent=function(e){};process(e){typeof e=="string"&&(e=A(e)),e instanceof tt||(e=new tt(e));let t,r=e.getAllSubcomponents(),n=0,i=r.length;for(;n<i;n++)switch(t=r[n],t.name){case"vtimezone":if(this.parseTimezone){let a=t.getFirstPropertyValue("tzid");a&&this.ontimezone(new C({tzid:a,component:t}))}break;case"vevent":this.parseEvent&&this.onevent(new Je(t));break;default:continue}this.oncomplete()}},Duration:X,Event:Je,Period:nr,Property:Bt,Recur:ut,RecurExpansion:ar,RecurIterator:be,Time:w,Timezone:C,TimezoneService:te,UtcOffset:wt,VCardTime:Rt,parse:A,stringify:Y,design:N,helpers:Ni};var ve=function(e,t){return ve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},ve(e,t)};function At(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ve(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var L=function(){return L=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},L.apply(this,arguments)};function g(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,a;n<i;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var _e=["MO","TU","WE","TH","FR","SA","SU"],W=function(){function e(t,r){if(r===0)throw new Error("Can't create weekday with n == 0");this.weekday=t,this.n=r}return e.fromStr=function(t){return new e(_e.indexOf(t))},e.prototype.nth=function(t){return this.n===t?this:new e(this.weekday,t)},e.prototype.equals=function(t){return this.weekday===t.weekday&&this.n===t.n},e.prototype.toString=function(){var t=_e[this.weekday];return this.n&&(t=(this.n>0?"+":"")+String(this.n)+t),t},e.prototype.getJsWeekday=function(){return this.weekday===6?0:this.weekday+1},e}(),P=function(e){return e!=null},rt=function(e){return typeof e=="number"},or=function(e){return typeof e=="string"&&_e.includes(e)},K=Array.isArray,it=function(e,t){t===void 0&&(t=e),arguments.length===1&&(t=e,e=0);for(var r=[],n=e;n<t;n++)r.push(n);return r},_=function(e,t){var r=0,n=[];if(K(e))for(;r<t;r++)n[r]=[].concat(e);else for(;r<t;r++)n[r]=e;return n},Vi=function(e){return K(e)?e:[e]};function Et(e,t,r){r===void 0&&(r=" ");var n=String(e);return t=t>>0,n.length>t?String(n):(t=t-n.length,t>r.length&&(r+=_(r,t/r.length)),r.slice(0,t)+String(n))}var Ki=function(e,t,r){var n=e.split(t);return r?n.slice(0,r).concat([n.slice(r).join(t)]):n},G=function(e,t){var r=e%t;return r*t<0?r+t:r},Se=function(e,t){return{div:Math.floor(e/t),mod:G(e,t)}},nt=function(e){return!P(e)||e.length===0},I=function(e){return!nt(e)},O=function(e,t){return I(e)&&e.indexOf(t)!==-1},xt=function(e,t,r,n,i,a){return n===void 0&&(n=0),i===void 0&&(i=0),a===void 0&&(a=0),new Date(Date.UTC(e,t-1,r,n,i,a))},qi=[31,28,31,30,31,30,31,31,30,31,30,31],xr=1e3*60*60*24,_r=9999,Dr=xt(1970,1,1),$i=[6,0,1,2,3,4,5],Ft=function(e){return e%4===0&&e%100!==0||e%400===0},Ar=function(e){return e instanceof Date},Wt=function(e){return Ar(e)&&!isNaN(e.getTime())},Zi=function(e,t){var r=e.getTime(),n=t.getTime(),i=r-n;return Math.round(i/xr)},De=function(e){return Zi(e,Dr)},Er=function(e){return new Date(Dr.getTime()+e*xr)},Gi=function(e){var t=e.getUTCMonth();return t===1&&Ft(e.getUTCFullYear())?29:qi[t]},Yt=function(e){return $i[e.getUTCDay()]},sr=function(e,t){var r=xt(e,t+1,1);return[Yt(r),Gi(r)]},Or=function(e,t){return t=t||e,new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()))},Ae=function(e){var t=new Date(e.getTime());return t},ur=function(e){for(var t=[],r=0;r<e.length;r++)t.push(Ae(e[r]));return t},Ht=function(e){e.sort(function(t,r){return t.getTime()-r.getTime()})},Ce=function(e,t){t===void 0&&(t=!0);var r=new Date(e);return[Et(r.getUTCFullYear().toString(),4,"0"),Et(r.getUTCMonth()+1,2,"0"),Et(r.getUTCDate(),2,"0"),"T",Et(r.getUTCHours(),2,"0"),Et(r.getUTCMinutes(),2,"0"),Et(r.getUTCSeconds(),2,"0"),t?"Z":""].join("")},Ye=function(e){var t=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/,r=t.exec(e);if(!r)throw new Error("Invalid UNTIL value: ".concat(e));return new Date(Date.UTC(parseInt(r[1],10),parseInt(r[2],10)-1,parseInt(r[3],10),parseInt(r[5],10)||0,parseInt(r[6],10)||0,parseInt(r[7],10)||0))},lr=function(e,t){var r=e.toLocaleString("sv-SE",{timeZone:t});return r.replace(" ","T")+"Z"},Ji=function(e,t){var r=Intl.DateTimeFormat().resolvedOptions().timeZone,n=new Date(lr(e,r)),i=new Date(lr(e,t??"UTC")),a=i.getTime()-n.getTime();return new Date(e.getTime()-a)},Qi=function(){function e(t,r){this.minDate=null,this.maxDate=null,this._result=[],this.total=0,this.method=t,this.args=r,t==="between"?(this.maxDate=r.inc?r.before:new Date(r.before.getTime()-1),this.minDate=r.inc?r.after:new Date(r.after.getTime()+1)):t==="before"?this.maxDate=r.inc?r.dt:new Date(r.dt.getTime()-1):t==="after"&&(this.minDate=r.inc?r.dt:new Date(r.dt.getTime()+1))}return e.prototype.accept=function(t){++this.total;var r=this.minDate&&t<this.minDate,n=this.maxDate&&t>this.maxDate;if(this.method==="between"){if(r)return!0;if(n)return!1}else if(this.method==="before"){if(n)return!1}else if(this.method==="after")return r?!0:(this.add(t),!1);return this.add(t)},e.prototype.add=function(t){return this._result.push(t),!0},e.prototype.getValue=function(){var t=this._result;switch(this.method){case"all":case"between":return t;case"before":case"after":default:return t.length?t[t.length-1]:null}},e.prototype.clone=function(){return new e(this.method,this.args)},e}(),Ct=Qi,Xi=function(e){At(t,e);function t(r,n,i){var a=e.call(this,r,n)||this;return a.iterator=i,a}return t.prototype.add=function(r){return this.iterator(r,this._result.length)?(this._result.push(r),!0):!1},t}(Ct),cr=Xi,ta={dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],tokens:{SKIP:/^[ \r\n\t]+|^\.$/,number:/^[1-9][0-9]*/,numberAsText:/^(one|two|three)/i,every:/^every/i,"day(s)":/^days?/i,"weekday(s)":/^weekdays?/i,"week(s)":/^weeks?/i,"hour(s)":/^hours?/i,"minute(s)":/^minutes?/i,"month(s)":/^months?/i,"year(s)":/^years?/i,on:/^(on|in)/i,at:/^(at)/i,the:/^the/i,first:/^first/i,second:/^second/i,third:/^third/i,nth:/^([1-9][0-9]*)(\.|th|nd|rd|st)/i,last:/^last/i,for:/^for/i,"time(s)":/^times?/i,until:/^(un)?til/i,monday:/^mo(n(day)?)?/i,tuesday:/^tu(e(s(day)?)?)?/i,wednesday:/^we(d(n(esday)?)?)?/i,thursday:/^th(u(r(sday)?)?)?/i,friday:/^fr(i(day)?)?/i,saturday:/^sa(t(urday)?)?/i,sunday:/^su(n(day)?)?/i,january:/^jan(uary)?/i,february:/^feb(ruary)?/i,march:/^mar(ch)?/i,april:/^apr(il)?/i,may:/^may/i,june:/^june?/i,july:/^july?/i,august:/^aug(ust)?/i,september:/^sep(t(ember)?)?/i,october:/^oct(ober)?/i,november:/^nov(ember)?/i,december:/^dec(ember)?/i,comma:/^(,\s*|(and|or)\s*)+/i}},re=ta,dr=function(e,t){return e.indexOf(t)!==-1},ea=function(e){return e.toString()},ra=function(e,t,r){return"".concat(t," ").concat(r,", ").concat(e)},na=function(){function e(t,r,n,i){if(r===void 0&&(r=ea),n===void 0&&(n=re),i===void 0&&(i=ra),this.text=[],this.language=n||re,this.gettext=r,this.dateFormatter=i,this.rrule=t,this.options=t.options,this.origOptions=t.origOptions,this.origOptions.bymonthday){var a=[].concat(this.options.bymonthday),o=[].concat(this.options.bynmonthday);a.sort(function(c,d){return c-d}),o.sort(function(c,d){return d-c}),this.bymonthday=a.concat(o),this.bymonthday.length||(this.bymonthday=null)}if(P(this.origOptions.byweekday)){var s=K(this.origOptions.byweekday)?this.origOptions.byweekday:[this.origOptions.byweekday],u=String(s);this.byweekday={allWeeks:s.filter(function(c){return!c.n}),someWeeks:s.filter(function(c){return!!c.n}),isWeekdays:u.indexOf("MO")!==-1&&u.indexOf("TU")!==-1&&u.indexOf("WE")!==-1&&u.indexOf("TH")!==-1&&u.indexOf("FR")!==-1&&u.indexOf("SA")===-1&&u.indexOf("SU")===-1,isEveryDay:u.indexOf("MO")!==-1&&u.indexOf("TU")!==-1&&u.indexOf("WE")!==-1&&u.indexOf("TH")!==-1&&u.indexOf("FR")!==-1&&u.indexOf("SA")!==-1&&u.indexOf("SU")!==-1};var l=function(c,d){return c.weekday-d.weekday};this.byweekday.allWeeks.sort(l),this.byweekday.someWeeks.sort(l),this.byweekday.allWeeks.length||(this.byweekday.allWeeks=null),this.byweekday.someWeeks.length||(this.byweekday.someWeeks=null)}else this.byweekday=null}return e.isFullyConvertible=function(t){var r=!0;if(!(t.options.freq in e.IMPLEMENTED)||t.origOptions.until&&t.origOptions.count)return!1;for(var n in t.origOptions){if(dr(["dtstart","tzid","wkst","freq"],n))return!0;if(!dr(e.IMPLEMENTED[t.options.freq],n))return!1}return r},e.prototype.isFullyConvertible=function(){return e.isFullyConvertible(this.rrule)},e.prototype.toString=function(){var t=this.gettext;if(!(this.options.freq in e.IMPLEMENTED))return t("RRule error: Unable to fully convert this rrule to text");if(this.text=[t("every")],this[v.FREQUENCIES[this.options.freq]](),this.options.until){this.add(t("until"));var r=this.options.until;this.add(this.dateFormatter(r.getUTCFullYear(),this.language.monthNames[r.getUTCMonth()],r.getUTCDate()))}else this.options.count&&this.add(t("for")).add(this.options.count.toString()).add(this.plural(this.options.count)?t("times"):t("time"));return this.isFullyConvertible()||this.add(t("(~ approximate)")),this.text.join("")},e.prototype.HOURLY=function(){var t=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?t("hours"):t("hour"))},e.prototype.MINUTELY=function(){var t=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?t("minutes"):t("minute"))},e.prototype.DAILY=function(){var t=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()),this.byweekday&&this.byweekday.isWeekdays?this.add(this.plural(this.options.interval)?t("weekdays"):t("weekday")):this.add(this.plural(this.options.interval)?t("days"):t("day")),this.origOptions.bymonth&&(this.add(t("in")),this._bymonth()),this.bymonthday?this._bymonthday():this.byweekday?this._byweekday():this.origOptions.byhour&&this._byhour()},e.prototype.WEEKLY=function(){var t=this.gettext;this.options.interval!==1&&this.add(this.options.interval.toString()).add(this.plural(this.options.interval)?t("weeks"):t("week")),this.byweekday&&this.byweekday.isWeekdays?this.options.interval===1?this.add(this.plural(this.options.interval)?t("weekdays"):t("weekday")):this.add(t("on")).add(t("weekdays")):this.byweekday&&this.byweekday.isEveryDay?this.add(this.plural(this.options.interval)?t("days"):t("day")):(this.options.interval===1&&this.add(t("week")),this.origOptions.bymonth&&(this.add(t("in")),this._bymonth()),this.bymonthday?this._bymonthday():this.byweekday&&this._byweekday(),this.origOptions.byhour&&this._byhour())},e.prototype.MONTHLY=function(){var t=this.gettext;this.origOptions.bymonth?(this.options.interval!==1&&(this.add(this.options.interval.toString()).add(t("months")),this.plural(this.options.interval)&&this.add(t("in"))),this._bymonth()):(this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?t("months"):t("month"))),this.bymonthday?this._bymonthday():this.byweekday&&this.byweekday.isWeekdays?this.add(t("on")).add(t("weekdays")):this.byweekday&&this._byweekday()},e.prototype.YEARLY=function(){var t=this.gettext;this.origOptions.bymonth?(this.options.interval!==1&&(this.add(this.options.interval.toString()),this.add(t("years"))),this._bymonth()):(this.options.interval!==1&&this.add(this.options.interval.toString()),this.add(this.plural(this.options.interval)?t("years"):t("year"))),this.bymonthday?this._bymonthday():this.byweekday&&this._byweekday(),this.options.byyearday&&this.add(t("on the")).add(this.list(this.options.byyearday,this.nth,t("and"))).add(t("day")),this.options.byweekno&&this.add(t("in")).add(this.plural(this.options.byweekno.length)?t("weeks"):t("week")).add(this.list(this.options.byweekno,void 0,t("and")))},e.prototype._bymonthday=function(){var t=this.gettext;this.byweekday&&this.byweekday.allWeeks?this.add(t("on")).add(this.list(this.byweekday.allWeeks,this.weekdaytext,t("or"))).add(t("the")).add(this.list(this.bymonthday,this.nth,t("or"))):this.add(t("on the")).add(this.list(this.bymonthday,this.nth,t("and")))},e.prototype._byweekday=function(){var t=this.gettext;this.byweekday.allWeeks&&!this.byweekday.isWeekdays&&this.add(t("on")).add(this.list(this.byweekday.allWeeks,this.weekdaytext)),this.byweekday.someWeeks&&(this.byweekday.allWeeks&&this.add(t("and")),this.add(t("on the")).add(this.list(this.byweekday.someWeeks,this.weekdaytext,t("and"))))},e.prototype._byhour=function(){var t=this.gettext;this.add(t("at")).add(this.list(this.origOptions.byhour,void 0,t("and")))},e.prototype._bymonth=function(){this.add(this.list(this.options.bymonth,this.monthtext,this.gettext("and")))},e.prototype.nth=function(t){t=parseInt(t.toString(),10);var r,n=this.gettext;if(t===-1)return n("last");var i=Math.abs(t);switch(i){case 1:case 21:case 31:r=i+n("st");break;case 2:case 22:r=i+n("nd");break;case 3:case 23:r=i+n("rd");break;default:r=i+n("th")}return t<0?r+" "+n("last"):r},e.prototype.monthtext=function(t){return this.language.monthNames[t-1]},e.prototype.weekdaytext=function(t){var r=rt(t)?(t+1)%7:t.getJsWeekday();return(t.n?this.nth(t.n)+" ":"")+this.language.dayNames[r]},e.prototype.plural=function(t){return t%100!==1},e.prototype.add=function(t){return this.text.push(" "),this.text.push(t),this},e.prototype.list=function(t,r,n,i){var a=this;i===void 0&&(i=","),K(t)||(t=[t]);var o=function(u,l,c){for(var d="",h=0;h<u.length;h++)h!==0&&(h===u.length-1?d+=" "+c+" ":d+=l+" "),d+=u[h];return d};r=r||function(u){return u.toString()};var s=function(u){return r&&r.call(a,u)};return n?o(t.map(s),i,n):t.map(s).join(i+" ")},e}(),lt=na,ia=function(){function e(t){this.done=!0,this.rules=t}return e.prototype.start=function(t){return this.text=t,this.done=!1,this.nextSymbol()},e.prototype.isDone=function(){return this.done&&this.symbol===null},e.prototype.nextSymbol=function(){var t,r;this.symbol=null,this.value=null;do{if(this.done)return!1;var n=void 0;t=null;for(var i in this.rules){n=this.rules[i];var a=n.exec(this.text);a&&(t===null||a[0].length>t[0].length)&&(t=a,r=i)}if(t!=null&&(this.text=this.text.substr(t[0].length),this.text===""&&(this.done=!0)),t==null){this.done=!0,this.symbol=null,this.value=null;return}}while(r==="SKIP");return this.symbol=r,this.value=t,!0},e.prototype.accept=function(t){if(this.symbol===t){if(this.value){var r=this.value;return this.nextSymbol(),r}return this.nextSymbol(),!0}return!1},e.prototype.acceptNumber=function(){return this.accept("number")},e.prototype.expect=function(t){if(this.accept(t))return!0;throw new Error("expected "+t+" but found "+this.symbol)},e}();function Cr(e,t){t===void 0&&(t=re);var r={},n=new ia(t.tokens);if(!n.start(e))return null;return i(),r;function i(){n.expect("every");var h=n.acceptNumber();if(h&&(r.interval=parseInt(h[0],10)),n.isDone())throw new Error("Unexpected end");switch(n.symbol){case"day(s)":r.freq=v.DAILY,n.nextSymbol()&&(o(),d());break;case"weekday(s)":r.freq=v.WEEKLY,r.byweekday=[v.MO,v.TU,v.WE,v.TH,v.FR],n.nextSymbol(),o(),d();break;case"week(s)":r.freq=v.WEEKLY,n.nextSymbol()&&(a(),o(),d());break;case"hour(s)":r.freq=v.HOURLY,n.nextSymbol()&&(a(),d());break;case"minute(s)":r.freq=v.MINUTELY,n.nextSymbol()&&(a(),d());break;case"month(s)":r.freq=v.MONTHLY,n.nextSymbol()&&(a(),d());break;case"year(s)":r.freq=v.YEARLY,n.nextSymbol()&&(a(),d());break;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":r.freq=v.WEEKLY;var f=n.symbol.substr(0,2).toUpperCase();if(r.byweekday=[v[f]],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var y=u();if(!y)throw new Error("Unexpected symbol "+n.symbol+", expected weekday");r.byweekday.push(v[y]),n.nextSymbol()}o(),c(),d();break;case"january":case"february":case"march":case"april":case"may":case"june":case"july":case"august":case"september":case"october":case"november":case"december":if(r.freq=v.YEARLY,r.bymonth=[s()],!n.nextSymbol())return;for(;n.accept("comma");){if(n.isDone())throw new Error("Unexpected end");var p=s();if(!p)throw new Error("Unexpected symbol "+n.symbol+", expected month");r.bymonth.push(p),n.nextSymbol()}a(),d();break;default:throw new Error("Unknown symbol")}}function a(){var h=n.accept("on"),f=n.accept("the");if(h||f)do{var y=l(),p=u(),b=s();if(y)p?(n.nextSymbol(),r.byweekday||(r.byweekday=[]),r.byweekday.push(v[p].nth(y))):(r.bymonthday||(r.bymonthday=[]),r.bymonthday.push(y),n.accept("day(s)"));else if(p)n.nextSymbol(),r.byweekday||(r.byweekday=[]),r.byweekday.push(v[p]);else if(n.symbol==="weekday(s)")n.nextSymbol(),r.byweekday||(r.byweekday=[v.MO,v.TU,v.WE,v.TH,v.FR]);else if(n.symbol==="week(s)"){n.nextSymbol();var S=n.acceptNumber();if(!S)throw new Error("Unexpected symbol "+n.symbol+", expected week number");for(r.byweekno=[parseInt(S[0],10)];n.accept("comma");){if(S=n.acceptNumber(),!S)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");r.byweekno.push(parseInt(S[0],10))}}else if(b)n.nextSymbol(),r.bymonth||(r.bymonth=[]),r.bymonth.push(b);else return}while(n.accept("comma")||n.accept("the")||n.accept("on"))}function o(){var h=n.accept("at");if(h)do{var f=n.acceptNumber();if(!f)throw new Error("Unexpected symbol "+n.symbol+", expected hour");for(r.byhour=[parseInt(f[0],10)];n.accept("comma");){if(f=n.acceptNumber(),!f)throw new Error("Unexpected symbol "+n.symbol+"; expected hour");r.byhour.push(parseInt(f[0],10))}}while(n.accept("comma")||n.accept("at"))}function s(){switch(n.symbol){case"january":return 1;case"february":return 2;case"march":return 3;case"april":return 4;case"may":return 5;case"june":return 6;case"july":return 7;case"august":return 8;case"september":return 9;case"october":return 10;case"november":return 11;case"december":return 12;default:return!1}}function u(){switch(n.symbol){case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return n.symbol.substr(0,2).toUpperCase();default:return!1}}function l(){switch(n.symbol){case"last":return n.nextSymbol(),-1;case"first":return n.nextSymbol(),1;case"second":return n.nextSymbol(),n.accept("last")?-2:2;case"third":return n.nextSymbol(),n.accept("last")?-3:3;case"nth":var h=parseInt(n.value[1],10);if(h<-366||h>366)throw new Error("Nth out of range: "+h);return n.nextSymbol(),n.accept("last")?-h:h;default:return!1}}function c(){n.accept("on"),n.accept("the");var h=l();if(h)for(r.bymonthday=[h],n.nextSymbol();n.accept("comma");){if(h=l(),!h)throw new Error("Unexpected symbol "+n.symbol+"; expected monthday");r.bymonthday.push(h),n.nextSymbol()}}function d(){if(n.symbol==="until"){var h=Date.parse(n.text);if(!h)throw new Error("Cannot parse until date:"+n.text);r.until=new Date(h)}else n.accept("for")&&(r.count=parseInt(n.value[0],10),n.expect("number"))}}var D;(function(e){e[e.YEARLY=0]="YEARLY",e[e.MONTHLY=1]="MONTHLY",e[e.WEEKLY=2]="WEEKLY",e[e.DAILY=3]="DAILY",e[e.HOURLY=4]="HOURLY",e[e.MINUTELY=5]="MINUTELY",e[e.SECONDLY=6]="SECONDLY"})(D||(D={}));function ke(e){return e<D.HOURLY}var aa=function(e,t){return t===void 0&&(t=re),new v(Cr(e,t)||void 0)},kt=["count","until","interval","byweekday","bymonthday","bymonth"];lt.IMPLEMENTED=[];lt.IMPLEMENTED[D.HOURLY]=kt;lt.IMPLEMENTED[D.MINUTELY]=kt;lt.IMPLEMENTED[D.DAILY]=["byhour"].concat(kt);lt.IMPLEMENTED[D.WEEKLY]=kt;lt.IMPLEMENTED[D.MONTHLY]=kt;lt.IMPLEMENTED[D.YEARLY]=["byweekno","byyearday"].concat(kt);var oa=function(e,t,r,n){return new lt(e,t,r,n).toString()},sa=lt.isFullyConvertible,ne=function(){function e(t,r,n,i){this.hour=t,this.minute=r,this.second=n,this.millisecond=i||0}return e.prototype.getHours=function(){return this.hour},e.prototype.getMinutes=function(){return this.minute},e.prototype.getSeconds=function(){return this.second},e.prototype.getMilliseconds=function(){return this.millisecond},e.prototype.getTime=function(){return(this.hour*60*60+this.minute*60+this.second)*1e3+this.millisecond},e}(),ua=function(e){At(t,e);function t(r,n,i,a,o,s,u){var l=e.call(this,a,o,s,u)||this;return l.year=r,l.month=n,l.day=i,l}return t.fromDate=function(r){return new this(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.valueOf()%1e3)},t.prototype.getWeekday=function(){return Yt(new Date(this.getTime()))},t.prototype.getTime=function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond)).getTime()},t.prototype.getDay=function(){return this.day},t.prototype.getMonth=function(){return this.month},t.prototype.getYear=function(){return this.year},t.prototype.addYears=function(r){this.year+=r},t.prototype.addMonths=function(r){if(this.month+=r,this.month>12){var n=Math.floor(this.month/12),i=G(this.month,12);this.month=i,this.year+=n,this.month===0&&(this.month=12,--this.year)}},t.prototype.addWeekly=function(r,n){n>this.getWeekday()?this.day+=-(this.getWeekday()+1+(6-n))+r*7:this.day+=-(this.getWeekday()-n)+r*7,this.fixDay()},t.prototype.addDaily=function(r){this.day+=r,this.fixDay()},t.prototype.addHours=function(r,n,i){for(n&&(this.hour+=Math.floor((23-this.hour)/r)*r);;){this.hour+=r;var a=Se(this.hour,24),o=a.div,s=a.mod;if(o&&(this.hour=s,this.addDaily(o)),nt(i)||O(i,this.hour))break}},t.prototype.addMinutes=function(r,n,i,a){for(n&&(this.minute+=Math.floor((1439-(this.hour*60+this.minute))/r)*r);;){this.minute+=r;var o=Se(this.minute,60),s=o.div,u=o.mod;if(s&&(this.minute=u,this.addHours(s,!1,i)),(nt(i)||O(i,this.hour))&&(nt(a)||O(a,this.minute)))break}},t.prototype.addSeconds=function(r,n,i,a,o){for(n&&(this.second+=Math.floor((86399-(this.hour*3600+this.minute*60+this.second))/r)*r);;){this.second+=r;var s=Se(this.second,60),u=s.div,l=s.mod;if(u&&(this.second=l,this.addMinutes(u,!1,i,a)),(nt(i)||O(i,this.hour))&&(nt(a)||O(a,this.minute))&&(nt(o)||O(o,this.second)))break}},t.prototype.fixDay=function(){if(!(this.day<=28)){var r=sr(this.year,this.month-1)[1];if(!(this.day<=r))for(;this.day>r;){if(this.day-=r,++this.month,this.month===13&&(this.month=1,++this.year,this.year>_r))return;r=sr(this.year,this.month-1)[1]}}},t.prototype.add=function(r,n){var i=r.freq,a=r.interval,o=r.wkst,s=r.byhour,u=r.byminute,l=r.bysecond;switch(i){case D.YEARLY:return this.addYears(a);case D.MONTHLY:return this.addMonths(a);case D.WEEKLY:return this.addWeekly(a,o);case D.DAILY:return this.addDaily(a);case D.HOURLY:return this.addHours(a,n,s);case D.MINUTELY:return this.addMinutes(a,n,s,u);case D.SECONDLY:return this.addSeconds(a,n,s,u,l)}},t}(ne);function Yr(e){for(var t=[],r=Object.keys(e),n=0,i=r;n<i.length;n++){var a=i[n];O(Ba,a)||t.push(a),Ar(e[a])&&!Wt(e[a])&&t.push(a)}if(t.length)throw new Error("Invalid options: "+t.join(", "));return L({},e)}function la(e){var t=L(L({},Pe),Yr(e));if(P(t.byeaster)&&(t.freq=v.YEARLY),!(P(t.freq)&&v.FREQUENCIES[t.freq]))throw new Error("Invalid frequency: ".concat(t.freq," ").concat(e.freq));if(t.dtstart||(t.dtstart=new Date(new Date().setMilliseconds(0))),P(t.wkst)?rt(t.wkst)||(t.wkst=t.wkst.weekday):t.wkst=v.MO.weekday,P(t.bysetpos)){rt(t.bysetpos)&&(t.bysetpos=[t.bysetpos]);for(var r=0;r<t.bysetpos.length;r++){var n=t.bysetpos[r];if(n===0||!(n>=-366&&n<=366))throw new Error("bysetpos must be between 1 and 366, or between -366 and -1")}}if(!(t.byweekno||I(t.byweekno)||I(t.byyearday)||t.bymonthday||I(t.bymonthday)||P(t.byweekday)||P(t.byeaster)))switch(t.freq){case v.YEARLY:t.bymonth||(t.bymonth=t.dtstart.getUTCMonth()+1),t.bymonthday=t.dtstart.getUTCDate();break;case v.MONTHLY:t.bymonthday=t.dtstart.getUTCDate();break;case v.WEEKLY:t.byweekday=[Yt(t.dtstart)];break}if(P(t.bymonth)&&!K(t.bymonth)&&(t.bymonth=[t.bymonth]),P(t.byyearday)&&!K(t.byyearday)&&rt(t.byyearday)&&(t.byyearday=[t.byyearday]),!P(t.bymonthday))t.bymonthday=[],t.bynmonthday=[];else if(K(t.bymonthday)){for(var i=[],a=[],r=0;r<t.bymonthday.length;r++){var n=t.bymonthday[r];n>0?i.push(n):n<0&&a.push(n)}t.bymonthday=i,t.bynmonthday=a}else t.bymonthday<0?(t.bynmonthday=[t.bymonthday],t.bymonthday=[]):(t.bynmonthday=[],t.bymonthday=[t.bymonthday]);if(P(t.byweekno)&&!K(t.byweekno)&&(t.byweekno=[t.byweekno]),!P(t.byweekday))t.bynweekday=null;else if(rt(t.byweekday))t.byweekday=[t.byweekday],t.bynweekday=null;else if(or(t.byweekday))t.byweekday=[W.fromStr(t.byweekday).weekday],t.bynweekday=null;else if(t.byweekday instanceof W)!t.byweekday.n||t.freq>v.MONTHLY?(t.byweekday=[t.byweekday.weekday],t.bynweekday=null):(t.bynweekday=[[t.byweekday.weekday,t.byweekday.n]],t.byweekday=null);else{for(var o=[],s=[],r=0;r<t.byweekday.length;r++){var u=t.byweekday[r];if(rt(u)){o.push(u);continue}else if(or(u)){o.push(W.fromStr(u).weekday);continue}!u.n||t.freq>v.MONTHLY?o.push(u.weekday):s.push([u.weekday,u.n])}t.byweekday=I(o)?o:null,t.bynweekday=I(s)?s:null}return P(t.byhour)?rt(t.byhour)&&(t.byhour=[t.byhour]):t.byhour=t.freq<v.HOURLY?[t.dtstart.getUTCHours()]:null,P(t.byminute)?rt(t.byminute)&&(t.byminute=[t.byminute]):t.byminute=t.freq<v.MINUTELY?[t.dtstart.getUTCMinutes()]:null,P(t.bysecond)?rt(t.bysecond)&&(t.bysecond=[t.bysecond]):t.bysecond=t.freq<v.SECONDLY?[t.dtstart.getUTCSeconds()]:null,{parsedOptions:t}}function ca(e){var t=e.dtstart.getTime()%1e3;if(!ke(e.freq))return[];var r=[];return e.byhour.forEach(function(n){e.byminute.forEach(function(i){e.bysecond.forEach(function(a){r.push(new ne(n,i,a,t))})})}),r}function Ee(e){var t=e.split(`
`).map(da).filter(function(r){return r!==null});return L(L({},t[0]),t[1])}function ie(e){var t={},r=/DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)/i.exec(e);if(!r)return t;var n=r[1],i=r[2];return n&&(t.tzid=n),t.dtstart=Ye(i),t}function da(e){if(e=e.replace(/^\s+|\s+$/,""),!e.length)return null;var t=/^([A-Z]+?)[:;]/.exec(e.toUpperCase());if(!t)return hr(e);var r=t[1];switch(r.toUpperCase()){case"RRULE":case"EXRULE":return hr(e);case"DTSTART":return ie(e);default:throw new Error("Unsupported RFC prop ".concat(r," in ").concat(e))}}function hr(e){var t=e.replace(/^RRULE:/i,""),r=ie(t),n=e.replace(/^(?:RRULE|EXRULE):/i,"").split(";");return n.forEach(function(i){var a=i.split("="),o=a[0],s=a[1];switch(o.toUpperCase()){case"FREQ":r.freq=D[s.toUpperCase()];break;case"WKST":r.wkst=et[s.toUpperCase()];break;case"COUNT":case"INTERVAL":case"BYSETPOS":case"BYMONTH":case"BYMONTHDAY":case"BYYEARDAY":case"BYWEEKNO":case"BYHOUR":case"BYMINUTE":case"BYSECOND":var u=ha(s),l=o.toLowerCase();r[l]=u;break;case"BYWEEKDAY":case"BYDAY":r.byweekday=fa(s);break;case"DTSTART":case"TZID":var c=ie(e);r.tzid=c.tzid,r.dtstart=c.dtstart;break;case"UNTIL":r.until=Ye(s);break;case"BYEASTER":r.byeaster=Number(s);break;default:throw new Error("Unknown RRULE property '"+o+"'")}}),r}function ha(e){if(e.indexOf(",")!==-1){var t=e.split(",");return t.map(fr)}return fr(e)}function fr(e){return/^[+-]?\d+$/.test(e)?Number(e):e}function fa(e){var t=e.split(",");return t.map(function(r){if(r.length===2)return et[r];var n=r.match(/^([+-]?\d{1,2})([A-Z]{2})$/);if(!n||n.length<3)throw new SyntaxError("Invalid weekday string: ".concat(r));var i=Number(n[1]),a=n[2],o=et[a].weekday;return new W(o,i)})}var ae=function(){function e(t,r){if(isNaN(t.getTime()))throw new RangeError("Invalid date passed to DateWithZone");this.date=t,this.tzid=r}return Object.defineProperty(e.prototype,"isUTC",{get:function(){return!this.tzid||this.tzid.toUpperCase()==="UTC"},enumerable:!1,configurable:!0}),e.prototype.toString=function(){var t=Ce(this.date.getTime(),this.isUTC);return this.isUTC?":".concat(t):";TZID=".concat(this.tzid,":").concat(t)},e.prototype.getTime=function(){return this.date.getTime()},e.prototype.rezonedDate=function(){return this.isUTC?this.date:Ji(this.date,this.tzid)},e}();function Oe(e){for(var t=[],r="",n=Object.keys(e),i=Object.keys(Pe),a=0;a<n.length;a++)if(n[a]!=="tzid"&&O(i,n[a])){var o=n[a].toUpperCase(),s=e[n[a]],u="";if(!(!P(s)||K(s)&&!s.length)){switch(o){case"FREQ":u=v.FREQUENCIES[e.freq];break;case"WKST":rt(s)?u=new W(s).toString():u=s.toString();break;case"BYWEEKDAY":o="BYDAY",u=Vi(s).map(function(f){return f instanceof W?f:K(f)?new W(f[0],f[1]):new W(f)}).toString();break;case"DTSTART":r=ya(s,e.tzid);break;case"UNTIL":u=Ce(s,!e.tzid);break;default:if(K(s)){for(var l=[],c=0;c<s.length;c++)l[c]=String(s[c]);u=l.toString()}else u=String(s)}u&&t.push([o,u])}}var d=t.map(function(f){var y=f[0],p=f[1];return"".concat(y,"=").concat(p.toString())}).join(";"),h="";return d!==""&&(h="RRULE:".concat(d)),[r,h].filter(function(f){return!!f}).join(`
`)}function ya(e,t){return e?"DTSTART"+new ae(new Date(e),t).toString():""}function ma(e,t){return Array.isArray(e)?!Array.isArray(t)||e.length!==t.length?!1:e.every(function(r,n){return r.getTime()===t[n].getTime()}):e instanceof Date?t instanceof Date&&e.getTime()===t.getTime():e===t}var pa=function(){function e(){this.all=!1,this.before=[],this.after=[],this.between=[]}return e.prototype._cacheAdd=function(t,r,n){r&&(r=r instanceof Date?Ae(r):ur(r)),t==="all"?this.all=r:(n._value=r,this[t].push(n))},e.prototype._cacheGet=function(t,r){var n=!1,i=r?Object.keys(r):[],a=function(c){for(var d=0;d<i.length;d++){var h=i[d];if(!ma(r[h],c[h]))return!0}return!1},o=this[t];if(t==="all")n=this.all;else if(K(o))for(var s=0;s<o.length;s++){var u=o[s];if(!(i.length&&a(u))){n=u._value;break}}if(!n&&this.all){for(var l=new Ct(t,r),s=0;s<this.all.length&&l.accept(this.all[s]);s++);n=l.getValue(),this._cacheAdd(t,n,r)}return K(n)?ur(n):n instanceof Date?Ae(n):n},e}(),ga=g(g(g(g(g(g(g(g(g(g(g(g(g([],_(1,31),!0),_(2,28),!0),_(3,31),!0),_(4,30),!0),_(5,31),!0),_(6,30),!0),_(7,31),!0),_(8,31),!0),_(9,30),!0),_(10,31),!0),_(11,30),!0),_(12,31),!0),_(1,7),!0),ba=g(g(g(g(g(g(g(g(g(g(g(g(g([],_(1,31),!0),_(2,29),!0),_(3,31),!0),_(4,30),!0),_(5,31),!0),_(6,30),!0),_(7,31),!0),_(8,31),!0),_(9,30),!0),_(10,31),!0),_(11,30),!0),_(12,31),!0),_(1,7),!0),wa=it(1,29),Ta=it(1,30),ft=it(1,31),B=it(1,32),va=g(g(g(g(g(g(g(g(g(g(g(g(g([],B,!0),Ta,!0),B,!0),ft,!0),B,!0),ft,!0),B,!0),B,!0),ft,!0),B,!0),ft,!0),B,!0),B.slice(0,7),!0),Sa=g(g(g(g(g(g(g(g(g(g(g(g(g([],B,!0),wa,!0),B,!0),ft,!0),B,!0),ft,!0),B,!0),B,!0),ft,!0),B,!0),ft,!0),B,!0),B.slice(0,7),!0),xa=it(-28,0),_a=it(-29,0),yt=it(-30,0),j=it(-31,0),Da=g(g(g(g(g(g(g(g(g(g(g(g(g([],j,!0),_a,!0),j,!0),yt,!0),j,!0),yt,!0),j,!0),j,!0),yt,!0),j,!0),yt,!0),j,!0),j.slice(0,7),!0),Aa=g(g(g(g(g(g(g(g(g(g(g(g(g([],j,!0),xa,!0),j,!0),yt,!0),j,!0),yt,!0),j,!0),j,!0),yt,!0),j,!0),yt,!0),j,!0),j.slice(0,7),!0),Ea=[0,31,60,91,121,152,182,213,244,274,305,335,366],Oa=[0,31,59,90,120,151,181,212,243,273,304,334,365],yr=function(){for(var e=[],t=0;t<55;t++)e=e.concat(it(7));return e}();function Ca(e,t){var r=xt(e,1,1),n=Ft(e)?366:365,i=Ft(e+1)?366:365,a=De(r),o=Yt(r),s=L(L({yearlen:n,nextyearlen:i,yearordinal:a,yearweekday:o},Ya(e)),{wnomask:null});if(nt(t.byweekno))return s;s.wnomask=_(0,n+7);var u,l,c=u=G(7-o+t.wkst,7);c>=4?(c=0,l=s.yearlen+G(o-t.wkst,7)):l=n-c;for(var d=Math.floor(l/7),h=G(l,7),f=Math.floor(d+h/4),y=0;y<t.byweekno.length;y++){var p=t.byweekno[y];if(p<0&&(p+=f+1),p>0&&p<=f){var b=void 0;p>1?(b=c+(p-1)*7,c!==u&&(b-=7-u)):b=c;for(var S=0;S<7&&(s.wnomask[b]=1,b++,s.wdaymask[b]!==t.wkst);S++);}}if(O(t.byweekno,1)){var b=c+f*7;if(c!==u&&(b-=7-u),b<n)for(var y=0;y<7&&(s.wnomask[b]=1,b+=1,s.wdaymask[b]!==t.wkst);y++);}if(c){var M=void 0;if(O(t.byweekno,-1))M=-1;else{var J=Yt(xt(e-1,1,1)),at=G(7-J.valueOf()+t.wkst,7),_t=Ft(e-1)?366:365,q=void 0;at>=4?(at=0,q=_t+G(J-t.wkst,7)):q=n-c,M=Math.floor(52+G(q,7)/4)}if(O(t.byweekno,M))for(var b=0;b<c;b++)s.wnomask[b]=1}return s}function Ya(e){var t=Ft(e)?366:365,r=xt(e,1,1),n=Yt(r);return t===365?{mmask:ga,mdaymask:Sa,nmdaymask:Aa,wdaymask:yr.slice(n),mrange:Oa}:{mmask:ba,mdaymask:va,nmdaymask:Da,wdaymask:yr.slice(n),mrange:Ea}}function ka(e,t,r,n,i,a){var o={lastyear:e,lastmonth:t,nwdaymask:[]},s=[];if(a.freq===v.YEARLY)if(nt(a.bymonth))s=[[0,r]];else for(var u=0;u<a.bymonth.length;u++)t=a.bymonth[u],s.push(n.slice(t-1,t+1));else a.freq===v.MONTHLY&&(s=[n.slice(t-1,t+1)]);if(nt(s))return o;o.nwdaymask=_(0,r);for(var u=0;u<s.length;u++)for(var l=s[u],c=l[0],d=l[1]-1,h=0;h<a.bynweekday.length;h++){var f=void 0,y=a.bynweekday[h],p=y[0],b=y[1];b<0?(f=d+(b+1)*7,f-=G(i[f]-p,7)):(f=c+(b-1)*7,f+=G(7-i[f]+p,7)),c<=f&&f<=d&&(o.nwdaymask[f]=1)}return o}function Pa(e,t){t===void 0&&(t=0);var r=e%19,n=Math.floor(e/100),i=e%100,a=Math.floor(n/4),o=n%4,s=Math.floor((n+8)/25),u=Math.floor((n-s+1)/3),l=Math.floor(19*r+n-a-u+15)%30,c=Math.floor(i/4),d=i%4,h=Math.floor(32+2*o+2*c-l-d)%7,f=Math.floor((r+11*l+22*h)/451),y=Math.floor((l+h-7*f+114)/31),p=(l+h-7*f+114)%31+1,b=Date.UTC(e,y-1,p+t),S=Date.UTC(e,0,1);return[Math.ceil((b-S)/(1e3*60*60*24))]}var Ma=function(){function e(t){this.options=t}return e.prototype.rebuild=function(t,r){var n=this.options;if(t!==this.lastyear&&(this.yearinfo=Ca(t,n)),I(n.bynweekday)&&(r!==this.lastmonth||t!==this.lastyear)){var i=this.yearinfo,a=i.yearlen,o=i.mrange,s=i.wdaymask;this.monthinfo=ka(t,r,a,o,s,n)}P(n.byeaster)&&(this.eastermask=Pa(t,n.byeaster))},Object.defineProperty(e.prototype,"lastyear",{get:function(){return this.monthinfo?this.monthinfo.lastyear:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastmonth",{get:function(){return this.monthinfo?this.monthinfo.lastmonth:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"yearlen",{get:function(){return this.yearinfo.yearlen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"yearordinal",{get:function(){return this.yearinfo.yearordinal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mrange",{get:function(){return this.yearinfo.mrange},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wdaymask",{get:function(){return this.yearinfo.wdaymask},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mmask",{get:function(){return this.yearinfo.mmask},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wnomask",{get:function(){return this.yearinfo.wnomask},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nwdaymask",{get:function(){return this.monthinfo?this.monthinfo.nwdaymask:[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextyearlen",{get:function(){return this.yearinfo.nextyearlen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mdaymask",{get:function(){return this.yearinfo.mdaymask},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nmdaymask",{get:function(){return this.yearinfo.nmdaymask},enumerable:!1,configurable:!0}),e.prototype.ydayset=function(){return[it(this.yearlen),0,this.yearlen]},e.prototype.mdayset=function(t,r){for(var n=this.mrange[r-1],i=this.mrange[r],a=_(null,this.yearlen),o=n;o<i;o++)a[o]=o;return[a,n,i]},e.prototype.wdayset=function(t,r,n){for(var i=_(null,this.yearlen+7),a=De(xt(t,r,n))-this.yearordinal,o=a,s=0;s<7&&(i[a]=a,++a,this.wdaymask[a]!==this.options.wkst);s++);return[i,o,a]},e.prototype.ddayset=function(t,r,n){var i=_(null,this.yearlen),a=De(xt(t,r,n))-this.yearordinal;return i[a]=a,[i,a,a+1]},e.prototype.htimeset=function(t,r,n,i){var a=this,o=[];return this.options.byminute.forEach(function(s){o=o.concat(a.mtimeset(t,s,n,i))}),Ht(o),o},e.prototype.mtimeset=function(t,r,n,i){var a=this.options.bysecond.map(function(o){return new ne(t,r,o,i)});return Ht(a),a},e.prototype.stimeset=function(t,r,n,i){return[new ne(t,r,n,i)]},e.prototype.getdayset=function(t){switch(t){case D.YEARLY:return this.ydayset.bind(this);case D.MONTHLY:return this.mdayset.bind(this);case D.WEEKLY:return this.wdayset.bind(this);case D.DAILY:return this.ddayset.bind(this);default:return this.ddayset.bind(this)}},e.prototype.gettimeset=function(t){switch(t){case D.HOURLY:return this.htimeset.bind(this);case D.MINUTELY:return this.mtimeset.bind(this);case D.SECONDLY:return this.stimeset.bind(this)}},e}(),Ua=Ma;function Na(e,t,r,n,i,a){for(var o=[],s=0;s<e.length;s++){var u=void 0,l=void 0,c=e[s];c<0?(u=Math.floor(c/t.length),l=G(c,t.length)):(u=Math.floor((c-1)/t.length),l=G(c-1,t.length));for(var d=[],h=r;h<n;h++){var f=a[h];P(f)&&d.push(f)}var y=void 0;u<0?y=d.slice(u)[0]:y=d[u];var p=t[l],b=Er(i.yearordinal+y),S=Or(b,p);O(o,S)||o.push(S)}return Ht(o),o}function kr(e,t){var r=t.dtstart,n=t.freq,i=t.interval,a=t.until,o=t.bysetpos,s=t.count;if(s===0||i===0)return Ot(e);var u=ua.fromDate(r),l=new Ua(t);l.rebuild(u.year,u.month);for(var c=Ra(l,u,t);;){var d=l.getdayset(n)(u.year,u.month,u.day),h=d[0],f=d[1],y=d[2],p=La(h,f,y,l,t);if(I(o))for(var b=Na(o,c,f,y,l,h),S=0;S<b.length;S++){var M=b[S];if(a&&M>a)return Ot(e);if(M>=r){var J=mr(M,t);if(!e.accept(J)||s&&(--s,!s))return Ot(e)}}else for(var S=f;S<y;S++){var at=h[S];if(P(at))for(var _t=Er(l.yearordinal+at),q=0;q<c.length;q++){var mt=c[q],M=Or(_t,mt);if(a&&M>a)return Ot(e);if(M>=r){var J=mr(M,t);if(!e.accept(J)||s&&(--s,!s))return Ot(e)}}}if(t.interval===0||(u.add(t,p),u.year>_r))return Ot(e);ke(n)||(c=l.gettimeset(n)(u.hour,u.minute,u.second,0)),l.rebuild(u.year,u.month)}}function Ia(e,t,r){var n=r.bymonth,i=r.byweekno,a=r.byweekday,o=r.byeaster,s=r.bymonthday,u=r.bynmonthday,l=r.byyearday;return I(n)&&!O(n,e.mmask[t])||I(i)&&!e.wnomask[t]||I(a)&&!O(a,e.wdaymask[t])||I(e.nwdaymask)&&!e.nwdaymask[t]||o!==null&&!O(e.eastermask,t)||(I(s)||I(u))&&!O(s,e.mdaymask[t])&&!O(u,e.nmdaymask[t])||I(l)&&(t<e.yearlen&&!O(l,t+1)&&!O(l,-e.yearlen+t)||t>=e.yearlen&&!O(l,t+1-e.yearlen)&&!O(l,-e.nextyearlen+t-e.yearlen))}function mr(e,t){return new ae(e,t.tzid).rezonedDate()}function Ot(e){return e.getValue()}function La(e,t,r,n,i){for(var a=!1,o=t;o<r;o++){var s=e[o];a=Ia(n,s,i),a&&(e[s]=null)}return a}function Ra(e,t,r){var n=r.freq,i=r.byhour,a=r.byminute,o=r.bysecond;return ke(n)?ca(r):n>=v.HOURLY&&I(i)&&!O(i,t.hour)||n>=v.MINUTELY&&I(a)&&!O(a,t.minute)||n>=v.SECONDLY&&I(o)&&!O(o,t.second)?[]:e.gettimeset(n)(t.hour,t.minute,t.second,t.millisecond)}var et={MO:new W(0),TU:new W(1),WE:new W(2),TH:new W(3),FR:new W(4),SA:new W(5),SU:new W(6)},Pe={freq:D.YEARLY,dtstart:null,interval:1,wkst:et.MO,count:null,until:null,tzid:null,bysetpos:null,bymonth:null,bymonthday:null,bynmonthday:null,byyearday:null,byweekno:null,byweekday:null,bynweekday:null,byhour:null,byminute:null,bysecond:null,byeaster:null},Ba=Object.keys(Pe),v=function(){function e(t,r){t===void 0&&(t={}),r===void 0&&(r=!1),this._cache=r?null:new pa,this.origOptions=Yr(t);var n=la(t).parsedOptions;this.options=n}return e.parseText=function(t,r){return Cr(t,r)},e.fromText=function(t,r){return aa(t,r)},e.fromString=function(t){return new e(e.parseString(t)||void 0)},e.prototype._iter=function(t){return kr(t,this.options)},e.prototype._cacheGet=function(t,r){return this._cache?this._cache._cacheGet(t,r):!1},e.prototype._cacheAdd=function(t,r,n){if(this._cache)return this._cache._cacheAdd(t,r,n)},e.prototype.all=function(t){if(t)return this._iter(new cr("all",{},t));var r=this._cacheGet("all");return r===!1&&(r=this._iter(new Ct("all",{})),this._cacheAdd("all",r)),r},e.prototype.between=function(t,r,n,i){if(n===void 0&&(n=!1),!Wt(t)||!Wt(r))throw new Error("Invalid date passed in to RRule.between");var a={before:r,after:t,inc:n};if(i)return this._iter(new cr("between",a,i));var o=this._cacheGet("between",a);return o===!1&&(o=this._iter(new Ct("between",a)),this._cacheAdd("between",o,a)),o},e.prototype.before=function(t,r){if(r===void 0&&(r=!1),!Wt(t))throw new Error("Invalid date passed in to RRule.before");var n={dt:t,inc:r},i=this._cacheGet("before",n);return i===!1&&(i=this._iter(new Ct("before",n)),this._cacheAdd("before",i,n)),i},e.prototype.after=function(t,r){if(r===void 0&&(r=!1),!Wt(t))throw new Error("Invalid date passed in to RRule.after");var n={dt:t,inc:r},i=this._cacheGet("after",n);return i===!1&&(i=this._iter(new Ct("after",n)),this._cacheAdd("after",i,n)),i},e.prototype.count=function(){return this.all().length},e.prototype.toString=function(){return Oe(this.origOptions)},e.prototype.toText=function(t,r,n){return oa(this,t,r,n)},e.prototype.isFullyConvertibleToText=function(){return sa(this)},e.prototype.clone=function(){return new e(this.origOptions)},e.FREQUENCIES=["YEARLY","MONTHLY","WEEKLY","DAILY","HOURLY","MINUTELY","SECONDLY"],e.YEARLY=D.YEARLY,e.MONTHLY=D.MONTHLY,e.WEEKLY=D.WEEKLY,e.DAILY=D.DAILY,e.HOURLY=D.HOURLY,e.MINUTELY=D.MINUTELY,e.SECONDLY=D.SECONDLY,e.MO=et.MO,e.TU=et.TU,e.WE=et.WE,e.TH=et.TH,e.FR=et.FR,e.SA=et.SA,e.SU=et.SU,e.parseString=Ee,e.optionsToString=Oe,e}();function ja(e,t,r,n,i,a){var o={},s=e.accept;function u(h,f){r.forEach(function(y){y.between(h,f,!0).forEach(function(p){o[Number(p)]=!0})})}i.forEach(function(h){var f=new ae(h,a).rezonedDate();o[Number(f)]=!0}),e.accept=function(h){var f=Number(h);return isNaN(f)?s.call(this,h):!o[f]&&(u(new Date(f-1),new Date(f+1)),!o[f])?(o[f]=!0,s.call(this,h)):!0},e.method==="between"&&(u(e.args.after,e.args.before),e.accept=function(h){var f=Number(h);return o[f]?!0:(o[f]=!0,s.call(this,h))});for(var l=0;l<n.length;l++){var c=new ae(n[l],a).rezonedDate();if(!e.accept(new Date(c.getTime())))break}t.forEach(function(h){kr(e,h.options)});var d=e._result;switch(Ht(d),e.method){case"all":case"between":return d;case"before":return d.length&&d[d.length-1]||null;case"after":default:return d.length&&d[0]||null}}var pr={dtstart:null,cache:!1,unfold:!1,forceset:!1,compatible:!1,tzid:null};function za(e,t){var r=[],n=[],i=[],a=[],o=ie(e),s=o.dtstart,u=o.tzid,l=Ka(e,t.unfold);return l.forEach(function(c){var d;if(c){var h=Va(c),f=h.name,y=h.parms,p=h.value;switch(f.toUpperCase()){case"RRULE":if(y.length)throw new Error("unsupported RRULE parm: ".concat(y.join(",")));r.push(Ee(c));break;case"RDATE":var b=(d=/RDATE(?:;TZID=([^:=]+))?/i.exec(c))!==null&&d!==void 0?d:[],S=b[1];S&&!u&&(u=S),n=n.concat(br(p,y));break;case"EXRULE":if(y.length)throw new Error("unsupported EXRULE parm: ".concat(y.join(",")));i.push(Ee(p));break;case"EXDATE":a=a.concat(br(p,y));break;case"DTSTART":break;default:throw new Error("unsupported property: "+f)}}}),{dtstart:s,tzid:u,rrulevals:r,rdatevals:n,exrulevals:i,exdatevals:a}}function Wa(e,t){var r=za(e,t),n=r.rrulevals,i=r.rdatevals,a=r.exrulevals,o=r.exdatevals,s=r.dtstart,u=r.tzid,l=t.cache===!1;if(t.compatible&&(t.forceset=!0,t.unfold=!0),t.forceset||n.length>1||i.length||a.length||o.length){var c=new Me(l);return c.dtstart(s),c.tzid(u||void 0),n.forEach(function(h){c.rrule(new v(xe(h,s,u),l))}),i.forEach(function(h){c.rdate(h)}),a.forEach(function(h){c.exrule(new v(xe(h,s,u),l))}),o.forEach(function(h){c.exdate(h)}),t.compatible&&t.dtstart&&c.rdate(s),c}var d=n[0]||{};return new v(xe(d,d.dtstart||t.dtstart||s,d.tzid||t.tzid||u),l)}function gr(e,t){return t===void 0&&(t={}),Wa(e,Fa(t))}function xe(e,t,r){return L(L({},e),{dtstart:t,tzid:r})}function Fa(e){var t=[],r=Object.keys(e),n=Object.keys(pr);if(r.forEach(function(i){O(n,i)||t.push(i)}),t.length)throw new Error("Invalid options: "+t.join(", "));return L(L({},pr),e)}function Ha(e){if(e.indexOf(":")===-1)return{name:"RRULE",value:e};var t=Ki(e,":",1),r=t[0],n=t[1];return{name:r,value:n}}function Va(e){var t=Ha(e),r=t.name,n=t.value,i=r.split(";");if(!i)throw new Error("empty property name");return{name:i[0].toUpperCase(),parms:i.slice(1),value:n}}function Ka(e,t){if(t===void 0&&(t=!1),e=e&&e.trim(),!e)throw new Error("Invalid empty string");if(!t)return e.split(/\s/);for(var r=e.split(`
`),n=0;n<r.length;){var i=r[n]=r[n].replace(/\s+$/g,"");i?n>0&&i[0]===" "?(r[n-1]+=i.slice(1),r.splice(n,1)):n+=1:r.splice(n,1)}return r}function qa(e){e.forEach(function(t){if(!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(t))throw new Error("unsupported RDATE/EXDATE parm: "+t)})}function br(e,t){return qa(t),e.split(",").map(function(r){return Ye(r)})}function wr(e){var t=this;return function(r){if(r!==void 0&&(t["_".concat(e)]=r),t["_".concat(e)]!==void 0)return t["_".concat(e)];for(var n=0;n<t._rrule.length;n++){var i=t._rrule[n].origOptions[e];if(i)return i}}}var Me=function(e){At(t,e);function t(r){r===void 0&&(r=!1);var n=e.call(this,{},r)||this;return n.dtstart=wr.apply(n,["dtstart"]),n.tzid=wr.apply(n,["tzid"]),n._rrule=[],n._rdate=[],n._exrule=[],n._exdate=[],n}return t.prototype._iter=function(r){return ja(r,this._rrule,this._exrule,this._rdate,this._exdate,this.tzid())},t.prototype.rrule=function(r){Tr(r,this._rrule)},t.prototype.exrule=function(r){Tr(r,this._exrule)},t.prototype.rdate=function(r){vr(r,this._rdate)},t.prototype.exdate=function(r){vr(r,this._exdate)},t.prototype.rrules=function(){return this._rrule.map(function(r){return gr(r.toString())})},t.prototype.exrules=function(){return this._exrule.map(function(r){return gr(r.toString())})},t.prototype.rdates=function(){return this._rdate.map(function(r){return new Date(r.getTime())})},t.prototype.exdates=function(){return this._exdate.map(function(r){return new Date(r.getTime())})},t.prototype.valueOf=function(){var r=[];return!this._rrule.length&&this._dtstart&&(r=r.concat(Oe({dtstart:this._dtstart}))),this._rrule.forEach(function(n){r=r.concat(n.toString().split(`
`))}),this._exrule.forEach(function(n){r=r.concat(n.toString().split(`
`).map(function(i){return i.replace(/^RRULE:/,"EXRULE:")}).filter(function(i){return!/^DTSTART/.test(i)}))}),this._rdate.length&&r.push(Sr("RDATE",this._rdate,this.tzid())),this._exdate.length&&r.push(Sr("EXDATE",this._exdate,this.tzid())),r},t.prototype.toString=function(){return this.valueOf().join(`
`)},t.prototype.clone=function(){var r=new t(!!this._cache);return this._rrule.forEach(function(n){return r.rrule(n.clone())}),this._exrule.forEach(function(n){return r.exrule(n.clone())}),this._rdate.forEach(function(n){return r.rdate(new Date(n.getTime()))}),this._exdate.forEach(function(n){return r.exdate(new Date(n.getTime()))}),r},t}(v);function Tr(e,t){if(!(e instanceof v))throw new TypeError(String(e)+" is not RRule instance");O(t.map(String),String(e))||t.push(e)}function vr(e,t){if(!(e instanceof Date))throw new TypeError(String(e)+" is not Date instance");O(t.map(Number),Number(e))||(t.push(e),Ht(t))}function Sr(e,t,r){var n=!r||r.toUpperCase()==="UTC",i=n?"".concat(e,":"):"".concat(e,";TZID=").concat(r,":"),a=t.map(function(o){return Ce(o.valueOf(),n)}).join(",");return"".concat(i).concat(a)}var $a={"Dateline Standard Time":"Etc/GMT+12","UTC-11":"Etc/GMT+11","Hawaiian Standard Time":"Pacific/Honolulu","Alaskan Standard Time":"America/Anchorage","Pacific Standard Time (Mexico)":"America/Santa_Isabel","Pacific Standard Time":"America/Los_Angeles","US Mountain Standard Time":"America/Phoenix","Mountain Standard Time (Mexico)":"America/Chihuahua","Mountain Standard Time":"America/Denver","Central America Standard Time":"America/Guatemala","Central Standard Time":"America/Chicago","Central Standard Time (Mexico)":"America/Mexico_City","Canada Central Standard Time":"America/Regina","SA Pacific Standard Time":"America/Bogota","Eastern Standard Time":"America/New_York","US Eastern Standard Time":"America/Indiana/Indianapolis","Venezuela Standard Time":"America/Caracas","Paraguay Standard Time":"America/Asuncion","Atlantic Standard Time":"America/Halifax","Central Brazilian Standard Time":"America/Cuiaba","SA Western Standard Time":"America/La_Paz","Pacific SA Standard Time":"America/Santiago","Newfoundland Standard Time":"America/St_Johns","E. South America Standard Time":"America/Sao_Paulo","Argentina Standard Time":"America/Buenos_Aires","SA Eastern Standard Time":"America/Cayenne","Greenland Standard Time":"America/Godthab","Montevideo Standard Time":"America/Montevideo","Bahia Standard Time":"America/Bahia","Azores Standard Time":"Atlantic/Azores","Cape Verde Standard Time":"Atlantic/Cape_Verde","Morocco Standard Time":"Africa/Casablanca","GMT Standard Time":"Europe/London","Greenwich Standard Time":"Atlantic/Reykjavik","W. Europe Standard Time":"Europe/Berlin","Central Europe Standard Time":"Europe/Budapest","Romance Standard Time":"Europe/Paris","Central European Standard Time":"Europe/Warsaw","W. Central Africa Standard Time":"Africa/Lagos","Namibia Standard Time":"Africa/Windhoek","Jordan Standard Time":"Asia/Amman","GTB Standard Time":"Europe/Bucharest","Middle East Standard Time":"Asia/Beirut","Egypt Standard Time":"Africa/Cairo","Syria Standard Time":"Asia/Damascus","E. Europe Standard Time":"Europe/Chisinau","South Africa Standard Time":"Africa/Johannesburg","FLE Standard Time":"Europe/Kiev","Turkey Standard Time":"Europe/Istanbul","Israel Standard Time":"Asia/Jerusalem","Kaliningrad Standard Time":"Europe/Kaliningrad","Libya Standard Time":"Africa/Tripoli","Arabic Standard Time":"Asia/Baghdad","Arab Standard Time":"Asia/Riyadh","Belarus Standard Time":"Europe/Minsk","Russian Standard Time":"Europe/Moscow","E. Africa Standard Time":"Africa/Nairobi","Iran Standard Time":"Asia/Tehran","Arabian Standard Time":"Asia/Dubai","Azerbaijan Standard Time":"Asia/Baku","Russia Time Zone 3":"Europe/Samara","Mauritius Standard Time":"Indian/Mauritius","Georgian Standard Time":"Asia/Tbilisi","Caucasus Standard Time":"Asia/Yerevan","Afghanistan Standard Time":"Asia/Kabul","West Asia Standard Time":"Asia/Tashkent","Ekaterinburg Standard Time":"Asia/Yekaterinburg","Pakistan Standard Time":"Asia/Karachi","India Standard Time":"Asia/Kolkata","Sri Lanka Standard Time":"Asia/Colombo","Nepal Standard Time":"Asia/Kathmandu","Central Asia Standard Time":"Asia/Almaty","Bangladesh Standard Time":"Asia/Dhaka","N. Central Asia Standard Time":"Asia/Novosibirsk","Myanmar Standard Time":"Asia/Rangoon","SE Asia Standard Time":"Asia/Bangkok","North Asia Standard Time":"Asia/Krasnoyarsk","China Standard Time":"Asia/Shanghai","North Asia East Standard Time":"Asia/Irkutsk","Singapore Standard Time":"Asia/Singapore","W. Australia Standard Time":"Australia/Perth","Taipei Standard Time":"Asia/Taipei","Ulaanbaatar Standard Time":"Asia/Ulaanbaatar","Tokyo Standard Time":"Asia/Tokyo","Korea Standard Time":"Asia/Seoul","Yakutsk Standard Time":"Asia/Yakutsk","Cen. Australia Standard Time":"Australia/Adelaide","AUS Central Standard Time":"Australia/Darwin","E. Australia Standard Time":"Australia/Brisbane","AUS Eastern Standard Time":"Australia/Sydney","West Pacific Standard Time":"Pacific/Port_Moresby","Tasmania Standard Time":"Australia/Hobart","Magadan Standard Time":"Asia/Magadan","Vladivostok Standard Time":"Asia/Vladivostok","Russia Time Zone 10":"Asia/Srednekolymsk","Central Pacific Standard Time":"Pacific/Guadalcanal","Russia Time Zone 11":"Asia/Anadyr","New Zealand Standard Time":"Pacific/Auckland","Fiji Standard Time":"Pacific/Fiji","Tonga Standard Time":"Pacific/Tongatapu","Samoa Standard Time":"Pacific/Apia","Line Islands Standard Time":"Pacific/Kiritimati"};function Pr(e){return!e||e==="UTC"||e==="None"?"UTC":e.includes("/")?e:$a[e]??null}var Mr="0.4.8",Ur="icalendar:lastSync";console.log(`[iCalendar] Plug script executing at top level (Version ${Mr})`);var Za={frequency:"FREQ",until:"UNTIL",count:"COUNT",interval:"INTERVAL",bysecond:"BYSECOND",byminute:"BYMINUTE",byhour:"BYHOUR",byday:"BYDAY",bymonthday:"BYMONTHDAY",byyearday:"BYYEARDAY",byweekno:"BYWEEKNO",bymonth:"BYMONTH",bysetpos:"BYSETPOS",wkst:"WKST",workweekstart:"WKST",freq:"FREQ"};function Ue(e){if(Array.isArray(e))return e.map(t=>Ue(t)).join(",");if(e instanceof Date)return e.toISOString().replace(/[-:]/g,"").split(".")[0]+"Z";if(typeof e=="object"&&e!==null){let t=e.date||e.day||e.value;if(t!==void 0)return Ue(t)}return String(e)}async function Ga(e){let r=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}function Vt(e,t="America/Los_Angeles"){try{let r=e.toLocaleString("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});console.log(`[iCalendar] Converting ${e.toISOString()} to ${t}: ${r}`);let n=r.match(/(\d{2})\/(\d{2})\/(\d{4}),\s*(\d{2}):(\d{2}):(\d{2})/);if(n){let[i,a,o,s,u,l,c]=n;return`${s}-${a}-${o}T${u}:${l}:${c}`}throw new Error("Failed to parse toLocaleString result")}catch(r){console.error(`[iCalendar] Error converting to timezone ${t}:`,r);let n=i=>String(i).padStart(2,"0");return e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())}}function Ne(e){if(e==null)return e;if(e instanceof Date)return e.toISOString();if(typeof e=="object"&&"date"in e&&e.date instanceof Date)return e.date.toISOString();if(typeof e=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e))try{return new Date(e).toISOString()}catch{return e}if(Array.isArray(e))return e.map(t=>Ne(t));if(typeof e=="object"){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Ne(e[r]));return t}return e}async function Ja(){try{let e=await qt.get("icalendar",{sources:[]});console.log("[iCalendar] Raw config retrieved:",JSON.stringify(e));let t=e.sources||[],r=e.syncWindowDays||365,n=e.displayTimezone||"America/Los_Angeles";if(t&&typeof t=="object"&&!Array.isArray(t)){let i=[];for(let a in t)t[a]&&typeof t[a].url=="string"&&i.push(t[a]);t=i}return{sources:t,syncWindowDays:r,displayTimezone:n}}catch(e){return console.error("[iCalendar] Error in getSources:",e),{sources:[],syncWindowDays:365,displayTimezone:"America/Los_Angeles"}}}function Qa(e,t=365,r="America/Los_Angeles",n=new Date){let i=e.rrule||e.recurrenceRule;if(!i)return[e];try{let a=new Me,o="";if(typeof i=="string")o=i.replace(/^RRULE:/i,"");else if(typeof i=="object"&&i!==null)o=Object.entries(i).map(([f,y])=>`${Za[f.toLowerCase()]||f.toUpperCase()}=${Ue(y)}`).join(";");else return console.warn(`[iCalendar] Invalid rrule type (${typeof i}) for event "${e.summary||"Untitled"}". Treating as non-recurring.`),[e];let s=new Date(e.start);if(isNaN(s.getTime()))return console.error(`[iCalendar] Invalid start date for recurrence: ${e.start}`),[e];let u=v.parseString(o);u.dtstart=s,a.rrule(new v(u));for(let f of e.exdate||[])a.exdate(new Date(f));let l=new Date(n.getTime()+t*864e5),c=a.between(s,l,!0),d=e.end?new Date(e.end).getTime()-s.getTime():0;return c.map(f=>{let y=d>0?new Date(f.getTime()+d):null;return{...e,start:f.toISOString(),startLocal:Vt(f,r),end:y?y.toISOString():void 0,endLocal:y?Vt(y,r):void 0,recurrent:!0,rrule:void 0}})}catch(a){return console.error(`[iCalendar] Error expanding recurrence for ${e.summary}:`,a),[e]}}async function Xa(e,t=365,r="America/Los_Angeles"){try{let n=await fetch(e.url);if(!n.ok)return console.error(`[iCalendar] Fetch failed for ${e.name}: ${n.status} ${n.statusText}`),[];let i=await n.text(),a=ht.parse(i),s=new ht.Component(a).getAllSubcomponents("vevent"),u=new Map;for(let c of s){let d=c.getFirstPropertyValue("recurrence-id"),h=c.getFirstPropertyValue("uid");d&&h&&(u.has(h)||u.set(h,new Set),u.get(h).add(d.toJSDate().toISOString()))}let l=[];for(let c of s){let d=new ht.Event(c),h=c.getFirstPropertyValue("status"),f=d.summary||"";if(h?.toUpperCase()==="CANCELLED"||f.toLowerCase().startsWith("canceled:")||f.toLowerCase().startsWith("cancelled:"))continue;let y=c.getAllProperties("attendee"),p=!1;for(let z of y)if(z.getParameter("partstat")?.toUpperCase()==="DECLINED"){p=!0;break}if(p)continue;let b=d.uid,S=d.description,M=d.location,J=c.getFirstPropertyValue("rrule"),at=c.getAllProperties("exdate").map(z=>z.getFirstValue().toJSDate().toISOString());if(b&&u.has(b)&&!c.getFirstPropertyValue("recurrence-id"))for(let z of u.get(b))at.push(z);let _t=d.startDate.toJSDate(),q=d.endDate?d.endDate.toJSDate():null,mt=d.startDate.timezone||"UTC",oe={uid:b,summary:f,name:f||"Untitled Event",description:S,location:M,start:_t.toISOString(),startLocal:Vt(_t,r),end:q?q.toISOString():void 0,endLocal:q?Vt(q,r):void 0,tag:"ical-event",sourceName:e.name,timezone:mt,rrule:J?J.toString():void 0,exdate:at.length>0?at:void 0};mt!=="UTC"&&mt!=="None"&&!Pr(mt)&&(oe.description=`(Warning: Unknown timezone "${mt}") ${oe.description||""}`);let jr=Qa(oe,t,r);for(let z of jr){let Le=`${z.start}${z.uid||""}${z.summary||""}`;z.ref=await Ga(Le);let Kt={start:z.start,startLocal:z.startLocal,end:z.end,endLocal:z.endLocal},Pt=Ne(z);Pt.start=Kt.start,Pt.startLocal=Kt.startLocal,Pt.end=Kt.end,Pt.endLocal=Kt.endLocal,l.push(Pt)}}return l}catch(n){return console.error(`[iCalendar] Error fetching/parsing ${e.name}:`,n.message||n,n.stack||""),[]}}async function Ie(){try{let{sources:e,syncWindowDays:t,displayTimezone:r}=await Ja();if(e.length===0)return;console.log(`[iCalendar] Using display timezone: ${r}`);let n=new Date("2026-02-21T14:00:00.000Z"),i=Vt(n,r);console.log(`[iCalendar] Timezone test: ${n.toISOString()} \u2192 ${i} (should be 06:00 PST)`),await ct.flashNotification("Syncing calendars...","info");let a=[];for(let o of e){let s=await Xa(o,t,r);a.push(...s)}await $t.indexObjects("$icalendar",a),await ct.flashNotification(`Synced ${a.length} events`,"info")}catch(e){console.error("[iCalendar] syncCalendars failed:",e)}}async function Nr(){await Nt.del(Ur),await Ie()}async function Ir(){if(!await ct.confirm("Clear all calendar events?"))return;let e=await It.query({prefix:["ridx","$icalendar"]}),t=[];for(let{key:r}of e)t.push(r),t.push(["idx",...r.slice(2),"$icalendar"]);t.length>0&&await It.batchDel(t),await Nt.del(Ur),await ct.flashNotification("Calendar index cleared","info")}async function Lr(){await ct.flashNotification(`iCalendar Plug ${Mr}`,"info")}var Rr={syncCalendars:Ie,forceSync:Nr,clearCache:Ir,showVersion:Lr},Br={name:"icalendar",version:"0.4.8",author:"sstent",index:"icalendar.ts",requiredPermissions:["fetch"],permissions:["fetch","http"],functions:{syncCalendars:{path:"icalendar.ts:syncCalendars",command:{name:"iCalendar: Sync",priority:-1},events:["editor:init"]},forceSync:{path:"icalendar.ts:forceSync",command:{name:"iCalendar: Force Sync",priority:-1}},clearCache:{path:"icalendar.ts:clearCache",command:{name:"iCalendar: Clear All Events",priority:-1}},showVersion:{path:"icalendar.ts:showVersion",command:{name:"iCalendar: Version",priority:-2}}},assets:{}},ys={manifest:Br,functionMapping:Rr};ze(Rr,Br,self.postMessage);export{ys as plug};
//# sourceMappingURL=icalendar.plug.js.map