@limrun/ui 0.22.4 → 0.22.6

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,1712 +0,0 @@
1
- import { jsxs as ee, jsx as w, Fragment as Co } from "react/jsx-runtime";
2
- import { M as Q, o as ln, q as dn, f as un, c as Ro, d as hn, b as fn, r as mn, s as pn, t as wo, u as Qe, v as gn, e as yn, w as G, x as Bt, y as vn, z as bn, B as Ct, C as B, E as Rt, a as wn, F as Mn, G as x, I as An } from "./core-nbvkIrvp.mjs";
3
- import { useReducer as Tn, useRef as H, useCallback as kt, memo as zt, useState as D, useEffect as J, useMemo as Xe, lazy as Oo, forwardRef as Cn, useImperativeHandle as Rn, Suspense as Mo } from "react";
4
- import { createPortal as On } from "react-dom";
5
- import './index.css';const ce = {
6
- sideBezel: 1.7,
7
- topBezel: 2.4,
8
- chin: 2.4,
9
- baseHeight: 2.2,
10
- baseOverhang: 4,
11
- screenRadius: 0.9,
12
- lidThickness: 0.7
13
- }, Ut = 100 + 2 * ce.sideBezel, at = Ut + 2 * ce.baseOverhang, Kt = ce.topBezel + ce.chin + ce.baseHeight, En = (Kt - 2 * ce.topBezel) / 2, oi = 8;
14
- function Nn(a) {
15
- const t = 100 / a, r = t + ce.topBezel + ce.chin;
16
- return {
17
- screenHeight: t,
18
- lidHeight: r,
19
- // A closed lid covers the base back to front.
20
- depth: r
21
- };
22
- }
23
- const kn = Math.PI / 2, ni = 135, ii = 100, ri = 2400;
24
- function ci(a) {
25
- return kn - a * Math.PI / 180;
26
- }
27
- function si(a) {
28
- const t = Math.max(0, Math.min(1, a));
29
- return 1 - Math.pow(1 - t, 3);
30
- }
31
- function Ye(a, t, r, l = 6) {
32
- const p = [], v = [
33
- [a / 2 - r.top, t / 2 - r.top, r.top, 0],
34
- [-a / 2 + r.top, t / 2 - r.top, r.top, Math.PI / 2],
35
- [-a / 2 + r.bottom, -t / 2 + r.bottom, r.bottom, Math.PI],
36
- [a / 2 - r.bottom, -t / 2 + r.bottom, r.bottom, Math.PI * 1.5]
37
- ];
38
- for (const [m, b, T, k] of v)
39
- for (let I = 0; I <= l; I++) {
40
- const E = k + I * Math.PI / 2 / l;
41
- p.push({ x: m + T * Math.cos(E), y: b + T * Math.sin(E), nx: Math.cos(E), ny: Math.sin(E) });
42
- }
43
- return p;
44
- }
45
- function ai(a) {
46
- const { screenHeight: t, lidHeight: r, depth: l } = Nn(a), p = [], v = (u, y, M) => p.push({ part: u, kind: y, vertices: new Float32Array(M) }), m = (u, y, M, W, P) => {
47
- const Y = M.map((ne) => ne.x), j = M.map((ne) => ne.y), [le, te, ye, q] = [Math.min(...Y), Math.max(...Y), Math.min(...j), Math.max(...j)], oe = (le + te) / 2, R = (ye + q) / 2, Ae = (ne, K) => [
48
- ...W(ne, K),
49
- ...P,
50
- (ne - le) / (te - le || 1),
51
- (K - ye) / (q - ye || 1)
52
- ], lt = [];
53
- for (let ne = 0; ne < M.length; ne++) {
54
- const K = M[ne], Re = M[(ne + 1) % M.length];
55
- for (const $e of [Ae(oe, R), Ae(K.x, K.y), Ae(Re.x, Re.y)]) lt.push(...$e);
56
- }
57
- v(u, y, lt);
58
- }, b = (u, y, M, W, P, Y, j) => {
59
- const le = [];
60
- for (let te = 0; te < M.length; te++) {
61
- const ye = M[te], q = M[(te + 1) % M.length], oe = (R, Ae) => [...W(R.x, R.y, Ae), ...P(R.nx, R.ny), 0, 0];
62
- for (const R of [
63
- oe(ye, Y),
64
- oe(q, Y),
65
- oe(q, j),
66
- oe(ye, Y),
67
- oe(q, j),
68
- oe(ye, j)
69
- ])
70
- le.push(...R);
71
- }
72
- v(u, y, le);
73
- }, T = Ye(Ut, r, { top: 2.2, bottom: 0.4 }), k = (u) => u + r / 2, I = ce.lidThickness;
74
- b(
75
- "lid",
76
- "shell",
77
- T,
78
- (u, y, M) => [u, k(y), M],
79
- (u, y) => [u, y, 0],
80
- -I,
81
- 0
82
- ), m("lid", "shell", T, (u, y) => [u, k(y), -I], [0, 0, -1]), m(
83
- "lid",
84
- "glass",
85
- Ye(Ut - 0.5, r - 0.5, { top: 1.95, bottom: 0.2 }),
86
- (u, y) => [u, k(y), 0.01],
87
- [0, 0, 1]
88
- );
89
- const E = ce.chin;
90
- m(
91
- "lid",
92
- "screen",
93
- Ye(100, t, { top: ce.screenRadius, bottom: 0 }),
94
- (u, y) => [u, E + t / 2 + y, 0.02],
95
- [0, 0, 1]
96
- ), m(
97
- "lid",
98
- "camera",
99
- Ye(0.5, 0.5, { top: 0.25, bottom: 0.25 }, 4),
100
- (u, y) => [u, r - ce.topBezel / 2 + y, 0.02],
101
- [0, 0, 1]
102
- );
103
- const L = Ye(at, l + I, { top: 3, bottom: 3 }), U = (u) => (l - I) / 2 - u;
104
- b(
105
- "base",
106
- "shell",
107
- L,
108
- (u, y, M) => [u, M, U(y)],
109
- (u, y) => [u, 0, -y],
110
- -2.2,
111
- 0
112
- ), m("base", "shell", L, (u, y) => [u, 0, U(y)], [0, 1, 0]), m("base", "shell", L, (u, y) => [u, -2.2, U(y)], [0, -1, 0]);
113
- const se = (u, y, M, W, P, Y, j) => m("base", u, Ye(W, P, { top: j, bottom: j }, 3), (le, te) => [y + le, Y, M - te], [0, 1, 0]), Me = at * 0.72, me = l * 0.08, C = [0.55, 1, 1, 1, 1, 1], ae = l * 0.4 / C.reduce((u, y) => u + y, 0);
114
- se("well", 0, me + l * 0.4 / 2, Me + 1.4, l * 0.4 + 1.4, 0.01, 0.8);
115
- let V = me;
116
- for (const [u, y] of C.entries()) {
117
- const M = y * ae, W = Me / 14;
118
- for (let P = 0; P < 14; P++) {
119
- if (u === 5 && P > 4 && P < 9) continue;
120
- const Y = u === 5 && P === 4 ? 5 : 1;
121
- se(
122
- "keys",
123
- -Me / 2 + W * (P + Y / 2),
124
- V + M / 2,
125
- W * Y - 0.5,
126
- M - 0.5,
127
- 0.03,
128
- 0.3
129
- );
130
- }
131
- V += M;
132
- }
133
- se("trackpad", 0, l * 0.72, at * 0.4, l * 0.36, 0.01, 1.2), m(
134
- "base",
135
- "scoop",
136
- Ye(14, 0.9, { top: 0, bottom: 0.45 }, 3),
137
- (u, y) => [u, -0.45 + y, l + 0.01],
138
- [0, 0, 1]
139
- );
140
- const S = /* @__PURE__ */ new Map();
141
- for (const u of p) {
142
- const y = `${u.part}:${u.kind}`;
143
- S.set(y, [...S.get(y) ?? [], u]);
144
- }
145
- return [...S.values()].map((u) => {
146
- const y = new Float32Array(u.reduce((W, P) => W + P.vertices.length, 0));
147
- let M = 0;
148
- for (const W of u)
149
- y.set(W.vertices, M), M += W.vertices.length;
150
- return { part: u[0].part, kind: u[0].kind, vertices: y };
151
- });
152
- }
153
- function li(a, t, r = 0) {
154
- const l = a >= t ? 1 : a / t, p = a >= t ? t / a : 1, v = (1 - l) / 2, m = r > 0 ? 1 - p : (1 - p) / 2;
155
- return { repeat: [1 / l, 1 / p], offset: [(0 - v) / l, (0 - m) / p] };
156
- }
157
- function di(a, t, r) {
158
- const l = a * r.repeat[0] + r.offset[0], p = t * r.repeat[1] + r.offset[1], v = 1e-9;
159
- if (l < -v || l > 1 + v || p < -v || p > 1 + v) return;
160
- const m = (b) => Math.max(0, Math.min(1, b));
161
- return { x: m(l), y: m(1 - p) };
162
- }
163
- const _n = 150, In = 8;
164
- class Sn {
165
- constructor(t, r = () => !1) {
166
- this.send = t, this.blocked = r;
167
- }
168
- send;
169
- blocked;
170
- // The last pointer event sent, whose buttons the guest holds.
171
- last;
172
- gesture;
173
- screen;
174
- pointer(t, r, l) {
175
- const p = t === Q.UP && !!this.last?.buttons;
176
- this.blocked() && !p || (this.last = { ...r, buttons: l }, this.send(ln(t, r.width, r.height, r.x, r.y, l)));
177
- }
178
- scroll(t, r, l) {
179
- this.blocked() || this.send(dn(t.width, t.height, t.x, t.y, r, l));
180
- }
181
- /**
182
- * A touch event, its fingers in client coordinates. Returns true when a finger lands on the screen
183
- * and starts a gesture, so the caller can give the screen the keyboard.
184
- */
185
- touch(t, r, l) {
186
- const p = this.gesture;
187
- if (r.length >= 2) {
188
- const m = {
189
- x: r.reduce((b, T) => b + T.x, 0) / r.length,
190
- y: r.reduce((b, T) => b + T.y, 0) / r.length
191
- };
192
- if (p?.mode === "scroll") {
193
- const b = l.map(m.x, m.y);
194
- b && t === "touchmove" && this.scroll(b, (p.x - m.x) * l.scale, (p.y - m.y) * l.scale);
195
- } else p?.mode === "press" ? this.lift(p, l) : p?.mode === "pending" && clearTimeout(p.timer);
196
- return this.gesture = { mode: "scroll", ...m }, !1;
197
- }
198
- const v = r[0];
199
- if (v && t === "touchstart" && !p)
200
- return this.blocked() || !l.contains(v.x, v.y) ? !1 : (this.screen = l, this.gesture = {
201
- mode: "pending",
202
- x: v.x,
203
- y: v.y,
204
- timer: setTimeout(() => this.press(), _n)
205
- }, !0);
206
- if (v && p?.mode === "pending") {
207
- if (Math.hypot(v.x - p.x, v.y - p.y) < In) return !1;
208
- this.press();
209
- }
210
- if (v && this.gesture?.mode === "press") {
211
- this.gesture = { mode: "press", x: v.x, y: v.y };
212
- const m = l.map(v.x, v.y);
213
- return m && this.pointer(Q.MOVE, m, 1), !1;
214
- }
215
- if (r.length === 0) {
216
- p?.mode === "pending" && (t === "touchcancel" ? clearTimeout(p.timer) : this.press());
217
- const m = this.gesture;
218
- m?.mode === "press" && this.lift(m, l), this.gesture = void 0;
219
- }
220
- return !1;
221
- }
222
- /** Drops a pending touch and lets go of any button the guest holds, where it was pressed. */
223
- release() {
224
- clearTimeout(this.gesture?.timer), this.gesture = void 0;
225
- const t = this.last;
226
- t?.buttons && this.pointer(Q.UP, t, 0);
227
- }
228
- // A pending finger's press, where it landed.
229
- press() {
230
- const t = this.gesture;
231
- if (t?.mode !== "pending") return;
232
- clearTimeout(t.timer), this.gesture = { mode: "press", x: t.x, y: t.y };
233
- const r = this.screen?.map(t.x, t.y);
234
- r && this.pointer(Q.DOWN, r, 1);
235
- }
236
- lift(t, r) {
237
- const l = r.map(t.x, t.y);
238
- l && this.pointer(Q.UP, l, 0);
239
- }
240
- }
241
- function xn(a, t) {
242
- return t.type === "choose" ? t.mode === a.mode ? a : t.mode === "3d" ? { ...a, mode: "3d", selection: a.selection + 1 } : { ...a, mode: "2d" } : a.mode !== "3d" || t.selection !== a.selection || a.ready === t.selection ? a : { ...a, ready: t.selection };
243
- }
244
- function Pn(a) {
245
- const [t, r] = Tn(xn, { mode: "2d", selection: 0, ready: 0 }), l = H(t);
246
- l.current = t;
247
- const p = H(a);
248
- p.current = a;
249
- const { mode: v, selection: m, ready: b } = t, T = kt((E) => r({ type: "choose", mode: E }), []), k = kt(() => {
250
- const E = l.current;
251
- E.mode !== "3d" || E.selection !== m || E.ready === m || (p.current?.(), r({ type: "ready", selection: m }));
252
- }, [m]), I = v === "3d" && b !== m;
253
- return { mode: v, shown: v === "3d" && !I ? "3d" : "2d", loading: I, choose: T, onReady: k };
254
- }
255
- function Hn({ view: a, label: t }) {
256
- return /* @__PURE__ */ ee("div", { className: "rc-duo-mode", role: "group", "aria-label": t, children: [
257
- /* @__PURE__ */ w("button", { type: "button", "aria-pressed": a.mode === "2d", onClick: () => a.choose("2d"), children: "2D" }),
258
- /* @__PURE__ */ w(
259
- "button",
260
- {
261
- type: "button",
262
- "aria-pressed": a.mode === "3d",
263
- "aria-busy": a.loading,
264
- title: a.loading ? "Loading 3D" : void 0,
265
- onClick: () => a.choose("3d"),
266
- children: "3D"
267
- }
268
- )
269
- ] });
270
- }
271
- const Dn = async (a) => {
272
- if (!a) return !1;
273
- try {
274
- if (typeof navigator < "u" && navigator.clipboard?.writeText)
275
- return await navigator.clipboard.writeText(a), !0;
276
- } catch {
277
- }
278
- try {
279
- const t = document.createElement("textarea");
280
- t.value = a, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
281
- const r = document.execCommand("copy");
282
- return document.body.removeChild(t), r;
283
- } catch {
284
- return !1;
285
- }
286
- }, Wn = zt(
287
- function({ element: t, screen: r, highlighted: l, selected: p, selectable: v, onClick: m }) {
288
- const b = un(t.frame, r);
289
- if (!b) return null;
290
- const T = Ro(t);
291
- return /* @__PURE__ */ w(
292
- "button",
293
- {
294
- type: "button",
295
- className: t.enabled ? "rc-inspect-box" : "rc-inspect-box rc-inspect-box-disabled",
296
- "data-ax-id": t.id,
297
- "data-ax-path": t.path,
298
- "data-ax-label": t.label || void 0,
299
- "data-ax-role": t.role || void 0,
300
- "data-highlighted": l ? "true" : "false",
301
- "data-selected": p ? "true" : "false",
302
- "aria-label": T,
303
- onClick: (k) => {
304
- v && (k.preventDefault(), k.stopPropagation(), m(t, { x: k.clientX, y: k.clientY }));
305
- },
306
- style: {
307
- left: `${b.x / r.width * 100}%`,
308
- top: `${b.y / r.height * 100}%`,
309
- width: `${b.width / r.width * 100}%`,
310
- height: `${b.height / r.height * 100}%`
311
- }
312
- }
313
- );
314
- },
315
- (a, t) => a.highlighted === t.highlighted && a.selected === t.selected && a.selectable === t.selectable && a.screen.width === t.screen.width && a.screen.height === t.screen.height && a.onClick === t.onClick && hn(a.element, t.element)
316
- ), Ln = 260, Yn = 220, Xn = 6, $n = 8, Bn = zt(function({
317
- element: t,
318
- platform: r,
319
- anchor: l,
320
- cursorAnchored: p,
321
- showActions: v,
322
- onTap: m
323
- }) {
324
- const [b, T] = D(null);
325
- J(() => {
326
- if (!b) return;
327
- const C = window.setTimeout(() => T(null), 1100);
328
- return () => window.clearTimeout(C);
329
- }, [b]);
330
- const k = Xe(() => {
331
- const C = Ln, ae = Yn, V = Xn, S = $n, u = typeof window < "u" ? window.innerWidth : 1024, y = typeof window < "u" ? window.innerHeight : 768, M = l.x + V + C <= u - S, W = l.y - V - ae >= S;
332
- let P = M ? l.x + V : l.x - V, Y = W ? l.y - V : l.y + V;
333
- const te = `translate(${M ? "0" : "-100%"}, ${W ? "-100%" : "0"})`;
334
- return P = Math.max(S + (M ? 0 : C), Math.min(u - S - (M ? C : 0), P)), Y = Math.max(S + (W ? ae : 0), Math.min(y - S - (W ? 0 : ae), Y)), { left: `${P}px`, top: `${Y}px`, transform: te };
335
- }, [l.x, l.y]), I = Xe(() => fn(t, r), [t, r]), E = r === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, L = r === "ios" ? "AXUniqueId" : "resourceId", U = kt(async (C, ae) => {
336
- if (!C) return;
337
- await Dn(C) && T(ae);
338
- }, []), se = mn(t), Me = t.label || t.value || se, me = Ro(t);
339
- return On(
340
- /* @__PURE__ */ ee(
341
- "div",
342
- {
343
- className: "rc-inspect-card",
344
- "data-cursor-anchored": p ? "true" : "false",
345
- style: k,
346
- onClick: (C) => C.stopPropagation(),
347
- onMouseDown: (C) => C.stopPropagation(),
348
- onMouseMove: (C) => C.stopPropagation(),
349
- children: [
350
- /* @__PURE__ */ ee("div", { className: "rc-inspect-card-header", children: [
351
- /* @__PURE__ */ w("span", { className: "rc-inspect-card-role", children: se }),
352
- !t.enabled && /* @__PURE__ */ w("span", { className: "rc-inspect-card-tag", children: "disabled" }),
353
- t.focused && /* @__PURE__ */ w("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
354
- ] }),
355
- /* @__PURE__ */ w("p", { className: "rc-inspect-card-title", title: me, children: Me }),
356
- E && /* @__PURE__ */ ee("div", { className: "rc-inspect-card-row", children: [
357
- /* @__PURE__ */ ee("span", { className: "rc-inspect-card-row-label", children: [
358
- L,
359
- ":"
360
- ] }),
361
- /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-value", children: E })
362
- ] }),
363
- t.value && t.value !== t.label && /* @__PURE__ */ ee("div", { className: "rc-inspect-card-row", children: [
364
- /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-label", children: "value:" }),
365
- /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-value", children: t.value })
366
- ] }),
367
- /* @__PURE__ */ ee("div", { className: "rc-inspect-card-row", children: [
368
- /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
369
- /* @__PURE__ */ ee("span", { className: "rc-inspect-card-row-value", children: [
370
- Math.round(t.frame.width),
371
- "×",
372
- Math.round(t.frame.height),
373
- " @ ",
374
- Math.round(t.frame.x),
375
- ",",
376
- Math.round(t.frame.y)
377
- ] })
378
- ] }),
379
- v && /* @__PURE__ */ ee("div", { className: "rc-inspect-card-actions", children: [
380
- /* @__PURE__ */ w(
381
- "button",
382
- {
383
- type: "button",
384
- className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
385
- disabled: !m,
386
- onClick: () => m?.(t, l),
387
- children: "Tap"
388
- }
389
- ),
390
- /* @__PURE__ */ w(
391
- "button",
392
- {
393
- type: "button",
394
- className: b === "selector" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
395
- disabled: !I,
396
- title: I ?? "No usable selector for this element",
397
- onClick: () => U(I ?? void 0, "selector"),
398
- children: b === "selector" ? "Copied!" : "Copy selector"
399
- }
400
- ),
401
- /* @__PURE__ */ w(
402
- "button",
403
- {
404
- type: "button",
405
- className: b === "id" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
406
- disabled: !E,
407
- title: E ?? `No ${L}`,
408
- onClick: () => U(E, "id"),
409
- children: b === "id" ? "Copied!" : `Copy ${L}`
410
- }
411
- )
412
- ] })
413
- ]
414
- }
415
- ),
416
- document.body
417
- );
418
- }), Un = zt(function({
419
- snapshot: t,
420
- geometry: r,
421
- highlightedId: l,
422
- selectedId: p,
423
- mode: v,
424
- cursorPosition: m,
425
- frozenCursorPosition: b,
426
- onSelectChange: T,
427
- onTapElement: k
428
- }) {
429
- const I = v === "select", E = I ? l !== null && l !== p : l !== null, L = I ? l ?? p : l, U = Xe(() => {
430
- const S = /* @__PURE__ */ new Map();
431
- if (!t) return S;
432
- for (const u of t.elements) S.set(u.id, u);
433
- return S;
434
- }, [t]), se = Xe(() => L ? U.get(L) ?? null : null, [L, U]);
435
- if (!(!!t && !!r && t.screen.width > 0 && t.screen.height > 0 && t.elements.length > 0)) return null;
436
- const me = E ? m : b ?? m, C = E, ae = I && !E && p !== null, V = (S) => {
437
- I && S.target === S.currentTarget && T(null, null);
438
- };
439
- return /* @__PURE__ */ ee(Co, { children: [
440
- /* @__PURE__ */ w(
441
- "div",
442
- {
443
- className: I ? "rc-inspect-overlay rc-inspect-overlay-select" : "rc-inspect-overlay",
444
- style: {
445
- left: `${r.left}px`,
446
- top: `${r.top}px`,
447
- width: `${r.width}px`,
448
- height: `${r.height}px`
449
- },
450
- onClick: V,
451
- children: t.elements.map((S) => /* @__PURE__ */ w(
452
- Wn,
453
- {
454
- element: S,
455
- screen: t.screen,
456
- highlighted: S.id === l,
457
- selected: S.id === p,
458
- selectable: I,
459
- onClick: T
460
- },
461
- S.id
462
- ))
463
- }
464
- ),
465
- se && me && /* @__PURE__ */ w(
466
- Bn,
467
- {
468
- element: se,
469
- platform: t.platform,
470
- anchor: me,
471
- cursorAnchored: C,
472
- showActions: ae,
473
- onTap: k
474
- }
475
- )
476
- ] });
477
- });
478
- function Kn(a, t) {
479
- if (!t.startsWith("lim_st_")) return !1;
480
- try {
481
- const r = new URL(a).pathname.split("/").map(decodeURIComponent).find((k) => /^(ios|android)_[a-z0-9_]+$/.test(k));
482
- if (!r) return !1;
483
- const l = r.split("_")[0], p = t.slice(7).split(".");
484
- if (p.length !== 3 || p.some((k) => !k)) return !1;
485
- const v = atob(p[1].replace(/-/g, "+").replace(/_/g, "/")), m = JSON.parse(
486
- new TextDecoder().decode(Uint8Array.from(v, (k) => k.charCodeAt(0)))
487
- );
488
- if (!m || typeof m != "object" || !("scopes" in m)) return !1;
489
- const b = m.scopes;
490
- if (!Array.isArray(b) || !b.every((k) => typeof k == "string")) return !1;
491
- let T = !1;
492
- for (const k of b) {
493
- const [I, E, L, U] = k.split(":");
494
- if (!(U !== void 0 || I !== l && I !== "*") && !(E !== r && E !== "*")) {
495
- if (L === "stream" || L === "all") return !1;
496
- L === "watch" && (T = !0);
497
- }
498
- }
499
- return T;
500
- } catch {
501
- return !1;
502
- }
503
- }
504
- const zn = Oo(() => import("./duo-view-C07GD_5E.mjs").then((a) => a.d)), Fn = Oo(() => import("./macbook-frame-Dm6ko0j9.mjs")), Ot = (a) => Object.entries(x).find(
505
- ([r, l]) => r.startsWith("ACTION_") && l === a
506
- )?.[0] ?? String(a), Ao = 1920, To = 1200, Vn = (a, t) => a === Ao && t === To || a === To && t === Ao, Gn = {
507
- ios: {
508
- videoBorderRadiusMultiplier: 0.15,
509
- loadingLogoSize: "20%",
510
- // Video position as percentage of frame dimensions
511
- videoPosition: {
512
- portrait: { heightMultiplier: 0.9678 },
513
- landscape: { widthMultiplier: 0.9678 }
514
- }
515
- },
516
- android: {
517
- videoBorderRadiusMultiplier: 0.13,
518
- loadingLogoSize: "40%",
519
- // Video position as percentage of frame dimensions
520
- videoPosition: {
521
- portrait: { heightMultiplier: 0.967 },
522
- landscape: { widthMultiplier: 0.962 }
523
- }
524
- },
525
- // A macOS virtual machine is a desktop display. Its MacBook Pro frame is drawn in CSS around
526
- // whatever size the guest display has; see MACBOOK below.
527
- macos: {
528
- videoBorderRadiusMultiplier: 0,
529
- loadingLogoSize: "10%",
530
- videoPosition: {
531
- portrait: { heightMultiplier: 1 },
532
- landscape: { widthMultiplier: 1 }
533
- }
534
- }
535
- }, jn = {
536
- "iphone-se": {
537
- videoBorderRadiusMultiplier: 0,
538
- loadingLogoSize: "20%",
539
- videoPosition: {
540
- portrait: { heightMultiplier: 667 / 889 },
541
- landscape: { widthMultiplier: 667 / 889 }
542
- },
543
- // The SE has no home indicator, so its frame's home button is the way home: 64 points across,
544
- // centered in the bottom bezel 389 points below the frame's center.
545
- homeButton: { offset: 389 / 889, diameter: 64 / 889 }
546
- },
547
- "iphone-17e": {
548
- videoBorderRadiusMultiplier: 47.33 / 452,
549
- loadingLogoSize: "20%",
550
- videoPosition: {
551
- portrait: { heightMultiplier: 844 / 888 },
552
- landscape: { widthMultiplier: 844 / 888 }
553
- }
554
- }
555
- }, $t = 16 / 10, Et = 44, qn = {
556
- videoBorderRadiusMultiplier: 32 / 1837,
557
- loadingLogoSize: "40%",
558
- videoPosition: {
559
- portrait: { heightMultiplier: 2560 / 2798 },
560
- landscape: { widthMultiplier: 2560 / 2798 }
561
- }
562
- };
563
- function Zn(a) {
564
- const t = a.code, r = Mn[t];
565
- if (!r)
566
- return Bt(`Unknown event.code: ${t}, key: ${a.key}`), null;
567
- let l = B.META_NONE;
568
- const p = t >= "KeyA" && t <= "KeyZ", v = a.getModifierState("CapsLock"), m = a.shiftKey;
569
- let b = m;
570
- return p && (b = m !== v), b && (l |= B.META_SHIFT_ON), a.ctrlKey && (l |= B.META_CTRL_ON), a.altKey && (l |= B.META_ALT_ON), a.metaKey && (l |= B.META_META_ON), { keycode: r, metaState: l };
571
- }
572
- function Nt(a, t) {
573
- const r = Object.keys(a);
574
- return r.length === Object.keys(t).length && r.every((l) => a[l] === t[l]);
575
- }
576
- const ui = Cn(
577
- ({
578
- className: a,
579
- url: t,
580
- token: r,
581
- sessionId: l,
582
- openUrl: p,
583
- watchOnly: v = !1,
584
- showFrame: m = !0,
585
- animateLid: b = !0,
586
- deviceModel: T,
587
- duoModelUrl: k,
588
- macbookModelUrl: I,
589
- autoReconnect: E,
590
- jitterBufferTargetMs: L,
591
- onPlaybackStats: U,
592
- onTerminated: se,
593
- assets: Me,
594
- onConnectionStateChange: me,
595
- inspectMode: C,
596
- onAxSnapshotChange: ae,
597
- onInspectSelectionChange: V,
598
- onAxStatusChange: S,
599
- axPollIntervalMs: u,
600
- axMaxBackoffMs: y,
601
- androidElementTreeOptions: M,
602
- onCameraDemandChange: W,
603
- onCameraStats: P,
604
- onTrace: Y,
605
- microphoneEnabled: j = !1,
606
- onMicrophoneStateChange: le
607
- }, te) => {
608
- const ye = Xe(() => Kn(t, r), [t, r]), q = v || ye, oe = H(null), R = H(null), Ae = H(null), [lt, ne] = D(!1), K = T === "iphone-duo" || lt, Re = T === "iphone-duo" ? T : void 0, $e = H(null), [Ft, Eo] = D(null), [Vt, No] = D(), [ko, _o] = D(!1), [Io, So] = D(!1), [xo, Po] = D(!1), [_t, Gt] = D(!1), [jt, qt] = D(!1), [Ho, Zt] = D({}), [Jt, Qt] = D(null), [It, Do] = D(null), [eo, Wo] = D(null), [to, oo] = D(null), et = Pn(() => pt.current?.release()), dt = H(!1), St = H(null), F = H(/* @__PURE__ */ new Map()), Oe = H(!1), [Lo, Yo] = D(!1), X = H(null), Be = H(null), tt = H({
609
- handle: () => {
610
- },
611
- end: () => {
612
- }
613
- }), [Ee, ut] = D(null), [no, xt] = D(null), [Pt, ot] = D(null), [Ht, ht] = D(null), [Xo, io] = D(null), [$o, ro] = D(null), ft = H(null), ve = H(void 0), co = (e) => {
614
- ft.current = e, ve.current === void 0 && (ve.current = window.requestAnimationFrame(() => {
615
- ve.current = void 0, ro(ft.current);
616
- }));
617
- }, [Bo, Ue] = D(null), Ne = H(null);
618
- Ne.current = no;
619
- const Ke = H(V);
620
- Ke.current = V;
621
- const ke = C === !0 || C === "hover-only", so = H(ke);
622
- so.current = ke;
623
- const Uo = C === "hover-only" ? "hover-only" : "select", z = Xe(() => pn(t), [t]), Ko = Xe(
624
- () => l || Array.from(crypto.getRandomValues(new Uint32Array(4)), (e) => e.toString(36)).join(""),
625
- [l]
626
- ), nt = z === "ios" && T && T !== "iphone-duo" ? T : void 0, _e = z === "android" && jt ? qn : nt ? jn[nt] : Gn[z], de = Me?.[z], ao = nt && de?.modelFrames?.[nt], lo = z === "android" && jt ? _t ? de?.tabletFrameLandscape : de?.tabletFrame : nt ? _t ? ao?.frameLandscape : ao?.frame : _t ? de?.frameLandscape : de?.frame, uo = de?.loadingLogo, it = !K && z !== "macos" && m && !!lo, pe = z === "macos" && m, Ie = pe && de?.frame && de.screen ? { src: de.frame, screen: de.screen } : void 0, Dt = H(null), zo = pe && et.mode === "3d", Se = pe && et.shown === "3d";
627
- dt.current = Se;
628
- const ho = et.choose;
629
- J(() => {
630
- pe || ho("2d");
631
- }, [pe, ho]);
632
- const N = H(null), he = (e) => N.current?.sendControl(e), mt = H(/* @__PURE__ */ new Set()), fo = H(!1);
633
- fo.current = C === !0;
634
- const pt = H(null);
635
- pt.current || (pt.current = new Sn(
636
- (e) => N.current?.sendControl(e),
637
- () => fo.current
638
- ));
639
- const xe = pt.current;
640
- J(() => () => xe.release(), [xe]);
641
- const rt = kt(() => {
642
- for (const e of mt.current)
643
- N.current?.sendControl(wo(Q.UP, e));
644
- mt.current.clear();
645
- }, []), Wt = (e, n) => N.current?.sendDuoControl(e, n) ?? Promise.reject(new Error("Simulator disconnected")), mo = -10, po = (e, n) => {
646
- const i = Fe();
647
- if (!i) return;
648
- const o = be(i, e, n);
649
- if (!o) return;
650
- const { videoX: c, videoY: d, videoWidth: s, videoHeight: h } = o, f = Rt(
651
- x.ACTION_DOWN,
652
- mo,
653
- s,
654
- h,
655
- c,
656
- d,
657
- 1,
658
- x.BUTTON_PRIMARY,
659
- x.BUTTON_PRIMARY
660
- );
661
- f && he(f), window.setTimeout(() => {
662
- const A = Rt(
663
- x.ACTION_UP,
664
- mo,
665
- s,
666
- h,
667
- c,
668
- d,
669
- 0,
670
- x.BUTTON_PRIMARY,
671
- x.BUTTON_PRIMARY
672
- );
673
- A && he(A);
674
- }, 60);
675
- }, Fo = (e, n) => {
676
- const i = Fe();
677
- if (!i || n.screen.width <= 0 || n.screen.height <= 0) return;
678
- const o = e.frame.x + e.frame.width / 2, c = e.frame.y + e.frame.height / 2, d = o / n.screen.width * i.actualWidth, s = c / n.screen.height * i.actualHeight, h = i.videoRect.left + i.offsetX + d, f = i.videoRect.top + i.offsetY + s;
679
- po(h, f);
680
- }, gt = -1, yt = -2, Pe = -3, ze = (e, n, i, o, c, d) => {
681
- const s = Rt(
682
- e,
683
- n,
684
- i,
685
- o,
686
- c,
687
- d,
688
- 1,
689
- // pressure
690
- x.BUTTON_PRIMARY,
691
- x.BUTTON_PRIMARY
692
- );
693
- s && (G("[rc-touch] sendSingleTouch", {
694
- action: e,
695
- actionName: Ot(e),
696
- pointerId: n,
697
- x: c,
698
- y: d,
699
- video: { width: i, height: o }
700
- }), he(s));
701
- }, He = (e, n, i) => {
702
- if (!i) return;
703
- const { videoX: o, videoY: c, videoWidth: d, videoHeight: s } = i;
704
- let h = null, f = null, A = 1;
705
- const _ = x.BUTTON_PRIMARY;
706
- switch (n) {
707
- case "down":
708
- e !== Pe && tt.current.end(), h = F.current.size === 0 ? x.ACTION_DOWN : x.ACTION_POINTER_DOWN, f = { x: o, y: c }, F.current.set(e, f), e === -1 && R.current?.focus();
709
- break;
710
- case "move":
711
- F.current.has(e) && (h = x.ACTION_MOVE, f = { x: o, y: c }, F.current.set(e, f));
712
- break;
713
- case "up":
714
- case "cancel":
715
- F.current.has(e) && (f = F.current.get(e), F.current.delete(e), n === "cancel" ? h = x.ACTION_CANCEL : h = F.current.size === 0 ? x.ACTION_UP : x.ACTION_POINTER_UP);
716
- break;
717
- }
718
- if (h !== null && f !== null) {
719
- G("[rc-touch][mouse->touch] sending", {
720
- pointerId: e,
721
- eventType: n,
722
- action: h,
723
- actionName: Ot(h),
724
- positionToSend: f,
725
- video: { width: d, height: s },
726
- altHeld: Oe.current,
727
- activePointersAfter: Array.from(F.current.entries()).map(([re, $]) => ({
728
- id: re,
729
- x: $.x,
730
- y: $.y
731
- }))
732
- });
733
- const g = Rt(
734
- h,
735
- e,
736
- d,
737
- s,
738
- f.x,
739
- f.y,
740
- A,
741
- _,
742
- _
743
- );
744
- g && (G("[rc-touch][mouse->touch] buffer", {
745
- pointerId: e,
746
- actionName: Ot(h),
747
- byteLength: g.byteLength
748
- }), he(g));
749
- } else (n === "up" || n === "cancel") && F.current.delete(e);
750
- }, Lt = (e) => {
751
- if (Oe.current !== e && (Oe.current = e, Yo(e), e || ut(null), G("[rc-touch][alt] updateAltHeld", {
752
- nextHeld: e,
753
- activePointerIds: Array.from(F.current.keys())
754
- }), z === "ios" && N.current?.getState().controlReady)) {
755
- const n = e ? B.ACTION_DOWN : B.ACTION_UP, i = Ct(
756
- n,
757
- B.KEYCODE_ALT_LEFT,
758
- 0,
759
- B.META_NONE
760
- );
761
- G("[rc-touch][alt] sending Indigo modifier keycode", {
762
- action: n,
763
- keycode: B.KEYCODE_ALT_LEFT
764
- }), i && he(i);
765
- }
766
- }, Fe = () => {
767
- const e = R.current, n = oe.current;
768
- if (!e || !n) return null;
769
- const i = e.videoWidth, o = e.videoHeight;
770
- if (!i || !o) return null;
771
- const c = e.getBoundingClientRect(), d = n.getBoundingClientRect(), s = c.width, h = c.height, f = i / o, A = s / h;
772
- let _ = s, g = h;
773
- f > A ? g = s / f : _ = h * f;
774
- const re = (s - _) / 2, $ = (h - g) / 2;
775
- return {
776
- videoWidth: i,
777
- videoHeight: o,
778
- videoRect: c,
779
- containerRect: d,
780
- actualWidth: _,
781
- actualHeight: g,
782
- offsetX: re,
783
- offsetY: $
784
- };
785
- }, be = (e, n, i) => {
786
- const o = n - e.videoRect.left - e.offsetX, c = i - e.videoRect.top - e.offsetY, d = Math.max(0, Math.min(e.actualWidth, o)), s = Math.max(0, Math.min(e.actualHeight, c)), h = Math.max(
787
- 0,
788
- Math.min(e.videoWidth, d / e.actualWidth * e.videoWidth)
789
- ), f = Math.max(
790
- 0,
791
- Math.min(e.videoHeight, s / e.actualHeight * e.videoHeight)
792
- );
793
- return {
794
- videoX: h,
795
- videoY: f,
796
- videoWidth: e.videoWidth,
797
- videoHeight: e.videoHeight
798
- };
799
- }, Vo = (e, n, i) => {
800
- const o = n - e.videoRect.left - e.offsetX, c = i - e.videoRect.top - e.offsetY, d = Math.max(0, Math.min(e.actualWidth, o)), s = Math.max(0, Math.min(e.actualHeight, c)), h = Math.max(
801
- 0,
802
- Math.min(e.videoWidth, d / e.actualWidth * e.videoWidth)
803
- ), f = Math.max(
804
- 0,
805
- Math.min(e.videoHeight, s / e.actualHeight * e.videoHeight)
806
- ), A = e.videoWidth - h, _ = e.videoHeight - f, g = e.videoRect.left + e.offsetX, re = e.videoRect.top + e.offsetY, $ = g - e.containerRect.left + d, Z = re - e.containerRect.top + s, ue = g - e.containerRect.left + (e.actualWidth - d), O = re - e.containerRect.top + (e.actualHeight - s);
807
- return {
808
- containerX: $,
809
- containerY: Z,
810
- mirrorContainerX: ue,
811
- mirrorContainerY: O,
812
- videoX: h,
813
- videoY: f,
814
- mirrorVideoX: A,
815
- mirrorVideoY: _,
816
- videoWidth: e.videoWidth,
817
- videoHeight: e.videoHeight
818
- };
819
- }, Go = (e, n, i, o, c, d, s) => {
820
- const h = An(e, n, i, o, c, d, s);
821
- G("[rc-touch2] sendTwoFingerMessage (iOS)", {
822
- actionName: Ot(e),
823
- video: { width: n, height: i },
824
- p0: { x: o, y: c },
825
- p1: { x: d, y: s },
826
- byteLength: h.byteLength
827
- }), he(h);
828
- }, Ve = (e, n, i, o, c, d, s, h, f) => {
829
- if (G("[rc-touch2] applyTwoFingerEvent", {
830
- platform: z,
831
- eventType: e,
832
- video: { width: n, height: i },
833
- p0: { x: o, y: c, id: h },
834
- p1: { x: d, y: s, id: f }
835
- }), e === "down" && tt.current.end(), z === "ios") {
836
- const A = e === "down" ? x.ACTION_DOWN : e === "move" ? x.ACTION_MOVE : x.ACTION_UP;
837
- Go(A, n, i, o, c, d, s);
838
- } else
839
- e === "down" ? (ze(x.ACTION_DOWN, h, n, i, o, c), ze(x.ACTION_POINTER_DOWN, f, n, i, d, s)) : e === "move" ? (ze(x.ACTION_MOVE, h, n, i, o, c), ze(x.ACTION_MOVE, f, n, i, d, s)) : (ze(x.ACTION_POINTER_UP, f, n, i, d, s), ze(x.ACTION_UP, h, n, i, o, c));
840
- }, jo = (e, n, i) => {
841
- if (!Oe.current) {
842
- Ee !== null && ut(null);
843
- return;
844
- }
845
- const o = Vo(e, n, i);
846
- ut(o);
847
- }, qo = (e, n, i) => {
848
- const o = Ne.current;
849
- if (!o || o.screen.width <= 0 || o.screen.height <= 0) return null;
850
- const c = n - e.videoRect.left - e.offsetX, d = i - e.videoRect.top - e.offsetY;
851
- if (c < 0 || d < 0 || c > e.actualWidth || d > e.actualHeight) return null;
852
- const s = c / e.actualWidth * o.screen.width, h = d / e.actualHeight * o.screen.height;
853
- return wn(o, s, h);
854
- }, Zo = (e) => ({
855
- map: (n, i) => {
856
- const o = be(e, n, i);
857
- if (o)
858
- return {
859
- x: o.videoX,
860
- y: o.videoY,
861
- width: o.videoWidth,
862
- height: o.videoHeight
863
- };
864
- },
865
- // A finger on the frame, or a letterbox bar, is not on the guest's screen.
866
- contains: (n, i) => {
867
- const o = n - e.videoRect.left - e.offsetX, c = i - e.videoRect.top - e.offsetY;
868
- return o >= 0 && o <= e.actualWidth && c >= 0 && c <= e.actualHeight;
869
- },
870
- scale: e.actualWidth > 0 ? e.videoWidth / e.actualWidth : 1
871
- }), Te = (e) => {
872
- if (K || dt.current) return;
873
- e.preventDefault(), e.stopPropagation();
874
- const n = Fe();
875
- if ((C === !0 || C === "hover-only") && !("touches" in e))
876
- if (e.type === "mousemove") {
877
- if (co({ x: e.clientX, y: e.clientY }), n) {
878
- const o = qo(n, e.clientX, e.clientY);
879
- ot(o?.id ?? null);
880
- }
881
- } else e.type === "mouseleave" && (co(null), ot(null));
882
- if (C !== !0) {
883
- if (z === "macos") {
884
- if (!n || !N.current?.getState().controlReady) return;
885
- if ("touches" in e) {
886
- const s = Array.from(e.touches, (h) => ({ x: h.clientX, y: h.clientY }));
887
- xe.touch(e.type, s, Zo(n)) && R.current?.focus();
888
- return;
889
- }
890
- const o = be(n, e.clientX, e.clientY);
891
- if (!o) return;
892
- const c = e.type === "mousedown" ? Q.DOWN : e.type === "mouseup" ? Q.UP : Q.MOVE, d = e.type === "mouseleave" ? 0 : e.buttons;
893
- e.type === "mousedown" && R.current?.focus(), xe.pointer(
894
- c,
895
- {
896
- x: o.videoX,
897
- y: o.videoY,
898
- width: o.videoWidth,
899
- height: o.videoHeight
900
- },
901
- d
902
- );
903
- return;
904
- }
905
- if (!("touches" in e) && n && (e.type === "mousemove" ? jo(n, e.clientX, e.clientY) : e.type === "mouseleave" && ut(null)), !(!N.current?.getState().controlReady || !R.current || !n))
906
- if ("touches" in e) {
907
- const o = e.touches, c = e.changedTouches;
908
- let d;
909
- switch (e.type) {
910
- case "touchstart":
911
- d = "down";
912
- break;
913
- case "touchmove":
914
- d = "move";
915
- break;
916
- case "touchend":
917
- d = "up";
918
- break;
919
- case "touchcancel":
920
- d = "cancel";
921
- break;
922
- default:
923
- return;
924
- }
925
- if (o.length === 2) {
926
- const s = o[0], h = o[1], f = be(n, s.clientX, s.clientY), A = be(n, h.clientX, h.clientY);
927
- if (!f || !A) return;
928
- X.current ? X.current.source === "real-touch" && (X.current.finger0 = { x: f.videoX, y: f.videoY }, X.current.finger1 = { x: A.videoX, y: A.videoY }, Ve(
929
- "move",
930
- f.videoWidth,
931
- f.videoHeight,
932
- f.videoX,
933
- f.videoY,
934
- A.videoX,
935
- A.videoY,
936
- X.current.pointerId0,
937
- X.current.pointerId1
938
- )) : (X.current = {
939
- finger0: { x: f.videoX, y: f.videoY },
940
- finger1: { x: A.videoX, y: A.videoY },
941
- videoSize: { width: f.videoWidth, height: f.videoHeight },
942
- source: "real-touch",
943
- pointerId0: s.identifier,
944
- pointerId1: h.identifier
945
- }, Ve(
946
- "down",
947
- f.videoWidth,
948
- f.videoHeight,
949
- f.videoX,
950
- f.videoY,
951
- A.videoX,
952
- A.videoY,
953
- s.identifier,
954
- h.identifier
955
- ));
956
- } else if (o.length < 2 && X.current?.source === "real-touch") {
957
- const s = X.current;
958
- Ve(
959
- "up",
960
- s.videoSize.width,
961
- s.videoSize.height,
962
- s.finger0.x,
963
- s.finger0.y,
964
- s.finger1.x,
965
- s.finger1.y,
966
- s.pointerId0,
967
- s.pointerId1
968
- ), X.current = null;
969
- return;
970
- } else {
971
- if (o.length > 2)
972
- return;
973
- {
974
- const s = c[0];
975
- if (s) {
976
- const h = be(n, s.clientX, s.clientY);
977
- He(s.identifier, d, h);
978
- }
979
- }
980
- }
981
- } else {
982
- let c = null;
983
- const d = X.current?.source === "alt-mouse";
984
- switch (e.type) {
985
- case "mousedown":
986
- e.button === 0 && (c = "down");
987
- break;
988
- case "mousemove":
989
- (d || F.current.has(-1)) && (c = "move");
990
- break;
991
- case "mouseup":
992
- e.button === 0 && (c = "up");
993
- break;
994
- case "mouseleave":
995
- (d || F.current.has(-1)) && (c = "up");
996
- break;
997
- }
998
- if (c) {
999
- const s = be(n, e.clientX, e.clientY);
1000
- if (!s)
1001
- return;
1002
- G("[rc-touch][mouse] event", {
1003
- domType: e.type,
1004
- eventType: c,
1005
- button: e.button,
1006
- buttons: e.buttons,
1007
- client: { x: e.clientX, y: e.clientY },
1008
- altHeldRef: Oe.current,
1009
- inTwoFingerMode: d,
1010
- geometry: {
1011
- videoX: s.videoX,
1012
- videoY: s.videoY,
1013
- videoWidth: s.videoWidth,
1014
- videoHeight: s.videoHeight
1015
- },
1016
- activePointerIds: Array.from(F.current.keys())
1017
- }), Oe.current || d ? Jo(c, s) : He(-1, c, s);
1018
- }
1019
- }
1020
- }
1021
- }, Jo = (e, n) => {
1022
- const { videoX: i, videoY: o, videoWidth: c, videoHeight: d } = n, s = c - i, h = d - o;
1023
- if (e === "down") {
1024
- X.current = {
1025
- finger0: { x: i, y: o },
1026
- finger1: { x: s, y: h },
1027
- videoSize: { width: c, height: d },
1028
- source: "alt-mouse",
1029
- pointerId0: gt,
1030
- pointerId1: yt
1031
- }, R.current?.focus(), Ve(
1032
- "down",
1033
- c,
1034
- d,
1035
- i,
1036
- o,
1037
- s,
1038
- h,
1039
- gt,
1040
- yt
1041
- );
1042
- return;
1043
- }
1044
- if (e === "move") {
1045
- X.current?.source === "alt-mouse" && (X.current.finger0 = { x: i, y: o }, X.current.finger1 = { x: s, y: h }, Ve(
1046
- "move",
1047
- c,
1048
- d,
1049
- i,
1050
- o,
1051
- s,
1052
- h,
1053
- gt,
1054
- yt
1055
- ));
1056
- return;
1057
- }
1058
- if (e === "up" || e === "cancel") {
1059
- const f = X.current;
1060
- if (f?.source === "alt-mouse") {
1061
- const { finger0: A, finger1: _, videoSize: g } = f;
1062
- Ve(
1063
- "up",
1064
- g.width,
1065
- g.height,
1066
- A.x,
1067
- A.y,
1068
- _.x,
1069
- _.y,
1070
- gt,
1071
- yt
1072
- ), X.current = null;
1073
- }
1074
- return;
1075
- }
1076
- }, Qo = 150, go = () => {
1077
- const e = Be.current;
1078
- e && (window.clearTimeout(e.endTimer), He(Pe, "up", e.pos), Be.current = null);
1079
- }, en = (e) => {
1080
- if (!N.current?.getState().controlReady || e.ctrlKey) return;
1081
- if (z === "macos") {
1082
- if (dt.current) return;
1083
- const O = Fe();
1084
- if (!O) return;
1085
- const De = e.clientX - O.videoRect.left - O.offsetX, we = e.clientY - O.videoRect.top - O.offsetY;
1086
- if (De < 0 || De > O.actualWidth || we < 0 || we > O.actualHeight)
1087
- return;
1088
- const ge = be(O, e.clientX, e.clientY);
1089
- if (!ge) return;
1090
- e.preventDefault();
1091
- const je = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? O.actualHeight : 1;
1092
- xe.scroll(
1093
- { x: ge.videoX, y: ge.videoY, width: ge.videoWidth, height: ge.videoHeight },
1094
- e.deltaX * je,
1095
- e.deltaY * je
1096
- );
1097
- return;
1098
- }
1099
- if (Oe.current || X.current) return;
1100
- const n = F.current.size;
1101
- if (n > 1 || n === 1 && !F.current.has(Pe)) return;
1102
- const i = Fe();
1103
- if (!i) return;
1104
- const o = e.clientX - i.videoRect.left - i.offsetX, c = e.clientY - i.videoRect.top - i.offsetY;
1105
- if (o < 0 || o > i.actualWidth || c < 0 || c > i.actualHeight)
1106
- return;
1107
- const d = be(i, e.clientX, e.clientY);
1108
- if (!d) return;
1109
- e.preventDefault();
1110
- const s = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? i.actualWidth : 1) * (i.videoWidth / i.actualWidth), h = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? i.actualHeight : 1) * (i.videoHeight / i.actualHeight), f = -e.deltaX * s, A = -e.deltaY * h, _ = (O) => {
1111
- window.clearTimeout(O.endTimer), O.endTimer = window.setTimeout(go, Qo);
1112
- };
1113
- if (f === 0 && A === 0) {
1114
- Be.current && _(Be.current);
1115
- return;
1116
- }
1117
- const g = () => ({
1118
- videoWidth: d.videoWidth,
1119
- videoHeight: d.videoHeight,
1120
- videoX: Math.abs(f) > Math.abs(A) ? Math.min(Math.max(d.videoX, d.videoWidth * 0.2), d.videoWidth * 0.8) : d.videoX,
1121
- videoY: Math.abs(A) >= Math.abs(f) ? Math.min(Math.max(d.videoY, d.videoHeight * 0.2), d.videoHeight * 0.8) : d.videoY
1122
- }), re = (O) => ({
1123
- ...O,
1124
- videoX: Math.min(Math.max(O.videoX + f, 0), O.videoWidth),
1125
- videoY: Math.min(Math.max(O.videoY + A, 0), O.videoHeight)
1126
- });
1127
- let $ = Be.current;
1128
- if ($)
1129
- window.clearTimeout($.endTimer);
1130
- else {
1131
- const O = g();
1132
- He(Pe, "down", O), $ = { pos: O, endTimer: 0 }, Be.current = $;
1133
- }
1134
- let Z = $.pos, ue = re(Z);
1135
- ue.videoX === Z.videoX && ue.videoY === Z.videoY && (He(Pe, "up", Z), Z = g(), He(Pe, "down", Z), ue = re(Z)), He(Pe, "move", ue), $.pos = ue, _($);
1136
- };
1137
- J(() => {
1138
- tt.current = { handle: en, end: go };
1139
- }), J(() => {
1140
- const e = oe.current;
1141
- if (!e) return;
1142
- const n = (i) => tt.current.handle(i);
1143
- return e.addEventListener("wheel", n, { passive: !1 }), () => {
1144
- tt.current.end(), e.removeEventListener("wheel", n);
1145
- };
1146
- }, []), J(() => {
1147
- const e = (c) => {
1148
- c.key === "Alt" && Lt(!0);
1149
- }, n = (c) => {
1150
- c.key === "Alt" && Lt(!1);
1151
- }, i = () => {
1152
- Lt(!1), rt();
1153
- }, o = () => {
1154
- document.hidden && rt();
1155
- };
1156
- return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", n, !0), window.addEventListener("blur", i), document.addEventListener("visibilitychange", o), () => {
1157
- window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", n, !0), window.removeEventListener("blur", i), document.removeEventListener("visibilitychange", o);
1158
- };
1159
- }, [rt]);
1160
- const Ge = (e) => {
1161
- e.preventDefault(), e.stopPropagation();
1162
- const n = document.activeElement === R.current || (K || dt.current) && document.activeElement === e.currentTarget;
1163
- if (G("Keyboard event:", {
1164
- type: e.type,
1165
- key: e.key,
1166
- keyCode: e.keyCode,
1167
- code: e.code,
1168
- target: e.target.tagName,
1169
- focused: n
1170
- }), !n) {
1171
- Bt("Simulator input not focused, skipping keyboard event");
1172
- return;
1173
- }
1174
- if (!N.current?.getState().controlReady) {
1175
- Bt("Data channel not ready for keyboard event:", N.current?.getState().connection);
1176
- return;
1177
- }
1178
- if (z === "macos") {
1179
- if (e.type === "keydown" && e.repeat) return;
1180
- const o = vn(e.code);
1181
- if (o === void 0) {
1182
- G(`Ignoring unmapped key for macOS: code=${e.code}`);
1183
- return;
1184
- }
1185
- e.type === "keydown" ? mt.current.add(o) : mt.current.delete(o), he(
1186
- wo(
1187
- e.type === "keydown" ? Q.DOWN : Q.UP,
1188
- o
1189
- )
1190
- );
1191
- return;
1192
- }
1193
- if (e.type === "keydown") {
1194
- if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
1195
- G("Paste shortcut detected"), navigator.clipboard.readText().then((o) => {
1196
- if (o) {
1197
- G(
1198
- "Pasting text via SET_CLIPBOARD:",
1199
- o.substring(0, 20) + (o.length > 20 ? "..." : "")
1200
- );
1201
- const c = bn(o, !0);
1202
- he(c);
1203
- }
1204
- }).catch((o) => {
1205
- console.error("Failed to read clipboard contents: ", o);
1206
- });
1207
- return;
1208
- }
1209
- if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
1210
- G("Menu shortcut detected");
1211
- const o = Ct(
1212
- B.ACTION_DOWN,
1213
- B.MENU,
1214
- 0,
1215
- B.META_NONE
1216
- // Modifiers are handled by the shortcut check, not passed down
1217
- );
1218
- he(o);
1219
- const c = Ct(
1220
- B.ACTION_UP,
1221
- B.MENU,
1222
- 0,
1223
- B.META_NONE
1224
- );
1225
- he(c);
1226
- return;
1227
- }
1228
- }
1229
- const i = Zn(e);
1230
- if (i) {
1231
- const { keycode: o, metaState: c } = i, d = e.type === "keydown" ? B.ACTION_DOWN : B.ACTION_UP;
1232
- G(`Sending Keycode: key=${e.key}, code=${o}, action=${d}, meta=${c}`);
1233
- const s = Ct(
1234
- d,
1235
- o,
1236
- 0,
1237
- // repeat count, typically 0 for single presses
1238
- c
1239
- );
1240
- he(s);
1241
- } else
1242
- G(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
1243
- }, tn = (e) => {
1244
- e.stopPropagation(), N.current?.reconnect();
1245
- }, ie = H({
1246
- onAxSnapshotChange: ae,
1247
- onAxStatusChange: S,
1248
- onCameraDemandChange: W,
1249
- onCameraStats: P,
1250
- onMicrophoneStateChange: le,
1251
- onTrace: Y,
1252
- onTerminated: se,
1253
- onConnectionStateChange: me,
1254
- onPlaybackStats: U
1255
- });
1256
- ie.current = {
1257
- onAxSnapshotChange: ae,
1258
- onAxStatusChange: S,
1259
- onCameraDemandChange: W,
1260
- onCameraStats: P,
1261
- onMicrophoneStateChange: le,
1262
- onTrace: Y,
1263
- onTerminated: se,
1264
- onConnectionStateChange: me,
1265
- onPlaybackStats: U
1266
- };
1267
- const Yt = !!Y;
1268
- J(() => {
1269
- St.current = null, Gt(!1), qt(!1), Zt({}), Qt(null);
1270
- }, [t, Re]), J(() => {
1271
- let e = !0;
1272
- Ne.current !== null && (Ne.current = null, xt(null), Qe("onAxSnapshotChange", ie.current.onAxSnapshotChange, null));
1273
- const n = gn({
1274
- url: t,
1275
- token: r,
1276
- sessionId: Ko,
1277
- watchOnly: q,
1278
- deviceModel: Re,
1279
- autoReconnect: E,
1280
- jitterBufferTargetMs: L,
1281
- openUrl: p,
1282
- inspectMode: C,
1283
- axPollIntervalMs: u,
1284
- axMaxBackoffMs: y,
1285
- androidElementTreeOptions: M,
1286
- microphoneEnabled: j,
1287
- onStateChange: (o) => {
1288
- (o.videoReady || o.connection === "idle" || o.connection === "connecting" || o.connection === "reconnecting") && _o(o.videoReady), So(o.connection === "failed"), Po(o.connection === "terminated"), ne(o.duo), Eo(o.duoState), No(o.duoError);
1289
- },
1290
- onAxSnapshotChange: (o) => {
1291
- e && (xt((c) => yn(c, o) ? c : o), ie.current.onAxSnapshotChange?.(o));
1292
- },
1293
- onAxStatusChange: (...o) => ie.current.onAxStatusChange?.(...o),
1294
- onCameraDemandChange: (...o) => ie.current.onCameraDemandChange?.(...o),
1295
- onCameraStats: P ? (...o) => ie.current.onCameraStats?.(...o) : void 0,
1296
- onMicrophoneStateChange: (...o) => ie.current.onMicrophoneStateChange?.(...o),
1297
- onTrace: Yt ? (...o) => ie.current.onTrace?.(...o) : void 0,
1298
- onTerminated: () => ie.current.onTerminated?.(),
1299
- onConnectionStateChange: (...o) => ie.current.onConnectionStateChange?.(...o),
1300
- onPlaybackStats: U ? (...o) => ie.current.onPlaybackStats?.(...o) : void 0
1301
- });
1302
- N.current = n;
1303
- const i = R.current ? n.attachVideo(R.current) : void 0;
1304
- return n.start(), () => {
1305
- e = !1, n.dispose(), i?.(), N.current = null;
1306
- };
1307
- }, [t, l, Re, Yt, q]), J(() => {
1308
- if (K && $e.current)
1309
- return N.current?.attachVideo($e.current, "inner");
1310
- }, [K, t, l, Re, Yt, q]), J(() => {
1311
- N.current?.updateOptions({
1312
- token: r,
1313
- openUrl: p,
1314
- axPollIntervalMs: u,
1315
- axMaxBackoffMs: y,
1316
- androidElementTreeOptions: M,
1317
- autoReconnect: E,
1318
- jitterBufferTargetMs: L,
1319
- microphoneEnabled: j,
1320
- inspectMode: C,
1321
- onPlaybackStats: U ? (...e) => ie.current.onPlaybackStats?.(...e) : void 0,
1322
- onCameraStats: P ? (...e) => ie.current.onCameraStats?.(...e) : void 0
1323
- });
1324
- }, [
1325
- r,
1326
- E,
1327
- L,
1328
- j,
1329
- C,
1330
- !!U,
1331
- !!P,
1332
- p,
1333
- u,
1334
- y,
1335
- M
1336
- ]);
1337
- const ct = () => {
1338
- if (!so.current) return;
1339
- const e = Fe();
1340
- if (!e) {
1341
- io(null);
1342
- return;
1343
- }
1344
- const n = {
1345
- left: e.videoRect.left - e.containerRect.left + e.offsetX,
1346
- top: e.videoRect.top - e.containerRect.top + e.offsetY,
1347
- width: e.actualWidth,
1348
- height: e.actualHeight
1349
- };
1350
- io(
1351
- (i) => i && i.left === n.left && i.top === n.top && i.width === n.width && i.height === n.height ? i : n
1352
- );
1353
- };
1354
- J(() => {
1355
- const e = R.current, n = Ae.current, i = oe.current;
1356
- if (!e) return;
1357
- const o = (_) => Zt((g) => Nt(g, _) ? g : _), c = (_) => Qt((g) => g && _ && Nt(g, _) ? g : _), d = (_) => Do((g) => g && _ && Nt(g, _) ? g : _), s = () => {
1358
- const _ = e.videoWidth > 0 && e.videoHeight > 0;
1359
- _ && (St.current = { width: e.videoWidth, height: e.videoHeight });
1360
- const g = St.current, re = g ? `${g.width} / ${g.height}` : void 0, $ = Dt.current;
1361
- if (Ie && i) {
1362
- if (oo(g ? g.width / g.height : $t), !$?.naturalWidth) return;
1363
- const We = $.naturalWidth / $.naturalHeight, vt = i.clientHeight - Et, Le = i.clientHeight > 0 ? Math.min(i.clientWidth, vt * We) : i.clientWidth;
1364
- if (Le <= 0) return;
1365
- const qe = Le / We, Ce = i.clientHeight > 0 ? Et / 2 : 0, { screen: fe } = Ie, bt = fe.notch ?? 0, Ze = fe.left * Le, Je = fe.top * qe, wt = fe.width * Le, Mt = fe.height * qe, vo = g ? g.width / g.height : $t, At = Math.min(wt, Mt * vo), Xt = At / vo, rn = Ze + (wt - At) / 2, cn = bt > 0 ? Je : Je + (Mt - Xt) / 2, bo = (st, Tt, sn, an) => `translate(calc(-50% + ${st + sn / 2 - Le / 2}px), calc(-50% + ${Tt + an / 2 - qe / 2 + Ce}px))`;
1366
- o({
1367
- width: `${At}px`,
1368
- height: `${Xt}px`,
1369
- transform: bo(rn, cn, At, Xt)
1370
- }), Wo((st) => {
1371
- const Tt = {
1372
- width: `${wt}px`,
1373
- height: `${Mt}px`,
1374
- transform: bo(Ze, Je, wt, Mt)
1375
- };
1376
- return st && Nt(st, Tt) ? st : Tt;
1377
- }), d({
1378
- width: `${Le}px`,
1379
- height: `${qe}px`,
1380
- transform: Ce ? `translateY(${Ce}px)` : void 0
1381
- }), c(null), ct();
1382
- return;
1383
- }
1384
- if (pe && i) {
1385
- const We = g ? g.width / g.height : $t, vt = i.clientWidth * 100 / at, qe = (i.clientHeight - Et) / (1 / We + Kt / 100), Ce = i.clientHeight > 0 ? Math.min(vt, qe) : vt;
1386
- if (Ce <= 0) return;
1387
- const fe = Ce / 100, bt = Ce / We, Ze = i.clientHeight > 0 ? Et / 2 : 0, Je = `${fe * ce.screenRadius}px`;
1388
- o({
1389
- aspectRatio: `${We}`,
1390
- width: `${Ce}px`,
1391
- height: `${bt}px`,
1392
- borderRadius: `${Je} ${Je} 0 0`,
1393
- transform: `translate(-50%, calc(-50% - ${fe * En - Ze}px))`
1394
- }), d({
1395
- width: `${fe * at}px`,
1396
- height: `${bt + fe * Kt}px`,
1397
- transform: Ze ? `translateY(${Ze}px)` : void 0,
1398
- "--rc-macbook-unit": `${fe}px`
1399
- }), oo(We), c(null), ct();
1400
- return;
1401
- }
1402
- if (d(null), !it || !n) {
1403
- o(
1404
- !_ && g ? {
1405
- aspectRatio: re,
1406
- contain: "size",
1407
- containIntrinsicSize: `${g.width}px ${g.height}px`
1408
- } : {}
1409
- ), c(null), ct();
1410
- return;
1411
- }
1412
- const Z = n.clientWidth, ue = n.clientHeight;
1413
- if (Z === 0 || ue === 0) return;
1414
- const O = g ? g.width > g.height : !1;
1415
- Gt(O), qt(
1416
- z === "android" && !!g && Vn(g.width, g.height)
1417
- );
1418
- const De = O ? _e.videoPosition.landscape : _e.videoPosition.portrait;
1419
- let we = { aspectRatio: re };
1420
- De.heightMultiplier ? (we.height = `${ue * De.heightMultiplier}px`, we.width = "auto") : De.widthMultiplier && (we.width = `${Z * De.widthMultiplier}px`, we.height = "auto"), we.borderRadius = `${O ? ue * _e.videoBorderRadiusMultiplier : Z * _e.videoBorderRadiusMultiplier}px`, o(we);
1421
- const ge = _e.homeButton, je = O ? Z : ue, yo = `calc(50% + ${je * (ge?.offset ?? 0)}px)`;
1422
- c(
1423
- ge ? {
1424
- width: `${je * ge.diameter}px`,
1425
- height: `${je * ge.diameter}px`,
1426
- left: O ? yo : "50%",
1427
- top: O ? "50%" : yo
1428
- } : null
1429
- ), ct();
1430
- }, h = new ResizeObserver(() => {
1431
- s();
1432
- });
1433
- n && h.observe(n), h.observe(e), i && h.observe(i), n && n.addEventListener("load", s);
1434
- const f = Dt.current;
1435
- f?.addEventListener("load", s), e.addEventListener("loadedmetadata", s), e.addEventListener("resize", s);
1436
- const A = () => N.current?.bumpActivity();
1437
- return e.addEventListener("resize", A), s(), () => {
1438
- h.disconnect(), e.removeEventListener("loadedmetadata", s), e.removeEventListener("resize", s), e.removeEventListener("resize", A), n && n.removeEventListener("load", s), f?.removeEventListener("load", s);
1439
- };
1440
- }, [_e, it, pe, Ie?.src, Se, t, T]), J(() => {
1441
- ke ? ct() : (xt(null), ot(null), ht(null), ro(null), Ue(null), ft.current = null, ve.current !== void 0 && (window.cancelAnimationFrame(ve.current), ve.current = void 0));
1442
- }, [ke]), J(() => () => {
1443
- ve.current !== void 0 && (window.cancelAnimationFrame(ve.current), ve.current = void 0);
1444
- }, []), J(() => {
1445
- if (!ke) return;
1446
- const e = (n) => {
1447
- n.key === "Escape" && (Ht || Pt) && (ht(null), ot(null), Ue(null), Qe("onInspectSelectionChange", Ke.current, null));
1448
- };
1449
- return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1450
- }, [ke, Ht, Pt]);
1451
- const on = () => {
1452
- R.current && R.current.focus();
1453
- };
1454
- Rn(te, () => ({
1455
- openUrl: (e) => N.current?.openUrl(e),
1456
- sendKeyEvent: (e) => N.current?.sendKeyEvent(e),
1457
- screenshot: (e) => N.current?.screenshot(e) ?? Promise.reject(new Error("Simulator disconnected")),
1458
- terminateApp: (e) => N.current?.terminateApp(e) ?? Promise.reject(new Error("Simulator disconnected")),
1459
- reconnect: () => N.current?.reconnect(),
1460
- refreshAxTree: () => N.current?.refreshAxTree() ?? Promise.reject(new Error("Simulator disconnected")),
1461
- getAxSnapshot: () => N.current?.getAxSnapshot() ?? null,
1462
- setInspectHighlight: (e) => {
1463
- ot(e?.id ?? null);
1464
- },
1465
- setInspectSelection: (e) => {
1466
- ht(e?.id ?? null), Ue(e ? ft.current : null);
1467
- const n = Ne.current;
1468
- e && n ? Qe("onInspectSelectionChange", Ke.current, { element: e, snapshot: n }) : Qe("onInspectSelectionChange", Ke.current, null);
1469
- },
1470
- getAxStatus: () => N.current?.getAxStatus() ?? "idle"
1471
- }));
1472
- const nn = Lo && Ee !== null;
1473
- return /* @__PURE__ */ ee(
1474
- "div",
1475
- {
1476
- ref: oe,
1477
- className: ["rc-container", a].filter(Boolean).join(" "),
1478
- style: { touchAction: "none" },
1479
- onMouseDown: Te,
1480
- onMouseMove: Te,
1481
- onMouseUp: Te,
1482
- onMouseLeave: Te,
1483
- onTouchStart: Te,
1484
- onTouchMove: Te,
1485
- onTouchEnd: Te,
1486
- onTouchCancel: Te,
1487
- onContextMenu: z === "macos" ? (e) => e.preventDefault() : void 0,
1488
- children: [
1489
- nn && Ee && /* @__PURE__ */ ee(Co, { children: [
1490
- /* @__PURE__ */ w(
1491
- "div",
1492
- {
1493
- className: "rc-touch-indicator",
1494
- style: {
1495
- left: `${Ee.containerX}px`,
1496
- top: `${Ee.containerY}px`
1497
- }
1498
- }
1499
- ),
1500
- /* @__PURE__ */ w(
1501
- "div",
1502
- {
1503
- className: "rc-touch-indicator",
1504
- style: {
1505
- left: `${Ee.mirrorContainerX}px`,
1506
- top: `${Ee.mirrorContainerY}px`
1507
- }
1508
- }
1509
- )
1510
- ] }),
1511
- it && /* @__PURE__ */ w(
1512
- "img",
1513
- {
1514
- ref: Ae,
1515
- src: lo,
1516
- alt: "",
1517
- className: z === "ios" ? "rc-phone-frame rc-phone-frame-ios" : "rc-phone-frame",
1518
- draggable: !1
1519
- }
1520
- ),
1521
- Ie && !Se && eo && /* @__PURE__ */ w("div", { className: "rc-macbook-screen", style: eo, "aria-hidden": "true" }),
1522
- Ie && !Se && /* @__PURE__ */ w(
1523
- "img",
1524
- {
1525
- ref: Dt,
1526
- src: Ie.src,
1527
- alt: "",
1528
- className: "rc-macbook-image",
1529
- style: It ?? { visibility: "hidden" },
1530
- draggable: !1
1531
- }
1532
- ),
1533
- pe && !Ie && It && !Se && /* @__PURE__ */ ee("div", { className: "rc-macbook", style: It, "aria-hidden": "true", children: [
1534
- /* @__PURE__ */ w("div", { className: "rc-macbook-lid", children: /* @__PURE__ */ w("div", { className: "rc-macbook-camera" }) }),
1535
- /* @__PURE__ */ w("div", { className: "rc-macbook-base" })
1536
- ] }),
1537
- it && Jt && !q && /* @__PURE__ */ w(
1538
- "button",
1539
- {
1540
- type: "button",
1541
- className: "rc-home-button",
1542
- "aria-label": "Home",
1543
- title: "Home",
1544
- style: Jt,
1545
- onMouseDown: (e) => e.stopPropagation(),
1546
- onTouchStart: (e) => e.stopPropagation(),
1547
- onTouchEnd: (e) => {
1548
- e.stopPropagation(), e.preventDefault(), N.current?.pressButton("home");
1549
- },
1550
- onClick: (e) => {
1551
- e.stopPropagation(), N.current?.pressButton("home");
1552
- }
1553
- }
1554
- ),
1555
- /* @__PURE__ */ w(
1556
- "video",
1557
- {
1558
- ref: R,
1559
- className: [
1560
- "rc-video",
1561
- !it && !pe && "rc-video-frameless",
1562
- !ko && (z === "macos" ? "rc-video-loading-desktop" : "rc-video-loading")
1563
- ].filter(Boolean).join(" "),
1564
- style: {
1565
- ...Ho,
1566
- ...K || Se ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
1567
- ...uo ? {
1568
- backgroundImage: `url("${uo}")`,
1569
- backgroundRepeat: "no-repeat",
1570
- backgroundPosition: "center",
1571
- backgroundSize: _e.loadingLogoSize
1572
- } : {}
1573
- },
1574
- autoPlay: !0,
1575
- playsInline: !0,
1576
- muted: !0,
1577
- tabIndex: K || Se ? -1 : 0,
1578
- onKeyDown: Ge,
1579
- onKeyUp: Ge,
1580
- onClick: on,
1581
- onFocus: () => {
1582
- R.current && (R.current.style.outline = "none");
1583
- },
1584
- onBlur: () => {
1585
- R.current && (R.current.style.outline = "none"), rt();
1586
- }
1587
- }
1588
- ),
1589
- zo && to && /* @__PURE__ */ w(Mo, { fallback: null, children: /* @__PURE__ */ w(
1590
- Fn,
1591
- {
1592
- video: R.current,
1593
- aspect: to,
1594
- model: I ?? de?.model,
1595
- animateLid: b,
1596
- watchOnly: q,
1597
- onReady: et.onReady,
1598
- pointer: (e, n, i, o) => {
1599
- const c = R.current;
1600
- !c?.videoWidth || !N.current?.getState().controlReady || xe.pointer(
1601
- e === "down" ? Q.DOWN : e === "up" ? Q.UP : Q.MOVE,
1602
- {
1603
- x: n * c.videoWidth,
1604
- y: i * c.videoHeight,
1605
- width: c.videoWidth,
1606
- height: c.videoHeight
1607
- },
1608
- o
1609
- );
1610
- },
1611
- scroll: (e, n, i, o) => {
1612
- const c = R.current;
1613
- !c?.videoWidth || !N.current?.getState().controlReady || xe.scroll(
1614
- {
1615
- x: e * c.videoWidth,
1616
- y: n * c.videoHeight,
1617
- width: c.videoWidth,
1618
- height: c.videoHeight
1619
- },
1620
- i,
1621
- o
1622
- );
1623
- },
1624
- onKeyDown: Ge,
1625
- onKeyUp: Ge,
1626
- onBlur: rt
1627
- }
1628
- ) }),
1629
- pe && /* @__PURE__ */ w(Hn, { view: et, label: "MacBook rendering" }),
1630
- K && /* @__PURE__ */ w(
1631
- "video",
1632
- {
1633
- ref: $e,
1634
- autoPlay: !0,
1635
- playsInline: !0,
1636
- muted: !0,
1637
- style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
1638
- }
1639
- ),
1640
- K && Ft && /* @__PURE__ */ w(Mo, { fallback: /* @__PURE__ */ w("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ w(
1641
- zn,
1642
- {
1643
- watchOnly: q,
1644
- showFrame: m,
1645
- model: k ?? de?.model,
1646
- outer: R.current,
1647
- inner: $e.current,
1648
- state: Ft,
1649
- setAngle: (e) => Wt("setHingeAngle", { angleDegrees: e }),
1650
- setOrientation: (e) => Wt("setDuoOrientation", { orientation: e }),
1651
- button: (e, n) => Wt("performActions", {
1652
- actions: [{ type: n ? "buttonDown" : "buttonUp", button: e }]
1653
- }),
1654
- touch: (e, n, i, o) => {
1655
- N.current?.sendDisplayTouch(e, n, i, o);
1656
- },
1657
- onKeyDown: Ge,
1658
- onKeyUp: Ge
1659
- }
1660
- ) }),
1661
- K && Vt && /* @__PURE__ */ w("div", { role: "alert", className: "rc-duo-error", children: Vt }),
1662
- !K && ke && /* @__PURE__ */ w(
1663
- Un,
1664
- {
1665
- snapshot: no,
1666
- geometry: Xo,
1667
- highlightedId: Pt,
1668
- selectedId: Ht,
1669
- mode: Uo,
1670
- cursorPosition: $o,
1671
- frozenCursorPosition: Bo,
1672
- onSelectChange: (e, n) => {
1673
- ht(e?.id ?? null), e && n ? Ue(n) : e || Ue(null);
1674
- const i = Ne.current;
1675
- e && i ? Qe("onInspectSelectionChange", Ke.current, {
1676
- element: e,
1677
- snapshot: i
1678
- }) : Qe("onInspectSelectionChange", Ke.current, null);
1679
- },
1680
- onTapElement: q ? void 0 : ((e, n) => {
1681
- if (n) {
1682
- po(n.x, n.y);
1683
- return;
1684
- }
1685
- const i = Ne.current;
1686
- i && Fo(e, i);
1687
- })
1688
- }
1689
- ),
1690
- xo ? /* @__PURE__ */ ee("div", { className: "rc-terminated", role: "status", children: [
1691
- /* @__PURE__ */ w("div", { className: "rc-terminated-title", children: "Instance terminated" }),
1692
- /* @__PURE__ */ w("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
1693
- ] }) : Io && /* @__PURE__ */ w("button", { type: "button", className: "rc-retry-button", onClick: tn, children: "Retry" })
1694
- ]
1695
- }
1696
- );
1697
- }
1698
- );
1699
- export {
1700
- Hn as D,
1701
- ii as M,
1702
- ui as R,
1703
- oi as a,
1704
- ni as b,
1705
- ri as c,
1706
- si as d,
1707
- li as e,
1708
- ci as l,
1709
- ai as m,
1710
- di as s,
1711
- Pn as u
1712
- };