PageSourceSearch

https://www.fatkun.net/_next/static/chunks/37885-910c2fc1b711b65e.js

js fatkun.net collected 2026-10-02 00:23:17 UTC 33,130 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[37885],{21611:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(47032).A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},27568:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(47032).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},31031:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(47032).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},37424:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(47032).A)("expand",[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}],["path",{d:"M3 16v5h5",key:"1t08am"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 8V3h5",key:"1ln10m"}],["path",{d:"M9 9 3 3",key:"v551iv"}]])},37885:(e,t,a)=>{a.d(t,{C:()=>S});var s=a(23732),r=a(92824),l=a(52885),i=a(87556),n=a(27568),o=a(37861),d=a(24266),c=a(41093),m=a(48467),g=a(67848),p=a(58356),u=a(21611),h=a(31031),x=a(59285),f=a(39323),b=a(86697),j=a(51222),v=a(37424),y=a(8296);let w={all:"全部",general:"通用背景",beauty:"美妆护肤",food:"食品饮料",home:"家居生活",clothing:"服饰鞋包",digital:"数码家电",seasonal:"季节节日",realistic:"实拍写实"},N=[{id:"general-pure-white",category:"general",name:"纯白无影",thumbnail:"/images/scene-presets/gen-white.png",prompt:"产品摄影,纯白色干净背景,无阴影,摄影棚灯光,商业目录风格,极简",negativePrompt:"杂乱背景,暗色,阴影"},{id:"general-podium-white",category:"general",name:"白色展台",thumbnail:"/images/scene-presets/gen-podium-white.png",prompt:"产品摄影,白色圆形展台,干净白色背景,柔和阴影,摄影棚灯光,极简商业摄影"},{id:"general-podium-morandi",category:"general",name:"莫兰迪展台",thumbnail:"/images/scene-presets/gen-morandi.png",prompt:"产品摄影,几何形状展台,莫兰迪色调,柔和艺术灯光,优雅阴影,抽象构图"},{id:"general-gradient",category:"general",name:"渐变色彩",thumbnail:"/images/scene-presets/gen-gradient.png",prompt:"产品摄影,从浅蓝到淡紫的平滑渐变背景,摄影棚灯光,干净专业"},{id:"general-nature-light",category:"general",name:"自然光影",thumbnail:"/images/scene-presets/gen-nature.png",prompt:"产品摄影,天然石材纹理表面,透过树叶的斑驳阳光,户外自然氛围,有机质感"},{id:"general-fabric",category:"general",name:"布艺纹理",thumbnail:"/images/scene-presets/gen-fabric.png",prompt:"产品摄影,柔软亚麻布料纹理背景,温暖中性色调,自然褶皱,温暖柔和灯光,优雅"},{id:"general-concrete",category:"general",name:"水泥工业",thumbnail:"/images/scene-presets/gen-concrete.png",prompt:"产品摄影,工业风水泥墙壁背景,原始水泥纹理,冷灰色调,戏剧性侧光,现代极简"},{id:"beauty-marble",category:"beauty",name:"高级大理石",thumbnail:"/images/scene-presets/beauty-marble.png",prompt:"产品摄影,大理石展台,柔和灯光,优雅氛围,高品质,极简,奢华感",negativePrompt:"杂乱背景,暗色,低质量"},{id:"beauty-water",category:"beauty",name:"清透水面",thumbnail:"/images/scene-presets/beauty-water.png",prompt:"产品摄影,水面上,涟漪,清新,蓝色调,明亮自然光线,清澈水面"},{id:"beauty-flower",category:"beauty",name:"鲜花簇拥",thumbnail:"/images/scene-presets/beauty-flower.png",prompt:"产品摄影,被柔和淡色鲜花环绕,浪漫氛围,柔焦背景,自然光,优雅"},{id:"beauty-rose",category:"beauty",name:"玫瑰花瓣",thumbnail:"/images/scene-preset
1s/beauty-rose.png",prompt:"产品摄影,散落的粉色玫瑰花瓣,柔和浪漫灯光,丝绸面料衬底,奢华美妆风格"},{id:"beauty-velvet",category:"beauty",name:"丝绒质感",thumbnail:"/images/scene-presets/beauty-velvet.png",prompt:"产品摄影,深色丝绒面料背景,酒红或深蓝色,丰富纹理,戏剧性聚光灯,奢华化妆品"},{id:"food-wooden",category:"food",name:"温馨木纹",thumbnail:"/images/scene-presets/food-wooden.png",prompt:"产品摄影,木质桌面上,温暖阳光,窗户光影,温馨氛围,厨房场景,美味"},{id:"food-picnic",category:"food",name:"户外野餐",thumbnail:"/images/scene-presets/food-picnic.png",prompt:"产品摄影,户外野餐场景,草地上,格子布,晴天,自然光线,清新户外氛围"},{id:"food-dark",category:"food",name:"暗调质感",thumbnail:"/images/scene-presets/food-dark.png",prompt:"产品摄影,深色背景,戏剧性灯光,石板纹理,专业美食摄影,暗调氛围"},{id:"food-marble-counter",category:"food",name:"大理石台面",thumbnail:"/images/scene-presets/food-marble.png",prompt:"产品摄影,白色大理石厨房台面,明亮干净氛围,散落新鲜香草,自然日光,高级食品"},{id:"food-japanese",category:"food",name:"日式和风",thumbnail:"/images/scene-presets/food-japanese.png",prompt:"产品摄影,日式极简风格,木质托盘,竹席,禅意氛围,柔和自然光,侘寂美学"},{id:"home-living-room",category:"home",name:"现代客厅",thumbnail:"/images/scene-presets/home-living.png",prompt:"产品摄影,现代客厅背景,沙发在背景中,柔和阳光,温馨家居氛围,室内设计"},{id:"home-bedside",category:"home",name:"舒适床头",thumbnail:"/images/scene-presets/home-bedside.png",prompt:"产品摄影,床头柜场景,虚化卧室背景,温暖台灯光线,舒适温馨氛围"},{id:"home-kitchen",category:"home",name:"洁净厨房",thumbnail:"/images/scene-presets/home-kitchen.png",prompt:"产品摄影,现代白色厨房台面,干净明亮,大理石台面,背景虚化的厨房置物架"},{id:"home-nordic",category:"home",name:"北欧极简",thumbnail:"/images/scene-presets/home-nordic.png",prompt:"产品摄影,北欧极简室内,白色墙壁,浅色木质家具,简约绿植,柔和自然散射光,干净美学"},{id:"home-bathroom",category:"home",name:"浴室清爽",thumbnail:"/images/scene-presets/home-bathroom.png",prompt:"产品摄影,洁净白色浴室,大理石表面,新鲜毛巾,SPA氛围,明亮通透,蒸汽感,放松"},{id:"clothing-street",category:"clothing",name:"街头潮流",thumbnail:"/images/scene-presets/cloth-street.png",prompt:"产品摄影,城市街道背景,虚化城市景深,自然日光,生活方式摄影"},{id:"clothing-studio",category:"clothing",name:"极简影棚",thumbnail:"/images/scene-presets/cloth-studio.png",prompt:"产品摄影,专业摄影棚背景,灰色无缝纸,柔光箱灯光,时尚摄影风格"},{id:"digital-tech",category:"digital",name:"科技几何",thumbnail:"/images/scene-presets/digital-tech.png",prompt:"产品摄影,几何形状,科技氛围,霓虹灯光点缀,深蓝和紫色调,未来感,3D渲染风格"},{id:"digital-desk",category:"digital",name:"办公桌面",thumbnail:"/images/scene-presets/digital-desk.png",prompt:"产品摄影,极简办公桌,笔记本电脑和绿植在背景中,柔和日光,专业工作空间"},{id:"digital-neon",category:"digital",name:"未来光效",thumbnail:"/images/scene-presets/digital-neon.png",prompt:"产品摄影,深色背景搭配鲜艳霓虹光轨,赛博朋克氛围,蓝紫色发光,未来科技产品"},{id:"digital-accessories",category:"digital",name:"桌面配件",thumbnail:"/images/scene-presets/digital-accessories.png",prompt:"产品摄影,整洁桌面搭配科技配件,无线充电器,耳机,现代工作空间美学,温暖LED灯光"},{id:"seasonal-spring",category:"seasonal",name:"春日花海",thumbnail:"/images/scene-presets/seasonal-spring.png",prompt:"产品摄影,春天樱花背景,柔和粉色花瓣飘落,温暖阳光,清新活力氛围,梦幻散景"},{id:"seasonal-christmas",category:"seasonal",name:"圣诞装饰",thumbnail:"/images/scene-preset
1s/seasonal-christmas.png",prompt:"产品摄影,圣诞装饰背景,松树枝,红色和金色装饰品,温暖闪烁灯光,节日温馨氛围"},{id:"seasonal-cny",category:"seasonal",name:"新年喜庆",thumbnail:"/images/scene-presets/seasonal-cny.png",prompt:"产品摄影,中国新年庆典背景,红色和金色配色,灯笼,梅花,喜庆欢乐氛围"}];function k(e){let{selectedSceneId:t,onSelect:a,suggestions:l,suggestionsLoading:i,onSelectSuggestion:n}=e,o=(0,f.c)("background_generation"),[c,m]=(0,r.useState)("all"),[g,p]=(0,r.useState)(!1),[u,b]=(0,r.useState)(null),[k,_]=(0,r.useState)("medium"),U=Object.entries(w),C="all"===c?N:N.filter(e=>e.category===c),R=N.find(e=>e.id===t);return(0,s.jsxs)("div",{className:"space-y-5",children:[(l&&l.length>0||i)&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"flex items-center gap-1.5 text-sm font-semibold mb-2",children:[(0,s.jsx)(h.A,{className:"w-4 h-4 text-yellow-500"}),"智能推荐",i&&(0,s.jsx)(d.A,{className:"w-3 h-3 animate-spin text-muted-foreground ml-1"})]}),i?(0,s.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3,4,5,6].map(e=>(0,s.jsx)("div",{className:"flex-shrink-0 w-[120px] h-[56px] rounded-lg bg-muted animate-pulse"},e))}):l&&l.length>0?(0,s.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-2",children:l.map(e=>(0,s.jsxs)("button",{onClick:()=>null==n?void 0:n(e),className:"flex-shrink-0 flex items-center gap-2 px-3 py-2.5 rounded-lg border border-yellow-200 bg-yellow-50/50 hover:bg-yellow-100/80 hover:border-yellow-300 transition-all text-xs group",children:[(0,s.jsx)("span",{className:"text-base",children:e.emoji}),(0,s.jsx)("span",{className:"font-medium text-yellow-900 group-hover:text-yellow-800 whitespace-nowrap",children:e.name})]},e.id))}):null]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-3",children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 flex-1",children:U.map(e=>{let[t,a]=e;return(0,s.jsx)(x.Ex,{variant:c===t?"default":"outline",className:"cursor-pointer hover:shadow-sm transition-all text-xs",onClick:()=>m(t),children:o("cat_"+t)},t)})}),(0,s.jsxs)(x.$n,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground flex-shrink-0",onClick:()=>p(!0),children:[(0,s.jsx)(v.A,{className:"w-3 h-3 mr-1"})," ",o("view_all")]})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 max-h-[360px] overflow-y-auto pr-1",children:C.map(e=>(0,s.jsxs)("button",{onClick:()=>a(e),onMouseEnter:()=>b(e),onMouseLeave:()=>b(null),className:(0,x.cn)("group relative aspect-square rounded-lg overflow-hidden border-2 transition-all hover:shadow-md",t===e.id?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-primary/50"),children:[(0,s.jsxs)("div",{className:"absolute inset-0 bg-muted flex items-center justify-center",children:[(0,s.jsx)(j.default,{src:e.thumbnail,alt:e.name,fill:!0,unoptimized:!0,sizes:"(max-width: 640px) 33vw, (max-width: 768px) 25vw, 20vw",className:"object-cover"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-trans
1parent to-transparent"})]}),(0,s.jsx)("span",{className:"absolute bottom-1 left-1 right-1 text-[10px] font-medium text-white text-center truncate",children:o("preset_"+e.id)}),t===e.id&&(0,s.jsx)("div",{className:"absolute top-1 right-1 w-4 h-4 bg-primary rounded-full flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-2.5 h-2.5 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]},e.id))})]}),g&&(0,s.jsx)("div",{className:"fixed inset-0 z-[100] bg-black/80 flex items-center justify-center p-4 backdrop-blur-sm",onClick:()=>p(!1),children:(0,s.jsxs)("div",{className:"relative max-w-[90vw] w-[1400px] h-[85vh] bg-background rounded-xl overflow-hidden shadow-2xl flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"p-4 border-b flex justify-between items-center bg-muted/30 shrink-0",children:[(0,s.jsxs)("h3",{className:"font-semibold text-lg flex items-center gap-2",children:[(0,s.jsx)(h.A,{className:"w-5 h-5 text-primary"})," ",o("gallery_presets")]}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("div",{className:"flex bg-muted rounded-md p-1 border shadow-sm",children:[(0,s.jsx)("button",{onClick:()=>_("small"),className:(0,x.cn)("px-3 text-xs py-1 rounded transition-colors","small"===k?"bg-background shadow-sm font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:"S"}),(0,s.jsx)("button",{onClick:()=>_("medium"),className:(0,x.cn)("px-3 text-xs py-1 rounded transition-colors","medium"===k?"bg-background shadow-sm font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:"M"}),(0,s.jsx)("button",{onClick:()=>_("large"),className:(0,x.cn)("px-3 text-xs py-1 rounded transition-colors","large"===k?"bg-background shadow-sm font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:"L"})]}),(0,s.jsx)(x.$n,{variant:"ghost",size:"icon",onClick:()=>p(!1),children:(0,s.jsx)(y.A,{className:"w-5 h-5"})})]})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-hidden flex",children:[(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-6 bg-muted/10 custom-scrollbar",children:(0,s.jsx)("div",{className:"space-y-8",children:U.filter(e=>{let[t]=e;return"all"!==t}).map(e=>{let[r,l]=e,i=N.filter(e=>e.category===r);return 0===i.length?null:(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"font-medium text-base mb-4 flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-1 h-4 bg-primary rounded-full"}),o("cat_"+r)]}),(0,s.jsx)("div",{className:(0,x.cn)("grid gap-6","small"===k&&"grid-cols-4 sm:grid-cols-5 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10 gap-3","medium"===k&&"grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8 gap-4","large"===k&&"grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-6"),children:i.map(e=>(0,s.jsxs)("button",{onClick:()=>{a(e)},className:(0,x.cn)("group relative aspect-square rounded-lg overflow-hidden border-2 transition-all hover:shadow-lg",t===e.id?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-primary/50"),children:[(0,s.jsxs)("div",{className:"absolute inset-0 bg-muted flex items-center justify-center",children:[(0,s.jsx)(j.default,{src:e.thumbnail,alt:e.name,fill:!0,unoptimized:!0,sizes:"(max-width: 640px) 33vw, (max-width: 768px) 25vw, 15vw",className:"object-cover group-hover:scale-110 transition-transform duration-300"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent opacity-90 group-hover:opacity-100 transition-opacity"})]}),(0,s.jsx)("span",{className:"absolute bottom-2 left-1 right-1 text-xs font-medium text-white text-center truncate",children:o("preset_"+e.id)}),t===e.id&&(0,s.jsx)("div",{className:"absolute top-1.5 right-1.5 w-5 h-5 bg-primary rounded-full flex items-center justify-center shadow-md",children:(0,s.jsx)("svg",{className:"w-3 h-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]},e.id))})]},r)})})}),(0,s.jsx)("div",{className:"w-[320px] lg:w-[400px] bg-card border-l flex flex-col p-6 overflow-y-auto",children:R?(0,s.jsxs)("div",{className:"flex flex-col h-full animate-in fade-in zoom-in-95 duration-200",children:[(0,s.jsxs)("h4",{className:"font-semibold text-lg mb-4 flex items-center gap-2",children:[(0,s.jsx)(h.A,{className:"w-5 h-5 text-primary"}),o("scene_details")]}),(0,s.jsx)("div",{className:"aspect-square relative rounded-xl overflow-hidden border shadow-sm mb-6 bg-muted/20",children:(0,s.jsx)(j.default,{src:R.thumbnail,alt:R.name,fill:!0,unoptimized:!0,sizes:"400px",className:"object-cover"})}),(0,s.jsxs)("div",{className:"mb-6 flex-1",children:[(0,s.jsxs)("h3",{className:"text-xl font-bold mb-3 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-2xl",children:R.emoji})," ",o("preset_"+R.id)]}),(0,s.jsx)(x.Ex,{variant:"secondary",className:"mb-4",children:o("cat_"+R.category)}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:o("prompt_label")}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground leading-relaxed bg-muted/30 p-3 rounded-lg border",children:o("prompt_"+R.id)})]})]}),(0,s.jsx)(x.$n,{size:"lg",className:"w-full shadow-sm",onClick:()=>p(!1),children:o("confirm_use")})]}):(0,s.jsxs)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm flex-col gap-4",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-full bg-muted/50 flex items-center justify-center",children:(0,s.jsx)(h.A,{className:"w-8 h-8 opacity-20"})}),(0,s.jsx)("p",{children:o("please_select_scene")})]})})]})]})}),u&&(0,s.jsxs)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[200] pointer-events-none w-[400px] h-[400px] bg-background rounded-2xl overflow-hidden shadow-2xl border-4 border-muted",children:[(0,s.jsx)(j.default,{src:u.thumbnail,alt:u.name,fill:!0,unoptimized:!0,sizes:"400px",className:"object-cover"}),(0,s.jsx)("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent p-4 pt-12",children:(0,s.jsx)("h4",{className:"text-white text-lg font-bold text-center",children:u.name})})]})]})}var _=a(22530),U=a(88e3),C=a(69495),R=a(24751);function S(e){let{className:t}=e,a=(0,f.c)("background_generation"),j=(0,f.c)("image_tools_common"),v=(0,b.Ym)(),[y,w]=(0,r.useState)("wan"),[N,S]=(0,r.useState)(null),[A,L]=(0,r.useState)(""),[z,E]=(0,r.useState)([]),[M,O]=(0,r.useState)(!1),[P,$]=(0,r.useState)(null),[F,D]=(0,r.useState)([]),[I,q]=(0,r.useState)(!1),[T,W]=(0,r.useState)(!1),B=(0,r.useRef)(null),Z=z.length>0,V=A.trim().length>0,H=(0,r.useCallback)(e=>{let t=Array.from(e).filter(e=>e.type.startsWith("image/")).map(e=>({id:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),file:e,originalUrl:URL.createObjectURL(e),aiStatus:"idle"}));E(e=>[...e,...t])},[]),J=e=>{e.target.files&&e.target.files.length>0&&H(e.target.files),e.target.value=""},Y=(0,r.useCallback)(async()=>
1{if(0!==z.length){q(!0),D([]);try{let e=z.slice(0,5),t=await Promise.all(e.map(e=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:512;return new Promise((a,s)=>{let r=new Image,l=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(l);let e=document.createElement("canvas"),{width:i,height:n}=r;i>n?i>t&&(n=Math.round(n*t/i),i=t):n>t&&(i=Math.round(i*t/n),n=t),e.width=i,e.height=n;let o=e.getContext("2d");if(!o)return s(Error("Failed to get canvas context"));o.drawImage(r,0,0,i,n),a(e.toDataURL("image/jpeg",.6))},r.onerror=()=>{URL.revokeObjectURL(l),s(Error("Failed to load image for resize"))},r.src=l})})(e.file))),a=await fetch("/api/ai/background-suggest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({images:t,locale:v}),credentials:"include"}),s=await a.json();s.suggestions&&Array.isArray(s.suggestions)&&D(s.suggestions)}catch(e){console.warn("AI suggestion failed:",e)}finally{q(!1)}}},[z]),K=(0,r.useCallback)(async(e,t)=>{var s,r,l,i;E(t=>t.map(t=>
1t.id===e.id?{...t,aiStatus:"processing",aiError:void 0}:t));try{let r="";if(C.xq[y]){let l=await (s=e.file,new Promise((e,t)=>{let a=new FileReader;a.onload=()=>e(a.result),a.onerror=t,a.readAsDataURL(s)})),i=await U.i.gemini.generateImage.mutate({prompt:"将这张产品图片的背景替换为:".concat(t,"。保持产品本身完全不变。在产品下方添加自然真实的阴影。专业商业产品摄影风格。"),image:l,model:y,source:"AI背景生成"});if(!i.image)throw Error(i.text||a("error_generate_failed"));r=i.image}else{let s=await function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2048;return new Promise((a,s)=>{let r=new Image,l=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(l);let{width:i,height:n}=r;if(i>n?i>t&&(n=Math.round(n*t/i),i=t):n>t&&(i=Math.round(i*t/n),n=t),i===r.width&&n===r.height)return a(e);let o=document.createElement("canvas");o.width=i,o.height=n;let d=o.getContext("2d");if(!d)return s(Error("Failed to get canvas context"));d.drawImage(r,0,0,i,n);let c="image/png"===e.type?"image/png":"image/jpeg";o.toBlob(t=>{if(!t)return s(Error("Canvas to Blob failed"));a(new File([t],e.name,{type:c,lastModified:Date.now()}))},c,.92)},r.onerror=()=>{URL.revokeObjectURL(l),s(Error("Failed to load image for resize"))},r.src=l})}(e.file,2048),l=new FormData;l.append("file",s);let i=await fetch("/api/upload",{method:"POST",body:l}),n=await i.json();if(!n.success)throw Error(n.error||a("error_upload_failed"));let o={imageUrl:n.url,backgroundPrompt:t,engine:"wan2.7"};(null==N?void 0:N.negativePrompt)&&(o.negativePrompt=a("neg_prompt_"+N.id));let d=await fetch("/api/ai/background-generation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),credentials:"include"}),c=await d.json();if(!c.success)throw Error(c.error||a("error_generate_failed"));r=c.data.url}E(t=>t.map(t=>t.id===e.id?{...t,aiStatus:"done",aiResultUrl:r}:t))}catch(n){let t=n.message||(null==(r=n.data)?void 0:r.message)||"",s=(null==(l=n.data)?void 0:l.code)==="UNAUTHORIZED"?a("error_need_login"):(null==(i=n.data)?void 0:i.code)==="PAYMENT_REQUIRED"?a("error_no_credits"):t.length>100?t.substring(0,100)+"...":t||a("error_generate_failed");if(E(t=>t.map(t=>t.id===e.id?{...t,aiStatus:"error",aiError:s}:t)),s.includes(a("error_no_credits")))throw n}},[y,N]),Q=(0,r.useCallback)(async()=>{if(!V)return void $(a("error_need_prompt"));let e=A.trim(),t=z.filter(e=>"idle"===e.aiStatus||"error"===e.aiStatus);if(0===t.length)return;O(!0),$(null);let s=y.startsWith("wan")?5:3,r=!1,l=[...t],i=[];try{for(;(l.length>0||i.length>0)&&!r;){for(;i.length<s&&l.length>0;){let t=l.shift(),s=K(t,e).catch(e=>{var t;if(null==e||null==(t=e.message)?void 0:t.includes(a("error_no_credits"))){r=!0;let e=l.map(e=>e.id);E(t=>t.map(t=>e.includes(t.id)?{...t,aiStatus:"idle"}:t)),l.length=0,$("积分不足,已停止后续生成")}}).finally(()=>{i.splice(i.indexOf(s),1)});i.push(s)}i.length>0&&await Promise.race(i)}}finally{O(!1)}},[z,A,K,y,V]),G=(0,r.useCallback)(async e=>{if(!V)return void $(a("error_need_prompt"));let t=z.find(t=>t.id===e);t&&($(null),K(t,A.trim()))},[V,z,K,A]),X=async(e,t,a)=>{try{let s=await fetch(e),r=await s.blob(),l=URL.createObjectURL(r),i=document.createElement("a");i.href=l;let n="";a&&(n=a.replace(/\.[^/.]+$/,"")+"-"),i.download="fiktu-".concat(t,"-").concat(n).concat(Date.now(),".png"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(l),1e3)}catch(t){window.open(e,"_blank")}},ee=async()=>{for(let e of z.filter(e=>"done"===e.aiStatus&&e.aiResultUrl))await X(e.aiResultUrl,"bg",e.file.name),await new Promise(e=>setTimeout(e,300))},[et,ea]=(0,r.useState)(null);return(0,s.jsxs)("div",{className:(0,x.cn)("w-full",t),children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6",children:[(0,s.jsx)("div",{className:"lg:col-span-7 xl:col-span-8 space-y-4 lg:sticky lg:top-6 lg:self-start",children:(0,s.jsx)(x.Zp,{className:(0,x.cn)("min-h-[400px]",!Z&&"flex items-center justify-center border-dashed"),children:Z?(0,s.jsxs)(x.Wu,{className:"p-4 flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4 pb-2 border-b",children:[(0,s.jsx)("h3",{className:"font-semibold text-sm flex items-center gap-2",children:a("uploaded_count",{count:z.length})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[z.some(e=>"done"===e.aiStatus)&&(0,s.jsxs)(x.$n,{size:"sm",onClick:ee,className:"bg-green-600 hover:bg-green-700 text-white shadow-sm mr-2",children:[(0,s.jsx)(i.A,{className:"w-4 h-4 mr-1"})," ",a("download_all")," (",z.filter(e=>"done"===e.aiStatus&&e.aiResultUrl).length,")"]}),(0,s.jsxs)(x.$n,{variant:"outline",size:"sm",onClick:()=>{var e;return null==(e=B.current)?void 0:e.click()},disabled:M,children:[(0,s.jsx)(n.A,{className:"w-4 h-4 mr-1"})," ",a("add_more")]}),(0,s.jsx)("input",{ref:B,type:"file",multiple:!0,className:"hidden",accept:"image/*",onChange:J}),(0,s.jsxs)(x.$n,{variant:"ghost",size:"sm",onClick:()=>
1{z.forEach(e=>{URL.revokeObjectURL(e.originalUrl),e.aiResultUrl&&URL.revokeObjectURL(e.aiResultUrl)}),E([]),ea(null)},disabled:M,className:"text-destructive hover:text-destructive/90 hover:bg-destructive/10",children:[(0,s.jsx)(o.A,{className:"w-4 h-4 mr-1"})," ",a("clear_all")]})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-4 gap-4 auto-rows-max overflow-y-auto max-h-[600px] p-1",children:z.map(e=>(0,s.jsxs)("div",{className:"group relative border rounded-lg overflow-hidden bg-muted/20 aspect-square flex flex-col",children:[(0,s.jsxs)("div",{className:"relative flex-1 p-2 flex items-center justify-center",children:[(0,s.jsx)("img",{src:e.aiResultUrl||e.originalUrl,alt:"预览",className:"max-w-full max-h-full object-contain rounded drop-shadow-md"}),(0,s.jsxs)("div",{className:"absolute top-2 left-2 flex flex-col gap-1",children:["processing"===e.aiStatus&&(0,s.jsxs)(x.Ex,{variant:"secondary",className:"bg-white/90 shadow-sm text-primary flex gap-1 items-center px-1.5 py-0.5 text-[10px]",children:[(0,s.jsx)(d.A,{className:"w-3 h-3 animate-spin"})," ",a("status_processing")]}),"done"===e.aiStatus&&(0,s.jsxs)(x.Ex,{variant:"secondary",className:"bg-green-500/90 text-white shadow-sm flex gap-1 items-center px-1.5 py-0.5 text-[10px]",children:[(0,s.jsx)(c.A,{className:"w-3 h-3"})," ",a("status_done")]}),"error"===e.aiStatus&&(0,s.jsxs)(x.Ex,{variant:"destructive",className:"shadow-sm flex gap-1 items-center px-1.5 py-0.5 text-[10px]",children:[(0,s.jsx)(m.A,{className:"w-3 h-3"})," ",a("status_error")]})]}),!M&&(0,s.jsx)("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:"done"===e.aiStatus?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.$n,{size:"sm",variant:"secondary",className:"h-8 text-xs",onClick:()=>ea(e),children:a("action_compare")}),(0,s.jsx)(x.$n,{size:"sm",className:"h-8 w-8 p-0",onClick:()=>X(e.aiResultUrl,"bg",e.file.name),children:(0,s.jsx)(i.A,{className:"w-4 h-4"})})]}):(0,s.jsxs)(s.Fragment,{children:["error"===e.aiStatus&&(0,s.jsx)(x.$n,{size:"sm",variant:"secondary",className:"h-8 w-8 p-0",title:a("action_retry"),onClick:()=>G(e.id),children:(0,s.jsx)(g.A,{className:"w-4 h-4"})}),(0,s.jsx)(x.$n,{size:"sm",variant:"destructive",className:"h-8 w-8 p-0",onClick:()=>{var t;return t=e.id,void E(e=>{let a=e.find(e=>e.id===t);return a&&(URL.revokeObjectURL(a.originalUrl),a.aiResultUrl&&URL.revokeObjectURL(a.aiResultUrl)),e.filter(e=>e.id!==t)})},children:(0,s.jsx)(o.A,{className:"w-4 h-4"})})]})})]}),e.aiError&&(0,s.jsx)("div",{className:"px-2 py-1 bg-destructive/10 text-destructive text-[10px] truncate border-t border-destructive/20",title:e.aiError,children:e.aiError})]},e.id))})]}):(0,s.jsxs)(x.Wu,{className:"py-12 flex flex-col items-center justify-center text-center",children:[(0,s.jsx)("div",{className:"w-16 h-16 bg-primary/10 text-primary rounded-full flex items-center justify-center mx-auto mb-4",children:(0,s.jsx)(l.A,{className:"w-8 h-8"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:a("upload_title")}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:a("upload_desc")}),(0,s.jsx)(x.$n,{size:"lg",onClick:()=>{var e;return null==(e=B.current)?void 0:e.click()},children:a("upload_btn")}),(0,s.jsx)("input",{ref:B,type:"file",multiple:!0,className:"hidden",accept:"image/*",onChange:J})]})})}),(0,s.jsxs)("div",{className:"lg:col-span-5 xl:col-span-4 space-y-4",children:[(0,s.jsx)(x.Zp,{children:(0,s.jsxs)(x.Wu,{className:"pt-5 pb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("h3",{className:"font-semibold text-sm",children:a("engine_title")}),(0,s.jsxs)(x.$n,{variant:"ghost",size:"sm",className:"h-7 text-xs px-2 text-muted-foreground",onClick:()=>W(!0),children:[(0,s.jsx)(p.A,{className:"w-3 h-3 mr-1"}),a("engine_history")]})]}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:["wan","gemini-flash","gpt-image-medium"].map(e=>{let t=C.xq[e];return t?(0,s.jsxs)("button",{onClick:()=>w(t.id),className:(0,x.cn)("flex flex-col items-center gap-1 p-2 rounded-lg border-2 transition-all text-xs",y===t.id?"border-primary bg-primary/5 text-primary":"border-muted hover:border-primary/40"),children:[(0,s.jsx)(u.A,{className:"w-4 h-4"}),(0,s.jsx)("span",{className:"font-medium text-[11px]",children:j("models."+t.labelKey)||t.id}),(0,s.jsxs)("span",{className:"text-[9px] text-muted-foreground",children:["fixed"===t.pricingRules.type?t.pricingRules.defaultEstimateCredits:"~".concat(t.pricingRules.defaultEstimateCredits)," ",j("credits")||"积分"]})]},t.id):null})})]})}),(0,s.jsx)(x.Zp,{children:(0,s.jsxs)(x.Wu,{className:"pt-5 pb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("h3",{className:"font-semibold text-sm",children:a("prompt_title")}),(0,s.jsxs)(x.$n,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:Y,disabled:I||!Z,children:[I?(0,s.jsx)(d.A,{className:"w-3 h-3 animate-spin mr-1"}):(0,s.jsx)(h.A,{className:"w-3 h-3 mr-1 text-yellow-500"}),a("smart_suggest")]})]}),(0,s.jsx)("textarea",{placeholder:a("prompt_placeholder"),value:A,onChange:e=>{L(e.target.value),S(null),P&&$(null)},rows:3,className:"flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 resize-none mb-4"}),P&&(0,s.jsxs)(x.Fc,{variant:"destructive",className:"mb-4 py-2",children:[(0,s.jsx)(m.A,{className:"w-4 h-4"}),(0,s.jsx)(x.TN,{children:P})]}),(0,s.jsx)(k,{selectedSceneId:null==N?void 0:N.id,onSelect:e=>{S(e),L(a("prompt_"+e.id))},suggestions:F,suggestionsLoading:I,onSelectSuggestion:e=>{L(e.prompt),S(null)}})]})}),(0,s.jsx)("div",{className:"sticky bottom-4 z-10 pt-2",children:(0,s.jsxs)("div",{className:"bg-card border shadow-lg rounded-xl p-3 flex gap-3",children:[(0,s.jsx)(x.$n,{className:"flex-1 shadow-sm",size:"lg",onClick:Q,disabled:M||0===z.filter(e=>"idle"===e.aiStatus||"error"===e.aiStatus).length,children:M?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"w-4 h-4 mr-2 animate-spin"})," ",a("status_processing"),"..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h.A,{className:"w-4 h-4 mr-2"})," ",a("start_generate")]})}),z.some(e=>"done"===e.aiStatus)&&(0,s.jsx)(x.$n,{variant:"outline",size:"lg",className:"px-3",onClick:ee,title:"下载全部成功图片",children:(0,s.jsx)(i.A,{className:"w-5 h-5"})})]})})]})]}),et&&(()=>{let e=z.filter(e=>"done"===e.aiStatus),t=e.findIndex(e=>e.id===et.id),r=t<e.length-1&&-1!==t;return(0,s.jsx)(R.E,{beforeUrl:et.originalUrl,afterUrl:et.aiResultUrl,beforeLabel:a("original_image"),afterLabel:a("result_image"),meta:(0,s.jsx)("span",{className:"text-[11px] text-muted-foreground truncate",children:et.file.name}),positionLabel:e.length>1?"".concat(t+1," / ").concat(e.length):void 0,onClose:()=>ea(null),onDownload:et.aiResultUrl?()=>X(et.aiResultUrl,"bg",et.file.name):void 0,onPrev:t>0?()=>ea(e[t-1]):void 0,onNext:r?()=>ea(e[t+1]):void 0})})(),T&&(0,s.jsx)("div",{className:"fixed inset-0 z-[150] bg-black/80 flex items-center justify-center p-4 backdrop-blur-sm",onClick:()=>W(!1),children:(0,s.jsxs)("div",{className:"relative max-w-5xl w-full max-h-[85vh] bg-background rounded-xl overflow-hidden shadow-2xl flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"p-4 border-b flex justify-between items-center bg-muted/30 shrink-0",children:[(0,s.jsxs)("h3",{className:"font-semibold flex items-center gap-2",children:[(0,s.jsx)(p.A,{className:"w-5 h-5 text-primary"})," ",a("history_title")]}),(0,s.jsx)(x.$n,{variant:"ghost",size:"sm",onClick:()=>W(!1),children:a("close")})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-6 custom-scrollbar bg-muted/10",children:(0,s.jsx)(_.V,{hideHeader:!0,defaultExpanded:!0,onSelectResult:e=>{window.open(e,"_blank")}})})]})})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.