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