@nylas/react 1.4.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/README.md +7 -0
  2. package/dist/add-circle-icon_2.entry-8a1c55bc.cjs +1 -0
  3. package/dist/{add-circle-icon_2.entry-615fc101.js → add-circle-icon_2.entry-b4bbcfee.js} +3 -3
  4. package/dist/archive-icon.entry-a2492cf3.js +16 -0
  5. package/dist/archive-icon.entry-e48d2356.cjs +1 -0
  6. package/dist/{arrow-icon.entry-da152ec2.js → arrow-icon.entry-9414299f.js} +5 -5
  7. package/dist/arrow-icon.entry-b1ecb2aa.cjs +1 -0
  8. package/dist/{bold-icon.entry-61046c15.js → bold-icon.entry-b72aed9f.js} +4 -4
  9. package/dist/{bold-icon.entry-58679992.cjs → bold-icon.entry-c781e9c1.cjs} +1 -1
  10. package/dist/{button-component_2.entry-db53e00a.js → button-component_2.entry-36e49459.js} +9 -9
  11. package/dist/{button-component_2.entry-53bfdc19.cjs → button-component_2.entry-73f76545.cjs} +1 -1
  12. package/dist/calendar-agenda-fill-icon_36.entry-e9b92e0e.cjs +6 -0
  13. package/dist/{calendar-agenda-fill-icon_36.entry-76796ea7.js → calendar-agenda-fill-icon_36.entry-efa7ad26.js} +100 -100
  14. package/dist/{calendar-cancel-icon.entry-e5032d71.cjs → calendar-cancel-icon.entry-01c388eb.cjs} +1 -1
  15. package/dist/{calendar-cancel-icon.entry-f3b8ae99.js → calendar-cancel-icon.entry-0f739a8a.js} +4 -4
  16. package/dist/{calendar-check-icon_2.entry-7303362a.cjs → calendar-check-icon_2.entry-5febbadf.cjs} +1 -1
  17. package/dist/{calendar-check-icon_2.entry-27dc91f7.js → calendar-check-icon_2.entry-dfb0036d.js} +3 -3
  18. package/dist/{calendar-icon.entry-4f432baf.cjs → calendar-icon.entry-9743e0b7.cjs} +1 -1
  19. package/dist/{calendar-icon.entry-48fc45d6.js → calendar-icon.entry-f197396d.js} +2 -2
  20. package/dist/{checkbox-component.entry-8fad4faf.cjs → checkbox-component.entry-1aa5782f.cjs} +1 -1
  21. package/dist/{checkbox-component.entry-a15ffc4c.js → checkbox-component.entry-72a6aa72.js} +4 -4
  22. package/dist/checkmark-icon_15.entry-35dd97b7.cjs +5 -0
  23. package/dist/{checkmark-icon_15.entry-9f926a70.js → checkmark-icon_15.entry-5c09cff5.js} +225 -223
  24. package/dist/{chevron-icon_3.entry-5130fbba.js → chevron-icon_3.entry-4a72f211.js} +6 -6
  25. package/dist/chevron-icon_3.entry-e0608b7c.cjs +1 -0
  26. package/dist/{clock-icon_4.entry-40a393c9.js → clock-icon_4.entry-0afe79c2.js} +8 -8
  27. package/dist/{clock-icon_4.entry-ac65deae.cjs → clock-icon_4.entry-202ce025.cjs} +1 -1
  28. package/dist/constants-f51538ef-cd2a67c4.cjs +1 -0
  29. package/dist/{constants-3d8016e3-3c080f00.js → constants-f51538ef-e0a5f026.js} +27 -32
  30. package/dist/{customParseFormat-a4d9ea69-763f219e.cjs → customParseFormat-d1de5ed0-65a0bba3.cjs} +1 -1
  31. package/dist/{customParseFormat-a4d9ea69-7caebeb2.js → customParseFormat-d1de5ed0-c0ef002d.js} +1 -1
  32. package/dist/{delete-icon.entry-78e44eba.js → delete-icon.entry-580bfcc9.js} +4 -4
  33. package/dist/{delete-icon.entry-770dac8c.cjs → delete-icon.entry-762ac892.cjs} +1 -1
  34. package/dist/{document-refresh-icon.entry-d331f844.cjs → document-refresh-icon.entry-4e0f0c61.cjs} +1 -1
  35. package/dist/document-refresh-icon.entry-e500b4e3.js +16 -0
  36. package/dist/elements/index.d.ts +0 -8
  37. package/dist/{feedbackSync-57bb471a-ee800a95.js → feedbackSync-172f942c-42124493.js} +1 -1
  38. package/dist/{feedbackSync-57bb471a-5afb7715.cjs → feedbackSync-172f942c-62f72bd2.cjs} +1 -1
  39. package/dist/{folder-icon.entry-163e0aee.cjs → folder-icon.entry-2694e253.cjs} +1 -1
  40. package/dist/{folder-icon.entry-42650400.js → folder-icon.entry-54c3cc66.js} +2 -2
  41. package/dist/{forward-icon.entry-d60b6e31.js → forward-icon.entry-5e540f05.js} +5 -5
  42. package/dist/{forward-icon.entry-0a499b38.cjs → forward-icon.entry-f07102d8.cjs} +1 -1
  43. package/dist/{globe-icon_2.entry-19359092.cjs → globe-icon_2.entry-14a4c168.cjs} +1 -1
  44. package/dist/{globe-icon_2.entry-5afa8049.js → globe-icon_2.entry-aaceb196.js} +90 -80
  45. package/dist/{google-logo-icon_6.entry-d2febb78.js → google-logo-icon_6.entry-00d40db2.js} +473 -439
  46. package/dist/google-logo-icon_6.entry-fa76ffe3.cjs +2 -0
  47. package/dist/{google-meet-icon_5.entry-4a94137f.cjs → google-meet-icon_5.entry-6c20e149.cjs} +1 -1
  48. package/dist/{google-meet-icon_5.entry-7b1b36f2.js → google-meet-icon_5.entry-f1f05903.js} +12 -12
  49. package/dist/inbox-icon.entry-9a4628f2.cjs +1 -0
  50. package/dist/inbox-icon.entry-aa78ba8c.js +16 -0
  51. package/dist/index-1e75512f.cjs +57 -0
  52. package/dist/{index-9243e481.js → index-e8380973.js} +5687 -4802
  53. package/dist/{index.es-13ff6710-0f748bd2.cjs → index.es-fc8588de-034ead51.cjs} +6 -6
  54. package/dist/{index.es-13ff6710-73fa05e6.js → index.es-fc8588de-c943eef6.js} +827 -1065
  55. package/dist/{info-icon_2.entry-ba869bab.js → info-icon_2.entry-b3b313ab.js} +3 -3
  56. package/dist/{info-icon_2.entry-6667923a.cjs → info-icon_2.entry-bbcefb9a.cjs} +1 -1
  57. package/dist/{input-component.entry-7396acf1.js → input-component.entry-401b9ba5.js} +9 -9
  58. package/dist/{input-component.entry-db84f917.cjs → input-component.entry-ec8e8e7c.cjs} +1 -1
  59. package/dist/input-dropdown_2.entry-8cb11601.cjs +1 -0
  60. package/dist/{input-dropdown_2.entry-20f2031b.js → input-dropdown_2.entry-c37f392c.js} +6 -6
  61. package/dist/italic-icon.entry-0e85d0d9.js +16 -0
  62. package/dist/italic-icon.entry-6675558a.cjs +1 -0
  63. package/dist/{multi-select-dropdown_2.entry-81740b34.js → multi-select-dropdown_2.entry-3eecf18a.js} +22 -16
  64. package/dist/{multi-select-dropdown_2.entry-8e07b42b.cjs → multi-select-dropdown_2.entry-e37c501d.cjs} +1 -1
  65. package/dist/{nylas-booked-event-card_12.entry-e56c8e92.js → nylas-booked-event-card_12.entry-e7464ae7.js} +226 -224
  66. package/dist/nylas-booked-event-card_12.entry-fddc9ab8.cjs +1 -0
  67. package/dist/{nylas-event-calendar_3.entry-2504c7c0.js → nylas-event-calendar_3.entry-9abd46c2.js} +2360 -2238
  68. package/dist/nylas-event-calendar_3.entry-e6669bbf.cjs +11 -0
  69. package/dist/{nylas-form-card.entry-98903549.js → nylas-form-card.entry-a3186807.js} +3 -3
  70. package/dist/{nylas-form-card.entry-c406e3d3.cjs → nylas-form-card.entry-cbb00fba.cjs} +1 -1
  71. package/dist/nylas-scheduler-editor.entry-5c92901a.cjs +2 -0
  72. package/dist/{nylas-scheduler-editor.entry-670cc0b8.js → nylas-scheduler-editor.entry-7b188a38.js} +83 -50
  73. package/dist/nylas-scheduling.entry-970240f6.cjs +1 -0
  74. package/dist/nylas-scheduling.entry-e9929b03.js +968 -0
  75. package/dist/{person-icon.entry-bdaa899b.cjs → person-icon.entry-8998fdb8.cjs} +1 -1
  76. package/dist/{person-icon.entry-3bca6e51.js → person-icon.entry-d2856f08.js} +4 -4
  77. package/dist/{play-icon.entry-ecc86e85.cjs → play-icon.entry-99eb969b.cjs} +1 -1
  78. package/dist/play-icon.entry-f949a80f.js +16 -0
  79. package/dist/{radio-button-group.entry-9851076c.js → radio-button-group.entry-bc3b12fd.js} +2 -2
  80. package/dist/{radio-button-group.entry-6965ad34.cjs → radio-button-group.entry-d66edd04.cjs} +1 -1
  81. package/dist/react.cjs +1 -1
  82. package/dist/react.js +96 -104
  83. package/dist/{refresh-icon.entry-90d52ab3.cjs → refresh-icon.entry-99d1982d.cjs} +1 -1
  84. package/dist/{refresh-icon.entry-d776c4a7.js → refresh-icon.entry-d6df8b1c.js} +2 -2
  85. package/dist/{register-component-02a05665-2e992621.js → register-component-62d792d4-448b6a43.js} +1 -1
  86. package/dist/{register-component-02a05665-75652287.cjs → register-component-62d792d4-c6e7d129.cjs} +1 -1
  87. package/dist/{reply-all-icon.entry-24f7c0fe.js → reply-all-icon.entry-7ebf01a0.js} +2 -2
  88. package/dist/{reply-all-icon.entry-6e49eb03.cjs → reply-all-icon.entry-d7c44139.cjs} +1 -1
  89. package/dist/{reply-icon.entry-7fff25c9.cjs → reply-icon.entry-058c00e8.cjs} +1 -1
  90. package/dist/{reply-icon.entry-d5d26d65.js → reply-icon.entry-d1622d85.js} +5 -5
  91. package/dist/sent-icon.entry-6c604512.cjs +1 -0
  92. package/dist/sent-icon.entry-fe12bc2f.js +16 -0
  93. package/dist/spam-icon.entry-45e5292e.cjs +1 -0
  94. package/dist/spam-icon.entry-b97c7709.js +16 -0
  95. package/dist/{star-icon.entry-3c57a35c.cjs → star-icon.entry-4db13fdb.cjs} +1 -1
  96. package/dist/{star-icon.entry-c2e743a9.js → star-icon.entry-98b80645.js} +6 -6
  97. package/dist/{stop-icon.entry-0b9563d5.js → stop-icon.entry-0290fd30.js} +2 -2
  98. package/dist/{stop-icon.entry-cf4c4e63.cjs → stop-icon.entry-9d7b53fd.cjs} +1 -1
  99. package/dist/{textarea-component.entry-2eccc173.cjs → textarea-component.entry-9b474ab5.cjs} +1 -1
  100. package/dist/{textarea-component.entry-60e7a4d0.js → textarea-component.entry-a62c257b.js} +2 -2
  101. package/dist/{toggle-switch.entry-612744fd.cjs → toggle-switch.entry-5dbfcd48.cjs} +1 -1
  102. package/dist/{toggle-switch.entry-0a6b01e6.js → toggle-switch.entry-e423b793.js} +2 -2
  103. package/dist/{translate-icon.entry-ede5f77d.js → translate-icon.entry-60c55a2e.js} +4 -4
  104. package/dist/{translate-icon.entry-8adc4146.cjs → translate-icon.entry-f82fa6fc.cjs} +1 -1
  105. package/dist/trash-fill-icon.entry-095caae3.cjs +1 -0
  106. package/dist/trash-fill-icon.entry-825055fd.js +16 -0
  107. package/dist/{underline-icon.entry-d2fe2da6.cjs → underline-icon.entry-0807a43d.cjs} +1 -1
  108. package/dist/{underline-icon.entry-b2b43ba2.js → underline-icon.entry-40028bc6.js} +2 -2
  109. package/dist/{warning-icon.entry-0a5c7337.js → warning-icon.entry-24e37759.js} +2 -2
  110. package/dist/{warning-icon.entry-85822f4d.cjs → warning-icon.entry-fce7c14f.cjs} +1 -1
  111. package/package.json +2 -2
  112. package/dist/add-circle-icon_2.entry-e616ece6.cjs +0 -1
  113. package/dist/archive-icon.entry-41938a61.cjs +0 -1
  114. package/dist/archive-icon.entry-bd81d2d9.js +0 -16
  115. package/dist/arrow-icon.entry-4103be57.cjs +0 -1
  116. package/dist/calendar-agenda-fill-icon_36.entry-917e4a9d.cjs +0 -6
  117. package/dist/checkmark-icon_15.entry-08c8b107.cjs +0 -5
  118. package/dist/chevron-icon_3.entry-2f75c3c4.cjs +0 -1
  119. package/dist/constants-3d8016e3-fd6c3848.cjs +0 -1
  120. package/dist/document-refresh-icon.entry-f6dfe744.js +0 -16
  121. package/dist/google-logo-icon_6.entry-896a10a5.cjs +0 -2
  122. package/dist/inbox-icon.entry-24ec450f.cjs +0 -1
  123. package/dist/inbox-icon.entry-b71acde0.js +0 -16
  124. package/dist/index-efb6db79.cjs +0 -57
  125. package/dist/input-dropdown_2.entry-0c219620.cjs +0 -1
  126. package/dist/italic-icon.entry-a9324a8a.cjs +0 -1
  127. package/dist/italic-icon.entry-c42f8112.js +0 -16
  128. package/dist/notebook-store-b61693cd-5657061b.js +0 -14
  129. package/dist/notebook-store-b61693cd-6515d345.cjs +0 -5
  130. package/dist/nylas-booked-event-card_12.entry-7c7afae5.cjs +0 -1
  131. package/dist/nylas-call-summary.entry-4bf7284f.cjs +0 -1
  132. package/dist/nylas-call-summary.entry-ad6fb46a.js +0 -16
  133. package/dist/nylas-event-calendar_3.entry-f747f6a8.cjs +0 -6
  134. package/dist/nylas-if-state.entry-6b071705.cjs +0 -1
  135. package/dist/nylas-if-state.entry-7468854a.js +0 -95
  136. package/dist/nylas-key-points.entry-7af8da1a.cjs +0 -1
  137. package/dist/nylas-key-points.entry-c186445e.js +0 -29
  138. package/dist/nylas-login.entry-171bd025.cjs +0 -1
  139. package/dist/nylas-login.entry-d85c1473.js +0 -74
  140. package/dist/nylas-provider.entry-ab1f6886.js +0 -265
  141. package/dist/nylas-provider.entry-e4231b93.cjs +0 -1
  142. package/dist/nylas-scheduler-editor.entry-d522ca98.cjs +0 -2
  143. package/dist/nylas-scheduling.entry-9e81c6fc.js +0 -439
  144. package/dist/nylas-scheduling.entry-c52edb14.cjs +0 -1
  145. package/dist/nylas-transcript.entry-a1fa7e17.cjs +0 -6
  146. package/dist/nylas-transcript.entry-fb39b5af.js +0 -128
  147. package/dist/nylas-video-player.entry-25e8cd9a.js +0 -39
  148. package/dist/nylas-video-player.entry-89842545.cjs +0 -1
  149. package/dist/nylas-video-preview.entry-28a0bd60.cjs +0 -1
  150. package/dist/nylas-video-preview.entry-80171531.js +0 -16
  151. package/dist/play-icon.entry-d548464e.js +0 -16
  152. package/dist/scheduler-config-store-d6729d8d-50920e8c.js +0 -29
  153. package/dist/scheduler-config-store-d6729d8d-a0bdda83.cjs +0 -1
  154. package/dist/scheduler-store-fe9e85a4-1dcfddfa.js +0 -533
  155. package/dist/scheduler-store-fe9e85a4-baabf78a.cjs +0 -1
  156. package/dist/sent-icon.entry-42ce5bcb.cjs +0 -1
  157. package/dist/sent-icon.entry-858fe83e.js +0 -16
  158. package/dist/spam-icon.entry-0827144e.js +0 -16
  159. package/dist/spam-icon.entry-bf1a48b6.cjs +0 -1
  160. package/dist/trash-fill-icon.entry-b6456ec8.cjs +0 -1
  161. package/dist/trash-fill-icon.entry-d48f72c5.js +0 -16
