@wandelbots/wandelbots-js-react-components 3.5.1-pr.feat-add-eight-abbs-v2.450.4419c66 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +61 -10
  2. package/dist/3d.cjs.js +2 -0
  3. package/dist/3d.cjs.js.map +1 -0
  4. package/dist/3d.d.ts +11 -0
  5. package/dist/3d.d.ts.map +1 -0
  6. package/dist/3d.es.js +16 -0
  7. package/dist/3d.es.js.map +1 -0
  8. package/dist/LoadingCover-Dr9hDTku.js +87 -0
  9. package/dist/LoadingCover-Dr9hDTku.js.map +1 -0
  10. package/dist/LoadingCover-r2yhJZF9.cjs +2 -0
  11. package/dist/LoadingCover-r2yhJZF9.cjs.map +1 -0
  12. package/dist/WandelscriptEditor-Dj7TBCkF.cjs +2 -0
  13. package/dist/WandelscriptEditor-Dj7TBCkF.cjs.map +1 -0
  14. package/dist/WandelscriptEditor-DnJvITTA.js +140 -0
  15. package/dist/WandelscriptEditor-DnJvITTA.js.map +1 -0
  16. package/dist/auth0-spa-js.production.esm-DL9f1uDJ.js +1438 -0
  17. package/dist/auth0-spa-js.production.esm-DL9f1uDJ.js.map +1 -0
  18. package/dist/auth0-spa-js.production.esm-DTiWXa87.cjs +5 -0
  19. package/dist/auth0-spa-js.production.esm-DTiWXa87.cjs.map +1 -0
  20. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +1 -1
  21. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts.map +1 -1
  22. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
  23. package/dist/components/3d-viewport/collider/ColliderCollection.d.ts +1 -1
  24. package/dist/components/3d-viewport/collider/ColliderCollection.d.ts.map +1 -1
  25. package/dist/components/3d-viewport/collider/ColliderElement.d.ts +1 -1
  26. package/dist/components/3d-viewport/collider/ColliderElement.d.ts.map +1 -1
  27. package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts +1 -1
  28. package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts.map +1 -1
  29. package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts +1 -1
  30. package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts.map +1 -1
  31. package/dist/components/ProgramStateIndicator.d.ts +3 -3
  32. package/dist/components/ProgramStateIndicator.d.ts.map +1 -1
  33. package/dist/components/RobotCard.d.ts +4 -3
  34. package/dist/components/RobotCard.d.ts.map +1 -1
  35. package/dist/components/jogging/JoggingBlocked.d.ts +7 -0
  36. package/dist/components/jogging/JoggingBlocked.d.ts.map +1 -0
  37. package/dist/components/jogging/JoggingCartesianTab.d.ts.map +1 -1
  38. package/dist/components/jogging/JoggingOptions.d.ts.map +1 -1
  39. package/dist/components/jogging/JoggingPanel.d.ts +1 -1
  40. package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
  41. package/dist/components/jogging/JoggingStore.d.ts +10 -5
  42. package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
  43. package/dist/components/jogging/PoseCartesianValues.d.ts +2 -2
  44. package/dist/components/jogging/PoseCartesianValues.d.ts.map +1 -1
  45. package/dist/components/jogging/PoseJointValues.d.ts +1 -2
  46. package/dist/components/jogging/PoseJointValues.d.ts.map +1 -1
  47. package/dist/components/robots/DHRobot.d.ts.map +1 -1
  48. package/dist/components/robots/Robot.d.ts +1 -1
  49. package/dist/components/robots/Robot.d.ts.map +1 -1
  50. package/dist/components/robots/RobotAnimator.d.ts +2 -2
  51. package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
  52. package/dist/components/robots/SupportedRobot.d.ts +3 -3
  53. package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
  54. package/dist/components/robots/manufacturerHomePositions.d.ts +1 -1
  55. package/dist/components/robots/manufacturerHomePositions.d.ts.map +1 -1
  56. package/dist/components/safetyBar/ControllerTypeIndicator.d.ts.map +1 -1
  57. package/dist/components/safetyBar/OperationModeIndicator.d.ts +2 -2
  58. package/dist/components/safetyBar/OperationModeIndicator.d.ts.map +1 -1
  59. package/dist/components/safetyBar/SafetyBar.d.ts +3 -3
  60. package/dist/components/safetyBar/SafetyBar.d.ts.map +1 -1
  61. package/dist/components/safetyBar/SafetyStateIndicator.d.ts +2 -2
  62. package/dist/components/safetyBar/SafetyStateIndicator.d.ts.map +1 -1
  63. package/dist/components/utils/errorHandling.d.ts.map +1 -1
  64. package/dist/components/utils/errorHandling.test.d.ts +2 -0
  65. package/dist/components/utils/errorHandling.test.d.ts.map +1 -0
  66. package/dist/core.cjs.js +2 -0
  67. package/dist/core.cjs.js.map +1 -0
  68. package/dist/core.d.ts +33 -0
  69. package/dist/core.d.ts.map +1 -0
  70. package/dist/core.es.js +54 -0
  71. package/dist/core.es.js.map +1 -0
  72. package/dist/index-CAib4NKw.js +2261 -0
  73. package/dist/index-CAib4NKw.js.map +1 -0
  74. package/dist/index-CqMZL0FV.cjs +2 -0
  75. package/dist/index-CqMZL0FV.cjs.map +1 -0
  76. package/dist/index-CxasuX80.js +5212 -0
  77. package/dist/index-CxasuX80.js.map +1 -0
  78. package/dist/index-DxwppshT.cjs +29 -0
  79. package/dist/index-DxwppshT.cjs.map +1 -0
  80. package/dist/index.cjs.js +2 -0
  81. package/dist/index.cjs.js.map +1 -0
  82. package/dist/index.d.ts +3 -39
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.es.js +69 -0
  85. package/dist/index.es.js.map +1 -0
  86. package/dist/lib/ConnectedMotionGroup.d.ts +90 -0
  87. package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -0
  88. package/dist/lib/JoggerConnection.d.ts +113 -0
  89. package/dist/lib/JoggerConnection.d.ts.map +1 -0
  90. package/dist/lib/JoggerConnection.test.d.ts +2 -0
  91. package/dist/lib/JoggerConnection.test.d.ts.map +1 -0
  92. package/dist/lib/MotionStreamConnection.d.ts +24 -0
  93. package/dist/lib/MotionStreamConnection.d.ts.map +1 -0
  94. package/dist/lib/MotionStreamConnection.test.d.ts +2 -0
  95. package/dist/lib/MotionStreamConnection.test.d.ts.map +1 -0
  96. package/dist/lib/motionStateUpdate.d.ts +7 -0
  97. package/dist/lib/motionStateUpdate.d.ts.map +1 -0
  98. package/dist/lib/motionStateUpdate.test.d.ts +2 -0
  99. package/dist/lib/motionStateUpdate.test.d.ts.map +1 -0
  100. package/dist/manufacturerHomePositions-Ca80ycLi.cjs +2 -0
  101. package/dist/manufacturerHomePositions-Ca80ycLi.cjs.map +1 -0
  102. package/dist/manufacturerHomePositions-CgaG5vaK.js +976 -0
  103. package/dist/manufacturerHomePositions-CgaG5vaK.js.map +1 -0
  104. package/dist/theming-Coh4zx7d.js +23682 -0
  105. package/dist/theming-Coh4zx7d.js.map +1 -0
  106. package/dist/theming-D4ztsmTr.cjs +133 -0
  107. package/dist/theming-D4ztsmTr.cjs.map +1 -0
  108. package/dist/wandelscript.cjs.js +2 -0
  109. package/dist/wandelscript.cjs.js.map +1 -0
  110. package/dist/wandelscript.d.ts +2 -0
  111. package/dist/wandelscript.d.ts.map +1 -0
  112. package/dist/wandelscript.es.js +5 -0
  113. package/dist/wandelscript.es.js.map +1 -0
  114. package/package.json +56 -28
  115. package/src/3d.ts +15 -0
  116. package/src/components/3d-viewport/CoordinateSystemTransform.tsx +1 -1
  117. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +1 -2
  118. package/src/components/3d-viewport/collider/ColliderCollection.tsx +1 -1
  119. package/src/components/3d-viewport/collider/ColliderElement.tsx +1 -1
  120. package/src/components/3d-viewport/collider/CollisionSceneRenderer.tsx +1 -1
  121. package/src/components/3d-viewport/collider/colliderShapeToBufferGeometry.ts +1 -1
  122. package/src/components/AppHeader.md +1 -1
  123. package/src/components/ProgramStateIndicator.tsx +3 -6
  124. package/src/components/RobotCard.tsx +4 -7
  125. package/src/components/jogging/JoggingBlocked.tsx +37 -0
  126. package/src/components/jogging/JoggingCartesianTab.tsx +13 -11
  127. package/src/components/jogging/JoggingJointLimitDetector.tsx +2 -2
  128. package/src/components/jogging/JoggingJointTab.tsx +4 -4
  129. package/src/components/jogging/JoggingOptions.tsx +6 -5
  130. package/src/components/jogging/JoggingPanel.tsx +6 -3
  131. package/src/components/jogging/JoggingStore.ts +66 -39
  132. package/src/components/jogging/PoseCartesianValues.tsx +3 -4
  133. package/src/components/jogging/PoseJointValues.tsx +3 -4
  134. package/src/components/robots/DHRobot.tsx +2 -3
  135. package/src/components/robots/Robot.tsx +1 -1
  136. package/src/components/robots/RobotAnimator.test.tsx +7 -22
  137. package/src/components/robots/RobotAnimator.tsx +8 -13
  138. package/src/components/robots/SupportedRobot.tsx +3 -6
  139. package/src/components/robots/manufacturerHomePositions.ts +1 -1
  140. package/src/components/safetyBar/ControllerTypeIndicator.tsx +4 -2
  141. package/src/components/safetyBar/OperationModeIndicator.tsx +7 -5
  142. package/src/components/safetyBar/SafetyBar.tsx +3 -6
  143. package/src/components/safetyBar/SafetyStateIndicator.tsx +9 -7
  144. package/src/components/utils/errorHandling.test.ts +41 -0
  145. package/src/components/utils/errorHandling.ts +4 -0
  146. package/src/core.ts +33 -0
  147. package/src/i18n/locales/de/translations.json +3 -0
  148. package/src/i18n/locales/en/translations.json +3 -0
  149. package/src/index.ts +4 -43
  150. package/src/lib/ConnectedMotionGroup.ts +444 -0
  151. package/src/lib/JoggerConnection.test.ts +120 -0
  152. package/src/lib/JoggerConnection.ts +674 -0
  153. package/src/lib/MotionStreamConnection.test.ts +23 -0
  154. package/src/lib/MotionStreamConnection.ts +189 -0
  155. package/src/lib/motionStateUpdate.test.ts +28 -0
  156. package/src/lib/motionStateUpdate.ts +117 -0
  157. package/src/wandelscript.ts +2 -0
  158. package/dist/auth0-spa-js.production.esm-1QXzndwB.js +0 -950
  159. package/dist/auth0-spa-js.production.esm-1QXzndwB.js.map +0 -1
  160. package/dist/auth0-spa-js.production.esm-BLRAk7Yh.cjs +0 -5
  161. package/dist/auth0-spa-js.production.esm-BLRAk7Yh.cjs.map +0 -1
  162. package/dist/index.cjs +0 -155
  163. package/dist/index.cjs.map +0 -1
  164. package/dist/index.js +0 -34927
  165. package/dist/index.js.map +0 -1
