@stripchatdev/ext-helper 0.1.44 → 0.1.46

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,59 +1,59 @@
1
- const q = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol === "platform_pubsub" && "version" in e && e.version === "1.0", R = (e) => e, N = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
2
- var h;
1
+ const L = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol === "platform_pubsub" && "version" in e && e.version === "1.0", I = (e) => e, k = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
2
+ var f;
3
3
  (function(e) {
4
4
  e.Base32IncorrectEncoding = "B32_ENC_INVALID", e.DecodeTimeInvalidCharacter = "DEC_TIME_CHAR", e.DecodeTimeValueMalformed = "DEC_TIME_MALFORMED", e.EncodeTimeNegative = "ENC_TIME_NEG", e.EncodeTimeSizeExceeded = "ENC_TIME_SIZE_EXCEED", e.EncodeTimeValueMalformed = "ENC_TIME_MALFORMED", e.PRNGDetectFailure = "PRNG_DETECT", e.ULIDInvalid = "ULID_INVALID", e.Unexpected = "UNEXPECTED", e.UUIDInvalid = "UUID_INVALID";
5
- })(h || (h = {}));
6
- class m extends Error {
5
+ })(f || (f = {}));
6
+ class y extends Error {
7
7
  constructor(t, r) {
8
8
  super(`${r} (${t})`), this.name = "ULIDError", this.code = t;
9
9
  }
10
10
  }
