@nylas/react 1.1.0-canary.5 → 1.1.0-canary.7
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.
- package/dist/{elements-dc5b338e-e87f79b6.js → elements-dc5b338e-6078b875.js} +1 -1
- package/dist/{elements-dc5b338e-29ef67ec.cjs → elements-dc5b338e-96e197ca.cjs} +1 -1
- package/dist/{focus-visible-e8093c16-61d506d2.cjs → focus-visible-e8093c16-018ffd63.cjs} +1 -1
- package/dist/{focus-visible-e8093c16-e7357f74.js → focus-visible-e8093c16-ab01d60a.js} +1 -1
- package/dist/{index-f9ba9aa8.js → index-1fd24ccf.js} +1039 -1428
- package/dist/index-823fdc6f.cjs +36 -0
- package/dist/react.cjs +1 -1
- package/dist/react.js +52 -52
- package/package.json +3 -3
- package/dist/add-circle-icon_22.entry-9f634efd.js +0 -1731
- package/dist/add-circle-icon_22.entry-e7ec6c34.cjs +0 -1
- package/dist/archive-icon_7.entry-24bac466.js +0 -75
- package/dist/archive-icon_7.entry-6649ed76.cjs +0 -1
- package/dist/arrow-icon.entry-1fffd526.cjs +0 -1
- package/dist/arrow-icon.entry-82e59ce4.js +0 -15
- package/dist/bold-icon_3.entry-5a01fecf.cjs +0 -1
- package/dist/bold-icon_3.entry-72e585da.js +0 -35
- package/dist/calendar-cancel-icon.entry-0b52bdc9.cjs +0 -1
- package/dist/calendar-cancel-icon.entry-247b530c.js +0 -15
- package/dist/calendar-check-icon_2.entry-d7bb76c7.cjs +0 -1
- package/dist/calendar-check-icon_2.entry-dbb2df49.js +0 -25
- package/dist/calendar-icon.entry-911773c4.cjs +0 -1
- package/dist/calendar-icon.entry-d64cb3d3.js +0 -15
- package/dist/chevron-icon_3.entry-b72f4cdb.cjs +0 -1
- package/dist/chevron-icon_3.entry-db9f8217.js +0 -117
- package/dist/close-icon.entry-9d141bb4.js +0 -15
- package/dist/close-icon.entry-da590fa2.cjs +0 -1
- package/dist/constants-6ee60d6d-09ee73d9.cjs +0 -15
- package/dist/constants-6ee60d6d-d5928e79.js +0 -3740
- package/dist/document-refresh-icon.entry-5e8cc2f0.cjs +0 -1
- package/dist/document-refresh-icon.entry-ee9632d7.js +0 -15
- package/dist/forward-icon_6.entry-cac8473a.cjs +0 -3
- package/dist/forward-icon_6.entry-f054ad9d.js +0 -953
- package/dist/globe-icon.entry-2fde6ac4.js +0 -15
- package/dist/globe-icon.entry-bc484551.cjs +0 -1
- package/dist/google-logo-icon_4.entry-a9848399.cjs +0 -1
- package/dist/google-logo-icon_4.entry-dca87e45.js +0 -349
- package/dist/index-22f7e49c.cjs +0 -37
- package/dist/index.es-f57e612a-1d17c676.js +0 -3137
- package/dist/index.es-f57e612a-95ca3e17.cjs +0 -7
- package/dist/info-icon_2.entry-dbf3931a.js +0 -34
- package/dist/info-icon_2.entry-e67844eb.cjs +0 -1
- package/dist/loading-icon.entry-4566cba8.cjs +0 -1
- package/dist/loading-icon.entry-ae4c2d7e.js +0 -15
- package/dist/mailbox-store-47fc8a1a-2365f20f.js +0 -380
- package/dist/mailbox-store-47fc8a1a-cd3516a7.cjs +0 -1
- package/dist/nylas-additional-participants.entry-7c568149.cjs +0 -1
- package/dist/nylas-additional-participants.entry-e8426256.js +0 -81
- package/dist/nylas-booked-event-card_10.entry-6a664889.cjs +0 -1
- package/dist/nylas-booked-event-card_10.entry-ef767733.js +0 -782
- package/dist/nylas-form-card.entry-d8506b1f.js +0 -54
- package/dist/nylas-form-card.entry-e44169b6.cjs +0 -1
- package/dist/nylas-if-state.entry-044c49d2.cjs +0 -1
- package/dist/nylas-if-state.entry-98a336df.js +0 -94
- package/dist/nylas-list-folders.entry-509f9be4.cjs +0 -1
- package/dist/nylas-list-folders.entry-55ce3403.js +0 -120
- package/dist/nylas-list-threads.entry-1f57382a.js +0 -70
- package/dist/nylas-list-threads.entry-c36e2cf3.cjs +0 -1
- package/dist/nylas-login.entry-66f542b8.cjs +0 -1
- package/dist/nylas-login.entry-76358c2f.js +0 -73
- package/dist/nylas-mailbox-pagination.entry-5562257a.js +0 -101
- package/dist/nylas-mailbox-pagination.entry-89b0dd99.cjs +0 -1
- package/dist/nylas-mailbox-toolbar-button.entry-573e0429.cjs +0 -1
- package/dist/nylas-mailbox-toolbar-button.entry-6b1b5b15.js +0 -82
- package/dist/nylas-mailbox.entry-97c503f2.js +0 -134
- package/dist/nylas-mailbox.entry-e21a2f50.cjs +0 -1
- package/dist/nylas-provider.entry-07e1e26a.js +0 -145
- package/dist/nylas-provider.entry-61899957.cjs +0 -1
- package/dist/nylas-scheduler-editor.entry-60fe38ce.cjs +0 -7
- package/dist/nylas-scheduler-editor.entry-e326c9de.js +0 -2275
- package/dist/nylas-scheduling.entry-be0cc090.js +0 -235
- package/dist/nylas-scheduling.entry-d88289db.cjs +0 -1
- package/dist/nylas-threads-refresh.entry-8201f8dd.js +0 -74
- package/dist/nylas-threads-refresh.entry-c71ee775.cjs +0 -1
- package/dist/nylas-threads-search.entry-912a90a4.cjs +0 -1
- package/dist/nylas-threads-search.entry-fc477e01.js +0 -69
- package/dist/nylas-view-thread.entry-af418ddb.cjs +0 -1
- package/dist/nylas-view-thread.entry-d2953ea8.js +0 -203
- package/dist/people-icon.entry-4b598fde.js +0 -15
- package/dist/people-icon.entry-73cfa6f5.cjs +0 -1
- package/dist/play-icon_2.entry-1a487abb.cjs +0 -1
- package/dist/play-icon_2.entry-d1c2f823.js +0 -25
- package/dist/refresh-icon.entry-42d543d0.cjs +0 -1
- package/dist/refresh-icon.entry-6aedfce6.js +0 -15
- package/dist/register-component-cf5c8420-d3fb6bf9.cjs +0 -1
- package/dist/register-component-cf5c8420-dc1bc0a4.js +0 -109
- package/dist/scheduler-config-store-6222c0ed-000f1a4f.js +0 -18
- package/dist/scheduler-config-store-6222c0ed-758621fb.cjs +0 -1
- package/dist/scheduler-store-39d37291-4e8e9ff9.js +0 -293
- package/dist/scheduler-store-39d37291-b66c052c.cjs +0 -1
- package/dist/time-period-selector.entry-f1e27a00.js +0 -76
- package/dist/time-period-selector.entry-fb3d0178.cjs +0 -1
- package/dist/translate-icon.entry-0d44b6cb.cjs +0 -1
- package/dist/translate-icon.entry-3db947f5.js +0 -15
- package/dist/warning-icon.entry-a20657e4.cjs +0 -1
- package/dist/warning-icon.entry-a8ea0fe0.js +0 -15
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { r as b, d as c, h as l, H as f, g as u } from "./index-f9ba9aa8.js";
|
|
2
|
-
import { R as m } from "./register-component-cf5c8420-dc1bc0a4.js";
|
|
3
|
-
import "react";
|
|
4
|
-
import "react-dom";
|
|
5
|
-
const h = ":host{display:block}sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}sp-button:hover{background-color:var(--nylas-color-primary-500)}sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}", p = h;
|
|
6
|
-
var g = function(t, o, e, n) {
|
|
7
|
-
var r = arguments.length, a = r < 3 ? o : n === null ? n = Object.getOwnPropertyDescriptor(o, e) : n, s;
|
|
8
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
9
|
-
a = Reflect.decorate(t, o, e, n);
|
|
10
|
-
else
|
|
11
|
-
for (var i = t.length - 1; i >= 0; i--)
|
|
12
|
-
(s = t[i]) && (a = (r < 3 ? s(a) : r > 3 ? s(o, e, a) : s(o, e)) || a);
|
|
13
|
-
return r > 3 && a && Object.defineProperty(o, e, a), a;
|
|
14
|
-
}, d = function(t, o) {
|
|
15
|
-
if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
|
|
16
|
-
return Reflect.metadata(t, o);
|
|
17
|
-
};
|
|
18
|
-
const y = class {
|
|
19
|
-
constructor(t) {
|
|
20
|
-
b(this, t), this.onClick = async () => {
|
|
21
|
-
const o = this.method;
|
|
22
|
-
if (c("[nylas-mailbox-toolbar-button] onClick", { method: o, mailboxConnector: this.mailboxConnector }), this.mailboxConnector && o) {
|
|
23
|
-
const e = this.callMethod(this.mailboxConnector, o);
|
|
24
|
-
e && await e();
|
|
25
|
-
}
|
|
26
|
-
}, this.method = void 0, this.dataState = void 0, this.iconOnly = !1, this.mailboxConnector = void 0;
|
|
27
|
-
}
|
|
28
|
-
connectedCallback() {
|
|
29
|
-
}
|
|
30
|
-
disconnectedCallback() {
|
|
31
|
-
}
|
|
32
|
-
async componentWillLoad() {
|
|
33
|
-
c("[nylas-if-state] Component will load");
|
|
34
|
-
}
|
|
35
|
-
async componentDidLoad() {
|
|
36
|
-
c("[nylas-if-state] Component did load");
|
|
37
|
-
}
|
|
38
|
-
callMethod(t, o) {
|
|
39
|
-
const e = o.split(".");
|
|
40
|
-
let n = t;
|
|
41
|
-
for (const s of e.slice(0, -1))
|
|
42
|
-
if (n = n[s], !n)
|
|
43
|
-
return;
|
|
44
|
-
const r = e[e.length - 1], a = n[r];
|
|
45
|
-
if (typeof a == "function")
|
|
46
|
-
return a.bind(n);
|
|
47
|
-
}
|
|
48
|
-
renderByState(t) {
|
|
49
|
-
return t ? l("slot", { name: "loading" }, "Loading...") : l("slot", null, "Click");
|
|
50
|
-
}
|
|
51
|
-
hasSlot(t) {
|
|
52
|
-
return !!this.host.querySelector(`[slot="${t}"]`);
|
|
53
|
-
}
|
|
54
|
-
render() {
|
|
55
|
-
var n;
|
|
56
|
-
let t = !1;
|
|
57
|
-
const o = (n = this.mailboxConnector) == null ? void 0 : n.nylasMailboxStore;
|
|
58
|
-
if (typeof o < "u") {
|
|
59
|
-
const r = String(this.dataState);
|
|
60
|
-
t = this.dataState ? o.get(r) === "loading" : !1;
|
|
61
|
-
}
|
|
62
|
-
const e = t ? "state-loading" : "state-ready";
|
|
63
|
-
return l(f, { key: "7e08197532b33b5df9e1b0332a697dd54938e3ef" }, l("sp-theme", { key: "c24c51549d68f06b206fbc1413a026215096c6ad", scale: "medium", color: "dark" }, l("sp-button", { onClick: this.onClick, disabled: t, key: e, "icon-only": this.iconOnly, label: this.renderByState(t) }, this.hasSlot("icon") && l("div", { slot: "icon", class: "slot" }, l("slot", { name: "icon" })), !this.iconOnly && this.renderByState(t))));
|
|
64
|
-
}
|
|
65
|
-
get host() {
|
|
66
|
-
return u(this);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
g([
|
|
70
|
-
m({
|
|
71
|
-
name: "nylas-mailbox-toolbar-button",
|
|
72
|
-
connectorToProp: "mailboxConnector",
|
|
73
|
-
fireRegisterEvent: !0
|
|
74
|
-
}),
|
|
75
|
-
d("design:type", Function),
|
|
76
|
-
d("design:paramtypes", []),
|
|
77
|
-
d("design:returntype", void 0)
|
|
78
|
-
], y.prototype, "render", null);
|
|
79
|
-
y.style = p;
|
|
80
|
-
export {
|
|
81
|
-
y as nylas_mailbox_toolbar_button
|
|
82
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { r as p, c as l, d as S, h as f, H as M, g as _ } from "./index-f9ba9aa8.js";
|
|
2
|
-
import { N as v, e as w } from "./index.es-f57e612a-1d17c676.js";
|
|
3
|
-
import { C as P, a as N, H as I, N as E, b as L, c as O, d as R } from "./mailbox-store-47fc8a1a-2365f20f.js";
|
|
4
|
-
import "react";
|
|
5
|
-
import "react-dom";
|
|
6
|
-
class T {
|
|
7
|
-
constructor(e, s, o, i) {
|
|
8
|
-
this.router = e, this.nylasAuth = s, this.nylasAuthStore = o, this.nylasMailboxStore = i;
|
|
9
|
-
}
|
|
10
|
-
init() {
|
|
11
|
-
S("NylasMailboxConnector init");
|
|
12
|
-
}
|
|
13
|
-
get mailboxStore() {
|
|
14
|
-
return this.nylasMailboxStore;
|
|
15
|
-
}
|
|
16
|
-
get authStore() {
|
|
17
|
-
return this.nylasAuthStore;
|
|
18
|
-
}
|
|
19
|
-
get auth() {
|
|
20
|
-
return this._authConnector ? this._authConnector : (this._authConnector = new E(this.nylasAuth, this.nylasAuthStore), this._authConnector);
|
|
21
|
-
}
|
|
22
|
-
get threads() {
|
|
23
|
-
return this._threadConnector ? this._threadConnector : (this._threadConnector = new L(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore, this.router), this._threadConnector);
|
|
24
|
-
}
|
|
25
|
-
get messages() {
|
|
26
|
-
return this._messageConnector ? this._messageConnector : (this._messageConnector = new O(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._messageConnector);
|
|
27
|
-
}
|
|
28
|
-
get folders() {
|
|
29
|
-
return this._foldersConnector ? this._foldersConnector : (this._foldersConnector = new R(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._foldersConnector);
|
|
30
|
-
}
|
|
31
|
-
getAuth() {
|
|
32
|
-
return this.nylasAuth;
|
|
33
|
-
}
|
|
34
|
-
resetStores() {
|
|
35
|
-
this.nylasMailboxStore.reset(), this.nylasAuthStore.reset();
|
|
36
|
-
}
|
|
37
|
-
async logout() {
|
|
38
|
-
await this.nylasAuth.logout(), this.resetStores();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const H = ":host{display:contents}", k = H, D = class {
|
|
42
|
-
constructor(t) {
|
|
43
|
-
p(this, t), this.init = l(this, "init", 7), this.loggedIn = l(this, "loggedIn", 7), this.loggedOut = l(this, "loggedOut", 7), this.handleAuthChange = async (e) => {
|
|
44
|
-
var s;
|
|
45
|
-
e ? this.loggedIn.emit(this.host) : this.loggedOut.emit(this.host).defaultPrevented || await ((s = this.nylasMailboxConnector) == null ? void 0 : s.logout());
|
|
46
|
-
}, this.automaticComponentRegistration = !0, this.eventOverrides = {}, this.authConfig = void 0, this.defaultAuthStoreState = void 0, this.defaultMailboxStoreState = void 0;
|
|
47
|
-
}
|
|
48
|
-
connectedCallback() {
|
|
49
|
-
S("[nylas-mailbox] connectedCallback");
|
|
50
|
-
}
|
|
51
|
-
async componentWillLoad() {
|
|
52
|
-
var o, i, d, u, c, y, g;
|
|
53
|
-
this.stores = {
|
|
54
|
-
auth: P(this.defaultAuthStoreState),
|
|
55
|
-
mailbox: N(this.defaultMailboxStoreState)
|
|
56
|
-
}, this.baseProvider = new v(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides), this.router = new I(), this.nylasAuth = w({
|
|
57
|
-
apiUri: "https://api.us.nylas.com",
|
|
58
|
-
elementsApiUri: "https://elements.us.nylas.com",
|
|
59
|
-
storageType: "indexeddb",
|
|
60
|
-
clientId: "YOUR_CLIENT_ID",
|
|
61
|
-
defaultScopes: [],
|
|
62
|
-
redirectURI: "/",
|
|
63
|
-
...this.authConfig
|
|
64
|
-
});
|
|
65
|
-
const t = (o = this.baseProvider) == null ? void 0 : o.getStore("auth");
|
|
66
|
-
if (!t)
|
|
67
|
-
throw new Error("Auth store is not defined");
|
|
68
|
-
const e = (i = this.baseProvider) == null ? void 0 : i.getStore("mailbox");
|
|
69
|
-
if (!e)
|
|
70
|
-
throw new Error("Mailbox store is not defined");
|
|
71
|
-
this.nylasMailboxConnector = new T(this.router, this.nylasAuth, t, e), this.init.emit(this.host).defaultPrevented || await ((d = this.nylasMailboxConnector) == null ? void 0 : d.auth.validateSession()), (u = this.router) == null || u.addRouteChangeListener("/thread/:threadId", async (x, A, b) => {
|
|
72
|
-
var a, r;
|
|
73
|
-
const h = b.threadId, n = await ((a = this.nylasMailboxConnector) == null ? void 0 : a.threads.getThread(h));
|
|
74
|
-
n && ((r = this.nylasMailboxConnector) == null || r.mailboxStore.set("selectedThread", n));
|
|
75
|
-
}), (c = this.router) == null || c.addRouteChangeListener("/", async (x, A, b) => {
|
|
76
|
-
var n, a, r, C;
|
|
77
|
-
if (!t.state.isAuthenticated)
|
|
78
|
-
return;
|
|
79
|
-
(n = this.nylasMailboxConnector) == null || n.threads.unSelectThread(), (a = this.nylasMailboxConnector) == null || a.folders.getFolders();
|
|
80
|
-
const h = window.location.hash.split("?")[1];
|
|
81
|
-
if (h) {
|
|
82
|
-
const m = new URLSearchParams(h).get("query");
|
|
83
|
-
m && await ((r = this.nylasMailboxConnector) == null ? void 0 : r.threads.getThreads({
|
|
84
|
-
search_query_native: m,
|
|
85
|
-
page_token: void 0
|
|
86
|
-
}));
|
|
87
|
-
} else
|
|
88
|
-
(C = this.nylasMailboxConnector) == null || C.threads.getThreads();
|
|
89
|
-
}), (y = this.router) == null || y.init(), this.handleAuthChange(t.state.isAuthenticated), (g = this.baseProvider) == null || g.componentWillLoad(this.nylasMailboxConnector);
|
|
90
|
-
}
|
|
91
|
-
async componentDidLoad() {
|
|
92
|
-
var e, s;
|
|
93
|
-
const t = (e = this.baseProvider) == null ? void 0 : e.getStore("auth");
|
|
94
|
-
if (!t)
|
|
95
|
-
throw new Error("Auth store is not defined");
|
|
96
|
-
t.onChange("isAuthenticated", this.handleAuthChange), (s = this.baseProvider) == null || s.componentDidLoad();
|
|
97
|
-
}
|
|
98
|
-
componentDisconnected() {
|
|
99
|
-
var t;
|
|
100
|
-
(t = this.baseProvider) == null || t.componentDisconnected();
|
|
101
|
-
}
|
|
102
|
-
async registerComponentHandler(t) {
|
|
103
|
-
var e;
|
|
104
|
-
(e = this.baseProvider) == null || e.registerComponent(t.detail);
|
|
105
|
-
}
|
|
106
|
-
async unregisterComponentHandler(t) {
|
|
107
|
-
var e;
|
|
108
|
-
(e = this.baseProvider) == null || e.unregisterComponent(t.detail);
|
|
109
|
-
}
|
|
110
|
-
async getMailboxStore() {
|
|
111
|
-
var t;
|
|
112
|
-
return (t = this.baseProvider) == null ? void 0 : t.getStore("mailbox");
|
|
113
|
-
}
|
|
114
|
-
async getAuthStore() {
|
|
115
|
-
var t;
|
|
116
|
-
return (t = this.baseProvider) == null ? void 0 : t.getStore("auth");
|
|
117
|
-
}
|
|
118
|
-
async getNylasAuth() {
|
|
119
|
-
return this.nylasAuth;
|
|
120
|
-
}
|
|
121
|
-
async getNylasMailboxConnector() {
|
|
122
|
-
return this.nylasMailboxConnector;
|
|
123
|
-
}
|
|
124
|
-
render() {
|
|
125
|
-
return f(M, { key: "67b9dd9ccdb6e16408e1a4d548fbe4447335feec" }, f("slot", { key: "6ab88f90f1c13cc2e6999c1ae17cfd0d76a18506" }));
|
|
126
|
-
}
|
|
127
|
-
get host() {
|
|
128
|
-
return _(this);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
D.style = k;
|
|
132
|
-
export {
|
|
133
|
-
D as nylas_mailbox
|
|
134
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-22f7e49c.cjs"),m=require("./index.es-f57e612a-95ca3e17.cjs"),n=require("./mailbox-store-47fc8a1a-cd3516a7.cjs");require("react");require("react-dom");class v{constructor(e,o,r,l){this.router=e,this.nylasAuth=o,this.nylasAuthStore=r,this.nylasMailboxStore=l}init(){s.debug("NylasMailboxConnector init")}get mailboxStore(){return this.nylasMailboxStore}get authStore(){return this.nylasAuthStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new n.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new n.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new n.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new n.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasMailboxStore.reset(),this.nylasAuthStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const _=":host{display:contents}",p=_,x=class{constructor(t){s.registerInstance(this,t),this.init=s.createEvent(this,"init",7),this.loggedIn=s.createEvent(this,"loggedIn",7),this.loggedOut=s.createEvent(this,"loggedOut",7),this.handleAuthChange=async e=>{var o;e?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host).defaultPrevented||await((o=this.nylasMailboxConnector)==null?void 0:o.logout())},this.automaticComponentRegistration=!0,this.eventOverrides={},this.authConfig=void 0,this.defaultAuthStoreState=void 0,this.defaultMailboxStoreState=void 0}connectedCallback(){s.debug("[nylas-mailbox] connectedCallback")}async componentWillLoad(){var r,l,u,c,y,g,b;this.stores={auth:n.CreateNylasAuthStore(this.defaultAuthStoreState),mailbox:n.CreateNylasMailboxStore(this.defaultMailboxStoreState)},this.baseProvider=new m.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.router=new n.HashRouter,this.nylasAuth=m.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const t=(r=this.baseProvider)==null?void 0:r.getStore("auth");if(!t)throw new Error("Auth store is not defined");const e=(l=this.baseProvider)==null?void 0:l.getStore("mailbox");if(!e)throw new Error("Mailbox store is not defined");this.nylasMailboxConnector=new v(this.router,this.nylasAuth,t,e),this.init.emit(this.host).defaultPrevented||await((u=this.nylasMailboxConnector)==null?void 0:u.auth.validateSession()),(c=this.router)==null||c.addRouteChangeListener("/thread/:threadId",async(A,M,C)=>{var i,h;const d=C.threadId,a=await((i=this.nylasMailboxConnector)==null?void 0:i.threads.getThread(d));a&&((h=this.nylasMailboxConnector)==null||h.mailboxStore.set("selectedThread",a))}),(y=this.router)==null||y.addRouteChangeListener("/",async(A,M,C)=>{var a,i,h,S;if(!t.state.isAuthenticated)return;(a=this.nylasMailboxConnector)==null||a.threads.unSelectThread(),(i=this.nylasMailboxConnector)==null||i.folders.getFolders();const d=window.location.hash.split("?")[1];if(d){const f=new URLSearchParams(d).get("query");f&&await((h=this.nylasMailboxConnector)==null?void 0:h.threads.getThreads({search_query_native:f,page_token:void 0}))}else(S=this.nylasMailboxConnector)==null||S.threads.getThreads()}),(g=this.router)==null||g.init(),this.handleAuthChange(t.state.isAuthenticated),(b=this.baseProvider)==null||b.componentWillLoad(this.nylasMailboxConnector)}async componentDidLoad(){var e,o;const t=(e=this.baseProvider)==null?void 0:e.getStore("auth");if(!t)throw new Error("Auth store is not defined");t.onChange("isAuthenticated",this.handleAuthChange),(o=this.baseProvider)==null||o.componentDidLoad()}componentDisconnected(){var t;(t=this.baseProvider)==null||t.componentDisconnected()}async registerComponentHandler(t){var e;(e=this.baseProvider)==null||e.registerComponent(t.detail)}async unregisterComponentHandler(t){var e;(e=this.baseProvider)==null||e.unregisterComponent(t.detail)}async getMailboxStore(){var t;return(t=this.baseProvider)==null?void 0:t.getStore("mailbox")}async getAuthStore(){var t;return(t=this.baseProvider)==null?void 0:t.getStore("auth")}async getNylasAuth(){return this.nylasAuth}async getNylasMailboxConnector(){return this.nylasMailboxConnector}render(){return s.h(s.Host,{key:"67b9dd9ccdb6e16408e1a4d548fbe4447335feec"},s.h("slot",{key:"6ab88f90f1c13cc2e6999c1ae17cfd0d76a18506"}))}get host(){return s.getElement(this)}};x.style=p;exports.nylas_mailbox=x;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { r as C, c as a, d as h, h as g, H as S, g as f } from "./index-f9ba9aa8.js";
|
|
2
|
-
import { N as m, e as b } from "./index.es-f57e612a-1d17c676.js";
|
|
3
|
-
import { C as A, a as p, H as v, N as P, b as _, c as N, d as w } from "./mailbox-store-47fc8a1a-2365f20f.js";
|
|
4
|
-
import { C as x, N as I } from "./scheduler-store-39d37291-4e8e9ff9.js";
|
|
5
|
-
import { C as M } from "./scheduler-config-store-6222c0ed-000f1a4f.js";
|
|
6
|
-
import "react";
|
|
7
|
-
import "react-dom";
|
|
8
|
-
class E {
|
|
9
|
-
constructor(e, s, r, o, l, n, i = "https://api.us.nylas.com") {
|
|
10
|
-
this.router = e, this.schedulerAPIURL = i, this.nylasAuth = s, this.nylasAuthStore = r, this.nylasMailboxStore = o, this.nylasSchedulerStore = l, this.nylasSchedulerConfigStore = n;
|
|
11
|
-
}
|
|
12
|
-
init() {
|
|
13
|
-
h("NylasConnector init");
|
|
14
|
-
}
|
|
15
|
-
get authStore() {
|
|
16
|
-
return this.nylasAuthStore;
|
|
17
|
-
}
|
|
18
|
-
get mailboxStore() {
|
|
19
|
-
return this.nylasMailboxStore;
|
|
20
|
-
}
|
|
21
|
-
get schedulerStore() {
|
|
22
|
-
return this.nylasSchedulerStore;
|
|
23
|
-
}
|
|
24
|
-
get schedulerConfigStore() {
|
|
25
|
-
return this.nylasSchedulerConfigStore;
|
|
26
|
-
}
|
|
27
|
-
get auth() {
|
|
28
|
-
return this._authConnector ? this._authConnector : (this._authConnector = new P(this.nylasAuth, this.nylasAuthStore), this._authConnector);
|
|
29
|
-
}
|
|
30
|
-
get threads() {
|
|
31
|
-
return this._threadConnector ? this._threadConnector : (this._threadConnector = new _(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore, this.router), this._threadConnector);
|
|
32
|
-
}
|
|
33
|
-
get messages() {
|
|
34
|
-
return this._messageConnector ? this._messageConnector : (this._messageConnector = new N(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._messageConnector);
|
|
35
|
-
}
|
|
36
|
-
get folders() {
|
|
37
|
-
return this._foldersConnector ? this._foldersConnector : (this._foldersConnector = new w(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._foldersConnector);
|
|
38
|
-
}
|
|
39
|
-
get scheduler() {
|
|
40
|
-
return this._schedulerAPIConnector ? this._schedulerAPIConnector : (this._schedulerAPIConnector = new I({
|
|
41
|
-
schedulerAPIURL: this.schedulerAPIURL,
|
|
42
|
-
schedulerStore: this.schedulerStore
|
|
43
|
-
}), this._schedulerAPIConnector);
|
|
44
|
-
}
|
|
45
|
-
getAuth() {
|
|
46
|
-
return this.nylasAuth;
|
|
47
|
-
}
|
|
48
|
-
resetStores() {
|
|
49
|
-
this.nylasAuthStore.reset(), this.nylasMailboxStore.reset();
|
|
50
|
-
}
|
|
51
|
-
async logout() {
|
|
52
|
-
await this.nylasAuth.logout(), this.resetStores();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const L = ":host{display:contents}", R = L, T = class {
|
|
56
|
-
constructor(t) {
|
|
57
|
-
C(this, t), this.init = a(this, "init", 7), this.loggedIn = a(this, "loggedIn", 7), this.loggedOut = a(this, "loggedOut", 7), this.handleAuthChange = async (e) => {
|
|
58
|
-
e ? this.loggedIn.emit(this.host) : this.loggedOut.emit(this.host);
|
|
59
|
-
}, this.authConfig = void 0, this.eventOverrides = {}, this.automaticComponentRegistration = !0;
|
|
60
|
-
}
|
|
61
|
-
connectedCallback() {
|
|
62
|
-
h("[nylas-provider] connectedCallback");
|
|
63
|
-
}
|
|
64
|
-
async componentWillLoad() {
|
|
65
|
-
var n, i, c, u, d, y;
|
|
66
|
-
h("[nylas-provider] componentWillLoad"), this.stores = {
|
|
67
|
-
auth: A(),
|
|
68
|
-
mailbox: p(),
|
|
69
|
-
scheduler: x(),
|
|
70
|
-
schedulerConfig: M()
|
|
71
|
-
}, this.baseProvider = new m(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides);
|
|
72
|
-
const t = new v();
|
|
73
|
-
this.nylasAuth = b({
|
|
74
|
-
apiUri: "https://api.us.nylas.com",
|
|
75
|
-
elementsApiUri: "https://elements.us.nylas.com",
|
|
76
|
-
storageType: "indexeddb",
|
|
77
|
-
clientId: "YOUR_CLIENT_ID",
|
|
78
|
-
defaultScopes: [],
|
|
79
|
-
redirectURI: "/",
|
|
80
|
-
...this.authConfig
|
|
81
|
-
});
|
|
82
|
-
const e = (n = this.baseProvider) == null ? void 0 : n.getStore("mailbox");
|
|
83
|
-
if (!e)
|
|
84
|
-
throw new Error("The mailbox store is not set");
|
|
85
|
-
const s = (i = this.baseProvider) == null ? void 0 : i.getStore("auth");
|
|
86
|
-
if (!s)
|
|
87
|
-
throw new Error("The auth store is not set");
|
|
88
|
-
const r = (c = this.baseProvider) == null ? void 0 : c.getStore("scheduler");
|
|
89
|
-
if (!r)
|
|
90
|
-
throw new Error("The scheduler store is not set");
|
|
91
|
-
const o = (u = this.baseProvider) == null ? void 0 : u.getStore("schedulerConfig");
|
|
92
|
-
if (!o)
|
|
93
|
-
throw new Error("The scheduler config store is not set");
|
|
94
|
-
this.nylasConnector = new E(t, this.nylasAuth, s, e, r, o), this.init.emit(this.host).defaultPrevented || await ((d = this.nylasConnector) == null ? void 0 : d.auth.validateSession()), this.handleAuthChange(s.state.isAuthenticated), (y = this.baseProvider) == null || y.componentWillLoad(this.nylasConnector);
|
|
95
|
-
}
|
|
96
|
-
componentDidLoad() {
|
|
97
|
-
var e, s;
|
|
98
|
-
const t = (e = this.baseProvider) == null ? void 0 : e.getStore("auth");
|
|
99
|
-
t == null || t.onChange("isAuthenticated", this.handleAuthChange), (s = this.baseProvider) == null || s.componentDidLoad();
|
|
100
|
-
}
|
|
101
|
-
componentDisconnected() {
|
|
102
|
-
var t;
|
|
103
|
-
(t = this.baseProvider) == null || t.componentDisconnected();
|
|
104
|
-
}
|
|
105
|
-
async registerComponentHandler(t) {
|
|
106
|
-
var e;
|
|
107
|
-
(e = this.baseProvider) == null || e.registerComponent(t.detail);
|
|
108
|
-
}
|
|
109
|
-
async unregisterComponentHandler(t) {
|
|
110
|
-
var e;
|
|
111
|
-
(e = this.baseProvider) == null || e.unregisterComponent(t.detail);
|
|
112
|
-
}
|
|
113
|
-
async getNylasAuth() {
|
|
114
|
-
return this.nylasAuth;
|
|
115
|
-
}
|
|
116
|
-
async getNylasConnector() {
|
|
117
|
-
return this.nylasConnector;
|
|
118
|
-
}
|
|
119
|
-
async getMailboxStore() {
|
|
120
|
-
var t;
|
|
121
|
-
return (t = this.baseProvider) == null ? void 0 : t.getStore("mailbox");
|
|
122
|
-
}
|
|
123
|
-
async getAuthStore() {
|
|
124
|
-
var t;
|
|
125
|
-
return (t = this.baseProvider) == null ? void 0 : t.getStore("auth");
|
|
126
|
-
}
|
|
127
|
-
async getNylasSchedulerStore() {
|
|
128
|
-
var t;
|
|
129
|
-
return (t = this.baseProvider) == null ? void 0 : t.getStore("scheduler");
|
|
130
|
-
}
|
|
131
|
-
async getNylasSchedulerConfigStore() {
|
|
132
|
-
var t;
|
|
133
|
-
return (t = this.baseProvider) == null ? void 0 : t.getStore("schedulerConfig");
|
|
134
|
-
}
|
|
135
|
-
render() {
|
|
136
|
-
return g(S, { key: "1eb5d566a5f7c425be7b30939b06a2dfbd34c7cc" }, g("slot", { key: "f3a6afab3af5893af6602f971dfe67a795f9bd4f" }));
|
|
137
|
-
}
|
|
138
|
-
get host() {
|
|
139
|
-
return f(this);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
T.style = R;
|
|
143
|
-
export {
|
|
144
|
-
T as nylas_provider
|
|
145
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-22f7e49c.cjs"),g=require("./index.es-f57e612a-95ca3e17.cjs"),o=require("./mailbox-store-47fc8a1a-cd3516a7.cjs"),S=require("./scheduler-store-39d37291-b66c052c.cjs"),b=require("./scheduler-config-store-6222c0ed-758621fb.cjs");require("react");require("react-dom");class f{constructor(t,r,n,i,l,h,a="https://api.us.nylas.com"){this.router=t,this.schedulerAPIURL=a,this.nylasAuth=r,this.nylasAuthStore=n,this.nylasMailboxStore=i,this.nylasSchedulerStore=l,this.nylasSchedulerConfigStore=h}init(){s.debug("NylasConnector init")}get authStore(){return this.nylasAuthStore}get mailboxStore(){return this.nylasMailboxStore}get schedulerStore(){return this.nylasSchedulerStore}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new o.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new o.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new o.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new o.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new S.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore}),this._schedulerAPIConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasAuthStore.reset(),this.nylasMailboxStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const m=":host{display:contents}",A=m,C=class{constructor(e){s.registerInstance(this,e),this.init=s.createEvent(this,"init",7),this.loggedIn=s.createEvent(this,"loggedIn",7),this.loggedOut=s.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host)},this.authConfig=void 0,this.eventOverrides={},this.automaticComponentRegistration=!0}connectedCallback(){s.debug("[nylas-provider] connectedCallback")}async componentWillLoad(){var h,a,c,u,d,y;s.debug("[nylas-provider] componentWillLoad"),this.stores={auth:o.CreateNylasAuthStore(),mailbox:o.CreateNylasMailboxStore(),scheduler:S.CreateNylasSchedulerStore(),schedulerConfig:b.CreateNylasSchedulerConfigStore()},this.baseProvider=new g.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const e=new o.HashRouter;this.nylasAuth=g.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const t=(h=this.baseProvider)==null?void 0:h.getStore("mailbox");if(!t)throw new Error("The mailbox store is not set");const r=(a=this.baseProvider)==null?void 0:a.getStore("auth");if(!r)throw new Error("The auth store is not set");const n=(c=this.baseProvider)==null?void 0:c.getStore("scheduler");if(!n)throw new Error("The scheduler store is not set");const i=(u=this.baseProvider)==null?void 0:u.getStore("schedulerConfig");if(!i)throw new Error("The scheduler config store is not set");this.nylasConnector=new f(e,this.nylasAuth,r,t,n,i),this.init.emit(this.host).defaultPrevented||await((d=this.nylasConnector)==null?void 0:d.auth.validateSession()),this.handleAuthChange(r.state.isAuthenticated),(y=this.baseProvider)==null||y.componentWillLoad(this.nylasConnector)}componentDidLoad(){var t,r;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");e==null||e.onChange("isAuthenticated",this.handleAuthChange),(r=this.baseProvider)==null||r.componentDidLoad()}componentDisconnected(){var e;(e=this.baseProvider)==null||e.componentDisconnected()}async registerComponentHandler(e){var t;(t=this.baseProvider)==null||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;(t=this.baseProvider)==null||t.unregisterComponent(e.detail)}async getNylasAuth(){return this.nylasAuth}async getNylasConnector(){return this.nylasConnector}async getMailboxStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("mailbox")}async getAuthStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("auth")}async getNylasSchedulerStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("scheduler")}async getNylasSchedulerConfigStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("schedulerConfig")}render(){return s.h(s.Host,{key:"1eb5d566a5f7c425be7b30939b06a2dfbd34c7cc"},s.h("slot",{key:"f3a6afab3af5893af6602f971dfe67a795f9bd4f"}))}get host(){return s.getElement(this)}};C.style=A;exports.nylas_provider=C;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var P=(n,t,r)=>t in n?U(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var S=(n,t,r)=>(P(n,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const index=require("./index-22f7e49c.cjs"),index_esF57e612a=require("./index.es-f57e612a-95ca3e17.cjs"),schedulerConfigStore6222c0ed=require("./scheduler-config-store-6222c0ed-758621fb.cjs");require("react");require("react-dom");class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:t,nylasSchedulerConfigStore:r}){this.nylasApiRequest=t,this.nylasSchedulerConfigStore=r}async currentUser(){return this.nylasApiRequest?this.nylasApiRequest.currentUser():(console.warn("Nylas API Request is not initialized"),null)}async getCalendars(){var s;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"});const[t,r]=await this.nylasApiRequest.request({method:"GET",path:"calendars"});return r?index.dataResponse(null,{message:"Error fetching calendars: "+r.message}):index_esF57e612a.Xr(t)?index.dataResponse(null,{message:"Error fetching calendars: "+((s=t.error)==null?void 0:s.message)}):(this.nylasSchedulerConfigStore.state.calendars=t.data,index.dataResponse(t.data))}async getConfigurationById(t,r=!1){var c;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"});if(!r){const u=this.nylasSchedulerConfigStore.state.configurations.find(h=>h.id===t);if(u)return this.nylasSchedulerConfigStore.state.config=u,index.dataResponse(u)}const[s,a]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${t}`});return a?index.dataResponse(null,{message:"Error fetching configuration: "+a.message}):index_esF57e612a.Xr(s)?index.dataResponse(null,{message:"Error fetching configuration: "+((c=s.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.config=s.data,this.nylasSchedulerConfigStore.state.configurations.find(u=>u.id===t)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(u=>u.id===t?s.data:u):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,s.data],index.dataResponse(s.data))}async getConfigurations(){var s;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"});const[t,r]=await this.nylasApiRequest.request({method:"GET",path:"scheduling/configurations"});return r?index.dataResponse(null,{message:"Error fetching configurations: "+r.message}):index_esF57e612a.Xr(t)?index.dataResponse(null,{message:"Error fetching configurations: "+((s=t.error)==null?void 0:s.message)}):(this.nylasSchedulerConfigStore.state.configurations=t.data,index.dataResponse(t.data))}async createConfiguration(t){var a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"});t.requires_session_auth=this.nylasSchedulerConfigStore.state.defaultRequiresSessionAuth;const[r,s]=await this.nylasApiRequest.request({method:"POST",path:"scheduling/configurations",body:t});return s?index.dataResponse(null,{message:"Error creating configuration: "+s.message}):index_esF57e612a.Xr(r)?index.dataResponse(null,{message:"Error creating configuration: "+((a=r.error)==null?void 0:a.message)}):(this.nylasSchedulerConfigStore.state.config=r.data,this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,r.data],index.dataResponse(r.data))}async updateConfiguration(t){var a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"});const[r,s]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${t.id}`,body:t});return s?index.dataResponse(null,{message:"Error updating configuration: "+s.message}):index_esF57e612a.Xr(r)?index.dataResponse(null,{message:"Error updating configuration: "+((a=r.error)==null?void 0:a.message)}):(this.nylasSchedulerConfigStore.state.config=r.data,this.nylasSchedulerConfigStore.state.configurations.find(c=>c.id===t.id)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(c=>c.id===t.id?r.data:c):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,r.data],index.dataResponse(r.data))}async deleteConfiguration(t){var a,c;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"});const[r,s]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}`});return s?index.dataResponse(null,{message:"Error deleting configuration: "+s.message}):index_esF57e612a.Xr(r)?index.dataResponse(null,{message:"Error deleting configuration: "+((a=r.error)==null?void 0:a.message)}):(this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter(u=>u.id!==t),((c=this.nylasSchedulerConfigStore.state.config)==null?void 0:c.id)===t&&(this.nylasSchedulerConfigStore.state.config={}),index.dataResponse(r.data))}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:t,nylasSchedulerConfigStore:r}){this.nylasApiRequest=t,this.nylasSchedulerConfigStore=r}init(){index.debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){return this._schedulerConfigConnector?this._schedulerConfigConnector:(this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore}),this._schedulerConfigConnector)}resetStores(){index.debug("NylasSchedulerConfigConnector resetStores"),this.nylasSchedulerConfigStore.reset()}async logout(){index.debug("NylasSchedulerConfigConnector logout"),this.resetStores()}}var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,inited=!1;function init(){inited=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=n.length;t<r;++t)lookup[t]=n[t],revLookup[n.charCodeAt(t)]=t;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63}function toByteArray(n){inited||init();var t,r,s,a,c,u,h=n.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");c=n[h-2]==="="?2:n[h-1]==="="?1:0,u=new Arr(h*3/4-c),s=c>0?h-4:h;var l=0;for(t=0,r=0;t<s;t+=4,r+=3)a=revLookup[n.charCodeAt(t)]<<18|revLookup[n.charCodeAt(t+1)]<<12|revLookup[n.charCodeAt(t+2)]<<6|revLookup[n.charCodeAt(t+3)],u[l++]=a>>16&255,u[l++]=a>>8&255,u[l++]=a&255;return c===2?(a=revLookup[n.charCodeAt(t)]<<2|revLookup[n.charCodeAt(t+1)]>>4,u[l++]=a&255):c===1&&(a=revLookup[n.charCodeAt(t)]<<10|revLookup[n.charCodeAt(t+1)]<<4|revLookup[n.charCodeAt(t+2)]>>2,u[l++]=a>>8&255,u[l++]=a&255),u}function tripletToBase64(n){return lookup[n>>18&63]+lookup[n>>12&63]+lookup[n>>6&63]+lookup[n&63]}function encodeChunk(n,t,r){for(var s,a=[],c=t;c<r;c+=3)s=(n[c]<<16)+(n[c+1]<<8)+n[c+2],a.push(tripletToBase64(s));return a.join("")}function fromByteArray(n){inited||init();for(var t,r=n.length,s=r%3,a="",c=[],u=16383,h=0,l=r-s;h<l;h+=u)c.push(encodeChunk(n,h,h+u>l?l:h+u));return s===1?(t=n[r-1],a+=lookup[t>>2],a+=lookup[t<<4&63],a+="=="):s===2&&(t=(n[r-2]<<8)+n[r-1],a+=lookup[t>>10],a+=lookup[t>>4&63],a+=lookup[t<<2&63],a+="="),c.push(a),c.join("")}function read(n,t,r,s,a){var c,u,h=a*8-s-1,l=(1<<h)-1,f=l>>1,p=-7,d=r?a-1:0,x=r?-1:1,g=n[t+d];for(d+=x,c=g&(1<<-p)-1,g>>=-p,p+=h;p>0;c=c*256+n[t+d],d+=x,p-=8);for(u=c&(1<<-p)-1,c>>=-p,p+=s;p>0;u=u*256+n[t+d],d+=x,p-=8);if(c===0)c=1-f;else{if(c===l)return u?NaN:(g?-1:1)*(1/0);u=u+Math.pow(2,s),c=c-f}return(g?-1:1)*u*Math.pow(2,c-s)}function write(n,t,r,s,a,c){var u,h,l,f=c*8-a-1,p=(1<<f)-1,d=p>>1,x=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=s?0:c-1,w=s?1:-1,y=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(h=isNaN(t)?1:0,u=p):(u=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-u))<1&&(u--,l*=2),u+d>=1?t+=x/l:t+=x*Math.pow(2,1-d),t*l>=2&&(u++,l/=2),u+d>=p?(h=0,u=p):u+d>=1?(h=(t*l-1)*Math.pow(2,a),u=u+d):(h=t*Math.pow(2,d-1)*Math.pow(2,a),u=0));a>=8;n[r+g]=h&255,g+=w,h/=256,a-=8);for(u=u<<a|h,f+=a;f>0;n[r+g]=u&255,g+=w,u/=256,f-=8);n[r+g-w]|=y*128}var toString={}.toString,isArray=Array.isArray||function(n){return toString.call(n)=="[object Array]"};/*!
|
|
2
|
-
* The buffer module from node.js, for the browser.
|
|
3
|
-
*
|
|
4
|
-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
5
|
-
* @license MIT
|
|
6
|
-
*/var INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=index_esF57e612a.global$1.TYPED_ARRAY_SUPPORT!==void 0?index_esF57e612a.global$1.TYPED_ARRAY_SUPPORT:!0;function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(n,t){if(kMaxLength()<t)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=Buffer.prototype):(n===null&&(n=new Buffer(t)),n.length=t),n}function Buffer(n,t,r){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer))return new Buffer(n,t,r);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,n)}return from(this,n,t,r)}Buffer.poolSize=8192;Buffer._augment=function(n){return n.__proto__=Buffer.prototype,n};function from(n,t,r,s){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?fromArrayBuffer(n,t,r,s):typeof t=="string"?fromString(n,t,r):fromObject(n,t)}Buffer.from=function(n,t,r){return from(null,n,t,r)};Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array);function assertSize(n){if(typeof n!="number")throw new TypeError('"size" argument must be a number');if(n<0)throw new RangeError('"size" argument must not be negative')}function alloc(n,t,r,s){return assertSize(t),t<=0?createBuffer(n,t):r!==void 0?typeof s=="string"?createBuffer(n,t).fill(r,s):createBuffer(n,t).fill(r):createBuffer(n,t)}Buffer.alloc=function(n,t,r){return alloc(null,n,t,r)};function allocUnsafe(n,t){if(assertSize(t),n=createBuffer(n,t<0?0:checked(t)|0),!Buffer.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)n[r]=0;return n}Buffer.allocUnsafe=function(n){return allocUnsafe(null,n)};Buffer.allocUnsafeSlow=function(n){return allocUnsafe(null,n)};function fromString(n,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!Buffer.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var s=byteLength(t,r)|0;n=createBuffer(n,s);var a=n.write(t,r);return a!==s&&(n=n.slice(0,a)),n}function fromArrayLike(n,t){var r=t.length<0?0:checked(t.length)|0;n=createBuffer(n,r);for(var s=0;s<r;s+=1)n[s]=t[s]&255;return n}function fromArrayBuffer(n,t,r,s){if(r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(s||0))throw new RangeError("'length' is out of bounds");return r===void 0&&s===void 0?t=new Uint8Array(t):s===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,s),Buffer.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=Buffer.prototype):n=fromArrayLike(n,t),n}function fromObject(n,t){if(internalIsBuffer(t)){var r=checked(t.length)|0;return n=createBuffer(n,r),n.length===0||t.copy(n,0,0,r),n}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||isnan(t.length)?createBuffer(n,0):fromArrayLike(n,t);if(t.type==="Buffer"&&isArray(t.data))return fromArrayLike(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(n){if(n>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return n|0}Buffer.isBuffer=isBuffer;function internalIsBuffer(n){return!!(n!=null&&n._isBuffer)}Buffer.compare=function(t,r){if(!internalIsBuffer(t)||!internalIsBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var s=t.length,a=r.length,c=0,u=Math.min(s,a);c<u;++c)if(t[c]!==r[c]){s=t[c],a=r[c];break}return s<a?-1:a<s?1:0};Buffer.isEncoding=function(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!0;default:return!1}};Buffer.concat=function(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 s;if(r===void 0)for(r=0,s=0;s<t.length;++s)r+=t[s].length;var a=Buffer.allocUnsafe(r),c=0;for(s=0;s<t.length;++s){var u=t[s];if(!internalIsBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(a,c),c+=u.length}return a};function byteLength(n,t){if(internalIsBuffer(n))return n.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;typeof n!="string"&&(n=""+n);var r=n.length;if(r===0)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return utf8ToBytes(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return base64ToBytes(n).length;default:if(s)return utf8ToBytes(n).length;t=(""+t).toLowerCase(),s=!0}}Buffer.byteLength=byteLength;function slowToString(n,t,r){var s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(n||(n="utf8");;)switch(n){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(s)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),s=!0}}Buffer.prototype._isBuffer=!0;function swap(n,t,r){var s=n[t];n[t]=n[r],n[r]=s}Buffer.prototype.swap16=function(){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(){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(){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(){var t=this.length|0;return t===0?"":arguments.length===0?utf8Slice(this,0,t):slowToString.apply(this,arguments)};Buffer.prototype.equals=function(t){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:Buffer.compare(this,t)===0};Buffer.prototype.inspect=function(){var t="",r=INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"};Buffer.prototype.compare=function(t,r,s,a,c){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),s===void 0&&(s=t?t.length:0),a===void 0&&(a=0),c===void 0&&(c=this.length),r<0||s>t.length||a<0||c>this.length)throw new RangeError("out of range index");if(a>=c&&r>=s)return 0;if(a>=c)return-1;if(r>=s)return 1;if(r>>>=0,s>>>=0,a>>>=0,c>>>=0,this===t)return 0;for(var u=c-a,h=s-r,l=Math.min(u,h),f=this.slice(a,c),p=t.slice(r,s),d=0;d<l;++d)if(f[d]!==p[d]){u=f[d],h=p[d];break}return u<h?-1:h<u?1:0};function bidirectionalIndexOf(n,t,r,s,a){if(n.length===0)return-1;if(typeof r=="string"?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=a?0:n.length-1),r<0&&(r=n.length+r),r>=n.length){if(a)return-1;r=n.length-1}else if(r<0)if(a)r=0;else return-1;if(typeof t=="string"&&(t=Buffer.from(t,s)),internalIsBuffer(t))return t.length===0?-1:arrayIndexOf(n,t,r,s,a);if(typeof t=="number")return t=t&255,Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(n,t,r):Uint8Array.prototype.lastIndexOf.call(n,t,r):arrayIndexOf(n,[t],r,s,a);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(n,t,r,s,a){var c=1,u=n.length,h=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(n.length<2||t.length<2)return-1;c=2,u/=2,h/=2,r/=2}function l(g,w){return c===1?g[w]:g.readUInt16BE(w*c)}var f;if(a){var p=-1;for(f=r;f<u;f++)if(l(n,f)===l(t,p===-1?0:f-p)){if(p===-1&&(p=f),f-p+1===h)return p*c}else p!==-1&&(f-=f-p),p=-1}else for(r+h>u&&(r=u-h),f=r;f>=0;f--){for(var d=!0,x=0;x<h;x++)if(l(n,f+x)!==l(t,x)){d=!1;break}if(d)return f}return-1}Buffer.prototype.includes=function(t,r,s){return this.indexOf(t,r,s)!==-1};Buffer.prototype.indexOf=function(t,r,s){return bidirectionalIndexOf(this,t,r,s,!0)};Buffer.prototype.lastIndexOf=function(t,r,s){return bidirectionalIndexOf(this,t,r,s,!1)};function hexWrite(n,t,r,s){r=Number(r)||0;var a=n.length-r;s?(s=Number(s),s>a&&(s=a)):s=a;var c=t.length;if(c%2!==0)throw new TypeError("Invalid hex string");s>c/2&&(s=c/2);for(var u=0;u<s;++u){var h=parseInt(t.substr(u*2,2),16);if(isNaN(h))return u;n[r+u]=h}return u}function utf8Write(n,t,r,s){return blitBuffer(utf8ToBytes(t,n.length-r),n,r,s)}function asciiWrite(n,t,r,s){return blitBuffer(asciiToBytes(t),n,r,s)}function latin1Write(n,t,r,s){return asciiWrite(n,t,r,s)}function base64Write(n,t,r,s){return blitBuffer(base64ToBytes(t),n,r,s)}function ucs2Write(n,t,r,s){return blitBuffer(utf16leToBytes(t,n.length-r),n,r,s)}Buffer.prototype.write=function(t,r,s,a){if(r===void 0)a="utf8",s=this.length,r=0;else if(s===void 0&&typeof r=="string")a=r,s=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(s)?(s=s|0,a===void 0&&(a="utf8")):(a=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var c=this.length-r;if((s===void 0||s>c)&&(s=c),t.length>0&&(s<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var u=!1;;)switch(a){case"hex":return hexWrite(this,t,r,s);case"utf8":case"utf-8":return utf8Write(this,t,r,s);case"ascii":return asciiWrite(this,t,r,s);case"latin1":case"binary":return latin1Write(this,t,r,s);case"base64":return base64Write(this,t,r,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,r,s);default:if(u)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),u=!0}};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(n,t,r){return t===0&&r===n.length?fromByteArray(n):fromByteArray(n.slice(t,r))}function utf8Slice(n,t,r){r=Math.min(n.length,r);for(var s=[],a=t;a<r;){var c=n[a],u=null,h=c>239?4:c>223?3:c>191?2:1;if(a+h<=r){var l,f,p,d;switch(h){case 1:c<128&&(u=c);break;case 2:l=n[a+1],(l&192)===128&&(d=(c&31)<<6|l&63,d>127&&(u=d));break;case 3:l=n[a+1],f=n[a+2],(l&192)===128&&(f&192)===128&&(d=(c&15)<<12|(l&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(u=d));break;case 4:l=n[a+1],f=n[a+2],p=n[a+3],(l&192)===128&&(f&192)===128&&(p&192)===128&&(d=(c&15)<<18|(l&63)<<12|(f&63)<<6|p&63,d>65535&&d<1114112&&(u=d))}}u===null?(u=65533,h=1):u>65535&&(u-=65536,s.push(u>>>10&1023|55296),u=56320|u&1023),s.push(u),a+=h}return decodeCodePointsArray(s)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(n){var t=n.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,n);for(var r="",s=0;s<t;)r+=String.fromCharCode.apply(String,n.slice(s,s+=MAX_ARGUMENTS_LENGTH));return r}function asciiSlice(n,t,r){var s="";r=Math.min(n.length,r);for(var a=t;a<r;++a)s+=String.fromCharCode(n[a]&127);return s}function latin1Slice(n,t,r){var s="";r=Math.min(n.length,r);for(var a=t;a<r;++a)s+=String.fromCharCode(n[a]);return s}function hexSlice(n,t,r){var s=n.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);for(var a="",c=t;c<r;++c)a+=toHex(n[c]);return a}function utf16leSlice(n,t,r){for(var s=n.slice(t,r),a="",c=0;c<s.length;c+=2)a+=String.fromCharCode(s[c]+s[c+1]*256);return a}Buffer.prototype.slice=function(t,r){var s=this.length;t=~~t,r=r===void 0?s:~~r,t<0?(t+=s,t<0&&(t=0)):t>s&&(t=s),r<0?(r+=s,r<0&&(r=0)):r>s&&(r=s),r<t&&(r=t);var a;if(Buffer.TYPED_ARRAY_SUPPORT)a=this.subarray(t,r),a.__proto__=Buffer.prototype;else{var c=r-t;a=new Buffer(c,void 0);for(var u=0;u<c;++u)a[u]=this[u+t]}return a};function checkOffset(n,t,r){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>r)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(t,r,s){t=t|0,r=r|0,s||checkOffset(t,r,this.length);for(var a=this[t],c=1,u=0;++u<r&&(c*=256);)a+=this[t+u]*c;return a};Buffer.prototype.readUIntBE=function(t,r,s){t=t|0,r=r|0,s||checkOffset(t,r,this.length);for(var a=this[t+--r],c=1;r>0&&(c*=256);)a+=this[t+--r]*c;return a};Buffer.prototype.readUInt8=function(t,r){return r||checkOffset(t,1,this.length),this[t]};Buffer.prototype.readUInt16LE=function(t,r){return r||checkOffset(t,2,this.length),this[t]|this[t+1]<<8};Buffer.prototype.readUInt16BE=function(t,r){return r||checkOffset(t,2,this.length),this[t]<<8|this[t+1]};Buffer.prototype.readUInt32LE=function(t,r){return r||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};Buffer.prototype.readUInt32BE=function(t,r){return r||checkOffset(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};Buffer.prototype.readIntLE=function(t,r,s){t=t|0,r=r|0,s||checkOffset(t,r,this.length);for(var a=this[t],c=1,u=0;++u<r&&(c*=256);)a+=this[t+u]*c;return c*=128,a>=c&&(a-=Math.pow(2,8*r)),a};Buffer.prototype.readIntBE=function(t,r,s){t=t|0,r=r|0,s||checkOffset(t,r,this.length);for(var a=r,c=1,u=this[t+--a];a>0&&(c*=256);)u+=this[t+--a]*c;return c*=128,u>=c&&(u-=Math.pow(2,8*r)),u};Buffer.prototype.readInt8=function(t,r){return r||checkOffset(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};Buffer.prototype.readInt16LE=function(t,r){r||checkOffset(t,2,this.length);var s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s};Buffer.prototype.readInt16BE=function(t,r){r||checkOffset(t,2,this.length);var s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s};Buffer.prototype.readInt32LE=function(t,r){return r||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};Buffer.prototype.readInt32BE=function(t,r){return r||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};Buffer.prototype.readFloatLE=function(t,r){return r||checkOffset(t,4,this.length),read(this,t,!0,23,4)};Buffer.prototype.readFloatBE=function(t,r){return r||checkOffset(t,4,this.length),read(this,t,!1,23,4)};Buffer.prototype.readDoubleLE=function(t,r){return r||checkOffset(t,8,this.length),read(this,t,!0,52,8)};Buffer.prototype.readDoubleBE=function(t,r){return r||checkOffset(t,8,this.length),read(this,t,!1,52,8)};function checkInt(n,t,r,s,a,c){if(!internalIsBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<c)throw new RangeError('"value" argument is out of bounds');if(r+s>n.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function(t,r,s,a){if(t=+t,r=r|0,s=s|0,!a){var c=Math.pow(2,8*s)-1;checkInt(this,t,r,s,c,0)}var u=1,h=0;for(this[r]=t&255;++h<s&&(u*=256);)this[r+h]=t/u&255;return r+s};Buffer.prototype.writeUIntBE=function(t,r,s,a){if(t=+t,r=r|0,s=s|0,!a){var c=Math.pow(2,8*s)-1;checkInt(this,t,r,s,c,0)}var u=s-1,h=1;for(this[r+u]=t&255;--u>=0&&(h*=256);)this[r+u]=t/h&255;return r+s};Buffer.prototype.writeUInt8=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};function objectWriteUInt16(n,t,r,s){t<0&&(t=65535+t+1);for(var a=0,c=Math.min(n.length-r,2);a<c;++a)n[r+a]=(t&255<<8*(s?a:1-a))>>>(s?a:1-a)*8}Buffer.prototype.writeUInt16LE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):objectWriteUInt16(this,t,r,!0),r+2};Buffer.prototype.writeUInt16BE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):objectWriteUInt16(this,t,r,!1),r+2};function objectWriteUInt32(n,t,r,s){t<0&&(t=4294967295+t+1);for(var a=0,c=Math.min(n.length-r,4);a<c;++a)n[r+a]=t>>>(s?a:3-a)*8&255}Buffer.prototype.writeUInt32LE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):objectWriteUInt32(this,t,r,!0),r+4};Buffer.prototype.writeUInt32BE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):objectWriteUInt32(this,t,r,!1),r+4};Buffer.prototype.writeIntLE=function(t,r,s,a){if(t=+t,r=r|0,!a){var c=Math.pow(2,8*s-1);checkInt(this,t,r,s,c-1,-c)}var u=0,h=1,l=0;for(this[r]=t&255;++u<s&&(h*=256);)t<0&&l===0&&this[r+u-1]!==0&&(l=1),this[r+u]=(t/h>>0)-l&255;return r+s};Buffer.prototype.writeIntBE=function(t,r,s,a){if(t=+t,r=r|0,!a){var c=Math.pow(2,8*s-1);checkInt(this,t,r,s,c-1,-c)}var u=s-1,h=1,l=0;for(this[r+u]=t&255;--u>=0&&(h*=256);)t<0&&l===0&&this[r+u+1]!==0&&(l=1),this[r+u]=(t/h>>0)-l&255;return r+s};Buffer.prototype.writeInt8=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1};Buffer.prototype.writeInt16LE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):objectWriteUInt16(this,t,r,!0),r+2};Buffer.prototype.writeInt16BE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):objectWriteUInt16(this,t,r,!1),r+2};Buffer.prototype.writeInt32LE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):objectWriteUInt32(this,t,r,!0),r+4};Buffer.prototype.writeInt32BE=function(t,r,s){return t=+t,r=r|0,s||checkInt(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):objectWriteUInt32(this,t,r,!1),r+4};function checkIEEE754(n,t,r,s,a,c){if(r+s>n.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(n,t,r,s,a){return a||checkIEEE754(n,t,r,4),write(n,t,r,s,23,4),r+4}Buffer.prototype.writeFloatLE=function(t,r,s){return writeFloat(this,t,r,!0,s)};Buffer.prototype.writeFloatBE=function(t,r,s){return writeFloat(this,t,r,!1,s)};function writeDouble(n,t,r,s,a){return a||checkIEEE754(n,t,r,8),write(n,t,r,s,52,8),r+8}Buffer.prototype.writeDoubleLE=function(t,r,s){return writeDouble(this,t,r,!0,s)};Buffer.prototype.writeDoubleBE=function(t,r,s){return writeDouble(this,t,r,!1,s)};Buffer.prototype.copy=function(t,r,s,a){if(s||(s=0),!a&&a!==0&&(a=this.length),r>=t.length&&(r=t.length),r||(r=0),a>0&&a<s&&(a=s),a===s||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("sourceStart out of bounds");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),t.length-r<a-s&&(a=t.length-r+s);var c=a-s,u;if(this===t&&s<r&&r<a)for(u=c-1;u>=0;--u)t[u+r]=this[u+s];else if(c<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(u=0;u<c;++u)t[u+r]=this[u+s];else Uint8Array.prototype.set.call(t,this.subarray(s,s+c),r);return c};Buffer.prototype.fill=function(t,r,s,a){if(typeof t=="string"){if(typeof r=="string"?(a=r,r=0,s=this.length):typeof s=="string"&&(a=s,s=this.length),t.length===1){var c=t.charCodeAt(0);c<256&&(t=c)}if(a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!Buffer.isEncoding(a))throw new TypeError("Unknown encoding: "+a)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<s)throw new RangeError("Out of range index");if(s<=r)return this;r=r>>>0,s=s===void 0?this.length:s>>>0,t||(t=0);var u;if(typeof t=="number")for(u=r;u<s;++u)this[u]=t;else{var h=internalIsBuffer(t)?t:utf8ToBytes(new Buffer(t,a).toString()),l=h.length;for(u=0;u<s-r;++u)this[u+r]=h[u%l]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(n){if(n=stringtrim(n).replace(INVALID_BASE64_RE,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function stringtrim(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function toHex(n){return n<16?"0"+n.toString(16):n.toString(16)}function utf8ToBytes(n,t){t=t||1/0;for(var r,s=n.length,a=null,c=[],u=0;u<s;++u){if(r=n.charCodeAt(u),r>55295&&r<57344){if(!a){if(r>56319){(t-=3)>-1&&c.push(239,191,189);continue}else if(u+1===s){(t-=3)>-1&&c.push(239,191,189);continue}a=r;continue}if(r<56320){(t-=3)>-1&&c.push(239,191,189),a=r;continue}r=(a-55296<<10|r-56320)+65536}else a&&(t-=3)>-1&&c.push(239,191,189);if(a=null,r<128){if((t-=1)<0)break;c.push(r)}else if(r<2048){if((t-=2)<0)break;c.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;c.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;c.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return c}function asciiToBytes(n){for(var t=[],r=0;r<n.length;++r)t.push(n.charCodeAt(r)&255);return t}function utf16leToBytes(n,t){for(var r,s,a,c=[],u=0;u<n.length&&!((t-=2)<0);++u)r=n.charCodeAt(u),s=r>>8,a=r%256,c.push(a),c.push(s);return c}function base64ToBytes(n){return toByteArray(base64clean(n))}function blitBuffer(n,t,r,s){for(var a=0;a<s&&!(a+r>=t.length||a>=n.length);++a)t[a+r]=n[a];return a}function isnan(n){return n!==n}function isBuffer(n){return n!=null&&(!!n._isBuffer||isFastBuffer(n)||isSlowBuffer(n))}function isFastBuffer(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function isSlowBuffer(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&isFastBuffer(n.slice(0,0))}class LocalStorage{get(t){return new Promise(r=>{const s=window.localStorage.getItem(t);r(s?JSON.parse(s):null)})}async remove(t){return window.localStorage.removeItem(t),new Promise(r=>{r(null)})}set(t,r){return window.localStorage.setItem(t,JSON.stringify(r)),new Promise(s=>{s(null)})}}const PKCE_KEY="pkce",GRANT_KEY="grant",USER_KEY="user";class Storage{constructor(t){S(this,"Storage",new LocalStorage);if(t){this.Storage=t;return}}setPKCE(t){const r=Buffer.from(t);this.Storage.set(PKCE_KEY,r.toString("base64"))}async getPKCE(){try{const t=await this.Storage.get(PKCE_KEY);if(t)return Buffer.from(t,"base64").toString("utf8")}catch{return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(t,r=!1){const{grant_id:s}=t;this.Storage.set(`${GRANT_KEY}${r?"-"+s:""}`,t)}removeGrant(t,r=!1){this.Storage.remove(`${GRANT_KEY}${r?"-"+t:""}`)}async getGrant(t,r=!1){const s=await this.Storage.get(`${GRANT_KEY}${r?"-"+t:""}`);return s||null}async setUserToken(t){const r=await this.getUserTokens();if(r)if(r.find(a=>a.sub===t.sub)){const a=r.map(c=>(c.sub===t.sub&&(c=t),c));this.Storage.set(USER_KEY,a)}else{const a=[...r,t];this.Storage.set(USER_KEY,a)}else this.Storage.set(USER_KEY,[t])}async getUserToken(t=""){const r=await this.Storage.get(USER_KEY);return r?t===""?r[0]:r.find(a=>a.sub===t):null}async getUserTokens(){const t=await this.Storage.get(USER_KEY);return t||null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(t){const r=await this.getUserTokens(),s=r==null?void 0:r.filter(a=>a.sub!==t);this.Storage.set(USER_KEY,s)}async clearSession(){const t=await this.getUserTokens();t==null||t.forEach(r=>{this.removeGrant(r.sub)}),this.removePKCE(),this.removeUserTokens()}}class IndexedDBStorage{constructor(){S(this,"databaseName","identity-db");S(this,"storeName","identity")}get(t){const r=this;return new Promise((s,a)=>{r.openDatabase().then(function(c){const u=c.transaction(r.storeName,"readwrite"),l=u.objectStore(r.storeName).get(t);l.onsuccess=()=>{s(l.result)},l.onerror=()=>{a(l.error)},u.oncomplete=()=>{c.close()}})})}async remove(t){const r=this;return new Promise((s,a)=>{const c=indexedDB.open(this.databaseName);c.onupgradeneeded=function(u){u.target.result.createObjectStore(r.storeName)},c.onerror=()=>{a(c.error)},c.onsuccess=u=>{const h=u.target.result,l=h.transaction(this.storeName,"readwrite"),p=l.objectStore(this.storeName).delete(t);p.onsuccess=()=>{s(null)},p.onerror=()=>{a(p.error)},l.oncomplete=()=>{h.close()}}})}set(t,r){return new Promise((s,a)=>{const c=indexedDB.open(this.databaseName);c.onerror=()=>{a(c.error)},c.onupgradeneeded=u=>{u.target.result.createObjectStore(this.storeName)},c.onsuccess=u=>{const h=u.target.result,l=h.transaction(this.storeName,"readwrite"),p=l.objectStore(this.storeName).put(r,t);p.onsuccess=()=>{s(r)},p.onerror=()=>{a(p.error)},l.oncomplete=()=>{h.close()}}})}openDatabase(){const t=this;return new Promise(function(r,s){const a=indexedDB.open(t.databaseName,2);a.onupgradeneeded=function(c){c.target.result.createObjectStore(t.storeName)},a.onsuccess=function(c){r(c.target.result)},a.onerror=function(c){s(c.error)}})}}var process=index.commonjsGlobal.process,sha256={exports:{}};(function(module){(function(){var ERROR="input is invalid type",WINDOW=typeof window=="object",root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self=="object",NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;NODE_JS?root=index.commonjsGlobal:WEB_WORKER&&(root=self);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=[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],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(n){return Object.prototype.toString.call(n)==="[object Array]"}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(n){return typeof n=="object"&&n.buffer&&n.buffer.constructor===ArrayBuffer});var createOutputMethod=function(n,t){return function(r){return new Sha256(t,!0).update(r)[n]()}},createMethod=function(n){var t=createOutputMethod("hex",n);NODE_JS&&(t=nodeWrap(t,n)),t.create=function(){return new Sha256(n)},t.update=function(a){return t.create().update(a)};for(var r=0;r<OUTPUT_TYPES.length;++r){var s=OUTPUT_TYPES[r];t[s]=createOutputMethod(s,n)}return t},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(n){if(typeof n=="string")return crypto.createHash(algorithm).update(n,"utf8").digest("hex");if(n==null)throw new Error(ERROR);return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(n)).digest("hex"):method(n)};return nodeMethod},createHmacOutputMethod=function(n,t){return function(r,s){return new HmacSha256(r,t,!0).update(s)[n]()}},createHmacMethod=function(n){var t=createHmacOutputMethod("hex",n);t.create=function(a){return new HmacSha256(a,n)},t.update=function(a,c){return t.create(a).update(c)};for(var r=0;r<OUTPUT_TYPES.length;++r){var s=OUTPUT_TYPES[r];t[s]=createHmacOutputMethod(s,n)}return t};function Sha256(n,t){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],n?(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=n}Sha256.prototype.update=function(n){if(!this.finalized){var t,r=typeof n;if(r!=="string"){if(r==="object"){if(n===null)throw new Error(ERROR);if(ARRAY_BUFFER&&n.constructor===ArrayBuffer)n=new Uint8Array(n);else if(!Array.isArray(n)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(n)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var s,a=0,c,u=n.length,h=this.blocks;a<u;){if(this.hashed&&(this.hashed=!1,h[0]=this.block,h[16]=h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7]=h[8]=h[9]=h[10]=h[11]=h[12]=h[13]=h[14]=h[15]=0),t)for(c=this.start;a<u&&c<64;++a)h[c>>2]|=n[a]<<SHIFT[c++&3];else for(c=this.start;a<u&&c<64;++a)s=n.charCodeAt(a),s<128?h[c>>2]|=s<<SHIFT[c++&3]:s<2048?(h[c>>2]|=(192|s>>6)<<SHIFT[c++&3],h[c>>2]|=(128|s&63)<<SHIFT[c++&3]):s<55296||s>=57344?(h[c>>2]|=(224|s>>12)<<SHIFT[c++&3],h[c>>2]|=(128|s>>6&63)<<SHIFT[c++&3],h[c>>2]|=(128|s&63)<<SHIFT[c++&3]):(s=65536+((s&1023)<<10|n.charCodeAt(++a)&1023),h[c>>2]|=(240|s>>18)<<SHIFT[c++&3],h[c>>2]|=(128|s>>12&63)<<SHIFT[c++&3],h[c>>2]|=(128|s>>6&63)<<SHIFT[c++&3],h[c>>2]|=(128|s&63)<<SHIFT[c++&3]);this.lastByteIndex=c,this.bytes+=c-this.start,c>=64?(this.block=h[16],this.start=c-64,this.hash(),this.hashed=!0):this.start=c}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var n=this.blocks,t=this.lastByteIndex;n[16]=this.block,n[t>>2]|=EXTRA[t&3],this.block=n[16],t>=56&&(this.hashed||this.hash(),n[0]=this.block,n[16]=n[1]=n[2]=n[3]=n[4]=n[5]=n[6]=n[7]=n[8]=n[9]=n[10]=n[11]=n[12]=n[13]=n[14]=n[15]=0),n[14]=this.hBytes<<3|this.bytes>>>29,n[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var n=this.h0,t=this.h1,r=this.h2,s=this.h3,a=this.h4,c=this.h5,u=this.h6,h=this.h7,l=this.blocks,f,p,d,x,g,w,y,m,A,v,_;for(f=16;f<64;++f)g=l[f-15],p=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=l[f-2],d=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,l[f]=l[f-16]+p+l[f-7]+d<<0;for(_=t&r,f=0;f<64;f+=4)this.first?(this.is224?(m=300032,g=l[0]-1413257819,h=g-150054599<<0,s=g+24177077<<0):(m=704751109,g=l[0]-210244248,h=g-1521486534<<0,s=g+143694565<<0),this.first=!1):(p=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),m=n&t,x=m^n&r^_,y=a&c^~a&u,g=h+d+y+K[f]+l[f],w=p+x,h=s+g<<0,s=g+w<<0),p=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),d=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),A=s&n,x=A^s&t^m,y=h&a^~h&c,g=u+d+y+K[f+1]+l[f+1],w=p+x,u=r+g<<0,r=g+w<<0,p=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),v=r&s,x=v^r&n^A,y=u&h^~u&a,g=c+d+y+K[f+2]+l[f+2],w=p+x,c=t+g<<0,t=g+w<<0,p=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),_=t&r,x=_^t&s^v,y=c&u^~c&h,g=a+d+y+K[f+3]+l[f+3],w=p+x,a=n+g<<0,n=g+w<<0;this.h0=this.h0+n<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+s<<0,this.h4=this.h4+a<<0,this.h5=this.h5+c<<0,this.h6=this.h6+u<<0,this.h7=this.h7+h<<0},Sha256.prototype.hex=function(){this.finalize();var n=this.h0,t=this.h1,r=this.h2,s=this.h3,a=this.h4,c=this.h5,u=this.h6,h=this.h7,l=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[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[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[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[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[u>>28&15]+HEX_CHARS[u>>24&15]+HEX_CHARS[u>>20&15]+HEX_CHARS[u>>16&15]+HEX_CHARS[u>>12&15]+HEX_CHARS[u>>8&15]+HEX_CHARS[u>>4&15]+HEX_CHARS[u&15];return this.is224||(l+=HEX_CHARS[h>>28&15]+HEX_CHARS[h>>24&15]+HEX_CHARS[h>>20&15]+HEX_CHARS[h>>16&15]+HEX_CHARS[h>>12&15]+HEX_CHARS[h>>8&15]+HEX_CHARS[h>>4&15]+HEX_CHARS[h&15]),l},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var n=this.h0,t=this.h1,r=this.h2,s=this.h3,a=this.h4,c=this.h5,u=this.h6,h=this.h7,l=[n>>24&255,n>>16&255,n>>8&255,n&255,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,s>>24&255,s>>16&255,s>>8&255,s&255,a>>24&255,a>>16&255,a>>8&255,a&255,c>>24&255,c>>16&255,c>>8&255,c&255,u>>24&255,u>>16&255,u>>8&255,u&255];return this.is224||l.push(h>>24&255,h>>16&255,h>>8&255,h&255),l},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var n=new ArrayBuffer(this.is224?28:32),t=new DataView(n);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),n};function HmacSha256(n,t,r){var s,a=typeof n;if(a==="string"){var c=[],u=n.length,h=0,l;for(s=0;s<u;++s)l=n.charCodeAt(s),l<128?c[h++]=l:l<2048?(c[h++]=192|l>>6,c[h++]=128|l&63):l<55296||l>=57344?(c[h++]=224|l>>12,c[h++]=128|l>>6&63,c[h++]=128|l&63):(l=65536+((l&1023)<<10|n.charCodeAt(++s)&1023),c[h++]=240|l>>18,c[h++]=128|l>>12&63,c[h++]=128|l>>6&63,c[h++]=128|l&63);n=c}else if(a==="object"){if(n===null)throw new Error(ERROR);if(ARRAY_BUFFER&&n.constructor===ArrayBuffer)n=new Uint8Array(n);else if(!Array.isArray(n)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(n)))throw new Error(ERROR)}else throw new Error(ERROR);n.length>64&&(n=new Sha256(t,!0).update(n).array());var f=[],p=[];for(s=0;s<64;++s){var d=n[s]||0;f[s]=92^d,p[s]=54^d}Sha256.call(this,t,r),this.update(p),this.oKeyPad=f,this.inner=!0,this.sharedMemory=r}HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var n=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(n),Sha256.prototype.finalize.call(this)}};var exports=createMethod();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)})()})(sha256);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!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(n){return typeof n=="string"&®EX.test(n)}var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(byteToHex[n[t+0]]+byteToHex[n[t+1]]+byteToHex[n[t+2]]+byteToHex[n[t+3]]+"-"+byteToHex[n[t+4]]+byteToHex[n[t+5]]+"-"+byteToHex[n[t+6]]+byteToHex[n[t+7]]+"-"+byteToHex[n[t+8]]+byteToHex[n[t+9]]+"-"+byteToHex[n[t+10]]+byteToHex[n[t+11]]+byteToHex[n[t+12]]+byteToHex[n[t+13]]+byteToHex[n[t+14]]+byteToHex[n[t+15]]).toLowerCase();if(!validate(r))throw TypeError("Stringified UUID is invalid");return r}function v4(n,t,r){n=n||{};var s=n.random||(n.rng||rng)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){r=r||0;for(var a=0;a<16;++a)t[r+a]=s[a];return t}return stringify(s)}async function getBytes(n,t){const r=n.getReader();let s;for(;!(s=await r.read()).done;)t(s.value)}function getLines(n){let t,r,s,a=!1;return function(u){t===void 0?(t=u,r=0,s=-1):t=concat(t,u);const h=t.length;let l=0;for(;r<h;){a&&(t[r]===10&&(l=++r),a=!1);let f=-1;for(;r<h&&f===-1;++r)switch(t[r]){case 58:s===-1&&(s=r-l);break;case 13:a=!0;case 10:f=r;break}if(f===-1)break;n(t.subarray(l,f),s),l=r,s=-1}l===h?t=void 0:l!==0&&(t=t.subarray(l),r-=l)}}function getMessages(n,t,r){let s=newMessage();const a=new TextDecoder;return function(u,h){if(u.length===0)r==null||r(s),s=newMessage();else if(h>0){const l=a.decode(u.subarray(0,h)),f=h+(u[h+1]===32?2:1),p=a.decode(u.subarray(f));switch(l){case"data":s.data=s.data?s.data+`
|
|
7
|
-
`+p:p;break;case"event":s.event=p;break;case"id":n(s.id=p);break;case"retry":const d=parseInt(p,10);isNaN(d)||t(s.retry=d);break}}}}function concat(n,t){const r=new Uint8Array(n.length+t.length);return r.set(n),r.set(t,n.length),r}function newMessage(){return{data:"",event:"",id:"",retry:void 0}}var __rest=function(n,t){var r={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(r[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(n);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(n,s[a])&&(r[s[a]]=n[s[a]]);return r};const EventStreamContentType="text/event-stream",DefaultRetryInterval=1e3,LastEventId="last-event-id";function fetchEventSource(n,t){var{signal:r,headers:s,onopen:a,onmessage:c,onclose:u,onerror:h,openWhenHidden:l,fetch:f}=t,p=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,x)=>{const g=Object.assign({},s);g.accept||(g.accept=EventStreamContentType);let w;function y(){w.abort(),document.hidden||T()}l||document.addEventListener("visibilitychange",y);let m=DefaultRetryInterval,A=0;function v(){document.removeEventListener("visibilitychange",y),window.clearTimeout(A),w.abort()}r==null||r.addEventListener("abort",()=>{v(),d()});const _=f??window.fetch,k=a??defaultOnOpen;async function T(){var I;w=new AbortController;try{const b=await _(n,Object.assign(Object.assign({},p),{headers:g,signal:w.signal}));await k(b),await getBytes(b.body,getLines(getMessages(R=>{R?g[LastEventId]=R:delete g[LastEventId]},R=>{m=R},c))),u==null||u(),v(),d()}catch(b){if(!w.signal.aborted)try{const R=(I=h==null?void 0:h(b))!==null&&I!==void 0?I:m;window.clearTimeout(A),A=window.setTimeout(T,R)}catch(R){v(),x(R)}}}T()})}function defaultOnOpen(n){const t=n.headers.get("content-type");if(!(t!=null&&t.startsWith(EventStreamContentType)))throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}function Base64EncodeUrl(n){return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function getTimestamp(){return Math.floor(Date.now()/1e3)}function e(n){this.message=n}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(n){var t=String(n).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,s,a=0,c=0,u="";s=t.charAt(c++);~s&&(r=a%4?64*r+s:s,a++%4)?u+=String.fromCharCode(255&r>>(-2*a&6)):0)s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);return u};function t$1(n){var t=n.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(r){return decodeURIComponent(r$1(r).replace(/(.)/g,function(s,a){var c=a.charCodeAt(0).toString(16).toUpperCase();return c.length<2&&(c="0"+c),"%"+c}))}(t)}catch{return r$1(t)}}function n$1(n){this.message=n}function o(n,t){if(typeof n!="string")throw new n$1("Invalid token specified");var r=(t=t||{}).header===!0?0:1;try{return JSON.parse(t$1(n.split(".")[r]))}catch(s){throw new n$1("Invalid token specified: "+s.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{constructor(t){S(this,"clientId");S(this,"redirectUri");S(this,"accessType","online");S(this,"domain","http://api.nylas.com");S(this,"versioned",!1);S(this,"Storage");S(this,"hosted",!1);S(this,"multiAccount",!1);S(this,"loginId","");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){const r=new IndexedDBStorage;this.Storage=new Storage(r)}else this.Storage=new Storage;t.accessType&&(this.accessType=t.accessType),t.loginId&&(this.loginId=t.loginId),t.hosted&&(this.hosted=t.hosted),this.codeExchange(null)}async validateAccessToken(t=""){const{access_token:r}=await this.Storage.getGrant(t,this.multiAccount);try{return!!(await(await fetch(`${this.domain}/connect/tokeninfo?access_token=${r}`,{method:"GET"})).json()).data}catch{return!1}}async validateIDToken(t=""){const{id_token:r}=await this.Storage.getGrant(t,this.multiAccount);try{const s=await fetch(`${this.domain}/connect/tokeninfo?id_token=${r}`,{method:"GET"});return!(s.status!==200||!(await s.json()).data)}catch{return!1}}getDomain(){return this.domain}async auth(t){this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))&&await this.hostedSetCodeChallenge();const r=await this.generateAuthURL(t);if(t.popup){this.popUp(r);return}return r}async generateAuthURL(t){const r=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return r&&(s+=`&code_challenge=${r}&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}async generateReauthURL(t,r){if(!t)throw new Error("Grant ID is required");const s=await this.Storage.getUserToken(t),a=await this.getCodeChallege();let c=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return a&&(c+=`&code_challenge=${a}&code_challenge_method=S256&options=rotate_refresh_token`),s!=null&&s.provider&&(c+=`&provider=${s.provider}`),s!=null&&s.email&&(c+=`&login_hint=${s.email}`),r&&(c+=`&scope=${r.join(" ")}`),c}async generateCodeChallenge(){if(await this.Storage.getPKCE())return;const r=v4();this.Storage.setPKCE(r)}async hostedSetCodeChallenge(){if(!this.hosted)throw console.error("Method only used with hosted flag enabled");const r=new URLSearchParams(window.location.search).get("code_challenge");if(!r){if(await this.Storage.getPKCE())return;console.warn("Code challenge is recomended");return}this.Storage.setPKCE(r)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const s=new URLSearchParams(window.location.search).get("code_challenge");return s||(console.warn("Code challenge is recomended"),"")}const t=await this.Storage.getPKCE();if(t){const r=sha256.exports.sha256(t);let s=Buffer.from(r).toString("base64");return s=Base64EncodeUrl(s),s}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin)))return!1;const t=await this.Storage.getUserTokens();return t&&t.length>0?(this.multiAccount&&await this.generateCodeChallenge(),!0):(await this.generateCodeChallenge(),!1)}isMultiAccount(){return this.multiAccount}async logout(){const t=await this.getProfile();await this.Storage.clearSession();const r={detail:t};window.dispatchEvent(new CustomEvent("onLogoutSuccess",r))}async getProfile(t=""){let r;return t?r=await this.Storage.getUserToken(t):r=await this.Storage.getUserToken(),r||null}async getProfiles(){const t=await this.Storage.getUserTokens();return t||null}async removeProfile(t){return await this.Storage.removeUserToken(t),await this.Storage.removeGrant(t),null}async authIMAP(t){const r=await this.getCodeChallege(),s={imap_username:t.username,imap_password:t.password,imap_host:t.hostIMAP,imap_port:t.portIMAP,type:t.type,smtp_host:t.hostSMTP,smtp_port:t.portSMTP,provider:t.provider,redirect_uri:this.redirectUri,state:t.state,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(s.id=this.loginId),r!=""&&(s.code_challenge=r,s.code_challenge_method="S256"),await(await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json()}async authEWS(t){const r=await this.getCodeChallege(),s={...t,redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(s.id=this.loginId),r!=""&&(s.code_challenge=r,s.code_challenge_method="S256"),await(await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json()}async detectEmail(t){return(await(await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`,{method:"POST",headers:new Headers({"content-type":"application/json"})})).json()).data}async applicationInfo(){return(await(await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})})).json()).data}async getAvailableProviders(){const t=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});return t?(await t.json()).data:null}onLoginSuccess(t){window.addEventListener("onLoginSuccess",r=>t(r))}onLogoutSuccess(t){window.addEventListener("onLogoutSuccess",r=>t(r))}onLoginFail(t){window.addEventListener("onLoginFail",r=>t(r))}onTokenRefreshSuccess(t){window.addEventListener("onTokenRefreshSuccess",r=>t(r))}onTokenRefreshFail(t){window.addEventListener("onTokenRefreshFail",r=>t(r))}onSessionExpired(t){window.addEventListener("onSessionExpired",r=>t(r))}async codeExchange(t){let r=new URLSearchParams(window.location.search);t&&(r=new URLSearchParams(t));const s=r.get("code"),a=r.get("state"),c=r.get("error"),u=r.get("error_description"),h=r.get("error_code");if(c&&u&&h){const f={detail:{error:c,error_description:u,error_code:h}};return window.dispatchEvent(new CustomEvent("onLoginFail",f)),window.history.pushState({},document.title,window.location.pathname),!1}if(!s)return console.warn("No code found"),!1;if(window.opener&&window.name==="uas-popup")return console.warn("Popup window detected"),!1;const l=await this.Storage.getPKCE();if(!l)return console.warn("No code verifier found"),!1;try{const f={client_id:this.clientId,redirect_uri:this.redirectUri,code:s,grant_type:"authorization_code",code_verifier:l},d=await(await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(f)})).json();if(d){if(d.error){const g={detail:d};return window.dispatchEvent(new CustomEvent("onLoginFail",g)),!0}const x=await this.handleCodeExchangeResponse(d);if(x.valid){a&&(x.data.state=a);const g={detail:x.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",g)),window.history.pushState({},document.title,window.location.pathname)}else{const g={detail:x.data};return window.dispatchEvent(new CustomEvent("onLoginFail",g)),!0}}return this.Storage.removePKCE(),!0}catch(f){const p={detail:f};return window.dispatchEvent(new CustomEvent("onLoginFail",p)),window.history.pushState({},document.title,window.location.pathname),!1}}async tokenExchange(t=""){const{refresh_token:r}=await this.Storage.getGrant(t,this.multiAccount);try{const s={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:r,grant_type:"refresh_token"},c=await(await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json();if(c){if(c.error){const f={detail:c};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",f)),!0}const u=getTimestamp();if(c.expires_in=u+c.expires_in,this.Storage.setGrant(c,this.multiAccount),!await this.validateIDToken(t)){const f={detail:c};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",f)),!0}const l={detail:c};return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",l)),!0}this.Storage.removePKCE()}catch(s){const a={detail:s};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",a)),!1}}async handleCodeExchangeResponse(t){if(t.error)return{data:t,valid:!1};const s=getTimestamp();t.expires_in=s+t.expires_in,this.Storage.setGrant(t,this.multiAccount);const a=o(t.id_token);return a.status="authenticated",this.Storage.setUserToken(a),await this.validateIDToken(a.sub)?{data:t,valid:!0}:{data:t,valid:!1}}async popUp(t){const a=window.screenX+(window.outerWidth-500)/2,c=window.screenY+(window.outerHeight-600)/2.5,u="uas-popup",h=t,l=window.open(h,u,`width=500,height=600,left=${a},top=${c}`);if(!l)return;const f=setInterval(async()=>{if(l.closed){const p={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",p)),f&&clearInterval(f);return}try{const p=l.location.href.split("?");if(!p[0])return;const d=l.location.search;if(l.history.pushState({},document.title,window.location.pathname),p[0]===this.redirectUri&&p.length>1){const x=await this.codeExchange(d);l.close(),x&&location.reload(),f&&clearInterval(f);return}}catch{return}},1e3)}async getAccessToken(t=""){const r=getTimestamp(),{access_token:s,expires_in:a}=await this.Storage.getGrant(t,this.multiAccount),c=s;return c&&a&&a>getTimestamp()&&a-r>30?c:(await this.tokenExchange(t),(await this.Storage.getGrant(t,this.multiAccount)).access_token)}async sse(t,r){const s=r.headers||{},a=s["Grant-ID"];let c="";if(this.multiAccount){if(!a)throw new Error("Grant ID is required for multi account calls");c=await this.getAccessToken(a)}else c=await this.getAccessToken();return delete s["Grant-ID"],s.Authorization=`Bearer ${c}`,s["content-type"]||(s["content-type"]="application/json"),fetchEventSource(`${this.domain}/${t}`,{...r,headers:s})}async fetch(t,r,s=!0,a){let c="",u=1;if(this.multiAccount){if(!r.grant_id)throw new Error("Grant ID is required for multi account calls");const l=await this.getProfiles();u=l?l.length:1,c=await this.getAccessToken(r.grant_id)}else c=await this.getAccessToken();let h=r.headers;Headers.prototype.isPrototypeOf(h)?(h.append("Authorization",`Bearer ${c}`),h.has("content-type")||h.append("content-type","application/json")):h=new Headers({Authorization:`Bearer ${c}`,"content-type":"application/json"});try{r!=null&&r.body&&(r.body=JSON.stringify(r==null?void 0:r.body));const l=await fetch(`${a||this.domain}/${t}`,{...r,headers:h});if(!s)return l;const f=await(l==null?void 0:l.json());if(!await this.isAuthenticatedResponse(l.status,f)){if(u>1){const d=await this.getProfile(r.grant_id);if(d){d.status="unauthorized",await this.Storage.setUserToken(d);const x={detail:{user:d}};window.dispatchEvent(new CustomEvent("onSessionExpired",x))}}else{const x={detail:{user:await this.Storage.getUserToken()}};window.dispatchEvent(new CustomEvent("onSessionExpired",x)),this.logout()}return}return f}catch(l){throw l}}async fetchRequest(t,r,s,a=!0,c,u){const h=await this.isLoggedIn(),l=new URL(t,c??this.domain),f=new Headers;if(f.append("Accept","application/json"),f.append("Content-Type","application/json"),f.append("User-Agent","nylas-identity"),h){const x=await this.getAccessToken();f.append("Authorization",`Bearer ${x}`)}const p=await fetch(l.toString(),{method:r||"GET",headers:f,mode:"cors",referrer:location.origin,body:s?JSON.stringify(s):void 0,...u||{}});return a?await p.json():p.body}async isAuthenticatedResponse(t,r){var s;return!(t==401&&((s=r==null?void 0:r.error)==null?void 0:s.type)=="token.unauthorized_access")}addAPIKey(t,r,s){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:!0,iat:getTimestamp(),iss:"",email:r,provider:"virtual-calendar",status:"authenticated",name:r,sub:t}),this.Storage.setGrant({grant_id:t,access_token:s,expires_in:2e9},this.multiAccount)}}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(n,t,r){this.props=n,this.context=t,this.refs=D,this.updater=r||B}E.prototype.isReactComponent={};E.prototype.setState=function(n,t){if(typeof n!="object"&&typeof n!="function"&&n!=null)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,n,t,"setState")};E.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(n,t,r){this.props=n,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;const LoginRequired=({authenticationUrl:n})=>index.h("div",{class:"login-required"},index.h("div",{class:"card"},index.h("p",null,"Log into your account to use the Scheduler Editor."),index.h("button",{class:"google-button",onClick:async t=>{t.preventDefault();const r=await n("google");r?window.location.href=r:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},index.h("span",{class:"icon"},index.h("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),index.h("button",{class:"microsoft-button",onClick:async t=>{t.preventDefault();const r=await n("microsoft");r?window.location.href=r:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},index.h("span",{class:"icon"},index.h("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),index.h("button",{class:"other-provider-button",onClick:async t=>{t.preventDefault();const r=await n();r?window.location.href=r:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},"View all providers ",index.h("chevron-icon",{width:"17",height:"17"})),index.h("small",{class:"disclaimer-text"},"* You will be redirected to authenticate your account."))),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}.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}',NylasSchedulerEditorStyle0=nylasSchedulerEditorCss,NylasSchedulerEditor=class{constructor(n){index.registerInstance(this,n),this.init=index.createEvent(this,"init",7),this.loggedIn=index.createEvent(this,"loggedIn",7),this.loggedOut=index.createEvent(this,"loggedOut",7),this.schedulerConfigCloseClicked=index.createEvent(this,"schedulerConfigCloseClicked",7),this.handleSchedulerConfigCloseClicked=t=>{this.schedulerConfigCloseClicked.emit(this.host)},this.authenticationUrl=async t=>this.nylasApiRequest?await this.nylasApiRequest.authenticationUrl({provider:t})||"":(console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."),""),this.defaultRequiresSessionAuth=!0,this.configurationId=void 0,this.nylasApiRequest=void 0,this.nylasSessionsConfig=void 0,this.eventOverrides={},this.schedulerPreviewLink="",this.defaultSchedulerConfigStoreState=void 0,this.mode="app",this.automaticComponentRegistration=!0}connectedCallback(){index.debug("[nylas-scheduler-editor] connectedCallback")}async componentWillLoad(){var r,s,a,c,u,h,l,f,p;if(index.debug("[nylas-scheduler-editor] componentWillLoad"),this.stores={schedulerConfig:schedulerConfigStore6222c0ed.CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigStoreState})},(s=(r=this.stores)==null?void 0:r.schedulerConfig)==null||s.set("defaultRequiresSessionAuth",this.defaultRequiresSessionAuth),!this.nylasApiRequest&&this.nylasSessionsConfig){const d=new NylasSessions(this.nylasSessionsConfig);await d.isLoggedIn(),d.onLoginSuccess(async()=>{var g,w;const x=await((w=(g=this.nylasSchedulerConfigConnector)==null?void 0:g.schedulerConfig)==null?void 0:w.currentUser());x&&(this.loggedIn.emit(this.host),this.loggedInHandler(x))}),d.onLoginFail(async()=>{var x,g;(g=(x=this.stores)==null?void 0:x.schedulerConfig)==null||g.set("currentUser",null),this.loggedOut.emit(this.host)}),this.nylasApiRequest=new index.NylasIdentityRequestWrapper(d)}this.baseProvider=new index_esF57e612a.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const n=this.baseProvider.getStore("schedulerConfig");if(this.nylasSchedulerConfigConnector=new NylasSchedulerConfigConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:n}),!this.init.emit(this.host).defaultPrevented){const d=await((c=(a=this.nylasSchedulerConfigConnector)==null?void 0:a.schedulerConfig)==null?void 0:c.currentUser());d?(this.loggedIn.emit(this.host),await this.loggedInHandler(d)):((h=(u=this.stores)==null?void 0:u.schedulerConfig)==null||h.set("currentUser",null),this.loggedOut.emit(this.host))}(f=(l=this.stores)==null?void 0:l.schedulerConfig)==null||f.onChange("config",async d=>{d&&d.id&&(this.configurationId=d.id)}),(p=this.baseProvider)==null||p.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){var n;index.debug("[nylas-scheduler-editor] componentDidLoad"),(n=this.baseProvider)==null||n.componentDidLoad()}componentDisconnected(){var n;(n=this.baseProvider)==null||n.componentDisconnected()}defaultRequiresSessionAuthChanged(n){var t,r;(r=(t=this.stores)==null?void 0:t.schedulerConfig)==null||r.set("defaultRequiresSessionAuth",n)}async configurationIdChanged(n){var t,r,s,a,c,u,h,l;n?(await((r=(t=this.nylasSchedulerConfigConnector)==null?void 0:t.schedulerConfig)==null?void 0:r.getConfigurationById(n)),(a=(s=this.stores)==null?void 0:s.schedulerConfig)==null||a.set("action","edit")):((u=(c=this.stores)==null?void 0:c.schedulerConfig)==null||u.set("config",{}),(l=(h=this.stores)==null?void 0:h.schedulerConfig)==null||l.set("action",null))}async store(){var n;return(n=this.stores)==null?void 0:n.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(n){var t;(t=this.baseProvider)==null||t.registerComponent(n.detail)}async unregisterComponentHandler(n){var t;(t=this.baseProvider)==null||t.unregisterComponent(n.detail)}async loggedInHandler(n){var t,r,s,a;(r=(t=this.stores)==null?void 0:t.schedulerConfig)==null||r.set("currentUser",n),this.nylasSchedulerConfigConnector&&(this.configurationId&&await((s=this.nylasSchedulerConfigConnector.schedulerConfig)==null?void 0:s.getConfigurationById(this.configurationId)),await((a=this.nylasSchedulerConfigConnector.schedulerConfig)==null?void 0:a.getCalendars()))}render(){var t,r,s,a,c,u;return this.mode==="app"?index.h(index.Host,null,index.h("div",{class:"scheduler-editor-header",part:"nse__header"},index.h("h1",{class:"scheduler-editor-title",part:"nse__title"},index.h("calendar-icon",{width:"18",height:"18"}),"Scheduler editor"),index.h("button",{class:"scheduler-editor-close",onClick:h=>this.handleSchedulerConfigCloseClicked(h),part:"nse__close-button"},index.h("close-icon",{width:"18",height:"18"}))),((r=(t=this.stores)==null?void 0:t.schedulerConfig)==null?void 0:r.state.currentUser)&&this.stores.schedulerConfig.state.action===null&&index.h("div",{class:"list-configurations"},index.h("nylas-list-configurations",null)),((a=(s=this.stores)==null?void 0:s.schedulerConfig)==null?void 0:a.state.currentUser)&&(this.stores.schedulerConfig.state.action==="create"||this.stores.schedulerConfig.state.action==="edit")&&index.h("nylas-editor-tabs",null),!((u=(c=this.stores)==null?void 0:c.schedulerConfig)!=null&&u.state.currentUser)&&index.h("slot",{name:"login-required"},index.h(LoginRequired,{authenticationUrl:this.authenticationUrl}))):index.h(index.Host,null,index.h("slot",null))}get host(){return index.getElement(this)}static get watchers(){return{defaultRequiresSessionAuth:["defaultRequiresSessionAuthChanged"],configurationId:["configurationIdChanged"]}}};NylasSchedulerEditor.style=NylasSchedulerEditorStyle0;exports.nylas_scheduler_editor=NylasSchedulerEditor;
|