import{f as a,k as s,V as t,h as l,z as e,v as i,i as o,L as n,D as u,E as r,x as c,Q as d,w as m,F as v,A as _,o as p}from"./vue-c4996fb3.js";import{_ as g}from"./CustomForm.vue_vue_type_style_index_0_lang-1d30a866.js";import{_ as f}from"./loading2.vue_vue_type_style_index_0_lang-83e3a6ec.js";import{_ as y}from"./resetbutton.vue_vue_type_style_index_0_lang-d6c64623.js";import{_ as x,a as j,F as b}from"./form-69522227.js";import{b as h,g as w,c as k,d as I,e as F,f as L}from"./Task-e3178eaa.js";import{V as z}from"./tool-3c7e2283.js";import{a as C}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";const E=a({props:{list:Object,status:String},setup(a,l){const e=()=>{const{status:l}=a;return""==l?s(x,null,null):"loading"==l?s(j,null,null):s("div",{class:"load-success-box"},[s("div",{class:"result-img-box"},[a.list?a.list.map((a=>s("div",{class:"result-img"},[s("img",{class:"img",src:a,alt:""},null)]))):""]),s("div",{class:"download-img-box"},[s(y,null,{default:()=>[t("下载")]})])])};return()=>s("div",{class:"img-res-status"},[e()])}}),V={class:"custom-image-generation-box"},q={class:"generation-box-parent"},A={class:"interaction-form"},G={class:"confirm-box"},S=r("div",{class:"pay-num"},null,-1),B={class:"generate-result"},D=r("div",{class:"help"},null,-1),M=a({__name:"index",setup(a){const x=l(!1),j=_().query.id,h=l();let M=null;const O=l(0),Q=l(!1),T=l({}),H=e({list:[],callback_list:[],status:"",reset_num:1}),J=l();i((()=>Q.value),(a=>{a&&(async()=>{try{let a=await I();0==a.code&&(T.value=a.data)}catch(a){}})()}));const K=a=>{M=window.setInterval((()=>{(async a=>{try{let s=await L({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&&s.data.image.length!=O.value||N())}catch(s){}})(a)}),2e3)},N=()=>{M&&(window.clearInterval(M),clearInterval(M),M=null)},P=()=>{H.list.forEach((a=>{a.lists.forEach((a=>{a.value&&(a.value="")}))})),H.status="",H.callback_list=[]},R=()=>{if(M)return void C("请等待上一个任务完成");let a={};for(let s=0;s<H.list.length;s++){let t=H.list[s];for(let s=0;s<t.lists.length;s++){let l=t.lists[s],e=z(l.rules,l.value,l.name);if(e)return void C(e);if("radio_group_size"==l.type&&""==l.value){let s=l.options.find((a=>"custom"==a.type));if(s){if(!s.value1||!s.value2)return void C("自定义图片尺寸未填写完整");a[l.name]=s.value1+"x"+s.value2}}l.value&&("number"==l.name?a[l.name]=parseFloat(l.value+""):a[l.name]=l.value)}}(async a=>{try{let s=await F({scenario_id:J.value,parameters:a});0==s.code&&(O.value=a.number,K(s.data.uuid),H.status="loading")}catch(s){}})(a)};return o((async()=>{j?await(async()=>{try{x.value=!0;let a=await w(j,"id");if(0==a.code){J.value=a.data.id;let s=a.data.form;if(!s.length)return void C("表单未配置");{s.push(k);const a=b(s);s=a.list,a.al_config&&(Q.value=!0)}H.list=s}x.value=!1}catch(a){x.value=!1}})():C("禁止访问")})),n((()=>{N()})),(a,l)=>(p(),u("div",V,[r("div",q,[c(r("div",{class:"generation-box",ref_key:"GenerationBox",ref:h},[r("div",A,[s(g,{formList:H.list,config:T.value},null,8,["formList","config"]),r("div",G,[S,s(y,{onClick:P,width:"20%"},{default:m((()=>[t("重置")])),_:1}),s(y,{onClick:R,width:"50%",bold:""},{default:m((()=>[t("生成图片")])),_:1})])]),r("div",B,[s(v(E),{status:H.status,list:H.callback_list},null,8,["status","list"])])],512),[[d,!x.value]])]),D,c(s(f,null,null,512),[[d,x.value]])]))}});export{M as default};