@@ -0,0 +1,1438 @@
1
+ function I(i, e) {
2
+ var t = {};
3
+ for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
4
+ if (i != null && typeof Object.getOwnPropertySymbols == "function") {
5
+ var o = 0;
6
+ for (n = Object.getOwnPropertySymbols(i); o < n.length; o++) e.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(i, n[o]) && (t[n[o]] = i[n[o]]);
7
+ }
8
+ return t;
9
+ }
10
+ var C = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
11
+ function Q(i) {
12
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
13
+ }
14
+ function ee(i, e) {
15
+ return i(e = { exports: {} }, e.exports), e.exports;
16
+ }
17
+ var O = ee((function(i, e) {
18
+ Object.defineProperty(e, "__esModule", { value: !0 });
19
+ var t = (function() {
20
+ function n() {
21
+ var o = this;
22
+ this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(r, a) {
23
+ var l = o.locked.get(r);
24
+ l === void 0 ? a === void 0 ? o.locked.set(r, []) : o.locked.set(r, [a]) : a !== void 0 && (l.unshift(a), o.locked.set(r, l));
25
+ }, this.isLocked = function(r) {
26
+ return o.locked.has(r);
27
+ }, this.lock = function(r) {
28
+ return new Promise((function(a, l) {
29
+ o.isLocked(r) ? o.addToLocked(r, a) : (o.addToLocked(r), a());
30
+ }));
31
+ }, this.unlock = function(r) {
32
+ var a = o.locked.get(r);
33
+ if (a !== void 0 && a.length !== 0) {
34
+ var l = a.pop();
35
+ o.locked.set(r, a), l !== void 0 && setTimeout(l, 0);
36
+ } else o.locked.delete(r);
37
+ };
38
+ }
39
+ return n.getInstance = function() {
40
+ return n.instance === void 0 && (n.instance = new n()), n.instance;
41
+ }, n;
42
+ })();
43
+ e.default = function() {
44
+ return t.getInstance();
45
+ };
46
+ }));
47
+ Q(O);
48
+ var xe = Q(ee((function(i, e) {
49
+ var t = C && C.__awaiter || function(s, c, h, d) {
50
+ return new (h || (h = Promise))((function(m, y) {
51
+ function f(w) {
52
+ try {
53
+ b(d.next(w));
54
+ } catch (g) {
55
+ y(g);
56
+ }
57
+ }
58
+ function k(w) {
59
+ try {
60
+ b(d.throw(w));
61
+ } catch (g) {
62
+ y(g);
63
+ }
64
+ }
65
+ function b(w) {
66
+ w.done ? m(w.value) : new h((function(g) {
67
+ g(w.value);
68
+ })).then(f, k);
69
+ }
70
+ b((d = d.apply(s, c || [])).next());
71
+ }));
72
+ }, n = C && C.__generator || function(s, c) {
73
+ var h, d, m, y, f = { label: 0, sent: function() {
74
+ if (1 & m[0]) throw m[1];
75
+ return m[1];
76
+ }, trys: [], ops: [] };
77
+ return y = { next: k(0), throw: k(1), return: k(2) }, typeof Symbol == "function" && (y[Symbol.iterator] = function() {
78
+ return this;
79
+ }), y;
80
+ function k(b) {
81
+ return function(w) {
82
+ return (function(g) {
83
+ if (h) throw new TypeError("Generator is already executing.");
84
+ for (; f; ) try {
85
+ if (h = 1, d && (m = 2 & g[0] ? d.return : g[0] ? d.throw || ((m = d.return) && m.call(d), 0) : d.next) && !(m = m.call(d, g[1])).done) return m;
86
+ switch (d = 0, m && (g = [2 & g[0], m.value]), g[0]) {
87
+ case 0:
88
+ case 1:
89
+ m = g;
90
+ break;
91
+ case 4:
92
+ return f.label++, { value: g[1], done: !1 };
93
+ case 5:
94
+ f.label++, d = g[1], g = [0];
95
+ continue;
96
+ case 7:
97
+ g = f.ops.pop(), f.trys.pop();
98
+ continue;
99
+ default:
100
+ if (m = f.trys, !((m = m.length > 0 && m[m.length - 1]) || g[0] !== 6 && g[0] !== 2)) {
101
+ f = 0;
102
+ continue;
103
+ }
104
+ if (g[0] === 3 && (!m || g[1] > m[0] && g[1] < m[3])) {
105
+ f.label = g[1];
106
+ break;
107
+ }
108
+ if (g[0] === 6 && f.label < m[1]) {
109
+ f.label = m[1], m = g;
110
+ break;
111
+ }
112
+ if (m && f.label < m[2]) {
113
+ f.label = m[2], f.ops.push(g);
114
+ break;
115
+ }
116
+ m[2] && f.ops.pop(), f.trys.pop();
117
+ continue;
118
+ }
119
+ g = c.call(s, f);
120
+ } catch (_) {
121
+ g = [6, _], d = 0;
122
+ } finally {
123
+ h = m = 0;
124
+ }
125
+ if (5 & g[0]) throw g[1];
126
+ return { value: g[0] ? g[1] : void 0, done: !0 };
127
+ })([b, w]);
128
+ };
129
+ }
130
+ }, o = C;
131
+ Object.defineProperty(e, "__esModule", { value: !0 });
132
+ var r = "browser-tabs-lock-key", a = { key: function(s) {
133
+ return t(o, void 0, void 0, (function() {
134
+ return n(this, (function(c) {
135
+ throw new Error("Unsupported");
136
+ }));
137
+ }));
138
+ }, getItem: function(s) {
139
+ return t(o, void 0, void 0, (function() {
140
+ return n(this, (function(c) {
141
+ throw new Error("Unsupported");
142
+ }));
143
+ }));
144
+ }, clear: function() {
145
+ return t(o, void 0, void 0, (function() {
146
+ return n(this, (function(s) {
147
+ return [2, window.localStorage.clear()];
148
+ }));
149
+ }));
150
+ }, removeItem: function(s) {
151
+ return t(o, void 0, void 0, (function() {
152
+ return n(this, (function(c) {
153
+ throw new Error("Unsupported");
154
+ }));
155
+ }));
156
+ }, setItem: function(s, c) {
157
+ return t(o, void 0, void 0, (function() {
158
+ return n(this, (function(h) {
159
+ throw new Error("Unsupported");
160
+ }));
161
+ }));
162
+ }, keySync: function(s) {
163
+ return window.localStorage.key(s);
164
+ }, getItemSync: function(s) {
165
+ return window.localStorage.getItem(s);
166
+ }, clearSync: function() {
167
+ return window.localStorage.clear();
168
+ }, removeItemSync: function(s) {
169
+ return window.localStorage.removeItem(s);
170
+ }, setItemSync: function(s, c) {
171
+ return window.localStorage.setItem(s, c);
172
+ } };
173
+ function l(s) {
174
+ return new Promise((function(c) {
175
+ return setTimeout(c, s);
176
+ }));
177
+ }
178
+ function u(s) {
179
+ for (var c = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", h = "", d = 0; d < s; d++)
180
+ h += c[Math.floor(Math.random() * c.length)];
181
+ return h;
182
+ }
183
+ var p = (function() {
184
+ function s(c) {
185
+ this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + u(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, s.waiters === void 0 && (s.waiters = []);
186
+ }
187
+ return s.prototype.acquireLock = function(c, h) {
188
+ return h === void 0 && (h = 5e3), t(this, void 0, void 0, (function() {
189
+ var d, m, y, f, k, b, w;
190
+ return n(this, (function(g) {
191
+ switch (g.label) {
192
+ case 0:
193
+ d = Date.now() + u(4), m = Date.now() + h, y = r + "-" + c, f = this.storageHandler === void 0 ? a : this.storageHandler, g.label = 1;
194
+ case 1:
195
+ return Date.now() < m ? [4, l(30)] : [3, 8];
196
+ case 2:
197
+ return g.sent(), f.getItemSync(y) !== null ? [3, 5] : (k = this.id + "-" + c + "-" + d, [4, l(Math.floor(25 * Math.random()))]);
198
+ case 3:
199
+ return g.sent(), f.setItemSync(y, JSON.stringify({ id: this.id, iat: d, timeoutKey: k, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, l(30)];
200
+ case 4:
201
+ return g.sent(), (b = f.getItemSync(y)) !== null && (w = JSON.parse(b)).id === this.id && w.iat === d ? (this.acquiredIatSet.add(d), this.refreshLockWhileAcquired(y, d), [2, !0]) : [3, 7];
202
+ case 5:
203
+ return s.lockCorrector(this.storageHandler === void 0 ? a : this.storageHandler), [4, this.waitForSomethingToChange(m)];
204
+ case 6:
205
+ g.sent(), g.label = 7;
206
+ case 7:
207
+ return d = Date.now() + u(4), [3, 1];
208
+ case 8:
209
+ return [2, !1];
210
+ }
211
+ }));
212
+ }));
213
+ }, s.prototype.refreshLockWhileAcquired = function(c, h) {
214
+ return t(this, void 0, void 0, (function() {
215
+ var d = this;
216
+ return n(this, (function(m) {
217
+ return setTimeout((function() {
218
+ return t(d, void 0, void 0, (function() {
219
+ var y, f, k;
220
+ return n(this, (function(b) {
221
+ switch (b.label) {
222
+ case 0:
223
+ return [4, O.default().lock(h)];
224
+ case 1:
225
+ return b.sent(), this.acquiredIatSet.has(h) ? (y = this.storageHandler === void 0 ? a : this.storageHandler, (f = y.getItemSync(c)) === null ? (O.default().unlock(h), [2]) : ((k = JSON.parse(f)).timeRefreshed = Date.now(), y.setItemSync(c, JSON.stringify(k)), O.default().unlock(h), this.refreshLockWhileAcquired(c, h), [2])) : (O.default().unlock(h), [2]);
226
+ }
227
+ }));
228
+ }));
229
+ }), 1e3), [2];
230
+ }));
231
+ }));
232
+ }, s.prototype.waitForSomethingToChange = function(c) {
233
+ return t(this, void 0, void 0, (function() {
234
+ return n(this, (function(h) {
235
+ switch (h.label) {
236
+ case 0:
237
+ return [4, new Promise((function(d) {
238
+ var m = !1, y = Date.now(), f = !1;
239
+ function k() {
240
+ if (f || (window.removeEventListener("storage", k), s.removeFromWaiting(k), clearTimeout(b), f = !0), !m) {
241
+ m = !0;
242
+ var w = 50 - (Date.now() - y);
243
+ w > 0 ? setTimeout(d, w) : d(null);
244
+ }
245
+ }
246
+ window.addEventListener("storage", k), s.addToWaiting(k);
247
+ var b = setTimeout(k, Math.max(0, c - Date.now()));
248
+ }))];
249
+ case 1:
250
+ return h.sent(), [2];
251
+ }
252
+ }));
253
+ }));
254
+ }, s.addToWaiting = function(c) {
255
+ this.removeFromWaiting(c), s.waiters !== void 0 && s.waiters.push(c);
256
+ }, s.removeFromWaiting = function(c) {
257
+ s.waiters !== void 0 && (s.waiters = s.waiters.filter((function(h) {
258
+ return h !== c;
259
+ })));
260
+ }, s.notifyWaiters = function() {
261
+ s.waiters !== void 0 && s.waiters.slice().forEach((function(c) {
262
+ return c();
263
+ }));
264
+ }, s.prototype.releaseLock = function(c) {
265
+ return t(this, void 0, void 0, (function() {
266
+ return n(this, (function(h) {
267
+ switch (h.label) {
268
+ case 0:
269
+ return [4, this.releaseLock__private__(c)];
270
+ case 1:
271
+ return [2, h.sent()];
272
+ }
273
+ }));
274
+ }));
275
+ }, s.prototype.releaseLock__private__ = function(c) {
276
+ return t(this, void 0, void 0, (function() {
277
+ var h, d, m, y;
278
+ return n(this, (function(f) {
279
+ switch (f.label) {
280
+ case 0:
281
+ return h = this.storageHandler === void 0 ? a : this.storageHandler, d = r + "-" + c, (m = h.getItemSync(d)) === null ? [2] : (y = JSON.parse(m)).id !== this.id ? [3, 2] : [4, O.default().lock(y.iat)];
282
+ case 1:
283
+ f.sent(), this.acquiredIatSet.delete(y.iat), h.removeItemSync(d), O.default().unlock(y.iat), s.notifyWaiters(), f.label = 2;
284
+ case 2:
285
+ return [2];
286
+ }
287
+ }));
288
+ }));
289
+ }, s.lockCorrector = function(c) {
290
+ for (var h = Date.now() - 5e3, d = c, m = [], y = 0; ; ) {
291
+ var f = d.keySync(y);
292
+ if (f === null) break;
293
+ m.push(f), y++;
294
+ }
295
+ for (var k = !1, b = 0; b < m.length; b++) {
296
+ var w = m[b];
297
+ if (w.includes(r)) {
298
+ var g = d.getItemSync(w);
299
+ if (g !== null) {
300
+ var _ = JSON.parse(g);
301
+ (_.timeRefreshed === void 0 && _.timeAcquired < h || _.timeRefreshed !== void 0 && _.timeRefreshed < h) && (d.removeItemSync(w), k = !0);
302
+ }
303
+ }
304
+ }
305
+ k && s.notifyWaiters();
306
+ }, s.waiters = void 0, s;
307
+ })();
308
+ e.default = p;
309
+ })));
310
+ const ze = { timeoutInSeconds: 60 }, ve = { name: "auth0-spa-js", version: "2.11.3" }, _e = () => Date.now();
311
+ class v extends Error {
312
+ constructor(e, t) {
313
+ super(t), this.error = e, this.error_description = t, Object.setPrototypeOf(this, v.prototype);
314
+ }
315
+ static fromPayload({ error: e, error_description: t }) {
316
+ return new v(e, t);
317
+ }
318
+ }
319
+ class te extends v {
320
+ constructor(e, t, n, o = null) {
321
+ super(e, t), this.state = n, this.appState = o, Object.setPrototypeOf(this, te.prototype);
322
+ }
323
+ }
324
+ class ne extends v {
325
+ constructor(e, t, n, o, r = null) {
326
+ super(e, t), this.connection = n, this.state = o, this.appState = r, Object.setPrototypeOf(this, ne.prototype);
327
+ }
328
+ }
329
+ class N extends v {
330
+ constructor() {
331
+ super("timeout", "Timeout"), Object.setPrototypeOf(this, N.prototype);
332
+ }
333
+ }
334
+ class oe extends N {
335
+ constructor(e) {
336
+ super(), this.popup = e, Object.setPrototypeOf(this, oe.prototype);
337
+ }
338
+ }
339
+ class ie extends v {
340
+ constructor(e) {
341
+ super("cancelled", "Popup closed"), this.popup = e, Object.setPrototypeOf(this, ie.prototype);
342
+ }
343
+ }
344
+ class re extends v {
345
+ constructor() {
346
+ super("popup_open", "Unable to open a popup for loginWithPopup - window.open returned `null`"), Object.setPrototypeOf(this, re.prototype);
347
+ }
348
+ }
349
+ class se extends v {
350
+ constructor(e, t, n) {
351
+ super(e, t), this.mfa_token = n, Object.setPrototypeOf(this, se.prototype);
352
+ }
353
+ }
354
+ class F extends v {
355
+ constructor(e, t) {
356
+ super("missing_refresh_token", `Missing Refresh Token (audience: '${J(e, ["default"])}', scope: '${J(t)}')`), this.audience = e, this.scope = t, Object.setPrototypeOf(this, F.prototype);
357
+ }
358
+ }
359
+ class ae extends v {
360
+ constructor(e, t) {
361
+ super("missing_scopes", `Missing requested scopes after refresh (audience: '${J(e, ["default"])}', missing scope: '${J(t)}')`), this.audience = e, this.scope = t, Object.setPrototypeOf(this, ae.prototype);
362
+ }
363
+ }
364
+ class G extends v {
365
+ constructor(e) {
366
+ super("use_dpop_nonce", "Server rejected DPoP proof: wrong nonce"), this.newDpopNonce = e, Object.setPrototypeOf(this, G.prototype);
367
+ }
368
+ }
369
+ function J(i, e = []) {
370
+ return i && !e.includes(i) ? i : "";
371
+ }
372
+ const X = () => window.crypto, R = () => {
373
+ const i = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
374
+ let e = "";
375
+ return Array.from(X().getRandomValues(new Uint8Array(43))).forEach(((t) => e += i[t % i.length])), e;
376
+ }, M = (i) => btoa(i), Ee = [{ key: "name", type: ["string"] }, { key: "version", type: ["string", "number"] }, { key: "env", type: ["object"] }], Ne = (i) => Object.keys(i).reduce(((e, t) => {
377
+ const n = Ee.find(((o) => o.key === t));
378
+ return n && n.type.includes(typeof i[t]) && (e[t] = i[t]), e;
379
+ }), {}), B = (i) => {
380
+ var { clientId: e } = i, t = I(i, ["clientId"]);
381
+ return new URLSearchParams(((n) => Object.keys(n).filter(((o) => n[o] !== void 0)).reduce(((o, r) => Object.assign(Object.assign({}, o), { [r]: n[r] })), {}))(Object.assign({ client_id: e }, t))).toString();
382
+ }, de = async (i) => await X().subtle.digest({ name: "SHA-256" }, new TextEncoder().encode(i)), he = (i) => ((e) => decodeURIComponent(atob(e).split("").map(((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2))).join("")))(i.replace(/_/g, "/").replace(/-/g, "+")), le = (i) => {
383
+ const e = new Uint8Array(i);
384
+ return ((t) => {
385
+ const n = { "+": "-", "/": "_", "=": "" };
386
+ return t.replace(/[+/=]/g, ((o) => n[o]));
387
+ })(window.btoa(String.fromCharCode(...Array.from(e))));
388
+ }, Re = new TextEncoder(), De = new TextDecoder();
389
+ function L(i) {
390
+ return typeof i == "string" ? Re.encode(i) : De.decode(i);
391
+ }
392
+ function pe(i) {
393
+ if (typeof i.modulusLength != "number" || i.modulusLength < 2048) throw new Le(`${i.name} modulusLength must be at least 2048 bits`);
394
+ }
395
+ async function Ae(i, e, t) {
396
+ if (t.usages.includes("sign") === !1) throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');
397
+ const n = `${U(L(JSON.stringify(i)))}.${U(L(JSON.stringify(e)))}`;
398
+ return `${n}.${U(await crypto.subtle.sign((function(o) {
399
+ switch (o.algorithm.name) {
400
+ case "ECDSA":
401
+ return { name: o.algorithm.name, hash: "SHA-256" };
402
+ case "RSA-PSS":
403
+ return pe(o.algorithm), { name: o.algorithm.name, saltLength: 32 };
404
+ case "RSASSA-PKCS1-v1_5":
405
+ return pe(o.algorithm), { name: o.algorithm.name };
406
+ case "Ed25519":
407
+ return { name: o.algorithm.name };
408
+ }
409
+ throw new K();
410
+ })(t), t, L(n)))}`;
411
+ }
412
+ let q;
413
+ Uint8Array.prototype.toBase64 ? q = (i) => (i instanceof ArrayBuffer && (i = new Uint8Array(i)), i.toBase64({ alphabet: "base64url", omitPadding: !0 })) : q = (e) => {
414
+ e instanceof ArrayBuffer && (e = new Uint8Array(e));
415
+ const t = [];
416
+ for (let n = 0; n < e.byteLength; n += 32768) t.push(String.fromCharCode.apply(null, e.subarray(n, n + 32768)));
417
+ return btoa(t.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
418
+ };
419
+ function U(i) {
420
+ return q(i);
421
+ }
422
+ class K extends Error {
423
+ constructor(e) {
424
+ var t;
425
+ super(e ?? "operation not supported"), this.name = this.constructor.name, (t = Error.captureStackTrace) === null || t === void 0 || t.call(Error, this, this.constructor);
426
+ }
427
+ }
428
+ class Le extends Error {
429
+ constructor(e) {
430
+ var t;
431
+ super(e), this.name = this.constructor.name, (t = Error.captureStackTrace) === null || t === void 0 || t.call(Error, this, this.constructor);
432
+ }
433
+ }
434
+ function Ue(i) {
435
+ switch (i.algorithm.name) {
436
+ case "RSA-PSS":
437
+ return (function(e) {
438
+ if (e.algorithm.hash.name === "SHA-256") return "PS256";
439
+ throw new K("unsupported RsaHashedKeyAlgorithm hash name");
440
+ })(i);
441
+ case "RSASSA-PKCS1-v1_5":
442
+ return (function(e) {
443
+ if (e.algorithm.hash.name === "SHA-256") return "RS256";
444
+ throw new K("unsupported RsaHashedKeyAlgorithm hash name");
445
+ })(i);
446
+ case "ECDSA":
447
+ return (function(e) {
448
+ if (e.algorithm.namedCurve === "P-256") return "ES256";
449
+ throw new K("unsupported EcKeyAlgorithm namedCurve");
450
+ })(i);
451
+ case "Ed25519":
452
+ return "Ed25519";
453
+ default:
454
+ throw new K("unsupported CryptoKey algorithm name");
455
+ }
456
+ }
457
+ function Se(i) {
458
+ return i instanceof CryptoKey;
459
+ }
460
+ function Ie(i) {
461
+ return Se(i) && i.type === "public";
462
+ }
463
+ async function Ze(i, e, t, n, o, r) {
464
+ const a = i == null ? void 0 : i.privateKey, l = i == null ? void 0 : i.publicKey;
465
+ if (!Se(u = a) || u.type !== "private") throw new TypeError('"keypair.privateKey" must be a private CryptoKey');
466
+ var u;
467
+ if (!Ie(l)) throw new TypeError('"keypair.publicKey" must be a public CryptoKey');
468
+ if (l.extractable !== !0) throw new TypeError('"keypair.publicKey.extractable" must be true');
469
+ if (typeof e != "string") throw new TypeError('"htu" must be a string');
470
+ if (typeof t != "string") throw new TypeError('"htm" must be a string');
471
+ if (n !== void 0 && typeof n != "string") throw new TypeError('"nonce" must be a string or undefined');
472
+ if (o !== void 0 && typeof o != "string") throw new TypeError('"accessToken" must be a string or undefined');
473
+ return Ae({ alg: Ue(a), typ: "dpop+jwt", jwk: await Pe(l) }, Object.assign(Object.assign({}, r), { iat: Math.floor(Date.now() / 1e3), jti: crypto.randomUUID(), htm: t, nonce: n, htu: e, ath: o ? U(await crypto.subtle.digest("SHA-256", L(o))) : void 0 }), a);
474
+ }
475
+ async function Pe(i) {
476
+ const { kty: e, e: t, n, x: o, y: r, crv: a } = await crypto.subtle.exportKey("jwk", i);
477
+ return { kty: e, crv: a, e: t, n, x: o, y: r };
478
+ }
479
+ const He = ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:token-exchange"];
480
+ function We() {
481
+ return (async function(i, e) {
482
+ var t;
483
+ let n;
484
+ if (i.length === 0) throw new TypeError('"alg" must be a non-empty string');
485
+ switch (i) {
486
+ case "PS256":
487
+ n = { name: "RSA-PSS", hash: "SHA-256", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]) };
488
+ break;
489
+ case "RS256":
490
+ n = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]) };
491
+ break;
492
+ case "ES256":
493
+ n = { name: "ECDSA", namedCurve: "P-256" };
494
+ break;
495
+ case "Ed25519":
496
+ n = { name: "Ed25519" };
497
+ break;
498
+ default:
499
+ throw new K();
500
+ }
501
+ return crypto.subtle.generateKey(n, (t = e == null ? void 0 : e.extractable) !== null && t !== void 0 && t, ["sign", "verify"]);
502
+ })("ES256", { extractable: !1 });
503
+ }
504
+ function Je(i) {
505
+ return (async function(e) {
506
+ if (!Ie(e)) throw new TypeError('"publicKey" must be a public CryptoKey');
507
+ if (e.extractable !== !0) throw new TypeError('"publicKey.extractable" must be true');
508
+ const t = await Pe(e);
509
+ let n;
510
+ switch (t.kty) {
511
+ case "EC":
512
+ n = { crv: t.crv, kty: t.kty, x: t.x, y: t.y };
513
+ break;
514
+ case "OKP":
515
+ n = { crv: t.crv, kty: t.kty, x: t.x };
516
+ break;
517
+ case "RSA":
518
+ n = { e: t.e, kty: t.kty, n: t.n };
519
+ break;
520
+ default:
521
+ throw new K("unsupported JWK kty");
522
+ }
523
+ return U(await crypto.subtle.digest({ name: "SHA-256" }, L(JSON.stringify(n))));
524
+ })(i.publicKey);
525
+ }
526
+ function Xe({ keyPair: i, url: e, method: t, nonce: n, accessToken: o }) {
527
+ const r = (function(a) {
528
+ const l = new URL(a);
529
+ return l.search = "", l.hash = "", l.href;
530
+ })(e);
531
+ return Ze(i, r, t, n, o);
532
+ }
533
+ const Ve = async (i, e) => {
534
+ const t = await fetch(i, e);
535
+ return { ok: t.ok, json: await t.json(), headers: (n = t.headers, [...n].reduce(((o, [r, a]) => (o[r] = a, o)), {})) };
536
+ var n;
537
+ }, Fe = async (i, e, t) => {
538
+ const n = new AbortController();
539
+ let o;
540
+ return e.signal = n.signal, Promise.race([Ve(i, e), new Promise(((r, a) => {
541
+ o = setTimeout((() => {
542
+ n.abort(), a(new Error("Timeout when executing 'fetch'"));
543
+ }), t);
544
+ }))]).finally((() => {
545
+ clearTimeout(o);
546
+ }));
547
+ }, Ge = async (i, e, t, n, o, r, a, l) => {
548
+ return u = { auth: { audience: e, scope: t }, timeout: o, fetchUrl: i, fetchOptions: n, useFormData: a, useMrrt: l }, p = r, new Promise((function(s, c) {
549
+ const h = new MessageChannel();
550
+ h.port1.onmessage = function(d) {
551
+ d.data.error ? c(new Error(d.data.error)) : s(d.data), h.port1.close();
552
+ }, p.postMessage(u, [h.port2]);
553
+ }));
554
+ var u, p;
555
+ }, Me = async (i, e, t, n, o, r, a = 1e4, l) => o ? Ge(i, e, t, n, a, o, r, l) : Fe(i, n, a);
556
+ async function Te(i, e, t, n, o, r, a, l, u, p) {
557
+ if (u) {
558
+ const w = await u.generateProof({ url: i, method: o.method || "GET", nonce: await u.getNonce() });
559
+ o.headers = Object.assign(Object.assign({}, o.headers), { dpop: w });
560
+ }
561
+ let s, c = null;
562
+ for (let w = 0; w < 3; w++) try {
563
+ s = await Me(i, t, n, o, r, a, e, l), c = null;
564
+ break;
565
+ } catch (g) {
566
+ c = g;
567
+ }
568
+ if (c) throw c;
569
+ const h = s.json, { error: d, error_description: m } = h, y = I(h, ["error", "error_description"]), { headers: f, ok: k } = s;
570
+ let b;
571
+ if (u && (b = f["dpop-nonce"], b && await u.setNonce(b)), !k) {
572
+ const w = m || `HTTP error. Unable to fetch ${i}`;
573
+ if (d === "mfa_required") throw new se(d, w, y.mfa_token);
574
+ if (d === "missing_refresh_token") throw new F(t, n);
575
+ if (d === "use_dpop_nonce") {
576
+ if (!u || !b || p) throw new G(b);
577
+ return Te(i, e, t, n, o, r, a, l, u, !0);
578
+ }
579
+ throw new v(d || "request_error", w);
580
+ }
581
+ return y;
582
+ }
583
+ async function Ye(i, e) {
584
+ var { baseUrl: t, timeout: n, audience: o, scope: r, auth0Client: a, useFormData: l, useMrrt: u, dpop: p } = i, s = I(i, ["baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop"]);
585
+ const c = s.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange", h = s.grant_type === "refresh_token" && u, d = Object.assign(Object.assign(Object.assign(Object.assign({}, s), c && o && { audience: o }), c && r && { scope: r }), h && { audience: o, scope: r }), m = l ? B(d) : JSON.stringify(d), y = (f = s.grant_type, He.includes(f));
586
+ var f;
587
+ return await Te(`${t}/oauth/token`, n, o || "default", r, { method: "POST", body: m, headers: { "Content-Type": l ? "application/x-www-form-urlencoded" : "application/json", "Auth0-Client": btoa(JSON.stringify(Ne(a || ve))) } }, e, l, u, y ? p : void 0);
588
+ }
589
+ const W = (...i) => {
590
+ return (e = i.filter(Boolean).join(" ").trim().split(/\s+/), Array.from(new Set(e))).join(" ");
591
+ var e;
592
+ }, H = (i, e, t) => {
593
+ let n;
594
+ return t && (n = i[t]), n || (n = i.default), W(n, e);
595
+ };
596
+ class S {
597
+ constructor(e, t = "@@auth0spajs@@", n) {
598
+ this.prefix = t, this.suffix = n, this.clientId = e.clientId, this.scope = e.scope, this.audience = e.audience;
599
+ }
600
+ toKey() {
601
+ return [this.prefix, this.clientId, this.audience, this.scope, this.suffix].filter(Boolean).join("::");
602
+ }
603
+ static fromKey(e) {
604
+ const [t, n, o, r] = e.split("::");
605
+ return new S({ clientId: n, scope: r, audience: o }, t);
606
+ }
607
+ static fromCacheEntry(e) {
608
+ const { scope: t, audience: n, client_id: o } = e;
609
+ return new S({ scope: t, audience: n, clientId: o });
610
+ }
611
+ }
612
+ class $e {
613
+ set(e, t) {
614
+ localStorage.setItem(e, JSON.stringify(t));
615
+ }
616
+ get(e) {
617
+ const t = window.localStorage.getItem(e);
618
+ if (t) try {
619
+ return JSON.parse(t);
620
+ } catch {
621
+ return;
622
+ }
623
+ }
624
+ remove(e) {
625
+ localStorage.removeItem(e);
626
+ }
627
+ allKeys() {
628
+ return Object.keys(window.localStorage).filter(((e) => e.startsWith("@@auth0spajs@@")));
629
+ }
630
+ }
631
+ class Oe {
632
+ constructor() {
633
+ this.enclosedCache = /* @__PURE__ */ (function() {
634
+ let e = {};
635
+ return { set(t, n) {
636
+ e[t] = n;
637
+ }, get(t) {
638
+ const n = e[t];
639
+ if (n) return n;
640
+ }, remove(t) {
641
+ delete e[t];
642
+ }, allKeys: () => Object.keys(e) };
643
+ })();
644
+ }
645
+ }
646
+ class Be {
647
+ constructor(e, t, n) {
648
+ this.cache = e, this.keyManifest = t, this.nowProvider = n || _e;
649
+ }
650
+ async setIdToken(e, t, n) {
651
+ var o;
652
+ const r = this.getIdTokenCacheKey(e);
653
+ await this.cache.set(r, { id_token: t, decodedToken: n }), await ((o = this.keyManifest) === null || o === void 0 ? void 0 : o.add(r));
654
+ }
655
+ async getIdToken(e) {
656
+ const t = await this.cache.get(this.getIdTokenCacheKey(e.clientId));
657
+ if (!t && e.scope && e.audience) {
658
+ const n = await this.get(e);
659
+ return !n || !n.id_token || !n.decodedToken ? void 0 : { id_token: n.id_token, decodedToken: n.decodedToken };
660
+ }
661
+ if (t) return { id_token: t.id_token, decodedToken: t.decodedToken };
662
+ }
663
+ async get(e, t = 0, n = !1, o) {
664
+ var r;
665
+ let a = await this.cache.get(e.toKey());
666
+ if (!a) {
667
+ const p = await this.getCacheKeys();
668
+ if (!p) return;
669
+ const s = this.matchExistingCacheKey(e, p);
670
+ if (s && (a = await this.cache.get(s)), !a && n && o !== "cache-only") return this.getEntryWithRefreshToken(e, p);
671
+ }
672
+ if (!a) return;
673
+ const l = await this.nowProvider(), u = Math.floor(l / 1e3);
674
+ return a.expiresAt - t < u ? a.body.refresh_token ? this.modifiedCachedEntry(a, e) : (await this.cache.remove(e.toKey()), void await ((r = this.keyManifest) === null || r === void 0 ? void 0 : r.remove(e.toKey()))) : a.body;
675
+ }
676
+ async modifiedCachedEntry(e, t) {
677
+ return e.body = { refresh_token: e.body.refresh_token, audience: e.body.audience, scope: e.body.scope }, await this.cache.set(t.toKey(), e), { refresh_token: e.body.refresh_token, audience: e.body.audience, scope: e.body.scope };
678
+ }
679
+ async set(e) {
680
+ var t;
681
+ const n = new S({ clientId: e.client_id, scope: e.scope, audience: e.audience }), o = await this.wrapCacheEntry(e);
682
+ await this.cache.set(n.toKey(), o), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.add(n.toKey()));
683
+ }
684
+ async remove(e, t, n) {
685
+ const o = new S({ clientId: e, scope: n, audience: t });
686
+ await this.cache.remove(o.toKey());
687
+ }
688
+ async clear(e) {
689
+ var t;
690
+ const n = await this.getCacheKeys();
691
+ n && (await n.filter(((o) => !e || o.includes(e))).reduce((async (o, r) => {
692
+ await o, await this.cache.remove(r);
693
+ }), Promise.resolve()), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.clear()));
694
+ }
695
+ async wrapCacheEntry(e) {
696
+ const t = await this.nowProvider();
697
+ return { body: e, expiresAt: Math.floor(t / 1e3) + e.expires_in };
698
+ }
699
+ async getCacheKeys() {
700
+ var e;
701
+ return this.keyManifest ? (e = await this.keyManifest.get()) === null || e === void 0 ? void 0 : e.keys : this.cache.allKeys ? this.cache.allKeys() : void 0;
702
+ }
703
+ getIdTokenCacheKey(e) {
704
+ return new S({ clientId: e }, "@@auth0spajs@@", "@@user@@").toKey();
705
+ }
706
+ matchExistingCacheKey(e, t) {
707
+ return t.filter(((n) => {
708
+ var o;
709
+ const r = S.fromKey(n), a = new Set(r.scope && r.scope.split(" ")), l = ((o = e.scope) === null || o === void 0 ? void 0 : o.split(" ")) || [], u = r.scope && l.reduce(((p, s) => p && a.has(s)), !0);
710
+ return r.prefix === "@@auth0spajs@@" && r.clientId === e.clientId && r.audience === e.audience && u;
711
+ }))[0];
712
+ }
713
+ async getEntryWithRefreshToken(e, t) {
714
+ var n;
715
+ for (const o of t) {
716
+ const r = S.fromKey(o);
717
+ if (r.prefix === "@@auth0spajs@@" && r.clientId === e.clientId) {
718
+ const a = await this.cache.get(o);
719
+ if (!((n = a == null ? void 0 : a.body) === null || n === void 0) && n.refresh_token) return this.modifiedCachedEntry(a, e);
720
+ }
721
+ }
722
+ }
723
+ async updateEntry(e, t) {
724
+ var n;
725
+ const o = await this.getCacheKeys();
726
+ if (o) for (const r of o) {
727
+ const a = await this.cache.get(r);
728
+ if (((n = a == null ? void 0 : a.body) === null || n === void 0 ? void 0 : n.refresh_token) === e) {
729
+ const l = Object.assign(Object.assign({}, a.body), { refresh_token: t });
730
+ await this.set(l);
731
+ }
732
+ }
733
+ }
734
+ }
735
+ class qe {
736
+ constructor(e, t, n) {
737
+ this.storage = e, this.clientId = t, this.cookieDomain = n, this.storageKey = `a0.spajs.txs.${this.clientId}`;
738
+ }
739
+ create(e) {
740
+ this.storage.save(this.storageKey, e, { daysUntilExpire: 1, cookieDomain: this.cookieDomain });
741
+ }
742
+ get() {
743
+ return this.storage.get(this.storageKey);
744
+ }
745
+ remove() {
746
+ this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain });
747
+ }
748
+ }
749
+ const D = (i) => typeof i == "number", Qe = ["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"], et = (i) => {
750
+ if (!i.id_token) throw new Error("ID token is required but missing");
751
+ const e = ((r) => {
752
+ const a = r.split("."), [l, u, p] = a;
753
+ if (a.length !== 3 || !l || !u || !p) throw new Error("ID token could not be decoded");
754
+ const s = JSON.parse(he(u)), c = { __raw: r }, h = {};
755
+ return Object.keys(s).forEach(((d) => {
756
+ c[d] = s[d], Qe.includes(d) || (h[d] = s[d]);
757
+ })), { encoded: { header: l, payload: u, signature: p }, header: JSON.parse(he(l)), claims: c, user: h };
758
+ })(i.id_token);
759
+ if (!e.claims.iss) throw new Error("Issuer (iss) claim must be a string present in the ID token");
760
+ if (e.claims.iss !== i.iss) throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${i.iss}", found "${e.claims.iss}"`);
761
+ if (!e.user.sub) throw new Error("Subject (sub) claim must be a string present in the ID token");
762
+ if (e.header.alg !== "RS256") throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);
763
+ if (!e.claims.aud || typeof e.claims.aud != "string" && !Array.isArray(e.claims.aud)) throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");
764
+ if (Array.isArray(e.claims.aud)) {
765
+ if (!e.claims.aud.includes(i.aud)) throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${i.aud}" but was not one of "${e.claims.aud.join(", ")}"`);
766
+ if (e.claims.aud.length > 1) {
767
+ if (!e.claims.azp) throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");
768
+ if (e.claims.azp !== i.aud) throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${i.aud}", found "${e.claims.azp}"`);
769
+ }
770
+ } else if (e.claims.aud !== i.aud) throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${i.aud}" but found "${e.claims.aud}"`);
771
+ if (i.nonce) {
772
+ if (!e.claims.nonce) throw new Error("Nonce (nonce) claim must be a string present in the ID token");
773
+ if (e.claims.nonce !== i.nonce) throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${i.nonce}", found "${e.claims.nonce}"`);
774
+ }
775
+ if (i.max_age && !D(e.claims.auth_time)) throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");
776
+ if (e.claims.exp == null || !D(e.claims.exp)) throw new Error("Expiration Time (exp) claim must be a number present in the ID token");
777
+ if (!D(e.claims.iat)) throw new Error("Issued At (iat) claim must be a number present in the ID token");
778
+ const t = i.leeway || 60, n = new Date(i.now || Date.now()), o = /* @__PURE__ */ new Date(0);
779
+ if (o.setUTCSeconds(e.claims.exp + t), n > o) throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${n}) is after expiration time (${o})`);
780
+ if (e.claims.nbf != null && D(e.claims.nbf)) {
781
+ const r = /* @__PURE__ */ new Date(0);
782
+ if (r.setUTCSeconds(e.claims.nbf - t), n < r) throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${n}) is before ${r}`);
783
+ }
784
+ if (e.claims.auth_time != null && D(e.claims.auth_time)) {
785
+ const r = /* @__PURE__ */ new Date(0);
786
+ if (r.setUTCSeconds(parseInt(e.claims.auth_time) + i.max_age + t), n > r) 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 (${n}) is after last auth at ${r}`);
787
+ }
788
+ if (i.organization) {
789
+ const r = i.organization.trim();
790
+ if (r.startsWith("org_")) {
791
+ const a = r;
792
+ if (!e.claims.org_id) throw new Error("Organization ID (org_id) claim must be a string present in the ID token");
793
+ if (a !== e.claims.org_id) throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`);
794
+ } else {
795
+ const a = r.toLowerCase();
796
+ if (!e.claims.org_name) throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
797
+ if (a !== e.claims.org_name) throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`);
798
+ }
799
+ }
800
+ return e;
801
+ };
802
+ var x = ee((function(i, e) {
803
+ var t = C && C.__assign || function() {
804
+ return t = Object.assign || function(u) {
805
+ for (var p, s = 1, c = arguments.length; s < c; s++) for (var h in p = arguments[s]) Object.prototype.hasOwnProperty.call(p, h) && (u[h] = p[h]);
806
+ return u;
807
+ }, t.apply(this, arguments);
808
+ };
809
+ function n(u, p) {
810
+ if (!p) return "";
811
+ var s = "; " + u;
812
+ return p === !0 ? s : s + "=" + p;
813
+ }
814
+ function o(u, p, s) {
815
+ return encodeURIComponent(u).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/\(/g, "%28").replace(/\)/g, "%29") + "=" + encodeURIComponent(p).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) + (function(c) {
816
+ if (typeof c.expires == "number") {
817
+ var h = /* @__PURE__ */ new Date();
818
+ h.setMilliseconds(h.getMilliseconds() + 864e5 * c.expires), c.expires = h;
819
+ }
820
+ return n("Expires", c.expires ? c.expires.toUTCString() : "") + n("Domain", c.domain) + n("Path", c.path) + n("Secure", c.secure) + n("SameSite", c.sameSite);
821
+ })(s);
822
+ }
823
+ function r(u) {
824
+ for (var p = {}, s = u ? u.split("; ") : [], c = /(%[\dA-F]{2})+/gi, h = 0; h < s.length; h++) {
825
+ var d = s[h].split("="), m = d.slice(1).join("=");
826
+ m.charAt(0) === '"' && (m = m.slice(1, -1));
827
+ try {
828
+ p[d[0].replace(c, decodeURIComponent)] = m.replace(c, decodeURIComponent);
829
+ } catch {
830
+ }
831
+ }
832
+ return p;
833
+ }
834
+ function a() {
835
+ return r(document.cookie);
836
+ }
837
+ function l(u, p, s) {
838
+ document.cookie = o(u, p, t({ path: "/" }, s));
839
+ }
840
+ e.__esModule = !0, e.encode = o, e.parse = r, e.getAll = a, e.get = function(u) {
841
+ return a()[u];
842
+ }, e.set = l, e.remove = function(u, p) {
843
+ l(u, "", t(t({}, p), { expires: -1 }));
844
+ };
845
+ }));
846
+ Q(x), x.encode, x.parse, x.getAll;
847
+ var tt = x.get, Ce = x.set, je = x.remove;
848
+ const z = { get(i) {
849
+ const e = tt(i);
850
+ if (e !== void 0) return JSON.parse(e);
851
+ }, save(i, e, t) {
852
+ let n = {};
853
+ window.location.protocol === "https:" && (n = { secure: !0, sameSite: "none" }), t != null && t.daysUntilExpire && (n.expires = t.daysUntilExpire), t != null && t.cookieDomain && (n.domain = t.cookieDomain), Ce(i, JSON.stringify(e), n);
854
+ }, remove(i, e) {
855
+ let t = {};
856
+ e != null && e.cookieDomain && (t.domain = e.cookieDomain), je(i, t);
857
+ } }, nt = { get(i) {
858
+ return z.get(i) || z.get(`_legacy_${i}`);
859
+ }, save(i, e, t) {
860
+ let n = {};
861
+ window.location.protocol === "https:" && (n = { secure: !0 }), t != null && t.daysUntilExpire && (n.expires = t.daysUntilExpire), t != null && t.cookieDomain && (n.domain = t.cookieDomain), Ce(`_legacy_${i}`, JSON.stringify(e), n), z.save(i, e, t);
862
+ }, remove(i, e) {
863
+ let t = {};
864
+ e != null && e.cookieDomain && (t.domain = e.cookieDomain), je(i, t), z.remove(i, e), z.remove(`_legacy_${i}`, e);
865
+ } }, ot = { get(i) {
866
+ if (typeof sessionStorage > "u") return;
867
+ const e = sessionStorage.getItem(i);
868
+ return e != null ? JSON.parse(e) : void 0;
869
+ }, save(i, e) {
870
+ sessionStorage.setItem(i, JSON.stringify(e));
871
+ }, remove(i) {
872
+ sessionStorage.removeItem(i);
873
+ } };
874
+ var j;
875
+ (function(i) {
876
+ i.Code = "code", i.ConnectCode = "connect_code";
877
+ })(j || (j = {}));
878
+ function it(i, e, t) {
879
+ var n = e === void 0 ? null : e, o = (function(u, p) {
880
+ var s = atob(u);
881
+ if (p) {
882
+ for (var c = new Uint8Array(s.length), h = 0, d = s.length; h < d; ++h) c[h] = s.charCodeAt(h);
883
+ return String.fromCharCode.apply(null, new Uint16Array(c.buffer));
884
+ }
885
+ return s;
886
+ })(i, t !== void 0 && t), r = o.indexOf(`
887
+ `, 10) + 1, a = o.substring(r) + (n ? "//# sourceMappingURL=" + n : ""), l = new Blob([a], { type: "application/javascript" });
888
+ return URL.createObjectURL(l);
889
+ }
890
+ var me, fe, ge, Y, rt = (me = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YSx1c2VNcnJ0OmZ9LHBvcnRzOltwXX0pPT57bGV0IGgsdSxsPXt9O2NvbnN0e2F1ZGllbmNlOmQsc2NvcGU6eX09cnx8e307dHJ5e2NvbnN0IHI9YT8oZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKChlLHQpPT57clt0XT1lfSkpLHJ9KShjLmJvZHkpOkpTT04ucGFyc2UoYy5ib2R5KTtpZighci5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1yLmdyYW50X3R5cGUpe2lmKHU9KChlLHQpPT5vW24oZSx0KV0pKGQseSksIXUmJmYpe2NvbnN0IGU9by5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+e2NvbnN0IHI9T2JqZWN0LmtleXMobykuZmluZCgocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBzPSgoZSx0KT0+dC5zdGFydHNXaXRoKGAke2V9fGApKSh0LHIpLG89ci5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIiksbj1lLnNwbGl0KCIgIikuZXZlcnkoKGU9Pm8uaW5jbHVkZXMoZSkpKTtyZXR1cm4gcyYmbn19KSk7cmV0dXJuISFyfSkoeSxkKTtlJiYhdCYmKHU9ZSl9aWYoIXUpdGhyb3cgbmV3IHQoZCx5KTtjLmJvZHk9YT9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7cmVmcmVzaF90b2tlbjp1fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7cmVmcmVzaF90b2tlbjp1fSkpfWxldCBqLGs7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGo9bmV3IEFib3J0Q29udHJvbGxlcixjLnNpZ25hbD1qLnNpZ25hbCk7dHJ5e2s9YXdhaXQgUHJvbWlzZS5yYWNlKFsoXz1lLG5ldyBQcm9taXNlKChlPT5zZXRUaW1lb3V0KGUsXykpKSksZmV0Y2goaSxPYmplY3QuYXNzaWduKHt9LGMpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIHAucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCFrKXJldHVybiBqJiZqLmFib3J0KCksdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO2c9ay5oZWFkZXJzLGw9Wy4uLmddLnJlZHVjZSgoKGUsW3Qscl0pPT4oZVt0XT1yLGUpKSx7fSksaD1hd2FpdCBrLmpzb24oKSxoLnJlZnJlc2hfdG9rZW4/KGYmJihvLmxhdGVzdF9yZWZyZXNoX3Rva2VuPWgucmVmcmVzaF90b2tlbixPPXUsYj1oLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMobykuZm9yRWFjaCgoKFtlLHRdKT0+e3Q9PT1PJiYob1tlXT1iKX0pKSksKChlLHQscik9PntvW24odCxyKV09ZX0pKGgucmVmcmVzaF90b2tlbixkLHkpLGRlbGV0ZSBoLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KShkLHkpLHAucG9zdE1lc3NhZ2Uoe29rOmsub2ssanNvbjpoLGhlYWRlcnM6bH0pfWNhdGNoKGUpe3AucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOmx9KX12YXIgTyxiLGcsX30pKX0oKTsKCg==", fe = null, ge = !1, function(i) {
891
+ return Y = Y || it(me, fe, ge), new Worker(Y, i);
892
+ });
893
+ const $ = {}, ye = async (i, e = 3) => {
894
+ for (let t = 0; t < e; t++) if (await i()) return !0;
895
+ return !1;
896
+ };
897
+ class st {
898
+ constructor(e, t) {
899
+ this.cache = e, this.clientId = t, this.manifestKey = this.createManifestKeyFrom(this.clientId);
900
+ }
901
+ async add(e) {
902
+ var t;
903
+ const n = new Set(((t = await this.cache.get(this.manifestKey)) === null || t === void 0 ? void 0 : t.keys) || []);
904
+ n.add(e), await this.cache.set(this.manifestKey, { keys: [...n] });
905
+ }
906
+ async remove(e) {
907
+ const t = await this.cache.get(this.manifestKey);
908
+ if (t) {
909
+ const n = new Set(t.keys);
910
+ return n.delete(e), n.size > 0 ? await this.cache.set(this.manifestKey, { keys: [...n] }) : await this.cache.remove(this.manifestKey);
911
+ }
912
+ }
913
+ get() {
914
+ return this.cache.get(this.manifestKey);
915
+ }
916
+ clear() {
917
+ return this.cache.remove(this.manifestKey);
918
+ }
919
+ createManifestKeyFrom(e) {
920
+ return `@@auth0spajs@@::${e}`;
921
+ }
922
+ }
923
+ const at = { memory: () => new Oe().enclosedCache, localstorage: () => new $e() }, we = (i) => at[i], be = (i) => {
924
+ const { openUrl: e, onRedirect: t } = i, n = I(i, ["openUrl", "onRedirect"]);
925
+ return Object.assign(Object.assign({}, n), { openUrl: e === !1 || e ? e : t });
926
+ }, ke = (i, e) => {
927
+ const t = (e == null ? void 0 : e.split(" ")) || [];
928
+ return ((i == null ? void 0 : i.split(" ")) || []).every(((n) => t.includes(n)));
929
+ }, T = { NONCE: "nonce", KEYPAIR: "keypair" };
930
+ class ct {
931
+ constructor(e) {
932
+ this.clientId = e;
933
+ }
934
+ getVersion() {
935
+ return 1;
936
+ }
937
+ createDbHandle() {
938
+ const e = window.indexedDB.open("auth0-spa-js", this.getVersion());
939
+ return new Promise(((t, n) => {
940
+ e.onupgradeneeded = () => Object.values(T).forEach(((o) => e.result.createObjectStore(o))), e.onerror = () => n(e.error), e.onsuccess = () => t(e.result);
941
+ }));
942
+ }
943
+ async getDbHandle() {
944
+ return this.dbHandle || (this.dbHandle = await this.createDbHandle()), this.dbHandle;
945
+ }
946
+ async executeDbRequest(e, t, n) {
947
+ const o = n((await this.getDbHandle()).transaction(e, t).objectStore(e));
948
+ return new Promise(((r, a) => {
949
+ o.onsuccess = () => r(o.result), o.onerror = () => a(o.error);
950
+ }));
951
+ }
952
+ buildKey(e) {
953
+ const t = e ? `_${e}` : "auth0";
954
+ return `${this.clientId}::${t}`;
955
+ }
956
+ setNonce(e, t) {
957
+ return this.save(T.NONCE, this.buildKey(t), e);
958
+ }
959
+ setKeyPair(e) {
960
+ return this.save(T.KEYPAIR, this.buildKey(), e);
961
+ }
962
+ async save(e, t, n) {
963
+ await this.executeDbRequest(e, "readwrite", ((o) => o.put(n, t)));
964
+ }
965
+ findNonce(e) {
966
+ return this.find(T.NONCE, this.buildKey(e));
967
+ }
968
+ findKeyPair() {
969
+ return this.find(T.KEYPAIR, this.buildKey());
970
+ }
971
+ find(e, t) {
972
+ return this.executeDbRequest(e, "readonly", ((n) => n.get(t)));
973
+ }
974
+ async deleteBy(e, t) {
975
+ const n = await this.executeDbRequest(e, "readonly", ((o) => o.getAllKeys()));
976
+ n == null || n.filter(t).map(((o) => this.executeDbRequest(e, "readwrite", ((r) => r.delete(o)))));
977
+ }
978
+ deleteByClientId(e, t) {
979
+ return this.deleteBy(e, ((n) => typeof n == "string" && n.startsWith(`${t}::`)));
980
+ }
981
+ clearNonces() {
982
+ return this.deleteByClientId(T.NONCE, this.clientId);
983
+ }
984
+ clearKeyPairs() {
985
+ return this.deleteByClientId(T.KEYPAIR, this.clientId);
986
+ }
987
+ }
988
+ class ut {
989
+ constructor(e) {
990
+ this.storage = new ct(e);
991
+ }
992
+ getNonce(e) {
993
+ return this.storage.findNonce(e);
994
+ }
995
+ setNonce(e, t) {
996
+ return this.storage.setNonce(e, t);
997
+ }
998
+ async getOrGenerateKeyPair() {
999
+ let e = await this.storage.findKeyPair();
1000
+ return e || (e = await We(), await this.storage.setKeyPair(e)), e;
1001
+ }
1002
+ async generateProof(e) {
1003
+ const t = await this.getOrGenerateKeyPair();
1004
+ return Xe(Object.assign({ keyPair: t }, e));
1005
+ }
1006
+ async calculateThumbprint() {
1007
+ return Je(await this.getOrGenerateKeyPair());
1008
+ }
1009
+ async clear() {
1010
+ await Promise.all([this.storage.clearNonces(), this.storage.clearKeyPairs()]);
1011
+ }
1012
+ }
1013
+ var E;
1014
+ (function(i) {
1015
+ i.Bearer = "Bearer", i.DPoP = "DPoP";
1016
+ })(E || (E = {}));
1017
+ class dt {
1018
+ constructor(e, t) {
1019
+ this.hooks = t, this.config = Object.assign(Object.assign({}, e), { fetch: e.fetch || (typeof window > "u" ? fetch : window.fetch.bind(window)) });
1020
+ }
1021
+ isAbsoluteUrl(e) {
1022
+ return /^(https?:)?\/\//i.test(e);
1023
+ }
1024
+ buildUrl(e, t) {
1025
+ if (t) {
1026
+ if (this.isAbsoluteUrl(t)) return t;
1027
+ if (e) return `${e.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}`;
1028
+ }
1029
+ throw new TypeError("`url` must be absolute or `baseUrl` non-empty.");
1030
+ }
1031
+ getAccessToken(e) {
1032
+ return this.config.getAccessToken ? this.config.getAccessToken(e) : this.hooks.getAccessToken(e);
1033
+ }
1034
+ extractUrl(e) {
1035
+ return typeof e == "string" ? e : e instanceof URL ? e.href : e.url;
1036
+ }
1037
+ buildBaseRequest(e, t) {
1038
+ if (!this.config.baseUrl) return new Request(e, t);
1039
+ const n = this.buildUrl(this.config.baseUrl, this.extractUrl(e)), o = e instanceof Request ? new Request(n, e) : n;
1040
+ return new Request(o, t);
1041
+ }
1042
+ setAuthorizationHeader(e, t, n = E.Bearer) {
1043
+ e.headers.set("authorization", `${n} ${t}`);
1044
+ }
1045
+ async setDpopProofHeader(e, t) {
1046
+ if (!this.config.dpopNonceId) return;
1047
+ const n = await this.hooks.getDpopNonce(), o = await this.hooks.generateDpopProof({ accessToken: t, method: e.method, nonce: n, url: e.url });
1048
+ e.headers.set("dpop", o);
1049
+ }
1050
+ async prepareRequest(e, t) {
1051
+ const n = await this.getAccessToken(t);
1052
+ let o, r;
1053
+ typeof n == "string" ? (o = this.config.dpopNonceId ? E.DPoP : E.Bearer, r = n) : (o = n.token_type, r = n.access_token), this.setAuthorizationHeader(e, r, o), o === E.DPoP && await this.setDpopProofHeader(e, r);
1054
+ }
1055
+ getHeader(e, t) {
1056
+ return Array.isArray(e) ? new Headers(e).get(t) || "" : typeof e.get == "function" ? e.get(t) || "" : e[t] || "";
1057
+ }
1058
+ hasUseDpopNonceError(e) {
1059
+ if (e.status !== 401) return !1;
1060
+ const t = this.getHeader(e.headers, "www-authenticate");
1061
+ return t.includes("invalid_dpop_nonce") || t.includes("use_dpop_nonce");
1062
+ }
1063
+ async handleResponse(e, t) {
1064
+ const n = this.getHeader(e.headers, "dpop-nonce");
1065
+ if (n && await this.hooks.setDpopNonce(n), !this.hasUseDpopNonceError(e)) return e;
1066
+ if (!n || !t.onUseDpopNonceError) throw new G(n);
1067
+ return t.onUseDpopNonceError();
1068
+ }
1069
+ async internalFetchWithAuth(e, t, n, o) {
1070
+ const r = this.buildBaseRequest(e, t);
1071
+ await this.prepareRequest(r, o);
1072
+ const a = await this.config.fetch(r);
1073
+ return this.handleResponse(a, n);
1074
+ }
1075
+ fetchWithAuth(e, t, n) {
1076
+ const o = { onUseDpopNonceError: () => this.internalFetchWithAuth(e, t, Object.assign(Object.assign({}, o), { onUseDpopNonceError: void 0 }), n) };
1077
+ return this.internalFetchWithAuth(e, t, o, n);
1078
+ }
1079
+ }
1080
+ class ht {
1081
+ constructor(e, t) {
1082
+ this.myAccountFetcher = e, this.apiBase = t;
1083
+ }
1084
+ async connectAccount(e) {
1085
+ const t = await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
1086
+ return this._handleResponse(t);
1087
+ }
1088
+ async completeAccount(e) {
1089
+ const t = await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
1090
+ return this._handleResponse(t);
1091
+ }
1092
+ async _handleResponse(e) {
1093
+ let t;
1094
+ try {
1095
+ t = await e.text(), t = JSON.parse(t);
1096
+ } catch (n) {
1097
+ throw new V({ type: "invalid_json", status: e.status, title: "Invalid JSON response", detail: t || String(n) });
1098
+ }
1099
+ if (e.ok) return t;
1100
+ throw new V(t);
1101
+ }
1102
+ }
1103
+ class V extends Error {
1104
+ constructor({ type: e, status: t, title: n, detail: o, validation_errors: r }) {
1105
+ super(o), this.name = "MyAccountApiError", this.type = e, this.status = t, this.title = n, this.detail = o, this.validation_errors = r, Object.setPrototypeOf(this, V.prototype);
1106
+ }
1107
+ }
1108
+ const A = new xe();
1109
+ class lt {
1110
+ constructor(e) {
1111
+ let t, n;
1112
+ if (this.userCache = new Oe().enclosedCache, this.activeLockKeys = /* @__PURE__ */ new Set(), this.defaultOptions = { authorizationParams: { scope: "openid profile email" }, useRefreshTokensFallback: !1, useFormData: !0 }, this._releaseLockOnPageHide = async () => {
1113
+ const u = Array.from(this.activeLockKeys);
1114
+ for (const p of u) await A.releaseLock(p);
1115
+ this.activeLockKeys.clear(), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
1116
+ }, this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), e), { authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), e.authorizationParams) }), typeof window < "u" && (() => {
1117
+ if (!X()) throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");
1118
+ if (X().subtle === void 0) throw new Error(`
1119
+ 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.
1120
+ `);
1121
+ })(), 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) n = e.cache;
1122
+ else {
1123
+ if (t = e.cacheLocation || "memory", !we(t)) throw new Error(`Invalid cache location "${t}"`);
1124
+ n = we(t)();
1125
+ }
1126
+ this.httpTimeoutMs = e.httpTimeoutInSeconds ? 1e3 * e.httpTimeoutInSeconds : 1e4, this.cookieStorage = e.legacySameSiteCookie === !1 ? z : nt, this.orgHintCookieName = `auth0.${this.options.clientId}.organization_hint`, this.isAuthenticatedCookieName = ((u) => `auth0.${u}.is.authenticated`)(this.options.clientId), this.sessionCheckExpiryDays = e.sessionCheckExpiryDays || 1;
1127
+ const o = e.useCookiesForTransactions ? this.cookieStorage : ot;
1128
+ var r;
1129
+ this.scope = ((u, p, ...s) => {
1130
+ if (typeof u != "object") return { default: W(p, u, ...s) };
1131
+ let c = { default: W(p, ...s) };
1132
+ return Object.keys(u).forEach(((h) => {
1133
+ const d = u[h];
1134
+ c[h] = W(p, d, ...s);
1135
+ })), c;
1136
+ })(this.options.authorizationParams.scope, "openid", this.options.useRefreshTokens ? "offline_access" : ""), this.transactionManager = new qe(o, this.options.clientId, this.options.cookieDomain), this.nowProvider = this.options.nowProvider || _e, this.cacheManager = new Be(n, n.allKeys ? void 0 : new st(n, this.options.clientId), this.nowProvider), this.dpop = this.options.useDpop ? new ut(this.options.clientId) : void 0, this.domainUrl = (r = this.options.domain, /^https?:\/\//.test(r) ? r : `https://${r}`), this.tokenIssuer = ((u, p) => u ? u.startsWith("https://") ? u : `https://${u}/` : `${p}/`)(this.options.issuer, this.domainUrl);
1137
+ const a = `${this.domainUrl}/me/`, l = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && { dpopNonceId: "__auth0_my_account_api__" }), { getAccessToken: () => this.getTokenSilently({ authorizationParams: { scope: "create:me:connected_accounts", audience: a }, detailedResponse: !0 }) }));
1138
+ this.myAccountApi = new ht(l, a), typeof window < "u" && window.Worker && this.options.useRefreshTokens && t === "memory" && (this.options.workerUrl ? this.worker = new Worker(this.options.workerUrl) : this.worker = new rt());
1139
+ }
1140
+ _url(e) {
1141
+ const t = encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client || ve)));
1142
+ return `${this.domainUrl}${e}&auth0Client=${t}`;
1143
+ }
1144
+ _authorizeUrl(e) {
1145
+ return this._url(`/authorize?${B(e)}`);
1146
+ }
1147
+ async _verifyIdToken(e, t, n) {
1148
+ const o = await this.nowProvider();
1149
+ return et({ iss: this.tokenIssuer, aud: this.options.clientId, id_token: e, nonce: t, organization: n, leeway: this.options.leeway, max_age: (r = this.options.authorizationParams.max_age, typeof r != "string" ? r : parseInt(r, 10) || void 0), now: o });
1150
+ var r;
1151
+ }
1152
+ _processOrgHint(e) {
1153
+ e ? this.cookieStorage.save(this.orgHintCookieName, e, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }) : this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain });
1154
+ }
1155
+ async _prepareAuthorizeUrl(e, t, n) {
1156
+ var o;
1157
+ const r = M(R()), a = M(R()), l = R(), u = await de(l), p = le(u), s = await ((o = this.dpop) === null || o === void 0 ? void 0 : o.calculateThumbprint()), c = ((d, m, y, f, k, b, w, g, _) => Object.assign(Object.assign(Object.assign({ client_id: d.clientId }, d.authorizationParams), y), { scope: H(m, y.scope, y.audience), response_type: "code", response_mode: g || "query", state: f, nonce: k, redirect_uri: w || d.authorizationParams.redirect_uri, code_challenge: b, code_challenge_method: "S256", dpop_jkt: _ }))(this.options, this.scope, e, r, a, p, e.redirect_uri || this.options.authorizationParams.redirect_uri || n, t == null ? void 0 : t.response_mode, s), h = this._authorizeUrl(c);
1158
+ return { nonce: a, code_verifier: l, scope: c.scope, audience: c.audience || "default", redirect_uri: c.redirect_uri, state: r, url: h };
1159
+ }
1160
+ async loginWithPopup(e, t) {
1161
+ var n;
1162
+ if (e = e || {}, !(t = t || {}).popup && (t.popup = ((l) => {
1163
+ const u = window.screenX + (window.innerWidth - 400) / 2, p = window.screenY + (window.innerHeight - 600) / 2;
1164
+ return window.open(l, "auth0:authorize:popup", `left=${u},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`);
1165
+ })(""), !t.popup)) throw new re();
1166
+ const o = await this._prepareAuthorizeUrl(e.authorizationParams || {}, { response_mode: "web_message" }, window.location.origin);
1167
+ t.popup.location.href = o.url;
1168
+ const r = await ((l) => new Promise(((u, p) => {
1169
+ let s;
1170
+ const c = setInterval((() => {
1171
+ l.popup && l.popup.closed && (clearInterval(c), clearTimeout(h), window.removeEventListener("message", s, !1), p(new ie(l.popup)));
1172
+ }), 1e3), h = setTimeout((() => {
1173
+ clearInterval(c), p(new oe(l.popup)), window.removeEventListener("message", s, !1);
1174
+ }), 1e3 * (l.timeoutInSeconds || 60));
1175
+ s = function(d) {
1176
+ if (d.data && d.data.type === "authorization_response") {
1177
+ if (clearTimeout(h), clearInterval(c), window.removeEventListener("message", s, !1), l.closePopup !== !1 && l.popup.close(), d.data.response.error) return p(v.fromPayload(d.data.response));
1178
+ u(d.data.response);
1179
+ }
1180
+ }, window.addEventListener("message", s);
1181
+ })))(Object.assign(Object.assign({}, t), { timeoutInSeconds: t.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || 60 }));
1182
+ if (o.state !== r.state) throw new v("state_mismatch", "Invalid state");
1183
+ const a = ((n = e.authorizationParams) === null || n === void 0 ? void 0 : n.organization) || this.options.authorizationParams.organization;
1184
+ await this._requestToken({ audience: o.audience, scope: o.scope, code_verifier: o.code_verifier, grant_type: "authorization_code", code: r.code, redirect_uri: o.redirect_uri }, { nonceIn: o.nonce, organization: a });
1185
+ }
1186
+ async getUser() {
1187
+ var e;
1188
+ const t = await this._getIdTokenFromCache();
1189
+ return (e = t == null ? void 0 : t.decodedToken) === null || e === void 0 ? void 0 : e.user;
1190
+ }
1191
+ async getIdTokenClaims() {
1192
+ var e;
1193
+ const t = await this._getIdTokenFromCache();
1194
+ return (e = t == null ? void 0 : t.decodedToken) === null || e === void 0 ? void 0 : e.claims;
1195
+ }
1196
+ async loginWithRedirect(e = {}) {
1197
+ var t;
1198
+ const n = be(e), { openUrl: o, fragment: r, appState: a } = n, l = I(n, ["openUrl", "fragment", "appState"]), u = ((t = l.authorizationParams) === null || t === void 0 ? void 0 : t.organization) || this.options.authorizationParams.organization, p = await this._prepareAuthorizeUrl(l.authorizationParams || {}), { url: s } = p, c = I(p, ["url"]);
1199
+ this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, c), { appState: a, response_type: j.Code }), u && { organization: u }));
1200
+ const h = r ? `${s}#${r}` : s;
1201
+ o ? await o(h) : window.location.assign(h);
1202
+ }
1203
+ async handleRedirectCallback(e = window.location.href) {
1204
+ const t = e.split("?").slice(1);
1205
+ if (t.length === 0) throw new Error("There are no query params available for parsing.");
1206
+ const n = this.transactionManager.get();
1207
+ if (!n) throw new v("missing_transaction", "Invalid state");
1208
+ this.transactionManager.remove();
1209
+ const o = ((r) => {
1210
+ r.indexOf("#") > -1 && (r = r.substring(0, r.indexOf("#")));
1211
+ const a = new URLSearchParams(r);
1212
+ return { state: a.get("state"), code: a.get("code") || void 0, connect_code: a.get("connect_code") || void 0, error: a.get("error") || void 0, error_description: a.get("error_description") || void 0 };
1213
+ })(t.join(""));
1214
+ return n.response_type === j.ConnectCode ? this._handleConnectAccountRedirectCallback(o, n) : this._handleLoginRedirectCallback(o, n);
1215
+ }
1216
+ async _handleLoginRedirectCallback(e, t) {
1217
+ const { code: n, state: o, error: r, error_description: a } = e;
1218
+ if (r) throw new te(r, a || r, o, t.appState);
1219
+ if (!t.code_verifier || t.state && t.state !== o) throw new v("state_mismatch", "Invalid state");
1220
+ const l = t.organization, u = t.nonce, p = t.redirect_uri;
1221
+ return await this._requestToken(Object.assign({ audience: t.audience, scope: t.scope, code_verifier: t.code_verifier, grant_type: "authorization_code", code: n }, p ? { redirect_uri: p } : {}), { nonceIn: u, organization: l }), { appState: t.appState, response_type: j.Code };
1222
+ }
1223
+ async _handleConnectAccountRedirectCallback(e, t) {
1224
+ const { connect_code: n, state: o, error: r, error_description: a } = e;
1225
+ if (r) throw new ne(r, a || r, t.connection, o, t.appState);
1226
+ if (!n) throw new v("missing_connect_code", "Missing connect code");
1227
+ if (!(t.code_verifier && t.state && t.auth_session && t.redirect_uri && t.state === o)) throw new v("state_mismatch", "Invalid state");
1228
+ const l = await this.myAccountApi.completeAccount({ auth_session: t.auth_session, connect_code: n, redirect_uri: t.redirect_uri, code_verifier: t.code_verifier });
1229
+ return Object.assign(Object.assign({}, l), { appState: t.appState, response_type: j.ConnectCode });
1230
+ }
1231
+ async checkSession(e) {
1232
+ if (!this.cookieStorage.get(this.isAuthenticatedCookieName)) {
1233
+ if (!this.cookieStorage.get("auth0.is.authenticated")) return;
1234
+ this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove("auth0.is.authenticated");
1235
+ }
1236
+ try {
1237
+ await this.getTokenSilently(e);
1238
+ } catch {
1239
+ }
1240
+ }
1241
+ async getTokenSilently(e = {}) {
1242
+ var t, n;
1243
+ const o = Object.assign(Object.assign({ cacheMode: "on" }, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: H(this.scope, (t = e.authorizationParams) === null || t === void 0 ? void 0 : t.scope, ((n = e.authorizationParams) === null || n === void 0 ? void 0 : n.audience) || this.options.authorizationParams.audience) }) }), r = await ((a, l) => {
1244
+ let u = $[l];
1245
+ return u || (u = a().finally((() => {
1246
+ delete $[l], u = null;
1247
+ })), $[l] = u), u;
1248
+ })((() => this._getTokenSilently(o)), `${this.options.clientId}::${o.authorizationParams.audience}::${o.authorizationParams.scope}`);
1249
+ return e.detailedResponse ? r : r == null ? void 0 : r.access_token;
1250
+ }
1251
+ async _getTokenSilently(e) {
1252
+ const { cacheMode: t } = e, n = I(e, ["cacheMode"]);
1253
+ if (t !== "off") {
1254
+ const l = await this._getEntryFromCache({ scope: n.authorizationParams.scope, audience: n.authorizationParams.audience || "default", clientId: this.options.clientId, cacheMode: t });
1255
+ if (l) return l;
1256
+ }
1257
+ if (t === "cache-only") return;
1258
+ const o = (r = this.options.clientId, a = n.authorizationParams.audience || "default", `auth0.lock.getTokenSilently.${r}.${a}`);
1259
+ var r, a;
1260
+ if (!await ye((() => A.acquireLock(o, 5e3)), 10)) throw new N();
1261
+ this.activeLockKeys.add(o), this.activeLockKeys.size === 1 && window.addEventListener("pagehide", this._releaseLockOnPageHide);
1262
+ try {
1263
+ if (t !== "off") {
1264
+ const d = await this._getEntryFromCache({ scope: n.authorizationParams.scope, audience: n.authorizationParams.audience || "default", clientId: this.options.clientId });
1265
+ if (d) return d;
1266
+ }
1267
+ const l = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(n) : await this._getTokenFromIFrame(n), { id_token: u, token_type: p, access_token: s, oauthTokenScope: c, expires_in: h } = l;
1268
+ return Object.assign(Object.assign({ id_token: u, token_type: p, access_token: s }, c ? { scope: c } : null), { expires_in: h });
1269
+ } finally {
1270
+ await A.releaseLock(o), this.activeLockKeys.delete(o), this.activeLockKeys.size === 0 && window.removeEventListener("pagehide", this._releaseLockOnPageHide);
1271
+ }
1272
+ }
1273
+ async getTokenWithPopup(e = {}, t = {}) {
1274
+ var n, o;
1275
+ const r = Object.assign(Object.assign({}, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: H(this.scope, (n = e.authorizationParams) === null || n === void 0 ? void 0 : n.scope, ((o = e.authorizationParams) === null || o === void 0 ? void 0 : o.audience) || this.options.authorizationParams.audience) }) });
1276
+ return t = Object.assign(Object.assign({}, ze), t), await this.loginWithPopup(r, t), (await this.cacheManager.get(new S({ scope: r.authorizationParams.scope, audience: r.authorizationParams.audience || "default", clientId: this.options.clientId }), void 0, this.options.useMrrt)).access_token;
1277
+ }
1278
+ async isAuthenticated() {
1279
+ return !!await this.getUser();
1280
+ }
1281
+ _buildLogoutUrl(e) {
1282
+ e.clientId !== null ? e.clientId = e.clientId || this.options.clientId : delete e.clientId;
1283
+ const t = e.logoutParams || {}, { federated: n } = t, o = I(t, ["federated"]), r = n ? "&federated" : "";
1284
+ return this._url(`/v2/logout?${B(Object.assign({ clientId: e.clientId }, o))}`) + r;
1285
+ }
1286
+ async logout(e = {}) {
1287
+ var t;
1288
+ const n = be(e), { openUrl: o } = n, r = I(n, ["openUrl"]);
1289
+ 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@@"), await ((t = this.dpop) === null || t === void 0 ? void 0 : t.clear());
1290
+ const a = this._buildLogoutUrl(r);
1291
+ o ? await o(a) : o !== !1 && window.location.assign(a);
1292
+ }
1293
+ async _getTokenFromIFrame(e) {
1294
+ const t = `auth0.lock.getTokenFromIFrame.${this.options.clientId}`;
1295
+ if (!await ye((() => A.acquireLock(t, 5e3)), 10)) throw new N();
1296
+ try {
1297
+ const n = Object.assign(Object.assign({}, e.authorizationParams), { prompt: "none" }), o = this.cookieStorage.get(this.orgHintCookieName);
1298
+ o && !n.organization && (n.organization = o);
1299
+ const { url: r, state: a, nonce: l, code_verifier: u, redirect_uri: p, scope: s, audience: c } = await this._prepareAuthorizeUrl(n, { response_mode: "web_message" }, window.location.origin);
1300
+ if (window.crossOriginIsolated) throw new v("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
1301
+ const h = e.timeoutInSeconds || this.options.authorizeTimeoutInSeconds;
1302
+ let d;
1303
+ try {
1304
+ d = new URL(this.domainUrl).origin;
1305
+ } catch {
1306
+ d = this.domainUrl;
1307
+ }
1308
+ const m = await ((f, k, b = 60) => new Promise(((w, g) => {
1309
+ const _ = window.document.createElement("iframe");
1310
+ _.setAttribute("width", "0"), _.setAttribute("height", "0"), _.style.display = "none";
1311
+ const ce = () => {
1312
+ window.document.body.contains(_) && (window.document.body.removeChild(_), window.removeEventListener("message", Z, !1));
1313
+ };
1314
+ let Z;
1315
+ const Ke = setTimeout((() => {
1316
+ g(new N()), ce();
1317
+ }), 1e3 * b);
1318
+ Z = function(P) {
1319
+ if (P.origin != k || !P.data || P.data.type !== "authorization_response") return;
1320
+ const ue = P.source;
1321
+ ue && ue.close(), P.data.response.error ? g(v.fromPayload(P.data.response)) : w(P.data.response), clearTimeout(Ke), window.removeEventListener("message", Z, !1), setTimeout(ce, 2e3);
1322
+ }, window.addEventListener("message", Z, !1), window.document.body.appendChild(_), _.setAttribute("src", f);
1323
+ })))(r, d, h);
1324
+ if (a !== m.state) throw new v("state_mismatch", "Invalid state");
1325
+ const y = await this._requestToken(Object.assign(Object.assign({}, e.authorizationParams), { code_verifier: u, code: m.code, grant_type: "authorization_code", redirect_uri: p, timeout: e.authorizationParams.timeout || this.httpTimeoutMs }), { nonceIn: l, organization: n.organization });
1326
+ return Object.assign(Object.assign({}, y), { scope: s, oauthTokenScope: y.scope, audience: c });
1327
+ } catch (n) {
1328
+ throw n.error === "login_required" && this.logout({ openUrl: !1 }), n;
1329
+ } finally {
1330
+ await A.releaseLock(t);
1331
+ }
1332
+ }
1333
+ async _getTokenUsingRefreshToken(e) {
1334
+ const t = await this.cacheManager.get(new S({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId }), void 0, this.options.useMrrt);
1335
+ if (!(t && t.refresh_token || this.worker)) {
1336
+ if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1337
+ throw new F(e.authorizationParams.audience || "default", e.authorizationParams.scope);
1338
+ }
1339
+ const n = e.authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || window.location.origin, o = typeof e.timeoutInSeconds == "number" ? 1e3 * e.timeoutInSeconds : null, r = ((s, c, h, d) => {
1340
+ var m;
1341
+ if (s && h && d) {
1342
+ if (c.audience !== h) return c.scope;
1343
+ const y = d.split(" "), f = ((m = c.scope) === null || m === void 0 ? void 0 : m.split(" ")) || [], k = f.every(((b) => y.includes(b)));
1344
+ return y.length >= f.length && k ? d : c.scope;
1345
+ }
1346
+ return c.scope;
1347
+ })(this.options.useMrrt, e.authorizationParams, t == null ? void 0 : t.audience, t == null ? void 0 : t.scope);
1348
+ try {
1349
+ const s = await this._requestToken(Object.assign(Object.assign(Object.assign({}, e.authorizationParams), { grant_type: "refresh_token", refresh_token: t && t.refresh_token, redirect_uri: n }), o && { timeout: o }), { scopesToRequest: r });
1350
+ if (s.refresh_token && (t != null && t.refresh_token) && await this.cacheManager.updateEntry(t.refresh_token, s.refresh_token), this.options.useMrrt && (a = t == null ? void 0 : t.audience, l = t == null ? void 0 : t.scope, u = e.authorizationParams.audience, p = e.authorizationParams.scope, (a !== u || !ke(p, l)) && !ke(r, s.scope))) {
1351
+ if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1352
+ await this.cacheManager.remove(this.options.clientId, e.authorizationParams.audience, e.authorizationParams.scope);
1353
+ const c = ((h, d) => {
1354
+ const m = (h == null ? void 0 : h.split(" ")) || [], y = (d == null ? void 0 : d.split(" ")) || [];
1355
+ return m.filter(((f) => y.indexOf(f) == -1)).join(",");
1356
+ })(r, s.scope);
1357
+ throw new ae(e.authorizationParams.audience || "default", c);
1358
+ }
1359
+ return Object.assign(Object.assign({}, s), { scope: e.authorizationParams.scope, oauthTokenScope: s.scope, audience: e.authorizationParams.audience || "default" });
1360
+ } catch (s) {
1361
+ if ((s.message.indexOf("Missing Refresh Token") > -1 || s.message && s.message.indexOf("invalid refresh token") > -1) && this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
1362
+ throw s;
1363
+ }
1364
+ var a, l, u, p;
1365
+ }
1366
+ async _saveEntryInCache(e) {
1367
+ const { id_token: t, decodedToken: n } = e, o = I(e, ["id_token", "decodedToken"]);
1368
+ this.userCache.set("@@user@@", { id_token: t, decodedToken: n }), await this.cacheManager.setIdToken(this.options.clientId, e.id_token, e.decodedToken), await this.cacheManager.set(o);
1369
+ }
1370
+ async _getIdTokenFromCache() {
1371
+ const e = this.options.authorizationParams.audience || "default", t = this.scope[e], n = await this.cacheManager.getIdToken(new S({ clientId: this.options.clientId, audience: e, scope: t })), o = this.userCache.get("@@user@@");
1372
+ return n && n.id_token === (o == null ? void 0 : o.id_token) ? o : (this.userCache.set("@@user@@", n), n);
1373
+ }
1374
+ async _getEntryFromCache({ scope: e, audience: t, clientId: n, cacheMode: o }) {
1375
+ const r = await this.cacheManager.get(new S({ scope: e, audience: t, clientId: n }), 60, this.options.useMrrt, o);
1376
+ if (r && r.access_token) {
1377
+ const { token_type: a, access_token: l, oauthTokenScope: u, expires_in: p } = r, s = await this._getIdTokenFromCache();
1378
+ return s && Object.assign(Object.assign({ id_token: s.id_token, token_type: a || "Bearer", access_token: l }, u ? { scope: u } : null), { expires_in: p });
1379
+ }
1380
+ }
1381
+ async _requestToken(e, t) {
1382
+ var n, o;
1383
+ const { nonceIn: r, organization: a, scopesToRequest: l } = t || {}, u = await Ye(Object.assign(Object.assign({ baseUrl: this.domainUrl, client_id: this.options.clientId, auth0Client: this.options.auth0Client, useFormData: this.options.useFormData, timeout: this.httpTimeoutMs, useMrrt: this.options.useMrrt, dpop: this.dpop }, e), { scope: l || e.scope }), this.worker), p = await this._verifyIdToken(u.id_token, r, a);
1384
+ if (e.grant_type === "authorization_code") {
1385
+ const s = await this._getIdTokenFromCache();
1386
+ !((o = (n = s == null ? void 0 : s.decodedToken) === null || n === void 0 ? void 0 : n.claims) === null || o === void 0) && o.sub && s.decodedToken.claims.sub !== p.claims.sub && (await this.cacheManager.clear(this.options.clientId), this.userCache.remove("@@user@@"));
1387
+ }
1388
+ return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, u), { decodedToken: p, scope: e.scope, audience: e.audience || "default" }), u.scope ? { oauthTokenScope: u.scope } : null), { client_id: this.options.clientId })), this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this._processOrgHint(a || p.claims.org_id), Object.assign(Object.assign({}, u), { decodedToken: p });
1389
+ }
1390
+ async exchangeToken(e) {
1391
+ return this._requestToken({ grant_type: "urn:ietf:params:oauth:grant-type:token-exchange", subject_token: e.subject_token, subject_token_type: e.subject_token_type, scope: H(this.scope, e.scope, e.audience || this.options.authorizationParams.audience), audience: e.audience || this.options.authorizationParams.audience, organization: e.organization || this.options.authorizationParams.organization });
1392
+ }
1393
+ _assertDpop(e) {
1394
+ if (!e) throw new Error("`useDpop` option must be enabled before using DPoP.");
1395
+ }
1396
+ getDpopNonce(e) {
1397
+ return this._assertDpop(this.dpop), this.dpop.getNonce(e);
1398
+ }
1399
+ setDpopNonce(e, t) {
1400
+ return this._assertDpop(this.dpop), this.dpop.setNonce(e, t);
1401
+ }
1402
+ generateDpopProof(e) {
1403
+ return this._assertDpop(this.dpop), this.dpop.generateProof(e);
1404
+ }
1405
+ createFetcher(e = {}) {
1406
+ return new dt(e, { isDpopEnabled: () => !!this.options.useDpop, getAccessToken: (t) => {
1407
+ var n;
1408
+ return this.getTokenSilently({ authorizationParams: { scope: (n = t == null ? void 0 : t.scope) === null || n === void 0 ? void 0 : n.join(" "), audience: t == null ? void 0 : t.audience }, detailedResponse: !0 });
1409
+ }, getDpopNonce: () => this.getDpopNonce(e.dpopNonceId), setDpopNonce: (t) => this.setDpopNonce(t, e.dpopNonceId), generateDpopProof: (t) => this.generateDpopProof(t) });
1410
+ }
1411
+ async connectAccountWithRedirect(e) {
1412
+ const { openUrl: t, appState: n, connection: o, scopes: r, authorization_params: a, redirectUri: l = this.options.authorizationParams.redirect_uri || window.location.origin } = e;
1413
+ if (!o) throw new Error("connection is required");
1414
+ const u = M(R()), p = R(), s = await de(p), c = le(s), { connect_uri: h, connect_params: d, auth_session: m } = await this.myAccountApi.connectAccount({ connection: o, scopes: r, redirect_uri: l, state: u, code_challenge: c, code_challenge_method: "S256", authorization_params: a });
1415
+ this.transactionManager.create({ state: u, code_verifier: p, auth_session: m, redirect_uri: l, appState: n, connection: o, response_type: j.ConnectCode });
1416
+ const y = new URL(h);
1417
+ y.searchParams.set("ticket", d.ticket), t ? await t(y.toString()) : window.location.assign(y);
1418
+ }
1419
+ }
1420
+ export {
1421
+ lt as Auth0Client,
1422
+ te as AuthenticationError,
1423
+ S as CacheKey,
1424
+ ne as ConnectError,
1425
+ v as GenericError,
1426
+ Oe as InMemoryCache,
1427
+ $e as LocalStorageCache,
1428
+ se as MfaRequiredError,
1429
+ F as MissingRefreshTokenError,
1430
+ V as MyAccountApiError,
1431
+ ie as PopupCancelledError,
1432
+ re as PopupOpenError,
1433
+ oe as PopupTimeoutError,
1434
+ j as ResponseType,
1435
+ N as TimeoutError,
1436
+ G as UseDpopNonceError
1437
+ };
1438
+ //# sourceMappingURL=auth0-spa-js.production.esm-DL9f1uDJ.js.map