ical-generator 8.1.2-develop.8 → 9.0.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,44 +19,40 @@
19
19
 
20
20
  <br />
21
21
 
22
-
23
22
  `ical-generator` is a small but fine library with which you can very easily create a valid iCal calendars, for example
24
23
  to generate subscriptionable calendar feeds.
25
24
 
26
-
27
-
28
25
  ## 📦 Installation
29
26
 
30
- npm install ical-generator
31
-
27
+ npm install ical-generator
32
28
 
33
29
  ## ⚡️ Quick Start
34
30
 
35
31
  ```javascript
36
- import ical, {ICalCalendarMethod} from 'ical-generator';
32
+ import ical, { ICalCalendarMethod } from 'ical-generator';
37
33
  import http from 'node:http';
38
34
 
39
- const calendar = ical({name: 'my first iCal'});
35
+ const calendar = ical({ name: 'my first iCal' });
40
36
 
41
37
  // A method is required for outlook to display event as an invitation
42
38
  calendar.method(ICalCalendarMethod.REQUEST);
43
39
 
44
40
  const startTime = new Date();
45
41
  const endTime = new Date();
46
- endTime.setHours(startTime.getHours()+1);
42
+ endTime.setHours(startTime.getHours() + 1);
47
43
  calendar.createEvent({
48
44
  start: startTime,
49
45
  end: endTime,
50
46
  summary: 'Example Event',
51
47
  description: 'It works ;)',
52
48
  location: 'my room',
53
- url: 'http://sebbo.net/'
49
+ url: 'http://sebbo.net/',
54
50
  });
55
51
 
56
52
  http.createServer((req, res) => {
57
53
  res.writeHead(200, {
58
54
  'Content-Type': 'text/calendar; charset=utf-8',
59
- 'Content-Disposition': 'attachment; filename="calendar.ics"'
55
+ 'Content-Disposition': 'attachment; filename="calendar.ics"',
60
56
  });
61
57
 
62
58
  res.end(calendar.toString());
@@ -64,6 +60,7 @@ http.createServer((req, res) => {
64
60
  console.log('Server running at http://127.0.0.1:3000/');
65
61
  });
66
62
  ```
