@limrun/ui 0.18.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1145 @@
1
+ import { jsx as m, jsxs as $, Fragment as mt } from "react/jsx-runtime";
2
+ import { f as Bt, c as pt, d as jt, b as Gt, h as qt, i as Qt, s as we, j as Zt, e as Jt, k as Y, l as Ge, m as en, o as He, p as E, q as We, a as tn, r as nn, t as p, u as on } from "./core-BhHpU_lr.mjs";
3
+ import { memo as qe, useState as R, useEffect as x, useMemo as Te, useCallback as rn, lazy as cn, forwardRef as sn, useRef as S, useImperativeHandle as an, Suspense as ln } from "react";
4
+ import { createPortal as dn } from "react-dom";
5
+ import './index.css';function gt(d) {
6
+ var r, h, u = "";
7
+ if (typeof d == "string" || typeof d == "number") u += d;
8
+ else if (typeof d == "object") if (Array.isArray(d)) {
9
+ var b = d.length;
10
+ for (r = 0; r < b; r++) d[r] && (h = gt(d[r])) && (u && (u += " "), u += h);
11
+ } else for (h in d) d[h] && (u && (u += " "), u += h);
12
+ return u;
13
+ }
14
+ function de() {
15
+ for (var d, r, h = 0, u = "", b = arguments.length; h < b; h++) (d = arguments[h]) && (r = gt(d)) && (u && (u += " "), u += r);
16
+ return u;
17
+ }
18
+ const un = async (d) => {
19
+ if (!d) return !1;
20
+ try {
21
+ if (typeof navigator < "u" && navigator.clipboard?.writeText)
22
+ return await navigator.clipboard.writeText(d), !0;
23
+ } catch {
24
+ }
25
+ try {
26
+ const r = document.createElement("textarea");
27
+ r.value = d, r.style.position = "fixed", r.style.opacity = "0", document.body.appendChild(r), r.select();
28
+ const h = document.execCommand("copy");
29
+ return document.body.removeChild(r), h;
30
+ } catch {
31
+ return !1;
32
+ }
33
+ }, hn = qe(
34
+ function({ element: r, screen: h, highlighted: u, selected: b, selectable: K, onClick: M }) {
35
+ const T = Bt(r.frame, h);
36
+ if (!T) return null;
37
+ const U = pt(r);
38
+ return /* @__PURE__ */ m(
39
+ "button",
40
+ {
41
+ type: "button",
42
+ className: de("rc-inspect-box", !r.enabled && "rc-inspect-box-disabled"),
43
+ "data-ax-id": r.id,
44
+ "data-ax-path": r.path,
45
+ "data-ax-label": r.label || void 0,
46
+ "data-ax-role": r.role || void 0,
47
+ "data-highlighted": u ? "true" : "false",
48
+ "data-selected": b ? "true" : "false",
49
+ "aria-label": U,
50
+ onClick: (H) => {
51
+ K && (H.preventDefault(), H.stopPropagation(), M(r, { x: H.clientX, y: H.clientY }));
52
+ },
53
+ style: {
54
+ left: `${T.x / h.width * 100}%`,
55
+ top: `${T.y / h.height * 100}%`,
56
+ width: `${T.width / h.width * 100}%`,
57
+ height: `${T.height / h.height * 100}%`
58
+ }
59
+ }
60
+ );
61
+ },
62
+ (d, r) => d.highlighted === r.highlighted && d.selected === r.selected && d.selectable === r.selectable && d.screen.width === r.screen.width && d.screen.height === r.screen.height && d.onClick === r.onClick && jt(d.element, r.element)
63
+ ), fn = 260, mn = 220, pn = 6, gn = 8, vn = qe(function({
64
+ element: r,
65
+ platform: h,
66
+ anchor: u,
67
+ cursorAnchored: b,
68
+ showActions: K,
69
+ onTap: M
70
+ }) {
71
+ const [T, U] = R(null);
72
+ x(() => {
73
+ if (!T) return;
74
+ const A = window.setTimeout(() => U(null), 1100);
75
+ return () => window.clearTimeout(A);
76
+ }, [T]);
77
+ const H = Te(() => {
78
+ const A = fn, F = mn, X = pn, g = gn, Q = typeof window < "u" ? window.innerWidth : 1024, oe = typeof window < "u" ? window.innerHeight : 768, Z = u.x + X + A <= Q - g, J = u.y - X - F >= g;
79
+ let ue = Z ? u.x + X : u.x - X, be = J ? u.y - X : u.y + X;
80
+ const Oe = `translate(${Z ? "0" : "-100%"}, ${J ? "-100%" : "0"})`;
81
+ return ue = Math.max(g + (Z ? 0 : A), Math.min(Q - g - (Z ? A : 0), ue)), be = Math.max(g + (J ? F : 0), Math.min(oe - g - (J ? 0 : F), be)), { left: `${ue}px`, top: `${be}px`, transform: Oe };
82
+ }, [u.x, u.y]), O = Te(() => Gt(r, h), [r, h]), W = h === "ios" ? r.selectors.AXUniqueId : r.selectors.resourceId, B = h === "ios" ? "AXUniqueId" : "resourceId", q = rn(async (A, F) => {
83
+ if (!A) return;
84
+ await un(A) && U(F);
85
+ }, []), P = qt(r), Ae = r.label || r.value || P, ne = pt(r);
86
+ return dn(
87
+ /* @__PURE__ */ $(
88
+ "div",
89
+ {
90
+ className: "rc-inspect-card",
91
+ "data-cursor-anchored": b ? "true" : "false",
92
+ style: H,
93
+ onClick: (A) => A.stopPropagation(),
94
+ onMouseDown: (A) => A.stopPropagation(),
95
+ onMouseMove: (A) => A.stopPropagation(),
96
+ children: [
97
+ /* @__PURE__ */ $("div", { className: "rc-inspect-card-header", children: [
98
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-role", children: P }),
99
+ !r.enabled && /* @__PURE__ */ m("span", { className: "rc-inspect-card-tag", children: "disabled" }),
100
+ r.focused && /* @__PURE__ */ m("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
101
+ ] }),
102
+ /* @__PURE__ */ m("p", { className: "rc-inspect-card-title", title: ne, children: Ae }),
103
+ W && /* @__PURE__ */ $("div", { className: "rc-inspect-card-row", children: [
104
+ /* @__PURE__ */ $("span", { className: "rc-inspect-card-row-label", children: [
105
+ B,
106
+ ":"
107
+ ] }),
108
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-value", children: W })
109
+ ] }),
110
+ r.value && r.value !== r.label && /* @__PURE__ */ $("div", { className: "rc-inspect-card-row", children: [
111
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-label", children: "value:" }),
112
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-value", children: r.value })
113
+ ] }),
114
+ /* @__PURE__ */ $("div", { className: "rc-inspect-card-row", children: [
115
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
116
+ /* @__PURE__ */ $("span", { className: "rc-inspect-card-row-value", children: [
117
+ Math.round(r.frame.width),
118
+ "×",
119
+ Math.round(r.frame.height),
120
+ " @ ",
121
+ Math.round(r.frame.x),
122
+ ",",
123
+ Math.round(r.frame.y)
124
+ ] })
125
+ ] }),
126
+ K && /* @__PURE__ */ $("div", { className: "rc-inspect-card-actions", children: [
127
+ /* @__PURE__ */ m(
128
+ "button",
129
+ {
130
+ type: "button",
131
+ className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
132
+ onClick: () => M(r, u),
133
+ children: "Tap"
134
+ }
135
+ ),
136
+ /* @__PURE__ */ m(
137
+ "button",
138
+ {
139
+ type: "button",
140
+ className: de("rc-inspect-card-btn", T === "selector" && "rc-inspect-card-btn-copied"),
141
+ disabled: !O,
142
+ title: O ?? "No usable selector for this element",
143
+ onClick: () => q(O ?? void 0, "selector"),
144
+ children: T === "selector" ? "Copied!" : "Copy selector"
145
+ }
146
+ ),
147
+ /* @__PURE__ */ m(
148
+ "button",
149
+ {
150
+ type: "button",
151
+ className: de("rc-inspect-card-btn", T === "id" && "rc-inspect-card-btn-copied"),
152
+ disabled: !W,
153
+ title: W ?? `No ${B}`,
154
+ onClick: () => q(W, "id"),
155
+ children: T === "id" ? "Copied!" : `Copy ${B}`
156
+ }
157
+ )
158
+ ] })
159
+ ]
160
+ }
161
+ ),
162
+ document.body
163
+ );
164
+ }), yn = qe(function({
165
+ snapshot: r,
166
+ geometry: h,
167
+ highlightedId: u,
168
+ selectedId: b,
169
+ mode: K,
170
+ cursorPosition: M,
171
+ frozenCursorPosition: T,
172
+ onSelectChange: U,
173
+ onTapElement: H
174
+ }) {
175
+ const O = K === "select", W = O ? u !== null && u !== b : u !== null, B = O ? u ?? b : u, q = Te(() => {
176
+ const g = /* @__PURE__ */ new Map();
177
+ if (!r) return g;
178
+ for (const Q of r.elements) g.set(Q.id, Q);
179
+ return g;
180
+ }, [r]), P = Te(() => B ? q.get(B) ?? null : null, [B, q]);
181
+ if (!(!!r && !!h && r.screen.width > 0 && r.screen.height > 0 && r.elements.length > 0)) return null;
182
+ const ne = W ? M : T ?? M, A = W, F = O && !W && b !== null, X = (g) => {
183
+ O && g.target === g.currentTarget && U(null, null);
184
+ };
185
+ return /* @__PURE__ */ $(mt, { children: [
186
+ /* @__PURE__ */ m(
187
+ "div",
188
+ {
189
+ className: de("rc-inspect-overlay", O && "rc-inspect-overlay-select"),
190
+ style: {
191
+ left: `${h.left}px`,
192
+ top: `${h.top}px`,
193
+ width: `${h.width}px`,
194
+ height: `${h.height}px`
195
+ },
196
+ onClick: X,
197
+ children: r.elements.map((g) => /* @__PURE__ */ m(
198
+ hn,
199
+ {
200
+ element: g,
201
+ screen: r.screen,
202
+ highlighted: g.id === u,
203
+ selected: g.id === b,
204
+ selectable: O,
205
+ onClick: U
206
+ },
207
+ g.id
208
+ ))
209
+ }
210
+ ),
211
+ P && ne && /* @__PURE__ */ m(
212
+ vn,
213
+ {
214
+ element: P,
215
+ platform: r.platform,
216
+ anchor: ne,
217
+ cursorAnchored: A,
218
+ showActions: F,
219
+ onTap: H
220
+ }
221
+ )
222
+ ] });
223
+ }), wn = cn(() => import("./duo-view-tndcvbIi.mjs").then((d) => d.d)), xe = (d) => Object.entries(p).find(
224
+ ([h, u]) => h.startsWith("ACTION_") && u === d
225
+ )?.[0] ?? String(d), ht = 1920, ft = 1200, Tn = (d, r) => d === ht && r === ft || d === ft && r === ht, An = {
226
+ ios: {
227
+ videoBorderRadiusMultiplier: 0.15,
228
+ loadingLogoSize: "20%",
229
+ // Video position as percentage of frame dimensions
230
+ videoPosition: {
231
+ portrait: { heightMultiplier: 0.9678 },
232
+ landscape: { widthMultiplier: 0.9678 }
233
+ }
234
+ },
235
+ android: {
236
+ videoBorderRadiusMultiplier: 0.13,
237
+ loadingLogoSize: "40%",
238
+ // Video position as percentage of frame dimensions
239
+ videoPosition: {
240
+ portrait: { heightMultiplier: 0.967 },
241
+ landscape: { widthMultiplier: 0.962 }
242
+ }
243
+ }
244
+ };
245
+ function bn(d) {
246
+ const r = d.code, h = nn[r];
247
+ if (!h)
248
+ return Ge(`Unknown event.code: ${r}, key: ${d.key}`), null;
249
+ let u = E.META_NONE;
250
+ const b = r >= "KeyA" && r <= "KeyZ", K = d.getModifierState("CapsLock"), M = d.shiftKey;
251
+ let T = M;
252
+ return b && (T = M !== K), T && (u |= E.META_SHIFT_ON), d.ctrlKey && (u |= E.META_CTRL_ON), d.altKey && (u |= E.META_ALT_ON), d.metaKey && (u |= E.META_META_ON), { keycode: h, metaState: u };
253
+ }
254
+ const In = sn(
255
+ ({
256
+ className: d,
257
+ url: r,
258
+ token: h,
259
+ sessionId: u,
260
+ openUrl: b,
261
+ showFrame: K = !0,
262
+ deviceModel: M,
263
+ duoModelUrl: T,
264
+ autoReconnect: U = !1,
265
+ jitterBufferTargetMs: H,
266
+ onPlaybackStats: O,
267
+ onTerminated: W,
268
+ assets: B,
269
+ onConnectionStateChange: q,
270
+ inspectMode: P,
271
+ onAxSnapshotChange: Ae,
272
+ onInspectSelectionChange: ne,
273
+ onAxStatusChange: A,
274
+ axPollIntervalMs: F,
275
+ axMaxBackoffMs: X,
276
+ androidElementTreeOptions: g,
277
+ onCameraDemandChange: Q,
278
+ onCameraStats: oe,
279
+ onTrace: Z,
280
+ microphoneEnabled: J = !1,
281
+ onMicrophoneStateChange: ue
282
+ }, be) => {
283
+ const Ce = S(null), I = S(null), Oe = S(null), [vt, yt] = R(!1), z = M === "iphone-duo" || vt, _e = S(null), [Qe, wt] = R(null), [Ze, Tt] = R(), [At, bt] = R(!1), [Ct, Nt] = R(!1), [Rt, Et] = R(!1), [Je, et] = R(!1), [It, tt] = R(!1), [Mt, $e] = R({}), Ue = S(null), _ = S(/* @__PURE__ */ new Map()), re = S(!1), [Ot, _t] = R(!1), C = S(null), he = S(null), Ne = S({
284
+ handle: () => {
285
+ },
286
+ end: () => {
287
+ }
288
+ }), [ie, Se] = R(null), [nt, Fe] = R(null), [ze, Re] = R(null), [Ke, Pe] = R(null), [St, ot] = R(null), [Pt, rt] = R(null), ke = S(null), j = S(void 0), it = (e) => {
289
+ ke.current = e, j.current === void 0 && (j.current = window.requestAnimationFrame(() => {
290
+ j.current = void 0, rt(ke.current);
291
+ }));
292
+ }, [kt, fe] = R(null), ce = S(null);
293
+ ce.current = nt;
294
+ const me = S(ne);
295
+ me.current = ne;
296
+ const Ee = P === !0 || P === "hover-only", Yt = P === "hover-only" ? "hover-only" : "select", ee = Te(() => Qt(r), [r]), Xt = Te(
297
+ () => u || Array.from(crypto.getRandomValues(new Uint32Array(4)), (e) => e.toString(36)).join(""),
298
+ [u]
299
+ ), pe = An[ee], Ie = B?.[ee], ct = ee === "android" && It ? Je ? Ie?.tabletFrameLandscape : Ie?.tabletFrame : Je ? Ie?.frameLandscape : Ie?.frame, st = Ie?.loadingLogo, Ye = !z && K && !!ct, v = S(null), V = (e) => v.current?.sendControl(e), Ve = (e, n) => v.current?.sendDuoControl(e, n) ?? Promise.reject(new Error("Simulator disconnected")), at = -10, lt = (e, n) => {
300
+ const o = Me();
301
+ if (!o) return;
302
+ const t = ve(o, e, n);
303
+ if (!t) return;
304
+ const { videoX: c, videoY: s, videoWidth: i, videoHeight: a } = t, l = We(
305
+ p.ACTION_DOWN,
306
+ at,
307
+ i,
308
+ a,
309
+ c,
310
+ s,
311
+ 1,
312
+ p.BUTTON_PRIMARY,
313
+ p.BUTTON_PRIMARY
314
+ );
315
+ l && V(l), window.setTimeout(() => {
316
+ const f = We(
317
+ p.ACTION_UP,
318
+ at,
319
+ i,
320
+ a,
321
+ c,
322
+ s,
323
+ 0,
324
+ p.BUTTON_PRIMARY,
325
+ p.BUTTON_PRIMARY
326
+ );
327
+ f && V(f);
328
+ }, 60);
329
+ }, Dt = (e, n) => {
330
+ const o = Me();
331
+ if (!o || n.screen.width <= 0 || n.screen.height <= 0) return;
332
+ const t = e.frame.x + e.frame.width / 2, c = e.frame.y + e.frame.height / 2, s = t / n.screen.width * o.actualWidth, i = c / n.screen.height * o.actualHeight, a = o.videoRect.left + o.offsetX + s, l = o.videoRect.top + o.offsetY + i;
333
+ lt(a, l);
334
+ }, Xe = -1, De = -2, se = -3, ge = (e, n, o, t, c, s) => {
335
+ const i = We(
336
+ e,
337
+ n,
338
+ o,
339
+ t,
340
+ c,
341
+ s,
342
+ 1,
343
+ // pressure
344
+ p.BUTTON_PRIMARY,
345
+ p.BUTTON_PRIMARY
346
+ );
347
+ i && (Y("[rc-touch] sendSingleTouch", {
348
+ action: e,
349
+ actionName: xe(e),
350
+ pointerId: n,
351
+ x: c,
352
+ y: s,
353
+ video: { width: o, height: t }
354
+ }), V(i));
355
+ }, ae = (e, n, o) => {
356
+ if (!o) return;
357
+ const { videoX: t, videoY: c, videoWidth: s, videoHeight: i } = o;
358
+ let a = null, l = null, f = 1;
359
+ const N = p.BUTTON_PRIMARY;
360
+ switch (n) {
361
+ case "down":
362
+ e !== se && Ne.current.end(), a = _.current.size === 0 ? p.ACTION_DOWN : p.ACTION_POINTER_DOWN, l = { x: t, y: c }, _.current.set(e, l), e === -1 && I.current?.focus();
363
+ break;
364
+ case "move":
365
+ _.current.has(e) && (a = p.ACTION_MOVE, l = { x: t, y: c }, _.current.set(e, l));
366
+ break;
367
+ case "up":
368
+ case "cancel":
369
+ _.current.has(e) && (l = _.current.get(e), _.current.delete(e), n === "cancel" ? a = p.ACTION_CANCEL : a = _.current.size === 0 ? p.ACTION_UP : p.ACTION_POINTER_UP);
370
+ break;
371
+ }
372
+ if (a !== null && l !== null) {
373
+ Y("[rc-touch][mouse->touch] sending", {
374
+ pointerId: e,
375
+ eventType: n,
376
+ action: a,
377
+ actionName: xe(a),
378
+ positionToSend: l,
379
+ video: { width: s, height: i },
380
+ altHeld: re.current,
381
+ activePointersAfter: Array.from(_.current.entries()).map(([k, w]) => ({
382
+ id: k,
383
+ x: w.x,
384
+ y: w.y
385
+ }))
386
+ });
387
+ const y = We(
388
+ a,
389
+ e,
390
+ s,
391
+ i,
392
+ l.x,
393
+ l.y,
394
+ f,
395
+ N,
396
+ N
397
+ );
398
+ y && (Y("[rc-touch][mouse->touch] buffer", {
399
+ pointerId: e,
400
+ actionName: xe(a),
401
+ byteLength: y.byteLength
402
+ }), V(y));
403
+ } else (n === "up" || n === "cancel") && _.current.delete(e);
404
+ }, Be = (e) => {
405
+ if (re.current !== e && (re.current = e, _t(e), e || Se(null), Y("[rc-touch][alt] updateAltHeld", {
406
+ nextHeld: e,
407
+ activePointerIds: Array.from(_.current.keys())
408
+ }), ee === "ios" && v.current?.getState().controlReady)) {
409
+ const n = e ? E.ACTION_DOWN : E.ACTION_UP, o = He(
410
+ n,
411
+ E.KEYCODE_ALT_LEFT,
412
+ 0,
413
+ E.META_NONE
414
+ );
415
+ Y("[rc-touch][alt] sending Indigo modifier keycode", {
416
+ action: n,
417
+ keycode: E.KEYCODE_ALT_LEFT
418
+ }), o && V(o);
419
+ }
420
+ }, Me = () => {
421
+ const e = I.current, n = Ce.current;
422
+ if (!e || !n) return null;
423
+ const o = e.videoWidth, t = e.videoHeight;
424
+ if (!o || !t) return null;
425
+ const c = e.getBoundingClientRect(), s = n.getBoundingClientRect(), i = c.width, a = c.height, l = o / t, f = i / a;
426
+ let N = i, y = a;
427
+ l > f ? y = i / l : N = a * l;
428
+ const k = (i - N) / 2, w = (a - y) / 2;
429
+ return {
430
+ videoWidth: o,
431
+ videoHeight: t,
432
+ videoRect: c,
433
+ containerRect: s,
434
+ actualWidth: N,
435
+ actualHeight: y,
436
+ offsetX: k,
437
+ offsetY: w
438
+ };
439
+ }, ve = (e, n, o) => {
440
+ const t = n - e.videoRect.left - e.offsetX, c = o - e.videoRect.top - e.offsetY, s = Math.max(0, Math.min(e.actualWidth, t)), i = Math.max(0, Math.min(e.actualHeight, c)), a = Math.max(
441
+ 0,
442
+ Math.min(e.videoWidth, s / e.actualWidth * e.videoWidth)
443
+ ), l = Math.max(
444
+ 0,
445
+ Math.min(e.videoHeight, i / e.actualHeight * e.videoHeight)
446
+ );
447
+ return {
448
+ videoX: a,
449
+ videoY: l,
450
+ videoWidth: e.videoWidth,
451
+ videoHeight: e.videoHeight
452
+ };
453
+ }, Lt = (e, n, o) => {
454
+ const t = n - e.videoRect.left - e.offsetX, c = o - e.videoRect.top - e.offsetY, s = Math.max(0, Math.min(e.actualWidth, t)), i = Math.max(0, Math.min(e.actualHeight, c)), a = Math.max(
455
+ 0,
456
+ Math.min(e.videoWidth, s / e.actualWidth * e.videoWidth)
457
+ ), l = Math.max(
458
+ 0,
459
+ Math.min(e.videoHeight, i / e.actualHeight * e.videoHeight)
460
+ ), f = e.videoWidth - a, N = e.videoHeight - l, y = e.videoRect.left + e.offsetX, k = e.videoRect.top + e.offsetY, w = y - e.containerRect.left + s, G = k - e.containerRect.top + i, le = y - e.containerRect.left + (e.actualWidth - s), L = k - e.containerRect.top + (e.actualHeight - i);
461
+ return {
462
+ containerX: w,
463
+ containerY: G,
464
+ mirrorContainerX: le,
465
+ mirrorContainerY: L,
466
+ videoX: a,
467
+ videoY: l,
468
+ mirrorVideoX: f,
469
+ mirrorVideoY: N,
470
+ videoWidth: e.videoWidth,
471
+ videoHeight: e.videoHeight
472
+ };
473
+ }, Ht = (e, n, o, t, c, s, i) => {
474
+ const a = on(e, n, o, t, c, s, i);
475
+ Y("[rc-touch2] sendTwoFingerMessage (iOS)", {
476
+ actionName: xe(e),
477
+ video: { width: n, height: o },
478
+ p0: { x: t, y: c },
479
+ p1: { x: s, y: i },
480
+ byteLength: a.byteLength
481
+ }), V(a);
482
+ }, ye = (e, n, o, t, c, s, i, a, l) => {
483
+ if (Y("[rc-touch2] applyTwoFingerEvent", {
484
+ platform: ee,
485
+ eventType: e,
486
+ video: { width: n, height: o },
487
+ p0: { x: t, y: c, id: a },
488
+ p1: { x: s, y: i, id: l }
489
+ }), e === "down" && Ne.current.end(), ee === "ios") {
490
+ const f = e === "down" ? p.ACTION_DOWN : e === "move" ? p.ACTION_MOVE : p.ACTION_UP;
491
+ Ht(f, n, o, t, c, s, i);
492
+ } else
493
+ e === "down" ? (ge(p.ACTION_DOWN, a, n, o, t, c), ge(p.ACTION_POINTER_DOWN, l, n, o, s, i)) : e === "move" ? (ge(p.ACTION_MOVE, a, n, o, t, c), ge(p.ACTION_MOVE, l, n, o, s, i)) : (ge(p.ACTION_POINTER_UP, l, n, o, s, i), ge(p.ACTION_UP, a, n, o, t, c));
494
+ }, Wt = (e, n, o) => {
495
+ if (!re.current) {
496
+ ie !== null && Se(null);
497
+ return;
498
+ }
499
+ const t = Lt(e, n, o);
500
+ Se(t);
501
+ }, xt = (e, n, o) => {
502
+ const t = ce.current;
503
+ if (!t || t.screen.width <= 0 || t.screen.height <= 0) return null;
504
+ const c = n - e.videoRect.left - e.offsetX, s = o - e.videoRect.top - e.offsetY;
505
+ if (c < 0 || s < 0 || c > e.actualWidth || s > e.actualHeight) return null;
506
+ const i = c / e.actualWidth * t.screen.width, a = s / e.actualHeight * t.screen.height;
507
+ return tn(t, i, a);
508
+ }, te = (e) => {
509
+ if (z) return;
510
+ e.preventDefault(), e.stopPropagation();
511
+ const n = Me();
512
+ if ((P === !0 || P === "hover-only") && !("touches" in e))
513
+ if (e.type === "mousemove") {
514
+ if (it({ x: e.clientX, y: e.clientY }), n) {
515
+ const t = xt(n, e.clientX, e.clientY);
516
+ Re(t?.id ?? null);
517
+ }
518
+ } else e.type === "mouseleave" && (it(null), Re(null));
519
+ if (P !== !0 && (!("touches" in e) && n && (e.type === "mousemove" ? Wt(n, e.clientX, e.clientY) : e.type === "mouseleave" && Se(null)), !(!v.current?.getState().controlReady || !I.current || !n)))
520
+ if ("touches" in e) {
521
+ const t = e.touches, c = e.changedTouches;
522
+ let s;
523
+ switch (e.type) {
524
+ case "touchstart":
525
+ s = "down";
526
+ break;
527
+ case "touchmove":
528
+ s = "move";
529
+ break;
530
+ case "touchend":
531
+ s = "up";
532
+ break;
533
+ case "touchcancel":
534
+ s = "cancel";
535
+ break;
536
+ default:
537
+ return;
538
+ }
539
+ if (t.length === 2) {
540
+ const i = t[0], a = t[1], l = ve(n, i.clientX, i.clientY), f = ve(n, a.clientX, a.clientY);
541
+ if (!l || !f) return;
542
+ C.current ? C.current.source === "real-touch" && (C.current.finger0 = { x: l.videoX, y: l.videoY }, C.current.finger1 = { x: f.videoX, y: f.videoY }, ye(
543
+ "move",
544
+ l.videoWidth,
545
+ l.videoHeight,
546
+ l.videoX,
547
+ l.videoY,
548
+ f.videoX,
549
+ f.videoY,
550
+ C.current.pointerId0,
551
+ C.current.pointerId1
552
+ )) : (C.current = {
553
+ finger0: { x: l.videoX, y: l.videoY },
554
+ finger1: { x: f.videoX, y: f.videoY },
555
+ videoSize: { width: l.videoWidth, height: l.videoHeight },
556
+ source: "real-touch",
557
+ pointerId0: i.identifier,
558
+ pointerId1: a.identifier
559
+ }, ye(
560
+ "down",
561
+ l.videoWidth,
562
+ l.videoHeight,
563
+ l.videoX,
564
+ l.videoY,
565
+ f.videoX,
566
+ f.videoY,
567
+ i.identifier,
568
+ a.identifier
569
+ ));
570
+ } else if (t.length < 2 && C.current?.source === "real-touch") {
571
+ const i = C.current;
572
+ ye(
573
+ "up",
574
+ i.videoSize.width,
575
+ i.videoSize.height,
576
+ i.finger0.x,
577
+ i.finger0.y,
578
+ i.finger1.x,
579
+ i.finger1.y,
580
+ i.pointerId0,
581
+ i.pointerId1
582
+ ), C.current = null;
583
+ return;
584
+ } else {
585
+ if (t.length > 2)
586
+ return;
587
+ {
588
+ const i = c[0];
589
+ if (i) {
590
+ const a = ve(n, i.clientX, i.clientY);
591
+ ae(i.identifier, s, a);
592
+ }
593
+ }
594
+ }
595
+ } else {
596
+ let c = null;
597
+ const s = C.current?.source === "alt-mouse";
598
+ switch (e.type) {
599
+ case "mousedown":
600
+ e.button === 0 && (c = "down");
601
+ break;
602
+ case "mousemove":
603
+ (s || _.current.has(-1)) && (c = "move");
604
+ break;
605
+ case "mouseup":
606
+ e.button === 0 && (c = "up");
607
+ break;
608
+ case "mouseleave":
609
+ (s || _.current.has(-1)) && (c = "up");
610
+ break;
611
+ }
612
+ if (c) {
613
+ const i = ve(n, e.clientX, e.clientY);
614
+ if (!i)
615
+ return;
616
+ Y("[rc-touch][mouse] event", {
617
+ domType: e.type,
618
+ eventType: c,
619
+ button: e.button,
620
+ buttons: e.buttons,
621
+ client: { x: e.clientX, y: e.clientY },
622
+ altHeldRef: re.current,
623
+ inTwoFingerMode: s,
624
+ geometry: {
625
+ videoX: i.videoX,
626
+ videoY: i.videoY,
627
+ videoWidth: i.videoWidth,
628
+ videoHeight: i.videoHeight
629
+ },
630
+ activePointerIds: Array.from(_.current.keys())
631
+ }), re.current || s ? $t(c, i) : ae(-1, c, i);
632
+ }
633
+ }
634
+ }, $t = (e, n) => {
635
+ const { videoX: o, videoY: t, videoWidth: c, videoHeight: s } = n, i = c - o, a = s - t;
636
+ if (e === "down") {
637
+ C.current = {
638
+ finger0: { x: o, y: t },
639
+ finger1: { x: i, y: a },
640
+ videoSize: { width: c, height: s },
641
+ source: "alt-mouse",
642
+ pointerId0: Xe,
643
+ pointerId1: De
644
+ }, I.current?.focus(), ye(
645
+ "down",
646
+ c,
647
+ s,
648
+ o,
649
+ t,
650
+ i,
651
+ a,
652
+ Xe,
653
+ De
654
+ );
655
+ return;
656
+ }
657
+ if (e === "move") {
658
+ C.current?.source === "alt-mouse" && (C.current.finger0 = { x: o, y: t }, C.current.finger1 = { x: i, y: a }, ye(
659
+ "move",
660
+ c,
661
+ s,
662
+ o,
663
+ t,
664
+ i,
665
+ a,
666
+ Xe,
667
+ De
668
+ ));
669
+ return;
670
+ }
671
+ if (e === "up" || e === "cancel") {
672
+ const l = C.current;
673
+ if (l?.source === "alt-mouse") {
674
+ const { finger0: f, finger1: N, videoSize: y } = l;
675
+ ye(
676
+ "up",
677
+ y.width,
678
+ y.height,
679
+ f.x,
680
+ f.y,
681
+ N.x,
682
+ N.y,
683
+ Xe,
684
+ De
685
+ ), C.current = null;
686
+ }
687
+ return;
688
+ }
689
+ }, Ut = 150, dt = () => {
690
+ const e = he.current;
691
+ e && (window.clearTimeout(e.endTimer), ae(se, "up", e.pos), he.current = null);
692
+ }, Ft = (e) => {
693
+ if (e.ctrlKey || re.current || C.current) return;
694
+ const n = _.current.size;
695
+ if (n > 1 || n === 1 && !_.current.has(se)) return;
696
+ const o = Me();
697
+ if (!o) return;
698
+ const t = e.clientX - o.videoRect.left - o.offsetX, c = e.clientY - o.videoRect.top - o.offsetY;
699
+ if (t < 0 || t > o.actualWidth || c < 0 || c > o.actualHeight)
700
+ return;
701
+ const s = ve(o, e.clientX, e.clientY);
702
+ if (!s) return;
703
+ e.preventDefault();
704
+ const i = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), a = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), l = -e.deltaX * i, f = -e.deltaY * a, N = (L) => {
705
+ window.clearTimeout(L.endTimer), L.endTimer = window.setTimeout(dt, Ut);
706
+ };
707
+ if (l === 0 && f === 0) {
708
+ he.current && N(he.current);
709
+ return;
710
+ }
711
+ const y = () => ({
712
+ videoWidth: s.videoWidth,
713
+ videoHeight: s.videoHeight,
714
+ videoX: Math.abs(l) > Math.abs(f) ? Math.min(Math.max(s.videoX, s.videoWidth * 0.2), s.videoWidth * 0.8) : s.videoX,
715
+ videoY: Math.abs(f) >= Math.abs(l) ? Math.min(Math.max(s.videoY, s.videoHeight * 0.2), s.videoHeight * 0.8) : s.videoY
716
+ }), k = (L) => ({
717
+ ...L,
718
+ videoX: Math.min(Math.max(L.videoX + l, 0), L.videoWidth),
719
+ videoY: Math.min(Math.max(L.videoY + f, 0), L.videoHeight)
720
+ });
721
+ let w = he.current;
722
+ if (w)
723
+ window.clearTimeout(w.endTimer);
724
+ else {
725
+ const L = y();
726
+ ae(se, "down", L), w = { pos: L, endTimer: 0 }, he.current = w;
727
+ }
728
+ let G = w.pos, le = k(G);
729
+ le.videoX === G.videoX && le.videoY === G.videoY && (ae(se, "up", G), G = y(), ae(se, "down", G), le = k(G)), ae(se, "move", le), w.pos = le, N(w);
730
+ };
731
+ x(() => {
732
+ Ne.current = { handle: Ft, end: dt };
733
+ }), x(() => {
734
+ const e = Ce.current;
735
+ if (!e) return;
736
+ const n = (o) => Ne.current.handle(o);
737
+ return e.addEventListener("wheel", n, { passive: !1 }), () => {
738
+ Ne.current.end(), e.removeEventListener("wheel", n);
739
+ };
740
+ }, []), x(() => {
741
+ const e = (t) => {
742
+ t.key === "Alt" && Be(!0);
743
+ }, n = (t) => {
744
+ t.key === "Alt" && Be(!1);
745
+ }, o = () => {
746
+ Be(!1);
747
+ };
748
+ return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", n, !0), window.addEventListener("blur", o), () => {
749
+ window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", n, !0), window.removeEventListener("blur", o);
750
+ };
751
+ }, []);
752
+ const Le = (e) => {
753
+ e.preventDefault(), e.stopPropagation();
754
+ const n = document.activeElement === I.current || z && document.activeElement === e.currentTarget;
755
+ if (Y("Keyboard event:", {
756
+ type: e.type,
757
+ key: e.key,
758
+ keyCode: e.keyCode,
759
+ code: e.code,
760
+ target: e.target.tagName,
761
+ focused: n
762
+ }), !n) {
763
+ Ge("Simulator input not focused, skipping keyboard event");
764
+ return;
765
+ }
766
+ if (!v.current?.getState().controlReady) {
767
+ Ge("Data channel not ready for keyboard event:", v.current?.getState().connection);
768
+ return;
769
+ }
770
+ if (e.type === "keydown") {
771
+ if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
772
+ Y("Paste shortcut detected"), navigator.clipboard.readText().then((t) => {
773
+ if (t) {
774
+ Y(
775
+ "Pasting text via SET_CLIPBOARD:",
776
+ t.substring(0, 20) + (t.length > 20 ? "..." : "")
777
+ );
778
+ const c = en(t, !0);
779
+ V(c);
780
+ }
781
+ }).catch((t) => {
782
+ console.error("Failed to read clipboard contents: ", t);
783
+ });
784
+ return;
785
+ }
786
+ if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
787
+ Y("Menu shortcut detected");
788
+ const t = He(
789
+ E.ACTION_DOWN,
790
+ E.MENU,
791
+ 0,
792
+ E.META_NONE
793
+ // Modifiers are handled by the shortcut check, not passed down
794
+ );
795
+ V(t);
796
+ const c = He(
797
+ E.ACTION_UP,
798
+ E.MENU,
799
+ 0,
800
+ E.META_NONE
801
+ );
802
+ V(c);
803
+ return;
804
+ }
805
+ }
806
+ const o = bn(e);
807
+ if (o) {
808
+ const { keycode: t, metaState: c } = o, s = e.type === "keydown" ? E.ACTION_DOWN : E.ACTION_UP;
809
+ Y(`Sending Keycode: key=${e.key}, code=${t}, action=${s}, meta=${c}`);
810
+ const i = He(
811
+ s,
812
+ t,
813
+ 0,
814
+ // repeat count, typically 0 for single presses
815
+ c
816
+ );
817
+ V(i);
818
+ } else
819
+ Y(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
820
+ }, zt = (e) => {
821
+ e.stopPropagation(), v.current?.reconnect();
822
+ }, D = S({
823
+ onAxSnapshotChange: Ae,
824
+ onAxStatusChange: A,
825
+ onCameraDemandChange: Q,
826
+ onCameraStats: oe,
827
+ onMicrophoneStateChange: ue,
828
+ onTrace: Z,
829
+ onTerminated: W,
830
+ onConnectionStateChange: q,
831
+ onPlaybackStats: O
832
+ });
833
+ D.current = {
834
+ onAxSnapshotChange: Ae,
835
+ onAxStatusChange: A,
836
+ onCameraDemandChange: Q,
837
+ onCameraStats: oe,
838
+ onMicrophoneStateChange: ue,
839
+ onTrace: Z,
840
+ onTerminated: W,
841
+ onConnectionStateChange: q,
842
+ onPlaybackStats: O
843
+ };
844
+ const je = !!Z;
845
+ x(() => {
846
+ Ue.current = null, et(!1), tt(!1), $e({});
847
+ }, [r, M]), x(() => {
848
+ let e = !0;
849
+ ce.current !== null && (ce.current = null, Fe(null), we("onAxSnapshotChange", D.current.onAxSnapshotChange, null));
850
+ const n = Zt({
851
+ url: r,
852
+ token: h,
853
+ sessionId: Xt,
854
+ deviceModel: M,
855
+ autoReconnect: U,
856
+ jitterBufferTargetMs: H,
857
+ openUrl: b,
858
+ inspectMode: P,
859
+ axPollIntervalMs: F,
860
+ axMaxBackoffMs: X,
861
+ androidElementTreeOptions: g,
862
+ microphoneEnabled: J,
863
+ onStateChange: (t) => {
864
+ (t.videoReady || t.connection === "idle" || t.connection === "connecting" || t.connection === "reconnecting") && bt(t.videoReady), Nt(t.connection === "failed"), Et(t.connection === "terminated"), yt(t.duo), wt(t.duoState), Tt(t.duoError);
865
+ },
866
+ onAxSnapshotChange: (t) => {
867
+ e && (Fe((c) => Jt(c, t) ? c : t), D.current.onAxSnapshotChange?.(t));
868
+ },
869
+ onAxStatusChange: (...t) => D.current.onAxStatusChange?.(...t),
870
+ onCameraDemandChange: (...t) => D.current.onCameraDemandChange?.(...t),
871
+ onCameraStats: oe ? (...t) => D.current.onCameraStats?.(...t) : void 0,
872
+ onMicrophoneStateChange: (...t) => D.current.onMicrophoneStateChange?.(...t),
873
+ onTrace: je ? (...t) => D.current.onTrace?.(...t) : void 0,
874
+ onTerminated: () => D.current.onTerminated?.(),
875
+ onConnectionStateChange: (...t) => D.current.onConnectionStateChange?.(...t),
876
+ onPlaybackStats: O ? (...t) => D.current.onPlaybackStats?.(...t) : void 0
877
+ });
878
+ v.current = n;
879
+ const o = I.current ? n.attachVideo(I.current) : void 0;
880
+ return n.start(), () => {
881
+ e = !1, n.dispose(), o?.(), v.current = null;
882
+ };
883
+ }, [r, h, u, M, je]), x(() => {
884
+ if (z && _e.current)
885
+ return v.current?.attachVideo(_e.current, "inner");
886
+ }, [z, r, h, u, M, je]), x(() => {
887
+ v.current?.updateOptions({
888
+ openUrl: b,
889
+ axPollIntervalMs: F,
890
+ axMaxBackoffMs: X,
891
+ androidElementTreeOptions: g,
892
+ autoReconnect: U,
893
+ jitterBufferTargetMs: H,
894
+ microphoneEnabled: J,
895
+ inspectMode: P,
896
+ onPlaybackStats: O ? (...e) => D.current.onPlaybackStats?.(...e) : void 0,
897
+ onCameraStats: oe ? (...e) => D.current.onCameraStats?.(...e) : void 0
898
+ });
899
+ }, [
900
+ U,
901
+ H,
902
+ J,
903
+ P,
904
+ !!O,
905
+ !!oe,
906
+ b,
907
+ F,
908
+ X,
909
+ g
910
+ ]);
911
+ const ut = () => {
912
+ const e = Me();
913
+ if (!e) {
914
+ ot(null);
915
+ return;
916
+ }
917
+ const n = {
918
+ left: e.videoRect.left - e.containerRect.left + e.offsetX,
919
+ top: e.videoRect.top - e.containerRect.top + e.offsetY,
920
+ width: e.actualWidth,
921
+ height: e.actualHeight
922
+ };
923
+ ot(
924
+ (o) => o && o.left === n.left && o.top === n.top && o.width === n.width && o.height === n.height ? o : n
925
+ );
926
+ };
927
+ x(() => {
928
+ const e = I.current, n = Oe.current, o = Ce.current;
929
+ if (!e) return;
930
+ const t = () => {
931
+ const i = e.videoWidth > 0 && e.videoHeight > 0;
932
+ i && (Ue.current = { width: e.videoWidth, height: e.videoHeight });
933
+ const a = Ue.current, l = a ? `${a.width} / ${a.height}` : void 0;
934
+ if (!Ye || !n) {
935
+ $e(
936
+ !i && a ? {
937
+ aspectRatio: l,
938
+ contain: "size",
939
+ containIntrinsicSize: `${a.width}px ${a.height}px`
940
+ } : {}
941
+ ), ut();
942
+ return;
943
+ }
944
+ const f = n.clientWidth, N = n.clientHeight;
945
+ if (f === 0 || N === 0) return;
946
+ const y = a ? a.width > a.height : !1;
947
+ et(y), tt(
948
+ ee === "android" && !!a && Tn(a.width, a.height)
949
+ );
950
+ const k = y ? pe.videoPosition.landscape : pe.videoPosition.portrait;
951
+ let w = { aspectRatio: l };
952
+ k.heightMultiplier ? (w.height = `${N * k.heightMultiplier}px`, w.width = "auto") : k.widthMultiplier && (w.width = `${f * k.widthMultiplier}px`, w.height = "auto"), w.borderRadius = `${y ? N * pe.videoBorderRadiusMultiplier : f * pe.videoBorderRadiusMultiplier}px`, $e(w), ut();
953
+ }, c = new ResizeObserver(() => {
954
+ t();
955
+ });
956
+ n && c.observe(n), c.observe(e), o && c.observe(o), n && n.addEventListener("load", t), e.addEventListener("loadedmetadata", t), e.addEventListener("resize", t);
957
+ const s = () => v.current?.bumpActivity();
958
+ return e.addEventListener("resize", s), t(), () => {
959
+ c.disconnect(), e.removeEventListener("loadedmetadata", t), e.removeEventListener("resize", t), e.removeEventListener("resize", s), n && n.removeEventListener("load", t);
960
+ };
961
+ }, [pe, Ye, r, M]), x(() => {
962
+ Ee || (Fe(null), Re(null), Pe(null), rt(null), fe(null), ke.current = null, j.current !== void 0 && (window.cancelAnimationFrame(j.current), j.current = void 0));
963
+ }, [Ee]), x(() => () => {
964
+ j.current !== void 0 && (window.cancelAnimationFrame(j.current), j.current = void 0);
965
+ }, []), x(() => {
966
+ if (!Ee) return;
967
+ const e = (n) => {
968
+ n.key === "Escape" && (Ke || ze) && (Pe(null), Re(null), fe(null), we("onInspectSelectionChange", me.current, null));
969
+ };
970
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
971
+ }, [Ee, Ke, ze]);
972
+ const Kt = () => {
973
+ I.current && I.current.focus();
974
+ };
975
+ an(be, () => ({
976
+ openUrl: (e) => v.current?.openUrl(e),
977
+ sendKeyEvent: (e) => v.current?.sendKeyEvent(e),
978
+ screenshot: (e) => v.current?.screenshot(e) ?? Promise.reject(new Error("Simulator disconnected")),
979
+ terminateApp: (e) => v.current?.terminateApp(e) ?? Promise.reject(new Error("Simulator disconnected")),
980
+ reconnect: () => v.current?.reconnect(),
981
+ refreshAxTree: () => v.current?.refreshAxTree() ?? Promise.reject(new Error("Simulator disconnected")),
982
+ getAxSnapshot: () => v.current?.getAxSnapshot() ?? null,
983
+ setInspectHighlight: (e) => {
984
+ Re(e?.id ?? null);
985
+ },
986
+ setInspectSelection: (e) => {
987
+ Pe(e?.id ?? null), fe(e ? ke.current : null);
988
+ const n = ce.current;
989
+ e && n ? we("onInspectSelectionChange", me.current, { element: e, snapshot: n }) : we("onInspectSelectionChange", me.current, null);
990
+ },
991
+ getAxStatus: () => v.current?.getAxStatus() ?? "idle"
992
+ }));
993
+ const Vt = Ot && ie !== null;
994
+ return /* @__PURE__ */ $(
995
+ "div",
996
+ {
997
+ ref: Ce,
998
+ className: de("rc-container", d),
999
+ style: { touchAction: "none" },
1000
+ onMouseDown: te,
1001
+ onMouseMove: te,
1002
+ onMouseUp: te,
1003
+ onMouseLeave: te,
1004
+ onTouchStart: te,
1005
+ onTouchMove: te,
1006
+ onTouchEnd: te,
1007
+ onTouchCancel: te,
1008
+ children: [
1009
+ Vt && ie && /* @__PURE__ */ $(mt, { children: [
1010
+ /* @__PURE__ */ m(
1011
+ "div",
1012
+ {
1013
+ className: "rc-touch-indicator",
1014
+ style: {
1015
+ left: `${ie.containerX}px`,
1016
+ top: `${ie.containerY}px`
1017
+ }
1018
+ }
1019
+ ),
1020
+ /* @__PURE__ */ m(
1021
+ "div",
1022
+ {
1023
+ className: "rc-touch-indicator",
1024
+ style: {
1025
+ left: `${ie.mirrorContainerX}px`,
1026
+ top: `${ie.mirrorContainerY}px`
1027
+ }
1028
+ }
1029
+ )
1030
+ ] }),
1031
+ Ye && /* @__PURE__ */ m(
1032
+ "img",
1033
+ {
1034
+ ref: Oe,
1035
+ src: ct,
1036
+ alt: "",
1037
+ className: ee === "ios" ? de("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
1038
+ draggable: !1
1039
+ }
1040
+ ),
1041
+ /* @__PURE__ */ m(
1042
+ "video",
1043
+ {
1044
+ ref: I,
1045
+ className: de(
1046
+ "rc-video",
1047
+ !Ye && "rc-video-frameless",
1048
+ !At && "rc-video-loading"
1049
+ ),
1050
+ style: {
1051
+ ...Mt,
1052
+ ...z ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
1053
+ ...st ? {
1054
+ backgroundImage: `url("${st}")`,
1055
+ backgroundRepeat: "no-repeat",
1056
+ backgroundPosition: "center",
1057
+ backgroundSize: pe.loadingLogoSize
1058
+ } : {}
1059
+ },
1060
+ autoPlay: !0,
1061
+ playsInline: !0,
1062
+ muted: !0,
1063
+ tabIndex: z ? -1 : 0,
1064
+ onKeyDown: Le,
1065
+ onKeyUp: Le,
1066
+ onClick: Kt,
1067
+ onFocus: () => {
1068
+ I.current && (I.current.style.outline = "none");
1069
+ },
1070
+ onBlur: () => {
1071
+ I.current && (I.current.style.outline = "none");
1072
+ }
1073
+ }
1074
+ ),
1075
+ z && /* @__PURE__ */ m(
1076
+ "video",
1077
+ {
1078
+ ref: _e,
1079
+ autoPlay: !0,
1080
+ playsInline: !0,
1081
+ muted: !0,
1082
+ style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
1083
+ }
1084
+ ),
1085
+ z && Qe && /* @__PURE__ */ m(ln, { fallback: /* @__PURE__ */ m("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ m(
1086
+ wn,
1087
+ {
1088
+ showFrame: K,
1089
+ modelUrl: T,
1090
+ outer: I.current,
1091
+ inner: _e.current,
1092
+ state: Qe,
1093
+ setAngle: (e) => Ve("setHingeAngle", { angleDegrees: e }),
1094
+ setOrientation: (e) => Ve("setDuoOrientation", { orientation: e }),
1095
+ button: (e, n) => Ve("performActions", {
1096
+ actions: [{ type: n ? "buttonDown" : "buttonUp", button: e }]
1097
+ }),
1098
+ touch: (e, n, o, t) => {
1099
+ v.current?.sendDisplayTouch(e, n, o, t);
1100
+ },
1101
+ onKeyDown: Le,
1102
+ onKeyUp: Le
1103
+ }
1104
+ ) }),
1105
+ z && Ze && /* @__PURE__ */ m("div", { role: "alert", className: "rc-duo-error", children: Ze }),
1106
+ !z && Ee && /* @__PURE__ */ m(
1107
+ yn,
1108
+ {
1109
+ snapshot: nt,
1110
+ geometry: St,
1111
+ highlightedId: ze,
1112
+ selectedId: Ke,
1113
+ mode: Yt,
1114
+ cursorPosition: Pt,
1115
+ frozenCursorPosition: kt,
1116
+ onSelectChange: (e, n) => {
1117
+ Pe(e?.id ?? null), e && n ? fe(n) : e || fe(null);
1118
+ const o = ce.current;
1119
+ e && o ? we("onInspectSelectionChange", me.current, {
1120
+ element: e,
1121
+ snapshot: o
1122
+ }) : we("onInspectSelectionChange", me.current, null);
1123
+ },
1124
+ onTapElement: (e, n) => {
1125
+ if (n) {
1126
+ lt(n.x, n.y);
1127
+ return;
1128
+ }
1129
+ const o = ce.current;
1130
+ o && Dt(e, o);
1131
+ }
1132
+ }
1133
+ ),
1134
+ Rt ? /* @__PURE__ */ $("div", { className: "rc-terminated", role: "status", children: [
1135
+ /* @__PURE__ */ m("div", { className: "rc-terminated-title", children: "Instance terminated" }),
1136
+ /* @__PURE__ */ m("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
1137
+ ] }) : Ct && /* @__PURE__ */ m("button", { type: "button", className: "rc-retry-button", onClick: zt, children: "Retry" })
1138
+ ]
1139
+ }
1140
+ );
1141
+ }
1142
+ );
1143
+ export {
1144
+ In as R
1145
+ };