import{_ as O}from"./CviodaRj.js";import{f as M,a7 as Q,h as W,j as X,s as Y,l as Z,m as tt,q as g,n as et,ac as S,ax as T,aF as ot,o,c as r,a as e,B as i,b as v,w as $,d as rt,F as m,C as G,t as L,aG as st,aH as at}from"./rj9DroTS.js";import{_ as nt}from"./CaYkGoDq.js";import{_ as it}from"./BfB93GgF.js";import{B as lt}from"./BqdG2yZI.js";import{c as s,b as a,e as x}from"./DRm_W2OS.js";import{u as dt}from"./D8YVGxht.js";import{_ as pt}from"./Cz8y7TzG.js";const ct=s("input-group",`
 display: inline-flex;
 width: 100%;
 flex-wrap: nowrap;
 vertical-align: bottom;
`,[a(">",[s("input",[a("&:not(:last-child)",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `),a("&:not(:first-child)",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 margin-left: -1px!important;
 `)]),s("button",[a("&:not(:last-child)",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `,[x("state-border, border",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `)]),a("&:not(:first-child)",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `,[x("state-border, border",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `)])]),a("*",[a("&:not(:last-child)",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `,[a(">",[s("input",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `),s("base-selection",[s("base-selection-label",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `),s("base-selection-tags",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `),x("box-shadow, border, state-border",`
 border-top-right-radius: 0!important;
 border-bottom-right-radius: 0!important;
 `)])])]),a("&:not(:first-child)",`
 margin-left: -1px!important;
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `,[a(">",[s("input",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `),s("base-selection",[s("base-selection-label",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `),s("base-selection-tags",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `),x("box-shadow, border, state-border",`
 border-top-left-radius: 0!important;
 border-bottom-left-radius: 0!important;
 `)])])])])])]),mt={},ut=M({name:"InputGroup",props:mt,setup(u){const{mergedClsPrefixRef:b}=Q(u);return dt("-input-group",ct,b),{mergedClsPrefix:b}},render(){const{mergedClsPrefix:u}=this;return W("div",{class:`${u}-input-group`},this.$slots)}}),bt=["checked"],ft={class:"modal",role:"dialog"},ht={class:"modal-box max-w-[760px] flex items-center flex-col"},_t={class:"flex flex-col gap-4 w-full"},gt={class:"flex text-base items-center gap-1"},vt=e("span",null,"创意生成工具",-1),xt={class:"action"},yt={key:0,class:"flex flex-wrap gap-2 items-start"},kt=["onClick"],Ct={key:0,class:"min-h-20 flex flex-col gap-2"},wt={class:"text-sm"},Ft=["onClick"],Bt={key:1,class:"rounded-box bg-[#f7f8fa] p-4 md:p-8"},St={class:"flex flex-col items-center justify-center mt-4 min-h-[140px]"},Tt={key:0,ref:"target",class:"loading loading-ring loading-md mb-4"},$t=e("img",{class:"w-20",src:nt},null,-1),Gt=e("div",{class:"mt-4 text-gray"}," 暂无生成结果... ",-1),It=M({__name:"CreativeGeneratorModal",emits:["done"],setup(u,{expose:b,emit:N}){const P=X(),{userInfo:k,isLogin:j,currAddress:Lt}=Y(P),C=Z("token"),w=tt(),l=g(!1),f=et(),d=S({prompt:""}),p=S({prompt:""}),c=g([]),h=g(!1),q=N;b({open(){if(!j.value){k.value={},C.value="",w.value="",f.add({severity:"error",summary:"请先登录！",life:3e3}),T();return}h.value=!0,U()}});const F=()=>{d.prompt="",p.prompt="",l.value=!1,c.value=[],h.value=!1,document.querySelector("#generator_modal").checked=!1},z=t=>{q("done",t),F()},A=async()=>{if(l.value=!0,!d.prompt){f.add({severity:"error",summary:"请输入主体内容！",life:3e3}),l.value=!1;return}try{c.value=[],p.prompt=it.cloneDeep(d.prompt);const t=await st(p);if(t.code===200)c.value=t.data??[],l.value=!1;else if(t.code===401){k.value={},C.value="",w.value="",f.add({severity:"error",summary:"请先登录！",life:3e3}),T(),h.value=!1,document.querySelector("#generator_modal").checked=!1;return}else throw t.message;l.value=!1}catch(t){l.value=!1,f.add({severity:"error",summary:t,life:3e3})}},D=()=>{p.prompt=""},I=t=>{t||(p.prompt="")},B=g([]),U=async()=>{const{error:t,data:_}=await ot();t||(B.value=_)},V=t=>{d.prompt?d.prompt+=` ${t.title}`:d.prompt+=`${t.title}`,at({id:t.id})};return(t,_)=>{const E=O,R=pt,H=lt,J=ut;return o(),r(m,null,[e("input",{id:"generator_modal",type:"checkbox",class:"modal-toggle",checked:i(h)},null,8,bt),e("div",ft,[e("div",ht,[e("button",{class:"btn text-lg btn-sm btn-circle btn-ghost absolute right-4 top-4 z-10",onClick:F}," ✕ "),e("div",_t,[e("div",gt,[v(E,{name:"robot",class:"non-h text-lg"}),vt]),e("div",xt,[v(J,null,{default:$(()=>[v(R,{value:i(d).prompt,"onUpdate:value":[_[0]||(_[0]=n=>i(d).prompt=n),I],maxlength:20,clearable:"","show-count":"",class:"bg-[#F7F8FA]",placeholder:"输入你想要的主体内容，如美少女、沙滩等",size:"large",onClear:D},null,8,["value"]),v(H,{type:"primary",size:"large",loading:i(l),onClick:A},{default:$(()=>[rt(" 生成 ")]),_:1},8,["loading"])]),_:1})]),i(p).prompt?(o(),r(m,{key:1},[i(c).length>0?(o(),r("div",Ct,[(o(!0),r(m,null,G(i(c),(n,y)=>(o(),r("div",{key:y,class:"group flex border border-[#F7F8FA] rounded-lg p-4 gap-2 bg-[#F2F2F2] hover:border-[#C1C5CD] justify-between transition-all duration-300"},[e("span",wt,L(n),1),e("button",{class:"btn btn-sm group-hover:btn-primary transition-all duration-300",onClick:K=>z(n)}," 去创作 ",8,Ft)]))),128))])):(o(),r("div",Bt,[e("div",St,[i(l)?(o(),r("span",Tt,null,512)):(o(),r(m,{key:1},[$t,Gt],64))])]))],64)):(o(),r("div",yt,[(o(!0),r(m,null,G(i(B),(n,y)=>(o(),r("div",{key:y,class:"btn btn-sm",onClick:K=>V(n)},L(n==null?void 0:n.title),9,kt))),128))]))])])])],64)}}});export{It as _};
