@nylas/web-elements 1.1.0-canary.7 → 1.1.0-canary.9

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 (473) hide show
  1. package/dist/cjs/{add-circle-icon_22.cjs.entry.js → add-circle-icon_21.cjs.entry.js} +55 -165
  2. package/dist/cjs/add-circle-icon_21.cjs.entry.js.map +1 -0
  3. package/dist/cjs/forward-icon_6.cjs.entry.js +2 -2
  4. package/dist/cjs/google-logo-icon_4.cjs.entry.js +24 -16
  5. package/dist/cjs/google-logo-icon_4.cjs.entry.js.map +1 -1
  6. package/dist/cjs/index.cjs.js +2 -2
  7. package/dist/cjs/{index.es-b12b7df1.js → index.es-cc2d145f.js} +3 -3
  8. package/dist/cjs/index.es-cc2d145f.js.map +1 -0
  9. package/dist/cjs/{index.es-0a0f2d87.js → index.es-ec84e726.js} +3 -3
  10. package/dist/cjs/index.es-ec84e726.js.map +1 -0
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/{mailbox-store-14531fd4.js → mailbox-store-5ea7604e.js} +3 -3
  13. package/dist/cjs/{mailbox-store-05fa3bec.js.map → mailbox-store-5ea7604e.js.map} +1 -1
  14. package/dist/cjs/{mailbox-store-05fa3bec.js → mailbox-store-a02df2a7.js} +3 -3
  15. package/dist/cjs/{mailbox-store-14531fd4.js.map → mailbox-store-a02df2a7.js.map} +1 -1
  16. package/dist/cjs/multi-select-dropdown.cjs.entry.js +1 -1
  17. package/dist/cjs/nylas-additional-participants.cjs.entry.js +2 -2
  18. package/dist/cjs/{nylas-api-request-abdb8dd8.js → nylas-api-request-05f1e068.js} +2 -2
  19. package/dist/cjs/{nylas-api-request-abdb8dd8.js.map → nylas-api-request-05f1e068.js.map} +1 -1
  20. package/dist/cjs/{nylas-api-request-27c25287.js → nylas-api-request-de316f1a.js} +2 -2
  21. package/dist/cjs/{nylas-api-request-27c25287.js.map → nylas-api-request-de316f1a.js.map} +1 -1
  22. package/dist/cjs/nylas-availability-picker.cjs.entry.js +4 -3
  23. package/dist/cjs/nylas-availability-picker.cjs.entry.js.map +1 -1
  24. package/dist/cjs/nylas-booked-event-card.cjs.entry.js +21 -5
  25. package/dist/cjs/nylas-booked-event-card.cjs.entry.js.map +1 -1
  26. package/dist/cjs/nylas-booked-event-card_10.cjs.entry.js +54 -9
  27. package/dist/cjs/nylas-booked-event-card_10.cjs.entry.js.map +1 -1
  28. package/dist/cjs/nylas-booking-calendar-picker.cjs.entry.js +2 -2
  29. package/dist/cjs/nylas-booking-form.cjs.entry.js +2 -2
  30. package/dist/cjs/nylas-buffer-time.cjs.entry.js +4 -4
  31. package/dist/cjs/nylas-buffer-time.cjs.entry.js.map +1 -1
  32. package/dist/cjs/nylas-calendar-picker.cjs.entry.js +2 -2
  33. package/dist/cjs/nylas-cancel-booking-form.cjs.entry.js +2 -2
  34. package/dist/cjs/nylas-cancelled-event-card.cjs.entry.js +22 -5
  35. package/dist/cjs/nylas-cancelled-event-card.cjs.entry.js.map +1 -1
  36. package/dist/cjs/nylas-composer.cjs.entry.js +1 -1
  37. package/dist/cjs/nylas-custom-booking-flow.cjs.entry.js +2 -2
  38. package/dist/cjs/nylas-date-picker.cjs.entry.js +15 -3
  39. package/dist/cjs/nylas-date-picker.cjs.entry.js.map +1 -1
  40. package/dist/cjs/nylas-editor-tabs.cjs.entry.js +18 -12
  41. package/dist/cjs/nylas-editor-tabs.cjs.entry.js.map +1 -1
  42. package/dist/cjs/nylas-event-description.cjs.entry.js +2 -2
  43. package/dist/cjs/nylas-event-duration.cjs.entry.js +2 -2
  44. package/dist/cjs/nylas-event-info.cjs.entry.js +3 -3
  45. package/dist/cjs/nylas-event-info.cjs.entry.js.map +1 -1
  46. package/dist/cjs/nylas-event-limits.cjs.entry.js +3 -3
  47. package/dist/cjs/nylas-event-limits.cjs.entry.js.map +1 -1
  48. package/dist/cjs/nylas-event-title.cjs.entry.js +22 -11
  49. package/dist/cjs/nylas-event-title.cjs.entry.js.map +1 -1
  50. package/dist/cjs/nylas-form-card.cjs.entry.js +2 -2
  51. package/dist/cjs/nylas-if-state.cjs.entry.js +2 -2
  52. package/dist/cjs/nylas-limit-future-bookings.cjs.entry.js +3 -3
  53. package/dist/cjs/nylas-limit-future-bookings.cjs.entry.js.map +1 -1
  54. package/dist/cjs/nylas-list-configurations.cjs.entry.js +8 -6
  55. package/dist/cjs/nylas-list-configurations.cjs.entry.js.map +1 -1
  56. package/dist/cjs/nylas-list-folders.cjs.entry.js +2 -2
  57. package/dist/cjs/nylas-list-threads.cjs.entry.js +2 -2
  58. package/dist/cjs/nylas-locale-switch.cjs.entry.js +2 -2
  59. package/dist/cjs/nylas-location-component.cjs.entry.js +3 -3
  60. package/dist/cjs/nylas-location-component.cjs.entry.js.map +1 -1
  61. package/dist/cjs/nylas-login.cjs.entry.js +2 -2
  62. package/dist/cjs/nylas-mailbox-pagination.cjs.entry.js +2 -2
  63. package/dist/cjs/nylas-mailbox-toolbar-button.cjs.entry.js +2 -2
  64. package/dist/cjs/nylas-mailbox.cjs.entry.js +3 -3
  65. package/dist/cjs/nylas-min-cancellation-notice.cjs.entry.js +3 -3
  66. package/dist/cjs/nylas-min-cancellation-notice.cjs.entry.js.map +1 -1
  67. package/dist/cjs/nylas-notification.cjs.entry.js +1 -1
  68. package/dist/cjs/nylas-provider.cjs.entry.js +5 -5
  69. package/dist/cjs/nylas-scheduler-editor.cjs.entry.js +8 -14
  70. package/dist/cjs/nylas-scheduler-editor.cjs.entry.js.map +1 -1
  71. package/dist/cjs/nylas-scheduling.cjs.entry.js +35 -12
  72. package/dist/cjs/nylas-scheduling.cjs.entry.js.map +1 -1
  73. package/dist/cjs/nylas-selected-event-card.cjs.entry.js +2 -2
  74. package/dist/cjs/nylas-summarize-message-button.cjs.entry.js +2 -2
  75. package/dist/cjs/nylas-threads-refresh.cjs.entry.js +2 -2
  76. package/dist/cjs/nylas-threads-search.cjs.entry.js +2 -2
  77. package/dist/cjs/nylas-time-window-picker.cjs.entry.js +1 -1
  78. package/dist/cjs/nylas-timeslot-picker.cjs.entry.js +2 -2
  79. package/dist/cjs/nylas-view-email.cjs.entry.js +1 -1
  80. package/dist/cjs/nylas-view-thread.cjs.entry.js +2 -2
  81. package/dist/cjs/nylas-web-elements.cjs.js +1 -1
  82. package/dist/cjs/{register-component-09ebdf31.js → register-component-2c3ad1d1.js} +2 -2
  83. package/dist/cjs/{register-component-09ebdf31.js.map → register-component-2c3ad1d1.js.map} +1 -1
  84. package/dist/cjs/{register-component-c8b6e907.js → register-component-4f8ae42c.js} +2 -2
  85. package/dist/cjs/{register-component-c8b6e907.js.map → register-component-4f8ae42c.js.map} +1 -1
  86. package/dist/cjs/{scheduler-config-store-37690bf0.js → scheduler-config-store-918c20d5.js} +3 -4
  87. package/dist/cjs/scheduler-config-store-918c20d5.js.map +1 -0
  88. package/dist/cjs/{scheduler-config-store-529c8d7e.js → scheduler-config-store-a5b7c08b.js} +3 -4
  89. package/dist/cjs/scheduler-config-store-a5b7c08b.js.map +1 -0
  90. package/dist/cjs/{scheduler-store-67dc1986.js → scheduler-store-33e204ef.js} +39 -7
  91. package/dist/cjs/scheduler-store-33e204ef.js.map +1 -0
  92. package/dist/cjs/{scheduler-store-0081970d.js → scheduler-store-df23f511.js} +39 -7
  93. package/dist/cjs/scheduler-store-df23f511.js.map +1 -0
  94. package/dist/cjs/time-period-selector.cjs.entry.js +1 -1
  95. package/dist/cjs/{utils-2c7f0895.js → utils-85bd0909.js} +109 -2
  96. package/dist/cjs/utils-85bd0909.js.map +1 -0
  97. package/dist/cjs/{utils-20663d54.js → utils-e6d76818.js} +109 -2
  98. package/dist/cjs/utils-e6d76818.js.map +1 -0
  99. package/dist/collection/common/types.js.map +1 -1
  100. package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.css +2 -1
  101. package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.js +56 -3
  102. package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.js.map +1 -1
  103. package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.js +75 -6
  104. package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.js.map +1 -1
  105. package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.js +37 -3
  106. package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.js.map +1 -1
  107. package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduling.js +41 -12
  108. package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduling.js.map +1 -1
  109. package/dist/collection/components/scheduler-editor/nylas-availability-picker/nylas-availability-picker.js +2 -1
  110. package/dist/collection/components/scheduler-editor/nylas-availability-picker/nylas-availability-picker.js.map +1 -1
  111. package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.css +23 -3
  112. package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.js +1 -1
  113. package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.js.map +1 -1
  114. package/dist/collection/components/scheduler-editor/nylas-editor-tabs/nylas-editor-tabs.css +7 -0
  115. package/dist/collection/components/scheduler-editor/nylas-editor-tabs/nylas-editor-tabs.js +39 -14
  116. package/dist/collection/components/scheduler-editor/nylas-editor-tabs/nylas-editor-tabs.js.map +1 -1
  117. package/dist/collection/components/scheduler-editor/nylas-editor-tabs/tab-contents.js +1 -1
  118. package/dist/collection/components/scheduler-editor/nylas-editor-tabs/tab-contents.js.map +1 -1
  119. package/dist/collection/components/scheduler-editor/nylas-event-info/nylas-event-info.js +1 -1
  120. package/dist/collection/components/scheduler-editor/nylas-event-info/nylas-event-info.js.map +1 -1
  121. package/dist/collection/components/scheduler-editor/nylas-event-limits/nylas-event-limits.js +1 -1
  122. package/dist/collection/components/scheduler-editor/nylas-event-limits/nylas-event-limits.js.map +1 -1
  123. package/dist/collection/components/scheduler-editor/nylas-event-title/nylas-event-title.js +21 -10
  124. package/dist/collection/components/scheduler-editor/nylas-event-title/nylas-event-title.js.map +1 -1
  125. package/dist/collection/components/scheduler-editor/nylas-limit-future-bookings/nylas-limit-future-bookings.css +7 -1
  126. package/dist/collection/components/scheduler-editor/nylas-list-configurations/nylas-list-configurations.css +20 -2
  127. package/dist/collection/components/scheduler-editor/nylas-list-configurations/nylas-list-configurations.js +5 -3
  128. package/dist/collection/components/scheduler-editor/nylas-list-configurations/nylas-list-configurations.js.map +1 -1
  129. package/dist/collection/components/scheduler-editor/nylas-location-component/nylas-location-component.css +5 -0
  130. package/dist/collection/components/scheduler-editor/nylas-min-cancellation-notice/nylas-min-cancellation-notice.css +7 -1
  131. package/dist/collection/components/scheduler-editor/nylas-scheduler-editor/nylas-scheduler-editor.css +20 -0
  132. package/dist/collection/components/scheduler-editor/nylas-scheduler-editor/nylas-scheduler-editor.js +6 -13
  133. package/dist/collection/components/scheduler-editor/nylas-scheduler-editor/nylas-scheduler-editor.js.map +1 -1
  134. package/dist/collection/connector/shared/api/scheduler-config.js +0 -1
  135. package/dist/collection/connector/shared/api/scheduler-config.js.map +1 -1
  136. package/dist/collection/connector/shared/api/scheduler.js +37 -5
  137. package/dist/collection/connector/shared/api/scheduler.js.map +1 -1
  138. package/dist/collection/stores/scheduler-config-store.js +2 -3
  139. package/dist/collection/stores/scheduler-config-store.js.map +1 -1
  140. package/dist/collection/stores/scheduler-store.js.map +1 -1
  141. package/dist/collection/utils/utils.js +104 -1
  142. package/dist/collection/utils/utils.js.map +1 -1
  143. package/dist/components/index.es.js +2 -2
  144. package/dist/components/index.es.js.map +1 -1
  145. package/dist/components/nylas-availability-picker2.js +2 -1
  146. package/dist/components/nylas-availability-picker2.js.map +1 -1
  147. package/dist/components/nylas-booked-event-card2.js +22 -5
  148. package/dist/components/nylas-booked-event-card2.js.map +1 -1
  149. package/dist/components/nylas-buffer-time2.js +2 -2
  150. package/dist/components/nylas-buffer-time2.js.map +1 -1
  151. package/dist/components/nylas-cancelled-event-card2.js +23 -4
  152. package/dist/components/nylas-cancelled-event-card2.js.map +1 -1
  153. package/dist/components/nylas-custom-booking-flow.js +170 -1
  154. package/dist/components/nylas-custom-booking-flow.js.map +1 -1
  155. package/dist/components/nylas-date-picker2.js +17 -3
  156. package/dist/components/nylas-date-picker2.js.map +1 -1
  157. package/dist/components/nylas-editor-tabs2.js +52 -51
  158. package/dist/components/nylas-editor-tabs2.js.map +1 -1
  159. package/dist/components/nylas-event-info2.js +1 -1
  160. package/dist/components/nylas-event-info2.js.map +1 -1
  161. package/dist/components/nylas-event-limits2.js +1 -1
  162. package/dist/components/nylas-event-limits2.js.map +1 -1
  163. package/dist/components/nylas-event-title2.js +21 -10
  164. package/dist/components/nylas-event-title2.js.map +1 -1
  165. package/dist/components/nylas-limit-future-bookings2.js +1 -1
  166. package/dist/components/nylas-limit-future-bookings2.js.map +1 -1
  167. package/dist/components/nylas-list-configurations2.js +7 -5
  168. package/dist/components/nylas-list-configurations2.js.map +1 -1
  169. package/dist/components/nylas-list-folders.js +1 -1
  170. package/dist/components/nylas-list-threads.js +1 -1
  171. package/dist/components/nylas-location-component2.js +1 -1
  172. package/dist/components/nylas-location-component2.js.map +1 -1
  173. package/dist/components/nylas-min-cancellation-notice2.js +1 -1
  174. package/dist/components/nylas-min-cancellation-notice2.js.map +1 -1
  175. package/dist/components/nylas-scheduler-editor.js +46 -59
  176. package/dist/components/nylas-scheduler-editor.js.map +1 -1
  177. package/dist/components/nylas-scheduling.js +34 -11
  178. package/dist/components/nylas-scheduling.js.map +1 -1
  179. package/dist/components/nylas-summarize-message-button2.js +1 -1
  180. package/dist/components/nylas-timeslot-picker2.js +1 -1
  181. package/dist/components/nylas-view-email2.js +1 -1
  182. package/dist/components/nylas-view-thread.js +1 -1
  183. package/dist/components/scheduler-config-store.js +2 -3
  184. package/dist/components/scheduler-config-store.js.map +1 -1
  185. package/dist/components/scheduler-store.js +37 -5
  186. package/dist/components/scheduler-store.js.map +1 -1
  187. package/dist/components/utils.js +105 -2
  188. package/dist/components/utils.js.map +1 -1
  189. package/dist/esm/{add-circle-icon_22.entry.js → add-circle-icon_21.entry.js} +56 -165
  190. package/dist/esm/add-circle-icon_21.entry.js.map +1 -0
  191. package/dist/esm/forward-icon_6.entry.js +2 -2
  192. package/dist/esm/google-logo-icon_4.entry.js +24 -16
  193. package/dist/esm/google-logo-icon_4.entry.js.map +1 -1
  194. package/dist/esm/{index.es-f57e612a.js → index.es-be19d2df.js} +3 -3
  195. package/dist/esm/index.es-be19d2df.js.map +1 -0
  196. package/dist/esm/{index.es-2842f8c8.js → index.es-eb477d56.js} +3 -3
  197. package/dist/esm/index.es-eb477d56.js.map +1 -0
  198. package/dist/esm/index.js +2 -2
  199. package/dist/esm/loader.js +1 -1
  200. package/dist/esm/{mailbox-store-47fc8a1a.js → mailbox-store-76540d24.js} +3 -3
  201. package/dist/{nylas-web-elements/mailbox-store-d48269de.js.map → esm/mailbox-store-76540d24.js.map} +1 -1
  202. package/dist/{nylas-web-elements/mailbox-store-d48269de.js → esm/mailbox-store-9f819402.js} +3 -3
  203. package/dist/esm/{mailbox-store-47fc8a1a.js.map → mailbox-store-9f819402.js.map} +1 -1
  204. package/dist/esm/multi-select-dropdown.entry.js +1 -1
  205. package/dist/esm/nylas-additional-participants.entry.js +2 -2
  206. package/dist/esm/{nylas-api-request-8932547a.js → nylas-api-request-59738f8c.js} +2 -2
  207. package/dist/esm/{nylas-api-request-8932547a.js.map → nylas-api-request-59738f8c.js.map} +1 -1
  208. package/dist/{nylas-web-elements/nylas-api-request-b085294d.js → esm/nylas-api-request-ff2869d7.js} +2 -2
  209. package/dist/esm/{nylas-api-request-b085294d.js.map → nylas-api-request-ff2869d7.js.map} +1 -1
  210. package/dist/esm/nylas-availability-picker.entry.js +4 -3
  211. package/dist/esm/nylas-availability-picker.entry.js.map +1 -1
  212. package/dist/esm/nylas-booked-event-card.entry.js +21 -5
  213. package/dist/esm/nylas-booked-event-card.entry.js.map +1 -1
  214. package/dist/esm/nylas-booked-event-card_10.entry.js +54 -9
  215. package/dist/esm/nylas-booked-event-card_10.entry.js.map +1 -1
  216. package/dist/esm/nylas-booking-calendar-picker.entry.js +2 -2
  217. package/dist/esm/nylas-booking-form.entry.js +2 -2
  218. package/dist/esm/nylas-buffer-time.entry.js +4 -4
  219. package/dist/esm/nylas-buffer-time.entry.js.map +1 -1
  220. package/dist/esm/nylas-calendar-picker.entry.js +2 -2
  221. package/dist/esm/nylas-cancel-booking-form.entry.js +2 -2
  222. package/dist/esm/nylas-cancelled-event-card.entry.js +22 -5
  223. package/dist/esm/nylas-cancelled-event-card.entry.js.map +1 -1
  224. package/dist/esm/nylas-composer.entry.js +1 -1
  225. package/dist/esm/nylas-custom-booking-flow.entry.js +2 -2
  226. package/dist/esm/nylas-date-picker.entry.js +15 -3
  227. package/dist/esm/nylas-date-picker.entry.js.map +1 -1
  228. package/dist/esm/nylas-editor-tabs.entry.js +18 -12
  229. package/dist/esm/nylas-editor-tabs.entry.js.map +1 -1
  230. package/dist/esm/nylas-event-description.entry.js +2 -2
  231. package/dist/esm/nylas-event-duration.entry.js +2 -2
  232. package/dist/esm/nylas-event-info.entry.js +3 -3
  233. package/dist/esm/nylas-event-info.entry.js.map +1 -1
  234. package/dist/esm/nylas-event-limits.entry.js +3 -3
  235. package/dist/esm/nylas-event-limits.entry.js.map +1 -1
  236. package/dist/esm/nylas-event-title.entry.js +22 -11
  237. package/dist/esm/nylas-event-title.entry.js.map +1 -1
  238. package/dist/esm/nylas-form-card.entry.js +2 -2
  239. package/dist/esm/nylas-if-state.entry.js +2 -2
  240. package/dist/esm/nylas-limit-future-bookings.entry.js +3 -3
  241. package/dist/esm/nylas-limit-future-bookings.entry.js.map +1 -1
  242. package/dist/esm/nylas-list-configurations.entry.js +8 -6
  243. package/dist/esm/nylas-list-configurations.entry.js.map +1 -1
  244. package/dist/esm/nylas-list-folders.entry.js +2 -2
  245. package/dist/esm/nylas-list-threads.entry.js +2 -2
  246. package/dist/esm/nylas-locale-switch.entry.js +2 -2
  247. package/dist/esm/nylas-location-component.entry.js +3 -3
  248. package/dist/esm/nylas-location-component.entry.js.map +1 -1
  249. package/dist/esm/nylas-login.entry.js +2 -2
  250. package/dist/esm/nylas-mailbox-pagination.entry.js +2 -2
  251. package/dist/esm/nylas-mailbox-toolbar-button.entry.js +2 -2
  252. package/dist/esm/nylas-mailbox.entry.js +3 -3
  253. package/dist/esm/nylas-min-cancellation-notice.entry.js +3 -3
  254. package/dist/esm/nylas-min-cancellation-notice.entry.js.map +1 -1
  255. package/dist/esm/nylas-notification.entry.js +1 -1
  256. package/dist/esm/nylas-provider.entry.js +5 -5
  257. package/dist/esm/nylas-scheduler-editor.entry.js +8 -14
  258. package/dist/esm/nylas-scheduler-editor.entry.js.map +1 -1
  259. package/dist/esm/nylas-scheduling.entry.js +35 -12
  260. package/dist/esm/nylas-scheduling.entry.js.map +1 -1
  261. package/dist/esm/nylas-selected-event-card.entry.js +2 -2
  262. package/dist/esm/nylas-summarize-message-button.entry.js +2 -2
  263. package/dist/esm/nylas-threads-refresh.entry.js +2 -2
  264. package/dist/esm/nylas-threads-search.entry.js +2 -2
  265. package/dist/esm/nylas-time-window-picker.entry.js +1 -1
  266. package/dist/esm/nylas-timeslot-picker.entry.js +2 -2
  267. package/dist/esm/nylas-view-email.entry.js +1 -1
  268. package/dist/esm/nylas-view-thread.entry.js +2 -2
  269. package/dist/esm/nylas-web-elements.js +1 -1
  270. package/dist/{nylas-web-elements/register-component-e5afe237.js → esm/register-component-0462b27d.js} +2 -2
  271. package/dist/esm/{register-component-cf5c8420.js.map → register-component-0462b27d.js.map} +1 -1
  272. package/dist/esm/{register-component-cf5c8420.js → register-component-83e24412.js} +2 -2
  273. package/dist/esm/{register-component-e5afe237.js.map → register-component-83e24412.js.map} +1 -1
  274. package/dist/{nylas-web-elements/scheduler-config-store-8f2e658e.js → esm/scheduler-config-store-8ccc8dc7.js} +3 -4
  275. package/dist/esm/scheduler-config-store-8ccc8dc7.js.map +1 -0
  276. package/dist/esm/{scheduler-config-store-07d98279.js → scheduler-config-store-ec3b6190.js} +3 -4
  277. package/dist/esm/scheduler-config-store-ec3b6190.js.map +1 -0
  278. package/dist/esm/{scheduler-store-a175fc3e.js → scheduler-store-8ca9003d.js} +39 -7
  279. package/dist/esm/scheduler-store-8ca9003d.js.map +1 -0
  280. package/dist/esm/{scheduler-store-66c2168c.js → scheduler-store-e314bbe6.js} +39 -7
  281. package/dist/esm/scheduler-store-e314bbe6.js.map +1 -0
  282. package/dist/esm/time-period-selector.entry.js +1 -1
  283. package/dist/esm/{utils-73d8a928.js → utils-157014b4.js} +106 -3
  284. package/dist/esm/utils-157014b4.js.map +1 -0
  285. package/dist/esm/{utils-d6204242.js → utils-e6b73120.js} +106 -3
  286. package/dist/esm/utils-e6b73120.js.map +1 -0
  287. package/dist/nylas-web-elements/{index.es-2842f8c8.js → index.es-eb477d56.js} +3 -3
  288. package/dist/nylas-web-elements/index.es-eb477d56.js.map +1 -0
  289. package/dist/nylas-web-elements/index.esm.js +2 -2
  290. package/dist/{esm/mailbox-store-d48269de.js → nylas-web-elements/mailbox-store-9f819402.js} +3 -3
  291. package/dist/{esm/mailbox-store-d48269de.js.map → nylas-web-elements/mailbox-store-9f819402.js.map} +1 -1
  292. package/dist/nylas-web-elements/multi-select-dropdown.entry.js +1 -1
  293. package/dist/nylas-web-elements/nylas-additional-participants.entry.js +2 -2
  294. package/dist/{esm/nylas-api-request-b085294d.js → nylas-web-elements/nylas-api-request-ff2869d7.js} +2 -2
  295. package/dist/nylas-web-elements/{nylas-api-request-b085294d.js.map → nylas-api-request-ff2869d7.js.map} +1 -1
  296. package/dist/nylas-web-elements/nylas-availability-picker.entry.js +4 -3
  297. package/dist/nylas-web-elements/nylas-availability-picker.entry.js.map +1 -1
  298. package/dist/nylas-web-elements/nylas-booked-event-card.entry.js +21 -5
  299. package/dist/nylas-web-elements/nylas-booked-event-card.entry.js.map +1 -1
  300. package/dist/nylas-web-elements/nylas-booking-calendar-picker.entry.js +2 -2
  301. package/dist/nylas-web-elements/nylas-booking-form.entry.js +2 -2
  302. package/dist/nylas-web-elements/nylas-buffer-time.entry.js +4 -4
  303. package/dist/nylas-web-elements/nylas-buffer-time.entry.js.map +1 -1
  304. package/dist/nylas-web-elements/nylas-calendar-picker.entry.js +2 -2
  305. package/dist/nylas-web-elements/nylas-cancel-booking-form.entry.js +2 -2
  306. package/dist/nylas-web-elements/nylas-cancelled-event-card.entry.js +22 -5
  307. package/dist/nylas-web-elements/nylas-cancelled-event-card.entry.js.map +1 -1
  308. package/dist/nylas-web-elements/nylas-composer.entry.js +1 -1
  309. package/dist/nylas-web-elements/nylas-custom-booking-flow.entry.js +2 -2
  310. package/dist/nylas-web-elements/nylas-date-picker.entry.js +15 -3
  311. package/dist/nylas-web-elements/nylas-date-picker.entry.js.map +1 -1
  312. package/dist/nylas-web-elements/nylas-editor-tabs.entry.js +18 -12
  313. package/dist/nylas-web-elements/nylas-editor-tabs.entry.js.map +1 -1
  314. package/dist/nylas-web-elements/nylas-event-description.entry.js +2 -2
  315. package/dist/nylas-web-elements/nylas-event-duration.entry.js +2 -2
  316. package/dist/nylas-web-elements/nylas-event-info.entry.js +3 -3
  317. package/dist/nylas-web-elements/nylas-event-info.entry.js.map +1 -1
  318. package/dist/nylas-web-elements/nylas-event-limits.entry.js +3 -3
  319. package/dist/nylas-web-elements/nylas-event-limits.entry.js.map +1 -1
  320. package/dist/nylas-web-elements/nylas-event-title.entry.js +22 -11
  321. package/dist/nylas-web-elements/nylas-event-title.entry.js.map +1 -1
  322. package/dist/nylas-web-elements/nylas-form-card.entry.js +2 -2
  323. package/dist/nylas-web-elements/nylas-if-state.entry.js +2 -2
  324. package/dist/nylas-web-elements/nylas-limit-future-bookings.entry.js +3 -3
  325. package/dist/nylas-web-elements/nylas-limit-future-bookings.entry.js.map +1 -1
  326. package/dist/nylas-web-elements/nylas-list-configurations.entry.js +8 -6
  327. package/dist/nylas-web-elements/nylas-list-configurations.entry.js.map +1 -1
  328. package/dist/nylas-web-elements/nylas-list-folders.entry.js +2 -2
  329. package/dist/nylas-web-elements/nylas-list-threads.entry.js +2 -2
  330. package/dist/nylas-web-elements/nylas-locale-switch.entry.js +2 -2
  331. package/dist/nylas-web-elements/nylas-location-component.entry.js +3 -3
  332. package/dist/nylas-web-elements/nylas-location-component.entry.js.map +1 -1
  333. package/dist/nylas-web-elements/nylas-login.entry.js +2 -2
  334. package/dist/nylas-web-elements/nylas-mailbox-pagination.entry.js +2 -2
  335. package/dist/nylas-web-elements/nylas-mailbox-toolbar-button.entry.js +2 -2
  336. package/dist/nylas-web-elements/nylas-mailbox.entry.js +3 -3
  337. package/dist/nylas-web-elements/nylas-min-cancellation-notice.entry.js +3 -3
  338. package/dist/nylas-web-elements/nylas-min-cancellation-notice.entry.js.map +1 -1
  339. package/dist/nylas-web-elements/nylas-notification.entry.js +1 -1
  340. package/dist/nylas-web-elements/nylas-provider.entry.js +5 -5
  341. package/dist/nylas-web-elements/nylas-scheduler-editor.entry.js +8 -14
  342. package/dist/nylas-web-elements/nylas-scheduler-editor.entry.js.map +1 -1
  343. package/dist/nylas-web-elements/nylas-scheduling.entry.js +35 -12
  344. package/dist/nylas-web-elements/nylas-scheduling.entry.js.map +1 -1
  345. package/dist/nylas-web-elements/nylas-selected-event-card.entry.js +2 -2
  346. package/dist/nylas-web-elements/nylas-summarize-message-button.entry.js +2 -2
  347. package/dist/nylas-web-elements/nylas-threads-refresh.entry.js +2 -2
  348. package/dist/nylas-web-elements/nylas-threads-search.entry.js +2 -2
  349. package/dist/nylas-web-elements/nylas-time-window-picker.entry.js +1 -1
  350. package/dist/nylas-web-elements/nylas-timeslot-picker.entry.js +2 -2
  351. package/dist/nylas-web-elements/nylas-view-email.entry.js +1 -1
  352. package/dist/nylas-web-elements/nylas-view-thread.entry.js +2 -2
  353. package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
  354. package/dist/nylas-web-elements/{p-41dc0d93.js → p-01e86103.js} +2 -2
  355. package/dist/nylas-web-elements/p-01e86103.js.map +1 -0
  356. package/dist/nylas-web-elements/{p-ad64c2b8.entry.js → p-0d1caebd.entry.js} +2 -2
  357. package/dist/nylas-web-elements/{p-a628eaeb.js → p-0dabcb4d.js} +2 -2
  358. package/dist/nylas-web-elements/{p-42791515.entry.js → p-2b63efd8.entry.js} +2 -2
  359. package/dist/nylas-web-elements/p-30f17ef2.entry.js +2 -0
  360. package/dist/nylas-web-elements/p-30f17ef2.entry.js.map +1 -0
  361. package/dist/nylas-web-elements/{p-f154a362.entry.js → p-38675cc5.entry.js} +2 -2
  362. package/dist/nylas-web-elements/p-39aa2263.js +2 -0
  363. package/dist/nylas-web-elements/p-39aa2263.js.map +1 -0
  364. package/dist/nylas-web-elements/{p-cc674b3b.entry.js → p-44a0f658.entry.js} +3 -3
  365. package/dist/nylas-web-elements/{p-cc674b3b.entry.js.map → p-44a0f658.entry.js.map} +1 -1
  366. package/dist/nylas-web-elements/{p-75a8d077.entry.js → p-47fa06de.entry.js} +2 -2
  367. package/dist/nylas-web-elements/{p-df6d54c7.entry.js → p-48b205a2.entry.js} +2 -2
  368. package/dist/nylas-web-elements/{p-6110351b.entry.js → p-551871cb.entry.js} +2 -2
  369. package/dist/nylas-web-elements/{p-bbf9aff2.entry.js → p-61b25ea6.entry.js} +2 -2
  370. package/dist/nylas-web-elements/p-74492776.entry.js +2 -0
  371. package/dist/nylas-web-elements/p-74492776.entry.js.map +1 -0
  372. package/dist/nylas-web-elements/{p-1d25ca06.entry.js → p-75bc6ef8.entry.js} +2 -2
  373. package/dist/nylas-web-elements/p-76461af6.entry.js +2 -0
  374. package/dist/nylas-web-elements/p-76461af6.entry.js.map +1 -0
  375. package/dist/nylas-web-elements/{p-7c55dfa0.entry.js → p-78e7f732.entry.js} +2 -2
  376. package/dist/nylas-web-elements/{p-eaa9151b.js → p-8b53becf.js} +2 -2
  377. package/dist/nylas-web-elements/{p-e22aa0b0.js → p-8f88a748.js} +2 -2
  378. package/dist/nylas-web-elements/p-8ffc644d.entry.js +2 -0
  379. package/dist/nylas-web-elements/p-8ffc644d.entry.js.map +1 -0
  380. package/dist/nylas-web-elements/{p-665ef10b.entry.js → p-933c6d32.entry.js} +4 -4
  381. package/dist/nylas-web-elements/p-933c6d32.entry.js.map +1 -0
  382. package/dist/nylas-web-elements/{p-e03b2592.entry.js → p-a002b4cf.entry.js} +2 -2
  383. package/dist/nylas-web-elements/p-ab09a78d.js +2 -0
  384. package/dist/nylas-web-elements/p-ab09a78d.js.map +1 -0
  385. package/dist/nylas-web-elements/p-b1b3eb52.entry.js +2 -0
  386. package/dist/nylas-web-elements/p-b1b3eb52.entry.js.map +1 -0
  387. package/dist/nylas-web-elements/{p-f1f8f745.entry.js → p-b302fbb1.entry.js} +2 -2
  388. package/dist/nylas-web-elements/{p-80d6175c.entry.js → p-b77c316c.entry.js} +2 -2
  389. package/dist/nylas-web-elements/{p-33b940fb.entry.js → p-d3065401.entry.js} +2 -2
  390. package/dist/nylas-web-elements/{p-343b8684.entry.js → p-da732fb1.entry.js} +2 -2
  391. package/dist/nylas-web-elements/p-ee91a2a0.js +2 -0
  392. package/dist/nylas-web-elements/p-ee91a2a0.js.map +1 -0
  393. package/dist/{esm/register-component-e5afe237.js → nylas-web-elements/register-component-0462b27d.js} +2 -2
  394. package/dist/nylas-web-elements/{register-component-e5afe237.js.map → register-component-0462b27d.js.map} +1 -1
  395. package/dist/{esm/scheduler-config-store-8f2e658e.js → nylas-web-elements/scheduler-config-store-8ccc8dc7.js} +3 -4
  396. package/dist/nylas-web-elements/scheduler-config-store-8ccc8dc7.js.map +1 -0
  397. package/dist/nylas-web-elements/{scheduler-store-66c2168c.js → scheduler-store-e314bbe6.js} +39 -7
  398. package/dist/nylas-web-elements/scheduler-store-e314bbe6.js.map +1 -0
  399. package/dist/nylas-web-elements/time-period-selector.entry.js +1 -1
  400. package/dist/nylas-web-elements/{utils-73d8a928.js → utils-157014b4.js} +106 -3
  401. package/dist/nylas-web-elements/utils-157014b4.js.map +1 -0
  402. package/dist/types/common/types.d.ts +10 -0
  403. package/dist/types/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.d.ts +8 -1
  404. package/dist/types/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.d.ts +8 -2
  405. package/dist/types/components/scheduler/nylas-date-picker/nylas-date-picker.d.ts +3 -0
  406. package/dist/types/components/scheduler/nylas-scheduler/nylas-scheduling.d.ts +2 -0
  407. package/dist/types/components/scheduler-editor/nylas-availability-picker/nylas-availability-picker.d.ts +1 -1
  408. package/dist/types/components/scheduler-editor/nylas-editor-tabs/nylas-editor-tabs.d.ts +2 -1
  409. package/dist/types/components/scheduler-editor/nylas-event-title/nylas-event-title.d.ts +1 -0
  410. package/dist/types/components/scheduler-editor/nylas-scheduler-editor/nylas-scheduler-editor.d.ts +1 -2
  411. package/dist/types/components.d.ts +87 -16
  412. package/dist/types/connector/shared/api/scheduler.d.ts +4 -1
  413. package/dist/types/stores/scheduler-config-store.d.ts +0 -1
  414. package/dist/types/stores/scheduler-store.d.ts +11 -0
  415. package/dist/types/utils/utils.d.ts +5 -0
  416. package/package.json +3 -3
  417. package/dist/cjs/add-circle-icon_22.cjs.entry.js.map +0 -1
  418. package/dist/cjs/index.es-0a0f2d87.js.map +0 -1
  419. package/dist/cjs/index.es-b12b7df1.js.map +0 -1
  420. package/dist/cjs/scheduler-config-store-37690bf0.js.map +0 -1
  421. package/dist/cjs/scheduler-config-store-529c8d7e.js.map +0 -1
  422. package/dist/cjs/scheduler-store-0081970d.js.map +0 -1
  423. package/dist/cjs/scheduler-store-67dc1986.js.map +0 -1
  424. package/dist/cjs/utils-20663d54.js.map +0 -1
  425. package/dist/cjs/utils-2c7f0895.js.map +0 -1
  426. package/dist/components/nylas-custom-booking-flow2.js +0 -174
  427. package/dist/components/nylas-custom-booking-flow2.js.map +0 -1
  428. package/dist/esm/add-circle-icon_22.entry.js.map +0 -1
  429. package/dist/esm/index.es-2842f8c8.js.map +0 -1
  430. package/dist/esm/index.es-f57e612a.js.map +0 -1
  431. package/dist/esm/scheduler-config-store-07d98279.js.map +0 -1
  432. package/dist/esm/scheduler-config-store-8f2e658e.js.map +0 -1
  433. package/dist/esm/scheduler-store-66c2168c.js.map +0 -1
  434. package/dist/esm/scheduler-store-a175fc3e.js.map +0 -1
  435. package/dist/esm/utils-73d8a928.js.map +0 -1
  436. package/dist/esm/utils-d6204242.js.map +0 -1
  437. package/dist/nylas-web-elements/index.es-2842f8c8.js.map +0 -1
  438. package/dist/nylas-web-elements/p-1a91cce5.entry.js +0 -2
  439. package/dist/nylas-web-elements/p-1a91cce5.entry.js.map +0 -1
  440. package/dist/nylas-web-elements/p-22e5436c.js +0 -2
  441. package/dist/nylas-web-elements/p-22e5436c.js.map +0 -1
  442. package/dist/nylas-web-elements/p-2b636359.entry.js +0 -2
  443. package/dist/nylas-web-elements/p-2b636359.entry.js.map +0 -1
  444. package/dist/nylas-web-elements/p-30784693.entry.js +0 -2
  445. package/dist/nylas-web-elements/p-30784693.entry.js.map +0 -1
  446. package/dist/nylas-web-elements/p-3909ec3f.entry.js +0 -2
  447. package/dist/nylas-web-elements/p-3909ec3f.entry.js.map +0 -1
  448. package/dist/nylas-web-elements/p-41dc0d93.js.map +0 -1
  449. package/dist/nylas-web-elements/p-665ef10b.entry.js.map +0 -1
  450. package/dist/nylas-web-elements/p-9ea458c3.js +0 -2
  451. package/dist/nylas-web-elements/p-9ea458c3.js.map +0 -1
  452. package/dist/nylas-web-elements/p-db15d382.js +0 -2
  453. package/dist/nylas-web-elements/p-db15d382.js.map +0 -1
  454. package/dist/nylas-web-elements/scheduler-config-store-8f2e658e.js.map +0 -1
  455. package/dist/nylas-web-elements/scheduler-store-66c2168c.js.map +0 -1
  456. package/dist/nylas-web-elements/utils-73d8a928.js.map +0 -1
  457. /package/dist/nylas-web-elements/{p-ad64c2b8.entry.js.map → p-0d1caebd.entry.js.map} +0 -0
  458. /package/dist/nylas-web-elements/{p-a628eaeb.js.map → p-0dabcb4d.js.map} +0 -0
  459. /package/dist/nylas-web-elements/{p-42791515.entry.js.map → p-2b63efd8.entry.js.map} +0 -0
  460. /package/dist/nylas-web-elements/{p-f154a362.entry.js.map → p-38675cc5.entry.js.map} +0 -0
  461. /package/dist/nylas-web-elements/{p-75a8d077.entry.js.map → p-47fa06de.entry.js.map} +0 -0
  462. /package/dist/nylas-web-elements/{p-df6d54c7.entry.js.map → p-48b205a2.entry.js.map} +0 -0
  463. /package/dist/nylas-web-elements/{p-6110351b.entry.js.map → p-551871cb.entry.js.map} +0 -0
  464. /package/dist/nylas-web-elements/{p-bbf9aff2.entry.js.map → p-61b25ea6.entry.js.map} +0 -0
  465. /package/dist/nylas-web-elements/{p-1d25ca06.entry.js.map → p-75bc6ef8.entry.js.map} +0 -0
  466. /package/dist/nylas-web-elements/{p-7c55dfa0.entry.js.map → p-78e7f732.entry.js.map} +0 -0
  467. /package/dist/nylas-web-elements/{p-eaa9151b.js.map → p-8b53becf.js.map} +0 -0
  468. /package/dist/nylas-web-elements/{p-e22aa0b0.js.map → p-8f88a748.js.map} +0 -0
  469. /package/dist/nylas-web-elements/{p-e03b2592.entry.js.map → p-a002b4cf.entry.js.map} +0 -0
  470. /package/dist/nylas-web-elements/{p-f1f8f745.entry.js.map → p-b302fbb1.entry.js.map} +0 -0
  471. /package/dist/nylas-web-elements/{p-80d6175c.entry.js.map → p-b77c316c.entry.js.map} +0 -0
  472. /package/dist/nylas-web-elements/{p-33b940fb.entry.js.map → p-d3065401.entry.js.map} +0 -0
  473. /package/dist/nylas-web-elements/{p-343b8684.entry.js.map → p-da732fb1.entry.js.map} +0 -0
