@sesamy/sesamy-js 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sesamy-js.es.js +2736 -0
- package/dist/sesamy-js.umd.js +30 -0
- package/package.json +14 -5
- package/.env +0 -2
- package/.env.production +0 -2
- package/.github/workflows/release.yml +0 -22
- package/.nvmrc +0 -1
- package/article.html +0 -13
- package/index.html +0 -23
- package/public/sesamy.png +0 -0
- package/renovate.json +0 -6
- package/src/actions/index.ts +0 -1
- package/src/app.ts +0 -91
- package/src/constants.ts +0 -2
- package/src/events/ready.ts +0 -11
- package/src/javascript-api.ts +0 -30
- package/src/main.ts +0 -29
- package/src/services/analytics/element-tracker.ts +0 -124
- package/src/services/analytics/index.ts +0 -214
- package/src/services/analytics/listeners/index.ts +0 -2
- package/src/services/analytics/listeners/route.ts +0 -8
- package/src/services/analytics/listeners/scroll.ts +0 -61
- package/src/services/analytics/types/analytics/activity-utils/index.d.ts +0 -52
- package/src/services/analytics/types/analytics/router-utils/index.d.ts +0 -7
- package/src/services/analytics/types/analytics/scroll-utils/index.d.ts +0 -4
- package/src/services/analytics/types/track-event.ts +0 -70
- package/src/services/auth/index.ts +0 -60
- package/src/state.ts +0 -3
- package/src/style.css +0 -97
- package/src/types/Config.ts +0 -11
- package/src/types/Events.ts +0 -3
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -23
- package/vite.config.js +0 -18
|
@@ -0,0 +1,2736 @@
|
|
|
1
|
+
var tr = Object.defineProperty;
|
|
2
|
+
var nr = (t, e, n) => e in t ? tr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var Y = (t, e, n) => (nr(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
(function() {
|
|
5
|
+
const e = document.createElement("link").relList;
|
|
6
|
+
if (e && e.supports && e.supports("modulepreload"))
|
|
7
|
+
return;
|
|
8
|
+
for (const i of document.querySelectorAll('link[rel="modulepreload"]'))
|
|
9
|
+
r(i);
|
|
10
|
+
new MutationObserver((i) => {
|
|
11
|
+
for (const o of i)
|
|
12
|
+
if (o.type === "childList")
|
|
13
|
+
for (const a of o.addedNodes)
|
|
14
|
+
a.tagName === "LINK" && a.rel === "modulepreload" && r(a);
|
|
15
|
+
}).observe(document, { childList: !0, subtree: !0 });
|
|
16
|
+
function n(i) {
|
|
17
|
+
const o = {};
|
|
18
|
+
return i.integrity && (o.integrity = i.integrity), i.referrerPolicy && (o.referrerPolicy = i.referrerPolicy), i.crossOrigin === "use-credentials" ? o.credentials = "include" : i.crossOrigin === "anonymous" ? o.credentials = "omit" : o.credentials = "same-origin", o;
|
|
19
|
+
}
|
|
20
|
+
function r(i) {
|
|
21
|
+
if (i.ep)
|
|
22
|
+
return;
|
|
23
|
+
i.ep = !0;
|
|
24
|
+
const o = n(i);
|
|
25
|
+
fetch(i.href, o);
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
var wt = /* @__PURE__ */ ((t) => (t.READY = "sesamyReady", t))(wt || {});
|
|
29
|
+
async function rr() {
|
|
30
|
+
const t = new CustomEvent(wt.READY, {
|
|
31
|
+
detail: {},
|
|
32
|
+
bubbles: !0,
|
|
33
|
+
composed: !0
|
|
34
|
+
});
|
|
35
|
+
dispatchEvent(t);
|
|
36
|
+
}
|
|
37
|
+
function q(t, e) {
|
|
38
|
+
var n = {};
|
|
39
|
+
for (var r in t)
|
|
40
|
+
Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
|
|
41
|
+
if (t != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
42
|
+
var i = 0;
|
|
43
|
+
for (r = Object.getOwnPropertySymbols(t); i < r.length; i++)
|
|
44
|
+
e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
|
|
45
|
+
}
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
var ae = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
49
|
+
function bt(t) {
|
|
50
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
51
|
+
}
|
|
52
|
+
function kt(t, e) {
|
|
53
|
+
return t(e = { exports: {} }, e.exports), e.exports;
|
|
54
|
+
}
|
|
55
|
+
var oe = kt(function(t, e) {
|
|
56
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
57
|
+
var n = function() {
|
|
58
|
+
function r() {
|
|
59
|
+
var i = this;
|
|
60
|
+
this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(o, a) {
|
|
61
|
+
var s = i.locked.get(o);
|
|
62
|
+
s === void 0 ? a === void 0 ? i.locked.set(o, []) : i.locked.set(o, [a]) : a !== void 0 && (s.unshift(a), i.locked.set(o, s));
|
|
63
|
+
}, this.isLocked = function(o) {
|
|
64
|
+
return i.locked.has(o);
|
|
65
|
+
}, this.lock = function(o) {
|
|
66
|
+
return new Promise(function(a, s) {
|
|
67
|
+
i.isLocked(o) ? i.addToLocked(o, a) : (i.addToLocked(o), a());
|
|
68
|
+
});
|
|
69
|
+
}, this.unlock = function(o) {
|
|
70
|
+
var a = i.locked.get(o);
|
|
71
|
+
if (a !== void 0 && a.length !== 0) {
|
|
72
|
+
var s = a.pop();
|
|
73
|
+
i.locked.set(o, a), s !== void 0 && setTimeout(s, 0);
|
|
74
|
+
} else
|
|
75
|
+
i.locked.delete(o);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return r.getInstance = function() {
|
|
79
|
+
return r.instance === void 0 && (r.instance = new r()), r.instance;
|
|
80
|
+
}, r;
|
|
81
|
+
}();
|
|
82
|
+
e.default = function() {
|
|
83
|
+
return n.getInstance();
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
bt(oe);
|
|
87
|
+
var ir = bt(kt(function(t, e) {
|
|
88
|
+
var n = ae && ae.__awaiter || function(u, c, d, h) {
|
|
89
|
+
return new (d || (d = Promise))(function(v, w) {
|
|
90
|
+
function y(I) {
|
|
91
|
+
try {
|
|
92
|
+
_(h.next(I));
|
|
93
|
+
} catch (g) {
|
|
94
|
+
w(g);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function k(I) {
|
|
98
|
+
try {
|
|
99
|
+
_(h.throw(I));
|
|
100
|
+
} catch (g) {
|
|
101
|
+
w(g);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function _(I) {
|
|
105
|
+
I.done ? v(I.value) : new d(function(g) {
|
|
106
|
+
g(I.value);
|
|
107
|
+
}).then(y, k);
|
|
108
|
+
}
|
|
109
|
+
_((h = h.apply(u, c || [])).next());
|
|
110
|
+
});
|
|
111
|
+
}, r = ae && ae.__generator || function(u, c) {
|
|
112
|
+
var d, h, v, w, y = { label: 0, sent: function() {
|
|
113
|
+
if (1 & v[0])
|
|
114
|
+
throw v[1];
|
|
115
|
+
return v[1];
|
|
116
|
+
}, trys: [], ops: [] };
|
|
117
|
+
return w = { next: k(0), throw: k(1), return: k(2) }, typeof Symbol == "function" && (w[Symbol.iterator] = function() {
|
|
118
|
+
return this;
|
|
119
|
+
}), w;
|
|
120
|
+
function k(_) {
|
|
121
|
+
return function(I) {
|
|
122
|
+
return function(g) {
|
|
123
|
+
if (d)
|
|
124
|
+
throw new TypeError("Generator is already executing.");
|
|
125
|
+
for (; y; )
|
|
126
|
+
try {
|
|
127
|
+
if (d = 1, h && (v = 2 & g[0] ? h.return : g[0] ? h.throw || ((v = h.return) && v.call(h), 0) : h.next) && !(v = v.call(h, g[1])).done)
|
|
128
|
+
return v;
|
|
129
|
+
switch (h = 0, v && (g = [2 & g[0], v.value]), g[0]) {
|
|
130
|
+
case 0:
|
|
131
|
+
case 1:
|
|
132
|
+
v = g;
|
|
133
|
+
break;
|
|
134
|
+
case 4:
|
|
135
|
+
return y.label++, { value: g[1], done: !1 };
|
|
136
|
+
case 5:
|
|
137
|
+
y.label++, h = g[1], g = [0];
|
|
138
|
+
continue;
|
|
139
|
+
case 7:
|
|
140
|
+
g = y.ops.pop(), y.trys.pop();
|
|
141
|
+
continue;
|
|
142
|
+
default:
|
|
143
|
+
if (v = y.trys, !((v = v.length > 0 && v[v.length - 1]) || g[0] !== 6 && g[0] !== 2)) {
|
|
144
|
+
y = 0;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (g[0] === 3 && (!v || g[1] > v[0] && g[1] < v[3])) {
|
|
148
|
+
y.label = g[1];
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
if (g[0] === 6 && y.label < v[1]) {
|
|
152
|
+
y.label = v[1], v = g;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
if (v && y.label < v[2]) {
|
|
156
|
+
y.label = v[2], y.ops.push(g);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
v[2] && y.ops.pop(), y.trys.pop();
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
g = c.call(u, y);
|
|
163
|
+
} catch (b) {
|
|
164
|
+
g = [6, b], h = 0;
|
|
165
|
+
} finally {
|
|
166
|
+
d = v = 0;
|
|
167
|
+
}
|
|
168
|
+
if (5 & g[0])
|
|
169
|
+
throw g[1];
|
|
170
|
+
return { value: g[0] ? g[1] : void 0, done: !0 };
|
|
171
|
+
}([_, I]);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}, i = ae;
|
|
175
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
176
|
+
var o = "browser-tabs-lock-key", a = { key: function(u) {
|
|
177
|
+
return n(i, void 0, void 0, function() {
|
|
178
|
+
return r(this, function(c) {
|
|
179
|
+
throw new Error("Unsupported");
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}, getItem: function(u) {
|
|
183
|
+
return n(i, void 0, void 0, function() {
|
|
184
|
+
return r(this, function(c) {
|
|
185
|
+
throw new Error("Unsupported");
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}, clear: function() {
|
|
189
|
+
return n(i, void 0, void 0, function() {
|
|
190
|
+
return r(this, function(u) {
|
|
191
|
+
return [2, window.localStorage.clear()];
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}, removeItem: function(u) {
|
|
195
|
+
return n(i, void 0, void 0, function() {
|
|
196
|
+
return r(this, function(c) {
|
|
197
|
+
throw new Error("Unsupported");
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}, setItem: function(u, c) {
|
|
201
|
+
return n(i, void 0, void 0, function() {
|
|
202
|
+
return r(this, function(d) {
|
|
203
|
+
throw new Error("Unsupported");
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}, keySync: function(u) {
|
|
207
|
+
return window.localStorage.key(u);
|
|
208
|
+
}, getItemSync: function(u) {
|
|
209
|
+
return window.localStorage.getItem(u);
|
|
210
|
+
}, clearSync: function() {
|
|
211
|
+
return window.localStorage.clear();
|
|
212
|
+
}, removeItemSync: function(u) {
|
|
213
|
+
return window.localStorage.removeItem(u);
|
|
214
|
+
}, setItemSync: function(u, c) {
|
|
215
|
+
return window.localStorage.setItem(u, c);
|
|
216
|
+
} };
|
|
217
|
+
function s(u) {
|
|
218
|
+
return new Promise(function(c) {
|
|
219
|
+
return setTimeout(c, u);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function f(u) {
|
|
223
|
+
for (var c = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", d = "", h = 0; h < u; h++)
|
|
224
|
+
d += c[Math.floor(Math.random() * c.length)];
|
|
225
|
+
return d;
|
|
226
|
+
}
|
|
227
|
+
var m = function() {
|
|
228
|
+
function u(c) {
|
|
229
|
+
this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + f(15), this.acquireLock = this.acquireLock.bind(this), this.releaseLock = this.releaseLock.bind(this), this.releaseLock__private__ = this.releaseLock__private__.bind(this), this.waitForSomethingToChange = this.waitForSomethingToChange.bind(this), this.refreshLockWhileAcquired = this.refreshLockWhileAcquired.bind(this), this.storageHandler = c, u.waiters === void 0 && (u.waiters = []);
|
|
230
|
+
}
|
|
231
|
+
return u.prototype.acquireLock = function(c, d) {
|
|
232
|
+
return d === void 0 && (d = 5e3), n(this, void 0, void 0, function() {
|
|
233
|
+
var h, v, w, y, k, _, I;
|
|
234
|
+
return r(this, function(g) {
|
|
235
|
+
switch (g.label) {
|
|
236
|
+
case 0:
|
|
237
|
+
h = Date.now() + f(4), v = Date.now() + d, w = o + "-" + c, y = this.storageHandler === void 0 ? a : this.storageHandler, g.label = 1;
|
|
238
|
+
case 1:
|
|
239
|
+
return Date.now() < v ? [4, s(30)] : [3, 8];
|
|
240
|
+
case 2:
|
|
241
|
+
return g.sent(), y.getItemSync(w) !== null ? [3, 5] : (k = this.id + "-" + c + "-" + h, [4, s(Math.floor(25 * Math.random()))]);
|
|
242
|
+
case 3:
|
|
243
|
+
return g.sent(), y.setItemSync(w, JSON.stringify({ id: this.id, iat: h, timeoutKey: k, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, s(30)];
|
|
244
|
+
case 4:
|
|
245
|
+
return g.sent(), (_ = y.getItemSync(w)) !== null && (I = JSON.parse(_)).id === this.id && I.iat === h ? (this.acquiredIatSet.add(h), this.refreshLockWhileAcquired(w, h), [2, !0]) : [3, 7];
|
|
246
|
+
case 5:
|
|
247
|
+
return u.lockCorrector(this.storageHandler === void 0 ? a : this.storageHandler), [4, this.waitForSomethingToChange(v)];
|
|
248
|
+
case 6:
|
|
249
|
+
g.sent(), g.label = 7;
|
|
250
|
+
case 7:
|
|
251
|
+
return h = Date.now() + f(4), [3, 1];
|
|
252
|
+
case 8:
|
|
253
|
+
return [2, !1];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}, u.prototype.refreshLockWhileAcquired = function(c, d) {
|
|
258
|
+
return n(this, void 0, void 0, function() {
|
|
259
|
+
var h = this;
|
|
260
|
+
return r(this, function(v) {
|
|
261
|
+
return setTimeout(function() {
|
|
262
|
+
return n(h, void 0, void 0, function() {
|
|
263
|
+
var w, y, k;
|
|
264
|
+
return r(this, function(_) {
|
|
265
|
+
switch (_.label) {
|
|
266
|
+
case 0:
|
|
267
|
+
return [4, oe.default().lock(d)];
|
|
268
|
+
case 1:
|
|
269
|
+
return _.sent(), this.acquiredIatSet.has(d) ? (w = this.storageHandler === void 0 ? a : this.storageHandler, (y = w.getItemSync(c)) === null ? (oe.default().unlock(d), [2]) : ((k = JSON.parse(y)).timeRefreshed = Date.now(), w.setItemSync(c, JSON.stringify(k)), oe.default().unlock(d), this.refreshLockWhileAcquired(c, d), [2])) : (oe.default().unlock(d), [2]);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}, 1e3), [2];
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}, u.prototype.waitForSomethingToChange = function(c) {
|
|
277
|
+
return n(this, void 0, void 0, function() {
|
|
278
|
+
return r(this, function(d) {
|
|
279
|
+
switch (d.label) {
|
|
280
|
+
case 0:
|
|
281
|
+
return [4, new Promise(function(h) {
|
|
282
|
+
var v = !1, w = Date.now(), y = !1;
|
|
283
|
+
function k() {
|
|
284
|
+
if (y || (window.removeEventListener("storage", k), u.removeFromWaiting(k), clearTimeout(_), y = !0), !v) {
|
|
285
|
+
v = !0;
|
|
286
|
+
var I = 50 - (Date.now() - w);
|
|
287
|
+
I > 0 ? setTimeout(h, I) : h(null);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
window.addEventListener("storage", k), u.addToWaiting(k);
|
|
291
|
+
var _ = setTimeout(k, Math.max(0, c - Date.now()));
|
|
292
|
+
})];
|
|
293
|
+
case 1:
|
|
294
|
+
return d.sent(), [2];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
}, u.addToWaiting = function(c) {
|
|
299
|
+
this.removeFromWaiting(c), u.waiters !== void 0 && u.waiters.push(c);
|
|
300
|
+
}, u.removeFromWaiting = function(c) {
|
|
301
|
+
u.waiters !== void 0 && (u.waiters = u.waiters.filter(function(d) {
|
|
302
|
+
return d !== c;
|
|
303
|
+
}));
|
|
304
|
+
}, u.notifyWaiters = function() {
|
|
305
|
+
u.waiters !== void 0 && u.waiters.slice().forEach(function(c) {
|
|
306
|
+
return c();
|
|
307
|
+
});
|
|
308
|
+
}, u.prototype.releaseLock = function(c) {
|
|
309
|
+
return n(this, void 0, void 0, function() {
|
|
310
|
+
return r(this, function(d) {
|
|
311
|
+
switch (d.label) {
|
|
312
|
+
case 0:
|
|
313
|
+
return [4, this.releaseLock__private__(c)];
|
|
314
|
+
case 1:
|
|
315
|
+
return [2, d.sent()];
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}, u.prototype.releaseLock__private__ = function(c) {
|
|
320
|
+
return n(this, void 0, void 0, function() {
|
|
321
|
+
var d, h, v, w;
|
|
322
|
+
return r(this, function(y) {
|
|
323
|
+
switch (y.label) {
|
|
324
|
+
case 0:
|
|
325
|
+
return d = this.storageHandler === void 0 ? a : this.storageHandler, h = o + "-" + c, (v = d.getItemSync(h)) === null ? [2] : (w = JSON.parse(v)).id !== this.id ? [3, 2] : [4, oe.default().lock(w.iat)];
|
|
326
|
+
case 1:
|
|
327
|
+
y.sent(), this.acquiredIatSet.delete(w.iat), d.removeItemSync(h), oe.default().unlock(w.iat), u.notifyWaiters(), y.label = 2;
|
|
328
|
+
case 2:
|
|
329
|
+
return [2];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
}, u.lockCorrector = function(c) {
|
|
334
|
+
for (var d = Date.now() - 5e3, h = c, v = [], w = 0; ; ) {
|
|
335
|
+
var y = h.keySync(w);
|
|
336
|
+
if (y === null)
|
|
337
|
+
break;
|
|
338
|
+
v.push(y), w++;
|
|
339
|
+
}
|
|
340
|
+
for (var k = !1, _ = 0; _ < v.length; _++) {
|
|
341
|
+
var I = v[_];
|
|
342
|
+
if (I.includes(o)) {
|
|
343
|
+
var g = h.getItemSync(I);
|
|
344
|
+
if (g !== null) {
|
|
345
|
+
var b = JSON.parse(g);
|
|
346
|
+
(b.timeRefreshed === void 0 && b.timeAcquired < d || b.timeRefreshed !== void 0 && b.timeRefreshed < d) && (h.removeItemSync(I), k = !0);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
k && u.notifyWaiters();
|
|
351
|
+
}, u.waiters = void 0, u;
|
|
352
|
+
}();
|
|
353
|
+
e.default = m;
|
|
354
|
+
}));
|
|
355
|
+
const or = { timeoutInSeconds: 60 }, hn = { name: "auth0-spa-js", version: "2.1.3" }, fn = () => Date.now();
|
|
356
|
+
let J = class ft extends Error {
|
|
357
|
+
constructor(e, n) {
|
|
358
|
+
super(n), this.error = e, this.error_description = n, Object.setPrototypeOf(this, ft.prototype);
|
|
359
|
+
}
|
|
360
|
+
static fromPayload({ error: e, error_description: n }) {
|
|
361
|
+
return new ft(e, n);
|
|
362
|
+
}
|
|
363
|
+
}, ar = class pn extends J {
|
|
364
|
+
constructor(e, n, r, i = null) {
|
|
365
|
+
super(e, n), this.state = r, this.appState = i, Object.setPrototypeOf(this, pn.prototype);
|
|
366
|
+
}
|
|
367
|
+
}, pt = class mn extends J {
|
|
368
|
+
constructor() {
|
|
369
|
+
super("timeout", "Timeout"), Object.setPrototypeOf(this, mn.prototype);
|
|
370
|
+
}
|
|
371
|
+
}, sr = class gn extends pt {
|
|
372
|
+
constructor(e) {
|
|
373
|
+
super(), this.popup = e, Object.setPrototypeOf(this, gn.prototype);
|
|
374
|
+
}
|
|
375
|
+
}, cr = class vn extends J {
|
|
376
|
+
constructor(e) {
|
|
377
|
+
super("cancelled", "Popup closed"), this.popup = e, Object.setPrototypeOf(this, vn.prototype);
|
|
378
|
+
}
|
|
379
|
+
}, ur = class yn extends J {
|
|
380
|
+
constructor(e, n, r) {
|
|
381
|
+
super(e, n), this.mfa_token = r, Object.setPrototypeOf(this, yn.prototype);
|
|
382
|
+
}
|
|
383
|
+
}, wn = class bn extends J {
|
|
384
|
+
constructor(e, n) {
|
|
385
|
+
super("missing_refresh_token", `Missing Refresh Token (audience: '${jt(e, ["default"])}', scope: '${jt(n)}')`), this.audience = e, this.scope = n, Object.setPrototypeOf(this, bn.prototype);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
function jt(t, e = []) {
|
|
389
|
+
return t && !e.includes(t) ? t : "";
|
|
390
|
+
}
|
|
391
|
+
const Ve = () => window.crypto, it = () => {
|
|
392
|
+
const t = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
|
|
393
|
+
let e = "";
|
|
394
|
+
return Array.from(Ve().getRandomValues(new Uint8Array(43))).forEach((n) => e += t[n % t.length]), e;
|
|
395
|
+
}, Tt = (t) => btoa(t), mt = (t) => {
|
|
396
|
+
var { clientId: e } = t, n = q(t, ["clientId"]);
|
|
397
|
+
return new URLSearchParams(((r) => Object.keys(r).filter((i) => r[i] !== void 0).reduce((i, o) => Object.assign(Object.assign({}, i), { [o]: r[o] }), {}))(Object.assign({ client_id: e }, n))).toString();
|
|
398
|
+
}, Ct = (t) => ((e) => decodeURIComponent(atob(e).split("").map((n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g, "/").replace(/-/g, "+")), lr = async (t, e) => {
|
|
399
|
+
const n = await fetch(t, e);
|
|
400
|
+
return { ok: n.ok, json: await n.json() };
|
|
401
|
+
}, dr = async (t, e, n) => {
|
|
402
|
+
const r = new AbortController();
|
|
403
|
+
let i;
|
|
404
|
+
return e.signal = r.signal, Promise.race([lr(t, e), new Promise((o, a) => {
|
|
405
|
+
i = setTimeout(() => {
|
|
406
|
+
r.abort(), a(new Error("Timeout when executing 'fetch'"));
|
|
407
|
+
}, n);
|
|
408
|
+
})]).finally(() => {
|
|
409
|
+
clearTimeout(i);
|
|
410
|
+
});
|
|
411
|
+
}, hr = async (t, e, n, r, i, o, a) => {
|
|
412
|
+
return s = { auth: { audience: e, scope: n }, timeout: i, fetchUrl: t, fetchOptions: r, useFormData: a }, f = o, new Promise(function(m, u) {
|
|
413
|
+
const c = new MessageChannel();
|
|
414
|
+
c.port1.onmessage = function(d) {
|
|
415
|
+
d.data.error ? u(new Error(d.data.error)) : m(d.data), c.port1.close();
|
|
416
|
+
}, f.postMessage(s, [c.port2]);
|
|
417
|
+
});
|
|
418
|
+
var s, f;
|
|
419
|
+
}, fr = async (t, e, n, r, i, o, a = 1e4) => i ? hr(t, e, n, r, a, i, o) : dr(t, r, a);
|
|
420
|
+
async function pr(t, e) {
|
|
421
|
+
var { baseUrl: n, timeout: r, audience: i, scope: o, auth0Client: a, useFormData: s } = t, f = q(t, ["baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData"]);
|
|
422
|
+
const m = s ? mt(f) : JSON.stringify(f);
|
|
423
|
+
return await async function(u, c, d, h, v, w, y) {
|
|
424
|
+
let k, _ = null;
|
|
425
|
+
for (let x = 0; x < 3; x++)
|
|
426
|
+
try {
|
|
427
|
+
k = await fr(u, d, h, v, w, y, c), _ = null;
|
|
428
|
+
break;
|
|
429
|
+
} catch (A) {
|
|
430
|
+
_ = A;
|
|
431
|
+
}
|
|
432
|
+
if (_)
|
|
433
|
+
throw _;
|
|
434
|
+
const I = k.json, { error: g, error_description: b } = I, D = q(I, ["error", "error_description"]), { ok: C } = k;
|
|
435
|
+
if (!C) {
|
|
436
|
+
const x = b || `HTTP error. Unable to fetch ${u}`;
|
|
437
|
+
throw g === "mfa_required" ? new ur(g, x, D.mfa_token) : g === "missing_refresh_token" ? new wn(d, h) : new J(g || "request_error", x);
|
|
438
|
+
}
|
|
439
|
+
return D;
|
|
440
|
+
}(`${n}/oauth/token`, r, i || "default", o, { method: "POST", body: m, headers: { "Content-Type": s ? "application/x-www-form-urlencoded" : "application/json", "Auth0-Client": btoa(JSON.stringify(a || hn)) } }, e, s);
|
|
441
|
+
}
|
|
442
|
+
const Ae = (...t) => {
|
|
443
|
+
return (e = t.filter(Boolean).join(" ").trim().split(/\s+/), Array.from(new Set(e))).join(" ");
|
|
444
|
+
var e;
|
|
445
|
+
};
|
|
446
|
+
let ce = class gt {
|
|
447
|
+
constructor(e, n = "@@auth0spajs@@", r) {
|
|
448
|
+
this.prefix = n, this.suffix = r, this.clientId = e.clientId, this.scope = e.scope, this.audience = e.audience;
|
|
449
|
+
}
|
|
450
|
+
toKey() {
|
|
451
|
+
return [this.prefix, this.clientId, this.audience, this.scope, this.suffix].filter(Boolean).join("::");
|
|
452
|
+
}
|
|
453
|
+
static fromKey(e) {
|
|
454
|
+
const [n, r, i, o] = e.split("::");
|
|
455
|
+
return new gt({ clientId: r, scope: o, audience: i }, n);
|
|
456
|
+
}
|
|
457
|
+
static fromCacheEntry(e) {
|
|
458
|
+
const { scope: n, audience: r, client_id: i } = e;
|
|
459
|
+
return new gt({ scope: n, audience: r, clientId: i });
|
|
460
|
+
}
|
|
461
|
+
}, mr = class {
|
|
462
|
+
set(e, n) {
|
|
463
|
+
localStorage.setItem(e, JSON.stringify(n));
|
|
464
|
+
}
|
|
465
|
+
get(e) {
|
|
466
|
+
const n = window.localStorage.getItem(e);
|
|
467
|
+
if (n)
|
|
468
|
+
try {
|
|
469
|
+
return JSON.parse(n);
|
|
470
|
+
} catch {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
remove(e) {
|
|
475
|
+
localStorage.removeItem(e);
|
|
476
|
+
}
|
|
477
|
+
allKeys() {
|
|
478
|
+
return Object.keys(window.localStorage).filter((e) => e.startsWith("@@auth0spajs@@"));
|
|
479
|
+
}
|
|
480
|
+
}, kn = class {
|
|
481
|
+
constructor() {
|
|
482
|
+
this.enclosedCache = /* @__PURE__ */ function() {
|
|
483
|
+
let e = {};
|
|
484
|
+
return { set(n, r) {
|
|
485
|
+
e[n] = r;
|
|
486
|
+
}, get(n) {
|
|
487
|
+
const r = e[n];
|
|
488
|
+
if (r)
|
|
489
|
+
return r;
|
|
490
|
+
}, remove(n) {
|
|
491
|
+
delete e[n];
|
|
492
|
+
}, allKeys: () => Object.keys(e) };
|
|
493
|
+
}();
|
|
494
|
+
}
|
|
495
|
+
}, gr = class {
|
|
496
|
+
constructor(e, n, r) {
|
|
497
|
+
this.cache = e, this.keyManifest = n, this.nowProvider = r || fn;
|
|
498
|
+
}
|
|
499
|
+
async setIdToken(e, n, r) {
|
|
500
|
+
var i;
|
|
501
|
+
const o = this.getIdTokenCacheKey(e);
|
|
502
|
+
await this.cache.set(o, { id_token: n, decodedToken: r }), await ((i = this.keyManifest) === null || i === void 0 ? void 0 : i.add(o));
|
|
503
|
+
}
|
|
504
|
+
async getIdToken(e) {
|
|
505
|
+
const n = await this.cache.get(this.getIdTokenCacheKey(e.clientId));
|
|
506
|
+
if (!n && e.scope && e.audience) {
|
|
507
|
+
const r = await this.get(e);
|
|
508
|
+
return !r || !r.id_token || !r.decodedToken ? void 0 : { id_token: r.id_token, decodedToken: r.decodedToken };
|
|
509
|
+
}
|
|
510
|
+
if (n)
|
|
511
|
+
return { id_token: n.id_token, decodedToken: n.decodedToken };
|
|
512
|
+
}
|
|
513
|
+
async get(e, n = 0) {
|
|
514
|
+
var r;
|
|
515
|
+
let i = await this.cache.get(e.toKey());
|
|
516
|
+
if (!i) {
|
|
517
|
+
const s = await this.getCacheKeys();
|
|
518
|
+
if (!s)
|
|
519
|
+
return;
|
|
520
|
+
const f = this.matchExistingCacheKey(e, s);
|
|
521
|
+
f && (i = await this.cache.get(f));
|
|
522
|
+
}
|
|
523
|
+
if (!i)
|
|
524
|
+
return;
|
|
525
|
+
const o = await this.nowProvider(), a = Math.floor(o / 1e3);
|
|
526
|
+
return i.expiresAt - n < a ? i.body.refresh_token ? (i.body = { refresh_token: i.body.refresh_token }, await this.cache.set(e.toKey(), i), i.body) : (await this.cache.remove(e.toKey()), void await ((r = this.keyManifest) === null || r === void 0 ? void 0 : r.remove(e.toKey()))) : i.body;
|
|
527
|
+
}
|
|
528
|
+
async set(e) {
|
|
529
|
+
var n;
|
|
530
|
+
const r = new ce({ clientId: e.client_id, scope: e.scope, audience: e.audience }), i = await this.wrapCacheEntry(e);
|
|
531
|
+
await this.cache.set(r.toKey(), i), await ((n = this.keyManifest) === null || n === void 0 ? void 0 : n.add(r.toKey()));
|
|
532
|
+
}
|
|
533
|
+
async clear(e) {
|
|
534
|
+
var n;
|
|
535
|
+
const r = await this.getCacheKeys();
|
|
536
|
+
r && (await r.filter((i) => !e || i.includes(e)).reduce(async (i, o) => {
|
|
537
|
+
await i, await this.cache.remove(o);
|
|
538
|
+
}, Promise.resolve()), await ((n = this.keyManifest) === null || n === void 0 ? void 0 : n.clear()));
|
|
539
|
+
}
|
|
540
|
+
async wrapCacheEntry(e) {
|
|
541
|
+
const n = await this.nowProvider();
|
|
542
|
+
return { body: e, expiresAt: Math.floor(n / 1e3) + e.expires_in };
|
|
543
|
+
}
|
|
544
|
+
async getCacheKeys() {
|
|
545
|
+
var e;
|
|
546
|
+
return this.keyManifest ? (e = await this.keyManifest.get()) === null || e === void 0 ? void 0 : e.keys : this.cache.allKeys ? this.cache.allKeys() : void 0;
|
|
547
|
+
}
|
|
548
|
+
getIdTokenCacheKey(e) {
|
|
549
|
+
return new ce({ clientId: e }, "@@auth0spajs@@", "@@user@@").toKey();
|
|
550
|
+
}
|
|
551
|
+
matchExistingCacheKey(e, n) {
|
|
552
|
+
return n.filter((r) => {
|
|
553
|
+
var i;
|
|
554
|
+
const o = ce.fromKey(r), a = new Set(o.scope && o.scope.split(" ")), s = ((i = e.scope) === null || i === void 0 ? void 0 : i.split(" ")) || [], f = o.scope && s.reduce((m, u) => m && a.has(u), !0);
|
|
555
|
+
return o.prefix === "@@auth0spajs@@" && o.clientId === e.clientId && o.audience === e.audience && f;
|
|
556
|
+
})[0];
|
|
557
|
+
}
|
|
558
|
+
}, vr = class {
|
|
559
|
+
constructor(e, n, r) {
|
|
560
|
+
this.storage = e, this.clientId = n, this.cookieDomain = r, this.storageKey = `a0.spajs.txs.${this.clientId}`;
|
|
561
|
+
}
|
|
562
|
+
create(e) {
|
|
563
|
+
this.storage.save(this.storageKey, e, { daysUntilExpire: 1, cookieDomain: this.cookieDomain });
|
|
564
|
+
}
|
|
565
|
+
get() {
|
|
566
|
+
return this.storage.get(this.storageKey);
|
|
567
|
+
}
|
|
568
|
+
remove() {
|
|
569
|
+
this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain });
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const Ee = (t) => typeof t == "number", yr = ["iss", "aud", "exp", "nbf", "iat", "jti", "azp", "nonce", "auth_time", "at_hash", "c_hash", "acr", "amr", "sub_jwk", "cnf", "sip_from_tag", "sip_date", "sip_callid", "sip_cseq_num", "sip_via_branch", "orig", "dest", "mky", "events", "toe", "txn", "rph", "sid", "vot", "vtm"], wr = (t) => {
|
|
573
|
+
if (!t.id_token)
|
|
574
|
+
throw new Error("ID token is required but missing");
|
|
575
|
+
const e = ((o) => {
|
|
576
|
+
const a = o.split("."), [s, f, m] = a;
|
|
577
|
+
if (a.length !== 3 || !s || !f || !m)
|
|
578
|
+
throw new Error("ID token could not be decoded");
|
|
579
|
+
const u = JSON.parse(Ct(f)), c = { __raw: o }, d = {};
|
|
580
|
+
return Object.keys(u).forEach((h) => {
|
|
581
|
+
c[h] = u[h], yr.includes(h) || (d[h] = u[h]);
|
|
582
|
+
}), { encoded: { header: s, payload: f, signature: m }, header: JSON.parse(Ct(s)), claims: c, user: d };
|
|
583
|
+
})(t.id_token);
|
|
584
|
+
if (!e.claims.iss)
|
|
585
|
+
throw new Error("Issuer (iss) claim must be a string present in the ID token");
|
|
586
|
+
if (e.claims.iss !== t.iss)
|
|
587
|
+
throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);
|
|
588
|
+
if (!e.user.sub)
|
|
589
|
+
throw new Error("Subject (sub) claim must be a string present in the ID token");
|
|
590
|
+
if (e.header.alg !== "RS256")
|
|
591
|
+
throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);
|
|
592
|
+
if (!e.claims.aud || typeof e.claims.aud != "string" && !Array.isArray(e.claims.aud))
|
|
593
|
+
throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");
|
|
594
|
+
if (Array.isArray(e.claims.aud)) {
|
|
595
|
+
if (!e.claims.aud.includes(t.aud))
|
|
596
|
+
throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);
|
|
597
|
+
if (e.claims.aud.length > 1) {
|
|
598
|
+
if (!e.claims.azp)
|
|
599
|
+
throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");
|
|
600
|
+
if (e.claims.azp !== t.aud)
|
|
601
|
+
throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`);
|
|
602
|
+
}
|
|
603
|
+
} else if (e.claims.aud !== t.aud)
|
|
604
|
+
throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);
|
|
605
|
+
if (t.nonce) {
|
|
606
|
+
if (!e.claims.nonce)
|
|
607
|
+
throw new Error("Nonce (nonce) claim must be a string present in the ID token");
|
|
608
|
+
if (e.claims.nonce !== t.nonce)
|
|
609
|
+
throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`);
|
|
610
|
+
}
|
|
611
|
+
if (t.max_age && !Ee(e.claims.auth_time))
|
|
612
|
+
throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");
|
|
613
|
+
if (e.claims.exp == null || !Ee(e.claims.exp))
|
|
614
|
+
throw new Error("Expiration Time (exp) claim must be a number present in the ID token");
|
|
615
|
+
if (!Ee(e.claims.iat))
|
|
616
|
+
throw new Error("Issued At (iat) claim must be a number present in the ID token");
|
|
617
|
+
const n = t.leeway || 60, r = new Date(t.now || Date.now()), i = /* @__PURE__ */ new Date(0);
|
|
618
|
+
if (i.setUTCSeconds(e.claims.exp + n), r > i)
|
|
619
|
+
throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);
|
|
620
|
+
if (e.claims.nbf != null && Ee(e.claims.nbf)) {
|
|
621
|
+
const o = /* @__PURE__ */ new Date(0);
|
|
622
|
+
if (o.setUTCSeconds(e.claims.nbf - n), r < o)
|
|
623
|
+
throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${o}`);
|
|
624
|
+
}
|
|
625
|
+
if (e.claims.auth_time != null && Ee(e.claims.auth_time)) {
|
|
626
|
+
const o = /* @__PURE__ */ new Date(0);
|
|
627
|
+
if (o.setUTCSeconds(parseInt(e.claims.auth_time) + t.max_age + n), r > o)
|
|
628
|
+
throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${o}`);
|
|
629
|
+
}
|
|
630
|
+
if (t.organization) {
|
|
631
|
+
const o = t.organization.trim();
|
|
632
|
+
if (o.startsWith("org_")) {
|
|
633
|
+
const a = o;
|
|
634
|
+
if (!e.claims.org_id)
|
|
635
|
+
throw new Error("Organization ID (org_id) claim must be a string present in the ID token");
|
|
636
|
+
if (a !== e.claims.org_id)
|
|
637
|
+
throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`);
|
|
638
|
+
} else {
|
|
639
|
+
const a = o.toLowerCase();
|
|
640
|
+
if (!e.claims.org_name)
|
|
641
|
+
throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
|
|
642
|
+
if (a !== e.claims.org_name)
|
|
643
|
+
throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return e;
|
|
647
|
+
};
|
|
648
|
+
var ue = kt(function(t, e) {
|
|
649
|
+
var n = ae && ae.__assign || function() {
|
|
650
|
+
return n = Object.assign || function(f) {
|
|
651
|
+
for (var m, u = 1, c = arguments.length; u < c; u++)
|
|
652
|
+
for (var d in m = arguments[u])
|
|
653
|
+
Object.prototype.hasOwnProperty.call(m, d) && (f[d] = m[d]);
|
|
654
|
+
return f;
|
|
655
|
+
}, n.apply(this, arguments);
|
|
656
|
+
};
|
|
657
|
+
function r(f, m) {
|
|
658
|
+
if (!m)
|
|
659
|
+
return "";
|
|
660
|
+
var u = "; " + f;
|
|
661
|
+
return m === !0 ? u : u + "=" + m;
|
|
662
|
+
}
|
|
663
|
+
function i(f, m, u) {
|
|
664
|
+
return encodeURIComponent(f).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/\(/g, "%28").replace(/\)/g, "%29") + "=" + encodeURIComponent(m).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) + function(c) {
|
|
665
|
+
if (typeof c.expires == "number") {
|
|
666
|
+
var d = /* @__PURE__ */ new Date();
|
|
667
|
+
d.setMilliseconds(d.getMilliseconds() + 864e5 * c.expires), c.expires = d;
|
|
668
|
+
}
|
|
669
|
+
return r("Expires", c.expires ? c.expires.toUTCString() : "") + r("Domain", c.domain) + r("Path", c.path) + r("Secure", c.secure) + r("SameSite", c.sameSite);
|
|
670
|
+
}(u);
|
|
671
|
+
}
|
|
672
|
+
function o(f) {
|
|
673
|
+
for (var m = {}, u = f ? f.split("; ") : [], c = /(%[\dA-F]{2})+/gi, d = 0; d < u.length; d++) {
|
|
674
|
+
var h = u[d].split("="), v = h.slice(1).join("=");
|
|
675
|
+
v.charAt(0) === '"' && (v = v.slice(1, -1));
|
|
676
|
+
try {
|
|
677
|
+
m[h[0].replace(c, decodeURIComponent)] = v.replace(c, decodeURIComponent);
|
|
678
|
+
} catch {
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return m;
|
|
682
|
+
}
|
|
683
|
+
function a() {
|
|
684
|
+
return o(document.cookie);
|
|
685
|
+
}
|
|
686
|
+
function s(f, m, u) {
|
|
687
|
+
document.cookie = i(f, m, n({ path: "/" }, u));
|
|
688
|
+
}
|
|
689
|
+
e.__esModule = !0, e.encode = i, e.parse = o, e.getAll = a, e.get = function(f) {
|
|
690
|
+
return a()[f];
|
|
691
|
+
}, e.set = s, e.remove = function(f, m) {
|
|
692
|
+
s(f, "", n(n({}, m), { expires: -1 }));
|
|
693
|
+
};
|
|
694
|
+
});
|
|
695
|
+
bt(ue), ue.encode, ue.parse, ue.getAll;
|
|
696
|
+
var br = ue.get, In = ue.set, Sn = ue.remove;
|
|
697
|
+
const pe = { get(t) {
|
|
698
|
+
const e = br(t);
|
|
699
|
+
if (e !== void 0)
|
|
700
|
+
return JSON.parse(e);
|
|
701
|
+
}, save(t, e, n) {
|
|
702
|
+
let r = {};
|
|
703
|
+
window.location.protocol === "https:" && (r = { secure: !0, sameSite: "none" }), n != null && n.daysUntilExpire && (r.expires = n.daysUntilExpire), n != null && n.cookieDomain && (r.domain = n.cookieDomain), In(t, JSON.stringify(e), r);
|
|
704
|
+
}, remove(t, e) {
|
|
705
|
+
let n = {};
|
|
706
|
+
e != null && e.cookieDomain && (n.domain = e.cookieDomain), Sn(t, n);
|
|
707
|
+
} }, kr = { get(t) {
|
|
708
|
+
return pe.get(t) || pe.get(`_legacy_${t}`);
|
|
709
|
+
}, save(t, e, n) {
|
|
710
|
+
let r = {};
|
|
711
|
+
window.location.protocol === "https:" && (r = { secure: !0 }), n != null && n.daysUntilExpire && (r.expires = n.daysUntilExpire), n != null && n.cookieDomain && (r.domain = n.cookieDomain), In(`_legacy_${t}`, JSON.stringify(e), r), pe.save(t, e, n);
|
|
712
|
+
}, remove(t, e) {
|
|
713
|
+
let n = {};
|
|
714
|
+
e != null && e.cookieDomain && (n.domain = e.cookieDomain), Sn(t, n), pe.remove(t, e), pe.remove(`_legacy_${t}`, e);
|
|
715
|
+
} }, Ir = { get(t) {
|
|
716
|
+
if (typeof sessionStorage > "u")
|
|
717
|
+
return;
|
|
718
|
+
const e = sessionStorage.getItem(t);
|
|
719
|
+
return e != null ? JSON.parse(e) : void 0;
|
|
720
|
+
}, save(t, e) {
|
|
721
|
+
sessionStorage.setItem(t, JSON.stringify(e));
|
|
722
|
+
}, remove(t) {
|
|
723
|
+
sessionStorage.removeItem(t);
|
|
724
|
+
} };
|
|
725
|
+
function Sr(t, e, n) {
|
|
726
|
+
var r = e === void 0 ? null : e, i = function(f, m) {
|
|
727
|
+
var u = atob(f);
|
|
728
|
+
if (m) {
|
|
729
|
+
for (var c = new Uint8Array(u.length), d = 0, h = u.length; d < h; ++d)
|
|
730
|
+
c[d] = u.charCodeAt(d);
|
|
731
|
+
return String.fromCharCode.apply(null, new Uint16Array(c.buffer));
|
|
732
|
+
}
|
|
733
|
+
return u;
|
|
734
|
+
}(t, n !== void 0 && n), o = i.indexOf(`
|
|
735
|
+
`, 10) + 1, a = i.substring(o) + (r ? "//# sourceMappingURL=" + r : ""), s = new Blob([a], { type: "application/javascript" });
|
|
736
|
+
return URL.createObjectURL(s);
|
|
737
|
+
}
|
|
738
|
+
var $t, zt, Nt, ot, _r = ($t = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=", zt = null, Nt = !1, function(t) {
|
|
739
|
+
return ot = ot || Sr($t, zt, Nt), new Worker(ot, t);
|
|
740
|
+
});
|
|
741
|
+
const at = {};
|
|
742
|
+
let Or = class {
|
|
743
|
+
constructor(e, n) {
|
|
744
|
+
this.cache = e, this.clientId = n, this.manifestKey = this.createManifestKeyFrom(this.clientId);
|
|
745
|
+
}
|
|
746
|
+
async add(e) {
|
|
747
|
+
var n;
|
|
748
|
+
const r = new Set(((n = await this.cache.get(this.manifestKey)) === null || n === void 0 ? void 0 : n.keys) || []);
|
|
749
|
+
r.add(e), await this.cache.set(this.manifestKey, { keys: [...r] });
|
|
750
|
+
}
|
|
751
|
+
async remove(e) {
|
|
752
|
+
const n = await this.cache.get(this.manifestKey);
|
|
753
|
+
if (n) {
|
|
754
|
+
const r = new Set(n.keys);
|
|
755
|
+
return r.delete(e), r.size > 0 ? await this.cache.set(this.manifestKey, { keys: [...r] }) : await this.cache.remove(this.manifestKey);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
get() {
|
|
759
|
+
return this.cache.get(this.manifestKey);
|
|
760
|
+
}
|
|
761
|
+
clear() {
|
|
762
|
+
return this.cache.remove(this.manifestKey);
|
|
763
|
+
}
|
|
764
|
+
createManifestKeyFrom(e) {
|
|
765
|
+
return `@@auth0spajs@@::${e}`;
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
const Pr = { memory: () => new kn().enclosedCache, localstorage: () => new mr() }, Dt = (t) => Pr[t], Lt = (t) => {
|
|
769
|
+
const { openUrl: e, onRedirect: n } = t, r = q(t, ["openUrl", "onRedirect"]);
|
|
770
|
+
return Object.assign(Object.assign({}, r), { openUrl: e === !1 || e ? e : n });
|
|
771
|
+
}, st = new ir();
|
|
772
|
+
let Er = class {
|
|
773
|
+
constructor(e) {
|
|
774
|
+
let n, r;
|
|
775
|
+
if (this.userCache = new kn().enclosedCache, this.defaultOptions = { authorizationParams: { scope: "openid profile email" }, useRefreshTokensFallback: !1, useFormData: !0 }, this._releaseLockOnPageHide = async () => {
|
|
776
|
+
await st.releaseLock("auth0.lock.getTokenSilently"), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
|
|
777
|
+
}, this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), e), { authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), e.authorizationParams) }), typeof window < "u" && (() => {
|
|
778
|
+
if (!Ve())
|
|
779
|
+
throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");
|
|
780
|
+
if (Ve().subtle === void 0)
|
|
781
|
+
throw new Error(`
|
|
782
|
+
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
783
|
+
`);
|
|
784
|
+
})(), e.cache && e.cacheLocation && console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."), e.cache)
|
|
785
|
+
r = e.cache;
|
|
786
|
+
else {
|
|
787
|
+
if (n = e.cacheLocation || "memory", !Dt(n))
|
|
788
|
+
throw new Error(`Invalid cache location "${n}"`);
|
|
789
|
+
r = Dt(n)();
|
|
790
|
+
}
|
|
791
|
+
this.httpTimeoutMs = e.httpTimeoutInSeconds ? 1e3 * e.httpTimeoutInSeconds : 1e4, this.cookieStorage = e.legacySameSiteCookie === !1 ? pe : kr, this.orgHintCookieName = `auth0.${this.options.clientId}.organization_hint`, this.isAuthenticatedCookieName = ((a) => `auth0.${a}.is.authenticated`)(this.options.clientId), this.sessionCheckExpiryDays = e.sessionCheckExpiryDays || 1;
|
|
792
|
+
const i = e.useCookiesForTransactions ? this.cookieStorage : Ir;
|
|
793
|
+
var o;
|
|
794
|
+
this.scope = Ae("openid", this.options.authorizationParams.scope, this.options.useRefreshTokens ? "offline_access" : ""), this.transactionManager = new vr(i, this.options.clientId, this.options.cookieDomain), this.nowProvider = this.options.nowProvider || fn, this.cacheManager = new gr(r, r.allKeys ? void 0 : new Or(r, this.options.clientId), this.nowProvider), this.domainUrl = (o = this.options.domain, /^https?:\/\//.test(o) ? o : `https://${o}`), this.tokenIssuer = ((a, s) => a ? a.startsWith("https://") ? a : `https://${a}/` : `${s}/`)(this.options.issuer, this.domainUrl), typeof window < "u" && window.Worker && this.options.useRefreshTokens && n === "memory" && (this.options.workerUrl ? this.worker = new Worker(this.options.workerUrl) : this.worker = new _r());
|
|
795
|
+
}
|
|
796
|
+
_url(e) {
|
|
797
|
+
const n = encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client || hn)));
|
|
798
|
+
return `${this.domainUrl}${e}&auth0Client=${n}`;
|
|
799
|
+
}
|
|
800
|
+
_authorizeUrl(e) {
|
|
801
|
+
return this._url(`/authorize?${mt(e)}`);
|
|
802
|
+
}
|
|
803
|
+
async _verifyIdToken(e, n, r) {
|
|
804
|
+
const i = await this.nowProvider();
|
|
805
|
+
return wr({ iss: this.tokenIssuer, aud: this.options.clientId, id_token: e, nonce: n, organization: r, leeway: this.options.leeway, max_age: (o = this.options.authorizationParams.max_age, typeof o != "string" ? o : parseInt(o, 10) || void 0), now: i });
|
|
806
|
+
var o;
|
|
807
|
+
}
|
|
808
|
+
_processOrgHint(e) {
|
|
809
|
+
e ? this.cookieStorage.save(this.orgHintCookieName, e, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }) : this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain });
|
|
810
|
+
}
|
|
811
|
+
async _prepareAuthorizeUrl(e, n, r) {
|
|
812
|
+
const i = Tt(it()), o = Tt(it()), a = it(), s = ((u) => {
|
|
813
|
+
const c = new Uint8Array(u);
|
|
814
|
+
return ((d) => {
|
|
815
|
+
const h = { "+": "-", "/": "_", "=": "" };
|
|
816
|
+
return d.replace(/[+/=]/g, (v) => h[v]);
|
|
817
|
+
})(window.btoa(String.fromCharCode(...Array.from(c))));
|
|
818
|
+
})(await (async (u) => await Ve().subtle.digest({ name: "SHA-256" }, new TextEncoder().encode(u)))(a)), f = ((u, c, d, h, v, w, y, k) => Object.assign(Object.assign(Object.assign({ client_id: u.clientId }, u.authorizationParams), d), { scope: Ae(c, d.scope), response_type: "code", response_mode: k || "query", state: h, nonce: v, redirect_uri: y || u.authorizationParams.redirect_uri, code_challenge: w, code_challenge_method: "S256" }))(this.options, this.scope, e, i, o, s, e.redirect_uri || this.options.authorizationParams.redirect_uri || r, n == null ? void 0 : n.response_mode), m = this._authorizeUrl(f);
|
|
819
|
+
return { nonce: o, code_verifier: a, scope: f.scope, audience: f.audience || "default", redirect_uri: f.redirect_uri, state: i, url: m };
|
|
820
|
+
}
|
|
821
|
+
async loginWithPopup(e, n) {
|
|
822
|
+
var r;
|
|
823
|
+
if (e = e || {}, !(n = n || {}).popup && (n.popup = ((s) => {
|
|
824
|
+
const f = window.screenX + (window.innerWidth - 400) / 2, m = window.screenY + (window.innerHeight - 600) / 2;
|
|
825
|
+
return window.open(s, "auth0:authorize:popup", `left=${f},top=${m},width=400,height=600,resizable,scrollbars=yes,status=1`);
|
|
826
|
+
})(""), !n.popup))
|
|
827
|
+
throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");
|
|
828
|
+
const i = await this._prepareAuthorizeUrl(e.authorizationParams || {}, { response_mode: "web_message" }, window.location.origin);
|
|
829
|
+
n.popup.location.href = i.url;
|
|
830
|
+
const o = await ((s) => new Promise((f, m) => {
|
|
831
|
+
let u;
|
|
832
|
+
const c = setInterval(() => {
|
|
833
|
+
s.popup && s.popup.closed && (clearInterval(c), clearTimeout(d), window.removeEventListener("message", u, !1), m(new cr(s.popup)));
|
|
834
|
+
}, 1e3), d = setTimeout(() => {
|
|
835
|
+
clearInterval(c), m(new sr(s.popup)), window.removeEventListener("message", u, !1);
|
|
836
|
+
}, 1e3 * (s.timeoutInSeconds || 60));
|
|
837
|
+
u = function(h) {
|
|
838
|
+
if (h.data && h.data.type === "authorization_response") {
|
|
839
|
+
if (clearTimeout(d), clearInterval(c), window.removeEventListener("message", u, !1), s.popup.close(), h.data.response.error)
|
|
840
|
+
return m(J.fromPayload(h.data.response));
|
|
841
|
+
f(h.data.response);
|
|
842
|
+
}
|
|
843
|
+
}, window.addEventListener("message", u);
|
|
844
|
+
}))(Object.assign(Object.assign({}, n), { timeoutInSeconds: n.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || 60 }));
|
|
845
|
+
if (i.state !== o.state)
|
|
846
|
+
throw new J("state_mismatch", "Invalid state");
|
|
847
|
+
const a = ((r = e.authorizationParams) === null || r === void 0 ? void 0 : r.organization) || this.options.authorizationParams.organization;
|
|
848
|
+
await this._requestToken({ audience: i.audience, scope: i.scope, code_verifier: i.code_verifier, grant_type: "authorization_code", code: o.code, redirect_uri: i.redirect_uri }, { nonceIn: i.nonce, organization: a });
|
|
849
|
+
}
|
|
850
|
+
async getUser() {
|
|
851
|
+
var e;
|
|
852
|
+
const n = await this._getIdTokenFromCache();
|
|
853
|
+
return (e = n == null ? void 0 : n.decodedToken) === null || e === void 0 ? void 0 : e.user;
|
|
854
|
+
}
|
|
855
|
+
async getIdTokenClaims() {
|
|
856
|
+
var e;
|
|
857
|
+
const n = await this._getIdTokenFromCache();
|
|
858
|
+
return (e = n == null ? void 0 : n.decodedToken) === null || e === void 0 ? void 0 : e.claims;
|
|
859
|
+
}
|
|
860
|
+
async loginWithRedirect(e = {}) {
|
|
861
|
+
var n;
|
|
862
|
+
const r = Lt(e), { openUrl: i, fragment: o, appState: a } = r, s = q(r, ["openUrl", "fragment", "appState"]), f = ((n = s.authorizationParams) === null || n === void 0 ? void 0 : n.organization) || this.options.authorizationParams.organization, m = await this._prepareAuthorizeUrl(s.authorizationParams || {}), { url: u } = m, c = q(m, ["url"]);
|
|
863
|
+
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, c), { appState: a }), f && { organization: f }));
|
|
864
|
+
const d = o ? `${u}#${o}` : u;
|
|
865
|
+
i ? await i(d) : window.location.assign(d);
|
|
866
|
+
}
|
|
867
|
+
async handleRedirectCallback(e = window.location.href) {
|
|
868
|
+
const n = e.split("?").slice(1);
|
|
869
|
+
if (n.length === 0)
|
|
870
|
+
throw new Error("There are no query params available for parsing.");
|
|
871
|
+
const { state: r, code: i, error: o, error_description: a } = ((c) => {
|
|
872
|
+
c.indexOf("#") > -1 && (c = c.substring(0, c.indexOf("#")));
|
|
873
|
+
const d = new URLSearchParams(c);
|
|
874
|
+
return { state: d.get("state"), code: d.get("code") || void 0, error: d.get("error") || void 0, error_description: d.get("error_description") || void 0 };
|
|
875
|
+
})(n.join("")), s = this.transactionManager.get();
|
|
876
|
+
if (!s)
|
|
877
|
+
throw new J("missing_transaction", "Invalid state");
|
|
878
|
+
if (this.transactionManager.remove(), o)
|
|
879
|
+
throw new ar(o, a || o, r, s.appState);
|
|
880
|
+
if (!s.code_verifier || s.state && s.state !== r)
|
|
881
|
+
throw new J("state_mismatch", "Invalid state");
|
|
882
|
+
const f = s.organization, m = s.nonce, u = s.redirect_uri;
|
|
883
|
+
return await this._requestToken(Object.assign({ audience: s.audience, scope: s.scope, code_verifier: s.code_verifier, grant_type: "authorization_code", code: i }, u ? { redirect_uri: u } : {}), { nonceIn: m, organization: f }), { appState: s.appState };
|
|
884
|
+
}
|
|
885
|
+
async checkSession(e) {
|
|
886
|
+
if (!this.cookieStorage.get(this.isAuthenticatedCookieName)) {
|
|
887
|
+
if (!this.cookieStorage.get("auth0.is.authenticated"))
|
|
888
|
+
return;
|
|
889
|
+
this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove("auth0.is.authenticated");
|
|
890
|
+
}
|
|
891
|
+
try {
|
|
892
|
+
await this.getTokenSilently(e);
|
|
893
|
+
} catch {
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
async getTokenSilently(e = {}) {
|
|
897
|
+
var n;
|
|
898
|
+
const r = Object.assign(Object.assign({ cacheMode: "on" }, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: Ae(this.scope, (n = e.authorizationParams) === null || n === void 0 ? void 0 : n.scope) }) }), i = await ((o, a) => {
|
|
899
|
+
let s = at[a];
|
|
900
|
+
return s || (s = o().finally(() => {
|
|
901
|
+
delete at[a], s = null;
|
|
902
|
+
}), at[a] = s), s;
|
|
903
|
+
})(() => this._getTokenSilently(r), `${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);
|
|
904
|
+
return e.detailedResponse ? i : i == null ? void 0 : i.access_token;
|
|
905
|
+
}
|
|
906
|
+
async _getTokenSilently(e) {
|
|
907
|
+
const { cacheMode: n } = e, r = q(e, ["cacheMode"]);
|
|
908
|
+
if (n !== "off") {
|
|
909
|
+
const i = await this._getEntryFromCache({ scope: r.authorizationParams.scope, audience: r.authorizationParams.audience || "default", clientId: this.options.clientId });
|
|
910
|
+
if (i)
|
|
911
|
+
return i;
|
|
912
|
+
}
|
|
913
|
+
if (n !== "cache-only") {
|
|
914
|
+
if (!await (async (i, o = 3) => {
|
|
915
|
+
for (let a = 0; a < o; a++)
|
|
916
|
+
if (await i())
|
|
917
|
+
return !0;
|
|
918
|
+
return !1;
|
|
919
|
+
})(() => st.acquireLock("auth0.lock.getTokenSilently", 5e3), 10))
|
|
920
|
+
throw new pt();
|
|
921
|
+
try {
|
|
922
|
+
if (window.addEventListener("pagehide", this._releaseLockOnPageHide), n !== "off") {
|
|
923
|
+
const m = await this._getEntryFromCache({ scope: r.authorizationParams.scope, audience: r.authorizationParams.audience || "default", clientId: this.options.clientId });
|
|
924
|
+
if (m)
|
|
925
|
+
return m;
|
|
926
|
+
}
|
|
927
|
+
const i = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(r) : await this._getTokenFromIFrame(r), { id_token: o, access_token: a, oauthTokenScope: s, expires_in: f } = i;
|
|
928
|
+
return Object.assign(Object.assign({ id_token: o, access_token: a }, s ? { scope: s } : null), { expires_in: f });
|
|
929
|
+
} finally {
|
|
930
|
+
await st.releaseLock("auth0.lock.getTokenSilently"), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
async getTokenWithPopup(e = {}, n = {}) {
|
|
935
|
+
var r;
|
|
936
|
+
const i = Object.assign(Object.assign({}, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: Ae(this.scope, (r = e.authorizationParams) === null || r === void 0 ? void 0 : r.scope) }) });
|
|
937
|
+
return n = Object.assign(Object.assign({}, or), n), await this.loginWithPopup(i, n), (await this.cacheManager.get(new ce({ scope: i.authorizationParams.scope, audience: i.authorizationParams.audience || "default", clientId: this.options.clientId }))).access_token;
|
|
938
|
+
}
|
|
939
|
+
async isAuthenticated() {
|
|
940
|
+
return !!await this.getUser();
|
|
941
|
+
}
|
|
942
|
+
_buildLogoutUrl(e) {
|
|
943
|
+
e.clientId !== null ? e.clientId = e.clientId || this.options.clientId : delete e.clientId;
|
|
944
|
+
const n = e.logoutParams || {}, { federated: r } = n, i = q(n, ["federated"]), o = r ? "&federated" : "";
|
|
945
|
+
return this._url(`/v2/logout?${mt(Object.assign({ clientId: e.clientId }, i))}`) + o;
|
|
946
|
+
}
|
|
947
|
+
async logout(e = {}) {
|
|
948
|
+
const n = Lt(e), { openUrl: r } = n, i = q(n, ["openUrl"]);
|
|
949
|
+
e.clientId === null ? await this.cacheManager.clear() : await this.cacheManager.clear(e.clientId || this.options.clientId), this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove(this.isAuthenticatedCookieName, { cookieDomain: this.options.cookieDomain }), this.userCache.remove("@@user@@");
|
|
950
|
+
const o = this._buildLogoutUrl(i);
|
|
951
|
+
r ? await r(o) : r !== !1 && window.location.assign(o);
|
|
952
|
+
}
|
|
953
|
+
async _getTokenFromIFrame(e) {
|
|
954
|
+
const n = Object.assign(Object.assign({}, e.authorizationParams), { prompt: "none" }), r = this.cookieStorage.get(this.orgHintCookieName);
|
|
955
|
+
r && !n.organization && (n.organization = r);
|
|
956
|
+
const { url: i, state: o, nonce: a, code_verifier: s, redirect_uri: f, scope: m, audience: u } = await this._prepareAuthorizeUrl(n, { response_mode: "web_message" }, window.location.origin);
|
|
957
|
+
try {
|
|
958
|
+
if (window.crossOriginIsolated)
|
|
959
|
+
throw new J("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
|
|
960
|
+
const c = e.timeoutInSeconds || this.options.authorizeTimeoutInSeconds, d = await ((v, w, y = 60) => new Promise((k, _) => {
|
|
961
|
+
const I = window.document.createElement("iframe");
|
|
962
|
+
I.setAttribute("width", "0"), I.setAttribute("height", "0"), I.style.display = "none";
|
|
963
|
+
const g = () => {
|
|
964
|
+
window.document.body.contains(I) && (window.document.body.removeChild(I), window.removeEventListener("message", b, !1));
|
|
965
|
+
};
|
|
966
|
+
let b;
|
|
967
|
+
const D = setTimeout(() => {
|
|
968
|
+
_(new pt()), g();
|
|
969
|
+
}, 1e3 * y);
|
|
970
|
+
b = function(C) {
|
|
971
|
+
if (C.origin != w || !C.data || C.data.type !== "authorization_response")
|
|
972
|
+
return;
|
|
973
|
+
const x = C.source;
|
|
974
|
+
x && x.close(), C.data.response.error ? _(J.fromPayload(C.data.response)) : k(C.data.response), clearTimeout(D), window.removeEventListener("message", b, !1), setTimeout(g, 2e3);
|
|
975
|
+
}, window.addEventListener("message", b, !1), window.document.body.appendChild(I), I.setAttribute("src", v);
|
|
976
|
+
}))(i, this.domainUrl, c);
|
|
977
|
+
if (o !== d.state)
|
|
978
|
+
throw new J("state_mismatch", "Invalid state");
|
|
979
|
+
const h = await this._requestToken(Object.assign(Object.assign({}, e.authorizationParams), { code_verifier: s, code: d.code, grant_type: "authorization_code", redirect_uri: f, timeout: e.authorizationParams.timeout || this.httpTimeoutMs }), { nonceIn: a, organization: n.organization });
|
|
980
|
+
return Object.assign(Object.assign({}, h), { scope: m, oauthTokenScope: h.scope, audience: u });
|
|
981
|
+
} catch (c) {
|
|
982
|
+
throw c.error === "login_required" && this.logout({ openUrl: !1 }), c;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
async _getTokenUsingRefreshToken(e) {
|
|
986
|
+
const n = await this.cacheManager.get(new ce({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId }));
|
|
987
|
+
if (!(n && n.refresh_token || this.worker)) {
|
|
988
|
+
if (this.options.useRefreshTokensFallback)
|
|
989
|
+
return await this._getTokenFromIFrame(e);
|
|
990
|
+
throw new wn(e.authorizationParams.audience || "default", e.authorizationParams.scope);
|
|
991
|
+
}
|
|
992
|
+
const r = e.authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || window.location.origin, i = typeof e.timeoutInSeconds == "number" ? 1e3 * e.timeoutInSeconds : null;
|
|
993
|
+
try {
|
|
994
|
+
const o = await this._requestToken(Object.assign(Object.assign(Object.assign({}, e.authorizationParams), { grant_type: "refresh_token", refresh_token: n && n.refresh_token, redirect_uri: r }), i && { timeout: i }));
|
|
995
|
+
return Object.assign(Object.assign({}, o), { scope: e.authorizationParams.scope, oauthTokenScope: o.scope, audience: e.authorizationParams.audience || "default" });
|
|
996
|
+
} catch (o) {
|
|
997
|
+
if ((o.message.indexOf("Missing Refresh Token") > -1 || o.message && o.message.indexOf("invalid refresh token") > -1) && this.options.useRefreshTokensFallback)
|
|
998
|
+
return await this._getTokenFromIFrame(e);
|
|
999
|
+
throw o;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
async _saveEntryInCache(e) {
|
|
1003
|
+
const { id_token: n, decodedToken: r } = e, i = q(e, ["id_token", "decodedToken"]);
|
|
1004
|
+
this.userCache.set("@@user@@", { id_token: n, decodedToken: r }), await this.cacheManager.setIdToken(this.options.clientId, e.id_token, e.decodedToken), await this.cacheManager.set(i);
|
|
1005
|
+
}
|
|
1006
|
+
async _getIdTokenFromCache() {
|
|
1007
|
+
const e = this.options.authorizationParams.audience || "default", n = await this.cacheManager.getIdToken(new ce({ clientId: this.options.clientId, audience: e, scope: this.scope })), r = this.userCache.get("@@user@@");
|
|
1008
|
+
return n && n.id_token === (r == null ? void 0 : r.id_token) ? r : (this.userCache.set("@@user@@", n), n);
|
|
1009
|
+
}
|
|
1010
|
+
async _getEntryFromCache({ scope: e, audience: n, clientId: r }) {
|
|
1011
|
+
const i = await this.cacheManager.get(new ce({ scope: e, audience: n, clientId: r }), 60);
|
|
1012
|
+
if (i && i.access_token) {
|
|
1013
|
+
const { access_token: o, oauthTokenScope: a, expires_in: s } = i, f = await this._getIdTokenFromCache();
|
|
1014
|
+
return f && Object.assign(Object.assign({ id_token: f.id_token, access_token: o }, a ? { scope: a } : null), { expires_in: s });
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
async _requestToken(e, n) {
|
|
1018
|
+
const { nonceIn: r, organization: i } = n || {}, o = await pr(Object.assign({ baseUrl: this.domainUrl, client_id: this.options.clientId, auth0Client: this.options.auth0Client, useFormData: this.options.useFormData, timeout: this.httpTimeoutMs }, e), this.worker), a = await this._verifyIdToken(o.id_token, r, i);
|
|
1019
|
+
return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, o), { decodedToken: a, scope: e.scope, audience: e.audience || "default" }), o.scope ? { oauthTokenScope: o.scope } : null), { client_id: this.options.clientId })), this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this._processOrgHint(i || a.claims.org_id), Object.assign(Object.assign({}, o), { decodedToken: a });
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
async function xr(t) {
|
|
1023
|
+
const e = new Er(t);
|
|
1024
|
+
return await e.checkSession(), e;
|
|
1025
|
+
}
|
|
1026
|
+
const jr = "sesamy.com", Tr = "https://logs.sesamy.com/events";
|
|
1027
|
+
let Q;
|
|
1028
|
+
async function Cr({ clientId: t }) {
|
|
1029
|
+
if (Q = await xr({
|
|
1030
|
+
domain: `token.${jr}`,
|
|
1031
|
+
clientId: t,
|
|
1032
|
+
cacheLocation: "localstorage"
|
|
1033
|
+
}), window.location.search.includes("code="))
|
|
1034
|
+
try {
|
|
1035
|
+
await Q.handleRedirectCallback(), window.history.replaceState({}, document.title, "/");
|
|
1036
|
+
} catch {
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
async function $r() {
|
|
1040
|
+
if (!Q)
|
|
1041
|
+
throw new Error("Auth0 client not initialized");
|
|
1042
|
+
return Q.isAuthenticated();
|
|
1043
|
+
}
|
|
1044
|
+
async function zr() {
|
|
1045
|
+
if (!Q)
|
|
1046
|
+
throw new Error("Auth0 client not initialized");
|
|
1047
|
+
return Q.getUser();
|
|
1048
|
+
}
|
|
1049
|
+
function Nr() {
|
|
1050
|
+
if (!Q)
|
|
1051
|
+
throw new Error("Auth0 client not initialized");
|
|
1052
|
+
return Q.loginWithRedirect({
|
|
1053
|
+
authorizationParams: {
|
|
1054
|
+
redirect_uri: window.location.href
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
function Dr() {
|
|
1059
|
+
if (!Q)
|
|
1060
|
+
throw new Error("Auth0 client not initialized");
|
|
1061
|
+
return Q.logout({
|
|
1062
|
+
logoutParams: {
|
|
1063
|
+
returnTo: window.location.href
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
function Lr(t = "sesamy") {
|
|
1068
|
+
window[t] = {
|
|
1069
|
+
getUser: zr,
|
|
1070
|
+
isAuthenticated: $r,
|
|
1071
|
+
loginWithRedirect: Nr,
|
|
1072
|
+
logout: Dr
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
function At(t, e, n, r, i) {
|
|
1076
|
+
for (e = e.split ? e.split(".") : e, r = 0; r < e.length; r++)
|
|
1077
|
+
t = t ? t[e[r]] : i;
|
|
1078
|
+
return t === i ? n : t;
|
|
1079
|
+
}
|
|
1080
|
+
var Ue = "undefined", Ut = "object", Ar = function() {
|
|
1081
|
+
}, _n = "any", On = "*", de = "__", He = typeof process < "u" ? process : {};
|
|
1082
|
+
He.env && He.env.NODE_ENV;
|
|
1083
|
+
var H = typeof document < "u";
|
|
1084
|
+
He.versions != null && He.versions.node != null;
|
|
1085
|
+
typeof Deno < "u" && Deno.core;
|
|
1086
|
+
H && window.name === "nodejs" || typeof navigator < "u" && navigator.userAgent !== void 0 && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
|
|
1087
|
+
function Pn(t, e) {
|
|
1088
|
+
return e.charAt(0)[t]() + e.slice(1);
|
|
1089
|
+
}
|
|
1090
|
+
var Ur = Pn.bind(null, "toUpperCase"), Zr = Pn.bind(null, "toLowerCase");
|
|
1091
|
+
function Rr(t) {
|
|
1092
|
+
return En(t) ? Ur("null") : typeof t == "object" ? Xr(t) : Object.prototype.toString.call(t).slice(8, -1);
|
|
1093
|
+
}
|
|
1094
|
+
function Ye(t, e) {
|
|
1095
|
+
e === void 0 && (e = !0);
|
|
1096
|
+
var n = Rr(t);
|
|
1097
|
+
return e ? Zr(n) : n;
|
|
1098
|
+
}
|
|
1099
|
+
function De(t, e) {
|
|
1100
|
+
return typeof e === t;
|
|
1101
|
+
}
|
|
1102
|
+
var G = De.bind(null, "function"), re = De.bind(null, "string"), me = De.bind(null, "undefined"), Wr = De.bind(null, "boolean");
|
|
1103
|
+
De.bind(null, "symbol");
|
|
1104
|
+
function En(t) {
|
|
1105
|
+
return t === null;
|
|
1106
|
+
}
|
|
1107
|
+
function Kr(t) {
|
|
1108
|
+
return Ye(t) === "number" && !isNaN(t);
|
|
1109
|
+
}
|
|
1110
|
+
function xn(t) {
|
|
1111
|
+
return Ye(t) === "array";
|
|
1112
|
+
}
|
|
1113
|
+
function F(t) {
|
|
1114
|
+
if (!Mr(t))
|
|
1115
|
+
return !1;
|
|
1116
|
+
for (var e = t; Object.getPrototypeOf(e) !== null; )
|
|
1117
|
+
e = Object.getPrototypeOf(e);
|
|
1118
|
+
return Object.getPrototypeOf(t) === e;
|
|
1119
|
+
}
|
|
1120
|
+
function Mr(t) {
|
|
1121
|
+
return t && (typeof t == "object" || t !== null);
|
|
1122
|
+
}
|
|
1123
|
+
function Xr(t) {
|
|
1124
|
+
return G(t.constructor) ? t.constructor.name : null;
|
|
1125
|
+
}
|
|
1126
|
+
function Vr(t) {
|
|
1127
|
+
return t instanceof Error || re(t.message) && t.constructor && Kr(t.constructor.stackTraceLimit);
|
|
1128
|
+
}
|
|
1129
|
+
function jn(t, e) {
|
|
1130
|
+
if (typeof e != "object" || En(e))
|
|
1131
|
+
return !1;
|
|
1132
|
+
if (e instanceof t)
|
|
1133
|
+
return !0;
|
|
1134
|
+
var n = Ye(new t(""));
|
|
1135
|
+
if (Vr(e))
|
|
1136
|
+
for (; e; ) {
|
|
1137
|
+
if (Ye(e) === n)
|
|
1138
|
+
return !0;
|
|
1139
|
+
e = Object.getPrototypeOf(e);
|
|
1140
|
+
}
|
|
1141
|
+
return !1;
|
|
1142
|
+
}
|
|
1143
|
+
jn.bind(null, TypeError);
|
|
1144
|
+
jn.bind(null, SyntaxError);
|
|
1145
|
+
function qe(t, e) {
|
|
1146
|
+
var n = t instanceof Element || t instanceof HTMLDocument;
|
|
1147
|
+
return n && e ? Fr(t, e) : n;
|
|
1148
|
+
}
|
|
1149
|
+
function Fr(t, e) {
|
|
1150
|
+
return e === void 0 && (e = ""), t && t.nodeName === e.toUpperCase();
|
|
1151
|
+
}
|
|
1152
|
+
function Qe(t) {
|
|
1153
|
+
var e = [].slice.call(arguments, 1);
|
|
1154
|
+
return function() {
|
|
1155
|
+
return t.apply(void 0, [].slice.call(arguments).concat(e));
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
Qe(qe, "form");
|
|
1159
|
+
Qe(qe, "button");
|
|
1160
|
+
Qe(qe, "input");
|
|
1161
|
+
Qe(qe, "select");
|
|
1162
|
+
function Jr(t) {
|
|
1163
|
+
return t ? xn(t) ? t : [t] : [];
|
|
1164
|
+
}
|
|
1165
|
+
function Zt(t) {
|
|
1166
|
+
try {
|
|
1167
|
+
return decodeURIComponent(t.replace(/\+/g, " "));
|
|
1168
|
+
} catch {
|
|
1169
|
+
return null;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function Hr() {
|
|
1173
|
+
if (H) {
|
|
1174
|
+
var t = navigator, e = t.languages;
|
|
1175
|
+
return t.userLanguage || (e && e.length ? e[0] : t.language);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
function Yr() {
|
|
1179
|
+
try {
|
|
1180
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1181
|
+
} catch {
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
function Gr(t) {
|
|
1185
|
+
return function(e) {
|
|
1186
|
+
for (var n, r = /* @__PURE__ */ Object.create(null), i = /([^&=]+)=?([^&]*)/g; n = i.exec(e); ) {
|
|
1187
|
+
var o = Zt(n[1]), a = Zt(n[2]);
|
|
1188
|
+
o.substring(o.length - 2) === "[]" ? (r[o = o.substring(0, o.length - 2)] || (r[o] = [])).push(a) : r[o] = a === "" || a;
|
|
1189
|
+
}
|
|
1190
|
+
for (var s in r) {
|
|
1191
|
+
var f = s.split("[");
|
|
1192
|
+
f.length > 1 && (Br(r, f.map(function(m) {
|
|
1193
|
+
return m.replace(/[?[\]\\ ]/g, "");
|
|
1194
|
+
}), r[s]), delete r[s]);
|
|
1195
|
+
}
|
|
1196
|
+
return r;
|
|
1197
|
+
}(function(e) {
|
|
1198
|
+
if (e) {
|
|
1199
|
+
var n = e.match(/\?(.*)/);
|
|
1200
|
+
return n && n[1] ? n[1].split("#")[0] : "";
|
|
1201
|
+
}
|
|
1202
|
+
return H && window.location.search.substring(1);
|
|
1203
|
+
}(t));
|
|
1204
|
+
}
|
|
1205
|
+
function Br(t, e, n) {
|
|
1206
|
+
for (var r = e.length - 1, i = 0; i < r; ++i) {
|
|
1207
|
+
var o = e[i];
|
|
1208
|
+
if (o === "__proto__" || o === "constructor")
|
|
1209
|
+
break;
|
|
1210
|
+
o in t || (t[o] = {}), t = t[o];
|
|
1211
|
+
}
|
|
1212
|
+
t[e[r]] = n;
|
|
1213
|
+
}
|
|
1214
|
+
function et() {
|
|
1215
|
+
for (var t = "", e = 0, n = 4294967295 * Math.random() | 0; e++ < 36; ) {
|
|
1216
|
+
var r = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e - 1], i = 15 & n;
|
|
1217
|
+
t += r == "-" || r == "4" ? r : (r == "x" ? i : 3 & i | 8).toString(16), n = e % 8 == 0 ? 4294967295 * Math.random() | 0 : n >> 4;
|
|
1218
|
+
}
|
|
1219
|
+
return t;
|
|
1220
|
+
}
|
|
1221
|
+
var Te = "global", be = de + "global" + de, ke = typeof self === Ut && self.self === self && self || typeof global === Ut && global.global === global && global || void 0;
|
|
1222
|
+
function he(t) {
|
|
1223
|
+
return ke[be][t];
|
|
1224
|
+
}
|
|
1225
|
+
function fe(t, e) {
|
|
1226
|
+
return ke[be][t] = e;
|
|
1227
|
+
}
|
|
1228
|
+
function Se(t) {
|
|
1229
|
+
delete ke[be][t];
|
|
1230
|
+
}
|
|
1231
|
+
function _e(t, e, n) {
|
|
1232
|
+
var r;
|
|
1233
|
+
try {
|
|
1234
|
+
if (It(t)) {
|
|
1235
|
+
var i = window[t];
|
|
1236
|
+
r = i[e].bind(i);
|
|
1237
|
+
}
|
|
1238
|
+
} catch {
|
|
1239
|
+
}
|
|
1240
|
+
return r || n;
|
|
1241
|
+
}
|
|
1242
|
+
ke[be] || (ke[be] = {});
|
|
1243
|
+
var Ze = {};
|
|
1244
|
+
function It(t) {
|
|
1245
|
+
if (typeof Ze[t] !== Ue)
|
|
1246
|
+
return Ze[t];
|
|
1247
|
+
try {
|
|
1248
|
+
var e = window[t];
|
|
1249
|
+
e.setItem(Ue, Ue), e.removeItem(Ue);
|
|
1250
|
+
} catch {
|
|
1251
|
+
return Ze[t] = !1;
|
|
1252
|
+
}
|
|
1253
|
+
return Ze[t] = !0;
|
|
1254
|
+
}
|
|
1255
|
+
function P() {
|
|
1256
|
+
return P = Object.assign || function(t) {
|
|
1257
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
1258
|
+
var n = arguments[e];
|
|
1259
|
+
for (var r in n)
|
|
1260
|
+
Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
|
|
1261
|
+
}
|
|
1262
|
+
return t;
|
|
1263
|
+
}, P.apply(this, arguments);
|
|
1264
|
+
}
|
|
1265
|
+
var ne = "function", ee = "undefined", qr = "@@redux/" + Math.random().toString(36), Rt = /* @__PURE__ */ function() {
|
|
1266
|
+
return typeof Symbol === ne && Symbol.observable || "@@observable";
|
|
1267
|
+
}(), Re = " != " + ne;
|
|
1268
|
+
function Tn(t, e, n) {
|
|
1269
|
+
var r;
|
|
1270
|
+
if (typeof e === ne && typeof n === ee && (n = e, e = void 0), typeof n !== ee) {
|
|
1271
|
+
if (typeof n !== ne)
|
|
1272
|
+
throw new Error("enhancer" + Re);
|
|
1273
|
+
return n(Tn)(t, e);
|
|
1274
|
+
}
|
|
1275
|
+
if (typeof t !== ne)
|
|
1276
|
+
throw new Error("reducer" + Re);
|
|
1277
|
+
var i = t, o = e, a = [], s = a, f = !1;
|
|
1278
|
+
function m() {
|
|
1279
|
+
s === a && (s = a.slice());
|
|
1280
|
+
}
|
|
1281
|
+
function u() {
|
|
1282
|
+
return o;
|
|
1283
|
+
}
|
|
1284
|
+
function c(h) {
|
|
1285
|
+
if (typeof h !== ne)
|
|
1286
|
+
throw new Error("Listener" + Re);
|
|
1287
|
+
var v = !0;
|
|
1288
|
+
return m(), s.push(h), function() {
|
|
1289
|
+
if (v) {
|
|
1290
|
+
v = !1, m();
|
|
1291
|
+
var w = s.indexOf(h);
|
|
1292
|
+
s.splice(w, 1);
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function d(h) {
|
|
1297
|
+
if (!F(h))
|
|
1298
|
+
throw new Error("Act != obj");
|
|
1299
|
+
if (typeof h.type === ee)
|
|
1300
|
+
throw new Error("ActType " + ee);
|
|
1301
|
+
if (f)
|
|
1302
|
+
throw new Error("Dispatch in reducer");
|
|
1303
|
+
try {
|
|
1304
|
+
f = !0, o = i(o, h);
|
|
1305
|
+
} finally {
|
|
1306
|
+
f = !1;
|
|
1307
|
+
}
|
|
1308
|
+
for (var v = a = s, w = 0; w < v.length; w++)
|
|
1309
|
+
(0, v[w])();
|
|
1310
|
+
return h;
|
|
1311
|
+
}
|
|
1312
|
+
return d({ type: "@@redux/INIT" }), (r = { dispatch: d, subscribe: c, getState: u, replaceReducer: function(h) {
|
|
1313
|
+
if (typeof h !== ne)
|
|
1314
|
+
throw new Error("next reducer" + Re);
|
|
1315
|
+
i = h, d({ type: "@@redux/INIT" });
|
|
1316
|
+
} })[Rt] = function() {
|
|
1317
|
+
var h, v = c;
|
|
1318
|
+
return (h = { subscribe: function(w) {
|
|
1319
|
+
if (typeof w != "object")
|
|
1320
|
+
throw new TypeError("Observer != obj");
|
|
1321
|
+
function y() {
|
|
1322
|
+
w.next && w.next(u());
|
|
1323
|
+
}
|
|
1324
|
+
return y(), { unsubscribe: v(y) };
|
|
1325
|
+
} })[Rt] = function() {
|
|
1326
|
+
return this;
|
|
1327
|
+
}, h;
|
|
1328
|
+
}, r;
|
|
1329
|
+
}
|
|
1330
|
+
function Qr(t, e) {
|
|
1331
|
+
var n = e && e.type;
|
|
1332
|
+
return "action " + (n && n.toString() || "?") + "reducer " + t + " returns " + ee;
|
|
1333
|
+
}
|
|
1334
|
+
function Ie() {
|
|
1335
|
+
var t = [].slice.call(arguments);
|
|
1336
|
+
return t.length === 0 ? function(e) {
|
|
1337
|
+
return e;
|
|
1338
|
+
} : t.length === 1 ? t[0] : t.reduce(function(e, n) {
|
|
1339
|
+
return function() {
|
|
1340
|
+
return e(n.apply(void 0, [].slice.call(arguments)));
|
|
1341
|
+
};
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
function ei() {
|
|
1345
|
+
var t = arguments;
|
|
1346
|
+
return function(e) {
|
|
1347
|
+
return function(n, r, i) {
|
|
1348
|
+
var o, a = e(n, r, i), s = a.dispatch, f = { getState: a.getState, dispatch: function(m) {
|
|
1349
|
+
return s(m);
|
|
1350
|
+
} };
|
|
1351
|
+
return o = [].slice.call(t).map(function(m) {
|
|
1352
|
+
return m(f);
|
|
1353
|
+
}), P({}, a, { dispatch: s = Ie.apply(void 0, o)(a.dispatch) });
|
|
1354
|
+
};
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
var ie = de + "anon_id", le = de + "user_id", ve = de + "user_traits", te = "userId", ge = "anonymousId", Fe = ["bootstrap", "params", "campaign", "initializeStart", "initialize", "initializeEnd", "ready", "resetStart", "reset", "resetEnd", "pageStart", "page", "pageEnd", "pageAborted", "trackStart", "track", "trackEnd", "trackAborted", "identifyStart", "identify", "identifyEnd", "identifyAborted", "userIdChanged", "registerPlugins", "enablePlugin", "disablePlugin", "online", "offline", "setItemStart", "setItem", "setItemEnd", "setItemAborted", "removeItemStart", "removeItem", "removeItemEnd", "removeItemAborted"], vt = ["name", "EVENTS", "config", "loaded"], O = Fe.reduce(function(t, e) {
|
|
1358
|
+
return t[e] = e, t;
|
|
1359
|
+
}, { registerPluginType: function(t) {
|
|
1360
|
+
return "registerPlugin:" + t;
|
|
1361
|
+
}, pluginReadyType: function(t) {
|
|
1362
|
+
return "ready:" + t;
|
|
1363
|
+
} }), Wt = /^utm_/, Kt = /^an_prop_/, Mt = /^an_trait_/;
|
|
1364
|
+
function ti(t) {
|
|
1365
|
+
var e = t.storage.setItem;
|
|
1366
|
+
return function(n) {
|
|
1367
|
+
return function(r) {
|
|
1368
|
+
return function(i) {
|
|
1369
|
+
if (i.type === O.bootstrap) {
|
|
1370
|
+
var o = i.params, a = i.user, s = i.persistedUser, f = i.initialUser, m = s.userId === a.userId;
|
|
1371
|
+
s.anonymousId !== a.anonymousId && e(ie, a.anonymousId), m || e(le, a.userId), f.traits && e(ve, P({}, m && s.traits ? s.traits : {}, f.traits));
|
|
1372
|
+
var u = Object.keys(i.params);
|
|
1373
|
+
if (u.length) {
|
|
1374
|
+
var c = o.an_uid, d = o.an_event, h = u.reduce(function(v, w) {
|
|
1375
|
+
if (w.match(Wt) || w.match(/^(d|g)clid/)) {
|
|
1376
|
+
var y = w.replace(Wt, "");
|
|
1377
|
+
v.campaign[y === "campaign" ? "name" : y] = o[w];
|
|
1378
|
+
}
|
|
1379
|
+
return w.match(Kt) && (v.props[w.replace(Kt, "")] = o[w]), w.match(Mt) && (v.traits[w.replace(Mt, "")] = o[w]), v;
|
|
1380
|
+
}, { campaign: {}, props: {}, traits: {} });
|
|
1381
|
+
n.dispatch(P({ type: O.params, raw: o }, h, c ? { userId: c } : {})), c && setTimeout(function() {
|
|
1382
|
+
return t.identify(c, h.traits);
|
|
1383
|
+
}, 0), d && setTimeout(function() {
|
|
1384
|
+
return t.track(d, h.props);
|
|
1385
|
+
}, 0), Object.keys(h.campaign).length && n.dispatch({ type: O.campaign, campaign: h.campaign });
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return r(i);
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
function ni(t) {
|
|
1394
|
+
return function(e, n) {
|
|
1395
|
+
if (e === void 0 && (e = {}), n === void 0 && (n = {}), n.type === O.setItemEnd) {
|
|
1396
|
+
if (n.key === ie)
|
|
1397
|
+
return P({}, e, { anonymousId: n.value });
|
|
1398
|
+
if (n.key === le)
|
|
1399
|
+
return P({}, e, { userId: n.value });
|
|
1400
|
+
}
|
|
1401
|
+
switch (n.type) {
|
|
1402
|
+
case O.identify:
|
|
1403
|
+
return Object.assign({}, e, { userId: n.userId, traits: P({}, e.traits, n.traits) });
|
|
1404
|
+
case O.reset:
|
|
1405
|
+
return [le, ie, ve].forEach(function(r) {
|
|
1406
|
+
t.removeItem(r);
|
|
1407
|
+
}), Object.assign({}, e, { userId: null, anonymousId: null, traits: {} });
|
|
1408
|
+
default:
|
|
1409
|
+
return e;
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
function Xt(t) {
|
|
1414
|
+
return { userId: t.getItem(le), anonymousId: t.getItem(ie), traits: t.getItem(ve) };
|
|
1415
|
+
}
|
|
1416
|
+
var yt = function(t) {
|
|
1417
|
+
return de + "TEMP" + de + t;
|
|
1418
|
+
};
|
|
1419
|
+
function ri(t) {
|
|
1420
|
+
var e = t.storage, n = e.setItem, r = e.removeItem, i = e.getItem;
|
|
1421
|
+
return function(o) {
|
|
1422
|
+
return function(a) {
|
|
1423
|
+
return function(s) {
|
|
1424
|
+
var f = s.userId, m = s.traits, u = s.options;
|
|
1425
|
+
if (s.type === O.reset && ([le, ve, ie].forEach(function(h) {
|
|
1426
|
+
r(h);
|
|
1427
|
+
}), [te, ge, "traits"].forEach(function(h) {
|
|
1428
|
+
Se(yt(h));
|
|
1429
|
+
})), s.type === O.identify) {
|
|
1430
|
+
i(ie) || n(ie, et());
|
|
1431
|
+
var c = i(le), d = i(ve) || {};
|
|
1432
|
+
c && c !== f && o.dispatch({ type: O.userIdChanged, old: { userId: c, traits: d }, new: { userId: f, traits: m }, options: u }), f && n(le, f), m && n(ve, P({}, d, m));
|
|
1433
|
+
}
|
|
1434
|
+
return a(s);
|
|
1435
|
+
};
|
|
1436
|
+
};
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
var je = {};
|
|
1440
|
+
function Vt(t, e) {
|
|
1441
|
+
je[t] && G(je[t]) && (je[t](e), delete je[t]);
|
|
1442
|
+
}
|
|
1443
|
+
function Cn(t, e, n) {
|
|
1444
|
+
return new Promise(function(r, i) {
|
|
1445
|
+
return e() ? r(t) : n < 1 ? i(P({}, t, { queue: !0 })) : new Promise(function(o) {
|
|
1446
|
+
return setTimeout(o, 10);
|
|
1447
|
+
}).then(function(o) {
|
|
1448
|
+
return Cn(t, e, n - 10).then(r, i);
|
|
1449
|
+
});
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
function $n(t, e, n) {
|
|
1453
|
+
var r = e(), i = t.getState(), o = i.plugins, a = i.queue, s = i.user;
|
|
1454
|
+
if (!i.context.offline && a && a.actions && a.actions.length) {
|
|
1455
|
+
var f = a.actions.reduce(function(u, c, d) {
|
|
1456
|
+
return o[c.plugin].loaded ? (u.process.push(c), u.processIndex.push(d)) : (u.requeue.push(c), u.requeueIndex.push(d)), u;
|
|
1457
|
+
}, { processIndex: [], process: [], requeue: [], requeueIndex: [] });
|
|
1458
|
+
if (f.processIndex && f.processIndex.length) {
|
|
1459
|
+
f.processIndex.forEach(function(u) {
|
|
1460
|
+
var c = a.actions[u], d = c.plugin, h = c.payload.type, v = r[d][h];
|
|
1461
|
+
if (v && G(v)) {
|
|
1462
|
+
var w = function(k, _) {
|
|
1463
|
+
return k === void 0 && (k = {}), _ === void 0 && (_ = {}), [te, ge].reduce(function(I, g) {
|
|
1464
|
+
return k.hasOwnProperty(g) && _[g] && _[g] !== k[g] && (I[g] = _[g]), I;
|
|
1465
|
+
}, k);
|
|
1466
|
+
}(c.payload, s);
|
|
1467
|
+
v({ payload: w, config: o[d].config, instance: n });
|
|
1468
|
+
var y = h + ":" + d;
|
|
1469
|
+
t.dispatch(P({}, w, { type: y, _: { called: y, from: "queueDrain" } }));
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
var m = a.actions.filter(function(u, c) {
|
|
1473
|
+
return !~f.processIndex.indexOf(c);
|
|
1474
|
+
});
|
|
1475
|
+
a.actions = m;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
var ct = function(t) {
|
|
1480
|
+
var e = t.data, n = t.action, r = t.instance, i = t.state, o = t.allPlugins, a = t.allMatches, s = t.store, f = t.EVENTS;
|
|
1481
|
+
try {
|
|
1482
|
+
var m = i.plugins, u = i.context, c = n.type, d = c.match(ye), h = e.exact.map(function(y) {
|
|
1483
|
+
return y.pluginName;
|
|
1484
|
+
});
|
|
1485
|
+
d && (h = a.during.map(function(y) {
|
|
1486
|
+
return y.pluginName;
|
|
1487
|
+
}));
|
|
1488
|
+
var v = /* @__PURE__ */ function(y, k) {
|
|
1489
|
+
return function(_, I, g) {
|
|
1490
|
+
var b = I.config, D = I.name, C = D + "." + _.type;
|
|
1491
|
+
g && (C = g.event);
|
|
1492
|
+
var x = _.type.match(ye) ? /* @__PURE__ */ function(A, L, X, U, V) {
|
|
1493
|
+
return function(R, E) {
|
|
1494
|
+
var K = U ? U.name : A, M = E && Ne(E) ? E : X;
|
|
1495
|
+
if (U && (!(M = E && Ne(E) ? E : [A]).includes(A) || M.length !== 1))
|
|
1496
|
+
throw new Error("Method " + L + " can only abort " + A + " plugin. " + JSON.stringify(M) + " input valid");
|
|
1497
|
+
return P({}, V, { abort: { reason: R, plugins: M, caller: L, _: K } });
|
|
1498
|
+
};
|
|
1499
|
+
}(D, C, k, g, _) : /* @__PURE__ */ function(A, L) {
|
|
1500
|
+
return function() {
|
|
1501
|
+
throw new Error(A.type + " action not cancellable. Remove abort in " + L);
|
|
1502
|
+
};
|
|
1503
|
+
}(_, C);
|
|
1504
|
+
return { payload: ii(_), instance: y, config: b || {}, abort: x };
|
|
1505
|
+
};
|
|
1506
|
+
}(r, h), w = e.exact.reduce(function(y, k) {
|
|
1507
|
+
var _ = k.pluginName, I = k.methodName, g = !1;
|
|
1508
|
+
return I.match(/^initialize/) || I.match(/^reset/) || (g = !m[_].loaded), u.offline && I.match(/^(page|track|identify)/) && (g = !0), y["" + _] = g, y;
|
|
1509
|
+
}, {});
|
|
1510
|
+
return Promise.resolve(e.exact.reduce(function(y, k, _) {
|
|
1511
|
+
try {
|
|
1512
|
+
var I = k.pluginName;
|
|
1513
|
+
return Promise.resolve(y).then(function(g) {
|
|
1514
|
+
function b() {
|
|
1515
|
+
return Promise.resolve(g);
|
|
1516
|
+
}
|
|
1517
|
+
var D = function() {
|
|
1518
|
+
if (e.namespaced && e.namespaced[I])
|
|
1519
|
+
return Promise.resolve(e.namespaced[I].reduce(function(C, x, A) {
|
|
1520
|
+
try {
|
|
1521
|
+
return Promise.resolve(C).then(function(L) {
|
|
1522
|
+
return x.method && G(x.method) ? (function(R, E) {
|
|
1523
|
+
var K = qt(R);
|
|
1524
|
+
if (K && K.name === E) {
|
|
1525
|
+
var M = qt(K.method);
|
|
1526
|
+
throw new Error([E + " plugin is calling method " + R, "Plugins cant call self", "Use " + K.method + " " + (M ? "or " + M.method : "") + " in " + E + " plugin insteadof " + R].join(`
|
|
1527
|
+
`));
|
|
1528
|
+
}
|
|
1529
|
+
}(x.methodName, x.pluginName), Promise.resolve(x.method({ payload: L, instance: r, abort: (X = L, U = I, V = x.pluginName, function(R, E) {
|
|
1530
|
+
return P({}, X, { abort: { reason: R, plugins: E || [U], caller: c, from: V || U } });
|
|
1531
|
+
}), config: Ht(x.pluginName, m, o), plugins: m })).then(function(R) {
|
|
1532
|
+
var E = F(R) ? R : {};
|
|
1533
|
+
return Promise.resolve(P({}, L, E));
|
|
1534
|
+
})) : L;
|
|
1535
|
+
var X, U, V;
|
|
1536
|
+
});
|
|
1537
|
+
} catch (L) {
|
|
1538
|
+
return Promise.reject(L);
|
|
1539
|
+
}
|
|
1540
|
+
}, Promise.resolve(n))).then(function(C) {
|
|
1541
|
+
g[I] = C;
|
|
1542
|
+
});
|
|
1543
|
+
g[I] = n;
|
|
1544
|
+
}();
|
|
1545
|
+
return D && D.then ? D.then(b) : b();
|
|
1546
|
+
});
|
|
1547
|
+
} catch (g) {
|
|
1548
|
+
return Promise.reject(g);
|
|
1549
|
+
}
|
|
1550
|
+
}, Promise.resolve({}))).then(function(y) {
|
|
1551
|
+
return Promise.resolve(e.exact.reduce(function(k, _, I) {
|
|
1552
|
+
try {
|
|
1553
|
+
var g = e.exact.length === I + 1, b = _.pluginName, D = o[b];
|
|
1554
|
+
return Promise.resolve(k).then(function(C) {
|
|
1555
|
+
var x = y[b] ? y[b] : {};
|
|
1556
|
+
if (d && (x = C), lt(x, b))
|
|
1557
|
+
return ut({ data: x, method: c, instance: r, pluginName: b, store: s }), Promise.resolve(C);
|
|
1558
|
+
if (lt(C, b))
|
|
1559
|
+
return g && ut({ data: C, method: c, instance: r, store: s }), Promise.resolve(C);
|
|
1560
|
+
if (w.hasOwnProperty(b) && w[b] === !0)
|
|
1561
|
+
return s.dispatch({ type: "queue", plugin: b, payload: x, _: { called: "queue", from: "queueMechanism" } }), Promise.resolve(C);
|
|
1562
|
+
var A = v(y[b], o[b]);
|
|
1563
|
+
return Promise.resolve(D[c]({ abort: A.abort, payload: x, instance: r, config: Ht(b, m, o), plugins: m })).then(function(L) {
|
|
1564
|
+
var X = F(L) ? L : {}, U = P({}, C, X), V = y[b];
|
|
1565
|
+
if (lt(V, b))
|
|
1566
|
+
ut({ data: V, method: c, instance: r, pluginName: b, store: s });
|
|
1567
|
+
else {
|
|
1568
|
+
var R = c + ":" + b;
|
|
1569
|
+
(R.match(/:/g) || []).length < 2 && !c.match(Ft) && !c.match(Jt) && r.dispatch(P({}, d ? U : x, { type: R, _: { called: R, from: "submethod" } }));
|
|
1570
|
+
}
|
|
1571
|
+
return Promise.resolve(U);
|
|
1572
|
+
});
|
|
1573
|
+
});
|
|
1574
|
+
} catch (C) {
|
|
1575
|
+
return Promise.reject(C);
|
|
1576
|
+
}
|
|
1577
|
+
}, Promise.resolve(n))).then(function(k) {
|
|
1578
|
+
if (!(c.match(ye) || c.match(/^registerPlugin/) || c.match(Jt) || c.match(Ft) || c.match(/^params/) || c.match(/^userIdChanged/))) {
|
|
1579
|
+
if (f.plugins.includes(c), k._ && k._.originalAction === c)
|
|
1580
|
+
return k;
|
|
1581
|
+
var _ = P({}, k, { _: { originalAction: k.type, called: k.type, from: "engineEnd" } });
|
|
1582
|
+
zn(k, e.exact.length) && !c.match(/End$/) && (_ = P({}, _, { type: k.type + "Aborted" })), s.dispatch(_);
|
|
1583
|
+
}
|
|
1584
|
+
return k;
|
|
1585
|
+
});
|
|
1586
|
+
});
|
|
1587
|
+
} catch (y) {
|
|
1588
|
+
return Promise.reject(y);
|
|
1589
|
+
}
|
|
1590
|
+
}, ye = /Start$/, Ft = /^bootstrap/, Jt = /^ready/;
|
|
1591
|
+
function ut(t) {
|
|
1592
|
+
var e = t.pluginName, n = t.method + "Aborted" + (e ? ":" + e : "");
|
|
1593
|
+
t.store.dispatch(P({}, t.data, { type: n, _: { called: n, from: "abort" } }));
|
|
1594
|
+
}
|
|
1595
|
+
function Ht(t, e, n) {
|
|
1596
|
+
var r = e[t] || n[t];
|
|
1597
|
+
return r && r.config ? r.config : {};
|
|
1598
|
+
}
|
|
1599
|
+
function Yt(t, e) {
|
|
1600
|
+
return e.reduce(function(n, r) {
|
|
1601
|
+
return r[t] ? n.concat({ methodName: t, pluginName: r.name, method: r[t] }) : n;
|
|
1602
|
+
}, []);
|
|
1603
|
+
}
|
|
1604
|
+
function Gt(t, e) {
|
|
1605
|
+
var n = t.replace(ye, ""), r = e ? ":" + e : "";
|
|
1606
|
+
return ["" + t + r, "" + n + r, n + "End" + r];
|
|
1607
|
+
}
|
|
1608
|
+
function lt(t, e) {
|
|
1609
|
+
var n = t.abort;
|
|
1610
|
+
return !!n && (n === !0 || Bt(n, e) || n && Bt(n.plugins, e));
|
|
1611
|
+
}
|
|
1612
|
+
function zn(t, e) {
|
|
1613
|
+
var n = t.abort;
|
|
1614
|
+
if (!n)
|
|
1615
|
+
return !1;
|
|
1616
|
+
if (n === !0 || re(n))
|
|
1617
|
+
return !0;
|
|
1618
|
+
var r = n.plugins;
|
|
1619
|
+
return Ne(n) && n.length === e || Ne(r) && r.length === e;
|
|
1620
|
+
}
|
|
1621
|
+
function Ne(t) {
|
|
1622
|
+
return Array.isArray(t);
|
|
1623
|
+
}
|
|
1624
|
+
function Bt(t, e) {
|
|
1625
|
+
return !(!t || !Ne(t)) && t.includes(e);
|
|
1626
|
+
}
|
|
1627
|
+
function qt(t) {
|
|
1628
|
+
var e = t.match(/(.*):(.*)/);
|
|
1629
|
+
return !!e && { method: e[1], name: e[2] };
|
|
1630
|
+
}
|
|
1631
|
+
function ii(t) {
|
|
1632
|
+
return Object.keys(t).reduce(function(e, n) {
|
|
1633
|
+
return n === "type" || (e[n] = F(t[n]) ? Object.assign({}, t[n]) : t[n]), e;
|
|
1634
|
+
}, {});
|
|
1635
|
+
}
|
|
1636
|
+
function oi(t, e, n) {
|
|
1637
|
+
var r = {};
|
|
1638
|
+
return function(i) {
|
|
1639
|
+
return function(o) {
|
|
1640
|
+
return function(a) {
|
|
1641
|
+
try {
|
|
1642
|
+
var s, f = function(g) {
|
|
1643
|
+
return s ? g : o(c);
|
|
1644
|
+
}, m = a.type, u = a.plugins, c = a;
|
|
1645
|
+
if (a.abort)
|
|
1646
|
+
return Promise.resolve(o(a));
|
|
1647
|
+
if (m === O.enablePlugin && i.dispatch({ type: O.initializeStart, plugins: u, disabled: [], fromEnable: !0, meta: a.meta }), m === O.disablePlugin && setTimeout(function() {
|
|
1648
|
+
return Vt(a.meta.rid, { payload: a });
|
|
1649
|
+
}, 0), m === O.initializeEnd) {
|
|
1650
|
+
var d = e(), h = Object.keys(d), v = h.filter(function(g) {
|
|
1651
|
+
return u.includes(g);
|
|
1652
|
+
}).map(function(g) {
|
|
1653
|
+
return d[g];
|
|
1654
|
+
}), w = [], y = [], k = a.disabled, _ = v.map(function(g) {
|
|
1655
|
+
var b = g.loaded, D = g.name, C = g.config;
|
|
1656
|
+
return Cn(g, function() {
|
|
1657
|
+
return b({ config: C });
|
|
1658
|
+
}, 1e4).then(function(x) {
|
|
1659
|
+
return r[D] || (i.dispatch({ type: O.pluginReadyType(D), name: D, events: Object.keys(g).filter(function(A) {
|
|
1660
|
+
return !vt.includes(A);
|
|
1661
|
+
}) }), r[D] = !0), w = w.concat(D), g;
|
|
1662
|
+
}).catch(function(x) {
|
|
1663
|
+
if (x instanceof Error)
|
|
1664
|
+
throw new Error(x);
|
|
1665
|
+
return y = y.concat(x.name), x;
|
|
1666
|
+
});
|
|
1667
|
+
});
|
|
1668
|
+
Promise.all(_).then(function(g) {
|
|
1669
|
+
var b = { plugins: w, failed: y, disabled: k };
|
|
1670
|
+
setTimeout(function() {
|
|
1671
|
+
h.length === _.length + k.length && i.dispatch(P({}, { type: O.ready }, b));
|
|
1672
|
+
}, 0);
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
var I = function() {
|
|
1676
|
+
if (m !== O.bootstrap)
|
|
1677
|
+
return /^ready:([^:]*)$/.test(m) && setTimeout(function() {
|
|
1678
|
+
return $n(i, e, t);
|
|
1679
|
+
}, 0), Promise.resolve(function(g, b, D, C, x) {
|
|
1680
|
+
try {
|
|
1681
|
+
var A = G(b) ? b() : b, L = g.type, X = L.replace(ye, "");
|
|
1682
|
+
if (g._ && g._.called)
|
|
1683
|
+
return Promise.resolve(g);
|
|
1684
|
+
var U = D.getState(), V = (K = A, (M = U.plugins) === void 0 && (M = {}), (Oe = g.options) === void 0 && (Oe = {}), Object.keys(K).filter(function(l) {
|
|
1685
|
+
var p = Oe.plugins || {};
|
|
1686
|
+
return Wr(p[l]) ? p[l] : p.all !== !1 && (!M[l] || M[l].enabled !== !1);
|
|
1687
|
+
}).map(function(l) {
|
|
1688
|
+
return K[l];
|
|
1689
|
+
}));
|
|
1690
|
+
L === O.initializeStart && g.fromEnable && (V = Object.keys(U.plugins).filter(function(l) {
|
|
1691
|
+
var p = U.plugins[l];
|
|
1692
|
+
return g.plugins.includes(l) && !p.initialized;
|
|
1693
|
+
}).map(function(l) {
|
|
1694
|
+
return A[l];
|
|
1695
|
+
}));
|
|
1696
|
+
var R = V.map(function(l) {
|
|
1697
|
+
return l.name;
|
|
1698
|
+
}), E = function(l, p, S) {
|
|
1699
|
+
var j = Gt(l).map(function(T) {
|
|
1700
|
+
return Yt(T, p);
|
|
1701
|
+
});
|
|
1702
|
+
return p.reduce(function(T, $) {
|
|
1703
|
+
var W = $.name, N = Gt(l, W).map(function(Pe) {
|
|
1704
|
+
return Yt(Pe, p);
|
|
1705
|
+
}), Z = N[0], z = N[1], B = N[2];
|
|
1706
|
+
return Z.length && (T.beforeNS[W] = Z), z.length && (T.duringNS[W] = z), B.length && (T.afterNS[W] = B), T;
|
|
1707
|
+
}, { before: j[0], beforeNS: {}, during: j[1], duringNS: {}, after: j[2], afterNS: {} });
|
|
1708
|
+
}(L, V);
|
|
1709
|
+
return Promise.resolve(ct({ action: g, data: { exact: E.before, namespaced: E.beforeNS }, state: U, allPlugins: A, allMatches: E, instance: D, store: C, EVENTS: x })).then(function(l) {
|
|
1710
|
+
function p() {
|
|
1711
|
+
var T = function() {
|
|
1712
|
+
if (L.match(ye))
|
|
1713
|
+
return Promise.resolve(ct({ action: P({}, S, { type: X + "End" }), data: { exact: E.after, namespaced: E.afterNS }, state: U, allPlugins: A, allMatches: E, instance: D, store: C, EVENTS: x })).then(function($) {
|
|
1714
|
+
$.meta && $.meta.hasCallback && Vt($.meta.rid, { payload: $ });
|
|
1715
|
+
});
|
|
1716
|
+
}();
|
|
1717
|
+
return T && T.then ? T.then(function() {
|
|
1718
|
+
return l;
|
|
1719
|
+
}) : l;
|
|
1720
|
+
}
|
|
1721
|
+
if (zn(l, R.length))
|
|
1722
|
+
return l;
|
|
1723
|
+
var S, j = function() {
|
|
1724
|
+
if (L !== X)
|
|
1725
|
+
return Promise.resolve(ct({ action: P({}, l, { type: X }), data: { exact: E.during, namespaced: E.duringNS }, state: U, allPlugins: A, allMatches: E, instance: D, store: C, EVENTS: x })).then(function(T) {
|
|
1726
|
+
S = T;
|
|
1727
|
+
});
|
|
1728
|
+
S = l;
|
|
1729
|
+
}();
|
|
1730
|
+
return j && j.then ? j.then(p) : p();
|
|
1731
|
+
});
|
|
1732
|
+
} catch (l) {
|
|
1733
|
+
return Promise.reject(l);
|
|
1734
|
+
}
|
|
1735
|
+
var K, M, Oe;
|
|
1736
|
+
}(a, e, t, i, n)).then(function(g) {
|
|
1737
|
+
return s = 1, o(g);
|
|
1738
|
+
});
|
|
1739
|
+
}();
|
|
1740
|
+
return Promise.resolve(I && I.then ? I.then(f) : f(I));
|
|
1741
|
+
} catch (g) {
|
|
1742
|
+
return Promise.reject(g);
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
};
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
function ai(t) {
|
|
1749
|
+
return function(e) {
|
|
1750
|
+
return function(n) {
|
|
1751
|
+
return function(r) {
|
|
1752
|
+
var i = r.type, o = r.key, a = r.value, s = r.options;
|
|
1753
|
+
if (i === O.setItem || i === O.removeItem) {
|
|
1754
|
+
if (r.abort)
|
|
1755
|
+
return n(r);
|
|
1756
|
+
i === O.setItem ? t.setItem(o, a, s) : t.removeItem(o, s);
|
|
1757
|
+
}
|
|
1758
|
+
return n(r);
|
|
1759
|
+
};
|
|
1760
|
+
};
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
var si = function() {
|
|
1764
|
+
var t = this;
|
|
1765
|
+
this.before = [], this.after = [], this.addMiddleware = function(e, n) {
|
|
1766
|
+
t[n] = t[n].concat(e);
|
|
1767
|
+
}, this.removeMiddleware = function(e, n) {
|
|
1768
|
+
var r = t[n].findIndex(function(i) {
|
|
1769
|
+
return i === e;
|
|
1770
|
+
});
|
|
1771
|
+
r !== -1 && (t[n] = [].concat(t[n].slice(0, r), t[n].slice(r + 1)));
|
|
1772
|
+
}, this.dynamicMiddlewares = function(e) {
|
|
1773
|
+
return function(n) {
|
|
1774
|
+
return function(r) {
|
|
1775
|
+
return function(i) {
|
|
1776
|
+
var o = { getState: n.getState, dispatch: function(s) {
|
|
1777
|
+
return n.dispatch(s);
|
|
1778
|
+
} }, a = t[e].map(function(s) {
|
|
1779
|
+
return s(o);
|
|
1780
|
+
});
|
|
1781
|
+
return Ie.apply(void 0, a)(r)(i);
|
|
1782
|
+
};
|
|
1783
|
+
};
|
|
1784
|
+
};
|
|
1785
|
+
};
|
|
1786
|
+
};
|
|
1787
|
+
function ci(t) {
|
|
1788
|
+
return function(e, n) {
|
|
1789
|
+
e === void 0 && (e = {});
|
|
1790
|
+
var r = {};
|
|
1791
|
+
if (n.type === "initialize:aborted")
|
|
1792
|
+
return e;
|
|
1793
|
+
if (/^registerPlugin:([^:]*)$/.test(n.type)) {
|
|
1794
|
+
var i = Qt(n.type, "registerPlugin"), o = t()[i];
|
|
1795
|
+
if (!o || !i)
|
|
1796
|
+
return e;
|
|
1797
|
+
var a = n.enabled, s = o.config;
|
|
1798
|
+
return r[i] = { enabled: a, initialized: !!a && !o.initialize, loaded: !!a && !!o.loaded({ config: s }), config: s }, P({}, e, r);
|
|
1799
|
+
}
|
|
1800
|
+
if (/^initialize:([^:]*)$/.test(n.type)) {
|
|
1801
|
+
var f = Qt(n.type, O.initialize), m = t()[f];
|
|
1802
|
+
return m && f ? (r[f] = P({}, e[f], { initialized: !0, loaded: !!m.loaded({ config: m.config }) }), P({}, e, r)) : e;
|
|
1803
|
+
}
|
|
1804
|
+
if (/^ready:([^:]*)$/.test(n.type))
|
|
1805
|
+
return r[n.name] = P({}, e[n.name], { loaded: !0 }), P({}, e, r);
|
|
1806
|
+
switch (n.type) {
|
|
1807
|
+
case O.disablePlugin:
|
|
1808
|
+
return P({}, e, en(n.plugins, !1, e));
|
|
1809
|
+
case O.enablePlugin:
|
|
1810
|
+
return P({}, e, en(n.plugins, !0, e));
|
|
1811
|
+
default:
|
|
1812
|
+
return e;
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
function Qt(t, e) {
|
|
1817
|
+
return t.substring(e.length + 1, t.length);
|
|
1818
|
+
}
|
|
1819
|
+
function en(t, e, n) {
|
|
1820
|
+
return t.reduce(function(r, i) {
|
|
1821
|
+
return r[i] = P({}, n[i], { enabled: e }), r;
|
|
1822
|
+
}, n);
|
|
1823
|
+
}
|
|
1824
|
+
function Nn(t) {
|
|
1825
|
+
try {
|
|
1826
|
+
return JSON.parse(JSON.stringify(t));
|
|
1827
|
+
} catch {
|
|
1828
|
+
}
|
|
1829
|
+
return t;
|
|
1830
|
+
}
|
|
1831
|
+
var ui = { last: {}, history: [] };
|
|
1832
|
+
function li(t, e) {
|
|
1833
|
+
t === void 0 && (t = ui);
|
|
1834
|
+
var n = e.options, r = e.meta;
|
|
1835
|
+
if (e.type === O.track) {
|
|
1836
|
+
var i = Nn(P({ event: e.event, properties: e.properties }, Object.keys(n).length && { options: n }, { meta: r }));
|
|
1837
|
+
return P({}, t, { last: i, history: t.history.concat(i) });
|
|
1838
|
+
}
|
|
1839
|
+
return t;
|
|
1840
|
+
}
|
|
1841
|
+
var di = { actions: [] };
|
|
1842
|
+
function hi(t, e) {
|
|
1843
|
+
t === void 0 && (t = di);
|
|
1844
|
+
var n = e.payload;
|
|
1845
|
+
switch (e.type) {
|
|
1846
|
+
case "queue":
|
|
1847
|
+
var r;
|
|
1848
|
+
return r = n && n.type && n.type === O.identify ? [e].concat(t.actions) : t.actions.concat(e), P({}, t, { actions: r });
|
|
1849
|
+
case "dequeue":
|
|
1850
|
+
return [];
|
|
1851
|
+
default:
|
|
1852
|
+
return t;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
var Dn = /#.*$/;
|
|
1856
|
+
function fi(t) {
|
|
1857
|
+
var e = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);
|
|
1858
|
+
return "/" + (e && e[3] ? e[3].split("?")[0].replace(Dn, "") : "");
|
|
1859
|
+
}
|
|
1860
|
+
var Ln, An, Un, Zn, pi = function(t) {
|
|
1861
|
+
if (t === void 0 && (t = {}), !H)
|
|
1862
|
+
return t;
|
|
1863
|
+
var e = document, n = e.title, r = e.referrer, i = window, o = i.location, a = i.innerWidth, s = i.innerHeight, f = o.hash, m = o.search, u = function(d) {
|
|
1864
|
+
var h = function() {
|
|
1865
|
+
if (H) {
|
|
1866
|
+
for (var v, w = document.getElementsByTagName("link"), y = 0; v = w[y]; y++)
|
|
1867
|
+
if (v.getAttribute("rel") === "canonical")
|
|
1868
|
+
return v.getAttribute("href");
|
|
1869
|
+
}
|
|
1870
|
+
}();
|
|
1871
|
+
return h ? h.match(/\?/) ? h : h + d : window.location.href.replace(Dn, "");
|
|
1872
|
+
}(m), c = { title: n, url: u, path: fi(u), hash: f, search: m, width: a, height: s };
|
|
1873
|
+
return r && r !== "" && (c.referrer = r), P({}, c, t);
|
|
1874
|
+
}, mi = { last: {}, history: [] };
|
|
1875
|
+
function gi(t, e) {
|
|
1876
|
+
t === void 0 && (t = mi);
|
|
1877
|
+
var n = e.options;
|
|
1878
|
+
if (e.type === O.page) {
|
|
1879
|
+
var r = Nn(P({ properties: e.properties, meta: e.meta }, Object.keys(n).length && { options: n }));
|
|
1880
|
+
return P({}, t, { last: r, history: t.history.concat(r) });
|
|
1881
|
+
}
|
|
1882
|
+
return t;
|
|
1883
|
+
}
|
|
1884
|
+
Ln = function() {
|
|
1885
|
+
if (!H)
|
|
1886
|
+
return !1;
|
|
1887
|
+
var t = navigator.appVersion;
|
|
1888
|
+
return ~t.indexOf("Win") ? "Windows" : ~t.indexOf("Mac") ? "MacOS" : ~t.indexOf("X11") ? "UNIX" : ~t.indexOf("Linux") ? "Linux" : "Unknown OS";
|
|
1889
|
+
}(), An = H ? document.referrer : null, Un = Hr(), Zn = Yr();
|
|
1890
|
+
var tn = { initialized: !1, sessionId: et(), app: null, version: null, debug: !1, offline: !!H && !navigator.onLine, os: { name: Ln }, userAgent: H ? navigator.userAgent : "node", library: { name: "analytics", version: "0.12.5" }, timezone: Zn, locale: Un, campaign: {}, referrer: An };
|
|
1891
|
+
function vi(t, e) {
|
|
1892
|
+
t === void 0 && (t = tn);
|
|
1893
|
+
var n = t.initialized, r = e.campaign;
|
|
1894
|
+
switch (e.type) {
|
|
1895
|
+
case O.campaign:
|
|
1896
|
+
return P({}, t, { campaign: r });
|
|
1897
|
+
case O.offline:
|
|
1898
|
+
return P({}, t, { offline: !0 });
|
|
1899
|
+
case O.online:
|
|
1900
|
+
return P({}, t, { offline: !1 });
|
|
1901
|
+
default:
|
|
1902
|
+
return n ? t : P({}, tn, t, { initialized: !0 });
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
var yi = ["plugins", "reducers", "storage"];
|
|
1906
|
+
function wi(t, e, n) {
|
|
1907
|
+
if (H) {
|
|
1908
|
+
var r = window[(n ? "add" : "remove") + "EventListener"];
|
|
1909
|
+
t.split(" ").forEach(function(i) {
|
|
1910
|
+
r(i, e);
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
function bi(t) {
|
|
1915
|
+
var e = wi.bind(null, "online offline", function(n) {
|
|
1916
|
+
return Promise.resolve(!navigator.onLine).then(t);
|
|
1917
|
+
});
|
|
1918
|
+
return e(!0), function(n) {
|
|
1919
|
+
return e(!1);
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
function Rn() {
|
|
1923
|
+
return fe("analytics", []), function(t) {
|
|
1924
|
+
return function(e, n, r) {
|
|
1925
|
+
var i = t(e, n, r), o = i.dispatch;
|
|
1926
|
+
return Object.assign(i, { dispatch: function(a) {
|
|
1927
|
+
return ke[be].analytics.push(a.action || a), o(a);
|
|
1928
|
+
} });
|
|
1929
|
+
};
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
function nn(t) {
|
|
1933
|
+
return function() {
|
|
1934
|
+
return Ie(Ie.apply(null, arguments), Rn());
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
function dt(t) {
|
|
1938
|
+
return t ? xn(t) ? t : [t] : [];
|
|
1939
|
+
}
|
|
1940
|
+
function rn(t, e, n) {
|
|
1941
|
+
t === void 0 && (t = {});
|
|
1942
|
+
var r, i, o = et();
|
|
1943
|
+
return e && (je[o] = (r = e, i = function(a) {
|
|
1944
|
+
for (var s, f = a || Array.prototype.slice.call(arguments), m = 0; m < f.length; m++)
|
|
1945
|
+
if (G(f[m])) {
|
|
1946
|
+
s = f[m];
|
|
1947
|
+
break;
|
|
1948
|
+
}
|
|
1949
|
+
return s;
|
|
1950
|
+
}(n), function(a) {
|
|
1951
|
+
i && i(a), r(a);
|
|
1952
|
+
})), P({}, t, { rid: o, ts: (/* @__PURE__ */ new Date()).getTime() }, e ? { hasCallback: !0 } : {});
|
|
1953
|
+
}
|
|
1954
|
+
function ki(t) {
|
|
1955
|
+
t === void 0 && (t = {});
|
|
1956
|
+
var e = t.reducers || {}, n = t.initialUser || {}, r = (t.plugins || []).reduce(function(l, p) {
|
|
1957
|
+
if (G(p))
|
|
1958
|
+
return l.middlewares = l.middlewares.concat(p), l;
|
|
1959
|
+
if (p.NAMESPACE && (p.name = p.NAMESPACE), !p.name)
|
|
1960
|
+
throw new Error("https://lytics.dev/errors/1");
|
|
1961
|
+
p.config || (p.config = {});
|
|
1962
|
+
var S = p.EVENTS ? Object.keys(p.EVENTS).map(function($) {
|
|
1963
|
+
return p.EVENTS[$];
|
|
1964
|
+
}) : [];
|
|
1965
|
+
l.pluginEnabled[p.name] = !(p.enabled === !1 || p.config.enabled === !1), delete p.enabled, p.methods && (l.methods[p.name] = Object.keys(p.methods).reduce(function($, W) {
|
|
1966
|
+
var N;
|
|
1967
|
+
return $[W] = (N = p.methods[W], function() {
|
|
1968
|
+
for (var Z = Array.prototype.slice.call(arguments), z = new Array(N.length), B = 0; B < Z.length; B++)
|
|
1969
|
+
z[B] = Z[B];
|
|
1970
|
+
return z[z.length] = b, N.apply({ instance: b }, z);
|
|
1971
|
+
}), $;
|
|
1972
|
+
}, {}), delete p.methods);
|
|
1973
|
+
var j = Object.keys(p).concat(S), T = new Set(l.events.concat(j));
|
|
1974
|
+
if (l.events = Array.from(T), l.pluginsArray = l.pluginsArray.concat(p), l.plugins[p.name])
|
|
1975
|
+
throw new Error(p.name + "AlreadyLoaded");
|
|
1976
|
+
return l.plugins[p.name] = p, l.plugins[p.name].loaded || (l.plugins[p.name].loaded = function() {
|
|
1977
|
+
return !0;
|
|
1978
|
+
}), l;
|
|
1979
|
+
}, { plugins: {}, pluginEnabled: {}, methods: {}, pluginsArray: [], middlewares: [], events: [] }), i = t.storage ? t.storage : { getItem: he, setItem: fe, removeItem: Se }, o = /* @__PURE__ */ function(l) {
|
|
1980
|
+
return function(p, S, j) {
|
|
1981
|
+
return S.getState("user")[p] || (j && F(j) && j[p] ? j[p] : Xt(l)[p] || he(yt(p)) || null);
|
|
1982
|
+
};
|
|
1983
|
+
}(i), a = r.plugins, s = r.events.filter(function(l) {
|
|
1984
|
+
return !vt.includes(l);
|
|
1985
|
+
}).sort(), f = new Set(s.concat(Fe).filter(function(l) {
|
|
1986
|
+
return !vt.includes(l);
|
|
1987
|
+
})), m = Array.from(f).sort(), u = function() {
|
|
1988
|
+
return a;
|
|
1989
|
+
}, c = new si(), d = c.addMiddleware, h = c.removeMiddleware, v = c.dynamicMiddlewares, w = function() {
|
|
1990
|
+
throw new Error("Abort disabled inListener");
|
|
1991
|
+
}, y = Gr(), k = Xt(i), _ = P({}, k, n, y.an_uid ? { userId: y.an_uid } : {}, y.an_aid ? { anonymousId: y.an_aid } : {});
|
|
1992
|
+
_.anonymousId || (_.anonymousId = et());
|
|
1993
|
+
var I = P({ enable: function(l, p) {
|
|
1994
|
+
return new Promise(function(S) {
|
|
1995
|
+
E.dispatch({ type: O.enablePlugin, plugins: dt(l), _: { originalAction: O.enablePlugin } }, S, [p]);
|
|
1996
|
+
});
|
|
1997
|
+
}, disable: function(l, p) {
|
|
1998
|
+
return new Promise(function(S) {
|
|
1999
|
+
E.dispatch({ type: O.disablePlugin, plugins: dt(l), _: { originalAction: O.disablePlugin } }, S, [p]);
|
|
2000
|
+
});
|
|
2001
|
+
} }, r.methods), g = !1, b = { identify: function(l, p, S, j) {
|
|
2002
|
+
try {
|
|
2003
|
+
var T = re(l) ? l : null, $ = F(l) ? l : p, W = S || {}, N = b.user();
|
|
2004
|
+
fe(yt(te), T);
|
|
2005
|
+
var Z = T || $.userId || o(te, b, $);
|
|
2006
|
+
return Promise.resolve(new Promise(function(z) {
|
|
2007
|
+
E.dispatch(P({ type: O.identifyStart, userId: Z, traits: $ || {}, options: W, anonymousId: N.anonymousId }, N.id && N.id !== T && { previousId: N.id }), z, [p, S, j]);
|
|
2008
|
+
}));
|
|
2009
|
+
} catch (z) {
|
|
2010
|
+
return Promise.reject(z);
|
|
2011
|
+
}
|
|
2012
|
+
}, track: function(l, p, S, j) {
|
|
2013
|
+
try {
|
|
2014
|
+
var T = F(l) ? l.event : l;
|
|
2015
|
+
if (!T || !re(T))
|
|
2016
|
+
throw new Error("EventMissing");
|
|
2017
|
+
var $ = F(l) ? l : p || {}, W = F(S) ? S : {};
|
|
2018
|
+
return Promise.resolve(new Promise(function(N) {
|
|
2019
|
+
E.dispatch({ type: O.trackStart, event: T, properties: $, options: W, userId: o(te, b, p), anonymousId: o(ge, b, p) }, N, [p, S, j]);
|
|
2020
|
+
}));
|
|
2021
|
+
} catch (N) {
|
|
2022
|
+
return Promise.reject(N);
|
|
2023
|
+
}
|
|
2024
|
+
}, page: function(l, p, S) {
|
|
2025
|
+
try {
|
|
2026
|
+
var j = F(l) ? l : {}, T = F(p) ? p : {};
|
|
2027
|
+
return Promise.resolve(new Promise(function($) {
|
|
2028
|
+
E.dispatch({ type: O.pageStart, properties: pi(j), options: T, userId: o(te, b, j), anonymousId: o(ge, b, j) }, $, [l, p, S]);
|
|
2029
|
+
}));
|
|
2030
|
+
} catch ($) {
|
|
2031
|
+
return Promise.reject($);
|
|
2032
|
+
}
|
|
2033
|
+
}, user: function(l) {
|
|
2034
|
+
if (l === te || l === "id")
|
|
2035
|
+
return o(te, b);
|
|
2036
|
+
if (l === ge || l === "anonId")
|
|
2037
|
+
return o(ge, b);
|
|
2038
|
+
var p = b.getState("user");
|
|
2039
|
+
return l ? At(p, l) : p;
|
|
2040
|
+
}, reset: function(l) {
|
|
2041
|
+
return new Promise(function(p) {
|
|
2042
|
+
E.dispatch({ type: O.resetStart }, p, l);
|
|
2043
|
+
});
|
|
2044
|
+
}, ready: function(l) {
|
|
2045
|
+
return g && l({ plugins: I, instance: b }), b.on(O.ready, function(p) {
|
|
2046
|
+
l(p), g = !0;
|
|
2047
|
+
});
|
|
2048
|
+
}, on: function(l, p) {
|
|
2049
|
+
if (!l || !G(p))
|
|
2050
|
+
return !1;
|
|
2051
|
+
if (l === O.bootstrap)
|
|
2052
|
+
throw new Error(".on disabled for " + l);
|
|
2053
|
+
var S = /Start$|Start:/;
|
|
2054
|
+
if (l === "*") {
|
|
2055
|
+
var j = function(N) {
|
|
2056
|
+
return function(Z) {
|
|
2057
|
+
return function(z) {
|
|
2058
|
+
return z.type.match(S) && p({ payload: z, instance: b, plugins: a }), Z(z);
|
|
2059
|
+
};
|
|
2060
|
+
};
|
|
2061
|
+
}, T = function(N) {
|
|
2062
|
+
return function(Z) {
|
|
2063
|
+
return function(z) {
|
|
2064
|
+
return z.type.match(S) || p({ payload: z, instance: b, plugins: a }), Z(z);
|
|
2065
|
+
};
|
|
2066
|
+
};
|
|
2067
|
+
};
|
|
2068
|
+
return d(j, We), d(T, Ke), function() {
|
|
2069
|
+
h(j, We), h(T, Ke);
|
|
2070
|
+
};
|
|
2071
|
+
}
|
|
2072
|
+
var $ = l.match(S) ? We : Ke, W = function(N) {
|
|
2073
|
+
return function(Z) {
|
|
2074
|
+
return function(z) {
|
|
2075
|
+
return z.type === l && p({ payload: z, instance: b, plugins: a, abort: w }), Z(z);
|
|
2076
|
+
};
|
|
2077
|
+
};
|
|
2078
|
+
};
|
|
2079
|
+
return d(W, $), function() {
|
|
2080
|
+
return h(W, $);
|
|
2081
|
+
};
|
|
2082
|
+
}, once: function(l, p) {
|
|
2083
|
+
if (!l || !G(p))
|
|
2084
|
+
return !1;
|
|
2085
|
+
if (l === O.bootstrap)
|
|
2086
|
+
throw new Error(".once disabled for " + l);
|
|
2087
|
+
var S = b.on(l, function(j) {
|
|
2088
|
+
p({ payload: j.payload, instance: b, plugins: a, abort: w }), S();
|
|
2089
|
+
});
|
|
2090
|
+
return S;
|
|
2091
|
+
}, getState: function(l) {
|
|
2092
|
+
var p = E.getState();
|
|
2093
|
+
return l ? At(p, l) : Object.assign({}, p);
|
|
2094
|
+
}, dispatch: function(l) {
|
|
2095
|
+
var p = re(l) ? { type: l } : l;
|
|
2096
|
+
if (Fe.includes(p.type))
|
|
2097
|
+
throw new Error("reserved action " + p.type);
|
|
2098
|
+
var S = P({}, p, { _: P({ originalAction: p.type }, l._ || {}) });
|
|
2099
|
+
E.dispatch(S);
|
|
2100
|
+
}, enablePlugin: I.enable, disablePlugin: I.disable, plugins: I, storage: { getItem: i.getItem, setItem: function(l, p, S) {
|
|
2101
|
+
E.dispatch({ type: O.setItemStart, key: l, value: p, options: S });
|
|
2102
|
+
}, removeItem: function(l, p) {
|
|
2103
|
+
E.dispatch({ type: O.removeItemStart, key: l, options: p });
|
|
2104
|
+
} }, setAnonymousId: function(l, p) {
|
|
2105
|
+
b.storage.setItem(ie, l, p);
|
|
2106
|
+
}, events: { core: Fe, plugins: s } }, D = r.middlewares.concat([function(l) {
|
|
2107
|
+
return function(p) {
|
|
2108
|
+
return function(S) {
|
|
2109
|
+
return S.meta || (S.meta = rn()), p(S);
|
|
2110
|
+
};
|
|
2111
|
+
};
|
|
2112
|
+
}, v(We), oi(b, u, { all: m, plugins: s }), ai(i), ti(b), ri(b), v(Ke)]), C = { context: vi, user: ni(i), page: gi, track: li, plugins: ci(u), queue: hi }, x = Ie, A = Ie;
|
|
2113
|
+
if (H && t.debug) {
|
|
2114
|
+
var L = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
|
2115
|
+
L && (x = L({ trace: !0, traceLimit: 25 })), A = function() {
|
|
2116
|
+
return arguments.length === 0 ? Rn() : F(typeof arguments[0]) ? nn() : nn().apply(null, arguments);
|
|
2117
|
+
};
|
|
2118
|
+
}
|
|
2119
|
+
var X, U = function(l) {
|
|
2120
|
+
return Object.keys(l).reduce(function(p, S) {
|
|
2121
|
+
return yi.includes(S) || (p[S] = l[S]), p;
|
|
2122
|
+
}, {});
|
|
2123
|
+
}(t), V = r.pluginsArray.reduce(function(l, p) {
|
|
2124
|
+
var S = p.name, j = p.config, T = p.loaded, $ = r.pluginEnabled[S];
|
|
2125
|
+
return l[S] = { enabled: $, initialized: !!$ && !p.initialize, loaded: !!T({ config: j }), config: j }, l;
|
|
2126
|
+
}, {}), R = { context: U, user: _, plugins: V }, E = Tn(function(l) {
|
|
2127
|
+
for (var p = Object.keys(l), S = {}, j = 0; j < p.length; j++) {
|
|
2128
|
+
var T = p[j];
|
|
2129
|
+
typeof l[T] === ne && (S[T] = l[T]);
|
|
2130
|
+
}
|
|
2131
|
+
var $, W = Object.keys(S);
|
|
2132
|
+
try {
|
|
2133
|
+
(function(N) {
|
|
2134
|
+
Object.keys(N).forEach(function(Z) {
|
|
2135
|
+
var z = N[Z];
|
|
2136
|
+
if (typeof z(void 0, { type: "@@redux/INIT" }) === ee || typeof z(void 0, { type: qr }) === ee)
|
|
2137
|
+
throw new Error("reducer " + Z + " " + ee);
|
|
2138
|
+
});
|
|
2139
|
+
})(S);
|
|
2140
|
+
} catch (N) {
|
|
2141
|
+
$ = N;
|
|
2142
|
+
}
|
|
2143
|
+
return function(N, Z) {
|
|
2144
|
+
if (N === void 0 && (N = {}), $)
|
|
2145
|
+
throw $;
|
|
2146
|
+
for (var z = !1, B = {}, Pe = 0; Pe < W.length; Pe++) {
|
|
2147
|
+
var Le = W[Pe], xt = N[Le], rt = (0, S[Le])(xt, Z);
|
|
2148
|
+
if (typeof rt === ee) {
|
|
2149
|
+
var er = Qr(Le, Z);
|
|
2150
|
+
throw new Error(er);
|
|
2151
|
+
}
|
|
2152
|
+
B[Le] = rt, z = z || rt !== xt;
|
|
2153
|
+
}
|
|
2154
|
+
return z ? B : N;
|
|
2155
|
+
};
|
|
2156
|
+
}(P({}, C, e)), R, A(x(ei.apply(void 0, D))));
|
|
2157
|
+
E.dispatch = (X = E.dispatch, function(l, p, S) {
|
|
2158
|
+
var j = P({}, l, { meta: rn(l.meta, p, dt(S)) });
|
|
2159
|
+
return X.apply(null, [j]);
|
|
2160
|
+
});
|
|
2161
|
+
var K = Object.keys(a);
|
|
2162
|
+
E.dispatch({ type: O.bootstrap, plugins: K, config: U, params: y, user: _, initialUser: n, persistedUser: k });
|
|
2163
|
+
var M = K.filter(function(l) {
|
|
2164
|
+
return r.pluginEnabled[l];
|
|
2165
|
+
}), Oe = K.filter(function(l) {
|
|
2166
|
+
return !r.pluginEnabled[l];
|
|
2167
|
+
});
|
|
2168
|
+
return E.dispatch({ type: O.registerPlugins, plugins: K, enabled: r.pluginEnabled }), r.pluginsArray.map(function(l, p) {
|
|
2169
|
+
var S = l.bootstrap, j = l.config, T = l.name;
|
|
2170
|
+
S && G(S) && S({ instance: b, config: j, payload: l }), E.dispatch({ type: O.registerPluginType(T), name: T, enabled: r.pluginEnabled[T], plugin: l }), r.pluginsArray.length === p + 1 && E.dispatch({ type: O.initializeStart, plugins: M, disabled: Oe });
|
|
2171
|
+
}), bi(function(l) {
|
|
2172
|
+
E.dispatch({ type: l ? O.offline : O.online });
|
|
2173
|
+
}), function(l, p, S) {
|
|
2174
|
+
setInterval(function() {
|
|
2175
|
+
return $n(l, p, S);
|
|
2176
|
+
}, 3e3);
|
|
2177
|
+
}(E, u, b), b;
|
|
2178
|
+
}
|
|
2179
|
+
var We = "before", Ke = "after", Ce = "cookie", se = Mn(), Wn = tt, Ii = tt;
|
|
2180
|
+
function Kn(t) {
|
|
2181
|
+
return se ? tt(t, "", -1) : Se(t);
|
|
2182
|
+
}
|
|
2183
|
+
function Mn() {
|
|
2184
|
+
if (se !== void 0)
|
|
2185
|
+
return se;
|
|
2186
|
+
var t = "cookiecookie";
|
|
2187
|
+
try {
|
|
2188
|
+
tt(t, t), se = document.cookie.indexOf(t) !== -1, Kn(t);
|
|
2189
|
+
} catch {
|
|
2190
|
+
se = !1;
|
|
2191
|
+
}
|
|
2192
|
+
return se;
|
|
2193
|
+
}
|
|
2194
|
+
function tt(t, e, n, r, i, o) {
|
|
2195
|
+
if (typeof window < "u") {
|
|
2196
|
+
var a = arguments.length > 1;
|
|
2197
|
+
return se === !1 && (a ? fe(t, e) : he(t)), a ? document.cookie = t + "=" + encodeURIComponent(e) + (n ? "; expires=" + new Date(+/* @__PURE__ */ new Date() + 1e3 * n).toUTCString() + (r ? "; path=" + r : "") + (i ? "; domain=" + i : "") + (o ? "; secure" : "") : "") : decodeURIComponent((("; " + document.cookie).split("; " + t + "=")[1] || "").split(";")[0]);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
var $e = "localStorage", Si = It.bind(null, "localStorage");
|
|
2201
|
+
_e("localStorage", "getItem", he);
|
|
2202
|
+
_e("localStorage", "setItem", fe);
|
|
2203
|
+
_e("localStorage", "removeItem", Se);
|
|
2204
|
+
var ze = "sessionStorage", _i = It.bind(null, "sessionStorage");
|
|
2205
|
+
_e("sessionStorage", "getItem", he);
|
|
2206
|
+
_e("sessionStorage", "setItem", fe);
|
|
2207
|
+
_e("sessionStorage", "removeItem", Se);
|
|
2208
|
+
function we(t) {
|
|
2209
|
+
var e = t;
|
|
2210
|
+
try {
|
|
2211
|
+
if ((e = JSON.parse(t)) === "true")
|
|
2212
|
+
return !0;
|
|
2213
|
+
if (e === "false")
|
|
2214
|
+
return !1;
|
|
2215
|
+
if (F(e))
|
|
2216
|
+
return e;
|
|
2217
|
+
parseFloat(e) === e && (e = parseFloat(e));
|
|
2218
|
+
} catch {
|
|
2219
|
+
}
|
|
2220
|
+
if (e !== null && e !== "")
|
|
2221
|
+
return e;
|
|
2222
|
+
}
|
|
2223
|
+
var Oi = Si(), Pi = _i(), Ei = Mn();
|
|
2224
|
+
function Xn(t, e) {
|
|
2225
|
+
if (t) {
|
|
2226
|
+
var n = St(e), r = !Et(n), i = _t(n) ? we(localStorage.getItem(t)) : void 0;
|
|
2227
|
+
if (r && !me(i))
|
|
2228
|
+
return i;
|
|
2229
|
+
var o = Ot(n) ? we(Wn(t)) : void 0;
|
|
2230
|
+
if (r && o)
|
|
2231
|
+
return o;
|
|
2232
|
+
var a = Pt(n) ? we(sessionStorage.getItem(t)) : void 0;
|
|
2233
|
+
if (r && a)
|
|
2234
|
+
return a;
|
|
2235
|
+
var s = he(t);
|
|
2236
|
+
return r ? s : { localStorage: i, sessionStorage: a, cookie: o, global: s };
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
function xi(t, e, n) {
|
|
2240
|
+
if (t && !me(e)) {
|
|
2241
|
+
var r = {}, i = St(n), o = JSON.stringify(e), a = !Et(i);
|
|
2242
|
+
return _t(i) && (r[$e] = Me($e, e, we(localStorage.getItem(t))), localStorage.setItem(t, o), a) ? r[$e] : Ot(i) && (r[Ce] = Me(Ce, e, we(Wn(t))), Ii(t, o), a) ? r[Ce] : Pt(i) && (r[ze] = Me(ze, e, we(sessionStorage.getItem(t))), sessionStorage.setItem(t, o), a) ? r[ze] : (r[Te] = Me(Te, e, he(t)), fe(t, e), a ? r[Te] : r);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
function ji(t, e) {
|
|
2246
|
+
if (t) {
|
|
2247
|
+
var n = St(e), r = Xn(t, On), i = {};
|
|
2248
|
+
return !me(r.localStorage) && _t(n) && (localStorage.removeItem(t), i[$e] = r.localStorage), !me(r.cookie) && Ot(n) && (Kn(t), i[Ce] = r.cookie), !me(r.sessionStorage) && Pt(n) && (sessionStorage.removeItem(t), i[ze] = r.sessionStorage), !me(r.global) && nt(n, Te) && (Se(t), i[Te] = r.global), i;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
function St(t) {
|
|
2252
|
+
return t ? re(t) ? t : t.storage : _n;
|
|
2253
|
+
}
|
|
2254
|
+
function _t(t) {
|
|
2255
|
+
return Oi && nt(t, $e);
|
|
2256
|
+
}
|
|
2257
|
+
function Ot(t) {
|
|
2258
|
+
return Ei && nt(t, Ce);
|
|
2259
|
+
}
|
|
2260
|
+
function Pt(t) {
|
|
2261
|
+
return Pi && nt(t, ze);
|
|
2262
|
+
}
|
|
2263
|
+
function Et(t) {
|
|
2264
|
+
return t === On || t === "all";
|
|
2265
|
+
}
|
|
2266
|
+
function nt(t, e) {
|
|
2267
|
+
return t === _n || t === e || Et(t);
|
|
2268
|
+
}
|
|
2269
|
+
function Me(t, e, n) {
|
|
2270
|
+
return { location: t, current: e, previous: n };
|
|
2271
|
+
}
|
|
2272
|
+
var Ti = { setItem: xi, getItem: Xn, removeItem: ji };
|
|
2273
|
+
function Ci(t, e, n) {
|
|
2274
|
+
return e in t ? Object.defineProperty(t, e, {
|
|
2275
|
+
value: n,
|
|
2276
|
+
enumerable: !0,
|
|
2277
|
+
configurable: !0,
|
|
2278
|
+
writable: !0
|
|
2279
|
+
}) : t[e] = n, t;
|
|
2280
|
+
}
|
|
2281
|
+
function on(t, e) {
|
|
2282
|
+
var n = Object.keys(t);
|
|
2283
|
+
if (Object.getOwnPropertySymbols) {
|
|
2284
|
+
var r = Object.getOwnPropertySymbols(t);
|
|
2285
|
+
e && (r = r.filter(function(i) {
|
|
2286
|
+
return Object.getOwnPropertyDescriptor(t, i).enumerable;
|
|
2287
|
+
})), n.push.apply(n, r);
|
|
2288
|
+
}
|
|
2289
|
+
return n;
|
|
2290
|
+
}
|
|
2291
|
+
function an(t) {
|
|
2292
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
2293
|
+
var n = arguments[e] != null ? arguments[e] : {};
|
|
2294
|
+
e % 2 ? on(Object(n), !0).forEach(function(r) {
|
|
2295
|
+
Ci(t, r, n[r]);
|
|
2296
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : on(Object(n)).forEach(function(r) {
|
|
2297
|
+
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
return t;
|
|
2301
|
+
}
|
|
2302
|
+
function $i() {
|
|
2303
|
+
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = {
|
|
2304
|
+
storage: Ti
|
|
2305
|
+
};
|
|
2306
|
+
return ki(an(an({}, e), t));
|
|
2307
|
+
}
|
|
2308
|
+
function zi(t, e) {
|
|
2309
|
+
e = e || {};
|
|
2310
|
+
var n, r, i = [], o = e.max || 1 / 0;
|
|
2311
|
+
function a() {
|
|
2312
|
+
clearInterval(n), t(i.splice(0, o)), s();
|
|
2313
|
+
}
|
|
2314
|
+
function s() {
|
|
2315
|
+
n = setInterval(a, e.interval || 1e4);
|
|
2316
|
+
}
|
|
2317
|
+
return s(), {
|
|
2318
|
+
flush: a,
|
|
2319
|
+
push: function(f) {
|
|
2320
|
+
return r = i.push(f), r >= o && a(), r;
|
|
2321
|
+
},
|
|
2322
|
+
size: function() {
|
|
2323
|
+
return i.length;
|
|
2324
|
+
},
|
|
2325
|
+
end: function(f) {
|
|
2326
|
+
f && a(), clearInterval(n);
|
|
2327
|
+
}
|
|
2328
|
+
};
|
|
2329
|
+
}
|
|
2330
|
+
const Vn = "@sesamy/sesamy-js", Fn = "1.0.1";
|
|
2331
|
+
function Ni(t) {
|
|
2332
|
+
if (!(typeof window > "u")) {
|
|
2333
|
+
var e = window, n = e.addEventListener, r = e.history, i = e.location, o = i.pathname;
|
|
2334
|
+
n("popstate", function() {
|
|
2335
|
+
return t(i.pathname);
|
|
2336
|
+
}), ["push", "replace"].map(function(a) {
|
|
2337
|
+
var s = "".concat(a, "State"), f = r[s];
|
|
2338
|
+
r[s] = function() {
|
|
2339
|
+
var m = arguments, u = Li(arguments[2]);
|
|
2340
|
+
return o !== u && (o = u, setTimeout(function() {
|
|
2341
|
+
return t(m[2]);
|
|
2342
|
+
}, 0)), f.apply(r, arguments);
|
|
2343
|
+
};
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
function Di(t, e) {
|
|
2348
|
+
var n = t.indexOf(e);
|
|
2349
|
+
return n > -1 ? t.slice(0, n) : t;
|
|
2350
|
+
}
|
|
2351
|
+
function Li(t) {
|
|
2352
|
+
return ["#", "?"].forEach(function(e) {
|
|
2353
|
+
return t = Di(t, e);
|
|
2354
|
+
}), t;
|
|
2355
|
+
}
|
|
2356
|
+
function Ai() {
|
|
2357
|
+
Ni(() => {
|
|
2358
|
+
Je.page();
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
var sn = "EventListener";
|
|
2362
|
+
function Ui(t) {
|
|
2363
|
+
return function(e, n, r, i) {
|
|
2364
|
+
var o = r || Ar, a = i || !1;
|
|
2365
|
+
if (!H)
|
|
2366
|
+
return o;
|
|
2367
|
+
var s = Ge(n), f = Ge(e, !0);
|
|
2368
|
+
if (!f.length)
|
|
2369
|
+
throw new Error("noElements");
|
|
2370
|
+
if (!s.length)
|
|
2371
|
+
throw new Error("noEvent");
|
|
2372
|
+
var m = [];
|
|
2373
|
+
return function u(c) {
|
|
2374
|
+
c && (m = []);
|
|
2375
|
+
for (var d = c ? "add" + sn : "remove" + sn, h = 0; h < f.length; h++) {
|
|
2376
|
+
var v = f[h];
|
|
2377
|
+
m[h] = c ? a && a.once ? Zi(o) : o : m[h] || o;
|
|
2378
|
+
for (var w = 0; w < s.length; w++)
|
|
2379
|
+
v[d] ? v["on" + s[w]] = c ? m[h] : null : v[d](s[w], m[h], a);
|
|
2380
|
+
}
|
|
2381
|
+
return u.bind(null, !c);
|
|
2382
|
+
}(t);
|
|
2383
|
+
};
|
|
2384
|
+
}
|
|
2385
|
+
function Ge(t, e) {
|
|
2386
|
+
if (re(t))
|
|
2387
|
+
return e ? Ge(document.querySelectorAll(t)) : (n = t).split(n.indexOf(",") > -1 ? "," : " ").map(function(a) {
|
|
2388
|
+
return a.trim();
|
|
2389
|
+
});
|
|
2390
|
+
var n;
|
|
2391
|
+
if (NodeList.prototype.isPrototypeOf(t)) {
|
|
2392
|
+
for (var r = [], i = t.length >>> 0; i--; )
|
|
2393
|
+
r[i] = t[i];
|
|
2394
|
+
return r;
|
|
2395
|
+
}
|
|
2396
|
+
var o = Jr(t);
|
|
2397
|
+
return e ? o.map(function(a) {
|
|
2398
|
+
return re(a) ? Ge(a, !0) : a;
|
|
2399
|
+
}).flat() : o;
|
|
2400
|
+
}
|
|
2401
|
+
function Zi(t, e) {
|
|
2402
|
+
var n;
|
|
2403
|
+
return function() {
|
|
2404
|
+
return t && (n = t.apply(e || this, arguments), t = null), n;
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
var ht = Ui("Event");
|
|
2408
|
+
function Jn(t, e) {
|
|
2409
|
+
return H && G(window[t]) ? (n = window[t], r = e, (i = window) === void 0 && (i = null), G(n) ? function() {
|
|
2410
|
+
n.apply(i, arguments), r.apply(i, arguments);
|
|
2411
|
+
} : r) : window[t] = e;
|
|
2412
|
+
var n, r, i;
|
|
2413
|
+
}
|
|
2414
|
+
Jn.bind(null, "onerror");
|
|
2415
|
+
Jn.bind(null, "onload");
|
|
2416
|
+
var Hn = typeof window > "u", cn = "hidden";
|
|
2417
|
+
function Ri(t) {
|
|
2418
|
+
if (Hn)
|
|
2419
|
+
return !1;
|
|
2420
|
+
var e = Wi(), n = "".concat(e.replace(/[H|h]idden/, ""), "visibilitychange"), r = function() {
|
|
2421
|
+
return t(!!document[e]);
|
|
2422
|
+
}, i = function() {
|
|
2423
|
+
return document.addEventListener(n, r);
|
|
2424
|
+
};
|
|
2425
|
+
return i(), function() {
|
|
2426
|
+
return document.removeEventListener(n, r), i;
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
function Wi() {
|
|
2430
|
+
var t = ["webkit", "moz", "ms", "o"];
|
|
2431
|
+
return Hn || cn in document ? cn : t.reduce(function(e, n) {
|
|
2432
|
+
var r = n + "Hidden";
|
|
2433
|
+
return !e && r in document ? r : e;
|
|
2434
|
+
}, null);
|
|
2435
|
+
}
|
|
2436
|
+
var Ki = ["mousemove", "mousedown", "touchmove", "touchstart", "touchend", "keydown"];
|
|
2437
|
+
function Mi(t, e) {
|
|
2438
|
+
e === void 0 && (e = {});
|
|
2439
|
+
var n = /* @__PURE__ */ function(a, s) {
|
|
2440
|
+
var f = this, m = !1;
|
|
2441
|
+
return function(u) {
|
|
2442
|
+
m || (a.call(f, u), m = !0, setTimeout(function() {
|
|
2443
|
+
return m = !1;
|
|
2444
|
+
}, s));
|
|
2445
|
+
};
|
|
2446
|
+
}(t, e.throttle || 1e4), r = [];
|
|
2447
|
+
function i() {
|
|
2448
|
+
var a = Ri(function(s) {
|
|
2449
|
+
s || n({ type: "tabVisible" });
|
|
2450
|
+
});
|
|
2451
|
+
return r = [a].concat(Ki.map(function(s) {
|
|
2452
|
+
return ht(document, s, n);
|
|
2453
|
+
})).concat(ht(window, "load", n)).concat(ht(window, "scroll", n, { capture: !0, passive: !0 })), o;
|
|
2454
|
+
}
|
|
2455
|
+
function o() {
|
|
2456
|
+
r.map(function(a) {
|
|
2457
|
+
return a();
|
|
2458
|
+
});
|
|
2459
|
+
}
|
|
2460
|
+
return i(), function() {
|
|
2461
|
+
return o(), i;
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
function Xi(t) {
|
|
2465
|
+
var e, n, r = t.onIdle, i = t.onWakeUp, o = t.onHeartbeat, a = t.timeout, s = a === void 0 ? 1e4 : a, f = t.throttle, m = f === void 0 ? 2e3 : f, u = !1, c = !1, d = /* @__PURE__ */ new Date(), h = function() {
|
|
2466
|
+
return clearTimeout(e);
|
|
2467
|
+
};
|
|
2468
|
+
function v(y) {
|
|
2469
|
+
h(), o && !u && o(xe(d), y), i && u && (u = !1, i(xe(n), y), d = /* @__PURE__ */ new Date()), e = setTimeout(function() {
|
|
2470
|
+
u = !0, r && (n = /* @__PURE__ */ new Date(), r(xe(d), y));
|
|
2471
|
+
}, s);
|
|
2472
|
+
}
|
|
2473
|
+
var w = Mi(v, { throttle: m });
|
|
2474
|
+
return { disable: function() {
|
|
2475
|
+
c = !0, u = !1, h();
|
|
2476
|
+
var y = w();
|
|
2477
|
+
return function() {
|
|
2478
|
+
return c = !1, d = /* @__PURE__ */ new Date(), v({ type: "load" }), y();
|
|
2479
|
+
};
|
|
2480
|
+
}, getStatus: function() {
|
|
2481
|
+
return { isIdle: u, isDisabled: c, active: u ? 0 : xe(d, c), idle: u ? xe(n, c) : 0 };
|
|
2482
|
+
} };
|
|
2483
|
+
}
|
|
2484
|
+
function xe(t, e) {
|
|
2485
|
+
return e ? 0 : Math.round((/* @__PURE__ */ new Date() - t) / 1e3);
|
|
2486
|
+
}
|
|
2487
|
+
const un = 5e3;
|
|
2488
|
+
class Vi {
|
|
2489
|
+
constructor(e) {
|
|
2490
|
+
Y(this, "element");
|
|
2491
|
+
Y(this, "isInViewport", !1);
|
|
2492
|
+
Y(this, "isAwake", !1);
|
|
2493
|
+
Y(this, "isFlushing");
|
|
2494
|
+
Y(this, "observer");
|
|
2495
|
+
Y(this, "lastEventAt", Date.now());
|
|
2496
|
+
Y(this, "registeredView", !1);
|
|
2497
|
+
Y(this, "viewCallback");
|
|
2498
|
+
Y(this, "activeDurationCallback");
|
|
2499
|
+
Y(this, "idleDurationCallback");
|
|
2500
|
+
this.element = e.element, this.viewCallback = e.viewCallback, this.activeDurationCallback = e.activeDurationCallback, this.idleDurationCallback = e.idleDurationCallback, this.observer = new IntersectionObserver(
|
|
2501
|
+
(n) => {
|
|
2502
|
+
n.forEach((r) => {
|
|
2503
|
+
this.handleInViewPort(r.isIntersecting);
|
|
2504
|
+
});
|
|
2505
|
+
},
|
|
2506
|
+
{
|
|
2507
|
+
threshold: 0
|
|
2508
|
+
}
|
|
2509
|
+
), this.observer.observe(this.element), Xi({
|
|
2510
|
+
onIdle: (n) => this.handleAwake(!1, n),
|
|
2511
|
+
onWakeUp: (n) => this.handleAwake(!0, n),
|
|
2512
|
+
timeout: un
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* Flush the awake timer in case the page is unloading
|
|
2517
|
+
*/
|
|
2518
|
+
flush() {
|
|
2519
|
+
this.isFlushing = !0, this.handleAwake(
|
|
2520
|
+
!this.isAwake,
|
|
2521
|
+
Math.round((Date.now() - this.lastEventAt) / 1e3)
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
handleInViewPort(e) {
|
|
2525
|
+
e ? (this.isAwake = !0, this.trackInViewport()) : this.handleAwake(
|
|
2526
|
+
!1,
|
|
2527
|
+
Math.round((Date.now() - this.lastEventAt) / 1e3)
|
|
2528
|
+
), this.isInViewport = e;
|
|
2529
|
+
}
|
|
2530
|
+
handleAwake(e, n) {
|
|
2531
|
+
this.isAwake = e, this.lastEventAt = e ? Date.now() - n * un : Date.now(), this.isInViewport && this.trackAwake(e, n);
|
|
2532
|
+
}
|
|
2533
|
+
trackAwake(e, n) {
|
|
2534
|
+
!e && this.activeDurationCallback && this.activeDurationCallback(n, this.isFlushing), e && this.idleDurationCallback && this.idleDurationCallback(n, this.isFlushing);
|
|
2535
|
+
}
|
|
2536
|
+
trackInViewport() {
|
|
2537
|
+
this.registeredView || (this.registeredView = !0, this.viewCallback && this.viewCallback());
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
let Yn = !1, Gn, ln, Be;
|
|
2541
|
+
function Fi({
|
|
2542
|
+
clientId: t,
|
|
2543
|
+
enabled: e = !0,
|
|
2544
|
+
endpoint: n = Tr
|
|
2545
|
+
}) {
|
|
2546
|
+
if (Gn = t, ln = e, Be = n, !ln)
|
|
2547
|
+
return;
|
|
2548
|
+
Ai();
|
|
2549
|
+
const r = new Vi({
|
|
2550
|
+
element: document.body,
|
|
2551
|
+
viewCallback: () => {
|
|
2552
|
+
Je.page();
|
|
2553
|
+
},
|
|
2554
|
+
activeDurationCallback: (i, o) => {
|
|
2555
|
+
Je.track("activeDuration", {
|
|
2556
|
+
duration: i,
|
|
2557
|
+
flushing: o
|
|
2558
|
+
});
|
|
2559
|
+
},
|
|
2560
|
+
idleDurationCallback: (i, o) => {
|
|
2561
|
+
Je.track("idleDuration", {
|
|
2562
|
+
duration: i,
|
|
2563
|
+
flushing: o
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
});
|
|
2567
|
+
Hi(document.body, () => {
|
|
2568
|
+
r.flush();
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
function Bn(t) {
|
|
2572
|
+
return JSON.stringify(
|
|
2573
|
+
t.map((e) => ({
|
|
2574
|
+
...e,
|
|
2575
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2576
|
+
originalTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2577
|
+
version: Fn,
|
|
2578
|
+
event: e.event || "page",
|
|
2579
|
+
context: {
|
|
2580
|
+
page: {
|
|
2581
|
+
url: window.location.hostname,
|
|
2582
|
+
path: window.location.pathname,
|
|
2583
|
+
title: document.title,
|
|
2584
|
+
search: window.location.search,
|
|
2585
|
+
referrer: document.referrer
|
|
2586
|
+
},
|
|
2587
|
+
locale: navigator.language,
|
|
2588
|
+
library: Vn,
|
|
2589
|
+
userAgent: navigator.userAgent,
|
|
2590
|
+
clientId: Gn
|
|
2591
|
+
}
|
|
2592
|
+
}))
|
|
2593
|
+
);
|
|
2594
|
+
}
|
|
2595
|
+
const qn = zi(
|
|
2596
|
+
async (t) => {
|
|
2597
|
+
if (t.length > 0) {
|
|
2598
|
+
const e = Bn(t);
|
|
2599
|
+
Yn ? navigator.sendBeacon(Be, e) : (await fetch(Be, {
|
|
2600
|
+
method: "POST",
|
|
2601
|
+
body: e,
|
|
2602
|
+
headers: {
|
|
2603
|
+
"Content-Type": "text/plain"
|
|
2604
|
+
}
|
|
2605
|
+
})).ok;
|
|
2606
|
+
}
|
|
2607
|
+
},
|
|
2608
|
+
{
|
|
2609
|
+
max: 10,
|
|
2610
|
+
// limit
|
|
2611
|
+
interval: 3e3
|
|
2612
|
+
// 3s
|
|
2613
|
+
}
|
|
2614
|
+
);
|
|
2615
|
+
function dn(t) {
|
|
2616
|
+
if (t.properties.flushing) {
|
|
2617
|
+
const e = { ...t };
|
|
2618
|
+
delete e.properties.flushing, navigator.sendBeacon(Be, Bn([e]));
|
|
2619
|
+
} else
|
|
2620
|
+
qn.push(t);
|
|
2621
|
+
}
|
|
2622
|
+
const Je = $i({
|
|
2623
|
+
app: Vn,
|
|
2624
|
+
version: Fn,
|
|
2625
|
+
plugins: [
|
|
2626
|
+
{
|
|
2627
|
+
name: "custom-analytics-plugin",
|
|
2628
|
+
page: ({ payload: t }) => {
|
|
2629
|
+
const { properties: e, anonymousId: n, userId: r, event: i } = t;
|
|
2630
|
+
dn({
|
|
2631
|
+
anonymousId: n,
|
|
2632
|
+
userId: r,
|
|
2633
|
+
properties: e,
|
|
2634
|
+
event: i,
|
|
2635
|
+
type: "page"
|
|
2636
|
+
});
|
|
2637
|
+
},
|
|
2638
|
+
track: ({ payload: t }) => {
|
|
2639
|
+
const { properties: e, anonymousId: n, userId: r, event: i } = t;
|
|
2640
|
+
dn({
|
|
2641
|
+
anonymousId: n,
|
|
2642
|
+
userId: r,
|
|
2643
|
+
properties: e,
|
|
2644
|
+
event: i,
|
|
2645
|
+
type: "track"
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
]
|
|
2650
|
+
});
|
|
2651
|
+
function Ji() {
|
|
2652
|
+
return Yn = !0, qn.flush();
|
|
2653
|
+
}
|
|
2654
|
+
const Qn = /* @__PURE__ */ new Map();
|
|
2655
|
+
function Hi(t, e) {
|
|
2656
|
+
Qn.set(t, e);
|
|
2657
|
+
}
|
|
2658
|
+
window.addEventListener("beforeunload", () => {
|
|
2659
|
+
Qn.forEach((t, e) => {
|
|
2660
|
+
t.bind(e)();
|
|
2661
|
+
}), Ji();
|
|
2662
|
+
});
|
|
2663
|
+
async function Yi(t) {
|
|
2664
|
+
await Cr(t), Fi({
|
|
2665
|
+
clientId: t.clientId,
|
|
2666
|
+
// The default client id can be overridden by the config
|
|
2667
|
+
...t.analytics
|
|
2668
|
+
}), Lr(t.namespace), rr();
|
|
2669
|
+
}
|
|
2670
|
+
const Xe = document.getElementById("sesamy-js");
|
|
2671
|
+
if (Xe != null && Xe.textContent)
|
|
2672
|
+
try {
|
|
2673
|
+
const t = JSON.parse(Xe.textContent);
|
|
2674
|
+
Yi(t);
|
|
2675
|
+
} catch (t) {
|
|
2676
|
+
console.error("Failed to parse config", t);
|
|
2677
|
+
}
|
|
2678
|
+
const Gi = "/sesamy.png";
|
|
2679
|
+
class Bi extends HTMLElement {
|
|
2680
|
+
constructor() {
|
|
2681
|
+
super();
|
|
2682
|
+
Y(this, "user");
|
|
2683
|
+
}
|
|
2684
|
+
async _handleProfile() {
|
|
2685
|
+
this.user = await window.sesamy.getUser(), this.render();
|
|
2686
|
+
}
|
|
2687
|
+
async connectedCallback() {
|
|
2688
|
+
if (this.setupEventListeners(), !window.sesamy) {
|
|
2689
|
+
window.addEventListener(wt.READY, () => this._handleProfile());
|
|
2690
|
+
return;
|
|
2691
|
+
}
|
|
2692
|
+
this._handleProfile();
|
|
2693
|
+
}
|
|
2694
|
+
render() {
|
|
2695
|
+
this.innerHTML = `
|
|
2696
|
+
<div>
|
|
2697
|
+
<a href="https://docs.sesamy.com" target="_blank">
|
|
2698
|
+
<img src="${Gi}" class="logo" alt="Vite logo" />
|
|
2699
|
+
</a>
|
|
2700
|
+
<h1>Sesamy JS</h1>
|
|
2701
|
+
<p class="read-the-docs">
|
|
2702
|
+
Click on the Sesamy logo to learn more
|
|
2703
|
+
</p>
|
|
2704
|
+
${this.user ? this.renderUserProfile() : this.renderLoginButton()}
|
|
2705
|
+
</div>
|
|
2706
|
+
`;
|
|
2707
|
+
}
|
|
2708
|
+
renderLoginButton() {
|
|
2709
|
+
return '<button part="login-btn" class="login auth-visible" id="login-btn"> Login </button>';
|
|
2710
|
+
}
|
|
2711
|
+
renderUserProfile() {
|
|
2712
|
+
var n, r;
|
|
2713
|
+
return `<div class="user" part="user">
|
|
2714
|
+
<a href="/profile" part="user-link">
|
|
2715
|
+
${(n = this.user) != null && n.picture ? ` <img
|
|
2716
|
+
class="big"
|
|
2717
|
+
part="user-img img-big"
|
|
2718
|
+
src=${this.user.picture}
|
|
2719
|
+
alt=${this.user.name || "User avatar"}
|
|
2720
|
+
/>` : '<div part="avatar avatar-big" class="avatar big"> Placeholder </div>'}
|
|
2721
|
+
<h2 class="user-name">${((r = this.user) == null ? void 0 : r.name) || "User Name"}</h2>
|
|
2722
|
+
</a>
|
|
2723
|
+
|
|
2724
|
+
<div class="logout-wrap">
|
|
2725
|
+
<a href="#" class="logout-btn" id="logout-btn"> Logout </a>
|
|
2726
|
+
</div>
|
|
2727
|
+
</div>`;
|
|
2728
|
+
}
|
|
2729
|
+
setupEventListeners() {
|
|
2730
|
+
this.addEventListener("click", (n) => {
|
|
2731
|
+
const r = n.target, i = r.closest("#logout-btn"), o = r.closest("#login-btn");
|
|
2732
|
+
i && window.sesamy.logout(), o && window.sesamy.loginWithRedirect();
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
customElements.define("sesamy-app", Bi);
|