@nylas/react 1.1.0-canary.9 → 1.1.1

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 (154) hide show
  1. package/README.md +110 -2
  2. package/dist/add-circle-icon_2.entry-b14ecb5c.js +25 -0
  3. package/dist/add-circle-icon_2.entry-c6211866.cjs +1 -0
  4. package/dist/archive-icon_7.entry-3fe7721a.js +75 -0
  5. package/dist/archive-icon_7.entry-54fc1f03.cjs +1 -0
  6. package/dist/arrow-icon.entry-1dfee3bc.cjs +1 -0
  7. package/dist/arrow-icon.entry-cc936041.js +15 -0
  8. package/dist/bold-icon_3.entry-4b9de887.cjs +1 -0
  9. package/dist/bold-icon_3.entry-e2a1d434.js +35 -0
  10. package/dist/button-component_2.entry-3639ade6.js +26 -0
  11. package/dist/button-component_2.entry-5666fdfa.cjs +1 -0
  12. package/dist/calendar-agenda-fill-icon_48.entry-56e364cd.js +5256 -0
  13. package/dist/calendar-agenda-fill-icon_48.entry-bf278e34.cjs +7 -0
  14. package/dist/calendar-cancel-icon.entry-ac1cb5dd.cjs +1 -0
  15. package/dist/calendar-cancel-icon.entry-dcd777cd.js +15 -0
  16. package/dist/calendar-check-icon_2.entry-6330bd2d.js +25 -0
  17. package/dist/calendar-check-icon_2.entry-7ad1b2a0.cjs +1 -0
  18. package/dist/calendar-icon.entry-5849a547.cjs +1 -0
  19. package/dist/calendar-icon.entry-8559fa0d.js +15 -0
  20. package/dist/checkbox-component_2.entry-1474c465.js +79 -0
  21. package/dist/checkbox-component_2.entry-6cf5da6b.cjs +1 -0
  22. package/dist/chevron-icon_3.entry-41170718.cjs +1 -0
  23. package/dist/chevron-icon_3.entry-cb757aa3.js +132 -0
  24. package/dist/clock-icon_4.entry-36a33de5.cjs +1 -0
  25. package/dist/clock-icon_4.entry-642f4dc6.js +45 -0
  26. package/dist/constants-50c3e067-4e027da4.cjs +15 -0
  27. package/dist/constants-50c3e067-83f1d865.js +3883 -0
  28. package/dist/copy-icon.entry-60740516.js +15 -0
  29. package/dist/copy-icon.entry-fb63cf53.cjs +1 -0
  30. package/dist/core-js-38e53e34.cjs +4 -0
  31. package/dist/core-js-a9d3b6e1.js +3297 -0
  32. package/dist/delete-icon_2.entry-45851bc5.js +25 -0
  33. package/dist/delete-icon_2.entry-d1af0606.cjs +1 -0
  34. package/dist/document-refresh-icon.entry-1731d4d9.cjs +1 -0
  35. package/dist/document-refresh-icon.entry-5db0830a.js +15 -0
  36. package/dist/dom-68f08be9.cjs +15 -0
  37. package/dist/dom-86e17616.js +664 -0
  38. package/dist/{types/elements → elements}/index.d.ts +48 -1
  39. package/dist/elements-dc5b338e-3099ee02.js +28031 -0
  40. package/dist/elements-dc5b338e-ab9afb63.cjs +16516 -0
  41. package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
  42. package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
  43. package/dist/focus-visible-e8093c16-067a8f23.js +84 -0
  44. package/dist/focus-visible-e8093c16-811f50fa.cjs +1 -0
  45. package/dist/forward-icon_6.entry-4e9c9686.cjs +3 -0
  46. package/dist/forward-icon_6.entry-e7c5fa46.js +953 -0
  47. package/dist/globe-icon.entry-74f79652.cjs +1 -0
  48. package/dist/globe-icon.entry-aa3f3ea3.js +15 -0
  49. package/dist/google-logo-icon_4.entry-0332a181.cjs +1 -0
  50. package/dist/google-logo-icon_4.entry-3fe41d69.js +673 -0
  51. package/dist/index-2a53b6a8.cjs +82 -0
  52. package/dist/index-a134f625.js +12842 -0
  53. package/dist/index.es-79f5b771-64a1baf0.cjs +7 -0
  54. package/dist/index.es-79f5b771-ce07d6fc.js +3135 -0
  55. package/dist/info-icon_2.entry-a3f40027.cjs +1 -0
  56. package/dist/info-icon_2.entry-fed731f4.js +34 -0
  57. package/dist/input-color-picker.entry-37826630.js +48 -0
  58. package/dist/input-color-picker.entry-cbdce7a1.cjs +1 -0
  59. package/dist/input-component.entry-b83b7103.js +70 -0
  60. package/dist/input-component.entry-e71b7062.cjs +1 -0
  61. package/dist/input-dropdown.entry-150819cd.cjs +1 -0
  62. package/dist/input-dropdown.entry-db0dae5f.js +134 -0
  63. package/dist/mailbox-store-9c52a3fa-04f22f60.cjs +1 -0
  64. package/dist/mailbox-store-9c52a3fa-80fe343c.js +380 -0
  65. package/dist/multi-select-dropdown.entry-629329d7.cjs +1 -0
  66. package/dist/multi-select-dropdown.entry-6b429b39.js +95 -0
  67. package/dist/nylas-booked-event-card_12.entry-660af56a.cjs +1 -0
  68. package/dist/nylas-booked-event-card_12.entry-c22c02b4.js +1133 -0
  69. package/dist/nylas-form-card.entry-2ced5eef.cjs +1 -0
  70. package/dist/nylas-form-card.entry-f3d6a1e4.js +57 -0
  71. package/dist/nylas-if-state.entry-55c32c0c.cjs +1 -0
  72. package/dist/nylas-if-state.entry-862ad978.js +94 -0
  73. package/dist/nylas-list-folders.entry-544fd38d.js +120 -0
  74. package/dist/nylas-list-folders.entry-77e936f7.cjs +1 -0
  75. package/dist/nylas-list-threads.entry-71411da7.js +70 -0
  76. package/dist/nylas-list-threads.entry-82e04782.cjs +1 -0
  77. package/dist/nylas-login.entry-3ccc2bef.cjs +1 -0
  78. package/dist/nylas-login.entry-48179c01.js +73 -0
  79. package/dist/nylas-mailbox-pagination.entry-77cf03b5.js +101 -0
  80. package/dist/nylas-mailbox-pagination.entry-d31f9aa4.cjs +1 -0
  81. package/dist/nylas-mailbox-toolbar-button.entry-33aad610.cjs +1 -0
  82. package/dist/nylas-mailbox-toolbar-button.entry-40e3c373.js +82 -0
  83. package/dist/nylas-mailbox.entry-963de1c3.cjs +1 -0
  84. package/dist/nylas-mailbox.entry-f4066fb2.js +134 -0
  85. package/dist/nylas-provider.entry-08767da3.cjs +1 -0
  86. package/dist/nylas-provider.entry-c61428b1.js +145 -0
  87. package/dist/nylas-reminder-emails.entry-cd8e1d2e.js +129 -0
  88. package/dist/nylas-reminder-emails.entry-d42a7f1d.cjs +4 -0
  89. package/dist/nylas-reminder-time_2.entry-d7115393.js +105 -0
  90. package/dist/nylas-reminder-time_2.entry-e5540fdd.cjs +1 -0
  91. package/dist/nylas-scheduler-editor.entry-65eb4938.js +1447 -0
  92. package/dist/nylas-scheduler-editor.entry-67904653.cjs +2 -0
  93. package/dist/nylas-scheduling.entry-50e41d85.cjs +1 -0
  94. package/dist/nylas-scheduling.entry-7aad4f63.js +345 -0
  95. package/dist/nylas-threads-refresh.entry-1b8befab.cjs +1 -0
  96. package/dist/nylas-threads-refresh.entry-d025575a.js +74 -0
  97. package/dist/nylas-threads-search.entry-78c06183.cjs +1 -0
  98. package/dist/nylas-threads-search.entry-a254c36e.js +69 -0
  99. package/dist/nylas-time-window-picker.entry-30baeb50.cjs +1 -0
  100. package/dist/nylas-time-window-picker.entry-89c15823.js +316 -0
  101. package/dist/nylas-view-thread.entry-939a4561.cjs +1 -0
  102. package/dist/nylas-view-thread.entry-c8d56573.js +203 -0
  103. package/dist/person-icon.entry-5ab75598.cjs +1 -0
  104. package/dist/person-icon.entry-8aef4041.js +15 -0
  105. package/dist/play-icon_2.entry-392ad303.cjs +1 -0
  106. package/dist/play-icon_2.entry-4b068c1b.js +25 -0
  107. package/dist/react.cjs +1 -0
  108. package/dist/react.js +145 -0
  109. package/dist/refresh-icon.entry-9ea254c9.cjs +1 -0
  110. package/dist/refresh-icon.entry-a754a2b5.js +15 -0
  111. package/dist/register-component-ea95564d-ab3d630f.cjs +1 -0
  112. package/dist/register-component-ea95564d-e19ec159.js +109 -0
  113. package/dist/scheduler-config-store-2a3b403d-4e10b542.cjs +1 -0
  114. package/dist/scheduler-config-store-2a3b403d-581c70cf.js +27 -0
  115. package/dist/scheduler-store-9ff4914b-6e28240e.cjs +1 -0
  116. package/dist/scheduler-store-9ff4914b-b71a0aca.js +474 -0
  117. package/dist/textarea-component.entry-70bb02bf.cjs +1 -0
  118. package/dist/textarea-component.entry-a5daab6c.js +37 -0
  119. package/dist/time-period-selector.entry-25348de7.js +80 -0
  120. package/dist/time-period-selector.entry-6306e456.cjs +1 -0
  121. package/dist/translate-icon.entry-785fa109.cjs +1 -0
  122. package/dist/translate-icon.entry-b6094ecc.js +15 -0
  123. package/dist/warning-icon.entry-4b400ee2.js +15 -0
  124. package/dist/warning-icon.entry-94e34c58.cjs +1 -0
  125. package/package.json +12 -8
  126. package/dist/elements/index.js +0 -92
  127. package/dist/elements/index.js.map +0 -1
  128. package/dist/elements/react-component-lib/createComponent.js +0 -65
  129. package/dist/elements/react-component-lib/createComponent.js.map +0 -1
  130. package/dist/elements/react-component-lib/createOverlayComponent.js +0 -98
  131. package/dist/elements/react-component-lib/createOverlayComponent.js.map +0 -1
  132. package/dist/elements/react-component-lib/index.js +0 -3
  133. package/dist/elements/react-component-lib/index.js.map +0 -1
  134. package/dist/elements/react-component-lib/interfaces.js +0 -2
  135. package/dist/elements/react-component-lib/interfaces.js.map +0 -1
  136. package/dist/elements/react-component-lib/utils/attachProps.js +0 -92
  137. package/dist/elements/react-component-lib/utils/attachProps.js.map +0 -1
  138. package/dist/elements/react-component-lib/utils/case.js +0 -7
  139. package/dist/elements/react-component-lib/utils/case.js.map +0 -1
  140. package/dist/elements/react-component-lib/utils/dev.js +0 -13
  141. package/dist/elements/react-component-lib/utils/dev.js.map +0 -1
  142. package/dist/elements/react-component-lib/utils/index.js +0 -31
  143. package/dist/elements/react-component-lib/utils/index.js.map +0 -1
  144. package/dist/index.js +0 -29
  145. package/dist/index.js.map +0 -1
  146. /package/dist/{types/elements → elements}/react-component-lib/createComponent.d.ts +0 -0
  147. /package/dist/{types/elements → elements}/react-component-lib/createOverlayComponent.d.ts +0 -0
  148. /package/dist/{types/elements → elements}/react-component-lib/index.d.ts +0 -0
  149. /package/dist/{types/elements → elements}/react-component-lib/interfaces.d.ts +0 -0
  150. /package/dist/{types/elements → elements}/react-component-lib/utils/attachProps.d.ts +0 -0
  151. /package/dist/{types/elements → elements}/react-component-lib/utils/case.d.ts +0 -0
  152. /package/dist/{types/elements → elements}/react-component-lib/utils/dev.d.ts +0 -0
  153. /package/dist/{types/elements → elements}/react-component-lib/utils/index.d.ts +0 -0
  154. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
