@acedatacloud/nexior 3.327.2 → 3.327.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/assets/{ApiCodeButton-C8uFIxln.js → ApiCodeButton-Doj0G2Ua.js} +1 -1
  2. package/dist/assets/{Artifacts-W-zD-oW9.js → Artifacts-BEI44lzw.js} +1 -1
  3. package/dist/assets/{AskUserQuestionCard-6pzfiMO_.js → AskUserQuestionCard-2ufrOhOW.js} +1 -1
  4. package/dist/assets/{Auth-BX8yeeMi.js → Auth-CKRgNMBJ.js} +1 -1
  5. package/dist/assets/{Bare-BZpr_aCh.js → Bare-D-OsdE3Z.js} +1 -1
  6. package/dist/assets/{BotPlaceholder-CB9iZVnJ.js → BotPlaceholder-Cd4ngCBY.js} +1 -1
  7. package/dist/assets/{BottomFooter-D1RW6wvm.js → BottomFooter-IYVmgbxh.js} +1 -1
  8. package/dist/assets/{Callback-BVC0wROR.js → Callback-BtFOkOKj.js} +1 -1
  9. package/dist/assets/{CodeSnippet-BUEfpOpX.js → CodeSnippet-BOeGVxl-.js} +1 -1
  10. package/dist/assets/{Console-BUmjX_rh.js → Console-CWk0Sc1d.js} +1 -1
  11. package/dist/assets/{Consumption-BKrS2kBX.js → Consumption-Bf7XwbiV.js} +1 -1
  12. package/dist/assets/{Conversation-28-2HOX5.js → Conversation-CauZ-Lgr.js} +1 -1
  13. package/dist/assets/{Conversation-B-tqeMwE.js → Conversation-CyeNO3n0.js} +1 -1
  14. package/dist/assets/{CopyToClipboard-DSUOjJxX.js → CopyToClipboard-C5rXbm0J.js} +1 -1
  15. package/dist/assets/{Detail-BCCPLSwL.js → Detail-FOvG361i.js} +2 -2
  16. package/dist/assets/Extra-CiNNWLEK.css +1 -0
  17. package/dist/assets/{Extra-D9yifhGa.js → Extra-zZYreRZS.js} +1 -1
  18. package/dist/assets/{FilePreview-eCw9jCmD.js → FilePreview-B-Sl7qAT.js} +1 -1
  19. package/dist/assets/{Hailuo-ug4RP5On.js → Hailuo-7OwLRaCQ.js} +1 -1
  20. package/dist/assets/{History-Bt1tQsFA.js → History-DTaHilzi.js} +1 -1
  21. package/dist/assets/{ImagePreview-CXNjM0lL.js → ImagePreview-NSygfR7g.js} +1 -1
  22. package/dist/assets/{ImageWrapper-EHp__mG3.js → ImageWrapper-D50hT3hY.js} +1 -1
  23. package/dist/assets/{Index-BcDwdFVc.js → Index--6TbSDiC.js} +1 -1
  24. package/dist/assets/{Index-DpehPjTr.js → Index-B3M-DmGS.js} +1 -1
  25. package/dist/assets/{Index-7-WhOKKv.js → Index-B6MlWRmF.js} +1 -1
  26. package/dist/assets/{Index-DTQ4seve.js → Index-BCt30s5o.js} +1 -1
  27. package/dist/assets/{Index-5_sdIl62.js → Index-BF9n21zA.js} +1 -1
  28. package/dist/assets/{Index-5VQL-gUP.js → Index-BJFAzMuV.js} +1 -1
  29. package/dist/assets/{Index-aNrBIAp7.js → Index-BP31J8Ws.js} +1 -1
  30. package/dist/assets/{Index-OLwhf__B.js → Index-BkgUQuPJ.js} +1 -1
  31. package/dist/assets/{Index-CTDkvGmW.js → Index-BlBFVFU_.js} +1 -1
  32. package/dist/assets/{Index-C20kRanW.js → Index-BlqYKwKJ.js} +1 -1
  33. package/dist/assets/{Index-BECc2bq5.js → Index-BykjM0A0.js} +1 -1
  34. package/dist/assets/{Index-D0N8SYBS.js → Index-C2c2CjIo.js} +1 -1
  35. package/dist/assets/{Index-BBz15UZK.js → Index-CCJBaehl.js} +1 -1
  36. package/dist/assets/{Index-InCqDA-6.js → Index-CSW7kEEB.js} +1 -1
  37. package/dist/assets/{Index-Dfikp06P.js → Index-CTSvG_Dx.js} +1 -1
  38. package/dist/assets/{Index-D2TGg9II.js → Index-CZHdQXIu.js} +1 -1
  39. package/dist/assets/{Index-CzawB4YY.js → Index-CbGKNaBu.js} +1 -1
  40. package/dist/assets/{Index-DL_Ui9po.js → Index-CdZP6PrI.js} +1 -1
  41. package/dist/assets/{Index-_rMlwpOI.js → Index-CzxJZq3_.js} +1 -1
  42. package/dist/assets/{Index-BkmPIh2z.js → Index-DFHqPqYd.js} +1 -1
  43. package/dist/assets/{Index-B28bPdRe.js → Index-DSwI-5y7.js} +1 -1
  44. package/dist/assets/{Index-Z5Q0t7tV.js → Index-DTD8V2TX.js} +1 -1
  45. package/dist/assets/{Index-BFWAjPxS.js → Index-DXFv2dpF.js} +1 -1
  46. package/dist/assets/{Index-G05AAg-q.js → Index-DigQ100K.js} +1 -1
  47. package/dist/assets/{Index-wXgSJR6w.js → Index-DlICwYiI.js} +1 -1
  48. package/dist/assets/{Index-v0SCDL7Y.js → Index-DlRoYbxm.js} +1 -1
  49. package/dist/assets/{Index-DLdV4g6s.js → Index-Dla53_8y.js} +1 -1
  50. package/dist/assets/{Index-j9OEe_pc.js → Index-JhEHIuVO.js} +1 -1
  51. package/dist/assets/{Index-cyVIcGcm.js → Index-mM2S8zs0.js} +1 -1
  52. package/dist/assets/{Invitees-BYfBvq7r.js → Invitees-De62LCQs.js} +1 -1
  53. package/dist/assets/{List-Cy_kWu6J.js → List-BmkMTyMc.js} +1 -1
  54. package/dist/assets/{List-BA5taZ_g.js → List-CIcmaHRG.js} +1 -1
  55. package/dist/assets/{List-2mxLaGuw.js → List-DaVCQjZj.js} +1 -1
  56. package/dist/assets/{LocalTools-CvDYzWd2.js → LocalTools-BSZRj23g.js} +1 -1
  57. package/dist/assets/{LocalTools-CsKzY78B.js → LocalTools-BdvRDPU9.js} +1 -1
  58. package/dist/assets/{Main-BGkxqmKY.js → Main-CBr3Af6c.js} +1 -1
  59. package/dist/assets/{Message-CksxQBDr.js → Message-P7noZKVu.js} +1 -1
  60. package/dist/assets/{Model-C-VVXL3k.js → Model-BVRkmtjw.js} +1 -1
  61. package/dist/assets/{Navigator-Db2wTQZ-.js → Navigator-B92ZL5ZS.js} +3 -3
  62. package/dist/assets/{NoTasks-C_nRAzj6.js → NoTasks-CHXTr4XZ.js} +1 -1
  63. package/dist/assets/{NotFound-BhD-rgq8.js → NotFound-CyPtWonF.js} +1 -1
  64. package/dist/assets/{Pay-Dm6KVfg2.js → Pay-hZluBcbO.js} +1 -1
  65. package/dist/assets/{Player-BXy7bTzY.js → Player-CdH2g1n-.js} +1 -1
  66. package/dist/assets/{PromptTextarea-BlwckA3Q.js → PromptTextarea-CULk8zG8.js} +1 -1
  67. package/dist/assets/{RealtimeCall-DgVSGmBf.js → RealtimeCall-CatOF5T7.js} +1 -1
  68. package/dist/assets/{ScheduledTasks-BtZ18BOw.js → ScheduledTasks-CwRSazrN.js} +1 -1
  69. package/dist/assets/{Status-CijUE5CQ.js → Status-V9Ps8wO-.js} +1 -1
  70. package/dist/assets/{Subscribe-5uJhQ-a3.js → Subscribe-9WHUE_6u.js} +1 -1
  71. package/dist/assets/{TabSwitcher-CUbpVzcT.js → TabSwitcher-BdpZ-DEH.js} +1 -1
  72. package/dist/assets/{Tts-s-gJZUMX.js → Tts-BCRPkVIs.js} +1 -1
  73. package/dist/assets/{VideoPlayer-DaDRABrK.js → VideoPlayer-BNndMZsO.js} +1 -1
  74. package/dist/assets/{VideoPreview-DsOzrdwz.js → VideoPreview-ixh6oOoZ.js} +1 -1
  75. package/dist/assets/{alert-Dpx0Wsp2.js → alert-DejBSzEr.js} +1 -1
  76. package/dist/assets/{avatar-CyJcynMP.js → avatar-B9NkTQFP.js} +1 -1
  77. package/dist/assets/{basic-CGXVYrBX.js → basic-DEkCL_3U.js} +1 -1
  78. package/dist/assets/{chat-B-QXiiDd.js → chat-DGyELiCS.js} +1 -1
  79. package/dist/assets/{codingBridge-CwVjGMs8.js → codingBridge-C7zzcC04.js} +1 -1
  80. package/dist/assets/{codingBridgeNotify-EtcpBNI_.js → codingBridgeNotify-9izf95z6.js} +2 -2
  81. package/dist/assets/{collapse-CBJ_BSMw.js → collapse-C0dG4Yuh.js} +1 -1
  82. package/dist/assets/{createTaskActions-D4uEtlfm.js → createTaskActions-thGpi8zX.js} +1 -1
  83. package/dist/assets/{date-picker-D3ABTPMI.js → date-picker-CsgHwert.js} +1 -1
  84. package/dist/assets/{digitalhuman-CIeswBZ_.js → digitalhuman-CDDVJLxI.js} +1 -1
  85. package/dist/assets/{drawer-PHRJ8Qym.js → drawer-CnIwH9og.js} +1 -1
  86. package/dist/assets/{dropdown-CrxoJmAm.js → dropdown-BEx2ZUAC.js} +1 -1
  87. package/dist/assets/{dropdown-w4Nao5cv.js → dropdown-CTQJlVWt.js} +1 -1
  88. package/dist/assets/{esm-Cd4a1v89.js → esm-BvEtmU7i.js} +3 -3
  89. package/dist/assets/{esm-BI1-a6xi.js → esm-CaUkH2Rt.js} +2 -2
  90. package/dist/assets/{esm-BU2qW_kJ.js → esm-Cgpqq4pp.js} +1 -1
  91. package/dist/assets/{esm-oVnsx9O-.js → esm-ChVf8Nk_.js} +1 -1
  92. package/dist/assets/esm-DOdMiV_D.js +1 -0
  93. package/dist/assets/{esm-DnvPp5Jz.js → esm-Dz9jaRpU.js} +2 -2
  94. package/dist/assets/{esm-BbH0hS1N.js → esm-V1tlqL2D.js} +1 -1
  95. package/dist/assets/{fish-BRNsWqYt.js → fish-BwMcpOq4.js} +1 -1
  96. package/dist/assets/{flux-pWjywiqF.js → flux-oj70jMhY.js} +1 -1
  97. package/dist/assets/{grokvideo-Cm-G8voz.js → grokvideo-CzMcVOaG.js} +1 -1
  98. package/dist/assets/{hailuo-DLc9mi9Z.js → hailuo-Dzg72b34.js} +1 -1
  99. package/dist/assets/{headshots-CgmiyIxo.js → headshots-Byv5zvBI.js} +1 -1
  100. package/dist/assets/{image-6dfQOn5p.js → image-D9tSToP8.js} +1 -1
  101. package/dist/assets/{index-B6pXonqJ.js → index-CX3_OnAo.js} +3 -3
  102. package/dist/assets/{index.browser.esm-fb4Z38ry.js → index.browser.esm-Cdm1romJ.js} +1 -1
  103. package/dist/assets/{index.es-BzwAVtoA.js → index.es-CjjFtgN-.js} +1 -1
  104. package/dist/assets/{input-number-D6zTxbSb.js → input-number-DBMGiEqp.js} +1 -1
  105. package/dist/assets/{kling-BhyS0AFi.js → kling-CvAbwYOk.js} +1 -1
  106. package/dist/assets/{luma-dALcqrX0.js → luma-CDuNJN9T.js} +1 -1
  107. package/dist/assets/{maestro-gFOYBPSi.js → maestro-CGfCL58E.js} +1 -1
  108. package/dist/assets/{midjourney-BMsZHWaJ.js → midjourney-BUIixOOF.js} +1 -1
  109. package/dist/assets/{mobileLocalExec-BVLVwQEQ.js → mobileLocalExec-Bfq-w5Zi.js} +2 -2
  110. package/dist/assets/{nanobanana-DILsLTHR.js → nanobanana-Bqd5M6d8.js} +1 -1
  111. package/dist/assets/{openaiimage-Dys7INFS.js → openaiimage-BNfaWcao.js} +1 -1
  112. package/dist/assets/{pagination-BxtJiMbm.js → pagination-BAPL2vq4.js} +1 -1
  113. package/dist/assets/{pagination-BKoVpF5k.js → pagination-C8J0Gyal.js} +1 -1
  114. package/dist/assets/{pika-FUsOUPv7.js → pika-Cnp_SmBr.js} +1 -1
  115. package/dist/assets/{pixverse-BCfU3EO5.js → pixverse-CRii6LmX.js} +1 -1
  116. package/dist/assets/{popover-CJ7Vh-Z9.js → popover-CGIgLrtM.js} +1 -1
  117. package/dist/assets/{producer-CvW_L4R3.js → producer-CB7TEaKm.js} +1 -1
  118. package/dist/assets/{qrart-DM34yxOx.js → qrart-D6BPxlge.js} +1 -1
  119. package/dist/assets/{realtime-Y0Snsfju.js → realtime-ovrjN6Uw.js} +1 -1
  120. package/dist/assets/{row-B19sQ-lm.js → row-BKdThz-n.js} +1 -1
  121. package/dist/assets/{seedance-DZcKrUKg.js → seedance-BmDpYwbJ.js} +1 -1
  122. package/dist/assets/{seedream-Boek2uG0.js → seedream-DRgUXe2L.js} +1 -1
  123. package/dist/assets/{select--8g3iZ4i.js → select-PQ29yVWj.js} +1 -1
  124. package/dist/assets/{serp-E1PAZjzR.js → serp-DqVJbWVF.js} +1 -1
  125. package/dist/assets/{slider-Cpy0oxLQ.js → slider-CGRLYFT6.js} +1 -1
  126. package/dist/assets/{solana-wallets-DrJAlBcF.js → solana-wallets-Bozbciuk.js} +2 -2
  127. package/dist/assets/{solana-wallets-vue-DNyFHwOg.js → solana-wallets-vue-CfrA5KLq.js} +1 -1
  128. package/dist/assets/{sora-LLIazJQT.js → sora-DMoM6Z6N.js} +1 -1
  129. package/dist/assets/{suno-ConBAo4f.js → suno-CLLVNfsG.js} +1 -1
  130. package/dist/assets/{switch-BwiE8QKL.js → switch-BmKFU2Ps.js} +1 -1
  131. package/dist/assets/{table--5wRXM4l.js → table-Cp0ajFJK.js} +1 -1
  132. package/dist/assets/{tabs-Duhy_bLm.js → tabs-DE54U7Eq.js} +1 -1
  133. package/dist/assets/{time-picker-CgRok3Wx.js → time-picker-BnDUtCzj.js} +1 -1
  134. package/dist/assets/{tooltip-C-bMaCw_.js → tooltip-QN0TPRGq.js} +1 -1
  135. package/dist/assets/{upload-BkKRYGRZ.js → upload-CXzyNknv.js} +1 -1
  136. package/dist/assets/{veo-DwxCKH5G.js → veo-BLc6tSdD.js} +1 -1
  137. package/dist/assets/{wan-BsJrglg7.js → wan-CVSxmDB5.js} +1 -1
  138. package/dist/assets/{web-PR7t6IZM.js → web-CG1t8qMk.js} +1 -1
  139. package/dist/assets/{web-D9LGFwGb.js → web-DUAI6s8f.js} +1 -1
  140. package/dist/assets/{web-D2JTLU0Y.js → web-DYiPjaR6.js} +1 -1
  141. package/dist/assets/{web-CZYBKAOw.js → web-Dk5wXaDA.js} +1 -1
  142. package/dist/assets/{web-D7H3Mq6_.js → web-bpeF0a21.js} +1 -1
  143. package/dist/assets/{webextrator-YXXh68JR.js → webextrator-Bfq-unsQ.js} +1 -1
  144. package/dist/index.html +1 -1
  145. package/package.json +1 -1
  146. package/dist/assets/Extra-DWjOyYAU.css +0 -1
  147. package/dist/assets/esm-DRoSeCo9.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,mt as c,tt as l,z as u}from"./vendor-chart-Dw-P17PN.js";import{n as d,t as f}from"./table--5wRXM4l.js";import{t as p}from"./tooltip-C-bMaCw_.js";import{t as m}from"./card-D-4S-l7a.js";import{n as ee,t as h}from"./row-B19sQ-lm.js";import{t as g}from"./divider-BNWJAaA2.js";import{t as _}from"./progress-BfXLGwWW.js";import{t as v}from"./skeleton-CoheJz5x.js";import{G as y,Ii as b,Zt as x,bn as S,dr as C,ht as w,lr as T,pt as E,sn as D,ur as O,vr as k}from"./index-B6pXonqJ.js";import{t as A}from"./index.es-BzwAVtoA.js";import{t as j}from"./CopyToClipboard-DSUOjJxX.js";var M=u({name:`ConsoleDistributionList`,components:{CopyToClipboard:j,FontAwesomeIcon:A,QrCode:x,ElProgress:_,ElRow:h,ElCol:ee,ElButton:b,ElDivider:g,ElCard:m,ElTooltip:p,ElTable:f,ElTableColumn:d,ElSkeleton:v},data(){return{invitees:[],inviteesCount:void 0,distributionLevels:[],distributionLink:void 0,distributionStatus:void 0,loading:!1}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},qrColor(){let e=document.documentElement.classList.contains(`dark`);return{dark:e?`#ffffff`:`#000000`,light:e?`#1e1e1e`:`#ffffff`}},distributionLevelMap(){let e={};return this.distributionLevels.forEach(t=>{e[t.level]=t}),e}},watch:{page:{handler(){this.onFetchData()}}},async mounted(){this.onFetchData(),this.onGenerateDistributionLink()},methods:{getPriceString:D,goHistory(){this.$router.push({name:E})},goInvitees(){this.$router.push({name:w})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},getPercentageForNextLevel(){let e=this.distributionLevelMap[this.distributionStatus?.level?.level]?.threshold,t=this.distributionLevelMap[this.distributionStatus?.level?.level+1]?.threshold;return Math.floor((this.distributionStatus?.price-e)/(t-e)*100)},getDeltaForNextLevel(){let e=this.distributionLevelMap[this.distributionStatus?.level?.level+1]?.threshold;return Math.floor(e-this.distributionStatus?.price)},async onFetchData(){this.loading=!0,await O.initialize(),Promise.all([this.onFetchDistributionStatus(),this.onFetchDistributionLevels(),this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onGenerateDistributionLink(){let e=`${window.location.origin}?inviter_id=${this.$store.getters.user.id}`;try{let t=(await C.create(e))?.data?.data?.url||e;this.distributionLink=S()?t.replace(`surl.id`,`share.acedata.cloud`):t}catch{this.distributionLink=e}},async onFetchDistributionStatus(){let{data:e}=await O.getAll({user_id:this.$store.getters.user.id});e.items&&e.items.length>0&&(this.distributionStatus=e.items[0])},async onFetchDistributionLevels(){let{data:e}=await T.getAll({limit:20,user_id:this.$store.getters.user.id});this.distributionLevels=e.items},async onFetchInvitees(){let{data:e}=await k.getInvitees({});this.invitees=e.items,this.inviteesCount=e.count}}}),N={class:`title`},P={key:1},F={class:`icon-wrapper`},I={class:`text-left`},L={class:`description`},R={class:`value`},z={key:1},B={class:`icon-wrapper`},V={class:`text-left`},H={class:`description`},U={class:`value`},W={key:1},G={class:`icon-wrapper`},K={class:`text-left`},q={class:`description`},J={class:`value`},te={key:1},Y={class:`icon-wrapper`},X={class:`text-left`},Z={class:`description`},Q={class:`value`},ne={key:1},re={class:`title`},ie={class:`clear-both overflow-hidden`},ae={class:`float-left description`},oe={class:`float-right description`},se={class:`description`},ce={class:`level`},le={class:`level`},ue={class:`level`},de={key:1},fe={class:`title`},pe={class:`link-wrapper text-center`},$=[`href`],me={class:`qr-wrapper ml-auto mr-auto`},he={class:`mt-0`},ge={class:`description`},_e={class:`more`};function ve(u,d,f,p,m,ee){let h=o(`el-col`),g=o(`el-row`),_=o(`el-skeleton`),v=o(`font-awesome-icon`),y=o(`el-button`),b=o(`el-card`),x=o(`el-tooltip`),S=o(`el-progress`),C=o(`el-divider`),w=o(`el-table-column`),T=o(`el-table`),E=o(`copy-to-clipboard`),D=o(`qr-code`);return l(),s(g,{class:`panel`},{default:c(()=>[r(h,{span:24},{default:c(()=>[r(g,null,{default:c(()=>[r(h,{span:24},{default:c(()=>[e(`h2`,N,n(u.$t(`common.title.distribution`)),1)]),_:1})]),_:1}),r(g,{gutter:15},{default:c(()=>[r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,P,[e(`div`,F,[r(v,{icon:`fa-solid fa-wallet`,class:`icon`})]),e(`div`,I,[e(`p`,L,n(u.$t(`distribution.title.price`)),1),e(`p`,R,n(u.getPriceString({value:u.distributionStatus?.price})),1)]),r(y,{type:`primary`,round:``,size:`small`,class:`btn`,onClick:u.goHistory},{default:c(()=>[t(n(u.$t(`distribution.button.detail`)),1)]),_:1},8,[`onClick`])]))]),_:1})]),_:1}),r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,z,[e(`div`,B,[r(v,{icon:`fa-solid fa-coins`,class:`icon`})]),e(`div`,V,[e(`p`,H,n(u.$t(`distribution.title.reward`)),1),e(`p`,U,n(u.getPriceString({value:u.distributionStatus?.reward})),1)]),r(x,{effect:`dark`,content:u.$t(`distribution.message.developingWithDrawal`),placement:`top`},{default:c(()=>[r(y,{type:`primary`,round:``,size:`small`,class:`btn`},{default:c(()=>[t(n(u.$t(`distribution.button.withdrawal`)),1)]),_:1})]),_:1},8,[`content`])]))]),_:1})]),_:1}),r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,W,[e(`div`,G,[r(v,{icon:`fa-solid fa-percent`,class:`icon`})]),e(`div`,K,[e(`p`,q,n(u.$t(`distribution.title.percentage`)),1),e(`p`,J,n(u.distributionStatus?.level?.percentage)+`%`,1)])]))]),_:1})]),_:1}),r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,te,[e(`div`,Y,[r(v,{icon:`fa-regular fa-user`,class:`icon`})]),e(`div`,X,[e(`p`,Z,n(u.$t(`distribution.title.inviteesCount`)),1),e(`p`,Q,n(u.inviteesCount),1)]),r(y,{type:`primary`,round:``,size:`small`,class:`btn`,onClick:u.goInvitees},{default:c(()=>[t(n(u.$t(`distribution.button.detail`)),1)]),_:1},8,[`onClick`])]))]),_:1})]),_:1})]),_:1}),r(g,{gutter:15},{default:c(()=>[r(h,{md:12,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`level-info mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,ne,[e(`h4`,re,n(u.$t(`distribution.title.levelInfo`)),1),e(`div`,ie,[e(`div`,ae,[e(`p`,null,n(u.$t(`distribution.title.currentLevel`))+`: L`+n(u.distributionStatus?.level?.level),1),e(`p`,null,n(u.$t(`distribution.title.currentPercentage`))+`: `+n(u.distributionLevelMap[u.distributionStatus?.level?.level]?.percentage)+`% `,1)]),e(`div`,oe,[e(`p`,null,n(u.$t(`distribution.title.nextLevel`))+`: L`+n(u.distributionStatus?.level?.level+1),1),e(`p`,null,n(u.$t(`distribution.title.nextPercentage`))+`: `+n(u.distributionLevelMap[u.distributionStatus?.level?.level+1]?.percentage)+`% `,1)])]),r(S,{"text-inside":!0,"stroke-width":20,percentage:u.getPercentageForNextLevel(),class:`mb-2`},null,8,[`percentage`]),e(`p`,se,n(u.$t(`distribution.message.deltaPriceForNextLevel`))+`: $`+n(u.getDeltaForNextLevel()),1),r(C),u.distributionLevels?(l(),s(T,{key:0,data:u.distributionLevels,stripe:``},{default:c(()=>[r(w,{label:u.$t(`distribution.field.level`)},{default:c(t=>[e(`span`,ce,`L`+n(t.row?.level),1)]),_:1},8,[`label`]),r(w,{label:u.$t(`distribution.field.threshold`)},{default:c(t=>[e(`span`,le,`$`+n(t.row?.threshold),1)]),_:1},8,[`label`]),r(w,{label:u.$t(`distribution.field.percentage`)},{default:c(t=>[e(`span`,ue,n(t.row?.percentage)+`%`,1)]),_:1},8,[`label`])]),_:1},8,[`data`])):i(``,!0)]))]),_:1})]),_:1}),r(h,{md:12,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`distribution-info mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,de,[e(`h4`,fe,n(u.$t(`distribution.title.distributionLink`)),1),r(C),e(`div`,pe,[i(``,!0),e(`a`,{href:u.distributionLink,class:`link`},n(u.distributionLink),9,$),r(E,{content:u.distributionLink},null,8,[`content`])]),e(`div`,me,[u.distributionLink?(l(),s(D,{key:0,value:u.distributionLink,size:180,margin:2,class:`block mb-2 ml-auto mr-auto`,type:`image/png`,color:u.qrColor},null,8,[`value`,`color`])):i(``,!0),e(`p`,he,n(u.$t(`distribution.message.distributionQrDescription`)),1)]),e(`p`,ge,[t(n(u.$t(`distribution.message.distributionLinkDescription`))+` `,1),e(`span`,_e,[r(x,{effect:`dark`,content:u.$t(`distribution.message.distributionLinkDescription2`),placement:`top`},{default:c(()=>[t(n(u.$t(`distribution.message.technicalDetail`)),1)]),_:1},8,[`content`])])])]))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}var ye=y(M,[[`render`,ve],[`__scopeId`,`data-v-cb452d37`]]);export{ye as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,mt as c,tt as l,z as u}from"./vendor-chart-Dw-P17PN.js";import{n as d,t as f}from"./table-Cp0ajFJK.js";import{t as p}from"./tooltip-QN0TPRGq.js";import{t as m}from"./card-D-4S-l7a.js";import{n as ee,t as h}from"./row-BKdThz-n.js";import{t as g}from"./divider-BNWJAaA2.js";import{t as _}from"./progress-BfXLGwWW.js";import{t as v}from"./skeleton-CoheJz5x.js";import{G as y,Ii as b,Zt as x,bn as S,dr as C,ht as w,lr as T,pt as E,sn as D,ur as O,vr as k}from"./index-CX3_OnAo.js";import{t as A}from"./index.es-CjjFtgN-.js";import{t as j}from"./CopyToClipboard-C5rXbm0J.js";var M=u({name:`ConsoleDistributionList`,components:{CopyToClipboard:j,FontAwesomeIcon:A,QrCode:x,ElProgress:_,ElRow:h,ElCol:ee,ElButton:b,ElDivider:g,ElCard:m,ElTooltip:p,ElTable:f,ElTableColumn:d,ElSkeleton:v},data(){return{invitees:[],inviteesCount:void 0,distributionLevels:[],distributionLink:void 0,distributionStatus:void 0,loading:!1}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},qrColor(){let e=document.documentElement.classList.contains(`dark`);return{dark:e?`#ffffff`:`#000000`,light:e?`#1e1e1e`:`#ffffff`}},distributionLevelMap(){let e={};return this.distributionLevels.forEach(t=>{e[t.level]=t}),e}},watch:{page:{handler(){this.onFetchData()}}},async mounted(){this.onFetchData(),this.onGenerateDistributionLink()},methods:{getPriceString:D,goHistory(){this.$router.push({name:E})},goInvitees(){this.$router.push({name:w})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},getPercentageForNextLevel(){let e=this.distributionLevelMap[this.distributionStatus?.level?.level]?.threshold,t=this.distributionLevelMap[this.distributionStatus?.level?.level+1]?.threshold;return Math.floor((this.distributionStatus?.price-e)/(t-e)*100)},getDeltaForNextLevel(){let e=this.distributionLevelMap[this.distributionStatus?.level?.level+1]?.threshold;return Math.floor(e-this.distributionStatus?.price)},async onFetchData(){this.loading=!0,await O.initialize(),Promise.all([this.onFetchDistributionStatus(),this.onFetchDistributionLevels(),this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onGenerateDistributionLink(){let e=`${window.location.origin}?inviter_id=${this.$store.getters.user.id}`;try{let t=(await C.create(e))?.data?.data?.url||e;this.distributionLink=S()?t.replace(`surl.id`,`share.acedata.cloud`):t}catch{this.distributionLink=e}},async onFetchDistributionStatus(){let{data:e}=await O.getAll({user_id:this.$store.getters.user.id});e.items&&e.items.length>0&&(this.distributionStatus=e.items[0])},async onFetchDistributionLevels(){let{data:e}=await T.getAll({limit:20,user_id:this.$store.getters.user.id});this.distributionLevels=e.items},async onFetchInvitees(){let{data:e}=await k.getInvitees({});this.invitees=e.items,this.inviteesCount=e.count}}}),N={class:`title`},P={key:1},F={class:`icon-wrapper`},I={class:`text-left`},L={class:`description`},R={class:`value`},z={key:1},B={class:`icon-wrapper`},V={class:`text-left`},H={class:`description`},U={class:`value`},W={key:1},G={class:`icon-wrapper`},K={class:`text-left`},q={class:`description`},J={class:`value`},te={key:1},Y={class:`icon-wrapper`},X={class:`text-left`},Z={class:`description`},Q={class:`value`},ne={key:1},re={class:`title`},ie={class:`clear-both overflow-hidden`},ae={class:`float-left description`},oe={class:`float-right description`},se={class:`description`},ce={class:`level`},le={class:`level`},ue={class:`level`},de={key:1},fe={class:`title`},pe={class:`link-wrapper text-center`},$=[`href`],me={class:`qr-wrapper ml-auto mr-auto`},he={class:`mt-0`},ge={class:`description`},_e={class:`more`};function ve(u,d,f,p,m,ee){let h=o(`el-col`),g=o(`el-row`),_=o(`el-skeleton`),v=o(`font-awesome-icon`),y=o(`el-button`),b=o(`el-card`),x=o(`el-tooltip`),S=o(`el-progress`),C=o(`el-divider`),w=o(`el-table-column`),T=o(`el-table`),E=o(`copy-to-clipboard`),D=o(`qr-code`);return l(),s(g,{class:`panel`},{default:c(()=>[r(h,{span:24},{default:c(()=>[r(g,null,{default:c(()=>[r(h,{span:24},{default:c(()=>[e(`h2`,N,n(u.$t(`common.title.distribution`)),1)]),_:1})]),_:1}),r(g,{gutter:15},{default:c(()=>[r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,P,[e(`div`,F,[r(v,{icon:`fa-solid fa-wallet`,class:`icon`})]),e(`div`,I,[e(`p`,L,n(u.$t(`distribution.title.price`)),1),e(`p`,R,n(u.getPriceString({value:u.distributionStatus?.price})),1)]),r(y,{type:`primary`,round:``,size:`small`,class:`btn`,onClick:u.goHistory},{default:c(()=>[t(n(u.$t(`distribution.button.detail`)),1)]),_:1},8,[`onClick`])]))]),_:1})]),_:1}),r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,z,[e(`div`,B,[r(v,{icon:`fa-solid fa-coins`,class:`icon`})]),e(`div`,V,[e(`p`,H,n(u.$t(`distribution.title.reward`)),1),e(`p`,U,n(u.getPriceString({value:u.distributionStatus?.reward})),1)]),r(x,{effect:`dark`,content:u.$t(`distribution.message.developingWithDrawal`),placement:`top`},{default:c(()=>[r(y,{type:`primary`,round:``,size:`small`,class:`btn`},{default:c(()=>[t(n(u.$t(`distribution.button.withdrawal`)),1)]),_:1})]),_:1},8,[`content`])]))]),_:1})]),_:1}),r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,W,[e(`div`,G,[r(v,{icon:`fa-solid fa-percent`,class:`icon`})]),e(`div`,K,[e(`p`,q,n(u.$t(`distribution.title.percentage`)),1),e(`p`,J,n(u.distributionStatus?.level?.percentage)+`%`,1)])]))]),_:1})]),_:1}),r(h,{md:6,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`item-mini mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,te,[e(`div`,Y,[r(v,{icon:`fa-regular fa-user`,class:`icon`})]),e(`div`,X,[e(`p`,Z,n(u.$t(`distribution.title.inviteesCount`)),1),e(`p`,Q,n(u.inviteesCount),1)]),r(y,{type:`primary`,round:``,size:`small`,class:`btn`,onClick:u.goInvitees},{default:c(()=>[t(n(u.$t(`distribution.button.detail`)),1)]),_:1},8,[`onClick`])]))]),_:1})]),_:1})]),_:1}),r(g,{gutter:15},{default:c(()=>[r(h,{md:12,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`level-info mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,ne,[e(`h4`,re,n(u.$t(`distribution.title.levelInfo`)),1),e(`div`,ie,[e(`div`,ae,[e(`p`,null,n(u.$t(`distribution.title.currentLevel`))+`: L`+n(u.distributionStatus?.level?.level),1),e(`p`,null,n(u.$t(`distribution.title.currentPercentage`))+`: `+n(u.distributionLevelMap[u.distributionStatus?.level?.level]?.percentage)+`% `,1)]),e(`div`,oe,[e(`p`,null,n(u.$t(`distribution.title.nextLevel`))+`: L`+n(u.distributionStatus?.level?.level+1),1),e(`p`,null,n(u.$t(`distribution.title.nextPercentage`))+`: `+n(u.distributionLevelMap[u.distributionStatus?.level?.level+1]?.percentage)+`% `,1)])]),r(S,{"text-inside":!0,"stroke-width":20,percentage:u.getPercentageForNextLevel(),class:`mb-2`},null,8,[`percentage`]),e(`p`,se,n(u.$t(`distribution.message.deltaPriceForNextLevel`))+`: $`+n(u.getDeltaForNextLevel()),1),r(C),u.distributionLevels?(l(),s(T,{key:0,data:u.distributionLevels,stripe:``},{default:c(()=>[r(w,{label:u.$t(`distribution.field.level`)},{default:c(t=>[e(`span`,ce,`L`+n(t.row?.level),1)]),_:1},8,[`label`]),r(w,{label:u.$t(`distribution.field.threshold`)},{default:c(t=>[e(`span`,le,`$`+n(t.row?.threshold),1)]),_:1},8,[`label`]),r(w,{label:u.$t(`distribution.field.percentage`)},{default:c(t=>[e(`span`,ue,n(t.row?.percentage)+`%`,1)]),_:1},8,[`label`])]),_:1},8,[`data`])):i(``,!0)]))]),_:1})]),_:1}),r(h,{md:12,xs:24},{default:c(()=>[r(b,{shadow:`hover`,class:`distribution-info mb-4`},{default:c(()=>[u.loading?(l(),s(_,{key:0})):(l(),a(`div`,de,[e(`h4`,fe,n(u.$t(`distribution.title.distributionLink`)),1),r(C),e(`div`,pe,[i(``,!0),e(`a`,{href:u.distributionLink,class:`link`},n(u.distributionLink),9,$),r(E,{content:u.distributionLink},null,8,[`content`])]),e(`div`,me,[u.distributionLink?(l(),s(D,{key:0,value:u.distributionLink,size:180,margin:2,class:`block mb-2 ml-auto mr-auto`,type:`image/png`,color:u.qrColor},null,8,[`value`,`color`])):i(``,!0),e(`p`,he,n(u.$t(`distribution.message.distributionQrDescription`)),1)]),e(`p`,ge,[t(n(u.$t(`distribution.message.distributionLinkDescription`))+` `,1),e(`span`,_e,[r(x,{effect:`dark`,content:u.$t(`distribution.message.distributionLinkDescription2`),placement:`top`},{default:c(()=>[t(n(u.$t(`distribution.message.technicalDetail`)),1)]),_:1},8,[`content`])])])]))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}var ye=y(M,[[`render`,ve],[`__scopeId`,`data-v-cb452d37`]]);export{ye as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,j as u,mt as d,rt as f,tt as p,z as m}from"./vendor-chart-Dw-P17PN.js";import{r as h,t as g}from"./select--8g3iZ4i.js";import{t as _}from"./upload-BkKRYGRZ.js";import{t as v}from"./tooltip-C-bMaCw_.js";import{t as y}from"./image-6dfQOn5p.js";import{t as b}from"./alert-Dpx0Wsp2.js";import{Kn as x}from"./constants-BjP62jX_.js";import{G as S,Ii as C,Ti as w,Tr as ee,Yn as T,di as E,hn as te,in as D,mi as O,nn as k,on as A,rn as j,tn as M}from"./index-B6pXonqJ.js";import{t as N}from"./index.es-BzwAVtoA.js";import{t as P}from"./CopyToClipboard-DSUOjJxX.js";import{t as F}from"./ImagePreview-CXNjM0lL.js";import{t as I}from"./Consumption-BKrS2kBX.js";import{i as L,n as R,t as z}from"./pagination-BKoVpF5k.js";import{t as B}from"./VideoPlayer-DaDRABrK.js";import{t as V}from"./ApiCodeButton-C8uFIxln.js";import{t as H}from"./BotPlaceholder-CB9iZVnJ.js";import{t as U}from"./NoTasks-C_nRAzj6.js";import{t as W}from"./Hailuo-ug4RP5On.js";import{t as G}from"./PromptTextarea-BlwckA3Q.js";var K=m({name:`ModelSelector`,components:{ElSelect:h,ElOption:g},data(){return{}},computed:{options(){return[{value:`minimax-t2v`,label:this.$t(`hailuo.button.model1`)},{value:`minimax-i2v`,label:this.$t(`hailuo.button.model2`)},{value:`minimax-i2v-director`,label:this.$t(`hailuo.button.model3`)}]},value:{get(){return this.$store.state.hailuo?.config?.model},set(e){this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,model:e})}}},mounted(){this.value||=x}}),q={class:`field`},J={class:`title font-bold`},Y={class:`float-left`};function X(t,n,r,o,m,h){let g=l(`el-option`),_=l(`el-select`);return p(),s(`div`,q,[e(`h2`,J,i(t.$t(`hailuo.name.model`)),1),a(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`hailuo.placeholder.select`),clearable:``},{default:d(()=>[(p(!0),s(c,null,f(t.options,t=>(p(),u(g,{key:t.value,label:t.label,value:t.value},{default:d(()=>[e(`span`,Y,i(t.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Z=S(K,[[`render`,X],[`__scopeId`,`data-v-a768fbd9`]]),Q=m({name:`StartImageUrlInput`,components:{ElUpload:_,ElButton:C,InfoIcon:L,ImagePreview:F},mixins:[D,k],data(){return{fileList:[],uploadUrl:O()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e.url).filter(e=>e!==void 0)},value:{get(){return this.$store.state.hailuo?.config?.first_image_url},set(){let e=this.urls?.[0];this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,first_image_url:e})}}},mounted(){this.value||=void 0,this.onSetStartImageUrl()},methods:{onExceed(){w.warning(this.$t(`hailuo.message.uploadStartImageExceed`))},onError(){w.error(this.$t(`hailuo.message.uploadStartImageError`))},async onRemove(){w.error(this.$t(`hailuo.message.uploadStartImageError`))},onSetStartImageUrl(){let e=this.urls?.[0];this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,first_image_url:e})},async onSuccess(){this.onSetStartImageUrl()}}}),ne={class:`relative`},re={class:`flex justify-between`},ie={class:`flex justify-start items-center`},ae={class:`text-sm font-bold`};function oe(t,n,c,f,m,h){let g=l(`info-icon`),_=l(`image-preview`),v=l(`el-button`),y=l(`el-upload`);return p(),s(`div`,ne,[e(`div`,re,[e(`div`,ie,[e(`span`,ae,i(t.$t(`hailuo.name.startImageUrl`)),1),a(g,{content:t.$t(`hailuo.description.startImageUrl`),class:`info`},null,8,[`content`])])]),a(y,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,name:`file`,"show-file-list":!0,limit:1,multiple:!1,"list-type":`picture`,action:t.uploadUrl,"on-exceed":t.onExceed,"on-error":t.onError,"on-remove":t.onRemove,"on-success":t.onSuccess,headers:t.headers},{file:d(({file:e})=>[e.url&&e.percentage!==void 0?(p(),u(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:d(()=>[a(v,{size:`small`,type:`primary`,class:`btn btn-upload`,round:``},{default:d(()=>[r(i(t.$t(`hailuo.button.uploadStartImageUrl`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-remove`,`on-success`,`headers`])])}var se=S(Q,[[`render`,oe],[`__scopeId`,`data-v-fbf49b06`]]),ce=m({name:`PromptInput`,components:{PromptTextarea:G},computed:{prompt:{get(){return this.$store.state.hailuo?.config?.prompt},set(e){this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function le(e,t,n,r,i,a){let o=l(`prompt-textarea`);return p(),u(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`hailuo.name.prompt`),info:e.$t(`hailuo.description.prompt`),placeholder:e.$t(`hailuo.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var ue=m({name:`PresetPanel`,components:{ElButton:C,FontAwesomeIcon:N,PromptInput:S(ce,[[`render`,le]]),StartImageUrlInput:se,ModelSelector:Z,Consumption:I},emits:[`generate`],computed:{config(){return this.$store.state.hailuo?.config},consumption(){return A(this.config,this.service?.cost)},service(){return this.$store.state.hailuo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),de={class:`flex flex-col h-full`},fe={class:`flex-1 overflow-y-auto p-5`},pe={class:`flex flex-col items-center justify-center px-5 pb-5`};function me(t,n,c,f,m,h){let g=l(`prompt-input`),_=l(`model-selector`),v=l(`start-image-url-input`),y=l(`consumption`),b=l(`font-awesome-icon`),x=l(`el-button`);return p(),s(`div`,de,[e(`div`,fe,[a(g,{class:`mb-4`}),a(_,{class:`mb-4`}),t.config?.model===`minimax-i2v`?(p(),u(v,{key:0,class:`mb-2`})):o(``,!0)]),e(`div`,pe,[a(y,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),t.config?.video_url!==void 0||t.config?.custom?(p(),u(x,{key:0,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:d(()=>[a(b,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`hailuo.button.extend`)),1)]),_:1},8,[`onClick`])):(p(),u(x,{key:1,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:d(()=>[a(b,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`hailuo.button.generate`)),1)]),_:1},8,[`onClick`]))])])}var he=S(ue,[[`render`,me]]),ge=m({name:`TaskPreview`,components:{ElImage:y,CopyToClipboard:P,FontAwesomeIcon:N,ElAlert:b,VideoPlayer:B,ElTooltip:v,ElButton:C,ApiCodeButton:V},props:{modelValue:{type:Object,required:!0}},computed:{application(){return this.$store.state.hailuo?.application},config(){return this.$store.state.hailuo?.config},video(){return this.modelValue?.response?.data?.[0]}},methods:{onDownload(e){console.debug(`on download hailuo video`,e),window.open(e,`_blank`)}}}),_e={class:`preview`},ve={class:`left`},ye={class:`main`},be={class:`bot`},xe={class:`datetime`},Se={class:`info`},Ce={key:0,class:`prompt mt-2`},we={key:0},Te={key:1},Ee={key:0,class:n({content:!0,failed:!0})},De={key:0,class:`mb-4`},Oe={key:1,class:n({operations:!0,"mt-2":!0})},ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ae={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},je={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Me={key:1,class:n({content:!0})},Ne={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Pe={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Fe={class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ie={key:2,class:n({content:!0})},Le={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Re(n,c,f,m,h,g){let _=l(`el-image`),v=l(`video-player`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`api-code-button`),S=l(`font-awesome-icon`),C=l(`copy-to-clipboard`),w=l(`el-alert`);return p(),s(`div`,_e,[e(`div`,ve,[a(_,{src:`https://cdn.acedata.cloud/0qg4gp.png`,class:`avatar`})]),e(`div`,ye,[e(`div`,be,[r(i(n.$t(`hailuo.name.hailuoBot`))+` `,1),e(`span`,xe,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,Se,[n.modelValue?.request?.prompt?(p(),s(`p`,Ce,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?o(``,!0):(p(),s(`span`,we,` - (`+i(n.$t(`hailuo.status.pending`))+`) `,1)),n.video?.state===`processing`||n.video?.state===`pending`||n.video?.state===`running`?(p(),s(`span`,Te,` - (`+i(n.$t(`hailuo.status.processing`))+`) `,1)):o(``,!0)])):o(``,!0)]),n.modelValue?.response?.success===!0?(p(),s(`div`,Ee,[n.video?.video_url?(p(),s(`div`,De,[a(v,{src:n.video?.video_url},null,8,[`src`])])):o(``,!0),n.video?(p(),s(`div`,Oe,[a(b,{class:`box-item`,effect:`dark`,content:n.$t(`hailuo.message.downloadVideo`),placement:`top-start`},{default:d(()=>[n.video?.video_url?(p(),u(y,{key:0,type:`info`,size:`small`,class:`mb-2`,onClick:c[0]||=t(e=>n.onDownload(n.video?.video_url),[`stop`])},{default:d(()=>[r(i(n.$t(`hailuo.button.download`)),1)]),_:1})):o(``,!0)]),_:1},8,[`content`]),a(x,{path:`/hailuo/videos`,body:n.modelValue?.request},null,8,[`body`])])):o(``,!0),a(w,{closable:!1,class:`mt-2 success`},{default:d(()=>[n.modelValue?.request?.model?(p(),s(`p`,ke,[a(S,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.model`))+`: `+i(n.modelValue?.request?.model)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])])):o(``,!0),e(`p`,Ae,[a(S,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])]),n.modelValue?.elapsed?(p(),s(`p`,je,[a(S,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0)]),_:1})])):o(``,!0),n.modelValue?.response?.success===!1?(p(),s(`div`,Me,[a(w,{closable:!1,class:`failure`},{template:d(()=>[a(S,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Ne,[a(S,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])]),e(`p`,Pe,[a(S,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.failureReason`))+`: `+i(n.modelValue?.response?.error?.message)+` `,1),a(C,{content:n.modelValue?.response?.error?.message},null,8,[`content`])]),n.modelValue?.elapsed?(p(),s(`p`,$,[a(S,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),e(`p`,Fe,[a(S,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(C,{content:n.modelValue?.response?.trace_id},null,8,[`content`])])]),_:1})])):o(``,!0),n.modelValue?.response?.success===void 0?(p(),s(`div`,Ie,[a(w,{closable:!1,class:`info`},{template:d(()=>[a(S,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Le,[a(S,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])])]),_:1})])):o(``,!0)])])}var ze=m({name:`RecentPanel`,components:{TaskPreview:S(ge,[[`render`,Re],[`__scopeId`,`data-v-53d13da4`]]),BotPlaceholder:H,NoTasks:U,ScrollList:R},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.hailuo?.tasks,items:this.$store.state.hailuo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Be={key:0},Ve={key:2,class:`w-full h-full flex items-center justify-center`};function He(e,t,n,r,i,m){let h=l(`bot-placeholder`),g=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return p(),s(c,null,[e.tasks?.items===void 0?(p(),s(`div`,Be,[a(h)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(p(),u(_,{key:1,ref:`scrollList`,class:`tasks w-full h-full overflow-y-auto`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:d(()=>[(p(!0),s(c,null,f(e.tasks?.items,e=>(p(),u(g,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(p(),s(`div`,Ve,[a(v)])):o(``,!0)],64)}var Ue=m({name:`HailuoIndex`,components:{ConfigPanel:he,Layout:W,RecentPanel:S(ze,[[`render`,He]])},mixins:[j],inject:[`initialized`],data(){return{task:void 0,job:0,timer:void 0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.hailuo?.status?.getApplications===E.Request},tasksLoading(){return this.$store.state.hailuo?.status?.getTasks===E.Request||this.fetchingTasks},credential(){return this.$store.state.hailuo.credential},config(){return this.$store.state.hailuo.config},application(){return this.$store.state.hailuo.application},tasks(){return this.$store.state.hailuo.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 z({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(`hailuo/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`hailuo/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(`hailuo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!M(this.uploadTracker,e=>this.$t(e),e=>w.warning(e)))return;let e={...this.config,async:!0};if(!te())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}w.info(this.$t(`hailuo.message.startingTask`)),ee(`hailuo`,T.generate(e,{token:t})).then(()=>{w.success(this.$t(`hailuo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?w.error(this.$t(`hailuo.message.usedUp`)):w.error(this.$t(`hailuo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function We(e,t,n,r,i,o){let s=l(`config-panel`),c=l(`recent-panel`),f=l(`layout`);return p(),u(f,null,{config:d(()=>[a(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:d(()=>[a(c,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var Ge=S(Ue,[[`render`,We]]);export{Ge as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,j as u,mt as d,rt as f,tt as p,z as m}from"./vendor-chart-Dw-P17PN.js";import{r as h,t as g}from"./select-PQ29yVWj.js";import{t as _}from"./upload-CXzyNknv.js";import{t as v}from"./tooltip-QN0TPRGq.js";import{t as y}from"./image-D9tSToP8.js";import{t as b}from"./alert-DejBSzEr.js";import{Kn as x}from"./constants-BjP62jX_.js";import{G as S,Ii as C,Ti as w,Tr as ee,Yn as T,di as E,hn as te,in as D,mi as O,nn as k,on as A,rn as j,tn as M}from"./index-CX3_OnAo.js";import{t as N}from"./index.es-CjjFtgN-.js";import{t as P}from"./CopyToClipboard-C5rXbm0J.js";import{t as F}from"./ImagePreview-NSygfR7g.js";import{t as I}from"./Consumption-Bf7XwbiV.js";import{i as L,n as R,t as z}from"./pagination-C8J0Gyal.js";import{t as B}from"./VideoPlayer-BNndMZsO.js";import{t as V}from"./ApiCodeButton-Doj0G2Ua.js";import{t as H}from"./BotPlaceholder-Cd4ngCBY.js";import{t as U}from"./NoTasks-CHXTr4XZ.js";import{t as W}from"./Hailuo-7OwLRaCQ.js";import{t as G}from"./PromptTextarea-CULk8zG8.js";var K=m({name:`ModelSelector`,components:{ElSelect:h,ElOption:g},data(){return{}},computed:{options(){return[{value:`minimax-t2v`,label:this.$t(`hailuo.button.model1`)},{value:`minimax-i2v`,label:this.$t(`hailuo.button.model2`)},{value:`minimax-i2v-director`,label:this.$t(`hailuo.button.model3`)}]},value:{get(){return this.$store.state.hailuo?.config?.model},set(e){this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,model:e})}}},mounted(){this.value||=x}}),q={class:`field`},J={class:`title font-bold`},Y={class:`float-left`};function X(t,n,r,o,m,h){let g=l(`el-option`),_=l(`el-select`);return p(),s(`div`,q,[e(`h2`,J,i(t.$t(`hailuo.name.model`)),1),a(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`hailuo.placeholder.select`),clearable:``},{default:d(()=>[(p(!0),s(c,null,f(t.options,t=>(p(),u(g,{key:t.value,label:t.label,value:t.value},{default:d(()=>[e(`span`,Y,i(t.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Z=S(K,[[`render`,X],[`__scopeId`,`data-v-a768fbd9`]]),Q=m({name:`StartImageUrlInput`,components:{ElUpload:_,ElButton:C,InfoIcon:L,ImagePreview:F},mixins:[D,k],data(){return{fileList:[],uploadUrl:O()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e.url).filter(e=>e!==void 0)},value:{get(){return this.$store.state.hailuo?.config?.first_image_url},set(){let e=this.urls?.[0];this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,first_image_url:e})}}},mounted(){this.value||=void 0,this.onSetStartImageUrl()},methods:{onExceed(){w.warning(this.$t(`hailuo.message.uploadStartImageExceed`))},onError(){w.error(this.$t(`hailuo.message.uploadStartImageError`))},async onRemove(){w.error(this.$t(`hailuo.message.uploadStartImageError`))},onSetStartImageUrl(){let e=this.urls?.[0];this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,first_image_url:e})},async onSuccess(){this.onSetStartImageUrl()}}}),ne={class:`relative`},re={class:`flex justify-between`},ie={class:`flex justify-start items-center`},ae={class:`text-sm font-bold`};function oe(t,n,c,f,m,h){let g=l(`info-icon`),_=l(`image-preview`),v=l(`el-button`),y=l(`el-upload`);return p(),s(`div`,ne,[e(`div`,re,[e(`div`,ie,[e(`span`,ae,i(t.$t(`hailuo.name.startImageUrl`)),1),a(g,{content:t.$t(`hailuo.description.startImageUrl`),class:`info`},null,8,[`content`])])]),a(y,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,name:`file`,"show-file-list":!0,limit:1,multiple:!1,"list-type":`picture`,action:t.uploadUrl,"on-exceed":t.onExceed,"on-error":t.onError,"on-remove":t.onRemove,"on-success":t.onSuccess,headers:t.headers},{file:d(({file:e})=>[e.url&&e.percentage!==void 0?(p(),u(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:d(()=>[a(v,{size:`small`,type:`primary`,class:`btn btn-upload`,round:``},{default:d(()=>[r(i(t.$t(`hailuo.button.uploadStartImageUrl`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-remove`,`on-success`,`headers`])])}var se=S(Q,[[`render`,oe],[`__scopeId`,`data-v-fbf49b06`]]),ce=m({name:`PromptInput`,components:{PromptTextarea:G},computed:{prompt:{get(){return this.$store.state.hailuo?.config?.prompt},set(e){this.$store.commit(`hailuo/setConfig`,{...this.$store.state.hailuo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function le(e,t,n,r,i,a){let o=l(`prompt-textarea`);return p(),u(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`hailuo.name.prompt`),info:e.$t(`hailuo.description.prompt`),placeholder:e.$t(`hailuo.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var ue=m({name:`PresetPanel`,components:{ElButton:C,FontAwesomeIcon:N,PromptInput:S(ce,[[`render`,le]]),StartImageUrlInput:se,ModelSelector:Z,Consumption:I},emits:[`generate`],computed:{config(){return this.$store.state.hailuo?.config},consumption(){return A(this.config,this.service?.cost)},service(){return this.$store.state.hailuo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),de={class:`flex flex-col h-full`},fe={class:`flex-1 overflow-y-auto p-5`},pe={class:`flex flex-col items-center justify-center px-5 pb-5`};function me(t,n,c,f,m,h){let g=l(`prompt-input`),_=l(`model-selector`),v=l(`start-image-url-input`),y=l(`consumption`),b=l(`font-awesome-icon`),x=l(`el-button`);return p(),s(`div`,de,[e(`div`,fe,[a(g,{class:`mb-4`}),a(_,{class:`mb-4`}),t.config?.model===`minimax-i2v`?(p(),u(v,{key:0,class:`mb-2`})):o(``,!0)]),e(`div`,pe,[a(y,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),t.config?.video_url!==void 0||t.config?.custom?(p(),u(x,{key:0,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:d(()=>[a(b,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`hailuo.button.extend`)),1)]),_:1},8,[`onClick`])):(p(),u(x,{key:1,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:d(()=>[a(b,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`hailuo.button.generate`)),1)]),_:1},8,[`onClick`]))])])}var he=S(ue,[[`render`,me]]),ge=m({name:`TaskPreview`,components:{ElImage:y,CopyToClipboard:P,FontAwesomeIcon:N,ElAlert:b,VideoPlayer:B,ElTooltip:v,ElButton:C,ApiCodeButton:V},props:{modelValue:{type:Object,required:!0}},computed:{application(){return this.$store.state.hailuo?.application},config(){return this.$store.state.hailuo?.config},video(){return this.modelValue?.response?.data?.[0]}},methods:{onDownload(e){console.debug(`on download hailuo video`,e),window.open(e,`_blank`)}}}),_e={class:`preview`},ve={class:`left`},ye={class:`main`},be={class:`bot`},xe={class:`datetime`},Se={class:`info`},Ce={key:0,class:`prompt mt-2`},we={key:0},Te={key:1},Ee={key:0,class:n({content:!0,failed:!0})},De={key:0,class:`mb-4`},Oe={key:1,class:n({operations:!0,"mt-2":!0})},ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ae={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},je={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Me={key:1,class:n({content:!0})},Ne={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Pe={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Fe={class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ie={key:2,class:n({content:!0})},Le={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Re(n,c,f,m,h,g){let _=l(`el-image`),v=l(`video-player`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`api-code-button`),S=l(`font-awesome-icon`),C=l(`copy-to-clipboard`),w=l(`el-alert`);return p(),s(`div`,_e,[e(`div`,ve,[a(_,{src:`https://cdn.acedata.cloud/0qg4gp.png`,class:`avatar`})]),e(`div`,ye,[e(`div`,be,[r(i(n.$t(`hailuo.name.hailuoBot`))+` `,1),e(`span`,xe,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,Se,[n.modelValue?.request?.prompt?(p(),s(`p`,Ce,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?o(``,!0):(p(),s(`span`,we,` - (`+i(n.$t(`hailuo.status.pending`))+`) `,1)),n.video?.state===`processing`||n.video?.state===`pending`||n.video?.state===`running`?(p(),s(`span`,Te,` - (`+i(n.$t(`hailuo.status.processing`))+`) `,1)):o(``,!0)])):o(``,!0)]),n.modelValue?.response?.success===!0?(p(),s(`div`,Ee,[n.video?.video_url?(p(),s(`div`,De,[a(v,{src:n.video?.video_url},null,8,[`src`])])):o(``,!0),n.video?(p(),s(`div`,Oe,[a(b,{class:`box-item`,effect:`dark`,content:n.$t(`hailuo.message.downloadVideo`),placement:`top-start`},{default:d(()=>[n.video?.video_url?(p(),u(y,{key:0,type:`info`,size:`small`,class:`mb-2`,onClick:c[0]||=t(e=>n.onDownload(n.video?.video_url),[`stop`])},{default:d(()=>[r(i(n.$t(`hailuo.button.download`)),1)]),_:1})):o(``,!0)]),_:1},8,[`content`]),a(x,{path:`/hailuo/videos`,body:n.modelValue?.request},null,8,[`body`])])):o(``,!0),a(w,{closable:!1,class:`mt-2 success`},{default:d(()=>[n.modelValue?.request?.model?(p(),s(`p`,ke,[a(S,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.model`))+`: `+i(n.modelValue?.request?.model)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])])):o(``,!0),e(`p`,Ae,[a(S,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])]),n.modelValue?.elapsed?(p(),s(`p`,je,[a(S,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0)]),_:1})])):o(``,!0),n.modelValue?.response?.success===!1?(p(),s(`div`,Me,[a(w,{closable:!1,class:`failure`},{template:d(()=>[a(S,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Ne,[a(S,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])]),e(`p`,Pe,[a(S,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.failureReason`))+`: `+i(n.modelValue?.response?.error?.message)+` `,1),a(C,{content:n.modelValue?.response?.error?.message},null,8,[`content`])]),n.modelValue?.elapsed?(p(),s(`p`,$,[a(S,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),e(`p`,Fe,[a(S,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(C,{content:n.modelValue?.response?.trace_id},null,8,[`content`])])]),_:1})])):o(``,!0),n.modelValue?.response?.success===void 0?(p(),s(`div`,Ie,[a(w,{closable:!1,class:`info`},{template:d(()=>[a(S,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Le,[a(S,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])])]),_:1})])):o(``,!0)])])}var ze=m({name:`RecentPanel`,components:{TaskPreview:S(ge,[[`render`,Re],[`__scopeId`,`data-v-53d13da4`]]),BotPlaceholder:H,NoTasks:U,ScrollList:R},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.hailuo?.tasks,items:this.$store.state.hailuo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Be={key:0},Ve={key:2,class:`w-full h-full flex items-center justify-center`};function He(e,t,n,r,i,m){let h=l(`bot-placeholder`),g=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return p(),s(c,null,[e.tasks?.items===void 0?(p(),s(`div`,Be,[a(h)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(p(),u(_,{key:1,ref:`scrollList`,class:`tasks w-full h-full overflow-y-auto`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:d(()=>[(p(!0),s(c,null,f(e.tasks?.items,e=>(p(),u(g,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(p(),s(`div`,Ve,[a(v)])):o(``,!0)],64)}var Ue=m({name:`HailuoIndex`,components:{ConfigPanel:he,Layout:W,RecentPanel:S(ze,[[`render`,He]])},mixins:[j],inject:[`initialized`],data(){return{task:void 0,job:0,timer:void 0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.hailuo?.status?.getApplications===E.Request},tasksLoading(){return this.$store.state.hailuo?.status?.getTasks===E.Request||this.fetchingTasks},credential(){return this.$store.state.hailuo.credential},config(){return this.$store.state.hailuo.config},application(){return this.$store.state.hailuo.application},tasks(){return this.$store.state.hailuo.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 z({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(`hailuo/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`hailuo/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(`hailuo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!M(this.uploadTracker,e=>this.$t(e),e=>w.warning(e)))return;let e={...this.config,async:!0};if(!te())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}w.info(this.$t(`hailuo.message.startingTask`)),ee(`hailuo`,T.generate(e,{token:t})).then(()=>{w.success(this.$t(`hailuo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?w.error(this.$t(`hailuo.message.usedUp`)):w.error(this.$t(`hailuo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function We(e,t,n,r,i,o){let s=l(`config-panel`),c=l(`recent-panel`),f=l(`layout`);return p(),u(f,null,{config:d(()=>[a(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:d(()=>[a(c,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var Ge=S(Ue,[[`render`,We]]);export{Ge as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,Gt as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,j as l,mt as u,tt as d,z as f}from"./vendor-chart-Dw-P17PN.js";import{at as p,it as m,nt as ee,rt as h}from"./constants-BjP62jX_.js";import{G as te,Ii as g,R as _,T as v,Zt as y,a as b,c as x,k as S,n as C,w}from"./index-B6pXonqJ.js";import{t as T}from"./index.es-BzwAVtoA.js";var E=f({name:`DownloadIndex`,components:{ElButton:g,QrCode:y,FontAwesomeIcon:T},data(){return{faAndroid:w,faApple:v,faGooglePlay:S,faWindows:_,faDownload:x,faCircleInfo:b,faArrowLeft:C}},computed:{brandTitle(){return this.$store.state.site?.title||`AceData`},brandLogo(){return this.$store.state.site?.logo||`/assets/logo-CDy94G52.png`},androidDownloadUrl(){return h},hasAndroidDownload(){return!!h},playStoreUrl(){return m},hasPlayStore(){return!!m},appStoreUrl(){return p},hasAppStore(){return!!p},iosDownloadUrl(){return``},iosFallbackUrl(){return``},hasIosDownload(){return!1},hasIos(){return this.hasAppStore||this.hasIosDownload},desktopReleasesUrl(){return ee}},methods:{goBack(){window.history.length>1?this.$router.back():this.$router.push(`/`)},openSupport(){window.open(`https://platform.acedata.cloud/support`,`_blank`)}}}),D={class:`download-page`},O={class:`download-page__inner`},k={class:`hero`},A={class:`hero__brand`},j=[`src`,`alt`],M={class:`hero__eyebrow`},N={class:`hero__title`},P={class:`hero__subtitle`},F={class:`hero__badges`},I={class:`badge badge--live`},L={class:`badge`},R={class:`hero__actions`},z={class:`platforms`},B={class:`platform platform--android`},V={class:`platform__head`},H={class:`platform__os`},U={class:`chip chip--live`},W={class:`platform__title`},G={class:`platform__text`},K={key:0,class:`qr`},q={class:`qr__hint`},J={class:`platform__foot platform__foot--stack`},Y={key:0,class:`platform__fallback`},X={class:`platform__meta`},Z={class:`platform__meta`},Q={class:`platform platform--ios`},ne={class:`platform__head`},re={class:`platform__os`},ie={class:`platform__title`},ae={class:`platform__text`},oe={key:0,class:`qr`},se={class:`qr__hint`},ce={key:1,class:`platform__foot platform__foot--stack`},le={class:`btn-row`},ue={class:`platform__meta`},de={class:`ios-soon`},fe={class:`ios-soon__text`},pe={class:`platform__foot platform__foot--stack`},me={class:`platform platform--windows`},he={class:`platform__head`},ge={class:`platform__os`},_e={class:`platform__title`},ve={class:`platform__text`},ye={class:`platform__foot platform__foot--stack`},be={class:`platform platform--mac`},xe={class:`platform__head`},Se={class:`platform__os`},Ce={class:`platform__title`},we={class:`platform__text`},Te={class:`platform__foot platform__foot--stack`},Ee={class:`advantages`},De={class:`advantage`},$={class:`advantage__title`},Oe={class:`advantage__text`},ke={class:`advantage`},Ae={class:`advantage__title`},je={class:`advantage__text`},Me={class:`advantage`},Ne={class:`advantage__title`},Pe={class:`advantage__text`},Fe={key:0,class:`note`},Ie={class:`note__text`},Le={class:`note`},Re={class:`note__text`};function ze(f,p,m,ee,h,te){let g=c(`font-awesome-icon`),_=c(`el-button`),v=c(`qr-code`);return d(),o(`div`,D,[p[15]||=e(`div`,{class:`download-page__glow`,"aria-hidden":`true`},null,-1),e(`div`,O,[e(`button`,{type:`button`,class:`download-back`,onClick:p[0]||=(...e)=>f.goBack&&f.goBack(...e)},[i(g,{icon:f.faArrowLeft,class:`download-back__icon`},null,8,[`icon`]),e(`span`,null,r(f.$t(`common.button.goBack`)),1)]),e(`header`,k,[e(`span`,A,[e(`img`,{src:f.brandLogo,alt:f.brandTitle,class:`hero__logo`},null,8,j)]),e(`p`,M,r(f.brandTitle)+` · `+r(f.$t(`common.nav.mobileApp`)),1),e(`h1`,N,r(f.$t(`common.title.mobileApp`)),1),e(`p`,P,r(f.$t(`common.message.mobileAppDescription`)),1),e(`div`,F,[e(`span`,I,[p[1]||=e(`span`,{class:`badge__dot`},null,-1),n(r(f.$t(`common.message.mobileAvailableNow`)),1)]),e(`span`,L,r(f.$t(`common.message.mobileSharedAccount`)),1)]),e(`div`,R,[f.hasPlayStore?(d(),l(_,{key:0,type:`primary`,round:``,size:`large`,tag:`a`,href:f.playStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faGooglePlay,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnGooglePlay`)),1)]),_:1},8,[`href`])):f.hasAndroidDownload?(d(),l(_,{key:1,type:`primary`,round:``,size:`large`,tag:`a`,href:f.androidDownloadUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faAndroid,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadAndroid`)),1)]),_:1},8,[`href`])):a(``,!0),f.hasAppStore?(d(),l(_,{key:2,round:``,size:`large`,tag:`a`,href:f.appStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnAppStore`)),1)]),_:1},8,[`href`])):a(``,!0),i(_,{round:``,size:`large`,class:`btn-ghost`,onClick:f.openSupport},{default:u(()=>[n(r(f.$t(`common.nav.support`)),1)]),_:1},8,[`onClick`])])]),e(`section`,z,[e(`article`,B,[e(`div`,V,[e(`span`,H,[i(g,{icon:f.faAndroid,class:`platform__os-icon`},null,8,[`icon`]),p[2]||=n(` Android `,-1)]),e(`span`,U,[p[3]||=e(`span`,{class:`chip__dot`},null,-1),n(r(f.$t(`common.message.mobileAvailableNow`)),1)])]),e(`h2`,W,r(f.$t(`common.button.downloadAndroid`)),1),e(`p`,G,r(f.$t(`common.message.mobileAndroidHint`)),1),f.hasPlayStore||f.hasAndroidDownload?(d(),o(`div`,K,[i(v,{value:f.hasPlayStore?f.playStoreUrl:f.androidDownloadUrl,width:184,height:184,class:`qr__img`,type:`image/png`,color:{dark:`#0e2a33ff`,light:`#ffffffff`}},null,8,[`value`]),e(`p`,q,r(f.hasPlayStore?f.$t(`common.message.mobilePlayStoreHint`):f.$t(`common.message.mobileSecureDelivery`)),1)])):a(``,!0),e(`div`,J,[f.hasPlayStore?(d(),l(_,{key:0,type:`primary`,round:``,size:`large`,tag:`a`,href:f.playStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faGooglePlay,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnGooglePlay`)),1)]),_:1},8,[`href`])):a(``,!0),f.hasAndroidDownload?(d(),o(s,{key:1},[f.hasPlayStore?(d(),o(`div`,Y,[i(_,{round:``,tag:`a`,href:f.androidDownloadUrl,target:`_blank`,class:`btn-ghost`},{default:u(()=>[i(g,{icon:f.faDownload,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadAndroid`)),1)]),_:1},8,[`href`]),e(`span`,X,r(f.$t(`common.message.mobileApkFallback`)),1)])):(d(),o(s,{key:1},[i(_,{type:`primary`,round:``,size:`large`,tag:`a`,href:f.androidDownloadUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faDownload,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadAndroid`)),1)]),_:1},8,[`href`]),e(`span`,Z,r(f.$t(`common.message.mobileDirectInstall`)),1)],64))],64)):a(``,!0)])]),e(`article`,Q,[e(`div`,ne,[e(`span`,re,[i(g,{icon:f.faApple,class:`platform__os-icon`},null,8,[`icon`]),p[4]||=n(` iOS `,-1)]),e(`span`,{class:t([`chip`,f.hasIos?`chip--live`:`chip--pending`])},[p[5]||=e(`span`,{class:`chip__dot`},null,-1),n(` `+r(f.hasIos?f.$t(`common.message.mobileNowOnAppStore`):f.$t(`common.message.mobileComingSoon`)),1)],2)]),e(`h2`,ie,r(f.$t(`common.button.downloadIos`)),1),e(`p`,ae,r(f.hasIos?f.$t(`common.message.mobileIosHint`):f.$t(`common.message.mobileIosPending`)),1),f.hasAppStore?(d(),o(`div`,oe,[i(v,{value:f.appStoreUrl,width:184,height:184,class:`qr__img`,type:`image/png`,color:{dark:`#0e2a33ff`,light:`#ffffffff`}},null,8,[`value`]),e(`p`,se,r(f.$t(`common.message.mobileAppStoreHint`)),1)])):a(``,!0),f.hasIos?(d(),o(`div`,ce,[f.hasAppStore?(d(),l(_,{key:0,type:`primary`,round:``,size:`large`,tag:`a`,href:f.appStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnAppStore`)),1)]),_:1},8,[`href`])):a(``,!0),f.hasIosDownload?(d(),o(s,{key:1},[e(`div`,le,[i(_,{type:f.hasAppStore?`default`:`primary`,round:``,size:f.hasAppStore?`default`:`large`,class:t({"btn-ghost":f.hasAppStore}),tag:`a`,href:f.iosDownloadUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.installIos`)),1)]),_:1},8,[`type`,`size`,`class`,`href`]),i(_,{round:``,size:`large`,class:`btn-ghost`,tag:`a`,href:f.iosFallbackUrl,target:`_blank`},{default:u(()=>[n(r(f.$t(`common.button.downloadIos`)),1)]),_:1},8,[`href`])]),e(`span`,ue,r(f.$t(`common.message.mobileInstallNote`)),1)],64)):a(``,!0)])):(d(),o(s,{key:2},[e(`div`,de,[i(g,{icon:f.faApple,class:`ios-soon__icon`},null,8,[`icon`]),e(`p`,fe,r(f.$t(`common.message.mobileComingSoon`)),1)]),e(`div`,pe,[i(_,{round:``,size:`large`,class:`btn-ghost`,onClick:f.openSupport},{default:u(()=>[n(r(f.$t(`common.nav.support`)),1)]),_:1},8,[`onClick`])])],64))]),e(`article`,me,[e(`div`,he,[e(`span`,ge,[i(g,{icon:f.faWindows,class:`platform__os-icon`},null,8,[`icon`]),p[6]||=n(` Windows `,-1)]),p[7]||=e(`span`,{class:`chip chip--beta`},[e(`span`,{class:`chip__dot`}),n(`Beta `)],-1)]),e(`h2`,_e,r(f.$t(`common.button.downloadWindows`)),1),e(`p`,ve,r(f.$t(`common.message.desktopWindowsHint`)),1),e(`div`,ye,[i(_,{type:`primary`,round:``,size:`large`,tag:`a`,href:f.desktopReleasesUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faWindows,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadWindows`)),1)]),_:1},8,[`href`]),p[8]||=e(`span`,{class:`platform__meta`},`Beta`,-1)])]),e(`article`,be,[e(`div`,xe,[e(`span`,Se,[i(g,{icon:f.faApple,class:`platform__os-icon`},null,8,[`icon`]),p[9]||=n(` macOS `,-1)]),p[10]||=e(`span`,{class:`chip chip--beta`},[e(`span`,{class:`chip__dot`}),n(`Beta `)],-1)]),e(`h2`,Ce,r(f.$t(`common.button.downloadMac`)),1),e(`p`,we,r(f.$t(`common.message.desktopMacHint`)),1),e(`div`,Te,[i(_,{type:`primary`,round:``,size:`large`,tag:`a`,href:f.desktopReleasesUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadMac`)),1)]),_:1},8,[`href`]),p[11]||=e(`span`,{class:`platform__meta`},`Beta · Apple Silicon & Intel`,-1)])])]),e(`section`,Ee,[e(`article`,De,[p[12]||=e(`span`,{class:`advantage__num`},`01`,-1),e(`h3`,$,r(f.$t(`common.title.mobileFastAccess`)),1),e(`p`,Oe,r(f.$t(`common.message.mobileFastAccess`)),1)]),e(`article`,ke,[p[13]||=e(`span`,{class:`advantage__num`},`02`,-1),e(`h3`,Ae,r(f.$t(`common.title.mobileTrustedRelease`)),1),e(`p`,je,r(f.$t(`common.message.mobileTrustedRelease`)),1)]),e(`article`,Me,[p[14]||=e(`span`,{class:`advantage__num`},`03`,-1),e(`h3`,Ne,r(f.$t(`common.title.mobileUnifiedExperience`)),1),e(`p`,Pe,r(f.$t(`common.message.mobileUnifiedExperience`)),1)])]),f.hasIosDownload?(d(),o(`aside`,Fe,[i(g,{icon:f.faCircleInfo,class:`note__icon`},null,8,[`icon`]),e(`p`,Ie,r(f.$t(`common.message.mobileInstallNote`)),1)])):a(``,!0),e(`aside`,Le,[i(g,{icon:f.faCircleInfo,class:`note__icon`},null,8,[`icon`]),e(`p`,Re,r(f.$t(`common.message.desktopUnsignedNote`)),1)])])])}var Be=te(E,[[`render`,ze],[`__scopeId`,`data-v-ba0c480b`]]);export{Be as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,Gt as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,j as l,mt as u,tt as d,z as f}from"./vendor-chart-Dw-P17PN.js";import{at as p,it as m,nt as ee,rt as h}from"./constants-BjP62jX_.js";import{G as te,Ii as g,R as _,T as v,Zt as y,a as b,c as x,k as S,n as C,w}from"./index-CX3_OnAo.js";import{t as T}from"./index.es-CjjFtgN-.js";var E=f({name:`DownloadIndex`,components:{ElButton:g,QrCode:y,FontAwesomeIcon:T},data(){return{faAndroid:w,faApple:v,faGooglePlay:S,faWindows:_,faDownload:x,faCircleInfo:b,faArrowLeft:C}},computed:{brandTitle(){return this.$store.state.site?.title||`AceData`},brandLogo(){return this.$store.state.site?.logo||`/assets/logo-CDy94G52.png`},androidDownloadUrl(){return h},hasAndroidDownload(){return!!h},playStoreUrl(){return m},hasPlayStore(){return!!m},appStoreUrl(){return p},hasAppStore(){return!!p},iosDownloadUrl(){return``},iosFallbackUrl(){return``},hasIosDownload(){return!1},hasIos(){return this.hasAppStore||this.hasIosDownload},desktopReleasesUrl(){return ee}},methods:{goBack(){window.history.length>1?this.$router.back():this.$router.push(`/`)},openSupport(){window.open(`https://platform.acedata.cloud/support`,`_blank`)}}}),D={class:`download-page`},O={class:`download-page__inner`},k={class:`hero`},A={class:`hero__brand`},j=[`src`,`alt`],M={class:`hero__eyebrow`},N={class:`hero__title`},P={class:`hero__subtitle`},F={class:`hero__badges`},I={class:`badge badge--live`},L={class:`badge`},R={class:`hero__actions`},z={class:`platforms`},B={class:`platform platform--android`},V={class:`platform__head`},H={class:`platform__os`},U={class:`chip chip--live`},W={class:`platform__title`},G={class:`platform__text`},K={key:0,class:`qr`},q={class:`qr__hint`},J={class:`platform__foot platform__foot--stack`},Y={key:0,class:`platform__fallback`},X={class:`platform__meta`},Z={class:`platform__meta`},Q={class:`platform platform--ios`},ne={class:`platform__head`},re={class:`platform__os`},ie={class:`platform__title`},ae={class:`platform__text`},oe={key:0,class:`qr`},se={class:`qr__hint`},ce={key:1,class:`platform__foot platform__foot--stack`},le={class:`btn-row`},ue={class:`platform__meta`},de={class:`ios-soon`},fe={class:`ios-soon__text`},pe={class:`platform__foot platform__foot--stack`},me={class:`platform platform--windows`},he={class:`platform__head`},ge={class:`platform__os`},_e={class:`platform__title`},ve={class:`platform__text`},ye={class:`platform__foot platform__foot--stack`},be={class:`platform platform--mac`},xe={class:`platform__head`},Se={class:`platform__os`},Ce={class:`platform__title`},we={class:`platform__text`},Te={class:`platform__foot platform__foot--stack`},Ee={class:`advantages`},De={class:`advantage`},$={class:`advantage__title`},Oe={class:`advantage__text`},ke={class:`advantage`},Ae={class:`advantage__title`},je={class:`advantage__text`},Me={class:`advantage`},Ne={class:`advantage__title`},Pe={class:`advantage__text`},Fe={key:0,class:`note`},Ie={class:`note__text`},Le={class:`note`},Re={class:`note__text`};function ze(f,p,m,ee,h,te){let g=c(`font-awesome-icon`),_=c(`el-button`),v=c(`qr-code`);return d(),o(`div`,D,[p[15]||=e(`div`,{class:`download-page__glow`,"aria-hidden":`true`},null,-1),e(`div`,O,[e(`button`,{type:`button`,class:`download-back`,onClick:p[0]||=(...e)=>f.goBack&&f.goBack(...e)},[i(g,{icon:f.faArrowLeft,class:`download-back__icon`},null,8,[`icon`]),e(`span`,null,r(f.$t(`common.button.goBack`)),1)]),e(`header`,k,[e(`span`,A,[e(`img`,{src:f.brandLogo,alt:f.brandTitle,class:`hero__logo`},null,8,j)]),e(`p`,M,r(f.brandTitle)+` · `+r(f.$t(`common.nav.mobileApp`)),1),e(`h1`,N,r(f.$t(`common.title.mobileApp`)),1),e(`p`,P,r(f.$t(`common.message.mobileAppDescription`)),1),e(`div`,F,[e(`span`,I,[p[1]||=e(`span`,{class:`badge__dot`},null,-1),n(r(f.$t(`common.message.mobileAvailableNow`)),1)]),e(`span`,L,r(f.$t(`common.message.mobileSharedAccount`)),1)]),e(`div`,R,[f.hasPlayStore?(d(),l(_,{key:0,type:`primary`,round:``,size:`large`,tag:`a`,href:f.playStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faGooglePlay,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnGooglePlay`)),1)]),_:1},8,[`href`])):f.hasAndroidDownload?(d(),l(_,{key:1,type:`primary`,round:``,size:`large`,tag:`a`,href:f.androidDownloadUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faAndroid,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadAndroid`)),1)]),_:1},8,[`href`])):a(``,!0),f.hasAppStore?(d(),l(_,{key:2,round:``,size:`large`,tag:`a`,href:f.appStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnAppStore`)),1)]),_:1},8,[`href`])):a(``,!0),i(_,{round:``,size:`large`,class:`btn-ghost`,onClick:f.openSupport},{default:u(()=>[n(r(f.$t(`common.nav.support`)),1)]),_:1},8,[`onClick`])])]),e(`section`,z,[e(`article`,B,[e(`div`,V,[e(`span`,H,[i(g,{icon:f.faAndroid,class:`platform__os-icon`},null,8,[`icon`]),p[2]||=n(` Android `,-1)]),e(`span`,U,[p[3]||=e(`span`,{class:`chip__dot`},null,-1),n(r(f.$t(`common.message.mobileAvailableNow`)),1)])]),e(`h2`,W,r(f.$t(`common.button.downloadAndroid`)),1),e(`p`,G,r(f.$t(`common.message.mobileAndroidHint`)),1),f.hasPlayStore||f.hasAndroidDownload?(d(),o(`div`,K,[i(v,{value:f.hasPlayStore?f.playStoreUrl:f.androidDownloadUrl,width:184,height:184,class:`qr__img`,type:`image/png`,color:{dark:`#0e2a33ff`,light:`#ffffffff`}},null,8,[`value`]),e(`p`,q,r(f.hasPlayStore?f.$t(`common.message.mobilePlayStoreHint`):f.$t(`common.message.mobileSecureDelivery`)),1)])):a(``,!0),e(`div`,J,[f.hasPlayStore?(d(),l(_,{key:0,type:`primary`,round:``,size:`large`,tag:`a`,href:f.playStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faGooglePlay,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnGooglePlay`)),1)]),_:1},8,[`href`])):a(``,!0),f.hasAndroidDownload?(d(),o(s,{key:1},[f.hasPlayStore?(d(),o(`div`,Y,[i(_,{round:``,tag:`a`,href:f.androidDownloadUrl,target:`_blank`,class:`btn-ghost`},{default:u(()=>[i(g,{icon:f.faDownload,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadAndroid`)),1)]),_:1},8,[`href`]),e(`span`,X,r(f.$t(`common.message.mobileApkFallback`)),1)])):(d(),o(s,{key:1},[i(_,{type:`primary`,round:``,size:`large`,tag:`a`,href:f.androidDownloadUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faDownload,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadAndroid`)),1)]),_:1},8,[`href`]),e(`span`,Z,r(f.$t(`common.message.mobileDirectInstall`)),1)],64))],64)):a(``,!0)])]),e(`article`,Q,[e(`div`,ne,[e(`span`,re,[i(g,{icon:f.faApple,class:`platform__os-icon`},null,8,[`icon`]),p[4]||=n(` iOS `,-1)]),e(`span`,{class:t([`chip`,f.hasIos?`chip--live`:`chip--pending`])},[p[5]||=e(`span`,{class:`chip__dot`},null,-1),n(` `+r(f.hasIos?f.$t(`common.message.mobileNowOnAppStore`):f.$t(`common.message.mobileComingSoon`)),1)],2)]),e(`h2`,ie,r(f.$t(`common.button.downloadIos`)),1),e(`p`,ae,r(f.hasIos?f.$t(`common.message.mobileIosHint`):f.$t(`common.message.mobileIosPending`)),1),f.hasAppStore?(d(),o(`div`,oe,[i(v,{value:f.appStoreUrl,width:184,height:184,class:`qr__img`,type:`image/png`,color:{dark:`#0e2a33ff`,light:`#ffffffff`}},null,8,[`value`]),e(`p`,se,r(f.$t(`common.message.mobileAppStoreHint`)),1)])):a(``,!0),f.hasIos?(d(),o(`div`,ce,[f.hasAppStore?(d(),l(_,{key:0,type:`primary`,round:``,size:`large`,tag:`a`,href:f.appStoreUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.getOnAppStore`)),1)]),_:1},8,[`href`])):a(``,!0),f.hasIosDownload?(d(),o(s,{key:1},[e(`div`,le,[i(_,{type:f.hasAppStore?`default`:`primary`,round:``,size:f.hasAppStore?`default`:`large`,class:t({"btn-ghost":f.hasAppStore}),tag:`a`,href:f.iosDownloadUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.installIos`)),1)]),_:1},8,[`type`,`size`,`class`,`href`]),i(_,{round:``,size:`large`,class:`btn-ghost`,tag:`a`,href:f.iosFallbackUrl,target:`_blank`},{default:u(()=>[n(r(f.$t(`common.button.downloadIos`)),1)]),_:1},8,[`href`])]),e(`span`,ue,r(f.$t(`common.message.mobileInstallNote`)),1)],64)):a(``,!0)])):(d(),o(s,{key:2},[e(`div`,de,[i(g,{icon:f.faApple,class:`ios-soon__icon`},null,8,[`icon`]),e(`p`,fe,r(f.$t(`common.message.mobileComingSoon`)),1)]),e(`div`,pe,[i(_,{round:``,size:`large`,class:`btn-ghost`,onClick:f.openSupport},{default:u(()=>[n(r(f.$t(`common.nav.support`)),1)]),_:1},8,[`onClick`])])],64))]),e(`article`,me,[e(`div`,he,[e(`span`,ge,[i(g,{icon:f.faWindows,class:`platform__os-icon`},null,8,[`icon`]),p[6]||=n(` Windows `,-1)]),p[7]||=e(`span`,{class:`chip chip--beta`},[e(`span`,{class:`chip__dot`}),n(`Beta `)],-1)]),e(`h2`,_e,r(f.$t(`common.button.downloadWindows`)),1),e(`p`,ve,r(f.$t(`common.message.desktopWindowsHint`)),1),e(`div`,ye,[i(_,{type:`primary`,round:``,size:`large`,tag:`a`,href:f.desktopReleasesUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faWindows,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadWindows`)),1)]),_:1},8,[`href`]),p[8]||=e(`span`,{class:`platform__meta`},`Beta`,-1)])]),e(`article`,be,[e(`div`,xe,[e(`span`,Se,[i(g,{icon:f.faApple,class:`platform__os-icon`},null,8,[`icon`]),p[9]||=n(` macOS `,-1)]),p[10]||=e(`span`,{class:`chip chip--beta`},[e(`span`,{class:`chip__dot`}),n(`Beta `)],-1)]),e(`h2`,Ce,r(f.$t(`common.button.downloadMac`)),1),e(`p`,we,r(f.$t(`common.message.desktopMacHint`)),1),e(`div`,Te,[i(_,{type:`primary`,round:``,size:`large`,tag:`a`,href:f.desktopReleasesUrl,target:`_blank`},{default:u(()=>[i(g,{icon:f.faApple,class:`btn-icon`},null,8,[`icon`]),n(` `+r(f.$t(`common.button.downloadMac`)),1)]),_:1},8,[`href`]),p[11]||=e(`span`,{class:`platform__meta`},`Beta · Apple Silicon & Intel`,-1)])])]),e(`section`,Ee,[e(`article`,De,[p[12]||=e(`span`,{class:`advantage__num`},`01`,-1),e(`h3`,$,r(f.$t(`common.title.mobileFastAccess`)),1),e(`p`,Oe,r(f.$t(`common.message.mobileFastAccess`)),1)]),e(`article`,ke,[p[13]||=e(`span`,{class:`advantage__num`},`02`,-1),e(`h3`,Ae,r(f.$t(`common.title.mobileTrustedRelease`)),1),e(`p`,je,r(f.$t(`common.message.mobileTrustedRelease`)),1)]),e(`article`,Me,[p[14]||=e(`span`,{class:`advantage__num`},`03`,-1),e(`h3`,Ne,r(f.$t(`common.title.mobileUnifiedExperience`)),1),e(`p`,Pe,r(f.$t(`common.message.mobileUnifiedExperience`)),1)])]),f.hasIosDownload?(d(),o(`aside`,Fe,[i(g,{icon:f.faCircleInfo,class:`note__icon`},null,8,[`icon`]),e(`p`,Ie,r(f.$t(`common.message.mobileInstallNote`)),1)])):a(``,!0),e(`aside`,Le,[i(g,{icon:f.faCircleInfo,class:`note__icon`},null,8,[`icon`]),e(`p`,Re,r(f.$t(`common.message.desktopUnsignedNote`)),1)])])])}var Be=te(E,[[`render`,ze],[`__scopeId`,`data-v-ba0c480b`]]);export{Be as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,Jt as t,L as n,at as r,ht as i,j as a,mt as o,ot as s,tt as c,z as l}from"./vendor-chart-Dw-P17PN.js";import{n as u,t as d}from"./table--5wRXM4l.js";import{t as f}from"./card-D-4S-l7a.js";import{n as p,t as m}from"./row-B19sQ-lm.js";import{t as h}from"./pagination-BxtJiMbm.js";import{G as g,vr as _}from"./index-B6pXonqJ.js";import{t as v}from"./CopyToClipboard-DSUOjJxX.js";var y=l({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(l,u,d,f,p,m){let h=r(`el-col`),g=r(`el-row`),_=r(`copy-to-clipboard`),v=r(`el-table-column`),y=r(`el-table`),O=r(`el-card`),k=r(`pagination`),A=s(`loading`);return c(),a(g,{class:`panel`},{default:o(()=>[n(h,{span:24},{default:o(()=>[n(g,null,{default:o(()=>[n(h,{span:24},{default:o(()=>[e(`h2`,b,t(l.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),n(g,null,{default:o(()=>[n(h,{span:24},{default:o(()=>[n(O,{shadow:`hover`},{default:o(()=>[i((c(),a(y,{data:l.invitees,stripe:``},{default:o(()=>[n(v,{prop:`id`,label:l.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:o(r=>[e(`span`,x,t(r.row.id),1),e(`span`,S,[n(_,{content:r.row.id},null,8,[`content`])])]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.username`),width:`300px`},{default:o(n=>[e(`span`,C,t(n.row?.username),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.email`),width:`300px`},{default:o(n=>[e(`span`,w,t(n.row?.email),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.nickname`),width:`200px`},{default:o(n=>[e(`span`,T,t(n.row.nickname),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.dateJoined`)},{default:o(n=>[e(`span`,E,t(l.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,l.loading]])]),_:1})]),_:1})]),_:1}),n(g,null,{default:o(()=>[n(h,{span:10,offset:14},{default:o(()=>[e(`div`,D,[n(k,{"current-page":l.page,"page-size":l.limit,total:l.total,onChange:l.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-b2200c49`]]);export{k as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,Jt as t,L as n,at as r,ht as i,j as a,mt as o,ot as s,tt as c,z as l}from"./vendor-chart-Dw-P17PN.js";import{n as u,t as d}from"./table-Cp0ajFJK.js";import{t as f}from"./card-D-4S-l7a.js";import{n as p,t as m}from"./row-BKdThz-n.js";import{t as h}from"./pagination-BAPL2vq4.js";import{G as g,vr as _}from"./index-CX3_OnAo.js";import{t as v}from"./CopyToClipboard-C5rXbm0J.js";var y=l({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:v,ElRow:m,ElCol:p,ElTable:d,ElTableColumn:u,ElCard:f},data(){return{invitees:[],loading:!1,total:void 0,limit:10}},computed:{redirect(){return this.$route.query.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData()},methods:{onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{page:e}})},onFetchData(){this.loading=!0,Promise.all([this.onFetchInvitees()]).finally(()=>{this.loading=!1})},async onFetchInvitees(){let{data:e}=await _.getInvitees({limit:this.limit,offset:(this.page-1)*this.limit,ordering:`-created_at`});this.invitees=e.items,this.total=e.count}}}),b={class:`title`},x={class:`key`},S={class:`copy`},C={class:`description`},w={class:`description`},T={class:`description`},E={class:`created-at`},D={class:`pagination m-v-lg`};function O(l,u,d,f,p,m){let h=r(`el-col`),g=r(`el-row`),_=r(`copy-to-clipboard`),v=r(`el-table-column`),y=r(`el-table`),O=r(`el-card`),k=r(`pagination`),A=s(`loading`);return c(),a(g,{class:`panel`},{default:o(()=>[n(h,{span:24},{default:o(()=>[n(g,null,{default:o(()=>[n(h,{span:24},{default:o(()=>[e(`h2`,b,t(l.$t(`common.title.invitee`)),1)]),_:1})]),_:1}),n(g,null,{default:o(()=>[n(h,{span:24},{default:o(()=>[n(O,{shadow:`hover`},{default:o(()=>[i((c(),a(y,{data:l.invitees,stripe:``},{default:o(()=>[n(v,{prop:`id`,label:l.$t(`user.field.id`),"class-name":`text-center`,width:`350px`},{default:o(r=>[e(`span`,x,t(r.row.id),1),e(`span`,S,[n(_,{content:r.row.id},null,8,[`content`])])]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.username`),width:`300px`},{default:o(n=>[e(`span`,C,t(n.row?.username),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.email`),width:`300px`},{default:o(n=>[e(`span`,w,t(n.row?.email),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.nickname`),width:`200px`},{default:o(n=>[e(`span`,T,t(n.row.nickname),1)]),_:1},8,[`label`]),n(v,{label:l.$t(`user.field.dateJoined`)},{default:o(n=>[e(`span`,E,t(l.$dayjs.format(n.row.date_joined)),1)]),_:1},8,[`label`])]),_:1},8,[`data`])),[[A,l.loading]])]),_:1})]),_:1})]),_:1}),n(g,null,{default:o(()=>[n(h,{span:10,offset:14},{default:o(()=>[e(`div`,D,[n(k,{"current-page":l.page,"page-size":l.limit,total:l.total,onChange:l.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var k=g(y,[[`render`,O],[`__scopeId`,`data-v-b2200c49`]]);export{k as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,a as c,at as l,c as u,d,ht as f,i as p,j as m,l as h,mt as g,n as _,o as v,ot as ee,qt as y,r as b,rt as x,s as S,t as C,tt as w,u as T,x as te,z as E}from"./vendor-chart-Dw-P17PN.js";import{r as D,t as O}from"./select--8g3iZ4i.js";import{n as k,t as A}from"./table--5wRXM4l.js";import{n as j,t as M}from"./tabs-Duhy_bLm.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-Bj0tEwH8.js";import{t as I}from"./date-picker-D3ABTPMI.js";import{n as L,t as R}from"./row-B19sQ-lm.js";import{t as z}from"./empty-xCRn_5sX.js";import{t as B}from"./pagination-BxtJiMbm.js";import{n as V,t as H}from"./skeleton-CoheJz5x.js";import{t as U}from"./switch-BwiE8QKL.js";import{Cr as W,G as ne,Ii as re,Oi as ie,Pi as ae,Ti as G,hr as K,li as q,mi as J,mr as Y,ni as X,pr as oe,ti as se,yr as ce}from"./index-B6pXonqJ.js";import{t as le}from"./index.es-BzwAVtoA.js";import{t as ue}from"./CopyToClipboard-DSUOjJxX.js";var de=e(W());v.register(c,u,p,b,S,T,d,h);var Z=[`#5B8FF9`,`#5AD8A6`,`#5D7092`,`#F6BD16`,`#6F5EF9`,`#6DC8EC`,`#945FB9`,`#FF9845`,`#1E9493`,`#FF99C3`],Q=`#C0C4CC`,fe=.01,pe=20;function me(e){return e<=Z.length?Z.slice(0,e):Array.from({length:e},(t,n)=>`hsl(${Math.round(n*360/e)}, 62%, ${n%2==0?55:45}%)`)}var he=15e3,ge=E({name:`ConsoleUsageList`,components:{Pagination:B,ElTag:ae,ElDatePicker:I,ElTable:A,ElSelect:D,ElOption:O,CopyToClipboard:ue,ElRow:R,ElCol:L,ElTableColumn:k,ElCard:N,ElRadioButton:P,ElRadioGroup:F,ElSkeleton:H,ElSkeletonItem:V,ElDialog:ie,ElTabs:j,ElTabPane:M,ElButton:re,ElEmpty:z,ElSwitch:U,FontAwesomeIcon:le,BarChart:C,DoughnutChart:_},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:se,serviceType:X,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()||X.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],chartView:`trend`,apiBreakdown:[],pieLabels:[],pieData:[],pieColors:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,traceId:this.$route.query.trace_id?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1,autoRefresh:!0,autoRefreshTimer:null,fetchSeq:0}},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,maxBarThickness:36,borderRadius:2,borderSkipped:!1}))}},barChartOptions(){let e=e=>new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100);return{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},plugins:{legend:{position:`bottom`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:14},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:!1},tooltip:{itemSort:(e,t)=>(t.parsed?.y||0)-(e.parsed?.y||0),callbacks:{label:t=>` ${t.dataset.label}: ${e(t.parsed.y)}`,footer:t=>`${this.$t(`usage.title.totalUsed`)}: ${e(t.reduce((e,t)=>e+(t.parsed?.y||0),0))}`}}},scales:{x:{stacked:!0,grid:{display:!1},ticks:{maxRotation:0,autoSkip:!0,autoSkipPadding:16}},y:{stacked:!0,beginAtZero:!0,border:{display:!1},grid:{color:`rgba(128, 128, 128, 0.15)`},ticks:{callback:t=>e(Number(t))}}}}},doughnutChartData(){return{labels:this.pieLabels,datasets:[{data:this.pieData,backgroundColor:this.pieColors,borderWidth:0,hoverOffset:6}]}},doughnutChartOptions(){let e=e=>this.fmtAmount(e),t=this.pieData.reduce((e,t)=>e+(t||0),0);return{responsive:!0,maintainAspectRatio:!1,cutout:`58%`,plugins:{legend:{position:`right`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:12}},title:{display:!1},tooltip:{callbacks:{label:n=>{let r=n.parsed||0,i=t>0?(r/t*100).toFixed(1):`0`;return` ${n.label}: ${e(r)} (${i}%)`}}}}}}},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()}},autoRefresh:{handler(e){e?this.startAutoRefresh():this.stopAutoRefresh()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions(),this.autoRefresh&&this.startAutoRefresh()},beforeUnmount(){this.stopAutoRefresh()},methods:{async onFetchUsages(e=!1){this.type===X.API?this.onFetchApiUsages(e):this.type===X.Proxy&&this.onFetchProxyUsages(e)},startAutoRefresh(){this.stopAutoRefresh(),this.autoRefreshTimer=window.setInterval(()=>{document.hidden||this.onFetchUsages(!0)},he)},stopAutoRefresh(){this.autoRefreshTimer!==null&&(clearInterval(this.autoRefreshTimer),this.autoRefreshTimer=null)},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(){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 Y.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},getCredentialLabel(e){return e.credential?.name?.trim()||e.credential?.id||e.credential_id||`-`},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&Y.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(){ce.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:q.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,oe.getAll({limit:1e3,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;Y.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}:{},...this.traceId?{trace_id:this.traceId}:{}}).then(({data:e})=>{t===this.fetchSeq&&(this.apiUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},onFetchProxyUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;K.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})=>{t===this.fetchSeq&&(this.proxyUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},async onExport(){let e=this.$store.state.token?.access;if(!e){G.error(this.$t(`usage.message.exportFailed`));return}let t={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}:{}},n=`${J()}/api/v1/usage/apis/export/?${de.default.stringify(t,{arrayFormat:`repeat`})}`,r=null,i=window.showSaveFilePicker;if(typeof i==`function`)try{r=await i({suggestedName:`usages.csv`,types:[{description:`CSV`,accept:{"text/csv":[`.csv`]}}]})}catch(e){if(e?.name===`AbortError`)return;r=null}this.exporting=!0;try{let t=await fetch(n,{headers:{authorization:`Bearer ${e}`}});if(!t.ok||!t.body)throw Error(`export failed: ${t.status}`);if(r)await t.body.pipeTo(await r.createWritable());else{let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`usages.csv`,r.click(),window.URL.revokeObjectURL(n)}}catch{G.error(this.$t(`usage.message.exportFailed`))}finally{this.exporting=!1}},fmtAmount(e){return new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100)},async onFetchAggregate(){if(this.type!==this.serviceType.API)return;this.aggLoading=!0;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]}:{},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};try{let{data:t}=await Y.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r={},i={};(t.items||[]).forEach(e=>{let t=e.amount||0;(r[e.date]||(r[e.date]={}))[e.api_id]=(r[e.date]?.[e.api_id]||0)+t,i[e.api_id]=(i[e.api_id]||0)+t});let a=Object.keys(i).sort((e,t)=>i[t]-i[e]),o=a.reduce((e,t)=>e+i[t],0),s=a.length;if(o>0){let e=o*(1-fe),t=0;for(let n=0;n<a.length;n++)if(t+=i[a[n]],t>=e){s=n+1;break}s=Math.min(s,pe)}a.length-s===1&&(s=a.length);let c=a.slice(0,s),l=new Set(c),u=me(c.length),d=a.slice(s),f=`${this.$t(`usage.value.others`)} (${d.length})`,p=c.map((e,i)=>({key:e,label:t.apis?.[e]?.title||e,data:n.map(t=>r[t]?.[e]||0),color:u[i]}));if(d.length){let e=n.map(e=>Object.entries(r[e]||{}).reduce((e,[t,n])=>l.has(t)?e:e+n,0));e.some(e=>e>0)&&p.push({key:`__others__`,label:f,data:e,color:Q})}this.apiBreakdown=a.map((e,n)=>({key:e,label:t.apis?.[e]?.title||e,amount:i[e],color:n<c.length?u[n]:Q,share:o>0?i[e]/o:0}));let m=[],h=[],g=[];c.forEach((e,n)=>{m.push(t.apis?.[e]?.title||e),h.push(i[e]),g.push(u[n])});let _=d.reduce((e,t)=>e+i[t],0);_>0&&(m.push(f),h.push(_),g.push(Q)),this.pieLabels=m,this.pieData=h,this.pieColors=g,this.barChartLabels=n,this.barChartSeries=p}finally{this.aggLoading=!1}}}}),_e={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},ve={class:`inline-block w-9`},ye={class:`inline-block`},be={key:1,class:`summary-card`},xe={class:`icon-wrapper`},Se={class:`text-left`},Ce={class:`description`},we={class:`value`},Te={class:`flex flex-wrap items-center justify-between gap-2`},Ee={class:`text-[15px] font-medium text-[var(--el-text-color-primary)]`},De={class:`chart-wrapper`},Oe={class:`share-cell`},ke={class:`share-bar`},Ae={class:`share-pct`},je={class:`flex items-center justify-end gap-2 mb-4`},Me={class:`text-sm text-[var(--el-text-color-regular)]`},Ne={key:0},Pe={key:0},Fe={key:1},Ie={class:`flex flex-wrap gap-2`},Le={class:`key`},Re={key:0,class:`cursor-pointer`},ze={class:`key`},Be={key:0,class:`cursor-pointer`},Ve={class:`created-at`},$={class:`key`},He={key:0,class:`cursor-pointer`},Ue={class:`created-at`},We={key:1,class:`detail-json`},Ge={key:2,class:`text-gray-400`},Ke={key:1,class:`detail-json`},qe={key:2,class:`text-gray-400`},Je={class:`float-right`};function Ye(e,c,u,d,p,h){let _=l(`el-col`),v=l(`el-row`),b=l(`el-radio-button`),S=l(`el-radio-group`),C=l(`el-option`),T=l(`el-select`),E=l(`el-skeleton-item`),D=l(`el-skeleton`),O=l(`el-date-picker`),k=l(`font-awesome-icon`),A=l(`el-button`),j=l(`el-card`),M=l(`bar-chart`),N=l(`el-empty`),P=l(`doughnut-chart`),F=l(`el-table-column`),I=l(`el-table`),L=l(`el-switch`),R=l(`el-tag`),z=l(`copy-to-clipboard`),B=l(`el-tab-pane`),V=l(`el-tabs`),H=l(`el-dialog`),U=l(`pagination`),W=ee(`loading`);return w(),m(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[t(`h2`,_e,r(e.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),i(v,null,{default:g(()=>[i(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,null,r(e.$t(`application.field.type`)),1),i(S,{modelValue:e.type,"onUpdate:modelValue":c[0]||=t=>e.type=t},{default:g(()=>[i(b,{value:e.serviceType.API,label:e.$t(`application.field.api`)},null,8,[`value`,`label`]),i(b,{value:e.serviceType.Proxy,label:e.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(i(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ve,r(e.$t(`usage.field.application`)),1),i(T,{modelValue:e.applicationIds,"onUpdate:modelValue":c[1]||=t=>e.applicationIds=t,placeholder:e.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApplicationsChange},{default:g(()=>[(w(!0),o(s,null,x(e.applications,e=>(w(),m(C,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[te,!1]]),e.type===e.serviceType.API?(w(),m(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ye,r(e.$t(`usage.field.api`)),1),e.apisLoading?(w(),m(D,{key:0,animated:``,class:`w-full`},{template:g(()=>[i(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(w(),m(T,{key:1,modelValue:e.apiIds,"onUpdate:modelValue":c[2]||=t=>e.apiIds=t,placeholder:e.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApisChange},{default:g(()=>[(w(!0),o(s,null,x(e.apis,e=>(w(),m(C,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(O,{modelValue:e.createdAtRange,"onUpdate:modelValue":c[3]||=t=>e.createdAtRange=t,type:`datetimerange`,class:`w-full`,shortcuts:e.shortcuts,"range-separator":e.$t(`usage.placeholder.to`),"start-placeholder":e.$t(`usage.placeholder.startDate`),"end-placeholder":e.$t(`usage.placeholder.endDate`),onChange:e.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(T,{modelValue:e.statusCodeFilter,"onUpdate:modelValue":c[4]||=t=>e.statusCodeFilter=t,placeholder:e.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:e.statusCodeOptionsLoading,onChange:e.onStatusCodeChange},{default:g(()=>[(w(!0),o(s,null,x(e.statusCodeOptions,e=>(w(),m(C,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:g(()=>[i(A,{type:`primary`,plain:``,loading:e.exporting,class:`w-full whitespace-nowrap`,onClick:e.onExport},{default:g(()=>[i(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+r(e.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):a(``,!0)]),_:1}),i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[e.type===e.serviceType.API?(w(),m(v,{key:0,gutter:24,class:`mb-5`},{default:g(()=>[i(_,{md:6,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{default:g(()=>[e.aggLoading?(w(),m(D,{key:0})):(w(),o(`div`,be,[t(`div`,xe,[i(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),t(`div`,Se,[t(`p`,Ce,r(e.$t(`usage.title.totalUsed`)),1),t(`p`,we,r(e.totalUsedString),1)])]))]),_:1})]),_:1}),i(_,{md:18,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{header:g(()=>[t(`div`,Te,[t(`span`,Ee,r(e.$t(`usage.title.usageAnalytics`)),1),i(S,{modelValue:e.chartView,"onUpdate:modelValue":c[5]||=t=>e.chartView=t,size:`small`},{default:g(()=>[i(b,{value:`trend`,label:e.$t(`usage.view.trend`)},null,8,[`label`]),i(b,{value:`distribution`,label:e.$t(`usage.view.distribution`)},null,8,[`label`]),i(b,{value:`breakdown`,label:e.$t(`usage.view.breakdown`)},null,8,[`label`])]),_:1},8,[`modelValue`])])]),default:g(()=>[t(`div`,De,[e.aggLoading?(w(),m(D,{key:0,class:`w-full`})):e.chartView===`trend`?(w(),o(s,{key:1},[e.barChartSeries.length?(w(),m(M,{key:0,data:e.barChartData,options:e.barChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):e.chartView===`distribution`?(w(),o(s,{key:2},[e.pieData.length?(w(),m(P,{key:0,data:e.doughnutChartData,options:e.doughnutChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):(w(),o(s,{key:3},[e.apiBreakdown.length?(w(),m(I,{key:0,data:e.apiBreakdown,size:`small`,height:`300`,class:`w-full`},{default:g(()=>[i(F,{label:e.$t(`usage.field.api`),"min-width":`160`},{default:g(e=>[t(`span`,{class:`color-dot`,style:y({backgroundColor:e.row.color})},null,4),t(`span`,null,r(e.row.label),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.consumed`),width:`120`,align:`right`},{default:g(n=>[t(`span`,null,r(e.fmtAmount(n.row.amount)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.share`),width:`150`},{default:g(e=>[t(`div`,Oe,[t(`div`,ke,[t(`div`,{class:`share-bar-fill`,style:y({width:e.row.share*100+`%`,backgroundColor:e.row.color})},null,4)]),t(`span`,Ae,r((e.row.share*100).toFixed(1))+`%`,1)])]),_:1},8,[`label`])]),_:1},8,[`data`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64))])]),_:1})]),_:1})]),_:1})):a(``,!0),i(j,{shadow:`hover`},{default:g(()=>[t(`div`,je,[t(`span`,Me,r(e.$t(`usage.field.autoRefresh`)),1),i(L,{modelValue:e.autoRefresh,"onUpdate:modelValue":c[6]||=t=>e.autoRefresh=t},null,8,[`modelValue`])]),e.type===e.serviceType.API?f((w(),m(I,{key:0,data:e.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.api?.title),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.statusCode`),width:`120px`},{default:g(t=>[t.row.status_code?(w(),o(`span`,Ne,r(t.row.status_code),1)):(w(),m(R,{key:1,type:`warning`,size:`small`},{default:g(()=>[n(r(e.$t(`usage.value.processing`)),1)]),_:1}))]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.elapsed`),width:`120px`},{default:g(n=>[t(`span`,null,r(e.formatElapsed(n.row.elapsed)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[e.getDeductedAmount(n.row)===e.getOriginalAmount(n.row)?(w(),o(`div`,Pe,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)])):(w(),o(`div`,Fe,[c[9]||=t(`p`,null,null,-1),t(`p`,null,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),t(`p`,null,[t(`del`,null,r(e.getOriginalAmount(n.row)),1)])]))]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:g(i=>[t(`div`,Ie,[i.row.original_amount>i.row.deducted_amount&&i.row.original_amount>0?(w(),m(R,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(((i.row.original_amount-i.row.deducted_amount)*100/i.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):a(``,!0),(w(!0),o(s,null,x(e.getSimpleMetadata(i.row.metadata),(e,t)=>(w(),m(R,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:g(t=>[t.row.id?(w(),m(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:n=>e.onShowDetail(t.row)},{default:g(()=>[n(r(e.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`trace_id`,label:e.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:g(e=>[t(`span`,Le,r(e.row.trace_id),1),e.row.trace_id?(w(),o(`span`,Re,[i(z,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,ze,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Be,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ve,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0),e.type===e.serviceType.Proxy?f((w(),m(I,{key:1,data:e.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.service?.title),1)]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1),t(`span`,null,r(e.getOriginalAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:g(e=>[(w(!0),o(s,null,x(e.row.metadata,(e,t)=>(w(),m(R,{key:t,class:`mb-2`},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,$,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,He,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ue,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0)]),_:1})]),_:1})]),_:1}),i(H,{modelValue:e.detailDialogVisible,"onUpdate:modelValue":c[8]||=t=>e.detailDialogVisible=t,title:e.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:g(()=>[i(V,{modelValue:e.detailActiveTab,"onUpdate:modelValue":c[7]||=t=>e.detailActiveTab=t},{default:g(()=>[i(B,{label:e.$t(`usage.dialog.request`),name:`request`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.request?(w(),o(`pre`,We,r(e.formatJson(e.detailRow.metadata.request)),1)):(w(),o(`p`,Ge,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),i(B,{label:e.$t(`usage.dialog.response`),name:`response`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.response?(w(),o(`pre`,Ke,r(e.formatJson(e.detailRow.metadata.response)),1)):(w(),o(`p`,qe,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),i(v,null,{default:g(()=>[i(_,{span:10,offset:14},{default:g(()=>[t(`div`,Je,[i(U,{"current-page":e.page,"page-size":e.limit,total:e.total,onChange:e.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Xe=ne(ge,[[`render`,Ye],[`__scopeId`,`data-v-7028d194`]]);export{Xe as default};
1
+ import{o as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,a as c,at as l,c as u,d,ht as f,i as p,j as m,l as h,mt as g,n as _,o as v,ot as ee,qt as y,r as b,rt as x,s as S,t as C,tt as w,u as T,x as te,z as E}from"./vendor-chart-Dw-P17PN.js";import{r as D,t as O}from"./select-PQ29yVWj.js";import{n as k,t as A}from"./table-Cp0ajFJK.js";import{n as j,t as M}from"./tabs-DE54U7Eq.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-Bj0tEwH8.js";import{t as I}from"./date-picker-CsgHwert.js";import{n as L,t as R}from"./row-BKdThz-n.js";import{t as z}from"./empty-xCRn_5sX.js";import{t as B}from"./pagination-BAPL2vq4.js";import{n as V,t as H}from"./skeleton-CoheJz5x.js";import{t as U}from"./switch-BmKFU2Ps.js";import{Cr as W,G as ne,Ii as re,Oi as ie,Pi as ae,Ti as G,hr as K,li as q,mi as J,mr as Y,ni as X,pr as oe,ti as se,yr as ce}from"./index-CX3_OnAo.js";import{t as le}from"./index.es-CjjFtgN-.js";import{t as ue}from"./CopyToClipboard-C5rXbm0J.js";var de=e(W());v.register(c,u,p,b,S,T,d,h);var Z=[`#5B8FF9`,`#5AD8A6`,`#5D7092`,`#F6BD16`,`#6F5EF9`,`#6DC8EC`,`#945FB9`,`#FF9845`,`#1E9493`,`#FF99C3`],Q=`#C0C4CC`,fe=.01,pe=20;function me(e){return e<=Z.length?Z.slice(0,e):Array.from({length:e},(t,n)=>`hsl(${Math.round(n*360/e)}, 62%, ${n%2==0?55:45}%)`)}var he=15e3,ge=E({name:`ConsoleUsageList`,components:{Pagination:B,ElTag:ae,ElDatePicker:I,ElTable:A,ElSelect:D,ElOption:O,CopyToClipboard:ue,ElRow:R,ElCol:L,ElTableColumn:k,ElCard:N,ElRadioButton:P,ElRadioGroup:F,ElSkeleton:H,ElSkeletonItem:V,ElDialog:ie,ElTabs:j,ElTabPane:M,ElButton:re,ElEmpty:z,ElSwitch:U,FontAwesomeIcon:le,BarChart:C,DoughnutChart:_},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:se,serviceType:X,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()||X.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],chartView:`trend`,apiBreakdown:[],pieLabels:[],pieData:[],pieColors:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,traceId:this.$route.query.trace_id?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1,autoRefresh:!0,autoRefreshTimer:null,fetchSeq:0}},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,maxBarThickness:36,borderRadius:2,borderSkipped:!1}))}},barChartOptions(){let e=e=>new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100);return{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},plugins:{legend:{position:`bottom`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:14},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:!1},tooltip:{itemSort:(e,t)=>(t.parsed?.y||0)-(e.parsed?.y||0),callbacks:{label:t=>` ${t.dataset.label}: ${e(t.parsed.y)}`,footer:t=>`${this.$t(`usage.title.totalUsed`)}: ${e(t.reduce((e,t)=>e+(t.parsed?.y||0),0))}`}}},scales:{x:{stacked:!0,grid:{display:!1},ticks:{maxRotation:0,autoSkip:!0,autoSkipPadding:16}},y:{stacked:!0,beginAtZero:!0,border:{display:!1},grid:{color:`rgba(128, 128, 128, 0.15)`},ticks:{callback:t=>e(Number(t))}}}}},doughnutChartData(){return{labels:this.pieLabels,datasets:[{data:this.pieData,backgroundColor:this.pieColors,borderWidth:0,hoverOffset:6}]}},doughnutChartOptions(){let e=e=>this.fmtAmount(e),t=this.pieData.reduce((e,t)=>e+(t||0),0);return{responsive:!0,maintainAspectRatio:!1,cutout:`58%`,plugins:{legend:{position:`right`,labels:{usePointStyle:!0,pointStyle:`circle`,boxWidth:8,boxHeight:8,padding:12}},title:{display:!1},tooltip:{callbacks:{label:n=>{let r=n.parsed||0,i=t>0?(r/t*100).toFixed(1):`0`;return` ${n.label}: ${e(r)} (${i}%)`}}}}}}},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()}},autoRefresh:{handler(e){e?this.startAutoRefresh():this.stopAutoRefresh()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions(),this.autoRefresh&&this.startAutoRefresh()},beforeUnmount(){this.stopAutoRefresh()},methods:{async onFetchUsages(e=!1){this.type===X.API?this.onFetchApiUsages(e):this.type===X.Proxy&&this.onFetchProxyUsages(e)},startAutoRefresh(){this.stopAutoRefresh(),this.autoRefreshTimer=window.setInterval(()=>{document.hidden||this.onFetchUsages(!0)},he)},stopAutoRefresh(){this.autoRefreshTimer!==null&&(clearInterval(this.autoRefreshTimer),this.autoRefreshTimer=null)},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(){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 Y.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},getCredentialLabel(e){return e.credential?.name?.trim()||e.credential?.id||e.credential_id||`-`},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&Y.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(){ce.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:q.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,oe.getAll({limit:1e3,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;Y.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}:{},...this.traceId?{trace_id:this.traceId}:{}}).then(({data:e})=>{t===this.fetchSeq&&(this.apiUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},onFetchProxyUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;K.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})=>{t===this.fetchSeq&&(this.proxyUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},async onExport(){let e=this.$store.state.token?.access;if(!e){G.error(this.$t(`usage.message.exportFailed`));return}let t={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}:{}},n=`${J()}/api/v1/usage/apis/export/?${de.default.stringify(t,{arrayFormat:`repeat`})}`,r=null,i=window.showSaveFilePicker;if(typeof i==`function`)try{r=await i({suggestedName:`usages.csv`,types:[{description:`CSV`,accept:{"text/csv":[`.csv`]}}]})}catch(e){if(e?.name===`AbortError`)return;r=null}this.exporting=!0;try{let t=await fetch(n,{headers:{authorization:`Bearer ${e}`}});if(!t.ok||!t.body)throw Error(`export failed: ${t.status}`);if(r)await t.body.pipeTo(await r.createWritable());else{let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`usages.csv`,r.click(),window.URL.revokeObjectURL(n)}}catch{G.error(this.$t(`usage.message.exportFailed`))}finally{this.exporting=!1}},fmtAmount(e){return new Intl.NumberFormat().format(Math.round(((e||0)+2**-52)*100)/100)},async onFetchAggregate(){if(this.type!==this.serviceType.API)return;this.aggLoading=!0;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]}:{},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};try{let{data:t}=await Y.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r={},i={};(t.items||[]).forEach(e=>{let t=e.amount||0;(r[e.date]||(r[e.date]={}))[e.api_id]=(r[e.date]?.[e.api_id]||0)+t,i[e.api_id]=(i[e.api_id]||0)+t});let a=Object.keys(i).sort((e,t)=>i[t]-i[e]),o=a.reduce((e,t)=>e+i[t],0),s=a.length;if(o>0){let e=o*(1-fe),t=0;for(let n=0;n<a.length;n++)if(t+=i[a[n]],t>=e){s=n+1;break}s=Math.min(s,pe)}a.length-s===1&&(s=a.length);let c=a.slice(0,s),l=new Set(c),u=me(c.length),d=a.slice(s),f=`${this.$t(`usage.value.others`)} (${d.length})`,p=c.map((e,i)=>({key:e,label:t.apis?.[e]?.title||e,data:n.map(t=>r[t]?.[e]||0),color:u[i]}));if(d.length){let e=n.map(e=>Object.entries(r[e]||{}).reduce((e,[t,n])=>l.has(t)?e:e+n,0));e.some(e=>e>0)&&p.push({key:`__others__`,label:f,data:e,color:Q})}this.apiBreakdown=a.map((e,n)=>({key:e,label:t.apis?.[e]?.title||e,amount:i[e],color:n<c.length?u[n]:Q,share:o>0?i[e]/o:0}));let m=[],h=[],g=[];c.forEach((e,n)=>{m.push(t.apis?.[e]?.title||e),h.push(i[e]),g.push(u[n])});let _=d.reduce((e,t)=>e+i[t],0);_>0&&(m.push(f),h.push(_),g.push(Q)),this.pieLabels=m,this.pieData=h,this.pieColors=g,this.barChartLabels=n,this.barChartSeries=p}finally{this.aggLoading=!1}}}}),_e={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},ve={class:`inline-block w-9`},ye={class:`inline-block`},be={key:1,class:`summary-card`},xe={class:`icon-wrapper`},Se={class:`text-left`},Ce={class:`description`},we={class:`value`},Te={class:`flex flex-wrap items-center justify-between gap-2`},Ee={class:`text-[15px] font-medium text-[var(--el-text-color-primary)]`},De={class:`chart-wrapper`},Oe={class:`share-cell`},ke={class:`share-bar`},Ae={class:`share-pct`},je={class:`flex items-center justify-end gap-2 mb-4`},Me={class:`text-sm text-[var(--el-text-color-regular)]`},Ne={key:0},Pe={key:0},Fe={key:1},Ie={class:`flex flex-wrap gap-2`},Le={class:`key`},Re={key:0,class:`cursor-pointer`},ze={class:`key`},Be={key:0,class:`cursor-pointer`},Ve={class:`created-at`},$={class:`key`},He={key:0,class:`cursor-pointer`},Ue={class:`created-at`},We={key:1,class:`detail-json`},Ge={key:2,class:`text-gray-400`},Ke={key:1,class:`detail-json`},qe={key:2,class:`text-gray-400`},Je={class:`float-right`};function Ye(e,c,u,d,p,h){let _=l(`el-col`),v=l(`el-row`),b=l(`el-radio-button`),S=l(`el-radio-group`),C=l(`el-option`),T=l(`el-select`),E=l(`el-skeleton-item`),D=l(`el-skeleton`),O=l(`el-date-picker`),k=l(`font-awesome-icon`),A=l(`el-button`),j=l(`el-card`),M=l(`bar-chart`),N=l(`el-empty`),P=l(`doughnut-chart`),F=l(`el-table-column`),I=l(`el-table`),L=l(`el-switch`),R=l(`el-tag`),z=l(`copy-to-clipboard`),B=l(`el-tab-pane`),V=l(`el-tabs`),H=l(`el-dialog`),U=l(`pagination`),W=ee(`loading`);return w(),m(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[t(`h2`,_e,r(e.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),i(v,null,{default:g(()=>[i(_,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,null,r(e.$t(`application.field.type`)),1),i(S,{modelValue:e.type,"onUpdate:modelValue":c[0]||=t=>e.type=t},{default:g(()=>[i(b,{value:e.serviceType.API,label:e.$t(`application.field.api`)},null,8,[`value`,`label`]),i(b,{value:e.serviceType.Proxy,label:e.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(i(_,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ve,r(e.$t(`usage.field.application`)),1),i(T,{modelValue:e.applicationIds,"onUpdate:modelValue":c[1]||=t=>e.applicationIds=t,placeholder:e.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApplicationsChange},{default:g(()=>[(w(!0),o(s,null,x(e.applications,e=>(w(),m(C,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[te,!1]]),e.type===e.serviceType.API?(w(),m(_,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[t(`span`,ye,r(e.$t(`usage.field.api`)),1),e.apisLoading?(w(),m(D,{key:0,animated:``,class:`w-full`},{template:g(()=>[i(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(w(),m(T,{key:1,modelValue:e.apiIds,"onUpdate:modelValue":c[2]||=t=>e.apiIds=t,placeholder:e.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:e.onApisChange},{default:g(()=>[(w(!0),o(s,null,x(e.apis,e=>(w(),m(C,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(O,{modelValue:e.createdAtRange,"onUpdate:modelValue":c[3]||=t=>e.createdAtRange=t,type:`datetimerange`,class:`w-full`,shortcuts:e.shortcuts,"range-separator":e.$t(`usage.placeholder.to`),"start-placeholder":e.$t(`usage.placeholder.startDate`),"end-placeholder":e.$t(`usage.placeholder.endDate`),onChange:e.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:g(()=>[i(T,{modelValue:e.statusCodeFilter,"onUpdate:modelValue":c[4]||=t=>e.statusCodeFilter=t,placeholder:e.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:e.statusCodeOptionsLoading,onChange:e.onStatusCodeChange},{default:g(()=>[(w(!0),o(s,null,x(e.statusCodeOptions,e=>(w(),m(C,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):a(``,!0),e.type===e.serviceType.API?(w(),m(_,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:g(()=>[i(A,{type:`primary`,plain:``,loading:e.exporting,class:`w-full whitespace-nowrap`,onClick:e.onExport},{default:g(()=>[i(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),n(` `+r(e.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):a(``,!0)]),_:1}),i(v,null,{default:g(()=>[i(_,{span:24},{default:g(()=>[e.type===e.serviceType.API?(w(),m(v,{key:0,gutter:24,class:`mb-5`},{default:g(()=>[i(_,{md:6,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{default:g(()=>[e.aggLoading?(w(),m(D,{key:0})):(w(),o(`div`,be,[t(`div`,xe,[i(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),t(`div`,Se,[t(`p`,Ce,r(e.$t(`usage.title.totalUsed`)),1),t(`p`,we,r(e.totalUsedString),1)])]))]),_:1})]),_:1}),i(_,{md:18,xs:24},{default:g(()=>[i(j,{shadow:`hover`,class:`h-full`},{header:g(()=>[t(`div`,Te,[t(`span`,Ee,r(e.$t(`usage.title.usageAnalytics`)),1),i(S,{modelValue:e.chartView,"onUpdate:modelValue":c[5]||=t=>e.chartView=t,size:`small`},{default:g(()=>[i(b,{value:`trend`,label:e.$t(`usage.view.trend`)},null,8,[`label`]),i(b,{value:`distribution`,label:e.$t(`usage.view.distribution`)},null,8,[`label`]),i(b,{value:`breakdown`,label:e.$t(`usage.view.breakdown`)},null,8,[`label`])]),_:1},8,[`modelValue`])])]),default:g(()=>[t(`div`,De,[e.aggLoading?(w(),m(D,{key:0,class:`w-full`})):e.chartView===`trend`?(w(),o(s,{key:1},[e.barChartSeries.length?(w(),m(M,{key:0,data:e.barChartData,options:e.barChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):e.chartView===`distribution`?(w(),o(s,{key:2},[e.pieData.length?(w(),m(P,{key:0,data:e.doughnutChartData,options:e.doughnutChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64)):(w(),o(s,{key:3},[e.apiBreakdown.length?(w(),m(I,{key:0,data:e.apiBreakdown,size:`small`,height:`300`,class:`w-full`},{default:g(()=>[i(F,{label:e.$t(`usage.field.api`),"min-width":`160`},{default:g(e=>[t(`span`,{class:`color-dot`,style:y({backgroundColor:e.row.color})},null,4),t(`span`,null,r(e.row.label),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.consumed`),width:`120`,align:`right`},{default:g(n=>[t(`span`,null,r(e.fmtAmount(n.row.amount)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.share`),width:`150`},{default:g(e=>[t(`div`,Oe,[t(`div`,ke,[t(`div`,{class:`share-bar-fill`,style:y({width:e.row.share*100+`%`,backgroundColor:e.row.color})},null,4)]),t(`span`,Ae,r((e.row.share*100).toFixed(1))+`%`,1)])]),_:1},8,[`label`])]),_:1},8,[`data`])):(w(),m(N,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64))])]),_:1})]),_:1})]),_:1})):a(``,!0),i(j,{shadow:`hover`},{default:g(()=>[t(`div`,je,[t(`span`,Me,r(e.$t(`usage.field.autoRefresh`)),1),i(L,{modelValue:e.autoRefresh,"onUpdate:modelValue":c[6]||=t=>e.autoRefresh=t},null,8,[`modelValue`])]),e.type===e.serviceType.API?f((w(),m(I,{key:0,data:e.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.api?.title),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.statusCode`),width:`120px`},{default:g(t=>[t.row.status_code?(w(),o(`span`,Ne,r(t.row.status_code),1)):(w(),m(R,{key:1,type:`warning`,size:`small`},{default:g(()=>[n(r(e.$t(`usage.value.processing`)),1)]),_:1}))]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.elapsed`),width:`120px`},{default:g(n=>[t(`span`,null,r(e.formatElapsed(n.row.elapsed)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[e.getDeductedAmount(n.row)===e.getOriginalAmount(n.row)?(w(),o(`div`,Pe,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)])):(w(),o(`div`,Fe,[c[9]||=t(`p`,null,null,-1),t(`p`,null,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),t(`p`,null,[t(`del`,null,r(e.getOriginalAmount(n.row)),1)])]))]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:g(i=>[t(`div`,Ie,[i.row.original_amount>i.row.deducted_amount&&i.row.original_amount>0?(w(),m(R,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(((i.row.original_amount-i.row.deducted_amount)*100/i.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):a(``,!0),(w(!0),o(s,null,x(e.getSimpleMetadata(i.row.metadata),(e,t)=>(w(),m(R,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:g(t=>[t.row.id?(w(),m(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:n=>e.onShowDetail(t.row)},{default:g(()=>[n(r(e.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`trace_id`,label:e.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:g(e=>[t(`span`,Le,r(e.row.trace_id),1),e.row.trace_id?(w(),o(`span`,Re,[i(z,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,ze,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Be,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ve,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0),e.type===e.serviceType.Proxy?f((w(),m(I,{key:1,data:e.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":e.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:g(()=>[i(F,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.service?.title),1)]),_:1},8,[`label`]),i(F,{prop:`remaining_amount`,label:e.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1),t(`span`,null,r(e.getOriginalAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`deducted_amount`,label:e.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getDeductedAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:g(n=>[t(`span`,null,r(e.getRemainingAmount(n.row)),1)]),_:1},8,[`label`]),i(F,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:g(e=>[(w(!0),o(s,null,x(e.row.metadata,(e,t)=>(w(),m(R,{key:t,class:`mb-2`},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),i(F,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,$,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,He,[i(z,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(F,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ue,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[W,e.loading]]):a(``,!0)]),_:1})]),_:1})]),_:1}),i(H,{modelValue:e.detailDialogVisible,"onUpdate:modelValue":c[8]||=t=>e.detailDialogVisible=t,title:e.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:g(()=>[i(V,{modelValue:e.detailActiveTab,"onUpdate:modelValue":c[7]||=t=>e.detailActiveTab=t},{default:g(()=>[i(B,{label:e.$t(`usage.dialog.request`),name:`request`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.request?(w(),o(`pre`,We,r(e.formatJson(e.detailRow.metadata.request)),1)):(w(),o(`p`,Ge,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),i(B,{label:e.$t(`usage.dialog.response`),name:`response`},{default:g(()=>[e.detailLoading?(w(),m(D,{key:0,rows:6,animated:``})):e.detailRow?.metadata?.response?(w(),o(`pre`,Ke,r(e.formatJson(e.detailRow.metadata.response)),1)):(w(),o(`p`,qe,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),i(v,null,{default:g(()=>[i(_,{span:10,offset:14},{default:g(()=>[t(`div`,Je,[i(U,{"current-page":e.page,"page-size":e.limit,total:e.total,onChange:e.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Xe=ne(ge,[[`render`,Ye],[`__scopeId`,`data-v-7028d194`]]);export{Xe as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,N as i,T as a,at as o,ht as s,j as c,mt as l,ot as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{r as m,t as h}from"./select--8g3iZ4i.js";import{n as g,t as _}from"./table--5wRXM4l.js";import{t as v}from"./card-D-4S-l7a.js";import{t as y}from"./date-picker-D3ABTPMI.js";import{n as b,t as x}from"./row-B19sQ-lm.js";import{t as S}from"./pagination-BxtJiMbm.js";import{t as C}from"./skeleton-CoheJz5x.js";import{G as w,Ii as T,Pi as E,fr as D,ri as O,sn as k}from"./index-B6pXonqJ.js";import{t as A}from"./index.es-BzwAVtoA.js";import{t as j}from"./CopyToClipboard-DSUOjJxX.js";var M={total_count:0,total_spent:0,state_counts:{}},N=p({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:j,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:T,ElTag:E,ElCard:v,ElSelect:m,ElOption:h,ElDatePicker:y,ElSkeleton:C,FontAwesomeIcon:A},data(){return{OrderState:O,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...M},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:O.PENDING,label:this.$t(`order.state.pending`)},{value:O.FINISHED,label:this.$t(`order.state.finished`)},{value:O.PAID,label:this.$t(`order.state.paid`)},{value:O.EXPIRED,label:this.$t(`order.state.expired`)},{value:O.FAILED,label:this.$t(`order.state.failed`)},{value:O.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:k,stateTagType(e){return e===O.FINISHED||e===O.PAID?`success`:e===O.EXPIRED||e===O.FAILED?`danger`:e===O.REFUNDED?`warning`:`info`},stateLabel(e){return{[O.PENDING]:this.$t(`order.state.pending`),[O.PAID]:this.$t(`order.state.paid`),[O.FINISHED]:this.$t(`order.state.finished`),[O.EXPIRED]:this.$t(`order.state.expired`),[O.FAILED]:this.$t(`order.state.failed`),[O.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==O.PAID&&e!==O.FINISHED&&e!==O.EXPIRED&&e!==O.FAILED&&e!==O.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,D.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,D.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,D.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})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={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(p,m,h,g,_,v){let y=o(`el-col`),b=o(`el-row`),x=o(`el-skeleton`),S=o(`font-awesome-icon`),C=o(`el-card`),w=o(`el-option`),T=o(`el-select`),E=o(`el-date-picker`),D=o(`el-button`),O=o(`copy-to-clipboard`),k=o(`el-table-column`),A=o(`el-tag`),j=o(`el-table`),M=o(`pagination`),N=u(`loading`);return f(),c(b,{class:`panel`},{default:l(()=>[r(y,{span:24},{default:l(()=>[r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[e(`h2`,P,n(p.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),r(b,{gutter:16},{default:l(()=>[r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,F,[e(`div`,I,[r(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),e(`p`,L,n(p.$t(`order.title.totalOrders`)),1),e(`p`,R,n(p.summary.total_count),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,z,[e(`div`,B,[r(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),e(`p`,V,n(p.$t(`order.title.totalSpent`)),1),e(`p`,H,n(p.getPriceString({value:p.summary.total_spent})),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,U,[e(`div`,W,[r(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),e(`p`,ee,n(p.$t(`order.title.finishedOrders`)),1),e(`p`,G,n(p.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,K,[e(`div`,q,[r(S,{icon:`fa-solid fa-clock`,class:`icon`})]),e(`p`,J,n(p.$t(`order.title.pendingOrders`)),1),e(`p`,Y,n(p.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),e(`div`,X,[r(T,{modelValue:p.filterState,"onUpdate:modelValue":m[0]||=e=>p.filterState=e,clearable:``,placeholder:p.$t(`order.field.allStates`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.stateOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(T,{modelValue:p.filterPayWay,"onUpdate:modelValue":m[1]||=e=>p.filterPayWay=e,clearable:``,placeholder:p.$t(`order.field.allPayWays`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.payWayOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(E,{modelValue:p.createdAtRange,"onUpdate:modelValue":m[2]||=e=>p.createdAtRange=e,type:`datetimerange`,shortcuts:p.shortcuts,"range-separator":p.$t(`usage.placeholder.to`),"start-placeholder":p.$t(`usage.placeholder.startDate`),"end-placeholder":p.$t(`usage.placeholder.endDate`),onChange:p.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),r(D,{type:`primary`,plain:``,loading:p.exporting,onClick:p.onExport},{default:l(()=>[r(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),t(` `+n(p.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[r(C,{shadow:`hover`},{default:l(()=>[s((f(),c(j,{data:p.orders,stripe:``,"empty-text":p.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:l(()=>[r(k,{prop:`id`,label:p.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:l(t=>[e(`span`,Z,n(t.row.id),1),e(`span`,Q,[r(O,{content:t.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.price`),width:`110px`,align:`center`},{default:l(t=>[e(`span`,$,n(p.getPriceString({value:t.row?.price})),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,te,n(t.row.description),1)]),_:1},8,[`label`]),r(k,{prop:`state`,label:p.$t(`order.field.state`),width:`130px`,align:`center`},{default:l(e=>[r(A,{type:p.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:l(()=>[t(n(p.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,ne,n(t.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(t=>[e(`span`,re,n(p.$dayjs.format(t.row.created_at)),1)]),_:1},8,[`label`]),r(k,{"min-width":`130px`,fixed:`right`},{default:l(r=>[e(`div`,ie,[p.isPendingAction(r.row.state)?(f(),c(D,{key:0,type:`primary`,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(f(),c(D,{key:1,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,p.loading]])]),_:1})]),_:1})]),_:1}),r(b,null,{default:l(()=>[r(y,{span:10,offset:14},{default:l(()=>[e(`div`,ae,[r(M,{"current-page":p.page,"page-size":p.limit,total:p.total,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=w(N,[[`render`,oe],[`__scopeId`,`data-v-452d97b9`]]);export{se as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,N as i,T as a,at as o,ht as s,j as c,mt as l,ot as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{r as m,t as h}from"./select-PQ29yVWj.js";import{n as g,t as _}from"./table-Cp0ajFJK.js";import{t as v}from"./card-D-4S-l7a.js";import{t as y}from"./date-picker-CsgHwert.js";import{n as b,t as x}from"./row-BKdThz-n.js";import{t as S}from"./pagination-BAPL2vq4.js";import{t as C}from"./skeleton-CoheJz5x.js";import{G as w,Ii as T,Pi as E,fr as D,ri as O,sn as k}from"./index-CX3_OnAo.js";import{t as A}from"./index.es-CjjFtgN-.js";import{t as j}from"./CopyToClipboard-C5rXbm0J.js";var M={total_count:0,total_spent:0,state_counts:{}},N=p({name:`ConsoleOrderList`,components:{Pagination:S,CopyToClipboard:j,ElRow:x,ElCol:b,ElTable:_,ElTableColumn:g,ElButton:T,ElTag:E,ElCard:v,ElSelect:m,ElOption:h,ElDatePicker:y,ElSkeleton:C,FontAwesomeIcon:A},data(){return{OrderState:O,orders:[],loading:!1,total:void 0,limit:10,filterState:this.$route.query.state?.toString()||``,filterPayWay:this.$route.query.pay_way?.toString()||``,createdAtRange:(()=>{let e=this.$route.query.created_at_from?.toString(),t=this.$route.query.created_at_to?.toString();if(e&&t)return[new Date(e),new Date(t)]})(),summary:{...M},summaryLoading:!1,exporting:!1,shortcuts:[{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}]}},computed:{page(){return parseInt(this.$route.query.page?.toString()||`1`)},stateOptions(){return[{value:O.PENDING,label:this.$t(`order.state.pending`)},{value:O.FINISHED,label:this.$t(`order.state.finished`)},{value:O.PAID,label:this.$t(`order.state.paid`)},{value:O.EXPIRED,label:this.$t(`order.state.expired`)},{value:O.FAILED,label:this.$t(`order.state.failed`)},{value:O.REFUNDED,label:this.$t(`order.state.refunded`)}]},payWayOptions(){return[{value:`WechatPay`,label:this.$t(`order.title.wechatPay`)},{value:`Stripe`,label:this.$t(`order.title.stripe`)},{value:`AliPay`,label:this.$t(`order.title.aliPay`)},{value:`X402`,label:this.$t(`order.title.x402`)},{value:`PayPal`,label:this.$t(`order.title.paypal`)}]},filterQuery(){let e={user_id:this.$store.getters.user?.id};return this.filterState&&(e.state=this.filterState),this.filterPayWay&&(e.pay_way=this.filterPayWay),this.createdAtRange?.[0]&&(e.created_at_from=this.createdAtRange[0]),this.createdAtRange?.[1]&&(e.created_at_to=this.createdAtRange[1]),e}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onFetchData(),this.onFetchSummary()},methods:{getPriceString:k,stateTagType(e){return e===O.FINISHED||e===O.PAID?`success`:e===O.EXPIRED||e===O.FAILED?`danger`:e===O.REFUNDED?`warning`:`info`},stateLabel(e){return{[O.PENDING]:this.$t(`order.state.pending`),[O.PAID]:this.$t(`order.state.paid`),[O.FINISHED]:this.$t(`order.state.finished`),[O.EXPIRED]:this.$t(`order.state.expired`),[O.FAILED]:this.$t(`order.state.failed`),[O.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==O.PAID&&e!==O.FINISHED&&e!==O.EXPIRED&&e!==O.FAILED&&e!==O.REFUNDED},goToDetail(e){this.$router.push({name:`console-order-detail`,params:{id:e}})},async onFilterChange(){await this.$router.push({name:this.$route.name?.toString(),query:{page:1,...this.filterState?{state:this.filterState}:{},...this.filterPayWay?{pay_way:this.filterPayWay}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0].toISOString()}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1].toISOString()}:{}}}),this.onFetchData(),this.onFetchSummary()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchData(){this.loading=!0,D.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,D.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...M}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,D.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})}}}),P={class:`title`},F={key:1,class:`card-content`},I={class:`icon-wrapper`},L={class:`description`},R={class:`value`},z={key:1,class:`card-content`},B={class:`icon-wrapper`},V={class:`description`},H={class:`value`},U={key:1,class:`card-content`},W={class:`icon-wrapper`},ee={class:`description`},G={class:`value`},K={key:1,class:`card-content`},q={class:`icon-wrapper`},J={class:`description`},Y={class:`value`},X={class:`filter-row mb-3`},Z={class:`key`},Q={class:`cursor-pointer`},$={class:`price`},te={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(p,m,h,g,_,v){let y=o(`el-col`),b=o(`el-row`),x=o(`el-skeleton`),S=o(`font-awesome-icon`),C=o(`el-card`),w=o(`el-option`),T=o(`el-select`),E=o(`el-date-picker`),D=o(`el-button`),O=o(`copy-to-clipboard`),k=o(`el-table-column`),A=o(`el-tag`),j=o(`el-table`),M=o(`pagination`),N=u(`loading`);return f(),c(b,{class:`panel`},{default:l(()=>[r(y,{span:24},{default:l(()=>[r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[e(`h2`,P,n(p.$t(`common.title.allOrders`)),1)]),_:1})]),_:1}),r(b,{gutter:16},{default:l(()=>[r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,F,[e(`div`,I,[r(S,{icon:`fa-solid fa-receipt`,class:`icon`})]),e(`p`,L,n(p.$t(`order.title.totalOrders`)),1),e(`p`,R,n(p.summary.total_count),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,z,[e(`div`,B,[r(S,{icon:`fa-solid fa-dollar-sign`,class:`icon`})]),e(`p`,V,n(p.$t(`order.title.totalSpent`)),1),e(`p`,H,n(p.getPriceString({value:p.summary.total_spent})),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,U,[e(`div`,W,[r(S,{icon:`fa-solid fa-check-circle`,class:`icon`})]),e(`p`,ee,n(p.$t(`order.title.finishedOrders`)),1),e(`p`,G,n(p.summary.state_counts?.Finished||0),1)]))]),_:1})]),_:1}),r(y,{md:6,sm:12,xs:24},{default:l(()=>[r(C,{shadow:`hover`,class:`item-mini mb-3`},{default:l(()=>[p.summaryLoading?(f(),c(x,{key:0})):(f(),i(`div`,K,[e(`div`,q,[r(S,{icon:`fa-solid fa-clock`,class:`icon`})]),e(`p`,J,n(p.$t(`order.title.pendingOrders`)),1),e(`p`,Y,n(p.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),e(`div`,X,[r(T,{modelValue:p.filterState,"onUpdate:modelValue":m[0]||=e=>p.filterState=e,clearable:``,placeholder:p.$t(`order.field.allStates`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.stateOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(T,{modelValue:p.filterPayWay,"onUpdate:modelValue":m[1]||=e=>p.filterPayWay=e,clearable:``,placeholder:p.$t(`order.field.allPayWays`),class:`filter-select`,onChange:p.onFilterChange},{default:l(()=>[(f(!0),i(a,null,d(p.payWayOptions,e=>(f(),c(w,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(E,{modelValue:p.createdAtRange,"onUpdate:modelValue":m[2]||=e=>p.createdAtRange=e,type:`datetimerange`,shortcuts:p.shortcuts,"range-separator":p.$t(`usage.placeholder.to`),"start-placeholder":p.$t(`usage.placeholder.startDate`),"end-placeholder":p.$t(`usage.placeholder.endDate`),onChange:p.onFilterChange},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`]),r(D,{type:`primary`,plain:``,loading:p.exporting,onClick:p.onExport},{default:l(()=>[r(S,{icon:`fa-solid fa-file-export`,class:`mr-1`}),t(` `+n(p.$t(`order.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),r(b,null,{default:l(()=>[r(y,{span:24},{default:l(()=>[r(C,{shadow:`hover`},{default:l(()=>[s((f(),c(j,{data:p.orders,stripe:``,"empty-text":p.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:l(()=>[r(k,{prop:`id`,label:p.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:l(t=>[e(`span`,Z,n(t.row.id),1),e(`span`,Q,[r(O,{content:t.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.price`),width:`110px`,align:`center`},{default:l(t=>[e(`span`,$,n(p.getPriceString({value:t.row?.price})),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.description`),"min-width":`220px`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,te,n(t.row.description),1)]),_:1},8,[`label`]),r(k,{prop:`state`,label:p.$t(`order.field.state`),width:`130px`,align:`center`},{default:l(e=>[r(A,{type:p.stateTagType(e.row.state),class:`mx-1`,effect:`dark`,round:``,size:`small`},{default:l(()=>[t(n(p.stateLabel(e.row.state)),1)]),_:2},1032,[`type`])]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.payWay`),width:`120px`,align:`center`,"class-name":`hidden md:table-cell`,"label-class-name":`hidden md:table-cell`},{default:l(t=>[e(`span`,ne,n(t.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(k,{label:p.$t(`order.field.createdAt`),width:`200px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(t=>[e(`span`,re,n(p.$dayjs.format(t.row.created_at)),1)]),_:1},8,[`label`]),r(k,{"min-width":`130px`,fixed:`right`},{default:l(r=>[e(`div`,ie,[p.isPendingAction(r.row.state)?(f(),c(D,{key:0,type:`primary`,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.continuePay`)),1)]),_:1},8,[`onClick`])):(f(),c(D,{key:1,size:`small`,onClick:e=>p.goToDetail(r.row.id)},{default:l(()=>[t(n(p.$t(`order.button.checkDetail`)),1)]),_:1},8,[`onClick`]))])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[N,p.loading]])]),_:1})]),_:1})]),_:1}),r(b,null,{default:l(()=>[r(y,{span:10,offset:14},{default:l(()=>[e(`div`,ae,[r(M,{"current-page":p.page,"page-size":p.limit,total:p.total,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var se=w(N,[[`render`,oe],[`__scopeId`,`data-v-452d97b9`]]);export{se as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,T as o,at as s,ht as c,j as l,mt as u,ot as ee,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{n as m,t as h}from"./table--5wRXM4l.js";import{t as g}from"./card-D-4S-l7a.js";import{n as _,t as v}from"./row-B19sQ-lm.js";import{t as y}from"./empty-xCRn_5sX.js";import{t as b}from"./pagination-BxtJiMbm.js";import{t as x}from"./skeleton-CoheJz5x.js";import{t as S}from"./switch-BwiE8QKL.js";import{G as C,Ii as w,Pi as T,Ti as E,ci as D,kn as O,li as k,lt as A,ni as j,rt as M,ti as N,vi as P,yr as F}from"./index-B6pXonqJ.js";import{t as I}from"./index.es-BzwAVtoA.js";import{t as L}from"./CopyToClipboard-DSUOjJxX.js";var R=p({name:`ConsoleApplicationList`,components:{Pagination:b,CopyToClipboard:L,ElTable:h,ElRow:v,ElButton:w,ElCol:_,ElTag:T,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:m,ElCard:g,FontAwesomeIcon:I},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!O(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return O(this.$store.getters.site)?!1:P()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||F.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{E.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{E.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:A,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:M,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=D.INDIVIDUAL){return new Promise((t,n)=>{F.getAll({limit:this.limit,...e===D.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:k.USAGE,scope:e}).then(({data:n})=>{e===D.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{E.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(D.INDIVIDUAL),this.onFetchApplications(D.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){F.create({type:k.USAGE,scope:D.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(D.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}`}}}),z={class:`title`},B={key:1,class:`summary-card`},V={class:`icon-wrapper`},H={class:`label`},U={class:`value`},W={class:`description`},G={key:1,class:`flex flex-row justify-between items-center gap-3`},K={class:`summary-card min-w-0 flex-1`},q={class:`flex justify-start items-center gap-2 mb-2 w-full`},te={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},Y={class:`label`},X={class:`value`},Z={class:`description`},Q={class:`flex flex-col items-end gap-2 shrink-0`},ne={class:`copy`},re={key:0,class:`expired-at`},ie={class:`flex flex-wrap items-center justify-end gap-1`},ae={class:`application-cards block sm:hidden`},oe={class:`flex items-center gap-2 flex-wrap`},se={class:`application-card__name`},ce={class:`application-card__id`},le={class:`truncate`},ue={class:`application-card__row`},de={class:`label`},fe={class:`value`},pe={key:0,class:`application-card__row`},$={class:`label`},me={class:`value`},he={key:1,class:`application-card__row`},ge={class:`label`},_e={class:`flex items-center justify-end gap-2 mt-3`},ve={class:`pagination`};function ye(p,m,h,g,_,v){let y=s(`el-col`),b=s(`el-row`),x=s(`el-skeleton`),S=s(`font-awesome-icon`),C=s(`el-card`),w=s(`copy-to-clipboard`),T=s(`el-button`),E=s(`el-table-column`),D=s(`el-tag`),O=s(`el-switch`),k=s(`el-table`),A=s(`el-empty`),j=s(`pagination`),M=ee(`loading`);return f(),l(b,{class:`application-list`},{default:u(()=>[r(y,{span:24},{default:u(()=>[r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`h2`,z,n(p.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(b,{gutter:15,class:`mb-3`},{default:u(()=>[r(y,{md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,B,[e(`div`,V,[r(S,{icon:`fa-solid fa-cubes-stacked`})]),e(`p`,H,n(p.$t(`application.title.count`)),1),e(`p`,U,n(p.individualApplicationsTotal),1),e(`p`,W,n(p.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),p.showGlobalPayment&&p.globalApplications?.length>0?(f(),l(y,{key:0,md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,G,[e(`div`,K,[e(`div`,q,[e(`div`,te,[r(S,{icon:`fa-solid fa-wallet`})]),e(`span`,J,[t(n(p.$t(`application.field.id`))+`: `+n(p.globalApplications?.[0]?.id)+` `,1),p.globalApplications?.[0]?.id?(f(),l(w,{key:0,content:p.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,Y,n(p.$t(`application.title.globalBalance`)),1),e(`p`,X,n(p.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(p.$t(`service.unit.credits`)),1),e(`p`,Z,n(p.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,Q,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:m[0]||=e=>p.onGoUsage(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1}),p.showGlobalPayment?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:m[1]||=e=>p.onBuyMore(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[r(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:u(()=>[c((f(),l(k,{data:p.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":p.$t(`common.message.noData`)},{default:u(()=>[r(E,{prop:`id`,label:p.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ne,[r(w,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.name`),width:`180px`},{default:u(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(f(),l(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{prop:`remaining_amount`,label:p.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(p.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`used_amount`,label:p.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[e(`span`,null,n(p.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`allow_consume_global`,label:p.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.service?.type===p.serviceType.API?(f(),l(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=>p.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(f(),a(`span`,re,n(p.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(E,{fixed:`right`,width:`200px`},{default:u(a=>[e(`div`,ie,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>p.onGoUsage(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(a?.row)?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,p.loading]])]),_:1}),e(`div`,ae,[p.loading?(f(),l(x,{key:0,rows:4,animated:``})):(f(),a(o,{key:1},[p.individualApplications?.length?(f(!0),a(o,{key:1},d(p.individualApplications,o=>(f(),l(C,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:u(()=>[e(`div`,oe,[e(`span`,se,n(o?.service?.title),1),o?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(f(),l(D,{key:2,type:`info`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,ce,[e(`span`,le,n(p.$t(`application.field.id`))+`: `+n(o.id),1),r(w,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,ue,[e(`span`,de,n(p.$t(`application.field.remainingAmount`)),1),e(`span`,fe,n(p.getRemainingAmount(o)),1)]),o?.expired_at?(f(),a(`div`,pe,[e(`span`,$,n(p.$t(`application.field.expiredAt`)),1),e(`span`,me,n(p.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===p.serviceType.API?(f(),a(`div`,he,[e(`span`,ge,n(p.$t(`application.field.allowConsumeGlobal`)),1),r(O,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>p.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,_e,[r(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>p.onGoUsage(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(o)?(f(),l(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(f(),l(A,{key:0,description:p.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`div`,ve,[r(j,{"current-page":p.page,"page-size":p.limit,total:p.individualApplicationsTotal,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var be=C(R,[[`render`,ye],[`__scopeId`,`data-v-29e1e6d7`]]);export{be as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,T as o,at as s,ht as c,j as l,mt as u,ot as ee,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{n as m,t as h}from"./table-Cp0ajFJK.js";import{t as g}from"./card-D-4S-l7a.js";import{n as _,t as v}from"./row-BKdThz-n.js";import{t as y}from"./empty-xCRn_5sX.js";import{t as b}from"./pagination-BAPL2vq4.js";import{t as x}from"./skeleton-CoheJz5x.js";import{t as S}from"./switch-BmKFU2Ps.js";import{G as C,Ii as w,Pi as T,Ti as E,ci as D,kn as O,li as k,lt as A,ni as j,rt as M,ti as N,vi as P,yr as F}from"./index-CX3_OnAo.js";import{t as I}from"./index.es-CjjFtgN-.js";import{t as L}from"./CopyToClipboard-C5rXbm0J.js";var R=p({name:`ConsoleApplicationList`,components:{Pagination:b,CopyToClipboard:L,ElTable:h,ElRow:v,ElButton:w,ElCol:_,ElTag:T,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:m,ElCard:g,FontAwesomeIcon:I},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!O(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return O(this.$store.getters.site)?!1:P()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||F.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{E.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{E.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:A,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:M,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=D.INDIVIDUAL){return new Promise((t,n)=>{F.getAll({limit:this.limit,...e===D.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:k.USAGE,scope:e}).then(({data:n})=>{e===D.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{E.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(D.INDIVIDUAL),this.onFetchApplications(D.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){F.create({type:k.USAGE,scope:D.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(D.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}`}}}),z={class:`title`},B={key:1,class:`summary-card`},V={class:`icon-wrapper`},H={class:`label`},U={class:`value`},W={class:`description`},G={key:1,class:`flex flex-row justify-between items-center gap-3`},K={class:`summary-card min-w-0 flex-1`},q={class:`flex justify-start items-center gap-2 mb-2 w-full`},te={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},Y={class:`label`},X={class:`value`},Z={class:`description`},Q={class:`flex flex-col items-end gap-2 shrink-0`},ne={class:`copy`},re={key:0,class:`expired-at`},ie={class:`flex flex-wrap items-center justify-end gap-1`},ae={class:`application-cards block sm:hidden`},oe={class:`flex items-center gap-2 flex-wrap`},se={class:`application-card__name`},ce={class:`application-card__id`},le={class:`truncate`},ue={class:`application-card__row`},de={class:`label`},fe={class:`value`},pe={key:0,class:`application-card__row`},$={class:`label`},me={class:`value`},he={key:1,class:`application-card__row`},ge={class:`label`},_e={class:`flex items-center justify-end gap-2 mt-3`},ve={class:`pagination`};function ye(p,m,h,g,_,v){let y=s(`el-col`),b=s(`el-row`),x=s(`el-skeleton`),S=s(`font-awesome-icon`),C=s(`el-card`),w=s(`copy-to-clipboard`),T=s(`el-button`),E=s(`el-table-column`),D=s(`el-tag`),O=s(`el-switch`),k=s(`el-table`),A=s(`el-empty`),j=s(`pagination`),M=ee(`loading`);return f(),l(b,{class:`application-list`},{default:u(()=>[r(y,{span:24},{default:u(()=>[r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`h2`,z,n(p.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(b,{gutter:15,class:`mb-3`},{default:u(()=>[r(y,{md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,B,[e(`div`,V,[r(S,{icon:`fa-solid fa-cubes-stacked`})]),e(`p`,H,n(p.$t(`application.title.count`)),1),e(`p`,U,n(p.individualApplicationsTotal),1),e(`p`,W,n(p.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),p.showGlobalPayment&&p.globalApplications?.length>0?(f(),l(y,{key:0,md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[p.loading?(f(),l(x,{key:0})):(f(),a(`div`,G,[e(`div`,K,[e(`div`,q,[e(`div`,te,[r(S,{icon:`fa-solid fa-wallet`})]),e(`span`,J,[t(n(p.$t(`application.field.id`))+`: `+n(p.globalApplications?.[0]?.id)+` `,1),p.globalApplications?.[0]?.id?(f(),l(w,{key:0,content:p.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,Y,n(p.$t(`application.title.globalBalance`)),1),e(`p`,X,n(p.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(p.$t(`service.unit.credits`)),1),e(`p`,Z,n(p.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,Q,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:m[0]||=e=>p.onGoUsage(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1}),p.showGlobalPayment?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:m[1]||=e=>p.onBuyMore(p.globalApplications?.[0])},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[r(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:u(()=>[c((f(),l(k,{data:p.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":p.$t(`common.message.noData`)},{default:u(()=>[r(E,{prop:`id`,label:p.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ne,[r(w,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.name`),width:`180px`},{default:u(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(f(),l(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(E,{prop:`remaining_amount`,label:p.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(p.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`used_amount`,label:p.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[e(`span`,null,n(p.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(E,{prop:`allow_consume_global`,label:p.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.service?.type===p.serviceType.API?(f(),l(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=>p.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(E,{label:p.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(f(),a(`span`,re,n(p.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(E,{fixed:`right`,width:`200px`},{default:u(a=>[e(`div`,ie,[r(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>p.onGoUsage(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(a?.row)?(f(),l(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(a?.row)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,p.loading]])]),_:1}),e(`div`,ae,[p.loading?(f(),l(x,{key:0,rows:4,animated:``})):(f(),a(o,{key:1},[p.individualApplications?.length?(f(!0),a(o,{key:1},d(p.individualApplications,o=>(f(),l(C,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:u(()=>[e(`div`,oe,[e(`span`,se,n(o?.service?.title),1),o?.type===`Period`?(f(),l(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(f(),l(D,{key:1,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(f(),l(D,{key:2,type:`info`,size:`small`,round:``},{default:u(()=>[t(n(p.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,ce,[e(`span`,le,n(p.$t(`application.field.id`))+`: `+n(o.id),1),r(w,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,ue,[e(`span`,de,n(p.$t(`application.field.remainingAmount`)),1),e(`span`,fe,n(p.getRemainingAmount(o)),1)]),o?.expired_at?(f(),a(`div`,pe,[e(`span`,$,n(p.$t(`application.field.expiredAt`)),1),e(`span`,me,n(p.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===p.serviceType.API?(f(),a(`div`,he,[e(`span`,ge,n(p.$t(`application.field.allowConsumeGlobal`)),1),r(O,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>p.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,_e,[r(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>p.onGoUsage(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),p.rowCanPay(o)?(f(),l(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>p.onBuyMore(o)},{default:u(()=>[r(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),t(` `+n(p.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(f(),l(A,{key:0,description:p.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`div`,ve,[r(j,{"current-page":p.page,"page-size":p.limit,total:p.individualApplicationsTotal,onChange:p.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var be=C(R,[[`render`,ye],[`__scopeId`,`data-v-29e1e6d7`]]);export{be as default};
@@ -1 +1 @@
1
- import{A as e,Jt as t,L as n,N as r,at as i,tt as a,z as o}from"./vendor-chart-Dw-P17PN.js";import{G as s}from"./index-B6pXonqJ.js";import{t as c}from"./LocalTools-CsKzY78B.js";var l=o({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(o,s,c,l,d,f){let p=i(`local-tools-setting`);return a(),r(`div`,u,[e(`h2`,null,t(o.$t(`common.settings.localTools`)),1),n(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
1
+ import{A as e,Jt as t,L as n,N as r,at as i,tt as a,z as o}from"./vendor-chart-Dw-P17PN.js";import{G as s}from"./index-CX3_OnAo.js";import{t as c}from"./LocalTools-BdvRDPU9.js";var l=o({name:`SettingsLocalTools`,components:{LocalToolsSetting:c}}),u={class:`local-tools-page`};function d(o,s,c,l,d,f){let p=i(`local-tools-setting`);return a(),r(`div`,u,[e(`h2`,null,t(o.$t(`common.settings.localTools`)),1),n(p)])}var f=s(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f as default};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,j as l,mt as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{H as ee}from"./use-deprecated-B-uvyrTL.js";import{t as m}from"./switch-BwiE8QKL.js";import{G as te,Gi as ne,Ii as h,Pi as g,br as _,gi as v,pi as y,q as b}from"./index-B6pXonqJ.js";import{t as x}from"./index.es-BzwAVtoA.js";var S=p({name:`LocalToolsSetting`,components:{ElButton:h,ElTag:g,ElSwitch:m,ElInput:ne,FontAwesomeIcon:x},data(){return{Plus:ee,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,xhsSkill:null,xhsLoading:!1,xhsInstalling:!1,xhsError:``,onFocus:null,cuOff:null,a11yPoll:null,refreshingA11y:!1}},computed:{desktop(){return!!b()},android(){return v()},canInstallXhs(){return this.a11yEnabled&&this.computerUse}},async mounted(){let e=b();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
1
+ import{r as e}from"./rolldown-runtime--c01j_DQ.js";import{A as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,j as l,mt as u,rt as d,tt as f,z as p}from"./vendor-chart-Dw-P17PN.js";import{H as ee}from"./use-deprecated-B-uvyrTL.js";import{t as m}from"./switch-BmKFU2Ps.js";import{G as te,Gi as ne,Ii as h,Pi as g,br as _,gi as v,pi as y,q as b}from"./index-CX3_OnAo.js";import{t as x}from"./index.es-CjjFtgN-.js";var S=p({name:`LocalToolsSetting`,components:{ElButton:h,ElTag:g,ElSwitch:m,ElInput:ne,FontAwesomeIcon:x},data(){return{Plus:ee,roots:[],tools:[],mcpServers:[],mcpUid:0,mcpStatuses:[],mcpBusy:null,savingMcp:!1,mcpSavedTip:!1,mcpError:``,grants:null,perm:null,computerUse:!1,computerTools:[],computerGrants:{},cuBusy:null,builtinTools:[],toolGrants:{},builtinBusy:null,savingCU:!1,preauthorizing:!1,saving:!1,savedTip:!1,a11yEnabled:!1,xhsSkill:null,xhsLoading:!1,xhsInstalling:!1,xhsError:``,onFocus:null,cuOff:null,a11yPoll:null,refreshingA11y:!1}},computed:{desktop(){return!!b()},android(){return v()},canInstallXhs(){return this.a11yEnabled&&this.computerUse}},async mounted(){let e=b();if(!e)return;let t=await e.getConfig();this.roots=t.roots,this.computerUse=t.computerUse===!0,this.mcpServers=(t.mcp??[]).map(e=>({_uid:this.mcpUid++,id:e.id,command:e.command,argsText:(e.args??[]).join(`
2
2
  `),envText:Object.entries(e.env??{}).map(([e,t])=>`${e}=${t}`).join(`
3
3
  `),enabled:e.enabled!==!1})),this.mcpStatuses=await e.mcp?.status()??[],this.tools=(await e.listTools()).map(e=>e.name),this.computerTools=await e.computerTools?.()??[],this.builtinTools=await e.builtinTools?.()??[];let n=await e.perm?.status();n?.mac&&(this.perm=n),await this.loadGrants(),this.android&&(await this.refreshA11y(),this.fetchXhsSkill(),this.onFocus=()=>{document.visibilityState===`visible`&&this.refreshA11y()},document.addEventListener(`visibilitychange`,this.onFocus),this.a11yPoll=window.setInterval(()=>{document.visibilityState===`visible`&&this.refreshA11y()},3e3)),this.cuOff=e.onComputerUseDisabled?.(()=>{this.computerUse=!1})??null},beforeUnmount(){this.cuOff?.(),this.onFocus&&document.removeEventListener(`visibilitychange`,this.onFocus),this.a11yPoll&&clearInterval(this.a11yPoll)},methods:{async refreshA11y(){if(!this.refreshingA11y){this.refreshingA11y=!0;try{let e=await b()?.perm?.status();this.a11yEnabled=e?.accessibility===!0}finally{this.refreshingA11y=!1}}},async openAndroidAccessibility(){await b()?.perm?.openPane(`accessibility`)},async fetchXhsSkill(){this.xhsLoading=!0,this.xhsError=``;try{let e=await _.get(`/skills/`,{baseURL:`${y()}/api/v1`,params:{q:`xhs-dm`,limit:10}}),t=Array.isArray(e.data?.items)?e.data.items:[];this.xhsSkill=t.find(e=>e.identifier?.endsWith(`/xhs-dm`))??null}catch(e){console.warn(`[LocalTools] fetch xhs skill failed`,e),this.xhsSkill=null,this.xhsError=this.$t(`common.settings.localToolsAndroidSkillsLoadFailed`)}finally{this.xhsLoading=!1}},async installXhs(){let e=this.xhsSkill;if(!(!e||e.installed)){this.xhsInstalling=!0,this.xhsError=``;try{await _.post(`/skills/${e.id}/install/`,{},{baseURL:`${y()}/api/v1`}),e.installed=!0}catch(t){t?.response?.status===409?e.installed=!0:this.xhsError=this.$t(`common.settings.localToolsAndroidSkillsInstallFailed`)}finally{this.xhsInstalling=!1}}},async loadGrants(){let e=b();if(!e?.grants){this.grants=null;return}let t=await e.grants.list(),n={},r={},i=new Set(this.builtinTools.map(e=>e.name)),a=[];for(let e of t){if(e.startsWith(`computer.`)&&!e.includes(`:`)){n[e]=!0;continue}if(!e.includes(`:`)&&i.has(e)){r[e]=!0;continue}let t=e.indexOf(`:{`),o=t>=0?t:e.indexOf(`:`);a.push({key:e,name:o>=0?e.slice(0,o):e,input:o>=0?e.slice(o+1):``})}this.computerGrants=n,this.toolGrants=r,this.grants=a},async addFolder(){let e=await b()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,k as c,mt as l,tt as u,z as d}from"./vendor-chart-Dw-P17PN.js";import{t as f}from"./Navigator-Db2wTQZ-.js";import{t as p}from"./checkbox-ChInsWN4.js";import{t as m}from"./divider-BNWJAaA2.js";import"./constants-BjP62jX_.js";import{G as h,Ii as g,Oi as _,Ti as v,an as y,ci as b,di as x,li as S,mi as C,yr as w}from"./index-B6pXonqJ.js";import{t as T}from"./Status-CijUE5CQ.js";var E=d({name:`ApplicationConfirm`,components:{ElDialog:_,ElDivider:m,ElCheckbox:p,ElButton:g},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:C,onApply(){if(!this.checked){v.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(i,a,c,d,f,p){let m=o(`el-divider`),h=o(`el-checkbox`),g=o(`el-button`),_=o(`el-dialog`);return u(),s(_,{"model-value":i.visible,width:`500px`,title:i.$t(`application.message.welcome`),center:``,onClose:a[1]||=e=>i.$emit(`update:visible`,!1)},{default:l(()=>[e(`div`,D,[e(`p`,O,n(i.$t(`application.message.notApplied`)),1),r(m,{class:`my-2`}),e(`div`,k,[r(h,{modelValue:i.checked,"onUpdate:modelValue":a[0]||=e=>i.checked=e,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),e(`span`,A,n(i.$t(`application.message.readPolicy`)),1),e(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:i.getBaseUrlPlatform()+`/terms`},` \xA0`+n(i.$t(`application.message.policy`)),9,j)]),r(g,{round:``,type:`primary`,onClick:i.onApply},{default:l(()=>[t(n(i.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=h(E,[[`render`,M]]),P=15e3,F=d({name:`LayoutMain`,components:{Navigator:f,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:c(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=y(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await w.create({type:S.USAGE,scope:b.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`):v.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0),n=this.$store.state.site?.title||`AceData`;v({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t,brand:n}):this.$t(`application.message.welcomeNoCredits`,{brand:n}),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(e,t,n,c,l,d){let f=o(`router-view`),p=o(`navigator`),m=o(`application-status`),h=o(`application-confirm`);return u(),a(`div`,I,[r(f,{class:`main`}),r(p,{class:`navigator`,direction:e.mobile?`row`:`column`},null,8,[`direction`]),e.application?(u(),s(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:e.application,applications:e.applications,"show-price":!1,authenticated:!!e.$store.state.token.access,service:e.service,onSelect:t[0]||=t=>e.$store.dispatch(`${e.appName}/setApplication`,t)},null,8,[`application`,`applications`,`authenticated`,`service`])):i(``,!0),r(h,{modelValue:e.applying,"onUpdate:modelValue":t[1]||=t=>e.applying=t,modelModifiers:{visible:!0},onApply:e.onApply},null,8,[`modelValue`,`onApply`])])}var R=h(F,[[`render`,L],[`__scopeId`,`data-v-334ded1d`]]);export{R as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,k as c,mt as l,tt as u,z as d}from"./vendor-chart-Dw-P17PN.js";import{t as f}from"./Navigator-B92ZL5ZS.js";import{t as p}from"./checkbox-ChInsWN4.js";import{t as m}from"./divider-BNWJAaA2.js";import"./constants-BjP62jX_.js";import{G as h,Ii as g,Oi as _,Ti as v,an as y,ci as b,di as x,li as S,mi as C,yr as w}from"./index-CX3_OnAo.js";import{t as T}from"./Status-V9Ps8wO-.js";var E=d({name:`ApplicationConfirm`,components:{ElDialog:_,ElDivider:m,ElCheckbox:p,ElButton:g},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:C,onApply(){if(!this.checked){v.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(i,a,c,d,f,p){let m=o(`el-divider`),h=o(`el-checkbox`),g=o(`el-button`),_=o(`el-dialog`);return u(),s(_,{"model-value":i.visible,width:`500px`,title:i.$t(`application.message.welcome`),center:``,onClose:a[1]||=e=>i.$emit(`update:visible`,!1)},{default:l(()=>[e(`div`,D,[e(`p`,O,n(i.$t(`application.message.notApplied`)),1),r(m,{class:`my-2`}),e(`div`,k,[r(h,{modelValue:i.checked,"onUpdate:modelValue":a[0]||=e=>i.checked=e,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),e(`span`,A,n(i.$t(`application.message.readPolicy`)),1),e(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:i.getBaseUrlPlatform()+`/terms`},` \xA0`+n(i.$t(`application.message.policy`)),9,j)]),r(g,{round:``,type:`primary`,onClick:i.onApply},{default:l(()=>[t(n(i.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=h(E,[[`render`,M]]),P=15e3,F=d({name:`LayoutMain`,components:{Navigator:f,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:c(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===x.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=y(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await w.create({type:S.USAGE,scope:b.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`):v.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0),n=this.$store.state.site?.title||`AceData`;v({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t,brand:n}):this.$t(`application.message.welcomeNoCredits`,{brand:n}),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(e,t,n,c,l,d){let f=o(`router-view`),p=o(`navigator`),m=o(`application-status`),h=o(`application-confirm`);return u(),a(`div`,I,[r(f,{class:`main`}),r(p,{class:`navigator`,direction:e.mobile?`row`:`column`},null,8,[`direction`]),e.application?(u(),s(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:e.application,applications:e.applications,"show-price":!1,authenticated:!!e.$store.state.token.access,service:e.service,onSelect:t[0]||=t=>e.$store.dispatch(`${e.appName}/setApplication`,t)},null,8,[`application`,`applications`,`authenticated`,`service`])):i(``,!0),r(h,{modelValue:e.applying,"onUpdate:modelValue":t[1]||=t=>e.applying=t,modelModifiers:{visible:!0},onApply:e.onApply},null,8,[`modelValue`,`onApply`])])}var R=h(F,[[`render`,L],[`__scopeId`,`data-v-334ded1d`]]);export{R as default};