ical-generator 4.0.0-develop.2 → 4.1.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/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2140 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +19 -18
- package/dist/index.js.map +1 -1
- package/package.json +22 -24
- package/src/alarm.ts +72 -7
- package/src/attendee.ts +2 -2
- package/src/calendar.ts +3 -3
- package/src/category.ts +1 -1
- package/src/event.ts +6 -6
- package/src/index.ts +8 -8
- package/src/tools.ts +1 -1
- package/dist/index.mjs +0 -77
- package/dist/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -9,41 +9,45 @@
|
|
|
9
9
|
"description": "ical-generator is a small piece of code which generates ical calendar files",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.5",
|
|
12
|
-
"@semantic-release/changelog": "^6.0.
|
|
12
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
13
13
|
"@semantic-release/exec": "^6.0.3",
|
|
14
14
|
"@semantic-release/git": "^10.0.1",
|
|
15
|
-
"@semantic-release/npm": "^
|
|
15
|
+
"@semantic-release/npm": "^10.0.2",
|
|
16
16
|
"@touch4it/ical-timezones": "^1.9.0",
|
|
17
|
-
"@types/luxon": "^3.
|
|
17
|
+
"@types/luxon": "^3.3.0",
|
|
18
18
|
"@types/mocha": "^10.0.1",
|
|
19
|
-
"@types/node": "^18.15.
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
21
|
-
"@typescript-eslint/parser": "^5.
|
|
19
|
+
"@types/node": "^18.15.11",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
21
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
22
22
|
"c8": "^7.11.3",
|
|
23
23
|
"dayjs": "^1.11.7",
|
|
24
|
-
"eslint": "^8.
|
|
25
|
-
"eslint-plugin-jsonc": "^2.
|
|
24
|
+
"eslint": "^8.37.0",
|
|
25
|
+
"eslint-plugin-jsonc": "^2.7.0",
|
|
26
26
|
"esm": "^3.2.25",
|
|
27
27
|
"license-checker": "^25.0.1",
|
|
28
28
|
"luxon": "^3.3.0",
|
|
29
29
|
"mocha": "^10.2.0",
|
|
30
30
|
"mochawesome": "^7.1.3",
|
|
31
31
|
"moment": "^2.29.4",
|
|
32
|
-
"moment-timezone": "^0.5.
|
|
32
|
+
"moment-timezone": "^0.5.42",
|
|
33
33
|
"nyc": "^15.1.0",
|
|
34
34
|
"portfinder": "^1.0.32",
|
|
35
35
|
"rrule": "^2.7.2",
|
|
36
|
-
"semantic-release": "^
|
|
36
|
+
"semantic-release": "^21.0.1",
|
|
37
37
|
"semantic-release-license": "^1.0.2",
|
|
38
38
|
"source-map-support": "^0.5.21",
|
|
39
39
|
"ts-node": "^10.9.1",
|
|
40
|
-
"tsup": "^6.
|
|
41
|
-
"typedoc": "^0.23.
|
|
42
|
-
"typescript": "^
|
|
40
|
+
"tsup": "^6.7.0",
|
|
41
|
+
"typedoc": "^0.23.28",
|
|
42
|
+
"typescript": "^5.0.4"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": "^14.8.0 || >=16.0.0"
|
|
46
46
|
},
|
|
47
|
+
"exports": {
|
|
48
|
+
"import": "./dist/index.js",
|
|
49
|
+
"require": "./dist/index.cjs"
|
|
50
|
+
},
|
|
47
51
|
"files": [
|
|
48
52
|
"/src",
|
|
49
53
|
"/dist"
|
|
@@ -63,16 +67,9 @@
|
|
|
63
67
|
"alarms"
|
|
64
68
|
],
|
|
65
69
|
"license": "MIT",
|
|
66
|
-
"main": "./dist/index.
|
|
67
|
-
"
|
|
68
|
-
"typings": "./dist/index.d.ts",
|
|
70
|
+
"main": "./dist/index.cjs",
|
|
71
|
+
"module": "./dist/index.js",
|
|
69
72
|
"name": "ical-generator",
|
|
70
|
-
"exports": {
|
|
71
|
-
"types": "./dist/index.d.ts",
|
|
72
|
-
"import": "./dist/index.mjs",
|
|
73
|
-
"require": "./dist/index.js"
|
|
74
|
-
},
|
|
75
|
-
"module": "./dist/index.mjs",
|
|
76
73
|
"peerDependencies": {
|
|
77
74
|
"@touch4it/ical-timezones": ">=1.6.0",
|
|
78
75
|
"@types/luxon": ">= 1.26.0",
|
|
@@ -120,7 +117,7 @@
|
|
|
120
117
|
},
|
|
121
118
|
"runkitExampleFilename": "examples/example-runkit.js",
|
|
122
119
|
"scripts": {
|
|
123
|
-
"build": "tsup",
|
|
120
|
+
"build": "tsup && cp ./dist/index.d.ts ./dist/index.d.cts",
|
|
124
121
|
"build-all": "./.github/workflows/build.sh",
|
|
125
122
|
"coverage": "c8 mocha",
|
|
126
123
|
"develop": "ts-node ./src/bin/start.ts",
|
|
@@ -130,5 +127,6 @@
|
|
|
130
127
|
"start": "node ./dist/bin/start.js",
|
|
131
128
|
"test": "mocha"
|
|
132
129
|
},
|
|
133
|
-
"
|
|
130
|
+
"type": "module",
|
|
131
|
+
"version": "4.1.0-develop.1"
|
|
134
132
|
}
|
package/src/alarm.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import ICalEvent from './event';
|
|
3
|
+
import ICalEvent from './event.js';
|
|
4
4
|
import {
|
|
5
5
|
addOrGetCustomAttributes,
|
|
6
6
|
formatDate,
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
checkDate,
|
|
10
10
|
toDurationString,
|
|
11
11
|
toJSON
|
|
12
|
-
} from './tools';
|
|
13
|
-
import {ICalDateTimeValue} from './types';
|
|
12
|
+
} from './tools.js';
|
|
13
|
+
import {ICalDateTimeValue} from './types.js';
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
export enum ICalAlarmType {
|
|
@@ -18,6 +18,13 @@ export enum ICalAlarmType {
|
|
|
18
18
|
audio = 'audio'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export const ICalAlarmRelatesTo = {
|
|
22
|
+
end: 'END',
|
|
23
|
+
start: 'START'
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export type ICalAlarmRelatesTo = typeof ICalAlarmRelatesTo[keyof typeof ICalAlarmRelatesTo];
|
|
27
|
+
|
|
21
28
|
export type ICalAlarmTypeValue = keyof ICalAlarmType;
|
|
22
29
|
|
|
23
30
|
export interface ICalAttachment {
|
|
@@ -28,6 +35,7 @@ export interface ICalAttachment {
|
|
|
28
35
|
export interface ICalAlarmData {
|
|
29
36
|
type?: ICalAlarmType | null;
|
|
30
37
|
trigger?: number | ICalDateTimeValue | null;
|
|
38
|
+
relatesTo?: ICalAlarmRelatesTo | null;
|
|
31
39
|
triggerBefore?: number | ICalDateTimeValue | null;
|
|
32
40
|
triggerAfter?: number | ICalDateTimeValue | null;
|
|
33
41
|
repeat?: number | null;
|
|
@@ -40,6 +48,7 @@ export interface ICalAlarmData {
|
|
|
40
48
|
interface ICalInternalAlarmData {
|
|
41
49
|
type: ICalAlarmType | null;
|
|
42
50
|
trigger: ICalDateTimeValue | number | null;
|
|
51
|
+
relatesTo: ICalAlarmRelatesTo | null;
|
|
43
52
|
repeat: number | null;
|
|
44
53
|
interval: number | null;
|
|
45
54
|
attach: ICalAttachment | null;
|
|
@@ -50,6 +59,7 @@ interface ICalInternalAlarmData {
|
|
|
50
59
|
export interface ICalAlarmJSONData {
|
|
51
60
|
type: ICalAlarmType | null;
|
|
52
61
|
trigger: string | number | null;
|
|
62
|
+
relatesTo: ICalAlarmRelatesTo | null;
|
|
53
63
|
repeat: number | null;
|
|
54
64
|
interval: number | null;
|
|
55
65
|
attach: ICalAttachment | null;
|
|
@@ -91,6 +101,7 @@ export default class ICalAlarm {
|
|
|
91
101
|
this.data = {
|
|
92
102
|
type: null,
|
|
93
103
|
trigger: null,
|
|
104
|
+
relatesTo: null,
|
|
94
105
|
repeat: null,
|
|
95
106
|
interval: null,
|
|
96
107
|
attach: null,
|
|
@@ -205,6 +216,55 @@ export default class ICalAlarm {
|
|
|
205
216
|
return this;
|
|
206
217
|
}
|
|
207
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Get to which time alarm trigger relates to.
|
|
221
|
+
* Can be either `START` or `END`. If the value is
|
|
222
|
+
* `START` the alarm is triggerd relative to the event start time.
|
|
223
|
+
* If the value is `END` the alarm is triggerd relative to the event end time
|
|
224
|
+
*
|
|
225
|
+
* @since 4.0.1
|
|
226
|
+
*/
|
|
227
|
+
relatesTo(): ICalAlarmRelatesTo | null;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Use this method to set to which time alarm trigger relates to.
|
|
231
|
+
* Works only if trigger is a `number`
|
|
232
|
+
*
|
|
233
|
+
* ```javascript
|
|
234
|
+
* const cal = ical();
|
|
235
|
+
* const event = cal.createEvent();
|
|
236
|
+
* const alarm = cal.createAlarm();
|
|
237
|
+
*
|
|
238
|
+
* alarm.trigger(600); // -> 10 minutes before event starts
|
|
239
|
+
*
|
|
240
|
+
* alarm.relatesTo('START'); // -> 10 minutes before event starts
|
|
241
|
+
* alarm.relatesTo('END'); // -> 10 minutes before event ends
|
|
242
|
+
*
|
|
243
|
+
* alarm.trigger(-600); // -> 10 minutes after event starts
|
|
244
|
+
*
|
|
245
|
+
* alarm.relatesTo('START'); // -> 10 minutes after event starts
|
|
246
|
+
* alarm.relatesTo('END'); // -> 10 minutes after event ends
|
|
247
|
+
* ```
|
|
248
|
+
* @since 4.0.1
|
|
249
|
+
*/
|
|
250
|
+
relatesTo(relatesTo: ICalAlarmRelatesTo | null): this;
|
|
251
|
+
relatesTo(relatesTo?: ICalAlarmRelatesTo | null): this | ICalAlarmRelatesTo | null {
|
|
252
|
+
if (relatesTo === undefined) {
|
|
253
|
+
return this.data.relatesTo;
|
|
254
|
+
}
|
|
255
|
+
if (!relatesTo) {
|
|
256
|
+
this.data.relatesTo = null;
|
|
257
|
+
return this;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (!Object.values(ICalAlarmRelatesTo).includes(relatesTo)) {
|
|
261
|
+
throw new Error('`relatesTo` is not correct, must be either `START` or `END`!');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
this.data.relatesTo = relatesTo;
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
|
|
208
268
|
|
|
209
269
|
/**
|
|
210
270
|
* Get the trigger time for the alarm. Can either
|
|
@@ -569,11 +629,16 @@ export default class ICalAlarm {
|
|
|
569
629
|
// ACTION
|
|
570
630
|
g += 'ACTION:' + this.data.type.toUpperCase() + '\r\n';
|
|
571
631
|
|
|
572
|
-
if (typeof this.data.trigger === 'number' && this.data.
|
|
573
|
-
|
|
574
|
-
|
|
632
|
+
if (typeof this.data.trigger === 'number' && this.data.relatesTo === null) {
|
|
633
|
+
if (this.data.trigger > 0) {
|
|
634
|
+
g += 'TRIGGER;RELATED=END:' + toDurationString(this.data.trigger) + '\r\n';
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
g += 'TRIGGER:' + toDurationString(this.data.trigger) + '\r\n';
|
|
638
|
+
}
|
|
639
|
+
}
|
|
575
640
|
else if (typeof this.data.trigger === 'number') {
|
|
576
|
-
g += 'TRIGGER:' + toDurationString(this.data.trigger) + '\r\n';
|
|
641
|
+
g += 'TRIGGER;RELATED=' + this.data.relatesTo.toUpperCase() + ':' + toDurationString(this.data.trigger) + '\r\n';
|
|
577
642
|
}
|
|
578
643
|
else {
|
|
579
644
|
g += 'TRIGGER;VALUE=DATE-TIME:' + formatDate(this.event.timezone(), this.data.trigger) + '\r\n';
|
package/src/attendee.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import {addOrGetCustomAttributes, checkEnum, checkNameAndMail, escape} from './tools';
|
|
5
|
-
import ICalEvent from './event';
|
|
4
|
+
import {addOrGetCustomAttributes, checkEnum, checkNameAndMail, escape} from './tools.js';
|
|
5
|
+
import ICalEvent from './event.js';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
interface ICalInternalAttendeeData {
|
package/src/calendar.ts
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
generateCustomAttributes,
|
|
8
8
|
isMomentDuration,
|
|
9
9
|
toDurationString
|
|
10
|
-
} from './tools';
|
|
11
|
-
import ICalEvent, {ICalEventData, ICalEventJSONData} from './event';
|
|
10
|
+
} from './tools.js';
|
|
11
|
+
import ICalEvent, {ICalEventData, ICalEventJSONData} from './event.js';
|
|
12
12
|
import {writeFile, writeFileSync, promises as fsPromises} from 'fs';
|
|
13
13
|
import {ServerResponse} from 'http';
|
|
14
|
-
import { ICalMomentDurationStub, ICalTimezone } from './types';
|
|
14
|
+
import { ICalMomentDurationStub, ICalTimezone } from './types.js';
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
export interface ICalCalendarData {
|
package/src/category.ts
CHANGED
package/src/event.ts
CHANGED
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
isRRule,
|
|
14
14
|
toDate,
|
|
15
15
|
toJSON
|
|
16
|
-
} from './tools';
|
|
17
|
-
import ICalAttendee, {ICalAttendeeData} from './attendee';
|
|
18
|
-
import ICalAlarm, {ICalAlarmData} from './alarm';
|
|
19
|
-
import ICalCategory, {ICalCategoryData} from './category';
|
|
20
|
-
import ICalCalendar from './calendar';
|
|
16
|
+
} from './tools.js';
|
|
17
|
+
import ICalAttendee, {ICalAttendeeData} from './attendee.js';
|
|
18
|
+
import ICalAlarm, {ICalAlarmData} from './alarm.js';
|
|
19
|
+
import ICalCategory, {ICalCategoryData} from './category.js';
|
|
20
|
+
import ICalCalendar from './calendar.js';
|
|
21
21
|
import {
|
|
22
22
|
ICalDateTimeValue,
|
|
23
23
|
ICalDescription,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
ICalRepeatingOptions,
|
|
28
28
|
ICalRRuleStub,
|
|
29
29
|
ICalWeekday
|
|
30
|
-
} from './types';
|
|
30
|
+
} from './types.js';
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
export enum ICalEventStatus {
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
-
import ICalCalendar, {ICalCalendarData} from './calendar';
|
|
7
|
+
import ICalCalendar, {ICalCalendarData} from './calendar.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -53,7 +53,7 @@ export {
|
|
|
53
53
|
ICalAlarmTypeValue,
|
|
54
54
|
ICalAlarmJSONData,
|
|
55
55
|
ICalAttachment
|
|
56
|
-
} from './alarm';
|
|
56
|
+
} from './alarm.js';
|
|
57
57
|
|
|
58
58
|
export {
|
|
59
59
|
default as ICalAttendee,
|
|
@@ -62,7 +62,7 @@ export {
|
|
|
62
62
|
ICalAttendeeRole,
|
|
63
63
|
ICalAttendeeStatus,
|
|
64
64
|
ICalAttendeeJSONData
|
|
65
|
-
} from './attendee';
|
|
65
|
+
} from './attendee.js';
|
|
66
66
|
|
|
67
67
|
export {
|
|
68
68
|
default as ICalCalendar,
|
|
@@ -70,12 +70,12 @@ export {
|
|
|
70
70
|
ICalCalendarProdIdData,
|
|
71
71
|
ICalCalendarMethod,
|
|
72
72
|
ICalCalendarJSONData
|
|
73
|
-
} from './calendar';
|
|
73
|
+
} from './calendar.js';
|
|
74
74
|
|
|
75
75
|
export {
|
|
76
76
|
default as ICalCategory,
|
|
77
77
|
ICalCategoryData
|
|
78
|
-
} from './category';
|
|
78
|
+
} from './category.js';
|
|
79
79
|
|
|
80
80
|
export {
|
|
81
81
|
default as ICalEvent,
|
|
@@ -85,7 +85,7 @@ export {
|
|
|
85
85
|
ICalEventData,
|
|
86
86
|
ICalEventJSONData,
|
|
87
87
|
ICalEventClass,
|
|
88
|
-
} from './event';
|
|
88
|
+
} from './event.js';
|
|
89
89
|
|
|
90
90
|
export {
|
|
91
91
|
ICalDateTimeValue,
|
|
@@ -103,11 +103,11 @@ export {
|
|
|
103
103
|
ICalLuxonDateTimeStub,
|
|
104
104
|
ICalDayJsStub,
|
|
105
105
|
ICalRRuleStub
|
|
106
|
-
} from './types';
|
|
106
|
+
} from './types.js';
|
|
107
107
|
|
|
108
108
|
export {
|
|
109
109
|
formatDate,
|
|
110
110
|
formatDateTZ,
|
|
111
111
|
escape,
|
|
112
112
|
foldLines
|
|
113
|
-
} from './tools';
|
|
113
|
+
} from './tools.js';
|
package/src/tools.ts
CHANGED
package/dist/index.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
function d(n,t,e,a){if(n!=null&&n.startsWith("/")&&(n=n.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 n&&(s=i.getFullYear()+String(i.getMonth()+1).padStart(2,"0")+i.getDate().toString().padStart(2,"0")),e?s:n?(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")+(a?"":"Z"),s)}else if(v(t)){let i=n?Y(t)&&!t.tz()?t.clone().tz(n):t:a?t:t.utc();return i.format("YYYYMMDD")+(e?"":"T"+i.format("HHmmss")+(a||n?"":"Z"))}else if(R(t)){let i=n?t.setZone(n):a?t:t.setZone("utc");return i.toFormat("yyyyLLdd")+(e?"":"T"+i.toFormat("HHmmss")+(a||n?"":"Z"))}else{let i=t;if(n)i=typeof t.tz=="function"?t.tz(n):t;else if(!a)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")+(a||n?"":"Z"))}}function b(n,t,e,a){let i="",s=(a==null?void 0:a.floating)||!1;return a!=null&&a.timezone&&(i=";TZID="+a.timezone,s=!0),t+i+":"+d(n,e,!1,s)}function l(n,t){return String(n).replace(t?/[\\"]/g:/[\\;,]/g,function(e){return"\\"+e}).replace(/(?:\r\n|\r|\n)/g,"\\n")}function O(n){return n.split(`\r
|
|
2
|
-
`).map(function(t){let e="",a=0;for(let i=0;i<t.length;i++){let s=t.charAt(i);s>="\uD800"&&s<="\uDBFF"&&(s+=t.charAt(++i));let c=new TextEncoder().encode(s).length;a+=c,a>74&&(e+=`\r
|
|
3
|
-
`,a=c),e+=s}return e}).join(`\r
|
|
4
|
-
`)}function u(n,t,e){if(Array.isArray(t))n.x=t.map(a=>{if(Array.isArray(a))return a;if(typeof a.key!="string"||typeof a.value!="string")throw new Error("Either key or value is not a string!");if(a.key.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");return[a.key,a.value]});else if(typeof t=="object")n.x=Object.entries(t).map(([a,i])=>{if(typeof a!="string"||typeof i!="string")throw new Error("Either key or value is not a string!");if(a.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");return[a,i]});else if(typeof t=="string"&&typeof e=="string"){if(t.substr(0,2)!=="X-")throw new Error("Key has to start with `X-`!");n.x.push([t,e])}else return n.x.map(a=>({key:a[0],value:a[1]}))}function D(n){let t=n.x.map(([e,a])=>e.toUpperCase()+":"+l(a,!1)).join(`\r
|
|
5
|
-
`);return t.length?t+`\r
|
|
6
|
-
`:""}function E(n,t){let e=null;if(typeof t=="string"){let a=t.match(/^(.+) ?<([^>]+)>$/);a?e={name:a[1].trim(),email:a[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("`"+n+"` isn't formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!e)throw new Error("`"+n+"` 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("`"+n+".name` is empty!");return e}function h(n,t){let e=Object.values(n),a=String(t).toUpperCase();if(!a||!e.includes(a))throw new Error(`Input must be one of the following: ${e.join(", ")}`);return a}function f(n,t){if(n instanceof Date&&isNaN(n.getTime())||typeof n=="string"&&isNaN(new Date(n).getTime()))throw new Error(`\`${t}\` has to be a valid date!`);if(n instanceof Date||typeof n=="string"||R(n)&&n.isValid===!0||(v(n)||j(n))&&n.isValid())return n;throw new Error(`\`${t}\` has to be a valid date!`)}function A(n){return typeof n=="string"||n instanceof Date?new Date(n):R(n)?n.toJSDate():n.toDate()}function v(n){return n!=null&&n._isAMomentObject!=null}function Y(n){return v(n)&&"tz"in n&&typeof n.tz=="function"}function j(n){return typeof n=="object"&&n!==null&&!(n instanceof Date)&&!v(n)&&!R(n)}function R(n){return typeof n=="object"&&n!==null&&"toJSDate"in n&&typeof n.toJSDate=="function"}function k(n){return n!==null&&typeof n=="object"&&typeof n.asSeconds=="function"}function x(n){return n!==null&&typeof n=="object"&&typeof n.between=="function"&&typeof n.toString=="function"}function m(n){return n?typeof n=="string"?n:n.toJSON():null}function C(n){let t="";return n<0&&(t="-",n*=-1),t+="P",n>=86400&&(t+=Math.floor(n/86400)+"D",n%=86400),!n&&t.length>1||(t+="T",n>=3600&&(t+=Math.floor(n/3600)+"H",n%=3600),n>=60&&(t+=Math.floor(n/60)+"M",n%=60),n>0?t+=n+"S":t.length<=2&&(t+="0S")),t}import J from"uuid-random";var w=(i=>(i.CHAIR="CHAIR",i.REQ="REQ-PARTICIPANT",i.OPT="OPT-PARTICIPANT",i.NON="NON-PARTICIPANT",i))(w||{}),M=(s=>(s.ACCEPTED="ACCEPTED",s.TENTATIVE="TENTATIVE",s.DECLINED="DECLINED",s.DELEGATED="DELEGATED",s.NEEDSACTION="NEEDS-ACTION",s))(M||{}),V=(s=>(s.INDIVIDUAL="INDIVIDUAL",s.GROUP="GROUP",s.RESOURCE="RESOURCE",s.ROOM="ROOM",s.UNKNOWN="UNKNOWN",s))(V||{}),o=class{constructor(t,e){if(this.data={name:null,email:null,mailto:null,sentBy:null,status:null,role:"REQ-PARTICIPANT",rsvp:null,type:null,delegatedTo:null,delegatedFrom:null,x:[]},this.event=e,!this.event)throw new Error("`event` option required!");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=h(w,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=h(M,t),this):(this.data.status=null,this)}type(t){return t===void 0?this.data.type:t?(this.data.type=h(V,t),this):(this.data.type=null,this)}delegatedTo(t){return t===void 0?this.data.delegatedTo:t?(typeof t=="string"?this.data.delegatedTo=new o(E("delegatedTo",t),this.event):t instanceof o?this.data.delegatedTo=t:this.data.delegatedTo=new o(t,this.event),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 o(E("delegatedFrom",t),this.event):t instanceof o?this.data.delegatedFrom=t:this.data.delegatedFrom=new o(t,this.event):this.data.delegatedFrom=null,this)}delegatesTo(t){let e=t instanceof o?t:this.event.createAttendee(t);return this.delegatedTo(e),e.delegatedFrom(this),e}delegatesFrom(t){let e=t instanceof o?t:this.event.createAttendee(t);return this.delegatedFrom(e),e.delegatedTo(this),e}x(t,e){if(t===void 0)return u(this.data);if(typeof t=="string"&&typeof e=="string")u(this.data,t,e);else if(typeof t=="object")u(this.data,t);else throw new Error("Either key or value is not a string!");return this}toJSON(){var t,e;return Object.assign({},this.data,{delegatedTo:((t=this.data.delegatedTo)==null?void 0:t.email())||null,delegatedFrom:((e=this.data.delegatedFrom)==null?void 0:e.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="'+l(this.data.name,!0)+'"'),this.data.email&&this.data.mailto&&(t+=";EMAIL="+l(this.data.email,!1)),this.data.x.length&&(t+=";"+this.data.x.map(([e,a])=>e.toUpperCase()+"="+l(a,!1)).join(";")),t+=":MAILTO:"+l(this.data.mailto||this.data.email,!1)+`\r
|
|
7
|
-
`,t}};var L=(e=>(e.display="display",e.audio="audio",e))(L||{}),I=class{constructor(t,e){if(this.data={type:null,trigger:null,repeat:null,interval:null,attach:null,description:null,x:[]},this.event=e,!e)throw new Error("`event` option required!");t.type!==void 0&&this.type(t.type),t.trigger!==void 0&&this.trigger(t.trigger),t.triggerBefore!==void 0&&this.triggerBefore(t.triggerBefore),t.triggerAfter!==void 0&&this.triggerAfter(t.triggerAfter),t.repeat!==void 0&&this.repeat(t.repeat),t.interval!==void 0&&this.interval(t.interval),t.attach!==void 0&&this.attach(t.attach),t.description!==void 0&&this.description(t.description),t.x!==void 0&&this.x(t.x)}type(t){if(t===void 0)return this.data.type;if(!t)return this.data.type=null,this;if(!Object.keys(L).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&&this.data.trigger)return this.data.trigger;if(t===void 0)return null;if(!t)this.data.trigger=null;else if(typeof t=="number"&&isFinite(t))this.data.trigger=-1*t;else{if(typeof t=="number")throw new Error("`trigger` is not correct, must be a finite number or a supported date!");this.data.trigger=f(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)}repeat(t){if(t===void 0)return this.data.repeat;if(!t)return this.data.repeat=null,this;if(typeof t!="number"||!isFinite(t))throw new Error("`repeat` is not correct, must be numeric!");return this.data.repeat=t,this}interval(t){if(t===void 0)return this.data.interval||null;if(!t)return this.data.interval=null,this;if(typeof t!="number"||!isFinite(t))throw new Error("`interval` is not correct, must be numeric!");return this.data.interval=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)}x(t,e){if(t===void 0)return u(this.data);if(typeof t=="string"&&typeof e=="string")u(this.data,t,e);else if(typeof t=="object")u(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:m(t),x:this.x()})}toString(){let t=`BEGIN:VALARM\r
|
|
8
|
-
`;if(!this.data.type)throw new Error("No value for `type` in ICalAlarm given!");if(!this.data.trigger)throw new Error("No value for `trigger` in ICalAlarm given!");if(t+="ACTION:"+this.data.type.toUpperCase()+`\r
|
|
9
|
-
`,typeof this.data.trigger=="number"&&this.data.trigger>0?t+="TRIGGER;RELATED=END:"+C(this.data.trigger)+`\r
|
|
10
|
-
`:typeof this.data.trigger=="number"?t+="TRIGGER:"+C(this.data.trigger)+`\r
|
|
11
|
-
`:t+="TRIGGER;VALUE=DATE-TIME:"+d(this.event.timezone(),this.data.trigger)+`\r
|
|
12
|
-
`,this.data.repeat&&!this.data.interval)throw new Error("No value for `interval` in ICalAlarm given, but required for `repeat`!");if(this.data.repeat&&(t+="REPEAT:"+this.data.repeat+`\r
|
|
13
|
-
`),this.data.interval&&!this.data.repeat)throw new Error("No value for `repeat` in ICalAlarm given, but required for `interval`!");return this.data.interval&&(t+="DURATION:"+C(this.data.interval)+`\r
|
|
14
|
-
`),this.data.type==="audio"&&this.data.attach&&this.data.attach.mime?t+="ATTACH;FMTTYPE="+l(this.data.attach.mime,!1)+":"+l(this.data.attach.uri,!1)+`\r
|
|
15
|
-
`:this.data.type==="audio"&&this.data.attach?t+="ATTACH;VALUE=URI:"+l(this.data.attach.uri,!1)+`\r
|
|
16
|
-
`:this.data.type==="audio"&&(t+=`ATTACH;VALUE=URI:Basso\r
|
|
17
|
-
`),this.data.type==="display"&&this.data.description?t+="DESCRIPTION:"+l(this.data.description,!1)+`\r
|
|
18
|
-
`:this.data.type==="display"&&(t+="DESCRIPTION:"+l(this.event.summary(),!1)+`\r
|
|
19
|
-
`),t+=D(this.data),t+=`END:VALARM\r
|
|
20
|
-
`,t}};var p=class{constructor(t){this.data={name:null},t.name!==void 0&&this.name(t.name)}name(t){return t===void 0?this.data.name:(this.data.name=t||null,this)}toJSON(){return Object.assign({},this.data)}toString(){if(!this.data.name)throw new Error("No value for `name` in ICalCategory given!");return l(this.data.name,!1)}};var N=(r=>(r.SECONDLY="SECONDLY",r.MINUTELY="MINUTELY",r.HOURLY="HOURLY",r.DAILY="DAILY",r.WEEKLY="WEEKLY",r.MONTHLY="MONTHLY",r.YEARLY="YEARLY",r))(N||{}),S=(r=>(r.SU="SU",r.MO="MO",r.TU="TU",r.WE="WE",r.TH="TH",r.FR="FR",r.SA="SA",r))(S||{});var z=(a=>(a.CONFIRMED="CONFIRMED",a.TENTATIVE="TENTATIVE",a.CANCELLED="CANCELLED",a))(z||{}),U=(i=>(i.FREE="FREE",i.TENTATIVE="TENTATIVE",i.BUSY="BUSY",i.OOF="OOF",i))(U||{}),P=(e=>(e.TRANSPARENT="TRANSPARENT",e.OPAQUE="OPAQUE",e))(P||{}),B=(a=>(a.PUBLIC="PUBLIC",a.PRIVATE="PRIVATE",a.CONFIDENTIAL="CONFIDENTIAL",a))(B||{}),y=class{constructor(t,e){if(this.data={id:J(),sequence:0,start:null,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){if(t===void 0)return this.data.start;if(this.data.start=f(t,"start"),this.data.start&&this.data.end&&A(this.data.start).getTime()>A(this.data.end).getTime()){let e=this.data.start;this.data.start=this.data.end,this.data.end=e}return this}end(t){if(t===void 0)return this.data.end;if(t===null)return this.data.end=null,this;if(this.data.end=f(t,"end"),this.data.start&&this.data.end&&A(this.data.start).getTime()>A(this.data.end).getTime()){let e=this.data.start;this.data.start=this.data.end,this.data.end=e}return this}recurrenceId(t){return t===void 0?this.data.recurrenceId:t===null?(this.data.recurrenceId=null,this):(this.data.recurrenceId=f(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=f(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(x(t)||typeof t=="string")return this.data.repeating=t,this;if(this.data.repeating={freq:h(N,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=f(t.until,"repeating.until")),t.byDay){let e=Array.isArray(t.byDay)?t.byDay:[t.byDay];this.data.repeating.byDay=e.map(a=>h(S,a))}if(t.byMonth){let e=Array.isArray(t.byMonth)?t.byMonth:[t.byMonth];this.data.repeating.byMonth=e.map(a=>{if(typeof a!="number"||a<1||a>12)throw new Error("`repeating.byMonth` contains invalid value `"+a+"`!");return a})}if(t.byMonthDay){let e=Array.isArray(t.byMonthDay)?t.byMonthDay:[t.byMonthDay];this.data.repeating.byMonthDay=e.map(a=>{if(typeof a!="number"||a<-31||a>31||a===0)throw new Error("`repeating.byMonthDay` contains invalid value `"+a+"`!");return a})}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(a=>{if(typeof a!="number"||a<-366||a>366||a===0)throw"`repeating.bySetPos` contains invalid value `"+a+"`!";return a})}if(t.exclude){let e=Array.isArray(t.exclude)?t.exclude:[t.exclude];this.data.repeating.exclude=e.map((a,i)=>f(a,`repeating.exclude[${i}]`))}return t.startOfWeek&&(this.data.repeating.startOfWeek=h(S,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&&!t.title||t!=null&&t.geo&&(!isFinite(t.geo.lat)||!isFinite(t.geo.lon)))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=E("organizer",t),this)}createAttendee(t={}){if(t instanceof o)return this.data.attendees.push(t),t;typeof t=="string"&&(t=E("data",t));let e=new o(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 p?t:new p(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=h(z,t),this)}busystatus(t){return t===void 0?this.data.busystatus:t===null?(this.data.busystatus=null,this):(this.data.busystatus=h(U,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=h(P,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=f(t,"created"),this)}lastModified(t){return t===void 0?this.data.lastModified:t===null?(this.data.lastModified=null,this):(this.data.lastModified=f(t,"lastModified"),this)}class(t){return t===void 0?this.data.class:t===null?(this.data.class=null,this):(this.data.class=h(B,t),this)}x(t,e){return t===void 0?u(this.data):(typeof t=="string"&&typeof e=="string"&&u(this.data,t,e),typeof t=="object"&&u(this.data,t),this)}toJSON(){var e;let t=null;return x(this.data.repeating)||typeof this.data.repeating=="string"?t=this.data.repeating.toString():this.data.repeating&&(t=Object.assign({},this.data.repeating,{until:m(this.data.repeating.until)||void 0,exclude:(e=this.data.repeating.exclude)==null?void 0:e.map(a=>m(a))})),Object.assign({},this.data,{start:m(this.data.start)||null,end:m(this.data.end)||null,recurrenceId:m(this.data.recurrenceId)||null,stamp:m(this.data.stamp)||null,created:m(this.data.created)||null,lastModified:m(this.data.lastModified)||null,repeating:t,x:this.x()})}toString(){var e,a,i,s,c;let t="";if(!this.data.start)throw new Error("No value for `start` in ICalEvent #"+this.data.id+" given!");if(t+=`BEGIN:VEVENT\r
|
|
21
|
-
`,t+="UID:"+this.data.id+`\r
|
|
22
|
-
`,t+="SEQUENCE:"+this.data.sequence+`\r
|
|
23
|
-
`,t+="DTSTAMP:"+d(this.calendar.timezone(),this.data.stamp)+`\r
|
|
24
|
-
`,this.data.allDay?(t+="DTSTART;VALUE=DATE:"+d(this.calendar.timezone(),this.data.start,!0)+`\r
|
|
25
|
-
`,this.data.end&&(t+="DTEND;VALUE=DATE:"+d(this.calendar.timezone(),this.data.end,!0)+`\r
|
|
26
|
-
`),t+=`X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\r
|
|
27
|
-
`,t+=`X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE\r
|
|
28
|
-
`):(t+=b(this.timezone(),"DTSTART",this.data.start,this.data)+`\r
|
|
29
|
-
`,this.data.end&&(t+=b(this.timezone(),"DTEND",this.data.end,this.data)+`\r
|
|
30
|
-
`)),x(this.data.repeating)||typeof this.data.repeating=="string"){let r=this.data.repeating.toString().replace(/\r\n/g,`
|
|
31
|
-
`).split(`
|
|
32
|
-
`).filter(g=>g&&!g.startsWith("DTSTART:")).join(`\r
|
|
33
|
-
`);!r.includes(`\r
|
|
34
|
-
`)&&!r.startsWith("RRULE:")&&(r="RRULE:"+r),t+=r.trim()+`\r
|
|
35
|
-
`}else this.data.repeating&&(t+="RRULE:FREQ="+this.data.repeating.freq,this.data.repeating.count&&(t+=";COUNT="+this.data.repeating.count),this.data.repeating.interval&&(t+=";INTERVAL="+this.data.repeating.interval),this.data.repeating.until&&(t+=";UNTIL="+d(this.calendar.timezone(),this.data.repeating.until,!1,this.floating())),this.data.repeating.byDay&&(t+=";BYDAY="+this.data.repeating.byDay.join(",")),this.data.repeating.byMonth&&(t+=";BYMONTH="+this.data.repeating.byMonth.join(",")),this.data.repeating.byMonthDay&&(t+=";BYMONTHDAY="+this.data.repeating.byMonthDay.join(",")),this.data.repeating.bySetPos&&(t+=";BYSETPOS="+this.data.repeating.bySetPos.join(",")),this.data.repeating.startOfWeek&&(t+=";WKST="+this.data.repeating.startOfWeek),t+=`\r
|
|
36
|
-
`,this.data.repeating.exclude&&(this.data.allDay?t+="EXDATE;VALUE=DATE:"+this.data.repeating.exclude.map(r=>d(this.calendar.timezone(),r,!0)).join(",")+`\r
|
|
37
|
-
`:(t+="EXDATE",this.timezone()?t+=";TZID="+this.timezone()+":"+this.data.repeating.exclude.map(r=>d(this.timezone(),r,!1,!0)).join(",")+`\r
|
|
38
|
-
`:t+=":"+this.data.repeating.exclude.map(r=>d(this.timezone(),r,!1,this.floating())).join(",")+`\r
|
|
39
|
-
`)));return this.data.recurrenceId&&(t+=b(this.timezone(),"RECURRENCE-ID",this.data.recurrenceId,this.data)+`\r
|
|
40
|
-
`),t+="SUMMARY:"+l(this.data.summary,!1)+`\r
|
|
41
|
-
`,this.data.transparency&&(t+="TRANSP:"+l(this.data.transparency,!1)+`\r
|
|
42
|
-
`),(e=this.data.location)!=null&&e.title&&(t+="LOCATION:"+l(this.data.location.title+(this.data.location.address?`
|
|
43
|
-
`+this.data.location.address:""),!1)+`\r
|
|
44
|
-
`,this.data.location.radius&&this.data.location.geo&&(t+="X-APPLE-STRUCTURED-LOCATION;VALUE=URI;"+(this.data.location.address?"X-ADDRESS="+l(this.data.location.address,!1)+";":"")+"X-APPLE-RADIUS="+l(this.data.location.radius,!1)+";X-TITLE="+l(this.data.location.title,!1)+":geo:"+l((a=this.data.location.geo)==null?void 0:a.lat,!1)+","+l((i=this.data.location.geo)==null?void 0:i.lon,!1)+`\r
|
|
45
|
-
`),this.data.location.geo&&(t+="GEO:"+l((s=this.data.location.geo)==null?void 0:s.lat,!1)+";"+l((c=this.data.location.geo)==null?void 0:c.lon,!1)+`\r
|
|
46
|
-
`)),this.data.description&&(t+="DESCRIPTION:"+l(this.data.description.plain,!1)+`\r
|
|
47
|
-
`,this.data.description.html&&(t+="X-ALT-DESC;FMTTYPE=text/html:"+l(this.data.description.html,!1)+`\r
|
|
48
|
-
`)),this.data.organizer&&(t+='ORGANIZER;CN="'+l(this.data.organizer.name,!0)+'"',this.data.organizer.sentBy&&(t+=';SENT-BY="mailto:'+l(this.data.organizer.sentBy,!0)+'"'),this.data.organizer.email&&this.data.organizer.mailto&&(t+=";EMAIL="+l(this.data.organizer.email,!1)),this.data.organizer.email&&(t+=":mailto:"+l(this.data.organizer.mailto||this.data.organizer.email,!1)),t+=`\r
|
|
49
|
-
`),this.data.attendees.forEach(function(r){t+=r.toString()}),this.data.alarms.forEach(function(r){t+=r.toString()}),this.data.categories.length>0&&(t+="CATEGORIES:"+this.data.categories.map(function(r){return r.toString()}).join()+`\r
|
|
50
|
-
`),this.data.url&&(t+="URL;VALUE=URI:"+l(this.data.url,!1)+`\r
|
|
51
|
-
`),this.data.attachments.length>0&&this.data.attachments.forEach(r=>{t+="ATTACH:"+l(r,!1)+`\r
|
|
52
|
-
`}),this.data.status&&(t+="STATUS:"+this.data.status.toUpperCase()+`\r
|
|
53
|
-
`),this.data.busystatus&&(t+="X-MICROSOFT-CDO-BUSYSTATUS:"+this.data.busystatus.toUpperCase()+`\r
|
|
54
|
-
`),this.data.priority!==null&&(t+="PRIORITY:"+this.data.priority+`\r
|
|
55
|
-
`),t+=D(this.data),this.data.created&&(t+="CREATED:"+d(this.calendar.timezone(),this.data.created)+`\r
|
|
56
|
-
`),this.data.lastModified&&(t+="LAST-MODIFIED:"+d(this.calendar.timezone(),this.data.lastModified)+`\r
|
|
57
|
-
`),this.data.class&&(t+="CLASS:"+this.data.class.toUpperCase()+`\r
|
|
58
|
-
`),t+=`END:VEVENT\r
|
|
59
|
-
`,t}};import{writeFile as G,writeFileSync as H,promises as W}from"fs";var F=(g=>(g.PUBLISH="PUBLISH",g.REQUEST="REQUEST",g.REPLY="REPLY",g.ADD="ADD",g.CANCEL="CANCEL",g.REFRESH="REFRESH",g.COUNTER="COUNTER",g.DECLINECOUNTER="DECLINECOUNTER",g))(F||{}),T=class{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"&&/^\/\/(.+)\/\/(.+)\/\/([A-Z]{1,4})$/.test(t))return this.data.prodId=t,this;if(typeof t=="string")throw new Error("`prodId` isn't formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/classes/ICalCalendar.html#prodId");if(typeof t!="object")throw new Error("`prodid` needs to be a valid formed 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 a=(t.language||"EN").toUpperCase();return this.data.prodId="//"+t.company+"//"+t.product+"//"+a,this}method(t){return t===void 0?this.data.method:t?(this.data.method=h(F,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){var e;return t===void 0?((e=this.data.timezone)==null?void 0:e.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:(k(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}save(t,e){return e?(G(t,this.toString(),e),this):W.writeFile(t,this.toString())}saveSync(t){return H(t,this.toString()),this}serve(t,e="calendar.ics"){return t.writeHead(200,{"Content-Type":"text/calendar; charset=utf-8","Content-Disposition":`attachment; filename="${e}"`}),t.end(this.toString()),this}toBlob(){return new Blob([this.toString()],{type:"text/calendar"})}toURL(){return URL.createObjectURL(this.toBlob())}x(t,e){if(t===void 0)return u(this.data);if(typeof t=="string"&&typeof e=="string")u(this.data,t,e);else if(typeof t=="object")u(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(){var e,a;let t="";return t=`BEGIN:VCALENDAR\r
|
|
60
|
-
VERSION:2.0\r
|
|
61
|
-
`,t+="PRODID:-"+this.data.prodId+`\r
|
|
62
|
-
`,this.data.url&&(t+="URL:"+this.data.url+`\r
|
|
63
|
-
`),this.data.source&&(t+="SOURCE;VALUE=URI:"+this.data.source+`\r
|
|
64
|
-
`),this.data.scale&&(t+="CALSCALE:"+this.data.scale+`\r
|
|
65
|
-
`),this.data.method&&(t+="METHOD:"+this.data.method+`\r
|
|
66
|
-
`),this.data.name&&(t+="NAME:"+this.data.name+`\r
|
|
67
|
-
`,t+="X-WR-CALNAME:"+this.data.name+`\r
|
|
68
|
-
`),this.data.description&&(t+="X-WR-CALDESC:"+this.data.description+`\r
|
|
69
|
-
`),(e=this.data.timezone)!=null&&e.generator&&[...new Set([this.timezone(),...this.data.events.map(s=>s.timezone())])].filter(s=>s!==null&&!s.startsWith("/")).forEach(s=>{var r;if(!((r=this.data.timezone)!=null&&r.generator))return;let c=this.data.timezone.generator(s);c&&(t+=c.replace(/\r\n/g,`
|
|
70
|
-
`).replace(/\n/g,`\r
|
|
71
|
-
`).trim()+`\r
|
|
72
|
-
`)}),(a=this.data.timezone)!=null&&a.name&&(t+="TIMEZONE-ID:"+this.data.timezone.name+`\r
|
|
73
|
-
`,t+="X-WR-TIMEZONE:"+this.data.timezone.name+`\r
|
|
74
|
-
`),this.data.ttl&&(t+="REFRESH-INTERVAL;VALUE=DURATION:"+C(this.data.ttl)+`\r
|
|
75
|
-
`,t+="X-PUBLISHED-TTL:"+C(this.data.ttl)+`\r
|
|
76
|
-
`),this.data.events.forEach(i=>t+=i.toString()),t+=D(this.data),t+="END:VCALENDAR",O(t)}};function q(n){return new T(n)}var vt=q;export{I as ICalAlarm,L as ICalAlarmType,o as ICalAttendee,w as ICalAttendeeRole,M as ICalAttendeeStatus,V as ICalAttendeeType,T as ICalCalendar,F as ICalCalendarMethod,p as ICalCategory,y as ICalEvent,U as ICalEventBusyStatus,B as ICalEventClass,N as ICalEventRepeatingFreq,z as ICalEventStatus,P as ICalEventTransparency,S as ICalWeekday,vt as default,l as escape,O as foldLines,d as formatDate,b as formatDateTZ};
|
|
77
|
-
//# sourceMappingURL=index.mjs.map
|