63
+
67
64
  See the [examples](https://github.com/sebbo2002/ical-generator/tree/develop/examples) folder for more examples.
68
65
 
69
66
  ## 📑 API-Reference
@@ -89,26 +86,23 @@ to use a VTimezone generator. Such a function generates a VTimezone entry and re
89
86
  be used for this:
90
87
 
91
88
  ```typescript
92
- import {ICalCalendar} from 'ical-generator';
93
- import {getVtimezoneComponent} from '@touch4it/ical-timezones';
89
+ import { ICalCalendar } from 'ical-generator';
90
+ import { getVtimezoneComponent } from '@touch4it/ical-timezones';
94
91
 
95
92
  const cal = new ICalCalendar();
96
93
  cal.timezone({
97
94
  name: 'FOO',
98
- generator: getVtimezoneComponent
95
+ generator: getVtimezoneComponent,
99
96
  });
100
97
  cal.createEvent({
101
98
  start: new Date(),
102
- timezone: 'Europe/London'
99
+ timezone: 'Europe/London',
103
100
  });
104
101
  ```
105
102
 
106
103
  If a `moment-timezone` object or Luxon's `setZone` method works, `ical-generator` sets it according to the time zone set
107
104
  in the calendar/event.
108
105
 
109
-
110
-
111
-
112
106
  ## 🚦 Tests
113
107
 
114
108
  ```
@@ -116,19 +110,19 @@ npm test
116
110
  npm run coverage
117
111
  ```
118
112
 
119
-
120
113
  ## 🙋 FAQ
121
114
 
122
115
  ### Where's the changelog?
116
+
123
117
  It's [here](https://github.com/sebbo2002/ical-generator/blob/develop/CHANGELOG.md). If you need the changelog for
124
118
  `ical-generator` 1.x.x and older, you'll find it [here](https://github.com/sebbo2002/ical-generator/blob/25338b8bf98f9afd3c88849e735fa33fa45fb766/CHANGELOG.md).
125
119
 
126
120
  ### I get a `ReferenceError: TextEncoder is not defined` error (in some browsers)
121
+
127
122
  This library uses [`TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder), which
128
123
  is available in node.js ≥ 11.0.0 and [all modern browsers](https://caniuse.com/?search=textencoder).
129
124
  Outdated browsers may not have the necessary API and generate this error when generating the calendar.
130
125
 
131
-
132
126
  ## 🙆🏼‍♂️ Copyright and license
133
127
 
134
128
  Copyright (c) Sebastian Pekarek under the [MIT license](LICENSE).
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var W=Object.create;var S=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var K=(a,t)=>{for(var e in t)S(a,e,{get:t[e],enumerable:!0})},Y=(a,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of X(t))!Q.call(a,i)&&i!==e&&S(a,i,{get:()=>t[i],enumerable:!(n=q(t,i))||n.enumerable});return a};var $=(a,t,e)=>(e=a!=null?W(Z(a)):{},Y(t||!a||!a.__esModule?S(e,"default",{value:a,enumerable:!0}):e,a)),_=a=>Y(S({},"__esModule",{value:!0}),a);var nt={};K(nt,{ICalAlarm:()=>I,ICalAlarmRelatesTo:()=>F,ICalAlarmType:()=>V,ICalAttendee:()=>f,ICalAttendeeRole:()=>O,ICalAttendeeStatus:()=>M,ICalAttendeeType:()=>w,ICalCalendar:()=>D,ICalCalendarMethod:()=>P,ICalCategory:()=>c,ICalEvent:()=>y,ICalEventBusyStatus:()=>z,ICalEventClass:()=>B,ICalEventRepeatingFreq:()=>b,ICalEventStatus:()=>L,ICalEventTransparency:()=>U,ICalWeekday:()=>T,default:()=>at,escape:()=>r,foldLines:()=>R,formatDate:()=>o,formatDateTZ:()=>A});module.exports=_(nt);var b=(u=>(u.SECONDLY="SECONDLY",u.MINUTELY="MINUTELY",u.HOURLY="HOURLY",u.DAILY="DAILY",u.WEEKLY="WEEKLY",u.MONTHLY="MONTHLY",u.YEARLY="YEARLY",u))(b||{}),T=(u=>(u.SU="SU",u.MO="MO",u.TU="TU",u.WE="WE",u.TH="TH",u.FR="FR",u.SA="SA",u))(T||{});function o(a,t,e,n){if(a?.startsWith("/")&&(a=a.substr(1)),typeof t=="string"||t instanceof Date){let i=new Date(t),s=i.getUTCFullYear()+String(i.getUTCMonth()+1).padStart(2,"0")+i.getUTCDate().toString().padStart(2,"0");return a&&(s=i.getFullYear()+String(i.getMonth()+1).padStart(2,"0")+i.getDate().toString().padStart(2,"0")),e?s:a?(s+="T"+i.getHours().toString().padStart(2,"0")+i.getMinutes().toString().padStart(2,"0")+i.getSeconds().toString().padStart(2,"0"),s):(s+="T"+i.getUTCHours().toString().padStart(2,"0")+i.getUTCMinutes().toString().padStart(2,"0")+i.getUTCSeconds().toString().padStart(2,"0")+(n?"":"Z"),s)}else if(x(t)){let i=a?j(t)&&!t.tz()?t.clone().tz(a):t:n||e&&j(t)&&t.tz()?t:t.utc();return i.format("YYYYMMDD")+(e?"":"T"+i.format("HHmmss")+(n||a?"":"Z"))}else if(v(t)){let i=a?t.setZone(a):n||e&&t.zone.type!=="system"?t:t.setZone("utc");return i.toFormat("yyyyLLdd")+(e?"":"T"+i.toFormat("HHmmss")+(n||a?"":"Z"))}else{let i=t;if(a)i=typeof t.tz=="function"?t.tz(a):t;else if(!n)if(typeof t.utc=="function")i=t.utc();else throw new Error("Unable to convert dayjs object to UTC value: UTC plugin is not available!");return i.format("YYYYMMDD")+(e?"":"T"+i.format("HHmmss")+(n||a?"":"Z"))}}function A(a,t,e,n){let i="",s=n?.floating||!1;return n?.timezone&&(i=";TZID="+n.timezone,s=!0),t+i+":"+o(a,e,!1,s)}function r(a,t){return String(a).replace(t?/[\\"]/g:/[\\;,]/g,function(e){return"\\"+e}).replace(/(?:\r\n|\r|\n)/g,"\\n")}function R(a){return a.split(`\r
1
+ "use strict";var W=Object.create;var S=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var K=(a,t)=>{for(var e in t)S(a,e,{get:t[e],enumerable:!0})},Y=(a,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of X(t))!Q.call(a,i)&&i!==e&&S(a,i,{get:()=>t[i],enumerable:!(n=q(t,i))||n.enumerable});return a};var $=(a,t,e)=>(e=a!=null?W(Z(a)):{},Y(t||!a||!a.__esModule?S(e,"default",{value:a,enumerable:!0}):e,a)),_=a=>Y(S({},"__esModule",{value:!0}),a);var nt={};K(nt,{ICalAlarm:()=>I,ICalAlarmRelatesTo:()=>F,ICalAlarmType:()=>V,ICalAttendee:()=>f,ICalAttendeeRole:()=>O,ICalAttendeeStatus:()=>M,ICalAttendeeType:()=>w,ICalCalendar:()=>D,ICalCalendarMethod:()=>P,ICalCategory:()=>c,ICalEvent:()=>y,ICalEventBusyStatus:()=>L,ICalEventClass:()=>z,ICalEventRepeatingFreq:()=>b,ICalEventStatus:()=>U,ICalEventTransparency:()=>B,ICalWeekday:()=>T,default:()=>at,escape:()=>r,foldLines:()=>R,formatDate:()=>o,formatDateTZ:()=>A});module.exports=_(nt);var H=$(require("uuid-random"),1);var b=(u=>(u.DAILY="DAILY",u.HOURLY="HOURLY",u.MINUTELY="MINUTELY",u.MONTHLY="MONTHLY",u.SECONDLY="SECONDLY",u.WEEKLY="WEEKLY",u.YEARLY="YEARLY",u))(b||{}),T=(u=>(u.FR="FR",u.MO="MO",u.SA="SA",u.SU="SU",u.TH="TH",u.TU="TU",u.WE="WE",u))(T||{});function l(a,t,e){if(Array.isArray(t))a.x=t.map(n=>{if(Array.isArray(n))return n;if(typeof n.key!="string"||typeof n.value!="string")throw new Error("Either key or value is not a string!");if(n.key.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");return[n.key,n.value]});else if(typeof t=="object")a.x=Object.entries(t).map(([n,i])=>{if(typeof n!="string"||typeof i!="string")throw new Error("Either key or value is not a string!");if(n.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");return[n,i]});else if(typeof t=="string"&&typeof e=="string"){if(t.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");a.x.push([t,e])}else return a.x.map(n=>({key:n[0],value:n[1]}))}function h(a,t){if(a instanceof Date&&isNaN(a.getTime())||typeof a=="string"&&isNaN(new Date(a).getTime()))throw new Error(`\`${t}\` has to be a valid date!`);if(a instanceof Date||typeof a=="string"||x(a)&&a.isValid===!0||(v(a)||tt(a))&&a.isValid())return a;throw new Error(`\`${t}\` has to be a valid date!`)}function d(a,t){let e=Object.values(a),n=String(t).toUpperCase();if(!n||!e.includes(n))throw new Error(`Input must be one of the following: ${e.join(", ")}`);return n}function p(a,t){let e=null;if(typeof t=="string"){let n=t.match(/^(.+) ?<([^>]+)>$/);n?e={email:n[2].trim(),name:n[1].trim()}:t.includes("@")&&(e={email:t.trim(),name:t.trim()})}else typeof t=="object"&&(e={email:t.email,mailto:t.mailto,name:t.name,sentBy:t.sentBy});if(!e&&typeof t=="string")throw new Error("`"+a+"` isn't formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!e)throw new Error("`"+a+"` needs to be a valid formed string or an object. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!e.name)throw new Error("`"+a+".name` is empty!");return e}function r(a,t){return String(a).replace(t?/[\\"]/g:/[\\;,]/g,function(e){return"\\"+e}).replace(/(?:\r\n|\r|\n)/g,"\\n")}function R(a){return a.split(`\r
2
2
  `).map(function(t){let e="",n=0;for(let i=0;i<t.length;i++){let s=t.charAt(i);s>="\uD800"&&s<="\uDBFF"&&(s+=t.charAt(++i));let J=new TextEncoder().encode(s).length;n+=J,n>74&&(e+=`\r
3
3
  `,n=J),e+=s}return e}).join(`\r
4
- `)}function l(a,t,e){if(Array.isArray(t))a.x=t.map(n=>{if(Array.isArray(n))return n;if(typeof n.key!="string"||typeof n.value!="string")throw new Error("Either key or value is not a string!");if(n.key.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");return[n.key,n.value]});else if(typeof t=="object")a.x=Object.entries(t).map(([n,i])=>{if(typeof n!="string"||typeof i!="string")throw new Error("Either key or value is not a string!");if(n.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");return[n,i]});else if(typeof t=="string"&&typeof e=="string"){if(t.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");a.x.push([t,e])}else return a.x.map(n=>({key:n[0],value:n[1]}))}function E(a){let t=a.x.map(([e,n])=>e.toUpperCase()+":"+r(n,!1)).join(`\r
4
+ `)}function o(a,t,e,n){if(a?.startsWith("/")&&(a=a.substr(1)),typeof t=="string"||t instanceof Date){let i=new Date(t),s=i.getUTCFullYear()+String(i.getUTCMonth()+1).padStart(2,"0")+i.getUTCDate().toString().padStart(2,"0");return a&&(s=i.getFullYear()+String(i.getMonth()+1).padStart(2,"0")+i.getDate().toString().padStart(2,"0")),e?s:a?(s+="T"+i.getHours().toString().padStart(2,"0")+i.getMinutes().toString().padStart(2,"0")+i.getSeconds().toString().padStart(2,"0"),s):(s+="T"+i.getUTCHours().toString().padStart(2,"0")+i.getUTCMinutes().toString().padStart(2,"0")+i.getUTCSeconds().toString().padStart(2,"0")+(n?"":"Z"),s)}else if(v(t)){let i=a?j(t)&&!t.tz()?t.clone().tz(a):t:n||e&&j(t)&&t.tz()?t:t.utc();return i.format("YYYYMMDD")+(e?"":"T"+i.format("HHmmss")+(n||a?"":"Z"))}else if(x(t)){let i=a?t.setZone(a):n||e&&t.zone.type!=="system"?t:t.setZone("utc");return i.toFormat("yyyyLLdd")+(e?"":"T"+i.toFormat("HHmmss")+(n||a?"":"Z"))}else{let i=t;if(a)i=typeof t.tz=="function"?t.tz(a):t;else if(!n)if(typeof t.utc=="function")i=t.utc();else throw new Error("Unable to convert dayjs object to UTC value: UTC plugin is not available!");return i.format("YYYYMMDD")+(e?"":"T"+i.format("HHmmss")+(n||a?"":"Z"))}}function A(a,t,e,n){let i="",s=n?.floating||!1;return n?.timezone&&(i=";TZID="+n.timezone,s=!0),t+i+":"+o(a,e,!1,s)}function E(a){let t=a.x.map(([e,n])=>e.toUpperCase()+":"+r(n,!1)).join(`\r
5
5
  `);return t.length?t+`\r
6
- `:""}function p(a,t){let e=null;if(typeof t=="string"){let n=t.match(/^(.+) ?<([^>]+)>$/);n?e={name:n[1].trim(),email:n[2].trim()}:t.includes("@")&&(e={name:t.trim(),email:t.trim()})}else typeof t=="object"&&(e={name:t.name,email:t.email,mailto:t.mailto,sentBy:t.sentBy});if(!e&&typeof t=="string")throw new Error("`"+a+"` isn't formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!e)throw new Error("`"+a+"` needs to be a valid formed string or an object. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!e.name)throw new Error("`"+a+".name` is empty!");return e}function d(a,t){let e=Object.values(a),n=String(t).toUpperCase();if(!n||!e.includes(n))throw new Error(`Input must be one of the following: ${e.join(", ")}`);return n}function h(a,t){if(a instanceof Date&&isNaN(a.getTime())||typeof a=="string"&&isNaN(new Date(a).getTime()))throw new Error(`\`${t}\` has to be a valid date!`);if(a instanceof Date||typeof a=="string"||v(a)&&a.isValid===!0||(x(a)||tt(a))&&a.isValid())return a;throw new Error(`\`${t}\` has to be a valid date!`)}function k(a){return typeof a=="string"||a instanceof Date?new Date(a):v(a)?a.toJSDate():a.toDate()}function x(a){return a!=null&&a._isAMomentObject!=null}function j(a){return x(a)&&"tz"in a&&typeof a.tz=="function"}function tt(a){return typeof a=="object"&&a!==null&&!(a instanceof Date)&&!x(a)&&!v(a)}function v(a){return typeof a=="object"&&a!==null&&"toJSDate"in a&&typeof a.toJSDate=="function"}function G(a){return a!==null&&typeof a=="object"&&"asSeconds"in a&&typeof a.asSeconds=="function"}function N(a){return a!==null&&typeof a=="object"&&"between"in a&&typeof a.between=="function"&&typeof a.toString=="function"}function g(a){return a?typeof a=="string"?a:a.toJSON():null}function C(a){let t="";return a<0&&(t="-",a*=-1),t+="P",a>=86400&&(t+=Math.floor(a/86400)+"D",a%=86400),!a&&t.length>1||(t+="T",a>=3600&&(t+=Math.floor(a/3600)+"H",a%=3600),a>=60&&(t+=Math.floor(a/60)+"M",a%=60),a>0?t+=a+"S":t.length<=2&&(t+="0S")),t}var H=$(require("uuid-random"),1);var O=(i=>(i.CHAIR="CHAIR",i.REQ="REQ-PARTICIPANT",i.OPT="OPT-PARTICIPANT",i.NON="NON-PARTICIPANT",i))(O||{}),M=(s=>(s.ACCEPTED="ACCEPTED",s.TENTATIVE="TENTATIVE",s.DECLINED="DECLINED",s.DELEGATED="DELEGATED",s.NEEDSACTION="NEEDS-ACTION",s))(M||{}),w=(s=>(s.INDIVIDUAL="INDIVIDUAL",s.GROUP="GROUP",s.RESOURCE="RESOURCE",s.ROOM="ROOM",s.UNKNOWN="UNKNOWN",s))(w||{}),f=class a{data;parent;constructor(t,e){if(this.data={name:null,email:"",mailto:null,sentBy:null,status:null,role:"REQ-PARTICIPANT",rsvp:null,type:null,delegatedTo:null,delegatedFrom:null,x:[]},this.parent=e,!this.parent)throw new Error("`event` option required!");if(!t.email)throw new Error("No value for `email` in ICalAttendee given!");t.name!==void 0&&this.name(t.name),t.email!==void 0&&this.email(t.email),t.mailto!==void 0&&this.mailto(t.mailto),t.sentBy!==void 0&&this.sentBy(t.sentBy),t.status!==void 0&&this.status(t.status),t.role!==void 0&&this.role(t.role),t.rsvp!==void 0&&this.rsvp(t.rsvp),t.type!==void 0&&this.type(t.type),t.delegatedTo!==void 0&&this.delegatedTo(t.delegatedTo),t.delegatedFrom!==void 0&&this.delegatedFrom(t.delegatedFrom),t.delegatesTo&&this.delegatesTo(t.delegatesTo),t.delegatesFrom&&this.delegatesFrom(t.delegatesFrom),t.x!==void 0&&this.x(t.x)}name(t){return t===void 0?this.data.name:(this.data.name=t||null,this)}email(t){return t?(this.data.email=t,this):this.data.email}mailto(t){return t===void 0?this.data.mailto:(this.data.mailto=t||null,this)}sentBy(t){return t?(this.data.sentBy=t,this):this.data.sentBy}role(t){return t===void 0?this.data.role:(this.data.role=d(O,t),this)}rsvp(t){return t===void 0?this.data.rsvp:t===null?(this.data.rsvp=null,this):(this.data.rsvp=!!t,this)}status(t){return t===void 0?this.data.status:t?(this.data.status=d(M,t),this):(this.data.status=null,this)}type(t){return t===void 0?this.data.type:t?(this.data.type=d(w,t),this):(this.data.type=null,this)}delegatedTo(t){return t===void 0?this.data.delegatedTo:t?(typeof t=="string"?this.data.delegatedTo=new a({email:t,...p("delegatedTo",t)},this.parent):t instanceof a?this.data.delegatedTo=t:this.data.delegatedTo=new a(t,this.parent),this.data.status="DELEGATED",this):(this.data.delegatedTo=null,this.data.status==="DELEGATED"&&(this.data.status=null),this)}delegatedFrom(t){return t===void 0?this.data.delegatedFrom:(t?typeof t=="string"?this.data.delegatedFrom=new a({email:t,...p("delegatedFrom",t)},this.parent):t instanceof a?this.data.delegatedFrom=t:this.data.delegatedFrom=new a(t,this.parent):this.data.delegatedFrom=null,this)}delegatesTo(t){let e=t instanceof a?t:this.parent.createAttendee(t);return this.delegatedTo(e),e.delegatedFrom(this),e}delegatesFrom(t){let e=t instanceof a?t:this.parent.createAttendee(t);return this.delegatedFrom(e),e.delegatedTo(this),e}x(t,e){if(t===void 0)return l(this.data);if(typeof t=="string"&&typeof e=="string")l(this.data,t,e);else if(typeof t=="object")l(this.data,t);else throw new Error("Either key or value is not a string!");return this}toJSON(){return Object.assign({},this.data,{delegatedTo:this.data.delegatedTo?.email()||null,delegatedFrom:this.data.delegatedFrom?.email()||null,x:this.x()})}toString(){let t="ATTENDEE";if(!this.data.email)throw new Error("No value for `email` in ICalAttendee given!");return t+=";ROLE="+this.data.role,this.data.type&&(t+=";CUTYPE="+this.data.type),this.data.status&&(t+=";PARTSTAT="+this.data.status),this.data.rsvp!==null&&(t+=";RSVP="+this.data.rsvp.toString().toUpperCase()),this.data.sentBy!==null&&(t+=';SENT-BY="mailto:'+this.data.sentBy+'"'),this.data.delegatedTo&&(t+=';DELEGATED-TO="'+this.data.delegatedTo.email()+'"'),this.data.delegatedFrom&&(t+=';DELEGATED-FROM="'+this.data.delegatedFrom.email()+'"'),this.data.name&&(t+=';CN="'+r(this.data.name,!0)+'"'),this.data.email&&this.data.mailto&&(t+=";EMAIL="+r(this.data.email,!1)),this.data.x.length&&(t+=";"+this.data.x.map(([e,n])=>e.toUpperCase()+"="+r(n,!1)).join(";")),t+=":MAILTO:"+r(this.data.mailto||this.data.email,!1)+`\r
7
- `,t}};var V=(n=>(n.display="display",n.audio="audio",n.email="email",n))(V||{}),F={end:"END",start:"START"},I=class{data;event;constructor(t,e){if(this.data={type:"display",trigger:-600,relatesTo:null,repeat:null,interval:null,attach:null,description:null,summary:null,attendees:[],x:[]},this.event=e,!e)throw new Error("`event` option required!");t.type!==void 0&&this.type(t.type),"trigger"in t&&t.trigger!==void 0&&this.trigger(t.trigger),"triggerBefore"in t&&t.triggerBefore!==void 0&&this.triggerBefore(t.triggerBefore),"triggerAfter"in t&&t.triggerAfter!==void 0&&this.triggerAfter(t.triggerAfter),t.repeat&&this.repeat(t.repeat),t.attach!==void 0&&this.attach(t.attach),t.description!==void 0&&this.description(t.description),t.summary!==void 0&&this.summary(t.summary),t.attendees!==void 0&&this.attendees(t.attendees),t.x!==void 0&&this.x(t.x)}type(t){if(t===void 0)return this.data.type;if(!t||!Object.keys(V).includes(t))throw new Error("`type` is not correct, must be either `display` or `audio`!");return this.data.type=t,this}trigger(t){if(t===void 0&&typeof this.data.trigger=="number")return-1*this.data.trigger;if(t===void 0)return this.data.trigger;if(typeof t=="number"&&isFinite(t))this.data.trigger=-1*t;else{if(!t||typeof t=="number")throw new Error("`trigger` is not correct, must be a finite number or a supported date!");this.data.trigger=h(t,"trigger")}return this}relatesTo(t){if(t===void 0)return this.data.relatesTo;if(!t)return this.data.relatesTo=null,this;if(!Object.values(F).includes(t))throw new Error("`relatesTo` is not correct, must be either `START` or `END`!");return this.data.relatesTo=t,this}triggerAfter(t){return t===void 0?this.data.trigger:this.trigger(typeof t=="number"?-1*t:t)}triggerBefore(t){return t===void 0?this.trigger():this.trigger(t)}repeat(t){if(t===void 0)return this.data.repeat;if(!t)return this.data.repeat=null,this;if(typeof t!="object")throw new Error("`repeat` is not correct, must be an object!");if(typeof t.times!="number"||!isFinite(t.times))throw new Error("`repeat.times` is not correct, must be numeric!");if(typeof t.interval!="number"||!isFinite(t.interval))throw new Error("`repeat.interval` is not correct, must be numeric!");return this.data.repeat=t,this}attach(t){if(t===void 0)return this.data.attach;if(!t)return this.data.attach=null,this;let e=null;if(typeof t=="string")e={uri:t,mime:null};else if(typeof t=="object")e={uri:t.uri,mime:t.mime||null};else throw new Error("`attachment` needs to be a valid formed string or an object. See https://sebbo2002.github.io/ical-generator/develop/reference/classes/ICalAlarm.html#attach");if(!e.uri)throw new Error("`attach.uri` is empty!");return this.data.attach={uri:e.uri,mime:e.mime},this}description(t){return t===void 0?this.data.description:t?(this.data.description=t,this):(this.data.description=null,this)}summary(t){return t===void 0?this.data.summary:t?(this.data.summary=t,this):(this.data.summary=null,this)}createAttendee(t){if(t instanceof f)return this.data.attendees.push(t),t;typeof t=="string"&&(t={email:t,...p("data",t)});let e=new f(t,this);return this.data.attendees.push(e),e}attendees(t){return t?(t.forEach(e=>this.createAttendee(e)),this):this.data.attendees}x(t,e){if(t===void 0)return l(this.data);if(typeof t=="string"&&typeof e=="string")l(this.data,t,e);else if(typeof t=="object")l(this.data,t);else throw new Error("Either key or value is not a string!");return this}toJSON(){let t=this.trigger();return Object.assign({},this.data,{trigger:typeof t=="number"?t:g(t),x:this.x()})}toString(){let t=`BEGIN:VALARM\r
6
+ `:""}function tt(a){return typeof a=="object"&&a!==null&&!(a instanceof Date)&&!v(a)&&!x(a)}function x(a){return typeof a=="object"&&a!==null&&"toJSDate"in a&&typeof a.toJSDate=="function"}function v(a){return a!=null&&a._isAMomentObject!=null}function G(a){return a!==null&&typeof a=="object"&&"asSeconds"in a&&typeof a.asSeconds=="function"}function j(a){return v(a)&&"tz"in a&&typeof a.tz=="function"}function N(a){return a!==null&&typeof a=="object"&&"between"in a&&typeof a.between=="function"&&typeof a.toString=="function"}function k(a){return typeof a=="string"||a instanceof Date?new Date(a):x(a)?a.toJSDate():a.toDate()}function C(a){let t="";return a<0&&(t="-",a*=-1),t+="P",a>=86400&&(t+=Math.floor(a/86400)+"D",a%=86400),!a&&t.length>1||(t+="T",a>=3600&&(t+=Math.floor(a/3600)+"H",a%=3600),a>=60&&(t+=Math.floor(a/60)+"M",a%=60),a>0?t+=a+"S":t.length<=2&&(t+="0S")),t}function g(a){return a?typeof a=="string"?a:a.toJSON():null}var O=(i=>(i.CHAIR="CHAIR",i.NON="NON-PARTICIPANT",i.OPT="OPT-PARTICIPANT",i.REQ="REQ-PARTICIPANT",i))(O||{}),M=(s=>(s.ACCEPTED="ACCEPTED",s.DECLINED="DECLINED",s.DELEGATED="DELEGATED",s.NEEDSACTION="NEEDS-ACTION",s.TENTATIVE="TENTATIVE",s))(M||{}),w=(s=>(s.GROUP="GROUP",s.INDIVIDUAL="INDIVIDUAL",s.RESOURCE="RESOURCE",s.ROOM="ROOM",s.UNKNOWN="UNKNOWN",s))(w||{}),f=class a{data;parent;constructor(t,e){if(this.data={delegatedFrom:null,delegatedTo:null,email:"",mailto:null,name:null,role:"REQ-PARTICIPANT",rsvp:null,sentBy:null,status:null,type:null,x:[]},this.parent=e,!this.parent)throw new Error("`event` option required!");if(!t.email)throw new Error("No value for `email` in ICalAttendee given!");t.name!==void 0&&this.name(t.name),t.email!==void 0&&this.email(t.email),t.mailto!==void 0&&this.mailto(t.mailto),t.sentBy!==void 0&&this.sentBy(t.sentBy),t.status!==void 0&&this.status(t.status),t.role!==void 0&&this.role(t.role),t.rsvp!==void 0&&this.rsvp(t.rsvp),t.type!==void 0&&this.type(t.type),t.delegatedTo!==void 0&&this.delegatedTo(t.delegatedTo),t.delegatedFrom!==void 0&&this.delegatedFrom(t.delegatedFrom),t.delegatesTo&&this.delegatesTo(t.delegatesTo),t.delegatesFrom&&this.delegatesFrom(t.delegatesFrom),t.x!==void 0&&this.x(t.x)}delegatedFrom(t){return t===void 0?this.data.delegatedFrom:(t?typeof t=="string"?this.data.delegatedFrom=new a({email:t,...p("delegatedFrom",t)},this.parent):t instanceof a?this.data.delegatedFrom=t:this.data.delegatedFrom=new a(t,this.parent):this.data.delegatedFrom=null,this)}delegatedTo(t){return t===void 0?this.data.delegatedTo:t?(typeof t=="string"?this.data.delegatedTo=new a({email:t,...p("delegatedTo",t)},this.parent):t instanceof a?this.data.delegatedTo=t:this.data.delegatedTo=new a(t,this.parent),this.data.status="DELEGATED",this):(this.data.delegatedTo=null,this.data.status==="DELEGATED"&&(this.data.status=null),this)}delegatesFrom(t){let e=t instanceof a?t:this.parent.createAttendee(t);return this.delegatedFrom(e),e.delegatedTo(this),e}delegatesTo(t){let e=t instanceof a?t:this.parent.createAttendee(t);return this.delegatedTo(e),e.delegatedFrom(this),e}email(t){return t?(this.data.email=t,this):this.data.email}mailto(t){return t===void 0?this.data.mailto:(this.data.mailto=t||null,this)}name(t){return t===void 0?this.data.name:(this.data.name=t||null,this)}role(t){return t===void 0?this.data.role:(this.data.role=d(O,t),this)}rsvp(t){return t===void 0?this.data.rsvp:t===null?(this.data.rsvp=null,this):(this.data.rsvp=!!t,this)}sentBy(t){return t?(this.data.sentBy=t,this):this.data.sentBy}status(t){return t===void 0?this.data.status:t?(this.data.status=d(M,t),this):(this.data.status=null,this)}toJSON(){return Object.assign({},this.data,{delegatedFrom:this.data.delegatedFrom?.email()||null,delegatedTo:this.data.delegatedTo?.email()||null,x:this.x()})}toString(){let t="ATTENDEE";if(!this.data.email)throw new Error("No value for `email` in ICalAttendee given!");return t+=";ROLE="+this.data.role,this.data.type&&(t+=";CUTYPE="+this.data.type),this.data.status&&(t+=";PARTSTAT="+this.data.status),this.data.rsvp!==null&&(t+=";RSVP="+this.data.rsvp.toString().toUpperCase()),this.data.sentBy!==null&&(t+=';SENT-BY="mailto:'+this.data.sentBy+'"'),this.data.delegatedTo&&(t+=';DELEGATED-TO="'+this.data.delegatedTo.email()+'"'),this.data.delegatedFrom&&(t+=';DELEGATED-FROM="'+this.data.delegatedFrom.email()+'"'),this.data.name&&(t+=';CN="'+r(this.data.name,!0)+'"'),this.data.email&&this.data.mailto&&(t+=";EMAIL="+r(this.data.email,!1)),this.data.x.length&&(t+=";"+this.data.x.map(([e,n])=>e.toUpperCase()+"="+r(n,!1)).join(";")),t+=":MAILTO:"+r(this.data.mailto||this.data.email,!1)+`\r
7
+ `,t}type(t){return t===void 0?this.data.type:t?(this.data.type=d(w,t),this):(this.data.type=null,this)}x(t,e){if(t===void 0)return l(this.data);if(typeof t=="string"&&typeof e=="string")l(this.data,t,e);else if(typeof t=="object")l(this.data,t);else throw new Error("Either key or value is not a string!");return this}};var V=(n=>(n.audio="audio",n.display="display",n.email="email",n))(V||{}),F={end:"END",start:"START"},I=class{data;event;constructor(t,e){if(this.data={attach:null,attendees:[],description:null,interval:null,relatesTo:null,repeat:null,summary:null,trigger:-600,type:"display",x:[]},this.event=e,!e)throw new Error("`event` option required!");t.type!==void 0&&this.type(t.type),"trigger"in t&&t.trigger!==void 0&&this.trigger(t.trigger),"triggerBefore"in t&&t.triggerBefore!==void 0&&this.triggerBefore(t.triggerBefore),"triggerAfter"in t&&t.triggerAfter!==void 0&&this.triggerAfter(t.triggerAfter),t.repeat&&this.repeat(t.repeat),t.attach!==void 0&&this.attach(t.attach),t.description!==void 0&&this.description(t.description),t.summary!==void 0&&this.summary(t.summary),t.attendees!==void 0&&this.attendees(t.attendees),t.x!==void 0&&this.x(t.x)}attach(t){if(t===void 0)return this.data.attach;if(!t)return this.data.attach=null,this;let e=null;if(typeof t=="string")e={mime:null,uri:t};else if(typeof t=="object")e={mime:t.mime||null,uri:t.uri};else throw new Error("`attachment` needs to be a valid formed string or an object. See https://sebbo2002.github.io/ical-generator/develop/reference/classes/ICalAlarm.html#attach");if(!e.uri)throw new Error("`attach.uri` is empty!");return this.data.attach={mime:e.mime,uri:e.uri},this}attendees(t){return t?(t.forEach(e=>this.createAttendee(e)),this):this.data.attendees}createAttendee(t){if(t instanceof f)return this.data.attendees.push(t),t;typeof t=="string"&&(t={email:t,...p("data",t)});let e=new f(t,this);return this.data.attendees.push(e),e}description(t){return t===void 0?this.data.description:t?(this.data.description=t,this):(this.data.description=null,this)}relatesTo(t){if(t===void 0)return this.data.relatesTo;if(!t)return this.data.relatesTo=null,this;if(!Object.values(F).includes(t))throw new Error("`relatesTo` is not correct, must be either `START` or `END`!");return this.data.relatesTo=t,this}repeat(t){if(t===void 0)return this.data.repeat;if(!t)return this.data.repeat=null,this;if(typeof t!="object")throw new Error("`repeat` is not correct, must be an object!");if(typeof t.times!="number"||!isFinite(t.times))throw new Error("`repeat.times` is not correct, must be numeric!");if(typeof t.interval!="number"||!isFinite(t.interval))throw new Error("`repeat.interval` is not correct, must be numeric!");return this.data.repeat=t,this}summary(t){return t===void 0?this.data.summary:t?(this.data.summary=t,this):(this.data.summary=null,this)}toJSON(){let t=this.trigger();return Object.assign({},this.data,{trigger:typeof t=="number"?t:g(t),x:this.x()})}toString(){let t=`BEGIN:VALARM\r
8
8
  `;if(t+="ACTION:"+this.data.type.toUpperCase()+`\r
9
9
  `,typeof this.data.trigger=="number"&&this.data.relatesTo===null?this.data.trigger>0?t+="TRIGGER;RELATED=END:"+C(this.data.trigger)+`\r
10
10
  `:t+="TRIGGER:"+C(this.data.trigger)+`\r
@@ -20,7 +20,7 @@
20
20
  `),this.data.type==="email"&&this.data.summary?t+="SUMMARY:"+r(this.data.summary,!1)+`\r
21
21
  `:this.data.type==="email"&&(t+="SUMMARY:"+r(this.event.summary(),!1)+`\r
22
22
  `),this.data.type==="email"&&this.data.attendees.forEach(e=>{t+=e.toString()}),t+=E(this.data),t+=`END:VALARM\r
23
- `,t}};var c=class{data;constructor(t){if(this.data={name:""},!t.name)throw new Error("No value for `name` in ICalCategory given!");this.name(t.name)}name(t){return t===void 0?this.data.name:(this.data.name=t,this)}toJSON(){return Object.assign({},this.data)}toString(){return r(this.data.name,!1)}};var L=(n=>(n.CONFIRMED="CONFIRMED",n.TENTATIVE="TENTATIVE",n.CANCELLED="CANCELLED",n))(L||{}),z=(i=>(i.FREE="FREE",i.TENTATIVE="TENTATIVE",i.BUSY="BUSY",i.OOF="OOF",i))(z||{}),U=(e=>(e.TRANSPARENT="TRANSPARENT",e.OPAQUE="OPAQUE",e))(U||{}),B=(n=>(n.PUBLIC="PUBLIC",n.PRIVATE="PRIVATE",n.CONFIDENTIAL="CONFIDENTIAL",n))(B||{}),y=class{data;calendar;constructor(t,e){if(this.data={id:(0,H.default)(),sequence:0,start:new Date,end:null,recurrenceId:null,timezone:null,stamp:new Date,allDay:!1,floating:!1,repeating:null,summary:"",location:null,description:null,organizer:null,attendees:[],alarms:[],categories:[],status:null,busystatus:null,priority:null,url:null,attachments:[],transparency:null,created:null,lastModified:null,class:null,x:[]},this.calendar=e,!e)throw new Error("`calendar` option required!");t.id&&this.id(t.id),t.sequence!==void 0&&this.sequence(t.sequence),t.start&&this.start(t.start),t.end!==void 0&&this.end(t.end),t.recurrenceId!==void 0&&this.recurrenceId(t.recurrenceId),t.timezone!==void 0&&this.timezone(t.timezone),t.stamp!==void 0&&this.stamp(t.stamp),t.allDay!==void 0&&this.allDay(t.allDay),t.floating!==void 0&&this.floating(t.floating),t.repeating!==void 0&&this.repeating(t.repeating),t.summary!==void 0&&this.summary(t.summary),t.location!==void 0&&this.location(t.location),t.description!==void 0&&this.description(t.description),t.organizer!==void 0&&this.organizer(t.organizer),t.attendees!==void 0&&this.attendees(t.attendees),t.alarms!==void 0&&this.alarms(t.alarms),t.categories!==void 0&&this.categories(t.categories),t.status!==void 0&&this.status(t.status),t.busystatus!==void 0&&this.busystatus(t.busystatus),t.priority!==void 0&&this.priority(t.priority),t.url!==void 0&&this.url(t.url),t.attachments!==void 0&&this.attachments(t.attachments),t.transparency!==void 0&&this.transparency(t.transparency),t.created!==void 0&&this.created(t.created),t.lastModified!==void 0&&this.lastModified(t.lastModified),t.class!==void 0&&this.class(t.class),t.x!==void 0&&this.x(t.x)}id(t){return t===void 0?this.data.id:(this.data.id=String(t),this)}uid(t){return t===void 0?this.id():this.id(t)}sequence(t){if(t===void 0)return this.data.sequence;let e=parseInt(String(t),10);if(isNaN(e))throw new Error("`sequence` must be a number!");return this.data.sequence=t,this}start(t){return t===void 0?(this.swapStartAndEndIfRequired(),this.data.start):(this.data.start=h(t,"start"),this)}end(t){return t===void 0?(this.swapStartAndEndIfRequired(),this.data.end):t===null?(this.data.end=null,this):(this.data.end=h(t,"end"),this)}swapStartAndEndIfRequired(){if(this.data.start&&this.data.end&&k(this.data.start).getTime()>k(this.data.end).getTime()){let t=this.data.start;this.data.start=this.data.end,this.data.end=t}}recurrenceId(t){return t===void 0?this.data.recurrenceId:t===null?(this.data.recurrenceId=null,this):(this.data.recurrenceId=h(t,"recurrenceId"),this)}timezone(t){return t===void 0&&this.data.timezone!==null?this.data.timezone:t===void 0?this.calendar.timezone():(this.data.timezone=t&&t!=="UTC"?t.toString():null,this.data.timezone&&(this.data.floating=!1),this)}stamp(t){return t===void 0?this.data.stamp:(this.data.stamp=h(t,"stamp"),this)}timestamp(t){return t===void 0?this.stamp():this.stamp(t)}allDay(t){return t===void 0?this.data.allDay:(this.data.allDay=!!t,this)}floating(t){return t===void 0?this.data.floating:(this.data.floating=!!t,this.data.floating&&(this.data.timezone=null),this)}repeating(t){if(t===void 0)return this.data.repeating;if(!t)return this.data.repeating=null,this;if(N(t)||typeof t=="string")return this.data.repeating=t,this;if(this.data.repeating={freq:d(b,t.freq)},t.count){if(!isFinite(t.count))throw new Error("`repeating.count` must be a finite number!");this.data.repeating.count=t.count}if(t.interval){if(!isFinite(t.interval))throw new Error("`repeating.interval` must be a finite number!");this.data.repeating.interval=t.interval}if(t.until!==void 0&&(this.data.repeating.until=h(t.until,"repeating.until")),t.byDay){let e=Array.isArray(t.byDay)?t.byDay:[t.byDay];this.data.repeating.byDay=e.map(n=>d(T,n))}if(t.byMonth){let e=Array.isArray(t.byMonth)?t.byMonth:[t.byMonth];this.data.repeating.byMonth=e.map(n=>{if(typeof n!="number"||n<1||n>12)throw new Error("`repeating.byMonth` contains invalid value `"+n+"`!");return n})}if(t.byMonthDay){let e=Array.isArray(t.byMonthDay)?t.byMonthDay:[t.byMonthDay];this.data.repeating.byMonthDay=e.map(n=>{if(typeof n!="number"||n<-31||n>31||n===0)throw new Error("`repeating.byMonthDay` contains invalid value `"+n+"`!");return n})}if(t.bySetPos){if(!this.data.repeating.byDay)throw"`repeating.bySetPos` must be used along with `repeating.byDay`!";let e=Array.isArray(t.bySetPos)?t.bySetPos:[t.bySetPos];this.data.repeating.bySetPos=e.map(n=>{if(typeof n!="number"||n<-366||n>366||n===0)throw"`repeating.bySetPos` contains invalid value `"+n+"`!";return n})}if(t.exclude){let e=Array.isArray(t.exclude)?t.exclude:[t.exclude];this.data.repeating.exclude=e.map((n,i)=>h(n,`repeating.exclude[${i}]`))}return t.startOfWeek&&(this.data.repeating.startOfWeek=d(T,t.startOfWeek)),this}summary(t){return t===void 0?this.data.summary:(this.data.summary=t?String(t):"",this)}location(t){if(t===void 0)return this.data.location;if(typeof t=="string")return this.data.location={title:t},this;if(t&&("title"in t&&!t.title||t?.geo&&(typeof t.geo.lat!="number"||!isFinite(t.geo.lat)||typeof t.geo.lon!="number"||!isFinite(t.geo.lon))||!("title"in t)&&!t?.geo))throw new Error("`location` isn't formatted correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/classes/ICalEvent.html#location");return this.data.location=t||null,this}description(t){return t===void 0?this.data.description:t===null?(this.data.description=null,this):(typeof t=="string"?this.data.description={plain:t}:this.data.description=t,this)}organizer(t){return t===void 0?this.data.organizer:t===null?(this.data.organizer=null,this):(this.data.organizer=p("organizer",t),this)}createAttendee(t){if(t instanceof f)return this.data.attendees.push(t),t;typeof t=="string"&&(t={email:t,...p("data",t)});let e=new f(t,this);return this.data.attendees.push(e),e}attendees(t){return t?(t.forEach(e=>this.createAttendee(e)),this):this.data.attendees}createAlarm(t){let e=t instanceof I?t:new I(t,this);return this.data.alarms.push(e),e}alarms(t){return t?(t.forEach(e=>this.createAlarm(e)),this):this.data.alarms}createCategory(t){let e=t instanceof c?t:new c(t);return this.data.categories.push(e),e}categories(t){return t?(t.forEach(e=>this.createCategory(e)),this):this.data.categories}status(t){return t===void 0?this.data.status:t===null?(this.data.status=null,this):(this.data.status=d(L,t),this)}busystatus(t){return t===void 0?this.data.busystatus:t===null?(this.data.busystatus=null,this):(this.data.busystatus=d(z,t),this)}priority(t){if(t===void 0)return this.data.priority;if(t===null)return this.data.priority=null,this;if(t<0||t>9)throw new Error("`priority` is invalid, musst be 0 \u2264 priority \u2264 9.");return this.data.priority=Math.round(t),this}url(t){return t===void 0?this.data.url:(this.data.url=t?String(t):null,this)}createAttachment(t){return this.data.attachments.push(t),this}attachments(t){return t?(t.forEach(e=>this.createAttachment(e)),this):this.data.attachments}transparency(t){return t===void 0?this.data.transparency:t?(this.data.transparency=d(U,t),this):(this.data.transparency=null,this)}created(t){return t===void 0?this.data.created:t===null?(this.data.created=null,this):(this.data.created=h(t,"created"),this)}lastModified(t){return t===void 0?this.data.lastModified:t===null?(this.data.lastModified=null,this):(this.data.lastModified=h(t,"lastModified"),this)}class(t){return t===void 0?this.data.class:t===null?(this.data.class=null,this):(this.data.class=d(B,t),this)}x(t,e){return t===void 0?l(this.data):(typeof t=="string"&&typeof e=="string"&&l(this.data,t,e),typeof t=="object"&&l(this.data,t),this)}toJSON(){let t=null;return N(this.data.repeating)||typeof this.data.repeating=="string"?t=this.data.repeating.toString():this.data.repeating&&(t=Object.assign({},this.data.repeating,{until:g(this.data.repeating.until)||void 0,exclude:this.data.repeating.exclude?.map(e=>g(e))})),this.swapStartAndEndIfRequired(),Object.assign({},this.data,{start:g(this.data.start)||null,end:g(this.data.end)||null,recurrenceId:g(this.data.recurrenceId)||null,stamp:g(this.data.stamp)||null,created:g(this.data.created)||null,lastModified:g(this.data.lastModified)||null,repeating:t,x:this.x()})}toString(){let t="";if(t+=`BEGIN:VEVENT\r
23
+ `,t}trigger(t){if(t===void 0&&typeof this.data.trigger=="number")return-1*this.data.trigger;if(t===void 0)return this.data.trigger;if(typeof t=="number"&&isFinite(t))this.data.trigger=-1*t;else{if(!t||typeof t=="number")throw new Error("`trigger` is not correct, must be a finite number or a supported date!");this.data.trigger=h(t,"trigger")}return this}triggerAfter(t){return t===void 0?this.data.trigger:this.trigger(typeof t=="number"?-1*t:t)}triggerBefore(t){return t===void 0?this.trigger():this.trigger(t)}type(t){if(t===void 0)return this.data.type;if(!t||!Object.keys(V).includes(t))throw new Error("`type` is not correct, must be either `display` or `audio`!");return this.data.type=t,this}x(t,e){if(t===void 0)return l(this.data);if(typeof t=="string"&&typeof e=="string")l(this.data,t,e);else if(typeof t=="object")l(this.data,t);else throw new Error("Either key or value is not a string!");return this}};var c=class{data;constructor(t){if(this.data={name:""},!t.name)throw new Error("No value for `name` in ICalCategory given!");this.name(t.name)}name(t){return t===void 0?this.data.name:(this.data.name=t,this)}toJSON(){return Object.assign({},this.data)}toString(){return r(this.data.name,!1)}};var L=(i=>(i.BUSY="BUSY",i.FREE="FREE",i.OOF="OOF",i.TENTATIVE="TENTATIVE",i))(L||{}),z=(n=>(n.CONFIDENTIAL="CONFIDENTIAL",n.PRIVATE="PRIVATE",n.PUBLIC="PUBLIC",n))(z||{}),U=(n=>(n.CANCELLED="CANCELLED",n.CONFIRMED="CONFIRMED",n.TENTATIVE="TENTATIVE",n))(U||{}),B=(e=>(e.OPAQUE="OPAQUE",e.TRANSPARENT="TRANSPARENT",e))(B||{}),y=class{calendar;data;constructor(t,e){if(this.data={alarms:[],allDay:!1,attachments:[],attendees:[],busystatus:null,categories:[],class:null,created:null,description:null,end:null,floating:!1,id:(0,H.default)(),lastModified:null,location:null,organizer:null,priority:null,recurrenceId:null,repeating:null,sequence:0,stamp:new Date,start:new Date,status:null,summary:"",timezone:null,transparency:null,url:null,x:[]},this.calendar=e,!e)throw new Error("`calendar` option required!");t.id&&this.id(t.id),t.sequence!==void 0&&this.sequence(t.sequence),t.start&&this.start(t.start),t.end!==void 0&&this.end(t.end),t.recurrenceId!==void 0&&this.recurrenceId(t.recurrenceId),t.timezone!==void 0&&this.timezone(t.timezone),t.stamp!==void 0&&this.stamp(t.stamp),t.allDay!==void 0&&this.allDay(t.allDay),t.floating!==void 0&&this.floating(t.floating),t.repeating!==void 0&&this.repeating(t.repeating),t.summary!==void 0&&this.summary(t.summary),t.location!==void 0&&this.location(t.location),t.description!==void 0&&this.description(t.description),t.organizer!==void 0&&this.organizer(t.organizer),t.attendees!==void 0&&this.attendees(t.attendees),t.alarms!==void 0&&this.alarms(t.alarms),t.categories!==void 0&&this.categories(t.categories),t.status!==void 0&&this.status(t.status),t.busystatus!==void 0&&this.busystatus(t.busystatus),t.priority!==void 0&&this.priority(t.priority),t.url!==void 0&&this.url(t.url),t.attachments!==void 0&&this.attachments(t.attachments),t.transparency!==void 0&&this.transparency(t.transparency),t.created!==void 0&&this.created(t.created),t.lastModified!==void 0&&this.lastModified(t.lastModified),t.class!==void 0&&this.class(t.class),t.x!==void 0&&this.x(t.x)}alarms(t){return t?(t.forEach(e=>this.createAlarm(e)),this):this.data.alarms}allDay(t){return t===void 0?this.data.allDay:(this.data.allDay=!!t,this)}attachments(t){return t?(t.forEach(e=>this.createAttachment(e)),this):this.data.attachments}attendees(t){return t?(t.forEach(e=>this.createAttendee(e)),this):this.data.attendees}busystatus(t){return t===void 0?this.data.busystatus:t===null?(this.data.busystatus=null,this):(this.data.busystatus=d(L,t),this)}categories(t){return t?(t.forEach(e=>this.createCategory(e)),this):this.data.categories}class(t){return t===void 0?this.data.class:t===null?(this.data.class=null,this):(this.data.class=d(z,t),this)}createAlarm(t){let e=t instanceof I?t:new I(t,this);return this.data.alarms.push(e),e}createAttachment(t){return this.data.attachments.push(t),this}createAttendee(t){if(t instanceof f)return this.data.attendees.push(t),t;typeof t=="string"&&(t={email:t,...p("data",t)});let e=new f(t,this);return this.data.attendees.push(e),e}createCategory(t){let e=t instanceof c?t:new c(t);return this.data.categories.push(e),e}created(t){return t===void 0?this.data.created:t===null?(this.data.created=null,this):(this.data.created=h(t,"created"),this)}description(t){return t===void 0?this.data.description:t===null?(this.data.description=null,this):(typeof t=="string"?this.data.description={plain:t}:this.data.description=t,this)}end(t){return t===void 0?(this.swapStartAndEndIfRequired(),this.data.end):t===null?(this.data.end=null,this):(this.data.end=h(t,"end"),this)}floating(t){return t===void 0?this.data.floating:(this.data.floating=!!t,this.data.floating&&(this.data.timezone=null),this)}id(t){return t===void 0?this.data.id:(this.data.id=String(t),this)}lastModified(t){return t===void 0?this.data.lastModified:t===null?(this.data.lastModified=null,this):(this.data.lastModified=h(t,"lastModified"),this)}location(t){if(t===void 0)return this.data.location;if(typeof t=="string")return this.data.location={title:t},this;if(t&&("title"in t&&!t.title||t?.geo&&(typeof t.geo.lat!="number"||!isFinite(t.geo.lat)||typeof t.geo.lon!="number"||!isFinite(t.geo.lon))||!("title"in t)&&!t?.geo))throw new Error("`location` isn't formatted correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/classes/ICalEvent.html#location");return this.data.location=t||null,this}organizer(t){return t===void 0?this.data.organizer:t===null?(this.data.organizer=null,this):(this.data.organizer=p("organizer",t),this)}priority(t){if(t===void 0)return this.data.priority;if(t===null)return this.data.priority=null,this;if(t<0||t>9)throw new Error("`priority` is invalid, musst be 0 \u2264 priority \u2264 9.");return this.data.priority=Math.round(t),this}recurrenceId(t){return t===void 0?this.data.recurrenceId:t===null?(this.data.recurrenceId=null,this):(this.data.recurrenceId=h(t,"recurrenceId"),this)}repeating(t){if(t===void 0)return this.data.repeating;if(!t)return this.data.repeating=null,this;if(N(t)||typeof t=="string")return this.data.repeating=t,this;if(this.data.repeating={freq:d(b,t.freq)},t.count){if(!isFinite(t.count))throw new Error("`repeating.count` must be a finite number!");this.data.repeating.count=t.count}if(t.interval){if(!isFinite(t.interval))throw new Error("`repeating.interval` must be a finite number!");this.data.repeating.interval=t.interval}if(t.until!==void 0&&(this.data.repeating.until=h(t.until,"repeating.until")),t.byDay){let e=Array.isArray(t.byDay)?t.byDay:[t.byDay];this.data.repeating.byDay=e.map(n=>d(T,n))}if(t.byMonth){let e=Array.isArray(t.byMonth)?t.byMonth:[t.byMonth];this.data.repeating.byMonth=e.map(n=>{if(typeof n!="number"||n<1||n>12)throw new Error("`repeating.byMonth` contains invalid value `"+n+"`!");return n})}if(t.byMonthDay){let e=Array.isArray(t.byMonthDay)?t.byMonthDay:[t.byMonthDay];this.data.repeating.byMonthDay=e.map(n=>{if(typeof n!="number"||n<-31||n>31||n===0)throw new Error("`repeating.byMonthDay` contains invalid value `"+n+"`!");return n})}if(t.bySetPos){if(!this.data.repeating.byDay)throw"`repeating.bySetPos` must be used along with `repeating.byDay`!";let e=Array.isArray(t.bySetPos)?t.bySetPos:[t.bySetPos];this.data.repeating.bySetPos=e.map(n=>{if(typeof n!="number"||n<-366||n>366||n===0)throw"`repeating.bySetPos` contains invalid value `"+n+"`!";return n})}if(t.exclude){let e=Array.isArray(t.exclude)?t.exclude:[t.exclude];this.data.repeating.exclude=e.map((n,i)=>h(n,`repeating.exclude[${i}]`))}return t.startOfWeek&&(this.data.repeating.startOfWeek=d(T,t.startOfWeek)),this}sequence(t){if(t===void 0)return this.data.sequence;let e=parseInt(String(t),10);if(isNaN(e))throw new Error("`sequence` must be a number!");return this.data.sequence=t,this}stamp(t){return t===void 0?this.data.stamp:(this.data.stamp=h(t,"stamp"),this)}start(t){return t===void 0?(this.swapStartAndEndIfRequired(),this.data.start):(this.data.start=h(t,"start"),this)}status(t){return t===void 0?this.data.status:t===null?(this.data.status=null,this):(this.data.status=d(U,t),this)}summary(t){return t===void 0?this.data.summary:(this.data.summary=t?String(t):"",this)}timestamp(t){return t===void 0?this.stamp():this.stamp(t)}timezone(t){return t===void 0&&this.data.timezone!==null?this.data.timezone:t===void 0?this.calendar.timezone():(this.data.timezone=t&&t!=="UTC"?t.toString():null,this.data.timezone&&(this.data.floating=!1),this)}toJSON(){let t=null;return N(this.data.repeating)||typeof this.data.repeating=="string"?t=this.data.repeating.toString():this.data.repeating&&(t=Object.assign({},this.data.repeating,{exclude:this.data.repeating.exclude?.map(e=>g(e)),until:g(this.data.repeating.until)||void 0})),this.swapStartAndEndIfRequired(),Object.assign({},this.data,{created:g(this.data.created)||null,end:g(this.data.end)||null,lastModified:g(this.data.lastModified)||null,recurrenceId:g(this.data.recurrenceId)||null,repeating:t,stamp:g(this.data.stamp)||null,start:g(this.data.start)||null,x:this.x()})}toString(){let t="";if(t+=`BEGIN:VEVENT\r
24
24
  `,t+="UID:"+this.data.id+`\r
25
25
  `,t+="SEQUENCE:"+this.data.sequence+`\r
26
26
  `,this.swapStartAndEndIfRequired(),t+="DTSTAMP:"+o(this.calendar.timezone(),this.data.stamp)+`\r
@@ -59,7 +59,7 @@
59
59
  `),this.data.lastModified&&(t+="LAST-MODIFIED:"+o(this.calendar.timezone(),this.data.lastModified)+`\r
60
60
  `),this.data.class&&(t+="CLASS:"+this.data.class.toUpperCase()+`\r
61
61
  `),t+=`END:VEVENT\r
62
- `,t}};var P=(m=>(m.PUBLISH="PUBLISH",m.REQUEST="REQUEST",m.REPLY="REPLY",m.ADD="ADD",m.CANCEL="CANCEL",m.REFRESH="REFRESH",m.COUNTER="COUNTER",m.DECLINECOUNTER="DECLINECOUNTER",m))(P||{}),D=class{data;constructor(t={}){this.data={prodId:"//sebbo.net//ical-generator//EN",method:null,name:null,description:null,timezone:null,source:null,url:null,scale:null,ttl:null,events:[],x:[]},t.prodId!==void 0&&this.prodId(t.prodId),t.method!==void 0&&this.method(t.method),t.name!==void 0&&this.name(t.name),t.description!==void 0&&this.description(t.description),t.timezone!==void 0&&this.timezone(t.timezone),t.source!==void 0&&this.source(t.source),t.url!==void 0&&this.url(t.url),t.scale!==void 0&&this.scale(t.scale),t.ttl!==void 0&&this.ttl(t.ttl),t.events!==void 0&&this.events(t.events),t.x!==void 0&&this.x(t.x)}prodId(t){if(!t)return this.data.prodId;if(typeof t=="string")return this.data.prodId=t,this;if(typeof t!="object")throw new Error("`prodid` needs to be a string or an object!");if(!t.company)throw new Error("`prodid.company` is a mandatory item!");if(!t.product)throw new Error("`prodid.product` is a mandatory item!");let e=(t.language||"EN").toUpperCase();return this.data.prodId="//"+t.company+"//"+t.product+"//"+e,this}method(t){return t===void 0?this.data.method:t?(this.data.method=d(P,t),this):(this.data.method=null,this)}name(t){return t===void 0?this.data.name:(this.data.name=t?String(t):null,this)}description(t){return t===void 0?this.data.description:(this.data.description=t?String(t):null,this)}timezone(t){return t===void 0?this.data.timezone?.name||null:(t==="UTC"?this.data.timezone=null:typeof t=="string"?this.data.timezone={name:t}:t===null?this.data.timezone=null:this.data.timezone=t,this)}source(t){return t===void 0?this.data.source:(this.data.source=t||null,this)}url(t){return t===void 0?this.data.url:(this.data.url=t||null,this)}scale(t){return t===void 0?this.data.scale:(t===null?this.data.scale=null:this.data.scale=t.toUpperCase(),this)}ttl(t){return t===void 0?this.data.ttl:(G(t)?this.data.ttl=t.asSeconds():t&&t>0?this.data.ttl=t:this.data.ttl=null,this)}createEvent(t){let e=t instanceof y?t:new y(t,this);return this.data.events.push(e),e}events(t){return t?(t.forEach(e=>this.createEvent(e)),this):this.data.events}clear(){return this.data.events=[],this}x(t,e){if(t===void 0)return l(this.data);if(typeof t=="string"&&typeof e=="string")l(this.data,t,e);else if(typeof t=="object")l(this.data,t);else throw new Error("Either key or value is not a string!");return this}toJSON(){return Object.assign({},this.data,{timezone:this.timezone(),events:this.data.events.map(t=>t.toJSON()),x:this.x()})}length(){return this.data.events.length}toString(){let t="";return t=`BEGIN:VCALENDAR\r
62
+ `,t}transparency(t){return t===void 0?this.data.transparency:t?(this.data.transparency=d(B,t),this):(this.data.transparency=null,this)}uid(t){return t===void 0?this.id():this.id(t)}url(t){return t===void 0?this.data.url:(this.data.url=t?String(t):null,this)}x(t,e){return t===void 0?l(this.data):(typeof t=="string"&&typeof e=="string"&&l(this.data,t,e),typeof t=="object"&&l(this.data,t),this)}swapStartAndEndIfRequired(){if(this.data.start&&this.data.end&&k(this.data.start).getTime()>k(this.data.end).getTime()){let t=this.data.start;this.data.start=this.data.end,this.data.end=t}}};var P=(m=>(m.ADD="ADD",m.CANCEL="CANCEL",m.COUNTER="COUNTER",m.DECLINECOUNTER="DECLINECOUNTER",m.PUBLISH="PUBLISH",m.REFRESH="REFRESH",m.REPLY="REPLY",m.REQUEST="REQUEST",m))(P||{}),D=class{data;constructor(t={}){this.data={description:null,events:[],method:null,name:null,prodId:"//sebbo.net//ical-generator//EN",scale:null,source:null,timezone:null,ttl:null,url:null,x:[]},t.prodId!==void 0&&this.prodId(t.prodId),t.method!==void 0&&this.method(t.method),t.name!==void 0&&this.name(t.name),t.description!==void 0&&this.description(t.description),t.timezone!==void 0&&this.timezone(t.timezone),t.source!==void 0&&this.source(t.source),t.url!==void 0&&this.url(t.url),t.scale!==void 0&&this.scale(t.scale),t.ttl!==void 0&&this.ttl(t.ttl),t.events!==void 0&&this.events(t.events),t.x!==void 0&&this.x(t.x)}clear(){return this.data.events=[],this}createEvent(t){let e=t instanceof y?t:new y(t,this);return this.data.events.push(e),e}description(t){return t===void 0?this.data.description:(this.data.description=t?String(t):null,this)}events(t){return t?(t.forEach(e=>this.createEvent(e)),this):this.data.events}length(){return this.data.events.length}method(t){return t===void 0?this.data.method:t?(this.data.method=d(P,t),this):(this.data.method=null,this)}name(t){return t===void 0?this.data.name:(this.data.name=t?String(t):null,this)}prodId(t){if(!t)return this.data.prodId;if(typeof t=="string")return this.data.prodId=t,this;if(typeof t!="object")throw new Error("`prodid` needs to be a string or an object!");if(!t.company)throw new Error("`prodid.company` is a mandatory item!");if(!t.product)throw new Error("`prodid.product` is a mandatory item!");let e=(t.language||"EN").toUpperCase();return this.data.prodId="//"+t.company+"//"+t.product+"//"+e,this}scale(t){return t===void 0?this.data.scale:(t===null?this.data.scale=null:this.data.scale=t.toUpperCase(),this)}source(t){return t===void 0?this.data.source:(this.data.source=t||null,this)}timezone(t){return t===void 0?this.data.timezone?.name||null:(t==="UTC"?this.data.timezone=null:typeof t=="string"?this.data.timezone={name:t}:t===null?this.data.timezone=null:this.data.timezone=t,this)}toJSON(){return Object.assign({},this.data,{events:this.data.events.map(t=>t.toJSON()),timezone:this.timezone(),x:this.x()})}toString(){let t="";return t=`BEGIN:VCALENDAR\r
63
63
  VERSION:2.0\r
64
64
  `,t+="PRODID:-"+this.data.prodId+`\r
65
65
  `,this.data.url&&(t+="URL:"+this.data.url+`\r
@@ -76,5 +76,5 @@ VERSION:2.0\r
76
76
  `,t+="X-WR-TIMEZONE:"+this.data.timezone.name+`\r
77
77
  `),this.data.ttl&&(t+="REFRESH-INTERVAL;VALUE=DURATION:"+C(this.data.ttl)+`\r
78
78
  `,t+="X-PUBLISHED-TTL:"+C(this.data.ttl)+`\r
79
- `),this.data.events.forEach(e=>t+=e.toString()),t+=E(this.data),t+="END:VCALENDAR",R(t)}};function et(a){return new D(a)}var at=et;0&&(module.exports={ICalAlarm,ICalAlarmRelatesTo,ICalAlarmType,ICalAttendee,ICalAttendeeRole,ICalAttendeeStatus,ICalAttendeeType,ICalCalendar,ICalCalendarMethod,ICalCategory,ICalEvent,ICalEventBusyStatus,ICalEventClass,ICalEventRepeatingFreq,ICalEventStatus,ICalEventTransparency,ICalWeekday,escape,foldLines,formatDate,formatDateTZ});
79
+ `),this.data.events.forEach(e=>t+=e.toString()),t+=E(this.data),t+="END:VCALENDAR",R(t)}ttl(t){return t===void 0?this.data.ttl:(G(t)?this.data.ttl=t.asSeconds():t&&t>0?this.data.ttl=t:this.data.ttl=null,this)}url(t){return t===void 0?this.data.url:(this.data.url=t||null,this)}x(t,e){if(t===void 0)return l(this.data);if(typeof t=="string"&&typeof e=="string")l(this.data,t,e);else if(typeof t=="object")l(this.data,t);else throw new Error("Either key or value is not a string!");return this}};function et(a){return new D(a)}var at=et;0&&(module.exports={ICalAlarm,ICalAlarmRelatesTo,ICalAlarmType,ICalAttendee,ICalAttendeeRole,ICalAttendeeStatus,ICalAttendeeType,ICalCalendar,ICalCalendarMethod,ICalCategory,ICalEvent,ICalEventBusyStatus,ICalEventClass,ICalEventRepeatingFreq,ICalEventStatus,ICalEventTransparency,ICalWeekday,escape,foldLines,formatDate,formatDateTZ});
80
80
  //# sourceMappingURL=index.cjs.map