@@ -0,0 +1,1447 @@
1
+ var P = Object.defineProperty;
2
+ var O = (r, t, n) => t in r ? P(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
3
+ var b = (r, t, n) => (O(r, typeof t != "symbol" ? t + "" : t, n), n);
4
+ import { p as process, i as commonjsGlobal, r as registerInstance, c as createEvent, d as debug, N as NylasIdentityRequestWrapper, h, H as Host, g as getElement, B as Buffer, F as Fragment, j as dataResponse } from "./index-a134f625.js";
5
+ import { N as NylasBaseProvider, X as Xr } from "./index.es-79f5b771-ce07d6fc.js";
6
+ import { C as CreateNylasSchedulerConfigStore } from "./scheduler-config-store-2a3b403d-581c70cf.js";
7
+ import "react";
8
+ import "react-dom";
9
+ class NylasSchedulerConfigAPIConnector {
10
+ constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
11
+ this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
12
+ }
13
+ async currentUser() {
14
+ return this.nylasApiRequest ? this.nylasApiRequest.currentUser() : (console.warn("Nylas API Request is not initialized"), null);
15
+ }
16
+ async getCalendars() {
17
+ var s;
18
+ if (!this.nylasApiRequest)
19
+ return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
20
+ message: "Error fetching calendars: Nylas API Request is not initialized"
21
+ });
22
+ const [t, n] = await this.nylasApiRequest.request({
23
+ method: "GET",
24
+ path: "calendars"
25
+ });
26
+ return n ? dataResponse(null, {
27
+ message: "Error fetching calendars: " + n.message
28
+ }) : Xr(t) ? dataResponse(null, {
29
+ message: "Error fetching calendars: " + ((s = t.error) == null ? void 0 : s.message)
30
+ }) : (this.nylasSchedulerConfigStore.state.calendars = t.data, dataResponse(t.data));
31
+ }
32
+ async getConfigurationById(t, n = !1) {
33
+ var a;
34
+ if (!this.nylasApiRequest)
35
+ return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
36
+ message: "Error fetching configuration: Nylas API Request is not initialized"
37
+ });
38
+ if (!n) {
39
+ const d = this.nylasSchedulerConfigStore.state.configurations.find((l) => l.id === t);
40
+ if (d)
41
+ return this.nylasSchedulerConfigStore.state.selectedConfiguration = d, dataResponse(d);
42
+ }
43
+ const [s, c] = await this.nylasApiRequest.request({
44
+ method: "GET",
45
+ path: `scheduling/configurations/${t}`
46
+ });
47
+ return c ? dataResponse(null, {
48
+ message: "Error fetching configuration: " + c.message
49
+ }) : Xr(s) ? dataResponse(null, {
50
+ message: "Error fetching configuration: " + ((a = s.error) == null ? void 0 : a.message)
51
+ }) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = s.data, this.nylasSchedulerConfigStore.state.configurations.find((d) => d.id === t) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((d) => d.id === t ? s.data : d) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, s.data], dataResponse(s.data));
52
+ }
53
+ async getConfigurations(t) {
54
+ var a;
55
+ if (!this.nylasApiRequest)
56
+ return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
57
+ message: "Error fetching configurations: Nylas API Request is not initialized"
58
+ });
59
+ const n = 50, [s, c] = await this.nylasApiRequest.request({
60
+ method: "GET",
61
+ path: `scheduling/configurations?limit=${n}${t ? `&page_token=${t}` : ""}`
62
+ });
63
+ return c ? dataResponse(null, {
64
+ message: "Error fetching configurations: " + c.message
65
+ }) : Xr(s) ? dataResponse(null, {
66
+ message: "Error fetching configurations: " + ((a = s.error) == null ? void 0 : a.message)
67
+ }) : (this.nylasSchedulerConfigStore.state.configurations = s.data, this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor = s.next_cursor || null, dataResponse(s.data));
68
+ }
69
+ async createConfiguration(t) {
70
+ var c;
71
+ if (!this.nylasApiRequest)
72
+ return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
73
+ message: "Error creating configuration: Nylas API Request is not initialized"
74
+ });
75
+ const [n, s] = await this.nylasApiRequest.request({
76
+ method: "POST",
77
+ path: "scheduling/configurations",
78
+ body: t
79
+ });
80
+ return s ? dataResponse(null, {
81
+ message: "Error creating configuration: " + s.message
82
+ }) : Xr(n) ? dataResponse(null, {
83
+ message: "Error creating configuration: " + ((c = n.error) == null ? void 0 : c.message)
84
+ }) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
85
+ }
86
+ async updateConfiguration(t) {
87
+ var c;
88
+ if (!this.nylasApiRequest)
89
+ return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
90
+ message: "Error updating configuration: Nylas API Request is not initialized"
91
+ });
92
+ const [n, s] = await this.nylasApiRequest.request({
93
+ method: "PUT",
94
+ path: `scheduling/configurations/${t.id}`,
95
+ body: t
96
+ });
97
+ return s ? dataResponse(null, {
98
+ message: "Error updating configuration: " + s.message
99
+ }) : Xr(n) ? dataResponse(null, {
100
+ message: "Error updating configuration: " + ((c = n.error) == null ? void 0 : c.message)
101
+ }) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations.find((a) => a.id === t.id) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((a) => a.id === t.id ? n.data : a) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
102
+ }
103
+ async deleteConfiguration(t) {
104
+ var c, a;
105
+ if (!this.nylasApiRequest)
106
+ return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
107
+ message: "Error deleting configuration: Nylas API Request is not initialized"
108
+ });
109
+ const [n, s] = await this.nylasApiRequest.request({
110
+ method: "DELETE",
111
+ path: `scheduling/configurations/${t}`
112
+ });
113
+ return s ? dataResponse(null, {
114
+ message: "Error deleting configuration: " + s.message
115
+ }) : Xr(n) ? dataResponse(null, {
116
+ message: "Error deleting configuration: " + ((c = n.error) == null ? void 0 : c.message)
117
+ }) : (this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.filter((d) => d.id !== t), ((a = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : a.id) === t && this.nylasSchedulerConfigStore.resetSelectedConfiguration(), dataResponse(n.data));
118
+ }
119
+ }
120
+ class NylasSchedulerConfigConnector {
121
+ constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
122
+ this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
123
+ }
124
+ init() {
125
+ debug("NylasSchedulerConfigConnector init");
126
+ }
127
+ get schedulerConfigStore() {
128
+ return this.nylasSchedulerConfigStore;
129
+ }
130
+ get schedulerConfig() {
131
+ return this._schedulerConfigConnector ? this._schedulerConfigConnector : (this._schedulerConfigConnector = new NylasSchedulerConfigAPIConnector({
132
+ nylasApiRequest: this.nylasApiRequest,
133
+ nylasSchedulerConfigStore: this.nylasSchedulerConfigStore
134
+ }), this._schedulerConfigConnector);
135
+ }
136
+ resetStores() {
137
+ debug("NylasSchedulerConfigConnector resetStores"), this.nylasSchedulerConfigStore.reset();
138
+ }
139
+ async logout() {
140
+ debug("NylasSchedulerConfigConnector logout"), this.resetStores();
141
+ }
142
+ }
143
+ class LocalStorage {
144
+ get(t) {
145
+ return new Promise((n) => {
146
+ const s = window.localStorage.getItem(t);
147
+ n(s ? JSON.parse(s) : null);
148
+ });
149
+ }
150
+ async remove(t) {
151
+ return window.localStorage.removeItem(t), new Promise((n) => {
152
+ n(null);
153
+ });
154
+ }
155
+ set(t, n) {
156
+ return window.localStorage.setItem(t, JSON.stringify(n)), new Promise((s) => {
157
+ s(null);
158
+ });
159
+ }
160
+ }
161
+ const PKCE_KEY = "pkce", GRANT_KEY = "grant", USER_KEY = "user";
162
+ class Storage {
163
+ constructor(t) {
164
+ b(this, "Storage", new LocalStorage());
165
+ if (t) {
166
+ this.Storage = t;
167
+ return;
168
+ }
169
+ }
170
+ setPKCE(t) {
171
+ const n = Buffer.from(t);
172
+ this.Storage.set(PKCE_KEY, n.toString("base64"));
173
+ }
174
+ async getPKCE() {
175
+ try {
176
+ const t = await this.Storage.get(PKCE_KEY);
177
+ if (t)
178
+ return Buffer.from(t, "base64").toString("utf8");
179
+ } catch {
180
+ return null;
181
+ }
182
+ return null;
183
+ }
184
+ removePKCE() {
185
+ this.Storage.remove(PKCE_KEY);
186
+ }
187
+ setGrant(t, n = !1) {
188
+ const { grant_id: s } = t;
189
+ this.Storage.set(`${GRANT_KEY}${n ? "-" + s : ""}`, t);
190
+ }
191
+ removeGrant(t, n = !1) {
192
+ this.Storage.remove(`${GRANT_KEY}${n ? "-" + t : ""}`);
193
+ }
194
+ async getGrant(t, n = !1) {
195
+ const s = await this.Storage.get(`${GRANT_KEY}${n ? "-" + t : ""}`);
196
+ return s || null;
197
+ }
198
+ // setUserToken is used to store the IDToken in storage
199
+ async setUserToken(t) {
200
+ const n = await this.getUserTokens();
201
+ if (n)
202
+ if (n.find((c) => c.sub === t.sub)) {
203
+ const c = n.map((a) => (a.sub === t.sub && (a = t), a));
204
+ this.Storage.set(USER_KEY, c);
205
+ } else {
206
+ const c = [...n, t];
207
+ this.Storage.set(USER_KEY, c);
208
+ }
209
+ else
210
+ this.Storage.set(USER_KEY, [t]);
211
+ }
212
+ // getUserToken is used to retrieve a specific IDToken from storage
213
+ async getUserToken(t = "") {
214
+ const n = await this.Storage.get(USER_KEY);
215
+ return n ? t === "" ? n[0] : n.find((c) => c.sub === t) : null;
216
+ }
217
+ // getUserTokens is used to retrieve all IDTokens from storage
218
+ async getUserTokens() {
219
+ const t = await this.Storage.get(USER_KEY);
220
+ return t || null;
221
+ }
222
+ // removeUserTokens is used to remove all IDTokens from storage
223
+ removeUserTokens() {
224
+ this.Storage.remove(USER_KEY);
225
+ }
226
+ // removeUserToken is used to remove a specific IDToken from storage
227
+ async removeUserToken(t) {
228
+ const n = await this.getUserTokens(), s = n == null ? void 0 : n.filter((c) => c.sub !== t);
229
+ this.Storage.set(USER_KEY, s);
230
+ }
231
+ async clearSession() {
232
+ const t = await this.getUserTokens();
233
+ t == null || t.forEach((n) => {
234
+ this.removeGrant(n.sub);
235
+ }), this.removePKCE(), this.removeUserTokens();
236
+ }
237
+ }
238
+ class IndexedDBStorage {
239
+ constructor() {
240
+ b(this, "databaseName", "identity-db");
241
+ b(this, "storeName", "identity");
242
+ }
243
+ get(t) {
244
+ const n = this;
245
+ return new Promise((s, c) => {
246
+ n.openDatabase().then(function(a) {
247
+ const d = a.transaction(n.storeName, "readwrite"), u = d.objectStore(n.storeName).get(t);
248
+ u.onsuccess = () => {
249
+ s(u.result);
250
+ }, u.onerror = () => {
251
+ c(u.error);
252
+ }, d.oncomplete = () => {
253
+ a.close();
254
+ };
255
+ });
256
+ });
257
+ }
258
+ async remove(t) {
259
+ const n = this;
260
+ return new Promise((s, c) => {
261
+ const a = indexedDB.open(this.databaseName);
262
+ a.onupgradeneeded = function(d) {
263
+ d.target.result.createObjectStore(n.storeName);
264
+ }, a.onerror = () => {
265
+ c(a.error);
266
+ }, a.onsuccess = (d) => {
267
+ const l = d.target.result, u = l.transaction(this.storeName, "readwrite"), y = u.objectStore(this.storeName).delete(t);
268
+ y.onsuccess = () => {
269
+ s(null);
270
+ }, y.onerror = () => {
271
+ c(y.error);
272
+ }, u.oncomplete = () => {
273
+ l.close();
274
+ };
275
+ };
276
+ });
277
+ }
278
+ set(t, n) {
279
+ return new Promise((s, c) => {
280
+ const a = indexedDB.open(this.databaseName);
281
+ a.onerror = () => {
282
+ c(a.error);
283
+ }, a.onupgradeneeded = (d) => {
284
+ d.target.result.createObjectStore(this.storeName);
285
+ }, a.onsuccess = (d) => {
286
+ const l = d.target.result, u = l.transaction(this.storeName, "readwrite"), y = u.objectStore(this.storeName).put(n, t);
287
+ y.onsuccess = () => {
288
+ s(n);
289
+ }, y.onerror = () => {
290
+ c(y.error);
291
+ }, u.oncomplete = () => {
292
+ l.close();
293
+ };
294
+ };
295
+ });
296
+ }
297
+ openDatabase() {
298
+ const t = this;
299
+ return new Promise(function(n, s) {
300
+ const c = indexedDB.open(t.databaseName, 2);
301
+ c.onupgradeneeded = function(a) {
302
+ a.target.result.createObjectStore(t.storeName);
303
+ }, c.onsuccess = function(a) {
304
+ n(a.target.result);
305
+ }, c.onerror = function(a) {
306
+ s(a.error);
307
+ };
308
+ });
309
+ }
310
+ }
311
+ var sha256 = { exports: {} };
312
+ (function(module) {
313
+ (function() {
314
+ var ERROR = "input is invalid type", WINDOW = typeof window == "object", root = WINDOW ? window : {};
315
+ root.JS_SHA256_NO_WINDOW && (WINDOW = !1);
316
+ var WEB_WORKER = !WINDOW && typeof self == "object", NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
317
+ NODE_JS ? root = commonjsGlobal : WEB_WORKER && (root = self);
318
+ var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && !0 && module.exports, ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", HEX_CHARS = "0123456789abcdef".split(""), EXTRA = [-2147483648, 8388608, 32768, 128], SHIFT = [24, 16, 8, 0], K = [
319
+ 1116352408,
320
+ 1899447441,
321
+ 3049323471,
322
+ 3921009573,
323
+ 961987163,
324
+ 1508970993,
325
+ 2453635748,
326
+ 2870763221,
327
+ 3624381080,
328
+ 310598401,
329
+ 607225278,
330
+ 1426881987,
331
+ 1925078388,
332
+ 2162078206,
333
+ 2614888103,
334
+ 3248222580,
335
+ 3835390401,
336
+ 4022224774,
337
+ 264347078,
338
+ 604807628,
339
+ 770255983,
340
+ 1249150122,
341
+ 1555081692,
342
+ 1996064986,
343
+ 2554220882,
344
+ 2821834349,
345
+ 2952996808,
346
+ 3210313671,
347
+ 3336571891,
348
+ 3584528711,
349
+ 113926993,
350
+ 338241895,
351
+ 666307205,
352
+ 773529912,
353
+ 1294757372,
354
+ 1396182291,
355
+ 1695183700,
356
+ 1986661051,
357
+ 2177026350,
358
+ 2456956037,
359
+ 2730485921,
360
+ 2820302411,
361
+ 3259730800,
362
+ 3345764771,
363
+ 3516065817,
364
+ 3600352804,
365
+ 4094571909,
366
+ 275423344,
367
+ 430227734,
368
+ 506948616,
369
+ 659060556,
370
+ 883997877,
371
+ 958139571,
372
+ 1322822218,
373
+ 1537002063,
374
+ 1747873779,
375
+ 1955562222,
376
+ 2024104815,
377
+ 2227730452,
378
+ 2361852424,
379
+ 2428436474,
380
+ 2756734187,
381
+ 3204031479,
382
+ 3329325298
383
+ ], OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"], blocks = [];
384
+ (root.JS_SHA256_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(r) {
385
+ return Object.prototype.toString.call(r) === "[object Array]";
386
+ }), ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(r) {
387
+ return typeof r == "object" && r.buffer && r.buffer.constructor === ArrayBuffer;
388
+ });
389
+ var createOutputMethod = function(r, t) {
390
+ return function(n) {
391
+ return new Sha256(t, !0).update(n)[r]();
392
+ };
393
+ }, createMethod = function(r) {
394
+ var t = createOutputMethod("hex", r);
395
+ NODE_JS && (t = nodeWrap(t, r)), t.create = function() {
396
+ return new Sha256(r);
397
+ }, t.update = function(c) {
398
+ return t.create().update(c);
399
+ };
400
+ for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
401
+ var s = OUTPUT_TYPES[n];
402
+ t[s] = createOutputMethod(s, r);
403
+ }
404
+ return t;
405
+ }, nodeWrap = function(method, is224) {
406
+ var crypto = eval("require('crypto')"), Buffer = eval("require('buffer').Buffer"), algorithm = is224 ? "sha224" : "sha256", nodeMethod = function(r) {
407
+ if (typeof r == "string")
408
+ return crypto.createHash(algorithm).update(r, "utf8").digest("hex");
409
+ if (r == null)
410
+ throw new Error(ERROR);
411
+ return r.constructor === ArrayBuffer && (r = new Uint8Array(r)), Array.isArray(r) || ArrayBuffer.isView(r) || r.constructor === Buffer ? crypto.createHash(algorithm).update(new Buffer(r)).digest("hex") : method(r);
412
+ };
413
+ return nodeMethod;
414
+ }, createHmacOutputMethod = function(r, t) {
415
+ return function(n, s) {
416
+ return new HmacSha256(n, t, !0).update(s)[r]();
417
+ };
418
+ }, createHmacMethod = function(r) {
419
+ var t = createHmacOutputMethod("hex", r);
420
+ t.create = function(c) {
421
+ return new HmacSha256(c, r);
422
+ }, t.update = function(c, a) {
423
+ return t.create(c).update(a);
424
+ };
425
+ for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
426
+ var s = OUTPUT_TYPES[n];
427
+ t[s] = createHmacOutputMethod(s, r);
428
+ }
429
+ return t;
430
+ };
431
+ function Sha256(r, t) {
432
+ 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) : this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], r ? (this.h0 = 3238371032, this.h1 = 914150663, this.h2 = 812702999, this.h3 = 4144912697, this.h4 = 4290775857, this.h5 = 1750603025, this.h6 = 1694076839, this.h7 = 3204075428) : (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 = !1, this.first = !0, this.is224 = r;
433
+ }
434
+ Sha256.prototype.update = function(r) {
435
+ if (!this.finalized) {
436
+ var t, n = typeof r;
437
+ if (n !== "string") {
438
+ if (n === "object") {
439
+ if (r === null)
440
+ throw new Error(ERROR);
441
+ if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
442
+ r = new Uint8Array(r);
443
+ else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
444
+ throw new Error(ERROR);
445
+ } else
446
+ throw new Error(ERROR);
447
+ t = !0;
448
+ }
449
+ for (var s, c = 0, a, d = r.length, l = this.blocks; c < d; ) {
450
+ if (this.hashed && (this.hashed = !1, l[0] = this.block, l[16] = l[1] = l[2] = l[3] = l[4] = l[5] = l[6] = l[7] = l[8] = l[9] = l[10] = l[11] = l[12] = l[13] = l[14] = l[15] = 0), t)
451
+ for (a = this.start; c < d && a < 64; ++c)
452
+ l[a >> 2] |= r[c] << SHIFT[a++ & 3];
453
+ else
454
+ for (a = this.start; c < d && a < 64; ++c)
455
+ s = r.charCodeAt(c), s < 128 ? l[a >> 2] |= s << SHIFT[a++ & 3] : s < 2048 ? (l[a >> 2] |= (192 | s >> 6) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s & 63) << SHIFT[a++ & 3]) : s < 55296 || s >= 57344 ? (l[a >> 2] |= (224 | s >> 12) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s >> 6 & 63) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s & 63) << SHIFT[a++ & 3]) : (s = 65536 + ((s & 1023) << 10 | r.charCodeAt(++c) & 1023), l[a >> 2] |= (240 | s >> 18) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s >> 12 & 63) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s >> 6 & 63) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s & 63) << SHIFT[a++ & 3]);
456
+ this.lastByteIndex = a, this.bytes += a - this.start, a >= 64 ? (this.block = l[16], this.start = a - 64, this.hash(), this.hashed = !0) : this.start = a;
457
+ }
458
+ return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0, this.bytes = this.bytes % 4294967296), this;
459
+ }
460
+ }, Sha256.prototype.finalize = function() {
461
+ if (!this.finalized) {
462
+ this.finalized = !0;
463
+ var r = this.blocks, t = this.lastByteIndex;
464
+ r[16] = this.block, r[t >> 2] |= EXTRA[t & 3], this.block = r[16], t >= 56 && (this.hashed || this.hash(), r[0] = this.block, r[16] = r[1] = r[2] = r[3] = r[4] = r[5] = r[6] = r[7] = r[8] = r[9] = r[10] = r[11] = r[12] = r[13] = r[14] = r[15] = 0), r[14] = this.hBytes << 3 | this.bytes >>> 29, r[15] = this.bytes << 3, this.hash();
465
+ }
466
+ }, Sha256.prototype.hash = function() {
467
+ var r = this.h0, t = this.h1, n = this.h2, s = this.h3, c = this.h4, a = this.h5, d = this.h6, l = this.h7, u = this.blocks, f, y, g, m, p, w, S, x, v, R, _;
468
+ for (f = 16; f < 64; ++f)
469
+ p = u[f - 15], y = (p >>> 7 | p << 25) ^ (p >>> 18 | p << 14) ^ p >>> 3, p = u[f - 2], g = (p >>> 17 | p << 15) ^ (p >>> 19 | p << 13) ^ p >>> 10, u[f] = u[f - 16] + y + u[f - 7] + g << 0;
470
+ for (_ = t & n, f = 0; f < 64; f += 4)
471
+ this.first ? (this.is224 ? (x = 300032, p = u[0] - 1413257819, l = p - 150054599 << 0, s = p + 24177077 << 0) : (x = 704751109, p = u[0] - 210244248, l = p - 1521486534 << 0, s = p + 143694565 << 0), this.first = !1) : (y = (r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10), g = (c >>> 6 | c << 26) ^ (c >>> 11 | c << 21) ^ (c >>> 25 | c << 7), x = r & t, m = x ^ r & n ^ _, S = c & a ^ ~c & d, p = l + g + S + K[f] + u[f], w = y + m, l = s + p << 0, s = p + w << 0), y = (s >>> 2 | s << 30) ^ (s >>> 13 | s << 19) ^ (s >>> 22 | s << 10), g = (l >>> 6 | l << 26) ^ (l >>> 11 | l << 21) ^ (l >>> 25 | l << 7), v = s & r, m = v ^ s & t ^ x, S = l & c ^ ~l & a, p = d + g + S + K[f + 1] + u[f + 1], w = y + m, d = n + p << 0, n = p + w << 0, y = (n >>> 2 | n << 30) ^ (n >>> 13 | n << 19) ^ (n >>> 22 | n << 10), g = (d >>> 6 | d << 26) ^ (d >>> 11 | d << 21) ^ (d >>> 25 | d << 7), R = n & s, m = R ^ n & r ^ v, S = d & l ^ ~d & c, p = a + g + S + K[f + 2] + u[f + 2], w = y + m, a = t + p << 0, t = p + w << 0, y = (t >>> 2 | t << 30) ^ (t >>> 13 | t << 19) ^ (t >>> 22 | t << 10), g = (a >>> 6 | a << 26) ^ (a >>> 11 | a << 21) ^ (a >>> 25 | a << 7), _ = t & n, m = _ ^ t & s ^ R, S = a & d ^ ~a & l, p = c + g + S + K[f + 3] + u[f + 3], w = y + m, c = r + p << 0, r = p + w << 0;
472
+ this.h0 = this.h0 + r << 0, this.h1 = this.h1 + t << 0, this.h2 = this.h2 + n << 0, this.h3 = this.h3 + s << 0, this.h4 = this.h4 + c << 0, this.h5 = this.h5 + a << 0, this.h6 = this.h6 + d << 0, this.h7 = this.h7 + l << 0;
473
+ }, Sha256.prototype.hex = function() {
474
+ this.finalize();
475
+ var r = this.h0, t = this.h1, n = this.h2, s = this.h3, c = this.h4, a = this.h5, d = this.h6, l = this.h7, u = 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[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[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[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[c >> 28 & 15] + HEX_CHARS[c >> 24 & 15] + HEX_CHARS[c >> 20 & 15] + HEX_CHARS[c >> 16 & 15] + HEX_CHARS[c >> 12 & 15] + HEX_CHARS[c >> 8 & 15] + HEX_CHARS[c >> 4 & 15] + HEX_CHARS[c & 15] + 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] + HEX_CHARS[d >> 28 & 15] + HEX_CHARS[d >> 24 & 15] + HEX_CHARS[d >> 20 & 15] + HEX_CHARS[d >> 16 & 15] + HEX_CHARS[d >> 12 & 15] + HEX_CHARS[d >> 8 & 15] + HEX_CHARS[d >> 4 & 15] + HEX_CHARS[d & 15];
476
+ return this.is224 || (u += HEX_CHARS[l >> 28 & 15] + HEX_CHARS[l >> 24 & 15] + HEX_CHARS[l >> 20 & 15] + HEX_CHARS[l >> 16 & 15] + HEX_CHARS[l >> 12 & 15] + HEX_CHARS[l >> 8 & 15] + HEX_CHARS[l >> 4 & 15] + HEX_CHARS[l & 15]), u;
477
+ }, Sha256.prototype.toString = Sha256.prototype.hex, Sha256.prototype.digest = function() {
478
+ this.finalize();
479
+ var r = this.h0, t = this.h1, n = this.h2, s = this.h3, c = this.h4, a = this.h5, d = this.h6, l = this.h7, u = [
480
+ r >> 24 & 255,
481
+ r >> 16 & 255,
482
+ r >> 8 & 255,
483
+ r & 255,
484
+ t >> 24 & 255,
485
+ t >> 16 & 255,
486
+ t >> 8 & 255,
487
+ t & 255,
488
+ n >> 24 & 255,
489
+ n >> 16 & 255,
490
+ n >> 8 & 255,
491
+ n & 255,
492
+ s >> 24 & 255,
493
+ s >> 16 & 255,
494
+ s >> 8 & 255,
495
+ s & 255,
496
+ c >> 24 & 255,
497
+ c >> 16 & 255,
498
+ c >> 8 & 255,
499
+ c & 255,
500
+ a >> 24 & 255,
501
+ a >> 16 & 255,
502
+ a >> 8 & 255,
503
+ a & 255,
504
+ d >> 24 & 255,
505
+ d >> 16 & 255,
506
+ d >> 8 & 255,
507
+ d & 255
508
+ ];
509
+ return this.is224 || u.push(l >> 24 & 255, l >> 16 & 255, l >> 8 & 255, l & 255), u;
510
+ }, Sha256.prototype.array = Sha256.prototype.digest, Sha256.prototype.arrayBuffer = function() {
511
+ this.finalize();
512
+ var r = new ArrayBuffer(this.is224 ? 28 : 32), t = new DataView(r);
513
+ return 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), this.is224 || t.setUint32(28, this.h7), r;
514
+ };
515
+ function HmacSha256(r, t, n) {
516
+ var s, c = typeof r;
517
+ if (c === "string") {
518
+ var a = [], d = r.length, l = 0, u;
519
+ for (s = 0; s < d; ++s)
520
+ u = r.charCodeAt(s), u < 128 ? a[l++] = u : u < 2048 ? (a[l++] = 192 | u >> 6, a[l++] = 128 | u & 63) : u < 55296 || u >= 57344 ? (a[l++] = 224 | u >> 12, a[l++] = 128 | u >> 6 & 63, a[l++] = 128 | u & 63) : (u = 65536 + ((u & 1023) << 10 | r.charCodeAt(++s) & 1023), a[l++] = 240 | u >> 18, a[l++] = 128 | u >> 12 & 63, a[l++] = 128 | u >> 6 & 63, a[l++] = 128 | u & 63);
521
+ r = a;
522
+ } else if (c === "object") {
523
+ if (r === null)
524
+ throw new Error(ERROR);
525
+ if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
526
+ r = new Uint8Array(r);
527
+ else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
528
+ throw new Error(ERROR);
529
+ } else
530
+ throw new Error(ERROR);
531
+ r.length > 64 && (r = new Sha256(t, !0).update(r).array());
532
+ var f = [], y = [];
533
+ for (s = 0; s < 64; ++s) {
534
+ var g = r[s] || 0;
535
+ f[s] = 92 ^ g, y[s] = 54 ^ g;
536
+ }
537
+ Sha256.call(this, t, n), this.update(y), this.oKeyPad = f, this.inner = !0, this.sharedMemory = n;
538
+ }
539
+ HmacSha256.prototype = new Sha256(), HmacSha256.prototype.finalize = function() {
540
+ if (Sha256.prototype.finalize.call(this), this.inner) {
541
+ this.inner = !1;
542
+ var r = this.array();
543
+ Sha256.call(this, this.is224, this.sharedMemory), this.update(this.oKeyPad), this.update(r), Sha256.prototype.finalize.call(this);
544
+ }
545
+ };
546
+ var exports = createMethod();
547
+ exports.sha256 = exports, exports.sha224 = createMethod(!0), exports.sha256.hmac = createHmacMethod(), exports.sha224.hmac = createHmacMethod(!0), COMMON_JS ? module.exports = exports : (root.sha256 = exports.sha256, root.sha224 = exports.sha224);
548
+ })();
549
+ })(sha256);
550
+ var getRandomValues, rnds8 = new Uint8Array(16);
551
+ function rng() {
552
+ if (!getRandomValues && (getRandomValues = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !getRandomValues))
553
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
554
+ return getRandomValues(rnds8);
555
+ }
556
+ 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;
557
+ function validate(r) {
558
+ return typeof r == "string" && REGEX.test(r);
559
+ }
560
+ var byteToHex = [];
561
+ for (var i = 0; i < 256; ++i)
562
+ byteToHex.push((i + 256).toString(16).substr(1));
563
+ function stringify(r) {
564
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, n = (byteToHex[r[t + 0]] + byteToHex[r[t + 1]] + byteToHex[r[t + 2]] + byteToHex[r[t + 3]] + "-" + byteToHex[r[t + 4]] + byteToHex[r[t + 5]] + "-" + byteToHex[r[t + 6]] + byteToHex[r[t + 7]] + "-" + byteToHex[r[t + 8]] + byteToHex[r[t + 9]] + "-" + byteToHex[r[t + 10]] + byteToHex[r[t + 11]] + byteToHex[r[t + 12]] + byteToHex[r[t + 13]] + byteToHex[r[t + 14]] + byteToHex[r[t + 15]]).toLowerCase();
565
+ if (!validate(n))
566
+ throw TypeError("Stringified UUID is invalid");
567
+ return n;
568
+ }
569
+ function v4(r, t, n) {
570
+ r = r || {};
571
+ var s = r.random || (r.rng || rng)();
572
+ if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, t) {
573
+ n = n || 0;
574
+ for (var c = 0; c < 16; ++c)
575
+ t[n + c] = s[c];
576
+ return t;
577
+ }
578
+ return stringify(s);
579
+ }
580
+ async function getBytes(r, t) {
581
+ const n = r.getReader();
582
+ let s;
583
+ for (; !(s = await n.read()).done; )
584
+ t(s.value);
585
+ }
586
+ function getLines(r) {
587
+ let t, n, s, c = !1;
588
+ return function(d) {
589
+ t === void 0 ? (t = d, n = 0, s = -1) : t = concat(t, d);
590
+ const l = t.length;
591
+ let u = 0;
592
+ for (; n < l; ) {
593
+ c && (t[n] === 10 && (u = ++n), c = !1);
594
+ let f = -1;
595
+ for (; n < l && f === -1; ++n)
596
+ switch (t[n]) {
597
+ case 58:
598
+ s === -1 && (s = n - u);
599
+ break;
600
+ case 13:
601
+ c = !0;
602
+ case 10:
603
+ f = n;
604
+ break;
605
+ }
606
+ if (f === -1)
607
+ break;
608
+ r(t.subarray(u, f), s), u = n, s = -1;
609
+ }
610
+ u === l ? t = void 0 : u !== 0 && (t = t.subarray(u), n -= u);
611
+ };
612
+ }
613
+ function getMessages(r, t, n) {
614
+ let s = newMessage();
615
+ const c = new TextDecoder();
616
+ return function(d, l) {
617
+ if (d.length === 0)
618
+ n == null || n(s), s = newMessage();
619
+ else if (l > 0) {
620
+ const u = c.decode(d.subarray(0, l)), f = l + (d[l + 1] === 32 ? 2 : 1), y = c.decode(d.subarray(f));
621
+ switch (u) {
622
+ case "data":
623
+ s.data = s.data ? s.data + `
624
+ ` + y : y;
625
+ break;
626
+ case "event":
627
+ s.event = y;
628
+ break;
629
+ case "id":
630
+ r(s.id = y);
631
+ break;
632
+ case "retry":
633
+ const g = parseInt(y, 10);
634
+ isNaN(g) || t(s.retry = g);
635
+ break;
636
+ }
637
+ }
638
+ };
639
+ }
640
+ function concat(r, t) {
641
+ const n = new Uint8Array(r.length + t.length);
642
+ return n.set(r), n.set(t, r.length), n;
643
+ }
644
+ function newMessage() {
645
+ return {
646
+ data: "",
647
+ event: "",
648
+ id: "",
649
+ retry: void 0
650
+ };
651
+ }
652
+ var __rest = function(r, t) {
653
+ var n = {};
654
+ for (var s in r)
655
+ Object.prototype.hasOwnProperty.call(r, s) && t.indexOf(s) < 0 && (n[s] = r[s]);
656
+ if (r != null && typeof Object.getOwnPropertySymbols == "function")
657
+ for (var c = 0, s = Object.getOwnPropertySymbols(r); c < s.length; c++)
658
+ t.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(r, s[c]) && (n[s[c]] = r[s[c]]);
659
+ return n;
660
+ };
661
+ const EventStreamContentType = "text/event-stream", DefaultRetryInterval = 1e3, LastEventId = "last-event-id";
662
+ function fetchEventSource(r, t) {
663
+ var { signal: n, headers: s, onopen: c, onmessage: a, onclose: d, onerror: l, openWhenHidden: u, fetch: f } = t, y = __rest(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
664
+ return new Promise((g, m) => {
665
+ const p = Object.assign({}, s);
666
+ p.accept || (p.accept = EventStreamContentType);
667
+ let w;
668
+ function S() {
669
+ w.abort(), document.hidden || k();
670
+ }
671
+ u || document.addEventListener("visibilitychange", S);
672
+ let x = DefaultRetryInterval, v = 0;
673
+ function R() {
674
+ document.removeEventListener("visibilitychange", S), window.clearTimeout(v), w.abort();
675
+ }
676
+ n == null || n.addEventListener("abort", () => {
677
+ R(), g();
678
+ });
679
+ const _ = f ?? window.fetch, T = c ?? defaultOnOpen;
680
+ async function k() {
681
+ var U;
682
+ w = new AbortController();
683
+ try {
684
+ const I = await _(r, Object.assign(Object.assign({}, y), { headers: p, signal: w.signal }));
685
+ await T(I), await getBytes(I.body, getLines(getMessages((A) => {
686
+ A ? p[LastEventId] = A : delete p[LastEventId];
687
+ }, (A) => {
688
+ x = A;
689
+ }, a))), d == null || d(), R(), g();
690
+ } catch (I) {
691
+ if (!w.signal.aborted)
692
+ try {
693
+ const A = (U = l == null ? void 0 : l(I)) !== null && U !== void 0 ? U : x;
694
+ window.clearTimeout(v), v = window.setTimeout(k, A);
695
+ } catch (A) {
696
+ R(), m(A);
697
+ }
698
+ }
699
+ }
700
+ k();
701
+ });
702
+ }
703
+ function defaultOnOpen(r) {
704
+ const t = r.headers.get("content-type");
705
+ if (!(t != null && t.startsWith(EventStreamContentType)))
706
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`);
707
+ }
708
+ function Base64EncodeUrl(r) {
709
+ return r.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
710
+ }
711
+ function getTimestamp() {
712
+ return Math.floor(Date.now() / 1e3);
713
+ }
714
+ function e(r) {
715
+ this.message = r;
716
+ }
717
+ e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
718
+ var r$1 = typeof window < "u" && window.atob && window.atob.bind(window) || function(r) {
719
+ var t = String(r).replace(/=+$/, "");
720
+ if (t.length % 4 == 1)
721
+ throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
722
+ for (var n, s, c = 0, a = 0, d = ""; s = t.charAt(a++); ~s && (n = c % 4 ? 64 * n + s : s, c++ % 4) ? d += String.fromCharCode(255 & n >> (-2 * c & 6)) : 0)
723
+ s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);
724
+ return d;
725
+ };
726
+ function t$1(r) {
727
+ var t = r.replace(/-/g, "+").replace(/_/g, "/");
728
+ switch (t.length % 4) {
729
+ case 0:
730
+ break;
731
+ case 2:
732
+ t += "==";
733
+ break;
734
+ case 3:
735
+ t += "=";
736
+ break;
737
+ default:
738
+ throw "Illegal base64url string!";
739
+ }
740
+ try {
741
+ return function(n) {
742
+ return decodeURIComponent(r$1(n).replace(/(.)/g, function(s, c) {
743
+ var a = c.charCodeAt(0).toString(16).toUpperCase();
744
+ return a.length < 2 && (a = "0" + a), "%" + a;
745
+ }));
746
+ }(t);
747
+ } catch {
748
+ return r$1(t);
749
+ }
750
+ }
751
+ function n$1(r) {
752
+ this.message = r;
753
+ }
754
+ function o(r, t) {
755
+ if (typeof r != "string")
756
+ throw new n$1("Invalid token specified");
757
+ var n = (t = t || {}).header === !0 ? 0 : 1;
758
+ try {
759
+ return JSON.parse(t$1(r.split(".")[n]));
760
+ } catch (s) {
761
+ throw new n$1("Invalid token specified: " + s.message);
762
+ }
763
+ }
764
+ n$1.prototype = new Error(), n$1.prototype.name = "InvalidTokenError";
765
+ class NylasSessions {
766
+ constructor(t) {
767
+ b(this, "clientId");
768
+ b(this, "redirectUri");
769
+ b(this, "accessType", "online");
770
+ b(this, "domain", "http://api.nylas.com");
771
+ b(this, "versioned", !1);
772
+ b(this, "Storage");
773
+ b(this, "hosted", !1);
774
+ b(this, "multiAccount", !1);
775
+ b(this, "loginId", "");
776
+ if (this.clientId = t.clientId, this.redirectUri = t.redirectUri, t.domain && (this.domain = t.domain, this.domain.substring(this.domain.length - 3).includes("/v") && (this.versioned = !0)), t.multiAccount && (this.multiAccount = t.multiAccount), t.sw) {
777
+ const n = new IndexedDBStorage();
778
+ this.Storage = new Storage(n);
779
+ } else
780
+ this.Storage = new Storage();
781
+ t.accessType && (this.accessType = t.accessType), t.loginId && (this.loginId = t.loginId), t.hosted && (this.hosted = t.hosted), this.codeExchange(null);
782
+ }
783
+ // Validates access token
784
+ async validateAccessToken(t = "") {
785
+ const n = await this.Storage.getGrant(t, this.multiAccount);
786
+ if (!n)
787
+ return !1;
788
+ const { access_token: s } = n;
789
+ try {
790
+ return !!(await (await fetch(`${this.domain}/connect/tokeninfo?access_token=${s}`, {
791
+ method: "GET"
792
+ })).json()).data;
793
+ } catch {
794
+ return !1;
795
+ }
796
+ }
797
+ // Validates id token
798
+ async validateIDToken(t = "") {
799
+ const n = await this.Storage.getGrant(t, this.multiAccount);
800
+ if (!n)
801
+ return !1;
802
+ const { id_token: s } = n;
803
+ try {
804
+ const c = await fetch(`${this.domain}/connect/tokeninfo?id_token=${s}`, {
805
+ method: "GET"
806
+ });
807
+ return !(c.status !== 200 || !(await c.json()).data);
808
+ } catch {
809
+ return !1;
810
+ }
811
+ }
812
+ // Gets domain of UAS
813
+ getDomain() {
814
+ return this.domain;
815
+ }
816
+ // Gets auth link
817
+ async auth(t) {
818
+ this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)) && await this.hostedSetCodeChallenge();
819
+ const n = await this.generateAuthURL(t);
820
+ if (t.popup) {
821
+ this.popUp(n);
822
+ return;
823
+ }
824
+ return n;
825
+ }
826
+ // Generates auth URL
827
+ async generateAuthURL(t) {
828
+ const n = await this.getCodeChallege();
829
+ let s = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
830
+ return n && (s += `&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`), t.provider && (s += `&provider=${t.provider}`), t.loginHint && (s += `&login_hint=${t.loginHint}`, t.includeGrantScopes && (s += `&include_grant_scopes=${t.includeGrantScopes}`)), t.scope && (s += `&scope=${t.scope.join(" ")}`), t.prompt && (s += `&prompt=${t.prompt}`), t.metadata && (s += `&metadata=${t.metadata}`), (t.state || this.loginId) && (s += `&state=${this.loginId ? this.loginId : t.state}`), s;
831
+ }
832
+ // Generates auth URL
833
+ async generateReauthURL(t, n) {
834
+ if (!t)
835
+ throw new Error("Grant ID is required");
836
+ const s = await this.Storage.getUserToken(t), c = await this.getCodeChallege();
837
+ let a = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
838
+ return c && (a += `&code_challenge=${c}&code_challenge_method=S256&options=rotate_refresh_token`), s != null && s.provider && (a += `&provider=${s.provider}`), s != null && s.email && (a += `&login_hint=${s.email}`), n && (a += `&scope=${n.join(" ")}`), a;
839
+ }
840
+ // Generates UUID code challenge
841
+ async generateCodeChallenge() {
842
+ if (await this.Storage.getPKCE())
843
+ return;
844
+ const n = v4();
845
+ this.Storage.setPKCE(n);
846
+ }
847
+ // Gets code challenge from URL query params
848
+ async hostedSetCodeChallenge() {
849
+ if (!this.hosted)
850
+ throw console.error("Method only used with hosted flag enabled");
851
+ const n = new URLSearchParams(window.location.search).get("code_challenge");
852
+ if (!n) {
853
+ if (await this.Storage.getPKCE())
854
+ return;
855
+ console.warn("Code challenge is recomended");
856
+ return;
857
+ }
858
+ this.Storage.setPKCE(n);
859
+ }
860
+ // Gets code challenge from store
861
+ async getCodeChallege() {
862
+ if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin))) {
863
+ const s = new URLSearchParams(window.location.search).get("code_challenge");
864
+ return s || (console.warn("Code challenge is recomended"), "");
865
+ }
866
+ const t = await this.Storage.getPKCE();
867
+ if (t) {
868
+ const n = sha256.exports.sha256(t);
869
+ let s = Buffer.from(n).toString("base64");
870
+ return s = Base64EncodeUrl(s), s;
871
+ }
872
+ return "";
873
+ }
874
+ // checks if user is logged in
875
+ async isLoggedIn() {
876
+ if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)))
877
+ return !1;
878
+ const t = await this.Storage.getUserTokens();
879
+ return t && t.length > 0 ? (this.multiAccount && await this.generateCodeChallenge(), !0) : (await this.generateCodeChallenge(), !1);
880
+ }
881
+ // Checks if user is multi account
882
+ isMultiAccount() {
883
+ return this.multiAccount;
884
+ }
885
+ // Logs user out
886
+ async logout() {
887
+ const t = await this.getProfile();
888
+ await this.Storage.clearSession();
889
+ const n = { detail: t };
890
+ window.dispatchEvent(new CustomEvent("onLogoutSuccess", n));
891
+ }
892
+ // Gets profile info from ID token
893
+ async getProfile(t = "") {
894
+ let n;
895
+ return t ? n = await this.Storage.getUserToken(t) : n = await this.Storage.getUserToken(), n || null;
896
+ }
897
+ // Gets profile info from ID tokens
898
+ async getProfiles() {
899
+ const t = await this.Storage.getUserTokens();
900
+ return t || null;
901
+ }
902
+ // Remove a specific profile
903
+ async removeProfile(t) {
904
+ return await this.Storage.removeUserToken(t), await this.Storage.removeGrant(t), null;
905
+ }
906
+ // IMAP authentication
907
+ async authIMAP(t) {
908
+ const n = await this.getCodeChallege(), s = {
909
+ imap_username: t.username,
910
+ imap_password: t.password,
911
+ imap_host: t.hostIMAP,
912
+ imap_port: t.portIMAP,
913
+ type: t.type,
914
+ smtp_host: t.hostSMTP,
915
+ smtp_port: t.portSMTP,
916
+ provider: t.provider,
917
+ redirect_uri: this.redirectUri,
918
+ state: t.state,
919
+ public_application_id: this.clientId,
920
+ access_type: this.accessType
921
+ };
922
+ return this.loginId && (s.id = this.loginId), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/imap`, {
923
+ method: "POST",
924
+ headers: new Headers({ "content-type": "application/json" }),
925
+ body: JSON.stringify(s)
926
+ })).json();
927
+ }
928
+ // EWS authentication
929
+ async authEWS(t) {
930
+ const n = await this.getCodeChallege(), s = {
931
+ ...t,
932
+ redirect_uri: this.redirectUri,
933
+ public_application_id: this.clientId,
934
+ access_type: this.accessType
935
+ };
936
+ return this.loginId && (s.id = this.loginId), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/ews`, {
937
+ method: "POST",
938
+ headers: new Headers({ "content-type": "application/json" }),
939
+ body: JSON.stringify(s)
940
+ })).json();
941
+ }
942
+ // Detects email
943
+ async detectEmail(t) {
944
+ return (await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`, {
945
+ method: "POST",
946
+ headers: new Headers({ "content-type": "application/json" })
947
+ })).json()).data;
948
+ }
949
+ // Gets app info from UAS
950
+ async applicationInfo() {
951
+ return (await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/applications?client_id=${this.clientId}`, {
952
+ method: "GET",
953
+ headers: new Headers({ "content-type": "application/json" })
954
+ })).json()).data;
955
+ }
956
+ // Gets providers form UAS
957
+ async getAvailableProviders() {
958
+ const t = await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`, {
959
+ method: "GET",
960
+ headers: new Headers({ "content-type": "application/json" })
961
+ });
962
+ return t ? (await t.json()).data : null;
963
+ }
964
+ // EVENT HOOKS
965
+ onLoginSuccess(t) {
966
+ window.addEventListener("onLoginSuccess", (n) => t(n));
967
+ }
968
+ onLogoutSuccess(t) {
969
+ window.addEventListener("onLogoutSuccess", (n) => t(n));
970
+ }
971
+ onLoginFail(t) {
972
+ window.addEventListener("onLoginFail", (n) => t(n));
973
+ }
974
+ onTokenRefreshSuccess(t) {
975
+ window.addEventListener("onTokenRefreshSuccess", (n) => t(n));
976
+ }
977
+ onTokenRefreshFail(t) {
978
+ window.addEventListener("onTokenRefreshFail", (n) => t(n));
979
+ }
980
+ onSessionExpired(t) {
981
+ window.addEventListener("onSessionExpired", (n) => t(n));
982
+ }
983
+ // Exchanges code for ID token and refresh and access tokens
984
+ async codeExchange(t) {
985
+ let n = new URLSearchParams(window.location.search);
986
+ t && (n = new URLSearchParams(t));
987
+ const s = n.get("code"), c = n.get("state"), a = n.get("error"), d = n.get("error_description"), l = n.get("error_code");
988
+ if (a && d && l) {
989
+ const f = {
990
+ detail: { error: a, error_description: d, error_code: l }
991
+ };
992
+ return window.dispatchEvent(new CustomEvent("onLoginFail", f)), window.history.pushState({}, document.title, window.location.pathname), !1;
993
+ }
994
+ if (!s)
995
+ return console.warn("No code found"), !1;
996
+ if (window.opener && window.name === "uas-popup")
997
+ return console.warn("Popup window detected"), !1;
998
+ const u = await this.Storage.getPKCE();
999
+ if (!u)
1000
+ return console.warn("No code verifier found"), !1;
1001
+ try {
1002
+ const f = {
1003
+ client_id: this.clientId,
1004
+ redirect_uri: this.redirectUri,
1005
+ code: s,
1006
+ grant_type: "authorization_code",
1007
+ code_verifier: u
1008
+ }, g = await (await fetch(`${this.domain}/connect/token`, {
1009
+ method: "POST",
1010
+ headers: new Headers({ "content-type": "application/json" }),
1011
+ body: JSON.stringify(f)
1012
+ })).json();
1013
+ if (g) {
1014
+ if (g.error) {
1015
+ const p = { detail: g };
1016
+ return window.dispatchEvent(new CustomEvent("onLoginFail", p)), !0;
1017
+ }
1018
+ const m = await this.handleCodeExchangeResponse(g);
1019
+ if (m.valid) {
1020
+ c && (m.data.state = c);
1021
+ const p = { detail: m.data };
1022
+ window.dispatchEvent(new CustomEvent("onLoginSuccess", p)), window.history.pushState({}, document.title, window.location.pathname);
1023
+ } else {
1024
+ const p = { detail: m.data };
1025
+ return window.dispatchEvent(new CustomEvent("onLoginFail", p)), !0;
1026
+ }
1027
+ }
1028
+ return this.Storage.removePKCE(), !0;
1029
+ } catch (f) {
1030
+ const y = { detail: f };
1031
+ return window.dispatchEvent(new CustomEvent("onLoginFail", y)), window.history.pushState({}, document.title, window.location.pathname), !1;
1032
+ }
1033
+ }
1034
+ // Token Exchange for session maintenece
1035
+ async tokenExchange(t = "") {
1036
+ const n = await this.Storage.getGrant(t, this.multiAccount);
1037
+ if (!n)
1038
+ return !1;
1039
+ const s = n.refresh_token;
1040
+ try {
1041
+ const c = {
1042
+ client_id: this.clientId,
1043
+ redirect_uri: this.redirectUri,
1044
+ refresh_token: s,
1045
+ grant_type: "refresh_token"
1046
+ }, d = await (await fetch(`${this.domain}/connect/token`, {
1047
+ method: "POST",
1048
+ headers: new Headers({ "content-type": "application/json" }),
1049
+ body: JSON.stringify(c)
1050
+ })).json();
1051
+ if (d) {
1052
+ if (d.error) {
1053
+ const y = { detail: d };
1054
+ return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", y)), !0;
1055
+ }
1056
+ const l = getTimestamp();
1057
+ if (d.expires_in = l + d.expires_in, this.Storage.setGrant(d, this.multiAccount), !await this.validateIDToken(t)) {
1058
+ const y = { detail: d };
1059
+ return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", y)), !0;
1060
+ }
1061
+ const f = { detail: d };
1062
+ return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess", f)), !0;
1063
+ }
1064
+ this.Storage.removePKCE();
1065
+ } catch (c) {
1066
+ const a = { detail: c };
1067
+ return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", a)), !1;
1068
+ }
1069
+ }
1070
+ // Handles the response of code exchange
1071
+ async handleCodeExchangeResponse(t) {
1072
+ if (t.error)
1073
+ return {
1074
+ data: t,
1075
+ valid: !1
1076
+ };
1077
+ const s = getTimestamp();
1078
+ t.expires_in = s + t.expires_in, this.Storage.setGrant(t, this.multiAccount);
1079
+ const c = o(t.id_token);
1080
+ return c.status = "authenticated", this.Storage.setUserToken(c), await this.validateIDToken(c.sub) ? {
1081
+ data: t,
1082
+ valid: !0
1083
+ } : {
1084
+ data: t,
1085
+ valid: !1
1086
+ };
1087
+ }
1088
+ // Regulates POPUP behaivior
1089
+ async popUp(t) {
1090
+ const c = window.screenX + (window.outerWidth - 500) / 2, a = window.screenY + (window.outerHeight - 600) / 2.5, d = "uas-popup", l = t, u = window.open(l, d, `width=500,height=600,left=${c},top=${a}`);
1091
+ if (!u)
1092
+ return;
1093
+ const f = setInterval(async () => {
1094
+ if (u.closed) {
1095
+ const y = {
1096
+ detail: { error_description: "OAuth provider window closed" }
1097
+ };
1098
+ window.dispatchEvent(new CustomEvent("onLoginFail", y)), f && clearInterval(f);
1099
+ return;
1100
+ }
1101
+ try {
1102
+ const y = u.location.href.split("?");
1103
+ if (!y[0])
1104
+ return;
1105
+ const g = u.location.search;
1106
+ if (u.history.pushState({}, document.title, window.location.pathname), y[0] === this.redirectUri && y.length > 1) {
1107
+ const m = await this.codeExchange(g);
1108
+ u.close(), m && location.reload(), f && clearInterval(f);
1109
+ return;
1110
+ }
1111
+ } catch {
1112
+ return;
1113
+ }
1114
+ }, 1e3);
1115
+ }
1116
+ // Returns access token
1117
+ async getAccessToken(t = "") {
1118
+ const n = getTimestamp(), s = await this.Storage.getGrant(t, this.multiAccount);
1119
+ if (!s)
1120
+ return null;
1121
+ const { access_token: c, expires_in: a } = s, d = c;
1122
+ return d && a && a > getTimestamp() && a - n > 30 ? d : (await this.tokenExchange(t), (await this.Storage.getGrant(t, this.multiAccount)).access_token);
1123
+ }
1124
+ async sse(t, n) {
1125
+ const s = n.headers || {}, c = s["Grant-ID"];
1126
+ let a = "";
1127
+ if (this.multiAccount) {
1128
+ if (!c)
1129
+ throw this.logout(), new Error("Grant ID is required for multi account calls");
1130
+ a = await this.getAccessToken(c);
1131
+ } else
1132
+ a = await this.getAccessToken();
1133
+ return delete s["Grant-ID"], s.Authorization = `Bearer ${a}`, s["content-type"] || (s["content-type"] = "application/json"), fetchEventSource(`${this.domain}/${t}`, {
1134
+ ...n,
1135
+ headers: s
1136
+ });
1137
+ }
1138
+ // Used to call Nylas API endpoints
1139
+ async fetch(t, n, s = !0, c) {
1140
+ let a = "", d = 1;
1141
+ if (this.multiAccount) {
1142
+ if (!n.grant_id)
1143
+ throw this.logout(), new Error("Grant ID is required for multi account calls");
1144
+ const u = await this.getProfiles();
1145
+ d = u ? u.length : 1, a = await this.getAccessToken(n.grant_id);
1146
+ } else
1147
+ a = await this.getAccessToken();
1148
+ if (!a)
1149
+ throw new Error("Access token not found");
1150
+ let l = n.headers;
1151
+ Headers.prototype.isPrototypeOf(l) ? (l.append("Authorization", `Bearer ${a}`), l.has("content-type") || l.append("content-type", "application/json")) : l = new Headers({
1152
+ Authorization: `Bearer ${a}`,
1153
+ "content-type": "application/json"
1154
+ });
1155
+ try {
1156
+ n != null && n.body && (n.body = JSON.stringify(n == null ? void 0 : n.body));
1157
+ const u = await fetch(`${c || this.domain}/${t}`, {
1158
+ ...n,
1159
+ headers: l
1160
+ });
1161
+ if (!s)
1162
+ return u;
1163
+ const f = await (u == null ? void 0 : u.json());
1164
+ if (!await this.isAuthenticatedResponse(u.status, f)) {
1165
+ if (d > 1) {
1166
+ const g = await this.getProfile(n.grant_id);
1167
+ if (g) {
1168
+ g.status = "unauthorized", await this.Storage.setUserToken(g);
1169
+ const m = {
1170
+ detail: { user: g }
1171
+ };
1172
+ window.dispatchEvent(new CustomEvent("onSessionExpired", m));
1173
+ }
1174
+ } else {
1175
+ const m = {
1176
+ detail: { user: await this.Storage.getUserToken() }
1177
+ };
1178
+ window.dispatchEvent(new CustomEvent("onSessionExpired", m));
1179
+ }
1180
+ this.logout();
1181
+ return;
1182
+ }
1183
+ return f;
1184
+ } catch (u) {
1185
+ throw u;
1186
+ }
1187
+ }
1188
+ async fetchRequest(t, n, s, c = !0, a, d) {
1189
+ const l = await this.isLoggedIn(), u = new URL(t, a ?? this.domain), f = new Headers();
1190
+ if (f.append("Accept", "application/json"), f.append("Content-Type", "application/json"), f.append("User-Agent", "nylas-identity"), l) {
1191
+ const m = await this.getAccessToken();
1192
+ f.append("Authorization", `Bearer ${m}`);
1193
+ }
1194
+ const y = await fetch(u.toString(), {
1195
+ method: n || "GET",
1196
+ headers: f,
1197
+ mode: "cors",
1198
+ referrer: location.origin,
1199
+ body: s ? JSON.stringify(s) : void 0,
1200
+ ...d || {}
1201
+ });
1202
+ return c ? await y.json() : y.body;
1203
+ }
1204
+ // Checks if the response is not 401
1205
+ async isAuthenticatedResponse(t, n) {
1206
+ var s;
1207
+ return !(t == 401 && ((s = n == null ? void 0 : n.error) == null ? void 0 : s.type) == "token.unauthorized_access");
1208
+ }
1209
+ addAPIKey(t, n, s) {
1210
+ this.Storage.setUserToken({
1211
+ aud: "https://api-staging.us.nylas.com/",
1212
+ exp: 2e9,
1213
+ email_verified: !0,
1214
+ iat: getTimestamp(),
1215
+ iss: "",
1216
+ email: n,
1217
+ provider: "virtual-calendar",
1218
+ status: "authenticated",
1219
+ name: n,
1220
+ sub: t
1221
+ }), this.Storage.setGrant({
1222
+ grant_id: t,
1223
+ access_token: s,
1224
+ expires_in: 2e9
1225
+ }, this.multiAccount);
1226
+ }
1227
+ }
1228
+ var B = { isMounted: function() {
1229
+ return !1;
1230
+ }, enqueueForceUpdate: function() {
1231
+ }, enqueueReplaceState: function() {
1232
+ }, enqueueSetState: function() {
1233
+ } }, C = Object.assign, D = {};
1234
+ function E(r, t, n) {
1235
+ this.props = r, this.context = t, this.refs = D, this.updater = n || B;
1236
+ }
1237
+ E.prototype.isReactComponent = {};
1238
+ E.prototype.setState = function(r, t) {
1239
+ if (typeof r != "object" && typeof r != "function" && r != null)
1240
+ throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
1241
+ this.updater.enqueueSetState(this, r, t, "setState");
1242
+ };
1243
+ E.prototype.forceUpdate = function(r) {
1244
+ this.updater.enqueueForceUpdate(this, r, "forceUpdate");
1245
+ };
1246
+ function F() {
1247
+ }
1248
+ F.prototype = E.prototype;
1249
+ function G(r, t, n) {
1250
+ this.props = r, this.context = t, this.refs = D, this.updater = n || B;
1251
+ }
1252
+ var H = G.prototype = new F();
1253
+ H.constructor = G;
1254
+ C(H, E.prototype);
1255
+ H.isPureReactComponent = !0;
1256
+ const LoginRequired = ({ authenticationUrl: r }) => h(
1257
+ "div",
1258
+ { class: "login-required", part: "login-component" },
1259
+ h(
1260
+ "div",
1261
+ { class: "card" },
1262
+ h("p", null, "Log into your account to use the Scheduler Editor."),
1263
+ h(
1264
+ "button",
1265
+ { class: "google-button", onClick: async (t) => {
1266
+ t.preventDefault();
1267
+ const n = await r("google");
1268
+ n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
1269
+ } },
1270
+ h(
1271
+ "span",
1272
+ { class: "icon" },
1273
+ h("google-logo-icon", { width: "15", height: "15" })
1274
+ ),
1275
+ "Continue with Google"
1276
+ ),
1277
+ h(
1278
+ "button",
1279
+ { class: "microsoft-button", onClick: async (t) => {
1280
+ t.preventDefault();
1281
+ const n = await r("microsoft");
1282
+ n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
1283
+ } },
1284
+ h(
1285
+ "span",
1286
+ { class: "icon" },
1287
+ h("microsoft-logo-icon", { width: "15", height: "15" })
1288
+ ),
1289
+ "Continue with Microsoft"
1290
+ ),
1291
+ h(
1292
+ "button",
1293
+ { class: "other-provider-button", onClick: async (t) => {
1294
+ t.preventDefault();
1295
+ const n = await r();
1296
+ n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
1297
+ } },
1298
+ "View all providers ",
1299
+ h("chevron-icon", { width: "17", height: "17" })
1300
+ ),
1301
+ h("small", { class: "disclaimer-text" }, "* You will be redirected to authenticate your account.")
1302
+ )
1303
+ );
1304
+ function ExpressFlow({ selectedConfiguration: r, currentUser: t, calendars: n }) {
1305
+ var c;
1306
+ const s = ((c = r == null ? void 0 : r.participants) == null ? void 0 : c.find((a) => a.is_organizer)) ?? t;
1307
+ return h(
1308
+ Fragment,
1309
+ null,
1310
+ h(
1311
+ "nylas-event-info",
1312
+ null,
1313
+ h(
1314
+ "div",
1315
+ { slot: "inputs" },
1316
+ h("nylas-event-title", null),
1317
+ h("nylas-event-duration", null),
1318
+ h("nylas-event-location", { userProvider: t.provider })
1319
+ )
1320
+ ),
1321
+ h("nylas-booking-calendar-picker", { calendars: n, currentUser: t, defaultBookingCalendar: s == null ? void 0 : s.email }),
1322
+ h("nylas-scheduling-method", { exportparts: "nsm, nsm__header, nsm__input-label, nsm__dropdown, nsm__dropdown-button, nsm__dropdown-content" }),
1323
+ h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" })
1324
+ );
1325
+ }
1326
+ 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 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 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:-moz-available;width:-webkit-fill-available;width:fill-available;min-width:325px}}div.scheduler-editor-content{height:610px}@media screen and (max-width: 768px){div.scheduler-editor-content{height:auto}}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;height:inherit}nylas-editor-tabs .composable{height:inherit;overflow: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:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@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:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.list-configurations{height:auto;padding:2rem 1rem}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}', NylasSchedulerEditorStyle0 = nylasSchedulerEditorCss, NylasSchedulerEditor = class {
1327
+ constructor(r) {
1328
+ registerInstance(this, r), 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 = (t) => {
1329
+ const n = this.schedulerConfigCloseClicked.emit(this.host);
1330
+ "schedulerConfigCloseClicked" in this.eventOverrides && this.eventOverrides.schedulerConfigCloseClicked(n, this.nylasSchedulerConfigConnector), n.defaultPrevented || (localStorage.removeItem("grant"), localStorage.removeItem("user"), window.location.reload());
1331
+ }, this.authenticationUrl = async (t) => this.nylasApiRequest ? await this.nylasApiRequest.authenticationUrl({ provider: t }) || "" : (console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."), ""), this.configurationId = void 0, this.nylasApiRequest = void 0, this.nylasSessionsConfig = void 0, this.defaultAuthArgs = void 0, this.eventOverrides = {}, this.schedulerPreviewLink = "", this.defaultSchedulerConfigState = void 0, this.mode = "app", this.additionalParticipants = void 0, this.hideEditorTabs = [], this.conferenceProviders = void 0, this.requiresSlug = !1, this.automaticComponentRegistration = !0;
1332
+ }
1333
+ connectedCallback() {
1334
+ debug("[nylas-scheduler-editor] connectedCallback");
1335
+ }
1336
+ async componentWillLoad() {
1337
+ var s, c, a, d, l, u, f, y;
1338
+ debug("[nylas-scheduler-editor] componentWillLoad");
1339
+ const r = (s = this.additionalParticipants) == null ? void 0 : s.filter((g) => {
1340
+ var p;
1341
+ const m = ((p = g.calendars) == null ? void 0 : p.length) > 0 ? g.calendars.filter((w) => w.id && w.name) : [];
1342
+ if (g.name && g.email && m.length > 0)
1343
+ return {
1344
+ name: g.name,
1345
+ email: g.email,
1346
+ calendars: m
1347
+ };
1348
+ });
1349
+ if (this.stores = {
1350
+ schedulerConfig: CreateNylasSchedulerConfigStore({
1351
+ ...this.defaultSchedulerConfigState,
1352
+ additionalParticipants: r,
1353
+ conferenceProviders: this.conferenceProviders,
1354
+ hideEditorTabs: this.hideEditorTabs,
1355
+ requiresSlug: this.requiresSlug
1356
+ })
1357
+ }, !this.nylasApiRequest && this.nylasSessionsConfig) {
1358
+ const g = new NylasSessions(this.nylasSessionsConfig);
1359
+ await g.isLoggedIn(), g.onLoginSuccess(async () => {
1360
+ var p, w;
1361
+ const m = await ((w = (p = this.nylasSchedulerConfigConnector) == null ? void 0 : p.schedulerConfig) == null ? void 0 : w.currentUser());
1362
+ if (m) {
1363
+ const S = this.loggedIn.emit(this.host);
1364
+ "loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(S, this.nylasSchedulerConfigConnector), S.defaultPrevented || await this.loggedInHandler(m);
1365
+ }
1366
+ }), g.onLoginFail(async () => {
1367
+ var p, w;
1368
+ (w = (p = this.stores) == null ? void 0 : p.schedulerConfig) == null || w.set("currentUser", null);
1369
+ const m = this.loggedOut.emit(this.host);
1370
+ "loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(m, this.nylasSchedulerConfigConnector), m.defaultPrevented);
1371
+ }), this.nylasApiRequest = new NylasIdentityRequestWrapper(g);
1372
+ }
1373
+ this.nylasApiRequest && this.defaultAuthArgs && this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs), this.baseProvider = new NylasBaseProvider(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides);
1374
+ const t = this.baseProvider.getStore("schedulerConfig");
1375
+ this.nylasSchedulerConfigConnector = new NylasSchedulerConfigConnector({
1376
+ nylasApiRequest: this.nylasApiRequest,
1377
+ nylasSchedulerConfigStore: t
1378
+ });
1379
+ const n = this.init.emit(this.host);
1380
+ if ("init" in this.eventOverrides && await this.eventOverrides.init(n, this.nylasSchedulerConfigConnector), !n.defaultPrevented) {
1381
+ const g = await ((a = (c = this.nylasSchedulerConfigConnector) == null ? void 0 : c.schedulerConfig) == null ? void 0 : a.currentUser());
1382
+ if (g) {
1383
+ const m = this.loggedIn.emit(this.host);
1384
+ "loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(m, this.nylasSchedulerConfigConnector), m.defaultPrevented || await this.loggedInHandler(g);
1385
+ } else {
1386
+ (l = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || l.set("currentUser", null);
1387
+ const m = this.loggedOut.emit(this.host);
1388
+ if ("loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(m, this.nylasSchedulerConfigConnector), m.defaultPrevented))
1389
+ return;
1390
+ }
1391
+ }
1392
+ (f = (u = this.stores) == null ? void 0 : u.schedulerConfig) == null || f.onChange("selectedConfiguration", async (g) => {
1393
+ g && g.id && (this.configurationId = g.id);
1394
+ }), (y = this.baseProvider) == null || y.componentWillLoad(this.nylasSchedulerConfigConnector);
1395
+ }
1396
+ async componentDidLoad() {
1397
+ var r;
1398
+ debug("[nylas-scheduler-editor] componentDidLoad"), await ((r = this.baseProvider) == null ? void 0 : r.componentDidLoad());
1399
+ }
1400
+ async componentDisconnected() {
1401
+ var r;
1402
+ await ((r = this.baseProvider) == null ? void 0 : r.componentDisconnected());
1403
+ }
1404
+ async configurationIdChanged(r) {
1405
+ var t, n, s, c, a, d, l, u;
1406
+ r ? (await ((n = (t = this.nylasSchedulerConfigConnector) == null ? void 0 : t.schedulerConfig) == null ? void 0 : n.getConfigurationById(r)), (c = (s = this.stores) == null ? void 0 : s.schedulerConfig) == null || c.set("action", "edit")) : ((d = (a = this.stores) == null ? void 0 : a.schedulerConfig) == null || d.set("selectedConfiguration", {}), (u = (l = this.stores) == null ? void 0 : l.schedulerConfig) == null || u.set("action", null));
1407
+ }
1408
+ async store() {
1409
+ var r;
1410
+ return (r = this.stores) == null ? void 0 : r.schedulerConfig;
1411
+ }
1412
+ async schedulerConnector() {
1413
+ return this.nylasSchedulerConfigConnector;
1414
+ }
1415
+ async registerComponentHandler(r) {
1416
+ var t;
1417
+ (t = this.baseProvider) == null || t.registerComponent(r.detail);
1418
+ }
1419
+ async unregisterComponentHandler(r) {
1420
+ var t;
1421
+ (t = this.baseProvider) == null || t.unregisterComponent(r.detail);
1422
+ }
1423
+ async loggedInHandler(r) {
1424
+ var t, n, s, c, a, d, l;
1425
+ if ((n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("currentUser", r), !!this.nylasSchedulerConfigConnector && (await ((s = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : s.getCalendars()), this.configurationId)) {
1426
+ const u = await ((c = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : c.getConfigurationById(this.configurationId));
1427
+ u && ((a = u[0]) != null && a.id) && ((l = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || l.set("action", "edit"));
1428
+ }
1429
+ }
1430
+ render() {
1431
+ var n, s, c, a, d, l, u, f, y, g, m, p, w, S, x, v, R, _, T;
1432
+ const r = this.host.querySelector('[slot="custom-page-style-inputs"]'), t = (c = (s = (n = this.stores) == null ? void 0 : n.schedulerConfig) == null ? void 0 : s.state.selectedConfiguration) == null ? void 0 : c.id;
1433
+ return h(Host, { key: "e3716df4b6320311046af1b529ee494c9b16c782" }, h("div", { key: "1e33292840f2906cfe0f0d4519192851e18d0ce7", class: "scheduler-editor-header", part: "nse__header" }, h("h1", { key: "830100ac6a1f5c369a6e665f4fe2ea458bf5b44f", class: "scheduler-editor-title", part: "nse__title" }, h("calendar-icon", { key: "b69dafa07a0af6fae4e1f57be7c98221bc8fc237", width: "18", height: "18" }), "Scheduler Editor"), h("button", { key: "c2e4c17d62f67c8c4011a8f41357481bd17eb883", class: "scheduler-editor-close", title: "logout", onClick: (k) => this.handleSchedulerConfigCloseClicked(k), part: "nse__close-button" }, h("close-icon", { key: "74eb653f9b8fea4a7c3669f7a707a5ebaa18d8d1", width: "18", height: "18" }))), h("div", { key: "33273e52377ec5b88672ed66db2a43ceab01b583", class: "scheduler-editor-content", part: "nse__content" }, ((d = (a = this.stores) == null ? void 0 : a.schedulerConfig) == null ? void 0 : d.state.currentUser) && this.stores.schedulerConfig.state.action === null && h("div", { class: "list-configurations" }, h("nylas-list-configurations", { exportparts: "nlc__create-new-cta" })), ((u = (l = this.stores) == null ? void 0 : l.schedulerConfig) == null ? void 0 : u.state.currentUser) && this.stores.schedulerConfig.state.action === "create" && h("nylas-editor-tabs", { mode: "composable" }, h(ExpressFlow, { currentUser: (y = (f = this.stores) == null ? void 0 : f.schedulerConfig) == null ? void 0 : y.state.currentUser, calendars: (p = (m = (g = this.stores) == null ? void 0 : g.schedulerConfig) == null ? void 0 : m.state) == null ? void 0 : p.calendars, selectedConfiguration: (x = (S = (w = this.stores) == null ? void 0 : w.schedulerConfig) == null ? void 0 : S.state) == null ? void 0 : x.selectedConfiguration })), ((R = (v = this.stores) == null ? void 0 : v.schedulerConfig) == null ? void 0 : R.state.currentUser) && this.stores.schedulerConfig.state.action === "edit" && h("nylas-editor-tabs", { key: t, mode: this.mode }, this.mode === "composable" && h("slot", null), this.mode === "app" && r && h("div", { style: { display: "none" }, slot: "custom-page-style-inputs", key: t }, h("slot", { name: "custom-page-style-inputs" }))), !((T = (_ = this.stores) == null ? void 0 : _.schedulerConfig) != null && T.state.currentUser) && h("slot", { name: "login-required" }, h(LoginRequired, { authenticationUrl: this.authenticationUrl }))));
1434
+ }
1435
+ get host() {
1436
+ return getElement(this);
1437
+ }
1438
+ static get watchers() {
1439
+ return {
1440
+ configurationId: ["configurationIdChanged"]
1441
+ };
1442
+ }
1443
+ };
1444
+ NylasSchedulerEditor.style = NylasSchedulerEditorStyle0;
1445
+ export {
1446
+ NylasSchedulerEditor as nylas_scheduler_editor
1447
+ };