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

3580 lines
151 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: 41ea0f48db16523a.d4f5853546.js
* Module id: 334642
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t,
r = e.i(462214),
i = e.i(358379),
a = e.i(734911),
l = e.i(41671),
n = e.i(777784),
s = e.i(386598),
o = e.i(41114);
let d = (0, i.memo)(function ({ opened: e, onClose: t, onAgreed: d }) {
let c = (0, s.useThirdAssetStore)((e) => e.signAgreement),
[u, p] = (0, i.useState)(!1),
[f, x] = (0, i.useState)(!1),
m = (0, i.useCallback)(async () => {
if (u && !f) {
x(!0);
try {
(await c()) ? d?.() : n.Notify.error("签署失败,请重试");
} finally {
x(!1);
}
}
}, [u, c, f, d, t]),
g = (0, i.useCallback)(() => {
p(!1), t();
}, [t]);
return (0, r.jsx)(a.Modal, {
opened: e,
onClose: g,
title: "Seedance2.0模型使用承诺书",
centered: !0,
withCloseButton: !0,
closeOnClickOutside: !1,
closeOnEscape: !1,
size: 740,
styles: {
overlay: { zIndex: 800 },
inner: { zIndex: 801 },
content: {
borderRadius: 12,
backgroundColor: "var(--bg-surface)",
border: "1px solid var(--border-default)",
},
header: { padding: "16px", backgroundColor: "transparent" },
title: { fontSize: 16, fontWeight: 500, color: "var(--fg-default)" },
body: { padding: "0 0 16px" },
close: { color: "var(--fg-muted)" },
},
children: (0, r.jsxs)("div", {
className:
"border-border-default flex max-h-[calc(100vh-200px)] flex-col border-t",
children: [
(0, r.jsxs)("div", {
className:
"tiny-scrollbar min-h-0 flex-1 space-y-3 overflow-y-auto px-6 pt-6 text-sm leading-relaxed",
children: [
(0, r.jsx)("p", {
className: "text-fg-default",
children:
"为保障您依法合规使用Seedance2.0模型所提供的相关服务,请您在使用前务必仔细阅读、充分理解并做出以下承诺:",
}),
(0, r.jsxs)("div", {
className: "space-y-2",
children: [
(0, r.jsx)("p", {
className: "text-fg-default font-medium",
children: "1. 您对即将上传或使用的素材拥有充分合法权益",
}),
(0, r.jsxs)("ul", {
className:
"text-fg-muted list-disc space-y-1 pl-5 text-[13px]",
children: [
(0, r.jsx)("li", {
children:
"包括但不限于图片/视频/音频/文本/人物形象/虚拟人像/声音/品牌元素等。",
}),
(0, r.jsx)("li", {
children:
"如所上传素材可能涉及任何他人肖像/声音/生物识别特征、或商标/版权内容等知识产权元素,请务必确保您已获得充分授权,未侵害任何第三方合法权益。",
}),
],
}),
],
}),
(0, r.jsxs)("div", {
className: "space-y-2",
children: [
(0, r.jsx)("p", {
className: "text-fg-default font-medium",
children: "2. 您将自行对所生成内容及使用后果负责",
}),
(0, r.jsx)("ul", {
className:
"text-fg-muted list-disc space-y-1 pl-5 text-[13px]",
children: (0, r.jsx)("li", {
children:
"您充分理解AI生成结果具有不确定性,是否对生成内容进行发布、传播、或商业使用,均由您自行判断并承担相应法律责任。",
}),
}),
],
}),
(0, r.jsxs)("div", {
className: "space-y-2",
children: [
(0, r.jsx)("p", {
className: "text-fg-default font-medium",
children:
"3. 如您存在违规使用行为,平台将有权采取限制措施",
}),
(0, r.jsx)("ul", {
className:
"text-fg-muted list-disc space-y-1 pl-5 text-[13px]",
children: (0, r.jsx)("li", {
children:
"一切对包含第三方合法权益素材的滥用,均将视为违规行为。平台将可能采取包括但不限于拦截生成、删除内容、限制下载、暂停或终止服务等措施。如因此给平台或第三方造成损失,您需自行承担赔偿责任。",
}),
}),
],
}),
],
}),
(0, r.jsxs)("div", {
className: "bg-bg-surface shrink-0 space-y-4 px-6 pb-4 pt-4",
children: [
(0, r.jsxs)("button", {
type: "button",
className:
"flex w-full cursor-pointer items-start gap-3 text-left",
onClick: () => p((e) => !e),
children: [
(0, r.jsx)("div", {
className: (0, o.cn)(
"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded border",
u
? "border-btn-primary bg-btn-primary"
: "border-border-emphasis bg-transparent",
),
children:
u &&
(0, r.jsx)(l.Icons.Check, {
className: "text-btn-primary-text size-3",
}),
}),
(0, r.jsx)("span", {
className: "text-fg-default text-[13px] leading-normal",
children:
"我已阅读并同意上述《Seedance2.0模型使用承诺书》",
}),
],
}),
(0, r.jsxs)("div", {
className: "flex items-center justify-end gap-3",
children: [
(0, r.jsx)("button", {
type: "button",
className:
"hover:bg-btn-ghost-hover text-fg-default h-8 rounded-lg px-3 text-[13px] transition-colors",
onClick: g,
children: "不同意",
}),
(0, r.jsx)("button", {
type: "button",
className: (0, o.cn)(
"h-8 rounded-lg px-3 text-[13px] transition-colors",
u
? "bg-btn-primary hover:bg-btn-primary-hover active:bg-btn-primary-active text-btn-primary-text"
: "bg-btn-primary/40 text-btn-primary-text/40 cursor-not-allowed",
),
disabled: !u || f,
onClick: () => void m(),
children: f ? "签署中..." : "同意并使用",
}),
],
}),
],
}),
],
}),
});
});
e.s(["SeedanceAgreementModal", 0, d], 433839);
var c = e.i(722573),
u = e.i(295085);
function p(e) {
return (0, o.cn)(
"absolute right-1.5 top-1.5 z-10 flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors",
e
? "border border-black/15 bg-white/95 text-neutral-800 shadow-sm hover:bg-white hover:text-neutral-950"
: "border-none bg-black/50 text-white/70 hover:bg-black/70 hover:text-white",
);
}
function f({
title: e,
cover: t,
className: i,
overlayClassName: a,
canvasLight: l = !1,
topRightAction: n,
actions: s = [],
onClick: d,
}) {
let c = s.length > 0 || !!n;
return (0, r.jsxs)("div", {
className: (0, o.cn)(
"group flex flex-col gap-1",
d ? "cursor-pointer" : "",
i,
),
onClick: d,
children: [
(0, r.jsxs)("div", {
className:
"relative aspect-square w-full overflow-hidden rounded-lg",
children: [
(0, r.jsx)("div", {
className:
"size-full transition-transform duration-200 group-hover:scale-105",
children: t,
}),
c &&
(0, r.jsxs)("div", {
className: (0, o.cn)(
"absolute inset-0 flex items-center justify-center rounded-lg bg-black/65 opacity-0 transition-opacity duration-150 group-hover:opacity-100",
a,
),
children: [
n,
s.length > 0 &&
(0, r.jsx)("div", {
className: "flex items-center gap-1",
children: s.map((e) =>
(0, r.jsx)(
"button",
{
type: "button",
onClick: (t) => {
t.stopPropagation(), e.onClick();
},
className:
"flex h-6 cursor-pointer items-center justify-center rounded-lg border-none bg-transparent px-2 text-[13px] text-white/90 transition-colors hover:bg-white/10 hover:text-white",
children: e.label,
},
e.label,
),
),
}),
],
}),
],
}),
(0, r.jsx)("p", {
className: (0, o.cn)(
"w-full truncate px-1 text-xs",
l ? "text-fg-muted" : "text-white/50",
),
children: e,
}),
],
});
}
function x({
subject: e,
className: t,
overlayClassName: a,
canvasLight: l = !1,
topRightAction: n,
actions: s = [],
disabled: o = !1,
disabledReason: d,
}) {
let [p, x] = (0, i.useState)(!1),
m = e.coverUrl || e.images?.[0]?.url,
g = m && !p,
h = (0, u.isVideoUrl)(m),
b = o
? s
.filter((e) => "使用" !== e.label)
.map((t) => ({ label: t.label, onClick: () => t.onClick(e) }))
: s.map((t) => ({ label: t.label, onClick: () => t.onClick(e) })),
v = (0, r.jsx)(f, {
title: e.name,
className: o ? "opacity-50" : t,
overlayClassName: a,
canvasLight: l,
topRightAction: n,
actions: b,
cover: g
? h
? (0, r.jsx)("video", {
src: m,
muted: !0,
autoPlay: !0,
loop: !0,
playsInline: !0,
className:
"absolute inset-0 size-full rounded-lg object-cover",
onError: () => x(!0),
})
: (0, r.jsx)("img", {
src: (0, u.getFasterImage)(m, { width: 140 }),
alt: e.name,
className:
"absolute inset-0 size-full rounded-lg object-cover",
onError: () => x(!0),
})
: (0, r.jsx)("div", {
className:
"flex size-full items-center justify-center bg-white/5 text-xs text-white/30",
children: "无封面",
}),
});
return o && d
? (0, r.jsx)(c.Tooltip, {
label: d,
position: "top",
withArrow: !0,
multiline: !0,
maw: 220,
children: (0, r.jsx)("div", { children: v }),
})
: v;
}
e.s(
["LibraryCard", () => f, "libraryCardTrashButtonClassName", () => p],
711337,
),
e.s(["SubjectLibraryCard", () => x], 464346);
var m = e.i(635287),
g = e.i(197895),
h = e.i(299750),
b = e.i(383924),
v = e.i(185990),
y = e.i(562530);
class j {
entityUuid;
name;
description;
coverUrl;
images;
videos;
audios;
type;
createdAtMs;
updatedAtMs;
specialSupportIdMap;
constructor(e) {
(this.entityUuid = e.entityUuid),
(this.name = e.name),
(this.description = e.description),
(this.coverUrl = e.coverUrl),
(this.images = e.images),
(this.videos = e.videos),
(this.audios = e.audios),
(this.type = e.type),
(this.createdAtMs = e.createdAtMs),
(this.updatedAtMs = e.updatedAtMs),
(this.specialSupportIdMap = e.specialSupportIdMap);
}
get uuid() {
return this.entityUuid;
}
get referenceImages() {
if (this.images && 0 !== this.images.length)
return this.images.map((e) => e.url);
}
}
function w(e) {
return new j(e);
}
let N = (e) => b.apiClient.post(v.default.entityLibraryCreate, e),
k = (e) => b.apiClient.post(v.default.entityLibraryUpdate, e),
C = (e) =>
b.apiClient.get(v.default.entityLibraryProgress, {
params: { taskId: e.taskId },
}),
S = (e = {}) => b.apiClient.post(v.default.entityLibraryList, e);
async function U(e) {
for (let t = 0; t < 90; t++) {
await new Promise((e) => setTimeout(e, 2e3));
let t = await (0, h.getGenerationProgress)([e]),
r = t?.data?.progresses?.[0];
if (r) {
if (2 === r.status && r.taskResult) return r.taskResult;
if (3 === r.status) throw Error(r.failedReason ?? "任务失败");
}
}
throw Error("任务超时");
}
let E = "qwen-3-vl-flash";
async function I(e) {
let t = [...e.imageUrls],
r = await (0, y.submitGenerationTask)({
params: {
count: 1,
model: E,
imageList: t,
scene: "character_description",
},
metadata: { node_id: "", project_id: "" },
provider: "qwen",
model: E,
taskType: "text",
requestId: (0, g.v4)(),
});
if (!r.success) throw Error(r.errorMsg ?? "创建任务失败");
let i = JSON.parse(await U(r.taskId));
return {
description:
Array.isArray(i.texts) && i.texts.length > 0
? i.texts
.map((e) => ("string" == typeof e ? e.trim() : ""))
.filter(Boolean)
.join("\n")
: "",
};
}
async function A(e) {
let t = await (0, y.submitGenerationTask)({
params: { imageList: [e] },
metadata: { node_id: "", project_id: "" },
provider: "kling",
model: "kling-multi-shot",
taskType: "image",
requestId: (0, g.v4)(),
});
if (!t.success) throw Error(t.errorMsg ?? "创建任务失败");
let r = JSON.parse(await U(t.taskId));
if (Array.isArray(r.batches) && r.batches.length > 0)
return { batches: r.batches };
if (Array.isArray(r.images) && r.images.length > 0) {
let e = r.images
.map((e, t) => {
let r = e.previewPath ?? e.url;
return r ? { url: r, label: `视角 ${t + 1}` } : null;
})
.filter((e) => null !== e);
return e.length > 0 ? { batches: [{ images: e }] } : { batches: [] };
}
return { batches: [] };
}
function F({
enabled: e,
type: t = null,
name: r,
onlyImage: a,
pageSize: l = 20,
}) {
let [n, s] = (0, i.useState)([]),
[o, d] = (0, i.useState)(0),
[c, u] = (0, i.useState)(1),
[p, f] = (0, i.useState)(!1),
[x, g] = (0, i.useState)(!1),
[h, b] = (0, i.useState)(!1),
[v, y] = (0, i.useState)(!1),
j = (0, i.useRef)(!1),
N = !v && n.length < o,
k = (0, i.useCallback)(
async (e, t, r) => {
if (!j.current) {
(j.current = !0), 1 === e ? f(!0) : g(!0), b(!1);
try {
let i = await S({
page: e,
pageSize: l,
type: t ?? void 0,
name: r,
onlyImage: a,
}),
n = (0, m.getApiData)(i);
if ((0, m.isApiOk)(i) && n?.entityList) {
let t = n.entityList.map(w);
1 === e ? s(t) : s((e) => [...e, ...t]),
d(n.total ?? 0),
u(e),
t.length < l && y(!0);
} else 1 === e && b(!0);
} catch (t) {
console.warn("[useSubjectList] fetch failed:", t),
1 === e && b(!0);
} finally {
f(!1), g(!1), (j.current = !1);
}
}
},
[a, l],
),
C = (0, i.useCallback)(
(e, t) => {
s([]), d(0), u(1), y(!1), k(1, e, t);
},
[k],
);
(0, i.useEffect)(() => {
e && C(t ?? null, r);
}, [e, t, r]);
let U = (0, i.useCallback)(() => {
N && !j.current && k(c + 1, t ?? null, r);
}, [N, c, k, t, r]);
return {
subjects: n,
total: o,
isLoading: p,
isLoadingMore: x,
loadError: h,
hasMore: N,
loadMore: U,
retry: (0, i.useCallback)(() => {
k(1, t ?? null, r);
}, [k, t, r]),
reset: (0, i.useCallback)(() => {
C(t ?? null, r);
}, [C, t, r]),
setSubjects: s,
setTotal: d,
};
}
e.s(
[
"createSubject",
0,
N,
"delSubject",
0,
(e) => b.apiClient.post(v.default.entityLibraryDelete, e),
"generateSmartCompletion",
() => A,
"generateSubjectDescription",
() => I,
"listSubjects",
0,
S,
"querySubjectProgress",
0,
C,
"toSubjectMeta",
() => w,
"updateSubject",
0,
k,
],
738638,
),
e.s(["useSubjectList", () => F], 199268);
var P = e.i(524961),
T = e.i(610582),
z = e.i(262834),
D = e.i(763910),
L = e.i(505e3);
((t = {})[(t.PENDING = 0)] = "PENDING"),
(t[(t.APPROVED = 1)] = "APPROVED"),
(t[(t.REJECTED = 2)] = "REJECTED"),
(t[(t.FAILED = 3)] = "FAILED"),
(t[(t.PENDING_TIMEOUT = 4)] = "PENDING_TIMEOUT");
let M = (e) =>
b.apiClient.get(v.default.klingCustomVoiceDetail, {
params: { id: e.id },
});
var O = e.i(791997);
e.i(135623);
var R = e.i(168823);
e.i(954175);
var _ = e.i(616803),
K = e.i(301710),
$ = e.i(89472),
B = e.i(174008);
function V({ width: e = 14, height: t = 14 }) {
return (0, r.jsxs)("svg", {
width: e,
height: t,
viewBox: "0 0 12 12",
fill: "none",
"aria-hidden": "true",
children: [
(0, r.jsxs)("line", {
x1: "2",
y1: "7",
x2: "2",
y2: "5",
stroke: "currentColor",
strokeLinecap: "round",
children: [
(0, r.jsx)("animate", {
attributeName: "y1",
values: "7;8.3;6.6;8.7;7.4;7",
dur: "0.9s",
begin: "0s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
(0, r.jsx)("animate", {
attributeName: "y2",
values: "5;3.8;5.6;3.4;4.6;5",
dur: "0.9s",
begin: "0s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
],
}),
(0, r.jsxs)("line", {
x1: "4",
y1: "8",
x2: "4",
y2: "4",
stroke: "currentColor",
strokeLinecap: "round",
children: [
(0, r.jsx)("animate", {
attributeName: "y1",
values: "8;9.4;7.2;9.1;8.1;8",
dur: "0.9s",
begin: "0.1s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
(0, r.jsx)("animate", {
attributeName: "y2",
values: "4;2.1;4.9;2.7;3.6;4",
dur: "0.9s",
begin: "0.1s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
],
}),
(0, r.jsxs)("line", {
x1: "6",
y1: "11",
x2: "6",
y2: "1",
stroke: "currentColor",
strokeLinecap: "round",
children: [
(0, r.jsx)("animate", {
attributeName: "y1",
values: "11;10.2;9.2;10.5;9.8;11",
dur: "0.9s",
begin: "0.2s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
(0, r.jsx)("animate", {
attributeName: "y2",
values: "1;1.9;2.8;1.5;2.2;1",
dur: "0.9s",
begin: "0.2s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
],
}),
(0, r.jsxs)("line", {
x1: "8",
y1: "9",
x2: "8",
y2: "3",
stroke: "currentColor",
strokeLinecap: "round",
children: [
(0, r.jsx)("animate", {
attributeName: "y1",
values: "9;10.1;8.6;9.7;8.8;9",
dur: "0.9s",
begin: "0.3s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
(0, r.jsx)("animate", {
attributeName: "y2",
values: "3;1.4;3.7;2.1;3;3",
dur: "0.9s",
begin: "0.3s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
],
}),
(0, r.jsxs)("line", {
x1: "10",
y1: "8",
x2: "10",
y2: "4",
stroke: "currentColor",
strokeLinecap: "round",
children: [
(0, r.jsx)("animate", {
attributeName: "y1",
values: "8;8.9;7.1;9.2;8.3;8",
dur: "0.9s",
begin: "0.4s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
(0, r.jsx)("animate", {
attributeName: "y2",
values: "4;3.2;5.2;2.7;3.8;4",
dur: "0.9s",
begin: "0.4s",
repeatCount: "indefinite",
calcMode: "spline",
keySplines:
"0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1;0.42 0 0.58 1",
}),
],
}),
],
});
}
var W = e.i(33725);
function q({
open: e,
onCancel: t,
onConfirm: a,
title: n,
description: s,
overlayZIndex: d = 650,
dialogZIndex: c = 660,
}) {
let u = (0, i.useId)(),
p = (0, i.useId)(),
f = (0, O.useCanvasThemeStore)((e) => "light" === e.theme);
return e
? (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsx)("div", {
className: "fixed inset-0 bg-black/45",
style: { zIndex: d },
onClick: t,
role: "presentation",
}),
(0, r.jsx)("div", {
className:
"pointer-events-none fixed inset-0 flex items-center justify-center p-4",
style: { zIndex: c },
children: (0, r.jsxs)("div", {
role: "alertdialog",
"aria-modal": !0,
"aria-labelledby": u,
"aria-describedby": p,
className: (0, o.cn)(
"pointer-events-auto flex w-[300px] flex-col gap-4 rounded-xl border p-4",
f
? "border-[var(--canvas-controls-border)] bg-[var(--canvas-controls-bg)] shadow-[0px_4px_8px_rgba(0,0,0,0.12)]"
: "border-[#363636] bg-[#262626] shadow-[0px_4px_8px_rgba(0,0,0,0.25)]",
),
onClick: (e) => e.stopPropagation(),
children: [
(0, r.jsxs)("div", {
className: "flex items-start gap-2",
children: [
(0, r.jsx)(l.Icons.WarnF, {
width: 16,
height: 16,
className: "mt-0.5 shrink-0 text-[#cb272d]",
}),
(0, r.jsx)("div", {
id: u,
className: (0, o.cn)(
"text-xs font-semibold leading-normal",
f
? "text-fg-default"
: "text-[var(--canvas-controls-text)]",
),
children: n,
}),
],
}),
(0, r.jsx)("div", {
id: p,
className: (0, o.cn)(
"flex flex-col gap-1 text-xs leading-[1.6]",
f ? "text-fg-subtle" : "[color:rgba(255,255,255,0.72)]",
),
children: s,
}),
(0, r.jsxs)("div", {
className: "flex w-full items-center justify-end gap-2",
children: [
(0, r.jsx)("button", {
type: "button",
onClick: t,
className: (0, o.cn)(
"flex h-7 cursor-pointer items-center justify-center rounded-lg px-3 text-[13px] transition-colors",
f
? "bg-black/6 text-fg-default hover:bg-black/10"
: "bg-white/[0.08] text-[var(--canvas-controls-text)] hover:bg-white/[0.12]",
),
children: "取消",
}),
(0, r.jsx)("button", {
type: "button",
onClick: a,
className:
"flex h-7 cursor-pointer items-center justify-center rounded-lg bg-[#cb272d] px-3 text-[13px] text-white transition-colors hover:bg-[#b52228]",
children: "确定",
}),
],
}),
],
}),
}),
],
})
: null;
}
function Y({
referenceImageUrl: e,
smartCompletion: t,
onConfirm: a,
completionPowerDisplay: s,
exitConfirmTitle: o,
exitConfirmDescription: d,
}) {
let { setShowModal: c, showModal: p, status: f, result: x } = t,
m = x?.batches ?? [],
[g, h] = (0, i.useState)(new Set()),
[b, v] = (0, i.useState)(!1),
y = (0, i.useRef)(x);
y.current !== x && ((y.current = x), h(new Set()));
let j = (0, i.useCallback)((e) => {
h((t) => {
let r = new Set(t);
if (r.has(e)) r.delete(e);
else {
if (r.size >= 3) return n.Notify.info(`最多选择 3 张补充视角`), t;
r.add(e);
}
return r;
});
}, []),
w = (0, i.useCallback)(() => {
if (0 === g.size) return;
let e = [];
for (let t of g) {
let [r, i] = t.split("-").map(Number),
a = m[r]?.images[i];
a && e.push(a.url);
}
a(e);
}, [g, m, a]),
N = (0, i.useCallback)(() => {
v(!0);
}, []),
k = (0, i.useCallback)(() => {
v(!1);
}, []),
C = (0, i.useCallback)(() => {
v(!1), c(!1);
}, [c]);
return ((0, i.useEffect)(() => {
p || v(!1);
}, [p]),
p)
? (0, r.jsxs)(T.Portal, {
children: [
(0, r.jsx)("div", {
className: "fixed inset-0",
style: {
zIndex: "calc(var(--z-overlay) + 30)",
backgroundColor: "rgba(0, 0, 0, 0.35)",
},
onClick: b ? void 0 : N,
role: "presentation",
}),
(0, r.jsx)("div", {
className:
"pointer-events-none fixed inset-0 flex items-center justify-center",
style: { zIndex: "calc(var(--z-overlay) + 31)" },
children: (0, r.jsx)("div", {
role: "dialog",
"aria-modal": !0,
onClick: (e) => e.stopPropagation(),
onKeyDown: void 0,
children: (0, r.jsxs)(z.default, {
className: "pointer-events-auto flex w-[604px] flex-col",
style: {
borderRadius: 12,
backgroundColor: "var(--canvas-controls-bg)",
backdropFilter: "blur(12px)",
border: "0.5px solid var(--canvas-controls-border)",
boxShadow: "0px 4px 8px rgba(0, 0, 0, 0.12)",
},
children: [
(0, r.jsxs)("div", {
className:
"flex shrink-0 items-center justify-between border-b px-4 pb-3 pt-3 [border-color:var(--canvas-controls-border)]",
children: [
(0, r.jsxs)("div", {
className: "flex items-center gap-2",
children: [
(0, r.jsx)("button", {
type: "button",
onClick: N,
className:
"flex size-5 items-center justify-center rounded-lg text-[var(--canvas-controls-icon)] transition-colors hover:bg-[var(--canvas-controls-hover)] hover:text-white",
children: (0, r.jsx)(l.Icons.Left, {
width: 14,
height: 14,
}),
}),
(0, r.jsx)("span", {
className:
"text-[13px] font-semibold text-[var(--canvas-controls-text)]",
children: "AI智能补全其他视角",
}),
],
}),
(0, r.jsx)("button", {
type: "button",
onClick: N,
className:
"flex size-6 items-center justify-center rounded-lg text-[var(--canvas-controls-icon)] transition-colors hover:bg-[var(--canvas-controls-hover)] hover:text-white",
children: (0, r.jsx)(l.Icons.x, {
width: 14,
height: 14,
}),
}),
],
}),
(0, r.jsxs)("div", {
className:
"flex max-h-[520px] min-h-0 min-w-0 gap-4 overflow-hidden p-4",
children: [
(0, r.jsxs)("div", {
className: "flex shrink-0 flex-col gap-2",
children: [
(0, r.jsx)("span", {
className:
"w-full text-center text-xs text-white/50",
children: "主参考图",
}),
(0, r.jsx)("div", {
className:
"h-[184px] w-[138px] overflow-hidden rounded-lg border [border-color:var(--canvas-controls-border)]",
children: (0, r.jsx)("img", {
src: (0, u.getFasterImage)(e, { width: 276 }),
alt: "主参考图",
className: "size-full object-cover",
}),
}),
],
}),
(0, r.jsxs)("div", {
className:
"flex min-h-0 min-w-0 flex-1 flex-col gap-1 overflow-hidden",
children: [
(0, r.jsx)("span", {
className:
"block w-full shrink-0 text-center text-xs leading-normal text-white/50",
children: "选择1-3张最满意的补充视角",
}),
(0, r.jsx)("div", {
className:
"tiny-scrollbar flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",
onWheel: (e) => e.stopPropagation(),
children:
0 === m.length
? (0, r.jsx)("div", {
className:
"rounded-lg border border-dashed border-white/15 px-4 py-8 text-center text-xs text-white/50",
children:
"未获取到生成图片,请点击「重新生成」重试",
})
: m.map((e, t) => {
let i = `batch-${t}-${e.images.map((e) => e.url).join(",")}`;
return (0, r.jsx)(
"div",
{
className:
"border-white/8 grid grid-cols-3 gap-2 rounded-lg border bg-black/20 p-2",
children: e.images.map((e, i) => {
let a = `${t}-${i}`,
n = g.has(a);
return (0, r.jsxs)(
"div",
{
role: "button",
tabIndex: 0,
onClick: () => j(a),
onKeyDown: (e) => {
("Enter" === e.key ||
" " === e.key) &&
(e.preventDefault(),
j(a));
},
className:
"relative flex min-w-0 cursor-pointer flex-col overflow-hidden rounded-md",
children: [
(0, r.jsx)("div", {
className:
"aspect-3/4 overflow-hidden rounded-md border [border-color:var(--canvas-controls-border)]",
children: (0, r.jsx)(
"img",
{
src: (0,
u.getFasterImage)(
e.url,
{ width: 252 },
),
alt: e.label,
className:
"size-full object-cover",
},
),
}),
(0, r.jsx)("div", {
className:
"absolute right-1.5 top-1.5",
children: (0, r.jsx)(
"div",
{
className: `flex size-4 items-center justify-center rounded border ${n ? "border-white/40 bg-black/70" : "border-white/25 bg-black/65"}`,
children:
n &&
(0, r.jsx)(
l.Icons.check,
{
width: 10,
height: 10,
className:
"text-white",
},
),
},
),
}),
],
},
a,
);
}),
},
i,
);
}),
}),
],
}),
],
}),
(0, r.jsxs)("div", {
className:
"flex shrink-0 items-center justify-end gap-2 border-t px-4 pb-4 pt-4 [border-color:var(--canvas-controls-border)]",
children: [
(0, r.jsx)("button", {
type: "button",
disabled: "generating" === f,
onClick: () => void t.trigger(e),
className:
"flex h-7 cursor-pointer items-center gap-1 rounded-lg bg-white/[0.08] px-3 text-[13px] text-[var(--canvas-controls-text)] transition-colors hover:bg-white/[0.12] disabled:cursor-not-allowed disabled:opacity-50",
children:
"generating" === f
? (0, r.jsxs)("span", {
className: "flex items-center gap-1",
children: [
(0, r.jsx)(l.Icons.Loading, {
width: 14,
height: 14,
className: "animate-spin text-white/45",
}),
(0, r.jsx)("span", {
className: "text-white/45",
children: "重新生成中",
}),
],
})
: (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsxs)("span", {
className:
"flex items-center gap-[2px]",
children: [
(0, r.jsx)(l.Icons.LightningF, {
width: 9,
height: 12,
className: "text-white/35",
}),
(0, r.jsx)("span", {
className: "text-xs text-white/35",
children: s,
}),
],
}),
(0, r.jsx)("span", {
children: "重新生成",
}),
],
}),
}),
(0, r.jsx)(P.Button, {
size: "xs",
radius: 8,
disabled: 0 === g.size,
onClick: w,
styles: {
root: {
height: 28,
minHeight: 28,
paddingInline: 12,
fontSize: 13,
backgroundColor:
g.size > 0 ? "#1f6dff" : void 0,
},
},
children: "确定",
}),
],
}),
],
}),
}),
}),
(0, r.jsx)(q, {
open: b,
onCancel: k,
onConfirm: C,
title: o,
description: d("generating" === f),
}),
],
})
: null;
}
let G = [
{ label: "全部", value: null },
{ label: "人物", value: m.AssetType.PERSON },
{ label: "场景", value: m.AssetType.SCENE },
{ label: "道具", value: m.AssetType.ITEM },
{ label: "特效", value: m.AssetType.STYLE },
{ label: "其它", value: m.AssetType.OTHER },
];
e.s(["SUBJECT_TAG_TABS", 0, G], 231270);
let J = "确定要退出?";
function H(e) {
return e
? (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsx)("p", { children: "关闭将不会保存任何更改。" }),
(0, r.jsx)("p", {
children: "智能补全任务不会取消,积分不返还。",
}),
(0, r.jsx)("p", { children: "任务完成后将展示在历史记录。" }),
],
})
: "关闭将不会保存任何更改。";
}
let X = "calc(var(--z-overlay) + 14)",
Z = "calc(var(--z-overlay) + 15)",
Q = { id: "none", name: "无配音" },
ee = ["audio", "video"];
async function et(e) {
let t = e.videoWidth || e.clientWidth,
r = e.videoHeight || e.clientHeight;
if (t < 2 || r < 2) return null;
let i = document.createElement("canvas");
(i.width = t), (i.height = r);
let a = i.getContext("2d");
if (!a) return null;
try {
a.drawImage(e, 0, 0, t, r);
} catch {
return null;
}
let l = await new Promise((e) => i.toBlob(e, "image/png"));
if (!l) return null;
let n = (0, R.getCookie)(L.USER_TOKEN_COOKIE_KEY),
s = (0, R.getCookie)(L.USER_UUID_COOKIE_KEY);
if (!n || "string" != typeof n || !s || "string" != typeof s) return null;
let o = new File([l], `subject-video-frame-${Date.now()}.png`, {
type: "image/png",
});
try {
let e = await (0, K.uploadViaPreSign)(o, {
token: n,
uuid: s,
verify: !0,
});
return e.url ?? (0, K.resolveUploadUrl)(e) ?? null;
} catch {
return null;
}
}
async function er(e) {
let t = URL.createObjectURL(e);
try {
if (
/\.(mp4|mov)$/i.test(e.name) ||
e.type.startsWith("video/") ||
"video/quicktime" === e.type
) {
let e = document.createElement("video");
return (
(e.preload = "metadata"),
await new Promise((r) => {
(e.onloadedmetadata = () => {
r(Number.isFinite(e.duration) ? e.duration : 0);
}),
(e.onerror = () => r(0)),
(e.src = t);
})
);
}
return await new Promise((e) => {
let r = new Audio();
(r.preload = "metadata"),
(r.onloadedmetadata = () => {
e(Number.isFinite(r.duration) ? r.duration : 0);
}),
(r.onerror = () => e(0)),
(r.src = t);
});
} finally {
URL.revokeObjectURL(t);
}
}
function ei(e, t) {
return new Promise((r) => {
let i,
a = null,
l = null,
n = () => {
void 0 !== i && (clearTimeout(i), (i = void 0)),
a && (a.removeAttribute("src"), a.load(), (a = null)),
l && (l.removeAttribute("src"), l.load(), (l = null));
};
(i = setTimeout(() => {
n(), r(0);
}, 15e3)),
"video" === t
? (((a = document.createElement("video")).preload = "metadata"),
/^https?:\/\//i.test(e) && (a.crossOrigin = "anonymous"),
(a.onloadedmetadata = () => {
let e =
a && Number.isFinite(a.duration) && a.duration > 0
? a.duration
: 0;
n(), r(e);
}),
(a.onerror = () => {
n(), r(0);
}),
(a.src = e))
: (((l = new Audio()).preload = "metadata"),
(l.onloadedmetadata = () => {
let e =
l && Number.isFinite(l.duration) && l.duration > 0
? l.duration
: 0;
n(), r(e);
}),
(l.onerror = () => {
n(), r(0);
}),
(l.src = e));
});
}
function ea(e) {
return e <= 0
? "无法读取视频时长,请更换素材或重新上传"
: e < 3 || e > 8
? `请上传时长在 3~8 秒之间的视频`
: null;
}
function el(e) {
return e <= 0
? "无法读取音频或视频时长,请更换素材或重新上传"
: e < 5 || e > 30
? `音频时长需在 5~30 秒之间`
: null;
}
function en(e) {
let t = e.raw;
return "video" === e.mediaType
? t.videoUrl ||
t.originalVideoUrl ||
t.previewPath ||
e.thumbnailUrl ||
""
: "audio" === e.mediaType
? t.audioUrl || t.previewPath || e.thumbnailUrl || ""
: "libtv" === e.source
? t.previewPath || e.thumbnailUrl || ""
: t.originalImageUrl ||
t.originImageUrl ||
e.thumbnailUrl ||
t.imageUrl ||
t.url ||
"";
}
function es({
value: e,
onChange: t,
options: a,
placeholder: n,
renderIcon: s,
footerAction: d,
onOpenChange: c,
}) {
let u = (0, O.useCanvasThemeStore)((e) => e.theme),
p = "light" === u,
[f, x] = (0, i.useState)(!1),
m = (0, i.useCallback)(
(e) => {
x(e), c?.(e);
},
[c],
),
g = (0, i.useRef)(null),
h = (0, i.useRef)(null),
[b, v] = (0, i.useState)({});
(0, i.useEffect)(() => {
if (!f) return;
let e = (e) => {
let t = e.target;
g.current?.contains(t) || h.current?.contains(t) || m(!1);
};
return (
document.addEventListener("mousedown", e),
() => document.removeEventListener("mousedown", e)
);
}, [f, m]);
let y = (0, i.useCallback)(() => {
x((e) => {
let t = !e;
if (t && g.current) {
let e = g.current.getBoundingClientRect();
v({
position: "fixed",
top: e.bottom + 4,
left: e.left,
width: e.width,
zIndex: "calc(var(--z-overlay) + 16)",
});
}
return c?.(t), t;
});
}, [c]),
j = a.find((t) => t.id === e),
w = j?.name ?? n ?? a[0]?.name ?? "",
N = !j || "none" === e;
return (0, r.jsxs)("div", {
children: [
(0, r.jsxs)("button", {
ref: g,
type: "button",
onClick: y,
className: (0, o.cn)(
"flex h-8 w-full items-center justify-between rounded-lg border bg-transparent px-3 text-left outline-none transition-colors",
p
? "border-border-default hover:border-border-emphasis"
: "border-border-muted hover:border-white/25",
),
children: [
(0, r.jsx)("span", {
className: (0, o.cn)(
"flex min-w-0 flex-1 items-center gap-1.5 text-[13px]",
N && n
? p
? "text-fg-disabled"
: "text-white/30"
: p
? "text-fg-default"
: "text-[#F7F7F7]",
),
children:
N && n
? n
: (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsx)("span", {
className: "truncate",
children: w,
}),
j?.official
? (0, r.jsx)("span", {
className: (0, o.cn)(
"shrink-0 rounded px-2 py-1 text-[12px] leading-none",
p
? "text-fg-muted bg-black/6"
: "bg-white/10 text-[#F7F7F7]",
),
children: "官方",
})
: null,
],
}),
}),
(0, r.jsx)(l.Icons.lucideChevronDown, {
width: 16,
height: 16,
className: `text-fg-subtle transition-transform ${f ? "rotate-180" : ""}`,
}),
],
}),
f &&
(0, r.jsx)(T.Portal, {
children: (0, r.jsxs)("div", {
ref: h,
style: { ...b, backgroundColor: "var(--canvas-controls-bg)" },
className: `border-canvas-controls-border flex max-h-[300px] flex-col overflow-hidden rounded-xl border py-1 shadow-lg ${"light" === u ? "canvas-light" : ""}`,
children: [
(0, r.jsx)("div", {
className:
"tiny-scrollbar min-h-0 flex-1 overflow-y-auto px-[1px]",
children: a.map((i) => {
let a = e === i.id;
return (0, r.jsxs)(
"div",
{
role: "button",
tabIndex: 0,
onClick: () => {
t(i.id), m(!1);
},
onKeyDown: (e) => {
("Enter" === e.key || " " === e.key) &&
(e.preventDefault(), t(i.id), m(!1));
},
className:
"hover:bg-canvas-controls-hover flex h-10 w-full cursor-pointer items-center gap-2 rounded-lg border-none bg-transparent px-2 text-left transition-colors",
children: [
s &&
(0, r.jsx)("div", {
className:
"bg-panel-background flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-full",
children: s(i),
}),
(0, r.jsxs)("span", {
className:
"flex min-w-0 flex-1 items-center gap-2",
children: [
(0, r.jsx)("span", {
className: (0, o.cn)(
"truncate text-[13px]",
p ? "text-fg-default" : "text-white/90",
),
children: i.name,
}),
i.official
? (0, r.jsx)("span", {
className: (0, o.cn)(
"shrink-0 rounded px-2 py-1 text-[12px] leading-none",
p
? "text-fg-muted bg-black/6"
: "bg-white/10 text-[#F7F7F7]",
),
children: "官方",
})
: null,
],
}),
a &&
(0, r.jsx)(l.Icons.check, {
width: 14,
height: 14,
className: (0, o.cn)(
"shrink-0",
p ? "text-fg-muted" : "text-white/60",
),
}),
],
},
i.id,
);
}),
}),
d &&
(0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsx)("div", {
className: (0, o.cn)(
"mx-2 my-1 border-t",
p ? "border-border-default" : "border-border-muted",
),
}),
d,
],
}),
],
}),
}),
],
});
}
async function eo(e, t) {
for (let r = 0; r < 150; r++) {
if (t?.cancelled) throw Error("cancelled");
let r = await C({ taskId: e }),
i = (0, m.getApiData)(r);
if (!(0, m.isApiOk)(r) || !i) throw Error("查询进度失败");
let a = i.taskStatus;
if ("succeed" === a || "success" === a) return i;
if ("failed" === a) {
let e =
"string" == typeof i.taskStatusMsg && i.taskStatusMsg.trim()
? i.taskStatusMsg.trim()
: null,
t = Error("subject-progress-failed");
throw (
((t.taskStatusFooter = !0), (t.subjectProgressBackendDetail = e), t)
);
}
await new Promise((e) => setTimeout(e, 2e3));
}
throw Error("主体创建超时");
}
async function ed(e, t) {
for (let r = 0; r < 60; r++) {
if (t?.cancelled) throw Error("cancelled");
let r = await M({ id: e }),
i = (0, m.getApiData)(r);
if (!(0, m.isApiOk)(r) || !i) throw Error("查询音色状态失败");
if ("succeed" === i.taskStatus || "success" === i.taskStatus) {
if (i.voiceId) return i.voiceId;
throw Error("音色创建成功但未返回 voiceId");
}
if ("failed" === i.taskStatus) {
let e =
"string" == typeof i.taskStatusMsg && i.taskStatusMsg.trim()
? i.taskStatusMsg.trim()
: null,
t = Error("voice-audit-failed");
throw ((t.voiceAuditFooter = !0), (t.voiceAuditBackendDetail = e), t);
}
await new Promise((e) => setTimeout(e, 2e3));
}
throw Error("音色创建超时");
}
function ec({
opened: e,
onClose: t,
editSubject: a,
readOnly: s = !1,
initialMedia: d,
onSuccess: c,
}) {
let p = "light" === (0, O.useCanvasThemeStore)((e) => e.theme),
f = !!a,
[x, g] = (0, i.useState)(null),
[h, y] = (0, i.useState)([]),
[j, C] = (0, i.useState)(null),
[S, U] = (0, i.useState)(!1),
[E, F] = (0, i.useState)(""),
[M, ec] = (0, i.useState)(null),
[eu, ep] = (0, i.useState)(""),
[ef, ex] = (0, i.useState)(""),
[em, eg] = (0, i.useState)("none"),
[eh, eb] = (0, i.useState)([]),
[ev, ey] = (0, i.useState)([]),
[ej, ew] = (0, i.useState)("none"),
[eN, ek] = (0, i.useState)(!1),
[eC, eS] = (0, i.useState)(null),
[eU, eE] = (0, i.useState)(!1),
eI = (0, i.useRef)(!1),
[eA, eF] = (0, i.useState)(null),
eP = (0, i.useRef)(null),
eT = (0, i.useRef)(null),
ez = (0, i.useRef)({ cancelled: !1 }),
eD = (function () {
let [e, t] = (0, i.useState)("idle"),
[r, a] = (0, i.useState)(null),
[l, s] = (0, i.useState)(!1),
o = (0, i.useRef)(0),
d = (0, i.useCallback)(
async (r, i) => {
if ((i?.stopPropagation(), !r))
return void n.Notify.error("请先上传至少一张参考图片");
if ("generating" === e) return;
o.current += 1;
let l = o.current;
t("generating");
try {
let e = await A(r);
if (l !== o.current) return;
a(e), t("done"), s(!0);
} catch {
if (l !== o.current) return;
n.Notify.error("智能补全失败,请重试"), t("idle");
}
},
[e],
),
c = (0, i.useCallback)(() => {
(o.current += 1), t("idle"), a(null), s(!1);
}, []);
return {
status: e,
result: r,
showModal: l,
setShowModal: s,
trigger: d,
reset: c,
};
})(),
eL = (0, i.useRef)(null),
eM = (0, i.useRef)(null),
eO = (0, i.useRef)(null),
[eR, e_] = (0, i.useState)(!1),
[eK, e$] = (0, i.useState)(0),
[eB, eV] = (0, i.useState)(0),
eW = (0, i.useRef)(null),
eq = (0, i.useRef)(null),
eY = (0, i.useRef)(0),
[eG, eJ] = (0, i.useState)(null),
[eH, eX] = (0, i.useState)(null),
[eZ, eQ] = (0, i.useState)(!1),
[e0, e1] = (0, i.useState)(!1),
[e2, e4] = (0, i.useState)(null),
e5 = (0, i.useRef)(null),
[e3, e8] = (0, i.useState)(null);
(eT.current = eA),
(0, i.useEffect)(() => {
if (!e || s) return;
let t = !1;
return (
(async () => {
try {
let e = await ((e = {}) =>
b.apiClient.get(v.default.klingPresetVoices, {
params: e,
}))({ pageSize: 100 }),
r = (0, m.getApiData)(e);
if (t) return;
(0, m.isApiOk)(e) &&
r?.items &&
ey(
r.items
.filter((e) => !!e.name && !!(e.voiceId || e.id))
.map((e) => ({
id: e.voiceId || e.id || "",
name: e.name,
official: !0,
previewUrl: e.previewUrl,
})),
);
} catch {}
})(),
() => {
t = !0;
}
);
}, [e, s]),
(0, i.useEffect)(() => {
if (e)
if ((eS(null), ec(null), (ez.current = { cancelled: !1 }), a)) {
ep(a.name), ex(a.description ?? "");
let e = a.audios?.find((e) => e.voiceId);
eg(e?.voiceId ?? "none"),
eb(
e?.voiceId
? [
{
id: e.voiceId,
name: e.name || e.voiceId,
previewUrl: e.url || void 0,
},
]
: [],
),
ew(null != a.type ? String(a.type) : "none"),
a.images && a.images.length > 0
? (g("image"),
y(
a.images.map((e, t) => ({
id: `existing-${t}`,
file: null,
previewUrl: e.url,
uploadedUrl: e.url,
isUploading: !1,
})),
),
C(null))
: a.videos && a.videos.length > 0
? (g("video"), y([]), C(a.videos[0].url))
: (g(null), y([]), C(null));
} else if (
(ep(""),
ex(""),
eg("none"),
eb([]),
ew("none"),
U(!1),
F(""),
eD.reset(),
d?.mode === "image" &&
d.referenceImages &&
d.referenceImages.length > 0)
) {
let e = d.referenceImages.slice(0, 4);
g("image"),
C(null),
y(
e.map((e, t) => ({
id: `initial-${t}`,
file: null,
previewUrl: e,
uploadedUrl: e,
isUploading: !1,
})),
);
} else
d?.mode === "video" && d.referenceVideo
? (g("video"), y([]), C(d.referenceVideo))
: (g(null), y([]), C(null));
}, [e, a, d]),
(0, i.useEffect)(() => {
if (!e || a || d?.mode !== "video" || !d.referenceVideo) return;
let t = d.referenceVideo,
r = !1;
return (
(async () => {
let e = await ei(t, "video");
if (r) return;
let i = ea(e);
i ? (n.Notify.error(i), ec(i)) : ec(null);
})(),
() => {
r = !0;
}
);
}, [e, a, d?.mode, d?.referenceVideo]),
(0, i.useEffect)(() => {
eP.current = new Audio();
let e = eP.current,
t = () => eF(null);
return (
e.addEventListener("ended", t),
() => {
e.pause(), e.removeEventListener("ended", t), (eP.current = null);
}
);
}, []),
(0, i.useEffect)(() => {
e ||
((ez.current.cancelled = !0),
eD.reset(),
eP.current?.pause(),
eP.current && (eP.current.currentTime = 0),
eF(null),
eJ(null),
eX(null),
eE(!1));
}, [e]),
(0, i.useEffect)(() => {
if (!eG) return;
let e = (e) => {
let t = e.target;
eq.current?.contains(t) || eJ(null);
};
return (
document.addEventListener("mousedown", e),
() => document.removeEventListener("mousedown", e)
);
}, [eG]),
(0, i.useEffect)(() => {
e$(0), eV(0), e_(!1);
}, [j]),
(0, i.useEffect)(() => {
if (!e || !j || S) return;
let t = eO.current;
if (!t) return;
let r = () => e$(t.currentTime),
i = () => e_(!0),
a = () => e_(!1),
l = () => {
let e = t.duration;
eV(Number.isFinite(e) && e > 0 ? e : 0);
};
return (
t.addEventListener("timeupdate", r),
t.addEventListener("play", i),
t.addEventListener("pause", a),
t.addEventListener("loadedmetadata", l),
t.addEventListener("durationchange", l),
l(),
() => {
t.removeEventListener("timeupdate", r),
t.removeEventListener("play", i),
t.removeEventListener("pause", a),
t.removeEventListener("loadedmetadata", l),
t.removeEventListener("durationchange", l);
}
);
}, [e, j, S]);
let e6 = (0, i.useCallback)(() => {
let e = eO.current;
e && (e.paused ? e.play().catch(() => void 0) : e.pause());
}, []),
e7 = (0, i.useCallback)(
(e) => {
e.stopPropagation(), e6();
},
[e6],
),
e9 = (0, i.useCallback)(
(e) => {
e.stopPropagation(), e6();
},
[e6],
),
te = (0, i.useCallback)((e) => {
let t = eO.current;
t && ((t.currentTime = e), e$(e));
}, []),
tt = h.filter((e) => e.uploadedUrl && !e.error).length,
tr = h.filter((e) => !e.error).length,
ti =
h.length > 0 &&
!h[0].isUploading &&
!h[0].error &&
!!h[0].uploadedUrl,
ta = ("image" === x && tt >= 2) || ("video" === x && null !== j && !M),
tl = eu.trim().length > 0 && ef.trim().length > 0 && ta,
tn = ("image" === x && ti) || ("video" === x && null !== j),
ts = (0, i.useCallback)(
async (e) => {
let t = Array.from(e.target.files ?? []);
if (((e.target.value = ""), 0 === t.length)) return;
g("image");
let r = 4 - h.length,
i = t
.slice(0, r)
.map((e) => ({
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
file: e,
previewUrl: URL.createObjectURL(e),
isUploading: !0,
}));
y((e) => [...e, ...i]);
let a = (0, R.getCookie)(L.USER_TOKEN_COOKIE_KEY),
l = (0, R.getCookie)(L.USER_UUID_COOKIE_KEY);
for (let e of i)
try {
if (!a || "string" != typeof a || !l || "string" != typeof l) {
y((t) =>
t.map((t) =>
t.id === e.id ? { ...t, isUploading: !1, error: !0 } : t,
),
);
continue;
}
let t = await (0, K.uploadViaPreSign)(e.file, {
token: a,
uuid: l,
verify: !0,
}),
r = t.url ?? (0, K.resolveUploadUrl)(t);
y((t) =>
t.map((t) =>
t.id === e.id
? {
...t,
isUploading: !1,
uploadedUrl: r ?? void 0,
error: !r,
}
: t,
),
);
} catch {
y((t) =>
t.map((t) =>
t.id === e.id ? { ...t, isUploading: !1, error: !0 } : t,
),
);
}
},
[h.length],
),
to = (0, i.useCallback)((e) => {
e5.current = e;
}, []),
td = (0, i.useCallback)((e, t) => {
e.preventDefault(), e8((e) => (e === t ? e : t));
}, []),
tc = (0, i.useCallback)((e, t) => {
e.preventDefault();
let r = e5.current;
(e5.current = null),
e8(null),
null !== r &&
r !== t &&
y((e) => {
let i = [...e],
[a] = i.splice(r, 1);
return i.splice(t, 0, a), i;
});
}, []),
tu = (0, i.useCallback)(() => {
(e5.current = null), e8(null);
}, []),
tp = (0, i.useCallback)(
(e) => {
let t = h.findIndex((t) => t.id === e);
if (-1 !== t) {
if ("generating" === eD.status && 0 === t) {
e4(e), e1(!0);
return;
}
y((t) => {
let r = t.filter((t) => t.id !== e);
return 0 === r.length && g(null), r;
});
}
},
[h, eD.status],
),
tf = (0, i.useCallback)(() => {
e1(!1), e4(null);
}, []),
tx = (0, i.useCallback)(() => {
e1(!1),
e4(null),
e2 &&
(eD.reset(),
y((e) => {
let t = e.filter((e) => e.id !== e2);
return 0 === t.length && g(null), t;
}));
}, [e2, eD.reset]),
tm = (0, i.useCallback)(async (e) => {
let t = e.target.files?.[0];
if (((e.target.value = ""), !t)) return;
let r = await (0, $.validateVideoFile)(t, {
minDurationSec: 3,
maxDurationSec: 8,
});
if (r) return void n.Notify.error(r);
g("video"), U(!0), F("上传中...");
try {
let e = (0, R.getCookie)(L.USER_TOKEN_COOKIE_KEY),
r = (0, R.getCookie)(L.USER_UUID_COOKIE_KEY);
if (!e || "string" != typeof e || !r || "string" != typeof r) {
n.Notify.error("请先登录"), U(!1), F("");
return;
}
let i = await (0, K.uploadViaPreSign)(t, {
token: e,
uuid: r,
verify: !1,
}),
a = i.url ?? (0, K.resolveUploadUrl)(i);
a
? (await (0, _.pollMediaAudit)(a, _.AuditContentType.VIDEO),
C(a),
ec(null))
: (n.Notify.error("视频上传失败"), g(null));
} catch (e) {
n.Notify.error(
e instanceof _.MediaAuditError ? e.message : "视频上传失败",
),
C(null),
g(null);
} finally {
U(!1), F("");
}
}, []),
tg = (0, i.useCallback)(() => {
C(null), g(null), ec(null);
}, []),
th = (0, i.useCallback)((e, t) => {
eJ({
scope: "media",
type: t,
style: {
position: "fixed",
top: e.clientY + 6,
left: e.clientX,
width: 100,
zIndex: Z,
},
});
}, []),
tb = (0, i.useCallback)((e) => {
let t = e.currentTarget.getBoundingClientRect();
eJ({
scope: "voice",
style: {
position: "fixed",
left: t.right + 10,
bottom: window.innerHeight - t.bottom - 4,
width: 120,
zIndex: Z,
},
});
}, []),
tv = (0, i.useCallback)(() => {
if (!eG) return;
if ("voice" === eG.scope) {
eJ(null), eW.current?.click();
return;
}
let e = eG.type;
(eJ(null), "image" === e) ? eL.current?.click() : eM.current?.click();
}, [eG]),
ty = (0, i.useCallback)(async (e, t, r) => {
try {
let i;
n.Notify.info("创建音色中...");
let a = await ((i = { name: e, url: t }),
b.apiClient.post(v.default.klingCustomVoiceCreate, i)),
l = (0, m.getApiData)(a);
if (!(0, m.isApiOk)(a) || !l?.taskId) {
n.Notify.error("音色创建失败"), eS(null);
return;
}
if (r()) return;
n.Notify.info("等待音色审核...");
let s = await ed(l.taskId, {
get cancelled() {
return r();
},
});
if (r()) return;
let o = { id: s, name: e, custom: !0, previewUrl: t };
eb((e) => [...e, o]),
eg(s),
eS(null),
n.Notify.success("音色添加成功");
} catch (e) {
if (r()) return;
if (e instanceof Error && e.voiceAuditFooter) {
n.Notify.error("音色创建失败,请重试"),
eS(e.voiceAuditBackendDetail ?? null);
return;
}
n.Notify.error(
e instanceof Error ? e.message : "音色创建失败,请重试",
),
eS(null);
}
}, []),
tj = (0, i.useCallback)(
(e) => {
if (eH && 0 !== e.length) {
if ("image" === eH) {
for (let t of e)
if ("image" !== t.mediaType)
return void n.Notify.error("请选择图片素材");
let t = [];
for (let r of e) {
let e = en(r);
if (!e) return void n.Notify.error("未获取到可用素材链接");
let i = (function (e) {
let t = e.raw;
if ("libtv" === e.source)
try {
let e = JSON.parse(t.extra ?? "{}"),
r = Number(e.width),
i = Number(e.height);
return {
width: Number.isFinite(r) ? r : void 0,
height: Number.isFinite(i) ? i : void 0,
};
} catch {
return {};
}
let r = Number(t.width),
i = Number(t.height);
return {
width: Number.isFinite(r) ? r : void 0,
height: Number.isFinite(i) ? i : void 0,
};
})(r),
a = (function (e, t) {
if (!e || !t || e <= 0 || t <= 0) return null;
let r = e * t;
return r <= 0xa00000
? null
: Math.floor(e * Math.sqrt(0xa00000 / r));
})(i.width, i.height),
l =
"image" !== r.mediaType
? r.thumbnailUrl || ""
: r.raw.imageUrl || r.thumbnailUrl || "",
s = (0, u.getOssCompressedImage)(l, 600) || l,
o =
null !== a
? (function (e, t) {
if (
!e ||
!e.startsWith("http") ||
e.includes("x-oss-process=")
)
return e;
let r = e.includes("?") ? "&" : "?";
return `${e}${r}x-oss-process=image/resize,w_${t},m_lfit/ignore-error,1`;
})(e, a)
: e;
t.push({ compressedDisplayUrl: s, compressedApiUrl: o });
}
g("image"),
C(null),
ec(null),
y((e) => {
let r = 4 - e.length;
return r <= 0
? (n.Notify.error(`最多可添加 4 张图片`), e)
: [
...e,
...t
.slice(0, r)
.map(
({
compressedDisplayUrl: e,
compressedApiUrl: t,
}) => ({
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
file: null,
previewUrl: e,
displayUrl: e,
uploadedUrl: t,
isUploading: !1,
}),
),
];
});
} else if ("video" === eH) {
let t = e[0];
if (!t) return;
if ("video" !== t.mediaType)
return void n.Notify.error("请选择视频素材");
let r = en(t);
return r
? void (async () => {
try {
let e = await ei(r, "video"),
t = ea(e);
g("video"),
y([]),
U(!1),
F(""),
C(r),
t ? (n.Notify.error(t), ec(t)) : ec(null);
} finally {
eX(null);
}
})()
: void n.Notify.error("未获取到可用素材链接");
} else if ("voice" === eH) {
let t = e[0];
if (!t) return;
if ("audio" !== t.mediaType && "video" !== t.mediaType)
return void n.Notify.error("请选择音频或视频素材");
let r = en(t);
return r
? void (async () => {
try {
let e,
i,
a = "video" === t.mediaType,
l = await ei(r, a ? "video" : "audio"),
s = el(l);
if (s) return void n.Notify.error(s);
let o =
((e = t.raw),
(i = (
[
"string" == typeof e.taskName ? e.taskName : "",
"string" == typeof e.title ? e.title : "",
"string" == typeof e.name ? e.name : "",
].find((e) => e.trim().length > 0) ?? "自定义音色"
)
.trim()
.replace(/\.[^.]+$/, "")
.slice(0, 20)).length >= 1
? i
: "自定义音色");
eY.current += 1;
let d = eY.current;
await ty(o, r, () => eY.current !== d);
} finally {
eX(null);
}
})()
: void n.Notify.error("未获取到可用素材链接");
}
eX(null);
}
},
[eH, ty],
),
tw = new Set(ev.map((e) => e.id)),
tN = [Q, ...eh.filter((e) => !tw.has(e.id)), ...ev],
tk = [
{ id: "none", name: "无标签" },
...G.filter((e) => null !== e.value).map((e) => ({
id: String(e.value),
name: e.label,
})),
],
tC = (0, i.useCallback)(
async (e) => {
let t = e.target.files?.[0];
if (((e.target.value = ""), !t)) return;
if (!/\.(mp3|wav|mp4|mov)$/i.test(t.name))
return void n.Notify.error(
"请上传 mp3、wav、mp4 或 mov 格式文件",
);
let r = t.name.replace(/\.[^.]+$/, "");
if (r.length < 1 || r.length > 20)
return void n.Notify.error("音频文件名需在 1~20 个字之间");
let i = el(await er(t));
if (i) return void n.Notify.error(i);
let a = (0, R.getCookie)(L.USER_TOKEN_COOKIE_KEY),
l = (0, R.getCookie)(L.USER_UUID_COOKIE_KEY);
if (!a || "string" != typeof a || !l || "string" != typeof l)
return void n.Notify.error("请先登录");
eY.current += 1;
let s = eY.current,
o = () => eY.current !== s,
d = r || "自定义音色";
n.Notify.info("正在上传...");
try {
let e = await (0, K.uploadViaPreSign)(t, {
token: a,
uuid: l,
verify: !1,
});
if (o()) return;
let r = (0, K.resolveUploadUrl)(e);
if (!r) return void n.Notify.error("音频上传失败");
await ty(d, r, o);
} catch (e) {
o() ||
n.Notify.error(
e instanceof _.MediaAuditError || e instanceof Error
? e.message
: "音频上传失败,请重试",
);
}
},
[ty],
),
tS = (0, i.useCallback)((e) => {
if ("none" === e.id) return;
if (!e.previewUrl) return void n.Notify.info("该音色暂无试听音频");
let t = eP.current;
if (t) {
if (eT.current === e.id) {
t.pause(), (t.currentTime = 0), eF(null);
return;
}
t.pause(),
(t.src = e.previewUrl),
(t.currentTime = 0),
t
.play()
.then(() => eF(e.id))
.catch(() => {
eF(null), n.Notify.error("音频播放失败,请稍后重试");
});
}
}, []),
tU = (0, i.useCallback)(async () => {
if (tl && !eI.current) {
(eI.current = !0), ek(!0), eS(null);
try {
let e =
"image" === x
? h
.map((e) => e.uploadedUrl)
.filter((e) => !!e)
.map((e, t) => ({ name: `image-${t}`, url: e }))
: void 0,
r = "video" === x && j ? [{ name: "video-0", url: j }] : void 0,
i = "none" === em ? void 0 : em,
l = i ? [...ev, ...eh].find((e) => e.id === i) : void 0,
s = i
? [
{
name: l?.name ?? "",
url: l?.previewUrl ?? "",
voiceId: i,
},
]
: void 0,
o = "none" !== ej ? Number(ej) : void 0;
if (f && a) {
let i = await k({
entityUuid: a.entityUuid,
name: eu.trim(),
description: ef.trim() || void 0,
coverUrl: e?.[0]?.url ?? j ?? void 0,
images: e,
videos: r,
audios: s,
type: o,
specialSupportType: ["kling"],
}),
l = (0, m.getApiData)(i);
if ((0, m.isApiOk)(i) && l)
if ("failed" === String(l.taskStatus ?? "").toLowerCase()) {
let e =
"string" == typeof l.taskStatusMsg &&
l.taskStatusMsg.trim()
? l.taskStatusMsg.trim()
: null;
eS(e), n.Notify.error("更新失败");
} else if (l.taskId) {
n.Notify.info("主体更新中,请稍候...");
let i = await eo(l.taskId, ez.current);
i.entityUuid &&
(n.Notify.success("主体更新成功"),
c?.(
w({
entityUuid: i.entityUuid,
name: eu.trim(),
description: ef.trim() || void 0,
coverUrl: e?.[0]?.url ?? j ?? void 0,
images: e,
videos: r,
audios: s,
type: o ?? a.type,
}),
),
t());
} else
n.Notify.success("主体更新成功"),
c?.(
w({
entityUuid: a.entityUuid,
name: eu.trim(),
description: ef.trim() || void 0,
coverUrl: e?.[0]?.url ?? j ?? void 0,
images: e ?? a.images,
videos: r ?? a.videos,
audios: s ?? a.audios,
type: o ?? a.type,
}),
),
t();
else n.Notify.error("更新失败,请稍后重试");
} else {
let i = await N({
name: eu.trim(),
description: ef.trim() || "",
coverUrl: e?.[0]?.url ?? j ?? void 0,
images: e,
videos: r,
audios: s,
type: o,
specialSupportType: ["kling"],
}),
a = (0, m.getApiData)(i);
if ((0, m.isApiOk)(i) && a)
if ("failed" === String(a.taskStatus ?? "").toLowerCase()) {
let e =
"string" == typeof a.taskStatusMsg &&
a.taskStatusMsg.trim()
? a.taskStatusMsg.trim()
: null;
eS(e), n.Notify.error("创建失败");
} else if (a.entityUuid) {
if (a.taskId) {
n.Notify.info("主体创建中,请稍候...");
let t =
(await eo(a.taskId, ez.current)).entityUuid ??
a.entityUuid;
n.Notify.success("主体创建成功"),
c?.(
w({
entityUuid: t,
name: eu.trim(),
description: ef.trim() || void 0,
coverUrl: e?.[0]?.url ?? j ?? void 0,
images: e,
videos: r,
audios: s,
type: o ?? 0,
createdAtMs: Date.now(),
}),
);
} else
n.Notify.success("主体创建成功"),
c?.(
w({
entityUuid: a.entityUuid,
name: eu.trim(),
description: ef.trim() || void 0,
coverUrl: e?.[0]?.url ?? j ?? void 0,
images: e,
videos: r,
audios: s,
type: o ?? 0,
createdAtMs: Date.now(),
}),
);
t();
} else n.Notify.error("创建失败,请稍后重试");
else n.Notify.error("创建失败,请稍后重试");
}
} catch (t) {
if (t instanceof Error && "cancelled" === t.message) return;
let e =
t instanceof Error ? t.message : "网络异常,请检查网络后重试";
t instanceof Error && t.taskStatusFooter
? (n.Notify.error("主体创建失败,请重试或检查上传的素材~"),
eS(t.subjectProgressBackendDetail ?? null))
: n.Notify.error(e);
} finally {
ek(!1), (eI.current = !1);
}
}
}, [tl, f, a, eu, ef, x, h, j, em, ev, eh, ej, c, t]),
tE = (0, i.useCallback)(() => {
eN ||
((ez.current.cancelled = !0),
eP.current?.pause(),
eP.current && (eP.current.currentTime = 0),
eO.current?.pause(),
eF(null),
t());
}, [eN, t]),
tI = (0, i.useCallback)(() => {
eQ(!1);
}, []),
tA = (0, i.useCallback)(() => {
if (!eN) {
if (s) return void tE();
eQ(!0);
}
}, [eN, s, tE]),
tF = (0, i.useCallback)(() => {
eQ(!1), tE();
}, [tE]);
(0, i.useEffect)(() => {
e || (eQ(!1), e1(!1), e4(null));
}, [e]),
(0, i.useEffect)(() => {
if (!e || eN) return;
let t = (e) => {
if ("Escape" === e.key && null === eH) {
if (e0) {
tf(),
e.preventDefault(),
e.stopPropagation(),
e.stopImmediatePropagation();
return;
}
if (eZ) {
tI(),
e.preventDefault(),
e.stopPropagation(),
e.stopImmediatePropagation();
return;
}
if (eG) {
eJ(null),
e.preventDefault(),
e.stopPropagation(),
e.stopImmediatePropagation();
return;
}
e.preventDefault(),
e.stopPropagation(),
e.stopImmediatePropagation(),
tA();
}
};
return (
document.addEventListener("keydown", t, !0),
() => document.removeEventListener("keydown", t, !0)
);
}, [e, eN, tA, eH, eG, eZ, e0, tI, tf]);
let tP = (0, i.useCallback)(
(e) => {
if (!s && "Enter" === e.key && !e.shiftKey && !eI.current) {
let t = e.target;
"BUTTON" !== t.tagName &&
"TEXTAREA" !== t.tagName &&
tl &&
(e.preventDefault(), tU());
}
},
[s, tl, tU],
),
tT = (0, i.useCallback)(async () => {
if (!s && tn) {
eE(!0);
try {
if ("image" === x) {
let e = {
imageUrls: h.map((e) => e.uploadedUrl).filter((e) => !!e),
},
t = await I(e);
ex(t.description.slice(0, 100));
return;
}
if ("video" === x && j) {
let e = eO.current;
if (!e) return void n.Notify.error("视频未就绪,请稍后重试");
e.pause(), e_(!1);
let t = await et(e);
if (!t)
return void n.Notify.error(
"无法截取当前画面,请确认视频资源允许跨域访问或稍后重试",
);
let r = await I({ imageUrls: [t] });
ex(r.description.slice(0, 100));
}
} catch {
n.Notify.error("生成失败,请稍后重试");
} finally {
eE(!1);
}
}
}, [s, tn, x, h, j]),
tz = (0, i.useCallback)((e) => {
let t = e.map((e) => ({
id: `smart-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
file: null,
previewUrl: e,
uploadedUrl: e,
isUploading: !1,
}));
y((e) => {
let r = e[0];
if (!r) return t.slice(0, 4);
let i = t.slice(0, 3),
a = e.slice(1),
l = Math.min(a.length, 3 - i.length);
return [r, ...a.slice(0, l), ...i];
}),
eD.reset();
}, []);
if (!e) return null;
let tD = h.length < 4,
tL = tN.find((e) => e.id === em) ?? Q,
tM = tk.find((e) => e.id === ej) ?? tk[0];
return (0, r.jsxs)(T.Portal, {
children: [
(0, r.jsx)("div", {
className: "fixed inset-0",
style: {
zIndex: "calc(var(--z-overlay) + 10)",
backgroundColor: "rgba(0, 0, 0, 0.35)",
backdropFilter: "blur(12px)",
WebkitBackdropFilter: "blur(12px)",
},
onClick: eN || eZ || e0 ? void 0 : tA,
role: "presentation",
}),
(0, r.jsx)("div", {
className:
"pointer-events-none fixed inset-0 flex items-center justify-center",
style: { zIndex: "calc(var(--z-overlay) + 11)" },
children: (0, r.jsx)("div", {
role: "dialog",
onClick: (e) => e.stopPropagation(),
onKeyDown: void 0,
children: (0, r.jsx)(z.default, {
className: `pointer-events-auto flex w-[600px] flex-col ${p ? "canvas-light" : ""}`,
style: {
borderRadius: 12,
backdropFilter: "none",
border: p
? "1px solid var(--canvas-controls-border)"
: "1px solid rgba(255, 255, 255, 0.1)",
},
children: (0, r.jsxs)("div", {
className: "flex flex-col",
onKeyDown: tP,
children: [
(0, r.jsxs)("div", {
className: (0, o.cn)(
"flex shrink-0 items-center justify-between border-b px-4 pb-3 pt-3",
p ? "border-border-default" : "border-border-muted",
),
children: [
(0, r.jsx)("span", {
className: "text-fg-default text-sm font-medium",
children: s
? "查看主体"
: f
? "编辑主体"
: "创建主体",
}),
(0, r.jsx)("button", {
type: "button",
onClick: tA,
disabled: eN,
className:
"text-fg-muted hover:bg-canvas-controls-hover hover:text-fg-default flex size-6 items-center justify-center rounded-lg transition-colors disabled:pointer-events-none disabled:opacity-50",
children: (0, r.jsx)(l.Icons.x, {
width: 14,
height: 14,
}),
}),
],
}),
(0, r.jsxs)("div", {
className: "h-[520px] p-4",
children: [
null === x &&
!s &&
(0, r.jsxs)("div", {
className: "flex items-center gap-1",
children: [
(0, r.jsxs)("div", {
className: (0, o.cn)(
"flex h-44 flex-1 cursor-pointer flex-col items-center justify-center gap-2 rounded-lg border-[0.5px] transition-colors",
p
? "border-border-default bg-bg-surface-secondary hover:bg-canvas-controls-hover"
: "border-[#525252] bg-[#1F1F1F]/90 hover:bg-white/10",
),
onClick: (e) => th(e, "image"),
children: [
(0, r.jsx)(l.Icons.plus, {
width: 13,
height: 13,
className: (0, o.cn)(
"mb-2",
p
? "text-fg-default"
: "text-[#f7f7f7]/90",
),
}),
(0, r.jsx)("span", {
className: (0, o.cn)(
"text-xs",
p ? "text-fg-default" : "text-[#f7f7f7]",
),
children: "添加角色图片",
}),
(0, r.jsx)("span", {
className: (0, o.cn)(
"text-[11px]",
p ? "text-fg-subtle" : "text-white/55",
),
children:
"2-4张,第一张图必须为清晰正脸的图片",
}),
],
}),
(0, r.jsx)("span", {
className: (0, o.cn)(
"shrink-0 px-2 text-xs",
p
? "text-fg-muted"
: "text-fg-default opacity-40",
),
children: "或",
}),
(0, r.jsxs)("div", {
className: (0, o.cn)(
"relative flex h-44 flex-1 cursor-pointer flex-col items-center justify-center gap-2 rounded-lg border-[0.5px] transition-colors",
p
? "border-border-default bg-bg-surface-secondary hover:bg-canvas-controls-hover"
: "border-[#525252] bg-[#1F1F1F]/90 hover:bg-white/10",
),
onClick: (e) => th(e, "video"),
children: [
(0, r.jsx)(l.Icons.plus, {
width: 13,
height: 13,
className: (0, o.cn)(
"mb-2",
p ? "text-fg-default" : "text-[#f7f7f7]",
),
}),
(0, r.jsx)("span", {
className: (0, o.cn)(
"text-xs",
p ? "text-fg-default" : "text-[#f7f7f7]",
),
children: "添加角色视频",
}),
(0, r.jsxs)("span", {
className: (0, o.cn)(
"text-[11px]",
p ? "text-fg-subtle" : "text-white/55",
),
children: [
3,
"-",
8,
"s单一连续镜头的视频",
],
}),
(0, r.jsx)("span", {
className: (0, o.cn)(
"absolute bottom-8 text-[11px]",
p ? "text-fg-subtle" : "text-white/55",
),
children: "目前视频仅支持人物主体",
}),
],
}),
],
}),
"image" === x &&
(0, r.jsxs)("div", {
className: "grid grid-cols-4 gap-3",
children: [
h.map((e, t) =>
(0, r.jsxs)(
"div",
{
draggable: !s && !e.isUploading,
onDragStart: () => to(t),
onDragOver: (e) => td(e, t),
onDrop: (e) => tc(e, t),
onDragEnd: tu,
className: (0, o.cn)(
"group/card relative transition-opacity",
!s &&
!e.isUploading &&
"cursor-grab active:cursor-grabbing",
e3 === t &&
(p
? "ring-2 ring-black/20"
: "ring-2 ring-white/50"),
),
children: [
(0, r.jsxs)("div", {
className: (0, o.cn)(
"aspect-3/4 overflow-hidden rounded-lg border transition-colors",
p
? "border-border-default group-hover/card:border-border-emphasis bg-black/3"
: "border-border-muted bg-white/5 group-hover/card:border-white/40",
),
children: [
(0, r.jsx)("img", {
src:
e.displayUrl ||
(function (e) {
if (!e || !e.startsWith("http"))
return e ?? "";
let t =
e.indexOf("x-oss-process="),
r =
-1 !== t
? e.slice(0, t - 1)
: e,
i = r.includes("?")
? "&"
: "?";
return `${r}${i}x-oss-process=image/resize,w_600,m_lfit/format,webp/ignore-error,1`;
})(e.uploadedUrl || e.previewUrl),
alt: "",
draggable: !1,
className: "size-full object-cover",
}),
(0, r.jsx)("div", {
className: (0, o.cn)(
"absolute inset-0 rounded-lg border bg-black/0 transition-colors",
p
? "group-hover/card:border-black/25 group-hover/card:bg-black/25"
: "group-hover/card:border-white/70 group-hover/card:bg-black/50",
),
}),
e.isUploading &&
(0, r.jsx)("div", {
className:
"absolute inset-0 flex items-center justify-center rounded-lg bg-black/50",
children: (0, r.jsx)("span", {
className:
"text-fg-muted text-xs",
children: "上传中...",
}),
}),
e.error &&
(0, r.jsx)("div", {
className:
"absolute inset-0 flex items-center justify-center rounded-lg bg-black/50",
children: (0, r.jsx)("span", {
className:
"text-xs text-red-400",
children: "上传失败",
}),
}),
],
}),
!s &&
(0, r.jsx)("button", {
type: "button",
onClick: () => tp(e.id),
className:
"absolute -right-1 -top-1 z-10 flex size-[15px] cursor-pointer items-center justify-center rounded-full border border-white/80 bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover/card:opacity-100",
children: (0, r.jsx)(l.Icons.x, {
width: 5,
height: 5,
}),
}),
],
},
e.id,
),
),
!s &&
tD &&
(0, r.jsxs)("div", {
className: (0, o.cn)(
"aspect-3/4 flex cursor-pointer flex-col items-center justify-end gap-2 rounded-lg border-[0.5px] py-8 transition-colors",
p
? "border-border-default bg-bg-surface-secondary hover:bg-canvas-controls-hover"
: "border-[#525252] bg-[#1F1F1F]/90 hover:bg-white/10",
),
onClick: (e) => th(e, "image"),
children: [
(0, r.jsx)(l.Icons.plus, {
width: 13,
height: 13,
className: (0, o.cn)(
"mb-2",
p
? "text-fg-default"
: "text-[#f7f7f7]/90",
),
}),
(0, r.jsxs)("span", {
className: (0, o.cn)(
"text-center text-xs",
p
? "text-fg-default"
: "text-[#f7f7f7]",
),
children: [
"添加其他视角图",
tr < 2 &&
(0, r.jsx)("span", {
className:
"text-[14px] text-[#cf3336]",
children: "*",
}),
],
}),
(0, r.jsx)("button", {
type: "button",
className: (0, o.cn)(
"mt-2 flex gap-1 rounded-lg px-2 py-1 text-[13px] enabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
p
? "bg-black/6 text-fg-default enabled:hover:bg-black/10"
: "bg-white/10 text-[#F7F7F7]",
),
disabled:
"generating" === eD.status || !ti,
onClick: (e) =>
void eD.trigger(h[0]?.uploadedUrl, e),
children:
"generating" === eD.status
? (0, r.jsxs)("span", {
className:
"flex items-center gap-1",
children: [
(0, r.jsx)(l.Icons.Loading, {
width: 14,
height: 14,
className: (0, o.cn)(
"animate-spin",
p
? "text-fg-muted"
: "text-[#A8A8A8]",
),
}),
(0, r.jsx)("span", {
className: p
? "text-fg-muted"
: "text-[#A8A8A8]",
children: "智能补全中",
}),
],
})
: (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsxs)("span", {
className:
"flex items-center gap-[2px]",
children: [
(0, r.jsx)(
l.Icons.LightningF,
{
width: 9,
height: 14,
className: p
? "text-fg-muted"
: "text-[#A8A8A8]",
},
),
(0, r.jsx)("span", {
className: (0, o.cn)(
"text-xs",
p
? "text-fg-muted"
: "text-[#A8A8A8]",
),
children: 6,
}),
],
}),
(0, r.jsx)("span", {
children: "智能补全",
}),
],
}),
}),
],
}),
],
}),
"video" === x &&
(0, r.jsx)("div", {
className: (0, o.cn)(
"group/video relative flex h-44 w-full items-center justify-center rounded-lg border transition-colors",
p
? "border-border-default bg-neutral-100"
: "border-neutral-800 bg-[#383838]",
),
children: S
? (0, r.jsxs)("div", {
className:
"flex h-44 w-full flex-col items-center justify-center gap-2",
children: [
(0, r.jsxs)("svg", {
className: (0, o.cn)(
"size-6 animate-spin",
p
? "text-fg-disabled"
: "text-white/40",
),
viewBox: "0 0 24 24",
fill: "none",
children: [
(0, r.jsx)("circle", {
cx: "12",
cy: "12",
r: "10",
stroke: "currentColor",
strokeWidth: "2",
opacity: "0.3",
}),
(0, r.jsx)("path", {
d: "M12 2a10 10 0 0 1 10 10",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
}),
],
}),
(0, r.jsx)("span", {
className: "text-fg-subtle text-sm",
children: E || "上传中...",
}),
],
})
: j
? (0, r.jsxs)("div", {
className:
"relative flex h-full min-h-0 w-full min-w-0 items-center justify-center",
children: [
(0, r.jsx)("video", {
ref: eO,
src: j,
crossOrigin:
(function (e) {
if (
!(
e.startsWith("blob:") ||
e.startsWith("data:")
)
)
return /^https?:\/\//i.test(e)
? "anonymous"
: void 0;
})(j) ?? void 0,
autoPlay: !0,
loop: !0,
muted: !0,
playsInline: !0,
className:
"max-h-full max-w-full cursor-pointer object-contain",
onClick: e9,
children: (0, r.jsx)("track", {
kind: "captions",
}),
}),
(0, r.jsx)("div", {
className:
"pointer-events-none absolute inset-0 bg-black/0 transition-colors group-hover/video:bg-black/50",
}),
(0, r.jsx)("div", {
className:
"pointer-events-none opacity-0 transition-opacity duration-200 group-hover/video:pointer-events-auto group-hover/video:opacity-100",
children: (0, r.jsx)(B.VideoPlayerBar, {
isPlaying: eR,
currentTime: eK,
duration: eB,
hasAudio: !1,
muted: !0,
onPlayPause: e7,
onSeek: te,
disableScreenShot: !0,
}),
}),
M
? (0, r.jsx)("div", {
className:
"pointer-events-none absolute inset-0 z-[25] flex items-center justify-center bg-black/65 px-3",
children: (0, r.jsx)("p", {
className:
"max-w-full text-center text-xs leading-relaxed text-white/80",
children: M,
}),
})
: null,
!s &&
(0, r.jsx)("button", {
type: "button",
onClick: tg,
className:
"absolute -right-1 -top-1 z-30 flex size-[15px] cursor-pointer items-center justify-center rounded-full border border-white/80 bg-[#222] text-[#F7F7F7] opacity-0 transition-opacity hover:border-white hover:bg-[#333] group-hover/video:opacity-100",
children: (0, r.jsx)(l.Icons.x, {
width: 5,
height: 5,
}),
}),
],
})
: null,
}),
(0, r.jsxs)("div", {
className: "mt-5 flex flex-col gap-2",
children: [
(0, r.jsxs)("span", {
className: "text-fg-muted text-sm",
children: [
"主体名称 ",
(0, r.jsx)("span", {
className: "text-[#cf3336]",
children: "*",
}),
],
}),
(0, r.jsxs)("div", {
className: "relative w-[276px]",
children: [
(0, r.jsx)("input", {
type: "text",
value: eu,
onChange: (e) =>
ep(e.target.value.slice(0, 20)),
readOnly: s,
placeholder: "请输入主体名称",
maxLength: 20,
className: (0, o.cn)(
"focus:border-brand-600 text-fg-default placeholder:text-fg-disabled read-only:text-fg-default h-8 w-full rounded-lg border bg-transparent px-3 pr-14 text-[13px] outline-none read-only:cursor-default",
p
? "border-border-default read-only:border-border-default"
: "border-border-muted read-only:border-border-muted",
),
}),
(0, r.jsxs)("span", {
className:
"text-fg-disabled absolute right-3 top-1/2 -translate-y-1/2 text-[11px]",
children: [eu.length, "/", 20],
}),
],
}),
],
}),
(0, r.jsx)("div", {
className: "mt-5 flex gap-4",
children: s
? (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsxs)("div", {
className: "flex flex-1 flex-col gap-2",
children: [
(0, r.jsx)("span", {
className:
"text-fg-muted flex items-center gap-1 text-sm",
children: "音色",
}),
(0, r.jsxs)("div", {
className: (0, o.cn)(
"flex h-8 items-center gap-2 rounded-lg border bg-transparent px-2.5",
p
? "border-border-default"
: "border-border-muted",
),
children: [
(0, r.jsx)("button", {
type: "button",
onClick: () => tS(tL),
disabled:
"none" === tL.id ||
!tL.previewUrl,
className:
"text-fg-muted hover:text-fg-default disabled:text-fg-disabled flex size-5 items-center justify-center transition-colors disabled:cursor-not-allowed",
children:
eA === tL.id
? (0, r.jsx)(V, {
width: 14,
height: 14,
})
: (0, r.jsx)(
l.Icons.audioPlayPending,
{ width: 14, height: 14 },
),
}),
(0, r.jsxs)("span", {
className:
"flex min-w-0 flex-1 items-center gap-1.5",
children: [
(0, r.jsx)("span", {
className: (0, o.cn)(
"truncate text-[13px]",
p
? "text-fg-default"
: "text-white/85",
),
children: tL.name,
}),
tL.official
? (0, r.jsx)("span", {
className: (0, o.cn)(
"shrink-0 rounded px-2 py-1 text-[12px] leading-none",
p
? "text-fg-muted bg-black/6"
: "bg-white/10 text-[#F7F7F7]",
),
children: "官方",
})
: null,
],
}),
],
}),
],
}),
(0, r.jsxs)("div", {
className: "flex flex-1 flex-col gap-2",
children: [
(0, r.jsx)("span", {
className: "text-fg-muted text-sm",
children: "标签",
}),
(0, r.jsx)("div", {
className: (0, o.cn)(
"text-fg-default flex h-8 items-center rounded-lg border bg-transparent px-3 text-[13px]",
p
? "border-border-default"
: "border-border-muted",
),
children: tM.name,
}),
],
}),
],
})
: (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsxs)("div", {
className: "flex flex-1 flex-col gap-2",
children: [
(0, r.jsxs)("span", {
className:
"text-fg-muted flex items-center gap-1 text-sm",
children: [
"音色",
(0, r.jsx)(W.CanvasTooltip, {
label:
"仅主体为人物时支持音色绑定和使用",
position: "top",
openDelay: 120,
zIndex: X,
children: (0, r.jsx)("button", {
type: "button",
className:
"text-fg-muted hover:text-fg-default flex size-4 cursor-help items-center justify-center rounded-full border-none bg-transparent p-0 transition-colors",
"aria-label": "音色使用说明",
children: (0, r.jsx)(
l.Icons.helpCircle,
{ width: 14, height: 14 },
),
}),
}),
],
}),
(0, r.jsx)(es, {
value: em,
onChange: eg,
options: tN,
onOpenChange: (e) => {
e ||
(eP.current?.pause(),
eP.current &&
(eP.current.currentTime = 0),
eF(null));
},
renderIcon: (e) => {
if ("none" === e.id)
return (0, r.jsx)(
l.Icons.audioNone,
{
width: 16,
height: 16,
className: "text-fg-default",
},
);
let t = eA === e.id,
i = t
? l.Icons.audioPlayPlaying
: l.Icons.audioPlayPending;
return (0, r.jsx)("span", {
role: "button",
tabIndex: 0,
onClick: (t) => {
t.stopPropagation(), tS(e);
},
onKeyDown: (t) => {
("Enter" === t.key ||
" " === t.key) &&
(t.preventDefault(),
t.stopPropagation(),
tS(e));
},
className:
"text-fg-default flex size-full items-center justify-center",
children: t
? (0, r.jsx)(V, {
width: 16,
height: 16,
})
: (0, r.jsx)(i, {
width: 16,
height: 16,
}),
});
},
footerAction: (0, r.jsxs)("button", {
type: "button",
onClick: (e) => {
e.stopPropagation(), tb(e);
},
className: (0, o.cn)(
"mx-1 flex h-10 cursor-pointer items-center gap-2 rounded-lg border-none bg-transparent px-2 text-left transition-colors",
p
? "hover:bg-black/6"
: "hover:bg-white/10",
),
children: [
(0, r.jsx)("div", {
className:
"flex size-6 shrink-0 items-center justify-center",
children: (0, r.jsx)(
l.Icons.plus,
{
width: 14,
height: 14,
className: "text-fg-muted",
},
),
}),
(0, r.jsx)("span", {
className:
"text-fg-default flex-1 text-[13px]",
children: "添加音色",
}),
],
}),
}),
],
}),
(0, r.jsxs)("div", {
className: "flex flex-1 flex-col gap-2",
children: [
(0, r.jsx)("span", {
className: "text-fg-muted text-sm",
children: "标签",
}),
(0, r.jsx)(es, {
value: ej,
onChange: ew,
options: tk,
placeholder: "请选择标签",
}),
],
}),
],
}),
}),
(0, r.jsxs)("div", {
className: "mt-5 flex flex-col gap-2",
children: [
(0, r.jsxs)("span", {
className: "text-fg-muted text-sm",
children: [
"主体描述 ",
(0, r.jsx)("span", {
className: "text-[#cf3336]",
children: "*",
}),
],
}),
(0, r.jsxs)("div", {
className: "h-25 relative",
children: [
(0, r.jsx)("textarea", {
value: ef,
onChange: (e) =>
ex(e.target.value.slice(0, 100)),
readOnly: s,
placeholder:
"描述主体的核心特征或者描述希望保留的细节,不超过100字",
maxLength: 100,
rows: 4,
className: (0, o.cn)(
"focus:border-brand-600 h-full w-full resize-none rounded-lg border bg-transparent px-3 py-2 text-xs leading-relaxed outline-none read-only:cursor-default",
p
? "border-border-default text-fg-default placeholder:text-fg-disabled read-only:border-border-default read-only:text-fg-default"
: "border-white/15 text-[#F7F7F7] placeholder:text-white/30 read-only:border-white/10 read-only:text-white/80",
),
}),
!s &&
(0, r.jsx)(W.CanvasTooltip, {
label:
"拖动视频进度条可对当前帧生成智能描述",
disabled: "video" !== x,
position: "top",
openDelay: 120,
zIndex: X,
children: (0, r.jsx)("span", {
className:
"absolute bottom-2 right-2 inline-flex",
children: (0, r.jsxs)("button", {
type: "button",
disabled: !tn || eU,
onClick: () => void tT(),
className: (0, o.cn)(
"flex h-8 shrink-0 items-center gap-1 rounded-lg px-2 transition-colors disabled:cursor-not-allowed",
p
? "enabled:text-fg-default disabled:text-fg-disabled enabled:bg-black/6 disabled:bg-black/4 enabled:hover:bg-black/10"
: "disabled:bg-white/4 enabled:bg-white/10 enabled:text-white/85 enabled:hover:bg-white/15 disabled:text-[#A8A8A8]",
),
"aria-busy": eU,
children: [
eU
? (0, r.jsx)(l.Icons.Loading, {
width: 14,
height: 14,
className:
"animate-spin text-current",
})
: (0, r.jsx)(l.Icons.SparkleF, {
width: 14,
height: 14,
className: "text-current",
}),
(0, r.jsx)("span", {
className:
"text-[13px] leading-none",
children: "智能生成",
}),
],
}),
}),
}),
],
}),
],
}),
],
}),
(0, r.jsx)("div", {
className:
"flex w-full shrink-0 items-end gap-3 px-4 pb-4 pt-2",
children: s
? (0, r.jsx)("button", {
type: "button",
onClick: tE,
className: (0, o.cn)(
"ml-auto flex h-8 cursor-pointer items-center rounded-lg border-none px-3 text-[13px] transition-colors",
p
? "text-fg-default bg-black/6 hover:bg-black/10"
: "bg-white/10 text-[#F7F7F7] hover:bg-white/15",
),
children: "关闭",
})
: (0, r.jsxs)(r.Fragment, {
children: [
eC
? (0, r.jsx)("div", {
className:
"min-w-0 flex-1 self-center pr-2",
children: (0, r.jsxs)("p", {
className: (0, o.cn)(
"text-xs leading-snug",
p ? "text-fg-subtle" : "text-white/50",
),
children: [
(0, r.jsx)("span", {
children: "失败原因:",
}),
eC,
],
}),
})
: null,
(0, r.jsxs)("div", {
className:
"ml-auto flex shrink-0 items-center gap-3",
children: [
(0, r.jsx)("button", {
type: "button",
onClick: tA,
disabled: eN,
className: (0, o.cn)(
"flex h-8 cursor-pointer items-center rounded-lg border-none px-3 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",
p
? "text-fg-default bg-black/6 hover:bg-black/10"
: "bg-white/10 text-[#F7F7F7] hover:bg-white/15",
),
children: "取消",
}),
(0, r.jsx)(P.Button, {
size: "xs",
radius: 8,
disabled: !tl,
loading: eN,
onClick: () => void tU(),
styles: {
root: {
height: 32,
paddingInline: 12,
backgroundColor: tl
? "#1f6dff"
: void 0,
color: tl ? "#ffffff" : void 0,
},
},
children: f ? "保存" : "创建",
}),
],
}),
],
}),
}),
],
}),
}),
}),
}),
!s &&
(0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsx)("input", {
ref: eL,
type: "file",
accept: "image/jpeg,image/png,image/webp",
multiple: !0,
style: { display: "none" },
onChange: (e) => void ts(e),
}),
(0, r.jsx)("input", {
ref: eM,
type: "file",
accept: "video/mp4,video/quicktime",
style: { display: "none" },
onChange: (e) => void tm(e),
}),
(0, r.jsx)("input", {
ref: eW,
type: "file",
accept:
".mp3,.wav,.mp4,.mov,audio/mpeg,audio/wav,audio/mp3,video/mp4,video/quicktime",
style: { display: "none" },
onChange: (e) => void tC(e),
}),
],
}),
eG &&
!s &&
(0, r.jsx)(T.Portal, {
children: (0, r.jsxs)("div", {
ref: eq,
style: {
...eG.style,
backgroundColor: "var(--canvas-controls-bg)",
},
className: `border-canvas-controls-border rounded-lg border p-1 shadow-lg ${p ? "canvas-light" : ""}`,
children: [
(0, r.jsx)("button", {
type: "button",
onClick: tv,
className:
"text-fg-default hover:bg-canvas-controls-hover w-full cursor-pointer rounded-md px-3 py-2 text-left text-xs transition-colors",
children: "本地上传",
}),
(0, r.jsx)("button", {
type: "button",
onClick: () => {
"voice" === eG.scope ? eX("voice") : eX(eG.type),
eJ(null);
},
className:
"text-fg-default hover:bg-canvas-controls-hover w-full cursor-pointer rounded-md px-3 py-2 text-left text-xs transition-colors",
children: "voice" === eG.scope ? "历史生成" : "历史图库",
}),
],
}),
}),
(0, r.jsx)(D.GalleryModal, {
opened: null !== eH,
onClose: () => eX(null),
onConfirm: tj,
maxSelect: "image" === eH ? Math.max(0, 4 - h.length) : 1,
allowedMediaType:
"voice" === eH
? ee
: "image" === eH || "video" === eH
? eH
: void 0,
zIndex: "calc(var(--z-overlay) + 20)",
}),
(0, r.jsx)(q, {
open: eZ,
onCancel: tI,
onConfirm: tF,
title: J,
description: H("generating" === eD.status),
}),
(0, r.jsx)(q, {
open: e0,
onCancel: tf,
onConfirm: tx,
title: "确定要删除参考图?",
description: (0, r.jsxs)(r.Fragment, {
children: [
(0, r.jsx)("p", {
children: "智能补全任务不会取消,积分不返还。",
}),
(0, r.jsx)("p", { children: "任务完成后将展示在历史记录。" }),
],
}),
overlayZIndex: "calc(var(--z-overlay) + 25)",
dialogZIndex: "calc(var(--z-overlay) + 26)",
}),
(0, r.jsx)(Y, {
referenceImageUrl: h[0]?.uploadedUrl ?? "",
smartCompletion: eD,
onConfirm: tz,
completionPowerDisplay: 6,
exitConfirmTitle: J,
exitConfirmDescription: H,
}),
],
});
}
e.s(["default", () => ec], 334642);
};
export default moduleFactory;