ical-generator 9.0.0-develop.1 → 9.0.0-develop.2

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import G from"uuid-random";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||{}),A=(u=>(u.FR="FR",u.MO="MO",u.SA="SA",u.SU="SU",u.TH="TH",u.TU="TU",u.WE="WE",u))(A||{});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"||S(a)&&a.isValid===!0||(R(a)||j(a))&&a.isValid())return a;throw new Error(`\`${t}\` has to be a valid date!`)}function o(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 v(a){return a.split(`\r
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||{}),A=(u=>(u.FR="FR",u.MO="MO",u.SA="SA",u.SU="SU",u.TH="TH",u.TU="TU",u.WE="WE",u))(A||{});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"||S(a)&&a.isValid===!0||(R(a)||j(a))&&a.isValid())return a;throw new Error(`\`${t}\` has to be a valid date!`)}function o(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 v(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 k=new TextEncoder().encode(s).length;n+=k,n>74&&(e+=`\r
3
3
  `,n=k),e+=s}return e}).join(`\r
4
4
  `)}function d(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(R(t)){let i=a?F(t)&&!t.tz()?t.clone().tz(a):t:n||e&&F(t)&&t.tz()?t:t.utc();return i.format("YYYYMMDD")+(e?"":"T"+i.format("HHmmss")+(n||a?"":"Z"))}else if(S(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 E(a,t,e,n){let i="",s=n?.floating||!1;return n?.timezone&&(i=";TZID="+n.timezone,s=!0),t+i+":"+d(a,e,!1,s)}function D(a){let t=a.x.map(([e,n])=>e.toUpperCase()+":"+r(n,!1)).join(`\r
@@ -20,7 +20,7 @@ import G from"uuid-random";var b=(u=>(u.DAILY="DAILY",u.HOURLY="HOURLY",u.MINUTE
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+=D(this.data),t+=`END:VALARM\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:G(),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=o(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=o(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(x(t)||typeof t=="string")return this.data.repeating=t,this;if(this.data.repeating={freq:o(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=>o(A,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=o(A,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=o(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 x(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
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:crypto.randomUUID(),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=o(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=o(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(x(t)||typeof t=="string")return this.data.repeating=t,this;if(this.data.repeating={freq:o(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=>o(A,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=o(A,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=o(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 x(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:"+d(this.calendar.timezone(),this.data.stamp)+`\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+=D(this.data),t+="END:VCALENDAR",v(t)}ttl(t){return t===void 0?this.data.ttl:(J(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 H(a){return new T(a)}var It=H;export{I as ICalAlarm,Y as ICalAlarmRelatesTo,V as ICalAlarmType,f as ICalAttendee,O as ICalAttendeeRole,M as ICalAttendeeStatus,w as ICalAttendeeType,T as ICalCalendar,P as ICalCalendarMethod,c as ICalCategory,y as ICalEvent,L as ICalEventBusyStatus,z as ICalEventClass,b as ICalEventRepeatingFreq,U as ICalEventStatus,B as ICalEventTransparency,A as ICalWeekday,It as default,r as escape,v as foldLines,d as formatDate,E as formatDateTZ};
79
+ `),this.data.events.forEach(e=>t+=e.toString()),t+=D(this.data),t+="END:VCALENDAR",v(t)}ttl(t){return t===void 0?this.data.ttl:(J(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 G(a){return new T(a)}var pt=G;export{I as ICalAlarm,Y as ICalAlarmRelatesTo,V as ICalAlarmType,f as ICalAttendee,O as ICalAttendeeRole,M as ICalAttendeeStatus,w as ICalAttendeeType,T as ICalCalendar,P as ICalCalendarMethod,c as ICalCategory,y as ICalEvent,L as ICalEventBusyStatus,z as ICalEventClass,b as ICalEventRepeatingFreq,U as ICalEventStatus,B as ICalEventTransparency,A as ICalWeekday,pt as default,r as escape,v as foldLines,d as formatDate,E as formatDateTZ};
80
80
  //# sourceMappingURL=index.js.map