@acedatacloud/nexior 3.278.14 → 3.278.15

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 (145) hide show
  1. package/dist/assets/{ApiCodeButton-BZfzlGoT.js → ApiCodeButton-D4B5DS_n.js} +1 -1
  2. package/dist/assets/{AskUserQuestionCard-NUXQL8Zq.js → AskUserQuestionCard-DiHtY08K.js} +1 -1
  3. package/dist/assets/{Auth-Doy_6USi.js → Auth-DAvEIxXl.js} +1 -1
  4. package/dist/assets/{Bare-CXquigjr.js → Bare-Db3hbIHK.js} +1 -1
  5. package/dist/assets/{BotPlaceholder-C6fcffYi.js → BotPlaceholder-CO654Xhh.js} +1 -1
  6. package/dist/assets/{BottomFooter-DC3RFv05.js → BottomFooter-BRNaWNfL.js} +1 -1
  7. package/dist/assets/{Callback-CD9_MGLj.js → Callback-TuWuZqVe.js} +1 -1
  8. package/dist/assets/{Console-Di0KxRmd.js → Console-NtNieH8x.js} +1 -1
  9. package/dist/assets/{Consumption-BobAFFfW.js → Consumption-Cmk_G3JD.js} +1 -1
  10. package/dist/assets/{Conversation-BHeZQ0cn.js → Conversation-Bj7KoPPc.js} +1 -1
  11. package/dist/assets/{CopyToClipboard-Rmd8YAx9.js → CopyToClipboard-yGJQFFP1.js} +1 -1
  12. package/dist/assets/{Detail-BQe7rywJ.js → Detail-Sy1iHSv6.js} +2 -2
  13. package/dist/assets/{Extra-BNvUcS0g.js → Extra-QCLwa_33.js} +1 -1
  14. package/dist/assets/{FilePreview-Boy0e4Gm.js → FilePreview-B4obFVCz.js} +1 -1
  15. package/dist/assets/{Hailuo-CfpyrSKC.js → Hailuo-Mf8iqfjV.js} +1 -1
  16. package/dist/assets/{History-C5DLqula.js → History-BnF7iGsM.js} +1 -1
  17. package/dist/assets/{ImagePreview-DAzwYsLG.js → ImagePreview-NgPB2xG0.js} +1 -1
  18. package/dist/assets/{ImageWrapper-CfqL_TA7.js → ImageWrapper-CyPlUNHb.js} +1 -1
  19. package/dist/assets/{Index-B6ykCwld.js → Index-0gM2Dup2.js} +1 -1
  20. package/dist/assets/{Index-y76mv7dZ.js → Index-45RbCxw9.js} +1 -1
  21. package/dist/assets/{Index-3_TPczMd.js → Index-6VxDp8mr.js} +1 -1
  22. package/dist/assets/{Index-D51jJbBd.js → Index-B4lXe4Nx.js} +1 -1
  23. package/dist/assets/{Index-CQKawnfM.js → Index-B_MUalKV.js} +1 -1
  24. package/dist/assets/{Index-XT8lP3be.js → Index-BeAgigQg.js} +1 -1
  25. package/dist/assets/{Index-BdCVgEfW.js → Index-BkhbZxAP.js} +1 -1
  26. package/dist/assets/{Index-B5JBzKDz.js → Index-BrKvnK1C.js} +1 -1
  27. package/dist/assets/{Index-Cm7Bya9_.js → Index-CLXbf6oi.js} +1 -1
  28. package/dist/assets/{Index-Dq7Gmukk.js → Index-CO1cJ49s.js} +1 -1
  29. package/dist/assets/{Index-8WpZCmW0.js → Index-CPJ7d-4L.js} +1 -1
  30. package/dist/assets/{Index-DG_c_T4b.js → Index-CPRFE3IZ.js} +1 -1
  31. package/dist/assets/{Index-DeM1WGR2.js → Index-Cezey0Dr.js} +1 -1
  32. package/dist/assets/{Index-ep5QBmCo.js → Index-CnLazsvn.js} +1 -1
  33. package/dist/assets/{Index-tslORP-h.js → Index-D0C8pVvD.js} +1 -1
  34. package/dist/assets/{Index-ClFKMYbv.js → Index-D85wvfO_.js} +1 -1
  35. package/dist/assets/{Index-Cy2hCycU.js → Index-DC5JDkEK.js} +1 -1
  36. package/dist/assets/{Index-joBZYr-D.js → Index-G7hA_iFB.js} +1 -1
  37. package/dist/assets/{Index-Dspzyxdl.js → Index-H_W1gEET.js} +1 -1
  38. package/dist/assets/{Index-DGvG8UB4.js → Index-OeK2ps4_.js} +1 -1
  39. package/dist/assets/{Index-CR_a2Oik.js → Index-Pud1AcVO.js} +1 -1
  40. package/dist/assets/{Index-ucRn7oVv.js → Index-bWoY7E28.js} +1 -1
  41. package/dist/assets/{Index-DQ1j41kD.js → Index-j26bj1eQ.js} +1 -1
  42. package/dist/assets/{Index-ByFu0OTO.js → Index-owb9cWvX.js} +1 -1
  43. package/dist/assets/{Index-BYQog1jU.js → Index-qanR5Yzm.js} +1 -1
  44. package/dist/assets/{Index-5_S-Wyxo.js → Index-vdIA8HNj.js} +1 -1
  45. package/dist/assets/{Invitees-D_6QdVJi.js → Invitees-DXMkWonc.js} +1 -1
  46. package/dist/assets/List-B3MhaSky.css +1 -0
  47. package/dist/assets/{List-DpIhXG43.js → List-DdHu1PJw.js} +1 -1
  48. package/dist/assets/List-DxF7epXn.js +1 -0
  49. package/dist/assets/{List-G5XhuiOR.js → List-tcrS4_-M.js} +1 -1
  50. package/dist/assets/{Main-C-iIJNjX.js → Main-BUE52G__.js} +1 -1
  51. package/dist/assets/{Model-DwHTupa7.js → Model-CmUo6DLw.js} +1 -1
  52. package/dist/assets/{Navigator-BcC63YP5.js → Navigator-DhzQXWHV.js} +1 -1
  53. package/dist/assets/{NoTasks-C6XmMSFO.js → NoTasks-q0UZouyf.js} +1 -1
  54. package/dist/assets/{NotFound-BSo1PKfq.js → NotFound-B4ZDMr63.js} +1 -1
  55. package/dist/assets/{Pagination-5dcmS8-D.js → Pagination-pNIAuBPg.js} +1 -1
  56. package/dist/assets/{Pay-DlCOr1I4.js → Pay-D3kvFYae.js} +1 -1
  57. package/dist/assets/{Player-CimzJPkJ.js → Player-B8ysZitm.js} +1 -1
  58. package/dist/assets/{Seedance-Ct--Q4ZJ.js → Seedance-C9BIQ3rO.js} +1 -1
  59. package/dist/assets/{Status-CqqMuyua.js → Status-BJG9p-wa.js} +1 -1
  60. package/dist/assets/{Subscribe-DT3x60Rb.js → Subscribe-0R1rKyv5.js} +1 -1
  61. package/dist/assets/{TabSwitcher-C9gbSJu9.js → TabSwitcher-CzGId_W3.js} +1 -1
  62. package/dist/assets/{Tts-0llgrdSk.js → Tts-BPT5fNP6.js} +1 -1
  63. package/dist/assets/{VideoPlayer-B7Rh5hn5.js → VideoPlayer-fdGu0PNE.js} +1 -1
  64. package/dist/assets/{avatar-CWE4C-cn.js → avatar-BTOO65_e.js} +1 -1
  65. package/dist/assets/{basic-DYM-_8A0.js → basic-CwRZSB8S.js} +1 -1
  66. package/dist/assets/{chat-HBGlDKJs.js → chat-DvQksQPR.js} +1 -1
  67. package/dist/assets/{codingBridge-BT_2cqrP.js → codingBridge-CVG5OrHy.js} +1 -1
  68. package/dist/assets/{codingBridgeNotify-DyyUEUIH.js → codingBridgeNotify-XwCAVJdp.js} +2 -2
  69. package/dist/assets/{collapse-CCW8ndAG.js → collapse-Aj0r021q.js} +1 -1
  70. package/dist/assets/{common-BzLOOdZl.js → common-4VDbDlgF.js} +1 -1
  71. package/dist/assets/{common-DGknNLsE.js → common-BNLtL8iR.js} +1 -1
  72. package/dist/assets/{common-v14C2y2H.js → common-BPBjvNQW.js} +1 -1
  73. package/dist/assets/{common-C1f80x5q.js → common-BSlXLSqs.js} +1 -1
  74. package/dist/assets/{common-DvA6VZhe.js → common-BWb2s7Al.js} +1 -1
  75. package/dist/assets/{common-fmwYpuPs.js → common-BYyVkYpb.js} +1 -1
  76. package/dist/assets/{common-Day4Srji.js → common-BZmWN1py.js} +1 -1
  77. package/dist/assets/{common-XiY362Y2.js → common-C08bms0j.js} +1 -1
  78. package/dist/assets/{common-D0sTFWc3.js → common-CJCzcqQY.js} +1 -1
  79. package/dist/assets/{common-B9ZcPZVw.js → common-CLSorhN-.js} +1 -1
  80. package/dist/assets/{common-DMEm7Rs7.js → common-Ce2o_qD1.js} +1 -1
  81. package/dist/assets/{common-DFwCi8aH.js → common-D3qpl5LS.js} +1 -1
  82. package/dist/assets/{common-D6gFX3M_.js → common-DKUw7qXh.js} +1 -1
  83. package/dist/assets/{common-Dq-uo3wJ.js → common-Ddc6CVDL.js} +1 -1
  84. package/dist/assets/{common-Br9T8KnP.js → common-J87ajtS6.js} +1 -1
  85. package/dist/assets/{common-CmGEY1zP.js → common-ZING777c.js} +1 -1
  86. package/dist/assets/{common-tUeDXkDy.js → common-fA_XvJ6q.js} +1 -1
  87. package/dist/assets/{common-Ddqjp1s7.js → common-ty2lzSjP.js} +1 -1
  88. package/dist/assets/{constants-Doj9A7vw.js → constants-DMm7qShB.js} +1 -1
  89. package/dist/assets/{createTaskActions-BnAW2iGK.js → createTaskActions-nH8CXpPL.js} +1 -1
  90. package/dist/assets/{date-picker-DI9uIhaT.js → date-picker-Nk8GD6uo.js} +1 -1
  91. package/dist/assets/{dropdown-WFbgtyHp.js → dropdown-Oojl3F3W.js} +1 -1
  92. package/dist/assets/{esm-ASqvGn8-.js → esm-B0GQyKem.js} +2 -2
  93. package/dist/assets/{esm-ybomsqJA.js → esm-CBXRhqqs.js} +1 -1
  94. package/dist/assets/{esm-D4LU_wfJ.js → esm-DFM9bmMx.js} +2 -2
  95. package/dist/assets/{esm-0ECBL9z9.js → esm-DGvO0PNt.js} +1 -1
  96. package/dist/assets/esm-DmVQ0-E2.js +1 -0
  97. package/dist/assets/{esm-COE75y8F.js → esm-ppaNCWOS.js} +1 -1
  98. package/dist/assets/{esm-p85u2qzN.js → esm-wHqWJEJ3.js} +3 -3
  99. package/dist/assets/{fish-DGqQONnC.js → fish-CmXjMaSz.js} +1 -1
  100. package/dist/assets/{flux-DgJt-04g.js → flux-BHeID6vh.js} +1 -1
  101. package/dist/assets/{grokvideo-WVq6FbLF.js → grokvideo-Cg5NqVm8.js} +1 -1
  102. package/dist/assets/{hailuo-HL-IZPfF.js → hailuo-yoyr_j83.js} +1 -1
  103. package/dist/assets/{headshots-n4aTAJ00.js → headshots-CmsKp_lm.js} +1 -1
  104. package/dist/assets/{image-Byij2YF_.js → image-DwwO3q6F.js} +1 -1
  105. package/dist/assets/{index-GNIRULpP.js → index-CXLIbz5p.js} +15 -15
  106. package/dist/assets/{index.browser.esm-Pa81FQbl.js → index.browser.esm-5LOhBRXN.js} +1 -1
  107. package/dist/assets/{index.es-BiR7C8is.js → index.es-gzde5lIu.js} +1 -1
  108. package/dist/assets/{input-number-BSfZnYzy.js → input-number-CqAZ9EOT.js} +1 -1
  109. package/dist/assets/{kling-CKuFouXq.js → kling-DVQ1kFNa.js} +1 -1
  110. package/dist/assets/{luma-zjhXbLJ9.js → luma-yRwnaFs8.js} +1 -1
  111. package/dist/assets/{midjourney-DyYaNivI.js → midjourney-49SZjlds.js} +1 -1
  112. package/dist/assets/{nanobanana-8i2pCull.js → nanobanana-BqZ4_QvJ.js} +1 -1
  113. package/dist/assets/{openaiimage-DFzoE83b.js → openaiimage-BCYxMdg1.js} +1 -1
  114. package/dist/assets/{pagination-BwffSnuv.js → pagination-By6QU7he.js} +1 -1
  115. package/dist/assets/{pika-BqzcRnw-.js → pika-C6_8kTAi.js} +1 -1
  116. package/dist/assets/{pixverse-euZtveHC.js → pixverse-CE2qALjB.js} +1 -1
  117. package/dist/assets/{popover-DDcCZSAx.js → popover-DkwMNegv.js} +1 -1
  118. package/dist/assets/{producer-LzAuqQcp.js → producer-DVT--YpD.js} +1 -1
  119. package/dist/assets/{qrart-B8X0arTv.js → qrart-YcCKqvJL.js} +1 -1
  120. package/dist/assets/{row-BJuqTN4_.js → row-BvkHf04T.js} +1 -1
  121. package/dist/assets/{seedance-DK8jbGGX.js → seedance-BJqSuLmY.js} +1 -1
  122. package/dist/assets/{seedream-Bg6i6CHH.js → seedream-DOiUXI6s.js} +1 -1
  123. package/dist/assets/{select-ChrghZdq.js → select-B6b3u-H9.js} +1 -1
  124. package/dist/assets/{serp-BVh7iGFW.js → serp-aYXwXVDf.js} +1 -1
  125. package/dist/assets/{slider-CPi2uOqY.js → slider-D4hdD0jx.js} +1 -1
  126. package/dist/assets/{solana-wallets-CnGKqqw4.js → solana-wallets-D4TBCoxi.js} +2 -2
  127. package/dist/assets/{solana-wallets-vue-CZz1UPgb.js → solana-wallets-vue-Bu2jXI3h.js} +1 -1
  128. package/dist/assets/{sora-CS2FifvH.js → sora-HvvhwwRX.js} +1 -1
  129. package/dist/assets/{suno-CmtPFPT7.js → suno-CXr_QODL.js} +1 -1
  130. package/dist/assets/{switch-BnyHYpIj.js → switch-DzKEO4No.js} +1 -1
  131. package/dist/assets/{tabs-Df29OFVp.js → tabs-tfJQ1CG8.js} +1 -1
  132. package/dist/assets/{upload-Da-O-e6z.js → upload-CtG17-3u.js} +1 -1
  133. package/dist/assets/{veo-BifuQe2n.js → veo-DwW0vbMT.js} +1 -1
  134. package/dist/assets/{wan-CuidxFr3.js → wan-CxuX9htz.js} +1 -1
  135. package/dist/assets/{web-DVSlxTni.js → web-BGVNqfqx.js} +1 -1
  136. package/dist/assets/{web-CanVG3eR.js → web-BUM9255_.js} +1 -1
  137. package/dist/assets/{web-BFwe8F7T.js → web-CM2fGZ1B.js} +1 -1
  138. package/dist/assets/{web-Bym9OJTt.js → web-CdLm5vsi.js} +1 -1
  139. package/dist/assets/{web-DXHhjbkZ.js → web-CwwuKls0.js} +1 -1
  140. package/dist/assets/{webextrator-DHKqLsOO.js → webextrator-DqEHJfun.js} +1 -1
  141. package/dist/index.html +2 -2
  142. package/package.json +1 -1
  143. package/dist/assets/List-BPGjjz7h.css +0 -1
  144. package/dist/assets/List-Du4l1QCv.js +0 -1
  145. package/dist/assets/esm-YEfY5Zkk.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,Ut as c,Vt as l,Wt as u,Z as d,dt as f,et as p,k as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{t as v}from"./button-DfsQodL-.js";import{r as y,t as b}from"./select-ChrghZdq.js";import{t as x}from"./upload-Da-O-e6z.js";import{t as S}from"./tooltip-BLwTovWL.js";import{t as C}from"./image-Byij2YF_.js";import{t as w}from"./alert-OvnfgMB-.js";import{t as T}from"./drawer-Dpuj2uIl.js";import{t as E}from"./switch-BnyHYpIj.js";import{_i as D,cr as O,dr as k,fr as A,gr as j,lr as M,mr as N,pr as ee,ur as P,vr as F}from"./constants-Doj9A7vw.js";import{Ar as I,At as L,Cr as te,E as R,In as ne,Lr as z,Mt as B,Pt as V,br as H,jt as U,kt as W,pn as G}from"./index-GNIRULpP.js";import{t as K}from"./index.es-BiR7C8is.js";import{t as q}from"./CopyToClipboard-Rmd8YAx9.js";import{t as J}from"./ImagePreview-DAzwYsLG.js";import{n as Y}from"./taskDrawerMixin-DEgO_R5H.js";import{t as X}from"./BotPlaceholder-C6fcffYi.js";import{i as Z,n as re,t as ie}from"./pagination-BwffSnuv.js";import{n as ae,t as oe}from"./NoTasks-C6XmMSFO.js";import{t as se}from"./Consumption-BobAFFfW.js";import{t as ce}from"./ApiCodeButton-BZfzlGoT.js";import{t as Q}from"./VideoPlayer-B7Rh5hn5.js";var le=r({name:`LayoutVeo`,components:{ElDrawer:T,ElButton:v,FontAwesomeIcon:K},mixins:[Y]}),ue={class:`main flex flex-row flex-1`},de={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},fe={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function pe(e,r,i,a,s,c){let l=h(`font-awesome-icon`),u=h(`el-button`),m=h(`el-drawer`);return d(),t(`div`,ue,[n(`div`,de,[p(e.$slots,`config`,{},void 0,!0)]),n(`div`,fe,[p(e.$slots,`result`,{},void 0,!0)]),f(o(u,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(l,{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:`350px`},{default:g(()=>[p(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var me=R(le,[[`render`,pe],[`__scopeId`,`data-v-12b82bc3`]]),he=r({name:`ModelSelector`,components:{ElSelect:y,ElOption:b},props:{modelValue:{type:String,default:void 0}},emits:[`update:modelValue`],data(){return{options:[{value:`veo2`,label:`veo2`},{value:`veo2-fast`,label:`veo2-fast`},{value:`veo3`,label:`veo3`},{value:`veo3-fast`,label:`veo3-fast`},{value:`veo31-fast`,label:`veo31-fast`},{value:`veo31`,label:`veo31`},{value:`veo31-fast-ingredients`,label:`veo31-fast-ingredients`}]}},computed:{value:{get(){return this.$store.state.veo?.config?.model},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,model:e})}}},mounted(){this.value||=k}}),ge={class:`field`},_e={class:`title font-bold`};function ve(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,ge,[n(`h2`,_e,u(r.$t(`veo.name.model`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`)},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var ye=R(he,[[`render`,ve],[`__scopeId`,`data-v-a59d89c9`]]),be=r({name:`ActionSelector`,components:{ElSelect:y,ElOption:b},data(){return{}},computed:{options(){return[{value:`text2video`,label:this.$t(`veo.button.action1`)},{value:`image2video`,label:this.$t(`veo.button.action2`)},{value:`ingredients2video`,label:this.$t(`veo.button.actionIngredients`)},{value:`upsample`,label:this.$t(`veo.button.actionUpsample`)},{value:`extend`,label:this.$t(`veo.button.actionExtend`)},{value:`reshoot`,label:this.$t(`veo.button.actionReshoot`)},{value:`object_insert`,label:this.$t(`veo.button.actionObjectInsert`)},{value:`object_remove`,label:this.$t(`veo.button.actionObjectRemove`)}]},value:{get(){return this.$store.state.veo?.config?.action},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,action:e})}}},mounted(){this.value||=O}}),xe={class:`field`},Se={class:`title font-bold`},Ce={class:`float-left`};function we(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,xe,[n(`h2`,Se,u(r.$t(`veo.name.action`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`),clearable:``},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,Ce,u(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Te=R(be,[[`render`,we],[`__scopeId`,`data-v-f4d8785c`]]),Ee=r({name:`TranslationSelector`,components:{ElSwitch:E,InfoIcon:Z},computed:{value:{get(){return this.$store.state.veo?.config?.translation},set(e){console.debug(`set translation`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,translation:e})}}},mounted(){this.value===void 0&&(this.value=!1)}}),De={class:`relative`},Oe={class:`flex justify-between`},ke={class:`flex justify-start items-center`},Ae={class:`text-sm font-bold`},je={class:`flex justify-end items-center`};function Me(e,r,i,a,s,c){let l=h(`info-icon`),f=h(`el-switch`);return d(),t(`div`,De,[n(`div`,Oe,[n(`div`,ke,[n(`span`,Ae,u(e.$t(`veo.name.translation`)),1),o(l,{content:e.$t(`veo.description.translation`)},null,8,[`content`])]),n(`div`,je,[o(f,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`},null,8,[`modelValue`])])])])}var Ne=R(Ee,[[`render`,Me]]),Pe=r({name:`AspectRatioSelector`,data(){return{options:[{value:`16:9`,label:`16:9`,width:25,height:13},{value:`9:16`,label:`9:16`,width:13,height:25}]}},computed:{active(){return this.options.findIndex(e=>e.value===this.value)||0},value:{get(){return this.$store.state.veo?.config?.aspect_ratio},set(e){console.debug(`set aspect_ratio`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,aspect_ratio:e})}}},mounted(){this.value||=M}}),Fe={class:`text-sm font-bold mb-2 block`},Ie={class:`items`},Le=[`onClick`],Re={class:`name`};function ze(r,i,a,o,f,p){return d(),t(`div`,null,[n(`span`,Fe,u(r.$t(`veo.name.ratio`)),1),n(`div`,Ie,[(d(!0),t(s,null,e(r.options,(e,i)=>(d(),t(`div`,{key:i,class:l({active:r.active===i,item:!0}),onClick:t=>r.value=e.value},[n(`div`,{class:l([`preview`,e.label])},[n(`div`,{class:`rect`,style:c({width:e.width+`px`,height:e.height+`px`})},null,4)],2),n(`p`,Re,u(e.label),1)],10,Le))),128))])])}var Be=R(Pe,[[`render`,ze],[`__scopeId`,`data-v-28c472c4`]]),Ve=r({name:`VideoFromInput`,components:{VideoPlayer:Q},props:{modelValue:{type:Object,required:!1,default:void 0}},data(){return{options:{quality:{default:`1080p`}}}},computed:{config(){return this.$store.state.veo?.config}}}),He={class:`relative`},Ue={class:`flex mb-2`},We={class:`text-sm font-bold`};function Ge(e,r,i,o,s,c){let l=h(`video-player`);return d(),t(`div`,He,[n(`div`,Ue,[n(`span`,We,u(e.$t(`veo.name.action3`)),1)]),n(`div`,null,[e.config?.video_url?(d(),a(l,{key:0,src:e.config?.video_url},null,8,[`src`])):m(``,!0)])])}var Ke=R(Ve,[[`render`,Ge]]),qe=r({name:`VideoIdInput`,components:{ElInput:z},computed:{value:{get(){return this.$store.state.veo?.config?.video_id},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,video_id:e})}}}}),Je={class:`field`},Ye={class:`title font-bold`};function Xe(e,r,i,a,s,c){let l=h(`el-input`);return d(),t(`div`,Je,[n(`h2`,Ye,u(e.$t(`veo.name.videoId`)),1),o(l,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`,type:`text`,placeholder:e.$t(`veo.placeholder.videoId`),clearable:``},null,8,[`modelValue`,`placeholder`])])}var Ze=R(qe,[[`render`,Xe],[`__scopeId`,`data-v-6eba4026`]]),Qe=r({name:`StartEndImage`,components:{ElUpload:x,ElButton:v,InfoIcon:Z,FontAwesomeIcon:K,ImagePreview:J},mixins:[B,L],emits:[`change`],data(){return{fileList:[],uploadUrl:te()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state?.veo?.config?.image_urls},set(){}}},mounted(){this.value||=void 0,this.onSetStartEndImageUrl()},methods:{onExceed(){I.warning(this.$t(`veo.message.uploadReferencesExceed`))},onError(){I.error(this.$t(`veo.message.uploadReferencesError`))},onSetStartEndImageUrl(){let e=this.urls;this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,image_urls:e})},async onSuccess(){this.onSetStartEndImageUrl()}}}),$e={class:`relative`},et={class:`flex justify-between`},tt={class:`flex justify-start items-center`},nt={class:`text-sm font-bold`};function rt(e,r,s,c,l,f){let p=h(`info-icon`),_=h(`image-preview`),v=h(`font-awesome-icon`),y=h(`el-button`),b=h(`el-upload`);return d(),t(`div`,$e,[n(`div`,et,[n(`div`,tt,[n(`span`,nt,u(e.$t(`veo.name.startEndImage`)),1),o(p,{content:e.$t(`veo.description.uploadStartEndImage`)},null,8,[`content`])])]),o(b,{ref:`uploader`,"file-list":e.fileList,"onUpdate:fileList":r[0]||=t=>e.fileList=t,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:2,class:`upload-wrapper`,multiple:!1,action:e.uploadUrl,"list-type":`picture`,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{file:g(({file:t})=>[t.url&&t.percentage!==void 0?(d(),a(_,{key:0,url:t.url,name:t.name,percentage:t.percentage,onRemove:n=>e.fileList.splice(e.fileList.indexOf(t),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):m(``,!0)]),default:g(()=>[o(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:g(()=>[o(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+u(e.$t(`veo.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var it=R(Qe,[[`render`,rt],[`__scopeId`,`data-v-f9a79b4a`]]),at=r({name:`UpsampleActionSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return F.map(e=>({value:e,label:e}))},value:{get(){return this.$store.state.veo?.config?.upsample_action},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,upsample_action:e})}}},mounted(){this.value||=ee}}),ot={class:`field`},st={class:`title font-bold`};function ct(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,ot,[n(`h2`,st,u(r.$t(`veo.name.upsampleAction`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`)},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var lt=R(at,[[`render`,ct],[`__scopeId`,`data-v-8b74a7ae`]]),ut=r({name:`ExtendModelSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return N.map(e=>({value:e,label:e}))},value:{get(){return this.$store.state.veo?.config?.model},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,model:e})}}},mounted(){(!this.value||!N.includes(this.value))&&(this.value=P)}}),dt={class:`field`},ft={class:`title font-bold`};function pt(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,dt,[n(`h2`,ft,u(r.$t(`veo.name.model`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`)},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var mt=R(ut,[[`render`,pt],[`__scopeId`,`data-v-cc3f9355`]]),ht=r({name:`MotionTypeSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return j.map(e=>({value:e,label:e}))},value:{get(){return this.$store.state.veo?.config?.motion_type},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,motion_type:e})}}},mounted(){this.value||=A}}),gt={class:`field`},_t={class:`title font-bold`};function vt(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,gt,[n(`h2`,_t,u(r.$t(`veo.name.motionType`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`),filterable:``},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var yt=R(ht,[[`render`,vt],[`__scopeId`,`data-v-3affff3c`]]),bt=r({name:`ImageMaskInput`,components:{ElInput:z},computed:{value:{get(){return this.$store.state.veo?.config?.image_mask},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,image_mask:e})}}}}),xt={class:`field`},St={class:`title font-bold`};function Ct(e,r,i,a,s,c){let l=h(`el-input`);return d(),t(`div`,xt,[n(`h2`,St,u(e.$t(`veo.name.imageMask`)),1),o(l,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`,type:`text`,placeholder:e.$t(`veo.placeholder.imageMask`),clearable:``},null,8,[`modelValue`,`placeholder`])])}var wt=R(bt,[[`render`,Ct],[`__scopeId`,`data-v-6cc27c68`]]),Tt=r({name:`PromptInput`,components:{PromptTextarea:ae},computed:{prompt:{get(){return this.$store.state.veo?.config?.prompt},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Et(e,t,n,r,i,o){let s=h(`prompt-textarea`);return d(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`veo.name.prompt`),info:e.$t(`veo.description.prompt`),placeholder:e.$t(`veo.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Dt=R(Tt,[[`render`,Et]]),Ot=[`upsample`,`extend`,`reshoot`,`object_insert`,`object_remove`,`get1080p`],kt=[`text2video`,`image2video`,`ingredients2video`],At=r({name:`ConfigPanel`,components:{ElButton:v,Consumption:se,FontAwesomeIcon:K,PromptInput:Dt,ModelSelector:ye,StartEndImage:it,ActionSelector:Te,VideoFromInput:Ke,VideoIdInput:Ze,UpsampleActionSelector:lt,ExtendModelSelector:mt,MotionTypeSelector:yt,ImageMaskInput:wt,TranslationSelector:Ne,AspectRatioSelector:Be},emits:[`generate`],computed:{config(){return this.$store.state.veo?.config},consumption(){return V(this.config,this.service?.cost)},service(){return this.$store.state.veo?.service},isPostProcessing(){return Ot.includes(this.config?.action??``)},isGeneration(){return kt.includes(this.config?.action??``)}},methods:{onGenerate(){this.$emit(`generate`)}}}),jt={class:`flex flex-col h-full`},Mt={class:`flex-1 overflow-y-auto p-5`},Nt={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pt(e,r,c,l,f,p){let _=h(`action-selector`),v=h(`video-from-input`),y=h(`video-id-input`),b=h(`upsample-action-selector`),x=h(`extend-model-selector`),S=h(`prompt-input`),C=h(`motion-type-selector`),w=h(`image-mask-input`),T=h(`translation-selector`),E=h(`aspect-ratio-selector`),D=h(`model-selector`),O=h(`start-end-image`),k=h(`consumption`),A=h(`font-awesome-icon`),j=h(`el-button`);return d(),t(`div`,jt,[n(`div`,Mt,[o(_,{class:`mb-4`}),e.isPostProcessing?(d(),t(s,{key:0},[e.config?.video_url?(d(),a(v,{key:0,class:`mb-4`})):m(``,!0),o(y,{class:`mb-4`})],64)):m(``,!0),e.config?.action===`upsample`?(d(),a(b,{key:1,class:`mb-4`})):m(``,!0),e.config?.action===`extend`?(d(),a(x,{key:2,class:`mb-4`})):m(``,!0),e.config?.action===`extend`?(d(),a(S,{key:3,class:`mb-4`})):m(``,!0),e.config?.action===`reshoot`?(d(),a(C,{key:4,class:`mb-4`})):m(``,!0),e.config?.action===`object_insert`?(d(),a(S,{key:5,class:`mb-4`})):m(``,!0),e.config?.action===`object_insert`||e.config?.action===`object_remove`?(d(),a(w,{key:6,class:`mb-4`})):m(``,!0),e.config?.action===`object_remove`?(d(),a(S,{key:7,class:`mb-4`})):m(``,!0),e.isGeneration?(d(),t(s,{key:8},[o(T,{class:`mb-4`}),o(E,{class:`mb-4`}),o(S,{class:`mb-4`}),e.config?.action===`ingredients2video`?m(``,!0):(d(),a(D,{key:0,class:`mb-4`})),e.config?.action===`image2video`||e.config?.action===`ingredients2video`?(d(),a(O,{key:1,class:`mb-2`})):m(``,!0)],64)):m(``,!0)]),n(`div`,Nt,[o(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),o(j,{type:`primary`,class:`btn w-full`,round:``,onClick:e.onGenerate},{default:g(()=>[o(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+u(e.$t(`veo.button.generate`)),1)]),_:1},8,[`onClick`])])])}var Ft=R(At,[[`render`,Pt]]),It=r({name:`TaskPreview`,components:{ElImage:C,CopyToClipboard:q,FontAwesomeIcon:K,ElAlert:w,VideoPlayer:Q,ElTooltip:S,ElButton:v,ApiCodeButton:ce},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.veo?.application},config(){return this.$store.state.veo?.config}},methods:{onPickAction(e,t,n,r){console.debug(`seed config from preview`,{action:n,upsampleAction:r,response:t}),this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,action:n,video_id:t?.data?.[0]?.id,video_url:t?.data?.[0]?.video_url,...r?{upsample_action:r}:{}})},onDownload(e,t){e?.stopPropagation(),console.log(`on download`),window.open(t,`_blank`)},onOpenVideo(e){window.open(e,`_blank`)}}}),Lt={class:`preview`},Rt={class:`left`},zt={class:`main`},Bt={class:`bot`},Vt={class:`datetime`},Ht={class:`info`},Ut={key:0,class:`prompt mt-2`},Wt={key:0},Gt={key:1},Kt={key:0,class:l({content:!0,failed:!0})},qt={key:0,class:`mb-4`},Jt={key:1,class:l({operations:!0,"mt-2":!0})},Yt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Xt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Zt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Qt={key:1,class:l({content:!0})},$t={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},en={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},tn={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},nn={key:2,class:l({content:!0})},rn={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},an={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function on(e,r,s,c,l,f){let p=h(`el-image`),_=h(`video-player`),v=h(`el-button`),y=h(`el-tooltip`),b=h(`api-code-button`),x=h(`font-awesome-icon`),S=h(`copy-to-clipboard`),C=h(`el-alert`);return d(),t(`div`,Lt,[n(`div`,Rt,[o(p,{src:`https://cdn.acedata.cloud/8nxyy9.jpg`,class:`avatar`})]),n(`div`,zt,[n(`div`,Bt,[i(u(e.$t(`veo.name.veoBot`))+` `,1),n(`span`,Vt,u(e.$dayjs.format(``+new Date(parseFloat((e.modelValue?.created_at||``).toString())*1e3))),1)]),n(`div`,Ht,[e.modelValue?.request?.prompt?(d(),t(`p`,Ut,[i(u(e.modelValue?.request?.prompt)+` `,1),e.modelValue?.response?m(``,!0):(d(),t(`span`,Wt,` - (`+u(e.$t(`veo.status.pending`))+`) `,1)),Array.isArray(e.modelValue?.response?.data)&&e.modelValue?.response?.data[0]?.state===`running`?(d(),t(`span`,Gt,` - (`+u(e.$t(`veo.status.processing`))+`) `,1)):m(``,!0)])):m(``,!0)]),e.modelValue?.response?.success===!0&&e.modelValue?.response?.data?(d(),t(`div`,Kt,[e.modelValue?.response?.data[0]?.video_url?(d(),t(`div`,qt,[o(_,{src:e.modelValue?.response?.data[0]?.video_url},null,8,[`src`])])):m(``,!0),e.modelValue?.response.success?(d(),t(`div`,Jt,[e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:r[0]||=t=>e.onPickAction(t,e.modelValue?.response,`upsample`,`1080p`)},{default:g(()=>[i(u(e.$t(`veo.button.actionUpsample1080p`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:1,type:`info`,size:`small`,class:`btn-action`,onClick:r[1]||=t=>e.onPickAction(t,e.modelValue?.response,`upsample`,`4k`)},{default:g(()=>[i(u(e.$t(`veo.button.actionUpsample4k`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:2,type:`info`,size:`small`,class:`btn-action`,onClick:r[2]||=t=>e.onPickAction(t,e.modelValue?.response,`upsample`,`gif`)},{default:g(()=>[i(u(e.$t(`veo.button.actionUpsampleGif`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:3,type:`info`,size:`small`,class:`btn-action`,onClick:r[3]||=t=>e.onPickAction(t,e.modelValue?.response,`extend`)},{default:g(()=>[i(u(e.$t(`veo.button.actionExtend`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:4,type:`info`,size:`small`,class:`btn-action`,onClick:r[4]||=t=>e.onPickAction(t,e.modelValue?.response,`reshoot`)},{default:g(()=>[i(u(e.$t(`veo.button.actionReshoot`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:5,type:`info`,size:`small`,class:`btn-action`,onClick:r[5]||=t=>e.onPickAction(t,e.modelValue?.response,`object_insert`)},{default:g(()=>[i(u(e.$t(`veo.button.actionObjectInsert`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:6,type:`info`,size:`small`,class:`btn-action`,onClick:r[6]||=t=>e.onPickAction(t,e.modelValue?.response,`object_remove`)},{default:g(()=>[i(u(e.$t(`veo.button.actionObjectRemove`)),1)]),_:1})):m(``,!0),o(y,{class:`box-item`,effect:`dark`,content:e.$t(`veo.message.downloadVideo`),placement:`top-start`},{default:g(()=>[e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:r[7]||=t=>e.onDownload(t,e.modelValue?.response?.data[0]?.video_url)},{default:g(()=>[i(u(e.$t(`veo.button.download`)),1)]),_:1})):m(``,!0)]),_:1},8,[`content`]),o(b,{path:`/veo/videos`,body:e.modelValue?.request},null,8,[`body`])])):m(``,!0),o(C,{closable:!1,class:`mt-2 success`},{default:g(()=>[n(`p`,Yt,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.model`))+`: `+u(e.modelValue?.request?.model),1)]),n(`p`,Xt,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.taskId`))+`: `+u(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),e.modelValue?.elapsed?(d(),t(`p`,Zt,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.elapsed`))+`: `+u(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0)]),_:1})])):m(``,!0),e.modelValue?.response?.success===!1?(d(),t(`div`,Qt,[o(C,{closable:!1,class:`failure`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.failure`)),1)]),default:g(()=>[n(`p`,$t,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.taskId`))+`: `+u(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),n(`p`,en,[o(x,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.failureReason`))+`: `+u(e.modelValue?.response?.error?.message)+` `,1),o(S,{content:e.modelValue?.response?.error?.message},null,8,[`content`])]),e.modelValue?.elapsed?(d(),t(`p`,$,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.elapsed`))+`: `+u(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0),e.modelValue?.response?.trace_id?(d(),t(`p`,tn,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.traceId`))+`: `+u(e.modelValue?.response?.trace_id)+` `,1),o(S,{content:e.modelValue?.response?.trace_id},null,8,[`content`])])):m(``,!0)]),_:1})])):m(``,!0),e.modelValue?.response?.success===void 0?(d(),t(`div`,nn,[o(C,{closable:!1,class:`info`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.failure`)),1)]),default:g(()=>[n(`p`,rn,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.taskId`))+`: `+u(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),e.modelValue?.response?.trace_id?(d(),t(`p`,an,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.traceId`))+`: `+u(e.modelValue?.response?.trace_id)+` `,1),o(S,{content:e.modelValue?.response?.trace_id},null,8,[`content`])])):m(``,!0)]),_:1})])):m(``,!0)])])}var sn=r({name:`RecentPanel`,components:{TaskPreview:R(It,[[`render`,on],[`__scopeId`,`data-v-9698fe5f`]]),NoTasks:oe,BotPlaceholder:X,ScrollList:re},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.veo?.tasks,items:this.$store.state.veo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),cn={key:0},ln={key:2,class:`w-full h-full flex items-center justify-center`};function un(n,r,i,c,l,u){let f=h(`bot-placeholder`),p=h(`task-preview`),_=h(`scroll-list`),v=h(`no-tasks`);return d(),t(s,null,[n.tasks?.items===void 0?(d(),t(`div`,cn,[o(f)])):n.tasks?.items?.length&&n.tasks?.items?.length>0?(d(),a(_,{key:1,ref:`scrollList`,class:`tasks h-full w-full overflow-y-auto`,loading:n.loading,onReachTop:r[0]||=e=>n.$emit(`reach-top`)},{default:g(()=>[(d(!0),t(s,null,e(n.tasks?.items,(e,t)=>(d(),a(p,{key:t,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):m(``,!0),n.tasks?.items?.length===0?(d(),t(`div`,ln,[o(v)])):m(``,!0)],64)}var dn=R(sn,[[`render`,un]]),fn=D(`veo`),pn=r({name:`VeoIndex`,components:{ConfigPanel:Ft,Layout:me,RecentPanel:dn},mixins:[U],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.veo?.status?.getApplications===H.Request},tasksLoading(){return this.$store.state.veo?.status?.getTasks===H.Request||this.fetchingTasks},credential(){return this.$store.state.veo.credential},config(){return this.$store.state.veo.config},tasks(){return this.$store.state.veo.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug(`new tasks detected`)},deep:!0},initialized:{async handler(e){e&&(console.debug(`layout initialized`),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await ie({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(`veo/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`veo/getApplications`),console.debug(`end onGetApplication`),await this.onGetTasks()},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(`veo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!W(this.uploadTracker,e=>this.$t(e),e=>I.warning(e)))return;let e={...this.config,callback_url:fn},t=this.credential?.token;if(!t){console.error(`no token specified`);return}if(e.action===`image2video`&&!(e.image_urls&&e.image_urls.length>0)){I.warning(this.$t(`veo.message.imageRequired`));return}(!e.image_urls||e.image_urls.length===0)&&delete e.image_urls,I.info(this.$t(`veo.message.startingTask`)),ne(`veo`,G.generate(e,{token:t})).then(()=>{I.success(this.$t(`veo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?I.error(this.$t(`veo.message.usedUp`)):I.error(this.$t(`veo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function mn(e,t,n,r,i,s){let c=h(`config-panel`),l=h(`recent-panel`),u=h(`layout`);return d(),a(u,null,{config:g(()=>[o(c,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:g(()=>[o(l,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var hn=R(pn,[[`render`,mn]]);export{hn 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,Ut as c,Vt as l,Wt as u,Z as d,dt as f,et as p,k as m,tt as h,ut as g,v as _}from"./vendor-chart-BJCvKk8-.js";import{t as v}from"./button-DfsQodL-.js";import{r as y,t as b}from"./select-B6b3u-H9.js";import{t as x}from"./upload-CtG17-3u.js";import{t as S}from"./tooltip-BLwTovWL.js";import{t as C}from"./image-DwwO3q6F.js";import{t as w}from"./alert-OvnfgMB-.js";import{t as T}from"./drawer-Dpuj2uIl.js";import{t as E}from"./switch-DzKEO4No.js";import{_i as D,cr as O,dr as k,fr as A,gr as j,lr as M,mr as N,pr as ee,ur as P,vr as F}from"./constants-DMm7qShB.js";import{Ar as I,At as L,Cr as te,E as R,In as ne,Lr as z,Mt as B,Pt as V,br as H,jt as U,kt as W,pn as G}from"./index-CXLIbz5p.js";import{t as K}from"./index.es-gzde5lIu.js";import{t as q}from"./CopyToClipboard-yGJQFFP1.js";import{t as J}from"./ImagePreview-NgPB2xG0.js";import{n as Y}from"./taskDrawerMixin-DEgO_R5H.js";import{t as X}from"./BotPlaceholder-CO654Xhh.js";import{i as Z,n as re,t as ie}from"./pagination-By6QU7he.js";import{n as ae,t as oe}from"./NoTasks-q0UZouyf.js";import{t as se}from"./Consumption-Cmk_G3JD.js";import{t as ce}from"./ApiCodeButton-D4B5DS_n.js";import{t as Q}from"./VideoPlayer-fdGu0PNE.js";var le=r({name:`LayoutVeo`,components:{ElDrawer:T,ElButton:v,FontAwesomeIcon:K},mixins:[Y]}),ue={class:`main flex flex-row flex-1`},de={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},fe={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function pe(e,r,i,a,s,c){let l=h(`font-awesome-icon`),u=h(`el-button`),m=h(`el-drawer`);return d(),t(`div`,ue,[n(`div`,de,[p(e.$slots,`config`,{},void 0,!0)]),n(`div`,fe,[p(e.$slots,`result`,{},void 0,!0)]),f(o(u,{circle:``,class:`menu`,onClick:r[0]||=t=>e.drawer=!0},{default:g(()=>[o(l,{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:`350px`},{default:g(()=>[p(e.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var me=R(le,[[`render`,pe],[`__scopeId`,`data-v-12b82bc3`]]),he=r({name:`ModelSelector`,components:{ElSelect:y,ElOption:b},props:{modelValue:{type:String,default:void 0}},emits:[`update:modelValue`],data(){return{options:[{value:`veo2`,label:`veo2`},{value:`veo2-fast`,label:`veo2-fast`},{value:`veo3`,label:`veo3`},{value:`veo3-fast`,label:`veo3-fast`},{value:`veo31-fast`,label:`veo31-fast`},{value:`veo31`,label:`veo31`},{value:`veo31-fast-ingredients`,label:`veo31-fast-ingredients`}]}},computed:{value:{get(){return this.$store.state.veo?.config?.model},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,model:e})}}},mounted(){this.value||=k}}),ge={class:`field`},_e={class:`title font-bold`};function ve(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,ge,[n(`h2`,_e,u(r.$t(`veo.name.model`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`)},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var ye=R(he,[[`render`,ve],[`__scopeId`,`data-v-a59d89c9`]]),be=r({name:`ActionSelector`,components:{ElSelect:y,ElOption:b},data(){return{}},computed:{options(){return[{value:`text2video`,label:this.$t(`veo.button.action1`)},{value:`image2video`,label:this.$t(`veo.button.action2`)},{value:`ingredients2video`,label:this.$t(`veo.button.actionIngredients`)},{value:`upsample`,label:this.$t(`veo.button.actionUpsample`)},{value:`extend`,label:this.$t(`veo.button.actionExtend`)},{value:`reshoot`,label:this.$t(`veo.button.actionReshoot`)},{value:`object_insert`,label:this.$t(`veo.button.actionObjectInsert`)},{value:`object_remove`,label:this.$t(`veo.button.actionObjectRemove`)}]},value:{get(){return this.$store.state.veo?.config?.action},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,action:e})}}},mounted(){this.value||=O}}),xe={class:`field`},Se={class:`title font-bold`},Ce={class:`float-left`};function we(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,xe,[n(`h2`,Se,u(r.$t(`veo.name.action`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`),clearable:``},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},{default:g(()=>[n(`span`,Ce,u(e.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Te=R(be,[[`render`,we],[`__scopeId`,`data-v-f4d8785c`]]),Ee=r({name:`TranslationSelector`,components:{ElSwitch:E,InfoIcon:Z},computed:{value:{get(){return this.$store.state.veo?.config?.translation},set(e){console.debug(`set translation`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,translation:e})}}},mounted(){this.value===void 0&&(this.value=!1)}}),De={class:`relative`},Oe={class:`flex justify-between`},ke={class:`flex justify-start items-center`},Ae={class:`text-sm font-bold`},je={class:`flex justify-end items-center`};function Me(e,r,i,a,s,c){let l=h(`info-icon`),f=h(`el-switch`);return d(),t(`div`,De,[n(`div`,Oe,[n(`div`,ke,[n(`span`,Ae,u(e.$t(`veo.name.translation`)),1),o(l,{content:e.$t(`veo.description.translation`)},null,8,[`content`])]),n(`div`,je,[o(f,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`},null,8,[`modelValue`])])])])}var Ne=R(Ee,[[`render`,Me]]),Pe=r({name:`AspectRatioSelector`,data(){return{options:[{value:`16:9`,label:`16:9`,width:25,height:13},{value:`9:16`,label:`9:16`,width:13,height:25}]}},computed:{active(){return this.options.findIndex(e=>e.value===this.value)||0},value:{get(){return this.$store.state.veo?.config?.aspect_ratio},set(e){console.debug(`set aspect_ratio`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,aspect_ratio:e})}}},mounted(){this.value||=M}}),Fe={class:`text-sm font-bold mb-2 block`},Ie={class:`items`},Le=[`onClick`],Re={class:`name`};function ze(r,i,a,o,f,p){return d(),t(`div`,null,[n(`span`,Fe,u(r.$t(`veo.name.ratio`)),1),n(`div`,Ie,[(d(!0),t(s,null,e(r.options,(e,i)=>(d(),t(`div`,{key:i,class:l({active:r.active===i,item:!0}),onClick:t=>r.value=e.value},[n(`div`,{class:l([`preview`,e.label])},[n(`div`,{class:`rect`,style:c({width:e.width+`px`,height:e.height+`px`})},null,4)],2),n(`p`,Re,u(e.label),1)],10,Le))),128))])])}var Be=R(Pe,[[`render`,ze],[`__scopeId`,`data-v-28c472c4`]]),Ve=r({name:`VideoFromInput`,components:{VideoPlayer:Q},props:{modelValue:{type:Object,required:!1,default:void 0}},data(){return{options:{quality:{default:`1080p`}}}},computed:{config(){return this.$store.state.veo?.config}}}),He={class:`relative`},Ue={class:`flex mb-2`},We={class:`text-sm font-bold`};function Ge(e,r,i,o,s,c){let l=h(`video-player`);return d(),t(`div`,He,[n(`div`,Ue,[n(`span`,We,u(e.$t(`veo.name.action3`)),1)]),n(`div`,null,[e.config?.video_url?(d(),a(l,{key:0,src:e.config?.video_url},null,8,[`src`])):m(``,!0)])])}var Ke=R(Ve,[[`render`,Ge]]),qe=r({name:`VideoIdInput`,components:{ElInput:z},computed:{value:{get(){return this.$store.state.veo?.config?.video_id},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,video_id:e})}}}}),Je={class:`field`},Ye={class:`title font-bold`};function Xe(e,r,i,a,s,c){let l=h(`el-input`);return d(),t(`div`,Je,[n(`h2`,Ye,u(e.$t(`veo.name.videoId`)),1),o(l,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`,type:`text`,placeholder:e.$t(`veo.placeholder.videoId`),clearable:``},null,8,[`modelValue`,`placeholder`])])}var Ze=R(qe,[[`render`,Xe],[`__scopeId`,`data-v-6eba4026`]]),Qe=r({name:`StartEndImage`,components:{ElUpload:x,ElButton:v,InfoIcon:Z,FontAwesomeIcon:K,ImagePreview:J},mixins:[B,L],emits:[`change`],data(){return{fileList:[],uploadUrl:te()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},value:{get(){return this.$store.state?.veo?.config?.image_urls},set(){}}},mounted(){this.value||=void 0,this.onSetStartEndImageUrl()},methods:{onExceed(){I.warning(this.$t(`veo.message.uploadReferencesExceed`))},onError(){I.error(this.$t(`veo.message.uploadReferencesError`))},onSetStartEndImageUrl(){let e=this.urls;this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,image_urls:e})},async onSuccess(){this.onSetStartEndImageUrl()}}}),$e={class:`relative`},et={class:`flex justify-between`},tt={class:`flex justify-start items-center`},nt={class:`text-sm font-bold`};function rt(e,r,s,c,l,f){let p=h(`info-icon`),_=h(`image-preview`),v=h(`font-awesome-icon`),y=h(`el-button`),b=h(`el-upload`);return d(),t(`div`,$e,[n(`div`,et,[n(`div`,tt,[n(`span`,nt,u(e.$t(`veo.name.startEndImage`)),1),o(p,{content:e.$t(`veo.description.uploadStartEndImage`)},null,8,[`content`])])]),o(b,{ref:`uploader`,"file-list":e.fileList,"onUpdate:fileList":r[0]||=t=>e.fileList=t,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:2,class:`upload-wrapper`,multiple:!1,action:e.uploadUrl,"list-type":`picture`,"on-exceed":e.onExceed,"on-error":e.onError,"on-success":e.onSuccess,headers:e.headers},{file:g(({file:t})=>[t.url&&t.percentage!==void 0?(d(),a(_,{key:0,url:t.url,name:t.name,percentage:t.percentage,onRemove:n=>e.fileList.splice(e.fileList.indexOf(t),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):m(``,!0)]),default:g(()=>[o(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:g(()=>[o(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+u(e.$t(`veo.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var it=R(Qe,[[`render`,rt],[`__scopeId`,`data-v-f9a79b4a`]]),at=r({name:`UpsampleActionSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return F.map(e=>({value:e,label:e}))},value:{get(){return this.$store.state.veo?.config?.upsample_action},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,upsample_action:e})}}},mounted(){this.value||=ee}}),ot={class:`field`},st={class:`title font-bold`};function ct(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,ot,[n(`h2`,st,u(r.$t(`veo.name.upsampleAction`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`)},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var lt=R(at,[[`render`,ct],[`__scopeId`,`data-v-8b74a7ae`]]),ut=r({name:`ExtendModelSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return N.map(e=>({value:e,label:e}))},value:{get(){return this.$store.state.veo?.config?.model},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,model:e})}}},mounted(){(!this.value||!N.includes(this.value))&&(this.value=P)}}),dt={class:`field`},ft={class:`title font-bold`};function pt(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,dt,[n(`h2`,ft,u(r.$t(`veo.name.model`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`)},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var mt=R(ut,[[`render`,pt],[`__scopeId`,`data-v-cc3f9355`]]),ht=r({name:`MotionTypeSelector`,components:{ElSelect:y,ElOption:b},computed:{options(){return j.map(e=>({value:e,label:e}))},value:{get(){return this.$store.state.veo?.config?.motion_type},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,motion_type:e})}}},mounted(){this.value||=A}}),gt={class:`field`},_t={class:`title font-bold`};function vt(r,i,c,l,f,p){let m=h(`el-option`),_=h(`el-select`);return d(),t(`div`,gt,[n(`h2`,_t,u(r.$t(`veo.name.motionType`)),1),o(_,{modelValue:r.value,"onUpdate:modelValue":i[0]||=e=>r.value=e,class:`value`,placeholder:r.$t(`veo.placeholder.select`),filterable:``},{default:g(()=>[(d(!0),t(s,null,e(r.options,e=>(d(),a(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var yt=R(ht,[[`render`,vt],[`__scopeId`,`data-v-3affff3c`]]),bt=r({name:`ImageMaskInput`,components:{ElInput:z},computed:{value:{get(){return this.$store.state.veo?.config?.image_mask},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,image_mask:e})}}}}),xt={class:`field`},St={class:`title font-bold`};function Ct(e,r,i,a,s,c){let l=h(`el-input`);return d(),t(`div`,xt,[n(`h2`,St,u(e.$t(`veo.name.imageMask`)),1),o(l,{modelValue:e.value,"onUpdate:modelValue":r[0]||=t=>e.value=t,class:`value`,type:`text`,placeholder:e.$t(`veo.placeholder.imageMask`),clearable:``},null,8,[`modelValue`,`placeholder`])])}var wt=R(bt,[[`render`,Ct],[`__scopeId`,`data-v-6cc27c68`]]),Tt=r({name:`PromptInput`,components:{PromptTextarea:ae},computed:{prompt:{get(){return this.$store.state.veo?.config?.prompt},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function Et(e,t,n,r,i,o){let s=h(`prompt-textarea`);return d(),a(s,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`veo.name.prompt`),info:e.$t(`veo.description.prompt`),placeholder:e.$t(`veo.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Dt=R(Tt,[[`render`,Et]]),Ot=[`upsample`,`extend`,`reshoot`,`object_insert`,`object_remove`,`get1080p`],kt=[`text2video`,`image2video`,`ingredients2video`],At=r({name:`ConfigPanel`,components:{ElButton:v,Consumption:se,FontAwesomeIcon:K,PromptInput:Dt,ModelSelector:ye,StartEndImage:it,ActionSelector:Te,VideoFromInput:Ke,VideoIdInput:Ze,UpsampleActionSelector:lt,ExtendModelSelector:mt,MotionTypeSelector:yt,ImageMaskInput:wt,TranslationSelector:Ne,AspectRatioSelector:Be},emits:[`generate`],computed:{config(){return this.$store.state.veo?.config},consumption(){return V(this.config,this.service?.cost)},service(){return this.$store.state.veo?.service},isPostProcessing(){return Ot.includes(this.config?.action??``)},isGeneration(){return kt.includes(this.config?.action??``)}},methods:{onGenerate(){this.$emit(`generate`)}}}),jt={class:`flex flex-col h-full`},Mt={class:`flex-1 overflow-y-auto p-5`},Nt={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pt(e,r,c,l,f,p){let _=h(`action-selector`),v=h(`video-from-input`),y=h(`video-id-input`),b=h(`upsample-action-selector`),x=h(`extend-model-selector`),S=h(`prompt-input`),C=h(`motion-type-selector`),w=h(`image-mask-input`),T=h(`translation-selector`),E=h(`aspect-ratio-selector`),D=h(`model-selector`),O=h(`start-end-image`),k=h(`consumption`),A=h(`font-awesome-icon`),j=h(`el-button`);return d(),t(`div`,jt,[n(`div`,Mt,[o(_,{class:`mb-4`}),e.isPostProcessing?(d(),t(s,{key:0},[e.config?.video_url?(d(),a(v,{key:0,class:`mb-4`})):m(``,!0),o(y,{class:`mb-4`})],64)):m(``,!0),e.config?.action===`upsample`?(d(),a(b,{key:1,class:`mb-4`})):m(``,!0),e.config?.action===`extend`?(d(),a(x,{key:2,class:`mb-4`})):m(``,!0),e.config?.action===`extend`?(d(),a(S,{key:3,class:`mb-4`})):m(``,!0),e.config?.action===`reshoot`?(d(),a(C,{key:4,class:`mb-4`})):m(``,!0),e.config?.action===`object_insert`?(d(),a(S,{key:5,class:`mb-4`})):m(``,!0),e.config?.action===`object_insert`||e.config?.action===`object_remove`?(d(),a(w,{key:6,class:`mb-4`})):m(``,!0),e.config?.action===`object_remove`?(d(),a(S,{key:7,class:`mb-4`})):m(``,!0),e.isGeneration?(d(),t(s,{key:8},[o(T,{class:`mb-4`}),o(E,{class:`mb-4`}),o(S,{class:`mb-4`}),e.config?.action===`ingredients2video`?m(``,!0):(d(),a(D,{key:0,class:`mb-4`})),e.config?.action===`image2video`||e.config?.action===`ingredients2video`?(d(),a(O,{key:1,class:`mb-2`})):m(``,!0)],64)):m(``,!0)]),n(`div`,Nt,[o(k,{value:e.consumption,service:e.service},null,8,[`value`,`service`]),o(j,{type:`primary`,class:`btn w-full`,round:``,onClick:e.onGenerate},{default:g(()=>[o(A,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+u(e.$t(`veo.button.generate`)),1)]),_:1},8,[`onClick`])])])}var Ft=R(At,[[`render`,Pt]]),It=r({name:`TaskPreview`,components:{ElImage:C,CopyToClipboard:q,FontAwesomeIcon:K,ElAlert:w,VideoPlayer:Q,ElTooltip:S,ElButton:v,ApiCodeButton:ce},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.veo?.application},config(){return this.$store.state.veo?.config}},methods:{onPickAction(e,t,n,r){console.debug(`seed config from preview`,{action:n,upsampleAction:r,response:t}),this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,action:n,video_id:t?.data?.[0]?.id,video_url:t?.data?.[0]?.video_url,...r?{upsample_action:r}:{}})},onDownload(e,t){e?.stopPropagation(),console.log(`on download`),window.open(t,`_blank`)},onOpenVideo(e){window.open(e,`_blank`)}}}),Lt={class:`preview`},Rt={class:`left`},zt={class:`main`},Bt={class:`bot`},Vt={class:`datetime`},Ht={class:`info`},Ut={key:0,class:`prompt mt-2`},Wt={key:0},Gt={key:1},Kt={key:0,class:l({content:!0,failed:!0})},qt={key:0,class:`mb-4`},Jt={key:1,class:l({operations:!0,"mt-2":!0})},Yt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Xt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Zt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Qt={key:1,class:l({content:!0})},$t={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},en={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},tn={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},nn={key:2,class:l({content:!0})},rn={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},an={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function on(e,r,s,c,l,f){let p=h(`el-image`),_=h(`video-player`),v=h(`el-button`),y=h(`el-tooltip`),b=h(`api-code-button`),x=h(`font-awesome-icon`),S=h(`copy-to-clipboard`),C=h(`el-alert`);return d(),t(`div`,Lt,[n(`div`,Rt,[o(p,{src:`https://cdn.acedata.cloud/8nxyy9.jpg`,class:`avatar`})]),n(`div`,zt,[n(`div`,Bt,[i(u(e.$t(`veo.name.veoBot`))+` `,1),n(`span`,Vt,u(e.$dayjs.format(``+new Date(parseFloat((e.modelValue?.created_at||``).toString())*1e3))),1)]),n(`div`,Ht,[e.modelValue?.request?.prompt?(d(),t(`p`,Ut,[i(u(e.modelValue?.request?.prompt)+` `,1),e.modelValue?.response?m(``,!0):(d(),t(`span`,Wt,` - (`+u(e.$t(`veo.status.pending`))+`) `,1)),Array.isArray(e.modelValue?.response?.data)&&e.modelValue?.response?.data[0]?.state===`running`?(d(),t(`span`,Gt,` - (`+u(e.$t(`veo.status.processing`))+`) `,1)):m(``,!0)])):m(``,!0)]),e.modelValue?.response?.success===!0&&e.modelValue?.response?.data?(d(),t(`div`,Kt,[e.modelValue?.response?.data[0]?.video_url?(d(),t(`div`,qt,[o(_,{src:e.modelValue?.response?.data[0]?.video_url},null,8,[`src`])])):m(``,!0),e.modelValue?.response.success?(d(),t(`div`,Jt,[e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:r[0]||=t=>e.onPickAction(t,e.modelValue?.response,`upsample`,`1080p`)},{default:g(()=>[i(u(e.$t(`veo.button.actionUpsample1080p`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:1,type:`info`,size:`small`,class:`btn-action`,onClick:r[1]||=t=>e.onPickAction(t,e.modelValue?.response,`upsample`,`4k`)},{default:g(()=>[i(u(e.$t(`veo.button.actionUpsample4k`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:2,type:`info`,size:`small`,class:`btn-action`,onClick:r[2]||=t=>e.onPickAction(t,e.modelValue?.response,`upsample`,`gif`)},{default:g(()=>[i(u(e.$t(`veo.button.actionUpsampleGif`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:3,type:`info`,size:`small`,class:`btn-action`,onClick:r[3]||=t=>e.onPickAction(t,e.modelValue?.response,`extend`)},{default:g(()=>[i(u(e.$t(`veo.button.actionExtend`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:4,type:`info`,size:`small`,class:`btn-action`,onClick:r[4]||=t=>e.onPickAction(t,e.modelValue?.response,`reshoot`)},{default:g(()=>[i(u(e.$t(`veo.button.actionReshoot`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:5,type:`info`,size:`small`,class:`btn-action`,onClick:r[5]||=t=>e.onPickAction(t,e.modelValue?.response,`object_insert`)},{default:g(()=>[i(u(e.$t(`veo.button.actionObjectInsert`)),1)]),_:1})):m(``,!0),e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:6,type:`info`,size:`small`,class:`btn-action`,onClick:r[6]||=t=>e.onPickAction(t,e.modelValue?.response,`object_remove`)},{default:g(()=>[i(u(e.$t(`veo.button.actionObjectRemove`)),1)]),_:1})):m(``,!0),o(y,{class:`box-item`,effect:`dark`,content:e.$t(`veo.message.downloadVideo`),placement:`top-start`},{default:g(()=>[e.modelValue?.response?.data[0]?.video_url?(d(),a(v,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:r[7]||=t=>e.onDownload(t,e.modelValue?.response?.data[0]?.video_url)},{default:g(()=>[i(u(e.$t(`veo.button.download`)),1)]),_:1})):m(``,!0)]),_:1},8,[`content`]),o(b,{path:`/veo/videos`,body:e.modelValue?.request},null,8,[`body`])])):m(``,!0),o(C,{closable:!1,class:`mt-2 success`},{default:g(()=>[n(`p`,Yt,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.model`))+`: `+u(e.modelValue?.request?.model),1)]),n(`p`,Xt,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.taskId`))+`: `+u(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),e.modelValue?.elapsed?(d(),t(`p`,Zt,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.elapsed`))+`: `+u(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0)]),_:1})])):m(``,!0),e.modelValue?.response?.success===!1?(d(),t(`div`,Qt,[o(C,{closable:!1,class:`failure`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.failure`)),1)]),default:g(()=>[n(`p`,$t,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.taskId`))+`: `+u(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),n(`p`,en,[o(x,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.failureReason`))+`: `+u(e.modelValue?.response?.error?.message)+` `,1),o(S,{content:e.modelValue?.response?.error?.message},null,8,[`content`])]),e.modelValue?.elapsed?(d(),t(`p`,$,[o(x,{icon:`fa-solid fa-clock`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.elapsed`))+`: `+u(e.modelValue?.elapsed?.toFixed(2))+`s `,1)])):m(``,!0),e.modelValue?.response?.trace_id?(d(),t(`p`,tn,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.traceId`))+`: `+u(e.modelValue?.response?.trace_id)+` `,1),o(S,{content:e.modelValue?.response?.trace_id},null,8,[`content`])])):m(``,!0)]),_:1})])):m(``,!0),e.modelValue?.response?.success===void 0?(d(),t(`div`,nn,[o(C,{closable:!1,class:`info`},{template:g(()=>[o(x,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.failure`)),1)]),default:g(()=>[n(`p`,rn,[o(x,{icon:`fa-solid fa-magic`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.taskId`))+`: `+u(e.modelValue?.id)+` `,1),o(S,{content:e.modelValue?.id},null,8,[`content`])]),e.modelValue?.response?.trace_id?(d(),t(`p`,an,[o(x,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),i(` `+u(e.$t(`veo.name.traceId`))+`: `+u(e.modelValue?.response?.trace_id)+` `,1),o(S,{content:e.modelValue?.response?.trace_id},null,8,[`content`])])):m(``,!0)]),_:1})])):m(``,!0)])])}var sn=r({name:`RecentPanel`,components:{TaskPreview:R(It,[[`render`,on],[`__scopeId`,`data-v-9698fe5f`]]),NoTasks:oe,BotPlaceholder:X,ScrollList:re},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.veo?.tasks,items:this.$store.state.veo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),cn={key:0},ln={key:2,class:`w-full h-full flex items-center justify-center`};function un(n,r,i,c,l,u){let f=h(`bot-placeholder`),p=h(`task-preview`),_=h(`scroll-list`),v=h(`no-tasks`);return d(),t(s,null,[n.tasks?.items===void 0?(d(),t(`div`,cn,[o(f)])):n.tasks?.items?.length&&n.tasks?.items?.length>0?(d(),a(_,{key:1,ref:`scrollList`,class:`tasks h-full w-full overflow-y-auto`,loading:n.loading,onReachTop:r[0]||=e=>n.$emit(`reach-top`)},{default:g(()=>[(d(!0),t(s,null,e(n.tasks?.items,(e,t)=>(d(),a(p,{key:t,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):m(``,!0),n.tasks?.items?.length===0?(d(),t(`div`,ln,[o(v)])):m(``,!0)],64)}var dn=R(sn,[[`render`,un]]),fn=D(`veo`),pn=r({name:`VeoIndex`,components:{ConfigPanel:Ft,Layout:me,RecentPanel:dn},mixins:[U],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.veo?.status?.getApplications===H.Request},tasksLoading(){return this.$store.state.veo?.status?.getTasks===H.Request||this.fetchingTasks},credential(){return this.$store.state.veo.credential},config(){return this.$store.state.veo.config},tasks(){return this.$store.state.veo.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug(`new tasks detected`)},deep:!0},initialized:{async handler(e){e&&(console.debug(`layout initialized`),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await ie({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(`veo/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`veo/getApplications`),console.debug(`end onGetApplication`),await this.onGetTasks()},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(`veo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!W(this.uploadTracker,e=>this.$t(e),e=>I.warning(e)))return;let e={...this.config,callback_url:fn},t=this.credential?.token;if(!t){console.error(`no token specified`);return}if(e.action===`image2video`&&!(e.image_urls&&e.image_urls.length>0)){I.warning(this.$t(`veo.message.imageRequired`));return}(!e.image_urls||e.image_urls.length===0)&&delete e.image_urls,I.info(this.$t(`veo.message.startingTask`)),ne(`veo`,G.generate(e,{token:t})).then(()=>{I.success(this.$t(`veo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?I.error(this.$t(`veo.message.usedUp`)):I.error(this.$t(`veo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function mn(e,t,n,r,i,s){let c=h(`config-panel`),l=h(`recent-panel`),u=h(`layout`);return d(),a(u,null,{config:g(()=>[o(c,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:g(()=>[o(l,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var hn=R(pn,[[`render`,mn]]);export{hn as default};
@@ -1 +1 @@
1
- import{A as e,F as t,Z as n}from"./vendor-chart-BJCvKk8-.js";import{E as r}from"./index-GNIRULpP.js";var i=t({name:`SettingsIndex`,mounted(){let e=this.$route.query.tab||``;window.dispatchEvent(new CustomEvent(`open-user-settings`,{detail:{tab:e}}))}}),a={class:`settings-page`};function o(t,r,i,o,s,c){return n(),e(`div`,a)}var s=r(i,[[`render`,o]]);export{s as default};
1
+ import{A as e,F as t,Z as n}from"./vendor-chart-BJCvKk8-.js";import{E as r}from"./index-CXLIbz5p.js";var i=t({name:`SettingsIndex`,mounted(){let e=this.$route.query.tab||``;window.dispatchEvent(new CustomEvent(`open-user-settings`,{detail:{tab:e}}))}}),a={class:`settings-page`};function o(t,r,i,o,s,c){return n(),e(`div`,a)}var s=r(i,[[`render`,o]]);export{s 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-lRQt4LGt.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-BJuqTN4_.js";import{t as h}from"./Pagination-5dcmS8-D.js";import{An as g,E as _}from"./index-GNIRULpP.js";import{t as v}from"./CopyToClipboard-Rmd8YAx9.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 g.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=_(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-lRQt4LGt.js";import{t as f}from"./card-DjyfNde2.js";import{n as p,t as m}from"./row-BvkHf04T.js";import{t as h}from"./Pagination-pNIAuBPg.js";import{An as g,E as _}from"./index-CXLIbz5p.js";import{t as v}from"./CopyToClipboard-yGJQFFP1.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 g.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=_(y,[[`render`,O],[`__scopeId`,`data-v-4556864d`]]);export{k as default};
@@ -0,0 +1 @@
1
+ .summary-card[data-v-1d77a696]{flex-direction:column;align-items:flex-start;gap:4px;display:flex}.summary-card .icon-wrapper[data-v-1d77a696]{background-color:var(--el-bg-color-page);text-align:center;width:40px;height:40px;color:var(--el-color-primary);border-radius:50%;flex-shrink:0;margin-bottom:6px;line-height:40px}.summary-card .label[data-v-1d77a696]{color:var(--el-text-color-regular);margin:0;font-size:14px;line-height:20px}.summary-card .value[data-v-1d77a696]{word-break:break-all;margin:0;font-size:30px;font-weight:600;line-height:36px}.summary-card .description[data-v-1d77a696]{color:var(--el-text-color-secondary);margin:4px 0 0;font-size:12px}.application-list[data-v-1d77a696]{width:100%;margin:0}.applications-table-card[data-v-1d77a696] .el-card__body{overflow-x:auto}.application-card__name[data-v-1d77a696]{color:var(--el-text-color-primary);word-break:break-word;font-size:15px;font-weight:600}.application-card__id[data-v-1d77a696]{color:var(--el-text-color-secondary);align-items:center;gap:4px;margin-top:6px;font-size:12px;display:flex}.application-card__id .truncate[data-v-1d77a696]{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.application-card__row[data-v-1d77a696]{justify-content:space-between;align-items:center;gap:8px;margin-top:8px;display:flex}.application-card__row .label[data-v-1d77a696]{color:var(--el-text-color-regular);flex-shrink:0;font-size:13px}.application-card__row .value[data-v-1d77a696]{color:var(--el-text-color-primary);text-align:right;word-break:break-all;font-size:14px;font-weight:500}@media screen and (width<=767px){.application-list[data-v-1d77a696]{display:block}.summary-card .value[data-v-1d77a696]{font-size:24px;line-height:30px}}
@@ -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{t as m}from"./button-DfsQodL-.js";import{r as h,t as ee}from"./select-ChrghZdq.js";import{n as g,t as _}from"./table-lRQt4LGt.js";import{t as v}from"./date-picker-DI9uIhaT.js";import{t as y}from"./card-DjyfNde2.js";import{n as b,t as x}from"./row-BJuqTN4_.js";import{t as S}from"./Pagination-5dcmS8-D.js";import{t as C}from"./skeleton-C4sltx62.js";import{E as w,Fr as T,Ft as E,fr as D,wn as O}from"./index-GNIRULpP.js";import{t as k}from"./index.es-BiR7C8is.js";import{t as A}from"./CopyToClipboard-Rmd8YAx9.js";var j={total_count:0,total_spent:0,state_counts:{}},M=r({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:A,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:m,ElTag:T,ElCard:y,ElSelect:h,ElOption:ee,ElDatePicker:v,ElSkeleton:C,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:E,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,O.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,O.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...j}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,O.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{t as m}from"./button-DfsQodL-.js";import{r as h,t as ee}from"./select-B6b3u-H9.js";import{n as g,t as _}from"./table-lRQt4LGt.js";import{t as v}from"./date-picker-Nk8GD6uo.js";import{t as y}from"./card-DjyfNde2.js";import{n as b,t as x}from"./row-BvkHf04T.js";import{t as S}from"./Pagination-pNIAuBPg.js";import{t as C}from"./skeleton-C4sltx62.js";import{E as w,Fr as T,Ft as E,fr as D,wn as O}from"./index-CXLIbz5p.js";import{t as k}from"./index.es-gzde5lIu.js";import{t as A}from"./CopyToClipboard-yGJQFFP1.js";var j={total_count:0,total_spent:0,state_counts:{}},M=r({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:A,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:m,ElTag:T,ElCard:y,ElSelect:h,ElOption:ee,ElDatePicker:v,ElSkeleton:C,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:E,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,O.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,O.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...j}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,O.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};
@@ -0,0 +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{t as h}from"./button-DfsQodL-.js";import{n as g,t as ee}from"./table-lRQt4LGt.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-BvkHf04T.js";import{t as b}from"./empty-DA4nlQUv.js";import{t as x}from"./Pagination-pNIAuBPg.js";import{t as S}from"./skeleton-C4sltx62.js";import{t as C}from"./switch-DzKEO4No.js";import{Ar as w,B as T,E,Er as D,Fr as O,P as k,_r as A,dr as j,jn as M,ur as N,vr as P}from"./index-CXLIbz5p.js";import{t as F}from"./index.es-gzde5lIu.js";import{t as I}from"./CopyToClipboard-yGJQFFP1.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:O,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:N,serviceType:j,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 D()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||M.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{w.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{w.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:T,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:k,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)=>{M.getAll({limit:this.limit,...e===A.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:P.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=>{w.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(){M.create({type:P.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 align-center`},G={class:`summary-card`},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`},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=E(L,[[`render`,ve],[`__scopeId`,`data-v-1d77a696`]]);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 p,k as m,n as h,nt as g,o as _,r as v,s as y,t as b,tt as x,ut as S,v as ee}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-DfsQodL-.js";import{r as w,t as T}from"./select-ChrghZdq.js";import{n as E,t as D}from"./table-lRQt4LGt.js";import{n as O,t as k}from"./tabs-Df29OFVp.js";import{t as A}from"./date-picker-DI9uIhaT.js";import{t as j}from"./card-DjyfNde2.js";import{n as M,r as N}from"./radio-BmBXySlN.js";import{n as P,t as F}from"./row-BJuqTN4_.js";import{t as I}from"./Pagination-5dcmS8-D.js";import{n as L,t as R}from"./skeleton-C4sltx62.js";import{Dn as z,E as B,En as V,Fr as H,Nr as U,Tn as W,dr as G,jn as K,ur as q,vr as J}from"./index-GNIRULpP.js";import{t as Y}from"./index.es-BiR7C8is.js";import{t as X}from"./CopyToClipboard-Rmd8YAx9.js";p.register(v,u,h,y,d,_);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:H,ElDatePicker:A,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:j,ElRadioButton:M,ElRadioGroup:N,ElSkeleton:R,ElSkeletonItem:L,ElDialog:U,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:b},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:q,serviceType:G,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()||G.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===G.API?this.onFetchApiUsages():this.type===G.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 V.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&&V.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(){K.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:J.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,W.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,V.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,z.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,V.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 V.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,p,h,_){let v=x(`el-col`),y=x(`el-row`),b=x(`el-radio-button`),C=x(`el-radio-group`),w=x(`el-option`),T=x(`el-select`),E=x(`el-skeleton-item`),D=x(`el-skeleton`),O=x(`el-date-picker`),k=x(`font-awesome-icon`),A=x(`el-button`),j=x(`el-card`),M=x(`bar-chart`),N=x(`el-table-column`),P=x(`el-tag`),F=x(`copy-to-clipboard`),I=x(`el-table`),L=x(`el-tab-pane`),R=x(`el-tabs`),z=x(`el-dialog`),B=x(`pagination`),V=g(`loading`);return l(),a(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[o(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(y,null,{default:S(()=>[o(v,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:S(()=>[o(b,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(b,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(v,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[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:S(()=>[(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),[[ee,!1]]),r.type===r.serviceType.API?(l(),a(v,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:S(()=>[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:S(()=>[(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})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[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})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[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:S(()=>[(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})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:S(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:S(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):m(``,!0)]),_:1}),o(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[r.type===r.serviceType.API?(l(),a(y,{key:0,gutter:24,class:`mb-5`},{default:S(()=>[o(v,{md:6,xs:24},{default:S(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:S(()=>[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(v,{md:18,xs:24},{default:S(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:S(()=>[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})):m(``,!0),o(j,{shadow:`hover`},{default:S(()=>[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:S(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:S(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:S(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:S(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:S(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:S(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:S(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:S(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):m(``,!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:S(()=>[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:S(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:S(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):m(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:S(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`])])):m(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:S(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):m(``,!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:S(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:S(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:S(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:S(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:S(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:S(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:S(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:S(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):m(``,!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:S(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:S(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:S(()=>[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:S(()=>[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(y,null,{default:S(()=>[o(v,{span:10,offset:14},{default:S(()=>[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=B(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 p,k as m,n as h,nt as g,o as _,r as v,s as y,t as b,tt as x,ut as S,v as ee}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-DfsQodL-.js";import{r as w,t as T}from"./select-B6b3u-H9.js";import{n as E,t as D}from"./table-lRQt4LGt.js";import{n as O,t as k}from"./tabs-tfJQ1CG8.js";import{t as A}from"./date-picker-Nk8GD6uo.js";import{t as j}from"./card-DjyfNde2.js";import{n as M,r as N}from"./radio-BmBXySlN.js";import{n as P,t as F}from"./row-BvkHf04T.js";import{t as I}from"./Pagination-pNIAuBPg.js";import{n as L,t as R}from"./skeleton-C4sltx62.js";import{Dn as z,E as B,En as V,Fr as H,Nr as U,Tn as W,dr as G,jn as K,ur as q,vr as J}from"./index-CXLIbz5p.js";import{t as Y}from"./index.es-gzde5lIu.js";import{t as X}from"./CopyToClipboard-yGJQFFP1.js";p.register(v,u,h,y,d,_);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:H,ElDatePicker:A,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:j,ElRadioButton:M,ElRadioGroup:N,ElSkeleton:R,ElSkeletonItem:L,ElDialog:U,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:b},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:q,serviceType:G,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()||G.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===G.API?this.onFetchApiUsages():this.type===G.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 V.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&&V.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(){K.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:J.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,W.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,V.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,z.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,V.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 V.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,p,h,_){let v=x(`el-col`),y=x(`el-row`),b=x(`el-radio-button`),C=x(`el-radio-group`),w=x(`el-option`),T=x(`el-select`),E=x(`el-skeleton-item`),D=x(`el-skeleton`),O=x(`el-date-picker`),k=x(`font-awesome-icon`),A=x(`el-button`),j=x(`el-card`),M=x(`bar-chart`),N=x(`el-table-column`),P=x(`el-tag`),F=x(`copy-to-clipboard`),I=x(`el-table`),L=x(`el-tab-pane`),R=x(`el-tabs`),z=x(`el-dialog`),B=x(`pagination`),V=g(`loading`);return l(),a(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[o(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(y,null,{default:S(()=>[o(v,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:S(()=>[o(b,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(b,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(v,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[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:S(()=>[(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),[[ee,!1]]),r.type===r.serviceType.API?(l(),a(v,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:S(()=>[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:S(()=>[(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})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[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})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[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:S(()=>[(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})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:S(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:S(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):m(``,!0)]),_:1}),o(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[r.type===r.serviceType.API?(l(),a(y,{key:0,gutter:24,class:`mb-5`},{default:S(()=>[o(v,{md:6,xs:24},{default:S(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:S(()=>[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(v,{md:18,xs:24},{default:S(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:S(()=>[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})):m(``,!0),o(j,{shadow:`hover`},{default:S(()=>[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:S(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:S(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:S(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:S(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:S(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:S(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:S(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:S(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):m(``,!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:S(()=>[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:S(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:S(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):m(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:S(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`])])):m(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:S(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):m(``,!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:S(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:S(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:S(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:S(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:S(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:S(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:S(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:S(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):m(``,!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:S(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:S(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:S(()=>[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:S(()=>[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(y,null,{default:S(()=>[o(v,{span:10,offset:14},{default:S(()=>[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=B(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe 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"./button-DfsQodL-.js";import{t as p}from"./Navigator-BcC63YP5.js";import{t as m}from"./checkbox-BAeQdLeW.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-Doj9A7vw.js";import{Ar as g,Cr as _,E as v,Nr as y,Nt as b,_r as x,br as S,jn as C,vr as w}from"./index-GNIRULpP.js";import{t as T}from"./Status-CqqMuyua.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:y,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:_,onApply(){if(!this.checked){g.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=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:v(E,[[`render`,M]])},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===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)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize)},methods:{onResize(){this.mobile=window.innerWidth<768},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId)return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=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 C.create({type:w.USAGE,scope:x.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`):g.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);g({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),P={class:`wrapper`};function F(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,P,[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 I=v(N,[[`render`,F],[`__scopeId`,`data-v-41b86eb8`]]);export{I 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"./button-DfsQodL-.js";import{t as p}from"./Navigator-DhzQXWHV.js";import{t as m}from"./checkbox-BAeQdLeW.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-DMm7qShB.js";import{Ar as g,Cr as _,E as v,Nr as y,Nt as b,_r as x,br as S,jn as C,vr as w}from"./index-CXLIbz5p.js";import{t as T}from"./Status-BJG9p-wa.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:y,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:_,onApply(){if(!this.checked){g.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=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:v(E,[[`render`,M]])},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===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)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize)},methods:{onResize(){this.mobile=window.innerWidth<768},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId)return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=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 C.create({type:w.USAGE,scope:x.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`):g.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);g({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),P={class:`wrapper`};function F(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,P,[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 I=v(N,[[`render`,F],[`__scopeId`,`data-v-41b86eb8`]]);export{I 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,Vt as c,Wt as l,Z as u,b as d,k as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-DfsQodL-.js";import{t as g}from"./upload-Da-O-e6z.js";import{t as _}from"./image-Byij2YF_.js";import{t as v}from"./alert-OvnfgMB-.js";import{n as y,r as b}from"./radio-BmBXySlN.js";import{t as x}from"./switch-BnyHYpIj.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-Doj9A7vw.js";import{Ar as C,At as w,Cr as T,E,J as ee,Jt as te,Lr as D}from"./index-GNIRULpP.js";import{t as O}from"./index.es-BiR7C8is.js";import{t as k}from"./CopyToClipboard-Rmd8YAx9.js";import{t as A}from"./Hailuo-CfpyrSKC.js";import{t as j}from"./BotPlaceholder-C6fcffYi.js";import{t as M}from"./TabSwitcher-C9gbSJu9.js";var N=4,P=90,F=r({name:`FishRecorder`,components:{ElButton:h,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){C.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;C.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){C.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${T()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){C.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){C.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(e,r,s,d,h,g){let _=p(`font-awesome-icon`),v=p(`el-button`);return u(),t(`div`,I,[e.state===`recorded`?f(``,!0):(u(),t(`div`,L,[n(`div`,R,[o(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,l(e.$t(`fish.description.readScript`)),1),o(v,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:m(()=>[o(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,l(e.currentScript),1)])),n(`div`,V,[e.state===`idle`?(u(),a(v,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(u(),a(v,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):f(``,!0),n(`div`,H,[n(`span`,{class:c([`timer`,e.state===`recording`?`live`:``])},l(e.formattedTime),3),n(`span`,U,l(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(u(),t(`div`,W,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[o(v,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(v,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:m(()=>[o(_,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):f(``,!0),n(`div`,q,[o(v,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:m(()=>[i(l(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=E(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=r({name:`FishModelConfigPanel`,components:{ElButton:h,ElInput:D,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:O,Recorder:Y},mixins:[w],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return T()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(C.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){C.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,C.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){C.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){C.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){C.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,r,s,c,d,h){let g=p(`el-input`),_=p(`font-awesome-icon`),v=p(`el-button`),y=p(`el-upload`),b=p(`recorder`),x=p(`el-radio-button`),S=p(`el-radio-group`),C=p(`el-switch`);return u(),t(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[i(l(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(g,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[i(l(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(u(),t(`span`,le,l(e.$t(`fish.description.audioRequired`)),1)):f(``,!0)]),n(`p`,ue,l(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(u(),t(`div`,de,[o(y,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:m(()=>[o(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:m(()=>[o(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):f(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(u(),t(`p`,fe,l(e.$t(`fish.message.recorderUnsupported`)),1)):f(``,!0),e.recording?(u(),a(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):f(``,!0),e.form.voicesUrl&&!e.recording?(u(),t(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[o(v,{link:``,size:`small`,onClick:e.clearAudio},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):f(``,!0)]),n(`div`,ge,[n(`h2`,_e,l(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,l(e.$t(`fish.description.audioTexts`)),1),o(g,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,l(e.$t(`fish.name.voiceDescription`)),1),o(g,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,l(e.$t(`fish.name.visibility`)),1),o(S,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:m(()=>[o(x,{label:`private`,value:`private`},{default:m(()=>[i(l(e.$t(`fish.value.private`)),1)]),_:1}),o(x,{label:`unlist`,value:`unlist`},{default:m(()=>[i(l(e.$t(`fish.value.unlist`)),1)]),_:1}),o(x,{label:`public`,value:`public`},{default:m(()=>[i(l(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,l(e.$t(`fish.name.trainMode`)),1),o(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:m(()=>[o(x,{label:`fast`,value:`fast`},{default:m(()=>[i(l(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(x,{label:`precise`,value:`precise`},{default:m(()=>[i(l(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,l(e.$t(`fish.name.enhanceAudio`)),1),o(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,l(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,l(e.$t(`fish.name.generateSample`)),1),o(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,l(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[o(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:m(()=>[o(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=E(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=r({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:ee}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,r,s,c,h,g){let _=p(`el-image`),v=p(`font-awesome-icon`),y=p(`copy-to-clipboard`),b=p(`el-alert`),x=p(`el-button`);return u(),t(`div`,Le,[n(`div`,Re,[e.coverSrc?(u(),a(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:m(()=>[o(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:m(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(u(),a(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,l(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(u(),t(`span`,He,l(e.createdAtLabel),1)):f(``,!0)]),e.modelValue?.description?(u(),t(`p`,Ue,l(e.modelValue?.description),1)):f(``,!0),e.sampleAudioUrl?(u(),t(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):f(``,!0),o(b,{closable:!1,class:`mt-2 success`},{default:m(()=>[e.voiceId?(u(),t(`p`,Ke,[o(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.referenceId`))+`: `+l(e.voiceId)+` `,1),o(y,{content:e.voiceId},null,8,[`content`])])):f(``,!0),e.modelValue?.visibility?(u(),t(`p`,qe,[o(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.visibility`))+`: `+l(e.modelValue?.visibility),1)])):f(``,!0)]),_:1}),n(`div`,Je,[o(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:d(e.onUseVoice,[`stop`])},{default:m(()=>[o(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=r({name:`FishModelListPanel`,components:{VoiceCard:E(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(r,i,c,d,m,h){let g=p(`bot-placeholder`),_=p(`font-awesome-icon`),v=p(`voice-card`);return u(),t(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,l(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(u(),t(`span`,et,l(r.voices?.length),1)):f(``,!0)]),n(`div`,tt,[r.voices===void 0?(u(),t(`div`,$,[o(g)])):r.voices.length===0?(u(),t(`div`,nt,[o(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,l(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,l(r.$t(`fish.description.noVoicesYet`)),1)])):(u(),t(`div`,at,[(u(!0),t(s,null,e(r.voices,e=>(u(),a(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=r({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:A,ModelListPanel:E(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,C.info(this.$t(`fish.message.creatingModel`));try{await te.createModel(e,{token:t}),C.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?C.error(this.$t(`fish.message.usedUp`)):C.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,t,r,i,s,c){let l=p(`tab-switcher`),d=p(`model-config-panel`),f=p(`model-list-panel`),h=p(`layout`);return u(),a(h,null,{config:m(()=>[n(`div`,ct,[o(l),n(`div`,lt,[o(d,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:m(()=>[o(f,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=E(st,[[`render`,ut]]);export{dt 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,Vt as c,Wt as l,Z as u,b as d,k as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-DfsQodL-.js";import{t as g}from"./upload-CtG17-3u.js";import{t as _}from"./image-DwwO3q6F.js";import{t as v}from"./alert-OvnfgMB-.js";import{n as y,r as b}from"./radio-BmBXySlN.js";import{t as x}from"./switch-DzKEO4No.js";import{t as S}from"./vendor-axios-Ck2ffRoh.js";import"./constants-DMm7qShB.js";import{Ar as C,At as w,Cr as T,E,J as ee,Jt as te,Lr as D}from"./index-CXLIbz5p.js";import{t as O}from"./index.es-gzde5lIu.js";import{t as k}from"./CopyToClipboard-yGJQFFP1.js";import{t as A}from"./Hailuo-Mf8iqfjV.js";import{t as j}from"./BotPlaceholder-CO654Xhh.js";import{t as M}from"./TabSwitcher-CzGId_W3.js";var N=4,P=90,F=r({name:`FishRecorder`,components:{ElButton:h,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){C.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;C.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){C.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await S.post(`${T()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){C.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){C.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(e,r,s,d,h,g){let _=p(`font-awesome-icon`),v=p(`el-button`);return u(),t(`div`,I,[e.state===`recorded`?f(``,!0):(u(),t(`div`,L,[n(`div`,R,[o(_,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,l(e.$t(`fish.description.readScript`)),1),o(v,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:m(()=>[o(_,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,l(e.currentScript),1)])),n(`div`,V,[e.state===`idle`?(u(),a(v,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(u(),a(v,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):f(``,!0),n(`div`,H,[n(`span`,{class:c([`timer`,e.state===`recording`?`live`:``])},l(e.formattedTime),3),n(`span`,U,l(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(u(),t(`div`,W,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[o(v,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(v,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:m(()=>[o(_,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):f(``,!0),n(`div`,q,[o(v,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:m(()=>[i(l(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=E(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=r({name:`FishModelConfigPanel`,components:{ElButton:h,ElInput:D,ElRadioButton:y,ElRadioGroup:b,ElSwitch:x,ElUpload:g,FontAwesomeIcon:O,Recorder:Y},mixins:[w],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return T()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(C.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){C.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,C.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){C.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){C.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){C.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,r,s,c,d,h){let g=p(`el-input`),_=p(`font-awesome-icon`),v=p(`el-button`),y=p(`el-upload`),b=p(`recorder`),x=p(`el-radio-button`),S=p(`el-radio-group`),C=p(`el-switch`);return u(),t(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[i(l(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(g,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[i(l(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(u(),t(`span`,le,l(e.$t(`fish.description.audioRequired`)),1)):f(``,!0)]),n(`p`,ue,l(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(u(),t(`div`,de,[o(y,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:m(()=>[o(v,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:m(()=>[o(_,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(v,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:m(()=>[o(_,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+l(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):f(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(u(),t(`p`,fe,l(e.$t(`fish.message.recorderUnsupported`)),1)):f(``,!0),e.recording?(u(),a(b,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):f(``,!0),e.form.voicesUrl&&!e.recording?(u(),t(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[o(v,{link:``,size:`small`,onClick:e.clearAudio},{default:m(()=>[o(_,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):f(``,!0)]),n(`div`,ge,[n(`h2`,_e,l(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,l(e.$t(`fish.description.audioTexts`)),1),o(g,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,l(e.$t(`fish.name.voiceDescription`)),1),o(g,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,l(e.$t(`fish.name.visibility`)),1),o(S,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:m(()=>[o(x,{label:`private`,value:`private`},{default:m(()=>[i(l(e.$t(`fish.value.private`)),1)]),_:1}),o(x,{label:`unlist`,value:`unlist`},{default:m(()=>[i(l(e.$t(`fish.value.unlist`)),1)]),_:1}),o(x,{label:`public`,value:`public`},{default:m(()=>[i(l(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,l(e.$t(`fish.name.trainMode`)),1),o(S,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:m(()=>[o(x,{label:`fast`,value:`fast`},{default:m(()=>[i(l(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(x,{label:`precise`,value:`precise`},{default:m(()=>[i(l(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,l(e.$t(`fish.name.enhanceAudio`)),1),o(C,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,l(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,l(e.$t(`fish.name.generateSample`)),1),o(C,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,l(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[o(v,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:m(()=>[o(_,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+l(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=E(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=r({name:`FishVoiceCard`,components:{ElAlert:v,ElButton:h,ElImage:_,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:ee}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,r,s,c,h,g){let _=p(`el-image`),v=p(`font-awesome-icon`),y=p(`copy-to-clipboard`),b=p(`el-alert`),x=p(`el-button`);return u(),t(`div`,Le,[n(`div`,Re,[e.coverSrc?(u(),a(_,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:m(()=>[o(_,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:m(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(u(),a(_,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,l(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(u(),t(`span`,He,l(e.createdAtLabel),1)):f(``,!0)]),e.modelValue?.description?(u(),t(`p`,Ue,l(e.modelValue?.description),1)):f(``,!0),e.sampleAudioUrl?(u(),t(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):f(``,!0),o(b,{closable:!1,class:`mt-2 success`},{default:m(()=>[e.voiceId?(u(),t(`p`,Ke,[o(v,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.referenceId`))+`: `+l(e.voiceId)+` `,1),o(y,{content:e.voiceId},null,8,[`content`])])):f(``,!0),e.modelValue?.visibility?(u(),t(`p`,qe,[o(v,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+l(e.$t(`fish.name.visibility`))+`: `+l(e.modelValue?.visibility),1)])):f(``,!0)]),_:1}),n(`div`,Je,[o(x,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:d(e.onUseVoice,[`stop`])},{default:m(()=>[o(v,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+l(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=r({name:`FishModelListPanel`,components:{VoiceCard:E(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:j,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(r,i,c,d,m,h){let g=p(`bot-placeholder`),_=p(`font-awesome-icon`),v=p(`voice-card`);return u(),t(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,l(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(u(),t(`span`,et,l(r.voices?.length),1)):f(``,!0)]),n(`div`,tt,[r.voices===void 0?(u(),t(`div`,$,[o(g)])):r.voices.length===0?(u(),t(`div`,nt,[o(_,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,l(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,l(r.$t(`fish.description.noVoicesYet`)),1)])):(u(),t(`div`,at,[(u(!0),t(s,null,e(r.voices,e=>(u(),a(v,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=r({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:A,ModelListPanel:E(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,C.info(this.$t(`fish.message.creatingModel`));try{await te.createModel(e,{token:t}),C.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?C.error(this.$t(`fish.message.usedUp`)):C.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,t,r,i,s,c){let l=p(`tab-switcher`),d=p(`model-config-panel`),f=p(`model-list-panel`),h=p(`layout`);return u(),a(h,null,{config:m(()=>[n(`div`,ct,[o(l),n(`div`,lt,[o(d,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:m(()=>[o(f,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=E(st,[[`render`,ut]]);export{dt as default};