@liquid-js/qr-code-styling 5.6.1 → 5.7.0-0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-dpqpq3zE.js","sources":["../src/utils/gradient.ts","../src/utils/color.ts"],"sourcesContent":["export enum GradientType {\r\n radial = 'radial',\r\n linear = 'linear'\r\n}\r\n\r\nexport interface Gradient {\r\n /**\r\n * Type of gradient spread\r\n *\r\n * @default GradientType.linear\r\n */\r\n type: `${GradientType}`\r\n /**\r\n * Rotation of gradient (in radians, Math.PI === 180 degrees)\r\n *\r\n * @default 0\r\n */\r\n rotation?: number\r\n /** Gradient colors. */\r\n colorStops: Array<{\r\n /** Position of color in gradient range */\r\n offset: number\r\n /** Color of stop in gradient range */\r\n color: string\r\n }>\r\n}\r\n\r\nexport function sanitizeGradient(gradient: Gradient): Gradient {\r\n const newGradient = { ...gradient }\r\n\r\n if (!newGradient.colorStops || !newGradient.colorStops.length) {\r\n throw new Error(\"Field 'colorStops' is required in gradient\")\r\n }\r\n\r\n if (newGradient.rotation) {\r\n newGradient.rotation = Number(newGradient.rotation)\r\n } else {\r\n newGradient.rotation = 0\r\n }\r\n\r\n newGradient.colorStops = newGradient.colorStops.map((colorStop: { offset: number, color: string }) => ({\r\n ...colorStop,\r\n offset: Number(colorStop.offset)\r\n }))\r\n\r\n return newGradient\r\n}\r\n","import { Gradient, GradientType } from './gradient.js'\nimport { numToAttr, svgAttr } from './svg.js'\n\nexport function parseColor(cstr: string) {\n let m: RegExpExecArray | null\n let parts: string[] | number[] = []\n let alpha = 1\n\n cstr = cstr.toLowerCase()\n\n if (cstr[0] === '#') {\n const base = cstr.slice(1)\n const size = base.length\n const isShort = size <= 4\n\n if (isShort) {\n parts = [parseInt(base[0] + base[0], 16), parseInt(base[1] + base[1], 16), parseInt(base[2] + base[2], 16)]\n if (size === 4) {\n alpha = parseInt(base[3] + base[3], 16) / 255\n }\n } else {\n parts = [parseInt(base[0] + base[1], 16), parseInt(base[2] + base[3], 16), parseInt(base[4] + base[5], 16)]\n if (size === 8) {\n alpha = parseInt(base[6] + base[7], 16) / 255\n }\n }\n\n if (!parts[0]) parts[0] = 0\n if (!parts[1]) parts[1] = 0\n if (!parts[2]) parts[2] = 0\n } else if ((m = /^((?:rgba?))\\s*\\(([^)]*)\\)/.exec(cstr))) {\n const dims = 3\n parts = m[2].trim().split(/\\s*[,/]\\s*|\\s+/)\n\n parts = parts.map((x, i) => {\n if (x[x.length - 1] === '%') {\n const v = parseFloat(x) / 100\n if (i === 3) return v\n return v * 255\n }\n\n if (x === 'none') return 0\n return parseFloat(x)\n })\n\n alpha = parts.length > dims ? parts.pop()! : 1\n } else {\n return {\n value: cstr,\n alpha\n }\n }\n\n const value = '#' + parts.map((v) => Math.max(0, Math.min(255, v)).toString(16).padStart(2, '0')).join('')\n return {\n value,\n alpha: Math.max(0, Math.min(1, alpha))\n }\n}\n\nexport interface ColorElementValue {\n gradient?: SVGElement\n value: string\n opacity: number\n}\n\nexport function createColor({\n options,\n color,\n additionalRotation,\n x,\n y,\n height,\n width,\n name,\n dotSize: size,\n document\n}: {\n options?: Gradient\n color?: string\n additionalRotation: number\n x: number\n y: number\n height: number\n width: number\n name: string\n dotSize: number\n document: Document\n}): ColorElementValue | undefined {\n const gradientSize = width > height ? width : height\n\n x -= size\n y -= size\n width += 2 * size\n height += 2 * size\n\n if (options) {\n let gradient: SVGElement\n if (options.type === GradientType.radial) {\n gradient = document.createElementNS('http://www.w3.org/2000/svg', 'radialGradient')\n gradient.setAttribute('id', name)\n gradient.setAttribute('gradientUnits', 'userSpaceOnUse')\n gradient.setAttribute('fx', numToAttr(x + width / 2))\n gradient.setAttribute('fy', numToAttr(y + height / 2))\n gradient.setAttribute('cx', numToAttr(x + width / 2))\n gradient.setAttribute('cy', numToAttr(y + height / 2))\n gradient.setAttribute('r', numToAttr(gradientSize / 2))\n } else {\n const rotation = ((options.rotation || 0) + additionalRotation) % (2 * Math.PI)\n const positiveRotation = (rotation + 2 * Math.PI) % (2 * Math.PI)\n let x0 = x + width / 2\n let y0 = y + height / 2\n let x1 = x + width / 2\n let y1 = y + height / 2\n\n if (\n (positiveRotation >= 0 && positiveRotation <= 0.25 * Math.PI) ||\n (positiveRotation > 1.75 * Math.PI && positiveRotation <= 2 * Math.PI)\n ) {\n x0 = x0 - width / 2\n y0 = y0 - (height / 2) * Math.tan(rotation)\n x1 = x1 + width / 2\n y1 = y1 + (height / 2) * Math.tan(rotation)\n } else if (positiveRotation > 0.25 * Math.PI && positiveRotation <= 0.75 * Math.PI) {\n y0 = y0 - height / 2\n x0 = x0 - width / 2 / Math.tan(rotation)\n y1 = y1 + height / 2\n x1 = x1 + width / 2 / Math.tan(rotation)\n } else if (positiveRotation > 0.75 * Math.PI && positiveRotation <= 1.25 * Math.PI) {\n x0 = x0 + width / 2\n y0 = y0 + (height / 2) * Math.tan(rotation)\n x1 = x1 - width / 2\n y1 = y1 - (height / 2) * Math.tan(rotation)\n } else if (positiveRotation > 1.25 * Math.PI && positiveRotation <= 1.75 * Math.PI) {\n y0 = y0 + height / 2\n x0 = x0 + width / 2 / Math.tan(rotation)\n y1 = y1 - height / 2\n x1 = x1 - width / 2 / Math.tan(rotation)\n }\n\n gradient = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient')\n gradient.setAttribute('id', name)\n gradient.setAttribute('gradientUnits', 'userSpaceOnUse')\n gradient.setAttribute('x1', numToAttr(x0))\n gradient.setAttribute('y1', numToAttr(y0))\n gradient.setAttribute('x2', numToAttr(x1))\n gradient.setAttribute('y2', numToAttr(y1))\n }\n\n options.colorStops.forEach((stopCfg: { offset: number, color: string }) => {\n const stop = document.createElementNS('http://www.w3.org/2000/svg', 'stop')\n stop.setAttribute('offset', svgAttr`${100 * stopCfg.offset}%`)\n\n const parsed = parseColor(stopCfg.color)\n stop.setAttribute('stop-color', parsed.value)\n if (parsed.alpha < 1) stop.setAttribute('stop-opacity', parsed.alpha.toFixed(7))\n gradient.appendChild(stop)\n })\n\n return {\n gradient,\n value: `url(#${name})`,\n opacity: 1\n }\n } else if (color) {\n const parsed = parseColor(color)\n\n return {\n value: parsed.value,\n opacity: parsed.alpha\n }\n }\n return\n}\n"],"names":["numToAttr","svgAttr","parseColor","cstr","parts","alpha","toLowerCase","size","base","slice","length","parseInt","m","exec","value","trim","split","map","x","i","v","parseFloat","dims","pop","Math","max","min","toString","padStart","join","createColor","a","color","b","additionalRotation","h","f","width","g","name","dotSize","k","document","r","l","gradientSize","height","c","options","type","radial","e","setAttribute","x0","y0","y","rotation","PI","positiveRotation","tan","x1","y1","gradient","createElementNS","colorStops","forEach","stopCfg","stop","offset","parsed","toFixed","appendChild","opacity","sanitizeGradient","Error","Number","p"],"mappings":"oBAAYA,aACRC,MAAA,oBACA,ICCEC,EAAAA,EAAAA,IAAAA,CAAAA,EAAUA,SAAAA,EAAWC,GAEnBC,IAAAA,EAA6B,GAC7BC,EAAQ,EAIZ,GAAgB,OAFhBF,EAAOA,EAAKG,eAEH,GAAY,CAEjB,IAAAC,GADAC,EAAUL,EAAGM,MAAK,IACLC,OACAH,MAGTH,EAAQ,CAACO,SAASH,EAAK,GAAKA,EAAK,GAAI,IAAKG,SAASH,EAAK,GAAKA,EAAK,GAAI,IAAKG,SAASH,EAAK,GAAKA,EAAK,GAAI,KAC1F,IAATD,IACAF,EAAQM,SAASH,EAAK,GAAKA,EAAK,GAAI,IAAM,OAG9CJ,EAAQ,CAACO,SAASH,EAAK,GAAKA,EAAK,GAAI,IAAKG,SAASH,EAAK,GAAKA,EAAK,GAAI,IAAKG,SAASH,EAAK,GAAKA,EAAK,GAAI,KAC1F,IAATD,IACAF,EAAQM,SAASH,EAAK,GAAKA,EAAK,GAAI,IAAM,MAI7CJ,EAAM,KAAIA,EAAM,GAAK,GACrBA,EAAM,KAAIA,EAAM,GAAK,GACrBA,EAAM,KAAIA,EAAM,GAAK,EAnBT,KAoBd,MAAKQ,EAAI,6BAA6BC,KAAKV,IAiB9C,MAAO,CACHW,MAAOX,EACPE,MAAAA,GAJJA,GAXAD,GAFAA,EAAQQ,EAAE,GAAGG,OAAOC,MAAM,mBAEZC,IAAI,CAACC,EAAGC,IACM,MAApBD,EAAEA,EAAER,OAAS,IACbU,EAAOC,WAAGH,OACA,IAANC,EAAgBC,EACT,IAAJA,GAGD,SAANF,EAAqB,EAClBG,WAAWH,KAGRR,OAdJY,EAcoBlB,EAAMmB,MAAS,CASjD,CAAA,MAAO,CACHT,MAFO,MAASG,IAASG,GAAGI,KAAKC,IAAK,EAAKD,KAAEE,IAAK,IAAON,IAAIO,aAAaC,SAAE,EAAU,MAAMC,KAAE,IAG9FxB,MAAOmB,KAAKC,IAAI,EAAGD,KAAKE,IAAI,EAAGrB,IArDA,aA+DjCyB,QACFC,EAAAC,MADwBC,EAExBC,2BAFwBC,SAMxBC,EAAAC,MANwBC,EAOxBC,KAAAF,EACAG,QACAC,EAAAC,SACAC,IAAA,IAVwBC,EAsB3BN,EACGF,EAAAE,EAAAO,EAKAC,GALkBC,GAAiBV,EAAQS,GAE3CL,EAAKlC,GACL,EAAKA,EACL8B,GAAS,EAAI9B,EACHwB,EAAIxB,CAEd,IAAIyC,EA+DA,OA/DSjB,SAEGkB,EAAAA,QAAsBC,EAAAA,EAAAA,6CACM,kBAA8BC,EAAAC,aACzDA,KAAAA,kBACAA,gBAAa,iCACbA,KAAAA,EAAmBpD,EAAAA,EAAAA,IAAAmD,EAAAC,aACnBA,KAAAA,UAAmBD,EAAAC,aACnBA,KAAAA,UAAmBD,EAAAC,aACnBA,KAAAA,EAAmBpD,EAAAA,EAAAA,IAAAmD,EAAAC,aACnBA,IAAkBpD,EAAU6C,EAAe,MAIhDQ,EAAKnC,EAAImB,EAAQ,EACjBiB,EAAKC,EAAIT,EAAS,EACb5B,GAAImB,EAAQ,EACZkB,GAAIT,EAAS,WALLE,EAAEQ,UAAgB,GAAKtB,IAAsB,OAASuB,OACjCjC,KAAGiC,KAAO,OAASA,MAOhC,GAAKC,GAAoB,IAAOlC,KAAKiC,IACzDC,EAAmB,KAAOlC,KAAKiC,IAAMC,GAAoB,EAAIlC,KAAKiC,IAE9DJ,GAAKhB,EAAQ,EACbiB,GAAMR,EAAS,EAAKtB,KAAKmC,IAAIH,GAC7BI,GAAKvB,EAAQ,EACbwB,GAAMf,EAAS,EAAKtB,KAAKmC,IAAIH,IAC3BE,EAAmB,IAAOlC,KAAKiC,IAAMC,GAAoB,IAAOlC,KAAKiC,IACvEH,GAAKR,EAAS,EACdO,GAAKhB,EAAQ,EAAIb,KAAKmC,IAAIH,GAC1BK,GAAKf,EAAS,EACdc,GAAKvB,EAAQ,EAAIb,KAAKmC,IAAIH,IACxBE,EAAmB,IAAOlC,KAAKiC,IAAMC,GAAoB,KAAOlC,KAAKiC,IACvEJ,GAAKhB,EAAQ,EACbiB,GAAMR,EAAS,EAAKtB,KAAKmC,IAAIH,GAC7BI,GAAKvB,EAAQ,EACbwB,GAAMf,EAAS,EAAKtB,KAAKmC,IAAIH,IAC3BE,EAAmB,KAAOlC,KAAKiC,IAAMC,GAAoB,KAAOlC,KAAKiC,KACvEH,GAAKR,EAAS,EACdO,GAAKhB,EAAQ,EAAIb,KAAKmC,IAAIH,GAC1BK,GAAKf,EAAS,EACdc,GAAKvB,EAAQ,EAAIb,KAAKmC,IAAIH,IAGnCM,EAAWpB,EAASqB,gBAAgB,6BAA8B,kBAClED,EAASV,aAAa,KAAMb,GAC5BuB,EAASV,aAAa,gBAAiB,kBACvCU,EAASV,aAAa,KAAMpD,EAAUqD,IACtCS,EAASV,aAAa,KAAMpD,EAAUsD,IACtCQ,EAASV,aAAa,KAAMpD,EAAU4D,IACtCE,EAASV,aAAa,KAAMpD,EAAU6D,OAGlCG,WAAWC,QAASC,IACxB,IAAAC,EAAUzB,EAAGqB,6CAAqD,UAC7DX,aAAa,SAAUnD,CAAA,GAAU,IAAMiE,EAAQE,aAExClE,EAAGgE,EAAWlC,OAC1BmC,EAAKf,aAAa,aAAciB,EAAOvD,OACnCuD,EAAOhE,MAAQ,GAAG8D,EAAKf,aAAa,eAAgBiB,EAAOhE,MAAMiE,QAAQ,MACpEC,YAAYJ,KAGlB,CACHL,SAAAA,EACAhD,MAAO,QAAQyB,KACfiC,QAAS,EAlEJ,CAoEN,GAAIxC,EAGP,MAAO,CACHlB,SAHQZ,EAAG8B,IAGGlB,MACd0D,QAASH,EAAOhE,MAjF3B,YD7DKoE,GACe,KADfA,EAAAA,IAA6C1C,IAG/CiC,aAAiBA,EAAAA,WAA2BA,OAAWtD,MAAvDgE,MACcA,qDAAM3C,EAAAyB,oBAGJA,OACWmB,EAAAA,UAAmBnB,EAAAA,EAAAA,WAKlCQ,EAAAA,WAAyBA,IAAAA,IAAW/C,IAAIgB,EAAmDmC,OAEnGA,OAAQO,EAAAA,WAGZ5C,CAAA,CC1CE7B,EAAAA,OAAAA,SAAAA,EAAAA,OAAAA,gBDwB6C0E,OAAA9C,OAAA2C"}
@@ -1,6 +1,6 @@
1
1
  import { QRCodeMinimal } from '@liquid-js/qrcode-generator/lib/qrcode/QRCodeMinimal.js';
2
2
  import { ColorElementValue } from '../utils/color.js';
3
- import { Options } from '../utils/options.js';
3
+ import { GeneratorMask, Options } from '../utils/options.js';
4
4
  export declare class QRSVG {
5
5
  private options;
6
6
  private _element;
@@ -14,18 +14,31 @@ export declare class QRSVG {
14
14
  private backgroundMask?;
15
15
  private dotsMask?;
16
16
  private lightDotsMask?;
17
+ private colorLayers;
18
+ private segmentMask?;
17
19
  private qr?;
18
20
  private document;
19
21
  private imageTools;
20
22
  constructor(options: Pick<Options, 'width' | 'height' | 'size' | 'document' | 'imageTools' | 'image' | 'imageOptions' | 'dotsOptions' | 'cornersDotOptions' | 'cornersSquareOptions' | 'backgroundOptions' | 'shape' | 'plugins'> & {
21
23
  errorCorrectionPercent: number;
24
+ mask?: GeneratorMask;
22
25
  });
23
26
  get width(): number;
24
27
  get height(): number;
25
28
  drawQR(qr: QRCodeMinimal): Promise<void>;
29
+ /**
30
+ * Replace clipped color rects with plain filled paths where possible
31
+ * (clip paths are poorly supported by vector editors and some PDF renderers)
32
+ */
33
+ private flattenColorLayers;
26
34
  drawBackground(): void;
27
35
  drawDots(filter?: (i: number, j: number) => boolean): void;
28
36
  drawCorners(): void;
37
+ /**
38
+ * Segments that get drawn, with the position of the QR code within them; the plugin mask if
39
+ * available, otherwise a mask generated from the shape and image mode
40
+ */
41
+ private getSegmentMask;
29
42
  drawImage({ width, height, count, dotSize }: {
30
43
  width: number;
31
44
  height: number;
@@ -1,2 +1,2 @@
1
- var t,e={DAILY:"DAILY",HOURLY:"HOURLY",MINUTELY:"MINUTELY",MONTHLY:"MONTHLY",SECONDLY:"SECONDLY",WEEKLY:"WEEKLY",YEARLY:"YEARLY"};t=e;var a,i={};function r(t,e,a){if(Array.isArray(e))t.x=e.map(t=>{if(Array.isArray(t))return t;if("string"!=typeof t.key||"string"!=typeof t.value)throw Error("Either key or value is not a string!");if("X-"!==t.key.substr(0,2))throw Error("Key has to start with `X-`!");return[t.key,t.value]});else if("object"==typeof e)t.x=Object.entries(e).map(([t,e])=>{if("string"!=typeof t||"string"!=typeof e)throw Error("Either key or value is not a string!");if("X-"!==t.substr(0,2))throw Error("Key has to start with `X-`!");return[t,e]});else{if("string"!=typeof e||"string"!=typeof a)return t.x.map(t=>({key:t[0],value:t[1]}));if("X-"!==e.substr(0,2))throw Error("Key has to start with `X-`!");t.x.push([e,a])}}function n(t,e){if(t instanceof Date&&isNaN(t.getTime())||"string"==typeof t&&isNaN(new Date(t).getTime()))throw Error(`\`${e}\` has to be a valid date!`);var a;if((a=t instanceof Date||"string"==typeof t||"object"==typeof t&&t&&(A(t)||v(t)||T(t)||E(t))||m(t)&&!0===t.isValid)||((a=p(t))||(a=!("object"!=typeof t||!t||t instanceof Date||p(t)||m(t)||y(t))),a=a&&t.isValid()),a)return t;throw Error(`\`${e}\` has to be a valid date!`)}function s(t,e){if(t=Object.values(t),!(e=String(e).toUpperCase())||!t.includes(e))throw Error(`Input must be one of the following: ${t.join(", ")}`);return e}function o(t,e){var a=null;if("string"==typeof e){let t=e.match(/^(.+) ?<([^>]+)>$/);t?a={email:t[2].trim(),name:t[1].trim()}:e.includes("@")&&(a={email:e.trim(),name:e.trim()})}else"object"==typeof e&&(a={email:e.email,mailto:e.mailto,name:e.name,sentBy:e.sentBy});if(!a&&"string"==typeof e)throw Error("`"+t+"` isn't formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!a)throw Error("`"+t+"` needs to be a valid formed string or an object. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!a.name)throw Error("`"+t+".name` is empty!");if(!a.email)throw Error("`"+t+".email` is empty!");return a}function d(t,e){return e?h(t):String(t).replace(/[\\;,]/g,t=>"\\"+t).replace(/(?:\r\n|\r|\n)/g,"\\n")}function h(t){return String(t).replace(/\^/g,"^^").replace(/"/g,"^'").replace(/(?:\r\n|\r|\n)/g,"^n")}function l(t,e,a,i){if(t?.startsWith("/")&&(t=t.substr(1)),"string"==typeof e||e instanceof Date){var r=(e=e instanceof Date&&"internal"in e&&e.internal instanceof Date&&"withTimeZone"in e&&"function"==typeof e.withTimeZone&&"tzComponents"in e&&"function"==typeof e.tzComponents?e.withTimeZone(t):new Date(e)).getUTCFullYear().toString().padStart(4,"0")+String(e.getUTCMonth()+1).padStart(2,"0")+e.getUTCDate().toString().padStart(2,"0");return t&&(r=e.getFullYear().toString().padStart(2,"0")+String(e.getMonth()+1).padStart(2,"0")+e.getDate().toString().padStart(2,"0")),a?r:t?r+="T"+e.getHours().toString().padStart(2,"0")+e.getMinutes().toString().padStart(2,"0")+e.getSeconds().toString().padStart(2,"0"):r+="T"+e.getUTCHours().toString().padStart(2,"0")+e.getUTCMinutes().toString().padStart(2,"0")+e.getUTCSeconds().toString().padStart(2,"0")+(i?"":"Z")}if(p(e))return(e=t?g(e)&&!e.tz()?e.clone().tz(t):e:i||a&&g(e)&&e.tz()?e:e.utc()).format("YYYYMMDD")+(a?"":"T"+e.format("HHmmss")+(i||t?"":"Z"));if(m(e))return(e=t?e.setZone(t):i||a&&"system"!==e.zone.type?e:e.setZone("utc")).toFormat("yyyyLLdd")+(a?"":"T"+e.toFormat("HHmmss")+(i||t?"":"Z"));if(A(e))return r=e,t&&(r=e.withTimeZone(t)),!t&&"UTC"!==e.timeZoneId&&(r=e.withTimeZone("UTC")),l(null,r.toPlainDateTime(),a,i||!!t);if(v(e))return a?e.year.toString().padStart(4,"0")+e.month.toString().padStart(2,"0")+e.day.toString().padStart(2,"0"):t?l(t,e=e.toZonedDateTime(t),a,i):e.year.toString().padStart(4,"0")+e.month.toString().padStart(2,"0")+e.day.toString().padStart(2,"0")+"T"+e.hour.toString().padStart(2,"0")+e.minute.toString().padStart(2,"0")+e.second.toString().padStart(2,"0")+(i||t?"":"Z");if(T(e))return e.year.toString().padStart(4,"0")+e.month.toString().padStart(2,"0")+e.day.toString().padStart(2,"0")+(a?"":"T000000"+(i||t?"":"Z"));if(E(e))return l(t,e=e.toZonedDateTimeISO(t||"UTC"),a,i);if(r=e,t)r="function"==typeof e.tz?e.tz(t):e;else if(!i){if("function"!=typeof e.utc)throw Error("Unable to convert dayjs object to UTC value: UTC plugin is not available!");r=e.utc()}return r.format("YYYYMMDD")+(a?"":"T"+r.format("HHmmss")+(i||t?"":"Z"))}function u(t,e,a,i){var r="",n=i?.floating||!1;return i?.timezone&&(r=";TZID="+i.timezone,n=!0),e+r+":"+l(t,a,!1,n)}function c(t){return(t=t.x.map(([t,e])=>t.toUpperCase()+":"+d(e,!1)).join("\r\n")).length?t+"\r\n":""}function m(t){return"object"==typeof t&&!!t&&"toJSDate"in t&&"function"==typeof t.toJSDate&&!y(t)}function p(t){return null!=t&&null!=t._isAMomentObject&&!y(t)}function g(t){return p(t)&&"tz"in t&&"function"==typeof t.tz}function f(t){return"object"==typeof t&&!!t&&"between"in t&&"function"==typeof t.between&&"function"==typeof t.toString}function y(t){return A(t)||v(t)||T(t)||E(t)}function E(t){return!("object"!=typeof t||!t||A(t)||v(t)||T(t)||!("toZonedDateTimeISO"in t)||"function"!=typeof t.toZonedDateTimeISO||"year"in t||"timeZoneId"in t)}function T(t){return"object"==typeof t&&!!t&&!A(t)&&!v(t)&&"toPlainDateTime"in t&&"function"==typeof t.toPlainDateTime&&"year"in t&&"number"==typeof t.year&&"month"in t&&"number"==typeof t.month&&"day"in t&&"number"==typeof t.day&&!("hour"in t)&&!("timeZoneId"in t)&&!("epochSeconds"in t)}function v(t){return"object"==typeof t&&!!t&&!A(t)&&"toZonedDateTime"in t&&"function"==typeof t.toZonedDateTime&&"toPlainDate"in t&&"function"==typeof t.toPlainDate&&"year"in t&&"number"==typeof t.year&&"month"in t&&"number"==typeof t.month&&"day"in t&&"number"==typeof t.day&&"hour"in t&&"number"==typeof t.hour&&"minute"in t&&"number"==typeof t.minute&&"second"in t&&"number"==typeof t.second&&!("timeZone"in t)}function A(t){return"object"==typeof t&&!!t&&"timeZoneId"in t&&"string"==typeof t.timeZoneId&&"toPlainDateTime"in t&&"function"==typeof t.toPlainDateTime&&"year"in t&&"number"==typeof t.year&&"month"in t&&"number"==typeof t.month&&"day"in t&&"number"==typeof t.day&&"hour"in t&&"number"==typeof t.hour&&"minute"in t&&"number"==typeof t.minute&&"second"in t&&"number"==typeof t.second}function S(t){return t=h(t),/[,:;]/.test(t)?'"'+t+'"':t}function D(t){return"string"==typeof t||t instanceof Date?new Date(t):A(t)?(t=t.toInstant(),new Date(t.epochMilliseconds)):v(t)?new Date(Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)):T(t)?new Date(Date.UTC(t.year,t.month-1,t.day)):E(t)?new Date(t.epochMilliseconds):m(t)?t.toJSDate():t.toDate()}function b(t){var e="";return t<0&&(e="-",t*=-1),e+="P",t>=86400&&(e+=Math.floor(t/86400)+"D",t%=86400),!t&&e.length>1||(e+="T",t>=3600&&(e+=Math.floor(t/3600)+"H",t%=3600),t>=60&&(e+=Math.floor(t/60)+"M",t%=60),t>0?e+=t+"S":e.length<=2&&(e+="0S")),e}function I(t){return t?"string"==typeof t?t:A(t)?I(t.withTimeZone("UTC").toPlainDateTime()):(y(t),t.toJSON()):null}i.FR="FR",i.MO="MO",i.SA="SA",i.SU="SU",i.TH="TH",i.TU="TU",i.WE="WE",a=i;var R,N={CHAIR:"CHAIR",NON:"NON-PARTICIPANT",OPT:"OPT-PARTICIPANT",REQ:"REQ-PARTICIPANT"};R=N;var C,O={CLIENT:"CLIENT",NONE:"NONE",SERVER:"SERVER"};C=O;var U,L={ACCEPTED:"ACCEPTED",DECLINED:"DECLINED",DELEGATED:"DELEGATED",NEEDSACTION:"NEEDS-ACTION",TENTATIVE:"TENTATIVE"};U=L;var w,M={GROUP:"GROUP",INDIVIDUAL:"INDIVIDUAL",RESOURCE:"RESOURCE",ROOM:"ROOM",UNKNOWN:"UNKNOWN"};w=M;var z,P=class{data;parent;constructor(t,e){if(this.data={delegatedFrom:null,delegatedTo:null,email:"",mailto:null,name:null,role:"REQ-PARTICIPANT",rsvp:null,scheduleAgent:null,sentBy:null,status:null,type:null,x:[]},this.parent=e,!this.parent)throw Error("`event` option required!");if(!t.email)throw Error("No value for `email` in ICalAttendee given!");void 0!==t.name&&this.name(t.name),void 0!==t.email&&this.email(t.email),void 0!==t.mailto&&this.mailto(t.mailto),void 0!==t.sentBy&&this.sentBy(t.sentBy),void 0!==t.status&&this.status(t.status),void 0!==t.role&&this.role(t.role),void 0!==t.rsvp&&this.rsvp(t.rsvp),void 0!==t.type&&this.type(t.type),void 0!==t.delegatedTo&&this.delegatedTo(t.delegatedTo),void 0!==t.delegatedFrom&&this.delegatedFrom(t.delegatedFrom),t.delegatesTo&&this.delegatesTo(t.delegatesTo),t.delegatesFrom&&this.delegatesFrom(t.delegatesFrom),void 0!==t.scheduleAgent&&this.scheduleAgent(t.scheduleAgent),void 0!==t.x&&this.x(t.x)}delegatedFrom(t){return void 0===t?this.data.delegatedFrom:(this.data.delegatedFrom=t?"string"==typeof t?new P(o("delegatedFrom",t),this.parent):t instanceof P?t:new P(t,this.parent):null,this)}delegatedTo(t){return void 0===t?this.data.delegatedTo:t?(this.data.delegatedTo="string"==typeof t?new P(o("delegatedTo",t),this.parent):t instanceof P?t:new P(t,this.parent),this.data.status="DELEGATED",this):(this.data.delegatedTo=null,"DELEGATED"===this.data.status&&(this.data.status=null),this)}delegatesFrom(t){return t=t instanceof P?t:this.parent.createAttendee(t),this.delegatedFrom(t),t.delegatedTo(this),t}delegatesTo(t){return t=t instanceof P?t:this.parent.createAttendee(t),this.delegatedTo(t),t.delegatedFrom(this),t}email(t){return t?(this.data.email=t,this):this.data.email}mailto(t){return void 0===t?this.data.mailto:(this.data.mailto=t||null,this)}name(t){return void 0===t?this.data.name:(this.data.name=t||null,this)}role(t){return void 0===t?this.data.role:(this.data.role=s(R,t),this)}rsvp(t){return void 0===t?this.data.rsvp:null===t?(this.data.rsvp=null,this):(this.data.rsvp=!!t,this)}scheduleAgent(t){return void 0===t?this.data.scheduleAgent:t?"string"==typeof t&&t.toUpperCase().startsWith("X-")?(this.data.scheduleAgent=t,this):(this.data.scheduleAgent=s(C,t),this):(this.data.scheduleAgent=null,this)}sentBy(t){return t?(this.data.sentBy=t,this):this.data.sentBy}status(t){return void 0===t?this.data.status:t?(this.data.status=s(U,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(){var t="ATTENDEE";if(!this.data.email)throw 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),null!==this.data.rsvp&&(t+=";RSVP="+this.data.rsvp.toString().toUpperCase()),null!==this.data.sentBy&&(t+=';SENT-BY="mailto:'+h(this.data.sentBy)+'"'),this.data.delegatedTo&&(t+=';DELEGATED-TO="'+h(this.data.delegatedTo.email())+'"'),this.data.delegatedFrom&&(t+=';DELEGATED-FROM="'+h(this.data.delegatedFrom.email())+'"'),this.data.name&&(t+=';CN="'+h(this.data.name)+'"'),this.data.email&&this.data.mailto&&(t+=";EMAIL="+S(this.data.email)),this.data.scheduleAgent&&(t+=";SCHEDULE-AGENT="+this.data.scheduleAgent),this.data.x.length&&(t+=";"+this.data.x.map(([t,e])=>t.toUpperCase()+"="+S(e)).join(";")),t+=":MAILTO:"+d(this.data.mailto||this.data.email,!1)+"\r\n"}type(t){return void 0===t?this.data.type:t?(this.data.type=s(w,t),this):(this.data.type=null,this)}x(t,e){if(void 0===t)return r(this.data);if("string"==typeof t&&"string"==typeof e)r(this.data,t,e);else{if("object"!=typeof t)throw Error("Either key or value is not a string!");r(this.data,t)}return this}},F={audio:"audio",display:"display",email:"email"};z=F;var j,x={end:"END",start:"START"},Y=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 Error("`event` option required!");void 0!==t.type&&this.type(t.type),"trigger"in t&&void 0!==t.trigger&&this.trigger(t.trigger),"triggerBefore"in t&&void 0!==t.triggerBefore&&this.triggerBefore(t.triggerBefore),"triggerAfter"in t&&void 0!==t.triggerAfter&&this.triggerAfter(t.triggerAfter),t.repeat&&this.repeat(t.repeat),void 0!==t.attach&&this.attach(t.attach),void 0!==t.description&&this.description(t.description),void 0!==t.summary&&this.summary(t.summary),void 0!==t.attendees&&this.attendees(t.attendees),void 0!==t.x&&this.x(t.x)}attach(t){if(void 0===t)return this.data.attach;if(!t)return this.data.attach=null,this;if("string"==typeof t)var e=null;else{if("object"!=typeof t)throw 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");e=t.mime||null,t=t.uri}if(!t)throw Error("`attach.uri` is empty!");return this.data.attach={mime:e,uri:t},this}attendees(t){return t?(t.forEach(t=>this.createAttendee(t)),this):this.data.attendees}createAttendee(t){return t instanceof P?(this.data.attendees.push(t),t):("string"==typeof t&&(t=o("data",t)),t=new P(t,this),this.data.attendees.push(t),t)}description(t){return void 0===t?this.data.description:t?(this.data.description=t,this):(this.data.description=null,this)}relatesTo(t){if(void 0===t)return this.data.relatesTo;if(!t)return this.data.relatesTo=null,this;if(!Object.values(x).includes(t))throw Error("`relatesTo` is not correct, must be either `START` or `END`!");return this.data.relatesTo=t,this}repeat(t){if(void 0===t)return this.data.repeat;if(!t)return this.data.repeat=null,this;if("object"!=typeof t)throw Error("`repeat` is not correct, must be an object!");if("number"!=typeof t.times||!isFinite(t.times))throw Error("`repeat.times` is not correct, must be numeric!");if("number"!=typeof t.interval||!isFinite(t.interval))throw Error("`repeat.interval` is not correct, must be numeric!");return this.data.repeat=t,this}summary(t){return void 0===t?this.data.summary:t?(this.data.summary=t,this):(this.data.summary=null,this)}toJSON(){var t=this.trigger();return Object.assign({},this.data,{trigger:"number"==typeof t?t:I(t),x:this.x()})}toString(){var t="BEGIN:VALARM\r\n";if(t+="ACTION:"+this.data.type.toUpperCase()+"\r\n","number"==typeof this.data.trigger&&null===this.data.relatesTo?this.data.trigger>0?t+="TRIGGER;RELATED=END:"+b(this.data.trigger)+"\r\n":t+="TRIGGER:"+b(this.data.trigger)+"\r\n":"number"==typeof this.data.trigger?t+="TRIGGER;RELATED="+this.data.relatesTo?.toUpperCase()+":"+b(this.data.trigger)+"\r\n":t+="TRIGGER;VALUE=DATE-TIME:"+l(this.event.timezone(),this.data.trigger)+"\r\n",this.data.repeat){if(!this.data.repeat.times)throw Error("No value for `repeat.times` in ICalAlarm given, but required for `interval`!");if(!this.data.repeat.interval)throw Error("No value for `repeat.interval` in ICalAlarm given, but required for `repeat`!");t+="REPEAT:"+this.data.repeat.times+"\r\n",t+="DURATION:"+b(this.data.repeat.interval)+"\r\n"}return"audio"===this.data.type&&this.data.attach&&this.data.attach.mime?t+="ATTACH;FMTTYPE="+S(this.data.attach.mime)+":"+d(this.data.attach.uri,!1)+"\r\n":"audio"===this.data.type&&this.data.attach?t+="ATTACH;VALUE=URI:"+d(this.data.attach.uri,!1)+"\r\n":"audio"===this.data.type&&(t+="ATTACH;VALUE=URI:Basso\r\n"),"audio"!==this.data.type&&this.data.description?t+="DESCRIPTION:"+d(this.data.description,!1)+"\r\n":"audio"!==this.data.type&&(t+="DESCRIPTION:"+d(this.event.summary(),!1)+"\r\n"),"email"===this.data.type&&this.data.summary?t+="SUMMARY:"+d(this.data.summary,!1)+"\r\n":"email"===this.data.type&&(t+="SUMMARY:"+d(this.event.summary(),!1)+"\r\n"),"email"===this.data.type&&this.data.attendees.forEach(e=>{t+=e.toString()}),t+=c(this.data),t+="END:VALARM\r\n"}trigger(t){if(void 0===t&&"number"==typeof this.data.trigger)return-1*this.data.trigger;if(void 0===t)return this.data.trigger;if("number"==typeof t&&isFinite(t))this.data.trigger=-1*t;else{if(!t||"number"==typeof t)throw Error("`trigger` is not correct, must be a finite number or a supported date!");this.data.trigger=n(t,"trigger")}return this}triggerAfter(t){return void 0===t?this.data.trigger:this.trigger("number"==typeof t?-1*t:t)}triggerBefore(t){return void 0===t?this.trigger():this.trigger(t)}type(t){if(void 0===t)return this.data.type;if(!t||!Object.keys(z).includes(t))throw Error("`type` is not correct, must be either `display` or `audio`!");return this.data.type=t,this}x(t,e){if(void 0===t)return r(this.data);if("string"==typeof t&&"string"==typeof e)r(this.data,t,e);else{if("object"!=typeof t)throw Error("Either key or value is not a string!");r(this.data,t)}return this}},V=class{data;constructor(t){if(this.data={name:""},!t.name)throw Error("No value for `name` in ICalCategory given!");this.name(t.name)}name(t){return void 0===t?this.data.name:(this.data.name=t,this)}toJSON(){return Object.assign({},this.data)}toString(){return d(this.data.name,!1)}},B={BUSY:"BUSY",FREE:"FREE",OOF:"OOF",TENTATIVE:"TENTATIVE"};j=B;var H,Z={CONFIDENTIAL:"CONFIDENTIAL",PRIVATE:"PRIVATE",PUBLIC:"PUBLIC"};H=Z;var X,G={CANCELLED:"CANCELLED",CONFIRMED:"CONFIRMED",TENTATIVE:"TENTATIVE"};X=G;var q,W={OPAQUE:"OPAQUE",TRANSPARENT:"TRANSPARENT"};q=W;var k,Q=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,travelTime:null,url:null,x:[]},this.calendar=e,!e)throw Error("`calendar` option required!");t.id&&this.id(t.id),void 0!==t.sequence&&this.sequence(t.sequence),t.start&&this.start(t.start),void 0!==t.end&&this.end(t.end),void 0!==t.recurrenceId&&this.recurrenceId(t.recurrenceId),void 0!==t.timezone&&this.timezone(t.timezone),void 0!==t.stamp&&this.stamp(t.stamp),void 0!==t.allDay&&this.allDay(t.allDay),void 0!==t.floating&&this.floating(t.floating),void 0!==t.repeating&&this.repeating(t.repeating),void 0!==t.summary&&this.summary(t.summary),void 0!==t.location&&this.location(t.location),void 0!==t.description&&this.description(t.description),void 0!==t.organizer&&this.organizer(t.organizer),void 0!==t.attendees&&this.attendees(t.attendees),void 0!==t.alarms&&this.alarms(t.alarms),void 0!==t.categories&&this.categories(t.categories),void 0!==t.status&&this.status(t.status),void 0!==t.busystatus&&this.busystatus(t.busystatus),void 0!==t.priority&&this.priority(t.priority),void 0!==t.url&&this.url(t.url),void 0!==t.attachments&&this.attachments(t.attachments),void 0!==t.transparency&&this.transparency(t.transparency),void 0!==t.travelTime&&this.travelTime(t.travelTime),void 0!==t.created&&this.created(t.created),void 0!==t.lastModified&&this.lastModified(t.lastModified),void 0!==t.class&&this.class(t.class),void 0!==t.x&&this.x(t.x)}alarms(t){return t?(t.forEach(t=>this.createAlarm(t)),this):this.data.alarms}allDay(t){return void 0===t?this.data.allDay:(this.data.allDay=!!t,this)}attachments(t){return t?(t.forEach(t=>this.createAttachment(t)),this):this.data.attachments}attendees(t){return t?(t.forEach(t=>this.createAttendee(t)),this):this.data.attendees}busystatus(t){return void 0===t?this.data.busystatus:null===t?(this.data.busystatus=null,this):(this.data.busystatus=s(j,t),this)}categories(t){return t?(t.forEach(t=>this.createCategory(t)),this):this.data.categories}class(t){return void 0===t?this.data.class:null===t?(this.data.class=null,this):(this.data.class=s(H,t),this)}createAlarm(t){return t=t instanceof Y?t:new Y(t,this),this.data.alarms.push(t),t}createAttachment(t){return this.data.attachments.push(t),this}createAttendee(t){return t instanceof P?(this.data.attendees.push(t),t):("string"==typeof t&&(t=o("data",t)),t=new P(t,this),this.data.attendees.push(t),t)}createCategory(t){return t=t instanceof V?t:new V(t),this.data.categories.push(t),t}created(t){return void 0===t?this.data.created:null===t?(this.data.created=null,this):(this.data.created=n(t,"created"),this)}description(t){return void 0===t?this.data.description:null===t?(this.data.description=null,this):(this.data.description="string"==typeof t?{plain:t}:t,this)}end(t){return void 0===t?(this.swapStartAndEndIfRequired(),this.data.end):null===t?(this.data.end=null,this):(this.data.end=n(t,"end"),this)}floating(t){return void 0===t?this.data.floating:(this.data.floating=!!t,this.data.floating&&(this.data.timezone=null),this)}id(t){return void 0===t?this.data.id:(this.data.id=String(t),this)}lastModified(t){return void 0===t?this.data.lastModified:null===t?(this.data.lastModified=null,this):(this.data.lastModified=n(t,"lastModified"),this)}location(t){if(void 0===t)return this.data.location;if("string"==typeof t)return this.data.location={title:t},this;if(t&&("title"in t&&!t.title||t?.geo&&("number"!=typeof t.geo.lat||!isFinite(t.geo.lat)||"number"!=typeof t.geo.lon||!isFinite(t.geo.lon))||!("title"in t)&&!t?.geo))throw 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 void 0===t?this.data.organizer:null===t?(this.data.organizer=null,this):(this.data.organizer=o("organizer",t),this)}priority(t){if(void 0===t)return this.data.priority;if(null===t)return this.data.priority=null,this;if(t<0||t>9)throw Error("`priority` is invalid, musst be 0 ≤ priority ≤ 9.");return this.data.priority=Math.round(t),this}recurrenceId(t){return void 0===t?this.data.recurrenceId:null===t?(this.data.recurrenceId=null,this):(this.data.recurrenceId=n(t,"recurrenceId"),this)}repeating(e){if(void 0===e)return this.data.repeating;if(!e)return this.data.repeating=null,this;if(f(e)||"string"==typeof e)return this.data.repeating=e,this;if(this.data.repeating={freq:s(t,e.freq)},e.count){if(!isFinite(e.count))throw Error("`repeating.count` must be a finite number!");this.data.repeating.count=e.count}if(e.interval){if(!isFinite(e.interval))throw Error("`repeating.interval` must be a finite number!");this.data.repeating.interval=e.interval}if(void 0!==e.until&&(this.data.repeating.until=n(e.until,"repeating.until")),e.byDay){var i=Array.isArray(e.byDay)?e.byDay:[e.byDay];this.data.repeating.byDay=i.map(t=>s(a,t))}if(e.byMonth&&(i=Array.isArray(e.byMonth)?e.byMonth:[e.byMonth],this.data.repeating.byMonth=i.map(t=>{if("number"!=typeof t||t<1||t>12)throw Error("`repeating.byMonth` contains invalid value `"+t+"`!");return t})),e.byMonthDay&&(i=Array.isArray(e.byMonthDay)?e.byMonthDay:[e.byMonthDay],this.data.repeating.byMonthDay=i.map(t=>{if("number"!=typeof t||t<-31||t>31||0===t)throw Error("`repeating.byMonthDay` contains invalid value `"+t+"`!");return t})),e.bySetPos){if(!this.data.repeating.byDay)throw"`repeating.bySetPos` must be used along with `repeating.byDay`!";i=Array.isArray(e.bySetPos)?e.bySetPos:[e.bySetPos],this.data.repeating.bySetPos=i.map(t=>{if("number"!=typeof t||t<-366||t>366||0===t)throw"`repeating.bySetPos` contains invalid value `"+t+"`!";return t})}return e.exclude&&(i=Array.isArray(e.exclude)?e.exclude:[e.exclude],this.data.repeating.exclude=i.map((t,e)=>n(t,`repeating.exclude[${e}]`))),e.startOfWeek&&(this.data.repeating.startOfWeek=s(a,e.startOfWeek)),this}sequence(t){if(void 0===t)return this.data.sequence;if(isNaN(parseInt(String(t),10)))throw Error("`sequence` must be a number!");return this.data.sequence=t,this}stamp(t){return void 0===t?this.data.stamp:(this.data.stamp=n(t,"stamp"),this)}start(t){return void 0===t?(this.swapStartAndEndIfRequired(),this.data.start):(this.data.start=n(t,"start"),this)}status(t){return void 0===t?this.data.status:null===t?(this.data.status=null,this):(this.data.status=s(X,t),this)}summary(t){return void 0===t?this.data.summary:(this.data.summary=t?String(t):"",this)}timestamp(t){return void 0===t?this.stamp():this.stamp(t)}timezone(t){return void 0===t&&null!==this.data.timezone?this.data.timezone:void 0===t?this.calendar.timezone():(this.data.timezone=t&&"UTC"!==t?t.toString():null,this.data.timezone&&(this.data.floating=!1),this)}toJSON(){var t=null;return f(this.data.repeating)||"string"==typeof this.data.repeating?t=this.data.repeating.toString():this.data.repeating&&(t=Object.assign({},this.data.repeating,{exclude:this.data.repeating.exclude?.map(t=>I(t)),until:I(this.data.repeating.until)||void 0})),this.swapStartAndEndIfRequired(),Object.assign({},this.data,{created:I(this.data.created)||null,end:I(this.data.end)||null,lastModified:I(this.data.lastModified)||null,recurrenceId:I(this.data.recurrenceId)||null,repeating:t,stamp:I(this.data.stamp)||null,start:I(this.data.start)||null,x:this.x()})}toString(){var t="";if(t+="BEGIN:VEVENT\r\n",t+="UID:"+this.data.id+"\r\n",t+="SEQUENCE:"+this.data.sequence+"\r\n",this.swapStartAndEndIfRequired(),t+="DTSTAMP:"+l(this.calendar.timezone(),this.data.stamp)+"\r\n",this.data.allDay?(t+="DTSTART;VALUE=DATE:"+l(this.timezone(),this.data.start,!0)+"\r\n",this.data.end&&(t+="DTEND;VALUE=DATE:"+l(this.timezone(),this.data.end,!0)+"\r\n"),t+="X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\r\n",t+="X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE\r\n"):(t+=u(this.timezone(),"DTSTART",this.data.start,this.data)+"\r\n",this.data.end&&(t+=u(this.timezone(),"DTEND",this.data.end,this.data)+"\r\n")),f(this.data.repeating)||"string"==typeof this.data.repeating){var e=this.data.repeating.toString().replace(/\r\n/g,"\n").split("\n").filter(t=>t&&!t.startsWith("DTSTART:")).join("\r\n");e.includes("\r\n")||e.startsWith("RRULE:")||(e="RRULE:"+e),t+=e.trim()+"\r\n"}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="+l(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\n",this.data.repeating.exclude&&(this.data.allDay?t+="EXDATE;VALUE=DATE:"+this.data.repeating.exclude.map(t=>l(this.calendar.timezone(),t,!0)).join(",")+"\r\n":(t+="EXDATE",this.timezone()?t+=";TZID="+this.timezone()+":"+this.data.repeating.exclude.map(t=>l(this.timezone(),t,!1,!0)).join(",")+"\r\n":t+=":"+this.data.repeating.exclude.map(t=>l(this.timezone(),t,!1,this.floating())).join(",")+"\r\n")));return this.data.recurrenceId&&(t+=u(this.timezone(),"RECURRENCE-ID",this.data.recurrenceId,this.data)+"\r\n"),t+="SUMMARY:"+d(this.data.summary,!1)+"\r\n",this.data.transparency&&(t+="TRANSP:"+d(this.data.transparency,!1)+"\r\n"),this.data.location&&"title"in this.data.location&&this.data.location.title&&(t+="LOCATION:"+d(this.data.location.title+(this.data.location.address?"\n"+this.data.location.address:""),!1)+"\r\n",this.data.location.radius&&this.data.location.geo&&(t+="X-APPLE-STRUCTURED-LOCATION;VALUE=URI;"+(this.data.location.address?"X-ADDRESS="+S(this.data.location.address)+";":"")+"X-APPLE-RADIUS="+S(this.data.location.radius)+";X-TITLE="+S(this.data.location.title)+":geo:"+d(this.data.location.geo?.lat,!1)+","+d(this.data.location.geo?.lon,!1)+"\r\n")),this.data.location?.geo?.lat&&this.data.location.geo.lon&&(t+="GEO:"+d(this.data.location.geo.lat,!1)+";"+d(this.data.location.geo.lon,!1)+"\r\n"),this.data.travelTime&&(t+="X-APPLE-TRAVEL-DURATION;VALUE=DURATION:"+b(this.data.travelTime.seconds)+"\r\n",this.data.location&&(this.data.travelTime.suggestionBehavior&&(t+="X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:"+this.data.travelTime.suggestionBehavior+"\r\n"),this.data.travelTime.startFrom))&&(t+="X-APPLE-TRAVEL-START;",(e=[]).push("ROUTING="+this.data.travelTime.startFrom.transportation),e.push("VALUE=URI"),"address"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.address&&e.push("X-ADDRESS="+S(this.data.travelTime.startFrom.location.address)),"radius"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.radius&&e.push("X-APPLE-RADIUS="+S(this.data.travelTime.startFrom.location.radius)),"title"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.title&&e.push("X-TITLE="+S(this.data.travelTime.startFrom.location.title)),t+=e.join(";"),"geo"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.geo&&(t+=":geo:"+d(this.data.travelTime.startFrom.location.geo?.lat,!1)+","+d(this.data.travelTime.startFrom.location.geo?.lon,!1)),t+="\r\n"),this.data.description&&(t+="DESCRIPTION:"+d(this.data.description.plain,!1)+"\r\n",this.data.description.html&&(t+="X-ALT-DESC;FMTTYPE=text/html:"+d(this.data.description.html,!1)+"\r\n")),this.data.organizer&&(t+='ORGANIZER;CN="'+h(this.data.organizer.name)+'"',this.data.organizer.sentBy&&(t+=';SENT-BY="mailto:'+h(this.data.organizer.sentBy)+'"'),this.data.organizer.email&&this.data.organizer.mailto&&(t+=";EMAIL="+S(this.data.organizer.email)),t+=":",this.data.organizer.email&&(t+="mailto:"+d(this.data.organizer.mailto||this.data.organizer.email,!1)),t+="\r\n"),this.data.attendees.forEach(function(e){t+=e.toString()}),this.data.alarms.forEach(function(e){t+=e.toString()}),this.data.categories.length>0&&(t+="CATEGORIES:"+this.data.categories.map(t=>t.toString()).join()+"\r\n"),this.data.url&&(t+="URL;VALUE=URI:"+d(this.data.url,!1)+"\r\n"),this.data.attachments.length>0&&this.data.attachments.forEach(e=>{t+="ATTACH:"+d(e,!1)+"\r\n"}),this.data.status&&(t+="STATUS:"+this.data.status.toUpperCase()+"\r\n"),this.data.busystatus&&(t+="X-MICROSOFT-CDO-BUSYSTATUS:"+this.data.busystatus.toUpperCase()+"\r\n"),null!==this.data.priority&&(t+="PRIORITY:"+this.data.priority+"\r\n"),t+=c(this.data),this.data.created&&(t+="CREATED:"+l(this.calendar.timezone(),this.data.created)+"\r\n"),this.data.lastModified&&(t+="LAST-MODIFIED:"+l(this.calendar.timezone(),this.data.lastModified)+"\r\n"),this.data.class&&(t+="CLASS:"+this.data.class.toUpperCase()+"\r\n"),t+="END:VEVENT\r\n"}transparency(t){return void 0===t?this.data.transparency:t?(this.data.transparency=s(q,t),this):(this.data.transparency=null,this)}travelTime(t){if(void 0===t)return this.data.travelTime;if("number"==typeof t&&t<=0)throw Error("`travelTime` has to be more than 0!");if(t&&"object"==typeof t&&"seconds"in t&&t.seconds<=0)throw Error("`travelTime.seconds` has to be more than 0!");return"number"==typeof t?(this.data.travelTime={seconds:t},this):(this.data.travelTime=t,this)}uid(t){return void 0===t?this.id():this.id(t)}url(t){return void 0===t?this.data.url:(this.data.url=t?String(t):null,this)}x(t,e){return void 0===t?r(this.data):("string"==typeof t&&"string"==typeof e&&r(this.data,t,e),"object"==typeof t&&r(this.data,t),this)}swapStartAndEndIfRequired(){if(this.data.start&&this.data.end&&D(this.data.start).getTime()>D(this.data.end).getTime()){let t=this.data.start;this.data.start=this.data.end,this.data.end=t}}},J={ADD:"ADD",CANCEL:"CANCEL",COUNTER:"COUNTER",DECLINECOUNTER:"DECLINECOUNTER",PUBLISH:"PUBLISH",REFRESH:"REFRESH",REPLY:"REPLY",REQUEST:"REQUEST"};k=J;var K=class{data;constructor(t={}){this.data={color:null,description:null,events:[],method:null,name:null,prodId:"//sebbo.net//ical-generator//EN",scale:null,source:null,timezone:null,ttl:null,url:null,x:[]},void 0!==t.prodId&&this.prodId(t.prodId),void 0!==t.method&&this.method(t.method),void 0!==t.name&&this.name(t.name),void 0!==t.description&&this.description(t.description),void 0!==t.timezone&&this.timezone(t.timezone),void 0!==t.source&&this.source(t.source),void 0!==t.url&&this.url(t.url),void 0!==t.scale&&this.scale(t.scale),void 0!==t.ttl&&this.ttl(t.ttl),void 0!==t.color&&this.color(t.color),void 0!==t.events&&this.events(t.events),void 0!==t.x&&this.x(t.x)}clear(){return this.data.events=[],this}color(t){if(void 0===t)return this.data.color;if("string"==typeof t&&!/^#[A-F0-9]{6}$/gi.test(t))throw Error("`color` is malformed!");return this.data.color=t?String(t).toUpperCase():null,this}createEvent(t){return t=t instanceof Q?t:new Q(t,this),this.data.events.push(t),t}description(t){return void 0===t?this.data.description:(this.data.description=t?String(t):null,this)}events(t){return t?(t.forEach(t=>this.createEvent(t)),this):this.data.events}length(){return this.data.events.length}method(t){return void 0===t?this.data.method:t?(this.data.method=s(k,t),this):(this.data.method=null,this)}name(t){return void 0===t?this.data.name:(this.data.name=t?String(t):null,this)}prodId(t){if(!t)return this.data.prodId;if("string"==typeof t)return this.data.prodId=t,this;if("object"!=typeof t)throw Error("`prodid` needs to be a string or an object!");if(!t.company)throw Error("`prodid.company` is a mandatory item!");if(!t.product)throw Error("`prodid.product` is a mandatory item!");var e=(t.language||"EN").toUpperCase();return this.data.prodId="//"+t.company+"//"+t.product+"//"+e,this}scale(t){return void 0===t?this.data.scale:(this.data.scale=null===t?null:t.toUpperCase(),this)}source(t){return void 0===t?this.data.source:(this.data.source=t||null,this)}timezone(t){return void 0===t?this.data.timezone?.name||null:(this.data.timezone="UTC"===t?null:"string"==typeof t?{name:t}:null===t?null:t,this)}toJSON(){return Object.assign({},this.data,{events:this.data.events.map(t=>t.toJSON()),timezone:this.timezone(),x:this.x()})}toString(){var t="";return t="BEGIN:VCALENDAR\r\nVERSION:2.0\r\n",t+="PRODID:-"+this.data.prodId+"\r\n",this.data.url&&(t+="URL:"+this.data.url+"\r\n"),this.data.source&&(t+="SOURCE;VALUE=URI:"+this.data.source+"\r\n"),this.data.scale&&(t+="CALSCALE:"+this.data.scale+"\r\n"),this.data.method&&(t+="METHOD:"+this.data.method+"\r\n"),this.data.name&&(t+="NAME:"+this.data.name+"\r\n",t+="X-WR-CALNAME:"+this.data.name+"\r\n"),this.data.description&&(t+="X-WR-CALDESC:"+this.data.description+"\r\n"),this.data.timezone?.generator&&[...new Set([this.timezone(),...this.data.events.map(t=>t.timezone())])].filter(t=>null!==t&&!t.startsWith("/")).forEach(e=>{this.data.timezone?.generator&&(e=this.data.timezone.generator(e))&&(t+=e.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n").trim()+"\r\n")}),this.data.timezone?.name&&(t+="TIMEZONE-ID:"+this.data.timezone.name+"\r\n",t+="X-WR-TIMEZONE:"+this.data.timezone.name+"\r\n"),this.data.ttl&&(t+="REFRESH-INTERVAL;VALUE=DURATION:"+b(this.data.ttl)+"\r\n",t+="X-PUBLISHED-TTL:"+b(this.data.ttl)+"\r\n"),this.data.color&&(t+="X-APPLE-CALENDAR-COLOR:"+this.data.color+"\r\n"),this.data.events.forEach(e=>t+=e.toString()),t+=c(this.data),function(t){return t.split("\r\n").map(function(t){var e;if(e=t.length<=74)t:{for(e=0;e<t.length;e++)if(t.charCodeAt(e)>127){e=!1;break t}e=!0}if(e)return t;e="";var a=0;for(let i=0;i<t.length;i++){let r,n=t.charAt(i),s=t.charCodeAt(i);s<128?r=1:s<2048?r=2:s>=55296&&s<=56319?(n+=t.charAt(++i),r=4):r=3,(a+=r)>74&&(e+="\r\n ",a=r),e+=n}return e}).join("\r\n")}(t+="END:VCALENDAR")}ttl(t){return void 0===t?this.data.ttl:("object"==typeof t&&t&&"asSeconds"in t&&"function"==typeof t.asSeconds?this.data.ttl=t.asSeconds():this.data.ttl=t&&t>0?t:null,this)}url(t){return void 0===t?this.data.url:(this.data.url=t||null,this)}x(t,e){if(void 0===t)return r(this.data);if("string"==typeof t&&"string"==typeof e)r(this.data,t,e);else{if("object"!=typeof t)throw Error("Either key or value is not a string!");r(this.data,t)}return this}};function $(t){if(t)return"string"==typeof t?new Date(t):t}export default class{pluginOptions;uuid;constructor(t,e){this.pluginOptions=t,this.uuid=e}configure(t){return t.data=this.generateEvent(),t.qrOptions.mode=void 0,t}generateEvent(){var t=new K({name:"QR calendar"}),{start:e,end:a,location:i,geo:r,organizer:n,...s}=this.pluginOptions,o="number"==typeof r?.lat&&"number"==typeof r.lon?r:void 0;return t.createEvent({...s,start:$(e),end:$(a),location:i?{title:i,geo:o}:o?{geo:o}:void 0,organizer:n?.email?{name:n.name||n.email,email:n.email}:void 0,id:this.uuid}).toString().split(/[\r\n]+/g).filter(t=>!t.startsWith("SEQUENCE:")&&!t.startsWith("DTSTAMP:")&&(this.uuid||!t.startsWith("UID:"))).join("\n")}}
1
+ var t,e={DAILY:"DAILY",HOURLY:"HOURLY",MINUTELY:"MINUTELY",MONTHLY:"MONTHLY",SECONDLY:"SECONDLY",WEEKLY:"WEEKLY",YEARLY:"YEARLY"};t=e;var a,i={};function r(t,e,a){if(Array.isArray(e))t.x=e.map(t=>{if(Array.isArray(t))return t;if("string"!=typeof t.key||"string"!=typeof t.value)throw Error("Either key or value is not a string!");if("X-"!==t.key.substr(0,2))throw Error("Key has to start with `X-`!");return[t.key,t.value]});else if("object"==typeof e)t.x=Object.entries(e).map(([t,e])=>{if("string"!=typeof t||"string"!=typeof e)throw Error("Either key or value is not a string!");if("X-"!==t.substr(0,2))throw Error("Key has to start with `X-`!");return[t,e]});else{if("string"!=typeof e||"string"!=typeof a)return t.x.map(t=>({key:t[0],value:t[1]}));if("X-"!==e.substr(0,2))throw Error("Key has to start with `X-`!");t.x.push([e,a])}}function n(t,e){if(t instanceof Date&&isNaN(t.getTime())||"string"==typeof t&&isNaN(new Date(t).getTime()))throw Error(`\`${e}\` has to be a valid date!`);var a;if((a=t instanceof Date||"string"==typeof t||"object"==typeof t&&t&&(A(t)||v(t)||T(t)||E(t))||m(t)&&!0===t.isValid)||((a=p(t))||(a=!("object"!=typeof t||!t||t instanceof Date||p(t)||m(t)||y(t))),a=a&&t.isValid()),a)return t;throw Error(`\`${e}\` has to be a valid date!`)}function s(t,e){if(t=Object.values(t),!(e=String(e).toUpperCase())||!t.includes(e))throw Error(`Input must be one of the following: ${t.join(", ")}`);return e}function o(t,e){var a=null;if("string"==typeof e){let t=e.match(/^(.+) ?<([^>]+)>$/);t?a={email:t[2].trim(),name:t[1].trim()}:e.includes("@")&&(a={email:e.trim(),name:e.trim()})}else"object"==typeof e&&(a={email:e.email,mailto:e.mailto,name:e.name,sentBy:e.sentBy});if(!a&&"string"==typeof e)throw Error("`"+t+"` isn't formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!a)throw Error("`"+t+"` needs to be a valid formed string or an object. See https://sebbo2002.github.io/ical-generator/develop/reference/interfaces/ICalOrganizer.html");if(!a.name)throw Error("`"+t+".name` is empty!");if(!a.email)throw Error("`"+t+".email` is empty!");return a}function d(t,e){return e?h(t):String(t).replace(/[\\;,]/g,t=>"\\"+t).replace(/(?:\r\n|\r|\n)/g,"\\n")}function h(t){return String(t).replace(/\^/g,"^^").replace(/"/g,"^'").replace(/(?:\r\n|\r|\n)/g,"^n")}function l(t,e,a,i){if(t?.startsWith("/")&&(t=t.substr(1)),"string"==typeof e||e instanceof Date){var r=(e=e instanceof Date&&"internal"in e&&e.internal instanceof Date&&"withTimeZone"in e&&"function"==typeof e.withTimeZone&&"tzComponents"in e&&"function"==typeof e.tzComponents?e.withTimeZone(t):new Date(e)).getUTCFullYear().toString().padStart(4,"0")+String(e.getUTCMonth()+1).padStart(2,"0")+e.getUTCDate().toString().padStart(2,"0");return t&&(r=e.getFullYear().toString().padStart(4,"0")+String(e.getMonth()+1).padStart(2,"0")+e.getDate().toString().padStart(2,"0")),a?r:t?r+="T"+e.getHours().toString().padStart(2,"0")+e.getMinutes().toString().padStart(2,"0")+e.getSeconds().toString().padStart(2,"0"):r+="T"+e.getUTCHours().toString().padStart(2,"0")+e.getUTCMinutes().toString().padStart(2,"0")+e.getUTCSeconds().toString().padStart(2,"0")+(i?"":"Z")}if(p(e))return(e=t?g(e)&&!e.tz()?e.clone().tz(t):e:i||a&&g(e)&&e.tz()?e:e.utc()).format("YYYYMMDD")+(a?"":"T"+e.format("HHmmss")+(i||t?"":"Z"));if(m(e))return(e=t?e.setZone(t):i||a&&"system"!==e.zone.type?e:e.setZone("utc")).toFormat("yyyyLLdd")+(a?"":"T"+e.toFormat("HHmmss")+(i||t?"":"Z"));if(A(e))return r=e,t&&(r=e.withTimeZone(t)),!t&&"UTC"!==e.timeZoneId&&(r=e.withTimeZone("UTC")),l(null,r.toPlainDateTime(),a,i||!!t);if(v(e))return a?e.year.toString().padStart(4,"0")+e.month.toString().padStart(2,"0")+e.day.toString().padStart(2,"0"):t?l(t,e=e.toZonedDateTime(t),a,i):e.year.toString().padStart(4,"0")+e.month.toString().padStart(2,"0")+e.day.toString().padStart(2,"0")+"T"+e.hour.toString().padStart(2,"0")+e.minute.toString().padStart(2,"0")+e.second.toString().padStart(2,"0")+(i||t?"":"Z");if(T(e))return e.year.toString().padStart(4,"0")+e.month.toString().padStart(2,"0")+e.day.toString().padStart(2,"0")+(a?"":"T000000"+(i||t?"":"Z"));if(E(e))return l(t,e=e.toZonedDateTimeISO(t||"UTC"),a,i);if(r=e,t)r="function"==typeof e.tz?e.tz(t):e;else if(!i){if("function"!=typeof e.utc)throw Error("Unable to convert dayjs object to UTC value: UTC plugin is not available!");r=e.utc()}return r.format("YYYYMMDD")+(a?"":"T"+r.format("HHmmss")+(i||t?"":"Z"))}function u(t,e,a,i){var r="",n=i?.floating||!1;return i?.timezone&&(r=";TZID="+i.timezone,n=!0),e+r+":"+l(t,a,!1,n)}function c(t){return(t=t.x.map(([t,e])=>t.toUpperCase()+":"+d(e,!1)).join("\r\n")).length?t+"\r\n":""}function m(t){return"object"==typeof t&&!!t&&"toJSDate"in t&&"function"==typeof t.toJSDate&&!y(t)}function p(t){return null!=t&&null!=t._isAMomentObject&&!y(t)}function g(t){return p(t)&&"tz"in t&&"function"==typeof t.tz}function f(t){return"object"==typeof t&&!!t&&"between"in t&&"function"==typeof t.between&&"function"==typeof t.toString}function y(t){return A(t)||v(t)||T(t)||E(t)}function E(t){return!("object"!=typeof t||!t||A(t)||v(t)||T(t)||!("toZonedDateTimeISO"in t)||"function"!=typeof t.toZonedDateTimeISO||"year"in t||"timeZoneId"in t)}function T(t){return"object"==typeof t&&!!t&&!A(t)&&!v(t)&&"toPlainDateTime"in t&&"function"==typeof t.toPlainDateTime&&"year"in t&&"number"==typeof t.year&&"month"in t&&"number"==typeof t.month&&"day"in t&&"number"==typeof t.day&&!("hour"in t)&&!("timeZoneId"in t)&&!("epochSeconds"in t)}function v(t){return"object"==typeof t&&!!t&&!A(t)&&"toZonedDateTime"in t&&"function"==typeof t.toZonedDateTime&&"toPlainDate"in t&&"function"==typeof t.toPlainDate&&"year"in t&&"number"==typeof t.year&&"month"in t&&"number"==typeof t.month&&"day"in t&&"number"==typeof t.day&&"hour"in t&&"number"==typeof t.hour&&"minute"in t&&"number"==typeof t.minute&&"second"in t&&"number"==typeof t.second&&!("timeZone"in t)}function A(t){return"object"==typeof t&&!!t&&"timeZoneId"in t&&"string"==typeof t.timeZoneId&&"toPlainDateTime"in t&&"function"==typeof t.toPlainDateTime&&"year"in t&&"number"==typeof t.year&&"month"in t&&"number"==typeof t.month&&"day"in t&&"number"==typeof t.day&&"hour"in t&&"number"==typeof t.hour&&"minute"in t&&"number"==typeof t.minute&&"second"in t&&"number"==typeof t.second}function S(t){return t=h(t),/[,:;]/.test(t)?'"'+t+'"':t}function D(t){return"string"==typeof t||t instanceof Date?new Date(t):A(t)?(t=t.toInstant(),new Date(t.epochMilliseconds)):v(t)?new Date(Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)):T(t)?new Date(Date.UTC(t.year,t.month-1,t.day)):E(t)?new Date(t.epochMilliseconds):m(t)?t.toJSDate():t.toDate()}function b(t){var e="";return t<0&&(e="-",t*=-1),e+="P",t>=86400&&(e+=Math.floor(t/86400)+"D",t%=86400),!t&&e.length>1||(e+="T",t>=3600&&(e+=Math.floor(t/3600)+"H",t%=3600),t>=60&&(e+=Math.floor(t/60)+"M",t%=60),t>0?e+=t+"S":e.length<=2&&(e+="0S")),e}function I(t){return t?"string"==typeof t?t:A(t)?I(t.withTimeZone("UTC").toPlainDateTime()):(y(t),t.toJSON()):null}i.FR="FR",i.MO="MO",i.SA="SA",i.SU="SU",i.TH="TH",i.TU="TU",i.WE="WE",a=i;var R,N={CHAIR:"CHAIR",NON:"NON-PARTICIPANT",OPT:"OPT-PARTICIPANT",REQ:"REQ-PARTICIPANT"};R=N;var C,O={CLIENT:"CLIENT",NONE:"NONE",SERVER:"SERVER"};C=O;var U,L={ACCEPTED:"ACCEPTED",DECLINED:"DECLINED",DELEGATED:"DELEGATED",NEEDSACTION:"NEEDS-ACTION",TENTATIVE:"TENTATIVE"};U=L;var w,M={GROUP:"GROUP",INDIVIDUAL:"INDIVIDUAL",RESOURCE:"RESOURCE",ROOM:"ROOM",UNKNOWN:"UNKNOWN"};w=M;var z,P=class{data;parent;constructor(t,e){if(this.data={delegatedFrom:null,delegatedTo:null,email:"",mailto:null,name:null,role:"REQ-PARTICIPANT",rsvp:null,scheduleAgent:null,sentBy:null,status:null,type:null,x:[]},this.parent=e,!this.parent)throw Error("`event` option required!");if(!t.email)throw Error("No value for `email` in ICalAttendee given!");void 0!==t.name&&this.name(t.name),void 0!==t.email&&this.email(t.email),void 0!==t.mailto&&this.mailto(t.mailto),void 0!==t.sentBy&&this.sentBy(t.sentBy),void 0!==t.status&&this.status(t.status),void 0!==t.role&&this.role(t.role),void 0!==t.rsvp&&this.rsvp(t.rsvp),void 0!==t.type&&this.type(t.type),void 0!==t.delegatedTo&&this.delegatedTo(t.delegatedTo),void 0!==t.delegatedFrom&&this.delegatedFrom(t.delegatedFrom),t.delegatesTo&&this.delegatesTo(t.delegatesTo),t.delegatesFrom&&this.delegatesFrom(t.delegatesFrom),void 0!==t.scheduleAgent&&this.scheduleAgent(t.scheduleAgent),void 0!==t.x&&this.x(t.x)}delegatedFrom(t){return void 0===t?this.data.delegatedFrom:(this.data.delegatedFrom=t?"string"==typeof t?new P(o("delegatedFrom",t),this.parent):t instanceof P?t:new P(t,this.parent):null,this)}delegatedTo(t){return void 0===t?this.data.delegatedTo:t?(this.data.delegatedTo="string"==typeof t?new P(o("delegatedTo",t),this.parent):t instanceof P?t:new P(t,this.parent),this.data.status="DELEGATED",this):(this.data.delegatedTo=null,"DELEGATED"===this.data.status&&(this.data.status=null),this)}delegatesFrom(t){return t=t instanceof P?t:this.parent.createAttendee(t),this.delegatedFrom(t),t.delegatedTo(this),t}delegatesTo(t){return t=t instanceof P?t:this.parent.createAttendee(t),this.delegatedTo(t),t.delegatedFrom(this),t}email(t){return t?(this.data.email=t,this):this.data.email}mailto(t){return void 0===t?this.data.mailto:(this.data.mailto=t||null,this)}name(t){return void 0===t?this.data.name:(this.data.name=t||null,this)}role(t){return void 0===t?this.data.role:(this.data.role=s(R,t),this)}rsvp(t){return void 0===t?this.data.rsvp:null===t?(this.data.rsvp=null,this):(this.data.rsvp=!!t,this)}scheduleAgent(t){return void 0===t?this.data.scheduleAgent:t?"string"==typeof t&&t.toUpperCase().startsWith("X-")?(this.data.scheduleAgent=t,this):(this.data.scheduleAgent=s(C,t),this):(this.data.scheduleAgent=null,this)}sentBy(t){return t?(this.data.sentBy=t,this):this.data.sentBy}status(t){return void 0===t?this.data.status:t?(this.data.status=s(U,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(){var t="ATTENDEE";if(!this.data.email)throw 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),null!==this.data.rsvp&&(t+=";RSVP="+this.data.rsvp.toString().toUpperCase()),null!==this.data.sentBy&&(t+=';SENT-BY="mailto:'+h(this.data.sentBy)+'"'),this.data.delegatedTo&&(t+=';DELEGATED-TO="'+h(this.data.delegatedTo.email())+'"'),this.data.delegatedFrom&&(t+=';DELEGATED-FROM="'+h(this.data.delegatedFrom.email())+'"'),this.data.name&&(t+=';CN="'+h(this.data.name)+'"'),this.data.email&&this.data.mailto&&(t+=";EMAIL="+S(this.data.email)),this.data.scheduleAgent&&(t+=";SCHEDULE-AGENT="+this.data.scheduleAgent),this.data.x.length&&(t+=";"+this.data.x.map(([t,e])=>t.toUpperCase()+"="+S(e)).join(";")),t+=":MAILTO:"+d(this.data.mailto||this.data.email,!1)+"\r\n"}type(t){return void 0===t?this.data.type:t?(this.data.type=s(w,t),this):(this.data.type=null,this)}x(t,e){if(void 0===t)return r(this.data);if("string"==typeof t&&"string"==typeof e)r(this.data,t,e);else{if("object"!=typeof t)throw Error("Either key or value is not a string!");r(this.data,t)}return this}},F={audio:"audio",display:"display",email:"email"};z=F;var j,x={end:"END",start:"START"},Y=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 Error("`event` option required!");void 0!==t.type&&this.type(t.type),"trigger"in t&&void 0!==t.trigger&&this.trigger(t.trigger),"triggerBefore"in t&&void 0!==t.triggerBefore&&this.triggerBefore(t.triggerBefore),"triggerAfter"in t&&void 0!==t.triggerAfter&&this.triggerAfter(t.triggerAfter),t.repeat&&this.repeat(t.repeat),void 0!==t.attach&&this.attach(t.attach),void 0!==t.description&&this.description(t.description),void 0!==t.summary&&this.summary(t.summary),void 0!==t.attendees&&this.attendees(t.attendees),void 0!==t.x&&this.x(t.x)}attach(t){if(void 0===t)return this.data.attach;if(!t)return this.data.attach=null,this;if("string"==typeof t)var e=null;else{if("object"!=typeof t)throw 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");e=t.mime||null,t=t.uri}if(!t)throw Error("`attach.uri` is empty!");return this.data.attach={mime:e,uri:t},this}attendees(t){return t?(t.forEach(t=>this.createAttendee(t)),this):this.data.attendees}createAttendee(t){return t instanceof P?(this.data.attendees.push(t),t):("string"==typeof t&&(t=o("data",t)),t=new P(t,this),this.data.attendees.push(t),t)}description(t){return void 0===t?this.data.description:t?(this.data.description=t,this):(this.data.description=null,this)}relatesTo(t){if(void 0===t)return this.data.relatesTo;if(!t)return this.data.relatesTo=null,this;if(!Object.values(x).includes(t))throw Error("`relatesTo` is not correct, must be either `START` or `END`!");return this.data.relatesTo=t,this}repeat(t){if(void 0===t)return this.data.repeat;if(!t)return this.data.repeat=null,this;if("object"!=typeof t)throw Error("`repeat` is not correct, must be an object!");if("number"!=typeof t.times||!isFinite(t.times))throw Error("`repeat.times` is not correct, must be numeric!");if("number"!=typeof t.interval||!isFinite(t.interval))throw Error("`repeat.interval` is not correct, must be numeric!");return this.data.repeat=t,this}summary(t){return void 0===t?this.data.summary:t?(this.data.summary=t,this):(this.data.summary=null,this)}toJSON(){var t=this.trigger();return Object.assign({},this.data,{trigger:"number"==typeof t?t:I(t),x:this.x()})}toString(){var t="BEGIN:VALARM\r\n";if(t+="ACTION:"+this.data.type.toUpperCase()+"\r\n","number"==typeof this.data.trigger&&null===this.data.relatesTo?this.data.trigger>0?t+="TRIGGER;RELATED=END:"+b(this.data.trigger)+"\r\n":t+="TRIGGER:"+b(this.data.trigger)+"\r\n":"number"==typeof this.data.trigger?t+="TRIGGER;RELATED="+this.data.relatesTo?.toUpperCase()+":"+b(this.data.trigger)+"\r\n":t+="TRIGGER;VALUE=DATE-TIME:"+l(this.event.timezone(),this.data.trigger)+"\r\n",this.data.repeat){if(!this.data.repeat.times)throw Error("No value for `repeat.times` in ICalAlarm given, but required for `interval`!");if(!this.data.repeat.interval)throw Error("No value for `repeat.interval` in ICalAlarm given, but required for `repeat`!");t+="REPEAT:"+this.data.repeat.times+"\r\n",t+="DURATION:"+b(this.data.repeat.interval)+"\r\n"}return"audio"===this.data.type&&this.data.attach&&this.data.attach.mime?t+="ATTACH;FMTTYPE="+S(this.data.attach.mime)+":"+d(this.data.attach.uri,!1)+"\r\n":"audio"===this.data.type&&this.data.attach?t+="ATTACH;VALUE=URI:"+d(this.data.attach.uri,!1)+"\r\n":"audio"===this.data.type&&(t+="ATTACH;VALUE=URI:Basso\r\n"),"audio"!==this.data.type&&this.data.description?t+="DESCRIPTION:"+d(this.data.description,!1)+"\r\n":"audio"!==this.data.type&&(t+="DESCRIPTION:"+d(this.event.summary(),!1)+"\r\n"),"email"===this.data.type&&this.data.summary?t+="SUMMARY:"+d(this.data.summary,!1)+"\r\n":"email"===this.data.type&&(t+="SUMMARY:"+d(this.event.summary(),!1)+"\r\n"),"email"===this.data.type&&this.data.attendees.forEach(e=>{t+=e.toString()}),t+=c(this.data),t+="END:VALARM\r\n"}trigger(t){if(void 0===t&&"number"==typeof this.data.trigger)return-1*this.data.trigger;if(void 0===t)return this.data.trigger;if("number"==typeof t&&isFinite(t))this.data.trigger=-1*t;else{if(!t||"number"==typeof t)throw Error("`trigger` is not correct, must be a finite number or a supported date!");this.data.trigger=n(t,"trigger")}return this}triggerAfter(t){return void 0===t?this.data.trigger:this.trigger("number"==typeof t?-1*t:t)}triggerBefore(t){return void 0===t?this.trigger():this.trigger(t)}type(t){if(void 0===t)return this.data.type;if(!t||!Object.keys(z).includes(t))throw Error("`type` is not correct, must be either `display` or `audio`!");return this.data.type=t,this}x(t,e){if(void 0===t)return r(this.data);if("string"==typeof t&&"string"==typeof e)r(this.data,t,e);else{if("object"!=typeof t)throw Error("Either key or value is not a string!");r(this.data,t)}return this}},V=class{data;constructor(t){if(this.data={name:""},!t.name)throw Error("No value for `name` in ICalCategory given!");this.name(t.name)}name(t){return void 0===t?this.data.name:(this.data.name=t,this)}toJSON(){return Object.assign({},this.data)}toString(){return d(this.data.name,!1)}},B={BUSY:"BUSY",FREE:"FREE",OOF:"OOF",TENTATIVE:"TENTATIVE"};j=B;var H,Z={CONFIDENTIAL:"CONFIDENTIAL",PRIVATE:"PRIVATE",PUBLIC:"PUBLIC"};H=Z;var X,G={CANCELLED:"CANCELLED",CONFIRMED:"CONFIRMED",TENTATIVE:"TENTATIVE"};X=G;var q,W={OPAQUE:"OPAQUE",TRANSPARENT:"TRANSPARENT"};q=W;var k,Q=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,travelTime:null,url:null,x:[]},this.calendar=e,!e)throw Error("`calendar` option required!");t.id&&this.id(t.id),void 0!==t.sequence&&this.sequence(t.sequence),t.start&&this.start(t.start),void 0!==t.end&&this.end(t.end),void 0!==t.recurrenceId&&this.recurrenceId(t.recurrenceId),void 0!==t.timezone&&this.timezone(t.timezone),void 0!==t.stamp&&this.stamp(t.stamp),void 0!==t.allDay&&this.allDay(t.allDay),void 0!==t.floating&&this.floating(t.floating),void 0!==t.repeating&&this.repeating(t.repeating),void 0!==t.summary&&this.summary(t.summary),void 0!==t.location&&this.location(t.location),void 0!==t.description&&this.description(t.description),void 0!==t.organizer&&this.organizer(t.organizer),void 0!==t.attendees&&this.attendees(t.attendees),void 0!==t.alarms&&this.alarms(t.alarms),void 0!==t.categories&&this.categories(t.categories),void 0!==t.status&&this.status(t.status),void 0!==t.busystatus&&this.busystatus(t.busystatus),void 0!==t.priority&&this.priority(t.priority),void 0!==t.url&&this.url(t.url),void 0!==t.attachments&&this.attachments(t.attachments),void 0!==t.transparency&&this.transparency(t.transparency),void 0!==t.travelTime&&this.travelTime(t.travelTime),void 0!==t.created&&this.created(t.created),void 0!==t.lastModified&&this.lastModified(t.lastModified),void 0!==t.class&&this.class(t.class),void 0!==t.x&&this.x(t.x)}alarms(t){return t?(t.forEach(t=>this.createAlarm(t)),this):this.data.alarms}allDay(t){return void 0===t?this.data.allDay:(this.data.allDay=!!t,this)}attachments(t){return t?(t.forEach(t=>this.createAttachment(t)),this):this.data.attachments}attendees(t){return t?(t.forEach(t=>this.createAttendee(t)),this):this.data.attendees}busystatus(t){return void 0===t?this.data.busystatus:null===t?(this.data.busystatus=null,this):(this.data.busystatus=s(j,t),this)}categories(t){return t?(t.forEach(t=>this.createCategory(t)),this):this.data.categories}class(t){return void 0===t?this.data.class:null===t?(this.data.class=null,this):(this.data.class=s(H,t),this)}createAlarm(t){return t=t instanceof Y?t:new Y(t,this),this.data.alarms.push(t),t}createAttachment(t){return this.data.attachments.push(t),this}createAttendee(t){return t instanceof P?(this.data.attendees.push(t),t):("string"==typeof t&&(t=o("data",t)),t=new P(t,this),this.data.attendees.push(t),t)}createCategory(t){return t=t instanceof V?t:new V(t),this.data.categories.push(t),t}created(t){return void 0===t?this.data.created:null===t?(this.data.created=null,this):(this.data.created=n(t,"created"),this)}description(t){return void 0===t?this.data.description:null===t?(this.data.description=null,this):(this.data.description="string"==typeof t?{plain:t}:t,this)}end(t){return void 0===t?(this.swapStartAndEndIfRequired(),this.data.end):null===t?(this.data.end=null,this):(this.data.end=n(t,"end"),this)}floating(t){return void 0===t?this.data.floating:(this.data.floating=!!t,this.data.floating&&(this.data.timezone=null),this)}id(t){return void 0===t?this.data.id:(this.data.id=String(t),this)}lastModified(t){return void 0===t?this.data.lastModified:null===t?(this.data.lastModified=null,this):(this.data.lastModified=n(t,"lastModified"),this)}location(t){if(void 0===t)return this.data.location;if("string"==typeof t)return this.data.location={title:t},this;if(t&&("title"in t&&!t.title||t?.geo&&("number"!=typeof t.geo.lat||!isFinite(t.geo.lat)||"number"!=typeof t.geo.lon||!isFinite(t.geo.lon))||!("title"in t)&&!t?.geo))throw 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 void 0===t?this.data.organizer:null===t?(this.data.organizer=null,this):(this.data.organizer=o("organizer",t),this)}priority(t){if(void 0===t)return this.data.priority;if(null===t)return this.data.priority=null,this;if(t<0||t>9)throw Error("`priority` is invalid, musst be 0 ≤ priority ≤ 9.");return this.data.priority=Math.round(t),this}recurrenceId(t){return void 0===t?this.data.recurrenceId:null===t?(this.data.recurrenceId=null,this):(this.data.recurrenceId=n(t,"recurrenceId"),this)}repeating(e){if(void 0===e)return this.data.repeating;if(!e)return this.data.repeating=null,this;if(f(e)||"string"==typeof e)return this.data.repeating=e,this;if(this.data.repeating={freq:s(t,e.freq)},e.count){if(!isFinite(e.count))throw Error("`repeating.count` must be a finite number!");this.data.repeating.count=e.count}if(e.interval){if(!isFinite(e.interval))throw Error("`repeating.interval` must be a finite number!");this.data.repeating.interval=e.interval}if(void 0!==e.until&&(this.data.repeating.until=n(e.until,"repeating.until")),e.byDay){var i=Array.isArray(e.byDay)?e.byDay:[e.byDay];this.data.repeating.byDay=i.map(t=>s(a,t))}if(e.byMonth&&(i=Array.isArray(e.byMonth)?e.byMonth:[e.byMonth],this.data.repeating.byMonth=i.map(t=>{if("number"!=typeof t||t<1||t>12)throw Error("`repeating.byMonth` contains invalid value `"+t+"`!");return t})),e.byMonthDay&&(i=Array.isArray(e.byMonthDay)?e.byMonthDay:[e.byMonthDay],this.data.repeating.byMonthDay=i.map(t=>{if("number"!=typeof t||t<-31||t>31||0===t)throw Error("`repeating.byMonthDay` contains invalid value `"+t+"`!");return t})),e.bySetPos){if(!this.data.repeating.byDay)throw"`repeating.bySetPos` must be used along with `repeating.byDay`!";i=Array.isArray(e.bySetPos)?e.bySetPos:[e.bySetPos],this.data.repeating.bySetPos=i.map(t=>{if("number"!=typeof t||t<-366||t>366||0===t)throw"`repeating.bySetPos` contains invalid value `"+t+"`!";return t})}return e.exclude&&(i=Array.isArray(e.exclude)?e.exclude:[e.exclude],this.data.repeating.exclude=i.map((t,e)=>n(t,`repeating.exclude[${e}]`))),e.startOfWeek&&(this.data.repeating.startOfWeek=s(a,e.startOfWeek)),this}sequence(t){if(void 0===t)return this.data.sequence;if(isNaN(parseInt(String(t),10)))throw Error("`sequence` must be a number!");return this.data.sequence=t,this}stamp(t){return void 0===t?this.data.stamp:(this.data.stamp=n(t,"stamp"),this)}start(t){return void 0===t?(this.swapStartAndEndIfRequired(),this.data.start):(this.data.start=n(t,"start"),this)}status(t){return void 0===t?this.data.status:null===t?(this.data.status=null,this):(this.data.status=s(X,t),this)}summary(t){return void 0===t?this.data.summary:(this.data.summary=t?String(t):"",this)}timestamp(t){return void 0===t?this.stamp():this.stamp(t)}timezone(t){return void 0===t&&null!==this.data.timezone?this.data.timezone:void 0===t?this.calendar.timezone():(this.data.timezone=t&&"UTC"!==t?t.toString():null,this.data.timezone&&(this.data.floating=!1),this)}toJSON(){var t=null;return f(this.data.repeating)||"string"==typeof this.data.repeating?t=this.data.repeating.toString():this.data.repeating&&(t=Object.assign({},this.data.repeating,{exclude:this.data.repeating.exclude?.map(t=>I(t)),until:I(this.data.repeating.until)||void 0})),this.swapStartAndEndIfRequired(),Object.assign({},this.data,{created:I(this.data.created)||null,end:I(this.data.end)||null,lastModified:I(this.data.lastModified)||null,recurrenceId:I(this.data.recurrenceId)||null,repeating:t,stamp:I(this.data.stamp)||null,start:I(this.data.start)||null,x:this.x()})}toString(){var t="";if(t+="BEGIN:VEVENT\r\n",t+="UID:"+this.data.id+"\r\n",t+="SEQUENCE:"+this.data.sequence+"\r\n",this.swapStartAndEndIfRequired(),t+="DTSTAMP:"+l(this.calendar.timezone(),this.data.stamp)+"\r\n",this.data.allDay?(t+="DTSTART;VALUE=DATE:"+l(this.timezone(),this.data.start,!0)+"\r\n",this.data.end&&(t+="DTEND;VALUE=DATE:"+l(this.timezone(),this.data.end,!0)+"\r\n"),t+="X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\r\n",t+="X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE\r\n"):(t+=u(this.timezone(),"DTSTART",this.data.start,this.data)+"\r\n",this.data.end&&(t+=u(this.timezone(),"DTEND",this.data.end,this.data)+"\r\n")),f(this.data.repeating)||"string"==typeof this.data.repeating){var e=this.data.repeating.toString().replace(/\r\n/g,"\n").split("\n").filter(t=>t&&!t.startsWith("DTSTART:")).join("\r\n");e.includes("\r\n")||e.startsWith("RRULE:")||(e="RRULE:"+e),t+=e.trim()+"\r\n"}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="+l(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\n",this.data.repeating.exclude&&(this.data.allDay?t+="EXDATE;VALUE=DATE:"+this.data.repeating.exclude.map(t=>l(this.calendar.timezone(),t,!0)).join(",")+"\r\n":(t+="EXDATE",this.timezone()?t+=";TZID="+this.timezone()+":"+this.data.repeating.exclude.map(t=>l(this.timezone(),t,!1,!0)).join(",")+"\r\n":t+=":"+this.data.repeating.exclude.map(t=>l(this.timezone(),t,!1,this.floating())).join(",")+"\r\n")));return this.data.recurrenceId&&(t+=u(this.timezone(),"RECURRENCE-ID",this.data.recurrenceId,this.data)+"\r\n"),t+="SUMMARY:"+d(this.data.summary,!1)+"\r\n",this.data.transparency&&(t+="TRANSP:"+d(this.data.transparency,!1)+"\r\n"),this.data.location&&"title"in this.data.location&&this.data.location.title&&(t+="LOCATION:"+d(this.data.location.title+(this.data.location.address?"\n"+this.data.location.address:""),!1)+"\r\n",this.data.location.radius&&this.data.location.geo&&(t+="X-APPLE-STRUCTURED-LOCATION;VALUE=URI;"+(this.data.location.address?"X-ADDRESS="+S(this.data.location.address)+";":"")+"X-APPLE-RADIUS="+S(this.data.location.radius)+";X-TITLE="+S(this.data.location.title)+":geo:"+d(this.data.location.geo?.lat,!1)+","+d(this.data.location.geo?.lon,!1)+"\r\n")),this.data.location?.geo?.lat&&this.data.location.geo.lon&&(t+="GEO:"+d(this.data.location.geo.lat,!1)+";"+d(this.data.location.geo.lon,!1)+"\r\n"),this.data.travelTime&&(t+="X-APPLE-TRAVEL-DURATION;VALUE=DURATION:"+b(this.data.travelTime.seconds)+"\r\n",this.data.location&&(this.data.travelTime.suggestionBehavior&&(t+="X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:"+this.data.travelTime.suggestionBehavior+"\r\n"),this.data.travelTime.startFrom))&&(t+="X-APPLE-TRAVEL-START;",(e=[]).push("ROUTING="+this.data.travelTime.startFrom.transportation),e.push("VALUE=URI"),"address"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.address&&e.push("X-ADDRESS="+S(this.data.travelTime.startFrom.location.address)),"radius"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.radius&&e.push("X-APPLE-RADIUS="+S(this.data.travelTime.startFrom.location.radius)),"title"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.title&&e.push("X-TITLE="+S(this.data.travelTime.startFrom.location.title)),t+=e.join(";"),"geo"in this.data.travelTime.startFrom.location&&this.data.travelTime.startFrom.location.geo&&(t+=":geo:"+d(this.data.travelTime.startFrom.location.geo?.lat,!1)+","+d(this.data.travelTime.startFrom.location.geo?.lon,!1)),t+="\r\n"),this.data.description&&(t+="DESCRIPTION:"+d(this.data.description.plain,!1)+"\r\n",this.data.description.html&&(t+="X-ALT-DESC;FMTTYPE=text/html:"+d(this.data.description.html,!1)+"\r\n")),this.data.organizer&&(t+='ORGANIZER;CN="'+h(this.data.organizer.name)+'"',this.data.organizer.sentBy&&(t+=';SENT-BY="mailto:'+h(this.data.organizer.sentBy)+'"'),this.data.organizer.email&&this.data.organizer.mailto&&(t+=";EMAIL="+S(this.data.organizer.email)),t+=":",this.data.organizer.email&&(t+="mailto:"+d(this.data.organizer.mailto||this.data.organizer.email,!1)),t+="\r\n"),this.data.attendees.forEach(function(e){t+=e.toString()}),this.data.alarms.forEach(function(e){t+=e.toString()}),this.data.categories.length>0&&(t+="CATEGORIES:"+this.data.categories.map(t=>t.toString()).join()+"\r\n"),this.data.url&&(t+="URL;VALUE=URI:"+d(this.data.url,!1)+"\r\n"),this.data.attachments.length>0&&this.data.attachments.forEach(e=>{t+="ATTACH:"+d(e,!1)+"\r\n"}),this.data.status&&(t+="STATUS:"+this.data.status.toUpperCase()+"\r\n"),this.data.busystatus&&(t+="X-MICROSOFT-CDO-BUSYSTATUS:"+this.data.busystatus.toUpperCase()+"\r\n"),null!==this.data.priority&&(t+="PRIORITY:"+this.data.priority+"\r\n"),t+=c(this.data),this.data.created&&(t+="CREATED:"+l(this.calendar.timezone(),this.data.created)+"\r\n"),this.data.lastModified&&(t+="LAST-MODIFIED:"+l(this.calendar.timezone(),this.data.lastModified)+"\r\n"),this.data.class&&(t+="CLASS:"+this.data.class.toUpperCase()+"\r\n"),t+="END:VEVENT\r\n"}transparency(t){return void 0===t?this.data.transparency:t?(this.data.transparency=s(q,t),this):(this.data.transparency=null,this)}travelTime(t){if(void 0===t)return this.data.travelTime;if("number"==typeof t&&t<=0)throw Error("`travelTime` has to be more than 0!");if(t&&"object"==typeof t&&"seconds"in t&&t.seconds<=0)throw Error("`travelTime.seconds` has to be more than 0!");return"number"==typeof t?(this.data.travelTime={seconds:t},this):(this.data.travelTime=t,this)}uid(t){return void 0===t?this.id():this.id(t)}url(t){return void 0===t?this.data.url:(this.data.url=t?String(t):null,this)}x(t,e){return void 0===t?r(this.data):("string"==typeof t&&"string"==typeof e&&r(this.data,t,e),"object"==typeof t&&r(this.data,t),this)}swapStartAndEndIfRequired(){if(this.data.start&&this.data.end&&D(this.data.start).getTime()>D(this.data.end).getTime()){let t=this.data.start;this.data.start=this.data.end,this.data.end=t}}},J={ADD:"ADD",CANCEL:"CANCEL",COUNTER:"COUNTER",DECLINECOUNTER:"DECLINECOUNTER",PUBLISH:"PUBLISH",REFRESH:"REFRESH",REPLY:"REPLY",REQUEST:"REQUEST"};k=J;var K=class{data;constructor(t={}){this.data={color:null,description:null,events:[],method:null,name:null,prodId:"//sebbo.net//ical-generator//EN",scale:null,source:null,timezone:null,ttl:null,url:null,x:[]},void 0!==t.prodId&&this.prodId(t.prodId),void 0!==t.method&&this.method(t.method),void 0!==t.name&&this.name(t.name),void 0!==t.description&&this.description(t.description),void 0!==t.timezone&&this.timezone(t.timezone),void 0!==t.source&&this.source(t.source),void 0!==t.url&&this.url(t.url),void 0!==t.scale&&this.scale(t.scale),void 0!==t.ttl&&this.ttl(t.ttl),void 0!==t.color&&this.color(t.color),void 0!==t.events&&this.events(t.events),void 0!==t.x&&this.x(t.x)}clear(){return this.data.events=[],this}color(t){if(void 0===t)return this.data.color;if("string"==typeof t&&!/^#[A-F0-9]{6}$/gi.test(t))throw Error("`color` is malformed!");return this.data.color=t?String(t).toUpperCase():null,this}createEvent(t){return t=t instanceof Q?t:new Q(t,this),this.data.events.push(t),t}description(t){return void 0===t?this.data.description:(this.data.description=t?String(t):null,this)}events(t){return t?(t.forEach(t=>this.createEvent(t)),this):this.data.events}length(){return this.data.events.length}method(t){return void 0===t?this.data.method:t?(this.data.method=s(k,t),this):(this.data.method=null,this)}name(t){return void 0===t?this.data.name:(this.data.name=t?String(t):null,this)}prodId(t){if(!t)return this.data.prodId;if("string"==typeof t)return this.data.prodId=t,this;if("object"!=typeof t)throw Error("`prodid` needs to be a string or an object!");if(!t.company)throw Error("`prodid.company` is a mandatory item!");if(!t.product)throw Error("`prodid.product` is a mandatory item!");var e=(t.language||"EN").toUpperCase();return this.data.prodId="//"+t.company+"//"+t.product+"//"+e,this}scale(t){return void 0===t?this.data.scale:(this.data.scale=null===t?null:t.toUpperCase(),this)}source(t){return void 0===t?this.data.source:(this.data.source=t||null,this)}timezone(t){return void 0===t?this.data.timezone?.name||null:(this.data.timezone="UTC"===t?null:"string"==typeof t?{name:t}:null===t?null:t,this)}toJSON(){return Object.assign({},this.data,{events:this.data.events.map(t=>t.toJSON()),timezone:this.timezone(),x:this.x()})}toString(){var t="";return t="BEGIN:VCALENDAR\r\nVERSION:2.0\r\n",t+="PRODID:-"+this.data.prodId+"\r\n",this.data.url&&(t+="URL:"+this.data.url+"\r\n"),this.data.source&&(t+="SOURCE;VALUE=URI:"+this.data.source+"\r\n"),this.data.scale&&(t+="CALSCALE:"+this.data.scale+"\r\n"),this.data.method&&(t+="METHOD:"+this.data.method+"\r\n"),this.data.name&&(t+="NAME:"+this.data.name+"\r\n",t+="X-WR-CALNAME:"+this.data.name+"\r\n"),this.data.description&&(t+="X-WR-CALDESC:"+this.data.description+"\r\n"),this.data.timezone?.generator&&[...new Set([this.timezone(),...this.data.events.map(t=>t.timezone())])].filter(t=>null!==t&&!t.startsWith("/")).forEach(e=>{this.data.timezone?.generator&&(e=this.data.timezone.generator(e))&&(t+=e.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n").trim()+"\r\n")}),this.data.timezone?.name&&(t+="TIMEZONE-ID:"+this.data.timezone.name+"\r\n",t+="X-WR-TIMEZONE:"+this.data.timezone.name+"\r\n"),this.data.ttl&&(t+="REFRESH-INTERVAL;VALUE=DURATION:"+b(this.data.ttl)+"\r\n",t+="X-PUBLISHED-TTL:"+b(this.data.ttl)+"\r\n"),this.data.color&&(t+="X-APPLE-CALENDAR-COLOR:"+this.data.color+"\r\n"),this.data.events.forEach(e=>t+=e.toString()),t+=c(this.data),function(t){return t.split("\r\n").map(function(t){var e;if(e=t.length<=74)t:{for(e=0;e<t.length;e++)if(t.charCodeAt(e)>127){e=!1;break t}e=!0}if(e)return t;e="";var a=0;for(let i=0;i<t.length;i++){let r,n=t.charAt(i),s=t.charCodeAt(i);s<128?r=1:s<2048?r=2:s>=55296&&s<=56319?(n+=t.charAt(++i),r=4):r=3,(a+=r)>74&&(e+="\r\n ",a=r),e+=n}return e}).join("\r\n")}(t+="END:VCALENDAR")}ttl(t){return void 0===t?this.data.ttl:("object"==typeof t&&t&&"asSeconds"in t&&"function"==typeof t.asSeconds?this.data.ttl=t.asSeconds():this.data.ttl=t&&t>0?t:null,this)}url(t){return void 0===t?this.data.url:(this.data.url=t||null,this)}x(t,e){if(void 0===t)return r(this.data);if("string"==typeof t&&"string"==typeof e)r(this.data,t,e);else{if("object"!=typeof t)throw Error("Either key or value is not a string!");r(this.data,t)}return this}};function $(t){if(t)return"string"==typeof t?new Date(t):t}export default class{pluginOptions;uuid;constructor(t,e){this.pluginOptions=t,this.uuid=e}configure(t){return t.data=this.generateEvent(),t.qrOptions.mode=void 0,t}generateEvent(){var t=new K({name:"QR calendar"}),{start:e,end:a,location:i,geo:r,organizer:n,...s}=this.pluginOptions,o="number"==typeof r?.lat&&"number"==typeof r.lon?r:void 0;return t.createEvent({...s,start:$(e),end:$(a),location:i?{title:i,geo:o}:o?{geo:o}:void 0,organizer:n?.email?{name:n.name||n.email,email:n.email}:void 0,id:this.uuid}).toString().split(/[\r\n]+/g).filter(t=>!t.startsWith("SEQUENCE:")&&!t.startsWith("DTSTAMP:")&&(this.uuid||!t.startsWith("UID:"))).join("\n")}}
2
2
  //# sourceMappingURL=event-plugin.js.map