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