@fkn/lib 0.9.49 → 0.9.51

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.
@@ -56,10 +56,10 @@ var ne = (e, t) => {
56
56
  dispatchEvent: (t) => e.remoteEvents.dispatchEvent(t)
57
57
  };
58
58
  }, x = /* @__PURE__ */ e({
59
- box: () => ye,
60
- createVideoElementHandle: () => _e,
61
- isType: () => ve,
62
- revive: () => be,
59
+ box: () => be,
60
+ createVideoElementHandle: () => ve,
61
+ isType: () => ye,
62
+ revive: () => xe,
63
63
  type: () => S
64
64
  }), S = "videoElement", ie = [
65
65
  "currentTime",
@@ -79,7 +79,7 @@ var ne = (e, t) => {
79
79
  "seeking",
80
80
  "readyState",
81
81
  "currentSrc"
82
- ], oe = ["buffered", "seekable"], se = Symbol.for("fkn.remoteVideoElement"), ce = Symbol.for("fkn.remoteVideoElement.state"), le = Symbol.for("fkn.remoteVideoElement.controller"), ue = (e) => e ? Array.from({ length: e.length }, (t, n) => [e.start(n), e.end(n)]) : [], C = (e) => {
82
+ ], oe = ["buffered", "seekable"], se = Symbol.for("fkn.remoteVideoElement"), ce = Symbol.for("fkn.remoteVideoElement.state"), le = Symbol.for("fkn.remoteVideoElement.controller"), ue = (e) => e ? Array.from({ length: e.length }, (t, n) => [e.start(n), e.end(n)]) : [], de = (e) => {
83
83
  let t = {};
84
84
  for (let n of [...ie, ...ae]) t[n] = e[n];
85
85
  for (let n of oe) t[n] = ue(e[n]);
@@ -87,7 +87,7 @@ var ne = (e, t) => {
87
87
  code: e.error.code,
88
88
  message: e.error.message
89
89
  } : null, t;
90
- }, de = (e) => {
90
+ }, fe = (e) => {
91
91
  let t = (t) => {
92
92
  if (!Number.isInteger(t) || t < 0 || t >= e.length) throw new DOMException("Index or size is negative or greater than the allowed amount", "IndexSizeError");
93
93
  };
@@ -102,17 +102,17 @@ var ne = (e, t) => {
102
102
  return t(n), e[n][1];
103
103
  }
104
104
  };
105
- }, fe = (e) => e ? {
105
+ }, pe = (e) => e ? {
106
106
  code: e.code,
107
107
  message: e.message,
108
108
  MEDIA_ERR_ABORTED: 1,
109
109
  MEDIA_ERR_NETWORK: 2,
110
110
  MEDIA_ERR_DECODE: 3,
111
111
  MEDIA_ERR_SRC_NOT_SUPPORTED: 4
112
- } : null, pe = (e) => ne(e, (e, t) => ({
112
+ } : null, me = (e) => ne(e, (e, t) => ({
113
113
  originalDetail: e instanceof CustomEvent ? e.detail : null,
114
- snapshot: C(t)
115
- })), me = async (e, t) => {
114
+ snapshot: de(t)
115
+ })), he = async (e, t) => {
116
116
  switch (t) {
117
117
  case "play": return await e.play(), null;
118
118
  case "pause": return e.pause(), null;
@@ -127,16 +127,16 @@ var ne = (e, t) => {
127
127
  }
128
128
  default: throw Error(`videoElement: unknown method "${t}"`);
129
129
  }
130
- }, he = (e) => ({
131
- call: async (t) => me(e, t),
130
+ }, ge = (e) => ({
131
+ call: async (t) => he(e, t),
132
132
  set: async (t, n) => {
133
133
  try {
134
134
  e[t] = n;
135
135
  } catch {}
136
- return C(e);
136
+ return de(e);
137
137
  },
138
- events: pe(e)
139
- }), ge = (e, t) => {
138
+ events: me(e)
139
+ }), _e = (e, t) => {
140
140
  let n = new EventTarget();
141
141
  Object.defineProperty(n, se, { value: !0 }), Object.defineProperty(n, ce, { value: e }), Object.defineProperty(n, le, { value: t });
142
142
  let r = b({
@@ -174,7 +174,7 @@ var ne = (e, t) => {
174
174
  configurable: !0,
175
175
  enumerable: !0,
176
176
  get() {
177
- return fe(e.error);
177
+ return pe(e.error);
178
178
  }
179
179
  },
180
180
  play: {
@@ -233,11 +233,11 @@ var ne = (e, t) => {
233
233
  configurable: !0,
234
234
  enumerable: !0,
235
235
  get() {
236
- return de(e[t]);
236
+ return fe(e[t]);
237
237
  }
238
238
  };
239
239
  return Object.defineProperties(n, i), n;
240
- }, _e = (e) => ge(C(e), he(e)), ve = (e) => typeof e == "object" && !!e && e[se] === !0, ye = (e, t) => {
240
+ }, ve = (e) => _e(de(e), ge(e)), ye = (e) => typeof e == "object" && !!e && e[se] === !0, be = (e, t) => {
241
241
  let n = e;
242
242
  return {
243
243
  ..._,
@@ -245,44 +245,44 @@ var ne = (e, t) => {
245
245
  initialState: n[ce],
246
246
  controller: ee(n[le], t)
247
247
  };
248
- }, be = (e, t) => {
248
+ }, xe = (e, t) => {
249
249
  let n = te(e.controller, t);
250
- return ge({ ...e.initialState }, n);
251
- }, xe = (e) => {
250
+ return _e({ ...e.initialState }, n);
251
+ }, Se = (e) => {
252
252
  let t = [];
253
253
  return e.forEach((e, n) => {
254
254
  t.push([n, e]);
255
255
  }), t;
256
- }, Se = "headers", Ce = {
257
- type: Se,
256
+ }, Ce = "headers", we = {
257
+ type: Ce,
258
258
  isType: (e) => e instanceof Headers,
259
259
  box: (e) => ({
260
260
  ..._,
261
- type: Se,
262
- entries: xe(e)
261
+ type: Ce,
262
+ entries: Se(e)
263
263
  }),
264
264
  revive: (e) => new Headers(e.entries)
265
- }, we = "response", Te = /* @__PURE__ */ new Set([
265
+ }, Te = "response", Ee = /* @__PURE__ */ new Set([
266
266
  101,
267
267
  204,
268
268
  205,
269
269
  304
270
- ]), Ee = {
271
- type: we,
270
+ ]), De = {
271
+ type: Te,
272
272
  isType: (e) => e instanceof Response,
273
273
  box: (e, t) => ({
274
274
  ..._,
275
- type: we,
275
+ type: Te,
276
276
  status: e.status,
277
277
  statusText: e.statusText,
278
- headers: Ce.box(e.headers),
278
+ headers: we.box(e.headers),
279
279
  body: e.body ? ee(e.body, t) : null,
280
280
  url: e.url,
281
281
  redirected: e.redirected
282
282
  }),
283
283
  revive: (e, t) => {
284
284
  if (e.status === 0) return Response.error();
285
- let n = Ce.revive(e.headers), r = e.body ? te(e.body, t) : null, i = Te.has(e.status);
285
+ let n = we.revive(e.headers), r = e.body ? te(e.body, t) : null, i = Ee.has(e.status);
286
286
  r && i && r.cancel().catch(() => {});
287
287
  let a = new Response(i ? null : r, {
288
288
  status: e.status,
@@ -297,22 +297,22 @@ var ne = (e, t) => {
297
297
  configurable: !0
298
298
  }), a;
299
299
  }
300
- }, De = (e) => [
300
+ }, Oe = (e) => [
301
301
  x,
302
- Ce,
303
- Ee,
302
+ we,
303
+ De,
304
304
  ...e
305
- ], Oe = 5, ke = 0, Ae = "fknExtension", je = "fknExtensionAbi", Me = "fknExtensionOps", Ne = [
305
+ ], ke = 5, Ae = 0, je = "fknExtension", Me = "fknExtensionAbi", Ne = "fknExtensionOps", Pe = [
306
306
  "data-fkn-extension",
307
307
  "data-fkn-extension-abi",
308
308
  "data-fkn-extension-ops"
309
- ], Pe = (e) => {
309
+ ], Fe = (e) => {
310
310
  if (e === void 0) return 0;
311
311
  let t = Number(e);
312
312
  return Number.isInteger(t) && t >= 0 ? t : 0;
313
- }, Fe = (e) => e === void 0 ? null : e.split(",").map((e) => e.trim()).filter(Boolean), Ie = (e, t = 0) => {
313
+ }, Ie = (e) => e === void 0 ? null : e.split(",").map((e) => e.trim()).filter(Boolean), Le = (e, t = 0) => {
314
314
  if (e.fknExtension !== "true") return { status: "absent" };
315
- let n = Pe(e[je]), r = Fe(e[Me]);
315
+ let n = Fe(e[Me]), r = Ie(e[Ne]);
316
316
  return n < t ? {
317
317
  status: "outdated",
318
318
  abi: n,
@@ -323,42 +323,42 @@ var ne = (e, t) => {
323
323
  abi: n,
324
324
  operations: r
325
325
  };
326
- }, Le = (e, t) => e.status === "ok" ? e.operations === null || e.operations.includes(t) : !1, Re = (e, t) => e.status === "ok" && e.operations !== null && e.operations.includes(t), w = class extends Error {
326
+ }, Re = (e, t) => e.status === "ok" ? e.operations === null || e.operations.includes(t) : !1, ze = (e, t) => e.status === "ok" && e.operations !== null && e.operations.includes(t), C = class extends Error {
327
327
  abi;
328
328
  required;
329
329
  name = "ExtensionOutdatedError";
330
330
  constructor(e, t) {
331
331
  super(`The FKN WebExtension is installed but too old for this page: it speaks ABI ${e} and this page needs at least ${t}. Updating the extension fixes this.`), this.abi = e, this.required = t;
332
332
  }
333
- }, T = class extends Error {
333
+ }, w = class extends Error {
334
334
  operation;
335
335
  abi;
336
336
  name = "ExtensionOperationUnsupportedError";
337
337
  constructor(e, t, n) {
338
338
  super(n ?? `The FKN WebExtension does not support "${e}" (ABI ${t}). Updating the extension may add it.`), this.operation = e, this.abi = t;
339
339
  }
340
- }, ze = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", Be = v();
341
- typeof document < "u" && document.addEventListener(ze, () => {
342
- Be.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: Ve() } }));
340
+ }, Be = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", Ve = v();
341
+ typeof document < "u" && document.addEventListener(Be, () => {
342
+ Ve.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: He() } }));
343
343
  });
344
- var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae] === "true", E = () => typeof document > "u" ? { status: "absent" } : Ie(document.documentElement.dataset), He = null, Ue = (e) => {
345
- He = e;
346
- }, We = 150, D = (e = 1e3) => new Promise((t, n) => {
347
- let r = () => E().status === "ok";
344
+ var He = () => typeof document > "u" ? !1 : document.documentElement.dataset[je] === "true", T = () => typeof document > "u" ? { status: "absent" } : Le(document.documentElement.dataset), Ue = null, We = (e) => {
345
+ Ue = e;
346
+ }, Ge = 150, E = (e = 1e3) => new Promise((t, n) => {
347
+ let r = () => T().status === "ok";
348
348
  if (r()) return t();
349
349
  let i, a = (e) => {
350
350
  clearTimeout(i), c.disconnect(), document.removeEventListener("readystatechange", l), e();
351
351
  }, o = () => a(async () => {
352
- let e = E();
353
- if (e.status === "outdated") return n(new w(e.abi, e.required));
354
- if (He) {
355
- if (await He().catch(() => {}), r()) return t();
356
- let e = E();
357
- if (e.status === "outdated") return n(new w(e.abi, e.required));
352
+ let e = T();
353
+ if (e.status === "outdated") return n(new C(e.abi, e.required));
354
+ if (Ue) {
355
+ if (await Ue().catch(() => {}), r()) return t();
356
+ let e = T();
357
+ if (e.status === "outdated") return n(new C(e.abi, e.required));
358
358
  }
359
359
  n(/* @__PURE__ */ Error("The FKN WebExtension is not installed, enabled or not exposed on this page."));
360
360
  }), s = () => {
361
- clearTimeout(i), i = setTimeout(() => r() ? a(t) : o(), We);
361
+ clearTimeout(i), i = setTimeout(() => r() ? a(t) : o(), Ge);
362
362
  }, c = new MutationObserver(() => {
363
363
  r() && a(t);
364
364
  }), l = () => {
@@ -366,33 +366,33 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
366
366
  };
367
367
  if (i = setTimeout(o, e), c.observe(document.documentElement, {
368
368
  attributes: !0,
369
- attributeFilter: [...Ne]
369
+ attributeFilter: [...Pe]
370
370
  }), document.addEventListener("readystatechange", l), document.readyState === "complete") return s();
371
371
  r() && a(t);
372
- }), Ge, O = new Proxy({}, { get: (e, t) => async (...e) => {
373
- await D(), Ge ??= y({}, {
372
+ }), Ke, D = new Proxy({}, { get: (e, t) => async (...e) => {
373
+ await E(), Ke ??= y({}, {
374
374
  transport: window,
375
- revivableModules: De
375
+ revivableModules: Oe
376
376
  });
377
- let n = (await Ge)[t];
377
+ let n = (await Ke)[t];
378
378
  return n(...e);
379
- } }), k = [
379
+ } }), O = [
380
380
  "origin",
381
381
  "referer",
382
382
  "cookie"
383
- ], Ke = (e, t) => (e ?? []).some(([e, n]) => e.trim().toLowerCase() === t && n !== ""), qe = (e) => Ke(e, "cookie"), Je = (e, t) => {
384
- if (t === "include" && qe(e)) throw Error("fetch: a forged Cookie header and credentials:'include' are different identities - send one or the other");
385
- }, Ye = (e, t) => {
383
+ ], qe = (e, t) => (e ?? []).some(([e, n]) => e.trim().toLowerCase() === t && n !== ""), Je = (e) => qe(e, "cookie"), Ye = (e, t) => {
384
+ if (t === "include" && Je(e)) throw Error("fetch: a forged Cookie header and credentials:'include' are different identities - send one or the other");
385
+ }, Xe = (e, t) => {
386
386
  if (!Array.isArray(t)) throw Error(`${e}: requestHeaders must be an array of header operations`);
387
387
  let n = [...new Set(t.map((e) => {
388
388
  let t = e?.header;
389
389
  return typeof t == "string" ? t.trim().toLowerCase() : String(t);
390
- }).filter((e) => !k.includes(e)))];
390
+ }).filter((e) => !O.includes(e)))];
391
391
  if (n.length) throw Error(`${e}: refusing to rewrite request header(s): ${n.join(", ")}`);
392
- }, Xe = (e) => {
393
- let t = [...new Set((e ?? []).map(([e]) => e.trim().toLowerCase()).filter((e) => !k.includes(e)))];
392
+ }, Ze = (e) => {
393
+ let t = [...new Set((e ?? []).map(([e]) => e.trim().toLowerCase()).filter((e) => !O.includes(e)))];
394
394
  if (t.length) throw Error(`fetch: refusing to forge request header(s): ${t.join(", ")}`);
395
- }, Ze = [
395
+ }, Qe = [
396
396
  "fkn.app",
397
397
  "fkn.dev",
398
398
  "sdbx.app",
@@ -414,7 +414,7 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
414
414
  "container-ckf.pages.dev",
415
415
  "stub-plugin.pages.dev",
416
416
  "stub.plugins.banou.dev"
417
- ], Qe = (e) => e.replace(/\.+$/, ""), $e = ["79.127.204.69", "152.233.49.59"], et = (e) => {
417
+ ], $e = (e) => e.replace(/\.+$/, ""), et = ["79.127.204.69", "152.233.49.59"], tt = (e) => {
418
418
  let t;
419
419
  try {
420
420
  t = new URL(`http://${e.includes(":") && !e.startsWith("[") ? `[${e}]` : e}/`).hostname;
@@ -432,18 +432,22 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
432
432
  ].join(".");
433
433
  }
