@limrun/ui 0.20.4 → 0.20.5

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