@acedatacloud/nexior 3.329.48 → 3.329.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ApiCodeButton-CUd4TC1Q.js → ApiCodeButton-BQdstZ9o.js} +1 -1
- package/dist/assets/{Artifacts-C6tJd1rJ.js → Artifacts-BXx9uaT7.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-BAk3vrry.js → AskUserQuestionCard-Cj3nY_7c.js} +1 -1
- package/dist/assets/{AudioPreview-B79qsQPJ.js → AudioPreview-4VgTsOeE.js} +1 -1
- package/dist/assets/{Auth-DTmylYTe.js → Auth-BMD_NYVt.js} +1 -1
- package/dist/assets/{Bare-BJDGc32N.js → Bare-6aTD3lUo.js} +1 -1
- package/dist/assets/{BotPlaceholder-BOpg76Oi.js → BotPlaceholder-Ck1mjnMM.js} +1 -1
- package/dist/assets/{BottomFooter-RMwOJXSt.js → BottomFooter-B3N8NY2w.js} +1 -1
- package/dist/assets/{Callback-3nPgcXDz.js → Callback-BbUWB7Qq.js} +1 -1
- package/dist/assets/{CodeSnippet-0Kb5PVy-.js → CodeSnippet-B2MmQK0Q.js} +1 -1
- package/dist/assets/{Console-Rxv19dQs.js → Console-CmINe76B.js} +1 -1
- package/dist/assets/{Consumption-CbSuHo-B.js → Consumption-CqnV6zKQ.js} +1 -1
- package/dist/assets/{Conversation-T41QcOYi.js → Conversation-Bq-nAp6V.js} +1 -1
- package/dist/assets/{Conversation-BKNU0Jp5.js → Conversation-BsiJIV_u.js} +1 -1
- package/dist/assets/{CopyToClipboard-DksVZ0H5.js → CopyToClipboard-rmORTzYc.js} +1 -1
- package/dist/assets/{Detail-YFjJT26d.js → Detail-CZtz-Wcz.js} +2 -2
- package/dist/assets/{Extra-B568Ycam.js → Extra-B1YqTXxc.js} +1 -1
- package/dist/assets/{FilePreview-kw-4u9Eq.js → FilePreview-CZc1NuMc.js} +1 -1
- package/dist/assets/{Hailuo-CoRkX3p_.js → Hailuo-78HzK7nv.js} +1 -1
- package/dist/assets/{History-D3FmC_PH.js → History-zRWsHwHR.js} +1 -1
- package/dist/assets/{ImagePreview-CMBKb-1b.js → ImagePreview-C_BsIyhE.js} +1 -1
- package/dist/assets/{ImageWrapper-ZRo3oVgf.js → ImageWrapper-DP_qfnZ_.js} +1 -1
- package/dist/assets/{Index-SNaausRB.js → Index-4Hwq3yoh.js} +1 -1
- package/dist/assets/{Index-DfWd9rzk.js → Index-BBWWYUZ1.js} +1 -1
- package/dist/assets/{Index-Cjlk9fby.js → Index-BCqxX3h7.js} +1 -1
- package/dist/assets/{Index-CnOpDNO7.js → Index-BHjSVnXl.js} +1 -1
- package/dist/assets/{Index-BOse1S2w.js → Index-BIogE1eS.js} +1 -1
- package/dist/assets/{Index-z4iIqNcQ.js → Index-BZ5yUtOl.js} +1 -1
- package/dist/assets/{Index-DgNnjtEb.js → Index-BgRh-iCb.js} +1 -1
- package/dist/assets/{Index-CJL2dVdR.js → Index-Bhkm_Q20.js} +1 -1
- package/dist/assets/{Index-DUpUmEwQ.js → Index-BwTiAV-E.js} +1 -1
- package/dist/assets/{Index-CDP6SULR.js → Index-BwWnMfeg.js} +1 -1
- package/dist/assets/{Index-DlxsUpUf.css → Index-C0qrnEHX.css} +1 -1
- package/dist/assets/{Index-Bq4Z8Lbg.js → Index-CAlqNXz8.js} +1 -1
- package/dist/assets/{Index-zWGsOUdx.js → Index-CVgTp_7R.js} +1 -1
- package/dist/assets/{Index-Dr8eRKiz.js → Index-Ccfg9u6M.js} +1 -1
- package/dist/assets/{Index-Bc_cAHcc.js → Index-Cg8eVS8s.js} +1 -1
- package/dist/assets/{Index-BY56E9wv.js → Index-CgMihG4b.js} +1 -1
- package/dist/assets/{Index-m_oLdH4j.js → Index-Cp9ocM8P.js} +1 -1
- package/dist/assets/{Index-97Ht0gLO.js → Index-CvbVThSE.js} +1 -1
- package/dist/assets/{Index-DKsOjaVB.js → Index-D1aPk8iT.js} +1 -1
- package/dist/assets/{Index-BV7_-jIc.js → Index-DCWOzRNM.js} +1 -1
- package/dist/assets/{Index-CgMnnBPg.js → Index-DHVxf1gH.js} +1 -1
- package/dist/assets/{Index-BnJqhsiA.css → Index-DQYsJlw6.css} +1 -1
- package/dist/assets/Index-DRLwa_7m.js +1 -0
- package/dist/assets/{Index-aGsKYlRu.js → Index-DWjZp31p.js} +1 -1
- package/dist/assets/{Index-DporlAKp.js → Index-Dl8LX5Vd.js} +1 -1
- package/dist/assets/{Index-DTa_wwWT.js → Index-DnBgBblJ.js} +1 -1
- package/dist/assets/{Index-ErXi8zLF.js → Index-DxoeQdsk.js} +1 -1
- package/dist/assets/{Index-Cv-ZIV7e.js → Index-E_S3tTFO.js} +1 -1
- package/dist/assets/{Index-DPjlDjX_.js → Index-TU-sLpQv.js} +1 -1
- package/dist/assets/{Index-DsSJB2bN.css → Index-Y-iZg6hM.css} +1 -1
- package/dist/assets/{Index-BwudR60x.js → Index-gwmFRkye.js} +1 -1
- package/dist/assets/{Index-Cm9atCUl.js → Index-jbctdNGA.js} +1 -1
- package/dist/assets/{Invitees-B1MEzafV.js → Invitees-pcLaY6el.js} +1 -1
- package/dist/assets/{List-CjNAVR6Y.js → List-BVEGFvMm.js} +1 -1
- package/dist/assets/{List-BspjYhhX.js → List-CQ7FyJVe.js} +1 -1
- package/dist/assets/{List-D2VYnD70.js → List-RubkIktz.js} +1 -1
- package/dist/assets/{LocalTools-Cn6y81Dt.js → LocalTools-BEtyOdPc.js} +1 -1
- package/dist/assets/{LocalTools-BlvIiyES.js → LocalTools-CKMMkNof.js} +1 -1
- package/dist/assets/{Main-DCVEjQlX.js → Main-BRG3fgFT.js} +1 -1
- package/dist/assets/{Message-p-0ZaZ3D.js → Message-h9svHwcT.js} +1 -1
- package/dist/assets/{Model-CSt9IxHH.js → Model-Buv5RDTA.js} +1 -1
- package/dist/assets/{Navigator-mrUaF5Xu.js → Navigator-CDn1-zJX.js} +3 -3
- package/dist/assets/{NotFound-ebgMmCMf.js → NotFound-B9buoNpm.js} +1 -1
- package/dist/assets/{Pay-BLwY_ZgY.js → Pay-D2XzBXBl.js} +1 -1
- package/dist/assets/{Player-CKf4KxUi.js → Player-CF2KaNMU.js} +1 -1
- package/dist/assets/{PromptTextarea-BKlwJ34c.js → PromptTextarea-DbxCyFDP.js} +1 -1
- package/dist/assets/{RealtimeCall-Dibrova3.js → RealtimeCall-BBBq2XHw.js} +1 -1
- package/dist/assets/{ScheduledTasks-CCgDV0mI.js → ScheduledTasks-CqO1-HAJ.js} +1 -1
- package/dist/assets/{Status-CyNJSpU-.js → Status-cFY4YqIR.js} +1 -1
- package/dist/assets/{Subscribe-BIGEu9ci.js → Subscribe-EP-3GWh9.js} +1 -1
- package/dist/assets/{TabSwitcher-BhrQkSUX.js → TabSwitcher-B99C8gb3.js} +1 -1
- package/dist/assets/{Tts-CKa0tK3j.js → Tts-qDiiNvEW.js} +1 -1
- package/dist/assets/{VideoPlayer-CChGJzkB.js → VideoPlayer-BYVFHaXG.js} +1 -1
- package/dist/assets/{alert-DqN2o6YF.js → alert-x8mYlhuj.js} +1 -1
- package/dist/assets/arrow-down-D8ZQ5fMG.js +1 -0
- package/dist/assets/{arrow-down-wide-narrow-Buoufpkp.js → arrow-down-wide-narrow-Kp7dCPTK.js} +1 -1
- package/dist/assets/arrow-left-B9DAQ5Lp.js +1 -0
- package/dist/assets/arrow-right-CY4eAHGV.js +1 -0
- package/dist/assets/arrow-up-BoWYVqpg.js +1 -0
- package/dist/assets/{avatar-C67xeXe2.js → avatar-xY62EGRe.js} +1 -1
- package/dist/assets/{basic-mfZYbhPD.js → basic-Bg9zZwJ6.js} +1 -1
- package/dist/assets/{box-vQGTyK9k.js → box-BEZ5ejlY.js} +1 -1
- package/dist/assets/{boxes-CJUZpl0g.js → boxes-DDscYXMD.js} +1 -1
- package/dist/assets/{brain-2ACSFiZj.js → brain-B939VD09.js} +1 -1
- package/dist/assets/{chart-no-axes-combined-CuDdWnPI.js → chart-no-axes-combined-CpGOEj7A.js} +1 -1
- package/dist/assets/{chat-C-VJhlQg.js → chat-Rfajry4H.js} +1 -1
- package/dist/assets/check-By7SyT1y.js +1 -0
- package/dist/assets/chevron-down-D_HKprqu.js +1 -0
- package/dist/assets/chevron-right-BIDd1rZo.js +1 -0
- package/dist/assets/circle-check-CxdRmME4.js +1 -0
- package/dist/assets/clock-C4q08wwy.js +1 -0
- package/dist/assets/{codingBridge-DQeEu9WX.js → codingBridge-EBF8j-ix.js} +1 -1
- package/dist/assets/{codingBridgeNotify-B5fAwLEm.js → codingBridgeNotify-CXm1OPK1.js} +2 -2
- package/dist/assets/{coins-BhXlFnOf.js → coins-BTu5thzB.js} +1 -1
- package/dist/assets/{collapse-Dy8fIdv6.js → collapse-Dr4wi752.js} +1 -1
- package/dist/assets/{createTaskActions-DJGgfJN0.js → createTaskActions-CT0k2Xot.js} +1 -1
- package/dist/assets/{digitalhuman-Dc3Gk5rX.js → digitalhuman-OXBSy9dw.js} +1 -1
- package/dist/assets/{dollar-sign-DiY9-ZBQ.js → dollar-sign-BkrT7-Sj.js} +1 -1
- package/dist/assets/{download-CI5Jd4FJ.js → download-DVE_LhWD.js} +1 -1
- package/dist/assets/{drawer-Bu5U_TlI.js → drawer-D6k00NQl.js} +1 -1
- package/dist/assets/{dropdown-69AAWB19.js → dropdown-CLTki_ih.js} +1 -1
- package/dist/assets/{dropdown-CuFpphV8.js → dropdown-VHkvYoL4.js} +1 -1
- package/dist/assets/{ellipsis-uGl7Jieg.js → ellipsis-Cob9XmBW.js} +1 -1
- package/dist/assets/{esm-C2Ej_bhP.js → esm-BUfIiLZD.js} +1 -1
- package/dist/assets/{esm-DLnqcqcl.js → esm-CY9pk-jr.js} +3 -3
- package/dist/assets/{esm-CSjv2Pg2.js → esm-CqCk5Tda.js} +1 -1
- package/dist/assets/{esm-BO6NqMVn.js → esm-DAm7ZZSK.js} +2 -2
- package/dist/assets/{esm-BGcapq40.js → esm-EEjikD0b.js} +2 -2
- package/dist/assets/{esm-i-VNWaST.js → esm-Ml658jQt.js} +1 -1
- package/dist/assets/esm-veBslxpk.js +1 -0
- package/dist/assets/{external-link-iO9U5G_p.js → external-link-RIX3x3j6.js} +1 -1
- package/dist/assets/{eye-KPLUUK_j.js → eye-KUfFEUJZ.js} +1 -1
- package/dist/assets/{file-output-BOWkai4z.js → file-output-BHblcI1H.js} +1 -1
- package/dist/assets/{file-text-GbKKvGZq.js → file-text-DtBp2Tgm.js} +1 -1
- package/dist/assets/{fish-CJjBkxHA.js → fish-KFRHkqIm.js} +1 -1
- package/dist/assets/{flux-MU-Twzwq.js → flux-CrBEaL-w.js} +1 -1
- package/dist/assets/{folder-WCye0Ois.js → folder-DhGoROwY.js} +1 -1
- package/dist/assets/gauge-CCJDsVbm.js +1 -0
- package/dist/assets/{globe-gky47OHr.js → globe-Cr0XXyWC.js} +1 -1
- package/dist/assets/{grokvideo-CD4qvucx.js → grokvideo-CFWGzqnP.js} +1 -1
- package/dist/assets/{hailuo-B8E1zt6U.js → hailuo-CQgBvRrN.js} +1 -1
- package/dist/assets/{headphones-DY1Xvny6.js → headphones-DjCXtWtW.js} +1 -1
- package/dist/assets/{history-BkkJL8mx.js → history-D7t11VI6.js} +1 -1
- package/dist/assets/{image-acE7lpK-.js → image-D9hVe2An.js} +1 -1
- package/dist/assets/{index-C16Hj9CP.js → index-h4BcqHjk.js} +3 -3
- package/dist/assets/{index.browser.esm-D6T-JSJl.js → index.browser.esm-Cj1UsO96.js} +1 -1
- package/dist/assets/{index.es-zdAKJtm2.js → index.es-Cbeh0C71.js} +1 -1
- package/dist/assets/{info-xDtf26MC.js → info-7QlewFBX.js} +1 -1
- package/dist/assets/{input-number-sKcZZmDs.js → input-number-CZgZJsF5.js} +1 -1
- package/dist/assets/{key-round-DNrwciWi.js → key-round-4vLoXXxg.js} +1 -1
- package/dist/assets/{kling-IgC9Uc_D.js → kling-DQuSLQvP.js} +1 -1
- package/dist/assets/{languages-BlC_iryL.js → languages-yHenK2uT.js} +1 -1
- package/dist/assets/{laptop-STm5xUdN.js → laptop-DI_e4ODd.js} +1 -1
- package/dist/assets/{lightbulb-DOomeZMy.js → lightbulb-Cbx7aB6y.js} +1 -1
- package/dist/assets/{link-W5DEJ7Uk.js → link-HE8UnMl5.js} +1 -1
- package/dist/assets/loader-circle-HkqnQLcn.js +1 -0
- package/dist/assets/{luma-wGSGreEF.js → luma-D7DLk-Ge.js} +1 -1
- package/dist/assets/{maestro-CZu9r2f7.js → maestro-C5srumVZ.js} +1 -1
- package/dist/assets/{mail-CBnj3cVy.js → mail-Dg-OWp-W.js} +1 -1
- package/dist/assets/{message-circle-UEvfGSS-.js → message-circle-_lAyr9pO.js} +1 -1
- package/dist/assets/{mic-CsONQRhm.js → mic-BwlJidQk.js} +1 -1
- package/dist/assets/{midjourney-BYA7_uqE.js → midjourney-BGP9e45v.js} +1 -1
- package/dist/assets/{mobileLocalExec-B6PSMW1Q.js → mobileLocalExec-D_TlyyLb.js} +2 -2
- package/dist/assets/{mouse-pointer-2-B9t6O3Gg.js → mouse-pointer-2-9NtAMIrw.js} +1 -1
- package/dist/assets/music-2-vR9_vMzq.js +1 -0
- package/dist/assets/{nanobanana-Y1Z-gHXw.js → nanobanana-BP0ebcOC.js} +1 -1
- package/dist/assets/{omni-DUL7IPNp.js → omni-Y3pm7jFq.js} +1 -1
- package/dist/assets/{openaiimage-5wEFa5-C.js → openaiimage-DiJr8Nvu.js} +1 -1
- package/dist/assets/{pagination-bKCTJxMn.js → pagination-Dj04WTpX.js} +1 -1
- package/dist/assets/{pagination-Bx8kvO1A.js → pagination-jAKTlMGg.js} +1 -1
- package/dist/assets/{palette-ZBmOOf30.js → palette-C3ujZ8BC.js} +1 -1
- package/dist/assets/{paperclip-BbionhTy.js → paperclip-B0nw-Qaf.js} +1 -1
- package/dist/assets/{pause-D1NbBC3F.js → pause-CG0UDByu.js} +1 -1
- package/dist/assets/{pencil-BK6Gy5V2.js → pencil-nTiWk3T7.js} +1 -1
- package/dist/assets/{pika-gcoIcs7I.js → pika-CoPaIOh6.js} +1 -1
- package/dist/assets/{pixverse-Ce74efEs.js → pixverse-CxqpkBPT.js} +1 -1
- package/dist/assets/play-tg4PKtQy.js +1 -0
- package/dist/assets/plus-BCeJVIcm.js +1 -0
- package/dist/assets/{popover-CktFYVov.js → popover-Dmn1Ifdn.js} +1 -1
- package/dist/assets/{producer-B4Cod3RR.js → producer-oNZVnb-3.js} +1 -1
- package/dist/assets/{qrart-BXdJvg5k.js → qrart-ISCRU-QQ.js} +1 -1
- package/dist/assets/{realtime-BU-yTh0g.js → realtime-COGDAX4r.js} +1 -1
- package/dist/assets/{refresh-cw-B14q5VI2.js → refresh-cw-CJowjzuP.js} +1 -1
- package/dist/assets/rotate-ccw-Bvzx9o_5.js +1 -0
- package/dist/assets/rotate-cw-BUhTjOZ5.js +1 -0
- package/dist/assets/{row-SUcM9Qp5.js → row-Dbo9j6N1.js} +1 -1
- package/dist/assets/search-DvJzLqVd.js +1 -0
- package/dist/assets/{seedance-DK6IFr-i.js → seedance-CamZk3VW.js} +1 -1
- package/dist/assets/{seedream-D7SB4_Cd.js → seedream-B7oXMpvP.js} +1 -1
- package/dist/assets/{select-DZCaWKok.js → select-DuspBjxM.js} +1 -1
- package/dist/assets/{serp-CmkITspi.js → serp-CdhyW3n_.js} +1 -1
- package/dist/assets/{shield-CirL9rYD.js → shield-DN9xtQPd.js} +1 -1
- package/dist/assets/{shuffle-DbGtBwoV.js → shuffle-CzWQZh64.js} +1 -1
- package/dist/assets/{slider-CpiDxKBE.js → slider-D13c5Wz0.js} +1 -1
- package/dist/assets/{sliders-horizontal-DsxTazyi.js → sliders-horizontal-CR4fCrO-.js} +1 -1
- package/dist/assets/{solana-wallets-a1MC468A.js → solana-wallets-BoX5DsoZ.js} +2 -2
- package/dist/assets/{solana-wallets-vue-CfTx3YZk.js → solana-wallets-vue-uxxHunFw.js} +1 -1
- package/dist/assets/{sora-iw8M6y1-.js → sora-COeAT6jk.js} +1 -1
- package/dist/assets/square-CLPs_q8l.js +1 -0
- package/dist/assets/{suno-CWtgvby0.js → suno-BB2-8ySl.js} +1 -1
- package/dist/assets/{switch-CjwwXJJ-.js → switch-DGjAGv1c.js} +1 -1
- package/dist/assets/{table-CLwvS0sW.js → table-C4lekjnN.js} +1 -1
- package/dist/assets/{tabs-8UTEJ0Bg.js → tabs-CYLrPpdu.js} +1 -1
- package/dist/assets/{tag-C4dI4B-9.js → tag-DvqDd89_.js} +1 -1
- package/dist/assets/{taskDrawerMixin-CrFn6ABi.js → taskDrawerMixin-D23gnPya.js} +1 -1
- package/dist/assets/terminal-BUNlX6R9.js +1 -0
- package/dist/assets/{time-picker-CXAZNY2Q.js → time-picker-cYF7587-.js} +1 -1
- package/dist/assets/{tooltip-CI4l4DOg.js → tooltip-O0jUmp8_.js} +1 -1
- package/dist/assets/{trash-2-GVGOLvcA.js → trash-2-D-aX1rGS.js} +1 -1
- package/dist/assets/{triangle-alert-DPU3gv8f.js → triangle-alert-BC93Xt4w.js} +1 -1
- package/dist/assets/{upload-DOmU-ynH.js → upload-BNaHShNL.js} +1 -1
- package/dist/assets/{upload-CbGx0SCQ.js → upload-CP3jRoVn.js} +1 -1
- package/dist/assets/user-B7nRG0YD.js +1 -0
- package/dist/assets/{veo-Bf28OHSd.js → veo-qk8-WnH2.js} +1 -1
- package/dist/assets/{video-CFaTzy2y.js → video-PsDBoU-r.js} +1 -1
- package/dist/assets/{volume-2-Cbn1UYkN.js → volume-2-B2MwCpKu.js} +1 -1
- package/dist/assets/{wallet-DVK5OHZ5.js → wallet-DbeMlRJW.js} +1 -1
- package/dist/assets/{wan-VUasMXOX.js → wan-AEsiNRwZ.js} +1 -1
- package/dist/assets/{wand-sparkles-pGeyau5p.js → wand-sparkles-Cfgyd-ZM.js} +1 -1
- package/dist/assets/{web-BdgXwNzm.js → web-8xFFHy8W.js} +1 -1
- package/dist/assets/{web-B37ni2dJ.js → web-Bmmi65iA.js} +1 -1
- package/dist/assets/{web-BaDJ-1i-.js → web-C96dukF7.js} +1 -1
- package/dist/assets/{web-CrbPOLY_.js → web-CgBdBzkx.js} +1 -1
- package/dist/assets/{web-BWqgHW3j.js → web-VFMYFBBk.js} +1 -1
- package/dist/assets/{webextrator-DbNwwNvU.js → webextrator-WsM58C2G.js} +1 -1
- package/dist/assets/{zap-B_H9Zf2S.js → zap-Cnylgx57.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/Index-tJcqojay.js +0 -1
- package/dist/assets/arrow-down-DUIM87dr.js +0 -1
- package/dist/assets/arrow-left-Bk7Iz8yw.js +0 -1
- package/dist/assets/arrow-right-DSS0Q7Mo.js +0 -1
- package/dist/assets/arrow-up-3Qhg_QJg.js +0 -1
- package/dist/assets/check-C0Gs-lfy.js +0 -1
- package/dist/assets/chevron-down-BBmFbMp3.js +0 -1
- package/dist/assets/chevron-right-DCcsG5ir.js +0 -1
- package/dist/assets/circle-check-DHZcjMim.js +0 -1
- package/dist/assets/clock-C90hJcW0.js +0 -1
- package/dist/assets/esm-DAugeQPl.js +0 -1
- package/dist/assets/gauge-Cufmm3HO.js +0 -1
- package/dist/assets/loader-circle-BAN1HyBA.js +0 -1
- package/dist/assets/music-2-CWMjS73t.js +0 -1
- package/dist/assets/play-umucbTo-.js +0 -1
- package/dist/assets/plus-DCYr1oKd.js +0 -1
- package/dist/assets/rotate-ccw-DYfFyP6x.js +0 -1
- package/dist/assets/rotate-cw-Bx7w_ZpJ.js +0 -1
- package/dist/assets/search-CriN9waJ.js +0 -1
- package/dist/assets/square-DLpzzDVj.js +0 -1
- package/dist/assets/terminal-CRSsf52D.js +0 -1
- package/dist/assets/user-C4S922yU.js +0 -1
|
@@ -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-DZCaWKok.js";import{t as _}from"./upload-DOmU-ynH.js";import{t as v}from"./tooltip-CI4l4DOg.js";import{t as y}from"./alert-DqN2o6YF.js";import{t as b}from"./clock-C90hJcW0.js";import{t as x}from"./CopyToClipboard-DksVZ0H5.js";import{r as S,t as C}from"./PromptTextarea-BKlwJ34c.js";import{t as w}from"./info-xDtf26MC.js";import{t as T}from"./triangle-alert-DPU3gv8f.js";import{t as E}from"./wand-sparkles-pGeyau5p.js";import{er as D}from"./constants-D-3QKDN1.js";import{$t as O,Ai as k,Bt as A,E as j,Ht as M,Pn as ee,Vt as te,Wt as N,ei as P,gi as F,mr as I,ri as L,zt as R}from"./index-C16Hj9CP.js";import{t as z}from"./ImagePreview-CMBKb-1b.js";import{t as B}from"./Consumption-CbSuHo-B.js";import{a as V,n as H,r as U,t as W}from"./pagination-Bx8kvO1A.js";import{t as G}from"./VideoPlayer-CChGJzkB.js";import{t as K}from"./ApiCodeButton-CUd4TC1Q.js";import{t as q}from"./BotPlaceholder-BOpg76Oi.js";import{t as J}from"./Hailuo-CoRkX3p_.js";var Y=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||=D}}),X={class:`field`},Z={class:`title font-bold`},Q={class:`float-left`};function ne(t,n,r,o,m,h){let g=l(`el-option`),_=l(`el-select`);return p(),s(`div`,X,[e(`h2`,Z,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`,Q,i(t.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var re=j(Y,[[`render`,ne],[`__scopeId`,`data-v-a768fbd9`]]),ie=m({name:`StartImageUrlInput`,components:{ElUpload:_,ElButton:k,InfoIcon:V,ImagePreview:z},mixins:[M,A],data(){return{fileList:[],uploadUrl:L()+`/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(){F.warning(this.$t(`hailuo.message.uploadStartImageExceed`))},onError(){F.error(this.$t(`hailuo.message.uploadStartImageError`))},async onRemove(){F.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()}}}),ae={class:`relative`},oe={class:`flex justify-between`},se={class:`flex justify-start items-center`},ce={class:`text-sm font-bold`};function le(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`,ae,[e(`div`,oe,[e(`div`,se,[e(`span`,ce,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 ue=j(ie,[[`render`,le],[`__scopeId`,`data-v-fbf49b06`]]),de=m({name:`PromptInput`,components:{PromptTextarea:C},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 fe(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 pe=m({name:`PresetPanel`,components:{MagicIcon:E,ElButton:k,PromptInput:j(de,[[`render`,fe]]),StartImageUrlInput:ue,ModelSelector:re,Consumption:B},emits:[`generate`],computed:{config(){return this.$store.state.hailuo?.config},consumption(){return N(this.config,this.service?.cost)},service(){return this.$store.state.hailuo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),me={class:`flex flex-col h-full`},he={class:`flex-1 overflow-y-auto p-5`},ge={class:`flex flex-col items-center justify-center px-5 pb-5`};function _e(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(`magic-icon`),x=l(`el-button`);return p(),s(`div`,me,[e(`div`,he,[a(g,{class:`mb-4`}),a(_,{class:`mb-4`}),t.config?.model===`minimax-i2v`?(p(),u(v,{key:0,class:`mb-4`})):o(``,!0)]),e(`div`,ge,[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,{class:`mr-2`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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,{class:`mr-2`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(t.$t(`hailuo.button.generate`)),1)]),_:1},8,[`onClick`]))])])}var ve=j(pe,[[`render`,_e]]),ye=m({name:`TaskPreview`,components:{ChannelIcon:S,InfoIcon:w,MagicIcon:E,TimeIcon:b,WarningIcon:T,CopyToClipboard:x,ElAlert:y,VideoPlayer:G,ElTooltip:v,ElButton:k,ApiCodeButton:K},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`)}}}),be={class:`preview`},xe={class:`left`},Se={class:`main`},Ce={class:`bot`},we={class:`datetime`},Te={class:`info`},Ee={key:0,class:`prompt mt-2`},De={key:0},Oe={key:1},ke={key:0,class:n({content:!0,failed:!0})},Ae={key:0,class:`mb-4`},je={key:1,class:n({operations:!0,"mt-2":!0})},Me={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ne={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Pe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},$={key:1,class:n({content:!0})},Fe={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ie={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Le={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Re={class:`text-[var(--el-text-color-regular)] text-xs mb-0`},ze={key:2,class:n({content:!0})},Be={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Ve(n,c,f,m,h,g){let _=l(`capability-presentation`),v=l(`video-player`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`api-code-button`),S=l(`channel-icon`),C=l(`copy-to-clipboard`),w=l(`magic-icon`),T=l(`time-icon`),E=l(`el-alert`),D=l(`warning-icon`),O=l(`info-icon`);return p(),s(`div`,be,[e(`div`,xe,[a(_,{capability:`hailuo`,part:`avatar`,class:`avatar`})]),e(`div`,Se,[e(`div`,Ce,[a(_,{capability:`hailuo`,part:`name`}),e(`span`,we,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,Te,[n.modelValue?.request?.prompt?(p(),s(`p`,Ee,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?o(``,!0):(p(),s(`span`,De,` - (`+i(n.$t(`hailuo.status.pending`))+`) `,1)),n.video?.state===`processing`||n.video?.state===`pending`||n.video?.state===`running`?(p(),s(`span`,Oe,` - (`+i(n.$t(`hailuo.status.processing`))+`) `,1)):o(``,!0)])):o(``,!0)]),n.modelValue?.response?.success===!0?(p(),s(`div`,ke,[n.video?.video_url?(p(),s(`div`,Ae,[a(v,{src:n.video?.video_url},null,8,[`src`])])):o(``,!0),n.video?(p(),s(`div`,je,[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(E,{closable:!1,class:`mt-2 success`},{default:d(()=>[n.modelValue?.request?.model?(p(),s(`p`,Me,[a(S,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,Ne,[a(w,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,Pe,[a(T,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,$,[a(E,{closable:!1,class:`failure`},{template:d(()=>[a(D,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Fe,[a(w,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])]),e(`p`,Ie,[a(O,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,Le,[a(T,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),e(`p`,Re,[a(S,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,ze,[a(E,{closable:!1,class:`info`},{template:d(()=>[a(D,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Be,[a(w,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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 He=m({name:`RecentPanel`,components:{TaskPreview:j(ye,[[`render`,Ve],[`__scopeId`,`data-v-03b088a6`]]),BotPlaceholder:q,NoTasks:U,ScrollList:H},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?.()}}}),Ue={key:0},We={key:2,class:`w-full h-full flex items-center justify-center`};function Ge(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`,Ue,[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`,We,[a(v)])):o(``,!0)],64)}var Ke=m({name:`HailuoIndex`,components:{ConfigPanel:ve,Layout:J,RecentPanel:j(He,[[`render`,Ge]])},mixins:[te],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===P.Request},tasksLoading(){return this.$store.state.hailuo?.status?.getTasks===P.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 W({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(!R(this.uploadTracker,e=>this.$t(e),e=>F.warning(e)))return;let e={...this.config,async:!0};if(!O())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}F.info(this.$t(`hailuo.message.startingTask`)),I(`hailuo`,ee.generate(e,{token:t})).then(()=>{F.success(this.$t(`hailuo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?F.error(this.$t(`hailuo.message.usedUp`)):F.error(this.$t(`hailuo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function qe(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 Je=j(Ke,[[`render`,qe]]);export{Je 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-DuspBjxM.js";import{t as _}from"./upload-BNaHShNL.js";import{t as v}from"./tooltip-O0jUmp8_.js";import{t as y}from"./alert-x8mYlhuj.js";import{t as b}from"./clock-C4q08wwy.js";import{t as x}from"./CopyToClipboard-rmORTzYc.js";import{r as S,t as C}from"./PromptTextarea-DbxCyFDP.js";import{t as w}from"./info-7QlewFBX.js";import{t as T}from"./triangle-alert-BC93Xt4w.js";import{t as E}from"./wand-sparkles-Cfgyd-ZM.js";import{er as D}from"./constants-D-3QKDN1.js";import{$t as O,Ai as k,Bt as A,E as j,Ht as M,Pn as ee,Vt as te,Wt as N,ei as P,gi as F,mr as I,ri as L,zt as R}from"./index-h4BcqHjk.js";import{t as z}from"./ImagePreview-C_BsIyhE.js";import{t as B}from"./Consumption-CqnV6zKQ.js";import{a as V,n as H,r as U,t as W}from"./pagination-jAKTlMGg.js";import{t as G}from"./VideoPlayer-BYVFHaXG.js";import{t as K}from"./ApiCodeButton-BQdstZ9o.js";import{t as q}from"./BotPlaceholder-Ck1mjnMM.js";import{t as J}from"./Hailuo-78HzK7nv.js";var Y=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||=D}}),X={class:`field`},Z={class:`title font-bold`},Q={class:`float-left`};function ne(t,n,r,o,m,h){let g=l(`el-option`),_=l(`el-select`);return p(),s(`div`,X,[e(`h2`,Z,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`,Q,i(t.label),1)]),_:2},1032,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var re=j(Y,[[`render`,ne],[`__scopeId`,`data-v-a768fbd9`]]),ie=m({name:`StartImageUrlInput`,components:{ElUpload:_,ElButton:k,InfoIcon:V,ImagePreview:z},mixins:[M,A],data(){return{fileList:[],uploadUrl:L()+`/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(){F.warning(this.$t(`hailuo.message.uploadStartImageExceed`))},onError(){F.error(this.$t(`hailuo.message.uploadStartImageError`))},async onRemove(){F.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()}}}),ae={class:`relative`},oe={class:`flex justify-between`},se={class:`flex justify-start items-center`},ce={class:`text-sm font-bold`};function le(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`,ae,[e(`div`,oe,[e(`div`,se,[e(`span`,ce,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 ue=j(ie,[[`render`,le],[`__scopeId`,`data-v-fbf49b06`]]),de=m({name:`PromptInput`,components:{PromptTextarea:C},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 fe(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 pe=m({name:`PresetPanel`,components:{MagicIcon:E,ElButton:k,PromptInput:j(de,[[`render`,fe]]),StartImageUrlInput:ue,ModelSelector:re,Consumption:B},emits:[`generate`],computed:{config(){return this.$store.state.hailuo?.config},consumption(){return N(this.config,this.service?.cost)},service(){return this.$store.state.hailuo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),me={class:`flex flex-col h-full`},he={class:`flex-1 overflow-y-auto p-5`},ge={class:`flex flex-col items-center justify-center px-5 pb-5`};function _e(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(`magic-icon`),x=l(`el-button`);return p(),s(`div`,me,[e(`div`,he,[a(g,{class:`mb-4`}),a(_,{class:`mb-4`}),t.config?.model===`minimax-i2v`?(p(),u(v,{key:0,class:`mb-4`})):o(``,!0)]),e(`div`,ge,[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,{class:`mr-2`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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,{class:`mr-2`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(t.$t(`hailuo.button.generate`)),1)]),_:1},8,[`onClick`]))])])}var ve=j(pe,[[`render`,_e]]),ye=m({name:`TaskPreview`,components:{ChannelIcon:S,InfoIcon:w,MagicIcon:E,TimeIcon:b,WarningIcon:T,CopyToClipboard:x,ElAlert:y,VideoPlayer:G,ElTooltip:v,ElButton:k,ApiCodeButton:K},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`)}}}),be={class:`preview`},xe={class:`left`},Se={class:`main`},Ce={class:`bot`},we={class:`datetime`},Te={class:`info`},Ee={key:0,class:`prompt mt-2`},De={key:0},Oe={key:1},ke={key:0,class:n({content:!0,failed:!0})},Ae={key:0,class:`mb-4`},je={key:1,class:n({operations:!0,"mt-2":!0})},Me={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ne={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Pe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},$={key:1,class:n({content:!0})},Fe={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ie={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Le={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Re={class:`text-[var(--el-text-color-regular)] text-xs mb-0`},ze={key:2,class:n({content:!0})},Be={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Ve(n,c,f,m,h,g){let _=l(`capability-presentation`),v=l(`video-player`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`api-code-button`),S=l(`channel-icon`),C=l(`copy-to-clipboard`),w=l(`magic-icon`),T=l(`time-icon`),E=l(`el-alert`),D=l(`warning-icon`),O=l(`info-icon`);return p(),s(`div`,be,[e(`div`,xe,[a(_,{capability:`hailuo`,part:`avatar`,class:`avatar`})]),e(`div`,Se,[e(`div`,Ce,[a(_,{capability:`hailuo`,part:`name`}),e(`span`,we,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,Te,[n.modelValue?.request?.prompt?(p(),s(`p`,Ee,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?o(``,!0):(p(),s(`span`,De,` - (`+i(n.$t(`hailuo.status.pending`))+`) `,1)),n.video?.state===`processing`||n.video?.state===`pending`||n.video?.state===`running`?(p(),s(`span`,Oe,` - (`+i(n.$t(`hailuo.status.processing`))+`) `,1)):o(``,!0)])):o(``,!0)]),n.modelValue?.response?.success===!0?(p(),s(`div`,ke,[n.video?.video_url?(p(),s(`div`,Ae,[a(v,{src:n.video?.video_url},null,8,[`src`])])):o(``,!0),n.video?(p(),s(`div`,je,[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(E,{closable:!1,class:`mt-2 success`},{default:d(()=>[n.modelValue?.request?.model?(p(),s(`p`,Me,[a(S,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,Ne,[a(w,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,Pe,[a(T,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,$,[a(E,{closable:!1,class:`failure`},{template:d(()=>[a(D,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Fe,[a(w,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(C,{content:n.modelValue?.id},null,8,[`content`])]),e(`p`,Ie,[a(O,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,Le,[a(T,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),e(`p`,Re,[a(S,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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`,ze,[a(E,{closable:!1,class:`info`},{template:d(()=>[a(D,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),r(` `+i(n.$t(`hailuo.name.failure`)),1)]),default:d(()=>[e(`p`,Be,[a(w,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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 He=m({name:`RecentPanel`,components:{TaskPreview:j(ye,[[`render`,Ve],[`__scopeId`,`data-v-03b088a6`]]),BotPlaceholder:q,NoTasks:U,ScrollList:H},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?.()}}}),Ue={key:0},We={key:2,class:`w-full h-full flex items-center justify-center`};function Ge(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`,Ue,[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`,We,[a(v)])):o(``,!0)],64)}var Ke=m({name:`HailuoIndex`,components:{ConfigPanel:ve,Layout:J,RecentPanel:j(He,[[`render`,Ge]])},mixins:[te],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===P.Request},tasksLoading(){return this.$store.state.hailuo?.status?.getTasks===P.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 W({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(!R(this.uploadTracker,e=>this.$t(e),e=>F.warning(e)))return;let e={...this.config,async:!0};if(!O())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}F.info(this.$t(`hailuo.message.startingTask`)),I(`hailuo`,ee.generate(e,{token:t})).then(()=>{F.success(this.$t(`hailuo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?F.error(this.$t(`hailuo.message.usedUp`)):F.error(this.$t(`hailuo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function qe(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 Je=j(Ke,[[`render`,qe]]);export{Je 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-
|
|
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-C4lekjnN.js";import{t as f}from"./card-D-4S-l7a.js";import{n as p,t as m}from"./row-Dbo9j6N1.js";import{t as h}from"./pagination-Dj04WTpX.js";import{t as g}from"./CopyToClipboard-rmORTzYc.js";import{E as _,or as v}from"./index-h4BcqHjk.js";var y=l({name:`ConsoleDistributionInvitees`,components:{Pagination:h,CopyToClipboard:g,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 v.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=_(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-DZCaWKok.js";import{n as k,t as A}from"./table-CLwvS0sW.js";import{n as j,t as M}from"./tabs-8UTEJ0Bg.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-B0Elgaw9.js";import{n as I,t as L}from"./file-output-BOWkai4z.js";import{n as R,t as z}from"./row-SUcM9Qp5.js";import{t as B}from"./empty-BOBA66a-.js";import{t as V}from"./pagination-bKCTJxMn.js";import{n as H,t as U}from"./skeleton-BVbQKb45.js";import{t as W}from"./switch-CjwwXJJ-.js";import{t as G}from"./boxes-CJUZpl0g.js";import{t as ne}from"./CopyToClipboard-DksVZ0H5.js";import{$n as K,Ai as re,E as ie,Gr as q,Oi as J,Qn as Y,Qr as ae,Wr as oe,er as se,fr as ce,gi as X,ri as le,sr as ue,xi as de}from"./index-C16Hj9CP.js";var fe=e(ce());v.register(c,u,p,b,S,T,d,h);var Z=[`#5B8FF9`,`#5AD8A6`,`#5D7092`,`#F6BD16`,`#6F5EF9`,`#6DC8EC`,`#945FB9`,`#FF9845`,`#1E9493`,`#FF99C3`],Q=`#C0C4CC`,pe=.01,me=20;function he(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 ge=15e3,_e=E({name:`ConsoleUsageList`,components:{ApplicationsIcon:G,ExportIcon:L,Pagination:V,ElTag:J,ElDatePicker:I,ElTable:A,ElSelect:D,ElOption:O,CopyToClipboard:ne,ElRow:z,ElCol:R,ElTableColumn:k,ElCard:N,ElRadioButton:P,ElRadioGroup:F,ElSkeleton:U,ElSkeletonItem:H,ElDialog:de,ElTabs:j,ElTabPane:M,ElButton:re,ElEmpty:B,ElSwitch:W,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:oe,serviceType:q,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||q.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],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===q.API?this.onFetchApiUsages(e):this.type===q.Proxy&&this.onFetchProxyUsages(e)},startAutoRefresh(){this.stopAutoRefresh(),this.autoRefreshTimer=window.setInterval(()=>{document.hidden||this.onFetchUsages(!0)},ge)},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 K.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&&K.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(){ue.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:ae.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,Y.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;K.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;se.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){X.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=`${le()}/api/v1/usage/apis/export/?${fe.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{X.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 K.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-pe),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,me)}a.length-s===1&&(s=a.length);let c=a.slice(0,s),l=new Set(c),u=he(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}}}}),ve={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},ye={class:`inline-block w-9`},be={class:`inline-block`},xe={key:1,class:`summary-card`},Se={class:`icon-wrapper`},Ce={class:`text-left`},we={class:`description`},Te={class:`value`},Ee={class:`flex flex-wrap items-center justify-between gap-2`},De={class:`text-[15px] font-medium text-[var(--el-text-color-primary)]`},Oe={class:`chart-wrapper`},ke={class:`share-cell`},Ae={class:`share-bar`},je={class:`share-pct`},Me={class:`flex items-center justify-end gap-2 mb-4`},Ne={class:`text-sm text-[var(--el-text-color-regular)]`},Pe={key:0},Fe={key:0},Ie={key:1},Le={class:`flex flex-wrap gap-2`},Re={class:`key`},ze={key:0,class:`cursor-pointer`},Be={class:`key`},Ve={key:0,class:`cursor-pointer`},He={class:`created-at`},Ue={class:`key`},We={key:0,class:`cursor-pointer`},Ge={class:`created-at`},$={key:1,class:`detail-json`},Ke={key:2,class:`text-gray-400`},qe={key:1,class:`detail-json`},Je={key:2,class:`text-gray-400`},Ye={class:`float-right`};function Xe(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(`export-icon`),A=l(`el-button`),j=l(`applications-icon`),M=l(`el-card`),N=l(`bar-chart`),P=l(`el-empty`),F=l(`doughnut-chart`),I=l(`el-table-column`),L=l(`el-table`),R=l(`el-switch`),z=l(`el-tag`),B=l(`copy-to-clipboard`),V=l(`el-tab-pane`),H=l(`el-tabs`),U=l(`el-dialog`),W=l(`pagination`),G=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`,ve,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`,ye,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`,be,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,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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(M,{shadow:`hover`,class:`h-full`},{default:g(()=>[e.aggLoading?(w(),m(D,{key:0})):(w(),o(`div`,xe,[t(`div`,Se,[i(j,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),t(`div`,Ce,[t(`p`,we,r(e.$t(`usage.title.totalUsed`)),1),t(`p`,Te,r(e.totalUsedString),1)])]))]),_:1})]),_:1}),i(_,{md:18,xs:24},{default:g(()=>[i(M,{shadow:`hover`,class:`h-full`},{header:g(()=>[t(`div`,Ee,[t(`span`,De,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`,Oe,[e.aggLoading?(w(),m(D,{key:0,class:`w-full`})):e.chartView===`trend`?(w(),o(s,{key:1},[e.barChartSeries.length?(w(),m(N,{key:0,data:e.barChartData,options:e.barChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(P,{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(F,{key:0,data:e.doughnutChartData,options:e.doughnutChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(P,{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(L,{key:0,data:e.apiBreakdown,size:`small`,height:`300`,class:`w-full`},{default:g(()=>[i(I,{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(I,{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(I,{label:e.$t(`usage.field.share`),width:`150`},{default:g(e=>[t(`div`,ke,[t(`div`,Ae,[t(`div`,{class:`share-bar-fill`,style:y({width:e.row.share*100+`%`,backgroundColor:e.row.color})},null,4)]),t(`span`,je,r((e.row.share*100).toFixed(1))+`%`,1)])]),_:1},8,[`label`])]),_:1},8,[`data`])):(w(),m(P,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64))])]),_:1})]),_:1})]),_:1})):a(``,!0),i(M,{shadow:`hover`},{default:g(()=>[t(`div`,Me,[t(`span`,Ne,r(e.$t(`usage.field.autoRefresh`)),1),i(R,{modelValue:e.autoRefresh,"onUpdate:modelValue":c[6]||=t=>e.autoRefresh=t},null,8,[`modelValue`])]),e.type===e.serviceType.API?f((w(),m(L,{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(I,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.api?.title),1)]),_:1},8,[`label`]),i(I,{label:e.$t(`usage.field.statusCode`),width:`120px`},{default:g(t=>[t.row.status_code?(w(),o(`span`,Pe,r(t.row.status_code),1)):(w(),m(z,{key:1,type:`warning`,size:`small`},{default:g(()=>[n(r(e.$t(`usage.value.processing`)),1)]),_:1}))]),_:1},8,[`label`]),i(I,{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(I,{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`,Fe,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)])):(w(),o(`div`,Ie,[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(I,{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(I,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:g(i=>[t(`div`,Le,[i.row.original_amount>i.row.deducted_amount&&i.row.original_amount>0?(w(),m(z,{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(z,{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(I,{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(I,{prop:`trace_id`,label:e.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:g(e=>[t(`span`,Re,r(e.row.trace_id),1),e.row.trace_id?(w(),o(`span`,ze,[i(B,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(I,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,Be,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Ve,[i(B,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(I,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,He,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[G,e.loading]]):a(``,!0),e.type===e.serviceType.Proxy?f((w(),m(L,{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(I,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.service?.title),1)]),_:1},8,[`label`]),i(I,{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(I,{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(I,{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(I,{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(z,{key:t,class:`mb-2`},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),i(I,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,Ue,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,We,[i(B,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(I,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ge,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[G,e.loading]]):a(``,!0)]),_:1})]),_:1})]),_:1}),i(U,{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(H,{modelValue:e.detailActiveTab,"onUpdate:modelValue":c[7]||=t=>e.detailActiveTab=t},{default:g(()=>[i(V,{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`,$,r(e.formatJson(e.detailRow.metadata.request)),1)):(w(),o(`p`,Ke,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),i(V,{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`,qe,r(e.formatJson(e.detailRow.metadata.response)),1)):(w(),o(`p`,Je,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`,Ye,[i(W,{"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 Ze=ie(_e,[[`render`,Xe],[`__scopeId`,`data-v-81b0a3c5`]]);export{Ze 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-DuspBjxM.js";import{n as k,t as A}from"./table-C4lekjnN.js";import{n as j,t as M}from"./tabs-CYLrPpdu.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-B0Elgaw9.js";import{n as I,t as L}from"./file-output-BHblcI1H.js";import{n as R,t as z}from"./row-Dbo9j6N1.js";import{t as B}from"./empty-BOBA66a-.js";import{t as V}from"./pagination-Dj04WTpX.js";import{n as H,t as U}from"./skeleton-BVbQKb45.js";import{t as W}from"./switch-DGjAGv1c.js";import{t as G}from"./boxes-DDscYXMD.js";import{t as ne}from"./CopyToClipboard-rmORTzYc.js";import{$n as K,Ai as re,E as ie,Gr as q,Oi as J,Qn as Y,Qr as ae,Wr as oe,er as se,fr as ce,gi as X,ri as le,sr as ue,xi as de}from"./index-h4BcqHjk.js";var fe=e(ce());v.register(c,u,p,b,S,T,d,h);var Z=[`#5B8FF9`,`#5AD8A6`,`#5D7092`,`#F6BD16`,`#6F5EF9`,`#6DC8EC`,`#945FB9`,`#FF9845`,`#1E9493`,`#FF99C3`],Q=`#C0C4CC`,pe=.01,me=20;function he(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 ge=15e3,_e=E({name:`ConsoleUsageList`,components:{ApplicationsIcon:G,ExportIcon:L,Pagination:V,ElTag:J,ElDatePicker:I,ElTable:A,ElSelect:D,ElOption:O,CopyToClipboard:ne,ElRow:z,ElCol:R,ElTableColumn:k,ElCard:N,ElRadioButton:P,ElRadioGroup:F,ElSkeleton:U,ElSkeletonItem:H,ElDialog:de,ElTabs:j,ElTabPane:M,ElButton:re,ElEmpty:B,ElSwitch:W,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:oe,serviceType:q,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||q.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],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===q.API?this.onFetchApiUsages(e):this.type===q.Proxy&&this.onFetchProxyUsages(e)},startAutoRefresh(){this.stopAutoRefresh(),this.autoRefreshTimer=window.setInterval(()=>{document.hidden||this.onFetchUsages(!0)},ge)},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 K.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&&K.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(){ue.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:ae.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,Y.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;K.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;se.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){X.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=`${le()}/api/v1/usage/apis/export/?${fe.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{X.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 K.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-pe),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,me)}a.length-s===1&&(s=a.length);let c=a.slice(0,s),l=new Set(c),u=he(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}}}}),ve={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},ye={class:`inline-block w-9`},be={class:`inline-block`},xe={key:1,class:`summary-card`},Se={class:`icon-wrapper`},Ce={class:`text-left`},we={class:`description`},Te={class:`value`},Ee={class:`flex flex-wrap items-center justify-between gap-2`},De={class:`text-[15px] font-medium text-[var(--el-text-color-primary)]`},Oe={class:`chart-wrapper`},ke={class:`share-cell`},Ae={class:`share-bar`},je={class:`share-pct`},Me={class:`flex items-center justify-end gap-2 mb-4`},Ne={class:`text-sm text-[var(--el-text-color-regular)]`},Pe={key:0},Fe={key:0},Ie={key:1},Le={class:`flex flex-wrap gap-2`},Re={class:`key`},ze={key:0,class:`cursor-pointer`},Be={class:`key`},Ve={key:0,class:`cursor-pointer`},He={class:`created-at`},Ue={class:`key`},We={key:0,class:`cursor-pointer`},Ge={class:`created-at`},$={key:1,class:`detail-json`},Ke={key:2,class:`text-gray-400`},qe={key:1,class:`detail-json`},Je={key:2,class:`text-gray-400`},Ye={class:`float-right`};function Xe(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(`export-icon`),A=l(`el-button`),j=l(`applications-icon`),M=l(`el-card`),N=l(`bar-chart`),P=l(`el-empty`),F=l(`doughnut-chart`),I=l(`el-table-column`),L=l(`el-table`),R=l(`el-switch`),z=l(`el-tag`),B=l(`copy-to-clipboard`),V=l(`el-tab-pane`),H=l(`el-tabs`),U=l(`el-dialog`),W=l(`pagination`),G=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`,ve,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`,ye,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`,be,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,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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(M,{shadow:`hover`,class:`h-full`},{default:g(()=>[e.aggLoading?(w(),m(D,{key:0})):(w(),o(`div`,xe,[t(`div`,Se,[i(j,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),t(`div`,Ce,[t(`p`,we,r(e.$t(`usage.title.totalUsed`)),1),t(`p`,Te,r(e.totalUsedString),1)])]))]),_:1})]),_:1}),i(_,{md:18,xs:24},{default:g(()=>[i(M,{shadow:`hover`,class:`h-full`},{header:g(()=>[t(`div`,Ee,[t(`span`,De,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`,Oe,[e.aggLoading?(w(),m(D,{key:0,class:`w-full`})):e.chartView===`trend`?(w(),o(s,{key:1},[e.barChartSeries.length?(w(),m(N,{key:0,data:e.barChartData,options:e.barChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(P,{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(F,{key:0,data:e.doughnutChartData,options:e.doughnutChartOptions,class:`chart`},null,8,[`data`,`options`])):(w(),m(P,{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(L,{key:0,data:e.apiBreakdown,size:`small`,height:`300`,class:`w-full`},{default:g(()=>[i(I,{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(I,{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(I,{label:e.$t(`usage.field.share`),width:`150`},{default:g(e=>[t(`div`,ke,[t(`div`,Ae,[t(`div`,{class:`share-bar-fill`,style:y({width:e.row.share*100+`%`,backgroundColor:e.row.color})},null,4)]),t(`span`,je,r((e.row.share*100).toFixed(1))+`%`,1)])]),_:1},8,[`label`])]),_:1},8,[`data`])):(w(),m(P,{key:1,description:e.$t(`common.message.noData`),"image-size":70,class:`w-full`},null,8,[`description`]))],64))])]),_:1})]),_:1})]),_:1})):a(``,!0),i(M,{shadow:`hover`},{default:g(()=>[t(`div`,Me,[t(`span`,Ne,r(e.$t(`usage.field.autoRefresh`)),1),i(R,{modelValue:e.autoRefresh,"onUpdate:modelValue":c[6]||=t=>e.autoRefresh=t},null,8,[`modelValue`])]),e.type===e.serviceType.API?f((w(),m(L,{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(I,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.api?.title),1)]),_:1},8,[`label`]),i(I,{label:e.$t(`usage.field.statusCode`),width:`120px`},{default:g(t=>[t.row.status_code?(w(),o(`span`,Pe,r(t.row.status_code),1)):(w(),m(z,{key:1,type:`warning`,size:`small`},{default:g(()=>[n(r(e.$t(`usage.value.processing`)),1)]),_:1}))]),_:1},8,[`label`]),i(I,{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(I,{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`,Fe,[t(`span`,null,r(e.getDeductedAmount(n.row)),1)])):(w(),o(`div`,Ie,[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(I,{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(I,{prop:`metadata`,label:e.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:g(i=>[t(`div`,Le,[i.row.original_amount>i.row.deducted_amount&&i.row.original_amount>0?(w(),m(z,{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(z,{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(I,{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(I,{prop:`trace_id`,label:e.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:g(e=>[t(`span`,Re,r(e.row.trace_id),1),e.row.trace_id?(w(),o(`span`,ze,[i(B,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(I,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,Be,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Ve,[i(B,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(I,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,He,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[G,e.loading]]):a(``,!0),e.type===e.serviceType.Proxy?f((w(),m(L,{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(I,{label:e.$t(`application.field.name`),width:`160px`},{default:g(e=>[t(`span`,null,r(e.row?.service?.title),1)]),_:1},8,[`label`]),i(I,{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(I,{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(I,{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(I,{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(z,{key:t,class:`mb-2`},{default:g(()=>[n(r(t)+`: `+r(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),i(I,{prop:`credential_id`,label:e.$t(`usage.field.credential`),width:`200px`,"class-name":`text-center`},{default:g(n=>[t(`span`,Ue,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,We,[i(B,{content:n.row.credential?.id||n.row.credential_id,class:`inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`label`]),i(I,{label:e.$t(`usage.field.createdAt`),width:`200px`},{default:g(n=>[t(`span`,Ge,r(e.$dayjs.format(n.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[G,e.loading]]):a(``,!0)]),_:1})]),_:1})]),_:1}),i(U,{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(H,{modelValue:e.detailActiveTab,"onUpdate:modelValue":c[7]||=t=>e.detailActiveTab=t},{default:g(()=>[i(V,{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`,$,r(e.formatJson(e.detailRow.metadata.request)),1)):(w(),o(`p`,Ke,r(e.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),i(V,{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`,qe,r(e.formatJson(e.detailRow.metadata.response)),1)):(w(),o(`p`,Je,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`,Ye,[i(W,{"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 Ze=ie(_e,[[`render`,Xe],[`__scopeId`,`data-v-81b0a3c5`]]);export{Ze 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-DZCaWKok.js";import{n as g,t as _}from"./table-CLwvS0sW.js";import{t as v}from"./card-D-4S-l7a.js";import{n as y,t as b}from"./file-output-BOWkai4z.js";import{n as x,t as S}from"./row-SUcM9Qp5.js";import{t as C}from"./pagination-bKCTJxMn.js";import{t as w}from"./skeleton-BVbQKb45.js";import{t as T}from"./circle-check-DHZcjMim.js";import{t as E}from"./clock-C90hJcW0.js";import{t as D}from"./CopyToClipboard-DksVZ0H5.js";import{t as O}from"./dollar-sign-DiY9-ZBQ.js";import{Ai as k,E as A,Gt as j,Kr as M,Oi as N,Zn as P,mi as F}from"./index-C16Hj9CP.js";var I=F(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),L={total_count:0,total_spent:0,state_counts:{}},R=p({name:`ConsoleOrderList`,components:{ExportIcon:b,MoneyIcon:O,ReceiptIcon:I,SuccessIcon:T,TimeIcon:E,Pagination:C,CopyToClipboard:D,ElRow:S,ElCol:x,ElTable:_,ElTableColumn:g,ElButton:k,ElTag:N,ElCard:v,ElSelect:m,ElOption:h,ElDatePicker:y,ElSkeleton:w},data(){return{OrderState:M,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:{...L},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:M.PENDING,label:this.$t(`order.state.pending`)},{value:M.FINISHED,label:this.$t(`order.state.finished`)},{value:M.PAID,label:this.$t(`order.state.paid`)},{value:M.EXPIRED,label:this.$t(`order.state.expired`)},{value:M.FAILED,label:this.$t(`order.state.failed`)},{value:M.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:j,stateTagType(e){return e===M.FINISHED||e===M.PAID?`success`:e===M.EXPIRED||e===M.FAILED?`danger`:e===M.REFUNDED?`warning`:`info`},stateLabel(e){return{[M.PENDING]:this.$t(`order.state.pending`),[M.PAID]:this.$t(`order.state.paid`),[M.FINISHED]:this.$t(`order.state.finished`),[M.EXPIRED]:this.$t(`order.state.expired`),[M.FAILED]:this.$t(`order.state.failed`),[M.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==M.PAID&&e!==M.FINISHED&&e!==M.EXPIRED&&e!==M.FAILED&&e!==M.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,P.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,P.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...L}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,P.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})}}}),z={class:`title`},B={key:1,class:`card-content`},V={class:`icon-wrapper`},H={class:`description`},U={class:`value`},W={key:1,class:`card-content`},G={class:`icon-wrapper`},K={class:`description`},q={class:`value`},J={key:1,class:`card-content`},ee={class:`icon-wrapper`},Y={class:`description`},X={class:`value`},Z={key:1,class:`card-content`},Q={class:`icon-wrapper`},$={class:`description`},te={class:`value`},ne={class:`filter-row mb-3`},re={class:`key`},ie={class:`cursor-pointer`},ae={class:`price`},oe={class:`description`},se={class:`text-gray-500`},ce={class:`created-at`},le={class:`flex items-center justify-center flex-wrap`},ue={class:`float-right`};function de(p,m,h,g,_,v){let y=o(`el-col`),b=o(`el-row`),x=o(`el-skeleton`),S=o(`receipt-icon`),C=o(`el-card`),w=o(`money-icon`),T=o(`success-icon`),E=o(`time-icon`),D=o(`el-option`),O=o(`el-select`),k=o(`el-date-picker`),A=o(`export-icon`),j=o(`el-button`),M=o(`copy-to-clipboard`),N=o(`el-table-column`),P=o(`el-tag`),F=o(`el-table`),I=o(`pagination`),L=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`,z,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`,B,[e(`div`,V,[r(S,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,H,n(p.$t(`order.title.totalOrders`)),1),e(`p`,U,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`,W,[e(`div`,G,[r(w,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,K,n(p.$t(`order.title.totalSpent`)),1),e(`p`,q,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`,J,[e(`div`,ee,[r(T,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,Y,n(p.$t(`order.title.finishedOrders`)),1),e(`p`,X,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`,Z,[e(`div`,Q,[r(E,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,$,n(p.$t(`order.title.pendingOrders`)),1),e(`p`,te,n(p.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),e(`div`,ne,[r(O,{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(D,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(O,{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(D,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(k,{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(j,{type:`primary`,plain:``,loading:p.exporting,onClick:p.onExport},{default:l(()=>[r(A,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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(F,{data:p.orders,stripe:``,"empty-text":p.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:l(()=>[r(N,{prop:`id`,label:p.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:l(t=>[e(`span`,re,n(t.row.id),1),e(`span`,ie,[r(M,{content:t.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(N,{label:p.$t(`order.field.price`),width:`110px`,align:`center`},{default:l(t=>[e(`span`,ae,n(p.getPriceString({value:t.row?.price})),1)]),_:1},8,[`label`]),r(N,{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`,oe,n(t.row.description),1)]),_:1},8,[`label`]),r(N,{prop:`state`,label:p.$t(`order.field.state`),width:`130px`,align:`center`},{default:l(e=>[r(P,{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(N,{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`,se,n(t.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(N,{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`,ce,n(p.$dayjs.format(t.row.created_at)),1)]),_:1},8,[`label`]),r(N,{"min-width":`130px`,fixed:`right`},{default:l(r=>[e(`div`,le,[p.isPendingAction(r.row.state)?(f(),c(j,{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(j,{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`])),[[L,p.loading]])]),_:1})]),_:1})]),_:1}),r(b,null,{default:l(()=>[r(y,{span:10,offset:14},{default:l(()=>[e(`div`,ue,[r(I,{"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 fe=A(R,[[`render`,de],[`__scopeId`,`data-v-c1fc3317`]]);export{fe 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-DuspBjxM.js";import{n as g,t as _}from"./table-C4lekjnN.js";import{t as v}from"./card-D-4S-l7a.js";import{n as y,t as b}from"./file-output-BHblcI1H.js";import{n as x,t as S}from"./row-Dbo9j6N1.js";import{t as C}from"./pagination-Dj04WTpX.js";import{t as w}from"./skeleton-BVbQKb45.js";import{t as T}from"./circle-check-CxdRmME4.js";import{t as E}from"./clock-C4q08wwy.js";import{t as D}from"./CopyToClipboard-rmORTzYc.js";import{t as O}from"./dollar-sign-BkrT7-Sj.js";import{Ai as k,E as A,Gt as j,Kr as M,Oi as N,Zn as P,mi as F}from"./index-h4BcqHjk.js";var I=F(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),L={total_count:0,total_spent:0,state_counts:{}},R=p({name:`ConsoleOrderList`,components:{ExportIcon:b,MoneyIcon:O,ReceiptIcon:I,SuccessIcon:T,TimeIcon:E,Pagination:C,CopyToClipboard:D,ElRow:S,ElCol:x,ElTable:_,ElTableColumn:g,ElButton:k,ElTag:N,ElCard:v,ElSelect:m,ElOption:h,ElDatePicker:y,ElSkeleton:w},data(){return{OrderState:M,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:{...L},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:M.PENDING,label:this.$t(`order.state.pending`)},{value:M.FINISHED,label:this.$t(`order.state.finished`)},{value:M.PAID,label:this.$t(`order.state.paid`)},{value:M.EXPIRED,label:this.$t(`order.state.expired`)},{value:M.FAILED,label:this.$t(`order.state.failed`)},{value:M.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:j,stateTagType(e){return e===M.FINISHED||e===M.PAID?`success`:e===M.EXPIRED||e===M.FAILED?`danger`:e===M.REFUNDED?`warning`:`info`},stateLabel(e){return{[M.PENDING]:this.$t(`order.state.pending`),[M.PAID]:this.$t(`order.state.paid`),[M.FINISHED]:this.$t(`order.state.finished`),[M.EXPIRED]:this.$t(`order.state.expired`),[M.FAILED]:this.$t(`order.state.failed`),[M.REFUNDED]:this.$t(`order.state.refunded`)}[e]||e},isPendingAction(e){return e!==M.PAID&&e!==M.FINISHED&&e!==M.EXPIRED&&e!==M.FAILED&&e!==M.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,P.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,P.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...L}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,P.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})}}}),z={class:`title`},B={key:1,class:`card-content`},V={class:`icon-wrapper`},H={class:`description`},U={class:`value`},W={key:1,class:`card-content`},G={class:`icon-wrapper`},K={class:`description`},q={class:`value`},J={key:1,class:`card-content`},ee={class:`icon-wrapper`},Y={class:`description`},X={class:`value`},Z={key:1,class:`card-content`},Q={class:`icon-wrapper`},$={class:`description`},te={class:`value`},ne={class:`filter-row mb-3`},re={class:`key`},ie={class:`cursor-pointer`},ae={class:`price`},oe={class:`description`},se={class:`text-gray-500`},ce={class:`created-at`},le={class:`flex items-center justify-center flex-wrap`},ue={class:`float-right`};function de(p,m,h,g,_,v){let y=o(`el-col`),b=o(`el-row`),x=o(`el-skeleton`),S=o(`receipt-icon`),C=o(`el-card`),w=o(`money-icon`),T=o(`success-icon`),E=o(`time-icon`),D=o(`el-option`),O=o(`el-select`),k=o(`el-date-picker`),A=o(`export-icon`),j=o(`el-button`),M=o(`copy-to-clipboard`),N=o(`el-table-column`),P=o(`el-tag`),F=o(`el-table`),I=o(`pagination`),L=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`,z,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`,B,[e(`div`,V,[r(S,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,H,n(p.$t(`order.title.totalOrders`)),1),e(`p`,U,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`,W,[e(`div`,G,[r(w,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,K,n(p.$t(`order.title.totalSpent`)),1),e(`p`,q,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`,J,[e(`div`,ee,[r(T,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,Y,n(p.$t(`order.title.finishedOrders`)),1),e(`p`,X,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`,Z,[e(`div`,Q,[r(E,{class:`icon`,size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,$,n(p.$t(`order.title.pendingOrders`)),1),e(`p`,te,n(p.summary.state_counts?.Pending||0),1)]))]),_:1})]),_:1})]),_:1}),e(`div`,ne,[r(O,{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(D,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(O,{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(D,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]),r(k,{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(j,{type:`primary`,plain:``,loading:p.exporting,onClick:p.onExport},{default:l(()=>[r(A,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),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(F,{data:p.orders,stripe:``,"empty-text":p.$t(`common.message.noData`),class:`min-h-[calc(100vh-450px)] mb-[20px]`},{default:l(()=>[r(N,{prop:`id`,label:p.$t(`order.field.id`),"class-name":`text-center`,width:`200px`},{default:l(t=>[e(`span`,re,n(t.row.id),1),e(`span`,ie,[r(M,{content:t.row.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(N,{label:p.$t(`order.field.price`),width:`110px`,align:`center`},{default:l(t=>[e(`span`,ae,n(p.getPriceString({value:t.row?.price})),1)]),_:1},8,[`label`]),r(N,{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`,oe,n(t.row.description),1)]),_:1},8,[`label`]),r(N,{prop:`state`,label:p.$t(`order.field.state`),width:`130px`,align:`center`},{default:l(e=>[r(P,{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(N,{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`,se,n(t.row.pay_way||`-`),1)]),_:1},8,[`label`]),r(N,{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`,ce,n(p.$dayjs.format(t.row.created_at)),1)]),_:1},8,[`label`]),r(N,{"min-width":`130px`,fixed:`right`},{default:l(r=>[e(`div`,le,[p.isPendingAction(r.row.state)?(f(),c(j,{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(j,{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`])),[[L,p.loading]])]),_:1})]),_:1})]),_:1}),r(b,null,{default:l(()=>[r(y,{span:10,offset:14},{default:l(()=>[e(`div`,ue,[r(I,{"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 fe=A(R,[[`render`,de],[`__scopeId`,`data-v-c1fc3317`]]);export{fe 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 ee,j as c,mt as l,ot as te,rt as u,tt as d,z as f}from"./vendor-chart-Dw-P17PN.js";import{n as p,t as m}from"./table-CLwvS0sW.js";import{t as h}from"./card-D-4S-l7a.js";import{n as g,t as _}from"./row-SUcM9Qp5.js";import{t as v}from"./empty-BOBA66a-.js";import{t as y}from"./pagination-bKCTJxMn.js";import{t as b}from"./skeleton-BVbQKb45.js";import{t as x}from"./switch-CjwwXJJ-.js";import{t as S}from"./boxes-CJUZpl0g.js";import{t as C}from"./chart-no-axes-combined-CuDdWnPI.js";import{t as w}from"./coins-BhXlFnOf.js";import{t as T}from"./CopyToClipboard-DksVZ0H5.js";import{t as E}from"./wallet-DVK5OHZ5.js";import{Ai as D,B as O,E as k,Gr as A,K as j,Oi as M,Qr as N,Wr as P,Zr as F,fn as I,gi as L,si as R,sr as z}from"./index-C16Hj9CP.js";var B=f({name:`ConsoleApplicationList`,components:{AnalyticsIcon:C,ApplicationsIcon:S,CreditsIcon:w,WalletIcon:E,Pagination:y,CopyToClipboard:T,ElTable:m,ElRow:_,ElButton:D,ElCol:g,ElTag:M,ElSkeleton:b,ElSwitch:x,ElEmpty:v,ElTableColumn:p,ElCard:h},data(){return{credentialType:P,serviceType:A,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!I(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return I(this.$store.getters.site)?!1:R()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||z.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{L.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{L.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:j,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:O,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=F.INDIVIDUAL){return new Promise((t,n)=>{z.getAll({limit:this.limit,...e===F.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:N.USAGE,scope:e}).then(({data:n})=>{e===F.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{L.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(F.INDIVIDUAL),this.onFetchApplications(F.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){z.create({type:N.USAGE,scope:F.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(F.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}`}}}),V={class:`title`},H={key:1,class:`summary-card`},U={class:`icon-wrapper`},W={class:`label`},G={class:`value`},K={class:`description`},q={key:1,class:`flex flex-row justify-between items-center gap-3`},J={class:`summary-card min-w-0 flex-1`},Y={class:`flex justify-start items-center gap-2 mb-2 w-full`},X={class:`icon-wrapper !mb-0`},Z={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},Q={class:`label`},ne={class:`value`},re={class:`description`},ie={class:`flex flex-col items-end gap-2 shrink-0`},ae={class:`copy`},oe={key:0,class:`expired-at`},se={class:`flex flex-wrap items-center justify-end gap-1`},ce={class:`application-cards block sm:hidden`},le={class:`flex items-center gap-2 flex-wrap`},ue={class:`application-card__name`},de={class:`application-card__id`},fe={class:`truncate`},pe={class:`application-card__row`},$={class:`label`},me={class:`value`},he={key:0,class:`application-card__row`},ge={class:`label`},_e={class:`value`},ve={key:1,class:`application-card__row`},ye={class:`label`},be={class:`flex items-center justify-end gap-2 mt-3`},xe={class:`pagination`};function Se(f,p,m,h,g,_){let v=s(`el-col`),y=s(`el-row`),b=s(`el-skeleton`),x=s(`applications-icon`),S=s(`el-card`),C=s(`wallet-icon`),w=s(`copy-to-clipboard`),T=s(`analytics-icon`),E=s(`el-button`),D=s(`credits-icon`),O=s(`el-table-column`),k=s(`el-tag`),A=s(`el-switch`),j=s(`el-table`),M=s(`el-empty`),N=s(`pagination`),P=te(`loading`);return d(),c(y,{class:`application-list`},{default:l(()=>[r(v,{span:24},{default:l(()=>[r(y,null,{default:l(()=>[r(v,{span:24},{default:l(()=>[e(`h2`,V,n(f.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(y,{gutter:15,class:`mb-3`},{default:l(()=>[r(v,{md:12,xs:24},{default:l(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:l(()=>[f.loading?(d(),c(b,{key:0})):(d(),a(`div`,H,[e(`div`,U,[r(x,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,W,n(f.$t(`application.title.count`)),1),e(`p`,G,n(f.individualApplicationsTotal),1),e(`p`,K,n(f.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),f.showGlobalPayment&&f.globalApplications?.length>0?(d(),c(v,{key:0,md:12,xs:24},{default:l(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:l(()=>[f.loading?(d(),c(b,{key:0})):(d(),a(`div`,q,[e(`div`,J,[e(`div`,Y,[e(`div`,X,[r(C,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`span`,Z,[t(n(f.$t(`application.field.id`))+`: `+n(f.globalApplications?.[0]?.id)+` `,1),f.globalApplications?.[0]?.id?(d(),c(w,{key:0,content:f.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,Q,n(f.$t(`application.title.globalBalance`)),1),e(`p`,ne,n(f.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(f.$t(`service.unit.credits`)),1),e(`p`,re,n(f.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,ie,[r(E,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:p[0]||=e=>f.onGoUsage(f.globalApplications?.[0])},{default:l(()=>[r(T,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.usage`)),1)]),_:1}),f.showGlobalPayment?(d(),c(E,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:p[1]||=e=>f.onBuyMore(f.globalApplications?.[0])},{default:l(()=>[r(D,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(y,null,{default:l(()=>[r(v,{span:24},{default:l(()=>[r(S,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:l(()=>[ee((d(),c(j,{data:f.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":f.$t(`common.message.noData`)},{default:l(()=>[r(O,{prop:`id`,label:f.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:l(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ae,[r(w,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(O,{label:f.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(e=>[e.row?.type===`Period`?(d(),c(k,{key:0,type:`success`,effect:`dark`,round:``},{default:l(()=>[t(n(f.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(d(),c(k,{key:1,effect:`dark`,round:``},{default:l(()=>[t(n(f.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(O,{label:f.$t(`application.field.name`),width:`180px`},{default:l(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(d(),c(k,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:l(()=>[t(n(f.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(O,{prop:`remaining_amount`,label:f.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:l(t=>[e(`span`,null,n(f.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(O,{prop:`used_amount`,label:f.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:l(t=>[e(`span`,null,n(f.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(O,{prop:`allow_consume_global`,label:f.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:l(e=>[e.row.service?.type===f.serviceType.API?(d(),c(A,{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=>f.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(O,{label:f.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(e=>[e.row.expired_at?(d(),a(`span`,oe,n(f.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(O,{fixed:`right`,width:`200px`},{default:l(a=>[e(`div`,se,[r(E,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>f.onGoUsage(a?.row)},{default:l(()=>[r(T,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),f.rowCanPay(a?.row)?(d(),c(E,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>f.onBuyMore(a?.row)},{default:l(()=>[r(D,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[P,f.loading]])]),_:1}),e(`div`,ce,[f.loading?(d(),c(b,{key:0,rows:4,animated:``})):(d(),a(o,{key:1},[f.individualApplications?.length?(d(!0),a(o,{key:1},u(f.individualApplications,o=>(d(),c(S,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:l(()=>[e(`div`,le,[e(`span`,ue,n(o?.service?.title),1),o?.type===`Period`?(d(),c(k,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:l(()=>[t(n(f.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(d(),c(k,{key:1,effect:`dark`,size:`small`,round:``},{default:l(()=>[t(n(f.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(d(),c(k,{key:2,type:`info`,size:`small`,round:``},{default:l(()=>[t(n(f.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,de,[e(`span`,fe,n(f.$t(`application.field.id`))+`: `+n(o.id),1),r(w,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,pe,[e(`span`,$,n(f.$t(`application.field.remainingAmount`)),1),e(`span`,me,n(f.getRemainingAmount(o)),1)]),o?.expired_at?(d(),a(`div`,he,[e(`span`,ge,n(f.$t(`application.field.expiredAt`)),1),e(`span`,_e,n(f.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===f.serviceType.API?(d(),a(`div`,ve,[e(`span`,ye,n(f.$t(`application.field.allowConsumeGlobal`)),1),r(A,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>f.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,be,[r(E,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>f.onGoUsage(o)},{default:l(()=>[r(T,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),f.rowCanPay(o)?(d(),c(E,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>f.onBuyMore(o)},{default:l(()=>[r(D,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(d(),c(M,{key:0,description:f.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(y,null,{default:l(()=>[r(v,{span:24},{default:l(()=>[e(`div`,xe,[r(N,{"current-page":f.page,"page-size":f.limit,total:f.individualApplicationsTotal,onChange:f.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Ce=k(B,[[`render`,Se],[`__scopeId`,`data-v-d88616c5`]]);export{Ce 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 ee,j as c,mt as l,ot as te,rt as u,tt as d,z as f}from"./vendor-chart-Dw-P17PN.js";import{n as p,t as m}from"./table-C4lekjnN.js";import{t as h}from"./card-D-4S-l7a.js";import{n as g,t as _}from"./row-Dbo9j6N1.js";import{t as v}from"./empty-BOBA66a-.js";import{t as y}from"./pagination-Dj04WTpX.js";import{t as b}from"./skeleton-BVbQKb45.js";import{t as x}from"./switch-DGjAGv1c.js";import{t as S}from"./boxes-DDscYXMD.js";import{t as C}from"./chart-no-axes-combined-CpGOEj7A.js";import{t as w}from"./coins-BTu5thzB.js";import{t as T}from"./CopyToClipboard-rmORTzYc.js";import{t as E}from"./wallet-DbeMlRJW.js";import{Ai as D,B as O,E as k,Gr as A,K as j,Oi as M,Qr as N,Wr as P,Zr as F,fn as I,gi as L,si as R,sr as z}from"./index-h4BcqHjk.js";var B=f({name:`ConsoleApplicationList`,components:{AnalyticsIcon:C,ApplicationsIcon:S,CreditsIcon:w,WalletIcon:E,Pagination:y,CopyToClipboard:T,ElTable:m,ElRow:_,ElButton:D,ElCol:g,ElTag:M,ElSkeleton:b,ElSwitch:x,ElEmpty:v,ElTableColumn:p,ElCard:h},data(){return{credentialType:P,serviceType:A,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!I(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return I(this.$store.getters.site)?!1:R()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||z.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{L.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{L.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:j,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:O,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=F.INDIVIDUAL){return new Promise((t,n)=>{z.getAll({limit:this.limit,...e===F.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:N.USAGE,scope:e}).then(({data:n})=>{e===F.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{L.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(F.INDIVIDUAL),this.onFetchApplications(F.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){z.create({type:N.USAGE,scope:F.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(F.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}`}}}),V={class:`title`},H={key:1,class:`summary-card`},U={class:`icon-wrapper`},W={class:`label`},G={class:`value`},K={class:`description`},q={key:1,class:`flex flex-row justify-between items-center gap-3`},J={class:`summary-card min-w-0 flex-1`},Y={class:`flex justify-start items-center gap-2 mb-2 w-full`},X={class:`icon-wrapper !mb-0`},Z={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},Q={class:`label`},ne={class:`value`},re={class:`description`},ie={class:`flex flex-col items-end gap-2 shrink-0`},ae={class:`copy`},oe={key:0,class:`expired-at`},se={class:`flex flex-wrap items-center justify-end gap-1`},ce={class:`application-cards block sm:hidden`},le={class:`flex items-center gap-2 flex-wrap`},ue={class:`application-card__name`},de={class:`application-card__id`},fe={class:`truncate`},pe={class:`application-card__row`},$={class:`label`},me={class:`value`},he={key:0,class:`application-card__row`},ge={class:`label`},_e={class:`value`},ve={key:1,class:`application-card__row`},ye={class:`label`},be={class:`flex items-center justify-end gap-2 mt-3`},xe={class:`pagination`};function Se(f,p,m,h,g,_){let v=s(`el-col`),y=s(`el-row`),b=s(`el-skeleton`),x=s(`applications-icon`),S=s(`el-card`),C=s(`wallet-icon`),w=s(`copy-to-clipboard`),T=s(`analytics-icon`),E=s(`el-button`),D=s(`credits-icon`),O=s(`el-table-column`),k=s(`el-tag`),A=s(`el-switch`),j=s(`el-table`),M=s(`el-empty`),N=s(`pagination`),P=te(`loading`);return d(),c(y,{class:`application-list`},{default:l(()=>[r(v,{span:24},{default:l(()=>[r(y,null,{default:l(()=>[r(v,{span:24},{default:l(()=>[e(`h2`,V,n(f.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(y,{gutter:15,class:`mb-3`},{default:l(()=>[r(v,{md:12,xs:24},{default:l(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:l(()=>[f.loading?(d(),c(b,{key:0})):(d(),a(`div`,H,[e(`div`,U,[r(x,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,W,n(f.$t(`application.title.count`)),1),e(`p`,G,n(f.individualApplicationsTotal),1),e(`p`,K,n(f.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),f.showGlobalPayment&&f.globalApplications?.length>0?(d(),c(v,{key:0,md:12,xs:24},{default:l(()=>[r(S,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:l(()=>[f.loading?(d(),c(b,{key:0})):(d(),a(`div`,q,[e(`div`,J,[e(`div`,Y,[e(`div`,X,[r(C,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`span`,Z,[t(n(f.$t(`application.field.id`))+`: `+n(f.globalApplications?.[0]?.id)+` `,1),f.globalApplications?.[0]?.id?(d(),c(w,{key:0,content:f.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,Q,n(f.$t(`application.title.globalBalance`)),1),e(`p`,ne,n(f.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(f.$t(`service.unit.credits`)),1),e(`p`,re,n(f.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,ie,[r(E,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:p[0]||=e=>f.onGoUsage(f.globalApplications?.[0])},{default:l(()=>[r(T,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.usage`)),1)]),_:1}),f.showGlobalPayment?(d(),c(E,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:p[1]||=e=>f.onBuyMore(f.globalApplications?.[0])},{default:l(()=>[r(D,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(y,null,{default:l(()=>[r(v,{span:24},{default:l(()=>[r(S,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:l(()=>[ee((d(),c(j,{data:f.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":f.$t(`common.message.noData`)},{default:l(()=>[r(O,{prop:`id`,label:f.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:l(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ae,[r(w,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(O,{label:f.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(e=>[e.row?.type===`Period`?(d(),c(k,{key:0,type:`success`,effect:`dark`,round:``},{default:l(()=>[t(n(f.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(d(),c(k,{key:1,effect:`dark`,round:``},{default:l(()=>[t(n(f.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(O,{label:f.$t(`application.field.name`),width:`180px`},{default:l(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(d(),c(k,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:l(()=>[t(n(f.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(O,{prop:`remaining_amount`,label:f.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:l(t=>[e(`span`,null,n(f.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(O,{prop:`used_amount`,label:f.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:l(t=>[e(`span`,null,n(f.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(O,{prop:`allow_consume_global`,label:f.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:l(e=>[e.row.service?.type===f.serviceType.API?(d(),c(A,{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=>f.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(O,{label:f.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:l(e=>[e.row.expired_at?(d(),a(`span`,oe,n(f.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(O,{fixed:`right`,width:`200px`},{default:l(a=>[e(`div`,se,[r(E,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>f.onGoUsage(a?.row)},{default:l(()=>[r(T,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),f.rowCanPay(a?.row)?(d(),c(E,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>f.onBuyMore(a?.row)},{default:l(()=>[r(D,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[P,f.loading]])]),_:1}),e(`div`,ce,[f.loading?(d(),c(b,{key:0,rows:4,animated:``})):(d(),a(o,{key:1},[f.individualApplications?.length?(d(!0),a(o,{key:1},u(f.individualApplications,o=>(d(),c(S,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:l(()=>[e(`div`,le,[e(`span`,ue,n(o?.service?.title),1),o?.type===`Period`?(d(),c(k,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:l(()=>[t(n(f.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(d(),c(k,{key:1,effect:`dark`,size:`small`,round:``},{default:l(()=>[t(n(f.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(d(),c(k,{key:2,type:`info`,size:`small`,round:``},{default:l(()=>[t(n(f.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,de,[e(`span`,fe,n(f.$t(`application.field.id`))+`: `+n(o.id),1),r(w,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,pe,[e(`span`,$,n(f.$t(`application.field.remainingAmount`)),1),e(`span`,me,n(f.getRemainingAmount(o)),1)]),o?.expired_at?(d(),a(`div`,he,[e(`span`,ge,n(f.$t(`application.field.expiredAt`)),1),e(`span`,_e,n(f.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===f.serviceType.API?(d(),a(`div`,ve,[e(`span`,ye,n(f.$t(`application.field.allowConsumeGlobal`)),1),r(A,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>f.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,be,[r(E,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>f.onGoUsage(o)},{default:l(()=>[r(T,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),f.rowCanPay(o)?(d(),c(E,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>f.onBuyMore(o)},{default:l(()=>[r(D,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(f.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(d(),c(M,{key:0,description:f.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(y,null,{default:l(()=>[r(v,{span:24},{default:l(()=>[e(`div`,xe,[r(N,{"current-page":f.page,"page-size":f.limit,total:f.individualApplicationsTotal,onChange:f.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Ce=k(B,[[`render`,Se],[`__scopeId`,`data-v-d88616c5`]]);export{Ce 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,st as f,tt as p,z as m}from"./vendor-chart-Dw-P17PN.js";import{t as ee}from"./switch-
|
|
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,st as f,tt as p,z as m}from"./vendor-chart-Dw-P17PN.js";import{t as ee}from"./switch-DGjAGv1c.js";import{n as te,t as h}from"./shield-DN9xtQPd.js";import{t as g}from"./folder-DhGoROwY.js";import{t as _}from"./mouse-pointer-2-9NtAMIrw.js";import{t as v}from"./pencil-nTiWk3T7.js";import{t as y}from"./plus-BCeJVIcm.js";import{t as b}from"./terminal-BUNlX6R9.js";import{t as x}from"./wand-sparkles-Cfgyd-ZM.js";import{Ai as S,E as C,O as w,Oi as ne,ai as T,cr as E,mi as D,ni as O,zi as k}from"./index-h4BcqHjk.js";var A=D(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),j=D(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),M=D(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),N=D(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),P=m({name:`LocalToolsSetting`,components:{AddIcon:y,ElButton:S,ElTag:ne,ElSwitch:ee,ElInput:k,FolderIcon:g,MagicIcon:x,SecurityIcon:h},data(){return{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!!w()},android(){return T()},canInstallXhs(){return this.a11yEnabled&&this.computerUse}},async mounted(){let e=w();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 w()?.perm?.status();this.a11yEnabled=e?.accessibility===!0}finally{this.refreshingA11y=!1}}},async openAndroidAccessibility(){await w()?.perm?.openPane(`accessibility`)},async fetchXhsSkill(){this.xhsLoading=!0,this.xhsError=``;try{let e=await E.get(`/skills/`,{baseURL:`${O()}/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 E.post(`/skills/${e.id}/install/`,{},{baseURL:`${O()}/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=w();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 w()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
|
|
4
4
|
`).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,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{t as s}from"./LocalTools-
|
|
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{t as s}from"./LocalTools-BEtyOdPc.js";import{E as c}from"./index-h4BcqHjk.js";var l=o({name:`SettingsLocalTools`,components:{LocalToolsSetting:s}}),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=c(l,[[`render`,d],[`__scopeId`,`data-v-ac732814`]]);export{f 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,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-
|
|
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-CDn1-zJX.js";import{t as p}from"./checkbox-DLvBiGkW.js";import{t as m}from"./divider-BNWJAaA2.js";import"./constants-D-3QKDN1.js";import{Ai as h,E as g,Qr as _,Ut as v,Zr as y,ei as b,gi as x,ri as S,sr as C,xi as w}from"./index-h4BcqHjk.js";import{t as T}from"./Status-cFY4YqIR.js";var E=d({name:`ApplicationConfirm`,components:{ElDialog:w,ElDivider:m,ElCheckbox:p,ElButton:h},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:S,onApply(){if(!this.checked){x.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(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=g(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===b.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=v(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await C.create({type:_.USAGE,scope:y.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):x.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0),n=this.$store.state.site?.title||`AceData`;x({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=g(F,[[`render`,L],[`__scopeId`,`data-v-334ded1d`]]);export{R as default};
|