@acedatacloud/nexior 3.31.0 → 3.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Auth-FDpP6sdw.js → Auth-BMFPBOLC.js} +1 -1
- package/dist/assets/{BotPlaceholder-C_tpj9cL.js → BotPlaceholder-C2zBHB2O.js} +1 -1
- package/dist/assets/{Callback-CF8NsFTN.js → Callback-PEFsbUF_.js} +1 -1
- package/dist/assets/{Console-DyDrK8jD.js → Console-DzC4Pf1q.js} +1 -1
- package/dist/assets/{Conversation-CbIvRgjb.js → Conversation-D2Iq4Xrq.js} +1 -1
- package/dist/assets/{CopyToClipboard-BGClcrVG.js → CopyToClipboard-D0zLUUky.js} +1 -1
- package/dist/assets/{Detail-Cc46R_61.js → Detail-DXaYd7bz.js} +2 -2
- package/dist/assets/{EditArray-DhB4A-4P.js → EditArray-CKHCiyfj.js} +1 -1
- package/dist/assets/{Extra-OG6qZqkS.js → Extra-QjRtYRyw.js} +1 -1
- package/dist/assets/{FilePreview-vHpQ_39Y.js → FilePreview-Cr0a54pM.js} +1 -1
- package/dist/assets/{History-DkRw43Cl.js → History-AVZYRpis.js} +1 -1
- package/dist/assets/{ImagePreview-Dif2Q49Y.js → ImagePreview-Dl9A5DPA.js} +1 -1
- package/dist/assets/{ImageWrapper-BskBzKqs.js → ImageWrapper-SReVU_Bh.js} +1 -1
- package/dist/assets/{Index-D-RbCzhR.js → Index-BOfXGPWU.js} +1 -1
- package/dist/assets/{Index-CQsHLtL9.js → Index-BPCnDcO8.js} +1 -1
- package/dist/assets/{Index-B_WaHvVq.js → Index-BSk3PuY2.js} +1 -1
- package/dist/assets/{Index-Q9b6AHOk.css → Index-BTa-g985.css} +1 -1
- package/dist/assets/{Index-BhtS87g8.js → Index-BZNFCobX.js} +1 -1
- package/dist/assets/{Index-BJeIJzAF.js → Index-Bdyvwk3P.js} +1 -1
- package/dist/assets/{Index-DAl7VUx0.js → Index-Bryr2--q.js} +1 -1
- package/dist/assets/{Index-CvWL3dnP.js → Index-BtOH7NOk.js} +1 -1
- package/dist/assets/{Index-AOp1iyZX.js → Index-CRlM8kzc.js} +1 -1
- package/dist/assets/{Index-Bs6AJerX.js → Index-CjLBLZu5.js} +1 -1
- package/dist/assets/{Index-DI0a679Y.js → Index-CooEkPU1.js} +1 -1
- package/dist/assets/{Index-BhKFb4US.js → Index-CvDrq9oO.js} +1 -1
- package/dist/assets/{Index-fmHObafV.js → Index-CziKsoUM.js} +1 -1
- package/dist/assets/{Index-BOSlmfKu.js → Index-Di6YZiYf.js} +1 -1
- package/dist/assets/{Index-B13mfXWf.js → Index-Dj0TB3rn.js} +1 -1
- package/dist/assets/{Index-By3C66Xq.js → Index-Dp_xDqU5.js} +1 -1
- package/dist/assets/{Index-7-MqNqOx.js → Index-DvcOw7mQ.js} +1 -1
- package/dist/assets/{Index-Bi5z34-z.js → Index-L4ganskU.js} +1 -1
- package/dist/assets/{Index-CE9mr3hy.js → Index-U9e5mECO.js} +1 -1
- package/dist/assets/{Index-m8G7Pz-J.js → Index-V9wxs9fX.js} +1 -1
- package/dist/assets/{Index-CvNs7Qc8.js → Index-ZQdXM0Qi.js} +1 -1
- package/dist/assets/{Invitees-BjwE0w-8.js → Invitees-BkrIczI4.js} +1 -1
- package/dist/assets/{List-DVknUaOz.js → List-ByCyyjcy.js} +1 -1
- package/dist/assets/{List-8o9CvgyI.js → List-D9VBxGDJ.js} +1 -1
- package/dist/assets/{List-BfHX6UFu.js → List-DnnTHjwR.js} +1 -1
- package/dist/assets/{Main-B9Wl0aM6.js → Main-B7Iuj_gr.js} +1 -1
- package/dist/assets/{Navigator-CZkWVWzN.js → Navigator-Bfg5MB9U.js} +1 -1
- package/dist/assets/{NoTasks-4TJvTcNH.js → NoTasks-CXFbDY0A.js} +1 -1
- package/dist/assets/{Pagination-DrZT-YqX.js → Pagination-pUGLnKvW.js} +1 -1
- package/dist/assets/{ScrollList-BSHydg5K.js → ScrollList-Ctwoso0M.js} +1 -1
- package/dist/assets/{Status-CU3tRVGG.js → Status-zVvonX-o.js} +1 -1
- package/dist/assets/{Subscribe-DEpZJt9v.js → Subscribe-Csw468W0.js} +1 -1
- package/dist/assets/{TransportWebHID-x82bKdqW.js → TransportWebHID-CrwmabwY.js} +1 -1
- package/dist/assets/{VideoPlayer-DhXW0ZpT.js → VideoPlayer-CQ5XJCD4.js} +1 -1
- package/dist/assets/avatar-Bz6boBn2.js +1 -0
- package/dist/assets/avatar-CfYRMFXV.css +1 -0
- package/dist/assets/{bignumber-D2i_F2iN.js → bignumber-B90gMj7-.js} +1 -1
- package/dist/assets/{distribution-DQWow-W5.js → distribution-tc7Ny12x.js} +1 -1
- package/dist/assets/{index-DgtHfSqf.js → index-Cg8W5HXP.js} +4 -4
- package/dist/assets/{index-Dd5huPwi.js → index-D-UbBaog.js} +1 -1
- package/dist/assets/{index-nzc2MroZ.js → index-DLFOYy34.js} +1 -1
- package/dist/assets/{index-BPpDhZjH.js → index-QbelgbtK.js} +1 -1
- package/dist/assets/{index-BJU-syOe.js → index-Qp3BWPL0.js} +1 -1
- package/dist/assets/{index-BnkMqzhi.js → index-at5IgPRK.js} +1 -1
- package/dist/assets/{index-DWmgW--A.js → index-hETw3-Tt.js} +1 -1
- package/dist/assets/{index-7qIS8l-a.js → index-kPB6cEeA.js} +1 -1
- package/dist/assets/{index.es-CQANB9vJ.js → index.es-sibb1JwV.js} +1 -1
- package/dist/assets/{order-iKdGqXyS.js → order-DBr_GxfO.js} +1 -1
- package/dist/assets/{price-Cbls6Qoc.js → price-CUVRj46N.js} +1 -1
- package/dist/assets/{solana-wallets-CkstrrV4.js → solana-wallets-CzHDaNyx.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-B1Go1xNW.js → solanaEmbed.esm-E1uzZz_Y.js} +1 -1
- package/dist/assets/{string_decoder-ll7baEuM.js → string_decoder-CImFLFld.js} +1 -1
- package/dist/assets/{vendor-web3-BXoVw72d.js → vendor-web3-vJ0jlMeb.js} +4 -4
- package/dist/assets/{web-Bl4nr7zA.js → web-CmA02DXc.js} +1 -1
- package/dist/assets/{web-DE8XF-r4.js → web-DUcCuWS_.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/avatar-Bypfdb1U.js +0 -1
- package/dist/assets/avatar-i-yziJxn.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as M}from"./index.es-CQANB9vJ.js";import{l as O,S as re,k as ce,N as ue,O as de,t as pe,u as C,s as B,a1 as x,a2 as ee,U as ie,e as J,j as N,D as ae,F as le,V as te,a3 as me,a4 as fe,Z as he,f as _e,g as ge,h as $e,p as ve,q as ye,K as ke,Y as we,a5 as be,a6 as Ce}from"./vendor-element-plus-B4FTqxj4.js";import{d as S,C as g,G as n,T as s,E as K,K as m,ai as a,D as i,O as y,R as u,S as D,ag as Y,J as w,Q as L,L as q,aq as Q,X as F,c as I,u as T,w as Se,b as Ve,P as Le,U as Ae}from"./vendor-vue-1w_NBnjl.js";import{_ as A,c4 as je,c5 as P,aj as Fe,ay as R,c6 as H,ar as Ee,ax as Te}from"./index-DgtHfSqf.js";import{I as G,S as Ue}from"./ScrollList-BSHydg5K.js";import{C as Pe,N as Ie}from"./NoTasks-4TJvTcNH.js";import{a as ze}from"./price-Cbls6Qoc.js";import{j as Z}from"./vendor-dayjs-CzbnksQQ.js";import{l as Ge}from"./pagination-CihAE3FS.js";import"./vendor-web3-BXoVw72d.js";import"./vendor-axios-NIGUFBhG.js";import"./vendor-vue-router-Dj5bcX0v.js";const Me=S({name:"LayoutSuno",components:{ElDrawer:re,ElButton:O,FontAwesomeIcon:M},data(){return{drawer:!1,preview:!1}},computed:{}}),Re={class:"main flex flex-row flex-1"},De={class:"config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]"},We={class:"result h-full flex flex-col flex-1 min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]"},Oe={class:"preview h-full w-[300px] flex flex-col"};function Be(e,t,l,o,c,p){const d=a("font-awesome-icon"),_=a("el-button"),$=a("el-drawer");return i(),g("div",Re,[n("div",De,[K(e.$slots,"config",{},void 0,!0)]),n("div",We,[K(e.$slots,"result",{},void 0,!0)]),n("div",Oe,[K(e.$slots,"preview",{},void 0,!0)]),s(_,{circle:"",class:"menu",onClick:t[0]||(t[0]=r=>e.drawer=!0)},{default:m(()=>[s(d,{icon:"fa-solid fa-magic"})]),_:1}),s($,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=r=>e.drawer=r),direction:"ltr","with-header":!1,size:"340px",class:"drawer"},{default:m(()=>[K(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const Ne=A(Me,[["render",Be],["__scopeId","data-v-c6c85757"]]),qe=S({name:"TypeSelector",components:{ElSelect:de,ElOption:ue,ElSwitch:ce},data(){return{options:[{label:"Suno v5",value:"chirp-v5",info:"8 min"},{label:"Suno v4.5+",value:"chirp-v4-5-plus",info:"8 min"},{label:"Suno v4.5",value:"chirp-v4-5",info:"4 min"},{label:"Suno v4",value:"chirp-v4",info:"2.5 min"},{label:"Suno v3.5",value:"chirp-v3-5",info:"2 min"},{label:"Suno v3",value:"chirp-v3-0",info:"2 min"}]}},computed:{custom:{get(){return this.$store.state.suno?.config?.custom||!1},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,custom:e})}},instrumental:{get(){return this.$store.state.suno?.config?.instrumental||!1},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,instrumental:e})}},model:{get(){return this.$store.state.suno?.config?.model},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e})}}},mounted(){this.model||(this.model=je)}}),He={class:"flex items-center justify-between mb-3"},Ke={class:"text-sm font-bold"},Ze={class:"mb-3"},Xe={class:"flex items-center mb-1"},Ye={class:"text-sm font-bold"},Je={class:"flex items-center justify-between w-full"},Qe={class:"text-xs text-[var(--el-text-color-placeholder)]"},xe={key:0,class:"flex items-center justify-between mb-3"},et={class:"text-sm font-bold"};function tt(e,t,l,o,c,p){const d=a("el-switch"),_=a("el-option"),$=a("el-select");return i(),g("div",null,[n("div",He,[n("span",Ke,u(e.$t("suno.name.type")),1),s(d,{modelValue:e.custom,"onUpdate:modelValue":t[0]||(t[0]=r=>e.custom=r),size:"small"},null,8,["modelValue"])]),n("div",Ze,[n("div",Xe,[n("span",Ye,u(e.$t("suno.name.model")),1)]),s($,{modelValue:e.model,"onUpdate:modelValue":t[1]||(t[1]=r=>e.model=r),class:"w-full",size:"default",placeholder:e.$t("suno.placeholder.select")},{default:m(()=>[(i(!0),g(D,null,Y(e.options,r=>(i(),w(_,{key:r.value,label:r.label,value:r.value},{default:m(()=>[n("div",Je,[n("span",null,u(r.label),1),n("span",Qe,u(r.info),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),e.custom?(i(),g("div",xe,[n("span",et,u(e.$t("suno.name.instrumental")),1),s(d,{modelValue:e.instrumental,"onUpdate:modelValue":t[2]||(t[2]=r=>e.instrumental=r),size:"small"},null,8,["modelValue"])])):y("",!0)])}const ot=A(qe,[["render",tt]]),st=S({name:"UploadAudio",components:{ElUpload:pe,ElButton:O,InfoIcon:G,FontAwesomeIcon:M},emits:["change"],data(){return{fileList:[],uploadUrl:Fe()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.suno?.config?.audio_id},set(){}}},watch:{urls:{handler(e){this.$emit("change",e)}}},mounted(){this.value||(this.value=void 0),this.onSetAudio()},methods:{onExceed(){C.warning(this.$t("suno.message.uploadReferencesExceed"))},onError(){C.error(this.$t("suno.message.uploadReferencesError"))},async onSuccess(){const e=this.urls?.[0];await this.onGenerateAudioId(e)},async onGenerateAudioId(e){const t={audio_url:e},l=this.credential?.token;if(!l){console.error("no token specified");return}C.info(this.$t("suno.message.startingUploadAudio")),P.upload(t,{token:l}).then(o=>{console.debug("get upload music success",o.data);const c=o.data?.data.audio_id;this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,audio_id:c,action:"upload_extend"}),C.success(this.$t("suno.message.startUploadAudioSuccess"))}).catch(o=>{C.error(o?.response?.data?.error?.message||this.$t("suno.message.startUploadAudioFailed"))})},onSetAudio(){}}}),nt={class:"relative"},it={class:"flex justify-between"},at={class:"flex justify-start items-center"},lt={class:"text-sm font-bold"};function rt(e,t,l,o,c,p){const d=a("info-icon"),_=a("font-awesome-icon"),$=a("el-button"),r=a("el-upload");return i(),g("div",nt,[n("div",it,[n("div",at,[n("span",lt,u(e.$t("suno.name.referenceAudios")),1),s(d,{content:e.$t("suno.description.uploadAudios")},null,8,["content"])])]),s(r,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=h=>e.fileList=h),name:"file",limit:1,class:"upload-wrapper",action:e.uploadUrl,accept:".mp3","show-file-list":!0,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:m(()=>[s($,{round:"",type:"primary",size:"small",class:"btn btn-upload"},{default:m(()=>[s(_,{icon:"fa-solid fa-upload",class:"icon mr-1"}),L(" "+u(e.$t("suno.button.uploadAudios")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","headers"])])}const ct=A(st,[["render",rt],["__scopeId","data-v-6236152c"]]),ut="",dt=S({name:"PromptInput",components:{ElInput:B,InfoIcon:G},computed:{prompt:{get(){return this.$store.state.suno?.config?.prompt},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=ut)}}),pt={class:"field"},mt={class:"flex items-center mb-1"},ft={class:"text-sm font-bold"};function ht(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-input");return i(),g("div",pt,[n("div",mt,[n("span",ft,u(e.$t("suno.name.songDescription")),1),s(d,{content:e.$t("suno.description.prompt")},null,8,["content"])]),s(_,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||(t[0]=$=>e.prompt=$),rows:4,type:"textarea",placeholder:e.$t("suno.placeholder.prompt")},null,8,["modelValue","placeholder"])])}const _t=A(dt,[["render",ht]]),gt="",$t=S({name:"LyricInput",components:{ElInput:B,ElButton:O,FontAwesomeIcon:M,InfoIcon:G},data(){return{generatingLyrics:!1}},computed:{lyric:{get(){return this.$store.state.suno?.config?.lyric},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric:e})}},config(){return this.$store.state.suno?.config},credential(){return this.$store.state.suno?.credential}},mounted(){this.lyric||(this.lyric=gt)},methods:{async onGenerateLyrics(){const e=this.credential?.token;if(!e)return;const t=this.config?.style||this.config?.title||"a beautiful song";this.generatingLyrics=!0,C.info(this.$t("suno.message.generatingLyrics"));try{const o=(await P.lyric({prompt:t},{token:e})).data?.data;o?.text&&(this.lyric=o.text,o?.title&&!this.config?.title&&this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric:o.text,title:o.title}),C.success(this.$t("suno.message.generateLyricsSuccess")))}catch{C.error(this.$t("suno.message.generateLyricsFailed"))}finally{this.generatingLyrics=!1}}}}),vt={class:"field"},yt={class:"flex items-center justify-between mb-1"},kt={class:"flex items-center"},wt={class:"text-sm font-bold"};function bt(e,t,l,o,c,p){const d=a("info-icon"),_=a("font-awesome-icon"),$=a("el-button"),r=a("el-input");return i(),g("div",vt,[n("div",yt,[n("div",kt,[n("span",wt,u(e.$t("suno.name.lyrics")),1),s(d,{content:e.$t("suno.description.lyrics")},null,8,["content"])]),e.config?.action!=="extend"?(i(),w($,{key:0,size:"small",loading:e.generatingLyrics,round:"",onClick:e.onGenerateLyrics},{default:m(()=>[e.generatingLyrics?y("",!0):(i(),w(_,{key:0,icon:"fa-solid fa-wand-magic-sparkles",class:"mr-1"})),L(" "+u(e.$t("suno.button.generate_lyrics")),1)]),_:1},8,["loading","onClick"])):y("",!0)]),e.config?.action!=="extend"?(i(),w(r,{key:0,modelValue:e.lyric,"onUpdate:modelValue":t[0]||(t[0]=h=>e.lyric=h),rows:5,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.lyrics")},null,8,["modelValue","placeholder"])):(i(),w(r,{key:1,modelValue:e.lyric,"onUpdate:modelValue":t[1]||(t[1]=h=>e.lyric=h),rows:5,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.extend.lyrics")},null,8,["modelValue","placeholder"]))])}const Ct=A($t,[["render",bt],["__scopeId","data-v-210d2670"]]),St=S({name:"StyleInput",components:{ElInput:B,ElButton:O,FontAwesomeIcon:M,InfoIcon:G},data(){return{optimizing:!1}},computed:{style:{get(){return this.$store.state.suno?.config?.style},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style:e})}},credential(){return this.$store.state.suno?.credential}},methods:{async onOptimizeStyle(){const e=this.credential?.token;if(!(!e||!this.style)){this.optimizing=!0,C.info(this.$t("suno.message.optimizingStyle"));try{const t=await P.style({prompt:this.style},{token:e}),l=t.data?.text||t.data?.data?.text;l&&(this.style=l,C.success(this.$t("suno.message.optimizeStyleSuccess")))}catch{C.error(this.$t("suno.message.optimizeStyleFailed"))}finally{this.optimizing=!1}}}}}),Vt={class:"field"},Lt={class:"flex items-center justify-between mb-1"},At={class:"flex items-center"},jt={class:"text-sm font-bold"};function Ft(e,t,l,o,c,p){const d=a("info-icon"),_=a("font-awesome-icon"),$=a("el-button"),r=a("el-input");return i(),g("div",Vt,[n("div",Lt,[n("div",At,[n("span",jt,u(e.$t("suno.name.style")),1),s(d,{content:e.$t("suno.description.style")},null,8,["content"])]),s($,{size:"small",loading:e.optimizing,round:"",onClick:e.onOptimizeStyle},{default:m(()=>[e.optimizing?y("",!0):(i(),w(_,{key:0,icon:"fa-solid fa-wand-magic-sparkles",class:"mr-1"})),L(" "+u(e.$t("suno.button.optimize_style")),1)]),_:1},8,["loading","onClick"])]),s(r,{modelValue:e.style,"onUpdate:modelValue":t[0]||(t[0]=h=>e.style=h),rows:2,type:"textarea",placeholder:e.$t("suno.placeholder.style")},null,8,["modelValue","placeholder"])])}const Et=A(St,[["render",Ft]]),Tt=S({name:"TitleInput",components:{ElInput:B,InfoIcon:G},computed:{title:{get(){return this.$store.state.suno?.config?.title},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,title:e})}}}}),Ut={class:"field"},Pt={class:"flex items-center mb-1"},It={class:"text-sm font-bold"};function zt(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-input");return i(),g("div",Ut,[n("div",Pt,[n("span",It,u(e.$t("suno.name.title")),1),s(d,{content:e.$t("suno.description.title")},null,8,["content"])]),s(_,{modelValue:e.title,"onUpdate:modelValue":t[0]||(t[0]=$=>e.title=$),placeholder:e.$t("suno.placeholder.title")},null,8,["modelValue","placeholder"])])}const Gt=A(Tt,[["render",zt]]);function W(e){const t=Math.floor(e)%60;e=Math.floor(e/60);const l=e%60,o=l<10?`0${l}`:l,c=t<10?`0${t}`:t;return o+":"+c}const Mt=S({name:"ExtendFromInput",components:{ElImage:N,ElIcon:J,ElInputNumber:ie,VideoPlay:ee,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){if(e===void 0){this.value=void 0;return}e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:W,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),Rt={class:"field"},Dt={class:"box"},Wt={class:"title font-bold"},Ot={class:"input-wrapper"},Bt={class:"task"},Nt={class:"left"},qt={key:2,class:"duration"},Ht={class:"info"},Kt={class:"title"},Zt={class:"style"};function Xt(e,t,l,o,c,p){const d=a("el-input-number"),_=a("el-image"),$=a("video-pause"),r=a("el-icon"),h=a("video-play"),b=Q("loading");return i(),g("div",Rt,[n("div",Dt,[n("h2",Wt,u(e.$t("suno.name.extend")),1),n("div",Ot,[s(d,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=f=>e.value=f),class:"value",min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.extend.continue_at"),onChange:e.handleChange},null,8,["modelValue","max","placeholder","onChange"])])]),n("div",Bt,[e.audio?(i(),g("div",{key:0,class:"audio",onClick:t[3]||(t[3]=f=>e.onClick(e.audio))},[q((i(),g("div",Nt,[s(_,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(i(),g("div",{key:0,class:"overlay",onClick:t[1]||(t[1]=f=>e.onPause(e.audio))},[s(r,null,{default:m(()=>[s($)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(i(),g("div",{key:1,class:"overlay",onClick:t[2]||(t[2]=f=>e.onPlay(e.audio))},[s(r,null,{default:m(()=>[s(h)]),_:1})])):y("",!0),e.audio?.duration?(i(),g("div",qt,u(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[b,!e.audio?.audio_url]]),n("div",Ht,[n("h2",Kt,u(e.audio?.title),1),n("p",Zt,u(e.audio?.style),1)])])):y("",!0)])])}const Yt=A(Mt,[["render",Xt],["__scopeId","data-v-bcce4821"]]),Jt=S({name:"CoverFromInput",components:{ElImage:N,ElIcon:J,VideoPlay:ee,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:W,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),Qt={class:"field"},xt={class:"box"},eo={class:"title font-bold"},to={class:"task"},oo={class:"left"},so={key:2,class:"duration"},no={class:"info"},io={class:"title"},ao={class:"style"};function lo(e,t,l,o,c,p){const d=a("el-image"),_=a("video-pause"),$=a("el-icon"),r=a("video-play"),h=Q("loading");return i(),g("div",Qt,[n("div",xt,[n("h2",eo,u(e.$t("suno.name.cover")),1)]),n("div",to,[e.audio?(i(),g("div",{key:0,class:"audio",onClick:t[2]||(t[2]=b=>e.onClick(e.audio))},[q((i(),g("div",oo,[s(d,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(i(),g("div",{key:0,class:"overlay",onClick:t[0]||(t[0]=b=>e.onPause(e.audio))},[s($,null,{default:m(()=>[s(_)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(i(),g("div",{key:1,class:"overlay",onClick:t[1]||(t[1]=b=>e.onPlay(e.audio))},[s($,null,{default:m(()=>[s(r)]),_:1})])):y("",!0),e.audio?.duration?(i(),g("div",so,u(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[h,!e.audio?.audio_url]]),n("div",no,[n("h2",io,u(e.audio?.title),1),n("p",ao,u(e.audio?.style),1)])])):y("",!0)])])}const ro=A(Jt,[["render",lo],["__scopeId","data-v-06640216"]]),co=S({name:"VocalGenderSelector",components:{ElRadioGroup:le,ElRadioButton:ae,InfoIcon:G},computed:{vocalGender:{get(){return this.$store.state.suno?.config?.vocal_gender||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,vocal_gender:e||void 0})}}}}),uo={class:"mb-2"},po={class:"flex items-center mb-1"},mo={class:"text-sm font-bold"};function fo(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-radio-button"),$=a("el-radio-group");return i(),g("div",uo,[n("div",po,[n("span",mo,u(e.$t("suno.name.vocalGender")),1),s(d,{content:e.$t("suno.description.vocalGender")},null,8,["content"])]),s($,{modelValue:e.vocalGender,"onUpdate:modelValue":t[0]||(t[0]=r=>e.vocalGender=r),size:"small"},{default:m(()=>[s(_,{value:""},{default:m(()=>[L(u(e.$t("suno.gender.auto")),1)]),_:1}),s(_,{value:"f"},{default:m(()=>[L(u(e.$t("suno.gender.female")),1)]),_:1}),s(_,{value:"m"},{default:m(()=>[L(u(e.$t("suno.gender.male")),1)]),_:1})]),_:1},8,["modelValue"])])}const ho=A(co,[["render",fo]]),_o=S({name:"AdvancedParams",components:{ElCollapse:fe,ElCollapseItem:me,ElInput:B,ElSlider:te,ElRadioGroup:le,ElRadioButton:ae},data(){return{activeNames:[]}},computed:{config(){return this.$store.state.suno?.config},isV5OrAbove(){return(this.config?.model||"")==="chirp-v5"},styleNegative:{get(){return this.$store.state.suno?.config?.style_negative||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style_negative:e||void 0})}},lyricPrompt:{get(){return this.$store.state.suno?.config?.lyric_prompt||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric_prompt:e||void 0})}},weirdness:{get(){return this.$store.state.suno?.config?.weirdness??0},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,weirdness:e||void 0})}},styleInfluence:{get(){return this.$store.state.suno?.config?.style_influence??50},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style_influence:e})}},variationCategory:{get(){return this.$store.state.suno?.config?.variation_category||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,variation_category:e||void 0})}},audioWeight:{get(){return this.$store.state.suno?.config?.audio_weight??50},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,audio_weight:e})}}}}),go={key:0,class:"mb-3"},$o={class:"flex items-center mb-1"},vo={class:"text-xs font-bold"},yo={key:1,class:"mb-3"},ko={class:"flex items-center mb-1"},wo={class:"text-xs font-bold"},bo={key:2,class:"mb-3"},Co={class:"flex items-center justify-between mb-1"},So={class:"text-xs font-bold"},Vo={class:"text-xs text-[var(--el-text-color-secondary)]"},Lo={key:3,class:"mb-3"},Ao={class:"flex items-center justify-between mb-1"},jo={class:"text-xs font-bold"},Fo={class:"text-xs text-[var(--el-text-color-secondary)]"},Eo={key:4,class:"mb-3"},To={class:"flex items-center mb-1"},Uo={class:"text-xs font-bold"},Po={key:5,class:"mb-3"},Io={class:"flex items-center justify-between mb-1"},zo={class:"text-xs font-bold"},Go={class:"text-xs text-[var(--el-text-color-secondary)]"};function Mo(e,t,l,o,c,p){const d=a("el-input"),_=a("el-slider"),$=a("el-radio-button"),r=a("el-radio-group"),h=a("el-collapse-item"),b=a("el-collapse");return i(),w(b,{modelValue:e.activeNames,"onUpdate:modelValue":t[6]||(t[6]=f=>e.activeNames=f),class:"advanced-collapse"},{default:m(()=>[s(h,{title:e.$t("suno.name.advancedParams"),name:"advanced"},{default:m(()=>[e.config?.custom?(i(),g("div",go,[n("div",$o,[n("span",vo,u(e.$t("suno.name.styleNegative")),1)]),s(d,{modelValue:e.styleNegative,"onUpdate:modelValue":t[0]||(t[0]=f=>e.styleNegative=f),size:"small",placeholder:e.$t("suno.placeholder.styleNegative")},null,8,["modelValue","placeholder"])])):y("",!0),e.config?.custom&&!e.config?.instrumental?(i(),g("div",yo,[n("div",ko,[n("span",wo,u(e.$t("suno.name.lyricPrompt")),1)]),s(d,{modelValue:e.lyricPrompt,"onUpdate:modelValue":t[1]||(t[1]=f=>e.lyricPrompt=f),size:"small",placeholder:e.$t("suno.placeholder.lyricPrompt")},null,8,["modelValue","placeholder"])])):y("",!0),e.config?.custom?(i(),g("div",bo,[n("div",Co,[n("span",So,u(e.$t("suno.name.weirdness")),1),n("span",Vo,u(e.weirdness??0),1)]),s(_,{modelValue:e.weirdness,"onUpdate:modelValue":t[2]||(t[2]=f=>e.weirdness=f),min:0,max:100,step:1,size:"small"},null,8,["modelValue"])])):y("",!0),e.config?.custom?(i(),g("div",Lo,[n("div",Ao,[n("span",jo,u(e.$t("suno.name.styleInfluence")),1),n("span",Fo,u(e.styleInfluence??50),1)]),s(_,{modelValue:e.styleInfluence,"onUpdate:modelValue":t[3]||(t[3]=f=>e.styleInfluence=f),min:0,max:100,step:1,size:"small"},null,8,["modelValue"])])):y("",!0),e.isV5OrAbove?(i(),g("div",Eo,[n("div",To,[n("span",Uo,u(e.$t("suno.name.variationCategory")),1)]),s(r,{modelValue:e.variationCategory,"onUpdate:modelValue":t[4]||(t[4]=f=>e.variationCategory=f),size:"small"},{default:m(()=>[s($,{value:""},{default:m(()=>[L(u(e.$t("suno.gender.auto")),1)]),_:1}),s($,{value:"high"},{default:m(()=>[L(u(e.$t("suno.variation.high")),1)]),_:1}),s($,{value:"low"},{default:m(()=>[L(u(e.$t("suno.variation.low")),1)]),_:1})]),_:1},8,["modelValue"])])):y("",!0),e.config?.action==="cover"?(i(),g("div",Po,[n("div",Io,[n("span",zo,u(e.$t("suno.name.audioWeight")),1),n("span",Go,u(e.audioWeight??50),1)]),s(_,{modelValue:e.audioWeight,"onUpdate:modelValue":t[5]||(t[5]=f=>e.audioWeight=f),min:0,max:100,step:1,size:"small"},null,8,["modelValue"])])):y("",!0)]),_:1},8,["title"])]),_:1},8,["modelValue"])}const Ro=A(_o,[["render",Mo],["__scopeId","data-v-be135363"]]),Do=S({name:"ReplaceSectionInput",components:{ElInputNumber:ie,ElImage:N,InfoIcon:G},computed:{audio(){return this.$store.state.suno?.config?.audio},replaceSectionStart:{get(){return this.$store.state.suno?.config?.replace_section_start},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,replace_section_start:e})}},replaceSectionEnd:{get(){return this.$store.state.suno?.config?.replace_section_end},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,replace_section_end:e})}}},methods:{onClick(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"})}}}),Wo={class:"field"},Oo={class:"flex items-center mb-2"},Bo={class:"text-sm font-bold m-0"},No={key:0,class:"task mb-2"},qo={class:"left relative w-[50px] h-[50px] mr-3 flex-shrink-0"},Ho={class:"info flex-1 min-w-0"},Ko={class:"text-sm font-bold m-0 truncate"},Zo={class:"text-xs text-[var(--el-text-color-secondary)] m-0 truncate"},Xo={class:"flex gap-2"};function Yo(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-image"),$=a("el-input-number"),r=Q("loading");return i(),g("div",Wo,[n("div",Oo,[n("h2",Bo,u(e.$t("suno.name.replaceSection")),1),s(d,{content:e.$t("suno.description.replaceSection")},null,8,["content"])]),e.audio?(i(),g("div",No,[n("div",{class:"audio flex items-center",onClick:t[0]||(t[0]=h=>e.onClick(e.audio))},[q((i(),g("div",qo,[s(_,{src:e.audio?.image_url,class:"w-full h-full rounded",fit:"cover"},null,8,["src"])])),[[r,!e.audio?.audio_url]]),n("div",Ho,[n("h2",Ko,u(e.audio?.title),1),n("p",Zo,u(e.audio?.style),1)])])])):y("",!0),n("div",Xo,[s($,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":t[1]||(t[1]=h=>e.replaceSectionStart=h),class:"flex-1",size:"small",min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.replaceSectionStart")},null,8,["modelValue","max","placeholder"]),s($,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":t[2]||(t[2]=h=>e.replaceSectionEnd=h),class:"flex-1",size:"small",min:e.replaceSectionStart||0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.replaceSectionEnd")},null,8,["modelValue","min","max","placeholder"])])])}const Jo=A(Do,[["render",Yo]]),Qo=S({name:"PresetPanel",components:{TypeSelector:ot,PromptInput:_t,LyricInput:Ct,StyleInput:Et,TitleInput:Gt,ExtendFromInput:Yt,CoverFromInput:ro,UploadAudio:ct,VocalGenderSelector:ho,AdvancedParams:Ro,ReplaceSectionInput:Jo,FontAwesomeIcon:M,ElButton:O,Consumption:Pe},emits:["generate"],computed:{config(){return this.$store.state.suno?.config},consumption(){return ze(this.config,this.service?.cost)},service(){return this.$store.state.suno?.service},supportsVocalGender(){const e=this.config?.model||"";return["chirp-v4-5-plus","chirp-v5"].includes(e)},generateButtonText(){const e=this.config?.action;return e==="extend"?this.$t("suno.button.extend"):e==="cover"?this.$t("suno.button.cover_music"):e==="remaster"?this.$t("suno.button.remaster"):e==="replace_section"?this.$t("suno.button.replace_section"):e==="mashup"?this.$t("suno.button.mashup"):e==="stems"?this.$t("suno.button.get_stems"):e==="concat"?this.$t("suno.button.concat_music"):this.$t("suno.button.generate")}},methods:{onGenerate(){this.$emit("generate")}}}),xo={class:"flex flex-col h-full"},es={class:"flex-1 overflow-y-auto p-5"},ts={class:"flex flex-col items-center justify-center px-5 pb-5"};function os(e,t,l,o,c,p){const d=a("type-selector"),_=a("upload-audio"),$=a("prompt-input"),r=a("lyric-input"),h=a("style-input"),b=a("title-input"),f=a("vocal-gender-selector"),k=a("extend-from-input"),U=a("cover-from-input"),E=a("replace-section-input"),j=a("advanced-params"),v=a("consumption"),V=a("font-awesome-icon"),z=a("el-button");return i(),g("div",xo,[n("div",es,[s(d,{class:"mb-4"}),s(_,{class:"mb-4"}),e.config?.custom?y("",!0):(i(),w($,{key:0,class:"mb-4"})),e.config?.custom&&!e.config.instrumental?(i(),w(r,{key:1,class:"mb-4"})):y("",!0),e.config?.custom?(i(),w(h,{key:2,class:"mb-4"})):y("",!0),e.config?.custom?(i(),w(b,{key:3,class:"mb-4"})):y("",!0),e.config?.custom&&!e.config.instrumental&&e.supportsVocalGender?(i(),w(f,{key:4,class:"mb-4"})):y("",!0),e.config?.action==="extend"?(i(),w(k,{key:5,class:"mb-4"})):y("",!0),e.config?.action==="cover"?(i(),w(U,{key:6,class:"mb-4"})):y("",!0),e.config?.action==="replace_section"?(i(),w(E,{key:7,class:"mb-4"})):y("",!0),s(j,{class:"mb-4"})]),n("div",ts,[s(v,{value:e.consumption,service:e.service},null,8,["value","service"]),s(z,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:m(()=>[s(V,{icon:"fa-solid fa-magic",class:"mr-2"}),L(" "+u(e.generateButtonText),1)]),_:1},8,["onClick"])])])}const ss=A(Qo,[["render",os],["__scopeId","data-v-a4cbdb91"]]);var X={exports:{}},ns=X.exports,se;function is(){return se||(se=1,function(e,t){(function(l,o){o()})(ns,function(){function l(r,h){return typeof h>"u"?h={autoBom:!1}:typeof h!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),h={autoBom:!h}),h.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(r.type)?new Blob(["\uFEFF",r],{type:r.type}):r}function o(r,h,b){var f=new XMLHttpRequest;f.open("GET",r),f.responseType="blob",f.onload=function(){$(f.response,h,b)},f.onerror=function(){console.error("could not download file")},f.send()}function c(r){var h=new XMLHttpRequest;h.open("HEAD",r,!1);try{h.send()}catch{}return 200<=h.status&&299>=h.status}function p(r){try{r.dispatchEvent(new MouseEvent("click"))}catch{var h=document.createEvent("MouseEvents");h.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),r.dispatchEvent(h)}}var d=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Z=="object"&&Z.global===Z?Z:void 0,_=d.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),$=d.saveAs||(typeof window!="object"||window!==d?function(){}:"download"in HTMLAnchorElement.prototype&&!_?function(r,h,b){var f=d.URL||d.webkitURL,k=document.createElement("a");h=h||r.name||"download",k.download=h,k.rel="noopener",typeof r=="string"?(k.href=r,k.origin===location.origin?p(k):c(k.href)?o(r,h,b):p(k,k.target="_blank")):(k.href=f.createObjectURL(r),setTimeout(function(){f.revokeObjectURL(k.href)},4e4),setTimeout(function(){p(k)},0))}:"msSaveOrOpenBlob"in navigator?function(r,h,b){if(h=h||r.name||"download",typeof r!="string")navigator.msSaveOrOpenBlob(l(r,b),h);else if(c(r))o(r,h,b);else{var f=document.createElement("a");f.href=r,f.target="_blank",setTimeout(function(){p(f)})}}:function(r,h,b,f){if(f=f||open("","_blank"),f&&(f.document.title=f.document.body.innerText="downloading..."),typeof r=="string")return o(r,h,b);var k=r.type==="application/octet-stream",U=/constructor/i.test(d.HTMLElement)||d.safari,E=/CriOS\/[\d]+/.test(navigator.userAgent);if((E||k&&U||_)&&typeof FileReader<"u"){var j=new FileReader;j.onloadend=function(){var z=j.result;z=E?z:z.replace(/^data:[^;]*;/,"data:attachment/file;"),f?f.location.href=z:location=z,f=null},j.readAsDataURL(r)}else{var v=d.URL||d.webkitURL,V=v.createObjectURL(r);f?f.location=V:location.href=V,f=null,setTimeout(function(){v.revokeObjectURL(V)},4e4)}});d.saveAs=$.saveAs=$,e.exports=$})}(X)),X.exports}var as=is();const ls="https://webhook.acedata.cloud/suno",rs=S({name:"TaskPreview",components:{ElImage:N,ElIcon:J,ElTooltip:ve,FontAwesomeIcon:M,VideoPlay:ee,VideoPause:x,ElDropdown:$e,ElDropdownMenu:ge,ElDropdownItem:_e,Loading:he},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1,isFetchingWav:!1,isFetchingMidi:!1}},computed:{loading(){return this.$store.state.suno?.status?.getApplications===R.Request},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},task(){return this.$store.state.suno?.tasks},audios(){const e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(l=>({...l,action:t})):e},application(){return this.$store.state.suno?.application},active(){return this.$store.state.suno?.tasks?.active}},methods:{useFormatDuring:W,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e.stopPropagation(),console.log("on extend"),console.debug("set config",t),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:t.model,custom:!0,instrumental:!1,style:t.style,action:"extend",audio:t,audio_id:t.id,continue_at:t.duration})},onDownload(e,t){e&&e.stopPropagation(),console.log("on download",t);const o=new URL(t).pathname,c=o.substring(o.lastIndexOf("/")+1);console.log("on preview",c),fetch(t).then(p=>p.blob()).then(p=>{as.saveAs(p,c)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;const t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(t){console.error("get videoUrl failed:",t),C.error(this.$t("suno.message.getVideoUrlFailed"))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,l)=>{const o={audio_id:e},c=this.credential?.token;if(!c){console.error("no token specified"),l(new Error("No token specified"));return}P.mp4(o,{token:c}).then(p=>{const d=p.data?.data?.video_url;d?t(d):l(new Error("Video URL not found in response"))}).catch(p=>{l(p)})})},onPreview(e,t){e.stopPropagation(),console.log("on preview",t),window.open(t,"_blank")},async onGetStems(e){await this.onGenerateAudioUrl("stems",e)},onCover(e){console.log("on cover"),console.debug("set config",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:"cover",audio:e,audio_id:e.id})},async onConcatMusic(e){await this.onGenerateAudioUrl("concat",e)},async onRemaster(e){await this.onGenerateAudioUrl("remaster",e)},async onGetAllStems(e){await this.onGenerateAudioUrl("all_stems",e)},onReplaceSection(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:"replace_section",audio:e,audio_id:e.id,replace_section_start:0,replace_section_end:Math.min(30,e.duration||30)})},onMashup(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,style:e.style,action:"mashup",audio:e,audio_id:e.id,mashup_audio_ids:[e.id]})},async handleWavDownload(e){if(!e?.id||this.isFetchingWav)return;const t=this.credential?.token;if(t)try{this.isFetchingWav=!0,C.info(this.$t("suno.message.fetchingWav"));const o=(await P.wav({audio_id:e.id},{token:t})).data?.data?.audio_url;o?this.onDownload(null,o):C.error(this.$t("suno.message.fetchWavFailed"))}catch{C.error(this.$t("suno.message.fetchWavFailed"))}finally{this.isFetchingWav=!1}},async handleMidiDownload(e){if(!e?.id||this.isFetchingMidi)return;const t=this.credential?.token;if(t)try{this.isFetchingMidi=!0,C.info(this.$t("suno.message.fetchingMidi"));const o=(await P.midi({audio_id:e.id},{token:t})).data?.data?.midi_url;o?this.onDownload(null,o):C.error(this.$t("suno.message.fetchMidiFailed"))}catch{C.error(this.$t("suno.message.fetchMidiFailed"))}finally{this.isFetchingMidi=!1}},async onGenerateAudioUrl(e,t){const l={action:e,audio_id:t,callback_url:ls},o=this.credential?.token;if(!o){console.error("no token specified");return}C.info(this.$t("suno.message.startingTask")),P.audio(l,{token:o}).then(()=>{C.success(this.$t("suno.message.startTaskSuccess"))}).catch(c=>{C.error(c?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".tasks");e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug("loading");return}await this.$store.dispatch("suno/getTasks",{limit:30,offset:0})}}}),cs={class:"task"},us=["onClick"],ds={class:"left"},ps=["onClick"],ms=["onClick"],fs={key:2,class:"duration"},hs={class:"info"},_s={class:"title"},gs={class:"style"},$s={class:"right"},vs={class:"el-dropdown-link"},ys={class:"flex items-center min-w-[120px]"},ks={class:"flex items-center min-w-[120px]"},ws={class:"flex items-center min-w-[120px]"},bs={class:"el-dropdown-link"};function Cs(e,t,l,o,c,p){const d=a("el-image"),_=a("video-pause"),$=a("el-icon"),r=a("video-play"),h=a("font-awesome-icon"),b=a("el-tooltip"),f=a("Loading"),k=a("el-dropdown-item"),U=a("el-dropdown-menu"),E=a("el-dropdown"),j=Q("loading");return i(),g("div",cs,[(i(!0),g(D,null,Y(e.audios,v=>(i(),g("div",{key:v.id,class:"audio",onClick:F(V=>e.onClick(v),["stop"])},[q((i(),g("div",ds,[s(d,{src:v?.image_url,class:"cover",fit:"cover",lazy:""},null,8,["src"]),v?.audio_url&&e.$store.state?.suno?.audio?.id===v.id&&e.$store.state?.suno?.audio?.state==="playing"?(i(),g("div",{key:0,class:"overlay",onClick:F(V=>e.onPause(v),["stop"])},[s($,null,{default:m(()=>[s(_)]),_:1})],8,ps)):y("",!0),v?.audio_url&&(e.$store.state?.suno?.audio?.id!==v.id||e.$store.state?.suno?.audio?.id===v.id&&e.$store.state?.suno?.audio?.state==="paused")?(i(),g("div",{key:1,class:"overlay",onClick:F(V=>e.onPlay(v),["stop"])},[s($,null,{default:m(()=>[s(r)]),_:1})],8,ms)):y("",!0),v?.duration?(i(),g("div",fs,u(e.useFormatDuring(v?.duration)),1)):y("",!0)])),[[j,!v?.audio_url]]),n("div",hs,[n("h2",_s,u(v?.title),1),n("p",gs,u(v?.style),1)]),n("div",$s,[s(E,null,{dropdown:m(()=>[s(U,null,{default:m(()=>[s(k,{disabled:e.isFetchingVideoUrl,onClick:V=>e.handleVideoDownload(v)},{default:m(()=>[n("div",ys,[e.isFetchingVideoUrl?(i(),w($,{key:0,class:"is-loading mr-2"},{default:m(()=>[s(f)]),_:1})):y("",!0),n("span",null,u(e.$t("suno.button.download_video")),1)])]),_:2},1032,["disabled","onClick"]),v?.audio_url?(i(),w(k,{key:0,onClick:F(V=>e.onDownload(V,v?.audio_url),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.download_audio")),1)]),_:2},1032,["onClick"])):y("",!0),s(k,{disabled:e.isFetchingWav,onClick:V=>e.handleWavDownload(v)},{default:m(()=>[n("div",ks,[e.isFetchingWav?(i(),w($,{key:0,class:"is-loading mr-2"},{default:m(()=>[s(f)]),_:1})):y("",!0),n("span",null,u(e.$t("suno.button.download_wav")),1)])]),_:2},1032,["disabled","onClick"]),s(k,{disabled:e.isFetchingMidi,onClick:V=>e.handleMidiDownload(v)},{default:m(()=>[n("div",ws,[e.isFetchingMidi?(i(),w($,{key:0,class:"is-loading mr-2"},{default:m(()=>[s(f)]),_:1})):y("",!0),n("span",null,u(e.$t("suno.button.download_midi")),1)])]),_:2},1032,["disabled","onClick"])]),_:2},1024)]),default:m(()=>[n("span",vs,[s(b,{effect:"dark",content:e.$t("suno.button.download"),placement:"top"},{default:m(()=>[v?.audio_url||v?.video_url?(i(),w(h,{key:0,icon:"fa-solid fa-download",class:"icon icon-download"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024),s(E,null,{dropdown:m(()=>[s(U,null,{default:m(()=>[v?.audio_url?(i(),w(k,{key:0,onClick:F(V=>e.onExtend(V,v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.extend")),1)]),_:2},1032,["onClick"])):y("",!0),v.id?(i(),w(k,{key:1,onClick:F(V=>e.onGetStems(v.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.get_stems")),1)]),_:2},1032,["onClick"])):y("",!0),v.id?(i(),w(k,{key:2,onClick:F(V=>e.onGetAllStems(v.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.all_stems")),1)]),_:2},1032,["onClick"])):y("",!0),s(k,{onClick:F(V=>e.onCover(v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.cover_music")),1)]),_:2},1032,["onClick"]),v?.id?(i(),w(k,{key:3,onClick:F(V=>e.onRemaster(v.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.remaster")),1)]),_:2},1032,["onClick"])):y("",!0),v?.id?(i(),w(k,{key:4,onClick:F(V=>e.onReplaceSection(v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.replace_section")),1)]),_:2},1032,["onClick"])):y("",!0),v?.id?(i(),w(k,{key:5,onClick:F(V=>e.onMashup(v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.mashup")),1)]),_:2},1032,["onClick"])):y("",!0),v?.id&&v?.action==="extend"?(i(),w(k,{key:6,onClick:F(V=>e.onConcatMusic(v?.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.concat_music")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:2},1024)]),default:m(()=>[n("span",bs,[s(b,{effect:"dark",content:e.$t("suno.button.more"),placement:"top"},{default:m(()=>[v?.audio_url||v?.video_url?(i(),w(h,{key:0,icon:"fa-solid fa-ellipsis",class:"icon icon-ellipsis"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024)])],8,us))),128))])}const Ss=A(rs,[["render",Cs]]),Vs={class:"player-slider"},Ls=S({__name:"PlayerSlider",setup(e){const t=H(),l=I({get:()=>t.state.suno?.audio?.progress,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:d})}),o=I({get:()=>t.state.suno?.audio?.duration,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:d})}),c=()=>{},p=d=>t.dispatch("suno/setAudio",{...t.state.suno.audio,progress:d});return(d,_)=>(i(),g("div",Vs,[s(T(te),{modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=$=>l.value=$),"show-tooltip":!1,min:0,max:o.value,onChange:p,onInput:c},null,8,["modelValue","max"])]))}}),As="/assets/disk-XFRmVAfp.png",js={class:"flex player-song"},Fs=["src"],Es={class:"ml-2 text-xs flex flex-col justify-between"},Ts={class:"w-52 2xl:w-96 cursor-pointer truncate"},Us={class:"flex"},Ps={class:"ml-2 text-dc"},Is=S({__name:"PlayerSong",setup(e){const t=H(),l=I({get:()=>t.state.suno.audio,set:o=>t.commit("suno/setAudio",o)});return Se(l,(o,c)=>{if(o?.audio_url!==c?.audio_url){console.log("audio changed",o),o.object&&(console.log("111",o.object),o.object.pause(),delete o.object);const p=new Audio(o.audio_url);o.state==="playing"?p.play():p.pause(),p.addEventListener("loadedmetadata",()=>{p.currentTime=0,p.addEventListener("timeupdate",()=>{t.commit("suno/setAudio",{...t.state.suno.audio,progress:p.currentTime})})}),t.commit("suno/setAudio",{...t.state.suno.audio,object:p})}else if(o?.progress!==c?.progress&&Math.abs(o.progress-o.object.currentTime)>2){console.log("progress changed",o.progress);const p=t.state.suno.audio;p.object&&(p.object.currentTime=p.progress)}else o?.state!==c?.state&&(console.log("state changed",o.state),o.object&&(o.state==="playing"?o.object.play():o.object.pause()));o?.volume!==c?.volume&&(console.log("volume changed",o.volume),o.object&&(o.object.volume=o.volume/100))}),(o,c)=>(i(),g("div",js,[n("img",{alt:"",class:"w-11 h-11 rounded",src:l.value?.image_url||T(As)},null,8,Fs),n("div",Es,[n("div",Ts,[n("div",Us,[n("span",null,u(l.value?.title||"Music"),1),n("span",Ps,"- "+u(l.value?.style||"SmallRuralDog"),1)])])])]))}}),zs={class:"flex justify-end items-center gap-x-2.5"},Gs={class:"text-xs"},Ms=S({__name:"PlayerAction",setup(e){const t=H(),l=I({get:()=>t.state.suno?.audio?.progress,set:c=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:c})}),o=I({get:()=>t.state.suno?.audio?.duration,set:c=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:c})});return(c,p)=>(i(),g("div",zs,[n("span",Gs,u(T(W)(l.value))+" / "+u(T(W)(o.value)),1)]))}});var Rs={size:"1em",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",rtl:!1,theme:"outline",colors:{outline:{fill:"#333",background:"transparent"},filled:{fill:"#333",background:"#FFF"},twoTone:{fill:"#333",twoTone:"#2F88FF"},multiColor:{outStrokeColor:"#333",outFillColor:"#2F88FF",innerStrokeColor:"#FFF",innerFillColor:"#43CCF8"}},prefix:"i"};function Ds(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function Ws(e,t,l){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],c=[],p=t.theme||l.theme;switch(p){case"outline":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push("none"),c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push("none");break;case"filled":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push("#FFF"),c.push("#FFF");break;case"two-tone":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[1]=="string"?o[1]:l.colors.twoTone.twoTone),c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[1]=="string"?o[1]:l.colors.twoTone.twoTone);break;case"multi-color":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[1]=="string"?o[1]:l.colors.multiColor.outFillColor),c.push(typeof o[2]=="string"?o[2]:l.colors.multiColor.innerStrokeColor),c.push(typeof o[3]=="string"?o[3]:l.colors.multiColor.innerFillColor);break}return{size:t.size||l.size,strokeWidth:t.strokeWidth||l.strokeWidth,strokeLinecap:t.strokeLinecap||l.strokeLinecap,strokeLinejoin:t.strokeLinejoin||l.strokeLinejoin,colors:c,id:e}}var Os=Symbol("icon-context");function oe(e,t,l){var o={name:"icon-"+e,props:["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","spin"],setup:function(p){var d=Ds(),_=Ve(Os,Rs);return function(){var $=p.size,r=p.strokeWidth,h=p.strokeLinecap,b=p.strokeLinejoin,f=p.theme,k=p.fill,U=p.spin,E=Ws(d,{size:$,strokeWidth:r,strokeLinecap:h,strokeLinejoin:b,theme:f,fill:k},_),j=[_.prefix+"-icon"];return j.push(_.prefix+"-icon-"+e),t&&_.rtl&&j.push(_.prefix+"-icon-rtl"),U&&j.push(_.prefix+"-icon-spin"),s("span",{class:j.join(" ")},[l(E)])}}};return o}const Bs=oe("pause-one",!1,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M19 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M29 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),Ns=oe("play",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M20 24V17.0718L26 20.5359L32 24L26 27.4641L20 30.9282V24Z",fill:e.colors[3],stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null)])}),qs=oe("volume-small",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 6V42C17 42 11.7985 32.8391 11.7985 32.8391H6C4.89543 32.8391 4 31.9437 4 30.8391V17.0108C4 15.9062 4.89543 15.0108 6 15.0108H11.7985C11.7985 15.0108 17 6 24 6Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M32 15L32 15C32.6232 15.5565 33.1881 16.1797 33.6841 16.8588C35.1387 18.8504 36 21.3223 36 24C36 26.6545 35.1535 29.1067 33.7218 31.0893C33.2168 31.7885 32.6391 32.4293 32 33",stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),ne=S({__name:"IconPark",props:{icon:{},theme:{},size:{},spin:{type:Boolean},fill:{},strokeLinecap:{},strokeLinejoin:{},strokeWidth:{}},setup(e){return(t,l)=>(i(),w(Le(t.icon),{theme:t.theme,size:t.size,spin:t.spin,fill:t.fill,"stroke-linecap":t.strokeLinecap,"stroke-linejoin":t.strokeLinejoin,"stroke-width":t.strokeWidth},null,8,["theme","size","spin","fill","stroke-linecap","stroke-linejoin","stroke-width"]))}}),Hs={class:"player-volume flex flex-col items-center pt-2"},Ks={class:"text-sm mt-3"},Zs=S({__name:"PlayerVolumeSlider",setup(e){const t=H(),l=I({get:()=>t.state.suno.audio?.volume,set:p=>t.commit("suno/setAudio",{...t.state.suno.audio,volume:p})}),o=I({get:()=>t.state.suno.audio?.muted,set:p=>t.commit("suno/setAudio",{...t.state.suno.audio,muted:p})}),c=p=>t.dispatch("suno/setVolume",p);return(p,d)=>(i(),g("div",Hs,[s(T(te),{modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=_=>l.value=_),vertical:"",height:"100px","show-tooltip":!1,max:100,min:0,size:"small",disabled:o.value,onInput:c},null,8,["modelValue","disabled"]),n("div",Ks,u(l.value),1)]))}}),Xs={class:"flex items-center justify-center gap-x-3"},Ys=S({__name:"PlayerController",setup(e){const t=H(),l=()=>t.dispatch("suno/setAudio",{...t.state.suno.audio,state:t.state.suno.audio.state==="playing"?"paused":"playing"}),o=I(()=>t.state.suno.audio);return(c,p)=>(i(),g("div",Xs,[s(ne,{icon:o.value?.state==="playing"?T(Bs):T(Ns),size:"45",theme:"filled",class:"text-[var(--el-color-primary)] cursor-pointer",onClick:l},null,8,["icon"]),s(T(ye),{placement:"top",width:"50px",trigger:"click"},{reference:m(()=>[s(ne,{icon:T(qs),size:"20","stroke-width":2,class:"cursor-pointer"},null,8,["icon"])]),default:m(()=>[s(Zs)]),_:1})]))}}),Js={class:"flex flex-col items-stretch h-20"},Qs={class:"flex grow px-5 items-center"},xs={class:"flex-1"},en={class:"flex-1"},tn={class:"flex-1"},on=S({__name:"Player",setup(e){return(t,l)=>(i(),g("div",Js,[s(Ls),n("div",Qs,[n("div",xs,[s(Is)]),n("div",en,[s(Ys)]),n("div",tn,[s(Ms)])])]))}}),sn=S({name:"RecentPanel",components:{ElSkeletonItem:we,ElSkeleton:ke,TaskPreview:Ss,Player:on,NoTasks:Ie,ScrollList:Ue},props:{loading:{type:Boolean,default:!1}},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.suno?.tasks,items:this.$store.state.suno?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),nn={key:0,class:"tasks"},an={class:"left w-[70px] p-[10px] flex items-center"},ln={class:"main w-[calc(100%-70px)] flex-1 p-[10px]"},rn={key:2,class:"w-full flex-1 flex items-center justify-center"},cn={class:"h-20"};function un(e,t,l,o,c,p){const d=a("el-skeleton-item"),_=a("el-skeleton"),$=a("task-preview"),r=a("scroll-list"),h=a("no-tasks"),b=a("player");return i(),g(D,null,[e.tasks?.items===void 0?(i(),g("div",nn,[(i(),g(D,null,Y(3,f=>n("div",{key:f,class:"flex"},[n("div",an,[s(_,{animated:""},{template:m(()=>[s(d,{variant:"image",class:"avatar w-[50px] h-[50px]"})]),_:1})]),n("div",ln,[s(_,{animated:""},{template:m(()=>[s(d,{variant:"p",class:"w-[200px] h-[15px] mb-[5px] mt-[10px]"}),s(d,{variant:"text"})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(i(),w(r,{key:1,ref:"scrollList",class:"flex-1 w-full overflow-y-auto tasks p-2",loading:e.loading,onReachTop:t[0]||(t[0]=f=>e.$emit("reach-top"))},{default:m(()=>[(i(!0),g(D,null,Y(e.tasks?.items,(f,k)=>(i(),w($,{key:k,"model-value":f,class:"preview"},null,8,["model-value"]))),128))]),_:1},8,["loading"])):y("",!0),e.tasks?.items?.length===0?(i(),g("div",rn,[s(h)])):y("",!0),q(n("div",cn,[s(b)],512),[[Ae,!!e.$store?.state?.suno?.audio?.object]])],64)}const dn=A(sn,[["render",un]]),pn=S({name:"TaskPreview",components:{IconPicture:Ce,ElImage:N,ElAvatar:be,ElIcon:J},computed:{audio(){return this.$store.state.suno?.audio}}}),mn={key:0,class:"size-full overflow-hidden"},fn={class:"relative h-[300px]"},hn={class:"flex items-center justify-center size-full bg-[var(--el-bg-color)]"},_n={class:"absolute bottom-0 left-0 right-0 m-0 p-4 text-white z-10 bg-gradient-to-t from-black/70 to-transparent"},gn={class:"p-4"},$n={class:"flex items-center font-bold mb-2"},vn={class:"text-[var(--el-text-color-regular)] mb-2"},yn={class:"text-xs text-[var(--el-text-color-regular)]"},kn={class:"mt-4 text-sm leading-[25px] whitespace-pre-wrap"},wn={key:1,class:"w-full h-full"};function bn(e,t,l,o,c,p){const d=a("icon-picture"),_=a("el-icon"),$=a("el-image"),r=a("el-avatar");return e.audio?.object?(i(),g("div",mn,[n("div",fn,[s($,{src:e.audio.image_url,fit:"cover",class:"size-full"},{error:m(()=>[n("div",hn,[s(_,{class:"text-3xl"},{default:m(()=>[s(d)]),_:1})])]),_:1},8,["src"]),n("h2",_n,u(e.audio?.title),1)]),n("div",gn,[n("div",$n,[s(r,{size:30,src:e.audio?.image_url,class:"mr-2"},null,8,["src"]),n("span",null,u(e.audio?.title),1)]),n("p",vn,u(e.audio?.style),1),n("p",yn,u(e.$dayjs.format(e.audio?.created_at)),1),n("div",kn,[n("p",null,u(e.audio?.lyric),1)])])])):(i(),g("div",wn))}const Cn=A(pn,[["render",bn]]),Sn="https://webhook.acedata.cloud/suno",Vn=S({name:"SunoIndex",components:{Layout:Ne,ConfigPanel:ss,RecentPanel:dn,PreviewPanel:Cn},inject:["initialized"],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.suno?.status?.getApplications===R.Request},tasksLoading(){return this.$store.state.suno?.status?.getTasks===R.Request||this.fetchingTasks},service(){return this.$store.state.suno.service},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},initializing(){return this.$store.state.suno.status.getApplications===R.Request},needApply(){return this.$store.state.suno.status.getApplications===R.Success&&!this.application},application(){return this.$store.state.suno.application},tasks(){return this.$store.state.suno.tasks},applications(){return this.$store.state.suno.applications}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await Ge({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("suno/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplications"),await this.$store.dispatch("suno/getApplications"),console.debug("end onGetApplications"),await this.onGetTasks()},onApply(){Ee.create({application:this.application}).then(({data:e})=>{this.application=e,C.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===Te&&C.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){await this.$nextTick();const e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=5,createdAtMin:l,createdAtMax:o}=e||{};console.debug("limit",t,"createdAtMin",l,"createdAtMax",o),this.fetchingTasks=!0;try{await this.$store.dispatch("suno/getTasks",{limit:t,createdAtMin:l,createdAtMax:o})}finally{this.fetchingTasks=!1}},async onGenerateAudio(){const e={...this.config,callback_url:Sn},t=this.credential?.token;if(!t){console.error("no token specified");return}C.info(this.$t("suno.message.startingTask")),P.audio(e,{token:t}).then(()=>{C.success(this.$t("suno.message.startTaskSuccess"))}).catch(l=>{C.error(l?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function Ln(e,t,l,o,c,p){const d=a("config-panel"),_=a("recent-panel"),$=a("preview-panel"),r=a("layout");return i(),w(r,null,{config:m(()=>[s(d,{onGenerate:e.onGenerateAudio},null,8,["onGenerate"])]),result:m(()=>[s(_,{ref:"recentPanel",class:"panel recent",loading:e.loadingMore,onReachTop:e.onReachTop},null,8,["loading","onReachTop"])]),preview:m(()=>[s($)]),_:1})}const Dn=A(Vn,[["render",Ln],["__scopeId","data-v-d1296b1a"]]);export{Dn as default};
|
|
1
|
+
import{F as M}from"./index.es-sibb1JwV.js";import{l as O,S as re,k as ce,N as ue,O as de,t as pe,u as C,s as B,a1 as x,a2 as ee,U as ie,e as J,j as N,D as ae,F as le,V as te,a3 as me,a4 as fe,Z as he,f as _e,g as ge,h as $e,p as ve,q as ye,K as ke,Y as we,a5 as be,a6 as Ce}from"./vendor-element-plus-B4FTqxj4.js";import{d as S,C as g,G as n,T as s,E as K,K as m,ai as a,D as i,O as y,R as u,S as D,ag as Y,J as w,Q as L,L as q,aq as Q,X as F,c as I,u as T,w as Se,b as Ve,P as Le,U as Ae}from"./vendor-vue-1w_NBnjl.js";import{_ as A,c4 as je,c5 as P,aj as Fe,ay as R,c6 as H,ar as Ee,ax as Te}from"./index-Cg8W5HXP.js";import{I as G,S as Ue}from"./ScrollList-Ctwoso0M.js";import{C as Pe,N as Ie}from"./NoTasks-CXFbDY0A.js";import{a as ze}from"./price-CUVRj46N.js";import{j as Z}from"./vendor-dayjs-CzbnksQQ.js";import{l as Ge}from"./pagination-CihAE3FS.js";import"./vendor-web3-vJ0jlMeb.js";import"./vendor-axios-NIGUFBhG.js";import"./vendor-vue-router-Dj5bcX0v.js";const Me=S({name:"LayoutSuno",components:{ElDrawer:re,ElButton:O,FontAwesomeIcon:M},data(){return{drawer:!1,preview:!1}},computed:{}}),Re={class:"main flex flex-row flex-1"},De={class:"config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]"},We={class:"result h-full flex flex-col flex-1 min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]"},Oe={class:"preview h-full w-[300px] flex flex-col"};function Be(e,t,l,o,c,p){const d=a("font-awesome-icon"),_=a("el-button"),$=a("el-drawer");return i(),g("div",Re,[n("div",De,[K(e.$slots,"config",{},void 0,!0)]),n("div",We,[K(e.$slots,"result",{},void 0,!0)]),n("div",Oe,[K(e.$slots,"preview",{},void 0,!0)]),s(_,{circle:"",class:"menu",onClick:t[0]||(t[0]=r=>e.drawer=!0)},{default:m(()=>[s(d,{icon:"fa-solid fa-magic"})]),_:1}),s($,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=r=>e.drawer=r),direction:"ltr","with-header":!1,size:"340px",class:"drawer"},{default:m(()=>[K(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const Ne=A(Me,[["render",Be],["__scopeId","data-v-c6c85757"]]),qe=S({name:"TypeSelector",components:{ElSelect:de,ElOption:ue,ElSwitch:ce},data(){return{options:[{label:"Suno v5",value:"chirp-v5",info:"8 min"},{label:"Suno v4.5+",value:"chirp-v4-5-plus",info:"8 min"},{label:"Suno v4.5",value:"chirp-v4-5",info:"4 min"},{label:"Suno v4",value:"chirp-v4",info:"2.5 min"},{label:"Suno v3.5",value:"chirp-v3-5",info:"2 min"},{label:"Suno v3",value:"chirp-v3-0",info:"2 min"}]}},computed:{custom:{get(){return this.$store.state.suno?.config?.custom||!1},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,custom:e})}},instrumental:{get(){return this.$store.state.suno?.config?.instrumental||!1},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,instrumental:e})}},model:{get(){return this.$store.state.suno?.config?.model},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e})}}},mounted(){this.model||(this.model=je)}}),He={class:"flex items-center justify-between mb-3"},Ke={class:"text-sm font-bold"},Ze={class:"mb-3"},Xe={class:"flex items-center mb-1"},Ye={class:"text-sm font-bold"},Je={class:"flex items-center justify-between w-full"},Qe={class:"text-xs text-[var(--el-text-color-placeholder)]"},xe={key:0,class:"flex items-center justify-between mb-3"},et={class:"text-sm font-bold"};function tt(e,t,l,o,c,p){const d=a("el-switch"),_=a("el-option"),$=a("el-select");return i(),g("div",null,[n("div",He,[n("span",Ke,u(e.$t("suno.name.type")),1),s(d,{modelValue:e.custom,"onUpdate:modelValue":t[0]||(t[0]=r=>e.custom=r),size:"small"},null,8,["modelValue"])]),n("div",Ze,[n("div",Xe,[n("span",Ye,u(e.$t("suno.name.model")),1)]),s($,{modelValue:e.model,"onUpdate:modelValue":t[1]||(t[1]=r=>e.model=r),class:"w-full",size:"default",placeholder:e.$t("suno.placeholder.select")},{default:m(()=>[(i(!0),g(D,null,Y(e.options,r=>(i(),w(_,{key:r.value,label:r.label,value:r.value},{default:m(()=>[n("div",Je,[n("span",null,u(r.label),1),n("span",Qe,u(r.info),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),e.custom?(i(),g("div",xe,[n("span",et,u(e.$t("suno.name.instrumental")),1),s(d,{modelValue:e.instrumental,"onUpdate:modelValue":t[2]||(t[2]=r=>e.instrumental=r),size:"small"},null,8,["modelValue"])])):y("",!0)])}const ot=A(qe,[["render",tt]]),st=S({name:"UploadAudio",components:{ElUpload:pe,ElButton:O,InfoIcon:G,FontAwesomeIcon:M},emits:["change"],data(){return{fileList:[],uploadUrl:Fe()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.suno?.config?.audio_id},set(){}}},watch:{urls:{handler(e){this.$emit("change",e)}}},mounted(){this.value||(this.value=void 0),this.onSetAudio()},methods:{onExceed(){C.warning(this.$t("suno.message.uploadReferencesExceed"))},onError(){C.error(this.$t("suno.message.uploadReferencesError"))},async onSuccess(){const e=this.urls?.[0];await this.onGenerateAudioId(e)},async onGenerateAudioId(e){const t={audio_url:e},l=this.credential?.token;if(!l){console.error("no token specified");return}C.info(this.$t("suno.message.startingUploadAudio")),P.upload(t,{token:l}).then(o=>{console.debug("get upload music success",o.data);const c=o.data?.data.audio_id;this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,audio_id:c,action:"upload_extend"}),C.success(this.$t("suno.message.startUploadAudioSuccess"))}).catch(o=>{C.error(o?.response?.data?.error?.message||this.$t("suno.message.startUploadAudioFailed"))})},onSetAudio(){}}}),nt={class:"relative"},it={class:"flex justify-between"},at={class:"flex justify-start items-center"},lt={class:"text-sm font-bold"};function rt(e,t,l,o,c,p){const d=a("info-icon"),_=a("font-awesome-icon"),$=a("el-button"),r=a("el-upload");return i(),g("div",nt,[n("div",it,[n("div",at,[n("span",lt,u(e.$t("suno.name.referenceAudios")),1),s(d,{content:e.$t("suno.description.uploadAudios")},null,8,["content"])])]),s(r,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=h=>e.fileList=h),name:"file",limit:1,class:"upload-wrapper",action:e.uploadUrl,accept:".mp3","show-file-list":!0,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:m(()=>[s($,{round:"",type:"primary",size:"small",class:"btn btn-upload"},{default:m(()=>[s(_,{icon:"fa-solid fa-upload",class:"icon mr-1"}),L(" "+u(e.$t("suno.button.uploadAudios")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","headers"])])}const ct=A(st,[["render",rt],["__scopeId","data-v-6236152c"]]),ut="",dt=S({name:"PromptInput",components:{ElInput:B,InfoIcon:G},computed:{prompt:{get(){return this.$store.state.suno?.config?.prompt},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=ut)}}),pt={class:"field"},mt={class:"flex items-center mb-1"},ft={class:"text-sm font-bold"};function ht(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-input");return i(),g("div",pt,[n("div",mt,[n("span",ft,u(e.$t("suno.name.songDescription")),1),s(d,{content:e.$t("suno.description.prompt")},null,8,["content"])]),s(_,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||(t[0]=$=>e.prompt=$),rows:4,type:"textarea",placeholder:e.$t("suno.placeholder.prompt")},null,8,["modelValue","placeholder"])])}const _t=A(dt,[["render",ht]]),gt="",$t=S({name:"LyricInput",components:{ElInput:B,ElButton:O,FontAwesomeIcon:M,InfoIcon:G},data(){return{generatingLyrics:!1}},computed:{lyric:{get(){return this.$store.state.suno?.config?.lyric},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric:e})}},config(){return this.$store.state.suno?.config},credential(){return this.$store.state.suno?.credential}},mounted(){this.lyric||(this.lyric=gt)},methods:{async onGenerateLyrics(){const e=this.credential?.token;if(!e)return;const t=this.config?.style||this.config?.title||"a beautiful song";this.generatingLyrics=!0,C.info(this.$t("suno.message.generatingLyrics"));try{const o=(await P.lyric({prompt:t},{token:e})).data?.data;o?.text&&(this.lyric=o.text,o?.title&&!this.config?.title&&this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric:o.text,title:o.title}),C.success(this.$t("suno.message.generateLyricsSuccess")))}catch{C.error(this.$t("suno.message.generateLyricsFailed"))}finally{this.generatingLyrics=!1}}}}),vt={class:"field"},yt={class:"flex items-center justify-between mb-1"},kt={class:"flex items-center"},wt={class:"text-sm font-bold"};function bt(e,t,l,o,c,p){const d=a("info-icon"),_=a("font-awesome-icon"),$=a("el-button"),r=a("el-input");return i(),g("div",vt,[n("div",yt,[n("div",kt,[n("span",wt,u(e.$t("suno.name.lyrics")),1),s(d,{content:e.$t("suno.description.lyrics")},null,8,["content"])]),e.config?.action!=="extend"?(i(),w($,{key:0,size:"small",loading:e.generatingLyrics,round:"",onClick:e.onGenerateLyrics},{default:m(()=>[e.generatingLyrics?y("",!0):(i(),w(_,{key:0,icon:"fa-solid fa-wand-magic-sparkles",class:"mr-1"})),L(" "+u(e.$t("suno.button.generate_lyrics")),1)]),_:1},8,["loading","onClick"])):y("",!0)]),e.config?.action!=="extend"?(i(),w(r,{key:0,modelValue:e.lyric,"onUpdate:modelValue":t[0]||(t[0]=h=>e.lyric=h),rows:5,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.lyrics")},null,8,["modelValue","placeholder"])):(i(),w(r,{key:1,modelValue:e.lyric,"onUpdate:modelValue":t[1]||(t[1]=h=>e.lyric=h),rows:5,type:"textarea",class:"lyrics",placeholder:e.$t("suno.placeholder.extend.lyrics")},null,8,["modelValue","placeholder"]))])}const Ct=A($t,[["render",bt],["__scopeId","data-v-210d2670"]]),St=S({name:"StyleInput",components:{ElInput:B,ElButton:O,FontAwesomeIcon:M,InfoIcon:G},data(){return{optimizing:!1}},computed:{style:{get(){return this.$store.state.suno?.config?.style},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style:e})}},credential(){return this.$store.state.suno?.credential}},methods:{async onOptimizeStyle(){const e=this.credential?.token;if(!(!e||!this.style)){this.optimizing=!0,C.info(this.$t("suno.message.optimizingStyle"));try{const t=await P.style({prompt:this.style},{token:e}),l=t.data?.text||t.data?.data?.text;l&&(this.style=l,C.success(this.$t("suno.message.optimizeStyleSuccess")))}catch{C.error(this.$t("suno.message.optimizeStyleFailed"))}finally{this.optimizing=!1}}}}}),Vt={class:"field"},Lt={class:"flex items-center justify-between mb-1"},At={class:"flex items-center"},jt={class:"text-sm font-bold"};function Ft(e,t,l,o,c,p){const d=a("info-icon"),_=a("font-awesome-icon"),$=a("el-button"),r=a("el-input");return i(),g("div",Vt,[n("div",Lt,[n("div",At,[n("span",jt,u(e.$t("suno.name.style")),1),s(d,{content:e.$t("suno.description.style")},null,8,["content"])]),s($,{size:"small",loading:e.optimizing,round:"",onClick:e.onOptimizeStyle},{default:m(()=>[e.optimizing?y("",!0):(i(),w(_,{key:0,icon:"fa-solid fa-wand-magic-sparkles",class:"mr-1"})),L(" "+u(e.$t("suno.button.optimize_style")),1)]),_:1},8,["loading","onClick"])]),s(r,{modelValue:e.style,"onUpdate:modelValue":t[0]||(t[0]=h=>e.style=h),rows:2,type:"textarea",placeholder:e.$t("suno.placeholder.style")},null,8,["modelValue","placeholder"])])}const Et=A(St,[["render",Ft]]),Tt=S({name:"TitleInput",components:{ElInput:B,InfoIcon:G},computed:{title:{get(){return this.$store.state.suno?.config?.title},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,title:e})}}}}),Ut={class:"field"},Pt={class:"flex items-center mb-1"},It={class:"text-sm font-bold"};function zt(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-input");return i(),g("div",Ut,[n("div",Pt,[n("span",It,u(e.$t("suno.name.title")),1),s(d,{content:e.$t("suno.description.title")},null,8,["content"])]),s(_,{modelValue:e.title,"onUpdate:modelValue":t[0]||(t[0]=$=>e.title=$),placeholder:e.$t("suno.placeholder.title")},null,8,["modelValue","placeholder"])])}const Gt=A(Tt,[["render",zt]]);function W(e){const t=Math.floor(e)%60;e=Math.floor(e/60);const l=e%60,o=l<10?`0${l}`:l,c=t<10?`0${t}`:t;return o+":"+c}const Mt=S({name:"ExtendFromInput",components:{ElImage:N,ElIcon:J,ElInputNumber:ie,VideoPlay:ee,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){if(e===void 0){this.value=void 0;return}e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:W,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),Rt={class:"field"},Dt={class:"box"},Wt={class:"title font-bold"},Ot={class:"input-wrapper"},Bt={class:"task"},Nt={class:"left"},qt={key:2,class:"duration"},Ht={class:"info"},Kt={class:"title"},Zt={class:"style"};function Xt(e,t,l,o,c,p){const d=a("el-input-number"),_=a("el-image"),$=a("video-pause"),r=a("el-icon"),h=a("video-play"),b=Q("loading");return i(),g("div",Rt,[n("div",Dt,[n("h2",Wt,u(e.$t("suno.name.extend")),1),n("div",Ot,[s(d,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=f=>e.value=f),class:"value",min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.extend.continue_at"),onChange:e.handleChange},null,8,["modelValue","max","placeholder","onChange"])])]),n("div",Bt,[e.audio?(i(),g("div",{key:0,class:"audio",onClick:t[3]||(t[3]=f=>e.onClick(e.audio))},[q((i(),g("div",Nt,[s(_,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(i(),g("div",{key:0,class:"overlay",onClick:t[1]||(t[1]=f=>e.onPause(e.audio))},[s(r,null,{default:m(()=>[s($)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(i(),g("div",{key:1,class:"overlay",onClick:t[2]||(t[2]=f=>e.onPlay(e.audio))},[s(r,null,{default:m(()=>[s(h)]),_:1})])):y("",!0),e.audio?.duration?(i(),g("div",qt,u(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[b,!e.audio?.audio_url]]),n("div",Ht,[n("h2",Kt,u(e.audio?.title),1),n("p",Zt,u(e.audio?.style),1)])])):y("",!0)])])}const Yt=A(Mt,[["render",Xt],["__scopeId","data-v-bcce4821"]]),Jt=S({name:"CoverFromInput",components:{ElImage:N,ElIcon:J,VideoPlay:ee,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.suno?.config?.audio},value:{get(){return this.$store.state.suno?.config?.continue_at},set(e){console.debug("set continue_at",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){this.value||(this.value=void 0)},methods:{handleChange(e){e<0?this.value=0:e>this.audio?.duration?this.value=this.audio?.duration:this.value=e},useFormatDuring:W,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),Qt={class:"field"},xt={class:"box"},eo={class:"title font-bold"},to={class:"task"},oo={class:"left"},so={key:2,class:"duration"},no={class:"info"},io={class:"title"},ao={class:"style"};function lo(e,t,l,o,c,p){const d=a("el-image"),_=a("video-pause"),$=a("el-icon"),r=a("video-play"),h=Q("loading");return i(),g("div",Qt,[n("div",xt,[n("h2",eo,u(e.$t("suno.name.cover")),1)]),n("div",to,[e.audio?(i(),g("div",{key:0,class:"audio",onClick:t[2]||(t[2]=b=>e.onClick(e.audio))},[q((i(),g("div",oo,[s(d,{src:e.audio?.image_url,class:"cover",fit:"cover"},null,8,["src"]),e.audio?.audio_url&&e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="playing"?(i(),g("div",{key:0,class:"overlay",onClick:t[0]||(t[0]=b=>e.onPause(e.audio))},[s($,null,{default:m(()=>[s(_)]),_:1})])):y("",!0),e.audio?.audio_url&&(e.$store.state?.suno?.audio?.id!==e.audio.id||e.$store.state?.suno?.audio?.id===e.audio.id&&e.$store.state?.suno?.audio?.state==="paused")?(i(),g("div",{key:1,class:"overlay",onClick:t[1]||(t[1]=b=>e.onPlay(e.audio))},[s($,null,{default:m(()=>[s(r)]),_:1})])):y("",!0),e.audio?.duration?(i(),g("div",so,u(e.useFormatDuring(e.audio?.duration)),1)):y("",!0)])),[[h,!e.audio?.audio_url]]),n("div",no,[n("h2",io,u(e.audio?.title),1),n("p",ao,u(e.audio?.style),1)])])):y("",!0)])])}const ro=A(Jt,[["render",lo],["__scopeId","data-v-06640216"]]),co=S({name:"VocalGenderSelector",components:{ElRadioGroup:le,ElRadioButton:ae,InfoIcon:G},computed:{vocalGender:{get(){return this.$store.state.suno?.config?.vocal_gender||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,vocal_gender:e||void 0})}}}}),uo={class:"mb-2"},po={class:"flex items-center mb-1"},mo={class:"text-sm font-bold"};function fo(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-radio-button"),$=a("el-radio-group");return i(),g("div",uo,[n("div",po,[n("span",mo,u(e.$t("suno.name.vocalGender")),1),s(d,{content:e.$t("suno.description.vocalGender")},null,8,["content"])]),s($,{modelValue:e.vocalGender,"onUpdate:modelValue":t[0]||(t[0]=r=>e.vocalGender=r),size:"small"},{default:m(()=>[s(_,{value:""},{default:m(()=>[L(u(e.$t("suno.gender.auto")),1)]),_:1}),s(_,{value:"f"},{default:m(()=>[L(u(e.$t("suno.gender.female")),1)]),_:1}),s(_,{value:"m"},{default:m(()=>[L(u(e.$t("suno.gender.male")),1)]),_:1})]),_:1},8,["modelValue"])])}const ho=A(co,[["render",fo]]),_o=S({name:"AdvancedParams",components:{ElCollapse:fe,ElCollapseItem:me,ElInput:B,ElSlider:te,ElRadioGroup:le,ElRadioButton:ae},data(){return{activeNames:[]}},computed:{config(){return this.$store.state.suno?.config},isV5OrAbove(){return(this.config?.model||"")==="chirp-v5"},styleNegative:{get(){return this.$store.state.suno?.config?.style_negative||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style_negative:e||void 0})}},lyricPrompt:{get(){return this.$store.state.suno?.config?.lyric_prompt||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,lyric_prompt:e||void 0})}},weirdness:{get(){return this.$store.state.suno?.config?.weirdness??0},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,weirdness:e||void 0})}},styleInfluence:{get(){return this.$store.state.suno?.config?.style_influence??50},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,style_influence:e})}},variationCategory:{get(){return this.$store.state.suno?.config?.variation_category||""},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,variation_category:e||void 0})}},audioWeight:{get(){return this.$store.state.suno?.config?.audio_weight??50},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,audio_weight:e})}}}}),go={key:0,class:"mb-3"},$o={class:"flex items-center mb-1"},vo={class:"text-xs font-bold"},yo={key:1,class:"mb-3"},ko={class:"flex items-center mb-1"},wo={class:"text-xs font-bold"},bo={key:2,class:"mb-3"},Co={class:"flex items-center justify-between mb-1"},So={class:"text-xs font-bold"},Vo={class:"text-xs text-[var(--el-text-color-secondary)]"},Lo={key:3,class:"mb-3"},Ao={class:"flex items-center justify-between mb-1"},jo={class:"text-xs font-bold"},Fo={class:"text-xs text-[var(--el-text-color-secondary)]"},Eo={key:4,class:"mb-3"},To={class:"flex items-center mb-1"},Uo={class:"text-xs font-bold"},Po={key:5,class:"mb-3"},Io={class:"flex items-center justify-between mb-1"},zo={class:"text-xs font-bold"},Go={class:"text-xs text-[var(--el-text-color-secondary)]"};function Mo(e,t,l,o,c,p){const d=a("el-input"),_=a("el-slider"),$=a("el-radio-button"),r=a("el-radio-group"),h=a("el-collapse-item"),b=a("el-collapse");return i(),w(b,{modelValue:e.activeNames,"onUpdate:modelValue":t[6]||(t[6]=f=>e.activeNames=f),class:"advanced-collapse"},{default:m(()=>[s(h,{title:e.$t("suno.name.advancedParams"),name:"advanced"},{default:m(()=>[e.config?.custom?(i(),g("div",go,[n("div",$o,[n("span",vo,u(e.$t("suno.name.styleNegative")),1)]),s(d,{modelValue:e.styleNegative,"onUpdate:modelValue":t[0]||(t[0]=f=>e.styleNegative=f),size:"small",placeholder:e.$t("suno.placeholder.styleNegative")},null,8,["modelValue","placeholder"])])):y("",!0),e.config?.custom&&!e.config?.instrumental?(i(),g("div",yo,[n("div",ko,[n("span",wo,u(e.$t("suno.name.lyricPrompt")),1)]),s(d,{modelValue:e.lyricPrompt,"onUpdate:modelValue":t[1]||(t[1]=f=>e.lyricPrompt=f),size:"small",placeholder:e.$t("suno.placeholder.lyricPrompt")},null,8,["modelValue","placeholder"])])):y("",!0),e.config?.custom?(i(),g("div",bo,[n("div",Co,[n("span",So,u(e.$t("suno.name.weirdness")),1),n("span",Vo,u(e.weirdness??0),1)]),s(_,{modelValue:e.weirdness,"onUpdate:modelValue":t[2]||(t[2]=f=>e.weirdness=f),min:0,max:100,step:1,size:"small"},null,8,["modelValue"])])):y("",!0),e.config?.custom?(i(),g("div",Lo,[n("div",Ao,[n("span",jo,u(e.$t("suno.name.styleInfluence")),1),n("span",Fo,u(e.styleInfluence??50),1)]),s(_,{modelValue:e.styleInfluence,"onUpdate:modelValue":t[3]||(t[3]=f=>e.styleInfluence=f),min:0,max:100,step:1,size:"small"},null,8,["modelValue"])])):y("",!0),e.isV5OrAbove?(i(),g("div",Eo,[n("div",To,[n("span",Uo,u(e.$t("suno.name.variationCategory")),1)]),s(r,{modelValue:e.variationCategory,"onUpdate:modelValue":t[4]||(t[4]=f=>e.variationCategory=f),size:"small"},{default:m(()=>[s($,{value:""},{default:m(()=>[L(u(e.$t("suno.gender.auto")),1)]),_:1}),s($,{value:"high"},{default:m(()=>[L(u(e.$t("suno.variation.high")),1)]),_:1}),s($,{value:"low"},{default:m(()=>[L(u(e.$t("suno.variation.low")),1)]),_:1})]),_:1},8,["modelValue"])])):y("",!0),e.config?.action==="cover"?(i(),g("div",Po,[n("div",Io,[n("span",zo,u(e.$t("suno.name.audioWeight")),1),n("span",Go,u(e.audioWeight??50),1)]),s(_,{modelValue:e.audioWeight,"onUpdate:modelValue":t[5]||(t[5]=f=>e.audioWeight=f),min:0,max:100,step:1,size:"small"},null,8,["modelValue"])])):y("",!0)]),_:1},8,["title"])]),_:1},8,["modelValue"])}const Ro=A(_o,[["render",Mo],["__scopeId","data-v-be135363"]]),Do=S({name:"ReplaceSectionInput",components:{ElInputNumber:ie,ElImage:N,InfoIcon:G},computed:{audio(){return this.$store.state.suno?.config?.audio},replaceSectionStart:{get(){return this.$store.state.suno?.config?.replace_section_start},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,replace_section_start:e})}},replaceSectionEnd:{get(){return this.$store.state.suno?.config?.replace_section_end},set(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,replace_section_end:e})}}},methods:{onClick(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"})}}}),Wo={class:"field"},Oo={class:"flex items-center mb-2"},Bo={class:"text-sm font-bold m-0"},No={key:0,class:"task mb-2"},qo={class:"left relative w-[50px] h-[50px] mr-3 flex-shrink-0"},Ho={class:"info flex-1 min-w-0"},Ko={class:"text-sm font-bold m-0 truncate"},Zo={class:"text-xs text-[var(--el-text-color-secondary)] m-0 truncate"},Xo={class:"flex gap-2"};function Yo(e,t,l,o,c,p){const d=a("info-icon"),_=a("el-image"),$=a("el-input-number"),r=Q("loading");return i(),g("div",Wo,[n("div",Oo,[n("h2",Bo,u(e.$t("suno.name.replaceSection")),1),s(d,{content:e.$t("suno.description.replaceSection")},null,8,["content"])]),e.audio?(i(),g("div",No,[n("div",{class:"audio flex items-center",onClick:t[0]||(t[0]=h=>e.onClick(e.audio))},[q((i(),g("div",qo,[s(_,{src:e.audio?.image_url,class:"w-full h-full rounded",fit:"cover"},null,8,["src"])])),[[r,!e.audio?.audio_url]]),n("div",Ho,[n("h2",Ko,u(e.audio?.title),1),n("p",Zo,u(e.audio?.style),1)])])])):y("",!0),n("div",Xo,[s($,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":t[1]||(t[1]=h=>e.replaceSectionStart=h),class:"flex-1",size:"small",min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.replaceSectionStart")},null,8,["modelValue","max","placeholder"]),s($,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":t[2]||(t[2]=h=>e.replaceSectionEnd=h),class:"flex-1",size:"small",min:e.replaceSectionStart||0,max:e.audio?.duration,controls:!1,placeholder:e.$t("suno.placeholder.replaceSectionEnd")},null,8,["modelValue","min","max","placeholder"])])])}const Jo=A(Do,[["render",Yo]]),Qo=S({name:"PresetPanel",components:{TypeSelector:ot,PromptInput:_t,LyricInput:Ct,StyleInput:Et,TitleInput:Gt,ExtendFromInput:Yt,CoverFromInput:ro,UploadAudio:ct,VocalGenderSelector:ho,AdvancedParams:Ro,ReplaceSectionInput:Jo,FontAwesomeIcon:M,ElButton:O,Consumption:Pe},emits:["generate"],computed:{config(){return this.$store.state.suno?.config},consumption(){return ze(this.config,this.service?.cost)},service(){return this.$store.state.suno?.service},supportsVocalGender(){const e=this.config?.model||"";return["chirp-v4-5-plus","chirp-v5"].includes(e)},generateButtonText(){const e=this.config?.action;return e==="extend"?this.$t("suno.button.extend"):e==="cover"?this.$t("suno.button.cover_music"):e==="remaster"?this.$t("suno.button.remaster"):e==="replace_section"?this.$t("suno.button.replace_section"):e==="mashup"?this.$t("suno.button.mashup"):e==="stems"?this.$t("suno.button.get_stems"):e==="concat"?this.$t("suno.button.concat_music"):this.$t("suno.button.generate")}},methods:{onGenerate(){this.$emit("generate")}}}),xo={class:"flex flex-col h-full"},es={class:"flex-1 overflow-y-auto p-5"},ts={class:"flex flex-col items-center justify-center px-5 pb-5"};function os(e,t,l,o,c,p){const d=a("type-selector"),_=a("upload-audio"),$=a("prompt-input"),r=a("lyric-input"),h=a("style-input"),b=a("title-input"),f=a("vocal-gender-selector"),k=a("extend-from-input"),U=a("cover-from-input"),E=a("replace-section-input"),j=a("advanced-params"),v=a("consumption"),V=a("font-awesome-icon"),z=a("el-button");return i(),g("div",xo,[n("div",es,[s(d,{class:"mb-4"}),s(_,{class:"mb-4"}),e.config?.custom?y("",!0):(i(),w($,{key:0,class:"mb-4"})),e.config?.custom&&!e.config.instrumental?(i(),w(r,{key:1,class:"mb-4"})):y("",!0),e.config?.custom?(i(),w(h,{key:2,class:"mb-4"})):y("",!0),e.config?.custom?(i(),w(b,{key:3,class:"mb-4"})):y("",!0),e.config?.custom&&!e.config.instrumental&&e.supportsVocalGender?(i(),w(f,{key:4,class:"mb-4"})):y("",!0),e.config?.action==="extend"?(i(),w(k,{key:5,class:"mb-4"})):y("",!0),e.config?.action==="cover"?(i(),w(U,{key:6,class:"mb-4"})):y("",!0),e.config?.action==="replace_section"?(i(),w(E,{key:7,class:"mb-4"})):y("",!0),s(j,{class:"mb-4"})]),n("div",ts,[s(v,{value:e.consumption,service:e.service},null,8,["value","service"]),s(z,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:m(()=>[s(V,{icon:"fa-solid fa-magic",class:"mr-2"}),L(" "+u(e.generateButtonText),1)]),_:1},8,["onClick"])])])}const ss=A(Qo,[["render",os],["__scopeId","data-v-a4cbdb91"]]);var X={exports:{}},ns=X.exports,se;function is(){return se||(se=1,function(e,t){(function(l,o){o()})(ns,function(){function l(r,h){return typeof h>"u"?h={autoBom:!1}:typeof h!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),h={autoBom:!h}),h.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(r.type)?new Blob(["\uFEFF",r],{type:r.type}):r}function o(r,h,b){var f=new XMLHttpRequest;f.open("GET",r),f.responseType="blob",f.onload=function(){$(f.response,h,b)},f.onerror=function(){console.error("could not download file")},f.send()}function c(r){var h=new XMLHttpRequest;h.open("HEAD",r,!1);try{h.send()}catch{}return 200<=h.status&&299>=h.status}function p(r){try{r.dispatchEvent(new MouseEvent("click"))}catch{var h=document.createEvent("MouseEvents");h.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),r.dispatchEvent(h)}}var d=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Z=="object"&&Z.global===Z?Z:void 0,_=d.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),$=d.saveAs||(typeof window!="object"||window!==d?function(){}:"download"in HTMLAnchorElement.prototype&&!_?function(r,h,b){var f=d.URL||d.webkitURL,k=document.createElement("a");h=h||r.name||"download",k.download=h,k.rel="noopener",typeof r=="string"?(k.href=r,k.origin===location.origin?p(k):c(k.href)?o(r,h,b):p(k,k.target="_blank")):(k.href=f.createObjectURL(r),setTimeout(function(){f.revokeObjectURL(k.href)},4e4),setTimeout(function(){p(k)},0))}:"msSaveOrOpenBlob"in navigator?function(r,h,b){if(h=h||r.name||"download",typeof r!="string")navigator.msSaveOrOpenBlob(l(r,b),h);else if(c(r))o(r,h,b);else{var f=document.createElement("a");f.href=r,f.target="_blank",setTimeout(function(){p(f)})}}:function(r,h,b,f){if(f=f||open("","_blank"),f&&(f.document.title=f.document.body.innerText="downloading..."),typeof r=="string")return o(r,h,b);var k=r.type==="application/octet-stream",U=/constructor/i.test(d.HTMLElement)||d.safari,E=/CriOS\/[\d]+/.test(navigator.userAgent);if((E||k&&U||_)&&typeof FileReader<"u"){var j=new FileReader;j.onloadend=function(){var z=j.result;z=E?z:z.replace(/^data:[^;]*;/,"data:attachment/file;"),f?f.location.href=z:location=z,f=null},j.readAsDataURL(r)}else{var v=d.URL||d.webkitURL,V=v.createObjectURL(r);f?f.location=V:location.href=V,f=null,setTimeout(function(){v.revokeObjectURL(V)},4e4)}});d.saveAs=$.saveAs=$,e.exports=$})}(X)),X.exports}var as=is();const ls="https://webhook.acedata.cloud/suno",rs=S({name:"TaskPreview",components:{ElImage:N,ElIcon:J,ElTooltip:ve,FontAwesomeIcon:M,VideoPlay:ee,VideoPause:x,ElDropdown:$e,ElDropdownMenu:ge,ElDropdownItem:_e,Loading:he},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1,isFetchingWav:!1,isFetchingMidi:!1}},computed:{loading(){return this.$store.state.suno?.status?.getApplications===R.Request},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},task(){return this.$store.state.suno?.tasks},audios(){const e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(l=>({...l,action:t})):e},application(){return this.$store.state.suno?.application},active(){return this.$store.state.suno?.tasks?.active}},methods:{useFormatDuring:W,onPlay(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"playing"}),console.log("on play")},onPause(e){this.$store.dispatch("suno/setAudio",{...this.$store.state.suno.audio,...e,state:"paused"}),console.log("on pause")},onClick(e){this.$store.state?.suno?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e.stopPropagation(),console.log("on extend"),console.debug("set config",t),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:t.model,custom:!0,instrumental:!1,style:t.style,action:"extend",audio:t,audio_id:t.id,continue_at:t.duration})},onDownload(e,t){e&&e.stopPropagation(),console.log("on download",t);const o=new URL(t).pathname,c=o.substring(o.lastIndexOf("/")+1);console.log("on preview",c),fetch(t).then(p=>p.blob()).then(p=>{as.saveAs(p,c)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;const t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(t){console.error("get videoUrl failed:",t),C.error(this.$t("suno.message.getVideoUrlFailed"))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,l)=>{const o={audio_id:e},c=this.credential?.token;if(!c){console.error("no token specified"),l(new Error("No token specified"));return}P.mp4(o,{token:c}).then(p=>{const d=p.data?.data?.video_url;d?t(d):l(new Error("Video URL not found in response"))}).catch(p=>{l(p)})})},onPreview(e,t){e.stopPropagation(),console.log("on preview",t),window.open(t,"_blank")},async onGetStems(e){await this.onGenerateAudioUrl("stems",e)},onCover(e){console.log("on cover"),console.debug("set config",e),this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:"cover",audio:e,audio_id:e.id})},async onConcatMusic(e){await this.onGenerateAudioUrl("concat",e)},async onRemaster(e){await this.onGenerateAudioUrl("remaster",e)},async onGetAllStems(e){await this.onGenerateAudioUrl("all_stems",e)},onReplaceSection(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:"replace_section",audio:e,audio_id:e.id,replace_section_start:0,replace_section_end:Math.min(30,e.duration||30)})},onMashup(e){this.$store.commit("suno/setConfig",{...this.$store.state.suno?.config,model:e.model,custom:!0,style:e.style,action:"mashup",audio:e,audio_id:e.id,mashup_audio_ids:[e.id]})},async handleWavDownload(e){if(!e?.id||this.isFetchingWav)return;const t=this.credential?.token;if(t)try{this.isFetchingWav=!0,C.info(this.$t("suno.message.fetchingWav"));const o=(await P.wav({audio_id:e.id},{token:t})).data?.data?.audio_url;o?this.onDownload(null,o):C.error(this.$t("suno.message.fetchWavFailed"))}catch{C.error(this.$t("suno.message.fetchWavFailed"))}finally{this.isFetchingWav=!1}},async handleMidiDownload(e){if(!e?.id||this.isFetchingMidi)return;const t=this.credential?.token;if(t)try{this.isFetchingMidi=!0,C.info(this.$t("suno.message.fetchingMidi"));const o=(await P.midi({audio_id:e.id},{token:t})).data?.data?.midi_url;o?this.onDownload(null,o):C.error(this.$t("suno.message.fetchMidiFailed"))}catch{C.error(this.$t("suno.message.fetchMidiFailed"))}finally{this.isFetchingMidi=!1}},async onGenerateAudioUrl(e,t){const l={action:e,audio_id:t,callback_url:ls},o=this.credential?.token;if(!o){console.error("no token specified");return}C.info(this.$t("suno.message.startingTask")),P.audio(l,{token:o}).then(()=>{C.success(this.$t("suno.message.startTaskSuccess"))}).catch(c=>{C.error(c?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{const e=document.querySelector(".tasks");e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug("loading");return}await this.$store.dispatch("suno/getTasks",{limit:30,offset:0})}}}),cs={class:"task"},us=["onClick"],ds={class:"left"},ps=["onClick"],ms=["onClick"],fs={key:2,class:"duration"},hs={class:"info"},_s={class:"title"},gs={class:"style"},$s={class:"right"},vs={class:"el-dropdown-link"},ys={class:"flex items-center min-w-[120px]"},ks={class:"flex items-center min-w-[120px]"},ws={class:"flex items-center min-w-[120px]"},bs={class:"el-dropdown-link"};function Cs(e,t,l,o,c,p){const d=a("el-image"),_=a("video-pause"),$=a("el-icon"),r=a("video-play"),h=a("font-awesome-icon"),b=a("el-tooltip"),f=a("Loading"),k=a("el-dropdown-item"),U=a("el-dropdown-menu"),E=a("el-dropdown"),j=Q("loading");return i(),g("div",cs,[(i(!0),g(D,null,Y(e.audios,v=>(i(),g("div",{key:v.id,class:"audio",onClick:F(V=>e.onClick(v),["stop"])},[q((i(),g("div",ds,[s(d,{src:v?.image_url,class:"cover",fit:"cover",lazy:""},null,8,["src"]),v?.audio_url&&e.$store.state?.suno?.audio?.id===v.id&&e.$store.state?.suno?.audio?.state==="playing"?(i(),g("div",{key:0,class:"overlay",onClick:F(V=>e.onPause(v),["stop"])},[s($,null,{default:m(()=>[s(_)]),_:1})],8,ps)):y("",!0),v?.audio_url&&(e.$store.state?.suno?.audio?.id!==v.id||e.$store.state?.suno?.audio?.id===v.id&&e.$store.state?.suno?.audio?.state==="paused")?(i(),g("div",{key:1,class:"overlay",onClick:F(V=>e.onPlay(v),["stop"])},[s($,null,{default:m(()=>[s(r)]),_:1})],8,ms)):y("",!0),v?.duration?(i(),g("div",fs,u(e.useFormatDuring(v?.duration)),1)):y("",!0)])),[[j,!v?.audio_url]]),n("div",hs,[n("h2",_s,u(v?.title),1),n("p",gs,u(v?.style),1)]),n("div",$s,[s(E,null,{dropdown:m(()=>[s(U,null,{default:m(()=>[s(k,{disabled:e.isFetchingVideoUrl,onClick:V=>e.handleVideoDownload(v)},{default:m(()=>[n("div",ys,[e.isFetchingVideoUrl?(i(),w($,{key:0,class:"is-loading mr-2"},{default:m(()=>[s(f)]),_:1})):y("",!0),n("span",null,u(e.$t("suno.button.download_video")),1)])]),_:2},1032,["disabled","onClick"]),v?.audio_url?(i(),w(k,{key:0,onClick:F(V=>e.onDownload(V,v?.audio_url),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.download_audio")),1)]),_:2},1032,["onClick"])):y("",!0),s(k,{disabled:e.isFetchingWav,onClick:V=>e.handleWavDownload(v)},{default:m(()=>[n("div",ks,[e.isFetchingWav?(i(),w($,{key:0,class:"is-loading mr-2"},{default:m(()=>[s(f)]),_:1})):y("",!0),n("span",null,u(e.$t("suno.button.download_wav")),1)])]),_:2},1032,["disabled","onClick"]),s(k,{disabled:e.isFetchingMidi,onClick:V=>e.handleMidiDownload(v)},{default:m(()=>[n("div",ws,[e.isFetchingMidi?(i(),w($,{key:0,class:"is-loading mr-2"},{default:m(()=>[s(f)]),_:1})):y("",!0),n("span",null,u(e.$t("suno.button.download_midi")),1)])]),_:2},1032,["disabled","onClick"])]),_:2},1024)]),default:m(()=>[n("span",vs,[s(b,{effect:"dark",content:e.$t("suno.button.download"),placement:"top"},{default:m(()=>[v?.audio_url||v?.video_url?(i(),w(h,{key:0,icon:"fa-solid fa-download",class:"icon icon-download"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024),s(E,null,{dropdown:m(()=>[s(U,null,{default:m(()=>[v?.audio_url?(i(),w(k,{key:0,onClick:F(V=>e.onExtend(V,v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.extend")),1)]),_:2},1032,["onClick"])):y("",!0),v.id?(i(),w(k,{key:1,onClick:F(V=>e.onGetStems(v.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.get_stems")),1)]),_:2},1032,["onClick"])):y("",!0),v.id?(i(),w(k,{key:2,onClick:F(V=>e.onGetAllStems(v.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.all_stems")),1)]),_:2},1032,["onClick"])):y("",!0),s(k,{onClick:F(V=>e.onCover(v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.cover_music")),1)]),_:2},1032,["onClick"]),v?.id?(i(),w(k,{key:3,onClick:F(V=>e.onRemaster(v.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.remaster")),1)]),_:2},1032,["onClick"])):y("",!0),v?.id?(i(),w(k,{key:4,onClick:F(V=>e.onReplaceSection(v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.replace_section")),1)]),_:2},1032,["onClick"])):y("",!0),v?.id?(i(),w(k,{key:5,onClick:F(V=>e.onMashup(v),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.mashup")),1)]),_:2},1032,["onClick"])):y("",!0),v?.id&&v?.action==="extend"?(i(),w(k,{key:6,onClick:F(V=>e.onConcatMusic(v?.id),["stop"])},{default:m(()=>[L(u(e.$t("suno.button.concat_music")),1)]),_:2},1032,["onClick"])):y("",!0)]),_:2},1024)]),default:m(()=>[n("span",bs,[s(b,{effect:"dark",content:e.$t("suno.button.more"),placement:"top"},{default:m(()=>[v?.audio_url||v?.video_url?(i(),w(h,{key:0,icon:"fa-solid fa-ellipsis",class:"icon icon-ellipsis"})):y("",!0)]),_:2},1032,["content"])])]),_:2},1024)])],8,us))),128))])}const Ss=A(rs,[["render",Cs]]),Vs={class:"player-slider"},Ls=S({__name:"PlayerSlider",setup(e){const t=H(),l=I({get:()=>t.state.suno?.audio?.progress,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:d})}),o=I({get:()=>t.state.suno?.audio?.duration,set:d=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:d})}),c=()=>{},p=d=>t.dispatch("suno/setAudio",{...t.state.suno.audio,progress:d});return(d,_)=>(i(),g("div",Vs,[s(T(te),{modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=$=>l.value=$),"show-tooltip":!1,min:0,max:o.value,onChange:p,onInput:c},null,8,["modelValue","max"])]))}}),As="/assets/disk-XFRmVAfp.png",js={class:"flex player-song"},Fs=["src"],Es={class:"ml-2 text-xs flex flex-col justify-between"},Ts={class:"w-52 2xl:w-96 cursor-pointer truncate"},Us={class:"flex"},Ps={class:"ml-2 text-dc"},Is=S({__name:"PlayerSong",setup(e){const t=H(),l=I({get:()=>t.state.suno.audio,set:o=>t.commit("suno/setAudio",o)});return Se(l,(o,c)=>{if(o?.audio_url!==c?.audio_url){console.log("audio changed",o),o.object&&(console.log("111",o.object),o.object.pause(),delete o.object);const p=new Audio(o.audio_url);o.state==="playing"?p.play():p.pause(),p.addEventListener("loadedmetadata",()=>{p.currentTime=0,p.addEventListener("timeupdate",()=>{t.commit("suno/setAudio",{...t.state.suno.audio,progress:p.currentTime})})}),t.commit("suno/setAudio",{...t.state.suno.audio,object:p})}else if(o?.progress!==c?.progress&&Math.abs(o.progress-o.object.currentTime)>2){console.log("progress changed",o.progress);const p=t.state.suno.audio;p.object&&(p.object.currentTime=p.progress)}else o?.state!==c?.state&&(console.log("state changed",o.state),o.object&&(o.state==="playing"?o.object.play():o.object.pause()));o?.volume!==c?.volume&&(console.log("volume changed",o.volume),o.object&&(o.object.volume=o.volume/100))}),(o,c)=>(i(),g("div",js,[n("img",{alt:"",class:"w-11 h-11 rounded",src:l.value?.image_url||T(As)},null,8,Fs),n("div",Es,[n("div",Ts,[n("div",Us,[n("span",null,u(l.value?.title||"Music"),1),n("span",Ps,"- "+u(l.value?.style||"SmallRuralDog"),1)])])])]))}}),zs={class:"flex justify-end items-center gap-x-2.5"},Gs={class:"text-xs"},Ms=S({__name:"PlayerAction",setup(e){const t=H(),l=I({get:()=>t.state.suno?.audio?.progress,set:c=>t.commit("suno/setAudio",{...t.state.suno.audio,progress:c})}),o=I({get:()=>t.state.suno?.audio?.duration,set:c=>t.commit("suno/setAudio",{...t.state.suno.audio,duration:c})});return(c,p)=>(i(),g("div",zs,[n("span",Gs,u(T(W)(l.value))+" / "+u(T(W)(o.value)),1)]))}});var Rs={size:"1em",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",rtl:!1,theme:"outline",colors:{outline:{fill:"#333",background:"transparent"},filled:{fill:"#333",background:"#FFF"},twoTone:{fill:"#333",twoTone:"#2F88FF"},multiColor:{outStrokeColor:"#333",outFillColor:"#2F88FF",innerStrokeColor:"#FFF",innerFillColor:"#43CCF8"}},prefix:"i"};function Ds(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function Ws(e,t,l){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],c=[],p=t.theme||l.theme;switch(p){case"outline":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push("none"),c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push("none");break;case"filled":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push("#FFF"),c.push("#FFF");break;case"two-tone":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[1]=="string"?o[1]:l.colors.twoTone.twoTone),c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[1]=="string"?o[1]:l.colors.twoTone.twoTone);break;case"multi-color":c.push(typeof o[0]=="string"?o[0]:"currentColor"),c.push(typeof o[1]=="string"?o[1]:l.colors.multiColor.outFillColor),c.push(typeof o[2]=="string"?o[2]:l.colors.multiColor.innerStrokeColor),c.push(typeof o[3]=="string"?o[3]:l.colors.multiColor.innerFillColor);break}return{size:t.size||l.size,strokeWidth:t.strokeWidth||l.strokeWidth,strokeLinecap:t.strokeLinecap||l.strokeLinecap,strokeLinejoin:t.strokeLinejoin||l.strokeLinejoin,colors:c,id:e}}var Os=Symbol("icon-context");function oe(e,t,l){var o={name:"icon-"+e,props:["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","spin"],setup:function(p){var d=Ds(),_=Ve(Os,Rs);return function(){var $=p.size,r=p.strokeWidth,h=p.strokeLinecap,b=p.strokeLinejoin,f=p.theme,k=p.fill,U=p.spin,E=Ws(d,{size:$,strokeWidth:r,strokeLinecap:h,strokeLinejoin:b,theme:f,fill:k},_),j=[_.prefix+"-icon"];return j.push(_.prefix+"-icon-"+e),t&&_.rtl&&j.push(_.prefix+"-icon-rtl"),U&&j.push(_.prefix+"-icon-spin"),s("span",{class:j.join(" ")},[l(E)])}}};return o}const Bs=oe("pause-one",!1,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M19 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M29 18V30",stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),Ns=oe("play",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M20 24V17.0718L26 20.5359L32 24L26 27.4641L20 30.9282V24Z",fill:e.colors[3],stroke:e.colors[2],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null)])}),qs=oe("volume-small",!0,function(e){return s("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},[s("path",{d:"M24 6V42C17 42 11.7985 32.8391 11.7985 32.8391H6C4.89543 32.8391 4 31.9437 4 30.8391V17.0108C4 15.9062 4.89543 15.0108 6 15.0108H11.7985C11.7985 15.0108 17 6 24 6Z",fill:e.colors[1],stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linejoin":e.strokeLinejoin},null),s("path",{d:"M32 15L32 15C32.6232 15.5565 33.1881 16.1797 33.6841 16.8588C35.1387 18.8504 36 21.3223 36 24C36 26.6545 35.1535 29.1067 33.7218 31.0893C33.2168 31.7885 32.6391 32.4293 32 33",stroke:e.colors[0],"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin},null)])}),ne=S({__name:"IconPark",props:{icon:{},theme:{},size:{},spin:{type:Boolean},fill:{},strokeLinecap:{},strokeLinejoin:{},strokeWidth:{}},setup(e){return(t,l)=>(i(),w(Le(t.icon),{theme:t.theme,size:t.size,spin:t.spin,fill:t.fill,"stroke-linecap":t.strokeLinecap,"stroke-linejoin":t.strokeLinejoin,"stroke-width":t.strokeWidth},null,8,["theme","size","spin","fill","stroke-linecap","stroke-linejoin","stroke-width"]))}}),Hs={class:"player-volume flex flex-col items-center pt-2"},Ks={class:"text-sm mt-3"},Zs=S({__name:"PlayerVolumeSlider",setup(e){const t=H(),l=I({get:()=>t.state.suno.audio?.volume,set:p=>t.commit("suno/setAudio",{...t.state.suno.audio,volume:p})}),o=I({get:()=>t.state.suno.audio?.muted,set:p=>t.commit("suno/setAudio",{...t.state.suno.audio,muted:p})}),c=p=>t.dispatch("suno/setVolume",p);return(p,d)=>(i(),g("div",Hs,[s(T(te),{modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=_=>l.value=_),vertical:"",height:"100px","show-tooltip":!1,max:100,min:0,size:"small",disabled:o.value,onInput:c},null,8,["modelValue","disabled"]),n("div",Ks,u(l.value),1)]))}}),Xs={class:"flex items-center justify-center gap-x-3"},Ys=S({__name:"PlayerController",setup(e){const t=H(),l=()=>t.dispatch("suno/setAudio",{...t.state.suno.audio,state:t.state.suno.audio.state==="playing"?"paused":"playing"}),o=I(()=>t.state.suno.audio);return(c,p)=>(i(),g("div",Xs,[s(ne,{icon:o.value?.state==="playing"?T(Bs):T(Ns),size:"45",theme:"filled",class:"text-[var(--el-color-primary)] cursor-pointer",onClick:l},null,8,["icon"]),s(T(ye),{placement:"top",width:"50px",trigger:"click"},{reference:m(()=>[s(ne,{icon:T(qs),size:"20","stroke-width":2,class:"cursor-pointer"},null,8,["icon"])]),default:m(()=>[s(Zs)]),_:1})]))}}),Js={class:"flex flex-col items-stretch h-20"},Qs={class:"flex grow px-5 items-center"},xs={class:"flex-1"},en={class:"flex-1"},tn={class:"flex-1"},on=S({__name:"Player",setup(e){return(t,l)=>(i(),g("div",Js,[s(Ls),n("div",Qs,[n("div",xs,[s(Is)]),n("div",en,[s(Ys)]),n("div",tn,[s(Ms)])])]))}}),sn=S({name:"RecentPanel",components:{ElSkeletonItem:we,ElSkeleton:ke,TaskPreview:Ss,Player:on,NoTasks:Ie,ScrollList:Ue},props:{loading:{type:Boolean,default:!1}},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.suno?.tasks,items:this.$store.state.suno?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),nn={key:0,class:"tasks"},an={class:"left w-[70px] p-[10px] flex items-center"},ln={class:"main w-[calc(100%-70px)] flex-1 p-[10px]"},rn={key:2,class:"w-full flex-1 flex items-center justify-center"},cn={class:"h-20"};function un(e,t,l,o,c,p){const d=a("el-skeleton-item"),_=a("el-skeleton"),$=a("task-preview"),r=a("scroll-list"),h=a("no-tasks"),b=a("player");return i(),g(D,null,[e.tasks?.items===void 0?(i(),g("div",nn,[(i(),g(D,null,Y(3,f=>n("div",{key:f,class:"flex"},[n("div",an,[s(_,{animated:""},{template:m(()=>[s(d,{variant:"image",class:"avatar w-[50px] h-[50px]"})]),_:1})]),n("div",ln,[s(_,{animated:""},{template:m(()=>[s(d,{variant:"p",class:"w-[200px] h-[15px] mb-[5px] mt-[10px]"}),s(d,{variant:"text"})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(i(),w(r,{key:1,ref:"scrollList",class:"flex-1 w-full overflow-y-auto tasks p-2",loading:e.loading,onReachTop:t[0]||(t[0]=f=>e.$emit("reach-top"))},{default:m(()=>[(i(!0),g(D,null,Y(e.tasks?.items,(f,k)=>(i(),w($,{key:k,"model-value":f,class:"preview"},null,8,["model-value"]))),128))]),_:1},8,["loading"])):y("",!0),e.tasks?.items?.length===0?(i(),g("div",rn,[s(h)])):y("",!0),q(n("div",cn,[s(b)],512),[[Ae,!!e.$store?.state?.suno?.audio?.object]])],64)}const dn=A(sn,[["render",un]]),pn=S({name:"TaskPreview",components:{IconPicture:Ce,ElImage:N,ElAvatar:be,ElIcon:J},computed:{audio(){return this.$store.state.suno?.audio}}}),mn={key:0,class:"size-full overflow-hidden"},fn={class:"relative h-[300px]"},hn={class:"flex items-center justify-center size-full bg-[var(--el-bg-color)]"},_n={class:"absolute bottom-0 left-0 right-0 m-0 p-4 text-white z-10 bg-gradient-to-t from-black/70 to-transparent"},gn={class:"p-4"},$n={class:"flex items-center font-bold mb-2"},vn={class:"text-[var(--el-text-color-regular)] mb-2"},yn={class:"text-xs text-[var(--el-text-color-regular)]"},kn={class:"mt-4 text-sm leading-[25px] whitespace-pre-wrap"},wn={key:1,class:"w-full h-full"};function bn(e,t,l,o,c,p){const d=a("icon-picture"),_=a("el-icon"),$=a("el-image"),r=a("el-avatar");return e.audio?.object?(i(),g("div",mn,[n("div",fn,[s($,{src:e.audio.image_url,fit:"cover",class:"size-full"},{error:m(()=>[n("div",hn,[s(_,{class:"text-3xl"},{default:m(()=>[s(d)]),_:1})])]),_:1},8,["src"]),n("h2",_n,u(e.audio?.title),1)]),n("div",gn,[n("div",$n,[s(r,{size:30,src:e.audio?.image_url,class:"mr-2"},null,8,["src"]),n("span",null,u(e.audio?.title),1)]),n("p",vn,u(e.audio?.style),1),n("p",yn,u(e.$dayjs.format(e.audio?.created_at)),1),n("div",kn,[n("p",null,u(e.audio?.lyric),1)])])])):(i(),g("div",wn))}const Cn=A(pn,[["render",bn]]),Sn="https://webhook.acedata.cloud/suno",Vn=S({name:"SunoIndex",components:{Layout:Ne,ConfigPanel:ss,RecentPanel:dn,PreviewPanel:Cn},inject:["initialized"],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.suno?.status?.getApplications===R.Request},tasksLoading(){return this.$store.state.suno?.status?.getTasks===R.Request||this.fetchingTasks},service(){return this.$store.state.suno.service},credential(){return this.$store.state.suno.credential},config(){return this.$store.state.suno.config},initializing(){return this.$store.state.suno.status.getApplications===R.Request},needApply(){return this.$store.state.suno.status.getApplications===R.Success&&!this.application},application(){return this.$store.state.suno.application},tasks(){return this.$store.state.suno.tasks},applications(){return this.$store.state.suno.applications}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await Ge({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("suno/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplications"),await this.$store.dispatch("suno/getApplications"),console.debug("end onGetApplications"),await this.onGetTasks()},onApply(){Ee.create({application:this.application}).then(({data:e})=>{this.application=e,C.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===Te&&C.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){await this.$nextTick();const e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=5,createdAtMin:l,createdAtMax:o}=e||{};console.debug("limit",t,"createdAtMin",l,"createdAtMax",o),this.fetchingTasks=!0;try{await this.$store.dispatch("suno/getTasks",{limit:t,createdAtMin:l,createdAtMax:o})}finally{this.fetchingTasks=!1}},async onGenerateAudio(){const e={...this.config,callback_url:Sn},t=this.credential?.token;if(!t){console.error("no token specified");return}C.info(this.$t("suno.message.startingTask")),P.audio(e,{token:t}).then(()=>{C.success(this.$t("suno.message.startTaskSuccess"))}).catch(l=>{C.error(l?.response?.data?.error?.message||this.$t("suno.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function Ln(e,t,l,o,c,p){const d=a("config-panel"),_=a("recent-panel"),$=a("preview-panel"),r=a("layout");return i(),w(r,null,{config:m(()=>[s(d,{onGenerate:e.onGenerateAudio},null,8,["onGenerate"])]),result:m(()=>[s(_,{ref:"recentPanel",class:"panel recent",loading:e.loadingMore,onReachTop:e.onReachTop},null,8,["loading","onReachTop"])]),preview:m(()=>[s($)]),_:1})}const Dn=A(Vn,[["render",Ln],["__scopeId","data-v-d1296b1a"]]);export{Dn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as A}from"./index.es-CQANB9vJ.js";import{l as C,S as N,s as W,t as H,u as V,N as j,O,p as K,G as Z,j as J}from"./vendor-element-plus-B4FTqxj4.js";import{d as k,C as i,G as c,T as s,E as D,K as _,ai as n,D as a,R as o,Q as u,S as w,ag as I,J as E,O as v,M as R,X as Q}from"./vendor-vue-1w_NBnjl.js";import{_ as y,aj as X,cg as Y,ch as x,ci as ee,cj as se,ck as te,cl as oe,cm as U,cn as G,co as q,cp as B,cq as ae,aB as ne,ay as P}from"./index-DgtHfSqf.js";import{I as M,S as le}from"./ScrollList-BSHydg5K.js";import{I as F}from"./ImagePreview-Dif2Q49Y.js";import{C as re,N as ie}from"./NoTasks-4TJvTcNH.js";import{a as ce}from"./price-Cbls6Qoc.js";import{C as de}from"./CopyToClipboard-BGClcrVG.js";import{I as me}from"./ImageWrapper-BskBzKqs.js";import{B as ue}from"./BotPlaceholder-C_tpj9cL.js";import"./vendor-dayjs-CzbnksQQ.js";import"./vendor-web3-BXoVw72d.js";import"./vendor-axios-NIGUFBhG.js";import"./vendor-vue-router-Dj5bcX0v.js";const pe=k({name:"LayoutSeedream",components:{ElDrawer:N,ElButton:C,FontAwesomeIcon:A},data(){return{drawer:!1}}}),fe={class:"main flex flex-row flex-1"},he={class:"config w-[320px] h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]"},_e={class:"result h-full p-6 flex-1 flex flex-col bg-[var(--app-content-bg)]"};function ge(e,t,g,r,m,p){const f=n("font-awesome-icon"),h=n("el-button"),l=n("el-drawer");return a(),i("div",fe,[c("div",he,[D(e.$slots,"config",{},void 0,!0)]),c("div",_e,[D(e.$slots,"result",{},void 0,!0)]),s(h,{circle:"",class:"menu",onClick:t[0]||(t[0]=d=>e.drawer=!0)},{default:_(()=>[s(f,{icon:"fa-solid fa-magic"})]),_:1}),s(l,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=d=>e.drawer=d),direction:"ltr","with-header":!1,size:"340px",class:"drawer"},{default:_(()=>[D(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const $e=y(pe,[["render",ge],["__scopeId","data-v-5ff0c320"]]),ve="",be=k({name:"SeedreamPromptInput",components:{ElInput:W,InfoIcon:M},computed:{prompt:{get(){return this.$store.state.seedream?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=ve)}}),ke={class:"field"},ye={class:"box"},we={class:"title font-bold"};function Ee(e,t,g,r,m,p){const f=n("info-icon"),h=n("el-input");return a(),i("div",ke,[c("div",ye,[c("h2",we,o(e.$t("seedream.name.prompt")),1),s(f,{content:e.$t("seedream.description.prompt"),class:"info"},null,8,["content"])]),s(h,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||(t[0]=l=>e.prompt=l),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("seedream.placeholder.prompt")},null,8,["modelValue","placeholder"])])}const Se=y(be,[["render",Ee],["__scopeId","data-v-5559520a"]]),Ve=k({name:"SeedreamImageInput",components:{ElUpload:H,ElButton:C,InfoIcon:M,ImagePreview:F,FontAwesomeIcon:A},data(){return{fileList:[],uploadUrl:X()+"/api/v1/files/",suppressWatch:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url).filter(e=>!!e)},value(){return this.$store.state.seedream?.config?.image}},watch:{value:{immediate:!0,handler(e){if(this.suppressWatch)return;if(!e||e.length===0){const r=(this.fileList||[]).filter(m=>!m?.response?.file_url);this.fileList=r.length?r:[];return}const t=[];e.forEach(r=>{const m=this.fileList.find(p=>p?.response?.file_url===r||p?.url===r);m?t.push(m):t.push({name:r.split("/").pop()||r,url:r,status:"success",percentage:100,response:{file_url:r}})}),(this.fileList||[]).filter(r=>!r?.response?.file_url).forEach(r=>{t.some(p=>p===r||p?.url===r?.url||p?.response?.file_url===r?.response?.file_url)||t.push(r)}),this.fileList=t}}},methods:{onChange(e){if(!e?.url&&e?.raw)try{e.url=URL.createObjectURL(e.raw)}catch{}},onRemove(e){if(e?.url&&typeof e.url=="string"&&e.url.startsWith("blob:"))try{URL.revokeObjectURL(e.url)}catch{}this.onSetImages()},onExceed(){V.warning(this.$t("seedream.message.uploadImageExceed"))},onError(){V.error(this.$t("seedream.message.uploadImageError"))},onSetImages(){const e=this.urls;this.suppressWatch=!0,this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,image:e}),this.$nextTick(()=>{this.suppressWatch=!1})},async onSuccess(e,t){e?.file_url&&(t.url=e.file_url,t.response=e),this.onSetImages()},onRemovePreview(e,t){if(this.fileList.splice(e,1),t?.url&&typeof t.url=="string"&&t.url.startsWith("blob:"))try{URL.revokeObjectURL(t.url)}catch{}this.onSetImages()}}}),Ie={class:"field"},Le={class:"label"},Re={class:"box"},Te={class:"title font-bold"},Ae={class:"value"},Ce={class:"file-list mt-2 flex flex-wrap gap-[10px]"};function Me(e,t,g,r,m,p){const f=n("info-icon"),h=n("font-awesome-icon"),l=n("el-button"),d=n("el-upload"),b=n("image-preview");return a(),i(w,null,[c("div",Ie,[c("div",Le,[c("div",Re,[c("h2",Te,o(e.$t("seedream.name.imageUrls")),1),s(f,{content:e.$t("seedream.description.imageUrls"),class:"info"},null,8,["content"])])]),c("div",Ae,[s(d,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=$=>e.fileList=$),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file",limit:14,multiple:!0,"show-file-list":!1,action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,"on-change":e.onChange,"on-remove":e.onRemove,headers:e.headers},{default:_(()=>[s(l,{size:"small",type:"primary",round:""},{default:_(()=>[s(h,{icon:"fa-solid fa-upload",class:"mr-1"}),u(" "+o(e.$t("seedream.button.uploadImageUrls")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","on-change","on-remove","headers"])])]),c("div",Ce,[(a(!0),i(w,null,I(e.fileList,($,S)=>(a(),E(b,{key:$.uid||$?.response?.file_url||$.url||S,url:$.url||$?.response?.file_url,name:$.name,percentage:$.percentage,onRemove:z=>e.onRemovePreview(S,$)},null,8,["url","name","percentage","onRemove"]))),128))])],64)}const De=y(Ve,[["render",Me],["__scopeId","data-v-29737ed9"]]),ze=k({name:"SeedreamModelSelector",components:{ElSelect:O,ElOption:j,InfoIcon:M},data(){return{options:[{value:x,label:this.$t("seedream.model.seedream45")},{value:ee,label:this.$t("seedream.model.seedream40")},{value:se,label:this.$t("seedream.model.seedream30t2i")},{value:te,label:this.$t("seedream.model.seededit30i2i")}]}},computed:{value:{get(){return this.$store.state.seedream?.config?.model},set(e){this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,model:e})}}},mounted(){this.value||(this.value=Y)}}),Ue={class:"field"},Ge={class:"label"},qe={class:"box"},Pe={class:"title font-bold"};function je(e,t,g,r,m,p){const f=n("info-icon"),h=n("el-option"),l=n("el-select");return a(),i("div",Ue,[c("div",Ge,[c("div",qe,[c("h2",Pe,o(e.$t("seedream.name.model")),1),s(f,{content:e.$t("seedream.description.model"),class:"info"},null,8,["content"])])]),s(l,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=d=>e.value=d),class:"value",placeholder:e.$t("seedream.placeholder.select")},{default:_(()=>[(a(!0),i(w,null,I(e.options,d=>(a(),E(h,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const Oe=y(ze,[["render",je],["__scopeId","data-v-3c3ca27d"]]),Be=k({name:"SeedreamSizeSelector",components:{ElSelect:O,ElOption:j,InfoIcon:M},data(){return{options:[{value:U,label:U},{value:G,label:G},{value:q,label:q}]}},computed:{value:{get(){return this.$store.state.seedream?.config?.size},set(e){this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,size:e})}}},mounted(){this.value||(this.value=oe)}}),Fe={class:"field"},Ne={class:"label"},We={class:"box"},He={class:"title font-bold"};function Ke(e,t,g,r,m,p){const f=n("info-icon"),h=n("el-option"),l=n("el-select");return a(),i("div",Fe,[c("div",Ne,[c("div",We,[c("h2",He,o(e.$t("seedream.name.size")),1),s(f,{content:e.$t("seedream.description.size"),class:"info"},null,8,["content"])])]),s(l,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=d=>e.value=d),class:"value",placeholder:e.$t("seedream.placeholder.select"),filterable:"","allow-create":"","default-first-option":""},{default:_(()=>[(a(!0),i(w,null,I(e.options,d=>(a(),E(h,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const Ze=y(Be,[["render",Ke],["__scopeId","data-v-54a9a469"]]),Je=k({name:"SeedreamConfigPanel",components:{ElButton:C,FontAwesomeIcon:A,PromptInput:Se,Consumption:re,ImageInput:De,ModelSelector:Oe,SizeSelector:Ze},emits:["generate"],computed:{config(){return this.$store.state.seedream?.config},consumption(){const e={...this.config||{}},t=Array.isArray(e?.image)&&e.image.length>0;return ce({...e,action:t?"edit":"generate",model:B(e?.model),count:1},this.service?.cost)},service(){return this.$store.state.seedream?.service}},methods:{onGenerate(){this.$emit("generate")}}}),Qe={class:"flex flex-col h-full"},Xe={class:"flex-1 overflow-y-auto p-5"},Ye={class:"flex flex-col items-center justify-center px-5 pb-5"};function xe(e,t,g,r,m,p){const f=n("model-selector"),h=n("size-selector"),l=n("prompt-input"),d=n("image-input"),b=n("consumption"),$=n("font-awesome-icon"),S=n("el-button");return a(),i("div",Qe,[c("div",Xe,[s(f,{class:"mb-4"}),s(h,{class:"mb-4"}),s(l,{class:"mb-4"}),s(d,{class:"mb-4"})]),c("div",Ye,[s(b,{value:e.consumption,service:e.service},null,8,["value","service"]),s(S,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:_(()=>[s($,{icon:"fa-solid fa-magic",class:"mr-2"}),u(" "+o(e.$t("seedream.button.generate")),1)]),_:1},8,["onClick"])])])}const es=y(Je,[["render",xe]]),ss=k({name:"SeedreamTaskPreview",components:{ElImage:J,CopyToClipboard:de,FontAwesomeIcon:A,ElAlert:Z,ImageWrapper:me,ElButton:C,ElTooltip:K,ImagePreview:F},props:{modelValue:{type:Object,required:!0}},computed:{isEdit(){return Array.isArray(this.modelValue?.request?.image)&&(this.modelValue?.request?.image?.length||0)>0},images(){const e=[];return Array.isArray(this.modelValue?.response?.data)&&this.modelValue?.response?.data?.forEach(t=>{e.push(t)}),e}},methods:{shortModel(e){return B(e)||e},onEdit(e){if(!e)return;console.debug("Edit image:",e);const t={...this.$store.state.seedream?.config||{}};t.image=[e],this.$store.commit("seedream/setConfig",t)}}}),ts={class:"preview"},os={class:"left"},as={class:"main"},ns={class:"bot"},ls={class:"datetime"},rs={class:"info"},is={key:0,class:"flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto"},cs={key:1,class:"prompt mt-2"},ds={key:0},ms={key:0,class:R({content:!0})},us={class:"text-[var(--el-text-color-regular)] text-xs mb-0"},ps={key:1,class:R({content:!0,failed:!0})},fs={class:"flex justify-start items-center gap-4 w-full overflow-x-auto"},hs={class:R({operations:!0,"mt-2":!0,"mb-2":!0})},_s={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},gs={key:1,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},$s={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},vs={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},bs={key:2,class:"text-[var(--el-text-color-regular)] text-xs mb-0"},ks={key:2,class:R({content:!0})},ys={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},ws={key:1,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Es={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Ss={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Vs={key:2,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Is={key:3,class:"text-[var(--el-text-color-regular)] text-xs mb-0"},Ls={key:3,class:R({content:!0})},Rs={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Ts={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-0"};function As(e,t,g,r,m,p){const f=n("el-image"),h=n("image-preview"),l=n("font-awesome-icon"),d=n("copy-to-clipboard"),b=n("el-alert"),$=n("image-wrapper"),S=n("el-button"),z=n("el-tooltip");return a(),i("div",ts,[c("div",os,[s(f,{src:"https://cdn.acedata.cloud/9egrbn.png",class:"avatar"})]),c("div",as,[c("div",ns,[u(o(e.$t("seedream.name.seedreamBot"))+" ",1),c("span",ls,o(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),c("div",rs,[Array.isArray(e.modelValue?.request?.image)&&e.modelValue?.request?.image.length>0?(a(),i("div",is,[(a(!0),i(w,null,I(e.modelValue?.request?.image,(L,T)=>(a(),E(h,{key:T,url:L,name:`image-${T+1}`,closable:!1},null,8,["url","name"]))),128))])):v("",!0),e.modelValue?.request?.prompt?(a(),i("p",cs,[u(o(e.modelValue?.request?.prompt)+" ",1),e.modelValue?.response?v("",!0):(a(),i("span",ds," - ("+o(e.$t("seedream.status.pending"))+") ",1))])):v("",!0)]),e.modelValue?.response?e.modelValue?.response?.success===!0?(a(),i("div",ps,[c("div",fs,[(a(!0),i(w,null,I(e.images,(L,T)=>(a(),E($,{key:T,src:L?.image_url,"raw-src":L?.image_url},null,8,["src","raw-src"]))),128))]),c("div",hs,[s(z,{class:"box-item",effect:"dark",content:e.$t("common.button.edit"),placement:"top-start"},{default:_(()=>[s(S,{type:"info",size:"small",class:"btn-action",onClick:t[0]||(t[0]=Q(L=>e.onEdit(e.images?.[0]?.image_url),["stop"]))},{default:_(()=>[u(o(e.$t("common.button.edit")),1)]),_:1})]),_:1},8,["content"])]),s(b,{closable:!1,class:"mt-2 success"},{default:_(()=>[e.modelValue?.request?.model?(a(),i("p",_s,[s(l,{icon:"fa-solid fa-cube",class:"mr-1"}),u(" "+o(e.$t("seedream.name.model"))+": "+o(e.shortModel(e.modelValue?.request?.model)),1)])):v("",!0),e.modelValue?.request?.size?(a(),i("p",gs,[s(l,{icon:"fa-solid fa-image",class:"mr-1"}),u(" "+o(e.$t("seedream.name.size"))+": "+o(e.modelValue?.request?.size),1)])):v("",!0),c("p",$s,[s(l,{icon:"fa-solid fa-bolt",class:"mr-1"}),u(" "+o(e.$t("seedream.name.task"))+": "+o(e.isEdit?e.$t("seedream.name.edits"):e.$t("seedream.name.generate")),1)]),c("p",vs,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy inline-block"},null,8,["content"])]),e.modelValue?.response?.trace_id?(a(),i("p",bs,[s(l,{icon:"fa-solid fa-hashtag",class:"mr-1"}),u(" "+o(e.$t("seedream.name.traceId"))+": "+o(e.modelValue?.response?.trace_id)+" ",1),s(d,{content:e.modelValue?.response?.trace_id,class:"btn-copy inline-block"},null,8,["content"])])):v("",!0)]),_:1})])):e.modelValue?.response?.success===!1?(a(),i("div",ks,[s(b,{closable:!1,class:"failure"},{template:_(()=>[s(l,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),u(" "+o(e.$t("seedream.name.failure")),1)]),default:_(()=>[e.modelValue?.request?.model?(a(),i("p",ys,[s(l,{icon:"fa-solid fa-cube",class:"mr-1"}),u(" "+o(e.$t("seedream.name.model"))+": "+o(e.shortModel(e.modelValue?.request?.model)),1)])):v("",!0),e.modelValue?.request?.size?(a(),i("p",ws,[s(l,{icon:"fa-solid fa-image",class:"mr-1"}),u(" "+o(e.$t("seedream.name.size"))+": "+o(e.modelValue?.request?.size),1)])):v("",!0),c("p",Es,[s(l,{icon:"fa-solid fa-bolt",class:"mr-1"}),u(" "+o(e.$t("seedream.name.task"))+": "+o(e.isEdit?e.$t("seedream.name.edits"):e.$t("seedream.name.generate")),1)]),c("p",Ss,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),e.modelValue?.response?.error?.message?(a(),i("p",Vs,[s(l,{icon:"fa-solid fa-circle-info",class:"mr-1"}),u(" "+o(e.$t("seedream.name.failureReason"))+": "+o(e.modelValue?.response?.error?.message)+" ",1),s(d,{content:e.modelValue?.response?.error?.message,class:"btn-copy"},null,8,["content"])])):v("",!0),e.modelValue?.response?.trace_id?(a(),i("p",Is,[s(l,{icon:"fa-solid fa-hashtag",class:"mr-1"}),u(" "+o(e.$t("seedream.name.traceId"))+": "+o(e.modelValue?.response?.trace_id)+" ",1),s(d,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])):v("",!0)]),_:1})])):(a(),i("div",Ls,[s(b,{closable:!1,class:"info"},{template:_(()=>[s(l,{icon:"fa-solid fa-circle-info",class:"mr-1"}),u(" "+o(e.$t("seedream.name.status")),1)]),default:_(()=>[c("p",Rs,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),e.modelValue?.response?.trace_id?(a(),i("p",Ts,[s(l,{icon:"fa-solid fa-hashtag",class:"mr-1"}),u(" "+o(e.$t("seedream.name.traceId"))+": "+o(e.modelValue?.response?.trace_id)+" ",1),s(d,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])):v("",!0)]),_:1})])):(a(),i("div",ms,[s(b,{closable:!1,class:"info"},{template:_(()=>[s(l,{icon:"fa-regular fa-clock",class:"mr-1"}),u(" "+o(e.$t("seedream.status.pending")),1)]),default:_(()=>[c("p",us,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy inline-block"},null,8,["content"])])]),_:1})]))])])}const Cs=y(ss,[["render",As],["__scopeId","data-v-20c93f4e"]]),Ms=k({name:"SeedreamRecentPanel",components:{TaskPreview:Cs,BotPlaceholder:ue,NoTasks:ie,ScrollList:le},props:{loading:{type:Boolean,default:!1}},emits:["reach-top"],computed:{tasks(){return{...this.$store.state.seedream?.tasks,items:this.$store.state.seedream?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Ds={key:0},zs={key:2,class:"w-full h-full flex items-center justify-center"};function Us(e,t,g,r,m,p){const f=n("bot-placeholder"),h=n("task-preview"),l=n("scroll-list"),d=n("no-tasks");return a(),i(w,null,[e.tasks?.items===void 0?(a(),i("div",Ds,[s(f)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(a(),E(l,{key:1,ref:"scrollList",class:"tasks h-full w-full overflow-y-auto",loading:e.loading,onReachTop:t[0]||(t[0]=b=>e.$emit("reach-top"))},{default:_(()=>[(a(!0),i(w,null,I(e.tasks?.items,b=>(a(),E(h,{key:b.id,"model-value":b},null,8,["model-value"]))),128))]),_:1},8,["loading"])):v("",!0),e.tasks?.items?.length===0?(a(),i("div",zs,[s(d)])):v("",!0)],64)}const Gs=y(Ms,[["render",Us]]),qs="https://webhook.acedata.cloud/seedream",Ps=k({name:"SeedreamIndex",components:{ConfigPanel:es,Layout:$e,RecentPanel:Gs},inject:["initialized"],data(){return{task:void 0,job:0,loading:!1}},computed:{applicationsLoading(){return this.$store.state.seedream?.status?.getApplications===P.Request},tasksLoading(){return this.$store.state.seedream?.status?.getTasks===P.Request},credential(){return this.$store.state.seedream?.credential},config(){return this.$store.state.seedream?.config},application(){return this.$store.state.seedream?.application},tasks(){return this.$store.state.seedream?.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){if(console.debug("reached top"),this.loading||this.tasksLoading)return;const e=this.tasks?.total,t=this.tasks?.items?.length||0;if(e!==void 0&&e<=t)return;const g=this.tasks?.items?.[0];if(!g?.created_at)return;const m=this.$refs.recentPanel?.getScrollElement?.(),p=m?.scrollHeight||0,f=m?.scrollTop||0;this.loading=!0;try{if(await this.onGetTasks({createdAtMax:g.created_at}),await this.$nextTick(),m){const h=m.scrollHeight;m.scrollTop=h-p+f}}finally{this.loading=!1}},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("seedream/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("seedream/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},async onScrollDown(){await this.$nextTick();const e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.tasksLoading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=20,createdAtMin:g,createdAtMax:r}=e||{};console.debug("limit",t,"createdAtMin",g,"createdAtMax",r),await this.$store.dispatch("seedream/getTasks",{limit:t,createdAtMin:g,createdAtMax:r})},async onGenerate(){const e={...this.config||{}};!(Array.isArray(e?.image)&&e.image.length>0)&&"image"in e&&delete e.image,e?.size||delete e.size;const g={...e,callback_url:qs},r=this.credential?.token;if(!r){console.error("no token specified");return}V.info(this.$t("seedream.message.startingTask")),ae.generate(g,{token:r}).then(()=>{V.success(this.$t("seedream.message.startTaskSuccess"))}).catch(m=>{const p=m?.response?.data;p?.error?.code===ne?V.error(this.$t("seedream.message.usedUp")):V.error(this.$t("seedream.message.startTaskFailed")+(p?.error?.message||""))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function js(e,t,g,r,m,p){const f=n("config-panel"),h=n("recent-panel"),l=n("layout");return a(),E(l,null,{config:_(()=>[s(f,{onGenerate:e.onGenerate},null,8,["onGenerate"])]),result:_(()=>[s(h,{ref:"recentPanel",loading:e.loading,onReachTop:e.onReachTop},null,8,["loading","onReachTop"])]),_:1})}const tt=y(Ps,[["render",js]]);export{tt as default};
|
|
1
|
+
import{F as A}from"./index.es-sibb1JwV.js";import{l as C,S as N,s as W,t as H,u as V,N as j,O,p as K,G as Z,j as J}from"./vendor-element-plus-B4FTqxj4.js";import{d as k,C as i,G as c,T as s,E as D,K as _,ai as n,D as a,R as o,Q as u,S as w,ag as I,J as E,O as v,M as R,X as Q}from"./vendor-vue-1w_NBnjl.js";import{_ as y,aj as X,cg as Y,ch as x,ci as ee,cj as se,ck as te,cl as oe,cm as U,cn as G,co as q,cp as B,cq as ae,aB as ne,ay as P}from"./index-Cg8W5HXP.js";import{I as M,S as le}from"./ScrollList-Ctwoso0M.js";import{I as F}from"./ImagePreview-Dl9A5DPA.js";import{C as re,N as ie}from"./NoTasks-CXFbDY0A.js";import{a as ce}from"./price-CUVRj46N.js";import{C as de}from"./CopyToClipboard-D0zLUUky.js";import{I as me}from"./ImageWrapper-SReVU_Bh.js";import{B as ue}from"./BotPlaceholder-C2zBHB2O.js";import"./vendor-dayjs-CzbnksQQ.js";import"./vendor-web3-vJ0jlMeb.js";import"./vendor-axios-NIGUFBhG.js";import"./vendor-vue-router-Dj5bcX0v.js";const pe=k({name:"LayoutSeedream",components:{ElDrawer:N,ElButton:C,FontAwesomeIcon:A},data(){return{drawer:!1}}}),fe={class:"main flex flex-row flex-1"},he={class:"config w-[320px] h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]"},_e={class:"result h-full p-6 flex-1 flex flex-col bg-[var(--app-content-bg)]"};function ge(e,t,g,r,m,p){const f=n("font-awesome-icon"),h=n("el-button"),l=n("el-drawer");return a(),i("div",fe,[c("div",he,[D(e.$slots,"config",{},void 0,!0)]),c("div",_e,[D(e.$slots,"result",{},void 0,!0)]),s(h,{circle:"",class:"menu",onClick:t[0]||(t[0]=d=>e.drawer=!0)},{default:_(()=>[s(f,{icon:"fa-solid fa-magic"})]),_:1}),s(l,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=d=>e.drawer=d),direction:"ltr","with-header":!1,size:"340px",class:"drawer"},{default:_(()=>[D(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const $e=y(pe,[["render",ge],["__scopeId","data-v-5ff0c320"]]),ve="",be=k({name:"SeedreamPromptInput",components:{ElInput:W,InfoIcon:M},computed:{prompt:{get(){return this.$store.state.seedream?.config?.prompt},set(e){console.debug("set prompt",e),this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,prompt:e})}}},mounted(){this.prompt||(this.prompt=ve)}}),ke={class:"field"},ye={class:"box"},we={class:"title font-bold"};function Ee(e,t,g,r,m,p){const f=n("info-icon"),h=n("el-input");return a(),i("div",ke,[c("div",ye,[c("h2",we,o(e.$t("seedream.name.prompt")),1),s(f,{content:e.$t("seedream.description.prompt"),class:"info"},null,8,["content"])]),s(h,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||(t[0]=l=>e.prompt=l),rows:3,type:"textarea",class:"prompt",placeholder:e.$t("seedream.placeholder.prompt")},null,8,["modelValue","placeholder"])])}const Se=y(be,[["render",Ee],["__scopeId","data-v-5559520a"]]),Ve=k({name:"SeedreamImageInput",components:{ElUpload:H,ElButton:C,InfoIcon:M,ImagePreview:F,FontAwesomeIcon:A},data(){return{fileList:[],uploadUrl:X()+"/api/v1/files/",suppressWatch:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url).filter(e=>!!e)},value(){return this.$store.state.seedream?.config?.image}},watch:{value:{immediate:!0,handler(e){if(this.suppressWatch)return;if(!e||e.length===0){const r=(this.fileList||[]).filter(m=>!m?.response?.file_url);this.fileList=r.length?r:[];return}const t=[];e.forEach(r=>{const m=this.fileList.find(p=>p?.response?.file_url===r||p?.url===r);m?t.push(m):t.push({name:r.split("/").pop()||r,url:r,status:"success",percentage:100,response:{file_url:r}})}),(this.fileList||[]).filter(r=>!r?.response?.file_url).forEach(r=>{t.some(p=>p===r||p?.url===r?.url||p?.response?.file_url===r?.response?.file_url)||t.push(r)}),this.fileList=t}}},methods:{onChange(e){if(!e?.url&&e?.raw)try{e.url=URL.createObjectURL(e.raw)}catch{}},onRemove(e){if(e?.url&&typeof e.url=="string"&&e.url.startsWith("blob:"))try{URL.revokeObjectURL(e.url)}catch{}this.onSetImages()},onExceed(){V.warning(this.$t("seedream.message.uploadImageExceed"))},onError(){V.error(this.$t("seedream.message.uploadImageError"))},onSetImages(){const e=this.urls;this.suppressWatch=!0,this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,image:e}),this.$nextTick(()=>{this.suppressWatch=!1})},async onSuccess(e,t){e?.file_url&&(t.url=e.file_url,t.response=e),this.onSetImages()},onRemovePreview(e,t){if(this.fileList.splice(e,1),t?.url&&typeof t.url=="string"&&t.url.startsWith("blob:"))try{URL.revokeObjectURL(t.url)}catch{}this.onSetImages()}}}),Ie={class:"field"},Le={class:"label"},Re={class:"box"},Te={class:"title font-bold"},Ae={class:"value"},Ce={class:"file-list mt-2 flex flex-wrap gap-[10px]"};function Me(e,t,g,r,m,p){const f=n("info-icon"),h=n("font-awesome-icon"),l=n("el-button"),d=n("el-upload"),b=n("image-preview");return a(),i(w,null,[c("div",Ie,[c("div",Le,[c("div",Re,[c("h2",Te,o(e.$t("seedream.name.imageUrls")),1),s(f,{content:e.$t("seedream.description.imageUrls"),class:"info"},null,8,["content"])])]),c("div",Ae,[s(d,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=$=>e.fileList=$),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file",limit:14,multiple:!0,"show-file-list":!1,action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,"on-change":e.onChange,"on-remove":e.onRemove,headers:e.headers},{default:_(()=>[s(l,{size:"small",type:"primary",round:""},{default:_(()=>[s(h,{icon:"fa-solid fa-upload",class:"mr-1"}),u(" "+o(e.$t("seedream.button.uploadImageUrls")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","on-change","on-remove","headers"])])]),c("div",Ce,[(a(!0),i(w,null,I(e.fileList,($,S)=>(a(),E(b,{key:$.uid||$?.response?.file_url||$.url||S,url:$.url||$?.response?.file_url,name:$.name,percentage:$.percentage,onRemove:z=>e.onRemovePreview(S,$)},null,8,["url","name","percentage","onRemove"]))),128))])],64)}const De=y(Ve,[["render",Me],["__scopeId","data-v-29737ed9"]]),ze=k({name:"SeedreamModelSelector",components:{ElSelect:O,ElOption:j,InfoIcon:M},data(){return{options:[{value:x,label:this.$t("seedream.model.seedream45")},{value:ee,label:this.$t("seedream.model.seedream40")},{value:se,label:this.$t("seedream.model.seedream30t2i")},{value:te,label:this.$t("seedream.model.seededit30i2i")}]}},computed:{value:{get(){return this.$store.state.seedream?.config?.model},set(e){this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,model:e})}}},mounted(){this.value||(this.value=Y)}}),Ue={class:"field"},Ge={class:"label"},qe={class:"box"},Pe={class:"title font-bold"};function je(e,t,g,r,m,p){const f=n("info-icon"),h=n("el-option"),l=n("el-select");return a(),i("div",Ue,[c("div",Ge,[c("div",qe,[c("h2",Pe,o(e.$t("seedream.name.model")),1),s(f,{content:e.$t("seedream.description.model"),class:"info"},null,8,["content"])])]),s(l,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=d=>e.value=d),class:"value",placeholder:e.$t("seedream.placeholder.select")},{default:_(()=>[(a(!0),i(w,null,I(e.options,d=>(a(),E(h,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const Oe=y(ze,[["render",je],["__scopeId","data-v-3c3ca27d"]]),Be=k({name:"SeedreamSizeSelector",components:{ElSelect:O,ElOption:j,InfoIcon:M},data(){return{options:[{value:U,label:U},{value:G,label:G},{value:q,label:q}]}},computed:{value:{get(){return this.$store.state.seedream?.config?.size},set(e){this.$store.commit("seedream/setConfig",{...this.$store.state.seedream?.config,size:e})}}},mounted(){this.value||(this.value=oe)}}),Fe={class:"field"},Ne={class:"label"},We={class:"box"},He={class:"title font-bold"};function Ke(e,t,g,r,m,p){const f=n("info-icon"),h=n("el-option"),l=n("el-select");return a(),i("div",Fe,[c("div",Ne,[c("div",We,[c("h2",He,o(e.$t("seedream.name.size")),1),s(f,{content:e.$t("seedream.description.size"),class:"info"},null,8,["content"])])]),s(l,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=d=>e.value=d),class:"value",placeholder:e.$t("seedream.placeholder.select"),filterable:"","allow-create":"","default-first-option":""},{default:_(()=>[(a(!0),i(w,null,I(e.options,d=>(a(),E(h,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])])}const Ze=y(Be,[["render",Ke],["__scopeId","data-v-54a9a469"]]),Je=k({name:"SeedreamConfigPanel",components:{ElButton:C,FontAwesomeIcon:A,PromptInput:Se,Consumption:re,ImageInput:De,ModelSelector:Oe,SizeSelector:Ze},emits:["generate"],computed:{config(){return this.$store.state.seedream?.config},consumption(){const e={...this.config||{}},t=Array.isArray(e?.image)&&e.image.length>0;return ce({...e,action:t?"edit":"generate",model:B(e?.model),count:1},this.service?.cost)},service(){return this.$store.state.seedream?.service}},methods:{onGenerate(){this.$emit("generate")}}}),Qe={class:"flex flex-col h-full"},Xe={class:"flex-1 overflow-y-auto p-5"},Ye={class:"flex flex-col items-center justify-center px-5 pb-5"};function xe(e,t,g,r,m,p){const f=n("model-selector"),h=n("size-selector"),l=n("prompt-input"),d=n("image-input"),b=n("consumption"),$=n("font-awesome-icon"),S=n("el-button");return a(),i("div",Qe,[c("div",Xe,[s(f,{class:"mb-4"}),s(h,{class:"mb-4"}),s(l,{class:"mb-4"}),s(d,{class:"mb-4"})]),c("div",Ye,[s(b,{value:e.consumption,service:e.service},null,8,["value","service"]),s(S,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:_(()=>[s($,{icon:"fa-solid fa-magic",class:"mr-2"}),u(" "+o(e.$t("seedream.button.generate")),1)]),_:1},8,["onClick"])])])}const es=y(Je,[["render",xe]]),ss=k({name:"SeedreamTaskPreview",components:{ElImage:J,CopyToClipboard:de,FontAwesomeIcon:A,ElAlert:Z,ImageWrapper:me,ElButton:C,ElTooltip:K,ImagePreview:F},props:{modelValue:{type:Object,required:!0}},computed:{isEdit(){return Array.isArray(this.modelValue?.request?.image)&&(this.modelValue?.request?.image?.length||0)>0},images(){const e=[];return Array.isArray(this.modelValue?.response?.data)&&this.modelValue?.response?.data?.forEach(t=>{e.push(t)}),e}},methods:{shortModel(e){return B(e)||e},onEdit(e){if(!e)return;console.debug("Edit image:",e);const t={...this.$store.state.seedream?.config||{}};t.image=[e],this.$store.commit("seedream/setConfig",t)}}}),ts={class:"preview"},os={class:"left"},as={class:"main"},ns={class:"bot"},ls={class:"datetime"},rs={class:"info"},is={key:0,class:"flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto"},cs={key:1,class:"prompt mt-2"},ds={key:0},ms={key:0,class:R({content:!0})},us={class:"text-[var(--el-text-color-regular)] text-xs mb-0"},ps={key:1,class:R({content:!0,failed:!0})},fs={class:"flex justify-start items-center gap-4 w-full overflow-x-auto"},hs={class:R({operations:!0,"mt-2":!0,"mb-2":!0})},_s={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},gs={key:1,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},$s={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},vs={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},bs={key:2,class:"text-[var(--el-text-color-regular)] text-xs mb-0"},ks={key:2,class:R({content:!0})},ys={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},ws={key:1,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Es={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Ss={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Vs={key:2,class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Is={key:3,class:"text-[var(--el-text-color-regular)] text-xs mb-0"},Ls={key:3,class:R({content:!0})},Rs={class:"text-[var(--el-text-color-regular)] text-xs mb-2"},Ts={key:0,class:"text-[var(--el-text-color-regular)] text-xs mb-0"};function As(e,t,g,r,m,p){const f=n("el-image"),h=n("image-preview"),l=n("font-awesome-icon"),d=n("copy-to-clipboard"),b=n("el-alert"),$=n("image-wrapper"),S=n("el-button"),z=n("el-tooltip");return a(),i("div",ts,[c("div",os,[s(f,{src:"https://cdn.acedata.cloud/9egrbn.png",class:"avatar"})]),c("div",as,[c("div",ns,[u(o(e.$t("seedream.name.seedreamBot"))+" ",1),c("span",ls,o(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),c("div",rs,[Array.isArray(e.modelValue?.request?.image)&&e.modelValue?.request?.image.length>0?(a(),i("div",is,[(a(!0),i(w,null,I(e.modelValue?.request?.image,(L,T)=>(a(),E(h,{key:T,url:L,name:`image-${T+1}`,closable:!1},null,8,["url","name"]))),128))])):v("",!0),e.modelValue?.request?.prompt?(a(),i("p",cs,[u(o(e.modelValue?.request?.prompt)+" ",1),e.modelValue?.response?v("",!0):(a(),i("span",ds," - ("+o(e.$t("seedream.status.pending"))+") ",1))])):v("",!0)]),e.modelValue?.response?e.modelValue?.response?.success===!0?(a(),i("div",ps,[c("div",fs,[(a(!0),i(w,null,I(e.images,(L,T)=>(a(),E($,{key:T,src:L?.image_url,"raw-src":L?.image_url},null,8,["src","raw-src"]))),128))]),c("div",hs,[s(z,{class:"box-item",effect:"dark",content:e.$t("common.button.edit"),placement:"top-start"},{default:_(()=>[s(S,{type:"info",size:"small",class:"btn-action",onClick:t[0]||(t[0]=Q(L=>e.onEdit(e.images?.[0]?.image_url),["stop"]))},{default:_(()=>[u(o(e.$t("common.button.edit")),1)]),_:1})]),_:1},8,["content"])]),s(b,{closable:!1,class:"mt-2 success"},{default:_(()=>[e.modelValue?.request?.model?(a(),i("p",_s,[s(l,{icon:"fa-solid fa-cube",class:"mr-1"}),u(" "+o(e.$t("seedream.name.model"))+": "+o(e.shortModel(e.modelValue?.request?.model)),1)])):v("",!0),e.modelValue?.request?.size?(a(),i("p",gs,[s(l,{icon:"fa-solid fa-image",class:"mr-1"}),u(" "+o(e.$t("seedream.name.size"))+": "+o(e.modelValue?.request?.size),1)])):v("",!0),c("p",$s,[s(l,{icon:"fa-solid fa-bolt",class:"mr-1"}),u(" "+o(e.$t("seedream.name.task"))+": "+o(e.isEdit?e.$t("seedream.name.edits"):e.$t("seedream.name.generate")),1)]),c("p",vs,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy inline-block"},null,8,["content"])]),e.modelValue?.response?.trace_id?(a(),i("p",bs,[s(l,{icon:"fa-solid fa-hashtag",class:"mr-1"}),u(" "+o(e.$t("seedream.name.traceId"))+": "+o(e.modelValue?.response?.trace_id)+" ",1),s(d,{content:e.modelValue?.response?.trace_id,class:"btn-copy inline-block"},null,8,["content"])])):v("",!0)]),_:1})])):e.modelValue?.response?.success===!1?(a(),i("div",ks,[s(b,{closable:!1,class:"failure"},{template:_(()=>[s(l,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),u(" "+o(e.$t("seedream.name.failure")),1)]),default:_(()=>[e.modelValue?.request?.model?(a(),i("p",ys,[s(l,{icon:"fa-solid fa-cube",class:"mr-1"}),u(" "+o(e.$t("seedream.name.model"))+": "+o(e.shortModel(e.modelValue?.request?.model)),1)])):v("",!0),e.modelValue?.request?.size?(a(),i("p",ws,[s(l,{icon:"fa-solid fa-image",class:"mr-1"}),u(" "+o(e.$t("seedream.name.size"))+": "+o(e.modelValue?.request?.size),1)])):v("",!0),c("p",Es,[s(l,{icon:"fa-solid fa-bolt",class:"mr-1"}),u(" "+o(e.$t("seedream.name.task"))+": "+o(e.isEdit?e.$t("seedream.name.edits"):e.$t("seedream.name.generate")),1)]),c("p",Ss,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),e.modelValue?.response?.error?.message?(a(),i("p",Vs,[s(l,{icon:"fa-solid fa-circle-info",class:"mr-1"}),u(" "+o(e.$t("seedream.name.failureReason"))+": "+o(e.modelValue?.response?.error?.message)+" ",1),s(d,{content:e.modelValue?.response?.error?.message,class:"btn-copy"},null,8,["content"])])):v("",!0),e.modelValue?.response?.trace_id?(a(),i("p",Is,[s(l,{icon:"fa-solid fa-hashtag",class:"mr-1"}),u(" "+o(e.$t("seedream.name.traceId"))+": "+o(e.modelValue?.response?.trace_id)+" ",1),s(d,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])):v("",!0)]),_:1})])):(a(),i("div",Ls,[s(b,{closable:!1,class:"info"},{template:_(()=>[s(l,{icon:"fa-solid fa-circle-info",class:"mr-1"}),u(" "+o(e.$t("seedream.name.status")),1)]),default:_(()=>[c("p",Rs,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),e.modelValue?.response?.trace_id?(a(),i("p",Ts,[s(l,{icon:"fa-solid fa-hashtag",class:"mr-1"}),u(" "+o(e.$t("seedream.name.traceId"))+": "+o(e.modelValue?.response?.trace_id)+" ",1),s(d,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])):v("",!0)]),_:1})])):(a(),i("div",ms,[s(b,{closable:!1,class:"info"},{template:_(()=>[s(l,{icon:"fa-regular fa-clock",class:"mr-1"}),u(" "+o(e.$t("seedream.status.pending")),1)]),default:_(()=>[c("p",us,[s(l,{icon:"fa-solid fa-magic",class:"mr-1"}),u(" "+o(e.$t("seedream.name.taskId"))+": "+o(e.modelValue?.id)+" ",1),s(d,{content:e.modelValue?.id,class:"btn-copy inline-block"},null,8,["content"])])]),_:1})]))])])}const Cs=y(ss,[["render",As],["__scopeId","data-v-20c93f4e"]]),Ms=k({name:"SeedreamRecentPanel",components:{TaskPreview:Cs,BotPlaceholder:ue,NoTasks:ie,ScrollList:le},props:{loading:{type:Boolean,default:!1}},emits:["reach-top"],computed:{tasks(){return{...this.$store.state.seedream?.tasks,items:this.$store.state.seedream?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Ds={key:0},zs={key:2,class:"w-full h-full flex items-center justify-center"};function Us(e,t,g,r,m,p){const f=n("bot-placeholder"),h=n("task-preview"),l=n("scroll-list"),d=n("no-tasks");return a(),i(w,null,[e.tasks?.items===void 0?(a(),i("div",Ds,[s(f)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(a(),E(l,{key:1,ref:"scrollList",class:"tasks h-full w-full overflow-y-auto",loading:e.loading,onReachTop:t[0]||(t[0]=b=>e.$emit("reach-top"))},{default:_(()=>[(a(!0),i(w,null,I(e.tasks?.items,b=>(a(),E(h,{key:b.id,"model-value":b},null,8,["model-value"]))),128))]),_:1},8,["loading"])):v("",!0),e.tasks?.items?.length===0?(a(),i("div",zs,[s(d)])):v("",!0)],64)}const Gs=y(Ms,[["render",Us]]),qs="https://webhook.acedata.cloud/seedream",Ps=k({name:"SeedreamIndex",components:{ConfigPanel:es,Layout:$e,RecentPanel:Gs},inject:["initialized"],data(){return{task:void 0,job:0,loading:!1}},computed:{applicationsLoading(){return this.$store.state.seedream?.status?.getApplications===P.Request},tasksLoading(){return this.$store.state.seedream?.status?.getTasks===P.Request},credential(){return this.$store.state.seedream?.credential},config(){return this.$store.state.seedream?.config},application(){return this.$store.state.seedream?.application},tasks(){return this.$store.state.seedream?.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){if(console.debug("reached top"),this.loading||this.tasksLoading)return;const e=this.tasks?.total,t=this.tasks?.items?.length||0;if(e!==void 0&&e<=t)return;const g=this.tasks?.items?.[0];if(!g?.created_at)return;const m=this.$refs.recentPanel?.getScrollElement?.(),p=m?.scrollHeight||0,f=m?.scrollTop||0;this.loading=!0;try{if(await this.onGetTasks({createdAtMax:g.created_at}),await this.$nextTick(),m){const h=m.scrollHeight;m.scrollTop=h-p+f}}finally{this.loading=!1}},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("seedream/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("seedream/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},async onScrollDown(){await this.$nextTick();const e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.tasksLoading){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=20,createdAtMin:g,createdAtMax:r}=e||{};console.debug("limit",t,"createdAtMin",g,"createdAtMax",r),await this.$store.dispatch("seedream/getTasks",{limit:t,createdAtMin:g,createdAtMax:r})},async onGenerate(){const e={...this.config||{}};!(Array.isArray(e?.image)&&e.image.length>0)&&"image"in e&&delete e.image,e?.size||delete e.size;const g={...e,callback_url:qs},r=this.credential?.token;if(!r){console.error("no token specified");return}V.info(this.$t("seedream.message.startingTask")),ae.generate(g,{token:r}).then(()=>{V.success(this.$t("seedream.message.startTaskSuccess"))}).catch(m=>{const p=m?.response?.data;p?.error?.code===ne?V.error(this.$t("seedream.message.usedUp")):V.error(this.$t("seedream.message.startTaskFailed")+(p?.error?.message||""))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function js(e,t,g,r,m,p){const f=n("config-panel"),h=n("recent-panel"),l=n("layout");return a(),E(l,null,{config:_(()=>[s(f,{onGenerate:e.onGenerate},null,8,["onGenerate"])]),result:_(()=>[s(h,{ref:"recentPanel",loading:e.loading,onReachTop:e.onReachTop},null,8,["loading","onReachTop"])]),_:1})}const tt=y(Ps,[["render",js]]);export{tt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.menu[data-v-c6c85757]{display:none}@media (max-width: 767px){.main .config[data-v-c6c85757]{display:none}.main .result[data-v-c6c85757]{width:100%}.main .preview[data-v-c6c85757]{display:none}.main .menu[data-v-c6c85757]{display:block;position:absolute;right:8px;top:45px;z-index:1000}}.title[data-v-6236152c]{font-size:14px;margin-bottom:0;width:30%}.btn.btn-upload[data-v-6236152c]{position:absolute;top:5px;right:0}.upload-wrapper{height:auto;display:flex}.upload-wrapper .el-upload-list{margin:0;width:100%}.field[data-v-210d2670] .el-textarea__inner{font-family:monospace;line-height:1.6}.field .box[data-v-bcce4821]{display:flex;flex-direction:row;align-items:center;justify-content:space-between;position:relative;margin-bottom:10px}.field .box .title[data-v-bcce4821]{font-size:14px;margin-bottom:10px}.field .box .input-wrapper[data-v-bcce4821]{width:150px;margin-left:30px}.field .box[data-v-06640216]{display:flex;flex-direction:row;align-items:center;justify-content:space-between;position:relative;margin-bottom:10px}.field .box .title[data-v-06640216]{font-size:14px;margin-bottom:10px}.field .box .input-wrapper[data-v-06640216]{width:150px;margin-left:30px}.advanced-collapse[data-v-be135363]{border:none}.advanced-collapse[data-v-be135363] .el-collapse-item__header{font-size:14px;font-weight:700;background:transparent;border:none;height:32px;line-height:32px}.advanced-collapse[data-v-be135363] .el-collapse-item__wrap{background:transparent;border:none}.advanced-collapse[data-v-be135363] .el-collapse-item__content{padding-bottom:0}.panel[data-v-a4cbdb91]{height:100%;padding:20px;display:flex;flex-direction:column}.panel .config[data-v-a4cbdb91]{width:100%;height:calc(100% - 50px);flex:1;position:relative}.panel .actions[data-v-a4cbdb91]{height:50px;display:flex;justify-content:center;align-items:center}.panel .actions .btn[data-v-a4cbdb91]{width:100%}.task{display:flex;flex-direction:column;cursor:pointer}.task .audio{display:flex;margin-bottom:10px;border-radius:10px}.task .audio:hover{background-color:var(--el-bg-color-page)}.task .audio .left{position:relative;width:60px;height:60px;margin-right:16px;flex-shrink:0}.task .audio .left:hover .overlay{display:block}.task .audio .left .cover{width:100%;height:100%;border-radius:4px}.task .audio .left .duration{position:absolute;right:0;bottom:0;background-color:#000000b3;padding:2px 4px;color:#fff;border-radius:2px;font-size:10px}.task .audio .left .overlay{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;display:none;transition:opacity .3s;border-radius:4px;text-align:center;line-height:70px;cursor:pointer}.task .audio .left .overlay .el-icon{font-size:20px;color:#fff}.task .audio .info{flex:1}.task .audio .info .title{font-size:14px;font-weight:700;margin-top:5px}.task .audio .info .style{font-size:12px;margin-bottom:0;color:var(--el-text-color-secondary)}.task .audio .right{width:120px;display:flex;align-items:center;justify-content:flex-end;padding-right:1px}.task .audio .right .icon{display:block;z-index:100;cursor:pointer;margin-right:15px}.task .audio .right .el-button{margin-right:15px}.player-slider .el-slider{height:10px}.player-slider .el-slider .el-slider__runway,.player-slider .el-slider .el-slider__bar{height:2px;border-radius:0}.player-slider .el-slider .el-slider__button-wrapper{width:10px;height:10px;top:-10.5px}.player-slider .el-slider .el-slider__button{width:8px;height:8px}.el-popover.el-popper{min-width:auto}.status[data-v-d1296b1a]{margin-bottom:10px}.panel.detail[data-v-d1296b1a]{width:100%;flex:1;overflow-y:scroll}.panel.recent[data-v-d1296b1a]{height:100%;width:100%;margin-bottom:10px;position:relative;justify-content:initial}.panel.operation[data-v-d1296b1a]{position:relative}
|
|
1
|
+
.menu[data-v-c6c85757]{display:none}@media (max-width: 767px){.main .config[data-v-c6c85757]{display:none}.main .result[data-v-c6c85757]{width:100%}.main .preview[data-v-c6c85757]{display:none}.main .menu[data-v-c6c85757]{display:block;position:absolute;right:8px;top:45px;z-index:1000}}.title[data-v-6236152c]{font-size:14px;margin-bottom:0;width:30%}.btn.btn-upload[data-v-6236152c]{position:absolute;top:5px;right:0}.upload-wrapper{height:auto;display:flex}.upload-wrapper .el-upload-list{margin:0;width:100%}.field[data-v-210d2670] .el-textarea__inner{font-family:monospace;line-height:1.6}.field .box[data-v-bcce4821]{display:flex;flex-direction:row;align-items:center;justify-content:space-between;position:relative;margin-bottom:10px}.field .box .title[data-v-bcce4821]{font-size:14px;margin-bottom:10px}.field .box .input-wrapper[data-v-bcce4821]{width:150px;margin-left:30px}.field .box[data-v-06640216]{display:flex;flex-direction:row;align-items:center;justify-content:space-between;position:relative;margin-bottom:10px}.field .box .title[data-v-06640216]{font-size:14px;margin-bottom:10px}.field .box .input-wrapper[data-v-06640216]{width:150px;margin-left:30px}.advanced-collapse[data-v-be135363]{border:none}.advanced-collapse[data-v-be135363] .el-collapse-item__header{font-size:14px;font-weight:700;background:transparent;border:none;height:32px;line-height:32px}.advanced-collapse[data-v-be135363] .el-collapse-item__wrap{background:transparent;border:none}.advanced-collapse[data-v-be135363] .el-collapse-item__content{padding-bottom:0}.panel[data-v-a4cbdb91]{height:100%;padding:20px;display:flex;flex-direction:column}.panel .config[data-v-a4cbdb91]{width:100%;height:calc(100% - 50px);flex:1;position:relative}.panel .actions[data-v-a4cbdb91]{height:50px;display:flex;justify-content:center;align-items:center}.panel .actions .btn[data-v-a4cbdb91]{width:100%}.task{display:flex;flex-direction:column;cursor:pointer}.task .audio{display:flex;margin-bottom:10px;border-radius:10px}.task .audio:hover{background-color:var(--el-bg-color-page)}.task .audio .left{position:relative;width:60px;height:60px;margin-right:16px;flex-shrink:0}.task .audio .left:hover .overlay{display:block}.task .audio .left .cover{width:100%;height:100%;border-radius:4px}.task .audio .left .duration{position:absolute;right:0;bottom:0;background-color:#000000b3;padding:2px 4px;color:#fff;border-radius:2px;font-size:10px}.task .audio .left .overlay{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;display:none;transition:opacity .3s;border-radius:4px;text-align:center;line-height:70px;cursor:pointer}.task .audio .left .overlay .el-icon{font-size:20px;color:#fff}.task .audio .info{flex:1;min-width:0;overflow:hidden}.task .audio .info .title{font-size:14px;font-weight:700;margin-top:5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.task .audio .info .style{font-size:12px;margin-bottom:0;color:var(--el-text-color-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.task .audio .right{width:120px;display:flex;align-items:center;justify-content:flex-end;padding-right:1px}.task .audio .right .icon{display:block;z-index:100;cursor:pointer;margin-right:15px}.task .audio .right .el-button{margin-right:15px}.player-slider .el-slider{height:10px}.player-slider .el-slider .el-slider__runway,.player-slider .el-slider .el-slider__bar{height:2px;border-radius:0}.player-slider .el-slider .el-slider__button-wrapper{width:10px;height:10px;top:-10.5px}.player-slider .el-slider .el-slider__button{width:8px;height:8px}.el-popover.el-popper{min-width:auto}.status[data-v-d1296b1a]{margin-bottom:10px}.panel.detail[data-v-d1296b1a]{width:100%;flex:1;overflow-y:scroll}.panel.recent[data-v-d1296b1a]{height:100%;width:100%;margin-bottom:10px;position:relative;justify-content:initial}.panel.operation[data-v-d1296b1a]{position:relative}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as C}from"./index.es-CQANB9vJ.js";import{l as A,S as L,t as U,u as w,F as D,D as j,j as P,W as z,X as B,G as M,Y as O,K as q}from"./vendor-element-plus-B4FTqxj4.js";import{d as v,C as l,G as r,T as s,E as R,K as d,ai as o,D as a,R as i,Q as _,S as T,ag as I,J as S,M as V,c as F,O as $}from"./vendor-vue-1w_NBnjl.js";import{_ as b,aj as N,c3 as H,aB as K,ar as J,ax as Q,ay as E}from"./index-DgtHfSqf.js";import{I as W,S as X}from"./ScrollList-BSHydg5K.js";import{I as Y}from"./ImagePreview-Dif2Q49Y.js";import{A as Z}from"./Status-CU3tRVGG.js";import{C as x}from"./CopyToClipboard-BGClcrVG.js";import{l as ee}from"./pagination-CihAE3FS.js";import"./vendor-dayjs-CzbnksQQ.js";import"./vendor-web3-BXoVw72d.js";import"./vendor-axios-NIGUFBhG.js";import"./vendor-vue-router-Dj5bcX0v.js";const se=v({name:"LayoutHeadshots",components:{ElDrawer:L,ElButton:A,FontAwesomeIcon:C},data(){return{drawer:!1}}}),te={class:"main flex flex-row flex-1"},ae={class:"config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]"},oe={class:"result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]"};function ne(e,t,m,h,k,y){const p=o("font-awesome-icon"),u=o("el-button"),n=o("el-drawer");return a(),l("div",te,[r("div",ae,[R(e.$slots,"config",{},void 0,!0)]),r("div",oe,[R(e.$slots,"result",{},void 0,!0)]),s(u,{circle:"",class:"menu",onClick:t[0]||(t[0]=c=>e.drawer=!0)},{default:d(()=>[s(p,{icon:"fa-solid fa-gear"})]),_:1}),s(n,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=c=>e.drawer=c),"with-header":!1,size:"340px",class:"drawer"},{default:d(()=>[R(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const ie=b(se,[["render",ne],["__scopeId","data-v-202b355b"]]),le=v({name:"ImageUrlsInput",components:{ElUpload:U,ElButton:A,InfoIcon:W,ImagePreview:Y,FontAwesomeIcon:C},data(){return{fileList:[],uploadUrl:N()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.headshots?.config?.image_urls},set(){const e=this.urls;this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,image_urls:e})}}},mounted(){this.value||(this.value=void 0),this.onSetImageUrls()},methods:{onExceed(){w.warning(this.$t("headshots.message.uploadImageExceed"))},onError(){w.error(this.$t("headshots.message.uploadImageError"))},onSetImageUrls(){const e=this.urls;this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,image_urls:e})},async onSuccess(){this.onSetImageUrls()}}}),re={class:"field"},ce={class:"title font-bold"},de={class:"upload-wrapper"};function pe(e,t,m,h,k,y){const p=o("image-preview"),u=o("font-awesome-icon"),n=o("el-button"),c=o("el-upload"),g=o("info-icon");return a(),l("div",re,[r("h2",ce,i(e.$t("headshots.name.endImageUrls")),1),r("div",de,[s(c,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=f=>e.fileList=f),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file",class:"value upload-wrapper",limit:2,multiple:!0,"list-type":"picture",action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{file:d(({file:f})=>[s(p,{url:f.url||f.response?.file_url,name:f.name,percentage:f.percentage,onRemove:G=>e.fileList.splice(e.fileList.indexOf(f),1)},null,8,["url","name","percentage","onRemove"])]),default:d(()=>[s(n,{size:"small",type:"primary",round:""},{default:d(()=>[s(u,{icon:"fa-solid fa-upload",class:"mr-1"}),_(" "+i(e.$t("headshots.button.uploadImageUrls")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","headers"])]),s(g,{content:e.$t("headshots.description.endImageUrls"),class:"info"},null,8,["content"])])}const me=b(le,[["render",pe],["__scopeId","data-v-1690629a"]]),he="fast",ue=v({name:"ModeSelector",components:{ElRadioButton:j,ElRadioGroup:D},data(){return{options:[{label:this.$t("headshots.button.fast"),value:"fast"},{label:this.$t("headshots.button.relax"),value:"relax"}]}},computed:{value:{get(){return this.$store.state.headshots.config?.mode},set(e){console.debug("set mode",e),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots.config,mode:e})}}},mounted(){this.value||(this.value=he)}}),ge={class:"field"},fe={class:"title font-bold"};function _e(e,t,m,h,k,y){const p=o("el-radio-button"),u=o("el-radio-group");return a(),l("div",ge,[r("h2",fe,i(e.$t("headshots.name.mode")),1),s(u,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=n=>e.value=n),size:"small",class:"mode"},{default:d(()=>[(a(!0),l(T,null,I(e.options,n=>(a(),S(p,{key:n.value,label:n.value},{default:d(()=>[_(i(n.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])])}const $e=b(ue,[["render",_e],["__scopeId","data-v-a2a0d5fa"]]),ve=v({name:"StylizeSelector",components:{ElTabs:B,ElTabPane:z,ElImage:P},data(){return{tab:"styles",value:"",elements:{styles:{displayName:this.$t("headshots.styleCategory.styles"),items:[{image:"https://static.aipedias.com/aicamera/common/20241008/20241008202314260779439.png",label:this.$t("headshots.styleTag.malePportrait"),value:"male_portrait"},{image:"https://static.aipedias.com/aicamera/common/20241008/202410082022241e9755548.png",label:this.$t("headshots.styleTag.malePportrait2"),value:"male_portrait2"},{image:"https://static.aipedias.com/aicamera/common/20241101/20241101170130d78f66521.png",label:this.$t("headshots.styleTag.kindergarten"),value:"kindergarten"},{image:"https://static.aipedias.com/aicamera/common/20240923/20240923123233accf60398.webp",label:this.$t("headshots.styleTag.logoTshirt"),value:"logo_tshirt"},{image:"https://static.aipedias.com/aicamera/common/20241025/202410252012329472d0656.jpg",label:this.$t("headshots.styleTag.wedding"),value:"wedding"},{image:"https://static.aipedias.com/aicamera/common/20240915/20240915145045254931400.webp",label:this.$t("headshots.styleTag.businessPphoto"),value:"business_photo"},{image:"https://static.aipedias.com/aicamera/common/20240810/20240810194526040341795.jpg",label:this.$t("headshots.styleTag.bobSuit"),value:"bob_suit"},{image:"https://static.aipedias.com/aicamera/common/20240717/20240717152654e0b348173.webp",label:this.$t("headshots.styleTag.femalePortrait"),value:"female_portrait"}]}}}},watch:{value(e){console.debug("set template",e),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,template:e})}},mounted(){this.value||(this.value=""),console.debug("set template",this.value),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,template:this.value})},methods:{onToggle(e){this.value===e?this.value="":this.value=e,console.debug("set template",this.value),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,template:this.value})}}}),be={class:"field"},ke=["onClick"],ye={class:"name"};function we(e,t,m,h,k,y){const p=o("el-image"),u=o("el-tab-pane"),n=o("el-tabs");return a(),l("div",be,[s(n,{modelValue:e.tab,"onUpdate:modelValue":t[0]||(t[0]=c=>e.tab=c)},{default:d(()=>[(a(!0),l(T,null,I(e.elements,(c,g)=>(a(),S(u,{key:g,label:c.displayName,name:g,class:"pane"},{default:d(()=>[(a(!0),l(T,null,I(c.items,(f,G)=>(a(),l("div",{key:G,class:V({item:!0,active:e.value===f.value}),onClick:_s=>e.onToggle(f.value)},[s(p,{src:f.image,fit:"fill",class:"preview"},null,8,["src"]),r("span",ye,i(f.label),1)],10,ke))),128))]),_:2},1032,["label","name"]))),128))]),_:1},8,["modelValue"])])}const Te=b(ve,[["render",we],["__scopeId","data-v-be4bd25d"]]),Ie=v({name:"PresetPanel",components:{ModeSelector:$e,ImageUrlsInput:me,ElButton:A,FontAwesomeIcon:C,ElementsSelector:Te},emits:["generate"],computed:{config(){return this.$store.state.headshots?.config}},methods:{onGenerate(){this.$emit("generate")}}}),Se={class:"panel"},Ve={class:"config"},Ee={class:"actions"};function Ce(e,t,m,h,k,y){const p=o("elements-selector"),u=o("mode-selector"),n=o("image-urls-input"),c=o("font-awesome-icon"),g=o("el-button");return a(),l("div",Se,[r("div",Ve,[s(p,{class:"mb-4"}),s(u,{class:"mb-4"}),s(n,{class:"mb-4"}),r("div",Ee,[s(g,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:d(()=>[s(c,{icon:"fa-solid fa-magic",class:"mr-2"}),_(" "+i(e.$t("headshots.button.generate")),1)]),_:1},8,["onClick"])])])])}const Re=b(Ie,[["render",Ce],["__scopeId","data-v-848739f6"]]),Ae=v({name:"ImageGallery",props:{modelValue:{type:Object,required:!0}},setup(e){return{images:F(()=>e.modelValue?.response?.data?.slice(0,2)||[]),viewImage:h=>{window.open(h,"_blank")}}}}),Ge={class:"image-gallery"},Pe=["src"],Le=["onClick"];function Ue(e,t,m,h,k,y){return a(),l("div",Ge,[(a(!0),l(T,null,I(e.images,(p,u)=>(a(),l("div",{key:u,class:"image-container"},[r("img",{src:p.image_url,alt:"Image"},null,8,Pe),p.image_url?(a(),l("button",{key:0,class:"view-button",onClick:n=>e.viewImage(p.image_url)},i(e.$t("headshots.button.viewImage")),9,Le)):$("",!0)]))),128))])}const De=b(Ae,[["render",Ue],["__scopeId","data-v-42f0a7be"]]),je=v({name:"TaskPreview",components:{ElImage:P,CopyToClipboard:x,FontAwesomeIcon:C,ElAlert:M,ImageGallery:De},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.headshots?.application},config(){return this.$store.state.headshots?.config}},methods:{onDownload(e,t){e.stopPropagation(),console.log("on download"),window.open(t,"_blank")},onReload(e){const t=e.target,m=new URL(t.src),h=m.searchParams.get("retry");if(!h)m.searchParams.set("retry","1");else if(parseInt(h)<2)m.searchParams.set("retry",(parseInt(h)+1).toString());else return;t.src=m.toString()},onOpenVideo(e){window.open(e,"_blank")}}}),ze={class:"preview"},Be={class:"left"},Me={class:"main"},Oe={class:"bot"},qe={class:"datetime"},Fe={class:"info"},Ne={key:0,class:"prompt mt-2"},He={key:0},Ke={key:1},Je={key:0,class:V({content:!0,failed:!0})},Qe={class:"image-wrapper"},We={class:"description"},Xe={key:1,class:V({content:!0})},Ye={class:"description"},Ze={class:"description"},xe={class:"description"},es={key:2,class:V({content:!0})},ss={class:"description"},ts={key:3,class:V({content:!0})},as={class:"description"};function os(e,t,m,h,k,y){const p=o("el-image"),u=o("image-gallery"),n=o("font-awesome-icon"),c=o("copy-to-clipboard"),g=o("el-alert");return a(),l("div",ze,[r("div",Be,[s(p,{src:"https://cdn.acedata.cloud/isxyfw.png",class:"avatar"})]),r("div",Me,[r("div",Oe,[_(i(e.$t("headshots.name.headshotsBot"))+" ",1),r("span",qe,i(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),r("div",Fe,[e.modelValue?.request?.template?(a(),l("p",Ne,[_(i(e.modelValue?.request?.template)+" ",1),e.modelValue?.response?$("",!0):(a(),l("span",He," - ("+i(e.$t("headshots.status.pending"))+") ",1)),e.modelValue?.response?.status==="unknown"?(a(),l("span",Ke," - ("+i(e.$t("headshots.status.processing"))+") ",1)):$("",!0)])):$("",!0)]),e.modelValue?.response?.success===!0?(a(),l("div",Je,[r("div",Qe,[s(u,{"model-value":e.modelValue},null,8,["model-value"])]),s(g,{closable:!1,class:"mt-2 success"},{default:d(()=>[r("p",We,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),e.modelValue?.response?.success===!1?(a(),l("div",Xe,[s(g,{closable:!1,class:"failure"},{template:d(()=>[s(n,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failure")),1)]),default:d(()=>[r("p",Ye,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),r("p",Ze,[s(n,{icon:"fa-solid fa-circle-info",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failureReason"))+": "+i(e.modelValue?.response?.error?.message)+" ",1),s(c,{content:e.modelValue?.response?.error?.message,class:"btn-copy"},null,8,["content"])]),r("p",xe,[s(n,{icon:"fa-solid fa-hashtag",class:"mr-1"}),_(" "+i(e.$t("headshots.name.traceId"))+": "+i(e.modelValue?.response?.trace_id)+" ",1),s(c,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),e.modelValue?.response?$("",!0):(a(),l("div",es,[s(g,{closable:!1,class:"info"},{template:d(()=>[s(n,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failure")),1)]),default:d(()=>[r("p",ss,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])),e.modelValue?.response?.status==="unknown"?(a(),l("div",ts,[s(g,{closable:!1,class:"info"},{template:d(()=>[s(n,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failure")),1)]),default:d(()=>[r("p",as,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0)])])}const ns=b(je,[["render",os],["__scopeId","data-v-d1196e0c"]]),is=v({name:"RecentPanel",components:{TaskPreview:ns,ElSkeleton:q,ElSkeletonItem:O,ScrollList:X},props:{loading:{type:Boolean,default:!1}},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.headshots?.tasks,items:this.$store.state.headshots?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),ls={key:0,class:"tasks"},rs={class:"left"},cs={class:"main"},ds={key:1,class:"tasks"},ps={key:2,class:"description"};function ms(e,t,m,h,k,y){const p=o("el-skeleton-item"),u=o("el-skeleton"),n=o("task-preview"),c=o("scroll-list");return a(),S(c,{ref:"scrollList",class:"panel recent",loading:e.loading,onReachTop:t[0]||(t[0]=g=>e.$emit("reach-top"))},{default:d(()=>[e.tasks?.items===void 0?(a(),l("div",ls,[(a(),l(T,null,I(3,g=>r("div",{key:g,class:"task placeholder"},[r("div",rs,[s(u,{animated:""},{template:d(()=>[s(p,{variant:"image",class:"avatar"})]),_:1})]),r("div",cs,[s(u,{animated:""},{template:d(()=>[s(p,{variant:"p",class:"title"}),s(p,{variant:"image",class:"icon"})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(a(),l("div",ds,[(a(!0),l(T,null,I(e.tasks?.items,(g,f)=>(a(),S(n,{key:f,"model-value":g,class:"preview"},null,8,["model-value"]))),128))])):$("",!0),e.tasks?.items?.length===0?(a(),l("p",ps,i(e.$t("headshots.message.noTasks")),1)):$("",!0)]),_:1},8,["loading"])}const hs=b(is,[["render",ms],["__scopeId","data-v-ffd55c16"]]),us="https://webhook.acedata.cloud/headshots",gs=v({name:"HeadshotsIndex",components:{ConfigPanel:Re,Layout:ie,ApplicationStatus:Z,RecentPanel:hs},inject:["initialized"],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.headshots?.status?.getApplications===E.Request},tasksLoading(){return this.$store.state.headshots?.status?.getTasks===E.Request||this.fetchingTasks},service(){return this.$store.state.headshots.service},credential(){return this.$store.state.headshots.credential},config(){return this.$store.state.headshots.config},initializing(){return this.$store.state.headshots.status.getApplications===E.Request},needApply(){return this.$store.state.headshots.status.getApplications===E.Success&&!this.application},application(){return this.$store.state.headshots.application},applications(){return this.$store.state.headshots.applications},tasks(){return this.$store.state.headshots.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await ee({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("headshots/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("headshots/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},onApply(){J.create({application:this.application}).then(({data:e})=>{this.application=e,w.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===Q&&w.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){await this.$nextTick();const e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=5,createdAtMin:m,createdAtMax:h}=e||{};console.debug("limit",t,"createdAtMin",m,"createdAtMax",h),this.fetchingTasks=!0;try{await this.$store.dispatch("headshots/getTasks",{limit:t,createdAtMin:m,createdAtMax:h})}finally{this.fetchingTasks=!1}},async onGeneratePicture(){const e={...this.config,callback_url:us},t=this.credential?.token;if(!t){console.error("no token specified");return}w.info(this.$t("headshots.message.startingTask")),H.generate(e,{token:t}).then(()=>{w.success(this.$t("headshots.message.startTaskSuccess")),this.$store.commit("headshots/setConfig",{config:void 0})}).catch(m=>{m?.response?.data?.error?.code===K?w.error(this.$t("headshots.message.usedUp")):w.error(this.$t("headshots.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function fs(e,t,m,h,k,y){const p=o("config-panel"),u=o("application-status"),n=o("recent-panel"),c=o("layout");return a(),S(c,null,{config:d(()=>[s(p,{onGenerate:e.onGeneratePicture},null,8,["onGenerate"])]),result:d(()=>[s(u,{initializing:e.initializing,application:e.application,applications:e.applications,service:e.service,"need-apply":e.needApply,class:"mb-4",onRefresh:e.onGetApplication,onSelect:t[0]||(t[0]=g=>e.$store.dispatch("headshots/setApplication",g))},null,8,["initializing","application","applications","service","need-apply","onRefresh"]),s(n,{ref:"recentPanel",class:"panel recent",loading:e.loadingMore,onReachTop:e.onReachTop},null,8,["loading","onReachTop"])]),_:1})}const As=b(gs,[["render",fs],["__scopeId","data-v-6cafffbd"]]);export{As as default};
|
|
1
|
+
import{F as C}from"./index.es-sibb1JwV.js";import{l as A,S as L,t as U,u as w,F as D,D as j,j as P,W as z,X as B,G as M,Y as O,K as q}from"./vendor-element-plus-B4FTqxj4.js";import{d as v,C as l,G as r,T as s,E as R,K as d,ai as o,D as a,R as i,Q as _,S as T,ag as I,J as S,M as V,c as F,O as $}from"./vendor-vue-1w_NBnjl.js";import{_ as b,aj as N,c3 as H,aB as K,ar as J,ax as Q,ay as E}from"./index-Cg8W5HXP.js";import{I as W,S as X}from"./ScrollList-Ctwoso0M.js";import{I as Y}from"./ImagePreview-Dl9A5DPA.js";import{A as Z}from"./Status-zVvonX-o.js";import{C as x}from"./CopyToClipboard-D0zLUUky.js";import{l as ee}from"./pagination-CihAE3FS.js";import"./vendor-dayjs-CzbnksQQ.js";import"./vendor-web3-vJ0jlMeb.js";import"./vendor-axios-NIGUFBhG.js";import"./vendor-vue-router-Dj5bcX0v.js";const se=v({name:"LayoutHeadshots",components:{ElDrawer:L,ElButton:A,FontAwesomeIcon:C},data(){return{drawer:!1}}}),te={class:"main flex flex-row flex-1"},ae={class:"config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]"},oe={class:"result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]"};function ne(e,t,m,h,k,y){const p=o("font-awesome-icon"),u=o("el-button"),n=o("el-drawer");return a(),l("div",te,[r("div",ae,[R(e.$slots,"config",{},void 0,!0)]),r("div",oe,[R(e.$slots,"result",{},void 0,!0)]),s(u,{circle:"",class:"menu",onClick:t[0]||(t[0]=c=>e.drawer=!0)},{default:d(()=>[s(p,{icon:"fa-solid fa-gear"})]),_:1}),s(n,{modelValue:e.drawer,"onUpdate:modelValue":t[1]||(t[1]=c=>e.drawer=c),"with-header":!1,size:"340px",class:"drawer"},{default:d(()=>[R(e.$slots,"config",{},void 0,!0)]),_:3},8,["modelValue"])])}const ie=b(se,[["render",ne],["__scopeId","data-v-202b355b"]]),le=v({name:"ImageUrlsInput",components:{ElUpload:U,ElButton:A,InfoIcon:W,ImagePreview:Y,FontAwesomeIcon:C},data(){return{fileList:[],uploadUrl:N()+"/api/v1/files/"}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state.headshots?.config?.image_urls},set(){const e=this.urls;this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,image_urls:e})}}},mounted(){this.value||(this.value=void 0),this.onSetImageUrls()},methods:{onExceed(){w.warning(this.$t("headshots.message.uploadImageExceed"))},onError(){w.error(this.$t("headshots.message.uploadImageError"))},onSetImageUrls(){const e=this.urls;this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,image_urls:e})},async onSuccess(){this.onSetImageUrls()}}}),re={class:"field"},ce={class:"title font-bold"},de={class:"upload-wrapper"};function pe(e,t,m,h,k,y){const p=o("image-preview"),u=o("font-awesome-icon"),n=o("el-button"),c=o("el-upload"),g=o("info-icon");return a(),l("div",re,[r("h2",ce,i(e.$t("headshots.name.endImageUrls")),1),r("div",de,[s(c,{"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=f=>e.fileList=f),accept:".png,.jpg,.jpeg,.gif,.bmp,.webp",name:"file",class:"value upload-wrapper",limit:2,multiple:!0,"list-type":"picture",action:e.uploadUrl,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{file:d(({file:f})=>[s(p,{url:f.url||f.response?.file_url,name:f.name,percentage:f.percentage,onRemove:G=>e.fileList.splice(e.fileList.indexOf(f),1)},null,8,["url","name","percentage","onRemove"])]),default:d(()=>[s(n,{size:"small",type:"primary",round:""},{default:d(()=>[s(u,{icon:"fa-solid fa-upload",class:"mr-1"}),_(" "+i(e.$t("headshots.button.uploadImageUrls")),1)]),_:1})]),_:1},8,["file-list","action","on-exceed","on-error","on-success","headers"])]),s(g,{content:e.$t("headshots.description.endImageUrls"),class:"info"},null,8,["content"])])}const me=b(le,[["render",pe],["__scopeId","data-v-1690629a"]]),he="fast",ue=v({name:"ModeSelector",components:{ElRadioButton:j,ElRadioGroup:D},data(){return{options:[{label:this.$t("headshots.button.fast"),value:"fast"},{label:this.$t("headshots.button.relax"),value:"relax"}]}},computed:{value:{get(){return this.$store.state.headshots.config?.mode},set(e){console.debug("set mode",e),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots.config,mode:e})}}},mounted(){this.value||(this.value=he)}}),ge={class:"field"},fe={class:"title font-bold"};function _e(e,t,m,h,k,y){const p=o("el-radio-button"),u=o("el-radio-group");return a(),l("div",ge,[r("h2",fe,i(e.$t("headshots.name.mode")),1),s(u,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=n=>e.value=n),size:"small",class:"mode"},{default:d(()=>[(a(!0),l(T,null,I(e.options,n=>(a(),S(p,{key:n.value,label:n.value},{default:d(()=>[_(i(n.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])])}const $e=b(ue,[["render",_e],["__scopeId","data-v-a2a0d5fa"]]),ve=v({name:"StylizeSelector",components:{ElTabs:B,ElTabPane:z,ElImage:P},data(){return{tab:"styles",value:"",elements:{styles:{displayName:this.$t("headshots.styleCategory.styles"),items:[{image:"https://static.aipedias.com/aicamera/common/20241008/20241008202314260779439.png",label:this.$t("headshots.styleTag.malePportrait"),value:"male_portrait"},{image:"https://static.aipedias.com/aicamera/common/20241008/202410082022241e9755548.png",label:this.$t("headshots.styleTag.malePportrait2"),value:"male_portrait2"},{image:"https://static.aipedias.com/aicamera/common/20241101/20241101170130d78f66521.png",label:this.$t("headshots.styleTag.kindergarten"),value:"kindergarten"},{image:"https://static.aipedias.com/aicamera/common/20240923/20240923123233accf60398.webp",label:this.$t("headshots.styleTag.logoTshirt"),value:"logo_tshirt"},{image:"https://static.aipedias.com/aicamera/common/20241025/202410252012329472d0656.jpg",label:this.$t("headshots.styleTag.wedding"),value:"wedding"},{image:"https://static.aipedias.com/aicamera/common/20240915/20240915145045254931400.webp",label:this.$t("headshots.styleTag.businessPphoto"),value:"business_photo"},{image:"https://static.aipedias.com/aicamera/common/20240810/20240810194526040341795.jpg",label:this.$t("headshots.styleTag.bobSuit"),value:"bob_suit"},{image:"https://static.aipedias.com/aicamera/common/20240717/20240717152654e0b348173.webp",label:this.$t("headshots.styleTag.femalePortrait"),value:"female_portrait"}]}}}},watch:{value(e){console.debug("set template",e),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,template:e})}},mounted(){this.value||(this.value=""),console.debug("set template",this.value),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,template:this.value})},methods:{onToggle(e){this.value===e?this.value="":this.value=e,console.debug("set template",this.value),this.$store.commit("headshots/setConfig",{...this.$store.state.headshots?.config,template:this.value})}}}),be={class:"field"},ke=["onClick"],ye={class:"name"};function we(e,t,m,h,k,y){const p=o("el-image"),u=o("el-tab-pane"),n=o("el-tabs");return a(),l("div",be,[s(n,{modelValue:e.tab,"onUpdate:modelValue":t[0]||(t[0]=c=>e.tab=c)},{default:d(()=>[(a(!0),l(T,null,I(e.elements,(c,g)=>(a(),S(u,{key:g,label:c.displayName,name:g,class:"pane"},{default:d(()=>[(a(!0),l(T,null,I(c.items,(f,G)=>(a(),l("div",{key:G,class:V({item:!0,active:e.value===f.value}),onClick:_s=>e.onToggle(f.value)},[s(p,{src:f.image,fit:"fill",class:"preview"},null,8,["src"]),r("span",ye,i(f.label),1)],10,ke))),128))]),_:2},1032,["label","name"]))),128))]),_:1},8,["modelValue"])])}const Te=b(ve,[["render",we],["__scopeId","data-v-be4bd25d"]]),Ie=v({name:"PresetPanel",components:{ModeSelector:$e,ImageUrlsInput:me,ElButton:A,FontAwesomeIcon:C,ElementsSelector:Te},emits:["generate"],computed:{config(){return this.$store.state.headshots?.config}},methods:{onGenerate(){this.$emit("generate")}}}),Se={class:"panel"},Ve={class:"config"},Ee={class:"actions"};function Ce(e,t,m,h,k,y){const p=o("elements-selector"),u=o("mode-selector"),n=o("image-urls-input"),c=o("font-awesome-icon"),g=o("el-button");return a(),l("div",Se,[r("div",Ve,[s(p,{class:"mb-4"}),s(u,{class:"mb-4"}),s(n,{class:"mb-4"}),r("div",Ee,[s(g,{type:"primary",class:"btn w-full",round:"",onClick:e.onGenerate},{default:d(()=>[s(c,{icon:"fa-solid fa-magic",class:"mr-2"}),_(" "+i(e.$t("headshots.button.generate")),1)]),_:1},8,["onClick"])])])])}const Re=b(Ie,[["render",Ce],["__scopeId","data-v-848739f6"]]),Ae=v({name:"ImageGallery",props:{modelValue:{type:Object,required:!0}},setup(e){return{images:F(()=>e.modelValue?.response?.data?.slice(0,2)||[]),viewImage:h=>{window.open(h,"_blank")}}}}),Ge={class:"image-gallery"},Pe=["src"],Le=["onClick"];function Ue(e,t,m,h,k,y){return a(),l("div",Ge,[(a(!0),l(T,null,I(e.images,(p,u)=>(a(),l("div",{key:u,class:"image-container"},[r("img",{src:p.image_url,alt:"Image"},null,8,Pe),p.image_url?(a(),l("button",{key:0,class:"view-button",onClick:n=>e.viewImage(p.image_url)},i(e.$t("headshots.button.viewImage")),9,Le)):$("",!0)]))),128))])}const De=b(Ae,[["render",Ue],["__scopeId","data-v-42f0a7be"]]),je=v({name:"TaskPreview",components:{ElImage:P,CopyToClipboard:x,FontAwesomeIcon:C,ElAlert:M,ImageGallery:De},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.headshots?.application},config(){return this.$store.state.headshots?.config}},methods:{onDownload(e,t){e.stopPropagation(),console.log("on download"),window.open(t,"_blank")},onReload(e){const t=e.target,m=new URL(t.src),h=m.searchParams.get("retry");if(!h)m.searchParams.set("retry","1");else if(parseInt(h)<2)m.searchParams.set("retry",(parseInt(h)+1).toString());else return;t.src=m.toString()},onOpenVideo(e){window.open(e,"_blank")}}}),ze={class:"preview"},Be={class:"left"},Me={class:"main"},Oe={class:"bot"},qe={class:"datetime"},Fe={class:"info"},Ne={key:0,class:"prompt mt-2"},He={key:0},Ke={key:1},Je={key:0,class:V({content:!0,failed:!0})},Qe={class:"image-wrapper"},We={class:"description"},Xe={key:1,class:V({content:!0})},Ye={class:"description"},Ze={class:"description"},xe={class:"description"},es={key:2,class:V({content:!0})},ss={class:"description"},ts={key:3,class:V({content:!0})},as={class:"description"};function os(e,t,m,h,k,y){const p=o("el-image"),u=o("image-gallery"),n=o("font-awesome-icon"),c=o("copy-to-clipboard"),g=o("el-alert");return a(),l("div",ze,[r("div",Be,[s(p,{src:"https://cdn.acedata.cloud/isxyfw.png",class:"avatar"})]),r("div",Me,[r("div",Oe,[_(i(e.$t("headshots.name.headshotsBot"))+" ",1),r("span",qe,i(e.$dayjs.format(""+new Date(parseFloat((e.modelValue?.created_at||"").toString())*1e3))),1)]),r("div",Fe,[e.modelValue?.request?.template?(a(),l("p",Ne,[_(i(e.modelValue?.request?.template)+" ",1),e.modelValue?.response?$("",!0):(a(),l("span",He," - ("+i(e.$t("headshots.status.pending"))+") ",1)),e.modelValue?.response?.status==="unknown"?(a(),l("span",Ke," - ("+i(e.$t("headshots.status.processing"))+") ",1)):$("",!0)])):$("",!0)]),e.modelValue?.response?.success===!0?(a(),l("div",Je,[r("div",Qe,[s(u,{"model-value":e.modelValue},null,8,["model-value"])]),s(g,{closable:!1,class:"mt-2 success"},{default:d(()=>[r("p",We,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),e.modelValue?.response?.success===!1?(a(),l("div",Xe,[s(g,{closable:!1,class:"failure"},{template:d(()=>[s(n,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failure")),1)]),default:d(()=>[r("p",Ye,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])]),r("p",Ze,[s(n,{icon:"fa-solid fa-circle-info",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failureReason"))+": "+i(e.modelValue?.response?.error?.message)+" ",1),s(c,{content:e.modelValue?.response?.error?.message,class:"btn-copy"},null,8,["content"])]),r("p",xe,[s(n,{icon:"fa-solid fa-hashtag",class:"mr-1"}),_(" "+i(e.$t("headshots.name.traceId"))+": "+i(e.modelValue?.response?.trace_id)+" ",1),s(c,{content:e.modelValue?.response?.trace_id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0),e.modelValue?.response?$("",!0):(a(),l("div",es,[s(g,{closable:!1,class:"info"},{template:d(()=>[s(n,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failure")),1)]),default:d(()=>[r("p",ss,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])),e.modelValue?.response?.status==="unknown"?(a(),l("div",ts,[s(g,{closable:!1,class:"info"},{template:d(()=>[s(n,{icon:"fa-solid fa-exclamation-triangle",class:"mr-1"}),_(" "+i(e.$t("headshots.name.failure")),1)]),default:d(()=>[r("p",as,[s(n,{icon:"fa-solid fa-magic",class:"mr-1"}),_(" "+i(e.$t("headshots.name.taskId"))+": "+i(e.modelValue?.id)+" ",1),s(c,{content:e.modelValue?.id,class:"btn-copy"},null,8,["content"])])]),_:1})])):$("",!0)])])}const ns=b(je,[["render",os],["__scopeId","data-v-d1196e0c"]]),is=v({name:"RecentPanel",components:{TaskPreview:ns,ElSkeleton:q,ElSkeletonItem:O,ScrollList:X},props:{loading:{type:Boolean,default:!1}},emits:["reach-top"],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.headshots?.tasks,items:this.$store.state.headshots?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),ls={key:0,class:"tasks"},rs={class:"left"},cs={class:"main"},ds={key:1,class:"tasks"},ps={key:2,class:"description"};function ms(e,t,m,h,k,y){const p=o("el-skeleton-item"),u=o("el-skeleton"),n=o("task-preview"),c=o("scroll-list");return a(),S(c,{ref:"scrollList",class:"panel recent",loading:e.loading,onReachTop:t[0]||(t[0]=g=>e.$emit("reach-top"))},{default:d(()=>[e.tasks?.items===void 0?(a(),l("div",ls,[(a(),l(T,null,I(3,g=>r("div",{key:g,class:"task placeholder"},[r("div",rs,[s(u,{animated:""},{template:d(()=>[s(p,{variant:"image",class:"avatar"})]),_:1})]),r("div",cs,[s(u,{animated:""},{template:d(()=>[s(p,{variant:"p",class:"title"}),s(p,{variant:"image",class:"icon"})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(a(),l("div",ds,[(a(!0),l(T,null,I(e.tasks?.items,(g,f)=>(a(),S(n,{key:f,"model-value":g,class:"preview"},null,8,["model-value"]))),128))])):$("",!0),e.tasks?.items?.length===0?(a(),l("p",ps,i(e.$t("headshots.message.noTasks")),1)):$("",!0)]),_:1},8,["loading"])}const hs=b(is,[["render",ms],["__scopeId","data-v-ffd55c16"]]),us="https://webhook.acedata.cloud/headshots",gs=v({name:"HeadshotsIndex",components:{ConfigPanel:Re,Layout:ie,ApplicationStatus:Z,RecentPanel:hs},inject:["initialized"],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.headshots?.status?.getApplications===E.Request},tasksLoading(){return this.$store.state.headshots?.status?.getTasks===E.Request||this.fetchingTasks},service(){return this.$store.state.headshots.service},credential(){return this.$store.state.headshots.credential},config(){return this.$store.state.headshots.config},initializing(){return this.$store.state.headshots.status.getApplications===E.Request},needApply(){return this.$store.state.headshots.status.getApplications===E.Success&&!this.application},application(){return this.$store.state.headshots.application},applications(){return this.$store.state.headshots.applications},tasks(){return this.$store.state.headshots.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug("new tasks detected")},deep:!0},initialized:{async handler(e){e&&(console.debug("layout initialized"),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await ee({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug("start onGetService"),await this.$store.dispatch("headshots/getService"),console.debug("end onGetService")},async onGetApplication(){console.debug("start onGetApplication"),await this.$store.dispatch("headshots/getApplications"),console.debug("end onGetApplication"),await this.onGetTasks()},onApply(){J.create({application:this.application}).then(({data:e})=>{this.application=e,w.success(this.$t("application.message.applySuccessfully"))}).catch(e=>{e?.response?.data?.code===Q&&w.error(this.$t("application.message.alreadyApplied"))})},async onScrollDown(){await this.$nextTick();const e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug("loading");return}console.debug("start onGetTasks",e);const{limit:t=5,createdAtMin:m,createdAtMax:h}=e||{};console.debug("limit",t,"createdAtMin",m,"createdAtMax",h),this.fetchingTasks=!0;try{await this.$store.dispatch("headshots/getTasks",{limit:t,createdAtMin:m,createdAtMax:h})}finally{this.fetchingTasks=!1}},async onGeneratePicture(){const e={...this.config,callback_url:us},t=this.credential?.token;if(!t){console.error("no token specified");return}w.info(this.$t("headshots.message.startingTask")),H.generate(e,{token:t}).then(()=>{w.success(this.$t("headshots.message.startTaskSuccess")),this.$store.commit("headshots/setConfig",{config:void 0})}).catch(m=>{m?.response?.data?.error?.code===K?w.error(this.$t("headshots.message.usedUp")):w.error(this.$t("headshots.message.startTaskFailed"))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function fs(e,t,m,h,k,y){const p=o("config-panel"),u=o("application-status"),n=o("recent-panel"),c=o("layout");return a(),S(c,null,{config:d(()=>[s(p,{onGenerate:e.onGeneratePicture},null,8,["onGenerate"])]),result:d(()=>[s(u,{initializing:e.initializing,application:e.application,applications:e.applications,service:e.service,"need-apply":e.needApply,class:"mb-4",onRefresh:e.onGetApplication,onSelect:t[0]||(t[0]=g=>e.$store.dispatch("headshots/setApplication",g))},null,8,["initializing","application","applications","service","need-apply","onRefresh"]),s(n,{ref:"recentPanel",class:"panel recent",loading:e.loadingMore,onReachTop:e.onReachTop},null,8,["loading","onReachTop"])]),_:1})}const As=b(gs,[["render",fs],["__scopeId","data-v-6cafffbd"]]);export{As as default};
|