import{f as s,h as t,z as e,i as l,D as a,x as i,Q as o,E as r,k as n,w as u,A as m,n as p,o as _,V as c}from"./vue-c4996fb3.js";import{_ as d}from"./CustomForm.vue_vue_type_style_index_0_lang-1d30a866.js";import{_ as v}from"./resetbutton.vue_vue_type_style_index_0_lang-d6c64623.js";import{_ as f}from"./gptmessage.vue_vue_type_style_index_0_lang-7e78322b.js";import{F as g,g as y,u as j,C as x}from"./Task-e3178eaa.js";import{a as h}from"./index-f23346c2.js";import{_ as w}from"./loading2.vue_vue_type_style_index_0_lang-83e3a6ec.js";import{V as L,C as k}from"./tool-3c7e2283.js";import{F as C}from"./form-69522227.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 b={class:"custom-copywriting-generation-page"},E=["src"],F={class:"interaction-form"},I={class:"confirm-box"},S=r("div",null,"字符余额：0/50000",-1),V=r("div",{class:"cust-line"},null,-1),q=s({__name:"index",setup(s){const g=m().query.id,q={tips:new URL("/assets/tips-c132fa27.png",self.location).href},z=t(),A=t(),B=t(""),D=t(!1),G=e({list:[]}),J=e({list:[],localList:[]}),M=async()=>{try{D.value=!0;let s=await y(g,"id");if(0==s.code){A.value=s.data.id,B.value=s.data.example_image;let t=s.data.form;t=C(t).list,G.list=t}D.value=!1,p((()=>{z.value&&k(z.value)}))}catch(s){D.value=!1}},N=()=>{G.list.forEach((s=>{s.lists.forEach((s=>{s.value&&(s.value="")}))}))},O=()=>{let s={};for(let t=0;t<G.list.length;t++){let e=G.list[t];for(let t=0;t<e.lists.length;t++){let l=e.lists[t],a=L(l.rules,l.value);if(a)return void h(a);s[l.name]=l.value}}(async s=>{try{J.list.push({message:""});let t=await j({scenario_id:A.value,messages:[],parameters:s});if(0==t.code){J.localList=t.data,localStorage.setItem(x,JSON.stringify(J.localList));let s=J.localList.filter((s=>"assistant"==s.role));s&&s.length&&(J.list[J.list.length-1].message=s[s.length-1].content)}}catch(t){J.list.pop()}})(s)};return l((async()=>{g?await M():h("禁止访问")})),(s,t)=>{var e;return _(),a("div",b,[i(r("div",{class:"custom-copywriting-generation",ref_key:"CopywritingBox",ref:z},[r("img",{class:"tip-box",src:null!=(e=B.value)?e:q.tips,alt:""},null,8,E),r("div",F,[n(d,{formList:G.list},null,8,["formList"]),r("div",I,[S,n(v,{onClick:N,width:"20%"},{default:u((()=>[c("重置")])),_:1}),n(v,{onClick:O,width:"50%",bold:""},{default:u((()=>[c("生成文案")])),_:1})]),V,n(f,{computed:"",list:J.list},null,8,["list"])])],512),[[o,!D.value]]),i(n(w,null,null,512),[[o,D.value]])])}}});export{q as default};