434
434
  return /^\d+\.\d+\.\d+\.\d+$/.test(t) ? t : void 0;
435
- }, A = (e) => {
436
- let t = Qe(e);
437
- if (Ze.some((e) => t === e || t.endsWith(`.${e}`))) return !0;
438
- let n = et(t);
439
- return n !== void 0 && $e.includes(n);
440
- }, tt = {
435
+ }, k = (e) => {
436
+ let t = $e(e);
437
+ if (Qe.some((e) => t === e || t.endsWith(`.${e}`))) return !0;
438
+ let n = tt(t);
439
+ return n !== void 0 && et.includes(n);
440
+ }, nt = 100, rt = (e) => [...e.trim()], A = (e, t) => {
441
+ if (typeof t != "string") return;
442
+ let n = rt(t).length;
443
+ if (n > 100) throw TypeError(`${e}: reason must be at most 100 characters, not ${n}`);
444
+ }, it = {
441
445
  scope: "network.fetch",
442
446
  category: "network",
443
447
  severity: 0,
444
448
  title: "Fetch data from other sites",
445
449
  description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
446
- }, nt = {
450
+ }, at = {
447
451
  scope: "network.fetchCredentialed",
448
452
  category: "network",
449
453
  severity: 3,
@@ -451,7 +455,7 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
451
455
  unsafe: !0,
452
456
  title: "Fetch from other sites, signed in as you",
453
457
  description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
454
- }, rt = {
458
+ }, ot = {
455
459
  scope: "network.fetchLocal",
456
460
  category: "network",
457
461
  severity: 3,
@@ -459,12 +463,12 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
459
463
  unsafe: !0,
460
464
  title: "Access devices on your local network",
461
465
  description: "Lets the app reach devices and services on your home or work network, which websites normally cannot touch."
462
- }, it = (e) => {
466
+ }, st = (e) => {
463
467
  let t = e.match(/^(\d+)\.(\d+)\.\d+\.\d+$/);
464
468
  if (!t) return !1;
465
469
  let [n, r] = [Number(t[1]), Number(t[2])];
466
470
  return n === 10 || n === 127 || n === 0 || n === 169 && r === 254 || n === 172 && r >= 16 && r <= 31 || n === 192 && r === 168;
467
- }, at = (e) => {
471
+ }, ct = (e) => {
468
472
  let t;
469
473
  try {
470
474
  t = new URL(e);
@@ -472,57 +476,58 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
472
476
  return !1;
473
477
  }
474
478
  let n = t.hostname.replace(/^\[|\]$/g, "").toLowerCase().replace(/\.$/, "");
475
- return n === "localhost" || n.endsWith(".localhost") || n.endsWith(".local") || n.endsWith(".internal") || n.endsWith(".home.arpa") ? !0 : n.includes(":") ? n === "::" || n === "::1" || n.startsWith("fc") || n.startsWith("fd") || /^fe[89ab]/.test(n) || n.startsWith("::ffff:") : it(n);
476
- }, ot = (e) => {
479
+ return n === "localhost" || n.endsWith(".localhost") || n.endsWith(".local") || n.endsWith(".internal") || n.endsWith(".home.arpa") ? !0 : n.includes(":") ? n === "::" || n === "::1" || n.startsWith("fc") || n.startsWith("fd") || /^fe[89ab]/.test(n) || n.startsWith("::ffff:") : st(n);
480
+ }, lt = (e) => {
477
481
  let t;
478
482
  try {
479
483
  t = new URL(e);
480
484
  } catch {
481
485
  return !1;
482
486
  }
483
- return t.protocol === "chrome-extension:" || t.protocol === "moz-extension:" || A(t.hostname);
484
- }, st = (e) => {
485
- if (ot(e)) throw Error("fetch: refusing to target the extension's own pages or FKN platform domains");
486
- }, ct = (e) => {
487
+ return t.protocol === "chrome-extension:" || t.protocol === "moz-extension:" || k(t.hostname);
488
+ }, ut = (e) => {
489
+ if (lt(e)) throw Error("fetch: refusing to target the extension's own pages or FKN platform domains");
490
+ }, dt = (e) => {
487
491
  if (!e?.headers) return;
488
- let t = new Headers(e.headers), n = k.map((e) => {
492
+ let t = new Headers(e.headers), n = O.map((e) => {
489
493
  let n = t.get(e);
490
494
  return n === null || n === "" ? void 0 : [e, n];
491
495
  }).filter((e) => e !== void 0);
492
496
  return n.length ? n : void 0;
493
- }, lt = async (e, t) => {
497
+ }, ft = async (e, t) => {
498
+ A("fetch", t?.reason);
494
499
  let n = new Request(e, t);
495
- st(n.url);
500
+ ut(n.url);
496
501
  let r = n.body ? await n.arrayBuffer() : null;
497
- return O.proxyFetch({
502
+ return D.proxyFetch({
498
503
  url: n.url,
499
504
  method: n.method,
500
505
  headers: [...n.headers],
501
506
  body: r,
502
507
  credentials: t?.credentials === "include" ? "include" : "omit",
503
508
  redirect: n.redirect,
504
- unsafeHeaders: ct(t),
509
+ unsafeHeaders: dt(t),
505
510
  reason: t?.reason,
506
511
  signal: t?.signal ?? void 0
507
512
  });
508
- }, ut = (e) => {
509
- for (let t of e) if (typeof t == "string" && A(t.trim().toLowerCase())) return t;
510
- }, dt = (e) => {
513
+ }, pt = (e) => {
514
+ for (let t of e) if (typeof t == "string" && k(t.trim().toLowerCase())) return t;
515
+ }, mt = (e) => {
511
516
  let t = e.trim().toLowerCase().replace(/^\.+|\.+$/g, "");
512
- return t !== "" && (A(t) || [...Ze, ...$e].some((e) => e.endsWith(`.${t}`)));
513
- }, ft = (e) => {
514
- for (let t of e) if (typeof t == "string" && dt(t)) return t;
515
- }, pt = (e) => `${e}: refusing to target FKN platform domains`, mt = (e, t) => {
516
- if (ut(t) !== void 0) throw Error(pt(e));
517
+ return t !== "" && (k(t) || [...Qe, ...et].some((e) => e.endsWith(`.${t}`)));
517
518
  }, ht = (e) => {
519
+ for (let t of e) if (typeof t == "string" && mt(t)) return t;
520
+ }, gt = (e) => `${e}: refusing to target FKN platform domains`, _t = (e, t) => {
521
+ if (pt(t) !== void 0) throw Error(gt(e));
522
+ }, vt = (e) => {
518
523
  try {
519
524
  return new URL(String(e)).hostname;
520
525
  } catch {
521
526
  return "";
522
527
  }
523
528
  }, j = (e, t) => {
524
- if (ft(t) !== void 0) throw Error(pt(e));
525
- }, gt = {
529
+ if (ht(t) !== void 0) throw Error(gt(e));
530
+ }, yt = {
526
531
  scope: "network.readCookie",
527
532
  category: "network",
528
533
  severity: 3,
@@ -530,7 +535,7 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
530
535
  unsafe: !0,
531
536
  title: "Read a site’s cookie",
532
537
  description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
533
- }, _t = { get: async (e) => (mt("cookies.get", [ht(e.url)]), O.getCookie(e)) }, vt = {
538
+ }, bt = { get: async (e) => (_t("cookies.get", [vt(e.url)]), D.getCookie(e)) }, xt = {
534
539
  scope: "network.modifyRequestHeaders",
535
540
  category: "network",
536
541
  severity: 2,
@@ -538,7 +543,7 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
538
543
  unsafe: !0,
539
544
  title: "Rewrite request headers to other sites",
540
545
  description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
541
- }, yt = async (e) => (j("setRequestHeaderRule", e.domains), Ye("setRequestHeaderRule", e.requestHeaders), O.setRequestHeaderRule(e)), bt = (e) => O.removeRequestHeaderRule({ ruleId: e }), xt = class extends Error {
546
+ }, St = async (e) => (j("setRequestHeaderRule", e.domains), Xe("setRequestHeaderRule", e.requestHeaders), A("setRequestHeaderRule", e.reason), D.setRequestHeaderRule(e)), Ct = (e) => D.removeRequestHeaderRule({ ruleId: e }), wt = class extends Error {
542
547
  reason;
543
548
  filename;
544
549
  line;
@@ -547,7 +552,7 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
547
552
  constructor(e, t, n, r, i) {
548
553
  super(`${e}:${n}:${r}: ${t}`), this.reason = t, this.filename = e, this.line = n, this.column = r, this.source = i;
549
554
  }
550
- }, St = class {
555
+ }, Tt = class {
551
556
  start;
552
557
  end;
553
558
  source;
@@ -558,7 +563,7 @@ var Ve = () => typeof document > "u" ? !1 : document.documentElement.dataset[Ae]
558
563
  (function(e) {
559
564
  e.stylesheet = "stylesheet", e.rule = "rule", e.declaration = "declaration", e.comment = "comment", e.atRule = "at-rule", e.container = "container", e.charset = "charset", e.counterStyle = "counter-style", e.document = "document", e.customMedia = "custom-media", e.fontFace = "font-face", e.fontFeatureValues = "font-feature-values", e.host = "host", e.import = "import", e.keyframes = "keyframes", e.keyframe = "keyframe", e.layer = "layer", e.media = "media", e.namespace = "namespace", e.page = "page", e.pageMarginBox = "page-margin-box", e.positionTry = "position-try", e.property = "property", e.scope = "scope", e.startingStyle = "starting-style", e.supports = "supports", e.viewTransition = "view-transition";
560
565
  })(M ||= {});
561
- var Ct = (e, t, n) => {
566
+ var Et = (e, t, n) => {
562
567
  let r = n, i = 1e4;
563
568
  do {
564
569
  let n = t.map((t) => e.indexOf(t, r));
@@ -591,14 +596,14 @@ var Ct = (e, t, n) => {
591
596
  break;
592
597
  case "\"":
593
598
  {
594
- let t = Ct(e, ["\""], o + 1);
599
+ let t = Et(e, ["\""], o + 1);
595
600
  if (t === -1) return -1;
596
601
  r = t + 1;
597
602
  }
598
603
  break;
599
604
  case "'":
600
605
  {
601
- let t = Ct(e, ["'"], o + 1);
606
+ let t = Et(e, ["'"], o + 1);
602
607
  if (t === -1) return -1;
603
608
  r = t + 1;
604
609
  }
@@ -608,17 +613,17 @@ var Ct = (e, t, n) => {
608
613
  i--;
609
614
  } while (i > 0);
610
615
  throw Error("Too many escaping");
611
- }, wt = /\/\*[^]*?(?:\*\/|$)/g;
616
+ }, Dt = /\/\*[^]*?(?:\*\/|$)/g;
612
617
  function P(e) {
613
618
  return e ? e.trim() : "";
614
619
  }
615
- function Tt(e, t) {
620
+ function Ot(e, t) {
616
621
  let n = e && typeof e.type == "string", r = n ? e : t;
617
622
  for (let t in e) {
618
623
  let n = e[t];
619
624
  Array.isArray(n) ? n.forEach((e) => {
620
- Tt(e, r);
621
- }) : n && typeof n == "object" && Tt(n, r);
625
+ Ot(e, r);
626
+ }) : n && typeof n == "object" && Ot(n, r);
622
627
  }
623
628
  return n && Object.defineProperty(e, "parent", {
624
629
  configurable: !0,
@@ -627,7 +632,7 @@ function Tt(e, t) {
627
632
  value: t || null
628
633
  }), e;
629
634
  }
630
- var Et = class {
635
+ var kt = class {
631
636
  level = 0;
632
637
  indentation = " ";
633
638
  compress = !1;
@@ -777,7 +782,7 @@ var Et = class {
777
782
  declaration(e) {
778
783
  return this.compress ? this.emit(`${e.property}:${e.value}`, e.position) + this.emit(";") : e.property === "grid-template-areas" ? this.emit(this.indent()) + this.emit(e.property + ": " + e.value.split("\n").join("\n".padEnd(22) + this.indent()), e.position) + this.emit(";") : this.emit(this.indent()) + this.emit(`${e.property}: ${e.value}`, e.position) + this.emit(";");
779
784
  }
780
- }, Dt = (e, t) => {
785
+ }, At = (e, t) => {
781
786
  t ||= {};
782
787
  let n = 1, r = 1;
783
788
  function i() {
@@ -785,14 +790,14 @@ var Et = class {
785
790
  line: n,
786
791
  column: r
787
792
  };
788
- return (i) => (i.position = new St(e, {
793
+ return (i) => (i.position = new Tt(e, {
789
794
  line: n,
790
795
  column: r
791
796
  }, t?.source || ""), u(), i);
792
797
  }
793
798
  let a = [];
794
799
  function o(i) {
795
- let o = new xt(t?.source || "", i, n, r, e);
800
+ let o = new wt(t?.source || "", i, n, r, e);
796
801
  if (!t?.silent) throw o;
797
802
  a.push(o);
798
803
  }
@@ -844,7 +849,7 @@ var Et = class {
844
849
  n.push(e.substring(r, i)), r = i + 1;
845
850
  }
846
851
  return n;
847
- })(P(n).replace(wt, ""), [","]).map((e) => P(e));
852
+ })(P(n).replace(Dt, ""), [","]).map((e) => P(e));
848
853
  }
849
854
  function m() {
850
855
  let t = i(), n = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);
@@ -854,10 +859,10 @@ var Et = class {
854
859
  if (!a) return o("property missing ':'");
855
860
  l(a);
856
861
  let s = "", c = N(e, [";", "}"]);
857
- c !== -1 && (s = e.substring(0, c), l([s]), s = P(s).replace(wt, ""));
862
+ c !== -1 && (s = e.substring(0, c), l([s]), s = P(s).replace(Dt, ""));
858
863
  let u = t({
859
864
  type: M.declaration,
860
- property: r.replace(wt, ""),
865
+ property: r.replace(Dt, ""),
861
866
  value: s
862
867
  }), d = /^[;\s]*/.exec(e);
863
868
  return d && l(d), u;
@@ -1235,7 +1240,7 @@ var Et = class {
1235
1240
  declarations: _() || []
1236
1241
  })) : o("selector missing");
1237
1242
  }
1238
- return Tt(function() {
1243
+ return Ot(function() {
1239
1244
  let n = function() {
1240
1245
  let n, r = [];
1241
1246
  for (u(), d(r); e.length;) {
@@ -1266,66 +1271,66 @@ var Et = class {
1266
1271
  }
1267
1272
  };
1268
1273
  }());
1269
- }, Ot = (e, t) => new Et(t || {}).compile(e), kt = Object.defineProperty, At = (e, t) => {
1274
+ }, jt = (e, t) => new kt(t || {}).compile(e), Mt = Object.defineProperty, Nt = (e, t) => {
1270
1275
  let n = {};
1271
- for (var r in e) kt(n, r, {
1276
+ for (var r in e) Mt(n, r, {
1272
1277
  get: e[r],
1273
1278
  enumerable: !0
1274
1279
  });
1275
- return t || kt(n, Symbol.toStringTag, { value: "Module" }), n;
1276
- }, jt = "LocatorError", Mt = "LocatorUnsupportedError", Nt = "LocatorDeniedError", Pt = "LocatorInvalidError", Ft = (e) => typeof e == "object" && e ? e.name : void 0, F = (e) => Object.assign(Error(e), { name: jt }), I = (e, t = "", n) => Object.assign(Error(e), {
1277
- name: Mt,
1280
+ return t || Mt(n, Symbol.toStringTag, { value: "Module" }), n;
1281
+ }, Pt = "LocatorError", Ft = "LocatorUnsupportedError", It = "LocatorDeniedError", Lt = "LocatorInvalidError", Rt = (e) => typeof e == "object" && e ? e.name : void 0, F = (e) => Object.assign(Error(e), { name: Pt }), I = (e, t = "", n) => Object.assign(Error(e), {
1282
+ name: Ft,
1278
1283
  operation: t,
1279
1284
  backend: n
1280
- }), It = (e, t) => I(`Locator operation not supported${t ? ` on the ${t} backend` : ""}: ${e}`, e, t), L = (e, t) => Object.assign(Error(e), {
1281
- name: Nt,
1285
+ }), zt = (e, t) => I(`Locator operation not supported${t ? ` on the ${t} backend` : ""}: ${e}`, e, t), L = (e, t) => Object.assign(Error(e), {
1286
+ name: It,
1282
1287
  operation: t
1283
- }), Lt = (e, t) => Object.assign(Error(e), {
1284
- name: Pt,
1288
+ }), Bt = (e, t) => Object.assign(Error(e), {
1289
+ name: Lt,
1285
1290
  operation: t
1286
1291
  }), R = class extends Error {
1287
1292
  name = "TimeoutError";
1288
1293
  constructor(e, t) {
1289
1294
  super(e, t?.cause === void 0 ? void 0 : { cause: t.cause });
1290
1295
  }
1291
- }, Rt = (e) => Ft(e) === Mt, zt = (e) => Ft(e) === Nt, z = (e) => Ft(e) === Pt, B = (e) => zt(e) || Rt(e) || z(e), V = (e) => {
1296
+ }, Vt = (e) => Rt(e) === Ft, Ht = (e) => Rt(e) === It, Ut = (e) => Rt(e) === Lt, z = (e) => Ht(e) || Vt(e) || Ut(e), B = (e) => {
1292
1297
  let t = (e.ownerDocument ?? e).defaultView;
1293
1298
  if (!t) throw F("the resolved element belongs to a document with no window");
1294
1299
  return t;
1295
- }, Bt = (e, t) => {
1300
+ }, Wt = (e, t) => {
1296
1301
  let n = e?.[t];
1297
1302
  return typeof n == "function" ? n : null;
1298
- }, H = (e, t) => {
1303
+ }, Gt = (e, t) => {
1299
1304
  if (typeof e != "object" || !e) return null;
1300
1305
  let n = (() => {
1301
1306
  try {
1302
- return Bt(V(e), t);
1307
+ return Wt(B(e), t);
1303
1308
  } catch {
1304
1309
  return null;
1305
1310
  }
1306
1311
  })();
1307
1312
  if (n && e instanceof n) return n;
1308
- let r = Bt(globalThis, t);
1313
+ let r = Wt(globalThis, t);
1309
1314
  return r && e instanceof r ? r : null;
1310
- }, U = (e, t) => H(e, t) !== null, W = (e) => {
1315
+ }, V = (e, t) => Gt(e, t) !== null, H = (e) => {
1311
1316
  if (e.length === 0) throw F("No elements found");
1312
1317
  if (e.length > 1) throw F(`Strict mode violation: locator resolved to ${e.length} elements`);
1313
1318
  return e[0];
1314
- }, Vt = (e, t) => {
1315
- if (!U(e, t)) throw F(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);
1319
+ }, Kt = (e, t) => {
1320
+ if (!V(e, t)) throw F(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);
1316
1321
  return e;
1317
- }, Ht = (e) => e.tagName.toLowerCase(), Ut = /* @__PURE__ */ new Set(), Wt = (e) => {
1318
- Ut.add(e);
1319
- }, Gt = /(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i, Kt = (e) => e.replace(/\\([0-9a-fA-F]{1,6})\s?/g, (e, t) => String.fromCodePoint(Number.parseInt(t, 16))).replace(/\\(.)/g, "$1"), qt = (e) => !Gt.test(Kt(e.value)), Jt = /* @__PURE__ */ new Set([
1322
+ }, qt = (e) => e.tagName.toLowerCase(), Jt = /* @__PURE__ */ new Set(), Yt = (e) => {
1323
+ Jt.add(e);
1324
+ }, Xt = /(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i, Zt = (e) => e.replace(/\\([0-9a-fA-F]{1,6})\s?/g, (e, t) => String.fromCodePoint(Number.parseInt(t, 16))).replace(/\\(.)/g, "$1"), Qt = (e) => !Xt.test(Zt(e.value)), $t = /* @__PURE__ */ new Set([
1320
1325
  M.import,
1321
1326
  M.fontFace,
1322
1327
  M.namespace,
1323
1328
  M.charset,
1324
1329
  M.document,
1325
1330
  M.comment
1326
- ]), Yt = (e) => {
1327
- if (Jt.has(e.type)) return null;
1328
- if (e.type === M.declaration) return qt(e) ? e : null;
1331
+ ]), en = (e) => {
1332
+ if ($t.has(e.type)) return null;
1333
+ if (e.type === M.declaration) return Qt(e) ? e : null;
1329
1334
  let t = e, n = { ...t };
1330
1335
  for (let e of [
1331
1336
  "declarations",
@@ -1333,18 +1338,18 @@ var Et = class {
1333
1338
  "keyframes"
1334
1339
  ]) {
1335
1340
  let r = t[e];
1336
- Array.isArray(r) && (n[e] = Xt(r));
1341
+ Array.isArray(r) && (n[e] = tn(r));
1337
1342
  }
1338
1343
  return n;
1339
- }, Xt = (e) => e.map((e) => Yt(e)).filter((e) => e !== null), Zt = (e) => {
1344
+ }, tn = (e) => e.map((e) => en(e)).filter((e) => e !== null), nn = (e) => {
1340
1345
  let t;
1341
1346
  try {
1342
- t = Dt(e, { silent: !0 });
1347
+ t = At(e, { silent: !0 });
1343
1348
  } catch {
1344
1349
  return "";
1345
1350
  }
1346
- return t.stylesheet.rules = Xt(t.stylesheet.rules), Ot(t);
1347
- }, Qt = (e, t) => {
1351
+ return t.stylesheet.rules = tn(t.stylesheet.rules), jt(t);
1352
+ }, rn = (e, t) => {
1348
1353
  let n = () => {
1349
1354
  t.parentNode || (e.head ?? e.documentElement).appendChild(t);
1350
1355
  };
@@ -1361,30 +1366,30 @@ var Et = class {
1361
1366
  });
1362
1367
  let i = () => r.disconnect(), a = e.defaultView;
1363
1368
  a ? a.addEventListener("load", i, { once: !0 }) : setTimeout(i, 3e4);
1364
- }, $t = { resolve: (e, t) => {
1369
+ }, an = { resolve: (e, t) => {
1365
1370
  let n = e.document.createElement("style");
1366
- n.textContent = t.noSanitize ? t.content : Zt(t.content);
1371
+ n.textContent = t.noSanitize ? t.content : nn(t.content);
1367
1372
  try {
1368
- Qt(e.document, n);
1373
+ rn(e.document, n);
1369
1374
  } catch (e) {
1370
1375
  console.error(e);
1371
1376
  }
1372
- Wt(n);
1373
- } }, en = (e) => {
1377
+ Yt(n);
1378
+ } }, on = (e) => {
1374
1379
  let t = [];
1375
1380
  return e.forEach((e, n) => {
1376
1381
  t.push([n, e]);
1377
1382
  }), t;
1378
- }, G = {
1383
+ }, U = {
1379
1384
  kind: "frame",
1380
1385
  ensureArgs: (e) => [void 0, e],
1381
1386
  resolve: async (e, t, n = {}) => {
1382
- if (typeof t != "string") throw Lt("fetch: url must be a string", "fetch");
1383
- let r = V(e.document), i;
1387
+ if (typeof t != "string") throw Bt("fetch: url must be a string", "fetch");
1388
+ let r = B(e.document), i;
1384
1389
  try {
1385
1390
  i = new r.URL(t, e.document.baseURI).href;
1386
1391
  } catch {
1387
- throw Lt(`fetch: not a valid url: ${t}`, "fetch");
1392
+ throw Bt(`fetch: not a valid url: ${t}`, "fetch");
1388
1393
  }
1389
1394
  let a = await r.fetch(i, {
1390
1395
  method: n.method ?? "GET",
@@ -1400,31 +1405,31 @@ var Et = class {
1400
1405
  url: a.url,
1401
1406
  redirected: a.redirected,
1402
1407
  type: a.type,
1403
- headers: en(a.headers),
1408
+ headers: on(a.headers),
1404
1409
  body: await a.arrayBuffer()
1405
1410
  };
1406
1411
  }
1407
- }, K = /* @__PURE__ */ At({
1408
- click: () => nn,
1409
- count: () => dn,
1410
- exists: () => fn,
1411
- fill: () => sn,
1412
- getAttribute: () => ln,
1413
- hover: () => rn,
1414
- isVisible: () => un,
1415
- textContent: () => cn
1416
- }), tn = (e, t) => {
1412
+ }, W = /* @__PURE__ */ Nt({
1413
+ click: () => cn,
1414
+ count: () => gn,
1415
+ exists: () => _n,
1416
+ fill: () => fn,
1417
+ getAttribute: () => mn,
1418
+ hover: () => ln,
1419
+ isVisible: () => hn,
1420
+ textContent: () => pn
1421
+ }), sn = (e, t) => {
1417
1422
  let n = e.getBoundingClientRect();
1418
1423
  return {
1419
1424
  clientX: n.left + n.width * (t?.x ?? .5),
1420
1425
  clientY: n.top + n.height * (t?.y ?? .5)
1421
1426
  };
1422
- }, nn = { resolve: (e, t = {}) => {
1423
- let n = W(e.elements), r = V(n), i = {
1427
+ }, cn = { resolve: (e, t = {}) => {
1428
+ let n = H(e.elements), r = B(n), i = {
1424
1429
  bubbles: !0,
1425
1430
  cancelable: !0,
1426
1431
  composed: !0,
1427
- ...tn(n, t.position),
1432
+ ...sn(n, t.position),
1428
1433
  button: 0
1429
1434
  }, a = {
1430
1435
  ...i,
@@ -1448,12 +1453,12 @@ var Et = class {
1448
1453
  ...i,
1449
1454
  buttons: 0
1450
1455
  }));
1451
- } }, rn = { resolve: (e, t = {}) => {
1452
- let n = W(e.elements), r = V(n), i = {
1456
+ } }, ln = { resolve: (e, t = {}) => {
1457
+ let n = H(e.elements), r = B(n), i = {
1453
1458
  bubbles: !0,
1454
1459
  cancelable: !0,
1455
1460
  composed: !0,
1456
- ...tn(n, t.position)
1461
+ ...sn(n, t.position)
1457
1462
  }, a = {
1458
1463
  ...i,
1459
1464
  pointerType: "mouse",
@@ -1467,11 +1472,11 @@ var Et = class {
1467
1472
  ...i,
1468
1473
  bubbles: !1
1469
1474
  })), n.dispatchEvent(new r.MouseEvent("mouseover", i)), n.dispatchEvent(new r.PointerEvent("pointermove", a)), n.dispatchEvent(new r.MouseEvent("mousemove", i));
1470
- } }, an = (e, t) => {
1475
+ } }, un = (e, t) => {
1471
1476
  e._valueTracker?.setValue("");
1472
- let n = (H(e, "HTMLTextAreaElement") ?? H(e, "HTMLInputElement"))?.prototype, r = n && Object.getOwnPropertyDescriptor(n, "value")?.set;
1477
+ let n = (Gt(e, "HTMLTextAreaElement") ?? Gt(e, "HTMLInputElement"))?.prototype, r = n && Object.getOwnPropertyDescriptor(n, "value")?.set;
1473
1478
  r ? r.call(e, t) : e.value = t;
1474
- }, on = (e, t) => {
1479
+ }, dn = (e, t) => {
1475
1480
  if (e.type !== "range") return null;
1476
1481
  let n = Number(e.min || 0), r = Number(e.max || 100);
1477
1482
  if (!Number.isFinite(n) || !Number.isFinite(r) || r <= n) return null;
@@ -1508,61 +1513,61 @@ var Et = class {
1508
1513
  buttons: 0
1509
1514
  }
1510
1515
  };
1511
- }, sn = { resolve: (e, t, n = {}) => {
1512
- let r = W(e.elements), i = V(r), a = U(r, "HTMLInputElement");
1513
- if (a || U(r, "HTMLTextAreaElement")) {
1514
- let e = r, n = a ? on(e, t) : null;
1515
- n && (r.dispatchEvent(new i.PointerEvent("pointerdown", n.pointerDown)), r.dispatchEvent(new i.MouseEvent("mousedown", n.mouseDown))), an(e, t), r.dispatchEvent(new i.Event("input", { bubbles: !0 })), n && (r.dispatchEvent(new i.PointerEvent("pointerup", n.pointerUp)), r.dispatchEvent(new i.MouseEvent("mouseup", n.mouseUp))), r.dispatchEvent(new i.Event("change", { bubbles: !0 }));
1516
+ }, fn = { resolve: (e, t, n = {}) => {
1517
+ let r = H(e.elements), i = B(r), a = V(r, "HTMLInputElement");
1518
+ if (a || V(r, "HTMLTextAreaElement")) {
1519
+ let e = r, n = a ? dn(e, t) : null;
1520
+ n && (r.dispatchEvent(new i.PointerEvent("pointerdown", n.pointerDown)), r.dispatchEvent(new i.MouseEvent("mousedown", n.mouseDown))), un(e, t), r.dispatchEvent(new i.Event("input", { bubbles: !0 })), n && (r.dispatchEvent(new i.PointerEvent("pointerup", n.pointerUp)), r.dispatchEvent(new i.MouseEvent("mouseup", n.mouseUp))), r.dispatchEvent(new i.Event("change", { bubbles: !0 }));
1516
1521
  return;
1517
1522
  }
1518
- if (U(r, "HTMLElement") && r.isContentEditable) {
1523
+ if (V(r, "HTMLElement") && r.isContentEditable) {
1519
1524
  r.textContent = t, r.dispatchEvent(new i.Event("input", { bubbles: !0 }));
1520
1525
  return;
1521
1526
  }
1522
- throw Error(`fill: element <${Ht(r)}> is not fillable`);
1523
- } }, cn = { resolve: (e, t = {}) => W(e.elements).textContent }, ln = { resolve: (e, t, n = {}) => W(e.elements).getAttribute(t) }, un = { resolve: (e, t = {}) => {
1524
- let n = W(e.elements);
1525
- if (!U(n, "HTMLElement")) return !0;
1526
- let r = V(n).getComputedStyle(n);
1527
+ throw Error(`fill: element <${qt(r)}> is not fillable`);
1528
+ } }, pn = { resolve: (e, t = {}) => H(e.elements).textContent }, mn = { resolve: (e, t, n = {}) => H(e.elements).getAttribute(t) }, hn = { resolve: (e, t = {}) => {
1529
+ let n = H(e.elements);
1530
+ if (!V(n, "HTMLElement")) return !0;
1531
+ let r = B(n).getComputedStyle(n);
1527
1532
  if (r?.display === "none" || r?.visibility === "hidden") return !1;
1528
1533
  let i = n.getBoundingClientRect();
1529
1534
  return i.width > 0 && i.height > 0;
1530
- } }, dn = { resolve: (e, t = {}) => e.elements.length }, fn = { resolve: (e, t = {}) => e.elements.length > 0 }, q = (e, t) => (e.topLevel ? [e.document] : e.elements).flatMap((e) => [...e.querySelectorAll(t)]), pn = (e) => e.replaceAll("\"", "\\\""), mn = {
1535
+ } }, gn = { resolve: (e, t = {}) => e.elements.length }, _n = { resolve: (e, t = {}) => e.elements.length > 0 }, G = (e, t) => (e.topLevel ? [e.document] : e.elements).flatMap((e) => [...e.querySelectorAll(t)]), vn = (e) => e.replaceAll("\"", "\\\""), yn = {
1531
1536
  to: "element",
1532
1537
  css: !0,
1533
- resolve: (e, t) => q(e, t),
1538
+ resolve: (e, t) => G(e, t),
1534
1539
  render: (e) => ({
1535
1540
  fragment: typeof e == "string" ? e : "?",
1536
1541
  separator: "descend"
1537
1542
  })
1538
- }, hn = {
1543
+ }, bn = {
1539
1544
  to: "frame",
1540
1545
  css: !0,
1541
1546
  barrier: "down",
1542
- resolve: (e, t) => q(e, t),
1547
+ resolve: (e, t) => G(e, t),
1543
1548
  render: (e) => ({
1544
1549
  fragment: typeof e == "string" ? e : "?",
1545
1550
  separator: "down"
1546
1551
  })
1547
- }, gn = {
1552
+ }, xn = {
1548
1553
  element: {
1549
1554
  selectors: {
1550
- locator: mn,
1551
- frameLocator: hn,
1555
+ locator: yn,
1556
+ frameLocator: bn,
1552
1557
  getByRole: {
1553
1558
  to: "element",
1554
- resolve: (e, t) => q(e, `[role="${CSS.escape(t)}"]`),
1555
- render: (e) => ({ fragment: typeof e == "string" ? `[role="${pn(e)}"]` : "[role]" })
1559
+ resolve: (e, t) => G(e, `[role="${CSS.escape(t)}"]`),
1560
+ render: (e) => ({ fragment: typeof e == "string" ? `[role="${vn(e)}"]` : "[role]" })
1556
1561
  },
1557
1562
  getByText: {
1558
1563
  to: "element",
1559
1564
  resolve: (e, t) => e.elements.flatMap((e) => [e, ...e.querySelectorAll("*")]).filter((e) => e.textContent?.includes(t)),
1560
- render: (e) => ({ fragment: typeof e == "string" ? `:has-text("${pn(e)}")` : ":has-text(...)" })
1565
+ render: (e) => ({ fragment: typeof e == "string" ? `:has-text("${vn(e)}")` : ":has-text(...)" })
1561
1566
  },
1562
1567
  getByTestId: {
1563
1568
  to: "element",
1564
- resolve: (e, t) => q(e, `[data-testid="${CSS.escape(t)}"]`),
1565
- render: (e) => ({ fragment: typeof e == "string" ? `[data-testid="${pn(e)}"]` : "[data-testid]" })
1569
+ resolve: (e, t) => G(e, `[data-testid="${CSS.escape(t)}"]`),
1570
+ render: (e) => ({ fragment: typeof e == "string" ? `[data-testid="${vn(e)}"]` : "[data-testid]" })
1566
1571
  },
1567
1572
  first: {
1568
1573
  to: "element",
@@ -1579,20 +1584,20 @@ var Et = class {
1579
1584
  }
1580
1585
  },
1581
1586
  operations: {
1582
- click: nn,
1583
- fill: sn,
1584
- hover: rn,
1585
- textContent: cn,
1586
- getAttribute: ln,
1587
- isVisible: un,
1588
- count: dn,
1589
- exists: fn
1587
+ click: cn,
1588
+ fill: fn,
1589
+ hover: ln,
1590
+ textContent: pn,
1591
+ getAttribute: mn,
1592
+ isVisible: hn,
1593
+ count: gn,
1594
+ exists: _n
1590
1595
  }
1591
1596
  },
1592
1597
  frame: {
1593
1598
  selectors: {
1594
- locator: mn,
1595
- frameLocator: hn,
1599
+ locator: yn,
1600
+ frameLocator: bn,
1596
1601
  owner: {
1597
1602
  to: "frame",
1598
1603
  barrier: "up",
@@ -1606,11 +1611,11 @@ var Et = class {
1606
1611
  }
1607
1612
  },
1608
1613
  operations: {
1609
- addStyleTag: $t,
1610
- fetch: G
1614
+ addStyleTag: an,
1615
+ fetch: U
1611
1616
  }
1612
1617
  }
1613
- }, _n = (e, t = gn) => ({
1618
+ }, Sn = (e, t = xn) => ({
1614
1619
  element: {
1615
1620
  selectors: {
1616
1621
  ...t.element.selectors,
@@ -1631,79 +1636,81 @@ var Et = class {
1631
1636
  ...e.frame?.operations
1632
1637
  }
1633
1638
  }
1634
- }), vn = 3e4, yn = 50, bn = (e) => {
1639
+ }), Cn = 3e4, wn = 50, K = (e) => {
1635
1640
  let t = e[e.length - 1];
1636
1641
  return typeof t == "object" && t ? t : void 0;
1637
- }, xn = (e) => {
1638
- let t = bn(e)?.timeout;
1639
- return typeof t == "number" ? t : vn;
1640
- }, Sn = ({ executor: e, parts: t }) => ({ highlight: (n) => e.highlight(t, n).then(() => {}, () => {}) }), Cn = async (e) => {
1642
+ }, Tn = (e) => {
1643
+ let t = K(e)?.timeout;
1644
+ return typeof t == "number" ? t : Cn;
1645
+ }, En = ({ executor: e, parts: t }) => ({ highlight: (n) => e.highlight(t, n).then(() => {}, () => {}) }), Dn = async (e) => {
1641
1646
  let t = {
1642
1647
  parts: e.parts,
1643
1648
  operation: e.operation,
1644
1649
  args: e.args,
1645
1650
  phase: "ensure"
1646
1651
  };
1647
- await e.gate?.(t, Sn(e));
1648
- }, wn = (e, t) => {
1652
+ await e.gate?.(t, En(e));
1653
+ }, On = (e, t) => {
1649
1654
  if (t !== void 0 && typeof t == "number" && !(Number.isFinite(t) && t > 0)) throw TypeError(`${e}: timeout must be a positive number of milliseconds, not ${t}; every call ends at its deadline, so 0 does not turn it off`);
1650
- }, Tn = (e) => typeof e == "object" && e && typeof e.message == "string" ? e.message : String(e), En = async (e) => {
1655
+ }, kn = (e) => typeof e == "object" && e && typeof e.message == "string" ? e.message : String(e), An = async (e) => {
1651
1656
  let { executor: t, gate: n, parts: r, operation: i, args: a } = e;
1652
- wn(i, bn(a)?.timeout), n && await n({
1657
+ On(i, K(a)?.timeout), n && await n({
1653
1658
  parts: r,
1654
1659
  operation: i,
1655
1660
  args: a,
1656
1661
  phase: "execute"
1657
- }, Sn(e));
1658
- let o = xn(a), s = Date.now() + o, c = /* @__PURE__ */ Error(`Locator timeout (${o}ms): ${i}`), { promise: l, reject: u } = Promise.withResolvers();
1662
+ }, En(e));
1663
+ let o = Tn(a), s = Date.now() + o, c = /* @__PURE__ */ Error(`Locator timeout (${o}ms): ${i}`), { promise: l, reject: u } = Promise.withResolvers();
1659
1664
  l.catch(() => {});
1660
1665
  let d = setTimeout(() => u(c), o), f = c;
1661
1666
  try {
1662
- for (; Date.now() < s;) try {
1663
- return await Promise.race([t.execute(r, i, a), l]);
1664
- } catch (e) {
1665
- if (e === c) break;
1666
- if (B(e)) throw e;
1667
- f = e;
1668
- let t = s - Date.now();
1669
- if (t <= 0) break;
1670
- await new Promise((e) => setTimeout(e, Math.min(yn, t)));
1671
- }
1667
+ do
1668
+ try {
1669
+ return await Promise.race([t.execute(r, i, a), l]);
1670
+ } catch (e) {
1671
+ if (e === c) break;
1672
+ if (z(e)) throw e;
1673
+ f = e;
1674
+ let t = s - Date.now();
1675
+ if (t <= 0) break;
1676
+ await new Promise((e) => setTimeout(e, Math.min(wn, t)));
1677
+ }
1678
+ while (Date.now() < s);
1672
1679
  } finally {
1673
1680
  clearTimeout(d);
1674
1681
  }
1675
- throw f === c ? new R(c.message) : new R(Tn(f), { cause: f });
1676
- }, Dn = (e, t, n, r, i) => {
1682
+ throw f === c ? new R(c.message) : new R(kn(f), { cause: f });
1683
+ }, jn = (e, t, n, r, i) => {
1677
1684
  let a = {};
1678
- for (let [o, s] of Object.entries(t[r].selectors)) a[o] = (...a) => Dn(e, t, n, s.to, [...i, {
1685
+ for (let [o, s] of Object.entries(t[r].selectors)) a[o] = (...a) => jn(e, t, n, s.to, [...i, {
1679
1686
  kind: r,
1680
1687
  name: o,
1681
1688
  args: a
1682
1689
  }]);
1683
- for (let [n, o] of Object.entries(t[r].operations)) a[n] = async (...t) => En({
1690
+ for (let [n, o] of Object.entries(t[r].operations)) a[n] = async (...t) => An({
1684
1691
  ...e,
1685
1692
  parts: i,
1686
1693
  operation: n,
1687
1694
  args: o.send ? o.send(...t) : t
1688
1695
  });
1689
- for (let [o, { to: s, rewrite: c }] of Object.entries(n[r] ?? {})) a[o] = (...r) => Dn(e, t, n, s, c(i, ...r));
1696
+ for (let [o, { to: s, rewrite: c }] of Object.entries(n[r] ?? {})) a[o] = (...r) => jn(e, t, n, s, c(i, ...r));
1690
1697
  return a.ensure = (n, a = {}) => {
1691
1698
  let o = t[r].operations[n]?.ensureArgs;
1692
- return Cn({
1699
+ return Dn({
1693
1700
  ...e,
1694
1701
  parts: i,
1695
1702
  operation: n,
1696
1703
  args: o?.(a) ?? [a]
1697
1704
  });
1698
1705
  }, a;
1699
- }, On = (e) => Dn(e, e.modules ?? gn, e.rewrites ?? {}, "frame", []), kn = () => {
1700
- let e = E();
1706
+ }, Mn = (e) => jn(e, e.modules ?? xn, e.rewrites ?? {}, "frame", []), Nn = () => {
1707
+ let e = T();
1701
1708
  return e.status === "ok" && e.abi >= 2;
1702
- }, An = async () => {
1703
- await D();
1704
- let e = E();
1705
- if (e.status === "ok" && e.abi < 2) throw new w(e.abi, 2);
1706
- }, jn = (e) => `Read the text, links and details ${e} shows.`, Mn = (e) => `Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`, Nn = [
1709
+ }, Pn = async () => {
1710
+ await E();
1711
+ let e = T();
1712
+ if (e.status === "ok" && e.abi < 2) throw new C(e.abi, 2);
1713
+ }, Fn = (e) => `Read the text, links and details ${e} shows.`, In = (e) => `Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`, Ln = [
1707
1714
  {
1708
1715
  id: "interaction",
1709
1716
  heading: "Interaction",
@@ -1718,9 +1725,9 @@ var Et = class {
1718
1725
  heading: "Site data",
1719
1726
  summary: "Can read the website's data",
1720
1727
  title: (e) => `Read data from ${e}`,
1721
- description: jn,
1728
+ description: Fn,
1722
1729
  cloudTitle: (e) => `Read what's on ${e}`,
1723
- cloudDescription: jn
1730
+ cloudDescription: Fn
1724
1731
  },
1725
1732
  {
1726
1733
  id: "network",
@@ -1736,11 +1743,11 @@ var Et = class {
1736
1743
  heading: "Evaluation",
1737
1744
  summary: "Can execute arbitrary code on the website",
1738
1745
  title: (e) => `Run code on ${e}`,
1739
- description: Mn,
1746
+ description: In,
1740
1747
  cloudTitle: (e) => `Run its own code on ${e}`,
1741
- cloudDescription: Mn
1748
+ cloudDescription: In
1742
1749
  }
1743
- ], Pn = (e) => (t) => {
1750
+ ], Rn = (e) => (t) => {
1744
1751
  if (typeof t != "object" || !t) return t === void 0 ? [] : [t];
1745
1752
  if (t.position !== void 0) throw TypeError(`${e}: position is Playwright's offset in pixels, which no backend serves yet; pass relativePosition, a 0..1 fraction of the box`);
1746
1753
  let { relativePosition: n, ...r } = t;
@@ -1748,46 +1755,46 @@ var Et = class {
1748
1755
  ...r,
1749
1756
  position: n
1750
1757
  }];
1751
- }, Fn = async (e, t, n) => {
1758
+ }, zn = async (e, t, n) => {
1752
1759
  try {
1753
- return await G.resolve(e, t, n);
1760
+ return await U.resolve(e, t, n);
1754
1761
  } catch (e) {
1755
- throw B(e) ? e : L(`frame.fetch: ${e instanceof Error ? `${e.name}: ${e.message}` : String(e)}; not retried, since the request may already have been sent`, "fetch");
1762
+ throw z(e) ? e : L(`frame.fetch: ${e instanceof Error ? `${e.name}: ${e.message}` : String(e)}; not retried, since the request may already have been sent`, "fetch");
1756
1763
  }
1757
- }, In = _n({
1764
+ }, Bn = Sn({
1758
1765
  element: { operations: {
1759
1766
  click: {
1760
- resolve: (e, t = {}) => K.click.resolve(e, t),
1761
- send: Pn("click")
1767
+ resolve: (e, t = {}) => W.click.resolve(e, t),
1768
+ send: Rn("click")
1762
1769
  },
1763
1770
  hover: {
1764
- resolve: (e, t = {}) => K.hover.resolve(e, t),
1765
- send: Pn("hover")
1771
+ resolve: (e, t = {}) => W.hover.resolve(e, t),
1772
+ send: Rn("hover")
1766
1773
  },
1767
- fill: { resolve: (e, t, n = {}) => K.fill.resolve(e, t, n) },
1768
- textContent: { resolve: (e, t = {}) => K.textContent.resolve(e) },
1769
- getAttribute: { resolve: (e, t, n = {}) => K.getAttribute.resolve(e, t) },
1770
- isVisible: { resolve: (e, t = {}) => K.isVisible.resolve(e) },
1771
- count: { resolve: (e, t = {}) => K.count.resolve(e) },
1772
- exists: { resolve: (e, t = {}) => K.exists.resolve(e) },
1773
- videoElement: { resolve: (e, t = {}) => _e(Vt(W(e.elements), "HTMLVideoElement")) }
1774
+ fill: { resolve: (e, t, n = {}) => W.fill.resolve(e, t, n) },
1775
+ textContent: { resolve: (e, t = {}) => W.textContent.resolve(e) },
1776
+ getAttribute: { resolve: (e, t, n = {}) => W.getAttribute.resolve(e, t) },
1777
+ isVisible: { resolve: (e, t = {}) => W.isVisible.resolve(e) },
1778
+ count: { resolve: (e, t = {}) => W.count.resolve(e) },
1779
+ exists: { resolve: (e, t = {}) => W.exists.resolve(e) },
1780
+ videoElement: { resolve: (e, t = {}) => ve(Kt(H(e.elements), "HTMLVideoElement")) }
1774
1781
  } },
1775
1782
  frame: { operations: {
1776
- addStyleTag: { resolve: (e, t) => $t.resolve(e, t) },
1783
+ addStyleTag: { resolve: (e, t) => an.resolve(e, t) },
1777
1784
  fetch: {
1778
- resolve: (e, t, n = {}) => Fn(e, t, n),
1779
- kind: G.kind,
1780
- ensureArgs: G.ensureArgs
1785
+ resolve: (e, t, n = {}) => zn(e, t, n),
1786
+ kind: U.kind,
1787
+ ensureArgs: U.ensureArgs
1781
1788
  },
1782
1789
  evaluate: {
1783
1790
  kind: "frame",
1784
1791
  typed: !1,
1785
1792
  resolve: (e, t, n) => {
1786
- throw It("evaluate", "this realm");
1793
+ throw zt("evaluate", "this realm");
1787
1794
  }
1788
1795
  }
1789
1796
  } }
1790
- }), Ln = (e) => e[e.length - 1], Rn = {
1797
+ }), Vn = (e) => e[e.length - 1], Hn = {
1791
1798
  element: {
1792
1799
  last: {
1793
1800
  to: "element",
@@ -1800,7 +1807,7 @@ var Et = class {
1800
1807
  contentFrame: {
1801
1808
  to: "frame",
1802
1809
  rewrite: (e) => {
1803
- let t = Ln(e);
1810
+ let t = Vn(e);
1804
1811
  if (t?.name !== "locator") throw TypeError("locator.contentFrame: only a locator that ends in locator(selector) can enter its frame; use frameLocator(selector)");
1805
1812
  return [...e.slice(0, -1), {
1806
1813
  ...t,
@@ -1813,7 +1820,7 @@ var Et = class {
1813
1820
  owner: {
1814
1821
  to: "element",
1815
1822
  rewrite: (e) => {
1816
- let t = Ln(e);
1823
+ let t = Vn(e);
1817
1824
  if (t?.name !== "frameLocator") throw TypeError("frameLocator.owner: this frame was not entered through frameLocator(selector)");
1818
1825
  return [...e.slice(0, -1), {
1819
1826
  ...t,
@@ -1830,7 +1837,7 @@ var Et = class {
1830
1837
  }]
1831
1838
  }
1832
1839
  }
1833
- }, zn = (e) => {
1840
+ }, Un = (e) => {
1834
1841
  if (!e || e === "about:blank") return !1;
1835
1842
  let t;
1836
1843
  try {
@@ -1838,46 +1845,46 @@ var Et = class {
1838
1845
  } catch {
1839
1846
  return !1;
1840
1847
  }
1841
- return t.protocol === "chrome-extension:" || t.protocol === "moz-extension:" || t.protocol !== "about:" && A(t.hostname);
1842
- }, J = (e) => {
1843
- if (zn(e)) throw Error("attachFrame: refusing to target the extension's own pages or an FKN platform origin");
1844
- }, Bn = ({ src: e, domains: t, lockdown: n }) => {
1848
+ return t.protocol === "chrome-extension:" || t.protocol === "moz-extension:" || t.protocol !== "about:" && k(t.hostname);
1849
+ }, q = (e) => {
1850
+ if (Un(e)) throw Error("attachFrame: refusing to target the extension's own pages or an FKN platform origin");
1851
+ }, Wn = ({ src: e, domains: t, lockdown: n }) => {
1845
1852
  if (n && !t.length && e && e !== "about:blank") throw Error("attachFrame: lockdown needs domains when the frame already has a src; pass domains or load it via goto");
1846
- }, Vn = {
1853
+ }, Gn = {
1847
1854
  scope: "embed.iframe",
1848
1855
  category: "interaction",
1849
1856
  severity: 0,
1850
1857
  title: "Load another website inside this app",
1851
1858
  description: "Lets the app embed external pages directly inside its own view."
1852
- }, Hn = {
1859
+ }, Kn = {
1853
1860
  scope: "embed.open",
1854
1861
  category: "interaction",
1855
1862
  severity: 0,
1856
1863
  title: "Open a website inside this app",
1857
1864
  description: "Lets the app navigate to another site without leaving its window."
1858
- }, Un = ["load", "commit"], Wn = (e) => {
1865
+ }, qn = ["load", "commit"], Jn = (e) => {
1859
1866
  if ("timeoutMs" in e) throw TypeError("frame.goto: pass timeout, in milliseconds; timeoutMs is not an option");
1860
1867
  let { waitUntil: t, timeout: n } = e;
1861
- if (t !== void 0 && !Un.includes(t)) throw TypeError(`frame.goto: waitUntil must be 'load' or 'commit', not ${JSON.stringify(t)}`);
1868
+ if (t !== void 0 && !qn.includes(t)) throw TypeError(`frame.goto: waitUntil must be 'load' or 'commit', not ${JSON.stringify(t)}`);
1862
1869
  if (n !== void 0 && typeof n != "number") throw TypeError("frame.goto: timeout must be a number of milliseconds");
1863
- wn("frame.goto", n);
1864
- }, Gn = class extends Error {
1870
+ On("frame.goto", n);
1871
+ }, Yn = class extends Error {
1865
1872
  name = "FrameWindowBlockedError";
1866
1873
  constructor() {
1867
1874
  super("attachFrame: the browser did not open the window. Call attachFrame directly in a click or key handler, and allow popups for this page");
1868
1875
  }
1869
- }, Kn = /* @__PURE__ */ new Set([
1876
+ }, Xn = /* @__PURE__ */ new Set([
1870
1877
  "jar-unreachable",
1871
1878
  "bad-url",
1872
1879
  "opaque-opener"
1873
- ]), qn = class extends Error {
1880
+ ]), Zn = class extends Error {
1874
1881
  name = "FrameWindowRefusedError";
1875
1882
  reason;
1876
1883
  constructor(e) {
1877
- let t = Kn.has(e) ? e : "unknown";
1884
+ let t = Xn.has(e) ? e : "unknown";
1878
1885
  super(t === "opaque-opener" ? "attachFrame: this page has an opaque origin, which a window can never answer, so no window was opened" : `attachFrame: the window refused to attach (${t}), and loaded nothing`), this.reason = t;
1879
1886
  }
1880
- }, Jn = ["message", "document"], Yn = (e) => {
1887
+ }, Qn = ["message", "document"], $n = (e) => {
1881
1888
  if (e === "*") return "*";
1882
1889
  let t = () => /* @__PURE__ */ TypeError(`frame.postMessage: targetOrigin must be '*' or an origin, not ${JSON.stringify(e)}`);
1883
1890
  if (typeof e != "string") throw t();
@@ -1889,48 +1896,48 @@ var Et = class {
1889
1896
  }
1890
1897
  if (n === "null") throw t();
1891
1898
  return n;
1892
- }, Xn = (e, t) => {
1899
+ }, er = (e, t) => {
1893
1900
  let n = typeof e == "object" && !!e;
1894
1901
  if (n && t !== void 0) throw TypeError("frame.postMessage: pass transfer inside the options object, not after it");
1895
1902
  let r = n ? e.targetOrigin ?? "*" : e ?? "*", i = n ? e.transfer : t;
1896
1903
  if (i !== void 0 && !Array.isArray(i)) throw TypeError("frame.postMessage: transfer must be an array");
1897
1904
  return {
1898
- targetOrigin: Yn(r),
1905
+ targetOrigin: $n(r),
1899
1906
  transfer: i === void 0 ? [] : [...i]
1900
1907
  };
1901
- }, Zn = [
1908
+ }, tr = [
1902
1909
  "url",
1903
1910
  "path",
1904
1911
  "type"
1905
- ], Qn = ["content", "sourceUrl"], $n = /[\n\r\u2028\u2029]/, er = (e) => {
1912
+ ], nr = ["content", "sourceUrl"], rr = /[\n\r\u2028\u2029]/, ir = (e) => {
1906
1913
  if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError("frame.addScriptTag: options must be an object { content }");
1907
- let t = Object.keys(e), n = t.find((e) => Zn.includes(e));
1914
+ let t = Object.keys(e), n = t.find((e) => tr.includes(e));
1908
1915
  if (n !== void 0) throw TypeError(`frame.addScriptTag: "${n}" is not served; it runs content as a classic inline script`);
1909
- let r = t.find((e) => !Qn.includes(e));
1916
+ let r = t.find((e) => !nr.includes(e));
1910
1917
  if (r !== void 0) throw TypeError(`frame.addScriptTag: unknown option "${r}"`);
1911
1918
  let { content: i, sourceUrl: a } = e;
1912
1919
  if (typeof i != "string") throw TypeError("frame.addScriptTag: content must be a string");
1913
- if (a !== void 0 && (typeof a != "string" || a === "" || $n.test(a))) throw TypeError("frame.addScriptTag: sourceUrl must be a non-empty string with no line break");
1920
+ if (a !== void 0 && (typeof a != "string" || a === "" || rr.test(a))) throw TypeError("frame.addScriptTag: sourceUrl must be a non-empty string with no line break");
1914
1921
  return a === void 0 ? { content: i } : {
1915
1922
  content: i,
1916
1923
  sourceUrl: a
1917
1924
  };
1918
- }, tr = [
1925
+ }, ar = [
1919
1926
  "name",
1920
1927
  "domain",
1921
1928
  "path"
1922
- ], nr = (e) => e instanceof RegExp || Object.prototype.toString.call(e) === "[object RegExp]", rr = (e) => {
1929
+ ], or = (e) => e instanceof RegExp || Object.prototype.toString.call(e) === "[object RegExp]", sr = (e) => {
1923
1930
  if (e === void 0) return {};
1924
1931
  if (Object.prototype.toString.call(e) !== "[object Object]") throw TypeError("frame.clearCookies: options must be an object");
1925
- let t = e, n = Object.keys(t).find((e) => !tr.includes(e));
1932
+ let t = e, n = Object.keys(t).find((e) => !ar.includes(e));
1926
1933
  if (n !== void 0) throw TypeError(`frame.clearCookies: unknown option "${n}"`);
1927
- let r = tr.flatMap((e) => {
1934
+ let r = ar.flatMap((e) => {
1928
1935
  let n = t[e];
1929
1936
  return n === void 0 ? [] : [{
1930
1937
  key: e,
1931
1938
  value: n
1932
1939
  }];
1933
- }), i = r.find(({ value: e }) => nr(e));
1940
+ }), i = r.find(({ value: e }) => or(e));
1934
1941
  if (i !== void 0) throw TypeError(`frame.clearCookies: ${i.key} is a RegExp, and clearCookies takes strings for name, domain and path for now`);
1935
1942
  let a = r.find(({ value: e }) => typeof e != "string");
1936
1943
  if (a !== void 0) throw TypeError(`frame.clearCookies: ${a.key} must be a string`);
@@ -1939,15 +1946,18 @@ var Et = class {
1939
1946
  let s = {};
1940
1947
  for (let { key: e, value: t } of r) s[e] = { equals: t };
1941
1948
  return s;
1942
- }, ir = (e) => {
1949
+ }, cr = (e) => {
1943
1950
  typeof globalThis.reportError == "function" ? globalThis.reportError(e) : console.error(e);
1944
- }, ar = (e) => {
1945
- let { owner: t, ...n } = On({
1951
+ }, lr = (e) => {
1952
+ let { owner: t, ...n } = Mn({
1946
1953
  executor: e.executor,
1947
- modules: In,
1948
- rewrites: Rn,
1949
- gate: e.gate
1950
- }), r = async (t, n = {}) => (J(t), Wn(n), e.goto(t, n)), i = () => e.url(), a = async (t) => {
1954
+ modules: Bn,
1955
+ rewrites: Hn,
1956
+ gate: async (t, n) => {
1957
+ A(t.operation, K(t.args)?.reason), await e.gate?.(t, n);
1958
+ }
1959
+ }), r = async (t, n = {}) => (q(t), Jn(n), e.goto(t, n)), i = () => e.url(), a = async (t) => {
1960
+ for (let e of t) A("frame.requestPermissions", e?.reason);
1951
1961
  let n = e.requestPermissions;
1952
1962
  if (!n) throw Error("frame.requestPermissions: this backend cannot ask for permission categories");
1953
1963
  return n(t);
@@ -1958,18 +1968,18 @@ var Et = class {
1958
1968
  if (typeof i != "string") throw TypeError("frame.evaluate: pass a function or a source string");
1959
1969
  return r(i, structuredClone(n));
1960
1970
  }, s = async (t) => {
1961
- let { content: n, ...r } = er(t), i = e.addScriptTag;
1971
+ let { content: n, ...r } = ir(t), i = e.addScriptTag;
1962
1972
  if (!i) throw Error("frame.addScriptTag: this backend cannot run scripts in the attached frame");
1963
1973
  await i(n, r);
1964
1974
  }, c = async (t) => {
1965
- let n = rr(t), r = e.clearCookies;
1975
+ let n = sr(t), r = e.clearCookies;
1966
1976
  if (!r) throw Error("frame.clearCookies: this backend cannot clear cookies");
1967
1977
  await r(n);
1968
1978
  }, l = ((t, n, r) => {
1969
1979
  try {
1970
1980
  let i = e.postMessage;
1971
1981
  if (!i) throw Error("frame.postMessage: this backend cannot message the attached frame");
1972
- let a = Xn(n, r);
1982
+ let a = er(n, r);
1973
1983
  return i(t, a.targetOrigin, a.transfer);
1974
1984
  } catch (e) {
1975
1985
  return Promise.reject(e);
@@ -1978,7 +1988,7 @@ var Et = class {
1978
1988
  message: /* @__PURE__ */ new Set(),
1979
1989
  document: /* @__PURE__ */ new Set()
1980
1990
  }, d = null, f = (e, t) => {
1981
- if (!Jn.includes(e)) throw TypeError(`frame.${t}: the event type must be ${Jn.map((e) => `'${e}'`).join(" or ")}, not ${JSON.stringify(e)}`);
1991
+ if (!Qn.includes(e)) throw TypeError(`frame.${t}: the event type must be ${Qn.map((e) => `'${e}'`).join(" or ")}, not ${JSON.stringify(e)}`);
1982
1992
  return u[e];
1983
1993
  }, p = (e) => {
1984
1994
  let t = e.type === "message" ? Object.freeze({
@@ -1994,7 +2004,7 @@ var Et = class {
1994
2004
  for (let n of [...u[e.type]]) try {
1995
2005
  n(t);
1996
2006
  } catch (e) {
1997
- ir(e);
2007
+ cr(e);
1998
2008
  }
1999
2009
  }, m = (e, t) => {
2000
2010
  if (f(e, "off").delete(t), d !== null && !u.message.size && !u.document.size) {
@@ -2027,7 +2037,7 @@ var Et = class {
2027
2037
  off: m
2028
2038
  };
2029
2039
  return _;
2030
- }, or = [
2040
+ }, ur = [
2031
2041
  h,
2032
2042
  t,
2033
2043
  g,
@@ -2041,43 +2051,43 @@ var Et = class {
2041
2051
  l,
2042
2052
  f,
2043
2053
  u,
2044
- Vn,
2045
- Hn,
2054
+ Gn,
2055
+ Kn,
2046
2056
  m,
2047
2057
  r,
2048
- tt,
2049
- nt,
2050
- rt,
2051
- gt,
2052
- vt
2053
- ], sr = Nn.map((e) => e.id), cr = {
2058
+ it,
2059
+ at,
2060
+ ot,
2061
+ yt,
2062
+ xt
2063
+ ], dr = Ln.map((e) => e.id), fr = {
2054
2064
  interaction: "act.click",
2055
2065
  storage: "read.text",
2056
2066
  network: "network.fetchCredentialed",
2057
2067
  evaluation: "media.appearU"
2058
- }, lr = (e) => e === 0 ? "auto" : e === 4 ? "critical" : "bundled", ur = or, Y = /* @__PURE__ */ new Map(), dr = {};
2068
+ }, pr = (e) => e === 0 ? "auto" : e === 4 ? "critical" : "bundled", mr = ur, J = /* @__PURE__ */ new Map(), hr = {};
2059
2069
  (() => {
2060
- Y = new Map(ur.map((e) => [e.scope, e])), dr = Object.fromEntries(Y), ur.filter((e) => e.severity === 4).map((e) => e.scope);
2061
- let e = (e) => ur.filter((t) => t.category === e && lr(t.severity) === "bundled");
2062
- Object.fromEntries(sr.map((t) => [t, Math.max(0, ...e(t).map((e) => e.severity))])), Object.fromEntries(sr.map((t) => [t, e(t).some((e) => e.unsafe === !0)]));
2070
+ J = new Map(mr.map((e) => [e.scope, e])), hr = Object.fromEntries(J), mr.filter((e) => e.severity === 4).map((e) => e.scope);
2071
+ let e = (e) => mr.filter((t) => t.category === e && pr(t.severity) === "bundled");
2072
+ Object.fromEntries(dr.map((t) => [t, Math.max(0, ...e(t).map((e) => e.severity))])), Object.fromEntries(dr.map((t) => [t, e(t).some((e) => e.unsafe === !0)]));
2063
2073
  })();
2064
- var fr = (e) => Y.get(e)?.category, pr = (e) => {
2065
- let t = Y.get(e);
2066
- return t && lr(t.severity);
2067
- }, mr = (e) => {
2068
- let t = Y.get(e);
2069
- if (t) return lr(t.severity) === "critical" ? t.scope : t.category;
2070
- }, hr = (e) => cr[e], gr = ({ category: e, key: t }) => {
2071
- let n = t ?? (e && hr(e));
2072
- return n !== void 0 && fr(n) !== void 0 ? n : void 0;
2073
- }, _r = (e, t) => {
2074
- for (let { category: n, key: r } of t) if (gr({
2074
+ var gr = (e) => J.get(e)?.category, _r = (e) => {
2075
+ let t = J.get(e);
2076
+ return t && pr(t.severity);
2077
+ }, vr = (e) => {
2078
+ let t = J.get(e);
2079
+ if (t) return pr(t.severity) === "critical" ? t.scope : t.category;
2080
+ }, yr = (e) => fr[e], br = ({ category: e, key: t }) => {
2081
+ let n = t ?? (e && yr(e));
2082
+ return n !== void 0 && gr(n) !== void 0 ? n : void 0;
2083
+ }, xr = (e, t) => {
2084
+ for (let { category: n, key: r } of t) if (br({
2075
2085
  category: n,
2076
2086
  key: r
2077
2087
  }) === void 0) throw TypeError(r === void 0 ? n === void 0 ? `${e}: name a category or a permission key` : `${e}: unknown permission category "${n}"` : `${e}: unknown permission key "${r}"`);
2078
- }, vr = (e, t = {}) => {
2088
+ }, Sr = (e, t = {}) => {
2079
2089
  let n = [], r = e.map((e) => {
2080
- let r = gr(e), i = [];
2090
+ let r = br(e), i = [];
2081
2091
  if (r !== void 0) for (let a of e.hosts) i.push(n.length), n.push({
2082
2092
  ...t,
2083
2093
  key: r,
@@ -2087,8 +2097,8 @@ var fr = (e) => Y.get(e)?.category, pr = (e) => {
2087
2097
  reason: e.reason
2088
2098
  });
2089
2099
  return {
2090
- key: r !== void 0 && pr(r) === "critical" ? r : void 0,
2091
- category: r === void 0 ? e.category ?? "interaction" : dr[r].category,
2100
+ key: r !== void 0 && _r(r) === "critical" ? r : void 0,
2101
+ category: r === void 0 ? e.category ?? "interaction" : hr[r].category,
2092
2102
  hosts: e.hosts,
2093
2103
  indexes: i
2094
2104
  };
@@ -2102,31 +2112,31 @@ var fr = (e) => Y.get(e)?.category, pr = (e) => {
2102
2112
  allow: i.length > 0 && i.every((t) => e[t]?.allow === !0)
2103
2113
  }))
2104
2114
  };
2105
- }, yr = (e) => typeof e == "object" && !!e, br = typeof chrome < "u" && !!chrome.runtime?.id, xr = (e) => yr(e) && e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY === !0 && typeof e.frameId == "string" && typeof e.document == "string", Sr = /* @__PURE__ */ new WeakMap(), Cr = /* @__PURE__ */ new WeakMap(), wr = /* @__PURE__ */ new WeakMap(), Tr = /* @__PURE__ */ new Set();
2106
- typeof window < "u" && br && window.addEventListener("message", (e) => {
2107
- if (!xr(e.data)) return;
2115
+ }, Cr = (e) => typeof e == "object" && !!e, wr = typeof chrome < "u" && !!chrome.runtime?.id, Tr = (e) => Cr(e) && e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY === !0 && typeof e.frameId == "string" && typeof e.document == "string", Er = /* @__PURE__ */ new WeakMap(), Dr = /* @__PURE__ */ new WeakMap(), Or = /* @__PURE__ */ new WeakMap(), kr = /* @__PURE__ */ new Set();
2116
+ typeof window < "u" && wr && window.addEventListener("message", (e) => {
2117
+ if (!Tr(e.data)) return;
2108
2118
  e.stopImmediatePropagation();
2109
2119
  let t = e.source;
2110
2120
  if (!t || typeof t != "object") return;
2111
- let n = t, r = Sr.get(n), i = e.data.frameId, a = e.data.document;
2112
- if (Sr.set(n, i), Cr.set(n, a), r) for (let e of Tr) e(r);
2113
- let o = wr.get(n);
2121
+ let n = t, r = Er.get(n), i = e.data.frameId, a = e.data.document;
2122
+ if (Er.set(n, i), Dr.set(n, a), r) for (let e of kr) e(r);
2123
+ let o = Or.get(n);
2114
2124
  if (o) {
2115
2125
  for (let e of [...o]) (e.notDocument === void 0 || e.notDocument !== a) && (o.delete(e), e.resolve(i));
2116
- o.size || wr.delete(n);
2126
+ o.size || Or.delete(n);
2117
2127
  }
2118
2128
  }, { capture: !0 });
2119
2129
  //#endregion
2120
2130
  //#region ../web-extension/lib/lib/evaluate-deadline.js
2121
- var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or = () => new R(Dr), kr = (e) => z(e) && e.message === Dr ? Or() : e, Ar = [
2131
+ var Ar = 3e4, jr = `frame.evaluate: the code did not settle within ${Ar}ms`, Mr = () => new R(jr), Nr = (e) => Ut(e) && e.message === jr ? Mr() : e, Pr = [
2122
2132
  /^frame load timed out after \d+ms for /,
2123
2133
  /^frame goto: documentstart timed out$/,
2124
2134
  /^navigation to .+ did not commit a document within \d+ms$/s
2125
- ], jr = (e) => {
2135
+ ], Fr = (e) => {
2126
2136
  if (e instanceof R) return e;
2127
2137
  let t = typeof e?.message == "string" ? e.message : "";
2128
- return Ar.some((e) => e.test(t)) ? new R(t) : e;
2129
- }, Mr = (e) => {
2138
+ return Pr.some((e) => e.test(t)) ? new R(t) : e;
2139
+ }, Ir = (e) => {
2130
2140
  let t = e;
2131
2141
  if (t.window === void 0) return "iframe";
2132
2142
  if (t.iframe !== void 0) throw TypeError("attachFrame: pass either iframe or window, not both");
@@ -2134,11 +2144,11 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2134
2144
  if (t.blank !== void 0) throw TypeError("attachFrame: blank does not apply to a window");
2135
2145
  if (typeof t.window != "object" || t.window === null) throw TypeError("attachFrame: window must be an object");
2136
2146
  return "window";
2137
- }, Nr = (e, t, n) => {
2147
+ }, Lr = (e, t, n) => {
2138
2148
  if (e === void 0) return t;
2139
2149
  if (typeof e != "number" || !Number.isFinite(e) || e <= 0) throw TypeError(`attachFrame: window.${n} must be a positive number of CSS pixels`);
2140
2150
  return Math.round(e);
2141
- }, Pr = ({ url: e, width: t, height: n }) => {
2151
+ }, Rr = ({ url: e, width: t, height: n }) => {
2142
2152
  let r = (() => {
2143
2153
  if (e === void 0 || e === "" || e === "about:blank") return "";
2144
2154
  if (typeof e != "string") throw TypeError("attachFrame: window.url must be a string");
@@ -2152,12 +2162,12 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2152
2162
  if (t.protocol !== "http:" && t.protocol !== "https:") throw TypeError("attachFrame: window.url must be an http or https address");
2153
2163
  return t.href;
2154
2164
  })();
2155
- return r && J(r), {
2165
+ return r && q(r), {
2156
2166
  url: r,
2157
- width: Nr(t, 500, "width"),
2158
- height: Nr(n, 700, "height")
2167
+ width: Lr(t, 500, "width"),
2168
+ height: Lr(n, 700, "height")
2159
2169
  };
2160
- }, Fr = "attachFrame: storageState seeds a fresh jar, so it needs cookies: 'ephemeral'", Ir = 1e11, Lr = [
2170
+ }, zr = "attachFrame: storageState seeds a fresh jar, so it needs cookies: 'ephemeral'", Br = 1e11, Vr = [
2161
2171
  "name",
2162
2172
  "value",
2163
2173
  "domain",
@@ -2166,11 +2176,11 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2166
2176
  "httpOnly",
2167
2177
  "secure",
2168
2178
  "sameSite"
2169
- ], Rr = [
2179
+ ], Hr = [
2170
2180
  "Strict",
2171
2181
  "Lax",
2172
2182
  "None"
2173
- ], zr = /[;\x00-\x1f\x7f]/, X = (e, t) => /* @__PURE__ */ TypeError(`attachFrame: storageState${e} ${t}`), Z = (e) => Object.prototype.toString.call(e) === "[object Object]", Br = (e) => {
2183
+ ], Y = /[;\x00-\x1f\x7f]/, X = (e, t) => /* @__PURE__ */ TypeError(`attachFrame: storageState${e} ${t}`), Z = (e) => Object.prototype.toString.call(e) === "[object Object]", Ur = (e) => {
2174
2184
  let t = e.startsWith(".") ? e.slice(1) : e;
2175
2185
  if (t === "") return null;
2176
2186
  try {
@@ -2178,19 +2188,19 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2178
2188
  } catch {
2179
2189
  return null;
2180
2190
  }
2181
- }, Vr = (e, t) => {
2191
+ }, Wr = (e, t) => {
2182
2192
  if (!Z(e)) throw X(t, "must be an object");
2183
- let n = Object.keys(e).find((e) => !Lr.includes(e));
2193
+ let n = Object.keys(e).find((e) => !Vr.includes(e));
2184
2194
  if (n !== void 0) throw X(`${t}.${n}`, "is not a cookie field");
2185
2195
  let { name: r, value: i, domain: a, path: o, expires: s, httpOnly: c, secure: l, sameSite: u } = e;
2186
- if (typeof r != "string" || r === "" || r.includes("=") || zr.test(r)) throw X(`${t}.name`, "must be a non-empty string with no \"=\", \";\" or control character");
2187
- if (typeof i != "string" || zr.test(i)) throw X(`${t}.value`, "must be a string with no \";\" or control character");
2188
- if (typeof a != "string" || Br(a) === null) throw X(`${t}.domain`, "must be a host: \".youtube.com\" for a cookie its subdomains also receive, \"www.youtube.com\" for a host-only one");
2189
- if (o !== void 0 && (typeof o != "string" || !o.startsWith("/") || zr.test(o))) throw X(`${t}.path`, "must be a string starting with \"/\"");
2196
+ if (typeof r != "string" || r === "" || r.includes("=") || Y.test(r)) throw X(`${t}.name`, "must be a non-empty string with no \"=\", \";\" or control character");
2197
+ if (typeof i != "string" || Y.test(i)) throw X(`${t}.value`, "must be a string with no \";\" or control character");
2198
+ if (typeof a != "string" || Ur(a) === null) throw X(`${t}.domain`, "must be a host: \".youtube.com\" for a cookie its subdomains also receive, \"www.youtube.com\" for a host-only one");
2199
+ if (o !== void 0 && (typeof o != "string" || !o.startsWith("/") || Y.test(o))) throw X(`${t}.path`, "must be a string starting with \"/\"");
2190
2200
  if (s !== void 0 && (typeof s != "number" || !Number.isFinite(s) || s <= 0 && s !== -1)) throw X(`${t}.expires`, "must be -1 for a session cookie, or milliseconds since the epoch");
2191
2201
  if (c !== void 0 && typeof c != "boolean") throw X(`${t}.httpOnly`, "must be a boolean");
2192
2202
  if (l !== void 0 && typeof l != "boolean") throw X(`${t}.secure`, "must be a boolean");
2193
- if (u !== void 0 && !Rr.includes(u)) throw X(`${t}.sameSite`, `must be 'Strict', 'Lax' or 'None', not ${JSON.stringify(u)}`);
2203
+ if (u !== void 0 && !Hr.includes(u)) throw X(`${t}.sameSite`, `must be 'Strict', 'Lax' or 'None', not ${JSON.stringify(u)}`);
2194
2204
  let d = r.toLowerCase();
2195
2205
  if (u === "None" && l !== !0) throw X(t, "is SameSite=None, which needs secure: true");
2196
2206
  if (d.startsWith("__secure-") && l !== !0) throw X(t, "is a __Secure- cookie, which needs secure: true");
@@ -2201,7 +2211,7 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2201
2211
  domain: a
2202
2212
  };
2203
2213
  return o !== void 0 && (f.path = o), s !== void 0 && (f.expires = s), c !== void 0 && (f.httpOnly = c), l !== void 0 && (f.secure = l), u !== void 0 && (f.sameSite = u), f;
2204
- }, Hr = (e, t) => {
2214
+ }, Gr = (e, t) => {
2205
2215
  if (!Z(e)) throw X(t, "must be an object { origin, localStorage }");
2206
2216
  let n = Object.keys(e).find((e) => e !== "origin" && e !== "localStorage");
2207
2217
  if (n !== void 0) throw X(`${t}.${n}`, "is not an origin field");
@@ -2225,31 +2235,32 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2225
2235
  };
2226
2236
  })
2227
2237
  };
2228
- }, Ur = (e) => {
2238
+ }, Kr = (e) => {
2229
2239
  if (!Z(e)) throw X("", "must be an object { cookies?, origins? }");
2230
2240
  let t = Object.keys(e).find((e) => e !== "cookies" && e !== "origins");
2231
2241
  if (t !== void 0) throw X(`.${t}`, "is not a storageState key; it takes cookies and origins");
2232
2242
  let { cookies: n = [], origins: r = [] } = e;
2233
2243
  if (!Array.isArray(n)) throw X(".cookies", "must be an array");
2234
2244
  if (!Array.isArray(r)) throw X(".origins", "must be an array");
2235
- let i = n.map((e, t) => Vr(e, `.cookies[${t}]`)), a = r.map((e, t) => Hr(e, `.origins[${t}]`));
2245
+ let i = n.map((e, t) => Wr(e, `.cookies[${t}]`)), a = r.map((e, t) => Gr(e, `.origins[${t}]`));
2236
2246
  return i.forEach(({ expires: e }, t) => {
2237
- if (e !== void 0 && e > 0 && e < Ir) throw X(`.cookies[${t}].expires`, `is milliseconds since the epoch, and ${e} reads as a date before 1974; a Playwright storageState gives seconds, so multiply it by 1000`);
2247
+ if (e !== void 0 && e > 0 && e < Br) throw X(`.cookies[${t}].expires`, `is milliseconds since the epoch, and ${e} reads as a date before 1974; a Playwright storageState gives seconds, so multiply it by 1000`);
2238
2248
  }), {
2239
2249
  cookies: i,
2240
2250
  origins: a
2241
2251
  };
2242
- }, Wr = [
2252
+ }, qr = [
2243
2253
  "persistent",
2244
2254
  "ephemeral",
2245
2255
  "native"
2246
- ], Gr = "attachFrame: syncCookies was replaced by cookies. true is cookies: 'persistent', or 'native' for the person's own browser cookies on the extension; false is cookies: 'ephemeral'", Kr = (e) => {
2247
- if ("syncCookies" in e) throw TypeError(Gr);
2256
+ ], Jr = "attachFrame: syncCookies was replaced by cookies. true is cookies: 'persistent', or 'native' for the person's own browser cookies on the extension; false is cookies: 'ephemeral'", Yr = (e) => {
2257
+ if ("syncCookies" in e) throw TypeError(Jr);
2248
2258
  let { cookies: t = "persistent" } = e;
2249
- if (!Wr.includes(t)) throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);
2250
- if (e.storageState !== void 0 && t !== "ephemeral") throw TypeError(Fr);
2251
- let n = e.storageState === void 0 ? void 0 : Ur(e.storageState), r = Mr(e);
2259
+ if (!qr.includes(t)) throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);
2260
+ if (e.storageState !== void 0 && t !== "ephemeral") throw TypeError(zr);
2261
+ let n = e.storageState === void 0 ? void 0 : Kr(e.storageState), r = Ir(e);
2252
2262
  if (r === "iframe" && e.lockdown && t !== "native") throw TypeError("attachFrame: lockdown runs on the extension, which serves only cookies: 'native'");
2263
+ if (Array.isArray(e.permissions)) for (let t of e.permissions) A("attachFrame", t?.reason);
2253
2264
  return n === void 0 ? {
2254
2265
  kind: r,
2255
2266
  cookies: t
@@ -2258,13 +2269,13 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2258
2269
  cookies: t,
2259
2270
  storageState: n
2260
2271
  };
2261
- }, qr = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", Jr = !1, Yr = () => {
2262
- Jr || (Jr = !0, console.warn("[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this."));
2263
- }, Xr = "frame: this frame no longer holds the document the app attached it to", Zr = "frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin", Qr = () => {
2264
- let e = E();
2272
+ }, Xr = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", Zr = !1, Qr = () => {
2273
+ Zr || (Zr = !0, console.warn("[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this."));
2274
+ }, $r = "frame: this frame no longer holds the document the app attached it to", ei = "frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin", ti = () => {
2275
+ let e = T();
2265
2276
  if (e.status === "ok" && e.abi >= 1) return;
2266
2277
  let t = e.status === "absent" ? 0 : e.abi;
2267
- throw new T("lockdown", t, `attachFrame: the installed FKN WebExtension (ABI ${t}) may predate lockdown, and one that does attaches the frame with its CSP removed rather than locked down. Updating the extension fixes this.`);
2278
+ throw new w("lockdown", t, `attachFrame: the installed FKN WebExtension (ABI ${t}) may predate lockdown, and one that does attaches the frame with its CSP removed rather than locked down. Updating the extension fixes this.`);
2268
2279
  }, Q = (e) => {
2269
2280
  try {
2270
2281
  return new URL(e, location.href).hostname;
@@ -2272,46 +2283,46 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2272
2283
  return "";
2273
2284
  }
2274
2285
  }, $ = () => {
2275
- let e = E();
2286
+ let e = T();
2276
2287
  return e.status === "absent" ? 0 : e.abi;
2277
- }, $r = "attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame", ei = "frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame", ti = "frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar", ni = ({ executeLocator: e, highlightLocator: t, ensureLocatorPermission: n, requestCategories: r, evaluateFrame: i, goto: a }, { hosts: o, url: s, page: c, unreachable: l, documents: u, navigated: d }) => {
2278
- let f = new Set(p(o, { ipv6: !0 })), m = (e) => f.has(p([ht(e)], { ipv6: !0 })[0] ?? "");
2279
- return ar({
2288
+ }, ni = "attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame", ri = "frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame", ii = "frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar", ai = ({ executeLocator: e, highlightLocator: t, ensureLocatorPermission: n, requestCategories: r, evaluateFrame: i, goto: a }, { hosts: o, url: s, page: c, unreachable: l, documents: u, navigated: d }) => {
2289
+ let f = new Set(p(o, { ipv6: !0 })), m = (e) => f.has(p([vt(e)], { ipv6: !0 })[0] ?? "");
2290
+ return lr({
2280
2291
  backend: "extension",
2281
2292
  executor: {
2282
2293
  execute: e,
2283
2294
  highlight: t
2284
2295
  },
2285
2296
  gate: (e) => n(e.parts, e.operation, e.args),
2286
- requestPermissions: async (e) => (_r("frame.requestPermissions", e), await An(), r(e)),
2297
+ requestPermissions: async (e) => (xr("frame.requestPermissions", e), await Pn(), r(e)),
2287
2298
  evaluate: async (e, t) => {
2288
- if (!Re(E(), "evaluate")) {
2289
- let e = E();
2290
- throw new T("evaluate", e.status === "ok" ? e.abi : 0);
2299
+ if (!ze(T(), "evaluate")) {
2300
+ let e = T();
2301
+ throw new w("evaluate", e.status === "ok" ? e.abi : 0);
2291
2302
  }
2292
2303
  return i({
2293
2304
  source: e,
2294
2305
  arg: t
2295
2306
  }).catch((e) => {
2296
- throw kr(e);
2307
+ throw Nr(e);
2297
2308
  });
2298
2309
  },
2299
2310
  addScriptTag: async () => {
2300
- throw new T("addScriptTag", $(), ei);
2311
+ throw new w("addScriptTag", $(), ri);
2301
2312
  },
2302
2313
  clearCookies: async () => {
2303
- throw new T("clearCookies", $(), ti);
2314
+ throw new w("clearCookies", $(), ii);
2304
2315
  },
2305
2316
  postMessage: (e, t, n) => {
2306
- if (t === "*") throw I(Zr, "postMessage", "extension");
2307
- if (!m(t)) throw L(Xr, "postMessage");
2317
+ if (t === "*") throw I(ei, "postMessage", "extension");
2318
+ if (!m(t)) throw L($r, "postMessage");
2308
2319
  let r = l();
2309
2320
  if (r) throw r;
2310
2321
  return c().postMessage(e, t, n), Promise.resolve();
2311
2322
  },
2312
2323
  listen: (e) => {
2313
2324
  let t = (t) => {
2314
- t.source !== null && t.source === c() && !xr(t.data) && m(t.origin) && e({
2325
+ t.source !== null && t.source === c() && !Tr(t.data) && m(t.origin) && e({
2315
2326
  type: "message",
2316
2327
  data: t.data,
2317
2328
  origin: t.origin,
@@ -2336,21 +2347,21 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2336
2347
  ...t === void 0 ? {} : { waitUntil: t === "commit" ? "documentstart" : t },
2337
2348
  ...n === void 0 ? {} : { timeoutMs: n }
2338
2349
  }).catch((e) => {
2339
- throw jr(e);
2350
+ throw Fr(e);
2340
2351
  });
2341
2352
  },
2342
2353
  url: s
2343
2354
  });
2344
- }, ri = async ({ iframe: e, domains: t = [], lockdown: n = !1, permissions: r, blank: i }) => {
2345
- if (i !== void 0) throw new T("blank", $(), $r);
2355
+ }, oi = async ({ iframe: e, domains: t = [], lockdown: n = !1, permissions: r, blank: i }) => {
2356
+ if (i !== void 0) throw new w("blank", $(), ni);
2346
2357
  let a = crypto.randomUUID();
2347
- if (J(e.src), Bn({
2358
+ if (q(e.src), Wn({
2348
2359
  src: e.src,
2349
2360
  domains: t,
2350
2361
  lockdown: n
2351
- }), j("attachFrame", t), await D(), n && Qr(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
2352
- e.dispatchEvent(new CustomEvent(qr, { detail: a }));
2353
- let o = ni(await O.attachFrame({
2362
+ }), j("attachFrame", t), await E(), n && ti(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
2363
+ e.dispatchEvent(new CustomEvent(Xr, { detail: a }));
2364
+ let o = ai(await D.attachFrame({
2354
2365
  marker: a,
2355
2366
  domains: t,
2356
2367
  syncCookies: !0,
@@ -2362,17 +2373,17 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2362
2373
  unreachable: () => e.contentWindow === null ? L("frame: navigate the frame before postMessage", "postMessage") : void 0,
2363
2374
  documents: (t) => (e.addEventListener("load", t), () => e.removeEventListener("load", t))
2364
2375
  });
2365
- return r?.length && (kn() ? await o.requestPermissions(r) : Yr()), o;
2366
- }, ii = "attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page", ai = "frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it", oi = "extension.attachFrame: the attached window closed; attach a fresh window", si = (e) => `attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`, ci = async (e) => {
2367
- let { domains: t = [], permissions: n } = e, { url: r, width: i, height: a } = Pr(e.window);
2376
+ return r?.length && (Nn() ? await o.requestPermissions(r) : Qr()), o;
2377
+ }, si = "attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page", ci = "frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it", li = "extension.attachFrame: the attached window closed; attach a fresh window", ui = (e) => `attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`, di = async (e) => {
2378
+ let { domains: t = [], permissions: n } = e, { url: r, width: i, height: a } = Rr(e.window);
2368
2379
  j("attachFrame", t);
2369
- let o = E();
2370
- if (!Re(o, "attachWindow")) throw o.status === "absent" ? new T("attachWindow", 0, ii) : new T("attachWindow", o.abi);
2380
+ let o = T();
2381
+ if (!ze(o, "attachWindow")) throw o.status === "absent" ? new w("attachWindow", 0, si) : new w("attachWindow", o.abi);
2371
2382
  let s = window.open(r || "about:blank", "_blank", `popup,width=${i},height=${a}`);
2372
- if (!s) throw new Gn();
2383
+ if (!s) throw new Yn();
2373
2384
  let c;
2374
2385
  try {
2375
- c = await O.attachWindow({
2386
+ c = await D.attachWindow({
2376
2387
  url: r,
2377
2388
  domains: t
2378
2389
  });
@@ -2386,11 +2397,11 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2386
2397
  u = !0;
2387
2398
  }, () => {
2388
2399
  u = !0;
2389
- }), f = r, p = ni(c, {
2400
+ }), f = r, p = ai(c, {
2390
2401
  hosts: r ? [...t, Q(r)] : t,
2391
2402
  url: () => f,
2392
2403
  page: () => s,
2393
- unreachable: () => u ? I(oi, "postMessage", "extension") : s.closed ? L(ai, "postMessage") : void 0,
2404
+ unreachable: () => u ? I(li, "postMessage", "extension") : s.closed ? L(ci, "postMessage") : void 0,
2394
2405
  documents: (e) => {
2395
2406
  let t = !0;
2396
2407
  return (async () => {
@@ -2423,30 +2434,30 @@ var Er = 3e4, Dr = `frame.evaluate: the code did not settle within ${Er}ms`, Or
2423
2434
  throw await h(), e;
2424
2435
  }
2425
2436
  return g;
2426
- }, li = (async (e) => {
2427
- let { kind: t, cookies: n } = Kr(e);
2428
- if (n !== "native") throw new T("cookies", $(), si(n));
2429
- return t === "window" ? ci(e) : ri(e);
2430
- }), ui = "permissions.request: pass hosts, the sites the grant applies to", di = { request: async (e) => {
2437
+ }, fi = (async (e) => {
2438
+ let { kind: t, cookies: n } = Yr(e);
2439
+ if (n !== "native") throw new w("cookies", $(), ui(n));
2440
+ return t === "window" ? di(e) : oi(e);
2441
+ }), pi = "permissions.request: pass hosts, the sites the grant applies to", mi = { request: async (e) => {
2431
2442
  let t = e.map((e) => {
2432
2443
  let { category: t, key: n, scope: r, reason: i, hosts: a } = e;
2433
- if (!("hosts" in e) && !("category" in e)) return { legacy: {
2444
+ if (A("permissions.request", i), !("hosts" in e) && !("category" in e)) return { legacy: {
2434
2445
  key: n,
2435
2446
  scope: r ?? "",
2436
2447
  reason: i
2437
2448
  } };
2438
2449
  let o = p(a ?? [], { ipv6: !0 });
2439
- if (!o.length) throw TypeError(ui);
2440
- return mt("permissions.request", o), { ask: {
2450
+ if (!o.length) throw TypeError(pi);
2451
+ return _t("permissions.request", o), { ask: {
2441
2452
  category: t,
2442
2453
  key: n,
2443
2454
  reason: i,
2444
2455
  hosts: o
2445
2456
  } };
2446
2457
  }), n = t.flatMap((e) => "ask" in e ? [e.ask] : []);
2447
- _r("permissions.request", n), n.length && await An();
2448
- let { items: r, answer: i } = vr(n), a = t.flatMap((e) => "legacy" in e ? [e.legacy] : []), o = [...r, ...a], s = o.length ? await O.requestPermissions(o) : [], c = i(s.slice(0, r.length)), l = s.slice(r.length), u = 0, d = 0;
2458
+ xr("permissions.request", n), n.length && await Pn();
2459
+ let { items: r, answer: i } = Sr(n), a = t.flatMap((e) => "legacy" in e ? [e.legacy] : []), o = [...r, ...a], s = o.length ? await D.requestPermissions(o) : [], c = i(s.slice(0, r.length)), l = s.slice(r.length), u = 0, d = 0;
2449
2460
  return t.map((e) => "ask" in e ? c[u++] : l[d++]);
2450
- } }, fi = "PermissionDeniedError", pi = (e) => e instanceof Error ? e.name === fi : yr(e) && e.name === "PermissionDeniedError";
2461
+ } }, hi = "PermissionDeniedError", gi = (e) => e instanceof Error ? e.name === hi : Cr(e) && e.name === "PermissionDeniedError";
2451
2462
  //#endregion
2452
- export { Be as $, It as A, _t as B, zn as C, Rt as D, Mt as E, zt as F, rt as G, st as H, Pt as I, at as J, tt as K, vt as L, I as M, B as N, L as O, jt as P, qe as Q, bt as R, Bn as S, R as T, lt as U, gt as V, nt as W, Xe as X, k as Y, Je as Z, qn as _, li as a, T as at, Hn as b, jr as c, Le as ct, yr as d, _e as dt, Ve as et, _r as f, ve as ft, Gn as g, pr as h, qr as i, Oe as it, z as j, Nt as k, Er as l, De as lt, mr as m, S as mt, pi as n, Ue as nt, Kr as o, w as ot, fr as p, be as pt, ot as q, di as r, D as rt, Pr as s, ke as st, fi as t, E as tt, Or as u, ye as ut, Vn as v, Nn as w, J as x, ar as y, yt as z };
2463
+ export { Ze as $, It as A, St as B, Un as C, Ft as D, R as E, Pt as F, at as G, yt as H, Ht as I, lt as J, ot as K, Lt as L, Ut as M, I as N, Vt as O, z as P, O as Q, xt as R, Wn as S, K as T, ut as U, bt as V, ft as W, nt as X, ct as Y, A as Z, Zn as _, S as _t, fi as a, We as at, Kn as b, Fr as c, w as ct, Cr as d, Re as dt, Ye as et, xr as f, Oe as ft, Yn as g, xe as gt, _r as h, ye as ht, Xr as i, T as it, zt as j, L as k, Ar as l, C as lt, vr as m, ve as mt, gi as n, Ve as nt, Yr as o, E as ot, gr as p, be as pt, it as q, mi as r, He as rt, Rr as s, ke as st, hi as t, Je as tt, Mr as u, Ae as ut, Gn as v, Ln as w, q as x, lr as y, Ct as z };