@limrun/ui 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,39 @@
1
- import { jsx as k, jsxs as ae, Fragment as Fr } from "react/jsx-runtime";
2
- import { memo as rr, useState as V, useEffect as pe, useMemo as Ke, useCallback as In, lazy as Yn, forwardRef as Kn, useRef as O, useImperativeHandle as kn, Suspense as Pn } from "react";
3
- import { createPortal as Un } from "react-dom";
4
- import './index.css';function Wr(r) {
1
+ import { jsx as k, jsxs as ue, Fragment as $r } from "react/jsx-runtime";
2
+ import { memo as cr, useState as V, useEffect as me, useMemo as ke, useCallback as Un, lazy as Ln, forwardRef as xn, useRef as v, useImperativeHandle as Fn, Suspense as Wn } from "react";
3
+ import { createPortal as Hn } from "react-dom";
4
+ import './index.css';function Xr(r) {
5
5
  var t, c, a = "";
6
6
  if (typeof r == "string" || typeof r == "number") a += r;
7
7
  else if (typeof r == "object") if (Array.isArray(r)) {
8
8
  var m = r.length;
9
- for (t = 0; t < m; t++) r[t] && (c = Wr(r[t])) && (a && (a += " "), a += c);
9
+ for (t = 0; t < m; t++) r[t] && (c = Xr(r[t])) && (a && (a += " "), a += c);
10
10
  } else for (c in r) r[c] && (a && (a += " "), a += c);
11
11
  return a;
12
12
  }
13
- function ke() {
14
- for (var r, t, c = 0, a = "", m = arguments.length; c < m; c++) (r = arguments[c]) && (t = Wr(r)) && (a && (a += " "), a += t);
13
+ function Pe() {
14
+ for (var r, t, c = 0, a = "", m = arguments.length; c < m; c++) (r = arguments[c]) && (t = Xr(r)) && (a && (a += " "), a += t);
15
15
  return a;
16
16
  }
17
- const Uo = { width: 164.6, height: 117.8, depth: 5.2 };
18
- function Lo(r, t, c) {
17
+ const $o = { width: 164.6, height: 117.8, depth: 5.2 };
18
+ function Xo(r, t, c) {
19
19
  return r = Math.max(0, Math.min(1, r)), t = Math.max(0, Math.min(1, t)), c === 1 ? { x: t, y: 1 - r } : c === 2 ? { x: 1 - r, y: 1 - t } : c === 3 ? { x: 1 - t, y: r } : { x: r, y: t };
20
20
  }
21
- function Ln(r) {
21
+ function $n(r) {
22
22
  return Number.isFinite(r) && r >= 0 && r <= 180;
23
23
  }
24
- function xo(r, t) {
24
+ function Bo(r, t) {
25
25
  return { x: Math.max(0, Math.min(1, r)), y: Math.max(0, Math.min(1, 1 - t)) };
26
26
  }
27
- function Fo(r, t, c) {
27
+ function qo(r, t, c) {
28
28
  return t && (r || !c) ? "touch" : r ? "ignore" : "orbit";
29
29
  }
30
- function xn(r, t, c, a) {
30
+ function Xn(r, t, c, a) {
31
31
  if (!Number.isInteger(r) || r < 0 || r > 3 || !Number.isInteger(t) || t < 1 || t > 255 || !Number.isFinite(c) || !Number.isFinite(a) || c < 0 || c > 1 || a < 0 || a > 1)
32
32
  throw new RangeError("Invalid display touch coordinates");
33
33
  const m = new ArrayBuffer(12), p = new DataView(m);
34
34
  return p.setUint8(0, 19), p.setUint8(1, r), p.setUint8(2, t), p.setFloat32(4, c, !0), p.setFloat32(8, a, !0), m;
35
35
  }
36
- class Wo {
36
+ class Vo {
37
37
  constructor(t, c) {
38
38
  this.send = t, this.failed = c;
39
39
  }
@@ -43,7 +43,7 @@ class Wo {
43
43
  running = !1;
44
44
  stopped = !1;
45
45
  set(t) {
46
- this.stopped || !Ln(t) || (this.latest = t, this.flush());
46
+ this.stopped || !$n(t) || (this.latest = t, this.flush());
47
47
  }
48
48
  stop() {
49
49
  this.stopped = !0, this.latest = void 0;
@@ -64,12 +64,12 @@ class Wo {
64
64
  }
65
65
  }
66
66
  }
67
- const Ho = {
67
+ const Go = {
68
68
  side: "Sleep/Wake",
69
69
  volumeUp: "Volume Up",
70
70
  volumeDown: "Volume Down"
71
71
  };
72
- class $o {
72
+ class Jo {
73
73
  constructor(t, c) {
74
74
  this.send = t, this.failed = c;
75
75
  }
@@ -91,13 +91,13 @@ class $o {
91
91
  this.tail = this.tail.then(() => this.send(t, c)).catch(this.failed);
92
92
  }
93
93
  }
94
- const Pt = {
94
+ const xt = {
95
95
  INJECT_KEYCODE: 0,
96
96
  INJECT_TOUCH_EVENT: 2,
97
97
  // iOS-specific: send two touch points in one message (Option/Alt+drag pinch)
98
98
  INJECT_TWO_FINGER_TOUCH_EVENT: 18,
99
99
  SET_CLIPBOARD: 9
100
- }, U = {
100
+ }, L = {
101
101
  ACTION_DOWN: 0,
102
102
  ACTION_UP: 1,
103
103
  ACTION_MOVE: 2,
@@ -233,7 +233,7 @@ const Pt = {
233
233
  KEYCODE_NUMPAD_COMMA: 159,
234
234
  KEYCODE_NUMPAD_ENTER: 160,
235
235
  KEYCODE_NUMPAD_EQUALS: 161
236
- }, Hr = {
236
+ }, Br = {
237
237
  KeyA: s.KEYCODE_A,
238
238
  KeyB: s.KEYCODE_B,
239
239
  KeyC: s.KEYCODE_C,
@@ -339,12 +339,12 @@ const Pt = {
339
339
  // Some numpads have comma
340
340
  NumpadEnter: s.KEYCODE_NUMPAD_ENTER,
341
341
  NumpadEqual: s.KEYCODE_NUMPAD_EQUALS
342
- }, $r = `(function(){"use strict";let e,t;self.onmessage=async({data:s})=>{s.type==="start"?(e=new AbortController,t=s.readable.pipeTo(s.writable,{signal:e.signal}).catch(o=>{e?.signal.aborted||self.postMessage({type:"error",message:String(o)})})):s.type==="stop"&&(e?.abort(),await t,self.postMessage({type:"stopped"}),self.close())}})();
343
- `, Kr = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", $r], { type: "text/javascript;charset=utf-8" });
344
- function Fn(r) {
342
+ }, qr = `(function(){"use strict";let e,t;self.onmessage=async({data:s})=>{s.type==="start"?(e=new AbortController,t=s.readable.pipeTo(s.writable,{signal:e.signal}).catch(o=>{e?.signal.aborted||self.postMessage({type:"error",message:String(o)})})):s.type==="stop"&&(e?.abort(),await t,self.postMessage({type:"stopped"}),self.close())}})();
343
+ `, Ur = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", qr], { type: "text/javascript;charset=utf-8" });
344
+ function Bn(r) {
345
345
  let t;
346
346
  try {
347
- if (t = Kr && (self.URL || self.webkitURL).createObjectURL(Kr), !t) throw "";
347
+ if (t = Ur && (self.URL || self.webkitURL).createObjectURL(Ur), !t) throw "";
348
348
  const c = new Worker(t, {
349
349
  name: r?.name
350
350
  });
@@ -353,100 +353,133 @@ function Fn(r) {
353
353
  }), c;
354
354
  } catch {
355
355
  return new Worker(
356
- "data:text/javascript;charset=utf-8," + encodeURIComponent($r),
356
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(qr),
357
357
  {
358
358
  name: r?.name
359
359
  }
360
360
  );
361
361
  }
362
362
  }
363
- function Wn(r, t, c) {
363
+ function qn(r, t, c) {
364
364
  const { MediaStreamTrackProcessor: a, MediaStreamTrackGenerator: m } = globalThis, p = t.getVideoTracks()[0];
365
- let C, y, b, _, M = !1;
365
+ let g, C, D, O, M = !1;
366
366
  const S = () => {
367
- M || (M = !0, C?.stop(), y?.stop(), b && (b.postMessage({ type: "stop" }), _ = setTimeout(() => b?.terminate(), 1e3)));
367
+ M || (M = !0, g?.stop(), C?.stop(), D && (D.postMessage({ type: "stop" }), O = setTimeout(() => D?.terminate(), 1e3)));
368
368
  }, G = (J) => {
369
369
  r.srcObject = J, r.play().catch(() => {
370
370
  });
371
- }, ie = (J) => {
371
+ }, ce = (J) => {
372
372
  M || (S(), c(J), G(t));
373
373
  };
374
374
  try {
375
375
  if (p && a && m) {
376
- C = p.clone();
377
- const J = new a({ track: C, maxBufferSize: 1 }), de = new m({ kind: "video" });
378
- y = de, b = new Fn(), b.onmessage = ({ data: Z }) => {
379
- Z.type === "error" ? ie(new Error(Z.message)) : Z.type === "stopped" && (clearTimeout(_), b?.terminate());
380
- }, b.onerror = (Z) => ie(new Error(Z.message)), b.postMessage({ type: "start", readable: J.readable, writable: de.writable }, [
376
+ g = p.clone();
377
+ const J = new a({ track: g, maxBufferSize: 1 }), he = new m({ kind: "video" });
378
+ C = he, D = new Bn(), D.onmessage = ({ data: ee }) => {
379
+ ee.type === "error" ? ce(new Error(ee.message)) : ee.type === "stopped" && (clearTimeout(O), D?.terminate());
380
+ }, D.onerror = (ee) => ce(new Error(ee.message)), D.postMessage({ type: "start", readable: J.readable, writable: he.writable }, [
381
381
  J.readable,
382
- de.writable
383
- ]), G(new MediaStream(t.getTracks().map((Z) => Z === p ? de : Z)));
382
+ he.writable
383
+ ]), G(new MediaStream(t.getTracks().map((ee) => ee === p ? he : ee)));
384
384
  } else
385
385
  G(t);
386
386
  } catch (J) {
387
- ie(J);
387
+ ce(J);
388
388
  }
389
389
  return S;
390
390
  }
391
- function Yt(r, t, c, a, m, p, C = 1, y = 0, b = 0) {
392
- const _ = new ArrayBuffer(32), M = new DataView(_);
391
+ function Vn(r, t) {
392
+ const c = r.createDataChannel("latency-trace-v1", {
393
+ ordered: !0,
394
+ negotiated: !0,
395
+ id: 2
396
+ });
397
+ let a = !1, m = !1, p = 0;
398
+ return c.onmessage = (g) => {
399
+ if (m) return;
400
+ let C;
401
+ try {
402
+ C = JSON.parse(g.data);
403
+ } catch (D) {
404
+ console.warn("Invalid latency trace message", D);
405
+ return;
406
+ }
407
+ C && typeof C == "object" && !Array.isArray(C) && t(C);
408
+ }, c.onclose = () => {
409
+ m = !0, a = !1;
410
+ }, {
411
+ accept(g) {
412
+ a = !m && g === 1;
413
+ },
414
+ wrap(g) {
415
+ if (!a || g.byteLength !== 32 || new DataView(g).getUint8(0) !== 2) return g;
416
+ const C = new ArrayBuffer(38), D = new DataView(C);
417
+ return D.setUint8(0, 240), D.setUint8(1, 1), D.setUint32(2, ++p, !0), new Uint8Array(C, 6).set(new Uint8Array(g)), C;
418
+ },
419
+ close() {
420
+ m = !0, a = !1, c.onmessage = null, c.onclose = null, c.close();
421
+ }
422
+ };
423
+ }
424
+ function Pt(r, t, c, a, m, p, g = 1, C = 0, D = 0) {
425
+ const O = new ArrayBuffer(32), M = new DataView(O);
393
426
  let S = 0;
394
- return M.setUint8(S, Pt.INJECT_TOUCH_EVENT), S += 1, M.setUint8(S, r), S += 1, M.setBigInt64(S, BigInt(t), !0), S += 8, M.setInt32(S, Math.round(m), !0), S += 4, M.setInt32(S, Math.round(p), !0), S += 4, M.setUint16(S, c, !0), S += 2, M.setUint16(S, a, !0), S += 2, M.setInt16(S, Math.round(C * 65535), !0), S += 2, M.setInt32(S, y, !0), S += 4, M.setInt32(S, b, !0), _;
427
+ return M.setUint8(S, xt.INJECT_TOUCH_EVENT), S += 1, M.setUint8(S, r), S += 1, M.setBigInt64(S, BigInt(t), !0), S += 8, M.setInt32(S, Math.round(m), !0), S += 4, M.setInt32(S, Math.round(p), !0), S += 4, M.setUint16(S, c, !0), S += 2, M.setUint16(S, a, !0), S += 2, M.setInt16(S, Math.round(g * 65535), !0), S += 2, M.setInt32(S, C, !0), S += 4, M.setInt32(S, D, !0), O;
395
428
  }
396
- function Hn(r, t, c, a, m, p, C) {
397
- const y = new ArrayBuffer(24), b = new DataView(y);
398
- let _ = 0;
399
- return b.setUint8(_, Pt.INJECT_TWO_FINGER_TOUCH_EVENT), _ += 1, b.setUint8(_, r), _ += 1, b.setInt32(_, Math.round(a), !0), _ += 4, b.setInt32(_, Math.round(m), !0), _ += 4, b.setInt32(_, Math.round(p), !0), _ += 4, b.setInt32(_, Math.round(C), !0), _ += 4, b.setUint16(_, t, !0), _ += 2, b.setUint16(_, c, !0), _ += 2, b.setUint16(_, 0, !0), y;
429
+ function Gn(r, t, c, a, m, p, g) {
430
+ const C = new ArrayBuffer(24), D = new DataView(C);
431
+ let O = 0;
432
+ return D.setUint8(O, xt.INJECT_TWO_FINGER_TOUCH_EVENT), O += 1, D.setUint8(O, r), O += 1, D.setInt32(O, Math.round(a), !0), O += 4, D.setInt32(O, Math.round(m), !0), O += 4, D.setInt32(O, Math.round(p), !0), O += 4, D.setInt32(O, Math.round(g), !0), O += 4, D.setUint16(O, t, !0), O += 2, D.setUint16(O, c, !0), O += 2, D.setUint16(O, 0, !0), C;
400
433
  }
401
- function $n(r, t = !0) {
434
+ function Jn(r, t = !0) {
402
435
  const a = new TextEncoder().encode(r), m = new ArrayBuffer(14 + a.length), p = new DataView(m);
403
- let C = 0;
404
- return p.setUint8(C, Pt.SET_CLIPBOARD), C += 1, p.setBigInt64(C, BigInt(0), !1), C += 8, p.setUint8(C, t ? 1 : 0), C += 1, p.setUint32(C, a.length, !1), C += 4, new Uint8Array(m, C).set(a), m;
436
+ let g = 0;
437
+ return p.setUint8(g, xt.SET_CLIPBOARD), g += 1, p.setBigInt64(g, BigInt(0), !1), g += 8, p.setUint8(g, t ? 1 : 0), g += 1, p.setUint32(g, a.length, !1), g += 4, new Uint8Array(m, g).set(a), m;
405
438
  }
406
- function pt(r, t, c = 0, a = 0) {
439
+ function gt(r, t, c = 0, a = 0) {
407
440
  const m = new ArrayBuffer(14), p = new DataView(m);
408
- let C = 0;
409
- return p.setUint8(C, Pt.INJECT_KEYCODE), C += 1, p.setUint8(C, r), C += 1, p.setInt32(C, t, !0), C += 4, p.setInt32(C, c, !0), C += 4, p.setInt32(C, a, !0), m;
441
+ let g = 0;
442
+ return p.setUint8(g, xt.INJECT_KEYCODE), g += 1, p.setUint8(g, r), g += 1, p.setInt32(g, t, !0), g += 4, p.setInt32(g, c, !0), g += 4, p.setInt32(g, a, !0), m;
410
443
  }
411
- const er = "Accessibility unavailable on this device.", kt = 500, Xr = (r, t) => Math.abs(r.x - t.x) < 0.5 && Math.abs(r.y - t.y) < 0.5 && Math.abs(r.width - t.width) < 0.5 && Math.abs(r.height - t.height) < 0.5, Xn = (r) => Math.max(0, r.width) * Math.max(0, r.height), Bn = (r) => {
444
+ const or = "Accessibility unavailable on this device.", Lt = 500, Vr = (r, t) => Math.abs(r.x - t.x) < 0.5 && Math.abs(r.y - t.y) < 0.5 && Math.abs(r.width - t.width) < 0.5 && Math.abs(r.height - t.height) < 0.5, jn = (r) => Math.max(0, r.width) * Math.max(0, r.height), zn = (r) => {
412
445
  const t = r.find((c) => c.frame && c.frame.width > 0 && c.frame.height > 0);
413
446
  return t?.frame ? ((Math.abs(t.frame.x) > 0.5 || Math.abs(t.frame.y) > 0.5) && console.warn(
414
447
  `[ax-tree] iOS root frame is not anchored at (0,0): (${t.frame.x},${t.frame.y}). Element positions may be slightly off from the rendered video.`
415
448
  ), { x: 0, y: 0, width: t.frame.width, height: t.frame.height }) : { x: 0, y: 0, width: 1, height: 1 };
416
- }, qn = (r) => {
449
+ }, Qn = (r) => {
417
450
  const t = {};
418
451
  return typeof r.AXUniqueId == "string" && r.AXUniqueId.length > 0 && (t.AXUniqueId = r.AXUniqueId), typeof r.AXLabel == "string" && r.AXLabel.length > 0 && (t.AXLabel = r.AXLabel), typeof r.type == "string" && r.type.length > 0 && (t.className = r.type), t;
419
- }, Vn = (r) => {
452
+ }, Zn = (r) => {
420
453
  const t = {};
421
454
  for (const [c, a] of Object.entries(r))
422
455
  c !== "children" && (t[c] = a);
423
456
  return t;
424
457
  };
425
- function Gn(r) {
426
- const t = Array.isArray(r) ? r : [r], c = Bn(t), a = [], m = (p, C) => {
427
- if (a.length >= kt) return;
428
- const y = p.frame;
429
- if (y && y.width > 0 && y.height > 0 && !Xr(y, c)) {
430
- const _ = p.role_description || p.role || "", M = (typeof p.AXLabel == "string" ? p.AXLabel : "") || (typeof p.title == "string" ? p.title : "") || "";
458
+ function eo(r) {
459
+ const t = Array.isArray(r) ? r : [r], c = zn(t), a = [], m = (p, g) => {
460
+ if (a.length >= Lt) return;
461
+ const C = p.frame;
462
+ if (C && C.width > 0 && C.height > 0 && !Vr(C, c)) {
463
+ const O = p.role_description || p.role || "", M = (typeof p.AXLabel == "string" ? p.AXLabel : "") || (typeof p.title == "string" ? p.title : "") || "";
431
464
  a.push({
432
- id: typeof p.AXUniqueId == "string" && p.AXUniqueId.length > 0 ? p.AXUniqueId : C,
433
- path: C,
465
+ id: typeof p.AXUniqueId == "string" && p.AXUniqueId.length > 0 ? p.AXUniqueId : g,
466
+ path: g,
434
467
  label: M,
435
468
  value: typeof p.AXValue == "string" ? p.AXValue : "",
436
- role: _,
469
+ role: O,
437
470
  type: typeof p.type == "string" ? p.type : "",
438
471
  enabled: p.enabled !== !1,
439
472
  focused: p.focused === !0,
440
- frame: { x: y.x, y: y.y, width: y.width, height: y.height },
441
- selectors: qn(p),
442
- raw: Vn(p)
473
+ frame: { x: C.x, y: C.y, width: C.width, height: C.height },
474
+ selectors: Qn(p),
475
+ raw: Zn(p)
443
476
  });
444
477
  }
445
- const b = Array.isArray(p.children) ? p.children : [];
446
- for (let _ = 0; _ < b.length && a.length < kt; _++)
447
- m(b[_], `${C}.${_}`);
478
+ const D = Array.isArray(p.children) ? p.children : [];
479
+ for (let O = 0; O < D.length && a.length < Lt; O++)
480
+ m(D[O], `${g}.${O}`);
448
481
  };
449
- for (let p = 0; p < t.length && a.length < kt; p++)
482
+ for (let p = 0; p < t.length && a.length < Lt; p++)
450
483
  m(t[p], String(p));
451
484
  return {
452
485
  platform: "ios",
@@ -455,40 +488,40 @@ function Gn(r) {
455
488
  capturedAt: Date.now()
456
489
  };
457
490
  }
458
- const Jn = (r) => {
491
+ const to = (r) => {
459
492
  let t = { x: 0, y: 0, width: 1, height: 1 }, c = 0;
460
493
  for (const a of r) {
461
494
  const m = a.parsedBounds;
462
495
  if (!m) continue;
463
- const p = m.right - m.left, C = m.bottom - m.top, y = Math.max(0, p) * Math.max(0, C);
464
- y > c && (c = y, t = { x: 0, y: 0, width: p, height: C });
496
+ const p = m.right - m.left, g = m.bottom - m.top, C = Math.max(0, p) * Math.max(0, g);
497
+ C > c && (c = C, t = { x: 0, y: 0, width: p, height: g });
465
498
  }
466
499
  return t;
467
- }, jn = (r) => {
500
+ }, ro = (r) => {
468
501
  const t = {};
469
502
  return typeof r.resourceId == "string" && r.resourceId.length > 0 && (t.resourceId = r.resourceId), typeof r.contentDesc == "string" && r.contentDesc.length > 0 && (t.contentDesc = r.contentDesc), typeof r.text == "string" && r.text.length > 0 && (t.text = r.text), typeof r.className == "string" && r.className.length > 0 && (t.className = r.className), t;
470
503
  };
471
- function zn(r) {
472
- const t = Jn(r), c = [];
473
- for (let a = 0; a < r.length && c.length < kt; a++) {
504
+ function no(r) {
505
+ const t = to(r), c = [];
506
+ for (let a = 0; a < r.length && c.length < Lt; a++) {
474
507
  const m = r[a], p = m.parsedBounds;
475
508
  if (!p) continue;
476
- const C = Math.max(0, p.right - p.left), y = Math.max(0, p.bottom - p.top);
477
- if (C <= 0 || y <= 0) continue;
478
- const b = { x: p.left, y: p.top, width: C, height: y };
479
- if (Xr(b, { x: 0, y: 0, width: t.width, height: t.height })) continue;
480
- const _ = m.contentDesc || m.text || "", M = m.className || "";
509
+ const g = Math.max(0, p.right - p.left), C = Math.max(0, p.bottom - p.top);
510
+ if (g <= 0 || C <= 0) continue;
511
+ const D = { x: p.left, y: p.top, width: g, height: C };
512
+ if (Vr(D, { x: 0, y: 0, width: t.width, height: t.height })) continue;
513
+ const O = m.contentDesc || m.text || "", M = m.className || "";
481
514
  c.push({
482
515
  id: m.resourceId && m.resourceId.length > 0 ? m.resourceId : m.contentDesc && m.contentDesc.length > 0 ? `cd:${m.contentDesc}` : String(a),
483
516
  path: String(a),
484
- label: _,
517
+ label: O,
485
518
  value: typeof m.text == "string" ? m.text : "",
486
519
  role: M,
487
520
  type: M,
488
521
  enabled: m.enabled !== !1,
489
522
  focused: m.focused === !0,
490
- frame: b,
491
- selectors: jn(m),
523
+ frame: D,
524
+ selectors: ro(m),
492
525
  raw: { ...m }
493
526
  });
494
527
  }
@@ -499,34 +532,34 @@ function zn(r) {
499
532
  capturedAt: Date.now()
500
533
  };
501
534
  }
502
- function Qn(r, t) {
503
- const c = Math.max(0, r.x), a = Math.max(0, r.y), m = Math.min(t.width, r.x + r.width), p = Math.min(t.height, r.y + r.height), C = Math.max(0, m - c), y = Math.max(0, p - a);
504
- return C > 0 && y > 0 ? { x: c, y: a, width: C, height: y } : null;
535
+ function oo(r, t) {
536
+ const c = Math.max(0, r.x), a = Math.max(0, r.y), m = Math.min(t.width, r.x + r.width), p = Math.min(t.height, r.y + r.height), g = Math.max(0, m - c), C = Math.max(0, p - a);
537
+ return g > 0 && C > 0 ? { x: c, y: a, width: g, height: C } : null;
505
538
  }
506
- function Br(r, t) {
539
+ function Gr(r, t) {
507
540
  if (r === t) return !0;
508
541
  if (r.id !== t.id || r.path !== t.path || r.label !== t.label || r.value !== t.value || r.role !== t.role || r.type !== t.type || r.enabled !== t.enabled || r.focused !== t.focused) return !1;
509
542
  const c = r.frame, a = t.frame;
510
543
  return c.x === a.x && c.y === a.y && c.width === a.width && c.height === a.height;
511
544
  }
512
- function qr(r, t) {
545
+ function Jr(r, t) {
513
546
  if (r === t) return !0;
514
547
  if (!r || !t || r.platform !== t.platform || r.screen.width !== t.screen.width || r.screen.height !== t.screen.height || r.elements.length !== t.elements.length) return !1;
515
548
  for (let c = 0; c < r.elements.length; c++)
516
- if (!Br(r.elements[c], t.elements[c])) return !1;
549
+ if (!Gr(r.elements[c], t.elements[c])) return !1;
517
550
  return !0;
518
551
  }
519
- function Zn(r, t, c) {
552
+ function io(r, t, c) {
520
553
  let a = null, m = 1 / 0;
521
554
  for (const p of r.elements) {
522
- const C = p.frame;
523
- if (t < C.x || c < C.y || t > C.x + C.width || c > C.y + C.height) continue;
524
- const y = Xn(C);
525
- y < m && (m = y, a = p);
555
+ const g = p.frame;
556
+ if (t < g.x || c < g.y || t > g.x + g.width || c > g.y + g.height) continue;
557
+ const C = jn(g);
558
+ C < m && (m = C, a = p);
526
559
  }
527
560
  return a;
528
561
  }
529
- function eo(r, t) {
562
+ function co(r, t) {
530
563
  if (t === "ios") {
531
564
  if (r.selectors.AXUniqueId)
532
565
  return `client.tapElement({ AXUniqueId: ${JSON.stringify(r.selectors.AXUniqueId)} })`;
@@ -538,21 +571,21 @@ function eo(r, t) {
538
571
  }
539
572
  return r.selectors.resourceId ? `client.tap({ selector: { resourceId: ${JSON.stringify(r.selectors.resourceId)} } })` : r.selectors.contentDesc ? `client.tap({ selector: { contentDesc: ${JSON.stringify(r.selectors.contentDesc)} } })` : r.selectors.text ? `client.tap({ selector: { text: ${JSON.stringify(r.selectors.text)} } })` : null;
540
573
  }
541
- function Vr(r) {
574
+ function jr(r) {
542
575
  const t = r.role || r.type || "";
543
576
  if (!t) return "element";
544
577
  let c = t.replace(/^AX/, "");
545
578
  return c.includes(".") && (c = c.split(".").pop()), c === "GenericElement" ? "Element" : (c = c.replace(/([a-z])([A-Z])/g, "$1 $2"), c);
546
579
  }
547
- const kr = 80;
548
- function Gr(r) {
549
- const t = Vr(r), c = r.label || r.value || "";
580
+ const Lr = 80;
581
+ function zr(r) {
582
+ const t = jr(r), c = r.label || r.value || "";
550
583
  if (!c) return t;
551
- const a = c.length > kr ? c.slice(0, kr).trimEnd() + "…" : c;
584
+ const a = c.length > Lr ? c.slice(0, Lr).trimEnd() + "…" : c;
552
585
  return `${t} · ${a}`;
553
586
  }
554
- const to = 500, ro = 2e3, Pr = 5e3, no = 8e3, oo = 1200, io = 250, co = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
555
- class so {
587
+ const so = 500, ao = 2e3, xr = 5e3, uo = 8e3, lo = 1200, fo = 250, ho = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
588
+ class po {
556
589
  platform;
557
590
  send;
558
591
  onSnapshot;
@@ -579,7 +612,7 @@ class so {
579
612
  // identical-to-current transitions are no-ops.
580
613
  status = "idle";
581
614
  constructor(t) {
582
- this.platform = t.platform, this.send = t.send, this.onSnapshot = t.onSnapshot, this.onStatusChange = t.onStatusChange, this.baseIntervalMs = t.baseIntervalMs ?? to, this.maxBackoffMs = t.maxBackoffMs ?? ro, this.androidElementTreeOptions = t.androidElementTreeOptions, this.currentInterval = this.baseIntervalMs;
615
+ this.platform = t.platform, this.send = t.send, this.onSnapshot = t.onSnapshot, this.onStatusChange = t.onStatusChange, this.baseIntervalMs = t.baseIntervalMs ?? so, this.maxBackoffMs = t.maxBackoffMs ?? ao, this.androidElementTreeOptions = t.androidElementTreeOptions, this.currentInterval = this.baseIntervalMs;
583
616
  }
584
617
  start() {
585
618
  this.running || (this.running = !0, this.currentInterval = this.baseIntervalMs, this.boostUntilMs = 0, this.setStatus("starting"), this.runOnce());
@@ -611,7 +644,7 @@ class so {
611
644
  bumpActivity() {
612
645
  if (!this.running) return;
613
646
  const t = Date.now();
614
- this.boostUntilMs = t + oo;
647
+ this.boostUntilMs = t + lo;
615
648
  const c = Math.max(150, Math.floor(this.baseIntervalMs / 2));
616
649
  if (t - this.lastBumpAtMs < c) {
617
650
  this.currentInterval = this.baseIntervalMs;
@@ -643,30 +676,30 @@ class so {
643
676
  if (!this.pending.get(c)) return !1;
644
677
  if (this.platform === "ios") {
645
678
  if (t.type !== "elementTreeResult") return !1;
646
- const y = typeof t.error == "string" ? t.error : null;
647
- if (y)
648
- return this.settleReject(c, new Error(y)), !0;
649
- const b = typeof t.json == "string" ? t.json : "";
679
+ const C = typeof t.error == "string" ? t.error : null;
680
+ if (C)
681
+ return this.settleReject(c, new Error(C)), !0;
682
+ const D = typeof t.json == "string" ? t.json : "";
650
683
  try {
651
- const _ = JSON.parse(b), M = Gn(_);
684
+ const O = JSON.parse(D), M = eo(O);
652
685
  this.settleResolve(c, M);
653
- } catch (_) {
654
- this.settleReject(c, _ instanceof Error ? _ : new Error(String(_)));
686
+ } catch (O) {
687
+ this.settleReject(c, O instanceof Error ? O : new Error(String(O)));
655
688
  }
656
689
  return !0;
657
690
  }
658
691
  if (t.type !== "getElementTreeResult") return !1;
659
692
  const m = t.error;
660
693
  if (m && typeof m == "object") {
661
- const y = typeof m.message == "string" ? m.message : "getElementTree failed";
662
- return this.settleReject(c, new Error(y)), !0;
694
+ const C = typeof m.message == "string" ? m.message : "getElementTree failed";
695
+ return this.settleReject(c, new Error(C)), !0;
663
696
  }
664
- const p = t.payload, C = Array.isArray(p?.nodes) ? p.nodes : [];
697
+ const p = t.payload, g = Array.isArray(p?.nodes) ? p.nodes : [];
665
698
  try {
666
- const y = zn(C);
667
- this.settleResolve(c, y);
668
- } catch (y) {
669
- this.settleReject(c, y instanceof Error ? y : new Error(String(y)));
699
+ const C = no(g);
700
+ this.settleResolve(c, C);
701
+ } catch (C) {
702
+ this.settleReject(c, C instanceof Error ? C : new Error(String(C)));
670
703
  }
671
704
  return !0;
672
705
  }
@@ -674,13 +707,13 @@ class so {
674
707
  return this.platform === "ios" ? { type: "elementTree", id: t } : { type: "getElementTree", id: t, ...this.androidElementTreeOptions };
675
708
  }
676
709
  async requestOnce() {
677
- const t = co();
710
+ const t = ho();
678
711
  return new Promise((c, a) => {
679
712
  const m = window.setTimeout(
680
713
  () => {
681
714
  this.pending.delete(t), a(new Error("elementTree request timed out"));
682
715
  },
683
- no + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
716
+ uo + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
684
717
  );
685
718
  this.pending.set(t, { resolve: c, reject: a, timer: m }), this.send(this.buildRequest(t)) || (window.clearTimeout(m), this.pending.delete(t), a(new Error("elementTree send failed (WebSocket not open)")));
686
719
  });
@@ -695,7 +728,7 @@ class so {
695
728
  } catch (t) {
696
729
  if (!this.running) return;
697
730
  const c = t instanceof Error ? t.message : String(t), a = /unavailable|not (yet )?running|failed|timeout/i.test(c);
698
- this.currentInterval = a ? Pr : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(a ? "unavailable" : "error", c);
731
+ this.currentInterval = a ? xr : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(a ? "unavailable" : "error", c);
699
732
  } finally {
700
733
  this.inflight = !1, this.scheduleNext();
701
734
  }
@@ -703,16 +736,16 @@ class so {
703
736
  }
704
737
  deliver(t) {
705
738
  const c = this.lastSnapshot;
706
- if (qr(c, t)) {
707
- this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = t, t.errors?.includes(er) || this.setStatus("ready");
739
+ if (Jr(c, t)) {
740
+ this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = t, t.errors?.includes(or) || this.setStatus("ready");
708
741
  return;
709
742
  }
710
- this.lastSnapshot = t, this.currentInterval = this.baseIntervalMs, t.errors?.includes(er) ? (this.currentInterval = Pr, this.setStatus("unavailable", er)) : this.setStatus("ready"), this.onSnapshot(t);
743
+ this.lastSnapshot = t, this.currentInterval = this.baseIntervalMs, t.errors?.includes(or) ? (this.currentInterval = xr, this.setStatus("unavailable", or)) : this.setStatus("ready"), this.onSnapshot(t);
711
744
  }
712
745
  scheduleNext() {
713
746
  if (!this.running) return;
714
747
  this.timer !== void 0 && window.clearTimeout(this.timer);
715
- const t = Date.now() < this.boostUntilMs ? Math.min(io, this.currentInterval) : this.currentInterval;
748
+ const t = Date.now() < this.boostUntilMs ? Math.min(fo, this.currentInterval) : this.currentInterval;
716
749
  this.timer = window.setTimeout(() => {
717
750
  this.timer = void 0, this.runOnce();
718
751
  }, t);
@@ -730,7 +763,7 @@ class so {
730
763
  window.clearTimeout(a.timer), a.reject(new Error(t)), this.pending.delete(c);
731
764
  }
732
765
  }
733
- class ao {
766
+ class mo {
734
767
  generation = 0;
735
768
  tail = Promise.resolve();
736
769
  get currentGeneration() {
@@ -761,23 +794,23 @@ class ao {
761
794
  ++this.generation;
762
795
  }
763
796
  }
764
- function uo(r) {
797
+ function Eo(r) {
765
798
  if (!r || typeof r != "object") return null;
766
799
  const t = r;
767
800
  if (t.type !== "cameraRequest" || typeof t.active != "boolean") return null;
768
801
  const c = { active: t.active };
769
802
  return (t.facingMode === "user" || t.facingMode === "environment") && (c.facingMode = t.facingMode), c;
770
803
  }
771
- function lo(r) {
804
+ function go(r) {
772
805
  const t = {
773
806
  frameRate: { ideal: 30, max: 30 }
774
807
  };
775
808
  return r?.facingMode && (t.facingMode = { ideal: r.facingMode }), t;
776
809
  }
777
- function fo(r, t) {
810
+ function yo(r, t) {
778
811
  return !r || r.facingMode !== t.facingMode;
779
812
  }
780
- function ho(r) {
813
+ function Co(r) {
781
814
  const t = r.getSettings();
782
815
  return {
783
816
  width: t.width,
@@ -788,14 +821,14 @@ function ho(r) {
788
821
  facingMode: t.facingMode
789
822
  };
790
823
  }
791
- function po(r) {
824
+ function vo(r) {
792
825
  return {
793
826
  type: "cameraResult",
794
827
  granted: !0,
795
- camera: ho(r)
828
+ camera: Co(r)
796
829
  };
797
830
  }
798
- const mo = async (r) => {
831
+ const Oo = async (r) => {
799
832
  if (!r) return !1;
800
833
  try {
801
834
  if (typeof navigator < "u" && navigator.clipboard?.writeText)
@@ -810,90 +843,90 @@ const mo = async (r) => {
810
843
  } catch {
811
844
  return !1;
812
845
  }
813
- }, Eo = rr(
814
- function({ element: t, screen: c, highlighted: a, selected: m, selectable: p, onClick: C }) {
815
- const y = Qn(t.frame, c);
816
- if (!y) return null;
817
- const b = Gr(t);
846
+ }, _o = cr(
847
+ function({ element: t, screen: c, highlighted: a, selected: m, selectable: p, onClick: g }) {
848
+ const C = oo(t.frame, c);
849
+ if (!C) return null;
850
+ const D = zr(t);
818
851
  return /* @__PURE__ */ k(
819
852
  "button",
820
853
  {
821
854
  type: "button",
822
- className: ke("rc-inspect-box", !t.enabled && "rc-inspect-box-disabled"),
855
+ className: Pe("rc-inspect-box", !t.enabled && "rc-inspect-box-disabled"),
823
856
  "data-ax-id": t.id,
824
857
  "data-ax-path": t.path,
825
858
  "data-ax-label": t.label || void 0,
826
859
  "data-ax-role": t.role || void 0,
827
860
  "data-highlighted": a ? "true" : "false",
828
861
  "data-selected": m ? "true" : "false",
829
- "aria-label": b,
830
- onClick: (_) => {
831
- p && (_.preventDefault(), _.stopPropagation(), C(t, { x: _.clientX, y: _.clientY }));
862
+ "aria-label": D,
863
+ onClick: (O) => {
864
+ p && (O.preventDefault(), O.stopPropagation(), g(t, { x: O.clientX, y: O.clientY }));
832
865
  },
833
866
  style: {
834
- left: `${y.x / c.width * 100}%`,
835
- top: `${y.y / c.height * 100}%`,
836
- width: `${y.width / c.width * 100}%`,
837
- height: `${y.height / c.height * 100}%`
867
+ left: `${C.x / c.width * 100}%`,
868
+ top: `${C.y / c.height * 100}%`,
869
+ width: `${C.width / c.width * 100}%`,
870
+ height: `${C.height / c.height * 100}%`
838
871
  }
839
872
  }
840
873
  );
841
874
  },
842
- (r, t) => r.highlighted === t.highlighted && r.selected === t.selected && r.selectable === t.selectable && r.screen.width === t.screen.width && r.screen.height === t.screen.height && r.onClick === t.onClick && Br(r.element, t.element)
843
- ), go = 260, Co = 220, yo = 6, vo = 8, Oo = rr(function({
875
+ (r, t) => r.highlighted === t.highlighted && r.selected === t.selected && r.selectable === t.selectable && r.screen.width === t.screen.width && r.screen.height === t.screen.height && r.onClick === t.onClick && Gr(r.element, t.element)
876
+ ), wo = 260, Do = 220, To = 6, Ao = 8, bo = cr(function({
844
877
  element: t,
845
878
  platform: c,
846
879
  anchor: a,
847
880
  cursorAnchored: m,
848
881
  showActions: p,
849
- onTap: C
882
+ onTap: g
850
883
  }) {
851
- const [y, b] = V(null);
852
- pe(() => {
853
- if (!y) return;
854
- const X = window.setTimeout(() => b(null), 1100);
884
+ const [C, D] = V(null);
885
+ me(() => {
886
+ if (!C) return;
887
+ const X = window.setTimeout(() => D(null), 1100);
855
888
  return () => window.clearTimeout(X);
856
- }, [y]);
857
- const _ = Ke(() => {
858
- const X = go, me = Co, ce = yo, H = vo, Ee = typeof window < "u" ? window.innerWidth : 1024, mt = typeof window < "u" ? window.innerHeight : 768, Pe = a.x + ce + X <= Ee - H, ge = a.y - ce - me >= H;
859
- let F = Pe ? a.x + ce : a.x - ce, _e = ge ? a.y - ce : a.y + ce;
860
- const Lt = `translate(${Pe ? "0" : "-100%"}, ${ge ? "-100%" : "0"})`;
861
- return F = Math.max(H + (Pe ? 0 : X), Math.min(Ee - H - (Pe ? X : 0), F)), _e = Math.max(H + (ge ? me : 0), Math.min(mt - H - (ge ? 0 : me), _e)), { left: `${F}px`, top: `${_e}px`, transform: Lt };
862
- }, [a.x, a.y]), M = Ke(() => eo(t, c), [t, c]), S = c === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, G = c === "ios" ? "AXUniqueId" : "resourceId", ie = In(async (X, me) => {
889
+ }, [C]);
890
+ const O = ke(() => {
891
+ const X = wo, Ee = Do, se = To, H = Ao, ge = typeof window < "u" ? window.innerWidth : 1024, tt = typeof window < "u" ? window.innerHeight : 768, Te = a.x + se + X <= ge - H, Ue = a.y - se - Ee >= H;
892
+ let _e = Te ? a.x + se : a.x - se, W = Ue ? a.y - se : a.y + se;
893
+ const Wt = `translate(${Te ? "0" : "-100%"}, ${Ue ? "-100%" : "0"})`;
894
+ return _e = Math.max(H + (Te ? 0 : X), Math.min(ge - H - (Te ? X : 0), _e)), W = Math.max(H + (Ue ? Ee : 0), Math.min(tt - H - (Ue ? 0 : Ee), W)), { left: `${_e}px`, top: `${W}px`, transform: Wt };
895
+ }, [a.x, a.y]), M = ke(() => co(t, c), [t, c]), S = c === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, G = c === "ios" ? "AXUniqueId" : "resourceId", ce = Un(async (X, Ee) => {
863
896
  if (!X) return;
864
- await mo(X) && b(me);
865
- }, []), J = Vr(t), de = t.label || t.value || J, Z = Gr(t);
866
- return Un(
867
- /* @__PURE__ */ ae(
897
+ await Oo(X) && D(Ee);
898
+ }, []), J = jr(t), he = t.label || t.value || J, ee = zr(t);
899
+ return Hn(
900
+ /* @__PURE__ */ ue(
868
901
  "div",
869
902
  {
870
903
  className: "rc-inspect-card",
871
904
  "data-cursor-anchored": m ? "true" : "false",
872
- style: _,
905
+ style: O,
873
906
  onClick: (X) => X.stopPropagation(),
874
907
  onMouseDown: (X) => X.stopPropagation(),
875
908
  onMouseMove: (X) => X.stopPropagation(),
876
909
  children: [
877
- /* @__PURE__ */ ae("div", { className: "rc-inspect-card-header", children: [
910
+ /* @__PURE__ */ ue("div", { className: "rc-inspect-card-header", children: [
878
911
  /* @__PURE__ */ k("span", { className: "rc-inspect-card-role", children: J }),
879
912
  !t.enabled && /* @__PURE__ */ k("span", { className: "rc-inspect-card-tag", children: "disabled" }),
880
913
  t.focused && /* @__PURE__ */ k("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
881
914
  ] }),
882
- /* @__PURE__ */ k("p", { className: "rc-inspect-card-title", title: Z, children: de }),
883
- S && /* @__PURE__ */ ae("div", { className: "rc-inspect-card-row", children: [
884
- /* @__PURE__ */ ae("span", { className: "rc-inspect-card-row-label", children: [
915
+ /* @__PURE__ */ k("p", { className: "rc-inspect-card-title", title: ee, children: he }),
916
+ S && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
917
+ /* @__PURE__ */ ue("span", { className: "rc-inspect-card-row-label", children: [
885
918
  G,
886
919
  ":"
887
920
  ] }),
888
921
  /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-value", children: S })
889
922
  ] }),
890
- t.value && t.value !== t.label && /* @__PURE__ */ ae("div", { className: "rc-inspect-card-row", children: [
923
+ t.value && t.value !== t.label && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
891
924
  /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-label", children: "value:" }),
892
925
  /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-value", children: t.value })
893
926
  ] }),
894
- /* @__PURE__ */ ae("div", { className: "rc-inspect-card-row", children: [
927
+ /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
895
928
  /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
896
- /* @__PURE__ */ ae("span", { className: "rc-inspect-card-row-value", children: [
929
+ /* @__PURE__ */ ue("span", { className: "rc-inspect-card-row-value", children: [
897
930
  Math.round(t.frame.width),
898
931
  "×",
899
932
  Math.round(t.frame.height),
@@ -903,13 +936,13 @@ const mo = async (r) => {
903
936
  Math.round(t.frame.y)
904
937
  ] })
905
938
  ] }),
906
- p && /* @__PURE__ */ ae("div", { className: "rc-inspect-card-actions", children: [
939
+ p && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-actions", children: [
907
940
  /* @__PURE__ */ k(
908
941
  "button",
909
942
  {
910
943
  type: "button",
911
944
  className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
912
- onClick: () => C(t, a),
945
+ onClick: () => g(t, a),
913
946
  children: "Tap"
914
947
  }
915
948
  ),
@@ -917,22 +950,22 @@ const mo = async (r) => {
917
950
  "button",
918
951
  {
919
952
  type: "button",
920
- className: ke("rc-inspect-card-btn", y === "selector" && "rc-inspect-card-btn-copied"),
953
+ className: Pe("rc-inspect-card-btn", C === "selector" && "rc-inspect-card-btn-copied"),
921
954
  disabled: !M,
922
955
  title: M ?? "No usable selector for this element",
923
- onClick: () => ie(M ?? void 0, "selector"),
924
- children: y === "selector" ? "Copied!" : "Copy selector"
956
+ onClick: () => ce(M ?? void 0, "selector"),
957
+ children: C === "selector" ? "Copied!" : "Copy selector"
925
958
  }
926
959
  ),
927
960
  /* @__PURE__ */ k(
928
961
  "button",
929
962
  {
930
963
  type: "button",
931
- className: ke("rc-inspect-card-btn", y === "id" && "rc-inspect-card-btn-copied"),
964
+ className: Pe("rc-inspect-card-btn", C === "id" && "rc-inspect-card-btn-copied"),
932
965
  disabled: !S,
933
966
  title: S ?? `No ${G}`,
934
- onClick: () => ie(S, "id"),
935
- children: y === "id" ? "Copied!" : `Copy ${G}`
967
+ onClick: () => ce(S, "id"),
968
+ children: C === "id" ? "Copied!" : `Copy ${G}`
936
969
  }
937
970
  )
938
971
  ] })
@@ -941,82 +974,82 @@ const mo = async (r) => {
941
974
  ),
942
975
  document.body
943
976
  );
944
- }), _o = rr(function({
977
+ }), So = cr(function({
945
978
  snapshot: t,
946
979
  geometry: c,
947
980
  highlightedId: a,
948
981
  selectedId: m,
949
982
  mode: p,
950
- cursorPosition: C,
951
- frozenCursorPosition: y,
952
- onSelectChange: b,
953
- onTapElement: _
983
+ cursorPosition: g,
984
+ frozenCursorPosition: C,
985
+ onSelectChange: D,
986
+ onTapElement: O
954
987
  }) {
955
- const M = p === "select", S = M ? a !== null && a !== m : a !== null, G = M ? a ?? m : a, ie = Ke(() => {
988
+ const M = p === "select", S = M ? a !== null && a !== m : a !== null, G = M ? a ?? m : a, ce = ke(() => {
956
989
  const H = /* @__PURE__ */ new Map();
957
990
  if (!t) return H;
958
- for (const Ee of t.elements) H.set(Ee.id, Ee);
991
+ for (const ge of t.elements) H.set(ge.id, ge);
959
992
  return H;
960
- }, [t]), J = Ke(() => G ? ie.get(G) ?? null : null, [G, ie]);
993
+ }, [t]), J = ke(() => G ? ce.get(G) ?? null : null, [G, ce]);
961
994
  if (!(!!t && !!c && t.screen.width > 0 && t.screen.height > 0 && t.elements.length > 0)) return null;
962
- const Z = S ? C : y ?? C, X = S, me = M && !S && m !== null, ce = (H) => {
963
- M && H.target === H.currentTarget && b(null, null);
995
+ const ee = S ? g : C ?? g, X = S, Ee = M && !S && m !== null, se = (H) => {
996
+ M && H.target === H.currentTarget && D(null, null);
964
997
  };
965
- return /* @__PURE__ */ ae(Fr, { children: [
998
+ return /* @__PURE__ */ ue($r, { children: [
966
999
  /* @__PURE__ */ k(
967
1000
  "div",
968
1001
  {
969
- className: ke("rc-inspect-overlay", M && "rc-inspect-overlay-select"),
1002
+ className: Pe("rc-inspect-overlay", M && "rc-inspect-overlay-select"),
970
1003
  style: {
971
1004
  left: `${c.left}px`,
972
1005
  top: `${c.top}px`,
973
1006
  width: `${c.width}px`,
974
1007
  height: `${c.height}px`
975
1008
  },
976
- onClick: ce,
1009
+ onClick: se,
977
1010
  children: t.elements.map((H) => /* @__PURE__ */ k(
978
- Eo,
1011
+ _o,
979
1012
  {
980
1013
  element: H,
981
1014
  screen: t.screen,
982
1015
  highlighted: H.id === a,
983
1016
  selected: H.id === m,
984
1017
  selectable: M,
985
- onClick: b
1018
+ onClick: D
986
1019
  },
987
1020
  H.id
988
1021
  ))
989
1022
  }
990
1023
  ),
991
- J && Z && /* @__PURE__ */ k(
992
- Oo,
1024
+ J && ee && /* @__PURE__ */ k(
1025
+ bo,
993
1026
  {
994
1027
  element: J,
995
1028
  platform: t.platform,
996
- anchor: Z,
1029
+ anchor: ee,
997
1030
  cursorAnchored: X,
998
- showActions: me,
999
- onTap: _
1031
+ showActions: Ee,
1032
+ onTap: O
1000
1033
  }
1001
1034
  )
1002
1035
  ] });
1003
- }), Do = Yn(() => import("./duo-view-C0jN3Y-c.mjs").then((r) => r.d)), x = (...r) => {
1036
+ }), Mo = Ln(() => import("./duo-view-XeO_m-1d.mjs").then((r) => r.d)), F = (...r) => {
1004
1037
  window.debugRemoteControl && console.log(...r);
1005
- }, w = (...r) => {
1038
+ }, A = (...r) => {
1006
1039
  window.debugRemoteControl && console.warn(...r);
1007
- }, L = (r, t, ...c) => {
1040
+ }, U = (r, t, ...c) => {
1008
1041
  if (t)
1009
1042
  try {
1010
1043
  t(...c);
1011
1044
  } catch (a) {
1012
1045
  console.error(`[RemoteControl] customer callback "${r}" threw:`, a);
1013
1046
  }
1014
- }, Kt = (r) => Object.entries(U).find(
1047
+ }, Ut = (r) => Object.entries(L).find(
1015
1048
  ([c, a]) => c.startsWith("ACTION_") && a === r
1016
- )?.[0] ?? String(r), To = (r) => r.includes("/android_") ? "android" : "ios", Ur = (r, t) => {
1049
+ )?.[0] ?? String(r), Ro = (r) => r.includes("/android_") ? "android" : "ios", Fr = (r, t) => {
1017
1050
  const c = new URL(r);
1018
1051
  return c.searchParams.set("token", t), c.toString();
1019
- }, Lr = 1920, xr = 1200, tr = 3, wo = 1e3, Ao = 15e3, bo = 3e3, So = 4e3, Mo = (r, t) => r === Lr && t === xr || r === xr && t === Lr, Ro = {
1052
+ }, Wr = 1920, Hr = 1200, ir = 3, No = 1e3, Io = 15e3, Yo = 3e3, Ko = 4e3, ko = (r, t) => r === Wr && t === Hr || r === Hr && t === Wr, Po = {
1020
1053
  ios: {
1021
1054
  videoBorderRadiusMultiplier: 0.15,
1022
1055
  loadingLogoSize: "20%",
@@ -1036,16 +1069,16 @@ const mo = async (r) => {
1036
1069
  }
1037
1070
  }
1038
1071
  };
1039
- function No(r) {
1040
- const t = r.code, c = Hr[t];
1072
+ function Uo(r) {
1073
+ const t = r.code, c = Br[t];
1041
1074
  if (!c)
1042
- return w(`Unknown event.code: ${t}, key: ${r.key}`), null;
1075
+ return A(`Unknown event.code: ${t}, key: ${r.key}`), null;
1043
1076
  let a = s.META_NONE;
1044
- const m = t >= "KeyA" && t <= "KeyZ", p = r.getModifierState("CapsLock"), C = r.shiftKey;
1045
- let y = C;
1046
- return m && (y = C !== p), y && (a |= s.META_SHIFT_ON), r.ctrlKey && (a |= s.META_CTRL_ON), r.altKey && (a |= s.META_ALT_ON), r.metaKey && (a |= s.META_META_ON), { keycode: c, metaState: a };
1077
+ const m = t >= "KeyA" && t <= "KeyZ", p = r.getModifierState("CapsLock"), g = r.shiftKey;
1078
+ let C = g;
1079
+ return m && (C = g !== p), C && (a |= s.META_SHIFT_ON), r.ctrlKey && (a |= s.META_CTRL_ON), r.altKey && (a |= s.META_ALT_ON), r.metaKey && (a |= s.META_META_ON), { keycode: c, metaState: a };
1047
1080
  }
1048
- const Xo = Kn(
1081
+ const jo = xn(
1049
1082
  ({
1050
1083
  className: r,
1051
1084
  url: t,
@@ -1053,115 +1086,118 @@ const Xo = Kn(
1053
1086
  sessionId: a,
1054
1087
  openUrl: m,
1055
1088
  showFrame: p = !0,
1056
- deviceModel: C,
1057
- duoModelUrl: y,
1058
- autoReconnect: b = !1,
1059
- onTerminated: _,
1089
+ deviceModel: g,
1090
+ duoModelUrl: C,
1091
+ autoReconnect: D = !1,
1092
+ onTerminated: O,
1060
1093
  assets: M,
1061
1094
  onConnectionStateChange: S,
1062
1095
  inspectMode: G,
1063
- onAxSnapshotChange: ie,
1096
+ onAxSnapshotChange: ce,
1064
1097
  onInspectSelectionChange: J,
1065
- onAxStatusChange: de,
1066
- axPollIntervalMs: Z,
1098
+ onAxStatusChange: he,
1099
+ axPollIntervalMs: ee,
1067
1100
  axMaxBackoffMs: X,
1068
- androidElementTreeOptions: me,
1069
- onCameraDemandChange: ce,
1101
+ androidElementTreeOptions: Ee,
1102
+ onCameraDemandChange: se,
1070
1103
  onCameraStats: H,
1071
- microphoneEnabled: Ee = !1,
1072
- onMicrophoneStateChange: mt
1073
- }, Pe) => {
1074
- const ge = O(null), F = O(null), _e = O(/* @__PURE__ */ new Map()), Ut = O(null), [nr, Lt] = V(!1), Ce = C === "iphone-duo" || nr, et = O(null), [or, ir] = V(null), [cr, sr] = V(), Ue = O(
1104
+ onTrace: ge,
1105
+ microphoneEnabled: tt = !1,
1106
+ onMicrophoneStateChange: Te
1107
+ }, Ue) => {
1108
+ const _e = v(null), W = v(null), rt = v(/* @__PURE__ */ new Map()), Ft = v(null), [Wt, Qr] = V(!1), ye = g === "iphone-duo" || Wt, nt = v(null), [sr, ar] = V(null), [ur, lr] = V(), Le = v(
1075
1109
  /* @__PURE__ */ new Map()
1076
- ), xt = (e, i) => new Promise((o, n) => {
1110
+ ), Ht = (e, i) => new Promise((o, n) => {
1077
1111
  const l = T.current;
1078
1112
  if (!l || l.readyState !== WebSocket.OPEN) {
1079
1113
  n(new Error("Simulator disconnected"));
1080
1114
  return;
1081
1115
  }
1082
1116
  const u = crypto.randomUUID(), f = setTimeout(() => {
1083
- Ue.current.delete(u), n(new Error("Device control timed out"));
1117
+ Le.current.delete(u), n(new Error("Device control timed out"));
1084
1118
  }, 5e3);
1085
- Ue.current.set(u, { resolve: o, reject: n, timer: f }), l.send(JSON.stringify({ type: e, id: u, ...i }));
1086
- }), [Jr, Ft] = V(!1), [jr, Et] = V(!1), [zr, ar] = V(!1), Le = O(!1), Wt = O(!1), [ur, Qr] = V(!1), [Zr, en] = V(!1), [tn, lr] = V({}), T = O(null), W = O(null), P = O(null), xe = O(void 0), tt = O(void 0), rt = O(void 0), gt = O(void 0), Fe = O(void 0), we = O(0), Ct = O(0), ye = O(!1), Ht = O(b);
1087
- Ht.current = b;
1088
- const Ae = O(null), re = O(null), be = O(void 0), $t = Ke(() => new ao(), []), ve = O(ce);
1089
- ve.current = ce;
1090
- const yt = O(H);
1091
- yt.current = H;
1092
- const nt = O(null), vt = O(null), Xt = O(Ee);
1093
- Xt.current = Ee;
1094
- const Bt = O(!1), ot = O(mt);
1095
- ot.current = mt;
1096
- const it = O(null), fe = O(null), Ot = O(0), dr = O(Promise.resolve()), We = O(null), ct = O(!1), De = O(/* @__PURE__ */ new Map()), Oe = O(/* @__PURE__ */ new Map()), Se = O(/* @__PURE__ */ new Map()), Me = O(/* @__PURE__ */ new Map()), Q = O(/* @__PURE__ */ new Map()), Re = O(!1), [rn, nn] = V(!1), B = O(null), He = O(null), st = O({
1119
+ Le.current.set(u, { resolve: o, reject: n, timer: f }), l.send(JSON.stringify({ type: e, id: u, ...i }));
1120
+ }), [Zr, $t] = V(!1), [en, yt] = V(!1), [tn, dr] = V(!1), xe = v(!1), Xt = v(!1), [fr, rn] = V(!1), [nn, on] = V(!1), [cn, hr] = V({}), T = v(null), x = v(null), P = v(null), Ct = v(null), Bt = v(ge);
1121
+ Bt.current = ge;
1122
+ const sn = !!ge, Fe = v(void 0), ot = v(void 0), it = v(void 0), vt = v(void 0), We = v(void 0), Ae = v(0), Ot = v(0), Ce = v(!1), qt = v(D);
1123
+ qt.current = D;
1124
+ const be = v(null), ne = v(null), Se = v(void 0), Vt = ke(() => new mo(), []), ve = v(se);
1125
+ ve.current = se;
1126
+ const _t = v(H);
1127
+ _t.current = H;
1128
+ const ct = v(null), wt = v(null), Gt = v(tt);
1129
+ Gt.current = tt;
1130
+ const Jt = v(!1), st = v(Te);
1131
+ st.current = Te;
1132
+ const at = v(null), pe = v(null), Dt = v(0), pr = v(Promise.resolve()), He = v(null), ut = v(!1), we = v(/* @__PURE__ */ new Map()), Oe = v(/* @__PURE__ */ new Map()), Me = v(/* @__PURE__ */ new Map()), Re = v(/* @__PURE__ */ new Map()), Z = v(/* @__PURE__ */ new Map()), Ne = v(!1), [an, un] = V(!1), B = v(null), $e = v(null), lt = v({
1097
1133
  handle: () => {
1098
1134
  },
1099
1135
  end: () => {
1100
1136
  }
1101
- }), [Ne, _t] = V(null), ee = O(null), [fr, hr] = V(null), [qt, at] = V(null), [Vt, Dt] = V(null), [on, pr] = V(null), [cn, mr] = V(null), Tt = O(null), se = O(void 0), Er = (e) => {
1102
- Tt.current = e, se.current === void 0 && (se.current = window.requestAnimationFrame(() => {
1103
- se.current = void 0, mr(Tt.current);
1137
+ }), [Ie, Tt] = V(null), te = v(null), [mr, Er] = V(null), [jt, dt] = V(null), [zt, At] = V(null), [ln, gr] = V(null), [dn, yr] = V(null), bt = v(null), ae = v(void 0), Cr = (e) => {
1138
+ bt.current = e, ae.current === void 0 && (ae.current = window.requestAnimationFrame(() => {
1139
+ ae.current = void 0, yr(bt.current);
1104
1140
  }));
1105
- }, [sn, $e] = V(null), Xe = O(G);
1106
- Xe.current = G;
1107
- const Be = O(null);
1108
- Be.current = fr;
1109
- const Gt = O(ie);
1110
- Gt.current = ie;
1111
- const qe = O(J);
1112
- qe.current = J;
1113
- const gr = O(de);
1114
- gr.current = de;
1115
- const Cr = O(_);
1116
- Cr.current = _;
1117
- const yr = O(S);
1118
- yr.current = S;
1119
- const Jt = O(null), Ve = (e) => {
1120
- Jt.current !== e && (Jt.current = e, L("onConnectionStateChange", yr.current, e));
1121
- }, ut = G === !0 || G === "hover-only", an = G === "hover-only" ? "hover-only" : "select", ue = Ke(
1141
+ }, [fn, Xe] = V(null), Be = v(G);
1142
+ Be.current = G;
1143
+ const qe = v(null);
1144
+ qe.current = mr;
1145
+ const Qt = v(ce);
1146
+ Qt.current = ce;
1147
+ const Ve = v(J);
1148
+ Ve.current = J;
1149
+ const vr = v(he);
1150
+ vr.current = he;
1151
+ const Or = v(O);
1152
+ Or.current = O;
1153
+ const _r = v(S);
1154
+ _r.current = S;
1155
+ const Zt = v(null), Ge = (e) => {
1156
+ Zt.current !== e && (Zt.current = e, U("onConnectionStateChange", _r.current, e));
1157
+ }, ft = G === !0 || G === "hover-only", hn = G === "hover-only" ? "hover-only" : "select", le = ke(
1122
1158
  () => a || Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
1123
1159
  [a]
1124
- ), he = Ke(() => To(t), [t]), Ge = Ro[he], lt = M?.[he], vr = he === "android" && Zr ? ur ? lt?.tabletFrameLandscape : lt?.tabletFrame : ur ? lt?.frameLandscape : lt?.frame, Or = lt?.loadingLogo, wt = !Ce && p && !!vr, K = (e) => {
1125
- x(e);
1126
- }, le = (e) => {
1127
- !P.current || P.current.readyState !== "open" || (P.current.send(e), ee.current?.bumpActivity());
1128
- }, _r = -10, Dr = (e, i) => {
1129
- const o = dt();
1160
+ ), de = ke(() => Ro(t), [t]), Je = Po[de], ht = M?.[de], wr = de === "android" && nn ? fr ? ht?.tabletFrameLandscape : ht?.tabletFrame : fr ? ht?.frameLandscape : ht?.frame, Dr = ht?.loadingLogo, St = !ye && p && !!wr, K = (e) => {
1161
+ F(e);
1162
+ }, fe = (e) => {
1163
+ !P.current || P.current.readyState !== "open" || (P.current.send(Ct.current?.wrap(e) ?? e), te.current?.bumpActivity());
1164
+ }, Tr = -10, Ar = (e, i) => {
1165
+ const o = pt();
1130
1166
  if (!o) return;
1131
- const n = je(o, e, i);
1167
+ const n = ze(o, e, i);
1132
1168
  if (!n) return;
1133
- const { videoX: l, videoY: u, videoWidth: f, videoHeight: E } = n, g = Yt(
1134
- U.ACTION_DOWN,
1135
- _r,
1169
+ const { videoX: l, videoY: u, videoWidth: f, videoHeight: E } = n, y = Pt(
1170
+ L.ACTION_DOWN,
1171
+ Tr,
1136
1172
  f,
1137
1173
  E,
1138
1174
  l,
1139
1175
  u,
1140
1176
  1,
1141
- U.BUTTON_PRIMARY,
1142
- U.BUTTON_PRIMARY
1177
+ L.BUTTON_PRIMARY,
1178
+ L.BUTTON_PRIMARY
1143
1179
  );
1144
- g && le(g), window.setTimeout(() => {
1145
- const h = Yt(
1146
- U.ACTION_UP,
1147
- _r,
1180
+ y && fe(y), window.setTimeout(() => {
1181
+ const h = Pt(
1182
+ L.ACTION_UP,
1183
+ Tr,
1148
1184
  f,
1149
1185
  E,
1150
1186
  l,
1151
1187
  u,
1152
1188
  0,
1153
- U.BUTTON_PRIMARY,
1154
- U.BUTTON_PRIMARY
1189
+ L.BUTTON_PRIMARY,
1190
+ L.BUTTON_PRIMARY
1155
1191
  );
1156
- h && le(h);
1192
+ h && fe(h);
1157
1193
  }, 60);
1158
- }, un = (e, i) => {
1159
- const o = dt();
1194
+ }, pn = (e, i) => {
1195
+ const o = pt();
1160
1196
  if (!o || i.screen.width <= 0 || i.screen.height <= 0) return;
1161
- const n = e.frame.x + e.frame.width / 2, l = e.frame.y + e.frame.height / 2, u = n / i.screen.width * o.actualWidth, f = l / i.screen.height * o.actualHeight, E = o.videoRect.left + o.offsetX + u, g = o.videoRect.top + o.offsetY + f;
1162
- Dr(E, g);
1163
- }, At = -1, bt = -2, Ie = -3, Je = (e, i, o, n, l, u) => {
1164
- const f = Yt(
1197
+ const n = e.frame.x + e.frame.width / 2, l = e.frame.y + e.frame.height / 2, u = n / i.screen.width * o.actualWidth, f = l / i.screen.height * o.actualHeight, E = o.videoRect.left + o.offsetX + u, y = o.videoRect.top + o.offsetY + f;
1198
+ Ar(E, y);
1199
+ }, Mt = -1, Rt = -2, Ye = -3, je = (e, i, o, n, l, u) => {
1200
+ const f = Pt(
1165
1201
  e,
1166
1202
  i,
1167
1203
  o,
@@ -1170,182 +1206,182 @@ const Xo = Kn(
1170
1206
  u,
1171
1207
  1,
1172
1208
  // pressure
1173
- U.BUTTON_PRIMARY,
1174
- U.BUTTON_PRIMARY
1209
+ L.BUTTON_PRIMARY,
1210
+ L.BUTTON_PRIMARY
1175
1211
  );
1176
- f && (x("[rc-touch] sendSingleTouch", {
1212
+ f && (F("[rc-touch] sendSingleTouch", {
1177
1213
  action: e,
1178
- actionName: Kt(e),
1214
+ actionName: Ut(e),
1179
1215
  pointerId: i,
1180
1216
  x: l,
1181
1217
  y: u,
1182
1218
  video: { width: o, height: n }
1183
- }), le(f));
1184
- }, Ye = (e, i, o) => {
1219
+ }), fe(f));
1220
+ }, Ke = (e, i, o) => {
1185
1221
  if (!o) return;
1186
1222
  const { videoX: n, videoY: l, videoWidth: u, videoHeight: f } = o;
1187
- let E = null, g = null, h = 1;
1188
- const R = U.BUTTON_PRIMARY;
1223
+ let E = null, y = null, h = 1;
1224
+ const R = L.BUTTON_PRIMARY;
1189
1225
  switch (i) {
1190
1226
  case "down":
1191
- e !== Ie && st.current.end(), E = Q.current.size === 0 ? U.ACTION_DOWN : U.ACTION_POINTER_DOWN, g = { x: n, y: l }, Q.current.set(e, g), e === -1 && F.current?.focus();
1227
+ e !== Ye && lt.current.end(), E = Z.current.size === 0 ? L.ACTION_DOWN : L.ACTION_POINTER_DOWN, y = { x: n, y: l }, Z.current.set(e, y), e === -1 && W.current?.focus();
1192
1228
  break;
1193
1229
  case "move":
1194
- Q.current.has(e) && (E = U.ACTION_MOVE, g = { x: n, y: l }, Q.current.set(e, g));
1230
+ Z.current.has(e) && (E = L.ACTION_MOVE, y = { x: n, y: l }, Z.current.set(e, y));
1195
1231
  break;
1196
1232
  case "up":
1197
1233
  case "cancel":
1198
- Q.current.has(e) && (g = Q.current.get(e), Q.current.delete(e), i === "cancel" ? E = U.ACTION_CANCEL : E = Q.current.size === 0 ? U.ACTION_UP : U.ACTION_POINTER_UP);
1234
+ Z.current.has(e) && (y = Z.current.get(e), Z.current.delete(e), i === "cancel" ? E = L.ACTION_CANCEL : E = Z.current.size === 0 ? L.ACTION_UP : L.ACTION_POINTER_UP);
1199
1235
  break;
1200
1236
  }
1201
- if (E !== null && g !== null) {
1202
- x("[rc-touch][mouse->touch] sending", {
1237
+ if (E !== null && y !== null) {
1238
+ F("[rc-touch][mouse->touch] sending", {
1203
1239
  pointerId: e,
1204
1240
  eventType: i,
1205
1241
  action: E,
1206
- actionName: Kt(E),
1207
- positionToSend: g,
1242
+ actionName: Ut(E),
1243
+ positionToSend: y,
1208
1244
  video: { width: u, height: f },
1209
- altHeld: Re.current,
1210
- activePointersAfter: Array.from(Q.current.entries()).map(([N, $]) => ({
1245
+ altHeld: Ne.current,
1246
+ activePointersAfter: Array.from(Z.current.entries()).map(([N, $]) => ({
1211
1247
  id: N,
1212
1248
  x: $.x,
1213
1249
  y: $.y
1214
1250
  }))
1215
1251
  });
1216
- const D = Yt(
1252
+ const _ = Pt(
1217
1253
  E,
1218
1254
  e,
1219
1255
  u,
1220
1256
  f,
1221
- g.x,
1222
- g.y,
1257
+ y.x,
1258
+ y.y,
1223
1259
  h,
1224
1260
  R,
1225
1261
  R
1226
1262
  );
1227
- D && (x("[rc-touch][mouse->touch] buffer", {
1263
+ _ && (F("[rc-touch][mouse->touch] buffer", {
1228
1264
  pointerId: e,
1229
- actionName: Kt(E),
1230
- byteLength: D.byteLength
1231
- }), le(D));
1232
- } else (i === "up" || i === "cancel") && Q.current.delete(e);
1233
- }, jt = (e) => {
1234
- if (Re.current !== e && (Re.current = e, nn(e), e || _t(null), x("[rc-touch][alt] updateAltHeld", {
1265
+ actionName: Ut(E),
1266
+ byteLength: _.byteLength
1267
+ }), fe(_));
1268
+ } else (i === "up" || i === "cancel") && Z.current.delete(e);
1269
+ }, er = (e) => {
1270
+ if (Ne.current !== e && (Ne.current = e, un(e), e || Tt(null), F("[rc-touch][alt] updateAltHeld", {
1235
1271
  nextHeld: e,
1236
- activePointerIds: Array.from(Q.current.keys())
1237
- }), he === "ios" && P.current && P.current.readyState === "open")) {
1238
- const i = e ? s.ACTION_DOWN : s.ACTION_UP, o = pt(
1272
+ activePointerIds: Array.from(Z.current.keys())
1273
+ }), de === "ios" && P.current && P.current.readyState === "open")) {
1274
+ const i = e ? s.ACTION_DOWN : s.ACTION_UP, o = gt(
1239
1275
  i,
1240
1276
  s.KEYCODE_ALT_LEFT,
1241
1277
  0,
1242
1278
  s.META_NONE
1243
1279
  );
1244
- x("[rc-touch][alt] sending Indigo modifier keycode", {
1280
+ F("[rc-touch][alt] sending Indigo modifier keycode", {
1245
1281
  action: i,
1246
1282
  keycode: s.KEYCODE_ALT_LEFT
1247
- }), o && le(o);
1283
+ }), o && fe(o);
1248
1284
  }
1249
- }, dt = () => {
1250
- const e = F.current, i = ge.current;
1285
+ }, pt = () => {
1286
+ const e = W.current, i = _e.current;
1251
1287
  if (!e || !i) return null;
1252
1288
  const o = e.videoWidth, n = e.videoHeight;
1253
1289
  if (!o || !n) return null;
1254
- const l = e.getBoundingClientRect(), u = i.getBoundingClientRect(), f = l.width, E = l.height, g = o / n, h = f / E;
1255
- let R = f, D = E;
1256
- g > h ? D = f / g : R = E * g;
1257
- const N = (f - R) / 2, $ = (E - D) / 2;
1290
+ const l = e.getBoundingClientRect(), u = i.getBoundingClientRect(), f = l.width, E = l.height, y = o / n, h = f / E;
1291
+ let R = f, _ = E;
1292
+ y > h ? _ = f / y : R = E * y;
1293
+ const N = (f - R) / 2, $ = (E - _) / 2;
1258
1294
  return {
1259
1295
  videoWidth: o,
1260
1296
  videoHeight: n,
1261
1297
  videoRect: l,
1262
1298
  containerRect: u,
1263
1299
  actualWidth: R,
1264
- actualHeight: D,
1300
+ actualHeight: _,
1265
1301
  offsetX: N,
1266
1302
  offsetY: $
1267
1303
  };
1268
- }, je = (e, i, o) => {
1304
+ }, ze = (e, i, o) => {
1269
1305
  const n = i - e.videoRect.left - e.offsetX, l = o - e.videoRect.top - e.offsetY, u = Math.max(0, Math.min(e.actualWidth, n)), f = Math.max(0, Math.min(e.actualHeight, l)), E = Math.max(
1270
1306
  0,
1271
1307
  Math.min(e.videoWidth, u / e.actualWidth * e.videoWidth)
1272
- ), g = Math.max(
1308
+ ), y = Math.max(
1273
1309
  0,
1274
1310
  Math.min(e.videoHeight, f / e.actualHeight * e.videoHeight)
1275
1311
  );
1276
1312
  return {
1277
1313
  videoX: E,
1278
- videoY: g,
1314
+ videoY: y,
1279
1315
  videoWidth: e.videoWidth,
1280
1316
  videoHeight: e.videoHeight
1281
1317
  };
1282
- }, ln = (e, i, o) => {
1318
+ }, mn = (e, i, o) => {
1283
1319
  const n = i - e.videoRect.left - e.offsetX, l = o - e.videoRect.top - e.offsetY, u = Math.max(0, Math.min(e.actualWidth, n)), f = Math.max(0, Math.min(e.actualHeight, l)), E = Math.max(
1284
1320
  0,
1285
1321
  Math.min(e.videoWidth, u / e.actualWidth * e.videoWidth)
1286
- ), g = Math.max(
1322
+ ), y = Math.max(
1287
1323
  0,
1288
1324
  Math.min(e.videoHeight, f / e.actualHeight * e.videoHeight)
1289
- ), h = e.videoWidth - E, R = e.videoHeight - g, D = e.videoRect.left + e.offsetX, N = e.videoRect.top + e.offsetY, $ = D - e.containerRect.left + u, ne = N - e.containerRect.top + f, j = D - e.containerRect.left + (e.actualWidth - u), v = N - e.containerRect.top + (e.actualHeight - f);
1325
+ ), h = e.videoWidth - E, R = e.videoHeight - y, _ = e.videoRect.left + e.offsetX, N = e.videoRect.top + e.offsetY, $ = _ - e.containerRect.left + u, oe = N - e.containerRect.top + f, j = _ - e.containerRect.left + (e.actualWidth - u), z = N - e.containerRect.top + (e.actualHeight - f);
1290
1326
  return {
1291
1327
  containerX: $,
1292
- containerY: ne,
1328
+ containerY: oe,
1293
1329
  mirrorContainerX: j,
1294
- mirrorContainerY: v,
1330
+ mirrorContainerY: z,
1295
1331
  videoX: E,
1296
- videoY: g,
1332
+ videoY: y,
1297
1333
  mirrorVideoX: h,
1298
1334
  mirrorVideoY: R,
1299
1335
  videoWidth: e.videoWidth,
1300
1336
  videoHeight: e.videoHeight
1301
1337
  };
1302
- }, dn = (e, i, o, n, l, u, f) => {
1303
- const E = Hn(e, i, o, n, l, u, f);
1304
- x("[rc-touch2] sendTwoFingerMessage (iOS)", {
1305
- actionName: Kt(e),
1338
+ }, En = (e, i, o, n, l, u, f) => {
1339
+ const E = Gn(e, i, o, n, l, u, f);
1340
+ F("[rc-touch2] sendTwoFingerMessage (iOS)", {
1341
+ actionName: Ut(e),
1306
1342
  video: { width: i, height: o },
1307
1343
  p0: { x: n, y: l },
1308
1344
  p1: { x: u, y: f },
1309
1345
  byteLength: E.byteLength
1310
- }), le(E);
1311
- }, ze = (e, i, o, n, l, u, f, E, g) => {
1312
- if (x("[rc-touch2] applyTwoFingerEvent", {
1313
- platform: he,
1346
+ }), fe(E);
1347
+ }, Qe = (e, i, o, n, l, u, f, E, y) => {
1348
+ if (F("[rc-touch2] applyTwoFingerEvent", {
1349
+ platform: de,
1314
1350
  eventType: e,
1315
1351
  video: { width: i, height: o },
1316
1352
  p0: { x: n, y: l, id: E },
1317
- p1: { x: u, y: f, id: g }
1318
- }), e === "down" && st.current.end(), he === "ios") {
1319
- const h = e === "down" ? U.ACTION_DOWN : e === "move" ? U.ACTION_MOVE : U.ACTION_UP;
1320
- dn(h, i, o, n, l, u, f);
1353
+ p1: { x: u, y: f, id: y }
1354
+ }), e === "down" && lt.current.end(), de === "ios") {
1355
+ const h = e === "down" ? L.ACTION_DOWN : e === "move" ? L.ACTION_MOVE : L.ACTION_UP;
1356
+ En(h, i, o, n, l, u, f);
1321
1357
  } else
1322
- e === "down" ? (Je(U.ACTION_DOWN, E, i, o, n, l), Je(U.ACTION_POINTER_DOWN, g, i, o, u, f)) : e === "move" ? (Je(U.ACTION_MOVE, E, i, o, n, l), Je(U.ACTION_MOVE, g, i, o, u, f)) : (Je(U.ACTION_POINTER_UP, g, i, o, u, f), Je(U.ACTION_UP, E, i, o, n, l));
1323
- }, fn = (e, i, o) => {
1324
- if (!Re.current) {
1325
- Ne !== null && _t(null);
1358
+ e === "down" ? (je(L.ACTION_DOWN, E, i, o, n, l), je(L.ACTION_POINTER_DOWN, y, i, o, u, f)) : e === "move" ? (je(L.ACTION_MOVE, E, i, o, n, l), je(L.ACTION_MOVE, y, i, o, u, f)) : (je(L.ACTION_POINTER_UP, y, i, o, u, f), je(L.ACTION_UP, E, i, o, n, l));
1359
+ }, gn = (e, i, o) => {
1360
+ if (!Ne.current) {
1361
+ Ie !== null && Tt(null);
1326
1362
  return;
1327
1363
  }
1328
- const n = ln(e, i, o);
1329
- _t(n);
1330
- }, hn = (e, i, o) => {
1331
- const n = Be.current;
1364
+ const n = mn(e, i, o);
1365
+ Tt(n);
1366
+ }, yn = (e, i, o) => {
1367
+ const n = qe.current;
1332
1368
  if (!n || n.screen.width <= 0 || n.screen.height <= 0) return null;
1333
1369
  const l = i - e.videoRect.left - e.offsetX, u = o - e.videoRect.top - e.offsetY;
1334
1370
  if (l < 0 || u < 0 || l > e.actualWidth || u > e.actualHeight) return null;
1335
1371
  const f = l / e.actualWidth * n.screen.width, E = u / e.actualHeight * n.screen.height;
1336
- return Zn(n, f, E);
1337
- }, Te = (e) => {
1338
- if (Ce) return;
1372
+ return io(n, f, E);
1373
+ }, De = (e) => {
1374
+ if (ye) return;
1339
1375
  e.preventDefault(), e.stopPropagation();
1340
- const i = dt();
1341
- if ((Xe.current === !0 || Xe.current === "hover-only") && !("touches" in e))
1376
+ const i = pt();
1377
+ if ((Be.current === !0 || Be.current === "hover-only") && !("touches" in e))
1342
1378
  if (e.type === "mousemove") {
1343
- if (Er({ x: e.clientX, y: e.clientY }), i) {
1344
- const n = hn(i, e.clientX, e.clientY);
1345
- at(n?.id ?? null);
1379
+ if (Cr({ x: e.clientX, y: e.clientY }), i) {
1380
+ const n = yn(i, e.clientX, e.clientY);
1381
+ dt(n?.id ?? null);
1346
1382
  }
1347
- } else e.type === "mouseleave" && (Er(null), at(null));
1348
- if (Xe.current !== !0 && (!("touches" in e) && i && (e.type === "mousemove" ? fn(i, e.clientX, e.clientY) : e.type === "mouseleave" && _t(null)), !(!P.current || P.current.readyState !== "open" || !F.current || !i)))
1383
+ } else e.type === "mouseleave" && (Cr(null), dt(null));
1384
+ if (Be.current !== !0 && (!("touches" in e) && i && (e.type === "mousemove" ? gn(i, e.clientX, e.clientY) : e.type === "mouseleave" && Tt(null)), !(!P.current || P.current.readyState !== "open" || !W.current || !i)))
1349
1385
  if ("touches" in e) {
1350
1386
  const n = e.touches, l = e.changedTouches;
1351
1387
  let u;
@@ -1366,31 +1402,31 @@ const Xo = Kn(
1366
1402
  return;
1367
1403
  }
1368
1404
  if (n.length === 2) {
1369
- const f = n[0], E = n[1], g = je(i, f.clientX, f.clientY), h = je(i, E.clientX, E.clientY);
1370
- if (!g || !h) return;
1371
- B.current ? B.current.source === "real-touch" && (B.current.finger0 = { x: g.videoX, y: g.videoY }, B.current.finger1 = { x: h.videoX, y: h.videoY }, ze(
1405
+ const f = n[0], E = n[1], y = ze(i, f.clientX, f.clientY), h = ze(i, E.clientX, E.clientY);
1406
+ if (!y || !h) return;
1407
+ B.current ? B.current.source === "real-touch" && (B.current.finger0 = { x: y.videoX, y: y.videoY }, B.current.finger1 = { x: h.videoX, y: h.videoY }, Qe(
1372
1408
  "move",
1373
- g.videoWidth,
1374
- g.videoHeight,
1375
- g.videoX,
1376
- g.videoY,
1409
+ y.videoWidth,
1410
+ y.videoHeight,
1411
+ y.videoX,
1412
+ y.videoY,
1377
1413
  h.videoX,
1378
1414
  h.videoY,
1379
1415
  B.current.pointerId0,
1380
1416
  B.current.pointerId1
1381
1417
  )) : (B.current = {
1382
- finger0: { x: g.videoX, y: g.videoY },
1418
+ finger0: { x: y.videoX, y: y.videoY },
1383
1419
  finger1: { x: h.videoX, y: h.videoY },
1384
- videoSize: { width: g.videoWidth, height: g.videoHeight },
1420
+ videoSize: { width: y.videoWidth, height: y.videoHeight },
1385
1421
  source: "real-touch",
1386
1422
  pointerId0: f.identifier,
1387
1423
  pointerId1: E.identifier
1388
- }, ze(
1424
+ }, Qe(
1389
1425
  "down",
1390
- g.videoWidth,
1391
- g.videoHeight,
1392
- g.videoX,
1393
- g.videoY,
1426
+ y.videoWidth,
1427
+ y.videoHeight,
1428
+ y.videoX,
1429
+ y.videoY,
1394
1430
  h.videoX,
1395
1431
  h.videoY,
1396
1432
  f.identifier,
@@ -1398,7 +1434,7 @@ const Xo = Kn(
1398
1434
  ));
1399
1435
  } else if (n.length < 2 && B.current?.source === "real-touch") {
1400
1436
  const f = B.current;
1401
- ze(
1437
+ Qe(
1402
1438
  "up",
1403
1439
  f.videoSize.width,
1404
1440
  f.videoSize.height,
@@ -1416,8 +1452,8 @@ const Xo = Kn(
1416
1452
  {
1417
1453
  const f = l[0];
1418
1454
  if (f) {
1419
- const E = je(i, f.clientX, f.clientY);
1420
- Ye(f.identifier, u, E);
1455
+ const E = ze(i, f.clientX, f.clientY);
1456
+ Ke(f.identifier, u, E);
1421
1457
  }
1422
1458
  }
1423
1459
  }
@@ -1429,26 +1465,26 @@ const Xo = Kn(
1429
1465
  e.button === 0 && (l = "down");
1430
1466
  break;
1431
1467
  case "mousemove":
1432
- (u || Q.current.has(-1)) && (l = "move");
1468
+ (u || Z.current.has(-1)) && (l = "move");
1433
1469
  break;
1434
1470
  case "mouseup":
1435
1471
  e.button === 0 && (l = "up");
1436
1472
  break;
1437
1473
  case "mouseleave":
1438
- (u || Q.current.has(-1)) && (l = "up");
1474
+ (u || Z.current.has(-1)) && (l = "up");
1439
1475
  break;
1440
1476
  }
1441
1477
  if (l) {
1442
- const f = je(i, e.clientX, e.clientY);
1478
+ const f = ze(i, e.clientX, e.clientY);
1443
1479
  if (!f)
1444
1480
  return;
1445
- x("[rc-touch][mouse] event", {
1481
+ F("[rc-touch][mouse] event", {
1446
1482
  domType: e.type,
1447
1483
  eventType: l,
1448
1484
  button: e.button,
1449
1485
  buttons: e.buttons,
1450
1486
  client: { x: e.clientX, y: e.clientY },
1451
- altHeldRef: Re.current,
1487
+ altHeldRef: Ne.current,
1452
1488
  inTwoFingerMode: u,
1453
1489
  geometry: {
1454
1490
  videoX: f.videoX,
@@ -1456,11 +1492,11 @@ const Xo = Kn(
1456
1492
  videoWidth: f.videoWidth,
1457
1493
  videoHeight: f.videoHeight
1458
1494
  },
1459
- activePointerIds: Array.from(Q.current.keys())
1460
- }), Re.current || u ? pn(l, f) : Ye(-1, l, f);
1495
+ activePointerIds: Array.from(Z.current.keys())
1496
+ }), Ne.current || u ? Cn(l, f) : Ke(-1, l, f);
1461
1497
  }
1462
1498
  }
1463
- }, pn = (e, i) => {
1499
+ }, Cn = (e, i) => {
1464
1500
  const { videoX: o, videoY: n, videoWidth: l, videoHeight: u } = i, f = l - o, E = u - n;
1465
1501
  if (e === "down") {
1466
1502
  B.current = {
@@ -1468,9 +1504,9 @@ const Xo = Kn(
1468
1504
  finger1: { x: f, y: E },
1469
1505
  videoSize: { width: l, height: u },
1470
1506
  source: "alt-mouse",
1471
- pointerId0: At,
1472
- pointerId1: bt
1473
- }, F.current?.focus(), ze(
1507
+ pointerId0: Mt,
1508
+ pointerId1: Rt
1509
+ }, W.current?.focus(), Qe(
1474
1510
  "down",
1475
1511
  l,
1476
1512
  u,
@@ -1478,13 +1514,13 @@ const Xo = Kn(
1478
1514
  n,
1479
1515
  f,
1480
1516
  E,
1481
- At,
1482
- bt
1517
+ Mt,
1518
+ Rt
1483
1519
  );
1484
1520
  return;
1485
1521
  }
1486
1522
  if (e === "move") {
1487
- B.current?.source === "alt-mouse" && (B.current.finger0 = { x: o, y: n }, B.current.finger1 = { x: f, y: E }, ze(
1523
+ B.current?.source === "alt-mouse" && (B.current.finger0 = { x: o, y: n }, B.current.finger1 = { x: f, y: E }, Qe(
1488
1524
  "move",
1489
1525
  l,
1490
1526
  u,
@@ -1492,96 +1528,96 @@ const Xo = Kn(
1492
1528
  n,
1493
1529
  f,
1494
1530
  E,
1495
- At,
1496
- bt
1531
+ Mt,
1532
+ Rt
1497
1533
  ));
1498
1534
  return;
1499
1535
  }
1500
1536
  if (e === "up" || e === "cancel") {
1501
- const g = B.current;
1502
- if (g?.source === "alt-mouse") {
1503
- const { finger0: h, finger1: R, videoSize: D } = g;
1504
- ze(
1537
+ const y = B.current;
1538
+ if (y?.source === "alt-mouse") {
1539
+ const { finger0: h, finger1: R, videoSize: _ } = y;
1540
+ Qe(
1505
1541
  "up",
1506
- D.width,
1507
- D.height,
1542
+ _.width,
1543
+ _.height,
1508
1544
  h.x,
1509
1545
  h.y,
1510
1546
  R.x,
1511
1547
  R.y,
1512
- At,
1513
- bt
1548
+ Mt,
1549
+ Rt
1514
1550
  ), B.current = null;
1515
1551
  }
1516
1552
  return;
1517
1553
  }
1518
- }, mn = 150, Tr = () => {
1519
- const e = He.current;
1520
- e && (window.clearTimeout(e.endTimer), Ye(Ie, "up", e.pos), He.current = null);
1521
- }, En = (e) => {
1522
- if (e.ctrlKey || Re.current || B.current) return;
1523
- const i = Q.current.size;
1524
- if (i > 1 || i === 1 && !Q.current.has(Ie)) return;
1525
- const o = dt();
1554
+ }, vn = 150, br = () => {
1555
+ const e = $e.current;
1556
+ e && (window.clearTimeout(e.endTimer), Ke(Ye, "up", e.pos), $e.current = null);
1557
+ }, On = (e) => {
1558
+ if (e.ctrlKey || Ne.current || B.current) return;
1559
+ const i = Z.current.size;
1560
+ if (i > 1 || i === 1 && !Z.current.has(Ye)) return;
1561
+ const o = pt();
1526
1562
  if (!o) return;
1527
1563
  const n = e.clientX - o.videoRect.left - o.offsetX, l = e.clientY - o.videoRect.top - o.offsetY;
1528
1564
  if (n < 0 || n > o.actualWidth || l < 0 || l > o.actualHeight)
1529
1565
  return;
1530
- const u = je(o, e.clientX, e.clientY);
1566
+ const u = ze(o, e.clientX, e.clientY);
1531
1567
  if (!u) return;
1532
1568
  e.preventDefault();
1533
- const f = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), E = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), g = -e.deltaX * f, h = -e.deltaY * E, R = (v) => {
1534
- window.clearTimeout(v.endTimer), v.endTimer = window.setTimeout(Tr, mn);
1569
+ const f = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), E = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), y = -e.deltaX * f, h = -e.deltaY * E, R = (z) => {
1570
+ window.clearTimeout(z.endTimer), z.endTimer = window.setTimeout(br, vn);
1535
1571
  };
1536
- if (g === 0 && h === 0) {
1537
- He.current && R(He.current);
1572
+ if (y === 0 && h === 0) {
1573
+ $e.current && R($e.current);
1538
1574
  return;
1539
1575
  }
1540
- const D = () => ({
1576
+ const _ = () => ({
1541
1577
  videoWidth: u.videoWidth,
1542
1578
  videoHeight: u.videoHeight,
1543
- videoX: Math.abs(g) > Math.abs(h) ? Math.min(Math.max(u.videoX, u.videoWidth * 0.2), u.videoWidth * 0.8) : u.videoX,
1544
- videoY: Math.abs(h) >= Math.abs(g) ? Math.min(Math.max(u.videoY, u.videoHeight * 0.2), u.videoHeight * 0.8) : u.videoY
1545
- }), N = (v) => ({
1546
- ...v,
1547
- videoX: Math.min(Math.max(v.videoX + g, 0), v.videoWidth),
1548
- videoY: Math.min(Math.max(v.videoY + h, 0), v.videoHeight)
1579
+ videoX: Math.abs(y) > Math.abs(h) ? Math.min(Math.max(u.videoX, u.videoWidth * 0.2), u.videoWidth * 0.8) : u.videoX,
1580
+ videoY: Math.abs(h) >= Math.abs(y) ? Math.min(Math.max(u.videoY, u.videoHeight * 0.2), u.videoHeight * 0.8) : u.videoY
1581
+ }), N = (z) => ({
1582
+ ...z,
1583
+ videoX: Math.min(Math.max(z.videoX + y, 0), z.videoWidth),
1584
+ videoY: Math.min(Math.max(z.videoY + h, 0), z.videoHeight)
1549
1585
  });
1550
- let $ = He.current;
1586
+ let $ = $e.current;
1551
1587
  if ($)
1552
1588
  window.clearTimeout($.endTimer);
1553
1589
  else {
1554
- const v = D();
1555
- Ye(Ie, "down", v), $ = { pos: v, endTimer: 0 }, He.current = $;
1590
+ const z = _();
1591
+ Ke(Ye, "down", z), $ = { pos: z, endTimer: 0 }, $e.current = $;
1556
1592
  }
1557
- let ne = $.pos, j = N(ne);
1558
- j.videoX === ne.videoX && j.videoY === ne.videoY && (Ye(Ie, "up", ne), ne = D(), Ye(Ie, "down", ne), j = N(ne)), Ye(Ie, "move", j), $.pos = j, R($);
1593
+ let oe = $.pos, j = N(oe);
1594
+ j.videoX === oe.videoX && j.videoY === oe.videoY && (Ke(Ye, "up", oe), oe = _(), Ke(Ye, "down", oe), j = N(oe)), Ke(Ye, "move", j), $.pos = j, R($);
1559
1595
  };
1560
- pe(() => {
1561
- st.current = { handle: En, end: Tr };
1562
- }), pe(() => {
1563
- const e = ge.current;
1596
+ me(() => {
1597
+ lt.current = { handle: On, end: br };
1598
+ }), me(() => {
1599
+ const e = _e.current;
1564
1600
  if (!e) return;
1565
- const i = (o) => st.current.handle(o);
1601
+ const i = (o) => lt.current.handle(o);
1566
1602
  return e.addEventListener("wheel", i, { passive: !1 }), () => {
1567
- st.current.end(), e.removeEventListener("wheel", i);
1603
+ lt.current.end(), e.removeEventListener("wheel", i);
1568
1604
  };
1569
- }, []), pe(() => {
1605
+ }, []), me(() => {
1570
1606
  const e = (n) => {
1571
- n.key === "Alt" && jt(!0);
1607
+ n.key === "Alt" && er(!0);
1572
1608
  }, i = (n) => {
1573
- n.key === "Alt" && jt(!1);
1609
+ n.key === "Alt" && er(!1);
1574
1610
  }, o = () => {
1575
- jt(!1);
1611
+ er(!1);
1576
1612
  };
1577
1613
  return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", i, !0), window.addEventListener("blur", o), () => {
1578
1614
  window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", i, !0), window.removeEventListener("blur", o);
1579
1615
  };
1580
1616
  }, []);
1581
- const St = (e) => {
1617
+ const Nt = (e) => {
1582
1618
  e.preventDefault(), e.stopPropagation();
1583
- const i = document.activeElement === F.current || Ce && document.activeElement === e.currentTarget;
1584
- if (x("Keyboard event:", {
1619
+ const i = document.activeElement === W.current || ye && document.activeElement === e.currentTarget;
1620
+ if (F("Keyboard event:", {
1585
1621
  type: e.type,
1586
1622
  key: e.key,
1587
1623
  keyCode: e.keyCode,
@@ -1589,23 +1625,23 @@ const Xo = Kn(
1589
1625
  target: e.target.tagName,
1590
1626
  focused: i
1591
1627
  }), !i) {
1592
- w("Simulator input not focused, skipping keyboard event");
1628
+ A("Simulator input not focused, skipping keyboard event");
1593
1629
  return;
1594
1630
  }
1595
1631
  if (!P.current || P.current.readyState !== "open") {
1596
- w("Data channel not ready for keyboard event:", P.current?.readyState);
1632
+ A("Data channel not ready for keyboard event:", P.current?.readyState);
1597
1633
  return;
1598
1634
  }
1599
1635
  if (e.type === "keydown") {
1600
1636
  if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
1601
- x("Paste shortcut detected"), navigator.clipboard.readText().then((n) => {
1637
+ F("Paste shortcut detected"), navigator.clipboard.readText().then((n) => {
1602
1638
  if (n) {
1603
- x(
1639
+ F(
1604
1640
  "Pasting text via SET_CLIPBOARD:",
1605
1641
  n.substring(0, 20) + (n.length > 20 ? "..." : "")
1606
1642
  );
1607
- const l = $n(n, !0);
1608
- le(l);
1643
+ const l = Jn(n, !0);
1644
+ fe(l);
1609
1645
  }
1610
1646
  }).catch((n) => {
1611
1647
  console.error("Failed to read clipboard contents: ", n);
@@ -1613,88 +1649,88 @@ const Xo = Kn(
1613
1649
  return;
1614
1650
  }
1615
1651
  if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
1616
- x("Menu shortcut detected");
1617
- const n = pt(
1652
+ F("Menu shortcut detected");
1653
+ const n = gt(
1618
1654
  s.ACTION_DOWN,
1619
1655
  s.MENU,
1620
1656
  0,
1621
1657
  s.META_NONE
1622
1658
  // Modifiers are handled by the shortcut check, not passed down
1623
1659
  );
1624
- le(n);
1625
- const l = pt(
1660
+ fe(n);
1661
+ const l = gt(
1626
1662
  s.ACTION_UP,
1627
1663
  s.MENU,
1628
1664
  0,
1629
1665
  s.META_NONE
1630
1666
  );
1631
- le(l);
1667
+ fe(l);
1632
1668
  return;
1633
1669
  }
1634
1670
  }
1635
- const o = No(e);
1671
+ const o = Uo(e);
1636
1672
  if (o) {
1637
1673
  const { keycode: n, metaState: l } = o, u = e.type === "keydown" ? s.ACTION_DOWN : s.ACTION_UP;
1638
- x(`Sending Keycode: key=${e.key}, code=${n}, action=${u}, meta=${l}`);
1639
- const f = pt(
1674
+ F(`Sending Keycode: key=${e.key}, code=${n}, action=${u}, meta=${l}`);
1675
+ const f = gt(
1640
1676
  u,
1641
1677
  n,
1642
1678
  0,
1643
1679
  // repeat count, typically 0 for single presses
1644
1680
  l
1645
1681
  );
1646
- le(f);
1682
+ fe(f);
1647
1683
  } else
1648
- x(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
1649
- }, gn = () => {
1684
+ F(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
1685
+ }, _n = () => {
1650
1686
  T.current && T.current.readyState === WebSocket.OPEN && T.current.send(
1651
1687
  JSON.stringify({
1652
1688
  type: "keepAlive",
1653
- sessionId: ue
1689
+ sessionId: le
1654
1690
  })
1655
1691
  );
1656
- }, wr = () => {
1657
- xe.current && window.clearInterval(xe.current), xe.current = window.setInterval(gn, 1e4);
1658
- }, Ar = () => {
1659
- xe.current && (window.clearInterval(xe.current), xe.current = void 0);
1660
- }, Mt = () => {
1661
- tt.current && (window.clearTimeout(tt.current), tt.current = void 0);
1662
- }, Rt = () => {
1663
- rt.current && (window.clearTimeout(rt.current), rt.current = void 0);
1664
- }, ft = () => {
1665
- gt.current && (window.clearInterval(gt.current), gt.current = void 0);
1666
- }, ht = () => {
1667
- Fe.current !== void 0 && (window.clearTimeout(Fe.current), Fe.current = void 0);
1668
- }, Cn = () => {
1669
- ct.current || (ct.current = !0, ft(), Ft(!0), Ve("connected"));
1670
- }, te = (e) => {
1692
+ }, Sr = () => {
1693
+ Fe.current && window.clearInterval(Fe.current), Fe.current = window.setInterval(_n, 1e4);
1694
+ }, Mr = () => {
1695
+ Fe.current && (window.clearInterval(Fe.current), Fe.current = void 0);
1696
+ }, It = () => {
1697
+ ot.current && (window.clearTimeout(ot.current), ot.current = void 0);
1698
+ }, Yt = () => {
1699
+ it.current && (window.clearTimeout(it.current), it.current = void 0);
1700
+ }, mt = () => {
1701
+ vt.current && (window.clearInterval(vt.current), vt.current = void 0);
1702
+ }, Et = () => {
1703
+ We.current !== void 0 && (window.clearTimeout(We.current), We.current = void 0);
1704
+ }, wn = () => {
1705
+ ut.current || (ut.current = !0, mt(), $t(!0), Ge("connected"));
1706
+ }, re = (e) => {
1671
1707
  for (const i of e.getTracks())
1672
1708
  try {
1673
1709
  i.stop();
1674
1710
  } catch (o) {
1675
- w("track.stop() failed:", o);
1711
+ A("track.stop() failed:", o);
1676
1712
  }
1677
- }, yn = () => {
1678
- const e = re.current;
1679
- e && (re.current = null, te(e));
1680
- }, br = (e) => {
1681
- const i = dr.current.then(e).catch((o) => {
1682
- w("microphone operation failed:", o);
1713
+ }, Dn = () => {
1714
+ const e = ne.current;
1715
+ e && (ne.current = null, re(e));
1716
+ }, Rr = (e) => {
1717
+ const i = pr.current.then(e).catch((o) => {
1718
+ A("microphone operation failed:", o);
1683
1719
  });
1684
- return dr.current = i, i;
1685
- }, zt = () => Xt.current || Bt.current, Sr = (e) => {
1720
+ return pr.current = i, i;
1721
+ }, tr = () => Gt.current || Jt.current, Nr = (e) => {
1686
1722
  const i = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1687
- We.current = i, e.send(JSON.stringify({ type: "microphoneStart", id: i }));
1688
- }, Qt = () => br(() => vn()), vn = async () => {
1689
- const e = Ot.current, i = () => e === Ot.current && zt(), o = (E) => {
1690
- L("onMicrophoneStateChange", ot.current, {
1723
+ He.current = i, e.send(JSON.stringify({ type: "microphoneStart", id: i }));
1724
+ }, rr = () => Rr(() => Tn()), Tn = async () => {
1725
+ const e = Dt.current, i = () => e === Dt.current && tr(), o = (E) => {
1726
+ U("onMicrophoneStateChange", st.current, {
1691
1727
  active: !1,
1692
1728
  error: E
1693
1729
  });
1694
1730
  };
1695
1731
  if (!i()) return;
1696
- const n = T.current, l = it.current;
1697
- if (!n || n.readyState !== WebSocket.OPEN || !l || fe.current) return;
1732
+ const n = T.current, l = at.current;
1733
+ if (!n || n.readyState !== WebSocket.OPEN || !l || pe.current) return;
1698
1734
  if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
1699
1735
  console.warn(
1700
1736
  "[RemoteControl] navigator.mediaDevices.getUserMedia unavailable. getUserMedia requires a secure context (https or http://localhost)."
@@ -1708,7 +1744,7 @@ const Xo = Kn(
1708
1744
  console.warn("[RemoteControl] microphone getUserMedia denied/failed:", E);
1709
1745
  }
1710
1746
  if (!i()) {
1711
- u && te(u);
1747
+ u && re(u);
1712
1748
  return;
1713
1749
  }
1714
1750
  if (!u) {
@@ -1717,56 +1753,56 @@ const Xo = Kn(
1717
1753
  }
1718
1754
  const f = u.getAudioTracks()[0] ?? null;
1719
1755
  if (!f) {
1720
- te(u), o("Captured stream has no audio track");
1756
+ re(u), o("Captured stream has no audio track");
1721
1757
  return;
1722
1758
  }
1723
1759
  try {
1724
1760
  await l.replaceTrack(f);
1725
1761
  } catch (E) {
1726
- w("replaceTrack(audioTrack) failed:", E), te(u), o("Failed to attach the microphone track to the connection");
1762
+ A("replaceTrack(audioTrack) failed:", E), re(u), o("Failed to attach the microphone track to the connection");
1727
1763
  return;
1728
1764
  }
1729
1765
  if (!i()) {
1730
1766
  try {
1731
1767
  await l.replaceTrack(null);
1732
1768
  } catch (E) {
1733
- w("replaceTrack(null) on stale mic attach failed:", E);
1769
+ A("replaceTrack(null) on stale mic attach failed:", E);
1734
1770
  }
1735
- te(u);
1771
+ re(u);
1736
1772
  return;
1737
1773
  }
1738
- fe.current = u, f.onended = () => {
1739
- fe.current === u && Nt("microphone capture ended by the browser");
1740
- }, Sr(n), L("onMicrophoneStateChange", ot.current, {
1774
+ pe.current = u, f.onended = () => {
1775
+ pe.current === u && Kt("microphone capture ended by the browser");
1776
+ }, Nr(n), U("onMicrophoneStateChange", st.current, {
1741
1777
  active: !0,
1742
1778
  label: f.label || void 0
1743
1779
  });
1744
- }, Nt = (e) => (++Ot.current, We.current = null, br(async () => {
1745
- const i = it.current, o = fe.current;
1746
- if (fe.current = null, i && o)
1780
+ }, Kt = (e) => (++Dt.current, He.current = null, Rr(async () => {
1781
+ const i = at.current, o = pe.current;
1782
+ if (pe.current = null, i && o)
1747
1783
  try {
1748
1784
  await i.replaceTrack(null);
1749
1785
  } catch (l) {
1750
- w("replaceTrack(null) on mic detach failed:", l);
1786
+ A("replaceTrack(null) on mic detach failed:", l);
1751
1787
  }
1752
- o && te(o);
1788
+ o && re(o);
1753
1789
  const n = T.current;
1754
1790
  if (o && n && n.readyState === WebSocket.OPEN) {
1755
1791
  const l = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1756
1792
  n.send(JSON.stringify({ type: "microphoneStop", id: l }));
1757
1793
  }
1758
- (o || e) && L("onMicrophoneStateChange", ot.current, {
1794
+ (o || e) && U("onMicrophoneStateChange", st.current, {
1759
1795
  active: !1,
1760
1796
  ...e !== void 0 && { error: e }
1761
1797
  });
1762
- })), Mr = (e, i) => {
1798
+ })), Ir = (e, i) => {
1763
1799
  let o;
1764
1800
  try {
1765
- o = po(i), console.info(
1801
+ o = vo(i), console.info(
1766
1802
  `[RemoteControl] camera capture: ${o.camera?.width}x${o.camera?.height} @ ${o.camera?.frameRate ?? "?"}fps` + (o.camera?.label ? ` — ${o.camera.label}` : "")
1767
1803
  );
1768
1804
  } catch (n) {
1769
- w("getSettings() on outbound camera track failed:", n), o = {
1805
+ A("getSettings() on outbound camera track failed:", n), o = {
1770
1806
  type: "cameraResult",
1771
1807
  granted: !0,
1772
1808
  camera: {
@@ -1774,13 +1810,13 @@ const Xo = Kn(
1774
1810
  }
1775
1811
  };
1776
1812
  }
1777
- e.send(JSON.stringify(o)), L("onCameraDemandChange", ve.current, !0, !0, o.camera);
1778
- }, On = (e) => {
1813
+ e.send(JSON.stringify(o)), U("onCameraDemandChange", ve.current, !0, !0, o.camera);
1814
+ }, An = (e) => {
1779
1815
  if (!e) return;
1780
1816
  const i = e.indexOf("/"), n = (i >= 0 ? e.slice(i + 1) : e).toUpperCase();
1781
1817
  return n === "HEVC" ? "H265" : n;
1782
- }, _n = async () => {
1783
- const e = Ae.current, i = yt.current;
1818
+ }, bn = async () => {
1819
+ const e = be.current, i = _t.current;
1784
1820
  if (!e || !i) return;
1785
1821
  let o;
1786
1822
  try {
@@ -1796,27 +1832,27 @@ const Xo = Kn(
1796
1832
  N && (l = N.mimeType);
1797
1833
  }
1798
1834
  if (!n) return;
1799
- const f = n.timestamp ?? Date.now(), E = vt.current;
1800
- let g, h, R;
1835
+ const f = n.timestamp ?? Date.now(), E = wt.current;
1836
+ let y, h, R;
1801
1837
  if (E && f > E.timestamp) {
1802
1838
  const N = (f - E.timestamp) / 1e3;
1803
- if (typeof n.framesEncoded == "number" && typeof E.framesEncoded == "number" && (g = Math.max(0, (n.framesEncoded - E.framesEncoded) / N)), typeof n.bytesSent == "number" && typeof E.bytesSent == "number" && (h = Math.max(0, (n.bytesSent - E.bytesSent) * 8 / N)), typeof n.packetsSent == "number" && typeof E.packetsSent == "number" && u && typeof u.packetsLost == "number" && typeof E.packetsLost == "number") {
1804
- const $ = n.packetsSent - E.packetsSent, ne = u.packetsLost - E.packetsLost;
1805
- $ > 0 && (R = Math.max(0, Math.min(100, ne / $ * 100)));
1839
+ if (typeof n.framesEncoded == "number" && typeof E.framesEncoded == "number" && (y = Math.max(0, (n.framesEncoded - E.framesEncoded) / N)), typeof n.bytesSent == "number" && typeof E.bytesSent == "number" && (h = Math.max(0, (n.bytesSent - E.bytesSent) * 8 / N)), typeof n.packetsSent == "number" && typeof E.packetsSent == "number" && u && typeof u.packetsLost == "number" && typeof E.packetsLost == "number") {
1840
+ const $ = n.packetsSent - E.packetsSent, oe = u.packetsLost - E.packetsLost;
1841
+ $ > 0 && (R = Math.max(0, Math.min(100, oe / $ * 100)));
1806
1842
  }
1807
1843
  }
1808
- vt.current = {
1844
+ wt.current = {
1809
1845
  timestamp: f,
1810
1846
  framesEncoded: n.framesEncoded,
1811
1847
  bytesSent: n.bytesSent,
1812
1848
  packetsSent: n.packetsSent,
1813
1849
  packetsLost: u?.packetsLost
1814
1850
  };
1815
- const D = {
1816
- codec: On(l),
1851
+ const _ = {
1852
+ codec: An(l),
1817
1853
  encoderImplementation: n.encoderImplementation,
1818
1854
  hardwareAccelerated: typeof n.powerEfficientEncoder == "boolean" ? n.powerEfficientEncoder : void 0,
1819
- framesPerSecond: g,
1855
+ framesPerSecond: y,
1820
1856
  framesEncoded: n.framesEncoded,
1821
1857
  bitrateBps: h,
1822
1858
  width: n.frameWidth,
@@ -1825,69 +1861,69 @@ const Xo = Kn(
1825
1861
  rttMs: typeof u?.roundTripTime == "number" ? u.roundTripTime * 1e3 : void 0,
1826
1862
  packetsLostPct: R
1827
1863
  };
1828
- L("onCameraStats", yt.current, D);
1829
- }, Rr = () => {
1830
- nt.current === null && (vt.current = null, nt.current = setInterval(() => {
1831
- _n();
1864
+ U("onCameraStats", _t.current, _);
1865
+ }, Yr = () => {
1866
+ ct.current === null && (wt.current = null, ct.current = setInterval(() => {
1867
+ bn();
1832
1868
  }, 1e3));
1833
- }, It = () => {
1834
- nt.current !== null && (clearInterval(nt.current), nt.current = null), vt.current = null, L("onCameraStats", yt.current, null);
1835
- }, Dn = (e, i, o, n) => $t.enqueue(async ({ isCurrent: l }) => {
1836
- const u = () => l() && n() && T.current === i && Ae.current === o;
1869
+ }, kt = () => {
1870
+ ct.current !== null && (clearInterval(ct.current), ct.current = null), wt.current = null, U("onCameraStats", _t.current, null);
1871
+ }, Sn = (e, i, o, n) => Vt.enqueue(async ({ isCurrent: l }) => {
1872
+ const u = () => l() && n() && T.current === i && be.current === o;
1837
1873
  if (!u()) return;
1838
1874
  if (!e.active) {
1839
- const D = re.current;
1875
+ const _ = ne.current;
1840
1876
  try {
1841
1877
  await o.replaceTrack(null);
1842
1878
  } catch (N) {
1843
- w("replaceTrack(null) on camera detach failed:", N);
1879
+ A("replaceTrack(null) on camera detach failed:", N);
1844
1880
  }
1845
- if (re.current === D && (re.current = null, be.current = void 0, D && te(D)), It(), !u()) return;
1846
- L("onCameraDemandChange", ve.current, !1);
1881
+ if (ne.current === _ && (ne.current = null, Se.current = void 0, _ && re(_)), kt(), !u()) return;
1882
+ U("onCameraDemandChange", ve.current, !1);
1847
1883
  return;
1848
1884
  }
1849
- L("onCameraDemandChange", ve.current, !0);
1850
- const f = re.current, E = f?.getVideoTracks()[0], g = be.current;
1851
- if (E?.readyState === "live" && g && !fo(g, e)) {
1852
- be.current = e, Mr(i, E), Rr();
1885
+ U("onCameraDemandChange", ve.current, !0);
1886
+ const f = ne.current, E = f?.getVideoTracks()[0], y = Se.current;
1887
+ if (E?.readyState === "live" && y && !yo(y, e)) {
1888
+ Se.current = e, Ir(i, E), Yr();
1853
1889
  return;
1854
1890
  }
1855
1891
  if (f) {
1856
1892
  try {
1857
1893
  await o.replaceTrack(null);
1858
- } catch (D) {
1859
- w("replaceTrack(null) before camera switch failed:", D);
1894
+ } catch (_) {
1895
+ A("replaceTrack(null) before camera switch failed:", _);
1860
1896
  }
1861
- if (re.current === f && (re.current = null, be.current = void 0, te(f)), It(), !u()) return;
1897
+ if (ne.current === f && (ne.current = null, Se.current = void 0, re(f)), kt(), !u()) return;
1862
1898
  }
1863
1899
  if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
1864
1900
  if (console.warn(
1865
1901
  "[RemoteControl] navigator.mediaDevices.getUserMedia unavailable. getUserMedia requires a secure context (https or http://localhost). Replying cameraResult granted=false so limulator falls back to black frames."
1866
1902
  ), !u()) return;
1867
- i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
1903
+ i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), U("onCameraDemandChange", ve.current, !0, !1);
1868
1904
  return;
1869
1905
  }
1870
1906
  let h = null;
1871
1907
  try {
1872
1908
  h = await navigator.mediaDevices.getUserMedia({
1873
- video: lo(e),
1909
+ video: go(e),
1874
1910
  audio: !1
1875
1911
  });
1876
- } catch (D) {
1877
- console.warn("[RemoteControl] getUserMedia denied/failed:", D);
1912
+ } catch (_) {
1913
+ console.warn("[RemoteControl] getUserMedia denied/failed:", _);
1878
1914
  }
1879
1915
  if (!u()) {
1880
- h && te(h);
1916
+ h && re(h);
1881
1917
  return;
1882
1918
  }
1883
1919
  if (!h) {
1884
- i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
1920
+ i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), U("onCameraDemandChange", ve.current, !0, !1);
1885
1921
  return;
1886
1922
  }
1887
1923
  const R = h.getVideoTracks()[0] ?? null;
1888
1924
  if (!R) {
1889
- if (te(h), !u()) return;
1890
- i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
1925
+ if (re(h), !u()) return;
1926
+ i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), U("onCameraDemandChange", ve.current, !0, !1);
1891
1927
  return;
1892
1928
  }
1893
1929
  try {
@@ -1896,68 +1932,68 @@ const Xo = Kn(
1896
1932
  }
1897
1933
  try {
1898
1934
  await o.replaceTrack(R);
1899
- } catch (D) {
1900
- if (w("replaceTrack(videoTrack) failed:", D), te(h), !u()) return;
1901
- i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
1935
+ } catch (_) {
1936
+ if (A("replaceTrack(videoTrack) failed:", _), re(h), !u()) return;
1937
+ i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), U("onCameraDemandChange", ve.current, !0, !1);
1902
1938
  return;
1903
1939
  }
1904
1940
  if (!u()) {
1905
1941
  try {
1906
1942
  await o.replaceTrack(null);
1907
- } catch (D) {
1908
- w("replaceTrack(null) for stale camera attach failed:", D);
1943
+ } catch (_) {
1944
+ A("replaceTrack(null) for stale camera attach failed:", _);
1909
1945
  }
1910
- te(h);
1946
+ re(h);
1911
1947
  return;
1912
1948
  }
1913
1949
  try {
1914
- const D = o.getParameters();
1915
- (!D.encodings || D.encodings.length === 0) && (D.encodings = [{}]), D.encodings[0].maxBitrate = 8e6, D.encodings[0].maxFramerate = 30, D.degradationPreference = "maintain-framerate", await o.setParameters(D);
1916
- } catch (D) {
1917
- w("setParameters on outbound camera failed:", D);
1950
+ const _ = o.getParameters();
1951
+ (!_.encodings || _.encodings.length === 0) && (_.encodings = [{}]), _.encodings[0].maxBitrate = 8e6, _.encodings[0].maxFramerate = 30, _.degradationPreference = "maintain-framerate", await o.setParameters(_);
1952
+ } catch (_) {
1953
+ A("setParameters on outbound camera failed:", _);
1918
1954
  }
1919
1955
  if (!u()) {
1920
1956
  try {
1921
1957
  await o.replaceTrack(null);
1922
- } catch (D) {
1923
- w("replaceTrack(null) for stale camera finalize failed:", D);
1958
+ } catch (_) {
1959
+ A("replaceTrack(null) for stale camera finalize failed:", _);
1924
1960
  }
1925
- te(h);
1961
+ re(h);
1926
1962
  return;
1927
1963
  }
1928
- re.current = h, be.current = e, R.onended = () => {
1929
- re.current === h && $t.enqueueCurrent(async ({ isCurrent: D }) => {
1930
- if (!(!D() || re.current !== h || !n() || T.current !== i || Ae.current !== o)) {
1964
+ ne.current = h, Se.current = e, R.onended = () => {
1965
+ ne.current === h && Vt.enqueueCurrent(async ({ isCurrent: _ }) => {
1966
+ if (!(!_() || ne.current !== h || !n() || T.current !== i || be.current !== o)) {
1931
1967
  try {
1932
1968
  await o.replaceTrack(null);
1933
1969
  } catch (N) {
1934
- w("replaceTrack(null) after camera ended failed:", N);
1970
+ A("replaceTrack(null) after camera ended failed:", N);
1935
1971
  }
1936
- !D() || re.current !== h || !n() || T.current !== i || Ae.current !== o || (re.current = null, be.current = void 0, te(h), It(), i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1));
1972
+ !_() || ne.current !== h || !n() || T.current !== i || be.current !== o || (ne.current = null, Se.current = void 0, re(h), kt(), i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), U("onCameraDemandChange", ve.current, !0, !1));
1937
1973
  }
1938
- }).catch((D) => w("camera ended cleanup failed:", D));
1939
- }, u() && (Mr(i, R), Rr());
1940
- }), Qe = () => {
1941
- for (const e of _e.current.values()) e();
1942
- _e.current.clear();
1943
- for (const e of Ue.current.values())
1974
+ }).catch((_) => A("camera ended cleanup failed:", _));
1975
+ }, u() && (Ir(i, R), Yr());
1976
+ }), Ze = () => {
1977
+ for (const e of rt.current.values()) e();
1978
+ rt.current.clear();
1979
+ for (const e of Le.current.values())
1944
1980
  clearTimeout(e.timer), e.reject(new Error("Simulator disconnected"));
1945
- Ue.current.clear(), ir(null), et.current && (et.current.srcObject = null), Rt(), ht(), ft(), ee.current && (ee.current.stop(), ee.current = null), $t.invalidate(), It(), yn(), be.current = void 0, Ae.current = null, ++Ot.current, Bt.current = !1, We.current = null, fe.current && (te(fe.current), fe.current = null, L("onMicrophoneStateChange", ot.current, {
1981
+ Le.current.clear(), ar(null), nt.current && (nt.current.srcObject = null), Yt(), Et(), mt(), te.current && (te.current.stop(), te.current = null), Vt.invalidate(), kt(), Dn(), Se.current = void 0, be.current = null, ++Dt.current, Jt.current = !1, He.current = null, pe.current && (re(pe.current), pe.current = null, U("onMicrophoneStateChange", st.current, {
1946
1982
  active: !1
1947
- })), it.current = null, se.current !== void 0 && (window.cancelAnimationFrame(se.current), se.current = void 0), T.current && (T.current.onopen = null, T.current.onmessage = null, T.current.onerror = null, T.current.onclose = null, T.current.close(), T.current = null), W.current && (W.current.onconnectionstatechange = null, W.current.oniceconnectionstatechange = null, W.current.ontrack = null, W.current.onicecandidate = null, W.current.close(), W.current = null), F.current && (F.current.srcObject = null), P.current && (P.current.onopen = null, P.current.onclose = null, P.current.onerror = null, P.current.close(), P.current = null);
1948
- }, Nr = () => {
1949
- document.hidden ? Ar() : wr();
1950
- }, Tn = async () => {
1983
+ })), at.current = null, ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0), T.current && (T.current.onopen = null, T.current.onmessage = null, T.current.onerror = null, T.current.onclose = null, T.current.close(), T.current = null), Ct.current?.close(), Ct.current = null, x.current && (x.current.onconnectionstatechange = null, x.current.oniceconnectionstatechange = null, x.current.ontrack = null, x.current.onicecandidate = null, x.current.close(), x.current = null), W.current && (W.current.srcObject = null), P.current && (P.current.onopen = null, P.current.onclose = null, P.current.onerror = null, P.current.close(), P.current = null);
1984
+ }, Kr = () => {
1985
+ document.hidden ? Mr() : Sr();
1986
+ }, Mn = async () => {
1951
1987
  if (typeof navigator < "u" && navigator.onLine === !1)
1952
1988
  return !1;
1953
1989
  let e;
1954
1990
  try {
1955
1991
  const n = new URL(t);
1956
- n.protocol = n.protocol === "wss:" ? "https:" : n.protocol === "ws:" ? "http:" : n.protocol, e = Ur(n.toString(), c);
1992
+ n.protocol = n.protocol === "wss:" ? "https:" : n.protocol === "ws:" ? "http:" : n.protocol, e = Fr(n.toString(), c);
1957
1993
  } catch {
1958
1994
  return !1;
1959
1995
  }
1960
- const i = new AbortController(), o = window.setTimeout(() => i.abort(), So);
1996
+ const i = new AbortController(), o = window.setTimeout(() => i.abort(), Ko);
1961
1997
  try {
1962
1998
  return (await fetch(e, { method: "GET", cache: "no-store", signal: i.signal })).status === 404;
1963
1999
  } catch {
@@ -1965,75 +2001,75 @@ const Xo = Kn(
1965
2001
  } finally {
1966
2002
  window.clearTimeout(o);
1967
2003
  }
1968
- }, wn = () => {
1969
- Le.current || (Le.current = !0, ar(!0), Et(!1), we.current += 1, Mt(), Rt(), ht(), Qe(), K("Instance terminated"), Ve("terminated"), L("onTerminated", Cr.current));
1970
- }, An = () => {
1971
- Le.current || Wt.current || (Wt.current = !0, Tn().then((e) => {
1972
- Wt.current = !1, e && wn();
2004
+ }, Rn = () => {
2005
+ xe.current || (xe.current = !0, dr(!0), yt(!1), Ae.current += 1, It(), Yt(), Et(), Ze(), K("Instance terminated"), Ge("terminated"), U("onTerminated", Or.current));
2006
+ }, Nn = () => {
2007
+ xe.current || Xt.current || (Xt.current = !0, Mn().then((e) => {
2008
+ Xt.current = !1, e && Rn();
1973
2009
  }));
1974
- }, Ze = (e, i) => {
1975
- if (Le.current || i !== we.current)
2010
+ }, et = (e, i) => {
2011
+ if (xe.current || i !== Ae.current)
1976
2012
  return;
1977
- if (An(), ye.current) {
1978
- if (!Ht.current) {
1979
- K(`Connection failed after it was established: ${e}`), Et(!0), Ve("failed"), Qe();
2013
+ if (Nn(), Ce.current) {
2014
+ if (!qt.current) {
2015
+ K(`Connection failed after it was established: ${e}`), yt(!0), Ge("failed"), Ze();
1980
2016
  return;
1981
2017
  }
1982
- K(`Reconnecting after established session dropped: ${e}`), ye.current = !1, Ct.current = -1;
2018
+ K(`Reconnecting after established session dropped: ${e}`), Ce.current = !1, Ot.current = -1;
1983
2019
  }
1984
- Mt();
1985
- const o = Ct.current + 1;
1986
- if (o >= tr) {
1987
- K(`Connection failed after ${tr} attempts: ${e}`), Et(!0), Ve("failed"), Qe();
2020
+ It();
2021
+ const o = Ot.current + 1;
2022
+ if (o >= ir) {
2023
+ K(`Connection failed after ${ir} attempts: ${e}`), yt(!0), Ge("failed"), Ze();
1988
2024
  return;
1989
2025
  }
1990
- K(`Retrying connection (${o + 1}/${tr})`), Ve("reconnecting"), Qe(), tt.current = window.setTimeout(() => {
1991
- tt.current = void 0, i === we.current && Ir(o);
1992
- }, wo);
1993
- }, Ir = async (e = 0) => {
1994
- if (Le.current) return;
1995
- const i = we.current + 1;
1996
- we.current = i, Ct.current = e, ye.current = !1, Et(!1), e === 0 && Jt.current !== "reconnecting" && Ve("connecting"), Mt(), Rt(), ft(), ct.current = !1, Ft(!1), Qe();
1997
- const o = () => i === we.current;
1998
- rt.current = window.setTimeout(() => {
1999
- rt.current = void 0, !(!o() || ye.current) && Ze("Connection did not succeed within 15 seconds", i);
2000
- }, Ao);
2026
+ K(`Retrying connection (${o + 1}/${ir})`), Ge("reconnecting"), Ze(), ot.current = window.setTimeout(() => {
2027
+ ot.current = void 0, i === Ae.current && kr(o);
2028
+ }, No);
2029
+ }, kr = async (e = 0) => {
2030
+ if (xe.current) return;
2031
+ const i = Ae.current + 1;
2032
+ Ae.current = i, Ot.current = e, Ce.current = !1, yt(!1), e === 0 && Zt.current !== "reconnecting" && Ge("connecting"), It(), Yt(), mt(), ut.current = !1, $t(!1), Ze();
2033
+ const o = () => i === Ae.current;
2034
+ it.current = window.setTimeout(() => {
2035
+ it.current = void 0, !(!o() || Ce.current) && et("Connection did not succeed within 15 seconds", i);
2036
+ }, Io);
2001
2037
  try {
2002
- const n = new WebSocket(Ur(t, c));
2003
- if (T.current = n, await new Promise((v, d) => {
2038
+ const n = new WebSocket(Fr(t, c));
2039
+ if (T.current = n, await new Promise((w, d) => {
2004
2040
  let Y = !1;
2005
- const z = window.setTimeout(() => d(new Error("WebSocket connection timeout")), 3e4), A = (I) => {
2006
- Y || (Y = !0, window.clearTimeout(z), I());
2041
+ const Q = window.setTimeout(() => d(new Error("WebSocket connection timeout")), 3e4), b = (I) => {
2042
+ Y || (Y = !0, window.clearTimeout(Q), I());
2007
2043
  };
2008
2044
  n.onopen = () => {
2009
- !o() || T.current !== n || A(v);
2045
+ !o() || T.current !== n || b(w);
2010
2046
  }, n.onerror = (I) => {
2011
- !o() || T.current !== n || (K("WebSocket error: " + I), A(() => d(new Error("WebSocket connection failed"))));
2047
+ !o() || T.current !== n || (K("WebSocket error: " + I), b(() => d(new Error("WebSocket connection failed"))));
2012
2048
  }, n.onclose = () => {
2013
- !o() || T.current !== n || (K("WebSocket closed"), A(() => d(new Error("WebSocket closed before connection was established"))));
2049
+ !o() || T.current !== n || (K("WebSocket closed"), b(() => d(new Error("WebSocket closed before connection was established"))));
2014
2050
  };
2015
2051
  }), !o() || T.current !== n)
2016
2052
  return;
2017
- n.onerror = (v) => {
2018
- !o() || T.current !== n || K("WebSocket error: " + v);
2053
+ n.onerror = (w) => {
2054
+ !o() || T.current !== n || K("WebSocket error: " + w);
2019
2055
  }, n.onclose = () => {
2020
2056
  !o() || T.current !== n || K("WebSocket closed");
2021
2057
  };
2022
- const l = new Promise((v, d) => {
2058
+ const l = new Promise((w, d) => {
2023
2059
  const Y = (I) => {
2024
- window.clearTimeout(z), n.removeEventListener("message", A), I();
2025
- }, z = window.setTimeout(
2060
+ window.clearTimeout(Q), n.removeEventListener("message", b), I();
2061
+ }, Q = window.setTimeout(
2026
2062
  () => Y(() => d(new Error("RTCConfiguration timeout"))),
2027
2063
  3e4
2028
- ), A = (I) => {
2064
+ ), b = (I) => {
2029
2065
  if (!(!o() || T.current !== n))
2030
2066
  try {
2031
2067
  const q = JSON.parse(I.data);
2032
- if (q.type === "signalingError" && q.requestType === "requestRtcConfiguration" && q.sessionId === ue) {
2033
- const oe = typeof q.error == "string" ? q.error : "Unable to load streaming configuration";
2034
- Y(() => d(new Error(oe)));
2068
+ if (q.type === "signalingError" && q.requestType === "requestRtcConfiguration" && q.sessionId === le) {
2069
+ const ie = typeof q.error == "string" ? q.error : "Unable to load streaming configuration";
2070
+ Y(() => d(new Error(ie)));
2035
2071
  } else q.type === "rtcConfiguration" && Y(
2036
- () => v({
2072
+ () => w({
2037
2073
  rtcConfiguration: q.rtcConfiguration,
2038
2074
  cameraSupported: q.cameraSupported === !0,
2039
2075
  foldSupported: q.foldSupported === !0
@@ -2043,10 +2079,10 @@ const Xo = Kn(
2043
2079
  console.error("Error handling RTC configuration:", q), Y(() => d(q));
2044
2080
  }
2045
2081
  };
2046
- n.addEventListener("message", A), n.send(
2082
+ n.addEventListener("message", b), n.send(
2047
2083
  JSON.stringify({
2048
2084
  type: "requestRtcConfiguration",
2049
- sessionId: ue
2085
+ sessionId: le
2050
2086
  })
2051
2087
  );
2052
2088
  }), {
@@ -2056,44 +2092,44 @@ const Xo = Kn(
2056
2092
  } = await l;
2057
2093
  if (!o() || T.current !== n)
2058
2094
  return;
2059
- const g = C === "iphone-duo" || E;
2060
- Lt(g);
2095
+ const y = g === "iphone-duo" || E;
2096
+ Qr(y);
2061
2097
  const h = new RTCPeerConnection({ ...u, iceTransportPolicy: "relay" });
2062
- W.current = h, h.addTransceiver("audio", { direction: "recvonly" });
2063
- const R = h.addTransceiver("video", { direction: "recvonly" }), D = g ? h.addTransceiver("video", { direction: "recvonly" }) : null, N = he === "ios" || f, $ = N ? h.addTransceiver("video", {
2098
+ x.current = h, h.addTransceiver("audio", { direction: "recvonly" });
2099
+ const R = h.addTransceiver("video", { direction: "recvonly" }), _ = y ? h.addTransceiver("video", { direction: "recvonly" }) : null, N = de === "ios" || f, $ = N ? h.addTransceiver("video", {
2064
2100
  direction: "sendonly"
2065
2101
  }) : null;
2066
- Ae.current = $?.sender ?? null;
2067
- const ne = N ? h.addTransceiver("audio", {
2102
+ be.current = $?.sender ?? null;
2103
+ const oe = N ? h.addTransceiver("audio", {
2068
2104
  direction: "sendonly"
2069
2105
  }) : null;
2070
- if (it.current = ne?.sender ?? null, RTCRtpReceiver.getCapabilities) {
2071
- const v = RTCRtpReceiver.getCapabilities("video");
2072
- if (v && v.codecs) {
2073
- const Y = v.codecs.sort((z, A) => {
2106
+ if (at.current = oe?.sender ?? null, RTCRtpReceiver.getCapabilities) {
2107
+ const w = RTCRtpReceiver.getCapabilities("video");
2108
+ if (w && w.codecs) {
2109
+ const Y = w.codecs.sort((Q, b) => {
2074
2110
  const I = (q) => {
2075
- const oe = q.mimeType.toLowerCase();
2076
- return oe.includes("vp9") ? 1 : oe.includes("h265") || oe.includes("hevc") ? 2 : oe.includes("h264") || oe.includes("avc") ? 3 : 4;
2111
+ const ie = q.mimeType.toLowerCase();
2112
+ return ie.includes("vp9") ? 1 : ie.includes("h265") || ie.includes("hevc") ? 2 : ie.includes("h264") || ie.includes("avc") ? 3 : 4;
2077
2113
  };
2078
- return I(z) - I(A);
2114
+ return I(Q) - I(b);
2079
2115
  });
2080
- R.setCodecPreferences(Y), D?.setCodecPreferences(Y), x("Set codec preferences:", Y.map((z) => z.mimeType).join(", "));
2116
+ R.setCodecPreferences(Y), _?.setCodecPreferences(Y), F("Set codec preferences:", Y.map((Q) => Q.mimeType).join(", "));
2081
2117
  }
2082
2118
  }
2083
2119
  if ($ && RTCRtpSender.getCapabilities) {
2084
- const v = RTCRtpSender.getCapabilities("video");
2085
- if (v && v.codecs) {
2086
- const d = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (A) => {
2087
- const I = A.mimeType.toLowerCase(), oe = (A.sdpFmtpLine || "").toLowerCase().match(/profile-level-id=([0-9a-f]{6})/), Nn = oe ? oe[1] : "";
2088
- return I === "video/h265" || I === "video/hevc" ? 1 : I === "video/h264" && d.has(Nn) ? 2 : I === "video/h264" ? 3 : I === "video/vp9" ? 4 : I === "video/vp8" ? 5 : I === "video/rtx" || I === "video/red" || I === "video/ulpfec" ? 0 : 6;
2089
- }, z = [...v.codecs].sort((A, I) => Y(A) - Y(I));
2120
+ const w = RTCRtpSender.getCapabilities("video");
2121
+ if (w && w.codecs) {
2122
+ const d = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (b) => {
2123
+ const I = b.mimeType.toLowerCase(), ie = (b.sdpFmtpLine || "").toLowerCase().match(/profile-level-id=([0-9a-f]{6})/), Pn = ie ? ie[1] : "";
2124
+ return I === "video/h265" || I === "video/hevc" ? 1 : I === "video/h264" && d.has(Pn) ? 2 : I === "video/h264" ? 3 : I === "video/vp9" ? 4 : I === "video/vp8" ? 5 : I === "video/rtx" || I === "video/red" || I === "video/ulpfec" ? 0 : 6;
2125
+ }, Q = [...w.codecs].sort((b, I) => Y(b) - Y(I));
2090
2126
  try {
2091
- $.setCodecPreferences(z), x(
2127
+ $.setCodecPreferences(Q), F(
2092
2128
  "Outbound camera codec preferences:",
2093
- z.map((A) => `${A.mimeType}${A.sdpFmtpLine ? `[${A.sdpFmtpLine}]` : ""}`).join(", ")
2129
+ Q.map((b) => `${b.mimeType}${b.sdpFmtpLine ? `[${b.sdpFmtpLine}]` : ""}`).join(", ")
2094
2130
  );
2095
- } catch (A) {
2096
- w("Failed to set outbound camera codec preferences:", A);
2131
+ } catch (b) {
2132
+ A("Failed to set outbound camera codec preferences:", b);
2097
2133
  }
2098
2134
  }
2099
2135
  }
@@ -2102,14 +2138,18 @@ const Xo = Kn(
2102
2138
  negotiated: !0,
2103
2139
  id: 1
2104
2140
  });
2105
- if (P.current = j, j.onopen = () => {
2141
+ P.current = j;
2142
+ const z = de === "ios" && !y && Bt.current ? Vn(h, (w) => {
2143
+ o() && x.current === h && U("onTrace", Bt.current, w);
2144
+ }) : null;
2145
+ if (Ct.current = z, j.onopen = () => {
2106
2146
  if (!o() || P.current !== j || T.current !== n)
2107
2147
  return;
2108
- ye.current = !0, Rt(), K("Control channel opened"), g && n.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), ee.current || (ee.current = new so({
2109
- platform: he,
2110
- baseIntervalMs: Z,
2148
+ Ce.current = !0, Yt(), K("Control channel opened"), y && n.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), te.current || (te.current = new po({
2149
+ platform: de,
2150
+ baseIntervalMs: ee,
2111
2151
  maxBackoffMs: X,
2112
- androidElementTreeOptions: me,
2152
+ androidElementTreeOptions: Ee,
2113
2153
  send: (d) => {
2114
2154
  if (!T.current || T.current.readyState !== WebSocket.OPEN) return !1;
2115
2155
  try {
@@ -2119,23 +2159,23 @@ const Xo = Kn(
2119
2159
  }
2120
2160
  },
2121
2161
  onSnapshot: (d) => {
2122
- hr((Y) => qr(Y, d) ? Y : d), queueMicrotask(() => {
2123
- L("onAxSnapshotChange", Gt.current, d);
2162
+ Er((Y) => Jr(Y, d) ? Y : d), queueMicrotask(() => {
2163
+ U("onAxSnapshotChange", Qt.current, d);
2124
2164
  });
2125
2165
  },
2126
2166
  onStatusChange: (d, Y) => {
2127
- L("onAxStatusChange", gr.current, d, Y);
2167
+ U("onAxStatusChange", vr.current, d, Y);
2128
2168
  }
2129
- }), (Xe.current === !0 || Xe.current === "hover-only") && ee.current.start());
2130
- const v = () => {
2131
- !o() || ct.current || P.current !== j || T.current !== n || n.readyState !== WebSocket.OPEN || n.send(JSON.stringify({ type: "requestFrame", sessionId: ue }));
2169
+ }), (Be.current === !0 || Be.current === "hover-only") && te.current.start());
2170
+ const w = () => {
2171
+ !o() || ut.current || P.current !== j || T.current !== n || n.readyState !== WebSocket.OPEN || n.send(JSON.stringify({ type: "requestFrame", sessionId: le }));
2132
2172
  };
2133
- if (v(), ft(), gt.current = window.setInterval(() => {
2134
- if (!o() || ct.current || P.current !== j || T.current !== n || n.readyState !== WebSocket.OPEN) {
2135
- ft();
2173
+ if (w(), mt(), vt.current = window.setInterval(() => {
2174
+ if (!o() || ut.current || P.current !== j || T.current !== n || n.readyState !== WebSocket.OPEN) {
2175
+ mt();
2136
2176
  return;
2137
2177
  }
2138
- v();
2178
+ w();
2139
2179
  }, 250), m) {
2140
2180
  try {
2141
2181
  const d = decodeURIComponent(m);
@@ -2143,7 +2183,7 @@ const Xo = Kn(
2143
2183
  JSON.stringify({
2144
2184
  type: "openUrl",
2145
2185
  url: d,
2146
- sessionId: ue
2186
+ sessionId: le
2147
2187
  })
2148
2188
  );
2149
2189
  } catch (d) {
@@ -2151,102 +2191,102 @@ const Xo = Kn(
2151
2191
  JSON.stringify({
2152
2192
  type: "openUrl",
2153
2193
  url: m,
2154
- sessionId: ue
2194
+ sessionId: le
2155
2195
  })
2156
2196
  );
2157
2197
  }
2158
- ee.current?.bumpActivity();
2198
+ te.current?.bumpActivity();
2159
2199
  }
2160
2200
  }, j.onclose = () => {
2161
2201
  !o() || P.current !== j || K("Control channel closed");
2162
- }, j.onerror = (v) => {
2163
- !o() || P.current !== j || (console.error("Control channel error:", v), K("Control channel error: " + v));
2202
+ }, j.onerror = (w) => {
2203
+ !o() || P.current !== j || (console.error("Control channel error:", w), K("Control channel error: " + w));
2164
2204
  }, h.onconnectionstatechange = () => {
2165
- !o() || W.current !== h || (K("Connection state: " + h.connectionState), h.connectionState === "failed" && ye.current && Ze("WebRTC connection entered failed state", i));
2205
+ !o() || x.current !== h || (K("Connection state: " + h.connectionState), h.connectionState === "failed" && Ce.current && et("WebRTC connection entered failed state", i));
2166
2206
  }, h.oniceconnectionstatechange = () => {
2167
- if (!o() || W.current !== h)
2207
+ if (!o() || x.current !== h)
2168
2208
  return;
2169
- const v = h.iceConnectionState;
2170
- if (K("ICE state: " + v), v === "connected" || v === "completed") {
2171
- ht(), zt() && !fe.current && Qt();
2209
+ const w = h.iceConnectionState;
2210
+ if (K("ICE state: " + w), w === "connected" || w === "completed") {
2211
+ Et(), tr() && !pe.current && rr();
2172
2212
  return;
2173
2213
  }
2174
- if (v === "failed") {
2175
- ht(), ye.current && Ze("ICE connection entered failed state", i);
2214
+ if (w === "failed") {
2215
+ Et(), Ce.current && et("ICE connection entered failed state", i);
2176
2216
  return;
2177
2217
  }
2178
- v === "disconnected" && ye.current && Ht.current && Fe.current === void 0 && (Fe.current = window.setTimeout(() => {
2179
- Fe.current = void 0, !(!o() || W.current !== h) && h.iceConnectionState === "disconnected" && Ze("ICE stayed disconnected past grace period", i);
2180
- }, bo));
2181
- }, h.ontrack = (v) => {
2182
- if (!(!o() || W.current !== h) && (K("Received remote track: " + v.track.kind), v.track.kind === "video" && F.current)) {
2183
- x(`[${(/* @__PURE__ */ new Date()).toISOString()}] Video track received:`, v.track);
2184
- const Y = v.track.id === "duo-inner" || v.streams.some((z) => z.id === "duo-inner") ? et.current : F.current;
2218
+ w === "disconnected" && Ce.current && qt.current && We.current === void 0 && (We.current = window.setTimeout(() => {
2219
+ We.current = void 0, !(!o() || x.current !== h) && h.iceConnectionState === "disconnected" && et("ICE stayed disconnected past grace period", i);
2220
+ }, Yo));
2221
+ }, h.ontrack = (w) => {
2222
+ if (!(!o() || x.current !== h) && (K("Received remote track: " + w.track.kind), w.track.kind === "video" && W.current)) {
2223
+ F(`[${(/* @__PURE__ */ new Date()).toISOString()}] Video track received:`, w.track);
2224
+ const Y = w.track.id === "duo-inner" || w.streams.some((Q) => Q.id === "duo-inner") ? nt.current : W.current;
2185
2225
  if (Y) {
2186
- const z = g ? new MediaStream([v.track]) : v.streams[0] ?? new MediaStream([v.track]);
2187
- _e.current.get(Y)?.(), _e.current.set(
2226
+ const Q = y ? new MediaStream([w.track]) : w.streams[0] ?? new MediaStream([w.track]);
2227
+ rt.current.get(Y)?.(), rt.current.set(
2188
2228
  Y,
2189
- Wn(Y, z, (A) => w("Video playback fallback:", A))
2229
+ qn(Y, Q, (b) => A("Video playback fallback:", b))
2190
2230
  );
2191
2231
  }
2192
2232
  }
2193
- }, h.onicecandidate = (v) => {
2194
- if (!(!o() || W.current !== h || T.current !== n))
2195
- if (v.candidate && n.readyState === WebSocket.OPEN) {
2233
+ }, h.onicecandidate = (w) => {
2234
+ if (!(!o() || x.current !== h || T.current !== n))
2235
+ if (w.candidate && n.readyState === WebSocket.OPEN) {
2196
2236
  const d = {
2197
2237
  type: "candidate",
2198
- candidate: v.candidate.candidate,
2199
- sdpMid: v.candidate.sdpMid,
2200
- sdpMLineIndex: v.candidate.sdpMLineIndex,
2201
- sessionId: ue
2238
+ candidate: w.candidate.candidate,
2239
+ sdpMid: w.candidate.sdpMid,
2240
+ sdpMLineIndex: w.candidate.sdpMLineIndex,
2241
+ sessionId: le
2202
2242
  };
2203
2243
  n.send(JSON.stringify(d)), K("Sent ICE candidate");
2204
2244
  } else
2205
2245
  K("ICE candidate gathering completed");
2206
- }, n.onmessage = async (v) => {
2246
+ }, n.onmessage = async (w) => {
2207
2247
  if (!o() || T.current !== n)
2208
2248
  return;
2209
2249
  let d;
2210
2250
  try {
2211
- d = JSON.parse(v.data);
2251
+ d = JSON.parse(w.data);
2212
2252
  } catch (Y) {
2213
- w("Error parsing message:", Y);
2253
+ A("Error parsing message:", Y);
2214
2254
  return;
2215
2255
  }
2216
- if (!ee.current?.handleMessage(d))
2256
+ if (!te.current?.handleMessage(d))
2217
2257
  switch (K("Received: " + d.type), d.type) {
2218
2258
  case "performActionsResult":
2219
2259
  case "foldStateResult":
2220
2260
  case "foldStateChanged": {
2221
- if (!g) break;
2222
- d.state ? (ir(d.state), sr(void 0)) : d.id === "duo-capabilities" && sr(d.error || "This instance does not support native iPhone Duo displays.");
2223
- const A = Ue.current.get(d.id);
2224
- A && (clearTimeout(A.timer), Ue.current.delete(d.id), d.error ? A.reject(new Error(d.error)) : A.resolve());
2261
+ if (!y) break;
2262
+ d.state ? (ar(d.state), lr(void 0)) : d.id === "duo-capabilities" && lr(d.error || "This instance does not support native iPhone Duo displays.");
2263
+ const b = Le.current.get(d.id);
2264
+ b && (clearTimeout(b.timer), Le.current.delete(d.id), d.error ? b.reject(new Error(d.error)) : b.resolve());
2225
2265
  break;
2226
2266
  }
2227
2267
  case "signalingError": {
2228
- if (d.requestType !== "offer" || d.sessionId !== ue)
2268
+ if (d.requestType !== "offer" || d.sessionId !== le)
2229
2269
  break;
2230
- const A = typeof d.error == "string" ? d.error : "Unable to establish the streaming connection";
2231
- K("Error: " + A), Ze(A, i);
2270
+ const b = typeof d.error == "string" ? d.error : "Unable to establish the streaming connection";
2271
+ K("Error: " + b), et(b, i);
2232
2272
  break;
2233
2273
  }
2234
2274
  case "answer":
2235
- if (!W.current || W.current !== h) {
2275
+ if (!x.current || x.current !== h) {
2236
2276
  K("No peer connection, skipping answer");
2237
2277
  break;
2238
2278
  }
2239
- if (await h.setRemoteDescription(
2279
+ if (z?.accept(d.latencyTraceVersion), await h.setRemoteDescription(
2240
2280
  new RTCSessionDescription({
2241
2281
  type: "answer",
2242
2282
  sdp: d.sdp
2243
2283
  })
2244
- ), !o() || W.current !== h)
2284
+ ), !o() || x.current !== h)
2245
2285
  return;
2246
2286
  K("Set remote description");
2247
2287
  break;
2248
2288
  case "candidate":
2249
- if (!W.current || W.current !== h) {
2289
+ if (!x.current || x.current !== h) {
2250
2290
  K("No peer connection, skipping candidate");
2251
2291
  break;
2252
2292
  }
@@ -2256,122 +2296,123 @@ const Xo = Kn(
2256
2296
  sdpMid: d.sdpMid,
2257
2297
  sdpMLineIndex: d.sdpMLineIndex
2258
2298
  })
2259
- ), !o() || W.current !== h)
2299
+ ), !o() || x.current !== h)
2260
2300
  return;
2261
2301
  K("Added ICE candidate");
2262
2302
  break;
2263
2303
  case "screenshot":
2264
2304
  case "screenshotResult": {
2265
2305
  if (typeof d.id != "string") {
2266
- w("Received invalid screenshot success message:", d);
2306
+ A("Received invalid screenshot success message:", d);
2267
2307
  break;
2268
2308
  }
2269
- const A = Io(d);
2270
- if (A) {
2271
- const oe = Oe.current.get(d.id);
2272
- if (!oe) {
2273
- w(`Received screenshot error for unknown or handled id: ${d.id}`);
2309
+ const b = Lo(d);
2310
+ if (b) {
2311
+ const ie = Oe.current.get(d.id);
2312
+ if (!ie) {
2313
+ A(`Received screenshot error for unknown or handled id: ${d.id}`);
2274
2314
  break;
2275
2315
  }
2276
- w(`Received screenshot error for id ${d.id}: ${A}`), oe(new Error(A)), De.current.delete(d.id), Oe.current.delete(d.id);
2316
+ A(`Received screenshot error for id ${d.id}: ${b}`), ie(new Error(b)), we.current.delete(d.id), Oe.current.delete(d.id);
2277
2317
  break;
2278
2318
  }
2279
- const I = Yo(d);
2319
+ const I = xo(d);
2280
2320
  if (!I) {
2281
- w("Received screenshot message without image data:", d);
2321
+ A("Received screenshot message without image data:", d);
2282
2322
  break;
2283
2323
  }
2284
- const q = De.current.get(d.id);
2324
+ const q = we.current.get(d.id);
2285
2325
  if (!q) {
2286
- w(`Received screenshot data for unknown or handled id: ${d.id}`);
2326
+ A(`Received screenshot data for unknown or handled id: ${d.id}`);
2287
2327
  break;
2288
2328
  }
2289
- x(`Received screenshot data for id ${d.id}`), q(I), De.current.delete(d.id), Oe.current.delete(d.id);
2329
+ F(`Received screenshot data for id ${d.id}`), q(I), we.current.delete(d.id), Oe.current.delete(d.id);
2290
2330
  break;
2291
2331
  }
2292
2332
  case "screenshotError":
2293
2333
  if (typeof d.id != "string" || typeof d.message != "string") {
2294
- w("Received invalid screenshot error message:", d);
2334
+ A("Received invalid screenshot error message:", d);
2295
2335
  break;
2296
2336
  }
2297
2337
  const Y = Oe.current.get(d.id);
2298
2338
  if (!Y) {
2299
- w(`Received screenshot error for unknown or handled id: ${d.id}`);
2339
+ A(`Received screenshot error for unknown or handled id: ${d.id}`);
2300
2340
  break;
2301
2341
  }
2302
- w(`Received screenshot error for id ${d.id}: ${d.message}`), Y(new Error(d.message)), De.current.delete(d.id), Oe.current.delete(d.id);
2342
+ A(`Received screenshot error for id ${d.id}: ${d.message}`), Y(new Error(d.message)), we.current.delete(d.id), Oe.current.delete(d.id);
2303
2343
  break;
2304
2344
  case "cameraRequest": {
2305
- const A = Ae.current;
2306
- if (!A)
2345
+ const b = be.current;
2346
+ if (!b)
2307
2347
  break;
2308
- const I = uo(d);
2348
+ const I = Eo(d);
2309
2349
  if (!I) {
2310
- w("Received invalid cameraRequest:", d);
2350
+ A("Received invalid cameraRequest:", d);
2311
2351
  break;
2312
2352
  }
2313
- console.info("[RemoteControl] cameraRequest received:", I.active, I.facingMode), await Dn(I, n, A, o);
2353
+ console.info("[RemoteControl] cameraRequest received:", I.active, I.facingMode), await Sn(I, n, b, o);
2314
2354
  break;
2315
2355
  }
2316
2356
  case "microphoneRequest": {
2317
- if (!it.current)
2357
+ if (!at.current)
2318
2358
  break;
2319
- const A = d.active === !0;
2320
- if (Bt.current = A, console.info("[RemoteControl] microphoneRequest received, active=", A), !A) {
2321
- Xt.current || await Nt();
2359
+ const b = d.active === !0;
2360
+ if (Jt.current = b, console.info("[RemoteControl] microphoneRequest received, active=", b), !b) {
2361
+ Gt.current || await Kt();
2322
2362
  break;
2323
2363
  }
2324
- if (fe.current) {
2325
- Sr(n);
2364
+ if (pe.current) {
2365
+ Nr(n);
2326
2366
  break;
2327
2367
  }
2328
- await Qt();
2368
+ await rr();
2329
2369
  break;
2330
2370
  }
2331
2371
  case "microphoneStartResult": {
2332
- if (We.current === null || d.id !== We.current)
2372
+ if (He.current === null || d.id !== He.current)
2333
2373
  break;
2334
- We.current = null, typeof d.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", d.error), Nt(d.error));
2374
+ He.current = null, typeof d.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", d.error), Kt(d.error));
2335
2375
  break;
2336
2376
  }
2337
2377
  case "terminateAppResult":
2338
2378
  if (typeof d.id != "string") {
2339
- w("Received invalid terminateApp result message:", d);
2379
+ A("Received invalid terminateApp result message:", d);
2340
2380
  break;
2341
2381
  }
2342
2382
  if (typeof d.error == "string") {
2343
- const A = Me.current.get(d.id);
2344
- if (!A) {
2345
- w(`Received terminateApp error for unknown or handled id: ${d.id}`);
2383
+ const b = Re.current.get(d.id);
2384
+ if (!b) {
2385
+ A(`Received terminateApp error for unknown or handled id: ${d.id}`);
2346
2386
  break;
2347
2387
  }
2348
- w(`Received terminateApp error for id ${d.id}: ${d.error}`), A(new Error(d.error)), Se.current.delete(d.id), Me.current.delete(d.id);
2388
+ A(`Received terminateApp error for id ${d.id}: ${d.error}`), b(new Error(d.error)), Me.current.delete(d.id), Re.current.delete(d.id);
2349
2389
  break;
2350
2390
  }
2351
- const z = Se.current.get(d.id);
2352
- if (!z) {
2353
- w(`Received terminateApp result for unknown or handled id: ${d.id}`);
2391
+ const Q = Me.current.get(d.id);
2392
+ if (!Q) {
2393
+ A(`Received terminateApp result for unknown or handled id: ${d.id}`);
2354
2394
  break;
2355
2395
  }
2356
- x(`Received terminateApp success for id ${d.id}`), z(), Se.current.delete(d.id), Me.current.delete(d.id);
2396
+ F(`Received terminateApp success for id ${d.id}`), Q(), Me.current.delete(d.id), Re.current.delete(d.id);
2357
2397
  break;
2358
2398
  default:
2359
- w(`Received unhandled message type: ${d.type}`, d);
2399
+ A(`Received unhandled message type: ${d.type}`, d);
2360
2400
  break;
2361
2401
  }
2362
- }, W.current === h) {
2363
- const v = await h.createOffer({
2402
+ }, x.current === h) {
2403
+ const w = await h.createOffer({
2364
2404
  offerToReceiveVideo: !0,
2365
2405
  offerToReceiveAudio: !1
2366
2406
  });
2367
- if (!o() || W.current !== h || (await h.setLocalDescription(v), !o() || W.current !== h))
2407
+ if (!o() || x.current !== h || (await h.setLocalDescription(w), !o() || x.current !== h))
2368
2408
  return;
2369
2409
  o() && T.current === n && n.readyState === WebSocket.OPEN && n.send(
2370
2410
  JSON.stringify({
2371
2411
  type: "offer",
2372
- ...g ? { displayStreams: !0 } : {},
2373
- sdp: v.sdp,
2374
- sessionId: ue
2412
+ ...y ? { displayStreams: !0 } : {},
2413
+ ...z ? { latencyTraceVersion: 1 } : {},
2414
+ sdp: w.sdp,
2415
+ sessionId: le
2375
2416
  })
2376
2417
  ), K("Sent offer");
2377
2418
  }
@@ -2379,24 +2420,24 @@ const Xo = Kn(
2379
2420
  if (!o())
2380
2421
  return;
2381
2422
  const l = n instanceof Error ? n.message : String(n);
2382
- K("Error: " + l), Ze(l, i);
2423
+ K("Error: " + l), et(l, i);
2383
2424
  }
2384
- }, Zt = () => {
2385
- Le.current = !1, ar(!1), Ir(0);
2386
- }, bn = () => {
2387
- we.current += 1, Ct.current = 0, ye.current = !1, Mt(), ht(), Qe(), K("Stopped");
2388
- }, Sn = (e) => {
2389
- e.stopPropagation(), Zt();
2425
+ }, nr = () => {
2426
+ xe.current = !1, dr(!1), kr(0);
2427
+ }, In = () => {
2428
+ Ae.current += 1, Ot.current = 0, Ce.current = !1, It(), Et(), Ze(), K("Stopped");
2429
+ }, Yn = (e) => {
2430
+ e.stopPropagation(), nr();
2390
2431
  };
2391
- pe(() => {
2392
- zt() ? Qt() : Nt();
2393
- }, [Ee]), pe(() => (Ft(!1), Zt(), document.hidden || wr(), document.addEventListener("visibilitychange", Nr), () => {
2394
- Ar(), bn(), document.removeEventListener("visibilitychange", Nr);
2395
- }), [t, c, a, C]);
2396
- const Yr = () => {
2397
- const e = dt();
2432
+ me(() => {
2433
+ tr() ? rr() : Kt();
2434
+ }, [tt]), me(() => ($t(!1), nr(), document.hidden || Sr(), document.addEventListener("visibilitychange", Kr), () => {
2435
+ Mr(), In(), document.removeEventListener("visibilitychange", Kr);
2436
+ }), [t, c, a, g, sn]);
2437
+ const Pr = () => {
2438
+ const e = pt();
2398
2439
  if (!e) {
2399
- pr(null);
2440
+ gr(null);
2400
2441
  return;
2401
2442
  }
2402
2443
  const i = {
@@ -2405,54 +2446,54 @@ const Xo = Kn(
2405
2446
  width: e.actualWidth,
2406
2447
  height: e.actualHeight
2407
2448
  };
2408
- pr(
2449
+ gr(
2409
2450
  (o) => o && o.left === i.left && o.top === i.top && o.width === i.width && o.height === i.height ? o : i
2410
2451
  );
2411
2452
  };
2412
- pe(() => {
2413
- const e = F.current, i = Ut.current, o = ge.current;
2453
+ me(() => {
2454
+ const e = W.current, i = Ft.current, o = _e.current;
2414
2455
  if (!e) return;
2415
2456
  const n = () => {
2416
- if (!wt || !i) {
2417
- lr({}), Yr();
2457
+ if (!St || !i) {
2458
+ hr({}), Pr();
2418
2459
  return;
2419
2460
  }
2420
2461
  const f = i.clientWidth, E = i.clientHeight;
2421
2462
  if (f === 0 || E === 0) return;
2422
- const g = e.videoWidth > e.videoHeight;
2423
- Qr(g), en(
2424
- he === "android" && Mo(e.videoWidth, e.videoHeight)
2463
+ const y = e.videoWidth > e.videoHeight;
2464
+ rn(y), on(
2465
+ de === "android" && ko(e.videoWidth, e.videoHeight)
2425
2466
  );
2426
- const h = g ? Ge.videoPosition.landscape : Ge.videoPosition.portrait;
2467
+ const h = y ? Je.videoPosition.landscape : Je.videoPosition.portrait;
2427
2468
  let R = {};
2428
- h.heightMultiplier ? (R.height = `${E * h.heightMultiplier}px`, R.width = "auto") : h.widthMultiplier && (R.width = `${f * h.widthMultiplier}px`, R.height = "auto"), R.borderRadius = `${g ? E * Ge.videoBorderRadiusMultiplier : f * Ge.videoBorderRadiusMultiplier}px`, lr(R), Yr();
2469
+ h.heightMultiplier ? (R.height = `${E * h.heightMultiplier}px`, R.width = "auto") : h.widthMultiplier && (R.width = `${f * h.widthMultiplier}px`, R.height = "auto"), R.borderRadius = `${y ? E * Je.videoBorderRadiusMultiplier : f * Je.videoBorderRadiusMultiplier}px`, hr(R), Pr();
2429
2470
  }, l = new ResizeObserver(() => {
2430
2471
  n();
2431
2472
  });
2432
2473
  i && l.observe(i), l.observe(e), o && l.observe(o), i && i.addEventListener("load", n), e.addEventListener("loadedmetadata", n), e.addEventListener("resize", n);
2433
- const u = () => ee.current?.bumpActivity();
2474
+ const u = () => te.current?.bumpActivity();
2434
2475
  return e.addEventListener("resize", u), n(), () => {
2435
2476
  l.disconnect(), e.removeEventListener("loadedmetadata", n), e.removeEventListener("resize", n), e.removeEventListener("resize", u), i && i.removeEventListener("load", n);
2436
2477
  };
2437
- }, [Ge, wt]), pe(() => {
2438
- const e = ee.current;
2439
- ut ? e?.start() : (e?.stop(), hr(null), at(null), Dt(null), mr(null), $e(null), Tt.current = null, se.current !== void 0 && (window.cancelAnimationFrame(se.current), se.current = void 0), L("onAxSnapshotChange", Gt.current, null));
2440
- }, [ut]), pe(() => () => {
2441
- se.current !== void 0 && (window.cancelAnimationFrame(se.current), se.current = void 0);
2442
- }, []), pe(() => {
2443
- if (!ut) return;
2478
+ }, [Je, St]), me(() => {
2479
+ const e = te.current;
2480
+ ft ? e?.start() : (e?.stop(), Er(null), dt(null), At(null), yr(null), Xe(null), bt.current = null, ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0), U("onAxSnapshotChange", Qt.current, null));
2481
+ }, [ft]), me(() => () => {
2482
+ ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0);
2483
+ }, []), me(() => {
2484
+ if (!ft) return;
2444
2485
  const e = (i) => {
2445
- i.key === "Escape" && (Vt || qt) && (Dt(null), at(null), $e(null), L("onInspectSelectionChange", qe.current, null));
2486
+ i.key === "Escape" && (zt || jt) && (At(null), dt(null), Xe(null), U("onInspectSelectionChange", Ve.current, null));
2446
2487
  };
2447
2488
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
2448
- }, [ut, Vt, qt]);
2449
- const Mn = () => {
2450
- F.current && F.current.focus();
2489
+ }, [ft, zt, jt]);
2490
+ const Kn = () => {
2491
+ W.current && W.current.focus();
2451
2492
  };
2452
- kn(Pe, () => ({
2493
+ Fn(Ue, () => ({
2453
2494
  openUrl: (e) => {
2454
2495
  if (!T.current || T.current.readyState !== WebSocket.OPEN) {
2455
- w("WebSocket not open, cannot send open_url command via ref.");
2496
+ A("WebSocket not open, cannot send open_url command via ref.");
2456
2497
  return;
2457
2498
  }
2458
2499
  try {
@@ -2461,125 +2502,125 @@ const Xo = Kn(
2461
2502
  JSON.stringify({
2462
2503
  type: "openUrl",
2463
2504
  url: i,
2464
- sessionId: ue
2505
+ sessionId: le
2465
2506
  })
2466
2507
  );
2467
2508
  } catch (i) {
2468
- w("Error decoding or sending URL via ref:", { error: i, url: e }), T.current.send(
2509
+ A("Error decoding or sending URL via ref:", { error: i, url: e }), T.current.send(
2469
2510
  JSON.stringify({
2470
2511
  type: "openUrl",
2471
2512
  url: e,
2472
- sessionId: ue
2513
+ sessionId: le
2473
2514
  })
2474
2515
  );
2475
2516
  }
2476
- ee.current?.bumpActivity();
2517
+ te.current?.bumpActivity();
2477
2518
  },
2478
2519
  sendKeyEvent: (e) => {
2479
2520
  if (!P.current || P.current.readyState !== "open") {
2480
- w("Data channel not ready for imperative key command:", P.current?.readyState);
2521
+ A("Data channel not ready for imperative key command:", P.current?.readyState);
2481
2522
  return;
2482
2523
  }
2483
- const i = Hr[e.code];
2524
+ const i = Br[e.code];
2484
2525
  if (!i) {
2485
- w(`Unknown event.code for imperative command: ${e.code}`);
2526
+ A(`Unknown event.code for imperative command: ${e.code}`);
2486
2527
  return;
2487
2528
  }
2488
2529
  let o = s.META_NONE;
2489
2530
  e.shiftKey && (o |= s.META_SHIFT_ON), e.altKey && (o |= s.META_ALT_ON), e.ctrlKey && (o |= s.META_CTRL_ON), e.metaKey && (o |= s.META_META_ON);
2490
2531
  const n = e.type === "keydown" ? s.ACTION_DOWN : s.ACTION_UP;
2491
- x(
2532
+ F(
2492
2533
  `Sending Imperative Key Command: code=${e.code}, keycode=${i}, action=${n}, meta=${o}`
2493
2534
  );
2494
- const l = pt(
2535
+ const l = gt(
2495
2536
  n,
2496
2537
  i,
2497
2538
  0,
2498
2539
  // repeat count, typically 0 for single presses
2499
2540
  o
2500
2541
  );
2501
- l && le(l);
2542
+ l && fe(l);
2502
2543
  },
2503
2544
  screenshot: (e) => new Promise((i, o) => {
2504
2545
  if (!T.current || T.current.readyState !== WebSocket.OPEN)
2505
- return w("WebSocket not open, cannot send screenshot command."), o(new Error("WebSocket is not connected or connection is not open."));
2546
+ return A("WebSocket not open, cannot send screenshot command."), o(new Error("WebSocket is not connected or connection is not open."));
2506
2547
  const n = `ui-ss-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, l = {
2507
2548
  type: e ? "screenshotDisplay" : "screenshot",
2508
2549
  ...e ? { display: e } : {},
2509
2550
  id: n
2510
2551
  };
2511
- De.current.set(n, i), Oe.current.set(n, o), x("Sending screenshot request:", l);
2552
+ we.current.set(n, i), Oe.current.set(n, o), F("Sending screenshot request:", l);
2512
2553
  try {
2513
2554
  T.current.send(JSON.stringify(l));
2514
2555
  } catch (u) {
2515
- w("Failed to send screenshot request immediately:", u), De.current.delete(n), Oe.current.delete(n), o(u);
2556
+ A("Failed to send screenshot request immediately:", u), we.current.delete(n), Oe.current.delete(n), o(u);
2516
2557
  return;
2517
2558
  }
2518
2559
  setTimeout(() => {
2519
- De.current.has(n) && (w(`Screenshot request timed out for id ${n}`), Oe.current.get(n)?.(new Error("Screenshot request timed out")), De.current.delete(n), Oe.current.delete(n));
2560
+ we.current.has(n) && (A(`Screenshot request timed out for id ${n}`), Oe.current.get(n)?.(new Error("Screenshot request timed out")), we.current.delete(n), Oe.current.delete(n));
2520
2561
  }, 3e4);
2521
2562
  }),
2522
2563
  terminateApp: (e) => new Promise((i, o) => {
2523
2564
  if (!T.current || T.current.readyState !== WebSocket.OPEN)
2524
- return w("WebSocket not open, cannot send terminateApp command."), o(new Error("WebSocket is not connected or connection is not open."));
2565
+ return A("WebSocket not open, cannot send terminateApp command."), o(new Error("WebSocket is not connected or connection is not open."));
2525
2566
  const n = `ui-term-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, l = {
2526
2567
  type: "terminateApp",
2527
2568
  id: n,
2528
2569
  bundleId: e
2529
2570
  };
2530
- Se.current.set(n, i), Me.current.set(n, o), x("Sending terminateApp request:", l);
2571
+ Me.current.set(n, i), Re.current.set(n, o), F("Sending terminateApp request:", l);
2531
2572
  try {
2532
2573
  T.current.send(JSON.stringify(l));
2533
2574
  } catch (u) {
2534
- w("Failed to send terminateApp request immediately:", u), Se.current.delete(n), Me.current.delete(n), o(u);
2575
+ A("Failed to send terminateApp request immediately:", u), Me.current.delete(n), Re.current.delete(n), o(u);
2535
2576
  return;
2536
2577
  }
2537
- ee.current?.bumpActivity(), setTimeout(() => {
2538
- Se.current.has(n) && (w(`terminateApp request timed out for id ${n}`), Me.current.get(n)?.(new Error("terminateApp request timed out")), Se.current.delete(n), Me.current.delete(n));
2578
+ te.current?.bumpActivity(), setTimeout(() => {
2579
+ Me.current.has(n) && (A(`terminateApp request timed out for id ${n}`), Re.current.get(n)?.(new Error("terminateApp request timed out")), Me.current.delete(n), Re.current.delete(n));
2539
2580
  }, 3e4);
2540
2581
  }),
2541
- reconnect: () => Zt(),
2582
+ reconnect: () => nr(),
2542
2583
  refreshAxTree: async () => {
2543
- const e = ee.current;
2584
+ const e = te.current;
2544
2585
  if (!e)
2545
2586
  throw new Error("Inspect mode is not active");
2546
2587
  return e.refresh();
2547
2588
  },
2548
- getAxSnapshot: () => Be.current,
2589
+ getAxSnapshot: () => qe.current,
2549
2590
  setInspectHighlight: (e) => {
2550
- at(e?.id ?? null);
2591
+ dt(e?.id ?? null);
2551
2592
  },
2552
2593
  setInspectSelection: (e) => {
2553
- Dt(e?.id ?? null), $e(e ? Tt.current : null);
2554
- const i = Be.current;
2555
- e && i ? L("onInspectSelectionChange", qe.current, { element: e, snapshot: i }) : L("onInspectSelectionChange", qe.current, null);
2594
+ At(e?.id ?? null), Xe(e ? bt.current : null);
2595
+ const i = qe.current;
2596
+ e && i ? U("onInspectSelectionChange", Ve.current, { element: e, snapshot: i }) : U("onInspectSelectionChange", Ve.current, null);
2556
2597
  },
2557
- getAxStatus: () => ee.current?.getStatus() ?? "idle"
2598
+ getAxStatus: () => te.current?.getStatus() ?? "idle"
2558
2599
  }));
2559
- const Rn = rn && Ne !== null;
2560
- return /* @__PURE__ */ ae(
2600
+ const kn = an && Ie !== null;
2601
+ return /* @__PURE__ */ ue(
2561
2602
  "div",
2562
2603
  {
2563
- ref: ge,
2564
- className: ke("rc-container", r),
2604
+ ref: _e,
2605
+ className: Pe("rc-container", r),
2565
2606
  style: { touchAction: "none" },
2566
- onMouseDown: Te,
2567
- onMouseMove: Te,
2568
- onMouseUp: Te,
2569
- onMouseLeave: Te,
2570
- onTouchStart: Te,
2571
- onTouchMove: Te,
2572
- onTouchEnd: Te,
2573
- onTouchCancel: Te,
2607
+ onMouseDown: De,
2608
+ onMouseMove: De,
2609
+ onMouseUp: De,
2610
+ onMouseLeave: De,
2611
+ onTouchStart: De,
2612
+ onTouchMove: De,
2613
+ onTouchEnd: De,
2614
+ onTouchCancel: De,
2574
2615
  children: [
2575
- Rn && Ne && /* @__PURE__ */ ae(Fr, { children: [
2616
+ kn && Ie && /* @__PURE__ */ ue($r, { children: [
2576
2617
  /* @__PURE__ */ k(
2577
2618
  "div",
2578
2619
  {
2579
2620
  className: "rc-touch-indicator",
2580
2621
  style: {
2581
- left: `${Ne.containerX}px`,
2582
- top: `${Ne.containerY}px`
2622
+ left: `${Ie.containerX}px`,
2623
+ top: `${Ie.containerY}px`
2583
2624
  }
2584
2625
  }
2585
2626
  ),
@@ -2588,142 +2629,142 @@ const Xo = Kn(
2588
2629
  {
2589
2630
  className: "rc-touch-indicator",
2590
2631
  style: {
2591
- left: `${Ne.mirrorContainerX}px`,
2592
- top: `${Ne.mirrorContainerY}px`
2632
+ left: `${Ie.mirrorContainerX}px`,
2633
+ top: `${Ie.mirrorContainerY}px`
2593
2634
  }
2594
2635
  }
2595
2636
  )
2596
2637
  ] }),
2597
- wt && /* @__PURE__ */ k(
2638
+ St && /* @__PURE__ */ k(
2598
2639
  "img",
2599
2640
  {
2600
- ref: Ut,
2601
- src: vr,
2641
+ ref: Ft,
2642
+ src: wr,
2602
2643
  alt: "",
2603
- className: he === "ios" ? ke("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
2644
+ className: de === "ios" ? Pe("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
2604
2645
  draggable: !1
2605
2646
  }
2606
2647
  ),
2607
2648
  /* @__PURE__ */ k(
2608
2649
  "video",
2609
2650
  {
2610
- ref: F,
2611
- className: ke(
2651
+ ref: W,
2652
+ className: Pe(
2612
2653
  "rc-video",
2613
- !wt && "rc-video-frameless",
2614
- !Jr && "rc-video-loading"
2654
+ !St && "rc-video-frameless",
2655
+ !Zr && "rc-video-loading"
2615
2656
  ),
2616
2657
  style: {
2617
- ...tn,
2618
- ...Ce ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
2619
- ...Or ? {
2620
- backgroundImage: `url("${Or}")`,
2658
+ ...cn,
2659
+ ...ye ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
2660
+ ...Dr ? {
2661
+ backgroundImage: `url("${Dr}")`,
2621
2662
  backgroundRepeat: "no-repeat",
2622
2663
  backgroundPosition: "center",
2623
- backgroundSize: Ge.loadingLogoSize
2664
+ backgroundSize: Je.loadingLogoSize
2624
2665
  } : {}
2625
2666
  },
2626
2667
  autoPlay: !0,
2627
2668
  playsInline: !0,
2628
2669
  muted: !0,
2629
- tabIndex: Ce ? -1 : 0,
2630
- onKeyDown: St,
2631
- onKeyUp: St,
2632
- onClick: Mn,
2633
- onLoadedData: Cn,
2670
+ tabIndex: ye ? -1 : 0,
2671
+ onKeyDown: Nt,
2672
+ onKeyUp: Nt,
2673
+ onClick: Kn,
2674
+ onLoadedData: wn,
2634
2675
  onFocus: () => {
2635
- F.current && (F.current.style.outline = "none");
2676
+ W.current && (W.current.style.outline = "none");
2636
2677
  },
2637
2678
  onBlur: () => {
2638
- F.current && (F.current.style.outline = "none");
2679
+ W.current && (W.current.style.outline = "none");
2639
2680
  }
2640
2681
  }
2641
2682
  ),
2642
- Ce && /* @__PURE__ */ k(
2683
+ ye && /* @__PURE__ */ k(
2643
2684
  "video",
2644
2685
  {
2645
- ref: et,
2686
+ ref: nt,
2646
2687
  autoPlay: !0,
2647
2688
  playsInline: !0,
2648
2689
  muted: !0,
2649
2690
  style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
2650
2691
  }
2651
2692
  ),
2652
- Ce && or && /* @__PURE__ */ k(Pn, { fallback: /* @__PURE__ */ k("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ k(
2653
- Do,
2693
+ ye && sr && /* @__PURE__ */ k(Wn, { fallback: /* @__PURE__ */ k("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ k(
2694
+ Mo,
2654
2695
  {
2655
2696
  showFrame: p,
2656
- modelUrl: y,
2657
- outer: F.current,
2658
- inner: et.current,
2659
- state: or,
2660
- setAngle: (e) => xt("setHingeAngle", { angleDegrees: e }),
2661
- setOrientation: (e) => xt("setDuoOrientation", { orientation: e }),
2662
- button: (e, i) => xt("performActions", {
2697
+ modelUrl: C,
2698
+ outer: W.current,
2699
+ inner: nt.current,
2700
+ state: sr,
2701
+ setAngle: (e) => Ht("setHingeAngle", { angleDegrees: e }),
2702
+ setOrientation: (e) => Ht("setDuoOrientation", { orientation: e }),
2703
+ button: (e, i) => Ht("performActions", {
2663
2704
  actions: [{ type: i ? "buttonDown" : "buttonUp", button: e }]
2664
2705
  }),
2665
2706
  touch: (e, i, o, n) => {
2666
2707
  const l = P.current;
2667
- l?.readyState === "open" && l.send(xn(e, i, o, n));
2708
+ l?.readyState === "open" && l.send(Xn(e, i, o, n));
2668
2709
  },
2669
- onKeyDown: St,
2670
- onKeyUp: St
2710
+ onKeyDown: Nt,
2711
+ onKeyUp: Nt
2671
2712
  }
2672
2713
  ) }),
2673
- Ce && cr && /* @__PURE__ */ k("div", { role: "alert", className: "rc-duo-error", children: cr }),
2674
- !Ce && ut && /* @__PURE__ */ k(
2675
- _o,
2714
+ ye && ur && /* @__PURE__ */ k("div", { role: "alert", className: "rc-duo-error", children: ur }),
2715
+ !ye && ft && /* @__PURE__ */ k(
2716
+ So,
2676
2717
  {
2677
- snapshot: fr,
2678
- geometry: on,
2679
- highlightedId: qt,
2680
- selectedId: Vt,
2681
- mode: an,
2682
- cursorPosition: cn,
2683
- frozenCursorPosition: sn,
2718
+ snapshot: mr,
2719
+ geometry: ln,
2720
+ highlightedId: jt,
2721
+ selectedId: zt,
2722
+ mode: hn,
2723
+ cursorPosition: dn,
2724
+ frozenCursorPosition: fn,
2684
2725
  onSelectChange: (e, i) => {
2685
- Dt(e?.id ?? null), e && i ? $e(i) : e || $e(null);
2686
- const o = Be.current;
2687
- e && o ? L("onInspectSelectionChange", qe.current, {
2726
+ At(e?.id ?? null), e && i ? Xe(i) : e || Xe(null);
2727
+ const o = qe.current;
2728
+ e && o ? U("onInspectSelectionChange", Ve.current, {
2688
2729
  element: e,
2689
2730
  snapshot: o
2690
- }) : L("onInspectSelectionChange", qe.current, null);
2731
+ }) : U("onInspectSelectionChange", Ve.current, null);
2691
2732
  },
2692
2733
  onTapElement: (e, i) => {
2693
2734
  if (i) {
2694
- Dr(i.x, i.y);
2735
+ Ar(i.x, i.y);
2695
2736
  return;
2696
2737
  }
2697
- const o = Be.current;
2698
- o && un(e, o);
2738
+ const o = qe.current;
2739
+ o && pn(e, o);
2699
2740
  }
2700
2741
  }
2701
2742
  ),
2702
- zr ? /* @__PURE__ */ ae("div", { className: "rc-terminated", role: "status", children: [
2743
+ tn ? /* @__PURE__ */ ue("div", { className: "rc-terminated", role: "status", children: [
2703
2744
  /* @__PURE__ */ k("div", { className: "rc-terminated-title", children: "Instance terminated" }),
2704
2745
  /* @__PURE__ */ k("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
2705
- ] }) : jr && /* @__PURE__ */ k("button", { type: "button", className: "rc-retry-button", onClick: Sn, children: "Retry" })
2746
+ ] }) : en && /* @__PURE__ */ k("button", { type: "button", className: "rc-retry-button", onClick: Yn, children: "Retry" })
2706
2747
  ]
2707
2748
  }
2708
2749
  );
2709
2750
  }
2710
- ), Io = (r) => typeof r.message == "string" ? r.message : typeof r.error == "string" ? r.error : null, Yo = (r) => typeof r.dataUri == "string" ? { dataUri: r.dataUri } : typeof r.base64 == "string" ? r.base64.startsWith("data:") ? { dataUri: r.base64 } : { dataUri: `data:${r.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${r.base64}` } : null;
2751
+ ), Lo = (r) => typeof r.message == "string" ? r.message : typeof r.error == "string" ? r.error : null, xo = (r) => typeof r.dataUri == "string" ? { dataUri: r.dataUri } : typeof r.base64 == "string" ? r.base64.startsWith("data:") ? { dataUri: r.base64 } : { dataUri: `data:${r.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${r.base64}` } : null;
2711
2752
  export {
2712
- er as A,
2713
- Uo as D,
2714
- Wo as H,
2715
- Xo as R,
2716
- Zn as a,
2717
- eo as b,
2718
- Gr as c,
2719
- Br as d,
2720
- qr as e,
2721
- Qn as f,
2722
- Gn as g,
2723
- $o as h,
2724
- Ho as i,
2725
- Lo as j,
2726
- Fo as k,
2727
- zn as n,
2728
- xo as p
2753
+ or as A,
2754
+ $o as D,
2755
+ Vo as H,
2756
+ jo as R,
2757
+ io as a,
2758
+ co as b,
2759
+ zr as c,
2760
+ Gr as d,
2761
+ Jr as e,
2762
+ oo as f,
2763
+ eo as g,
2764
+ Jo as h,
2765
+ Go as i,
2766
+ Xo as j,
2767
+ qo as k,
2768
+ no as n,
2769
+ Bo as p
2729
2770
  };