tsdav
Version:
WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser
2 lines (1 loc) • 40.4 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("debug"),r=require("xml-js"),a=require("cross-fetch"),s=require("base-64");exports.DAVNamespace=void 0,(e=exports.DAVNamespace||(exports.DAVNamespace={})).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:";const o={[exports.DAVNamespace.CALDAV]:"xmlns:c",[exports.DAVNamespace.CARDDAV]:"xmlns:card",[exports.DAVNamespace.CALENDAR_SERVER]:"xmlns:cs",[exports.DAVNamespace.CALDAV_APPLE]:"xmlns:ca",[exports.DAVNamespace.DAV]:"xmlns:d"};var c,n;exports.DAVNamespaceShort=void 0,(c=exports.DAVNamespaceShort||(exports.DAVNamespaceShort={})).CALDAV="c",c.CARDDAV="card",c.CALENDAR_SERVER="cs",c.CALDAV_APPLE="ca",c.DAV="d",function(e){e.VEVENT="VEVENT",e.VTODO="VTODO",e.VJOURNAL="VJOURNAL",e.VFREEBUSY="VFREEBUSY",e.VTIMEZONE="VTIMEZONE",e.VALARM="VALARM"}(n||(n={}));const d="undefined"!=typeof globalThis&&"function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):a,i=e=>{const t=Number(e);if(!Number.isNaN(t))return t;const r=e.toLowerCase();return"true"===r||"false"!==r&&e},l=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),a=t.trim();if(Math.abs(r.length-a.length)>1)return!1;const s="/"===r.slice(-1)?r.slice(0,-1):r,o="/"===a.slice(-1)?a.slice(0,-1):a;return e.includes(o)||t.includes(s)},h=(e,t)=>{if(!e&&!t)return!0;if(!e||!t)return!1;const r=e.trim(),a=t.trim(),s="/"===r.slice(-1)?r.slice(0,-1):r,o="/"===a.slice(-1)?a.slice(0,-1):a;return e.includes(o)||t.includes(s)},p=e=>e.reduce((e,t)=>({...e,[o[t]]:t}),{}),u=e=>Object.entries(e).reduce((e,[t,r])=>r?{...e,[t]:r}:e,{}),f=(e,t)=>t?{[e]:t}:{},v=(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:u,conditionalParam:f,excludeHeaders:v,getDAVAttribute:p,urlContains:h,urlEquals:l});const A=t("tsdav:request"),O=async e=>{var t;const{url:a,init:s,convertIncoming:o=!0,parseOutgoing:c=!0,fetchOptions:n={},fetch:l}=e,h=null!=l?l:d,{headers:p={},body:f,namespace:v,method:m,attributes:O}=s,y=o?r.js2xml({_declaration:{_attributes:{version:"1.0",encoding:"utf-8"}},...f,_attributes:O},{compact:!0,spaces:2,elementNameFn:e=>v&&!/^.+:.+/.test(e)?`${v}:${e}`:e}):f,D={...n};delete D.headers;const V=await h(a,{headers:{"Content-Type":"text/xml;charset=UTF-8",...u(p),...n.headers||{}},body:y,method:m,...D}),x=await V.text();if(!(V.ok&&(null===(t=V.headers.get("content-type"))||void 0===t?void 0:t.includes("xml"))&&c&&x))return[{href:V.url,ok:V.ok,status:V.status,statusText:V.statusText,raw:x}];const C=r.xml2js(x,{compact:!0,trim:!0,textFn:(e,t)=>{try{const r=t._parent,a=Object.keys(r),s=a[a.length-1],o=r[s];if(o.length>0){o[o.length-1]=i(e)}else r[s]=i(e)}catch(e){A(e.stack)}},elementNameFn:e=>e.replace(/^.+:/,"").replace(/([-_]\w)/g,e=>e[1].toUpperCase()),attributesFn:e=>{const t={...e};return delete t.xmlns,t},ignoreDeclaration:!0});return(Array.isArray(C.multistatus.response)?C.multistatus.response:[C.multistatus.response]).map(e=>{var t,r;if(!e)return{status:V.status,statusText:V.statusText,ok:V.ok};const a=/^\S+\s(?<status>\d+)\s(?<statusText>.+)$/.exec(e.status);return{raw:C,href:e.href,status:(null==a?void 0:a.groups)?Number.parseInt(null==a?void 0:a.groups.status,10):V.status,statusText:null!==(r=null===(t=null==a?void 0:a.groups)||void 0===t?void 0:t.statusText)&&void 0!==r?r:V.statusText,ok:!e.error,error:e.error,responsedescription:e.responsedescription,props:(Array.isArray(e.propstat)?e.propstat:[e.propstat]).reduce((e,t)=>({...e,...null==t?void 0:t.prop}),{})}})},y=async e=>{const{url:t,props:r,depth:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e;return O({url:t,init:{method:"PROPFIND",headers:v(u({depth:a,...s}),o),namespace:exports.DAVNamespaceShort.DAV,body:{propfind:{_attributes:p([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALDAV_APPLE,exports.DAVNamespace.CALENDAR_SERVER,exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),prop:r}}},fetchOptions:c,fetch:n})},D=async e=>{const{url:t,data:r,headers:a,headersToExclude:s,fetchOptions:o={},fetch:c}=e;return(null!=c?c:d)(t,{method:"PUT",body:r,headers:v(a,s),...o})},V=async e=>{const{url:t,data:r,etag:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e;return(null!=n?n:d)(t,{method:"PUT",body:r,headers:v(u({"If-Match":a,...s}),o),...c})},x=async e=>{const{url:t,headers:r,etag:a,headersToExclude:s,fetchOptions:o={},fetch:c}=e;return(null!=c?c:d)(t,{method:"DELETE",headers:v(u({"If-Match":a,...r}),s),...o})};var C=Object.freeze({__proto__:null,createObject:D,davRequest:O,deleteObject:x,propfind:y,updateObject:V});function g(e,t){const r=e=>t.every(t=>e[t]);return Array.isArray(e)?e.every(e=>r(e)):r(e)}const b=(e,t)=>t.reduce((t,r)=>e[r]?t:`${t.length?`${t},`:""}${r.toString()}`,""),w=t("tsdav:collection"),S=async e=>{const{url:t,body:r,depth:a,defaultNamespace:s=exports.DAVNamespaceShort.DAV,headers:o,headersToExclude:c,fetchOptions:n={},fetch:d}=e,i=await O({url:t,init:{method:"REPORT",headers:v(u({depth:a,...o}),c),namespace:s,body:r},fetchOptions:n,fetch:d}),l=i.find(e=>!e.ok||e.status&&e.status>=400);if(l)throw new Error(`Collection query failed: ${l.status} ${l.statusText}. ${l.raw?`Raw response: ${l.raw}`:""}`);return 1===i.length&&!i[0].raw&&i[0].status&&i[0].status<300?[]:i},N=async e=>{const{url:t,props:r,depth:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e;return O({url:t,init:{method:"MKCOL",headers:v(u({depth:a,...s}),o),namespace:exports.DAVNamespaceShort.DAV,body:r?{mkcol:{set:{prop:r}}}:void 0},fetchOptions:c,fetch:n})},$=async e=>{var t,r,a,s,o;const{collection:c,headers:n,headersToExclude:d,fetchOptions:i={},fetch:l}=e;return null!==(o=null===(s=null===(a=null===(r=null===(t=(await y({url:c.url,props:{[`${exports.DAVNamespaceShort.DAV}:supported-report-set`]:{}},depth:"0",headers:v(n,d),fetchOptions:i,fetch:l}))[0])||void 0===t?void 0:t.props)||void 0===r?void 0:r.supportedReportSet)||void 0===a?void 0:a.supportedReport)||void 0===s?void 0:s.map(e=>Object.keys(e.report)[0]))&&void 0!==o?o:[]},T=async e=>{var t,r,a;const{collection:s,headers:o,headersToExclude:c,fetchOptions:n={},fetch:d}=e,i=(await y({url:s.url,props:{[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{}},depth:"0",headers:v(o,c),fetchOptions:n,fetch:d})).filter(e=>h(s.url,e.href))[0];if(!i)throw new Error("Collection does not exist on server");return{isDirty:`${s.ctag}`!=`${null===(t=i.props)||void 0===t?void 0:t.getctag}`,newCtag:null===(a=null===(r=i.props)||void 0===r?void 0:r.getctag)||void 0===a?void 0:a.toString()}},E=e=>{const{url:t,props:r,headers:a,syncLevel:s,syncToken:o,headersToExclude:c,fetchOptions:n,fetch:d}=e;return O({url:t,init:{method:"REPORT",namespace:exports.DAVNamespaceShort.DAV,headers:v({...a},c),body:{"sync-collection":{_attributes:p([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),"sync-level":s,"sync-token":o,[`${exports.DAVNamespaceShort.DAV}:prop`]:r}}},fetchOptions:n,fetch:d})},k=async e=>{var t,r,a,s,o,c,n,d,i,l,p,u;const{collection:f,method:m,headers:A,headersToExclude:O,account:y,detailedResult:D,fetchOptions:V={},fetch:x}=e,C=["accountType","homeUrl"];if(!y||!g(y,C)){if(!y)throw new Error("no account for smartCollectionSync");throw new Error(`account must have ${b(y,C)} before smartCollectionSync`)}const S=null!=m?m:(null===(t=f.reports)||void 0===t?void 0:t.includes("syncCollection"))?"webdav":"basic";if(w(`smart collection sync with type ${y.accountType} and method ${S}`),"webdav"===S){const e=await E({url:f.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${"caldav"===y.accountType?exports.DAVNamespaceShort.CALDAV:exports.DAVNamespaceShort.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{},[`${exports.DAVNamespaceShort.DAV}:displayname`]:{}},syncLevel:1,syncToken:f.syncToken,headers:v(A,O),fetchOptions:V,fetch:x}),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}),i=t.filter(e=>404!==e.status).map(e=>e.href),l=t.filter(e=>404===e.status).map(e=>e.href),p=(i.length&&null!==(a=await(null===(r=null==f?void 0:f.objectMultiGet)||void 0===r?void 0:r.call(f,{url:f.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${"caldav"===y.accountType?exports.DAVNamespaceShort.CALDAV:exports.DAVNamespaceShort.CARDDAV}:${"caldav"===y.accountType?"calendar-data":"address-data"}`]:{}},objectUrls:i,depth:"1",headers:v(A,O),fetchOptions:V,fetch:x})))&&void 0!==a?a:[]).map(e=>{var t,r,a,s,o,c,n,d,i,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===(s=null===(a=e.props)||void 0===a?void 0:a.calendarData)||void 0===s?void 0:s._cdata)&&void 0!==o?o:null===(c=e.props)||void 0===c?void 0:c.calendarData:null!==(i=null===(d=null===(n=e.props)||void 0===n?void 0:n.addressData)||void 0===d?void 0:d._cdata)&&void 0!==i?i:null===(l=e.props)||void 0===l?void 0:l.addressData}}),u=null!==(s=f.objects)&&void 0!==s?s:[],m=p.filter(e=>u.every(t=>!h(t.url,e.url))),C=u.reduce((e,t)=>{const r=p.find(e=>h(e.url,t.url));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e},[]),g=l.map(e=>({url:e,etag:""})),b=u.filter(e=>p.some(t=>h(e.url,t.url)&&t.etag===e.etag));return{...f,objects:D?{created:m,updated:C,deleted:g}:[...b,...m,...C],syncToken:null!==(d=null===(n=null===(c=null===(o=e[0])||void 0===o?void 0:o.raw)||void 0===c?void 0:c.multistatus)||void 0===n?void 0:n.syncToken)&&void 0!==d?d:f.syncToken}}if("basic"===S){const{isDirty:e,newCtag:t}=await T({collection:f,headers:v(A,O),fetchOptions:V,fetch:x}),r=null!==(i=f.objects)&&void 0!==i?i:[],a=null!==(u=await(null===(p=(l=f).fetchObjects)||void 0===p?void 0:p.call(l,{collection:f,headers:v(A,O),fetchOptions:V,fetch:x})))&&void 0!==u?u:[],s=a.filter(e=>r.every(t=>!h(t.url,e.url))),o=r.reduce((e,t)=>{const r=a.find(e=>h(e.url,t.url));return r&&r.etag&&r.etag!==t.etag?[...e,r]:e},[]),c=r.filter(e=>a.every(t=>!h(t.url,e.url))),n=r.filter(e=>a.some(t=>h(e.url,t.url)&&t.etag===e.etag));if(e)return{...f,objects:D?{created:s,updated:o,deleted:c}:[...n,...s,...o],ctag:t}}return D?{...f,objects:{created:[],updated:[],deleted:[]}}:f};var U=Object.freeze({__proto__:null,collectionQuery:S,isCollectionDirty:T,makeCollection:N,smartCollectionSync:k,supportedReportSet:$,syncCollection:E});const _=t("tsdav:addressBook"),R=async e=>{const{url:t,props:r,filters:a,depth:s,headers:o,headersToExclude:c,fetchOptions:n={},fetch:d}=e;return S({url:t,body:{"addressbook-query":u({_attributes:p([exports.DAVNamespace.CARDDAV,exports.DAVNamespace.DAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,filter:null!=a?a:{"prop-filter":{_attributes:{name:"FN"}}}})},defaultNamespace:exports.DAVNamespaceShort.CARDDAV,depth:s,headers:v(o,c),fetchOptions:n,fetch:d})},j=async e=>{const{url:t,props:r,objectUrls:a,depth:s,headers:o,headersToExclude:c,fetchOptions:n={},fetch:d}=e;return S({url:t,body:{"addressbook-multiget":u({_attributes:p([exports.DAVNamespace.DAV,exports.DAVNamespace.CARDDAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,[`${exports.DAVNamespaceShort.DAV}:href`]:a})},defaultNamespace:exports.DAVNamespaceShort.CARDDAV,depth:s,headers:v(o,c),fetchOptions:n,fetch:d})},L=async e=>{const{account:t,headers:r,props:a,headersToExclude:s,fetchOptions:o={},fetch:c}=null!=e?e:{},n=["homeUrl","rootUrl"];if(!t||!g(t,n)){if(!t)throw new Error("no account for fetchAddressBooks");throw new Error(`account must have ${b(t,n)} before fetchAddressBooks`)}const d=await y({url:t.homeUrl,props:null!=a?a:{[`${exports.DAVNamespaceShort.DAV}:displayname`]:{},[`${exports.DAVNamespaceShort.CALENDAR_SERVER}:getctag`]:{},[`${exports.DAVNamespaceShort.DAV}:resourcetype`]:{},[`${exports.DAVNamespaceShort.DAV}:sync-token`]:{}},depth:"1",headers:v(r,s),fetchOptions:o,fetch:c});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,a,s,o,c,n,d,i,l;const h=null!==(s=null===(a=null===(r=e.props)||void 0===r?void 0:r.displayname)||void 0===a?void 0:a._cdata)&&void 0!==s?s:null===(o=e.props)||void 0===o?void 0:o.displayname;return _(`Found address book named ${"string"==typeof h?h:""},\n props: ${JSON.stringify(e.props)}`),{url:new URL(null!==(c=e.href)&&void 0!==c?c:"",null!==(n=t.rootUrl)&&void 0!==n?n:"").href,ctag:null===(d=e.props)||void 0===d?void 0:d.getctag,displayName:"string"==typeof h?h:"",resourcetype:Object.keys(null===(i=e.props)||void 0===i?void 0:i.resourcetype),syncToken:null===(l=e.props)||void 0===l?void 0:l.syncToken}}).map(async e=>({...e,reports:await $({collection:e,headers:v(r,s),fetchOptions:o,fetch:c})})))},H=async e=>{const{addressBook:t,headers:r,objectUrls:a,headersToExclude:s,urlFilter:o=e=>e,useMultiGet:c=!0,fetchOptions:n={},fetch:d}=e;_(`Fetching vcards from ${null==t?void 0:t.url}`);const i=["url"];if(!t||!g(t,i)){if(!t)throw new Error("cannot fetchVCards for undefined addressBook");throw new Error(`addressBook must have ${b(t,i)} before fetchVCards`)}const h=(null!=a?a:(await R({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{}},depth:"1",headers:v(r,s),fetchOptions:n,fetch:d})).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(e=>e&&!l(e,t.url)).filter(o).map(e=>new URL(e).pathname);let p=[];return h.length>0&&(p=c?await j({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]:{}},objectUrls:h,depth:"1",headers:v(r,s),fetchOptions:n,fetch:d}):await R({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CARDDAV}:address-data`]:{}},depth:"1",headers:v(r,s),fetchOptions:n,fetch:d})),p.map(e=>{var r,a,s,o,c,n;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:null===(a=e.props)||void 0===a?void 0:a.getetag,data:null!==(c=null===(o=null===(s=e.props)||void 0===s?void 0:s.addressData)||void 0===o?void 0:o._cdata)&&void 0!==c?c:null===(n=e.props)||void 0===n?void 0:n.addressData}})},B=async e=>{const{addressBook:t,vCardString:r,filename:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e;return D({url:new URL(a,t.url).href,data:r,headers:v({"content-type":"text/vcard; charset=utf-8","If-None-Match":"*",...s},o),fetchOptions:c,fetch:n})},P=async e=>{const{vCard:t,headers:r,headersToExclude:a,fetchOptions:s={},fetch:o}=e;return V({url:t.url,data:t.data,etag:t.etag,headers:v({"content-type":"text/vcard; charset=utf-8",...r},a),fetchOptions:s,fetch:o})},F=async e=>{const{vCard:t,headers:r,headersToExclude:a,fetchOptions:s={},fetch:o}=e;return x({url:t.url,etag:t.etag,headers:v(r,a),fetchOptions:s,fetch:o})};var M=Object.freeze({__proto__:null,addressBookMultiGet:j,addressBookQuery:R,createVCard:B,deleteVCard:F,fetchAddressBooks:L,fetchVCards:H,updateVCard:P});const I=t("tsdav:calendar"),z=async e=>{var t,r,a;const{account:s,headers:o,headersToExclude:c,fetchOptions:n={},fetch:d}=e,i=["principalUrl","rootUrl"];if(!g(s,i))throw new Error(`account must have ${b(s,i)} before fetchUserAddresses`);I(`Fetch user addresses from ${s.principalUrl}`);const l=(await y({url:s.principalUrl,props:{[`${exports.DAVNamespaceShort.CALDAV}:calendar-user-address-set`]:{}},depth:"0",headers:v(o,c),fetchOptions:n,fetch:d})).find(e=>h(s.principalUrl,e.href));if(!l||!l.ok)throw new Error("cannot find calendarUserAddresses");const p=(null===(a=null===(r=null===(t=null==l?void 0:l.props)||void 0===t?void 0:t.calendarUserAddressSet)||void 0===r?void 0:r.href)||void 0===a?void 0:a.filter(Boolean))||[];return I(`Fetched calendar user addresses ${p}`),p},q=async e=>{const{url:t,props:r,filters:a,timezone:s,depth:o,headers:c,headersToExclude:n,fetchOptions:d={},fetch:i}=e;return S({url:t,body:{"calendar-query":u({_attributes:p([exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALENDAR_SERVER,exports.DAVNamespace.CALDAV_APPLE,exports.DAVNamespace.DAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,filter:a,timezone:s})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:o,headers:v(c,n),fetchOptions:d,fetch:i})},Z=async e=>{const{url:t,props:r,objectUrls:a,filters:s,timezone:o,depth:c,headers:n,headersToExclude:d,fetchOptions:i={},fetch:l}=e;return S({url:t,body:{"calendar-multiget":u({_attributes:p([exports.DAVNamespace.DAV,exports.DAVNamespace.CALDAV]),[`${exports.DAVNamespaceShort.DAV}:prop`]:r,[`${exports.DAVNamespaceShort.DAV}:href`]:a,filter:s,timezone:o})},defaultNamespace:exports.DAVNamespaceShort.CALDAV,depth:c,headers:v(n,d),fetchOptions:i,fetch:l})},Q=async e=>{const{url:t,props:r,depth:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e;return O({url:t,init:{method:"MKCALENDAR",headers:v(u({depth:a,...s}),o),namespace:exports.DAVNamespaceShort.DAV,body:{[`${exports.DAVNamespaceShort.CALDAV}:mkcalendar`]:{_attributes:p([exports.DAVNamespace.DAV,exports.DAVNamespace.CALDAV,exports.DAVNamespace.CALDAV_APPLE]),set:{prop:r}}}},fetchOptions:c,fetch:n})},G=async e=>{const{headers:t,account:r,props:a,projectedProps:s,headersToExclude:o,fetchOptions:c={},fetch:d}=null!=e?e:{},i=["homeUrl","rootUrl"];if(!r||!g(r,i)){if(!r)throw new Error("no account for fetchCalendars");throw new Error(`account must have ${b(r,i)} before fetchCalendars`)}const l=await y({url:r.homeUrl,props:null!=a?a:{[`${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:v(t,o),fetchOptions:c,fetch: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,a,s,o,c;return(Array.isArray(null===(r=null===(t=e.props)||void 0===t?void 0:t.supportedCalendarComponentSet)||void 0===r?void 0:r.comp)?null===(a=e.props)||void 0===a?void 0:a.supportedCalendarComponentSet.comp.map(e=>e._attributes.name):[null===(c=null===(o=null===(s=e.props)||void 0===s?void 0:s.supportedCalendarComponentSet)||void 0===o?void 0:o.comp)||void 0===c?void 0:c._attributes.name]).some(e=>Object.values(n).includes(e))}).map(e=>{var t,a,o,c,n,d,i,l,h,p,u,v,m,A,O,y;const D=null===(t=e.props)||void 0===t?void 0:t.calendarDescription,V=null===(a=e.props)||void 0===a?void 0:a.calendarTimezone;return{description:"string"==typeof D?D:"",timezone:"string"==typeof V?V:"",url:new URL(null!==(o=e.href)&&void 0!==o?o:"",null!==(c=r.rootUrl)&&void 0!==c?c:"").href,ctag:null===(n=e.props)||void 0===n?void 0:n.getctag,calendarColor:null===(d=e.props)||void 0===d?void 0:d.calendarColor,displayName:null!==(l=null===(i=e.props)||void 0===i?void 0:i.displayname._cdata)&&void 0!==l?l:null===(h=e.props)||void 0===h?void 0:h.displayname,components:Array.isArray(null===(p=e.props)||void 0===p?void 0:p.supportedCalendarComponentSet.comp)?null===(u=e.props)||void 0===u?void 0:u.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===(O=e.props)||void 0===O?void 0:O.syncToken,...f("projectedProps",Object.fromEntries(Object.entries(null!==(y=e.props)&&void 0!==y?y:{}).filter(([e])=>null==s?void 0:s[e])))}}).map(async e=>({...e,reports:await $({collection:e,headers:v(t,o),fetchOptions:c,fetch:d})})))},J=async e=>{const{calendar:t,objectUrls:r,filters:a,timeRange:s,headers:o,expand:c,urlFilter:n=e=>Boolean(null==e?void 0:e.includes(".ics")),useMultiGet:d=!0,headersToExclude:i,fetchOptions:l={},fetch:h}=e;if(s){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(s.start)&&e.test(s.end)||t.test(s.start)&&t.test(s.end)))throw new Error("invalid timeRange format, not in ISO8601")}I(`Fetching calendar objects from ${null==t?void 0:t.url}`);const p=["url"];if(!t||!g(t,p)){if(!t)throw new Error("cannot fetchCalendarObjects for undefined calendar");throw new Error(`calendar must have ${b(t,p)} before fetchCalendarObjects`)}const u=null!=a?a:[{"comp-filter":{_attributes:{name:"VCALENDAR"},"comp-filter":{_attributes:{name:"VEVENT"},...s?{"time-range":{_attributes:{start:`${new Date(s.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(s.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{}}}}];let f=[];const m=(null!=r?r:(f=await q({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},...c&&s?{[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(s.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(s.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}}:{}},filters:u,depth:"1",headers:v(o,i),fetchOptions:l,fetch:h})).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 A=[];return m.length>0&&(A=c&&!r?f.filter(e=>{var r,a;const s=(null!==(r=e.href)&&void 0!==r?r:"").startsWith("http")?e.href:new URL(null!==(a=e.href)&&void 0!==a?a:"",t.url).href;return n(null!=s?s:"")}):d?await Z({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:{...c&&s?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(s.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(s.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{}}},objectUrls:m,depth:"1",headers:v(o,i),fetchOptions:l,fetch:h}):await q({url:t.url,props:{[`${exports.DAVNamespaceShort.DAV}:getetag`]:{},[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]:{...c&&s?{[`${exports.DAVNamespaceShort.CALDAV}:expand`]:{_attributes:{start:`${new Date(s.start).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`,end:`${new Date(s.end).toISOString().slice(0,19).replace(/[-:.]/g,"")}Z`}}}:{}}},filters:u,depth:"1",headers:v(o,i),fetchOptions:l,fetch:h})),A.map(e=>{var r,a,s,o,c,n;return{url:new URL(null!==(r=e.href)&&void 0!==r?r:"",t.url).href,etag:`${null===(a=e.props)||void 0===a?void 0:a.getetag}`,data:null!==(c=null===(o=null===(s=e.props)||void 0===s?void 0:s.calendarData)||void 0===o?void 0:o._cdata)&&void 0!==c?c:null===(n=e.props)||void 0===n?void 0:n.calendarData}})},W=async e=>{const{calendar:t,iCalString:r,filename:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e;return D({url:new URL(a,t.url).href,data:r,headers:v({"content-type":"text/calendar; charset=utf-8","If-None-Match":"*",...s},o),fetchOptions:c,fetch:n})},K=async e=>{const{calendarObject:t,headers:r,headersToExclude:a,fetchOptions:s={},fetch:o}=e;return V({url:t.url,data:t.data,etag:t.etag,headers:v({"content-type":"text/calendar; charset=utf-8",...r},a),fetchOptions:s,fetch:o})},Y=async e=>{const{calendarObject:t,headers:r,headersToExclude:a,fetchOptions:s={},fetch:o}=e;return x({url:t.url,etag:t.etag,headers:v(r,a),fetchOptions:s,fetch:o})},X=async e=>{var t;const{oldCalendars:r,account:a,detailedResult:s,headers:o,headersToExclude:c,fetchOptions:n={},fetch:d}=e;if(!a)throw new Error("Must have account before syncCalendars");const i=null!==(t=null!=r?r:a.calendars)&&void 0!==t?t:[],l=await G({account:a,headers:v(o,c),fetchOptions:n,fetch:d}),p=l.filter(e=>i.every(t=>!h(t.url,e.url)));I(`new calendars: ${p.map(e=>e.displayName)}`);const u=i.reduce((e,t)=>{const r=l.find(e=>h(e.url,t.url));return r&&(r.syncToken&&`${r.syncToken}`!=`${t.syncToken}`||r.ctag&&`${r.ctag}`!=`${t.ctag}`)?[...e,r]:e},[]);I(`updated calendars: ${u.map(e=>e.displayName)}`);const f=await Promise.all(u.map(async e=>await k({collection:{...e,objectMultiGet:Z},method:"webdav",headers:v(o,c),account:a,fetchOptions:n,fetch:d}))),m=i.filter(e=>l.every(t=>!h(t.url,e.url)));I(`deleted calendars: ${m.map(e=>e.displayName)}`);const A=i.filter(e=>l.some(t=>h(t.url,e.url)&&(t.syncToken&&`${t.syncToken}`!=`${e.syncToken}`||t.ctag&&`${t.ctag}`!=`${e.ctag}`)));return s?{created:p,updated:u,deleted:m}:[...A,...p,...f]},ee=async e=>{const{url:t,timeRange:r,depth:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch: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(await S({url:t,body:{"free-busy-query":u({_attributes:p([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:a,headers:v(s,o),fetchOptions:c,fetch:n}))[0]};var te=Object.freeze({__proto__:null,calendarMultiGet:Z,calendarQuery:q,createCalendarObject:W,deleteCalendarObject:Y,fetchCalendarObjects:J,fetchCalendarUserAddresses:z,fetchCalendars:G,freeBusyQuery:ee,makeCalendar:Q,syncCalendars:X,updateCalendarObject:K});const re=t("tsdav:account"),ae=async e=>{var t,r;re("Service discovery...");const{account:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e,i=null!=n?n:d,l=new URL(a.serverUrl),h=new URL(`/.well-known/${a.accountType}`,l);h.protocol=null!==(t=l.protocol)&&void 0!==t?t:"http";try{const e=await i(h.href,{headers:{...v(s,o),"Content-Type":"text/xml;charset=UTF-8"},method:"PROPFIND",body:'<?xml version="1.0" encoding="utf-8" ?>\n<d:propfind xmlns:d="DAV:">\n <d:prop>\n <d:resourcetype/>\n </d:prop>\n</d:propfind>',redirect:"manual",...c});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,l);return e.hostname===h.hostname&&h.port&&!e.port&&(e.port=h.port),e.protocol=null!==(r=l.protocol)&&void 0!==r?r:"http",e.href}}}catch(e){re(`Service discovery failed: ${e.stack}`)}return l.href},se=async e=>{var t,r,a,s,o;const{account:c,headers:n,headersToExclude:d,fetchOptions:i={},fetch:l}=e,h=["rootUrl"];if(!g(c,h))throw new Error(`account must have ${b(c,h)} before fetchPrincipalUrl`);re(`Fetching principal url from path ${c.rootUrl}`);const[p]=await y({url:c.rootUrl,props:{[`${exports.DAVNamespaceShort.DAV}:current-user-principal`]:{}},depth:"0",headers:v(n,d),fetchOptions:i,fetch:l});if(!p.ok&&(re(`Fetch principal url failed: ${p.statusText}`),401===p.status))throw new Error("Invalid credentials");return re(`Fetched principal url ${null===(r=null===(t=p.props)||void 0===t?void 0:t.currentUserPrincipal)||void 0===r?void 0:r.href}`),new URL(null!==(o=null===(s=null===(a=p.props)||void 0===a?void 0:a.currentUserPrincipal)||void 0===s?void 0:s.href)&&void 0!==o?o:"",c.rootUrl).href},oe=async e=>{var t,r;const{account:a,headers:s,headersToExclude:o,fetchOptions:c={},fetch:n}=e,d=["principalUrl","rootUrl"];if(!g(a,d))throw new Error(`account must have ${b(a,d)} before fetchHomeUrl`);re(`Fetch home url from ${a.principalUrl}`);const i=await y({url:a.principalUrl,props:"caldav"===a.accountType?{[`${exports.DAVNamespaceShort.CALDAV}:calendar-home-set`]:{}}:{[`${exports.DAVNamespaceShort.CARDDAV}:addressbook-home-set`]:{}},depth:"0",headers:v(s,o),fetchOptions:c,fetch:n}),l=i.find(e=>h(a.principalUrl,e.href));if(!l||!l.ok)throw re(`Fetch home url failed with status ${null==l?void 0:l.statusText} and error ${JSON.stringify(i.map(e=>e.error))}`),new Error("cannot find homeUrl");const p=new URL("caldav"===a.accountType?null===(t=null==l?void 0:l.props)||void 0===t?void 0:t.calendarHomeSet.href:null===(r=null==l?void 0:l.props)||void 0===r?void 0:r.addressbookHomeSet.href,a.rootUrl).href;return re(`Fetched home url ${p}`),p},ce=async e=>{const{account:t,headers:r,loadCollections:a=!1,loadObjects:s=!1,headersToExclude:o,fetchOptions:c={},fetch:n}=e,d={...t};return d.rootUrl=await ae({account:t,headers:v(r,o),fetchOptions:c,fetch:n}),d.principalUrl=await se({account:d,headers:v(r,o),fetchOptions:c,fetch:n}),d.homeUrl=await oe({account:d,headers:v(r,o),fetchOptions:c,fetch:n}),(a||s)&&("caldav"===t.accountType?d.calendars=await G({headers:v(r,o),account:d,fetchOptions:c,fetch:n}):"carddav"===t.accountType&&(d.addressBooks=await L({headers:v(r,o),account:d,fetchOptions:c,fetch:n}))),s&&("caldav"===t.accountType&&d.calendars?d.calendars=await Promise.all(d.calendars.map(async e=>({...e,objects:await J({calendar:e,headers:v(r,o),fetchOptions:c,fetch:n})}))):"carddav"===t.accountType&&d.addressBooks&&(d.addressBooks=await Promise.all(d.addressBooks.map(async e=>({...e,objects:await H({addressBook:e,headers:v(r,o),fetchOptions:c,fetch:n})}))))),d};var ne=Object.freeze({__proto__:null,createAccount:ce,fetchHomeUrl:oe,fetchPrincipalUrl:se,serviceDiscovery:ae});const de=t("tsdav:authHelper"),ie=(e,t)=>(...r)=>e({...t,...r[0]}),le=e=>(de(`Basic auth token generated: ${s.encode(`${e.username}:${e.password}`)}`),{authorization:`Basic ${s.encode(`${e.username}:${e.password}`)}`}),he=e=>({authorization:`Bearer ${e.accessToken}`}),pe=async(e,t,r)=>{const a=["authorizationCode","redirectUrl","clientId","clientSecret","tokenUrl"];if(!g(e,a))throw new Error(`Oauth credentials missing: ${b(e,a)}`);const s=new URLSearchParams({grant_type:"authorization_code",code:e.authorizationCode,redirect_uri:e.redirectUrl,client_id:e.clientId,client_secret:e.clientSecret});de(e.tokenUrl),de(s.toString());const o=null!=r?r:d,c=await o(e.tokenUrl,{method:"POST",body:s.toString(),headers:{"content-length":`${s.toString().length}`,"content-type":"application/x-www-form-urlencoded"},...null!=t?t:{}});if(c.ok){return await c.json()}return de(`Fetch Oauth tokens failed: ${await c.text()}`),{}},ue=async(e,t,r)=>{const a=["refreshToken","clientId","clientSecret","tokenUrl"];if(!g(e,a))throw new Error(`Oauth credentials missing: ${b(e,a)}`);const s=new URLSearchParams({client_id:e.clientId,client_secret:e.clientSecret,refresh_token:e.refreshToken,grant_type:"refresh_token"}),o=null!=r?r:d,c=await o(e.tokenUrl,{method:"POST",body:s.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"},...null!=t?t:{}});if(c.ok){return await c.json()}return de(`Refresh access token failed: ${await c.text()}`),{}},fe=async(e,t,r)=>{var a;de("Fetching oauth headers");let s={};return e.refreshToken?(e.refreshToken&&!e.accessToken||Date.now()>(null!==(a=e.expiration)&&void 0!==a?a:0))&&(s=await ue(e,t,r)):s=await pe(e,t,r),de(`Oauth tokens fetched: ${s.access_token}`),{tokens:s,headers:{authorization:`Bearer ${s.access_token}`}}};var ve=Object.freeze({__proto__:null,defaultParam:ie,fetchOauthTokens:pe,getBasicAuthHeaders:le,getBearerAuthHeaders:he,getOauthHeaders:fe,refreshAccessToken:ue});const me=async e=>{var t;const{serverUrl:r,credentials:a,authMethod:s,defaultAccountType:o,authFunction:c,fetch:n}=e;let d={};switch(s){case"Basic":d=le(a);break;case"Bearer":d=he(a);break;case"Oauth":d=(await fe(a,void 0,n)).headers;break;case"Digest":d={Authorization:`Digest ${a.digestString}`};break;case"Custom":d=null!==(t=await(null==c?void 0:c(a)))&&void 0!==t?t:{};break;default:throw new Error("Invalid auth method")}const i=o?await ce({account:{serverUrl:r,credentials:a,accountType:o},headers:d,fetch:n}):void 0,l=ie(D,{url:r,headers:d,fetch:n}),h=ie(V,{headers:d,url:r,fetch:n}),p=ie(x,{headers:d,url:r,fetch:n}),u=ie(y,{headers:d,fetch:n}),f=ie(S,{headers:d,fetch:n}),v=ie(N,{headers:d,fetch:n}),m=ie(E,{headers:d,fetch:n}),A=ie($,{headers:d,fetch:n}),C=ie(T,{headers:d,fetch:n}),g=ie(k,{headers:d,account:i,fetch:n}),b=ie(q,{headers:d,fetch:n}),w=ie(Z,{headers:d,fetch:n}),U=ie(Q,{headers:d,fetch:n}),_=ie(G,{headers:d,account:i,fetch:n}),M=ie(z,{headers:d,account:i,fetch:n}),I=ie(J,{headers:d,fetch:n}),ee=ie(W,{headers:d,fetch:n}),te=ie(K,{headers:d,fetch:n}),re=ie(Y,{headers:d,fetch:n}),ae=ie(X,{account:i,headers:d,fetch:n}),se=ie(R,{headers:d,fetch:n}),oe=ie(j,{headers:d,fetch:n});return{davRequest:async e=>{const{init:t,fetch:r,...a}=e,{headers:s,...o}=t;return O({...a,init:{...o,headers:{...d,...s}},fetch:null!=r?r:n})},propfind:u,createAccount:async e=>{const{account:t,headers:s,loadCollections:o,loadObjects:c,fetch:i}=e;return ce({account:{serverUrl:r,credentials:a,...t},headers:{...d,...s},loadCollections:o,loadObjects:c,fetch:null!=i?i:n})},createObject:l,updateObject:h,deleteObject:p,calendarQuery:b,addressBookQuery:se,collectionQuery:f,makeCollection:v,calendarMultiGet:w,makeCalendar:U,syncCollection:m,supportedReportSet:A,isCollectionDirty:C,smartCollectionSync:g,fetchCalendars:_,fetchCalendarUserAddresses:M,fetchCalendarObjects:I,createCalendarObject:ee,updateCalendarObject:te,deleteCalendarObject:re,syncCalendars:ae,fetchAddressBooks:ie(L,{account:i,headers:d,fetch:n}),addressBookMultiGet:oe,fetchVCards:ie(H,{headers:d,fetch:n}),createVCard:ie(B,{headers:d,fetch:n}),updateVCard:ie(P,{headers:d,fetch:n}),deleteVCard:ie(F,{headers:d,fetch:n})}};class Ae{constructor(e){var t,r,a;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,this.fetchOptions=null!==(a=e.fetchOptions)&&void 0!==a?a:{},this.fetchOverride=e.fetch}async login(){var e;switch(this.authMethod){case"Basic":this.authHeaders=le(this.credentials);break;case"Bearer":this.authHeaders=he(this.credentials);break;case"Oauth":this.authHeaders=(await fe(this.credentials,this.fetchOptions,this.fetchOverride)).headers;break;case"Digest":this.authHeaders={Authorization:`Digest ${this.credentials.digestString}`};break;case"Custom":this.authHeaders=await(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?await ce({account:{serverUrl:this.serverUrl,credentials:this.credentials,accountType:this.accountType},headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride}):void 0}async davRequest(e){const{init:t,fetch:r,...a}=e,{headers:s,...o}=t;return O({...a,init:{...o,headers:{...this.authHeaders,...s}},fetchOptions:this.fetchOptions,fetch:null!=r?r:this.fetchOverride})}async createObject(...e){return ie(D,{url:this.serverUrl,headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async updateObject(...e){return ie(V,{url:this.serverUrl,headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async deleteObject(...e){return ie(x,{url:this.serverUrl,headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async propfind(...e){return ie(y,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async createAccount(e){const{account:t,headers:r,loadCollections:a,loadObjects:s,fetchOptions:o,fetch:c}=e;return ce({account:{serverUrl:this.serverUrl,credentials:this.credentials,...t},headers:{...this.authHeaders,...r},loadCollections:a,loadObjects:s,fetchOptions:null!=o?o:this.fetchOptions,fetch:null!=c?c:this.fetchOverride})}async collectionQuery(...e){return ie(S,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async makeCollection(...e){return ie(N,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async syncCollection(...e){return ie(E,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async supportedReportSet(...e){return ie($,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async isCollectionDirty(...e){return ie(T,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async smartCollectionSync(...e){return ie(k,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride,account:this.account})(e[0])}async calendarQuery(...e){return ie(q,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async makeCalendar(...e){return ie(Q,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async calendarMultiGet(...e){return ie(Z,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async fetchCalendars(...e){return ie(G,{headers:this.authHeaders,account:this.account,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(null==e?void 0:e[0])}async fetchCalendarUserAddresses(...e){return ie(z,{headers:this.authHeaders,account:this.account,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(null==e?void 0:e[0])}async fetchCalendarObjects(...e){return ie(J,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async createCalendarObject(...e){return ie(W,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async updateCalendarObject(...e){return ie(K,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async deleteCalendarObject(...e){return ie(Y,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async syncCalendars(...e){return ie(X,{headers:this.authHeaders,account:this.account,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async addressBookQuery(...e){return ie(R,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async addressBookMultiGet(...e){return ie(j,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async fetchAddressBooks(...e){return ie(L,{headers:this.authHeaders,account:this.account,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(null==e?void 0:e[0])}async fetchVCards(...e){return ie(H,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async createVCard(...e){return ie(B,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async updateVCard(...e){return ie(P,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}async deleteVCard(...e){return ie(F,{headers:this.authHeaders,fetchOptions:this.fetchOptions,fetch:this.fetchOverride})(e[0])}}var Oe=Object.freeze({__proto__:null,DAVClient:Ae,createDAVClient:me}),ye={DAVNamespace:exports.DAVNamespace,DAVNamespaceShort:exports.DAVNamespaceShort,DAVAttributeMap:o,...Oe,...C,...U,...ne,...M,...te,...ve,...m};exports.DAVAttributeMap=o,exports.DAVClient=Ae,exports.addressBookMultiGet=j,exports.addressBookQuery=R,exports.calendarMultiGet=Z,exports.calendarQuery=q,exports.cleanupFalsy=u,exports.collectionQuery=S,exports.createAccount=ce,exports.createCalendarObject=W,exports.createDAVClient=me,exports.createObject=D,exports.createVCard=B,exports.davRequest=O,exports.default=ye,exports.deleteCalendarObject=Y,exports.deleteObject=x,exports.deleteVCard=F,exports.fetchAddressBooks=L,exports.fetchCalendarObjects=J,exports.fetchCalendarUserAddresses=z,exports.fetchCalendars=G,exports.fetchOauthTokens=pe,exports.fetchVCards=H,exports.freeBusyQuery=ee,exports.getBasicAuthHeaders=le,exports.getBearerAuthHeaders=he,exports.getDAVAttribute=p,exports.getOauthHeaders=fe,exports.isCollectionDirty=T,exports.makeCalendar=Q,exports.propfind=y,exports.refreshAccessToken=ue,exports.smartCollectionSync=k,exports.supportedReportSet=$,exports.syncCalendars=X,exports.syncCollection=E,exports.updateCalendarObject=K,exports.updateObject=V,exports.updateVCard=P,exports.urlContains=h,exports.urlEquals=l;