@acedatacloud/nexior 3.277.4 → 3.277.5

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.
Files changed (143) hide show
  1. package/dist/assets/{ApiCodeButton-DXN7iB8l.js → ApiCodeButton-9rdgO0or.js} +1 -1
  2. package/dist/assets/{AskUserQuestionCard-CPQb26DU.js → AskUserQuestionCard-BO9LbC9D.js} +1 -1
  3. package/dist/assets/{Auth-BkXFXHwC.js → Auth-C3zTAhvN.js} +1 -1
  4. package/dist/assets/{Bare-B5EPTD3k.js → Bare-3PA6dGCh.js} +1 -1
  5. package/dist/assets/{BotPlaceholder-R_nAAbft.js → BotPlaceholder-DhZ616uF.js} +1 -1
  6. package/dist/assets/{BottomFooter-jepzQURF.js → BottomFooter-DegHQFt2.js} +1 -1
  7. package/dist/assets/{Callback-DH3ldyqo.js → Callback-Csgmunrn.js} +1 -1
  8. package/dist/assets/{Console-rsr21rbN.js → Console-DTqwL9iH.js} +1 -1
  9. package/dist/assets/{Consumption-CjrpUNmV.js → Consumption-Dv4UTeE5.js} +1 -1
  10. package/dist/assets/{Conversation-PmXYPnF1.js → Conversation-CP5iZ9Gh.js} +1 -1
  11. package/dist/assets/{CopyToClipboard-DXA4nHxo.js → CopyToClipboard-CW-duTMh.js} +1 -1
  12. package/dist/assets/{Detail-BtKYzcA7.js → Detail-Z_2SqsPW.js} +2 -2
  13. package/dist/assets/{Extra-B9rCcwWj.js → Extra-BspM5QQI.js} +1 -1
  14. package/dist/assets/{FilePreview-Dqk4WVEr.js → FilePreview-BTDowqVT.js} +1 -1
  15. package/dist/assets/{Hailuo-D_ir2qwk.js → Hailuo-kmnQTeOS.js} +1 -1
  16. package/dist/assets/{History-g_mPJBRP.js → History-DJwnqCd7.js} +1 -1
  17. package/dist/assets/{ImagePreview-Bkw_taCt.js → ImagePreview-CjurFfIy.js} +1 -1
  18. package/dist/assets/{ImageWrapper-BPvtDIMf.js → ImageWrapper-DZXsT0GB.js} +1 -1
  19. package/dist/assets/Index-4F7k6tIW.js +1 -0
  20. package/dist/assets/{Index-C2jzr33l.js → Index-BTddZVrJ.js} +1 -1
  21. package/dist/assets/{Index-C8zclc3l.js → Index-BXuf-l6W.js} +1 -1
  22. package/dist/assets/{Index-ZXaIaAWW.js → Index-BXyyTYVj.js} +1 -1
  23. package/dist/assets/{Index-DQ6WJNd4.js → Index-B_2uV-WB.js} +1 -1
  24. package/dist/assets/{Index-BDGE5GsR.js → Index-B_V1107d.js} +1 -1
  25. package/dist/assets/{Index-CJ_B5PUw.js → Index-BnMrjX59.js} +1 -1
  26. package/dist/assets/{Index-BQWV4ACZ.js → Index-BrR-NCxC.js} +1 -1
  27. package/dist/assets/{Index-C9vdHrH1.js → Index-BsFA8G7I.js} +1 -1
  28. package/dist/assets/{Index-Dsbx7mYp.js → Index-Bueutmwo.js} +1 -1
  29. package/dist/assets/{Index-CGQPNGH6.js → Index-CHZJjObr.js} +1 -1
  30. package/dist/assets/{Index-CaYlG9QS.js → Index-CZT2jdAy.js} +1 -1
  31. package/dist/assets/{Index-CqgNerQP.js → Index-Ck7P_BAG.js} +1 -1
  32. package/dist/assets/{Index-JB4pTHsw.js → Index-CtQ2amxO.js} +1 -1
  33. package/dist/assets/{Index-BHzERvOB.js → Index-DIr7JBqu.js} +1 -1
  34. package/dist/assets/{Index-CycuKObu.js → Index-DSHxxiqN.js} +1 -1
  35. package/dist/assets/{Index-C3yZt6r4.js → Index-Dai9c3aE.js} +1 -1
  36. package/dist/assets/{Index-B6G7B2I0.js → Index-DcuCXN4S.js} +1 -1
  37. package/dist/assets/{Index-D9e-AGnZ.js → Index-DxNU9BrQ.js} +1 -1
  38. package/dist/assets/{Index-ComARfRw.js → Index-LMJdIXo8.js} +1 -1
  39. package/dist/assets/{Index-C2M1W6HA.js → Index-SRN-SciE.js} +1 -1
  40. package/dist/assets/{Index-ke_plb_v.js → Index-VVvUshW_.js} +1 -1
  41. package/dist/assets/{Index-CTuEMRMq.js → Index-Y1wgnIWr.js} +1 -1
  42. package/dist/assets/{Index-Wn4WhxSA.js → Index-_c1bADkv.js} +1 -1
  43. package/dist/assets/{Index-DSIgRXEN.js → Index-aVHAY8VD.js} +1 -1
  44. package/dist/assets/{Index-D3Do9QG2.js → Index-rxEQpPu3.js} +1 -1
  45. package/dist/assets/{Invitees-CtOjf0iy.js → Invitees-CtmT6N2P.js} +1 -1
  46. package/dist/assets/{List-DjAb-cmd.js → List-B1eQgXm4.js} +1 -1
  47. package/dist/assets/{List-HnIA1E2e.js → List-BQsxl9OO.js} +1 -1
  48. package/dist/assets/{List-CpB562Ry.js → List-Bqa5U4qI.js} +1 -1
  49. package/dist/assets/{Main-BI0k19m6.js → Main-BtSiwJEL.js} +1 -1
  50. package/dist/assets/{Model-wnwwcJwj.js → Model-CL7S3uKt.js} +1 -1
  51. package/dist/assets/{Navigator-BknUSx4Z.js → Navigator-C989uP0E.js} +1 -1
  52. package/dist/assets/{NoTasks-568fhAGt.js → NoTasks-HGgmWayY.js} +1 -1
  53. package/dist/assets/{NotFound-Co5GcLDE.js → NotFound-CPpraXlK.js} +1 -1
  54. package/dist/assets/{Pagination-C9VVozAy.js → Pagination-DkhsjZ3x.js} +1 -1
  55. package/dist/assets/{Pay-D0MlHd8L.js → Pay-BWm8WKVp.js} +1 -1
  56. package/dist/assets/{Player--ctmekZs.js → Player-Dg2tf_iI.js} +1 -1
  57. package/dist/assets/{Seedance-vljqSpVs.js → Seedance-Cszb_X1k.js} +1 -1
  58. package/dist/assets/{Status-CvH_CBCZ.js → Status-B7xq2zJE.js} +1 -1
  59. package/dist/assets/{Subscribe-DCU6AfQa.js → Subscribe-CBnMeeuP.js} +1 -1
  60. package/dist/assets/{TabSwitcher-CHZ_ECnY.js → TabSwitcher-g-agCufh.js} +1 -1
  61. package/dist/assets/{Tts-DGZwUosH.js → Tts-DOJJTFgz.js} +1 -1
  62. package/dist/assets/{VideoPlayer-BjsbkQZc.js → VideoPlayer-_FQCj0ZO.js} +1 -1
  63. package/dist/assets/{avatar-CHgySyav.js → avatar-BlmXvUoy.js} +1 -1
  64. package/dist/assets/{basic-CjTT_oRU.js → basic-CdSp10T2.js} +1 -1
  65. package/dist/assets/{chat-BOAbBwQI.js → chat-BDQkbDpx.js} +1 -1
  66. package/dist/assets/{codingBridge-B-gY1N1A.js → codingBridge-3WJhCzBo.js} +1 -1
  67. package/dist/assets/{codingBridge-DAK6VumY.js → codingBridge-3WOLNEpk.js} +1 -1
  68. package/dist/assets/{codingBridge-B6CatBrM.js → codingBridge-8n45uKpV.js} +1 -1
  69. package/dist/assets/{codingBridge-iRMNlW_S.js → codingBridge-BMEP_vTH.js} +1 -1
  70. package/dist/assets/{codingBridge-GHfcAtW8.js → codingBridge-BbR7lW-u.js} +1 -1
  71. package/dist/assets/{codingBridge-mfpuGC6b.js → codingBridge-Bh6rWHNu.js} +1 -1
  72. package/dist/assets/{codingBridge-D1WDrcmr.js → codingBridge-C4fHRmxn.js} +1 -1
  73. package/dist/assets/{codingBridge-CvB_AifV.js → codingBridge-CH5rv53f.js} +1 -1
  74. package/dist/assets/{codingBridge-DnLwm8Vn.js → codingBridge-CQbWRH-y.js} +1 -1
  75. package/dist/assets/{codingBridge-Bvgssc71.js → codingBridge-CZFOGzn8.js} +1 -1
  76. package/dist/assets/{codingBridge-CAhONS09.js → codingBridge-CouY2bMV.js} +1 -1
  77. package/dist/assets/{codingBridge-DMGrbAaR.js → codingBridge-CpCUFbIx.js} +1 -1
  78. package/dist/assets/{codingBridge-BPDUyHBH.js → codingBridge-Didt9l_F.js} +1 -1
  79. package/dist/assets/{codingBridge-DI54WF2v.js → codingBridge-K8s1qD2P.js} +1 -1
  80. package/dist/assets/{codingBridge-id8MUjk3.js → codingBridge-LvufX6dg.js} +1 -1
  81. package/dist/assets/{codingBridge--XigVvyR.js → codingBridge-X-xT4hgU.js} +1 -1
  82. package/dist/assets/{codingBridge-Dxupvrte.js → codingBridge-eHNUDtXs.js} +1 -1
  83. package/dist/assets/{codingBridge-CkaxOr4j.js → codingBridge-iKrg_YzA.js} +1 -1
  84. package/dist/assets/{codingBridge-Oiwx8S44.js → codingBridge-nx_Ad0y0.js} +1 -1
  85. package/dist/assets/{codingBridgeNotify-nSBbOsRW.js → codingBridgeNotify-CQnqejnD.js} +2 -2
  86. package/dist/assets/{collapse-B99-bYjk.js → collapse-DzxsO3Mt.js} +1 -1
  87. package/dist/assets/{constants-B6_fTlam.js → constants-EAH6CsV9.js} +1 -1
  88. package/dist/assets/{createTaskActions-CClbGT-n.js → createTaskActions-08HriN96.js} +1 -1
  89. package/dist/assets/{date-picker-BtukkZrG.js → date-picker-DFsSONyL.js} +1 -1
  90. package/dist/assets/{dropdown-BzFwppmF.js → dropdown-Dh3U4lax.js} +1 -1
  91. package/dist/assets/esm-BD9aVehm.js +1 -0
  92. package/dist/assets/{esm-l5ji9H4b.js → esm-Bn0vJPGM.js} +1 -1
  93. package/dist/assets/{esm-DFfWKlEX.js → esm-BnSUrs3x.js} +1 -1
  94. package/dist/assets/{esm-CWZTkeBt.js → esm-Bp9p27ec.js} +3 -3
  95. package/dist/assets/{esm-CyghH0i3.js → esm-CAB34Hv4.js} +2 -2
  96. package/dist/assets/{esm-kL8Pp6jZ.js → esm-ed2G2n0j.js} +2 -2
  97. package/dist/assets/{esm-BOBX4dhx.js → esm-tQgyvSEq.js} +1 -1
  98. package/dist/assets/{fish-BWtzHFqO.js → fish-FgOp1bSR.js} +1 -1
  99. package/dist/assets/{flux-C-FqnDs4.js → flux-CNKI3gnl.js} +1 -1
  100. package/dist/assets/{grokvideo-C9fmjCwH.js → grokvideo-CJ8EegtG.js} +1 -1
  101. package/dist/assets/{hailuo-BrfV-8h8.js → hailuo-g_CiU9UH.js} +1 -1
  102. package/dist/assets/{headshots-Mjvj0YDr.js → headshots-ba-P4q7n.js} +1 -1
  103. package/dist/assets/{image-tItcr5tZ.js → image-BhCAlGZE.js} +1 -1
  104. package/dist/assets/{index-DpREqzJQ.js → index-WLGDsbco.js} +4 -4
  105. package/dist/assets/{index.browser.esm-BVybW0ME.js → index.browser.esm-DWAeifl9.js} +1 -1
  106. package/dist/assets/{index.es-DkXuZNXE.js → index.es-DEMCbRdu.js} +1 -1
  107. package/dist/assets/{input-number-BZClQnf5.js → input-number-De_zhvd-.js} +1 -1
  108. package/dist/assets/{kling-DnnRrHSY.js → kling-6kHkdbKB.js} +1 -1
  109. package/dist/assets/{luma-BfJ45Nrp.js → luma-zvOlfp2v.js} +1 -1
  110. package/dist/assets/{midjourney-BhBFIcGa.js → midjourney-BkAINbX6.js} +1 -1
  111. package/dist/assets/{nanobanana-9yIPx-7N.js → nanobanana-CDdy7DXE.js} +1 -1
  112. package/dist/assets/{openaiimage-yBE3S9GR.js → openaiimage-MuckNyIT.js} +1 -1
  113. package/dist/assets/{pagination-BQOE0Lce.js → pagination-B3UvJKZu.js} +1 -1
  114. package/dist/assets/{pika-BwDH6RXc.js → pika-CgTKZBY7.js} +1 -1
  115. package/dist/assets/{pixverse-V1u83-NJ.js → pixverse-CpDZvu26.js} +1 -1
  116. package/dist/assets/{popover-BOyleW7G.js → popover-DaX9BEhA.js} +1 -1
  117. package/dist/assets/{producer-D5j29zwT.js → producer-BSdBVVx_.js} +1 -1
  118. package/dist/assets/{qrart-BOGIYlCy.js → qrart-DukU-wH0.js} +1 -1
  119. package/dist/assets/{row-D8loqAPL.js → row-DLJTcN3S.js} +1 -1
  120. package/dist/assets/{seedance-BFWs3OMD.js → seedance-DOMVfpfX.js} +1 -1
  121. package/dist/assets/{seedream-PMGj_GEr.js → seedream-qYoaVvs3.js} +1 -1
  122. package/dist/assets/{select-CYdISXBV.js → select-CyfjsVYT.js} +1 -1
  123. package/dist/assets/{serp-BXsV4ruQ.js → serp-D8F32UZn.js} +1 -1
  124. package/dist/assets/{slider-heMG04zo.js → slider-C8p-p_jG.js} +1 -1
  125. package/dist/assets/{solana-wallets-DpEYEH8X.js → solana-wallets-CxX-IPdE.js} +2 -2
  126. package/dist/assets/{solana-wallets-vue-DwDUK9GJ.js → solana-wallets-vue-IWygWoNX.js} +1 -1
  127. package/dist/assets/{sora-BPluLKCF.js → sora-BBCFCnxD.js} +1 -1
  128. package/dist/assets/{suno-B3FfSfsu.js → suno--sxHZfXr.js} +1 -1
  129. package/dist/assets/{switch-DT8swXGq.js → switch-DfeNNIjH.js} +1 -1
  130. package/dist/assets/{tabs-DbqhD0Ri.js → tabs-DDqt-7al.js} +1 -1
  131. package/dist/assets/{upload-CHAO8dYa.js → upload-CIsl9b3M.js} +1 -1
  132. package/dist/assets/{veo--ebyIQZO.js → veo-C0Hd8shD.js} +1 -1
  133. package/dist/assets/{wan-QNzJ6Wsl.js → wan-CfT1U6Bg.js} +1 -1
  134. package/dist/assets/{web-BhPhz6gK.js → web-8dTV3yka.js} +1 -1
  135. package/dist/assets/{web-Dslc1DMt.js → web-BLoe5UoX.js} +1 -1
  136. package/dist/assets/{web-B3c_92-W.js → web-C7_2fRfR.js} +1 -1
  137. package/dist/assets/{web-DaBpN21i.js → web-DH9f_v7D.js} +1 -1
  138. package/dist/assets/{web-CggzH-kj.js → web-jldUVJrz.js} +1 -1
  139. package/dist/assets/{webextrator-BVPmDKBS.js → webextrator-CiqM06HL.js} +1 -1
  140. package/dist/index.html +2 -2
  141. package/package.json +1 -1
  142. package/dist/assets/Index-CEMmW0Xt.js +0 -1
  143. package/dist/assets/esm-LoPWTfn9.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,D as t,E as n,M as r,N as i,O as a,P as o,Q as s,Ut as c,X as l,_ as u,et as d,k as f,lt as p,tt as m,ut as h,x as g,y as _}from"./vendor-chart-mdwpew_o.js";import{t as v}from"./button-DWzbdjZV.js";import{F as y,X as b,Y as x,tt as S,z as C}from"./use-deprecated-CPfQu7wa.js";import{r as w,t as T}from"./select-CYdISXBV.js";import{n as E,t as D}from"./tabs-DbqhD0Ri.js";import{t as O}from"./upload-CHAO8dYa.js";import{t as k}from"./tooltip-C3PYfh8V.js";import{t as A}from"./image-tItcr5tZ.js";import{t as j}from"./avatar-DJGt2zYX.js";import{n as M,r as N}from"./radio-IJQsW93X.js";import{n as ee,t as P}from"./collapse-B99-bYjk.js";import{t as F}from"./drawer-BvYPSxXh.js";import{n as I,r as te,t as ne}from"./dropdown-BzFwppmF.js";import{t as L}from"./input-number-BZClQnf5.js";import{n as re,t as ie}from"./skeleton-Cn4UY-T8.js";import{t as ae}from"./slider-heMG04zo.js";import{t as oe}from"./switch-DT8swXGq.js";import{Mn as se,hi as R}from"./constants-B6_fTlam.js";import{An as z,At as B,E as V,Fn as H,Ir as U,Nt as W,Ot as G,Sr as K,kr as q,kt as ce,nn as J,yr as Y}from"./index-DpREqzJQ.js";import{t as X}from"./index.es-DkXuZNXE.js";import{n as le}from"./taskDrawerMixin-Cr17Yxqk.js";import{i as Z,n as ue,r as de,t as fe}from"./pagination-BQOE0Lce.js";import{n as pe,t as me}from"./NoTasks-568fhAGt.js";import{t as he}from"./Consumption-CjrpUNmV.js";import{n as ge,r as Q,t as _e}from"./Player--ctmekZs.js";var ve=o({name:`LayoutProducer`,components:{ElDrawer:F,ElButton:v,FontAwesomeIcon:X},mixins:[le],data(){return{preview:!1}},computed:{}}),ye={class:`main flex flex-row flex-1`},be={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},xe={class:`result h-full flex flex-col flex-1 min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`},Se={class:`preview h-full w-[300px] flex flex-col`};function Ce(t,r,a,o,s,c){let m=d(`font-awesome-icon`),g=d(`el-button`),_=d(`el-drawer`);return l(),f(`div`,ye,[n(`div`,be,[e(t.$slots,`config`,{},void 0,!0)]),n(`div`,xe,[e(t.$slots,`result`,{},void 0,!0)]),n(`div`,Se,[e(t.$slots,`preview`,{},void 0,!0)]),h(i(g,{circle:``,class:`menu`,onClick:r[0]||=e=>t.drawer=!0},{default:p(()=>[i(m,{icon:`fa-solid fa-magic`})]),_:1},512),[[u,!t.tasksEmpty]]),i(_,{modelValue:t.drawer,"onUpdate:modelValue":r[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:p(()=>[e(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=V(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=o({name:`TypeSelector`,components:{ElSelect:w,ElOption:T,ElSwitch:oe,InfoIcon:Z},data(){return{options:[{label:`FUZZ-2.0 Pro`,value:`FUZZ-2.0 Pro`,desc:this.$t(`producer.model.fuzz20proDesc`)},{label:`FUZZ-2.0`,value:`FUZZ-2.0`,desc:this.$t(`producer.model.fuzz20desc`)},{label:`FUZZ-2.0 Raw`,value:`FUZZ-2.0 Raw`,desc:this.$t(`producer.model.fuzz20rawDesc`)},{label:`FUZZ-1.1 Pro`,value:`FUZZ-1.1 Pro`,desc:this.$t(`producer.model.fuzz11proDesc`)},{label:`FUZZ-1.1`,value:`FUZZ-1.1`,desc:this.$t(`producer.model.fuzz11desc`)},{label:`FUZZ-1.0 Pro`,value:`FUZZ-1.0 Pro`,desc:this.$t(`producer.model.fuzz10proDesc`)},{label:`FUZZ-1.0`,value:`FUZZ-1.0`,desc:this.$t(`producer.model.fuzz10desc`)},{label:`FUZZ-0.8`,value:`FUZZ-0.8`,desc:this.$t(`producer.model.fuzz08desc`)}]}},computed:{custom:{get(){return this.$store.state.producer?.config?.custom||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e})}},instrumental:{get(){return this.$store.state.producer?.config?.instrumental||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,instrumental:e})}},model:{get(){return this.$store.state.producer?.config?.model},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e})}}},mounted(){this.model||=se}}),Ee={class:`mb-3`},De={class:`flex items-center mb-1`},Oe={class:`text-sm font-bold`},ke={class:`model-option`},Ae={class:`model-option-name`},je={class:`model-option-desc`},Me={key:0,class:`flex items-center justify-between mb-3`},Ne={class:`flex items-center`},Pe={class:`text-sm font-bold`};function Fe(e,r,o,u,m,h){let _=d(`el-option`),v=d(`el-select`),y=d(`info-icon`),b=d(`el-switch`);return l(),f(`div`,null,[n(`div`,Ee,[n(`div`,De,[n(`span`,Oe,c(e.$t(`producer.name.model`)),1)]),i(v,{modelValue:e.model,"onUpdate:modelValue":r[0]||=t=>e.model=t,class:`w-full model-select`,size:`default`,placeholder:e.$t(`producer.placeholder.select`)},{default:p(()=>[(l(!0),f(g,null,s(e.options,e=>(l(),t(_,{key:e.value,label:e.label,value:e.value},{default:p(()=>[n(`div`,ke,[n(`span`,Ae,c(e.label),1),n(`span`,je,c(e.desc),1)])]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])]),e.custom?(l(),f(`div`,Me,[n(`div`,Ne,[n(`span`,Pe,c(e.$t(`producer.name.instrumental`)),1),i(y,{content:e.$t(`producer.description.instrumental`)},null,8,[`content`])]),i(b,{modelValue:e.instrumental,"onUpdate:modelValue":r[1]||=t=>e.instrumental=t},null,8,[`modelValue`])])):a(``,!0)])}var Ie=V(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=o({name:`UploadAudio`,components:{ElUpload:O,ElButton:v,ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z,FontAwesomeIcon:X},mixins:[ce],emits:[`change`],data(){return{fileList:[],uploadUrl:K()+`/api/v1/files/`,audioPreviewUrl:null,uploading:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},hasUploadedAudio(){let e=this.$store.state.producer?.config?.action;return e===`upload_extend`||e===`upload_cover`},uploadAction:{get(){return this.$store.state.producer?.config?.action||`upload_extend`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,action:e})}}},watch:{urls:{handler(e){this.$emit(`change`,e)}}},methods:{onExceed(){q.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,q.error(this.$t(`producer.message.uploadReferencesError`))},async onSuccess(){let e=this.urls?.[0];if(!e){this.uploading=!1;return}this.audioPreviewUrl=e,await this.onGenerateAudioId(e)},async onGenerateAudioId(e){let t={audio_url:e},n=this.credential?.token;if(!n){console.error(`no token specified`),this.uploading=!1;return}this.uploading=!0,q.info(this.$t(`producer.message.startingUploadAudio`));try{let e=(await J.upload(t,{token:n})).data?.data.audio_id;this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,audio_id:e,action:`upload_extend`}),q.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){q.error(e?.response?.data?.error?.message||this.$t(`producer.message.startUploadAudioFailed`))}finally{this.uploading=!1}}}}),Re={class:`relative`},ze={class:`flex justify-between items-center mb-2`},Be={class:`flex justify-start items-center`},Ve={class:`text-sm font-bold`},He={key:0,class:`mb-2`},Ue=[`src`],We={key:1,class:`mt-1`};function Ge(e,t,o,s,u,m){let h=d(`info-icon`),g=d(`font-awesome-icon`),_=d(`el-button`),v=d(`el-upload`),y=d(`el-radio-button`),b=d(`el-radio-group`);return l(),f(`div`,Re,[n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.$t(`producer.name.referenceAudios`)),1),i(h,{content:e.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),i(v,{"file-list":e.fileList,"onUpdate:fileList":t[0]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper inline-upload`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:p(()=>[i(_,{round:``,type:`primary`,size:`small`,loading:e.uploading},{default:p(()=>[i(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+c(e.$t(`producer.button.uploadAudios`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])]),e.audioPreviewUrl?(l(),f(`div`,He,[n(`audio`,{src:e.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):a(``,!0),e.hasUploadedAudio?(l(),f(`div`,We,[i(b,{modelValue:e.uploadAction,"onUpdate:modelValue":t[1]||=t=>e.uploadAction=t,size:`small`},{default:p(()=>[i(y,{value:`upload_extend`},{default:p(()=>[r(c(e.$t(`producer.button.extend`)),1)]),_:1}),i(y,{value:`upload_cover`},{default:p(()=>[r(c(e.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):a(``,!0)])}var Ke=V(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=o({name:`PromptInput`,components:{PromptTextarea:pe},computed:{prompt:{get(){return this.$store.state.producer?.config?.prompt},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Je(e,n,r,i,a,o){let s=d(`prompt-textarea`);return l(),t(s,{modelValue:e.prompt,"onUpdate:modelValue":n[0]||=t=>e.prompt=t,title:e.$t(`producer.name.songDescription`),info:e.$t(`producer.description.prompt`),placeholder:e.$t(`producer.placeholder.prompt`),"min-rows":5,"max-rows":14},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Ye=V(qe,[[`render`,Je]]),Xe=o({name:`LyricInput`,components:{ElInput:U,ElButton:v,FontAwesomeIcon:X,InfoIcon:Z},data(){return{generatingLyrics:!1}},computed:{lyric:{get(){return this.$store.state.producer?.config?.lyric},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:e})}},config(){return this.$store.state.producer?.config},credential(){return this.$store.state.producer?.credential}},mounted(){this.lyric||=``},methods:{async onGenerateLyrics(){let e=this.credential?.token;if(!e)return;let t=this.config?.style||this.config?.title||`a beautiful song`;this.generatingLyrics=!0,q.info(this.$t(`producer.message.generatingLyrics`));try{let n=(await J.lyric({prompt:t},{token:e})).data?.data;n?.text&&(this.lyric=n.text,n?.title&&!this.config?.title&&this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:n.text,title:n.title}),q.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{q.error(this.$t(`producer.message.generateLyricsFailed`))}finally{this.generatingLyrics=!1}}}}),Ze={class:`field`},Qe={class:`flex items-center justify-between mb-1`},$e={class:`flex items-center`},et={class:`text-sm font-bold`};function tt(e,o,s,u,m,h){let g=d(`info-icon`),_=d(`font-awesome-icon`),v=d(`el-button`),y=d(`el-input`);return l(),f(`div`,Ze,[n(`div`,Qe,[n(`div`,$e,[n(`span`,et,c(e.$t(`producer.name.lyrics`)),1),i(g,{content:e.$t(`producer.description.lyrics`)},null,8,[`content`])]),e.config?.action===`extend`?a(``,!0):(l(),t(v,{key:0,size:`small`,loading:e.generatingLyrics,round:``,onClick:e.onGenerateLyrics},{default:p(()=>[e.generatingLyrics?a(``,!0):(l(),t(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),r(` `+c(e.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),e.config?.action===`extend`?(l(),t(y,{key:1,modelValue:e.lyric,"onUpdate:modelValue":o[1]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(l(),t(y,{key:0,modelValue:e.lyric,"onUpdate:modelValue":o[0]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=V(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=o({name:`StyleInput`,components:{ElInput:U,InfoIcon:Z},computed:{style:{get(){return this.$store.state.producer?.config?.style},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style:e})}}}}),it={class:`field`},at={class:`flex items-center justify-between mb-1`},ot={class:`flex items-center`},st={class:`text-sm font-bold`};function ct(e,t,r,a,o,s){let u=d(`info-icon`),p=d(`el-input`);return l(),f(`div`,it,[n(`div`,at,[n(`div`,ot,[n(`span`,st,c(e.$t(`producer.name.style`)),1),i(u,{content:e.$t(`producer.description.style`)},null,8,[`content`])])]),i(p,{modelValue:e.style,"onUpdate:modelValue":t[0]||=t=>e.style=t,rows:2,type:`textarea`,placeholder:e.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=V(rt,[[`render`,ct]]),ut=o({name:`TitleInput`,components:{ElInput:U,InfoIcon:Z},computed:{title:{get(){return this.$store.state.producer?.config?.title},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,title:e})}}}}),dt={class:`field`},ft={class:`flex items-center mb-1`},pt={class:`text-sm font-bold`};function mt(e,t,r,a,o,s){let u=d(`info-icon`),p=d(`el-input`);return l(),f(`div`,dt,[n(`div`,ft,[n(`span`,pt,c(e.$t(`producer.name.title`)),1),i(u,{content:e.$t(`producer.description.title`)},null,8,[`content`])]),i(p,{modelValue:e.title,"onUpdate:modelValue":t[0]||=t=>e.title=t,placeholder:e.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=V(ut,[[`render`,mt]]),gt=o({name:`ExtendFromInput`,components:{ElImage:A,ElIcon:S,ElInputNumber:L,VideoPlay:b,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),_t={class:`field`},vt={class:`box`},yt={class:`title font-bold`},bt={class:`input-wrapper`},xt={class:`task`},St={class:`left`},Ct={key:2,class:`duration`},wt={class:`info`},Tt={class:`title`},Et={class:`style`};function Dt(e,t,r,o,s,u){let g=d(`el-input-number`),_=d(`el-image`),v=d(`video-pause`),y=d(`el-icon`),b=d(`video-play`),x=m(`loading`);return l(),f(`div`,_t,[n(`div`,vt,[n(`h2`,yt,c(e.$t(`producer.name.extend`)),1),n(`div`,bt,[i(g,{modelValue:e.value,"onUpdate:modelValue":t[0]||=t=>e.value=t,class:`value`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.extend.continue_at`),onChange:e.handleChange},null,8,[`modelValue`,`max`,`placeholder`,`onChange`])])]),n(`div`,xt,[e.audio?(l(),f(`div`,{key:0,class:`audio`,onClick:t[3]||=t=>e.onClick(e.audio)},[h((l(),f(`div`,St,[i(_,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),f(`div`,{key:0,class:`overlay`,onClick:t[1]||=t=>e.onPause(e.audio)},[i(y,null,{default:p(()=>[i(v)]),_:1})])):a(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),f(`div`,{key:1,class:`overlay`,onClick:t[2]||=t=>e.onPlay(e.audio)},[i(y,null,{default:p(()=>[i(b)]),_:1})])):a(``,!0),e.audio?.duration?(l(),f(`div`,Ct,c(e.useFormatDuring(e.audio?.duration)),1)):a(``,!0)])),[[x,!e.audio?.audio_url]]),n(`div`,wt,[n(`h2`,Tt,c(e.audio?.title),1),n(`p`,Et,c(e.audio?.style),1)])])):a(``,!0)])])}var Ot=V(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=o({name:`CoverFromInput`,components:{ElImage:A,ElIcon:S,VideoPlay:b,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),At={class:`field`},jt={class:`box`},Mt={class:`title font-bold`},Nt={class:`task`},Pt={class:`left`},Ft={key:2,class:`duration`},It={class:`info`},Lt={class:`title`},Rt={class:`style`};function zt(e,t,r,o,s,u){let g=d(`el-image`),_=d(`video-pause`),v=d(`el-icon`),y=d(`video-play`),b=m(`loading`);return l(),f(`div`,At,[n(`div`,jt,[n(`h2`,Mt,c(e.$t(`producer.name.cover`)),1)]),n(`div`,Nt,[e.audio?(l(),f(`div`,{key:0,class:`audio`,onClick:t[2]||=t=>e.onClick(e.audio)},[h((l(),f(`div`,Pt,[i(g,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),f(`div`,{key:0,class:`overlay`,onClick:t[0]||=t=>e.onPause(e.audio)},[i(v,null,{default:p(()=>[i(_)]),_:1})])):a(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),f(`div`,{key:1,class:`overlay`,onClick:t[1]||=t=>e.onPlay(e.audio)},[i(v,null,{default:p(()=>[i(y)]),_:1})])):a(``,!0),e.audio?.duration?(l(),f(`div`,Ft,c(e.useFormatDuring(e.audio?.duration)),1)):a(``,!0)])),[[b,!e.audio?.audio_url]]),n(`div`,It,[n(`h2`,Lt,c(e.audio?.title),1),n(`p`,Rt,c(e.audio?.style),1)])])):a(``,!0)])])}var Bt=V(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=o({name:`VocalGenderSelector`,components:{ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z},computed:{vocalGender:{get(){return this.$store.state.producer?.config?.vocal_gender||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,vocal_gender:e||void 0})}}}}),Ht={class:`mb-2`},Ut={class:`flex items-center mb-1`},Wt={class:`text-sm font-bold`};function Gt(e,t,a,o,s,u){let m=d(`info-icon`),h=d(`el-radio-button`),g=d(`el-radio-group`);return l(),f(`div`,Ht,[n(`div`,Ut,[n(`span`,Wt,c(e.$t(`producer.name.vocalGender`)),1),i(m,{content:e.$t(`producer.description.vocalGender`)},null,8,[`content`])]),i(g,{modelValue:e.vocalGender,"onUpdate:modelValue":t[0]||=t=>e.vocalGender=t},{default:p(()=>[i(h,{value:``},{default:p(()=>[r(c(e.$t(`producer.gender.auto`)),1)]),_:1}),i(h,{value:`f`},{default:p(()=>[r(c(e.$t(`producer.gender.female`)),1)]),_:1}),i(h,{value:`m`},{default:p(()=>[r(c(e.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=V(Vt,[[`render`,Gt]]),qt=o({name:`AdvancedParams`,components:{ElCollapse:P,ElCollapseItem:ee,ElInput:U,ElSlider:ae,ElInputNumber:L,InfoIcon:Z},data(){return{activeNames:[]}},computed:{config(){return this.$store.state.producer?.config},styleNegative:{get(){return this.$store.state.producer?.config?.style_negative||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style_negative:e||void 0})}},lyricPrompt:{get(){return this.$store.state.producer?.config?.lyric_prompt||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric_prompt:e||void 0})}},weirdness:{get(){return this.$store.state.producer?.config?.weirdness??.5},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,weirdness:e})}},soundStrength:{get(){return this.$store.state.producer?.config?.sound_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,sound_strength:e})}},lyricsStrength:{get(){return this.$store.state.producer?.config?.lyrics_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyrics_strength:e})}},seed:{get(){return this.$store.state.producer?.config?.seed},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,seed:e})}}},mounted(){let e=this.$store.state.producer?.config;if(!e)return;let t={};typeof e.weirdness==`number`&&e.weirdness>1&&(t.weirdness=e.weirdness/100),typeof e.sound_strength==`number`&&e.sound_strength>1&&(t.sound_strength=e.sound_strength/100),typeof e.lyrics_strength==`number`&&e.lyrics_strength>1&&(t.lyrics_strength=e.lyrics_strength/100),Object.keys(t).length>0&&this.$store.commit(`producer/setConfig`,{...e,...t})}}),Jt={key:0,class:`mb-3`},Yt={class:`flex items-center mb-1`},Xt={class:`text-xs font-bold`},Zt={key:1,class:`mb-3`},Qt={class:`flex items-center mb-1`},$t={class:`text-xs font-bold`},en={class:`mb-3`},tn={class:`flex items-center justify-between mb-1`},nn={class:`flex items-center`},rn={class:`text-xs font-bold`},an={class:`text-xs text-[var(--el-text-color-secondary)]`},on={class:`mb-3`},sn={class:`flex items-center justify-between mb-1`},cn={class:`flex items-center`},ln={class:`text-xs font-bold`},un={class:`text-xs text-[var(--el-text-color-secondary)]`},dn={key:2,class:`mb-3`},fn={class:`flex items-center justify-between mb-1`},pn={class:`flex items-center`},mn={class:`text-xs font-bold`},hn={class:`text-xs text-[var(--el-text-color-secondary)]`},gn={class:`mb-3`},_n={class:`flex items-center mb-1`},vn={class:`text-xs font-bold`};function yn(e,r,o,s,u,m){let h=d(`info-icon`),g=d(`el-input`),_=d(`el-slider`),v=d(`el-input-number`),y=d(`el-collapse-item`),b=d(`el-collapse`);return l(),t(b,{modelValue:e.activeNames,"onUpdate:modelValue":r[6]||=t=>e.activeNames=t,class:`advanced-collapse`},{default:p(()=>[i(y,{title:e.$t(`producer.name.advancedParams`),name:`advanced`},{default:p(()=>[e.config?.custom?(l(),f(`div`,Jt,[n(`div`,Yt,[n(`span`,Xt,c(e.$t(`producer.name.styleNegative`)),1),i(h,{content:e.$t(`producer.description.styleNegative`)},null,8,[`content`])]),i(g,{modelValue:e.styleNegative,"onUpdate:modelValue":r[0]||=t=>e.styleNegative=t,size:`small`,placeholder:e.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),e.config?.custom&&!e.config?.instrumental?(l(),f(`div`,Zt,[n(`div`,Qt,[n(`span`,$t,c(e.$t(`producer.name.lyricPrompt`)),1),i(h,{content:e.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),i(g,{modelValue:e.lyricPrompt,"onUpdate:modelValue":r[1]||=t=>e.lyricPrompt=t,size:`small`,placeholder:e.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),n(`div`,en,[n(`div`,tn,[n(`div`,nn,[n(`span`,rn,c(e.$t(`producer.name.weirdness`)),1),i(h,{content:e.$t(`producer.description.weirdness`)},null,8,[`content`])]),n(`span`,an,c(e.weirdness??.5),1)]),i(_,{modelValue:e.weirdness,"onUpdate:modelValue":r[2]||=t=>e.weirdness=t,min:0,max:1,step:.01},null,8,[`modelValue`])]),n(`div`,on,[n(`div`,sn,[n(`div`,cn,[n(`span`,ln,c(e.$t(`producer.name.soundStrength`)),1),i(h,{content:e.$t(`producer.description.soundStrength`)},null,8,[`content`])]),n(`span`,un,c(e.soundStrength??.7),1)]),i(_,{modelValue:e.soundStrength,"onUpdate:modelValue":r[3]||=t=>e.soundStrength=t,min:.2,max:1,step:.01},null,8,[`modelValue`])]),e.config?.custom&&!e.config?.instrumental?(l(),f(`div`,dn,[n(`div`,fn,[n(`div`,pn,[n(`span`,mn,c(e.$t(`producer.name.lyricsStrength`)),1),i(h,{content:e.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),n(`span`,hn,c(e.lyricsStrength??.7),1)]),i(_,{modelValue:e.lyricsStrength,"onUpdate:modelValue":r[4]||=t=>e.lyricsStrength=t,min:0,max:1,step:.01},null,8,[`modelValue`])])):a(``,!0),n(`div`,gn,[n(`div`,_n,[n(`span`,vn,c(e.$t(`producer.name.seed`)),1),i(h,{content:e.$t(`producer.description.seed`)},null,8,[`content`])]),i(v,{modelValue:e.seed,"onUpdate:modelValue":r[5]||=t=>e.seed=t,min:0,controls:!1,size:`small`,placeholder:e.$t(`producer.placeholder.seed`),class:`w-full`},null,8,[`modelValue`,`placeholder`])])]),_:1},8,[`title`])]),_:1},8,[`modelValue`])}var bn=V(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=o({name:`ReplaceSectionInput`,components:{ElInputNumber:L,ElImage:A,InfoIcon:Z},computed:{audio(){return this.$store.state.producer?.config?.audio},replaceSectionStart:{get(){return this.$store.state.producer?.config?.replace_section_start},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_start:e})}},replaceSectionEnd:{get(){return this.$store.state.producer?.config?.replace_section_end},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_end:e})}}},methods:{onClick(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`})}}}),Sn={class:`field`},Cn={class:`flex items-center mb-2`},wn={class:`text-sm font-bold m-0`},Tn={key:0,class:`task mb-2`},En={class:`left relative w-[50px] h-[50px] mr-3 flex-shrink-0`},Dn={class:`info flex-1 min-w-0`},On={class:`text-sm font-bold m-0 truncate`},kn={class:`text-xs text-[var(--el-text-color-secondary)] m-0 truncate`},An={class:`flex gap-2`};function jn(e,t,r,o,s,u){let p=d(`info-icon`),g=d(`el-image`),_=d(`el-input-number`),v=m(`loading`);return l(),f(`div`,Sn,[n(`div`,Cn,[n(`h2`,wn,c(e.$t(`producer.name.replaceSection`)),1),i(p,{content:e.$t(`producer.description.replaceSection`)},null,8,[`content`])]),e.audio?(l(),f(`div`,Tn,[n(`div`,{class:`audio flex items-center`,onClick:t[0]||=t=>e.onClick(e.audio)},[h((l(),f(`div`,En,[i(g,{src:e.audio?.image_url,class:`w-full h-full rounded`,fit:`cover`},null,8,[`src`])])),[[v,!e.audio?.audio_url]]),n(`div`,Dn,[n(`h2`,On,c(e.audio?.title),1),n(`p`,kn,c(e.audio?.style),1)])])])):a(``,!0),n(`div`,An,[i(_,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":t[1]||=t=>e.replaceSectionStart=t,class:`flex-1`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionStart`)},null,8,[`modelValue`,`max`,`placeholder`]),i(_,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":t[2]||=t=>e.replaceSectionEnd=t,class:`flex-1`,min:e.replaceSectionStart||0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionEnd`)},null,8,[`modelValue`,`min`,`max`,`placeholder`])])])}var Mn=o({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:V(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:v,ElTabs:E,ElTabPane:D,Consumption:he},emits:[`generate`],computed:{config(){return this.$store.state.producer?.config},mode:{get(){return this.$store.state.producer?.config?.custom?`custom`:`simple`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e===`custom`})}},consumption(){return W(this.config,this.service?.cost)},service(){return this.$store.state.producer?.service},generateButtonText(){let e=this.config?.action;return e===`extend`||e===`upload_extend`?this.$t(`producer.button.extend`):e===`cover`||e===`upload_cover`?this.$t(`producer.button.cover_music`):e===`variation`?this.$t(`producer.button.variation`):e===`replace_section`?this.$t(`producer.button.replace_section`):e===`stems`?this.$t(`producer.button.get_stems`):e===`swap_vocals`?this.$t(`producer.button.swap_vocals`):e===`swap_instrumentals`?this.$t(`producer.button.swap_instrumentals`):this.$t(`producer.button.generate`)}},methods:{onGenerate(){this.$emit(`generate`)},onClearAll(){this.$store.commit(`producer/setConfig`,{custom:this.$store.state.producer?.config?.custom||!1,instrumental:!1,prompt:``,lyric:``,style:``,title:``,model:this.$store.state.producer?.config?.model})}}}),Nn={class:`flex flex-col h-full`},Pn={class:`flex-1 overflow-y-auto p-5`},Fn={class:`pt-2 px-1`},In={class:`pt-2 px-1`},Ln={class:`flex flex-col items-center justify-center px-5 pb-5 gap-2`},Rn={class:`flex gap-2 w-full`};function zn(e,o,s,u,m,h){let g=d(`type-selector`),_=d(`upload-audio`),v=d(`prompt-input`),y=d(`extend-from-input`),b=d(`cover-from-input`),x=d(`replace-section-input`),S=d(`advanced-params`),C=d(`el-tab-pane`),w=d(`lyric-input`),T=d(`style-input`),E=d(`title-input`),D=d(`vocal-gender-selector`),O=d(`el-tabs`),k=d(`consumption`),A=d(`font-awesome-icon`),j=d(`el-button`);return l(),f(`div`,Nn,[n(`div`,Pn,[i(O,{modelValue:e.mode,"onUpdate:modelValue":o[0]||=t=>e.mode=t,class:`producer-mode-tabs`,stretch:``},{default:p(()=>[i(C,{label:e.$t(`producer.mode.simple`),name:`simple`},{default:p(()=>[n(`div`,Fn,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),i(v,{class:`mb-4`}),e.config?.action===`extend`?(l(),t(y,{key:0,class:`mb-4`})):a(``,!0),e.config?.action===`cover`?(l(),t(b,{key:1,class:`mb-4`})):a(``,!0),e.config?.action===`replace_section`?(l(),t(x,{key:2,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`]),i(C,{label:e.$t(`producer.mode.custom`),name:`custom`},{default:p(()=>[n(`div`,In,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),e.config?.instrumental?a(``,!0):(l(),t(w,{key:0,class:`mb-4`})),i(T,{class:`mb-4`}),i(E,{class:`mb-4`}),e.config?.instrumental?a(``,!0):(l(),t(D,{key:1,class:`mb-4`})),e.config?.action===`extend`?(l(),t(y,{key:2,class:`mb-4`})):a(``,!0),e.config?.action===`cover`?(l(),t(b,{key:3,class:`mb-4`})):a(``,!0),e.config?.action===`replace_section`?(l(),t(x,{key:4,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),n(`div`,Ln,[i(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),n(`div`,Rn,[i(j,{class:`flex-1`,onClick:e.onClearAll},{default:p(()=>[i(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),r(` `+c(e.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),i(j,{type:`primary`,class:`flex-1`,round:``,onClick:e.onGenerate},{default:p(()=>[i(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+c(e.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=V(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=R(`producer`),Un=o({name:`TaskPreview`,components:{ElImage:A,ElIcon:S,ElTooltip:k,FontAwesomeIcon:X,VideoPlay:b,VideoPause:x,ElDropdown:ne,ElDropdownMenu:te,ElDropdownItem:I,Loading:y,ApiCodeDialog:de},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1,isFetchingWav:!1,apiCodeVisible:!1,apiCodePath:`/producer/audios`,apiCodeBody:{}}},computed:{loading(){return this.$store.state.producer?.status?.getApplications===Y.Request},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},task(){return this.$store.state.producer?.tasks},audios(){let e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(e=>({...e,action:t})):e},application(){return this.$store.state.producer?.application},active(){return this.$store.state.producer?.tasks?.active}},methods:{useFormatDuring:Q,onViewCode(){let e=this.modelValue?.request||{},t={};Object.entries(e).forEach(([e,n])=>{e===`application_id`||e===`callback_url`||n!=null&&(typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0||(t[e]=n))}),this.apiCodeBody=t,this.apiCodePath=`/producer/audios`,this.apiCodeVisible=!0},onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e?.stopPropagation(),console.debug(`set config`,t),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.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();let n=new URL(t).pathname,r=n.substring(n.lastIndexOf(`/`)+1);fetch(t).then(e=>e.blob()).then(e=>{(0,Vn.saveAs)(e,r)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;let t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(e){console.error(`get videoUrl failed:`,e),q.error(this.$t(`producer.message.getVideoUrlFailed`))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,n)=>{let r={audio_id:e},i=this.credential?.token;if(!i){console.error(`no token specified`),n(Error(`No token specified`));return}J.video(r,{token:i}).then(e=>{let r=e.data?.data?.video_url;r?t(r):n(Error(`Video URL not found in response`))}).catch(e=>{n(e)})})},onPreview(e,t){e?.stopPropagation(),window.open(t,`_blank`)},async onGetStems(e){await this.onGenerateAudioUrl(`stems`,e)},onCover(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:`cover`,audio:e,audio_id:e.id})},onVariation(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,style:e.style,action:`variation`,audio:e,audio_id:e.id})},async onSwapVocals(e){await this.onGenerateAudioUrl(`swap_vocals`,e)},async onSwapInstrumentals(e){await this.onGenerateAudioUrl(`swap_instrumentals`,e)},async onGetAllStems(e){await this.onGenerateAudioUrl(`all_stems`,e)},onReplaceSection(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.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)})},async handleWavDownload(e){if(!e?.id||this.isFetchingWav)return;let t=this.credential?.token;if(t)try{this.isFetchingWav=!0,q.info(this.$t(`producer.message.fetchingWav`));let n=(await J.wav({audio_id:e.id},{token:t})).data?.data,r=Array.isArray(n)?n[0]?.file_url:n?.file_url||n?.audio_url;r?this.onDownload(null,r):q.error(this.$t(`producer.message.fetchWavFailed`))}catch{q.error(this.$t(`producer.message.fetchWavFailed`))}finally{this.isFetchingWav=!1}},async onGenerateAudioUrl(e,t){let n={action:e,audio_id:t,callback_url:Hn},r=this.credential?.token;if(!r){console.error(`no token specified`);return}q.info(this.$t(`producer.message.startingTask`)),J.audio(n,{token:r}).then(()=>{q.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{q.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{let e=document.querySelector(`.tasks`);e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug(`loading`);return}await this.$store.dispatch(`producer/getTasks`,{limit:30,offset:0})}}}),Wn={class:`task`},Gn=[`onClick`],Kn={class:`left`},qn=[`onClick`],Jn=[`onClick`],Yn={key:2,class:`duration`},Xn={class:`info`},Zn={class:`title`},Qn={class:`style`},$n={class:`right`},er={class:`el-dropdown-link`},tr={class:`flex items-center min-w-[120px]`},nr={class:`flex items-center min-w-[120px]`},rr={class:`el-dropdown-link`};function ir(e,o,u,v,y,b){let x=d(`el-image`),S=d(`video-pause`),C=d(`el-icon`),w=d(`video-play`),T=d(`font-awesome-icon`),E=d(`el-tooltip`),D=d(`Loading`),O=d(`el-dropdown-item`),k=d(`el-dropdown-menu`),A=d(`el-dropdown`),j=d(`api-code-dialog`),M=m(`loading`);return l(),f(`div`,Wn,[(l(!0),f(g,null,s(e.audios,o=>(l(),f(`div`,{key:o.id,class:`audio`,onClick:_(t=>e.onClick(o),[`stop`])},[h((l(),f(`div`,Kn,[i(x,{src:o?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),o?.audio_url&&e.$store.state?.producer?.audio?.id===o.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),f(`div`,{key:0,class:`overlay`,onClick:_(t=>e.onPause(o),[`stop`])},[i(C,null,{default:p(()=>[i(S)]),_:1})],8,qn)):a(``,!0),o?.audio_url&&(e.$store.state?.producer?.audio?.id!==o.id||e.$store.state?.producer?.audio?.id===o.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),f(`div`,{key:1,class:`overlay`,onClick:_(t=>e.onPlay(o),[`stop`])},[i(C,null,{default:p(()=>[i(w)]),_:1})],8,Jn)):a(``,!0),o?.duration?(l(),f(`div`,Yn,c(e.useFormatDuring(o?.duration)),1)):a(``,!0)])),[[M,!o?.audio_url]]),n(`div`,Xn,[n(`h2`,Zn,c(o?.title),1),n(`p`,Qn,c(o?.style),1)]),n(`div`,$n,[i(A,null,{dropdown:p(()=>[i(k,null,{default:p(()=>[i(O,{disabled:e.isFetchingVideoUrl,onClick:t=>e.handleVideoDownload(o)},{default:p(()=>[n(`div`,tr,[e.isFetchingVideoUrl?(l(),t(C,{key:0,class:`is-loading mr-2`},{default:p(()=>[i(D)]),_:1})):a(``,!0),n(`span`,null,c(e.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),o?.audio_url?(l(),t(O,{key:0,onClick:_(t=>e.onDownload(t,o?.audio_url),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{disabled:e.isFetchingWav,onClick:t=>e.handleWavDownload(o)},{default:p(()=>[n(`div`,nr,[e.isFetchingWav?(l(),t(C,{key:0,class:`is-loading mr-2`},{default:p(()=>[i(D)]),_:1})):a(``,!0),n(`span`,null,c(e.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:p(()=>[n(`span`,er,[i(E,{effect:`dark`,content:e.$t(`producer.button.download`),placement:`top`},{default:p(()=>[o?.audio_url||o?.video_url?(l(),t(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),i(A,null,{dropdown:p(()=>[i(k,null,{default:p(()=>[o?.audio_url?(l(),t(O,{key:0,onClick:_(t=>e.onExtend(t,o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):a(``,!0),o.id?(l(),t(O,{key:1,onClick:_(t=>e.onGetStems(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),o.id?(l(),t(O,{key:2,onClick:_(t=>e.onGetAllStems(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:_(t=>e.onCover(o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),o?.id?(l(),t(O,{key:3,onClick:_(t=>e.onVariation(o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):a(``,!0),o?.id?(l(),t(O,{key:4,onClick:_(t=>e.onSwapVocals(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):a(``,!0),o?.id?(l(),t(O,{key:5,onClick:_(t=>e.onSwapInstrumentals(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):a(``,!0),o?.id?(l(),t(O,{key:6,onClick:_(t=>e.onReplaceSection(o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:_(e.onViewCode,[`stop`])},{default:p(()=>[i(T,{icon:`fa-solid fa-code`,class:`mr-1`}),r(` `+c(e.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:p(()=>[n(`span`,rr,[i(E,{effect:`dark`,content:e.$t(`producer.button.more`),placement:`top`},{default:p(()=>[o?.audio_url||o?.video_url?(l(),t(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Gn))),128)),i(j,{visible:e.apiCodeVisible,"onUpdate:visible":o[0]||=t=>e.apiCodeVisible=t,method:`POST`,path:e.apiCodePath,body:e.apiCodeBody,token:e.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ar=o({name:`RecentPanel`,components:{ElSkeletonItem:re,ElSkeleton:ie,TaskPreview:V(Un,[[`render`,ir]]),Player:_e,NoTasks:me,ScrollList:ue},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.producer?.tasks,items:this.$store.state.producer?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),or={key:0,class:`tasks`},sr={class:`left w-[70px] p-[10px] flex items-center`},$={class:`main w-[calc(100%-70px)] flex-1 p-[10px]`},cr={key:2,class:`w-full flex-1 flex items-center justify-center`},lr={class:`h-20`};function ur(e,r,o,c,m,_){let v=d(`el-skeleton-item`),y=d(`el-skeleton`),b=d(`task-preview`),x=d(`scroll-list`),S=d(`no-tasks`),C=d(`player`);return l(),f(g,null,[e.tasks?.items===void 0?(l(),f(`div`,or,[(l(),f(g,null,s(3,e=>n(`div`,{key:e,class:`flex`},[n(`div`,sr,[i(y,{animated:``},{template:p(()=>[i(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),n(`div`,$,[i(y,{animated:``},{template:p(()=>[i(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),i(v,{variant:`text`})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(l(),t(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:e.loading,onReachTop:r[0]||=t=>e.$emit(`reach-top`)},{default:p(()=>[(l(!0),f(g,null,s(e.tasks?.items,(e,n)=>(l(),t(b,{key:n,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):a(``,!0),e.tasks?.items?.length===0?(l(),f(`div`,cr,[i(S)])):a(``,!0),h(n(`div`,lr,[i(C,{namespace:`producer`})],512),[[u,!!e.$store?.state?.producer?.audio?.object]])],64)}var dr=V(ar,[[`render`,ur]]),fr=o({name:`TaskPreview`,components:{IconPicture:C,ElImage:A,ElAvatar:j,ElIcon:S},computed:{audio(){return this.$store.state.producer?.audio}}}),pr={key:0,class:`size-full overflow-hidden`},mr={class:`relative h-[300px]`},hr={class:`flex items-center justify-center size-full bg-[var(--el-bg-color)]`},gr={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`},_r={class:`p-4`},vr={class:`flex items-center font-bold mb-2`},yr={class:`text-[var(--el-text-color-regular)] mb-2`},br={class:`text-xs text-[var(--el-text-color-regular)]`},xr={class:`mt-4 text-sm leading-[25px] whitespace-pre-wrap`},Sr={key:1,class:`w-full h-full`};function Cr(e,t,r,a,o,s){let u=d(`icon-picture`),m=d(`el-icon`),h=d(`el-image`),g=d(`el-avatar`);return e.audio?.object?(l(),f(`div`,pr,[n(`div`,mr,[i(h,{src:e.audio.image_url,fit:`cover`,class:`size-full`},{error:p(()=>[n(`div`,hr,[i(m,{class:`text-3xl`},{default:p(()=>[i(u)]),_:1})])]),_:1},8,[`src`]),n(`h2`,gr,c(e.audio?.title),1)]),n(`div`,_r,[n(`div`,vr,[i(g,{size:30,src:e.audio?.image_url,class:`mr-2`},null,8,[`src`]),n(`span`,null,c(e.audio?.title),1)]),n(`p`,yr,c(e.audio?.style),1),n(`p`,br,c(e.$dayjs.format(e.audio?.created_at)),1),n(`div`,xr,[n(`p`,null,c(e.audio?.lyric),1)])])])):(l(),f(`div`,Sr))}var wr=V(fr,[[`render`,Cr]]),Tr=R(`producer`),Er=o({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:dr,PreviewPanel:wr},mixins:[B],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===Y.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===Y.Request||this.fetchingTasks},service(){return this.$store.state.producer.service},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},initializing(){return this.$store.state.producer.status.getApplications===Y.Request},needApply(){return this.$store.state.producer.status.getApplications===Y.Success&&!this.application},application(){return this.$store.state.producer.application},tasks(){return this.$store.state.producer.tasks},applications(){return this.$store.state.producer.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 fe({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(`producer/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplications`),await this.$store.dispatch(`producer/getApplications`),console.debug(`end onGetApplications`),await this.onGetTasks()},onApply(){z.create({application:this.application}).then(({data:e})=>{this.application=e,q.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&q.error(this.$t(`application.message.alreadyApplied`))})},async onScrollDown(){await this.$nextTick();let 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);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`producer/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerateAudio(){if(!G(this.uploadTracker,e=>this.$t(e),e=>q.warning(e)))return;let e={...this.config,callback_url:Tr},t=this.credential?.token;if(!t){console.error(`no token specified`);return}q.info(this.$t(`producer.message.startingTask`)),H(`producer`,J.audio(e,{token:t})).then(()=>{q.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{q.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function Dr(e,n,r,a,o,s){let c=d(`config-panel`),u=d(`recent-panel`),f=d(`preview-panel`),m=d(`layout`);return l(),t(m,null,{config:p(()=>[i(c,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:p(()=>[i(u,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:p(()=>[i(f)]),_:1})}var Or=V(Er,[[`render`,Dr],[`__scopeId`,`data-v-a766e27a`]]);export{Or as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,D as t,E as n,M as r,N as i,O as a,P as o,Q as s,Ut as c,X as l,_ as u,et as d,k as f,lt as p,tt as m,ut as h,x as g,y as _}from"./vendor-chart-mdwpew_o.js";import{t as v}from"./button-DWzbdjZV.js";import{F as y,X as b,Y as x,tt as S,z as C}from"./use-deprecated-CPfQu7wa.js";import{r as w,t as T}from"./select-CyfjsVYT.js";import{n as E,t as D}from"./tabs-DDqt-7al.js";import{t as O}from"./upload-CIsl9b3M.js";import{t as k}from"./tooltip-C3PYfh8V.js";import{t as A}from"./image-BhCAlGZE.js";import{t as j}from"./avatar-DJGt2zYX.js";import{n as M,r as N}from"./radio-IJQsW93X.js";import{n as ee,t as P}from"./collapse-DzxsO3Mt.js";import{t as F}from"./drawer-BvYPSxXh.js";import{n as I,r as te,t as ne}from"./dropdown-Dh3U4lax.js";import{t as L}from"./input-number-De_zhvd-.js";import{n as re,t as ie}from"./skeleton-Cn4UY-T8.js";import{t as ae}from"./slider-C8p-p_jG.js";import{t as oe}from"./switch-DfeNNIjH.js";import{Mn as se,hi as R}from"./constants-EAH6CsV9.js";import{An as z,At as B,E as V,Fn as H,Ir as U,Nt as W,Ot as G,Sr as K,kr as q,kt as ce,nn as J,yr as Y}from"./index-WLGDsbco.js";import{t as X}from"./index.es-DEMCbRdu.js";import{n as le}from"./taskDrawerMixin-Cr17Yxqk.js";import{i as Z,n as ue,r as de,t as fe}from"./pagination-B3UvJKZu.js";import{n as pe,t as me}from"./NoTasks-HGgmWayY.js";import{t as he}from"./Consumption-Dv4UTeE5.js";import{n as ge,r as Q,t as _e}from"./Player-Dg2tf_iI.js";var ve=o({name:`LayoutProducer`,components:{ElDrawer:F,ElButton:v,FontAwesomeIcon:X},mixins:[le],data(){return{preview:!1}},computed:{}}),ye={class:`main flex flex-row flex-1`},be={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},xe={class:`result h-full flex flex-col flex-1 min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`},Se={class:`preview h-full w-[300px] flex flex-col`};function Ce(t,r,a,o,s,c){let m=d(`font-awesome-icon`),g=d(`el-button`),_=d(`el-drawer`);return l(),f(`div`,ye,[n(`div`,be,[e(t.$slots,`config`,{},void 0,!0)]),n(`div`,xe,[e(t.$slots,`result`,{},void 0,!0)]),n(`div`,Se,[e(t.$slots,`preview`,{},void 0,!0)]),h(i(g,{circle:``,class:`menu`,onClick:r[0]||=e=>t.drawer=!0},{default:p(()=>[i(m,{icon:`fa-solid fa-magic`})]),_:1},512),[[u,!t.tasksEmpty]]),i(_,{modelValue:t.drawer,"onUpdate:modelValue":r[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:p(()=>[e(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=V(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=o({name:`TypeSelector`,components:{ElSelect:w,ElOption:T,ElSwitch:oe,InfoIcon:Z},data(){return{options:[{label:`FUZZ-2.0 Pro`,value:`FUZZ-2.0 Pro`,desc:this.$t(`producer.model.fuzz20proDesc`)},{label:`FUZZ-2.0`,value:`FUZZ-2.0`,desc:this.$t(`producer.model.fuzz20desc`)},{label:`FUZZ-2.0 Raw`,value:`FUZZ-2.0 Raw`,desc:this.$t(`producer.model.fuzz20rawDesc`)},{label:`FUZZ-1.1 Pro`,value:`FUZZ-1.1 Pro`,desc:this.$t(`producer.model.fuzz11proDesc`)},{label:`FUZZ-1.1`,value:`FUZZ-1.1`,desc:this.$t(`producer.model.fuzz11desc`)},{label:`FUZZ-1.0 Pro`,value:`FUZZ-1.0 Pro`,desc:this.$t(`producer.model.fuzz10proDesc`)},{label:`FUZZ-1.0`,value:`FUZZ-1.0`,desc:this.$t(`producer.model.fuzz10desc`)},{label:`FUZZ-0.8`,value:`FUZZ-0.8`,desc:this.$t(`producer.model.fuzz08desc`)}]}},computed:{custom:{get(){return this.$store.state.producer?.config?.custom||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e})}},instrumental:{get(){return this.$store.state.producer?.config?.instrumental||!1},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,instrumental:e})}},model:{get(){return this.$store.state.producer?.config?.model},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e})}}},mounted(){this.model||=se}}),Ee={class:`mb-3`},De={class:`flex items-center mb-1`},Oe={class:`text-sm font-bold`},ke={class:`model-option`},Ae={class:`model-option-name`},je={class:`model-option-desc`},Me={key:0,class:`flex items-center justify-between mb-3`},Ne={class:`flex items-center`},Pe={class:`text-sm font-bold`};function Fe(e,r,o,u,m,h){let _=d(`el-option`),v=d(`el-select`),y=d(`info-icon`),b=d(`el-switch`);return l(),f(`div`,null,[n(`div`,Ee,[n(`div`,De,[n(`span`,Oe,c(e.$t(`producer.name.model`)),1)]),i(v,{modelValue:e.model,"onUpdate:modelValue":r[0]||=t=>e.model=t,class:`w-full model-select`,size:`default`,placeholder:e.$t(`producer.placeholder.select`)},{default:p(()=>[(l(!0),f(g,null,s(e.options,e=>(l(),t(_,{key:e.value,label:e.label,value:e.value},{default:p(()=>[n(`div`,ke,[n(`span`,Ae,c(e.label),1),n(`span`,je,c(e.desc),1)])]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])]),e.custom?(l(),f(`div`,Me,[n(`div`,Ne,[n(`span`,Pe,c(e.$t(`producer.name.instrumental`)),1),i(y,{content:e.$t(`producer.description.instrumental`)},null,8,[`content`])]),i(b,{modelValue:e.instrumental,"onUpdate:modelValue":r[1]||=t=>e.instrumental=t},null,8,[`modelValue`])])):a(``,!0)])}var Ie=V(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=o({name:`UploadAudio`,components:{ElUpload:O,ElButton:v,ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z,FontAwesomeIcon:X},mixins:[ce],emits:[`change`],data(){return{fileList:[],uploadUrl:K()+`/api/v1/files/`,audioPreviewUrl:null,uploading:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},urls(){return this.fileList.map(e=>e?.response?.file_url)},hasUploadedAudio(){let e=this.$store.state.producer?.config?.action;return e===`upload_extend`||e===`upload_cover`},uploadAction:{get(){return this.$store.state.producer?.config?.action||`upload_extend`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,action:e})}}},watch:{urls:{handler(e){this.$emit(`change`,e)}}},methods:{onExceed(){q.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,q.error(this.$t(`producer.message.uploadReferencesError`))},async onSuccess(){let e=this.urls?.[0];if(!e){this.uploading=!1;return}this.audioPreviewUrl=e,await this.onGenerateAudioId(e)},async onGenerateAudioId(e){let t={audio_url:e},n=this.credential?.token;if(!n){console.error(`no token specified`),this.uploading=!1;return}this.uploading=!0,q.info(this.$t(`producer.message.startingUploadAudio`));try{let e=(await J.upload(t,{token:n})).data?.data.audio_id;this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,audio_id:e,action:`upload_extend`}),q.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){q.error(e?.response?.data?.error?.message||this.$t(`producer.message.startUploadAudioFailed`))}finally{this.uploading=!1}}}}),Re={class:`relative`},ze={class:`flex justify-between items-center mb-2`},Be={class:`flex justify-start items-center`},Ve={class:`text-sm font-bold`},He={key:0,class:`mb-2`},Ue=[`src`],We={key:1,class:`mt-1`};function Ge(e,t,o,s,u,m){let h=d(`info-icon`),g=d(`font-awesome-icon`),_=d(`el-button`),v=d(`el-upload`),y=d(`el-radio-button`),b=d(`el-radio-group`);return l(),f(`div`,Re,[n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.$t(`producer.name.referenceAudios`)),1),i(h,{content:e.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),i(v,{"file-list":e.fileList,"onUpdate:fileList":t[0]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper inline-upload`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{default:p(()=>[i(_,{round:``,type:`primary`,size:`small`,loading:e.uploading},{default:p(()=>[i(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+c(e.$t(`producer.button.uploadAudios`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])]),e.audioPreviewUrl?(l(),f(`div`,He,[n(`audio`,{src:e.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):a(``,!0),e.hasUploadedAudio?(l(),f(`div`,We,[i(b,{modelValue:e.uploadAction,"onUpdate:modelValue":t[1]||=t=>e.uploadAction=t,size:`small`},{default:p(()=>[i(y,{value:`upload_extend`},{default:p(()=>[r(c(e.$t(`producer.button.extend`)),1)]),_:1}),i(y,{value:`upload_cover`},{default:p(()=>[r(c(e.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):a(``,!0)])}var Ke=V(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=o({name:`PromptInput`,components:{PromptTextarea:pe},computed:{prompt:{get(){return this.$store.state.producer?.config?.prompt},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Je(e,n,r,i,a,o){let s=d(`prompt-textarea`);return l(),t(s,{modelValue:e.prompt,"onUpdate:modelValue":n[0]||=t=>e.prompt=t,title:e.$t(`producer.name.songDescription`),info:e.$t(`producer.description.prompt`),placeholder:e.$t(`producer.placeholder.prompt`),"min-rows":5,"max-rows":14},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Ye=V(qe,[[`render`,Je]]),Xe=o({name:`LyricInput`,components:{ElInput:U,ElButton:v,FontAwesomeIcon:X,InfoIcon:Z},data(){return{generatingLyrics:!1}},computed:{lyric:{get(){return this.$store.state.producer?.config?.lyric},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:e})}},config(){return this.$store.state.producer?.config},credential(){return this.$store.state.producer?.credential}},mounted(){this.lyric||=``},methods:{async onGenerateLyrics(){let e=this.credential?.token;if(!e)return;let t=this.config?.style||this.config?.title||`a beautiful song`;this.generatingLyrics=!0,q.info(this.$t(`producer.message.generatingLyrics`));try{let n=(await J.lyric({prompt:t},{token:e})).data?.data;n?.text&&(this.lyric=n.text,n?.title&&!this.config?.title&&this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric:n.text,title:n.title}),q.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{q.error(this.$t(`producer.message.generateLyricsFailed`))}finally{this.generatingLyrics=!1}}}}),Ze={class:`field`},Qe={class:`flex items-center justify-between mb-1`},$e={class:`flex items-center`},et={class:`text-sm font-bold`};function tt(e,o,s,u,m,h){let g=d(`info-icon`),_=d(`font-awesome-icon`),v=d(`el-button`),y=d(`el-input`);return l(),f(`div`,Ze,[n(`div`,Qe,[n(`div`,$e,[n(`span`,et,c(e.$t(`producer.name.lyrics`)),1),i(g,{content:e.$t(`producer.description.lyrics`)},null,8,[`content`])]),e.config?.action===`extend`?a(``,!0):(l(),t(v,{key:0,size:`small`,loading:e.generatingLyrics,round:``,onClick:e.onGenerateLyrics},{default:p(()=>[e.generatingLyrics?a(``,!0):(l(),t(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),r(` `+c(e.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),e.config?.action===`extend`?(l(),t(y,{key:1,modelValue:e.lyric,"onUpdate:modelValue":o[1]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(l(),t(y,{key:0,modelValue:e.lyric,"onUpdate:modelValue":o[0]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=V(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=o({name:`StyleInput`,components:{ElInput:U,InfoIcon:Z},computed:{style:{get(){return this.$store.state.producer?.config?.style},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style:e})}}}}),it={class:`field`},at={class:`flex items-center justify-between mb-1`},ot={class:`flex items-center`},st={class:`text-sm font-bold`};function ct(e,t,r,a,o,s){let u=d(`info-icon`),p=d(`el-input`);return l(),f(`div`,it,[n(`div`,at,[n(`div`,ot,[n(`span`,st,c(e.$t(`producer.name.style`)),1),i(u,{content:e.$t(`producer.description.style`)},null,8,[`content`])])]),i(p,{modelValue:e.style,"onUpdate:modelValue":t[0]||=t=>e.style=t,rows:2,type:`textarea`,placeholder:e.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=V(rt,[[`render`,ct]]),ut=o({name:`TitleInput`,components:{ElInput:U,InfoIcon:Z},computed:{title:{get(){return this.$store.state.producer?.config?.title},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,title:e})}}}}),dt={class:`field`},ft={class:`flex items-center mb-1`},pt={class:`text-sm font-bold`};function mt(e,t,r,a,o,s){let u=d(`info-icon`),p=d(`el-input`);return l(),f(`div`,dt,[n(`div`,ft,[n(`span`,pt,c(e.$t(`producer.name.title`)),1),i(u,{content:e.$t(`producer.description.title`)},null,8,[`content`])]),i(p,{modelValue:e.title,"onUpdate:modelValue":t[0]||=t=>e.title=t,placeholder:e.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=V(ut,[[`render`,mt]]),gt=o({name:`ExtendFromInput`,components:{ElImage:A,ElIcon:S,ElInputNumber:L,VideoPlay:b,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),_t={class:`field`},vt={class:`box`},yt={class:`title font-bold`},bt={class:`input-wrapper`},xt={class:`task`},St={class:`left`},Ct={key:2,class:`duration`},wt={class:`info`},Tt={class:`title`},Et={class:`style`};function Dt(e,t,r,o,s,u){let g=d(`el-input-number`),_=d(`el-image`),v=d(`video-pause`),y=d(`el-icon`),b=d(`video-play`),x=m(`loading`);return l(),f(`div`,_t,[n(`div`,vt,[n(`h2`,yt,c(e.$t(`producer.name.extend`)),1),n(`div`,bt,[i(g,{modelValue:e.value,"onUpdate:modelValue":t[0]||=t=>e.value=t,class:`value`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.extend.continue_at`),onChange:e.handleChange},null,8,[`modelValue`,`max`,`placeholder`,`onChange`])])]),n(`div`,xt,[e.audio?(l(),f(`div`,{key:0,class:`audio`,onClick:t[3]||=t=>e.onClick(e.audio)},[h((l(),f(`div`,St,[i(_,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),f(`div`,{key:0,class:`overlay`,onClick:t[1]||=t=>e.onPause(e.audio)},[i(y,null,{default:p(()=>[i(v)]),_:1})])):a(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),f(`div`,{key:1,class:`overlay`,onClick:t[2]||=t=>e.onPlay(e.audio)},[i(y,null,{default:p(()=>[i(b)]),_:1})])):a(``,!0),e.audio?.duration?(l(),f(`div`,Ct,c(e.useFormatDuring(e.audio?.duration)),1)):a(``,!0)])),[[x,!e.audio?.audio_url]]),n(`div`,wt,[n(`h2`,Tt,c(e.audio?.title),1),n(`p`,Et,c(e.audio?.style),1)])])):a(``,!0)])])}var Ot=V(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=o({name:`CoverFromInput`,components:{ElImage:A,ElIcon:S,VideoPlay:b,VideoPause:x},data(){return{}},computed:{audio(){return this.$store.state.producer?.config?.audio},value:{get(){return this.$store.state.producer?.config?.continue_at},set(e){console.debug(`set continue_at`,e),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,continue_at:e?parseInt(e):void 0})}}},mounted(){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:Q,onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})}}}),At={class:`field`},jt={class:`box`},Mt={class:`title font-bold`},Nt={class:`task`},Pt={class:`left`},Ft={key:2,class:`duration`},It={class:`info`},Lt={class:`title`},Rt={class:`style`};function zt(e,t,r,o,s,u){let g=d(`el-image`),_=d(`video-pause`),v=d(`el-icon`),y=d(`video-play`),b=m(`loading`);return l(),f(`div`,At,[n(`div`,jt,[n(`h2`,Mt,c(e.$t(`producer.name.cover`)),1)]),n(`div`,Nt,[e.audio?(l(),f(`div`,{key:0,class:`audio`,onClick:t[2]||=t=>e.onClick(e.audio)},[h((l(),f(`div`,Pt,[i(g,{src:e.audio?.image_url,class:`cover`,fit:`cover`},null,8,[`src`]),e.audio?.audio_url&&e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),f(`div`,{key:0,class:`overlay`,onClick:t[0]||=t=>e.onPause(e.audio)},[i(v,null,{default:p(()=>[i(_)]),_:1})])):a(``,!0),e.audio?.audio_url&&(e.$store.state?.producer?.audio?.id!==e.audio.id||e.$store.state?.producer?.audio?.id===e.audio.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),f(`div`,{key:1,class:`overlay`,onClick:t[1]||=t=>e.onPlay(e.audio)},[i(v,null,{default:p(()=>[i(y)]),_:1})])):a(``,!0),e.audio?.duration?(l(),f(`div`,Ft,c(e.useFormatDuring(e.audio?.duration)),1)):a(``,!0)])),[[b,!e.audio?.audio_url]]),n(`div`,It,[n(`h2`,Lt,c(e.audio?.title),1),n(`p`,Rt,c(e.audio?.style),1)])])):a(``,!0)])])}var Bt=V(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=o({name:`VocalGenderSelector`,components:{ElRadioGroup:N,ElRadioButton:M,InfoIcon:Z},computed:{vocalGender:{get(){return this.$store.state.producer?.config?.vocal_gender||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,vocal_gender:e||void 0})}}}}),Ht={class:`mb-2`},Ut={class:`flex items-center mb-1`},Wt={class:`text-sm font-bold`};function Gt(e,t,a,o,s,u){let m=d(`info-icon`),h=d(`el-radio-button`),g=d(`el-radio-group`);return l(),f(`div`,Ht,[n(`div`,Ut,[n(`span`,Wt,c(e.$t(`producer.name.vocalGender`)),1),i(m,{content:e.$t(`producer.description.vocalGender`)},null,8,[`content`])]),i(g,{modelValue:e.vocalGender,"onUpdate:modelValue":t[0]||=t=>e.vocalGender=t},{default:p(()=>[i(h,{value:``},{default:p(()=>[r(c(e.$t(`producer.gender.auto`)),1)]),_:1}),i(h,{value:`f`},{default:p(()=>[r(c(e.$t(`producer.gender.female`)),1)]),_:1}),i(h,{value:`m`},{default:p(()=>[r(c(e.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=V(Vt,[[`render`,Gt]]),qt=o({name:`AdvancedParams`,components:{ElCollapse:P,ElCollapseItem:ee,ElInput:U,ElSlider:ae,ElInputNumber:L,InfoIcon:Z},data(){return{activeNames:[]}},computed:{config(){return this.$store.state.producer?.config},styleNegative:{get(){return this.$store.state.producer?.config?.style_negative||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,style_negative:e||void 0})}},lyricPrompt:{get(){return this.$store.state.producer?.config?.lyric_prompt||``},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyric_prompt:e||void 0})}},weirdness:{get(){return this.$store.state.producer?.config?.weirdness??.5},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,weirdness:e})}},soundStrength:{get(){return this.$store.state.producer?.config?.sound_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,sound_strength:e})}},lyricsStrength:{get(){return this.$store.state.producer?.config?.lyrics_strength??.7},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,lyrics_strength:e})}},seed:{get(){return this.$store.state.producer?.config?.seed},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,seed:e})}}},mounted(){let e=this.$store.state.producer?.config;if(!e)return;let t={};typeof e.weirdness==`number`&&e.weirdness>1&&(t.weirdness=e.weirdness/100),typeof e.sound_strength==`number`&&e.sound_strength>1&&(t.sound_strength=e.sound_strength/100),typeof e.lyrics_strength==`number`&&e.lyrics_strength>1&&(t.lyrics_strength=e.lyrics_strength/100),Object.keys(t).length>0&&this.$store.commit(`producer/setConfig`,{...e,...t})}}),Jt={key:0,class:`mb-3`},Yt={class:`flex items-center mb-1`},Xt={class:`text-xs font-bold`},Zt={key:1,class:`mb-3`},Qt={class:`flex items-center mb-1`},$t={class:`text-xs font-bold`},en={class:`mb-3`},tn={class:`flex items-center justify-between mb-1`},nn={class:`flex items-center`},rn={class:`text-xs font-bold`},an={class:`text-xs text-[var(--el-text-color-secondary)]`},on={class:`mb-3`},sn={class:`flex items-center justify-between mb-1`},cn={class:`flex items-center`},ln={class:`text-xs font-bold`},un={class:`text-xs text-[var(--el-text-color-secondary)]`},dn={key:2,class:`mb-3`},fn={class:`flex items-center justify-between mb-1`},pn={class:`flex items-center`},mn={class:`text-xs font-bold`},hn={class:`text-xs text-[var(--el-text-color-secondary)]`},gn={class:`mb-3`},_n={class:`flex items-center mb-1`},vn={class:`text-xs font-bold`};function yn(e,r,o,s,u,m){let h=d(`info-icon`),g=d(`el-input`),_=d(`el-slider`),v=d(`el-input-number`),y=d(`el-collapse-item`),b=d(`el-collapse`);return l(),t(b,{modelValue:e.activeNames,"onUpdate:modelValue":r[6]||=t=>e.activeNames=t,class:`advanced-collapse`},{default:p(()=>[i(y,{title:e.$t(`producer.name.advancedParams`),name:`advanced`},{default:p(()=>[e.config?.custom?(l(),f(`div`,Jt,[n(`div`,Yt,[n(`span`,Xt,c(e.$t(`producer.name.styleNegative`)),1),i(h,{content:e.$t(`producer.description.styleNegative`)},null,8,[`content`])]),i(g,{modelValue:e.styleNegative,"onUpdate:modelValue":r[0]||=t=>e.styleNegative=t,size:`small`,placeholder:e.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),e.config?.custom&&!e.config?.instrumental?(l(),f(`div`,Zt,[n(`div`,Qt,[n(`span`,$t,c(e.$t(`producer.name.lyricPrompt`)),1),i(h,{content:e.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),i(g,{modelValue:e.lyricPrompt,"onUpdate:modelValue":r[1]||=t=>e.lyricPrompt=t,size:`small`,placeholder:e.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):a(``,!0),n(`div`,en,[n(`div`,tn,[n(`div`,nn,[n(`span`,rn,c(e.$t(`producer.name.weirdness`)),1),i(h,{content:e.$t(`producer.description.weirdness`)},null,8,[`content`])]),n(`span`,an,c(e.weirdness??.5),1)]),i(_,{modelValue:e.weirdness,"onUpdate:modelValue":r[2]||=t=>e.weirdness=t,min:0,max:1,step:.01},null,8,[`modelValue`])]),n(`div`,on,[n(`div`,sn,[n(`div`,cn,[n(`span`,ln,c(e.$t(`producer.name.soundStrength`)),1),i(h,{content:e.$t(`producer.description.soundStrength`)},null,8,[`content`])]),n(`span`,un,c(e.soundStrength??.7),1)]),i(_,{modelValue:e.soundStrength,"onUpdate:modelValue":r[3]||=t=>e.soundStrength=t,min:.2,max:1,step:.01},null,8,[`modelValue`])]),e.config?.custom&&!e.config?.instrumental?(l(),f(`div`,dn,[n(`div`,fn,[n(`div`,pn,[n(`span`,mn,c(e.$t(`producer.name.lyricsStrength`)),1),i(h,{content:e.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),n(`span`,hn,c(e.lyricsStrength??.7),1)]),i(_,{modelValue:e.lyricsStrength,"onUpdate:modelValue":r[4]||=t=>e.lyricsStrength=t,min:0,max:1,step:.01},null,8,[`modelValue`])])):a(``,!0),n(`div`,gn,[n(`div`,_n,[n(`span`,vn,c(e.$t(`producer.name.seed`)),1),i(h,{content:e.$t(`producer.description.seed`)},null,8,[`content`])]),i(v,{modelValue:e.seed,"onUpdate:modelValue":r[5]||=t=>e.seed=t,min:0,controls:!1,size:`small`,placeholder:e.$t(`producer.placeholder.seed`),class:`w-full`},null,8,[`modelValue`,`placeholder`])])]),_:1},8,[`title`])]),_:1},8,[`modelValue`])}var bn=V(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=o({name:`ReplaceSectionInput`,components:{ElInputNumber:L,ElImage:A,InfoIcon:Z},computed:{audio(){return this.$store.state.producer?.config?.audio},replaceSectionStart:{get(){return this.$store.state.producer?.config?.replace_section_start},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_start:e})}},replaceSectionEnd:{get(){return this.$store.state.producer?.config?.replace_section_end},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,replace_section_end:e})}}},methods:{onClick(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`})}}}),Sn={class:`field`},Cn={class:`flex items-center mb-2`},wn={class:`text-sm font-bold m-0`},Tn={key:0,class:`task mb-2`},En={class:`left relative w-[50px] h-[50px] mr-3 flex-shrink-0`},Dn={class:`info flex-1 min-w-0`},On={class:`text-sm font-bold m-0 truncate`},kn={class:`text-xs text-[var(--el-text-color-secondary)] m-0 truncate`},An={class:`flex gap-2`};function jn(e,t,r,o,s,u){let p=d(`info-icon`),g=d(`el-image`),_=d(`el-input-number`),v=m(`loading`);return l(),f(`div`,Sn,[n(`div`,Cn,[n(`h2`,wn,c(e.$t(`producer.name.replaceSection`)),1),i(p,{content:e.$t(`producer.description.replaceSection`)},null,8,[`content`])]),e.audio?(l(),f(`div`,Tn,[n(`div`,{class:`audio flex items-center`,onClick:t[0]||=t=>e.onClick(e.audio)},[h((l(),f(`div`,En,[i(g,{src:e.audio?.image_url,class:`w-full h-full rounded`,fit:`cover`},null,8,[`src`])])),[[v,!e.audio?.audio_url]]),n(`div`,Dn,[n(`h2`,On,c(e.audio?.title),1),n(`p`,kn,c(e.audio?.style),1)])])])):a(``,!0),n(`div`,An,[i(_,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":t[1]||=t=>e.replaceSectionStart=t,class:`flex-1`,min:0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionStart`)},null,8,[`modelValue`,`max`,`placeholder`]),i(_,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":t[2]||=t=>e.replaceSectionEnd=t,class:`flex-1`,min:e.replaceSectionStart||0,max:e.audio?.duration,controls:!1,placeholder:e.$t(`producer.placeholder.replaceSectionEnd`)},null,8,[`modelValue`,`min`,`max`,`placeholder`])])])}var Mn=o({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:V(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:v,ElTabs:E,ElTabPane:D,Consumption:he},emits:[`generate`],computed:{config(){return this.$store.state.producer?.config},mode:{get(){return this.$store.state.producer?.config?.custom?`custom`:`simple`},set(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,custom:e===`custom`})}},consumption(){return W(this.config,this.service?.cost)},service(){return this.$store.state.producer?.service},generateButtonText(){let e=this.config?.action;return e===`extend`||e===`upload_extend`?this.$t(`producer.button.extend`):e===`cover`||e===`upload_cover`?this.$t(`producer.button.cover_music`):e===`variation`?this.$t(`producer.button.variation`):e===`replace_section`?this.$t(`producer.button.replace_section`):e===`stems`?this.$t(`producer.button.get_stems`):e===`swap_vocals`?this.$t(`producer.button.swap_vocals`):e===`swap_instrumentals`?this.$t(`producer.button.swap_instrumentals`):this.$t(`producer.button.generate`)}},methods:{onGenerate(){this.$emit(`generate`)},onClearAll(){this.$store.commit(`producer/setConfig`,{custom:this.$store.state.producer?.config?.custom||!1,instrumental:!1,prompt:``,lyric:``,style:``,title:``,model:this.$store.state.producer?.config?.model})}}}),Nn={class:`flex flex-col h-full`},Pn={class:`flex-1 overflow-y-auto p-5`},Fn={class:`pt-2 px-1`},In={class:`pt-2 px-1`},Ln={class:`flex flex-col items-center justify-center px-5 pb-5 gap-2`},Rn={class:`flex gap-2 w-full`};function zn(e,o,s,u,m,h){let g=d(`type-selector`),_=d(`upload-audio`),v=d(`prompt-input`),y=d(`extend-from-input`),b=d(`cover-from-input`),x=d(`replace-section-input`),S=d(`advanced-params`),C=d(`el-tab-pane`),w=d(`lyric-input`),T=d(`style-input`),E=d(`title-input`),D=d(`vocal-gender-selector`),O=d(`el-tabs`),k=d(`consumption`),A=d(`font-awesome-icon`),j=d(`el-button`);return l(),f(`div`,Nn,[n(`div`,Pn,[i(O,{modelValue:e.mode,"onUpdate:modelValue":o[0]||=t=>e.mode=t,class:`producer-mode-tabs`,stretch:``},{default:p(()=>[i(C,{label:e.$t(`producer.mode.simple`),name:`simple`},{default:p(()=>[n(`div`,Fn,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),i(v,{class:`mb-4`}),e.config?.action===`extend`?(l(),t(y,{key:0,class:`mb-4`})):a(``,!0),e.config?.action===`cover`?(l(),t(b,{key:1,class:`mb-4`})):a(``,!0),e.config?.action===`replace_section`?(l(),t(x,{key:2,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`]),i(C,{label:e.$t(`producer.mode.custom`),name:`custom`},{default:p(()=>[n(`div`,In,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),e.config?.instrumental?a(``,!0):(l(),t(w,{key:0,class:`mb-4`})),i(T,{class:`mb-4`}),i(E,{class:`mb-4`}),e.config?.instrumental?a(``,!0):(l(),t(D,{key:1,class:`mb-4`})),e.config?.action===`extend`?(l(),t(y,{key:2,class:`mb-4`})):a(``,!0),e.config?.action===`cover`?(l(),t(b,{key:3,class:`mb-4`})):a(``,!0),e.config?.action===`replace_section`?(l(),t(x,{key:4,class:`mb-4`})):a(``,!0),i(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),n(`div`,Ln,[i(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),n(`div`,Rn,[i(j,{class:`flex-1`,onClick:e.onClearAll},{default:p(()=>[i(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),r(` `+c(e.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),i(j,{type:`primary`,class:`flex-1`,round:``,onClick:e.onGenerate},{default:p(()=>[i(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+c(e.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=V(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=R(`producer`),Un=o({name:`TaskPreview`,components:{ElImage:A,ElIcon:S,ElTooltip:k,FontAwesomeIcon:X,VideoPlay:b,VideoPause:x,ElDropdown:ne,ElDropdownMenu:te,ElDropdownItem:I,Loading:y,ApiCodeDialog:de},props:{modelValue:{type:Object,required:!0}},data(){return{isFetchingVideoUrl:!1,isFetchingWav:!1,apiCodeVisible:!1,apiCodePath:`/producer/audios`,apiCodeBody:{}}},computed:{loading(){return this.$store.state.producer?.status?.getApplications===Y.Request},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},task(){return this.$store.state.producer?.tasks},audios(){let e=this.modelValue?.response?.data??[],t=this.modelValue?.request?.action;return t?e.map(e=>({...e,action:t})):e},application(){return this.$store.state.producer?.application},active(){return this.$store.state.producer?.tasks?.active}},methods:{useFormatDuring:Q,onViewCode(){let e=this.modelValue?.request||{},t={};Object.entries(e).forEach(([e,n])=>{e===`application_id`||e===`callback_url`||n!=null&&(typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0||(t[e]=n))}),this.apiCodeBody=t,this.apiCodePath=`/producer/audios`,this.apiCodeVisible=!0},onPlay(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`playing`}),console.log(`on play`)},onPause(e){this.$store.dispatch(`producer/setAudio`,{...this.$store.state.producer.audio,...e,state:`paused`}),console.log(`on pause`)},onClick(e){this.$store.state?.producer?.audio?.id!==e.id&&this.onPlay({...e,progress:0})},onExtend(e,t){e?.stopPropagation(),console.debug(`set config`,t),this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.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();let n=new URL(t).pathname,r=n.substring(n.lastIndexOf(`/`)+1);fetch(t).then(e=>e.blob()).then(e=>{(0,Vn.saveAs)(e,r)})},async handleVideoDownload(e){if(e.video_url){this.onDownload(null,e.video_url);return}if(!this.isFetchingVideoUrl)try{this.isFetchingVideoUrl=!0;let t=await this.fetchVideoUrlFromApi(e?.id);console.log(`get videoUrl: ${t}`),e.video_url=t,this.onDownload(null,t)}catch(e){console.error(`get videoUrl failed:`,e),q.error(this.$t(`producer.message.getVideoUrlFailed`))}finally{this.isFetchingVideoUrl=!1}},async fetchVideoUrlFromApi(e){return new Promise((t,n)=>{let r={audio_id:e},i=this.credential?.token;if(!i){console.error(`no token specified`),n(Error(`No token specified`));return}J.video(r,{token:i}).then(e=>{let r=e.data?.data?.video_url;r?t(r):n(Error(`Video URL not found in response`))}).catch(e=>{n(e)})})},onPreview(e,t){e?.stopPropagation(),window.open(t,`_blank`)},async onGetStems(e){await this.onGenerateAudioUrl(`stems`,e)},onCover(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,instrumental:!1,style:e.style,action:`cover`,audio:e,audio_id:e.id})},onVariation(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.config,model:e.model,custom:!0,style:e.style,action:`variation`,audio:e,audio_id:e.id})},async onSwapVocals(e){await this.onGenerateAudioUrl(`swap_vocals`,e)},async onSwapInstrumentals(e){await this.onGenerateAudioUrl(`swap_instrumentals`,e)},async onGetAllStems(e){await this.onGenerateAudioUrl(`all_stems`,e)},onReplaceSection(e){this.$store.commit(`producer/setConfig`,{...this.$store.state.producer?.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)})},async handleWavDownload(e){if(!e?.id||this.isFetchingWav)return;let t=this.credential?.token;if(t)try{this.isFetchingWav=!0,q.info(this.$t(`producer.message.fetchingWav`));let n=(await J.wav({audio_id:e.id},{token:t})).data?.data,r=Array.isArray(n)?n[0]?.file_url:n?.file_url||n?.audio_url;r?this.onDownload(null,r):q.error(this.$t(`producer.message.fetchWavFailed`))}catch{q.error(this.$t(`producer.message.fetchWavFailed`))}finally{this.isFetchingWav=!1}},async onGenerateAudioUrl(e,t){let n={action:e,audio_id:t,callback_url:Hn},r=this.credential?.token;if(!r){console.error(`no token specified`);return}q.info(this.$t(`producer.message.startingTask`)),J.audio(n,{token:r}).then(()=>{q.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{q.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{await this.onGetTasks(),await this.onScrollDown()})},async onScrollDown(){setTimeout(()=>{let e=document.querySelector(`.tasks`);e&&(e.scrollTop=e.scrollHeight)},1e3)},async onGetTasks(){if(this.loading){console.debug(`loading`);return}await this.$store.dispatch(`producer/getTasks`,{limit:30,offset:0})}}}),Wn={class:`task`},Gn=[`onClick`],Kn={class:`left`},qn=[`onClick`],Jn=[`onClick`],Yn={key:2,class:`duration`},Xn={class:`info`},Zn={class:`title`},Qn={class:`style`},$n={class:`right`},er={class:`el-dropdown-link`},tr={class:`flex items-center min-w-[120px]`},nr={class:`flex items-center min-w-[120px]`},rr={class:`el-dropdown-link`};function ir(e,o,u,v,y,b){let x=d(`el-image`),S=d(`video-pause`),C=d(`el-icon`),w=d(`video-play`),T=d(`font-awesome-icon`),E=d(`el-tooltip`),D=d(`Loading`),O=d(`el-dropdown-item`),k=d(`el-dropdown-menu`),A=d(`el-dropdown`),j=d(`api-code-dialog`),M=m(`loading`);return l(),f(`div`,Wn,[(l(!0),f(g,null,s(e.audios,o=>(l(),f(`div`,{key:o.id,class:`audio`,onClick:_(t=>e.onClick(o),[`stop`])},[h((l(),f(`div`,Kn,[i(x,{src:o?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),o?.audio_url&&e.$store.state?.producer?.audio?.id===o.id&&e.$store.state?.producer?.audio?.state===`playing`?(l(),f(`div`,{key:0,class:`overlay`,onClick:_(t=>e.onPause(o),[`stop`])},[i(C,null,{default:p(()=>[i(S)]),_:1})],8,qn)):a(``,!0),o?.audio_url&&(e.$store.state?.producer?.audio?.id!==o.id||e.$store.state?.producer?.audio?.id===o.id&&e.$store.state?.producer?.audio?.state===`paused`)?(l(),f(`div`,{key:1,class:`overlay`,onClick:_(t=>e.onPlay(o),[`stop`])},[i(C,null,{default:p(()=>[i(w)]),_:1})],8,Jn)):a(``,!0),o?.duration?(l(),f(`div`,Yn,c(e.useFormatDuring(o?.duration)),1)):a(``,!0)])),[[M,!o?.audio_url]]),n(`div`,Xn,[n(`h2`,Zn,c(o?.title),1),n(`p`,Qn,c(o?.style),1)]),n(`div`,$n,[i(A,null,{dropdown:p(()=>[i(k,null,{default:p(()=>[i(O,{disabled:e.isFetchingVideoUrl,onClick:t=>e.handleVideoDownload(o)},{default:p(()=>[n(`div`,tr,[e.isFetchingVideoUrl?(l(),t(C,{key:0,class:`is-loading mr-2`},{default:p(()=>[i(D)]),_:1})):a(``,!0),n(`span`,null,c(e.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),o?.audio_url?(l(),t(O,{key:0,onClick:_(t=>e.onDownload(t,o?.audio_url),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{disabled:e.isFetchingWav,onClick:t=>e.handleWavDownload(o)},{default:p(()=>[n(`div`,nr,[e.isFetchingWav?(l(),t(C,{key:0,class:`is-loading mr-2`},{default:p(()=>[i(D)]),_:1})):a(``,!0),n(`span`,null,c(e.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:p(()=>[n(`span`,er,[i(E,{effect:`dark`,content:e.$t(`producer.button.download`),placement:`top`},{default:p(()=>[o?.audio_url||o?.video_url?(l(),t(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),i(A,null,{dropdown:p(()=>[i(k,null,{default:p(()=>[o?.audio_url?(l(),t(O,{key:0,onClick:_(t=>e.onExtend(t,o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):a(``,!0),o.id?(l(),t(O,{key:1,onClick:_(t=>e.onGetStems(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),o.id?(l(),t(O,{key:2,onClick:_(t=>e.onGetAllStems(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:_(t=>e.onCover(o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),o?.id?(l(),t(O,{key:3,onClick:_(t=>e.onVariation(o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):a(``,!0),o?.id?(l(),t(O,{key:4,onClick:_(t=>e.onSwapVocals(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):a(``,!0),o?.id?(l(),t(O,{key:5,onClick:_(t=>e.onSwapInstrumentals(o.id),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):a(``,!0),o?.id?(l(),t(O,{key:6,onClick:_(t=>e.onReplaceSection(o),[`stop`])},{default:p(()=>[r(c(e.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):a(``,!0),i(O,{onClick:_(e.onViewCode,[`stop`])},{default:p(()=>[i(T,{icon:`fa-solid fa-code`,class:`mr-1`}),r(` `+c(e.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:p(()=>[n(`span`,rr,[i(E,{effect:`dark`,content:e.$t(`producer.button.more`),placement:`top`},{default:p(()=>[o?.audio_url||o?.video_url?(l(),t(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):a(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Gn))),128)),i(j,{visible:e.apiCodeVisible,"onUpdate:visible":o[0]||=t=>e.apiCodeVisible=t,method:`POST`,path:e.apiCodePath,body:e.apiCodeBody,token:e.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ar=o({name:`RecentPanel`,components:{ElSkeletonItem:re,ElSkeleton:ie,TaskPreview:V(Un,[[`render`,ir]]),Player:_e,NoTasks:me,ScrollList:ue},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.producer?.tasks,items:this.$store.state.producer?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),or={key:0,class:`tasks`},sr={class:`left w-[70px] p-[10px] flex items-center`},$={class:`main w-[calc(100%-70px)] flex-1 p-[10px]`},cr={key:2,class:`w-full flex-1 flex items-center justify-center`},lr={class:`h-20`};function ur(e,r,o,c,m,_){let v=d(`el-skeleton-item`),y=d(`el-skeleton`),b=d(`task-preview`),x=d(`scroll-list`),S=d(`no-tasks`),C=d(`player`);return l(),f(g,null,[e.tasks?.items===void 0?(l(),f(`div`,or,[(l(),f(g,null,s(3,e=>n(`div`,{key:e,class:`flex`},[n(`div`,sr,[i(y,{animated:``},{template:p(()=>[i(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),n(`div`,$,[i(y,{animated:``},{template:p(()=>[i(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),i(v,{variant:`text`})]),_:1})])])),64))])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(l(),t(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:e.loading,onReachTop:r[0]||=t=>e.$emit(`reach-top`)},{default:p(()=>[(l(!0),f(g,null,s(e.tasks?.items,(e,n)=>(l(),t(b,{key:n,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):a(``,!0),e.tasks?.items?.length===0?(l(),f(`div`,cr,[i(S)])):a(``,!0),h(n(`div`,lr,[i(C,{namespace:`producer`})],512),[[u,!!e.$store?.state?.producer?.audio?.object]])],64)}var dr=V(ar,[[`render`,ur]]),fr=o({name:`TaskPreview`,components:{IconPicture:C,ElImage:A,ElAvatar:j,ElIcon:S},computed:{audio(){return this.$store.state.producer?.audio}}}),pr={key:0,class:`size-full overflow-hidden`},mr={class:`relative h-[300px]`},hr={class:`flex items-center justify-center size-full bg-[var(--el-bg-color)]`},gr={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`},_r={class:`p-4`},vr={class:`flex items-center font-bold mb-2`},yr={class:`text-[var(--el-text-color-regular)] mb-2`},br={class:`text-xs text-[var(--el-text-color-regular)]`},xr={class:`mt-4 text-sm leading-[25px] whitespace-pre-wrap`},Sr={key:1,class:`w-full h-full`};function Cr(e,t,r,a,o,s){let u=d(`icon-picture`),m=d(`el-icon`),h=d(`el-image`),g=d(`el-avatar`);return e.audio?.object?(l(),f(`div`,pr,[n(`div`,mr,[i(h,{src:e.audio.image_url,fit:`cover`,class:`size-full`},{error:p(()=>[n(`div`,hr,[i(m,{class:`text-3xl`},{default:p(()=>[i(u)]),_:1})])]),_:1},8,[`src`]),n(`h2`,gr,c(e.audio?.title),1)]),n(`div`,_r,[n(`div`,vr,[i(g,{size:30,src:e.audio?.image_url,class:`mr-2`},null,8,[`src`]),n(`span`,null,c(e.audio?.title),1)]),n(`p`,yr,c(e.audio?.style),1),n(`p`,br,c(e.$dayjs.format(e.audio?.created_at)),1),n(`div`,xr,[n(`p`,null,c(e.audio?.lyric),1)])])])):(l(),f(`div`,Sr))}var wr=V(fr,[[`render`,Cr]]),Tr=R(`producer`),Er=o({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:dr,PreviewPanel:wr},mixins:[B],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===Y.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===Y.Request||this.fetchingTasks},service(){return this.$store.state.producer.service},credential(){return this.$store.state.producer.credential},config(){return this.$store.state.producer.config},initializing(){return this.$store.state.producer.status.getApplications===Y.Request},needApply(){return this.$store.state.producer.status.getApplications===Y.Success&&!this.application},application(){return this.$store.state.producer.application},tasks(){return this.$store.state.producer.tasks},applications(){return this.$store.state.producer.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 fe({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(`producer/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplications`),await this.$store.dispatch(`producer/getApplications`),console.debug(`end onGetApplications`),await this.onGetTasks()},onApply(){z.create({application:this.application}).then(({data:e})=>{this.application=e,q.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&q.error(this.$t(`application.message.alreadyApplied`))})},async onScrollDown(){await this.$nextTick();let 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);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`producer/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerateAudio(){if(!G(this.uploadTracker,e=>this.$t(e),e=>q.warning(e)))return;let e={...this.config,callback_url:Tr},t=this.credential?.token;if(!t){console.error(`no token specified`);return}q.info(this.$t(`producer.message.startingTask`)),H(`producer`,J.audio(e,{token:t})).then(()=>{q.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{q.error(e?.response?.data?.error?.message||this.$t(`producer.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function Dr(e,n,r,a,o,s){let c=d(`config-panel`),u=d(`recent-panel`),f=d(`preview-panel`),m=d(`layout`);return l(),t(m,null,{config:p(()=>[i(c,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:p(()=>[i(u,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:p(()=>[i(f)]),_:1})}var Or=V(Er,[[`render`,Dr],[`__scopeId`,`data-v-a766e27a`]]);export{Or as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,N as n,P as r,Ut as i,X as a,et as o,lt as s,tt as c,ut as l}from"./vendor-chart-mdwpew_o.js";import{n as u,t as d}from"./table-fY8LUehs.js";import{t as f}from"./card-B1OoUKT4.js";import{n as p,t as m}from"./row-D8loqAPL.js";import{t as h}from"./Pagination-C9VVozAy.js";import{E as g,kn as _}from"./index-DpREqzJQ.js";import{t as v}from"./CopyToClipboard-DXA4nHxo.js";var y=r({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(r,u,d,f,p,m){let h=o(`el-col`),g=o(`el-row`),_=o(`copy-to-clipboard`),v=o(`el-table-column`),y=o(`el-table`),O=o(`el-card`),k=o(`pagination`),A=c(`loading`);return a(),e(g,{class:`panel`},{default:s(()=>[n(h,{span:24},{default:s(()=>[n(g,null,{default:s(()=>[n(h,{span:24},{default:s(()=>[t(`h2`,b,i(r.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),n(g,null,{default:s(()=>[n(h,{span:24},{default:s(()=>[n(O,{shadow:`hover`},{default:s(()=>[l((a(),e(y,{data:r.invitees,stripe:``},{default:s(()=>[n(v,{prop:`id`,label:r.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:s(e=>[t(`span`,x,i(e.row.id),1),t(`span`,S,[n(_,{content:e.row.id},null,8,[`content`])])]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.username`),width:`300px`},{default:s(e=>[t(`span`,C,i(e.row?.username),1)]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.email`),width:`300px`},{default:s(e=>[t(`span`,w,i(e.row?.email),1)]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.nickname`),width:`200px`},{default:s(e=>[t(`span`,T,i(e.row.nickname),1)]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.dateJoined`)},{default:s(e=>[t(`span`,E,i(r.$dayjs.format(e.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,r.loading]])]),_:1})]),_:1})]),_:1}),n(g,null,{default:s(()=>[n(h,{span:10,offset:14},{default:s(()=>[t(`div`,D,[n(k,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-4556864d`]]);export{k as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,N as n,P as r,Ut as i,X as a,et as o,lt as s,tt as c,ut as l}from"./vendor-chart-mdwpew_o.js";import{n as u,t as d}from"./table-fY8LUehs.js";import{t as f}from"./card-B1OoUKT4.js";import{n as p,t as m}from"./row-DLJTcN3S.js";import{t as h}from"./Pagination-DkhsjZ3x.js";import{E as g,kn as _}from"./index-WLGDsbco.js";import{t as v}from"./CopyToClipboard-CW-duTMh.js";var y=r({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(r,u,d,f,p,m){let h=o(`el-col`),g=o(`el-row`),_=o(`copy-to-clipboard`),v=o(`el-table-column`),y=o(`el-table`),O=o(`el-card`),k=o(`pagination`),A=c(`loading`);return a(),e(g,{class:`panel`},{default:s(()=>[n(h,{span:24},{default:s(()=>[n(g,null,{default:s(()=>[n(h,{span:24},{default:s(()=>[t(`h2`,b,i(r.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),n(g,null,{default:s(()=>[n(h,{span:24},{default:s(()=>[n(O,{shadow:`hover`},{default:s(()=>[l((a(),e(y,{data:r.invitees,stripe:``},{default:s(()=>[n(v,{prop:`id`,label:r.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:s(e=>[t(`span`,x,i(e.row.id),1),t(`span`,S,[n(_,{content:e.row.id},null,8,[`content`])])]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.username`),width:`300px`},{default:s(e=>[t(`span`,C,i(e.row?.username),1)]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.email`),width:`300px`},{default:s(e=>[t(`span`,w,i(e.row?.email),1)]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.nickname`),width:`200px`},{default:s(e=>[t(`span`,T,i(e.row.nickname),1)]),_:1},8,[`label`]),n(v,{label:r.$t(`user.field.dateJoined`)},{default:s(e=>[t(`span`,E,i(r.$dayjs.format(e.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,r.loading]])]),_:1})]),_:1})]),_:1}),n(g,null,{default:s(()=>[n(h,{span:10,offset:14},{default:s(()=>[t(`div`,D,[n(k,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-4556864d`]]);export{k as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,O as i,P as a,Ut as o,X as s,et as c,k as l,lt as u,tt as d,ut as f}from"./vendor-chart-mdwpew_o.js";import{t as p}from"./button-DWzbdjZV.js";import{n as m,t as h}from"./table-fY8LUehs.js";import{t as g}from"./card-B1OoUKT4.js";import{n as _,t as v}from"./row-D8loqAPL.js";import{t as y}from"./Pagination-C9VVozAy.js";import{t as b}from"./skeleton-Cn4UY-T8.js";import{t as x}from"./switch-DT8swXGq.js";import{An as S,B as C,E as w,P as T,Pr as E,Tr as D,_r as O,gr as k,kr as A,lr as j,ur as M}from"./index-DpREqzJQ.js";import{t as N}from"./index.es-DkXuZNXE.js";import{t as P}from"./CopyToClipboard-DXA4nHxo.js";var F=a({name:`ConsoleApplicationList`,components:{Pagination:y,CopyToClipboard:P,ElTable:h,ElRow:v,ElButton:p,ElCol:_,ElTag:E,ElSkeleton:b,ElSwitch:x,ElTableColumn:m,ElCard:g,FontAwesomeIcon:N},data(){return{credentialType:j,serviceType:M,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showPayment(){return!D()}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{updateAllowConsumeGlobal(e,t){!e||!e.id||S.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{A.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{A.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:C,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=k.INDIVIDUAL){return new Promise((t,n)=>{S.getAll({limit:this.limit,...e===k.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:O.USAGE,scope:e}).then(({data:n})=>{e===k.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{A.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(k.INDIVIDUAL),this.onFetchApplications(k.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){S.create({type:O.USAGE,scope:k.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(k.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),I={class:`title`},L={key:1,class:`summary-card`},R={class:`icon-wrapper`},z={class:`label`},B={class:`value`},V={class:`description`},H={key:1,class:`flex flex-row justify-between align-center`},U={class:`summary-card`},W={class:`flex justify-start items-center gap-2 mb-2 w-full`},G={class:`icon-wrapper !mb-0`},K={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},q={class:`label`},J={class:`value`},Y={class:`description`},X={class:`flex flex-col items-end gap-2`},Z={class:`copy`},Q={key:0,class:`expired-at`},$={class:`flex flex-wrap items-center justify-end gap-1`},ee={class:`pagination`};function te(a,p,m,h,g,_){let v=c(`el-col`),y=c(`el-row`),b=c(`el-skeleton`),x=c(`font-awesome-icon`),S=c(`el-card`),C=c(`copy-to-clipboard`),w=c(`el-button`),T=c(`el-table-column`),E=c(`el-tag`),D=c(`el-switch`),O=c(`el-table`),k=c(`pagination`),A=d(`loading`);return s(),e(y,{class:`application-list`},{default:u(()=>[r(v,{span:24},{default:u(()=>[r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[t(`h2`,I,o(a.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(y,{gutter:15,class:`mb-3`},{default:u(()=>[r(v,{md:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[a.loading?(s(),e(b,{key:0})):(s(),l(`div`,L,[t(`div`,R,[r(x,{icon:`fa-solid fa-cubes-stacked`})]),t(`p`,z,o(a.$t(`application.title.count`)),1),t(`p`,B,o(a.individualApplicationsTotal),1),t(`p`,V,o(a.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),a.showPayment&&a.globalApplications?.length>0?(s(),e(v,{key:0,md:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[a.loading?(s(),e(b,{key:0})):(s(),l(`div`,H,[t(`div`,U,[t(`div`,W,[t(`div`,G,[r(x,{icon:`fa-solid fa-wallet`})]),t(`span`,K,[n(o(a.$t(`application.field.id`))+`: `+o(a.globalApplications?.[0]?.id)+` `,1),a.globalApplications?.[0]?.id?(s(),e(C,{key:0,content:a.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),t(`p`,q,o(a.$t(`application.title.globalBalance`)),1),t(`p`,J,o(a.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+o(a.$t(`service.unit.credits`)),1),t(`p`,Y,o(a.$t(`application.message.globalBalanceDescription`)),1)]),t(`div`,X,[r(w,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:p[0]||=e=>a.onGoUsage(a.globalApplications?.[0])},{default:u(()=>[r(x,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.usage`)),1)]),_:1}),a.showPayment?(s(),e(w,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:p[1]||=e=>a.onBuyMore(a.globalApplications?.[0])},{default:u(()=>[r(x,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[r(S,{shadow:`hover`,class:`applications-table-card`},{default:u(()=>[f((s(),e(O,{data:a.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":a.$t(`common.message.noData`)},{default:u(()=>[r(T,{prop:`id`,label:a.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(e=>[t(`span`,null,o(e.row.id),1),t(`span`,Z,[r(C,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(T,{label:a.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[t.row?.type===`Period`?(s(),e(E,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[n(o(a.$t(`application.type.period`)),1)]),_:1})):t.row?.type===`Usage`?(s(),e(E,{key:1,effect:`dark`,round:``},{default:u(()=>[n(o(a.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(T,{label:a.$t(`application.field.name`),width:`180px`},{default:u(r=>[t(`span`,null,o(r.row?.service?.title),1),r.row?.role===`grantee`?(s(),e(E,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[n(o(a.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(T,{prop:`remaining_amount`,label:a.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(e=>[t(`span`,null,o(a.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),r(T,{prop:`used_amount`,label:a.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[t(`span`,null,o(a.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),r(T,{prop:`allow_consume_global`,label:a.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[t.row.service?.type===a.serviceType.API?(s(),e(D,{key:0,modelValue:t.row.allow_consume_global,"onUpdate:modelValue":e=>t.row.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>a.updateAllowConsumeGlobal(t.row,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(T,{label:a.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(s(),l(`span`,Q,o(a.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(T,{fixed:`right`,width:`200px`},{default:u(c=>[t(`div`,$,[r(w,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>a.onGoUsage(c?.row)},{default:u(()=>[r(x,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),a.showPayment?(s(),e(w,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>a.onBuyMore(c?.row)},{default:u(()=>[r(x,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[A,a.loading]])]),_:1})]),_:1})]),_:1}),r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[t(`div`,ee,[r(k,{"current-page":a.page,"page-size":a.limit,total:a.individualApplicationsTotal,onChange:a.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ne=w(F,[[`render`,te],[`__scopeId`,`data-v-7182b838`]]);export{ne as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,O as i,P as a,Ut as o,X as s,et as c,k as l,lt as u,tt as d,ut as f}from"./vendor-chart-mdwpew_o.js";import{t as p}from"./button-DWzbdjZV.js";import{n as m,t as h}from"./table-fY8LUehs.js";import{t as g}from"./card-B1OoUKT4.js";import{n as _,t as v}from"./row-DLJTcN3S.js";import{t as y}from"./Pagination-DkhsjZ3x.js";import{t as b}from"./skeleton-Cn4UY-T8.js";import{t as x}from"./switch-DfeNNIjH.js";import{An as S,B as C,E as w,P as T,Pr as E,Tr as D,_r as O,gr as k,kr as A,lr as j,ur as M}from"./index-WLGDsbco.js";import{t as N}from"./index.es-DEMCbRdu.js";import{t as P}from"./CopyToClipboard-CW-duTMh.js";var F=a({name:`ConsoleApplicationList`,components:{Pagination:y,CopyToClipboard:P,ElTable:h,ElRow:v,ElButton:p,ElCol:_,ElTag:E,ElSkeleton:b,ElSwitch:x,ElTableColumn:m,ElCard:g,FontAwesomeIcon:N},data(){return{credentialType:j,serviceType:M,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showPayment(){return!D()}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{updateAllowConsumeGlobal(e,t){!e||!e.id||S.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{A.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{A.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:C,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:T,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=k.INDIVIDUAL){return new Promise((t,n)=>{S.getAll({limit:this.limit,...e===k.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:O.USAGE,scope:e}).then(({data:n})=>{e===k.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{A.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(k.INDIVIDUAL),this.onFetchApplications(k.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){S.create({type:O.USAGE,scope:k.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(k.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),I={class:`title`},L={key:1,class:`summary-card`},R={class:`icon-wrapper`},z={class:`label`},B={class:`value`},V={class:`description`},H={key:1,class:`flex flex-row justify-between align-center`},U={class:`summary-card`},W={class:`flex justify-start items-center gap-2 mb-2 w-full`},G={class:`icon-wrapper !mb-0`},K={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},q={class:`label`},J={class:`value`},Y={class:`description`},X={class:`flex flex-col items-end gap-2`},Z={class:`copy`},Q={key:0,class:`expired-at`},$={class:`flex flex-wrap items-center justify-end gap-1`},ee={class:`pagination`};function te(a,p,m,h,g,_){let v=c(`el-col`),y=c(`el-row`),b=c(`el-skeleton`),x=c(`font-awesome-icon`),S=c(`el-card`),C=c(`copy-to-clipboard`),w=c(`el-button`),T=c(`el-table-column`),E=c(`el-tag`),D=c(`el-switch`),O=c(`el-table`),k=c(`pagination`),A=d(`loading`);return s(),e(y,{class:`application-list`},{default:u(()=>[r(v,{span:24},{default:u(()=>[r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[t(`h2`,I,o(a.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(y,{gutter:15,class:`mb-3`},{default:u(()=>[r(v,{md:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[a.loading?(s(),e(b,{key:0})):(s(),l(`div`,L,[t(`div`,R,[r(x,{icon:`fa-solid fa-cubes-stacked`})]),t(`p`,z,o(a.$t(`application.title.count`)),1),t(`p`,B,o(a.individualApplicationsTotal),1),t(`p`,V,o(a.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),a.showPayment&&a.globalApplications?.length>0?(s(),e(v,{key:0,md:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[a.loading?(s(),e(b,{key:0})):(s(),l(`div`,H,[t(`div`,U,[t(`div`,W,[t(`div`,G,[r(x,{icon:`fa-solid fa-wallet`})]),t(`span`,K,[n(o(a.$t(`application.field.id`))+`: `+o(a.globalApplications?.[0]?.id)+` `,1),a.globalApplications?.[0]?.id?(s(),e(C,{key:0,content:a.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),t(`p`,q,o(a.$t(`application.title.globalBalance`)),1),t(`p`,J,o(a.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+o(a.$t(`service.unit.credits`)),1),t(`p`,Y,o(a.$t(`application.message.globalBalanceDescription`)),1)]),t(`div`,X,[r(w,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:p[0]||=e=>a.onGoUsage(a.globalApplications?.[0])},{default:u(()=>[r(x,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.usage`)),1)]),_:1}),a.showPayment?(s(),e(w,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:p[1]||=e=>a.onBuyMore(a.globalApplications?.[0])},{default:u(()=>[r(x,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[r(S,{shadow:`hover`,class:`applications-table-card`},{default:u(()=>[f((s(),e(O,{data:a.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":a.$t(`common.message.noData`)},{default:u(()=>[r(T,{prop:`id`,label:a.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(e=>[t(`span`,null,o(e.row.id),1),t(`span`,Z,[r(C,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(T,{label:a.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[t.row?.type===`Period`?(s(),e(E,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[n(o(a.$t(`application.type.period`)),1)]),_:1})):t.row?.type===`Usage`?(s(),e(E,{key:1,effect:`dark`,round:``},{default:u(()=>[n(o(a.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(T,{label:a.$t(`application.field.name`),width:`180px`},{default:u(r=>[t(`span`,null,o(r.row?.service?.title),1),r.row?.role===`grantee`?(s(),e(E,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[n(o(a.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(T,{prop:`remaining_amount`,label:a.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(e=>[t(`span`,null,o(a.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),r(T,{prop:`used_amount`,label:a.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[t(`span`,null,o(a.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),r(T,{prop:`allow_consume_global`,label:a.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[t.row.service?.type===a.serviceType.API?(s(),e(D,{key:0,modelValue:t.row.allow_consume_global,"onUpdate:modelValue":e=>t.row.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>a.updateAllowConsumeGlobal(t.row,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(T,{label:a.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(s(),l(`span`,Q,o(a.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(T,{fixed:`right`,width:`200px`},{default:u(c=>[t(`div`,$,[r(w,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>a.onGoUsage(c?.row)},{default:u(()=>[r(x,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),a.showPayment?(s(),e(w,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>a.onBuyMore(c?.row)},{default:u(()=>[r(x,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),n(` `+o(a.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[A,a.loading]])]),_:1})]),_:1})]),_:1}),r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[t(`div`,ee,[r(k,{"current-page":a.page,"page-size":a.limit,total:a.individualApplicationsTotal,onChange:a.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ne=w(F,[[`render`,te],[`__scopeId`,`data-v-7182b838`]]);export{ne as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,P as i,Q as a,Ut as o,X as s,et as c,k as l,lt as u,tt as d,ut as ee,x as f}from"./vendor-chart-mdwpew_o.js";import{t as p}from"./button-DWzbdjZV.js";import{r as m,t as h}from"./select-CYdISXBV.js";import{n as g,t as _}from"./table-fY8LUehs.js";import{t as v}from"./date-picker-BtukkZrG.js";import{t as y}from"./card-B1OoUKT4.js";import{n as b,t as x}from"./row-D8loqAPL.js";import{t as S}from"./Pagination-C9VVozAy.js";import{t as C}from"./skeleton-Cn4UY-T8.js";import{Cn as w,E as T,Pr as E,Pt as D,dr as O}from"./index-DpREqzJQ.js";import{t as k}from"./index.es-DkXuZNXE.js";import{t as A}from"./CopyToClipboard-DXA4nHxo.js";var j={total_count:0,total_spent:0,state_counts:{}},M=i({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:A,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:p,ElTag:E,ElCard:y,ElSelect:m,ElOption:h,ElDatePicker:v,ElSkeleton:C,FontAwesomeIcon:k},data(){return{OrderState:O,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...j},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:O.PENDING,label:this.$t(`order.state.pending`)},{value:O.FINISHED,label:this.$t(`order.state.finished`)},{value:O.PAID,label:this.$t(`order.state.paid`)},{value:O.EXPIRED,label:this.$t(`order.state.expired`)},{value:O.FAILED,label:this.$t(`order.state.failed`)},{value:O.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:D,stateTagType(e){return e===O.FINISHED||e===O.PAID?`success`:e===O.EXPIRED||e===O.FAILED?`danger`:e===O.REFUNDED?`warning`:`info`},stateLabel(e){return{[O.PENDING]:this.$t(`order.state.pending`),[O.PAID]:this.$t(`order.state.paid`),[O.FINISHED]:this.$t(`order.state.finished`),[O.EXPIRED]:this.$t(`order.state.expired`),[O.FAILED]:this.$t(`order.state.failed`),[O.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==O.PAID&&e!==O.FINISHED&&e!==O.EXPIRED&&e!==O.FAILED&&e!==O.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,w.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,w.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...j}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,w.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),N={class:`title`},P={key:1,class:`card-content`},F={class:`icon-wrapper`},I={class:`description`},L={class:`value`},R={key:1,class:`card-content`},z={class:`icon-wrapper`},B={class:`description`},V={class:`value`},H={key:1,class:`card-content`},U={class:`icon-wrapper`},te={class:`description`},W={class:`value`},G={key:1,class:`card-content`},K={class:`icon-wrapper`},q={class:`description`},J={class:`value`},Y={class:`filter-row mb-3`},X={class:`key`},Z={class:`cursor-pointer`},Q={class:`price`},ne={class:`description`},re={class:`text-gray-500`},$={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(i,p,m,h,g,_){let v=c(`el-col`),y=c(`el-row`),b=c(`el-skeleton`),x=c(`font-awesome-icon`),S=c(`el-card`),C=c(`el-option`),w=c(`el-select`),T=c(`el-date-picker`),E=c(`el-button`),D=c(`copy-to-clipboard`),O=c(`el-table-column`),k=c(`el-tag`),A=c(`el-table`),j=c(`pagination`),M=d(`loading`);return s(),e(y,{class:`panel`},{default:u(()=>[r(v,{span:24},{default:u(()=>[r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[t(`h2`,N,o(i.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),r(y,{gutter:16},{default:u(()=>[r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,P,[t(`div`,F,[r(x,{icon:`fa-solid fa-receipt`,class:`icon`})]),t(`p`,I,o(i.$t(`order.title.totalOrders`)),1),t(`p`,L,o(i.summary.total_count),1)]))]),_:1})]),_:1}),r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,R,[t(`div`,z,[r(x,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),t(`p`,B,o(i.$t(`order.title.totalSpent`)),1),t(`p`,V,o(i.getPriceString({value:i.summary.total_spent})),1)]))]),_:1})]),_:1}),r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,H,[t(`div`,U,[r(x,{icon:`fa-solid fa-check-circle`,class:`icon`})]),t(`p`,te,o(i.$t(`order.title.finishedOrders`)),1),t(`p`,W,o(i.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,G,[t(`div`,K,[r(x,{icon:`fa-solid fa-clock`,class:`icon`})]),t(`p`,q,o(i.$t(`order.title.pendingOrders`)),1),t(`p`,J,o(i.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),t(`div`,Y,[r(w,{modelValue:i.filterState,"onUpdate:modelValue":p[0]||=e=>i.filterState=e,clearable:``,placeholder:i.$t(`order.field.allStates`),class:`filter-select`,onChange:i.onFilterChange},{default:u(()=>[(s(!0),l(f,null,a(i.stateOptions,t=>(s(),e(C,{key:t.value,label:t.label,value:t.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(w,{modelValue:i.filterPayWay,"onUpdate:modelValue":p[1]||=e=>i.filterPayWay=e,clearable:``,placeholder:i.$t(`order.field.allPayWays`),class:`filter-select`,onChange:i.onFilterChange},{default:u(()=>[(s(!0),l(f,null,a(i.payWayOptions,t=>(s(),e(C,{key:t.value,label:t.label,value:t.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(T,{modelValue:i.createdAtRange,"onUpdate:modelValue":p[2]||=e=>i.createdAtRange=e,type:`datetimerange`,shortcuts:i.shortcuts,"range-separator":i.$t(`usage.placeholder.to`),"start-placeholder":i.$t(`usage.placeholder.startDate`),"end-placeholder":i.$t(`usage.placeholder.endDate`),onChange:i.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),r(E,{type:`primary`,plain:``,loading:i.exporting,onClick:i.onExport},{default:u(()=>[r(x,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+o(i.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[r(S,{shadow:`hover`},{default:u(()=>[ee((s(),e(A,{data:i.orders,stripe:``,"empty-text":i.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:u(()=>[r(O,{prop:`id`,label:i.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:u(e=>[t(`span`,X,o(e.row.id),1),t(`span`,Z,[r(D,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.price`),width:`110px`,align:`center`},{default:u(e=>[t(`span`,Q,o(i.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:u(e=>[t(`span`,ne,o(e.row.description),1)]),_:1},8,[`label`]),r(O,{prop:`state`,label:i.$t(`order.field.state`),width:`130px`,align:`center`},{default:u(e=>[r(k,{type:i.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:u(()=>[n(o(i.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:u(e=>[t(`span`,re,o(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[t(`span`,$,o(i.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),r(O,{"min-width":`130px`,fixed:`right`},{default:u(r=>[t(`div`,ie,[i.isPendingAction(r.row.state)?(s(),e(E,{key:0,type:`primary`,size:`small`,onClick:e=>i.goToDetail(r.row.id)},{default:u(()=>[n(o(i.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(s(),e(E,{key:1,size:`small`,onClick:e=>i.goToDetail(r.row.id)},{default:u(()=>[n(o(i.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,i.loading]])]),_:1})]),_:1})]),_:1}),r(y,null,{default:u(()=>[r(v,{span:10,offset:14},{default:u(()=>[t(`div`,ae,[r(j,{"current-page":i.page,"page-size":i.limit,total:i.total,onChange:i.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=T(M,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,P as i,Q as a,Ut as o,X as s,et as c,k as l,lt as u,tt as d,ut as ee,x as f}from"./vendor-chart-mdwpew_o.js";import{t as p}from"./button-DWzbdjZV.js";import{r as m,t as h}from"./select-CyfjsVYT.js";import{n as g,t as _}from"./table-fY8LUehs.js";import{t as v}from"./date-picker-DFsSONyL.js";import{t as y}from"./card-B1OoUKT4.js";import{n as b,t as x}from"./row-DLJTcN3S.js";import{t as S}from"./Pagination-DkhsjZ3x.js";import{t as C}from"./skeleton-Cn4UY-T8.js";import{Cn as w,E as T,Pr as E,Pt as D,dr as O}from"./index-WLGDsbco.js";import{t as k}from"./index.es-DEMCbRdu.js";import{t as A}from"./CopyToClipboard-CW-duTMh.js";var j={total_count:0,total_spent:0,state_counts:{}},M=i({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:A,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:p,ElTag:E,ElCard:y,ElSelect:m,ElOption:h,ElDatePicker:v,ElSkeleton:C,FontAwesomeIcon:k},data(){return{OrderState:O,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...j},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:O.PENDING,label:this.$t(`order.state.pending`)},{value:O.FINISHED,label:this.$t(`order.state.finished`)},{value:O.PAID,label:this.$t(`order.state.paid`)},{value:O.EXPIRED,label:this.$t(`order.state.expired`)},{value:O.FAILED,label:this.$t(`order.state.failed`)},{value:O.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:D,stateTagType(e){return e===O.FINISHED||e===O.PAID?`success`:e===O.EXPIRED||e===O.FAILED?`danger`:e===O.REFUNDED?`warning`:`info`},stateLabel(e){return{[O.PENDING]:this.$t(`order.state.pending`),[O.PAID]:this.$t(`order.state.paid`),[O.FINISHED]:this.$t(`order.state.finished`),[O.EXPIRED]:this.$t(`order.state.expired`),[O.FAILED]:this.$t(`order.state.failed`),[O.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==O.PAID&&e!==O.FINISHED&&e!==O.EXPIRED&&e!==O.FAILED&&e!==O.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,w.getAll({ordering:`-created_at`,limit:this.limit,offset:(this.page-1)*this.limit,...this.filterQuery}).then(({data:e})=>{this.orders=e.items,this.total=e.count}).catch(()=>{}).finally(()=>{this.loading=!1})},onFetchSummary(){this.summaryLoading=!0,w.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...j}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,w.exportCsv(this.filterQuery).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`orders.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})}}}),N={class:`title`},P={key:1,class:`card-content`},F={class:`icon-wrapper`},I={class:`description`},L={class:`value`},R={key:1,class:`card-content`},z={class:`icon-wrapper`},B={class:`description`},V={class:`value`},H={key:1,class:`card-content`},U={class:`icon-wrapper`},te={class:`description`},W={class:`value`},G={key:1,class:`card-content`},K={class:`icon-wrapper`},q={class:`description`},J={class:`value`},Y={class:`filter-row mb-3`},X={class:`key`},Z={class:`cursor-pointer`},Q={class:`price`},ne={class:`description`},re={class:`text-gray-500`},$={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(i,p,m,h,g,_){let v=c(`el-col`),y=c(`el-row`),b=c(`el-skeleton`),x=c(`font-awesome-icon`),S=c(`el-card`),C=c(`el-option`),w=c(`el-select`),T=c(`el-date-picker`),E=c(`el-button`),D=c(`copy-to-clipboard`),O=c(`el-table-column`),k=c(`el-tag`),A=c(`el-table`),j=c(`pagination`),M=d(`loading`);return s(),e(y,{class:`panel`},{default:u(()=>[r(v,{span:24},{default:u(()=>[r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[t(`h2`,N,o(i.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),r(y,{gutter:16},{default:u(()=>[r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,P,[t(`div`,F,[r(x,{icon:`fa-solid fa-receipt`,class:`icon`})]),t(`p`,I,o(i.$t(`order.title.totalOrders`)),1),t(`p`,L,o(i.summary.total_count),1)]))]),_:1})]),_:1}),r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,R,[t(`div`,z,[r(x,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),t(`p`,B,o(i.$t(`order.title.totalSpent`)),1),t(`p`,V,o(i.getPriceString({value:i.summary.total_spent})),1)]))]),_:1})]),_:1}),r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,H,[t(`div`,U,[r(x,{icon:`fa-solid fa-check-circle`,class:`icon`})]),t(`p`,te,o(i.$t(`order.title.finishedOrders`)),1),t(`p`,W,o(i.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),r(v,{md:6,sm:12,xs:24},{default:u(()=>[r(S,{shadow:`hover`,class:`item-mini mb-3`},{default:u(()=>[i.summaryLoading?(s(),e(b,{key:0})):(s(),l(`div`,G,[t(`div`,K,[r(x,{icon:`fa-solid fa-clock`,class:`icon`})]),t(`p`,q,o(i.$t(`order.title.pendingOrders`)),1),t(`p`,J,o(i.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),t(`div`,Y,[r(w,{modelValue:i.filterState,"onUpdate:modelValue":p[0]||=e=>i.filterState=e,clearable:``,placeholder:i.$t(`order.field.allStates`),class:`filter-select`,onChange:i.onFilterChange},{default:u(()=>[(s(!0),l(f,null,a(i.stateOptions,t=>(s(),e(C,{key:t.value,label:t.label,value:t.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(w,{modelValue:i.filterPayWay,"onUpdate:modelValue":p[1]||=e=>i.filterPayWay=e,clearable:``,placeholder:i.$t(`order.field.allPayWays`),class:`filter-select`,onChange:i.onFilterChange},{default:u(()=>[(s(!0),l(f,null,a(i.payWayOptions,t=>(s(),e(C,{key:t.value,label:t.label,value:t.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(T,{modelValue:i.createdAtRange,"onUpdate:modelValue":p[2]||=e=>i.createdAtRange=e,type:`datetimerange`,shortcuts:i.shortcuts,"range-separator":i.$t(`usage.placeholder.to`),"start-placeholder":i.$t(`usage.placeholder.startDate`),"end-placeholder":i.$t(`usage.placeholder.endDate`),onChange:i.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),r(E,{type:`primary`,plain:``,loading:i.exporting,onClick:i.onExport},{default:u(()=>[r(x,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+o(i.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),r(y,null,{default:u(()=>[r(v,{span:24},{default:u(()=>[r(S,{shadow:`hover`},{default:u(()=>[ee((s(),e(A,{data:i.orders,stripe:``,"empty-text":i.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:u(()=>[r(O,{prop:`id`,label:i.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:u(e=>[t(`span`,X,o(e.row.id),1),t(`span`,Z,[r(D,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.price`),width:`110px`,align:`center`},{default:u(e=>[t(`span`,Q,o(i.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:u(e=>[t(`span`,ne,o(e.row.description),1)]),_:1},8,[`label`]),r(O,{prop:`state`,label:i.$t(`order.field.state`),width:`130px`,align:`center`},{default:u(e=>[r(k,{type:i.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:u(()=>[n(o(i.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:u(e=>[t(`span`,re,o(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(O,{label:i.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[t(`span`,$,o(i.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),r(O,{"min-width":`130px`,fixed:`right`},{default:u(r=>[t(`div`,ie,[i.isPendingAction(r.row.state)?(s(),e(E,{key:0,type:`primary`,size:`small`,onClick:e=>i.goToDetail(r.row.id)},{default:u(()=>[n(o(i.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(s(),e(E,{key:1,size:`small`,onClick:e=>i.goToDetail(r.row.id)},{default:u(()=>[n(o(i.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,i.loading]])]),_:1})]),_:1})]),_:1}),r(y,null,{default:u(()=>[r(v,{span:10,offset:14},{default:u(()=>[t(`div`,ae,[r(j,{"current-page":i.page,"page-size":i.limit,total:i.total,onChange:i.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=T(M,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,O as i,P as a,Q as o,Ut as s,X as c,_ as l,a as u,c as d,et as f,i as ee,k as p,lt as m,n as h,o as g,r as _,s as v,t as y,tt as b,ut as x,x as S}from"./vendor-chart-mdwpew_o.js";import{t as C}from"./button-DWzbdjZV.js";import{r as w,t as T}from"./select-CYdISXBV.js";import{n as E,t as D}from"./table-fY8LUehs.js";import{n as O,t as k}from"./tabs-DbqhD0Ri.js";import{t as A}from"./date-picker-BtukkZrG.js";import{t as j}from"./card-B1OoUKT4.js";import{n as M,r as N}from"./radio-IJQsW93X.js";import{n as P,t as F}from"./row-D8loqAPL.js";import{t as I}from"./Pagination-C9VVozAy.js";import{n as L,t as R}from"./skeleton-Cn4UY-T8.js";import{An as z,E as B,En as V,Mr as H,Pr as U,Tn as W,_r as G,lr as K,ur as q,wn as J}from"./index-DpREqzJQ.js";import{t as Y}from"./index.es-DkXuZNXE.js";import{t as X}from"./CopyToClipboard-DXA4nHxo.js";ee.register(_,u,h,v,d,g);var Z=a({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:U,ElDatePicker:A,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:j,ElRadioButton:M,ElRadioGroup:N,ElSkeleton:R,ElSkeletonItem:L,ElDialog:H,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:y},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:K,serviceType:q,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||q.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===q.API?this.onFetchApiUsages():this.type===q.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await W.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&W.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){z.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:G.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,J.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,W.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,V.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,W.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await W.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(a,u,d,ee,h,g){let _=f(`el-col`),v=f(`el-row`),y=f(`el-radio-button`),C=f(`el-radio-group`),w=f(`el-option`),T=f(`el-select`),E=f(`el-skeleton-item`),D=f(`el-skeleton`),O=f(`el-date-picker`),k=f(`font-awesome-icon`),A=f(`el-button`),j=f(`el-card`),M=f(`bar-chart`),N=f(`el-table-column`),P=f(`el-tag`),F=f(`copy-to-clipboard`),I=f(`el-table`),L=f(`el-tab-pane`),R=f(`el-tabs`),z=f(`el-dialog`),B=f(`pagination`),V=b(`loading`);return c(),e(v,null,{default:m(()=>[r(_,{span:24},{default:m(()=>[r(v,null,{default:m(()=>[r(_,{span:24},{default:m(()=>[t(`h2`,Q,s(a.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),r(v,null,{default:m(()=>[r(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[t(`span`,null,s(a.$t(`application.field.type`)),1),r(C,{modelValue:a.type,"onUpdate:modelValue":u[0]||=e=>a.type=e},{default:m(()=>[r(y,{value:a.serviceType.API,label:a.$t(`application.field.api`)},null,8,[`value`,`label`]),r(y,{value:a.serviceType.Proxy,label:a.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),x(r(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[t(`span`,$,s(a.$t(`usage.field.application`)),1),r(T,{modelValue:a.applicationIds,"onUpdate:modelValue":u[1]||=e=>a.applicationIds=e,placeholder:a.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:a.onApplicationsChange},{default:m(()=>[(c(!0),p(S,null,o(a.applications,t=>(c(),e(w,{key:t.id,label:t.service?.title,value:t?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[l,!1]]),a.type===a.serviceType.API?(c(),e(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[t(`span`,te,s(a.$t(`usage.field.api`)),1),a.apisLoading?(c(),e(D,{key:0,animated:``,class:`w-full`},{template:m(()=>[r(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(c(),e(T,{key:1,modelValue:a.apiIds,"onUpdate:modelValue":u[2]||=e=>a.apiIds=e,placeholder:a.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:a.onApisChange},{default:m(()=>[(c(!0),p(S,null,o(a.apis,t=>(c(),e(w,{key:t?.id,label:t?.title,value:t?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):i(``,!0),a.type===a.serviceType.API?(c(),e(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[r(O,{modelValue:a.createdAtRange,"onUpdate:modelValue":u[3]||=e=>a.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:a.shortcuts,"range-separator":a.$t(`usage.placeholder.to`),"start-placeholder":a.$t(`usage.placeholder.startDate`),"end-placeholder":a.$t(`usage.placeholder.endDate`),onChange:a.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):i(``,!0),a.type===a.serviceType.API?(c(),e(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[r(T,{modelValue:a.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>a.statusCodeFilter=e,placeholder:a.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:a.statusCodeOptionsLoading,onChange:a.onStatusCodeChange},{default:m(()=>[(c(!0),p(S,null,o(a.statusCodeOptions,t=>(c(),e(w,{key:t,label:String(t),value:String(t)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):i(``,!0),a.type===a.serviceType.API?(c(),e(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:m(()=>[r(A,{type:`primary`,plain:``,loading:a.exporting,class:`w-full whitespace-nowrap`,onClick:a.onExport},{default:m(()=>[r(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+s(a.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):i(``,!0)]),_:1}),r(v,null,{default:m(()=>[r(_,{span:24},{default:m(()=>[a.type===a.serviceType.API?(c(),e(v,{key:0,gutter:24,class:`mb-5`},{default:m(()=>[r(_,{md:6,xs:24},{default:m(()=>[r(j,{shadow:`hover`,class:`h-full`},{default:m(()=>[a.aggLoading?(c(),e(D,{key:0})):(c(),p(`div`,ne,[t(`div`,re,[r(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),t(`div`,ie,[t(`p`,ae,s(a.$t(`usage.title.totalUsed`)),1),t(`p`,oe,s(a.totalUsedString),1)])]))]),_:1})]),_:1}),r(_,{md:18,xs:24},{default:m(()=>[r(j,{shadow:`hover`,class:`h-full`},{default:m(()=>[t(`div`,se,[a.aggLoading?(c(),e(D,{key:0,class:`w-full`})):(c(),e(M,{key:1,data:a.barChartData,options:a.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):i(``,!0),r(j,{shadow:`hover`},{default:m(()=>[a.type===a.serviceType.API?x((c(),e(I,{key:0,data:a.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":a.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:m(()=>[r(N,{label:a.$t(`application.field.name`),width:`160px`},{default:m(e=>[t(`span`,null,s(e.row?.api?.title),1)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.statusCode`),width:`120px`},{default:m(e=>[t(`span`,null,s(e.row.status_code),1)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.elapsed`),width:`120px`},{default:m(e=>[t(`span`,null,s(a.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),r(N,{prop:`deducted_amount`,label:a.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[a.getDeductedAmount(e.row)===a.getOriginalAmount(e.row)?(c(),p(`div`,ce,[t(`span`,null,s(a.getDeductedAmount(e.row)),1)])):(c(),p(`div`,le,[u[7]||=t(`p`,null,null,-1),t(`p`,null,[t(`span`,null,s(a.getDeductedAmount(e.row)),1)]),t(`p`,null,[t(`del`,null,s(a.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),r(N,{prop:`remaining_amount`,label:a.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{prop:`metadata`,label:a.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:m(r=>[t(`div`,ue,[r.row.original_amount>r.row.deducted_amount&&r.row.original_amount>0?(c(),e(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:m(()=>[n(s(((r.row.original_amount-r.row.deducted_amount)*100/r.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):i(``,!0),(c(!0),p(S,null,o(a.getSimpleMetadata(r.row.metadata),(t,r)=>(c(),e(P,{key:r,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:m(()=>[n(s(r)+`: `+s(t),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:m(t=>[t.row.id?(c(),e(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:e=>a.onShowDetail(t.row)},{default:m(()=>[n(s(a.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):i(``,!0)]),_:1},8,[`label`]),r(N,{prop:`trace_id`,label:a.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:m(e=>[t(`span`,de,s(e.row.trace_id),1),e.row.trace_id?(c(),p(`span`,fe,[r(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):i(``,!0)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.createdAt`),width:`200px`},{default:m(e=>[t(`span`,pe,s(a.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,a.loading]]):i(``,!0),a.type===a.serviceType.Proxy?x((c(),e(I,{key:1,data:a.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":a.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:m(()=>[r(N,{label:a.$t(`application.field.name`),width:`160px`},{default:m(e=>[t(`span`,null,s(e.row?.service?.title),1)]),_:1},8,[`label`]),r(N,{prop:`remaining_amount`,label:a.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getRemainingAmount(e.row)),1),t(`span`,null,s(a.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{prop:`deducted_amount`,label:a.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{prop:`metadata`,label:a.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:m(t=>[(c(!0),p(S,null,o(t.row.metadata,(t,r)=>(c(),e(P,{key:r,class:`mb-2`},{default:m(()=>[n(s(r)+`: `+s(t),1)]),_:2},1024))),128))]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.createdAt`),width:`200px`},{default:m(e=>[t(`span`,me,s(a.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,a.loading]]):i(``,!0)]),_:1})]),_:1})]),_:1}),r(z,{modelValue:a.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>a.detailDialogVisible=e,title:a.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:m(()=>[r(R,{modelValue:a.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>a.detailActiveTab=e},{default:m(()=>[r(L,{label:a.$t(`usage.dialog.request`),name:`request`},{default:m(()=>[a.detailLoading?(c(),e(D,{key:0,rows:6,animated:``})):a.detailRow?.metadata?.request?(c(),p(`pre`,he,s(a.formatJson(a.detailRow.metadata.request)),1)):(c(),p(`p`,ge,s(a.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),r(L,{label:a.$t(`usage.dialog.response`),name:`response`},{default:m(()=>[a.detailLoading?(c(),e(D,{key:0,rows:6,animated:``})):a.detailRow?.metadata?.response?(c(),p(`pre`,_e,s(a.formatJson(a.detailRow.metadata.response)),1)):(c(),p(`p`,ve,s(a.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),r(v,null,{default:m(()=>[r(_,{span:10,offset:14},{default:m(()=>[t(`div`,ye,[r(B,{"current-page":a.page,"page-size":a.limit,total:a.total,onChange:a.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=B(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,O as i,P as a,Q as o,Ut as s,X as c,_ as l,a as u,c as d,et as f,i as ee,k as p,lt as m,n as h,o as g,r as _,s as v,t as y,tt as b,ut as x,x as S}from"./vendor-chart-mdwpew_o.js";import{t as C}from"./button-DWzbdjZV.js";import{r as w,t as T}from"./select-CyfjsVYT.js";import{n as E,t as D}from"./table-fY8LUehs.js";import{n as O,t as k}from"./tabs-DDqt-7al.js";import{t as A}from"./date-picker-DFsSONyL.js";import{t as j}from"./card-B1OoUKT4.js";import{n as M,r as N}from"./radio-IJQsW93X.js";import{n as P,t as F}from"./row-DLJTcN3S.js";import{t as I}from"./Pagination-DkhsjZ3x.js";import{n as L,t as R}from"./skeleton-Cn4UY-T8.js";import{An as z,E as B,En as V,Mr as H,Pr as U,Tn as W,_r as G,lr as K,ur as q,wn as J}from"./index-WLGDsbco.js";import{t as Y}from"./index.es-DEMCbRdu.js";import{t as X}from"./CopyToClipboard-CW-duTMh.js";ee.register(_,u,h,v,d,g);var Z=a({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:U,ElDatePicker:A,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:j,ElRadioButton:M,ElRadioGroup:N,ElSkeleton:R,ElSkeletonItem:L,ElDialog:H,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:y},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:K,serviceType:q,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||q.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===q.API?this.onFetchApiUsages():this.type===q.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await W.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&W.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){z.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:G.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,J.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,W.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,V.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,W.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await W.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(a,u,d,ee,h,g){let _=f(`el-col`),v=f(`el-row`),y=f(`el-radio-button`),C=f(`el-radio-group`),w=f(`el-option`),T=f(`el-select`),E=f(`el-skeleton-item`),D=f(`el-skeleton`),O=f(`el-date-picker`),k=f(`font-awesome-icon`),A=f(`el-button`),j=f(`el-card`),M=f(`bar-chart`),N=f(`el-table-column`),P=f(`el-tag`),F=f(`copy-to-clipboard`),I=f(`el-table`),L=f(`el-tab-pane`),R=f(`el-tabs`),z=f(`el-dialog`),B=f(`pagination`),V=b(`loading`);return c(),e(v,null,{default:m(()=>[r(_,{span:24},{default:m(()=>[r(v,null,{default:m(()=>[r(_,{span:24},{default:m(()=>[t(`h2`,Q,s(a.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),r(v,null,{default:m(()=>[r(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[t(`span`,null,s(a.$t(`application.field.type`)),1),r(C,{modelValue:a.type,"onUpdate:modelValue":u[0]||=e=>a.type=e},{default:m(()=>[r(y,{value:a.serviceType.API,label:a.$t(`application.field.api`)},null,8,[`value`,`label`]),r(y,{value:a.serviceType.Proxy,label:a.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),x(r(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[t(`span`,$,s(a.$t(`usage.field.application`)),1),r(T,{modelValue:a.applicationIds,"onUpdate:modelValue":u[1]||=e=>a.applicationIds=e,placeholder:a.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:a.onApplicationsChange},{default:m(()=>[(c(!0),p(S,null,o(a.applications,t=>(c(),e(w,{key:t.id,label:t.service?.title,value:t?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[l,!1]]),a.type===a.serviceType.API?(c(),e(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[t(`span`,te,s(a.$t(`usage.field.api`)),1),a.apisLoading?(c(),e(D,{key:0,animated:``,class:`w-full`},{template:m(()=>[r(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(c(),e(T,{key:1,modelValue:a.apiIds,"onUpdate:modelValue":u[2]||=e=>a.apiIds=e,placeholder:a.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:a.onApisChange},{default:m(()=>[(c(!0),p(S,null,o(a.apis,t=>(c(),e(w,{key:t?.id,label:t?.title,value:t?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):i(``,!0),a.type===a.serviceType.API?(c(),e(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[r(O,{modelValue:a.createdAtRange,"onUpdate:modelValue":u[3]||=e=>a.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:a.shortcuts,"range-separator":a.$t(`usage.placeholder.to`),"start-placeholder":a.$t(`usage.placeholder.startDate`),"end-placeholder":a.$t(`usage.placeholder.endDate`),onChange:a.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):i(``,!0),a.type===a.serviceType.API?(c(),e(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:m(()=>[r(T,{modelValue:a.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>a.statusCodeFilter=e,placeholder:a.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:a.statusCodeOptionsLoading,onChange:a.onStatusCodeChange},{default:m(()=>[(c(!0),p(S,null,o(a.statusCodeOptions,t=>(c(),e(w,{key:t,label:String(t),value:String(t)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):i(``,!0),a.type===a.serviceType.API?(c(),e(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:m(()=>[r(A,{type:`primary`,plain:``,loading:a.exporting,class:`w-full whitespace-nowrap`,onClick:a.onExport},{default:m(()=>[r(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+s(a.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):i(``,!0)]),_:1}),r(v,null,{default:m(()=>[r(_,{span:24},{default:m(()=>[a.type===a.serviceType.API?(c(),e(v,{key:0,gutter:24,class:`mb-5`},{default:m(()=>[r(_,{md:6,xs:24},{default:m(()=>[r(j,{shadow:`hover`,class:`h-full`},{default:m(()=>[a.aggLoading?(c(),e(D,{key:0})):(c(),p(`div`,ne,[t(`div`,re,[r(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),t(`div`,ie,[t(`p`,ae,s(a.$t(`usage.title.totalUsed`)),1),t(`p`,oe,s(a.totalUsedString),1)])]))]),_:1})]),_:1}),r(_,{md:18,xs:24},{default:m(()=>[r(j,{shadow:`hover`,class:`h-full`},{default:m(()=>[t(`div`,se,[a.aggLoading?(c(),e(D,{key:0,class:`w-full`})):(c(),e(M,{key:1,data:a.barChartData,options:a.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):i(``,!0),r(j,{shadow:`hover`},{default:m(()=>[a.type===a.serviceType.API?x((c(),e(I,{key:0,data:a.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":a.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:m(()=>[r(N,{label:a.$t(`application.field.name`),width:`160px`},{default:m(e=>[t(`span`,null,s(e.row?.api?.title),1)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.statusCode`),width:`120px`},{default:m(e=>[t(`span`,null,s(e.row.status_code),1)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.elapsed`),width:`120px`},{default:m(e=>[t(`span`,null,s(a.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),r(N,{prop:`deducted_amount`,label:a.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[a.getDeductedAmount(e.row)===a.getOriginalAmount(e.row)?(c(),p(`div`,ce,[t(`span`,null,s(a.getDeductedAmount(e.row)),1)])):(c(),p(`div`,le,[u[7]||=t(`p`,null,null,-1),t(`p`,null,[t(`span`,null,s(a.getDeductedAmount(e.row)),1)]),t(`p`,null,[t(`del`,null,s(a.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),r(N,{prop:`remaining_amount`,label:a.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{prop:`metadata`,label:a.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:m(r=>[t(`div`,ue,[r.row.original_amount>r.row.deducted_amount&&r.row.original_amount>0?(c(),e(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:m(()=>[n(s(((r.row.original_amount-r.row.deducted_amount)*100/r.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):i(``,!0),(c(!0),p(S,null,o(a.getSimpleMetadata(r.row.metadata),(t,r)=>(c(),e(P,{key:r,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:m(()=>[n(s(r)+`: `+s(t),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:m(t=>[t.row.id?(c(),e(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:e=>a.onShowDetail(t.row)},{default:m(()=>[n(s(a.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):i(``,!0)]),_:1},8,[`label`]),r(N,{prop:`trace_id`,label:a.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:m(e=>[t(`span`,de,s(e.row.trace_id),1),e.row.trace_id?(c(),p(`span`,fe,[r(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):i(``,!0)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.createdAt`),width:`200px`},{default:m(e=>[t(`span`,pe,s(a.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,a.loading]]):i(``,!0),a.type===a.serviceType.Proxy?x((c(),e(I,{key:1,data:a.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":a.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:m(()=>[r(N,{label:a.$t(`application.field.name`),width:`160px`},{default:m(e=>[t(`span`,null,s(e.row?.service?.title),1)]),_:1},8,[`label`]),r(N,{prop:`remaining_amount`,label:a.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getRemainingAmount(e.row)),1),t(`span`,null,s(a.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{prop:`deducted_amount`,label:a.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:m(e=>[t(`span`,null,s(a.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),r(N,{prop:`metadata`,label:a.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:m(t=>[(c(!0),p(S,null,o(t.row.metadata,(t,r)=>(c(),e(P,{key:r,class:`mb-2`},{default:m(()=>[n(s(r)+`: `+s(t),1)]),_:2},1024))),128))]),_:1},8,[`label`]),r(N,{label:a.$t(`usage.field.createdAt`),width:`200px`},{default:m(e=>[t(`span`,me,s(a.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,a.loading]]):i(``,!0)]),_:1})]),_:1})]),_:1}),r(z,{modelValue:a.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>a.detailDialogVisible=e,title:a.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:m(()=>[r(R,{modelValue:a.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>a.detailActiveTab=e},{default:m(()=>[r(L,{label:a.$t(`usage.dialog.request`),name:`request`},{default:m(()=>[a.detailLoading?(c(),e(D,{key:0,rows:6,animated:``})):a.detailRow?.metadata?.request?(c(),p(`pre`,he,s(a.formatJson(a.detailRow.metadata.request)),1)):(c(),p(`p`,ge,s(a.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),r(L,{label:a.$t(`usage.dialog.response`),name:`response`},{default:m(()=>[a.detailLoading?(c(),e(D,{key:0,rows:6,animated:``})):a.detailRow?.metadata?.response?(c(),p(`pre`,_e,s(a.formatJson(a.detailRow.metadata.response)),1)):(c(),p(`p`,ve,s(a.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),r(v,null,{default:m(()=>[r(_,{span:10,offset:14},{default:m(()=>[t(`div`,ye,[r(B,{"current-page":a.page,"page-size":a.limit,total:a.total,onChange:a.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=B(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,O as i,P as a,T as o,Ut as s,X as c,et as l,k as u,lt as d}from"./vendor-chart-mdwpew_o.js";import{t as f}from"./button-DWzbdjZV.js";import{t as p}from"./Navigator-BknUSx4Z.js";import{t as m}from"./checkbox-hfJFSY6z.js";import{t as h}from"./divider-Ba_Z3oBh.js";import"./constants-B6_fTlam.js";import{An as g,E as _,Mr as v,Mt as y,Sr as b,_r as x,gr as S,kr as C,yr as w}from"./index-DpREqzJQ.js";import{t as T}from"./Status-CvH_CBCZ.js";var E=a({name:`ApplicationConfirm`,components:{ElDialog:v,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:b,onApply(){if(!this.checked){C.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(i,a,o,u,f,p){let m=l(`el-divider`),h=l(`el-checkbox`),g=l(`el-button`),_=l(`el-dialog`);return c(),e(_,{"model-value":i.visible,width:`500px`,title:i.$t(`application.message.welcome`),center:``,onClose:a[1]||=e=>i.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(i.$t(`application.message.notApplied`)),1),r(m,{class:`my-2`}),t(`div`,k,[r(h,{modelValue:i.checked,"onUpdate:modelValue":a[0]||=e=>i.checked=e,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(i.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:i.getBaseUrlPlatform()+`/terms`},` \xA0`+s(i.$t(`application.message.policy`)),9,j)]),r(g,{round:``,type:`primary`,onClick:i.onApply},{default:d(()=>[n(s(i.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=a({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:_(E,[[`render`,M]])},provide(){return{initialized:o(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:window.innerWidth<768,initializeRunId:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===w.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize)},methods:{onResize(){this.mobile=window.innerWidth<768},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId)return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=y(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await g.create({type:x.USAGE,scope:S.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):C.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);C({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),P={class:`wrapper`};function F(t,n,a,o,s,d){let f=l(`router-view`),p=l(`navigator`),m=l(`application-status`),h=l(`application-confirm`);return c(),u(`div`,P,[r(f,{class:`main`}),r(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),e(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):i(``,!0),r(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var I=_(N,[[`render`,F],[`__scopeId`,`data-v-319483e1`]]);export{I as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{D as e,E as t,M as n,N as r,O as i,P as a,T as o,Ut as s,X as c,et as l,k as u,lt as d}from"./vendor-chart-mdwpew_o.js";import{t as f}from"./button-DWzbdjZV.js";import{t as p}from"./Navigator-C989uP0E.js";import{t as m}from"./checkbox-hfJFSY6z.js";import{t as h}from"./divider-Ba_Z3oBh.js";import"./constants-EAH6CsV9.js";import{An as g,E as _,Mr as v,Mt as y,Sr as b,_r as x,gr as S,kr as C,yr as w}from"./index-WLGDsbco.js";import{t as T}from"./Status-B7xq2zJE.js";var E=a({name:`ApplicationConfirm`,components:{ElDialog:v,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:b,onApply(){if(!this.checked){C.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(i,a,o,u,f,p){let m=l(`el-divider`),h=l(`el-checkbox`),g=l(`el-button`),_=l(`el-dialog`);return c(),e(_,{"model-value":i.visible,width:`500px`,title:i.$t(`application.message.welcome`),center:``,onClose:a[1]||=e=>i.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(i.$t(`application.message.notApplied`)),1),r(m,{class:`my-2`}),t(`div`,k,[r(h,{modelValue:i.checked,"onUpdate:modelValue":a[0]||=e=>i.checked=e,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(i.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:i.getBaseUrlPlatform()+`/terms`},` \xA0`+s(i.$t(`application.message.policy`)),9,j)]),r(g,{round:``,type:`primary`,onClick:i.onApply},{default:d(()=>[n(s(i.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=a({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:_(E,[[`render`,M]])},provide(){return{initialized:o(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:window.innerWidth<768,initializeRunId:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===w.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize)},methods:{onResize(){this.mobile=window.innerWidth<768},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId)return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=y(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await g.create({type:x.USAGE,scope:S.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):C.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);C({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),P={class:`wrapper`};function F(t,n,a,o,s,d){let f=l(`router-view`),p=l(`navigator`),m=l(`application-status`),h=l(`application-confirm`);return c(),u(`div`,P,[r(f,{class:`main`}),r(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),e(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):i(``,!0),r(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var I=_(N,[[`render`,F],[`__scopeId`,`data-v-319483e1`]]);export{I as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{Bt as e,D as t,E as n,M as r,N as i,O as a,P as o,Q as s,Ut as c,X as l,et as u,k as d,lt as f,x as p,y as m}from"./vendor-chart-mdwpew_o.js";import{t as h}from"./button-DWzbdjZV.js";import{t as g}from"./upload-CHAO8dYa.js";import{t as _}from"./image-tItcr5tZ.js";import{t as v}from"./alert-BJj7gY4q.js";import{n as y,r as b}from"./radio-IJQsW93X.js";import{t as x}from"./switch-DT8swXGq.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-B6_fTlam.js";import{E as C,Ir as w,J as T,Sr as E,kr as D,kt as ee,qt as te}from"./index-DpREqzJQ.js";import{t as O}from"./index.es-DkXuZNXE.js";import{t as k}from"./CopyToClipboard-DXA4nHxo.js";import{t as A}from"./Hailuo-D_ir2qwk.js";import{t as j}from"./BotPlaceholder-R_nAAbft.js";import{t as M}from"./TabSwitcher-CHZ_ECnY.js";var N=4,P=90,F=o({name:`FishRecorder`,components:{ElButton:h,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){D.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;D.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){D.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${E()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){D.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){D.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(o,s,p,m,h,g){let _=u(`font-awesome-icon`),v=u(`el-button`);return l(),d(`div`,I,[o.state===`recorded`?a(``,!0):(l(),d(`div`,L,[n(`div`,R,[i(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,c(o.$t(`fish.description.readScript`)),1),i(v,{link:``,size:`small`,class:`ml-auto`,disabled:o.state===`recording`,onClick:o.nextScript},{default:f(()=>[i(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),r(` `+c(o.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,c(o.currentScript),1)])),n(`div`,V,[o.state===`idle`?(l(),t(v,{key:0,type:`danger`,circle:``,size:`large`,title:o.$t(`fish.button.startRecord`),onClick:o.startRecord},{default:f(()=>[i(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):o.state===`recording`?(l(),t(v,{key:1,type:`warning`,circle:``,size:`large`,title:o.$t(`fish.button.stopRecord`),onClick:o.stopRecord},{default:f(()=>[i(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):a(``,!0),n(`div`,H,[n(`span`,{class:e([`timer`,o.state===`recording`?`live`:``])},c(o.formattedTime),3),n(`span`,U,c(o.state===`idle`?o.$t(`fish.description.recorderIdle`):o.state===`recording`?o.$t(`fish.description.recorderRecording`):o.$t(`fish.description.recorderRecorded`)),1)])]),o.state===`recorded`&&o.recordedUrl?(l(),d(`div`,W,[n(`audio`,{src:o.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[i(v,{size:`small`,disabled:o.uploading,onClick:o.reset},{default:f(()=>[i(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),r(` `+c(o.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),i(v,{size:`small`,type:`primary`,loading:o.uploading,onClick:o.useRecording},{default:f(()=>[i(_,{icon:`fa-solid fa-check`,class:`mr-1`}),r(` `+c(o.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):a(``,!0),n(`div`,q,[i(v,{link:``,size:`small`,disabled:o.uploading||o.state===`recording`,onClick:o.onCancel},{default:f(()=>[r(c(o.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=C(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=o({name:`FishModelConfigPanel`,components:{ElButton:h,ElInput:w,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:O,Recorder:Y},mixins:[ee],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return E()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(D.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){D.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,D.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){D.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){D.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){D.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,o,s,p,m,h){let g=u(`el-input`),_=u(`font-awesome-icon`),v=u(`el-button`),y=u(`el-upload`),b=u(`recorder`),x=u(`el-radio-button`),S=u(`el-radio-group`),C=u(`el-switch`);return l(),d(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[r(c(e.$t(`fish.name.voiceTitle`))+` `,1),o[9]||=n(`span`,{class:`required`},`*`,-1)]),i(g,{modelValue:e.form.title,"onUpdate:modelValue":o[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[r(c(e.$t(`fish.name.referenceAudio`))+` `,1),o[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),d(`span`,le,c(e.$t(`fish.description.audioRequired`)),1)):a(``,!0)]),n(`p`,ue,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),d(`div`,de,[i(y,{"file-list":e.fileList,"onUpdate:fileList":o[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:f(()=>[i(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:f(()=>[i(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),i(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:f(()=>[i(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),r(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):a(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),d(`p`,fe,c(e.$t(`fish.message.recorderUnsupported`)),1)):a(``,!0),e.recording?(l(),t(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:o[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):a(``,!0),e.form.voicesUrl&&!e.recording?(l(),d(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[i(v,{link:``,size:`small`,onClick:e.clearAudio},{default:f(()=>[i(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),r(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):a(``,!0)]),n(`div`,ge,[n(`h2`,_e,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,c(e.$t(`fish.description.audioTexts`)),1),i(g,{modelValue:e.form.texts,"onUpdate:modelValue":o[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,c(e.$t(`fish.name.voiceDescription`)),1),i(g,{modelValue:e.form.description,"onUpdate:modelValue":o[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,c(e.$t(`fish.name.visibility`)),1),i(S,{modelValue:e.form.visibility,"onUpdate:modelValue":o[5]||=t=>e.form.visibility=t,size:`small`},{default:f(()=>[i(x,{label:`private`,value:`private`},{default:f(()=>[r(c(e.$t(`fish.value.private`)),1)]),_:1}),i(x,{label:`unlist`,value:`unlist`},{default:f(()=>[r(c(e.$t(`fish.value.unlist`)),1)]),_:1}),i(x,{label:`public`,value:`public`},{default:f(()=>[r(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,c(e.$t(`fish.name.trainMode`)),1),i(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":o[6]||=t=>e.form.trainMode=t,size:`small`},{default:f(()=>[i(x,{label:`fast`,value:`fast`},{default:f(()=>[r(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),i(x,{label:`precise`,value:`precise`},{default:f(()=>[r(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,c(e.$t(`fish.name.enhanceAudio`)),1),i(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":o[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,c(e.$t(`fish.name.generateSample`)),1),i(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":o[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[i(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:f(()=>[i(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=C(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=o({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:T}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,o,s,p,h,g){let _=u(`el-image`),v=u(`font-awesome-icon`),y=u(`copy-to-clipboard`),b=u(`el-alert`),x=u(`el-button`);return l(),d(`div`,Le,[n(`div`,Re,[e.coverSrc?(l(),t(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:f(()=>[i(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:f(()=>[...o[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),t(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),d(`span`,He,c(e.createdAtLabel),1)):a(``,!0)]),e.modelValue?.description?(l(),d(`p`,Ue,c(e.modelValue?.description),1)):a(``,!0),e.sampleAudioUrl?(l(),d(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):a(``,!0),i(b,{closable:!1,class:`mt-2 success`},{default:f(()=>[e.voiceId?(l(),d(`p`,Ke,[i(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),r(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),i(y,{content:e.voiceId},null,8,[`content`])])):a(``,!0),e.modelValue?.visibility?(l(),d(`p`,qe,[i(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),r(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):a(``,!0)]),_:1}),n(`div`,Je,[i(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:m(e.onUseVoice,[`stop`])},{default:f(()=>[i(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),r(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=o({name:`FishModelListPanel`,components:{VoiceCard:C(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(e,r,o,f,m,h){let g=u(`bot-placeholder`),_=u(`font-awesome-icon`),v=u(`voice-card`);return l(),d(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,c(e.$t(`fish.title.myVoices`)),1),e.voices?.length?(l(),d(`span`,et,c(e.voices?.length),1)):a(``,!0)]),n(`div`,tt,[e.voices===void 0?(l(),d(`div`,$,[i(g)])):e.voices.length===0?(l(),d(`div`,nt,[i(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,c(e.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,c(e.$t(`fish.description.noVoicesYet`)),1)])):(l(),d(`div`,at,[(l(!0),d(p,null,s(e.voices,e=>(l(),t(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=o({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:A,ModelListPanel:C(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,D.info(this.$t(`fish.message.creatingModel`));try{await te.createModel(e,{token:t}),D.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?D.error(this.$t(`fish.message.usedUp`)):D.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,r,a,o,s,c){let d=u(`tab-switcher`),p=u(`model-config-panel`),m=u(`model-list-panel`),h=u(`layout`);return l(),t(h,null,{config:f(()=>[n(`div`,ct,[i(d),n(`div`,lt,[i(p,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:f(()=>[i(m,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=C(st,[[`render`,ut]]);export{dt as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{Bt as e,D as t,E as n,M as r,N as i,O as a,P as o,Q as s,Ut as c,X as l,et as u,k as d,lt as f,x as p,y as m}from"./vendor-chart-mdwpew_o.js";import{t as h}from"./button-DWzbdjZV.js";import{t as g}from"./upload-CIsl9b3M.js";import{t as _}from"./image-BhCAlGZE.js";import{t as v}from"./alert-BJj7gY4q.js";import{n as y,r as b}from"./radio-IJQsW93X.js";import{t as x}from"./switch-DfeNNIjH.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-EAH6CsV9.js";import{E as C,Ir as w,J as T,Sr as E,kr as D,kt as ee,qt as te}from"./index-WLGDsbco.js";import{t as O}from"./index.es-DEMCbRdu.js";import{t as k}from"./CopyToClipboard-CW-duTMh.js";import{t as A}from"./Hailuo-kmnQTeOS.js";import{t as j}from"./BotPlaceholder-DhZ616uF.js";import{t as M}from"./TabSwitcher-g-agCufh.js";var N=4,P=90,F=o({name:`FishRecorder`,components:{ElButton:h,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){D.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;D.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){D.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${E()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){D.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){D.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(o,s,p,m,h,g){let _=u(`font-awesome-icon`),v=u(`el-button`);return l(),d(`div`,I,[o.state===`recorded`?a(``,!0):(l(),d(`div`,L,[n(`div`,R,[i(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,c(o.$t(`fish.description.readScript`)),1),i(v,{link:``,size:`small`,class:`ml-auto`,disabled:o.state===`recording`,onClick:o.nextScript},{default:f(()=>[i(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),r(` `+c(o.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,c(o.currentScript),1)])),n(`div`,V,[o.state===`idle`?(l(),t(v,{key:0,type:`danger`,circle:``,size:`large`,title:o.$t(`fish.button.startRecord`),onClick:o.startRecord},{default:f(()=>[i(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):o.state===`recording`?(l(),t(v,{key:1,type:`warning`,circle:``,size:`large`,title:o.$t(`fish.button.stopRecord`),onClick:o.stopRecord},{default:f(()=>[i(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):a(``,!0),n(`div`,H,[n(`span`,{class:e([`timer`,o.state===`recording`?`live`:``])},c(o.formattedTime),3),n(`span`,U,c(o.state===`idle`?o.$t(`fish.description.recorderIdle`):o.state===`recording`?o.$t(`fish.description.recorderRecording`):o.$t(`fish.description.recorderRecorded`)),1)])]),o.state===`recorded`&&o.recordedUrl?(l(),d(`div`,W,[n(`audio`,{src:o.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[i(v,{size:`small`,disabled:o.uploading,onClick:o.reset},{default:f(()=>[i(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),r(` `+c(o.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),i(v,{size:`small`,type:`primary`,loading:o.uploading,onClick:o.useRecording},{default:f(()=>[i(_,{icon:`fa-solid fa-check`,class:`mr-1`}),r(` `+c(o.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):a(``,!0),n(`div`,q,[i(v,{link:``,size:`small`,disabled:o.uploading||o.state===`recording`,onClick:o.onCancel},{default:f(()=>[r(c(o.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=C(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=o({name:`FishModelConfigPanel`,components:{ElButton:h,ElInput:w,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:O,Recorder:Y},mixins:[ee],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return E()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(D.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){D.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,D.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){D.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){D.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){D.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,o,s,p,m,h){let g=u(`el-input`),_=u(`font-awesome-icon`),v=u(`el-button`),y=u(`el-upload`),b=u(`recorder`),x=u(`el-radio-button`),S=u(`el-radio-group`),C=u(`el-switch`);return l(),d(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[r(c(e.$t(`fish.name.voiceTitle`))+` `,1),o[9]||=n(`span`,{class:`required`},`*`,-1)]),i(g,{modelValue:e.form.title,"onUpdate:modelValue":o[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[r(c(e.$t(`fish.name.referenceAudio`))+` `,1),o[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),d(`span`,le,c(e.$t(`fish.description.audioRequired`)),1)):a(``,!0)]),n(`p`,ue,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),d(`div`,de,[i(y,{"file-list":e.fileList,"onUpdate:fileList":o[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:f(()=>[i(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:f(()=>[i(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),i(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:f(()=>[i(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),r(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):a(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),d(`p`,fe,c(e.$t(`fish.message.recorderUnsupported`)),1)):a(``,!0),e.recording?(l(),t(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:o[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):a(``,!0),e.form.voicesUrl&&!e.recording?(l(),d(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[i(v,{link:``,size:`small`,onClick:e.clearAudio},{default:f(()=>[i(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),r(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):a(``,!0)]),n(`div`,ge,[n(`h2`,_e,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,c(e.$t(`fish.description.audioTexts`)),1),i(g,{modelValue:e.form.texts,"onUpdate:modelValue":o[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,c(e.$t(`fish.name.voiceDescription`)),1),i(g,{modelValue:e.form.description,"onUpdate:modelValue":o[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,c(e.$t(`fish.name.visibility`)),1),i(S,{modelValue:e.form.visibility,"onUpdate:modelValue":o[5]||=t=>e.form.visibility=t,size:`small`},{default:f(()=>[i(x,{label:`private`,value:`private`},{default:f(()=>[r(c(e.$t(`fish.value.private`)),1)]),_:1}),i(x,{label:`unlist`,value:`unlist`},{default:f(()=>[r(c(e.$t(`fish.value.unlist`)),1)]),_:1}),i(x,{label:`public`,value:`public`},{default:f(()=>[r(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,c(e.$t(`fish.name.trainMode`)),1),i(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":o[6]||=t=>e.form.trainMode=t,size:`small`},{default:f(()=>[i(x,{label:`fast`,value:`fast`},{default:f(()=>[r(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),i(x,{label:`precise`,value:`precise`},{default:f(()=>[r(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,c(e.$t(`fish.name.enhanceAudio`)),1),i(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":o[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,c(e.$t(`fish.name.generateSample`)),1),i(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":o[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[i(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:f(()=>[i(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=C(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=o({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:T}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,o,s,p,h,g){let _=u(`el-image`),v=u(`font-awesome-icon`),y=u(`copy-to-clipboard`),b=u(`el-alert`),x=u(`el-button`);return l(),d(`div`,Le,[n(`div`,Re,[e.coverSrc?(l(),t(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:f(()=>[i(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:f(()=>[...o[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),t(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),d(`span`,He,c(e.createdAtLabel),1)):a(``,!0)]),e.modelValue?.description?(l(),d(`p`,Ue,c(e.modelValue?.description),1)):a(``,!0),e.sampleAudioUrl?(l(),d(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):a(``,!0),i(b,{closable:!1,class:`mt-2 success`},{default:f(()=>[e.voiceId?(l(),d(`p`,Ke,[i(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),r(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),i(y,{content:e.voiceId},null,8,[`content`])])):a(``,!0),e.modelValue?.visibility?(l(),d(`p`,qe,[i(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),r(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):a(``,!0)]),_:1}),n(`div`,Je,[i(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:m(e.onUseVoice,[`stop`])},{default:f(()=>[i(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),r(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=o({name:`FishModelListPanel`,components:{VoiceCard:C(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(e,r,o,f,m,h){let g=u(`bot-placeholder`),_=u(`font-awesome-icon`),v=u(`voice-card`);return l(),d(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,c(e.$t(`fish.title.myVoices`)),1),e.voices?.length?(l(),d(`span`,et,c(e.voices?.length),1)):a(``,!0)]),n(`div`,tt,[e.voices===void 0?(l(),d(`div`,$,[i(g)])):e.voices.length===0?(l(),d(`div`,nt,[i(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,c(e.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,c(e.$t(`fish.description.noVoicesYet`)),1)])):(l(),d(`div`,at,[(l(!0),d(p,null,s(e.voices,e=>(l(),t(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=o({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:A,ModelListPanel:C(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,D.info(this.$t(`fish.message.creatingModel`));try{await te.createModel(e,{token:t}),D.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?D.error(this.$t(`fish.message.usedUp`)):D.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,r,a,o,s,c){let d=u(`tab-switcher`),p=u(`model-config-panel`),m=u(`model-list-panel`),h=u(`layout`);return l(),t(h,null,{config:f(()=>[n(`div`,ct,[i(d),n(`div`,lt,[i(p,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:f(()=>[i(m,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=C(st,[[`render`,ut]]);export{dt as default};