11
- function T(e) {
11
+ function O(e) {
12
12
  const t = Math.floor(e() * 32) % 32;
13
- return N.charAt(t);
13
+ return k.charAt(t);
14
14
  }
15
- function O(e) {
16
- const t = P(), r = t && (t.crypto || t.msCrypto) || null;
15
+ function A(e) {
16
+ const t = x(), r = t && (t.crypto || t.msCrypto) || null;
17
17
  if (typeof (r == null ? void 0 : r.getRandomValues) == "function")
18
18
  return () => {
19
- const s = new Uint8Array(1);
20
- return r.getRandomValues(s), s[0] / 255;
19
+ const n = new Uint8Array(1);
20
+ return r.getRandomValues(n), n[0] / 255;
21
21
  };
22
22
  if (typeof (r == null ? void 0 : r.randomBytes) == "function")
23
23
  return () => r.randomBytes(1).readUInt8() / 255;
24
- throw new m(h.PRNGDetectFailure, "Failed to find a reliable PRNG");
24
+ throw new y(f.PRNGDetectFailure, "Failed to find a reliable PRNG");
25
25
  }
26
- function P() {
27
- return x() ? self : typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : null;
26
+ function x() {
27
+ return F() ? self : typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : null;
28
28
  }
29
- function H(e, t) {
29
+ function C(e, t) {
30
30
  let r = "";
31
31
  for (; e > 0; e--)
32
- r = T(t) + r;
32
+ r = O(t) + r;
33
33
  return r;
34
34
  }
35
- function L(e, t = 10) {
35
+ function D(e, t = 10) {
36
36
  if (isNaN(e))
37
- throw new m(h.EncodeTimeValueMalformed, `Time must be a number: ${e}`);
37
+ throw new y(f.EncodeTimeValueMalformed, `Time must be a number: ${e}`);
38
38
  if (e > 281474976710655)
39
- throw new m(h.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${281474976710655}: ${e}`);
39
+ throw new y(f.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${281474976710655}: ${e}`);
40
40
  if (e < 0)
41
- throw new m(h.EncodeTimeNegative, `Time must be positive: ${e}`);
41
+ throw new y(f.EncodeTimeNegative, `Time must be positive: ${e}`);
42
42
  if (Number.isInteger(e) === !1)
43
- throw new m(h.EncodeTimeValueMalformed, `Time must be an integer: ${e}`);
44
- let r, s = "";
45
- for (let o = t; o > 0; o--)
46
- r = e % 32, s = N.charAt(r) + s, e = (e - r) / 32;
47
- return s;
43
+ throw new y(f.EncodeTimeValueMalformed, `Time must be an integer: ${e}`);
44
+ let r, n = "";
45
+ for (let s = t; s > 0; s--)
46
+ r = e % 32, n = k.charAt(r) + n, e = (e - r) / 32;
47
+ return n;
48
48
  }
49
- function x() {
49
+ function F() {
50
50
  return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
51
51
  }
52
- function g(e, t) {
53
- const r = t || O(), s = !e || isNaN(e) ? Date.now() : e;
54
- return L(s, 10) + H(16, r);
52
+ function E(e, t) {
53
+ const r = t || A(), n = !e || isNaN(e) ? Date.now() : e;
54
+ return D(n, 10) + C(16, r);
55
55
  }
56
- const A = ({ seq: e, uniqId: t }) => (r) => ({
56
+ const j = ({ seq: e, uniqId: t }) => (r) => ({
57
57
  ...{
58
58
  protocol: "platform_pubsub",
59
59
  version: "1.0",
@@ -62,69 +62,69 @@ const A = ({ seq: e, uniqId: t }) => (r) => ({
62
62
  timestamp: Date.now()
63
63
  },
64
64
  ...r
65
- }), w = A({
66
- uniqId: () => g(),
67
- seq: () => g()
65
+ }), v = j({
66
+ uniqId: () => E(),
67
+ seq: () => E()
68
68
  });
69
- class C {
69
+ class G {
70
70
  constructor(t) {
71
- this.eventHandlerMap = /* @__PURE__ */ new Map(), this.transportMessageHandler = (o) => {
72
- const { data: n, senderId: a } = o;
73
- if (q(n)) {
74
- if (n.type === "event") {
75
- const { eventName: i } = n, c = this.eventHandlerMap.get(i);
71
+ this.eventHandlerMap = /* @__PURE__ */ new Map(), this.transportMessageHandler = (s) => {
72
+ const { data: o, senderId: a } = s;
73
+ if (L(o)) {
74
+ if (o.type === "event") {
75
+ const { eventName: i } = o, c = this.eventHandlerMap.get(i);
76
76
  if (!c)
77
77
  return;
78
- c.forEach((l) => {
78
+ c.forEach((h) => {
79
79
  try {
80
- l(n.data, a);
81
- } catch (p) {
82
- console.error("[PubSubSubscriber] transportMessageHandler: failed to handle income message", p);
80
+ h(o.data, a);
81
+ } catch (m) {
82
+ console.error("[PubSubSubscriber] transportMessageHandler: failed to handle income message", m);
83
83
  }
84
84
  });
85
85
  return;
86
86
  }
87
- console.error("[PubSubSubscriber] transportMessageHandler: unhandled message", n);
87
+ console.error("[PubSubSubscriber] transportMessageHandler: unhandled message", o);
88
88
  }
89
89
  };
90
- const { brokerId: r, transport: s } = t;
91
- this.brokerId = r, this.transport = s, this.transport.onMessage(this.transportMessageHandler);
90
+ const { brokerId: r, transport: n } = t;
91
+ this.brokerId = r, this.transport = n, this.transport.onMessage(this.transportMessageHandler);
92
92
  }
93
93
  subscribe(t, r) {
94
- const s = R(t);
95
- let o = this.eventHandlerMap.get(s);
96
- o || (o = /* @__PURE__ */ new Set(), this.eventHandlerMap.set(s, o)), o.add(r);
97
- const n = w({
94
+ const n = I(t);
95
+ let s = this.eventHandlerMap.get(n);
96
+ s || (s = /* @__PURE__ */ new Set(), this.eventHandlerMap.set(n, s)), s.add(r);
97
+ const o = v({
98
98
  type: "subscribe",
99
99
  eventName: t
100
100
  });
101
- this.transport.send(this.brokerId, n);
101
+ this.transport.send(this.brokerId, o);
102
102
  }
103
103
  unsubscribe(t, r) {
104
- const s = R(t);
105
- let o = this.eventHandlerMap.get(s);
106
- if (o && (r ? (o.delete(r), o.size || this.eventHandlerMap.delete(s)) : this.eventHandlerMap.delete(s), !this.eventHandlerMap.has(s))) {
107
- const n = w({
104
+ const n = I(t);
105
+ let s = this.eventHandlerMap.get(n);
106
+ if (s && (r ? (s.delete(r), s.size || this.eventHandlerMap.delete(n)) : this.eventHandlerMap.delete(n), !this.eventHandlerMap.has(n))) {
107
+ const o = v({
108
108
  type: "unsubscribe",
109
109
  eventName: t
110
110
  });
111
- this.transport.send(this.brokerId, n);
111
+ this.transport.send(this.brokerId, o);
112
112
  }
113
113
  }
114
114
  }
115
- const D = !!Error.captureStackTrace, j = "APP_ERROR";
116
- class E extends Error {
115
+ const z = !!Error.captureStackTrace, B = "APP_ERROR";
116
+ class b extends Error {
117
117
  constructor(t, r) {
118
- super(t), this.name = new.target.name || j, this.cause = r, D && Error.captureStackTrace(this, this.constructor);
118
+ super(t), this.name = new.target.name || B, this.cause = r, z && Error.captureStackTrace(this, this.constructor);
119
119
  }
120
120
  static serializeCause(t) {
121
- return t instanceof E ? t.toJSON() : t instanceof Error ? { name: t.name, message: t.message } : t !== null && typeof t == "object" ? t : String(t);
121
+ return t instanceof b ? t.toJSON() : t instanceof Error ? { name: t.name, message: t.message } : t !== null && typeof t == "object" ? t : String(t);
122
122
  }
123
123
  toJSON() {
124
124
  return {
125
125
  name: this.name,
126
126
  message: this.message,
127
- cause: this.cause ? E.serializeCause(this.cause) : void 0
127
+ cause: this.cause ? b.serializeCause(this.cause) : void 0
128
128
  };
129
129
  }
130
130
  toString() {
@@ -136,12 +136,12 @@ class E extends Error {
136
136
  }
137
137
  }
138
138
  }
139
- const F = {
139
+ const V = {
140
140
  INTERNAL_ERROR: "INTERNAL_ERROR"
141
- }, G = "RPC_ERROR";
142
- class z extends E {
141
+ }, X = "RPC_ERROR";
142
+ class W extends b {
143
143
  constructor(t) {
144
- super(t.message || "rpc error", t.cause), this.name = G, this.code = (t == null ? void 0 : t.code) || F.INTERNAL_ERROR, this.method = t.method, this.params = t.params;
144
+ super(t.message || "rpc error", t.cause), this.name = X, this.code = (t == null ? void 0 : t.code) || V.INTERNAL_ERROR, this.method = t.method, this.params = t.params;
145
145
  }
146
146
  toJSON() {
147
147
  return {
@@ -152,7 +152,7 @@ class z extends E {
152
152
  };
153
153
  }
154
154
  }
155
- const B = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol === "platform_rpc" && "version" in e && e.version === "1.0", X = ({ uniqId: e }) => (t) => ({
155
+ const $ = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol === "platform_rpc" && "version" in e && e.version === "1.0", J = ({ uniqId: e }) => (t) => ({
156
156
  ...{
157
157
  requestId: e(),
158
158
  protocol: "platform_rpc",
@@ -160,48 +160,48 @@ const B = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol ==
160
160
  timestamp: Date.now()
161
161
  },
162
162
  ...t
163
- }), $ = X({
164
- uniqId: () => g()
163
+ }), U = J({
164
+ uniqId: () => E()
165
165
  });
166
- class W {
166
+ class K {
167
167
  constructor(t) {
168
- this.pendingEntryMap = /* @__PURE__ */ new Map(), this.transportMessageHandler = (o) => {
169
- const { data: n } = o;
170
- if (B(n)) {
171
- if (n.type === "response" && n.status === "ok") {
172
- const a = this.pendingEntryMap.get(n.requestId);
168
+ this.pendingEntryMap = /* @__PURE__ */ new Map(), this.transportMessageHandler = (s) => {
169
+ const { data: o } = s;
170
+ if ($(o)) {
171
+ if (o.type === "response" && o.status === "ok") {
172
+ const a = this.pendingEntryMap.get(o.requestId);
173
173
  if (!a) {
174
- console.error("[RpcClient] transportMessageHandler: got success response without pending request", n);
174
+ console.error("[RpcClient] transportMessageHandler: got success response without pending request", o);
175
175
  return;
176
176
  }
177
- this.pendingEntryMap.delete(n.requestId), a.resolve(n.result);
177
+ this.pendingEntryMap.delete(o.requestId), a.resolve(o.result);
178
178
  return;
179
179
  }
180
- if (n.type === "response" && n.status === "error") {
181
- const a = this.pendingEntryMap.get(n.requestId);
180
+ if (o.type === "response" && o.status === "error") {
181
+ const a = this.pendingEntryMap.get(o.requestId);
182
182
  if (!a) {
183
- console.error("[RpcClient] transportMessageHandler: got error response without pending request", n);
183
+ console.error("[RpcClient] transportMessageHandler: got error response without pending request", o);
184
184
  return;
185
185
  }
186
- this.pendingEntryMap.delete(n.requestId), a.reject(new z(n.error));
186
+ this.pendingEntryMap.delete(o.requestId), a.reject(new W(o.error));
187
187
  return;
188
188
  }
189
- console.error("[RpcClient] transportMessageHandler: invalid message schema", n);
189
+ console.error("[RpcClient] transportMessageHandler: invalid message schema", o);
190
190
  }
191
191
  };
192
- const { serverId: r, transport: s } = t;
193
- this.serverId = r, this.transport = s, this.transport.onMessage(this.transportMessageHandler);
192
+ const { serverId: r, transport: n } = t;
193
+ this.serverId = r, this.transport = n, this.transport.onMessage(this.transportMessageHandler);
194
194
  }
195
195
  makeRequest(t, r) {
196
- const s = $({
196
+ const n = U({
197
197
  type: "request",
198
198
  method: t,
199
199
  params: r
200
- }), o = new Promise((n, a) => {
201
- this.pendingEntryMap.set(s.requestId, {
200
+ }), s = new Promise((o, a) => {
201
+ this.pendingEntryMap.set(n.requestId, {
202
202
  method: t,
203
203
  resolve: (i) => {
204
- n(i);
204
+ o(i);
205
205
  },
206
206
  reject: (i) => {
207
207
  a(i);
@@ -209,44 +209,44 @@ class W {
209
209
  });
210
210
  });
211
211
  try {
212
- this.transport.send(this.serverId, s);
213
- } catch (n) {
214
- console.error("[RpcClient] makeRequest: failed to send rpc message", n);
215
- const a = this.pendingEntryMap.get(s.requestId);
216
- a && (this.pendingEntryMap.delete(s.requestId), a.reject(n));
212
+ this.transport.send(this.serverId, n);
213
+ } catch (o) {
214
+ console.error("[RpcClient] makeRequest: failed to send rpc message", o);
215
+ const a = this.pendingEntryMap.get(n.requestId);
216
+ a && (this.pendingEntryMap.delete(n.requestId), a.reject(o));
217
217
  }
218
- return o;
218
+ return s;
219
219
  }
220
220
  }
221
- const J = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol === "platform_transport" && "version" in e && e.version === "1.0", V = ({ uniqId: e }) => (t) => ({
221
+ const Z = (e) => !!e && typeof e == "object" && "protocol" in e && e.protocol === "platform_transport" && "version" in e && e.version === "1.0", Q = ({ uniqId: e }) => (t) => ({
222
222
  messageId: e(),
223
223
  protocol: "platform_transport",
224
224
  version: "1.0",
225
225
  ...t
226
- }), I = V({
227
- uniqId: g
226
+ }), S = Q({
227
+ uniqId: E
228
228
  });
229
- class U {
229
+ class Y {
230
230
  constructor(t) {
231
- this.peers = /* @__PURE__ */ new Map(), this.handlers = /* @__PURE__ */ new Set(), this.onMessage = (o) => {
232
- const n = (a) => {
233
- const { data: i, origin: c, source: l } = a;
234
- if (!l || !J(i))
231
+ this.peers = /* @__PURE__ */ new Map(), this.handlers = /* @__PURE__ */ new Set(), this.onMessage = (s) => {
232
+ const o = (a) => {
233
+ const { data: i, origin: c, source: h } = a;
234
+ if (!h || !Z(i))
235
235
  return;
236
- const { recipientId: p } = i;
237
- if (!(p !== this.transportId || !this.findPeer(l, c)))
236
+ const { recipientId: m } = i;
237
+ if (!(m !== this.transportId || !this.findPeer(h, c)))
238
238
  try {
239
- o(i);
240
- } catch (y) {
241
- console.error("[PostMessageTransport] onMessage: failed to call cb on message", y);
239
+ s(i);
240
+ } catch (w) {
241
+ console.error("[PostMessageTransport] onMessage: failed to call cb on message", w);
242
242
  }
243
243
  };
244
- return this.localWindow.addEventListener("message", n), this.handlers.add(n), () => {
245
- this.localWindow.removeEventListener("message", n), this.handlers.delete(n);
244
+ return this.localWindow.addEventListener("message", o), this.handlers.add(o), () => {
245
+ this.localWindow.removeEventListener("message", o), this.handlers.delete(o);
246
246
  };
247
247
  };
248
- const { localWindow: r, transportId: s } = t;
249
- this.transportId = s, this.localWindow = r || window;
248
+ const { localWindow: r, transportId: n } = t;
249
+ this.transportId = n, this.localWindow = r || window;
250
250
  }
251
251
  destroy() {
252
252
  this.handlers.forEach((t) => {
@@ -254,29 +254,29 @@ class U {
254
254
  });
255
255
  }
256
256
  send(t, r) {
257
- const s = this.peers.get(t);
258
- if (s) {
259
- const o = I({
257
+ const n = this.peers.get(t);
258
+ if (n) {
259
+ const s = S({
260
260
  data: r,
261
261
  senderId: this.transportId,
262
- recipientId: s.id
262
+ recipientId: n.id
263
263
  });
264
- s.source.postMessage(o, s.origin);
264
+ n.source.postMessage(s, n.origin);
265
265
  }
266
266
  }
267
267
  broadcast(t) {
268
268
  this.peers.forEach((r) => {
269
- const s = I({
269
+ const n = S({
270
270
  data: t,
271
271
  senderId: this.transportId,
272
272
  recipientId: r.id
273
273
  });
274
- r.source.postMessage(s, r.origin);
274
+ r.source.postMessage(n, r.origin);
275
275
  });
276
276
  }
277
277
  broadcastGroup(t, r) {
278
- t.forEach((s) => {
279
- this.send(s, r);
278
+ t.forEach((n) => {
279
+ this.send(n, r);
280
280
  });
281
281
  }
282
282
  addPeer(t) {
@@ -286,52 +286,52 @@ class U {
286
286
  this.peers.delete(t);
287
287
  }
288
288
  findPeer(t, r) {
289
- for (const [s, o] of this.peers)
290
- if (o.source === t && o.origin === r)
291
- return o;
289
+ for (const [n, s] of this.peers)
290
+ if (s.source === t && s.origin === r)
291
+ return s;
292
292
  return null;
293
293
  }
294
294
  }
295
- const f = {
295
+ const g = {
296
296
  name: "unknownError",
297
297
  message: "unknown error"
298
- }, k = (e, t = 3, r = 0) => {
298
+ }, P = (e, t = 3, r = 0) => {
299
299
  if (e instanceof Error) {
300
- const s = r < t && e.cause ? k(e.cause, t, r + 1) : void 0;
300
+ const n = r < t && e.cause ? P(e.cause, t, r + 1) : void 0;
301
301
  return {
302
302
  name: e.name,
303
303
  message: e.message,
304
304
  stack: e.stack,
305
- cause: s
305
+ cause: n
306
306
  };
307
307
  }
308
308
  if (typeof e == "string")
309
309
  return {
310
- name: f.name,
310
+ name: g.name,
311
311
  message: e
312
312
  };
313
313
  if (typeof e == "number" || typeof e == "bigint" || typeof e == "boolean")
314
314
  return {
315
- name: f.name,
315
+ name: g.name,
316
316
  message: String(e)
317
317
  };
318
318
  if (e && typeof e == "object")
319
319
  try {
320
320
  return {
321
- name: f.name,
321
+ name: g.name,
322
322
  message: "message" in e && typeof e.message == "string" && e.message !== "" ? e.message : JSON.stringify(e)
323
323
  };
324
324
  } catch {
325
325
  return {
326
- name: f.name,
326
+ name: g.name,
327
327
  message: "failed to serialize error: unserializable error object"
328
328
  };
329
329
  }
330
- return f;
331
- }, S = (e) => {
330
+ return g;
331
+ }, q = (e) => {
332
332
  const t = [];
333
333
  if (e instanceof Error)
334
- t.push(e.message), "cause" in e && t.push(S(e.cause));
334
+ t.push(e.message), "cause" in e && t.push(q(e.cause));
335
335
  else
336
336
  try {
337
337
  const r = JSON.stringify(e);
@@ -340,7 +340,7 @@ const f = {
340
340
  t.push("failed to get chained error message: unserializable error object");
341
341
  }
342
342
  return t.join(":");
343
- }, K = [
343
+ }, ee = [
344
344
  // browser internals — harmless noise
345
345
  /resizeObserver loop/ig,
346
346
  // cross-origin script errors with zero useful info
@@ -363,31 +363,31 @@ const f = {
363
363
  // generic network noise already captured by fetch/xhr integrations
364
364
  /networkError when attempting to fetch resource/ig,
365
365
  /load failed/ig
366
- ], Z = (e) => K.some((t) => (t.lastIndex = 0, t.test(e))), Q = (e) => {
367
- const t = S(e.error), r = typeof e.data == "object" && "message" in e.data && typeof e.data.message == "string" ? e.data.message : "";
368
- return [t, r].filter((s) => !!s).join(":");
369
- }, Y = (e) => e.data && typeof e.data == "object" && "filename" in e.data ? String(e.data.filename ?? "") : "", ee = (e) => {
370
- const t = Q(e), r = Y(e);
371
- return r && /^(chrome|moz|safari)-extension:\/\//.test(r) ? !0 : !!t && Z(t);
372
- }, te = "get", re = (e, t) => {
373
- var o;
374
- let r, s;
375
- return e instanceof Request ? (r = e.url, s = e.method) : e instanceof URL ? r = e.toString() : r = e, {
376
- method: s || ((o = t == null ? void 0 : t.method) == null ? void 0 : o.toString()) || te,
366
+ ], te = (e) => ee.some((t) => (t.lastIndex = 0, t.test(e))), re = (e) => {
367
+ const t = q(e.error), r = typeof e.data == "object" && "message" in e.data && typeof e.data.message == "string" ? e.data.message : "";
368
+ return [t, r].filter((n) => !!n).join(":");
369
+ }, ne = (e) => e.data && typeof e.data == "object" && "filename" in e.data ? String(e.data.filename ?? "") : "", se = (e) => {
370
+ const t = re(e), r = ne(e);
371
+ return r && /^(chrome|moz|safari)-extension:\/\//.test(r) ? !0 : !!t && te(t);
372
+ }, oe = "get", ae = (e, t) => {
373
+ var s;
374
+ let r, n;
375
+ return e instanceof Request ? (r = e.url, n = e.method) : e instanceof URL ? r = e.toString() : r = e, {
376
+ method: n || ((s = t == null ? void 0 : t.method) == null ? void 0 : s.toString()) || oe,
377
377
  url: r
378
378
  };
379
- }, se = (e, t, r) => ({
379
+ }, ie = (e, t, r) => ({
380
380
  statusCode: r.status,
381
- ...re(e, t)
382
- }), ne = (e) => {
381
+ ...ae(e, t)
382
+ }), ce = (e) => {
383
383
  const t = window.fetch;
384
384
  Object.defineProperty(window, "fetch", {
385
- value: async (s, o) => {
385
+ value: async (n, s) => {
386
386
  try {
387
- const n = new Error("synthetic error"), a = await t(s, o), i = a.clone(), c = se(s, o, i);
387
+ const o = new Error("synthetic error"), a = await t(n, s), i = a.clone(), c = ie(n, s, i);
388
388
  if (a.status >= 500) {
389
389
  const d = new Error("fetch response error");
390
- d.stack = n.stack, e.report({
390
+ d.stack = o.stack, e.report({
391
391
  kind: "fetchResponseError",
392
392
  type: "network",
393
393
  data: c,
@@ -395,14 +395,14 @@ const f = {
395
395
  });
396
396
  }
397
397
  const {
398
- arrayBuffer: l,
399
- blob: p,
400
- json: b,
401
- text: y
398
+ arrayBuffer: h,
399
+ blob: m,
400
+ json: M,
401
+ text: w
402
402
  } = a;
403
403
  return a.json = async function() {
404
404
  try {
405
- return await b.call(this);
405
+ return await M.call(this);
406
406
  } catch (d) {
407
407
  throw e.report({
408
408
  type: "network",
@@ -416,7 +416,7 @@ const f = {
416
416
  }
417
417
  }, a.text = async function() {
418
418
  try {
419
- return await y.call(this);
419
+ return await w.call(this);
420
420
  } catch (d) {
421
421
  throw e.report({
422
422
  type: "network",
@@ -430,7 +430,7 @@ const f = {
430
430
  }
431
431
  }, a.blob = async function() {
432
432
  try {
433
- return await p.call(this);
433
+ return await m.call(this);
434
434
  } catch (d) {
435
435
  throw e.report({
436
436
  type: "network",
@@ -444,7 +444,7 @@ const f = {
444
444
  }
445
445
  }, a.arrayBuffer = async function() {
446
446
  try {
447
- return await l.call(this);
447
+ return await h.call(this);
448
448
  } catch (d) {
449
449
  throw e.report({
450
450
  type: "network",
@@ -457,50 +457,50 @@ const f = {
457
457
  }), d;
458
458
  }
459
459
  }, a;
460
- } catch (n) {
461
- throw n instanceof Error && n.name === "AbortError", n;
460
+ } catch (o) {
461
+ throw o instanceof Error && o.name === "AbortError", o;
462
462
  }
463
463
  },
464
464
  configurable: !0,
465
465
  writable: !0
466
466
  });
467
- }, oe = (e) => {
467
+ }, ue = (e) => {
468
468
  window.addEventListener("unhandledrejection", ({ reason: t }) => {
469
469
  e.report({
470
470
  type: "runtime",
471
471
  kind: "unhandledRejection",
472
472
  error: t
473
473
  });
474
- }), window.addEventListener("error", ({ colno: t, error: r, filename: s, lineno: o, message: n }) => {
474
+ }), window.addEventListener("error", ({ colno: t, error: r, filename: n, lineno: s, message: o }) => {
475
475
  e.report({
476
476
  type: "runtime",
477
477
  kind: "uncaughtError",
478
478
  error: r,
479
479
  data: {
480
- lineno: o,
480
+ lineno: s,
481
481
  colno: t,
482
- message: n,
483
- filename: s
482
+ message: o,
483
+ filename: n
484
484
  }
485
485
  });
486
486
  });
487
- }, _ = Symbol("patchedXHLHttpRequest"), u = Symbol("requestInfo"), ae = (e) => ({
487
+ }, _ = Symbol("patchedXHLHttpRequest"), p = Symbol("requestInfo"), de = (e) => ({
488
488
  statusCode: e.status,
489
- ...e[u]
490
- }), ie = (e) => (e[u] || (e[u] = {}), e[u]), ce = (e) => {
489
+ ...e[p]
490
+ }), le = (e) => (e[p] || (e[p] = {}), e[p]), pe = (e) => {
491
491
  e[_] = !0;
492
- }, de = (e) => e[_] === !0, ue = (e) => {
493
- const t = XMLHttpRequest.prototype.send, r = XMLHttpRequest.prototype.open, s = function(...n) {
494
- const [a, i] = n;
495
- this[u] = {
492
+ }, he = (e) => e[_] === !0, fe = (e) => {
493
+ const t = XMLHttpRequest.prototype.send, r = XMLHttpRequest.prototype.open, n = function(...o) {
494
+ const [a, i] = o;
495
+ this[p] = {
496
496
  method: a,
497
497
  url: typeof i == "string" ? i : i.toString()
498
- }, de(this) || (ce(this), this.addEventListener("error", () => {
498
+ }, he(this) || (pe(this), this.addEventListener("error", () => {
499
499
  const c = new Error("XMLHttpRequest network error");
500
500
  e.report({
501
501
  type: "network",
502
502
  kind: "xmlHttpRequestError",
503
- data: this[u],
503
+ data: this[p],
504
504
  error: c
505
505
  });
506
506
  }), this.addEventListener("timeout", () => {
@@ -508,7 +508,7 @@ const f = {
508
508
  e.report({
509
509
  type: "network",
510
510
  kind: "xmlHttpRequestTimeoutError",
511
- data: this[u],
511
+ data: this[p],
512
512
  error: c
513
513
  });
514
514
  }), this.addEventListener("load", () => {
@@ -517,88 +517,88 @@ const f = {
517
517
  e.report({
518
518
  type: "network",
519
519
  kind: "xmlHttpRequestLoadError",
520
- data: ae(this),
520
+ data: de(this),
521
521
  error: c
522
522
  });
523
523
  }
524
524
  }));
525
525
  try {
526
- r.apply(this, n);
526
+ r.apply(this, o);
527
527
  } catch (c) {
528
528
  throw e.report({
529
529
  type: "network",
530
530
  kind: "xmlHttpRequestOpenError",
531
531
  error: c,
532
- data: this[u]
532
+ data: this[p]
533
533
  }), c;
534
534
  }
535
- }, o = function(n) {
535
+ }, s = function(o) {
536
536
  try {
537
- const a = ie(this), i = new Error("XMLHttpRequest request initiator");
538
- a.requestStack = i.stack, t.call(this, n);
537
+ const a = le(this), i = new Error("XMLHttpRequest request initiator");
538
+ a.requestStack = i.stack, t.call(this, o);
539
539
  } catch (a) {
540
540
  throw e.report({
541
541
  type: "network",
542
542
  kind: "xmlHttpRequestSendError",
543
543
  error: a,
544
- data: this[u]
544
+ data: this[p]
545
545
  }), a;
546
546
  }
547
547
  };
548
548
  Object.defineProperty(XMLHttpRequest.prototype, "open", {
549
- value: s,
549
+ value: n,
550
550
  configurable: !0,
551
551
  writable: !0
552
552
  }), Object.defineProperty(XMLHttpRequest.prototype, "send", {
553
- value: o,
553
+ value: s,
554
554
  configurable: !0,
555
555
  writable: !0
556
556
  });
557
557
  };
558
- let M;
559
- class le {
558
+ let N;
559
+ class me {
560
560
  constructor(t) {
561
561
  this.onError = t;
562
562
  }
563
563
  report(t) {
564
- if (ee(t))
564
+ if (se(t))
565
565
  return;
566
- const { error: r, ...s } = t;
566
+ const { error: r, ...n } = t;
567
567
  this.onError({
568
- ...s,
569
- error: r ? k(r) : void 0
568
+ ...n,
569
+ error: r ? P(r) : void 0
570
570
  });
571
571
  }
572
572
  init() {
573
573
  this.applyIntegrations();
574
574
  }
575
575
  applyIntegrations() {
576
- M || (M = !0, oe(this), ue(this), ne(this));
576
+ N || (N = !0, ue(this), fe(this), ce(this));
577
577
  }
578
578
  }
579
- class he {
579
+ class ge {
580
580
  constructor(t) {
581
581
  const {
582
582
  frameId: r,
583
- serverId: s,
584
- serverOrigin: o,
585
- serverSource: n,
583
+ serverId: n,
584
+ serverOrigin: s,
585
+ serverSource: o,
586
586
  theme: a
587
587
  } = t, i = {
588
- id: s,
589
- origin: o,
590
- source: n
591
- }, c = new U({
588
+ id: n,
589
+ origin: s,
590
+ source: o
591
+ }, c = new Y({
592
592
  transportId: r
593
593
  });
594
- c.addPeer(i), this.rpcClient = new W({
594
+ c.addPeer(i), this.rpcClient = new K({
595
595
  transport: c,
596
- serverId: s
597
- }), this.subscriber = new C({
596
+ serverId: n
597
+ }), this.subscriber = new G({
598
598
  transport: c,
599
599
  brokerId: i.id
600
- }), document.documentElement.dataset.theme = a, this.crashReporter = new le((l) => {
601
- this.makeRequest("v1.system.report.crash", l);
600
+ }), document.documentElement.dataset.theme = a, this.crashReporter = new me((h) => {
601
+ this.makeRequest("v1.system.report.crash", h);
602
602
  });
603
603
  }
604
604
  makeRequest(t, r) {
@@ -618,17 +618,17 @@ class he {
618
618
  i.offsetHeight,
619
619
  i.scrollHeight
620
620
  );
621
- }, s = () => {
621
+ }, n = () => {
622
622
  const i = document.body;
623
623
  return Math.max(
624
624
  i.offsetWidth,
625
625
  i.scrollWidth
626
626
  );
627
- }, o = () => {
628
- const i = s(), c = r();
627
+ }, s = () => {
628
+ const i = n(), c = r();
629
629
  (t.height !== c || t.width !== i) && (t = { height: c, width: i }, this.makeRequest("v1.system.resize.notify", { height: c, width: i }));
630
630
  };
631
- o(), new ResizeObserver(o).observe(document.body), new MutationObserver(o).observe(document.body, {
631
+ s(), new ResizeObserver(s).observe(document.body), new MutationObserver(s).observe(document.body, {
632
632
  childList: !0,
633
633
  subtree: !0,
634
634
  attributes: !0,
@@ -636,22 +636,77 @@ class he {
636
636
  }), this.crashReporter.init();
637
637
  }
638
638
  }
639
- let v = !1;
640
- const pe = () => {
641
- if (v)
639
+ const ye = HTMLElement.prototype.focus, Ee = SVGElement.prototype.focus;
640
+ function T(e) {
641
+ const t = typeof e == "object" && e ? { ...e, preventScroll: !0 } : { preventScroll: !0 };
642
+ if (this instanceof HTMLElement)
643
+ return ye.call(this, t);
644
+ if (this instanceof SVGElement)
645
+ return Ee.call(this, t);
646
+ }
647
+ const be = HTMLFormElement.prototype.submit, we = HTMLFormElement.prototype.requestSubmit, Re = /* @__PURE__ */ new Set(["_top", "_blank", "_parent"]), R = (e) => !!e && Re.has(e.toLowerCase());
648
+ function Me() {
649
+ const e = this.getAttribute("target");
650
+ if (!R(e))
651
+ return be.call(this);
652
+ }
653
+ function Ie(e) {
654
+ const t = (e == null ? void 0 : e.getAttribute("formtarget")) || this.getAttribute("target");
655
+ if (!R(t))
656
+ return we.call(this, e);
657
+ }
658
+ function ve(e) {
659
+ var s;
660
+ const t = e.target;
661
+ if (!(t instanceof HTMLFormElement))
662
+ return;
663
+ const r = e instanceof SubmitEvent ? e.submitter : null, n = (r == null ? void 0 : r.getAttribute("formtarget")) || t.getAttribute("target") || ((s = document.querySelector("base[target]")) == null ? void 0 : s.getAttribute("target")) || "_self";
664
+ R(n) && (e.preventDefault(), e.stopImmediatePropagation());
665
+ }
666
+ const l = () => {
667
+ }, u = (e, t, r) => {
668
+ const n = e;
669
+ if (!n || typeof n[t] != "function")
670
+ return;
671
+ const s = Object.getOwnPropertyDescriptor(n, t);
672
+ if (!(s && s.configurable === !1 && s.writable === !1))
673
+ try {
674
+ Object.defineProperty(n, t, {
675
+ configurable: !1,
676
+ enumerable: (s == null ? void 0 : s.enumerable) ?? !1,
677
+ value: r,
678
+ writable: !1
679
+ });
680
+ } catch {
681
+ }
682
+ }, Se = () => {
683
+ u(Window.prototype, "open", () => null), u(window, "open", () => null), u(Element.prototype, "scrollIntoView", l), u(
684
+ Element.prototype,
685
+ "scrollIntoViewIfNeeded",
686
+ l
687
+ ), u(HTMLElement.prototype, "focus", T), u(SVGElement.prototype, "focus", T), u(History.prototype, "back", l), u(History.prototype, "forward", l), u(History.prototype, "go", l), u(History.prototype, "pushState", l), u(History.prototype, "replaceState", l), u(
688
+ HTMLVideoElement.prototype,
689
+ "requestPictureInPicture",
690
+ () => Promise.resolve({})
691
+ ), u(HTMLFormElement.prototype, "submit", Me), u(HTMLFormElement.prototype, "requestSubmit", Ie), typeof Location < "u" && (u(Location.prototype, "assign", l), u(Location.prototype, "replace", l), u(Location.prototype, "reload", l)), document.addEventListener("submit", ve, !0);
692
+ };
693
+ let H = !1;
694
+ typeof window < "u" && typeof document < "u" && Se();
695
+ const Ne = () => {
696
+ if (H)
642
697
  throw new Error("ext helper already created, only one instance is allowed");
643
- const e = new URL(window.location.href), t = e.searchParams.get("origin") || "", r = e.searchParams.get("theme") || "dark", s = e.searchParams.get("frameId");
644
- if (!s)
698
+ const e = new URL(window.location.href), t = e.searchParams.get("origin") || "", r = e.searchParams.get("theme") || "dark", n = e.searchParams.get("frameId");
699
+ if (!n)
645
700
  throw new Error("failed to create ext helper, frameId is empty");
646
- const o = new he({
701
+ const s = new ge({
647
702
  serverId: "server",
648
703
  serverOrigin: t || window.parent.origin,
649
704
  serverSource: window.parent,
650
- frameId: s,
705
+ frameId: n,
651
706
  theme: r
652
707
  });
653
- return o.bootstrap(), v = !0, o;
708
+ return s.bootstrap(), H = !0, s;
654
709
  };
655
710
  export {
656
- pe as createExtHelper
711
+ Ne as createExtHelper
657
712
  };