@@ -1,7 +1,7 @@
1
- "use strict";const T=require("./index-efb6db79.cjs");class nr{constructor(e,n,r=!0,s){this.automaticComponentRegistration=!0,this.registeredComponents={},this.propStateRegistrations=new Map,this.eventListenerRegistrations=new Map,this.host=e,this.stores=n,this.automaticComponentRegistration=r,this.eventOverrides=s,T.debug(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:s}),this.registerComponent=this.registerComponent.bind(this),this.getStore=this.getStore.bind(this),Object.keys(this.stores).forEach(i=>{this.propStateRegistrations.set(i,new Map)})}async componentWillLoad(e){T.debug(`[${this.hostTagName}] Will load`),this.setupStoreListeners(),this.nylasConnector=e;const n=Array.from(this.host.querySelectorAll("*")).filter(s=>s.tagName.toLowerCase().startsWith("nylas-"));T.debug(`[${this.hostTagName}] Found ${n.length} child component(s).`,{childComponents:n});const r=n.map(async s=>{const i=s;if(!i){T.debug(`[~${this.hostTagName}] (componentWillLoad) Component ${i.tagName} does not have a name. Skipping.`);return}if(!i.registerNylasComponent){T.debug(`[~${this.hostTagName}] (componentWillLoad) Component ${i.tagName} is not a component that can be registered. Skipping.`,{component:i});return}const o={element:i,name:i.tagName.toLowerCase(),getStoresToProp:i.getStoresToProp,storeToProps:i.storeToProps,stateToProps:i.stateToProps,authToProp:i.authToProp,eventToProps:i.eventToProps,connectorToProp:i.connectorToProp,localPropsToProp:i.localPropsToProp};await this.registerComponent(o)});await Promise.all(r)}async componentDidLoad(){T.debug(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach(e=>{e.dispose()})}async registerComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){T.debug(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}await this.registerComponent(e.detail)}async unregisterComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){T.debug(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}async registerComponent(e){T.debug(`~[${this.hostTagName}] (registerComponent) Registering component ${e.name}.`);const n=e.element.dataset.nylasId;n&&this.registeredComponents[n]?(T.debug(`[${this.hostTagName}] (registerComponent) Component ${e.name} already registered. Updating registration.`),this.cleanupComponentRegistration(n,!1)):e.element.dataset.nylasId=n||T.uniqueID();const s=e.element.dataset.nylasId;s&&(this.registeredComponents[s]=e),T.debug(`[${this.hostTagName}] (registerComponent) Waiting for "${e.element.localName}" component to be defined`,{component:e});try{await customElements.whenDefined(e.element.tagName.toLowerCase()),T.debug(`[${this.hostTagName}] (registerComponent) Component "${e.element.localName}" is now defined`)}catch(p){T.debug(`[${this.hostTagName}] (registerComponent) Error waiting for component "${e.element.localName}" to be defined:`,p)}const i=this.eventOverrides,{stateToProps:o,getStoresToProp:u,eventToProps:a,storeToProps:c,connectorToProp:h,localPropsToProp:l,element:d}=e;a==null||a.forEach((p,m)=>{var b;const f=this.nylasConnector,v=async w=>{T.debug(`[${this.hostTagName}] (registerComponent) Handling "${e.name}" prop "${String(m)}" event.`,{event:w}),m in i&&(T.debug(`[${this.hostTagName}] (registerComponent) Found event override for "${String(m)}" event. Calling override.`),await i[m](w,f)),w.defaultPrevented||await p(w,f)},y=e.element.dataset.nylasId;y&&!this.eventListenerRegistrations.has(y)&&this.eventListenerRegistrations.set(y,[]),y&&((b=this.eventListenerRegistrations.get(y))==null||b.push([d,m,v])),T.debug(`[${this.hostTagName}] (registerComponent) Setting "${e.name}" event "${String(m)}" to automcially call NylasConnector method.`);const g=T.formatEventName(m.toString());T.debug(`[${this.hostTagName}] (registerComponent) Adding event listener for "${g}" on "${d.tagName}"`),d.addEventListener(g,v)}),o==null||o.forEach((p,m)=>{var b,w,C,k;const[f,v]=m.split("."),g=this.getStore(f).state[v];if(!d.dataset.nylasId){T.debug(`[${this.hostTagName}] (registerComponent) Component "${e.name}" not registered. Skipping.`,{component:e});return}this.propStateRegistrations.has(f)||this.propStateRegistrations.set(f,new Map),(b=this.propStateRegistrations.get(f))!=null&&b.has(v)?(k=(C=this.propStateRegistrations.get(f))==null?void 0:C.get(v))==null||k.push({elementId:d.dataset.nylasId,propKey:p}):(w=this.propStateRegistrations.get(f))==null||w.set(v,[{elementId:d.dataset.nylasId,propKey:p}]),d[p.toString()]=g,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${p.toString()}" to "${m}" value.`,{stateValue:g})}),l==null||l.forEach((p,m)=>{const f=this.host[m];d[p.toString()]=f,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${p.toString()}" to the value of "${m}" value.`,{value:m,mappedPropValue:f})}),u&&(d[u==null?void 0:u.toString()]=this.getStore,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${u.toString()}" to "getStore" method.`)),c==null||c.forEach((p,m)=>{const f=this.getStore(m);d[p.toString()]=f,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${p.toString()}" to "${m}" store.`,{store:f})}),h&&(d[h==null?void 0:h.toString()]=this.nylasConnector,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${h.toString()}" to "nylasConnector" value.`,{connectorToProp:h})),typeof d.registerCallback=="function"&&(T.debug(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${e.name}".`),await d.registerCallback()),T.debug(`[${this.hostTagName}] (registerComponent) Component ${e.name} registered.`)}cleanupComponentRegistration(e,n=!0){const r=this.eventListenerRegistrations.get(e);r&&(r.forEach(([s,i,o])=>{const u=T.formatEventName(i.toString());T.debug(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${u}" on "${s.tagName}"`),s.removeEventListener(u,o)}),this.eventListenerRegistrations.delete(e)),this.propStateRegistrations.forEach((s,i)=>{s.forEach((o,u)=>{var c;const a=o.filter(h=>h.elementId!==e);a.length!==o.length&&((c=this.propStateRegistrations.get(i))==null||c.set(u,a))})}),n&&delete this.registeredComponents[e]}unregisterComponent(e){T.debug(`[${this.hostTagName}] Unregistering component ${e.name}.`);const n=e.element.dataset.nylasId;if(!n){T.debug(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${e.name}.`);return}if(this.registeredComponents[n]){T.debug(`[${this.hostTagName}] (unregisterComponent) Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach((s,i)=>{s.forEach((o,u)=>{var h,l;const a=(h=this.propStateRegistrations.get(i))==null?void 0:h.get(u),c=a==null?void 0:a.filter(d=>d.elementId!==n);c&&((l=this.propStateRegistrations.get(i))==null||l.set(u,c))})});const r=this.eventListenerRegistrations.get(n);r==null||r.forEach(([s,i,o])=>{const u=T.formatEventName(i.toString());T.debug(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${u}" on "${s.tagName}"`),s.removeEventListener(u,o)}),delete this.registeredComponents[n]}getStore(e){const n=this.stores[e];if(!n)throw new Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);return n}async setupStoreListeners(){const e=this;Object.entries(this.stores).forEach(([n,r])=>{T.debug(`[${e.hostTagName}] (setupStoreListeners) Listening for changes in "${n}" store.`),r.use({set(s,i,o){var c;if(T.debug(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${s.toString()}" changed`,{newValue:i,oldValue:o}),i===o){T.debug(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${s.toString()}" unchanged. Skipping.`);return}const u=e.registeredComponents;if(!u){T.debug(`[${e.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}const a=((c=e.propStateRegistrations.get(n))==null?void 0:c.get(s.toString()))||[];T.debug(`[${e.hostTagName}] (setupStoreListeners) Found ${a.length} prop(s) registered for "${s.toString()}" store.`,{props:a,propStateRegistrations:e.propStateRegistrations}),a.forEach(({elementId:h,propKey:l})=>{const d=u[h];if(!d){T.debug(`[${e.hostTagName}] (setupStoreListeners) Component "${h}" not found. Skipping.`,{component:d});return}const m=e.getStore(n).state[s];d.element[l.toString()]=m,T.debug(`[${e.hostTagName}] (setupStoreListeners) Setting "${d.name}" prop "${l.toString()}" to "${s.toString()}" value.`,{stateValue:m})})}})})}get hostTagName(){var e,n;return((n=(e=this.host)==null?void 0:e.tagName)==null?void 0:n.toLowerCase())??"nylas-provider"}}class rr extends nr{}var sr=Object.defineProperty,ir=(t,e,n)=>e in t?sr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pt=(t,e,n)=>(ir(t,typeof e!="symbol"?e+"":e,n),n),Sn=(t=>(t.Error="error",t.Warning="warning",t.Info="info",t.Success="success",t))(Sn||{});const or=t=>t!==null&&typeof t=="object"&&"error"in t;async function hn(t){const e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),r=Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const R=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:T.global$1,j=Object.keys,M=Array.isArray;function U(t,e){return typeof e!="object"||j(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||R.Promise||(R.Promise=Promise);const Be=Object.getPrototypeOf,ar={}.hasOwnProperty;function z(t,e){return ar.call(t,e)}function Ce(t,e){typeof e=="function"&&(e=e(Be(t))),(typeof Reflect>"u"?j:Reflect.ownKeys)(e).forEach(n=>{ee(t,n,e[n])})}const Cn=Object.defineProperty;function ee(t,e,n,r){Cn(t,e,U(n&&z(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function ke(t){return{from:function(e){return t.prototype=Object.create(e.prototype),ee(t.prototype,"constructor",t),{extend:Ce.bind(null,t.prototype)}}}}const ur=Object.getOwnPropertyDescriptor;function Jt(t,e){let n;return ur(t,e)||(n=Be(t))&&Jt(n,e)}const lr=[].slice;function ut(t,e,n){return lr.call(t,e,n)}function Pn(t,e){return e(t)}function Ie(t){if(!t)throw new Error("Assertion Failed")}function En(t){R.setImmediate?setImmediate(t):setTimeout(t,0)}function Tn(t,e){return t.reduce((n,r,s)=>{var i=e(r,s);return i&&(n[i[0]]=i[1]),n},{})}function te(t,e){if(z(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,s=e.length;r<s;++r){var i=te(t,e[r]);n.push(i)}return n}var o=e.indexOf(".");if(o!==-1){var u=t[e.substr(0,o)];return u===void 0?void 0:te(u,e.substr(o+1))}}function H(t,e,n){if(t&&e!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(t)))if(typeof e!="string"&&"length"in e){Ie(typeof n!="string"&&"length"in n);for(var r=0,s=e.length;r<s;++r)H(t,e[r],n[r])}else{var i=e.indexOf(".");if(i!==-1){var o=e.substr(0,i),u=e.substr(i+1);if(u==="")n===void 0?M(t)&&!isNaN(parseInt(o))?t.splice(o,1):delete t[o]:t[o]=n;else{var a=t[o];a&&z(t,o)||(a=t[o]={}),H(a,u,n)}}else n===void 0?M(t)&&!isNaN(parseInt(e))?t.splice(e,1):delete t[e]:t[e]=n}}function An(t){var e={};for(var n in t)z(t,n)&&(e[n]=t[n]);return e}const cr=[].concat;function On(t){return cr.apply([],t)}const In="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(On([8,16,32,64].map(t=>["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>R[t]),hr=In.map(t=>R[t]);Tn(In,t=>[t,!0]);let se=null;function We(t){se=typeof WeakMap<"u"&&new WeakMap;const e=Et(t);return se=null,e}function Et(t){if(!t||typeof t!="object")return t;let e=se&&se.get(t);if(e)return e;if(M(t)){e=[],se&&se.set(t,e);for(var n=0,r=t.length;n<r;++n)e.push(Et(t[n]))}else if(hr.indexOf(t.constructor)>=0)e=t;else{const i=Be(t);for(var s in e=i===Object.prototype?{}:Object.create(i),se&&se.set(t,e),t)z(t,s)&&(e[s]=Et(t[s]))}return e}const{toString:dr}={};function Tt(t){return dr.call(t).slice(8,-1)}const At=typeof Symbol<"u"?Symbol.iterator:"@@iterator",fr=typeof At=="symbol"?function(t){var e;return t!=null&&(e=t[At])&&e.apply(t)}:function(){return null},_e={};function J(t){var e,n,r,s;if(arguments.length===1){if(M(t))return t.slice();if(this===_e&&typeof t=="string")return[t];if(s=fr(t)){for(n=[];!(r=s.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const Zt=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var G=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Rn(t,e){G=t,Nn=e}var Nn=()=>!0;const pr=!new Error("").stack;function Pe(){if(pr)try{throw new Error}catch(t){return t}return new Error}function Ot(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(`
1
+ "use strict";const T=require("./index-1e75512f.cjs");class er{constructor(e,n,r=!0,s){this.automaticComponentRegistration=!0,this.registeredComponents={},this.propStateRegistrations=new Map,this.eventListenerRegistrations=new Map,this.host=e,this.stores=n,this.automaticComponentRegistration=r,this.eventOverrides=s,T.debug(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:s}),this.registerComponent=this.registerComponent.bind(this),this.getStore=this.getStore.bind(this),Object.keys(this.stores).forEach(i=>{this.propStateRegistrations.set(i,new Map)})}async componentWillLoad(e){T.debug(`[${this.hostTagName}] Will load`),this.setupStoreListeners(),this.nylasConnector=e;const n=Array.from(this.host.querySelectorAll("*")).filter(s=>s.tagName.toLowerCase().startsWith("nylas-"));T.debug(`[${this.hostTagName}] Found ${n.length} child component(s).`,{childComponents:n});const r=n.map(async s=>{const i=s;if(!i){T.debug(`[~${this.hostTagName}] (componentWillLoad) Component ${i.tagName} does not have a name. Skipping.`);return}if(!i.registerNylasComponent){T.debug(`[~${this.hostTagName}] (componentWillLoad) Component ${i.tagName} is not a component that can be registered. Skipping.`,{component:i});return}const o={element:i,name:i.tagName.toLowerCase(),getStoresToProp:i.getStoresToProp,storeToProps:i.storeToProps,stateToProps:i.stateToProps,authToProp:i.authToProp,eventToProps:i.eventToProps,connectorToProp:i.connectorToProp,localPropsToProp:i.localPropsToProp};await this.registerComponent(o)});await Promise.all(r)}async componentDidLoad(){T.debug(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach(e=>{e.dispose()})}async registerComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){T.debug(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}await this.registerComponent(e.detail)}async unregisterComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){T.debug(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}async registerComponent(e){T.debug(`~[${this.hostTagName}] (registerComponent) Registering component ${e.name}.`);const n=e.element.dataset.nylasId;n&&this.registeredComponents[n]?(T.debug(`[${this.hostTagName}] (registerComponent) Component ${e.name} already registered. Updating registration.`),this.cleanupComponentRegistration(n,!1)):e.element.dataset.nylasId=n||T.uniqueID();const s=e.element.dataset.nylasId;s&&(this.registeredComponents[s]=e),T.debug(`[${this.hostTagName}] (registerComponent) Waiting for "${e.element.localName}" component to be defined`,{component:e});try{await customElements.whenDefined(e.element.tagName.toLowerCase()),T.debug(`[${this.hostTagName}] (registerComponent) Component "${e.element.localName}" is now defined`)}catch(p){T.debug(`[${this.hostTagName}] (registerComponent) Error waiting for component "${e.element.localName}" to be defined:`,p)}const i=this.eventOverrides,{stateToProps:o,getStoresToProp:u,eventToProps:a,storeToProps:c,connectorToProp:h,localPropsToProp:l,element:d}=e;a==null||a.forEach((p,m)=>{var b;const f=this.nylasConnector,v=async w=>{T.debug(`[${this.hostTagName}] (registerComponent) Handling "${e.name}" prop "${String(m)}" event.`,{event:w}),m in i&&(T.debug(`[${this.hostTagName}] (registerComponent) Found event override for "${String(m)}" event. Calling override.`),await i[m](w,f)),w.defaultPrevented||await p(w,f)},y=e.element.dataset.nylasId;y&&!this.eventListenerRegistrations.has(y)&&this.eventListenerRegistrations.set(y,[]),y&&((b=this.eventListenerRegistrations.get(y))==null||b.push([d,m,v])),T.debug(`[${this.hostTagName}] (registerComponent) Setting "${e.name}" event "${String(m)}" to automcially call NylasConnector method.`);const g=T.formatEventName(m.toString());T.debug(`[${this.hostTagName}] (registerComponent) Adding event listener for "${g}" on "${d.tagName}"`),d.addEventListener(g,v)}),o==null||o.forEach((p,m)=>{var b,w,C,k;const[f,v]=m.split("."),g=this.getStore(f).state[v];if(!d.dataset.nylasId){T.debug(`[${this.hostTagName}] (registerComponent) Component "${e.name}" not registered. Skipping.`,{component:e});return}this.propStateRegistrations.has(f)||this.propStateRegistrations.set(f,new Map),(b=this.propStateRegistrations.get(f))!=null&&b.has(v)?(k=(C=this.propStateRegistrations.get(f))==null?void 0:C.get(v))==null||k.push({elementId:d.dataset.nylasId,propKey:p}):(w=this.propStateRegistrations.get(f))==null||w.set(v,[{elementId:d.dataset.nylasId,propKey:p}]),d[p.toString()]=g,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${p.toString()}" to "${m}" value.`,{stateValue:g})}),l==null||l.forEach((p,m)=>{const f=this.host[m];d[p.toString()]=f,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${p.toString()}" to the value of "${m}" value.`,{value:m,mappedPropValue:f})}),u&&(d[u==null?void 0:u.toString()]=this.getStore,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${u.toString()}" to "getStore" method.`)),c==null||c.forEach((p,m)=>{const f=this.getStore(m);d[p.toString()]=f,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${p.toString()}" to "${m}" store.`,{store:f})}),h&&(d[h==null?void 0:h.toString()]=this.nylasConnector,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${h.toString()}" to "nylasConnector" value.`,{connectorToProp:h})),typeof d.registerCallback=="function"&&(T.debug(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${e.name}".`),await d.registerCallback()),T.debug(`[${this.hostTagName}] (registerComponent) Component ${e.name} registered.`)}cleanupComponentRegistration(e,n=!0){const r=this.eventListenerRegistrations.get(e);r&&(r.forEach(([s,i,o])=>{const u=T.formatEventName(i.toString());T.debug(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${u}" on "${s.tagName}"`),s.removeEventListener(u,o)}),this.eventListenerRegistrations.delete(e)),this.propStateRegistrations.forEach((s,i)=>{s.forEach((o,u)=>{var c;const a=o.filter(h=>h.elementId!==e);a.length!==o.length&&((c=this.propStateRegistrations.get(i))==null||c.set(u,a))})}),n&&delete this.registeredComponents[e]}unregisterComponent(e){T.debug(`[${this.hostTagName}] Unregistering component ${e.name}.`);const n=e.element.dataset.nylasId;if(!n){T.debug(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${e.name}.`);return}if(this.registeredComponents[n]){T.debug(`[${this.hostTagName}] (unregisterComponent) Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach((s,i)=>{s.forEach((o,u)=>{var h,l;const a=(h=this.propStateRegistrations.get(i))==null?void 0:h.get(u),c=a==null?void 0:a.filter(d=>d.elementId!==n);c&&((l=this.propStateRegistrations.get(i))==null||l.set(u,c))})});const r=this.eventListenerRegistrations.get(n);r==null||r.forEach(([s,i,o])=>{const u=T.formatEventName(i.toString());T.debug(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${u}" on "${s.tagName}"`),s.removeEventListener(u,o)}),delete this.registeredComponents[n]}getStore(e){const n=this.stores[e];if(!n)throw new Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);return n}async setupStoreListeners(){const e=this;Object.entries(this.stores).forEach(([n,r])=>{T.debug(`[${e.hostTagName}] (setupStoreListeners) Listening for changes in "${n}" store.`),r.use({set(s,i,o){var c;if(T.debug(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${s.toString()}" changed`,{newValue:i,oldValue:o}),i===o){T.debug(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${s.toString()}" unchanged. Skipping.`);return}const u=e.registeredComponents;if(!u){T.debug(`[${e.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}const a=((c=e.propStateRegistrations.get(n))==null?void 0:c.get(s.toString()))||[];T.debug(`[${e.hostTagName}] (setupStoreListeners) Found ${a.length} prop(s) registered for "${s.toString()}" store.`,{props:a,propStateRegistrations:e.propStateRegistrations}),a.forEach(({elementId:h,propKey:l})=>{const d=u[h];if(!d){T.debug(`[${e.hostTagName}] (setupStoreListeners) Component "${h}" not found. Skipping.`,{component:d});return}const m=e.getStore(n).state[s];d.element[l.toString()]=m,T.debug(`[${e.hostTagName}] (setupStoreListeners) Setting "${d.name}" prop "${l.toString()}" to "${s.toString()}" value.`,{stateValue:m})})}})})}get hostTagName(){var e,n;return((n=(e=this.host)==null?void 0:e.tagName)==null?void 0:n.toLowerCase())??"nylas-provider"}}class tr extends er{}var kn=(t=>(t.Error="error",t.Warning="warning",t.Info="info",t.Success="success",t))(kn||{});const nr=t=>t!==null&&typeof t=="object"&&"error"in t,N=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:T.global$1,I=Object.keys,M=Array.isArray;function U(t,e){return typeof e!="object"||I(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||N.Promise||(N.Promise=Promise);const Be=Object.getPrototypeOf,rr={}.hasOwnProperty;function z(t,e){return rr.call(t,e)}function Ce(t,e){typeof e=="function"&&(e=e(Be(t))),(typeof Reflect>"u"?I:Reflect.ownKeys)(e).forEach(n=>{ee(t,n,e[n])})}const xn=Object.defineProperty;function ee(t,e,n,r){xn(t,e,U(n&&z(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function _e(t){return{from:function(e){return t.prototype=Object.create(e.prototype),ee(t.prototype,"constructor",t),{extend:Ce.bind(null,t.prototype)}}}}const sr=Object.getOwnPropertyDescriptor;function Qt(t,e){let n;return sr(t,e)||(n=Be(t))&&Qt(n,e)}const ir=[].slice;function ut(t,e,n){return ir.call(t,e,n)}function Sn(t,e){return e(t)}function Ke(t){if(!t)throw new Error("Assertion Failed")}function Cn(t){N.setImmediate?setImmediate(t):setTimeout(t,0)}function En(t,e){return t.reduce((n,r,s)=>{var i=e(r,s);return i&&(n[i[0]]=i[1]),n},{})}function te(t,e){if(z(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,s=e.length;r<s;++r){var i=te(t,e[r]);n.push(i)}return n}var o=e.indexOf(".");if(o!==-1){var u=t[e.substr(0,o)];return u===void 0?void 0:te(u,e.substr(o+1))}}function Y(t,e,n){if(t&&e!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(t)))if(typeof e!="string"&&"length"in e){Ke(typeof n!="string"&&"length"in n);for(var r=0,s=e.length;r<s;++r)Y(t,e[r],n[r])}else{var i=e.indexOf(".");if(i!==-1){var o=e.substr(0,i),u=e.substr(i+1);if(u==="")n===void 0?M(t)&&!isNaN(parseInt(o))?t.splice(o,1):delete t[o]:t[o]=n;else{var a=t[o];a&&z(t,o)||(a=t[o]={}),Y(a,u,n)}}else n===void 0?M(t)&&!isNaN(parseInt(e))?t.splice(e,1):delete t[e]:t[e]=n}}function Pn(t){var e={};for(var n in t)z(t,n)&&(e[n]=t[n]);return e}const or=[].concat;function Tn(t){return or.apply([],t)}const On="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Tn([8,16,32,64].map(t=>["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>N[t]),ar=On.map(t=>N[t]);En(On,t=>[t,!0]);let se=null;function Ve(t){se=typeof WeakMap<"u"&&new WeakMap;const e=Et(t);return se=null,e}function Et(t){if(!t||typeof t!="object")return t;let e=se&&se.get(t);if(e)return e;if(M(t)){e=[],se&&se.set(t,e);for(var n=0,r=t.length;n<r;++n)e.push(Et(t[n]))}else if(ar.indexOf(t.constructor)>=0)e=t;else{const i=Be(t);for(var s in e=i===Object.prototype?{}:Object.create(i),se&&se.set(t,e),t)z(t,s)&&(e[s]=Et(t[s]))}return e}const{toString:ur}={};function Pt(t){return ur.call(t).slice(8,-1)}const Tt=typeof Symbol<"u"?Symbol.iterator:"@@iterator",lr=typeof Tt=="symbol"?function(t){var e;return t!=null&&(e=t[Tt])&&e.apply(t)}:function(){return null},we={};function J(t){var e,n,r,s;if(arguments.length===1){if(M(t))return t.slice();if(this===we&&typeof t=="string")return[t];if(s=lr(t)){for(n=[];!(r=s.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const Jt=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var G=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function An(t,e){G=t,Kn=e}var Kn=()=>!0;const cr=!new Error("").stack;function Ee(){if(cr)try{throw new Error}catch(t){return t}return new Error}function Ot(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(`
2
2
  `).length),n.split(`
3
- `).slice(e).filter(Nn).map(r=>`
4
- `+r).join("")):""}var $n=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],en=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat($n),mr={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function xe(t,e){this._e=Pe(),this.name=t,this.message=e}function Kn(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,s)=>s.indexOf(n)===r).join(`
5
- `)}function lt(t,e,n,r){this._e=Pe(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Kn(t,e)}function Ne(t,e){this._e=Pe(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Kn(t,e)}ke(xe).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Ot(this._e,2))}},toString:function(){return this.name+": "+this.message}}),ke(lt).from(xe),ke(Ne).from(xe);var tn=en.reduce((t,e)=>(t[e]=e+"Error",t),{});const gr=xe;var E=en.reduce((t,e)=>{var n=e+"Error";function r(s,i){this._e=Pe(),this.name=n,s?typeof s=="string"?(this.message=`${s}${i?`
6
- `+i:""}`,this.inner=i||null):typeof s=="object"&&(this.message=`${s.name} ${s.message}`,this.inner=s):(this.message=mr[e]||n,this.inner=null)}return ke(r).from(gr),t[e]=r,t},{});E.Syntax=SyntaxError,E.Type=TypeError,E.Range=RangeError;var dn=$n.reduce((t,e)=>(t[e+"Error"]=E[e],t),{}),tt=en.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=E[e]),t),{});function I(){}function Fe(t){return t}function yr(t,e){return t==null||t===Fe?e:function(n){return e(t(n))}}function me(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function vr(t,e){return t===I?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?me(r,this.onsuccess):r),s&&(this.onerror=this.onerror?me(s,this.onerror):s),i!==void 0?i:n}}function br(t,e){return t===I?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?me(n,this.onsuccess):n),r&&(this.onerror=this.onerror?me(r,this.onerror):r)}}function wr(t,e){return t===I?e:function(n){var r=t.apply(this,arguments);U(n,r);var s=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return s&&(this.onsuccess=this.onsuccess?me(s,this.onsuccess):s),i&&(this.onerror=this.onerror?me(i,this.onerror):i),r===void 0?o===void 0?void 0:o:U(r,o)}}function _r(t,e){return t===I?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function nn(t,e){return t===I?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then(function(){return e.apply(r,i)})}return e.apply(this,arguments)}}tt.ModifyError=lt,tt.DexieError=xe,tt.BulkError=Ne;var Me={};const jn=100,[It,ct,Rt]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Be(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Be(e),t]})(),Dn=ct&&ct.then,nt=It&&It.constructor,rn=!!Rt;var Nt=!1,kr=Rt?()=>{Rt.then(Ye)}:R.setImmediate?setImmediate.bind(null,Ye):R.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Ye(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Ye,0)},$e=function(t,e){Re.push([t,e]),ht&&(kr(),ht=!1)},$t=!0,ht=!0,de=[],rt=[],Kt=null,jt=Fe,Se={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:mn,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{mn(t[0],t[1])}catch{}})}},P=Se,Re=[],fe=0,st=[];function S(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=I,this._lib=!1;var e=this._PSD=P;if(G&&(this._stackHolder=Pe(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Me)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Bt(this,this._value))}this._state=null,this._value=null,++e.ref,Fn(this,t)}const Dt={get:function(){var t=P,e=dt;function n(r,s){var i=!t.global&&(t!==P||e!==dt);const o=i&&!ne();var u=new S((a,c)=>{sn(this,new Bn(ft(r,t,i,o),ft(s,t,i,o),a,c,t))});return G&&Ln(u,this),u}return n.prototype=Me,n},set:function(t){ee(this,"then",t&&t.prototype===Me?Dt:{get:function(){return t},set:Dt.set})}};function Bn(t,e,n,r,s){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=s}function Fn(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&ze();n&&typeof n.then=="function"?Fn(t,(s,i)=>{n instanceof S?n._then(s,i):n.then(s,i)}):(t._state=!0,t._value=n,Mn(t)),r&&He()}},Bt.bind(null,t))}catch(n){Bt(t,n)}}function Bt(t,e){if(rt.push(e),t._state===null){var n=t._lib&&ze();e=jt(e),t._state=!1,t._value=e,G&&e!==null&&typeof e=="object"&&!e._promise&&function(r,s,i){try{r.apply(null,i)}catch(o){s&&s(o)}}(()=>{var r=Jt(e,"stack");e._promise=t,ee(e,"stack",{get:()=>Nt?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){de.some(s=>s._value===r._value)||de.push(r)}(t),Mn(t),n&&He()}}function Mn(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n<r;++n)sn(t,e[n]);var s=t._PSD;--s.ref||s.finalize(),fe===0&&(++fe,$e(()=>{--fe==0&&on()},[]))}function sn(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++fe,$e(xr,[n,t,e])}else t._listeners.push(e)}function xr(t,e,n){try{Kt=e;var r,s=e._value;e._state?r=t(s):(rt.length&&(rt=[]),r=t(s),rt.indexOf(s)===-1&&function(i){for(var o=de.length;o;)if(de[--o]._value===i._value)return void de.splice(o,1)}(e)),n.resolve(r)}catch(i){n.reject(i)}finally{Kt=null,--fe==0&&on(),--n.psd.ref||n.psd.finalize()}}function qn(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var s,i,o=t._value;o!=null?(s=o.name||"Error",i=o.message||o,r=Ot(o,0)):(s=o,i=""),e.push(s+(i?": "+i:"")+r)}return G&&((r=Ot(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&qn(t._prev,e,n)),e}function Ln(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function Ye(){ze()&&He()}function ze(){var t=$t;return $t=!1,ht=!1,t}function He(){var t,e,n;do for(;Re.length>0;)for(t=Re,Re=[],n=t.length,e=0;e<n;++e){var r=t[e];r[0].apply(null,r[1])}while(Re.length>0);$t=!0,ht=!0}function on(){var t=de;de=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=st.slice(0),n=e.length;n;)e[--n]()}function Ge(t){return new S(Me,!1,t)}function N(t,e){var n=P;return function(){var r=ze(),s=P;try{return ae(n,!0),t.apply(this,arguments)}catch(i){e&&e(i)}finally{ae(s,!1),r&&He()}}}Ce(S.prototype,{then:Dt,_then:function(t,e){sn(this,new Bn(null,null,t,e,P))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):Ge(r)):this.then(null,r=>r&&r.name===e?n(r):Ge(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Ge(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Nt=!0;var t=qn(this,[],20).join(`
7
- From previous: `);return this._state!==null&&(this._stack=t),t}finally{Nt=!1}}},timeout:function(t,e){return t<1/0?new S((n,r)=>{var s=setTimeout(()=>r(new E.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,s))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&ee(S.prototype,Symbol.toStringTag,"Dexie.Promise"),Se.env=Un(),Ce(S,{all:function(){var t=J.apply(null,arguments).map(Xe);return new S(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((s,i)=>S.resolve(s).then(o=>{t[i]=o,--r||e(t)},n))})},resolve:t=>{if(t instanceof S)return t;if(t&&typeof t.then=="function")return new S((n,r)=>{t.then(n,r)});var e=new S(Me,!0,t);return Ln(e,Kt),e},reject:Ge,race:function(){var t=J.apply(null,arguments).map(Xe);return new S((e,n)=>{t.map(r=>S.resolve(r).then(e,n))})},PSD:{get:()=>P,set:t=>P=t},totalEchoes:{get:()=>dt},newPSD:oe,usePSD:Te,scheduler:{get:()=>$e,set:t=>{$e=t}},rejectionMapper:{get:()=>jt,set:t=>{jt=t}},follow:(t,e)=>new S((n,r)=>oe((s,i)=>{var o=P;o.unhandleds=[],o.onunhandled=i,o.finalize=me(function(){(function(u){function a(){u(),st.splice(st.indexOf(a),1)}st.push(a),++fe,$e(()=>{--fe==0&&on()},[])})(()=>{this.unhandleds.length===0?s():i(this.unhandleds[0])})},o.finalize),t()},e,n,r))}),nt&&(nt.allSettled&&ee(S,"allSettled",function(){const t=J.apply(null,arguments).map(Xe);return new S(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((s,i)=>S.resolve(s).then(o=>r[i]={status:"fulfilled",value:o},o=>r[i]={status:"rejected",reason:o}).then(()=>--n||e(r)))})}),nt.any&&typeof AggregateError<"u"&&ee(S,"any",function(){const t=J.apply(null,arguments).map(Xe);return new S((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const s=new Array(r);t.forEach((i,o)=>S.resolve(i).then(u=>e(u),u=>{s[o]=u,--r||n(new AggregateError(s))}))})}));const F={awaits:0,echoes:0,id:0};var Sr=0,it=[],bt=0,dt=0,Cr=0;function oe(t,e,n,r){var s=P,i=Object.create(s);i.parent=s,i.ref=0,i.global=!1,i.id=++Cr;var o=Se.env;i.env=rn?{Promise:S,PromiseProp:{value:S,configurable:!0,writable:!0},all:S.all,race:S.race,allSettled:S.allSettled,any:S.any,resolve:S.resolve,reject:S.reject,nthen:fn(o.nthen,i),gthen:fn(o.gthen,i)}:{},e&&U(i,e),++s.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=Te(i,t,n,r);return i.ref===0&&i.finalize(),u}function Ee(){return F.id||(F.id=++Sr),++F.awaits,F.echoes+=jn,F.id}function ne(){return!!F.awaits&&(--F.awaits==0&&(F.id=0),F.echoes=F.awaits*jn,!0)}function Xe(t){return F.echoes&&t&&t.constructor===nt?(Ee(),t.then(e=>(ne(),e),e=>(ne(),D(e)))):t}function Pr(t){++dt,F.echoes&&--F.echoes!=0||(F.echoes=F.id=0),it.push(P),ae(t,!0)}function Er(){var t=it[it.length-1];it.pop(),ae(t,!1)}function ae(t,e){var n=P;if((e?!F.echoes||bt++&&t===P:!bt||--bt&&t===P)||Vn(e?Pr.bind(null,t):Er),t!==P&&(P=t,n===Se&&(Se.env=Un()),rn)){var r=Se.env.Promise,s=t.env;ct.then=s.nthen,r.prototype.then=s.gthen,(n.global||t.global)&&(Object.defineProperty(R,"Promise",s.PromiseProp),r.all=s.all,r.race=s.race,r.resolve=s.resolve,r.reject=s.reject,s.allSettled&&(r.allSettled=s.allSettled),s.any&&(r.any=s.any))}}function Un(){var t=R.Promise;return rn?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(R,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:ct.then,gthen:t.prototype.then}:{}}function Te(t,e,n,r,s){var i=P;try{return ae(t,!0),e(n,r,s)}finally{ae(i,!1)}}function Vn(t){Dn.call(It,t)}function ft(t,e,n,r){return typeof t!="function"?t:function(){var s=P;n&&Ee(),ae(e,!0);try{return t.apply(this,arguments)}finally{ae(s,!1),r&&Vn(ne)}}}function fn(t,e){return function(n,r){return t.call(this,ft(n,e),ft(r,e))}}(""+Dn).indexOf("[native code]")===-1&&(Ee=ne=I);const pn="unhandledrejection";function mn(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,s={promise:e,reason:t};if(R.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(pn,!0,!0),U(r,s)):R.CustomEvent&&U(r=new CustomEvent(pn,{detail:s}),s),r&&R.dispatchEvent&&(dispatchEvent(r),!R.PromiseRejectionEvent&&R.onunhandledrejection))try{R.onunhandledrejection(r)}catch{}G&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var D=S.reject;function Ft(t,e,n,r){if(t.idbdb&&(t._state.openComplete||P.letThrough||t._vip)){var s=t._createTransaction(e,n,t._dbSchema);try{s.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===tn.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Ft(t,e,n,r))):D(i)}return s._promise(e,(i,o)=>oe(()=>(P.trans=s,r(i,o,s)))).then(i=>s._completion.then(()=>i))}if(t._state.openComplete)return D(new E.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return D(new E.DatabaseClosed);t.open().catch(I)}return t._state.dbReadyPromise.then(()=>Ft(t,e,n,r))}const gn="3.2.4",he=String.fromCharCode(65535),Mt=-1/0,X="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Wn="String expected.",Ke=[],gt=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Tr=gt,Ar=gt,zn=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),yt="__dbnames",wt="readonly",_t="readwrite";function ge(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Hn={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Qe(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=We(e))[t],e)}class Or{_trans(e,n,r){const s=this._tx||P.trans,i=this.name;function o(a,c,h){if(!h.schema[i])throw new E.NotFound("Table "+i+" not part of transaction");return n(h.idbtrans,h)}const u=ze();try{return s&&s.db===this.db?s===P.trans?s._promise(e,o,r):oe(()=>s._promise(e,o,r),{trans:s,transless:P.transless||P}):Ft(this.db,e,[this.name],o)}finally{u&&He()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(s=>this.hook.reading.fire(s))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(M(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=j(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(h=>c.keyPath.indexOf(h)>=0)&&c.keyPath.every(h=>n.indexOf(h)>=0))[0];if(r&&this.db._maxKey!==he)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&&G&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:s}=this.schema,i=this.db._deps.indexedDB;function o(c,h){try{return i.cmp(c,h)===0}catch{return!1}}const[u,a]=n.reduce(([c,h],l)=>{const d=s[l],p=e[l];return[c||d,c||!d?ge(h,d&&d.multi?m=>{const f=te(m,l);return M(f)&&f.some(v=>o(p,v))}:m=>o(p,te(m,l))):h]},[null,null]);return u?this.where(u.name).equals(e[u.keyPath]).filter(a):r?this.filter(a):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,M(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const s=Object.create(e.prototype);for(var i in r)if(z(r,i))try{s[i]=r[i]}catch{}return s};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){U(this,e)})}add(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=Qe(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:n!=null?[n]:null,values:[i]})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{H(e,s,o)}catch{}return o})}update(e,n){if(typeof e!="object"||M(e))return this.where(":id").equals(e).modify(n);{const r=te(e,this.schema.primKey.keyPath);if(r===void 0)return D(new E.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?j(n).forEach(s=>{H(e,s,n[s])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=Qe(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[i],keys:n!=null?[n]:null})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{H(e,s,o)}catch{}return o})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?S.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Hn})).then(e=>e.numFailures?S.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(s=>this.hook.reading.fire(s))))}bulkAdd(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:u,keyPath:a}=this.schema.primKey;if(a&&s)throw new E.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new E.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let h=a&&u?e.map(Qe(a)):e;return this.core.mutate({trans:o,type:"add",keys:s,values:h,wantResults:i}).then(({numFailures:l,results:d,lastResult:p,failures:m})=>{if(l===0)return i?d:p;throw new Ne(`${this.name}.bulkAdd(): ${l} of ${c} operations failed`,m)})})}bulkPut(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:u,keyPath:a}=this.schema.primKey;if(a&&s)throw new E.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new E.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let h=a&&u?e.map(Qe(a)):e;return this.core.mutate({trans:o,type:"put",keys:s,values:h,wantResults:i}).then(({numFailures:l,results:d,lastResult:p,failures:m})=>{if(l===0)return i?d:p;throw new Ne(`${this.name}.bulkPut(): ${l} of ${c} operations failed`,m)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:s,failures:i})=>{if(r===0)return s;throw new Ne(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,i)})}}function je(t){var e={},n=function(o,u){if(u){for(var a=arguments.length,c=new Array(a-1);--a;)c[a-1]=arguments[a];return e[o].subscribe.apply(null,c),t}if(typeof o=="string")return e[o]};n.addEventType=i;for(var r=1,s=arguments.length;r<s;++r)i(arguments[r]);return n;function i(o,u,a){if(typeof o!="object"){var c;u||(u=_r),a||(a=I);var h={subscribers:[],fire:a,subscribe:function(l){h.subscribers.indexOf(l)===-1&&(h.subscribers.push(l),h.fire=u(h.fire,l))},unsubscribe:function(l){h.subscribers=h.subscribers.filter(function(d){return d!==l}),h.fire=h.subscribers.reduce(u,a)}};return e[o]=n[o]=h,h}j(c=o).forEach(function(l){var d=c[l];if(M(d))i(l,c[l][0],c[l][1]);else{if(d!=="asap")throw new E.InvalidArgument("Invalid event config");var p=i(l,Fe,function(){for(var m=arguments.length,f=new Array(m);m--;)f[m]=arguments[m];p.subscribers.forEach(function(v){En(function(){v.apply(null,f)})})})}})}}function Oe(t,e){return ke(e).from({prototype:t}),e}function be(t,e){return!(t.filter||t.algorithm||t.or)&&(e?t.justLimit:!t.replayFilter)}function kt(t,e){t.filter=ge(t.filter,e)}function xt(t,e,n){var r=t.replayFilter;t.replayFilter=r?()=>ge(r(),e()):e,t.justLimit=n&&!r}function ot(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new E.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function yn(t,e,n){const r=ot(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function Je(t,e,n,r){const s=t.replayFilter?ge(t.filter,t.replayFilter()):t.filter;if(t.or){const i={},o=(u,a,c)=>{if(!s||s(a,c,d=>a.stop(d),d=>a.fail(d))){var h=a.primaryKey,l=""+h;l==="[object ArrayBuffer]"&&(l=""+new Uint8Array(h)),z(i,l)||(i[l]=!0,e(u,a,c))}};return Promise.all([t.or._iterate(o,n),vn(yn(t,r,n),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}return vn(yn(t,r,n),ge(t.algorithm,s),e,!t.keysOnly&&t.valueMapper)}function vn(t,e,n,r){var s=N(r?(i,o,u)=>n(r(i),o,u):n);return t.then(i=>{if(i)return i.start(()=>{var o=()=>i.continue();e&&!e(i,u=>o=u,u=>{i.stop(u),o=I},u=>{i.fail(u),o=I})||s(i.value,i,u=>o=u),o()})})}function L(t,e){try{const n=bn(t),r=bn(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:t<e?-1:0;case"binary":return function(s,i){const o=s.length,u=i.length,a=o<u?o:u;for(let c=0;c<a;++c)if(s[c]!==i[c])return s[c]<i[c]?-1:1;return o===u?0:o<u?-1:1}(wn(t),wn(e));case"Array":return function(s,i){const o=s.length,u=i.length,a=o<u?o:u;for(let c=0;c<a;++c){const h=L(s[c],i[c]);if(h!==0)return h}return o===u?0:o<u?-1:1}(t,e)}}catch{}return NaN}function bn(t){const e=typeof t;if(e!=="object")return e;if(ArrayBuffer.isView(t))return"binary";const n=Tt(t);return n==="ArrayBuffer"?"binary":n}function wn(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class Ir{_read(e,n){var r=this._ctx;return r.error?r.table._trans(null,D.bind(null,r.error)):r.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,D.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=ge(n.algorithm,e)}_iterate(e,n){return Je(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&U(r,e),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(r=>Je(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,s=r.table.core;if(be(r,!0))return s.count({trans:n,query:{index:ot(r,s.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var i=0;return Je(r,()=>(++i,!1),n,s).then(()=>i)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),s=r[0],i=r.length-1;function o(c,h){return h?o(c[r[h]],h-1):c[s]}var u=this._ctx.dir==="next"?1:-1;function a(c,h){var l=o(c,i),d=o(h,i);return l<d?-u:l>d?u:0}return this.toArray(function(c){return c.sort(a)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&be(r,!0)&&r.limit>0){const{valueMapper:s}=r,i=ot(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:i,range:r.range}}).then(({result:o})=>s?o.map(s):o)}{const s=[];return Je(r,i=>s.push(i),n,r.table.core).then(()=>s)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,be(n)?xt(n,()=>{var r=e;return(s,i)=>r===0||(r===1?(--r,!1):(i(()=>{s.advance(r),r=0}),!1))}):xt(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),xt(this._ctx,()=>{var n=e;return function(r,s,i){return--n<=0&&s(i),n>=0}},!0),this}until(e,n){return kt(this._ctx,function(r,s,i){return!e(r.value)||(s(i),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return kt(this._ctx,function(s){return e(s.value)}),n=this._ctx,r=e,n.isMatch=ge(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.key,s)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.primaryKey,s)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&be(n,!0)&&n.limit>0)return this._read(s=>{var i=ot(n,n.table.core.schema);return n.table.core.query({trans:s,values:!1,limit:n.limit,query:{index:i,range:n.range}})}).then(({result:s})=>s).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return kt(this._ctx,function(s){var i=s.primaryKey.toString(),o=z(r,i);return r[i]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(r=>{var s;if(typeof e=="function")s=e;else{var i=j(e),o=i.length;s=function(f){for(var v=!1,y=0;y<o;++y){var g=i[y],b=e[g];te(f,g)!==b&&(H(f,g,b),v=!0)}return v}}const u=n.table.core,{outbound:a,extractKey:c}=u.schema.primaryKey,h=this.db._options.modifyChunkSize||200,l=[];let d=0;const p=[],m=(f,v)=>{const{failures:y,numFailures:g}=v;d+=f-g;for(let b of j(y))l.push(y[b])};return this.clone().primaryKeys().then(f=>{const v=y=>{const g=Math.min(h,f.length-y);return u.getMany({trans:r,keys:f.slice(y,y+g),cache:"immutable"}).then(b=>{const w=[],C=[],k=a?[]:null,_=[];for(let x=0;x<g;++x){const $=b[x],O={value:We($),primKey:f[y+x]};s.call(O,O.value,O)!==!1&&(O.value==null?_.push(f[y+x]):a||L(c($),c(O.value))===0?(C.push(O.value),a&&k.push(f[y+x])):(_.push(f[y+x]),w.push(O.value)))}const A=be(n)&&n.limit===1/0&&(typeof e!="function"||e===St)&&{index:n.index,range:n.range};return Promise.resolve(w.length>0&&u.mutate({trans:r,type:"add",values:w}).then(x=>{for(let $ in x.failures)_.splice(parseInt($),1);m(w.length,x)})).then(()=>(C.length>0||A&&typeof e=="object")&&u.mutate({trans:r,type:"put",keys:k,values:C,criteria:A,changeSpec:typeof e!="function"&&e}).then(x=>m(C.length,x))).then(()=>(_.length>0||A&&e===St)&&u.mutate({trans:r,type:"delete",keys:_,criteria:A}).then(x=>m(_.length,x))).then(()=>f.length>y+g&&v(y+h))})};return v(0).then(()=>{if(l.length>0)throw new lt("Error modifying one or more objects",l,d,p);return f.length})})})}delete(){var e=this._ctx,n=e.range;return be(e)&&(e.isPrimKey&&!Ar||n.type===3)?this._write(r=>{const{primaryKey:s}=e.table.core.schema,i=n;return e.table.core.count({trans:r,query:{index:s,range:i}}).then(o=>e.table.core.mutate({trans:r,type:"deleteRange",range:i}).then(({failures:u,lastResult:a,results:c,numFailures:h})=>{if(h)throw new lt("Could not delete some values",Object.keys(u).map(l=>u[l]),o-h);return o-h}))}):this.modify(St)}}const St=(t,e)=>e.value=null;function Rr(t,e){return t<e?-1:t===e?0:1}function Nr(t,e){return t>e?-1:t===e?0:1}function W(t,e,n){var r=t instanceof Gn?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function we(t){return new t.Collection(t,()=>Yn("")).limit(0)}function $r(t,e,n,r,s,i){for(var o=Math.min(t.length,r.length),u=-1,a=0;a<o;++a){var c=e[a];if(c!==r[a])return s(t[a],n[a])<0?t.substr(0,a)+n[a]+n.substr(a+1):s(t[a],r[a])<0?t.substr(0,a)+r[a]+n.substr(a+1):u>=0?t.substr(0,u)+e[u]+n.substr(u+1):null;s(t[a],c)<0&&(u=a)}return o<r.length&&i==="next"?t+n.substr(t.length):o<t.length&&i==="prev"?t.substr(0,n.length):u<0?null:t.substr(0,u)+r[u]+n.substr(u+1)}function Ze(t,e,n,r){var s,i,o,u,a,c,h,l=n.length;if(!n.every(f=>typeof f=="string"))return W(t,Wn);function d(f){s=function(y){return y==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(f),i=function(y){return y==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(f),o=f==="next"?Rr:Nr;var v=n.map(function(y){return{lower:i(y),upper:s(y)}}).sort(function(y,g){return o(y.lower,g.lower)});u=v.map(function(y){return y.upper}),a=v.map(function(y){return y.lower}),c=f,h=f==="next"?"":r}d("next");var p=new t.Collection(t,()=>re(u[0],a[l-1]+r));p._ondirectionchange=function(f){d(f)};var m=0;return p._addAlgorithm(function(f,v,y){var g=f.key;if(typeof g!="string")return!1;var b=i(g);if(e(b,a,m))return!0;for(var w=null,C=m;C<l;++C){var k=$r(g,b,u[C],a[C],o,c);k===null&&w===null?m=C+1:(w===null||o(w,k)>0)&&(w=k)}return v(w!==null?function(){f.continue(w+h)}:y),!1}),p}function re(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Yn(t){return{type:1,lower:t,upper:t}}class Gn{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,s){r=r!==!1,s=s===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||s)&&(!r||!s)?we(this):new this.Collection(this,()=>re(e,n,!r,!s))}catch{return W(this,X)}}equals(e){return e==null?W(this,X):new this.Collection(this,()=>Yn(e))}above(e){return e==null?W(this,X):new this.Collection(this,()=>re(e,void 0,!0))}aboveOrEqual(e){return e==null?W(this,X):new this.Collection(this,()=>re(e,void 0,!1))}below(e){return e==null?W(this,X):new this.Collection(this,()=>re(void 0,e,!1,!0))}belowOrEqual(e){return e==null?W(this,X):new this.Collection(this,()=>re(void 0,e))}startsWith(e){return typeof e!="string"?W(this,Wn):this.between(e,e+he,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):Ze(this,(n,r)=>n.indexOf(r[0])===0,[e],he)}equalsIgnoreCase(e){return Ze(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=J.apply(_e,arguments);return e.length===0?we(this):Ze(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=J.apply(_e,arguments);return e.length===0?we(this):Ze(this,(n,r)=>r.some(s=>n.indexOf(s)===0),e,he)}anyOf(){const e=J.apply(_e,arguments);let n=this._cmp;try{e.sort(n)}catch{return W(this,X)}if(e.length===0)return we(this);const r=new this.Collection(this,()=>re(e[0],e[e.length-1]));r._ondirectionchange=i=>{n=i==="next"?this._ascending:this._descending,e.sort(n)};let s=0;return r._addAlgorithm((i,o,u)=>{const a=i.key;for(;n(a,e[s])>0;)if(++s,s===e.length)return o(u),!1;return n(a,e[s])===0||(o(()=>{i.continue(e[s])}),!1)}),r}notEqual(e){return this.inAnyRange([[Mt,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=J.apply(_e,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return W(this,X)}const n=e.reduce((r,s)=>r?r.concat([[r[r.length-1][1],s]]):[[Mt,s]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,s=this._ascending,i=this._descending,o=this._min,u=this._max;if(e.length===0)return we(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&s(g[0],g[1])<=0))return W(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",E.InvalidArgument);const a=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let h,l=s;function d(g,b){return l(g[0],b[0])}try{h=e.reduce(function(g,b){let w=0,C=g.length;for(;w<C;++w){const k=g[w];if(r(b[0],k[1])<0&&r(b[1],k[0])>0){k[0]=o(k[0],b[0]),k[1]=u(k[1],b[1]);break}}return w===C&&g.push(b),g},[]),h.sort(d)}catch{return W(this,X)}let p=0;const m=c?g=>s(g,h[p][1])>0:g=>s(g,h[p][1])>=0,f=a?g=>i(g,h[p][0])>0:g=>i(g,h[p][0])>=0;let v=m;const y=new this.Collection(this,()=>re(h[0][0],h[h.length-1][1],!a,!c));return y._ondirectionchange=g=>{g==="next"?(v=m,l=s):(v=f,l=i),h.sort(d)},y._addAlgorithm((g,b,w)=>{for(var C=g.key;v(C);)if(++p,p===h.length)return b(w),!1;return!!function(k){return!m(k)&&!f(k)}(C)||(this._cmp(C,h[p][1])===0||this._cmp(C,h[p][0])===0||b(()=>{l===s?g.continue(h[p][0]):g.continue(h[p][1])}),!1)}),y}startsWithAnyOf(){const e=J.apply(_e,arguments);return e.every(n=>typeof n=="string")?e.length===0?we(this):this.inAnyRange(e.map(n=>[n,n+he])):W(this,"startsWithAnyOf() only works with strings")}}function Y(t){return N(function(e){return qe(e),t(e.target.error),!1})}function qe(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Le="storagemutated",ie="x-storagemutated-1",ue=je(null,Le);class Kr{_lock(){return Ie(!P.global),++this._reculock,this._reculock!==1||P.global||(P.lockOwnerFor=this),this}_unlock(){if(Ie(!P.global),--this._reculock==0)for(P.global||(P.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Te(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&P.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(Ie(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new E.DatabaseClosed(r);case"MissingAPIError":throw new E.MissingAPI(r.message,r);default:throw new E.OpenFailed(r)}if(!this.active)throw new E.TransactionInactive;return Ie(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=N(s=>{qe(s),this._reject(e.error)}),e.onabort=N(s=>{qe(s),this.active&&this._reject(new E.Abort(e.error)),this.active=!1,this.on("abort").fire(s)}),e.oncomplete=N(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&ue.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return D(new E.ReadOnly("Transaction is readonly"));if(!this.active)return D(new E.TransactionInactive);if(this._locked())return new S((i,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(i,o)},P])});if(r)return oe(()=>{var i=new S((o,u)=>{this._lock();const a=n(o,u,this);a&&a.then&&a.then(o,u)});return i.finally(()=>this._unlock()),i._lib=!0,i});var s=new S((i,o)=>{var u=n(i,o,this);u&&u.then&&u.then(i,o)});return s._lib=!0,s}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=S.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var s=n.idbtrans.objectStore(n.storeNames[0]);(function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(s.get(-1/0).onsuccess=o)})()}var i=n._waitingFor;return new S((o,u)=>{r.then(a=>n._waitingQueue.push(N(o.bind(null,a))),a=>n._waitingQueue.push(N(u.bind(null,a)))).finally(()=>{n._waitingFor===i&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new E.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(z(n,e))return n[e];const r=this.schema[e];if(!r)throw new E.NotFound("Table "+e+" not part of transaction");const s=new this.db.Table(e,r,this);return s.core=this.db.core.table(e),n[e]=s,s}}function qt(t,e,n,r,s,i,o){return{name:t,keyPath:e,unique:n,multi:r,auto:s,compound:i,src:(n&&!o?"&":"")+(r?"*":"")+(s?"++":"")+Xn(e)}}function Xn(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Qn(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:Tn(n,r=>[r.name,r])}}let Ue=t=>{try{return t.only([[]]),Ue=()=>[[]],[[]]}catch{return Ue=()=>he,he}};function Lt(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?n=>n[e]:n=>te(n,e)}(t):e=>te(e,t)}function _n(t){return[].slice.call(t)}let jr=0;function De(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Dr(t,e,n){function r(a){if(a.type===3)return null;if(a.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:h,lowerOpen:l,upperOpen:d}=a;return c===void 0?h===void 0?null:e.upperBound(h,!!d):h===void 0?e.lowerBound(c,!!l):e.bound(c,h,!!l,!!d)}const{schema:s,hasGetAll:i}=function(a,c){const h=_n(a.objectStoreNames);return{schema:{name:a.name,tables:h.map(l=>c.objectStore(l)).map(l=>{const{keyPath:d,autoIncrement:p}=l,m=M(d),f=d==null,v={},y={name:l.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:m,keyPath:d,autoIncrement:p,unique:!0,extractKey:Lt(d)},indexes:_n(l.indexNames).map(g=>l.index(g)).map(g=>{const{name:b,unique:w,multiEntry:C,keyPath:k}=g,_={name:b,compound:M(k),keyPath:k,unique:w,multiEntry:C,extractKey:Lt(k)};return v[De(k)]=_,_}),getIndexByKeyPath:g=>v[De(g)]};return v[":id"]=y.primaryKey,d!=null&&(v[De(d)]=y.primaryKey),y})},hasGetAll:h.length>0&&"getAll"in c.objectStore(h[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),o=s.tables.map(a=>function(c){const h=c.name;return{name:h,schema:c,mutate:function({trans:l,type:d,keys:p,values:m,range:f}){return new Promise((v,y)=>{v=N(v);const g=l.objectStore(h),b=g.keyPath==null,w=d==="put"||d==="add";if(!w&&d!=="delete"&&d!=="deleteRange")throw new Error("Invalid operation type: "+d);const{length:C}=p||m||{length:1};if(p&&m&&p.length!==m.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return v({numFailures:0,failures:{},results:[],lastResult:void 0});let k;const _=[],A=[];let x=0;const $=q=>{++x,qe(q)};if(d==="deleteRange"){if(f.type===4)return v({numFailures:x,failures:A,results:[],lastResult:void 0});f.type===3?_.push(k=g.clear()):_.push(k=g.delete(r(f)))}else{const[q,B]=w?b?[m,p]:[m,null]:[p,null];if(w)for(let K=0;K<C;++K)_.push(k=B&&B[K]!==void 0?g[d](q[K],B[K]):g[d](q[K])),k.onerror=$;else for(let K=0;K<C;++K)_.push(k=g[d](q[K])),k.onerror=$}const O=q=>{const B=q.target.result;_.forEach((K,ye)=>K.error!=null&&(A[ye]=K.error)),v({numFailures:x,failures:A,results:d==="delete"?p:_.map(K=>K.result),lastResult:B})};k.onerror=q=>{$(q),O(q)},k.onsuccess=O})},getMany:({trans:l,keys:d})=>new Promise((p,m)=>{p=N(p);const f=l.objectStore(h),v=d.length,y=new Array(v);let g,b=0,w=0;const C=_=>{const A=_.target;y[A._pos]=A.result,++w===b&&p(y)},k=Y(m);for(let _=0;_<v;++_)d[_]!=null&&(g=f.get(d[_]),g._pos=_,g.onsuccess=C,g.onerror=k,++b);b===0&&p(y)}),get:({trans:l,key:d})=>new Promise((p,m)=>{p=N(p);const f=l.objectStore(h).get(d);f.onsuccess=v=>p(v.target.result),f.onerror=Y(m)}),query:function(l){return d=>new Promise((p,m)=>{p=N(p);const{trans:f,values:v,limit:y,query:g}=d,b=y===1/0?void 0:y,{index:w,range:C}=g,k=f.objectStore(h),_=w.isPrimaryKey?k:k.index(w.name),A=r(C);if(y===0)return p({result:[]});if(l){const x=v?_.getAll(A,b):_.getAllKeys(A,b);x.onsuccess=$=>p({result:$.target.result}),x.onerror=Y(m)}else{let x=0;const $=v||!("openKeyCursor"in _)?_.openCursor(A):_.openKeyCursor(A),O=[];$.onsuccess=q=>{const B=$.result;return B?(O.push(v?B.value:B.primaryKey),++x===y?p({result:O}):void B.continue()):p({result:O})},$.onerror=Y(m)}})}(i),openCursor:function({trans:l,values:d,query:p,reverse:m,unique:f}){return new Promise((v,y)=>{v=N(v);const{index:g,range:b}=p,w=l.objectStore(h),C=g.isPrimaryKey?w:w.index(g.name),k=m?f?"prevunique":"prev":f?"nextunique":"next",_=d||!("openKeyCursor"in C)?C.openCursor(r(b),k):C.openKeyCursor(r(b),k);_.onerror=Y(y),_.onsuccess=N(A=>{const x=_.result;if(!x)return void v(null);x.___id=++jr,x.done=!1;const $=x.continue.bind(x);let O=x.continuePrimaryKey;O&&(O=O.bind(x));const q=x.advance.bind(x),B=()=>{throw new Error("Cursor not stopped")};x.trans=l,x.stop=x.continue=x.continuePrimaryKey=x.advance=()=>{throw new Error("Cursor not started")},x.fail=N(y),x.next=function(){let K=1;return this.start(()=>K--?this.continue():this.stop()).then(()=>this)},x.start=K=>{const ye=new Promise((V,le)=>{V=N(V),_.onerror=Y(le),x.fail=le,x.stop=Ae=>{x.stop=x.continue=x.continuePrimaryKey=x.advance=B,V(Ae)}}),ve=()=>{if(_.result)try{K()}catch(V){x.fail(V)}else x.done=!0,x.start=()=>{throw new Error("Cursor behind last entry")},x.stop()};return _.onsuccess=N(V=>{_.onsuccess=ve,ve()}),x.continue=$,x.continuePrimaryKey=O,x.advance=q,ve(),ye},v(x)},y)})},count({query:l,trans:d}){const{index:p,range:m}=l;return new Promise((f,v)=>{const y=d.objectStore(h),g=p.isPrimaryKey?y:y.index(p.name),b=r(m),w=b?g.count(b):g.count();w.onsuccess=N(C=>f(C.target.result)),w.onerror=Y(v)})}}}(a)),u={};return o.forEach(a=>u[a.name]=a),{stack:"dbcore",transaction:t.transaction.bind(t),table(a){if(!u[a])throw new Error(`Table '${a}' not found`);return u[a]},MIN_KEY:-1/0,MAX_KEY:Ue(e),schema:s}}function Ut({_novip:t},e){const n=e.db,r=function(s,i,{IDBKeyRange:o,indexedDB:u},a){return{dbcore:function(c,h){return h.reduce((l,{create:d})=>({...l,...d(l)}),c)}(Dr(i,o,a),s.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(s=>{const i=s.name;t.core.schema.tables.some(o=>o.name===i)&&(s.core=t.core.table(i),t[i]instanceof t.Table&&(t[i].core=s.core))})}function pt({_novip:t},e,n,r){n.forEach(s=>{const i=r[s];e.forEach(o=>{const u=Jt(o,s);(!u||"value"in u&&u.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?ee(o,s,{get(){return this.table(s)},set(a){Cn(this,s,{value:a,writable:!0,configurable:!0,enumerable:!0})}}):o[s]=new t.Table(s,i))})})}function Vt({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Br(t,e){return t._cfg.version-e._cfg.version}function Fr(t,e,n,r){const s=t._dbSchema,i=t._createTransaction("readwrite",t._storeNames,s);i.create(n),i._completion.catch(r);const o=i._reject.bind(i),u=P.transless||P;oe(()=>{P.trans=i,P.transless=u,e===0?(j(s).forEach(a=>{Ct(n,a,s[a].primKey,s[a].indexes)}),Ut(t,n),S.follow(()=>t.on.populate.fire(i)).catch(o)):function({_novip:a},c,h,l){const d=[],p=a._versions;let m=a._dbSchema=zt(a,a.idbdb,l),f=!1;const v=p.filter(g=>g._cfg.version>=c);function y(){return d.length?S.resolve(d.shift()(h.idbtrans)).then(y):S.resolve()}return v.forEach(g=>{d.push(()=>{const b=m,w=g._cfg.dbschema;Ht(a,b,l),Ht(a,w,l),m=a._dbSchema=w;const C=Jn(b,w);C.add.forEach(_=>{Ct(l,_[0],_[1].primKey,_[1].indexes)}),C.change.forEach(_=>{if(_.recreate)throw new E.Upgrade("Not yet support for changing primary key");{const A=l.objectStore(_.name);_.add.forEach(x=>Wt(A,x)),_.change.forEach(x=>{A.deleteIndex(x.name),Wt(A,x)}),_.del.forEach(x=>A.deleteIndex(x))}});const k=g._cfg.contentUpgrade;if(k&&g._cfg.version>c){Ut(a,l),h._memoizedTables={},f=!0;let _=An(w);C.del.forEach(O=>{_[O]=b[O]}),Vt(a,[a.Transaction.prototype]),pt(a,[a.Transaction.prototype],j(_),_),h.schema=_;const A=Zt(k);let x;A&&Ee();const $=S.follow(()=>{if(x=k(h),x&&A){var O=ne.bind(null,null);x.then(O,O)}});return x&&typeof x.then=="function"?S.resolve(x):$.then(()=>x)}}),d.push(b=>{(!f||!Tr)&&function(w,C){[].slice.call(C.db.objectStoreNames).forEach(k=>w[k]==null&&C.db.deleteObjectStore(k))}(g._cfg.dbschema,b),Vt(a,[a.Transaction.prototype]),pt(a,[a.Transaction.prototype],a._storeNames,a._dbSchema),h.schema=a._dbSchema})}),y().then(()=>{var g,b;b=l,j(g=m).forEach(w=>{b.db.objectStoreNames.contains(w)||Ct(b,w,g[w].primKey,g[w].indexes)})})}(t,e,i,n).catch(o)})}function Jn(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const s=t[r],i=e[r];if(s){const o={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!gt)o.recreate=!0,n.change.push(o);else{const u=s.idxByName,a=i.idxByName;let c;for(c in u)a[c]||o.del.push(c);for(c in a){const h=u[c],l=a[c];h?h.src!==l.src&&o.change.push(l):o.add.push(l)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}else n.add.push([r,i])}return n}function Ct(t,e,n,r){const s=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(i=>Wt(s,i)),s}function Wt(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function zt(t,e,n){const r={};return ut(e.objectStoreNames,0).forEach(s=>{const i=n.objectStore(s);let o=i.keyPath;const u=qt(Xn(o),o||"",!1,!1,!!i.autoIncrement,o&&typeof o!="string",!0),a=[];for(let h=0;h<i.indexNames.length;++h){const l=i.index(i.indexNames[h]);o=l.keyPath;var c=qt(l.name,o,!!l.unique,!!l.multiEntry,!1,o&&typeof o!="string",!1);a.push(c)}r[s]=Qn(s,u,a)}),r}function Ht({_novip:t},e,n){const r=n.db.objectStoreNames;for(let s=0;s<r.length;++s){const i=r[s],o=n.objectStore(i);t._hasGetAll="getAll"in o;for(let u=0;u<o.indexNames.length;++u){const a=o.indexNames[u],c=o.index(a).keyPath,h=typeof c=="string"?c:"["+ut(c).join("+")+"]";if(e[i]){const l=e[i].idxByName[h];l&&(l.name=a,delete e[i].idxByName[h],e[i].idxByName[a]=l)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&R.WorkerGlobalScope&&R instanceof R.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class Mr{_parseStoresSpec(e,n){j(e).forEach(r=>{if(e[r]!==null){var s=e[r].split(",").map((o,u)=>{const a=(o=o.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(a)?a.match(/^\[(.*)\]$/)[1].split("+"):a;return qt(a,c||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),M(c),u===0)}),i=s.shift();if(i.multi)throw new E.Schema("Primary key cannot be multi-valued");s.forEach(o=>{if(o.auto)throw new E.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new E.Schema("Index must have a name and cannot be an empty string")}),n[r]=Qn(r,i,s)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?U(this._cfg.storesSource,e):e;const r=n._versions,s={};let i={};return r.forEach(o=>{U(s,o._cfg.storesSource),i=o._cfg.dbschema={},o._parseStoresSpec(s,i)}),n._dbSchema=i,Vt(n,[n._allTables,n,n.Transaction.prototype]),pt(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],j(i),i),n._storeNames=j(i),this}upgrade(e){return this._cfg.contentUpgrade=nn(this._cfg.contentUpgrade||I,e),this}}function an(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new pe(yt,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function un(t){return t&&typeof t.databases=="function"}function Yt(t){return oe(function(){return P.letThrough=!0,t()})}function qr(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function Lr(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?D(e.dbOpenError):t);G&&(e.openCanceller._stackHolder=Pe()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function s(){if(e.openCanceller!==r)throw new E.DatabaseClosed("db.open() was cancelled")}let i=e.dbReadyResolve,o=null,u=!1;return S.race([r,(typeof navigator>"u"?S.resolve():qr()).then(()=>new S((a,c)=>{if(s(),!n)throw new E.MissingAPI;const h=t.name,l=e.autoSchema?n.open(h):n.open(h,Math.round(10*t.verno));if(!l)throw new E.MissingAPI;l.onerror=Y(c),l.onblocked=N(t._fireOnBlocked),l.onupgradeneeded=N(d=>{if(o=l.transaction,e.autoSchema&&!t._options.allowEmptyDB){l.onerror=qe,o.abort(),l.result.close();const m=n.deleteDatabase(h);m.onsuccess=m.onerror=N(()=>{c(new E.NoSuchDatabase(`Database ${h} doesnt exist`))})}else{o.onerror=Y(c);var p=d.oldVersion>Math.pow(2,62)?0:d.oldVersion;u=p<1,t._novip.idbdb=l.result,Fr(t,p/10,o,c)}},c),l.onsuccess=N(()=>{o=null;const d=t._novip.idbdb=l.result,p=ut(d.objectStoreNames);if(p.length>0)try{const f=d.transaction((m=p).length===1?m[0]:m,"readonly");e.autoSchema?function({_novip:v},y,g){v.verno=y.version/10;const b=v._dbSchema=zt(0,y,g);v._storeNames=ut(y.objectStoreNames,0),pt(v,[v._allTables],j(b),b)}(t,d,f):(Ht(t,t._dbSchema,f),function(v,y){const g=Jn(zt(0,v.idbdb,y),v._dbSchema);return!(g.add.length||g.change.some(b=>b.add.length||b.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ut(t,f)}catch{}var m;Ke.push(t),d.onversionchange=N(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),d.onclose=N(f=>{t.on("close").fire(f)}),u&&function({indexedDB:f,IDBKeyRange:v},y){!un(f)&&y!==yt&&an(f,v).put({name:y}).catch(I)}(t._deps,h),a()},c)}))]).then(()=>(s(),e.onReadyBeingFired=[],S.resolve(Yt(()=>t.on.ready.fire(t.vip))).then(function a(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(nn,I);return e.onReadyBeingFired=[],S.resolve(Yt(()=>c(t.vip))).then(a)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(a=>{e.dbOpenError=a;try{o&&o.abort()}catch{}return r===e.openCanceller&&t._close(),D(a)}).finally(()=>{e.openComplete=!0,i()})}function Gt(t){var e=i=>t.next(i),n=s(e),r=s(i=>t.throw(i));function s(i){return o=>{var u=i(o),a=u.value;return u.done?a:a&&typeof a.then=="function"?a.then(n,r):M(a)?Promise.all(a).then(n,r):n(a)}}return s(e)()}function Ur(t,e,n){var r=arguments.length;if(r<2)throw new E.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[t,On(s),n]}function Zn(t,e,n,r,s){return S.resolve().then(()=>{const i=P.transless||P,o=t._createTransaction(e,n,t._dbSchema,r),u={trans:o,transless:i};if(r)o.idbtrans=r.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(l){return l.name===tn.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Zn(t,e,n,null,s))):D(l)}const a=Zt(s);let c;a&&Ee();const h=S.follow(()=>{if(c=s.call(o,o),c)if(a){var l=ne.bind(null,null);c.then(l,l)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Gt(c))},u);return(c&&typeof c.then=="function"?S.resolve(c).then(l=>o.active?l:D(new E.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):h.then(()=>c)).then(l=>(r&&o._resolve(),o._completion.then(()=>l))).catch(l=>(o._reject(l),D(l)))})}function et(t,e,n){const r=M(t)?t.slice():[t];for(let s=0;s<n;++s)r.push(e);return r}const Vr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(t){return{...t,table(e){const n=t.table(e),{schema:r}=n,s={},i=[];function o(c,h,l){const d=De(c),p=s[d]=s[d]||[],m=c==null?0:typeof c=="string"?1:c.length,f=h>0,v={...l,isVirtual:f,keyTail:h,keyLength:m,extractKey:Lt(c),unique:!f&&l.unique};return p.push(v),v.isPrimaryKey||i.push(v),m>1&&o(m===2?c[0]:c.slice(0,m-1),h+1,l),p.sort((y,g)=>y.keyTail-g.keyTail),v}const u=o(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[u];for(const c of r.indexes)o(c.keyPath,0,c);function a(c){const h=c.query.index;return h.isVirtual?{...c,query:{index:h,range:(l=c.query.range,d=h.keyTail,{type:l.type===1?2:l.type,lower:et(l.lower,l.lowerOpen?t.MAX_KEY:t.MIN_KEY,d),lowerOpen:!0,upper:et(l.upper,l.upperOpen?t.MIN_KEY:t.MAX_KEY,d),upperOpen:!0})}}:c;var l,d}return{...n,schema:{...r,primaryKey:u,indexes:i,getIndexByKeyPath:function(c){const h=s[De(c)];return h&&h[0]}},count:c=>n.count(a(c)),query:c=>n.query(a(c)),openCursor(c){const{keyTail:h,isVirtual:l,keyLength:d}=c.query.index;return l?n.openCursor(a(c)).then(p=>p&&function(m){return Object.create(m,{continue:{value:function(f){f!=null?m.continue(et(f,c.reverse?t.MAX_KEY:t.MIN_KEY,h)):c.unique?m.continue(m.key.slice(0,d).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,h)):m.continue()}},continuePrimaryKey:{value(f,v){m.continuePrimaryKey(et(f,t.MAX_KEY,h),v)}},primaryKey:{get:()=>m.primaryKey},key:{get(){const f=m.key;return d===1?f[0]:f.slice(0,d)}},value:{get:()=>m.value}})}(p)):n.openCursor(c)}}}}}};function ln(t,e,n,r){return n=n||{},r=r||"",j(t).forEach(s=>{if(z(e,s)){var i=t[s],o=e[s];if(typeof i=="object"&&typeof o=="object"&&i&&o){const u=Tt(i);u!==Tt(o)?n[r+s]=e[s]:u==="Object"?ln(i,o,n,r+s+"."):i!==o&&(n[r+s]=e[s])}else i!==o&&(n[r+s]=e[s])}else n[r+s]=void 0}),j(e).forEach(s=>{z(t,s)||(n[r+s]=e[s])}),n}const Wr={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=P.trans,{deleting:o,creating:u,updating:a}=i.table(e).hook;switch(s.type){case"add":if(u.fire===I)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(u.fire===I&&a.fire===I)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(o.fire===I)break;return i._promise("readwrite",()=>c(s),!0);case"deleteRange":if(o.fire===I)break;return i._promise("readwrite",()=>function(l){return h(l.trans,l.range,1e4)}(s),!0)}return n.mutate(s);function c(l){const d=P.trans,p=l.keys||function(m,f){return f.type==="delete"?f.keys:f.keys||f.values.map(m.extractKey)}(r,l);if(!p)throw new Error("Keys missing");return(l=l.type==="add"||l.type==="put"?{...l,keys:p}:{...l}).type!=="delete"&&(l.values=[...l.values]),l.keys&&(l.keys=[...l.keys]),function(m,f,v){return f.type==="add"?Promise.resolve([]):m.getMany({trans:f.trans,keys:v,cache:"immutable"})}(n,l,p).then(m=>{const f=p.map((v,y)=>{const g=m[y],b={onerror:null,onsuccess:null};if(l.type==="delete")o.fire.call(b,v,g,d);else if(l.type==="add"||g===void 0){const w=u.fire.call(b,v,l.values[y],d);v==null&&w!=null&&(v=w,l.keys[y]=v,r.outbound||H(l.values[y],r.keyPath,v))}else{const w=ln(g,l.values[y]),C=a.fire.call(b,w,v,g,d);if(C){const k=l.values[y];Object.keys(C).forEach(_=>{z(k,_)?k[_]=C[_]:H(k,_,C[_])})}}return b});return n.mutate(l).then(({failures:v,results:y,numFailures:g,lastResult:b})=>{for(let w=0;w<p.length;++w){const C=y?y[w]:p[w],k=f[w];C==null?k.onerror&&k.onerror(v[w]):k.onsuccess&&k.onsuccess(l.type==="put"&&m[w]?l.values[w]:C)}return{failures:v,results:y,numFailures:g,lastResult:b}}).catch(v=>(f.forEach(y=>y.onerror&&y.onerror(v)),Promise.reject(v)))})}function h(l,d,p){return n.query({trans:l,values:!1,query:{index:r,range:d},limit:p}).then(({result:m})=>c({type:"delete",keys:m,trans:l}).then(f=>f.numFailures>0?Promise.reject(f.failures[0]):m.length<p?{failures:[],numFailures:0,lastResult:void 0}:h(l,{...d,lower:m[m.length-1],lowerOpen:!0},p)))}}}}})};function er(t,e,n){try{if(!e||e.keys.length<t.length)return null;const r=[];for(let s=0,i=0;s<e.keys.length&&i<t.length;++s)L(e.keys[s],t[i])===0&&(r.push(n?We(e.values[s]):e.values[s]),++i);return r.length===t.length?r:null}catch{return null}}const zr={stack:"dbcore",level:-1,create:t=>({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const s=er(r.keys,r.trans._cache,r.cache==="clone");return s?S.resolve(s):n.getMany(r).then(i=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?We(i):i},i))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function cn(t){return!("from"in t)}const Q=function(t,e){if(!this){const n=new Q;return t&&"d"in t&&U(n,t),n}U(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Ve(t,e,n){const r=L(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(cn(t))return U(t,{from:e,to:n,d:1});const s=t.l,i=t.r;if(L(n,t.from)<0)return s?Ve(s,e,n):t.l={from:e,to:n,d:1,l:null,r:null},kn(t);if(L(e,t.to)>0)return i?Ve(i,e,n):t.r={from:e,to:n,d:1,l:null,r:null},kn(t);L(e,t.from)<0&&(t.from=e,t.l=null,t.d=i?i.d+1:1),L(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const o=!t.r;s&&!t.l&&mt(t,s),i&&o&&mt(t,i)}function mt(t,e){cn(e)||function n(r,{from:s,to:i,l:o,r:u}){Ve(r,s,i),o&&n(r,o),u&&n(r,u)}(t,e)}function Hr(t,e){const n=Xt(e);let r=n.next();if(r.done)return!1;let s=r.value;const i=Xt(t);let o=i.next(s.from),u=o.value;for(;!r.done&&!o.done;){if(L(u.from,s.to)<=0&&L(u.to,s.from)>=0)return!0;L(s.from,u.from)<0?s=(r=n.next(u.from)).value:u=(o=i.next(s.from)).value}return!1}function Xt(t){let e=cn(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&L(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||L(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function kn(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const i=s==="r"?"l":"r",o={...t},u=t[s];t.from=u.from,t.to=u.to,t[s]=u[s],o[s]=u[i],t[i]=o,o.d=xn(o)}t.d=xn(t)}function xn({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}Ce(Q.prototype,{add(t){return mt(this,t),this},addKey(t){return Ve(this,t,t),this},addKeys(t){return t.forEach(e=>Ve(this,e,e)),this},[At](){return Xt(this)}});const Yr={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new Q(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const s=t.table(r),{schema:i}=s,{primaryKey:o}=i,{extractKey:u,outbound:a}=o,c={...s,mutate:d=>{const p=d.trans,m=p.mutatedParts||(p.mutatedParts={}),f=k=>{const _=`idb://${e}/${r}/${k}`;return m[_]||(m[_]=new Q)},v=f(""),y=f(":dels"),{type:g}=d;let[b,w]=d.type==="deleteRange"?[d.range]:d.type==="delete"?[d.keys]:d.values.length<50?[[],d.values]:[];const C=d.trans._cache;return s.mutate(d).then(k=>{if(M(b)){g!=="delete"&&(b=k.results),v.addKeys(b);const _=er(b,C);_||g==="add"||y.addKeys(b),(_||w)&&function(A,x,$,O){function q(B){const K=A(B.name||"");function ye(V){return V!=null?B.extractKey(V):null}const ve=V=>B.multiEntry&&M(V)?V.forEach(le=>K.addKey(le)):K.addKey(V);($||O).forEach((V,le)=>{const Ae=$&&ye($[le]),vt=O&&ye(O[le]);L(Ae,vt)!==0&&(Ae!=null&&ve(Ae),vt!=null&&ve(vt))})}x.indexes.forEach(q)}(f,i,_,w)}else if(b){const _={from:b.lower,to:b.upper};y.add(_),v.add(_)}else v.add(n),y.add(n),i.indexes.forEach(_=>f(_.name).add(n));return k})}},h=({query:{index:d,range:p}})=>{var m,f;return[d,new Q((m=p.lower)!==null&&m!==void 0?m:t.MIN_KEY,(f=p.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},l={get:d=>[o,new Q(d.key)],getMany:d=>[o,new Q().addKeys(d.keys)],count:h,query:h,openCursor:h};return j(l).forEach(d=>{c[d]=function(p){const{subscr:m}=P;if(m){const f=w=>{const C=`idb://${e}/${r}/${w}`;return m[C]||(m[C]=new Q)},v=f(""),y=f(":dels"),[g,b]=l[d](p);if(f(g.name||"").add(b),!g.isPrimaryKey){if(d!=="count"){const w=d==="query"&&a&&p.values&&s.query({...p,values:!1});return s[d].apply(this,arguments).then(C=>{if(d==="query"){if(a&&p.values)return w.then(({result:_})=>(v.addKeys(_),C));const k=p.values?C.result.map(u):C.result;p.values?v.addKeys(k):y.addKeys(k)}else if(d==="openCursor"){const k=C,_=p.values;return k&&Object.create(k,{key:{get:()=>(y.addKey(k.primaryKey),k.key)},primaryKey:{get(){const A=k.primaryKey;return y.addKey(A),A}},value:{get:()=>(_&&v.addKey(k.primaryKey),k.value)}})}return C})}y.add(n)}}return s[d].apply(this,arguments)}}),c}}}};class pe{constructor(e,n){this._middlewares={},this.verno=0;const r=pe.dependencies;this._options=n={addons:pe.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:s}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:I,dbReadyPromise:null,cancelOpen:I,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var o;i.dbReadyPromise=new S(u=>{i.dbReadyResolve=u}),i.openCanceller=new S((u,a)=>{i.cancelOpen=a}),this._state=i,this.name=e,this.on=je(this,"populate","blocked","versionchange","close",{ready:[nn,I]}),this.on.ready.subscribe=Pn(this.on.ready.subscribe,u=>(a,c)=>{pe.vip(()=>{const h=this._state;if(h.openComplete)h.dbOpenError||S.resolve().then(a),c&&u(a);else if(h.onReadyBeingFired)h.onReadyBeingFired.push(a),c&&u(a);else{u(a);const l=this;c||u(function d(){l.on.ready.unsubscribe(a),l.on.ready.unsubscribe(d)})}})}),this.Collection=(o=this,Oe(Ir.prototype,function(u,a){this.db=o;let c=Hn,h=null;if(a)try{c=a()}catch(m){h=m}const l=u._ctx,d=l.table,p=d.hook.reading.fire;this._ctx={table:d,index:l.index,isPrimKey:!l.index||d.schema.primKey.keyPath&&l.index===d.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:h,or:l.or,valueMapper:p!==Fe?p:null}})),this.Table=function(u){return Oe(Or.prototype,function(a,c,h){this.db=u,this._tx=h,this.name=a,this.schema=c,this.hook=u._allTables[a]?u._allTables[a].hook:je(null,{creating:[vr,I],reading:[yr,Fe],updating:[wr,I],deleting:[br,I]})})}(this),this.Transaction=function(u){return Oe(Kr.prototype,function(a,c,h,l,d){this.db=u,this.mode=a,this.storeNames=c,this.schema=h,this.chromeTransactionDurability=l,this.idbtrans=null,this.on=je(this,"complete","error","abort"),this.parent=d||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new S((p,m)=>{this._resolve=p,this._reject=m}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var m=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):m&&this.idbtrans&&this.idbtrans.abort(),D(p)})})}(this),this.Version=function(u){return Oe(Mr.prototype,function(a){this.db=u,this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(u){return Oe(Gn.prototype,function(a,c,h){this.db=u,this._ctx={table:a,index:c===":id"?null:c,or:h};const l=u._deps.indexedDB;if(!l)throw new E.MissingAPI;this._cmp=this._ascending=l.cmp.bind(l),this._descending=(d,p)=>l.cmp(p,d),this._max=(d,p)=>l.cmp(d,p)>0?d:p,this._min=(d,p)=>l.cmp(d,p)<0?d:p,this._IDBKeyRange=u._deps.IDBKeyRange})}(this),this.on("versionchange",u=>{u.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",u=>{!u.newVersion||u.newVersion<u.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${u.oldVersion/10}`)}),this._maxKey=Ue(n.IDBKeyRange),this._createTransaction=(u,a,c,h)=>new this.Transaction(u,a,c,this._options.chromeTransactionDurability,h),this._fireOnBlocked=u=>{this.on("blocked").fire(u),Ke.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(u))},this.use(Vr),this.use(Wr),this.use(Yr),this.use(zr),this.vip=Object.create(this,{_vip:{value:!0}}),s.forEach(u=>u(this))}version(e){if(isNaN(e)||e<.1)throw new E.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new E.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(s=>s._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(Br),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||P.letThrough||this._vip)?e():new S((n,r)=>{if(this._state.openComplete)return r(new E.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new E.DatabaseClosed);this.open().catch(I)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:s}){s&&this.unuse({stack:e,name:s});const i=this._middlewares[e]||(this._middlewares[e]=[]);return i.push({stack:e,create:n,level:r??10,name:s}),i.sort((o,u)=>o.level-u.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(s=>r?s.create!==r:!!n&&s.name!==n)),this}open(){return Lr(this)}_close(){const e=this._state,n=Ke.indexOf(this);if(n>=0&&Ke.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new S(r=>{e.dbReadyResolve=r}),e.openCanceller=new S((r,s)=>{e.cancelOpen=s})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new E.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new S((r,s)=>{const i=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=N(()=>{(function({indexedDB:u,IDBKeyRange:a},c){!un(u)&&c!==yt&&an(u,a).delete(c).catch(I)})(this._deps,this.name),r()}),o.onerror=Y(s),o.onblocked=this._fireOnBlocked};if(e)throw new E.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(i):i()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return j(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Ur.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let s=P.trans;s&&s.db===this&&e.indexOf("!")===-1||(s=null);const i=e.indexOf("?")!==-1;let o,u;e=e.replace("!","").replace("?","");try{if(u=n.map(c=>{var h=c instanceof this.Table?c.name:c;if(typeof h!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return h}),e=="r"||e===wt)o=wt;else{if(e!="rw"&&e!=_t)throw new E.InvalidArgument("Invalid transaction mode: "+e);o=_t}if(s){if(s.mode===wt&&o===_t){if(!i)throw new E.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");s=null}s&&u.forEach(c=>{if(s&&s.storeNames.indexOf(c)===-1){if(!i)throw new E.SubTransaction("Table "+c+" not included in parent transaction.");s=null}}),i&&s&&!s.active&&(s=null)}}catch(c){return s?s._promise(null,(h,l)=>{l(c)}):D(c)}const a=Zn.bind(null,this,o,u,s,r);return s?s._promise(o,a,"lock"):P.trans?Te(P.transless,()=>this._whenReady(a)):this._whenReady(a)}table(e){if(!z(this._allTables,e))throw new E.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Gr=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Xr{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Gr](){return this}}function tr(t,e){return j(e).forEach(n=>{mt(t[n]||(t[n]=new Q),e[n])}),t}function Qr(t){let e,n=!1;const r=new Xr(s=>{const i=Zt(t);let o=!1,u={},a={};const c={get closed(){return o},unsubscribe:()=>{o=!0,ue.storagemutated.unsubscribe(p)}};s.start&&s.start(c);let h=!1,l=!1;function d(){return j(a).some(f=>u[f]&&Hr(u[f],a[f]))}const p=f=>{tr(u,f),d()&&m()},m=()=>{if(h||o)return;u={};const f={},v=function(y){i&&Ee();const g=()=>oe(t,{subscr:y,trans:null}),b=P.trans?Te(P.transless,g):g();return i&&b.then(ne,ne),b}(f);l||(ue(Le,p),l=!0),h=!0,Promise.resolve(v).then(y=>{n=!0,e=y,h=!1,o||(d()?m():(u={},a=f,s.next&&s.next(y)))},y=>{h=!1,n=!1,s.error&&s.error(y),c.unsubscribe()})};return m(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let Qt;try{Qt={indexedDB:R.indexedDB||R.mozIndexedDB||R.webkitIndexedDB||R.msIndexedDB,IDBKeyRange:R.IDBKeyRange||R.webkitIDBKeyRange}}catch{Qt={indexedDB:null,IDBKeyRange:null}}const ce=pe;function at(t){let e=Z;try{Z=!0,ue.storagemutated.fire(t)}finally{Z=e}}Ce(ce,{...tt,delete:t=>new ce(t,{addons:[]}).delete(),exists:t=>new ce(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return un(e)?Promise.resolve(e.databases()).then(r=>r.map(s=>s.name).filter(s=>s!==yt)):an(e,n).toCollection().primaryKeys()}(ce.dependencies).then(t)}catch{return D(new E.MissingAPI)}},defineClass:()=>function(t){U(this,t)},ignoreTransaction:t=>P.trans?Te(P.transless,t):t(),vip:Yt,async:function(t){return function(){try{var e=Gt(t.apply(this,arguments));return e&&typeof e.then=="function"?e:S.resolve(e)}catch(n){return D(n)}}},spawn:function(t,e,n){try{var r=Gt(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:S.resolve(r)}catch(s){return D(s)}},currentTransaction:{get:()=>P.trans||null},waitFor:function(t,e){const n=S.resolve(typeof t=="function"?ce.ignoreTransaction(t):t).timeout(e||6e4);return P.trans?P.trans.waitFor(n):n},Promise:S,debug:{get:()=>G,set:t=>{Rn(t,t==="dexie"?()=>!0:zn)}},derive:ke,extend:U,props:Ce,override:Pn,Events:je,on:ue,liveQuery:Qr,extendObservabilitySet:tr,getByKeyPath:te,setByKeyPath:H,delByKeyPath:function(t,e){typeof e=="string"?H(t,e,void 0):"length"in e&&[].map.call(e,function(n){H(t,n,void 0)})},shallowClone:An,deepClone:We,getObjectDiff:ln,cmp:L,asap:En,minKey:Mt,addons:[],connections:Ke,errnames:tn,dependencies:Qt,semVer:gn,version:gn.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),ce.maxKey=Ue(ce.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ue(Le,t=>{if(!Z){let e;gt?(e=document.createEvent("CustomEvent"),e.initCustomEvent(ie,!0,!0,t)):e=new CustomEvent(ie,{detail:t}),Z=!0,dispatchEvent(e),Z=!1}}),addEventListener(ie,({detail:t})=>{Z||at(t)}));let Z=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(ie);typeof t.unref=="function"&&t.unref(),ue(Le,e=>{Z||t.postMessage(e)}),t.onmessage=e=>{e.data&&at(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){ue(Le,e=>{try{Z||(typeof localStorage<"u"&&localStorage.setItem(ie,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ie,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===ie){const n=JSON.parse(e.newValue);n&&at(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===ie&&at(e.changedParts)})}S.rejectionMapper=function(t,e){if(!t||t instanceof xe||t instanceof TypeError||t instanceof SyntaxError||!t.name||!dn[t.name])return t;var n=new dn[t.name](e||t.message,t);return"stack"in t&&ee(n,"stack",{get:function(){return this.inner.stack}}),n},Rn(G,zn);class Jr extends pe{constructor(){super("NylasAuthDatabase"),Pt(this,"grant"),Pt(this,"pkce"),this.version(1).stores({grant:"++id,token",pkce:"++id,codeVerifier"}),this.grant=this.table("grant"),this.pkce=this.table("pkce")}}class Zr{constructor(){Pt(this,"theDB"),this.theDB=new Jr}async setCodeVerifier(e){await this.theDB.pkce.put({id:1,codeVerifier:e},1)}async getCodeVerifier(){const[e]=await this.theDB.pkce.toArray();return e?e.codeVerifier:null}async getTokenInfo(){const e=await this.theDB.grant.get(1);return e?e.token:null}async setTokenInfo(e){await this.theDB.grant.put({id:1,token:e},1)}async reset(){await this.theDB.grant.clear()}}function es(t){const e="NylasAuth";if(!t)throw new Error("NylasAuth requires a config object");let n=null;if(t.storageType==="indexeddb"&&(n=new Zr),!n)throw new Error("NylasAuth requires a storage object");const r=[{type:"read-only",value:"https://www.googleapis.com/auth/gmail.readonly"},{type:"modify",value:"https://www.googleapis.com/auth/gmail.modify"},{type:"compose",value:"https://www.googleapis.com/auth/gmail.compose"},{type:"insert",value:"https://www.googleapis.com/auth/gmail.insert"},{type:"labels",value:"https://www.googleapis.com/auth/gmail.labels"},{type:"metadata",value:"https://www.googleapis.com/auth/gmail.metadata"},{type:"settings.basic",value:"https://www.googleapis.com/auth/gmail.settings.basic"},{type:"settings.sharing",value:"https://www.googleapis.com/auth/gmail.settings.sharing"}],s=[{type:"read-only",value:"https://outlook.office.com/mail.read"},{type:"modify",value:"https://outlook.office.com/mail.readwrite"},{type:"send",value:"https://outlook.office.com/mail.send"},{type:"offline",value:"offline_access"}];async function i(o,u,a,c=!0,h,l){const d=await(n==null?void 0:n.getTokenInfo()),p=new URL(o,h??t.apiUri),m=new Headers;m.append("Accept","application/json"),m.append("Content-Type","application/json"),m.append("User-Agent",e),d&&m.append("Authorization",`Bearer ${d.access_token}`);const f=await fetch(p.toString(),{method:u||"GET",headers:m,mode:"cors",referrer:location.origin,body:a?JSON.stringify(a):void 0,...l||{}});return c?await f.json():f.body}return{config:t,async getHostedAuthRedirectURL(o=t.defaultScopes,u,a){const c=await hn(Math.random().toString()),h=await hn(c);await(n==null?void 0:n.setCodeVerifier(c));const l=new URL(`${t.apiUri}/v3/connect/auth`);return l.searchParams.set("client_id",t.clientId),l.searchParams.set("response_type","code"),l.searchParams.set("scope",o.join(" ")),l.searchParams.set("redirect_uri",t.redirectURI),l.searchParams.set("access_type","offline"),l.searchParams.set("code_challenge",h),l.searchParams.set("code_challenge_method","S256"),l.searchParams.set("options","rotate_refresh_token"),a&&l.searchParams.set("provider",a),u&&l.searchParams.set("login_hint",u),l.toString()},nylasAPIRequest:i,async exchangeAuthCodeForTokenInfo(o){if(!o)return null;const u=await(n==null?void 0:n.getCodeVerifier()),a=await this.nylasAPIRequest("/v3/connect/token","POST",{code:o,client_id:t.clientId,grant_type:"authorization_code",redirect_uri:t.redirectURI,code_verifier:u});return"error"in a||await(n==null?void 0:n.setTokenInfo(a)),a},async nylasDownloadFileRequest(o,u="GET",a){const c=await(n==null?void 0:n.getTokenInfo()),h=new URL(o,t.apiUri),l=new Headers;return l.append("Accept","application/json"),l.append("Content-Type","application/octet-stream"),l.append("User-Agent",e),c&&l.append("Authorization",`Bearer ${c.access_token}`),(await fetch(h.toString(),{method:u,headers:l,mode:"cors",referrer:location.origin,body:a?JSON.stringify(a):void 0})).blob()},async logout(){const o=await(n==null?void 0:n.getTokenInfo());o&&await this.nylasAPIRequest(`/v3/connect/revoke?token=${o.access_token}`,"POST"),await(n==null?void 0:n.reset())},async isAuthenticated(){return!!await(n==null?void 0:n.getTokenInfo())},async getTokenInfo(){const o=await(n==null?void 0:n.getTokenInfo());if(!o)return null;const{access_token:u,...a}=o;return a},async isAccessTokenValid(){const o=await(n==null?void 0:n.getTokenInfo());return o?"data"in await this.nylasAPIRequest(`/v3/connect/tokeninfo?id_token=${o.id_token}`,"GET"):!1},async refreshAccessToken(){const o=await(n==null?void 0:n.getTokenInfo());if(!o)return null;const u=await this.nylasAPIRequest("/v3/connect/token","POST",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:o.refresh_token});return"error"in u||await(n==null?void 0:n.setTokenInfo(u)),u},async hasScopeByType(o="email",u){const a=await(n==null?void 0:n.getTokenInfo());if(!a)return!1;const c=a.scope.toLowerCase().split(" ");let h=[];const l=Array.isArray(u)?u:[u];return o==="email"&&(h=[...s,...r].filter(d=>l.includes(d.type))),h.every(d=>c.includes(d.value))},async hasScope(o){const u=await(n==null?void 0:n.getTokenInfo());if(!u)return!1;const a=u.scope.toLowerCase().split(" ");return(Array.isArray(o)?o:[o]).some(c=>a.includes(c.toLowerCase()))}}}exports.NylasBaseProvider=rr;exports.Xr=or;exports.es=es;exports.nr=Sn;
3
+ `).slice(e).filter(Kn).map(r=>`
4
+ `+r).join("")):""}var Nn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Zt=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Nn),hr={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function ke(t,e){this._e=Ee(),this.name=t,this.message=e}function $n(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,s)=>s.indexOf(n)===r).join(`
5
+ `)}function lt(t,e,n,r){this._e=Ee(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=$n(t,e)}function $e(t,e){this._e=Ee(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=$n(t,e)}_e(ke).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Ot(this._e,2))}},toString:function(){return this.name+": "+this.message}}),_e(lt).from(ke),_e($e).from(ke);var en=Zt.reduce((t,e)=>(t[e]=e+"Error",t),{});const dr=ke;var P=Zt.reduce((t,e)=>{var n=e+"Error";function r(s,i){this._e=Ee(),this.name=n,s?typeof s=="string"?(this.message=`${s}${i?`
6
+ `+i:""}`,this.inner=i||null):typeof s=="object"&&(this.message=`${s.name} ${s.message}`,this.inner=s):(this.message=hr[e]||n,this.inner=null)}return _e(r).from(dr),t[e]=r,t},{});P.Syntax=SyntaxError,P.Type=TypeError,P.Range=RangeError;var cn=Nn.reduce((t,e)=>(t[e+"Error"]=P[e],t),{}),tt=Zt.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=P[e]),t),{});function K(){}function Fe(t){return t}function fr(t,e){return t==null||t===Fe?e:function(n){return e(t(n))}}function pe(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function pr(t,e){return t===K?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?pe(r,this.onsuccess):r),s&&(this.onerror=this.onerror?pe(s,this.onerror):s),i!==void 0?i:n}}function mr(t,e){return t===K?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?pe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?pe(r,this.onerror):r)}}function gr(t,e){return t===K?e:function(n){var r=t.apply(this,arguments);U(n,r);var s=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return s&&(this.onsuccess=this.onsuccess?pe(s,this.onsuccess):s),i&&(this.onerror=this.onerror?pe(i,this.onerror):i),r===void 0?o===void 0?void 0:o:U(r,o)}}function yr(t,e){return t===K?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function tn(t,e){return t===K?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then(function(){return e.apply(r,i)})}return e.apply(this,arguments)}}tt.ModifyError=lt,tt.DexieError=ke,tt.BulkError=$e;var Me={};const Rn=100,[At,ct,Kt]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Be(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Be(e),t]})(),jn=ct&&ct.then,nt=At&&At.constructor,nn=!!Kt;var Nt=!1,vr=Kt?()=>{Kt.then(He)}:N.setImmediate?setImmediate.bind(null,He):N.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{He(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(He,0)},Re=function(t,e){Ne.push([t,e]),ht&&(vr(),ht=!1)},$t=!0,ht=!0,de=[],rt=[],Rt=null,jt=Fe,xe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:fn,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{fn(t[0],t[1])}catch{}})}},E=xe,Ne=[],fe=0,st=[];function S(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=K,this._lib=!1;var e=this._PSD=E;if(G&&(this._stackHolder=Ee(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Me)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Dt(this,this._value))}this._state=null,this._value=null,++e.ref,Dn(this,t)}const It={get:function(){var t=E,e=dt;function n(r,s){var i=!t.global&&(t!==E||e!==dt);const o=i&&!ne();var u=new S((a,c)=>{rn(this,new In(ft(r,t,i,o),ft(s,t,i,o),a,c,t))});return G&&Mn(u,this),u}return n.prototype=Me,n},set:function(t){ee(this,"then",t&&t.prototype===Me?It:{get:function(){return t},set:It.set})}};function In(t,e,n,r,s){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=s}function Dn(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&ze();n&&typeof n.then=="function"?Dn(t,(s,i)=>{n instanceof S?n._then(s,i):n.then(s,i)}):(t._state=!0,t._value=n,Bn(t)),r&&Ye()}},Dt.bind(null,t))}catch(n){Dt(t,n)}}function Dt(t,e){if(rt.push(e),t._state===null){var n=t._lib&&ze();e=jt(e),t._state=!1,t._value=e,G&&e!==null&&typeof e=="object"&&!e._promise&&function(r,s,i){try{r.apply(null,i)}catch(o){s&&s(o)}}(()=>{var r=Qt(e,"stack");e._promise=t,ee(e,"stack",{get:()=>Nt?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){de.some(s=>s._value===r._value)||de.push(r)}(t),Bn(t),n&&Ye()}}function Bn(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n<r;++n)rn(t,e[n]);var s=t._PSD;--s.ref||s.finalize(),fe===0&&(++fe,Re(()=>{--fe==0&&sn()},[]))}function rn(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++fe,Re(br,[n,t,e])}else t._listeners.push(e)}function br(t,e,n){try{Rt=e;var r,s=e._value;e._state?r=t(s):(rt.length&&(rt=[]),r=t(s),rt.indexOf(s)===-1&&function(i){for(var o=de.length;o;)if(de[--o]._value===i._value)return void de.splice(o,1)}(e)),n.resolve(r)}catch(i){n.reject(i)}finally{Rt=null,--fe==0&&sn(),--n.psd.ref||n.psd.finalize()}}function Fn(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var s,i,o=t._value;o!=null?(s=o.name||"Error",i=o.message||o,r=Ot(o,0)):(s=o,i=""),e.push(s+(i?": "+i:"")+r)}return G&&((r=Ot(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Fn(t._prev,e,n)),e}function Mn(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function He(){ze()&&Ye()}function ze(){var t=$t;return $t=!1,ht=!1,t}function Ye(){var t,e,n;do for(;Ne.length>0;)for(t=Ne,Ne=[],n=t.length,e=0;e<n;++e){var r=t[e];r[0].apply(null,r[1])}while(Ne.length>0);$t=!0,ht=!0}function sn(){var t=de;de=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=st.slice(0),n=e.length;n;)e[--n]()}function Ge(t){return new S(Me,!1,t)}function $(t,e){var n=E;return function(){var r=ze(),s=E;try{return ae(n,!0),t.apply(this,arguments)}catch(i){e&&e(i)}finally{ae(s,!1),r&&Ye()}}}Ce(S.prototype,{then:It,_then:function(t,e){rn(this,new In(null,null,t,e,E))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):Ge(r)):this.then(null,r=>r&&r.name===e?n(r):Ge(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Ge(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Nt=!0;var t=Fn(this,[],20).join(`
7
+ From previous: `);return this._state!==null&&(this._stack=t),t}finally{Nt=!1}}},timeout:function(t,e){return t<1/0?new S((n,r)=>{var s=setTimeout(()=>r(new P.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,s))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&ee(S.prototype,Symbol.toStringTag,"Dexie.Promise"),xe.env=qn(),Ce(S,{all:function(){var t=J.apply(null,arguments).map(Xe);return new S(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((s,i)=>S.resolve(s).then(o=>{t[i]=o,--r||e(t)},n))})},resolve:t=>{if(t instanceof S)return t;if(t&&typeof t.then=="function")return new S((n,r)=>{t.then(n,r)});var e=new S(Me,!0,t);return Mn(e,Rt),e},reject:Ge,race:function(){var t=J.apply(null,arguments).map(Xe);return new S((e,n)=>{t.map(r=>S.resolve(r).then(e,n))})},PSD:{get:()=>E,set:t=>E=t},totalEchoes:{get:()=>dt},newPSD:oe,usePSD:Te,scheduler:{get:()=>Re,set:t=>{Re=t}},rejectionMapper:{get:()=>jt,set:t=>{jt=t}},follow:(t,e)=>new S((n,r)=>oe((s,i)=>{var o=E;o.unhandleds=[],o.onunhandled=i,o.finalize=pe(function(){(function(u){function a(){u(),st.splice(st.indexOf(a),1)}st.push(a),++fe,Re(()=>{--fe==0&&sn()},[])})(()=>{this.unhandleds.length===0?s():i(this.unhandleds[0])})},o.finalize),t()},e,n,r))}),nt&&(nt.allSettled&&ee(S,"allSettled",function(){const t=J.apply(null,arguments).map(Xe);return new S(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((s,i)=>S.resolve(s).then(o=>r[i]={status:"fulfilled",value:o},o=>r[i]={status:"rejected",reason:o}).then(()=>--n||e(r)))})}),nt.any&&typeof AggregateError<"u"&&ee(S,"any",function(){const t=J.apply(null,arguments).map(Xe);return new S((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const s=new Array(r);t.forEach((i,o)=>S.resolve(i).then(u=>e(u),u=>{s[o]=u,--r||n(new AggregateError(s))}))})}));const F={awaits:0,echoes:0,id:0};var wr=0,it=[],bt=0,dt=0,_r=0;function oe(t,e,n,r){var s=E,i=Object.create(s);i.parent=s,i.ref=0,i.global=!1,i.id=++_r;var o=xe.env;i.env=nn?{Promise:S,PromiseProp:{value:S,configurable:!0,writable:!0},all:S.all,race:S.race,allSettled:S.allSettled,any:S.any,resolve:S.resolve,reject:S.reject,nthen:hn(o.nthen,i),gthen:hn(o.gthen,i)}:{},e&&U(i,e),++s.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=Te(i,t,n,r);return i.ref===0&&i.finalize(),u}function Pe(){return F.id||(F.id=++wr),++F.awaits,F.echoes+=Rn,F.id}function ne(){return!!F.awaits&&(--F.awaits==0&&(F.id=0),F.echoes=F.awaits*Rn,!0)}function Xe(t){return F.echoes&&t&&t.constructor===nt?(Pe(),t.then(e=>(ne(),e),e=>(ne(),D(e)))):t}function kr(t){++dt,F.echoes&&--F.echoes!=0||(F.echoes=F.id=0),it.push(E),ae(t,!0)}function xr(){var t=it[it.length-1];it.pop(),ae(t,!1)}function ae(t,e){var n=E;if((e?!F.echoes||bt++&&t===E:!bt||--bt&&t===E)||Ln(e?kr.bind(null,t):xr),t!==E&&(E=t,n===xe&&(xe.env=qn()),nn)){var r=xe.env.Promise,s=t.env;ct.then=s.nthen,r.prototype.then=s.gthen,(n.global||t.global)&&(Object.defineProperty(N,"Promise",s.PromiseProp),r.all=s.all,r.race=s.race,r.resolve=s.resolve,r.reject=s.reject,s.allSettled&&(r.allSettled=s.allSettled),s.any&&(r.any=s.any))}}function qn(){var t=N.Promise;return nn?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(N,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:ct.then,gthen:t.prototype.then}:{}}function Te(t,e,n,r,s){var i=E;try{return ae(t,!0),e(n,r,s)}finally{ae(i,!1)}}function Ln(t){jn.call(At,t)}function ft(t,e,n,r){return typeof t!="function"?t:function(){var s=E;n&&Pe(),ae(e,!0);try{return t.apply(this,arguments)}finally{ae(s,!1),r&&Ln(ne)}}}function hn(t,e){return function(n,r){return t.call(this,ft(n,e),ft(r,e))}}(""+jn).indexOf("[native code]")===-1&&(Pe=ne=K);const dn="unhandledrejection";function fn(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,s={promise:e,reason:t};if(N.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(dn,!0,!0),U(r,s)):N.CustomEvent&&U(r=new CustomEvent(dn,{detail:s}),s),r&&N.dispatchEvent&&(dispatchEvent(r),!N.PromiseRejectionEvent&&N.onunhandledrejection))try{N.onunhandledrejection(r)}catch{}G&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var D=S.reject;function Bt(t,e,n,r){if(t.idbdb&&(t._state.openComplete||E.letThrough||t._vip)){var s=t._createTransaction(e,n,t._dbSchema);try{s.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===en.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Bt(t,e,n,r))):D(i)}return s._promise(e,(i,o)=>oe(()=>(E.trans=s,r(i,o,s)))).then(i=>s._completion.then(()=>i))}if(t._state.openComplete)return D(new P.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return D(new P.DatabaseClosed);t.open().catch(K)}return t._state.dbReadyPromise.then(()=>Bt(t,e,n,r))}const pn="3.2.4",he=String.fromCharCode(65535),Ft=-1/0,X="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Un="String expected.",je=[],gt=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Sr=gt,Cr=gt,Wn=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),yt="__dbnames",wt="readonly",_t="readwrite";function me(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Vn={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Qe(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Ve(e))[t],e)}class Er{_trans(e,n,r){const s=this._tx||E.trans,i=this.name;function o(a,c,h){if(!h.schema[i])throw new P.NotFound("Table "+i+" not part of transaction");return n(h.idbtrans,h)}const u=ze();try{return s&&s.db===this.db?s===E.trans?s._promise(e,o,r):oe(()=>s._promise(e,o,r),{trans:s,transless:E.transless||E}):Bt(this.db,e,[this.name],o)}finally{u&&Ye()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(s=>this.hook.reading.fire(s))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(M(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=I(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>c.compound&&n.every(h=>c.keyPath.indexOf(h)>=0)&&c.keyPath.every(h=>n.indexOf(h)>=0))[0];if(r&&this.db._maxKey!==he)return this.where(r.name).equals(r.keyPath.map(c=>e[c]));!r&&G&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:s}=this.schema,i=this.db._deps.indexedDB;function o(c,h){try{return i.cmp(c,h)===0}catch{return!1}}const[u,a]=n.reduce(([c,h],l)=>{const d=s[l],p=e[l];return[c||d,c||!d?me(h,d&&d.multi?m=>{const f=te(m,l);return M(f)&&f.some(v=>o(p,v))}:m=>o(p,te(m,l))):h]},[null,null]);return u?this.where(u.name).equals(e[u.keyPath]).filter(a):r?this.filter(a):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,M(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const s=Object.create(e.prototype);for(var i in r)if(z(r,i))try{s[i]=r[i]}catch{}return s};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){U(this,e)})}add(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=Qe(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:n!=null?[n]:null,values:[i]})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{Y(e,s,o)}catch{}return o})}update(e,n){if(typeof e!="object"||M(e))return this.where(":id").equals(e).modify(n);{const r=te(e,this.schema.primKey.keyPath);if(r===void 0)return D(new P.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?I(n).forEach(s=>{Y(e,s,n[s])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=Qe(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[i],keys:n!=null?[n]:null})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{Y(e,s,o)}catch{}return o})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?S.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Vn})).then(e=>e.numFailures?S.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(s=>this.hook.reading.fire(s))))}bulkAdd(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:u,keyPath:a}=this.schema.primKey;if(a&&s)throw new P.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new P.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let h=a&&u?e.map(Qe(a)):e;return this.core.mutate({trans:o,type:"add",keys:s,values:h,wantResults:i}).then(({numFailures:l,results:d,lastResult:p,failures:m})=>{if(l===0)return i?d:p;throw new $e(`${this.name}.bulkAdd(): ${l} of ${c} operations failed`,m)})})}bulkPut(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:u,keyPath:a}=this.schema.primKey;if(a&&s)throw new P.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new P.InvalidArgument("Arguments objects and keys must have the same length");const c=e.length;let h=a&&u?e.map(Qe(a)):e;return this.core.mutate({trans:o,type:"put",keys:s,values:h,wantResults:i}).then(({numFailures:l,results:d,lastResult:p,failures:m})=>{if(l===0)return i?d:p;throw new $e(`${this.name}.bulkPut(): ${l} of ${c} operations failed`,m)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:s,failures:i})=>{if(r===0)return s;throw new $e(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,i)})}}function Ie(t){var e={},n=function(o,u){if(u){for(var a=arguments.length,c=new Array(a-1);--a;)c[a-1]=arguments[a];return e[o].subscribe.apply(null,c),t}if(typeof o=="string")return e[o]};n.addEventType=i;for(var r=1,s=arguments.length;r<s;++r)i(arguments[r]);return n;function i(o,u,a){if(typeof o!="object"){var c;u||(u=yr),a||(a=K);var h={subscribers:[],fire:a,subscribe:function(l){h.subscribers.indexOf(l)===-1&&(h.subscribers.push(l),h.fire=u(h.fire,l))},unsubscribe:function(l){h.subscribers=h.subscribers.filter(function(d){return d!==l}),h.fire=h.subscribers.reduce(u,a)}};return e[o]=n[o]=h,h}I(c=o).forEach(function(l){var d=c[l];if(M(d))i(l,c[l][0],c[l][1]);else{if(d!=="asap")throw new P.InvalidArgument("Invalid event config");var p=i(l,Fe,function(){for(var m=arguments.length,f=new Array(m);m--;)f[m]=arguments[m];p.subscribers.forEach(function(v){Cn(function(){v.apply(null,f)})})})}})}}function Ae(t,e){return _e(e).from({prototype:t}),e}function ve(t,e){return!(t.filter||t.algorithm||t.or)&&(e?t.justLimit:!t.replayFilter)}function kt(t,e){t.filter=me(t.filter,e)}function xt(t,e,n){var r=t.replayFilter;t.replayFilter=r?()=>me(r(),e()):e,t.justLimit=n&&!r}function ot(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new P.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function mn(t,e,n){const r=ot(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function Je(t,e,n,r){const s=t.replayFilter?me(t.filter,t.replayFilter()):t.filter;if(t.or){const i={},o=(u,a,c)=>{if(!s||s(a,c,d=>a.stop(d),d=>a.fail(d))){var h=a.primaryKey,l=""+h;l==="[object ArrayBuffer]"&&(l=""+new Uint8Array(h)),z(i,l)||(i[l]=!0,e(u,a,c))}};return Promise.all([t.or._iterate(o,n),gn(mn(t,r,n),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}return gn(mn(t,r,n),me(t.algorithm,s),e,!t.keysOnly&&t.valueMapper)}function gn(t,e,n,r){var s=$(r?(i,o,u)=>n(r(i),o,u):n);return t.then(i=>{if(i)return i.start(()=>{var o=()=>i.continue();e&&!e(i,u=>o=u,u=>{i.stop(u),o=K},u=>{i.fail(u),o=K})||s(i.value,i,u=>o=u),o()})})}function L(t,e){try{const n=yn(t),r=yn(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:t<e?-1:0;case"binary":return function(s,i){const o=s.length,u=i.length,a=o<u?o:u;for(let c=0;c<a;++c)if(s[c]!==i[c])return s[c]<i[c]?-1:1;return o===u?0:o<u?-1:1}(vn(t),vn(e));case"Array":return function(s,i){const o=s.length,u=i.length,a=o<u?o:u;for(let c=0;c<a;++c){const h=L(s[c],i[c]);if(h!==0)return h}return o===u?0:o<u?-1:1}(t,e)}}catch{}return NaN}function yn(t){const e=typeof t;if(e!=="object")return e;if(ArrayBuffer.isView(t))return"binary";const n=Pt(t);return n==="ArrayBuffer"?"binary":n}function vn(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class Pr{_read(e,n){var r=this._ctx;return r.error?r.table._trans(null,D.bind(null,r.error)):r.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,D.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=me(n.algorithm,e)}_iterate(e,n){return Je(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&U(r,e),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(r=>Je(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,s=r.table.core;if(ve(r,!0))return s.count({trans:n,query:{index:ot(r,s.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var i=0;return Je(r,()=>(++i,!1),n,s).then(()=>i)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),s=r[0],i=r.length-1;function o(c,h){return h?o(c[r[h]],h-1):c[s]}var u=this._ctx.dir==="next"?1:-1;function a(c,h){var l=o(c,i),d=o(h,i);return l<d?-u:l>d?u:0}return this.toArray(function(c){return c.sort(a)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&ve(r,!0)&&r.limit>0){const{valueMapper:s}=r,i=ot(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:i,range:r.range}}).then(({result:o})=>s?o.map(s):o)}{const s=[];return Je(r,i=>s.push(i),n,r.table.core).then(()=>s)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,ve(n)?xt(n,()=>{var r=e;return(s,i)=>r===0||(r===1?(--r,!1):(i(()=>{s.advance(r),r=0}),!1))}):xt(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),xt(this._ctx,()=>{var n=e;return function(r,s,i){return--n<=0&&s(i),n>=0}},!0),this}until(e,n){return kt(this._ctx,function(r,s,i){return!e(r.value)||(s(i),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return kt(this._ctx,function(s){return e(s.value)}),n=this._ctx,r=e,n.isMatch=me(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.key,s)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.primaryKey,s)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&ve(n,!0)&&n.limit>0)return this._read(s=>{var i=ot(n,n.table.core.schema);return n.table.core.query({trans:s,values:!1,limit:n.limit,query:{index:i,range:n.range}})}).then(({result:s})=>s).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return kt(this._ctx,function(s){var i=s.primaryKey.toString(),o=z(r,i);return r[i]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(r=>{var s;if(typeof e=="function")s=e;else{var i=I(e),o=i.length;s=function(f){for(var v=!1,y=0;y<o;++y){var g=i[y],b=e[g];te(f,g)!==b&&(Y(f,g,b),v=!0)}return v}}const u=n.table.core,{outbound:a,extractKey:c}=u.schema.primaryKey,h=this.db._options.modifyChunkSize||200,l=[];let d=0;const p=[],m=(f,v)=>{const{failures:y,numFailures:g}=v;d+=f-g;for(let b of I(y))l.push(y[b])};return this.clone().primaryKeys().then(f=>{const v=y=>{const g=Math.min(h,f.length-y);return u.getMany({trans:r,keys:f.slice(y,y+g),cache:"immutable"}).then(b=>{const w=[],C=[],k=a?[]:null,_=[];for(let x=0;x<g;++x){const R=b[x],A={value:Ve(R),primKey:f[y+x]};s.call(A,A.value,A)!==!1&&(A.value==null?_.push(f[y+x]):a||L(c(R),c(A.value))===0?(C.push(A.value),a&&k.push(f[y+x])):(_.push(f[y+x]),w.push(A.value)))}const O=ve(n)&&n.limit===1/0&&(typeof e!="function"||e===St)&&{index:n.index,range:n.range};return Promise.resolve(w.length>0&&u.mutate({trans:r,type:"add",values:w}).then(x=>{for(let R in x.failures)_.splice(parseInt(R),1);m(w.length,x)})).then(()=>(C.length>0||O&&typeof e=="object")&&u.mutate({trans:r,type:"put",keys:k,values:C,criteria:O,changeSpec:typeof e!="function"&&e}).then(x=>m(C.length,x))).then(()=>(_.length>0||O&&e===St)&&u.mutate({trans:r,type:"delete",keys:_,criteria:O}).then(x=>m(_.length,x))).then(()=>f.length>y+g&&v(y+h))})};return v(0).then(()=>{if(l.length>0)throw new lt("Error modifying one or more objects",l,d,p);return f.length})})})}delete(){var e=this._ctx,n=e.range;return ve(e)&&(e.isPrimKey&&!Cr||n.type===3)?this._write(r=>{const{primaryKey:s}=e.table.core.schema,i=n;return e.table.core.count({trans:r,query:{index:s,range:i}}).then(o=>e.table.core.mutate({trans:r,type:"deleteRange",range:i}).then(({failures:u,lastResult:a,results:c,numFailures:h})=>{if(h)throw new lt("Could not delete some values",Object.keys(u).map(l=>u[l]),o-h);return o-h}))}):this.modify(St)}}const St=(t,e)=>e.value=null;function Tr(t,e){return t<e?-1:t===e?0:1}function Or(t,e){return t>e?-1:t===e?0:1}function V(t,e,n){var r=t instanceof Yn?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function be(t){return new t.Collection(t,()=>zn("")).limit(0)}function Ar(t,e,n,r,s,i){for(var o=Math.min(t.length,r.length),u=-1,a=0;a<o;++a){var c=e[a];if(c!==r[a])return s(t[a],n[a])<0?t.substr(0,a)+n[a]+n.substr(a+1):s(t[a],r[a])<0?t.substr(0,a)+r[a]+n.substr(a+1):u>=0?t.substr(0,u)+e[u]+n.substr(u+1):null;s(t[a],c)<0&&(u=a)}return o<r.length&&i==="next"?t+n.substr(t.length):o<t.length&&i==="prev"?t.substr(0,n.length):u<0?null:t.substr(0,u)+r[u]+n.substr(u+1)}function Ze(t,e,n,r){var s,i,o,u,a,c,h,l=n.length;if(!n.every(f=>typeof f=="string"))return V(t,Un);function d(f){s=function(y){return y==="next"?g=>g.toUpperCase():g=>g.toLowerCase()}(f),i=function(y){return y==="next"?g=>g.toLowerCase():g=>g.toUpperCase()}(f),o=f==="next"?Tr:Or;var v=n.map(function(y){return{lower:i(y),upper:s(y)}}).sort(function(y,g){return o(y.lower,g.lower)});u=v.map(function(y){return y.upper}),a=v.map(function(y){return y.lower}),c=f,h=f==="next"?"":r}d("next");var p=new t.Collection(t,()=>re(u[0],a[l-1]+r));p._ondirectionchange=function(f){d(f)};var m=0;return p._addAlgorithm(function(f,v,y){var g=f.key;if(typeof g!="string")return!1;var b=i(g);if(e(b,a,m))return!0;for(var w=null,C=m;C<l;++C){var k=Ar(g,b,u[C],a[C],o,c);k===null&&w===null?m=C+1:(w===null||o(w,k)>0)&&(w=k)}return v(w!==null?function(){f.continue(w+h)}:y),!1}),p}function re(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function zn(t){return{type:1,lower:t,upper:t}}class Yn{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,s){r=r!==!1,s=s===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||s)&&(!r||!s)?be(this):new this.Collection(this,()=>re(e,n,!r,!s))}catch{return V(this,X)}}equals(e){return e==null?V(this,X):new this.Collection(this,()=>zn(e))}above(e){return e==null?V(this,X):new this.Collection(this,()=>re(e,void 0,!0))}aboveOrEqual(e){return e==null?V(this,X):new this.Collection(this,()=>re(e,void 0,!1))}below(e){return e==null?V(this,X):new this.Collection(this,()=>re(void 0,e,!1,!0))}belowOrEqual(e){return e==null?V(this,X):new this.Collection(this,()=>re(void 0,e))}startsWith(e){return typeof e!="string"?V(this,Un):this.between(e,e+he,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):Ze(this,(n,r)=>n.indexOf(r[0])===0,[e],he)}equalsIgnoreCase(e){return Ze(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=J.apply(we,arguments);return e.length===0?be(this):Ze(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=J.apply(we,arguments);return e.length===0?be(this):Ze(this,(n,r)=>r.some(s=>n.indexOf(s)===0),e,he)}anyOf(){const e=J.apply(we,arguments);let n=this._cmp;try{e.sort(n)}catch{return V(this,X)}if(e.length===0)return be(this);const r=new this.Collection(this,()=>re(e[0],e[e.length-1]));r._ondirectionchange=i=>{n=i==="next"?this._ascending:this._descending,e.sort(n)};let s=0;return r._addAlgorithm((i,o,u)=>{const a=i.key;for(;n(a,e[s])>0;)if(++s,s===e.length)return o(u),!1;return n(a,e[s])===0||(o(()=>{i.continue(e[s])}),!1)}),r}notEqual(e){return this.inAnyRange([[Ft,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=J.apply(we,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return V(this,X)}const n=e.reduce((r,s)=>r?r.concat([[r[r.length-1][1],s]]):[[Ft,s]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,s=this._ascending,i=this._descending,o=this._min,u=this._max;if(e.length===0)return be(this);if(!e.every(g=>g[0]!==void 0&&g[1]!==void 0&&s(g[0],g[1])<=0))return V(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",P.InvalidArgument);const a=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let h,l=s;function d(g,b){return l(g[0],b[0])}try{h=e.reduce(function(g,b){let w=0,C=g.length;for(;w<C;++w){const k=g[w];if(r(b[0],k[1])<0&&r(b[1],k[0])>0){k[0]=o(k[0],b[0]),k[1]=u(k[1],b[1]);break}}return w===C&&g.push(b),g},[]),h.sort(d)}catch{return V(this,X)}let p=0;const m=c?g=>s(g,h[p][1])>0:g=>s(g,h[p][1])>=0,f=a?g=>i(g,h[p][0])>0:g=>i(g,h[p][0])>=0;let v=m;const y=new this.Collection(this,()=>re(h[0][0],h[h.length-1][1],!a,!c));return y._ondirectionchange=g=>{g==="next"?(v=m,l=s):(v=f,l=i),h.sort(d)},y._addAlgorithm((g,b,w)=>{for(var C=g.key;v(C);)if(++p,p===h.length)return b(w),!1;return!!function(k){return!m(k)&&!f(k)}(C)||(this._cmp(C,h[p][1])===0||this._cmp(C,h[p][0])===0||b(()=>{l===s?g.continue(h[p][0]):g.continue(h[p][1])}),!1)}),y}startsWithAnyOf(){const e=J.apply(we,arguments);return e.every(n=>typeof n=="string")?e.length===0?be(this):this.inAnyRange(e.map(n=>[n,n+he])):V(this,"startsWithAnyOf() only works with strings")}}function H(t){return $(function(e){return qe(e),t(e.target.error),!1})}function qe(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Le="storagemutated",ie="x-storagemutated-1",ue=Ie(null,Le);class Kr{_lock(){return Ke(!E.global),++this._reculock,this._reculock!==1||E.global||(E.lockOwnerFor=this),this}_unlock(){if(Ke(!E.global),--this._reculock==0)for(E.global||(E.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Te(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&E.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(Ke(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new P.DatabaseClosed(r);case"MissingAPIError":throw new P.MissingAPI(r.message,r);default:throw new P.OpenFailed(r)}if(!this.active)throw new P.TransactionInactive;return Ke(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=$(s=>{qe(s),this._reject(e.error)}),e.onabort=$(s=>{qe(s),this.active&&this._reject(new P.Abort(e.error)),this.active=!1,this.on("abort").fire(s)}),e.oncomplete=$(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&ue.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return D(new P.ReadOnly("Transaction is readonly"));if(!this.active)return D(new P.TransactionInactive);if(this._locked())return new S((i,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(i,o)},E])});if(r)return oe(()=>{var i=new S((o,u)=>{this._lock();const a=n(o,u,this);a&&a.then&&a.then(o,u)});return i.finally(()=>this._unlock()),i._lib=!0,i});var s=new S((i,o)=>{var u=n(i,o,this);u&&u.then&&u.then(i,o)});return s._lib=!0,s}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=S.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var s=n.idbtrans.objectStore(n.storeNames[0]);(function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(s.get(-1/0).onsuccess=o)})()}var i=n._waitingFor;return new S((o,u)=>{r.then(a=>n._waitingQueue.push($(o.bind(null,a))),a=>n._waitingQueue.push($(u.bind(null,a)))).finally(()=>{n._waitingFor===i&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new P.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(z(n,e))return n[e];const r=this.schema[e];if(!r)throw new P.NotFound("Table "+e+" not part of transaction");const s=new this.db.Table(e,r,this);return s.core=this.db.core.table(e),n[e]=s,s}}function Mt(t,e,n,r,s,i,o){return{name:t,keyPath:e,unique:n,multi:r,auto:s,compound:i,src:(n&&!o?"&":"")+(r?"*":"")+(s?"++":"")+Hn(e)}}function Hn(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Gn(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:En(n,r=>[r.name,r])}}let Ue=t=>{try{return t.only([[]]),Ue=()=>[[]],[[]]}catch{return Ue=()=>he,he}};function qt(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?n=>n[e]:n=>te(n,e)}(t):e=>te(e,t)}function bn(t){return[].slice.call(t)}let Nr=0;function De(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function $r(t,e,n){function r(a){if(a.type===3)return null;if(a.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:h,lowerOpen:l,upperOpen:d}=a;return c===void 0?h===void 0?null:e.upperBound(h,!!d):h===void 0?e.lowerBound(c,!!l):e.bound(c,h,!!l,!!d)}const{schema:s,hasGetAll:i}=function(a,c){const h=bn(a.objectStoreNames);return{schema:{name:a.name,tables:h.map(l=>c.objectStore(l)).map(l=>{const{keyPath:d,autoIncrement:p}=l,m=M(d),f=d==null,v={},y={name:l.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:m,keyPath:d,autoIncrement:p,unique:!0,extractKey:qt(d)},indexes:bn(l.indexNames).map(g=>l.index(g)).map(g=>{const{name:b,unique:w,multiEntry:C,keyPath:k}=g,_={name:b,compound:M(k),keyPath:k,unique:w,multiEntry:C,extractKey:qt(k)};return v[De(k)]=_,_}),getIndexByKeyPath:g=>v[De(g)]};return v[":id"]=y.primaryKey,d!=null&&(v[De(d)]=y.primaryKey),y})},hasGetAll:h.length>0&&"getAll"in c.objectStore(h[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),o=s.tables.map(a=>function(c){const h=c.name;return{name:h,schema:c,mutate:function({trans:l,type:d,keys:p,values:m,range:f}){return new Promise((v,y)=>{v=$(v);const g=l.objectStore(h),b=g.keyPath==null,w=d==="put"||d==="add";if(!w&&d!=="delete"&&d!=="deleteRange")throw new Error("Invalid operation type: "+d);const{length:C}=p||m||{length:1};if(p&&m&&p.length!==m.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return v({numFailures:0,failures:{},results:[],lastResult:void 0});let k;const _=[],O=[];let x=0;const R=q=>{++x,qe(q)};if(d==="deleteRange"){if(f.type===4)return v({numFailures:x,failures:O,results:[],lastResult:void 0});f.type===3?_.push(k=g.clear()):_.push(k=g.delete(r(f)))}else{const[q,B]=w?b?[m,p]:[m,null]:[p,null];if(w)for(let j=0;j<C;++j)_.push(k=B&&B[j]!==void 0?g[d](q[j],B[j]):g[d](q[j])),k.onerror=R;else for(let j=0;j<C;++j)_.push(k=g[d](q[j])),k.onerror=R}const A=q=>{const B=q.target.result;_.forEach((j,ge)=>j.error!=null&&(O[ge]=j.error)),v({numFailures:x,failures:O,results:d==="delete"?p:_.map(j=>j.result),lastResult:B})};k.onerror=q=>{R(q),A(q)},k.onsuccess=A})},getMany:({trans:l,keys:d})=>new Promise((p,m)=>{p=$(p);const f=l.objectStore(h),v=d.length,y=new Array(v);let g,b=0,w=0;const C=_=>{const O=_.target;y[O._pos]=O.result,++w===b&&p(y)},k=H(m);for(let _=0;_<v;++_)d[_]!=null&&(g=f.get(d[_]),g._pos=_,g.onsuccess=C,g.onerror=k,++b);b===0&&p(y)}),get:({trans:l,key:d})=>new Promise((p,m)=>{p=$(p);const f=l.objectStore(h).get(d);f.onsuccess=v=>p(v.target.result),f.onerror=H(m)}),query:function(l){return d=>new Promise((p,m)=>{p=$(p);const{trans:f,values:v,limit:y,query:g}=d,b=y===1/0?void 0:y,{index:w,range:C}=g,k=f.objectStore(h),_=w.isPrimaryKey?k:k.index(w.name),O=r(C);if(y===0)return p({result:[]});if(l){const x=v?_.getAll(O,b):_.getAllKeys(O,b);x.onsuccess=R=>p({result:R.target.result}),x.onerror=H(m)}else{let x=0;const R=v||!("openKeyCursor"in _)?_.openCursor(O):_.openKeyCursor(O),A=[];R.onsuccess=q=>{const B=R.result;return B?(A.push(v?B.value:B.primaryKey),++x===y?p({result:A}):void B.continue()):p({result:A})},R.onerror=H(m)}})}(i),openCursor:function({trans:l,values:d,query:p,reverse:m,unique:f}){return new Promise((v,y)=>{v=$(v);const{index:g,range:b}=p,w=l.objectStore(h),C=g.isPrimaryKey?w:w.index(g.name),k=m?f?"prevunique":"prev":f?"nextunique":"next",_=d||!("openKeyCursor"in C)?C.openCursor(r(b),k):C.openKeyCursor(r(b),k);_.onerror=H(y),_.onsuccess=$(O=>{const x=_.result;if(!x)return void v(null);x.___id=++Nr,x.done=!1;const R=x.continue.bind(x);let A=x.continuePrimaryKey;A&&(A=A.bind(x));const q=x.advance.bind(x),B=()=>{throw new Error("Cursor not stopped")};x.trans=l,x.stop=x.continue=x.continuePrimaryKey=x.advance=()=>{throw new Error("Cursor not started")},x.fail=$(y),x.next=function(){let j=1;return this.start(()=>j--?this.continue():this.stop()).then(()=>this)},x.start=j=>{const ge=new Promise((W,le)=>{W=$(W),_.onerror=H(le),x.fail=le,x.stop=Oe=>{x.stop=x.continue=x.continuePrimaryKey=x.advance=B,W(Oe)}}),ye=()=>{if(_.result)try{j()}catch(W){x.fail(W)}else x.done=!0,x.start=()=>{throw new Error("Cursor behind last entry")},x.stop()};return _.onsuccess=$(W=>{_.onsuccess=ye,ye()}),x.continue=R,x.continuePrimaryKey=A,x.advance=q,ye(),ge},v(x)},y)})},count({query:l,trans:d}){const{index:p,range:m}=l;return new Promise((f,v)=>{const y=d.objectStore(h),g=p.isPrimaryKey?y:y.index(p.name),b=r(m),w=b?g.count(b):g.count();w.onsuccess=$(C=>f(C.target.result)),w.onerror=H(v)})}}}(a)),u={};return o.forEach(a=>u[a.name]=a),{stack:"dbcore",transaction:t.transaction.bind(t),table(a){if(!u[a])throw new Error(`Table '${a}' not found`);return u[a]},MIN_KEY:-1/0,MAX_KEY:Ue(e),schema:s}}function Lt({_novip:t},e){const n=e.db,r=function(s,i,{IDBKeyRange:o,indexedDB:u},a){return{dbcore:function(c,h){return h.reduce((l,{create:d})=>({...l,...d(l)}),c)}($r(i,o,a),s.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(s=>{const i=s.name;t.core.schema.tables.some(o=>o.name===i)&&(s.core=t.core.table(i),t[i]instanceof t.Table&&(t[i].core=s.core))})}function pt({_novip:t},e,n,r){n.forEach(s=>{const i=r[s];e.forEach(o=>{const u=Qt(o,s);(!u||"value"in u&&u.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?ee(o,s,{get(){return this.table(s)},set(a){xn(this,s,{value:a,writable:!0,configurable:!0,enumerable:!0})}}):o[s]=new t.Table(s,i))})})}function Ut({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Rr(t,e){return t._cfg.version-e._cfg.version}function jr(t,e,n,r){const s=t._dbSchema,i=t._createTransaction("readwrite",t._storeNames,s);i.create(n),i._completion.catch(r);const o=i._reject.bind(i),u=E.transless||E;oe(()=>{E.trans=i,E.transless=u,e===0?(I(s).forEach(a=>{Ct(n,a,s[a].primKey,s[a].indexes)}),Lt(t,n),S.follow(()=>t.on.populate.fire(i)).catch(o)):function({_novip:a},c,h,l){const d=[],p=a._versions;let m=a._dbSchema=Vt(a,a.idbdb,l),f=!1;const v=p.filter(g=>g._cfg.version>=c);function y(){return d.length?S.resolve(d.shift()(h.idbtrans)).then(y):S.resolve()}return v.forEach(g=>{d.push(()=>{const b=m,w=g._cfg.dbschema;zt(a,b,l),zt(a,w,l),m=a._dbSchema=w;const C=Xn(b,w);C.add.forEach(_=>{Ct(l,_[0],_[1].primKey,_[1].indexes)}),C.change.forEach(_=>{if(_.recreate)throw new P.Upgrade("Not yet support for changing primary key");{const O=l.objectStore(_.name);_.add.forEach(x=>Wt(O,x)),_.change.forEach(x=>{O.deleteIndex(x.name),Wt(O,x)}),_.del.forEach(x=>O.deleteIndex(x))}});const k=g._cfg.contentUpgrade;if(k&&g._cfg.version>c){Lt(a,l),h._memoizedTables={},f=!0;let _=Pn(w);C.del.forEach(A=>{_[A]=b[A]}),Ut(a,[a.Transaction.prototype]),pt(a,[a.Transaction.prototype],I(_),_),h.schema=_;const O=Jt(k);let x;O&&Pe();const R=S.follow(()=>{if(x=k(h),x&&O){var A=ne.bind(null,null);x.then(A,A)}});return x&&typeof x.then=="function"?S.resolve(x):R.then(()=>x)}}),d.push(b=>{(!f||!Sr)&&function(w,C){[].slice.call(C.db.objectStoreNames).forEach(k=>w[k]==null&&C.db.deleteObjectStore(k))}(g._cfg.dbschema,b),Ut(a,[a.Transaction.prototype]),pt(a,[a.Transaction.prototype],a._storeNames,a._dbSchema),h.schema=a._dbSchema})}),y().then(()=>{var g,b;b=l,I(g=m).forEach(w=>{b.db.objectStoreNames.contains(w)||Ct(b,w,g[w].primKey,g[w].indexes)})})}(t,e,i,n).catch(o)})}function Xn(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const s=t[r],i=e[r];if(s){const o={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!gt)o.recreate=!0,n.change.push(o);else{const u=s.idxByName,a=i.idxByName;let c;for(c in u)a[c]||o.del.push(c);for(c in a){const h=u[c],l=a[c];h?h.src!==l.src&&o.change.push(l):o.add.push(l)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}else n.add.push([r,i])}return n}function Ct(t,e,n,r){const s=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(i=>Wt(s,i)),s}function Wt(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Vt(t,e,n){const r={};return ut(e.objectStoreNames,0).forEach(s=>{const i=n.objectStore(s);let o=i.keyPath;const u=Mt(Hn(o),o||"",!1,!1,!!i.autoIncrement,o&&typeof o!="string",!0),a=[];for(let h=0;h<i.indexNames.length;++h){const l=i.index(i.indexNames[h]);o=l.keyPath;var c=Mt(l.name,o,!!l.unique,!!l.multiEntry,!1,o&&typeof o!="string",!1);a.push(c)}r[s]=Gn(s,u,a)}),r}function zt({_novip:t},e,n){const r=n.db.objectStoreNames;for(let s=0;s<r.length;++s){const i=r[s],o=n.objectStore(i);t._hasGetAll="getAll"in o;for(let u=0;u<o.indexNames.length;++u){const a=o.indexNames[u],c=o.index(a).keyPath,h=typeof c=="string"?c:"["+ut(c).join("+")+"]";if(e[i]){const l=e[i].idxByName[h];l&&(l.name=a,delete e[i].idxByName[h],e[i].idxByName[a]=l)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&N.WorkerGlobalScope&&N instanceof N.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class Ir{_parseStoresSpec(e,n){I(e).forEach(r=>{if(e[r]!==null){var s=e[r].split(",").map((o,u)=>{const a=(o=o.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(a)?a.match(/^\[(.*)\]$/)[1].split("+"):a;return Mt(a,c||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),M(c),u===0)}),i=s.shift();if(i.multi)throw new P.Schema("Primary key cannot be multi-valued");s.forEach(o=>{if(o.auto)throw new P.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new P.Schema("Index must have a name and cannot be an empty string")}),n[r]=Gn(r,i,s)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?U(this._cfg.storesSource,e):e;const r=n._versions,s={};let i={};return r.forEach(o=>{U(s,o._cfg.storesSource),i=o._cfg.dbschema={},o._parseStoresSpec(s,i)}),n._dbSchema=i,Ut(n,[n._allTables,n,n.Transaction.prototype]),pt(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],I(i),i),n._storeNames=I(i),this}upgrade(e){return this._cfg.contentUpgrade=tn(this._cfg.contentUpgrade||K,e),this}}function on(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Se(yt,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function an(t){return t&&typeof t.databases=="function"}function Yt(t){return oe(function(){return E.letThrough=!0,t()})}function Dr(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function Br(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?D(e.dbOpenError):t);G&&(e.openCanceller._stackHolder=Ee()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function s(){if(e.openCanceller!==r)throw new P.DatabaseClosed("db.open() was cancelled")}let i=e.dbReadyResolve,o=null,u=!1;return S.race([r,(typeof navigator>"u"?S.resolve():Dr()).then(()=>new S((a,c)=>{if(s(),!n)throw new P.MissingAPI;const h=t.name,l=e.autoSchema?n.open(h):n.open(h,Math.round(10*t.verno));if(!l)throw new P.MissingAPI;l.onerror=H(c),l.onblocked=$(t._fireOnBlocked),l.onupgradeneeded=$(d=>{if(o=l.transaction,e.autoSchema&&!t._options.allowEmptyDB){l.onerror=qe,o.abort(),l.result.close();const m=n.deleteDatabase(h);m.onsuccess=m.onerror=$(()=>{c(new P.NoSuchDatabase(`Database ${h} doesnt exist`))})}else{o.onerror=H(c);var p=d.oldVersion>Math.pow(2,62)?0:d.oldVersion;u=p<1,t._novip.idbdb=l.result,jr(t,p/10,o,c)}},c),l.onsuccess=$(()=>{o=null;const d=t._novip.idbdb=l.result,p=ut(d.objectStoreNames);if(p.length>0)try{const f=d.transaction((m=p).length===1?m[0]:m,"readonly");e.autoSchema?function({_novip:v},y,g){v.verno=y.version/10;const b=v._dbSchema=Vt(0,y,g);v._storeNames=ut(y.objectStoreNames,0),pt(v,[v._allTables],I(b),b)}(t,d,f):(zt(t,t._dbSchema,f),function(v,y){const g=Xn(Vt(0,v.idbdb,y),v._dbSchema);return!(g.add.length||g.change.some(b=>b.add.length||b.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Lt(t,f)}catch{}var m;je.push(t),d.onversionchange=$(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),d.onclose=$(f=>{t.on("close").fire(f)}),u&&function({indexedDB:f,IDBKeyRange:v},y){!an(f)&&y!==yt&&on(f,v).put({name:y}).catch(K)}(t._deps,h),a()},c)}))]).then(()=>(s(),e.onReadyBeingFired=[],S.resolve(Yt(()=>t.on.ready.fire(t.vip))).then(function a(){if(e.onReadyBeingFired.length>0){let c=e.onReadyBeingFired.reduce(tn,K);return e.onReadyBeingFired=[],S.resolve(Yt(()=>c(t.vip))).then(a)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(a=>{e.dbOpenError=a;try{o&&o.abort()}catch{}return r===e.openCanceller&&t._close(),D(a)}).finally(()=>{e.openComplete=!0,i()})}function Ht(t){var e=i=>t.next(i),n=s(e),r=s(i=>t.throw(i));function s(i){return o=>{var u=i(o),a=u.value;return u.done?a:a&&typeof a.then=="function"?a.then(n,r):M(a)?Promise.all(a).then(n,r):n(a)}}return s(e)()}function Fr(t,e,n){var r=arguments.length;if(r<2)throw new P.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[t,Tn(s),n]}function Qn(t,e,n,r,s){return S.resolve().then(()=>{const i=E.transless||E,o=t._createTransaction(e,n,t._dbSchema,r),u={trans:o,transless:i};if(r)o.idbtrans=r.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(l){return l.name===en.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Qn(t,e,n,null,s))):D(l)}const a=Jt(s);let c;a&&Pe();const h=S.follow(()=>{if(c=s.call(o,o),c)if(a){var l=ne.bind(null,null);c.then(l,l)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Ht(c))},u);return(c&&typeof c.then=="function"?S.resolve(c).then(l=>o.active?l:D(new P.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):h.then(()=>c)).then(l=>(r&&o._resolve(),o._completion.then(()=>l))).catch(l=>(o._reject(l),D(l)))})}function et(t,e,n){const r=M(t)?t.slice():[t];for(let s=0;s<n;++s)r.push(e);return r}const Mr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(t){return{...t,table(e){const n=t.table(e),{schema:r}=n,s={},i=[];function o(c,h,l){const d=De(c),p=s[d]=s[d]||[],m=c==null?0:typeof c=="string"?1:c.length,f=h>0,v={...l,isVirtual:f,keyTail:h,keyLength:m,extractKey:qt(c),unique:!f&&l.unique};return p.push(v),v.isPrimaryKey||i.push(v),m>1&&o(m===2?c[0]:c.slice(0,m-1),h+1,l),p.sort((y,g)=>y.keyTail-g.keyTail),v}const u=o(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[u];for(const c of r.indexes)o(c.keyPath,0,c);function a(c){const h=c.query.index;return h.isVirtual?{...c,query:{index:h,range:(l=c.query.range,d=h.keyTail,{type:l.type===1?2:l.type,lower:et(l.lower,l.lowerOpen?t.MAX_KEY:t.MIN_KEY,d),lowerOpen:!0,upper:et(l.upper,l.upperOpen?t.MIN_KEY:t.MAX_KEY,d),upperOpen:!0})}}:c;var l,d}return{...n,schema:{...r,primaryKey:u,indexes:i,getIndexByKeyPath:function(c){const h=s[De(c)];return h&&h[0]}},count:c=>n.count(a(c)),query:c=>n.query(a(c)),openCursor(c){const{keyTail:h,isVirtual:l,keyLength:d}=c.query.index;return l?n.openCursor(a(c)).then(p=>p&&function(m){return Object.create(m,{continue:{value:function(f){f!=null?m.continue(et(f,c.reverse?t.MAX_KEY:t.MIN_KEY,h)):c.unique?m.continue(m.key.slice(0,d).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,h)):m.continue()}},continuePrimaryKey:{value(f,v){m.continuePrimaryKey(et(f,t.MAX_KEY,h),v)}},primaryKey:{get:()=>m.primaryKey},key:{get(){const f=m.key;return d===1?f[0]:f.slice(0,d)}},value:{get:()=>m.value}})}(p)):n.openCursor(c)}}}}}};function un(t,e,n,r){return n=n||{},r=r||"",I(t).forEach(s=>{if(z(e,s)){var i=t[s],o=e[s];if(typeof i=="object"&&typeof o=="object"&&i&&o){const u=Pt(i);u!==Pt(o)?n[r+s]=e[s]:u==="Object"?un(i,o,n,r+s+"."):i!==o&&(n[r+s]=e[s])}else i!==o&&(n[r+s]=e[s])}else n[r+s]=void 0}),I(e).forEach(s=>{z(t,s)||(n[r+s]=e[s])}),n}const qr={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=E.trans,{deleting:o,creating:u,updating:a}=i.table(e).hook;switch(s.type){case"add":if(u.fire===K)break;return i._promise("readwrite",()=>c(s),!0);case"put":if(u.fire===K&&a.fire===K)break;return i._promise("readwrite",()=>c(s),!0);case"delete":if(o.fire===K)break;return i._promise("readwrite",()=>c(s),!0);case"deleteRange":if(o.fire===K)break;return i._promise("readwrite",()=>function(l){return h(l.trans,l.range,1e4)}(s),!0)}return n.mutate(s);function c(l){const d=E.trans,p=l.keys||function(m,f){return f.type==="delete"?f.keys:f.keys||f.values.map(m.extractKey)}(r,l);if(!p)throw new Error("Keys missing");return(l=l.type==="add"||l.type==="put"?{...l,keys:p}:{...l}).type!=="delete"&&(l.values=[...l.values]),l.keys&&(l.keys=[...l.keys]),function(m,f,v){return f.type==="add"?Promise.resolve([]):m.getMany({trans:f.trans,keys:v,cache:"immutable"})}(n,l,p).then(m=>{const f=p.map((v,y)=>{const g=m[y],b={onerror:null,onsuccess:null};if(l.type==="delete")o.fire.call(b,v,g,d);else if(l.type==="add"||g===void 0){const w=u.fire.call(b,v,l.values[y],d);v==null&&w!=null&&(v=w,l.keys[y]=v,r.outbound||Y(l.values[y],r.keyPath,v))}else{const w=un(g,l.values[y]),C=a.fire.call(b,w,v,g,d);if(C){const k=l.values[y];Object.keys(C).forEach(_=>{z(k,_)?k[_]=C[_]:Y(k,_,C[_])})}}return b});return n.mutate(l).then(({failures:v,results:y,numFailures:g,lastResult:b})=>{for(let w=0;w<p.length;++w){const C=y?y[w]:p[w],k=f[w];C==null?k.onerror&&k.onerror(v[w]):k.onsuccess&&k.onsuccess(l.type==="put"&&m[w]?l.values[w]:C)}return{failures:v,results:y,numFailures:g,lastResult:b}}).catch(v=>(f.forEach(y=>y.onerror&&y.onerror(v)),Promise.reject(v)))})}function h(l,d,p){return n.query({trans:l,values:!1,query:{index:r,range:d},limit:p}).then(({result:m})=>c({type:"delete",keys:m,trans:l}).then(f=>f.numFailures>0?Promise.reject(f.failures[0]):m.length<p?{failures:[],numFailures:0,lastResult:void 0}:h(l,{...d,lower:m[m.length-1],lowerOpen:!0},p)))}}}}})};function Jn(t,e,n){try{if(!e||e.keys.length<t.length)return null;const r=[];for(let s=0,i=0;s<e.keys.length&&i<t.length;++s)L(e.keys[s],t[i])===0&&(r.push(n?Ve(e.values[s]):e.values[s]),++i);return r.length===t.length?r:null}catch{return null}}const Lr={stack:"dbcore",level:-1,create:t=>({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const s=Jn(r.keys,r.trans._cache,r.cache==="clone");return s?S.resolve(s):n.getMany(r).then(i=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Ve(i):i},i))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function ln(t){return!("from"in t)}const Q=function(t,e){if(!this){const n=new Q;return t&&"d"in t&&U(n,t),n}U(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function We(t,e,n){const r=L(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(ln(t))return U(t,{from:e,to:n,d:1});const s=t.l,i=t.r;if(L(n,t.from)<0)return s?We(s,e,n):t.l={from:e,to:n,d:1,l:null,r:null},wn(t);if(L(e,t.to)>0)return i?We(i,e,n):t.r={from:e,to:n,d:1,l:null,r:null},wn(t);L(e,t.from)<0&&(t.from=e,t.l=null,t.d=i?i.d+1:1),L(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const o=!t.r;s&&!t.l&&mt(t,s),i&&o&&mt(t,i)}function mt(t,e){ln(e)||function n(r,{from:s,to:i,l:o,r:u}){We(r,s,i),o&&n(r,o),u&&n(r,u)}(t,e)}function Ur(t,e){const n=Gt(e);let r=n.next();if(r.done)return!1;let s=r.value;const i=Gt(t);let o=i.next(s.from),u=o.value;for(;!r.done&&!o.done;){if(L(u.from,s.to)<=0&&L(u.to,s.from)>=0)return!0;L(s.from,u.from)<0?s=(r=n.next(u.from)).value:u=(o=i.next(s.from)).value}return!1}function Gt(t){let e=ln(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&L(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||L(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function wn(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const i=s==="r"?"l":"r",o={...t},u=t[s];t.from=u.from,t.to=u.to,t[s]=u[s],o[s]=u[i],t[i]=o,o.d=_n(o)}t.d=_n(t)}function _n({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}Ce(Q.prototype,{add(t){return mt(this,t),this},addKey(t){return We(this,t,t),this},addKeys(t){return t.forEach(e=>We(this,e,e)),this},[Tt](){return Gt(this)}});const Wr={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new Q(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const s=t.table(r),{schema:i}=s,{primaryKey:o}=i,{extractKey:u,outbound:a}=o,c={...s,mutate:d=>{const p=d.trans,m=p.mutatedParts||(p.mutatedParts={}),f=k=>{const _=`idb://${e}/${r}/${k}`;return m[_]||(m[_]=new Q)},v=f(""),y=f(":dels"),{type:g}=d;let[b,w]=d.type==="deleteRange"?[d.range]:d.type==="delete"?[d.keys]:d.values.length<50?[[],d.values]:[];const C=d.trans._cache;return s.mutate(d).then(k=>{if(M(b)){g!=="delete"&&(b=k.results),v.addKeys(b);const _=Jn(b,C);_||g==="add"||y.addKeys(b),(_||w)&&function(O,x,R,A){function q(B){const j=O(B.name||"");function ge(W){return W!=null?B.extractKey(W):null}const ye=W=>B.multiEntry&&M(W)?W.forEach(le=>j.addKey(le)):j.addKey(W);(R||A).forEach((W,le)=>{const Oe=R&&ge(R[le]),vt=A&&ge(A[le]);L(Oe,vt)!==0&&(Oe!=null&&ye(Oe),vt!=null&&ye(vt))})}x.indexes.forEach(q)}(f,i,_,w)}else if(b){const _={from:b.lower,to:b.upper};y.add(_),v.add(_)}else v.add(n),y.add(n),i.indexes.forEach(_=>f(_.name).add(n));return k})}},h=({query:{index:d,range:p}})=>{var m,f;return[d,new Q((m=p.lower)!==null&&m!==void 0?m:t.MIN_KEY,(f=p.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},l={get:d=>[o,new Q(d.key)],getMany:d=>[o,new Q().addKeys(d.keys)],count:h,query:h,openCursor:h};return I(l).forEach(d=>{c[d]=function(p){const{subscr:m}=E;if(m){const f=w=>{const C=`idb://${e}/${r}/${w}`;return m[C]||(m[C]=new Q)},v=f(""),y=f(":dels"),[g,b]=l[d](p);if(f(g.name||"").add(b),!g.isPrimaryKey){if(d!=="count"){const w=d==="query"&&a&&p.values&&s.query({...p,values:!1});return s[d].apply(this,arguments).then(C=>{if(d==="query"){if(a&&p.values)return w.then(({result:_})=>(v.addKeys(_),C));const k=p.values?C.result.map(u):C.result;p.values?v.addKeys(k):y.addKeys(k)}else if(d==="openCursor"){const k=C,_=p.values;return k&&Object.create(k,{key:{get:()=>(y.addKey(k.primaryKey),k.key)},primaryKey:{get(){const O=k.primaryKey;return y.addKey(O),O}},value:{get:()=>(_&&v.addKey(k.primaryKey),k.value)}})}return C})}y.add(n)}}return s[d].apply(this,arguments)}}),c}}}};class Se{constructor(e,n){this._middlewares={},this.verno=0;const r=Se.dependencies;this._options=n={addons:Se.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:s}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:K,dbReadyPromise:null,cancelOpen:K,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var o;i.dbReadyPromise=new S(u=>{i.dbReadyResolve=u}),i.openCanceller=new S((u,a)=>{i.cancelOpen=a}),this._state=i,this.name=e,this.on=Ie(this,"populate","blocked","versionchange","close",{ready:[tn,K]}),this.on.ready.subscribe=Sn(this.on.ready.subscribe,u=>(a,c)=>{Se.vip(()=>{const h=this._state;if(h.openComplete)h.dbOpenError||S.resolve().then(a),c&&u(a);else if(h.onReadyBeingFired)h.onReadyBeingFired.push(a),c&&u(a);else{u(a);const l=this;c||u(function d(){l.on.ready.unsubscribe(a),l.on.ready.unsubscribe(d)})}})}),this.Collection=(o=this,Ae(Pr.prototype,function(u,a){this.db=o;let c=Vn,h=null;if(a)try{c=a()}catch(m){h=m}const l=u._ctx,d=l.table,p=d.hook.reading.fire;this._ctx={table:d,index:l.index,isPrimKey:!l.index||d.schema.primKey.keyPath&&l.index===d.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:h,or:l.or,valueMapper:p!==Fe?p:null}})),this.Table=function(u){return Ae(Er.prototype,function(a,c,h){this.db=u,this._tx=h,this.name=a,this.schema=c,this.hook=u._allTables[a]?u._allTables[a].hook:Ie(null,{creating:[pr,K],reading:[fr,Fe],updating:[gr,K],deleting:[mr,K]})})}(this),this.Transaction=function(u){return Ae(Kr.prototype,function(a,c,h,l,d){this.db=u,this.mode=a,this.storeNames=c,this.schema=h,this.chromeTransactionDurability=l,this.idbtrans=null,this.on=Ie(this,"complete","error","abort"),this.parent=d||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new S((p,m)=>{this._resolve=p,this._reject=m}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var m=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):m&&this.idbtrans&&this.idbtrans.abort(),D(p)})})}(this),this.Version=function(u){return Ae(Ir.prototype,function(a){this.db=u,this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(u){return Ae(Yn.prototype,function(a,c,h){this.db=u,this._ctx={table:a,index:c===":id"?null:c,or:h};const l=u._deps.indexedDB;if(!l)throw new P.MissingAPI;this._cmp=this._ascending=l.cmp.bind(l),this._descending=(d,p)=>l.cmp(p,d),this._max=(d,p)=>l.cmp(d,p)>0?d:p,this._min=(d,p)=>l.cmp(d,p)<0?d:p,this._IDBKeyRange=u._deps.IDBKeyRange})}(this),this.on("versionchange",u=>{u.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",u=>{!u.newVersion||u.newVersion<u.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${u.oldVersion/10}`)}),this._maxKey=Ue(n.IDBKeyRange),this._createTransaction=(u,a,c,h)=>new this.Transaction(u,a,c,this._options.chromeTransactionDurability,h),this._fireOnBlocked=u=>{this.on("blocked").fire(u),je.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(u))},this.use(Mr),this.use(qr),this.use(Wr),this.use(Lr),this.vip=Object.create(this,{_vip:{value:!0}}),s.forEach(u=>u(this))}version(e){if(isNaN(e)||e<.1)throw new P.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new P.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(s=>s._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(Rr),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||E.letThrough||this._vip)?e():new S((n,r)=>{if(this._state.openComplete)return r(new P.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new P.DatabaseClosed);this.open().catch(K)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:s}){s&&this.unuse({stack:e,name:s});const i=this._middlewares[e]||(this._middlewares[e]=[]);return i.push({stack:e,create:n,level:r??10,name:s}),i.sort((o,u)=>o.level-u.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(s=>r?s.create!==r:!!n&&s.name!==n)),this}open(){return Br(this)}_close(){const e=this._state,n=je.indexOf(this);if(n>=0&&je.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new S(r=>{e.dbReadyResolve=r}),e.openCanceller=new S((r,s)=>{e.cancelOpen=s})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new P.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new S((r,s)=>{const i=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=$(()=>{(function({indexedDB:u,IDBKeyRange:a},c){!an(u)&&c!==yt&&on(u,a).delete(c).catch(K)})(this._deps,this.name),r()}),o.onerror=H(s),o.onblocked=this._fireOnBlocked};if(e)throw new P.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(i):i()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return I(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Fr.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let s=E.trans;s&&s.db===this&&e.indexOf("!")===-1||(s=null);const i=e.indexOf("?")!==-1;let o,u;e=e.replace("!","").replace("?","");try{if(u=n.map(c=>{var h=c instanceof this.Table?c.name:c;if(typeof h!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return h}),e=="r"||e===wt)o=wt;else{if(e!="rw"&&e!=_t)throw new P.InvalidArgument("Invalid transaction mode: "+e);o=_t}if(s){if(s.mode===wt&&o===_t){if(!i)throw new P.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");s=null}s&&u.forEach(c=>{if(s&&s.storeNames.indexOf(c)===-1){if(!i)throw new P.SubTransaction("Table "+c+" not included in parent transaction.");s=null}}),i&&s&&!s.active&&(s=null)}}catch(c){return s?s._promise(null,(h,l)=>{l(c)}):D(c)}const a=Qn.bind(null,this,o,u,s,r);return s?s._promise(o,a,"lock"):E.trans?Te(E.transless,()=>this._whenReady(a)):this._whenReady(a)}table(e){if(!z(this._allTables,e))throw new P.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Vr=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class zr{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Vr](){return this}}function Zn(t,e){return I(e).forEach(n=>{mt(t[n]||(t[n]=new Q),e[n])}),t}function Yr(t){let e,n=!1;const r=new zr(s=>{const i=Jt(t);let o=!1,u={},a={};const c={get closed(){return o},unsubscribe:()=>{o=!0,ue.storagemutated.unsubscribe(p)}};s.start&&s.start(c);let h=!1,l=!1;function d(){return I(a).some(f=>u[f]&&Ur(u[f],a[f]))}const p=f=>{Zn(u,f),d()&&m()},m=()=>{if(h||o)return;u={};const f={},v=function(y){i&&Pe();const g=()=>oe(t,{subscr:y,trans:null}),b=E.trans?Te(E.transless,g):g();return i&&b.then(ne,ne),b}(f);l||(ue(Le,p),l=!0),h=!0,Promise.resolve(v).then(y=>{n=!0,e=y,h=!1,o||(d()?m():(u={},a=f,s.next&&s.next(y)))},y=>{h=!1,n=!1,s.error&&s.error(y),c.unsubscribe()})};return m(),c});return r.hasValue=()=>n,r.getValue=()=>e,r}let Xt;try{Xt={indexedDB:N.indexedDB||N.mozIndexedDB||N.webkitIndexedDB||N.msIndexedDB,IDBKeyRange:N.IDBKeyRange||N.webkitIDBKeyRange}}catch{Xt={indexedDB:null,IDBKeyRange:null}}const ce=Se;function at(t){let e=Z;try{Z=!0,ue.storagemutated.fire(t)}finally{Z=e}}Ce(ce,{...tt,delete:t=>new ce(t,{addons:[]}).delete(),exists:t=>new ce(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return an(e)?Promise.resolve(e.databases()).then(r=>r.map(s=>s.name).filter(s=>s!==yt)):on(e,n).toCollection().primaryKeys()}(ce.dependencies).then(t)}catch{return D(new P.MissingAPI)}},defineClass:()=>function(t){U(this,t)},ignoreTransaction:t=>E.trans?Te(E.transless,t):t(),vip:Yt,async:function(t){return function(){try{var e=Ht(t.apply(this,arguments));return e&&typeof e.then=="function"?e:S.resolve(e)}catch(n){return D(n)}}},spawn:function(t,e,n){try{var r=Ht(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:S.resolve(r)}catch(s){return D(s)}},currentTransaction:{get:()=>E.trans||null},waitFor:function(t,e){const n=S.resolve(typeof t=="function"?ce.ignoreTransaction(t):t).timeout(e||6e4);return E.trans?E.trans.waitFor(n):n},Promise:S,debug:{get:()=>G,set:t=>{An(t,t==="dexie"?()=>!0:Wn)}},derive:_e,extend:U,props:Ce,override:Sn,Events:Ie,on:ue,liveQuery:Yr,extendObservabilitySet:Zn,getByKeyPath:te,setByKeyPath:Y,delByKeyPath:function(t,e){typeof e=="string"?Y(t,e,void 0):"length"in e&&[].map.call(e,function(n){Y(t,n,void 0)})},shallowClone:Pn,deepClone:Ve,getObjectDiff:un,cmp:L,asap:Cn,minKey:Ft,addons:[],connections:je,errnames:en,dependencies:Xt,semVer:pn,version:pn.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),ce.maxKey=Ue(ce.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ue(Le,t=>{if(!Z){let e;gt?(e=document.createEvent("CustomEvent"),e.initCustomEvent(ie,!0,!0,t)):e=new CustomEvent(ie,{detail:t}),Z=!0,dispatchEvent(e),Z=!1}}),addEventListener(ie,({detail:t})=>{Z||at(t)}));let Z=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(ie);typeof t.unref=="function"&&t.unref(),ue(Le,e=>{Z||t.postMessage(e)}),t.onmessage=e=>{e.data&&at(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){ue(Le,e=>{try{Z||(typeof localStorage<"u"&&localStorage.setItem(ie,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ie,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===ie){const n=JSON.parse(e.newValue);n&&at(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===ie&&at(e.changedParts)})}S.rejectionMapper=function(t,e){if(!t||t instanceof ke||t instanceof TypeError||t instanceof SyntaxError||!t.name||!cn[t.name])return t;var n=new cn[t.name](e||t.message,t);return"stack"in t&&ee(n,"stack",{get:function(){return this.inner.stack}}),n},An(G,Wn);exports.NylasBaseProvider=tr;exports.Xr=nr;exports.nr=kn;