@acedatacloud/nexior 3.330.1 → 3.330.2
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-BzkhBHWS.js → ApiCodeButton-D8Lr9i4E.js} +1 -1
- package/dist/assets/{Artifacts-DmLZnVJc.js → Artifacts-Dr-3gz-k.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-BJIw5SSf.js → AskUserQuestionCard-Binv5IB7.js} +1 -1
- package/dist/assets/{AudioPreview-BckRaAPm.js → AudioPreview-CLtIeBY8.js} +1 -1
- package/dist/assets/{Auth-DmvyHjqF.js → Auth-DqRBNYWP.js} +1 -1
- package/dist/assets/{Bare-DP2nJiH8.js → Bare-CALSQoZM.js} +1 -1
- package/dist/assets/{BotPlaceholder-B9ulHBEZ.js → BotPlaceholder-CCj8ODYM.js} +1 -1
- package/dist/assets/{BottomFooter-D8oaRG-T.js → BottomFooter-COeqv3_V.js} +1 -1
- package/dist/assets/{Callback-DQgxHHPS.js → Callback-R_XbxciR.js} +1 -1
- package/dist/assets/{CodeSnippet-CcVEZTvC.js → CodeSnippet-CT8KY-5q.js} +1 -1
- package/dist/assets/{Console-DaU3BqdH.js → Console-BiAjSoke.js} +1 -1
- package/dist/assets/{Consumption-D3lzzWzO.js → Consumption-Dgskudi5.js} +1 -1
- package/dist/assets/{Conversation-DnrOOl5o.js → Conversation-ByUS-JXR.js} +1 -1
- package/dist/assets/{Conversation-CZhjEkax.js → Conversation-CNwcfxrG.js} +1 -1
- package/dist/assets/{CopyToClipboard-B3wEx6PW.js → CopyToClipboard-CobD01a5.js} +1 -1
- package/dist/assets/{Detail-BpVi2BmT.js → Detail-DY26RI3C.js} +2 -2
- package/dist/assets/{Extra-B2pxMaNh.js → Extra-BFQoEWWH.js} +1 -1
- package/dist/assets/{FilePreview-BmE28GTy.js → FilePreview-xnEz6GyW.js} +1 -1
- package/dist/assets/{Hailuo-kcJqOzZm.js → Hailuo-BQjFFXNn.js} +1 -1
- package/dist/assets/{History-ByNA8ZnE.js → History-BnGaDVYw.js} +1 -1
- package/dist/assets/{ImagePreview-DvE8T3Eo.js → ImagePreview-D4In_JJ4.js} +1 -1
- package/dist/assets/{ImageWrapper-PXlVdR5B.js → ImageWrapper-BJeG-xzl.js} +1 -1
- package/dist/assets/{Index-DKrfswus.js → Index-0nYCdsfM.js} +1 -1
- package/dist/assets/{Index-CYXfzEyN.js → Index-6P-60LST.js} +1 -1
- package/dist/assets/{Index-DqfdDp9H2.js → Index-B2r1Fkrx2.js} +1 -1
- package/dist/assets/{Index-nQr71r_l.js → Index-B382x-ir.js} +1 -1
- package/dist/assets/{Index-Cq_MrAec.js → Index-B7_Gj_LH.js} +1 -1
- package/dist/assets/{Index-GGYXuBSu.js → Index-B9nJUV8u.js} +1 -1
- package/dist/assets/{Index-CpwCpmW1.js → Index-BAVyV816.js} +1 -1
- package/dist/assets/{Index-CQC7i5Mu.js → Index-BJj6egLD.js} +1 -1
- package/dist/assets/{Index-BLdDUsuP.js → Index-BSHH_ixy.js} +1 -1
- package/dist/assets/{Index-BZEg4D79.js → Index-BVNJQ2uc.js} +1 -1
- package/dist/assets/{Index-ByCrVnzh2.js → Index-BlHL5tuG2.js} +1 -1
- package/dist/assets/{Index-DQvNHgFe.js → Index-C-d54Q-G.js} +1 -1
- package/dist/assets/{Index-Cq7CMdQ-.js → Index-C0obpEk3.js} +1 -1
- package/dist/assets/{Index-VG9SFLF4.js → Index-CcLyG5xQ.js} +1 -1
- package/dist/assets/{Index-DIm0q-zo.js → Index-CdQZB7ed.js} +1 -1
- package/dist/assets/{Index-C0NrfaH8.js → Index-CjQe2PA6.js} +1 -1
- package/dist/assets/{Index-DNf4A2dF.js → Index-CudxdTgY.js} +1 -1
- package/dist/assets/{Index-H6e_1HzK2.js → Index-DEYW-G__2.js} +1 -1
- package/dist/assets/{Index-DpPnMwVD.js → Index-DLBXyN_c.js} +1 -1
- package/dist/assets/{Index-D9qfg41M.js → Index-DM7IsWFf.js} +1 -1
- package/dist/assets/Index-DXM3WRhr.css +1 -0
- package/dist/assets/{Index-Bh8ViRmF2.js → Index-DuD4uVbb2.js} +1 -1
- package/dist/assets/{Index-CXLIWFzu.js → Index-N0DSTQo2.js} +1 -1
- package/dist/assets/{Index-CDvyioDo2.js → Index-PrHLCPDs2.js} +1 -1
- package/dist/assets/{Index-CSCEyhmK.js → Index-SwXF_Nnr.js} +1 -1
- package/dist/assets/{Index-jCyy_m2a.js → Index-e3tn2ObB.js} +1 -1
- package/dist/assets/{Index-CD8jMjp2.js → Index-l7bMjdDh.js} +1 -1
- package/dist/assets/Index-otR8IhYq.js +1 -0
- package/dist/assets/{Index-DNQCUB0v.js → Index-pTxb97K9.js} +1 -1
- package/dist/assets/{Index-D990apVP2.js → Index-wR1oJAwn2.js} +1 -1
- package/dist/assets/{Index-QqIC7IND2.js → Index-zpGjapYP2.js} +1 -1
- package/dist/assets/{Invitees-ujnDp-Z6.js → Invitees-DmMAQ-PI.js} +1 -1
- package/dist/assets/{List-DKvAZQMf.js → List-CFnj6Hf_.js} +1 -1
- package/dist/assets/{List-Fe0cqSrW.js → List-DV0u1M4F.js} +1 -1
- package/dist/assets/{List-BlcmzMsG.js → List-aNqIyCRY.js} +1 -1
- package/dist/assets/{LocalTools-C0CoTvlu.js → LocalTools-B3naEaby.js} +1 -1
- package/dist/assets/{LocalTools-BKjypFQz.js → LocalTools-Ci7tX2CK.js} +1 -1
- package/dist/assets/{Main-ChuxIGKX.js → Main-Bz5l6dd8.js} +1 -1
- package/dist/assets/{Message-DKL6CHOT.js → Message-UktS8Qo7.js} +1 -1
- package/dist/assets/{Model-D3qPbDxu.js → Model-DMi1-KF7.js} +1 -1
- package/dist/assets/{Navigator-BQaLv-3L.js → Navigator-CdWvL0LB.js} +3 -3
- package/dist/assets/{NotFound-BpqS1Zzj.js → NotFound-D2Uyfqrp.js} +1 -1
- package/dist/assets/{Pay-MfVMXYH0.js → Pay-DeHjwgWe.js} +1 -1
- package/dist/assets/{Player-CX-iVgR7.js → Player-7cCfxKzR.js} +1 -1
- package/dist/assets/{Poivelle-_WodQIac2.js → Poivelle-CM3z0iVy2.js} +1 -1
- package/dist/assets/{PromptTextarea-h_ilLkbi.js → PromptTextarea-DfDNaV7A.js} +1 -1
- package/dist/assets/{RealtimeCall-zUb7mEA7.js → RealtimeCall-CnXBS8t1.js} +1 -1
- package/dist/assets/{ScheduledTasks-CFBNLRuz.js → ScheduledTasks-CG0NO9ZZ.js} +1 -1
- package/dist/assets/{Status-CgJJt-vG.js → Status-B2Q-2Wyr.js} +1 -1
- package/dist/assets/{Subscribe-DKQs-_2W.js → Subscribe-CG7yvyO8.js} +1 -1
- package/dist/assets/{TabSwitcher-B5k_8RMO.js → TabSwitcher-BNks92qw.js} +1 -1
- package/dist/assets/{Tts-C_WMy2Jc.js → Tts-B6OSZh-O.js} +1 -1
- package/dist/assets/{VideoPlayer-UNsNlbF9.js → VideoPlayer-k3Ldw9Fb.js} +1 -1
- package/dist/assets/{alert-CvYeFxpp.js → alert-aGWGlhyi.js} +1 -1
- package/dist/assets/arrow-down-D4NEMo6o.js +1 -0
- package/dist/assets/{arrow-down-wide-narrow-D__sbhC5.js → arrow-down-wide-narrow-CBvgW7Cq.js} +1 -1
- package/dist/assets/arrow-left-CsP0ABa3.js +1 -0
- package/dist/assets/arrow-right-BG5p7k6j.js +1 -0
- package/dist/assets/arrow-up-DFqD7eHw.js +1 -0
- package/dist/assets/{avatar-DbjW5E1G.js → avatar-D3-CuwKi.js} +1 -1
- package/dist/assets/{basic-Mhhc6fQw.js → basic-nNUwOuz7.js} +1 -1
- package/dist/assets/{box-DxQeJmA0.js → box-CWr58MOh.js} +1 -1
- package/dist/assets/{boxes-FpgJRmSP.js → boxes-DaWSOxZC.js} +1 -1
- package/dist/assets/{brain-BkYXtgp_.js → brain-CxcwjBQc.js} +1 -1
- package/dist/assets/{chart-no-axes-combined-CYwY4LnJ.js → chart-no-axes-combined-D1kSYY9A.js} +1 -1
- package/dist/assets/{chat-BQ3mctW7.js → chat-CnKkBYJW.js} +1 -1
- package/dist/assets/check-BNcS1dGL.js +1 -0
- package/dist/assets/chevron-down-Bc5dTxUa.js +1 -0
- package/dist/assets/chevron-right-4wCKukT3.js +1 -0
- package/dist/assets/circle-check-P_IPZeI2.js +1 -0
- package/dist/assets/clock-B7IhOYYN.js +1 -0
- package/dist/assets/{codingBridge-KChNdAcG.js → codingBridge-DZEczeLe.js} +1 -1
- package/dist/assets/{codingBridgeNotify-B96QC7Wg.js → codingBridgeNotify-Dq-7a2B9.js} +2 -2
- package/dist/assets/{coins-wE7lvXoA.js → coins-Bkyf11zx.js} +1 -1
- package/dist/assets/{collapse-C3GgtJ5b.js → collapse-CFedqlxn.js} +1 -1
- package/dist/assets/{createTaskActions-DI0ygrcF.js → createTaskActions-CzwUWJr7.js} +1 -1
- package/dist/assets/{digitalhuman-pD-UZQ_h.js → digitalhuman-HUyJ7Uo5.js} +1 -1
- package/dist/assets/{dollar-sign-DHsTvp0K.js → dollar-sign-BkiTuqOT.js} +1 -1
- package/dist/assets/{download-DEqA7FHK.js → download-dp9ZV5XA.js} +1 -1
- package/dist/assets/{drawer-FoelQ1jk.js → drawer-DcgCZ31v.js} +1 -1
- package/dist/assets/{dropdown-8rJAlYIR.js → dropdown-CjYbH7nc.js} +1 -1
- package/dist/assets/{dropdown-CZ_glYZQ.js → dropdown-yvYwNVzD.js} +1 -1
- package/dist/assets/{ellipsis-sYPOFvkE.js → ellipsis-4vD9xdkH.js} +1 -1
- package/dist/assets/{esm-BPakpmL_.js → esm-BVEOupDu.js} +1 -1
- package/dist/assets/{esm-S093gPtB.js → esm-CFKrJosS.js} +1 -1
- package/dist/assets/esm-Cg55iA0t.js +1 -0
- package/dist/assets/{esm-DJTuHDp0.js → esm-D4-qoBFc.js} +1 -1
- package/dist/assets/{esm-DgfGXWQp.js → esm-Dq0L2-7o.js} +3 -3
- package/dist/assets/{esm-BYwHHxP5.js → esm-IhiVw2ze.js} +2 -2
- package/dist/assets/{esm-BbumsI5-.js → esm-bNDwWdM4.js} +2 -2
- package/dist/assets/{external-link-gUz5_zWo.js → external-link-BY18tYsQ.js} +1 -1
- package/dist/assets/{eye-CbgR3nF6.js → eye-BUUGqKwe.js} +1 -1
- package/dist/assets/{file-output-BsfAuD0j.js → file-output-DVxHksbh.js} +1 -1
- package/dist/assets/{file-text-DTiwnKrx.js → file-text-hFGYRjQg.js} +1 -1
- package/dist/assets/{fish-CrbEaNah.js → fish-B-gBtX0I.js} +1 -1
- package/dist/assets/{flux-Bn2q8VWa.js → flux-Cr78Tdi4.js} +1 -1
- package/dist/assets/{folder-okzkHXVJ.js → folder-CCUPcJzs.js} +1 -1
- package/dist/assets/gauge-CBLqkAUv.js +1 -0
- package/dist/assets/{globe-Buu3csej.js → globe-CNhdLZjI.js} +1 -1
- package/dist/assets/{grokvideo-BIkQ2pS8.js → grokvideo-DOmkv5qg.js} +1 -1
- package/dist/assets/{hailuo-jww8sSWf.js → hailuo-kywwujNt.js} +1 -1
- package/dist/assets/{headphones-Cn0WnnUi.js → headphones-DSDe66Nv.js} +1 -1
- package/dist/assets/{history-CBYOgyE0.js → history-BmX1vVON.js} +1 -1
- package/dist/assets/{image-D_CnB-x8.js → image-DrxguMaF.js} +1 -1
- package/dist/assets/{index-DDsc4-VK.js → index-q3EZ6Mqo.js} +3 -3
- package/dist/assets/{index.browser.esm-DJ--DeYQ.js → index.browser.esm-DzsneLGt.js} +1 -1
- package/dist/assets/{index.es-BdtEQv8Q.js → index.es-DMAEtG-0.js} +1 -1
- package/dist/assets/{info-DS6qnkrJ.js → info-CoB_XFSo.js} +1 -1
- package/dist/assets/{input-number-9EzHHBvS.js → input-number-CII6cbBx.js} +1 -1
- package/dist/assets/{key-round-reIrbDKR.js → key-round-DFkAG3Hz.js} +1 -1
- package/dist/assets/{kling-DnRWz5L_.js → kling-AKGn0FOR.js} +1 -1
- package/dist/assets/{languages-BoiDiMzP.js → languages-BClGs-3-.js} +1 -1
- package/dist/assets/{laptop-DwrWci6P.js → laptop-C-fHlo-h.js} +1 -1
- package/dist/assets/{lightbulb-B2QU3oSC.js → lightbulb-HU8gUN6p.js} +1 -1
- package/dist/assets/{link-Bdu78_yx.js → link-BG-ROGKi.js} +1 -1
- package/dist/assets/loader-circle-DLsuSdIW.js +1 -0
- package/dist/assets/{luma-BiGuKU3g.js → luma-BDtWWVj5.js} +1 -1
- package/dist/assets/{maestro-CN1FgJmX.js → maestro-AYjxanGx.js} +1 -1
- package/dist/assets/{mail-BbjdX2bc.js → mail-DIhtCD7n.js} +1 -1
- package/dist/assets/{message-circle-0YrnqODh.js → message-circle-DnN3ojBA.js} +1 -1
- package/dist/assets/{mic-D1cHPnK3.js → mic-4AmyAjOr.js} +1 -1
- package/dist/assets/{midjourney-TBrk2k5b.js → midjourney-Cen_FzWx.js} +1 -1
- package/dist/assets/{mobileLocalExec-BVB_SKMx.js → mobileLocalExec-mFi0l25j.js} +2 -2
- package/dist/assets/{mouse-pointer-2-DR2i9v6t.js → mouse-pointer-2-BfzMdKm2.js} +1 -1
- package/dist/assets/music-2-DbKO4cqj.js +1 -0
- package/dist/assets/{nanobanana-kBtJ4n8E.js → nanobanana-_yovoyht.js} +1 -1
- package/dist/assets/{omni-BfEhnusR.js → omni-Bd24tCAQ.js} +1 -1
- package/dist/assets/{openaiimage-D2TgEG7p.js → openaiimage-DREjWPmX.js} +1 -1
- package/dist/assets/{pagination-CNY-3TH1.js → pagination-CbK56qlZ.js} +1 -1
- package/dist/assets/{pagination-BoCv2-qy.js → pagination-DLcNYR9W.js} +1 -1
- package/dist/assets/{palette-haNdOTj8.js → palette-DDSn0Uvk.js} +1 -1
- package/dist/assets/{paperclip-BHk_AeHO.js → paperclip-C4cgZYEL.js} +1 -1
- package/dist/assets/{pause-DIS4z983.js → pause-DvYILJAb.js} +1 -1
- package/dist/assets/{pencil-Caj5Hnam.js → pencil-D9disow9.js} +1 -1
- package/dist/assets/{pika-B6O5lYQc.js → pika-DoQa1bfF.js} +1 -1
- package/dist/assets/{pixverse-S2Amp_eB.js → pixverse-CF4pIN5H.js} +1 -1
- package/dist/assets/play-Dph_BVOC.js +1 -0
- package/dist/assets/plus-MaZrwBBS.js +1 -0
- package/dist/assets/{poivelle-CrZs5Y1L.js → poivelle-BZ_Yhjg5.js} +1 -1
- package/dist/assets/{popover-cwjZR1PM.js → popover-DPf-uHkp.js} +1 -1
- package/dist/assets/{producer-B07kHUTn.js → producer-BddRCk6h.js} +1 -1
- package/dist/assets/{qrart-BPDLwOgh.js → qrart-CdKTVLSe.js} +1 -1
- package/dist/assets/{realtime-W6_Gwdj1.js → realtime-Dmmvlfp2.js} +1 -1
- package/dist/assets/{refresh-cw-DCZE2dJS.js → refresh-cw-BUFrfNwN.js} +1 -1
- package/dist/assets/rotate-ccw-xdtXls1D.js +1 -0
- package/dist/assets/rotate-cw-BkLzQqnB.js +1 -0
- package/dist/assets/{row-CRkRGNjN.js → row-7SGe6R0i.js} +1 -1
- package/dist/assets/search-BIdlVLiX.js +1 -0
- package/dist/assets/{seedance-CoSwpeHQ.js → seedance-5gxgZx-C.js} +1 -1
- package/dist/assets/{seedream-CSzzmvV-.js → seedream-Bi9xIS9F.js} +1 -1
- package/dist/assets/{select-DcGEHLoP.js → select-Dge0Ui3m.js} +1 -1
- package/dist/assets/{serp-BYafxhsb.js → serp-BFe66dmC.js} +1 -1
- package/dist/assets/{shield-BgeFOMEP.js → shield-BYfeX6ht.js} +1 -1
- package/dist/assets/{shuffle-CuEA9lKS.js → shuffle-C_wUcmMO.js} +1 -1
- package/dist/assets/{slider-CntvJq5o.js → slider-Ddj0K5Cv.js} +1 -1
- package/dist/assets/{sliders-horizontal-BW39Cgmw.js → sliders-horizontal-YhyKrGHF.js} +1 -1
- package/dist/assets/{solana-wallets-CF4IkOYU.js → solana-wallets-BKUzpdcQ.js} +2 -2
- package/dist/assets/{solana-wallets-vue-DlASZhf2.js → solana-wallets-vue-X0Je4IqE.js} +1 -1
- package/dist/assets/{sora-DvtyDrRk.js → sora-5iCtzSFm.js} +1 -1
- package/dist/assets/{sparkles-DQgXN1dg.js → sparkles-BENfCb_G.js} +1 -1
- package/dist/assets/square-C7CCnIRB.js +1 -0
- package/dist/assets/{suno-DP7EWtp5.js → suno-DfwL5Q77.js} +1 -1
- package/dist/assets/{switch-BFdf3Z4j.js → switch-9jtFRLVU.js} +1 -1
- package/dist/assets/{table-CRJnKRaX.js → table-Bc8_6EWw.js} +1 -1
- package/dist/assets/{tabs-BLoCcpjj.js → tabs-DT1yo-3d.js} +1 -1
- package/dist/assets/{tag-B9oywG6V.js → tag-DTkThcxP.js} +1 -1
- package/dist/assets/{taskDrawerMixin-C9NZkL6z.js → taskDrawerMixin-CORK_-hW.js} +1 -1
- package/dist/assets/terminal-jeXNvV4j.js +1 -0
- package/dist/assets/{time-picker-BeToLh5s.js → time-picker-Bj96adGM.js} +1 -1
- package/dist/assets/{tooltip-BSzURqeu.js → tooltip-B3MsWA6p.js} +1 -1
- package/dist/assets/{trash-2-rtoj4aT0.js → trash-2-CZbUaTdV.js} +1 -1
- package/dist/assets/{triangle-alert-YFpY3rLX.js → triangle-alert-CpzVp2jP.js} +1 -1
- package/dist/assets/{upload-9HJf6IRj.js → upload-CxZ2j52R.js} +1 -1
- package/dist/assets/{upload-DuJCvqjP.js → upload-GSRNbk78.js} +1 -1
- package/dist/assets/user-B8v5Qydb.js +1 -0
- package/dist/assets/{veo-B-5JSWsW.js → veo-Cs4h8lwX.js} +1 -1
- package/dist/assets/{video-CkIRABVZ.js → video-DQpkGhn6.js} +1 -1
- package/dist/assets/{volume-2-DmHW4ySG.js → volume-2-DpvJdqOY.js} +1 -1
- package/dist/assets/{wallet-DD7BRWEc.js → wallet-DWLeOXgB.js} +1 -1
- package/dist/assets/{wan-CPSJRQXZ.js → wan-jD1qER9L.js} +1 -1
- package/dist/assets/{wand-sparkles-CsuqI3Jr.js → wand-sparkles-BfXtzg0M.js} +1 -1
- package/dist/assets/{web-CjQz0lpZ.js → web-B4hcQk7r.js} +1 -1
- package/dist/assets/{web-D2UiVXdy.js → web-BWH-cMZ_.js} +1 -1
- package/dist/assets/{web-CJGBQYvZ.js → web-CeVmP-ZS.js} +1 -1
- package/dist/assets/{web-DH3Q2fhJ.js → web-CfAdqEA2.js} +1 -1
- package/dist/assets/{web-B7EnBIza.js → web-DG1TnNov.js} +1 -1
- package/dist/assets/{webextrator-MGiMw-OB.js → webextrator-CrfeLOND.js} +1 -1
- package/dist/assets/{zap-gdcptL_y.js → zap-B0ioEMv9.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/Index-2Eg2esX_.js +0 -1
- package/dist/assets/Index-k-RDLHZJ.css +0 -1
- package/dist/assets/arrow-down-De1spY7j.js +0 -1
- package/dist/assets/arrow-left-BUcIf7LW.js +0 -1
- package/dist/assets/arrow-right-DbtcF9Oj.js +0 -1
- package/dist/assets/arrow-up-CnJNmAPO.js +0 -1
- package/dist/assets/check-CLue1B5d.js +0 -1
- package/dist/assets/chevron-down-WtfPSJFK.js +0 -1
- package/dist/assets/chevron-right-CbKd-rAn.js +0 -1
- package/dist/assets/circle-check-a9dsi5uZ.js +0 -1
- package/dist/assets/clock-CNvQ2Wnk.js +0 -1
- package/dist/assets/esm-C8CBDmea.js +0 -1
- package/dist/assets/gauge-DVu_5LZj.js +0 -1
- package/dist/assets/loader-circle-DIdWTG46.js +0 -1
- package/dist/assets/music-2-D6DmDH1K.js +0 -1
- package/dist/assets/play-BRnIME5R.js +0 -1
- package/dist/assets/plus-BesrcmKk.js +0 -1
- package/dist/assets/rotate-ccw-C9xpbi86.js +0 -1
- package/dist/assets/rotate-cw-ova0GqQw.js +0 -1
- package/dist/assets/search-KN1jKOco.js +0 -1
- package/dist/assets/square-IGBkyjuN.js +0 -1
- package/dist/assets/terminal-DVlGLmYq.js +0 -1
- package/dist/assets/user-CJV_Vmur.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,Gt as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,ht as l,it as u,j as d,mt as f,qt as p,rt as m,tt as h,x as g,z as _}from"./vendor-chart-Dw-P17PN.js";import{r as v,t as y}from"./select-DcGEHLoP.js";import{n as b,t as x}from"./tabs-BLoCcpjj.js";import{t as S}from"./upload-DuJCvqjP.js";import{t as C}from"./tooltip-BSzURqeu.js";import{t as w}from"./alert-CvYeFxpp.js";import{t as T}from"./drawer-FoelQ1jk.js";import{t as E}from"./switch-BFdf3Z4j.js";import{n as D}from"./taskDrawerMixin-C9NZkL6z.js";import{t as O}from"./box-DxQeJmA0.js";import{t as k}from"./clock-CNvQ2Wnk.js";import{t as A}from"./CopyToClipboard-B3wEx6PW.js";import{n as j,r as M,t as N}from"./PromptTextarea-h_ilLkbi.js";import{t as P}from"./info-DS6qnkrJ.js";import{t as F}from"./languages-BoiDiMzP.js";import{t as ee}from"./triangle-alert-YFpY3rLX.js";import{t as te}from"./upload-9HJf6IRj.js";import{t as I}from"./wand-sparkles-CsuqI3Jr.js";import{t as L}from"./zap-gdcptL_y.js";import{ei as R,ni as z,ti as ne}from"./constants-OfAt86nA.js";import{Bt as re,E as B,Gt as ie,Hn as ae,Ht as oe,Mi as V,Ut as H,Vt as U,ai as W,en as G,gr as K,ni as q,vi as J}from"./index-DDsc4-VK.js";import{t as Y}from"./ImagePreview-DvE8T3Eo.js";import{t as se}from"./Consumption-D3lzzWzO.js";import{a as X,n as ce,r as le,t as ue}from"./pagination-CNY-3TH1.js";import{t as de}from"./VideoPlayer-UNsNlbF9.js";import{t as fe}from"./ApiCodeButton-BzkhBHWS.js";import{t as pe}from"./BotPlaceholder-B9ulHBEZ.js";var me=_({name:`LayoutVeo`,components:{MagicIcon:I,ElDrawer:T,ElButton:V},mixins:[D]}),he={class:`main flex flex-row flex-1`},ge={class:`config w-[320px] flex-none h-full min-h-0 overflow-hidden flex flex-col bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},_e={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function ve(t,n,r,a,s,d){let p=c(`magic-icon`),m=c(`el-button`),_=c(`el-drawer`);return h(),o(`div`,he,[e(`div`,ge,[u(t.$slots,`config`,{},void 0,!0)]),e(`div`,_e,[u(t.$slots,`result`,{},void 0,!0)]),l(i(m,{circle:``,class:`menu`,"aria-label":t.$t(`common.button.openMenu`),title:t.$t(`common.button.openMenu`),onClick:n[0]||=e=>t.drawer=!0},{default:f(()=>[i(p,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),_:1},8,[`aria-label`,`title`]),[[g,!t.tasksEmpty]]),i(_,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`generator-drawer`},{default:f(()=>[u(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ye=B(me,[[`render`,ve],[`__scopeId`,`data-v-293c9493`]]),Z=`veo31-fast-ingredients`,be=[{value:`veo31-fast`,label:`Veo 3.1 Fast`},{value:`veo3-fast`,label:`Veo 3 Fast`},{value:`veo31`,label:`Veo 3.1`},{value:`veo3`,label:`Veo 3`}],Q=(e,t)=>{let n=!!(e?.action&&e.action!==t),r={...e,action:t};return t===`text2video`?(r.model=r.model===`veo31-fast-ingredients`?z:r.model||`veo31-fast`,delete r.image_urls,r):t===`ingredients2video`?(r.model=Z,n?delete r.image_urls:r.image_urls=r.image_urls?.slice(0,3),r):(r.model=r.model===`veo31-fast-ingredients`?z:r.model||`veo31-fast`,n?delete r.image_urls:r.image_urls=r.image_urls?.slice(0,2),r)},xe=e=>{let t={...Q(e,e?.action||`text2video`),async:!0};return t.image_urls?.length||delete t.image_urls,t},Se=_({name:`ModelSelector`,components:{ElSelect:v,ElOption:y},computed:{isModelLocked(){return this.$store.state.veo?.config?.action===`ingredients2video`},options(){return this.isModelLocked?[{value:Z,label:`Veo 3.1 Fast`}]:be},value:{get(){return this.$store.state.veo?.config?.model},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,model:e})}}},mounted(){this.value||=z}}),Ce={class:`field`},we={class:`title font-bold`};function Te(t,n,a,l,u,p){let g=c(`el-option`),_=c(`el-select`);return h(),o(`div`,Ce,[e(`h2`,we,r(t.$t(`veo.name.model`)),1),i(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`veo.placeholder.select`),disabled:t.isModelLocked},{default:f(()=>[(h(!0),o(s,null,m(t.options,e=>(h(),d(g,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`disabled`])])}var Ee=B(Se,[[`render`,Te],[`__scopeId`,`data-v-90ed8cff`]]),De=_({name:`ActionSelector`,components:{ElTabs:b,ElTabPane:x},data(){return{}},computed:{options(){return[{value:`text2video`,label:this.$t(`veo.button.action1`)},{value:`image2video`,label:this.$t(`veo.button.action2`)},{value:`ingredients2video`,label:this.$t(`veo.button.actionIngredients`)}]},value(){return this.$store.state.veo?.config?.action||`text2video`}},mounted(){this.$store.state.veo?.config?.action||this.onUpdate(R)},methods:{onUpdate(e){this.$store.commit(`veo/setConfig`,Q(this.$store.state.veo?.config,e))}}});function Oe(e,t,n,r,i,a){let l=c(`el-tab-pane`),u=c(`el-tabs`);return h(),d(u,{"model-value":e.value,class:`action-tabs scenario-tabs scenario-tabs--divided`,stretch:``,"onUpdate:modelValue":e.onUpdate},{default:f(()=>[(h(!0),o(s,null,m(e.options,e=>(h(),d(l,{key:e.value,name:e.value,label:e.label},null,8,[`name`,`label`]))),128))]),_:1},8,[`model-value`,`onUpdate:modelValue`])}var ke=B(De,[[`render`,Oe],[`__scopeId`,`data-v-531a5c55`]]),Ae=_({name:`TranslationSelector`,components:{ElSwitch:E,InfoIcon:X},computed:{value:{get(){return this.$store.state.veo?.config?.translation},set(e){console.debug(`set translation`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,translation:e})}}},mounted(){this.value===void 0&&(this.value=!1)}}),je={class:`relative`},Me={class:`flex justify-between`},Ne={class:`flex justify-start items-center`},Pe={class:`text-sm font-bold`},Fe={class:`flex justify-end items-center`};function Ie(t,n,a,s,l,u){let d=c(`info-icon`),f=c(`el-switch`);return h(),o(`div`,je,[e(`div`,Me,[e(`div`,Ne,[e(`span`,Pe,r(t.$t(`veo.name.translation`)),1),i(d,{content:t.$t(`veo.description.translation`)},null,8,[`content`])]),e(`div`,Fe,[i(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`},null,8,[`modelValue`])])])])}var Le=B(Ae,[[`render`,Ie]]),Re=_({name:`AspectRatioSelector`,data(){return{options:[{value:`16:9`,label:`16:9`,width:25,height:13},{value:`9:16`,label:`9:16`,width:13,height:25}]}},computed:{active(){return this.options.findIndex(e=>e.value===this.value)||0},value:{get(){return this.$store.state.veo?.config?.aspect_ratio},set(e){console.debug(`set aspect_ratio`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,aspect_ratio:e})}}},mounted(){this.value||=ne}}),ze={class:`text-sm font-bold mb-2 block`},Be={class:`items`},Ve=[`onClick`],He={class:`name`};function Ue(n,i,a,c,l,u){return h(),o(`div`,null,[e(`span`,ze,r(n.$t(`veo.name.ratio`)),1),e(`div`,Be,[(h(!0),o(s,null,m(n.options,(i,a)=>(h(),o(`div`,{key:a,class:t({active:n.active===a,item:!0}),onClick:e=>n.value=i.value},[e(`div`,{class:t([`preview`,i.label])},[e(`div`,{class:`rect`,style:p({width:i.width+`px`,height:i.height+`px`})},null,4)],2),e(`p`,He,r(i.label),1)],10,Ve))),128))])])}var We=B(Re,[[`render`,Ue],[`__scopeId`,`data-v-28c472c4`]]),Ge=_({name:`StartEndImage`,components:{UploadIcon:te,ElUpload:S,ElButton:V,InfoIcon:X,ImagePreview:Y},mixins:[H,U],props:{limit:{type:Number,default:2},ingredients:{type:Boolean,default:!1}},emits:[`change`],data(){return{fileList:[],uploadUrl:W()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},title(){return this.ingredients?this.$t(`veo.button.actionIngredients`):this.$t(`veo.name.startEndImage`)},description(){return this.ingredients?this.$t(`veo.description.imageUrl`):this.$t(`veo.description.uploadStartEndImage`)},urls(){return this.fileList.map(e=>e.response?.file_url||e.url).filter(e=>!!e)},value:{get(){return this.$store.state?.veo?.config?.image_urls},set(){}}},watch:{limit(){this.fileList.length>this.limit&&(this.fileList=this.fileList.slice(0,this.limit),this.onSetStartEndImageUrl())}},mounted(){this.fileList=(this.value||[]).map((e,t)=>({name:`reference-${t+1}`,percentage:100,response:{file_url:e},status:`success`,uid:Date.now()+t,url:e}))},methods:{onExceed(){J.warning(this.$t(`veo.message.uploadReferencesLimit`,{limit:this.limit}))},onError(){J.error(this.$t(`veo.message.uploadReferencesError`))},onSetStartEndImageUrl(){let e=this.urls;this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,image_urls:e})},async onSuccess(){this.onSetStartEndImageUrl()},onRemove(e){let t=this.fileList.indexOf(e);t>=0&&this.fileList.splice(t,1),this.onSetStartEndImageUrl()}}}),Ke={class:`relative`},qe={class:`flex justify-between`},Je={class:`flex justify-start items-center`},Ye={class:`text-sm font-bold`};function Xe(t,s,l,u,p,m){let g=c(`info-icon`),_=c(`image-preview`),v=c(`upload-icon`),y=c(`el-button`),b=c(`el-upload`);return h(),o(`div`,Ke,[e(`div`,qe,[e(`div`,Je,[e(`span`,Ye,r(t.title),1),i(g,{content:t.description},null,8,[`content`])])]),i(b,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":s[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:t.limit,class:`upload-wrapper`,multiple:!0,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:f(({file:e})=>[e.url&&e.percentage!==void 0?(h(),d(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.onRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`])):a(``,!0)]),default:f(()=>[i(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:f(()=>[i(v,{class:`icon mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(t.$t(`veo.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`limit`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var Ze=B(Ge,[[`render`,Xe],[`__scopeId`,`data-v-89137805`]]),Qe=_({name:`PromptInput`,components:{PromptTextarea:N},computed:{prompt:{get(){return this.$store.state.veo?.config?.prompt},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function $e(e,t,n,r,i,a){let o=c(`prompt-textarea`);return h(),d(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`veo.name.prompt`),info:e.$t(`veo.description.prompt`),placeholder:e.$t(`veo.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var et=_({name:`ConfigPanel`,components:{MagicIcon:I,ElButton:V,Consumption:se,PromptInput:B(Qe,[[`render`,$e]]),ModelSelector:Ee,StartEndImage:Ze,ActionSelector:ke,TranslationSelector:Le,AspectRatioSelector:We},emits:[`generate`],computed:{config(){return this.$store.state.veo?.config},showsImages(){return this.config?.action===`image2video`||this.config?.action===`ingredients2video`},imageLimit(){return this.config?.action===`ingredients2video`?3:2},consumption(){return ie(this.config,this.service?.cost)},service(){return this.$store.state.veo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),tt={class:`flex flex-col h-full`},nt={class:`flex-1 overflow-y-auto p-5`},rt={class:`flex flex-col items-center justify-center px-5 pb-5`};function it(t,s,l,u,p,m){let g=c(`action-selector`),_=c(`model-selector`),v=c(`start-end-image`),y=c(`prompt-input`),b=c(`aspect-ratio-selector`),x=c(`translation-selector`),S=c(`consumption`),C=c(`magic-icon`),w=c(`el-button`);return h(),o(`div`,tt,[e(`div`,nt,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),t.showsImages?(h(),d(v,{key:t.config?.action,class:`mb-4`,limit:t.imageLimit,ingredients:t.config?.action===`ingredients2video`},null,8,[`limit`,`ingredients`])):a(``,!0),i(y,{class:`mb-4`}),i(b,{class:`mb-4`}),i(x,{class:`mb-4`})]),e(`div`,rt,[i(S,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),i(w,{type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:f(()=>[i(C,{class:`mr-2`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(t.$t(`veo.button.generate`)),1)]),_:1},8,[`onClick`])])])}var at=B(et,[[`render`,it]]),ot=_({name:`TaskPreview`,components:{ApplicationIcon:O,ChannelIcon:M,ExpandIcon:j,InfoIcon:P,LanguageIcon:F,LightningIcon:L,MagicIcon:I,TimeIcon:k,WarningIcon:ee,CopyToClipboard:A,ElAlert:w,VideoPlayer:de,ImagePreview:Y,ElTooltip:C,ElButton:V,ApiCodeButton:fe},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{referenceImages(){let e=this.modelValue?.request?.image_urls;return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]},actionLabel(){let e=this.modelValue?.request,t=e?.model===`veo31-fast-ingredients`||this.referenceImages.length>2?`ingredients2video`:this.referenceImages.length>0?`image2video`:`text2video`,n=e?.action||t;return this.$t({text2video:`veo.button.action1`,image2video:`veo.button.action2`,ingredients2video:`veo.button.actionIngredients`}[n]||`veo.name.action`)},traceId(){return this.modelValue?.response?.trace_id||this.modelValue?.trace_id},taskInfoClass(){return this.modelValue?.response?.success===!0?`success`:this.modelValue?.response?.success===!1?`failure`:`info`}},methods:{onDownload(e,t){e?.stopPropagation(),console.log(`on download`),window.open(t,`_blank`)},onOpenVideo(e){window.open(e,`_blank`)}}}),st={class:`preview`},ct={class:`left`},lt={class:`main`},ut={class:`bot`},dt={class:`datetime`},ft={class:`info`},pt={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},mt={key:1,class:`prompt mt-2`},ht={key:0},gt={key:1},_t={key:0,class:t({content:!0,failed:!0})},vt={key:0,class:`mb-4`},yt={key:1,class:t({operations:!0,"mt-2":!0})},bt={key:1,class:t({content:!0})},xt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},St={class:t({content:!0})},Ct={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},wt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Tt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Et={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Dt={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ot={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function kt(l,u,p,g,_,v){let y=c(`capability-presentation`),b=c(`image-preview`),x=c(`video-player`),S=c(`el-button`),C=c(`el-tooltip`),w=c(`api-code-button`),T=c(`warning-icon`),E=c(`info-icon`),D=c(`copy-to-clipboard`),O=c(`el-alert`),k=c(`application-icon`),A=c(`lightning-icon`),j=c(`expand-icon`),M=c(`language-icon`),N=c(`magic-icon`),P=c(`time-icon`),F=c(`channel-icon`);return h(),o(`div`,st,[e(`div`,ct,[i(y,{capability:`veo`,part:`avatar`,class:`avatar`})]),e(`div`,lt,[e(`div`,ut,[i(y,{capability:`veo`,part:`name`}),e(`span`,dt,r(l.$dayjs.format(``+new Date(parseFloat((l.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,ft,[l.referenceImages.length>0?(h(),o(`div`,pt,[(h(!0),o(s,null,m(l.referenceImages,(e,t)=>(h(),d(b,{key:`${t}-${e}`,url:e,name:`reference-${t+1}`,closable:!1},null,8,[`url`,`name`]))),128))])):a(``,!0),l.modelValue?.request?.prompt?(h(),o(`p`,mt,[n(r(l.modelValue?.request?.prompt)+` `,1),l.modelValue?.response?a(``,!0):(h(),o(`span`,ht,` - (`+r(l.$t(`veo.status.pending`))+`) `,1)),Array.isArray(l.modelValue?.response?.data)&&l.modelValue?.response?.data[0]?.state===`running`?(h(),o(`span`,gt,` - (`+r(l.$t(`veo.status.processing`))+`) `,1)):a(``,!0)])):a(``,!0)]),l.modelValue?.response?.success===!0&&l.modelValue?.response?.data?(h(),o(`div`,_t,[l.modelValue?.response?.data[0]?.video_url?(h(),o(`div`,vt,[i(x,{src:l.modelValue?.response?.data[0]?.video_url},null,8,[`src`])])):a(``,!0),l.modelValue?.response.success?(h(),o(`div`,yt,[i(C,{class:`box-item`,effect:`dark`,content:l.$t(`veo.message.downloadVideo`),placement:`top-start`},{default:f(()=>[l.modelValue?.response?.data[0]?.video_url?(h(),d(S,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:u[0]||=e=>l.onDownload(e,l.modelValue?.response?.data[0]?.video_url)},{default:f(()=>[n(r(l.$t(`veo.button.download`)),1)]),_:1})):a(``,!0)]),_:1},8,[`content`]),i(w,{path:`/veo/videos`,body:l.modelValue?.request},null,8,[`body`])])):a(``,!0)])):a(``,!0),l.modelValue?.response?.success===!1?(h(),o(`div`,bt,[i(O,{closable:!1,class:`failure`},{template:f(()=>[i(T,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.failure`)),1)]),default:f(()=>[e(`p`,xt,[i(E,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.failureReason`))+`: `+r(l.modelValue?.response?.error?.message)+` `,1),i(D,{content:l.modelValue?.response?.error?.message},null,8,[`content`])])]),_:1})])):a(``,!0),e(`div`,St,[i(O,{closable:!1,class:t([`mt-2`,`task-metadata`,l.taskInfoClass])},{default:f(()=>[l.modelValue?.request?.model?(h(),o(`p`,Ct,[i(k,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.model`))+`: `+r(l.modelValue?.request?.model),1)])):a(``,!0),e(`p`,wt,[i(A,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.action`))+`: `+r(l.actionLabel),1)]),l.modelValue?.request?.aspect_ratio?(h(),o(`p`,Tt,[i(j,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.ratio`))+`: `+r(l.modelValue?.request?.aspect_ratio),1)])):a(``,!0),l.modelValue?.request?.translation===void 0?a(``,!0):(h(),o(`p`,Et,[i(M,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.translation`))+`: `+r(l.$t(l.modelValue?.request?.translation?`seedance.button.on`:`seedance.button.off`)),1)])),e(`p`,$,[i(N,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.taskId`))+`: `+r(l.modelValue?.id)+` `,1),i(D,{content:l.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),l.modelValue?.elapsed?(h(),o(`p`,Dt,[i(P,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.elapsed`))+`: `+r(l.modelValue?.elapsed?.toFixed(2))+`s `,1)])):a(``,!0),l.traceId?(h(),o(`p`,Ot,[i(F,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.traceId`))+`: `+r(l.traceId)+` `,1),i(D,{content:l.traceId,class:`btn-copy inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`class`])])])])}var At=_({name:`RecentPanel`,components:{TaskPreview:B(ot,[[`render`,kt],[`__scopeId`,`data-v-54ddb667`]]),NoTasks:le,BotPlaceholder:pe,ScrollList:ce},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.veo?.tasks,items:this.$store.state.veo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),jt={key:0},Mt={key:2,class:`w-full h-full flex items-center justify-center`};function Nt(e,t,n,r,l,u){let p=c(`bot-placeholder`),g=c(`task-preview`),_=c(`scroll-list`),v=c(`no-tasks`);return h(),o(s,null,[e.tasks?.items===void 0?(h(),o(`div`,jt,[i(p)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(h(),d(_,{key:1,ref:`scrollList`,class:`tasks h-full w-full overflow-y-auto`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:f(()=>[(h(!0),o(s,null,m(e.tasks?.items,(e,t)=>(h(),d(g,{key:t,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):a(``,!0),e.tasks?.items?.length===0?(h(),o(`div`,Mt,[i(v)])):a(``,!0)],64)}var Pt=_({name:`VeoIndex`,components:{ConfigPanel:at,Layout:ye,RecentPanel:B(At,[[`render`,Nt]])},mixins:[oe],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.veo?.status?.getApplications===q.Request},tasksLoading(){return this.$store.state.veo?.status?.getTasks===q.Request||this.fetchingTasks},credential(){return this.$store.state.veo.credential},config(){return this.$store.state.veo.config},tasks(){return this.$store.state.veo.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug(`new tasks detected`)},deep:!0},initialized:{async handler(e){e&&(console.debug(`layout initialized`),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await ue({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`veo/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`veo/getApplications`),console.debug(`end onGetApplication`),await this.onGetTasks()},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`veo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!re(this.uploadTracker,e=>this.$t(e),e=>J.warning(e)))return;let e=xe(this.config);if(!G())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}if((e.action===`image2video`||e.action===`ingredients2video`)&&!(e.image_urls&&e.image_urls.length>0)){J.warning(this.$t(`veo.message.imageRequired`));return}J.info(this.$t(`veo.message.startingTask`)),K(`veo`,ae.generate(e,{token:t})).then(()=>{J.success(this.$t(`veo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?J.error(this.$t(`veo.message.usedUp`)):J.error(this.$t(`veo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function Ft(e,t,n,r,a,o){let s=c(`config-panel`),l=c(`recent-panel`),u=c(`layout`);return h(),d(u,null,{config:f(()=>[i(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:f(()=>[i(l,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var It=B(Pt,[[`render`,Ft]]);export{It as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,Gt as t,I as n,Jt as r,L as i,M as a,N as o,T as s,at as c,ht as l,it as u,j as d,mt as f,qt as p,rt as m,tt as h,x as g,z as _}from"./vendor-chart-Dw-P17PN.js";import{r as v,t as y}from"./select-Dge0Ui3m.js";import{n as b,t as x}from"./tabs-DT1yo-3d.js";import{t as S}from"./upload-GSRNbk78.js";import{t as C}from"./tooltip-B3MsWA6p.js";import{t as w}from"./alert-aGWGlhyi.js";import{t as T}from"./drawer-DcgCZ31v.js";import{t as E}from"./switch-9jtFRLVU.js";import{n as D}from"./taskDrawerMixin-CORK_-hW.js";import{t as O}from"./box-CWr58MOh.js";import{t as k}from"./clock-B7IhOYYN.js";import{t as A}from"./CopyToClipboard-CobD01a5.js";import{n as j,r as M,t as N}from"./PromptTextarea-DfDNaV7A.js";import{t as P}from"./info-CoB_XFSo.js";import{t as F}from"./languages-BClGs-3-.js";import{t as ee}from"./triangle-alert-CpzVp2jP.js";import{t as te}from"./upload-CxZ2j52R.js";import{t as I}from"./wand-sparkles-BfXtzg0M.js";import{t as L}from"./zap-B0ioEMv9.js";import{ei as R,ni as z,ti as ne}from"./constants-OfAt86nA.js";import{Bt as re,E as B,Gt as ie,Hn as ae,Ht as oe,Mi as V,Ut as H,Vt as U,ai as W,en as G,gr as K,ni as q,vi as J}from"./index-q3EZ6Mqo.js";import{t as Y}from"./ImagePreview-D4In_JJ4.js";import{t as se}from"./Consumption-Dgskudi5.js";import{a as X,n as ce,r as le,t as ue}from"./pagination-CbK56qlZ.js";import{t as de}from"./VideoPlayer-k3Ldw9Fb.js";import{t as fe}from"./ApiCodeButton-D8Lr9i4E.js";import{t as pe}from"./BotPlaceholder-CCj8ODYM.js";var me=_({name:`LayoutVeo`,components:{MagicIcon:I,ElDrawer:T,ElButton:V},mixins:[D]}),he={class:`main flex flex-row flex-1`},ge={class:`config w-[320px] flex-none h-full min-h-0 overflow-hidden flex flex-col bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},_e={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function ve(t,n,r,a,s,d){let p=c(`magic-icon`),m=c(`el-button`),_=c(`el-drawer`);return h(),o(`div`,he,[e(`div`,ge,[u(t.$slots,`config`,{},void 0,!0)]),e(`div`,_e,[u(t.$slots,`result`,{},void 0,!0)]),l(i(m,{circle:``,class:`menu`,"aria-label":t.$t(`common.button.openMenu`),title:t.$t(`common.button.openMenu`),onClick:n[0]||=e=>t.drawer=!0},{default:f(()=>[i(p,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),_:1},8,[`aria-label`,`title`]),[[g,!t.tasksEmpty]]),i(_,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`generator-drawer`},{default:f(()=>[u(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ye=B(me,[[`render`,ve],[`__scopeId`,`data-v-293c9493`]]),Z=`veo31-fast-ingredients`,be=[{value:`veo31-fast`,label:`Veo 3.1 Fast`},{value:`veo3-fast`,label:`Veo 3 Fast`},{value:`veo31`,label:`Veo 3.1`},{value:`veo3`,label:`Veo 3`}],Q=(e,t)=>{let n=!!(e?.action&&e.action!==t),r={...e,action:t};return t===`text2video`?(r.model=r.model===`veo31-fast-ingredients`?z:r.model||`veo31-fast`,delete r.image_urls,r):t===`ingredients2video`?(r.model=Z,n?delete r.image_urls:r.image_urls=r.image_urls?.slice(0,3),r):(r.model=r.model===`veo31-fast-ingredients`?z:r.model||`veo31-fast`,n?delete r.image_urls:r.image_urls=r.image_urls?.slice(0,2),r)},xe=e=>{let t={...Q(e,e?.action||`text2video`),async:!0};return t.image_urls?.length||delete t.image_urls,t},Se=_({name:`ModelSelector`,components:{ElSelect:v,ElOption:y},computed:{isModelLocked(){return this.$store.state.veo?.config?.action===`ingredients2video`},options(){return this.isModelLocked?[{value:Z,label:`Veo 3.1 Fast`}]:be},value:{get(){return this.$store.state.veo?.config?.model},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo.config,model:e})}}},mounted(){this.value||=z}}),Ce={class:`field`},we={class:`title font-bold`};function Te(t,n,a,l,u,p){let g=c(`el-option`),_=c(`el-select`);return h(),o(`div`,Ce,[e(`h2`,we,r(t.$t(`veo.name.model`)),1),i(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`veo.placeholder.select`),disabled:t.isModelLocked},{default:f(()=>[(h(!0),o(s,null,m(t.options,e=>(h(),d(g,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`disabled`])])}var Ee=B(Se,[[`render`,Te],[`__scopeId`,`data-v-90ed8cff`]]),De=_({name:`ActionSelector`,components:{ElTabs:b,ElTabPane:x},data(){return{}},computed:{options(){return[{value:`text2video`,label:this.$t(`veo.button.action1`)},{value:`image2video`,label:this.$t(`veo.button.action2`)},{value:`ingredients2video`,label:this.$t(`veo.button.actionIngredients`)}]},value(){return this.$store.state.veo?.config?.action||`text2video`}},mounted(){this.$store.state.veo?.config?.action||this.onUpdate(R)},methods:{onUpdate(e){this.$store.commit(`veo/setConfig`,Q(this.$store.state.veo?.config,e))}}});function Oe(e,t,n,r,i,a){let l=c(`el-tab-pane`),u=c(`el-tabs`);return h(),d(u,{"model-value":e.value,class:`action-tabs scenario-tabs scenario-tabs--divided`,stretch:``,"onUpdate:modelValue":e.onUpdate},{default:f(()=>[(h(!0),o(s,null,m(e.options,e=>(h(),d(l,{key:e.value,name:e.value,label:e.label},null,8,[`name`,`label`]))),128))]),_:1},8,[`model-value`,`onUpdate:modelValue`])}var ke=B(De,[[`render`,Oe],[`__scopeId`,`data-v-531a5c55`]]),Ae=_({name:`TranslationSelector`,components:{ElSwitch:E,InfoIcon:X},computed:{value:{get(){return this.$store.state.veo?.config?.translation},set(e){console.debug(`set translation`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,translation:e})}}},mounted(){this.value===void 0&&(this.value=!1)}}),je={class:`relative`},Me={class:`flex justify-between`},Ne={class:`flex justify-start items-center`},Pe={class:`text-sm font-bold`},Fe={class:`flex justify-end items-center`};function Ie(t,n,a,s,l,u){let d=c(`info-icon`),f=c(`el-switch`);return h(),o(`div`,je,[e(`div`,Me,[e(`div`,Ne,[e(`span`,Pe,r(t.$t(`veo.name.translation`)),1),i(d,{content:t.$t(`veo.description.translation`)},null,8,[`content`])]),e(`div`,Fe,[i(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`},null,8,[`modelValue`])])])])}var Le=B(Ae,[[`render`,Ie]]),Re=_({name:`AspectRatioSelector`,data(){return{options:[{value:`16:9`,label:`16:9`,width:25,height:13},{value:`9:16`,label:`9:16`,width:13,height:25}]}},computed:{active(){return this.options.findIndex(e=>e.value===this.value)||0},value:{get(){return this.$store.state.veo?.config?.aspect_ratio},set(e){console.debug(`set aspect_ratio`,e),this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,aspect_ratio:e})}}},mounted(){this.value||=ne}}),ze={class:`text-sm font-bold mb-2 block`},Be={class:`items`},Ve=[`onClick`],He={class:`name`};function Ue(n,i,a,c,l,u){return h(),o(`div`,null,[e(`span`,ze,r(n.$t(`veo.name.ratio`)),1),e(`div`,Be,[(h(!0),o(s,null,m(n.options,(i,a)=>(h(),o(`div`,{key:a,class:t({active:n.active===a,item:!0}),onClick:e=>n.value=i.value},[e(`div`,{class:t([`preview`,i.label])},[e(`div`,{class:`rect`,style:p({width:i.width+`px`,height:i.height+`px`})},null,4)],2),e(`p`,He,r(i.label),1)],10,Ve))),128))])])}var We=B(Re,[[`render`,Ue],[`__scopeId`,`data-v-28c472c4`]]),Ge=_({name:`StartEndImage`,components:{UploadIcon:te,ElUpload:S,ElButton:V,InfoIcon:X,ImagePreview:Y},mixins:[H,U],props:{limit:{type:Number,default:2},ingredients:{type:Boolean,default:!1}},emits:[`change`],data(){return{fileList:[],uploadUrl:W()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},title(){return this.ingredients?this.$t(`veo.button.actionIngredients`):this.$t(`veo.name.startEndImage`)},description(){return this.ingredients?this.$t(`veo.description.imageUrl`):this.$t(`veo.description.uploadStartEndImage`)},urls(){return this.fileList.map(e=>e.response?.file_url||e.url).filter(e=>!!e)},value:{get(){return this.$store.state?.veo?.config?.image_urls},set(){}}},watch:{limit(){this.fileList.length>this.limit&&(this.fileList=this.fileList.slice(0,this.limit),this.onSetStartEndImageUrl())}},mounted(){this.fileList=(this.value||[]).map((e,t)=>({name:`reference-${t+1}`,percentage:100,response:{file_url:e},status:`success`,uid:Date.now()+t,url:e}))},methods:{onExceed(){J.warning(this.$t(`veo.message.uploadReferencesLimit`,{limit:this.limit}))},onError(){J.error(this.$t(`veo.message.uploadReferencesError`))},onSetStartEndImageUrl(){let e=this.urls;this.$store.commit(`veo/setConfig`,{...this.$store.state?.veo?.config,image_urls:e})},async onSuccess(){this.onSetStartEndImageUrl()},onRemove(e){let t=this.fileList.indexOf(e);t>=0&&this.fileList.splice(t,1),this.onSetStartEndImageUrl()}}}),Ke={class:`relative`},qe={class:`flex justify-between`},Je={class:`flex justify-start items-center`},Ye={class:`text-sm font-bold`};function Xe(t,s,l,u,p,m){let g=c(`info-icon`),_=c(`image-preview`),v=c(`upload-icon`),y=c(`el-button`),b=c(`el-upload`);return h(),o(`div`,Ke,[e(`div`,qe,[e(`div`,Je,[e(`span`,Ye,r(t.title),1),i(g,{content:t.description},null,8,[`content`])])]),i(b,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":s[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:t.limit,class:`upload-wrapper`,multiple:!0,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:f(({file:e})=>[e.url&&e.percentage!==void 0?(h(),d(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.onRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`])):a(``,!0)]),default:f(()=>[i(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:f(()=>[i(v,{class:`icon mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(t.$t(`veo.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`limit`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var Ze=B(Ge,[[`render`,Xe],[`__scopeId`,`data-v-89137805`]]),Qe=_({name:`PromptInput`,components:{PromptTextarea:N},computed:{prompt:{get(){return this.$store.state.veo?.config?.prompt},set(e){this.$store.commit(`veo/setConfig`,{...this.$store.state.veo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function $e(e,t,n,r,i,a){let o=c(`prompt-textarea`);return h(),d(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`veo.name.prompt`),info:e.$t(`veo.description.prompt`),placeholder:e.$t(`veo.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var et=_({name:`ConfigPanel`,components:{MagicIcon:I,ElButton:V,Consumption:se,PromptInput:B(Qe,[[`render`,$e]]),ModelSelector:Ee,StartEndImage:Ze,ActionSelector:ke,TranslationSelector:Le,AspectRatioSelector:We},emits:[`generate`],computed:{config(){return this.$store.state.veo?.config},showsImages(){return this.config?.action===`image2video`||this.config?.action===`ingredients2video`},imageLimit(){return this.config?.action===`ingredients2video`?3:2},consumption(){return ie(this.config,this.service?.cost)},service(){return this.$store.state.veo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),tt={class:`flex flex-col h-full`},nt={class:`flex-1 overflow-y-auto p-5`},rt={class:`flex flex-col items-center justify-center px-5 pb-5`};function it(t,s,l,u,p,m){let g=c(`action-selector`),_=c(`model-selector`),v=c(`start-end-image`),y=c(`prompt-input`),b=c(`aspect-ratio-selector`),x=c(`translation-selector`),S=c(`consumption`),C=c(`magic-icon`),w=c(`el-button`);return h(),o(`div`,tt,[e(`div`,nt,[i(g,{class:`mb-4`}),i(_,{class:`mb-4`}),t.showsImages?(h(),d(v,{key:t.config?.action,class:`mb-4`,limit:t.imageLimit,ingredients:t.config?.action===`ingredients2video`},null,8,[`limit`,`ingredients`])):a(``,!0),i(y,{class:`mb-4`}),i(b,{class:`mb-4`}),i(x,{class:`mb-4`})]),e(`div`,rt,[i(S,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),i(w,{type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:f(()=>[i(C,{class:`mr-2`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(t.$t(`veo.button.generate`)),1)]),_:1},8,[`onClick`])])])}var at=B(et,[[`render`,it]]),ot=_({name:`TaskPreview`,components:{ApplicationIcon:O,ChannelIcon:M,ExpandIcon:j,InfoIcon:P,LanguageIcon:F,LightningIcon:L,MagicIcon:I,TimeIcon:k,WarningIcon:ee,CopyToClipboard:A,ElAlert:w,VideoPlayer:de,ImagePreview:Y,ElTooltip:C,ElButton:V,ApiCodeButton:fe},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{referenceImages(){let e=this.modelValue?.request?.image_urls;return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]},actionLabel(){let e=this.modelValue?.request,t=e?.model===`veo31-fast-ingredients`||this.referenceImages.length>2?`ingredients2video`:this.referenceImages.length>0?`image2video`:`text2video`,n=e?.action||t;return this.$t({text2video:`veo.button.action1`,image2video:`veo.button.action2`,ingredients2video:`veo.button.actionIngredients`}[n]||`veo.name.action`)},traceId(){return this.modelValue?.response?.trace_id||this.modelValue?.trace_id},taskInfoClass(){return this.modelValue?.response?.success===!0?`success`:this.modelValue?.response?.success===!1?`failure`:`info`}},methods:{onDownload(e,t){e?.stopPropagation(),console.log(`on download`),window.open(t,`_blank`)},onOpenVideo(e){window.open(e,`_blank`)}}}),st={class:`preview`},ct={class:`left`},lt={class:`main`},ut={class:`bot`},dt={class:`datetime`},ft={class:`info`},pt={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},mt={key:1,class:`prompt mt-2`},ht={key:0},gt={key:1},_t={key:0,class:t({content:!0,failed:!0})},vt={key:0,class:`mb-4`},yt={key:1,class:t({operations:!0,"mt-2":!0})},bt={key:1,class:t({content:!0})},xt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},St={class:t({content:!0})},Ct={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},wt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Tt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Et={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Dt={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ot={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function kt(l,u,p,g,_,v){let y=c(`capability-presentation`),b=c(`image-preview`),x=c(`video-player`),S=c(`el-button`),C=c(`el-tooltip`),w=c(`api-code-button`),T=c(`warning-icon`),E=c(`info-icon`),D=c(`copy-to-clipboard`),O=c(`el-alert`),k=c(`application-icon`),A=c(`lightning-icon`),j=c(`expand-icon`),M=c(`language-icon`),N=c(`magic-icon`),P=c(`time-icon`),F=c(`channel-icon`);return h(),o(`div`,st,[e(`div`,ct,[i(y,{capability:`veo`,part:`avatar`,class:`avatar`})]),e(`div`,lt,[e(`div`,ut,[i(y,{capability:`veo`,part:`name`}),e(`span`,dt,r(l.$dayjs.format(``+new Date(parseFloat((l.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,ft,[l.referenceImages.length>0?(h(),o(`div`,pt,[(h(!0),o(s,null,m(l.referenceImages,(e,t)=>(h(),d(b,{key:`${t}-${e}`,url:e,name:`reference-${t+1}`,closable:!1},null,8,[`url`,`name`]))),128))])):a(``,!0),l.modelValue?.request?.prompt?(h(),o(`p`,mt,[n(r(l.modelValue?.request?.prompt)+` `,1),l.modelValue?.response?a(``,!0):(h(),o(`span`,ht,` - (`+r(l.$t(`veo.status.pending`))+`) `,1)),Array.isArray(l.modelValue?.response?.data)&&l.modelValue?.response?.data[0]?.state===`running`?(h(),o(`span`,gt,` - (`+r(l.$t(`veo.status.processing`))+`) `,1)):a(``,!0)])):a(``,!0)]),l.modelValue?.response?.success===!0&&l.modelValue?.response?.data?(h(),o(`div`,_t,[l.modelValue?.response?.data[0]?.video_url?(h(),o(`div`,vt,[i(x,{src:l.modelValue?.response?.data[0]?.video_url},null,8,[`src`])])):a(``,!0),l.modelValue?.response.success?(h(),o(`div`,yt,[i(C,{class:`box-item`,effect:`dark`,content:l.$t(`veo.message.downloadVideo`),placement:`top-start`},{default:f(()=>[l.modelValue?.response?.data[0]?.video_url?(h(),d(S,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:u[0]||=e=>l.onDownload(e,l.modelValue?.response?.data[0]?.video_url)},{default:f(()=>[n(r(l.$t(`veo.button.download`)),1)]),_:1})):a(``,!0)]),_:1},8,[`content`]),i(w,{path:`/veo/videos`,body:l.modelValue?.request},null,8,[`body`])])):a(``,!0)])):a(``,!0),l.modelValue?.response?.success===!1?(h(),o(`div`,bt,[i(O,{closable:!1,class:`failure`},{template:f(()=>[i(T,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.failure`)),1)]),default:f(()=>[e(`p`,xt,[i(E,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.failureReason`))+`: `+r(l.modelValue?.response?.error?.message)+` `,1),i(D,{content:l.modelValue?.response?.error?.message},null,8,[`content`])])]),_:1})])):a(``,!0),e(`div`,St,[i(O,{closable:!1,class:t([`mt-2`,`task-metadata`,l.taskInfoClass])},{default:f(()=>[l.modelValue?.request?.model?(h(),o(`p`,Ct,[i(k,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.model`))+`: `+r(l.modelValue?.request?.model),1)])):a(``,!0),e(`p`,wt,[i(A,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.action`))+`: `+r(l.actionLabel),1)]),l.modelValue?.request?.aspect_ratio?(h(),o(`p`,Tt,[i(j,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.ratio`))+`: `+r(l.modelValue?.request?.aspect_ratio),1)])):a(``,!0),l.modelValue?.request?.translation===void 0?a(``,!0):(h(),o(`p`,Et,[i(M,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.translation`))+`: `+r(l.$t(l.modelValue?.request?.translation?`seedance.button.on`:`seedance.button.off`)),1)])),e(`p`,$,[i(N,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.taskId`))+`: `+r(l.modelValue?.id)+` `,1),i(D,{content:l.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),l.modelValue?.elapsed?(h(),o(`p`,Dt,[i(P,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.elapsed`))+`: `+r(l.modelValue?.elapsed?.toFixed(2))+`s `,1)])):a(``,!0),l.traceId?(h(),o(`p`,Ot,[i(F,{class:`mr-1`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),n(` `+r(l.$t(`veo.name.traceId`))+`: `+r(l.traceId)+` `,1),i(D,{content:l.traceId,class:`btn-copy inline-block`},null,8,[`content`])])):a(``,!0)]),_:1},8,[`class`])])])])}var At=_({name:`RecentPanel`,components:{TaskPreview:B(ot,[[`render`,kt],[`__scopeId`,`data-v-54ddb667`]]),NoTasks:le,BotPlaceholder:pe,ScrollList:ce},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.veo?.tasks,items:this.$store.state.veo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),jt={key:0},Mt={key:2,class:`w-full h-full flex items-center justify-center`};function Nt(e,t,n,r,l,u){let p=c(`bot-placeholder`),g=c(`task-preview`),_=c(`scroll-list`),v=c(`no-tasks`);return h(),o(s,null,[e.tasks?.items===void 0?(h(),o(`div`,jt,[i(p)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(h(),d(_,{key:1,ref:`scrollList`,class:`tasks h-full w-full overflow-y-auto`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:f(()=>[(h(!0),o(s,null,m(e.tasks?.items,(e,t)=>(h(),d(g,{key:t,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):a(``,!0),e.tasks?.items?.length===0?(h(),o(`div`,Mt,[i(v)])):a(``,!0)],64)}var Pt=_({name:`VeoIndex`,components:{ConfigPanel:at,Layout:ye,RecentPanel:B(At,[[`render`,Nt]])},mixins:[oe],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.veo?.status?.getApplications===q.Request},tasksLoading(){return this.$store.state.veo?.status?.getTasks===q.Request||this.fetchingTasks},credential(){return this.$store.state.veo.credential},config(){return this.$store.state.veo.config},tasks(){return this.$store.state.veo.tasks}},watch:{tasks:{handler(e,t){e?.items?.length>t?.items?.length&&console.debug(`new tasks detected`)},deep:!0},initialized:{async handler(e){e&&(console.debug(`layout initialized`),await this.onGetTasks(),await this.onScrollDown(),this.job=window.setInterval(()=>{this.onGetTasks()},5e3))},immediate:!0}},async mounted(){await this.onGetService()},async unmounted(){window.clearInterval(this.job)},methods:{async onReachTop(){await ue({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loadingMore,setLoading:e=>this.loadingMore=e,isBlocked:()=>this.tasksLoading||this.applicationsLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`veo/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`veo/getApplications`),console.debug(`end onGetApplication`),await this.onGetTasks()},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),this.fetchingTasks=!0;try{await this.$store.dispatch(`veo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!re(this.uploadTracker,e=>this.$t(e),e=>J.warning(e)))return;let e=xe(this.config);if(!G())return;let t=this.credential?.token;if(!t){console.error(`no token specified`);return}if((e.action===`image2video`||e.action===`ingredients2video`)&&!(e.image_urls&&e.image_urls.length>0)){J.warning(this.$t(`veo.message.imageRequired`));return}J.info(this.$t(`veo.message.startingTask`)),K(`veo`,ae.generate(e,{token:t})).then(()=>{J.success(this.$t(`veo.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?J.error(this.$t(`veo.message.usedUp`)):J.error(this.$t(`veo.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function Ft(e,t,n,r,a,o){let s=c(`config-panel`),l=c(`recent-panel`),u=c(`layout`);return h(),d(u,null,{config:f(()=>[i(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:f(()=>[i(l,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var It=B(Pt,[[`render`,Ft]]);export{It 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-Bc8_6EWw.js";import{t as f}from"./card-D-4S-l7a.js";import{n as p,t as m}from"./row-7SGe6R0i.js";import{t as h}from"./pagination-DLcNYR9W.js";import{t as g}from"./CopyToClipboard-CobD01a5.js";import{E as _,cr as v}from"./index-q3EZ6Mqo.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"./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-DcGEHLoP.js";import{n as g,t as _}from"./table-CRJnKRaX.js";import{t as v}from"./card-D-4S-l7a.js";import{n as y,t as b}from"./file-output-BsfAuD0j.js";import{n as x,t as S}from"./row-CRkRGNjN.js";import{t as C}from"./pagination-BoCv2-qy.js";import{t as w}from"./skeleton-B3LIGUiE.js";import{t as T}from"./circle-check-a9dsi5uZ.js";import{t as E}from"./clock-CNvQ2Wnk.js";import{t as D}from"./CopyToClipboard-B3wEx6PW.js";import{t as O}from"./dollar-sign-DHsTvp0K.js";import{$n as k,Ai as A,E as j,Jr as M,Kt as N,Mi as P,gi as F}from"./index-DDsc4-VK.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:P,ElTag:A,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:N,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,k.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,k.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...L}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,k.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=j(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-Dge0Ui3m.js";import{n as g,t as _}from"./table-Bc8_6EWw.js";import{t as v}from"./card-D-4S-l7a.js";import{n as y,t as b}from"./file-output-DVxHksbh.js";import{n as x,t as S}from"./row-7SGe6R0i.js";import{t as C}from"./pagination-DLcNYR9W.js";import{t as w}from"./skeleton-B3LIGUiE.js";import{t as T}from"./circle-check-P_IPZeI2.js";import{t as E}from"./clock-B7IhOYYN.js";import{t as D}from"./CopyToClipboard-CobD01a5.js";import{t as O}from"./dollar-sign-BkiTuqOT.js";import{$n as k,Ai as A,E as j,Jr as M,Kt as N,Mi as P,gi as F}from"./index-q3EZ6Mqo.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:P,ElTag:A,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:N,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,k.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,k.getSummary(this.filterQuery).then(({data:e})=>{this.summary=e}).catch(()=>{this.summary={...L}}).finally(()=>{this.summaryLoading=!1})},onExport(){this.exporting=!0,k.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=j(R,[[`render`,de],[`__scopeId`,`data-v-c1fc3317`]]);export{fe 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-DcGEHLoP.js";import{n as k,t as A}from"./table-CRJnKRaX.js";import{n as j,t as M}from"./tabs-BLoCcpjj.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-DgDgyT2l.js";import{n as I,t as L}from"./file-output-BsfAuD0j.js";import{n as R,t as z}from"./row-CRkRGNjN.js";import{t as B}from"./empty-B1wenOj5.js";import{t as V}from"./pagination-BoCv2-qy.js";import{n as H,t as U}from"./skeleton-B3LIGUiE.js";import{t as W}from"./switch-BFdf3Z4j.js";import{t as G}from"./boxes-FpgJRmSP.js";import{t as ne}from"./CopyToClipboard-B3wEx6PW.js";import{Ai as re,Ci as ie,E as ae,Kr as oe,Mi as K,ai as q,ei as se,er as ce,lr as le,mr as ue,nr as de,qr as J,tr as Y,vi as X}from"./index-DDsc4-VK.js";var fe=e(ue());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:re,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:ie,ElTabs:j,ElTabPane:M,ElButton:K,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:J,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()||J.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===J.API?this.onFetchApiUsages(e):this.type===J.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 Y.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},getCredentialLabel(e){return e.credential?.name?.trim()||e.credential?.id||e.credential_id||`-`},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&Y.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){le.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:se.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,ce.getAll({limit:1e3,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;Y.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{},...this.traceId?{trace_id:this.traceId}:{}}).then(({data:e})=>{t===this.fetchSeq&&(this.apiUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},onFetchProxyUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;de.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=`${q()}/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 Y.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r={},i={};(t.items||[]).forEach(e=>{let t=e.amount||0;(r[e.date]||(r[e.date]={}))[e.api_id]=(r[e.date]?.[e.api_id]||0)+t,i[e.api_id]=(i[e.api_id]||0)+t});let a=Object.keys(i).sort((e,t)=>i[t]-i[e]),o=a.reduce((e,t)=>e+i[t],0),s=a.length;if(o>0){let e=o*(1-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`},$={class:`created-at`},He={class:`key`},Ue={key:0,class:`cursor-pointer`},We={class:`created-at`},Ge={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`,$,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`,He,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Ue,[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`,We,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`,Ge,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=ae(_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-Dge0Ui3m.js";import{n as k,t as A}from"./table-Bc8_6EWw.js";import{n as j,t as M}from"./tabs-DT1yo-3d.js";import{t as N}from"./card-D-4S-l7a.js";import{n as P,r as F}from"./radio-DgDgyT2l.js";import{n as I,t as L}from"./file-output-DVxHksbh.js";import{n as R,t as z}from"./row-7SGe6R0i.js";import{t as B}from"./empty-B1wenOj5.js";import{t as V}from"./pagination-DLcNYR9W.js";import{n as H,t as U}from"./skeleton-B3LIGUiE.js";import{t as W}from"./switch-9jtFRLVU.js";import{t as G}from"./boxes-DaWSOxZC.js";import{t as ne}from"./CopyToClipboard-CobD01a5.js";import{Ai as re,Ci as ie,E as ae,Kr as oe,Mi as K,ai as q,ei as se,er as ce,lr as le,mr as ue,nr as de,qr as J,tr as Y,vi as X}from"./index-q3EZ6Mqo.js";var fe=e(ue());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:re,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:ie,ElTabs:j,ElTabPane:M,ElButton:K,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:J,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()||J.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===J.API?this.onFetchApiUsages(e):this.type===J.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 Y.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},getCredentialLabel(e){return e.credential?.name?.trim()||e.credential?.id||e.credential_id||`-`},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&Y.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){le.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:se.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,ce.getAll({limit:1e3,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;Y.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{},...this.traceId?{trace_id:this.traceId}:{}}).then(({data:e})=>{t===this.fetchSeq&&(this.apiUsages=e.items,this.total=e.count)}).catch(()=>{}).finally(()=>{e||(this.loading=!1)})},onFetchProxyUsages(e=!1){e||(this.loading=!0);let t=++this.fetchSeq;de.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=`${q()}/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 Y.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r={},i={};(t.items||[]).forEach(e=>{let t=e.amount||0;(r[e.date]||(r[e.date]={}))[e.api_id]=(r[e.date]?.[e.api_id]||0)+t,i[e.api_id]=(i[e.api_id]||0)+t});let a=Object.keys(i).sort((e,t)=>i[t]-i[e]),o=a.reduce((e,t)=>e+i[t],0),s=a.length;if(o>0){let e=o*(1-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`},$={class:`created-at`},He={class:`key`},Ue={key:0,class:`cursor-pointer`},We={class:`created-at`},Ge={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`,$,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`,He,r(e.getCredentialLabel(n.row)),1),n.row.credential?.id||n.row.credential_id?(w(),o(`span`,Ue,[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`,We,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`,Ge,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=ae(_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,M as i,N as a,T as o,at as s,ht as c,j as l,mt as u,ot as d,rt as f,tt as p,z as m}from"./vendor-chart-Dw-P17PN.js";import{n as h,t as g}from"./table-CRJnKRaX.js";import{t as _}from"./card-D-4S-l7a.js";import{n as v,t as ee}from"./row-CRkRGNjN.js";import{t as y}from"./empty-B1wenOj5.js";import{t as b}from"./pagination-BoCv2-qy.js";import{t as x}from"./skeleton-B3LIGUiE.js";import{t as S}from"./switch-BFdf3Z4j.js";import{t as C}from"./boxes-FpgJRmSP.js";import{t as w}from"./chart-no-axes-combined-CYwY4LnJ.js";import{t as T}from"./coins-wE7lvXoA.js";import{t as E}from"./CopyToClipboard-B3wEx6PW.js";import{t as D}from"./wallet-DD7BRWEc.js";import{$r as O,Ai as k,B as A,E as j,K as M,Kr as N,Mi as P,ei as F,li as I,lr as L,pn as R,qr as z,vi as B}from"./index-DDsc4-VK.js";var V=m({name:`ConsoleApplicationList`,components:{AnalyticsIcon:w,ApplicationsIcon:C,CreditsIcon:T,WalletIcon:D,Pagination:b,CopyToClipboard:E,ElTable:g,ElRow:ee,ElButton:P,ElCol:v,ElTag:k,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:h,ElCard:_},data(){return{credentialType:N,serviceType:z,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!R(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return R(this.$store.getters.site)?!1:I()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||L.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{B.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{B.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:M,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:A,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=O.INDIVIDUAL){return new Promise((t,n)=>{L.getAll({limit:this.limit,...e===O.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:F.USAGE,scope:e}).then(({data:n})=>{e===O.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{B.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(O.INDIVIDUAL),this.onFetchApplications(O.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){L.create({type:F.USAGE,scope:O.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(O.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}`}}}),H={class:`title`},U={key:1,class:`summary-card`},W={class:`icon-wrapper`},G={class:`label`},K={class:`value`},q={class:`description`},J={key:1,class:`flex flex-row justify-between items-center gap-3`},Y={class:`summary-card min-w-0 flex-1`},X={class:`flex justify-start items-center gap-2 mb-2 w-full`},Z={class:`icon-wrapper !mb-0`},Q={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={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(m,h,g,_,v,ee){let y=s(`el-col`),b=s(`el-row`),x=s(`el-skeleton`),S=s(`applications-icon`),C=s(`el-card`),w=s(`wallet-icon`),T=s(`copy-to-clipboard`),E=s(`analytics-icon`),D=s(`el-button`),O=s(`credits-icon`),k=s(`el-table-column`),A=s(`el-tag`),j=s(`el-switch`),M=s(`el-table`),N=s(`el-empty`),P=s(`pagination`),F=d(`loading`);return p(),l(b,{class:`application-list`},{default:u(()=>[r(y,{span:24},{default:u(()=>[r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`h2`,H,n(m.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(b,{gutter:15,class:`mb-3`},{default:u(()=>[r(y,{md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[m.loading?(p(),l(x,{key:0})):(p(),a(`div`,U,[e(`div`,W,[r(S,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,G,n(m.$t(`application.title.count`)),1),e(`p`,K,n(m.individualApplicationsTotal),1),e(`p`,q,n(m.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),m.showGlobalPayment&&m.globalApplications?.length>0?(p(),l(y,{key:0,md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[m.loading?(p(),l(x,{key:0})):(p(),a(`div`,J,[e(`div`,Y,[e(`div`,X,[e(`div`,Z,[r(w,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`span`,Q,[t(n(m.$t(`application.field.id`))+`: `+n(m.globalApplications?.[0]?.id)+` `,1),m.globalApplications?.[0]?.id?(p(),l(T,{key:0,content:m.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,te,n(m.$t(`application.title.globalBalance`)),1),e(`p`,ne,n(m.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(m.$t(`service.unit.credits`)),1),e(`p`,re,n(m.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,ie,[r(D,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>m.onGoUsage(m.globalApplications?.[0])},{default:u(()=>[r(E,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.usage`)),1)]),_:1}),m.showGlobalPayment?(p(),l(D,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>m.onBuyMore(m.globalApplications?.[0])},{default:u(()=>[r(O,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[r(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:u(()=>[c((p(),l(M,{data:m.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":m.$t(`common.message.noData`)},{default:u(()=>[r(k,{prop:`id`,label:m.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ae,[r(T,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(k,{label:m.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row?.type===`Period`?(p(),l(A,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[t(n(m.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(p(),l(A,{key:1,effect:`dark`,round:``},{default:u(()=>[t(n(m.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(k,{label:m.$t(`application.field.name`),width:`180px`},{default:u(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(p(),l(A,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[t(n(m.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(k,{prop:`remaining_amount`,label:m.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(m.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(k,{prop:`used_amount`,label:m.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[e(`span`,null,n(m.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(k,{prop:`allow_consume_global`,label:m.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.service?.type===m.serviceType.API?(p(),l(j,{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=>m.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(k,{label:m.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(p(),a(`span`,oe,n(m.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(k,{fixed:`right`,width:`200px`},{default:u(a=>[e(`div`,se,[r(D,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>m.onGoUsage(a?.row)},{default:u(()=>[r(E,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),m.rowCanPay(a?.row)?(p(),l(D,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>m.onBuyMore(a?.row)},{default:u(()=>[r(O,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[F,m.loading]])]),_:1}),e(`div`,ce,[m.loading?(p(),l(x,{key:0,rows:4,animated:``})):(p(),a(o,{key:1},[m.individualApplications?.length?(p(!0),a(o,{key:1},f(m.individualApplications,o=>(p(),l(C,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:u(()=>[e(`div`,le,[e(`span`,ue,n(o?.service?.title),1),o?.type===`Period`?(p(),l(A,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(m.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(p(),l(A,{key:1,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(m.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(p(),l(A,{key:2,type:`info`,size:`small`,round:``},{default:u(()=>[t(n(m.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,de,[e(`span`,fe,n(m.$t(`application.field.id`))+`: `+n(o.id),1),r(T,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,pe,[e(`span`,$,n(m.$t(`application.field.remainingAmount`)),1),e(`span`,me,n(m.getRemainingAmount(o)),1)]),o?.expired_at?(p(),a(`div`,he,[e(`span`,ge,n(m.$t(`application.field.expiredAt`)),1),e(`span`,_e,n(m.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===m.serviceType.API?(p(),a(`div`,ve,[e(`span`,ye,n(m.$t(`application.field.allowConsumeGlobal`)),1),r(j,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>m.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,be,[r(D,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>m.onGoUsage(o)},{default:u(()=>[r(E,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),m.rowCanPay(o)?(p(),l(D,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>m.onBuyMore(o)},{default:u(()=>[r(O,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(p(),l(N,{key:0,description:m.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`div`,xe,[r(P,{"current-page":m.page,"page-size":m.limit,total:m.individualApplicationsTotal,onChange:m.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Ce=j(V,[[`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 c,j as l,mt as u,ot as d,rt as f,tt as p,z as m}from"./vendor-chart-Dw-P17PN.js";import{n as h,t as g}from"./table-Bc8_6EWw.js";import{t as _}from"./card-D-4S-l7a.js";import{n as v,t as ee}from"./row-7SGe6R0i.js";import{t as y}from"./empty-B1wenOj5.js";import{t as b}from"./pagination-DLcNYR9W.js";import{t as x}from"./skeleton-B3LIGUiE.js";import{t as S}from"./switch-9jtFRLVU.js";import{t as C}from"./boxes-DaWSOxZC.js";import{t as w}from"./chart-no-axes-combined-D1kSYY9A.js";import{t as T}from"./coins-Bkyf11zx.js";import{t as E}from"./CopyToClipboard-CobD01a5.js";import{t as D}from"./wallet-DWLeOXgB.js";import{$r as O,Ai as k,B as A,E as j,K as M,Kr as N,Mi as P,ei as F,li as I,lr as L,pn as R,qr as z,vi as B}from"./index-q3EZ6Mqo.js";var V=m({name:`ConsoleApplicationList`,components:{AnalyticsIcon:w,ApplicationsIcon:C,CreditsIcon:T,WalletIcon:D,Pagination:b,CopyToClipboard:E,ElTable:g,ElRow:ee,ElButton:P,ElCol:v,ElTag:k,ElSkeleton:x,ElSwitch:S,ElEmpty:y,ElTableColumn:h,ElCard:_},data(){return{credentialType:N,serviceType:z,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!R(this.$store.getters.site)}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return R(this.$store.getters.site)?!1:I()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||L.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{B.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{B.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:M,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:A,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=O.INDIVIDUAL){return new Promise((t,n)=>{L.getAll({limit:this.limit,...e===O.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:F.USAGE,scope:e}).then(({data:n})=>{e===O.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{B.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(O.INDIVIDUAL),this.onFetchApplications(O.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){L.create({type:F.USAGE,scope:O.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(O.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}`}}}),H={class:`title`},U={key:1,class:`summary-card`},W={class:`icon-wrapper`},G={class:`label`},K={class:`value`},q={class:`description`},J={key:1,class:`flex flex-row justify-between items-center gap-3`},Y={class:`summary-card min-w-0 flex-1`},X={class:`flex justify-start items-center gap-2 mb-2 w-full`},Z={class:`icon-wrapper !mb-0`},Q={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={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(m,h,g,_,v,ee){let y=s(`el-col`),b=s(`el-row`),x=s(`el-skeleton`),S=s(`applications-icon`),C=s(`el-card`),w=s(`wallet-icon`),T=s(`copy-to-clipboard`),E=s(`analytics-icon`),D=s(`el-button`),O=s(`credits-icon`),k=s(`el-table-column`),A=s(`el-tag`),j=s(`el-switch`),M=s(`el-table`),N=s(`el-empty`),P=s(`pagination`),F=d(`loading`);return p(),l(b,{class:`application-list`},{default:u(()=>[r(y,{span:24},{default:u(()=>[r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`h2`,H,n(m.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),r(b,{gutter:15,class:`mb-3`},{default:u(()=>[r(y,{md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[m.loading?(p(),l(x,{key:0})):(p(),a(`div`,U,[e(`div`,W,[r(S,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`p`,G,n(m.$t(`application.title.count`)),1),e(`p`,K,n(m.individualApplicationsTotal),1),e(`p`,q,n(m.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),m.showGlobalPayment&&m.globalApplications?.length>0?(p(),l(y,{key:0,md:12,xs:24},{default:u(()=>[r(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:u(()=>[m.loading?(p(),l(x,{key:0})):(p(),a(`div`,J,[e(`div`,Y,[e(`div`,X,[e(`div`,Z,[r(w,{size:`1em`,"aria-hidden":`true`,focusable:`false`})]),e(`span`,Q,[t(n(m.$t(`application.field.id`))+`: `+n(m.globalApplications?.[0]?.id)+` `,1),m.globalApplications?.[0]?.id?(p(),l(T,{key:0,content:m.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):i(``,!0)])]),e(`p`,te,n(m.$t(`application.title.globalBalance`)),1),e(`p`,ne,n(m.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+n(m.$t(`service.unit.credits`)),1),e(`p`,re,n(m.$t(`application.message.globalBalanceDescription`)),1)]),e(`div`,ie,[r(D,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>m.onGoUsage(m.globalApplications?.[0])},{default:u(()=>[r(E,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.usage`)),1)]),_:1}),m.showGlobalPayment?(p(),l(D,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>m.onBuyMore(m.globalApplications?.[0])},{default:u(()=>[r(O,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.buyMore`)),1)]),_:1})):i(``,!0)])]))]),_:1})]),_:1})):i(``,!0)]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[r(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:u(()=>[c((p(),l(M,{data:m.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":m.$t(`common.message.noData`)},{default:u(()=>[r(k,{prop:`id`,label:m.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(t.row.id),1),e(`span`,ae,[r(T,{content:t?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),r(k,{label:m.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row?.type===`Period`?(p(),l(A,{key:0,type:`success`,effect:`dark`,round:``},{default:u(()=>[t(n(m.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(p(),l(A,{key:1,effect:`dark`,round:``},{default:u(()=>[t(n(m.$t(`application.type.usage`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(k,{label:m.$t(`application.field.name`),width:`180px`},{default:u(r=>[e(`span`,null,n(r.row?.service?.title),1),r.row?.role===`grantee`?(p(),l(A,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:u(()=>[t(n(m.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),_:1},8,[`label`]),r(k,{prop:`remaining_amount`,label:m.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:u(t=>[e(`span`,null,n(m.getRemainingAmount(t.row)),1)]),_:1},8,[`label`]),r(k,{prop:`used_amount`,label:m.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(t=>[e(`span`,null,n(m.getUsedAmount(t.row)),1)]),_:1},8,[`label`]),r(k,{prop:`allow_consume_global`,label:m.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.service?.type===m.serviceType.API?(p(),l(j,{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=>m.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):i(``,!0)]),_:1},8,[`label`]),r(k,{label:m.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:u(e=>[e.row.expired_at?(p(),a(`span`,oe,n(m.$dayjs.format(e.row.expired_at)),1)):i(``,!0)]),_:1},8,[`label`]),r(k,{fixed:`right`,width:`200px`},{default:u(a=>[e(`div`,se,[r(D,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:e=>m.onGoUsage(a?.row)},{default:u(()=>[r(E,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),m.rowCanPay(a?.row)?(p(),l(D,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:e=>m.onBuyMore(a?.row)},{default:u(()=>[r(O,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[F,m.loading]])]),_:1}),e(`div`,ce,[m.loading?(p(),l(x,{key:0,rows:4,animated:``})):(p(),a(o,{key:1},[m.individualApplications?.length?(p(!0),a(o,{key:1},f(m.individualApplications,o=>(p(),l(C,{key:o.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:u(()=>[e(`div`,le,[e(`span`,ue,n(o?.service?.title),1),o?.type===`Period`?(p(),l(A,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(m.$t(`application.type.period`)),1)]),_:1})):o?.type===`Usage`?(p(),l(A,{key:1,effect:`dark`,size:`small`,round:``},{default:u(()=>[t(n(m.$t(`application.type.usage`)),1)]),_:1})):i(``,!0),o?.role===`grantee`?(p(),l(A,{key:2,type:`info`,size:`small`,round:``},{default:u(()=>[t(n(m.$t(`application.badge.shared`)),1)]),_:1})):i(``,!0)]),e(`div`,de,[e(`span`,fe,n(m.$t(`application.field.id`))+`: `+n(o.id),1),r(T,{content:o.id,class:`inline-block shrink-0`},null,8,[`content`])]),e(`div`,pe,[e(`span`,$,n(m.$t(`application.field.remainingAmount`)),1),e(`span`,me,n(m.getRemainingAmount(o)),1)]),o?.expired_at?(p(),a(`div`,he,[e(`span`,ge,n(m.$t(`application.field.expiredAt`)),1),e(`span`,_e,n(m.$dayjs.format(o.expired_at)),1)])):i(``,!0),o.service?.type===m.serviceType.API?(p(),a(`div`,ve,[e(`span`,ye,n(m.$t(`application.field.allowConsumeGlobal`)),1),r(j,{modelValue:o.allow_consume_global,"onUpdate:modelValue":e=>o.allow_consume_global=e,"active-value":!0,"inactive-value":!1,onChange:e=>m.updateAllowConsumeGlobal(o,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):i(``,!0),e(`div`,be,[r(D,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:e=>m.onGoUsage(o)},{default:u(()=>[r(E,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),m.rowCanPay(o)?(p(),l(D,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:e=>m.onBuyMore(o)},{default:u(()=>[r(O,{class:`mr-1 text-[12px]`,size:`1em`,"aria-hidden":`true`,focusable:`false`}),t(` `+n(m.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):i(``,!0)])]),_:2},1024))),128)):(p(),l(N,{key:0,description:m.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),r(b,null,{default:u(()=>[r(y,{span:24},{default:u(()=>[e(`div`,xe,[r(P,{"current-page":m.page,"page-size":m.limit,total:m.individualApplicationsTotal,onChange:m.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var Ce=j(V,[[`render`,Se],[`__scopeId`,`data-v-d88616c5`]]);export{Ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,Jt as t,L as n,N as r,at as i,tt as a,z as o}from"./vendor-chart-Dw-P17PN.js";import{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-Ci7tX2CK.js";import{E as c}from"./index-q3EZ6Mqo.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,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-9jtFRLVU.js";import{n as h,t as g}from"./shield-BYfeX6ht.js";import{t as _}from"./folder-CCUPcJzs.js";import{t as v}from"./mouse-pointer-2-BfzMdKm2.js";import{t as y}from"./pencil-D9disow9.js";import{t as b}from"./plus-MaZrwBBS.js";import{t as x}from"./terminal-jeXNvV4j.js";import{t as S}from"./wand-sparkles-BfXtzg0M.js";import{Ai as C,E as w,Mi as T,O as E,Vi as te,gi as D,ii as O,si as ne,ur as k}from"./index-q3EZ6Mqo.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:b,ElButton:T,ElTag:C,ElSwitch:ee,ElInput:te,FolderIcon:_,MagicIcon:S,SecurityIcon:g},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!!E()},android(){return ne()},canInstallXhs(){return this.a11yEnabled&&this.computerUse}},async mounted(){let e=E();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 E()?.perm?.status();this.a11yEnabled=e?.accessibility===!0}finally{this.refreshingA11y=!1}}},async openAndroidAccessibility(){await E()?.perm?.openPane(`accessibility`)},async fetchXhsSkill(){this.xhsLoading=!0,this.xhsError=``;try{let e=await k.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 k.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=E();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 E()?.pickFolder();e&&!this.roots.includes(e)&&this.roots.push(e)},removeRoot(e){this.roots.splice(e,1)},addMcp(){this.mcpServers.push({_uid:this.mcpUid++,id:``,command:``,argsText:``,envText:``,enabled:!0})},removeMcp(e){this.mcpServers.splice(e,1)},mcpStatusFor(e){let t=e.trim();return this.mcpStatuses.find(e=>e.id===t)},mcpBadgeType(e){let t=this.mcpStatusFor(e)?.status;return t===`connected`?`success`:t===`failed`?`danger`:`info`},mcpBadgeText(e){let t=this.mcpStatusFor(e);return this.mcpBusy===e.trim()?this.$t(`common.settings.localToolsMcpConnecting`):t?t.status===`connected`?this.$t(`common.settings.localToolsMcpConnected`,{n:t.toolCount}):t.status===`disabled`?this.$t(`common.settings.localToolsMcpDisabled`):this.$t(`common.settings.localToolsMcpFailed`):this.$t(`common.settings.localToolsMcpNotSaved`)},mcpErrorFor(e){let t=this.mcpStatusFor(e);return t?.status===`failed`&&t.error?t.error:``},buildMcpPayload(){this.mcpError=``;let e=[],t=new Set;for(let n of this.mcpServers){let r=n.id.trim(),i=n.command.trim();if(!r||!i)return this.mcpError=this.$t(`common.settings.localToolsMcpNameRequired`),null;if(!/^[A-Za-z0-9_-]+$/.test(r))return this.mcpError=this.$t(`common.settings.localToolsMcpNameInvalid`),null;if(t.has(r))return this.mcpError=this.$t(`common.settings.localToolsMcpDuplicateName`),null;t.add(r);let a=n.argsText.split(`
|
|
4
4
|
`).map(e=>e.trim()).filter(Boolean),o={};for(let e of n.envText.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,I as t,Jt as n,L as r,M as i,N as a,at as o,j as s,k as c,mt as l,tt as u,z as d}from"./vendor-chart-Dw-P17PN.js";import{t as f}from"./Navigator-
|
|
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-CdWvL0LB.js";import{t as p}from"./checkbox-CeoqKfX8.js";import{t as m}from"./divider-BNWJAaA2.js";import"./constants-OfAt86nA.js";import{$r as h,Ci as g,E as _,Mi as v,Wt as y,ai as b,ei as x,lr as S,ni as C,vi as w}from"./index-q3EZ6Mqo.js";import{t as T}from"./Status-B2Q-2Wyr.js";var E=d({name:`ApplicationConfirm`,components:{ElDialog:g,ElDivider:m,ElCheckbox:p,ElButton:v},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:b,onApply(){if(!this.checked){w.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=_(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===C.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,!this.$store.state.token?.access||(console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId))return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=y(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await S.create({type:x.USAGE,scope:h.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`):w.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`;w({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=_(F,[[`render`,L],[`__scopeId`,`data-v-334ded1d`]]);export{R as default};
|