/* * Extracted from browser-delivered Turbopack chunk: fd0220e4d10052af.701bdafa2d.js * Module id: 767818 * 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(524961), r = e.i(41671), a = e.i(777784), o = e.i(944733), s = e.i(791997); let c = { backdropFilter: "blur(16px)", WebkitBackdropFilter: "blur(16px)", background: "rgba(0, 0, 0, 0.45)", border: "0.5px solid rgba(196, 196, 196, 0.6)", }, l = { backdropFilter: "blur(16px)", WebkitBackdropFilter: "blur(16px)", background: "rgba(255, 255, 255, 0.85)", border: "0.5px solid rgba(0, 0, 0, 0.12)", boxShadow: "0px 2px 6px rgba(0, 0, 0, 0.08)", }, u = { background: "none", border: "none", padding: 0 }, h = (0, n.memo)(function ({ taskInfo: e, className: n = "", children: i, onCancel: r, }) { let a = (0, s.useCanvasThemeStore)((e) => e.theme), o = !!e?.benefitTag, h = (function (e, t, n, i) { let r = t && t > 0 ? ` ${t}%` : ""; if (0 === e) { if (n && n.remainSeconds > 0) { var a; return `排队中,预计等待${"number" != typeof (a = n.remainSeconds) || isNaN(a) || a <= 0 ? "0秒" : a > 120 ? `${Math.ceil(a / 60)}分钟` : `${a}秒`}`; } return i ? `畅享0积分生成中${r}` : `生成中${r}...`; } return 1 === e ? i ? `畅享0积分生成中${r}` : `生成中${r}...` : `准备中${r}...`; })(e?.status, e?.progressPercent, e?.delayInfo, o); return (0, t.jsxs)("div", { className: `flex h-8 items-center justify-center gap-2.5 rounded-lg px-4 py-2 ${n}`, style: "light" === a ? l : c, children: [ (0, t.jsx)("span", { className: `whitespace-nowrap text-sm font-medium ${"light" === a ? "text-neutral-900" : "text-white"}`, children: h, }), r && (0, t.jsx)("button", { type: "button", className: `nodrag shrink-0 cursor-pointer whitespace-nowrap text-sm transition-colors ${"light" === a ? "text-neutral-400 hover:text-neutral-600" : "text-white/50 hover:text-white/80"}`, style: u, onClick: (e) => { e.stopPropagation(), r(); }, children: "取消", }), i, ], }); }); e.s(["default", 0, h], 276204); var f = e.i(963527), d = e.i(185264), p = e.i(409488), g = e.i(396805), b = e.i(299750), m = e.i(562530), w = e.i(216257), v = e.i(10036); let x = (0, g.createWithEqualityFn)((e) => ({ open: !1, nodeId: null, taskInfo: null, loading: !1, acceleratePower: null, throttledInfo: null, setOpen: (t, n) => e({ open: !0, nodeId: t, taskInfo: n, loading: !0, acceleratePower: null, throttledInfo: null, }), setClose: () => e({ open: !1, nodeId: null, taskInfo: null, loading: !1, acceleratePower: null, throttledInfo: null, }), setLoading: (t) => e({ loading: t }), setAcceleratePower: (t) => e({ acceleratePower: t }), setThrottledInfo: (t) => e({ throttledInfo: t }), })), y = new Set(); function _(e, t) { let i = (0, w.useCanvasStore)((e) => e.getNode), r = (0, w.useCanvasStore)((e) => e.updateNodeData), a = t.taskId, o = t.benefitTag; (0, n.useEffect)(() => { if (!a) return; let t = `${a}:${o ?? ""}`; if (y.has(t)) return; y.add(t); let n = !1; return ( (async () => { try { let t = await (0, b.calculatePowerBatch)( [{ taskId: a, disableBenefitTags: o ? [o] : void 0 }], 1, ); if (n) return; if (t?.code === 0 && t.data?.items?.length) { let n = t.data.items[0].power ?? 0, o = i(e), s = o?.data?.taskInfo; s?.taskId === a && r(e, { taskInfo: { ...s, acceleratePower: n } }); } } catch { y.delete(t); } })(), () => { n = !0; } ); }, [a, o, e, i, r]); } let S = "libtv_queue_switch_prompted_date"; function E() { let { setOpen: e, setClose: t, setAcceleratePower: i, setLoading: r, setThrottledInfo: a, } = x(), [o, s] = (0, n.useState)(!1), c = (0, w.useCanvasStore)((e) => e.updateNodeData), l = (0, w.useGlobalStore)((e) => e.getModel), u = (0, w.useCanvasStore)((e) => e.projectId); return { openSkipQueueDialog: (0, n.useCallback)( async (t, n) => { e(t, n); let o = null != n.acceleratePower; o && i(n.acceleratePower ?? 0); try { if (!o) { let e = await (0, b.calculatePowerBatch)( [ { taskId: n.taskId, disableBenefitTags: n.benefitTag ? [n.benefitTag] : void 0, }, ], 1, ); e?.code === 0 && e.data?.items?.length && i(e.data.items[0].power ?? 0); } let e = w.stores.canvas; if (e) { let t = []; for (let i of e.nodes) { let e = i.data, r = e?.taskInfo; r?.taskId && r.taskId !== n.taskId && 0 === r.status && r.delayInfo && r.delayInfo.remainSeconds > 0 && t.push({ taskId: r.taskId, disableBenefitTags: r.benefitTag ? [r.benefitTag] : void 0, }); } if (t.length > 0) { t.unshift({ taskId: n.taskId, disableBenefitTags: n.benefitTag ? [n.benefitTag] : void 0, }); let i = 0; try { let e = await (0, b.calculatePowerBatch)(t, 1); if (e?.code === 0 && e.data?.items) for (let t of e.data.items) i += t.power; } catch { for (let n of t) { let t = e.nodes.find((e) => { let t = e.data; return t?.taskInfo?.taskId === n.taskId; }); i += t?.data?.taskInfo?.acceleratePower ?? 0; } } let r = t.map((e) => e.taskId); a({ count: r.length, taskIds: r, totalCostPower: i }); } } } catch { } finally { r(!1); } }, [e, t, i, r, a], ), confirmSkipQueue: (0, n.useCallback)( async (e, n) => { let { nodeId: i, taskInfo: r, throttledInfo: a, acceleratePower: o, } = x.getState(); if (!i || !r) return; let h = "batch" === e && a ? a.totalCostPower : (o ?? 0), g = d.useUserVipInfo.getState().vipInfo; if ( h > (g?.attr?.totalPower || 0) - (g?.attr?.usedPower || 0) + (g?.attr?.libtvUsablePower || 0) ) return void (0, f.openVipModel)({ intent: "purchase_vip", isShowChargePop: !0, chargeType: 1, }); s(!0); try { let t, i = "batch" === e && a ? a.taskIds : [r.taskId]; n && (await (0, p.disableRateLimitBenefit)(1), await d.useUserVipInfo.getState().syncUserBenefits()); let o = w.stores.canvas, s = []; for (let e of i) { if (!o) continue; let t = o.nodes.find((t) => { let n = t.data; return n?.taskInfo?.taskId === e; }); if (!t) continue; let n = (0, v.getGeneratorTypeFromNode)(t); if (!n) continue; let i = t.data, r = i.taskInfo, a = i.params ?? {}, c = (0, v.buildRequestData)(a, n, t.id, u, l); r?.benefitTag && (c.disableBenefitTags = [r.benefitTag]), (c.infiniteSwitch = 1), s.push({ targetNodeId: t.id, oldTaskId: e, requestData: c }); } let h = await (function (e, t = 3) { return new Promise((n) => { let i = Array(e.length), r = 0, a = 0, o = Math.min(t, e.length); for (let t = 0; t < o; t++) !(function t() { if (r >= e.length) return; let o = r++; e[o]() .then((e) => { i[o] = e; }) .catch(() => { i[o] = void 0; }) .finally(() => { ++a === e.length ? n(i) : t(); }); })(); }); })( s.map( (e) => async () => ( await (0, b.stopTaskBatch)([e.oldTaskId]), (0, m.submitGenerationTask)(e.requestData) ), ), 3, ); for (let e = 0; e < s.length; e++) { let t = h[e]; t?.success && t.taskId && c(s[e].targetNodeId, { taskInfo: { taskId: t.taskId, loading: !0, status: 0 }, }); } ((t = localStorage.getItem(S)) && t === new Date().toDateString()) || localStorage.setItem(S, new Date().toDateString()); } finally { s(!1), t(); } }, [u, l, c, t], ), switching: o, }; } e.s( [ "useAutoThrottledCost", () => _, "useSkipQueue", () => E, "useSkipQueueDialogStore", 0, x, ], 767818, ); let M = (0, n.memo)(function ({ nodeId: e, taskInfo: n, className: i = "", }) { let { openSkipQueueDialog: a } = E(); return ( _(e, n), (0, t.jsxs)("button", { type: "button", className: `flex h-8 items-center justify-center gap-2.5 rounded-lg px-4 py-2 ${i}`, style: { backdropFilter: "blur(16px)", WebkitBackdropFilter: "blur(16px)", background: "rgba(0, 0, 0, 0.45)", border: "0.5px solid rgba(196, 196, 196, 0.6)", }, onClick: () => { a(e, n); }, children: [ (0, t.jsx)("span", { className: "whitespace-nowrap text-sm font-medium text-white", children: "立即加速", }), (0, t.jsx)(r.Icons.LightningF, { width: 14, height: 14, color: "#FFB800", }), null != n.acceleratePower && (0, t.jsx)("span", { className: "whitespace-nowrap text-sm font-medium text-white", children: n.acceleratePower, }), ], }) ); }); function T(e) { if (e?.loading !== !0) return !1; if (void 0 === e.status || null === e.status) return !0; var t = e.status; if (0 === t || 1 === t || "0" === t || "1" === t) return !0; let n = Number(t); return 0 === n || 1 === n; } function k(e) { return e?.status === 3 && e?.loading === !1; } let C = (0, n.memo)(function ({ taskInfo: e, onRetry: s, hasContent: c = !1, nodeId: l, onCancel: u, onViewDetail: f, }) { let d = (0, n.useRef)(e); d.current = e; let p = (0, n.useCallback)(() => { if (!u) return; let e = d.current?.progressPercent, n = e && e > 0 ? `(${e}%)` : ""; (0, o.confirm)({ title: "取消生成", message: (0, t.jsxs)(t.Fragment, { children: [ "正在生成中", n, ",即将完成!", (0, t.jsx)("br", {}), "停止将不退还已消耗算力。", ], }), confirmText: "确定", cancelText: "取消", onConfirm: u, }); }, [u]); if (k(e)) return (0, t.jsxs)("div", { className: "flex h-full flex-col items-center justify-center gap-3", children: [ (0, t.jsxs)("svg", { width: 36, height: 36, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", className: "canvas-light:text-red-500 text-red-400", children: [ (0, t.jsx)("path", { d: "M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", }), (0, t.jsx)("line", { x1: "12", y1: "9", x2: "12", y2: "13" }), (0, t.jsx)("line", { x1: "12", y1: "17", x2: "12.01", y2: "17", }), ], }), (0, t.jsx)("span", { className: "canvas-light:text-red-500 text-sm font-medium text-red-400", children: "生成失败", }), e?.failedReason && (0, t.jsx)("span", { className: "canvas-light:text-neutral-500 max-w-[90%] text-center text-xs leading-tight text-white/50", children: e.failedReason, }), e?.taskId && (0, t.jsxs)("span", { className: "canvas-light:text-neutral-400 flex max-w-[90%] items-center gap-1 text-[10px] text-white/30", children: [ (0, t.jsxs)("span", { className: "truncate", title: e.taskId, children: ["TaskID: ", e.taskId], }), (0, t.jsx)("button", { type: "button", className: "nodrag canvas-light:text-neutral-400 canvas-light:hover:bg-black/5 canvas-light:hover:text-neutral-600 shrink-0 rounded p-0.5 text-white/30 transition-colors hover:bg-white/10 hover:text-white/60", onClick: () => { navigator.clipboard.writeText(e.taskId).then( () => a.Notify.success("TaskID 已复制"), () => a.Notify.error("复制失败"), ); }, children: (0, t.jsx)(r.Icons.copy, { width: 12, height: 12, }), }), ], }), f && e?.failedReason?.includes("参考图可能包含真人形象") && (0, t.jsx)("button", { type: "button", className: "nodrag canvas-light:text-neutral-500 canvas-light:hover:text-neutral-700 flex h-[28px] w-[76px] items-center justify-center rounded text-[10px] text-white/50 transition-colors hover:text-white/80", onClick: f, children: "查看详情", }), s && (0, t.jsx)(i.Button, { onClick: s, variant: "light", color: "red", size: "xs", radius: "xl", children: "重新生成", }), ], }); if (!T(e)) return null; let g = e?.status === 0 && (e?.delayInfo?.remainSeconds ?? 0) > 0, b = g && l && e, m = u ? (g ? u : p) : void 0; return c ? (0, t.jsxs)("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center rounded-xl p-4", children: [ (0, t.jsx)("div", { className: "generating-breathing-dark absolute inset-0 rounded-xl", }), (0, t.jsxs)("div", { className: "group pointer-events-auto relative z-10 flex w-full max-w-[min(100%,280px)] flex-col items-center gap-2", children: [ b ? (0, t.jsx)(M, { nodeId: l, taskInfo: e }) : null, (0, t.jsx)(h, { taskInfo: e, onCancel: m }), ], }), ], }) : (0, t.jsxs)("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 p-4", children: [ (0, t.jsx)("div", { className: "generating-breathing-grey absolute inset-0 rounded-xl", }), (0, t.jsxs)("div", { className: "group pointer-events-auto relative z-10 flex w-full max-w-[min(100%,280px)] flex-col items-center gap-2", children: [ b ? (0, t.jsx)(M, { nodeId: l, taskInfo: e }) : null, (0, t.jsx)(h, { taskInfo: e, onCancel: m }), ], }), ], }); }); e.s( ["default", 0, C, "isTaskFailed", () => k, "isTaskGenerating", () => T], 959248, ); }; export default moduleFactory;