import{f as a,h as s,v as t,k as e,x as l,Q as i,V as u,z as o,i as n,j as r,L as m,D as c,E as d,w as _,F as p,A as g,n as v,o as f}from"./vue-c4996fb3.js";import{_ as b}from"./CustomForm.vue_vue_type_style_index_0_lang-1d30a866.js";import{_ as y}from"./loading2.vue_vue_type_style_index_0_lang-83e3a6ec.js";import{_ as j}from"./resetbutton.vue_vue_type_style_index_0_lang-d6c64623.js";import{_ as x,a as h,e as w,F as k}from"./form-69522227.js";import{I}from"./ImageEdit-b40a69a1.js";import{M as O,d as S,e as L,i as C,g as E,f as B}from"./Task-e3178eaa.js";import{C as F}from"./tool-3c7e2283.js";import{a as G}from"./index-f23346c2.js";import"./index-e32d7919.js";import"./index-5faf8ab3.js";import"./withInstall-a23174bf.js";import"./useGlobalIcon-99a58828.js";import"./useVModel-63d31bce.js";import"./index-76b22244.js";import"./dialog-1e319511.js";import"./index-839eb681.js";import"./v4-77ca1988.js";import"./index.vue_vue_type_style_index_0_lang-90c1354d.js";import"./ScrollLoad.vue_vue_type_script_setup_true_lang-e44f7581.js";import"./_plugin-vue_export-helper-1b428a4d.js";const q=a({props:{list:Object,status:String,backgroundImage:String,config:Object,OverlayImages:Object,module_status:Number},emits:["submit"],setup(a,{emit:o}){const n=s(O.wait);t((()=>a.module_status),(a=>{a&&(n.value=a)}));const r=a=>{o("submit",a)},m=()=>{const{status:s}=a;return""==s?e(x,null,null):"loading"==s?e(h,null,null):"edit"==s?"":e("div",{class:"load-success-box"},[e("div",{class:"result-img-box narrow-scrollbar"},[a.list?a.list.map((a=>e("div",{class:"result-img"},[e("img",{class:"img",src:a,alt:""},null)]))):""]),e("div",{class:"download-img-box"},[e(j,null,{default:()=>[u("下载")]})])])};return()=>e("div",{class:"img-res-status"},[m(),l(e(I,{module_status:n.value,list:a.OverlayImages,edit_image:a.backgroundImage,config:a.config,onSubmit:r},null),[[i,"edit"==a.status]])])}}),z={class:"custom-model-template"},A={class:"generation-box-parent"},M={class:"interaction-form"},V={class:"confirm-box"},D=d("div",{class:"pay-num"},null,-1),N={class:"generate-result"},Q=d("div",{class:"help"},null,-1),T=a({__name:"index",setup(a){const t=s(!1),x=g().query.id,h=s();let I=null;const C=o({url:"",prompt:"",name:""}),T=s({}),H=o({list:[],callback_list:[],status:"",module_status:O.wait,reset_num:1}),J=o({list:[]}),K=s(),P=s(),R=a=>{J.list.length?J.list[0]=a:J.list.push(a)},U=a=>{C.url=a.url,C.prompt=a.prompt,C.name=a.name,H.status="edit"},W=a=>{I=window.setInterval((()=>{(async a=>{try{let s=await B({key:a});0==s.code&&s.data.image&&(H.status="success",s.data.image.length>H.callback_list.length&&(H.callback_list=s.data.image),4==s.data.image.length&&X())}catch(s){}})(a)}),2e3)},X=()=>{I&&(window.clearInterval(I),clearInterval(I),I=null)},Y=()=>{H.list.forEach((a=>{a.lists.forEach((a=>{a.value&&(a.value="")}))})),H.status="",H.callback_list=[],H.reset_num+=1},Z=a=>{if(a){const s=w(H.list);s&&(s.image=a,s[C.name]=C.prompt,$(s))}},$=async a=>{try{let s=await L({scenario_id:K.value,parameters:a});0==s.code&&(W(s.data.uuid),H.status="loading")}catch(s){}},aa=()=>{w(H.list)&&(H.module_status=O.upload,H.status="loading")};n((async()=>{(async()=>{try{let a=await S();0==a.code&&(T.value=a.data)}catch(a){}})()}));const sa=async()=>{try{t.value=!0;let a=await E(x,"id");if(0==a.code){K.value=a.data.id,P.value=a.data.sub_type;let s=a.data.form;if(!s.length)return void G("表单未配置");s=k(s).list;H.list=s}t.value=!1,v((()=>{h.value&&F(h.value)}))}catch(a){t.value=!1}};return r((async()=>{x?await sa():G("禁止访问")})),m((()=>{X()})),(a,s)=>(f(),c("div",z,[d("div",A,[l(d("div",{class:"generation-box",ref_key:"GenerationBox",ref:h},[d("div",M,[e(b,{formList:H.list,sub_type:P.value,onSubmitBackGround:U,onSubmitLocalImage:R},null,8,["formList","sub_type"]),d("div",V,[D,e(j,{onClick:Y,width:"20%"},{default:_((()=>[u("重置")])),_:1}),e(j,{onClick:aa,width:"50%",bold:""},{default:_((()=>[u("生成图片")])),_:1})])]),d("div",N,[e(p(q),{status:H.status,backgroundImage:C.url,OverlayImages:J.list,list:H.callback_list,module_status:H.module_status,config:T.value,onSubmit:Z},null,8,["status","backgroundImage","OverlayImages","list","module_status","config"])])],512),[[i,!t.value]])]),Q,l(e(y,null,null,512),[[i,t.value]])]))}});export{T as default};
