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

490 lines
19 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Extracted from browser-delivered Turbopack chunk: fd0220e4d10052af.701bdafa2d.js
* Module id: 10357
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(462214),
n = e.i(358379),
i = e.i(111558),
r = e.i(292002),
a = e.i(768924),
o = e.i(415796),
s = e.i(85614),
c = e.i(867734),
l = e.i(282932),
u = e.i(755636),
h = e.i(33830),
f = e.i(41671),
d = e.i(777784),
p = e.i(772e3),
g = e.i(703962),
b = e.i(505e3),
m = e.i(713118),
w = e.i(182004),
v = e.i(216257),
x = e.i(961258);
e.i(135623);
var y = e.i(168823);
e.i(954175);
var _ = e.i(616803),
S = e.i(301710),
E = e.i(649342),
M = e.i(44980),
T = e.i(15146),
k = e.i(717139),
C = e.i(380332),
A = e.i(710871),
N = e.i(174008),
I = e.i(739809);
let P =
"flex h-8 w-8 min-w-8 shrink-0 items-center justify-center rounded-lg text-neutral-50 transition-colors hover:bg-white/10 disabled:pointer-events-none disabled:opacity-40",
R = (0, n.memo)(function ({ id: e, selected: R }) {
let L = (0, n.useRef)(null),
D = (0, n.useRef)(null),
j = (0, a.useReactFlow)(),
O = (0, n.useRef)(null),
F = (0, n.useRef)(null),
U = (0, v.useCanvasStore)((t) => t.getNode(e)?.data),
B = (0, v.useCanvasStore)((e) => e.updateNodeData),
H = (0, v.useCanvasStore)((e) => e.addNode),
z = (0, v.useCanvasStore)((e) => e.isReadonly),
[G, $] = (0, n.useState)(!1),
[V, W] = (0, n.useState)(!1);
(0, k.useNodeDimensionSync)(e, L);
let K = (0, C.useNodeInteraction)(e, R),
{ isDraggingConnection: q } = K,
[X, Y] = (0, n.useState)(!1),
J = U?.panoramaUrl?.trim() || void 0,
Z = U?.name || U?.label || "全景",
Q = (0, n.useCallback)(() => {
j.fitView({
nodes: [{ id: e }],
padding: 0.25,
duration: 300,
minZoom: x.CANVAS_ZOOM.min,
maxZoom: x.CANVAS_ZOOM.max,
}),
Y(!0);
}, [e, j]),
ee =
"number" == typeof U?.contentWidth ? U.contentWidth : m.NODE_WIDTH,
et = "number" == typeof U?.contentHeight ? U.contentHeight : 220,
en = X ? Math.round((16 / 9) * et) : ee,
ei = (0, n.useCallback)((t) => B(e, { name: t }), [e, B]),
er = (0, n.useCallback)(
(e) => {
let t = v.stores.canvas?.edges ?? [],
n = j.getNodes(),
i = (0, M.getAbsoluteNodePosition)(e, n),
r = new Set(
t.filter((t) => t.source === e.id).map((e) => e.target),
),
a = n.filter(
(e) =>
!!r.has(e.id) &&
(0, M.getAbsoluteNodePosition)(e, n).x > i.x,
);
return 0 === a.length
? i.y
: Math.max(
...a.map((e) => {
let t = (0, M.getAbsoluteNodePosition)(e, n),
i =
e.measured?.height ?? e.height ?? m.NODE_HEIGHT_EMPTY;
return t.y + i;
}),
) + 80;
},
[j],
),
ea = (0, n.useCallback)(
async (t, n) => {
if (0 === t.length) return;
let i = (0, y.getCookie)(b.USER_TOKEN_COOKIE_KEY),
a = (0, y.getCookie)(b.USER_UUID_COOKIE_KEY);
if (!i || "string" != typeof i || !a || "string" != typeof a)
return void d.Notify.error("请先登录");
let o = j.getNode(e);
if (!o) return;
(O.current = null), (F.current = null);
let s = t[0],
c = (0, m.computeNodeDimensionsFromNatural)(s.width, s.height),
l = c.width,
u = c.height,
h = [],
f = 0,
g = t.length;
try {
for (let e = 0; e < t.length; e++) {
let s = t[e],
{ offsetX: c, offsetY: b } = (0,
T.getPanoramaBatchCellOffsets)(e, g, l, u, 60);
try {
let t = await (0, p.dataUrlToFile)(
s.dataUrl,
`panorama-${e}`,
),
f = await (0, S.uploadViaPreSign)(t, {
token: i,
uuid: a,
onCalcHashEnd: () => {},
}),
d = f.url ?? (0, S.resolveUploadUrl)(f);
if (!d) throw Error("上传图片失败:未返回图片URL");
let m = j.getNodes(),
v = (0, M.getAbsoluteNodePosition)(o, m);
0 === e &&
((O.current = v.x + en + M.CANVAS_RIGHT_EDGE_GAP),
(F.current = er(o)));
let x =
(O.current ?? v.x + en + M.CANVAS_RIGHT_EDGE_GAP) + c,
y = (F.current ?? v.y) + b,
_ = crypto.randomUUID(),
E =
4 === g
? T.PANORAMA_RING4_NODE_LABELS[e]
: 12 === g
? (0, T.getPanoramaRing12NodeLabel)(e)
: `${n}${e + 1}`;
H(
{
id: _,
type: w.NodeType.IMAGE,
data: {
type: w.NodeType.IMAGE,
label: E,
url: [],
action: w.NodeAction.IMAGE_GENERATE,
generatorType: w.GeneratorType.DEFAULT,
},
position: { x: x, y: y },
sourcePosition: r.Position.Right,
targetPosition: r.Position.Left,
},
{ skipOverlapResolution: !0 },
),
h.push(_),
B(_, {
url: [d],
contentWidth: l,
contentHeight: u,
params: { prompt: "", settings: { ratio: "auto" } },
});
} catch (t) {
if (t instanceof _.FileReviewError) {
f++,
d.Notify.warn(`第 ${e + 1} 张图片审核未通过,已跳过`);
continue;
}
throw t;
}
}
if (
((0, E.groupGridChildNodes)(
e,
h,
l,
u,
(0, T.getPanoramaScreenshotGroupName)(h.length),
(e) => {
requestAnimationFrame(() => {
j.fitBounds(e, { duration: 350, padding: 0.15 });
});
},
),
0 === h.length)
)
d.Notify.error(
f > 0 ? "所有全景截图审核未通过" : "未能创建生图节点",
);
else {
let e =
f > 0
? `生图节点创建完成(${f} 张审核未通过已跳过)`
: "生图节点创建完成";
d.Notify.success(e);
}
} catch (t) {
let e = t instanceof Error ? t.message : "全景生图节点创建失败";
d.Notify.error(e);
}
},
[e, j, H, B, en, er],
),
eo = (0, n.useCallback)(() => {
if (z) return void d.Notify.warning("只读模式无法创建节点");
let e = D.current?.captureScreenshot(),
t = D.current?.getRendererPixelSize();
e && t
? ($(!0),
d.Notify.info("正在上传全景截图并创建生图节点..."),
ea(
[{ dataUrl: e, width: t.width, height: t.height }],
`${Z} 截图`,
).finally(() => $(!1)))
: d.Notify.error("截图失败");
}, [z, ea, Z]),
es = (0, n.useCallback)(() => {
if (z) return void d.Notify.warning("只读模式无法创建节点");
let e = D.current?.captureScreenshotsFromRing(4);
e?.length
? ($(!0),
d.Notify.info("正在上传全景截图并创建生图节点..."),
ea(e, `${Z} 视角`).finally(() => $(!1)))
: d.Notify.error("截图失败");
}, [z, ea, Z]),
ec = (0, n.useCallback)(() => {
if (z) return void d.Notify.warning("只读模式无法创建节点");
let e = D.current?.captureScreenshotsFromRing(12);
e?.length
? ($(!0),
d.Notify.info("正在上传全景截图并创建生图节点..."),
ea(e, `${Z} 视角`).finally(() => $(!1)))
: d.Notify.error("截图失败");
}, [z, ea, Z]),
el = (0, n.useCallback)(() => {
D.current?.resetView();
}, []);
(0, n.useEffect)(() => {
if (!X) return;
let e = (e) => {
"Escape" === e.key && (e.stopPropagation(), Y(!1));
};
window.addEventListener("keydown", e);
let t = document.body.style.overflow;
return (
(document.body.style.overflow = "hidden"),
() => {
window.removeEventListener("keydown", e),
(document.body.style.overflow = t);
}
);
}, [X]);
let eu = {
width: `${en}px`,
height: `${et}px`,
position: "relative",
background: "var(--Surface-secondary-background, #262626)",
border: "1px solid var(--canvas-node-border)",
borderRadius: "12px",
overflow: "hidden",
},
eh =
!J || q || X
? void 0
: (0, t.jsx)(g.default, {
nodeId: e,
baseOffset: 24,
zIndex: 20,
children: (0, t.jsxs)("div", {
className:
"nodrag flex w-max items-center justify-center gap-1",
style: N.FLOATING_TOOLBAR_STYLE,
children: [
(0, t.jsx)("button", {
type: "button",
className: P,
title: "截图并创建生图节点",
disabled: z || G,
onClick: eo,
children: (0, t.jsx)(o.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
(0, t.jsx)("button", {
type: "button",
className: P,
title: "四宫格:四方位截图上传后创建生图节点",
disabled: z || G,
onClick: es,
children: (0, t.jsx)(l.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
(0, t.jsx)("button", {
type: "button",
className: P,
title: "十二宫格:十二方位截图上传后创建生图节点",
disabled: z || G,
onClick: ec,
children: (0, t.jsx)(u.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
(0, t.jsx)("button", {
type: "button",
className: P,
title: "重置视角",
onClick: el,
children: (0, t.jsx)(h.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
(0, t.jsx)("button", {
type: "button",
className: V
? "flex h-8 w-8 min-w-8 shrink-0 items-center justify-center rounded-lg text-btn-primary transition-colors bg-(--btn-secondary-bg) disabled:pointer-events-none disabled:opacity-40"
: P,
title: "构图参考线",
onClick: () => W((e) => !e),
children: (0, t.jsx)(s.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
(0, t.jsx)("button", {
type: "button",
className: P,
title: "全景预览",
onClick: Q,
children: (0, t.jsx)(c.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
],
}),
});
return (0, t.jsxs)(A.default, {
ref: L,
id: e,
selected: R,
label: Z,
titleIcon: (0, t.jsx)(f.Icons.Rotate3d, { className: "h-3.5 w-3.5" }),
isReadonly: z,
onLabelChange: ei,
maxWidth: en,
interaction: K,
contentStyle: eu,
contentClassName: "group overflow-hidden rounded-xl",
shouldShowGenerator: !1,
nodeType: w.NodeType.SPACE_SCENE_720,
beforeContent: eh,
children: [
(0, t.jsx)("div", {
className: `relative h-full w-full ${q ? "pointer-events-none" : ""}`,
style: { touchAction: "none" },
children: X
? null
: (0, t.jsx)(I.default, {
ref: D,
url: J,
className: "h-full w-full",
showCompositionGrid: V,
}),
}),
X &&
J &&
"u" > typeof document &&
(0, i.createPortal)(
(0, t.jsxs)("div", {
className: "fixed inset-0 flex flex-col",
style: {
zIndex: 400,
background: "rgba(10, 10, 10, 0.95)",
backdropFilter: "blur(8px)",
},
children: [
(0, t.jsxs)("div", {
className:
"flex shrink-0 items-center justify-between border-b px-6",
style: {
height: 56,
borderColor: "rgba(255, 255, 255, 0.08)",
},
children: [
(0, t.jsx)("span", {
className: "text-base font-medium text-white/90",
children: Z,
}),
(0, t.jsxs)("div", {
className: "flex items-center gap-1",
children: [
(0, t.jsx)("button", {
type: "button",
onClick: () => W((e) => !e),
className: V
? "bg-(--btn-secondary-bg) text-btn-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors"
: "flex h-8 w-8 items-center justify-center rounded-lg text-white/50 transition-colors hover:bg-white/10 hover:text-white/80",
title: "构图参考线",
children: (0, t.jsx)(s.default, {
className: "h-4 w-4 shrink-0",
"aria-hidden": !0,
}),
}),
(0, t.jsx)("button", {
type: "button",
onClick: () => Y(!1),
className:
"flex h-7 w-7 items-center justify-center rounded-lg text-white/50 transition-colors hover:bg-white/10 hover:text-white/80",
title: "关闭 (ESC)",
children: (0, t.jsx)(f.Icons.x, {
width: 12,
height: 12,
}),
}),
],
}),
],
}),
(0, t.jsx)("div", {
className: "min-h-0 flex-1",
style: { touchAction: "none" },
children: (0, t.jsx)(I.default, {
ref: D,
url: J,
className: "h-full w-full",
showCompositionGrid: V,
}),
}),
],
}),
document.body,
),
],
});
});
function L({ selected: e }) {
return (0, t.jsxs)("div", {
style: {
width: 1,
height: 1,
minWidth: 1,
minHeight: 1,
background: "var(--Surface-secondary-background, #262626)",
border: e
? "2px solid var(--canvas-node-border-selected)"
: "1px solid var(--canvas-node-border)",
position: "relative",
overflow: "hidden",
},
children: [
(0, t.jsx)(a.Handle, {
type: "target",
position: r.Position.Left,
id: "target",
style: { background: "var(--canvas-handle)" },
}),
(0, t.jsx)(a.Handle, {
type: "source",
position: r.Position.Right,
id: "source",
style: { background: "var(--canvas-handle)" },
}),
],
});
}
(R.displayName = "SpaceScene720Node"),
e.s(["default", 0, R], 303665),
e.s(["default", () => L], 10357);
};
export default moduleFactory;