PageSourceSearch

https://easymax.ai/static/js/r2/async/7404.ad0a695348.js

js easymax.ai collected 2026-10-05 13:40:48 UTC 33,451 bytes, 2 lines download raw bytes

1/*! LICENSE: 7404.ad0a695348.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[7404],{92279(e,a,t){t.r(a),t.d(a,{component:()=>en});var s=t(72361),r=t(32317),n=t(96962),i=t(53540),o=t(25500),d=t(9781);let l=(0,d.A)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);var c=t(40315),m=t(55724),u=t(14653),p=t(24623),h=t(63162),g=t(68413),x=t(6702),f=t(20598),b=t(60641),v=t(72868),j=t(68974),y=t(82655),w=t(11728),k=t(88288),N=t(56920),z=t(70954),C=t(22990);function R(e){return{id:e.task_id,prompt:e.prompt,modelName:e.model_name,mode:e.mode,status:e.status,uploadProgress:100,createdAt:1e3*e.created_at,startedAt:e.started_at?1e3*e.started_at:void 0,finishedAt:e.finished_at?1e3*e.finished_at:void 0,results:e.results??[],error:e.error}}async function A(){return(await C.FH.get("/api/user/image-studio/config")).data.data}async function M(e){return(await C.FH.post("/api/user/image-studio/polish",{prompt:e},{skipErrorHandler:!0})).data.data.prompt}async function S(e,a){let t=await C.FH.get("/api/user/image-studio/tasks",{params:{page:e,page_size:a},skipErrorHandler:!0});return{items:t.data.data.items.map(R),total:t.data.data.total,activeCount:t.data.data.active_count}}async function _(e,a,t){let s=new FormData;return s.append("model_id",e.model.id),s.append("mode",e.mode),s.append("prompt",e.prompt),s.append("size",e.size),s.append("quality",e.quality),s.append("output_format",e.outputFormat),e.referenceImages.forEach(e=>s.append("images",e)),R((await C.FH.post("/api/user/image-studio/tasks",s,{signal:a,skipErrorHandler:!0,onUploadProgress:e=>t(e.total?Math.max(0,Math.min(100,Math.round(e.loaded/e.total*100))):0)})).data.data)}async function $(e){await C.FH.post(`/api/user/image-studio/tasks/${encodeURIComponent(e)}/cancel`,void 0,{skipErrorHandler:!0})}async function D(e){await C.FH.post(`/api/user/image-studio/tasks/${encodeURIComponent(e)}/retry`,void 0,{skipErrorHandler:!0})}async function q(e){await C.FH.delete(`/api/user/image-studio/tasks/${encodeURIComponent(e)}`,{skipErrorHandler:!0})}async function E(){await C.FH.delete("/api/user/image-studio/tasks",{skipErrorHandler:!0})}async function I(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(await C.FH.get(`/api/user/image-studio/tasks/${encodeURIComponent(e)}/image`,{params:a?{proxy:1}:void 0,responseType:"blob",skipErrorHandler:!0})).data}var F=t(15762),P=t(65277),H=t(71065);let L=(0,d.A)("clock-3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]);var U=t(33834),O=t(23921),T=t(47497);let B=new Set(["queued","uploading","generating"]);function G(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),t=e.startedAt||e.createdAt;return Math.max(0,Math.floor(((e.finishedAt||a)-t)/1e3))}function W(e){var a;let{t}=(0,x.Bd)(),[r,n]=(0,g.useState)(Date.now()),[i,o]=(0,g.useState)(""),[d,l]=(0,g.useState)(!1),[c,p]=(0,g.useState)(!1),[h,b]=(0,g.useState)(!1),[y,w]=(0,g.useState)(!1),k=(a=e.task,B.has(a.status)),N=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if("success"===e.status)return 100;if("uploading"===e.status)return Math.max(1,Math.min(15,Math.round(.15*e.uploadProgress)));let t=G(e,a);return"queued"===e.status?Math.min(10,3+Math.floor(t/2)):"generating"===e.status?Math.min(92,12+Math.round(80*(1-Math.exp(-t/45)))):100}(e.task,r),z=G(e.task,r),C=e.task.results[0]?.url;(0,g.useEffect)(()=>{if(!k)return;let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[k]),(0,g.useEffect)(()=>{if("success"!==e.task.status||!C)return void o("");if(!C.startsWith("/api/"))return void o(C);let a=!1,t="";return I(e.task.id).then(e=>{a||o(t=URL.createObjectURL(e))}).catch(()=>{a||o("")}),()=>{a=!0,t&&URL.revokeObjectURL(t)}},[e.task.id,e.task.status,C]);let R={queued:t("Waiting to upload"),uploading:t("Uploading reference images {{progress}}%",{progress:e.task.uploadProgress}),generating:t("Generating image"),success:t("Completed"),error:t("Generation failed"),cancelled:t("Cancelled")}[e.task.status],A=async()=>
2{if(!c){p(!0);try{let a=await I(e.task.id,!0),t=URL.createObjectURL(a),s=document.createElement("a"),r=a.type.split("/")[1]?.split(";")[0],n=e.task.results[0]?.mime.split("/")[1]?.split(";")[0];s.href=t,s.download=`image-${e.task.id}.${r||n||"png"}`,document.body.appendChild(s),s.click(),s.remove(),window.setTimeout(()=>URL.revokeObjectURL(t),1e3)}catch{f.oR.error(t("Failed to load image"))}finally{p(!1)}}};return(0,s.jsxs)(j.Zp,{className:"overflow-hidden",children:[(0,s.jsxs)(j.aR,{className:"gap-2 pb-3",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(j.ZB,{className:"truncate text-sm",children:e.task.modelName}),(0,s.jsx)("p",{className:"text-muted-foreground mt-1 line-clamp-2 text-xs",children:e.task.prompt})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[k&&(0,s.jsx)(v.$,{type:"button",size:"icon-sm",variant:"ghost",onClick:e.onCancel,"aria-label":t("Cancel task"),children:(0,s.jsx)(F.A,{className:"size-4"})}),"success"===e.task.status&&(0,s.jsx)(v.$,{type:"button",size:"icon-sm",variant:"ghost",disabled:d,onClick:async()=>{if(!d){l(!0);try{await e.onEdit()}finally{l(!1)}}},"aria-label":t("Add image to edit mode"),children:d?(0,s.jsx)(m.A,{className:"size-4 animate-spin"}):(0,s.jsx)(P.A,{className:"size-4"})}),(0,s.jsx)(v.$,{type:"button",size:"icon-sm",variant:"ghost",disabled:y,"aria-busy":y,onClick:async()=>{if(!y){w(!0);try{await e.onDelete()}finally{w(!1)}}},"aria-label":t("Delete record"),children:y?(0,s.jsx)(m.A,{className:"size-4 animate-spin"}):(0,s.jsx)(u.A,{className:"size-4"})})]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[k&&(0,s.jsx)(m.A,{className:"size-3.5 animate-spin"}),"cancelled"===e.task.status&&(0,s.jsx)(H.A,{className:"size-3.5"}),(0,s.jsx)("span",{children:R}),(0,s.jsxs)("span",{className:"ml-auto flex items-center gap-1 tabular-nums",children:[(0,s.jsx)(L,{className:"size-3.5"}),t("{{seconds}} seconds",{seconds:z})]})]}),(0,s.jsx)(T.ke,{value:N}),k&&(0,s.jsxs)("div",{className:"text-muted-foreground text-right text-[11px] tabular-nums",children:[N,"%"]})]})]}),(0,s.jsxs)(j.Wu,{className:"pt-0",children:["success"===e.task.status&&e.task.results[0]&&(0,s.jsx)("div",{className:"group bg-muted relative overflow-hidden rounded-lg border",children:i?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"block w-full",onClick:()=>e.onPreview(i),children:(0,s.jsx)("img",{src:i,alt:t("Generated result"),className:"aspect-square w-full object-cover"})}),(0,s.jsx)("button",{type:"button",disabled:c,"aria-busy":c,onClick:()=>void A(),className:"absolute right-2 bottom-2 rounded-md bg-black/70 p-2 text-white opacity-0 transition-opacity group-hover:opacity-100","aria-label":t("Download"),children:c?(0,s.jsx)(m.A,{className:"size-4 animate-spin"}):(0,s.jsx)(U.A,{className:"size-4"})})]}):(0,s.jsxs)("div",{className:"text-muted-foreground flex aspect-square items-center justify-center text-sm",children:[(0,s.jsx)(m.A,{className:"mr-2 size-4 animate-spin"}),t("Loading image")]})}),("error"===e.task.status||"cancelled"===e.task.status)&&(0,s.jsxs)("div",{className:"border-destructive/30 bg-destructive/5 space-y-3 rounded-lg border p-3",children:[(0,s.jsx)("p",{className:"text-destructive text-xs",children:e.task.error||R}),(0,s.jsxs)(v.$,{type:"button",size:"sm",variant:"outline",disabled:h,"aria-busy":h,onClick:async()=>{if(!h){b(!0);try{await e.onRetry()}finally{b(!1)}}},children:[h?(0,s.jsx)(m.A,{className:"mr-1.5 size-3.5 animate-spin"}):(0,s.jsx)(O.A,{className:"mr-1.5 size-3.5"}),t("Retry")]})]})]})]})}var V=t(3225),J=t(66002),Z=t(56275);function K(e){return`${e.name}-${e.size}-${e.lastModified}`}function X(e){return e.type.startsWith("image/")}function Y(e){let{t:a}=(0,x.Bd)(),[t,r]=(0,g.useState)(""),n=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let a=URL.createObjectURL(e.file);return r(a),()=>URL.revokeObjectURL(a)},[e.file]),(0,s.jsxs)("div",{className:"group bg-muted relative aspect-square overflow-hidden rounded-xl border",children:[(0,s.jsx)("img",{src:t,alt:a("Reference image {{index}}",{index:e.index+1}),className:"size-full object-cover"}),(0,s.jsx)(v.$,{type:"button",size:"icon-sm",variant:"ghost",disabled:e.disabled,className:"absolute top-1.5 right-1.5 z-10 size-7 rounded-full bg-black/70 text-white shadow-none hover:bg-black/85 hover:text-white","aria-label":a("Remove reference image {{index}}",{index:e.index+1}),onClick:e.onRemove,children:(0,s.jsx)(F.A,{className:"size-4"})}),(0,s.jsx)("div",{className:"absolute inset-x-0 bottom-0 flex items-center bg-black/65 p-1.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",children:(0,s.jsxs)(v.$,{type:"button",size:"sm",variant:"ghost",disabled:e.disabled,className:"h-7 text-white hover:bg-white/20 hover:text-white",onClick:()=>n.current?.click(),children:[(0,s.jsx)(P.A,{className:"mr-1 size-3.5"})," ",a("Replace")]})}),(0,s.jsx)("input",{ref:n,type:"file",accept:"image/*",className:"hidden",onChange:a=>{let t=a.target.files?.[0];t&&e.onReplace(t),a.target.value=""}})]})}function Q(e){let{t:a}=(0,x.Bd)(),t=(0,g.useRef)(null),[r,n]=(0,g.useState)(!1),i=Math.max(0,e.maxFiles-e.files.length),o=t=>{let s=t.find(e=>!X(e));s&&f.oR.error(a("{{name}} is not an image file",{name:s.name}));let r=t.find(e=>e.size>0x4000000);r&&f.oR.error(a("{{name}} exceeds the per-image size limit of 64 MB",{name:r.name}));let n=new Set(e.files.map(K));t.filter(e=>X(e)&&e.size<=0x4000000).length>i&&f.oR.error(a("At most {{count}} reference images are allowed",{count:e.maxFiles}));let o=[],d=e.files.reduce((e,a)=>e+a.size,0);for(let e of t){let t=K(e);if(!(!X(e)||e.size>0x4000000||n.has(t))&&!(o.length>=i)){if(d+e.size>0x5a00000){f.oR.error(a("Reference images may not exceed 90 MB in total"));break}n.add(t),o.push(e),d+=e.size}}o.length>0&&e.onChange([...e.files,...o])};return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:(0,Z.cn)("rounded-xl border border-dashed p-4 transition-colors",r&&"border-primary bg-primary/5",e.disabled&&"pointer-events-none opacity-50"),onDragOver:e=>{e.preventDefault(),n(!0)},onDragLeave:()=>n(!1),onDrop:e=>{e.preventDefault(),n(!1),o([...e.dataTransfer.files])},children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"bg-primary/10 text-primary rounded-lg p-2",children:(0,s.jsx)(V.A,{className:"size-5"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:a("Reference images")}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:a("Drag images here or add them manually")})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[e.files.length>0&&(0,s.jsxs)(v.$,{type:"button",size:"sm",variant:"outline",disabled:e.disabled,onClick:()=>e.onChange([]),children:[(0,s.jsx)(u.A,{className:"mr-1.5 size-4"})," ",a("Clear all")]}),(0,s.jsxs)(v.$,{type:"button",size:"sm",variant:"outline",disabled:e.disabled||0===i,onClick:()=>t.current?.click(),children:[(0,s.jsx)(J.A,{className:"mr-1.5 size-4"})," ",a("Add images")]})]})]}),(0,s.jsx)("input",{ref:t,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{o([...e.target.files??[]]),e.target.value=""}})]}),e.files.length>0&&(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-4 lg:grid-cols-6",children:e.files.map((t,r)=>(0,s.jsx)(Y,{file:t,index:r,disabled:e.disabled,onRemove:()=>e.onChange(e.files.filter((e,a)=>a!==r)),onReplace:t=>((t,s)=>{if(!X(s))return void f.oR.error(a("{{name}} is not an image file",{name:s.name}));if(s.size>0x4000000)return void f.oR.error(a("{{name}} exceeds the per-image size limit of 64 MB",{name:s.name}));let r=K(s);e.files.some((e,a)=>a!==t&&K(e)===r)?f.oR.error(a("This reference image has already been added")):e.files.reduce((e,a,r)=>e+(r===t?s.size:a.size),0)>0x5a00000?f.oR.error(a("Reference images may not exceed 90 MB in total")):e.onCh
2ange(e.files.map((e,a)=>a===t?s:e))})(r,t)},K(t)))})]})}function ee(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return Math.max(0,Math.max(1,Math.min(10,Math.trunc(a)||1))-Math.max(0,Math.trunc(e)))}let ea=new Set(["queued","uploading","generating"]),et=[];function es(e){if(o.A.isAxiosError(e)){let a=e.response?.data,t=a?.error?.message||a?.message||e.message,s=a?.error?.code,r=e.response?.status;return[t,s?`错误码:${s}`:"",r?`HTTP ${r}`:""].filter(Boolean).join(" · ")}return e instanceof Error?e.message:String(e)}function er(){let{t:e}=(0,x.Bd)(),a=(0,n.jE)(),t=(0,i.I)({queryKey:["image-studio-config"],queryFn:A}),[r,o]=(0,g.useState)("generate"),[d,C]=(0,g.useState)(""),[R,F]=(0,g.useState)(""),[P,H]=(0,g.useState)(""),[L,U]=(0,g.useState)(""),[O,T]=(0,g.useState)("jpeg"),[B,G]=(0,g.useState)(1),[V,J]=(0,g.useState)([]),[Z,K]=(0,g.useState)(!1),[X,Y]=(0,g.useState)(!1),[er,en]=(0,g.useState)({completed:0,total:0}),[ei,eo]=(0,g.useState)([]),[ed,el]=(0,g.useState)(1),[ec,em]=(0,g.useState)(""),[eu,ep]=(0,g.useState)(!1),[eh,eg]=(0,g.useState)(!1),[ex,ef]=(0,g.useState)(!1),eb=(0,g.useRef)(new Map),ev=(0,g.useRef)(!1),ej=(0,i.I)({queryKey:["image-studio-tasks",ed],queryFn:()=>S(ed,6),placeholderData:e=>e,refetchInterval:e=>(e.state.data?.activeCount??0)>0&&2e3}),ey=t.data?.models??et,ew=(0,g.useMemo)(()=>ey.filter(e=>"edit"===r?e.support_edit:e.support_generate),[r,ey]),ek=ew.find(e=>e.id===d)??ew[0],eN=(ej.data?.activeCount??0)+ei.filter(e=>ea.has(e.status)).length,ez=t.data?.max_parallel_tasks??10,eC=ee(eN,ez),eR=(ej.data?.total??0)+ei.length,eA=Math.max(1,Math.ceil(eR/6)),eM=1===ed?[...ei,...ej.data?.items??[]].slice(0,6):ej.data?.items??[];(0,g.useEffect)(()=>{ej.data&&!ej.isPlaceholderData&&ed>eA&&el(eA)},[ed,eA,ej.data,ej.isPlaceholderData]),(0,g.useEffect)(()=>{let e=Math.max(1,eC);B>e&&G(e)},[eC,B]);let eS=(0,g.useCallback)(e=>{e&&(C(e.id),H(e.default_size||e.sizes[0]||""),U(e.default_quality||e.qualities[0]||""),T(e.output_formats.includes("jpeg")?"jpeg":e.default_output||e.output_formats[0]||"png"),J(a=>a.slice(0,e.max_reference_images||16)))},[]);(0,g.useEffect)(()=>{ek&&d!==ek.id&&eS(ek)},[d,ek,eS]);let e_=(e,a)=>{eo(t=>t.map(t=>t.id===e?{...t,...a}:t))},e$=async(e,a)=>{let t=new AbortController;eb.current.set(e,t),e_(e,{status:"uploading",uploadProgress:0});try{return await _(a,t.signal,a=>e_(e,{uploadProgress:a})),e_(e,{status:"queued",uploadProgress:100}),!0}catch(a){return t.signal.aborted?eo(a=>a.filter(a=>a.id!==e)):e_(e,{status:"error",error:es(a),finishedAt:Date.now()}),!1}finally{eb.current.delete(e)}},eD=async()=>{if(ev.current)return;if(!ek)return void f.oR.error(e("No available image model. Please contact the administrator."));if(!R.trim())return void f.oR.error(e("Please enter an image instruction"));if("edit"===r&&0===V.length)return void f.oR.error(e("Edit mode requires at least one reference image"));let t=function(e,a){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return Math.min(Math.max(1,Math.min(5,Math.trunc(e)||1)),ee(a,t))}(B,eN,ez);if(0===t)return void f.oR.error(e("At most {{count}} image tasks can run at the same time",{count:ez}));t<B&&f.oR.info(e("Only {{count}} task slots are currently available",{count:t})),ev.current=!0,Y(!0),en({completed:0,total:t});let s={model:ek,mode:r,prompt:R.trim(),size:P,quality:L,outputFormat:O,referenceImages:[...V]},n=Array.from({length:t},()=>({id:`img-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,prompt:s.prompt,modelName:ek.name,mode:r,status:"queued",uploadProgress:0,createdAt:Date.now(),results:[]}));eo(e=>[...n,...e]),el(1);try{let t=await Promise.all(n.map(async e=>{let a=await e$(e.id,s);return en(e=>({...e,completed:e.completed+1})),{id:e.id,success:a}})),r=new Set(t.filter(e=>e.success).map(e=>e.id));await a.refetchQueries({queryKey:["image-studio-tasks"],type:"active"}),eo(e=>e.filter(e=>!r.has(e.id))),r.size===n.length?(Z||(F(""),J([])),f.oR.success(e("{{count}} image tasks created",{count:r.size}))):f.oR.error(e("{{created}} of {{total}} image tasks were created",{created:r.size,total:n.length}))}finally{ev.current=!1,Y(!1),en({completed:0,total:0})}},eq=async a=>{if(0===ee(eN,ez))return void f.oR.error(e("At most {{count}} image tasks can run at the same time",{count:ez}));try{await D(a.id),await ej.refetch()}catch(e){f.oR.error(es(e))}},eE=async e=>{let a=eb.current.get(e.id);if(a)return void a.abort();try{await $(e.id),await ej.refetch()}catch(e){f.oR.error(es(e))}},eI=async e=>{let a=eb.current.get(e.id);if(a){a.abort(),eo(a=>a.filter(a=>a.id!==e.id));return}try{await q(e.id),await ej.refetch()}catch(e){f.oR.error(es(e))}},eF=async()=>
2{if(!eh){eg(!0),eb.current.forEach(e=>e.abort()),eb.current.clear(),eo([]);try{await E(),el(1),ep(!1),await ej.refetch(),f.oR.success(e("All image task records cleared"))}catch(e){f.oR.error(es(e))}finally{eg(!1)}}},eP=async()=>{if(!ex){if(!R.trim())return void f.oR.error(e("Please enter an image instruction"));if(!t.data?.prompt_polish_enabled)return void f.oR.error(e("The administrator has not configured a prompt polish model"));ef(!0);try{F(await M(R.trim())),f.oR.success(e("Prompt polished"))}catch(e){f.oR.error(es(e))}finally{ef(!1)}}},eH=async a=>{let t=ek?.support_edit?ek:ey.find(e=>e.support_edit);if(!t)return void f.oR.error(e("No image model supports edit mode"));if(V.length>=t.max_reference_images)return void f.oR.error(e("You can upload at most {{count}} reference images",{count:t.max_reference_images}));try{let s=await I(a.id,!0),r=s.type||a.results[0]?.mime||"image/jpeg",n="image/jpeg"===r?"jpg":r.split("/")[1]?.replace("svg+xml","svg")||"png",i=new File([s],`generated-${a.id}.${n}`,{type:r});o("edit"),eS(t),J(e=>[...e,i]),f.oR.success(e("Image added to edit mode"))}catch(e){f.oR.error(es(e))}};return(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-[1720px] min-w-0 flex-col gap-4 p-4 md:p-6",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,s.jsx)("div",{children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"bg-primary/10 text-primary rounded-xl p-2.5",children:(0,s.jsx)(c.A,{className:"size-5"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:e("Image Studio")}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:e("Create and edit images as independent agent tasks, without chat history.")})]})]})}),(0,s.jsx)("div",{className:"bg-card rounded-full border px-3 py-1.5 text-sm",children:e("{{active}} active · {{available}} slots available",{active:eN,available:eC})})]}),(0,s.jsxs)("div",{className:"grid min-w-0 items-start gap-5 xl:grid-cols-[minmax(500px,580px)_minmax(0,1fr)]",children:[(0,s.jsxs)(j.Zp,{className:"border-border min-w-0 border shadow-none ring-0 transition-none hover:shadow-none active:shadow-none","data-card-hover":"false",style:{boxShadow:"none",filter:"none",transform:"none"},children:[(0,s.jsx)(j.aR,{className:"pb-3",children:(0,s.jsx)(j.ZB,{children:e("Create a task")})}),(0,s.jsxs)(j.Wu,{className:"space-y-4",children:[(0,s.jsx)(N.tU,{value:r,onValueChange:e=>{o(e),eS(ey.find(a=>"edit"===e?a.support_edit:a.support_generate))}
2,children:(0,s.jsxs)(N.j7,{className:"bg-foreground/[0.07] border-foreground/10 relative grid w-full grid-cols-2 overflow-hidden rounded-md border p-1 shadow-none dark:bg-white/10",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"bg-background pointer-events-none absolute top-1 bottom-1 left-1 w-[calc(50%-0.25rem)] rounded-sm transition-transform duration-200 ease-out",style:{boxShadow:"none",transform:"edit"===r?"translateX(100%)":"translateX(0)"}}),(0,s.jsx)(N.Xi,{value:"generate",className:"relative z-10 rounded-sm bg-transparent shadow-none transition-colors duration-150 ease-out hover:shadow-none active:shadow-none data-active:bg-transparent data-active:shadow-none dark:data-active:bg-transparent",style:{animation:"none",boxShadow:"none",transform:"none",transition:"background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out"},children:e("Generate mode")}),(0,s.jsx)(N.Xi,{value:"edit",className:"relative z-10 rounded-sm bg-transparent shadow-none transition-colors duration-150 ease-out hover:shadow-none active:shadow-none data-active:bg-transparent data-active:shadow-none dark:data-active:bg-transparent",style:{animation:"none",boxShadow:"none",transform:"none",transition:"background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out"},children:e("Edit mode")})]})}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(w.J,{children:e("Image model")}),(0,s.jsxs)(k.l6,{value:ek?.id??"",onValueChange:e=>eS(ew.find(a=>a.id===e)),children:[(0,s.jsx)(k.bq,{className:"bg-muted/70 border-foreground
2/15 focus-visible:border-primary/50 hover:bg-muted/70 dark:bg-input/50 dark:hover:bg-input/50 h-11 w-full rounded-md px-3 shadow-none transition-none hover:shadow-none focus-visible:ring-0 active:shadow-none",style:{animation:"none",transform:"none",transition:"none"},children:ek?(0,s.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[(0,s.jsx)("span",{className:"truncate font-medium",children:ek.name}),(0,s.jsx)("span",{className:"text-muted-foreground bg-muted ml-auto shrink-0 rounded-md px-1.5 py-0.5 text-[11px] font-medium",children:"openai"===ek.provider?"OpenAI":"Gemini"})]}):(0,s.jsx)("span",{className:"text-muted-foreground",children:e("Select a model")})}),(0,s.jsx)(k.gC,{align:"start",alignItemWithTrigger:!1,className:"bg-muted border-foreground/15 data-closed:fade-out-0 data-closed:slide-out-to-top-1 data-closed:zoom-out-100 data-open:fade-in-0 data-open:slide-in-from-top-1 data-open:zoom-in-100 rounded-md border p-1 shadow-none",sideOffset:8,style:{animationDuration:"120ms",boxShadow:"none"},children:ew.map(e=>(0,s.jsx)(k.eb,{value:e.id,className:"focus:bg-background rounded-sm py-2 pr-9 pl-3",children:(0,s.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate",children:e.name}),(0,s.jsx)("span",{className:"text-muted-foreground bg-muted ml-auto rounded-md px-1.5 py-0.5 text-[11px] font-medium",children:"openai"===e.provider?"OpenAI":"Gemini"})]})},e.id))})]})]}),"edit"===r&&(0,s.jsx)(Q,{files:V,onChange:J,maxFiles:ek?.max_reference_images||16,disabled:X}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)(w.J,{htmlFor:"image-studio-prompt",children:e("Instruction")}),(0,s.jsxs)(v.$,{type:"button",variant:"outline",size:"sm",disabled:X||ex||!R.trim(),onClick:()=>void eP(),children:[ex?(0,s.jsx)(m.A,{className:"mr-1.5 size-4 animate-spin"}):(0,s.jsx)(c.A,{className:"mr-1.5 size-4"}),e("AI polish")]})]}),(0,s.jsx)(z.T,{id:"image-studio-prompt",className:"bg-muted/45 border-foreground
2/15 focus-visible:border-primary/50 shadow-none focus-visible:ring-0",value:R,onChange:e=>F(e.target.value),rows:6,maxLength:8e3,placeholder:"edit"===r?e("Describe how the reference image should be changed"):e("Describe the image you want to create"),disabled:X}),(0,s.jsxs)("p",{className:"text-muted-foreground text-right text-xs",children:[R.length,"/8000"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-end gap-x-5 gap-y-4",style:{marginTop:"0.25rem"},children:[(0,s.jsxs)("div",{className:"w-fit space-y-2",children:[(0,s.jsx)(w.J,{children:ek?.provider==="gemini"?e("Aspect ratio"):e("Size")}),(0,s.jsxs)(k.l6,{value:P,onValueChange:e=>null!==e&&H(e),children:[(0,s.jsx)(k.bq,{className:"bg-muted/70 border-foreground/15 focus-visible:border-primary/50 hover:bg-muted/70 dark:bg-input/50 dark:hover:bg-input/50 h-10 w-auto min-w-36 rounded-md px-3 shadow-none transition-none hover:shadow-none focus-visible:ring-0 active:shadow-none",style:{animation:"none",transform:"none",transition:"none"},children:(0,s.jsx)(k.yv,{placeholder:e("Auto")})}),(0,s.jsx)(k.gC,{align:"start",alignItemWithTrigger:!1,className:"bg-muted border-foreground
2/15 data-closed:fade-out-0 data-closed:slide-out-to-top-1 data-closed:zoom-out-100 data-open:fade-in-0 data-open:slide-in-from-top-1 data-open:zoom-in-100 w-max min-w-(--anchor-width) rounded-md border p-1 shadow-none",sideOffset:8,style:{animationDuration:"120ms",boxShadow:"none"},children:(ek?.sizes??[]).map(e=>(0,s.jsx)(k.eb,{value:e,className:"focus:bg-background rounded-sm py-2 pr-9 pl-3",children:e},e))})]})]}),(0,s.jsxs)("div",{className:"w-fit space-y-2",children:[(0,s.jsx)(w.J,{children:ek?.provider==="gemini"?e("Resolution"):e("Quality")}),(0,s.jsxs)(k.l6,{value:L,onValueChange:e=>null!==e&&U(e),children:[(0,s.jsx)(k.bq,{className:"bg-muted/70 border-foreground/15 focus-visible:border-primary/50 hover:bg-muted/70 dark:bg-input/50 dark:hover:bg-input/50 h-10 w-auto min-w-28 rounded-md px-3 shadow-none transition-none hover:shadow-none focus-visible:ring-0 active:shadow-none",style:{animation:"none",transform:"none",transition:"none"},children:(0,s.jsx)(k.yv,{placeholder:e("Auto")})}),(0,s.jsx)(k.gC,{align:"start",alignItemWithTrigger:!1,className:"bg-muted border-foreground
2/15 data-closed:fade-out-0 data-closed:slide-out-to-top-1 data-closed:zoom-out-100 data-open:fade-in-0 data-open:slide-in-from-top-1 data-open:zoom-in-100 w-max min-w-(--anchor-width) rounded-md border p-1 shadow-none",sideOffset:8,style:{animationDuration:"120ms",boxShadow:"none"},children:(ek?.qualities??[]).map(e=>(0,s.jsx)(k.eb,{value:e,className:"focus:bg-background rounded-sm py-2 pr-9 pl-3",children:e},e))})]})]})]}),ek?.provider==="openai"&&ek.output_formats.length>0&&(0,s.jsxs)("div",{className:"w-fit space-y-2",children:[(0,s.jsx)(w.J,{children:e("Output format")}),(0,s.jsxs)(k.l6,{value:O,onValueChange:e=>null!==e&&T(e),children:[(0,s.jsx)(k.bq,{className:"bg-muted/70 border-foreground/15 focus-visible:border-primary/50 hover:bg-muted/70 dark:bg-input/50 dark:hover:bg-input/50 h-10 w-auto min-w-24 rounded-md px-3 shadow-none transition-none hover:shadow-none focus-visible:ring-0 active:shadow-none",style:{animation:"none",transform:"none",transition:"none"},children:(0,s.jsx)(k.yv,{})}),(0,s.jsx)(k.gC,{align:"start",alignItemWithTrigger:!1,className:"bg-muted border-foreground
2/15 data-closed:fade-out-0 data-closed:slide-out-to-top-1 data-closed:zoom-out-100 data-open:fade-in-0 data-open:slide-in-from-top-1 data-open:zoom-in-100 w-max min-w-(--anchor-width) rounded-md border p-1 shadow-none",sideOffset:8,style:{animationDuration:"120ms",boxShadow:"none"},children:ek.output_formats.map(e=>(0,s.jsx)(k.eb,{value:e,className:"focus:bg-background rounded-sm py-2 pr-9 pl-3",children:e.toUpperCase()},e))})]})]}),"generate"===r&&ek?.provider==="openai"&&(0,s.jsx)("p",{className:"text-muted-foreground bg-muted/45 border-foreground/10 rounded-md border px-3 py-2 text-xs leading-relaxed",children:e("For GPT image models, include the desired aspect ratio or size directly in the prompt because the size option below may not always take effect. Example: Generate an image of a puppy in 16:9.")}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(w.J,{children:e("Number of tasks")}),(0,s.jsx)("div",{className:"grid grid-cols-5 gap-2",children:[1,2,3,4,5].map(e=>(0,s.jsx)(v.$,{type:"button",variant:B===e?"default":"outline",onClick:()=>G(e),disabled:X||0===eC||e>eC,children:e},e))})]}),(0,s.jsxs)("label",{className:"flex w-fit cursor-pointer items-center gap-2 text-sm",children:[(0,s.jsx)(y.S,{checked:Z,disabled:X,onCheckedChange:e=>K(!0===e)}),(0,s.jsx)("span",{children:e("Keep prompt and reference images")})]}),(0,s.jsx)(v.$,{type:"button",size:"lg",className:"w-full",onClick:()=>void eD(),disabled:X||!ek||0===eC,"aria-busy":X,children:X?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.A,{className:"mr-2 size-5 animate-spin"}),e("Creating image tasks {{completed}}/{{total}}...",{completed:er.completed,total:er.total})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l,{className:"mr-2 size-5"}),e("Submit {{count}} image task",{count:B})]})})]})]}),(0,s.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"font-semibold",children:e("Task workspace")}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:e("You can keep configuring and submitting new work while tasks run.")}),(0,s.jsx)("p",{className:"text-muted-foreground/80 mt-1 text-xs",children:e("Image resources expire {{days}} days after generation. Please download and save them in time.",{days:t.data?.image_expiry_days??7})})]}),eR>0&&(0,s.jsxs)(v.$,{type:"button",variant:"outline",size:"sm",onClick:()=>ep(!0),children:[(0,s.jsx)(u.A,{className:"mr-1.5 size-4"})," ",e("Clear all records")]})]}),t.isLoading?(0,s.jsx)("div",{className:"text-muted-foreground rounded-xl border border-dashed p-12 text-center text-sm",children:e("Loading image models...")}):0===ew.length?(0,s.jsxs)("div",{className:"rounded-xl border border-dashed p-12 text-center",children:[(0,s.jsx)(l,{className:"text-muted-foreground mx-auto size-10"}),(0,s.jsx)("p",{className:"mt-3 font-medium",children:e("No available image model")}),(0,s.jsx)("p",{className:"text-muted-foreground mt-1 text-sm",children:e("Ask an administrator to enable an OpenAI or Gemini image model.")})]}):ej.isLoading&&0===ei.length?(0,s.jsx)("div",{className:"text-muted-foreground rounded-xl border border-dashed p-12 text-center text-sm",children:e("Loading task history...")}):0===eR?(0,s.jsxs)("div",{className:"rounded-xl border border-dashed p-12 text-center",children:[(0,s.jsx)(c.A,{className:"text-muted-foreground mx-auto size-10"}),(0,s.jsx)("p",{className:"mt-3 font-medium",children:e("Your image tasks will appear here")}),(0,s.jsx)("p",{className:"text-muted-foreground mt-1 text-sm",children:e("This is a task workspace, not a chat conversation.")})]}):(0,s.jsx)("div",{className:"grid gap-4 sm:grid-cols-2 2xl:grid-cols-3",children:eM.map(e=>(0,s.jsx)(W,{task:e,onCancel:()=>void eE(e),onRetry:()=>eq(e),onDelete:()=>eI(e),onEdit:()=>eH(e),onPreview:em},e.id))}),eR>6&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 pt-1",children:[(0,s.jsxs)(v.$,{type:"button",variant:"outline",size:"sm",disabled:1===ed||ej.isPlaceholderData,onClick:()=>el(e=>Math.max(1,e-1)),children:[(0,s.jsx)(p.A,{className:"mr-1 size-4"}),e("Previous page")]}),(0,s.jsx)("span",{className:"text-muted-foreground min-w-28 text-center text-sm",children:e("Page {{current}} of {{total}}",{current:ed,total:eA})}),(0,s.jsxs)(v.$,{type:"button",variant:"outline",size:"sm",disabled:ed===eA||ej.isPlaceholderData,onClick:()=>el(e=>Math.min(eA,e+1)),children:[e("Next page"),(0,s.jsx)(h.A,{className:"ml-1 size-4"})]})]})]})]}),(0,s.jsx)(b.l,{open:eu,onOpenChange:e=>!eh&&ep(e),title:e("Clear all image task records?"),description:e("This will cancel active tasks and permanently delete all image history and stored images."),contentHeight:"auto",contentClassName:"sm:max-w-md",footer
2:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(v.$,{type:"button",variant:"outline",onClick:()=>ep(!1),disabled:eh,children:e("Cancel")}),(0,s.jsxs)(v.$,{type:"button",variant:"destructive",onClick:()=>void eF(),disabled:eh,children:[eh&&(0,s.jsx)(m.A,{className:"size-4 animate-spin"}),eh?e("Clearing..."):e("Clear all records")]})]}),children:(0,s.jsx)("div",{})}),(0,s.jsx)(b.l,{open:!!ec,onOpenChange:e=>!e&&em(""),title:e("Image preview"),contentClassName:"sm:max-w-5xl",contentHeight:"min(78vh, 900px)",children:ec&&(0,s.jsx)("img",{src:ec,alt:e("Generated image preview"),className:"mx-auto max-h-[75vh] max-w-full rounded-lg object-contain"})})]})}function en(){return(0,s.jsx)(r.gZ,{className:"overflow-y-auto overscroll-contain p-0",children:(0,s.jsx)(er,{})})}},71065(e,a,t){let s=(0,t(9781).A)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);t.d(a,{},{A:s})},33834(e,a,t){let s=(0,t(9781).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);t.d(a,{},{A:s})},40315(e,a,t){let s=(0,t(9781).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"}
2],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);t.d(a,{},{A:s})},3225(e,a,t){let s=(0,t(9781).A)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);t.d(a,{},{A:s})}}]);

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.