@machinemetrics/mm-react-embeddable 2.0.0-2 → 2.0.0-4

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.
@@ -1,7 +1,7 @@
1
- import E, { createContext as ce, useContext as Z, useState as M, useRef as R, useCallback as g, useEffect as w, useMemo as le } from "react";
2
- import U from "prop-types";
3
- import K from "styled-components";
4
- const Y = ce(null), J = ce({
1
+ import x, { createContext as ue, useContext as G, useState as C, useRef as b, useCallback as h, useEffect as T, useMemo as fe } from "react";
2
+ import w from "prop-types";
3
+ import se from "styled-components";
4
+ const re = ue(null), J = ue({
5
5
  pending: [],
6
6
  authorize: () => {
7
7
  },
@@ -14,69 +14,74 @@ const Y = ce(null), J = ce({
14
14
  originEpochs: {},
15
15
  credentials: {},
16
16
  unsupported: {}
17
- }), de = "access_token", re = (r) => r ? r.kind ? r : r.accessToken ? {
18
- kind: de,
19
- accessToken: r.accessToken,
20
- expiresAt: r.expiresAt || null
21
- } : null : null, fe = /* @__PURE__ */ new Set(["host_not_allowed", "invalid_token", "provider_unavailable"]), X = typeof window != "undefined" && window.location.protocol === "https:", pe = 8e3, Q = (r) => {
17
+ }), pe = "access_token", oe = (t) => t ? t.kind ? t : t.accessToken ? {
18
+ kind: pe,
19
+ accessToken: t.accessToken,
20
+ expiresAt: t.expiresAt || null
21
+ } : null : null, me = 60, he = 120, ge = /* @__PURE__ */ new Set([
22
+ "host_not_allowed",
23
+ "unbound_host_bound_guest",
24
+ "invalid_token",
25
+ "provider_unavailable"
26
+ ]), te = typeof window != "undefined" && window.location.protocol === "https:", be = 8e3, N = (t) => {
22
27
  try {
23
- return new URL(r).origin;
28
+ return new URL(t).origin;
24
29
  } catch {
25
30
  return null;
26
31
  }
27
- }, ne = (r, o) => {
28
- const c = o == null ? void 0 : o.origin;
29
- return !c || Q(r == null ? void 0 : r.authUrl) !== c ? null : c;
30
- }, oe = (r) => {
31
- if (!r || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(r) || r.includes(":"))
32
- return r;
33
- const o = r.split(".");
34
- return o.length <= 2 ? r : o.slice(-2).join(".");
35
- }, me = (r, o) => {
32
+ }, ie = (t, s) => {
33
+ const c = s == null ? void 0 : s.origin;
34
+ return !c || N(t == null ? void 0 : t.authUrl) !== c ? null : c;
35
+ }, ce = (t) => {
36
+ if (!t || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(t) || t.includes(":"))
37
+ return t;
38
+ const s = t.split(".");
39
+ return s.length <= 2 ? t : s.slice(-2).join(".");
40
+ }, Ee = (t, s) => {
36
41
  try {
37
- const c = new URL(r), a = new URL(o);
38
- return c.protocol !== a.protocol ? !0 : oe(c.hostname) !== oe(a.hostname);
42
+ const c = new URL(t), d = new URL(s);
43
+ return c.protocol !== d.protocol ? !0 : ce(c.hostname) !== ce(d.hostname);
39
44
  } catch {
40
45
  return !0;
41
46
  }
42
- }, he = (r, { onBlocked: o, onClosed: c }) => {
43
- const a = window.open(
44
- r.authUrl,
47
+ }, Re = (t, { onBlocked: s, onClosed: c }) => {
48
+ const d = window.open(
49
+ t.authUrl,
45
50
  "mm-embed-auth",
46
51
  "popup,width=600,height=700"
47
52
  );
48
- if (!a)
49
- return o(), () => {
53
+ if (!d)
54
+ return s(), () => {
50
55
  };
51
- const p = setInterval(() => {
52
- a.closed && (clearInterval(p), c());
56
+ const m = setInterval(() => {
57
+ d.closed && (clearInterval(m), c());
53
58
  }, 1e3);
54
- return () => clearInterval(p);
55
- }, ue = ({ children: r, launcher: o, broker: c }) => {
56
- const a = Z(Y), [p, m] = M({}), [L, T] = M({}), [y, d] = M({}), [I, C] = M({}), v = R(y);
57
- v.current = y;
58
- const b = R(p);
59
- b.current = p;
60
- const $ = R(null), G = R({}), O = R({}), j = R({}), P = R(c);
61
- P.current = c;
62
- const A = g((e) => {
63
- const t = O.current[e];
64
- if (!t)
59
+ return () => clearInterval(m);
60
+ }, ae = ({ children: t, launcher: s, broker: c }) => {
61
+ const d = G(re), [m, E] = C({}), [H, I] = C({}), [$, S] = C({}), [q, P] = C({}), Y = b($);
62
+ Y.current = $;
63
+ const R = b(m);
64
+ R.current = m;
65
+ const F = b(null), V = b({}), A = b({}), Z = b({}), y = b(c);
66
+ y.current = c;
67
+ const U = h((e) => {
68
+ const r = A.current[e];
69
+ if (!r)
65
70
  return;
66
- const n = (i) => !i[e] || i[e].clientId ? i : { ...i, [e]: { ...i[e], clientId: t } };
67
- m(n), C(n);
68
- }, []), u = g(
69
- (e, t) => {
70
- e && (C((n) => n[e] ? n : {
71
+ const n = (u) => !u[e] || u[e].clientId ? u : { ...u, [e]: { ...u[e], clientId: r } };
72
+ E(n), P(n);
73
+ }, []), i = h(
74
+ (e, r) => {
75
+ e && (P((n) => n[e] ? n : {
71
76
  ...n,
72
- [e]: { origin: e, reason: t, clientId: O.current[e] || null }
73
- }), A(e));
77
+ [e]: { origin: e, reason: r, clientId: A.current[e] || null }
78
+ }), U(e));
74
79
  },
75
- [A]
76
- ), l = g(
77
- (e, { v2: t = !1, origin: n = null } = {}) => {
78
- n && (t && v.current[n] || (m((i) => i[n] ? i : {
79
- ...i,
80
+ [U]
81
+ ), a = h(
82
+ (e, { v2: r = !1, origin: n = null } = {}) => {
83
+ n && (r && Y.current[n] || (E((u) => u[n] ? u : {
84
+ ...u,
80
85
  [n]: {
81
86
  origin: n,
82
87
  authUrl: e.authUrl,
@@ -84,61 +89,63 @@ const Y = ce(null), J = ce({
84
89
  // v2 entries try the invisible silent resolver first — but only on a host that can
85
90
  // frame login (https). Otherwise (and for legacy signals) go straight to interactive,
86
91
  // so an http host doesn't wait out a silent frame that can never load login.
87
- status: t && P.current ? "broker" : t && e.silentUrl && X ? "silent" : "interactive",
88
- v2: t,
92
+ status: r && y.current ? "broker" : r && e.silentUrl && te ? "silent" : "interactive",
93
+ v2: r,
89
94
  // v1.9: the scope the guest asked for; forwarded verbatim to the broker.
90
95
  scope: e.scope || null,
91
- acceptsCredentials: j.current[n] || null,
96
+ acceptsCredentials: Z.current[n] || null,
92
97
  consent: null,
93
98
  error: null,
94
99
  // clientId from the request payload (v2) or the cached init (legacy);
95
100
  // the host resolves the display name from it.
96
- clientId: e.clientId || O.current[n] || null,
101
+ clientId: e.clientId || A.current[n] || null,
97
102
  popupBlocked: !1
98
103
  }
99
- }), A(n)));
104
+ }), U(n)));
100
105
  },
101
- [A]
102
- ), s = g((e) => {
103
- m((t) => {
104
- if (!t[e])
105
- return t;
106
- const n = { ...t };
106
+ [U]
107
+ ), o = b({}), l = h((e) => {
108
+ o.current[e] && (clearTimeout(o.current[e]), delete o.current[e]);
109
+ }, []), f = h((e) => {
110
+ l(e), E((r) => {
111
+ if (!r[e])
112
+ return r;
113
+ const n = { ...r };
107
114
  return delete n[e], n;
108
115
  });
109
- }, []), f = g(
116
+ }, [l]), g = h(
110
117
  (e) => {
111
- e && (s(e), T((t) => ({
112
- ...t,
113
- [e]: (t[e] || 0) + 1
118
+ e && (f(e), I((r) => ({
119
+ ...r,
120
+ [e]: (r[e] || 0) + 1
114
121
  })));
115
122
  },
116
- [s]
117
- ), x = g((e) => {
118
- m((t) => !t[e] || t[e].status === "interactive" ? t : {
119
- ...t,
120
- [e]: { ...t[e], status: "interactive" }
123
+ [f]
124
+ ), O = h((e) => {
125
+ E((r) => !r[e] || r[e].status === "interactive" ? r : {
126
+ ...r,
127
+ [e]: { ...r[e], status: "interactive" }
121
128
  });
122
- }, []), z = g(
129
+ }, []), j = h(
123
130
  (e) => {
124
- s(e.origin);
131
+ f(e.origin);
125
132
  },
126
- [s]
127
- ), S = g(
128
- (e, t) => {
129
- const n = ne(e, t);
133
+ [f]
134
+ ), k = h(
135
+ (e, r) => {
136
+ const n = ie(e, r);
130
137
  if (n) {
131
- if (me(n, window.location.origin)) {
132
- u(n, "cross-site-legacy");
138
+ if (Ee(n, window.location.origin)) {
139
+ i(n, "cross-site-legacy");
133
140
  return;
134
141
  }
135
- l(e, { origin: n });
142
+ a(e, { origin: n });
136
143
  }
137
144
  },
138
- [l, u]
145
+ [a, i]
139
146
  );
140
- w(() => {
141
- if (!a)
147
+ T(() => {
148
+ if (!d)
142
149
  return;
143
150
  const e = [
144
151
  // `init` carries the app's OAuth clientId. Cache it by the ATTESTED app
@@ -147,168 +154,180 @@ const Y = ce(null), J = ce({
147
154
  // signals, so it is usually cached by the time an entry is created. The
148
155
  // clientId is only a lookup key: the host resolves the display name from
149
156
  // it, and a broker binds it to the attested origin server-side.
150
- a.addListener("*", "init", (t, n) => {
151
- n != null && n.origin && (t != null && t.clientId) && (O.current[n.origin] = t.clientId, A(n.origin)), n != null && n.origin && Array.isArray(t == null ? void 0 : t.acceptsCredentials) && (j.current[n.origin] = t.acceptsCredentials);
157
+ d.addListener("*", "init", (r, n) => {
158
+ n != null && n.origin && (r != null && r.clientId) && (A.current[n.origin] = r.clientId, U(n.origin)), n != null && n.origin && Array.isArray(r == null ? void 0 : r.acceptsCredentials) && (Z.current[n.origin] = r.acceptsCredentials);
152
159
  }),
153
- a.addListener("*", "authorize", S),
154
- a.addListener("*", "login", S),
155
- a.addListener(
160
+ d.addListener("*", "authorize", k),
161
+ d.addListener("*", "login", k),
162
+ d.addListener(
156
163
  "*",
157
164
  "credential-request",
158
- (t, n) => l(t, { v2: !0, origin: ne(t, n) })
165
+ (r, n) => a(r, { v2: !0, origin: ie(r, n) })
159
166
  )
160
167
  ];
161
- return () => e.forEach((t) => t());
162
- }, [a, S, l, A]), w(() => {
163
- const e = (t) => {
164
- const n = t == null ? void 0 : t.data;
168
+ return () => e.forEach((r) => r());
169
+ }, [d, k, a, U]), T(() => {
170
+ const e = (r) => {
171
+ const n = r == null ? void 0 : r.data;
165
172
  if (!n || n.type !== "authorized" && n.type !== "authorize-failed")
166
173
  return;
167
- const i = Q(n.authUrl);
168
- if (!(!i || t.origin !== i)) {
174
+ const u = N(n.authUrl);
175
+ if (!(!u || r.origin !== u)) {
169
176
  if (n.type === "authorized") {
170
177
  if (n.accessToken) {
171
- if (!b.current[i])
178
+ if (!R.current[u])
172
179
  return;
173
- d((h) => ({
174
- ...h,
175
- [i]: re({ accessToken: n.accessToken })
176
- })), s(i);
180
+ S((p) => ({
181
+ ...p,
182
+ [u]: oe({ accessToken: n.accessToken })
183
+ })), f(u);
177
184
  } else
178
- f(i);
185
+ g(u);
179
186
  return;
180
187
  }
181
- x(i);
188
+ O(u);
182
189
  }
183
190
  };
184
191
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
185
- }, [s, f, x]);
186
- const _ = g(
187
- (e, t) => {
188
- const n = e == null ? void 0 : e.origin, i = re(t);
189
- !n || !i || (d((h) => ({ ...h, [n]: i })), s(n));
192
+ }, [f, g, O]);
193
+ const B = h(
194
+ (e, r) => {
195
+ const n = e == null ? void 0 : e.origin, u = oe(r);
196
+ !n || !u || (S((p) => ({ ...p, [n]: u })), f(n));
190
197
  },
191
- [s]
192
- ), k = g((e, t) => {
193
- m((n) => n[e] ? { ...n, [e]: { ...n[e], ...t } } : n);
194
- }, []), F = g(
195
- async (e, { approve: t } = {}) => {
196
- const n = P.current, { origin: i } = e;
197
- let h;
198
+ [f]
199
+ ), z = h((e, r) => {
200
+ E((n) => n[e] ? { ...n, [e]: { ...n[e], ...r } } : n);
201
+ }, []), L = b({}), M = h(
202
+ async (e, { approve: r } = {}) => {
203
+ const n = y.current, { origin: u } = e;
204
+ let p;
198
205
  try {
199
- h = await n(
200
- { origin: i, clientId: e.clientId, scope: e.scope, authUrl: e.authUrl },
201
- { approve: t }
206
+ p = await n(
207
+ { origin: u, clientId: e.clientId, scope: e.scope, authUrl: e.authUrl },
208
+ { approve: r }
202
209
  );
203
210
  } catch {
204
- t ? k(i, { error: { reason: "broker_unavailable" } }) : k(i, {
205
- status: e.silentUrl && X ? "silent" : "interactive"
211
+ r ? z(u, { error: { reason: "broker_unavailable" } }) : z(u, {
212
+ status: e.silentUrl && te ? "silent" : "interactive"
206
213
  });
207
214
  return;
208
215
  }
209
- if ((h == null ? void 0 : h.status) === 200 && h.credential) {
210
- _(e, h.credential);
216
+ if ((p == null ? void 0 : p.status) === 200 && p.credential) {
217
+ B(e, p.credential);
211
218
  return;
212
219
  }
213
- if ((h == null ? void 0 : h.status) === 409 && h.consentRequired) {
214
- k(i, {
220
+ if ((p == null ? void 0 : p.status) === 409 && p.consentRequired) {
221
+ z(u, {
215
222
  status: "interactive",
216
223
  consent: {
217
- client: h.client || null,
218
- stepUp: !!h.stepUp,
219
- scope: h.scope || e.scope
224
+ client: p.client || null,
225
+ stepUp: !!p.stepUp,
226
+ scope: p.scope || e.scope
220
227
  },
221
228
  error: null
222
229
  });
223
230
  return;
224
231
  }
225
- const N = (h == null ? void 0 : h.error) || "broker_error";
226
- if (!t && fe.has(N)) {
227
- k(i, {
228
- status: e.silentUrl && X ? "silent" : "interactive"
232
+ const Q = (p == null ? void 0 : p.error) || "broker_error";
233
+ if (!r && ge.has(Q)) {
234
+ z(u, {
235
+ status: e.silentUrl && te ? "silent" : "interactive"
229
236
  });
230
237
  return;
231
238
  }
232
- if (t && N === "consent_denied") {
233
- k(i, { error: null });
239
+ if (r && Q === "consent_denied") {
240
+ z(u, { error: null });
234
241
  return;
235
242
  }
236
- s(i), C((te) => ({
237
- ...te,
238
- [i]: {
239
- origin: i,
240
- reason: `broker:${N}`,
241
- detail: h || null,
242
- clientId: e.clientId || O.current[i] || null
243
+ if (Q === "rate_limited" && !e.rateLimitRetried) {
244
+ const ee = Math.min(
245
+ Number(p == null ? void 0 : p.retryAfter) > 0 ? Number(p.retryAfter) : me,
246
+ he
247
+ ), de = { ...e, rateLimitRetried: !0 };
248
+ l(u), o.current[u] = setTimeout(() => {
249
+ delete o.current[u], L.current[u] = !0, v.current(de, { approve: r }).finally(() => {
250
+ delete L.current[u];
251
+ });
252
+ }, ee * 1e3), z(u, { rateLimitRetried: !0 });
253
+ return;
254
+ }
255
+ f(u), P((ee) => ({
256
+ ...ee,
257
+ [u]: {
258
+ origin: u,
259
+ reason: `broker:${Q}`,
260
+ detail: p || null,
261
+ clientId: e.clientId || A.current[u] || null
243
262
  }
244
263
  }));
245
264
  },
246
- [_, k, s]
247
- ), q = R({});
248
- w(() => {
249
- Object.values(p).forEach((e) => {
250
- e.status !== "broker" || q.current[e.origin] || (q.current[e.origin] = !0, F(e).finally(() => {
251
- delete q.current[e.origin];
265
+ [B, z, f, l]
266
+ ), v = b(M);
267
+ v.current = M, T(() => {
268
+ Object.values(m).forEach((e) => {
269
+ e.status !== "broker" || L.current[e.origin] || o.current[e.origin] || (L.current[e.origin] = !0, M(e).finally(() => {
270
+ delete L.current[e.origin];
252
271
  }));
253
272
  });
254
- }, [p, F]);
255
- const B = g(
256
- (e) => !P.current || !(e != null && e.consent) ? Promise.resolve() : F(e, { approve: !0 }),
257
- [F]
273
+ }, [m, M]);
274
+ const K = h(
275
+ (e) => !y.current || !(e != null && e.consent) ? Promise.resolve() : M(e, { approve: !0 }),
276
+ [M]
258
277
  );
259
- w(() => {
260
- const e = G.current;
261
- Object.values(p).forEach((t) => {
262
- t.status === "silent" && !e[t.origin] && (e[t.origin] = setTimeout(() => {
263
- delete e[t.origin], x(t.origin);
264
- }, pe));
265
- }), Object.keys(e).forEach((t) => {
266
- (!p[t] || p[t].status !== "silent") && (clearTimeout(e[t]), delete e[t]);
278
+ T(() => {
279
+ const e = V.current;
280
+ Object.values(m).forEach((r) => {
281
+ r.status === "silent" && !e[r.origin] && (e[r.origin] = setTimeout(() => {
282
+ delete e[r.origin], O(r.origin);
283
+ }, be));
284
+ }), Object.keys(e).forEach((r) => {
285
+ (!m[r] || m[r].status !== "silent") && (clearTimeout(e[r]), delete e[r]);
267
286
  });
268
- }, [p, x]), w(() => () => {
269
- $.current && $.current(), Object.values(G.current).forEach(clearTimeout);
287
+ }, [m, O]), T(() => () => {
288
+ F.current && F.current(), Object.values(V.current).forEach(clearTimeout), Object.values(o.current).forEach(clearTimeout);
270
289
  }, []);
271
- const D = g(
290
+ const W = h(
272
291
  (e) => {
273
- $.current && ($.current(), $.current = null);
274
- const t = o || he;
275
- $.current = t(e, {
292
+ F.current && (F.current(), F.current = null);
293
+ const r = s || Re;
294
+ F.current = r(e, {
276
295
  onBlocked: () => {
277
- m((n) => n[e.origin] ? {
296
+ E((n) => n[e.origin] ? {
278
297
  ...n,
279
298
  [e.origin]: { ...n[e.origin], popupBlocked: !0 }
280
299
  } : n);
281
300
  },
282
301
  onClosed: () => {
283
302
  if (e.v2) {
284
- X && m((n) => !n[e.origin] || !n[e.origin].silentUrl ? n : {
303
+ te && E((n) => !n[e.origin] || !n[e.origin].silentUrl ? n : {
285
304
  ...n,
286
305
  [e.origin]: { ...n[e.origin], status: "silent" }
287
306
  });
288
307
  return;
289
308
  }
290
- f(e.origin);
309
+ g(e.origin);
291
310
  }
292
311
  });
293
312
  },
294
- [o, f]
295
- ), H = {
313
+ [s, g]
314
+ ), _ = {
296
315
  // Hosts render UI for interactive entries only; silent resolution is
297
316
  // invisible by design.
298
- pending: Object.values(p).filter(
317
+ pending: Object.values(m).filter(
299
318
  (e) => e.status === "interactive"
300
319
  ),
301
- authorize: D,
302
- approve: B,
303
- complete: _,
304
- dismiss: z,
305
- originEpochs: L,
306
- credentials: y,
307
- unsupported: I
308
- }, W = Object.values(p).filter(
320
+ authorize: W,
321
+ approve: K,
322
+ complete: B,
323
+ dismiss: j,
324
+ originEpochs: H,
325
+ credentials: $,
326
+ unsupported: q
327
+ }, D = Object.values(m).filter(
309
328
  (e) => e.status === "silent" && e.silentUrl
310
329
  );
311
- return /* @__PURE__ */ E.createElement(J.Provider, { value: H }, r, W.map((e) => /* @__PURE__ */ E.createElement(
330
+ return /* @__PURE__ */ x.createElement(J.Provider, { value: _ }, t, D.map((e) => /* @__PURE__ */ x.createElement(
312
331
  "iframe",
313
332
  {
314
333
  key: `mm-silent-auth-${e.origin}`,
@@ -320,9 +339,9 @@ const Y = ce(null), J = ce({
320
339
  }
321
340
  )));
322
341
  };
323
- ue.propTypes = {
324
- children: U.node,
325
- launcher: U.func,
342
+ ae.propTypes = {
343
+ children: w.node,
344
+ launcher: w.func,
326
345
  /**
327
346
  * `async (request, { approve }) => result` where request =
328
347
  * `{ origin, clientId, scope, authUrl }` (origin is the zone-attested frame origin) and result
@@ -330,169 +349,169 @@ ue.propTypes = {
330
349
  * client }`, `{ status: 409, consentRequired: true, client: { name, hostname }, stepUp }`, or
331
350
  * `{ status, error }`. Provided only by hosts that are themselves first-party clients.
332
351
  */
333
- broker: U.func
352
+ broker: w.func
334
353
  };
335
- const ge = () => Z(J), be = (r) => {
336
- const { originEpochs: o } = Z(J), c = Q(r);
337
- return c && o[c] || 0;
338
- }, Ee = (r) => {
339
- const { credentials: o } = Z(J), c = Q(r);
340
- return c && o[c] || null;
341
- }, ke = (r) => {
342
- const { unsupported: o } = Z(J), c = Q(r);
343
- return c && o[c] || null;
344
- }, we = ({ children: r, authorizationLauncher: o, credentialBroker: c }) => {
345
- const [a, p] = M({}), [m, L] = M({}), T = R({}), y = R({}), d = R({}), I = g((u, l) => {
346
- var s;
347
- return !!((s = d.current[u]) != null && s.has(l));
348
- }, []), C = g((u, l, s) => {
349
- p((f) => ({ ...f, [u]: { origin: l, frameRef: s } }));
350
- }, []), v = g((u) => {
351
- p((l) => {
352
- const s = { ...l };
353
- return delete s[u], s;
354
- }), L((l) => {
355
- const s = { ...l };
356
- return delete s[u], s;
357
- }), delete d.current[u];
354
+ const Pe = () => G(J), Te = (t) => {
355
+ const { originEpochs: s } = G(J), c = N(t);
356
+ return c && s[c] || 0;
357
+ }, ke = (t) => {
358
+ const { credentials: s } = G(J), c = N(t);
359
+ return c && s[c] || null;
360
+ }, we = (t) => {
361
+ const { unsupported: s } = G(J), c = N(t);
362
+ return c && s[c] || null;
363
+ }, Ie = ({ children: t, authorizationLauncher: s, credentialBroker: c }) => {
364
+ const [d, m] = C({}), [E, H] = C({}), I = b({}), $ = b({}), S = b({}), q = h((i, a) => {
365
+ var o;
366
+ return !!((o = S.current[i]) != null && o.has(a));
367
+ }, []), P = h((i, a, o) => {
368
+ m((l) => ({ ...l, [i]: { origin: a, frameRef: o } }));
369
+ }, []), Y = h((i) => {
370
+ m((a) => {
371
+ const o = { ...a };
372
+ return delete o[i], o;
373
+ }), H((a) => {
374
+ const o = { ...a };
375
+ return delete o[i], o;
376
+ }), delete S.current[i];
358
377
  }, []);
359
- w(() => {
360
- const u = (s = [], f, x) => {
361
- s.forEach((z) => z(f, x));
362
- }, l = (s) => {
363
- var F, q, B, D, H, W, e;
364
- if (!((F = s == null ? void 0 : s.data) != null && F.instanceId))
378
+ T(() => {
379
+ const i = (o = [], l, f) => {
380
+ o.forEach((g) => g(l, f));
381
+ }, a = (o) => {
382
+ var B, z, L, M, v, K, W;
383
+ if (!((B = o == null ? void 0 : o.data) != null && B.instanceId))
365
384
  return;
366
- const { instanceId: f, type: x } = s.data, z = a[f], S = (B = (q = z == null ? void 0 : z.frameRef) == null ? void 0 : q.current) == null ? void 0 : B.contentWindow;
367
- if (!S || s.source !== S || s.origin !== z.origin)
385
+ const { instanceId: l, type: f } = o.data, g = d[l], O = (L = (z = g == null ? void 0 : g.frameRef) == null ? void 0 : z.current) == null ? void 0 : L.contentWindow;
386
+ if (!O || o.source !== O || o.origin !== g.origin)
368
387
  return;
369
- const _ = { origin: s.origin }, k = T.current;
370
- if (x === "response") {
371
- const { callbackId: t, response: n, error: i } = s.data, h = y.current[t];
372
- h && (h(n, i), delete y.current[t]);
388
+ const j = { origin: o.origin }, k = I.current;
389
+ if (f === "response") {
390
+ const { callbackId: _, response: D, error: e } = o.data, r = $.current[_];
391
+ r && (r(D, e), delete $.current[_]);
373
392
  return;
374
393
  }
375
- if (x === "mark-registered") {
376
- const { requestType: t } = s.data;
377
- d.current[f] || (d.current[f] = /* @__PURE__ */ new Set()), d.current[f].add(t);
394
+ if (f === "mark-registered") {
395
+ const { requestType: _ } = o.data;
396
+ S.current[l] || (S.current[l] = /* @__PURE__ */ new Set()), S.current[l].add(_);
378
397
  return;
379
398
  }
380
- x === "ready" && L((t) => ({ ...t, [f]: !0 })), u((D = k[f]) == null ? void 0 : D[x], s.data, _), u((H = k["*"]) == null ? void 0 : H[x], s.data, _), u((W = k[f]) == null ? void 0 : W["*"], s.data, _), u((e = k["*"]) == null ? void 0 : e["*"], s.data, _);
399
+ f === "ready" && H((_) => ({ ..._, [l]: !0 })), i((M = k[l]) == null ? void 0 : M[f], o.data, j), i((v = k["*"]) == null ? void 0 : v[f], o.data, j), i((K = k[l]) == null ? void 0 : K["*"], o.data, j), i((W = k["*"]) == null ? void 0 : W["*"], o.data, j);
381
400
  };
382
- return window.addEventListener("message", l), () => {
383
- window.removeEventListener("message", l);
401
+ return window.addEventListener("message", a), () => {
402
+ window.removeEventListener("message", a);
384
403
  };
385
- }, [a]);
386
- const b = g(
387
- (u, l, s) => {
388
- var x, z;
389
- const f = a[u];
390
- if (!f) {
391
- console.warn(`Origin not set for id: ${u}. Unable to send message.`);
404
+ }, [d]);
405
+ const R = h(
406
+ (i, a, o) => {
407
+ var f, g;
408
+ const l = d[i];
409
+ if (!l) {
410
+ console.warn(`Origin not set for id: ${i}. Unable to send message.`);
392
411
  return;
393
412
  }
394
- (z = (x = f == null ? void 0 : f.frameRef) == null ? void 0 : x.current) != null && z.contentWindow && f.frameRef.current.contentWindow.postMessage(
395
- { type: l, ...s, instanceId: u },
396
- f.origin
413
+ (g = (f = l == null ? void 0 : l.frameRef) == null ? void 0 : f.current) != null && g.contentWindow && l.frameRef.current.contentWindow.postMessage(
414
+ { type: a, ...o, instanceId: i },
415
+ l.origin
397
416
  );
398
417
  },
399
- [a]
400
- ), $ = R(0), G = g(() => `${Date.now()}-${++$.current}`, []), O = g(
401
- async (u, l, s = {}) => new Promise((f, x) => {
402
- const z = G(), S = (_, k) => {
403
- delete y.current[z], k ? x(k) : f(_);
418
+ [d]
419
+ ), F = b(0), V = h(() => `${Date.now()}-${++F.current}`, []), A = h(
420
+ async (i, a, o = {}) => new Promise((l, f) => {
421
+ const g = V(), O = (j, k) => {
422
+ delete $.current[g], k ? f(k) : l(j);
404
423
  };
405
- y.current[z] = S, b(u, "request", { callbackId: z, requestType: l, data: s });
424
+ $.current[g] = O, R(i, "request", { callbackId: g, requestType: a, data: o });
406
425
  }),
407
- [b]
408
- ), j = g(
409
- (u, l) => {
410
- b(u, "load-options", l);
426
+ [R]
427
+ ), Z = h(
428
+ (i, a) => {
429
+ R(i, "load-options", a);
411
430
  },
412
- [b]
413
- ), P = g(
414
- (u, l) => {
415
- b(u, "validate", l);
431
+ [R]
432
+ ), y = h(
433
+ (i, a) => {
434
+ R(i, "validate", a);
416
435
  },
417
- [b]
418
- ), A = le(
436
+ [R]
437
+ ), U = fe(
419
438
  () => ({
420
- registerFrame: C,
421
- unregisterFrame: v,
422
- sendMessage: b,
423
- sendRequest: O,
424
- loadOptions: j,
425
- validate: P,
426
- hasHandler: I,
427
- readyFrames: m,
428
- addListener: (u, l, s) => (T.current[u] || (T.current[u] = {}), T.current[u][l] || (T.current[u][l] = []), T.current[u][l].push(s), () => {
429
- T.current[u][l] = T.current[u][l].filter((f) => f !== s);
439
+ registerFrame: P,
440
+ unregisterFrame: Y,
441
+ sendMessage: R,
442
+ sendRequest: A,
443
+ loadOptions: Z,
444
+ validate: y,
445
+ hasHandler: q,
446
+ readyFrames: E,
447
+ addListener: (i, a, o) => (I.current[i] || (I.current[i] = {}), I.current[i][a] || (I.current[i][a] = []), I.current[i][a].push(o), () => {
448
+ I.current[i][a] = I.current[i][a].filter((l) => l !== o);
430
449
  })
431
450
  }),
432
451
  [
433
- C,
434
- v,
435
- b,
436
- O,
437
- j,
438
452
  P,
439
- I,
440
- m
453
+ Y,
454
+ R,
455
+ A,
456
+ Z,
457
+ y,
458
+ q,
459
+ E
441
460
  ]
442
461
  );
443
- return /* @__PURE__ */ E.createElement(Y.Provider, { value: A }, /* @__PURE__ */ E.createElement(ue, { launcher: o, broker: c }, r));
444
- }, V = (r, o, c) => {
445
- const a = Z(Y);
446
- if (a === null)
462
+ return /* @__PURE__ */ x.createElement(re.Provider, { value: U }, /* @__PURE__ */ x.createElement(ae, { launcher: s, broker: c }, t));
463
+ }, X = (t, s, c) => {
464
+ const d = G(re);
465
+ if (d === null)
447
466
  throw new Error(
448
467
  "useEmbeddedEffect must be used within a MMEmbeddableZoneProvider"
449
468
  );
450
- const p = R(c);
451
- w(() => {
452
- p.current = c;
453
- }, [c]), w(() => {
454
- if (!(!r || !o)) {
455
- if (o.startsWith("key:")) {
456
- const m = o.substring(4);
457
- return a.readyFrames[r] && a.sendMessage(r, "subscribe-key", { keyChord: m }), a.addListener(
458
- r,
459
- `key-pressed:${m}`,
460
- (...T) => p.current(...T)
469
+ const m = b(c);
470
+ T(() => {
471
+ m.current = c;
472
+ }, [c]), T(() => {
473
+ if (!(!t || !s)) {
474
+ if (s.startsWith("key:")) {
475
+ const E = s.substring(4);
476
+ return d.readyFrames[t] && d.sendMessage(t, "subscribe-key", { keyChord: E }), d.addListener(
477
+ t,
478
+ `key-pressed:${E}`,
479
+ (...I) => m.current(...I)
461
480
  );
462
481
  }
463
- return a.addListener(
464
- r,
465
- o,
466
- (...m) => p.current(...m)
482
+ return d.addListener(
483
+ t,
484
+ s,
485
+ (...E) => m.current(...E)
467
486
  );
468
487
  }
469
- }, [a, r, o]);
488
+ }, [d, t, s]);
470
489
  };
471
- we.propTypes = {
472
- children: U.node.isRequired,
490
+ Ie.propTypes = {
491
+ children: w.node.isRequired,
473
492
  /**
474
493
  * Optional interactive-step launcher for embedded authorizations,
475
494
  * `(entry, { onBlocked, onClosed }) => cleanup`. Defaults to a top-level
476
495
  * popup. Hosts that cannot open windows (Android WebView shells) drive
477
496
  * their own UI from useEmbeddedAuthorizations() instead.
478
497
  */
479
- authorizationLauncher: U.func,
498
+ authorizationLauncher: w.func,
480
499
  /**
481
500
  * Optional credential broker for hosts that are first-party MachineMetrics clients
482
501
  * (`async (request, { approve }) => result`, see EmbeddedAuthorizationManager). When present,
483
502
  * v2 credential requests are brokered server-side (no popup, no hidden frame) and consent is
484
503
  * rendered natively by the host from the broker's `client` identity.
485
504
  */
486
- credentialBroker: U.func
505
+ credentialBroker: w.func
487
506
  };
488
- const ee = K.default || K, Re = 1e4, xe = "credentials", Te = (r, o) => `${r}/mm-embedded-interop?id=${encodeURIComponent(o)}&origin=${encodeURIComponent(
507
+ const ne = se.default || se, _e = 1e4, Ue = "credentials", Le = (t, s) => `${t}/mm-embedded-interop?id=${encodeURIComponent(s)}&origin=${encodeURIComponent(
489
508
  window.location.origin
490
- )}&caps=${xe}`, Ie = ee.iframe`
509
+ )}&caps=${Ue}`, Me = ne.iframe`
491
510
  width: 100%;
492
511
  height: 100%;
493
512
  border: none;
494
- visibility: ${(r) => r.$isReady ? "visible" : "hidden"};
495
- `, ze = ee.div`
513
+ visibility: ${(t) => t.$isReady ? "visible" : "hidden"};
514
+ `, Ce = ne.div`
496
515
  width: 100%;
497
516
  height: 100%;
498
517
  display: flex;
@@ -505,265 +524,182 @@ const ee = K.default || K, Re = 1e4, xe = "credentials", Te = (r, o) => `${r}/mm
505
524
  text-align: center;
506
525
  color: #555;
507
526
  font-size: 14px;
508
- `, Ue = (r) => {
509
- const o = r && r.origin || "This app", c = r && r.reason || "";
527
+ `, Ae = (t) => {
528
+ const s = t && t.origin || "This app", c = t && t.reason || "";
510
529
  switch (c) {
511
530
  case "broker:scope_above_ceiling":
512
531
  return {
513
- title: `${o} can’t be authorized here`,
532
+ title: `${s} can’t be authorized here`,
514
533
  detail: "It asks for permissions your role doesn’t have."
515
534
  };
516
535
  case "broker:origin_mismatch":
517
536
  case "broker:unknown_client":
518
537
  return {
519
- title: `${o} can’t be authorized here`,
538
+ title: `${s} can’t be authorized here`,
520
539
  detail: "It isn’t registered to run at this address."
521
540
  };
522
541
  case "broker:cross_company_principal":
523
542
  return {
524
- title: `${o} can’t be authorized here`,
543
+ title: `${s} can’t be authorized here`,
525
544
  detail: "It can’t be authorized for this account."
526
545
  };
527
546
  default:
528
547
  return c.startsWith("broker:") ? {
529
- title: `${o} can’t be authorized here`,
548
+ title: `${s} can’t be authorized here`,
530
549
  detail: "Authorization was refused."
531
550
  } : {
532
- title: `${o} can’t be embedded here`,
551
+ title: `${s} can’t be embedded here`,
533
552
  detail: "It needs an update to support embedding from a different domain."
534
553
  };
535
554
  }
536
- }, ae = ({ entry: r }) => {
537
- const o = Ue(r);
538
- return /* @__PURE__ */ E.createElement(ze, { "data-reason": r && r.reason || void 0 }, /* @__PURE__ */ E.createElement("div", { style: { fontWeight: 600 } }, o.title), /* @__PURE__ */ E.createElement("div", { style: { fontSize: 12, color: "#888" } }, o.detail));
555
+ }, le = ({ entry: t }) => {
556
+ const s = Ae(t);
557
+ return /* @__PURE__ */ x.createElement(Ce, { "data-reason": t && t.reason || void 0 }, /* @__PURE__ */ x.createElement("div", { style: { fontWeight: 600 } }, s.title), /* @__PURE__ */ x.createElement("div", { style: { fontSize: 12, color: "#888" } }, s.detail));
539
558
  };
540
- ae.propTypes = {
541
- entry: U.shape({
542
- origin: U.string,
543
- name: U.string,
544
- reason: U.string,
545
- detail: U.object
559
+ le.propTypes = {
560
+ entry: w.shape({
561
+ origin: w.string,
562
+ name: w.string,
563
+ reason: w.string,
564
+ detail: w.object
546
565
  })
547
566
  };
548
- const ye = ee.div`
567
+ const Oe = ne.div`
549
568
  height: 100%;
550
569
  display: flex;
551
570
  flex: 1;
552
571
  align-items: center;
553
572
  justify-content: center;
554
- `, Ce = () => /* @__PURE__ */ E.createElement(ye, null, /* @__PURE__ */ E.createElement("div", { style: { textAlign: "center" } }, "This app couldn’t be loaded as an embeddable widget.")), Ae = ({
555
- id: r,
556
- src: o,
573
+ `, ze = () => /* @__PURE__ */ x.createElement(Oe, null, /* @__PURE__ */ x.createElement("div", { style: { textAlign: "center" } }, "This app couldn’t be loaded as an embeddable widget.")), xe = ({
574
+ id: t,
575
+ src: s,
557
576
  path: c,
558
- onInit: a = () => {
577
+ onInit: d = () => {
559
578
  },
560
- onTimeout: p,
561
- context: m = {},
562
- params: L = {},
563
- renderUnsupported: T,
564
- renderTimeout: y,
565
- ...d
579
+ onTimeout: m,
580
+ context: E = {},
581
+ params: H = {},
582
+ renderUnsupported: I,
583
+ renderTimeout: $,
584
+ ...S
566
585
  }) => {
567
- if ("isConfiguring" in d)
586
+ if ("isConfiguring" in S)
568
587
  return console.error(
569
588
  "isConfiguring must be passed via the params prop to MMEmbeddableZone"
570
589
  ), null;
571
- if ("colorMode" in m)
590
+ if ("colorMode" in E)
572
591
  return console.error(
573
592
  "colorMode must be passed via the params prop to MMEmbeddableZone"
574
593
  ), null;
575
- if ("isFullScreen" in m)
594
+ if ("isFullScreen" in E)
576
595
  return console.error(
577
596
  "isFullScreen must be passed via the params prop to MMEmbeddableZone"
578
597
  ), null;
579
- const I = R(), [C, v] = M(), [b, $] = M(0), [G, O] = M(!1), [j, P] = M(!1), A = be(o), u = Ee(o), l = ke(o), [s, f] = M(0), [x, z] = M(null), { registerFrame: S, unregisterFrame: _, sendMessage: k } = Z(
580
- Y
581
- ), [F, q] = M(), B = R(), D = R(p), H = R(a), W = R(!1), e = g(() => {
582
- W.current = !1, clearTimeout(B.current), $(0), O(!1), P(!1), z(null);
598
+ const q = b(), [P, Y] = C(), [R, F] = C(0), [V, A] = C(!1), [Z, y] = C(!1), U = Te(s), i = ke(s), a = we(s), [o, l] = C(0), [f, g] = C(null), { registerFrame: O, unregisterFrame: j, sendMessage: k } = G(
599
+ re
600
+ ), [B, z] = C(), L = b(), M = b(m), v = b(d), K = b(!1), W = h(() => {
601
+ K.current = !1, clearTimeout(L.current), F(0), A(!1), y(!1), g(null);
583
602
  }, []);
584
- w(() => {
585
- (A > 0 || s > 0) && e();
586
- }, [A, s, e]), w(() => {
587
- D.current = p;
588
- }, [p]), w(() => {
589
- H.current = a;
590
- }, [a]), w(() => {
591
- b && k(r, "set-context", {
603
+ T(() => {
604
+ (U > 0 || o > 0) && W();
605
+ }, [U, o, W]), T(() => {
606
+ M.current = m;
607
+ }, [m]), T(() => {
608
+ v.current = d;
609
+ }, [d]), T(() => {
610
+ R && k(t, "set-context", {
592
611
  context: {
593
- ...m
612
+ ...E
594
613
  }
595
614
  });
596
- }, [m, r, b]), w(() => {
597
- b && k(r, "set-params", { params: L });
598
- }, [L, r, b]), w(() => {
599
- c !== void 0 && q((c == null ? void 0 : c.indexOf("/")) === 0 ? c : `/${c}`);
600
- }, [c]), w(() => {
601
- F === void 0 || !b || k(r, "navigate", { path: F });
602
- }, [F, b, r, k]), w(() => {
603
- if (!o || !r || !I)
615
+ }, [E, t, R]), T(() => {
616
+ R && k(t, "set-params", { params: H });
617
+ }, [H, t, R]), T(() => {
618
+ c !== void 0 && z((c == null ? void 0 : c.indexOf("/")) === 0 ? c : `/${c}`);
619
+ }, [c]), T(() => {
620
+ B === void 0 || !R || k(t, "navigate", { path: B });
621
+ }, [B, R, t, k]), T(() => {
622
+ if (!s || !t || !q)
604
623
  return;
605
- e();
606
- const i = new URL(o);
607
- return S(r, i.origin, I), H.current(), v(Te(i.origin, r)), () => {
608
- _(r);
624
+ W();
625
+ const e = new URL(s);
626
+ return O(t, e.origin, q), v.current(), Y(Le(e.origin, t)), () => {
627
+ j(t);
609
628
  };
610
- }, [o, r, S, I, e]), w(() => {
611
- if (!(!C || W.current))
612
- return B.current = setTimeout(() => {
613
- O(!0), D.current && D.current();
614
- }, Re), () => clearTimeout(B.current);
615
- }, [C, o, A, s]);
616
- const t = g(() => {
617
- W.current = !0, clearTimeout(B.current), O(!1);
629
+ }, [s, t, O, q, W]), T(() => {
630
+ if (!(!P || K.current))
631
+ return L.current = setTimeout(() => {
632
+ A(!0), M.current && M.current();
633
+ }, _e), () => clearTimeout(L.current);
634
+ }, [P, s, U, o]);
635
+ const _ = h(() => {
636
+ K.current = !0, clearTimeout(L.current), A(!1);
618
637
  }, []);
619
- V(r, "init", (i) => {
620
- t(), Array.isArray(i == null ? void 0 : i.acceptsCredentials) && z(i.acceptsCredentials);
621
- }), V(r, "authorize", t), V(r, "login", t), V(r, "credential-request", () => {
622
- t(), P(!0);
623
- }), w(() => {
624
- if (!j || !u)
638
+ X(t, "init", (e) => {
639
+ _(), Array.isArray(e == null ? void 0 : e.acceptsCredentials) && g(e.acceptsCredentials);
640
+ }), X(t, "authorize", _), X(t, "login", _), X(t, "credential-request", () => {
641
+ _(), y(!0);
642
+ }), T(() => {
643
+ if (!Z || !i)
625
644
  return;
626
- const i = x;
627
- if (Array.isArray(i) && !i.includes(u.kind))
645
+ const e = f;
646
+ if (Array.isArray(e) && !e.includes(i.kind))
628
647
  return;
629
- const h = u.kind === "access_token" ? { accessToken: u.accessToken } : {};
630
- k(r, "credential", { ...h, credential: u });
631
- }, [j, u, x, r, k]), V(r, "ready", () => {
632
- t(), $((i) => i + 1);
648
+ const r = i.kind === "access_token" ? { accessToken: i.accessToken } : {};
649
+ k(t, "credential", { ...r, credential: i });
650
+ }, [Z, i, f, t, k]), X(t, "ready", () => {
651
+ _(), F((e) => e + 1);
633
652
  });
634
- const n = R();
635
- return V(r, "heartbeat", () => {
636
- n.current && clearTimeout(n.current), n.current = setTimeout(() => {
637
- f((i) => i + 1);
653
+ const D = b();
654
+ return X(t, "heartbeat", () => {
655
+ D.current && clearTimeout(D.current), D.current = setTimeout(() => {
656
+ l((e) => e + 1);
638
657
  }, 6e3);
639
- }), w(() => () => {
640
- n.current && clearTimeout(n.current);
641
- }, []), l ? T ? T(l) : /* @__PURE__ */ E.createElement(ae, { entry: l }) : G && !b ? y ? y() : /* @__PURE__ */ E.createElement(Ce, null) : /* @__PURE__ */ E.createElement(
642
- Ie,
658
+ }), T(() => () => {
659
+ D.current && clearTimeout(D.current);
660
+ }, []), a ? I ? I(a) : /* @__PURE__ */ x.createElement(le, { entry: a }) : V && !R ? $ ? $() : /* @__PURE__ */ x.createElement(ze, null) : /* @__PURE__ */ x.createElement(
661
+ Me,
643
662
  {
644
- key: `auth-epoch-${A}-frame-${s}`,
645
- $isReady: b,
646
- ref: I,
647
- src: C,
648
- ...d
663
+ key: `auth-epoch-${U}-frame-${o}`,
664
+ $isReady: R,
665
+ ref: q,
666
+ src: P,
667
+ ...S
649
668
  }
650
669
  );
651
670
  };
652
- Ae.propTypes = {
653
- id: U.string,
654
- src: U.string.isRequired,
655
- path: U.string,
656
- onInit: U.func,
657
- onTimeout: U.func,
671
+ xe.propTypes = {
672
+ id: w.string,
673
+ src: w.string.isRequired,
674
+ path: w.string,
675
+ onInit: w.func,
676
+ onTimeout: w.func,
658
677
  /**
659
678
  * Optional host-styled renderer for the structurally-unsupported embed
660
679
  * state (legacy app on a cross-site origin), `(entry) => ReactNode`. Falls
661
680
  * back to a minimal built-in placeholder.
662
681
  */
663
- renderUnsupported: U.func,
682
+ renderUnsupported: w.func,
664
683
  /**
665
684
  * Optional host-styled renderer for the handshake-timeout failure state
666
685
  * (the app is not embeddable / could not load), `() => ReactNode`. Falls
667
686
  * back to a minimal centered message.
668
687
  */
669
- renderTimeout: U.func
670
- };
671
- const Me = K.div`
672
- position: fixed;
673
- inset: 0;
674
- background: rgba(0, 0, 0, 0.45);
675
- display: flex;
676
- align-items: center;
677
- justify-content: center;
678
- z-index: 10000;
679
- `, Oe = K.div`
680
- background: #fff;
681
- border-radius: 8px;
682
- box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
683
- padding: 24px;
684
- width: 480px;
685
- max-width: calc(100vw - 32px);
686
- font-family: sans-serif;
687
- color: #222;
688
- `, _e = K.div`
689
- display: flex;
690
- align-items: center;
691
- justify-content: space-between;
692
- padding: 10px 0;
693
- gap: 16px;
694
- `, Le = K.button`
695
- background: #16a500;
696
- color: #fff;
697
- border: none;
698
- border-radius: 6px;
699
- padding: 9px 18px;
700
- font-size: 14px;
701
- cursor: pointer;
702
- white-space: nowrap;
703
- `, $e = K.p`
704
- color: #b3261e;
705
- font-size: 13px;
706
- margin: 4px 0 0;
707
- `, se = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
708
- let ie = !1;
709
- const Pe = () => {
710
- const { pending: r, authorize: o, dismiss: c } = ge(), a = r.filter((d) => !d.consent), p = r.length - a.length, m = R(null), L = R(null), T = a.length > 0;
711
- if (w(() => {
712
- p > 0 && !ie && (ie = !0, console.error(
713
- "[mm-react-embeddable] EmbeddedAuthorizationPrompt received a brokered consent entry. A host with a credentialBroker must render its own consent UI (useEmbeddedAuthorizations: approve/dismiss); this default prompt only handles the popup path."
714
- ));
715
- }, [p]), w(() => {
716
- if (!T || !m.current)
717
- return;
718
- L.current = document.activeElement;
719
- const d = m.current.querySelector(se);
720
- return d && d.focus(), () => {
721
- const I = L.current;
722
- I && typeof I.focus == "function" && I.focus();
723
- };
724
- }, [T]), !T)
725
- return null;
726
- const y = (d) => {
727
- if (d.key === "Escape") {
728
- d.preventDefault(), a.forEach((b) => c(b));
729
- return;
730
- }
731
- if (d.key !== "Tab" || !m.current)
732
- return;
733
- const I = Array.from(m.current.querySelectorAll(se));
734
- if (I.length === 0)
735
- return;
736
- const C = I[0], v = I[I.length - 1];
737
- d.shiftKey && document.activeElement === C ? (d.preventDefault(), v.focus()) : !d.shiftKey && document.activeElement === v && (d.preventDefault(), C.focus());
738
- };
739
- return /* @__PURE__ */ E.createElement(Me, null, /* @__PURE__ */ E.createElement(
740
- Oe,
741
- {
742
- ref: m,
743
- role: "dialog",
744
- "aria-modal": "true",
745
- "aria-labelledby": "mm-embedded-authorization-title",
746
- onKeyDown: y
747
- },
748
- /* @__PURE__ */ E.createElement("h3", { id: "mm-embedded-authorization-title", style: { margin: "0 0 8px" } }, "Authorization Required"),
749
- /* @__PURE__ */ E.createElement("p", { style: { margin: "0 0 12px", fontSize: 14, color: "#555" } }, "The following apps need you to sign in and authorize them before they can load."),
750
- a.map((d) => /* @__PURE__ */ E.createElement("div", { key: d.origin }, /* @__PURE__ */ E.createElement(_e, null, /* @__PURE__ */ E.createElement("div", null, /* @__PURE__ */ E.createElement("div", { style: { fontWeight: 600 } }, d.origin)), /* @__PURE__ */ E.createElement(Le, { onClick: () => o(d) }, "Authorize")), d.popupBlocked && /* @__PURE__ */ E.createElement($e, null, "The sign-in window was blocked. Allow popups for this site, then try again.")))
751
- ));
688
+ renderTimeout: w.func
752
689
  };
753
690
  export {
754
- de as CREDENTIAL_KIND_ACCESS_TOKEN,
691
+ pe as CREDENTIAL_KIND_ACCESS_TOKEN,
755
692
  J as EmbeddedAuthorizationContext,
756
- Pe as EmbeddedAuthorizationPrompt,
757
- Ae as MMEmbeddableZone,
758
- Y as MMEmbeddableZoneContext,
759
- we as MMEmbeddableZoneProvider,
760
- me as isCrossSite,
761
- re as normalizeCredential,
762
- he as popupAuthorizationLauncher,
763
- Ue as unsupportedCopy,
764
- ge as useEmbeddedAuthorizations,
765
- Ee as useEmbeddedCredential,
766
- V as useEmbeddedEffect,
767
- be as useEmbeddedOriginEpoch,
768
- ke as useEmbeddedUnsupported
693
+ xe as MMEmbeddableZone,
694
+ re as MMEmbeddableZoneContext,
695
+ Ie as MMEmbeddableZoneProvider,
696
+ Ee as isCrossSite,
697
+ oe as normalizeCredential,
698
+ Re as popupAuthorizationLauncher,
699
+ Ae as unsupportedCopy,
700
+ Pe as useEmbeddedAuthorizations,
701
+ ke as useEmbeddedCredential,
702
+ X as useEmbeddedEffect,
703
+ Te as useEmbeddedOriginEpoch,
704
+ we as useEmbeddedUnsupported
769
705
  };