@@ -1,10 +1,10 @@
1
- import{h,r as registerInstance,c as createEvent,H as Host,a as getElement}from"./p-68c2fadf.js";import{X as Xr,g as global,N as NylasBaseProvider}from"./p-9ea458c3.js";import{N as NylasIdentityRequestWrapper}from"./p-a628eaeb.js";import{d as dataResponse,a as debug}from"./p-41dc0d93.js";import{C as CreateNylasSchedulerConfigStore}from"./p-db15d382.js";import{c as commonjsGlobal}from"./p-cb65c223.js";import"./p-cabb2e68.js";class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const[e,t]=await this.nylasApiRequest.request({method:"GET",path:`calendars`});if(t){return dataResponse(null,{message:"Error fetching calendars: "+t.message})}if(Xr(e)){return dataResponse(null,{message:"Error fetching calendars: "+e.error?.message})}this.nylasSchedulerConfigStore.state.calendars=e.data;return dataResponse(e.data)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"})}if(!t){const t=this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e));if(t){this.nylasSchedulerConfigStore.state.selectedConfiguration=t;return dataResponse(t)}}const[r,n]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(n){return dataResponse(null,{message:"Error fetching configuration: "+n.message})}if(Xr(r)){return dataResponse(null,{message:"Error fetching configuration: "+r.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=r.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((t=>t.id===e?r.data:t))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,r.data]}return dataResponse(r.data)}async getConfigurations(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const[e,t]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations`});if(t){return dataResponse(null,{message:"Error fetching configurations: "+t.message})}if(Xr(e)){return dataResponse(null,{message:"Error fetching configurations: "+e.error?.message})}this.nylasSchedulerConfigStore.state.configurations=e.data;return dataResponse(e.data)}async createConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"})}e.requires_session_auth=this.nylasSchedulerConfigStore.state.defaultRequiresSessionAuth;const[t,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations`,body:e});if(r){return dataResponse(null,{message:"Error creating configuration: "+r.message})}if(Xr(t)){return dataResponse(null,{message:"Error creating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data];return dataResponse(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"})}const[t,r]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});if(r){return dataResponse(null,{message:"Error updating configuration: "+r.message})}if(Xr(t)){return dataResponse(null,{message:"Error updating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e.id))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((r=>r.id===e.id?t.data:r))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data]}return dataResponse(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"})}const[t,r]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});if(r){return dataResponse(null,{message:"Error deleting configuration: "+r.message})}if(Xr(t)){return dataResponse(null,{message:"Error deleting configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter((t=>t.id!==e));if(this.nylasSchedulerConfigStore.state.selectedConfiguration?.id===e){this.nylasSchedulerConfigStore.resetSelectedConfiguration()}return dataResponse(t.data)}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){debug("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){debug("NylasSchedulerConfigConnector logout");this.resetStores()}}var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var inited=false;function init(){inited=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t<r;++t){lookup[t]=e[t];revLookup[e.charCodeAt(t)]=t}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63}function toByteArray(e){if(!inited){init()}var t,r,n,i,s,o;var a=e.length;if(a%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}s=e[a-2]==="="?2:e[a-1]==="="?1:0;o=new Arr(a*3/4-s);n=s>0?a-4:a;var f=0;for(t=0,r=0;t<n;t+=4,r+=3){i=revLookup[e.charCodeAt(t)]<<18|revLookup[e.charCodeAt(t+1)]<<12|revLookup[e.charCodeAt(t+2)]<<6|revLookup[e.charCodeAt(t+3)];o[f++]=i>>16&255;o[f++]=i>>8&255;o[f++]=i&255}if(s===2){i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4;o[f++]=i&255}else if(s===1){i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2;o[f++]=i>>8&255;o[f++]=i&255}return o}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){var n;var i=[];for(var s=t;s<r;s+=3){n=(e[s]<<16)+(e[s+1]<<8)+e[s+2];i.push(tripletToBase64(n))}return i.join("")}function fromByteArray(e){if(!inited){init()}var t;var r=e.length;var n=r%3;var i="";var s=[];var o=16383;for(var a=0,f=r-n;a<f;a+=o){s.push(encodeChunk(e,a,a+o>f?f:a+o))}if(n===1){t=e[r-1];i+=lookup[t>>2];i+=lookup[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=lookup[t>>10];i+=lookup[t>>4&63];i+=lookup[t<<2&63];i+="="}s.push(i);return s.join("")}function read(e,t,r,n,i){var s,o;var a=i*8-n-1;var f=(1<<a)-1;var u=f>>1;var c=-7;var h=r?i-1:0;var l=r?-1:1;var d=e[t+h];h+=l;s=d&(1<<-c)-1;d>>=-c;c+=a;for(;c>0;s=s*256+e[t+h],h+=l,c-=8){}o=s&(1<<-c)-1;s>>=-c;c+=n;for(;c>0;o=o*256+e[t+h],h+=l,c-=8){}if(s===0){s=1-u}else if(s===f){return o?NaN:(d?-1:1)*Infinity}else{o=o+Math.pow(2,n);s=s-u}return(d?-1:1)*o*Math.pow(2,s-n)}function write(e,t,r,n,i,s){var o,a,f;var u=s*8-i-1;var c=(1<<u)-1;var h=c>>1;var l=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var d=n?0:s-1;var y=n?1:-1;var p=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){a=isNaN(t)?1:0;o=c}else{o=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-o))<1){o--;f*=2}if(o+h>=1){t+=l/f}else{t+=l*Math.pow(2,1-h)}if(t*f>=2){o++;f/=2}if(o+h>=c){a=0;o=c}else if(o+h>=1){a=(t*f-1)*Math.pow(2,i);o=o+h}else{a=t*Math.pow(2,h-1)*Math.pow(2,i);o=0}}for(;i>=8;e[r+d]=a&255,d+=y,a/=256,i-=8){}o=o<<i|a;u+=i;for(;u>0;e[r+d]=o&255,d+=y,o/=256,u-=8){}e[r+d-y]|=p*128}var toString={}.toString;var isArray=Array.isArray||function(e){return toString.call(e)=="[object Array]"};
1
+ import{h,r as registerInstance,c as createEvent,H as Host,a as getElement}from"./p-68c2fadf.js";import{X as Xr,g as global,N as NylasBaseProvider}from"./p-39aa2263.js";import{N as NylasIdentityRequestWrapper}from"./p-0dabcb4d.js";import{d as dataResponse,a as debug}from"./p-01e86103.js";import{C as CreateNylasSchedulerConfigStore}from"./p-ee91a2a0.js";import{c as commonjsGlobal}from"./p-cb65c223.js";import"./p-cabb2e68.js";class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const[e,t]=await this.nylasApiRequest.request({method:"GET",path:`calendars`});if(t){return dataResponse(null,{message:"Error fetching calendars: "+t.message})}if(Xr(e)){return dataResponse(null,{message:"Error fetching calendars: "+e.error?.message})}this.nylasSchedulerConfigStore.state.calendars=e.data;return dataResponse(e.data)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"})}if(!t){const t=this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e));if(t){this.nylasSchedulerConfigStore.state.selectedConfiguration=t;return dataResponse(t)}}const[r,n]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(n){return dataResponse(null,{message:"Error fetching configuration: "+n.message})}if(Xr(r)){return dataResponse(null,{message:"Error fetching configuration: "+r.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=r.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((t=>t.id===e?r.data:t))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,r.data]}return dataResponse(r.data)}async getConfigurations(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const[e,t]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations`});if(t){return dataResponse(null,{message:"Error fetching configurations: "+t.message})}if(Xr(e)){return dataResponse(null,{message:"Error fetching configurations: "+e.error?.message})}this.nylasSchedulerConfigStore.state.configurations=e.data;return dataResponse(e.data)}async createConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"})}const[t,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations`,body:e});if(r){return dataResponse(null,{message:"Error creating configuration: "+r.message})}if(Xr(t)){return dataResponse(null,{message:"Error creating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data];return dataResponse(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"})}const[t,r]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});if(r){return dataResponse(null,{message:"Error updating configuration: "+r.message})}if(Xr(t)){return dataResponse(null,{message:"Error updating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e.id))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((r=>r.id===e.id?t.data:r))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data]}return dataResponse(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"})}const[t,r]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});if(r){return dataResponse(null,{message:"Error deleting configuration: "+r.message})}if(Xr(t)){return dataResponse(null,{message:"Error deleting configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter((t=>t.id!==e));if(this.nylasSchedulerConfigStore.state.selectedConfiguration?.id===e){this.nylasSchedulerConfigStore.resetSelectedConfiguration()}return dataResponse(t.data)}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){debug("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){debug("NylasSchedulerConfigConnector logout");this.resetStores()}}var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var inited=false;function init(){inited=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t<r;++t){lookup[t]=e[t];revLookup[e.charCodeAt(t)]=t}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63}function toByteArray(e){if(!inited){init()}var t,r,n,i,s,o;var a=e.length;if(a%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}s=e[a-2]==="="?2:e[a-1]==="="?1:0;o=new Arr(a*3/4-s);n=s>0?a-4:a;var f=0;for(t=0,r=0;t<n;t+=4,r+=3){i=revLookup[e.charCodeAt(t)]<<18|revLookup[e.charCodeAt(t+1)]<<12|revLookup[e.charCodeAt(t+2)]<<6|revLookup[e.charCodeAt(t+3)];o[f++]=i>>16&255;o[f++]=i>>8&255;o[f++]=i&255}if(s===2){i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4;o[f++]=i&255}else if(s===1){i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2;o[f++]=i>>8&255;o[f++]=i&255}return o}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){var n;var i=[];for(var s=t;s<r;s+=3){n=(e[s]<<16)+(e[s+1]<<8)+e[s+2];i.push(tripletToBase64(n))}return i.join("")}function fromByteArray(e){if(!inited){init()}var t;var r=e.length;var n=r%3;var i="";var s=[];var o=16383;for(var a=0,f=r-n;a<f;a+=o){s.push(encodeChunk(e,a,a+o>f?f:a+o))}if(n===1){t=e[r-1];i+=lookup[t>>2];i+=lookup[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=lookup[t>>10];i+=lookup[t>>4&63];i+=lookup[t<<2&63];i+="="}s.push(i);return s.join("")}function read(e,t,r,n,i){var s,o;var a=i*8-n-1;var f=(1<<a)-1;var u=f>>1;var c=-7;var h=r?i-1:0;var l=r?-1:1;var d=e[t+h];h+=l;s=d&(1<<-c)-1;d>>=-c;c+=a;for(;c>0;s=s*256+e[t+h],h+=l,c-=8){}o=s&(1<<-c)-1;s>>=-c;c+=n;for(;c>0;o=o*256+e[t+h],h+=l,c-=8){}if(s===0){s=1-u}else if(s===f){return o?NaN:(d?-1:1)*Infinity}else{o=o+Math.pow(2,n);s=s-u}return(d?-1:1)*o*Math.pow(2,s-n)}function write(e,t,r,n,i,s){var o,a,f;var u=s*8-i-1;var c=(1<<u)-1;var h=c>>1;var l=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var d=n?0:s-1;var y=n?1:-1;var p=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){a=isNaN(t)?1:0;o=c}else{o=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-o))<1){o--;f*=2}if(o+h>=1){t+=l/f}else{t+=l*Math.pow(2,1-h)}if(t*f>=2){o++;f/=2}if(o+h>=c){a=0;o=c}else if(o+h>=1){a=(t*f-1)*Math.pow(2,i);o=o+h}else{a=t*Math.pow(2,h-1)*Math.pow(2,i);o=0}}for(;i>=8;e[r+d]=a&255,d+=y,a/=256,i-=8){}o=o<<i|a;u+=i;for(;u>0;e[r+d]=o&255,d+=y,o/=256,u-=8){}e[r+d-y]|=p*128}var toString={}.toString;var isArray=Array.isArray||function(e){return toString.call(e)=="[object Array]"};
2
2
  /*!
3
3
  * The buffer module from node.js, for the browser.
4
4
  *
5
5
  * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
6
6
  * @license MIT
7
- */var INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:true;function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()<t){throw new RangeError("Invalid typed array length")}if(Buffer.TYPED_ARRAY_SUPPORT){e=new Uint8Array(t);e.__proto__=Buffer.prototype}else{if(e===null){e=new Buffer(t)}e.length=t}return e}function Buffer(e,t,r){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer)){return new Buffer(e,t,r)}if(typeof e==="number"){if(typeof t==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return allocUnsafe(this,e)}return from(this,e,t,r)}Buffer.poolSize=8192;Buffer._augment=function(e){e.__proto__=Buffer.prototype;return e};function from(e,t,r,n){if(typeof t==="number"){throw new TypeError('"value" argument must not be a number')}if(typeof ArrayBuffer!=="undefined"&&t instanceof ArrayBuffer){return fromArrayBuffer(e,t,r,n)}if(typeof t==="string"){return fromString(e,t,r)}return fromObject(e,t)}Buffer.from=function(e,t,r){return from(null,e,t,r)};if(Buffer.TYPED_ARRAY_SUPPORT){Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array}function assertSize(e){if(typeof e!=="number"){throw new TypeError('"size" argument must be a number')}else if(e<0){throw new RangeError('"size" argument must not be negative')}}function alloc(e,t,r,n){assertSize(t);if(t<=0){return createBuffer(e,t)}if(r!==undefined){return typeof n==="string"?createBuffer(e,t).fill(r,n):createBuffer(e,t).fill(r)}return createBuffer(e,t)}Buffer.alloc=function(e,t,r){return alloc(null,e,t,r)};function allocUnsafe(e,t){assertSize(t);e=createBuffer(e,t<0?0:checked(t)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;++r){e[r]=0}}return e}Buffer.allocUnsafe=function(e){return allocUnsafe(null,e)};Buffer.allocUnsafeSlow=function(e){return allocUnsafe(null,e)};function fromString(e,t,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}var n=byteLength(t,r)|0;e=createBuffer(e,n);var i=e.write(t,r);if(i!==n){e=e.slice(0,i)}return e}function fromArrayLike(e,t){var r=t.length<0?0:checked(t.length)|0;e=createBuffer(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function fromArrayBuffer(e,t,r,n){if(r<0||t.byteLength<r){throw new RangeError("'offset' is out of bounds")}if(t.byteLength<r+(n||0)){throw new RangeError("'length' is out of bounds")}if(r===undefined&&n===undefined){t=new Uint8Array(t)}else if(n===undefined){t=new Uint8Array(t,r)}else{t=new Uint8Array(t,r,n)}if(Buffer.TYPED_ARRAY_SUPPORT){e=t;e.__proto__=Buffer.prototype}else{e=fromArrayLike(e,t)}return e}function fromObject(e,t){if(internalIsBuffer(t)){var r=checked(t.length)|0;e=createBuffer(e,r);if(e.length===0){return e}t.copy(e,0,0,r);return e}if(t){if(typeof ArrayBuffer!=="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t){if(typeof t.length!=="number"||isnan(t.length)){return createBuffer(e,0)}return fromArrayLike(e,t)}if(t.type==="Buffer"&&isArray(t.data)){return fromArrayLike(e,t.data)}}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return e|0}Buffer.isBuffer=isBuffer;function internalIsBuffer(e){return!!(e!=null&&e._isBuffer)}Buffer.compare=function e(t,r){if(!internalIsBuffer(t)||!internalIsBuffer(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var s=0,o=Math.min(n,i);s<o;++s){if(t[s]!==r[s]){n=t[s];i=r[s];break}}if(n<i)return-1;if(i<n)return 1;return 0};Buffer.isEncoding=function e(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function e(t,r){if(!isArray(t)){throw new TypeError('"list" argument must be an Array of Buffers')}if(t.length===0){return Buffer.alloc(0)}var n;if(r===undefined){r=0;for(n=0;n<t.length;++n){r+=t[n].length}}var i=Buffer.allocUnsafe(r);var s=0;for(n=0;n<t.length;++n){var o=t[n];if(!internalIsBuffer(o)){throw new TypeError('"list" argument must be an Array of Buffers')}o.copy(i,s);s+=o.length}return i};function byteLength(e,t){if(internalIsBuffer(e)){return e.length}if(typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)){return e.byteLength}if(typeof e!=="string"){e=""+e}var r=e.length;if(r===0)return 0;var n=false;for(;;){switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case undefined:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase();n=true}}}Buffer.byteLength=byteLength;function slowToString(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}Buffer.prototype._isBuffer=true;function swap(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}Buffer.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r<t;r+=2){swap(this,r,r+1)}return this};Buffer.prototype.swap32=function e(){var t=this.length;if(t%4!==0){throw new RangeError("Buffer size must be a multiple of 32-bits")}for(var r=0;r<t;r+=4){swap(this,r,r+3);swap(this,r+1,r+2)}return this};Buffer.prototype.swap64=function e(){var t=this.length;if(t%8!==0){throw new RangeError("Buffer size must be a multiple of 64-bits")}for(var r=0;r<t;r+=8){swap(this,r,r+7);swap(this,r+1,r+6);swap(this,r+2,r+5);swap(this,r+3,r+4)}return this};Buffer.prototype.toString=function e(){var t=this.length|0;if(t===0)return"";if(arguments.length===0)return utf8Slice(this,0,t);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function e(t){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");if(this===t)return true;return Buffer.compare(this,t)===0};Buffer.prototype.inspect=function e(){var t="";var r=INSPECT_MAX_BYTES;if(this.length>0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return"<Buffer "+t+">"};Buffer.prototype.compare=function e(t,r,n,i,s){if(!internalIsBuffer(t)){throw new TypeError("Argument must be a Buffer")}if(r===undefined){r=0}if(n===undefined){n=t?t.length:0}if(i===undefined){i=0}if(s===undefined){s=this.length}if(r<0||n>t.length||i<0||s>this.length){throw new RangeError("out of range index")}if(i>=s&&r>=n){return 0}if(i>=s){return-1}if(r>=n){return 1}r>>>=0;n>>>=0;i>>>=0;s>>>=0;if(this===t)return 0;var o=s-i;var a=n-r;var f=Math.min(o,a);var u=this.slice(i,s);var c=t.slice(r,n);for(var h=0;h<f;++h){if(u[h]!==c[h]){o=u[h];a=c[h];break}}if(o<a)return-1;if(a<o)return 1;return 0};function bidirectionalIndexOf(e,t,r,n,i){if(e.length===0)return-1;if(typeof r==="string"){n=r;r=0}else if(r>2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=Buffer.from(t,n)}if(internalIsBuffer(t)){if(t.length===0){return-1}return arrayIndexOf(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return arrayIndexOf(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,i){var s=1;var o=e.length;var a=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}s=2;o/=2;a/=2;r/=2}}function f(e,t){if(s===1){return e[t]}else{return e.readUInt16BE(t*s)}}var u;if(i){var c=-1;for(u=r;u<o;u++){if(f(e,u)===f(t,c===-1?0:u-c)){if(c===-1)c=u;if(u-c+1===a)return c*s}else{if(c!==-1)u-=u-c;c=-1}}}else{if(r+a>o)r=o-a;for(u=r;u>=0;u--){var h=true;for(var l=0;l<a;l++){if(f(e,u+l)!==f(t,l)){h=false;break}}if(h)return u}}return-1}Buffer.prototype.includes=function e(t,r,n){return this.indexOf(t,r,n)!==-1};Buffer.prototype.indexOf=function e(t,r,n){return bidirectionalIndexOf(this,t,r,n,true)};Buffer.prototype.lastIndexOf=function e(t,r,n){return bidirectionalIndexOf(this,t,r,n,false)};function hexWrite(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");if(n>s/2){n=s/2}for(var o=0;o<n;++o){var a=parseInt(t.substr(o*2,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function utf8Write(e,t,r,n){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,n)}function asciiWrite(e,t,r,n){return blitBuffer(asciiToBytes(t),e,r,n)}function latin1Write(e,t,r,n){return asciiWrite(e,t,r,n)}function base64Write(e,t,r,n){return blitBuffer(base64ToBytes(t),e,r,n)}function ucs2Write(e,t,r,n){return blitBuffer(utf16leToBytes(t,e.length-r),e,r,n)}Buffer.prototype.write=function e(t,r,n,i){if(r===undefined){i="utf8";n=this.length;r=0}else if(n===undefined&&typeof r==="string"){i=r;n=this.length;r=0}else if(isFinite(r)){r=r|0;if(isFinite(n)){n=n|0;if(i===undefined)i="utf8"}else{i=n;n=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var s=this.length-r;if(n===undefined||n>s)n=s;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var o=false;for(;;){switch(i){case"hex":return hexWrite(this,t,r,n);case"utf8":case"utf-8":return utf8Write(this,t,r,n);case"ascii":return asciiWrite(this,t,r,n);case"latin1":case"binary":return latin1Write(this,t,r,n);case"base64":return base64Write(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();o=true}}};Buffer.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,r){if(t===0&&r===e.length){return fromByteArray(e)}else{return fromByteArray(e.slice(t,r))}}function utf8Slice(e,t,r){r=Math.min(e.length,r);var n=[];var i=t;while(i<r){var s=e[i];var o=null;var a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var f,u,c,h;switch(a){case 1:if(s<128){o=s}break;case 2:f=e[i+1];if((f&192)===128){h=(s&31)<<6|f&63;if(h>127){o=h}}break;case 3:f=e[i+1];u=e[i+2];if((f&192)===128&&(u&192)===128){h=(s&15)<<12|(f&63)<<6|u&63;if(h>2047&&(h<55296||h>57343)){o=h}}break;case 4:f=e[i+1];u=e[i+2];c=e[i+3];if((f&192)===128&&(u&192)===128&&(c&192)===128){h=(s&15)<<18|(f&63)<<12|(u&63)<<6|c&63;if(h>65535&&h<1114112){o=h}}}}if(o===null){o=65533;a=1}else if(o>65535){o-=65536;n.push(o>>>10&1023|55296);o=56320|o&1023}n.push(o);i+=a}return decodeCodePointsArray(n)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(n<t){r+=String.fromCharCode.apply(String,e.slice(n,n+=MAX_ARGUMENTS_LENGTH))}return r}function asciiSlice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i){n+=String.fromCharCode(e[i]&127)}return n}function latin1Slice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i){n+=String.fromCharCode(e[i])}return n}function hexSlice(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var s=t;s<r;++s){i+=toHex(e[s])}return i}function utf16leSlice(e,t,r){var n=e.slice(t,r);var i="";for(var s=0;s<n.length;s+=2){i+=String.fromCharCode(n[s]+n[s+1]*256)}return i}Buffer.prototype.slice=function e(t,r){var n=this.length;t=~~t;r=r===undefined?n:~~r;if(t<0){t+=n;if(t<0)t=0}else if(t>n){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(r<t)r=t;var i;if(Buffer.TYPED_ARRAY_SUPPORT){i=this.subarray(t,r);i.__proto__=Buffer.prototype}else{var s=r-t;i=new Buffer(s,undefined);for(var o=0;o<s;++o){i[o]=this[o+t]}}return i};function checkOffset(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var s=1;var o=0;while(++o<r&&(s*=256)){i+=this[t+o]*s}return i};Buffer.prototype.readUIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n){checkOffset(t,r,this.length)}var i=this[t+--r];var s=1;while(r>0&&(s*=256)){i+=this[t+--r]*s}return i};Buffer.prototype.readUInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);return this[t]};Buffer.prototype.readUInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]|this[t+1]<<8};Buffer.prototype.readUInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]<<8|this[t+1]};Buffer.prototype.readUInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};Buffer.prototype.readUInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};Buffer.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var s=1;var o=0;while(++o<r&&(s*=256)){i+=this[t+o]*s}s*=128;if(i>=s)i-=Math.pow(2,8*r);return i};Buffer.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=r;var s=1;var o=this[t+--i];while(i>0&&(s*=256)){o+=this[t+--i]*s}s*=128;if(o>=s)o-=Math.pow(2,8*r);return o};Buffer.prototype.readInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};Buffer.prototype.readInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};Buffer.prototype.readInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};Buffer.prototype.readInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};Buffer.prototype.readInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};Buffer.prototype.readFloatLE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read(this,t,true,23,4)};Buffer.prototype.readFloatBE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read(this,t,false,23,4)};Buffer.prototype.readDoubleLE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read(this,t,true,52,8)};Buffer.prototype.readDoubleBE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read(this,t,false,52,8)};function checkInt(e,t,r,n,i,s){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var s=Math.pow(2,8*n)-1;checkInt(this,t,r,n,s,0)}var o=1;var a=0;this[r]=t&255;while(++a<n&&(o*=256)){this[r+a]=t/o&255}return r+n};Buffer.prototype.writeUIntBE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var s=Math.pow(2,8*n)-1;checkInt(this,t,r,n,s,0)}var o=n-1;var a=1;this[r+o]=t&255;while(--o>=0&&(a*=256)){this[r+o]=t/a&255}return r+n};Buffer.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function objectWriteUInt16(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,s=Math.min(e.length-r,2);i<s;++i){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};function objectWriteUInt32(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,s=Math.min(e.length-r,4);i<s;++i){e[r+i]=t>>>(n?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};Buffer.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var s=Math.pow(2,8*n-1);checkInt(this,t,r,n,s-1,-s)}var o=0;var a=1;var f=0;this[r]=t&255;while(++o<n&&(a*=256)){if(t<0&&f===0&&this[r+o-1]!==0){f=1}this[r+o]=(t/a>>0)-f&255}return r+n};Buffer.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var s=Math.pow(2,8*n-1);checkInt(this,t,r,n,s-1,-s)}var o=n-1;var a=1;var f=0;this[r+o]=t&255;while(--o>=0&&(a*=256)){if(t<0&&f===0&&this[r+o+1]!==0){f=1}this[r+o]=(t/a>>0)-f&255}return r+n};Buffer.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};Buffer.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};Buffer.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};function checkIEEE754(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,4)}write(e,t,r,n,23,4);return r+4}Buffer.prototype.writeFloatLE=function e(t,r,n){return writeFloat(this,t,r,true,n)};Buffer.prototype.writeFloatBE=function e(t,r,n){return writeFloat(this,t,r,false,n)};function writeDouble(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,8)}write(e,t,r,n,52,8);return r+8}Buffer.prototype.writeDoubleLE=function e(t,r,n){return writeDouble(this,t,r,true,n)};Buffer.prototype.writeDoubleBE=function e(t,r,n){return writeDouble(this,t,r,false,n)};Buffer.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i<n)i=n;if(i===n)return 0;if(t.length===0||this.length===0)return 0;if(r<0){throw new RangeError("targetStart out of bounds")}if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r<i-n){i=t.length-r+n}var s=i-n;var o;if(this===t&&n<r&&r<i){for(o=s-1;o>=0;--o){t[o+r]=this[o+n]}}else if(s<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(o=0;o<s;++o){t[o+r]=this[o+n]}}else{Uint8Array.prototype.set.call(t,this.subarray(n,n+s),r)}return s};Buffer.prototype.fill=function e(t,r,n,i){if(typeof t==="string"){if(typeof r==="string"){i=r;r=0;n=this.length}else if(typeof n==="string"){i=n;n=this.length}if(t.length===1){var s=t.charCodeAt(0);if(s<256){t=s}}if(i!==undefined&&typeof i!=="string"){throw new TypeError("encoding must be a string")}if(typeof i==="string"&&!Buffer.isEncoding(i)){throw new TypeError("Unknown encoding: "+i)}}else if(typeof t==="number"){t=t&255}if(r<0||this.length<r||this.length<n){throw new RangeError("Out of range index")}if(n<=r){return this}r=r>>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var o;if(typeof t==="number"){for(o=r;o<n;++o){this[o]=t}}else{var a=internalIsBuffer(t)?t:utf8ToBytes(new Buffer(t,i).toString());var f=a.length;for(o=0;o<n-r;++o){this[o+r]=a[o%f]}}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(e){e=stringtrim(e).replace(INVALID_BASE64_RE,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function stringtrim(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function toHex(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function utf8ToBytes(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var s=[];for(var o=0;o<n;++o){r=e.charCodeAt(o);if(r>55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)s.push(239,191,189);continue}else if(o+1===n){if((t-=3)>-1)s.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)s.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)s.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return s}function asciiToBytes(e){var t=[];for(var r=0;r<e.length;++r){t.push(e.charCodeAt(r)&255)}return t}function utf16leToBytes(e,t){var r,n,i;var s=[];for(var o=0;o<e.length;++o){if((t-=2)<0)break;r=e.charCodeAt(o);n=r>>8;i=r%256;s.push(i);s.push(n)}return s}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var i=0;i<n;++i){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function isnan(e){return e!==e}function isBuffer(e){return e!=null&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&isFastBuffer(e.slice(0,0))}class LocalStorage{get(e){return new Promise((t=>{const r=window.localStorage.getItem(e);if(!r){t(null)}else{t(JSON.parse(r))}}))}async remove(e){window.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){window.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const PKCE_KEY="pkce";const GRANT_KEY="grant";const USER_KEY="user";class Storage{Storage=new LocalStorage;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=Buffer.from(e);this.Storage.set(PKCE_KEY,t.toString("base64"))}async getPKCE(){try{const e=await this.Storage.get(PKCE_KEY);if(e){const t=Buffer.from(e,"base64");return t.toString("utf8")}}catch(e){return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(e,t=false){const{grant_id:r}=e;this.Storage.set(`${GRANT_KEY}${t?"-"+r:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${GRANT_KEY}${t?"-"+e:""}`)}async getGrant(e,t=false){const r=await this.Storage.get(`${GRANT_KEY}${t?"-"+e:""}`);if(r){return r}return null}async setUserToken(e){const t=await this.getUserTokens();if(t){const r=t.find((t=>t.sub===e.sub));if(!r){const r=[...t,e];this.Storage.set(USER_KEY,r)}else{const r=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(USER_KEY,r)}}else{this.Storage.set(USER_KEY,[e])}}async getUserToken(e=""){const t=await this.Storage.get(USER_KEY);if(t){if(e===""){return t[0]}const r=t.find((t=>t.sub===e));return r}return null}async getUserTokens(){const e=await this.Storage.get(USER_KEY);if(e){return e}return null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(e){const t=await this.getUserTokens();const r=t?.filter((t=>t.sub!==e));this.Storage.set(USER_KEY,r)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class IndexedDBStorage{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((r,n)=>{t.openDatabase().then((function(i){const s=i.transaction(t.storeName,"readwrite");const o=s.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{r(a.result)};a.onerror=()=>{n(a.error)};s.oncomplete=()=>{i.close()}}))}))}async remove(e){const t=this;return new Promise(((r,n)=>{const i=indexedDB.open(this.databaseName);i.onupgradeneeded=function(e){const r=e.target.result;r.createObjectStore(t.storeName)};i.onerror=()=>{n(i.error)};i.onsuccess=t=>{const i=t.target.result;const s=i.transaction(this.storeName,"readwrite");const o=s.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{r(null)};a.onerror=()=>{n(a.error)};s.oncomplete=()=>{i.close()}}}))}set(e,t){return new Promise(((r,n)=>{const i=indexedDB.open(this.databaseName);i.onerror=()=>{n(i.error)};i.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};i.onsuccess=i=>{const s=i.target.result;const o=s.transaction(this.storeName,"readwrite");const a=o.objectStore(this.storeName);const f=a.put(t,e);f.onsuccess=()=>{r(t)};f.onerror=()=>{n(f.error)};o.oncomplete=()=>{s.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,r){const n=indexedDB.open(e.databaseName,2);n.onupgradeneeded=function(t){const r=t.target.result;r.createObjectStore(e.storeName)};n.onsuccess=function(e){t(e.target.result)};n.onerror=function(e){r(e.error)}}))}}var process=commonjsGlobal.process;var sha256={exports:{}};(function(module){(function(){var ERROR="input is invalid type";var WINDOW=typeof window==="object";var root=WINDOW?window:{};if(root.JS_SHA256_NO_WINDOW){WINDOW=false}var WEB_WORKER=!WINDOW&&typeof self==="object";var NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process==="object"&&process.versions&&process.versions.node;if(NODE_JS){root=commonjsGlobal}else if(WEB_WORKER){root=self}var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&"object"==="object"&&module.exports;var ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer!=="undefined";var HEX_CHARS="0123456789abcdef".split("");var EXTRA=[-2147483648,8388608,32768,128];var SHIFT=[24,16,8,0];var K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];var OUTPUT_TYPES=["hex","array","digest","arrayBuffer"];var blocks=[];if(root.JS_SHA256_NO_NODE_JS||!Array.isArray){Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}if(ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)){ArrayBuffer.isView=function(e){return typeof e==="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer}}var createOutputMethod=function(e,t){return function(r){return new Sha256(t,true).update(r)[e]()}};var createMethod=function(e){var t=createOutputMethod("hex",e);if(NODE_JS){t=nodeWrap(t,e)}t.create=function(){return new Sha256(e)};t.update=function(e){return t.create().update(e)};for(var r=0;r<OUTPUT_TYPES.length;++r){var n=OUTPUT_TYPES[r];t[n]=createOutputMethod(n,e)}return t};var nodeWrap=function(method,is224){var crypto=eval("require('crypto')");var Buffer=eval("require('buffer').Buffer");var algorithm=is224?"sha224":"sha256";var nodeMethod=function(e){if(typeof e==="string"){return crypto.createHash(algorithm).update(e,"utf8").digest("hex")}else{if(e===null||e===undefined){throw new Error(ERROR)}else if(e.constructor===ArrayBuffer){e=new Uint8Array(e)}}if(Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer){return crypto.createHash(algorithm).update(new Buffer(e)).digest("hex")}else{return method(e)}};return nodeMethod};var createHmacOutputMethod=function(e,t){return function(r,n){return new HmacSha256(r,t,true).update(n)[e]()}};var createHmacMethod=function(e){var t=createHmacOutputMethod("hex",e);t.create=function(t){return new HmacSha256(t,e)};t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<OUTPUT_TYPES.length;++r){var n=OUTPUT_TYPES[r];t[n]=createHmacOutputMethod(n,e)}return t};function Sha256(e,t){if(t){blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0;this.blocks=blocks}else{this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}if(e){this.h0=3238371032;this.h1=914150663;this.h2=812702999;this.h3=4144912697;this.h4=4290775857;this.h5=1750603025;this.h6=1694076839;this.h7=3204075428}else{this.h0=1779033703;this.h1=3144134277;this.h2=1013904242;this.h3=2773480762;this.h4=1359893119;this.h5=2600822924;this.h6=528734635;this.h7=1541459225}this.block=this.start=this.bytes=this.hBytes=0;this.finalized=this.hashed=false;this.first=true;this.is224=e}Sha256.prototype.update=function(e){if(this.finalized){return}var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}t=true}var n,i=0,s,o=e.length,a=this.blocks;while(i<o){if(this.hashed){this.hashed=false;a[0]=this.block;a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0}if(t){for(s=this.start;i<o&&s<64;++i){a[s>>2]|=e[i]<<SHIFT[s++&3]}}else{for(s=this.start;i<o&&s<64;++i){n=e.charCodeAt(i);if(n<128){a[s>>2]|=n<<SHIFT[s++&3]}else if(n<2048){a[s>>2]|=(192|n>>6)<<SHIFT[s++&3];a[s>>2]|=(128|n&63)<<SHIFT[s++&3]}else if(n<55296||n>=57344){a[s>>2]|=(224|n>>12)<<SHIFT[s++&3];a[s>>2]|=(128|n>>6&63)<<SHIFT[s++&3];a[s>>2]|=(128|n&63)<<SHIFT[s++&3]}else{n=65536+((n&1023)<<10|e.charCodeAt(++i)&1023);a[s>>2]|=(240|n>>18)<<SHIFT[s++&3];a[s>>2]|=(128|n>>12&63)<<SHIFT[s++&3];a[s>>2]|=(128|n>>6&63)<<SHIFT[s++&3];a[s>>2]|=(128|n&63)<<SHIFT[s++&3]}}}this.lastByteIndex=s;this.bytes+=s-this.start;if(s>=64){this.block=a[16];this.start=s-64;this.hash();this.hashed=true}else{this.start=s}}if(this.bytes>4294967295){this.hBytes+=this.bytes/4294967296<<0;this.bytes=this.bytes%4294967296}return this};Sha256.prototype.finalize=function(){if(this.finalized){return}this.finalized=true;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block;e[t>>2]|=EXTRA[t&3];this.block=e[16];if(t>=56){if(!this.hashed){this.hash()}e[0]=this.block;e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0}e[14]=this.hBytes<<3|this.bytes>>>29;e[15]=this.bytes<<3;this.hash()};Sha256.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,s=this.h5,o=this.h6,a=this.h7,f=this.blocks,u,c,h,l,d,y,p,w,g,v,b;for(u=16;u<64;++u){d=f[u-15];c=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;d=f[u-2];h=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10;f[u]=f[u-16]+c+f[u-7]+h<<0}b=t&r;for(u=0;u<64;u+=4){if(this.first){if(this.is224){w=300032;d=f[0]-1413257819;a=d-150054599<<0;n=d+24177077<<0}else{w=704751109;d=f[0]-210244248;a=d-1521486534<<0;n=d+143694565<<0}this.first=false}else{c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10);h=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7);w=e&t;l=w^e&r^b;p=i&s^~i&o;d=a+h+p+K[u]+f[u];y=c+l;a=n+d<<0;n=d+y<<0}c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10);h=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7);g=n&e;l=g^n&t^w;p=a&i^~a&s;d=o+h+p+K[u+1]+f[u+1];y=c+l;o=r+d<<0;r=d+y<<0;c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10);h=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7);v=r&n;l=v^r&e^g;p=o&a^~o&i;d=s+h+p+K[u+2]+f[u+2];y=c+l;s=t+d<<0;t=d+y<<0;c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10);h=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7);b=t&r;l=b^t&n^v;p=s&o^~s&a;d=i+h+p+K[u+3]+f[u+3];y=c+l;i=e+d<<0;e=d+y<<0}this.h0=this.h0+e<<0;this.h1=this.h1+t<<0;this.h2=this.h2+r<<0;this.h3=this.h3+n<<0;this.h4=this.h4+i<<0;this.h5=this.h5+s<<0;this.h6=this.h6+o<<0;this.h7=this.h7+a<<0};Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,s=this.h5,o=this.h6,a=this.h7;var f=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[o&15];if(!this.is224){f+=HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[a&15]}return f};Sha256.prototype.toString=Sha256.prototype.hex;Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,s=this.h5,o=this.h6,a=this.h7;var f=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,n>>24&255,n>>16&255,n>>8&255,n&255,i>>24&255,i>>16&255,i>>8&255,i&255,s>>24&255,s>>16&255,s>>8&255,s&255,o>>24&255,o>>16&255,o>>8&255,o&255];if(!this.is224){f.push(a>>24&255,a>>16&255,a>>8&255,a&255)}return f};Sha256.prototype.array=Sha256.prototype.digest;Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32);var t=new DataView(e);t.setUint32(0,this.h0);t.setUint32(4,this.h1);t.setUint32(8,this.h2);t.setUint32(12,this.h3);t.setUint32(16,this.h4);t.setUint32(20,this.h5);t.setUint32(24,this.h6);if(!this.is224){t.setUint32(28,this.h7)}return e};function HmacSha256(e,t,r){var n,i=typeof e;if(i==="string"){var s=[],o=e.length,a=0,f;for(n=0;n<o;++n){f=e.charCodeAt(n);if(f<128){s[a++]=f}else if(f<2048){s[a++]=192|f>>6;s[a++]=128|f&63}else if(f<55296||f>=57344){s[a++]=224|f>>12;s[a++]=128|f>>6&63;s[a++]=128|f&63}else{f=65536+((f&1023)<<10|e.charCodeAt(++n)&1023);s[a++]=240|f>>18;s[a++]=128|f>>12&63;s[a++]=128|f>>6&63;s[a++]=128|f&63}}e=s}else{if(i==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}}if(e.length>64){e=new Sha256(t,true).update(e).array()}var u=[],c=[];for(n=0;n<64;++n){var h=e[n]||0;u[n]=92^h;c[n]=54^h}Sha256.call(this,t,r);this.update(c);this.oKeyPad=u;this.inner=true;this.sharedMemory=r}HmacSha256.prototype=new Sha256;HmacSha256.prototype.finalize=function(){Sha256.prototype.finalize.call(this);if(this.inner){this.inner=false;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory);this.update(this.oKeyPad);this.update(e);Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports;exports.sha224=createMethod(true);exports.sha256.hmac=createHmacMethod();exports.sha224.hmac=createHmacMethod(true);if(COMMON_JS){module.exports=exports}else{root.sha256=exports.sha256;root.sha224=exports.sha224}})()})(sha256);var getRandomValues;var rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){getRandomValues=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!getRandomValues){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return typeof e==="string"&&REGEX.test(e)}var byteToHex=[];for(var i=0;i<256;++i){byteToHex.push((i+256).toString(16).substr(1))}function stringify(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var r=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(r)){throw TypeError("Stringified UUID is invalid")}return r}function v4(e,t,r){e=e||{};var n=e.random||(e.rng||rng)();n[6]=n[6]&15|64;n[8]=n[8]&63|128;if(t){r=r||0;for(var i=0;i<16;++i){t[r+i]=n[i]}return t}return stringify(n)}async function getBytes(e,t){const r=e.getReader();let n;while(!(n=await r.read()).done){t(n.value)}}function getLines(e){let t;let r;let n;let i=false;return function s(o){if(t===undefined){t=o;r=0;n=-1}else{t=concat(t,o)}const a=t.length;let f=0;while(r<a){if(i){if(t[r]===10){f=++r}i=false}let s=-1;for(;r<a&&s===-1;++r){switch(t[r]){case 58:if(n===-1){n=r-f}break;case 13:i=true;case 10:s=r;break}}if(s===-1){break}e(t.subarray(f,s),n);f=r;n=-1}if(f===a){t=undefined}else if(f!==0){t=t.subarray(f);r-=f}}}function getMessages(e,t,r){let n=newMessage();const i=new TextDecoder;return function s(o,a){if(o.length===0){r===null||r===void 0?void 0:r(n);n=newMessage()}else if(a>0){const r=i.decode(o.subarray(0,a));const s=a+(o[a+1]===32?2:1);const f=i.decode(o.subarray(s));switch(r){case"data":n.data=n.data?n.data+"\n"+f:f;break;case"event":n.event=f;break;case"id":e(n.id=f);break;case"retry":const r=parseInt(f,10);if(!isNaN(r)){t(n.retry=r)}break}}}}function concat(e,t){const r=new Uint8Array(e.length+t.length);r.set(e);r.set(t,e.length);return r}function newMessage(){return{data:"",event:"",id:"",retry:undefined}}var __rest=undefined&&undefined.__rest||function(e,t){var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0)r[n]=e[n];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++){if(t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i]))r[n[i]]=e[n[i]]}return r};const EventStreamContentType="text/event-stream";const DefaultRetryInterval=1e3;const LastEventId="last-event-id";function fetchEventSource(e,t){var{signal:r,headers:n,onopen:i,onmessage:s,onclose:o,onerror:a,openWhenHidden:f,fetch:u}=t,c=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,h)=>{const l=Object.assign({},n);if(!l.accept){l.accept=EventStreamContentType}let d;function y(){d.abort();if(!document.hidden){m()}}if(!f){document.addEventListener("visibilitychange",y)}let p=DefaultRetryInterval;let w=0;function g(){document.removeEventListener("visibilitychange",y);window.clearTimeout(w);d.abort()}r===null||r===void 0?void 0:r.addEventListener("abort",(()=>{g();t()}));const v=u!==null&&u!==void 0?u:window.fetch;const b=i!==null&&i!==void 0?i:defaultOnOpen;async function m(){var r;d=new AbortController;try{const r=await v(e,Object.assign(Object.assign({},c),{headers:l,signal:d.signal}));await b(r);await getBytes(r.body,getLines(getMessages((e=>{if(e){l[LastEventId]=e}else{delete l[LastEventId]}}),(e=>{p=e}),s)));o===null||o===void 0?void 0:o();g();t()}catch(e){if(!d.signal.aborted){try{const t=(r=a===null||a===void 0?void 0:a(e))!==null&&r!==void 0?r:p;window.clearTimeout(w);w=window.setTimeout(m,t)}catch(e){g();h(e)}}}}m()}))}function defaultOnOpen(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(EventStreamContentType))){throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}}function Base64EncodeUrl(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function getTimestamp(){return Math.floor(Date.now()/1e3)}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,o=0,a="";i=r.charAt(o++);~i&&(n=s%4?64*n+i:i,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function t$1(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r$1(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return r$1(t)}}function n$1(e){this.message=e}function o(e,t){if("string"!=typeof e)throw new n$1("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(t$1(e.split(".")[r]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{clientId;redirectUri;accessType="online";domain="http://api.nylas.com";versioned=false;Storage;hosted=false;multiAccount=false;loginId="";constructor(e){this.clientId=e.clientId;this.redirectUri=e.redirectUri;if(e.domain){this.domain=e.domain;const t=this.domain.substring(this.domain.length-3);if(t.includes("/v")){this.versioned=true}}if(e.multiAccount){this.multiAccount=e.multiAccount}if(e.sw){const e=new IndexedDBStorage;this.Storage=new Storage(e)}else{this.Storage=new Storage}if(e.accessType){this.accessType=e.accessType}if(e.loginId){this.loginId=e.loginId}if(e.hosted){this.hosted=e.hosted}this.codeExchange(null)}async validateAccessToken(e=""){const{access_token:t}=await this.Storage.getGrant(e,this.multiAccount);try{const e=await fetch(`${this.domain}/connect/tokeninfo?access_token=${t}`,{method:"GET"});const r=await e.json();if(!r.data){return false}return true}catch(e){return false}}async validateIDToken(e=""){const{id_token:t}=await this.Storage.getGrant(e,this.multiAccount);try{const e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${t}`,{method:"GET"});if(e.status!==200){return false}const r=await e.json();if(!r.data){return false}return true}catch(e){return false}}getDomain(){return this.domain}async auth(e){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){await this.hostedSetCodeChallenge()}const t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){const t=await this.getCodeChallege();let r=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(t){r+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`}if(e.provider){r+=`&provider=${e.provider}`}if(e.loginHint){r+=`&login_hint=${e.loginHint}`;if(e.includeGrantScopes){r+=`&include_grant_scopes=${e.includeGrantScopes}`}}if(e.scope){r+=`&scope=${e.scope.join(" ")}`}if(e.prompt){r+=`&prompt=${e.prompt}`}if(e.metadata){r+=`&metadata=${e.metadata}`}if(e.state||this.loginId){r+=`&state=${this.loginId?this.loginId:e.state}`}return r}async generateReauthURL(e,t){if(!e){throw new Error("Grant ID is required")}const r=await this.Storage.getUserToken(e);const n=await this.getCodeChallege();let i=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(n){i+=`&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`}if(r?.provider){i+=`&provider=${r.provider}`}if(r?.email){i+=`&login_hint=${r.email}`}if(t){i+=`&scope=${t.join(" ")}`}return i}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=v4();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){const e=await this.Storage.getPKCE();if(e){return}console.warn("Code challenge is recomended");return}this.Storage.setPKCE(t)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){console.warn("Code challenge is recomended");return""}return t}const e=await this.Storage.getPKCE();if(e){const t=sha256.exports.sha256(e);let r=Buffer.from(t).toString("base64");r=Base64EncodeUrl(r);return r}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){return false}const e=await this.Storage.getUserTokens();if(e&&e.length>0){if(this.multiAccount){await this.generateCodeChallenge()}return true}await this.generateCodeChallenge();return false}isMultiAccount(){return this.multiAccount}async logout(){const e=await this.getProfile();await this.Storage.clearSession();const t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;if(e){t=await this.Storage.getUserToken(e)}else{t=await this.Storage.getUserToken()}if(t){return t}return null}async getProfiles(){const e=await this.Storage.getUserTokens();if(e){return e}return null}async removeProfile(e){await this.Storage.removeUserToken(e);await this.Storage.removeGrant(e);return null}async authIMAP(e){const t=await this.getCodeChallege();const r={imap_username:e.username,imap_password:e.password,imap_host:e.hostIMAP,imap_port:e.portIMAP,type:e.type,smtp_host:e.hostSMTP,smtp_port:e.portSMTP,provider:e.provider,redirect_uri:this.redirectUri,state:e.state,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){r.id=this.loginId}if(t!=""){r.code_challenge=t;r.code_challenge_method="S256"}const n=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(r)});const i=await n.json();return i}async authEWS(e){const t=await this.getCodeChallege();const r={...e,redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){r.id=this.loginId}if(t!=""){r.code_challenge=t;r.code_challenge_method="S256"}const n=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(r)});const i=await n.json();return i}async detectEmail(e){const t=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${e}`,{method:"POST",headers:new Headers({"content-type":"application/json"})});const r=await t.json();return r.data}async applicationInfo(){const e=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});const t=await e.json();return t.data}async getAvailableProviders(){const e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});if(e){const t=await e.json();const r=t.data;return r}return null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",(t=>e(t)))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",(t=>e(t)))}onLoginFail(e){window.addEventListener("onLoginFail",(t=>e(t)))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",(t=>e(t)))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",(t=>e(t)))}onSessionExpired(e){window.addEventListener("onSessionExpired",(t=>e(t)))}async codeExchange(e){let t=new URLSearchParams(window.location.search);if(e){t=new URLSearchParams(e)}const r=t.get("code");const n=t.get("state");const i=t.get("error");const s=t.get("error_description");const o=t.get("error_code");if(i&&s&&o){const e={detail:{error:i,error_description:s,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}if(!r){console.warn("No code found");return false}if(window.opener&&window.name==="uas-popup"){console.warn("Popup window detected");return false}const a=await this.Storage.getPKCE();if(!a){console.warn("No code verifier found");return false}try{const e={client_id:this.clientId,redirect_uri:this.redirectUri,code:r,grant_type:"authorization_code",code_verifier:a};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const i=await t.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(i);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(n){e.data.state=n}const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t));window.history.pushState({},document.title,window.location.pathname)}}this.Storage.removePKCE();return true}catch(i){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}}async tokenExchange(e=""){const{refresh_token:t}=await this.Storage.getGrant(e,this.multiAccount);try{const r={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:t,grant_type:"refresh_token"};const n=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(r)});const i=await n.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=getTimestamp();i.expires_in=t+i.expires_in;this.Storage.setGrant(i,this.multiAccount);const r=await this.validateIDToken(e);if(!r){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const n={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",n));return true}this.Storage.removePKCE()}catch(e){const t={detail:e};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",t));return false}}async handleCodeExchangeResponse(e){const t=true;if(e.error){return{data:e,valid:false}}const r=getTimestamp();e.expires_in=r+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const n=o(e.id_token);n.status="authenticated";this.Storage.setUserToken(n);const i=await this.validateIDToken(n.sub);if(!i){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const r=600;const n=window.screenX+(window.outerWidth-t)/2;const i=window.screenY+(window.outerHeight-r)/2.5;const s=`uas-popup`;const o=e;const a=window.open(o,s,`width=${t},height=${r},left=${n},top=${i}`);if(!a){return}const f=setInterval((async()=>{if(a.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));f&&clearInterval(f);return}try{const e=a.location.href.split("?");if(!e[0]){return}const t=a.location.search;a.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);a.close();if(e){location.reload()}f&&clearInterval(f);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=getTimestamp();const{access_token:r,expires_in:n}=await this.Storage.getGrant(e,this.multiAccount);const i=r;if(i){if(n&&n>getTimestamp()){const e=n-t;if(e>30){return i}}}await this.tokenExchange(e);const s=await this.Storage.getGrant(e,this.multiAccount);return s.access_token}async sse(e,t){const r=t.headers||{};const n=r["Grant-ID"];let i="";if(this.multiAccount){if(!n){throw new Error("Grant ID is required for multi account calls")}i=await this.getAccessToken(n)}else{i=await this.getAccessToken()}delete r["Grant-ID"];r["Authorization"]=`Bearer ${i}`;if(!r["content-type"]){r["content-type"]="application/json"}return fetchEventSource(`${this.domain}/${e}`,{...t,headers:r})}async fetch(e,t,r=true,n){let i="";let s=1;if(this.multiAccount){if(!t.grant_id){throw new Error("Grant ID is required for multi account calls")}const e=await this.getProfiles();s=e?e.length:1;i=await this.getAccessToken(t.grant_id)}else{i=await this.getAccessToken()}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${i}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${i}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const i=await fetch(`${n||this.domain}/${e}`,{...t,headers:o});if(!r){return i}const a=await(i?.json());const f=await this.isAuthenticatedResponse(i.status,a);if(!f){if(s>1){const e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized";await this.Storage.setUserToken(e);const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{const e=await this.Storage.getUserToken();const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t));this.logout()}return}return a}catch(e){throw e}}async fetchRequest(e,t,r,n=true,i,s){const o=await this.isLoggedIn();const a=new URL(e,i??this.domain);const f=new Headers;f.append("Accept","application/json");f.append("Content-Type","application/json");f.append("User-Agent","nylas-identity");if(o){const e=await this.getAccessToken();f.append("Authorization",`Bearer ${e}`)}const u=await fetch(a.toString(),{method:t||"GET",headers:f,mode:"cors",referrer:location.origin,body:r?JSON.stringify(r):undefined,...s||{}});if(!n){return u.body}const c=await u.json();return c}async isAuthenticatedResponse(e,t){if(e==401&&t?.error?.type=="token.unauthorized_access"){return false}return true}addAPIKey(e,t,r){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:true,iat:getTimestamp(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e});this.Storage.setGrant({grant_id:e,access_token:r,expires_in:2e9},this.multiAccount)}}var react_production_min={};
7
+ */var INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:true;function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()<t){throw new RangeError("Invalid typed array length")}if(Buffer.TYPED_ARRAY_SUPPORT){e=new Uint8Array(t);e.__proto__=Buffer.prototype}else{if(e===null){e=new Buffer(t)}e.length=t}return e}function Buffer(e,t,r){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer)){return new Buffer(e,t,r)}if(typeof e==="number"){if(typeof t==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return allocUnsafe(this,e)}return from(this,e,t,r)}Buffer.poolSize=8192;Buffer._augment=function(e){e.__proto__=Buffer.prototype;return e};function from(e,t,r,n){if(typeof t==="number"){throw new TypeError('"value" argument must not be a number')}if(typeof ArrayBuffer!=="undefined"&&t instanceof ArrayBuffer){return fromArrayBuffer(e,t,r,n)}if(typeof t==="string"){return fromString(e,t,r)}return fromObject(e,t)}Buffer.from=function(e,t,r){return from(null,e,t,r)};if(Buffer.TYPED_ARRAY_SUPPORT){Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array}function assertSize(e){if(typeof e!=="number"){throw new TypeError('"size" argument must be a number')}else if(e<0){throw new RangeError('"size" argument must not be negative')}}function alloc(e,t,r,n){assertSize(t);if(t<=0){return createBuffer(e,t)}if(r!==undefined){return typeof n==="string"?createBuffer(e,t).fill(r,n):createBuffer(e,t).fill(r)}return createBuffer(e,t)}Buffer.alloc=function(e,t,r){return alloc(null,e,t,r)};function allocUnsafe(e,t){assertSize(t);e=createBuffer(e,t<0?0:checked(t)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;++r){e[r]=0}}return e}Buffer.allocUnsafe=function(e){return allocUnsafe(null,e)};Buffer.allocUnsafeSlow=function(e){return allocUnsafe(null,e)};function fromString(e,t,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}var n=byteLength(t,r)|0;e=createBuffer(e,n);var i=e.write(t,r);if(i!==n){e=e.slice(0,i)}return e}function fromArrayLike(e,t){var r=t.length<0?0:checked(t.length)|0;e=createBuffer(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function fromArrayBuffer(e,t,r,n){if(r<0||t.byteLength<r){throw new RangeError("'offset' is out of bounds")}if(t.byteLength<r+(n||0)){throw new RangeError("'length' is out of bounds")}if(r===undefined&&n===undefined){t=new Uint8Array(t)}else if(n===undefined){t=new Uint8Array(t,r)}else{t=new Uint8Array(t,r,n)}if(Buffer.TYPED_ARRAY_SUPPORT){e=t;e.__proto__=Buffer.prototype}else{e=fromArrayLike(e,t)}return e}function fromObject(e,t){if(internalIsBuffer(t)){var r=checked(t.length)|0;e=createBuffer(e,r);if(e.length===0){return e}t.copy(e,0,0,r);return e}if(t){if(typeof ArrayBuffer!=="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t){if(typeof t.length!=="number"||isnan(t.length)){return createBuffer(e,0)}return fromArrayLike(e,t)}if(t.type==="Buffer"&&isArray(t.data)){return fromArrayLike(e,t.data)}}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return e|0}Buffer.isBuffer=isBuffer;function internalIsBuffer(e){return!!(e!=null&&e._isBuffer)}Buffer.compare=function e(t,r){if(!internalIsBuffer(t)||!internalIsBuffer(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var s=0,o=Math.min(n,i);s<o;++s){if(t[s]!==r[s]){n=t[s];i=r[s];break}}if(n<i)return-1;if(i<n)return 1;return 0};Buffer.isEncoding=function e(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function e(t,r){if(!isArray(t)){throw new TypeError('"list" argument must be an Array of Buffers')}if(t.length===0){return Buffer.alloc(0)}var n;if(r===undefined){r=0;for(n=0;n<t.length;++n){r+=t[n].length}}var i=Buffer.allocUnsafe(r);var s=0;for(n=0;n<t.length;++n){var o=t[n];if(!internalIsBuffer(o)){throw new TypeError('"list" argument must be an Array of Buffers')}o.copy(i,s);s+=o.length}return i};function byteLength(e,t){if(internalIsBuffer(e)){return e.length}if(typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)){return e.byteLength}if(typeof e!=="string"){e=""+e}var r=e.length;if(r===0)return 0;var n=false;for(;;){switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case undefined:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase();n=true}}}Buffer.byteLength=byteLength;function slowToString(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}Buffer.prototype._isBuffer=true;function swap(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}Buffer.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r<t;r+=2){swap(this,r,r+1)}return this};Buffer.prototype.swap32=function e(){var t=this.length;if(t%4!==0){throw new RangeError("Buffer size must be a multiple of 32-bits")}for(var r=0;r<t;r+=4){swap(this,r,r+3);swap(this,r+1,r+2)}return this};Buffer.prototype.swap64=function e(){var t=this.length;if(t%8!==0){throw new RangeError("Buffer size must be a multiple of 64-bits")}for(var r=0;r<t;r+=8){swap(this,r,r+7);swap(this,r+1,r+6);swap(this,r+2,r+5);swap(this,r+3,r+4)}return this};Buffer.prototype.toString=function e(){var t=this.length|0;if(t===0)return"";if(arguments.length===0)return utf8Slice(this,0,t);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function e(t){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");if(this===t)return true;return Buffer.compare(this,t)===0};Buffer.prototype.inspect=function e(){var t="";var r=INSPECT_MAX_BYTES;if(this.length>0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return"<Buffer "+t+">"};Buffer.prototype.compare=function e(t,r,n,i,s){if(!internalIsBuffer(t)){throw new TypeError("Argument must be a Buffer")}if(r===undefined){r=0}if(n===undefined){n=t?t.length:0}if(i===undefined){i=0}if(s===undefined){s=this.length}if(r<0||n>t.length||i<0||s>this.length){throw new RangeError("out of range index")}if(i>=s&&r>=n){return 0}if(i>=s){return-1}if(r>=n){return 1}r>>>=0;n>>>=0;i>>>=0;s>>>=0;if(this===t)return 0;var o=s-i;var a=n-r;var f=Math.min(o,a);var u=this.slice(i,s);var c=t.slice(r,n);for(var h=0;h<f;++h){if(u[h]!==c[h]){o=u[h];a=c[h];break}}if(o<a)return-1;if(a<o)return 1;return 0};function bidirectionalIndexOf(e,t,r,n,i){if(e.length===0)return-1;if(typeof r==="string"){n=r;r=0}else if(r>2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=Buffer.from(t,n)}if(internalIsBuffer(t)){if(t.length===0){return-1}return arrayIndexOf(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return arrayIndexOf(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,i){var s=1;var o=e.length;var a=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}s=2;o/=2;a/=2;r/=2}}function f(e,t){if(s===1){return e[t]}else{return e.readUInt16BE(t*s)}}var u;if(i){var c=-1;for(u=r;u<o;u++){if(f(e,u)===f(t,c===-1?0:u-c)){if(c===-1)c=u;if(u-c+1===a)return c*s}else{if(c!==-1)u-=u-c;c=-1}}}else{if(r+a>o)r=o-a;for(u=r;u>=0;u--){var h=true;for(var l=0;l<a;l++){if(f(e,u+l)!==f(t,l)){h=false;break}}if(h)return u}}return-1}Buffer.prototype.includes=function e(t,r,n){return this.indexOf(t,r,n)!==-1};Buffer.prototype.indexOf=function e(t,r,n){return bidirectionalIndexOf(this,t,r,n,true)};Buffer.prototype.lastIndexOf=function e(t,r,n){return bidirectionalIndexOf(this,t,r,n,false)};function hexWrite(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");if(n>s/2){n=s/2}for(var o=0;o<n;++o){var a=parseInt(t.substr(o*2,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function utf8Write(e,t,r,n){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,n)}function asciiWrite(e,t,r,n){return blitBuffer(asciiToBytes(t),e,r,n)}function latin1Write(e,t,r,n){return asciiWrite(e,t,r,n)}function base64Write(e,t,r,n){return blitBuffer(base64ToBytes(t),e,r,n)}function ucs2Write(e,t,r,n){return blitBuffer(utf16leToBytes(t,e.length-r),e,r,n)}Buffer.prototype.write=function e(t,r,n,i){if(r===undefined){i="utf8";n=this.length;r=0}else if(n===undefined&&typeof r==="string"){i=r;n=this.length;r=0}else if(isFinite(r)){r=r|0;if(isFinite(n)){n=n|0;if(i===undefined)i="utf8"}else{i=n;n=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var s=this.length-r;if(n===undefined||n>s)n=s;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var o=false;for(;;){switch(i){case"hex":return hexWrite(this,t,r,n);case"utf8":case"utf-8":return utf8Write(this,t,r,n);case"ascii":return asciiWrite(this,t,r,n);case"latin1":case"binary":return latin1Write(this,t,r,n);case"base64":return base64Write(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();o=true}}};Buffer.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,r){if(t===0&&r===e.length){return fromByteArray(e)}else{return fromByteArray(e.slice(t,r))}}function utf8Slice(e,t,r){r=Math.min(e.length,r);var n=[];var i=t;while(i<r){var s=e[i];var o=null;var a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var f,u,c,h;switch(a){case 1:if(s<128){o=s}break;case 2:f=e[i+1];if((f&192)===128){h=(s&31)<<6|f&63;if(h>127){o=h}}break;case 3:f=e[i+1];u=e[i+2];if((f&192)===128&&(u&192)===128){h=(s&15)<<12|(f&63)<<6|u&63;if(h>2047&&(h<55296||h>57343)){o=h}}break;case 4:f=e[i+1];u=e[i+2];c=e[i+3];if((f&192)===128&&(u&192)===128&&(c&192)===128){h=(s&15)<<18|(f&63)<<12|(u&63)<<6|c&63;if(h>65535&&h<1114112){o=h}}}}if(o===null){o=65533;a=1}else if(o>65535){o-=65536;n.push(o>>>10&1023|55296);o=56320|o&1023}n.push(o);i+=a}return decodeCodePointsArray(n)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(n<t){r+=String.fromCharCode.apply(String,e.slice(n,n+=MAX_ARGUMENTS_LENGTH))}return r}function asciiSlice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i){n+=String.fromCharCode(e[i]&127)}return n}function latin1Slice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i){n+=String.fromCharCode(e[i])}return n}function hexSlice(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var s=t;s<r;++s){i+=toHex(e[s])}return i}function utf16leSlice(e,t,r){var n=e.slice(t,r);var i="";for(var s=0;s<n.length;s+=2){i+=String.fromCharCode(n[s]+n[s+1]*256)}return i}Buffer.prototype.slice=function e(t,r){var n=this.length;t=~~t;r=r===undefined?n:~~r;if(t<0){t+=n;if(t<0)t=0}else if(t>n){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(r<t)r=t;var i;if(Buffer.TYPED_ARRAY_SUPPORT){i=this.subarray(t,r);i.__proto__=Buffer.prototype}else{var s=r-t;i=new Buffer(s,undefined);for(var o=0;o<s;++o){i[o]=this[o+t]}}return i};function checkOffset(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var s=1;var o=0;while(++o<r&&(s*=256)){i+=this[t+o]*s}return i};Buffer.prototype.readUIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n){checkOffset(t,r,this.length)}var i=this[t+--r];var s=1;while(r>0&&(s*=256)){i+=this[t+--r]*s}return i};Buffer.prototype.readUInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);return this[t]};Buffer.prototype.readUInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]|this[t+1]<<8};Buffer.prototype.readUInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]<<8|this[t+1]};Buffer.prototype.readUInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};Buffer.prototype.readUInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};Buffer.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var s=1;var o=0;while(++o<r&&(s*=256)){i+=this[t+o]*s}s*=128;if(i>=s)i-=Math.pow(2,8*r);return i};Buffer.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=r;var s=1;var o=this[t+--i];while(i>0&&(s*=256)){o+=this[t+--i]*s}s*=128;if(o>=s)o-=Math.pow(2,8*r);return o};Buffer.prototype.readInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};Buffer.prototype.readInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};Buffer.prototype.readInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};Buffer.prototype.readInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};Buffer.prototype.readInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};Buffer.prototype.readFloatLE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read(this,t,true,23,4)};Buffer.prototype.readFloatBE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read(this,t,false,23,4)};Buffer.prototype.readDoubleLE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read(this,t,true,52,8)};Buffer.prototype.readDoubleBE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read(this,t,false,52,8)};function checkInt(e,t,r,n,i,s){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var s=Math.pow(2,8*n)-1;checkInt(this,t,r,n,s,0)}var o=1;var a=0;this[r]=t&255;while(++a<n&&(o*=256)){this[r+a]=t/o&255}return r+n};Buffer.prototype.writeUIntBE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var s=Math.pow(2,8*n)-1;checkInt(this,t,r,n,s,0)}var o=n-1;var a=1;this[r+o]=t&255;while(--o>=0&&(a*=256)){this[r+o]=t/a&255}return r+n};Buffer.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function objectWriteUInt16(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,s=Math.min(e.length-r,2);i<s;++i){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};function objectWriteUInt32(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,s=Math.min(e.length-r,4);i<s;++i){e[r+i]=t>>>(n?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};Buffer.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var s=Math.pow(2,8*n-1);checkInt(this,t,r,n,s-1,-s)}var o=0;var a=1;var f=0;this[r]=t&255;while(++o<n&&(a*=256)){if(t<0&&f===0&&this[r+o-1]!==0){f=1}this[r+o]=(t/a>>0)-f&255}return r+n};Buffer.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var s=Math.pow(2,8*n-1);checkInt(this,t,r,n,s-1,-s)}var o=n-1;var a=1;var f=0;this[r+o]=t&255;while(--o>=0&&(a*=256)){if(t<0&&f===0&&this[r+o+1]!==0){f=1}this[r+o]=(t/a>>0)-f&255}return r+n};Buffer.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};Buffer.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};Buffer.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};function checkIEEE754(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,4)}write(e,t,r,n,23,4);return r+4}Buffer.prototype.writeFloatLE=function e(t,r,n){return writeFloat(this,t,r,true,n)};Buffer.prototype.writeFloatBE=function e(t,r,n){return writeFloat(this,t,r,false,n)};function writeDouble(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,8)}write(e,t,r,n,52,8);return r+8}Buffer.prototype.writeDoubleLE=function e(t,r,n){return writeDouble(this,t,r,true,n)};Buffer.prototype.writeDoubleBE=function e(t,r,n){return writeDouble(this,t,r,false,n)};Buffer.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i<n)i=n;if(i===n)return 0;if(t.length===0||this.length===0)return 0;if(r<0){throw new RangeError("targetStart out of bounds")}if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r<i-n){i=t.length-r+n}var s=i-n;var o;if(this===t&&n<r&&r<i){for(o=s-1;o>=0;--o){t[o+r]=this[o+n]}}else if(s<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(o=0;o<s;++o){t[o+r]=this[o+n]}}else{Uint8Array.prototype.set.call(t,this.subarray(n,n+s),r)}return s};Buffer.prototype.fill=function e(t,r,n,i){if(typeof t==="string"){if(typeof r==="string"){i=r;r=0;n=this.length}else if(typeof n==="string"){i=n;n=this.length}if(t.length===1){var s=t.charCodeAt(0);if(s<256){t=s}}if(i!==undefined&&typeof i!=="string"){throw new TypeError("encoding must be a string")}if(typeof i==="string"&&!Buffer.isEncoding(i)){throw new TypeError("Unknown encoding: "+i)}}else if(typeof t==="number"){t=t&255}if(r<0||this.length<r||this.length<n){throw new RangeError("Out of range index")}if(n<=r){return this}r=r>>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var o;if(typeof t==="number"){for(o=r;o<n;++o){this[o]=t}}else{var a=internalIsBuffer(t)?t:utf8ToBytes(new Buffer(t,i).toString());var f=a.length;for(o=0;o<n-r;++o){this[o+r]=a[o%f]}}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(e){e=stringtrim(e).replace(INVALID_BASE64_RE,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function stringtrim(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function toHex(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function utf8ToBytes(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var s=[];for(var o=0;o<n;++o){r=e.charCodeAt(o);if(r>55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)s.push(239,191,189);continue}else if(o+1===n){if((t-=3)>-1)s.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)s.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)s.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return s}function asciiToBytes(e){var t=[];for(var r=0;r<e.length;++r){t.push(e.charCodeAt(r)&255)}return t}function utf16leToBytes(e,t){var r,n,i;var s=[];for(var o=0;o<e.length;++o){if((t-=2)<0)break;r=e.charCodeAt(o);n=r>>8;i=r%256;s.push(i);s.push(n)}return s}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var i=0;i<n;++i){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function isnan(e){return e!==e}function isBuffer(e){return e!=null&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&isFastBuffer(e.slice(0,0))}class LocalStorage{get(e){return new Promise((t=>{const r=window.localStorage.getItem(e);if(!r){t(null)}else{t(JSON.parse(r))}}))}async remove(e){window.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){window.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const PKCE_KEY="pkce";const GRANT_KEY="grant";const USER_KEY="user";class Storage{Storage=new LocalStorage;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=Buffer.from(e);this.Storage.set(PKCE_KEY,t.toString("base64"))}async getPKCE(){try{const e=await this.Storage.get(PKCE_KEY);if(e){const t=Buffer.from(e,"base64");return t.toString("utf8")}}catch(e){return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(e,t=false){const{grant_id:r}=e;this.Storage.set(`${GRANT_KEY}${t?"-"+r:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${GRANT_KEY}${t?"-"+e:""}`)}async getGrant(e,t=false){const r=await this.Storage.get(`${GRANT_KEY}${t?"-"+e:""}`);if(r){return r}return null}async setUserToken(e){const t=await this.getUserTokens();if(t){const r=t.find((t=>t.sub===e.sub));if(!r){const r=[...t,e];this.Storage.set(USER_KEY,r)}else{const r=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(USER_KEY,r)}}else{this.Storage.set(USER_KEY,[e])}}async getUserToken(e=""){const t=await this.Storage.get(USER_KEY);if(t){if(e===""){return t[0]}const r=t.find((t=>t.sub===e));return r}return null}async getUserTokens(){const e=await this.Storage.get(USER_KEY);if(e){return e}return null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(e){const t=await this.getUserTokens();const r=t?.filter((t=>t.sub!==e));this.Storage.set(USER_KEY,r)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class IndexedDBStorage{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((r,n)=>{t.openDatabase().then((function(i){const s=i.transaction(t.storeName,"readwrite");const o=s.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{r(a.result)};a.onerror=()=>{n(a.error)};s.oncomplete=()=>{i.close()}}))}))}async remove(e){const t=this;return new Promise(((r,n)=>{const i=indexedDB.open(this.databaseName);i.onupgradeneeded=function(e){const r=e.target.result;r.createObjectStore(t.storeName)};i.onerror=()=>{n(i.error)};i.onsuccess=t=>{const i=t.target.result;const s=i.transaction(this.storeName,"readwrite");const o=s.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{r(null)};a.onerror=()=>{n(a.error)};s.oncomplete=()=>{i.close()}}}))}set(e,t){return new Promise(((r,n)=>{const i=indexedDB.open(this.databaseName);i.onerror=()=>{n(i.error)};i.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};i.onsuccess=i=>{const s=i.target.result;const o=s.transaction(this.storeName,"readwrite");const a=o.objectStore(this.storeName);const f=a.put(t,e);f.onsuccess=()=>{r(t)};f.onerror=()=>{n(f.error)};o.oncomplete=()=>{s.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,r){const n=indexedDB.open(e.databaseName,2);n.onupgradeneeded=function(t){const r=t.target.result;r.createObjectStore(e.storeName)};n.onsuccess=function(e){t(e.target.result)};n.onerror=function(e){r(e.error)}}))}}var process=commonjsGlobal.process;var sha256={exports:{}};(function(module){(function(){var ERROR="input is invalid type";var WINDOW=typeof window==="object";var root=WINDOW?window:{};if(root.JS_SHA256_NO_WINDOW){WINDOW=false}var WEB_WORKER=!WINDOW&&typeof self==="object";var NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process==="object"&&process.versions&&process.versions.node;if(NODE_JS){root=commonjsGlobal}else if(WEB_WORKER){root=self}var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&"object"==="object"&&module.exports;var ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer!=="undefined";var HEX_CHARS="0123456789abcdef".split("");var EXTRA=[-2147483648,8388608,32768,128];var SHIFT=[24,16,8,0];var K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];var OUTPUT_TYPES=["hex","array","digest","arrayBuffer"];var blocks=[];if(root.JS_SHA256_NO_NODE_JS||!Array.isArray){Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}if(ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)){ArrayBuffer.isView=function(e){return typeof e==="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer}}var createOutputMethod=function(e,t){return function(r){return new Sha256(t,true).update(r)[e]()}};var createMethod=function(e){var t=createOutputMethod("hex",e);if(NODE_JS){t=nodeWrap(t,e)}t.create=function(){return new Sha256(e)};t.update=function(e){return t.create().update(e)};for(var r=0;r<OUTPUT_TYPES.length;++r){var n=OUTPUT_TYPES[r];t[n]=createOutputMethod(n,e)}return t};var nodeWrap=function(method,is224){var crypto=eval("require('crypto')");var Buffer=eval("require('buffer').Buffer");var algorithm=is224?"sha224":"sha256";var nodeMethod=function(e){if(typeof e==="string"){return crypto.createHash(algorithm).update(e,"utf8").digest("hex")}else{if(e===null||e===undefined){throw new Error(ERROR)}else if(e.constructor===ArrayBuffer){e=new Uint8Array(e)}}if(Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer){return crypto.createHash(algorithm).update(new Buffer(e)).digest("hex")}else{return method(e)}};return nodeMethod};var createHmacOutputMethod=function(e,t){return function(r,n){return new HmacSha256(r,t,true).update(n)[e]()}};var createHmacMethod=function(e){var t=createHmacOutputMethod("hex",e);t.create=function(t){return new HmacSha256(t,e)};t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<OUTPUT_TYPES.length;++r){var n=OUTPUT_TYPES[r];t[n]=createHmacOutputMethod(n,e)}return t};function Sha256(e,t){if(t){blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0;this.blocks=blocks}else{this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}if(e){this.h0=3238371032;this.h1=914150663;this.h2=812702999;this.h3=4144912697;this.h4=4290775857;this.h5=1750603025;this.h6=1694076839;this.h7=3204075428}else{this.h0=1779033703;this.h1=3144134277;this.h2=1013904242;this.h3=2773480762;this.h4=1359893119;this.h5=2600822924;this.h6=528734635;this.h7=1541459225}this.block=this.start=this.bytes=this.hBytes=0;this.finalized=this.hashed=false;this.first=true;this.is224=e}Sha256.prototype.update=function(e){if(this.finalized){return}var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}t=true}var n,i=0,s,o=e.length,a=this.blocks;while(i<o){if(this.hashed){this.hashed=false;a[0]=this.block;a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0}if(t){for(s=this.start;i<o&&s<64;++i){a[s>>2]|=e[i]<<SHIFT[s++&3]}}else{for(s=this.start;i<o&&s<64;++i){n=e.charCodeAt(i);if(n<128){a[s>>2]|=n<<SHIFT[s++&3]}else if(n<2048){a[s>>2]|=(192|n>>6)<<SHIFT[s++&3];a[s>>2]|=(128|n&63)<<SHIFT[s++&3]}else if(n<55296||n>=57344){a[s>>2]|=(224|n>>12)<<SHIFT[s++&3];a[s>>2]|=(128|n>>6&63)<<SHIFT[s++&3];a[s>>2]|=(128|n&63)<<SHIFT[s++&3]}else{n=65536+((n&1023)<<10|e.charCodeAt(++i)&1023);a[s>>2]|=(240|n>>18)<<SHIFT[s++&3];a[s>>2]|=(128|n>>12&63)<<SHIFT[s++&3];a[s>>2]|=(128|n>>6&63)<<SHIFT[s++&3];a[s>>2]|=(128|n&63)<<SHIFT[s++&3]}}}this.lastByteIndex=s;this.bytes+=s-this.start;if(s>=64){this.block=a[16];this.start=s-64;this.hash();this.hashed=true}else{this.start=s}}if(this.bytes>4294967295){this.hBytes+=this.bytes/4294967296<<0;this.bytes=this.bytes%4294967296}return this};Sha256.prototype.finalize=function(){if(this.finalized){return}this.finalized=true;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block;e[t>>2]|=EXTRA[t&3];this.block=e[16];if(t>=56){if(!this.hashed){this.hash()}e[0]=this.block;e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0}e[14]=this.hBytes<<3|this.bytes>>>29;e[15]=this.bytes<<3;this.hash()};Sha256.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,s=this.h5,o=this.h6,a=this.h7,f=this.blocks,u,c,h,l,d,y,p,w,g,v,m;for(u=16;u<64;++u){d=f[u-15];c=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;d=f[u-2];h=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10;f[u]=f[u-16]+c+f[u-7]+h<<0}m=t&r;for(u=0;u<64;u+=4){if(this.first){if(this.is224){w=300032;d=f[0]-1413257819;a=d-150054599<<0;n=d+24177077<<0}else{w=704751109;d=f[0]-210244248;a=d-1521486534<<0;n=d+143694565<<0}this.first=false}else{c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10);h=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7);w=e&t;l=w^e&r^m;p=i&s^~i&o;d=a+h+p+K[u]+f[u];y=c+l;a=n+d<<0;n=d+y<<0}c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10);h=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7);g=n&e;l=g^n&t^w;p=a&i^~a&s;d=o+h+p+K[u+1]+f[u+1];y=c+l;o=r+d<<0;r=d+y<<0;c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10);h=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7);v=r&n;l=v^r&e^g;p=o&a^~o&i;d=s+h+p+K[u+2]+f[u+2];y=c+l;s=t+d<<0;t=d+y<<0;c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10);h=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7);m=t&r;l=m^t&n^v;p=s&o^~s&a;d=i+h+p+K[u+3]+f[u+3];y=c+l;i=e+d<<0;e=d+y<<0}this.h0=this.h0+e<<0;this.h1=this.h1+t<<0;this.h2=this.h2+r<<0;this.h3=this.h3+n<<0;this.h4=this.h4+i<<0;this.h5=this.h5+s<<0;this.h6=this.h6+o<<0;this.h7=this.h7+a<<0};Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,s=this.h5,o=this.h6,a=this.h7;var f=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[o&15];if(!this.is224){f+=HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[a&15]}return f};Sha256.prototype.toString=Sha256.prototype.hex;Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,s=this.h5,o=this.h6,a=this.h7;var f=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,n>>24&255,n>>16&255,n>>8&255,n&255,i>>24&255,i>>16&255,i>>8&255,i&255,s>>24&255,s>>16&255,s>>8&255,s&255,o>>24&255,o>>16&255,o>>8&255,o&255];if(!this.is224){f.push(a>>24&255,a>>16&255,a>>8&255,a&255)}return f};Sha256.prototype.array=Sha256.prototype.digest;Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32);var t=new DataView(e);t.setUint32(0,this.h0);t.setUint32(4,this.h1);t.setUint32(8,this.h2);t.setUint32(12,this.h3);t.setUint32(16,this.h4);t.setUint32(20,this.h5);t.setUint32(24,this.h6);if(!this.is224){t.setUint32(28,this.h7)}return e};function HmacSha256(e,t,r){var n,i=typeof e;if(i==="string"){var s=[],o=e.length,a=0,f;for(n=0;n<o;++n){f=e.charCodeAt(n);if(f<128){s[a++]=f}else if(f<2048){s[a++]=192|f>>6;s[a++]=128|f&63}else if(f<55296||f>=57344){s[a++]=224|f>>12;s[a++]=128|f>>6&63;s[a++]=128|f&63}else{f=65536+((f&1023)<<10|e.charCodeAt(++n)&1023);s[a++]=240|f>>18;s[a++]=128|f>>12&63;s[a++]=128|f>>6&63;s[a++]=128|f&63}}e=s}else{if(i==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}}if(e.length>64){e=new Sha256(t,true).update(e).array()}var u=[],c=[];for(n=0;n<64;++n){var h=e[n]||0;u[n]=92^h;c[n]=54^h}Sha256.call(this,t,r);this.update(c);this.oKeyPad=u;this.inner=true;this.sharedMemory=r}HmacSha256.prototype=new Sha256;HmacSha256.prototype.finalize=function(){Sha256.prototype.finalize.call(this);if(this.inner){this.inner=false;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory);this.update(this.oKeyPad);this.update(e);Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports;exports.sha224=createMethod(true);exports.sha256.hmac=createHmacMethod();exports.sha224.hmac=createHmacMethod(true);if(COMMON_JS){module.exports=exports}else{root.sha256=exports.sha256;root.sha224=exports.sha224}})()})(sha256);var getRandomValues;var rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){getRandomValues=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!getRandomValues){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return typeof e==="string"&&REGEX.test(e)}var byteToHex=[];for(var i=0;i<256;++i){byteToHex.push((i+256).toString(16).substr(1))}function stringify(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var r=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(r)){throw TypeError("Stringified UUID is invalid")}return r}function v4(e,t,r){e=e||{};var n=e.random||(e.rng||rng)();n[6]=n[6]&15|64;n[8]=n[8]&63|128;if(t){r=r||0;for(var i=0;i<16;++i){t[r+i]=n[i]}return t}return stringify(n)}async function getBytes(e,t){const r=e.getReader();let n;while(!(n=await r.read()).done){t(n.value)}}function getLines(e){let t;let r;let n;let i=false;return function s(o){if(t===undefined){t=o;r=0;n=-1}else{t=concat(t,o)}const a=t.length;let f=0;while(r<a){if(i){if(t[r]===10){f=++r}i=false}let s=-1;for(;r<a&&s===-1;++r){switch(t[r]){case 58:if(n===-1){n=r-f}break;case 13:i=true;case 10:s=r;break}}if(s===-1){break}e(t.subarray(f,s),n);f=r;n=-1}if(f===a){t=undefined}else if(f!==0){t=t.subarray(f);r-=f}}}function getMessages(e,t,r){let n=newMessage();const i=new TextDecoder;return function s(o,a){if(o.length===0){r===null||r===void 0?void 0:r(n);n=newMessage()}else if(a>0){const r=i.decode(o.subarray(0,a));const s=a+(o[a+1]===32?2:1);const f=i.decode(o.subarray(s));switch(r){case"data":n.data=n.data?n.data+"\n"+f:f;break;case"event":n.event=f;break;case"id":e(n.id=f);break;case"retry":const r=parseInt(f,10);if(!isNaN(r)){t(n.retry=r)}break}}}}function concat(e,t){const r=new Uint8Array(e.length+t.length);r.set(e);r.set(t,e.length);return r}function newMessage(){return{data:"",event:"",id:"",retry:undefined}}var __rest=undefined&&undefined.__rest||function(e,t){var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0)r[n]=e[n];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++){if(t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i]))r[n[i]]=e[n[i]]}return r};const EventStreamContentType="text/event-stream";const DefaultRetryInterval=1e3;const LastEventId="last-event-id";function fetchEventSource(e,t){var{signal:r,headers:n,onopen:i,onmessage:s,onclose:o,onerror:a,openWhenHidden:f,fetch:u}=t,c=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,h)=>{const l=Object.assign({},n);if(!l.accept){l.accept=EventStreamContentType}let d;function y(){d.abort();if(!document.hidden){b()}}if(!f){document.addEventListener("visibilitychange",y)}let p=DefaultRetryInterval;let w=0;function g(){document.removeEventListener("visibilitychange",y);window.clearTimeout(w);d.abort()}r===null||r===void 0?void 0:r.addEventListener("abort",(()=>{g();t()}));const v=u!==null&&u!==void 0?u:window.fetch;const m=i!==null&&i!==void 0?i:defaultOnOpen;async function b(){var r;d=new AbortController;try{const r=await v(e,Object.assign(Object.assign({},c),{headers:l,signal:d.signal}));await m(r);await getBytes(r.body,getLines(getMessages((e=>{if(e){l[LastEventId]=e}else{delete l[LastEventId]}}),(e=>{p=e}),s)));o===null||o===void 0?void 0:o();g();t()}catch(e){if(!d.signal.aborted){try{const t=(r=a===null||a===void 0?void 0:a(e))!==null&&r!==void 0?r:p;window.clearTimeout(w);w=window.setTimeout(b,t)}catch(e){g();h(e)}}}}b()}))}function defaultOnOpen(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(EventStreamContentType))){throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}}function Base64EncodeUrl(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function getTimestamp(){return Math.floor(Date.now()/1e3)}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,o=0,a="";i=r.charAt(o++);~i&&(n=s%4?64*n+i:i,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function t$1(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r$1(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return r$1(t)}}function n$1(e){this.message=e}function o(e,t){if("string"!=typeof e)throw new n$1("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(t$1(e.split(".")[r]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{clientId;redirectUri;accessType="online";domain="http://api.nylas.com";versioned=false;Storage;hosted=false;multiAccount=false;loginId="";constructor(e){this.clientId=e.clientId;this.redirectUri=e.redirectUri;if(e.domain){this.domain=e.domain;const t=this.domain.substring(this.domain.length-3);if(t.includes("/v")){this.versioned=true}}if(e.multiAccount){this.multiAccount=e.multiAccount}if(e.sw){const e=new IndexedDBStorage;this.Storage=new Storage(e)}else{this.Storage=new Storage}if(e.accessType){this.accessType=e.accessType}if(e.loginId){this.loginId=e.loginId}if(e.hosted){this.hosted=e.hosted}this.codeExchange(null)}async validateAccessToken(e=""){const{access_token:t}=await this.Storage.getGrant(e,this.multiAccount);try{const e=await fetch(`${this.domain}/connect/tokeninfo?access_token=${t}`,{method:"GET"});const r=await e.json();if(!r.data){return false}return true}catch(e){return false}}async validateIDToken(e=""){const{id_token:t}=await this.Storage.getGrant(e,this.multiAccount);try{const e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${t}`,{method:"GET"});if(e.status!==200){return false}const r=await e.json();if(!r.data){return false}return true}catch(e){return false}}getDomain(){return this.domain}async auth(e){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){await this.hostedSetCodeChallenge()}const t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){const t=await this.getCodeChallege();let r=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(t){r+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`}if(e.provider){r+=`&provider=${e.provider}`}if(e.loginHint){r+=`&login_hint=${e.loginHint}`;if(e.includeGrantScopes){r+=`&include_grant_scopes=${e.includeGrantScopes}`}}if(e.scope){r+=`&scope=${e.scope.join(" ")}`}if(e.prompt){r+=`&prompt=${e.prompt}`}if(e.metadata){r+=`&metadata=${e.metadata}`}if(e.state||this.loginId){r+=`&state=${this.loginId?this.loginId:e.state}`}return r}async generateReauthURL(e,t){if(!e){throw new Error("Grant ID is required")}const r=await this.Storage.getUserToken(e);const n=await this.getCodeChallege();let i=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(n){i+=`&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`}if(r?.provider){i+=`&provider=${r.provider}`}if(r?.email){i+=`&login_hint=${r.email}`}if(t){i+=`&scope=${t.join(" ")}`}return i}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=v4();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){const e=await this.Storage.getPKCE();if(e){return}console.warn("Code challenge is recomended");return}this.Storage.setPKCE(t)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){console.warn("Code challenge is recomended");return""}return t}const e=await this.Storage.getPKCE();if(e){const t=sha256.exports.sha256(e);let r=Buffer.from(t).toString("base64");r=Base64EncodeUrl(r);return r}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){return false}const e=await this.Storage.getUserTokens();if(e&&e.length>0){if(this.multiAccount){await this.generateCodeChallenge()}return true}await this.generateCodeChallenge();return false}isMultiAccount(){return this.multiAccount}async logout(){const e=await this.getProfile();await this.Storage.clearSession();const t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;if(e){t=await this.Storage.getUserToken(e)}else{t=await this.Storage.getUserToken()}if(t){return t}return null}async getProfiles(){const e=await this.Storage.getUserTokens();if(e){return e}return null}async removeProfile(e){await this.Storage.removeUserToken(e);await this.Storage.removeGrant(e);return null}async authIMAP(e){const t=await this.getCodeChallege();const r={imap_username:e.username,imap_password:e.password,imap_host:e.hostIMAP,imap_port:e.portIMAP,type:e.type,smtp_host:e.hostSMTP,smtp_port:e.portSMTP,provider:e.provider,redirect_uri:this.redirectUri,state:e.state,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){r.id=this.loginId}if(t!=""){r.code_challenge=t;r.code_challenge_method="S256"}const n=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(r)});const i=await n.json();return i}async authEWS(e){const t=await this.getCodeChallege();const r={...e,redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){r.id=this.loginId}if(t!=""){r.code_challenge=t;r.code_challenge_method="S256"}const n=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(r)});const i=await n.json();return i}async detectEmail(e){const t=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${e}`,{method:"POST",headers:new Headers({"content-type":"application/json"})});const r=await t.json();return r.data}async applicationInfo(){const e=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});const t=await e.json();return t.data}async getAvailableProviders(){const e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});if(e){const t=await e.json();const r=t.data;return r}return null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",(t=>e(t)))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",(t=>e(t)))}onLoginFail(e){window.addEventListener("onLoginFail",(t=>e(t)))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",(t=>e(t)))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",(t=>e(t)))}onSessionExpired(e){window.addEventListener("onSessionExpired",(t=>e(t)))}async codeExchange(e){let t=new URLSearchParams(window.location.search);if(e){t=new URLSearchParams(e)}const r=t.get("code");const n=t.get("state");const i=t.get("error");const s=t.get("error_description");const o=t.get("error_code");if(i&&s&&o){const e={detail:{error:i,error_description:s,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}if(!r){console.warn("No code found");return false}if(window.opener&&window.name==="uas-popup"){console.warn("Popup window detected");return false}const a=await this.Storage.getPKCE();if(!a){console.warn("No code verifier found");return false}try{const e={client_id:this.clientId,redirect_uri:this.redirectUri,code:r,grant_type:"authorization_code",code_verifier:a};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const i=await t.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(i);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(n){e.data.state=n}const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t));window.history.pushState({},document.title,window.location.pathname)}}this.Storage.removePKCE();return true}catch(i){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}}async tokenExchange(e=""){const{refresh_token:t}=await this.Storage.getGrant(e,this.multiAccount);try{const r={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:t,grant_type:"refresh_token"};const n=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(r)});const i=await n.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=getTimestamp();i.expires_in=t+i.expires_in;this.Storage.setGrant(i,this.multiAccount);const r=await this.validateIDToken(e);if(!r){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const n={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",n));return true}this.Storage.removePKCE()}catch(e){const t={detail:e};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",t));return false}}async handleCodeExchangeResponse(e){const t=true;if(e.error){return{data:e,valid:false}}const r=getTimestamp();e.expires_in=r+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const n=o(e.id_token);n.status="authenticated";this.Storage.setUserToken(n);const i=await this.validateIDToken(n.sub);if(!i){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const r=600;const n=window.screenX+(window.outerWidth-t)/2;const i=window.screenY+(window.outerHeight-r)/2.5;const s=`uas-popup`;const o=e;const a=window.open(o,s,`width=${t},height=${r},left=${n},top=${i}`);if(!a){return}const f=setInterval((async()=>{if(a.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));f&&clearInterval(f);return}try{const e=a.location.href.split("?");if(!e[0]){return}const t=a.location.search;a.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);a.close();if(e){location.reload()}f&&clearInterval(f);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=getTimestamp();const{access_token:r,expires_in:n}=await this.Storage.getGrant(e,this.multiAccount);const i=r;if(i){if(n&&n>getTimestamp()){const e=n-t;if(e>30){return i}}}await this.tokenExchange(e);const s=await this.Storage.getGrant(e,this.multiAccount);return s.access_token}async sse(e,t){const r=t.headers||{};const n=r["Grant-ID"];let i="";if(this.multiAccount){if(!n){throw new Error("Grant ID is required for multi account calls")}i=await this.getAccessToken(n)}else{i=await this.getAccessToken()}delete r["Grant-ID"];r["Authorization"]=`Bearer ${i}`;if(!r["content-type"]){r["content-type"]="application/json"}return fetchEventSource(`${this.domain}/${e}`,{...t,headers:r})}async fetch(e,t,r=true,n){let i="";let s=1;if(this.multiAccount){if(!t.grant_id){throw new Error("Grant ID is required for multi account calls")}const e=await this.getProfiles();s=e?e.length:1;i=await this.getAccessToken(t.grant_id)}else{i=await this.getAccessToken()}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${i}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${i}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const i=await fetch(`${n||this.domain}/${e}`,{...t,headers:o});if(!r){return i}const a=await(i?.json());const f=await this.isAuthenticatedResponse(i.status,a);if(!f){if(s>1){const e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized";await this.Storage.setUserToken(e);const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{const e=await this.Storage.getUserToken();const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t));this.logout()}return}return a}catch(e){throw e}}async fetchRequest(e,t,r,n=true,i,s){const o=await this.isLoggedIn();const a=new URL(e,i??this.domain);const f=new Headers;f.append("Accept","application/json");f.append("Content-Type","application/json");f.append("User-Agent","nylas-identity");if(o){const e=await this.getAccessToken();f.append("Authorization",`Bearer ${e}`)}const u=await fetch(a.toString(),{method:t||"GET",headers:f,mode:"cors",referrer:location.origin,body:r?JSON.stringify(r):undefined,...s||{}});if(!n){return u.body}const c=await u.json();return c}async isAuthenticatedResponse(e,t){if(e==401&&t?.error?.type=="token.unauthorized_access"){return false}return true}addAPIKey(e,t,r){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:true,iat:getTimestamp(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e});this.Storage.setGrant({grant_id:e,access_token:r,expires_in:2e9},this.multiAccount)}}var react_production_min={};
8
8
  /**
9
9
  * @license React
10
10
  * react.production.min.js
@@ -13,5 +13,5 @@ import{h,r as registerInstance,c as createEvent,H as Host,a as getElement}from".
13
13
  *
14
14
  * This source code is licensed under the MIT license found in the
15
15
  * LICENSE file in the root directory of this source tree.
16
- */var l=Symbol.for("react.element"),n=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),u=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),z=Symbol.iterator;function A(e){if(null===e||"object"!==typeof e)return null;e=z&&e[z]||e["@@iterator"];return"function"===typeof e?e:null}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(e,t,r){this.props=e;this.context=t;this.refs=D;this.updater=r||B}E.prototype.isReactComponent={};E.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};E.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(e,t,r){this.props=e;this.context=t;this.refs=D;this.updater=r||B}var H=G.prototype=new F;H.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;var I=Array.isArray,J=Object.prototype.hasOwnProperty,K={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function M(e,t,r){var n,i={},s=null,o=null;if(null!=t)for(n in void 0!==t.ref&&(o=t.ref),void 0!==t.key&&(s=""+t.key),t)J.call(t,n)&&!L.hasOwnProperty(n)&&(i[n]=t[n]);var a=arguments.length-2;if(1===a)i.children=r;else if(1<a){for(var f=Array(a),u=0;u<a;u++)f[u]=arguments[u+2];i.children=f}if(e&&e.defaultProps)for(n in a=e.defaultProps,a)void 0===i[n]&&(i[n]=a[n]);return{$$typeof:l,type:e,key:s,ref:o,props:i,_owner:K.current}}function N(e,t){return{$$typeof:l,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function O(e){return"object"===typeof e&&null!==e&&e.$$typeof===l}function escape(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}var P=/\/+/g;function Q(e,t){return"object"===typeof e&&null!==e&&null!=e.key?escape(""+e.key):t.toString(36)}function R(e,t,r,i,s){var o=typeof e;if("undefined"===o||"boolean"===o)e=null;var a=!1;if(null===e)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case l:case n:a=!0}}if(a)return a=e,s=s(a),e=""===i?"."+Q(a,0):i,I(s)?(r="",null!=e&&(r=e.replace(P,"$&/")+"/"),R(s,t,r,"",(function(e){return e}))):null!=s&&(O(s)&&(s=N(s,r+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(P,"$&/")+"/")+e)),t.push(s)),1;a=0;i=""===i?".":i+":";if(I(e))for(var f=0;f<e.length;f++){o=e[f];var u=i+Q(o,f);a+=R(o,t,r,u,s)}else if(u=A(e),"function"===typeof u)for(e=u.call(e),f=0;!(o=e.next()).done;)o=o.value,u=i+Q(o,f++),a+=R(o,t,r,u,s);else if("object"===o)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function S(e,t,r){if(null==e)return e;var n=[],i=0;R(e,n,"","",(function(e){return t.call(r,e,i++)}));return n}function T(e){if(-1===e._status){var t=e._result;t=t();t.then((function(t){if(0===e._status||-1===e._status)e._status=1,e._result=t}),(function(t){if(0===e._status||-1===e._status)e._status=2,e._result=t}));-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var U={current:null},V={transition:null},W={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:V,ReactCurrentOwner:K};react_production_min.Children={map:S,forEach:function(e,t,r){S(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;S(e,(function(){t++}));return t},toArray:function(e){return S(e,(function(e){return e}))||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};react_production_min.Component=E;react_production_min.Fragment=p;react_production_min.Profiler=r;react_production_min.PureComponent=G;react_production_min.StrictMode=q;react_production_min.Suspense=w;react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W;react_production_min.cloneElement=function(e,t,r){if(null===e||void 0===e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=C({},e.props),i=e.key,s=e.ref,o=e._owner;if(null!=t){void 0!==t.ref&&(s=t.ref,o=K.current);void 0!==t.key&&(i=""+t.key);if(e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(f in t)J.call(t,f)&&!L.hasOwnProperty(f)&&(n[f]=void 0===t[f]&&void 0!==a?a[f]:t[f])}var f=arguments.length-2;if(1===f)n.children=r;else if(1<f){a=Array(f);for(var u=0;u<f;u++)a[u]=arguments[u+2];n.children=a}return{$$typeof:l,type:e.type,key:i,ref:s,props:n,_owner:o}};react_production_min.createContext=function(e){e={$$typeof:u,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};e.Provider={$$typeof:t,_context:e};return e.Consumer=e};react_production_min.createElement=M;react_production_min.createFactory=function(e){var t=M.bind(null,e);t.type=e;return t};react_production_min.createRef=function(){return{current:null}};react_production_min.forwardRef=function(e){return{$$typeof:v,render:e}};react_production_min.isValidElement=O;react_production_min.lazy=function(e){return{$$typeof:y,_payload:{_status:-1,_result:e},_init:T}};react_production_min.memo=function(e,t){return{$$typeof:x,type:e,compare:void 0===t?null:t}};react_production_min.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}};react_production_min.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};react_production_min.useCallback=function(e,t){return U.current.useCallback(e,t)};react_production_min.useContext=function(e){return U.current.useContext(e)};react_production_min.useDebugValue=function(){};react_production_min.useDeferredValue=function(e){return U.current.useDeferredValue(e)};react_production_min.useEffect=function(e,t){return U.current.useEffect(e,t)};react_production_min.useId=function(){return U.current.useId()};react_production_min.useImperativeHandle=function(e,t,r){return U.current.useImperativeHandle(e,t,r)};react_production_min.useInsertionEffect=function(e,t){return U.current.useInsertionEffect(e,t)};react_production_min.useLayoutEffect=function(e,t){return U.current.useLayoutEffect(e,t)};react_production_min.useMemo=function(e,t){return U.current.useMemo(e,t)};react_production_min.useReducer=function(e,t,r){return U.current.useReducer(e,t,r)};react_production_min.useRef=function(e){return U.current.useRef(e)};react_production_min.useState=function(e){return U.current.useState(e)};react_production_min.useSyncExternalStore=function(e,t,r){return U.current.useSyncExternalStore(e,t,r)};react_production_min.useTransition=function(){return U.current.useTransition()};react_production_min.version="18.2.0";const LoginRequired=({authenticationUrl:e})=>h("div",{class:"login-required"},h("div",{class:"card"},h("p",null,"Log into your account to use the Scheduler Editor."),h("button",{class:"google-button",onClick:async t=>{t.preventDefault();const r=await e("google");if(r){window.location.href=r}else{console.error(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},h("span",{class:"icon"},h("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),h("button",{class:"microsoft-button",onClick:async t=>{t.preventDefault();const r=await e("microsoft");if(r){window.location.href=r}else{console.error(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},h("span",{class:"icon"},h("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),h("button",{class:"other-provider-button",onClick:async t=>{t.preventDefault();const r=await e();if(r){window.location.href=r}else{console.error(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},"View all providers ",h("chevron-icon",{width:"17",height:"17"})),h("small",{class:"disclaimer-text"},"* You will be redirected to authenticate your account.")));const nylasSchedulerEditorCss=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.05), 0px 10px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}div.scheduler-editor-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900)}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;width:858px;margin:0;font-size:18px;line-height:24px;font-weight:600}@media screen and (max-width: 768px){div.scheduler-editor-header h1.scheduler-editor-title{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary)}div.scheduler-editor-header button:disabled{cursor:not-allowed}nylas-editor-tabs{width:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;max-width:fit-content;align-self:center}.login-required{display:flex;flex-direction:column;padding:2rem 1rem;background-color:var(--nylas-base-25)}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem}';const NylasSchedulerEditorStyle0=nylasSchedulerEditorCss;const NylasSchedulerEditor=class{constructor(e){registerInstance(this,e);this.init=createEvent(this,"init",7);this.loggedIn=createEvent(this,"loggedIn",7);this.loggedOut=createEvent(this,"loggedOut",7);this.schedulerConfigCloseClicked=createEvent(this,"schedulerConfigCloseClicked",7);this.handleSchedulerConfigCloseClicked=e=>{this.schedulerConfigCloseClicked.emit(this.host)};this.authenticationUrl=async e=>{if(!this.nylasApiRequest){console.error(`[nylas-scheduler-editor] Nylas API Request is not initialized.`);return""}const t=await this.nylasApiRequest.authenticationUrl({provider:e});return t||""};this.defaultRequiresSessionAuth=true;this.configurationId=undefined;this.nylasApiRequest=undefined;this.nylasSessionsConfig=undefined;this.defaultAuthArgs=undefined;this.eventOverrides={};this.schedulerPreviewLink="";this.defaultSchedulerConfigStoreState=undefined;this.mode="app";this.automaticComponentRegistration=true}connectedCallback(){debug(`[nylas-scheduler-editor] connectedCallback`)}async componentWillLoad(){debug(`[nylas-scheduler-editor] componentWillLoad`);this.stores={schedulerConfig:CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigStoreState})};this.stores?.schedulerConfig?.set("defaultRequiresSessionAuth",this.defaultRequiresSessionAuth);if(!this.nylasApiRequest&&this.nylasSessionsConfig){const e=new NylasSessions(this.nylasSessionsConfig);await e.isLoggedIn();e.onLoginSuccess((async()=>{const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){this.loggedIn.emit(this.host);this.loggedInHandler(e)}}));e.onLoginFail((async()=>{this.stores?.schedulerConfig?.set("currentUser",null);this.loggedOut.emit(this.host)}));this.nylasApiRequest=new NylasIdentityRequestWrapper(e)}if(this.nylasApiRequest&&this.defaultAuthArgs){this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs)}this.baseProvider=new NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const e=this.baseProvider.getStore("schedulerConfig");this.nylasSchedulerConfigConnector=new NylasSchedulerConfigConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:e});const t=this.init.emit(this.host);if(!t.defaultPrevented){const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){this.loggedIn.emit(this.host);await this.loggedInHandler(e)}else{this.stores?.schedulerConfig?.set("currentUser",null);this.loggedOut.emit(this.host)}}this.stores?.schedulerConfig?.onChange("selectedConfiguration",(async e=>{if(e&&e.id){this.configurationId=e.id}}));this.baseProvider?.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){debug(`[nylas-scheduler-editor] componentDidLoad`);this.baseProvider?.componentDidLoad()}componentDisconnected(){this.baseProvider?.componentDisconnected()}defaultRequiresSessionAuthChanged(e){this.stores?.schedulerConfig?.set("defaultRequiresSessionAuth",e)}async configurationIdChanged(e){if(e){await(this.nylasSchedulerConfigConnector?.schedulerConfig?.getConfigurationById(e));this.stores?.schedulerConfig?.set("action","edit")}else{this.stores?.schedulerConfig?.set("selectedConfiguration",{});this.stores?.schedulerConfig?.set("action",null)}}async store(){return this.stores?.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async loggedInHandler(e){this.stores?.schedulerConfig?.set("currentUser",e);if(!this.nylasSchedulerConfigConnector){return}if(this.configurationId){await(this.nylasSchedulerConfigConnector.schedulerConfig?.getConfigurationById(this.configurationId))}await(this.nylasSchedulerConfigConnector.schedulerConfig?.getCalendars())}render(){return h(Host,{key:"14880638bcb9c031f748d72fe0052b6eb0df463d"},h("div",{key:"f0ee0e9a97eddbd350dfc41469257475e6178e3d",class:"scheduler-editor-header",part:"nse__header"},h("h1",{key:"eb85113f9650853bb6f3f348e6517ba83112f28f",class:"scheduler-editor-title",part:"nse__title"},h("calendar-icon",{key:"48e6edb5828fbdb111a3360a5c49ef762008c69a",width:"18",height:"18"}),"Scheduler editor"),h("button",{key:"f3d02137c2a999e6305b20b6735efc77370a6a83",class:"scheduler-editor-close",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},h("close-icon",{key:"05280d7af113731d30b659d9de308b23aa3ea014",width:"18",height:"18"}))),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&h("div",{class:"list-configurations"},h("nylas-list-configurations",null)),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&h("nylas-editor-tabs",{mode:"composable"},h("nylas-event-info",null,h("div",{slot:"inputs"},h("nylas-event-title",null),h("nylas-event-duration",null),h("nylas-location-component",null))),h("nylas-booking-calendar-picker",null)),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&h("nylas-editor-tabs",{mode:this.mode},this.mode==="composable"&&h("slot",null)),!this.stores?.schedulerConfig?.state.currentUser&&h("slot",{name:"login-required"},h(LoginRequired,{authenticationUrl:this.authenticationUrl})))}get host(){return getElement(this)}static get watchers(){return{defaultRequiresSessionAuth:["defaultRequiresSessionAuthChanged"],configurationId:["configurationIdChanged"]}}};NylasSchedulerEditor.style=NylasSchedulerEditorStyle0;export{NylasSchedulerEditor as nylas_scheduler_editor};
17
- //# sourceMappingURL=p-665ef10b.entry.js.map
16
+ */var l=Symbol.for("react.element"),n=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),u=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),z=Symbol.iterator;function A(e){if(null===e||"object"!==typeof e)return null;e=z&&e[z]||e["@@iterator"];return"function"===typeof e?e:null}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(e,t,r){this.props=e;this.context=t;this.refs=D;this.updater=r||B}E.prototype.isReactComponent={};E.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};E.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(e,t,r){this.props=e;this.context=t;this.refs=D;this.updater=r||B}var H=G.prototype=new F;H.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;var I=Array.isArray,J=Object.prototype.hasOwnProperty,K={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function M(e,t,r){var n,i={},s=null,o=null;if(null!=t)for(n in void 0!==t.ref&&(o=t.ref),void 0!==t.key&&(s=""+t.key),t)J.call(t,n)&&!L.hasOwnProperty(n)&&(i[n]=t[n]);var a=arguments.length-2;if(1===a)i.children=r;else if(1<a){for(var f=Array(a),u=0;u<a;u++)f[u]=arguments[u+2];i.children=f}if(e&&e.defaultProps)for(n in a=e.defaultProps,a)void 0===i[n]&&(i[n]=a[n]);return{$$typeof:l,type:e,key:s,ref:o,props:i,_owner:K.current}}function N(e,t){return{$$typeof:l,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function O(e){return"object"===typeof e&&null!==e&&e.$$typeof===l}function escape(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}var P=/\/+/g;function Q(e,t){return"object"===typeof e&&null!==e&&null!=e.key?escape(""+e.key):t.toString(36)}function R(e,t,r,i,s){var o=typeof e;if("undefined"===o||"boolean"===o)e=null;var a=!1;if(null===e)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case l:case n:a=!0}}if(a)return a=e,s=s(a),e=""===i?"."+Q(a,0):i,I(s)?(r="",null!=e&&(r=e.replace(P,"$&/")+"/"),R(s,t,r,"",(function(e){return e}))):null!=s&&(O(s)&&(s=N(s,r+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(P,"$&/")+"/")+e)),t.push(s)),1;a=0;i=""===i?".":i+":";if(I(e))for(var f=0;f<e.length;f++){o=e[f];var u=i+Q(o,f);a+=R(o,t,r,u,s)}else if(u=A(e),"function"===typeof u)for(e=u.call(e),f=0;!(o=e.next()).done;)o=o.value,u=i+Q(o,f++),a+=R(o,t,r,u,s);else if("object"===o)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function S(e,t,r){if(null==e)return e;var n=[],i=0;R(e,n,"","",(function(e){return t.call(r,e,i++)}));return n}function T(e){if(-1===e._status){var t=e._result;t=t();t.then((function(t){if(0===e._status||-1===e._status)e._status=1,e._result=t}),(function(t){if(0===e._status||-1===e._status)e._status=2,e._result=t}));-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var U={current:null},V={transition:null},W={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:V,ReactCurrentOwner:K};react_production_min.Children={map:S,forEach:function(e,t,r){S(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;S(e,(function(){t++}));return t},toArray:function(e){return S(e,(function(e){return e}))||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};react_production_min.Component=E;react_production_min.Fragment=p;react_production_min.Profiler=r;react_production_min.PureComponent=G;react_production_min.StrictMode=q;react_production_min.Suspense=w;react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W;react_production_min.cloneElement=function(e,t,r){if(null===e||void 0===e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=C({},e.props),i=e.key,s=e.ref,o=e._owner;if(null!=t){void 0!==t.ref&&(s=t.ref,o=K.current);void 0!==t.key&&(i=""+t.key);if(e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(f in t)J.call(t,f)&&!L.hasOwnProperty(f)&&(n[f]=void 0===t[f]&&void 0!==a?a[f]:t[f])}var f=arguments.length-2;if(1===f)n.children=r;else if(1<f){a=Array(f);for(var u=0;u<f;u++)a[u]=arguments[u+2];n.children=a}return{$$typeof:l,type:e.type,key:i,ref:s,props:n,_owner:o}};react_production_min.createContext=function(e){e={$$typeof:u,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};e.Provider={$$typeof:t,_context:e};return e.Consumer=e};react_production_min.createElement=M;react_production_min.createFactory=function(e){var t=M.bind(null,e);t.type=e;return t};react_production_min.createRef=function(){return{current:null}};react_production_min.forwardRef=function(e){return{$$typeof:v,render:e}};react_production_min.isValidElement=O;react_production_min.lazy=function(e){return{$$typeof:y,_payload:{_status:-1,_result:e},_init:T}};react_production_min.memo=function(e,t){return{$$typeof:x,type:e,compare:void 0===t?null:t}};react_production_min.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}};react_production_min.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};react_production_min.useCallback=function(e,t){return U.current.useCallback(e,t)};react_production_min.useContext=function(e){return U.current.useContext(e)};react_production_min.useDebugValue=function(){};react_production_min.useDeferredValue=function(e){return U.current.useDeferredValue(e)};react_production_min.useEffect=function(e,t){return U.current.useEffect(e,t)};react_production_min.useId=function(){return U.current.useId()};react_production_min.useImperativeHandle=function(e,t,r){return U.current.useImperativeHandle(e,t,r)};react_production_min.useInsertionEffect=function(e,t){return U.current.useInsertionEffect(e,t)};react_production_min.useLayoutEffect=function(e,t){return U.current.useLayoutEffect(e,t)};react_production_min.useMemo=function(e,t){return U.current.useMemo(e,t)};react_production_min.useReducer=function(e,t,r){return U.current.useReducer(e,t,r)};react_production_min.useRef=function(e){return U.current.useRef(e)};react_production_min.useState=function(e){return U.current.useState(e)};react_production_min.useSyncExternalStore=function(e,t,r){return U.current.useSyncExternalStore(e,t,r)};react_production_min.useTransition=function(){return U.current.useTransition()};react_production_min.version="18.2.0";const LoginRequired=({authenticationUrl:e})=>h("div",{class:"login-required"},h("div",{class:"card"},h("p",null,"Log into your account to use the Scheduler Editor."),h("button",{class:"google-button",onClick:async t=>{t.preventDefault();const r=await e("google");if(r){window.location.href=r}else{console.error(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},h("span",{class:"icon"},h("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),h("button",{class:"microsoft-button",onClick:async t=>{t.preventDefault();const r=await e("microsoft");if(r){window.location.href=r}else{console.error(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},h("span",{class:"icon"},h("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),h("button",{class:"other-provider-button",onClick:async t=>{t.preventDefault();const r=await e();if(r){window.location.href=r}else{console.error(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},"View all providers ",h("chevron-icon",{width:"17",height:"17"})),h("small",{class:"disclaimer-text"},"* You will be redirected to authenticate your account.")));const nylasSchedulerEditorCss=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.05), 0px 10px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}div.scheduler-editor-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900)}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;width:858px;margin:0;font-size:18px;line-height:24px;font-weight:600}@media screen and (max-width: 768px){div.scheduler-editor-header h1.scheduler-editor-title{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary)}div.scheduler-editor-header button:disabled{cursor:not-allowed}nylas-editor-tabs{width:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;max-width:fit-content;align-self:center}.login-required{height:554px;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25)}@media screen and (max-width: 768px){.login-required{height:auto}}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem;height:554px;background:var(--nylas-base-25)}@media screen and (max-width: 768px){.list-configurations{height:auto}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}';const NylasSchedulerEditorStyle0=nylasSchedulerEditorCss;const NylasSchedulerEditor=class{constructor(e){registerInstance(this,e);this.init=createEvent(this,"init",7);this.loggedIn=createEvent(this,"loggedIn",7);this.loggedOut=createEvent(this,"loggedOut",7);this.schedulerConfigCloseClicked=createEvent(this,"schedulerConfigCloseClicked",7);this.handleSchedulerConfigCloseClicked=e=>{this.schedulerConfigCloseClicked.emit(this.host)};this.authenticationUrl=async e=>{if(!this.nylasApiRequest){console.error(`[nylas-scheduler-editor] Nylas API Request is not initialized.`);return""}const t=await this.nylasApiRequest.authenticationUrl({provider:e});return t||""};this.defaultRequiresSessionAuth=true;this.configurationId=undefined;this.nylasApiRequest=undefined;this.nylasSessionsConfig=undefined;this.defaultAuthArgs=undefined;this.eventOverrides={};this.schedulerPreviewLink="";this.defaultSchedulerConfigState=undefined;this.mode="app";this.automaticComponentRegistration=true}connectedCallback(){debug(`[nylas-scheduler-editor] connectedCallback`)}async componentWillLoad(){debug(`[nylas-scheduler-editor] componentWillLoad`);this.stores={schedulerConfig:CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigState})};if(!this.nylasApiRequest&&this.nylasSessionsConfig){const e=new NylasSessions(this.nylasSessionsConfig);await e.isLoggedIn();e.onLoginSuccess((async()=>{const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){this.loggedIn.emit(this.host);this.loggedInHandler(e)}}));e.onLoginFail((async()=>{this.stores?.schedulerConfig?.set("currentUser",null);this.loggedOut.emit(this.host)}));this.nylasApiRequest=new NylasIdentityRequestWrapper(e)}if(this.nylasApiRequest&&this.defaultAuthArgs){this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs)}this.baseProvider=new NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const e=this.baseProvider.getStore("schedulerConfig");this.nylasSchedulerConfigConnector=new NylasSchedulerConfigConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:e});const t=this.init.emit(this.host);if(!t.defaultPrevented){const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){this.loggedIn.emit(this.host);await this.loggedInHandler(e)}else{this.stores?.schedulerConfig?.set("currentUser",null);this.loggedOut.emit(this.host)}}this.stores?.schedulerConfig?.onChange("selectedConfiguration",(async e=>{if(e&&e.id){this.configurationId=e.id}}));this.baseProvider?.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){debug(`[nylas-scheduler-editor] componentDidLoad`);this.baseProvider?.componentDidLoad()}componentDisconnected(){this.baseProvider?.componentDisconnected()}async configurationIdChanged(e){if(e){await(this.nylasSchedulerConfigConnector?.schedulerConfig?.getConfigurationById(e));this.stores?.schedulerConfig?.set("action","edit")}else{this.stores?.schedulerConfig?.set("selectedConfiguration",{});this.stores?.schedulerConfig?.set("action",null)}}async store(){return this.stores?.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async loggedInHandler(e){this.stores?.schedulerConfig?.set("currentUser",e);if(!this.nylasSchedulerConfigConnector){return}if(this.configurationId){await(this.nylasSchedulerConfigConnector.schedulerConfig?.getConfigurationById(this.configurationId))}await(this.nylasSchedulerConfigConnector.schedulerConfig?.getCalendars())}render(){return h(Host,{key:"5eacdea0c9cce3941dbcc80668d79bd78ab51e53"},h("div",{key:"f17745ecf7c21920a7d6b20bca0ec840d3b26925",class:"scheduler-editor-header",part:"nse__header"},h("h1",{key:"bd6ab00923b3f4d913e346aded89982bcc002b9f",class:"scheduler-editor-title",part:"nse__title"},h("calendar-icon",{key:"8755a2e5fde1d94c87f7ae487ffc16981ec3a844",width:"18",height:"18"}),"Scheduler editor"),h("button",{key:"80e55094ce9da9ece1f6e62d2ca4892c0cc6ee7e",class:"scheduler-editor-close",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},h("close-icon",{key:"8aa07ef7733444d32d38a7e5d9e6d3d61f226331",width:"18",height:"18"}))),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&h("div",{class:"list-configurations"},h("nylas-list-configurations",null)),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&h("nylas-editor-tabs",{mode:"composable"},h("nylas-event-info",null,h("div",{slot:"inputs"},h("nylas-event-title",null),h("nylas-event-duration",null),h("nylas-location-component",null))),h("nylas-booking-calendar-picker",null)),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&h("nylas-editor-tabs",{mode:this.mode},this.mode==="composable"&&h("slot",null)),!this.stores?.schedulerConfig?.state.currentUser&&h("slot",{name:"login-required"},h(LoginRequired,{authenticationUrl:this.authenticationUrl})))}get host(){return getElement(this)}static get watchers(){return{configurationId:["configurationIdChanged"]}}};NylasSchedulerEditor.style=NylasSchedulerEditorStyle0;export{NylasSchedulerEditor as nylas_scheduler_editor};
17
+ //# sourceMappingURL=p-933c6d32.entry.js.map