@acedatacloud/nexior 3.314.1 → 3.314.3

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 (169) hide show
  1. package/dist/assets/{ApiCodeButton-Bs0Mc76Y.js → ApiCodeButton-CBSyjGXU.js} +1 -1
  2. package/dist/assets/{Artifacts-CgmxP3RJ.js → Artifacts-DF_h-Wll.js} +1 -1
  3. package/dist/assets/{AskUserQuestionCard-Cz-blS03.js → AskUserQuestionCard-ypXctC8e.js} +1 -1
  4. package/dist/assets/{Auth-GHp7fBKP.js → Auth-BhP3iCZV.js} +1 -1
  5. package/dist/assets/{Bare-DvwZ0m5x.js → Bare-B5gZ2iOj.js} +1 -1
  6. package/dist/assets/{BotPlaceholder-ByASGxzf.js → BotPlaceholder-tieUIcRy.js} +1 -1
  7. package/dist/assets/{BottomFooter-Cxu2SJtj.js → BottomFooter-DdeXzP-6.js} +1 -1
  8. package/dist/assets/{Callback-CwY7U_6T.js → Callback-DSIbguks.js} +1 -1
  9. package/dist/assets/{CodeSnippet-DxAJtjdO.js → CodeSnippet-F0q6pP62.js} +1 -1
  10. package/dist/assets/{Console-DfJdAfrR.js → Console-DKek9dH8.js} +1 -1
  11. package/dist/assets/{Consumption-9e8Kk4qS.js → Consumption-DFgxLgQ0.js} +1 -1
  12. package/dist/assets/{Conversation-GdrLVYTl.js → Conversation-C59sFf1C.js} +1 -1
  13. package/dist/assets/Conversation-CSmt6MMG.js +1 -0
  14. package/dist/assets/{CopyToClipboard-BE1wy8qZ.js → CopyToClipboard-DIqw8clv.js} +1 -1
  15. package/dist/assets/{Detail-Cd63Xdtg.js → Detail-BpjjJGGY.js} +2 -2
  16. package/dist/assets/{Extra-BB8xyh6y.js → Extra-gBr4ahry.js} +1 -1
  17. package/dist/assets/{FilePreview-BsaVVcsD.js → FilePreview-rbNLg692.js} +1 -1
  18. package/dist/assets/{Hailuo-C0xKfTO9.js → Hailuo-D0_1bqT3.js} +1 -1
  19. package/dist/assets/{History-Clgmi9Xv.js → History-BTjZzy9-.js} +1 -1
  20. package/dist/assets/{ImagePreview-X_3puJlh.js → ImagePreview-BXrCtlZ8.js} +1 -1
  21. package/dist/assets/{ImageWrapper-CSXa5VLL.js → ImageWrapper-pYLwzpK8.js} +1 -1
  22. package/dist/assets/{Index-DkwF8kqk.js → Index-6p5-oPnc.js} +1 -1
  23. package/dist/assets/{Index-DpR40iXP.js → Index-B4H7PWnG.js} +1 -1
  24. package/dist/assets/{Index-C2rlj71z.js → Index-B9Q2ffOs.js} +1 -1
  25. package/dist/assets/{Index-DL9nRN4w.js → Index-BINwpb6Y.js} +1 -1
  26. package/dist/assets/{Index-CGEN7Af9.js → Index-BRfF5w2P.js} +1 -1
  27. package/dist/assets/{Index-D8mOgPwI.js → Index-Bg2RmRub.js} +1 -1
  28. package/dist/assets/{Index-Dh0UWLue.js → Index-BgIIEajW.js} +1 -1
  29. package/dist/assets/{Index-DxkWCf65.js → Index-BwesZ8hO.js} +1 -1
  30. package/dist/assets/{Index-DKbAWgyf.js → Index-BznYFsO-.js} +1 -1
  31. package/dist/assets/{Index-Dy6-1A5Z.js → Index-C5ZBqGjv.js} +1 -1
  32. package/dist/assets/{Index-CsSwe8I-.js → Index-CBZNE1js.js} +1 -1
  33. package/dist/assets/{Index-CQz_iRYP.js → Index-CJrPuxg9.js} +1 -1
  34. package/dist/assets/{Index-ZpdLDw_f.js → Index-CV3wpI3K.js} +1 -1
  35. package/dist/assets/{Index-CtGQr6Ns.js → Index-C_0M1SFS.js} +1 -1
  36. package/dist/assets/Index-Cd2T-jxH.js +1 -0
  37. package/dist/assets/{Index-5ndbXYi8.js → Index-CdinCGjE.js} +1 -1
  38. package/dist/assets/{Index-Doqyl3oP.js → Index-Ck9FIKYH.js} +1 -1
  39. package/dist/assets/{Index-B0VN9lvy.js → Index-CozMZQ4C.js} +1 -1
  40. package/dist/assets/{Index-OUV0Dis9.js → Index-CuepwJRl.js} +1 -1
  41. package/dist/assets/Index-CyY2WVto.css +1 -0
  42. package/dist/assets/{Index-DXcfbBC6.js → Index-CynKRSZT.js} +1 -1
  43. package/dist/assets/{Index-3W8cuqCw.js → Index-D5gpqTcU.js} +1 -1
  44. package/dist/assets/{Index-C09puuQI.js → Index-D99xSR0Z.js} +1 -1
  45. package/dist/assets/Index-DD6eZ4zb.js +1 -0
  46. package/dist/assets/Index-DQArTIen.js +1 -0
  47. package/dist/assets/{Index-G8pHWMG5.js → Index-Dbq74YFn.js} +1 -1
  48. package/dist/assets/{Index-B1g5Ju34.js → Index-DdKBa2De.js} +1 -1
  49. package/dist/assets/{Index-D5pSlWo4.js → Index-DljbuUtm.js} +1 -1
  50. package/dist/assets/{Index-Cjnoyrxb.css → Index-Dr1GWEqN.css} +1 -1
  51. package/dist/assets/{Index-C9QcWDtS.js → Index-ku91-YrX.js} +1 -1
  52. package/dist/assets/{Invitees-Cz_W-x4P.js → Invitees-DgF84Dnq.js} +1 -1
  53. package/dist/assets/{List-DMr5VW05.js → List-DI8V6nZV.js} +1 -1
  54. package/dist/assets/{List-BlG3hKbv.js → List-DR9gBLXT.js} +1 -1
  55. package/dist/assets/{List-08e7dPI9.js → List-v6WCvUuD.js} +1 -1
  56. package/dist/assets/{LocalTools-DnutI4O8.js → LocalTools-BYTYgsmP.js} +1 -1
  57. package/dist/assets/{LocalTools-Di3vKye_.js → LocalTools-CtfFuSKn.js} +1 -1
  58. package/dist/assets/{Main-Bbu_P_kS.js → Main-nc26Lqt7.js} +1 -1
  59. package/dist/assets/{Message-IybXBUcB.js → Message-CLfjZKCc.js} +2 -2
  60. package/dist/assets/{Model-CG8yndpR.js → Model-C1MZyKXX.js} +1 -1
  61. package/dist/assets/{Navigator-DoISXXSE.js → Navigator-iSknSN8-.js} +2 -2
  62. package/dist/assets/{NoTasks-Be_86fis.js → NoTasks-Xnxp0ghd.js} +1 -1
  63. package/dist/assets/{NotFound-DHXuXOfp.js → NotFound-ghXeMNjg.js} +1 -1
  64. package/dist/assets/{Pagination-DRlr3vYx.js → Pagination-aD-CS8DI.js} +1 -1
  65. package/dist/assets/{Pay-Djsq3SyQ.js → Pay-CYYOQzl4.js} +1 -1
  66. package/dist/assets/{Player-B27_rrp7.js → Player-z0eKg5bN.js} +1 -1
  67. package/dist/assets/{PromptTextarea-C0Vv1r8K.js → PromptTextarea-hPH8fLrL.js} +1 -1
  68. package/dist/assets/{RealtimeCall-DZLkh4Hh.js → RealtimeCall-CVdxpZns.js} +1 -1
  69. package/dist/assets/{ScheduledTasks-COPD85NP.js → ScheduledTasks-CeClUgVr.js} +1 -1
  70. package/dist/assets/{Status-CUL6T7ei.js → Status-Dd0lLBot.js} +1 -1
  71. package/dist/assets/{Subscribe-DOLHd1o5.js → Subscribe-BEyP7ehP.js} +1 -1
  72. package/dist/assets/{TabSwitcher-BWHuoa7f.js → TabSwitcher-_jmyIKzA.js} +1 -1
  73. package/dist/assets/{Tts-CKcsVZaR.js → Tts-BpOe0Ttj.js} +1 -1
  74. package/dist/assets/{VideoPlayer-BUvHvMWF.js → VideoPlayer-3XZb-Ip-.js} +1 -1
  75. package/dist/assets/{alert-YYOiLWri.js → alert-CzzZuwhp.js} +1 -1
  76. package/dist/assets/{avatar-CQlXN3A1.js → avatar-BXSK9Y46.js} +1 -1
  77. package/dist/assets/{basic-naOTVJkq.js → basic-BCCVsr1X.js} +1 -1
  78. package/dist/assets/{chat-BtEKTSdo.js → chat-CaAV_3X4.js} +1 -1
  79. package/dist/assets/codingBridge-DV8c67-e.js +2 -0
  80. package/dist/assets/{codingBridgeNotify-Bj53tjf-.js → codingBridgeNotify-DOOUCMSO.js} +2 -2
  81. package/dist/assets/{collapse-DrK7wbng.js → collapse-Cosm9h0L.js} +1 -1
  82. package/dist/assets/{constants-DqciFo58.js → constants-BI-FWncP.js} +1 -1
  83. package/dist/assets/{createTaskActions-C3fKw6P4.js → createTaskActions-CmCwDqSA.js} +1 -1
  84. package/dist/assets/{date-picker-DZsxIimL.js → date-picker-Cf_K-mee.js} +1 -1
  85. package/dist/assets/{digitalhuman-OgiA0FxZ.js → digitalhuman-CFLp13pC.js} +1 -1
  86. package/dist/assets/{drawer-B1KhnI9D.js → drawer-CaHf70Re.js} +1 -1
  87. package/dist/assets/{dropdown-Dqzvx8GW.js → dropdown-CS8h2o-L.js} +1 -1
  88. package/dist/assets/{dropdown-UMEMC-MM.js → dropdown-dCC6OPvq.js} +1 -1
  89. package/dist/assets/esm-BXbsKcir.js +1 -0
  90. package/dist/assets/{esm-BZa6OjH1.js → esm-C2qza7-U.js} +1 -1
  91. package/dist/assets/{esm-BExd_6px.js → esm-CDteyh0U.js} +2 -2
  92. package/dist/assets/{esm-BafkRSqe.js → esm-Cu5Yu1_x.js} +1 -1
  93. package/dist/assets/{esm-CaO4BT5P.js → esm-CvUXGpO3.js} +1 -1
  94. package/dist/assets/{esm-CGbjV-GD.js → esm-DKrgX2Fw.js} +2 -2
  95. package/dist/assets/{esm-CJmmhUPn.js → esm-xroRSDKu.js} +3 -3
  96. package/dist/assets/{fish-BqPDgmnd.js → fish-9ehsrJ4t.js} +1 -1
  97. package/dist/assets/{flux-DYCI8EXt.js → flux-CVod9Wto.js} +1 -1
  98. package/dist/assets/{grokvideo-ou6Ir9P-.js → grokvideo-CLrFaGX2.js} +1 -1
  99. package/dist/assets/{hailuo-EHxu77Ns.js → hailuo-BbFTxyVj.js} +1 -1
  100. package/dist/assets/{headshots-BcI30jiY.js → headshots-BKLH5Bax.js} +1 -1
  101. package/dist/assets/{image-BKnKnVaq.js → image-Rt1tBHga.js} +1 -1
  102. package/dist/assets/{index-CHpU1m3n.js → index-CmR4fqhy.js} +5 -5
  103. package/dist/assets/{index.browser.esm-PpHERHxR.js → index.browser.esm-CnkhTM8R.js} +1 -1
  104. package/dist/assets/{index.es-BPpNb_kj.js → index.es-D1U5NzTe.js} +1 -1
  105. package/dist/assets/{input-number-CH0br6q0.js → input-number-CmJUcGZE.js} +1 -1
  106. package/dist/assets/{kling-Cy2Jyg9_.js → kling-43obmfh3.js} +1 -1
  107. package/dist/assets/{luma-Ac1N-SAR.js → luma-AF2uGNcX.js} +1 -1
  108. package/dist/assets/{maestro-B_S15l8U.js → maestro-D4fJ0N3X.js} +1 -1
  109. package/dist/assets/{midjourney-CUxsYx4H.js → midjourney-DY_CDc8U.js} +1 -1
  110. package/dist/assets/{nanobanana-2B09M-EV.js → nanobanana-3eA_ctsZ.js} +1 -1
  111. package/dist/assets/{openaiimage-CQ9hmfWO.js → openaiimage-6yEs8JA2.js} +1 -1
  112. package/dist/assets/{openaiimage--ef_WM0Z.js → openaiimage-B17V2p_T.js} +1 -1
  113. package/dist/assets/{openaiimage-D7cm1Oer.js → openaiimage-B6grtnNo.js} +1 -1
  114. package/dist/assets/{openaiimage-CugB1uxn.js → openaiimage-BDejHaav.js} +1 -1
  115. package/dist/assets/{openaiimage-ShnEEY1z.js → openaiimage-BNpTdd65.js} +1 -1
  116. package/dist/assets/{openaiimage-CW0koXYG.js → openaiimage-BvvI3cAF.js} +1 -1
  117. package/dist/assets/{openaiimage-qPHvcBI_.js → openaiimage-C-NCPCrx.js} +1 -1
  118. package/dist/assets/{openaiimage-DwZXelHI.js → openaiimage-C2bpyQKJ.js} +1 -1
  119. package/dist/assets/{openaiimage-CZpunKLX.js → openaiimage-CIpfs68J.js} +1 -1
  120. package/dist/assets/{openaiimage-DsF4S2z_.js → openaiimage-CenlIY1F.js} +1 -1
  121. package/dist/assets/{openaiimage-jF7-9GOh.js → openaiimage-CmZuvl6k.js} +1 -1
  122. package/dist/assets/{openaiimage-Bqvs5JoR.js → openaiimage-CstO8Enq.js} +1 -1
  123. package/dist/assets/{openaiimage-CwInPQF1.js → openaiimage-DG68fZf0.js} +1 -1
  124. package/dist/assets/{openaiimage-Bt8d5v84.js → openaiimage-DyfMkAO-.js} +1 -1
  125. package/dist/assets/{openaiimage-DaM2d5w5.js → openaiimage-JksJhYkF.js} +1 -1
  126. package/dist/assets/{openaiimage-CpE2ycjX.js → openaiimage-Ot-ASuqJ.js} +1 -1
  127. package/dist/assets/{openaiimage-BaNa9IHV.js → openaiimage-bmpUPifv.js} +1 -1
  128. package/dist/assets/{openaiimage-CzR4PSXN.js → openaiimage-kTlSy1sn.js} +1 -1
  129. package/dist/assets/{openaiimage-C8TKksfD.js → openaiimage-kjvlnoXZ.js} +1 -1
  130. package/dist/assets/{pagination-Dadi3T3c.js → pagination-CjPMnvoG.js} +1 -1
  131. package/dist/assets/{pika-CY8G01g_.js → pika-Bm8RAjld.js} +1 -1
  132. package/dist/assets/{pixverse-BJ2HdxlW.js → pixverse-bny0Nyl_.js} +1 -1
  133. package/dist/assets/{popover-DYkL95yc.js → popover-hXeisgFI.js} +1 -1
  134. package/dist/assets/{producer-DvFZCpfU.js → producer-ysXtbtRo.js} +1 -1
  135. package/dist/assets/{qrart-C9zLG_6z.js → qrart-CjPRfOiB.js} +1 -1
  136. package/dist/assets/{realtime-DWn_fYBN.js → realtime-BLbYkauY.js} +1 -1
  137. package/dist/assets/{row-CTuxolD7.js → row-5dtZ6DfJ.js} +1 -1
  138. package/dist/assets/{seedance-BnhsmsW2.js → seedance-CHYisOvN.js} +1 -1
  139. package/dist/assets/{seedream-DD_qK_m3.js → seedream-BUw5nPh7.js} +1 -1
  140. package/dist/assets/{select-xK2ZUesB.js → select-DDah7mdR.js} +1 -1
  141. package/dist/assets/{serp-BV5BN6Fy.js → serp-CWcjjj2z.js} +1 -1
  142. package/dist/assets/{slider-BFKzJE0L.js → slider-CgOC9Fc_.js} +1 -1
  143. package/dist/assets/{solana-wallets-BCt-Ci5j.js → solana-wallets-C_CKTdOn.js} +2 -2
  144. package/dist/assets/{solana-wallets-vue-BlHSn6tE.js → solana-wallets-vue-m0YO_jrE.js} +1 -1
  145. package/dist/assets/{sora-DHPD57lB.js → sora-Cn_k-MXf.js} +1 -1
  146. package/dist/assets/{suno-C6Y_vJVC.js → suno-Dqp8HHxd.js} +1 -1
  147. package/dist/assets/{switch-Bz9UXHGk.js → switch-B_TTmYW_.js} +1 -1
  148. package/dist/assets/{table-6Mxc3xNy.js → table-14lYFmZr.js} +1 -1
  149. package/dist/assets/{tabs-CtZvnqow.js → tabs-DsayJIJU.js} +1 -1
  150. package/dist/assets/{time-picker-_cbXXPIs.js → time-picker-3rFJb4H7.js} +1 -1
  151. package/dist/assets/{tooltip-DMo49h1I.js → tooltip-DNiZcnVJ.js} +1 -1
  152. package/dist/assets/{upload-DzODCA15.js → upload-lwIDYY8G.js} +1 -1
  153. package/dist/assets/{veo-DQXKUpbF.js → veo-D-UMAY1m.js} +1 -1
  154. package/dist/assets/{wan-CnNDGUl6.js → wan-CWMuwEoY.js} +1 -1
  155. package/dist/assets/{web-VdbWkcmw.js → web-BIc01-8C.js} +1 -1
  156. package/dist/assets/{web-2ZoieRNs.js → web-BX_b2yMF.js} +1 -1
  157. package/dist/assets/{web-D-5TEDqL.js → web-BhheuYAW.js} +1 -1
  158. package/dist/assets/{web-BByOHaxq.js → web-CdMB-8lm.js} +1 -1
  159. package/dist/assets/{web-BxgkxDtg.js → web-DWSl-bMe.js} +1 -1
  160. package/dist/assets/{webextrator-B_8erGTC.js → webextrator-BhKEa3xo.js} +1 -1
  161. package/dist/index.html +2 -2
  162. package/package.json +1 -1
  163. package/dist/assets/Conversation-Da6jeVu0.js +0 -1
  164. package/dist/assets/Index-Brl4DSk-.js +0 -1
  165. package/dist/assets/Index-C7fQZrR7.css +0 -1
  166. package/dist/assets/Index-CXihbyoF.js +0 -1
  167. package/dist/assets/Index-DHK253L1.js +0 -1
  168. package/dist/assets/codingBridge-DVH2dYaH.js +0 -2
  169. package/dist/assets/esm-Bim-p6Sb.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,b as u,dt as d,et as f,k as p,nt as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{B as v,I as y,X as b,Z as x,nt as S}from"./use-deprecated-B-NFNg3W.js";import{r as C,t as w}from"./select-xK2ZUesB.js";import{n as T,t as E}from"./tabs-CtZvnqow.js";import{t as D}from"./upload-DzODCA15.js";import{t as O}from"./tooltip-DMo49h1I.js";import{t as k}from"./image-BKnKnVaq.js";import{t as A}from"./avatar-Chg0rxNt.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{n as ee,t as N}from"./collapse-DrK7wbng.js";import{t as P}from"./drawer-B1KhnI9D.js";import{n as F,r as I,t as te}from"./dropdown-UMEMC-MM.js";import{t as L}from"./input-number-CH0br6q0.js";import{n as ne,t as re}from"./skeleton-BwNBivMN.js";import{t as ie}from"./slider-BFKzJE0L.js";import{t as ae}from"./switch-Bz9UXHGk.js";import{Rn as oe}from"./constants-DqciFo58.js";import{$r as R,A as z,Br as B,Hr as V,Ht as H,Kt as U,Lr as W,Ut as G,Vt as K,Zn as q,_n as J,ci as Y,en as se,qn as ce}from"./index-CHpU1m3n.js";import{t as X}from"./index.es-BPpNb_kj.js";import{n as le}from"./taskDrawerMixin-DEgO_R5H.js";import{t as ue}from"./Consumption-9e8Kk4qS.js";import{i as Z,n as de,r as fe,t as pe}from"./pagination-Dadi3T3c.js";import{t as me}from"./NoTasks-Be_86fis.js";import{t as he}from"./PromptTextarea-C0Vv1r8K.js";import{n as ge,r as Q,t as _e}from"./Player-B27_rrp7.js";var ve=r({name:`LayoutProducer`,components:{ElDrawer:P,ElButton:R,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(e,r,i,a,s,c){let u=h(`font-awesome-icon`),p=h(`el-button`),m=h(`el-drawer`);return l(),t(`div`,ye,[n(`div`,be,[f(e.$slots,`config`,{},void 0,!0)]),n(`div`,xe,[f(e.$slots,`result`,{},void 0,!0)]),n(`div`,Se,[f(e.$slots,`preview`,{},void 0,!0)]),d(o(p,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(u,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!e.tasksEmpty]]),o(m,{modelValue:e.drawer,"onUpdate:modelValue":r[1]||=t=>e.drawer=t,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:g(()=>[f(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=z(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=r({name:`TypeSelector`,components:{ElSelect:C,ElOption:w,ElSwitch:ae,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||=oe}}),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(r,i,u,d,f,m){let _=h(`el-option`),v=h(`el-select`),y=h(`info-icon`),b=h(`el-switch`);return l(),t(`div`,null,[n(`div`,Ee,[n(`div`,De,[n(`span`,Oe,c(r.$t(`producer.name.model`)),1)]),o(v,{modelValue:r.model,"onUpdate:modelValue":i[0]||=e=>r.model=e,class:`w-full model-select`,size:`default`,placeholder:r.$t(`producer.placeholder.select`)},{default:g(()=>[(l(!0),t(s,null,e(r.options,e=>(l(),a(_,{key:e.value,label:e.label,value:e.value},{default:g(()=>[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`])]),r.custom?(l(),t(`div`,Me,[n(`div`,Ne,[n(`span`,Pe,c(r.$t(`producer.name.instrumental`)),1),o(y,{content:r.$t(`producer.description.instrumental`)},null,8,[`content`])]),o(b,{modelValue:r.instrumental,"onUpdate:modelValue":i[1]||=e=>r.instrumental=e},null,8,[`modelValue`])])):p(``,!0)])}var Ie=z(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=r({name:`UploadAudio`,components:{ElUpload:D,ElButton:R,ElRadioGroup:M,ElRadioButton:j,InfoIcon:Z,FontAwesomeIcon:X},mixins:[H],emits:[`change`],data(){return{fileList:[],uploadUrl:B()+`/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(){V.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,V.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,V.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`}),V.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){V.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,r,a,s,u,d){let f=h(`info-icon`),m=h(`font-awesome-icon`),_=h(`el-button`),v=h(`el-upload`),y=h(`el-radio-button`),b=h(`el-radio-group`);return l(),t(`div`,Re,[n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.$t(`producer.name.referenceAudios`)),1),o(f,{content:e.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),o(v,{"file-list":e.fileList,"onUpdate:fileList":r[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:g(()=>[o(_,{round:``,type:`primary`,size:`small`,loading:e.uploading},{default:g(()=>[o(m,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+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(),t(`div`,He,[n(`audio`,{src:e.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):p(``,!0),e.hasUploadedAudio?(l(),t(`div`,We,[o(b,{modelValue:e.uploadAction,"onUpdate:modelValue":r[1]||=t=>e.uploadAction=t,size:`small`},{default:g(()=>[o(y,{value:`upload_extend`},{default:g(()=>[i(c(e.$t(`producer.button.extend`)),1)]),_:1}),o(y,{value:`upload_cover`},{default:g(()=>[i(c(e.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):p(``,!0)])}var Ke=z(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=r({name:`PromptInput`,components:{PromptTextarea:he},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,t,n,r,i,o){let s=h(`prompt-textarea`);return l(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[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=z(qe,[[`render`,Je]]),Xe=r({name:`LyricInput`,components:{ElInput:Y,ElButton:R,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,V.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}),V.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{V.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,r,s,u,d,f){let m=h(`info-icon`),_=h(`font-awesome-icon`),v=h(`el-button`),y=h(`el-input`);return l(),t(`div`,Ze,[n(`div`,Qe,[n(`div`,$e,[n(`span`,et,c(e.$t(`producer.name.lyrics`)),1),o(m,{content:e.$t(`producer.description.lyrics`)},null,8,[`content`])]),e.config?.action===`extend`?p(``,!0):(l(),a(v,{key:0,size:`small`,loading:e.generatingLyrics,round:``,onClick:e.onGenerateLyrics},{default:g(()=>[e.generatingLyrics?p(``,!0):(l(),a(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),i(` `+c(e.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),e.config?.action===`extend`?(l(),a(y,{key:1,modelValue:e.lyric,"onUpdate:modelValue":r[1]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(l(),a(y,{key:0,modelValue:e.lyric,"onUpdate:modelValue":r[0]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=z(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=r({name:`StyleInput`,components:{ElInput:Y,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,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,it,[n(`div`,at,[n(`div`,ot,[n(`span`,st,c(e.$t(`producer.name.style`)),1),o(d,{content:e.$t(`producer.description.style`)},null,8,[`content`])])]),o(f,{modelValue:e.style,"onUpdate:modelValue":r[0]||=t=>e.style=t,rows:2,type:`textarea`,placeholder:e.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=z(rt,[[`render`,ct]]),ut=r({name:`TitleInput`,components:{ElInput:Y,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,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,dt,[n(`div`,ft,[n(`span`,pt,c(e.$t(`producer.name.title`)),1),o(d,{content:e.$t(`producer.description.title`)},null,8,[`content`])]),o(f,{modelValue:e.title,"onUpdate:modelValue":r[0]||=t=>e.title=t,placeholder:e.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=z(ut,[[`render`,mt]]),gt=r({name:`ExtendFromInput`,components:{ElImage:k,ElIcon:S,ElInputNumber:L,VideoPlay:x,VideoPause:b},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,r,i,a,s,u){let f=h(`el-input-number`),_=h(`el-image`),v=h(`video-pause`),y=h(`el-icon`),b=h(`video-play`),x=m(`loading`);return l(),t(`div`,_t,[n(`div`,vt,[n(`h2`,yt,c(e.$t(`producer.name.extend`)),1),n(`div`,bt,[o(f,{modelValue:e.value,"onUpdate:modelValue":r[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(),t(`div`,{key:0,class:`audio`,onClick:r[3]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,St,[o(_,{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(),t(`div`,{key:0,class:`overlay`,onClick:r[1]||=t=>e.onPause(e.audio)},[o(y,null,{default:g(()=>[o(v)]),_:1})])):p(``,!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(),t(`div`,{key:1,class:`overlay`,onClick:r[2]||=t=>e.onPlay(e.audio)},[o(y,null,{default:g(()=>[o(b)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ct,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!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)])])):p(``,!0)])])}var Ot=z(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=r({name:`CoverFromInput`,components:{ElImage:k,ElIcon:S,VideoPlay:x,VideoPause:b},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,r,i,a,s,u){let f=h(`el-image`),_=h(`video-pause`),v=h(`el-icon`),y=h(`video-play`),b=m(`loading`);return l(),t(`div`,At,[n(`div`,jt,[n(`h2`,Mt,c(e.$t(`producer.name.cover`)),1)]),n(`div`,Nt,[e.audio?(l(),t(`div`,{key:0,class:`audio`,onClick:r[2]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,Pt,[o(f,{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(),t(`div`,{key:0,class:`overlay`,onClick:r[0]||=t=>e.onPause(e.audio)},[o(v,null,{default:g(()=>[o(_)]),_:1})])):p(``,!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(),t(`div`,{key:1,class:`overlay`,onClick:r[1]||=t=>e.onPlay(e.audio)},[o(v,null,{default:g(()=>[o(y)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ft,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!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)])])):p(``,!0)])])}var Bt=z(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=r({name:`VocalGenderSelector`,components:{ElRadioGroup:M,ElRadioButton:j,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,r,a,s,u,d){let f=h(`info-icon`),p=h(`el-radio-button`),m=h(`el-radio-group`);return l(),t(`div`,Ht,[n(`div`,Ut,[n(`span`,Wt,c(e.$t(`producer.name.vocalGender`)),1),o(f,{content:e.$t(`producer.description.vocalGender`)},null,8,[`content`])]),o(m,{modelValue:e.vocalGender,"onUpdate:modelValue":r[0]||=t=>e.vocalGender=t},{default:g(()=>[o(p,{value:``},{default:g(()=>[i(c(e.$t(`producer.gender.auto`)),1)]),_:1}),o(p,{value:`f`},{default:g(()=>[i(c(e.$t(`producer.gender.female`)),1)]),_:1}),o(p,{value:`m`},{default:g(()=>[i(c(e.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=z(Vt,[[`render`,Gt]]),qt=r({name:`AdvancedParams`,components:{ElCollapse:N,ElCollapseItem:ee,ElInput:Y,ElSlider:ie,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,i,s,u,d){let f=h(`info-icon`),m=h(`el-input`),_=h(`el-slider`),v=h(`el-input-number`),y=h(`el-collapse-item`),b=h(`el-collapse`);return l(),a(b,{modelValue:e.activeNames,"onUpdate:modelValue":r[6]||=t=>e.activeNames=t,class:`advanced-collapse`},{default:g(()=>[o(y,{title:e.$t(`producer.name.advancedParams`),name:`advanced`},{default:g(()=>[e.config?.custom?(l(),t(`div`,Jt,[n(`div`,Yt,[n(`span`,Xt,c(e.$t(`producer.name.styleNegative`)),1),o(f,{content:e.$t(`producer.description.styleNegative`)},null,8,[`content`])]),o(m,{modelValue:e.styleNegative,"onUpdate:modelValue":r[0]||=t=>e.styleNegative=t,size:`small`,placeholder:e.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),e.config?.custom&&!e.config?.instrumental?(l(),t(`div`,Zt,[n(`div`,Qt,[n(`span`,$t,c(e.$t(`producer.name.lyricPrompt`)),1),o(f,{content:e.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),o(m,{modelValue:e.lyricPrompt,"onUpdate:modelValue":r[1]||=t=>e.lyricPrompt=t,size:`small`,placeholder:e.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),n(`div`,en,[n(`div`,tn,[n(`div`,nn,[n(`span`,rn,c(e.$t(`producer.name.weirdness`)),1),o(f,{content:e.$t(`producer.description.weirdness`)},null,8,[`content`])]),n(`span`,an,c(e.weirdness??.5),1)]),o(_,{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),o(f,{content:e.$t(`producer.description.soundStrength`)},null,8,[`content`])]),n(`span`,un,c(e.soundStrength??.7),1)]),o(_,{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(),t(`div`,dn,[n(`div`,fn,[n(`div`,pn,[n(`span`,mn,c(e.$t(`producer.name.lyricsStrength`)),1),o(f,{content:e.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),n(`span`,hn,c(e.lyricsStrength??.7),1)]),o(_,{modelValue:e.lyricsStrength,"onUpdate:modelValue":r[4]||=t=>e.lyricsStrength=t,min:0,max:1,step:.01},null,8,[`modelValue`])])):p(``,!0),n(`div`,gn,[n(`div`,_n,[n(`span`,vn,c(e.$t(`producer.name.seed`)),1),o(f,{content:e.$t(`producer.description.seed`)},null,8,[`content`])]),o(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=z(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=r({name:`ReplaceSectionInput`,components:{ElInputNumber:L,ElImage:k,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,r,i,a,s,u){let f=h(`info-icon`),g=h(`el-image`),_=h(`el-input-number`),v=m(`loading`);return l(),t(`div`,Sn,[n(`div`,Cn,[n(`h2`,wn,c(e.$t(`producer.name.replaceSection`)),1),o(f,{content:e.$t(`producer.description.replaceSection`)},null,8,[`content`])]),e.audio?(l(),t(`div`,Tn,[n(`div`,{class:`audio flex items-center`,onClick:r[0]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,En,[o(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)])])])):p(``,!0),n(`div`,An,[o(_,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":r[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`]),o(_,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":r[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=r({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:z(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:R,ElTabs:T,ElTabPane:E,Consumption:ue},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 U(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,r,s,u,d,f){let m=h(`type-selector`),_=h(`upload-audio`),v=h(`prompt-input`),y=h(`extend-from-input`),b=h(`cover-from-input`),x=h(`replace-section-input`),S=h(`advanced-params`),C=h(`el-tab-pane`),w=h(`lyric-input`),T=h(`style-input`),E=h(`title-input`),D=h(`vocal-gender-selector`),O=h(`el-tabs`),k=h(`consumption`),A=h(`font-awesome-icon`),j=h(`el-button`);return l(),t(`div`,Nn,[n(`div`,Pn,[o(O,{modelValue:e.mode,"onUpdate:modelValue":r[0]||=t=>e.mode=t,class:`producer-mode-tabs`,stretch:``},{default:g(()=>[o(C,{label:e.$t(`producer.mode.simple`),name:`simple`},{default:g(()=>[n(`div`,Fn,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),o(v,{class:`mb-4`}),e.config?.action===`extend`?(l(),a(y,{key:0,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:1,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:2,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`]),o(C,{label:e.$t(`producer.mode.custom`),name:`custom`},{default:g(()=>[n(`div`,In,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(w,{key:0,class:`mb-4`})),o(T,{class:`mb-4`}),o(E,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(D,{key:1,class:`mb-4`})),e.config?.action===`extend`?(l(),a(y,{key:2,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:3,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:4,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),n(`div`,Ln,[o(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),n(`div`,Rn,[o(j,{class:`flex-1`,onClick:e.onClearAll},{default:g(()=>[o(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),i(` `+c(e.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),o(j,{type:`primary`,class:`flex-1`,round:``,onClick:e.onGenerate},{default:g(()=>[o(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=z(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=r({name:`TaskPreview`,components:{ElImage:k,ElIcon:S,ElTooltip:O,FontAwesomeIcon:X,VideoPlay:x,VideoPause:b,ElDropdown:te,ElDropdownMenu:I,ElDropdownItem:F,Loading:y,ApiCodeDialog:fe},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===W.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),V.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,V.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):V.error(this.$t(`producer.message.fetchWavFailed`))}catch{V.error(this.$t(`producer.message.fetchWavFailed`))}finally{this.isFetchingWav=!1}},async onGenerateAudioUrl(e,t){let n={action:e,audio_id:t,async:!0},r=this.credential?.token;if(!r){console.error(`no token specified`);return}V.info(this.$t(`producer.message.startingTask`)),J.audio(n,{token:r}).then(()=>{V.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{V.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})}}}),Un={class:`task`},Wn=[`onClick`],Gn={class:`left`},Kn=[`onClick`],qn=[`onClick`],Jn={key:2,class:`duration`},Yn={class:`info`},Xn={class:`title`},Zn={class:`style`},Qn={class:`right`},$n={class:`el-dropdown-link`},er={class:`flex items-center min-w-[120px]`},tr={class:`flex items-center min-w-[120px]`},nr={class:`el-dropdown-link`};function rr(r,f,_,v,y,b){let x=h(`el-image`),S=h(`video-pause`),C=h(`el-icon`),w=h(`video-play`),T=h(`font-awesome-icon`),E=h(`el-tooltip`),D=h(`Loading`),O=h(`el-dropdown-item`),k=h(`el-dropdown-menu`),A=h(`el-dropdown`),j=h(`api-code-dialog`),M=m(`loading`);return l(),t(`div`,Un,[(l(!0),t(s,null,e(r.audios,e=>(l(),t(`div`,{key:e.id,class:`audio`,onClick:u(t=>r.onClick(e),[`stop`])},[d((l(),t(`div`,Gn,[o(x,{src:e?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),e?.audio_url&&r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:u(t=>r.onPause(e),[`stop`])},[o(C,null,{default:g(()=>[o(S)]),_:1})],8,Kn)):p(``,!0),e?.audio_url&&(r.$store.state?.producer?.audio?.id!==e.id||r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:u(t=>r.onPlay(e),[`stop`])},[o(C,null,{default:g(()=>[o(w)]),_:1})],8,qn)):p(``,!0),e?.duration?(l(),t(`div`,Jn,c(r.useFormatDuring(e?.duration)),1)):p(``,!0)])),[[M,!e?.audio_url]]),n(`div`,Yn,[n(`h2`,Xn,c(e?.title),1),n(`p`,Zn,c(e?.style),1)]),n(`div`,Qn,[o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[o(O,{disabled:r.isFetchingVideoUrl,onClick:t=>r.handleVideoDownload(e)},{default:g(()=>[n(`div`,er,[r.isFetchingVideoUrl?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onDownload(t,e?.audio_url),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{disabled:r.isFetchingWav,onClick:t=>r.handleWavDownload(e)},{default:g(()=>[n(`div`,tr,[r.isFetchingWav?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,$n,[o(E,{effect:`dark`,content:r.$t(`producer.button.download`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onExtend(t,e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:1,onClick:u(t=>r.onGetStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:2,onClick:u(t=>r.onGetAllStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(t=>r.onCover(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),e?.id?(l(),a(O,{key:3,onClick:u(t=>r.onVariation(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:4,onClick:u(t=>r.onSwapVocals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:5,onClick:u(t=>r.onSwapInstrumentals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:6,onClick:u(t=>r.onReplaceSection(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(r.onViewCode,[`stop`])},{default:g(()=>[o(T,{icon:`fa-solid fa-code`,class:`mr-1`}),i(` `+c(r.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,nr,[o(E,{effect:`dark`,content:r.$t(`producer.button.more`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Wn))),128)),o(j,{visible:r.apiCodeVisible,"onUpdate:visible":f[0]||=e=>r.apiCodeVisible=e,method:`POST`,path:r.apiCodePath,body:r.apiCodeBody,token:r.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ir=r({name:`RecentPanel`,components:{ElSkeletonItem:ne,ElSkeleton:re,TaskPreview:z(Hn,[[`render`,rr]]),Player:_e,NoTasks:me,ScrollList:de},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?.()}}}),ar={key:0,class:`tasks`},or={class:`left w-[70px] p-[10px] flex items-center`},sr={class:`main w-[calc(100%-70px)] flex-1 p-[10px]`},$={key:2,class:`w-full flex-1 flex items-center justify-center`},cr={class:`h-20`};function lr(r,i,c,u,f,m){let v=h(`el-skeleton-item`),y=h(`el-skeleton`),b=h(`task-preview`),x=h(`scroll-list`),S=h(`no-tasks`),C=h(`player`);return l(),t(s,null,[r.tasks?.items===void 0?(l(),t(`div`,ar,[(l(),t(s,null,e(3,e=>n(`div`,{key:e,class:`flex`},[n(`div`,or,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),n(`div`,sr,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),o(v,{variant:`text`})]),_:1})])])),64))])):r.tasks?.items?.length&&r.tasks?.items?.length>0?(l(),a(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:r.loading,onReachTop:i[0]||=e=>r.$emit(`reach-top`)},{default:g(()=>[(l(!0),t(s,null,e(r.tasks?.items,(e,t)=>(l(),a(b,{key:t,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):p(``,!0),r.tasks?.items?.length===0?(l(),t(`div`,$,[o(S)])):p(``,!0),d(n(`div`,cr,[o(C,{namespace:`producer`})],512),[[_,!!r.$store?.state?.producer?.audio?.object]])],64)}var ur=z(ir,[[`render`,lr]]),dr=r({name:`TaskPreview`,components:{IconPicture:v,ElImage:k,ElAvatar:A,ElIcon:S},computed:{audio(){return this.$store.state.producer?.audio}}}),fr={key:0,class:`size-full overflow-hidden`},pr={class:`relative h-[300px]`},mr={class:`flex items-center justify-center size-full bg-[var(--el-bg-color)]`},hr={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`},gr={class:`p-4`},_r={class:`flex items-center font-bold mb-2`},vr={class:`text-[var(--el-text-color-regular)] mb-2`},yr={class:`text-xs text-[var(--el-text-color-regular)]`},br={class:`mt-4 text-sm leading-[25px] whitespace-pre-wrap`},xr={key:1,class:`w-full h-full`};function Sr(e,r,i,a,s,u){let d=h(`icon-picture`),f=h(`el-icon`),p=h(`el-image`),m=h(`el-avatar`);return e.audio?.object?(l(),t(`div`,fr,[n(`div`,pr,[o(p,{src:e.audio.image_url,fit:`cover`,class:`size-full`},{error:g(()=>[n(`div`,mr,[o(f,{class:`text-3xl`},{default:g(()=>[o(d)]),_:1})])]),_:1},8,[`src`]),n(`h2`,hr,c(e.audio?.title),1)]),n(`div`,gr,[n(`div`,_r,[o(m,{size:30,src:e.audio?.image_url,class:`mr-2`},null,8,[`src`]),n(`span`,null,c(e.audio?.title),1)]),n(`p`,vr,c(e.audio?.style),1),n(`p`,yr,c(e.$dayjs.format(e.audio?.created_at)),1),n(`div`,br,[n(`p`,null,c(e.audio?.lyric),1)])])])):(l(),t(`div`,xr))}var Cr=r({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:ur,PreviewPanel:z(dr,[[`render`,Sr]])},mixins:[G],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===W.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===W.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===W.Request},needApply(){return this.$store.state.producer.status.getApplications===W.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 pe({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(){ce.create({application:this.application}).then(({data:e})=>{this.application=e,V.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&V.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(!K(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let e={...this.config,async:!0};if(!se())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}V.info(this.$t(`producer.message.startingTask`)),q(`producer`,J.audio(e,{token:t})).then(()=>{V.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{V.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 wr(e,t,n,r,i,s){let c=h(`config-panel`),u=h(`recent-panel`),d=h(`preview-panel`),f=h(`layout`);return l(),a(f,null,{config:g(()=>[o(c,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:g(()=>[o(u,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:g(()=>[o(d)]),_:1})}var Tr=z(Cr,[[`render`,wr],[`__scopeId`,`data-v-23eb99dc`]]);export{Tr as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,b as u,dt as d,et as f,k as p,nt as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{B as v,I as y,X as b,Z as x,nt as S}from"./use-deprecated-B-NFNg3W.js";import{r as C,t as w}from"./select-DDah7mdR.js";import{n as T,t as E}from"./tabs-DsayJIJU.js";import{t as D}from"./upload-lwIDYY8G.js";import{t as O}from"./tooltip-DNiZcnVJ.js";import{t as k}from"./image-Rt1tBHga.js";import{t as A}from"./avatar-Chg0rxNt.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{n as ee,t as N}from"./collapse-Cosm9h0L.js";import{t as P}from"./drawer-CaHf70Re.js";import{n as F,r as I,t as te}from"./dropdown-dCC6OPvq.js";import{t as L}from"./input-number-CmJUcGZE.js";import{n as ne,t as re}from"./skeleton-BwNBivMN.js";import{t as ie}from"./slider-CgOC9Fc_.js";import{t as ae}from"./switch-B_TTmYW_.js";import{zn as oe}from"./constants-BI-FWncP.js";import{$r as R,A as z,Br as B,Hr as V,Ht as H,Kt as U,Lr as W,Ut as G,Vt as K,Zn as q,_n as J,ci as Y,en as se,qn as ce}from"./index-CmR4fqhy.js";import{t as X}from"./index.es-D1U5NzTe.js";import{n as le}from"./taskDrawerMixin-DEgO_R5H.js";import{t as ue}from"./Consumption-DFgxLgQ0.js";import{i as Z,n as de,r as fe,t as pe}from"./pagination-CjPMnvoG.js";import{t as me}from"./NoTasks-Xnxp0ghd.js";import{t as he}from"./PromptTextarea-hPH8fLrL.js";import{n as ge,r as Q,t as _e}from"./Player-z0eKg5bN.js";var ve=r({name:`LayoutProducer`,components:{ElDrawer:P,ElButton:R,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(e,r,i,a,s,c){let u=h(`font-awesome-icon`),p=h(`el-button`),m=h(`el-drawer`);return l(),t(`div`,ye,[n(`div`,be,[f(e.$slots,`config`,{},void 0,!0)]),n(`div`,xe,[f(e.$slots,`result`,{},void 0,!0)]),n(`div`,Se,[f(e.$slots,`preview`,{},void 0,!0)]),d(o(p,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(u,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!e.tasksEmpty]]),o(m,{modelValue:e.drawer,"onUpdate:modelValue":r[1]||=t=>e.drawer=t,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:g(()=>[f(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=z(ve,[[`render`,Ce],[`__scopeId`,`data-v-cc984c6f`]]),Te=r({name:`TypeSelector`,components:{ElSelect:C,ElOption:w,ElSwitch:ae,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||=oe}}),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(r,i,u,d,f,m){let _=h(`el-option`),v=h(`el-select`),y=h(`info-icon`),b=h(`el-switch`);return l(),t(`div`,null,[n(`div`,Ee,[n(`div`,De,[n(`span`,Oe,c(r.$t(`producer.name.model`)),1)]),o(v,{modelValue:r.model,"onUpdate:modelValue":i[0]||=e=>r.model=e,class:`w-full model-select`,size:`default`,placeholder:r.$t(`producer.placeholder.select`)},{default:g(()=>[(l(!0),t(s,null,e(r.options,e=>(l(),a(_,{key:e.value,label:e.label,value:e.value},{default:g(()=>[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`])]),r.custom?(l(),t(`div`,Me,[n(`div`,Ne,[n(`span`,Pe,c(r.$t(`producer.name.instrumental`)),1),o(y,{content:r.$t(`producer.description.instrumental`)},null,8,[`content`])]),o(b,{modelValue:r.instrumental,"onUpdate:modelValue":i[1]||=e=>r.instrumental=e},null,8,[`modelValue`])])):p(``,!0)])}var Ie=z(Te,[[`render`,Fe],[`__scopeId`,`data-v-42496b9a`]]),Le=r({name:`UploadAudio`,components:{ElUpload:D,ElButton:R,ElRadioGroup:M,ElRadioButton:j,InfoIcon:Z,FontAwesomeIcon:X},mixins:[H],emits:[`change`],data(){return{fileList:[],uploadUrl:B()+`/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(){V.warning(this.$t(`producer.message.uploadReferencesExceed`))},onError(){this.uploading=!1,V.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,V.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`}),V.success(this.$t(`producer.message.startUploadAudioSuccess`))}catch(e){V.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,r,a,s,u,d){let f=h(`info-icon`),m=h(`font-awesome-icon`),_=h(`el-button`),v=h(`el-upload`),y=h(`el-radio-button`),b=h(`el-radio-group`);return l(),t(`div`,Re,[n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.$t(`producer.name.referenceAudios`)),1),o(f,{content:e.$t(`producer.description.uploadAudios`)},null,8,[`content`])]),o(v,{"file-list":e.fileList,"onUpdate:fileList":r[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:g(()=>[o(_,{round:``,type:`primary`,size:`small`,loading:e.uploading},{default:g(()=>[o(m,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+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(),t(`div`,He,[n(`audio`,{src:e.audioPreviewUrl,controls:``,class:`w-full`},null,8,Ue)])):p(``,!0),e.hasUploadedAudio?(l(),t(`div`,We,[o(b,{modelValue:e.uploadAction,"onUpdate:modelValue":r[1]||=t=>e.uploadAction=t,size:`small`},{default:g(()=>[o(y,{value:`upload_extend`},{default:g(()=>[i(c(e.$t(`producer.button.extend`)),1)]),_:1}),o(y,{value:`upload_cover`},{default:g(()=>[i(c(e.$t(`producer.button.cover_music`)),1)]),_:1})]),_:1},8,[`modelValue`])])):p(``,!0)])}var Ke=z(Le,[[`render`,Ge],[`__scopeId`,`data-v-7fd0580a`]]),qe=r({name:`PromptInput`,components:{PromptTextarea:he},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,t,n,r,i,o){let s=h(`prompt-textarea`);return l(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[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=z(qe,[[`render`,Je]]),Xe=r({name:`LyricInput`,components:{ElInput:Y,ElButton:R,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,V.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}),V.success(this.$t(`producer.message.generateLyricsSuccess`)))}catch{V.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,r,s,u,d,f){let m=h(`info-icon`),_=h(`font-awesome-icon`),v=h(`el-button`),y=h(`el-input`);return l(),t(`div`,Ze,[n(`div`,Qe,[n(`div`,$e,[n(`span`,et,c(e.$t(`producer.name.lyrics`)),1),o(m,{content:e.$t(`producer.description.lyrics`)},null,8,[`content`])]),e.config?.action===`extend`?p(``,!0):(l(),a(v,{key:0,size:`small`,loading:e.generatingLyrics,round:``,onClick:e.onGenerateLyrics},{default:g(()=>[e.generatingLyrics?p(``,!0):(l(),a(_,{key:0,icon:`fa-solid fa-wand-magic-sparkles`,class:`mr-1`})),i(` `+c(e.$t(`producer.button.generate_lyrics`)),1)]),_:1},8,[`loading`,`onClick`]))]),e.config?.action===`extend`?(l(),a(y,{key:1,modelValue:e.lyric,"onUpdate:modelValue":r[1]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.extend.lyrics`)},null,8,[`modelValue`,`placeholder`])):(l(),a(y,{key:0,modelValue:e.lyric,"onUpdate:modelValue":r[0]||=t=>e.lyric=t,rows:5,type:`textarea`,class:`lyrics`,placeholder:e.$t(`producer.placeholder.lyrics`)},null,8,[`modelValue`,`placeholder`]))])}var nt=z(Xe,[[`render`,tt],[`__scopeId`,`data-v-88c6da2b`]]),rt=r({name:`StyleInput`,components:{ElInput:Y,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,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,it,[n(`div`,at,[n(`div`,ot,[n(`span`,st,c(e.$t(`producer.name.style`)),1),o(d,{content:e.$t(`producer.description.style`)},null,8,[`content`])])]),o(f,{modelValue:e.style,"onUpdate:modelValue":r[0]||=t=>e.style=t,rows:2,type:`textarea`,placeholder:e.$t(`producer.placeholder.style`)},null,8,[`modelValue`,`placeholder`])])}var lt=z(rt,[[`render`,ct]]),ut=r({name:`TitleInput`,components:{ElInput:Y,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,r,i,a,s,u){let d=h(`info-icon`),f=h(`el-input`);return l(),t(`div`,dt,[n(`div`,ft,[n(`span`,pt,c(e.$t(`producer.name.title`)),1),o(d,{content:e.$t(`producer.description.title`)},null,8,[`content`])]),o(f,{modelValue:e.title,"onUpdate:modelValue":r[0]||=t=>e.title=t,placeholder:e.$t(`producer.placeholder.title`)},null,8,[`modelValue`,`placeholder`])])}var ht=z(ut,[[`render`,mt]]),gt=r({name:`ExtendFromInput`,components:{ElImage:k,ElIcon:S,ElInputNumber:L,VideoPlay:x,VideoPause:b},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,r,i,a,s,u){let f=h(`el-input-number`),_=h(`el-image`),v=h(`video-pause`),y=h(`el-icon`),b=h(`video-play`),x=m(`loading`);return l(),t(`div`,_t,[n(`div`,vt,[n(`h2`,yt,c(e.$t(`producer.name.extend`)),1),n(`div`,bt,[o(f,{modelValue:e.value,"onUpdate:modelValue":r[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(),t(`div`,{key:0,class:`audio`,onClick:r[3]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,St,[o(_,{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(),t(`div`,{key:0,class:`overlay`,onClick:r[1]||=t=>e.onPause(e.audio)},[o(y,null,{default:g(()=>[o(v)]),_:1})])):p(``,!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(),t(`div`,{key:1,class:`overlay`,onClick:r[2]||=t=>e.onPlay(e.audio)},[o(y,null,{default:g(()=>[o(b)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ct,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!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)])])):p(``,!0)])])}var Ot=z(gt,[[`render`,Dt],[`__scopeId`,`data-v-26d43480`]]),kt=r({name:`CoverFromInput`,components:{ElImage:k,ElIcon:S,VideoPlay:x,VideoPause:b},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,r,i,a,s,u){let f=h(`el-image`),_=h(`video-pause`),v=h(`el-icon`),y=h(`video-play`),b=m(`loading`);return l(),t(`div`,At,[n(`div`,jt,[n(`h2`,Mt,c(e.$t(`producer.name.cover`)),1)]),n(`div`,Nt,[e.audio?(l(),t(`div`,{key:0,class:`audio`,onClick:r[2]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,Pt,[o(f,{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(),t(`div`,{key:0,class:`overlay`,onClick:r[0]||=t=>e.onPause(e.audio)},[o(v,null,{default:g(()=>[o(_)]),_:1})])):p(``,!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(),t(`div`,{key:1,class:`overlay`,onClick:r[1]||=t=>e.onPlay(e.audio)},[o(v,null,{default:g(()=>[o(y)]),_:1})])):p(``,!0),e.audio?.duration?(l(),t(`div`,Ft,c(e.useFormatDuring(e.audio?.duration)),1)):p(``,!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)])])):p(``,!0)])])}var Bt=z(kt,[[`render`,zt],[`__scopeId`,`data-v-d8a8e583`]]),Vt=r({name:`VocalGenderSelector`,components:{ElRadioGroup:M,ElRadioButton:j,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,r,a,s,u,d){let f=h(`info-icon`),p=h(`el-radio-button`),m=h(`el-radio-group`);return l(),t(`div`,Ht,[n(`div`,Ut,[n(`span`,Wt,c(e.$t(`producer.name.vocalGender`)),1),o(f,{content:e.$t(`producer.description.vocalGender`)},null,8,[`content`])]),o(m,{modelValue:e.vocalGender,"onUpdate:modelValue":r[0]||=t=>e.vocalGender=t},{default:g(()=>[o(p,{value:``},{default:g(()=>[i(c(e.$t(`producer.gender.auto`)),1)]),_:1}),o(p,{value:`f`},{default:g(()=>[i(c(e.$t(`producer.gender.female`)),1)]),_:1}),o(p,{value:`m`},{default:g(()=>[i(c(e.$t(`producer.gender.male`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var Kt=z(Vt,[[`render`,Gt]]),qt=r({name:`AdvancedParams`,components:{ElCollapse:N,ElCollapseItem:ee,ElInput:Y,ElSlider:ie,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,i,s,u,d){let f=h(`info-icon`),m=h(`el-input`),_=h(`el-slider`),v=h(`el-input-number`),y=h(`el-collapse-item`),b=h(`el-collapse`);return l(),a(b,{modelValue:e.activeNames,"onUpdate:modelValue":r[6]||=t=>e.activeNames=t,class:`advanced-collapse`},{default:g(()=>[o(y,{title:e.$t(`producer.name.advancedParams`),name:`advanced`},{default:g(()=>[e.config?.custom?(l(),t(`div`,Jt,[n(`div`,Yt,[n(`span`,Xt,c(e.$t(`producer.name.styleNegative`)),1),o(f,{content:e.$t(`producer.description.styleNegative`)},null,8,[`content`])]),o(m,{modelValue:e.styleNegative,"onUpdate:modelValue":r[0]||=t=>e.styleNegative=t,size:`small`,placeholder:e.$t(`producer.placeholder.styleNegative`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),e.config?.custom&&!e.config?.instrumental?(l(),t(`div`,Zt,[n(`div`,Qt,[n(`span`,$t,c(e.$t(`producer.name.lyricPrompt`)),1),o(f,{content:e.$t(`producer.description.lyricPrompt`)},null,8,[`content`])]),o(m,{modelValue:e.lyricPrompt,"onUpdate:modelValue":r[1]||=t=>e.lyricPrompt=t,size:`small`,placeholder:e.$t(`producer.placeholder.lyricPrompt`)},null,8,[`modelValue`,`placeholder`])])):p(``,!0),n(`div`,en,[n(`div`,tn,[n(`div`,nn,[n(`span`,rn,c(e.$t(`producer.name.weirdness`)),1),o(f,{content:e.$t(`producer.description.weirdness`)},null,8,[`content`])]),n(`span`,an,c(e.weirdness??.5),1)]),o(_,{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),o(f,{content:e.$t(`producer.description.soundStrength`)},null,8,[`content`])]),n(`span`,un,c(e.soundStrength??.7),1)]),o(_,{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(),t(`div`,dn,[n(`div`,fn,[n(`div`,pn,[n(`span`,mn,c(e.$t(`producer.name.lyricsStrength`)),1),o(f,{content:e.$t(`producer.description.lyricsStrength`)},null,8,[`content`])]),n(`span`,hn,c(e.lyricsStrength??.7),1)]),o(_,{modelValue:e.lyricsStrength,"onUpdate:modelValue":r[4]||=t=>e.lyricsStrength=t,min:0,max:1,step:.01},null,8,[`modelValue`])])):p(``,!0),n(`div`,gn,[n(`div`,_n,[n(`span`,vn,c(e.$t(`producer.name.seed`)),1),o(f,{content:e.$t(`producer.description.seed`)},null,8,[`content`])]),o(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=z(qt,[[`render`,yn],[`__scopeId`,`data-v-f9296888`]]),xn=r({name:`ReplaceSectionInput`,components:{ElInputNumber:L,ElImage:k,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,r,i,a,s,u){let f=h(`info-icon`),g=h(`el-image`),_=h(`el-input-number`),v=m(`loading`);return l(),t(`div`,Sn,[n(`div`,Cn,[n(`h2`,wn,c(e.$t(`producer.name.replaceSection`)),1),o(f,{content:e.$t(`producer.description.replaceSection`)},null,8,[`content`])]),e.audio?(l(),t(`div`,Tn,[n(`div`,{class:`audio flex items-center`,onClick:r[0]||=t=>e.onClick(e.audio)},[d((l(),t(`div`,En,[o(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)])])])):p(``,!0),n(`div`,An,[o(_,{modelValue:e.replaceSectionStart,"onUpdate:modelValue":r[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`]),o(_,{modelValue:e.replaceSectionEnd,"onUpdate:modelValue":r[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=r({name:`PresetPanel`,components:{TypeSelector:Ie,PromptInput:Ye,LyricInput:nt,StyleInput:lt,TitleInput:ht,ExtendFromInput:Ot,CoverFromInput:Bt,UploadAudio:Ke,VocalGenderSelector:Kt,AdvancedParams:bn,ReplaceSectionInput:z(xn,[[`render`,jn]]),FontAwesomeIcon:X,ElButton:R,ElTabs:T,ElTabPane:E,Consumption:ue},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 U(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,r,s,u,d,f){let m=h(`type-selector`),_=h(`upload-audio`),v=h(`prompt-input`),y=h(`extend-from-input`),b=h(`cover-from-input`),x=h(`replace-section-input`),S=h(`advanced-params`),C=h(`el-tab-pane`),w=h(`lyric-input`),T=h(`style-input`),E=h(`title-input`),D=h(`vocal-gender-selector`),O=h(`el-tabs`),k=h(`consumption`),A=h(`font-awesome-icon`),j=h(`el-button`);return l(),t(`div`,Nn,[n(`div`,Pn,[o(O,{modelValue:e.mode,"onUpdate:modelValue":r[0]||=t=>e.mode=t,class:`producer-mode-tabs`,stretch:``},{default:g(()=>[o(C,{label:e.$t(`producer.mode.simple`),name:`simple`},{default:g(()=>[n(`div`,Fn,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),o(v,{class:`mb-4`}),e.config?.action===`extend`?(l(),a(y,{key:0,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:1,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:2,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`]),o(C,{label:e.$t(`producer.mode.custom`),name:`custom`},{default:g(()=>[n(`div`,In,[o(m,{class:`mb-4`}),o(_,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(w,{key:0,class:`mb-4`})),o(T,{class:`mb-4`}),o(E,{class:`mb-4`}),e.config?.instrumental?p(``,!0):(l(),a(D,{key:1,class:`mb-4`})),e.config?.action===`extend`?(l(),a(y,{key:2,class:`mb-4`})):p(``,!0),e.config?.action===`cover`?(l(),a(b,{key:3,class:`mb-4`})):p(``,!0),e.config?.action===`replace_section`?(l(),a(x,{key:4,class:`mb-4`})):p(``,!0),o(S,{class:`mb-4`})])]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),n(`div`,Ln,[o(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),n(`div`,Rn,[o(j,{class:`flex-1`,onClick:e.onClearAll},{default:g(()=>[o(A,{icon:`fa-solid fa-broom`,class:`mr-1`}),i(` `+c(e.$t(`producer.button.clear_all`)),1)]),_:1},8,[`onClick`]),o(j,{type:`primary`,class:`flex-1`,round:``,onClick:e.onGenerate},{default:g(()=>[o(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.generateButtonText),1)]),_:1},8,[`onClick`])])])])}var Bn=z(Mn,[[`render`,zn],[`__scopeId`,`data-v-4a4b209e`]]),Vn=ge(),Hn=r({name:`TaskPreview`,components:{ElImage:k,ElIcon:S,ElTooltip:O,FontAwesomeIcon:X,VideoPlay:x,VideoPause:b,ElDropdown:te,ElDropdownMenu:I,ElDropdownItem:F,Loading:y,ApiCodeDialog:fe},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===W.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),V.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,V.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):V.error(this.$t(`producer.message.fetchWavFailed`))}catch{V.error(this.$t(`producer.message.fetchWavFailed`))}finally{this.isFetchingWav=!1}},async onGenerateAudioUrl(e,t){let n={action:e,audio_id:t,async:!0},r=this.credential?.token;if(!r){console.error(`no token specified`);return}V.info(this.$t(`producer.message.startingTask`)),J.audio(n,{token:r}).then(()=>{V.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{V.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})}}}),Un={class:`task`},Wn=[`onClick`],Gn={class:`left`},Kn=[`onClick`],qn=[`onClick`],Jn={key:2,class:`duration`},Yn={class:`info`},Xn={class:`title`},Zn={class:`style`},Qn={class:`right`},$n={class:`el-dropdown-link`},er={class:`flex items-center min-w-[120px]`},tr={class:`flex items-center min-w-[120px]`},nr={class:`el-dropdown-link`};function rr(r,f,_,v,y,b){let x=h(`el-image`),S=h(`video-pause`),C=h(`el-icon`),w=h(`video-play`),T=h(`font-awesome-icon`),E=h(`el-tooltip`),D=h(`Loading`),O=h(`el-dropdown-item`),k=h(`el-dropdown-menu`),A=h(`el-dropdown`),j=h(`api-code-dialog`),M=m(`loading`);return l(),t(`div`,Un,[(l(!0),t(s,null,e(r.audios,e=>(l(),t(`div`,{key:e.id,class:`audio`,onClick:u(t=>r.onClick(e),[`stop`])},[d((l(),t(`div`,Gn,[o(x,{src:e?.image_url,class:`cover`,fit:`cover`,lazy:``},null,8,[`src`]),e?.audio_url&&r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`playing`?(l(),t(`div`,{key:0,class:`overlay`,onClick:u(t=>r.onPause(e),[`stop`])},[o(C,null,{default:g(()=>[o(S)]),_:1})],8,Kn)):p(``,!0),e?.audio_url&&(r.$store.state?.producer?.audio?.id!==e.id||r.$store.state?.producer?.audio?.id===e.id&&r.$store.state?.producer?.audio?.state===`paused`)?(l(),t(`div`,{key:1,class:`overlay`,onClick:u(t=>r.onPlay(e),[`stop`])},[o(C,null,{default:g(()=>[o(w)]),_:1})],8,qn)):p(``,!0),e?.duration?(l(),t(`div`,Jn,c(r.useFormatDuring(e?.duration)),1)):p(``,!0)])),[[M,!e?.audio_url]]),n(`div`,Yn,[n(`h2`,Xn,c(e?.title),1),n(`p`,Zn,c(e?.style),1)]),n(`div`,Qn,[o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[o(O,{disabled:r.isFetchingVideoUrl,onClick:t=>r.handleVideoDownload(e)},{default:g(()=>[n(`div`,er,[r.isFetchingVideoUrl?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_video`)),1)])]),_:1},8,[`disabled`,`onClick`]),e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onDownload(t,e?.audio_url),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.download_audio`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{disabled:r.isFetchingWav,onClick:t=>r.handleWavDownload(e)},{default:g(()=>[n(`div`,tr,[r.isFetchingWav?(l(),a(C,{key:0,class:`is-loading mr-2`},{default:g(()=>[o(D)]),_:1})):p(``,!0),n(`span`,null,c(r.$t(`producer.button.download_wav`)),1)])]),_:1},8,[`disabled`,`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,$n,[o(E,{effect:`dark`,content:r.$t(`producer.button.download`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-download`,class:`icon icon-download`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024),o(A,null,{dropdown:g(()=>[o(k,null,{default:g(()=>[e?.audio_url?(l(),a(O,{key:0,onClick:u(t=>r.onExtend(t,e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.extend`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:1,onClick:u(t=>r.onGetStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.get_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),e.id?(l(),a(O,{key:2,onClick:u(t=>r.onGetAllStems(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.all_stems`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(t=>r.onCover(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.cover_music`)),1)]),_:1},8,[`onClick`]),e?.id?(l(),a(O,{key:3,onClick:u(t=>r.onVariation(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.variation`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:4,onClick:u(t=>r.onSwapVocals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_vocals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:5,onClick:u(t=>r.onSwapInstrumentals(e.id),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.swap_instrumentals`)),1)]),_:1},8,[`onClick`])):p(``,!0),e?.id?(l(),a(O,{key:6,onClick:u(t=>r.onReplaceSection(e),[`stop`])},{default:g(()=>[i(c(r.$t(`producer.button.replace_section`)),1)]),_:1},8,[`onClick`])):p(``,!0),o(O,{onClick:u(r.onViewCode,[`stop`])},{default:g(()=>[o(T,{icon:`fa-solid fa-code`,class:`mr-1`}),i(` `+c(r.$t(`common.button.viewCode`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),default:g(()=>[n(`span`,nr,[o(E,{effect:`dark`,content:r.$t(`producer.button.more`),placement:`top`},{default:g(()=>[e?.audio_url||e?.video_url?(l(),a(T,{key:0,icon:`fa-solid fa-ellipsis`,class:`icon icon-ellipsis`})):p(``,!0)]),_:2},1032,[`content`])])]),_:2},1024)])],8,Wn))),128)),o(j,{visible:r.apiCodeVisible,"onUpdate:visible":f[0]||=e=>r.apiCodeVisible=e,method:`POST`,path:r.apiCodePath,body:r.apiCodeBody,token:r.$store.state.producer?.credential?.token||``},null,8,[`visible`,`path`,`body`,`token`])])}var ir=r({name:`RecentPanel`,components:{ElSkeletonItem:ne,ElSkeleton:re,TaskPreview:z(Hn,[[`render`,rr]]),Player:_e,NoTasks:me,ScrollList:de},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?.()}}}),ar={key:0,class:`tasks`},or={class:`left w-[70px] p-[10px] flex items-center`},sr={class:`main w-[calc(100%-70px)] flex-1 p-[10px]`},$={key:2,class:`w-full flex-1 flex items-center justify-center`},cr={class:`h-20`};function lr(r,i,c,u,f,m){let v=h(`el-skeleton-item`),y=h(`el-skeleton`),b=h(`task-preview`),x=h(`scroll-list`),S=h(`no-tasks`),C=h(`player`);return l(),t(s,null,[r.tasks?.items===void 0?(l(),t(`div`,ar,[(l(),t(s,null,e(3,e=>n(`div`,{key:e,class:`flex`},[n(`div`,or,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`image`,class:`avatar w-[50px] h-[50px]`})]),_:1})]),n(`div`,sr,[o(y,{animated:``},{template:g(()=>[o(v,{variant:`p`,class:`w-[200px] h-[15px] mb-[5px] mt-[10px]`}),o(v,{variant:`text`})]),_:1})])])),64))])):r.tasks?.items?.length&&r.tasks?.items?.length>0?(l(),a(x,{key:1,ref:`scrollList`,class:`flex-1 w-full overflow-y-auto tasks p-2`,loading:r.loading,onReachTop:i[0]||=e=>r.$emit(`reach-top`)},{default:g(()=>[(l(!0),t(s,null,e(r.tasks?.items,(e,t)=>(l(),a(b,{key:t,"model-value":e,class:`preview`},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):p(``,!0),r.tasks?.items?.length===0?(l(),t(`div`,$,[o(S)])):p(``,!0),d(n(`div`,cr,[o(C,{namespace:`producer`})],512),[[_,!!r.$store?.state?.producer?.audio?.object]])],64)}var ur=z(ir,[[`render`,lr]]),dr=r({name:`TaskPreview`,components:{IconPicture:v,ElImage:k,ElAvatar:A,ElIcon:S},computed:{audio(){return this.$store.state.producer?.audio}}}),fr={key:0,class:`size-full overflow-hidden`},pr={class:`relative h-[300px]`},mr={class:`flex items-center justify-center size-full bg-[var(--el-bg-color)]`},hr={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`},gr={class:`p-4`},_r={class:`flex items-center font-bold mb-2`},vr={class:`text-[var(--el-text-color-regular)] mb-2`},yr={class:`text-xs text-[var(--el-text-color-regular)]`},br={class:`mt-4 text-sm leading-[25px] whitespace-pre-wrap`},xr={key:1,class:`w-full h-full`};function Sr(e,r,i,a,s,u){let d=h(`icon-picture`),f=h(`el-icon`),p=h(`el-image`),m=h(`el-avatar`);return e.audio?.object?(l(),t(`div`,fr,[n(`div`,pr,[o(p,{src:e.audio.image_url,fit:`cover`,class:`size-full`},{error:g(()=>[n(`div`,mr,[o(f,{class:`text-3xl`},{default:g(()=>[o(d)]),_:1})])]),_:1},8,[`src`]),n(`h2`,hr,c(e.audio?.title),1)]),n(`div`,gr,[n(`div`,_r,[o(m,{size:30,src:e.audio?.image_url,class:`mr-2`},null,8,[`src`]),n(`span`,null,c(e.audio?.title),1)]),n(`p`,vr,c(e.audio?.style),1),n(`p`,yr,c(e.$dayjs.format(e.audio?.created_at)),1),n(`div`,br,[n(`p`,null,c(e.audio?.lyric),1)])])])):(l(),t(`div`,xr))}var Cr=r({name:`ProducerIndex`,components:{Layout:we,ConfigPanel:Bn,RecentPanel:ur,PreviewPanel:z(dr,[[`render`,Sr]])},mixins:[G],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.producer?.status?.getApplications===W.Request},tasksLoading(){return this.$store.state.producer?.status?.getTasks===W.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===W.Request},needApply(){return this.$store.state.producer.status.getApplications===W.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 pe({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(){ce.create({application:this.application}).then(({data:e})=>{this.application=e,V.success(this.$t(`application.message.applySuccessfully`))}).catch(e=>{e?.response?.data?.code===`duplication`&&V.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(!K(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let e={...this.config,async:!0};if(!se())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}V.info(this.$t(`producer.message.startingTask`)),q(`producer`,J.audio(e,{token:t})).then(()=>{V.success(this.$t(`producer.message.startTaskSuccess`))}).catch(e=>{V.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 wr(e,t,n,r,i,s){let c=h(`config-panel`),u=h(`recent-panel`),d=h(`preview-panel`),f=h(`layout`);return l(),a(f,null,{config:g(()=>[o(c,{onGenerate:e.onGenerateAudio},null,8,[`onGenerate`])]),result:g(()=>[o(u,{ref:`recentPanel`,class:`panel recent`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),preview:g(()=>[o(d)]),_:1})}var Tr=z(Cr,[[`render`,wr],[`__scopeId`,`data-v-23eb99dc`]]);export{Tr as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{D as e,F as t,O as n,P as r,Wt as i,Z as a,dt as o,nt as s,tt as c,ut as l}from"./vendor-chart-BJCvKk8-.js";import{n as u,t as d}from"./table-6Mxc3xNy.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-CTuxolD7.js";import{t as h}from"./Pagination-DRlr3vYx.js";import{A as g,Kn as _}from"./index-CHpU1m3n.js";import{t as v}from"./CopyToClipboard-BE1wy8qZ.js";var y=t({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(t,u,d,f,p,m){let h=c(`el-col`),g=c(`el-row`),_=c(`copy-to-clipboard`),v=c(`el-table-column`),y=c(`el-table`),O=c(`el-card`),k=c(`pagination`),A=s(`loading`);return a(),n(g,{class:`panel`},{default:l(()=>[r(h,{span:24},{default:l(()=>[r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[e(`h2`,b,i(t.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[r(O,{shadow:`hover`},{default:l(()=>[o((a(),n(y,{data:t.invitees,stripe:``},{default:l(()=>[r(v,{prop:`id`,label:t.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:l(t=>[e(`span`,x,i(t.row.id),1),e(`span`,S,[r(_,{content:t.row.id},null,8,[`content`])])]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.username`),width:`300px`},{default:l(t=>[e(`span`,C,i(t.row?.username),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.email`),width:`300px`},{default:l(t=>[e(`span`,w,i(t.row?.email),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.nickname`),width:`200px`},{default:l(t=>[e(`span`,T,i(t.row.nickname),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.dateJoined`)},{default:l(n=>[e(`span`,E,i(t.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,t.loading]])]),_:1})]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:10,offset:14},{default:l(()=>[e(`div`,D,[r(k,{"current-page":t.page,"page-size":t.limit,total:t.total,onChange:t.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,F as t,O as n,P as r,Wt as i,Z as a,dt as o,nt as s,tt as c,ut as l}from"./vendor-chart-BJCvKk8-.js";import{n as u,t as d}from"./table-14lYFmZr.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-5dtZ6DfJ.js";import{t as h}from"./Pagination-aD-CS8DI.js";import{A as g,Kn as _}from"./index-CmR4fqhy.js";import{t as v}from"./CopyToClipboard-DIqw8clv.js";var y=t({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(t,u,d,f,p,m){let h=c(`el-col`),g=c(`el-row`),_=c(`copy-to-clipboard`),v=c(`el-table-column`),y=c(`el-table`),O=c(`el-card`),k=c(`pagination`),A=s(`loading`);return a(),n(g,{class:`panel`},{default:l(()=>[r(h,{span:24},{default:l(()=>[r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[e(`h2`,b,i(t.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:24},{default:l(()=>[r(O,{shadow:`hover`},{default:l(()=>[o((a(),n(y,{data:t.invitees,stripe:``},{default:l(()=>[r(v,{prop:`id`,label:t.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:l(t=>[e(`span`,x,i(t.row.id),1),e(`span`,S,[r(_,{content:t.row.id},null,8,[`content`])])]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.username`),width:`300px`},{default:l(t=>[e(`span`,C,i(t.row?.username),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.email`),width:`300px`},{default:l(t=>[e(`span`,w,i(t.row?.email),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.nickname`),width:`200px`},{default:l(t=>[e(`span`,T,i(t.row.nickname),1)]),_:1},8,[`label`]),r(v,{label:t.$t(`user.field.dateJoined`)},{default:l(n=>[e(`span`,E,i(t.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,t.loading]])]),_:1})]),_:1})]),_:1}),r(g,null,{default:l(()=>[r(h,{span:10,offset:14},{default:l(()=>[e(`div`,D,[r(k,{"current-page":t.page,"page-size":t.limit,total:t.total,onChange:t.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{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{r as m,t as h}from"./select-xK2ZUesB.js";import{n as ee,t as g}from"./table-6Mxc3xNy.js";import{t as _}from"./card-DjyfNde2.js";import{t as v}from"./date-picker-DZsxIimL.js";import{n as y,t as b}from"./row-CTuxolD7.js";import{t as x}from"./Pagination-DRlr3vYx.js";import{t as S}from"./skeleton-BwNBivMN.js";import{$r as C,A as w,Bn as T,Zr as E,kr as D,qt as O}from"./index-CHpU1m3n.js";import{t as k}from"./index.es-BPpNb_kj.js";import{t as A}from"./CopyToClipboard-BE1wy8qZ.js";var j={total_count:0,total_spent:0,state_counts:{}},M=r({name:`ConsoleOrderList`,components:{Pagination:x,CopyToClipboard:A,ElRow:b,ElCol:y,ElTable:g,ElTableColumn:ee,ElButton:C,ElTag:E,ElCard:_,ElSelect:m,ElOption:h,ElDatePicker:v,ElSkeleton:S,FontAwesomeIcon:k},data(){return{OrderState:D,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:D.PENDING,label:this.$t(`order.state.pending`)},{value:D.FINISHED,label:this.$t(`order.state.finished`)},{value:D.PAID,label:this.$t(`order.state.paid`)},{value:D.EXPIRED,label:this.$t(`order.state.expired`)},{value:D.FAILED,label:this.$t(`order.state.failed`)},{value:D.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:O,stateTagType(e){return e===D.FINISHED||e===D.PAID?`success`:e===D.EXPIRED||e===D.FAILED?`danger`:e===D.REFUNDED?`warning`:`info`},stateLabel(e){return{[D.PENDING]:this.$t(`order.state.pending`),[D.PAID]:this.$t(`order.state.paid`),[D.FINISHED]:this.$t(`order.state.finished`),[D.EXPIRED]:this.$t(`order.state.expired`),[D.FAILED]:this.$t(`order.state.failed`),[D.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==D.PAID&&e!==D.FINISHED&&e!==D.EXPIRED&&e!==D.FAILED&&e!==D.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,T.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,T.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...j}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,T.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`},$={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,ee,g,_){let v=f(`el-col`),y=f(`el-row`),b=f(`el-skeleton`),x=f(`font-awesome-icon`),S=f(`el-card`),C=f(`el-option`),w=f(`el-select`),T=f(`el-date-picker`),E=f(`el-button`),D=f(`copy-to-clipboard`),O=f(`el-table-column`),k=f(`el-tag`),A=f(`el-table`),j=f(`pagination`),M=d(`loading`);return l(),a(y,{class:`panel`},{default:p(()=>[o(v,{span:24},{default:p(()=>[o(y,null,{default:p(()=>[o(v,{span:24},{default:p(()=>[n(`h2`,N,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(y,{gutter:16},{default:p(()=>[o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,P,[n(`div`,F,[o(x,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,I,c(r.$t(`order.title.totalOrders`)),1),n(`p`,L,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,R,[n(`div`,z,[o(x,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,B,c(r.$t(`order.title.totalSpent`)),1),n(`p`,V,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,H,[n(`div`,U,[o(x,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,te,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,W,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,G,[n(`div`,K,[o(x,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,q,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,J,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,Y,[o(w,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(C,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(w,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(C,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(E,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(x,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(y,null,{default:p(()=>[o(v,{span:24},{default:p(()=>[o(S,{shadow:`hover`},{default:p(()=>[u((l(),a(A,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(O,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,X,c(e.row.id),1),n(`span`,Z,[o(D,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,Q,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,$,c(e.row.description),1)]),_:1},8,[`label`]),o(O,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(k,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(O,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(E,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(E,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1})]),_:1})]),_:1}),o(y,null,{default:p(()=>[o(v,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(j,{"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 se=w(M,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,nt as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{r as m,t as h}from"./select-DDah7mdR.js";import{n as ee,t as g}from"./table-14lYFmZr.js";import{t as _}from"./card-DjyfNde2.js";import{t as v}from"./date-picker-Cf_K-mee.js";import{n as y,t as b}from"./row-5dtZ6DfJ.js";import{t as x}from"./Pagination-aD-CS8DI.js";import{t as S}from"./skeleton-BwNBivMN.js";import{$r as C,A as w,Bn as T,Zr as E,kr as D,qt as O}from"./index-CmR4fqhy.js";import{t as k}from"./index.es-D1U5NzTe.js";import{t as A}from"./CopyToClipboard-DIqw8clv.js";var j={total_count:0,total_spent:0,state_counts:{}},M=r({name:`ConsoleOrderList`,components:{Pagination:x,CopyToClipboard:A,ElRow:b,ElCol:y,ElTable:g,ElTableColumn:ee,ElButton:C,ElTag:E,ElCard:_,ElSelect:m,ElOption:h,ElDatePicker:v,ElSkeleton:S,FontAwesomeIcon:k},data(){return{OrderState:D,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:D.PENDING,label:this.$t(`order.state.pending`)},{value:D.FINISHED,label:this.$t(`order.state.finished`)},{value:D.PAID,label:this.$t(`order.state.paid`)},{value:D.EXPIRED,label:this.$t(`order.state.expired`)},{value:D.FAILED,label:this.$t(`order.state.failed`)},{value:D.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:O,stateTagType(e){return e===D.FINISHED||e===D.PAID?`success`:e===D.EXPIRED||e===D.FAILED?`danger`:e===D.REFUNDED?`warning`:`info`},stateLabel(e){return{[D.PENDING]:this.$t(`order.state.pending`),[D.PAID]:this.$t(`order.state.paid`),[D.FINISHED]:this.$t(`order.state.finished`),[D.EXPIRED]:this.$t(`order.state.expired`),[D.FAILED]:this.$t(`order.state.failed`),[D.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==D.PAID&&e!==D.FINISHED&&e!==D.EXPIRED&&e!==D.FAILED&&e!==D.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,T.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,T.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...j}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,T.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`},$={class:`description`},ne={class:`text-gray-500`},re={class:`created-at`},ie={class:`flex items-center justify-center flex-wrap`},ae={class:`float-right`};function oe(r,m,h,ee,g,_){let v=f(`el-col`),y=f(`el-row`),b=f(`el-skeleton`),x=f(`font-awesome-icon`),S=f(`el-card`),C=f(`el-option`),w=f(`el-select`),T=f(`el-date-picker`),E=f(`el-button`),D=f(`copy-to-clipboard`),O=f(`el-table-column`),k=f(`el-tag`),A=f(`el-table`),j=f(`pagination`),M=d(`loading`);return l(),a(y,{class:`panel`},{default:p(()=>[o(v,{span:24},{default:p(()=>[o(y,null,{default:p(()=>[o(v,{span:24},{default:p(()=>[n(`h2`,N,c(r.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),o(y,{gutter:16},{default:p(()=>[o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,P,[n(`div`,F,[o(x,{icon:`fa-solid fa-receipt`,class:`icon`})]),n(`p`,I,c(r.$t(`order.title.totalOrders`)),1),n(`p`,L,c(r.summary.total_count),1)]))]),_:1})]),_:1}),o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,R,[n(`div`,z,[o(x,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),n(`p`,B,c(r.$t(`order.title.totalSpent`)),1),n(`p`,V,c(r.getPriceString({value:r.summary.total_spent})),1)]))]),_:1})]),_:1}),o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,H,[n(`div`,U,[o(x,{icon:`fa-solid fa-check-circle`,class:`icon`})]),n(`p`,te,c(r.$t(`order.title.finishedOrders`)),1),n(`p`,W,c(r.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),o(v,{md:6,sm:12,xs:24},{default:p(()=>[o(S,{shadow:`hover`,class:`item-mini mb-3`},{default:p(()=>[r.summaryLoading?(l(),a(b,{key:0})):(l(),t(`div`,G,[n(`div`,K,[o(x,{icon:`fa-solid fa-clock`,class:`icon`})]),n(`p`,q,c(r.$t(`order.title.pendingOrders`)),1),n(`p`,J,c(r.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),n(`div`,Y,[o(w,{modelValue:r.filterState,"onUpdate:modelValue":m[0]||=e=>r.filterState=e,clearable:``,placeholder:r.$t(`order.field.allStates`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.stateOptions,e=>(l(),a(C,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(w,{modelValue:r.filterPayWay,"onUpdate:modelValue":m[1]||=e=>r.filterPayWay=e,clearable:``,placeholder:r.$t(`order.field.allPayWays`),class:`filter-select`,onChange:r.onFilterChange},{default:p(()=>[(l(!0),t(s,null,e(r.payWayOptions,e=>(l(),a(C,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),o(T,{modelValue:r.createdAtRange,"onUpdate:modelValue":m[2]||=e=>r.createdAtRange=e,type:`datetimerange`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),o(E,{type:`primary`,plain:``,loading:r.exporting,onClick:r.onExport},{default:p(()=>[o(x,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),o(y,null,{default:p(()=>[o(v,{span:24},{default:p(()=>[o(S,{shadow:`hover`},{default:p(()=>[u((l(),a(A,{data:r.orders,stripe:``,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:p(()=>[o(O,{prop:`id`,label:r.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:p(e=>[n(`span`,X,c(e.row.id),1),n(`span`,Z,[o(D,{content:e.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.price`),width:`110px`,align:`center`},{default:p(e=>[n(`span`,Q,c(r.getPriceString({value:e.row?.price})),1)]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,$,c(e.row.description),1)]),_:1},8,[`label`]),o(O,{prop:`state`,label:r.$t(`order.field.state`),width:`130px`,align:`center`},{default:p(e=>[o(k,{type:r.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:p(()=>[i(c(r.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:p(e=>[n(`span`,ne,c(e.row.pay_way||`-`),1)]),_:1},8,[`label`]),o(O,{label:r.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:p(e=>[n(`span`,re,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`]),o(O,{"min-width":`130px`,fixed:`right`},{default:p(e=>[n(`div`,ie,[r.isPendingAction(e.row.state)?(l(),a(E,{key:0,type:`primary`,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(l(),a(E,{key:1,size:`small`,onClick:t=>r.goToDetail(e.row.id)},{default:p(()=>[i(c(r.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1})]),_:1})]),_:1}),o(y,null,{default:p(()=>[o(v,{span:10,offset:14},{default:p(()=>[n(`div`,ae,[o(j,{"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 se=w(M,[[`render`,oe],[`__scopeId`,`data-v-350ab467`]]);export{se as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{n as h,t as g}from"./table-6Mxc3xNy.js";import{t as ee}from"./card-DjyfNde2.js";import{n as _,t as v}from"./row-CTuxolD7.js";import{t as y}from"./empty-CdsD8g84.js";import{t as b}from"./Pagination-DRlr3vYx.js";import{t as x}from"./skeleton-BwNBivMN.js";import{t as S}from"./switch-Bz9UXHGk.js";import{o as C}from"./surface-D249_eDG.js";import{$r as w,A as T,Dr as E,Fr as D,Hr as O,Or as k,Pr as A,U as j,Y as M,Zr as N,qn as P}from"./index-CHpU1m3n.js";import{t as F}from"./index.es-BPpNb_kj.js";import{t as I}from"./CopyToClipboard-BE1wy8qZ.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:b,CopyToClipboard:I,ElTable:g,ElRow:v,ElButton:w,ElCol:_,ElTag:N,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:h,ElCard:ee,FontAwesomeIcon:F},data(){return{credentialType:E,serviceType:k,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`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return C()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||P.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{O.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{O.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:M,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:j,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=A.INDIVIDUAL){return new Promise((t,n)=>{P.getAll({limit:this.limit,...e===A.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:D.USAGE,scope:e}).then(({data:n})=>{e===A.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{O.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(A.INDIVIDUAL),this.onFetchApplications(A.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){P.create({type:D.USAGE,scope:A.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(A.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}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=T(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{n as h,t as g}from"./table-14lYFmZr.js";import{t as ee}from"./card-DjyfNde2.js";import{n as _,t as v}from"./row-5dtZ6DfJ.js";import{t as y}from"./empty-CdsD8g84.js";import{t as b}from"./Pagination-aD-CS8DI.js";import{t as x}from"./skeleton-BwNBivMN.js";import{t as S}from"./switch-B_TTmYW_.js";import{o as C}from"./surface-D249_eDG.js";import{$r as w,A as T,Dr as E,Fr as D,Hr as O,Or as k,Pr as A,U as j,Y as M,Zr as N,qn as P}from"./index-CmR4fqhy.js";import{t as F}from"./index.es-D1U5NzTe.js";import{t as I}from"./CopyToClipboard-DIqw8clv.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:b,CopyToClipboard:I,ElTable:g,ElRow:v,ElButton:w,ElCol:_,ElTag:N,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:h,ElCard:ee,FontAwesomeIcon:F},data(){return{credentialType:E,serviceType:k,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`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return C()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||P.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{O.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{O.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:M,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:j,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=A.INDIVIDUAL){return new Promise((t,n)=>{P.getAll({limit:this.limit,...e===A.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:D.USAGE,scope:e}).then(({data:n})=>{e===A.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{O.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(A.INDIVIDUAL),this.onFetchApplications(A.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){P.create({type:D.USAGE,scope:A.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(A.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}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=T(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{r as C,t as w}from"./select-xK2ZUesB.js";import{n as T,t as E}from"./table-6Mxc3xNy.js";import{n as D,t as O}from"./tabs-CtZvnqow.js";import{t as k}from"./card-DjyfNde2.js";import{n as A,r as j}from"./radio-3Hz7h3DR.js";import{t as M}from"./date-picker-DZsxIimL.js";import{n as N,t as P}from"./row-CTuxolD7.js";import{t as F}from"./Pagination-DRlr3vYx.js";import{n as I,t as L}from"./skeleton-BwNBivMN.js";import{$r as R,A as z,Dr as B,Fr as V,Gr as H,Hn as U,Or as W,Un as G,Vn as K,Zr as q,qn as J}from"./index-CHpU1m3n.js";import{t as Y}from"./index.es-BPpNb_kj.js";import{t as X}from"./CopyToClipboard-BE1wy8qZ.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:F,ElTag:q,ElDatePicker:M,ElTable:E,ElSelect:C,ElOption:w,CopyToClipboard:X,ElRow:P,ElCol:N,ElTableColumn:T,ElCard:k,ElRadioButton:A,ElRadioGroup:j,ElSkeleton:L,ElSkeletonItem:I,ElDialog:H,ElTabs:D,ElTabPane:O,ElButton:R,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:B,serviceType:W,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()||W.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===W.API?this.onFetchApiUsages():this.type===W.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 U.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&&U.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(){J.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:V.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,K.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,U.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,G.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,U.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 U.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(r,u,d,ee,m,g){let _=b(`el-col`),v=b(`el-row`),y=b(`el-radio-button`),C=b(`el-radio-group`),w=b(`el-option`),T=b(`el-select`),E=b(`el-skeleton-item`),D=b(`el-skeleton`),O=b(`el-date-picker`),k=b(`font-awesome-icon`),A=b(`el-button`),j=b(`el-card`),M=b(`bar-chart`),N=b(`el-table-column`),P=b(`el-tag`),F=b(`copy-to-clipboard`),I=b(`el-table`),L=b(`el-tab-pane`),R=b(`el-tabs`),z=b(`el-dialog`),B=b(`pagination`),V=h(`loading`);return l(),a(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(v,null,{default:x(()=>[o(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:x(()=>[o(y,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(y,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:x(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[S,!1]]),r.type===r.serviceType.API?(l(),a(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:x(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:x(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:x(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:x(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:x(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):p(``,!0)]),_:1}),o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[r.type===r.serviceType.API?(l(),a(v,{key:0,gutter:24,class:`mb-5`},{default:x(()=>[o(_,{md:6,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(_,{md:18,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):p(``,!0),o(j,{shadow:`hover`},{default:x(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:x(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:x(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:x(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):p(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:x(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:x(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):p(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:x(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):p(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:x(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:x(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:x(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(v,null,{default:x(()=>[o(_,{span:10,offset:14},{default:x(()=>[n(`div`,ye,[o(B,{"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 xe=z(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as ee,k as p,n as m,nt as h,o as g,r as _,s as v,t as y,tt as b,ut as x,v as S}from"./vendor-chart-BJCvKk8-.js";import{r as C,t as w}from"./select-DDah7mdR.js";import{n as T,t as E}from"./table-14lYFmZr.js";import{n as D,t as O}from"./tabs-DsayJIJU.js";import{t as k}from"./card-DjyfNde2.js";import{n as A,r as j}from"./radio-3Hz7h3DR.js";import{t as M}from"./date-picker-Cf_K-mee.js";import{n as N,t as P}from"./row-5dtZ6DfJ.js";import{t as F}from"./Pagination-aD-CS8DI.js";import{n as I,t as L}from"./skeleton-BwNBivMN.js";import{$r as R,A as z,Dr as B,Fr as V,Gr as H,Hn as U,Or as W,Un as G,Vn as K,Zr as q,qn as J}from"./index-CmR4fqhy.js";import{t as Y}from"./index.es-D1U5NzTe.js";import{t as X}from"./CopyToClipboard-DIqw8clv.js";ee.register(_,u,m,v,d,g);var Z=r({name:`ConsoleUsageList`,components:{Pagination:F,ElTag:q,ElDatePicker:M,ElTable:E,ElSelect:C,ElOption:w,CopyToClipboard:X,ElRow:P,ElCol:N,ElTableColumn:T,ElCard:k,ElRadioButton:A,ElRadioGroup:j,ElSkeleton:L,ElSkeletonItem:I,ElDialog:H,ElTabs:D,ElTabPane:O,ElButton:R,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:B,serviceType:W,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()||W.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===W.API?this.onFetchApiUsages():this.type===W.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 U.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&&U.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(){J.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:V.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,K.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,U.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,G.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,U.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 U.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(r,u,d,ee,m,g){let _=b(`el-col`),v=b(`el-row`),y=b(`el-radio-button`),C=b(`el-radio-group`),w=b(`el-option`),T=b(`el-select`),E=b(`el-skeleton-item`),D=b(`el-skeleton`),O=b(`el-date-picker`),k=b(`font-awesome-icon`),A=b(`el-button`),j=b(`el-card`),M=b(`bar-chart`),N=b(`el-table-column`),P=b(`el-tag`),F=b(`copy-to-clipboard`),I=b(`el-table`),L=b(`el-tab-pane`),R=b(`el-tabs`),z=b(`el-dialog`),B=b(`pagination`),V=h(`loading`);return l(),a(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(v,null,{default:x(()=>[o(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:x(()=>[o(y,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(y,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:x(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[S,!1]]),r.type===r.serviceType.API?(l(),a(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:x(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:x(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:x(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:x(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):p(``,!0),r.type===r.serviceType.API?(l(),a(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:x(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:x(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):p(``,!0)]),_:1}),o(v,null,{default:x(()=>[o(_,{span:24},{default:x(()=>[r.type===r.serviceType.API?(l(),a(v,{key:0,gutter:24,class:`mb-5`},{default:x(()=>[o(_,{md:6,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(_,{md:18,xs:24},{default:x(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:x(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):p(``,!0),o(j,{shadow:`hover`},{default:x(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:x(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:x(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:x(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):p(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:x(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:x(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):p(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:x(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):p(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:x(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:x(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:x(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:x(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:x(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:x(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):p(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:x(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:x(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:x(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(v,null,{default:x(()=>[o(_,{span:10,offset:14},{default:x(()=>[n(`div`,ye,[o(B,{"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 xe=z(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
@@ -1,4 +1,4 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{H as p}from"./use-deprecated-B-NFNg3W.js";import{t as m}from"./switch-Bz9UXHGk.js";import{i as ee}from"./surface-D249_eDG.js";import{$r as te,A as h,M as g,Zr as _,ci as v}from"./index-CHpU1m3n.js";import{t as y}from"./index.es-BPpNb_kj.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:te,ElTag:_,ElSwitch:m,ElInput:v,FontAwesomeIcon:y},data(){return{Plus:p,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,onFocus:null,cuOff:null}},computed:{desktop(){return!!g()},android(){return ee()}},async mounted(){let e=g();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
1
+ import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,k as u,tt as d,ut as f}from"./vendor-chart-BJCvKk8-.js";import{H as p}from"./use-deprecated-B-NFNg3W.js";import{t as m}from"./switch-B_TTmYW_.js";import{i as ee}from"./surface-D249_eDG.js";import{$r as te,A as h,M as g,Zr as _,ci as v}from"./index-CmR4fqhy.js";import{t as y}from"./index.es-D1U5NzTe.js";var b=r({name:`LocalToolsSetting`,components:{ElButton:te,ElTag:_,ElSwitch:m,ElInput:v,FontAwesomeIcon:y},data(){return{Plus:p,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,onFocus:null,cuOff:null}},computed:{desktop(){return!!g()},android(){return ee()}},async mounted(){let e=g();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
2
2
  `),envText:Object.entries(e.env??{}).map(([e,t])=>`${e}=${t}`).join(`
3
3
  `),enabled:e.enabled!==!1})),this.mcpStatuses=await e.mcp?.status()??[],this.tools=(await e.listTools()).map(e=>e.name),this.computerTools=await e.computerTools?.()??[],this.builtinTools=await e.builtinTools?.()??[];let n=await e.perm?.status();n?.mac&&(this.perm=n),await this.loadGrants(),this.android&&(await this.refreshA11y(),this.onFocus=()=>{document.visibilityState===`visible`&&this.refreshA11y()},document.addEventListener(`visibilitychange`,this.onFocus)),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.(),this.onFocus&&document.removeEventListener(`visibilitychange`,this.onFocus)},methods:{async refreshA11y(){let e=await g()?.perm?.status();this.a11yEnabled=e?.accessibility===!0},async openAndroidAccessibility(){await g()?.perm?.openPane(`accessibility`)},async loadGrants(){let e=g();if(!e?.grants){this.grants=null;return}let t=await e.grants.list(),n={},r={},i=new Set(this.builtinTools.map(e=>e.name)),a=[];for(let e of t){if(e.startsWith(`computer.`)&&!e.includes(`:`)){n[e]=!0;continue}if(!e.includes(`:`)&&i.has(e)){r[e]=!0;continue}let t=e.indexOf(`:{`),o=t>=0?t:e.indexOf(`:`);a.push({key:e,name:o>=0?e.slice(0,o):e,input:o>=0?e.slice(o+1):``})}this.computerGrants=n,this.toolGrants=r,this.grants=a},async addFolder(){let e=await g()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
@@ -1 +1 @@
1
- import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{A as s}from"./index-CHpU1m3n.js";import{t as c}from"./LocalTools-DnutI4O8.js";var l=n({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(n,s,c,l,d,f){let p=o(`local-tools-setting`);return a(),e(`div`,u,[t(`h2`,null,i(n.$t(`common.settings.localTools`)),1),r(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
1
+ import{A as e,D as t,F as n,P as r,Wt as i,Z as a,tt as o}from"./vendor-chart-BJCvKk8-.js";import{A as s}from"./index-CmR4fqhy.js";import{t as c}from"./LocalTools-BYTYgsmP.js";var l=n({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(n,s,c,l,d,f){let p=o(`local-tools-setting`);return a(),e(`div`,u,[t(`h2`,null,i(n.$t(`common.settings.localTools`)),1),r(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./Navigator-DoISXXSE.js";import{t as p}from"./checkbox-BC1X4B2U.js";import{t as m}from"./divider-LA__Fty9.js";import"./constants-DqciFo58.js";import{$r as h,A as g,Br as _,Fr as v,Gr as y,Gt as b,Hr as x,Lr as S,Pr as C,qn as w}from"./index-CHpU1m3n.js";import{t as T}from"./Status-CUL6T7ei.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:y,ElDivider:m,ElCheckbox:p,ElButton:h},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:_,onApply(){if(!this.checked){x.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(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$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:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=g(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:f,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer: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===S.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),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(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=b(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 w.create({type:v.USAGE,scope:C.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`):x.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);x({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(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`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=g(F,[[`render`,L],[`__scopeId`,`data-v-f071b44e`]]);export{R as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./Navigator-iSknSN8-.js";import{t as p}from"./checkbox-BC1X4B2U.js";import{t as m}from"./divider-LA__Fty9.js";import"./constants-BI-FWncP.js";import{$r as h,A as g,Br as _,Fr as v,Gr as y,Gt as b,Hr as x,Lr as S,Pr as C,qn as w}from"./index-CmR4fqhy.js";import{t as T}from"./Status-Dd0lLBot.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:y,ElDivider:m,ElCheckbox:p,ElButton:h},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:_,onApply(){if(!this.checked){x.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(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$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:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=g(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:f,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer: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===S.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),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(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=b(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 w.create({type:v.USAGE,scope:C.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`):x.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);x({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(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`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=g(F,[[`render`,L],[`__scopeId`,`data-v-f071b44e`]]);export{R as default};