@limrun/ui 0.20.8 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GLTFLoader-CDlCzcwQ.js → GLTFLoader-C25N9Y4j.js} +1 -1
- package/dist/{GLTFLoader-k2LXj_Q8.mjs → GLTFLoader-D4AITfgZ.mjs} +1 -1
- package/dist/core/constants.d.ts +8 -0
- package/dist/core/mac-keys.d.ts +1 -0
- package/dist/core/stream-options.d.ts +2 -2
- package/dist/core/stream-utils.d.ts +1 -1
- package/dist/core/webrtc-messages.d.ts +3 -0
- package/dist/core-BCBQrYsk.js +2 -0
- package/dist/core-CRIachT9.mjs +2327 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +7 -7
- package/dist/{duo-frame-gXvPDImv.js → duo-frame-B1NXSk6a.js} +2 -2
- package/dist/{duo-frame-Sz0TWot-.mjs → duo-frame-D1JK_cRk.mjs} +3 -3
- package/dist/{duo-view-DWqQXwdZ.mjs → duo-view-BeqYIqfQ.mjs} +39 -39
- package/dist/{duo-view-BMPB0h3C.js → duo-view-PsR5b045.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +2 -2
- package/dist/remote-control-DNr0Pyrx.js +1 -0
- package/dist/remote-control-rdm3mDtI.mjs +1299 -0
- package/package.json +1 -1
- package/dist/core-Bdivxz74.js +0 -2
- package/dist/core-BpV73M0K.mjs +0 -2162
- package/dist/remote-control-BB9Zl64_.mjs +0 -1222
- package/dist/remote-control-Dg5lOsj_.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as wr, jsx as Jn } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as en, useState as cs, useEffect as Ea } from "react";
|
|
3
|
-
import { D as Tu,
|
|
4
|
-
import { h as Ru, u as Pu, D as Iu, a as Du, f as Lu } from "./duo-view-
|
|
3
|
+
import { D as Tu, E as Au, F as Cr, G as wu, I as Cu } from "./core-CRIachT9.mjs";
|
|
4
|
+
import { h as Ru, u as Pu, D as Iu, a as Du, f as Lu } from "./duo-view-BeqYIqfQ.mjs";
|
|
5
5
|
const To = "183", Nu = 0, ec = 1, Uu = 2, ls = 1, Fu = 2, ir = 3, Xn = 0, Oe = 1, hn = 2, Pn = 0, Li = 1, nc = 2, ic = 3, rc = 4, Ou = 5, ri = 100, Bu = 101, zu = 102, Vu = 103, ku = 104, Gu = 200, Hu = 201, Wu = 202, Xu = 203, Ta = 204, Aa = 205, qu = 206, Yu = 207, Zu = 208, Ju = 209, $u = 210, Ku = 211, ju = 212, Qu = 213, th = 214, wa = 0, Ca = 1, Ra = 2, Ui = 3, Pa = 4, Ia = 5, Da = 6, La = 7, Pl = 0, eh = 1, nh = 2, dn = 0, Il = 1, Dl = 2, Ll = 3, Ao = 4, Nl = 5, Ul = 6, Fl = 7, sc = "attached", ih = "detached", Ol = 300, li = 301, Fi = 302, us = 303, Us = 304, As = 306, Na = 1e3, An = 1001, Ua = 1002, Ce = 1003, rh = 1004, Rr = 1005, ve = 1006, Fs = 1007, oi = 1008, He = 1009, Bl = 1010, zl = 1011, fr = 1012, wo = 1013, mn = 1014, We = 1015, Dn = 1016, Co = 1017, Ro = 1018, dr = 1020, Vl = 35902, kl = 35899, Gl = 1021, Hl = 1022, Xe = 1023, Ln = 1026, ci = 1027, Po = 1028, Io = 1029, Oi = 1030, Do = 1031, Lo = 1033, hs = 33776, fs = 33777, ds = 33778, ps = 33779, Fa = 35840, Oa = 35841, Ba = 35842, za = 35843, Va = 36196, ka = 37492, Ga = 37496, Ha = 37488, Wa = 37489, Xa = 37490, qa = 37491, Ya = 37808, Za = 37809, Ja = 37810, $a = 37811, Ka = 37812, ja = 37813, Qa = 37814, to = 37815, eo = 37816, no = 37817, io = 37818, ro = 37819, so = 37820, ao = 37821, oo = 36492, co = 36494, lo = 36495, uo = 36283, ho = 36284, fo = 36285, po = 36286, gs = 2300, mo = 2301, Os = 2302, ac = 2303, oc = 2400, cc = 2401, lc = 2402, sh = 2500, ah = 0, oh = 1, uc = 2, ch = 3200, Wl = 0, lh = 1, Hn = "", Fe = "srgb", Bi = "srgb-linear", _s = "linear", re = "srgb", mi = 7680, hc = 519, uh = 512, hh = 513, fh = 514, No = 515, dh = 516, ph = 517, Uo = 518, mh = 519, go = 35044, fc = 35048, dc = "300 es", fn = 2e3, pr = 2001;
|
|
6
6
|
function gh(i) {
|
|
7
7
|
for (let t = i.length - 1; t >= 0; --t)
|
|
@@ -26256,7 +26256,7 @@ function T0(i, t, e) {
|
|
|
26256
26256
|
},
|
|
26257
26257
|
// Imported appearances replace the rigid body while live screens and the hinge remain under our control.
|
|
26258
26258
|
loadAppearance: async (mt) => {
|
|
26259
|
-
const { GLTFLoader: st } = await import("./GLTFLoader-
|
|
26259
|
+
const { GLTFLoader: st } = await import("./GLTFLoader-D4AITfgZ.mjs"), { scene: F } = await new st().loadAsync(mt), $ = /* @__PURE__ */ new Set();
|
|
26260
26260
|
if (F.traverse((J) => {
|
|
26261
26261
|
if (J instanceof Ee) {
|
|
26262
26262
|
$.add(J.geometry);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o, jsxs as x, Fragment as z } from "react/jsx-runtime";
|
|
2
2
|
import ot, { useId as J, useState as W, useRef as M, useEffect as T, useCallback as at, useLayoutEffect as it, Suspense as st, lazy as ct } from "react";
|
|
3
|
-
import { H as dt, D as A,
|
|
3
|
+
import { H as dt, D as A, z as ut, B as lt, C as ht, E as ft, F as j } from "./core-CRIachT9.mjs";
|
|
4
4
|
function mt(t, n, r) {
|
|
5
5
|
const [s, i] = W(t), a = M({ nativeAngle: t, send: n, failed: r });
|
|
6
6
|
a.current = { nativeAngle: t, send: n, failed: r };
|
|
@@ -238,7 +238,7 @@ function yt(t, n, r, s) {
|
|
|
238
238
|
y = (y - i / 2) * l, f = (f - a / 2) * l;
|
|
239
239
|
const P = d === 1 ? { x: -f, y } : d === 2 ? { x: -y, y: -f } : d === 3 ? { x: f, y: -y } : { x: y, y: f };
|
|
240
240
|
return { x: P.x + r / 2, y: P.y + s / 2 };
|
|
241
|
-
}, H = (d % 2 ? a : i) * l, D = (d % 2 ? i : a) * l,
|
|
241
|
+
}, H = (d % 2 ? a : i) * l, D = (d % 2 ? i : a) * l, F = {
|
|
242
242
|
min: { x: (r - H) / 2, y: (s - D) / 2 },
|
|
243
243
|
max: { x: (r + H) / 2, y: (s + D) / 2 }
|
|
244
244
|
}, g = [
|
|
@@ -247,13 +247,13 @@ function yt(t, n, r, s) {
|
|
|
247
247
|
{ button: "side", x: i + 0.35, y: a / 2 - 21, width: 0.7, height: 13, edge: "right" }
|
|
248
248
|
], b = ["top", "right", "bottom", "left"], v = g.map((y) => {
|
|
249
249
|
const f = b[(b.indexOf(y.edge) + d) % 4], P = h(y.x, y.y);
|
|
250
|
-
return f === "top" && (P.y =
|
|
250
|
+
return f === "top" && (P.y = F.min.y - 28), f === "bottom" && (P.y = F.max.y + 28), f === "left" && (P.x = F.min.x - 28), f === "right" && (P.x = F.max.x + 28), { button: y.button, edge: f, ...P, targetX: P.x, targetY: P.y };
|
|
251
251
|
}), w = v.filter((y) => y.button !== "side"), p = d % 2 ? "y" : "x";
|
|
252
252
|
w.sort((y, f) => y[p] - f[p]);
|
|
253
|
-
const
|
|
253
|
+
const N = d % 2 ? "targetY" : "targetX";
|
|
254
254
|
if (w[1][p] - w[0][p] < 44) {
|
|
255
255
|
const y = (w[0][p] + w[1][p]) / 2;
|
|
256
|
-
w[0][
|
|
256
|
+
w[0][N] = y - 22, w[1][N] = y + 22;
|
|
257
257
|
}
|
|
258
258
|
return {
|
|
259
259
|
bodyWidth: i,
|
|
@@ -264,8 +264,8 @@ function yt(t, n, r, s) {
|
|
|
264
264
|
turns: d,
|
|
265
265
|
buttons: g,
|
|
266
266
|
guides: v,
|
|
267
|
-
rect:
|
|
268
|
-
iconSize: Math.min(bt(
|
|
267
|
+
rect: F,
|
|
268
|
+
iconSize: Math.min(bt(F), 12 * l)
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
function bt(t) {
|
|
@@ -313,7 +313,7 @@ function xt(t, n, r, s, i = !0) {
|
|
|
313
313
|
m.current = { inner: n, frame: r };
|
|
314
314
|
const [d, l] = W(), h = M(void 0), H = M(void 0), D = at(() => {
|
|
315
315
|
clearTimeout(H.current), h.current = void 0, l(void 0);
|
|
316
|
-
}, []),
|
|
316
|
+
}, []), F = (g) => {
|
|
317
317
|
if (!i || g === n) {
|
|
318
318
|
D();
|
|
319
319
|
return;
|
|
@@ -335,8 +335,8 @@ function xt(t, n, r, s, i = !0) {
|
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
if (g.inner === n || (l(void 0), !g.frame.scale || !r.scale) || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
338
|
-
const p = h.current?.before ?? _(t.current),
|
|
339
|
-
clearTimeout(H.current), h.current = void 0, p && l({ from:
|
|
338
|
+
const p = h.current?.before ?? _(t.current), N = h.current?.from ?? g;
|
|
339
|
+
clearTimeout(H.current), h.current = void 0, p && l({ from: N, to: b, before: p, ready: !1 });
|
|
340
340
|
}, [n, r.scale, r.turns, r.rect.min.x, r.rect.min.y, s, i]), T(() => {
|
|
341
341
|
if (!d || d.from.inner === n) return;
|
|
342
342
|
const g = wt(t.current, (w) => {
|
|
@@ -347,7 +347,7 @@ function xt(t, n, r, s, i = !0) {
|
|
|
347
347
|
return b?.addEventListener("change", v), () => {
|
|
348
348
|
g(), b?.removeEventListener("change", v);
|
|
349
349
|
};
|
|
350
|
-
}, [d?.from, n]), { motion: d, finish: D, prepare:
|
|
350
|
+
}, [d?.from, n]), { motion: d, finish: D, prepare: F };
|
|
351
351
|
}
|
|
352
352
|
function Mt({ pose: t, image: n, scale: r }) {
|
|
353
353
|
const { bodyWidth: s, bodyHeight: i, screenWidth: a, screenHeight: u } = t.frame, m = a * r, d = u * r;
|
|
@@ -418,7 +418,7 @@ function Ct({ motion: t, onFinish: n }) {
|
|
|
418
418
|
)
|
|
419
419
|
] });
|
|
420
420
|
}
|
|
421
|
-
const kt = ct(() => import("./duo-frame-
|
|
421
|
+
const kt = ct(() => import("./duo-frame-D1JK_cRk.mjs").then((t) => t.ac));
|
|
422
422
|
function Dt(t) {
|
|
423
423
|
const [n, r] = W("2d");
|
|
424
424
|
return /* @__PURE__ */ x("div", { className: "rc-duo-view", children: [
|
|
@@ -432,15 +432,15 @@ function Dt(t) {
|
|
|
432
432
|
function Z(t) {
|
|
433
433
|
const n = t.showFrame !== !1, r = M(null), s = M(null), i = M(t);
|
|
434
434
|
i.current = t;
|
|
435
|
-
const [a, u] = W({ width: 0, height: 0 }), [m, d] = W(), [l, h] = W(), [H, D] = W(), [
|
|
435
|
+
const [a, u] = W({ width: 0, height: 0 }), [m, d] = W(), [l, h] = W(), [H, D] = W(), [F, g] = W(), b = M(void 0), v = M(null);
|
|
436
436
|
v.current || (v.current = new ut((...e) => i.current.touch(...e)));
|
|
437
|
-
const w = M(null), p = lt(t.state),
|
|
437
|
+
const w = M(null), p = lt(t.state), N = p?.id === "inner" ? t.inner : t.outer, y = ht(p?.orientation), f = p?.id === "inner", P = { portrait: 0, pud: 2, "landscape-left": 3, "landscape-right": 1 }[t.state.orientation], R = n ? (P + (f ? 1 : 0)) % 4 : y, C = yt(f, R, a.width, a.height), U = n ? C.screenWidth : (f ? p?.height : p?.width) ?? 1, B = n ? C.screenHeight : (f ? p?.width : p?.height) ?? 1, S = n ? C.bodyWidth : U, O = n ? C.bodyHeight : B, k = n ? C.scale : Math.max(
|
|
438
438
|
0,
|
|
439
439
|
Math.min(
|
|
440
|
-
a.width / (C.turns % 2 ? O :
|
|
441
|
-
a.height / (C.turns % 2 ?
|
|
440
|
+
a.width / (C.turns % 2 ? O : S),
|
|
441
|
+
a.height / (C.turns % 2 ? S : O)
|
|
442
442
|
)
|
|
443
|
-
),
|
|
443
|
+
), V = U * k, K = B * k;
|
|
444
444
|
T(() => {
|
|
445
445
|
const e = new ResizeObserver(([c]) => {
|
|
446
446
|
c && u({ width: c.contentRect.width, height: c.contentRect.height });
|
|
@@ -448,19 +448,19 @@ function Z(t) {
|
|
|
448
448
|
return r.current && e.observe(r.current), () => e.disconnect();
|
|
449
449
|
}, []), T(() => {
|
|
450
450
|
const e = s.current;
|
|
451
|
-
if (!e || !
|
|
451
|
+
if (!e || !N) return;
|
|
452
452
|
const c = () => {
|
|
453
|
-
e.srcObject !==
|
|
453
|
+
e.srcObject !== N.srcObject && (e.srcObject = N.srcObject), e.play().catch(() => {
|
|
454
454
|
}), t.outer?.pause(), t.inner?.pause();
|
|
455
455
|
};
|
|
456
|
-
return c(),
|
|
457
|
-
|
|
456
|
+
return c(), N.addEventListener("loadedmetadata", c), () => {
|
|
457
|
+
N.removeEventListener("loadedmetadata", c), e.pause(), e.srcObject = null;
|
|
458
458
|
for (const X of [t.outer, t.inner]) X?.play().catch(() => {
|
|
459
459
|
});
|
|
460
460
|
};
|
|
461
|
-
}, [
|
|
461
|
+
}, [N, t.outer, t.inner]);
|
|
462
462
|
const {
|
|
463
|
-
motion:
|
|
463
|
+
motion: E,
|
|
464
464
|
finish: $,
|
|
465
465
|
prepare: tt
|
|
466
466
|
} = xt(s, f, C, t.state.orientation, n), { angle: et, changeAngle: rt, interacting: nt } = mt(
|
|
@@ -496,7 +496,7 @@ function Z(t) {
|
|
|
496
496
|
}, q = (e) => ({
|
|
497
497
|
disabled: t.watchOnly,
|
|
498
498
|
onPointerDown: (c) => {
|
|
499
|
-
t.watchOnly ||
|
|
499
|
+
t.watchOnly || E || c.button !== 0 || (c.currentTarget.setPointerCapture(c.pointerId), w.current?.press(e), g(e));
|
|
500
500
|
},
|
|
501
501
|
onPointerUp: L,
|
|
502
502
|
onPointerCancel: L,
|
|
@@ -506,7 +506,7 @@ function Z(t) {
|
|
|
506
506
|
onPointerLeave: () => D(void 0),
|
|
507
507
|
onFocus: () => h(C.guides.find((c) => c.button === e)?.edge),
|
|
508
508
|
onKeyDown: (c) => {
|
|
509
|
-
|
|
509
|
+
E || (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.repeat || (w.current?.press(e), g(e)));
|
|
510
510
|
},
|
|
511
511
|
onKeyUp: (c) => {
|
|
512
512
|
(c.key === "Enter" || c.key === " ") && (c.preventDefault(), L());
|
|
@@ -521,8 +521,8 @@ function Z(t) {
|
|
|
521
521
|
{
|
|
522
522
|
ref: r,
|
|
523
523
|
className: "rc-duo-flat-stage",
|
|
524
|
-
"data-folding": !!
|
|
525
|
-
"aria-busy": !!
|
|
524
|
+
"data-folding": !!E,
|
|
525
|
+
"aria-busy": !!E,
|
|
526
526
|
onPointerMove: (e) => {
|
|
527
527
|
if (!n) return;
|
|
528
528
|
const c = e.currentTarget.getBoundingClientRect();
|
|
@@ -538,12 +538,12 @@ function Z(t) {
|
|
|
538
538
|
className: "rc-duo-flat-device",
|
|
539
539
|
"data-display": f ? "inner" : "outer",
|
|
540
540
|
style: {
|
|
541
|
-
width:
|
|
541
|
+
width: S * k,
|
|
542
542
|
height: O * k,
|
|
543
543
|
transform: "translate(-50%, -50%) rotate(" + C.turns * 90 + "deg)"
|
|
544
544
|
},
|
|
545
545
|
children: [
|
|
546
|
-
n && /* @__PURE__ */ o(Q, { inner: f, width:
|
|
546
|
+
n && /* @__PURE__ */ o(Q, { inner: f, width: S, height: O }),
|
|
547
547
|
/* @__PURE__ */ o(
|
|
548
548
|
"div",
|
|
549
549
|
{
|
|
@@ -552,16 +552,16 @@ function Z(t) {
|
|
|
552
552
|
"aria-label": "iPhone Duo 2D simulator",
|
|
553
553
|
tabIndex: 0,
|
|
554
554
|
style: {
|
|
555
|
-
width:
|
|
555
|
+
width: V,
|
|
556
556
|
height: K,
|
|
557
|
-
left: (
|
|
558
|
-
top: (O -
|
|
557
|
+
left: (S - U) / 2 * k,
|
|
558
|
+
top: (O - B) / 2 * k,
|
|
559
559
|
borderRadius: n ? f ? 5.3 * k : [0.8, 6.6, 6.6, 0.8].map((e) => e * k + "px").join(" ") : 0
|
|
560
560
|
},
|
|
561
|
-
onKeyDown:
|
|
561
|
+
onKeyDown: E ? void 0 : t.onKeyDown,
|
|
562
562
|
onKeyUp: t.onKeyUp,
|
|
563
563
|
onPointerDown: (e) => {
|
|
564
|
-
if (t.watchOnly ||
|
|
564
|
+
if (t.watchOnly || E || b.current !== void 0 || e.button !== 0 || !p)
|
|
565
565
|
return;
|
|
566
566
|
e.currentTarget.focus({ preventScroll: !0 }), e.currentTarget.setPointerCapture(e.pointerId);
|
|
567
567
|
const c = G(e);
|
|
@@ -585,8 +585,8 @@ function Z(t) {
|
|
|
585
585
|
muted: !0,
|
|
586
586
|
playsInline: !0,
|
|
587
587
|
style: {
|
|
588
|
-
width: f ? K :
|
|
589
|
-
height: f ?
|
|
588
|
+
width: f ? K : V,
|
|
589
|
+
height: f ? V : K,
|
|
590
590
|
transform: "translate(-50%, -50%) rotate(" + (f ? 90 : 0) + "deg)"
|
|
591
591
|
}
|
|
592
592
|
}
|
|
@@ -601,7 +601,7 @@ function Z(t) {
|
|
|
601
601
|
"data-duo-button": e.button,
|
|
602
602
|
"data-edge": e.edge,
|
|
603
603
|
"data-highlighted": H === e.button,
|
|
604
|
-
"data-pressed":
|
|
604
|
+
"data-pressed": F === e.button,
|
|
605
605
|
"aria-label": j[e.button] + " physical button",
|
|
606
606
|
title: j[e.button],
|
|
607
607
|
style: {
|
|
@@ -630,7 +630,7 @@ function Z(t) {
|
|
|
630
630
|
className: "rc-duo-hardware",
|
|
631
631
|
"data-duo-button": e.button,
|
|
632
632
|
"data-visible": l === e.edge,
|
|
633
|
-
"data-pressed":
|
|
633
|
+
"data-pressed": F === e.button,
|
|
634
634
|
"aria-label": j[e.button],
|
|
635
635
|
title: j[e.button],
|
|
636
636
|
style: {
|
|
@@ -645,7 +645,7 @@ function Z(t) {
|
|
|
645
645
|
},
|
|
646
646
|
e.button
|
|
647
647
|
)),
|
|
648
|
-
|
|
648
|
+
E && /* @__PURE__ */ o(Ct, { motion: E, onFinish: $ })
|
|
649
649
|
]
|
|
650
650
|
}
|
|
651
651
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),u=require("react"),E=require("./core-Bdivxz74.js");function Y(e,o,n){const[i,a]=u.useState(e),s=u.useRef({nativeAngle:e,send:o,failed:n});s.current={nativeAngle:e,send:o,failed:n};const l=u.useRef(void 0),x=u.useRef(!1),d=u.useRef(null);return u.useEffect(()=>(d.current=new E.HingeSender(async h=>{await s.current.send(h),l.current===h&&(l.current=void 0)},h=>{l.current=void 0,s.current.failed(String(h)),a(s.current.nativeAngle)}),()=>d.current?.stop()),[]),u.useEffect(()=>{!x.current&&l.current===void 0&&a(e)},[e]),{angle:i,changeAngle:h=>{s.current.failed(void 0),l.current=h,a(h),d.current?.set(h)},interacting:x}}function $({angle:e,watchOnly:o=!1,changeAngle:n,interacting:i,rotate:a,onFold:s,foldTarget:l,onHingeDrag:x,children:d}){const f=u.useId();return r.jsxs("div",{className:"rc-duo-controls",onPointerDown:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"rc-duo-hinge",children:[r.jsx("button",{disabled:o,className:"rc-duo-fold",onClick:s??(()=>n(e<90?180:0)),children:(l??e)<90?"Unfold":"Fold"}),r.jsx("label",{htmlFor:f,children:"Hinge"}),r.jsx("input",{id:f,type:"range",disabled:o,min:0,max:180,step:1,value:e,onPointerDown:h=>{x?.(),i.current=!0,h.currentTarget.setPointerCapture(h.pointerId)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},onLostPointerCapture:()=>{i.current=!1},onChange:h=>n(Number(h.target.value))}),r.jsxs("output",{children:[Math.round(e),"°"]}),r.jsx("button",{disabled:o,className:"rc-duo-rotate","aria-label":"Rotate device",title:"Rotate device",onClick:a,children:r.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[r.jsx("rect",{x:"7",y:"3",width:"10",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9a9 9 0 0 1 3-5M3 4v5h5M21 15a9 9 0 0 1-3 5m3 0v-5h-5"})]})})]}),d&&r.jsx("div",{className:"rc-duo-views","aria-label":"Device view",children:d})]})}function G({button:e}){return r.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="side"?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"6",y:"10",width:"12",height:"11",rx:"2"}),r.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]}):r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 9h4l5-5v16l-5-5H3zM17 12h5"}),e==="volumeUp"&&r.jsx("path",{d:"M19.5 9.5v5"})]})})}function B(e,o,n,i,a,s){return"M"+(e+a)+","+o+"H"+(e+n-s)+"a"+s+","+s+" 0 0 1 "+s+","+s+"V"+(o+i-s)+"a"+s+","+s+" 0 0 1 "+-s+","+s+"H"+(e+a)+"a"+a+","+a+" 0 0 1 "+-a+","+-a+"V"+(o+a)+"a"+a+","+a+" 0 0 1 "+a+","+-a+"Z"}function A({inner:e,width:o,height:n}){const i=u.useId().replace(/:/g,""),a=e?8.4:1.25,s=8.4;return r.jsxs("svg",{className:"rc-duo-flat-frame",viewBox:"0 0 "+o+" "+n,"aria-hidden":"true",children:[r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:i+"-silver",x1:"0",y1:"0",x2:"1",y2:"1",children:[r.jsx("stop",{offset:"0",stopColor:"#62676b"}),r.jsx("stop",{offset:"0.035",stopColor:"#f9faf9"}),r.jsx("stop",{offset:"0.11",stopColor:"#b0b4b6"}),r.jsx("stop",{offset:"0.31",stopColor:"#fdfefd"}),r.jsx("stop",{offset:"0.43",stopColor:"#797f84"}),r.jsx("stop",{offset:"0.51",stopColor:"#e8eaea"}),r.jsx("stop",{offset:"0.7",stopColor:"#979da1"}),r.jsx("stop",{offset:"0.87",stopColor:"#fafbf9"}),r.jsx("stop",{offset:"1",stopColor:"#5f676c"})]}),r.jsxs("linearGradient",{id:i+"-spine",children:[r.jsx("stop",{stopColor:"#4a5154"}),r.jsx("stop",{offset:"0.16",stopColor:"#d6d9d9"}),r.jsx("stop",{offset:"0.4",stopColor:"#f8f9f7"}),r.jsx("stop",{offset:"0.62",stopColor:"#a2a8ab"}),r.jsx("stop",{offset:"0.83",stopColor:"#e4e7e5"}),r.jsx("stop",{offset:"1",stopColor:"#666e72"})]})]}),!e&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"-2.3",y:"0.7",width:"3.3",height:n-1.4,rx:"0.85",fill:"url(#"+i+"-spine)",stroke:"#8b9296",strokeWidth:"0.15"}),r.jsx("path",{d:"M-.6 2V"+(n-2),stroke:"#f5f6f4",strokeWidth:"0.22"})]}),r.jsx("path",{d:B(0,0,o,n,a,s),fill:"url(#"+i+"-silver)",stroke:"#696f72",strokeWidth:"0.24"}),r.jsx("path",{d:B(.48,.48,o-.96,n-.96,Math.max(.5,a-.48),s-.48),fill:"none",stroke:"#ffffff",strokeOpacity:"0.85",strokeWidth:"0.2"}),r.jsx("path",{d:B(1.12,1.12,o-2.24,n-2.24,e?7.15:.65,7.15),fill:"#090b0d",stroke:"#34393c",strokeWidth:"0.2"}),[o-16,e?19:16].map(l=>r.jsx(u.Fragment,{children:r.jsx("path",{d:"M"+l+",0.17v0.82M"+l+","+(n-1)+"v0.82",stroke:"#b1b2ac",strokeWidth:"1.1"})},l)),e&&[0,n-.6].map(l=>r.jsx("rect",{x:o/2-2.2,y:l,width:"4.4",height:"0.6",rx:"0.18",fill:"url(#"+i+"-spine)",stroke:"#697074",strokeWidth:"0.14"},l)),r.jsx("path",{d:"M"+(o-.1)+",20h-.9m.9,"+(n-40)+"h-.9",stroke:"#b1b2ac",strokeWidth:"1.05"})]})}function ne(e,o,n,i){const a=E.DUO_DIMENSIONS.width/(e?1:2),s=E.DUO_DIMENSIONS.height,l=e?157.5:77.1,x=e?110.8:112.2,d=(o+(e?3:0))%4,f=Math.max(0,Math.min((n-120)/(d%2?s:a),(i-120)/(d%2?a:s))),h=(y,m)=>{y=(y-a/2)*f,m=(m-s/2)*f;const C=d===1?{x:-m,y}:d===2?{x:-y,y:-m}:d===3?{x:m,y:-y}:{x:y,y:m};return{x:C.x+n/2,y:C.y+i/2}},N=(d%2?s:a)*f,D=(d%2?a:s)*f,k={min:{x:(n-N)/2,y:(i-D)/2},max:{x:(n+N)/2,y:(i+D)/2}},g=[{button:"volumeDown",x:a-37,y:-.32,width:9.5,height:.65,edge:"top"},{button:"volumeUp",x:a-25,y:-.32,width:9.5,height:.65,edge:"top"},{button:"side",x:a+.35,y:s/2-21,width:.7,height:13,edge:"right"}],b=["top","right","bottom","left"],j=g.map(y=>{const m=b[(b.indexOf(y.edge)+d)%4],C=h(y.x,y.y);return m==="top"&&(C.y=k.min.y-28),m==="bottom"&&(C.y=k.max.y+28),m==="left"&&(C.x=k.min.x-28),m==="right"&&(C.x=k.max.x+28),{button:y.button,edge:m,...C,targetX:C.x,targetY:C.y}}),v=j.filter(y=>y.button!=="side"),p=d%2?"y":"x";v.sort((y,m)=>y[p]-m[p]);const S=d%2?"targetY":"targetX";if(v[1][p]-v[0][p]<44){const y=(v[0][p]+v[1][p])/2;v[0][S]=y-22,v[1][S]=y+22}return{bodyWidth:a,bodyHeight:s,screenWidth:l,screenHeight:x,scale:f,turns:d,buttons:g,guides:j,rect:k,iconSize:Math.min(Z(k),12*f)}}function Z(e){return Math.max(12,Math.min(24,Math.max(e.max.x-e.min.x,e.max.y-e.min.y)/24))}function J(e,o,n){return[["top",n.min.y-o,e,n.min.x,n.max.x],["bottom",o-n.max.y,e,n.min.x,n.max.x],["left",n.min.x-e,o,n.min.y,n.max.y],["right",e-n.max.x,o,n.min.y,n.max.y]].filter(([,a,s,l,x])=>a>=-7&&a<=52&&s>=l-12&&s<=x+12).sort((a,s)=>Math.abs(a[1])-Math.abs(s[1]))[0]?.[0]}function V(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return;const o=Math.min(1,1024/Math.max(e.videoWidth,e.videoHeight)),n=document.createElement("canvas");try{const i=n.getContext("2d");return i?(n.width=Math.round(e.videoWidth*o),n.height=Math.round(e.videoHeight*o),i.drawImage(e,0,0,n.width,n.height),n):void 0}catch{return}}function oe(e,o){let n=!1,i;const a=f=>{n||(d(),o(f))},s=()=>{if(n)return;const f=V(e);f&&a(f)},l=()=>{i=void 0,s(),n||(i=e?.requestVideoFrameCallback?.(l))},x=setTimeout(()=>a(void 0),2500);i=e?.requestVideoFrameCallback?.(l),e?.addEventListener("loadeddata",s),!e?.requestVideoFrameCallback&&e&&e.readyState>=2&&s();function d(){n=!0,clearTimeout(x),i!==void 0&&e?.cancelVideoFrameCallback(i),e?.removeEventListener("loadeddata",s)}return d}function se(e,o,n,i,a=!0){const s=u.useRef(void 0),l=u.useRef(i),x=u.useRef({inner:o,frame:n});x.current={inner:o,frame:n};const[d,f]=u.useState(),h=u.useRef(void 0),N=u.useRef(void 0),D=u.useCallback(()=>{clearTimeout(N.current),h.current=void 0,f(void 0)},[]),k=g=>{if(!a||g===o){D();return}if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||h.current)return;const b=V(e.current);if(!b)return;const j=x.current;h.current={from:j,to:j,before:b,ready:!1},f(h.current),N.current=setTimeout(D,5e3)};return u.useEffect(()=>()=>clearTimeout(N.current),[]),u.useLayoutEffect(()=>{const g=s.current,b={inner:o,frame:n};s.current=b;const j=l.current!==i;if(l.current=i,!g)return;const v=Math.abs(g.frame.rect.min.x+g.frame.rect.max.x-n.rect.min.x-n.rect.max.x)>.5||Math.abs(g.frame.rect.min.y+g.frame.rect.max.y-n.rect.min.y-n.rect.max.y)>.5;if(!a||v||j){D();return}if(g.inner===o||(f(void 0),!g.frame.scale||!n.scale)||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const p=h.current?.before??V(e.current),S=h.current?.from??g;clearTimeout(N.current),h.current=void 0,p&&f({from:S,to:b,before:p,ready:!1})},[o,n.scale,n.turns,n.rect.min.x,n.rect.min.y,i,a]),u.useEffect(()=>{if(!d||d.from.inner===o)return;const g=oe(e.current,v=>{v?f(p=>p&&{...p,to:x.current,after:v,ready:!0}):D()}),b=window.matchMedia?.("(prefers-reduced-motion: reduce)"),j=()=>{b?.matches&&f(void 0)};return b?.addEventListener("change",j),()=>{g(),b?.removeEventListener("change",j)}},[d?.from,o]),{motion:d,finish:D,prepare:k}}function ae({pose:e,image:o,scale:n}){const{bodyWidth:i,bodyHeight:a,screenWidth:s,screenHeight:l}=e.frame,x=s*n,d=l*n;return r.jsxs("div",{className:"rc-duo-fold-still",style:{width:i*n,height:a*n},children:[r.jsx(A,{inner:e.inner,width:i,height:a}),r.jsx("div",{className:"rc-duo-flat-screen",style:{width:x,height:d,left:(i-s)*n/2,top:(a-l)*n/2,borderRadius:e.inner?5.3*n:[.8,6.6,6.6,.8].map(f=>f*n+"px").join(" ")},children:o&&r.jsx("canvas",{ref:f=>{f&&(f.width=o.width,f.height=o.height,f.getContext("2d")?.drawImage(o,0,0))},style:{width:e.inner?d:x,height:e.inner?x:d,transform:`translate(-50%, -50%) rotate(${e.inner?90:0}deg)`}})})]})}function ie({motion:e,onFinish:o}){const n=u.useRef(null),[i,a]=u.useState(!1);return u.useEffect(()=>{if(a(!1),!e.ready)return;let s=!1,l;return Promise.resolve().then(()=>require("./duo-fold-renderer-DdltAnF7.js")).then(({renderFold:x})=>{s||!n.current||(l=x(n.current,e,o),a(!0))}).catch(()=>{s||o()}),()=>{s=!0,l?.()}},[e.ready,e.from,o]),r.jsxs(r.Fragment,{children:[!i&&r.jsx("div",{className:"rc-duo-fold-hold","aria-hidden":"true",style:{width:e.from.frame.bodyWidth*e.from.frame.scale,height:e.from.frame.bodyHeight*e.from.frame.scale,transform:`translate(-50%, -50%) rotate(${e.from.frame.turns*90}deg)`},children:r.jsx(ae,{pose:e.from,image:e.before,scale:e.from.frame.scale})}),r.jsx("canvas",{ref:n,className:"rc-duo-fold-canvas","aria-hidden":"true",style:{visibility:i?"visible":"hidden"}})]})}const ce=u.lazy(()=>Promise.resolve().then(()=>require("./duo-frame-gXvPDImv.js")).then(e=>e.duoFrame));function ue(e){const[o,n]=u.useState("2d");return r.jsxs("div",{className:"rc-duo-view",children:[e.showFrame!==!1&&o==="3d"?r.jsx(u.Suspense,{fallback:r.jsx(X,{...e}),children:r.jsx(ce,{...e})}):r.jsx(X,{...e}),e.showFrame!==!1&&r.jsxs("div",{className:"rc-duo-mode",role:"group","aria-label":"Device rendering",children:[r.jsx("button",{type:"button","aria-pressed":o==="2d",onClick:()=>n("2d"),children:"2D"}),r.jsx("button",{type:"button","aria-pressed":o==="3d",onClick:()=>n("3d"),children:"3D"})]})]})}function X(e){const o=e.showFrame!==!1,n=u.useRef(null),i=u.useRef(null),a=u.useRef(e);a.current=e;const[s,l]=u.useState({width:0,height:0}),[x,d]=u.useState(),[f,h]=u.useState(),[N,D]=u.useState(),[k,g]=u.useState(),b=u.useRef(void 0),j=u.useRef(null);j.current||(j.current=new E.DuoTouchController((...t)=>a.current.touch(...t)));const v=u.useRef(null),p=E.getDuoDisplay(e.state),S=p?.id==="inner"?e.inner:e.outer,y=E.duoDisplayTurns(p?.orientation),m=p?.id==="inner",C={portrait:0,pud:2,"landscape-left":3,"landscape-right":1}[e.state.orientation],H=o?(C+(m?1:0))%4:y,w=ne(m,H,s.width,s.height),W=o?w.screenWidth:(m?p?.height:p?.width)??1,I=o?w.screenHeight:(m?p?.width:p?.height)??1,R=o?w.bodyWidth:W,F=o?w.bodyHeight:I,M=o?w.scale:Math.max(0,Math.min(s.width/(w.turns%2?F:R),s.height/(w.turns%2?R:F))),U=W*M,L=I*M;u.useEffect(()=>{const t=new ResizeObserver(([c])=>{c&&l({width:c.contentRect.width,height:c.contentRect.height})});return n.current&&t.observe(n.current),()=>t.disconnect()},[]),u.useEffect(()=>{const t=i.current;if(!t||!S)return;const c=()=>{t.srcObject!==S.srcObject&&(t.srcObject=S.srcObject),t.play().catch(()=>{}),e.outer?.pause(),e.inner?.pause()};return c(),S.addEventListener("loadedmetadata",c),()=>{S.removeEventListener("loadedmetadata",c),t.pause(),t.srcObject=null;for(const z of[e.outer,e.inner])z?.play().catch(()=>{})}},[S,e.outer,e.inner]);const{motion:P,finish:_,prepare:Q}=se(i,m,w,e.state.orientation,o),{angle:ee,changeAngle:te,interacting:re}=Y(e.state.angleDegrees,async t=>{Q(t>=90);try{await e.setAngle(t)}catch(c){throw _(),c}},d),T=()=>{j.current?.release(),b.current=void 0};u.useEffect(()=>{v.current=new E.DuoButtonSender((c,z)=>a.current.button(c,z),c=>d(String(c)));const t=()=>{T(),v.current?.release(),g(void 0)};return window.addEventListener("blur",t),()=>{t(),window.removeEventListener("blur",t)}},[]),u.useEffect(()=>{j.current?.setDisplay(p,H),j.current?.active||(b.current=void 0)},[p,H]);const O=()=>{v.current?.release(),g(void 0)},q=t=>({disabled:e.watchOnly,onPointerDown:c=>{e.watchOnly||P||c.button!==0||(c.currentTarget.setPointerCapture(c.pointerId),v.current?.press(t),g(t))},onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onBlur:O,onPointerEnter:()=>D(t),onPointerLeave:()=>D(void 0),onFocus:()=>h(w.guides.find(c=>c.button===t)?.edge),onKeyDown:c=>{P||(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),c.repeat||(v.current?.press(t),g(t)))},onKeyUp:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),O())}}),K=t=>{const c=t.currentTarget.getBoundingClientRect();return{x:(t.clientX-c.left)/c.width,y:(t.clientY-c.top)/c.height}};return r.jsxs("div",{className:o?"rc-duo":"rc-duo rc-duo-frameless",children:[r.jsxs("div",{ref:n,className:"rc-duo-flat-stage","data-folding":!!P,"aria-busy":!!P,onPointerMove:t=>{if(!o)return;const c=t.currentTarget.getBoundingClientRect();h(J(t.clientX-c.left,t.clientY-c.top,w.rect))},onPointerLeave:()=>{h(void 0),D(void 0)},children:[r.jsxs("div",{className:"rc-duo-flat-device","data-display":m?"inner":"outer",style:{width:R*M,height:F*M,transform:"translate(-50%, -50%) rotate("+w.turns*90+"deg)"},children:[o&&r.jsx(A,{inner:m,width:R,height:F}),r.jsx("div",{className:"rc-duo-flat-screen",role:"application","aria-label":"iPhone Duo 2D simulator",tabIndex:0,style:{width:U,height:L,left:(R-W)/2*M,top:(F-I)/2*M,borderRadius:o?m?5.3*M:[.8,6.6,6.6,.8].map(t=>t*M+"px").join(" "):0},onKeyDown:P?void 0:e.onKeyDown,onKeyUp:e.onKeyUp,onPointerDown:t=>{if(e.watchOnly||P||b.current!==void 0||t.button!==0||!p)return;t.currentTarget.focus({preventScroll:!0}),t.currentTarget.setPointerCapture(t.pointerId);const c=K(t);b.current=t.pointerId,j.current?.touch("begin",c.x,c.y)},onPointerMove:t=>{if(b.current!==t.pointerId)return;const c=K(t);j.current?.touch("move",c.x,c.y)},onPointerUp:t=>{b.current===t.pointerId&&T()},onPointerCancel:T,onLostPointerCapture:T,children:r.jsx("video",{ref:i,autoPlay:!0,muted:!0,playsInline:!0,style:{width:m?L:U,height:m?U:L,transform:"translate(-50%, -50%) rotate("+(m?90:0)+"deg)"}})}),o&&w.buttons.map(t=>r.jsx("button",{type:"button",className:"rc-duo-physical","data-duo-button":t.button,"data-edge":t.edge,"data-highlighted":N===t.button,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button]+" physical button",title:E.DUO_BUTTONS[t.button],style:{left:t.x*M,top:t.y*M,width:t.edge==="top"?Math.max(28,t.width*M):28,height:t.edge==="top"?28:Math.max(28,t.height*M)},...q(t.button),children:r.jsx("span",{style:{width:Math.max(2,t.width*M),height:Math.max(2,t.height*M)}})},t.button))]}),o&&w.guides.map(t=>r.jsx("button",{type:"button",className:"rc-duo-hardware","data-duo-button":t.button,"data-visible":f===t.edge,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button],title:E.DUO_BUTTONS[t.button],style:{left:t.targetX,top:t.targetY,"--duo-hardware-icon-size":`${w.iconSize}px`,"--duo-hardware-icon-x":`${t.x-t.targetX}px`,"--duo-hardware-icon-y":`${t.y-t.targetY}px`},...q(t.button),children:r.jsx(G,{button:t.button})},t.button)),P&&r.jsx(ie,{motion:P,onFinish:_})]}),o&&r.jsx($,{watchOnly:e.watchOnly,angle:ee,changeAngle:te,interacting:re,rotate:()=>{e.setOrientation(e.state.orientation==="portrait"?"landscape-left":"portrait").catch(t=>d(String(t)))},children:r.jsx("span",{className:"rc-duo-view-label",children:"Front view"})}),x&&r.jsx("div",{role:"alert",className:"rc-duo-error",children:x})]})}const de=Object.freeze(Object.defineProperty({__proto__:null,default:ue},Symbol.toStringTag,{value:"Module"}));exports.DuoControls=$;exports.DuoHardwareIcon=G;exports.duoView=de;exports.flatHoverEdge=J;exports.hardwareIconSize=Z;exports.useDuoHinge=Y;
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),u=require("react"),E=require("./core-BCBQrYsk.js");function Y(e,o,n){const[i,a]=u.useState(e),s=u.useRef({nativeAngle:e,send:o,failed:n});s.current={nativeAngle:e,send:o,failed:n};const l=u.useRef(void 0),x=u.useRef(!1),d=u.useRef(null);return u.useEffect(()=>(d.current=new E.HingeSender(async h=>{await s.current.send(h),l.current===h&&(l.current=void 0)},h=>{l.current=void 0,s.current.failed(String(h)),a(s.current.nativeAngle)}),()=>d.current?.stop()),[]),u.useEffect(()=>{!x.current&&l.current===void 0&&a(e)},[e]),{angle:i,changeAngle:h=>{s.current.failed(void 0),l.current=h,a(h),d.current?.set(h)},interacting:x}}function $({angle:e,watchOnly:o=!1,changeAngle:n,interacting:i,rotate:a,onFold:s,foldTarget:l,onHingeDrag:x,children:d}){const f=u.useId();return r.jsxs("div",{className:"rc-duo-controls",onPointerDown:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"rc-duo-hinge",children:[r.jsx("button",{disabled:o,className:"rc-duo-fold",onClick:s??(()=>n(e<90?180:0)),children:(l??e)<90?"Unfold":"Fold"}),r.jsx("label",{htmlFor:f,children:"Hinge"}),r.jsx("input",{id:f,type:"range",disabled:o,min:0,max:180,step:1,value:e,onPointerDown:h=>{x?.(),i.current=!0,h.currentTarget.setPointerCapture(h.pointerId)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},onLostPointerCapture:()=>{i.current=!1},onChange:h=>n(Number(h.target.value))}),r.jsxs("output",{children:[Math.round(e),"°"]}),r.jsx("button",{disabled:o,className:"rc-duo-rotate","aria-label":"Rotate device",title:"Rotate device",onClick:a,children:r.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[r.jsx("rect",{x:"7",y:"3",width:"10",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9a9 9 0 0 1 3-5M3 4v5h5M21 15a9 9 0 0 1-3 5m3 0v-5h-5"})]})})]}),d&&r.jsx("div",{className:"rc-duo-views","aria-label":"Device view",children:d})]})}function G({button:e}){return r.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="side"?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"6",y:"10",width:"12",height:"11",rx:"2"}),r.jsx("path",{d:"M8 10V7a4 4 0 0 1 8 0v3"})]}):r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 9h4l5-5v16l-5-5H3zM17 12h5"}),e==="volumeUp"&&r.jsx("path",{d:"M19.5 9.5v5"})]})})}function B(e,o,n,i,a,s){return"M"+(e+a)+","+o+"H"+(e+n-s)+"a"+s+","+s+" 0 0 1 "+s+","+s+"V"+(o+i-s)+"a"+s+","+s+" 0 0 1 "+-s+","+s+"H"+(e+a)+"a"+a+","+a+" 0 0 1 "+-a+","+-a+"V"+(o+a)+"a"+a+","+a+" 0 0 1 "+a+","+-a+"Z"}function A({inner:e,width:o,height:n}){const i=u.useId().replace(/:/g,""),a=e?8.4:1.25,s=8.4;return r.jsxs("svg",{className:"rc-duo-flat-frame",viewBox:"0 0 "+o+" "+n,"aria-hidden":"true",children:[r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:i+"-silver",x1:"0",y1:"0",x2:"1",y2:"1",children:[r.jsx("stop",{offset:"0",stopColor:"#62676b"}),r.jsx("stop",{offset:"0.035",stopColor:"#f9faf9"}),r.jsx("stop",{offset:"0.11",stopColor:"#b0b4b6"}),r.jsx("stop",{offset:"0.31",stopColor:"#fdfefd"}),r.jsx("stop",{offset:"0.43",stopColor:"#797f84"}),r.jsx("stop",{offset:"0.51",stopColor:"#e8eaea"}),r.jsx("stop",{offset:"0.7",stopColor:"#979da1"}),r.jsx("stop",{offset:"0.87",stopColor:"#fafbf9"}),r.jsx("stop",{offset:"1",stopColor:"#5f676c"})]}),r.jsxs("linearGradient",{id:i+"-spine",children:[r.jsx("stop",{stopColor:"#4a5154"}),r.jsx("stop",{offset:"0.16",stopColor:"#d6d9d9"}),r.jsx("stop",{offset:"0.4",stopColor:"#f8f9f7"}),r.jsx("stop",{offset:"0.62",stopColor:"#a2a8ab"}),r.jsx("stop",{offset:"0.83",stopColor:"#e4e7e5"}),r.jsx("stop",{offset:"1",stopColor:"#666e72"})]})]}),!e&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"-2.3",y:"0.7",width:"3.3",height:n-1.4,rx:"0.85",fill:"url(#"+i+"-spine)",stroke:"#8b9296",strokeWidth:"0.15"}),r.jsx("path",{d:"M-.6 2V"+(n-2),stroke:"#f5f6f4",strokeWidth:"0.22"})]}),r.jsx("path",{d:B(0,0,o,n,a,s),fill:"url(#"+i+"-silver)",stroke:"#696f72",strokeWidth:"0.24"}),r.jsx("path",{d:B(.48,.48,o-.96,n-.96,Math.max(.5,a-.48),s-.48),fill:"none",stroke:"#ffffff",strokeOpacity:"0.85",strokeWidth:"0.2"}),r.jsx("path",{d:B(1.12,1.12,o-2.24,n-2.24,e?7.15:.65,7.15),fill:"#090b0d",stroke:"#34393c",strokeWidth:"0.2"}),[o-16,e?19:16].map(l=>r.jsx(u.Fragment,{children:r.jsx("path",{d:"M"+l+",0.17v0.82M"+l+","+(n-1)+"v0.82",stroke:"#b1b2ac",strokeWidth:"1.1"})},l)),e&&[0,n-.6].map(l=>r.jsx("rect",{x:o/2-2.2,y:l,width:"4.4",height:"0.6",rx:"0.18",fill:"url(#"+i+"-spine)",stroke:"#697074",strokeWidth:"0.14"},l)),r.jsx("path",{d:"M"+(o-.1)+",20h-.9m.9,"+(n-40)+"h-.9",stroke:"#b1b2ac",strokeWidth:"1.05"})]})}function ne(e,o,n,i){const a=E.DUO_DIMENSIONS.width/(e?1:2),s=E.DUO_DIMENSIONS.height,l=e?157.5:77.1,x=e?110.8:112.2,d=(o+(e?3:0))%4,f=Math.max(0,Math.min((n-120)/(d%2?s:a),(i-120)/(d%2?a:s))),h=(y,m)=>{y=(y-a/2)*f,m=(m-s/2)*f;const C=d===1?{x:-m,y}:d===2?{x:-y,y:-m}:d===3?{x:m,y:-y}:{x:y,y:m};return{x:C.x+n/2,y:C.y+i/2}},N=(d%2?s:a)*f,D=(d%2?a:s)*f,k={min:{x:(n-N)/2,y:(i-D)/2},max:{x:(n+N)/2,y:(i+D)/2}},g=[{button:"volumeDown",x:a-37,y:-.32,width:9.5,height:.65,edge:"top"},{button:"volumeUp",x:a-25,y:-.32,width:9.5,height:.65,edge:"top"},{button:"side",x:a+.35,y:s/2-21,width:.7,height:13,edge:"right"}],b=["top","right","bottom","left"],j=g.map(y=>{const m=b[(b.indexOf(y.edge)+d)%4],C=h(y.x,y.y);return m==="top"&&(C.y=k.min.y-28),m==="bottom"&&(C.y=k.max.y+28),m==="left"&&(C.x=k.min.x-28),m==="right"&&(C.x=k.max.x+28),{button:y.button,edge:m,...C,targetX:C.x,targetY:C.y}}),v=j.filter(y=>y.button!=="side"),p=d%2?"y":"x";v.sort((y,m)=>y[p]-m[p]);const S=d%2?"targetY":"targetX";if(v[1][p]-v[0][p]<44){const y=(v[0][p]+v[1][p])/2;v[0][S]=y-22,v[1][S]=y+22}return{bodyWidth:a,bodyHeight:s,screenWidth:l,screenHeight:x,scale:f,turns:d,buttons:g,guides:j,rect:k,iconSize:Math.min(Z(k),12*f)}}function Z(e){return Math.max(12,Math.min(24,Math.max(e.max.x-e.min.x,e.max.y-e.min.y)/24))}function J(e,o,n){return[["top",n.min.y-o,e,n.min.x,n.max.x],["bottom",o-n.max.y,e,n.min.x,n.max.x],["left",n.min.x-e,o,n.min.y,n.max.y],["right",e-n.max.x,o,n.min.y,n.max.y]].filter(([,a,s,l,x])=>a>=-7&&a<=52&&s>=l-12&&s<=x+12).sort((a,s)=>Math.abs(a[1])-Math.abs(s[1]))[0]?.[0]}function V(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return;const o=Math.min(1,1024/Math.max(e.videoWidth,e.videoHeight)),n=document.createElement("canvas");try{const i=n.getContext("2d");return i?(n.width=Math.round(e.videoWidth*o),n.height=Math.round(e.videoHeight*o),i.drawImage(e,0,0,n.width,n.height),n):void 0}catch{return}}function oe(e,o){let n=!1,i;const a=f=>{n||(d(),o(f))},s=()=>{if(n)return;const f=V(e);f&&a(f)},l=()=>{i=void 0,s(),n||(i=e?.requestVideoFrameCallback?.(l))},x=setTimeout(()=>a(void 0),2500);i=e?.requestVideoFrameCallback?.(l),e?.addEventListener("loadeddata",s),!e?.requestVideoFrameCallback&&e&&e.readyState>=2&&s();function d(){n=!0,clearTimeout(x),i!==void 0&&e?.cancelVideoFrameCallback(i),e?.removeEventListener("loadeddata",s)}return d}function se(e,o,n,i,a=!0){const s=u.useRef(void 0),l=u.useRef(i),x=u.useRef({inner:o,frame:n});x.current={inner:o,frame:n};const[d,f]=u.useState(),h=u.useRef(void 0),N=u.useRef(void 0),D=u.useCallback(()=>{clearTimeout(N.current),h.current=void 0,f(void 0)},[]),k=g=>{if(!a||g===o){D();return}if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||h.current)return;const b=V(e.current);if(!b)return;const j=x.current;h.current={from:j,to:j,before:b,ready:!1},f(h.current),N.current=setTimeout(D,5e3)};return u.useEffect(()=>()=>clearTimeout(N.current),[]),u.useLayoutEffect(()=>{const g=s.current,b={inner:o,frame:n};s.current=b;const j=l.current!==i;if(l.current=i,!g)return;const v=Math.abs(g.frame.rect.min.x+g.frame.rect.max.x-n.rect.min.x-n.rect.max.x)>.5||Math.abs(g.frame.rect.min.y+g.frame.rect.max.y-n.rect.min.y-n.rect.max.y)>.5;if(!a||v||j){D();return}if(g.inner===o||(f(void 0),!g.frame.scale||!n.scale)||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const p=h.current?.before??V(e.current),S=h.current?.from??g;clearTimeout(N.current),h.current=void 0,p&&f({from:S,to:b,before:p,ready:!1})},[o,n.scale,n.turns,n.rect.min.x,n.rect.min.y,i,a]),u.useEffect(()=>{if(!d||d.from.inner===o)return;const g=oe(e.current,v=>{v?f(p=>p&&{...p,to:x.current,after:v,ready:!0}):D()}),b=window.matchMedia?.("(prefers-reduced-motion: reduce)"),j=()=>{b?.matches&&f(void 0)};return b?.addEventListener("change",j),()=>{g(),b?.removeEventListener("change",j)}},[d?.from,o]),{motion:d,finish:D,prepare:k}}function ae({pose:e,image:o,scale:n}){const{bodyWidth:i,bodyHeight:a,screenWidth:s,screenHeight:l}=e.frame,x=s*n,d=l*n;return r.jsxs("div",{className:"rc-duo-fold-still",style:{width:i*n,height:a*n},children:[r.jsx(A,{inner:e.inner,width:i,height:a}),r.jsx("div",{className:"rc-duo-flat-screen",style:{width:x,height:d,left:(i-s)*n/2,top:(a-l)*n/2,borderRadius:e.inner?5.3*n:[.8,6.6,6.6,.8].map(f=>f*n+"px").join(" ")},children:o&&r.jsx("canvas",{ref:f=>{f&&(f.width=o.width,f.height=o.height,f.getContext("2d")?.drawImage(o,0,0))},style:{width:e.inner?d:x,height:e.inner?x:d,transform:`translate(-50%, -50%) rotate(${e.inner?90:0}deg)`}})})]})}function ie({motion:e,onFinish:o}){const n=u.useRef(null),[i,a]=u.useState(!1);return u.useEffect(()=>{if(a(!1),!e.ready)return;let s=!1,l;return Promise.resolve().then(()=>require("./duo-fold-renderer-DdltAnF7.js")).then(({renderFold:x})=>{s||!n.current||(l=x(n.current,e,o),a(!0))}).catch(()=>{s||o()}),()=>{s=!0,l?.()}},[e.ready,e.from,o]),r.jsxs(r.Fragment,{children:[!i&&r.jsx("div",{className:"rc-duo-fold-hold","aria-hidden":"true",style:{width:e.from.frame.bodyWidth*e.from.frame.scale,height:e.from.frame.bodyHeight*e.from.frame.scale,transform:`translate(-50%, -50%) rotate(${e.from.frame.turns*90}deg)`},children:r.jsx(ae,{pose:e.from,image:e.before,scale:e.from.frame.scale})}),r.jsx("canvas",{ref:n,className:"rc-duo-fold-canvas","aria-hidden":"true",style:{visibility:i?"visible":"hidden"}})]})}const ce=u.lazy(()=>Promise.resolve().then(()=>require("./duo-frame-B1NXSk6a.js")).then(e=>e.duoFrame));function ue(e){const[o,n]=u.useState("2d");return r.jsxs("div",{className:"rc-duo-view",children:[e.showFrame!==!1&&o==="3d"?r.jsx(u.Suspense,{fallback:r.jsx(X,{...e}),children:r.jsx(ce,{...e})}):r.jsx(X,{...e}),e.showFrame!==!1&&r.jsxs("div",{className:"rc-duo-mode",role:"group","aria-label":"Device rendering",children:[r.jsx("button",{type:"button","aria-pressed":o==="2d",onClick:()=>n("2d"),children:"2D"}),r.jsx("button",{type:"button","aria-pressed":o==="3d",onClick:()=>n("3d"),children:"3D"})]})]})}function X(e){const o=e.showFrame!==!1,n=u.useRef(null),i=u.useRef(null),a=u.useRef(e);a.current=e;const[s,l]=u.useState({width:0,height:0}),[x,d]=u.useState(),[f,h]=u.useState(),[N,D]=u.useState(),[k,g]=u.useState(),b=u.useRef(void 0),j=u.useRef(null);j.current||(j.current=new E.DuoTouchController((...t)=>a.current.touch(...t)));const v=u.useRef(null),p=E.getDuoDisplay(e.state),S=p?.id==="inner"?e.inner:e.outer,y=E.duoDisplayTurns(p?.orientation),m=p?.id==="inner",C={portrait:0,pud:2,"landscape-left":3,"landscape-right":1}[e.state.orientation],H=o?(C+(m?1:0))%4:y,w=ne(m,H,s.width,s.height),W=o?w.screenWidth:(m?p?.height:p?.width)??1,I=o?w.screenHeight:(m?p?.width:p?.height)??1,R=o?w.bodyWidth:W,F=o?w.bodyHeight:I,M=o?w.scale:Math.max(0,Math.min(s.width/(w.turns%2?F:R),s.height/(w.turns%2?R:F))),U=W*M,L=I*M;u.useEffect(()=>{const t=new ResizeObserver(([c])=>{c&&l({width:c.contentRect.width,height:c.contentRect.height})});return n.current&&t.observe(n.current),()=>t.disconnect()},[]),u.useEffect(()=>{const t=i.current;if(!t||!S)return;const c=()=>{t.srcObject!==S.srcObject&&(t.srcObject=S.srcObject),t.play().catch(()=>{}),e.outer?.pause(),e.inner?.pause()};return c(),S.addEventListener("loadedmetadata",c),()=>{S.removeEventListener("loadedmetadata",c),t.pause(),t.srcObject=null;for(const z of[e.outer,e.inner])z?.play().catch(()=>{})}},[S,e.outer,e.inner]);const{motion:P,finish:_,prepare:Q}=se(i,m,w,e.state.orientation,o),{angle:ee,changeAngle:te,interacting:re}=Y(e.state.angleDegrees,async t=>{Q(t>=90);try{await e.setAngle(t)}catch(c){throw _(),c}},d),T=()=>{j.current?.release(),b.current=void 0};u.useEffect(()=>{v.current=new E.DuoButtonSender((c,z)=>a.current.button(c,z),c=>d(String(c)));const t=()=>{T(),v.current?.release(),g(void 0)};return window.addEventListener("blur",t),()=>{t(),window.removeEventListener("blur",t)}},[]),u.useEffect(()=>{j.current?.setDisplay(p,H),j.current?.active||(b.current=void 0)},[p,H]);const O=()=>{v.current?.release(),g(void 0)},q=t=>({disabled:e.watchOnly,onPointerDown:c=>{e.watchOnly||P||c.button!==0||(c.currentTarget.setPointerCapture(c.pointerId),v.current?.press(t),g(t))},onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onBlur:O,onPointerEnter:()=>D(t),onPointerLeave:()=>D(void 0),onFocus:()=>h(w.guides.find(c=>c.button===t)?.edge),onKeyDown:c=>{P||(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),c.repeat||(v.current?.press(t),g(t)))},onKeyUp:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),O())}}),K=t=>{const c=t.currentTarget.getBoundingClientRect();return{x:(t.clientX-c.left)/c.width,y:(t.clientY-c.top)/c.height}};return r.jsxs("div",{className:o?"rc-duo":"rc-duo rc-duo-frameless",children:[r.jsxs("div",{ref:n,className:"rc-duo-flat-stage","data-folding":!!P,"aria-busy":!!P,onPointerMove:t=>{if(!o)return;const c=t.currentTarget.getBoundingClientRect();h(J(t.clientX-c.left,t.clientY-c.top,w.rect))},onPointerLeave:()=>{h(void 0),D(void 0)},children:[r.jsxs("div",{className:"rc-duo-flat-device","data-display":m?"inner":"outer",style:{width:R*M,height:F*M,transform:"translate(-50%, -50%) rotate("+w.turns*90+"deg)"},children:[o&&r.jsx(A,{inner:m,width:R,height:F}),r.jsx("div",{className:"rc-duo-flat-screen",role:"application","aria-label":"iPhone Duo 2D simulator",tabIndex:0,style:{width:U,height:L,left:(R-W)/2*M,top:(F-I)/2*M,borderRadius:o?m?5.3*M:[.8,6.6,6.6,.8].map(t=>t*M+"px").join(" "):0},onKeyDown:P?void 0:e.onKeyDown,onKeyUp:e.onKeyUp,onPointerDown:t=>{if(e.watchOnly||P||b.current!==void 0||t.button!==0||!p)return;t.currentTarget.focus({preventScroll:!0}),t.currentTarget.setPointerCapture(t.pointerId);const c=K(t);b.current=t.pointerId,j.current?.touch("begin",c.x,c.y)},onPointerMove:t=>{if(b.current!==t.pointerId)return;const c=K(t);j.current?.touch("move",c.x,c.y)},onPointerUp:t=>{b.current===t.pointerId&&T()},onPointerCancel:T,onLostPointerCapture:T,children:r.jsx("video",{ref:i,autoPlay:!0,muted:!0,playsInline:!0,style:{width:m?L:U,height:m?U:L,transform:"translate(-50%, -50%) rotate("+(m?90:0)+"deg)"}})}),o&&w.buttons.map(t=>r.jsx("button",{type:"button",className:"rc-duo-physical","data-duo-button":t.button,"data-edge":t.edge,"data-highlighted":N===t.button,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button]+" physical button",title:E.DUO_BUTTONS[t.button],style:{left:t.x*M,top:t.y*M,width:t.edge==="top"?Math.max(28,t.width*M):28,height:t.edge==="top"?28:Math.max(28,t.height*M)},...q(t.button),children:r.jsx("span",{style:{width:Math.max(2,t.width*M),height:Math.max(2,t.height*M)}})},t.button))]}),o&&w.guides.map(t=>r.jsx("button",{type:"button",className:"rc-duo-hardware","data-duo-button":t.button,"data-visible":f===t.edge,"data-pressed":k===t.button,"aria-label":E.DUO_BUTTONS[t.button],title:E.DUO_BUTTONS[t.button],style:{left:t.targetX,top:t.targetY,"--duo-hardware-icon-size":`${w.iconSize}px`,"--duo-hardware-icon-x":`${t.x-t.targetX}px`,"--duo-hardware-icon-y":`${t.y-t.targetY}px`},...q(t.button),children:r.jsx(G,{button:t.button})},t.button)),P&&r.jsx(ie,{motion:P,onFinish:_})]}),o&&r.jsx($,{watchOnly:e.watchOnly,angle:ee,changeAngle:te,interacting:re,rotate:()=>{e.setOrientation(e.state.orientation==="portrait"?"landscape-left":"portrait").catch(t=>d(String(t)))},children:r.jsx("span",{className:"rc-duo-view-label",children:"Front view"})}),x&&r.jsx("div",{role:"alert",className:"rc-duo-error",children:x})]})}const de=Object.freeze(Object.defineProperty({__proto__:null,default:ue},Symbol.toStringTag,{value:"Module"}));exports.DuoControls=$;exports.DuoHardwareIcon=G;exports.duoView=de;exports.flatHoverEdge=J;exports.hardwareIconSize=Z;exports.useDuoHinge=Y;
|