Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

529 lines
20 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: e5665fbfc4a03fa5.7b861e1710.js
* Module id: 523520
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(462214),
r = e.i(358379),
n = e.i(529833),
a = e.i(41671),
l = e.i(722573),
o = e.i(677588),
i = e.i(216257),
s = e.i(791997),
u = e.i(41114),
c = e.i(91134),
d = e.i(234954);
function f({ enabled: e, className: r, size: n = 16 }) {
return (0, t.jsxs)("svg", {
width: n,
height: n,
viewBox: "0 0 16 16",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
className: r,
children: [
(0, t.jsx)("path", {
d: "M10.6664 2.06738C11.734 2.0674 12.5998 2.93241 12.6 4V4.68457L13.6224 4.36523C14.438 4.11054 15.267 4.71976 15.267 5.57422V10.4268C15.2668 11.281 14.4378 11.8903 13.6224 11.6357L12.6 11.3154V12C12.5998 13.0676 11.734 13.9336 10.6664 13.9336H8.00037C7.66921 13.9336 7.40013 13.6651 7.39978 13.334C7.39978 13.0026 7.669 12.7334 8.00037 12.7334H10.6664C11.0713 12.7334 11.3996 12.4048 11.3998 12V4C11.3996 3.59515 11.0713 3.26662 10.6664 3.2666H2.66638C2.26163 3.26678 1.93316 3.59525 1.93298 4V8.57129C1.93281 8.9025 1.66462 9.17186 1.33337 9.17188C1.00211 9.17188 0.73394 8.90251 0.733765 8.57129V4C0.73394 2.93251 1.59889 2.06756 2.66638 2.06738H10.6664ZM13.9808 5.50977L12.6 5.94141V10.0586L13.9808 10.4902C14.0234 10.5031 14.0666 10.4713 14.0668 10.4268V5.57422C14.0668 5.52948 14.0235 5.4969 13.9808 5.50977ZM4.00037 4.66699C4.36828 4.66719 4.66621 4.96509 4.66638 5.33301C4.66638 5.70108 4.36839 5.9998 4.00037 6C3.63218 6 3.33337 5.7012 3.33337 5.33301C3.33355 4.96497 3.63228 4.66699 4.00037 4.66699Z",
fill: "currentColor",
}),
(0, t.jsx)("circle", {
cx: "4",
cy: "5.33",
r: "0.67",
fill: e ? "#4EC740" : "#525252",
style: { transition: "fill 0.25s ease" },
}),
(0, t.jsx)("rect", {
x: "1",
y: "10.33",
width: "10",
height: "5.33",
rx: "2.665",
fill: e ? "#4EC740" : "#A8A8A8",
style: { transition: "fill 0.25s ease" },
}),
(0, t.jsx)("circle", {
cx: e ? 11 : 4,
cy: "13",
r: "2",
fill: "white",
style: { transition: "cx 0.25s cubic-bezier(0.4, 0, 0.2, 1)" },
}),
],
});
}
function m(e, t) {
let r = () => {
if (0 === e.length) return 0;
let t = e.findIndex((e) => !0 === e.default);
return t >= 0 ? t : 0;
};
if (!t) return r();
let n = e.findIndex((e) => e.key === t);
return n >= 0 ? n : r();
}
function p({ items: e, selectedIndex: n, onSelect: l, label: o }) {
let i = (0, r.useRef)(null),
s = (0, r.useRef)(null),
c = (0, r.useRef)(n);
c.current = n;
let d = (0, r.useRef)(l);
if (
((d.current = l),
(0, r.useEffect)(() => {
let t = s.current;
if (!t) return;
let r = (t) => {
if (
(t.preventDefault(),
t.stopPropagation(),
i.current || 15 > Math.abs(t.deltaY))
)
return;
let r = c.current,
n = e.length,
a = t.deltaY > 0 ? Math.min(r + 1, n - 1) : Math.max(r - 1, 0);
a !== r && d.current(a),
(i.current = setTimeout(() => {
i.current = null;
}, 350));
};
return (
t.addEventListener("wheel", r, { passive: !1 }),
() => t.removeEventListener("wheel", r)
);
}, [e.length]),
0 === e.length)
)
return null;
let f = e.some((e) => e.image),
m = e[n],
p = -(96 * n) + 30,
g = 0 === n,
v = n === e.length - 1,
h = (e) => {
e.preventDefault(), e.stopPropagation();
},
x = (e) => {
e.preventDefault(), e.stopPropagation();
};
return (0, t.jsxs)("div", {
className: "flex w-[120px] flex-col items-center",
children: [
(0, t.jsx)("div", {
className: "flex h-5 w-full items-center justify-center",
onPointerDown: h,
onMouseDown: h,
children: (0, t.jsx)("button", {
type: "button",
"aria-disabled": g,
onPointerDown: h,
onMouseDown: h,
onClick: (e) => {
x(e), g || l(Math.max(n - 1, 0));
},
className: (0, u.cn)(
"text-fg-muted hover:text-fg-default flex size-5 cursor-pointer items-center justify-center transition-colors",
g && "cursor-not-allowed opacity-40 hover:text-inherit",
),
children: (0, t.jsx)(a.Icons.lucideChevronDown, {
className: "size-3.5 rotate-180",
}),
}),
}),
(0, t.jsxs)("div", {
ref: s,
className: "relative w-full",
style: { height: 156 },
children: [
(0, t.jsx)("div", {
className:
"border-hair border-border-default pointer-events-none absolute inset-x-4 z-20 rounded-xl",
style: {
top: 30,
height: 96,
background:
"radial-gradient(ellipse at center, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%)",
},
children: (0, t.jsx)("span", {
className: "text-fg-muted mt-2 block text-center text-[11px]",
children: o,
}),
}),
(0, t.jsx)("div", {
className: "absolute inset-0 overflow-hidden",
children: (0, t.jsx)("div", {
className: "flex flex-col items-center",
style: {
transform: `translateY(${p}px)`,
transition: "transform 0.3s cubic-bezier(0, 0, 0.2, 1)",
},
children: e.map((e, r) => {
var a;
let o,
i = r === n;
return (0, t.jsx)(
"button",
{
type: "button",
onClick: () => l(r),
className: (0, u.cn)(
"flex w-full shrink-0 cursor-pointer flex-col items-center",
f ? "justify-end pb-4" : "justify-center pt-4",
),
style: { height: 96 },
children:
f && e.image
? (0, t.jsx)("img", {
src: e.image,
alt: e.name,
className: (0, u.cn)(
"rounded object-cover transition-all duration-200",
i
? "size-12 opacity-100"
: "size-10 opacity-50",
),
loading: "lazy",
})
: (0, t.jsx)("span", {
className: (0, u.cn)(
"text-fg-default font-semibold transition-all duration-200",
i
? "text-2xl opacity-100"
: "text-xl opacity-50",
),
children: (o = (a = e.name).match(/[\d.]+/))
? o[0]
: a,
}),
},
e.key,
);
}),
}),
}),
],
}),
(0, t.jsx)("div", {
className: "flex h-5 w-full items-center justify-center",
onPointerDown: h,
onMouseDown: h,
children: (0, t.jsx)("button", {
type: "button",
"aria-disabled": v,
onPointerDown: h,
onMouseDown: h,
onClick: (t) => {
x(t), v || l(Math.min(n + 1, e.length - 1));
},
className: (0, u.cn)(
"text-fg-muted hover:text-fg-default flex size-5 cursor-pointer items-center justify-center transition-colors",
v && "cursor-not-allowed opacity-40 hover:text-inherit",
),
children: (0, t.jsx)(a.Icons.lucideChevronDown, {
className: "size-3.5",
}),
}),
}),
(0, t.jsx)("span", {
className:
"text-fg-muted mt-2 w-full truncate text-center text-[11px]",
children: f ? m.name : "mm",
}),
],
});
}
function g() {
return (0, t.jsx)("div", {
className: "flex h-14 w-4 items-center justify-center self-center",
children: (0, t.jsx)("div", {
className: "bg-canvas-controls-border h-full w-px",
}),
});
}
function v({
params: e,
modelSchema: v,
onParamsChange: h,
interactionDisabled: x,
}) {
let b = (0, s.useCanvasThemeStore)((e) => e.theme),
[y, j] = (0, r.useState)(!1),
w = (0, r.useRef)(null),
N = (0, r.useRef)(null),
C = (0, d.usePopoverManager)(),
S = (0, r.useId)(),
[D, k] = (0, r.useState)({ camera: 0, lens: 0, focal: 0, aperture: 0 }),
V = (0, i.useGlobalStore)((e) => e.cameraControl),
I = (0, r.useMemo)(() => {
let e = v?.properties;
return e?.cameraControl === !0;
}, [v]),
E = e.cameraControl;
(0, r.useEffect)(() => {
if (C)
return C.register({
id: S,
targetRef: w,
dropdownRef: N,
close: () => j(!1),
});
}, [C, S]),
(0, r.useEffect)(() => {
y &&
V &&
E &&
k({
camera: m(V.camera ?? [], E.camera),
lens: m(V.lens ?? [], E.lens),
focal: m(V.focal ?? [], E.focal),
aperture: m(V.aperture ?? [], E.aperture),
});
}, [y]);
let M = (0, r.useCallback)(
(e) => {
if ((e.stopPropagation(), !E)) return;
let t = { ...E, enabled: !E.enabled };
h({ cameraControl: t }), (0, c.saveCameraControlStorage)(t);
},
[E, h],
),
_ = (0, r.useCallback)(() => {
if (!V) return;
let e = (e) => (V[e] ?? [])[D[e]]?.key ?? "",
t = {
enabled: !0,
camera: e("camera"),
lens: e("lens"),
focal: e("focal"),
aperture: e("aperture"),
};
h({ cameraControl: t }), (0, c.saveCameraControlStorage)(t), j(!1);
}, [V, D, h]),
T = (0, r.useCallback)((e, t) => {
k((r) => ({ ...r, [e]: t }));
}, []),
R = (0, r.useCallback)((e) => {
e.preventDefault(), e.stopPropagation();
}, []),
A = (0, r.useCallback)((e) => {
e.detail < 2 || (e.preventDefault(), e.stopPropagation());
}, []),
z = (0, r.useMemo)(() => {
if (!V || !E) return null;
let e = (e) => (V[e] ?? []).find((t) => t.key === E[e]),
r = e("camera"),
n = e("lens"),
a = e("focal"),
l = e("aperture");
if (!r) return null;
let o = [n?.name, a?.name, l?.name].filter(Boolean).join(" / ");
return (0, t.jsxs)("div", {
className: (0, u.cn)(
"flex items-center gap-2.5 py-0.5",
"light" === b && "canvas-light",
),
children: [
r.image &&
(0, t.jsx)("img", {
src: r.image,
alt: r.name,
className: "size-9 shrink-0 rounded object-cover",
}),
(0, t.jsxs)("div", {
className: "flex flex-col gap-0.5",
children: [
(0, t.jsxs)("div", {
className: "flex items-center justify-between gap-2",
children: [
(0, t.jsx)("span", {
className: "text-fg-default text-xs font-medium",
children: r.name,
}),
(0, t.jsx)("span", {
className: (0, u.cn)(
"text-xs",
E.enabled ? "text-fg-default" : "text-fg-muted",
),
children: E.enabled ? "已开启" : "已关闭",
}),
],
}),
o &&
(0, t.jsx)("span", {
className: "text-fg-muted text-xs",
children: o,
}),
],
}),
],
});
}, [V, E, b]);
if (
((0, r.useEffect)(() => {
x && j(!1);
}, [x]),
!I || !V)
)
return null;
let P = E?.enabled ?? !1;
return (0, t.jsxs)(n.Popover, {
opened: !x && y,
onChange: x ? () => void 0 : j,
position: "bottom",
offset: 0,
shadow: "md",
radius: "md",
withinPortal: !0,
closeOnClickOutside: !1,
children: [
(0, t.jsx)(n.Popover.Target, {
children: (0, t.jsx)(l.Tooltip, {
label: x ? "全景模式下已锁定" : z,
disabled: !x && (y || !z),
position: "top",
openDelay: 300,
styles:
"light" === b
? { tooltip: { padding: "6px 10px", borderRadius: "10px" } }
: {
tooltip: {
backgroundColor: "#000000",
padding: "6px 10px",
border: "0.5px solid #363636",
borderRadius: "10px",
boxShadow:
"0px 8px 16px rgba(0,0,0,0.18), 0px 2px 4px rgba(0,0,0,0.2)",
},
},
children: (0, t.jsxs)("button", {
type: "button",
ref: w,
disabled: x,
onClick: () => {
x ||
((0, o.reportLog)({
e: "libtv.canvas.image_generator.camera_control.click",
}),
C?.closeAll(S),
j((e) => !e));
},
className: (0, u.cn)(
"flex h-8 shrink-0 items-center justify-center gap-1 rounded-lg bg-transparent px-2 py-1 transition-colors",
x
? "cursor-not-allowed opacity-50"
: "hover:bg-btn-ghost-hover cursor-pointer",
!x && y && "bg-btn-ghost-hover",
),
children: [
(0, t.jsx)("span", {
role: "button",
tabIndex: -1,
onClick: M,
onKeyDown: (e) => {
("Enter" === e.key || " " === e.key) && M(e);
},
className:
"hover:bg-btn-ghost-hover flex size-6 items-center justify-center rounded-lg",
children: (0, t.jsx)(f, {
enabled: P,
className: "text-fg-default",
size: 16,
}),
}),
(0, t.jsx)("span", {
className: "text-fg-default whitespace-nowrap text-[13px]",
children: "摄像机",
}),
],
}),
}),
}),
(0, t.jsx)(n.Popover.Dropdown, {
ref: N,
className: `bg-panel-background border-border-muted hairline! p-0! ${"light" === b ? "canvas-light" : ""}`,
children: (0, t.jsxs)("div", {
className:
"flex flex-col rounded-xl shadow-[0px_4px_10px_rgba(0,0,0,0.12),0px_2px_4px_rgba(0,0,0,0.2)] backdrop-blur-2xl",
onDoubleClickCapture: R,
onMouseDownCapture: A,
onPointerDownCapture: A,
children: [
(0, t.jsxs)("div", {
className:
"border-border-muted flex h-12 items-center justify-between border-b px-4",
children: [
(0, t.jsx)("span", {
className: "text-fg-default text-sm font-medium",
children: "摄像机",
}),
(0, t.jsx)("button", {
type: "button",
onClick: () => j(!1),
className:
"text-fg-muted hover:text-fg-default flex size-6 items-center justify-center rounded-lg transition-colors",
children: (0, t.jsx)(a.Icons.x, {
className: "size-3.5",
}),
}),
],
}),
(0, t.jsxs)("div", {
className: "flex items-start justify-center gap-1 px-6 py-5",
children: [
(0, t.jsx)(g, {}),
(0, t.jsx)(p, {
items: V.camera ?? [],
selectedIndex: D.camera,
onSelect: (e) => T("camera", e),
label: "相机",
}),
(0, t.jsx)(g, {}),
(0, t.jsx)(p, {
items: V.lens ?? [],
selectedIndex: D.lens,
onSelect: (e) => T("lens", e),
label: "镜头",
}),
(0, t.jsx)(g, {}),
(0, t.jsx)(p, {
items: V.focal ?? [],
selectedIndex: D.focal,
onSelect: (e) => T("focal", e),
label: "焦距",
}),
(0, t.jsx)(g, {}),
(0, t.jsx)(p, {
items: V.aperture ?? [],
selectedIndex: D.aperture,
onSelect: (e) => T("aperture", e),
label: "光圈",
}),
(0, t.jsx)(g, {}),
],
}),
(0, t.jsx)("div", {
className: "flex items-center justify-end px-4 pb-4",
children: (0, t.jsx)("button", {
type: "button",
onClick: _,
className:
"bg-btn-primary hover:bg-btn-primary-hover active:bg-btn-primary-active text-btn-primary-text h-8 w-[50px] rounded-lg text-[13px] transition-colors",
children: "使用",
}),
}),
],
}),
}),
],
});
}
e.s(["default", () => v], 523520);
};
export default moduleFactory;