From 450d6d8aaa3413569e2040702ab640d16297a87b Mon Sep 17 00:00:00 2001 From: Nathaniel Lin Date: Tue, 16 Jul 2024 11:36:27 +0800 Subject: [PATCH] v2.0.10 --- CHANGELOG.md | 6 + dist/package.json | 32 +- dist/tsdav.cjs | 39 +- dist/tsdav.cjs.js | 39 +- dist/tsdav.d.ts | 1000 ++++++++++++++++++++++++++++---------------- dist/tsdav.esm.js | 39 +- dist/tsdav.js | 52 +-- dist/tsdav.min.cjs | 2 +- dist/tsdav.min.js | 4 +- dist/tsdav.min.mjs | 2 +- dist/tsdav.mjs | 39 +- package.json | 32 +- src/client.ts | 1 + yarn.lock | 746 ++++++++++++++++++--------------- 14 files changed, 1203 insertions(+), 830 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ca179f..9499498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v2.0.10 + +**improvements** +- fixed [#191](https://github.com/natelindev/tsdav/issues/191) where `authFunction` is not properly assigned in constructor. +- updated deps. + ## v2.0.9 **improvements** diff --git a/dist/package.json b/dist/package.json index 7dfec20..da89243 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,6 +1,6 @@ { "name": "tsdav", - "version": "2.0.9", + "version": "2.0.10", "description": "WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser", "keywords": [ "dav", @@ -50,7 +50,7 @@ "dependencies": { "base-64": "1.0.0", "cross-fetch": "4.0.0", - "debug": "4.3.4", + "debug": "4.3.5", "xml-js": "1.6.11" }, "devDependencies": { @@ -60,31 +60,31 @@ "@types/base-64": "1.0.2", "@types/debug": "4.1.12", "@types/jest": "29.5.12", - "@types/node": "20.11.19", - "@typescript-eslint/eslint-plugin": "7.0.2", - "@typescript-eslint/parser": "7.0.2", + "@types/node": "20.14.10", + "@typescript-eslint/eslint-plugin": "7.16.1", + "@typescript-eslint/parser": "7.16.1", "copyfiles": "2.4.1", "cross-env": "7.0.3", "dotenv": "16.4.5", - "eslint": "8.56.0", + "eslint": "9.7.0", "eslint-config-airbnb": "19.0.4", - "eslint-config-airbnb-typescript": "17.1.0", + "eslint-config-airbnb-typescript": "18.0.0", "eslint-config-prettier": "9.1.0", - "eslint-module-utils": "2.8.0", + "eslint-module-utils": "2.8.1", "eslint-plugin-import": "2.29.1", "eslint-plugin-prettier": "5.1.3", "jest": "29.7.0", - "prettier": "3.2.5", - "rimraf": "5.0.5", - "rollup": "4.12.0", - "rollup-plugin-dts": "6.1.0", + "prettier": "3.3.3", + "rimraf": "5.0.7", + "rollup": "4.18.1", + "rollup-plugin-dts": "6.1.1", "rollup-plugin-node-builtins": "2.1.2", "rollup-plugin-polyfill-node": "0.13.0", "rollup-plugin-terser": "7.0.2", - "sort-package-json": "2.8.0", - "ts-jest": "29.1.2", - "tslib": "2.6.2", - "typescript": "5.3.3" + "sort-package-json": "2.10.0", + "ts-jest": "29.2.2", + "tslib": "2.6.3", + "typescript": "5.5.3" }, "engines": { "node": ">=10" diff --git a/dist/tsdav.cjs b/dist/tsdav.cjs index 1d71478..d7d21f9 100644 --- a/dist/tsdav.cjs +++ b/dist/tsdav.cjs @@ -400,7 +400,7 @@ const supportedReportSet = (params) => __awaiter(void 0, void 0, void 0, functio return ((_e = (_d = (_c = (_b = (_a = res[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.supportedReportSet) === null || _c === void 0 ? void 0 : _c.supportedReport) === null || _d === void 0 ? void 0 : _d.map((sr) => Object.keys(sr.report)[0])) !== null && _e !== void 0 ? _e : []); }); const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _f, _g, _h; + var _a, _b, _c; const { collection, headers, headersToExclude } = params; const responses = yield propfind({ url: collection.url, @@ -415,8 +415,8 @@ const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Collection does not exist on server'); } return { - isDirty: collection.ctag !== ((_f = res.props) === null || _f === void 0 ? void 0 : _f.getctag), - newCtag: (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.getctag) === null || _h === void 0 ? void 0 : _h.toString(), + isDirty: collection.ctag !== ((_a = res.props) === null || _a === void 0 ? void 0 : _a.getctag), + newCtag: (_c = (_b = res.props) === null || _b === void 0 ? void 0 : _b.getctag) === null || _c === void 0 ? void 0 : _c.toString(), }; }); /** @@ -447,7 +447,7 @@ const syncCollection = (params) => { }; /** remote collection to local */ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const { collection, method, headers, headersToExclude, account, detailedResult } = params; const requiredFields = ['accountType', 'homeUrl']; if (!account || !hasFields(account, requiredFields)) { @@ -456,7 +456,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi } throw new Error(`account must have ${findMissingFieldNames(account, requiredFields)} before smartCollectionSync`); } - const syncMethod = method !== null && method !== void 0 ? method : (((_j = collection.reports) === null || _j === void 0 ? void 0 : _j.includes('syncCollection')) ? 'webdav' : 'basic'); + const syncMethod = method !== null && method !== void 0 ? method : (((_a = collection.reports) === null || _a === void 0 ? void 0 : _a.includes('syncCollection')) ? 'webdav' : 'basic'); debug$4(`smart collection sync with type ${account.accountType} and method ${syncMethod}`); if (syncMethod === 'webdav') { const result = yield syncCollection({ @@ -478,7 +478,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi const changedObjectUrls = objectResponses.filter((o) => o.status !== 404).map((r) => r.href); const deletedObjectUrls = objectResponses.filter((o) => o.status === 404).map((r) => r.href); const multiGetObjectResponse = changedObjectUrls.length - ? (_l = (yield ((_k = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _k === void 0 ? void 0 : _k.call(collection, { + ? (_c = (yield ((_b = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _b === void 0 ? void 0 : _b.call(collection, { url: collection.url, props: { [`${exports.DAVNamespaceShort.DAV}:getetag`]: {}, @@ -489,7 +489,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi objectUrls: changedObjectUrls, depth: '1', headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _l !== void 0 ? _l : [] + })))) !== null && _c !== void 0 ? _c : [] : []; const remoteObjects = multiGetObjectResponse.map((res) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; @@ -501,7 +501,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi : (_j = (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.addressData) === null || _h === void 0 ? void 0 : _h._cdata) !== null && _j !== void 0 ? _j : (_k = res.props) === null || _k === void 0 ? void 0 : _k.addressData, }; }); - const localObjects = (_m = collection.objects) !== null && _m !== void 0 ? _m : []; + const localObjects = (_d = collection.objects) !== null && _d !== void 0 ? _d : []; // no existing url const created = remoteObjects.filter((o) => localObjects.every((lo) => !urlContains(lo.url, o.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -524,18 +524,18 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi ? { created, updated, deleted } : [...unchanged, ...created, ...updated], // all syncToken in the results are the same so we use the first one here - syncToken: (_r = (_q = (_p = (_o = result[0]) === null || _o === void 0 ? void 0 : _o.raw) === null || _p === void 0 ? void 0 : _p.multistatus) === null || _q === void 0 ? void 0 : _q.syncToken) !== null && _r !== void 0 ? _r : collection.syncToken }); + syncToken: (_h = (_g = (_f = (_e = result[0]) === null || _e === void 0 ? void 0 : _e.raw) === null || _f === void 0 ? void 0 : _f.multistatus) === null || _g === void 0 ? void 0 : _g.syncToken) !== null && _h !== void 0 ? _h : collection.syncToken }); } if (syncMethod === 'basic') { const { isDirty, newCtag } = yield isCollectionDirty({ collection, headers: excludeHeaders(headers, headersToExclude), }); - const localObjects = (_s = collection.objects) !== null && _s !== void 0 ? _s : []; - const remoteObjects = (_u = (yield ((_t = collection.fetchObjects) === null || _t === void 0 ? void 0 : _t.call(collection, { + const localObjects = (_j = collection.objects) !== null && _j !== void 0 ? _j : []; + const remoteObjects = (_l = (yield ((_k = collection.fetchObjects) === null || _k === void 0 ? void 0 : _k.call(collection, { collection, headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _u !== void 0 ? _u : []; + })))) !== null && _l !== void 0 ? _l : []; // no existing url const created = remoteObjects.filter((ro) => localObjects.every((lo) => !urlContains(lo.url, ro.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -1155,7 +1155,7 @@ const serviceDiscovery = (params) => __awaiter(void 0, void 0, void 0, function* return endpoint.href; }); const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _c, _d, _e, _f, _g; + var _a, _b, _c, _d, _e; const { account, headers, headersToExclude } = params; const requiredFields = ['rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1176,11 +1176,11 @@ const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Invalid credentials'); } } - debug$1(`Fetched principal url ${(_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href}`); - return new URL((_g = (_f = (_e = response.props) === null || _e === void 0 ? void 0 : _e.currentUserPrincipal) === null || _f === void 0 ? void 0 : _f.href) !== null && _g !== void 0 ? _g : '', account.rootUrl).href; + debug$1(`Fetched principal url ${(_b = (_a = response.props) === null || _a === void 0 ? void 0 : _a.currentUserPrincipal) === null || _b === void 0 ? void 0 : _b.href}`); + return new URL((_e = (_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '', account.rootUrl).href; }); const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _h, _j; + var _a, _b; const { account, headers, headersToExclude } = params; const requiredFields = ['principalUrl', 'rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1200,8 +1200,8 @@ const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () throw new Error('cannot find homeUrl'); } const result = new URL(account.accountType === 'caldav' - ? (_h = matched === null || matched === void 0 ? void 0 : matched.props) === null || _h === void 0 ? void 0 : _h.calendarHomeSet.href - : (_j = matched === null || matched === void 0 ? void 0 : matched.props) === null || _j === void 0 ? void 0 : _j.addressbookHomeSet.href, account.rootUrl).href; + ? (_a = matched === null || matched === void 0 ? void 0 : matched.props) === null || _a === void 0 ? void 0 : _a.calendarHomeSet.href + : (_b = matched === null || matched === void 0 ? void 0 : matched.props) === null || _b === void 0 ? void 0 : _b.addressbookHomeSet.href, account.rootUrl).href; debug$1(`Fetched home url ${result}`); return result; }); @@ -1516,10 +1516,11 @@ class DAVClient { this.credentials = params.credentials; this.authMethod = (_a = params.authMethod) !== null && _a !== void 0 ? _a : 'Basic'; this.accountType = (_b = params.defaultAccountType) !== null && _b !== void 0 ? _b : 'caldav'; + this.authFunction = params.authFunction; } login() { - var _a; return __awaiter(this, void 0, void 0, function* () { + var _a; switch (this.authMethod) { case 'Basic': this.authHeaders = getBasicAuthHeaders(this.credentials); diff --git a/dist/tsdav.cjs.js b/dist/tsdav.cjs.js index 1d71478..d7d21f9 100644 --- a/dist/tsdav.cjs.js +++ b/dist/tsdav.cjs.js @@ -400,7 +400,7 @@ const supportedReportSet = (params) => __awaiter(void 0, void 0, void 0, functio return ((_e = (_d = (_c = (_b = (_a = res[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.supportedReportSet) === null || _c === void 0 ? void 0 : _c.supportedReport) === null || _d === void 0 ? void 0 : _d.map((sr) => Object.keys(sr.report)[0])) !== null && _e !== void 0 ? _e : []); }); const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _f, _g, _h; + var _a, _b, _c; const { collection, headers, headersToExclude } = params; const responses = yield propfind({ url: collection.url, @@ -415,8 +415,8 @@ const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Collection does not exist on server'); } return { - isDirty: collection.ctag !== ((_f = res.props) === null || _f === void 0 ? void 0 : _f.getctag), - newCtag: (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.getctag) === null || _h === void 0 ? void 0 : _h.toString(), + isDirty: collection.ctag !== ((_a = res.props) === null || _a === void 0 ? void 0 : _a.getctag), + newCtag: (_c = (_b = res.props) === null || _b === void 0 ? void 0 : _b.getctag) === null || _c === void 0 ? void 0 : _c.toString(), }; }); /** @@ -447,7 +447,7 @@ const syncCollection = (params) => { }; /** remote collection to local */ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const { collection, method, headers, headersToExclude, account, detailedResult } = params; const requiredFields = ['accountType', 'homeUrl']; if (!account || !hasFields(account, requiredFields)) { @@ -456,7 +456,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi } throw new Error(`account must have ${findMissingFieldNames(account, requiredFields)} before smartCollectionSync`); } - const syncMethod = method !== null && method !== void 0 ? method : (((_j = collection.reports) === null || _j === void 0 ? void 0 : _j.includes('syncCollection')) ? 'webdav' : 'basic'); + const syncMethod = method !== null && method !== void 0 ? method : (((_a = collection.reports) === null || _a === void 0 ? void 0 : _a.includes('syncCollection')) ? 'webdav' : 'basic'); debug$4(`smart collection sync with type ${account.accountType} and method ${syncMethod}`); if (syncMethod === 'webdav') { const result = yield syncCollection({ @@ -478,7 +478,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi const changedObjectUrls = objectResponses.filter((o) => o.status !== 404).map((r) => r.href); const deletedObjectUrls = objectResponses.filter((o) => o.status === 404).map((r) => r.href); const multiGetObjectResponse = changedObjectUrls.length - ? (_l = (yield ((_k = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _k === void 0 ? void 0 : _k.call(collection, { + ? (_c = (yield ((_b = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _b === void 0 ? void 0 : _b.call(collection, { url: collection.url, props: { [`${exports.DAVNamespaceShort.DAV}:getetag`]: {}, @@ -489,7 +489,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi objectUrls: changedObjectUrls, depth: '1', headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _l !== void 0 ? _l : [] + })))) !== null && _c !== void 0 ? _c : [] : []; const remoteObjects = multiGetObjectResponse.map((res) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; @@ -501,7 +501,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi : (_j = (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.addressData) === null || _h === void 0 ? void 0 : _h._cdata) !== null && _j !== void 0 ? _j : (_k = res.props) === null || _k === void 0 ? void 0 : _k.addressData, }; }); - const localObjects = (_m = collection.objects) !== null && _m !== void 0 ? _m : []; + const localObjects = (_d = collection.objects) !== null && _d !== void 0 ? _d : []; // no existing url const created = remoteObjects.filter((o) => localObjects.every((lo) => !urlContains(lo.url, o.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -524,18 +524,18 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi ? { created, updated, deleted } : [...unchanged, ...created, ...updated], // all syncToken in the results are the same so we use the first one here - syncToken: (_r = (_q = (_p = (_o = result[0]) === null || _o === void 0 ? void 0 : _o.raw) === null || _p === void 0 ? void 0 : _p.multistatus) === null || _q === void 0 ? void 0 : _q.syncToken) !== null && _r !== void 0 ? _r : collection.syncToken }); + syncToken: (_h = (_g = (_f = (_e = result[0]) === null || _e === void 0 ? void 0 : _e.raw) === null || _f === void 0 ? void 0 : _f.multistatus) === null || _g === void 0 ? void 0 : _g.syncToken) !== null && _h !== void 0 ? _h : collection.syncToken }); } if (syncMethod === 'basic') { const { isDirty, newCtag } = yield isCollectionDirty({ collection, headers: excludeHeaders(headers, headersToExclude), }); - const localObjects = (_s = collection.objects) !== null && _s !== void 0 ? _s : []; - const remoteObjects = (_u = (yield ((_t = collection.fetchObjects) === null || _t === void 0 ? void 0 : _t.call(collection, { + const localObjects = (_j = collection.objects) !== null && _j !== void 0 ? _j : []; + const remoteObjects = (_l = (yield ((_k = collection.fetchObjects) === null || _k === void 0 ? void 0 : _k.call(collection, { collection, headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _u !== void 0 ? _u : []; + })))) !== null && _l !== void 0 ? _l : []; // no existing url const created = remoteObjects.filter((ro) => localObjects.every((lo) => !urlContains(lo.url, ro.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -1155,7 +1155,7 @@ const serviceDiscovery = (params) => __awaiter(void 0, void 0, void 0, function* return endpoint.href; }); const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _c, _d, _e, _f, _g; + var _a, _b, _c, _d, _e; const { account, headers, headersToExclude } = params; const requiredFields = ['rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1176,11 +1176,11 @@ const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Invalid credentials'); } } - debug$1(`Fetched principal url ${(_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href}`); - return new URL((_g = (_f = (_e = response.props) === null || _e === void 0 ? void 0 : _e.currentUserPrincipal) === null || _f === void 0 ? void 0 : _f.href) !== null && _g !== void 0 ? _g : '', account.rootUrl).href; + debug$1(`Fetched principal url ${(_b = (_a = response.props) === null || _a === void 0 ? void 0 : _a.currentUserPrincipal) === null || _b === void 0 ? void 0 : _b.href}`); + return new URL((_e = (_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '', account.rootUrl).href; }); const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _h, _j; + var _a, _b; const { account, headers, headersToExclude } = params; const requiredFields = ['principalUrl', 'rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1200,8 +1200,8 @@ const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () throw new Error('cannot find homeUrl'); } const result = new URL(account.accountType === 'caldav' - ? (_h = matched === null || matched === void 0 ? void 0 : matched.props) === null || _h === void 0 ? void 0 : _h.calendarHomeSet.href - : (_j = matched === null || matched === void 0 ? void 0 : matched.props) === null || _j === void 0 ? void 0 : _j.addressbookHomeSet.href, account.rootUrl).href; + ? (_a = matched === null || matched === void 0 ? void 0 : matched.props) === null || _a === void 0 ? void 0 : _a.calendarHomeSet.href + : (_b = matched === null || matched === void 0 ? void 0 : matched.props) === null || _b === void 0 ? void 0 : _b.addressbookHomeSet.href, account.rootUrl).href; debug$1(`Fetched home url ${result}`); return result; }); @@ -1516,10 +1516,11 @@ class DAVClient { this.credentials = params.credentials; this.authMethod = (_a = params.authMethod) !== null && _a !== void 0 ? _a : 'Basic'; this.accountType = (_b = params.defaultAccountType) !== null && _b !== void 0 ? _b : 'caldav'; + this.authFunction = params.authFunction; } login() { - var _a; return __awaiter(this, void 0, void 0, function* () { + var _a; switch (this.authMethod) { case 'Basic': this.authHeaders = getBasicAuthHeaders(this.credentials); diff --git a/dist/tsdav.d.ts b/dist/tsdav.d.ts index 30a48e8..f7e3dbe 100644 --- a/dist/tsdav.d.ts +++ b/dist/tsdav.d.ts @@ -194,11 +194,11 @@ declare const fetchAddressBooks: (params?: { }) => Promise; declare const fetchVCards: (params: { addressBook: DAVAddressBook; - headers?: Record | undefined; - objectUrls?: string[] | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - useMultiGet?: boolean | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; }) => Promise; declare const createVCard: (params: { addressBook: DAVAddressBook; @@ -253,17 +253,17 @@ declare const fetchCalendars: (params?: { }) => Promise; declare const fetchCalendarObjects: (params: { calendar: DAVCalendar; - objectUrls?: string[] | undefined; - filters?: ElementCompact | undefined; + objectUrls?: string[]; + filters?: ElementCompact; timeRange?: { start: string; end: string; - } | undefined; - expand?: boolean | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - useMultiGet?: boolean | undefined; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; }) => Promise; declare const createCalendarObject: (params: { calendar: DAVCalendar; @@ -375,9 +375,9 @@ declare const deleteObject: (params: { declare const createDAVClient: (params: { serverUrl: string; credentials: DAVCredentials; - authMethod?: "Basic" | "Oauth" | "Digest" | "Custom" | undefined; - authFunction?: ((credentials: DAVCredentials) => Promise>) | undefined; - defaultAccountType?: DAVAccount['accountType'] | undefined; + authMethod?: "Basic" | "Oauth" | "Digest" | "Custom"; + authFunction?: (credentials: DAVCredentials) => Promise>; + defaultAccountType?: DAVAccount["accountType"] | undefined; }) => Promise<{ davRequest: (params0: { url: string; @@ -388,12 +388,18 @@ declare const createDAVClient: (params: { propfind: (params: { url: string; props: xml_js.ElementCompact; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; createAccount: (params0: { - account: Optional; + account: Optional; headers?: Record; loadCollections?: boolean; loadObjects?: boolean; @@ -401,170 +407,309 @@ declare const createDAVClient: (params: { createObject: (params: { url: string; data: BodyInit; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + data: BodyInit; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; updateObject: (params: { url: string; data: BodyInit; - etag?: string | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + data: BodyInit; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; deleteObject: (params: { url: string; - etag?: string | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; calendarQuery: (params: { url: string; props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact | undefined; - timezone?: string | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + filters?: xml_js.ElementCompact; + timezone?: string; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + filters?: xml_js.ElementCompact; + timezone?: string; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; addressBookQuery: (params: { url: string; props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + filters?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + filters?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; collectionQuery: (params: { url: string; body: any; - depth?: DAVDepth | undefined; - defaultNamespace?: DAVNamespaceShort | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + depth?: DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + body: any; + depth?: DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; makeCollection: (params: { url: string; - props?: xml_js.ElementCompact | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + props?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; calendarMultiGet: (params: { url: string; props: xml_js.ElementCompact; - objectUrls?: string[] | undefined; - timezone?: string | undefined; + objectUrls?: string[]; + timezone?: string; depth: DAVDepth; - filters?: xml_js.ElementCompact | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + filters?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + objectUrls?: string[]; + timezone?: string; + depth: DAVDepth; + filters?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; makeCalendar: (params: { url: string; props: xml_js.ElementCompact; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; syncCollection: (params: { url: string; props: xml_js.ElementCompact; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - syncLevel?: number | undefined; - syncToken?: string | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + }) => Promise>; supportedReportSet: (params: { collection: DAVCollection; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; isCollectionDirty: (params: { collection: DAVCollection; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; }) => Promise<{ isDirty: boolean; newCtag: string; - }>; + }>>; smartCollectionSync: SmartCollectionSync; fetchCalendars: (params?: { - account?: DAVAccount | undefined; - props?: xml_js.ElementCompact | undefined; - projectedProps?: Record | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - } | undefined) => Promise; + account?: DAVAccount; + props?: xml_js.ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + } | undefined) => ReturnType<(params?: { + account?: DAVAccount; + props?: xml_js.ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; fetchCalendarObjects: (params: { calendar: DAVCalendar; - objectUrls?: string[] | undefined; - filters?: xml_js.ElementCompact | undefined; + objectUrls?: string[]; + filters?: xml_js.ElementCompact; + timeRange?: { + start: string; + end: string; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + }) => ReturnType<(params: { + calendar: DAVCalendar; + objectUrls?: string[]; + filters?: xml_js.ElementCompact; timeRange?: { start: string; end: string; - } | undefined; - expand?: boolean | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - useMultiGet?: boolean | undefined; - }) => Promise; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + }) => Promise>; createCalendarObject: (params: { calendar: DAVCalendar; iCalString: string; filename: string; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + calendar: DAVCalendar; + iCalString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; updateCalendarObject: (params: { - calendarObject: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; deleteCalendarObject: (params: { - calendarObject: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; syncCalendars: SyncCalendars; fetchAddressBooks: (params?: { - account?: DAVAccount | undefined; - props?: xml_js.ElementCompact | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - } | undefined) => Promise; + account?: DAVAccount; + props?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + } | undefined) => ReturnType<(params?: { + account?: DAVAccount; + props?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; addressBookMultiGet: (params: { url: string; props: xml_js.ElementCompact; objectUrls: string[]; depth: DAVDepth; - headers?: Record | undefined; - }) => Promise; + headers?: Record; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + objectUrls: string[]; + depth: DAVDepth; + headers?: Record; + }) => Promise>; fetchVCards: (params: { - addressBook: DAVCollection; - headers?: Record | undefined; - objectUrls?: string[] | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - useMultiGet?: boolean | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + }) => ReturnType<(params: { + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + }) => Promise>; createVCard: (params: { - addressBook: DAVCollection; + addressBook: DAVAddressBook; vCardString: string; filename: string; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + addressBook: DAVAddressBook; + vCardString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; updateVCard: (params: { - vCard: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; deleteVCard: (params: { - vCard: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; }>; declare class DAVClient { serverUrl: string; @@ -656,94 +801,94 @@ declare const getDAVAttribute: (nsArr: DAVNamespace[]) => { declare const cleanupFalsy: (obj: T) => NoUndefinedField; declare const _default: { - urlEquals: (urlA?: string | undefined, urlB?: string | undefined) => boolean; - urlContains: (urlA?: string | undefined, urlB?: string | undefined) => boolean; + urlEquals: (urlA?: string, urlB?: string) => boolean; + urlContains: (urlA?: string, urlB?: string) => boolean; getDAVAttribute: (nsArr: DAVNamespace[]) => { [key: string]: DAVNamespace; }; cleanupFalsy: (obj: T) => NoUndefinedField; - conditionalParam: (key: string, param: T_1) => { - [key: string]: T_1; + conditionalParam: (key: string, param: T) => { + [key: string]: T; }; excludeHeaders: (headers: Record | undefined, headersToExclude: string[] | undefined) => Record; defaultParam: any>(fn: F, params: Partial[0]>) => (...args: Parameters) => ReturnType; getBasicAuthHeaders: (credentials: DAVCredentials) => { - authorization?: string | undefined; + authorization?: string; }; fetchOauthTokens: (credentials: DAVCredentials) => Promise; refreshAccessToken: (credentials: DAVCredentials) => Promise<{ - access_token?: string | undefined; - expires_in?: number | undefined; + access_token?: string; + expires_in?: number; }>; getOauthHeaders: (credentials: DAVCredentials) => Promise<{ tokens: DAVTokens; headers: { - authorization?: string | undefined; + authorization?: string; }; }>; calendarQuery: (params: { url: string; props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact | undefined; - timezone?: string | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + filters?: xml_js.ElementCompact; + timezone?: string; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; }) => Promise; calendarMultiGet: (params: { url: string; props: xml_js.ElementCompact; - objectUrls?: string[] | undefined; - timezone?: string | undefined; + objectUrls?: string[]; + timezone?: string; depth: DAVDepth; - filters?: xml_js.ElementCompact | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + filters?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; }) => Promise; makeCalendar: (params: { url: string; props: xml_js.ElementCompact; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; }) => Promise; fetchCalendars: (params?: { - account?: DAVAccount | undefined; - props?: xml_js.ElementCompact | undefined; - projectedProps?: Record | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - } | undefined) => Promise; + account?: DAVAccount; + props?: xml_js.ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + }) => Promise; fetchCalendarObjects: (params: { calendar: DAVCalendar; - objectUrls?: string[] | undefined; - filters?: xml_js.ElementCompact | undefined; + objectUrls?: string[]; + filters?: xml_js.ElementCompact; timeRange?: { start: string; end: string; - } | undefined; - expand?: boolean | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - useMultiGet?: boolean | undefined; - }) => Promise; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + }) => Promise; createCalendarObject: (params: { calendar: DAVCalendar; iCalString: string; filename: string; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; updateCalendarObject: (params: { - calendarObject: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; }) => Promise; deleteCalendarObject: (params: { - calendarObject: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; }) => Promise; syncCalendars: SyncCalendars; freeBusyQuery: (params: { @@ -752,102 +897,102 @@ declare const _default: { start: string; end: string; }; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; }) => Promise; addressBookQuery: (params: { url: string; props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + filters?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; }) => Promise; addressBookMultiGet: (params: { url: string; props: xml_js.ElementCompact; objectUrls: string[]; depth: DAVDepth; - headers?: Record | undefined; + headers?: Record; }) => Promise; fetchAddressBooks: (params?: { - account?: DAVAccount | undefined; - props?: xml_js.ElementCompact | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - } | undefined) => Promise; + account?: DAVAccount; + props?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => Promise; fetchVCards: (params: { - addressBook: DAVCollection; - headers?: Record | undefined; - objectUrls?: string[] | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - useMultiGet?: boolean | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + }) => Promise; createVCard: (params: { - addressBook: DAVCollection; + addressBook: DAVAddressBook; vCardString: string; filename: string; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; updateVCard: (params: { - vCard: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; }) => Promise; deleteVCard: (params: { - vCard: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; }) => Promise; serviceDiscovery: (params: { account: DAVAccount; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; fetchPrincipalUrl: (params: { account: DAVAccount; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; fetchHomeUrl: (params: { account: DAVAccount; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; createAccount: (params: { account: DAVAccount; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - loadCollections?: boolean | undefined; - loadObjects?: boolean | undefined; + headers?: Record; + headersToExclude?: string[]; + loadCollections?: boolean; + loadObjects?: boolean; }) => Promise; collectionQuery: (params: { url: string; body: any; - depth?: DAVDepth | undefined; - defaultNamespace?: DAVNamespaceShort | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + depth?: DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; }) => Promise; makeCollection: (params: { url: string; - props?: xml_js.ElementCompact | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + props?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; }) => Promise; supportedReportSet: (params: { collection: DAVCollection; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; isCollectionDirty: (params: { collection: DAVCollection; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise<{ isDirty: boolean; newCtag: string; @@ -855,237 +1000,382 @@ declare const _default: { syncCollection: (params: { url: string; props: xml_js.ElementCompact; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - syncLevel?: number | undefined; - syncToken?: string | undefined; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; }) => Promise; smartCollectionSync: SmartCollectionSync; davRequest: (params: { url: string; init: DAVRequest; - convertIncoming?: boolean | undefined; - parseOutgoing?: boolean | undefined; + convertIncoming?: boolean; + parseOutgoing?: boolean; }) => Promise; propfind: (params: { url: string; props: xml_js.ElementCompact; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; }) => Promise; createObject: (params: { url: string; data: BodyInit; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; }) => Promise; updateObject: (params: { url: string; data: BodyInit; - etag?: string | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + etag?: string; + headers?: Record; + headersToExclude?: string[]; }) => Promise; deleteObject: (params: { url: string; - etag?: string | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + etag?: string; + headers?: Record; + headersToExclude?: string[]; }) => Promise; createDAVClient: (params: { serverUrl: string; credentials: DAVCredentials; - authMethod?: "Basic" | "Oauth" | "Digest" | "Custom" | undefined; - authFunction?: ((credentials: DAVCredentials) => Promise>) | undefined; - defaultAccountType?: "caldav" | "carddav" | undefined; + authMethod?: "Basic" | "Oauth" | "Digest" | "Custom"; + authFunction?: (credentials: DAVCredentials) => Promise>; + defaultAccountType?: DAVAccount["accountType"] | undefined; }) => Promise<{ davRequest: (params0: { url: string; init: DAVRequest; - convertIncoming?: boolean | undefined; - parseOutgoing?: boolean | undefined; + convertIncoming?: boolean; + parseOutgoing?: boolean; }) => Promise; propfind: (params: { url: string; props: xml_js.ElementCompact; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; createAccount: (params0: { account: Optional; - headers?: Record | undefined; - loadCollections?: boolean | undefined; - loadObjects?: boolean | undefined; + headers?: Record; + loadCollections?: boolean; + loadObjects?: boolean; }) => Promise; createObject: (params: { url: string; data: BodyInit; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + data: BodyInit; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; updateObject: (params: { url: string; data: BodyInit; - etag?: string | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + data: BodyInit; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; deleteObject: (params: { url: string; - etag?: string | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; calendarQuery: (params: { url: string; props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact | undefined; - timezone?: string | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + filters?: xml_js.ElementCompact; + timezone?: string; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + filters?: xml_js.ElementCompact; + timezone?: string; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; addressBookQuery: (params: { url: string; props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + filters?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + filters?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; collectionQuery: (params: { url: string; body: any; - depth?: DAVDepth | undefined; - defaultNamespace?: DAVNamespaceShort | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + depth?: DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + body: any; + depth?: DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; makeCollection: (params: { url: string; - props?: xml_js.ElementCompact | undefined; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + props?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props?: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; calendarMultiGet: (params: { url: string; props: xml_js.ElementCompact; - objectUrls?: string[] | undefined; - timezone?: string | undefined; + objectUrls?: string[]; + timezone?: string; depth: DAVDepth; - filters?: xml_js.ElementCompact | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + filters?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + objectUrls?: string[]; + timezone?: string; + depth: DAVDepth; + filters?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; makeCalendar: (params: { url: string; props: xml_js.ElementCompact; - depth?: DAVDepth | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; syncCollection: (params: { url: string; props: xml_js.ElementCompact; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - syncLevel?: number | undefined; - syncToken?: string | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + }) => Promise>; supportedReportSet: (params: { collection: DAVCollection; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; isCollectionDirty: (params: { collection: DAVCollection; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; }) => Promise<{ isDirty: boolean; newCtag: string; - }>; + }>>; smartCollectionSync: SmartCollectionSync; fetchCalendars: (params?: { - account?: DAVAccount | undefined; - props?: xml_js.ElementCompact | undefined; - projectedProps?: Record | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - } | undefined) => Promise; + account?: DAVAccount; + props?: xml_js.ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + } | undefined) => ReturnType<(params?: { + account?: DAVAccount; + props?: xml_js.ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; fetchCalendarObjects: (params: { calendar: DAVCalendar; - objectUrls?: string[] | undefined; - filters?: xml_js.ElementCompact | undefined; + objectUrls?: string[]; + filters?: xml_js.ElementCompact; + timeRange?: { + start: string; + end: string; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + }) => ReturnType<(params: { + calendar: DAVCalendar; + objectUrls?: string[]; + filters?: xml_js.ElementCompact; timeRange?: { start: string; end: string; - } | undefined; - expand?: boolean | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - useMultiGet?: boolean | undefined; - }) => Promise; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + }) => Promise>; createCalendarObject: (params: { calendar: DAVCalendar; iCalString: string; filename: string; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + calendar: DAVCalendar; + iCalString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; updateCalendarObject: (params: { - calendarObject: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; deleteCalendarObject: (params: { - calendarObject: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; syncCalendars: SyncCalendars; fetchAddressBooks: (params?: { - account?: DAVAccount | undefined; - props?: xml_js.ElementCompact | undefined; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - } | undefined) => Promise; + account?: DAVAccount; + props?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + } | undefined) => ReturnType<(params?: { + account?: DAVAccount; + props?: xml_js.ElementCompact; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; addressBookMultiGet: (params: { url: string; props: xml_js.ElementCompact; objectUrls: string[]; depth: DAVDepth; - headers?: Record | undefined; - }) => Promise; + headers?: Record; + }) => ReturnType<(params: { + url: string; + props: xml_js.ElementCompact; + objectUrls: string[]; + depth: DAVDepth; + headers?: Record; + }) => Promise>; fetchVCards: (params: { - addressBook: DAVCollection; - headers?: Record | undefined; - objectUrls?: string[] | undefined; - urlFilter?: ((url: string) => boolean) | undefined; - useMultiGet?: boolean | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + }) => ReturnType<(params: { + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + }) => Promise>; createVCard: (params: { - addressBook: DAVCollection; + addressBook: DAVAddressBook; + vCardString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + addressBook: DAVAddressBook; vCardString: string; filename: string; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; updateVCard: (params: { - vCard: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; deleteVCard: (params: { - vCard: DAVObject; - headers?: Record | undefined; - headersToExclude?: string[] | undefined; - }) => Promise; + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => ReturnType<(params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + }) => Promise>; }>; DAVClient: typeof DAVClient; DAVNamespace: typeof DAVNamespace; diff --git a/dist/tsdav.esm.js b/dist/tsdav.esm.js index 64f08c0..030eec9 100644 --- a/dist/tsdav.esm.js +++ b/dist/tsdav.esm.js @@ -396,7 +396,7 @@ const supportedReportSet = (params) => __awaiter(void 0, void 0, void 0, functio return ((_e = (_d = (_c = (_b = (_a = res[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.supportedReportSet) === null || _c === void 0 ? void 0 : _c.supportedReport) === null || _d === void 0 ? void 0 : _d.map((sr) => Object.keys(sr.report)[0])) !== null && _e !== void 0 ? _e : []); }); const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _f, _g, _h; + var _a, _b, _c; const { collection, headers, headersToExclude } = params; const responses = yield propfind({ url: collection.url, @@ -411,8 +411,8 @@ const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Collection does not exist on server'); } return { - isDirty: collection.ctag !== ((_f = res.props) === null || _f === void 0 ? void 0 : _f.getctag), - newCtag: (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.getctag) === null || _h === void 0 ? void 0 : _h.toString(), + isDirty: collection.ctag !== ((_a = res.props) === null || _a === void 0 ? void 0 : _a.getctag), + newCtag: (_c = (_b = res.props) === null || _b === void 0 ? void 0 : _b.getctag) === null || _c === void 0 ? void 0 : _c.toString(), }; }); /** @@ -443,7 +443,7 @@ const syncCollection = (params) => { }; /** remote collection to local */ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const { collection, method, headers, headersToExclude, account, detailedResult } = params; const requiredFields = ['accountType', 'homeUrl']; if (!account || !hasFields(account, requiredFields)) { @@ -452,7 +452,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi } throw new Error(`account must have ${findMissingFieldNames(account, requiredFields)} before smartCollectionSync`); } - const syncMethod = method !== null && method !== void 0 ? method : (((_j = collection.reports) === null || _j === void 0 ? void 0 : _j.includes('syncCollection')) ? 'webdav' : 'basic'); + const syncMethod = method !== null && method !== void 0 ? method : (((_a = collection.reports) === null || _a === void 0 ? void 0 : _a.includes('syncCollection')) ? 'webdav' : 'basic'); debug$4(`smart collection sync with type ${account.accountType} and method ${syncMethod}`); if (syncMethod === 'webdav') { const result = yield syncCollection({ @@ -474,7 +474,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi const changedObjectUrls = objectResponses.filter((o) => o.status !== 404).map((r) => r.href); const deletedObjectUrls = objectResponses.filter((o) => o.status === 404).map((r) => r.href); const multiGetObjectResponse = changedObjectUrls.length - ? (_l = (yield ((_k = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _k === void 0 ? void 0 : _k.call(collection, { + ? (_c = (yield ((_b = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _b === void 0 ? void 0 : _b.call(collection, { url: collection.url, props: { [`${DAVNamespaceShort.DAV}:getetag`]: {}, @@ -485,7 +485,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi objectUrls: changedObjectUrls, depth: '1', headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _l !== void 0 ? _l : [] + })))) !== null && _c !== void 0 ? _c : [] : []; const remoteObjects = multiGetObjectResponse.map((res) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; @@ -497,7 +497,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi : (_j = (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.addressData) === null || _h === void 0 ? void 0 : _h._cdata) !== null && _j !== void 0 ? _j : (_k = res.props) === null || _k === void 0 ? void 0 : _k.addressData, }; }); - const localObjects = (_m = collection.objects) !== null && _m !== void 0 ? _m : []; + const localObjects = (_d = collection.objects) !== null && _d !== void 0 ? _d : []; // no existing url const created = remoteObjects.filter((o) => localObjects.every((lo) => !urlContains(lo.url, o.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -520,18 +520,18 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi ? { created, updated, deleted } : [...unchanged, ...created, ...updated], // all syncToken in the results are the same so we use the first one here - syncToken: (_r = (_q = (_p = (_o = result[0]) === null || _o === void 0 ? void 0 : _o.raw) === null || _p === void 0 ? void 0 : _p.multistatus) === null || _q === void 0 ? void 0 : _q.syncToken) !== null && _r !== void 0 ? _r : collection.syncToken }); + syncToken: (_h = (_g = (_f = (_e = result[0]) === null || _e === void 0 ? void 0 : _e.raw) === null || _f === void 0 ? void 0 : _f.multistatus) === null || _g === void 0 ? void 0 : _g.syncToken) !== null && _h !== void 0 ? _h : collection.syncToken }); } if (syncMethod === 'basic') { const { isDirty, newCtag } = yield isCollectionDirty({ collection, headers: excludeHeaders(headers, headersToExclude), }); - const localObjects = (_s = collection.objects) !== null && _s !== void 0 ? _s : []; - const remoteObjects = (_u = (yield ((_t = collection.fetchObjects) === null || _t === void 0 ? void 0 : _t.call(collection, { + const localObjects = (_j = collection.objects) !== null && _j !== void 0 ? _j : []; + const remoteObjects = (_l = (yield ((_k = collection.fetchObjects) === null || _k === void 0 ? void 0 : _k.call(collection, { collection, headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _u !== void 0 ? _u : []; + })))) !== null && _l !== void 0 ? _l : []; // no existing url const created = remoteObjects.filter((ro) => localObjects.every((lo) => !urlContains(lo.url, ro.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -1151,7 +1151,7 @@ const serviceDiscovery = (params) => __awaiter(void 0, void 0, void 0, function* return endpoint.href; }); const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _c, _d, _e, _f, _g; + var _a, _b, _c, _d, _e; const { account, headers, headersToExclude } = params; const requiredFields = ['rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1172,11 +1172,11 @@ const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Invalid credentials'); } } - debug$1(`Fetched principal url ${(_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href}`); - return new URL((_g = (_f = (_e = response.props) === null || _e === void 0 ? void 0 : _e.currentUserPrincipal) === null || _f === void 0 ? void 0 : _f.href) !== null && _g !== void 0 ? _g : '', account.rootUrl).href; + debug$1(`Fetched principal url ${(_b = (_a = response.props) === null || _a === void 0 ? void 0 : _a.currentUserPrincipal) === null || _b === void 0 ? void 0 : _b.href}`); + return new URL((_e = (_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '', account.rootUrl).href; }); const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _h, _j; + var _a, _b; const { account, headers, headersToExclude } = params; const requiredFields = ['principalUrl', 'rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1196,8 +1196,8 @@ const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () throw new Error('cannot find homeUrl'); } const result = new URL(account.accountType === 'caldav' - ? (_h = matched === null || matched === void 0 ? void 0 : matched.props) === null || _h === void 0 ? void 0 : _h.calendarHomeSet.href - : (_j = matched === null || matched === void 0 ? void 0 : matched.props) === null || _j === void 0 ? void 0 : _j.addressbookHomeSet.href, account.rootUrl).href; + ? (_a = matched === null || matched === void 0 ? void 0 : matched.props) === null || _a === void 0 ? void 0 : _a.calendarHomeSet.href + : (_b = matched === null || matched === void 0 ? void 0 : matched.props) === null || _b === void 0 ? void 0 : _b.addressbookHomeSet.href, account.rootUrl).href; debug$1(`Fetched home url ${result}`); return result; }); @@ -1512,10 +1512,11 @@ class DAVClient { this.credentials = params.credentials; this.authMethod = (_a = params.authMethod) !== null && _a !== void 0 ? _a : 'Basic'; this.accountType = (_b = params.defaultAccountType) !== null && _b !== void 0 ? _b : 'caldav'; + this.authFunction = params.authFunction; } login() { - var _a; return __awaiter(this, void 0, void 0, function* () { + var _a; switch (this.authMethod) { case 'Basic': this.authHeaders = getBasicAuthHeaders(this.credentials); diff --git a/dist/tsdav.js b/dist/tsdav.js index 7e423a9..ecd9e52 100644 --- a/dist/tsdav.js +++ b/dist/tsdav.js @@ -4180,7 +4180,6 @@ if (typeof Object.create === 'function'){ ctor.prototype.constructor = ctor; }; } -var inherits$1 = inherits; var formatRegExp = /%[sdj%]/g; function format(f) { @@ -4950,7 +4949,7 @@ var _polyfillNode_string_decoder = /*#__PURE__*/Object.freeze({ Readable.ReadableState = ReadableState; var debug$6 = debuglog('stream'); -inherits$1(Readable, EventEmitter); +inherits(Readable, EventEmitter); function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own @@ -5839,7 +5838,7 @@ function indexOf(xs, x) { // the drain event emission and buffering. Writable.WritableState = WritableState; -inherits$1(Writable, EventEmitter); +inherits(Writable, EventEmitter); function nop() {} @@ -6310,7 +6309,7 @@ function CorkedRequest(state) { }; } -inherits$1(Duplex, Readable); +inherits(Duplex, Readable); var keys = Object.keys(Writable.prototype); for (var v = 0; v < keys.length; v++) { @@ -6390,7 +6389,7 @@ function onEndNT(self) { // would be consumed, and then the rest would wait (un-transformed) until // the results of the previous transformed chunk were consumed. -inherits$1(Transform, Duplex); +inherits(Transform, Duplex); function TransformState(stream) { this.afterTransform = function (er, data) { @@ -6517,7 +6516,7 @@ function done(stream, er) { return stream.push(null); } -inherits$1(PassThrough, Transform); +inherits(PassThrough, Transform); function PassThrough(options) { if (!(this instanceof PassThrough)) return new PassThrough(options); @@ -6528,7 +6527,7 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -inherits$1(Stream, EventEmitter); +inherits(Stream, EventEmitter); Stream.Readable = Readable; Stream.Writable = Writable; Stream.Duplex = Duplex; @@ -9308,7 +9307,7 @@ const supportedReportSet = (params) => __awaiter(void 0, void 0, void 0, functio return ((_e = (_d = (_c = (_b = (_a = res[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.supportedReportSet) === null || _c === void 0 ? void 0 : _c.supportedReport) === null || _d === void 0 ? void 0 : _d.map((sr) => Object.keys(sr.report)[0])) !== null && _e !== void 0 ? _e : []); }); const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _f, _g, _h; + var _a, _b, _c; const { collection, headers, headersToExclude } = params; const responses = yield propfind({ url: collection.url, @@ -9323,8 +9322,8 @@ const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Collection does not exist on server'); } return { - isDirty: collection.ctag !== ((_f = res.props) === null || _f === void 0 ? void 0 : _f.getctag), - newCtag: (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.getctag) === null || _h === void 0 ? void 0 : _h.toString(), + isDirty: collection.ctag !== ((_a = res.props) === null || _a === void 0 ? void 0 : _a.getctag), + newCtag: (_c = (_b = res.props) === null || _b === void 0 ? void 0 : _b.getctag) === null || _c === void 0 ? void 0 : _c.toString(), }; }); /** @@ -9355,7 +9354,7 @@ const syncCollection = (params) => { }; /** remote collection to local */ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const { collection, method, headers, headersToExclude, account, detailedResult } = params; const requiredFields = ['accountType', 'homeUrl']; if (!account || !hasFields(account, requiredFields)) { @@ -9364,7 +9363,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi } throw new Error(`account must have ${findMissingFieldNames(account, requiredFields)} before smartCollectionSync`); } - const syncMethod = method !== null && method !== void 0 ? method : (((_j = collection.reports) === null || _j === void 0 ? void 0 : _j.includes('syncCollection')) ? 'webdav' : 'basic'); + const syncMethod = method !== null && method !== void 0 ? method : (((_a = collection.reports) === null || _a === void 0 ? void 0 : _a.includes('syncCollection')) ? 'webdav' : 'basic'); debug$4(`smart collection sync with type ${account.accountType} and method ${syncMethod}`); if (syncMethod === 'webdav') { const result = yield syncCollection({ @@ -9386,7 +9385,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi const changedObjectUrls = objectResponses.filter((o) => o.status !== 404).map((r) => r.href); const deletedObjectUrls = objectResponses.filter((o) => o.status === 404).map((r) => r.href); const multiGetObjectResponse = changedObjectUrls.length - ? (_l = (yield ((_k = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _k === void 0 ? void 0 : _k.call(collection, { + ? (_c = (yield ((_b = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _b === void 0 ? void 0 : _b.call(collection, { url: collection.url, props: { [`${DAVNamespaceShort.DAV}:getetag`]: {}, @@ -9397,7 +9396,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi objectUrls: changedObjectUrls, depth: '1', headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _l !== void 0 ? _l : [] + })))) !== null && _c !== void 0 ? _c : [] : []; const remoteObjects = multiGetObjectResponse.map((res) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; @@ -9409,7 +9408,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi : (_j = (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.addressData) === null || _h === void 0 ? void 0 : _h._cdata) !== null && _j !== void 0 ? _j : (_k = res.props) === null || _k === void 0 ? void 0 : _k.addressData, }; }); - const localObjects = (_m = collection.objects) !== null && _m !== void 0 ? _m : []; + const localObjects = (_d = collection.objects) !== null && _d !== void 0 ? _d : []; // no existing url const created = remoteObjects.filter((o) => localObjects.every((lo) => !urlContains(lo.url, o.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -9432,18 +9431,18 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi ? { created, updated, deleted } : [...unchanged, ...created, ...updated], // all syncToken in the results are the same so we use the first one here - syncToken: (_r = (_q = (_p = (_o = result[0]) === null || _o === void 0 ? void 0 : _o.raw) === null || _p === void 0 ? void 0 : _p.multistatus) === null || _q === void 0 ? void 0 : _q.syncToken) !== null && _r !== void 0 ? _r : collection.syncToken }); + syncToken: (_h = (_g = (_f = (_e = result[0]) === null || _e === void 0 ? void 0 : _e.raw) === null || _f === void 0 ? void 0 : _f.multistatus) === null || _g === void 0 ? void 0 : _g.syncToken) !== null && _h !== void 0 ? _h : collection.syncToken }); } if (syncMethod === 'basic') { const { isDirty, newCtag } = yield isCollectionDirty({ collection, headers: excludeHeaders(headers, headersToExclude), }); - const localObjects = (_s = collection.objects) !== null && _s !== void 0 ? _s : []; - const remoteObjects = (_u = (yield ((_t = collection.fetchObjects) === null || _t === void 0 ? void 0 : _t.call(collection, { + const localObjects = (_j = collection.objects) !== null && _j !== void 0 ? _j : []; + const remoteObjects = (_l = (yield ((_k = collection.fetchObjects) === null || _k === void 0 ? void 0 : _k.call(collection, { collection, headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _u !== void 0 ? _u : []; + })))) !== null && _l !== void 0 ? _l : []; // no existing url const created = remoteObjects.filter((ro) => localObjects.every((lo) => !urlContains(lo.url, ro.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -10063,7 +10062,7 @@ const serviceDiscovery = (params) => __awaiter(void 0, void 0, void 0, function* return endpoint.href; }); const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _c, _d, _e, _f, _g; + var _a, _b, _c, _d, _e; const { account, headers, headersToExclude } = params; const requiredFields = ['rootUrl']; if (!hasFields(account, requiredFields)) { @@ -10084,11 +10083,11 @@ const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Invalid credentials'); } } - debug$1(`Fetched principal url ${(_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href}`); - return new URL((_g = (_f = (_e = response.props) === null || _e === void 0 ? void 0 : _e.currentUserPrincipal) === null || _f === void 0 ? void 0 : _f.href) !== null && _g !== void 0 ? _g : '', account.rootUrl).href; + debug$1(`Fetched principal url ${(_b = (_a = response.props) === null || _a === void 0 ? void 0 : _a.currentUserPrincipal) === null || _b === void 0 ? void 0 : _b.href}`); + return new URL((_e = (_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '', account.rootUrl).href; }); const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _h, _j; + var _a, _b; const { account, headers, headersToExclude } = params; const requiredFields = ['principalUrl', 'rootUrl']; if (!hasFields(account, requiredFields)) { @@ -10108,8 +10107,8 @@ const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () throw new Error('cannot find homeUrl'); } const result = new URL(account.accountType === 'caldav' - ? (_h = matched === null || matched === void 0 ? void 0 : matched.props) === null || _h === void 0 ? void 0 : _h.calendarHomeSet.href - : (_j = matched === null || matched === void 0 ? void 0 : matched.props) === null || _j === void 0 ? void 0 : _j.addressbookHomeSet.href, account.rootUrl).href; + ? (_a = matched === null || matched === void 0 ? void 0 : matched.props) === null || _a === void 0 ? void 0 : _a.calendarHomeSet.href + : (_b = matched === null || matched === void 0 ? void 0 : matched.props) === null || _b === void 0 ? void 0 : _b.addressbookHomeSet.href, account.rootUrl).href; debug$1(`Fetched home url ${result}`); return result; }); @@ -10589,10 +10588,11 @@ class DAVClient { this.credentials = params.credentials; this.authMethod = (_a = params.authMethod) !== null && _a !== void 0 ? _a : 'Basic'; this.accountType = (_b = params.defaultAccountType) !== null && _b !== void 0 ? _b : 'caldav'; + this.authFunction = params.authFunction; } login() { - var _a; return __awaiter(this, void 0, void 0, function* () { + var _a; switch (this.authMethod) { case 'Basic': this.authHeaders = getBasicAuthHeaders(this.credentials); diff --git a/dist/tsdav.min.cjs b/dist/tsdav.min.cjs index 2c3a23f..ba60e9a 100644 --- a/dist/tsdav.min.cjs +++ b/dist/tsdav.min.cjs @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("cross-fetch"),r=require("debug"),o=require("xml-js"),a=require("base-64");function s(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(o=Object.getOwnPropertySymbols(e);a{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},u=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim();if(Math.abs(r.length-o.length)>1)return!1;const a="/"===r.slice(-1)?r.slice(0,-1):r,s="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(s)||t.includes(a)},p=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim(),a="/"===r.slice(-1)?r.slice(0,-1):r,s="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(s)||t.includes(a)},h=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[n[t]]:t})),{}),v=e=>Object.entries(e).reduce(((e,[t,r])=>r?Object.assign(Object.assign({},e),{[t]:r}):e),{}),f=(e,t)=>t?{[e]:t}:{},m=(e,t)=>e?t&&0!==t.length?Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e)))):e:{};var A=Object.freeze({__proto__:null,cleanupFalsy:v,conditionalParam:f,excludeHeaders:m,getDAVAttribute:h,urlContains:p,urlEquals:u});const D=r("tsdav:request"),g=e=>d(void 0,void 0,void 0,(function*(){var r;const{url:a,init:s,convertIncoming:d=!0,parseOutgoing:n=!0}=e,{headers:i={},body:c,namespace:u,method:p,attributes:h}=s,f=d?o.js2xml(Object.assign(Object.assign({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},c),{_attributes:h}),{compact:!0,spaces:2,elementNameFn:e=>u&&!/^.+:.+/.test(e)?`${u}:${e}`:e}):c,m=yield t.fetch(a,{headers:Object.assign({"Content-Type":"text/xml;charset=UTF-8"},v(i)),body:f,method:p}),A=yield m.text();if(!m.ok||!(null===(r=m.headers.get("content-type"))||void 0===r?void 0:r.includes("xml"))||!n)return[{href:m.url,ok:m.ok,status:m.status,statusText:m.statusText,raw:A}];const g=o.xml2js(A,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,o=Object.keys(r),a=o[o.length-1],s=r[a];if(s.length>0){s[s.length-1]=l(e)}else r[a]=l(e)}catch(e){D(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,(e=>e[1].toUpperCase())),attributesFn:e=>{const t=Object.assign({},e);return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(g.multistatus.response)?g.multistatus.response:[g.multistatus.response]).map((e=>{var t,r;if(!e)return{status:m.status,statusText:m.statusText,ok:m.ok};const o=/^\S+\s(?\d+)\s(?.+)$/.exec(e.status);return{raw:g,href:e.href,status:(null==o?void 0:o.groups)?Number.parseInt(null==o?void 0:o.groups.status,10):m.status,statusText:null!==(r=null===(t=null==o?void 0:o.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:m.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce(((e,t)=>Object.assign(Object.assign({},e),null==t?void 0:t.prop)),{})}}))})),y=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:s}=e;return g({url:t,init:{method:"PROPFIND",headers:m(v(Object.assign({depth:o},a)),s),namespace:exports.DAVNamespaceShort.DAV,body:{propfind:{_attributes:h([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALDAV_APPLE,exports.DAVNamespace.CALENDAR_SERVER,exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),prop:r}}}})})),b=e=>d(void 0,void 0,void 0,(function*(){const{url:r,data:o,headers:a,headersToExclude:s}=e;return t.fetch(r,{method:"PUT",body:o,headers:m(a,s)})})),V=e=>d(void 0,void 0,void 0,(function*(){const{url:r,data:o,etag:a,headers:s,headersToExclude:d}=e;return t.fetch(r,{method:"PUT",body:o,headers:m(v(Object.assign({"If-Match":a},s)),d)})})),x=e=>d(void 0,void 0,void 0,(function*(){const{url:r,headers:o,etag:a,headersToExclude:s}=e;return t.fetch(r,{method:"DELETE",headers:m(v(Object.assign({"If-Match":a},o)),s)})}));var O=Object.freeze({__proto__:null,createObject:b,davRequest:g,deleteObject:x,propfind:y,updateObject:V});function C(e,t){const r=e=>t.every((t=>e[t]));return Array.isArray(e)?e.every((e=>r(e))):r(e)}const j=(e,t)=>t.reduce(((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`),""),S=r("tsdav:collection"),N=e=>d(void 0,void 0,void 0,(function*(){const{url:t,body:r,depth:o,defaultNamespace:a=exports.DAVNamespaceShort.DAV,headers:s,headersToExclude:d}=e,n=yield g({url:t,init:{method:"REPORT",headers:m(v(Object.assign({depth:o},s)),d),namespace:a,body:r}});return 1!==n.length||n[0].raw?n:[]})),E=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:s}=e;return g({url:t,init:{method:"MKCOL",headers:m(v(Object.assign({depth:o},a)),s),namespace:exports.DAVNamespaceShort.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0}})})),k=e=>d(void 0,void 0,void 0,(function*(){var t,r,o,a,s;const{collection:d,headers:n,headersToExclude:i}=e;return null!==(s=null===(a=null===(o=null===(r=null===(t=(yield y({url:d.url,props:{[`${exports.DAVNamespaceShort.DAV}:supported-report-set`]:{}},depth:"0",headers:m(n,i)}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===o?void 0:o.supportedReport)||void 0===a?void 0:a.map((e=>Object.keys(e.report)[0])))&&void 0!==s?s:[]})),T=e=>d(void 0,void 0,void 0,(function*(){var t,r,o;const{collection:a,headers:s,headersToExclude:d}=e,n=(yield y({url:a.url,props:{[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:m(s,d)})).filter((e=>p(a.url,e.href)))[0];if(!n)throw new Error("Collection does not exist on server");return{isDirty:a.ctag!==(null===(t=n.props)||void 0===t?void 0:t.getctag),newCtag:null===(o=null===(r=n.props)||void 0===r?void 0:r.getctag)||void 0===o?void 0:o.toString()}})),$=e=>{const{url:t,props:r,headers:o,syncLevel:a,syncToken:s,headersToExclude:d}=e;return g({url:t,init:{method:"REPORT",namespace:exports.DAVNamespaceShort.DAV,headers:m(Object.assign({},o),d),body:{"sync-collection":{_attributes:h([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),"sync-level":a,"sync-token":s,[`${exports.DAVNamespaceShort.DAV}:prop`]:r}}}})},w=e=>d(void 0,void 0,void 0,(function*(){var t,r,o,a,s,d,n,i,c,l,u;const{collection:h,method:v,headers:f,headersToExclude:A,account:D,detailedResult:g}=e,y=["accountType","homeUrl"];if(!D||!C(D,y)){if(!D)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${j(D,y)} before smartCollectionSync`)}const b=null!=v?v:(null===(t=h.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(S(`smart collection sync with type ${D.accountType} and method ${b}`),"webdav"===b){const e=yield $({url:h.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${"caldav"===D.accountType?exports.DAVNamespaceShort.CALDAV:exports.DAVNamespaceShort.CARDDAV}:${"caldav"===D.accountType?"calendar-data":"address-data"}`]:{},[`${exports.DAVNamespaceShort.DAV}:displayname`]:{}},syncLevel:1,syncToken:h.syncToken,headers:m(f,A)}),t=e.filter((e=>{var t;const r="caldav"===D.accountType?".ics":".vcf";return(null===(t=e.href)||void 0===t?void 0:t.slice(-4))===r})),c=t.filter((e=>404!==e.status)).map((e=>e.href)),l=t.filter((e=>404===e.status)).map((e=>e.href)),u=(c.length&&null!==(o=yield null===(r=null==h?void 0:h.objectMultiGet)||void 0===r?void 0:r.call(h,{url:h.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${"caldav"===D.accountType?exports.DAVNamespaceShort.CALDAV:exports.DAVNamespaceShort.CARDDAV}:${"caldav"===D.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:c,depth:"1",headers:m(f,A)}))&&void 0!==o?o:[]).map((e=>{var t,r,o,a,s,d,n,i,c,l;return{url:null!==(t=e.href)&&void 0!==t?t:"",etag:null===(r=e.props)||void 0===r?void 0:r.getetag,data:"caldav"===(null==D?void 0:D.accountType)?null!==(s=null===(a=null===(o=e.props)||void 0===o?void 0:o.calendarData)||void 0===a?void 0:a._cdata)&&void 0!==s?s:null===(d=e.props)||void 0===d?void 0:d.calendarData:null!==(c=null===(i=null===(n=e.props)||void 0===n?void 0:n.addressData)||void 0===i?void 0:i._cdata)&&void 0!==c?c:null===(l=e.props)||void 0===l?void 0:l.addressData}})),v=null!==(a=h.objects)&&void 0!==a?a:[],y=u.filter((e=>v.every((t=>!p(t.url,e.url))))),b=v.reduce(((e,t)=>{const r=u.find((e=>p(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),V=l.map((e=>({url:e,etag:""}))),x=v.filter((e=>u.some((t=>p(e.url,t.url)&&t.etag===e.etag))));return Object.assign(Object.assign({},h),{objects:g?{created:y,updated:b,deleted:V}:[...x,...y,...b],syncToken:null!==(i=null===(n=null===(d=null===(s=e[0])||void 0===s?void 0:s.raw)||void 0===d?void 0:d.multistatus)||void 0===n?void 0:n.syncToken)&&void 0!==i?i:h.syncToken})}if("basic"===b){const{isDirty:e,newCtag:t}=yield T({collection:h,headers:m(f,A)}),r=null!==(c=h.objects)&&void 0!==c?c:[],o=null!==(u=yield null===(l=h.fetchObjects)||void 0===l?void 0:l.call(h,{collection:h,headers:m(f,A)}))&&void 0!==u?u:[],a=o.filter((e=>r.every((t=>!p(t.url,e.url))))),s=r.reduce(((e,t)=>{const r=o.find((e=>p(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),d=r.filter((e=>o.every((t=>!p(t.url,e.url))))),n=r.filter((e=>o.some((t=>p(e.url,t.url)&&t.etag===e.etag))));if(e)return Object.assign(Object.assign({},h),{objects:g?{created:a,updated:s,deleted:d}:[...n,...a,...s],ctag:t})}return g?Object.assign(Object.assign({},h),{objects:{created:[],updated:[],deleted:[]}}):h}));var _=Object.freeze({__proto__:null,collectionQuery:N,isCollectionDirty:T,makeCollection:E,smartCollectionSync:w,supportedReportSet:k,syncCollection:$});const R=r("tsdav:addressBook"),U=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,depth:a,headers:s,headersToExclude:d}=e;return N({url:t,body:{"addressbook-query":{_attributes:h([exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,filter:null!=o?o:{"prop-filter":{_attributes:{name:"FN"}}}}},defaultNamespace:exports.DAVNamespaceShort.CARDDAV,depth:a,headers:m(s,d)})})),L=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,depth:a,headers:s}=e;return N({url:t,body:{"addressbook-multiget":{_attributes:h([exports.DAVNamespace.DAV,exports.DAVNamespace.CARDDAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,[`${exports.DAVNamespaceShort.DAV}:href`]:o}},defaultNamespace:exports.DAVNamespaceShort.CARDDAV,depth:a,headers:s})})),P=e=>d(void 0,void 0,void 0,(function*(){const{account:t,headers:r,props:o,headersToExclude:a}=null!=e?e:{},s=["homeUrl","rootUrl"];if(!t||!C(t,s)){if(!t)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${j(t,s)} before fetchAddressBooks`)}const n=yield y({url:t.homeUrl,props:null!=o?o:{[`${exports.DAVNamespaceShort.DAV}:displayname`]:{},[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{},[`${exports.DAVNamespaceShort.DAV}:resourcetype`]:{},[`${exports.DAVNamespaceShort.DAV}:sync-token`]:{}},depth:"1",headers:m(r,a)});return Promise.all(n.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("addressbook")})).map((e=>{var r,o,a,s,d,n,i,c,l;const u=null!==(a=null===(o=null===(r=e.props)||void 0===r?void 0:r.displayname)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(s=e.props)||void 0===s?void 0:s.displayname;return R(`Found address book named ${"string"==typeof u?u:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(d=e.href)&&void 0!==d?d:"",null!==(n=t.rootUrl)&&void 0!==n?n:"").href,ctag:null===(i=e.props)||void 0===i?void 0:i.getctag,displayName:"string"==typeof u?u:"",resourcetype:Object.keys(null===(c=e.props)||void 0===c?void 0:c.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}})).map((e=>d(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:r})})})))))})),H=e=>d(void 0,void 0,void 0,(function*(){const{addressBook:t,headers:r,objectUrls:o,headersToExclude:a,urlFilter:s=(e=>e),useMultiGet:d=!0}=e;R(`Fetching vcards from ${null==t?void 0:t.url}`);const n=["url"];if(!t||!C(t,n)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${j(t,n)} before fetchVCards`)}const i=(null!=o?o:(yield U({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{}},depth:"1",headers:m(r,a)})).map((e=>{var t;return e.ok&&null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(s).map((e=>new URL(e).pathname));let c=[];return i.length>0&&(c=d?yield L({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]:{}},objectUrls:i,depth:"1",headers:m(r,a)}):yield U({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]:{}},depth:"1",headers:m(r,a)})),c.map((e=>{var r,o,a,s,d,n;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(o=e.props)||void 0===o?void 0:o.getetag,data:null!==(d=null===(s=null===(a=e.props)||void 0===a?void 0:a.addressData)||void 0===s?void 0:s._cdata)&&void 0!==d?d:null===(n=e.props)||void 0===n?void 0:n.addressData}}))})),B=e=>d(void 0,void 0,void 0,(function*(){const{addressBook:t,vCardString:r,filename:o,headers:a,headersToExclude:s}=e;return b({url:new URL(o,t.url).href,data:r,headers:m(Object.assign({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*"},a),s)})})),I=e=>d(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return V({url:t.url,data:t.data,etag:t.etag,headers:m(Object.assign({"content-type":"text/vcard; charset=utf-8"},r),o)})})),M=e=>d(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return x({url:t.url,etag:t.etag,headers:m(r,o)})}));var F=Object.freeze({__proto__:null,addressBookMultiGet:L,addressBookQuery:U,createVCard:B,deleteVCard:M,fetchAddressBooks:P,fetchVCards:H,updateVCard:I});const z=r("tsdav:calendar"),Z=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,timezone:a,depth:s,headers:d,headersToExclude:n}=e;return N({url:t,body:{"calendar-query":v({_attributes:h([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALENDAR_SERVER,exports.DAVNamespace.CALDAV_APPLE,exports.DAVNamespace.DAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,filter:o,timezone:a})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:s,headers:m(d,n)})})),q=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,filters:a,timezone:s,depth:d,headers:n,headersToExclude:i}=e;return N({url:t,body:{"calendar-multiget":Object.assign(Object.assign({_attributes:h([exports.DAVNamespace.DAV,exports.DAVNamespace.CALDAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,[`${exports.DAVNamespaceShort.DAV}:href`]:o},f("filter",a)),{timezone:s})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:d,headers:m(n,i)})})),Q=e=>d(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:s}=e;return g({url:t,init:{method:"MKCALENDAR",headers:m(v(Object.assign({depth:o},a)),s),namespace:exports.DAVNamespaceShort.DAV,body:{[`${exports.DAVNamespaceShort.CALDAV}:mkcalendar`]:{_attributes:h([exports.DAVNamespace.DAV,exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALDAV_APPLE]),set:{prop:r}}}}})})),G=e=>d(void 0,void 0,void 0,(function*(){const{headers:t,account:r,props:o,projectedProps:a,headersToExclude:s}=null!=e?e:{},n=["homeUrl","rootUrl"];if(!r||!C(r,n)){if(!r)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${j(r,n)} before fetchCalendars`)}const i=yield y({url:r.homeUrl,props:null!=o?o:{[`${exports.DAVNamespaceShort.CALDAV}:calendar-description`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-timezone`]:{},[`${exports.DAVNamespaceShort.DAV}:displayname`]:{},[`${exports.DAVNamespaceShort.CALDAV_APPLE}:calendar-color`]:{},[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{},[`${exports.DAVNamespaceShort.DAV}:resourcetype`]:{},[`${exports.DAVNamespaceShort.CALDAV}:supported-calendar-component-set`]:{},[`${exports.DAVNamespaceShort.DAV}:sync-token`]:{}},depth:"1",headers:m(t,s)});return Promise.all(i.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("calendar")})).filter((e=>{var t,r,o,a;return(Array.isArray(null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet.comp)?null===(r=e.props)||void 0===r?void 0:r.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(a=null===(o=e.props)||void 0===o?void 0:o.supportedCalendarComponentSet.comp)||void 0===a?void 0:a._attributes.name]||[]).some((e=>Object.values(c).includes(e)))})).map((e=>{var t,o,s,d,n,i,c,l,u,p,h,v,m,A,D,g;const y=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,b=null===(o=e.props)||void 0===o?void 0:o.calendarTimezone;return Object.assign({description:"string"==typeof y?y:"",timezone:"string"==typeof b?b:"",url:new URL(null!==(s=e.href)&&void 0!==s?s:"",null!==(d=r.rootUrl)&&void 0!==d?d:"").href,ctag:null===(n=e.props)||void 0===n?void 0:n.getctag,calendarColor:null===(i=e.props)||void 0===i?void 0:i.calendarColor,displayName:null!==(l=null===(c=e.props)||void 0===c?void 0:c.displayname._cdata)&&void 0!==l?l:null===(u=e.props)||void 0===u?void 0:u.displayname,components:Array.isArray(null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp)?null===(h=e.props)||void 0===h?void 0:h.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(m=null===(v=e.props)||void 0===v?void 0:v.supportedCalendarComponentSet.comp)||void 0===m?void 0:m._attributes.name],resourcetype:Object.keys(null===(A=e.props)||void 0===A?void 0:A.resourcetype),syncToken:null===(D=e.props)||void 0===D?void 0:D.syncToken},f("projectedProps",Object.fromEntries(Object.entries(null!==(g=e.props)&&void 0!==g?g:{}).filter((([e])=>null==a?void 0:a[e])))))})).map((e=>d(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:m(t,s)})})})))))})),J=e=>d(void 0,void 0,void 0,(function*(){const{calendar:t,objectUrls:r,filters:o,timeRange:a,headers:s,expand:d,urlFilter:n=(e=>Boolean(null==e?void 0:e.includes(".ics"))),useMultiGet:i=!0,headersToExclude:c}=e;if(a){const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(a.start)&&e.test(a.end)||t.test(a.start)&&t.test(a.end)))throw new Error("invalid timeRange format, not in ISO8601")}z(`Fetching calendar objects from ${null==t?void 0:t.url}`);const l=["url"];if(!t||!C(t,l)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${j(t,l)} before fetchCalendarObjects`)}const u=null!=o?o:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":Object.assign({_attributes:{name:"VEVENT"}},a?{"time-range":{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})}}],p=(null!=r?r:(yield Z({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:Object.assign({},d&&a?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:u,depth:"1",headers:m(s,c)})).map((e=>{var t;return null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(n).map((e=>new URL(e).pathname));let h=[];return p.length>0&&(h=!i||d?yield Z({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:Object.assign({},d&&a?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:u,depth:"1",headers:m(s,c)}):yield q({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:Object.assign({},d&&a?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},objectUrls:p,depth:"1",headers:m(s,c)})),h.map((e=>{var r,o,a,s,d,n;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(o=e.props)||void 0===o?void 0:o.getetag}`,data:null!==(d=null===(s=null===(a=e.props)||void 0===a?void 0:a.calendarData)||void 0===s?void 0:s._cdata)&&void 0!==d?d:null===(n=e.props)||void 0===n?void 0:n.calendarData}}))})),K=e=>d(void 0,void 0,void 0,(function*(){const{calendar:t,iCalString:r,filename:o,headers:a,headersToExclude:s}=e;return b({url:new URL(o,t.url).href,data:r,headers:m(Object.assign({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*"},a),s)})})),W=e=>d(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return V({url:t.url,data:t.data,etag:t.etag,headers:m(Object.assign({"content-type":"text/calendar; charset=utf-8"},r),o)})})),Y=e=>d(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return x({url:t.url,etag:t.etag,headers:m(r,o)})})),X=e=>d(void 0,void 0,void 0,(function*(){var t;const{oldCalendars:r,account:o,detailedResult:a,headers:s,headersToExclude:n}=e;if(!o)throw new Error("Must have account before syncCalendars");const i=null!==(t=null!=r?r:o.calendars)&&void 0!==t?t:[],c=yield G({account:o,headers:m(s,n)}),l=c.filter((e=>i.every((t=>!p(t.url,e.url)))));z(`new calendars: ${l.map((e=>e.displayName))}`);const u=i.reduce(((e,t)=>{const r=c.find((e=>p(e.url,t.url)));return r&&(r.syncToken&&r.syncToken!==t.syncToken||r.ctag&&r.ctag!==t.ctag)?[...e,r]:e}),[]);z(`updated calendars: ${u.map((e=>e.displayName))}`);const h=yield Promise.all(u.map((e=>d(void 0,void 0,void 0,(function*(){return yield w({collection:Object.assign(Object.assign({},e),{objectMultiGet:q}),method:"webdav",headers:m(s,n),account:o})}))))),v=i.filter((e=>c.every((t=>!p(t.url,e.url)))));z(`deleted calendars: ${v.map((e=>e.displayName))}`);const f=i.filter((e=>c.some((t=>p(t.url,e.url)&&(t.syncToken&&t.syncToken!==e.syncToken||t.ctag&&t.ctag!==e.ctag)))));return a?{created:l,updated:u,deleted:v}:[...f,...l,...h]})),ee=e=>d(void 0,void 0,void 0,(function*(){const{url:t,timeRange:r,depth:o,headers:a,headersToExclude:s}=e;if(!r)throw new Error("timeRange is required");{const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(r.start)&&e.test(r.end)||t.test(r.start)&&t.test(r.end)))throw new Error("invalid timeRange format, not in ISO8601")}return(yield N({url:t,body:{"free-busy-query":v({_attributes:h([exports.DAVNamespace.CALDAV]),[`${exports.DAVNamespaceShort.CALDAV}:time-range`]:{_attributes:{start:`${new Date(r.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(r.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:o,headers:m(a,s)}))[0]}));var te=Object.freeze({__proto__:null,calendarMultiGet:q,calendarQuery:Z,createCalendarObject:K,deleteCalendarObject:Y,fetchCalendarObjects:J,fetchCalendars:G,freeBusyQuery:ee,makeCalendar:Q,syncCalendars:X,updateCalendarObject:W});const re=r("tsdav:account"),oe=e=>d(void 0,void 0,void 0,(function*(){var r,o;re("Service discovery...");const{account:a,headers:s,headersToExclude:d}=e,n=new URL(a.serverUrl),i=new URL(`/.well-known/${a.accountType}`,n);i.protocol=null!==(r=n.protocol)&&void 0!==r?r:"http";try{const e=yield t.fetch(i.href,{headers:m(s,d),method:"PROPFIND",redirect:"manual"});if(e.status>=300&&e.status<400){const t=e.headers.get("Location");if("string"==typeof t&&t.length){re(`Service discovery redirected to ${t}`);const e=new URL(t,n);return e.hostname===i.hostname&&i.port&&!e.port&&(e.port=i.port),e.protocol=null!==(o=n.protocol)&&void 0!==o?o:"http",e.href}}}catch(e){re(`Service discovery failed: ${e.stack}`)}return n.href})),ae=e=>d(void 0,void 0,void 0,(function*(){var t,r,o,a,s;const{account:d,headers:n,headersToExclude:i}=e,c=["rootUrl"];if(!C(d,c))throw new Error(`account must have ${j(d,c)} before fetchPrincipalUrl`);re(`Fetching principal url from path ${d.rootUrl}`);const[l]=yield y({url:d.rootUrl,props:{[`${exports.DAVNamespaceShort.DAV}:current-user-principal`]:{}},depth:"0",headers:m(n,i)});if(!l.ok&&(re(`Fetch principal url failed: ${l.statusText}`),401===l.status))throw new Error("Invalid credentials");return re(`Fetched principal url ${null===(r=null===(t=l.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(s=null===(a=null===(o=l.props)||void 0===o?void 0:o.currentUserPrincipal)||void 0===a?void 0:a.href)&&void 0!==s?s:"",d.rootUrl).href})),se=e=>d(void 0,void 0,void 0,(function*(){var t,r;const{account:o,headers:a,headersToExclude:s}=e,d=["principalUrl","rootUrl"];if(!C(o,d))throw new Error(`account must have ${j(o,d)} before fetchHomeUrl`);re(`Fetch home url from ${o.principalUrl}`);const n=(yield y({url:o.principalUrl,props:"caldav"===o.accountType?{[`${exports.DAVNamespaceShort.CALDAV}:calendar-home-set`]:{}}:{[`${exports.DAVNamespaceShort.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:m(a,s)})).find((e=>p(o.principalUrl,e.href)));if(!n||!n.ok)throw new Error("cannot find homeUrl");const i=new URL("caldav"===o.accountType?null===(t=null==n?void 0:n.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==n?void 0:n.props)||void 0===r?void 0:r.addressbookHomeSet.href,o.rootUrl).href;return re(`Fetched home url ${i}`),i})),de=e=>d(void 0,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o=!1,loadObjects:a=!1,headersToExclude:s}=e,n=Object.assign({},t);return n.rootUrl=yield oe({account:t,headers:m(r,s)}),n.principalUrl=yield ae({account:n,headers:m(r,s)}),n.homeUrl=yield se({account:n,headers:m(r,s)}),(o||a)&&("caldav"===t.accountType?n.calendars=yield G({headers:m(r,s),account:n}):"carddav"===t.accountType&&(n.addressBooks=yield P({headers:m(r,s),account:n}))),a&&("caldav"===t.accountType&&n.calendars?n.calendars=yield Promise.all(n.calendars.map((e=>d(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield J({calendar:e,headers:m(r,s)})})}))))):"carddav"===t.accountType&&n.addressBooks&&(n.addressBooks=yield Promise.all(n.addressBooks.map((e=>d(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield H({addressBook:e,headers:m(r,s)})})}))))))),n}));var ne=Object.freeze({__proto__:null,createAccount:de,fetchHomeUrl:se,fetchPrincipalUrl:ae,serviceDiscovery:oe});const ie=r("tsdav:authHelper"),ce=(e,t)=>(...r)=>e(Object.assign(Object.assign({},t),r[0])),le=e=>(ie(`Basic auth token generated: ${a.encode(`${e.username}:${e.password}`)}`),{authorization:`Basic ${a.encode(`${e.username}:${e.password}`)}`}),ue=e=>d(void 0,void 0,void 0,(function*(){const r=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!C(e,r))throw new Error(`Oauth credentials missing: ${j(e,r)}`);const o=new URLSearchParams({grant_type:"authorization_code",code:e.authorizationCode,redirect_uri:e.redirectUrl,client_id:e.clientId,client_secret:e.clientSecret});ie(e.tokenUrl),ie(o.toString());const a=yield t.fetch(e.tokenUrl,{method:"POST",body:o.toString(),headers:{"content-length":`${o.toString().length}`,"content-type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Fetch Oauth tokens failed: ${yield a.text()}`),{}})),pe=e=>d(void 0,void 0,void 0,(function*(){const r=["refreshToken","clientId","clientSecret","tokenUrl"];if(!C(e,r))throw new Error(`Oauth credentials missing: ${j(e,r)}`);const o=new URLSearchParams({client_id:e.clientId,client_secret:e.clientSecret,refresh_token:e.refreshToken,grant_type:"refresh_token"}),a=yield t.fetch(e.tokenUrl,{method:"POST",body:o.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Refresh access token failed: ${yield a.text()}`),{}})),he=e=>d(void 0,void 0,void 0,(function*(){var t;ie("Fetching oauth headers");let r={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(t=e.expiration)&&void 0!==t?t:0))&&(r=yield pe(e)):r=yield ue(e),ie(`Oauth tokens fetched: ${r.access_token}`),{tokens:r,headers:{authorization:`Bearer ${r.access_token}`}}}));var ve=Object.freeze({__proto__:null,defaultParam:ce,fetchOauthTokens:ue,getBasicAuthHeaders:le,getOauthHeaders:he,refreshAccessToken:pe});const fe=e=>d(void 0,void 0,void 0,(function*(){var t;const{serverUrl:r,credentials:o,authMethod:a,defaultAccountType:n,authFunction:i}=e;let c={};switch(a){case"Basic":c=le(o);break;case"Oauth":c=(yield he(o)).headers;break;case"Digest":c={Authorization:`Digest ${o.digestString}`};break;case"Custom":c=null!==(t=yield null==i?void 0:i(o))&&void 0!==t?t:{};break;default:throw new Error("Invalid auth method")}const l=n?yield de({account:{serverUrl:r,credentials:o,accountType:n},headers:c}):void 0,u=ce(b,{url:r,headers:c}),p=ce(V,{headers:c,url:r}),h=ce(x,{headers:c,url:r}),v=ce(y,{headers:c}),f=ce(N,{headers:c}),m=ce(E,{headers:c}),A=ce($,{headers:c}),D=ce(k,{headers:c}),O=ce(T,{headers:c}),C=ce(w,{headers:c,account:l}),j=ce(Z,{headers:c}),S=ce(q,{headers:c}),_=ce(Q,{headers:c}),R=ce(G,{headers:c,account:l}),F=ce(J,{headers:c}),z=ce(K,{headers:c}),ee=ce(W,{headers:c}),te=ce(Y,{headers:c}),re=ce(X,{account:l,headers:c}),oe=ce(U,{headers:c}),ae=ce(L,{headers:c});return{davRequest:e=>d(void 0,void 0,void 0,(function*(){const{init:t}=e,r=s(e,["init"]),{headers:o}=t,a=s(t,["headers"]);return g(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},a),{headers:Object.assign(Object.assign({},c),o)})}))})),propfind:v,createAccount:e=>d(void 0,void 0,void 0,(function*(){const{account:t,headers:a,loadCollections:s,loadObjects:d}=e;return de({account:Object.assign({serverUrl:r,credentials:o},t),headers:Object.assign(Object.assign({},c),a),loadCollections:s,loadObjects:d})})),createObject:u,updateObject:p,deleteObject:h,calendarQuery:j,addressBookQuery:oe,collectionQuery:f,makeCollection:m,calendarMultiGet:S,makeCalendar:_,syncCollection:A,supportedReportSet:D,isCollectionDirty:O,smartCollectionSync:C,fetchCalendars:R,fetchCalendarObjects:F,createCalendarObject:z,updateCalendarObject:ee,deleteCalendarObject:te,syncCalendars:re,fetchAddressBooks:ce(P,{account:l,headers:c}),addressBookMultiGet:ae,fetchVCards:ce(H,{headers:c}),createVCard:ce(B,{headers:c}),updateVCard:ce(I,{headers:c}),deleteVCard:ce(M,{headers:c})}}));class me{constructor(e){var t,r;this.serverUrl=e.serverUrl,this.credentials=e.credentials,this.authMethod=null!==(t=e.authMethod)&&void 0!==t?t:"Basic",this.accountType=null!==(r=e.defaultAccountType)&&void 0!==r?r:"caldav"}login(){var e;return d(this,void 0,void 0,(function*(){switch(this.authMethod){case"Basic":this.authHeaders=le(this.credentials);break;case"Oauth":this.authHeaders=(yield he(this.credentials)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=yield null===(e=this.authFunction)||void 0===e?void 0:e.call(this,this.credentials);break;default:throw new Error("Invalid auth method")}this.account=this.accountType?yield de({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders}):void 0}))}davRequest(e){return d(this,void 0,void 0,(function*(){const{init:t}=e,r=s(e,["init"]),{headers:o}=t,a=s(t,["headers"]);return g(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},a),{headers:Object.assign(Object.assign({},this.authHeaders),o)})}))}))}createObject(...e){return d(this,void 0,void 0,(function*(){return ce(b,{url:this.serverUrl,headers:this.authHeaders})(e[0])}))}updateObject(...e){return d(this,void 0,void 0,(function*(){return ce(V,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}deleteObject(...e){return d(this,void 0,void 0,(function*(){return ce(x,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}propfind(...e){return d(this,void 0,void 0,(function*(){return ce(y,{headers:this.authHeaders})(e[0])}))}createAccount(e){return d(this,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o,loadObjects:a}=e;return de({account:Object.assign({serverUrl:this.serverUrl,credentials:this.credentials},t),headers:Object.assign(Object.assign({},this.authHeaders),r),loadCollections:o,loadObjects:a})}))}collectionQuery(...e){return d(this,void 0,void 0,(function*(){return ce(N,{headers:this.authHeaders})(e[0])}))}makeCollection(...e){return d(this,void 0,void 0,(function*(){return ce(E,{headers:this.authHeaders})(e[0])}))}syncCollection(...e){return d(this,void 0,void 0,(function*(){return ce($,{headers:this.authHeaders})(e[0])}))}supportedReportSet(...e){return d(this,void 0,void 0,(function*(){return ce(k,{headers:this.authHeaders})(e[0])}))}isCollectionDirty(...e){return d(this,void 0,void 0,(function*(){return ce(T,{headers:this.authHeaders})(e[0])}))}smartCollectionSync(...e){return d(this,void 0,void 0,(function*(){return ce(w,{headers:this.authHeaders,account:this.account})(e[0])}))}calendarQuery(...e){return d(this,void 0,void 0,(function*(){return ce(Z,{headers:this.authHeaders})(e[0])}))}makeCalendar(...e){return d(this,void 0,void 0,(function*(){return ce(Q,{headers:this.authHeaders})(e[0])}))}calendarMultiGet(...e){return d(this,void 0,void 0,(function*(){return ce(q,{headers:this.authHeaders})(e[0])}))}fetchCalendars(...e){return d(this,void 0,void 0,(function*(){return ce(G,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchCalendarObjects(...e){return d(this,void 0,void 0,(function*(){return ce(J,{headers:this.authHeaders})(e[0])}))}createCalendarObject(...e){return d(this,void 0,void 0,(function*(){return ce(K,{headers:this.authHeaders})(e[0])}))}updateCalendarObject(...e){return d(this,void 0,void 0,(function*(){return ce(W,{headers:this.authHeaders})(e[0])}))}deleteCalendarObject(...e){return d(this,void 0,void 0,(function*(){return ce(Y,{headers:this.authHeaders})(e[0])}))}syncCalendars(...e){return d(this,void 0,void 0,(function*(){return ce(X,{headers:this.authHeaders,account:this.account})(e[0])}))}addressBookQuery(...e){return d(this,void 0,void 0,(function*(){return ce(U,{headers:this.authHeaders})(e[0])}))}addressBookMultiGet(...e){return d(this,void 0,void 0,(function*(){return ce(L,{headers:this.authHeaders})(e[0])}))}fetchAddressBooks(...e){return d(this,void 0,void 0,(function*(){return ce(P,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchVCards(...e){return d(this,void 0,void 0,(function*(){return ce(H,{headers:this.authHeaders})(e[0])}))}createVCard(...e){return d(this,void 0,void 0,(function*(){return ce(B,{headers:this.authHeaders})(e[0])}))}updateVCard(...e){return d(this,void 0,void 0,(function*(){return ce(I,{headers:this.authHeaders})(e[0])}))}deleteVCard(...e){return d(this,void 0,void 0,(function*(){return ce(M,{headers:this.authHeaders})(e[0])}))}}var Ae=Object.freeze({__proto__:null,DAVClient:me,createDAVClient:fe}),De=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({DAVNamespace:exports.DAVNamespace,DAVNamespaceShort:exports.DAVNamespaceShort,DAVAttributeMap:n},Ae),O),_),ne),F),te),ve),A);exports.DAVAttributeMap=n,exports.DAVClient=me,exports.addressBookQuery=U,exports.calendarMultiGet=q,exports.calendarQuery=Z,exports.cleanupFalsy=v,exports.collectionQuery=N,exports.createAccount=de,exports.createCalendarObject=K,exports.createDAVClient=fe,exports.createObject=b,exports.createVCard=B,exports.davRequest=g,exports.default=De,exports.deleteCalendarObject=Y,exports.deleteObject=x,exports.deleteVCard=M,exports.fetchAddressBooks=P,exports.fetchCalendarObjects=J,exports.fetchCalendars=G,exports.fetchOauthTokens=ue,exports.fetchVCards=H,exports.freeBusyQuery=ee,exports.getBasicAuthHeaders=le,exports.getDAVAttribute=h,exports.getOauthHeaders=he,exports.isCollectionDirty=T,exports.makeCalendar=Q,exports.propfind=y,exports.refreshAccessToken=pe,exports.smartCollectionSync=w,exports.supportedReportSet=k,exports.syncCalendars=X,exports.syncCollection=$,exports.updateCalendarObject=W,exports.updateObject=V,exports.updateVCard=I,exports.urlContains=p,exports.urlEquals=u; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("cross-fetch"),r=require("debug"),o=require("xml-js"),a=require("base-64");function s(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(o=Object.getOwnPropertySymbols(e);a{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},u=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim();if(Math.abs(r.length-o.length)>1)return!1;const a="/"===r.slice(-1)?r.slice(0,-1):r,s="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(s)||t.includes(a)},p=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim(),a="/"===r.slice(-1)?r.slice(0,-1):r,s="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(s)||t.includes(a)},h=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[d[t]]:t})),{}),v=e=>Object.entries(e).reduce(((e,[t,r])=>r?Object.assign(Object.assign({},e),{[t]:r}):e),{}),f=(e,t)=>t?{[e]:t}:{},m=(e,t)=>e?t&&0!==t.length?Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e)))):e:{};var A=Object.freeze({__proto__:null,cleanupFalsy:v,conditionalParam:f,excludeHeaders:m,getDAVAttribute:h,urlContains:p,urlEquals:u});const D=r("tsdav:request"),g=e=>n(void 0,void 0,void 0,(function*(){var r;const{url:a,init:s,convertIncoming:n=!0,parseOutgoing:d=!0}=e,{headers:i={},body:c,namespace:u,method:p,attributes:h}=s,f=n?o.js2xml(Object.assign(Object.assign({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},c),{_attributes:h}),{compact:!0,spaces:2,elementNameFn:e=>u&&!/^.+:.+/.test(e)?`${u}:${e}`:e}):c,m=yield t.fetch(a,{headers:Object.assign({"Content-Type":"text/xml;charset=UTF-8"},v(i)),body:f,method:p}),A=yield m.text();if(!m.ok||!(null===(r=m.headers.get("content-type"))||void 0===r?void 0:r.includes("xml"))||!d)return[{href:m.url,ok:m.ok,status:m.status,statusText:m.statusText,raw:A}];const g=o.xml2js(A,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,o=Object.keys(r),a=o[o.length-1],s=r[a];if(s.length>0){s[s.length-1]=l(e)}else r[a]=l(e)}catch(e){D(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,(e=>e[1].toUpperCase())),attributesFn:e=>{const t=Object.assign({},e);return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(g.multistatus.response)?g.multistatus.response:[g.multistatus.response]).map((e=>{var t,r;if(!e)return{status:m.status,statusText:m.statusText,ok:m.ok};const o=/^\S+\s(?\d+)\s(?.+)$/.exec(e.status);return{raw:g,href:e.href,status:(null==o?void 0:o.groups)?Number.parseInt(null==o?void 0:o.groups.status,10):m.status,statusText:null!==(r=null===(t=null==o?void 0:o.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:m.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce(((e,t)=>Object.assign(Object.assign({},e),null==t?void 0:t.prop)),{})}}))})),y=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:s}=e;return g({url:t,init:{method:"PROPFIND",headers:m(v(Object.assign({depth:o},a)),s),namespace:exports.DAVNamespaceShort.DAV,body:{propfind:{_attributes:h([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALDAV_APPLE,exports.DAVNamespace.CALENDAR_SERVER,exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),prop:r}}}})})),b=e=>n(void 0,void 0,void 0,(function*(){const{url:r,data:o,headers:a,headersToExclude:s}=e;return t.fetch(r,{method:"PUT",body:o,headers:m(a,s)})})),V=e=>n(void 0,void 0,void 0,(function*(){const{url:r,data:o,etag:a,headers:s,headersToExclude:n}=e;return t.fetch(r,{method:"PUT",body:o,headers:m(v(Object.assign({"If-Match":a},s)),n)})})),x=e=>n(void 0,void 0,void 0,(function*(){const{url:r,headers:o,etag:a,headersToExclude:s}=e;return t.fetch(r,{method:"DELETE",headers:m(v(Object.assign({"If-Match":a},o)),s)})}));var O=Object.freeze({__proto__:null,createObject:b,davRequest:g,deleteObject:x,propfind:y,updateObject:V});function C(e,t){const r=e=>t.every((t=>e[t]));return Array.isArray(e)?e.every((e=>r(e))):r(e)}const j=(e,t)=>t.reduce(((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`),""),S=r("tsdav:collection"),N=e=>n(void 0,void 0,void 0,(function*(){const{url:t,body:r,depth:o,defaultNamespace:a=exports.DAVNamespaceShort.DAV,headers:s,headersToExclude:n}=e,d=yield g({url:t,init:{method:"REPORT",headers:m(v(Object.assign({depth:o},s)),n),namespace:a,body:r}});return 1!==d.length||d[0].raw?d:[]})),E=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:s}=e;return g({url:t,init:{method:"MKCOL",headers:m(v(Object.assign({depth:o},a)),s),namespace:exports.DAVNamespaceShort.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0}})})),k=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,s;const{collection:n,headers:d,headersToExclude:i}=e;return null!==(s=null===(a=null===(o=null===(r=null===(t=(yield y({url:n.url,props:{[`${exports.DAVNamespaceShort.DAV}:supported-report-set`]:{}},depth:"0",headers:m(d,i)}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===o?void 0:o.supportedReport)||void 0===a?void 0:a.map((e=>Object.keys(e.report)[0])))&&void 0!==s?s:[]})),T=e=>n(void 0,void 0,void 0,(function*(){var t,r,o;const{collection:a,headers:s,headersToExclude:n}=e,d=(yield y({url:a.url,props:{[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:m(s,n)})).filter((e=>p(a.url,e.href)))[0];if(!d)throw new Error("Collection does not exist on server");return{isDirty:a.ctag!==(null===(t=d.props)||void 0===t?void 0:t.getctag),newCtag:null===(o=null===(r=d.props)||void 0===r?void 0:r.getctag)||void 0===o?void 0:o.toString()}})),$=e=>{const{url:t,props:r,headers:o,syncLevel:a,syncToken:s,headersToExclude:n}=e;return g({url:t,init:{method:"REPORT",namespace:exports.DAVNamespaceShort.DAV,headers:m(Object.assign({},o),n),body:{"sync-collection":{_attributes:h([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),"sync-level":a,"sync-token":s,[`${exports.DAVNamespaceShort.DAV}:prop`]:r}}}})},w=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,s,n,d,i,c,l,u;const{collection:h,method:v,headers:f,headersToExclude:A,account:D,detailedResult:g}=e,y=["accountType","homeUrl"];if(!D||!C(D,y)){if(!D)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${j(D,y)} before smartCollectionSync`)}const b=null!=v?v:(null===(t=h.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(S(`smart collection sync with type ${D.accountType} and method ${b}`),"webdav"===b){const e=yield $({url:h.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${"caldav"===D.accountType?exports.DAVNamespaceShort.CALDAV:exports.DAVNamespaceShort.CARDDAV}:${"caldav"===D.accountType?"calendar-data":"address-data"}`]:{},[`${exports.DAVNamespaceShort.DAV}:displayname`]:{}},syncLevel:1,syncToken:h.syncToken,headers:m(f,A)}),t=e.filter((e=>{var t;const r="caldav"===D.accountType?".ics":".vcf";return(null===(t=e.href)||void 0===t?void 0:t.slice(-4))===r})),c=t.filter((e=>404!==e.status)).map((e=>e.href)),l=t.filter((e=>404===e.status)).map((e=>e.href)),u=(c.length&&null!==(o=yield null===(r=null==h?void 0:h.objectMultiGet)||void 0===r?void 0:r.call(h,{url:h.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${"caldav"===D.accountType?exports.DAVNamespaceShort.CALDAV:exports.DAVNamespaceShort.CARDDAV}:${"caldav"===D.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:c,depth:"1",headers:m(f,A)}))&&void 0!==o?o:[]).map((e=>{var t,r,o,a,s,n,d,i,c,l;return{url:null!==(t=e.href)&&void 0!==t?t:"",etag:null===(r=e.props)||void 0===r?void 0:r.getetag,data:"caldav"===(null==D?void 0:D.accountType)?null!==(s=null===(a=null===(o=e.props)||void 0===o?void 0:o.calendarData)||void 0===a?void 0:a._cdata)&&void 0!==s?s:null===(n=e.props)||void 0===n?void 0:n.calendarData:null!==(c=null===(i=null===(d=e.props)||void 0===d?void 0:d.addressData)||void 0===i?void 0:i._cdata)&&void 0!==c?c:null===(l=e.props)||void 0===l?void 0:l.addressData}})),v=null!==(a=h.objects)&&void 0!==a?a:[],y=u.filter((e=>v.every((t=>!p(t.url,e.url))))),b=v.reduce(((e,t)=>{const r=u.find((e=>p(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),V=l.map((e=>({url:e,etag:""}))),x=v.filter((e=>u.some((t=>p(e.url,t.url)&&t.etag===e.etag))));return Object.assign(Object.assign({},h),{objects:g?{created:y,updated:b,deleted:V}:[...x,...y,...b],syncToken:null!==(i=null===(d=null===(n=null===(s=e[0])||void 0===s?void 0:s.raw)||void 0===n?void 0:n.multistatus)||void 0===d?void 0:d.syncToken)&&void 0!==i?i:h.syncToken})}if("basic"===b){const{isDirty:e,newCtag:t}=yield T({collection:h,headers:m(f,A)}),r=null!==(c=h.objects)&&void 0!==c?c:[],o=null!==(u=yield null===(l=h.fetchObjects)||void 0===l?void 0:l.call(h,{collection:h,headers:m(f,A)}))&&void 0!==u?u:[],a=o.filter((e=>r.every((t=>!p(t.url,e.url))))),s=r.reduce(((e,t)=>{const r=o.find((e=>p(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),n=r.filter((e=>o.every((t=>!p(t.url,e.url))))),d=r.filter((e=>o.some((t=>p(e.url,t.url)&&t.etag===e.etag))));if(e)return Object.assign(Object.assign({},h),{objects:g?{created:a,updated:s,deleted:n}:[...d,...a,...s],ctag:t})}return g?Object.assign(Object.assign({},h),{objects:{created:[],updated:[],deleted:[]}}):h}));var _=Object.freeze({__proto__:null,collectionQuery:N,isCollectionDirty:T,makeCollection:E,smartCollectionSync:w,supportedReportSet:k,syncCollection:$});const R=r("tsdav:addressBook"),U=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,depth:a,headers:s,headersToExclude:n}=e;return N({url:t,body:{"addressbook-query":{_attributes:h([exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,filter:null!=o?o:{"prop-filter":{_attributes:{name:"FN"}}}}},defaultNamespace:exports.DAVNamespaceShort.CARDDAV,depth:a,headers:m(s,n)})})),L=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,depth:a,headers:s}=e;return N({url:t,body:{"addressbook-multiget":{_attributes:h([exports.DAVNamespace.DAV,exports.DAVNamespace.CARDDAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,[`${exports.DAVNamespaceShort.DAV}:href`]:o}},defaultNamespace:exports.DAVNamespaceShort.CARDDAV,depth:a,headers:s})})),P=e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:r,props:o,headersToExclude:a}=null!=e?e:{},s=["homeUrl","rootUrl"];if(!t||!C(t,s)){if(!t)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${j(t,s)} before fetchAddressBooks`)}const d=yield y({url:t.homeUrl,props:null!=o?o:{[`${exports.DAVNamespaceShort.DAV}:displayname`]:{},[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{},[`${exports.DAVNamespaceShort.DAV}:resourcetype`]:{},[`${exports.DAVNamespaceShort.DAV}:sync-token`]:{}},depth:"1",headers:m(r,a)});return Promise.all(d.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("addressbook")})).map((e=>{var r,o,a,s,n,d,i,c,l;const u=null!==(a=null===(o=null===(r=e.props)||void 0===r?void 0:r.displayname)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(s=e.props)||void 0===s?void 0:s.displayname;return R(`Found address book named ${"string"==typeof u?u:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(n=e.href)&&void 0!==n?n:"",null!==(d=t.rootUrl)&&void 0!==d?d:"").href,ctag:null===(i=e.props)||void 0===i?void 0:i.getctag,displayName:"string"==typeof u?u:"",resourcetype:Object.keys(null===(c=e.props)||void 0===c?void 0:c.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}})).map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:r})})})))))})),H=e=>n(void 0,void 0,void 0,(function*(){const{addressBook:t,headers:r,objectUrls:o,headersToExclude:a,urlFilter:s=(e=>e),useMultiGet:n=!0}=e;R(`Fetching vcards from ${null==t?void 0:t.url}`);const d=["url"];if(!t||!C(t,d)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${j(t,d)} before fetchVCards`)}const i=(null!=o?o:(yield U({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{}},depth:"1",headers:m(r,a)})).map((e=>{var t;return e.ok&&null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(s).map((e=>new URL(e).pathname));let c=[];return i.length>0&&(c=n?yield L({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]:{}},objectUrls:i,depth:"1",headers:m(r,a)}):yield U({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]:{}},depth:"1",headers:m(r,a)})),c.map((e=>{var r,o,a,s,n,d;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(o=e.props)||void 0===o?void 0:o.getetag,data:null!==(n=null===(s=null===(a=e.props)||void 0===a?void 0:a.addressData)||void 0===s?void 0:s._cdata)&&void 0!==n?n:null===(d=e.props)||void 0===d?void 0:d.addressData}}))})),B=e=>n(void 0,void 0,void 0,(function*(){const{addressBook:t,vCardString:r,filename:o,headers:a,headersToExclude:s}=e;return b({url:new URL(o,t.url).href,data:r,headers:m(Object.assign({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*"},a),s)})})),I=e=>n(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return V({url:t.url,data:t.data,etag:t.etag,headers:m(Object.assign({"content-type":"text/vcard; charset=utf-8"},r),o)})})),M=e=>n(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return x({url:t.url,etag:t.etag,headers:m(r,o)})}));var F=Object.freeze({__proto__:null,addressBookMultiGet:L,addressBookQuery:U,createVCard:B,deleteVCard:M,fetchAddressBooks:P,fetchVCards:H,updateVCard:I});const z=r("tsdav:calendar"),Z=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,timezone:a,depth:s,headers:n,headersToExclude:d}=e;return N({url:t,body:{"calendar-query":v({_attributes:h([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALENDAR_SERVER,exports.DAVNamespace.CALDAV_APPLE,exports.DAVNamespace.DAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,filter:o,timezone:a})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:s,headers:m(n,d)})})),q=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,filters:a,timezone:s,depth:n,headers:d,headersToExclude:i}=e;return N({url:t,body:{"calendar-multiget":Object.assign(Object.assign({_attributes:h([exports.DAVNamespace.DAV,exports.DAVNamespace.CALDAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,[`${exports.DAVNamespaceShort.DAV}:href`]:o},f("filter",a)),{timezone:s})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:n,headers:m(d,i)})})),Q=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:s}=e;return g({url:t,init:{method:"MKCALENDAR",headers:m(v(Object.assign({depth:o},a)),s),namespace:exports.DAVNamespaceShort.DAV,body:{[`${exports.DAVNamespaceShort.CALDAV}:mkcalendar`]:{_attributes:h([exports.DAVNamespace.DAV,exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALDAV_APPLE]),set:{prop:r}}}}})})),G=e=>n(void 0,void 0,void 0,(function*(){const{headers:t,account:r,props:o,projectedProps:a,headersToExclude:s}=null!=e?e:{},d=["homeUrl","rootUrl"];if(!r||!C(r,d)){if(!r)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${j(r,d)} before fetchCalendars`)}const i=yield y({url:r.homeUrl,props:null!=o?o:{[`${exports.DAVNamespaceShort.CALDAV}:calendar-description`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-timezone`]:{},[`${exports.DAVNamespaceShort.DAV}:displayname`]:{},[`${exports.DAVNamespaceShort.CALDAV_APPLE}:calendar-color`]:{},[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{},[`${exports.DAVNamespaceShort.DAV}:resourcetype`]:{},[`${exports.DAVNamespaceShort.CALDAV}:supported-calendar-component-set`]:{},[`${exports.DAVNamespaceShort.DAV}:sync-token`]:{}},depth:"1",headers:m(t,s)});return Promise.all(i.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("calendar")})).filter((e=>{var t,r,o,a;return(Array.isArray(null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet.comp)?null===(r=e.props)||void 0===r?void 0:r.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(a=null===(o=e.props)||void 0===o?void 0:o.supportedCalendarComponentSet.comp)||void 0===a?void 0:a._attributes.name]||[]).some((e=>Object.values(c).includes(e)))})).map((e=>{var t,o,s,n,d,i,c,l,u,p,h,v,m,A,D,g;const y=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,b=null===(o=e.props)||void 0===o?void 0:o.calendarTimezone;return Object.assign({description:"string"==typeof y?y:"",timezone:"string"==typeof b?b:"",url:new URL(null!==(s=e.href)&&void 0!==s?s:"",null!==(n=r.rootUrl)&&void 0!==n?n:"").href,ctag:null===(d=e.props)||void 0===d?void 0:d.getctag,calendarColor:null===(i=e.props)||void 0===i?void 0:i.calendarColor,displayName:null!==(l=null===(c=e.props)||void 0===c?void 0:c.displayname._cdata)&&void 0!==l?l:null===(u=e.props)||void 0===u?void 0:u.displayname,components:Array.isArray(null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp)?null===(h=e.props)||void 0===h?void 0:h.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(m=null===(v=e.props)||void 0===v?void 0:v.supportedCalendarComponentSet.comp)||void 0===m?void 0:m._attributes.name],resourcetype:Object.keys(null===(A=e.props)||void 0===A?void 0:A.resourcetype),syncToken:null===(D=e.props)||void 0===D?void 0:D.syncToken},f("projectedProps",Object.fromEntries(Object.entries(null!==(g=e.props)&&void 0!==g?g:{}).filter((([e])=>null==a?void 0:a[e])))))})).map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:m(t,s)})})})))))})),J=e=>n(void 0,void 0,void 0,(function*(){const{calendar:t,objectUrls:r,filters:o,timeRange:a,headers:s,expand:n,urlFilter:d=(e=>Boolean(null==e?void 0:e.includes(".ics"))),useMultiGet:i=!0,headersToExclude:c}=e;if(a){const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(a.start)&&e.test(a.end)||t.test(a.start)&&t.test(a.end)))throw new Error("invalid timeRange format, not in ISO8601")}z(`Fetching calendar objects from ${null==t?void 0:t.url}`);const l=["url"];if(!t||!C(t,l)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${j(t,l)} before fetchCalendarObjects`)}const u=null!=o?o:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":Object.assign({_attributes:{name:"VEVENT"}},a?{"time-range":{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})}}],p=(null!=r?r:(yield Z({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:Object.assign({},n&&a?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:u,depth:"1",headers:m(s,c)})).map((e=>{var t;return null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(d).map((e=>new URL(e).pathname));let h=[];return p.length>0&&(h=!i||n?yield Z({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:Object.assign({},n&&a?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:u,depth:"1",headers:m(s,c)}):yield q({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:Object.assign({},n&&a?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},objectUrls:p,depth:"1",headers:m(s,c)})),h.map((e=>{var r,o,a,s,n,d;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(o=e.props)||void 0===o?void 0:o.getetag}`,data:null!==(n=null===(s=null===(a=e.props)||void 0===a?void 0:a.calendarData)||void 0===s?void 0:s._cdata)&&void 0!==n?n:null===(d=e.props)||void 0===d?void 0:d.calendarData}}))})),K=e=>n(void 0,void 0,void 0,(function*(){const{calendar:t,iCalString:r,filename:o,headers:a,headersToExclude:s}=e;return b({url:new URL(o,t.url).href,data:r,headers:m(Object.assign({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*"},a),s)})})),W=e=>n(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return V({url:t.url,data:t.data,etag:t.etag,headers:m(Object.assign({"content-type":"text/calendar; charset=utf-8"},r),o)})})),Y=e=>n(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return x({url:t.url,etag:t.etag,headers:m(r,o)})})),X=e=>n(void 0,void 0,void 0,(function*(){var t;const{oldCalendars:r,account:o,detailedResult:a,headers:s,headersToExclude:d}=e;if(!o)throw new Error("Must have account before syncCalendars");const i=null!==(t=null!=r?r:o.calendars)&&void 0!==t?t:[],c=yield G({account:o,headers:m(s,d)}),l=c.filter((e=>i.every((t=>!p(t.url,e.url)))));z(`new calendars: ${l.map((e=>e.displayName))}`);const u=i.reduce(((e,t)=>{const r=c.find((e=>p(e.url,t.url)));return r&&(r.syncToken&&r.syncToken!==t.syncToken||r.ctag&&r.ctag!==t.ctag)?[...e,r]:e}),[]);z(`updated calendars: ${u.map((e=>e.displayName))}`);const h=yield Promise.all(u.map((e=>n(void 0,void 0,void 0,(function*(){return yield w({collection:Object.assign(Object.assign({},e),{objectMultiGet:q}),method:"webdav",headers:m(s,d),account:o})}))))),v=i.filter((e=>c.every((t=>!p(t.url,e.url)))));z(`deleted calendars: ${v.map((e=>e.displayName))}`);const f=i.filter((e=>c.some((t=>p(t.url,e.url)&&(t.syncToken&&t.syncToken!==e.syncToken||t.ctag&&t.ctag!==e.ctag)))));return a?{created:l,updated:u,deleted:v}:[...f,...l,...h]})),ee=e=>n(void 0,void 0,void 0,(function*(){const{url:t,timeRange:r,depth:o,headers:a,headersToExclude:s}=e;if(!r)throw new Error("timeRange is required");{const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(r.start)&&e.test(r.end)||t.test(r.start)&&t.test(r.end)))throw new Error("invalid timeRange format, not in ISO8601")}return(yield N({url:t,body:{"free-busy-query":v({_attributes:h([exports.DAVNamespace.CALDAV]),[`${exports.DAVNamespaceShort.CALDAV}:time-range`]:{_attributes:{start:`${new Date(r.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(r.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:o,headers:m(a,s)}))[0]}));var te=Object.freeze({__proto__:null,calendarMultiGet:q,calendarQuery:Z,createCalendarObject:K,deleteCalendarObject:Y,fetchCalendarObjects:J,fetchCalendars:G,freeBusyQuery:ee,makeCalendar:Q,syncCalendars:X,updateCalendarObject:W});const re=r("tsdav:account"),oe=e=>n(void 0,void 0,void 0,(function*(){var r,o;re("Service discovery...");const{account:a,headers:s,headersToExclude:n}=e,d=new URL(a.serverUrl),i=new URL(`/.well-known/${a.accountType}`,d);i.protocol=null!==(r=d.protocol)&&void 0!==r?r:"http";try{const e=yield t.fetch(i.href,{headers:m(s,n),method:"PROPFIND",redirect:"manual"});if(e.status>=300&&e.status<400){const t=e.headers.get("Location");if("string"==typeof t&&t.length){re(`Service discovery redirected to ${t}`);const e=new URL(t,d);return e.hostname===i.hostname&&i.port&&!e.port&&(e.port=i.port),e.protocol=null!==(o=d.protocol)&&void 0!==o?o:"http",e.href}}}catch(e){re(`Service discovery failed: ${e.stack}`)}return d.href})),ae=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,s;const{account:n,headers:d,headersToExclude:i}=e,c=["rootUrl"];if(!C(n,c))throw new Error(`account must have ${j(n,c)} before fetchPrincipalUrl`);re(`Fetching principal url from path ${n.rootUrl}`);const[l]=yield y({url:n.rootUrl,props:{[`${exports.DAVNamespaceShort.DAV}:current-user-principal`]:{}},depth:"0",headers:m(d,i)});if(!l.ok&&(re(`Fetch principal url failed: ${l.statusText}`),401===l.status))throw new Error("Invalid credentials");return re(`Fetched principal url ${null===(r=null===(t=l.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(s=null===(a=null===(o=l.props)||void 0===o?void 0:o.currentUserPrincipal)||void 0===a?void 0:a.href)&&void 0!==s?s:"",n.rootUrl).href})),se=e=>n(void 0,void 0,void 0,(function*(){var t,r;const{account:o,headers:a,headersToExclude:s}=e,n=["principalUrl","rootUrl"];if(!C(o,n))throw new Error(`account must have ${j(o,n)} before fetchHomeUrl`);re(`Fetch home url from ${o.principalUrl}`);const d=(yield y({url:o.principalUrl,props:"caldav"===o.accountType?{[`${exports.DAVNamespaceShort.CALDAV}:calendar-home-set`]:{}}:{[`${exports.DAVNamespaceShort.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:m(a,s)})).find((e=>p(o.principalUrl,e.href)));if(!d||!d.ok)throw new Error("cannot find homeUrl");const i=new URL("caldav"===o.accountType?null===(t=null==d?void 0:d.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==d?void 0:d.props)||void 0===r?void 0:r.addressbookHomeSet.href,o.rootUrl).href;return re(`Fetched home url ${i}`),i})),ne=e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o=!1,loadObjects:a=!1,headersToExclude:s}=e,d=Object.assign({},t);return d.rootUrl=yield oe({account:t,headers:m(r,s)}),d.principalUrl=yield ae({account:d,headers:m(r,s)}),d.homeUrl=yield se({account:d,headers:m(r,s)}),(o||a)&&("caldav"===t.accountType?d.calendars=yield G({headers:m(r,s),account:d}):"carddav"===t.accountType&&(d.addressBooks=yield P({headers:m(r,s),account:d}))),a&&("caldav"===t.accountType&&d.calendars?d.calendars=yield Promise.all(d.calendars.map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield J({calendar:e,headers:m(r,s)})})}))))):"carddav"===t.accountType&&d.addressBooks&&(d.addressBooks=yield Promise.all(d.addressBooks.map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield H({addressBook:e,headers:m(r,s)})})}))))))),d}));var de=Object.freeze({__proto__:null,createAccount:ne,fetchHomeUrl:se,fetchPrincipalUrl:ae,serviceDiscovery:oe});const ie=r("tsdav:authHelper"),ce=(e,t)=>(...r)=>e(Object.assign(Object.assign({},t),r[0])),le=e=>(ie(`Basic auth token generated: ${a.encode(`${e.username}:${e.password}`)}`),{authorization:`Basic ${a.encode(`${e.username}:${e.password}`)}`}),ue=e=>n(void 0,void 0,void 0,(function*(){const r=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!C(e,r))throw new Error(`Oauth credentials missing: ${j(e,r)}`);const o=new URLSearchParams({grant_type:"authorization_code",code:e.authorizationCode,redirect_uri:e.redirectUrl,client_id:e.clientId,client_secret:e.clientSecret});ie(e.tokenUrl),ie(o.toString());const a=yield t.fetch(e.tokenUrl,{method:"POST",body:o.toString(),headers:{"content-length":`${o.toString().length}`,"content-type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Fetch Oauth tokens failed: ${yield a.text()}`),{}})),pe=e=>n(void 0,void 0,void 0,(function*(){const r=["refreshToken","clientId","clientSecret","tokenUrl"];if(!C(e,r))throw new Error(`Oauth credentials missing: ${j(e,r)}`);const o=new URLSearchParams({client_id:e.clientId,client_secret:e.clientSecret,refresh_token:e.refreshToken,grant_type:"refresh_token"}),a=yield t.fetch(e.tokenUrl,{method:"POST",body:o.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Refresh access token failed: ${yield a.text()}`),{}})),he=e=>n(void 0,void 0,void 0,(function*(){var t;ie("Fetching oauth headers");let r={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(t=e.expiration)&&void 0!==t?t:0))&&(r=yield pe(e)):r=yield ue(e),ie(`Oauth tokens fetched: ${r.access_token}`),{tokens:r,headers:{authorization:`Bearer ${r.access_token}`}}}));var ve=Object.freeze({__proto__:null,defaultParam:ce,fetchOauthTokens:ue,getBasicAuthHeaders:le,getOauthHeaders:he,refreshAccessToken:pe});const fe=e=>n(void 0,void 0,void 0,(function*(){var t;const{serverUrl:r,credentials:o,authMethod:a,defaultAccountType:d,authFunction:i}=e;let c={};switch(a){case"Basic":c=le(o);break;case"Oauth":c=(yield he(o)).headers;break;case"Digest":c={Authorization:`Digest ${o.digestString}`};break;case"Custom":c=null!==(t=yield null==i?void 0:i(o))&&void 0!==t?t:{};break;default:throw new Error("Invalid auth method")}const l=d?yield ne({account:{serverUrl:r,credentials:o,accountType:d},headers:c}):void 0,u=ce(b,{url:r,headers:c}),p=ce(V,{headers:c,url:r}),h=ce(x,{headers:c,url:r}),v=ce(y,{headers:c}),f=ce(N,{headers:c}),m=ce(E,{headers:c}),A=ce($,{headers:c}),D=ce(k,{headers:c}),O=ce(T,{headers:c}),C=ce(w,{headers:c,account:l}),j=ce(Z,{headers:c}),S=ce(q,{headers:c}),_=ce(Q,{headers:c}),R=ce(G,{headers:c,account:l}),F=ce(J,{headers:c}),z=ce(K,{headers:c}),ee=ce(W,{headers:c}),te=ce(Y,{headers:c}),re=ce(X,{account:l,headers:c}),oe=ce(U,{headers:c}),ae=ce(L,{headers:c});return{davRequest:e=>n(void 0,void 0,void 0,(function*(){const{init:t}=e,r=s(e,["init"]),{headers:o}=t,a=s(t,["headers"]);return g(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},a),{headers:Object.assign(Object.assign({},c),o)})}))})),propfind:v,createAccount:e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:a,loadCollections:s,loadObjects:n}=e;return ne({account:Object.assign({serverUrl:r,credentials:o},t),headers:Object.assign(Object.assign({},c),a),loadCollections:s,loadObjects:n})})),createObject:u,updateObject:p,deleteObject:h,calendarQuery:j,addressBookQuery:oe,collectionQuery:f,makeCollection:m,calendarMultiGet:S,makeCalendar:_,syncCollection:A,supportedReportSet:D,isCollectionDirty:O,smartCollectionSync:C,fetchCalendars:R,fetchCalendarObjects:F,createCalendarObject:z,updateCalendarObject:ee,deleteCalendarObject:te,syncCalendars:re,fetchAddressBooks:ce(P,{account:l,headers:c}),addressBookMultiGet:ae,fetchVCards:ce(H,{headers:c}),createVCard:ce(B,{headers:c}),updateVCard:ce(I,{headers:c}),deleteVCard:ce(M,{headers:c})}}));class me{constructor(e){var t,r;this.serverUrl=e.serverUrl,this.credentials=e.credentials,this.authMethod=null!==(t=e.authMethod)&&void 0!==t?t:"Basic",this.accountType=null!==(r=e.defaultAccountType)&&void 0!==r?r:"caldav",this.authFunction=e.authFunction}login(){return n(this,void 0,void 0,(function*(){var e;switch(this.authMethod){case"Basic":this.authHeaders=le(this.credentials);break;case"Oauth":this.authHeaders=(yield he(this.credentials)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=yield null===(e=this.authFunction)||void 0===e?void 0:e.call(this,this.credentials);break;default:throw new Error("Invalid auth method")}this.account=this.accountType?yield ne({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders}):void 0}))}davRequest(e){return n(this,void 0,void 0,(function*(){const{init:t}=e,r=s(e,["init"]),{headers:o}=t,a=s(t,["headers"]);return g(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},a),{headers:Object.assign(Object.assign({},this.authHeaders),o)})}))}))}createObject(...e){return n(this,void 0,void 0,(function*(){return ce(b,{url:this.serverUrl,headers:this.authHeaders})(e[0])}))}updateObject(...e){return n(this,void 0,void 0,(function*(){return ce(V,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}deleteObject(...e){return n(this,void 0,void 0,(function*(){return ce(x,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}propfind(...e){return n(this,void 0,void 0,(function*(){return ce(y,{headers:this.authHeaders})(e[0])}))}createAccount(e){return n(this,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o,loadObjects:a}=e;return ne({account:Object.assign({serverUrl:this.serverUrl,credentials:this.credentials},t),headers:Object.assign(Object.assign({},this.authHeaders),r),loadCollections:o,loadObjects:a})}))}collectionQuery(...e){return n(this,void 0,void 0,(function*(){return ce(N,{headers:this.authHeaders})(e[0])}))}makeCollection(...e){return n(this,void 0,void 0,(function*(){return ce(E,{headers:this.authHeaders})(e[0])}))}syncCollection(...e){return n(this,void 0,void 0,(function*(){return ce($,{headers:this.authHeaders})(e[0])}))}supportedReportSet(...e){return n(this,void 0,void 0,(function*(){return ce(k,{headers:this.authHeaders})(e[0])}))}isCollectionDirty(...e){return n(this,void 0,void 0,(function*(){return ce(T,{headers:this.authHeaders})(e[0])}))}smartCollectionSync(...e){return n(this,void 0,void 0,(function*(){return ce(w,{headers:this.authHeaders,account:this.account})(e[0])}))}calendarQuery(...e){return n(this,void 0,void 0,(function*(){return ce(Z,{headers:this.authHeaders})(e[0])}))}makeCalendar(...e){return n(this,void 0,void 0,(function*(){return ce(Q,{headers:this.authHeaders})(e[0])}))}calendarMultiGet(...e){return n(this,void 0,void 0,(function*(){return ce(q,{headers:this.authHeaders})(e[0])}))}fetchCalendars(...e){return n(this,void 0,void 0,(function*(){return ce(G,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchCalendarObjects(...e){return n(this,void 0,void 0,(function*(){return ce(J,{headers:this.authHeaders})(e[0])}))}createCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(K,{headers:this.authHeaders})(e[0])}))}updateCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(W,{headers:this.authHeaders})(e[0])}))}deleteCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(Y,{headers:this.authHeaders})(e[0])}))}syncCalendars(...e){return n(this,void 0,void 0,(function*(){return ce(X,{headers:this.authHeaders,account:this.account})(e[0])}))}addressBookQuery(...e){return n(this,void 0,void 0,(function*(){return ce(U,{headers:this.authHeaders})(e[0])}))}addressBookMultiGet(...e){return n(this,void 0,void 0,(function*(){return ce(L,{headers:this.authHeaders})(e[0])}))}fetchAddressBooks(...e){return n(this,void 0,void 0,(function*(){return ce(P,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchVCards(...e){return n(this,void 0,void 0,(function*(){return ce(H,{headers:this.authHeaders})(e[0])}))}createVCard(...e){return n(this,void 0,void 0,(function*(){return ce(B,{headers:this.authHeaders})(e[0])}))}updateVCard(...e){return n(this,void 0,void 0,(function*(){return ce(I,{headers:this.authHeaders})(e[0])}))}deleteVCard(...e){return n(this,void 0,void 0,(function*(){return ce(M,{headers:this.authHeaders})(e[0])}))}}var Ae=Object.freeze({__proto__:null,DAVClient:me,createDAVClient:fe}),De=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({DAVNamespace:exports.DAVNamespace,DAVNamespaceShort:exports.DAVNamespaceShort,DAVAttributeMap:d},Ae),O),_),de),F),te),ve),A);exports.DAVAttributeMap=d,exports.DAVClient=me,exports.addressBookQuery=U,exports.calendarMultiGet=q,exports.calendarQuery=Z,exports.cleanupFalsy=v,exports.collectionQuery=N,exports.createAccount=ne,exports.createCalendarObject=K,exports.createDAVClient=fe,exports.createObject=b,exports.createVCard=B,exports.davRequest=g,exports.default=De,exports.deleteCalendarObject=Y,exports.deleteObject=x,exports.deleteVCard=M,exports.fetchAddressBooks=P,exports.fetchCalendarObjects=J,exports.fetchCalendars=G,exports.fetchOauthTokens=ue,exports.fetchVCards=H,exports.freeBusyQuery=ee,exports.getBasicAuthHeaders=le,exports.getDAVAttribute=h,exports.getOauthHeaders=he,exports.isCollectionDirty=T,exports.makeCalendar=Q,exports.propfind=y,exports.refreshAccessToken=pe,exports.smartCollectionSync=w,exports.supportedReportSet=k,exports.syncCalendars=X,exports.syncCollection=$,exports.updateCalendarObject=W,exports.updateObject=V,exports.updateVCard=I,exports.urlContains=p,exports.urlEquals=u; diff --git a/dist/tsdav.min.js b/dist/tsdav.min.js index e9b9eb7..f86a4d2 100644 --- a/dist/tsdav.min.js +++ b/dist/tsdav.min.js @@ -1,2 +1,2 @@ -function e(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i-1};function l(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function d(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function g(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function y(e){var t=new FileReader,r=g(t);return t.readAsArrayBuffer(e),r}function v(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=v(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=v(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=p(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(y)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=g(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?t:e}(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function A(e,t){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},m.call(w.prototype),m.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},A.error=function(){var e=new A(null,{status:0,statusText:""});return e.type="error",e};var T=[301,302,303,307,308];A.redirect=function(e,t){if(-1===T.indexOf(t))throw new RangeError("Invalid status code");return new A(null,{status:t,headers:{location:e}})},t.DOMException=r.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function _(e,n){return new Promise((function(i,a){var u=new w(e,n);if(u.signal&&u.signal.aborted)return a(new t.DOMException("Aborted","AbortError"));var c=new XMLHttpRequest;function l(){c.abort()}c.onload=function(){var e,t,r={status:c.status,statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in c?c.responseURL:r.headers.get("X-Request-URL");var n="response"in c?c.response:c.responseText;setTimeout((function(){i(new A(n,r))}),0)},c.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},c.onabort=function(){setTimeout((function(){a(new t.DOMException("Aborted","AbortError"))}),0)},c.open(u.method,function(e){try{return""===e&&r.location.href?r.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?c.withCredentials=!0:"omit"===u.credentials&&(c.withCredentials=!1),"responseType"in c&&(o?c.responseType="blob":s&&u.headers.get("Content-Type")&&-1!==u.headers.get("Content-Type").indexOf("application/octet-stream")&&(c.responseType="arraybuffer")),!n||"object"!=typeof n.headers||n.headers instanceof f?u.headers.forEach((function(e,t){c.setRequestHeader(t,e)})):Object.getOwnPropertyNames(n.headers).forEach((function(e){c.setRequestHeader(e,d(n.headers[e]))})),u.signal&&(u.signal.addEventListener("abort",l),c.onreadystatechange=function(){4===c.readyState&&u.signal.removeEventListener("abort",l)}),c.send(void 0===u._bodyInit?null:u._bodyInit)}))}_.polyfill=!0,r.fetch||(r.fetch=_,r.Headers=f,r.Request=w,r.Response=A),t.Headers=f,t.Request=w,t.Response=A,t.fetch=_}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=n.fetch?n:i;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t}(o,o.exports);var a=o.exports,s="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function u(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}var l=u,d=c;function h(e){if(l===setTimeout)return setTimeout(e,0);if((l===u||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}"function"==typeof s.setTimeout&&(l=setTimeout),"function"==typeof s.clearTimeout&&(d=clearTimeout);var f,p=[],g=!1,y=-1;function v(){g&&f&&(g=!1,f.length?p=f.concat(p):y=-1,p.length&&m())}function m(){if(!g){var e=h(v);g=!0;for(var t=p.length;t;){for(f=p,p=[];++y1)for(var r=1;r=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}return N=function(s,u){u=u||{};var c=typeof s;if("string"===c&&s.length>0)return function(a){if((a=String(a)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(!s)return;var u=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*o;case"weeks":case"week":case"w":return u*i;case"days":case"day":case"d":return u*n;case"hours":case"hour":case"hrs":case"hr":case"h":return u*r;case"minutes":case"minute":case"mins":case"min":case"m":return u*t;case"seconds":case"second":case"secs":case"sec":case"s":return u*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(s);if("number"===c&&isFinite(s))return u.long?function(i){var o=Math.abs(i);if(o>=n)return a(i,o,n,"day");if(o>=r)return a(i,o,r,"hour");if(o>=t)return a(i,o,t,"minute");if(o>=e)return a(i,o,e,"second");return i+" ms"}(s):function(i){var o=Math.abs(i);if(o>=n)return Math.round(i/n)+"d";if(o>=r)return Math.round(i/r)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))},N}var P=function(e){function t(e){let n,i,o,a=null;function s(...e){if(!s.enabled)return;const r=s,i=Number(new Date),o=i-(n||i);r.diff=o,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";a++;const o=t.formatters[i];if("function"==typeof o){const t=e[a];n=o.call(r,t),e.splice(a,1),a--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=r,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{a=e}}),"function"==typeof t.init&&t.init(s),s}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==L&&"env"in L&&(e=L.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=P(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(k,k.exports);var U,B=n(k.exports);!function(e){e.CALENDAR_SERVER="http://calendarserver.org/ns/",e.CALDAV_APPLE="http://apple.com/ns/ical/",e.CALDAV="urn:ietf:params:xml:ns:caldav",e.CARDDAV="urn:ietf:params:xml:ns:carddav",e.DAV="DAV:"}(U||(U={}));const M={[U.CALDAV]:"xmlns:c",[U.CARDDAV]:"xmlns:card",[U.CALENDAR_SERVER]:"xmlns:cs",[U.CALDAV_APPLE]:"xmlns:ca",[U.DAV]:"xmlns:d"};var V,K;!function(e){e.CALDAV="c",e.CARDDAV="card",e.CALENDAR_SERVER="cs",e.CALDAV_APPLE="ca",e.DAV="d"}(V||(V={})),function(e){e.VEVENT="VEVENT",e.VTODO="VTODO",e.VJOURNAL="VJOURNAL",e.VFREEBUSY="VFREEBUSY",e.VTIMEZONE="VTIMEZONE",e.VALARM="VALARM"}(K||(K={}));var $=[],H=[],Y="undefined"!=typeof Uint8Array?Uint8Array:Array,z=!1;function q(){z=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+$[i>>12&63]+$[i>>6&63]+$[63&i]);return o.join("")}function W(e){var t;z||q();for(var r=e.length,n=r%3,i="",o=[],a=16383,s=0,u=r-n;su?u:s+a));return 1===n?(t=e[r-1],i+=$[t>>2],i+=$[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=$[t>>10],i+=$[t>>4&63],i+=$[t<<2&63],i+="="),o.push(i),o.join("")}function Q(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,l=-7,d=r?i-1:0,h=r?-1:1,f=e[t+d];for(d+=h,o=f&(1<<-l)-1,f>>=-l,l+=s;l>0;o=256*o+e[t+d],d+=h,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+e[t+d],d+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),o-=c}return(f?-1:1)*a*Math.pow(2,o-n)}function X(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+d>=1?h/u:h*Math.pow(2,1-d))*u>=2&&(a++,u/=2),a+d>=l?(s=0,a=l):a+d>=1?(s=(t*u-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[r+f]=255&a,f+=p,a/=256,c-=8);e[r+f-p]|=128*g}var Z={}.toString,J=Array.isArray||function(e){return"[object Array]"==Z.call(e)};function ee(){return re.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function te(e,t){if(ee()=ee())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ee().toString(16)+" bytes");return 0|e}function ue(e){return!(null==e||!e._isBuffer)}function ce(e,t){if(ue(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ke(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ie(e).length;default:if(n)return ke(e).length;t=(""+t).toLowerCase(),n=!0}}function le(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return _e(this,t,r);case"utf8":case"utf-8":return Ee(this,t,r);case"ascii":return Ae(this,t,r);case"latin1":case"binary":return Te(this,t,r);case"base64":return we(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function de(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function he(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=re.from(t,n)),ue(t))return 0===t.length?-1:fe(e,t,r,n,i);if("number"==typeof t)return t&=255,re.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):fe(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function fe(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var l=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var d=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function we(e,t,r){return 0===t&&r===e.length?W(e):W(e.slice(t,r))}function Ee(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+d<=r)switch(d){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=d}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},re.prototype.compare=function(e,t,r,n,i){if(!ue(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(n,i),c=e.slice(t,r),l=0;li)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return pe(this,e,t,r);case"utf8":case"utf-8":return ge(this,e,t,r);case"ascii":return ye(this,e,t,r);case"latin1":case"binary":return ve(this,e,t,r);case"base64":return me(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return be(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},re.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ae(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function xe(e,t,r,n,i,o){if(!ue(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function De(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Re(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Se(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Fe(e,t,r,n,i){return i||Se(e,0,r,4),X(e,t,r,n,23,4),r+4}function Ne(e,t,r,n,i){return i||Se(e,0,r,8),X(e,t,r,n,52,8),r+8}re.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},re.prototype.readUInt8=function(e,t){return t||Oe(e,1,this.length),this[e]},re.prototype.readUInt16LE=function(e,t){return t||Oe(e,2,this.length),this[e]|this[e+1]<<8},re.prototype.readUInt16BE=function(e,t){return t||Oe(e,2,this.length),this[e]<<8|this[e+1]},re.prototype.readUInt32LE=function(e,t){return t||Oe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},re.prototype.readUInt32BE=function(e,t){return t||Oe(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},re.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Oe(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},re.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Oe(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},re.prototype.readInt8=function(e,t){return t||Oe(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},re.prototype.readInt16LE=function(e,t){t||Oe(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},re.prototype.readInt16BE=function(e,t){t||Oe(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},re.prototype.readInt32LE=function(e,t){return t||Oe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},re.prototype.readInt32BE=function(e,t){return t||Oe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},re.prototype.readFloatLE=function(e,t){return t||Oe(e,4,this.length),Q(this,e,!0,23,4)},re.prototype.readFloatBE=function(e,t){return t||Oe(e,4,this.length),Q(this,e,!1,23,4)},re.prototype.readDoubleLE=function(e,t){return t||Oe(e,8,this.length),Q(this,e,!0,52,8)},re.prototype.readDoubleBE=function(e,t){return t||Oe(e,8,this.length),Q(this,e,!1,52,8)},re.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||xe(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},re.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,1,255,0),re.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},re.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,65535,0),re.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):De(this,e,t,!0),t+2},re.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,65535,0),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):De(this,e,t,!1),t+2},re.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,4294967295,0),re.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Re(this,e,t,!0),t+4},re.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,4294967295,0),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Re(this,e,t,!1),t+4},re.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);xe(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},re.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);xe(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},re.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,1,127,-128),re.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},re.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,32767,-32768),re.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):De(this,e,t,!0),t+2},re.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,32767,-32768),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):De(this,e,t,!1),t+2},re.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,2147483647,-2147483648),re.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Re(this,e,t,!0),t+4},re.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Re(this,e,t,!1),t+4},re.prototype.writeFloatLE=function(e,t,r){return Fe(this,e,t,!0,r)},re.prototype.writeFloatBE=function(e,t,r){return Fe(this,e,t,!1,r)},re.prototype.writeDoubleLE=function(e,t,r){return Ne(this,e,t,!0,r)},re.prototype.writeDoubleBE=function(e,t,r){return Ne(this,e,t,!1,r)},re.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!re.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ie(e){return function(e){var t,r,n,i,o,a;z||q();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[s-2]?2:"="===e[s-1]?1:0,a=new Y(3*s/4-o),n=o>0?s-4:s;var u=0;for(t=0,r=0;t>16&255,a[u++]=i>>8&255,a[u++]=255&i;return 2===o?(i=H[e.charCodeAt(t)]<<2|H[e.charCodeAt(t+1)]>>4,a[u++]=255&i):1===o&&(i=H[e.charCodeAt(t)]<<10|H[e.charCodeAt(t+1)]<<4|H[e.charCodeAt(t+2)]>>2,a[u++]=i>>8&255,a[u++]=255&i),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(je,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Pe(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ue(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Be={};function Me(){}function Ve(){Ve.init.call(this)}function Ke(e){return void 0===e._maxListeners?Ve.defaultMaxListeners:e._maxListeners}function $e(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Xe(e,n),o=0;o0&&a.length>i){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else a=o[t]=r,++e._eventsCount;return e}function We(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Qe(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Xe(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}Me.prototype=Object.create(null),Ve.EventEmitter=Ve,Ve.usingDomains=!1,Ve.prototype.domain=void 0,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.init=function(){this.domain=null,Ve.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Me,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ve.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Ve.prototype.getMaxListeners=function(){return Ke(this)},Ve.prototype.emit=function(e){var t,r,n,i,o,a,s,u="error"===e;if(a=this._events)u=u&&null==a.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(r=a[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:$e(r,l,this);break;case 2:He(r,l,this,arguments[1]);break;case 3:Ye(r,l,this,arguments[1],arguments[2]);break;case 4:ze(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Me,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var Ze="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Je=/%[sdj%]/g;function et(e){if(!ht(e)){for(var t=[],r=0;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),a=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),lt(t)?r.showHidden=t:t&&wt(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=ot),st(r,e,r.depth)}function ot(e,t){var r=it.styles[t];return r?"["+it.colors[r][0]+"m"+e+"["+it.colors[r][1]+"m":e}function at(e,t){return e}function st(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==it&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=st(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(lt(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),a=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ut(t);if(0===o.length){if(mt(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(pt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ut(t)}var u,c,l="",d=!1,h=["{","}"];(u=t,Array.isArray(u)&&(d=!0,h=["[","]"]),mt(t))&&(l=" [Function"+(t.name?": "+t.name:"")+"]");return pt(t)&&(l=" "+RegExp.prototype.toString.call(t)),yt(t)&&(l=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(l=" "+ut(t)),0!==o.length||d&&0!=t.length?r<0?pt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=d?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,l,h)):h[0]+l+h[1]}function ut(e){return"["+Error.prototype.toString.call(e)+"]"}function ct(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),Et(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=dt(r)?st(e,u.value,null):st(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),ft(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function lt(e){return"boolean"==typeof e}function dt(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function pt(e){return gt(e)&&"[object RegExp]"===bt(e)}function gt(e){return"object"==typeof e&&null!==e}function yt(e){return gt(e)&&"[object Date]"===bt(e)}function vt(e){return gt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function wt(e,t){if(!t||!gt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function At(){this.head=null,this.tail=null,this.length=0}it.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},it.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},At.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},At.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},At.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},At.prototype.clear=function(){this.head=this.tail=null,this.length=0},At.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},At.prototype.concat=function(e){if(0===this.length)return re.alloc(0);if(1===this.length)return this.head.data;for(var t=re.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var Tt=re.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Tt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Ot;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=xt;break;default:return void(this.write=Ct)}this.charBuffer=new re(6),this.charReceived=0,this.charLength=0}function Ct(e){return e.toString(this.encoding)}function Ot(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function xt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t};var Dt=Object.freeze({__proto__:null,StringDecoder:_t});Ft.ReadableState=St;var Rt=function(e){if(ft(rt)&&(rt=L.env.NODE_DEBUG||""),e=e.toUpperCase(),!nt[e])if(new RegExp("\\b"+e+"\\b","i").test(rt)){nt[e]=function(){var t=et.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else nt[e]=function(){};return nt[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new At,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function Ft(e){if(!(this instanceof Ft))return new Ft(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),Ve.call(this)}function Nt(e,t,r,n,i){var o=function(e,t){var r=null;re.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Lt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Lt(e))),function(e,t){t.readingMore||(t.readingMore=!0,b(It,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Lt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Rt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?b(kt,e):kt(e))}function kt(e){Rt("emit readable"),e.emit("readable"),Bt(e)}function It(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=re.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Vt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,b(Kt,t,e))}function Kt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function $t(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Rt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Vt(this):Lt(this),null;if(0===(e=jt(e,t))&&t.ended)return 0===t.length&&Vt(this),null;var n,i=t.needReadable;return Rt("need readable",i),(0===t.length||t.length-e0?Mt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Vt(this)),null!==n&&this.emit("data",n),n},Ft.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ft.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,Rt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?a:c;function o(e){Rt("onunpipe"),e===r&&c()}function a(){Rt("onend"),e.end()}n.endEmitted?b(i):r.once("end",i),e.on("unpipe",o);var s=function(e){return function(){var t=e._readableState;Rt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Bt(e))}}(r);e.on("drain",s);var u=!1;function c(){Rt("cleanup"),e.removeListener("close",f),e.removeListener("finish",p),e.removeListener("drain",s),e.removeListener("error",h),e.removeListener("unpipe",o),r.removeListener("end",a),r.removeListener("end",c),r.removeListener("data",d),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||s()}var l=!1;function d(t){Rt("ondata"),l=!1,!1!==e.write(t)||l||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==$t(n.pipes,e))&&!u&&(Rt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,l=!0),r.pause())}function h(t){var r;Rt("onerror",t),g(),e.removeListener("error",h),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function f(){e.removeListener("finish",p),g()}function p(){Rt("onfinish"),e.removeListener("close",f),g()}function g(){Rt("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",f),e.once("finish",p),e.emit("pipe",r),n.flowing||(Rt("pipe resume"),r.resume()),e},Ft.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Jt(e,t),r&&(t.finished?b(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ze(ir,Ft);for(var tr=Object.keys(qt.prototype),rr=0;rr"===o?(_(n,"onsgmldeclaration",n.sgmlDecl),n.sgmlDecl="",n.state=E.TEXT):p(o)?(n.state=E.SGML_DECL_QUOTED,n.sgmlDecl+=o):n.sgmlDecl+=o;continue;case E.SGML_DECL_QUOTED:o===n.q&&(n.state=E.SGML_DECL,n.q=""),n.sgmlDecl+=o;continue;case E.DOCTYPE:">"===o?(n.state=E.TEXT,_(n,"ondoctype",n.doctype),n.doctype=!0):(n.doctype+=o,"["===o?n.state=E.DOCTYPE_DTD:p(o)&&(n.state=E.DOCTYPE_QUOTED,n.q=o));continue;case E.DOCTYPE_QUOTED:n.doctype+=o,o===n.q&&(n.q="",n.state=E.DOCTYPE);continue;case E.DOCTYPE_DTD:n.doctype+=o,"]"===o?n.state=E.DOCTYPE:p(o)&&(n.state=E.DOCTYPE_DTD_QUOTED,n.q=o);continue;case E.DOCTYPE_DTD_QUOTED:n.doctype+=o,o===n.q&&(n.state=E.DOCTYPE_DTD,n.q="");continue;case E.COMMENT:"-"===o?n.state=E.COMMENT_ENDING:n.comment+=o;continue;case E.COMMENT_ENDING:"-"===o?(n.state=E.COMMENT_ENDED,n.comment=O(n.opt,n.comment),n.comment&&_(n,"oncomment",n.comment),n.comment=""):(n.comment+="-"+o,n.state=E.COMMENT);continue;case E.COMMENT_ENDED:">"!==o?(R(n,"Malformed comment"),n.comment+="--"+o,n.state=E.COMMENT):n.state=E.TEXT;continue;case E.CDATA:"]"===o?n.state=E.CDATA_ENDING:n.cdata+=o;continue;case E.CDATA_ENDING:"]"===o?n.state=E.CDATA_ENDING_2:(n.cdata+="]"+o,n.state=E.CDATA);continue;case E.CDATA_ENDING_2:">"===o?(n.cdata&&_(n,"oncdata",n.cdata),_(n,"onclosecdata"),n.cdata="",n.state=E.TEXT):"]"===o?n.cdata+="]":(n.cdata+="]]"+o,n.state=E.CDATA);continue;case E.PROC_INST:"?"===o?n.state=E.PROC_INST_ENDING:f(o)?n.state=E.PROC_INST_BODY:n.procInstName+=o;continue;case E.PROC_INST_BODY:if(!n.procInstBody&&f(o))continue;"?"===o?n.state=E.PROC_INST_ENDING:n.procInstBody+=o;continue;case E.PROC_INST_ENDING:">"===o?(_(n,"onprocessinginstruction",{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody="",n.state=E.TEXT):(n.procInstBody+="?"+o,n.state=E.PROC_INST_BODY);continue;case E.OPEN_TAG:y(l,o)?n.tagName+=o:(S(n),">"===o?j(n):"/"===o?n.state=E.OPEN_TAG_SLASH:(f(o)||R(n,"Invalid character in tag name"),n.state=E.ATTRIB));continue;case E.OPEN_TAG_SLASH:">"===o?(j(n,!0),L(n)):(R(n,"Forward-slash in opening tag not followed by >"),n.state=E.ATTRIB);continue;case E.ATTRIB:if(f(o))continue;">"===o?j(n):"/"===o?n.state=E.OPEN_TAG_SLASH:y(c,o)?(n.attribName=o,n.attribValue="",n.state=E.ATTRIB_NAME):R(n,"Invalid attribute name");continue;case E.ATTRIB_NAME:"="===o?n.state=E.ATTRIB_VALUE:">"===o?(R(n,"Attribute without value"),n.attribValue=n.attribName,N(n),j(n)):f(o)?n.state=E.ATTRIB_NAME_SAW_WHITE:y(l,o)?n.attribName+=o:R(n,"Invalid attribute name");continue;case E.ATTRIB_NAME_SAW_WHITE:if("="===o)n.state=E.ATTRIB_VALUE;else{if(f(o))continue;R(n,"Attribute without value"),n.tag.attributes[n.attribName]="",n.attribValue="",_(n,"onattribute",{name:n.attribName,value:""}),n.attribName="",">"===o?j(n):y(c,o)?(n.attribName=o,n.state=E.ATTRIB_NAME):(R(n,"Invalid attribute name"),n.state=E.ATTRIB)}continue;case E.ATTRIB_VALUE:if(f(o))continue;p(o)?(n.q=o,n.state=E.ATTRIB_VALUE_QUOTED):(R(n,"Unquoted attribute value"),n.state=E.ATTRIB_VALUE_UNQUOTED,n.attribValue=o);continue;case E.ATTRIB_VALUE_QUOTED:if(o!==n.q){"&"===o?n.state=E.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=o;continue}N(n),n.q="",n.state=E.ATTRIB_VALUE_CLOSED;continue;case E.ATTRIB_VALUE_CLOSED:f(o)?n.state=E.ATTRIB:">"===o?j(n):"/"===o?n.state=E.OPEN_TAG_SLASH:y(c,o)?(R(n,"No whitespace between attributes"),n.attribName=o,n.attribValue="",n.state=E.ATTRIB_NAME):R(n,"Invalid attribute name");continue;case E.ATTRIB_VALUE_UNQUOTED:if(!g(o)){"&"===o?n.state=E.ATTRIB_VALUE_ENTITY_U:n.attribValue+=o;continue}N(n),">"===o?j(n):n.state=E.ATTRIB;continue;case E.CLOSE_TAG:if(n.tagName)">"===o?L(n):y(l,o)?n.tagName+=o:n.script?(n.script+=""===o?L(n):R(n,"Invalid characters in closing tag");continue;case E.TEXT_ENTITY:case E.ATTRIB_VALUE_ENTITY_Q:case E.ATTRIB_VALUE_ENTITY_U:var u,m;switch(n.state){case E.TEXT_ENTITY:u=E.TEXT,m="textNode";break;case E.ATTRIB_VALUE_ENTITY_Q:u=E.ATTRIB_VALUE_QUOTED,m="attribValue";break;case E.ATTRIB_VALUE_ENTITY_U:u=E.ATTRIB_VALUE_UNQUOTED,m="attribValue"}";"===o?(n[m]+=k(n),n.entity="",n.state=u):y(n.entity.length?h:d,o)?n.entity+=o:(R(n,"Invalid character in entity name"),n[m]+="&"+n.entity+o,n.entity="",n.state=u);continue;default:throw new Error(n,"Unknown state: "+n.state)}return n.position>=n.bufferCheckPosition&&function(t){for(var n=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,o=0,a=r.length;on)switch(r[o]){case"textNode":C(t);break;case"cdata":_(t,"oncdata",t.cdata),t.cdata="";break;case"script":_(t,"onscript",t.script),t.script="";break;default:x(t,"Max buffer length exceeded: "+r[o])}i=Math.max(i,s)}var u=e.MAX_BUFFER_LENGTH-i;t.bufferCheckPosition=u+t.position}(n),n} -/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var e;C(e=this),""!==e.cdata&&(_(e,"oncdata",e.cdata),e.cdata=""),""!==e.script&&(_(e,"onscript",e.script),e.script="")}};try{t=hr.Stream}catch(e){t=function(){}}var i=e.EVENTS.filter((function(e){return"error"!==e&&"end"!==e}));function o(e,r){if(!(this instanceof o))return new o(e,r);t.apply(this),this._parser=new n(e,r),this.writable=!0,this.readable=!0;var a=this;this._parser.onend=function(){a.emit("end")},this._parser.onerror=function(e){a.emit("error",e),a._parser.error=null},this._decoder=null,i.forEach((function(e){Object.defineProperty(a,"on"+e,{get:function(){return a._parser["on"+e]},set:function(t){if(!t)return a.removeAllListeners(e),a._parser["on"+e]=t,t;a.on(e,t)},enumerable:!0,configurable:!1})}))}o.prototype=Object.create(t.prototype,{constructor:{value:o}}),o.prototype.write=function(e){if("function"==typeof re.isBuffer&&re.isBuffer(e)){if(!this._decoder){var t=fr.StringDecoder;this._decoder=new t("utf8")}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit("data",e),!0},o.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},o.prototype.on=function(e,r){var n=this;return n._parser["on"+e]||-1===i.indexOf(e)||(n._parser["on"+e]=function(){var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),n.emit.apply(n,t)}),t.prototype.on.call(n,e,r)};var a="http://www.w3.org/XML/1998/namespace",s="http://www.w3.org/2000/xmlns/",u={xml:a,xmlns:s},c=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,l=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,d=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,h=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(e){return" "===e||"\n"===e||"\r"===e||"\t"===e}function p(e){return'"'===e||"'"===e}function g(e){return">"===e||f(e)}function y(e,t){return e.test(t)}function v(e,t){return!y(e,t)}var m,b,w,E=0;for(var A in e.STATE={BEGIN:E++,BEGIN_WHITESPACE:E++,TEXT:E++,TEXT_ENTITY:E++,OPEN_WAKA:E++,SGML_DECL:E++,SGML_DECL_QUOTED:E++,DOCTYPE:E++,DOCTYPE_QUOTED:E++,DOCTYPE_DTD:E++,DOCTYPE_DTD_QUOTED:E++,COMMENT_STARTING:E++,COMMENT:E++,COMMENT_ENDING:E++,COMMENT_ENDED:E++,CDATA:E++,CDATA_ENDING:E++,CDATA_ENDING_2:E++,PROC_INST:E++,PROC_INST_BODY:E++,PROC_INST_ENDING:E++,OPEN_TAG:E++,OPEN_TAG_SLASH:E++,ATTRIB:E++,ATTRIB_NAME:E++,ATTRIB_NAME_SAW_WHITE:E++,ATTRIB_VALUE:E++,ATTRIB_VALUE_QUOTED:E++,ATTRIB_VALUE_CLOSED:E++,ATTRIB_VALUE_UNQUOTED:E++,ATTRIB_VALUE_ENTITY_Q:E++,ATTRIB_VALUE_ENTITY_U:E++,CLOSE_TAG:E++,CLOSE_TAG_SAW_WHITE:E++,SCRIPT:E++,SCRIPT_ENDING:E++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach((function(t){var r=e.ENTITIES[t],n="number"==typeof r?String.fromCharCode(r):r;e.ENTITIES[t]=n})),e.STATE)e.STATE[e.STATE[A]]=A;function T(e,t,r){e[t]&&e[t](r)}function _(e,t,r){e.textNode&&C(e),T(e,t,r)}function C(e){e.textNode=O(e.opt,e.textNode),e.textNode&&T(e,"ontext",e.textNode),e.textNode=""}function O(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g," ")),t}function x(e,t){return C(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,T(e,"onerror",t),e}function D(e){return e.sawRoot&&!e.closedRoot&&R(e,"Unclosed root tag"),e.state!==E.BEGIN&&e.state!==E.BEGIN_WHITESPACE&&e.state!==E.TEXT&&x(e,"Unexpected end"),C(e),e.c="",e.closed=!0,T(e,"onend"),n.call(e,e.strict,e.opt),e}function R(e,t){if("object"!=typeof e||!(e instanceof n))throw new Error("bad call to strictFail");e.strict&&x(e,t)}function S(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,r=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(r.ns=t.ns),e.attribList.length=0,_(e,"onopentagstart",r)}function F(e,t){var r=e.indexOf(":")<0?["",e]:e.split(":"),n=r[0],i=r[1];return t&&"xmlns"===e&&(n="xmlns",i=""),{prefix:n,local:i}}function N(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName))e.attribName=e.attribValue="";else{if(e.opt.xmlns){var t=F(e.attribName,!0),r=t.prefix,n=t.local;if("xmlns"===r)if("xml"===n&&e.attribValue!==a)R(e,"xml: prefix must be bound to "+a+"\nActual: "+e.attribValue);else if("xmlns"===n&&e.attribValue!==s)R(e,"xmlns: prefix must be bound to "+s+"\nActual: "+e.attribValue);else{var i=e.tag,o=e.tags[e.tags.length-1]||e;i.ns===o.ns&&(i.ns=Object.create(o.ns)),i.ns[n]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,_(e,"onattribute",{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=""}}function j(e,t){if(e.opt.xmlns){var r=e.tag,n=F(e.tagName);r.prefix=n.prefix,r.local=n.local,r.uri=r.ns[n.prefix]||"",r.prefix&&!r.uri&&(R(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName)),r.uri=n.prefix);var i=e.tags[e.tags.length-1]||e;r.ns&&i.ns!==r.ns&&Object.keys(r.ns).forEach((function(t){_(e,"onopennamespace",{prefix:t,uri:r.ns[t]})}));for(var o=0,a=e.attribList.length;o",e.tagName="",void(e.state=E.SCRIPT);_(e,"onscript",e.script),e.script=""}var t=e.tags.length,r=e.tagName;e.strict||(r=r[e.looseCase]());for(var n=r;t--&&e.tags[t].name!==n;)R(e,"Unexpected close tag");if(t<0)return R(e,"Unmatched closing tag: "+e.tagName),e.textNode+="",void(e.state=E.TEXT);e.tagName=r;for(var i=e.tags.length;i-- >t;){var o=e.tag=e.tags.pop();e.tagName=e.tag.name,_(e,"onclosetag",e.tagName);var a={};for(var s in o.ns)a[s]=o.ns[s];var u=e.tags[e.tags.length-1]||e;e.opt.xmlns&&o.ns!==u.ns&&Object.keys(o.ns).forEach((function(t){var r=o.ns[t];_(e,"onclosenamespace",{prefix:t,uri:r})}))}0===t&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName="",e.attribList.length=0,e.state=E.TEXT}function k(e){var t,r=e.entity,n=r.toLowerCase(),i="";return e.ENTITIES[r]?e.ENTITIES[r]:e.ENTITIES[n]?e.ENTITIES[n]:("#"===(r=n).charAt(0)&&("x"===r.charAt(1)?(r=r.slice(2),i=(t=parseInt(r,16)).toString(16)):(r=r.slice(1),i=(t=parseInt(r,10)).toString(10))),r=r.replace(/^0+/,""),isNaN(t)||i.toLowerCase()!==r?(R(e,"Invalid character entity"),"&"+e.entity+";"):String.fromCodePoint(t))}function I(e,t){"<"===t?(e.state=E.OPEN_WAKA,e.startTagPosition=e.position):f(t)||(R(e,"Non-whitespace before first tag."),e.textNode=t,e.state=E.TEXT)}function P(e,t){var r="";return t1114111||b(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?n.push(s):(e=55296+((s-=65536)>>10),t=s%1024+56320,n.push(e,t)),(i+1===o||n.length>r)&&(a+=m.apply(null,n),n.length=0)}return a},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:w,configurable:!0,writable:!0}):String.fromCodePoint=w)}(Be);var pr,gr,yr=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},vr=yr,mr={copyOptions:function(e){var t,r={};for(t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r},ensureFlagExists:function(e,t){e in t&&"boolean"==typeof t[e]||(t[e]=!1)},ensureSpacesExists:function(e){(!("spaces"in e)||"number"!=typeof e.spaces&&"string"!=typeof e.spaces)&&(e.spaces=0)},ensureAlwaysArrayExists:function(e){"alwaysArray"in e&&("boolean"==typeof e.alwaysArray||vr(e.alwaysArray))||(e.alwaysArray=!1)},ensureKeyExists:function(e,t){e+"Key"in t&&"string"==typeof t[e+"Key"]||(t[e+"Key"]=t.compact?"_"+e:e)},checkFnExists:function(e,t){return e+"Fn"in t}},br=Be,wr=mr,Er=yr;function Ar(e){var t=Number(e);if(!isNaN(t))return t;var r=e.toLowerCase();return"true"===r||"false"!==r&&e}function Tr(e,t){var r;if(pr.compact){if(!gr[pr[e+"Key"]]&&(Er(pr.alwaysArray)?-1!==pr.alwaysArray.indexOf(pr[e+"Key"]):pr.alwaysArray)&&(gr[pr[e+"Key"]]=[]),gr[pr[e+"Key"]]&&!Er(gr[pr[e+"Key"]])&&(gr[pr[e+"Key"]]=[gr[pr[e+"Key"]]]),e+"Fn"in pr&&"string"==typeof t&&(t=pr[e+"Fn"](t,gr)),"instruction"===e&&("instructionFn"in pr||"instructionNameFn"in pr))for(r in t)if(t.hasOwnProperty(r))if("instructionFn"in pr)t[r]=pr.instructionFn(t[r],r,gr);else{var n=t[r];delete t[r],t[pr.instructionNameFn(r,n,gr)]=n}Er(gr[pr[e+"Key"]])?gr[pr[e+"Key"]].push(t):gr[pr[e+"Key"]]=t}else{gr[pr.elementsKey]||(gr[pr.elementsKey]=[]);var i={};if(i[pr.typeKey]=e,"instruction"===e){for(r in t)if(t.hasOwnProperty(r))break;i[pr.nameKey]="instructionNameFn"in pr?pr.instructionNameFn(r,t,gr):r,pr.instructionHasAttributes?(i[pr.attributesKey]=t[r][pr.attributesKey],"instructionFn"in pr&&(i[pr.attributesKey]=pr.instructionFn(i[pr.attributesKey],r,gr))):("instructionFn"in pr&&(t[r]=pr.instructionFn(t[r],r,gr)),i[pr.instructionKey]=t[r])}else e+"Fn"in pr&&(t=pr[e+"Fn"](t,gr)),i[pr[e+"Key"]]=t;pr.addParent&&(i[pr.parentKey]=gr),gr[pr.elementsKey].push(i)}}function _r(e){var t;if("attributesFn"in pr&&e&&(e=pr.attributesFn(e,gr)),(pr.trim||"attributeValueFn"in pr||"attributeNameFn"in pr||pr.nativeTypeAttributes)&&e)for(t in e)if(e.hasOwnProperty(t)&&(pr.trim&&(e[t]=e[t].trim()),pr.nativeTypeAttributes&&(e[t]=Ar(e[t])),"attributeValueFn"in pr&&(e[t]=pr.attributeValueFn(e[t],t,gr)),"attributeNameFn"in pr)){var r=e[t];delete e[t],e[pr.attributeNameFn(t,e[t],gr)]=r}return e}function Cr(e){var t={};if(e.body&&("xml"===e.name.toLowerCase()||pr.instructionHasAttributes)){for(var r,n=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(r=n.exec(e.body));)t[r[1]]=r[2]||r[3]||r[4];t=_r(t)}if("xml"===e.name.toLowerCase()){if(pr.ignoreDeclaration)return;gr[pr.declarationKey]={},Object.keys(t).length&&(gr[pr.declarationKey][pr.attributesKey]=t),pr.addParent&&(gr[pr.declarationKey][pr.parentKey]=gr)}else{if(pr.ignoreInstruction)return;pr.trim&&(e.body=e.body.trim());var i={};pr.instructionHasAttributes&&Object.keys(t).length?(i[e.name]={},i[e.name][pr.attributesKey]=t):i[e.name]=e.body,Tr("instruction",i)}}function Or(e,t){var r;if("object"==typeof e&&(t=e.attributes,e=e.name),t=_r(t),"elementNameFn"in pr&&(e=pr.elementNameFn(e,gr)),pr.compact){var n;if(r={},!pr.ignoreAttributes&&t&&Object.keys(t).length)for(n in r[pr.attributesKey]={},t)t.hasOwnProperty(n)&&(r[pr.attributesKey][n]=t[n]);!(e in gr)&&(Er(pr.alwaysArray)?-1!==pr.alwaysArray.indexOf(e):pr.alwaysArray)&&(gr[e]=[]),gr[e]&&!Er(gr[e])&&(gr[e]=[gr[e]]),Er(gr[e])?gr[e].push(r):gr[e]=r}else gr[pr.elementsKey]||(gr[pr.elementsKey]=[]),(r={})[pr.typeKey]="element",r[pr.nameKey]=e,!pr.ignoreAttributes&&t&&Object.keys(t).length&&(r[pr.attributesKey]=t),pr.alwaysChildren&&(r[pr.elementsKey]=[]),gr[pr.elementsKey].push(r);r[pr.parentKey]=gr,gr=r}function xr(e){pr.ignoreText||(e.trim()||pr.captureSpacesBetweenElements)&&(pr.trim&&(e=e.trim()),pr.nativeType&&(e=Ar(e)),pr.sanitize&&(e=e.replace(/&/g,"&").replace(//g,">")),Tr("text",e))}function Dr(e){pr.ignoreComment||(pr.trim&&(e=e.trim()),Tr("comment",e))}function Rr(e){var t=gr[pr.parentKey];pr.addParent||delete gr[pr.parentKey],gr=t}function Sr(e){pr.ignoreCdata||(pr.trim&&(e=e.trim()),Tr("cdata",e))}function Fr(e){pr.ignoreDoctype||(e=e.replace(/^ /,""),pr.trim&&(e=e.trim()),Tr("doctype",e))}function Nr(e){e.note=e}var jr=function(e,t){var r=br.parser(!0,{}),n={};if(gr=n,pr=function(e){return pr=wr.copyOptions(e),wr.ensureFlagExists("ignoreDeclaration",pr),wr.ensureFlagExists("ignoreInstruction",pr),wr.ensureFlagExists("ignoreAttributes",pr),wr.ensureFlagExists("ignoreText",pr),wr.ensureFlagExists("ignoreComment",pr),wr.ensureFlagExists("ignoreCdata",pr),wr.ensureFlagExists("ignoreDoctype",pr),wr.ensureFlagExists("compact",pr),wr.ensureFlagExists("alwaysChildren",pr),wr.ensureFlagExists("addParent",pr),wr.ensureFlagExists("trim",pr),wr.ensureFlagExists("nativeType",pr),wr.ensureFlagExists("nativeTypeAttributes",pr),wr.ensureFlagExists("sanitize",pr),wr.ensureFlagExists("instructionHasAttributes",pr),wr.ensureFlagExists("captureSpacesBetweenElements",pr),wr.ensureAlwaysArrayExists(pr),wr.ensureKeyExists("declaration",pr),wr.ensureKeyExists("instruction",pr),wr.ensureKeyExists("attributes",pr),wr.ensureKeyExists("text",pr),wr.ensureKeyExists("comment",pr),wr.ensureKeyExists("cdata",pr),wr.ensureKeyExists("doctype",pr),wr.ensureKeyExists("type",pr),wr.ensureKeyExists("name",pr),wr.ensureKeyExists("elements",pr),wr.ensureKeyExists("parent",pr),wr.checkFnExists("doctype",pr),wr.checkFnExists("instruction",pr),wr.checkFnExists("cdata",pr),wr.checkFnExists("comment",pr),wr.checkFnExists("text",pr),wr.checkFnExists("instructionName",pr),wr.checkFnExists("elementName",pr),wr.checkFnExists("attributeName",pr),wr.checkFnExists("attributeValue",pr),wr.checkFnExists("attributes",pr),pr}(t),r.opt={strictEntities:!0},r.onopentag=Or,r.ontext=xr,r.oncomment=Dr,r.onclosetag=Rr,r.onerror=Nr,r.oncdata=Sr,r.ondoctype=Fr,r.onprocessinginstruction=Cr,r.write(e).close(),n[pr.elementsKey]){var i=n[pr.elementsKey];delete n[pr.elementsKey],n[pr.elementsKey]=i,delete n.text}return n},Lr=mr,kr=jr;var Ir,Pr,Ur=mr,Br=yr;function Mr(e,t,r){return(!r&&e.spaces?"\n":"")+Array(t+1).join(e.spaces)}function Vr(e,t,r){if(t.ignoreAttributes)return"";"attributesFn"in t&&(e=t.attributesFn(e,Pr,Ir));var n,i,o,a,s=[];for(n in e)e.hasOwnProperty(n)&&null!==e[n]&&void 0!==e[n]&&(a=t.noQuotesForNativeAttributes&&"string"!=typeof e[n]?"":'"',i=(i=""+e[n]).replace(/"/g,"""),o="attributeNameFn"in t?t.attributeNameFn(n,i,Pr,Ir):n,s.push(t.spaces&&t.indentAttributes?Mr(t,r+1,!1):" "),s.push(o+"="+a+("attributeValueFn"in t?t.attributeValueFn(i,n,Pr,Ir):i)+a));return e&&Object.keys(e).length&&t.spaces&&t.indentAttributes&&s.push(Mr(t,r,!1)),s.join("")}function Kr(e,t,r){return Ir=e,Pr="xml",t.ignoreDeclaration?"":""}function $r(e,t,r){if(t.ignoreInstruction)return"";var n;for(n in e)if(e.hasOwnProperty(n))break;var i="instructionNameFn"in t?t.instructionNameFn(n,e[n],Pr,Ir):n;if("object"==typeof e[n])return Ir=e,Pr=i,"";var o=e[n]?e[n]:"";return"instructionFn"in t&&(o=t.instructionFn(o,n,Pr,Ir)),""}function Hr(e,t){return t.ignoreComment?"":"\x3c!--"+("commentFn"in t?t.commentFn(e,Pr,Ir):e)+"--\x3e"}function Yr(e,t){return t.ignoreCdata?"":"","]]]]>"))+"]]>"}function zr(e,t){return t.ignoreDoctype?"":""}function qr(e,t){return t.ignoreText?"":(e=(e=(e=""+e).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in t?t.textFn(e,Pr,Ir):e)}function Gr(e,t,r,n){return e.reduce((function(e,i){var o=Mr(t,r,n&&!e);switch(i.type){case"element":return e+o+function(e,t,r){Ir=e,Pr=e.name;var n=[],i="elementNameFn"in t?t.elementNameFn(e.name,e):e.name;n.push("<"+i),e[t.attributesKey]&&n.push(Vr(e[t.attributesKey],t,r));var o=e[t.elementsKey]&&e[t.elementsKey].length||e[t.attributesKey]&&"preserve"===e[t.attributesKey]["xml:space"];return o||(o="fullTagEmptyElementFn"in t?t.fullTagEmptyElementFn(e.name,e):t.fullTagEmptyElement),o?(n.push(">"),e[t.elementsKey]&&e[t.elementsKey].length&&(n.push(Gr(e[t.elementsKey],t,r+1)),Ir=e,Pr=e.name),n.push(t.spaces&&function(e,t){var r;if(e.elements&&e.elements.length)for(r=0;r")):n.push("/>"),n.join("")}(i,t,r);case"comment":return e+o+Hr(i[t.commentKey],t);case"doctype":return e+o+zr(i[t.doctypeKey],t);case"cdata":return e+(t.indentCdata?o:"")+Yr(i[t.cdataKey],t);case"text":return e+(t.indentText?o:"")+qr(i[t.textKey],t);case"instruction":var a={};return a[i[t.nameKey]]=i[t.attributesKey]?i:i[t.instructionKey],e+(t.indentInstruction?o:"")+$r(a,t,r)}}),"")}function Wr(e,t,r){var n;for(n in e)if(e.hasOwnProperty(n))switch(n){case t.parentKey:case t.attributesKey:break;case t.textKey:if(t.indentText||r)return!0;break;case t.cdataKey:if(t.indentCdata||r)return!0;break;case t.instructionKey:if(t.indentInstruction||r)return!0;break;case t.doctypeKey:case t.commentKey:default:return!0}return!1}function Qr(e,t,r,n,i){Ir=e,Pr=t;var o="elementNameFn"in r?r.elementNameFn(t,e):t;if(null==e||""===e)return"fullTagEmptyElementFn"in r&&r.fullTagEmptyElementFn(t,e)||r.fullTagEmptyElement?"<"+o+">":"<"+o+"/>";var a=[];if(t){if(a.push("<"+o),"object"!=typeof e)return a.push(">"+qr(e,r)+""),a.join("");e[r.attributesKey]&&a.push(Vr(e[r.attributesKey],r,n));var s=Wr(e,r,!0)||e[r.attributesKey]&&"preserve"===e[r.attributesKey]["xml:space"];if(s||(s="fullTagEmptyElementFn"in r?r.fullTagEmptyElementFn(t,e):r.fullTagEmptyElement),!s)return a.push("/>"),a.join("");a.push(">")}return a.push(Xr(e,r,n+1,!1)),Ir=e,Pr=t,t&&a.push((i?Mr(r,n,!1):"")+""),a.join("")}function Xr(e,t,r,n){var i,o,a,s=[];for(o in e)if(e.hasOwnProperty(o))for(a=Br(e[o])?e[o]:[e[o]],i=0;i{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},on=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),n=t.trim();if(Math.abs(r.length-n.length)>1)return!1;const i="/"===r.slice(-1)?r.slice(0,-1):r,o="/"===n.slice(-1)?n.slice(0,-1):n;return e.includes(o)||t.includes(i)},an=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),n=t.trim(),i="/"===r.slice(-1)?r.slice(0,-1):r,o="/"===n.slice(-1)?n.slice(0,-1):n;return e.includes(o)||t.includes(i)},sn=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[M[t]]:t})),{}),un=e=>Object.entries(e).reduce(((e,[t,r])=>r?Object.assign(Object.assign({},e),{[t]:r}):e),{}),cn=(e,t)=>t?{[e]:t}:{},ln=(e,t)=>e?t&&0!==t.length?Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e)))):e:{};var dn=Object.freeze({__proto__:null,cleanupFalsy:un,conditionalParam:cn,excludeHeaders:ln,getDAVAttribute:sn,urlContains:an,urlEquals:on});const hn=B("tsdav:request"),fn=e=>t(void 0,void 0,void 0,(function*(){var t;const{url:r,init:n,convertIncoming:i=!0,parseOutgoing:o=!0}=e,{headers:s={},body:u,namespace:c,method:l,attributes:d}=n,h=i?rn.js2xml(Object.assign(Object.assign({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},u),{_attributes:d}),{compact:!0,spaces:2,elementNameFn:e=>c&&!/^.+:.+/.test(e)?`${c}:${e}`:e}):u,f=yield a.fetch(r,{headers:Object.assign({"Content-Type":"text/xml;charset=UTF-8"},un(s)),body:h,method:l}),p=yield f.text();if(!f.ok||!(null===(t=f.headers.get("content-type"))||void 0===t?void 0:t.includes("xml"))||!o)return[{href:f.url,ok:f.ok,status:f.status,statusText:f.statusText,raw:p}];const g=rn.xml2js(p,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,n=Object.keys(r),i=n[n.length-1],o=r[i];if(o.length>0){o[o.length-1]=nn(e)}else r[i]=nn(e)}catch(e){hn(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,(e=>e[1].toUpperCase())),attributesFn:e=>{const t=Object.assign({},e);return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(g.multistatus.response)?g.multistatus.response:[g.multistatus.response]).map((e=>{var t,r;if(!e)return{status:f.status,statusText:f.statusText,ok:f.ok};const n=/^\S+\s(?\d+)\s(?.+)$/.exec(e.status);return{raw:g,href:e.href,status:(null==n?void 0:n.groups)?Number.parseInt(null==n?void 0:n.groups.status,10):f.status,statusText:null!==(r=null===(t=null==n?void 0:n.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:f.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce(((e,t)=>Object.assign(Object.assign({},e),null==t?void 0:t.prop)),{})}}))})),pn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:n,headers:i,headersToExclude:o}=e;return fn({url:t,init:{method:"PROPFIND",headers:ln(un(Object.assign({depth:n},i)),o),namespace:V.DAV,body:{propfind:{_attributes:sn([U.CALDAV,U.CALDAV_APPLE,U.CALENDAR_SERVER,U.CARDDAV,U.DAV]),prop:r}}}})})),gn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,data:r,headers:n,headersToExclude:i}=e;return a.fetch(t,{method:"PUT",body:r,headers:ln(n,i)})})),yn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,data:r,etag:n,headers:i,headersToExclude:o}=e;return a.fetch(t,{method:"PUT",body:r,headers:ln(un(Object.assign({"If-Match":n},i)),o)})})),vn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,headers:r,etag:n,headersToExclude:i}=e;return a.fetch(t,{method:"DELETE",headers:ln(un(Object.assign({"If-Match":n},r)),i)})}));var mn=Object.freeze({__proto__:null,createObject:gn,davRequest:fn,deleteObject:vn,propfind:pn,updateObject:yn});function bn(e,t){const r=e=>t.every((t=>e[t]));return Array.isArray(e)?e.every((e=>r(e))):r(e)}const wn=(e,t)=>t.reduce(((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`),""),En=B("tsdav:collection"),An=e=>t(void 0,void 0,void 0,(function*(){const{url:t,body:r,depth:n,defaultNamespace:i=V.DAV,headers:o,headersToExclude:a}=e,s=yield fn({url:t,init:{method:"REPORT",headers:ln(un(Object.assign({depth:n},o)),a),namespace:i,body:r}});return 1!==s.length||s[0].raw?s:[]})),Tn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:n,headers:i,headersToExclude:o}=e;return fn({url:t,init:{method:"MKCOL",headers:ln(un(Object.assign({depth:n},i)),o),namespace:V.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0}})})),_n=e=>t(void 0,void 0,void 0,(function*(){var t,r,n,i,o;const{collection:a,headers:s,headersToExclude:u}=e;return null!==(o=null===(i=null===(n=null===(r=null===(t=(yield pn({url:a.url,props:{[`${V.DAV}:supported-report-set`]:{}},depth:"0",headers:ln(s,u)}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===n?void 0:n.supportedReport)||void 0===i?void 0:i.map((e=>Object.keys(e.report)[0])))&&void 0!==o?o:[]})),Cn=e=>t(void 0,void 0,void 0,(function*(){var t,r,n;const{collection:i,headers:o,headersToExclude:a}=e,s=(yield pn({url:i.url,props:{[`${V.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:ln(o,a)})).filter((e=>an(i.url,e.href)))[0];if(!s)throw new Error("Collection does not exist on server");return{isDirty:i.ctag!==(null===(t=s.props)||void 0===t?void 0:t.getctag),newCtag:null===(n=null===(r=s.props)||void 0===r?void 0:r.getctag)||void 0===n?void 0:n.toString()}})),On=e=>{const{url:t,props:r,headers:n,syncLevel:i,syncToken:o,headersToExclude:a}=e;return fn({url:t,init:{method:"REPORT",namespace:V.DAV,headers:ln(Object.assign({},n),a),body:{"sync-collection":{_attributes:sn([U.CALDAV,U.CARDDAV,U.DAV]),"sync-level":i,"sync-token":o,[`${V.DAV}:prop`]:r}}}})},xn=e=>t(void 0,void 0,void 0,(function*(){var t,r,n,i,o,a,s,u,c,l,d;const{collection:h,method:f,headers:p,headersToExclude:g,account:y,detailedResult:v}=e,m=["accountType","homeUrl"];if(!y||!bn(y,m)){if(!y)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${wn(y,m)} before smartCollectionSync`)}const b=null!=f?f:(null===(t=h.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(En(`smart collection sync with type ${y.accountType} and method ${b}`),"webdav"===b){const e=yield On({url:h.url,props:{[`${V.DAV}:getetag`]:{},[`${"caldav"===y.accountType?V.CALDAV:V.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{},[`${V.DAV}:displayname`]:{}},syncLevel:1,syncToken:h.syncToken,headers:ln(p,g)}),t=e.filter((e=>{var t;const r="caldav"===y.accountType?".ics":".vcf";return(null===(t=e.href)||void 0===t?void 0:t.slice(-4))===r})),c=t.filter((e=>404!==e.status)).map((e=>e.href)),l=t.filter((e=>404===e.status)).map((e=>e.href)),d=(c.length&&null!==(n=yield null===(r=null==h?void 0:h.objectMultiGet)||void 0===r?void 0:r.call(h,{url:h.url,props:{[`${V.DAV}:getetag`]:{},[`${"caldav"===y.accountType?V.CALDAV:V.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:c,depth:"1",headers:ln(p,g)}))&&void 0!==n?n:[]).map((e=>{var t,r,n,i,o,a,s,u,c,l;return{url:null!==(t=e.href)&&void 0!==t?t:"",etag:null===(r=e.props)||void 0===r?void 0:r.getetag,data:"caldav"===(null==y?void 0:y.accountType)?null!==(o=null===(i=null===(n=e.props)||void 0===n?void 0:n.calendarData)||void 0===i?void 0:i._cdata)&&void 0!==o?o:null===(a=e.props)||void 0===a?void 0:a.calendarData:null!==(c=null===(u=null===(s=e.props)||void 0===s?void 0:s.addressData)||void 0===u?void 0:u._cdata)&&void 0!==c?c:null===(l=e.props)||void 0===l?void 0:l.addressData}})),f=null!==(i=h.objects)&&void 0!==i?i:[],m=d.filter((e=>f.every((t=>!an(t.url,e.url))))),b=f.reduce(((e,t)=>{const r=d.find((e=>an(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),w=l.map((e=>({url:e,etag:""}))),E=f.filter((e=>d.some((t=>an(e.url,t.url)&&t.etag===e.etag))));return Object.assign(Object.assign({},h),{objects:v?{created:m,updated:b,deleted:w}:[...E,...m,...b],syncToken:null!==(u=null===(s=null===(a=null===(o=e[0])||void 0===o?void 0:o.raw)||void 0===a?void 0:a.multistatus)||void 0===s?void 0:s.syncToken)&&void 0!==u?u:h.syncToken})}if("basic"===b){const{isDirty:e,newCtag:t}=yield Cn({collection:h,headers:ln(p,g)}),r=null!==(c=h.objects)&&void 0!==c?c:[],n=null!==(d=yield null===(l=h.fetchObjects)||void 0===l?void 0:l.call(h,{collection:h,headers:ln(p,g)}))&&void 0!==d?d:[],i=n.filter((e=>r.every((t=>!an(t.url,e.url))))),o=r.reduce(((e,t)=>{const r=n.find((e=>an(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),a=r.filter((e=>n.every((t=>!an(t.url,e.url))))),s=r.filter((e=>n.some((t=>an(e.url,t.url)&&t.etag===e.etag))));if(e)return Object.assign(Object.assign({},h),{objects:v?{created:i,updated:o,deleted:a}:[...s,...i,...o],ctag:t})}return v?Object.assign(Object.assign({},h),{objects:{created:[],updated:[],deleted:[]}}):h}));var Dn=Object.freeze({__proto__:null,collectionQuery:An,isCollectionDirty:Cn,makeCollection:Tn,smartCollectionSync:xn,supportedReportSet:_n,syncCollection:On});const Rn=B("tsdav:addressBook"),Sn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:n,depth:i,headers:o,headersToExclude:a}=e;return An({url:t,body:{"addressbook-query":{_attributes:sn([U.CARDDAV,U.DAV]),[`${V.DAV}:prop`]:r,filter:null!=n?n:{"prop-filter":{_attributes:{name:"FN"}}}}},defaultNamespace:V.CARDDAV,depth:i,headers:ln(o,a)})})),Fn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:n,depth:i,headers:o}=e;return An({url:t,body:{"addressbook-multiget":{_attributes:sn([U.DAV,U.CARDDAV]),[`${V.DAV}:prop`]:r,[`${V.DAV}:href`]:n}},defaultNamespace:V.CARDDAV,depth:i,headers:o})})),Nn=e=>t(void 0,void 0,void 0,(function*(){const{account:r,headers:n,props:i,headersToExclude:o}=null!=e?e:{},a=["homeUrl","rootUrl"];if(!r||!bn(r,a)){if(!r)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${wn(r,a)} before fetchAddressBooks`)}const s=yield pn({url:r.homeUrl,props:null!=i?i:{[`${V.DAV}:displayname`]:{},[`${V.CALENDAR_SERVER}:getctag`]:{},[`${V.DAV}:resourcetype`]:{},[`${V.DAV}:sync-token`]:{}},depth:"1",headers:ln(n,o)});return Promise.all(s.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("addressbook")})).map((e=>{var t,n,i,o,a,s,u,c,l;const d=null!==(i=null===(n=null===(t=e.props)||void 0===t?void 0:t.displayname)||void 0===n?void 0:n._cdata)&&void 0!==i?i:null===(o=e.props)||void 0===o?void 0:o.displayname;return Rn(`Found address book named ${"string"==typeof d?d:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(a=e.href)&&void 0!==a?a:"",null!==(s=r.rootUrl)&&void 0!==s?s:"").href,ctag:null===(u=e.props)||void 0===u?void 0:u.getctag,displayName:"string"==typeof d?d:"",resourcetype:Object.keys(null===(c=e.props)||void 0===c?void 0:c.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}})).map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield _n({collection:e,headers:n})})})))))})),jn=e=>t(void 0,void 0,void 0,(function*(){const{addressBook:t,headers:r,objectUrls:n,headersToExclude:i,urlFilter:o=(e=>e),useMultiGet:a=!0}=e;Rn(`Fetching vcards from ${null==t?void 0:t.url}`);const s=["url"];if(!t||!bn(t,s)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${wn(t,s)} before fetchVCards`)}const u=(null!=n?n:(yield Sn({url:t.url,props:{[`${V.DAV}:getetag`]:{}},depth:"1",headers:ln(r,i)})).map((e=>{var t;return e.ok&&null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(o).map((e=>new URL(e).pathname));let c=[];return u.length>0&&(c=a?yield Fn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CARDDAV}:address-data`]:{}},objectUrls:u,depth:"1",headers:ln(r,i)}):yield Sn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CARDDAV}:address-data`]:{}},depth:"1",headers:ln(r,i)})),c.map((e=>{var r,n,i,o,a,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(n=e.props)||void 0===n?void 0:n.getetag,data:null!==(a=null===(o=null===(i=e.props)||void 0===i?void 0:i.addressData)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(s=e.props)||void 0===s?void 0:s.addressData}}))})),Ln=e=>t(void 0,void 0,void 0,(function*(){const{addressBook:t,vCardString:r,filename:n,headers:i,headersToExclude:o}=e;return gn({url:new URL(n,t.url).href,data:r,headers:ln(Object.assign({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*"},i),o)})})),kn=e=>t(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:n}=e;return yn({url:t.url,data:t.data,etag:t.etag,headers:ln(Object.assign({"content-type":"text/vcard; charset=utf-8"},r),n)})})),In=e=>t(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:n}=e;return vn({url:t.url,etag:t.etag,headers:ln(r,n)})}));var Pn=Object.freeze({__proto__:null,addressBookMultiGet:Fn,addressBookQuery:Sn,createVCard:Ln,deleteVCard:In,fetchAddressBooks:Nn,fetchVCards:jn,updateVCard:kn});const Un=B("tsdav:calendar"),Bn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:n,timezone:i,depth:o,headers:a,headersToExclude:s}=e;return An({url:t,body:{"calendar-query":un({_attributes:sn([U.CALDAV,U.CALENDAR_SERVER,U.CALDAV_APPLE,U.DAV]),[`${V.DAV}:prop`]:r,filter:n,timezone:i})},defaultNamespace:V.CALDAV,depth:o,headers:ln(a,s)})})),Mn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:n,filters:i,timezone:o,depth:a,headers:s,headersToExclude:u}=e;return An({url:t,body:{"calendar-multiget":Object.assign(Object.assign({_attributes:sn([U.DAV,U.CALDAV]),[`${V.DAV}:prop`]:r,[`${V.DAV}:href`]:n},cn("filter",i)),{timezone:o})},defaultNamespace:V.CALDAV,depth:a,headers:ln(s,u)})})),Vn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:n,headers:i,headersToExclude:o}=e;return fn({url:t,init:{method:"MKCALENDAR",headers:ln(un(Object.assign({depth:n},i)),o),namespace:V.DAV,body:{[`${V.CALDAV}:mkcalendar`]:{_attributes:sn([U.DAV,U.CALDAV,U.CALDAV_APPLE]),set:{prop:r}}}}})})),Kn=e=>t(void 0,void 0,void 0,(function*(){const{headers:r,account:n,props:i,projectedProps:o,headersToExclude:a}=null!=e?e:{},s=["homeUrl","rootUrl"];if(!n||!bn(n,s)){if(!n)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${wn(n,s)} before fetchCalendars`)}const u=yield pn({url:n.homeUrl,props:null!=i?i:{[`${V.CALDAV}:calendar-description`]:{},[`${V.CALDAV}:calendar-timezone`]:{},[`${V.DAV}:displayname`]:{},[`${V.CALDAV_APPLE}:calendar-color`]:{},[`${V.CALENDAR_SERVER}:getctag`]:{},[`${V.DAV}:resourcetype`]:{},[`${V.CALDAV}:supported-calendar-component-set`]:{},[`${V.DAV}:sync-token`]:{}},depth:"1",headers:ln(r,a)});return Promise.all(u.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("calendar")})).filter((e=>{var t,r,n,i;return(Array.isArray(null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet.comp)?null===(r=e.props)||void 0===r?void 0:r.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(i=null===(n=e.props)||void 0===n?void 0:n.supportedCalendarComponentSet.comp)||void 0===i?void 0:i._attributes.name]||[]).some((e=>Object.values(K).includes(e)))})).map((e=>{var t,r,i,a,s,u,c,l,d,h,f,p,g,y,v,m;const b=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,w=null===(r=e.props)||void 0===r?void 0:r.calendarTimezone;return Object.assign({description:"string"==typeof b?b:"",timezone:"string"==typeof w?w:"",url:new URL(null!==(i=e.href)&&void 0!==i?i:"",null!==(a=n.rootUrl)&&void 0!==a?a:"").href,ctag:null===(s=e.props)||void 0===s?void 0:s.getctag,calendarColor:null===(u=e.props)||void 0===u?void 0:u.calendarColor,displayName:null!==(l=null===(c=e.props)||void 0===c?void 0:c.displayname._cdata)&&void 0!==l?l:null===(d=e.props)||void 0===d?void 0:d.displayname,components:Array.isArray(null===(h=e.props)||void 0===h?void 0:h.supportedCalendarComponentSet.comp)?null===(f=e.props)||void 0===f?void 0:f.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(g=null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp)||void 0===g?void 0:g._attributes.name],resourcetype:Object.keys(null===(y=e.props)||void 0===y?void 0:y.resourcetype),syncToken:null===(v=e.props)||void 0===v?void 0:v.syncToken},cn("projectedProps",Object.fromEntries(Object.entries(null!==(m=e.props)&&void 0!==m?m:{}).filter((([e])=>null==o?void 0:o[e])))))})).map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield _n({collection:e,headers:ln(r,a)})})})))))})),$n=e=>t(void 0,void 0,void 0,(function*(){const{calendar:t,objectUrls:r,filters:n,timeRange:i,headers:o,expand:a,urlFilter:s=(e=>Boolean(null==e?void 0:e.includes(".ics"))),useMultiGet:u=!0,headersToExclude:c}=e;if(i){const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(i.start)&&e.test(i.end)||t.test(i.start)&&t.test(i.end)))throw new Error("invalid timeRange format, not in ISO8601")}Un(`Fetching calendar objects from ${null==t?void 0:t.url}`);const l=["url"];if(!t||!bn(t,l)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${wn(t,l)} before fetchCalendarObjects`)}const d=null!=n?n:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":Object.assign({_attributes:{name:"VEVENT"}},i?{"time-range":{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})}}],h=(null!=r?r:(yield Bn({url:t.url,props:{[`${V.DAV}:getetag`]:Object.assign({},a&&i?{[`${V.CALDAV}:expand`]:{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:d,depth:"1",headers:ln(o,c)})).map((e=>{var t;return null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(s).map((e=>new URL(e).pathname));let f=[];return h.length>0&&(f=!u||a?yield Bn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CALDAV}:calendar-data`]:Object.assign({},a&&i?{[`${V.CALDAV}:expand`]:{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:d,depth:"1",headers:ln(o,c)}):yield Mn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CALDAV}:calendar-data`]:Object.assign({},a&&i?{[`${V.CALDAV}:expand`]:{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},objectUrls:h,depth:"1",headers:ln(o,c)})),f.map((e=>{var r,n,i,o,a,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(n=e.props)||void 0===n?void 0:n.getetag}`,data:null!==(a=null===(o=null===(i=e.props)||void 0===i?void 0:i.calendarData)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(s=e.props)||void 0===s?void 0:s.calendarData}}))})),Hn=e=>t(void 0,void 0,void 0,(function*(){const{calendar:t,iCalString:r,filename:n,headers:i,headersToExclude:o}=e;return gn({url:new URL(n,t.url).href,data:r,headers:ln(Object.assign({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*"},i),o)})})),Yn=e=>t(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:n}=e;return yn({url:t.url,data:t.data,etag:t.etag,headers:ln(Object.assign({"content-type":"text/calendar; charset=utf-8"},r),n)})})),zn=e=>t(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:n}=e;return vn({url:t.url,etag:t.etag,headers:ln(r,n)})})),qn=e=>t(void 0,void 0,void 0,(function*(){var r;const{oldCalendars:n,account:i,detailedResult:o,headers:a,headersToExclude:s}=e;if(!i)throw new Error("Must have account before syncCalendars");const u=null!==(r=null!=n?n:i.calendars)&&void 0!==r?r:[],c=yield Kn({account:i,headers:ln(a,s)}),l=c.filter((e=>u.every((t=>!an(t.url,e.url)))));Un(`new calendars: ${l.map((e=>e.displayName))}`);const d=u.reduce(((e,t)=>{const r=c.find((e=>an(e.url,t.url)));return r&&(r.syncToken&&r.syncToken!==t.syncToken||r.ctag&&r.ctag!==t.ctag)?[...e,r]:e}),[]);Un(`updated calendars: ${d.map((e=>e.displayName))}`);const h=yield Promise.all(d.map((e=>t(void 0,void 0,void 0,(function*(){return yield xn({collection:Object.assign(Object.assign({},e),{objectMultiGet:Mn}),method:"webdav",headers:ln(a,s),account:i})}))))),f=u.filter((e=>c.every((t=>!an(t.url,e.url)))));Un(`deleted calendars: ${f.map((e=>e.displayName))}`);const p=u.filter((e=>c.some((t=>an(t.url,e.url)&&(t.syncToken&&t.syncToken!==e.syncToken||t.ctag&&t.ctag!==e.ctag)))));return o?{created:l,updated:d,deleted:f}:[...p,...l,...h]})),Gn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,timeRange:r,depth:n,headers:i,headersToExclude:o}=e;if(!r)throw new Error("timeRange is required");{const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(r.start)&&e.test(r.end)||t.test(r.start)&&t.test(r.end)))throw new Error("invalid timeRange format, not in ISO8601")}return(yield An({url:t,body:{"free-busy-query":un({_attributes:sn([U.CALDAV]),[`${V.CALDAV}:time-range`]:{_attributes:{start:`${new Date(r.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(r.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}})},defaultNamespace:V.CALDAV,depth:n,headers:ln(i,o)}))[0]}));var Wn=Object.freeze({__proto__:null,calendarMultiGet:Mn,calendarQuery:Bn,createCalendarObject:Hn,deleteCalendarObject:zn,fetchCalendarObjects:$n,fetchCalendars:Kn,freeBusyQuery:Gn,makeCalendar:Vn,syncCalendars:qn,updateCalendarObject:Yn});const Qn=B("tsdav:account"),Xn=e=>t(void 0,void 0,void 0,(function*(){var t,r;Qn("Service discovery...");const{account:n,headers:i,headersToExclude:o}=e,s=new URL(n.serverUrl),u=new URL(`/.well-known/${n.accountType}`,s);u.protocol=null!==(t=s.protocol)&&void 0!==t?t:"http";try{const e=yield a.fetch(u.href,{headers:ln(i,o),method:"PROPFIND",redirect:"manual"});if(e.status>=300&&e.status<400){const t=e.headers.get("Location");if("string"==typeof t&&t.length){Qn(`Service discovery redirected to ${t}`);const e=new URL(t,s);return e.hostname===u.hostname&&u.port&&!e.port&&(e.port=u.port),e.protocol=null!==(r=s.protocol)&&void 0!==r?r:"http",e.href}}}catch(e){Qn(`Service discovery failed: ${e.stack}`)}return s.href})),Zn=e=>t(void 0,void 0,void 0,(function*(){var t,r,n,i,o;const{account:a,headers:s,headersToExclude:u}=e,c=["rootUrl"];if(!bn(a,c))throw new Error(`account must have ${wn(a,c)} before fetchPrincipalUrl`);Qn(`Fetching principal url from path ${a.rootUrl}`);const[l]=yield pn({url:a.rootUrl,props:{[`${V.DAV}:current-user-principal`]:{}},depth:"0",headers:ln(s,u)});if(!l.ok&&(Qn(`Fetch principal url failed: ${l.statusText}`),401===l.status))throw new Error("Invalid credentials");return Qn(`Fetched principal url ${null===(r=null===(t=l.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(o=null===(i=null===(n=l.props)||void 0===n?void 0:n.currentUserPrincipal)||void 0===i?void 0:i.href)&&void 0!==o?o:"",a.rootUrl).href})),Jn=e=>t(void 0,void 0,void 0,(function*(){var t,r;const{account:n,headers:i,headersToExclude:o}=e,a=["principalUrl","rootUrl"];if(!bn(n,a))throw new Error(`account must have ${wn(n,a)} before fetchHomeUrl`);Qn(`Fetch home url from ${n.principalUrl}`);const s=(yield pn({url:n.principalUrl,props:"caldav"===n.accountType?{[`${V.CALDAV}:calendar-home-set`]:{}}:{[`${V.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:ln(i,o)})).find((e=>an(n.principalUrl,e.href)));if(!s||!s.ok)throw new Error("cannot find homeUrl");const u=new URL("caldav"===n.accountType?null===(t=null==s?void 0:s.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==s?void 0:s.props)||void 0===r?void 0:r.addressbookHomeSet.href,n.rootUrl).href;return Qn(`Fetched home url ${u}`),u})),ei=e=>t(void 0,void 0,void 0,(function*(){const{account:r,headers:n,loadCollections:i=!1,loadObjects:o=!1,headersToExclude:a}=e,s=Object.assign({},r);return s.rootUrl=yield Xn({account:r,headers:ln(n,a)}),s.principalUrl=yield Zn({account:s,headers:ln(n,a)}),s.homeUrl=yield Jn({account:s,headers:ln(n,a)}),(i||o)&&("caldav"===r.accountType?s.calendars=yield Kn({headers:ln(n,a),account:s}):"carddav"===r.accountType&&(s.addressBooks=yield Nn({headers:ln(n,a),account:s}))),o&&("caldav"===r.accountType&&s.calendars?s.calendars=yield Promise.all(s.calendars.map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield $n({calendar:e,headers:ln(n,a)})})}))))):"carddav"===r.accountType&&s.addressBooks&&(s.addressBooks=yield Promise.all(s.addressBooks.map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield jn({addressBook:e,headers:ln(n,a)})})}))))))),s}));var ti,ri,ni=Object.freeze({__proto__:null,createAccount:ei,fetchHomeUrl:Jn,fetchPrincipalUrl:Zn,serviceDiscovery:Xn}),ii={exports:{}};ti=ii,ri=ii.exports,function(e){var t=ri,n=ti&&ti.exports==t&&ti,i="object"==typeof r&&r;i.global!==i&&i.window!==i||(e=i);var o=function(e){this.message=e};(o.prototype=new Error).name="InvalidCharacterError";var a=function(e){throw new o(e)},s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,c={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&a("The string to be encoded contains characters outside of the Latin1 range.");for(var t,r,n,i,o=e.length%3,u="",c=-1,l=e.length-o;++c>18&63)+s.charAt(i>>12&63)+s.charAt(i>>6&63)+s.charAt(63&i);return 2==o?(t=e.charCodeAt(c)<<8,r=e.charCodeAt(++c),u+=s.charAt((i=t+r)>>10)+s.charAt(i>>4&63)+s.charAt(i<<2&63)+"="):1==o&&(i=e.charCodeAt(c),u+=s.charAt(i>>2)+s.charAt(i<<4&63)+"=="),u},decode:function(e){var t=(e=String(e).replace(u,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&a("Invalid character: the string to be decoded is not correctly encoded.");for(var r,n,i=0,o="",c=-1;++c>(-2*i&6)));return o},version:"1.0.0"};if(t&&!t.nodeType)if(n)n.exports=c;else for(var l in c)c.hasOwnProperty(l)&&(t[l]=c[l]);else e.base64=c}(r);var oi=ii.exports;const ai=B("tsdav:authHelper"),si=(e,t)=>(...r)=>e(Object.assign(Object.assign({},t),r[0])),ui=e=>(ai(`Basic auth token generated: ${oi.encode(`${e.username}:${e.password}`)}`),{authorization:`Basic ${oi.encode(`${e.username}:${e.password}`)}`}),ci=e=>t(void 0,void 0,void 0,(function*(){const t=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!bn(e,t))throw new Error(`Oauth credentials missing: ${wn(e,t)}`);const r=new URLSearchParams({grant_type:"authorization_code",code:e.authorizationCode,redirect_uri:e.redirectUrl,client_id:e.clientId,client_secret:e.clientSecret});ai(e.tokenUrl),ai(r.toString());const n=yield a.fetch(e.tokenUrl,{method:"POST",body:r.toString(),headers:{"content-length":`${r.toString().length}`,"content-type":"application/x-www-form-urlencoded"}});if(n.ok){return yield n.json()}return ai(`Fetch Oauth tokens failed: ${yield n.text()}`),{}})),li=e=>t(void 0,void 0,void 0,(function*(){const t=["refreshToken","clientId","clientSecret","tokenUrl"];if(!bn(e,t))throw new Error(`Oauth credentials missing: ${wn(e,t)}`);const r=new URLSearchParams({client_id:e.clientId,client_secret:e.clientSecret,refresh_token:e.refreshToken,grant_type:"refresh_token"}),n=yield a.fetch(e.tokenUrl,{method:"POST",body:r.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(n.ok){return yield n.json()}return ai(`Refresh access token failed: ${yield n.text()}`),{}})),di=e=>t(void 0,void 0,void 0,(function*(){var t;ai("Fetching oauth headers");let r={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(t=e.expiration)&&void 0!==t?t:0))&&(r=yield li(e)):r=yield ci(e),ai(`Oauth tokens fetched: ${r.access_token}`),{tokens:r,headers:{authorization:`Bearer ${r.access_token}`}}}));var hi=Object.freeze({__proto__:null,defaultParam:si,fetchOauthTokens:ci,getBasicAuthHeaders:ui,getOauthHeaders:di,refreshAccessToken:li});const fi=r=>t(void 0,void 0,void 0,(function*(){var n;const{serverUrl:i,credentials:o,authMethod:a,defaultAccountType:s,authFunction:u}=r;let c={};switch(a){case"Basic":c=ui(o);break;case"Oauth":c=(yield di(o)).headers;break;case"Digest":c={Authorization:`Digest ${o.digestString}`};break;case"Custom":c=null!==(n=yield null==u?void 0:u(o))&&void 0!==n?n:{};break;default:throw new Error("Invalid auth method")}const l=s?yield ei({account:{serverUrl:i,credentials:o,accountType:s},headers:c}):void 0,d=si(gn,{url:i,headers:c}),h=si(yn,{headers:c,url:i}),f=si(vn,{headers:c,url:i}),p=si(pn,{headers:c}),g=si(An,{headers:c}),y=si(Tn,{headers:c}),v=si(On,{headers:c}),m=si(_n,{headers:c}),b=si(Cn,{headers:c}),w=si(xn,{headers:c,account:l}),E=si(Bn,{headers:c}),A=si(Mn,{headers:c}),T=si(Vn,{headers:c}),_=si(Kn,{headers:c,account:l}),C=si($n,{headers:c}),O=si(Hn,{headers:c}),x=si(Yn,{headers:c}),D=si(zn,{headers:c}),R=si(qn,{account:l,headers:c}),S=si(Sn,{headers:c}),F=si(Fn,{headers:c});return{davRequest:r=>t(void 0,void 0,void 0,(function*(){const{init:t}=r,n=e(r,["init"]),{headers:i}=t,o=e(t,["headers"]);return fn(Object.assign(Object.assign({},n),{init:Object.assign(Object.assign({},o),{headers:Object.assign(Object.assign({},c),i)})}))})),propfind:p,createAccount:e=>t(void 0,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:n,loadObjects:a}=e;return ei({account:Object.assign({serverUrl:i,credentials:o},t),headers:Object.assign(Object.assign({},c),r),loadCollections:n,loadObjects:a})})),createObject:d,updateObject:h,deleteObject:f,calendarQuery:E,addressBookQuery:S,collectionQuery:g,makeCollection:y,calendarMultiGet:A,makeCalendar:T,syncCollection:v,supportedReportSet:m,isCollectionDirty:b,smartCollectionSync:w,fetchCalendars:_,fetchCalendarObjects:C,createCalendarObject:O,updateCalendarObject:x,deleteCalendarObject:D,syncCalendars:R,fetchAddressBooks:si(Nn,{account:l,headers:c}),addressBookMultiGet:F,fetchVCards:si(jn,{headers:c}),createVCard:si(Ln,{headers:c}),updateVCard:si(kn,{headers:c}),deleteVCard:si(In,{headers:c})}}));class pi{constructor(e){var t,r;this.serverUrl=e.serverUrl,this.credentials=e.credentials,this.authMethod=null!==(t=e.authMethod)&&void 0!==t?t:"Basic",this.accountType=null!==(r=e.defaultAccountType)&&void 0!==r?r:"caldav"}login(){var e;return t(this,void 0,void 0,(function*(){switch(this.authMethod){case"Basic":this.authHeaders=ui(this.credentials);break;case"Oauth":this.authHeaders=(yield di(this.credentials)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=yield null===(e=this.authFunction)||void 0===e?void 0:e.call(this,this.credentials);break;default:throw new Error("Invalid auth method")}this.account=this.accountType?yield ei({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders}):void 0}))}davRequest(r){return t(this,void 0,void 0,(function*(){const{init:t}=r,n=e(r,["init"]),{headers:i}=t,o=e(t,["headers"]);return fn(Object.assign(Object.assign({},n),{init:Object.assign(Object.assign({},o),{headers:Object.assign(Object.assign({},this.authHeaders),i)})}))}))}createObject(...e){return t(this,void 0,void 0,(function*(){return si(gn,{url:this.serverUrl,headers:this.authHeaders})(e[0])}))}updateObject(...e){return t(this,void 0,void 0,(function*(){return si(yn,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}deleteObject(...e){return t(this,void 0,void 0,(function*(){return si(vn,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}propfind(...e){return t(this,void 0,void 0,(function*(){return si(pn,{headers:this.authHeaders})(e[0])}))}createAccount(e){return t(this,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:n,loadObjects:i}=e;return ei({account:Object.assign({serverUrl:this.serverUrl,credentials:this.credentials},t),headers:Object.assign(Object.assign({},this.authHeaders),r),loadCollections:n,loadObjects:i})}))}collectionQuery(...e){return t(this,void 0,void 0,(function*(){return si(An,{headers:this.authHeaders})(e[0])}))}makeCollection(...e){return t(this,void 0,void 0,(function*(){return si(Tn,{headers:this.authHeaders})(e[0])}))}syncCollection(...e){return t(this,void 0,void 0,(function*(){return si(On,{headers:this.authHeaders})(e[0])}))}supportedReportSet(...e){return t(this,void 0,void 0,(function*(){return si(_n,{headers:this.authHeaders})(e[0])}))}isCollectionDirty(...e){return t(this,void 0,void 0,(function*(){return si(Cn,{headers:this.authHeaders})(e[0])}))}smartCollectionSync(...e){return t(this,void 0,void 0,(function*(){return si(xn,{headers:this.authHeaders,account:this.account})(e[0])}))}calendarQuery(...e){return t(this,void 0,void 0,(function*(){return si(Bn,{headers:this.authHeaders})(e[0])}))}makeCalendar(...e){return t(this,void 0,void 0,(function*(){return si(Vn,{headers:this.authHeaders})(e[0])}))}calendarMultiGet(...e){return t(this,void 0,void 0,(function*(){return si(Mn,{headers:this.authHeaders})(e[0])}))}fetchCalendars(...e){return t(this,void 0,void 0,(function*(){return si(Kn,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchCalendarObjects(...e){return t(this,void 0,void 0,(function*(){return si($n,{headers:this.authHeaders})(e[0])}))}createCalendarObject(...e){return t(this,void 0,void 0,(function*(){return si(Hn,{headers:this.authHeaders})(e[0])}))}updateCalendarObject(...e){return t(this,void 0,void 0,(function*(){return si(Yn,{headers:this.authHeaders})(e[0])}))}deleteCalendarObject(...e){return t(this,void 0,void 0,(function*(){return si(zn,{headers:this.authHeaders})(e[0])}))}syncCalendars(...e){return t(this,void 0,void 0,(function*(){return si(qn,{headers:this.authHeaders,account:this.account})(e[0])}))}addressBookQuery(...e){return t(this,void 0,void 0,(function*(){return si(Sn,{headers:this.authHeaders})(e[0])}))}addressBookMultiGet(...e){return t(this,void 0,void 0,(function*(){return si(Fn,{headers:this.authHeaders})(e[0])}))}fetchAddressBooks(...e){return t(this,void 0,void 0,(function*(){return si(Nn,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchVCards(...e){return t(this,void 0,void 0,(function*(){return si(jn,{headers:this.authHeaders})(e[0])}))}createVCard(...e){return t(this,void 0,void 0,(function*(){return si(Ln,{headers:this.authHeaders})(e[0])}))}updateVCard(...e){return t(this,void 0,void 0,(function*(){return si(kn,{headers:this.authHeaders})(e[0])}))}deleteVCard(...e){return t(this,void 0,void 0,(function*(){return si(In,{headers:this.authHeaders})(e[0])}))}}var gi=Object.freeze({__proto__:null,DAVClient:pi,createDAVClient:fi}),yi=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({DAVNamespace:U,DAVNamespaceShort:V,DAVAttributeMap:M},gi),mn),Dn),ni),Pn),Wn),hi),dn);export{M as DAVAttributeMap,pi as DAVClient,U as DAVNamespace,V as DAVNamespaceShort,Sn as addressBookQuery,Mn as calendarMultiGet,Bn as calendarQuery,un as cleanupFalsy,An as collectionQuery,ei as createAccount,Hn as createCalendarObject,fi as createDAVClient,gn as createObject,Ln as createVCard,fn as davRequest,yi as default,zn as deleteCalendarObject,vn as deleteObject,In as deleteVCard,Nn as fetchAddressBooks,$n as fetchCalendarObjects,Kn as fetchCalendars,ci as fetchOauthTokens,jn as fetchVCards,Gn as freeBusyQuery,ui as getBasicAuthHeaders,sn as getDAVAttribute,di as getOauthHeaders,Cn as isCollectionDirty,Vn as makeCalendar,pn as propfind,li as refreshAccessToken,xn as smartCollectionSync,_n as supportedReportSet,qn as syncCalendars,On as syncCollection,Yn as updateCalendarObject,yn as updateObject,kn as updateVCard,an as urlContains,on as urlEquals}; +function e(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i-1};function l(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function d(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function g(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function y(e){var t=new FileReader,r=g(t);return t.readAsArrayBuffer(e),r}function v(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=v(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=v(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=p(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(y)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=g(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?t:e}(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function A(e,t){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},m.call(w.prototype),m.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},A.error=function(){var e=new A(null,{status:0,statusText:""});return e.type="error",e};var T=[301,302,303,307,308];A.redirect=function(e,t){if(-1===T.indexOf(t))throw new RangeError("Invalid status code");return new A(null,{status:t,headers:{location:e}})},t.DOMException=r.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function _(e,n){return new Promise((function(i,a){var u=new w(e,n);if(u.signal&&u.signal.aborted)return a(new t.DOMException("Aborted","AbortError"));var c=new XMLHttpRequest;function l(){c.abort()}c.onload=function(){var e,t,r={status:c.status,statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in c?c.responseURL:r.headers.get("X-Request-URL");var n="response"in c?c.response:c.responseText;setTimeout((function(){i(new A(n,r))}),0)},c.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},c.onabort=function(){setTimeout((function(){a(new t.DOMException("Aborted","AbortError"))}),0)},c.open(u.method,function(e){try{return""===e&&r.location.href?r.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?c.withCredentials=!0:"omit"===u.credentials&&(c.withCredentials=!1),"responseType"in c&&(o?c.responseType="blob":s&&u.headers.get("Content-Type")&&-1!==u.headers.get("Content-Type").indexOf("application/octet-stream")&&(c.responseType="arraybuffer")),!n||"object"!=typeof n.headers||n.headers instanceof f?u.headers.forEach((function(e,t){c.setRequestHeader(t,e)})):Object.getOwnPropertyNames(n.headers).forEach((function(e){c.setRequestHeader(e,d(n.headers[e]))})),u.signal&&(u.signal.addEventListener("abort",l),c.onreadystatechange=function(){4===c.readyState&&u.signal.removeEventListener("abort",l)}),c.send(void 0===u._bodyInit?null:u._bodyInit)}))}_.polyfill=!0,r.fetch||(r.fetch=_,r.Headers=f,r.Request=w,r.Response=A),t.Headers=f,t.Request=w,t.Response=A,t.fetch=_}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=n.fetch?n:i;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t}(o,o.exports);var a=o.exports,s="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function u(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}var l=u,d=c;function h(e){if(l===setTimeout)return setTimeout(e,0);if((l===u||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}"function"==typeof s.setTimeout&&(l=setTimeout),"function"==typeof s.clearTimeout&&(d=clearTimeout);var f,p=[],g=!1,y=-1;function v(){g&&f&&(g=!1,f.length?p=f.concat(p):y=-1,p.length&&m())}function m(){if(!g){var e=h(v);g=!0;for(var t=p.length;t;){for(f=p,p=[];++y1)for(var r=1;r=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}return N=function(s,u){u=u||{};var c=typeof s;if("string"===c&&s.length>0)return function(a){if((a=String(a)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(!s)return;var u=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*o;case"weeks":case"week":case"w":return u*i;case"days":case"day":case"d":return u*n;case"hours":case"hour":case"hrs":case"hr":case"h":return u*r;case"minutes":case"minute":case"mins":case"min":case"m":return u*t;case"seconds":case"second":case"secs":case"sec":case"s":return u*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(s);if("number"===c&&isFinite(s))return u.long?function(i){var o=Math.abs(i);if(o>=n)return a(i,o,n,"day");if(o>=r)return a(i,o,r,"hour");if(o>=t)return a(i,o,t,"minute");if(o>=e)return a(i,o,e,"second");return i+" ms"}(s):function(i){var o=Math.abs(i);if(o>=n)return Math.round(i/n)+"d";if(o>=r)return Math.round(i/r)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))},N}var P=function(e){function t(e){let n,i,o,a=null;function s(...e){if(!s.enabled)return;const r=s,i=Number(new Date),o=i-(n||i);r.diff=o,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";a++;const o=t.formatters[i];if("function"==typeof o){const t=e[a];n=o.call(r,t),e.splice(a,1),a--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=r,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{a=e}}),"function"==typeof t.init&&t.init(s),s}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==L&&"env"in L&&(e=L.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=P(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(k,k.exports);var U,B=n(k.exports);!function(e){e.CALENDAR_SERVER="http://calendarserver.org/ns/",e.CALDAV_APPLE="http://apple.com/ns/ical/",e.CALDAV="urn:ietf:params:xml:ns:caldav",e.CARDDAV="urn:ietf:params:xml:ns:carddav",e.DAV="DAV:"}(U||(U={}));const M={[U.CALDAV]:"xmlns:c",[U.CARDDAV]:"xmlns:card",[U.CALENDAR_SERVER]:"xmlns:cs",[U.CALDAV_APPLE]:"xmlns:ca",[U.DAV]:"xmlns:d"};var V,K;!function(e){e.CALDAV="c",e.CARDDAV="card",e.CALENDAR_SERVER="cs",e.CALDAV_APPLE="ca",e.DAV="d"}(V||(V={})),function(e){e.VEVENT="VEVENT",e.VTODO="VTODO",e.VJOURNAL="VJOURNAL",e.VFREEBUSY="VFREEBUSY",e.VTIMEZONE="VTIMEZONE",e.VALARM="VALARM"}(K||(K={}));var $=[],H=[],Y="undefined"!=typeof Uint8Array?Uint8Array:Array,z=!1;function q(){z=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>18&63]+$[i>>12&63]+$[i>>6&63]+$[63&i]);return o.join("")}function W(e){var t;z||q();for(var r=e.length,n=r%3,i="",o=[],a=16383,s=0,u=r-n;su?u:s+a));return 1===n?(t=e[r-1],i+=$[t>>2],i+=$[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=$[t>>10],i+=$[t>>4&63],i+=$[t<<2&63],i+="="),o.push(i),o.join("")}function Q(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,l=-7,d=r?i-1:0,h=r?-1:1,f=e[t+d];for(d+=h,o=f&(1<<-l)-1,f>>=-l,l+=s;l>0;o=256*o+e[t+d],d+=h,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+e[t+d],d+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),o-=c}return(f?-1:1)*a*Math.pow(2,o-n)}function X(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+d>=1?h/u:h*Math.pow(2,1-d))*u>=2&&(a++,u/=2),a+d>=l?(s=0,a=l):a+d>=1?(s=(t*u-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[r+f]=255&a,f+=p,a/=256,c-=8);e[r+f-p]|=128*g}var Z={}.toString,J=Array.isArray||function(e){return"[object Array]"==Z.call(e)};function ee(){return re.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function te(e,t){if(ee()=ee())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ee().toString(16)+" bytes");return 0|e}function ue(e){return!(null==e||!e._isBuffer)}function ce(e,t){if(ue(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ke(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Ie(e).length;default:if(n)return ke(e).length;t=(""+t).toLowerCase(),n=!0}}function le(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return _e(this,t,r);case"utf8":case"utf-8":return Ee(this,t,r);case"ascii":return Ae(this,t,r);case"latin1":case"binary":return Te(this,t,r);case"base64":return we(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function de(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function he(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=re.from(t,n)),ue(t))return 0===t.length?-1:fe(e,t,r,n,i);if("number"==typeof t)return t&=255,re.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):fe(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function fe(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var l=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var d=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function we(e,t,r){return 0===t&&r===e.length?W(e):W(e.slice(t,r))}function Ee(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+d<=r)switch(d){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=d}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},re.prototype.compare=function(e,t,r,n,i){if(!ue(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(n,i),c=e.slice(t,r),l=0;li)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return pe(this,e,t,r);case"utf8":case"utf-8":return ge(this,e,t,r);case"ascii":return ye(this,e,t,r);case"latin1":case"binary":return ve(this,e,t,r);case"base64":return me(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return be(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},re.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ae(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function xe(e,t,r,n,i,o){if(!ue(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function De(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Re(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Se(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Fe(e,t,r,n,i){return i||Se(e,0,r,4),X(e,t,r,n,23,4),r+4}function Ne(e,t,r,n,i){return i||Se(e,0,r,8),X(e,t,r,n,52,8),r+8}re.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},re.prototype.readUInt8=function(e,t){return t||Oe(e,1,this.length),this[e]},re.prototype.readUInt16LE=function(e,t){return t||Oe(e,2,this.length),this[e]|this[e+1]<<8},re.prototype.readUInt16BE=function(e,t){return t||Oe(e,2,this.length),this[e]<<8|this[e+1]},re.prototype.readUInt32LE=function(e,t){return t||Oe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},re.prototype.readUInt32BE=function(e,t){return t||Oe(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},re.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Oe(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},re.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Oe(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},re.prototype.readInt8=function(e,t){return t||Oe(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},re.prototype.readInt16LE=function(e,t){t||Oe(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},re.prototype.readInt16BE=function(e,t){t||Oe(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},re.prototype.readInt32LE=function(e,t){return t||Oe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},re.prototype.readInt32BE=function(e,t){return t||Oe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},re.prototype.readFloatLE=function(e,t){return t||Oe(e,4,this.length),Q(this,e,!0,23,4)},re.prototype.readFloatBE=function(e,t){return t||Oe(e,4,this.length),Q(this,e,!1,23,4)},re.prototype.readDoubleLE=function(e,t){return t||Oe(e,8,this.length),Q(this,e,!0,52,8)},re.prototype.readDoubleBE=function(e,t){return t||Oe(e,8,this.length),Q(this,e,!1,52,8)},re.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||xe(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},re.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,1,255,0),re.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},re.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,65535,0),re.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):De(this,e,t,!0),t+2},re.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,65535,0),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):De(this,e,t,!1),t+2},re.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,4294967295,0),re.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Re(this,e,t,!0),t+4},re.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,4294967295,0),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Re(this,e,t,!1),t+4},re.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);xe(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},re.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);xe(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},re.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,1,127,-128),re.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},re.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,32767,-32768),re.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):De(this,e,t,!0),t+2},re.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,2,32767,-32768),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):De(this,e,t,!1),t+2},re.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,2147483647,-2147483648),re.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Re(this,e,t,!0),t+4},re.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||xe(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),re.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Re(this,e,t,!1),t+4},re.prototype.writeFloatLE=function(e,t,r){return Fe(this,e,t,!0,r)},re.prototype.writeFloatBE=function(e,t,r){return Fe(this,e,t,!1,r)},re.prototype.writeDoubleLE=function(e,t,r){return Ne(this,e,t,!0,r)},re.prototype.writeDoubleBE=function(e,t,r){return Ne(this,e,t,!1,r)},re.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!re.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Ie(e){return function(e){var t,r,n,i,o,a;z||q();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[s-2]?2:"="===e[s-1]?1:0,a=new Y(3*s/4-o),n=o>0?s-4:s;var u=0;for(t=0,r=0;t>16&255,a[u++]=i>>8&255,a[u++]=255&i;return 2===o?(i=H[e.charCodeAt(t)]<<2|H[e.charCodeAt(t+1)]>>4,a[u++]=255&i):1===o&&(i=H[e.charCodeAt(t)]<<10|H[e.charCodeAt(t+1)]<<4|H[e.charCodeAt(t+2)]>>2,a[u++]=i>>8&255,a[u++]=255&i),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(je,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Pe(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ue(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Be,Me={};function Ve(){}function Ke(){Ke.init.call(this)}function $e(e){return void 0===e._maxListeners?Ke.defaultMaxListeners:e._maxListeners}function He(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Ze(e,n),o=0;o0&&a.length>i){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else a=o[t]=r,++e._eventsCount;return e}function Qe(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Xe(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Ze(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}Ve.prototype=Object.create(null),Ke.EventEmitter=Ke,Ke.usingDomains=!1,Ke.prototype.domain=void 0,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.init=function(){this.domain=null,Ke.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ve,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ke.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Ke.prototype.getMaxListeners=function(){return $e(this)},Ke.prototype.emit=function(e){var t,r,n,i,o,a,s,u="error"===e;if(a=this._events)u=u&&null==a.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(r=a[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:He(r,l,this);break;case 2:Ye(r,l,this,arguments[1]);break;case 3:ze(r,l,this,arguments[1],arguments[2]);break;case 4:qe(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Ve,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]},Be="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e};var Je=/%[sdj%]/g;function et(e){if(!ht(e)){for(var t=[],r=0;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),a=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),lt(t)?r.showHidden=t:t&&wt(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=ot),st(r,e,r.depth)}function ot(e,t){var r=it.styles[t];return r?"["+it.colors[r][0]+"m"+e+"["+it.colors[r][1]+"m":e}function at(e,t){return e}function st(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==it&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=st(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(lt(t))return e.stylize(""+t,"boolean");if(dt(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),a=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ut(t);if(0===o.length){if(mt(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(pt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ut(t)}var u,c,l="",d=!1,h=["{","}"];(u=t,Array.isArray(u)&&(d=!0,h=["[","]"]),mt(t))&&(l=" [Function"+(t.name?": "+t.name:"")+"]");return pt(t)&&(l=" "+RegExp.prototype.toString.call(t)),yt(t)&&(l=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(l=" "+ut(t)),0!==o.length||d&&0!=t.length?r<0?pt(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=d?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,l,h)):h[0]+l+h[1]}function ut(e){return"["+Error.prototype.toString.call(e)+"]"}function ct(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),Et(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=dt(r)?st(e,u.value,null):st(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),ft(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function lt(e){return"boolean"==typeof e}function dt(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function pt(e){return gt(e)&&"[object RegExp]"===bt(e)}function gt(e){return"object"==typeof e&&null!==e}function yt(e){return gt(e)&&"[object Date]"===bt(e)}function vt(e){return gt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function wt(e,t){if(!t||!gt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function At(){this.head=null,this.tail=null,this.length=0}it.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},it.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},At.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},At.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},At.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},At.prototype.clear=function(){this.head=this.tail=null,this.length=0},At.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},At.prototype.concat=function(e){if(0===this.length)return re.alloc(0);if(1===this.length)return this.head.data;for(var t=re.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var Tt=re.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Tt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Ot;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=xt;break;default:return void(this.write=Ct)}this.charBuffer=new re(6),this.charReceived=0,this.charLength=0}function Ct(e){return e.toString(this.encoding)}function Ot(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function xt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_t.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},_t.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_t.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t};var Dt=Object.freeze({__proto__:null,StringDecoder:_t});Ft.ReadableState=St;var Rt=function(e){if(ft(rt)&&(rt=L.env.NODE_DEBUG||""),e=e.toUpperCase(),!nt[e])if(new RegExp("\\b"+e+"\\b","i").test(rt)){nt[e]=function(){var t=et.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else nt[e]=function(){};return nt[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new At,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new _t(e.encoding),this.encoding=e.encoding)}function Ft(e){if(!(this instanceof Ft))return new Ft(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),Ke.call(this)}function Nt(e,t,r,n,i){var o=function(e,t){var r=null;re.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Lt(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Lt(e))),function(e,t){t.readingMore||(t.readingMore=!0,b(It,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Lt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Rt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?b(kt,e):kt(e))}function kt(e){Rt("emit readable"),e.emit("readable"),Bt(e)}function It(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=re.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function Vt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,b(Kt,t,e))}function Kt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function $t(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Rt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Vt(this):Lt(this),null;if(0===(e=jt(e,t))&&t.ended)return 0===t.length&&Vt(this),null;var n,i=t.needReadable;return Rt("need readable",i),(0===t.length||t.length-e0?Mt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Vt(this)),null!==n&&this.emit("data",n),n},Ft.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ft.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,Rt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?a:c;function o(e){Rt("onunpipe"),e===r&&c()}function a(){Rt("onend"),e.end()}n.endEmitted?b(i):r.once("end",i),e.on("unpipe",o);var s=function(e){return function(){var t=e._readableState;Rt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Bt(e))}}(r);e.on("drain",s);var u=!1;function c(){Rt("cleanup"),e.removeListener("close",f),e.removeListener("finish",p),e.removeListener("drain",s),e.removeListener("error",h),e.removeListener("unpipe",o),r.removeListener("end",a),r.removeListener("end",c),r.removeListener("data",d),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||s()}var l=!1;function d(t){Rt("ondata"),l=!1,!1!==e.write(t)||l||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==$t(n.pipes,e))&&!u&&(Rt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,l=!0),r.pause())}function h(t){var r;Rt("onerror",t),g(),e.removeListener("error",h),0===(r="error",e.listeners(r).length)&&e.emit("error",t)}function f(){e.removeListener("finish",p),g()}function p(){Rt("onfinish"),e.removeListener("close",f),g()}function g(){Rt("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",f),e.once("finish",p),e.emit("pipe",r),n.flowing||(Rt("pipe resume"),r.resume()),e},Ft.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Jt(e,t),r&&(t.finished?b(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Be(ir,Ft);for(var tr=Object.keys(qt.prototype),rr=0;rr"===o?(_(n,"onsgmldeclaration",n.sgmlDecl),n.sgmlDecl="",n.state=E.TEXT):p(o)?(n.state=E.SGML_DECL_QUOTED,n.sgmlDecl+=o):n.sgmlDecl+=o;continue;case E.SGML_DECL_QUOTED:o===n.q&&(n.state=E.SGML_DECL,n.q=""),n.sgmlDecl+=o;continue;case E.DOCTYPE:">"===o?(n.state=E.TEXT,_(n,"ondoctype",n.doctype),n.doctype=!0):(n.doctype+=o,"["===o?n.state=E.DOCTYPE_DTD:p(o)&&(n.state=E.DOCTYPE_QUOTED,n.q=o));continue;case E.DOCTYPE_QUOTED:n.doctype+=o,o===n.q&&(n.q="",n.state=E.DOCTYPE);continue;case E.DOCTYPE_DTD:n.doctype+=o,"]"===o?n.state=E.DOCTYPE:p(o)&&(n.state=E.DOCTYPE_DTD_QUOTED,n.q=o);continue;case E.DOCTYPE_DTD_QUOTED:n.doctype+=o,o===n.q&&(n.state=E.DOCTYPE_DTD,n.q="");continue;case E.COMMENT:"-"===o?n.state=E.COMMENT_ENDING:n.comment+=o;continue;case E.COMMENT_ENDING:"-"===o?(n.state=E.COMMENT_ENDED,n.comment=O(n.opt,n.comment),n.comment&&_(n,"oncomment",n.comment),n.comment=""):(n.comment+="-"+o,n.state=E.COMMENT);continue;case E.COMMENT_ENDED:">"!==o?(R(n,"Malformed comment"),n.comment+="--"+o,n.state=E.COMMENT):n.state=E.TEXT;continue;case E.CDATA:"]"===o?n.state=E.CDATA_ENDING:n.cdata+=o;continue;case E.CDATA_ENDING:"]"===o?n.state=E.CDATA_ENDING_2:(n.cdata+="]"+o,n.state=E.CDATA);continue;case E.CDATA_ENDING_2:">"===o?(n.cdata&&_(n,"oncdata",n.cdata),_(n,"onclosecdata"),n.cdata="",n.state=E.TEXT):"]"===o?n.cdata+="]":(n.cdata+="]]"+o,n.state=E.CDATA);continue;case E.PROC_INST:"?"===o?n.state=E.PROC_INST_ENDING:f(o)?n.state=E.PROC_INST_BODY:n.procInstName+=o;continue;case E.PROC_INST_BODY:if(!n.procInstBody&&f(o))continue;"?"===o?n.state=E.PROC_INST_ENDING:n.procInstBody+=o;continue;case E.PROC_INST_ENDING:">"===o?(_(n,"onprocessinginstruction",{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody="",n.state=E.TEXT):(n.procInstBody+="?"+o,n.state=E.PROC_INST_BODY);continue;case E.OPEN_TAG:y(l,o)?n.tagName+=o:(S(n),">"===o?j(n):"/"===o?n.state=E.OPEN_TAG_SLASH:(f(o)||R(n,"Invalid character in tag name"),n.state=E.ATTRIB));continue;case E.OPEN_TAG_SLASH:">"===o?(j(n,!0),L(n)):(R(n,"Forward-slash in opening tag not followed by >"),n.state=E.ATTRIB);continue;case E.ATTRIB:if(f(o))continue;">"===o?j(n):"/"===o?n.state=E.OPEN_TAG_SLASH:y(c,o)?(n.attribName=o,n.attribValue="",n.state=E.ATTRIB_NAME):R(n,"Invalid attribute name");continue;case E.ATTRIB_NAME:"="===o?n.state=E.ATTRIB_VALUE:">"===o?(R(n,"Attribute without value"),n.attribValue=n.attribName,N(n),j(n)):f(o)?n.state=E.ATTRIB_NAME_SAW_WHITE:y(l,o)?n.attribName+=o:R(n,"Invalid attribute name");continue;case E.ATTRIB_NAME_SAW_WHITE:if("="===o)n.state=E.ATTRIB_VALUE;else{if(f(o))continue;R(n,"Attribute without value"),n.tag.attributes[n.attribName]="",n.attribValue="",_(n,"onattribute",{name:n.attribName,value:""}),n.attribName="",">"===o?j(n):y(c,o)?(n.attribName=o,n.state=E.ATTRIB_NAME):(R(n,"Invalid attribute name"),n.state=E.ATTRIB)}continue;case E.ATTRIB_VALUE:if(f(o))continue;p(o)?(n.q=o,n.state=E.ATTRIB_VALUE_QUOTED):(R(n,"Unquoted attribute value"),n.state=E.ATTRIB_VALUE_UNQUOTED,n.attribValue=o);continue;case E.ATTRIB_VALUE_QUOTED:if(o!==n.q){"&"===o?n.state=E.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=o;continue}N(n),n.q="",n.state=E.ATTRIB_VALUE_CLOSED;continue;case E.ATTRIB_VALUE_CLOSED:f(o)?n.state=E.ATTRIB:">"===o?j(n):"/"===o?n.state=E.OPEN_TAG_SLASH:y(c,o)?(R(n,"No whitespace between attributes"),n.attribName=o,n.attribValue="",n.state=E.ATTRIB_NAME):R(n,"Invalid attribute name");continue;case E.ATTRIB_VALUE_UNQUOTED:if(!g(o)){"&"===o?n.state=E.ATTRIB_VALUE_ENTITY_U:n.attribValue+=o;continue}N(n),">"===o?j(n):n.state=E.ATTRIB;continue;case E.CLOSE_TAG:if(n.tagName)">"===o?L(n):y(l,o)?n.tagName+=o:n.script?(n.script+=""===o?L(n):R(n,"Invalid characters in closing tag");continue;case E.TEXT_ENTITY:case E.ATTRIB_VALUE_ENTITY_Q:case E.ATTRIB_VALUE_ENTITY_U:var u,m;switch(n.state){case E.TEXT_ENTITY:u=E.TEXT,m="textNode";break;case E.ATTRIB_VALUE_ENTITY_Q:u=E.ATTRIB_VALUE_QUOTED,m="attribValue";break;case E.ATTRIB_VALUE_ENTITY_U:u=E.ATTRIB_VALUE_UNQUOTED,m="attribValue"}";"===o?(n[m]+=k(n),n.entity="",n.state=u):y(n.entity.length?h:d,o)?n.entity+=o:(R(n,"Invalid character in entity name"),n[m]+="&"+n.entity+o,n.entity="",n.state=u);continue;default:throw new Error(n,"Unknown state: "+n.state)}return n.position>=n.bufferCheckPosition&&function(t){for(var n=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,o=0,a=r.length;on)switch(r[o]){case"textNode":C(t);break;case"cdata":_(t,"oncdata",t.cdata),t.cdata="";break;case"script":_(t,"onscript",t.script),t.script="";break;default:x(t,"Max buffer length exceeded: "+r[o])}i=Math.max(i,s)}var u=e.MAX_BUFFER_LENGTH-i;t.bufferCheckPosition=u+t.position}(n),n} +/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var e;C(e=this),""!==e.cdata&&(_(e,"oncdata",e.cdata),e.cdata=""),""!==e.script&&(_(e,"onscript",e.script),e.script="")}};try{t=hr.Stream}catch(e){t=function(){}}var i=e.EVENTS.filter((function(e){return"error"!==e&&"end"!==e}));function o(e,r){if(!(this instanceof o))return new o(e,r);t.apply(this),this._parser=new n(e,r),this.writable=!0,this.readable=!0;var a=this;this._parser.onend=function(){a.emit("end")},this._parser.onerror=function(e){a.emit("error",e),a._parser.error=null},this._decoder=null,i.forEach((function(e){Object.defineProperty(a,"on"+e,{get:function(){return a._parser["on"+e]},set:function(t){if(!t)return a.removeAllListeners(e),a._parser["on"+e]=t,t;a.on(e,t)},enumerable:!0,configurable:!1})}))}o.prototype=Object.create(t.prototype,{constructor:{value:o}}),o.prototype.write=function(e){if("function"==typeof re.isBuffer&&re.isBuffer(e)){if(!this._decoder){var t=fr.StringDecoder;this._decoder=new t("utf8")}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit("data",e),!0},o.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},o.prototype.on=function(e,r){var n=this;return n._parser["on"+e]||-1===i.indexOf(e)||(n._parser["on"+e]=function(){var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),n.emit.apply(n,t)}),t.prototype.on.call(n,e,r)};var a="http://www.w3.org/XML/1998/namespace",s="http://www.w3.org/2000/xmlns/",u={xml:a,xmlns:s},c=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,l=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,d=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,h=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(e){return" "===e||"\n"===e||"\r"===e||"\t"===e}function p(e){return'"'===e||"'"===e}function g(e){return">"===e||f(e)}function y(e,t){return e.test(t)}function v(e,t){return!y(e,t)}var m,b,w,E=0;for(var A in e.STATE={BEGIN:E++,BEGIN_WHITESPACE:E++,TEXT:E++,TEXT_ENTITY:E++,OPEN_WAKA:E++,SGML_DECL:E++,SGML_DECL_QUOTED:E++,DOCTYPE:E++,DOCTYPE_QUOTED:E++,DOCTYPE_DTD:E++,DOCTYPE_DTD_QUOTED:E++,COMMENT_STARTING:E++,COMMENT:E++,COMMENT_ENDING:E++,COMMENT_ENDED:E++,CDATA:E++,CDATA_ENDING:E++,CDATA_ENDING_2:E++,PROC_INST:E++,PROC_INST_BODY:E++,PROC_INST_ENDING:E++,OPEN_TAG:E++,OPEN_TAG_SLASH:E++,ATTRIB:E++,ATTRIB_NAME:E++,ATTRIB_NAME_SAW_WHITE:E++,ATTRIB_VALUE:E++,ATTRIB_VALUE_QUOTED:E++,ATTRIB_VALUE_CLOSED:E++,ATTRIB_VALUE_UNQUOTED:E++,ATTRIB_VALUE_ENTITY_Q:E++,ATTRIB_VALUE_ENTITY_U:E++,CLOSE_TAG:E++,CLOSE_TAG_SAW_WHITE:E++,SCRIPT:E++,SCRIPT_ENDING:E++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach((function(t){var r=e.ENTITIES[t],n="number"==typeof r?String.fromCharCode(r):r;e.ENTITIES[t]=n})),e.STATE)e.STATE[e.STATE[A]]=A;function T(e,t,r){e[t]&&e[t](r)}function _(e,t,r){e.textNode&&C(e),T(e,t,r)}function C(e){e.textNode=O(e.opt,e.textNode),e.textNode&&T(e,"ontext",e.textNode),e.textNode=""}function O(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g," ")),t}function x(e,t){return C(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,T(e,"onerror",t),e}function D(e){return e.sawRoot&&!e.closedRoot&&R(e,"Unclosed root tag"),e.state!==E.BEGIN&&e.state!==E.BEGIN_WHITESPACE&&e.state!==E.TEXT&&x(e,"Unexpected end"),C(e),e.c="",e.closed=!0,T(e,"onend"),n.call(e,e.strict,e.opt),e}function R(e,t){if("object"!=typeof e||!(e instanceof n))throw new Error("bad call to strictFail");e.strict&&x(e,t)}function S(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,r=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(r.ns=t.ns),e.attribList.length=0,_(e,"onopentagstart",r)}function F(e,t){var r=e.indexOf(":")<0?["",e]:e.split(":"),n=r[0],i=r[1];return t&&"xmlns"===e&&(n="xmlns",i=""),{prefix:n,local:i}}function N(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName))e.attribName=e.attribValue="";else{if(e.opt.xmlns){var t=F(e.attribName,!0),r=t.prefix,n=t.local;if("xmlns"===r)if("xml"===n&&e.attribValue!==a)R(e,"xml: prefix must be bound to "+a+"\nActual: "+e.attribValue);else if("xmlns"===n&&e.attribValue!==s)R(e,"xmlns: prefix must be bound to "+s+"\nActual: "+e.attribValue);else{var i=e.tag,o=e.tags[e.tags.length-1]||e;i.ns===o.ns&&(i.ns=Object.create(o.ns)),i.ns[n]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,_(e,"onattribute",{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=""}}function j(e,t){if(e.opt.xmlns){var r=e.tag,n=F(e.tagName);r.prefix=n.prefix,r.local=n.local,r.uri=r.ns[n.prefix]||"",r.prefix&&!r.uri&&(R(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName)),r.uri=n.prefix);var i=e.tags[e.tags.length-1]||e;r.ns&&i.ns!==r.ns&&Object.keys(r.ns).forEach((function(t){_(e,"onopennamespace",{prefix:t,uri:r.ns[t]})}));for(var o=0,a=e.attribList.length;o",e.tagName="",void(e.state=E.SCRIPT);_(e,"onscript",e.script),e.script=""}var t=e.tags.length,r=e.tagName;e.strict||(r=r[e.looseCase]());for(var n=r;t--&&e.tags[t].name!==n;)R(e,"Unexpected close tag");if(t<0)return R(e,"Unmatched closing tag: "+e.tagName),e.textNode+="",void(e.state=E.TEXT);e.tagName=r;for(var i=e.tags.length;i-- >t;){var o=e.tag=e.tags.pop();e.tagName=e.tag.name,_(e,"onclosetag",e.tagName);var a={};for(var s in o.ns)a[s]=o.ns[s];var u=e.tags[e.tags.length-1]||e;e.opt.xmlns&&o.ns!==u.ns&&Object.keys(o.ns).forEach((function(t){var r=o.ns[t];_(e,"onclosenamespace",{prefix:t,uri:r})}))}0===t&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName="",e.attribList.length=0,e.state=E.TEXT}function k(e){var t,r=e.entity,n=r.toLowerCase(),i="";return e.ENTITIES[r]?e.ENTITIES[r]:e.ENTITIES[n]?e.ENTITIES[n]:("#"===(r=n).charAt(0)&&("x"===r.charAt(1)?(r=r.slice(2),i=(t=parseInt(r,16)).toString(16)):(r=r.slice(1),i=(t=parseInt(r,10)).toString(10))),r=r.replace(/^0+/,""),isNaN(t)||i.toLowerCase()!==r?(R(e,"Invalid character entity"),"&"+e.entity+";"):String.fromCodePoint(t))}function I(e,t){"<"===t?(e.state=E.OPEN_WAKA,e.startTagPosition=e.position):f(t)||(R(e,"Non-whitespace before first tag."),e.textNode=t,e.state=E.TEXT)}function P(e,t){var r="";return t1114111||b(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?n.push(s):(e=55296+((s-=65536)>>10),t=s%1024+56320,n.push(e,t)),(i+1===o||n.length>r)&&(a+=m.apply(null,n),n.length=0)}return a},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:w,configurable:!0,writable:!0}):String.fromCodePoint=w)}(Me);var pr,gr,yr=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},vr=yr,mr={copyOptions:function(e){var t,r={};for(t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r},ensureFlagExists:function(e,t){e in t&&"boolean"==typeof t[e]||(t[e]=!1)},ensureSpacesExists:function(e){(!("spaces"in e)||"number"!=typeof e.spaces&&"string"!=typeof e.spaces)&&(e.spaces=0)},ensureAlwaysArrayExists:function(e){"alwaysArray"in e&&("boolean"==typeof e.alwaysArray||vr(e.alwaysArray))||(e.alwaysArray=!1)},ensureKeyExists:function(e,t){e+"Key"in t&&"string"==typeof t[e+"Key"]||(t[e+"Key"]=t.compact?"_"+e:e)},checkFnExists:function(e,t){return e+"Fn"in t}},br=Me,wr=mr,Er=yr;function Ar(e){var t=Number(e);if(!isNaN(t))return t;var r=e.toLowerCase();return"true"===r||"false"!==r&&e}function Tr(e,t){var r;if(pr.compact){if(!gr[pr[e+"Key"]]&&(Er(pr.alwaysArray)?-1!==pr.alwaysArray.indexOf(pr[e+"Key"]):pr.alwaysArray)&&(gr[pr[e+"Key"]]=[]),gr[pr[e+"Key"]]&&!Er(gr[pr[e+"Key"]])&&(gr[pr[e+"Key"]]=[gr[pr[e+"Key"]]]),e+"Fn"in pr&&"string"==typeof t&&(t=pr[e+"Fn"](t,gr)),"instruction"===e&&("instructionFn"in pr||"instructionNameFn"in pr))for(r in t)if(t.hasOwnProperty(r))if("instructionFn"in pr)t[r]=pr.instructionFn(t[r],r,gr);else{var n=t[r];delete t[r],t[pr.instructionNameFn(r,n,gr)]=n}Er(gr[pr[e+"Key"]])?gr[pr[e+"Key"]].push(t):gr[pr[e+"Key"]]=t}else{gr[pr.elementsKey]||(gr[pr.elementsKey]=[]);var i={};if(i[pr.typeKey]=e,"instruction"===e){for(r in t)if(t.hasOwnProperty(r))break;i[pr.nameKey]="instructionNameFn"in pr?pr.instructionNameFn(r,t,gr):r,pr.instructionHasAttributes?(i[pr.attributesKey]=t[r][pr.attributesKey],"instructionFn"in pr&&(i[pr.attributesKey]=pr.instructionFn(i[pr.attributesKey],r,gr))):("instructionFn"in pr&&(t[r]=pr.instructionFn(t[r],r,gr)),i[pr.instructionKey]=t[r])}else e+"Fn"in pr&&(t=pr[e+"Fn"](t,gr)),i[pr[e+"Key"]]=t;pr.addParent&&(i[pr.parentKey]=gr),gr[pr.elementsKey].push(i)}}function _r(e){var t;if("attributesFn"in pr&&e&&(e=pr.attributesFn(e,gr)),(pr.trim||"attributeValueFn"in pr||"attributeNameFn"in pr||pr.nativeTypeAttributes)&&e)for(t in e)if(e.hasOwnProperty(t)&&(pr.trim&&(e[t]=e[t].trim()),pr.nativeTypeAttributes&&(e[t]=Ar(e[t])),"attributeValueFn"in pr&&(e[t]=pr.attributeValueFn(e[t],t,gr)),"attributeNameFn"in pr)){var r=e[t];delete e[t],e[pr.attributeNameFn(t,e[t],gr)]=r}return e}function Cr(e){var t={};if(e.body&&("xml"===e.name.toLowerCase()||pr.instructionHasAttributes)){for(var r,n=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(r=n.exec(e.body));)t[r[1]]=r[2]||r[3]||r[4];t=_r(t)}if("xml"===e.name.toLowerCase()){if(pr.ignoreDeclaration)return;gr[pr.declarationKey]={},Object.keys(t).length&&(gr[pr.declarationKey][pr.attributesKey]=t),pr.addParent&&(gr[pr.declarationKey][pr.parentKey]=gr)}else{if(pr.ignoreInstruction)return;pr.trim&&(e.body=e.body.trim());var i={};pr.instructionHasAttributes&&Object.keys(t).length?(i[e.name]={},i[e.name][pr.attributesKey]=t):i[e.name]=e.body,Tr("instruction",i)}}function Or(e,t){var r;if("object"==typeof e&&(t=e.attributes,e=e.name),t=_r(t),"elementNameFn"in pr&&(e=pr.elementNameFn(e,gr)),pr.compact){var n;if(r={},!pr.ignoreAttributes&&t&&Object.keys(t).length)for(n in r[pr.attributesKey]={},t)t.hasOwnProperty(n)&&(r[pr.attributesKey][n]=t[n]);!(e in gr)&&(Er(pr.alwaysArray)?-1!==pr.alwaysArray.indexOf(e):pr.alwaysArray)&&(gr[e]=[]),gr[e]&&!Er(gr[e])&&(gr[e]=[gr[e]]),Er(gr[e])?gr[e].push(r):gr[e]=r}else gr[pr.elementsKey]||(gr[pr.elementsKey]=[]),(r={})[pr.typeKey]="element",r[pr.nameKey]=e,!pr.ignoreAttributes&&t&&Object.keys(t).length&&(r[pr.attributesKey]=t),pr.alwaysChildren&&(r[pr.elementsKey]=[]),gr[pr.elementsKey].push(r);r[pr.parentKey]=gr,gr=r}function xr(e){pr.ignoreText||(e.trim()||pr.captureSpacesBetweenElements)&&(pr.trim&&(e=e.trim()),pr.nativeType&&(e=Ar(e)),pr.sanitize&&(e=e.replace(/&/g,"&").replace(//g,">")),Tr("text",e))}function Dr(e){pr.ignoreComment||(pr.trim&&(e=e.trim()),Tr("comment",e))}function Rr(e){var t=gr[pr.parentKey];pr.addParent||delete gr[pr.parentKey],gr=t}function Sr(e){pr.ignoreCdata||(pr.trim&&(e=e.trim()),Tr("cdata",e))}function Fr(e){pr.ignoreDoctype||(e=e.replace(/^ /,""),pr.trim&&(e=e.trim()),Tr("doctype",e))}function Nr(e){e.note=e}var jr=function(e,t){var r=br.parser(!0,{}),n={};if(gr=n,pr=function(e){return pr=wr.copyOptions(e),wr.ensureFlagExists("ignoreDeclaration",pr),wr.ensureFlagExists("ignoreInstruction",pr),wr.ensureFlagExists("ignoreAttributes",pr),wr.ensureFlagExists("ignoreText",pr),wr.ensureFlagExists("ignoreComment",pr),wr.ensureFlagExists("ignoreCdata",pr),wr.ensureFlagExists("ignoreDoctype",pr),wr.ensureFlagExists("compact",pr),wr.ensureFlagExists("alwaysChildren",pr),wr.ensureFlagExists("addParent",pr),wr.ensureFlagExists("trim",pr),wr.ensureFlagExists("nativeType",pr),wr.ensureFlagExists("nativeTypeAttributes",pr),wr.ensureFlagExists("sanitize",pr),wr.ensureFlagExists("instructionHasAttributes",pr),wr.ensureFlagExists("captureSpacesBetweenElements",pr),wr.ensureAlwaysArrayExists(pr),wr.ensureKeyExists("declaration",pr),wr.ensureKeyExists("instruction",pr),wr.ensureKeyExists("attributes",pr),wr.ensureKeyExists("text",pr),wr.ensureKeyExists("comment",pr),wr.ensureKeyExists("cdata",pr),wr.ensureKeyExists("doctype",pr),wr.ensureKeyExists("type",pr),wr.ensureKeyExists("name",pr),wr.ensureKeyExists("elements",pr),wr.ensureKeyExists("parent",pr),wr.checkFnExists("doctype",pr),wr.checkFnExists("instruction",pr),wr.checkFnExists("cdata",pr),wr.checkFnExists("comment",pr),wr.checkFnExists("text",pr),wr.checkFnExists("instructionName",pr),wr.checkFnExists("elementName",pr),wr.checkFnExists("attributeName",pr),wr.checkFnExists("attributeValue",pr),wr.checkFnExists("attributes",pr),pr}(t),r.opt={strictEntities:!0},r.onopentag=Or,r.ontext=xr,r.oncomment=Dr,r.onclosetag=Rr,r.onerror=Nr,r.oncdata=Sr,r.ondoctype=Fr,r.onprocessinginstruction=Cr,r.write(e).close(),n[pr.elementsKey]){var i=n[pr.elementsKey];delete n[pr.elementsKey],n[pr.elementsKey]=i,delete n.text}return n},Lr=mr,kr=jr;var Ir,Pr,Ur=mr,Br=yr;function Mr(e,t,r){return(!r&&e.spaces?"\n":"")+Array(t+1).join(e.spaces)}function Vr(e,t,r){if(t.ignoreAttributes)return"";"attributesFn"in t&&(e=t.attributesFn(e,Pr,Ir));var n,i,o,a,s=[];for(n in e)e.hasOwnProperty(n)&&null!==e[n]&&void 0!==e[n]&&(a=t.noQuotesForNativeAttributes&&"string"!=typeof e[n]?"":'"',i=(i=""+e[n]).replace(/"/g,"""),o="attributeNameFn"in t?t.attributeNameFn(n,i,Pr,Ir):n,s.push(t.spaces&&t.indentAttributes?Mr(t,r+1,!1):" "),s.push(o+"="+a+("attributeValueFn"in t?t.attributeValueFn(i,n,Pr,Ir):i)+a));return e&&Object.keys(e).length&&t.spaces&&t.indentAttributes&&s.push(Mr(t,r,!1)),s.join("")}function Kr(e,t,r){return Ir=e,Pr="xml",t.ignoreDeclaration?"":""}function $r(e,t,r){if(t.ignoreInstruction)return"";var n;for(n in e)if(e.hasOwnProperty(n))break;var i="instructionNameFn"in t?t.instructionNameFn(n,e[n],Pr,Ir):n;if("object"==typeof e[n])return Ir=e,Pr=i,"";var o=e[n]?e[n]:"";return"instructionFn"in t&&(o=t.instructionFn(o,n,Pr,Ir)),""}function Hr(e,t){return t.ignoreComment?"":"\x3c!--"+("commentFn"in t?t.commentFn(e,Pr,Ir):e)+"--\x3e"}function Yr(e,t){return t.ignoreCdata?"":"","]]]]>"))+"]]>"}function zr(e,t){return t.ignoreDoctype?"":""}function qr(e,t){return t.ignoreText?"":(e=(e=(e=""+e).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in t?t.textFn(e,Pr,Ir):e)}function Gr(e,t,r,n){return e.reduce((function(e,i){var o=Mr(t,r,n&&!e);switch(i.type){case"element":return e+o+function(e,t,r){Ir=e,Pr=e.name;var n=[],i="elementNameFn"in t?t.elementNameFn(e.name,e):e.name;n.push("<"+i),e[t.attributesKey]&&n.push(Vr(e[t.attributesKey],t,r));var o=e[t.elementsKey]&&e[t.elementsKey].length||e[t.attributesKey]&&"preserve"===e[t.attributesKey]["xml:space"];return o||(o="fullTagEmptyElementFn"in t?t.fullTagEmptyElementFn(e.name,e):t.fullTagEmptyElement),o?(n.push(">"),e[t.elementsKey]&&e[t.elementsKey].length&&(n.push(Gr(e[t.elementsKey],t,r+1)),Ir=e,Pr=e.name),n.push(t.spaces&&function(e,t){var r;if(e.elements&&e.elements.length)for(r=0;r")):n.push("/>"),n.join("")}(i,t,r);case"comment":return e+o+Hr(i[t.commentKey],t);case"doctype":return e+o+zr(i[t.doctypeKey],t);case"cdata":return e+(t.indentCdata?o:"")+Yr(i[t.cdataKey],t);case"text":return e+(t.indentText?o:"")+qr(i[t.textKey],t);case"instruction":var a={};return a[i[t.nameKey]]=i[t.attributesKey]?i:i[t.instructionKey],e+(t.indentInstruction?o:"")+$r(a,t,r)}}),"")}function Wr(e,t,r){var n;for(n in e)if(e.hasOwnProperty(n))switch(n){case t.parentKey:case t.attributesKey:break;case t.textKey:if(t.indentText||r)return!0;break;case t.cdataKey:if(t.indentCdata||r)return!0;break;case t.instructionKey:if(t.indentInstruction||r)return!0;break;case t.doctypeKey:case t.commentKey:default:return!0}return!1}function Qr(e,t,r,n,i){Ir=e,Pr=t;var o="elementNameFn"in r?r.elementNameFn(t,e):t;if(null==e||""===e)return"fullTagEmptyElementFn"in r&&r.fullTagEmptyElementFn(t,e)||r.fullTagEmptyElement?"<"+o+">":"<"+o+"/>";var a=[];if(t){if(a.push("<"+o),"object"!=typeof e)return a.push(">"+qr(e,r)+""),a.join("");e[r.attributesKey]&&a.push(Vr(e[r.attributesKey],r,n));var s=Wr(e,r,!0)||e[r.attributesKey]&&"preserve"===e[r.attributesKey]["xml:space"];if(s||(s="fullTagEmptyElementFn"in r?r.fullTagEmptyElementFn(t,e):r.fullTagEmptyElement),!s)return a.push("/>"),a.join("");a.push(">")}return a.push(Xr(e,r,n+1,!1)),Ir=e,Pr=t,t&&a.push((i?Mr(r,n,!1):"")+""),a.join("")}function Xr(e,t,r,n){var i,o,a,s=[];for(o in e)if(e.hasOwnProperty(o))for(a=Br(e[o])?e[o]:[e[o]],i=0;i{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},on=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),n=t.trim();if(Math.abs(r.length-n.length)>1)return!1;const i="/"===r.slice(-1)?r.slice(0,-1):r,o="/"===n.slice(-1)?n.slice(0,-1):n;return e.includes(o)||t.includes(i)},an=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),n=t.trim(),i="/"===r.slice(-1)?r.slice(0,-1):r,o="/"===n.slice(-1)?n.slice(0,-1):n;return e.includes(o)||t.includes(i)},sn=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[M[t]]:t})),{}),un=e=>Object.entries(e).reduce(((e,[t,r])=>r?Object.assign(Object.assign({},e),{[t]:r}):e),{}),cn=(e,t)=>t?{[e]:t}:{},ln=(e,t)=>e?t&&0!==t.length?Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e)))):e:{};var dn=Object.freeze({__proto__:null,cleanupFalsy:un,conditionalParam:cn,excludeHeaders:ln,getDAVAttribute:sn,urlContains:an,urlEquals:on});const hn=B("tsdav:request"),fn=e=>t(void 0,void 0,void 0,(function*(){var t;const{url:r,init:n,convertIncoming:i=!0,parseOutgoing:o=!0}=e,{headers:s={},body:u,namespace:c,method:l,attributes:d}=n,h=i?rn.js2xml(Object.assign(Object.assign({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},u),{_attributes:d}),{compact:!0,spaces:2,elementNameFn:e=>c&&!/^.+:.+/.test(e)?`${c}:${e}`:e}):u,f=yield a.fetch(r,{headers:Object.assign({"Content-Type":"text/xml;charset=UTF-8"},un(s)),body:h,method:l}),p=yield f.text();if(!f.ok||!(null===(t=f.headers.get("content-type"))||void 0===t?void 0:t.includes("xml"))||!o)return[{href:f.url,ok:f.ok,status:f.status,statusText:f.statusText,raw:p}];const g=rn.xml2js(p,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,n=Object.keys(r),i=n[n.length-1],o=r[i];if(o.length>0){o[o.length-1]=nn(e)}else r[i]=nn(e)}catch(e){hn(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,(e=>e[1].toUpperCase())),attributesFn:e=>{const t=Object.assign({},e);return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(g.multistatus.response)?g.multistatus.response:[g.multistatus.response]).map((e=>{var t,r;if(!e)return{status:f.status,statusText:f.statusText,ok:f.ok};const n=/^\S+\s(?\d+)\s(?.+)$/.exec(e.status);return{raw:g,href:e.href,status:(null==n?void 0:n.groups)?Number.parseInt(null==n?void 0:n.groups.status,10):f.status,statusText:null!==(r=null===(t=null==n?void 0:n.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:f.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce(((e,t)=>Object.assign(Object.assign({},e),null==t?void 0:t.prop)),{})}}))})),pn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:n,headers:i,headersToExclude:o}=e;return fn({url:t,init:{method:"PROPFIND",headers:ln(un(Object.assign({depth:n},i)),o),namespace:V.DAV,body:{propfind:{_attributes:sn([U.CALDAV,U.CALDAV_APPLE,U.CALENDAR_SERVER,U.CARDDAV,U.DAV]),prop:r}}}})})),gn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,data:r,headers:n,headersToExclude:i}=e;return a.fetch(t,{method:"PUT",body:r,headers:ln(n,i)})})),yn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,data:r,etag:n,headers:i,headersToExclude:o}=e;return a.fetch(t,{method:"PUT",body:r,headers:ln(un(Object.assign({"If-Match":n},i)),o)})})),vn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,headers:r,etag:n,headersToExclude:i}=e;return a.fetch(t,{method:"DELETE",headers:ln(un(Object.assign({"If-Match":n},r)),i)})}));var mn=Object.freeze({__proto__:null,createObject:gn,davRequest:fn,deleteObject:vn,propfind:pn,updateObject:yn});function bn(e,t){const r=e=>t.every((t=>e[t]));return Array.isArray(e)?e.every((e=>r(e))):r(e)}const wn=(e,t)=>t.reduce(((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`),""),En=B("tsdav:collection"),An=e=>t(void 0,void 0,void 0,(function*(){const{url:t,body:r,depth:n,defaultNamespace:i=V.DAV,headers:o,headersToExclude:a}=e,s=yield fn({url:t,init:{method:"REPORT",headers:ln(un(Object.assign({depth:n},o)),a),namespace:i,body:r}});return 1!==s.length||s[0].raw?s:[]})),Tn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:n,headers:i,headersToExclude:o}=e;return fn({url:t,init:{method:"MKCOL",headers:ln(un(Object.assign({depth:n},i)),o),namespace:V.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0}})})),_n=e=>t(void 0,void 0,void 0,(function*(){var t,r,n,i,o;const{collection:a,headers:s,headersToExclude:u}=e;return null!==(o=null===(i=null===(n=null===(r=null===(t=(yield pn({url:a.url,props:{[`${V.DAV}:supported-report-set`]:{}},depth:"0",headers:ln(s,u)}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===n?void 0:n.supportedReport)||void 0===i?void 0:i.map((e=>Object.keys(e.report)[0])))&&void 0!==o?o:[]})),Cn=e=>t(void 0,void 0,void 0,(function*(){var t,r,n;const{collection:i,headers:o,headersToExclude:a}=e,s=(yield pn({url:i.url,props:{[`${V.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:ln(o,a)})).filter((e=>an(i.url,e.href)))[0];if(!s)throw new Error("Collection does not exist on server");return{isDirty:i.ctag!==(null===(t=s.props)||void 0===t?void 0:t.getctag),newCtag:null===(n=null===(r=s.props)||void 0===r?void 0:r.getctag)||void 0===n?void 0:n.toString()}})),On=e=>{const{url:t,props:r,headers:n,syncLevel:i,syncToken:o,headersToExclude:a}=e;return fn({url:t,init:{method:"REPORT",namespace:V.DAV,headers:ln(Object.assign({},n),a),body:{"sync-collection":{_attributes:sn([U.CALDAV,U.CARDDAV,U.DAV]),"sync-level":i,"sync-token":o,[`${V.DAV}:prop`]:r}}}})},xn=e=>t(void 0,void 0,void 0,(function*(){var t,r,n,i,o,a,s,u,c,l,d;const{collection:h,method:f,headers:p,headersToExclude:g,account:y,detailedResult:v}=e,m=["accountType","homeUrl"];if(!y||!bn(y,m)){if(!y)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${wn(y,m)} before smartCollectionSync`)}const b=null!=f?f:(null===(t=h.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(En(`smart collection sync with type ${y.accountType} and method ${b}`),"webdav"===b){const e=yield On({url:h.url,props:{[`${V.DAV}:getetag`]:{},[`${"caldav"===y.accountType?V.CALDAV:V.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{},[`${V.DAV}:displayname`]:{}},syncLevel:1,syncToken:h.syncToken,headers:ln(p,g)}),t=e.filter((e=>{var t;const r="caldav"===y.accountType?".ics":".vcf";return(null===(t=e.href)||void 0===t?void 0:t.slice(-4))===r})),c=t.filter((e=>404!==e.status)).map((e=>e.href)),l=t.filter((e=>404===e.status)).map((e=>e.href)),d=(c.length&&null!==(n=yield null===(r=null==h?void 0:h.objectMultiGet)||void 0===r?void 0:r.call(h,{url:h.url,props:{[`${V.DAV}:getetag`]:{},[`${"caldav"===y.accountType?V.CALDAV:V.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:c,depth:"1",headers:ln(p,g)}))&&void 0!==n?n:[]).map((e=>{var t,r,n,i,o,a,s,u,c,l;return{url:null!==(t=e.href)&&void 0!==t?t:"",etag:null===(r=e.props)||void 0===r?void 0:r.getetag,data:"caldav"===(null==y?void 0:y.accountType)?null!==(o=null===(i=null===(n=e.props)||void 0===n?void 0:n.calendarData)||void 0===i?void 0:i._cdata)&&void 0!==o?o:null===(a=e.props)||void 0===a?void 0:a.calendarData:null!==(c=null===(u=null===(s=e.props)||void 0===s?void 0:s.addressData)||void 0===u?void 0:u._cdata)&&void 0!==c?c:null===(l=e.props)||void 0===l?void 0:l.addressData}})),f=null!==(i=h.objects)&&void 0!==i?i:[],m=d.filter((e=>f.every((t=>!an(t.url,e.url))))),b=f.reduce(((e,t)=>{const r=d.find((e=>an(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),w=l.map((e=>({url:e,etag:""}))),E=f.filter((e=>d.some((t=>an(e.url,t.url)&&t.etag===e.etag))));return Object.assign(Object.assign({},h),{objects:v?{created:m,updated:b,deleted:w}:[...E,...m,...b],syncToken:null!==(u=null===(s=null===(a=null===(o=e[0])||void 0===o?void 0:o.raw)||void 0===a?void 0:a.multistatus)||void 0===s?void 0:s.syncToken)&&void 0!==u?u:h.syncToken})}if("basic"===b){const{isDirty:e,newCtag:t}=yield Cn({collection:h,headers:ln(p,g)}),r=null!==(c=h.objects)&&void 0!==c?c:[],n=null!==(d=yield null===(l=h.fetchObjects)||void 0===l?void 0:l.call(h,{collection:h,headers:ln(p,g)}))&&void 0!==d?d:[],i=n.filter((e=>r.every((t=>!an(t.url,e.url))))),o=r.reduce(((e,t)=>{const r=n.find((e=>an(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),a=r.filter((e=>n.every((t=>!an(t.url,e.url))))),s=r.filter((e=>n.some((t=>an(e.url,t.url)&&t.etag===e.etag))));if(e)return Object.assign(Object.assign({},h),{objects:v?{created:i,updated:o,deleted:a}:[...s,...i,...o],ctag:t})}return v?Object.assign(Object.assign({},h),{objects:{created:[],updated:[],deleted:[]}}):h}));var Dn=Object.freeze({__proto__:null,collectionQuery:An,isCollectionDirty:Cn,makeCollection:Tn,smartCollectionSync:xn,supportedReportSet:_n,syncCollection:On});const Rn=B("tsdav:addressBook"),Sn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:n,depth:i,headers:o,headersToExclude:a}=e;return An({url:t,body:{"addressbook-query":{_attributes:sn([U.CARDDAV,U.DAV]),[`${V.DAV}:prop`]:r,filter:null!=n?n:{"prop-filter":{_attributes:{name:"FN"}}}}},defaultNamespace:V.CARDDAV,depth:i,headers:ln(o,a)})})),Fn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:n,depth:i,headers:o}=e;return An({url:t,body:{"addressbook-multiget":{_attributes:sn([U.DAV,U.CARDDAV]),[`${V.DAV}:prop`]:r,[`${V.DAV}:href`]:n}},defaultNamespace:V.CARDDAV,depth:i,headers:o})})),Nn=e=>t(void 0,void 0,void 0,(function*(){const{account:r,headers:n,props:i,headersToExclude:o}=null!=e?e:{},a=["homeUrl","rootUrl"];if(!r||!bn(r,a)){if(!r)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${wn(r,a)} before fetchAddressBooks`)}const s=yield pn({url:r.homeUrl,props:null!=i?i:{[`${V.DAV}:displayname`]:{},[`${V.CALENDAR_SERVER}:getctag`]:{},[`${V.DAV}:resourcetype`]:{},[`${V.DAV}:sync-token`]:{}},depth:"1",headers:ln(n,o)});return Promise.all(s.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("addressbook")})).map((e=>{var t,n,i,o,a,s,u,c,l;const d=null!==(i=null===(n=null===(t=e.props)||void 0===t?void 0:t.displayname)||void 0===n?void 0:n._cdata)&&void 0!==i?i:null===(o=e.props)||void 0===o?void 0:o.displayname;return Rn(`Found address book named ${"string"==typeof d?d:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(a=e.href)&&void 0!==a?a:"",null!==(s=r.rootUrl)&&void 0!==s?s:"").href,ctag:null===(u=e.props)||void 0===u?void 0:u.getctag,displayName:"string"==typeof d?d:"",resourcetype:Object.keys(null===(c=e.props)||void 0===c?void 0:c.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}})).map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield _n({collection:e,headers:n})})})))))})),jn=e=>t(void 0,void 0,void 0,(function*(){const{addressBook:t,headers:r,objectUrls:n,headersToExclude:i,urlFilter:o=(e=>e),useMultiGet:a=!0}=e;Rn(`Fetching vcards from ${null==t?void 0:t.url}`);const s=["url"];if(!t||!bn(t,s)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${wn(t,s)} before fetchVCards`)}const u=(null!=n?n:(yield Sn({url:t.url,props:{[`${V.DAV}:getetag`]:{}},depth:"1",headers:ln(r,i)})).map((e=>{var t;return e.ok&&null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(o).map((e=>new URL(e).pathname));let c=[];return u.length>0&&(c=a?yield Fn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CARDDAV}:address-data`]:{}},objectUrls:u,depth:"1",headers:ln(r,i)}):yield Sn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CARDDAV}:address-data`]:{}},depth:"1",headers:ln(r,i)})),c.map((e=>{var r,n,i,o,a,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(n=e.props)||void 0===n?void 0:n.getetag,data:null!==(a=null===(o=null===(i=e.props)||void 0===i?void 0:i.addressData)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(s=e.props)||void 0===s?void 0:s.addressData}}))})),Ln=e=>t(void 0,void 0,void 0,(function*(){const{addressBook:t,vCardString:r,filename:n,headers:i,headersToExclude:o}=e;return gn({url:new URL(n,t.url).href,data:r,headers:ln(Object.assign({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*"},i),o)})})),kn=e=>t(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:n}=e;return yn({url:t.url,data:t.data,etag:t.etag,headers:ln(Object.assign({"content-type":"text/vcard; charset=utf-8"},r),n)})})),In=e=>t(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:n}=e;return vn({url:t.url,etag:t.etag,headers:ln(r,n)})}));var Pn=Object.freeze({__proto__:null,addressBookMultiGet:Fn,addressBookQuery:Sn,createVCard:Ln,deleteVCard:In,fetchAddressBooks:Nn,fetchVCards:jn,updateVCard:kn});const Un=B("tsdav:calendar"),Bn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:n,timezone:i,depth:o,headers:a,headersToExclude:s}=e;return An({url:t,body:{"calendar-query":un({_attributes:sn([U.CALDAV,U.CALENDAR_SERVER,U.CALDAV_APPLE,U.DAV]),[`${V.DAV}:prop`]:r,filter:n,timezone:i})},defaultNamespace:V.CALDAV,depth:o,headers:ln(a,s)})})),Mn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:n,filters:i,timezone:o,depth:a,headers:s,headersToExclude:u}=e;return An({url:t,body:{"calendar-multiget":Object.assign(Object.assign({_attributes:sn([U.DAV,U.CALDAV]),[`${V.DAV}:prop`]:r,[`${V.DAV}:href`]:n},cn("filter",i)),{timezone:o})},defaultNamespace:V.CALDAV,depth:a,headers:ln(s,u)})})),Vn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:n,headers:i,headersToExclude:o}=e;return fn({url:t,init:{method:"MKCALENDAR",headers:ln(un(Object.assign({depth:n},i)),o),namespace:V.DAV,body:{[`${V.CALDAV}:mkcalendar`]:{_attributes:sn([U.DAV,U.CALDAV,U.CALDAV_APPLE]),set:{prop:r}}}}})})),Kn=e=>t(void 0,void 0,void 0,(function*(){const{headers:r,account:n,props:i,projectedProps:o,headersToExclude:a}=null!=e?e:{},s=["homeUrl","rootUrl"];if(!n||!bn(n,s)){if(!n)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${wn(n,s)} before fetchCalendars`)}const u=yield pn({url:n.homeUrl,props:null!=i?i:{[`${V.CALDAV}:calendar-description`]:{},[`${V.CALDAV}:calendar-timezone`]:{},[`${V.DAV}:displayname`]:{},[`${V.CALDAV_APPLE}:calendar-color`]:{},[`${V.CALENDAR_SERVER}:getctag`]:{},[`${V.DAV}:resourcetype`]:{},[`${V.CALDAV}:supported-calendar-component-set`]:{},[`${V.DAV}:sync-token`]:{}},depth:"1",headers:ln(r,a)});return Promise.all(u.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("calendar")})).filter((e=>{var t,r,n,i;return(Array.isArray(null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet.comp)?null===(r=e.props)||void 0===r?void 0:r.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(i=null===(n=e.props)||void 0===n?void 0:n.supportedCalendarComponentSet.comp)||void 0===i?void 0:i._attributes.name]||[]).some((e=>Object.values(K).includes(e)))})).map((e=>{var t,r,i,a,s,u,c,l,d,h,f,p,g,y,v,m;const b=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,w=null===(r=e.props)||void 0===r?void 0:r.calendarTimezone;return Object.assign({description:"string"==typeof b?b:"",timezone:"string"==typeof w?w:"",url:new URL(null!==(i=e.href)&&void 0!==i?i:"",null!==(a=n.rootUrl)&&void 0!==a?a:"").href,ctag:null===(s=e.props)||void 0===s?void 0:s.getctag,calendarColor:null===(u=e.props)||void 0===u?void 0:u.calendarColor,displayName:null!==(l=null===(c=e.props)||void 0===c?void 0:c.displayname._cdata)&&void 0!==l?l:null===(d=e.props)||void 0===d?void 0:d.displayname,components:Array.isArray(null===(h=e.props)||void 0===h?void 0:h.supportedCalendarComponentSet.comp)?null===(f=e.props)||void 0===f?void 0:f.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(g=null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp)||void 0===g?void 0:g._attributes.name],resourcetype:Object.keys(null===(y=e.props)||void 0===y?void 0:y.resourcetype),syncToken:null===(v=e.props)||void 0===v?void 0:v.syncToken},cn("projectedProps",Object.fromEntries(Object.entries(null!==(m=e.props)&&void 0!==m?m:{}).filter((([e])=>null==o?void 0:o[e])))))})).map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield _n({collection:e,headers:ln(r,a)})})})))))})),$n=e=>t(void 0,void 0,void 0,(function*(){const{calendar:t,objectUrls:r,filters:n,timeRange:i,headers:o,expand:a,urlFilter:s=(e=>Boolean(null==e?void 0:e.includes(".ics"))),useMultiGet:u=!0,headersToExclude:c}=e;if(i){const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(i.start)&&e.test(i.end)||t.test(i.start)&&t.test(i.end)))throw new Error("invalid timeRange format, not in ISO8601")}Un(`Fetching calendar objects from ${null==t?void 0:t.url}`);const l=["url"];if(!t||!bn(t,l)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${wn(t,l)} before fetchCalendarObjects`)}const d=null!=n?n:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":Object.assign({_attributes:{name:"VEVENT"}},i?{"time-range":{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})}}],h=(null!=r?r:(yield Bn({url:t.url,props:{[`${V.DAV}:getetag`]:Object.assign({},a&&i?{[`${V.CALDAV}:expand`]:{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:d,depth:"1",headers:ln(o,c)})).map((e=>{var t;return null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(s).map((e=>new URL(e).pathname));let f=[];return h.length>0&&(f=!u||a?yield Bn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CALDAV}:calendar-data`]:Object.assign({},a&&i?{[`${V.CALDAV}:expand`]:{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:d,depth:"1",headers:ln(o,c)}):yield Mn({url:t.url,props:{[`${V.DAV}:getetag`]:{},[`${V.CALDAV}:calendar-data`]:Object.assign({},a&&i?{[`${V.CALDAV}:expand`]:{_attributes:{start:`${new Date(i.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(i.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},objectUrls:h,depth:"1",headers:ln(o,c)})),f.map((e=>{var r,n,i,o,a,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(n=e.props)||void 0===n?void 0:n.getetag}`,data:null!==(a=null===(o=null===(i=e.props)||void 0===i?void 0:i.calendarData)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(s=e.props)||void 0===s?void 0:s.calendarData}}))})),Hn=e=>t(void 0,void 0,void 0,(function*(){const{calendar:t,iCalString:r,filename:n,headers:i,headersToExclude:o}=e;return gn({url:new URL(n,t.url).href,data:r,headers:ln(Object.assign({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*"},i),o)})})),Yn=e=>t(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:n}=e;return yn({url:t.url,data:t.data,etag:t.etag,headers:ln(Object.assign({"content-type":"text/calendar; charset=utf-8"},r),n)})})),zn=e=>t(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:n}=e;return vn({url:t.url,etag:t.etag,headers:ln(r,n)})})),qn=e=>t(void 0,void 0,void 0,(function*(){var r;const{oldCalendars:n,account:i,detailedResult:o,headers:a,headersToExclude:s}=e;if(!i)throw new Error("Must have account before syncCalendars");const u=null!==(r=null!=n?n:i.calendars)&&void 0!==r?r:[],c=yield Kn({account:i,headers:ln(a,s)}),l=c.filter((e=>u.every((t=>!an(t.url,e.url)))));Un(`new calendars: ${l.map((e=>e.displayName))}`);const d=u.reduce(((e,t)=>{const r=c.find((e=>an(e.url,t.url)));return r&&(r.syncToken&&r.syncToken!==t.syncToken||r.ctag&&r.ctag!==t.ctag)?[...e,r]:e}),[]);Un(`updated calendars: ${d.map((e=>e.displayName))}`);const h=yield Promise.all(d.map((e=>t(void 0,void 0,void 0,(function*(){return yield xn({collection:Object.assign(Object.assign({},e),{objectMultiGet:Mn}),method:"webdav",headers:ln(a,s),account:i})}))))),f=u.filter((e=>c.every((t=>!an(t.url,e.url)))));Un(`deleted calendars: ${f.map((e=>e.displayName))}`);const p=u.filter((e=>c.some((t=>an(t.url,e.url)&&(t.syncToken&&t.syncToken!==e.syncToken||t.ctag&&t.ctag!==e.ctag)))));return o?{created:l,updated:d,deleted:f}:[...p,...l,...h]})),Gn=e=>t(void 0,void 0,void 0,(function*(){const{url:t,timeRange:r,depth:n,headers:i,headersToExclude:o}=e;if(!r)throw new Error("timeRange is required");{const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(r.start)&&e.test(r.end)||t.test(r.start)&&t.test(r.end)))throw new Error("invalid timeRange format, not in ISO8601")}return(yield An({url:t,body:{"free-busy-query":un({_attributes:sn([U.CALDAV]),[`${V.CALDAV}:time-range`]:{_attributes:{start:`${new Date(r.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(r.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}})},defaultNamespace:V.CALDAV,depth:n,headers:ln(i,o)}))[0]}));var Wn=Object.freeze({__proto__:null,calendarMultiGet:Mn,calendarQuery:Bn,createCalendarObject:Hn,deleteCalendarObject:zn,fetchCalendarObjects:$n,fetchCalendars:Kn,freeBusyQuery:Gn,makeCalendar:Vn,syncCalendars:qn,updateCalendarObject:Yn});const Qn=B("tsdav:account"),Xn=e=>t(void 0,void 0,void 0,(function*(){var t,r;Qn("Service discovery...");const{account:n,headers:i,headersToExclude:o}=e,s=new URL(n.serverUrl),u=new URL(`/.well-known/${n.accountType}`,s);u.protocol=null!==(t=s.protocol)&&void 0!==t?t:"http";try{const e=yield a.fetch(u.href,{headers:ln(i,o),method:"PROPFIND",redirect:"manual"});if(e.status>=300&&e.status<400){const t=e.headers.get("Location");if("string"==typeof t&&t.length){Qn(`Service discovery redirected to ${t}`);const e=new URL(t,s);return e.hostname===u.hostname&&u.port&&!e.port&&(e.port=u.port),e.protocol=null!==(r=s.protocol)&&void 0!==r?r:"http",e.href}}}catch(e){Qn(`Service discovery failed: ${e.stack}`)}return s.href})),Zn=e=>t(void 0,void 0,void 0,(function*(){var t,r,n,i,o;const{account:a,headers:s,headersToExclude:u}=e,c=["rootUrl"];if(!bn(a,c))throw new Error(`account must have ${wn(a,c)} before fetchPrincipalUrl`);Qn(`Fetching principal url from path ${a.rootUrl}`);const[l]=yield pn({url:a.rootUrl,props:{[`${V.DAV}:current-user-principal`]:{}},depth:"0",headers:ln(s,u)});if(!l.ok&&(Qn(`Fetch principal url failed: ${l.statusText}`),401===l.status))throw new Error("Invalid credentials");return Qn(`Fetched principal url ${null===(r=null===(t=l.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(o=null===(i=null===(n=l.props)||void 0===n?void 0:n.currentUserPrincipal)||void 0===i?void 0:i.href)&&void 0!==o?o:"",a.rootUrl).href})),Jn=e=>t(void 0,void 0,void 0,(function*(){var t,r;const{account:n,headers:i,headersToExclude:o}=e,a=["principalUrl","rootUrl"];if(!bn(n,a))throw new Error(`account must have ${wn(n,a)} before fetchHomeUrl`);Qn(`Fetch home url from ${n.principalUrl}`);const s=(yield pn({url:n.principalUrl,props:"caldav"===n.accountType?{[`${V.CALDAV}:calendar-home-set`]:{}}:{[`${V.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:ln(i,o)})).find((e=>an(n.principalUrl,e.href)));if(!s||!s.ok)throw new Error("cannot find homeUrl");const u=new URL("caldav"===n.accountType?null===(t=null==s?void 0:s.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==s?void 0:s.props)||void 0===r?void 0:r.addressbookHomeSet.href,n.rootUrl).href;return Qn(`Fetched home url ${u}`),u})),ei=e=>t(void 0,void 0,void 0,(function*(){const{account:r,headers:n,loadCollections:i=!1,loadObjects:o=!1,headersToExclude:a}=e,s=Object.assign({},r);return s.rootUrl=yield Xn({account:r,headers:ln(n,a)}),s.principalUrl=yield Zn({account:s,headers:ln(n,a)}),s.homeUrl=yield Jn({account:s,headers:ln(n,a)}),(i||o)&&("caldav"===r.accountType?s.calendars=yield Kn({headers:ln(n,a),account:s}):"carddav"===r.accountType&&(s.addressBooks=yield Nn({headers:ln(n,a),account:s}))),o&&("caldav"===r.accountType&&s.calendars?s.calendars=yield Promise.all(s.calendars.map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield $n({calendar:e,headers:ln(n,a)})})}))))):"carddav"===r.accountType&&s.addressBooks&&(s.addressBooks=yield Promise.all(s.addressBooks.map((e=>t(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield jn({addressBook:e,headers:ln(n,a)})})}))))))),s}));var ti,ri,ni=Object.freeze({__proto__:null,createAccount:ei,fetchHomeUrl:Jn,fetchPrincipalUrl:Zn,serviceDiscovery:Xn}),ii={exports:{}};ti=ii,ri=ii.exports,function(e){var t=ri,n=ti&&ti.exports==t&&ti,i="object"==typeof r&&r;i.global!==i&&i.window!==i||(e=i);var o=function(e){this.message=e};(o.prototype=new Error).name="InvalidCharacterError";var a=function(e){throw new o(e)},s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,c={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&a("The string to be encoded contains characters outside of the Latin1 range.");for(var t,r,n,i,o=e.length%3,u="",c=-1,l=e.length-o;++c>18&63)+s.charAt(i>>12&63)+s.charAt(i>>6&63)+s.charAt(63&i);return 2==o?(t=e.charCodeAt(c)<<8,r=e.charCodeAt(++c),u+=s.charAt((i=t+r)>>10)+s.charAt(i>>4&63)+s.charAt(i<<2&63)+"="):1==o&&(i=e.charCodeAt(c),u+=s.charAt(i>>2)+s.charAt(i<<4&63)+"=="),u},decode:function(e){var t=(e=String(e).replace(u,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&a("Invalid character: the string to be decoded is not correctly encoded.");for(var r,n,i=0,o="",c=-1;++c>(-2*i&6)));return o},version:"1.0.0"};if(t&&!t.nodeType)if(n)n.exports=c;else for(var l in c)c.hasOwnProperty(l)&&(t[l]=c[l]);else e.base64=c}(r);var oi=ii.exports;const ai=B("tsdav:authHelper"),si=(e,t)=>(...r)=>e(Object.assign(Object.assign({},t),r[0])),ui=e=>(ai(`Basic auth token generated: ${oi.encode(`${e.username}:${e.password}`)}`),{authorization:`Basic ${oi.encode(`${e.username}:${e.password}`)}`}),ci=e=>t(void 0,void 0,void 0,(function*(){const t=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!bn(e,t))throw new Error(`Oauth credentials missing: ${wn(e,t)}`);const r=new URLSearchParams({grant_type:"authorization_code",code:e.authorizationCode,redirect_uri:e.redirectUrl,client_id:e.clientId,client_secret:e.clientSecret});ai(e.tokenUrl),ai(r.toString());const n=yield a.fetch(e.tokenUrl,{method:"POST",body:r.toString(),headers:{"content-length":`${r.toString().length}`,"content-type":"application/x-www-form-urlencoded"}});if(n.ok){return yield n.json()}return ai(`Fetch Oauth tokens failed: ${yield n.text()}`),{}})),li=e=>t(void 0,void 0,void 0,(function*(){const t=["refreshToken","clientId","clientSecret","tokenUrl"];if(!bn(e,t))throw new Error(`Oauth credentials missing: ${wn(e,t)}`);const r=new URLSearchParams({client_id:e.clientId,client_secret:e.clientSecret,refresh_token:e.refreshToken,grant_type:"refresh_token"}),n=yield a.fetch(e.tokenUrl,{method:"POST",body:r.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(n.ok){return yield n.json()}return ai(`Refresh access token failed: ${yield n.text()}`),{}})),di=e=>t(void 0,void 0,void 0,(function*(){var t;ai("Fetching oauth headers");let r={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(t=e.expiration)&&void 0!==t?t:0))&&(r=yield li(e)):r=yield ci(e),ai(`Oauth tokens fetched: ${r.access_token}`),{tokens:r,headers:{authorization:`Bearer ${r.access_token}`}}}));var hi=Object.freeze({__proto__:null,defaultParam:si,fetchOauthTokens:ci,getBasicAuthHeaders:ui,getOauthHeaders:di,refreshAccessToken:li});const fi=r=>t(void 0,void 0,void 0,(function*(){var n;const{serverUrl:i,credentials:o,authMethod:a,defaultAccountType:s,authFunction:u}=r;let c={};switch(a){case"Basic":c=ui(o);break;case"Oauth":c=(yield di(o)).headers;break;case"Digest":c={Authorization:`Digest ${o.digestString}`};break;case"Custom":c=null!==(n=yield null==u?void 0:u(o))&&void 0!==n?n:{};break;default:throw new Error("Invalid auth method")}const l=s?yield ei({account:{serverUrl:i,credentials:o,accountType:s},headers:c}):void 0,d=si(gn,{url:i,headers:c}),h=si(yn,{headers:c,url:i}),f=si(vn,{headers:c,url:i}),p=si(pn,{headers:c}),g=si(An,{headers:c}),y=si(Tn,{headers:c}),v=si(On,{headers:c}),m=si(_n,{headers:c}),b=si(Cn,{headers:c}),w=si(xn,{headers:c,account:l}),E=si(Bn,{headers:c}),A=si(Mn,{headers:c}),T=si(Vn,{headers:c}),_=si(Kn,{headers:c,account:l}),C=si($n,{headers:c}),O=si(Hn,{headers:c}),x=si(Yn,{headers:c}),D=si(zn,{headers:c}),R=si(qn,{account:l,headers:c}),S=si(Sn,{headers:c}),F=si(Fn,{headers:c});return{davRequest:r=>t(void 0,void 0,void 0,(function*(){const{init:t}=r,n=e(r,["init"]),{headers:i}=t,o=e(t,["headers"]);return fn(Object.assign(Object.assign({},n),{init:Object.assign(Object.assign({},o),{headers:Object.assign(Object.assign({},c),i)})}))})),propfind:p,createAccount:e=>t(void 0,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:n,loadObjects:a}=e;return ei({account:Object.assign({serverUrl:i,credentials:o},t),headers:Object.assign(Object.assign({},c),r),loadCollections:n,loadObjects:a})})),createObject:d,updateObject:h,deleteObject:f,calendarQuery:E,addressBookQuery:S,collectionQuery:g,makeCollection:y,calendarMultiGet:A,makeCalendar:T,syncCollection:v,supportedReportSet:m,isCollectionDirty:b,smartCollectionSync:w,fetchCalendars:_,fetchCalendarObjects:C,createCalendarObject:O,updateCalendarObject:x,deleteCalendarObject:D,syncCalendars:R,fetchAddressBooks:si(Nn,{account:l,headers:c}),addressBookMultiGet:F,fetchVCards:si(jn,{headers:c}),createVCard:si(Ln,{headers:c}),updateVCard:si(kn,{headers:c}),deleteVCard:si(In,{headers:c})}}));class pi{constructor(e){var t,r;this.serverUrl=e.serverUrl,this.credentials=e.credentials,this.authMethod=null!==(t=e.authMethod)&&void 0!==t?t:"Basic",this.accountType=null!==(r=e.defaultAccountType)&&void 0!==r?r:"caldav",this.authFunction=e.authFunction}login(){return t(this,void 0,void 0,(function*(){var e;switch(this.authMethod){case"Basic":this.authHeaders=ui(this.credentials);break;case"Oauth":this.authHeaders=(yield di(this.credentials)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=yield null===(e=this.authFunction)||void 0===e?void 0:e.call(this,this.credentials);break;default:throw new Error("Invalid auth method")}this.account=this.accountType?yield ei({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders}):void 0}))}davRequest(r){return t(this,void 0,void 0,(function*(){const{init:t}=r,n=e(r,["init"]),{headers:i}=t,o=e(t,["headers"]);return fn(Object.assign(Object.assign({},n),{init:Object.assign(Object.assign({},o),{headers:Object.assign(Object.assign({},this.authHeaders),i)})}))}))}createObject(...e){return t(this,void 0,void 0,(function*(){return si(gn,{url:this.serverUrl,headers:this.authHeaders})(e[0])}))}updateObject(...e){return t(this,void 0,void 0,(function*(){return si(yn,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}deleteObject(...e){return t(this,void 0,void 0,(function*(){return si(vn,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}propfind(...e){return t(this,void 0,void 0,(function*(){return si(pn,{headers:this.authHeaders})(e[0])}))}createAccount(e){return t(this,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:n,loadObjects:i}=e;return ei({account:Object.assign({serverUrl:this.serverUrl,credentials:this.credentials},t),headers:Object.assign(Object.assign({},this.authHeaders),r),loadCollections:n,loadObjects:i})}))}collectionQuery(...e){return t(this,void 0,void 0,(function*(){return si(An,{headers:this.authHeaders})(e[0])}))}makeCollection(...e){return t(this,void 0,void 0,(function*(){return si(Tn,{headers:this.authHeaders})(e[0])}))}syncCollection(...e){return t(this,void 0,void 0,(function*(){return si(On,{headers:this.authHeaders})(e[0])}))}supportedReportSet(...e){return t(this,void 0,void 0,(function*(){return si(_n,{headers:this.authHeaders})(e[0])}))}isCollectionDirty(...e){return t(this,void 0,void 0,(function*(){return si(Cn,{headers:this.authHeaders})(e[0])}))}smartCollectionSync(...e){return t(this,void 0,void 0,(function*(){return si(xn,{headers:this.authHeaders,account:this.account})(e[0])}))}calendarQuery(...e){return t(this,void 0,void 0,(function*(){return si(Bn,{headers:this.authHeaders})(e[0])}))}makeCalendar(...e){return t(this,void 0,void 0,(function*(){return si(Vn,{headers:this.authHeaders})(e[0])}))}calendarMultiGet(...e){return t(this,void 0,void 0,(function*(){return si(Mn,{headers:this.authHeaders})(e[0])}))}fetchCalendars(...e){return t(this,void 0,void 0,(function*(){return si(Kn,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchCalendarObjects(...e){return t(this,void 0,void 0,(function*(){return si($n,{headers:this.authHeaders})(e[0])}))}createCalendarObject(...e){return t(this,void 0,void 0,(function*(){return si(Hn,{headers:this.authHeaders})(e[0])}))}updateCalendarObject(...e){return t(this,void 0,void 0,(function*(){return si(Yn,{headers:this.authHeaders})(e[0])}))}deleteCalendarObject(...e){return t(this,void 0,void 0,(function*(){return si(zn,{headers:this.authHeaders})(e[0])}))}syncCalendars(...e){return t(this,void 0,void 0,(function*(){return si(qn,{headers:this.authHeaders,account:this.account})(e[0])}))}addressBookQuery(...e){return t(this,void 0,void 0,(function*(){return si(Sn,{headers:this.authHeaders})(e[0])}))}addressBookMultiGet(...e){return t(this,void 0,void 0,(function*(){return si(Fn,{headers:this.authHeaders})(e[0])}))}fetchAddressBooks(...e){return t(this,void 0,void 0,(function*(){return si(Nn,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchVCards(...e){return t(this,void 0,void 0,(function*(){return si(jn,{headers:this.authHeaders})(e[0])}))}createVCard(...e){return t(this,void 0,void 0,(function*(){return si(Ln,{headers:this.authHeaders})(e[0])}))}updateVCard(...e){return t(this,void 0,void 0,(function*(){return si(kn,{headers:this.authHeaders})(e[0])}))}deleteVCard(...e){return t(this,void 0,void 0,(function*(){return si(In,{headers:this.authHeaders})(e[0])}))}}var gi=Object.freeze({__proto__:null,DAVClient:pi,createDAVClient:fi}),yi=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({DAVNamespace:U,DAVNamespaceShort:V,DAVAttributeMap:M},gi),mn),Dn),ni),Pn),Wn),hi),dn);export{M as DAVAttributeMap,pi as DAVClient,U as DAVNamespace,V as DAVNamespaceShort,Sn as addressBookQuery,Mn as calendarMultiGet,Bn as calendarQuery,un as cleanupFalsy,An as collectionQuery,ei as createAccount,Hn as createCalendarObject,fi as createDAVClient,gn as createObject,Ln as createVCard,fn as davRequest,yi as default,zn as deleteCalendarObject,vn as deleteObject,In as deleteVCard,Nn as fetchAddressBooks,$n as fetchCalendarObjects,Kn as fetchCalendars,ci as fetchOauthTokens,jn as fetchVCards,Gn as freeBusyQuery,ui as getBasicAuthHeaders,sn as getDAVAttribute,di as getOauthHeaders,Cn as isCollectionDirty,Vn as makeCalendar,pn as propfind,li as refreshAccessToken,xn as smartCollectionSync,_n as supportedReportSet,qn as syncCalendars,On as syncCollection,Yn as updateCalendarObject,yn as updateObject,kn as updateVCard,an as urlContains,on as urlEquals}; diff --git a/dist/tsdav.min.mjs b/dist/tsdav.min.mjs index 51340af..b13897a 100644 --- a/dist/tsdav.min.mjs +++ b/dist/tsdav.min.mjs @@ -1 +1 @@ -import{fetch as e}from"cross-fetch";import t from"debug";import r from"xml-js";import{encode as o}from"base-64";function a(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(o=Object.getOwnPropertySymbols(e);a{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},u=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim();if(Math.abs(r.length-o.length)>1)return!1;const a="/"===r.slice(-1)?r.slice(0,-1):r,n="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(n)||t.includes(a)},h=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim(),a="/"===r.slice(-1)?r.slice(0,-1):r,n="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(n)||t.includes(a)},p=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[s[t]]:t})),{}),v=e=>Object.entries(e).reduce(((e,[t,r])=>r?Object.assign(Object.assign({},e),{[t]:r}):e),{}),f=(e,t)=>t?{[e]:t}:{},g=(e,t)=>e?t&&0!==t.length?Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e)))):e:{};var m=Object.freeze({__proto__:null,cleanupFalsy:v,conditionalParam:f,excludeHeaders:g,getDAVAttribute:p,urlContains:h,urlEquals:u});const b=t("tsdav:request"),y=t=>n(void 0,void 0,void 0,(function*(){var o;const{url:a,init:n,convertIncoming:d=!0,parseOutgoing:s=!0}=t,{headers:i={},body:c,namespace:u,method:h,attributes:p}=n,f=d?r.js2xml(Object.assign(Object.assign({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},c),{_attributes:p}),{compact:!0,spaces:2,elementNameFn:e=>u&&!/^.+:.+/.test(e)?`${u}:${e}`:e}):c,g=yield e(a,{headers:Object.assign({"Content-Type":"text/xml;charset=UTF-8"},v(i)),body:f,method:h}),m=yield g.text();if(!g.ok||!(null===(o=g.headers.get("content-type"))||void 0===o?void 0:o.includes("xml"))||!s)return[{href:g.url,ok:g.ok,status:g.status,statusText:g.statusText,raw:m}];const y=r.xml2js(m,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,o=Object.keys(r),a=o[o.length-1],n=r[a];if(n.length>0){n[n.length-1]=l(e)}else r[a]=l(e)}catch(e){b(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,(e=>e[1].toUpperCase())),attributesFn:e=>{const t=Object.assign({},e);return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(y.multistatus.response)?y.multistatus.response:[y.multistatus.response]).map((e=>{var t,r;if(!e)return{status:g.status,statusText:g.statusText,ok:g.ok};const o=/^\S+\s(?\d+)\s(?.+)$/.exec(e.status);return{raw:y,href:e.href,status:(null==o?void 0:o.groups)?Number.parseInt(null==o?void 0:o.groups.status,10):g.status,statusText:null!==(r=null===(t=null==o?void 0:o.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:g.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce(((e,t)=>Object.assign(Object.assign({},e),null==t?void 0:t.prop)),{})}}))})),A=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:n}=e;return y({url:t,init:{method:"PROPFIND",headers:g(v(Object.assign({depth:o},a)),n),namespace:i.DAV,body:{propfind:{_attributes:p([d.CALDAV,d.CALDAV_APPLE,d.CALENDAR_SERVER,d.CARDDAV,d.DAV]),prop:r}}}})})),O=t=>n(void 0,void 0,void 0,(function*(){const{url:r,data:o,headers:a,headersToExclude:n}=t;return e(r,{method:"PUT",body:o,headers:g(a,n)})})),j=t=>n(void 0,void 0,void 0,(function*(){const{url:r,data:o,etag:a,headers:n,headersToExclude:d}=t;return e(r,{method:"PUT",body:o,headers:g(v(Object.assign({"If-Match":a},n)),d)})})),D=t=>n(void 0,void 0,void 0,(function*(){const{url:r,headers:o,etag:a,headersToExclude:n}=t;return e(r,{method:"DELETE",headers:g(v(Object.assign({"If-Match":a},o)),n)})}));var C=Object.freeze({__proto__:null,createObject:O,davRequest:y,deleteObject:D,propfind:A,updateObject:j});function V(e,t){const r=e=>t.every((t=>e[t]));return Array.isArray(e)?e.every((e=>r(e))):r(e)}const E=(e,t)=>t.reduce(((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`),""),T=t("tsdav:collection"),$=e=>n(void 0,void 0,void 0,(function*(){const{url:t,body:r,depth:o,defaultNamespace:a=i.DAV,headers:n,headersToExclude:d}=e,s=yield y({url:t,init:{method:"REPORT",headers:g(v(Object.assign({depth:o},n)),d),namespace:a,body:r}});return 1!==s.length||s[0].raw?s:[]})),w=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:n}=e;return y({url:t,init:{method:"MKCOL",headers:g(v(Object.assign({depth:o},a)),n),namespace:i.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0}})})),k=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,n;const{collection:d,headers:s,headersToExclude:c}=e;return null!==(n=null===(a=null===(o=null===(r=null===(t=(yield A({url:d.url,props:{[`${i.DAV}:supported-report-set`]:{}},depth:"0",headers:g(s,c)}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===o?void 0:o.supportedReport)||void 0===a?void 0:a.map((e=>Object.keys(e.report)[0])))&&void 0!==n?n:[]})),_=e=>n(void 0,void 0,void 0,(function*(){var t,r,o;const{collection:a,headers:n,headersToExclude:d}=e,s=(yield A({url:a.url,props:{[`${i.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:g(n,d)})).filter((e=>h(a.url,e.href)))[0];if(!s)throw new Error("Collection does not exist on server");return{isDirty:a.ctag!==(null===(t=s.props)||void 0===t?void 0:t.getctag),newCtag:null===(o=null===(r=s.props)||void 0===r?void 0:r.getctag)||void 0===o?void 0:o.toString()}})),R=e=>{const{url:t,props:r,headers:o,syncLevel:a,syncToken:n,headersToExclude:s}=e;return y({url:t,init:{method:"REPORT",namespace:i.DAV,headers:g(Object.assign({},o),s),body:{"sync-collection":{_attributes:p([d.CALDAV,d.CARDDAV,d.DAV]),"sync-level":a,"sync-token":n,[`${i.DAV}:prop`]:r}}}})},U=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,n,d,s,c,l,u,p;const{collection:v,method:f,headers:m,headersToExclude:b,account:y,detailedResult:A}=e,O=["accountType","homeUrl"];if(!y||!V(y,O)){if(!y)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${E(y,O)} before smartCollectionSync`)}const j=null!=f?f:(null===(t=v.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(T(`smart collection sync with type ${y.accountType} and method ${j}`),"webdav"===j){const e=yield R({url:v.url,props:{[`${i.DAV}:getetag`]:{},[`${"caldav"===y.accountType?i.CALDAV:i.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{},[`${i.DAV}:displayname`]:{}},syncLevel:1,syncToken:v.syncToken,headers:g(m,b)}),t=e.filter((e=>{var t;const r="caldav"===y.accountType?".ics":".vcf";return(null===(t=e.href)||void 0===t?void 0:t.slice(-4))===r})),l=t.filter((e=>404!==e.status)).map((e=>e.href)),u=t.filter((e=>404===e.status)).map((e=>e.href)),p=(l.length&&null!==(o=yield null===(r=null==v?void 0:v.objectMultiGet)||void 0===r?void 0:r.call(v,{url:v.url,props:{[`${i.DAV}:getetag`]:{},[`${"caldav"===y.accountType?i.CALDAV:i.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:l,depth:"1",headers:g(m,b)}))&&void 0!==o?o:[]).map((e=>{var t,r,o,a,n,d,s,i,c,l;return{url:null!==(t=e.href)&&void 0!==t?t:"",etag:null===(r=e.props)||void 0===r?void 0:r.getetag,data:"caldav"===(null==y?void 0:y.accountType)?null!==(n=null===(a=null===(o=e.props)||void 0===o?void 0:o.calendarData)||void 0===a?void 0:a._cdata)&&void 0!==n?n:null===(d=e.props)||void 0===d?void 0:d.calendarData:null!==(c=null===(i=null===(s=e.props)||void 0===s?void 0:s.addressData)||void 0===i?void 0:i._cdata)&&void 0!==c?c:null===(l=e.props)||void 0===l?void 0:l.addressData}})),f=null!==(a=v.objects)&&void 0!==a?a:[],O=p.filter((e=>f.every((t=>!h(t.url,e.url))))),j=f.reduce(((e,t)=>{const r=p.find((e=>h(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),D=u.map((e=>({url:e,etag:""}))),C=f.filter((e=>p.some((t=>h(e.url,t.url)&&t.etag===e.etag))));return Object.assign(Object.assign({},v),{objects:A?{created:O,updated:j,deleted:D}:[...C,...O,...j],syncToken:null!==(c=null===(s=null===(d=null===(n=e[0])||void 0===n?void 0:n.raw)||void 0===d?void 0:d.multistatus)||void 0===s?void 0:s.syncToken)&&void 0!==c?c:v.syncToken})}if("basic"===j){const{isDirty:e,newCtag:t}=yield _({collection:v,headers:g(m,b)}),r=null!==(l=v.objects)&&void 0!==l?l:[],o=null!==(p=yield null===(u=v.fetchObjects)||void 0===u?void 0:u.call(v,{collection:v,headers:g(m,b)}))&&void 0!==p?p:[],a=o.filter((e=>r.every((t=>!h(t.url,e.url))))),n=r.reduce(((e,t)=>{const r=o.find((e=>h(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),d=r.filter((e=>o.every((t=>!h(t.url,e.url))))),s=r.filter((e=>o.some((t=>h(e.url,t.url)&&t.etag===e.etag))));if(e)return Object.assign(Object.assign({},v),{objects:A?{created:a,updated:n,deleted:d}:[...s,...a,...n],ctag:t})}return A?Object.assign(Object.assign({},v),{objects:{created:[],updated:[],deleted:[]}}):v}));var S=Object.freeze({__proto__:null,collectionQuery:$,isCollectionDirty:_,makeCollection:w,smartCollectionSync:U,supportedReportSet:k,syncCollection:R});const x=t("tsdav:addressBook"),L=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,depth:a,headers:n,headersToExclude:s}=e;return $({url:t,body:{"addressbook-query":{_attributes:p([d.CARDDAV,d.DAV]),[`${i.DAV}:prop`]:r,filter:null!=o?o:{"prop-filter":{_attributes:{name:"FN"}}}}},defaultNamespace:i.CARDDAV,depth:a,headers:g(n,s)})})),N=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,depth:a,headers:n}=e;return $({url:t,body:{"addressbook-multiget":{_attributes:p([d.DAV,d.CARDDAV]),[`${i.DAV}:prop`]:r,[`${i.DAV}:href`]:o}},defaultNamespace:i.CARDDAV,depth:a,headers:n})})),P=e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:r,props:o,headersToExclude:a}=null!=e?e:{},d=["homeUrl","rootUrl"];if(!t||!V(t,d)){if(!t)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${E(t,d)} before fetchAddressBooks`)}const s=yield A({url:t.homeUrl,props:null!=o?o:{[`${i.DAV}:displayname`]:{},[`${i.CALENDAR_SERVER}:getctag`]:{},[`${i.DAV}:resourcetype`]:{},[`${i.DAV}:sync-token`]:{}},depth:"1",headers:g(r,a)});return Promise.all(s.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("addressbook")})).map((e=>{var r,o,a,n,d,s,i,c,l;const u=null!==(a=null===(o=null===(r=e.props)||void 0===r?void 0:r.displayname)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(n=e.props)||void 0===n?void 0:n.displayname;return x(`Found address book named ${"string"==typeof u?u:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(d=e.href)&&void 0!==d?d:"",null!==(s=t.rootUrl)&&void 0!==s?s:"").href,ctag:null===(i=e.props)||void 0===i?void 0:i.getctag,displayName:"string"==typeof u?u:"",resourcetype:Object.keys(null===(c=e.props)||void 0===c?void 0:c.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}})).map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:r})})})))))})),H=e=>n(void 0,void 0,void 0,(function*(){const{addressBook:t,headers:r,objectUrls:o,headersToExclude:a,urlFilter:n=(e=>e),useMultiGet:d=!0}=e;x(`Fetching vcards from ${null==t?void 0:t.url}`);const s=["url"];if(!t||!V(t,s)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${E(t,s)} before fetchVCards`)}const c=(null!=o?o:(yield L({url:t.url,props:{[`${i.DAV}:getetag`]:{}},depth:"1",headers:g(r,a)})).map((e=>{var t;return e.ok&&null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(n).map((e=>new URL(e).pathname));let l=[];return c.length>0&&(l=d?yield N({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CARDDAV}:address-data`]:{}},objectUrls:c,depth:"1",headers:g(r,a)}):yield L({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CARDDAV}:address-data`]:{}},depth:"1",headers:g(r,a)})),l.map((e=>{var r,o,a,n,d,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(o=e.props)||void 0===o?void 0:o.getetag,data:null!==(d=null===(n=null===(a=e.props)||void 0===a?void 0:a.addressData)||void 0===n?void 0:n._cdata)&&void 0!==d?d:null===(s=e.props)||void 0===s?void 0:s.addressData}}))})),B=e=>n(void 0,void 0,void 0,(function*(){const{addressBook:t,vCardString:r,filename:o,headers:a,headersToExclude:n}=e;return O({url:new URL(o,t.url).href,data:r,headers:g(Object.assign({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*"},a),n)})})),I=e=>n(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return j({url:t.url,data:t.data,etag:t.etag,headers:g(Object.assign({"content-type":"text/vcard; charset=utf-8"},r),o)})})),M=e=>n(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return D({url:t.url,etag:t.etag,headers:g(r,o)})}));var F=Object.freeze({__proto__:null,addressBookMultiGet:N,addressBookQuery:L,createVCard:B,deleteVCard:M,fetchAddressBooks:P,fetchVCards:H,updateVCard:I});const z=t("tsdav:calendar"),Z=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,timezone:a,depth:n,headers:s,headersToExclude:c}=e;return $({url:t,body:{"calendar-query":v({_attributes:p([d.CALDAV,d.CALENDAR_SERVER,d.CALDAV_APPLE,d.DAV]),[`${i.DAV}:prop`]:r,filter:o,timezone:a})},defaultNamespace:i.CALDAV,depth:n,headers:g(s,c)})})),G=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,filters:a,timezone:n,depth:s,headers:c,headersToExclude:l}=e;return $({url:t,body:{"calendar-multiget":Object.assign(Object.assign({_attributes:p([d.DAV,d.CALDAV]),[`${i.DAV}:prop`]:r,[`${i.DAV}:href`]:o},f("filter",a)),{timezone:n})},defaultNamespace:i.CALDAV,depth:s,headers:g(c,l)})})),Q=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:n}=e;return y({url:t,init:{method:"MKCALENDAR",headers:g(v(Object.assign({depth:o},a)),n),namespace:i.DAV,body:{[`${i.CALDAV}:mkcalendar`]:{_attributes:p([d.DAV,d.CALDAV,d.CALDAV_APPLE]),set:{prop:r}}}}})})),q=e=>n(void 0,void 0,void 0,(function*(){const{headers:t,account:r,props:o,projectedProps:a,headersToExclude:d}=null!=e?e:{},s=["homeUrl","rootUrl"];if(!r||!V(r,s)){if(!r)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${E(r,s)} before fetchCalendars`)}const l=yield A({url:r.homeUrl,props:null!=o?o:{[`${i.CALDAV}:calendar-description`]:{},[`${i.CALDAV}:calendar-timezone`]:{},[`${i.DAV}:displayname`]:{},[`${i.CALDAV_APPLE}:calendar-color`]:{},[`${i.CALENDAR_SERVER}:getctag`]:{},[`${i.DAV}:resourcetype`]:{},[`${i.CALDAV}:supported-calendar-component-set`]:{},[`${i.DAV}:sync-token`]:{}},depth:"1",headers:g(t,d)});return Promise.all(l.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("calendar")})).filter((e=>{var t,r,o,a;return(Array.isArray(null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet.comp)?null===(r=e.props)||void 0===r?void 0:r.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(a=null===(o=e.props)||void 0===o?void 0:o.supportedCalendarComponentSet.comp)||void 0===a?void 0:a._attributes.name]||[]).some((e=>Object.values(c).includes(e)))})).map((e=>{var t,o,n,d,s,i,c,l,u,h,p,v,g,m,b,y;const A=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,O=null===(o=e.props)||void 0===o?void 0:o.calendarTimezone;return Object.assign({description:"string"==typeof A?A:"",timezone:"string"==typeof O?O:"",url:new URL(null!==(n=e.href)&&void 0!==n?n:"",null!==(d=r.rootUrl)&&void 0!==d?d:"").href,ctag:null===(s=e.props)||void 0===s?void 0:s.getctag,calendarColor:null===(i=e.props)||void 0===i?void 0:i.calendarColor,displayName:null!==(l=null===(c=e.props)||void 0===c?void 0:c.displayname._cdata)&&void 0!==l?l:null===(u=e.props)||void 0===u?void 0:u.displayname,components:Array.isArray(null===(h=e.props)||void 0===h?void 0:h.supportedCalendarComponentSet.comp)?null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(g=null===(v=e.props)||void 0===v?void 0:v.supportedCalendarComponentSet.comp)||void 0===g?void 0:g._attributes.name],resourcetype:Object.keys(null===(m=e.props)||void 0===m?void 0:m.resourcetype),syncToken:null===(b=e.props)||void 0===b?void 0:b.syncToken},f("projectedProps",Object.fromEntries(Object.entries(null!==(y=e.props)&&void 0!==y?y:{}).filter((([e])=>null==a?void 0:a[e])))))})).map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:g(t,d)})})})))))})),J=e=>n(void 0,void 0,void 0,(function*(){const{calendar:t,objectUrls:r,filters:o,timeRange:a,headers:n,expand:d,urlFilter:s=(e=>Boolean(null==e?void 0:e.includes(".ics"))),useMultiGet:c=!0,headersToExclude:l}=e;if(a){const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(a.start)&&e.test(a.end)||t.test(a.start)&&t.test(a.end)))throw new Error("invalid timeRange format, not in ISO8601")}z(`Fetching calendar objects from ${null==t?void 0:t.url}`);const u=["url"];if(!t||!V(t,u)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${E(t,u)} before fetchCalendarObjects`)}const h=null!=o?o:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":Object.assign({_attributes:{name:"VEVENT"}},a?{"time-range":{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})}}],p=(null!=r?r:(yield Z({url:t.url,props:{[`${i.DAV}:getetag`]:Object.assign({},d&&a?{[`${i.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:h,depth:"1",headers:g(n,l)})).map((e=>{var t;return null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(s).map((e=>new URL(e).pathname));let v=[];return p.length>0&&(v=!c||d?yield Z({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CALDAV}:calendar-data`]:Object.assign({},d&&a?{[`${i.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:h,depth:"1",headers:g(n,l)}):yield G({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CALDAV}:calendar-data`]:Object.assign({},d&&a?{[`${i.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},objectUrls:p,depth:"1",headers:g(n,l)})),v.map((e=>{var r,o,a,n,d,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(o=e.props)||void 0===o?void 0:o.getetag}`,data:null!==(d=null===(n=null===(a=e.props)||void 0===a?void 0:a.calendarData)||void 0===n?void 0:n._cdata)&&void 0!==d?d:null===(s=e.props)||void 0===s?void 0:s.calendarData}}))})),K=e=>n(void 0,void 0,void 0,(function*(){const{calendar:t,iCalString:r,filename:o,headers:a,headersToExclude:n}=e;return O({url:new URL(o,t.url).href,data:r,headers:g(Object.assign({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*"},a),n)})})),W=e=>n(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return j({url:t.url,data:t.data,etag:t.etag,headers:g(Object.assign({"content-type":"text/calendar; charset=utf-8"},r),o)})})),Y=e=>n(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return D({url:t.url,etag:t.etag,headers:g(r,o)})})),X=e=>n(void 0,void 0,void 0,(function*(){var t;const{oldCalendars:r,account:o,detailedResult:a,headers:d,headersToExclude:s}=e;if(!o)throw new Error("Must have account before syncCalendars");const i=null!==(t=null!=r?r:o.calendars)&&void 0!==t?t:[],c=yield q({account:o,headers:g(d,s)}),l=c.filter((e=>i.every((t=>!h(t.url,e.url)))));z(`new calendars: ${l.map((e=>e.displayName))}`);const u=i.reduce(((e,t)=>{const r=c.find((e=>h(e.url,t.url)));return r&&(r.syncToken&&r.syncToken!==t.syncToken||r.ctag&&r.ctag!==t.ctag)?[...e,r]:e}),[]);z(`updated calendars: ${u.map((e=>e.displayName))}`);const p=yield Promise.all(u.map((e=>n(void 0,void 0,void 0,(function*(){return yield U({collection:Object.assign(Object.assign({},e),{objectMultiGet:G}),method:"webdav",headers:g(d,s),account:o})}))))),v=i.filter((e=>c.every((t=>!h(t.url,e.url)))));z(`deleted calendars: ${v.map((e=>e.displayName))}`);const f=i.filter((e=>c.some((t=>h(t.url,e.url)&&(t.syncToken&&t.syncToken!==e.syncToken||t.ctag&&t.ctag!==e.ctag)))));return a?{created:l,updated:u,deleted:v}:[...f,...l,...p]})),ee=e=>n(void 0,void 0,void 0,(function*(){const{url:t,timeRange:r,depth:o,headers:a,headersToExclude:n}=e;if(!r)throw new Error("timeRange is required");{const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(r.start)&&e.test(r.end)||t.test(r.start)&&t.test(r.end)))throw new Error("invalid timeRange format, not in ISO8601")}return(yield $({url:t,body:{"free-busy-query":v({_attributes:p([d.CALDAV]),[`${i.CALDAV}:time-range`]:{_attributes:{start:`${new Date(r.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(r.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}})},defaultNamespace:i.CALDAV,depth:o,headers:g(a,n)}))[0]}));var te=Object.freeze({__proto__:null,calendarMultiGet:G,calendarQuery:Z,createCalendarObject:K,deleteCalendarObject:Y,fetchCalendarObjects:J,fetchCalendars:q,freeBusyQuery:ee,makeCalendar:Q,syncCalendars:X,updateCalendarObject:W});const re=t("tsdav:account"),oe=t=>n(void 0,void 0,void 0,(function*(){var r,o;re("Service discovery...");const{account:a,headers:n,headersToExclude:d}=t,s=new URL(a.serverUrl),i=new URL(`/.well-known/${a.accountType}`,s);i.protocol=null!==(r=s.protocol)&&void 0!==r?r:"http";try{const t=yield e(i.href,{headers:g(n,d),method:"PROPFIND",redirect:"manual"});if(t.status>=300&&t.status<400){const e=t.headers.get("Location");if("string"==typeof e&&e.length){re(`Service discovery redirected to ${e}`);const t=new URL(e,s);return t.hostname===i.hostname&&i.port&&!t.port&&(t.port=i.port),t.protocol=null!==(o=s.protocol)&&void 0!==o?o:"http",t.href}}}catch(e){re(`Service discovery failed: ${e.stack}`)}return s.href})),ae=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,n;const{account:d,headers:s,headersToExclude:c}=e,l=["rootUrl"];if(!V(d,l))throw new Error(`account must have ${E(d,l)} before fetchPrincipalUrl`);re(`Fetching principal url from path ${d.rootUrl}`);const[u]=yield A({url:d.rootUrl,props:{[`${i.DAV}:current-user-principal`]:{}},depth:"0",headers:g(s,c)});if(!u.ok&&(re(`Fetch principal url failed: ${u.statusText}`),401===u.status))throw new Error("Invalid credentials");return re(`Fetched principal url ${null===(r=null===(t=u.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(n=null===(a=null===(o=u.props)||void 0===o?void 0:o.currentUserPrincipal)||void 0===a?void 0:a.href)&&void 0!==n?n:"",d.rootUrl).href})),ne=e=>n(void 0,void 0,void 0,(function*(){var t,r;const{account:o,headers:a,headersToExclude:n}=e,d=["principalUrl","rootUrl"];if(!V(o,d))throw new Error(`account must have ${E(o,d)} before fetchHomeUrl`);re(`Fetch home url from ${o.principalUrl}`);const s=(yield A({url:o.principalUrl,props:"caldav"===o.accountType?{[`${i.CALDAV}:calendar-home-set`]:{}}:{[`${i.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:g(a,n)})).find((e=>h(o.principalUrl,e.href)));if(!s||!s.ok)throw new Error("cannot find homeUrl");const c=new URL("caldav"===o.accountType?null===(t=null==s?void 0:s.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==s?void 0:s.props)||void 0===r?void 0:r.addressbookHomeSet.href,o.rootUrl).href;return re(`Fetched home url ${c}`),c})),de=e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o=!1,loadObjects:a=!1,headersToExclude:d}=e,s=Object.assign({},t);return s.rootUrl=yield oe({account:t,headers:g(r,d)}),s.principalUrl=yield ae({account:s,headers:g(r,d)}),s.homeUrl=yield ne({account:s,headers:g(r,d)}),(o||a)&&("caldav"===t.accountType?s.calendars=yield q({headers:g(r,d),account:s}):"carddav"===t.accountType&&(s.addressBooks=yield P({headers:g(r,d),account:s}))),a&&("caldav"===t.accountType&&s.calendars?s.calendars=yield Promise.all(s.calendars.map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield J({calendar:e,headers:g(r,d)})})}))))):"carddav"===t.accountType&&s.addressBooks&&(s.addressBooks=yield Promise.all(s.addressBooks.map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield H({addressBook:e,headers:g(r,d)})})}))))))),s}));var se=Object.freeze({__proto__:null,createAccount:de,fetchHomeUrl:ne,fetchPrincipalUrl:ae,serviceDiscovery:oe});const ie=t("tsdav:authHelper"),ce=(e,t)=>(...r)=>e(Object.assign(Object.assign({},t),r[0])),le=e=>(ie(`Basic auth token generated: ${o(`${e.username}:${e.password}`)}`),{authorization:`Basic ${o(`${e.username}:${e.password}`)}`}),ue=t=>n(void 0,void 0,void 0,(function*(){const r=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!V(t,r))throw new Error(`Oauth credentials missing: ${E(t,r)}`);const o=new URLSearchParams({grant_type:"authorization_code",code:t.authorizationCode,redirect_uri:t.redirectUrl,client_id:t.clientId,client_secret:t.clientSecret});ie(t.tokenUrl),ie(o.toString());const a=yield e(t.tokenUrl,{method:"POST",body:o.toString(),headers:{"content-length":`${o.toString().length}`,"content-type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Fetch Oauth tokens failed: ${yield a.text()}`),{}})),he=t=>n(void 0,void 0,void 0,(function*(){const r=["refreshToken","clientId","clientSecret","tokenUrl"];if(!V(t,r))throw new Error(`Oauth credentials missing: ${E(t,r)}`);const o=new URLSearchParams({client_id:t.clientId,client_secret:t.clientSecret,refresh_token:t.refreshToken,grant_type:"refresh_token"}),a=yield e(t.tokenUrl,{method:"POST",body:o.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Refresh access token failed: ${yield a.text()}`),{}})),pe=e=>n(void 0,void 0,void 0,(function*(){var t;ie("Fetching oauth headers");let r={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(t=e.expiration)&&void 0!==t?t:0))&&(r=yield he(e)):r=yield ue(e),ie(`Oauth tokens fetched: ${r.access_token}`),{tokens:r,headers:{authorization:`Bearer ${r.access_token}`}}}));var ve=Object.freeze({__proto__:null,defaultParam:ce,fetchOauthTokens:ue,getBasicAuthHeaders:le,getOauthHeaders:pe,refreshAccessToken:he});const fe=e=>n(void 0,void 0,void 0,(function*(){var t;const{serverUrl:r,credentials:o,authMethod:d,defaultAccountType:s,authFunction:i}=e;let c={};switch(d){case"Basic":c=le(o);break;case"Oauth":c=(yield pe(o)).headers;break;case"Digest":c={Authorization:`Digest ${o.digestString}`};break;case"Custom":c=null!==(t=yield null==i?void 0:i(o))&&void 0!==t?t:{};break;default:throw new Error("Invalid auth method")}const l=s?yield de({account:{serverUrl:r,credentials:o,accountType:s},headers:c}):void 0,u=ce(O,{url:r,headers:c}),h=ce(j,{headers:c,url:r}),p=ce(D,{headers:c,url:r}),v=ce(A,{headers:c}),f=ce($,{headers:c}),g=ce(w,{headers:c}),m=ce(R,{headers:c}),b=ce(k,{headers:c}),C=ce(_,{headers:c}),V=ce(U,{headers:c,account:l}),E=ce(Z,{headers:c}),T=ce(G,{headers:c}),S=ce(Q,{headers:c}),x=ce(q,{headers:c,account:l}),F=ce(J,{headers:c}),z=ce(K,{headers:c}),ee=ce(W,{headers:c}),te=ce(Y,{headers:c}),re=ce(X,{account:l,headers:c}),oe=ce(L,{headers:c}),ae=ce(N,{headers:c});return{davRequest:e=>n(void 0,void 0,void 0,(function*(){const{init:t}=e,r=a(e,["init"]),{headers:o}=t,n=a(t,["headers"]);return y(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},c),o)})}))})),propfind:v,createAccount:e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:a,loadCollections:n,loadObjects:d}=e;return de({account:Object.assign({serverUrl:r,credentials:o},t),headers:Object.assign(Object.assign({},c),a),loadCollections:n,loadObjects:d})})),createObject:u,updateObject:h,deleteObject:p,calendarQuery:E,addressBookQuery:oe,collectionQuery:f,makeCollection:g,calendarMultiGet:T,makeCalendar:S,syncCollection:m,supportedReportSet:b,isCollectionDirty:C,smartCollectionSync:V,fetchCalendars:x,fetchCalendarObjects:F,createCalendarObject:z,updateCalendarObject:ee,deleteCalendarObject:te,syncCalendars:re,fetchAddressBooks:ce(P,{account:l,headers:c}),addressBookMultiGet:ae,fetchVCards:ce(H,{headers:c}),createVCard:ce(B,{headers:c}),updateVCard:ce(I,{headers:c}),deleteVCard:ce(M,{headers:c})}}));class ge{constructor(e){var t,r;this.serverUrl=e.serverUrl,this.credentials=e.credentials,this.authMethod=null!==(t=e.authMethod)&&void 0!==t?t:"Basic",this.accountType=null!==(r=e.defaultAccountType)&&void 0!==r?r:"caldav"}login(){var e;return n(this,void 0,void 0,(function*(){switch(this.authMethod){case"Basic":this.authHeaders=le(this.credentials);break;case"Oauth":this.authHeaders=(yield pe(this.credentials)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=yield null===(e=this.authFunction)||void 0===e?void 0:e.call(this,this.credentials);break;default:throw new Error("Invalid auth method")}this.account=this.accountType?yield de({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders}):void 0}))}davRequest(e){return n(this,void 0,void 0,(function*(){const{init:t}=e,r=a(e,["init"]),{headers:o}=t,n=a(t,["headers"]);return y(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},this.authHeaders),o)})}))}))}createObject(...e){return n(this,void 0,void 0,(function*(){return ce(O,{url:this.serverUrl,headers:this.authHeaders})(e[0])}))}updateObject(...e){return n(this,void 0,void 0,(function*(){return ce(j,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}deleteObject(...e){return n(this,void 0,void 0,(function*(){return ce(D,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}propfind(...e){return n(this,void 0,void 0,(function*(){return ce(A,{headers:this.authHeaders})(e[0])}))}createAccount(e){return n(this,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o,loadObjects:a}=e;return de({account:Object.assign({serverUrl:this.serverUrl,credentials:this.credentials},t),headers:Object.assign(Object.assign({},this.authHeaders),r),loadCollections:o,loadObjects:a})}))}collectionQuery(...e){return n(this,void 0,void 0,(function*(){return ce($,{headers:this.authHeaders})(e[0])}))}makeCollection(...e){return n(this,void 0,void 0,(function*(){return ce(w,{headers:this.authHeaders})(e[0])}))}syncCollection(...e){return n(this,void 0,void 0,(function*(){return ce(R,{headers:this.authHeaders})(e[0])}))}supportedReportSet(...e){return n(this,void 0,void 0,(function*(){return ce(k,{headers:this.authHeaders})(e[0])}))}isCollectionDirty(...e){return n(this,void 0,void 0,(function*(){return ce(_,{headers:this.authHeaders})(e[0])}))}smartCollectionSync(...e){return n(this,void 0,void 0,(function*(){return ce(U,{headers:this.authHeaders,account:this.account})(e[0])}))}calendarQuery(...e){return n(this,void 0,void 0,(function*(){return ce(Z,{headers:this.authHeaders})(e[0])}))}makeCalendar(...e){return n(this,void 0,void 0,(function*(){return ce(Q,{headers:this.authHeaders})(e[0])}))}calendarMultiGet(...e){return n(this,void 0,void 0,(function*(){return ce(G,{headers:this.authHeaders})(e[0])}))}fetchCalendars(...e){return n(this,void 0,void 0,(function*(){return ce(q,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchCalendarObjects(...e){return n(this,void 0,void 0,(function*(){return ce(J,{headers:this.authHeaders})(e[0])}))}createCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(K,{headers:this.authHeaders})(e[0])}))}updateCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(W,{headers:this.authHeaders})(e[0])}))}deleteCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(Y,{headers:this.authHeaders})(e[0])}))}syncCalendars(...e){return n(this,void 0,void 0,(function*(){return ce(X,{headers:this.authHeaders,account:this.account})(e[0])}))}addressBookQuery(...e){return n(this,void 0,void 0,(function*(){return ce(L,{headers:this.authHeaders})(e[0])}))}addressBookMultiGet(...e){return n(this,void 0,void 0,(function*(){return ce(N,{headers:this.authHeaders})(e[0])}))}fetchAddressBooks(...e){return n(this,void 0,void 0,(function*(){return ce(P,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchVCards(...e){return n(this,void 0,void 0,(function*(){return ce(H,{headers:this.authHeaders})(e[0])}))}createVCard(...e){return n(this,void 0,void 0,(function*(){return ce(B,{headers:this.authHeaders})(e[0])}))}updateVCard(...e){return n(this,void 0,void 0,(function*(){return ce(I,{headers:this.authHeaders})(e[0])}))}deleteVCard(...e){return n(this,void 0,void 0,(function*(){return ce(M,{headers:this.authHeaders})(e[0])}))}}var me=Object.freeze({__proto__:null,DAVClient:ge,createDAVClient:fe}),be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({DAVNamespace:d,DAVNamespaceShort:i,DAVAttributeMap:s},me),C),S),se),F),te),ve),m);export{s as DAVAttributeMap,ge as DAVClient,d as DAVNamespace,i as DAVNamespaceShort,L as addressBookQuery,G as calendarMultiGet,Z as calendarQuery,v as cleanupFalsy,$ as collectionQuery,de as createAccount,K as createCalendarObject,fe as createDAVClient,O as createObject,B as createVCard,y as davRequest,be as default,Y as deleteCalendarObject,D as deleteObject,M as deleteVCard,P as fetchAddressBooks,J as fetchCalendarObjects,q as fetchCalendars,ue as fetchOauthTokens,H as fetchVCards,ee as freeBusyQuery,le as getBasicAuthHeaders,p as getDAVAttribute,pe as getOauthHeaders,_ as isCollectionDirty,Q as makeCalendar,A as propfind,he as refreshAccessToken,U as smartCollectionSync,k as supportedReportSet,X as syncCalendars,R as syncCollection,W as updateCalendarObject,j as updateObject,I as updateVCard,h as urlContains,u as urlEquals}; +import{fetch as e}from"cross-fetch";import t from"debug";import r from"xml-js";import{encode as o}from"base-64";function a(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(o=Object.getOwnPropertySymbols(e);a{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},u=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim();if(Math.abs(r.length-o.length)>1)return!1;const a="/"===r.slice(-1)?r.slice(0,-1):r,n="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(n)||t.includes(a)},h=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),o=t.trim(),a="/"===r.slice(-1)?r.slice(0,-1):r,n="/"===o.slice(-1)?o.slice(0,-1):o;return e.includes(n)||t.includes(a)},p=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[s[t]]:t})),{}),v=e=>Object.entries(e).reduce(((e,[t,r])=>r?Object.assign(Object.assign({},e),{[t]:r}):e),{}),f=(e,t)=>t?{[e]:t}:{},g=(e,t)=>e?t&&0!==t.length?Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e)))):e:{};var m=Object.freeze({__proto__:null,cleanupFalsy:v,conditionalParam:f,excludeHeaders:g,getDAVAttribute:p,urlContains:h,urlEquals:u});const b=t("tsdav:request"),y=t=>n(void 0,void 0,void 0,(function*(){var o;const{url:a,init:n,convertIncoming:d=!0,parseOutgoing:s=!0}=t,{headers:i={},body:c,namespace:u,method:h,attributes:p}=n,f=d?r.js2xml(Object.assign(Object.assign({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}}},c),{_attributes:p}),{compact:!0,spaces:2,elementNameFn:e=>u&&!/^.+:.+/.test(e)?`${u}:${e}`:e}):c,g=yield e(a,{headers:Object.assign({"Content-Type":"text/xml;charset=UTF-8"},v(i)),body:f,method:h}),m=yield g.text();if(!g.ok||!(null===(o=g.headers.get("content-type"))||void 0===o?void 0:o.includes("xml"))||!s)return[{href:g.url,ok:g.ok,status:g.status,statusText:g.statusText,raw:m}];const y=r.xml2js(m,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,o=Object.keys(r),a=o[o.length-1],n=r[a];if(n.length>0){n[n.length-1]=l(e)}else r[a]=l(e)}catch(e){b(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,(e=>e[1].toUpperCase())),attributesFn:e=>{const t=Object.assign({},e);return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(y.multistatus.response)?y.multistatus.response:[y.multistatus.response]).map((e=>{var t,r;if(!e)return{status:g.status,statusText:g.statusText,ok:g.ok};const o=/^\S+\s(?\d+)\s(?.+)$/.exec(e.status);return{raw:y,href:e.href,status:(null==o?void 0:o.groups)?Number.parseInt(null==o?void 0:o.groups.status,10):g.status,statusText:null!==(r=null===(t=null==o?void 0:o.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:g.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce(((e,t)=>Object.assign(Object.assign({},e),null==t?void 0:t.prop)),{})}}))})),A=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:n}=e;return y({url:t,init:{method:"PROPFIND",headers:g(v(Object.assign({depth:o},a)),n),namespace:i.DAV,body:{propfind:{_attributes:p([d.CALDAV,d.CALDAV_APPLE,d.CALENDAR_SERVER,d.CARDDAV,d.DAV]),prop:r}}}})})),O=t=>n(void 0,void 0,void 0,(function*(){const{url:r,data:o,headers:a,headersToExclude:n}=t;return e(r,{method:"PUT",body:o,headers:g(a,n)})})),j=t=>n(void 0,void 0,void 0,(function*(){const{url:r,data:o,etag:a,headers:n,headersToExclude:d}=t;return e(r,{method:"PUT",body:o,headers:g(v(Object.assign({"If-Match":a},n)),d)})})),D=t=>n(void 0,void 0,void 0,(function*(){const{url:r,headers:o,etag:a,headersToExclude:n}=t;return e(r,{method:"DELETE",headers:g(v(Object.assign({"If-Match":a},o)),n)})}));var C=Object.freeze({__proto__:null,createObject:O,davRequest:y,deleteObject:D,propfind:A,updateObject:j});function V(e,t){const r=e=>t.every((t=>e[t]));return Array.isArray(e)?e.every((e=>r(e))):r(e)}const E=(e,t)=>t.reduce(((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`),""),T=t("tsdav:collection"),$=e=>n(void 0,void 0,void 0,(function*(){const{url:t,body:r,depth:o,defaultNamespace:a=i.DAV,headers:n,headersToExclude:d}=e,s=yield y({url:t,init:{method:"REPORT",headers:g(v(Object.assign({depth:o},n)),d),namespace:a,body:r}});return 1!==s.length||s[0].raw?s:[]})),w=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:n}=e;return y({url:t,init:{method:"MKCOL",headers:g(v(Object.assign({depth:o},a)),n),namespace:i.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0}})})),k=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,n;const{collection:d,headers:s,headersToExclude:c}=e;return null!==(n=null===(a=null===(o=null===(r=null===(t=(yield A({url:d.url,props:{[`${i.DAV}:supported-report-set`]:{}},depth:"0",headers:g(s,c)}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===o?void 0:o.supportedReport)||void 0===a?void 0:a.map((e=>Object.keys(e.report)[0])))&&void 0!==n?n:[]})),_=e=>n(void 0,void 0,void 0,(function*(){var t,r,o;const{collection:a,headers:n,headersToExclude:d}=e,s=(yield A({url:a.url,props:{[`${i.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:g(n,d)})).filter((e=>h(a.url,e.href)))[0];if(!s)throw new Error("Collection does not exist on server");return{isDirty:a.ctag!==(null===(t=s.props)||void 0===t?void 0:t.getctag),newCtag:null===(o=null===(r=s.props)||void 0===r?void 0:r.getctag)||void 0===o?void 0:o.toString()}})),R=e=>{const{url:t,props:r,headers:o,syncLevel:a,syncToken:n,headersToExclude:s}=e;return y({url:t,init:{method:"REPORT",namespace:i.DAV,headers:g(Object.assign({},o),s),body:{"sync-collection":{_attributes:p([d.CALDAV,d.CARDDAV,d.DAV]),"sync-level":a,"sync-token":n,[`${i.DAV}:prop`]:r}}}})},U=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,n,d,s,c,l,u,p;const{collection:v,method:f,headers:m,headersToExclude:b,account:y,detailedResult:A}=e,O=["accountType","homeUrl"];if(!y||!V(y,O)){if(!y)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${E(y,O)} before smartCollectionSync`)}const j=null!=f?f:(null===(t=v.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(T(`smart collection sync with type ${y.accountType} and method ${j}`),"webdav"===j){const e=yield R({url:v.url,props:{[`${i.DAV}:getetag`]:{},[`${"caldav"===y.accountType?i.CALDAV:i.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{},[`${i.DAV}:displayname`]:{}},syncLevel:1,syncToken:v.syncToken,headers:g(m,b)}),t=e.filter((e=>{var t;const r="caldav"===y.accountType?".ics":".vcf";return(null===(t=e.href)||void 0===t?void 0:t.slice(-4))===r})),l=t.filter((e=>404!==e.status)).map((e=>e.href)),u=t.filter((e=>404===e.status)).map((e=>e.href)),p=(l.length&&null!==(o=yield null===(r=null==v?void 0:v.objectMultiGet)||void 0===r?void 0:r.call(v,{url:v.url,props:{[`${i.DAV}:getetag`]:{},[`${"caldav"===y.accountType?i.CALDAV:i.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:l,depth:"1",headers:g(m,b)}))&&void 0!==o?o:[]).map((e=>{var t,r,o,a,n,d,s,i,c,l;return{url:null!==(t=e.href)&&void 0!==t?t:"",etag:null===(r=e.props)||void 0===r?void 0:r.getetag,data:"caldav"===(null==y?void 0:y.accountType)?null!==(n=null===(a=null===(o=e.props)||void 0===o?void 0:o.calendarData)||void 0===a?void 0:a._cdata)&&void 0!==n?n:null===(d=e.props)||void 0===d?void 0:d.calendarData:null!==(c=null===(i=null===(s=e.props)||void 0===s?void 0:s.addressData)||void 0===i?void 0:i._cdata)&&void 0!==c?c:null===(l=e.props)||void 0===l?void 0:l.addressData}})),f=null!==(a=v.objects)&&void 0!==a?a:[],O=p.filter((e=>f.every((t=>!h(t.url,e.url))))),j=f.reduce(((e,t)=>{const r=p.find((e=>h(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),D=u.map((e=>({url:e,etag:""}))),C=f.filter((e=>p.some((t=>h(e.url,t.url)&&t.etag===e.etag))));return Object.assign(Object.assign({},v),{objects:A?{created:O,updated:j,deleted:D}:[...C,...O,...j],syncToken:null!==(c=null===(s=null===(d=null===(n=e[0])||void 0===n?void 0:n.raw)||void 0===d?void 0:d.multistatus)||void 0===s?void 0:s.syncToken)&&void 0!==c?c:v.syncToken})}if("basic"===j){const{isDirty:e,newCtag:t}=yield _({collection:v,headers:g(m,b)}),r=null!==(l=v.objects)&&void 0!==l?l:[],o=null!==(p=yield null===(u=v.fetchObjects)||void 0===u?void 0:u.call(v,{collection:v,headers:g(m,b)}))&&void 0!==p?p:[],a=o.filter((e=>r.every((t=>!h(t.url,e.url))))),n=r.reduce(((e,t)=>{const r=o.find((e=>h(e.url,t.url)));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e}),[]),d=r.filter((e=>o.every((t=>!h(t.url,e.url))))),s=r.filter((e=>o.some((t=>h(e.url,t.url)&&t.etag===e.etag))));if(e)return Object.assign(Object.assign({},v),{objects:A?{created:a,updated:n,deleted:d}:[...s,...a,...n],ctag:t})}return A?Object.assign(Object.assign({},v),{objects:{created:[],updated:[],deleted:[]}}):v}));var S=Object.freeze({__proto__:null,collectionQuery:$,isCollectionDirty:_,makeCollection:w,smartCollectionSync:U,supportedReportSet:k,syncCollection:R});const x=t("tsdav:addressBook"),L=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,depth:a,headers:n,headersToExclude:s}=e;return $({url:t,body:{"addressbook-query":{_attributes:p([d.CARDDAV,d.DAV]),[`${i.DAV}:prop`]:r,filter:null!=o?o:{"prop-filter":{_attributes:{name:"FN"}}}}},defaultNamespace:i.CARDDAV,depth:a,headers:g(n,s)})})),N=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,depth:a,headers:n}=e;return $({url:t,body:{"addressbook-multiget":{_attributes:p([d.DAV,d.CARDDAV]),[`${i.DAV}:prop`]:r,[`${i.DAV}:href`]:o}},defaultNamespace:i.CARDDAV,depth:a,headers:n})})),P=e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:r,props:o,headersToExclude:a}=null!=e?e:{},d=["homeUrl","rootUrl"];if(!t||!V(t,d)){if(!t)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${E(t,d)} before fetchAddressBooks`)}const s=yield A({url:t.homeUrl,props:null!=o?o:{[`${i.DAV}:displayname`]:{},[`${i.CALENDAR_SERVER}:getctag`]:{},[`${i.DAV}:resourcetype`]:{},[`${i.DAV}:sync-token`]:{}},depth:"1",headers:g(r,a)});return Promise.all(s.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("addressbook")})).map((e=>{var r,o,a,n,d,s,i,c,l;const u=null!==(a=null===(o=null===(r=e.props)||void 0===r?void 0:r.displayname)||void 0===o?void 0:o._cdata)&&void 0!==a?a:null===(n=e.props)||void 0===n?void 0:n.displayname;return x(`Found address book named ${"string"==typeof u?u:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(d=e.href)&&void 0!==d?d:"",null!==(s=t.rootUrl)&&void 0!==s?s:"").href,ctag:null===(i=e.props)||void 0===i?void 0:i.getctag,displayName:"string"==typeof u?u:"",resourcetype:Object.keys(null===(c=e.props)||void 0===c?void 0:c.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}})).map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:r})})})))))})),H=e=>n(void 0,void 0,void 0,(function*(){const{addressBook:t,headers:r,objectUrls:o,headersToExclude:a,urlFilter:n=(e=>e),useMultiGet:d=!0}=e;x(`Fetching vcards from ${null==t?void 0:t.url}`);const s=["url"];if(!t||!V(t,s)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${E(t,s)} before fetchVCards`)}const c=(null!=o?o:(yield L({url:t.url,props:{[`${i.DAV}:getetag`]:{}},depth:"1",headers:g(r,a)})).map((e=>{var t;return e.ok&&null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(n).map((e=>new URL(e).pathname));let l=[];return c.length>0&&(l=d?yield N({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CARDDAV}:address-data`]:{}},objectUrls:c,depth:"1",headers:g(r,a)}):yield L({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CARDDAV}:address-data`]:{}},depth:"1",headers:g(r,a)})),l.map((e=>{var r,o,a,n,d,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(o=e.props)||void 0===o?void 0:o.getetag,data:null!==(d=null===(n=null===(a=e.props)||void 0===a?void 0:a.addressData)||void 0===n?void 0:n._cdata)&&void 0!==d?d:null===(s=e.props)||void 0===s?void 0:s.addressData}}))})),B=e=>n(void 0,void 0,void 0,(function*(){const{addressBook:t,vCardString:r,filename:o,headers:a,headersToExclude:n}=e;return O({url:new URL(o,t.url).href,data:r,headers:g(Object.assign({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*"},a),n)})})),I=e=>n(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return j({url:t.url,data:t.data,etag:t.etag,headers:g(Object.assign({"content-type":"text/vcard; charset=utf-8"},r),o)})})),F=e=>n(void 0,void 0,void 0,(function*(){const{vCard:t,headers:r,headersToExclude:o}=e;return D({url:t.url,etag:t.etag,headers:g(r,o)})}));var M=Object.freeze({__proto__:null,addressBookMultiGet:N,addressBookQuery:L,createVCard:B,deleteVCard:F,fetchAddressBooks:P,fetchVCards:H,updateVCard:I});const z=t("tsdav:calendar"),Z=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,filters:o,timezone:a,depth:n,headers:s,headersToExclude:c}=e;return $({url:t,body:{"calendar-query":v({_attributes:p([d.CALDAV,d.CALENDAR_SERVER,d.CALDAV_APPLE,d.DAV]),[`${i.DAV}:prop`]:r,filter:o,timezone:a})},defaultNamespace:i.CALDAV,depth:n,headers:g(s,c)})})),G=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,objectUrls:o,filters:a,timezone:n,depth:s,headers:c,headersToExclude:l}=e;return $({url:t,body:{"calendar-multiget":Object.assign(Object.assign({_attributes:p([d.DAV,d.CALDAV]),[`${i.DAV}:prop`]:r,[`${i.DAV}:href`]:o},f("filter",a)),{timezone:n})},defaultNamespace:i.CALDAV,depth:s,headers:g(c,l)})})),Q=e=>n(void 0,void 0,void 0,(function*(){const{url:t,props:r,depth:o,headers:a,headersToExclude:n}=e;return y({url:t,init:{method:"MKCALENDAR",headers:g(v(Object.assign({depth:o},a)),n),namespace:i.DAV,body:{[`${i.CALDAV}:mkcalendar`]:{_attributes:p([d.DAV,d.CALDAV,d.CALDAV_APPLE]),set:{prop:r}}}}})})),q=e=>n(void 0,void 0,void 0,(function*(){const{headers:t,account:r,props:o,projectedProps:a,headersToExclude:d}=null!=e?e:{},s=["homeUrl","rootUrl"];if(!r||!V(r,s)){if(!r)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${E(r,s)} before fetchCalendars`)}const l=yield A({url:r.homeUrl,props:null!=o?o:{[`${i.CALDAV}:calendar-description`]:{},[`${i.CALDAV}:calendar-timezone`]:{},[`${i.DAV}:displayname`]:{},[`${i.CALDAV_APPLE}:calendar-color`]:{},[`${i.CALENDAR_SERVER}:getctag`]:{},[`${i.DAV}:resourcetype`]:{},[`${i.CALDAV}:supported-calendar-component-set`]:{},[`${i.DAV}:sync-token`]:{}},depth:"1",headers:g(t,d)});return Promise.all(l.filter((e=>{var t,r;return Object.keys(null!==(r=null===(t=e.props)||void 0===t?void 0:t.resourcetype)&&void 0!==r?r:{}).includes("calendar")})).filter((e=>{var t,r,o,a;return(Array.isArray(null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet.comp)?null===(r=e.props)||void 0===r?void 0:r.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(a=null===(o=e.props)||void 0===o?void 0:o.supportedCalendarComponentSet.comp)||void 0===a?void 0:a._attributes.name]||[]).some((e=>Object.values(c).includes(e)))})).map((e=>{var t,o,n,d,s,i,c,l,u,h,p,v,g,m,b,y;const A=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,O=null===(o=e.props)||void 0===o?void 0:o.calendarTimezone;return Object.assign({description:"string"==typeof A?A:"",timezone:"string"==typeof O?O:"",url:new URL(null!==(n=e.href)&&void 0!==n?n:"",null!==(d=r.rootUrl)&&void 0!==d?d:"").href,ctag:null===(s=e.props)||void 0===s?void 0:s.getctag,calendarColor:null===(i=e.props)||void 0===i?void 0:i.calendarColor,displayName:null!==(l=null===(c=e.props)||void 0===c?void 0:c.displayname._cdata)&&void 0!==l?l:null===(u=e.props)||void 0===u?void 0:u.displayname,components:Array.isArray(null===(h=e.props)||void 0===h?void 0:h.supportedCalendarComponentSet.comp)?null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp.map((e=>e._attributes.name)):[null===(g=null===(v=e.props)||void 0===v?void 0:v.supportedCalendarComponentSet.comp)||void 0===g?void 0:g._attributes.name],resourcetype:Object.keys(null===(m=e.props)||void 0===m?void 0:m.resourcetype),syncToken:null===(b=e.props)||void 0===b?void 0:b.syncToken},f("projectedProps",Object.fromEntries(Object.entries(null!==(y=e.props)&&void 0!==y?y:{}).filter((([e])=>null==a?void 0:a[e])))))})).map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{reports:yield k({collection:e,headers:g(t,d)})})})))))})),J=e=>n(void 0,void 0,void 0,(function*(){const{calendar:t,objectUrls:r,filters:o,timeRange:a,headers:n,expand:d,urlFilter:s=(e=>Boolean(null==e?void 0:e.includes(".ics"))),useMultiGet:c=!0,headersToExclude:l}=e;if(a){const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(a.start)&&e.test(a.end)||t.test(a.start)&&t.test(a.end)))throw new Error("invalid timeRange format, not in ISO8601")}z(`Fetching calendar objects from ${null==t?void 0:t.url}`);const u=["url"];if(!t||!V(t,u)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${E(t,u)} before fetchCalendarObjects`)}const h=null!=o?o:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":Object.assign({_attributes:{name:"VEVENT"}},a?{"time-range":{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})}}],p=(null!=r?r:(yield Z({url:t.url,props:{[`${i.DAV}:getetag`]:Object.assign({},d&&a?{[`${i.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:h,depth:"1",headers:g(n,l)})).map((e=>{var t;return null!==(t=e.href)&&void 0!==t?t:""}))).map((e=>e.startsWith("http")||!e?e:new URL(e,t.url).href)).filter(s).map((e=>new URL(e).pathname));let v=[];return p.length>0&&(v=!c||d?yield Z({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CALDAV}:calendar-data`]:Object.assign({},d&&a?{[`${i.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},filters:h,depth:"1",headers:g(n,l)}):yield G({url:t.url,props:{[`${i.DAV}:getetag`]:{},[`${i.CALDAV}:calendar-data`]:Object.assign({},d&&a?{[`${i.CALDAV}:expand`]:{_attributes:{start:`${new Date(a.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(a.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{})},objectUrls:p,depth:"1",headers:g(n,l)})),v.map((e=>{var r,o,a,n,d,s;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(o=e.props)||void 0===o?void 0:o.getetag}`,data:null!==(d=null===(n=null===(a=e.props)||void 0===a?void 0:a.calendarData)||void 0===n?void 0:n._cdata)&&void 0!==d?d:null===(s=e.props)||void 0===s?void 0:s.calendarData}}))})),K=e=>n(void 0,void 0,void 0,(function*(){const{calendar:t,iCalString:r,filename:o,headers:a,headersToExclude:n}=e;return O({url:new URL(o,t.url).href,data:r,headers:g(Object.assign({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*"},a),n)})})),W=e=>n(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return j({url:t.url,data:t.data,etag:t.etag,headers:g(Object.assign({"content-type":"text/calendar; charset=utf-8"},r),o)})})),Y=e=>n(void 0,void 0,void 0,(function*(){const{calendarObject:t,headers:r,headersToExclude:o}=e;return D({url:t.url,etag:t.etag,headers:g(r,o)})})),X=e=>n(void 0,void 0,void 0,(function*(){var t;const{oldCalendars:r,account:o,detailedResult:a,headers:d,headersToExclude:s}=e;if(!o)throw new Error("Must have account before syncCalendars");const i=null!==(t=null!=r?r:o.calendars)&&void 0!==t?t:[],c=yield q({account:o,headers:g(d,s)}),l=c.filter((e=>i.every((t=>!h(t.url,e.url)))));z(`new calendars: ${l.map((e=>e.displayName))}`);const u=i.reduce(((e,t)=>{const r=c.find((e=>h(e.url,t.url)));return r&&(r.syncToken&&r.syncToken!==t.syncToken||r.ctag&&r.ctag!==t.ctag)?[...e,r]:e}),[]);z(`updated calendars: ${u.map((e=>e.displayName))}`);const p=yield Promise.all(u.map((e=>n(void 0,void 0,void 0,(function*(){return yield U({collection:Object.assign(Object.assign({},e),{objectMultiGet:G}),method:"webdav",headers:g(d,s),account:o})}))))),v=i.filter((e=>c.every((t=>!h(t.url,e.url)))));z(`deleted calendars: ${v.map((e=>e.displayName))}`);const f=i.filter((e=>c.some((t=>h(t.url,e.url)&&(t.syncToken&&t.syncToken!==e.syncToken||t.ctag&&t.ctag!==e.ctag)))));return a?{created:l,updated:u,deleted:v}:[...f,...l,...p]})),ee=e=>n(void 0,void 0,void 0,(function*(){const{url:t,timeRange:r,depth:o,headers:a,headersToExclude:n}=e;if(!r)throw new Error("timeRange is required");{const e=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,t=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;if(!(e.test(r.start)&&e.test(r.end)||t.test(r.start)&&t.test(r.end)))throw new Error("invalid timeRange format, not in ISO8601")}return(yield $({url:t,body:{"free-busy-query":v({_attributes:p([d.CALDAV]),[`${i.CALDAV}:time-range`]:{_attributes:{start:`${new Date(r.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(r.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}})},defaultNamespace:i.CALDAV,depth:o,headers:g(a,n)}))[0]}));var te=Object.freeze({__proto__:null,calendarMultiGet:G,calendarQuery:Z,createCalendarObject:K,deleteCalendarObject:Y,fetchCalendarObjects:J,fetchCalendars:q,freeBusyQuery:ee,makeCalendar:Q,syncCalendars:X,updateCalendarObject:W});const re=t("tsdav:account"),oe=t=>n(void 0,void 0,void 0,(function*(){var r,o;re("Service discovery...");const{account:a,headers:n,headersToExclude:d}=t,s=new URL(a.serverUrl),i=new URL(`/.well-known/${a.accountType}`,s);i.protocol=null!==(r=s.protocol)&&void 0!==r?r:"http";try{const t=yield e(i.href,{headers:g(n,d),method:"PROPFIND",redirect:"manual"});if(t.status>=300&&t.status<400){const e=t.headers.get("Location");if("string"==typeof e&&e.length){re(`Service discovery redirected to ${e}`);const t=new URL(e,s);return t.hostname===i.hostname&&i.port&&!t.port&&(t.port=i.port),t.protocol=null!==(o=s.protocol)&&void 0!==o?o:"http",t.href}}}catch(e){re(`Service discovery failed: ${e.stack}`)}return s.href})),ae=e=>n(void 0,void 0,void 0,(function*(){var t,r,o,a,n;const{account:d,headers:s,headersToExclude:c}=e,l=["rootUrl"];if(!V(d,l))throw new Error(`account must have ${E(d,l)} before fetchPrincipalUrl`);re(`Fetching principal url from path ${d.rootUrl}`);const[u]=yield A({url:d.rootUrl,props:{[`${i.DAV}:current-user-principal`]:{}},depth:"0",headers:g(s,c)});if(!u.ok&&(re(`Fetch principal url failed: ${u.statusText}`),401===u.status))throw new Error("Invalid credentials");return re(`Fetched principal url ${null===(r=null===(t=u.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(n=null===(a=null===(o=u.props)||void 0===o?void 0:o.currentUserPrincipal)||void 0===a?void 0:a.href)&&void 0!==n?n:"",d.rootUrl).href})),ne=e=>n(void 0,void 0,void 0,(function*(){var t,r;const{account:o,headers:a,headersToExclude:n}=e,d=["principalUrl","rootUrl"];if(!V(o,d))throw new Error(`account must have ${E(o,d)} before fetchHomeUrl`);re(`Fetch home url from ${o.principalUrl}`);const s=(yield A({url:o.principalUrl,props:"caldav"===o.accountType?{[`${i.CALDAV}:calendar-home-set`]:{}}:{[`${i.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:g(a,n)})).find((e=>h(o.principalUrl,e.href)));if(!s||!s.ok)throw new Error("cannot find homeUrl");const c=new URL("caldav"===o.accountType?null===(t=null==s?void 0:s.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==s?void 0:s.props)||void 0===r?void 0:r.addressbookHomeSet.href,o.rootUrl).href;return re(`Fetched home url ${c}`),c})),de=e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o=!1,loadObjects:a=!1,headersToExclude:d}=e,s=Object.assign({},t);return s.rootUrl=yield oe({account:t,headers:g(r,d)}),s.principalUrl=yield ae({account:s,headers:g(r,d)}),s.homeUrl=yield ne({account:s,headers:g(r,d)}),(o||a)&&("caldav"===t.accountType?s.calendars=yield q({headers:g(r,d),account:s}):"carddav"===t.accountType&&(s.addressBooks=yield P({headers:g(r,d),account:s}))),a&&("caldav"===t.accountType&&s.calendars?s.calendars=yield Promise.all(s.calendars.map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield J({calendar:e,headers:g(r,d)})})}))))):"carddav"===t.accountType&&s.addressBooks&&(s.addressBooks=yield Promise.all(s.addressBooks.map((e=>n(void 0,void 0,void 0,(function*(){return Object.assign(Object.assign({},e),{objects:yield H({addressBook:e,headers:g(r,d)})})}))))))),s}));var se=Object.freeze({__proto__:null,createAccount:de,fetchHomeUrl:ne,fetchPrincipalUrl:ae,serviceDiscovery:oe});const ie=t("tsdav:authHelper"),ce=(e,t)=>(...r)=>e(Object.assign(Object.assign({},t),r[0])),le=e=>(ie(`Basic auth token generated: ${o(`${e.username}:${e.password}`)}`),{authorization:`Basic ${o(`${e.username}:${e.password}`)}`}),ue=t=>n(void 0,void 0,void 0,(function*(){const r=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!V(t,r))throw new Error(`Oauth credentials missing: ${E(t,r)}`);const o=new URLSearchParams({grant_type:"authorization_code",code:t.authorizationCode,redirect_uri:t.redirectUrl,client_id:t.clientId,client_secret:t.clientSecret});ie(t.tokenUrl),ie(o.toString());const a=yield e(t.tokenUrl,{method:"POST",body:o.toString(),headers:{"content-length":`${o.toString().length}`,"content-type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Fetch Oauth tokens failed: ${yield a.text()}`),{}})),he=t=>n(void 0,void 0,void 0,(function*(){const r=["refreshToken","clientId","clientSecret","tokenUrl"];if(!V(t,r))throw new Error(`Oauth credentials missing: ${E(t,r)}`);const o=new URLSearchParams({client_id:t.clientId,client_secret:t.clientSecret,refresh_token:t.refreshToken,grant_type:"refresh_token"}),a=yield e(t.tokenUrl,{method:"POST",body:o.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(a.ok){return yield a.json()}return ie(`Refresh access token failed: ${yield a.text()}`),{}})),pe=e=>n(void 0,void 0,void 0,(function*(){var t;ie("Fetching oauth headers");let r={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(t=e.expiration)&&void 0!==t?t:0))&&(r=yield he(e)):r=yield ue(e),ie(`Oauth tokens fetched: ${r.access_token}`),{tokens:r,headers:{authorization:`Bearer ${r.access_token}`}}}));var ve=Object.freeze({__proto__:null,defaultParam:ce,fetchOauthTokens:ue,getBasicAuthHeaders:le,getOauthHeaders:pe,refreshAccessToken:he});const fe=e=>n(void 0,void 0,void 0,(function*(){var t;const{serverUrl:r,credentials:o,authMethod:d,defaultAccountType:s,authFunction:i}=e;let c={};switch(d){case"Basic":c=le(o);break;case"Oauth":c=(yield pe(o)).headers;break;case"Digest":c={Authorization:`Digest ${o.digestString}`};break;case"Custom":c=null!==(t=yield null==i?void 0:i(o))&&void 0!==t?t:{};break;default:throw new Error("Invalid auth method")}const l=s?yield de({account:{serverUrl:r,credentials:o,accountType:s},headers:c}):void 0,u=ce(O,{url:r,headers:c}),h=ce(j,{headers:c,url:r}),p=ce(D,{headers:c,url:r}),v=ce(A,{headers:c}),f=ce($,{headers:c}),g=ce(w,{headers:c}),m=ce(R,{headers:c}),b=ce(k,{headers:c}),C=ce(_,{headers:c}),V=ce(U,{headers:c,account:l}),E=ce(Z,{headers:c}),T=ce(G,{headers:c}),S=ce(Q,{headers:c}),x=ce(q,{headers:c,account:l}),M=ce(J,{headers:c}),z=ce(K,{headers:c}),ee=ce(W,{headers:c}),te=ce(Y,{headers:c}),re=ce(X,{account:l,headers:c}),oe=ce(L,{headers:c}),ae=ce(N,{headers:c});return{davRequest:e=>n(void 0,void 0,void 0,(function*(){const{init:t}=e,r=a(e,["init"]),{headers:o}=t,n=a(t,["headers"]);return y(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},c),o)})}))})),propfind:v,createAccount:e=>n(void 0,void 0,void 0,(function*(){const{account:t,headers:a,loadCollections:n,loadObjects:d}=e;return de({account:Object.assign({serverUrl:r,credentials:o},t),headers:Object.assign(Object.assign({},c),a),loadCollections:n,loadObjects:d})})),createObject:u,updateObject:h,deleteObject:p,calendarQuery:E,addressBookQuery:oe,collectionQuery:f,makeCollection:g,calendarMultiGet:T,makeCalendar:S,syncCollection:m,supportedReportSet:b,isCollectionDirty:C,smartCollectionSync:V,fetchCalendars:x,fetchCalendarObjects:M,createCalendarObject:z,updateCalendarObject:ee,deleteCalendarObject:te,syncCalendars:re,fetchAddressBooks:ce(P,{account:l,headers:c}),addressBookMultiGet:ae,fetchVCards:ce(H,{headers:c}),createVCard:ce(B,{headers:c}),updateVCard:ce(I,{headers:c}),deleteVCard:ce(F,{headers:c})}}));class ge{constructor(e){var t,r;this.serverUrl=e.serverUrl,this.credentials=e.credentials,this.authMethod=null!==(t=e.authMethod)&&void 0!==t?t:"Basic",this.accountType=null!==(r=e.defaultAccountType)&&void 0!==r?r:"caldav",this.authFunction=e.authFunction}login(){return n(this,void 0,void 0,(function*(){var e;switch(this.authMethod){case"Basic":this.authHeaders=le(this.credentials);break;case"Oauth":this.authHeaders=(yield pe(this.credentials)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=yield null===(e=this.authFunction)||void 0===e?void 0:e.call(this,this.credentials);break;default:throw new Error("Invalid auth method")}this.account=this.accountType?yield de({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders}):void 0}))}davRequest(e){return n(this,void 0,void 0,(function*(){const{init:t}=e,r=a(e,["init"]),{headers:o}=t,n=a(t,["headers"]);return y(Object.assign(Object.assign({},r),{init:Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},this.authHeaders),o)})}))}))}createObject(...e){return n(this,void 0,void 0,(function*(){return ce(O,{url:this.serverUrl,headers:this.authHeaders})(e[0])}))}updateObject(...e){return n(this,void 0,void 0,(function*(){return ce(j,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}deleteObject(...e){return n(this,void 0,void 0,(function*(){return ce(D,{headers:this.authHeaders,url:this.serverUrl})(e[0])}))}propfind(...e){return n(this,void 0,void 0,(function*(){return ce(A,{headers:this.authHeaders})(e[0])}))}createAccount(e){return n(this,void 0,void 0,(function*(){const{account:t,headers:r,loadCollections:o,loadObjects:a}=e;return de({account:Object.assign({serverUrl:this.serverUrl,credentials:this.credentials},t),headers:Object.assign(Object.assign({},this.authHeaders),r),loadCollections:o,loadObjects:a})}))}collectionQuery(...e){return n(this,void 0,void 0,(function*(){return ce($,{headers:this.authHeaders})(e[0])}))}makeCollection(...e){return n(this,void 0,void 0,(function*(){return ce(w,{headers:this.authHeaders})(e[0])}))}syncCollection(...e){return n(this,void 0,void 0,(function*(){return ce(R,{headers:this.authHeaders})(e[0])}))}supportedReportSet(...e){return n(this,void 0,void 0,(function*(){return ce(k,{headers:this.authHeaders})(e[0])}))}isCollectionDirty(...e){return n(this,void 0,void 0,(function*(){return ce(_,{headers:this.authHeaders})(e[0])}))}smartCollectionSync(...e){return n(this,void 0,void 0,(function*(){return ce(U,{headers:this.authHeaders,account:this.account})(e[0])}))}calendarQuery(...e){return n(this,void 0,void 0,(function*(){return ce(Z,{headers:this.authHeaders})(e[0])}))}makeCalendar(...e){return n(this,void 0,void 0,(function*(){return ce(Q,{headers:this.authHeaders})(e[0])}))}calendarMultiGet(...e){return n(this,void 0,void 0,(function*(){return ce(G,{headers:this.authHeaders})(e[0])}))}fetchCalendars(...e){return n(this,void 0,void 0,(function*(){return ce(q,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchCalendarObjects(...e){return n(this,void 0,void 0,(function*(){return ce(J,{headers:this.authHeaders})(e[0])}))}createCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(K,{headers:this.authHeaders})(e[0])}))}updateCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(W,{headers:this.authHeaders})(e[0])}))}deleteCalendarObject(...e){return n(this,void 0,void 0,(function*(){return ce(Y,{headers:this.authHeaders})(e[0])}))}syncCalendars(...e){return n(this,void 0,void 0,(function*(){return ce(X,{headers:this.authHeaders,account:this.account})(e[0])}))}addressBookQuery(...e){return n(this,void 0,void 0,(function*(){return ce(L,{headers:this.authHeaders})(e[0])}))}addressBookMultiGet(...e){return n(this,void 0,void 0,(function*(){return ce(N,{headers:this.authHeaders})(e[0])}))}fetchAddressBooks(...e){return n(this,void 0,void 0,(function*(){return ce(P,{headers:this.authHeaders,account:this.account})(null==e?void 0:e[0])}))}fetchVCards(...e){return n(this,void 0,void 0,(function*(){return ce(H,{headers:this.authHeaders})(e[0])}))}createVCard(...e){return n(this,void 0,void 0,(function*(){return ce(B,{headers:this.authHeaders})(e[0])}))}updateVCard(...e){return n(this,void 0,void 0,(function*(){return ce(I,{headers:this.authHeaders})(e[0])}))}deleteVCard(...e){return n(this,void 0,void 0,(function*(){return ce(F,{headers:this.authHeaders})(e[0])}))}}var me=Object.freeze({__proto__:null,DAVClient:ge,createDAVClient:fe}),be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({DAVNamespace:d,DAVNamespaceShort:i,DAVAttributeMap:s},me),C),S),se),M),te),ve),m);export{s as DAVAttributeMap,ge as DAVClient,d as DAVNamespace,i as DAVNamespaceShort,L as addressBookQuery,G as calendarMultiGet,Z as calendarQuery,v as cleanupFalsy,$ as collectionQuery,de as createAccount,K as createCalendarObject,fe as createDAVClient,O as createObject,B as createVCard,y as davRequest,be as default,Y as deleteCalendarObject,D as deleteObject,F as deleteVCard,P as fetchAddressBooks,J as fetchCalendarObjects,q as fetchCalendars,ue as fetchOauthTokens,H as fetchVCards,ee as freeBusyQuery,le as getBasicAuthHeaders,p as getDAVAttribute,pe as getOauthHeaders,_ as isCollectionDirty,Q as makeCalendar,A as propfind,he as refreshAccessToken,U as smartCollectionSync,k as supportedReportSet,X as syncCalendars,R as syncCollection,W as updateCalendarObject,j as updateObject,I as updateVCard,h as urlContains,u as urlEquals}; diff --git a/dist/tsdav.mjs b/dist/tsdav.mjs index 64f08c0..030eec9 100644 --- a/dist/tsdav.mjs +++ b/dist/tsdav.mjs @@ -396,7 +396,7 @@ const supportedReportSet = (params) => __awaiter(void 0, void 0, void 0, functio return ((_e = (_d = (_c = (_b = (_a = res[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.supportedReportSet) === null || _c === void 0 ? void 0 : _c.supportedReport) === null || _d === void 0 ? void 0 : _d.map((sr) => Object.keys(sr.report)[0])) !== null && _e !== void 0 ? _e : []); }); const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _f, _g, _h; + var _a, _b, _c; const { collection, headers, headersToExclude } = params; const responses = yield propfind({ url: collection.url, @@ -411,8 +411,8 @@ const isCollectionDirty = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Collection does not exist on server'); } return { - isDirty: collection.ctag !== ((_f = res.props) === null || _f === void 0 ? void 0 : _f.getctag), - newCtag: (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.getctag) === null || _h === void 0 ? void 0 : _h.toString(), + isDirty: collection.ctag !== ((_a = res.props) === null || _a === void 0 ? void 0 : _a.getctag), + newCtag: (_c = (_b = res.props) === null || _b === void 0 ? void 0 : _b.getctag) === null || _c === void 0 ? void 0 : _c.toString(), }; }); /** @@ -443,7 +443,7 @@ const syncCollection = (params) => { }; /** remote collection to local */ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const { collection, method, headers, headersToExclude, account, detailedResult } = params; const requiredFields = ['accountType', 'homeUrl']; if (!account || !hasFields(account, requiredFields)) { @@ -452,7 +452,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi } throw new Error(`account must have ${findMissingFieldNames(account, requiredFields)} before smartCollectionSync`); } - const syncMethod = method !== null && method !== void 0 ? method : (((_j = collection.reports) === null || _j === void 0 ? void 0 : _j.includes('syncCollection')) ? 'webdav' : 'basic'); + const syncMethod = method !== null && method !== void 0 ? method : (((_a = collection.reports) === null || _a === void 0 ? void 0 : _a.includes('syncCollection')) ? 'webdav' : 'basic'); debug$4(`smart collection sync with type ${account.accountType} and method ${syncMethod}`); if (syncMethod === 'webdav') { const result = yield syncCollection({ @@ -474,7 +474,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi const changedObjectUrls = objectResponses.filter((o) => o.status !== 404).map((r) => r.href); const deletedObjectUrls = objectResponses.filter((o) => o.status === 404).map((r) => r.href); const multiGetObjectResponse = changedObjectUrls.length - ? (_l = (yield ((_k = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _k === void 0 ? void 0 : _k.call(collection, { + ? (_c = (yield ((_b = collection === null || collection === void 0 ? void 0 : collection.objectMultiGet) === null || _b === void 0 ? void 0 : _b.call(collection, { url: collection.url, props: { [`${DAVNamespaceShort.DAV}:getetag`]: {}, @@ -485,7 +485,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi objectUrls: changedObjectUrls, depth: '1', headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _l !== void 0 ? _l : [] + })))) !== null && _c !== void 0 ? _c : [] : []; const remoteObjects = multiGetObjectResponse.map((res) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; @@ -497,7 +497,7 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi : (_j = (_h = (_g = res.props) === null || _g === void 0 ? void 0 : _g.addressData) === null || _h === void 0 ? void 0 : _h._cdata) !== null && _j !== void 0 ? _j : (_k = res.props) === null || _k === void 0 ? void 0 : _k.addressData, }; }); - const localObjects = (_m = collection.objects) !== null && _m !== void 0 ? _m : []; + const localObjects = (_d = collection.objects) !== null && _d !== void 0 ? _d : []; // no existing url const created = remoteObjects.filter((o) => localObjects.every((lo) => !urlContains(lo.url, o.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -520,18 +520,18 @@ const smartCollectionSync = (params) => __awaiter(void 0, void 0, void 0, functi ? { created, updated, deleted } : [...unchanged, ...created, ...updated], // all syncToken in the results are the same so we use the first one here - syncToken: (_r = (_q = (_p = (_o = result[0]) === null || _o === void 0 ? void 0 : _o.raw) === null || _p === void 0 ? void 0 : _p.multistatus) === null || _q === void 0 ? void 0 : _q.syncToken) !== null && _r !== void 0 ? _r : collection.syncToken }); + syncToken: (_h = (_g = (_f = (_e = result[0]) === null || _e === void 0 ? void 0 : _e.raw) === null || _f === void 0 ? void 0 : _f.multistatus) === null || _g === void 0 ? void 0 : _g.syncToken) !== null && _h !== void 0 ? _h : collection.syncToken }); } if (syncMethod === 'basic') { const { isDirty, newCtag } = yield isCollectionDirty({ collection, headers: excludeHeaders(headers, headersToExclude), }); - const localObjects = (_s = collection.objects) !== null && _s !== void 0 ? _s : []; - const remoteObjects = (_u = (yield ((_t = collection.fetchObjects) === null || _t === void 0 ? void 0 : _t.call(collection, { + const localObjects = (_j = collection.objects) !== null && _j !== void 0 ? _j : []; + const remoteObjects = (_l = (yield ((_k = collection.fetchObjects) === null || _k === void 0 ? void 0 : _k.call(collection, { collection, headers: excludeHeaders(headers, headersToExclude), - })))) !== null && _u !== void 0 ? _u : []; + })))) !== null && _l !== void 0 ? _l : []; // no existing url const created = remoteObjects.filter((ro) => localObjects.every((lo) => !urlContains(lo.url, ro.url))); // debug(`created objects: ${created.map((o) => o.url).join('\n')}`); @@ -1151,7 +1151,7 @@ const serviceDiscovery = (params) => __awaiter(void 0, void 0, void 0, function* return endpoint.href; }); const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _c, _d, _e, _f, _g; + var _a, _b, _c, _d, _e; const { account, headers, headersToExclude } = params; const requiredFields = ['rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1172,11 +1172,11 @@ const fetchPrincipalUrl = (params) => __awaiter(void 0, void 0, void 0, function throw new Error('Invalid credentials'); } } - debug$1(`Fetched principal url ${(_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href}`); - return new URL((_g = (_f = (_e = response.props) === null || _e === void 0 ? void 0 : _e.currentUserPrincipal) === null || _f === void 0 ? void 0 : _f.href) !== null && _g !== void 0 ? _g : '', account.rootUrl).href; + debug$1(`Fetched principal url ${(_b = (_a = response.props) === null || _a === void 0 ? void 0 : _a.currentUserPrincipal) === null || _b === void 0 ? void 0 : _b.href}`); + return new URL((_e = (_d = (_c = response.props) === null || _c === void 0 ? void 0 : _c.currentUserPrincipal) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '', account.rootUrl).href; }); const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () { - var _h, _j; + var _a, _b; const { account, headers, headersToExclude } = params; const requiredFields = ['principalUrl', 'rootUrl']; if (!hasFields(account, requiredFields)) { @@ -1196,8 +1196,8 @@ const fetchHomeUrl = (params) => __awaiter(void 0, void 0, void 0, function* () throw new Error('cannot find homeUrl'); } const result = new URL(account.accountType === 'caldav' - ? (_h = matched === null || matched === void 0 ? void 0 : matched.props) === null || _h === void 0 ? void 0 : _h.calendarHomeSet.href - : (_j = matched === null || matched === void 0 ? void 0 : matched.props) === null || _j === void 0 ? void 0 : _j.addressbookHomeSet.href, account.rootUrl).href; + ? (_a = matched === null || matched === void 0 ? void 0 : matched.props) === null || _a === void 0 ? void 0 : _a.calendarHomeSet.href + : (_b = matched === null || matched === void 0 ? void 0 : matched.props) === null || _b === void 0 ? void 0 : _b.addressbookHomeSet.href, account.rootUrl).href; debug$1(`Fetched home url ${result}`); return result; }); @@ -1512,10 +1512,11 @@ class DAVClient { this.credentials = params.credentials; this.authMethod = (_a = params.authMethod) !== null && _a !== void 0 ? _a : 'Basic'; this.accountType = (_b = params.defaultAccountType) !== null && _b !== void 0 ? _b : 'caldav'; + this.authFunction = params.authFunction; } login() { - var _a; return __awaiter(this, void 0, void 0, function* () { + var _a; switch (this.authMethod) { case 'Basic': this.authHeaders = getBasicAuthHeaders(this.credentials); diff --git a/package.json b/package.json index 7dfec20..da89243 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsdav", - "version": "2.0.9", + "version": "2.0.10", "description": "WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser", "keywords": [ "dav", @@ -50,7 +50,7 @@ "dependencies": { "base-64": "1.0.0", "cross-fetch": "4.0.0", - "debug": "4.3.4", + "debug": "4.3.5", "xml-js": "1.6.11" }, "devDependencies": { @@ -60,31 +60,31 @@ "@types/base-64": "1.0.2", "@types/debug": "4.1.12", "@types/jest": "29.5.12", - "@types/node": "20.11.19", - "@typescript-eslint/eslint-plugin": "7.0.2", - "@typescript-eslint/parser": "7.0.2", + "@types/node": "20.14.10", + "@typescript-eslint/eslint-plugin": "7.16.1", + "@typescript-eslint/parser": "7.16.1", "copyfiles": "2.4.1", "cross-env": "7.0.3", "dotenv": "16.4.5", - "eslint": "8.56.0", + "eslint": "9.7.0", "eslint-config-airbnb": "19.0.4", - "eslint-config-airbnb-typescript": "17.1.0", + "eslint-config-airbnb-typescript": "18.0.0", "eslint-config-prettier": "9.1.0", - "eslint-module-utils": "2.8.0", + "eslint-module-utils": "2.8.1", "eslint-plugin-import": "2.29.1", "eslint-plugin-prettier": "5.1.3", "jest": "29.7.0", - "prettier": "3.2.5", - "rimraf": "5.0.5", - "rollup": "4.12.0", - "rollup-plugin-dts": "6.1.0", + "prettier": "3.3.3", + "rimraf": "5.0.7", + "rollup": "4.18.1", + "rollup-plugin-dts": "6.1.1", "rollup-plugin-node-builtins": "2.1.2", "rollup-plugin-polyfill-node": "0.13.0", "rollup-plugin-terser": "7.0.2", - "sort-package-json": "2.8.0", - "ts-jest": "29.1.2", - "tslib": "2.6.2", - "typescript": "5.3.3" + "sort-package-json": "2.10.0", + "ts-jest": "29.2.2", + "tslib": "2.6.3", + "typescript": "5.5.3" }, "engines": { "node": ">=10" diff --git a/src/client.ts b/src/client.ts index e40c883..e75a4ad 100644 --- a/src/client.ts +++ b/src/client.ts @@ -249,6 +249,7 @@ export class DAVClient { this.credentials = params.credentials; this.authMethod = params.authMethod ?? 'Basic'; this.accountType = params.defaultAccountType ?? 'caldav'; + this.authFunction = params.authFunction; } async login(): Promise { diff --git a/yarn.lock b/yarn.lock index 710b977..17d30c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -43,13 +43,13 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/code-frame@^7.22.13": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.4.tgz#03ae5af150be94392cb5c7ccd97db5a19a5da6aa" - integrity sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA== +"@babel/code-frame@^7.24.2": + version "7.24.7" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.24.7.tgz#882fd9e09e8ee324e496bd040401c6f046ef4465" + integrity sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA== dependencies: - "@babel/highlight" "^7.23.4" - chalk "^2.4.2" + "@babel/highlight" "^7.24.7" + picocolors "^1.0.0" "@babel/compat-data@^7.16.4": version "7.16.4" @@ -300,10 +300,10 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== -"@babel/helper-validator-identifier@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" - integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== +"@babel/helper-validator-identifier@^7.24.7": + version "7.24.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz#75b889cfaf9e35c2aaf42cf0d72c8e91719251db" + integrity sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w== "@babel/helper-validator-option@^7.16.7": version "7.16.7" @@ -369,14 +369,15 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/highlight@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" - integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A== +"@babel/highlight@^7.24.7": + version "7.24.7" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.24.7.tgz#a05ab1df134b286558aae0ed41e6c5f731bf409d" + integrity sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw== dependencies: - "@babel/helper-validator-identifier" "^7.22.20" + "@babel/helper-validator-identifier" "^7.24.7" chalk "^2.4.2" js-tokens "^4.0.0" + picocolors "^1.0.0" "@babel/parser@^7.1.0", "@babel/parser@^7.14.5": version "7.15.3" @@ -586,49 +587,59 @@ dependencies: eslint-visitor-keys "^3.3.0" -"@eslint-community/regexpp@^4.5.1", "@eslint-community/regexpp@^4.6.1": +"@eslint-community/regexpp@^4.10.0": version "4.10.0" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== -"@eslint/eslintrc@^2.1.4": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.4.tgz#388a269f0f25c1b6adc317b5a2c55714894c70ad" - integrity sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ== +"@eslint-community/regexpp@^4.11.0": + version "4.11.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.11.0.tgz#b0ffd0312b4a3fd2d6f77237e7248a5ad3a680ae" + integrity sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A== + +"@eslint/config-array@^0.17.0": + version "0.17.0" + resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.17.0.tgz#ff305e1ee618a00e6e5d0485454c8d92d94a860d" + integrity sha512-A68TBu6/1mHHuc5YJL0U0VVeGNiklLAL6rRmhTCP2B5XjWLMnrX+HkO+IAXyHvks5cyyY1jjK5ITPQ1HGS2EVA== + dependencies: + "@eslint/object-schema" "^2.1.4" + debug "^4.3.1" + minimatch "^3.1.2" + +"@eslint/eslintrc@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.1.0.tgz#dbd3482bfd91efa663cbe7aa1f506839868207b6" + integrity sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.6.0" - globals "^13.19.0" + espree "^10.0.1" + globals "^14.0.0" ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.56.0": - version "8.56.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.56.0.tgz#ef20350fec605a7f7035a01764731b2de0f3782b" - integrity sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A== +"@eslint/js@9.7.0": + version "9.7.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.7.0.tgz#b712d802582f02b11cfdf83a85040a296afec3f0" + integrity sha512-ChuWDQenef8OSFnvuxv0TCVxEwmu3+hPNKvM9B34qpM0rDRbjL8t5QkQeHHeAfsKQjuH9wS82WeCi1J/owatng== -"@humanwhocodes/config-array@^0.11.13": - version "0.11.13" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.13.tgz#075dc9684f40a531d9b26b0822153c1e832ee297" - integrity sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ== - dependencies: - "@humanwhocodes/object-schema" "^2.0.1" - debug "^4.1.1" - minimatch "^3.0.5" +"@eslint/object-schema@^2.1.4": + version "2.1.4" + resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.4.tgz#9e69f8bb4031e11df79e03db09f9dbbae1740843" + integrity sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ== "@humanwhocodes/module-importer@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== -"@humanwhocodes/object-schema@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz#e5211452df060fa8522b55c7b3c0c4d1981cb044" - integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw== +"@humanwhocodes/retry@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.3.0.tgz#6d86b8cb322660f03d3f0aa94b99bdd8e172d570" + integrity sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew== "@isaacs/cliui@^8.0.2": version "8.0.2" @@ -1024,70 +1035,85 @@ estree-walker "^2.0.2" picomatch "^2.3.1" -"@rollup/rollup-android-arm-eabi@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.12.0.tgz#38c3abd1955a3c21d492af6b1a1dca4bb1d894d6" - integrity sha512-+ac02NL/2TCKRrJu2wffk1kZ+RyqxVUlbjSagNgPm94frxtr+XDL12E5Ll1enWskLrtrZ2r8L3wED1orIibV/w== - -"@rollup/rollup-android-arm64@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.12.0.tgz#3822e929f415627609e53b11cec9a4be806de0e2" - integrity sha512-OBqcX2BMe6nvjQ0Nyp7cC90cnumt8PXmO7Dp3gfAju/6YwG0Tj74z1vKrfRz7qAv23nBcYM8BCbhrsWqO7PzQQ== - -"@rollup/rollup-darwin-arm64@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.12.0.tgz#6c082de71f481f57df6cfa3701ab2a7afde96f69" - integrity sha512-X64tZd8dRE/QTrBIEs63kaOBG0b5GVEd3ccoLtyf6IdXtHdh8h+I56C2yC3PtC9Ucnv0CpNFJLqKFVgCYe0lOQ== - -"@rollup/rollup-darwin-x64@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.12.0.tgz#c34ca0d31f3c46a22c9afa0e944403eea0edcfd8" - integrity sha512-cc71KUZoVbUJmGP2cOuiZ9HSOP14AzBAThn3OU+9LcA1+IUqswJyR1cAJj3Mg55HbjZP6OLAIscbQsQLrpgTOg== - -"@rollup/rollup-linux-arm-gnueabihf@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.12.0.tgz#48e899c1e438629c072889b824a98787a7c2362d" - integrity sha512-a6w/Y3hyyO6GlpKL2xJ4IOh/7d+APaqLYdMf86xnczU3nurFTaVN9s9jOXQg97BE4nYm/7Ga51rjec5nfRdrvA== - -"@rollup/rollup-linux-arm64-gnu@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.12.0.tgz#788c2698a119dc229062d40da6ada8a090a73a68" - integrity sha512-0fZBq27b+D7Ar5CQMofVN8sggOVhEtzFUwOwPppQt0k+VR+7UHMZZY4y+64WJ06XOhBTKXtQB/Sv0NwQMXyNAA== - -"@rollup/rollup-linux-arm64-musl@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.12.0.tgz#3882a4e3a564af9e55804beeb67076857b035ab7" - integrity sha512-eTvzUS3hhhlgeAv6bfigekzWZjaEX9xP9HhxB0Dvrdbkk5w/b+1Sxct2ZuDxNJKzsRStSq1EaEkVSEe7A7ipgQ== - -"@rollup/rollup-linux-riscv64-gnu@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.12.0.tgz#0c6ad792e1195c12bfae634425a3d2aa0fe93ab7" - integrity sha512-ix+qAB9qmrCRiaO71VFfY8rkiAZJL8zQRXveS27HS+pKdjwUfEhqo2+YF2oI+H/22Xsiski+qqwIBxVewLK7sw== - -"@rollup/rollup-linux-x64-gnu@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.12.0.tgz#9d62485ea0f18d8674033b57aa14fb758f6ec6e3" - integrity sha512-TenQhZVOtw/3qKOPa7d+QgkeM6xY0LtwzR8OplmyL5LrgTWIXpTQg2Q2ycBf8jm+SFW2Wt/DTn1gf7nFp3ssVA== - -"@rollup/rollup-linux-x64-musl@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.12.0.tgz#50e8167e28b33c977c1f813def2b2074d1435e05" - integrity sha512-LfFdRhNnW0zdMvdCb5FNuWlls2WbbSridJvxOvYWgSBOYZtgBfW9UGNJG//rwMqTX1xQE9BAodvMH9tAusKDUw== - -"@rollup/rollup-win32-arm64-msvc@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.12.0.tgz#68d233272a2004429124494121a42c4aebdc5b8e" - integrity sha512-JPDxovheWNp6d7AHCgsUlkuCKvtu3RB55iNEkaQcf0ttsDU/JZF+iQnYcQJSk/7PtT4mjjVG8N1kpwnI9SLYaw== - -"@rollup/rollup-win32-ia32-msvc@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.12.0.tgz#366ca62221d1689e3b55a03f4ae12ae9ba595d40" - integrity sha512-fjtuvMWRGJn1oZacG8IPnzIV6GF2/XG+h71FKn76OYFqySXInJtseAqdprVTDTyqPxQOG9Exak5/E9Z3+EJ8ZA== - -"@rollup/rollup-win32-x64-msvc@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.12.0.tgz#9ffdf9ed133a7464f4ae187eb9e1294413fab235" - integrity sha512-ZYmr5mS2wd4Dew/JjT0Fqi2NPB/ZhZ2VvPp7SmvPZb4Y1CG/LRcS6tcRo2cYU7zLK5A7cdbhWnnWmUjoI4qapg== +"@rollup/rollup-android-arm-eabi@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.1.tgz#f0da481244b7d9ea15296b35f7fe39cd81157396" + integrity sha512-lncuC4aHicncmbORnx+dUaAgzee9cm/PbIqgWz1PpXuwc+sa1Ct83tnqUDy/GFKleLiN7ZIeytM6KJ4cAn1SxA== + +"@rollup/rollup-android-arm64@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.1.tgz#82ab3c575f4235fb647abea5e08eec6cf325964e" + integrity sha512-F/tkdw0WSs4ojqz5Ovrw5r9odqzFjb5LIgHdHZG65dFI1lWTWRVy32KDJLKRISHgJvqUeUhdIvy43fX41znyDg== + +"@rollup/rollup-darwin-arm64@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.1.tgz#6a530452e68a9152809ce58de1f89597632a085b" + integrity sha512-vk+ma8iC1ebje/ahpxpnrfVQJibTMyHdWpOGZ3JpQ7Mgn/3QNHmPq7YwjZbIE7km73dH5M1e6MRRsnEBW7v5CQ== + +"@rollup/rollup-darwin-x64@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.18.1.tgz#47727479f5ca292cf434d7e75af2725b724ecbc7" + integrity sha512-IgpzXKauRe1Tafcej9STjSSuG0Ghu/xGYH+qG6JwsAUxXrnkvNHcq/NL6nz1+jzvWAnQkuAJ4uIwGB48K9OCGA== + +"@rollup/rollup-linux-arm-gnueabihf@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.18.1.tgz#46193c498aa7902a8db89ac00128060320e84fef" + integrity sha512-P9bSiAUnSSM7EmyRK+e5wgpqai86QOSv8BwvkGjLwYuOpaeomiZWifEos517CwbG+aZl1T4clSE1YqqH2JRs+g== + +"@rollup/rollup-linux-arm-musleabihf@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.18.1.tgz#22d831fe239643c1d05c98906420325cee439d85" + integrity sha512-5RnjpACoxtS+aWOI1dURKno11d7krfpGDEn19jI8BuWmSBbUC4ytIADfROM1FZrFhQPSoP+KEa3NlEScznBTyQ== + +"@rollup/rollup-linux-arm64-gnu@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.1.tgz#19abd33695ec9d588b4a858d122631433084e4a3" + integrity sha512-8mwmGD668m8WaGbthrEYZ9CBmPug2QPGWxhJxh/vCgBjro5o96gL04WLlg5BA233OCWLqERy4YUzX3bJGXaJgQ== + +"@rollup/rollup-linux-arm64-musl@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.18.1.tgz#d60af8c0b9be424424ff96a0ba19fce65d26f6ab" + integrity sha512-dJX9u4r4bqInMGOAQoGYdwDP8lQiisWb9et+T84l2WXk41yEej8v2iGKodmdKimT8cTAYt0jFb+UEBxnPkbXEQ== + +"@rollup/rollup-linux-powerpc64le-gnu@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.18.1.tgz#b1194e5ed6d138fdde0842d126fccde74a90f457" + integrity sha512-V72cXdTl4EI0x6FNmho4D502sy7ed+LuVW6Ym8aI6DRQ9hQZdp5sj0a2usYOlqvFBNKQnLQGwmYnujo2HvjCxQ== + +"@rollup/rollup-linux-riscv64-gnu@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.18.1.tgz#f5a635c017b9bff8b856b0221fbd5c0e3373b7ec" + integrity sha512-f+pJih7sxoKmbjghrM2RkWo2WHUW8UbfxIQiWo5yeCaCM0TveMEuAzKJte4QskBp1TIinpnRcxkquY+4WuY/tg== + +"@rollup/rollup-linux-s390x-gnu@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.1.tgz#f1043d9f4026bf6995863cb3f8dd4732606e4baa" + integrity sha512-qb1hMMT3Fr/Qz1OKovCuUM11MUNLUuHeBC2DPPAWUYYUAOFWaxInaTwTQmc7Fl5La7DShTEpmYwgdt2hG+4TEg== + +"@rollup/rollup-linux-x64-gnu@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.1.tgz#1e781730be445119f06c9df5f185e193bc82c610" + integrity sha512-7O5u/p6oKUFYjRbZkL2FLbwsyoJAjyeXHCU3O4ndvzg2OFO2GinFPSJFGbiwFDaCFc+k7gs9CF243PwdPQFh5g== + +"@rollup/rollup-linux-x64-musl@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.18.1.tgz#08f12e1965d6f27d6898ff932592121cca6abc4b" + integrity sha512-pDLkYITdYrH/9Cv/Vlj8HppDuLMDUBmgsM0+N+xLtFd18aXgM9Nyqupb/Uw+HeidhfYg2lD6CXvz6CjoVOaKjQ== + +"@rollup/rollup-win32-arm64-msvc@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.1.tgz#4a5dcbbe7af7d41cac92b09798e7c1831da1f599" + integrity sha512-W2ZNI323O/8pJdBGil1oCauuCzmVd9lDmWBBqxYZcOqWD6aWqJtVBQ1dFrF4dYpZPks6F+xCZHfzG5hYlSHZ6g== + +"@rollup/rollup-win32-ia32-msvc@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.1.tgz#075b0713de627843a73b4cf0e087c56b53e9d780" + integrity sha512-ELfEX1/+eGZYMaCIbK4jqLxO1gyTSOIlZr6pbC4SRYFaSIDVKOnZNMdoZ+ON0mrFDp4+H5MhwNC1H/AhE3zQLg== + +"@rollup/rollup-win32-x64-msvc@4.18.1": + version "4.18.1" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.1.tgz#0cb240c147c0dfd0e3eaff4cc060a772d39e155c" + integrity sha512-yjk2MAkQmoaPYCSu35RLJ62+dz358nE83VfTePJRp8CG7aMg25mEJYpXFiD+NcevhX8LxD5OP5tktPXnXN7GDw== "@sinclair/typebox@^0.25.16": version "0.25.24" @@ -1207,11 +1233,6 @@ expect "^29.0.0" pretty-format "^29.0.0" -"@types/json-schema@^7.0.12": - version "7.0.15" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" - integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== - "@types/json5@^0.0.29": version "0.0.29" resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" @@ -1227,10 +1248,10 @@ resolved "https://registry.npmjs.org/@types/node/-/node-16.7.1.tgz#c6b9198178da504dfca1fd0be9b2e1002f1586f0" integrity sha512-ncRdc45SoYJ2H4eWU9ReDfp3vtFqDYhjOsKlFFUDEn8V1Bgr2RjYal8YT5byfadWIRluhPFU6JiDOl0H6Sl87A== -"@types/node@20.11.19": - version "20.11.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.19.tgz#b466de054e9cb5b3831bee38938de64ac7f81195" - integrity sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ== +"@types/node@20.14.10": + version "20.14.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.10.tgz#a1a218290f1b6428682e3af044785e5874db469a" + integrity sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ== dependencies: undici-types "~5.26.4" @@ -1239,11 +1260,6 @@ resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975" integrity sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q== -"@types/semver@^7.5.0": - version "7.5.6" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.6.tgz#c65b2bfce1bec346582c07724e3f8c1017a20339" - integrity sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A== - "@types/stack-utils@^2.0.0": version "2.0.1" resolved "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" @@ -1261,96 +1277,86 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.0.2.tgz#c13a34057be425167cc4a765158c46fdf2fd981d" - integrity sha512-/XtVZJtbaphtdrWjr+CJclaCVGPtOdBpFEnvtNf/jRV0IiEemRrL0qABex/nEt8isYcnFacm3nPHYQwL+Wb7qg== - dependencies: - "@eslint-community/regexpp" "^4.5.1" - "@typescript-eslint/scope-manager" "7.0.2" - "@typescript-eslint/type-utils" "7.0.2" - "@typescript-eslint/utils" "7.0.2" - "@typescript-eslint/visitor-keys" "7.0.2" - debug "^4.3.4" +"@typescript-eslint/eslint-plugin@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.16.1.tgz#f5f5da52db674b1f2cdb9d5f3644e5b2ec750465" + integrity sha512-SxdPak/5bO0EnGktV05+Hq8oatjAYVY3Zh2bye9pGZy6+jwyR3LG3YKkV4YatlsgqXP28BTeVm9pqwJM96vf2A== + dependencies: + "@eslint-community/regexpp" "^4.10.0" + "@typescript-eslint/scope-manager" "7.16.1" + "@typescript-eslint/type-utils" "7.16.1" + "@typescript-eslint/utils" "7.16.1" + "@typescript-eslint/visitor-keys" "7.16.1" graphemer "^1.4.0" - ignore "^5.2.4" + ignore "^5.3.1" natural-compare "^1.4.0" - semver "^7.5.4" - ts-api-utils "^1.0.1" + ts-api-utils "^1.3.0" -"@typescript-eslint/parser@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.0.2.tgz#95c31233d343db1ca1df8df7811b5b87ca7b1a68" - integrity sha512-GdwfDglCxSmU+QTS9vhz2Sop46ebNCXpPPvsByK7hu0rFGRHL+AusKQJ7SoN+LbLh6APFpQwHKmDSwN35Z700Q== +"@typescript-eslint/parser@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.16.1.tgz#84c581cf86c8b2becd48d33ddc41a6303d57b274" + integrity sha512-u+1Qx86jfGQ5i4JjK33/FnawZRpsLxRnKzGE6EABZ40KxVT/vWsiZFEBBHjFOljmmV3MBYOHEKi0Jm9hbAOClA== dependencies: - "@typescript-eslint/scope-manager" "7.0.2" - "@typescript-eslint/types" "7.0.2" - "@typescript-eslint/typescript-estree" "7.0.2" - "@typescript-eslint/visitor-keys" "7.0.2" + "@typescript-eslint/scope-manager" "7.16.1" + "@typescript-eslint/types" "7.16.1" + "@typescript-eslint/typescript-estree" "7.16.1" + "@typescript-eslint/visitor-keys" "7.16.1" debug "^4.3.4" -"@typescript-eslint/scope-manager@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.0.2.tgz#6ec4cc03752758ddd1fdaae6fbd0ed9a2ca4fe63" - integrity sha512-l6sa2jF3h+qgN2qUMjVR3uCNGjWw4ahGfzIYsCtFrQJCjhbrDPdiihYT8FnnqFwsWX+20hK592yX9I2rxKTP4g== +"@typescript-eslint/scope-manager@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.16.1.tgz#2b43041caabf8ddd74512b8b550b9fc53ca3afa1" + integrity sha512-nYpyv6ALte18gbMz323RM+vpFpTjfNdyakbf3nsLvF43uF9KeNC289SUEW3QLZ1xPtyINJ1dIsZOuWuSRIWygw== dependencies: - "@typescript-eslint/types" "7.0.2" - "@typescript-eslint/visitor-keys" "7.0.2" + "@typescript-eslint/types" "7.16.1" + "@typescript-eslint/visitor-keys" "7.16.1" -"@typescript-eslint/type-utils@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.0.2.tgz#a7fc0adff0c202562721357e7478207d380a757b" - integrity sha512-IKKDcFsKAYlk8Rs4wiFfEwJTQlHcdn8CLwLaxwd6zb8HNiMcQIFX9sWax2k4Cjj7l7mGS5N1zl7RCHOVwHq2VQ== +"@typescript-eslint/type-utils@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.16.1.tgz#4d7ae4f3d9e3c8cbdabae91609b1a431de6aa6ca" + integrity sha512-rbu/H2MWXN4SkjIIyWcmYBjlp55VT+1G3duFOIukTNFxr9PI35pLc2ydwAfejCEitCv4uztA07q0QWanOHC7dA== dependencies: - "@typescript-eslint/typescript-estree" "7.0.2" - "@typescript-eslint/utils" "7.0.2" + "@typescript-eslint/typescript-estree" "7.16.1" + "@typescript-eslint/utils" "7.16.1" debug "^4.3.4" - ts-api-utils "^1.0.1" + ts-api-utils "^1.3.0" -"@typescript-eslint/types@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.0.2.tgz#b6edd108648028194eb213887d8d43ab5750351c" - integrity sha512-ZzcCQHj4JaXFjdOql6adYV4B/oFOFjPOC9XYwCaZFRvqN8Llfvv4gSxrkQkd2u4Ci62i2c6W6gkDwQJDaRc4nA== +"@typescript-eslint/types@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.16.1.tgz#bbab066276d18e398bc64067b23f1ce84dfc6d8c" + integrity sha512-AQn9XqCzUXd4bAVEsAXM/Izk11Wx2u4H3BAfQVhSfzfDOm/wAON9nP7J5rpkCxts7E5TELmN845xTUCQrD1xIQ== -"@typescript-eslint/typescript-estree@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.0.2.tgz#3c6dc8a3b9799f4ef7eca0d224ded01974e4cb39" - integrity sha512-3AMc8khTcELFWcKcPc0xiLviEvvfzATpdPj/DXuOGIdQIIFybf4DMT1vKRbuAEOFMwhWt7NFLXRkbjsvKZQyvw== +"@typescript-eslint/typescript-estree@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.1.tgz#9b145ba4fd1dde1986697e1ce57dc501a1736dd3" + integrity sha512-0vFPk8tMjj6apaAZ1HlwM8w7jbghC8jc1aRNJG5vN8Ym5miyhTQGMqU++kuBFDNKe9NcPeZ6x0zfSzV8xC1UlQ== dependencies: - "@typescript-eslint/types" "7.0.2" - "@typescript-eslint/visitor-keys" "7.0.2" + "@typescript-eslint/types" "7.16.1" + "@typescript-eslint/visitor-keys" "7.16.1" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" - minimatch "9.0.3" - semver "^7.5.4" - ts-api-utils "^1.0.1" + minimatch "^9.0.4" + semver "^7.6.0" + ts-api-utils "^1.3.0" -"@typescript-eslint/utils@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.0.2.tgz#8756123054cd934c8ba7db6a6cffbc654b10b5c4" - integrity sha512-PZPIONBIB/X684bhT1XlrkjNZJIEevwkKDsdwfiu1WeqBxYEEdIgVDgm8/bbKHVu+6YOpeRqcfImTdImx/4Bsw== +"@typescript-eslint/utils@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.16.1.tgz#df42dc8ca5a4603016fd102db0346cdab415cdb7" + integrity sha512-WrFM8nzCowV0he0RlkotGDujx78xudsxnGMBHI88l5J8wEhED6yBwaSLP99ygfrzAjsQvcYQ94quDwI0d7E1fA== dependencies: "@eslint-community/eslint-utils" "^4.4.0" - "@types/json-schema" "^7.0.12" - "@types/semver" "^7.5.0" - "@typescript-eslint/scope-manager" "7.0.2" - "@typescript-eslint/types" "7.0.2" - "@typescript-eslint/typescript-estree" "7.0.2" - semver "^7.5.4" + "@typescript-eslint/scope-manager" "7.16.1" + "@typescript-eslint/types" "7.16.1" + "@typescript-eslint/typescript-estree" "7.16.1" -"@typescript-eslint/visitor-keys@7.0.2": - version "7.0.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.0.2.tgz#2899b716053ad7094962beb895d11396fc12afc7" - integrity sha512-8Y+YiBmqPighbm5xA2k4wKTxRzx9EkBu7Rlw+WHqMvRJ3RPz/BMBO9b2ru0LUNmXg120PHUXD5+SWFy2R8DqlQ== +"@typescript-eslint/visitor-keys@7.16.1": + version "7.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.1.tgz#4287bcf44c34df811ff3bb4d269be6cfc7d8c74b" + integrity sha512-Qlzzx4sE4u3FsHTPQAAQFJFNOuqtuY0LFrZHwQ8IHK705XxBiWOFkfKRWu6niB7hwfgnwIpO4jTC75ozW1PHWg== dependencies: - "@typescript-eslint/types" "7.0.2" - eslint-visitor-keys "^3.4.1" - -"@ungap/structured-clone@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" - integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== + "@typescript-eslint/types" "7.16.1" + eslint-visitor-keys "^3.4.3" abstract-leveldown@~0.12.0, abstract-leveldown@~0.12.1: version "0.12.4" @@ -1364,10 +1370,15 @@ acorn-jsx@^5.3.2: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn@^8.9.0: - version "8.11.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b" - integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w== +acorn@^8.11.3: + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== + +acorn@^8.12.0: + version "8.12.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248" + integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg== ajv@^6.12.4: version "6.12.6" @@ -1523,6 +1534,11 @@ asn1.js@^5.2.0: minimalistic-assert "^1.0.0" safer-buffer "^2.1.0" +async@^3.2.3: + version "3.2.5" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.5.tgz#ebd52a8fdaf7a2289a24df399f8d8485c8a46b66" + integrity sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg== + available-typed-arrays@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" @@ -1811,7 +1827,7 @@ chalk@^2.0.0, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.0.2: version "4.1.2" resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -2034,10 +2050,10 @@ crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" -debug@4.3.4, debug@^4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== +debug@4.3.5: + version "4.3.5" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" + integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== dependencies: ms "2.1.2" @@ -2055,6 +2071,13 @@ debug@^4.1.0, debug@^4.1.1, debug@^4.3.2: dependencies: ms "2.1.2" +debug@^4.3.1, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + dedent@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff" @@ -2157,13 +2180,6 @@ doctrine@^2.1.0: dependencies: esutils "^2.0.2" -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" - dotenv@16.4.5: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" @@ -2174,6 +2190,13 @@ eastasianwidth@^0.2.0: resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== +ejs@^3.0.0: + version "3.1.10" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b" + integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA== + dependencies: + jake "^10.8.5" + electron-to-chromium@^1.4.17: version "1.4.38" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.38.tgz#10ea58d73d36b13e78d5024f3b74a352d3958d01" @@ -2352,10 +2375,10 @@ eslint-config-airbnb-base@^15.0.0: object.entries "^1.1.5" semver "^6.3.0" -eslint-config-airbnb-typescript@17.1.0: - version "17.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-17.1.0.tgz#fda960eee4a510f092a9a1c139035ac588937ddc" - integrity sha512-GPxI5URre6dDpJ0CtcthSZVBAfI+Uw7un5OYNVxP2EYi3H81Jw701yFP7AU+/vCE7xBtFmjge7kfhhk4+RAiig== +eslint-config-airbnb-typescript@18.0.0: + version "18.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-18.0.0.tgz#b1646db4134858d704b1d2bee47e1d72c180315f" + integrity sha512-oc+Lxzgzsu8FQyFVa4QFaVKiitTYiiW3frB9KYW5OWdPrqFc7FzxgB20hP4cHMlr+MBzGcLl3jnCOVOydL9mIg== dependencies: eslint-config-airbnb-base "^15.0.0" @@ -2382,7 +2405,14 @@ eslint-import-resolver-node@^0.3.9: is-core-module "^2.13.0" resolve "^1.22.4" -eslint-module-utils@2.8.0, eslint-module-utils@^2.8.0: +eslint-module-utils@2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz#52f2404300c3bd33deece9d7372fb337cc1d7c34" + integrity sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q== + dependencies: + debug "^3.2.7" + +eslint-module-utils@^2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz#e439fee65fc33f6bba630ff621efc38ec0375c49" integrity sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw== @@ -2420,10 +2450,10 @@ eslint-plugin-prettier@5.1.3: prettier-linter-helpers "^1.0.0" synckit "^0.8.6" -eslint-scope@^7.2.2: - version "7.2.2" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" - integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== +eslint-scope@^8.0.2: + version "8.0.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.0.2.tgz#5cbb33d4384c9136083a71190d548158fe128f94" + integrity sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" @@ -2433,51 +2463,47 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint-visitor-keys@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" - integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== - eslint-visitor-keys@^3.4.3: version "3.4.3" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@8.56.0: - version "8.56.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.56.0.tgz#4957ce8da409dc0809f99ab07a1b94832ab74b15" - integrity sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ== +eslint-visitor-keys@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz#e3adc021aa038a2a8e0b2f8b0ce8f66b9483b1fb" + integrity sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw== + +eslint@9.7.0: + version "9.7.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.7.0.tgz#bedb48e1cdc2362a0caaa106a4c6ed943e8b09e4" + integrity sha512-FzJ9D/0nGiCGBf8UXO/IGLTgLVzIxze1zpfA8Ton2mjLovXdAPlYDv+MQDcqj3TmrhAGYfOpz9RfR+ent0AgAw== dependencies: "@eslint-community/eslint-utils" "^4.2.0" - "@eslint-community/regexpp" "^4.6.1" - "@eslint/eslintrc" "^2.1.4" - "@eslint/js" "8.56.0" - "@humanwhocodes/config-array" "^0.11.13" + "@eslint-community/regexpp" "^4.11.0" + "@eslint/config-array" "^0.17.0" + "@eslint/eslintrc" "^3.1.0" + "@eslint/js" "9.7.0" "@humanwhocodes/module-importer" "^1.0.1" + "@humanwhocodes/retry" "^0.3.0" "@nodelib/fs.walk" "^1.2.8" - "@ungap/structured-clone" "^1.2.0" ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.3.2" - doctrine "^3.0.0" escape-string-regexp "^4.0.0" - eslint-scope "^7.2.2" - eslint-visitor-keys "^3.4.3" - espree "^9.6.1" - esquery "^1.4.2" + eslint-scope "^8.0.2" + eslint-visitor-keys "^4.0.0" + espree "^10.1.0" + esquery "^1.5.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" + file-entry-cache "^8.0.0" find-up "^5.0.0" glob-parent "^6.0.2" - globals "^13.19.0" - graphemer "^1.4.0" ignore "^5.2.0" imurmurhash "^0.1.4" is-glob "^4.0.0" is-path-inside "^3.0.3" - js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" @@ -2487,24 +2513,33 @@ eslint@8.56.0: strip-ansi "^6.0.1" text-table "^0.2.0" -espree@^9.6.0, espree@^9.6.1: - version "9.6.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" - integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== +espree@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.0.1.tgz#600e60404157412751ba4a6f3a2ee1a42433139f" + integrity sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww== dependencies: - acorn "^8.9.0" + acorn "^8.11.3" acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.4.1" + eslint-visitor-keys "^4.0.0" + +espree@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.1.0.tgz#8788dae611574c0f070691f522e4116c5a11fc56" + integrity sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA== + dependencies: + acorn "^8.12.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^4.0.0" esprima@^4.0.0: version "4.0.1" resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.4.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" - integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== +esquery@^1.5.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" + integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== dependencies: estraverse "^5.1.0" @@ -2636,12 +2671,19 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" -file-entry-cache@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" - integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== +file-entry-cache@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-8.0.0.tgz#7787bddcf1131bffb92636c69457bbc0edd6d81f" + integrity sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ== + dependencies: + flat-cache "^4.0.0" + +filelist@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.4.tgz#f78978a1e944775ff9e62e744424f215e58352b5" + integrity sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q== dependencies: - flat-cache "^3.0.4" + minimatch "^5.0.1" fill-range@^7.0.1: version "7.0.1" @@ -2666,18 +2708,18 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" -flat-cache@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" - integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== +flat-cache@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-4.0.1.tgz#0ece39fcb14ee012f4b0410bd33dd9c1f011127c" + integrity sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw== dependencies: - flatted "^3.1.0" - rimraf "^3.0.2" + flatted "^3.2.9" + keyv "^4.5.4" -flatted@^3.1.0: - version "3.2.2" - resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561" - integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA== +flatted@^3.2.9: + version "3.3.1" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" + integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== for-each@^0.3.3: version "0.3.3" @@ -2872,12 +2914,10 @@ globals@^11.1.0: resolved "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.19.0: - version "13.20.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82" - integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ== - dependencies: - type-fest "^0.20.2" +globals@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" + integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== globalthis@^1.0.3: version "1.0.3" @@ -3035,10 +3075,10 @@ ignore@^5.2.0: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== -ignore@^5.2.4: - version "5.3.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" - integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg== +ignore@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" + integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw== import-fresh@^3.2.1: version "3.3.0" @@ -3417,6 +3457,16 @@ jackspeak@^2.3.5: optionalDependencies: "@pkgjs/parseargs" "^0.11.0" +jake@^10.8.5: + version "10.9.1" + resolved "https://registry.yarnpkg.com/jake/-/jake-10.9.1.tgz#8dc96b7fcc41cb19aa502af506da4e1d56f5e62b" + integrity sha512-61btcOHNnLnsOdtLgA5efqQWjnSi/vow5HbI7HMdKKWqvrKR1bLK3BPlJn9gcSaP2ewuamUSMB5XEy76KUIS2w== + dependencies: + async "^3.2.3" + chalk "^4.0.2" + filelist "^1.0.4" + minimatch "^3.1.2" + jest-changed-files@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" @@ -3861,6 +3911,11 @@ jsesc@^2.5.1: resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== +json-buffer@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" + integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== + json-parse-even-better-errors@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" @@ -3900,6 +3955,13 @@ json5@^2.2.3: resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== +keyv@^4.5.4: + version "4.5.4" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" + integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== + dependencies: + json-buffer "3.0.1" + kleur@^3.0.3: version "3.0.3" resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" @@ -4049,7 +4111,14 @@ ltgt@^2.1.2: resolved "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" integrity sha1-81ypHEk/e3PaDgdJUwTxezH4fuU= -magic-string@^0.30.3, magic-string@^0.30.4: +magic-string@^0.30.10: + version "0.30.10" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.10.tgz#123d9c41a0cb5640c892b041d4cfb3bd0aa4b39e" + integrity sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ== + dependencies: + "@jridgewell/sourcemap-codec" "^1.4.15" + +magic-string@^0.30.3: version "0.30.5" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.5.tgz#1994d980bd1c8835dc6e78db7cbd4ae4f24746f9" integrity sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA== @@ -4125,13 +4194,6 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@9.0.3: - version "9.0.3" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" - integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== - dependencies: - brace-expansion "^2.0.1" - minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -4139,7 +4201,7 @@ minimatch@^3.0.3, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimatch@^3.0.5, minimatch@^3.1.2: +minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -4160,6 +4222,13 @@ minimatch@^9.0.1: dependencies: brace-expansion "^2.0.1" +minimatch@^9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" + integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -4498,10 +4567,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@3.2.5: - version "3.2.5" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" - integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== +prettier@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" + integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew== pretty-format@^29.0.0, pretty-format@^29.5.0: version "29.5.0" @@ -4705,20 +4774,13 @@ reusify@^1.0.4: resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.5.tgz#9be65d2d6e683447d2e9013da2bf451139a61ccf" - integrity sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A== +rimraf@5.0.7: + version "5.0.7" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.7.tgz#27bddf202e7d89cb2e0381656380d1734a854a74" + integrity sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg== dependencies: glob "^10.3.7" -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.2" resolved "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" @@ -4727,14 +4789,14 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" -rollup-plugin-dts@6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.0.tgz#56e9c5548dac717213c6a4aa9df523faf04f75ae" - integrity sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw== +rollup-plugin-dts@6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.1.tgz#46b33f4d1d7f4e66f1171ced9b282ac11a15a254" + integrity sha512-aSHRcJ6KG2IHIioYlvAOcEq6U99sVtqDDKVhnwt70rW6tsz3tv5OSjEiWcgzfsHdLyGXZ/3b/7b/+Za3Y6r1XA== dependencies: - magic-string "^0.30.4" + magic-string "^0.30.10" optionalDependencies: - "@babel/code-frame" "^7.22.13" + "@babel/code-frame" "^7.24.2" rollup-plugin-node-builtins@2.1.2: version "2.1.2" @@ -4763,26 +4825,29 @@ rollup-plugin-terser@7.0.2: serialize-javascript "^4.0.0" terser "^5.0.0" -rollup@4.12.0: - version "4.12.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.12.0.tgz#0b6d1e5f3d46bbcf244deec41a7421dc54cc45b5" - integrity sha512-wz66wn4t1OHIJw3+XU7mJJQV/2NAfw5OAk6G6Hoo3zcvz/XOfQ52Vgi+AN4Uxoxi0KBBwk2g8zPrTDA4btSB/Q== +rollup@4.18.1: + version "4.18.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.18.1.tgz#18a606df5e76ca53b8a69f2d8eab256d69dda851" + integrity sha512-Elx2UT8lzxxOXMpy5HWQGZqkrQOtrVDDa/bm9l10+U4rQnVzbL/LgZ4NOM1MPIDyHk69W4InuYDF5dzRh4Kw1A== dependencies: "@types/estree" "1.0.5" optionalDependencies: - "@rollup/rollup-android-arm-eabi" "4.12.0" - "@rollup/rollup-android-arm64" "4.12.0" - "@rollup/rollup-darwin-arm64" "4.12.0" - "@rollup/rollup-darwin-x64" "4.12.0" - "@rollup/rollup-linux-arm-gnueabihf" "4.12.0" - "@rollup/rollup-linux-arm64-gnu" "4.12.0" - "@rollup/rollup-linux-arm64-musl" "4.12.0" - "@rollup/rollup-linux-riscv64-gnu" "4.12.0" - "@rollup/rollup-linux-x64-gnu" "4.12.0" - "@rollup/rollup-linux-x64-musl" "4.12.0" - "@rollup/rollup-win32-arm64-msvc" "4.12.0" - "@rollup/rollup-win32-ia32-msvc" "4.12.0" - "@rollup/rollup-win32-x64-msvc" "4.12.0" + "@rollup/rollup-android-arm-eabi" "4.18.1" + "@rollup/rollup-android-arm64" "4.18.1" + "@rollup/rollup-darwin-arm64" "4.18.1" + "@rollup/rollup-darwin-x64" "4.18.1" + "@rollup/rollup-linux-arm-gnueabihf" "4.18.1" + "@rollup/rollup-linux-arm-musleabihf" "4.18.1" + "@rollup/rollup-linux-arm64-gnu" "4.18.1" + "@rollup/rollup-linux-arm64-musl" "4.18.1" + "@rollup/rollup-linux-powerpc64le-gnu" "4.18.1" + "@rollup/rollup-linux-riscv64-gnu" "4.18.1" + "@rollup/rollup-linux-s390x-gnu" "4.18.1" + "@rollup/rollup-linux-x64-gnu" "4.18.1" + "@rollup/rollup-linux-x64-musl" "4.18.1" + "@rollup/rollup-win32-arm64-msvc" "4.18.1" + "@rollup/rollup-win32-ia32-msvc" "4.18.1" + "@rollup/rollup-win32-x64-msvc" "4.18.1" fsevents "~2.3.2" run-parallel@^1.1.9: @@ -4848,6 +4913,11 @@ semver@^7.5.3, semver@^7.5.4: dependencies: lru-cache "^6.0.0" +semver@^7.6.0: + version "7.6.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13" + integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w== + semver@~2.3.1: version "2.3.2" resolved "https://registry.npmjs.org/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52" @@ -4943,10 +5013,10 @@ sort-object-keys@^1.1.3: resolved "https://registry.npmjs.org/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45" integrity sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg== -sort-package-json@2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.8.0.tgz#6a46439ad0fef77f091e678e103f03ecbea575c8" - integrity sha512-PxeNg93bTJWmDGnu0HADDucoxfFiKkIr73Kv85EBThlI1YQPdc0XovBgg2llD0iABZbu2SlKo8ntGmOP9wOj/g== +sort-package-json@2.10.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.10.0.tgz#6be07424bf3b7db9fbb1bdd69e7945f301026d8a" + integrity sha512-MYecfvObMwJjjJskhxYfuOADkXp1ZMMnCFC8yhp+9HDsk7HhR336hd7eiBs96lTXfiqmUNI+WQCeCMRBhl251g== dependencies: detect-indent "^7.0.1" detect-newline "^4.0.0" @@ -4954,6 +5024,7 @@ sort-package-json@2.8.0: git-hooks-list "^3.0.0" globby "^13.1.2" is-plain-obj "^4.1.0" + semver "^7.6.0" sort-object-keys "^1.1.3" source-map-support@0.5.13: @@ -5236,17 +5307,18 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= -ts-api-utils@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" - integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg== +ts-api-utils@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1" + integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ== -ts-jest@29.1.2: - version "29.1.2" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.2.tgz#7613d8c81c43c8cb312c6904027257e814c40e09" - integrity sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g== +ts-jest@29.2.2: + version "29.2.2" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.2.2.tgz#0d2387bb04d39174b20a05172a968f258aedff4d" + integrity sha512-sSW7OooaKT34AAngP6k1VS669a0HdLxkQZnlC7T76sckGCokXFnvJ3yRlQZGRTAoV5K19HfSgCiSwWOSIfcYlg== dependencies: bs-logger "0.x" + ejs "^3.0.0" fast-json-stable-stringify "2.x" jest-util "^29.0.0" json5 "^2.2.3" @@ -5265,7 +5337,12 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@2.6.2, tslib@^2.6.2: +tslib@2.6.3: + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== + +tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== @@ -5282,11 +5359,6 @@ type-detect@4.0.8: resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - type-fest@^0.21.3: version "0.21.3" resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" @@ -5341,10 +5413,10 @@ typedarray@^0.0.6: resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@5.3.3: - version "5.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" - integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== +typescript@5.5.3: + version "5.5.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa" + integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ== unbox-primitive@^1.0.1: version "1.0.1"