@acedatacloud/nexior 3.324.4 → 3.324.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/assets/ApiCodeButton-JnYcIZze.css +1 -0
  2. package/dist/assets/ApiCodeButton-WbUyGTD7.js +1 -0
  3. package/dist/assets/{Artifacts-Bz3P0CHT.js → Artifacts-DD6Vzaqa.js} +1 -1
  4. package/dist/assets/{AskUserQuestionCard-B6qyqhjQ.js → AskUserQuestionCard-DiMXXPRx.js} +1 -1
  5. package/dist/assets/{Auth-CPH4wcbH.js → Auth-AjaeR3WH.js} +1 -1
  6. package/dist/assets/{Bare-DgTscDdo.js → Bare-CrU7_CJq.js} +1 -1
  7. package/dist/assets/{BotPlaceholder-Dn8d_dlZ.js → BotPlaceholder-DeEtrFs6.js} +1 -1
  8. package/dist/assets/{BottomFooter-BUSumJVu.js → BottomFooter-lIw27MGi.js} +1 -1
  9. package/dist/assets/{Callback-DCPxjDtM.js → Callback-q_lQn5Yx.js} +1 -1
  10. package/dist/assets/{CodeSnippet-BR9bBvwR.js → CodeSnippet-BQiQ19gv.js} +1 -1
  11. package/dist/assets/{Console-BpX6WmY4.js → Console-D3xsmLBR.js} +1 -1
  12. package/dist/assets/{Consumption-Ch2waQDb.js → Consumption-0ipkiA5W.js} +1 -1
  13. package/dist/assets/{Conversation-B8r9rczt.js → Conversation-DMduwcbU.js} +1 -1
  14. package/dist/assets/{Conversation-DsB2XIwH.js → Conversation-KbwaUkGE.js} +1 -1
  15. package/dist/assets/{CopyToClipboard-BpPd8B8b.js → CopyToClipboard-BDHrbE9N.js} +1 -1
  16. package/dist/assets/{Detail-3WNjWDl2.js → Detail-DcrhXOF9.js} +2 -2
  17. package/dist/assets/{Extra-BWCK-5JY.js → Extra-BzPXd3G6.js} +1 -1
  18. package/dist/assets/{FilePreview-pOUKDsWd.js → FilePreview-L3brxpd6.js} +1 -1
  19. package/dist/assets/{Hailuo-CXR3wAjV.js → Hailuo-WofVoDsl.js} +1 -1
  20. package/dist/assets/{History-WwIV1x8D.js → History-CuizF__H.js} +1 -1
  21. package/dist/assets/{ImagePreview-BfslzHEU.js → ImagePreview-CBJ5UBky.js} +1 -1
  22. package/dist/assets/{ImageWrapper-COUXJuJv.js → ImageWrapper-XPy_gfNc.js} +1 -1
  23. package/dist/assets/{Index-U_y1py-f.js → Index-9RwZ4GjZ.js} +1 -1
  24. package/dist/assets/{Index-DmXOqD5_.js → Index-9gco_vOj.js} +1 -1
  25. package/dist/assets/{Index-dSyA7jbM.js → Index-B0cFDbj0.js} +1 -1
  26. package/dist/assets/{Index-Bmvh2Tj2.js → Index-B5U47TQ5.js} +1 -1
  27. package/dist/assets/{Index-BCu2MeL7.js → Index-B9osKe5l.js} +1 -1
  28. package/dist/assets/{Index-CJW5-I6I.js → Index-BHA46aUU.js} +1 -1
  29. package/dist/assets/{Index-C0Me2XTj.js → Index-BYoFfW4v.js} +1 -1
  30. package/dist/assets/{Index-Cnk0Ul6l.js → Index-BaYwJpcc.js} +1 -1
  31. package/dist/assets/{Index-Boa6Xi1t.js → Index-Bg4LsAyR.js} +1 -1
  32. package/dist/assets/{Index-vxezeFEx.js → Index-Bt2RMfTe.js} +1 -1
  33. package/dist/assets/{Index-DWwvVfJG.js → Index-Bz_K1COD.js} +1 -1
  34. package/dist/assets/{Index-DH2YJrw1.js → Index-CDlW94Hk.js} +1 -1
  35. package/dist/assets/Index-CMSszvu-.js +1 -0
  36. package/dist/assets/{Index-B2tzjesK.js → Index-CR7CzFLC.js} +1 -1
  37. package/dist/assets/{Index-HsOjOzRi.js → Index-CTOkFoWc.js} +1 -1
  38. package/dist/assets/{Index-Na6IcXP7.js → Index-CWlpo8Gb.js} +1 -1
  39. package/dist/assets/{Index-CmtQEOEO.js → Index-CcXGyIh_.js} +1 -1
  40. package/dist/assets/{Index-CFyzCt9U.js → Index-CjzUEUY6.js} +1 -1
  41. package/dist/assets/{Index-CjIpZHpK.js → Index-CqpH6lC4.js} +1 -1
  42. package/dist/assets/{Index-CHIBKJhI.js → Index-CsYNnX9o.js} +1 -1
  43. package/dist/assets/{Index-BX4IuMn1.js → Index-D1qwdvus.js} +1 -1
  44. package/dist/assets/{Index-BSAoEpbV.css → Index-DHm3Mr7O.css} +1 -1
  45. package/dist/assets/{Index-y6hofnbo.js → Index-DX2jfpaA.js} +1 -1
  46. package/dist/assets/{Index-B0uJ38ou.js → Index-DdByUdL8.js} +1 -1
  47. package/dist/assets/{Index-BQRikq_P.js → Index-DnEsCUmI.js} +1 -1
  48. package/dist/assets/{Index-DZSTWdcQ.js → Index-QRNe74IB.js} +1 -1
  49. package/dist/assets/{Index-M-ee1_Cs.js → Index-jvvOf_Hl.js} +1 -1
  50. package/dist/assets/{Index-CbPO1VzU.js → Index-uB2b97Vo.js} +1 -1
  51. package/dist/assets/{Index-k6IwASoO.js → Index-wj2OT1Ym.js} +1 -1
  52. package/dist/assets/{Invitees-DQPqOGfQ.js → Invitees-Lrq3YVpo.js} +1 -1
  53. package/dist/assets/{List-9CiMpsWb.js → List-B-dx2_AH.js} +1 -1
  54. package/dist/assets/{List-Bf9dYPlV.js → List-BDS8_neK.js} +1 -1
  55. package/dist/assets/{List-DTw7qRok.js → List-VZOpccKP.js} +1 -1
  56. package/dist/assets/{LocalTools-LtZwqqgS.js → LocalTools-CpsWQcNU.js} +1 -1
  57. package/dist/assets/{LocalTools-DZAROLJ1.js → LocalTools-De1jS3H4.js} +1 -1
  58. package/dist/assets/{Main-CDUz-uT6.js → Main-Cegxncbv.js} +1 -1
  59. package/dist/assets/{Message-qt8rx8z6.js → Message-D0DYdBS4.js} +1 -1
  60. package/dist/assets/{Model-B9yoCCq3.js → Model-DxruPgdr.js} +1 -1
  61. package/dist/assets/{Navigator-DiL6OyCW.js → Navigator-DmkLvqA8.js} +3 -3
  62. package/dist/assets/{NoTasks-Cox5rrM8.js → NoTasks-CF_GuqSx.js} +1 -1
  63. package/dist/assets/{NotFound-BXG5cUr8.js → NotFound-CfCOSdwv.js} +1 -1
  64. package/dist/assets/{Pagination-CiLjpGJR.js → Pagination-Dx4ymdiN.js} +1 -1
  65. package/dist/assets/{Pay-DvjyRc2T.js → Pay-Cl3tA2LA.js} +1 -1
  66. package/dist/assets/{Player-CkxHgZFl.js → Player-BfqmocvH.js} +1 -1
  67. package/dist/assets/{PromptTextarea-CEL2z0Ne.js → PromptTextarea-JRe0Kgab.js} +1 -1
  68. package/dist/assets/{RealtimeCall-RaTPOfBz.js → RealtimeCall-CEihDrKN.js} +1 -1
  69. package/dist/assets/{ScheduledTasks-BSjFU6yn.js → ScheduledTasks-DzPyfFCO.js} +1 -1
  70. package/dist/assets/{Status-D9nfcepM.js → Status-CcnJdn-O.js} +1 -1
  71. package/dist/assets/{Subscribe-DTVltEqQ.js → Subscribe-uCyxn-uv.js} +1 -1
  72. package/dist/assets/{TabSwitcher-BqeLEQ0X.js → TabSwitcher-elinKN4s.js} +1 -1
  73. package/dist/assets/{Tts-T6zjp2QY.js → Tts-DRxPJHET.js} +1 -1
  74. package/dist/assets/{VideoPlayer-BzaeOeXh.js → VideoPlayer-CUG8KpLW.js} +1 -1
  75. package/dist/assets/{VideoPreview-q3TB5acv.js → VideoPreview-CQYWI0Ez.js} +1 -1
  76. package/dist/assets/{alert-2qBdi1l1.js → alert-9UHbWOgh.js} +1 -1
  77. package/dist/assets/{avatar-DQfRtj17.js → avatar-DhkDVzOU.js} +1 -1
  78. package/dist/assets/{basic-DZKbiP4M.js → basic-IRmTqVTt.js} +1 -1
  79. package/dist/assets/{chat-DUnXL1u-.js → chat-D5KXxpIZ.js} +1 -1
  80. package/dist/assets/{codingBridge-sspPAPZA.js → codingBridge-S1ltJgFG.js} +1 -1
  81. package/dist/assets/{codingBridgeNotify-C_pn7ylq.js → codingBridgeNotify-BDNm16OG.js} +2 -2
  82. package/dist/assets/{collapse-DXFwNqDk.js → collapse-BnO-Y8Q3.js} +1 -1
  83. package/dist/assets/{createTaskActions-DUYp4UuS.js → createTaskActions-DROE61Dv.js} +1 -1
  84. package/dist/assets/{date-picker-RrAmVP1K.js → date-picker-0YL40dVm.js} +1 -1
  85. package/dist/assets/{digitalhuman-dB--xRZQ.js → digitalhuman-C7Xa0SZs.js} +1 -1
  86. package/dist/assets/{drawer-u1pTNeW8.js → drawer-BhyqFLuj.js} +1 -1
  87. package/dist/assets/{dropdown-F76x0Cic.js → dropdown-Bunw8IHQ.js} +1 -1
  88. package/dist/assets/{dropdown-CmH5-veE.js → dropdown-pUxEN4RP.js} +1 -1
  89. package/dist/assets/{esm-CNSbqlpi.js → esm-BifGSZcY.js} +2 -2
  90. package/dist/assets/{esm-Bw22s8IP.js → esm-BifJVOIU.js} +1 -1
  91. package/dist/assets/{esm-2lhbopeQ.js → esm-BtStpu1S.js} +1 -1
  92. package/dist/assets/esm-D6mkoEJX.js +1 -0
  93. package/dist/assets/{esm-C6ETodjc.js → esm-Drnxkqc2.js} +3 -3
  94. package/dist/assets/{esm-fnuvj1fL.js → esm-VmydlJSG.js} +2 -2
  95. package/dist/assets/{esm-CM69Q0Ac.js → esm-zjC_jWza.js} +1 -1
  96. package/dist/assets/{fish-_o8HKaDm.js → fish-BQnjshEa.js} +1 -1
  97. package/dist/assets/{flux-C3T8QWMh.js → flux-DlpNN983.js} +1 -1
  98. package/dist/assets/{grokvideo-B5n9HL86.js → grokvideo-BdPYnA3h.js} +1 -1
  99. package/dist/assets/{hailuo-B9lY_8yE.js → hailuo-DMr0lY2d.js} +1 -1
  100. package/dist/assets/{headshots-sGwv8qBh.js → headshots-ULYibmVj.js} +1 -1
  101. package/dist/assets/{image-DGnWsKHn.js → image-C_wGl_Tq.js} +1 -1
  102. package/dist/assets/{index-DqpzpRT-.js → index-CEsOXc02.js} +3 -3
  103. package/dist/assets/{index.browser.esm-BsqhSb0X.js → index.browser.esm-CCS69rIB.js} +1 -1
  104. package/dist/assets/{index.es-D7t9e-wf.js → index.es-CZ18ogLi.js} +1 -1
  105. package/dist/assets/{input-number-_KRhOc4-.js → input-number-BqS9Kh4f.js} +1 -1
  106. package/dist/assets/{kling-Df01CqAH.js → kling-CsmlRVsq.js} +1 -1
  107. package/dist/assets/{luma-D1B8646_.js → luma-D1Dd8Tqi.js} +1 -1
  108. package/dist/assets/{maestro-ZX172Oxn.js → maestro-D1OgZ-O4.js} +1 -1
  109. package/dist/assets/{midjourney-BocHA4xn.js → midjourney-XEE-qOEI.js} +1 -1
  110. package/dist/assets/{mobileLocalExec-B9S0tNMw.js → mobileLocalExec-zAV4vJey.js} +2 -2
  111. package/dist/assets/{nanobanana-hrQj9nTn.js → nanobanana-DJxGpd7I.js} +1 -1
  112. package/dist/assets/{openaiimage-BMLA7jAD.js → openaiimage-CgrHgn99.js} +1 -1
  113. package/dist/assets/{pagination-CyeMpm2N.js → pagination-UvuFCwzm.js} +1 -1
  114. package/dist/assets/{pika-D2csQ_Bq.js → pika-BTJvDT24.js} +1 -1
  115. package/dist/assets/{pixverse-DGAXeh5B.js → pixverse-BIQ1aDBT.js} +1 -1
  116. package/dist/assets/{popover-3AWrj26s.js → popover-C-_iN2fz.js} +1 -1
  117. package/dist/assets/{producer-CxOab8vB.js → producer-Bu5x5yel.js} +1 -1
  118. package/dist/assets/{qrart-5Qgqow9s.js → qrart-DMfgYxtG.js} +1 -1
  119. package/dist/assets/{realtime--VTiT1T4.js → realtime-DCLcrj13.js} +1 -1
  120. package/dist/assets/{row-Cnmy4vVD.js → row-K2C2TzIB.js} +1 -1
  121. package/dist/assets/{seedance-DgnXx01F.js → seedance-30yDaVec.js} +1 -1
  122. package/dist/assets/{seedream-D4egeIBZ.js → seedream-DFBdgaWE.js} +1 -1
  123. package/dist/assets/{select-CVXgXqir.js → select-B0Rytq57.js} +1 -1
  124. package/dist/assets/{serp-wNf2w-6t.js → serp-QuTcRG1a.js} +1 -1
  125. package/dist/assets/{slider-CDoSZg65.js → slider-B0zBUesv.js} +1 -1
  126. package/dist/assets/{solana-wallets-CW509J3q.js → solana-wallets-CdCOGFmp.js} +2 -2
  127. package/dist/assets/{solana-wallets-vue-lfiZGauF.js → solana-wallets-vue-CnEZaw7A.js} +1 -1
  128. package/dist/assets/{sora-CQRPAisZ.js → sora-DvCq2R7F.js} +1 -1
  129. package/dist/assets/{suno-CKJm4r92.js → suno-BfanILOd.js} +1 -1
  130. package/dist/assets/{switch-UZQHGjPB.js → switch-C_iujXz0.js} +1 -1
  131. package/dist/assets/{table-Doe0OvHs.js → table-BQPqgdX7.js} +1 -1
  132. package/dist/assets/{tabs-C_XpWXWP.js → tabs-B_Vz5BEf.js} +1 -1
  133. package/dist/assets/{time-picker-CZb8xvOW.js → time-picker-DPtXGOnJ.js} +1 -1
  134. package/dist/assets/{tooltip-Cb1CIPoD.js → tooltip-DMkRuyNr.js} +1 -1
  135. package/dist/assets/{upload-D-zDieUV.js → upload-CKPXpkhw.js} +1 -1
  136. package/dist/assets/{veo-COYFIzjX.js → veo-Ccq4L7tM.js} +1 -1
  137. package/dist/assets/{wan-CS1VT95N.js → wan-Ds131rTG.js} +1 -1
  138. package/dist/assets/{web-DvIQN5XL.js → web-BNKwT-_X.js} +1 -1
  139. package/dist/assets/{web-pBPCvJpR.js → web-CIQob5nc.js} +1 -1
  140. package/dist/assets/{web-CXHmXDxA.js → web-CIU8i5ts.js} +1 -1
  141. package/dist/assets/{web-vLJJVSaY.js → web-DnggU2zT.js} +1 -1
  142. package/dist/assets/{web-Bh0mmO9l.js → web-NRrZsNTw.js} +1 -1
  143. package/dist/assets/{webextrator-DwVfL_kB.js → webextrator-CUsuPiGt.js} +1 -1
  144. package/dist/index.html +1 -1
  145. package/package.json +1 -1
  146. package/dist/assets/ApiCodeButton-BfkxBwQR.css +0 -1
  147. package/dist/assets/ApiCodeButton-D08Q_WRa.js +0 -1
  148. package/dist/assets/Index-C0XceZ0C.js +0 -1
  149. package/dist/assets/esm-D-G57aZg.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,ht as u,it as d,j as f,mt as p,qt as m,rt as h,tt as g,x as _,z as v}from"./vendor-chart-Dw-P17PN.js";import{E as y}from"./use-deprecated-B-uvyrTL.js";import{r as b,t as x}from"./select-CVXgXqir.js";import{n as S,t as C}from"./tabs-C_XpWXWP.js";import{t as w}from"./upload-D-zDieUV.js";import{t as T}from"./tooltip-Cb1CIPoD.js";import{t as E}from"./image-DGnWsKHn.js";import{t as ee}from"./alert-2qBdi1l1.js";import{n as D,r as O}from"./radio-Bj0tEwH8.js";import{t as k}from"./drawer-u1pTNeW8.js";import{t as A}from"./input-number-_KRhOc4-.js";import{t as te}from"./slider-CDoSZg65.js";import{t as ne}from"./switch-UZQHGjPB.js";import{Qr as re,ni as ie,ri as j,ti as ae}from"./constants-Cm1pJ8kP.js";import{Di as M,Ht as N,Kt as P,Ut as oe,Vt as F,Wt as I,Xr as L,en as R,gi as se,j as z,oi as B,qr as ce,si as V,sr as H,vi as U,zn as W}from"./index-DqpzpRT-.js";import{t as G}from"./index.es-D7t9e-wf.js";import{t as le}from"./CopyToClipboard-BpPd8B8b.js";import{t as ue}from"./FilePreview-pOUKDsWd.js";import{t as K}from"./ImagePreview-BfslzHEU.js";import{n as de}from"./taskDrawerMixin-DyAUhFEq.js";import{t as q}from"./Consumption-Ch2waQDb.js";import{i as J,n as fe,t as pe}from"./pagination-CyeMpm2N.js";import{t as me}from"./VideoPlayer-BzaeOeXh.js";import{t as he}from"./ApiCodeButton-D08Q_WRa.js";import{t as ge}from"./BotPlaceholder-Dn8d_dlZ.js";import{t as _e}from"./NoTasks-Cox5rrM8.js";import{t as ve}from"./PromptTextarea-CEL2z0Ne.js";var ye=v({name:`LayoutKling`,components:{ElDrawer:k,ElButton:U,FontAwesomeIcon:G},mixins:[de]}),be={class:`main flex flex-row flex-1 min-h-0`},xe={class:`config w-[320px] flex-none h-full flex flex-col bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},Se={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function Ce(t,n,r,i,o,c){let f=l(`font-awesome-icon`),m=l(`el-button`),h=l(`el-drawer`);return g(),s(`div`,be,[e(`div`,xe,[d(t.$slots,`config`,{},void 0,!0)]),e(`div`,Se,[d(t.$slots,`result`,{},void 0,!0)]),u(a(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:p(()=>[a(f,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!t.tasksEmpty]]),a(h,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`350px`},{default:p(()=>[d(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=z(ye,[[`render`,Ce],[`__scopeId`,`data-v-b87958dc`]]),Te={text2video:!0,image2video:!0,endImage:!1,audio:!1,motionControl:!1};function Y(e,t,n){let r=t||`std`,i=n??5;switch(e){case`kling-v1`:return{text2video:!0,image2video:!0,endImage:i===5,audio:!1,motionControl:i===5};case`kling-v1-6`:case`kling-v2-5-turbo`:return{text2video:!0,image2video:!0,endImage:r===`pro`,audio:!1,motionControl:!1};case`kling-v2-6`:return{text2video:!0,image2video:!0,endImage:r===`pro`,audio:r===`pro`,motionControl:!1};case`kling-v2-master`:case`kling-v2-1-master`:return{text2video:!0,image2video:!0,endImage:!1,audio:!1,motionControl:!1};case`kling-v3`:return{text2video:!0,image2video:!0,endImage:!0,audio:!0,motionControl:r!==`4k`};case`kling-v3-omni`:return{text2video:!0,image2video:!0,endImage:!0,audio:!0,motionControl:!1};case`kling-video-o1`:return{text2video:!0,image2video:!0,endImage:!0,audio:!1,motionControl:!1};default:return Te}}function X(e,t){if(!e)return[];let n=t.model??e.model,r=t.mode??e.mode,i=t.duration??e.duration;if(!n)return[];let a=Y(n,r,i),o=[];return e.end_image_url&&!a.endImage&&o.push({field:`end_image_url`,i18nLabel:`kling.name.endImage`}),e.generate_audio&&!a.audio&&o.push({field:`generate_audio`,i18nLabel:`kling.name.generateAudio`}),e.camera_control?.type&&(!a.motionControl||e.start_image_url)&&o.push({field:`camera_control`,i18nLabel:`kling.name.cameraControl`}),o}function Z(e,t){let n={...e};for(let e of t)e.field===`end_image_url`&&(n.end_image_url=void 0),e.field===`generate_audio`&&(n.generate_audio=!1),e.field===`camera_control`&&(n.camera_control=void 0);return n}var Ee=v({name:`ModelSelector`,components:{ElSelect:b,ElOption:x},props:{modelValue:{type:String,default:void 0}},emits:[`update:modelValue`],data(){return{revertKey:0,options:[{value:`kling-v3`,label:`v3`},{value:`kling-v3-omni`,label:`v3-Omni`},{value:`kling-v2-6`,label:`v2.6`},{value:`kling-v2-5-turbo`,label:`v2.5-Turbo`},{value:`kling-v2-1-master`,label:`v2.1-Master`},{value:`kling-v2-master`,label:`v2-Master`},{value:`kling-v1-6`,label:`v1.6`},{value:`kling-v1`,label:`v1`},{value:`kling-video-o1`,label:`Video-o1`}]}},computed:{value(){return this.$store.state.kling?.config?.model}},mounted(){this.value||this.applyModel(re)},methods:{async onChange(e){let t=this.$store.state.kling?.config||{},n=X(t,{model:e});if(n.length===0){this.applyModel(e);return}let r=n.map(e=>this.$t(e.i18nLabel)).join(`、`);try{await B.confirm(this.$t(`kling.message.featureNotSupportedBody`,{fields:r}),this.$t(`kling.message.featureNotSupportedTitle`),{confirmButtonText:this.$t(`kling.button.confirmContinue`),cancelButtonText:this.$t(`kling.button.cancelSwitch`),type:`warning`});let i=Z({...t,model:e},n);this.$store.commit(`kling/setConfig`,i),V.success(this.$t(`kling.message.featureRemovedNotice`,{fields:r}))}catch{this.revertKey+=1}},applyModel(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling.config,model:e})}}}),De={class:`field`},Oe={class:`title font-bold`};function ke(t,n,r,a,o,u){let d=l(`el-option`),m=l(`el-select`);return g(),s(`div`,De,[e(`h2`,Oe,i(t.$t(`pika.name.model`)),1),(g(),f(m,{key:t.revertKey,"model-value":t.value,class:`value`,placeholder:t.$t(`pika.placeholder.select`),onChange:t.onChange},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(d,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`model-value`,`placeholder`,`onChange`]))])}var Ae=z(Ee,[[`render`,ke],[`__scopeId`,`data-v-04059875`]]),je=v({name:`ModeSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},props:{modelValue:{type:String,default:void 0}},emits:[`update:modelValue`],data(){return{revertKey:0}},computed:{selectedModel(){return this.$store.state.kling?.config?.model||``},cameraControlSet(){return!!this.$store.state.kling?.config?.camera_control?.type},fourKReason(){return j.includes(this.selectedModel)?this.cameraControlSet?this.$t(`kling.description.mode4kIncompatibleCamera`):``:this.$t(`kling.description.mode4kRequiresV3`)},options(){return[{value:`std`,label:this.$t(`kling.name.modeStd`),disabled:!1,disabledReason:``},{value:`pro`,label:this.$t(`kling.name.modePro`),disabled:!1,disabledReason:``},{value:`4k`,label:this.$t(`kling.name.mode4k`),disabled:!!this.fourKReason,disabledReason:this.fourKReason}]},value(){return this.$store.state.kling?.config?.mode}},watch:{fourKReason(e){e&&this.value===`4k`&&this.applyMode(`std`)}},mounted(){this.value||this.applyMode(`std`)},methods:{async onChange(e){let t=this.$store.state.kling?.config||{},n=X(t,{mode:e});if(n.length===0){this.applyMode(e);return}let r=n.map(e=>this.$t(e.i18nLabel)).join(`、`);try{await B.confirm(this.$t(`kling.message.featureNotSupportedBody`,{fields:r}),this.$t(`kling.message.featureNotSupportedTitle`),{confirmButtonText:this.$t(`kling.button.confirmContinue`),cancelButtonText:this.$t(`kling.button.cancelSwitch`),type:`warning`});let i=Z({...t,mode:e},n);this.$store.commit(`kling/setConfig`,i),V.success(this.$t(`kling.message.featureRemovedNotice`,{fields:r}))}catch{this.revertKey+=1}},applyMode(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling.config,mode:e})}}}),Me={class:`field`},Ne={class:`header`},Pe={class:`title font-bold`},Fe={key:0,class:`opt-tip`};function Ie(t,r,u,d,m,_){let v=l(`info-icon`),y=l(`el-option`),b=l(`el-select`);return g(),s(`div`,Me,[e(`div`,Ne,[e(`h2`,Pe,i(t.$t(`kling.name.mode`)),1),a(v,{content:t.$t(`kling.description.mode`),class:`info-icon`},null,8,[`content`])]),(g(),f(b,{key:t.revertKey,"model-value":t.value,class:`value`,placeholder:t.$t(`kling.placeholder.select`),clearable:!0,onChange:t.onChange},{default:p(()=>[(g(!0),s(c,null,h(t.options,t=>(g(),f(y,{key:t.value,label:t.label,value:t.value,disabled:t.disabled},{default:p(()=>[e(`span`,{class:n({"opt-disabled":t.disabled})},i(t.label),3),t.disabled&&t.disabledReason?(g(),s(`span`,Fe,i(t.disabledReason),1)):o(``,!0)]),_:2},1032,[`label`,`value`,`disabled`]))),128))]),_:1},8,[`model-value`,`placeholder`,`onChange`]))])}var Le=z(je,[[`render`,Ie],[`__scopeId`,`data-v-9a8fa3c5`]]),Re=[3,5,8,10,12,15],ze=[5,10],Be=v({name:`DurationSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},data(){return{revertKey:0}},computed:{selectedModel(){return this.$store.state.kling?.config?.model||``},isV3Model(){return j.includes(this.selectedModel)},allowedDurations(){return this.isV3Model?Re:ze},value(){return this.$store.state.kling?.config?.duration??5},selectValue(){let e=this.allowedDurations;return e.includes(this.value)?this.value:e.includes(5)?5:e[0]}},watch:{isV3Model(){this.allowedDurations.includes(this.value)||this.applyDuration(5)}},mounted(){this.$store.state.kling?.config?.duration||this.applyDuration(5)},methods:{async onChange(e){let t=this.$store.state.kling?.config||{},n=X(t,{duration:e});if(n.length===0){this.applyDuration(e);return}let r=n.map(e=>this.$t(e.i18nLabel)).join(`、`);try{await B.confirm(this.$t(`kling.message.featureNotSupportedBody`,{fields:r}),this.$t(`kling.message.featureNotSupportedTitle`),{confirmButtonText:this.$t(`kling.button.confirmContinue`),cancelButtonText:this.$t(`kling.button.cancelSwitch`),type:`warning`});let i=Z({...t,duration:e},n);this.$store.commit(`kling/setConfig`,i),V.success(this.$t(`kling.message.featureRemovedNotice`,{fields:r}))}catch{this.revertKey+=1}},applyDuration(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling.config,duration:e})}}}),Ve={class:`field`},He={class:`control`},Ue={class:`label`},We={class:`title font-bold`};function Ge(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,Ve,[e(`div`,He,[e(`div`,Ue,[e(`h2`,We,i(t.$t(`kling.name.duration`)),1),a(m,{content:t.$t(`kling.description.duration`),class:`info-icon ml-1`},null,8,[`content`])]),(g(),f(v,{key:t.revertKey,"model-value":t.selectValue,class:`value`,placeholder:t.$t(`kling.placeholder.select`),onChange:t.onChange},{default:p(()=>[(g(!0),s(c,null,h(t.allowedDurations,e=>(g(),f(_,{key:e,label:`${e}s`,value:e},null,8,[`label`,`value`]))),128))]),_:1},8,[`model-value`,`placeholder`,`onChange`]))])])}var Ke=z(Be,[[`render`,Ge],[`__scopeId`,`data-v-5ae55e28`]]),qe=v({name:`RatioSelector`,data(){return{options:[{value:`1:1`,label:`1:1`,width:20,height:20},{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?.kling?.config?.aspect_ratio},set(e){console.debug(`set ratio`,e),this.$store.commit(`kling/setConfig`,{...this.$store.state?.kling?.config,aspect_ratio:e})}}},mounted(){this.value||=`1:1`}}),Je={class:`text-sm font-bold mb-2 block`},Ye={class:`items`},Xe=[`onClick`],Ze={class:`name`};function Qe(t,r,a,o,l,u){return g(),s(`div`,null,[e(`span`,Je,i(t.$t(`kling.name.ratio`)),1),e(`div`,Ye,[(g(!0),s(c,null,h(t.options,(r,a)=>(g(),s(`div`,{key:a,class:n({active:t.active===a,item:!0}),onClick:e=>t.value=r.value},[e(`div`,{class:n([`preview`,r.label])},[e(`div`,{class:`rect`,style:m({width:r.width+`px`,height:r.height+`px`})},null,4)],2),e(`p`,Ze,i(r.label),1)],10,Xe))),128))])])}var $e=z(qe,[[`render`,Qe],[`__scopeId`,`data-v-cdb14b2f`]]),et=v({name:`StartImage`,components:{ElUpload:w,ElButton:U,ElTooltip:T,InfoIcon:J,FontAwesomeIcon:G,ImagePreview:K},mixins:[I,N],emits:[`change`],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},reachedLimit(){return(this.fileList?.length||0)>=1},value:{get(){return this.$store.state?.kling?.config?.start_image_url},set(){}}},mounted(){this.value||=void 0,this.onSetStartImageUrl()},methods:{onExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onSetStartImageUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setConfig`,{...this.$store.state?.kling?.config,start_image_url:e})},async onSuccess(){this.onSetStartImageUrl()}}}),tt={class:`relative`},nt={class:`flex justify-between`},rt={class:`flex justify-start items-center`},it={class:`text-sm font-bold`};function at(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`el-upload`);return g(),s(`div`,tt,[e(`div`,nt,[e(`div`,rt,[e(`span`,it,i(t.$t(`kling.name.startImage`)),1),a(h,{content:t.$t(`kling.description.uploadStartImage`)},null,8,[`content`])])]),a(x,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,disabled:t.reachedLimit,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(b,{content:t.$t(`kling.message.uploadReferencesExceed`),disabled:!t.reachedLimit,placement:`top`},{default:p(()=>[e(`span`,null,[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`,disabled:t.reachedLimit},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1},8,[`disabled`])])]),_:1},8,[`content`,`disabled`])]),_:1},8,[`file-list`,`disabled`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var ot=z(et,[[`render`,at],[`__scopeId`,`data-v-756dc269`]]),st=v({name:`EndImage`,components:{ElUpload:w,ElButton:U,ElTooltip:T,ImagePreview:K,InfoIcon:J,FontAwesomeIcon:G},mixins:[I,N],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},reachedLimit(){return(this.fileList?.length||0)>=1},klingConfig(){return this.$store.state?.kling?.config||{}},endImageSupported(){return Y(this.klingConfig.model,this.klingConfig.mode,this.klingConfig.duration).endImage},hasStartImage(){return!!this.klingConfig.start_image_url},uploadDisabled(){return this.reachedLimit||!this.endImageSupported||!this.hasStartImage},uploadTooltip(){return this.endImageSupported?this.hasStartImage?this.reachedLimit?this.$t(`kling.message.uploadReferencesExceed`):``:this.$t(`kling.message.endImageRequiresStart`):this.$t(`kling.message.endImageNotSupported`)},storeValue(){return this.klingConfig.end_image_url},value:{get(){return this.storeValue},set(){}}},watch:{storeValue(e){!e&&this.fileList.length>0&&(this.fileList=[])},hasStartImage(e){!e&&this.storeValue&&(this.fileList=[],this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,end_image_url:void 0}))}},mounted(){this.value||=void 0,this.onSetEndImageUrl()},methods:{onBeforeUpload(){return this.endImageSupported?this.hasStartImage?!0:(V.warning(this.$t(`kling.message.endImageRequiresStart`)),!1):(V.warning(this.$t(`kling.message.endImageNotSupported`)),!1)},onExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onSetEndImageUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,end_image_url:e})},async onSuccess(){this.onSetEndImageUrl()}}}),ct={class:`relative`},lt={class:`flex justify-between`},ut={class:`flex justify-start items-center`},dt={class:`text-sm font-bold`};function ft(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`el-upload`);return g(),s(`div`,ct,[e(`div`,lt,[e(`div`,ut,[e(`span`,dt,i(t.$t(`kling.name.endImage`)),1),a(h,{content:t.$t(`kling.description.uploadEndImage`)},null,8,[`content`])])]),a(x,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,disabled:t.uploadDisabled,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"before-upload":t.onBeforeUpload,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(b,{content:t.uploadTooltip,disabled:!t.uploadDisabled,placement:`top`},{default:p(()=>[e(`span`,null,[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`,disabled:t.uploadDisabled},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1},8,[`disabled`])])]),_:1},8,[`content`,`disabled`])]),_:1},8,[`file-list`,`disabled`,`action`,`before-upload`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var pt=z(st,[[`render`,ft],[`__scopeId`,`data-v-c1b257e5`]]),mt=v({name:`CfgScaleSelector`,components:{ElSlider:te,InfoIcon:J,ElInputNumber:A},computed:{value:{get(){return this.$store.state?.kling?.config?.cfg_scale},set(e){console.debug(`set cfg_scale`,e),this.$store.commit(`kling/setConfig`,{...this.$store.state?.kling?.config,cfg_scale:e})}}},mounted(){this.value||=0}}),ht={class:`flex justify-between`},gt={class:`flex justify-start items-center`},_t={class:`text-sm font-bold`},vt={class:`flex justify-end items-center`},yt={class:`w-full`};function bt(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-input-number`),p=l(`el-slider`);return g(),s(`div`,null,[e(`div`,ht,[e(`div`,gt,[e(`span`,_t,i(t.$t(`kling.name.cfgScale`)),1),a(d,{content:t.$t(`kling.description.cfgScale`)},null,8,[`content`])]),e(`div`,vt,[a(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,"controls-position":`right`},null,8,[`modelValue`])])]),e(`div`,yt,[a(p,{modelValue:t.value,"onUpdate:modelValue":n[1]||=e=>t.value=e,min:0,max:1,step:.1},null,8,[`modelValue`])])])}var xt=z(mt,[[`render`,bt]]),St=v({name:`GenerateAudioSelector`,components:{ElSwitch:ne,InfoIcon:J},computed:{selectedModel(){return this.$store.state.kling?.config?.model||``},selectedMode(){return this.$store.state.kling?.config?.mode||``},supported(){return!!(j.includes(this.selectedModel)||this.selectedModel===`kling-v2-6`&&this.selectedMode===`pro`)},tooltipContent(){return this.supported?this.$t(`kling.description.generateAudio`):this.$t(`kling.description.generateAudioUnsupported`)},value:{get(){return this.supported?this.$store.state.kling?.config?.generate_audio??!1:!1},set(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,generate_audio:e})}}},watch:{supported(e){!e&&this.$store.state.kling?.config?.generate_audio&&this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,generate_audio:!1})}}}),Ct={class:`relative`},wt={class:`flex justify-between items-center`},Tt={class:`flex justify-start items-center`},Et={class:`text-sm font-bold`};function Dt(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-switch`);return g(),s(`div`,Ct,[e(`div`,wt,[e(`div`,Tt,[e(`span`,Et,i(t.$t(`kling.name.generateAudio`)),1),a(d,{content:t.tooltipContent},null,8,[`content`])]),a(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,disabled:!t.supported},null,8,[`modelValue`,`disabled`])])])}var Ot=z(St,[[`render`,Dt]]),kt=[`horizontal`,`vertical`,`pan`,`tilt`,`roll`,`zoom`],At=v({name:`CameraControlSelector`,components:{ElSelect:b,ElOption:x,ElSlider:te,ElInputNumber:A,InfoIcon:J},data(){return{configKeys:kt}},computed:{typeOptions(){return[{value:``,label:this.$t(`kling.name.cameraTypeNone`)},{value:`simple`,label:this.$t(`kling.name.cameraTypeSimple`)},{value:`down_back`,label:this.$t(`kling.name.cameraTypeDownBack`)},{value:`forward_up`,label:this.$t(`kling.name.cameraTypeForwardUp`)},{value:`left_turn_forward`,label:this.$t(`kling.name.cameraTypeLeftTurnForward`)},{value:`right_turn_forward`,label:this.$t(`kling.name.cameraTypeRightTurnForward`)}]},selectedMode(){return this.$store.state.kling?.config?.mode||``},selectedModel(){return this.$store.state.kling?.config?.model||``},selectedDuration(){return this.$store.state.kling?.config?.duration},motionControlSupported(){return Y(this.selectedModel,this.selectedMode,this.selectedDuration).motionControl},hasStartImage(){return!!this.$store.state.kling?.config?.start_image_url},disabled(){return!this.motionControlSupported||this.hasStartImage},tooltipContent(){return this.motionControlSupported?this.hasStartImage?this.$t(`kling.description.cameraControlDisabledImage2Video`):this.$t(`kling.description.cameraControl`):this.$t(`kling.description.cameraControlNotSupported`)},selectedType(){return this.$store.state.kling?.config?.camera_control?.type},selectedTypeRaw:{get(){return this.selectedType??``},set(e){let t=this.$store.state.kling?.config||{};if(!e){let e={...t};delete e.camera_control,this.$store.commit(`kling/setConfig`,e);return}let n=e;this.$store.commit(`kling/setConfig`,{...t,camera_control:{type:n,config:n===`simple`?t.camera_control?.config||{}:void 0}})}},configValues(){return this.$store.state.kling?.config?.camera_control?.config||{}}},watch:{disabled(e){e&&this.selectedType!==void 0&&(this.selectedTypeRaw=``)}},methods:{writeConfig(e,t){let n=this.$store.state.kling?.config||{},r=n.camera_control||{type:`simple`},i={...r.config||{}};t==null?delete i[e]:i[e]=t,this.$store.commit(`kling/setConfig`,{...n,camera_control:{...r,type:`simple`,config:i}})},onSliderChange(e,t){this.writeConfig(e,t)},onNumberChange(e,t){this.writeConfig(e,t)}}}),jt={class:`field`},Mt={class:`header`},Nt={class:`text-sm font-bold`},Pt={key:0,class:`config-grid`},Ft={class:`cfg-row-head`},It={class:`cfg-name`};function Lt(t,n,r,u,d,m){let _=l(`info-icon`),v=l(`el-option`),y=l(`el-select`),b=l(`el-input-number`),x=l(`el-slider`);return g(),s(`div`,jt,[e(`div`,Mt,[e(`span`,Nt,i(t.$t(`kling.name.cameraControl`)),1),a(_,{content:t.tooltipContent},null,8,[`content`])]),a(y,{modelValue:t.selectedTypeRaw,"onUpdate:modelValue":n[0]||=e=>t.selectedTypeRaw=e,class:`value`,placeholder:t.$t(`kling.placeholder.cameraType`),clearable:!0,disabled:t.disabled},{default:p(()=>[(g(!0),s(c,null,h(t.typeOptions,e=>(g(),f(v,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`disabled`]),t.selectedType===`simple`&&!t.disabled?(g(),s(`div`,Pt,[(g(!0),s(c,null,h(t.configKeys,n=>(g(),s(`div`,{key:n,class:`cfg-row`},[e(`div`,Ft,[e(`span`,It,i(t.$t(`kling.name.cc_${n}`)),1),a(b,{modelValue:t.configValues[n],"onUpdate:modelValue":e=>t.configValues[n]=e,min:-1,max:1,step:.1,precision:1,"controls-position":`right`,size:`small`,class:`cfg-num`,onChange:e=>t.onNumberChange(n,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])]),a(x,{"model-value":t.configValues[n]??0,min:-1,max:1,step:.1,onInput:e=>t.onSliderChange(n,e)},null,8,[`model-value`,`onInput`])]))),128))])):o(``,!0)])}var Rt=z(At,[[`render`,Lt],[`__scopeId`,`data-v-cd896060`]]),zt=[{groupKey:`cameraMovements`,chipKeys:[`rotateAround`,`stationary`,`handheld`,`zoomOut`,`zoomIn`,`follow`,`panRight`,`tiltUp`,`tiltDown`,`orbit`]},{groupKey:`cameraSpeed`,chipKeys:[`speedSlow`,`speedMedium`,`speedFast`]},{groupKey:`shotType`,chipKeys:[`shotClose`,`shotMedium`,`shotLong`,`shotLowAngle`,`shotHighAngle`,`shotShallowDof`,`shotFront`,`shotProfile`,`shotCloseUp`,`shotDrone`]},{groupKey:`light`,chipKeys:[`lightSunlight`,`lightSoft`,`lightNeon`,`lightWarm`,`lightNature`,`lightCandle`,`lightCityNight`]},{groupKey:`frame`,chipKeys:[`frameRichDetails`,`frameSimpleBg`]},{groupKey:`atmosphere`,chipKeys:[`atmosphereMysterious`,`atmospherePeaceful`,`atmosphereHeartwarming`,`atmosphereVivid`,`atmosphereColorful`]}],Q=`, `;function Bt(e,t){let n=(e||``).trim();return n?n.includes(t)?n:`${n}${Q}${t}`:t}function $(e,t){if(!e||!t)return e||``;let n=[`${t}${Q}`,`${Q}${t}`,t],r=e;for(let e of n)if(r.includes(e)){r=r.replace(e,``);break}return r.replace(/(?:,\s*)+$/,``).replace(/^(?:,\s*)+/,``)}var Vt=v({name:`InspirationPills`,components:{FontAwesomeIcon:G},computed:{prompt(){return this.$store.state.kling?.config?.prompt||``},allChipTexts(){return zt.flatMap(e=>e.chipKeys.map(e=>this.$t(`kling.inspiration.chip.${e}`)))},selected(){let e=this.prompt;if(!e)return[];let t=[];for(let n of this.allChipTexts){let r=e.indexOf(n);r!==-1&&t.push({text:n,idx:r})}return t.sort((e,t)=>e.idx-t.idx).map(e=>e.text)}},methods:{onRemove(e){let t=$(this.prompt,e);this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,prompt:t})}}}),Ht={key:0,class:`pills`,role:`list`},Ut={class:`pill-text`},Wt=[`aria-label`,`onClick`];function Gt(n,r,u,d,f,p){let m=l(`font-awesome-icon`);return n.selected.length>0?(g(),s(`div`,Ht,[(g(!0),s(c,null,h(n.selected,r=>(g(),s(`div`,{key:r,class:`pill`,role:`listitem`},[e(`span`,Ut,i(r),1),e(`button`,{type:`button`,class:`pill-remove`,"aria-label":n.$t(`kling.inspiration.removeChip`),onClick:t(e=>n.onRemove(r),[`stop`])},[a(m,{icon:`fa-solid fa-xmark`})],8,Wt)]))),128))])):o(``,!0)}var Kt=v({name:`PromptInput`,components:{ElButton:U,FontAwesomeIcon:G,PromptTextarea:ve,InspirationPills:z(Vt,[[`render`,Gt],[`__scopeId`,`data-v-5fc4fa65`]])},emits:[`open-inspiration`],computed:{prompt:{get(){return this.$store.state.kling?.config?.prompt},set(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,prompt:e})}}},mounted(){this.prompt||=``}});function qt(e,t,n,o,s,c){let u=l(`font-awesome-icon`),d=l(`el-button`),m=l(`inspiration-pills`),h=l(`prompt-textarea`);return g(),f(h,{modelValue:e.prompt,"onUpdate:modelValue":t[1]||=t=>e.prompt=t,title:e.$t(`kling.name.prompt`),info:e.$t(`kling.description.prompt`),placeholder:e.$t(`kling.placeholder.prompt`)},{actions:p(()=>[a(d,{text:``,size:`small`,class:`inspiration-btn`,onClick:t[0]||=t=>e.$emit(`open-inspiration`)},{default:p(()=>[a(u,{icon:`fa-regular fa-lightbulb`,class:`mr-1`}),r(` `+i(e.$t(`kling.inspiration.openButton`)),1)]),_:1})]),before:p(()=>[a(m)]),_:1},8,[`modelValue`,`title`,`info`,`placeholder`])}var Jt=z(Kt,[[`render`,qt],[`__scopeId`,`data-v-c01fc1a6`]]),Yt=v({name:`NegativePromptInput`,components:{ElInput:M,InfoIcon:J},computed:{prompt:{get(){return this.$store.state.kling?.config?.negative_prompt},set(e){console.debug(`set prompt`,e),this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,negative_prompt:e})}}},mounted(){this.prompt||=``}}),Xt={class:`field`},Zt={class:`box`},Qt={class:`title font-bold`};function $t(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-input`);return g(),s(`div`,Xt,[e(`div`,Zt,[e(`h2`,Qt,i(t.$t(`kling.name.negativePrompt`)),1),a(d,{content:t.$t(`kling.description.negativePrompt`),class:`info`},null,8,[`content`])]),a(f,{modelValue:t.prompt,"onUpdate:modelValue":n[0]||=e=>t.prompt=e,rows:3,type:`textarea`,class:`prompt`,placeholder:t.$t(`kling.placeholder.negativePrompt`)},null,8,[`modelValue`,`placeholder`])])}var en=z(Yt,[[`render`,$t],[`__scopeId`,`data-v-de98cf01`]]),tn=v({name:`InspirationDrawer`,components:{ElDrawer:k,ElButton:U,FontAwesomeIcon:G},props:{modelValue:{type:Boolean,default:!1}},emits:[`update:modelValue`],data(){return{groups:zt,Close:y}},computed:{visible:{get(){return this.modelValue},set(e){this.$emit(`update:modelValue`,e)}},drawerSize(){return window.innerWidth<768?`100%`:`380px`},prompt(){return this.$store.state.kling?.config?.prompt||``},allChipTexts(){return this.groups.flatMap(e=>e.chipKeys.map(e=>this.$t(`kling.inspiration.chip.${e}`)))},selectedCount(){return this.allChipTexts.filter(e=>this.isSelected(e)).length}},methods:{chipText(e){return this.$t(`kling.inspiration.chip.${e}`)},isSelected(e){return e?this.prompt.includes(e):!1},setPrompt(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,prompt:e})},onToggle(e){e&&(this.isSelected(e)?this.setPrompt($(this.prompt,e)):this.setPrompt(Bt(this.prompt,e)))},onClearSelected(){let e=this.prompt;for(let t of this.allChipTexts)for(;e.includes(t);)e=$(e,t);this.setPrompt(e)}}}),nn={class:`drawer-content`},rn={class:`drawer-header`},an={class:`title-row`},on={class:`title`},sn={class:`hint`},cn={key:0,class:`selected-bar`},ln={class:`selected-text`},un={class:`groups`},dn={class:`group-title`},fn={class:`chip-grid`},pn=[`onClick`];function mn(t,u,d,m,_,v){let y=l(`font-awesome-icon`),b=l(`el-button`),x=l(`el-drawer`);return g(),f(x,{modelValue:t.visible,"onUpdate:modelValue":u[1]||=e=>t.visible=e,direction:`rtl`,"with-header":!1,size:t.drawerSize,"custom-class":`kling-inspiration-drawer`,"destroy-on-close":!1},{default:p(()=>[e(`div`,nn,[e(`div`,rn,[e(`div`,an,[a(y,{icon:`fa-regular fa-lightbulb`,class:`mr-2`}),e(`span`,on,i(t.$t(`kling.inspiration.title`)),1)]),a(b,{text:``,icon:t.Close,class:`close-btn`,onClick:u[0]||=e=>t.visible=!1},null,8,[`icon`])]),e(`div`,sn,i(t.$t(`kling.inspiration.hint`)),1),t.selectedCount>0?(g(),s(`div`,cn,[e(`span`,ln,i(t.$t(`kling.inspiration.selectedSummary`,{count:t.selectedCount})),1),a(b,{text:``,size:`small`,class:`clear-btn`,onClick:t.onClearSelected},{default:p(()=>[r(i(t.$t(`kling.inspiration.clearSelected`)),1)]),_:1},8,[`onClick`])])):o(``,!0),e(`div`,un,[(g(!0),s(c,null,h(t.groups,r=>(g(),s(`div`,{key:r.groupKey,class:`group`},[e(`div`,dn,i(t.$t(`kling.inspiration.group.${r.groupKey}`)),1),e(`div`,fn,[(g(!0),s(c,null,h(r.chipKeys,e=>(g(),s(`button`,{key:e,type:`button`,class:n({chip:!0,active:t.isSelected(t.chipText(e))}),onClick:n=>t.onToggle(t.chipText(e))},i(t.chipText(e)),11,pn))),128))])]))),128))])])]),_:1},8,[`modelValue`,`size`])}var hn=z(tn,[[`render`,mn],[`__scopeId`,`data-v-7d457a69`]]),gn={"kling-v3":`v3`,"kling-v3-omni":`v3-Omni`,"kling-v2-6":`v2.6`,"kling-v2-5-turbo":`v2.5-Turbo`,"kling-v2-1-master":`v2.1-Master`,"kling-v2-master":`v2-Master`,"kling-v1-6":`v1.6`,"kling-v1":`v1`,"kling-video-o1":`Video-o1`},_n={std:`720p`,pro:`1080p`,"4k":`4K`},vn=v({name:`SummaryChip`,components:{FontAwesomeIcon:G},computed:{config(){return this.$store.state.kling?.config||{}},modelLabel(){let e=this.config?.model||`kling-v2-5-turbo`;return gn[e]||e},durationLabel(){return`${this.config?.duration??5}s`},aspectRatio(){return this.config?.aspect_ratio||``},modeLabel(){let e=this.config?.mode||`std`;return _n[e]||e},generateAudio(){return!!this.config?.generate_audio}}}),yn={class:`summary-chip`},bn=[`title`],xn=[`title`],Sn=[`title`],Cn=[`title`],wn=[`title`];function Tn(t,n,r,c,u,d){let f=l(`font-awesome-icon`);return g(),s(`div`,yn,[e(`span`,{class:`part`,title:t.$t(`kling.name.model`)},i(t.modelLabel),9,bn),n[0]||=e(`span`,{class:`dot`},`·`,-1),e(`span`,{class:`part`,title:t.$t(`kling.name.duration`)},i(t.durationLabel),9,xn),n[1]||=e(`span`,{class:`dot`},`·`,-1),e(`span`,{class:`part`,title:t.$t(`kling.name.ratio`)},i(t.aspectRatio||`16:9`),9,Sn),n[2]||=e(`span`,{class:`dot`},`·`,-1),e(`span`,{class:`part`,title:t.$t(`kling.name.mode`)},i(t.modeLabel),9,Cn),t.generateAudio?(g(),s(`span`,{key:0,class:`audio`,title:t.$t(`kling.name.generateAudio`)},[a(f,{icon:`fa-solid fa-headphones`})],8,wn)):o(``,!0)])}var En=v({name:`ConfigPanel`,components:{ElButton:U,Consumption:q,FontAwesomeIcon:G,PromptInput:Jt,NegativePromptInput:en,ModelSelector:Ae,ModeSelector:Le,DurationSelector:Ke,RatioSelector:$e,StartImage:ot,CfgScaleSelector:xt,GenerateAudioSelector:Ot,CameraControlSelector:Rt,InspirationDrawer:hn,SummaryChip:z(vn,[[`render`,Tn],[`__scopeId`,`data-v-418a6733`]]),EndImage:pt},emits:[`generate`],data(){return{inspirationOpen:!1}},computed:{config(){return this.$store.state.kling?.config},consumption(){return P(this.config,this.service?.cost)},service(){return this.$store.state.kling?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),Dn={class:`flex flex-col h-full`},On={class:`flex-1 overflow-y-auto p-5`},kn={class:`flex flex-col items-center justify-center px-5 pb-5`};function An(t,n,o,c,u,d){let m=l(`prompt-input`),h=l(`model-selector`),_=l(`ratio-selector`),v=l(`start-image`),y=l(`end-image`),b=l(`duration-selector`),x=l(`mode-selector`),S=l(`generate-audio-selector`),C=l(`camera-control-selector`),w=l(`cfg-scale-selector`),T=l(`negative-prompt-input`),E=l(`summary-chip`),ee=l(`consumption`),D=l(`font-awesome-icon`),O=l(`el-button`),k=l(`inspiration-drawer`);return g(),s(`div`,Dn,[e(`div`,On,[a(m,{class:`mb-4`,onOpenInspiration:n[0]||=e=>t.inspirationOpen=!0}),a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),a(v,{class:`mb-2`}),a(y,{class:`mb-2`}),a(b,{class:`mb-4`}),a(x,{class:`mb-4`}),a(S,{class:`mb-4`}),a(C,{class:`mb-4`}),a(w,{class:`mb-4`}),a(T,{class:`mb-4`})]),e(`div`,kn,[a(E),a(ee,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),t.config?.video_url!==void 0||t.config?.custom?(g(),f(O,{key:0,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(D,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.extend`)),1)]),_:1},8,[`onClick`])):(g(),f(O,{key:1,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(D,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.generate`)),1)]),_:1},8,[`onClick`]))]),a(k,{modelValue:t.inspirationOpen,"onUpdate:modelValue":n[1]||=e=>t.inspirationOpen=e},null,8,[`modelValue`])])}var jn=z(En,[[`render`,An]]),Mn=v({name:`MotionImage`,components:{ElUpload:w,ElButton:U,InfoIcon:J,FontAwesomeIcon:G,ImagePreview:K},mixins:[I,N],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)}},mounted(){this.onSetImageUrl()},methods:{onExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onRemove(e){this.fileList.splice(this.fileList.indexOf(e),1),this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,image_url:void 0})},onSetImageUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,image_url:e})},async onSuccess(){this.onSetImageUrl()}}}),Nn={class:`relative`},Pn={class:`flex justify-between`},Fn={class:`flex justify-start items-center`},In={class:`text-sm font-bold`};function Ln(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-upload`);return g(),s(`div`,Nn,[e(`div`,Pn,[e(`div`,Fn,[e(`span`,In,i(t.$t(`kling.name.motionImage`)),1),a(h,{content:t.$t(`kling.description.motionImage`)},null,8,[`content`])])]),a(b,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.onRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var Rn=z(Mn,[[`render`,Ln],[`__scopeId`,`data-v-e52eaf2f`]]),zn=v({name:`MotionVideo`,components:{ElUpload:w,ElButton:U,InfoIcon:J,FilePreview:ue,FontAwesomeIcon:G},mixins:[N],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)}},mounted(){this.onSetVideoUrl()},methods:{onExceed(){V.warning(this.$t(`kling.message.uploadVideoExceed`))},onError(){V.error(this.$t(`kling.message.uploadVideoError`))},onRemove(e){this.fileList.splice(this.fileList.indexOf(e),1),this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,video_url:void 0})},beforeUpload(e){let t=e.type===`video/mp4`||e.type===`video/quicktime`,n=e.size/1024/1024<100;return t?n?!0:(V.error(this.$t(`kling.message.uploadVideoSizeExceed`)),!1):(V.error(this.$t(`kling.message.uploadVideoTypeFailed`)),!1)},onSetVideoUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,video_url:e})},async onSuccess(){this.onSetVideoUrl()}}}),Bn={class:`relative`},Vn={class:`flex justify-between`},Hn={class:`flex justify-start items-center`},Un={class:`text-sm font-bold`};function Wn(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`file-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-upload`);return g(),s(`div`,Bn,[e(`div`,Vn,[e(`div`,Hn,[e(`span`,Un,i(t.$t(`kling.name.motionVideo`)),1),a(h,{content:t.$t(`kling.description.motionVideo`)},null,8,[`content`])])]),a(b,{"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.mp4,.mov`,name:`file`,class:`value`,"show-file-list":!0,limit:1,multiple:!1,action:t.uploadUrl,"before-upload":t.beforeUpload,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.percentage===void 0?o(``,!0):(g(),f(_,{key:0,url:e.url||e.response?.file_url,name:e.name,percentage:e.percentage,onRemove:n=>t.onRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`]))]),default:p(()=>[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadVideoUrl`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`before-upload`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var Gn=z(zn,[[`render`,Wn],[`__scopeId`,`data-v-7019a8d2`]]),Kn=v({name:`MotionPromptInput`,components:{ElInput:M,InfoIcon:J},computed:{prompt:{get(){return this.$store.state.kling?.motionConfig?.prompt||``},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,prompt:e})}}}}),qn={class:`field`},Jn={class:`box`},Yn={class:`title font-bold`};function Xn(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-input`);return g(),s(`div`,qn,[e(`div`,Jn,[e(`h2`,Yn,i(t.$t(`kling.name.motionPrompt`)),1),a(d,{content:t.$t(`kling.description.motionPrompt`),class:`info`},null,8,[`content`])]),a(f,{modelValue:t.prompt,"onUpdate:modelValue":n[0]||=e=>t.prompt=e,rows:3,type:`textarea`,class:`prompt`,placeholder:t.$t(`kling.placeholder.motionPrompt`)},null,8,[`modelValue`,`placeholder`])])}var Zn=z(Kn,[[`render`,Xn],[`__scopeId`,`data-v-ca9fdbe5`]]),Qn=`video`,$n=v({name:`CharacterOrientationSelector`,components:{ElRadioGroup:O,ElRadioButton:D,InfoIcon:J},computed:{value:{get(){return this.$store.state.kling?.motionConfig?.character_orientation||Qn},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,character_orientation:e})}}},mounted(){this.$store.state.kling?.motionConfig?.character_orientation||(this.value=Qn)}}),er={class:`field`},tr={class:`header`},nr={class:`text-sm font-bold`};function rr(t,n,o,c,u,d){let f=l(`info-icon`),m=l(`el-radio-button`),h=l(`el-radio-group`);return g(),s(`div`,er,[e(`div`,tr,[e(`span`,nr,i(t.$t(`kling.name.characterOrientation`)),1),a(f,{content:t.$t(`kling.description.characterOrientation`)},null,8,[`content`])]),a(h,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,size:`small`,class:`value`},{default:p(()=>[a(m,{label:`image`},{default:p(()=>[r(i(t.$t(`kling.name.orientationImage`)),1)]),_:1}),a(m,{label:`video`},{default:p(()=>[r(i(t.$t(`kling.name.orientationVideo`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var ir=z($n,[[`render`,rr],[`__scopeId`,`data-v-7a91195b`]]),ar=`kling-v2-6`,or=v({name:`MotionModelSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},computed:{options(){return[{value:`kling-v2-6`,label:`Kling 2.6`},{value:`kling-v3`,label:`Kling 3.0`}]},value:{get(){return this.$store.state.kling?.motionConfig?.model_name||ar},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,model_name:e})}}},mounted(){this.$store.state.kling?.motionConfig?.model_name||(this.value=ar)}}),sr={class:`field`},cr={class:`header`},lr={class:`title font-bold`};function ur(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,sr,[e(`div`,cr,[e(`h2`,lr,i(t.$t(`kling.name.motionModel`)),1),a(m,{content:t.$t(`kling.description.motionModel`)},null,8,[`content`])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var dr=z(or,[[`render`,ur],[`__scopeId`,`data-v-480e8da2`]]),fr=`std`,pr=v({name:`MotionModeSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},computed:{options(){return[{value:`std`,label:this.$t(`kling.name.modeStd`)},{value:`pro`,label:this.$t(`kling.name.modePro`)}]},value:{get(){return this.$store.state.kling?.motionConfig?.mode||fr},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,mode:e})}}},mounted(){this.$store.state.kling?.motionConfig?.mode||(this.value=fr)}}),mr={class:`field`},hr={class:`header`},gr={class:`title font-bold`};function _r(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,mr,[e(`div`,hr,[e(`h2`,gr,i(t.$t(`kling.name.mode`)),1),a(m,{content:t.$t(`kling.description.motionMode`)},null,8,[`content`])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var vr=z(pr,[[`render`,_r],[`__scopeId`,`data-v-1295688c`]]),yr=v({name:`KeepOriginalSoundSelector`,components:{ElSwitch:ne,InfoIcon:J},computed:{value:{get(){return(this.$store.state.kling?.motionConfig?.keep_original_sound??`yes`)===`yes`},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,keep_original_sound:e?`yes`:`no`})}}}}),br={class:`relative`},xr={class:`flex justify-between items-center`},Sr={class:`flex justify-start items-center`},Cr={class:`text-sm font-bold`};function wr(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-switch`);return g(),s(`div`,br,[e(`div`,xr,[e(`div`,Sr,[e(`span`,Cr,i(t.$t(`kling.name.keepOriginalSound`)),1),a(d,{content:t.$t(`kling.description.keepOriginalSound`)},null,8,[`content`])]),a(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e},null,8,[`modelValue`])])])}var Tr=v({name:`MotionPanel`,components:{ElButton:U,FontAwesomeIcon:G,Consumption:q,MotionImage:Rn,MotionVideo:Gn,MotionPromptInput:Zn,CharacterOrientationSelector:ir,MotionModelSelector:dr,MotionModeSelector:vr,KeepOriginalSoundSelector:z(yr,[[`render`,wr]])},emits:[`generate`],computed:{motionConfig(){return this.$store.state.kling?.motionConfig},consumption(){return P({...this.motionConfig,duration:1},this.service?.cost)},service(){return this.$store.state.kling?.service},canGenerate(){let e=this.motionConfig;return!!(e?.image_url&&e?.video_url)}},methods:{onGenerate(){this.$emit(`generate`)}}}),Er={class:`flex flex-col h-full`},Dr={class:`flex-1 overflow-y-auto p-5`},Or={class:`flex flex-col items-center justify-center px-5 pb-5`};function kr(t,n,o,c,u,d){let f=l(`motion-image`),m=l(`motion-video`),h=l(`motion-prompt-input`),_=l(`character-orientation-selector`),v=l(`motion-model-selector`),y=l(`motion-mode-selector`),b=l(`keep-original-sound-selector`),x=l(`consumption`),S=l(`font-awesome-icon`),C=l(`el-button`);return g(),s(`div`,Er,[e(`div`,Dr,[a(f,{class:`mb-3`}),a(m,{class:`mb-3`}),a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),a(v,{class:`mb-4`}),a(y,{class:`mb-4`}),a(b,{class:`mb-4`})]),e(`div`,Or,[a(x,{value:t.consumption,service:t.service,"rate-unit":t.$t(`kling.name.perSecond`),note:t.$t(`kling.message.motionPricingNote`)},null,8,[`value`,`service`,`rate-unit`,`note`]),a(C,{type:`primary`,class:`btn w-full`,round:``,disabled:!t.canGenerate,onClick:t.onGenerate},{default:p(()=>[a(S,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.generateMotion`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Ar=z(Tr,[[`render`,kr]]),jr=v({name:`KlingTabSwitcher`,components:{ElTabs:S,ElTabPane:C,ElTag:se},props:{modelValue:{type:String,default:`videos`}},emits:[`update:modelValue`],computed:{tabs(){return[{value:`videos`,label:this.$t(`kling.tab.videoGeneration`)},{value:`motion`,label:this.$t(`kling.tab.motionControl`)},{value:`talking-photo`,label:this.$t(`kling.tab.talkingPhoto`)}]}},methods:{onUpdate(e){this.$emit(`update:modelValue`,e)}}}),Mr=[`title`],Nr={class:`text`};function Pr(t,n,a,u,d,m){let _=l(`el-tag`),v=l(`el-tab-pane`),y=l(`el-tabs`);return g(),f(y,{"model-value":t.modelValue,class:`kling-tabs`,stretch:``,"onUpdate:modelValue":t.onUpdate},{default:p(()=>[(g(!0),s(c,null,h(t.tabs,t=>(g(),f(v,{key:t.value,name:t.value,disabled:t.disabled},{label:p(()=>[e(`span`,{class:`tab-label`,title:t.disabled?t.disabledReason:void 0},[e(`span`,Nr,i(t.label),1),t.badge?(g(),f(_,{key:0,size:`small`,type:`warning`,class:`badge`},{default:p(()=>[r(i(t.badge),1)]),_:2},1024)):o(``,!0)],8,Mr)]),_:2},1032,[`name`,`disabled`]))),128))]),_:1},8,[`model-value`,`onUpdate:modelValue`])}var Fr=z(jr,[[`render`,Pr],[`__scopeId`,`data-v-fda33e4c`]]),Ir={"kling-v2-6":`v2.6`,"kling-v2-5-turbo":`v2.5-Turbo`,"kling-v2-1-master":`v2.1-Master`,"kling-v2-master":`v2-Master`,"kling-v1-6":`v1.6`,"kling-v1":`v1`},Lr=v({name:`TalkingPhotoModelSelector`,components:{ElSelect:b,ElOption:x},data(){return{options:ie.map(e=>({value:e,label:Ir[e]||e}))}},computed:{value:{get(){return this.$store.state.kling?.talkingPhotoConfig?.model||`kling-v2-1-master`},set(e){this.$store.commit(`kling/setTalkingPhotoConfig`,{...this.$store.state.kling?.talkingPhotoConfig,model:e})}}},mounted(){this.$store.state.kling?.talkingPhotoConfig?.model||(this.value=ae)}}),Rr={class:`field`},zr={class:`title font-bold`};function Br(t,n,r,o,u,d){let m=l(`el-option`),_=l(`el-select`);return g(),s(`div`,Rr,[e(`h2`,zr,i(t.$t(`kling.name.model`)),1),a(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Vr=z(Lr,[[`render`,Br],[`__scopeId`,`data-v-cbc83d11`]]),Hr=v({name:`TalkingPhotoModeSelector`,components:{ElSelect:b,ElOption:x},computed:{options(){return[{value:`std`,label:this.$t(`kling.name.modeStd`)},{value:`pro`,label:this.$t(`kling.name.modePro`)}]},value:{get(){return this.$store.state.kling?.talkingPhotoConfig?.mode||`pro`},set(e){this.$store.commit(`kling/setTalkingPhotoConfig`,{...this.$store.state.kling?.talkingPhotoConfig,mode:e})}}},mounted(){this.$store.state.kling?.talkingPhotoConfig?.mode||(this.value=`pro`)}}),Ur={class:`field`},Wr={class:`title font-bold`};function Gr(t,n,r,o,u,d){let m=l(`el-option`),_=l(`el-select`);return g(),s(`div`,Ur,[e(`h2`,Wr,i(t.$t(`kling.name.mode`)),1),a(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Kr=v({name:`TalkingPhotoPanel`,components:{ElUpload:w,ElButton:U,ElInput:M,FontAwesomeIcon:G,Consumption:q,InfoIcon:J,ImagePreview:K,ModelSelector:Vr,ModeSelector:z(Hr,[[`render`,Gr],[`__scopeId`,`data-v-92525a1d`]])},mixins:[N],emits:[`generate`],data(){return{imageFiles:[],audioFiles:[],uploadUrl:L()+`/api/v1/files/`}},computed:{config(){return this.$store.state.kling?.talkingPhotoConfig||{}},audioUrl(){return this.config.audio_url},headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},service(){return this.$store.state.kling?.service},consumption(){return P({...this.config,action:`talking-photo`},this.service?.cost)},canGenerate(){return!!(this.config.image_url&&this.config.audio_url)}},methods:{commit(e){this.$store.commit(`kling/setTalkingPhotoConfig`,{...this.config,...e})},onPromptChange(e){this.commit({prompt:e})},onImageExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onImageError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onImageSuccess(e){this.commit({image_url:e?.file_url})},onImageRemove(e){this.imageFiles.splice(this.imageFiles.indexOf(e),1),this.commit({image_url:void 0})},onAudioExceed(){V.warning(this.$t(`kling.message.uploadAudioExceed`))},onAudioError(){V.error(this.$t(`kling.message.uploadAudioError`))},onAudioSuccess(e){this.commit({audio_url:e?.file_url})},onAudioRemove(){this.commit({audio_url:void 0})},onGenerate(){this.$emit(`generate`)}}}),qr={class:`flex flex-col h-full`},Jr={class:`flex-1 overflow-y-auto p-5`},Yr={class:`relative mb-4`},Xr={class:`flex justify-start items-center`},Zr={class:`text-sm font-bold`},Qr={class:`relative mb-4`},$r={class:`flex justify-start items-center`},ei={class:`text-sm font-bold`},ti=[`src`],ni={class:`mb-4`},ri={class:`flex justify-start items-center`},ii={class:`text-sm font-bold`},ai={class:`flex flex-col items-center justify-center px-5 pb-5`};function oi(t,n,c,u,d,m){let h=l(`model-selector`),_=l(`mode-selector`),v=l(`info-icon`),y=l(`image-preview`),b=l(`font-awesome-icon`),x=l(`el-button`),S=l(`el-upload`),C=l(`el-input`),w=l(`consumption`);return g(),s(`div`,qr,[e(`div`,Jr,[a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),e(`div`,Yr,[e(`div`,Xr,[e(`span`,Zr,i(t.$t(`kling.name.talkingPhotoImage`)),1),a(v,{content:t.$t(`kling.description.talkingPhotoImage`)},null,8,[`content`])]),a(S,{ref:`imageUploader`,"file-list":t.imageFiles,"onUpdate:fileList":n[0]||=e=>t.imageFiles=e,name:`file`,accept:`.png,.jpg,.jpeg,.webp,.bmp`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,headers:t.headers,"on-exceed":t.onImageExceed,"on-error":t.onImageError,"on-success":t.onImageSuccess},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(y,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.onImageRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(x,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(b,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`headers`,`on-exceed`,`on-error`,`on-success`])]),e(`div`,Qr,[e(`div`,$r,[e(`span`,ei,i(t.$t(`kling.name.talkingPhotoAudio`)),1),a(v,{content:t.$t(`kling.description.talkingPhotoAudio`)},null,8,[`content`])]),a(S,{ref:`audioUploader`,"file-list":t.audioFiles,"onUpdate:fileList":n[1]||=e=>t.audioFiles=e,name:`file`,accept:`.mp3,.wav,.m4a,.aac`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,headers:t.headers,"on-exceed":t.onAudioExceed,"on-error":t.onAudioError,"on-success":t.onAudioSuccess,"on-remove":t.onAudioRemove},{default:p(()=>[a(x,{round:``,type:`primary`,size:`small`,class:`btn`},{default:p(()=>[a(b,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadAudio`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`headers`,`on-exceed`,`on-error`,`on-success`,`on-remove`]),t.audioUrl?(g(),s(`audio`,{key:0,src:t.audioUrl,controls:``,class:`w-full mt-2`},null,8,ti)):o(``,!0)]),e(`div`,ni,[e(`div`,ri,[e(`span`,ii,i(t.$t(`kling.name.talkingPhotoPrompt`)),1),a(v,{content:t.$t(`kling.description.talkingPhotoPrompt`)},null,8,[`content`])]),a(C,{"model-value":t.config.prompt,type:`textarea`,rows:2,placeholder:t.$t(`kling.placeholder.talkingPhotoPrompt`),class:`mt-1`,"onUpdate:modelValue":t.onPromptChange},null,8,[`model-value`,`placeholder`,`onUpdate:modelValue`])])]),e(`div`,ai,[a(w,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),a(x,{type:`primary`,class:`btn w-full`,round:``,disabled:!t.canGenerate,onClick:t.onGenerate},{default:p(()=>[a(b,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.generateTalkingPhoto`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var si=z(Kr,[[`render`,oi],[`__scopeId`,`data-v-27261e35`]]),ci=v({name:`TaskPreview`,components:{ElImage:E,CopyToClipboard:le,FontAwesomeIcon:G,ElAlert:ee,VideoPlayer:me,ElTooltip:T,ElButton:U,ImagePreview:K,ApiCodeButton:he},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.kling?.application},config(){return this.$store.state.kling?.config},referenceImages(){let e=[],t=this.modelValue?.request?.start_image_url,n=this.modelValue?.request?.end_image_url;return t&&e.push({url:t,name:`start-image`}),n&&e.push({url:n,name:`end-image`}),e}},methods:{onDownload(e,t){e?.stopPropagation(),console.log(`on download`),window.open(t,`_blank`)},onOpenVideo(e){window.open(e,`_blank`)}}}),li={class:`preview`},ui={class:`left`},di={class:`main`},fi={class:`bot`},pi={class:`datetime`},mi={class:`info`},hi={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},gi={key:1,class:`prompt mt-2`},_i={key:0},vi={key:1},yi={key:0,class:n({content:!0,failed:!0})},bi={key:0,class:`mb-4`},xi={key:1,class:n({operations:!0,"mt-2":!0})},Si={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ci={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},wi={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ti={key:1,class:n({content:!0})},Ei={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Di={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Oi={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},ki={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ai={key:2,class:n({content:!0})},ji={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Mi={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Ni(t,n,u,d,m,_){let v=l(`el-image`),y=l(`image-preview`),b=l(`video-player`),x=l(`el-button`),S=l(`el-tooltip`),C=l(`api-code-button`),w=l(`font-awesome-icon`),T=l(`copy-to-clipboard`),E=l(`el-alert`);return g(),s(`div`,li,[e(`div`,ui,[a(v,{src:`https://cdn.acedata.cloud/qpbbbb.jpg`,class:`avatar`})]),e(`div`,di,[e(`div`,fi,[r(i(t.$t(`kling.name.klingBot`))+` `,1),e(`span`,pi,i(t.$dayjs.format(``+new Date(parseFloat((t.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,mi,[t.referenceImages.length>0?(g(),s(`div`,hi,[(g(!0),s(c,null,h(t.referenceImages,(e,t)=>(g(),f(y,{key:t,url:e.url,name:e.name,closable:!1},null,8,[`url`,`name`]))),128))])):o(``,!0),t.modelValue?.request?.prompt?(g(),s(`p`,gi,[r(i(t.modelValue?.request?.prompt)+` `,1),t.modelValue?.response?o(``,!0):(g(),s(`span`,_i,` - (`+i(t.$t(`kling.status.pending`))+`) `,1)),t.modelValue?.response?.state===`submitted`||t.modelValue?.response?.state===`processing`||t.modelValue?.response?.state===`pending`||t.modelValue?.response?.state===`completed`?(g(),s(`span`,vi,` - (`+i(t.$t(`kling.status.processing`))+`) `,1)):o(``,!0)])):o(``,!0)]),t.modelValue?.response?.success===!0?(g(),s(`div`,yi,[t.modelValue?.response.video_url?(g(),s(`div`,bi,[a(b,{src:t.modelValue?.response.video_url},null,8,[`src`])])):o(``,!0),t.modelValue?.response.success?(g(),s(`div`,xi,[a(S,{class:`box-item`,effect:`dark`,content:t.$t(`kling.message.downloadVideo`),placement:`top-start`},{default:p(()=>[t.modelValue?.response.video_url?(g(),f(x,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:n[0]||=e=>t.onDownload(e,t.modelValue?.response.video_url)},{default:p(()=>[r(i(t.$t(`kling.button.download`)),1)]),_:1})):o(``,!0)]),_:1},8,[`content`]),a(C,{path:`/kling/videos`,body:t.modelValue?.request},null,8,[`body`])])):o(``,!0),a(E,{closable:!1,class:`mt-2 success`},{default:p(()=>[e(`p`,Si,[a(w,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.model`))+`: `+i(t.modelValue?.request?.model),1)]),e(`p`,Ci,[a(w,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.taskId`))+`: `+i(t.modelValue?.id)+` `,1),a(T,{content:t.modelValue?.id},null,8,[`content`])]),t.modelValue?.elapsed?(g(),s(`p`,wi,[a(w,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.elapsed`))+`: `+i(t.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0)]),_:1})])):o(``,!0),t.modelValue?.response?.success===!1?(g(),s(`div`,Ti,[a(E,{closable:!1,class:`failure`},{template:p(()=>[a(w,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.failure`)),1)]),default:p(()=>[e(`p`,Ei,[a(w,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.taskId`))+`: `+i(t.modelValue?.id)+` `,1),a(T,{content:t.modelValue?.id},null,8,[`content`])]),e(`p`,Di,[a(w,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.failureReason`))+`: `+i(t.modelValue?.response?.error?.message)+` `,1),a(T,{content:t.modelValue?.response?.error?.message},null,8,[`content`])]),t.modelValue?.elapsed?(g(),s(`p`,Oi,[a(w,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.elapsed`))+`: `+i(t.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),t.modelValue?.response?.trace_id?(g(),s(`p`,ki,[a(w,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.traceId`))+`: `+i(t.modelValue?.response?.trace_id)+` `,1),a(T,{content:t.modelValue?.response?.trace_id},null,8,[`content`])])):o(``,!0)]),_:1})])):o(``,!0),t.modelValue?.response?.success===void 0?(g(),s(`div`,Ai,[a(E,{closable:!1,class:`info`},{template:p(()=>[a(w,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.failure`)),1)]),default:p(()=>[e(`p`,ji,[a(w,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.taskId`))+`: `+i(t.modelValue?.id)+` `,1),a(T,{content:t.modelValue?.id},null,8,[`content`])]),t.modelValue?.response?.trace_id?(g(),s(`p`,Mi,[a(w,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.traceId`))+`: `+i(t.modelValue?.response?.trace_id)+` `,1),a(T,{content:t.modelValue?.response?.trace_id},null,8,[`content`])])):o(``,!0)]),_:1})])):o(``,!0)])])}var Pi=v({name:`RecentPanel`,components:{TaskPreview:z(ci,[[`render`,Ni],[`__scopeId`,`data-v-c36bfd7f`]]),NoTasks:_e,BotPlaceholder:ge,ScrollList:fe},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.kling?.tasks,items:this.$store.state.kling?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Fi={key:0},Ii={key:2,class:`w-full h-full flex items-center justify-center`};function Li(e,t,n,r,i,u){let d=l(`bot-placeholder`),m=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return g(),s(c,null,[e.tasks?.items===void 0?(g(),s(`div`,Fi,[a(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(g(),f(_,{key:1,ref:`scrollList`,class:`h-full w-full overflow-y-auto tasks`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:p(()=>[(g(!0),s(c,null,h(e.tasks?.items,e=>(g(),f(m,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(g(),s(`div`,Ii,[a(v)])):o(``,!0)],64)}var Ri=v({name:`KlingIndex`,components:{ConfigPanel:jn,MotionPanel:Ar,TalkingPhotoPanel:si,TabSwitcher:Fr,Layout:we,RecentPanel:z(Pi,[[`render`,Li]])},mixins:[oe],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.kling?.status?.getApplications===ce.Request},tasksLoading(){return this.$store.state.kling?.status?.getTasks===ce.Request||this.fetchingTasks},credential(){return this.$store.state.kling.credential},config(){return this.$store.state.kling.config},motionConfig(){return this.$store.state.kling.motionConfig},talkingPhotoConfig(){return this.$store.state.kling.talkingPhotoConfig},taskType(){return this.$store.state.kling.taskType||`videos`},tasks(){return this.$store.state.kling.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 pe({tasks: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(`kling/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`kling/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(`kling/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!F(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let{camera_control:e,...t}=this.config||{},n={...t,async:!0};if(!n.video_id&&!t.video_url&&!n.start_image_url&&n.end_image_url){V.warning(this.$t(`kling.message.endImageRequiresStart`));return}if(n.action||(n.video_id||t.video_url?n.action=`extend`:n.start_image_url?n.action=`image2video`:n.action=`text2video`),n.action===`text2video`&&n.end_image_url&&delete n.end_image_url,e?.type&&(n.camera_control={type:e.type,...e.type===`simple`&&e.config?{config:Object.fromEntries(Object.entries(e.config).filter(([,e])=>e!=null))}:{}}),!R())return;let r=this.credential?.token;if(!r){console.error(`no token specified`);return}V.info(this.$t(`kling.message.startingTask`)),H(`kling`,W.generate(n,{token:r})).then(()=>{V.success(this.$t(`kling.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?V.error(this.$t(`kling.message.usedUp`)):V.error(this.$t(`kling.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()},async onTabChange(e){e!==this.taskType&&(await this.$store.dispatch(`kling/setTaskType`,e),await this.onGetTasks(),await this.onScrollDown())},async onGenerateMotion(){if(!F(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let e=this.motionConfig||{};if(!e.image_url||!e.video_url){V.warning(this.$t(`kling.message.motionMissingInputs`));return}let t={image_url:e.image_url,video_url:e.video_url,character_orientation:e.character_orientation||`video`,mode:e.mode||`std`,keep_original_sound:e.keep_original_sound??`yes`,...e.model_name?{model_name:e.model_name}:{},...e.prompt?{prompt:e.prompt}:{},async:!0};if(!R())return;let n=this.credential?.token;if(!n){console.error(`no token specified`);return}V.info(this.$t(`kling.message.startingTask`)),H(`kling`,W.motion(t,{token:n})).then(()=>{V.success(this.$t(`kling.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?V.error(this.$t(`kling.message.usedUp`)):V.error(this.$t(`kling.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},async onGenerateTalkingPhoto(){if(!F(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let e=this.talkingPhotoConfig||{};if(!e.image_url||!e.audio_url){V.warning(this.$t(`kling.message.talkingPhotoMissingInputs`));return}let t={image_url:e.image_url,audio_url:e.audio_url,model:e.model||`kling-v2-1-master`,mode:e.mode||`pro`,...e.prompt?{prompt:e.prompt}:{},...e.duration?{duration:e.duration}:{},async:!0};if(!R())return;let n=this.credential?.token;if(!n){console.error(`no token specified`);return}V.info(this.$t(`kling.message.startingTask`)),H(`kling`,W.talkingPhoto(t,{token:n})).then(()=>{V.success(this.$t(`kling.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?V.error(this.$t(`kling.message.usedUp`)):V.error(this.$t(`kling.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}}),zi={class:`flex flex-col h-full`},Bi={class:`flex-1 min-h-0`};function Vi(t,n,r,i,s,c){let u=l(`tab-switcher`),d=l(`config-panel`),m=l(`motion-panel`),h=l(`talking-photo-panel`),_=l(`recent-panel`),v=l(`layout`);return g(),f(v,null,{config:p(()=>[e(`div`,zi,[a(u,{"model-value":t.taskType,"onUpdate:modelValue":t.onTabChange},null,8,[`model-value`,`onUpdate:modelValue`]),e(`div`,Bi,[t.taskType===`videos`?(g(),f(d,{key:0,onGenerate:t.onGenerate},null,8,[`onGenerate`])):t.taskType===`motion`?(g(),f(m,{key:1,onGenerate:t.onGenerateMotion},null,8,[`onGenerate`])):t.taskType===`talking-photo`?(g(),f(h,{key:2,onGenerate:t.onGenerateTalkingPhoto},null,8,[`onGenerate`])):o(``,!0)])])]),result:p(()=>[a(_,{ref:`recentPanel`,loading:t.loadingMore,onReachTop:t.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var Hi=z(Ri,[[`render`,Vi]]);export{Hi as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,ht as u,it as d,j as f,mt as p,qt as m,rt as h,tt as g,x as _,z as v}from"./vendor-chart-Dw-P17PN.js";import{E as y}from"./use-deprecated-B-uvyrTL.js";import{r as b,t as x}from"./select-B0Rytq57.js";import{n as S,t as C}from"./tabs-B_Vz5BEf.js";import{t as w}from"./upload-CKPXpkhw.js";import{t as T}from"./tooltip-DMkRuyNr.js";import{t as E}from"./image-C_wGl_Tq.js";import{t as ee}from"./alert-9UHbWOgh.js";import{n as D,r as O}from"./radio-Bj0tEwH8.js";import{t as k}from"./drawer-BhyqFLuj.js";import{t as A}from"./input-number-BqS9Kh4f.js";import{t as te}from"./slider-B0zBUesv.js";import{t as ne}from"./switch-C_iujXz0.js";import{Qr as re,ni as ie,ri as j,ti as ae}from"./constants-Cm1pJ8kP.js";import{Di as M,Ht as N,Kt as P,Ut as oe,Vt as F,Wt as I,Xr as L,en as R,gi as se,j as z,oi as B,qr as ce,si as V,sr as H,vi as U,zn as W}from"./index-CEsOXc02.js";import{t as G}from"./index.es-CZ18ogLi.js";import{t as le}from"./CopyToClipboard-BDHrbE9N.js";import{t as ue}from"./FilePreview-L3brxpd6.js";import{t as K}from"./ImagePreview-CBJ5UBky.js";import{n as de}from"./taskDrawerMixin-DyAUhFEq.js";import{t as q}from"./Consumption-0ipkiA5W.js";import{i as J,n as fe,t as pe}from"./pagination-UvuFCwzm.js";import{t as me}from"./VideoPlayer-CUG8KpLW.js";import{t as he}from"./ApiCodeButton-WbUyGTD7.js";import{t as ge}from"./BotPlaceholder-DeEtrFs6.js";import{t as _e}from"./NoTasks-CF_GuqSx.js";import{t as ve}from"./PromptTextarea-JRe0Kgab.js";var ye=v({name:`LayoutKling`,components:{ElDrawer:k,ElButton:U,FontAwesomeIcon:G},mixins:[de]}),be={class:`main flex flex-row flex-1 min-h-0`},xe={class:`config w-[320px] flex-none h-full flex flex-col bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},Se={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function Ce(t,n,r,i,o,c){let f=l(`font-awesome-icon`),m=l(`el-button`),h=l(`el-drawer`);return g(),s(`div`,be,[e(`div`,xe,[d(t.$slots,`config`,{},void 0,!0)]),e(`div`,Se,[d(t.$slots,`result`,{},void 0,!0)]),u(a(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:p(()=>[a(f,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!t.tasksEmpty]]),a(h,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`350px`},{default:p(()=>[d(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var we=z(ye,[[`render`,Ce],[`__scopeId`,`data-v-b87958dc`]]),Te={text2video:!0,image2video:!0,endImage:!1,audio:!1,motionControl:!1};function Y(e,t,n){let r=t||`std`,i=n??5;switch(e){case`kling-v1`:return{text2video:!0,image2video:!0,endImage:i===5,audio:!1,motionControl:i===5};case`kling-v1-6`:case`kling-v2-5-turbo`:return{text2video:!0,image2video:!0,endImage:r===`pro`,audio:!1,motionControl:!1};case`kling-v2-6`:return{text2video:!0,image2video:!0,endImage:r===`pro`,audio:r===`pro`,motionControl:!1};case`kling-v2-master`:case`kling-v2-1-master`:return{text2video:!0,image2video:!0,endImage:!1,audio:!1,motionControl:!1};case`kling-v3`:return{text2video:!0,image2video:!0,endImage:!0,audio:!0,motionControl:r!==`4k`};case`kling-v3-omni`:return{text2video:!0,image2video:!0,endImage:!0,audio:!0,motionControl:!1};case`kling-video-o1`:return{text2video:!0,image2video:!0,endImage:!0,audio:!1,motionControl:!1};default:return Te}}function X(e,t){if(!e)return[];let n=t.model??e.model,r=t.mode??e.mode,i=t.duration??e.duration;if(!n)return[];let a=Y(n,r,i),o=[];return e.end_image_url&&!a.endImage&&o.push({field:`end_image_url`,i18nLabel:`kling.name.endImage`}),e.generate_audio&&!a.audio&&o.push({field:`generate_audio`,i18nLabel:`kling.name.generateAudio`}),e.camera_control?.type&&(!a.motionControl||e.start_image_url)&&o.push({field:`camera_control`,i18nLabel:`kling.name.cameraControl`}),o}function Z(e,t){let n={...e};for(let e of t)e.field===`end_image_url`&&(n.end_image_url=void 0),e.field===`generate_audio`&&(n.generate_audio=!1),e.field===`camera_control`&&(n.camera_control=void 0);return n}var Ee=v({name:`ModelSelector`,components:{ElSelect:b,ElOption:x},props:{modelValue:{type:String,default:void 0}},emits:[`update:modelValue`],data(){return{revertKey:0,options:[{value:`kling-v3`,label:`v3`},{value:`kling-v3-omni`,label:`v3-Omni`},{value:`kling-v2-6`,label:`v2.6`},{value:`kling-v2-5-turbo`,label:`v2.5-Turbo`},{value:`kling-v2-1-master`,label:`v2.1-Master`},{value:`kling-v2-master`,label:`v2-Master`},{value:`kling-v1-6`,label:`v1.6`},{value:`kling-v1`,label:`v1`},{value:`kling-video-o1`,label:`Video-o1`}]}},computed:{value(){return this.$store.state.kling?.config?.model}},mounted(){this.value||this.applyModel(re)},methods:{async onChange(e){let t=this.$store.state.kling?.config||{},n=X(t,{model:e});if(n.length===0){this.applyModel(e);return}let r=n.map(e=>this.$t(e.i18nLabel)).join(`、`);try{await B.confirm(this.$t(`kling.message.featureNotSupportedBody`,{fields:r}),this.$t(`kling.message.featureNotSupportedTitle`),{confirmButtonText:this.$t(`kling.button.confirmContinue`),cancelButtonText:this.$t(`kling.button.cancelSwitch`),type:`warning`});let i=Z({...t,model:e},n);this.$store.commit(`kling/setConfig`,i),V.success(this.$t(`kling.message.featureRemovedNotice`,{fields:r}))}catch{this.revertKey+=1}},applyModel(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling.config,model:e})}}}),De={class:`field`},Oe={class:`title font-bold`};function ke(t,n,r,a,o,u){let d=l(`el-option`),m=l(`el-select`);return g(),s(`div`,De,[e(`h2`,Oe,i(t.$t(`pika.name.model`)),1),(g(),f(m,{key:t.revertKey,"model-value":t.value,class:`value`,placeholder:t.$t(`pika.placeholder.select`),onChange:t.onChange},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(d,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`model-value`,`placeholder`,`onChange`]))])}var Ae=z(Ee,[[`render`,ke],[`__scopeId`,`data-v-04059875`]]),je=v({name:`ModeSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},props:{modelValue:{type:String,default:void 0}},emits:[`update:modelValue`],data(){return{revertKey:0}},computed:{selectedModel(){return this.$store.state.kling?.config?.model||``},cameraControlSet(){return!!this.$store.state.kling?.config?.camera_control?.type},fourKReason(){return j.includes(this.selectedModel)?this.cameraControlSet?this.$t(`kling.description.mode4kIncompatibleCamera`):``:this.$t(`kling.description.mode4kRequiresV3`)},options(){return[{value:`std`,label:this.$t(`kling.name.modeStd`),disabled:!1,disabledReason:``},{value:`pro`,label:this.$t(`kling.name.modePro`),disabled:!1,disabledReason:``},{value:`4k`,label:this.$t(`kling.name.mode4k`),disabled:!!this.fourKReason,disabledReason:this.fourKReason}]},value(){return this.$store.state.kling?.config?.mode}},watch:{fourKReason(e){e&&this.value===`4k`&&this.applyMode(`std`)}},mounted(){this.value||this.applyMode(`std`)},methods:{async onChange(e){let t=this.$store.state.kling?.config||{},n=X(t,{mode:e});if(n.length===0){this.applyMode(e);return}let r=n.map(e=>this.$t(e.i18nLabel)).join(`、`);try{await B.confirm(this.$t(`kling.message.featureNotSupportedBody`,{fields:r}),this.$t(`kling.message.featureNotSupportedTitle`),{confirmButtonText:this.$t(`kling.button.confirmContinue`),cancelButtonText:this.$t(`kling.button.cancelSwitch`),type:`warning`});let i=Z({...t,mode:e},n);this.$store.commit(`kling/setConfig`,i),V.success(this.$t(`kling.message.featureRemovedNotice`,{fields:r}))}catch{this.revertKey+=1}},applyMode(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling.config,mode:e})}}}),Me={class:`field`},Ne={class:`header`},Pe={class:`title font-bold`},Fe={key:0,class:`opt-tip`};function Ie(t,r,u,d,m,_){let v=l(`info-icon`),y=l(`el-option`),b=l(`el-select`);return g(),s(`div`,Me,[e(`div`,Ne,[e(`h2`,Pe,i(t.$t(`kling.name.mode`)),1),a(v,{content:t.$t(`kling.description.mode`),class:`info-icon`},null,8,[`content`])]),(g(),f(b,{key:t.revertKey,"model-value":t.value,class:`value`,placeholder:t.$t(`kling.placeholder.select`),clearable:!0,onChange:t.onChange},{default:p(()=>[(g(!0),s(c,null,h(t.options,t=>(g(),f(y,{key:t.value,label:t.label,value:t.value,disabled:t.disabled},{default:p(()=>[e(`span`,{class:n({"opt-disabled":t.disabled})},i(t.label),3),t.disabled&&t.disabledReason?(g(),s(`span`,Fe,i(t.disabledReason),1)):o(``,!0)]),_:2},1032,[`label`,`value`,`disabled`]))),128))]),_:1},8,[`model-value`,`placeholder`,`onChange`]))])}var Le=z(je,[[`render`,Ie],[`__scopeId`,`data-v-9a8fa3c5`]]),Re=[3,5,8,10,12,15],ze=[5,10],Be=v({name:`DurationSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},data(){return{revertKey:0}},computed:{selectedModel(){return this.$store.state.kling?.config?.model||``},isV3Model(){return j.includes(this.selectedModel)},allowedDurations(){return this.isV3Model?Re:ze},value(){return this.$store.state.kling?.config?.duration??5},selectValue(){let e=this.allowedDurations;return e.includes(this.value)?this.value:e.includes(5)?5:e[0]}},watch:{isV3Model(){this.allowedDurations.includes(this.value)||this.applyDuration(5)}},mounted(){this.$store.state.kling?.config?.duration||this.applyDuration(5)},methods:{async onChange(e){let t=this.$store.state.kling?.config||{},n=X(t,{duration:e});if(n.length===0){this.applyDuration(e);return}let r=n.map(e=>this.$t(e.i18nLabel)).join(`、`);try{await B.confirm(this.$t(`kling.message.featureNotSupportedBody`,{fields:r}),this.$t(`kling.message.featureNotSupportedTitle`),{confirmButtonText:this.$t(`kling.button.confirmContinue`),cancelButtonText:this.$t(`kling.button.cancelSwitch`),type:`warning`});let i=Z({...t,duration:e},n);this.$store.commit(`kling/setConfig`,i),V.success(this.$t(`kling.message.featureRemovedNotice`,{fields:r}))}catch{this.revertKey+=1}},applyDuration(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling.config,duration:e})}}}),Ve={class:`field`},He={class:`control`},Ue={class:`label`},We={class:`title font-bold`};function Ge(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,Ve,[e(`div`,He,[e(`div`,Ue,[e(`h2`,We,i(t.$t(`kling.name.duration`)),1),a(m,{content:t.$t(`kling.description.duration`),class:`info-icon ml-1`},null,8,[`content`])]),(g(),f(v,{key:t.revertKey,"model-value":t.selectValue,class:`value`,placeholder:t.$t(`kling.placeholder.select`),onChange:t.onChange},{default:p(()=>[(g(!0),s(c,null,h(t.allowedDurations,e=>(g(),f(_,{key:e,label:`${e}s`,value:e},null,8,[`label`,`value`]))),128))]),_:1},8,[`model-value`,`placeholder`,`onChange`]))])])}var Ke=z(Be,[[`render`,Ge],[`__scopeId`,`data-v-5ae55e28`]]),qe=v({name:`RatioSelector`,data(){return{options:[{value:`1:1`,label:`1:1`,width:20,height:20},{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?.kling?.config?.aspect_ratio},set(e){console.debug(`set ratio`,e),this.$store.commit(`kling/setConfig`,{...this.$store.state?.kling?.config,aspect_ratio:e})}}},mounted(){this.value||=`1:1`}}),Je={class:`text-sm font-bold mb-2 block`},Ye={class:`items`},Xe=[`onClick`],Ze={class:`name`};function Qe(t,r,a,o,l,u){return g(),s(`div`,null,[e(`span`,Je,i(t.$t(`kling.name.ratio`)),1),e(`div`,Ye,[(g(!0),s(c,null,h(t.options,(r,a)=>(g(),s(`div`,{key:a,class:n({active:t.active===a,item:!0}),onClick:e=>t.value=r.value},[e(`div`,{class:n([`preview`,r.label])},[e(`div`,{class:`rect`,style:m({width:r.width+`px`,height:r.height+`px`})},null,4)],2),e(`p`,Ze,i(r.label),1)],10,Xe))),128))])])}var $e=z(qe,[[`render`,Qe],[`__scopeId`,`data-v-cdb14b2f`]]),et=v({name:`StartImage`,components:{ElUpload:w,ElButton:U,ElTooltip:T,InfoIcon:J,FontAwesomeIcon:G,ImagePreview:K},mixins:[I,N],emits:[`change`],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},reachedLimit(){return(this.fileList?.length||0)>=1},value:{get(){return this.$store.state?.kling?.config?.start_image_url},set(){}}},mounted(){this.value||=void 0,this.onSetStartImageUrl()},methods:{onExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onSetStartImageUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setConfig`,{...this.$store.state?.kling?.config,start_image_url:e})},async onSuccess(){this.onSetStartImageUrl()}}}),tt={class:`relative`},nt={class:`flex justify-between`},rt={class:`flex justify-start items-center`},it={class:`text-sm font-bold`};function at(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`el-upload`);return g(),s(`div`,tt,[e(`div`,nt,[e(`div`,rt,[e(`span`,it,i(t.$t(`kling.name.startImage`)),1),a(h,{content:t.$t(`kling.description.uploadStartImage`)},null,8,[`content`])])]),a(x,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,disabled:t.reachedLimit,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(b,{content:t.$t(`kling.message.uploadReferencesExceed`),disabled:!t.reachedLimit,placement:`top`},{default:p(()=>[e(`span`,null,[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`,disabled:t.reachedLimit},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1},8,[`disabled`])])]),_:1},8,[`content`,`disabled`])]),_:1},8,[`file-list`,`disabled`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var ot=z(et,[[`render`,at],[`__scopeId`,`data-v-756dc269`]]),st=v({name:`EndImage`,components:{ElUpload:w,ElButton:U,ElTooltip:T,ImagePreview:K,InfoIcon:J,FontAwesomeIcon:G},mixins:[I,N],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)},reachedLimit(){return(this.fileList?.length||0)>=1},klingConfig(){return this.$store.state?.kling?.config||{}},endImageSupported(){return Y(this.klingConfig.model,this.klingConfig.mode,this.klingConfig.duration).endImage},hasStartImage(){return!!this.klingConfig.start_image_url},uploadDisabled(){return this.reachedLimit||!this.endImageSupported||!this.hasStartImage},uploadTooltip(){return this.endImageSupported?this.hasStartImage?this.reachedLimit?this.$t(`kling.message.uploadReferencesExceed`):``:this.$t(`kling.message.endImageRequiresStart`):this.$t(`kling.message.endImageNotSupported`)},storeValue(){return this.klingConfig.end_image_url},value:{get(){return this.storeValue},set(){}}},watch:{storeValue(e){!e&&this.fileList.length>0&&(this.fileList=[])},hasStartImage(e){!e&&this.storeValue&&(this.fileList=[],this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,end_image_url:void 0}))}},mounted(){this.value||=void 0,this.onSetEndImageUrl()},methods:{onBeforeUpload(){return this.endImageSupported?this.hasStartImage?!0:(V.warning(this.$t(`kling.message.endImageRequiresStart`)),!1):(V.warning(this.$t(`kling.message.endImageNotSupported`)),!1)},onExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onSetEndImageUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,end_image_url:e})},async onSuccess(){this.onSetEndImageUrl()}}}),ct={class:`relative`},lt={class:`flex justify-between`},ut={class:`flex justify-start items-center`},dt={class:`text-sm font-bold`};function ft(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-tooltip`),x=l(`el-upload`);return g(),s(`div`,ct,[e(`div`,lt,[e(`div`,ut,[e(`span`,dt,i(t.$t(`kling.name.endImage`)),1),a(h,{content:t.$t(`kling.description.uploadEndImage`)},null,8,[`content`])])]),a(x,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,disabled:t.uploadDisabled,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"before-upload":t.onBeforeUpload,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(b,{content:t.uploadTooltip,disabled:!t.uploadDisabled,placement:`top`},{default:p(()=>[e(`span`,null,[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`,disabled:t.uploadDisabled},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1},8,[`disabled`])])]),_:1},8,[`content`,`disabled`])]),_:1},8,[`file-list`,`disabled`,`action`,`before-upload`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var pt=z(st,[[`render`,ft],[`__scopeId`,`data-v-c1b257e5`]]),mt=v({name:`CfgScaleSelector`,components:{ElSlider:te,InfoIcon:J,ElInputNumber:A},computed:{value:{get(){return this.$store.state?.kling?.config?.cfg_scale},set(e){console.debug(`set cfg_scale`,e),this.$store.commit(`kling/setConfig`,{...this.$store.state?.kling?.config,cfg_scale:e})}}},mounted(){this.value||=0}}),ht={class:`flex justify-between`},gt={class:`flex justify-start items-center`},_t={class:`text-sm font-bold`},vt={class:`flex justify-end items-center`},yt={class:`w-full`};function bt(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-input-number`),p=l(`el-slider`);return g(),s(`div`,null,[e(`div`,ht,[e(`div`,gt,[e(`span`,_t,i(t.$t(`kling.name.cfgScale`)),1),a(d,{content:t.$t(`kling.description.cfgScale`)},null,8,[`content`])]),e(`div`,vt,[a(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,"controls-position":`right`},null,8,[`modelValue`])])]),e(`div`,yt,[a(p,{modelValue:t.value,"onUpdate:modelValue":n[1]||=e=>t.value=e,min:0,max:1,step:.1},null,8,[`modelValue`])])])}var xt=z(mt,[[`render`,bt]]),St=v({name:`GenerateAudioSelector`,components:{ElSwitch:ne,InfoIcon:J},computed:{selectedModel(){return this.$store.state.kling?.config?.model||``},selectedMode(){return this.$store.state.kling?.config?.mode||``},supported(){return!!(j.includes(this.selectedModel)||this.selectedModel===`kling-v2-6`&&this.selectedMode===`pro`)},tooltipContent(){return this.supported?this.$t(`kling.description.generateAudio`):this.$t(`kling.description.generateAudioUnsupported`)},value:{get(){return this.supported?this.$store.state.kling?.config?.generate_audio??!1:!1},set(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,generate_audio:e})}}},watch:{supported(e){!e&&this.$store.state.kling?.config?.generate_audio&&this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,generate_audio:!1})}}}),Ct={class:`relative`},wt={class:`flex justify-between items-center`},Tt={class:`flex justify-start items-center`},Et={class:`text-sm font-bold`};function Dt(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-switch`);return g(),s(`div`,Ct,[e(`div`,wt,[e(`div`,Tt,[e(`span`,Et,i(t.$t(`kling.name.generateAudio`)),1),a(d,{content:t.tooltipContent},null,8,[`content`])]),a(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,disabled:!t.supported},null,8,[`modelValue`,`disabled`])])])}var Ot=z(St,[[`render`,Dt]]),kt=[`horizontal`,`vertical`,`pan`,`tilt`,`roll`,`zoom`],At=v({name:`CameraControlSelector`,components:{ElSelect:b,ElOption:x,ElSlider:te,ElInputNumber:A,InfoIcon:J},data(){return{configKeys:kt}},computed:{typeOptions(){return[{value:``,label:this.$t(`kling.name.cameraTypeNone`)},{value:`simple`,label:this.$t(`kling.name.cameraTypeSimple`)},{value:`down_back`,label:this.$t(`kling.name.cameraTypeDownBack`)},{value:`forward_up`,label:this.$t(`kling.name.cameraTypeForwardUp`)},{value:`left_turn_forward`,label:this.$t(`kling.name.cameraTypeLeftTurnForward`)},{value:`right_turn_forward`,label:this.$t(`kling.name.cameraTypeRightTurnForward`)}]},selectedMode(){return this.$store.state.kling?.config?.mode||``},selectedModel(){return this.$store.state.kling?.config?.model||``},selectedDuration(){return this.$store.state.kling?.config?.duration},motionControlSupported(){return Y(this.selectedModel,this.selectedMode,this.selectedDuration).motionControl},hasStartImage(){return!!this.$store.state.kling?.config?.start_image_url},disabled(){return!this.motionControlSupported||this.hasStartImage},tooltipContent(){return this.motionControlSupported?this.hasStartImage?this.$t(`kling.description.cameraControlDisabledImage2Video`):this.$t(`kling.description.cameraControl`):this.$t(`kling.description.cameraControlNotSupported`)},selectedType(){return this.$store.state.kling?.config?.camera_control?.type},selectedTypeRaw:{get(){return this.selectedType??``},set(e){let t=this.$store.state.kling?.config||{};if(!e){let e={...t};delete e.camera_control,this.$store.commit(`kling/setConfig`,e);return}let n=e;this.$store.commit(`kling/setConfig`,{...t,camera_control:{type:n,config:n===`simple`?t.camera_control?.config||{}:void 0}})}},configValues(){return this.$store.state.kling?.config?.camera_control?.config||{}}},watch:{disabled(e){e&&this.selectedType!==void 0&&(this.selectedTypeRaw=``)}},methods:{writeConfig(e,t){let n=this.$store.state.kling?.config||{},r=n.camera_control||{type:`simple`},i={...r.config||{}};t==null?delete i[e]:i[e]=t,this.$store.commit(`kling/setConfig`,{...n,camera_control:{...r,type:`simple`,config:i}})},onSliderChange(e,t){this.writeConfig(e,t)},onNumberChange(e,t){this.writeConfig(e,t)}}}),jt={class:`field`},Mt={class:`header`},Nt={class:`text-sm font-bold`},Pt={key:0,class:`config-grid`},Ft={class:`cfg-row-head`},It={class:`cfg-name`};function Lt(t,n,r,u,d,m){let _=l(`info-icon`),v=l(`el-option`),y=l(`el-select`),b=l(`el-input-number`),x=l(`el-slider`);return g(),s(`div`,jt,[e(`div`,Mt,[e(`span`,Nt,i(t.$t(`kling.name.cameraControl`)),1),a(_,{content:t.tooltipContent},null,8,[`content`])]),a(y,{modelValue:t.selectedTypeRaw,"onUpdate:modelValue":n[0]||=e=>t.selectedTypeRaw=e,class:`value`,placeholder:t.$t(`kling.placeholder.cameraType`),clearable:!0,disabled:t.disabled},{default:p(()=>[(g(!0),s(c,null,h(t.typeOptions,e=>(g(),f(v,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`disabled`]),t.selectedType===`simple`&&!t.disabled?(g(),s(`div`,Pt,[(g(!0),s(c,null,h(t.configKeys,n=>(g(),s(`div`,{key:n,class:`cfg-row`},[e(`div`,Ft,[e(`span`,It,i(t.$t(`kling.name.cc_${n}`)),1),a(b,{modelValue:t.configValues[n],"onUpdate:modelValue":e=>t.configValues[n]=e,min:-1,max:1,step:.1,precision:1,"controls-position":`right`,size:`small`,class:`cfg-num`,onChange:e=>t.onNumberChange(n,e)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])]),a(x,{"model-value":t.configValues[n]??0,min:-1,max:1,step:.1,onInput:e=>t.onSliderChange(n,e)},null,8,[`model-value`,`onInput`])]))),128))])):o(``,!0)])}var Rt=z(At,[[`render`,Lt],[`__scopeId`,`data-v-cd896060`]]),zt=[{groupKey:`cameraMovements`,chipKeys:[`rotateAround`,`stationary`,`handheld`,`zoomOut`,`zoomIn`,`follow`,`panRight`,`tiltUp`,`tiltDown`,`orbit`]},{groupKey:`cameraSpeed`,chipKeys:[`speedSlow`,`speedMedium`,`speedFast`]},{groupKey:`shotType`,chipKeys:[`shotClose`,`shotMedium`,`shotLong`,`shotLowAngle`,`shotHighAngle`,`shotShallowDof`,`shotFront`,`shotProfile`,`shotCloseUp`,`shotDrone`]},{groupKey:`light`,chipKeys:[`lightSunlight`,`lightSoft`,`lightNeon`,`lightWarm`,`lightNature`,`lightCandle`,`lightCityNight`]},{groupKey:`frame`,chipKeys:[`frameRichDetails`,`frameSimpleBg`]},{groupKey:`atmosphere`,chipKeys:[`atmosphereMysterious`,`atmospherePeaceful`,`atmosphereHeartwarming`,`atmosphereVivid`,`atmosphereColorful`]}],Q=`, `;function Bt(e,t){let n=(e||``).trim();return n?n.includes(t)?n:`${n}${Q}${t}`:t}function $(e,t){if(!e||!t)return e||``;let n=[`${t}${Q}`,`${Q}${t}`,t],r=e;for(let e of n)if(r.includes(e)){r=r.replace(e,``);break}return r.replace(/(?:,\s*)+$/,``).replace(/^(?:,\s*)+/,``)}var Vt=v({name:`InspirationPills`,components:{FontAwesomeIcon:G},computed:{prompt(){return this.$store.state.kling?.config?.prompt||``},allChipTexts(){return zt.flatMap(e=>e.chipKeys.map(e=>this.$t(`kling.inspiration.chip.${e}`)))},selected(){let e=this.prompt;if(!e)return[];let t=[];for(let n of this.allChipTexts){let r=e.indexOf(n);r!==-1&&t.push({text:n,idx:r})}return t.sort((e,t)=>e.idx-t.idx).map(e=>e.text)}},methods:{onRemove(e){let t=$(this.prompt,e);this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,prompt:t})}}}),Ht={key:0,class:`pills`,role:`list`},Ut={class:`pill-text`},Wt=[`aria-label`,`onClick`];function Gt(n,r,u,d,f,p){let m=l(`font-awesome-icon`);return n.selected.length>0?(g(),s(`div`,Ht,[(g(!0),s(c,null,h(n.selected,r=>(g(),s(`div`,{key:r,class:`pill`,role:`listitem`},[e(`span`,Ut,i(r),1),e(`button`,{type:`button`,class:`pill-remove`,"aria-label":n.$t(`kling.inspiration.removeChip`),onClick:t(e=>n.onRemove(r),[`stop`])},[a(m,{icon:`fa-solid fa-xmark`})],8,Wt)]))),128))])):o(``,!0)}var Kt=v({name:`PromptInput`,components:{ElButton:U,FontAwesomeIcon:G,PromptTextarea:ve,InspirationPills:z(Vt,[[`render`,Gt],[`__scopeId`,`data-v-5fc4fa65`]])},emits:[`open-inspiration`],computed:{prompt:{get(){return this.$store.state.kling?.config?.prompt},set(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,prompt:e})}}},mounted(){this.prompt||=``}});function qt(e,t,n,o,s,c){let u=l(`font-awesome-icon`),d=l(`el-button`),m=l(`inspiration-pills`),h=l(`prompt-textarea`);return g(),f(h,{modelValue:e.prompt,"onUpdate:modelValue":t[1]||=t=>e.prompt=t,title:e.$t(`kling.name.prompt`),info:e.$t(`kling.description.prompt`),placeholder:e.$t(`kling.placeholder.prompt`)},{actions:p(()=>[a(d,{text:``,size:`small`,class:`inspiration-btn`,onClick:t[0]||=t=>e.$emit(`open-inspiration`)},{default:p(()=>[a(u,{icon:`fa-regular fa-lightbulb`,class:`mr-1`}),r(` `+i(e.$t(`kling.inspiration.openButton`)),1)]),_:1})]),before:p(()=>[a(m)]),_:1},8,[`modelValue`,`title`,`info`,`placeholder`])}var Jt=z(Kt,[[`render`,qt],[`__scopeId`,`data-v-c01fc1a6`]]),Yt=v({name:`NegativePromptInput`,components:{ElInput:M,InfoIcon:J},computed:{prompt:{get(){return this.$store.state.kling?.config?.negative_prompt},set(e){console.debug(`set prompt`,e),this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,negative_prompt:e})}}},mounted(){this.prompt||=``}}),Xt={class:`field`},Zt={class:`box`},Qt={class:`title font-bold`};function $t(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-input`);return g(),s(`div`,Xt,[e(`div`,Zt,[e(`h2`,Qt,i(t.$t(`kling.name.negativePrompt`)),1),a(d,{content:t.$t(`kling.description.negativePrompt`),class:`info`},null,8,[`content`])]),a(f,{modelValue:t.prompt,"onUpdate:modelValue":n[0]||=e=>t.prompt=e,rows:3,type:`textarea`,class:`prompt`,placeholder:t.$t(`kling.placeholder.negativePrompt`)},null,8,[`modelValue`,`placeholder`])])}var en=z(Yt,[[`render`,$t],[`__scopeId`,`data-v-de98cf01`]]),tn=v({name:`InspirationDrawer`,components:{ElDrawer:k,ElButton:U,FontAwesomeIcon:G},props:{modelValue:{type:Boolean,default:!1}},emits:[`update:modelValue`],data(){return{groups:zt,Close:y}},computed:{visible:{get(){return this.modelValue},set(e){this.$emit(`update:modelValue`,e)}},drawerSize(){return window.innerWidth<768?`100%`:`380px`},prompt(){return this.$store.state.kling?.config?.prompt||``},allChipTexts(){return this.groups.flatMap(e=>e.chipKeys.map(e=>this.$t(`kling.inspiration.chip.${e}`)))},selectedCount(){return this.allChipTexts.filter(e=>this.isSelected(e)).length}},methods:{chipText(e){return this.$t(`kling.inspiration.chip.${e}`)},isSelected(e){return e?this.prompt.includes(e):!1},setPrompt(e){this.$store.commit(`kling/setConfig`,{...this.$store.state.kling?.config,prompt:e})},onToggle(e){e&&(this.isSelected(e)?this.setPrompt($(this.prompt,e)):this.setPrompt(Bt(this.prompt,e)))},onClearSelected(){let e=this.prompt;for(let t of this.allChipTexts)for(;e.includes(t);)e=$(e,t);this.setPrompt(e)}}}),nn={class:`drawer-content`},rn={class:`drawer-header`},an={class:`title-row`},on={class:`title`},sn={class:`hint`},cn={key:0,class:`selected-bar`},ln={class:`selected-text`},un={class:`groups`},dn={class:`group-title`},fn={class:`chip-grid`},pn=[`onClick`];function mn(t,u,d,m,_,v){let y=l(`font-awesome-icon`),b=l(`el-button`),x=l(`el-drawer`);return g(),f(x,{modelValue:t.visible,"onUpdate:modelValue":u[1]||=e=>t.visible=e,direction:`rtl`,"with-header":!1,size:t.drawerSize,"custom-class":`kling-inspiration-drawer`,"destroy-on-close":!1},{default:p(()=>[e(`div`,nn,[e(`div`,rn,[e(`div`,an,[a(y,{icon:`fa-regular fa-lightbulb`,class:`mr-2`}),e(`span`,on,i(t.$t(`kling.inspiration.title`)),1)]),a(b,{text:``,icon:t.Close,class:`close-btn`,onClick:u[0]||=e=>t.visible=!1},null,8,[`icon`])]),e(`div`,sn,i(t.$t(`kling.inspiration.hint`)),1),t.selectedCount>0?(g(),s(`div`,cn,[e(`span`,ln,i(t.$t(`kling.inspiration.selectedSummary`,{count:t.selectedCount})),1),a(b,{text:``,size:`small`,class:`clear-btn`,onClick:t.onClearSelected},{default:p(()=>[r(i(t.$t(`kling.inspiration.clearSelected`)),1)]),_:1},8,[`onClick`])])):o(``,!0),e(`div`,un,[(g(!0),s(c,null,h(t.groups,r=>(g(),s(`div`,{key:r.groupKey,class:`group`},[e(`div`,dn,i(t.$t(`kling.inspiration.group.${r.groupKey}`)),1),e(`div`,fn,[(g(!0),s(c,null,h(r.chipKeys,e=>(g(),s(`button`,{key:e,type:`button`,class:n({chip:!0,active:t.isSelected(t.chipText(e))}),onClick:n=>t.onToggle(t.chipText(e))},i(t.chipText(e)),11,pn))),128))])]))),128))])])]),_:1},8,[`modelValue`,`size`])}var hn=z(tn,[[`render`,mn],[`__scopeId`,`data-v-7d457a69`]]),gn={"kling-v3":`v3`,"kling-v3-omni":`v3-Omni`,"kling-v2-6":`v2.6`,"kling-v2-5-turbo":`v2.5-Turbo`,"kling-v2-1-master":`v2.1-Master`,"kling-v2-master":`v2-Master`,"kling-v1-6":`v1.6`,"kling-v1":`v1`,"kling-video-o1":`Video-o1`},_n={std:`720p`,pro:`1080p`,"4k":`4K`},vn=v({name:`SummaryChip`,components:{FontAwesomeIcon:G},computed:{config(){return this.$store.state.kling?.config||{}},modelLabel(){let e=this.config?.model||`kling-v2-5-turbo`;return gn[e]||e},durationLabel(){return`${this.config?.duration??5}s`},aspectRatio(){return this.config?.aspect_ratio||``},modeLabel(){let e=this.config?.mode||`std`;return _n[e]||e},generateAudio(){return!!this.config?.generate_audio}}}),yn={class:`summary-chip`},bn=[`title`],xn=[`title`],Sn=[`title`],Cn=[`title`],wn=[`title`];function Tn(t,n,r,c,u,d){let f=l(`font-awesome-icon`);return g(),s(`div`,yn,[e(`span`,{class:`part`,title:t.$t(`kling.name.model`)},i(t.modelLabel),9,bn),n[0]||=e(`span`,{class:`dot`},`·`,-1),e(`span`,{class:`part`,title:t.$t(`kling.name.duration`)},i(t.durationLabel),9,xn),n[1]||=e(`span`,{class:`dot`},`·`,-1),e(`span`,{class:`part`,title:t.$t(`kling.name.ratio`)},i(t.aspectRatio||`16:9`),9,Sn),n[2]||=e(`span`,{class:`dot`},`·`,-1),e(`span`,{class:`part`,title:t.$t(`kling.name.mode`)},i(t.modeLabel),9,Cn),t.generateAudio?(g(),s(`span`,{key:0,class:`audio`,title:t.$t(`kling.name.generateAudio`)},[a(f,{icon:`fa-solid fa-headphones`})],8,wn)):o(``,!0)])}var En=v({name:`ConfigPanel`,components:{ElButton:U,Consumption:q,FontAwesomeIcon:G,PromptInput:Jt,NegativePromptInput:en,ModelSelector:Ae,ModeSelector:Le,DurationSelector:Ke,RatioSelector:$e,StartImage:ot,CfgScaleSelector:xt,GenerateAudioSelector:Ot,CameraControlSelector:Rt,InspirationDrawer:hn,SummaryChip:z(vn,[[`render`,Tn],[`__scopeId`,`data-v-418a6733`]]),EndImage:pt},emits:[`generate`],data(){return{inspirationOpen:!1}},computed:{config(){return this.$store.state.kling?.config},consumption(){return P(this.config,this.service?.cost)},service(){return this.$store.state.kling?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),Dn={class:`flex flex-col h-full`},On={class:`flex-1 overflow-y-auto p-5`},kn={class:`flex flex-col items-center justify-center px-5 pb-5`};function An(t,n,o,c,u,d){let m=l(`prompt-input`),h=l(`model-selector`),_=l(`ratio-selector`),v=l(`start-image`),y=l(`end-image`),b=l(`duration-selector`),x=l(`mode-selector`),S=l(`generate-audio-selector`),C=l(`camera-control-selector`),w=l(`cfg-scale-selector`),T=l(`negative-prompt-input`),E=l(`summary-chip`),ee=l(`consumption`),D=l(`font-awesome-icon`),O=l(`el-button`),k=l(`inspiration-drawer`);return g(),s(`div`,Dn,[e(`div`,On,[a(m,{class:`mb-4`,onOpenInspiration:n[0]||=e=>t.inspirationOpen=!0}),a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),a(v,{class:`mb-2`}),a(y,{class:`mb-2`}),a(b,{class:`mb-4`}),a(x,{class:`mb-4`}),a(S,{class:`mb-4`}),a(C,{class:`mb-4`}),a(w,{class:`mb-4`}),a(T,{class:`mb-4`})]),e(`div`,kn,[a(E),a(ee,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),t.config?.video_url!==void 0||t.config?.custom?(g(),f(O,{key:0,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(D,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.extend`)),1)]),_:1},8,[`onClick`])):(g(),f(O,{key:1,type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(D,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.generate`)),1)]),_:1},8,[`onClick`]))]),a(k,{modelValue:t.inspirationOpen,"onUpdate:modelValue":n[1]||=e=>t.inspirationOpen=e},null,8,[`modelValue`])])}var jn=z(En,[[`render`,An]]),Mn=v({name:`MotionImage`,components:{ElUpload:w,ElButton:U,InfoIcon:J,FontAwesomeIcon:G,ImagePreview:K},mixins:[I,N],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)}},mounted(){this.onSetImageUrl()},methods:{onExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onRemove(e){this.fileList.splice(this.fileList.indexOf(e),1),this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,image_url:void 0})},onSetImageUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,image_url:e})},async onSuccess(){this.onSetImageUrl()}}}),Nn={class:`relative`},Pn={class:`flex justify-between`},Fn={class:`flex justify-start items-center`},In={class:`text-sm font-bold`};function Ln(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-upload`);return g(),s(`div`,Nn,[e(`div`,Pn,[e(`div`,Fn,[e(`span`,In,i(t.$t(`kling.name.motionImage`)),1),a(h,{content:t.$t(`kling.description.motionImage`)},null,8,[`content`])])]),a(b,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.onRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var Rn=z(Mn,[[`render`,Ln],[`__scopeId`,`data-v-e52eaf2f`]]),zn=v({name:`MotionVideo`,components:{ElUpload:w,ElButton:U,InfoIcon:J,FilePreview:ue,FontAwesomeIcon:G},mixins:[N],data(){return{fileList:[],uploadUrl:L()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url)}},mounted(){this.onSetVideoUrl()},methods:{onExceed(){V.warning(this.$t(`kling.message.uploadVideoExceed`))},onError(){V.error(this.$t(`kling.message.uploadVideoError`))},onRemove(e){this.fileList.splice(this.fileList.indexOf(e),1),this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,video_url:void 0})},beforeUpload(e){let t=e.type===`video/mp4`||e.type===`video/quicktime`,n=e.size/1024/1024<100;return t?n?!0:(V.error(this.$t(`kling.message.uploadVideoSizeExceed`)),!1):(V.error(this.$t(`kling.message.uploadVideoTypeFailed`)),!1)},onSetVideoUrl(){let e=this.urls?.[0];this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,video_url:e})},async onSuccess(){this.onSetVideoUrl()}}}),Bn={class:`relative`},Vn={class:`flex justify-between`},Hn={class:`flex justify-start items-center`},Un={class:`text-sm font-bold`};function Wn(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`file-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-upload`);return g(),s(`div`,Bn,[e(`div`,Vn,[e(`div`,Hn,[e(`span`,Un,i(t.$t(`kling.name.motionVideo`)),1),a(h,{content:t.$t(`kling.description.motionVideo`)},null,8,[`content`])])]),a(b,{"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.mp4,.mov`,name:`file`,class:`value`,"show-file-list":!0,limit:1,multiple:!1,action:t.uploadUrl,"before-upload":t.beforeUpload,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,headers:t.headers},{file:p(({file:e})=>[e.percentage===void 0?o(``,!0):(g(),f(_,{key:0,url:e.url||e.response?.file_url,name:e.name,percentage:e.percentage,onRemove:n=>t.onRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`]))]),default:p(()=>[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadVideoUrl`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`before-upload`,`on-exceed`,`on-error`,`on-success`,`headers`])])}var Gn=z(zn,[[`render`,Wn],[`__scopeId`,`data-v-7019a8d2`]]),Kn=v({name:`MotionPromptInput`,components:{ElInput:M,InfoIcon:J},computed:{prompt:{get(){return this.$store.state.kling?.motionConfig?.prompt||``},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,prompt:e})}}}}),qn={class:`field`},Jn={class:`box`},Yn={class:`title font-bold`};function Xn(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-input`);return g(),s(`div`,qn,[e(`div`,Jn,[e(`h2`,Yn,i(t.$t(`kling.name.motionPrompt`)),1),a(d,{content:t.$t(`kling.description.motionPrompt`),class:`info`},null,8,[`content`])]),a(f,{modelValue:t.prompt,"onUpdate:modelValue":n[0]||=e=>t.prompt=e,rows:3,type:`textarea`,class:`prompt`,placeholder:t.$t(`kling.placeholder.motionPrompt`)},null,8,[`modelValue`,`placeholder`])])}var Zn=z(Kn,[[`render`,Xn],[`__scopeId`,`data-v-ca9fdbe5`]]),Qn=`video`,$n=v({name:`CharacterOrientationSelector`,components:{ElRadioGroup:O,ElRadioButton:D,InfoIcon:J},computed:{value:{get(){return this.$store.state.kling?.motionConfig?.character_orientation||Qn},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,character_orientation:e})}}},mounted(){this.$store.state.kling?.motionConfig?.character_orientation||(this.value=Qn)}}),er={class:`field`},tr={class:`header`},nr={class:`text-sm font-bold`};function rr(t,n,o,c,u,d){let f=l(`info-icon`),m=l(`el-radio-button`),h=l(`el-radio-group`);return g(),s(`div`,er,[e(`div`,tr,[e(`span`,nr,i(t.$t(`kling.name.characterOrientation`)),1),a(f,{content:t.$t(`kling.description.characterOrientation`)},null,8,[`content`])]),a(h,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,size:`small`,class:`value`},{default:p(()=>[a(m,{label:`image`},{default:p(()=>[r(i(t.$t(`kling.name.orientationImage`)),1)]),_:1}),a(m,{label:`video`},{default:p(()=>[r(i(t.$t(`kling.name.orientationVideo`)),1)]),_:1})]),_:1},8,[`modelValue`])])}var ir=z($n,[[`render`,rr],[`__scopeId`,`data-v-7a91195b`]]),ar=`kling-v2-6`,or=v({name:`MotionModelSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},computed:{options(){return[{value:`kling-v2-6`,label:`Kling 2.6`},{value:`kling-v3`,label:`Kling 3.0`}]},value:{get(){return this.$store.state.kling?.motionConfig?.model_name||ar},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,model_name:e})}}},mounted(){this.$store.state.kling?.motionConfig?.model_name||(this.value=ar)}}),sr={class:`field`},cr={class:`header`},lr={class:`title font-bold`};function ur(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,sr,[e(`div`,cr,[e(`h2`,lr,i(t.$t(`kling.name.motionModel`)),1),a(m,{content:t.$t(`kling.description.motionModel`)},null,8,[`content`])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var dr=z(or,[[`render`,ur],[`__scopeId`,`data-v-480e8da2`]]),fr=`std`,pr=v({name:`MotionModeSelector`,components:{ElSelect:b,ElOption:x,InfoIcon:J},computed:{options(){return[{value:`std`,label:this.$t(`kling.name.modeStd`)},{value:`pro`,label:this.$t(`kling.name.modePro`)}]},value:{get(){return this.$store.state.kling?.motionConfig?.mode||fr},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,mode:e})}}},mounted(){this.$store.state.kling?.motionConfig?.mode||(this.value=fr)}}),mr={class:`field`},hr={class:`header`},gr={class:`title font-bold`};function _r(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,mr,[e(`div`,hr,[e(`h2`,gr,i(t.$t(`kling.name.mode`)),1),a(m,{content:t.$t(`kling.description.motionMode`)},null,8,[`content`])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var vr=z(pr,[[`render`,_r],[`__scopeId`,`data-v-1295688c`]]),yr=v({name:`KeepOriginalSoundSelector`,components:{ElSwitch:ne,InfoIcon:J},computed:{value:{get(){return(this.$store.state.kling?.motionConfig?.keep_original_sound??`yes`)===`yes`},set(e){this.$store.commit(`kling/setMotionConfig`,{...this.$store.state.kling?.motionConfig,keep_original_sound:e?`yes`:`no`})}}}}),br={class:`relative`},xr={class:`flex justify-between items-center`},Sr={class:`flex justify-start items-center`},Cr={class:`text-sm font-bold`};function wr(t,n,r,o,c,u){let d=l(`info-icon`),f=l(`el-switch`);return g(),s(`div`,br,[e(`div`,xr,[e(`div`,Sr,[e(`span`,Cr,i(t.$t(`kling.name.keepOriginalSound`)),1),a(d,{content:t.$t(`kling.description.keepOriginalSound`)},null,8,[`content`])]),a(f,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e},null,8,[`modelValue`])])])}var Tr=v({name:`MotionPanel`,components:{ElButton:U,FontAwesomeIcon:G,Consumption:q,MotionImage:Rn,MotionVideo:Gn,MotionPromptInput:Zn,CharacterOrientationSelector:ir,MotionModelSelector:dr,MotionModeSelector:vr,KeepOriginalSoundSelector:z(yr,[[`render`,wr]])},emits:[`generate`],computed:{motionConfig(){return this.$store.state.kling?.motionConfig},consumption(){return P({...this.motionConfig,duration:1},this.service?.cost)},service(){return this.$store.state.kling?.service},canGenerate(){let e=this.motionConfig;return!!(e?.image_url&&e?.video_url)}},methods:{onGenerate(){this.$emit(`generate`)}}}),Er={class:`flex flex-col h-full`},Dr={class:`flex-1 overflow-y-auto p-5`},Or={class:`flex flex-col items-center justify-center px-5 pb-5`};function kr(t,n,o,c,u,d){let f=l(`motion-image`),m=l(`motion-video`),h=l(`motion-prompt-input`),_=l(`character-orientation-selector`),v=l(`motion-model-selector`),y=l(`motion-mode-selector`),b=l(`keep-original-sound-selector`),x=l(`consumption`),S=l(`font-awesome-icon`),C=l(`el-button`);return g(),s(`div`,Er,[e(`div`,Dr,[a(f,{class:`mb-3`}),a(m,{class:`mb-3`}),a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),a(v,{class:`mb-4`}),a(y,{class:`mb-4`}),a(b,{class:`mb-4`})]),e(`div`,Or,[a(x,{value:t.consumption,service:t.service,"rate-unit":t.$t(`kling.name.perSecond`),note:t.$t(`kling.message.motionPricingNote`)},null,8,[`value`,`service`,`rate-unit`,`note`]),a(C,{type:`primary`,class:`btn w-full`,round:``,disabled:!t.canGenerate,onClick:t.onGenerate},{default:p(()=>[a(S,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.generateMotion`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Ar=z(Tr,[[`render`,kr]]),jr=v({name:`KlingTabSwitcher`,components:{ElTabs:S,ElTabPane:C,ElTag:se},props:{modelValue:{type:String,default:`videos`}},emits:[`update:modelValue`],computed:{tabs(){return[{value:`videos`,label:this.$t(`kling.tab.videoGeneration`)},{value:`motion`,label:this.$t(`kling.tab.motionControl`)},{value:`talking-photo`,label:this.$t(`kling.tab.talkingPhoto`)}]}},methods:{onUpdate(e){this.$emit(`update:modelValue`,e)}}}),Mr=[`title`],Nr={class:`text`};function Pr(t,n,a,u,d,m){let _=l(`el-tag`),v=l(`el-tab-pane`),y=l(`el-tabs`);return g(),f(y,{"model-value":t.modelValue,class:`kling-tabs`,stretch:``,"onUpdate:modelValue":t.onUpdate},{default:p(()=>[(g(!0),s(c,null,h(t.tabs,t=>(g(),f(v,{key:t.value,name:t.value,disabled:t.disabled},{label:p(()=>[e(`span`,{class:`tab-label`,title:t.disabled?t.disabledReason:void 0},[e(`span`,Nr,i(t.label),1),t.badge?(g(),f(_,{key:0,size:`small`,type:`warning`,class:`badge`},{default:p(()=>[r(i(t.badge),1)]),_:2},1024)):o(``,!0)],8,Mr)]),_:2},1032,[`name`,`disabled`]))),128))]),_:1},8,[`model-value`,`onUpdate:modelValue`])}var Fr=z(jr,[[`render`,Pr],[`__scopeId`,`data-v-fda33e4c`]]),Ir={"kling-v2-6":`v2.6`,"kling-v2-5-turbo":`v2.5-Turbo`,"kling-v2-1-master":`v2.1-Master`,"kling-v2-master":`v2-Master`,"kling-v1-6":`v1.6`,"kling-v1":`v1`},Lr=v({name:`TalkingPhotoModelSelector`,components:{ElSelect:b,ElOption:x},data(){return{options:ie.map(e=>({value:e,label:Ir[e]||e}))}},computed:{value:{get(){return this.$store.state.kling?.talkingPhotoConfig?.model||`kling-v2-1-master`},set(e){this.$store.commit(`kling/setTalkingPhotoConfig`,{...this.$store.state.kling?.talkingPhotoConfig,model:e})}}},mounted(){this.$store.state.kling?.talkingPhotoConfig?.model||(this.value=ae)}}),Rr={class:`field`},zr={class:`title font-bold`};function Br(t,n,r,o,u,d){let m=l(`el-option`),_=l(`el-select`);return g(),s(`div`,Rr,[e(`h2`,zr,i(t.$t(`kling.name.model`)),1),a(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Vr=z(Lr,[[`render`,Br],[`__scopeId`,`data-v-cbc83d11`]]),Hr=v({name:`TalkingPhotoModeSelector`,components:{ElSelect:b,ElOption:x},computed:{options(){return[{value:`std`,label:this.$t(`kling.name.modeStd`)},{value:`pro`,label:this.$t(`kling.name.modePro`)}]},value:{get(){return this.$store.state.kling?.talkingPhotoConfig?.mode||`pro`},set(e){this.$store.commit(`kling/setTalkingPhotoConfig`,{...this.$store.state.kling?.talkingPhotoConfig,mode:e})}}},mounted(){this.$store.state.kling?.talkingPhotoConfig?.mode||(this.value=`pro`)}}),Ur={class:`field`},Wr={class:`title font-bold`};function Gr(t,n,r,o,u,d){let m=l(`el-option`),_=l(`el-select`);return g(),s(`div`,Ur,[e(`h2`,Wr,i(t.$t(`kling.name.mode`)),1),a(_,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`kling.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(m,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Kr=v({name:`TalkingPhotoPanel`,components:{ElUpload:w,ElButton:U,ElInput:M,FontAwesomeIcon:G,Consumption:q,InfoIcon:J,ImagePreview:K,ModelSelector:Vr,ModeSelector:z(Hr,[[`render`,Gr],[`__scopeId`,`data-v-92525a1d`]])},mixins:[N],emits:[`generate`],data(){return{imageFiles:[],audioFiles:[],uploadUrl:L()+`/api/v1/files/`}},computed:{config(){return this.$store.state.kling?.talkingPhotoConfig||{}},audioUrl(){return this.config.audio_url},headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},service(){return this.$store.state.kling?.service},consumption(){return P({...this.config,action:`talking-photo`},this.service?.cost)},canGenerate(){return!!(this.config.image_url&&this.config.audio_url)}},methods:{commit(e){this.$store.commit(`kling/setTalkingPhotoConfig`,{...this.config,...e})},onPromptChange(e){this.commit({prompt:e})},onImageExceed(){V.warning(this.$t(`kling.message.uploadReferencesExceed`))},onImageError(){V.error(this.$t(`kling.message.uploadReferencesError`))},onImageSuccess(e){this.commit({image_url:e?.file_url})},onImageRemove(e){this.imageFiles.splice(this.imageFiles.indexOf(e),1),this.commit({image_url:void 0})},onAudioExceed(){V.warning(this.$t(`kling.message.uploadAudioExceed`))},onAudioError(){V.error(this.$t(`kling.message.uploadAudioError`))},onAudioSuccess(e){this.commit({audio_url:e?.file_url})},onAudioRemove(){this.commit({audio_url:void 0})},onGenerate(){this.$emit(`generate`)}}}),qr={class:`flex flex-col h-full`},Jr={class:`flex-1 overflow-y-auto p-5`},Yr={class:`relative mb-4`},Xr={class:`flex justify-start items-center`},Zr={class:`text-sm font-bold`},Qr={class:`relative mb-4`},$r={class:`flex justify-start items-center`},ei={class:`text-sm font-bold`},ti=[`src`],ni={class:`mb-4`},ri={class:`flex justify-start items-center`},ii={class:`text-sm font-bold`},ai={class:`flex flex-col items-center justify-center px-5 pb-5`};function oi(t,n,c,u,d,m){let h=l(`model-selector`),_=l(`mode-selector`),v=l(`info-icon`),y=l(`image-preview`),b=l(`font-awesome-icon`),x=l(`el-button`),S=l(`el-upload`),C=l(`el-input`),w=l(`consumption`);return g(),s(`div`,qr,[e(`div`,Jr,[a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),e(`div`,Yr,[e(`div`,Xr,[e(`span`,Zr,i(t.$t(`kling.name.talkingPhotoImage`)),1),a(v,{content:t.$t(`kling.description.talkingPhotoImage`)},null,8,[`content`])]),a(S,{ref:`imageUploader`,"file-list":t.imageFiles,"onUpdate:fileList":n[0]||=e=>t.imageFiles=e,name:`file`,accept:`.png,.jpg,.jpeg,.webp,.bmp`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,headers:t.headers,"on-exceed":t.onImageExceed,"on-error":t.onImageError,"on-success":t.onImageSuccess},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(y,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.onImageRemove(e)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(x,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(b,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadReferences`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`headers`,`on-exceed`,`on-error`,`on-success`])]),e(`div`,Qr,[e(`div`,$r,[e(`span`,ei,i(t.$t(`kling.name.talkingPhotoAudio`)),1),a(v,{content:t.$t(`kling.description.talkingPhotoAudio`)},null,8,[`content`])]),a(S,{ref:`audioUploader`,"file-list":t.audioFiles,"onUpdate:fileList":n[1]||=e=>t.audioFiles=e,name:`file`,accept:`.mp3,.wav,.m4a,.aac`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,headers:t.headers,"on-exceed":t.onAudioExceed,"on-error":t.onAudioError,"on-success":t.onAudioSuccess,"on-remove":t.onAudioRemove},{default:p(()=>[a(x,{round:``,type:`primary`,size:`small`,class:`btn`},{default:p(()=>[a(b,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`kling.button.uploadAudio`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`headers`,`on-exceed`,`on-error`,`on-success`,`on-remove`]),t.audioUrl?(g(),s(`audio`,{key:0,src:t.audioUrl,controls:``,class:`w-full mt-2`},null,8,ti)):o(``,!0)]),e(`div`,ni,[e(`div`,ri,[e(`span`,ii,i(t.$t(`kling.name.talkingPhotoPrompt`)),1),a(v,{content:t.$t(`kling.description.talkingPhotoPrompt`)},null,8,[`content`])]),a(C,{"model-value":t.config.prompt,type:`textarea`,rows:2,placeholder:t.$t(`kling.placeholder.talkingPhotoPrompt`),class:`mt-1`,"onUpdate:modelValue":t.onPromptChange},null,8,[`model-value`,`placeholder`,`onUpdate:modelValue`])])]),e(`div`,ai,[a(w,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),a(x,{type:`primary`,class:`btn w-full`,round:``,disabled:!t.canGenerate,onClick:t.onGenerate},{default:p(()=>[a(b,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`kling.button.generateTalkingPhoto`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var si=z(Kr,[[`render`,oi],[`__scopeId`,`data-v-27261e35`]]),ci=v({name:`TaskPreview`,components:{ElImage:E,CopyToClipboard:le,FontAwesomeIcon:G,ElAlert:ee,VideoPlayer:me,ElTooltip:T,ElButton:U,ImagePreview:K,ApiCodeButton:he},props:{modelValue:{type:Object,required:!0}},data(){return{}},computed:{application(){return this.$store.state.kling?.application},config(){return this.$store.state.kling?.config},referenceImages(){let e=[],t=this.modelValue?.request?.start_image_url,n=this.modelValue?.request?.end_image_url;return t&&e.push({url:t,name:`start-image`}),n&&e.push({url:n,name:`end-image`}),e}},methods:{onDownload(e,t){e?.stopPropagation(),console.log(`on download`),window.open(t,`_blank`)},onOpenVideo(e){window.open(e,`_blank`)}}}),li={class:`preview`},ui={class:`left`},di={class:`main`},fi={class:`bot`},pi={class:`datetime`},mi={class:`info`},hi={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},gi={key:1,class:`prompt mt-2`},_i={key:0},vi={key:1},yi={key:0,class:n({content:!0,failed:!0})},bi={key:0,class:`mb-4`},xi={key:1,class:n({operations:!0,"mt-2":!0})},Si={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ci={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},wi={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ti={key:1,class:n({content:!0})},Ei={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Di={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Oi={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},ki={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Ai={key:2,class:n({content:!0})},ji={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Mi={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Ni(t,n,u,d,m,_){let v=l(`el-image`),y=l(`image-preview`),b=l(`video-player`),x=l(`el-button`),S=l(`el-tooltip`),C=l(`api-code-button`),w=l(`font-awesome-icon`),T=l(`copy-to-clipboard`),E=l(`el-alert`);return g(),s(`div`,li,[e(`div`,ui,[a(v,{src:`https://cdn.acedata.cloud/qpbbbb.jpg`,class:`avatar`})]),e(`div`,di,[e(`div`,fi,[r(i(t.$t(`kling.name.klingBot`))+` `,1),e(`span`,pi,i(t.$dayjs.format(``+new Date(parseFloat((t.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,mi,[t.referenceImages.length>0?(g(),s(`div`,hi,[(g(!0),s(c,null,h(t.referenceImages,(e,t)=>(g(),f(y,{key:t,url:e.url,name:e.name,closable:!1},null,8,[`url`,`name`]))),128))])):o(``,!0),t.modelValue?.request?.prompt?(g(),s(`p`,gi,[r(i(t.modelValue?.request?.prompt)+` `,1),t.modelValue?.response?o(``,!0):(g(),s(`span`,_i,` - (`+i(t.$t(`kling.status.pending`))+`) `,1)),t.modelValue?.response?.state===`submitted`||t.modelValue?.response?.state===`processing`||t.modelValue?.response?.state===`pending`||t.modelValue?.response?.state===`completed`?(g(),s(`span`,vi,` - (`+i(t.$t(`kling.status.processing`))+`) `,1)):o(``,!0)])):o(``,!0)]),t.modelValue?.response?.success===!0?(g(),s(`div`,yi,[t.modelValue?.response.video_url?(g(),s(`div`,bi,[a(b,{src:t.modelValue?.response.video_url},null,8,[`src`])])):o(``,!0),t.modelValue?.response.success?(g(),s(`div`,xi,[a(S,{class:`box-item`,effect:`dark`,content:t.$t(`kling.message.downloadVideo`),placement:`top-start`},{default:p(()=>[t.modelValue?.response.video_url?(g(),f(x,{key:0,type:`info`,size:`small`,class:`btn-action`,onClick:n[0]||=e=>t.onDownload(e,t.modelValue?.response.video_url)},{default:p(()=>[r(i(t.$t(`kling.button.download`)),1)]),_:1})):o(``,!0)]),_:1},8,[`content`]),a(C,{path:`/kling/videos`,body:t.modelValue?.request},null,8,[`body`])])):o(``,!0),a(E,{closable:!1,class:`mt-2 success`},{default:p(()=>[e(`p`,Si,[a(w,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.model`))+`: `+i(t.modelValue?.request?.model),1)]),e(`p`,Ci,[a(w,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.taskId`))+`: `+i(t.modelValue?.id)+` `,1),a(T,{content:t.modelValue?.id},null,8,[`content`])]),t.modelValue?.elapsed?(g(),s(`p`,wi,[a(w,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.elapsed`))+`: `+i(t.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0)]),_:1})])):o(``,!0),t.modelValue?.response?.success===!1?(g(),s(`div`,Ti,[a(E,{closable:!1,class:`failure`},{template:p(()=>[a(w,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.failure`)),1)]),default:p(()=>[e(`p`,Ei,[a(w,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.taskId`))+`: `+i(t.modelValue?.id)+` `,1),a(T,{content:t.modelValue?.id},null,8,[`content`])]),e(`p`,Di,[a(w,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.failureReason`))+`: `+i(t.modelValue?.response?.error?.message)+` `,1),a(T,{content:t.modelValue?.response?.error?.message},null,8,[`content`])]),t.modelValue?.elapsed?(g(),s(`p`,Oi,[a(w,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.elapsed`))+`: `+i(t.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),t.modelValue?.response?.trace_id?(g(),s(`p`,ki,[a(w,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.traceId`))+`: `+i(t.modelValue?.response?.trace_id)+` `,1),a(T,{content:t.modelValue?.response?.trace_id},null,8,[`content`])])):o(``,!0)]),_:1})])):o(``,!0),t.modelValue?.response?.success===void 0?(g(),s(`div`,Ai,[a(E,{closable:!1,class:`info`},{template:p(()=>[a(w,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.failure`)),1)]),default:p(()=>[e(`p`,ji,[a(w,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.taskId`))+`: `+i(t.modelValue?.id)+` `,1),a(T,{content:t.modelValue?.id},null,8,[`content`])]),t.modelValue?.response?.trace_id?(g(),s(`p`,Mi,[a(w,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(t.$t(`kling.name.traceId`))+`: `+i(t.modelValue?.response?.trace_id)+` `,1),a(T,{content:t.modelValue?.response?.trace_id},null,8,[`content`])])):o(``,!0)]),_:1})])):o(``,!0)])])}var Pi=v({name:`RecentPanel`,components:{TaskPreview:z(ci,[[`render`,Ni],[`__scopeId`,`data-v-c36bfd7f`]]),NoTasks:_e,BotPlaceholder:ge,ScrollList:fe},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.kling?.tasks,items:this.$store.state.kling?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Fi={key:0},Ii={key:2,class:`w-full h-full flex items-center justify-center`};function Li(e,t,n,r,i,u){let d=l(`bot-placeholder`),m=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return g(),s(c,null,[e.tasks?.items===void 0?(g(),s(`div`,Fi,[a(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(g(),f(_,{key:1,ref:`scrollList`,class:`h-full w-full overflow-y-auto tasks`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:p(()=>[(g(!0),s(c,null,h(e.tasks?.items,e=>(g(),f(m,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(g(),s(`div`,Ii,[a(v)])):o(``,!0)],64)}var Ri=v({name:`KlingIndex`,components:{ConfigPanel:jn,MotionPanel:Ar,TalkingPhotoPanel:si,TabSwitcher:Fr,Layout:we,RecentPanel:z(Pi,[[`render`,Li]])},mixins:[oe],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.kling?.status?.getApplications===ce.Request},tasksLoading(){return this.$store.state.kling?.status?.getTasks===ce.Request||this.fetchingTasks},credential(){return this.$store.state.kling.credential},config(){return this.$store.state.kling.config},motionConfig(){return this.$store.state.kling.motionConfig},talkingPhotoConfig(){return this.$store.state.kling.talkingPhotoConfig},taskType(){return this.$store.state.kling.taskType||`videos`},tasks(){return this.$store.state.kling.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 pe({tasks: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(`kling/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`kling/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(`kling/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!F(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let{camera_control:e,...t}=this.config||{},n={...t,async:!0};if(!n.video_id&&!t.video_url&&!n.start_image_url&&n.end_image_url){V.warning(this.$t(`kling.message.endImageRequiresStart`));return}if(n.action||(n.video_id||t.video_url?n.action=`extend`:n.start_image_url?n.action=`image2video`:n.action=`text2video`),n.action===`text2video`&&n.end_image_url&&delete n.end_image_url,e?.type&&(n.camera_control={type:e.type,...e.type===`simple`&&e.config?{config:Object.fromEntries(Object.entries(e.config).filter(([,e])=>e!=null))}:{}}),!R())return;let r=this.credential?.token;if(!r){console.error(`no token specified`);return}V.info(this.$t(`kling.message.startingTask`)),H(`kling`,W.generate(n,{token:r})).then(()=>{V.success(this.$t(`kling.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?V.error(this.$t(`kling.message.usedUp`)):V.error(this.$t(`kling.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()},async onTabChange(e){e!==this.taskType&&(await this.$store.dispatch(`kling/setTaskType`,e),await this.onGetTasks(),await this.onScrollDown())},async onGenerateMotion(){if(!F(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let e=this.motionConfig||{};if(!e.image_url||!e.video_url){V.warning(this.$t(`kling.message.motionMissingInputs`));return}let t={image_url:e.image_url,video_url:e.video_url,character_orientation:e.character_orientation||`video`,mode:e.mode||`std`,keep_original_sound:e.keep_original_sound??`yes`,...e.model_name?{model_name:e.model_name}:{},...e.prompt?{prompt:e.prompt}:{},async:!0};if(!R())return;let n=this.credential?.token;if(!n){console.error(`no token specified`);return}V.info(this.$t(`kling.message.startingTask`)),H(`kling`,W.motion(t,{token:n})).then(()=>{V.success(this.$t(`kling.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?V.error(this.$t(`kling.message.usedUp`)):V.error(this.$t(`kling.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},async onGenerateTalkingPhoto(){if(!F(this.uploadTracker,e=>this.$t(e),e=>V.warning(e)))return;let e=this.talkingPhotoConfig||{};if(!e.image_url||!e.audio_url){V.warning(this.$t(`kling.message.talkingPhotoMissingInputs`));return}let t={image_url:e.image_url,audio_url:e.audio_url,model:e.model||`kling-v2-1-master`,mode:e.mode||`pro`,...e.prompt?{prompt:e.prompt}:{},...e.duration?{duration:e.duration}:{},async:!0};if(!R())return;let n=this.credential?.token;if(!n){console.error(`no token specified`);return}V.info(this.$t(`kling.message.startingTask`)),H(`kling`,W.talkingPhoto(t,{token:n})).then(()=>{V.success(this.$t(`kling.message.startTaskSuccess`))}).catch(e=>{(e?.response?.data)?.error?.code===`used_up`?V.error(this.$t(`kling.message.usedUp`)):V.error(this.$t(`kling.message.startTaskFailed`))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})}}}),zi={class:`flex flex-col h-full`},Bi={class:`flex-1 min-h-0`};function Vi(t,n,r,i,s,c){let u=l(`tab-switcher`),d=l(`config-panel`),m=l(`motion-panel`),h=l(`talking-photo-panel`),_=l(`recent-panel`),v=l(`layout`);return g(),f(v,null,{config:p(()=>[e(`div`,zi,[a(u,{"model-value":t.taskType,"onUpdate:modelValue":t.onTabChange},null,8,[`model-value`,`onUpdate:modelValue`]),e(`div`,Bi,[t.taskType===`videos`?(g(),f(d,{key:0,onGenerate:t.onGenerate},null,8,[`onGenerate`])):t.taskType===`motion`?(g(),f(m,{key:1,onGenerate:t.onGenerateMotion},null,8,[`onGenerate`])):t.taskType===`talking-photo`?(g(),f(h,{key:2,onGenerate:t.onGenerateTalkingPhoto},null,8,[`onGenerate`])):o(``,!0)])])]),result:p(()=>[a(_,{ref:`recentPanel`,loading:t.loadingMore,onReachTop:t.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var Hi=z(Ri,[[`render`,Vi]]);export{Hi as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,ht as u,it as d,j as f,mt as p,rt as m,tt as h,x as g,z as _}from"./vendor-chart-Dw-P17PN.js";import{n as v,r as y,t as b}from"./select-CVXgXqir.js";import{t as x}from"./upload-D-zDieUV.js";import{t as S}from"./tooltip-Cb1CIPoD.js";import{t as C}from"./image-DGnWsKHn.js";import{t as w}from"./alert-2qBdi1l1.js";import{t as T}from"./drawer-u1pTNeW8.js";import{t as E}from"./input-number-_KRhOc4-.js";import{t as D}from"./switch-UZQHGjPB.js";import{Cn as ee,Dn as O,En as k,Mn as A,Nn as j,On as M,Sn as N,Tn as te,bn as ne,jn as re,kn as P,wn as ie,xn as F}from"./constants-Cm1pJ8kP.js";import{Cn as I,Ht as L,Kt as R,Ut as z,Vt as B,Xr as V,en as H,j as U,qr as W,si as G,sr as K,vi as q}from"./index-DqpzpRT-.js";import{t as J}from"./index.es-D7t9e-wf.js";import{t as Y}from"./CopyToClipboard-BpPd8B8b.js";import{t as X}from"./ImagePreview-BfslzHEU.js";import{n as ae}from"./taskDrawerMixin-DyAUhFEq.js";import{t as oe}from"./Consumption-Ch2waQDb.js";import{i as Z,n as se,t as ce}from"./pagination-CyeMpm2N.js";import{t as le}from"./ApiCodeButton-D08Q_WRa.js";import{t as ue}from"./BotPlaceholder-Dn8d_dlZ.js";import{t as de}from"./NoTasks-Cox5rrM8.js";import{t as fe}from"./PromptTextarea-CEL2z0Ne.js";import{t as pe}from"./ImageWrapper-COUXJuJv.js";var me=_({name:`LayoutNanobanana`,components:{ElDrawer:T,ElButton:q,FontAwesomeIcon:J},mixins:[ae]}),he={class:`main flex flex-row flex-1`},ge={class:`config w-[320px] flex-none h-full overflow-y-auto 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,i,o,c){let f=l(`font-awesome-icon`),m=l(`el-button`),_=l(`el-drawer`);return h(),s(`div`,he,[e(`div`,ge,[d(t.$slots,`config`,{},void 0,!0)]),e(`div`,_e,[d(t.$slots,`result`,{},void 0,!0)]),u(a(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:p(()=>[a(f,{icon:`fa-solid fa-magic`})]),_:1},512),[[g,!t.tasksEmpty]]),a(_,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:p(()=>[d(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ye=U(me,[[`render`,ve],[`__scopeId`,`data-v-cca80bbd`]]),be=_({name:`PromptInput`,components:{PromptTextarea:fe},computed:{prompt:{get(){return this.$store.state.openaiimage?.config?.prompt},set(e){this.$store.commit(`openaiimage/setConfig`,{...this.$store.state.openaiimage?.config,prompt:e})}}},mounted(){this.prompt||=``}});function xe(e,t,n,r,i,a){let o=l(`prompt-textarea`);return h(),f(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`openaiimage.name.prompt`),info:e.$t(`openaiimage.description.prompt`),placeholder:e.$t(`openaiimage.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Se=U(be,[[`render`,xe]]),Ce=_({name:`ImageUrlsInput`,components:{ElUpload:x,ElButton:q,InfoIcon:Z,ImagePreview:X,FontAwesomeIcon:J},mixins:[L],data(){return{fileList:[],uploadUrl:V()+`/api/v1/files/`,suppressWatch:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url).filter(e=>!!e)},value(){return this.$store.state.openaiimage?.config?.image_urls}},watch:{value:{immediate:!0,handler(e){if(this.suppressWatch)return;if(!e||e.length===0){let e=(this.fileList||[]).filter(e=>!e?.response?.file_url);this.fileList=e.length?e:[];return}let t=[];e.forEach(e=>{let n=this.fileList.find(t=>t?.response?.file_url===e||t?.url===e);n?t.push(n):t.push({name:e.split(`/`).pop()||e,url:e,status:`success`,percentage:100,response:{file_url:e}})}),(this.fileList||[]).filter(e=>!e?.response?.file_url).forEach(e=>{t.some(t=>t===e||t?.url===e?.url||t?.response?.file_url===e?.response?.file_url)||t.push(e)}),this.fileList=t}}},mounted(){},methods:{onChange(e){if(!e?.url&&e?.raw)try{e.url=URL.createObjectURL(e.raw)}catch{}},onRemove(e){if(e?.url&&typeof e.url==`string`&&e.url.startsWith(`blob:`))try{URL.revokeObjectURL(e.url)}catch{}this.onSetImageUrls()},onExceed(){G.warning(this.$t(`openaiimage.message.uploadImageExceed`))},onError(){G.error(this.$t(`openaiimage.message.uploadImageError`))},onSetImageUrls(){let e=this.urls;this.suppressWatch=!0,this.$store.commit(`openaiimage/setConfig`,{...this.$store.state.openaiimage?.config,image_urls:e}),this.$nextTick(()=>{this.suppressWatch=!1})},async onSuccess(e,t){e?.file_url&&(t.url=e.file_url,t.response=e),this.onSetImageUrls()},onRemovePreview(e,t){if(this.fileList.splice(e,1),t?.url&&typeof t.url==`string`&&t.url.startsWith(`blob:`))try{URL.revokeObjectURL(t.url)}catch{}this.onSetImageUrls()}}}),we={class:`field flex items-center justify-between`},Te={class:`title font-bold text-[14px] mb-[10px]`},Ee={class:`upload-wrapper flex flex-col items-start gap-[8px]`},De={class:`controls flex items-center`},Oe={class:`file-list flex flex-wrap gap-[10px]`};function ke(t,n,o,u,d,g){let _=l(`font-awesome-icon`),v=l(`el-button`),y=l(`el-upload`),b=l(`info-icon`),x=l(`image-preview`);return h(),s(c,null,[e(`div`,we,[e(`h2`,Te,i(t.$t(`openaiimage.name.imageUrls`)),1),e(`div`,Ee,[e(`div`,De,[a(y,{"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,name:`file`,class:`value`,limit:5,multiple:!0,"show-file-list":!1,action:t.uploadUrl,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,"on-change":t.onChange,"on-remove":t.onRemove,headers:t.headers},{default:p(()=>[a(v,{size:`small`,type:`primary`,round:``},{default:p(()=>[a(_,{icon:`fa-solid fa-upload`,class:`mr-1`}),r(` `+i(t.$t(`openaiimage.button.uploadImageUrls`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`on-change`,`on-remove`,`headers`]),a(b,{content:t.$t(`openaiimage.description.imageUrls`),class:`ml-2`},null,8,[`content`])])])]),e(`div`,Oe,[(h(!0),s(c,null,m(t.fileList,(e,n)=>(h(),f(x,{key:e.uid||e?.response?.file_url||e.url||n,url:e.url||e?.response?.file_url,name:e.name,percentage:e.percentage,onRemove:r=>t.onRemovePreview(n,e)},null,8,[`url`,`name`,`percentage`,`onRemove`]))),128))])],64)}var Ae=U(Ce,[[`render`,ke]]),je=_({name:`OpenAIImageModelSelector`,components:{ElSelect:y,ElOption:b,InfoIcon:Z},data(){return{options:[{value:te,label:this.$t(`openaiimage.model.gptImage1`)},{value:k,label:this.$t(`openaiimage.model.gptImage15`)},{value:O,label:this.$t(`openaiimage.model.gptImage2`)},{value:M,label:this.$t(`openaiimage.model.gptImage2Official`)}]}},computed:{value:{get(){return this.$store.state.openaiimage?.config?.model},set(e){this.$store.commit(`openaiimage/setConfig`,{...this.$store.state.openaiimage?.config,model:e})}},modelDescription(){return this.$t(`openaiimage.description.model`)}},mounted(){this.value||=ee}}),Me={class:`field`},Ne={class:`label`},Pe={class:`box`},Fe={class:`title font-bold`};function Ie(t,n,r,o,u,d){let g=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return h(),s(`div`,Me,[e(`div`,Ne,[e(`div`,Pe,[e(`h2`,Fe,i(t.$t(`openaiimage.name.model`)),1),a(g,{content:t.modelDescription,class:`info`},null,8,[`content`])])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`openaiimage.placeholder.select`)},{default:p(()=>[(h(!0),s(c,null,m(t.options,e=>(h(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Le=U(je,[[`render`,Ie],[`__scopeId`,`data-v-a42acad4`]]);function Q(e){if(!e)return;let t=/^(\d+)x(\d+)$/.exec(e);if(t)return{w:Number(t[1]),h:Number(t[2])}}var Re=_({name:`OpenAIImageSizeSelector`,components:{ElSelect:y,ElOption:b,ElOptionGroup:v,ElSwitch:D,ElInputNumber:E,InfoIcon:Z},data(){return{customMode:!1,customWidth:1024,customHeight:1024}},computed:{model(){return this.$store.state.openaiimage?.config?.model||`gpt-image-2`},storedSize(){return this.$store.state.openaiimage?.config?.size},emptySizeValue(){return``},customSupported(){return N.includes(this.model)},presets(){return P[this.model]??P[`gpt-image-2`]??[]},presetGroups(){return this.model===`gpt-image-2`||this.model===`gpt-image-2:official`?[{label:this.$t(`openaiimage.sizeGroup.standard1k`),options:re},{label:this.$t(`openaiimage.sizeGroup.preset2k`),options:A},{label:this.$t(`openaiimage.sizeGroup.preset4k`),options:j}]:[{label:this.$t(`openaiimage.sizeGroup.standard1k`),options:this.presets}]},useCustom:{get(){return this.customSupported&&this.customMode},set(e){if(!(e&&!this.customSupported))if(this.customMode=e,e){if(this.customError)return;this.commitSize(`${this.customWidth}x${this.customHeight}`)}else this.commitSize()}},presetValue:{get(){let e=this.storedSize;return e&&this.presets.includes(e)?e:this.emptySizeValue},set(e){this.customMode=!1,this.commitSize(e||void 0)}},multiple(){return 16},minSide(){return 256},maxSide(){return ne},customError(){let e=this.customWidth,t=this.customHeight;return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0?this.$t(`openaiimage.error.customSizePositive`):e%this.multiple!==0||t%this.multiple!==0?this.$t(`openaiimage.error.customSizeMultiple`,{multiple:this.multiple}):e<this.minSide||t<this.minSide?this.$t(`openaiimage.error.customSizeMin`,{min:this.minSide}):Math.max(e,t)>this.maxSide?this.$t(`openaiimage.error.customSizeMax`,{max:this.maxSide}):e*t>8294400?this.$t(`openaiimage.error.customSizePixels`,{pixels:F.toLocaleString()}):``}},watch:{model:{immediate:!1,handler(){this.customSupported||(this.customMode=!1);let e=this.storedSize;if(!e||this.presets.includes(e))return;let t=Q(e);t&&this.customSupported&&(this.customMode=!0,this.customWidth=t.w,this.customHeight=t.h,!this.customError)||this.commitSize()}},storedSize(e){if(!e){this.customMode=!1;return}if(this.presets.includes(e)){this.customMode=!1;return}let t=Q(e);t&&this.customSupported&&(this.customMode=!0,this.customWidth!==t.w&&(this.customWidth=t.w),this.customHeight!==t.h&&(this.customHeight=t.h))},customWidth(){this.syncCustomToStore()},customHeight(){this.syncCustomToStore()}},mounted(){let e=this.storedSize,t=Q(e);e&&t&&this.customSupported&&!this.presets.includes(e)&&(this.customMode=!0,this.customWidth=t.w,this.customHeight=t.h)},methods:{commitSize(e){let t={...this.$store.state.openaiimage?.config};e?t.size=e:delete t.size,this.$store.commit(`openaiimage/setConfig`,t)},syncCustomToStore(){this.useCustom&&(this.customError||this.commitSize(`${this.customWidth}x${this.customHeight}`))}}}),ze={class:`resolution`},Be={class:`field`},Ve={class:`label`},He={class:`box`},Ue={class:`title font-bold`},We={class:`field custom-toggle`},Ge={class:`label`},Ke={class:`box`},qe={class:`title font-bold`},Je={key:0,class:`custom-inputs`},Ye={class:`row`},Xe={class:`row-label`},Ze={class:`row`},Qe={class:`row-label`},$e={key:0,class:`error`};function et(t,n,r,u,d,g){let _=l(`info-icon`),v=l(`el-option`),y=l(`el-option-group`),b=l(`el-select`),x=l(`el-switch`),S=l(`el-input-number`);return h(),s(`div`,ze,[e(`div`,Be,[e(`div`,Ve,[e(`div`,He,[e(`h2`,Ue,i(t.$t(`openaiimage.name.size`)),1),a(_,{content:t.$t(`openaiimage.description.size`),class:`info`},null,8,[`content`])])]),a(b,{modelValue:t.presetValue,"onUpdate:modelValue":n[0]||=e=>t.presetValue=e,class:`value`,placeholder:t.$t(`openaiimage.placeholder.select`),disabled:t.useCustom},{default:p(()=>[a(v,{label:t.$t(`suno.gender.auto`),value:t.emptySizeValue},null,8,[`label`,`value`]),(h(!0),s(c,null,m(t.presetGroups,e=>(h(),f(y,{key:e.label,label:e.label},{default:p(()=>[(h(!0),s(c,null,m(e.options,e=>(h(),f(v,{key:e,label:e,value:e},null,8,[`label`,`value`]))),128))]),_:2},1032,[`label`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`disabled`])]),t.customSupported?(h(),s(c,{key:0},[e(`div`,We,[e(`div`,Ge,[e(`div`,Ke,[e(`h2`,qe,i(t.$t(`openaiimage.name.customSize`)),1),a(_,{content:t.$t(`openaiimage.description.customSize`),class:`info`},null,8,[`content`])])]),a(x,{modelValue:t.useCustom,"onUpdate:modelValue":n[1]||=e=>t.useCustom=e,class:`value-switch`},null,8,[`modelValue`])]),t.useCustom?(h(),s(`div`,Je,[e(`div`,Ye,[e(`span`,Xe,i(t.$t(`openaiimage.name.width`)),1),a(S,{modelValue:t.customWidth,"onUpdate:modelValue":n[2]||=e=>t.customWidth=e,class:`row-input`,min:t.minSide,max:t.maxSide,step:t.multiple,"step-strictly":!0,"controls-position":`right`},null,8,[`modelValue`,`min`,`max`,`step`])]),e(`div`,Ze,[e(`span`,Qe,i(t.$t(`openaiimage.name.height`)),1),a(S,{modelValue:t.customHeight,"onUpdate:modelValue":n[3]||=e=>t.customHeight=e,class:`row-input`,min:t.minSide,max:t.maxSide,step:t.multiple,"step-strictly":!0,"controls-position":`right`},null,8,[`modelValue`,`min`,`max`,`step`])]),t.customError?(h(),s(`div`,$e,i(t.customError),1)):o(``,!0)])):o(``,!0)],64)):o(``,!0)])}var tt=_({name:`ConfigPanel`,components:{ElButton:q,FontAwesomeIcon:J,PromptInput:Se,Consumption:oe,ImageUrlsInput:Ae,ModelSelector:Le,ResolutionSelector:U(Re,[[`render`,et],[`__scopeId`,`data-v-dfce4922`]])},emits:[`generate`],computed:{config(){return this.$store.state.openaiimage?.config},consumption(){return R({...this.config||{}},this.service?.cost)},service(){return this.$store.state.openaiimage?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),nt={class:`flex flex-col h-full`},rt={class:`flex-1 overflow-y-auto p-5`},it={class:`flex flex-col items-center justify-center px-5 pb-5`};function at(t,n,o,c,u,d){let f=l(`model-selector`),m=l(`resolution-selector`),g=l(`prompt-input`),_=l(`image-urls-input`),v=l(`consumption`),y=l(`font-awesome-icon`),b=l(`el-button`);return h(),s(`div`,nt,[e(`div`,rt,[a(f,{class:`mb-4`}),a(m,{class:`mb-4`}),a(g,{class:`mb-4`}),a(_,{class:`mb-4`})]),e(`div`,it,[a(v,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),a(b,{type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(y,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`openaiimage.button.generate`)),1)]),_:1},8,[`onClick`])])])}var ot=U(tt,[[`render`,at]]),st=_({name:`TaskPreview`,components:{ElImage:C,CopyToClipboard:Y,FontAwesomeIcon:J,ElAlert:w,ImageWrapper:pe,ElButton:q,ElTooltip:S,ImagePreview:X,ApiCodeButton:le},props:{modelValue:{type:Object,required:!0}},setup(){return{OPENAIIMAGE_LOGO:ie}},computed:{isEditRequest(){let e=this.modelValue?.request;return this.modelValue?.type===`images_edits`||e?.action===`edit`||this.referenceImages.length>0},showTaskType(){return!!(this.modelValue?.request?.action||this.modelValue?.type||this.referenceImages.length>0)},taskTypeLabel(){return this.isEditRequest?this.$t(`openaiimage.name.edits`):this.$t(`openaiimage.name.generate`)},openaiimagePath(){return this.isEditRequest?`/openai/images/edits`:`/openai/images/generations`},openaiimageCodeBody(){let e=this.modelValue?.request;if(!e)return;let t={...e};if(delete t.action,delete t.callback_url,this.isEditRequest){delete t.image_urls,delete t.image;let e=this.referenceImages;e.length===1?t.image=e[0]:e.length>1&&(t.image=e)}else delete t.image_urls,delete t.image;return t},images(){let e=[];return Array.isArray(this.modelValue?.response?.data)&&this.modelValue?.response?.data?.forEach(t=>{let n=t;if(n?.image_url||n?.url){e.push(n);return}n?.b64_json&&e.push({...n,url:`data:image/png;base64,${n.b64_json}`})}),e},referenceImages(){let e=this.modelValue?.request;if(!e)return[];let t=Array.isArray(e.image_urls)?e.image_urls:[];if(t.length>0)return t.filter(e=>typeof e==`string`&&e.length>0);let n=e.image;return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):typeof n==`string`&&n.length>0?[n]:Array.isArray(e.images)?e.images.map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`)return e.image_url}).filter(e=>typeof e==`string`&&e.length>0):[]}},methods:{onEdit(e){if(!e)return;console.debug(`Edit image:`,e);let t={...this.$store.state.openaiimage?.config||{}};t.image_urls=[e],this.$store.commit(`openaiimage/setConfig`,t)}}}),ct={class:`preview`},lt={class:`left`},ut={class:`main`},dt={class:`bot`},ft={class:`datetime`},pt={class:`info`},mt={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},ht={key:1,class:`prompt mt-2`},gt={key:0},_t={key:0,class:n({content:!0,failed:!0})},vt={class:`flex justify-start items-center gap-4 w-full overflow-x-auto`},yt={class:n({operations:!0,"mt-2":!0,"mb-2":!0})},bt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},xt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},St={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ct={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},wt={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Tt={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Et={key:1,class:n({content:!0})},Dt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ot={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},kt={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},At={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},jt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Mt={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Nt={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},$={key:2,class:n({content:!0})},Pt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ft={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},It={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Lt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`};function Rt(n,u,d,g,_,v){let y=l(`el-image`),b=l(`image-preview`),x=l(`image-wrapper`),S=l(`el-button`),C=l(`el-tooltip`),w=l(`api-code-button`),T=l(`font-awesome-icon`),E=l(`copy-to-clipboard`),D=l(`el-alert`);return h(),s(`div`,ct,[e(`div`,lt,[a(y,{src:n.OPENAIIMAGE_LOGO,class:`avatar`},null,8,[`src`])]),e(`div`,ut,[e(`div`,dt,[r(i(n.$t(`openaiimage.name.openaiimageBot`))+` `,1),e(`span`,ft,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,pt,[n.referenceImages.length>0?(h(),s(`div`,mt,[(h(!0),s(c,null,m(n.referenceImages,(e,t)=>(h(),f(b,{key:t,url:e,name:`image-${t+1}`,closable:!1},null,8,[`url`,`name`]))),128))])):o(``,!0),n.modelValue?.request?.prompt?(h(),s(`p`,ht,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?o(``,!0):(h(),s(`span`,gt,` - (`+i(n.$t(`openaiimage.status.pending`))+`) `,1))])):o(``,!0)]),n.modelValue?.response?.success===!0?(h(),s(`div`,_t,[e(`div`,vt,[(h(!0),s(c,null,m(n.images,(e,t)=>(h(),f(x,{key:t,src:e?.image_url||e?.url||``,"raw-src":e?.image_url||e?.url||``},null,8,[`src`,`raw-src`]))),128))]),e(`div`,yt,[a(C,{class:`box-item`,effect:`dark`,content:n.$t(`common.button.edit`),placement:`top-start`},{default:p(()=>[a(S,{type:`info`,size:`small`,class:`btn-action`,onClick:u[0]||=t(e=>n.onEdit(n.images?.[0]?.image_url||n.images?.[0]?.url),[`stop`])},{default:p(()=>[r(i(n.$t(`common.button.edit`)),1)]),_:1})]),_:1},8,[`content`]),a(w,{path:n.openaiimagePath,body:n.openaiimageCodeBody},null,8,[`path`,`body`])]),a(D,{closable:!1,class:`mt-2 success`},{default:p(()=>[n.modelValue?.request?.model?(h(),s(`p`,bt,[a(T,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.modelValue?.request?.size?(h(),s(`p`,xt,[a(T,{icon:`fa-solid fa-image`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.size`))+`: `+i(n.modelValue?.request?.size),1)])):o(``,!0),n.showTaskType?(h(),s(`p`,St,[a(T,{icon:`fa-solid fa-bolt`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.task`))+`: `+i(n.taskTypeLabel),1)])):o(``,!0),e(`p`,Ct,[a(T,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(E,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.modelValue?.elapsed?(h(),s(`p`,wt,[a(T,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),n.modelValue?.response?.trace_id?(h(),s(`p`,Tt,[a(T,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(E,{content:n.modelValue?.response?.trace_id,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0)]),_:1})])):n.modelValue?.response?.success===!1?(h(),s(`div`,Et,[a(D,{closable:!1,class:`failure`},{template:p(()=>[a(T,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.failure`)),1)]),default:p(()=>[n.modelValue?.request?.model?(h(),s(`p`,Dt,[a(T,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.modelValue?.request?.size?(h(),s(`p`,Ot,[a(T,{icon:`fa-solid fa-image`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.size`))+`: `+i(n.modelValue?.request?.size),1)])):o(``,!0),n.showTaskType?(h(),s(`p`,kt,[a(T,{icon:`fa-solid fa-bolt`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.task`))+`: `+i(n.taskTypeLabel),1)])):o(``,!0),e(`p`,At,[a(T,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(E,{content:n.modelValue?.id,class:`btn-copy`},null,8,[`content`])]),e(`p`,jt,[a(T,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.failureReason`))+`: `+i(n.modelValue?.response?.error?.message)+` `,1),a(E,{content:n.modelValue?.response?.error?.message,class:`btn-copy`},null,8,[`content`])]),n.modelValue?.elapsed?(h(),s(`p`,Mt,[a(T,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),n.modelValue?.response?.trace_id?(h(),s(`p`,Nt,[a(T,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(E,{content:n.modelValue?.response?.trace_id,class:`btn-copy`},null,8,[`content`])])):o(``,!0)]),_:1})])):(h(),s(`div`,$,[a(D,{closable:!1,class:`info`},{template:p(()=>[a(T,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.failure`)),1)]),default:p(()=>[n.modelValue?.request?.model?(h(),s(`p`,Pt,[a(T,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.modelValue?.request?.size?(h(),s(`p`,Ft,[a(T,{icon:`fa-solid fa-image`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.size`))+`: `+i(n.modelValue?.request?.size),1)])):o(``,!0),n.showTaskType?(h(),s(`p`,It,[a(T,{icon:`fa-solid fa-bolt`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.task`))+`: `+i(n.taskTypeLabel),1)])):o(``,!0),e(`p`,Lt,[a(T,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(E,{content:n.modelValue?.id,class:`btn-copy`},null,8,[`content`])])]),_:1})]))])])}var zt=_({name:`RecentPanel`,components:{TaskPreview:U(st,[[`render`,Rt],[`__scopeId`,`data-v-8ee5fb87`]]),BotPlaceholder:ue,NoTasks:de,ScrollList:se},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.openaiimage?.tasks,items:this.$store.state.openaiimage?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Bt={key:0},Vt={key:2,class:`w-full h-full flex items-center justify-center`};function Ht(e,t,n,r,i,u){let d=l(`bot-placeholder`),g=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return h(),s(c,null,[e.tasks?.items===void 0?(h(),s(`div`,Bt,[a(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(h(),f(_,{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:p(()=>[(h(!0),s(c,null,m(e.tasks?.items,e=>(h(),f(g,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(h(),s(`div`,Vt,[a(v)])):o(``,!0)],64)}var Ut=_({name:`OpenAIImageIndex`,components:{ConfigPanel:ot,Layout:ye,RecentPanel:U(zt,[[`render`,Ht]])},mixins:[z],inject:[`initialized`],data(){return{task:void 0,job:0,loading:!1}},computed:{applicationsLoading(){return this.$store.state.openaiimage?.status?.getApplications===W.Request},tasksLoading(){return this.$store.state.openaiimage?.status?.getTasks===W.Request},credential(){return this.$store.state.openaiimage?.credential},config(){return this.$store.state.openaiimage?.config},application(){return this.$store.state.openaiimage?.application},tasks(){return this.$store.state.openaiimage?.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 ce({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loading,setLoading:e=>this.loading=e,isBlocked:()=>this.tasksLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`openaiimage/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`openaiimage/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.tasksLoading){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=20,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),await this.$store.dispatch(`openaiimage/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})},async onGenerate(){if(!B(this.uploadTracker,e=>this.$t(e),e=>G.warning(e)))return;let e={...this.config||{}},t=Array.isArray(e?.image_urls)&&e.image_urls.length>0;if(!this.hasText(e.prompt)){G.error(this.$t(`openaiimage.message.promptRequired`));return}e.prompt=e.prompt.trim(),!t&&`image_urls`in e&&delete e.image_urls,e.size||delete e.size;let n={...e,action:`generate`,async:!0},r={action:`edit`,model:e?.model,prompt:e?.prompt,size:e?.size,image_urls:e?.image_urls||[],async:!0};if(!H())return;let i=this.credential?.token;if(!i){console.error(`no token specified`);return}G.info(this.$t(`openaiimage.message.startingTask`)),K(`openaiimage`,t?I.edit(r,{token:i}):I.generate(n,{token:i})).then(e=>{console.debug(`task accepted`,e.data?.task_id),G.success(this.$t(`openaiimage.message.startTaskSuccess`))}).catch(e=>{let t=e?.response?.data;t?.error?.code===`used_up`?G.error(this.$t(`openaiimage.message.usedUp`)):G.error(this.$t(`openaiimage.message.startTaskFailed`)+(t?.error?.message||``))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()},hasText(e){return typeof e==`string`&&e.trim().length>0}}});function Wt(e,t,n,r,i,o){let s=l(`config-panel`),c=l(`recent-panel`),u=l(`layout`);return h(),f(u,null,{config:p(()=>[a(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:p(()=>[a(c,{ref:`recentPanel`,loading:e.loading,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var Gt=U(Ut,[[`render`,Wt]]);export{Gt as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,ht as u,it as d,j as f,mt as p,rt as m,tt as h,x as g,z as _}from"./vendor-chart-Dw-P17PN.js";import{n as v,r as y,t as b}from"./select-B0Rytq57.js";import{t as x}from"./upload-CKPXpkhw.js";import{t as S}from"./tooltip-DMkRuyNr.js";import{t as C}from"./image-C_wGl_Tq.js";import{t as w}from"./alert-9UHbWOgh.js";import{t as T}from"./drawer-BhyqFLuj.js";import{t as E}from"./input-number-BqS9Kh4f.js";import{t as D}from"./switch-C_iujXz0.js";import{Cn as ee,Dn as O,En as k,Mn as A,Nn as j,On as M,Sn as N,Tn as te,bn as ne,jn as re,kn as P,wn as ie,xn as F}from"./constants-Cm1pJ8kP.js";import{Cn as I,Ht as L,Kt as R,Ut as z,Vt as B,Xr as V,en as H,j as U,qr as W,si as G,sr as K,vi as q}from"./index-CEsOXc02.js";import{t as J}from"./index.es-CZ18ogLi.js";import{t as Y}from"./CopyToClipboard-BDHrbE9N.js";import{t as X}from"./ImagePreview-CBJ5UBky.js";import{n as ae}from"./taskDrawerMixin-DyAUhFEq.js";import{t as oe}from"./Consumption-0ipkiA5W.js";import{i as Z,n as se,t as ce}from"./pagination-UvuFCwzm.js";import{t as le}from"./ApiCodeButton-WbUyGTD7.js";import{t as ue}from"./BotPlaceholder-DeEtrFs6.js";import{t as de}from"./NoTasks-CF_GuqSx.js";import{t as fe}from"./PromptTextarea-JRe0Kgab.js";import{t as pe}from"./ImageWrapper-XPy_gfNc.js";var me=_({name:`LayoutNanobanana`,components:{ElDrawer:T,ElButton:q,FontAwesomeIcon:J},mixins:[ae]}),he={class:`main flex flex-row flex-1`},ge={class:`config w-[320px] flex-none h-full overflow-y-auto 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,i,o,c){let f=l(`font-awesome-icon`),m=l(`el-button`),_=l(`el-drawer`);return h(),s(`div`,he,[e(`div`,ge,[d(t.$slots,`config`,{},void 0,!0)]),e(`div`,_e,[d(t.$slots,`result`,{},void 0,!0)]),u(a(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:p(()=>[a(f,{icon:`fa-solid fa-magic`})]),_:1},512),[[g,!t.tasksEmpty]]),a(_,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`340px`,class:`drawer`},{default:p(()=>[d(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ye=U(me,[[`render`,ve],[`__scopeId`,`data-v-cca80bbd`]]),be=_({name:`PromptInput`,components:{PromptTextarea:fe},computed:{prompt:{get(){return this.$store.state.openaiimage?.config?.prompt},set(e){this.$store.commit(`openaiimage/setConfig`,{...this.$store.state.openaiimage?.config,prompt:e})}}},mounted(){this.prompt||=``}});function xe(e,t,n,r,i,a){let o=l(`prompt-textarea`);return h(),f(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`openaiimage.name.prompt`),info:e.$t(`openaiimage.description.prompt`),placeholder:e.$t(`openaiimage.placeholder.prompt`)},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var Se=U(be,[[`render`,xe]]),Ce=_({name:`ImageUrlsInput`,components:{ElUpload:x,ElButton:q,InfoIcon:Z,ImagePreview:X,FontAwesomeIcon:J},mixins:[L],data(){return{fileList:[],uploadUrl:V()+`/api/v1/files/`,suppressWatch:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url).filter(e=>!!e)},value(){return this.$store.state.openaiimage?.config?.image_urls}},watch:{value:{immediate:!0,handler(e){if(this.suppressWatch)return;if(!e||e.length===0){let e=(this.fileList||[]).filter(e=>!e?.response?.file_url);this.fileList=e.length?e:[];return}let t=[];e.forEach(e=>{let n=this.fileList.find(t=>t?.response?.file_url===e||t?.url===e);n?t.push(n):t.push({name:e.split(`/`).pop()||e,url:e,status:`success`,percentage:100,response:{file_url:e}})}),(this.fileList||[]).filter(e=>!e?.response?.file_url).forEach(e=>{t.some(t=>t===e||t?.url===e?.url||t?.response?.file_url===e?.response?.file_url)||t.push(e)}),this.fileList=t}}},mounted(){},methods:{onChange(e){if(!e?.url&&e?.raw)try{e.url=URL.createObjectURL(e.raw)}catch{}},onRemove(e){if(e?.url&&typeof e.url==`string`&&e.url.startsWith(`blob:`))try{URL.revokeObjectURL(e.url)}catch{}this.onSetImageUrls()},onExceed(){G.warning(this.$t(`openaiimage.message.uploadImageExceed`))},onError(){G.error(this.$t(`openaiimage.message.uploadImageError`))},onSetImageUrls(){let e=this.urls;this.suppressWatch=!0,this.$store.commit(`openaiimage/setConfig`,{...this.$store.state.openaiimage?.config,image_urls:e}),this.$nextTick(()=>{this.suppressWatch=!1})},async onSuccess(e,t){e?.file_url&&(t.url=e.file_url,t.response=e),this.onSetImageUrls()},onRemovePreview(e,t){if(this.fileList.splice(e,1),t?.url&&typeof t.url==`string`&&t.url.startsWith(`blob:`))try{URL.revokeObjectURL(t.url)}catch{}this.onSetImageUrls()}}}),we={class:`field flex items-center justify-between`},Te={class:`title font-bold text-[14px] mb-[10px]`},Ee={class:`upload-wrapper flex flex-col items-start gap-[8px]`},De={class:`controls flex items-center`},Oe={class:`file-list flex flex-wrap gap-[10px]`};function ke(t,n,o,u,d,g){let _=l(`font-awesome-icon`),v=l(`el-button`),y=l(`el-upload`),b=l(`info-icon`),x=l(`image-preview`);return h(),s(c,null,[e(`div`,we,[e(`h2`,Te,i(t.$t(`openaiimage.name.imageUrls`)),1),e(`div`,Ee,[e(`div`,De,[a(y,{"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,name:`file`,class:`value`,limit:5,multiple:!0,"show-file-list":!1,action:t.uploadUrl,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,"on-change":t.onChange,"on-remove":t.onRemove,headers:t.headers},{default:p(()=>[a(v,{size:`small`,type:`primary`,round:``},{default:p(()=>[a(_,{icon:`fa-solid fa-upload`,class:`mr-1`}),r(` `+i(t.$t(`openaiimage.button.uploadImageUrls`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`on-change`,`on-remove`,`headers`]),a(b,{content:t.$t(`openaiimage.description.imageUrls`),class:`ml-2`},null,8,[`content`])])])]),e(`div`,Oe,[(h(!0),s(c,null,m(t.fileList,(e,n)=>(h(),f(x,{key:e.uid||e?.response?.file_url||e.url||n,url:e.url||e?.response?.file_url,name:e.name,percentage:e.percentage,onRemove:r=>t.onRemovePreview(n,e)},null,8,[`url`,`name`,`percentage`,`onRemove`]))),128))])],64)}var Ae=U(Ce,[[`render`,ke]]),je=_({name:`OpenAIImageModelSelector`,components:{ElSelect:y,ElOption:b,InfoIcon:Z},data(){return{options:[{value:te,label:this.$t(`openaiimage.model.gptImage1`)},{value:k,label:this.$t(`openaiimage.model.gptImage15`)},{value:O,label:this.$t(`openaiimage.model.gptImage2`)},{value:M,label:this.$t(`openaiimage.model.gptImage2Official`)}]}},computed:{value:{get(){return this.$store.state.openaiimage?.config?.model},set(e){this.$store.commit(`openaiimage/setConfig`,{...this.$store.state.openaiimage?.config,model:e})}},modelDescription(){return this.$t(`openaiimage.description.model`)}},mounted(){this.value||=ee}}),Me={class:`field`},Ne={class:`label`},Pe={class:`box`},Fe={class:`title font-bold`};function Ie(t,n,r,o,u,d){let g=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return h(),s(`div`,Me,[e(`div`,Ne,[e(`div`,Pe,[e(`h2`,Fe,i(t.$t(`openaiimage.name.model`)),1),a(g,{content:t.modelDescription,class:`info`},null,8,[`content`])])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`openaiimage.placeholder.select`)},{default:p(()=>[(h(!0),s(c,null,m(t.options,e=>(h(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Le=U(je,[[`render`,Ie],[`__scopeId`,`data-v-a42acad4`]]);function Q(e){if(!e)return;let t=/^(\d+)x(\d+)$/.exec(e);if(t)return{w:Number(t[1]),h:Number(t[2])}}var Re=_({name:`OpenAIImageSizeSelector`,components:{ElSelect:y,ElOption:b,ElOptionGroup:v,ElSwitch:D,ElInputNumber:E,InfoIcon:Z},data(){return{customMode:!1,customWidth:1024,customHeight:1024}},computed:{model(){return this.$store.state.openaiimage?.config?.model||`gpt-image-2`},storedSize(){return this.$store.state.openaiimage?.config?.size},emptySizeValue(){return``},customSupported(){return N.includes(this.model)},presets(){return P[this.model]??P[`gpt-image-2`]??[]},presetGroups(){return this.model===`gpt-image-2`||this.model===`gpt-image-2:official`?[{label:this.$t(`openaiimage.sizeGroup.standard1k`),options:re},{label:this.$t(`openaiimage.sizeGroup.preset2k`),options:A},{label:this.$t(`openaiimage.sizeGroup.preset4k`),options:j}]:[{label:this.$t(`openaiimage.sizeGroup.standard1k`),options:this.presets}]},useCustom:{get(){return this.customSupported&&this.customMode},set(e){if(!(e&&!this.customSupported))if(this.customMode=e,e){if(this.customError)return;this.commitSize(`${this.customWidth}x${this.customHeight}`)}else this.commitSize()}},presetValue:{get(){let e=this.storedSize;return e&&this.presets.includes(e)?e:this.emptySizeValue},set(e){this.customMode=!1,this.commitSize(e||void 0)}},multiple(){return 16},minSide(){return 256},maxSide(){return ne},customError(){let e=this.customWidth,t=this.customHeight;return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0?this.$t(`openaiimage.error.customSizePositive`):e%this.multiple!==0||t%this.multiple!==0?this.$t(`openaiimage.error.customSizeMultiple`,{multiple:this.multiple}):e<this.minSide||t<this.minSide?this.$t(`openaiimage.error.customSizeMin`,{min:this.minSide}):Math.max(e,t)>this.maxSide?this.$t(`openaiimage.error.customSizeMax`,{max:this.maxSide}):e*t>8294400?this.$t(`openaiimage.error.customSizePixels`,{pixels:F.toLocaleString()}):``}},watch:{model:{immediate:!1,handler(){this.customSupported||(this.customMode=!1);let e=this.storedSize;if(!e||this.presets.includes(e))return;let t=Q(e);t&&this.customSupported&&(this.customMode=!0,this.customWidth=t.w,this.customHeight=t.h,!this.customError)||this.commitSize()}},storedSize(e){if(!e){this.customMode=!1;return}if(this.presets.includes(e)){this.customMode=!1;return}let t=Q(e);t&&this.customSupported&&(this.customMode=!0,this.customWidth!==t.w&&(this.customWidth=t.w),this.customHeight!==t.h&&(this.customHeight=t.h))},customWidth(){this.syncCustomToStore()},customHeight(){this.syncCustomToStore()}},mounted(){let e=this.storedSize,t=Q(e);e&&t&&this.customSupported&&!this.presets.includes(e)&&(this.customMode=!0,this.customWidth=t.w,this.customHeight=t.h)},methods:{commitSize(e){let t={...this.$store.state.openaiimage?.config};e?t.size=e:delete t.size,this.$store.commit(`openaiimage/setConfig`,t)},syncCustomToStore(){this.useCustom&&(this.customError||this.commitSize(`${this.customWidth}x${this.customHeight}`))}}}),ze={class:`resolution`},Be={class:`field`},Ve={class:`label`},He={class:`box`},Ue={class:`title font-bold`},We={class:`field custom-toggle`},Ge={class:`label`},Ke={class:`box`},qe={class:`title font-bold`},Je={key:0,class:`custom-inputs`},Ye={class:`row`},Xe={class:`row-label`},Ze={class:`row`},Qe={class:`row-label`},$e={key:0,class:`error`};function et(t,n,r,u,d,g){let _=l(`info-icon`),v=l(`el-option`),y=l(`el-option-group`),b=l(`el-select`),x=l(`el-switch`),S=l(`el-input-number`);return h(),s(`div`,ze,[e(`div`,Be,[e(`div`,Ve,[e(`div`,He,[e(`h2`,Ue,i(t.$t(`openaiimage.name.size`)),1),a(_,{content:t.$t(`openaiimage.description.size`),class:`info`},null,8,[`content`])])]),a(b,{modelValue:t.presetValue,"onUpdate:modelValue":n[0]||=e=>t.presetValue=e,class:`value`,placeholder:t.$t(`openaiimage.placeholder.select`),disabled:t.useCustom},{default:p(()=>[a(v,{label:t.$t(`suno.gender.auto`),value:t.emptySizeValue},null,8,[`label`,`value`]),(h(!0),s(c,null,m(t.presetGroups,e=>(h(),f(y,{key:e.label,label:e.label},{default:p(()=>[(h(!0),s(c,null,m(e.options,e=>(h(),f(v,{key:e,label:e,value:e},null,8,[`label`,`value`]))),128))]),_:2},1032,[`label`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`disabled`])]),t.customSupported?(h(),s(c,{key:0},[e(`div`,We,[e(`div`,Ge,[e(`div`,Ke,[e(`h2`,qe,i(t.$t(`openaiimage.name.customSize`)),1),a(_,{content:t.$t(`openaiimage.description.customSize`),class:`info`},null,8,[`content`])])]),a(x,{modelValue:t.useCustom,"onUpdate:modelValue":n[1]||=e=>t.useCustom=e,class:`value-switch`},null,8,[`modelValue`])]),t.useCustom?(h(),s(`div`,Je,[e(`div`,Ye,[e(`span`,Xe,i(t.$t(`openaiimage.name.width`)),1),a(S,{modelValue:t.customWidth,"onUpdate:modelValue":n[2]||=e=>t.customWidth=e,class:`row-input`,min:t.minSide,max:t.maxSide,step:t.multiple,"step-strictly":!0,"controls-position":`right`},null,8,[`modelValue`,`min`,`max`,`step`])]),e(`div`,Ze,[e(`span`,Qe,i(t.$t(`openaiimage.name.height`)),1),a(S,{modelValue:t.customHeight,"onUpdate:modelValue":n[3]||=e=>t.customHeight=e,class:`row-input`,min:t.minSide,max:t.maxSide,step:t.multiple,"step-strictly":!0,"controls-position":`right`},null,8,[`modelValue`,`min`,`max`,`step`])]),t.customError?(h(),s(`div`,$e,i(t.customError),1)):o(``,!0)])):o(``,!0)],64)):o(``,!0)])}var tt=_({name:`ConfigPanel`,components:{ElButton:q,FontAwesomeIcon:J,PromptInput:Se,Consumption:oe,ImageUrlsInput:Ae,ModelSelector:Le,ResolutionSelector:U(Re,[[`render`,et],[`__scopeId`,`data-v-dfce4922`]])},emits:[`generate`],computed:{config(){return this.$store.state.openaiimage?.config},consumption(){return R({...this.config||{}},this.service?.cost)},service(){return this.$store.state.openaiimage?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),nt={class:`flex flex-col h-full`},rt={class:`flex-1 overflow-y-auto p-5`},it={class:`flex flex-col items-center justify-center px-5 pb-5`};function at(t,n,o,c,u,d){let f=l(`model-selector`),m=l(`resolution-selector`),g=l(`prompt-input`),_=l(`image-urls-input`),v=l(`consumption`),y=l(`font-awesome-icon`),b=l(`el-button`);return h(),s(`div`,nt,[e(`div`,rt,[a(f,{class:`mb-4`}),a(m,{class:`mb-4`}),a(g,{class:`mb-4`}),a(_,{class:`mb-4`})]),e(`div`,it,[a(v,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),a(b,{type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(y,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`openaiimage.button.generate`)),1)]),_:1},8,[`onClick`])])])}var ot=U(tt,[[`render`,at]]),st=_({name:`TaskPreview`,components:{ElImage:C,CopyToClipboard:Y,FontAwesomeIcon:J,ElAlert:w,ImageWrapper:pe,ElButton:q,ElTooltip:S,ImagePreview:X,ApiCodeButton:le},props:{modelValue:{type:Object,required:!0}},setup(){return{OPENAIIMAGE_LOGO:ie}},computed:{isEditRequest(){let e=this.modelValue?.request;return this.modelValue?.type===`images_edits`||e?.action===`edit`||this.referenceImages.length>0},showTaskType(){return!!(this.modelValue?.request?.action||this.modelValue?.type||this.referenceImages.length>0)},taskTypeLabel(){return this.isEditRequest?this.$t(`openaiimage.name.edits`):this.$t(`openaiimage.name.generate`)},openaiimagePath(){return this.isEditRequest?`/openai/images/edits`:`/openai/images/generations`},openaiimageCodeBody(){let e=this.modelValue?.request;if(!e)return;let t={...e};if(delete t.action,delete t.callback_url,this.isEditRequest){delete t.image_urls,delete t.image;let e=this.referenceImages;e.length===1?t.image=e[0]:e.length>1&&(t.image=e)}else delete t.image_urls,delete t.image;return t},images(){let e=[];return Array.isArray(this.modelValue?.response?.data)&&this.modelValue?.response?.data?.forEach(t=>{let n=t;if(n?.image_url||n?.url){e.push(n);return}n?.b64_json&&e.push({...n,url:`data:image/png;base64,${n.b64_json}`})}),e},referenceImages(){let e=this.modelValue?.request;if(!e)return[];let t=Array.isArray(e.image_urls)?e.image_urls:[];if(t.length>0)return t.filter(e=>typeof e==`string`&&e.length>0);let n=e.image;return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):typeof n==`string`&&n.length>0?[n]:Array.isArray(e.images)?e.images.map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`)return e.image_url}).filter(e=>typeof e==`string`&&e.length>0):[]}},methods:{onEdit(e){if(!e)return;console.debug(`Edit image:`,e);let t={...this.$store.state.openaiimage?.config||{}};t.image_urls=[e],this.$store.commit(`openaiimage/setConfig`,t)}}}),ct={class:`preview`},lt={class:`left`},ut={class:`main`},dt={class:`bot`},ft={class:`datetime`},pt={class:`info`},mt={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},ht={key:1,class:`prompt mt-2`},gt={key:0},_t={key:0,class:n({content:!0,failed:!0})},vt={class:`flex justify-start items-center gap-4 w-full overflow-x-auto`},yt={class:n({operations:!0,"mt-2":!0,"mb-2":!0})},bt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},xt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},St={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ct={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},wt={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Tt={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Et={key:1,class:n({content:!0})},Dt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ot={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},kt={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},At={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},jt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Mt={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Nt={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},$={key:2,class:n({content:!0})},Pt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ft={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},It={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Lt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`};function Rt(n,u,d,g,_,v){let y=l(`el-image`),b=l(`image-preview`),x=l(`image-wrapper`),S=l(`el-button`),C=l(`el-tooltip`),w=l(`api-code-button`),T=l(`font-awesome-icon`),E=l(`copy-to-clipboard`),D=l(`el-alert`);return h(),s(`div`,ct,[e(`div`,lt,[a(y,{src:n.OPENAIIMAGE_LOGO,class:`avatar`},null,8,[`src`])]),e(`div`,ut,[e(`div`,dt,[r(i(n.$t(`openaiimage.name.openaiimageBot`))+` `,1),e(`span`,ft,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,pt,[n.referenceImages.length>0?(h(),s(`div`,mt,[(h(!0),s(c,null,m(n.referenceImages,(e,t)=>(h(),f(b,{key:t,url:e,name:`image-${t+1}`,closable:!1},null,8,[`url`,`name`]))),128))])):o(``,!0),n.modelValue?.request?.prompt?(h(),s(`p`,ht,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?o(``,!0):(h(),s(`span`,gt,` - (`+i(n.$t(`openaiimage.status.pending`))+`) `,1))])):o(``,!0)]),n.modelValue?.response?.success===!0?(h(),s(`div`,_t,[e(`div`,vt,[(h(!0),s(c,null,m(n.images,(e,t)=>(h(),f(x,{key:t,src:e?.image_url||e?.url||``,"raw-src":e?.image_url||e?.url||``},null,8,[`src`,`raw-src`]))),128))]),e(`div`,yt,[a(C,{class:`box-item`,effect:`dark`,content:n.$t(`common.button.edit`),placement:`top-start`},{default:p(()=>[a(S,{type:`info`,size:`small`,class:`btn-action`,onClick:u[0]||=t(e=>n.onEdit(n.images?.[0]?.image_url||n.images?.[0]?.url),[`stop`])},{default:p(()=>[r(i(n.$t(`common.button.edit`)),1)]),_:1})]),_:1},8,[`content`]),a(w,{path:n.openaiimagePath,body:n.openaiimageCodeBody},null,8,[`path`,`body`])]),a(D,{closable:!1,class:`mt-2 success`},{default:p(()=>[n.modelValue?.request?.model?(h(),s(`p`,bt,[a(T,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.modelValue?.request?.size?(h(),s(`p`,xt,[a(T,{icon:`fa-solid fa-image`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.size`))+`: `+i(n.modelValue?.request?.size),1)])):o(``,!0),n.showTaskType?(h(),s(`p`,St,[a(T,{icon:`fa-solid fa-bolt`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.task`))+`: `+i(n.taskTypeLabel),1)])):o(``,!0),e(`p`,Ct,[a(T,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(E,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.modelValue?.elapsed?(h(),s(`p`,wt,[a(T,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),n.modelValue?.response?.trace_id?(h(),s(`p`,Tt,[a(T,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(E,{content:n.modelValue?.response?.trace_id,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0)]),_:1})])):n.modelValue?.response?.success===!1?(h(),s(`div`,Et,[a(D,{closable:!1,class:`failure`},{template:p(()=>[a(T,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.failure`)),1)]),default:p(()=>[n.modelValue?.request?.model?(h(),s(`p`,Dt,[a(T,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.modelValue?.request?.size?(h(),s(`p`,Ot,[a(T,{icon:`fa-solid fa-image`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.size`))+`: `+i(n.modelValue?.request?.size),1)])):o(``,!0),n.showTaskType?(h(),s(`p`,kt,[a(T,{icon:`fa-solid fa-bolt`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.task`))+`: `+i(n.taskTypeLabel),1)])):o(``,!0),e(`p`,At,[a(T,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(E,{content:n.modelValue?.id,class:`btn-copy`},null,8,[`content`])]),e(`p`,jt,[a(T,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.failureReason`))+`: `+i(n.modelValue?.response?.error?.message)+` `,1),a(E,{content:n.modelValue?.response?.error?.message,class:`btn-copy`},null,8,[`content`])]),n.modelValue?.elapsed?(h(),s(`p`,Mt,[a(T,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),n.modelValue?.response?.trace_id?(h(),s(`p`,Nt,[a(T,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(E,{content:n.modelValue?.response?.trace_id,class:`btn-copy`},null,8,[`content`])])):o(``,!0)]),_:1})])):(h(),s(`div`,$,[a(D,{closable:!1,class:`info`},{template:p(()=>[a(T,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.failure`)),1)]),default:p(()=>[n.modelValue?.request?.model?(h(),s(`p`,Pt,[a(T,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.modelValue?.request?.size?(h(),s(`p`,Ft,[a(T,{icon:`fa-solid fa-image`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.size`))+`: `+i(n.modelValue?.request?.size),1)])):o(``,!0),n.showTaskType?(h(),s(`p`,It,[a(T,{icon:`fa-solid fa-bolt`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.task`))+`: `+i(n.taskTypeLabel),1)])):o(``,!0),e(`p`,Lt,[a(T,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`openaiimage.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(E,{content:n.modelValue?.id,class:`btn-copy`},null,8,[`content`])])]),_:1})]))])])}var zt=_({name:`RecentPanel`,components:{TaskPreview:U(st,[[`render`,Rt],[`__scopeId`,`data-v-8ee5fb87`]]),BotPlaceholder:ue,NoTasks:de,ScrollList:se},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],data(){return{job:0}},computed:{tasks(){return{...this.$store.state.openaiimage?.tasks,items:this.$store.state.openaiimage?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),Bt={key:0},Vt={key:2,class:`w-full h-full flex items-center justify-center`};function Ht(e,t,n,r,i,u){let d=l(`bot-placeholder`),g=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return h(),s(c,null,[e.tasks?.items===void 0?(h(),s(`div`,Bt,[a(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(h(),f(_,{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:p(()=>[(h(!0),s(c,null,m(e.tasks?.items,e=>(h(),f(g,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(h(),s(`div`,Vt,[a(v)])):o(``,!0)],64)}var Ut=_({name:`OpenAIImageIndex`,components:{ConfigPanel:ot,Layout:ye,RecentPanel:U(zt,[[`render`,Ht]])},mixins:[z],inject:[`initialized`],data(){return{task:void 0,job:0,loading:!1}},computed:{applicationsLoading(){return this.$store.state.openaiimage?.status?.getApplications===W.Request},tasksLoading(){return this.$store.state.openaiimage?.status?.getTasks===W.Request},credential(){return this.$store.state.openaiimage?.credential},config(){return this.$store.state.openaiimage?.config},application(){return this.$store.state.openaiimage?.application},tasks(){return this.$store.state.openaiimage?.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 ce({tasks:this.tasks,getTasks:()=>this.tasks,loading:this.loading,setLoading:e=>this.loading=e,isBlocked:()=>this.tasksLoading,fetch:e=>this.onGetTasks({createdAtMax:e}),getScrollElement:()=>this.getTasksScrollElement()})},async onGetService(){console.debug(`start onGetService`),await this.$store.dispatch(`openaiimage/getService`),console.debug(`end onGetService`)},async onGetApplication(){console.debug(`start onGetApplication`),await this.$store.dispatch(`openaiimage/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.tasksLoading){console.debug(`loading`);return}console.debug(`start onGetTasks`,e);let{limit:t=20,createdAtMin:n,createdAtMax:r}=e||{};console.debug(`limit`,t,`createdAtMin`,n,`createdAtMax`,r),await this.$store.dispatch(`openaiimage/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})},async onGenerate(){if(!B(this.uploadTracker,e=>this.$t(e),e=>G.warning(e)))return;let e={...this.config||{}},t=Array.isArray(e?.image_urls)&&e.image_urls.length>0;if(!this.hasText(e.prompt)){G.error(this.$t(`openaiimage.message.promptRequired`));return}e.prompt=e.prompt.trim(),!t&&`image_urls`in e&&delete e.image_urls,e.size||delete e.size;let n={...e,action:`generate`,async:!0},r={action:`edit`,model:e?.model,prompt:e?.prompt,size:e?.size,image_urls:e?.image_urls||[],async:!0};if(!H())return;let i=this.credential?.token;if(!i){console.error(`no token specified`);return}G.info(this.$t(`openaiimage.message.startingTask`)),K(`openaiimage`,t?I.edit(r,{token:i}):I.generate(n,{token:i})).then(e=>{console.debug(`task accepted`,e.data?.task_id),G.success(this.$t(`openaiimage.message.startTaskSuccess`))}).catch(e=>{let t=e?.response?.data;t?.error?.code===`used_up`?G.error(this.$t(`openaiimage.message.usedUp`)):G.error(this.$t(`openaiimage.message.startTaskFailed`)+(t?.error?.message||``))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()},hasText(e){return typeof e==`string`&&e.trim().length>0}}});function Wt(e,t,n,r,i,o){let s=l(`config-panel`),c=l(`recent-panel`),u=l(`layout`);return h(),f(u,null,{config:p(()=>[a(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:p(()=>[a(c,{ref:`recentPanel`,loading:e.loading,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var Gt=U(Ut,[[`render`,Wt]]);export{Gt as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,ht as u,it as d,j as f,mt as p,qt as m,rt as h,tt as g,x as _,z as v}from"./vendor-chart-Dw-P17PN.js";import{r as y,t as b}from"./select-CVXgXqir.js";import{t as x}from"./upload-D-zDieUV.js";import{t as S}from"./tooltip-Cb1CIPoD.js";import{t as C}from"./image-DGnWsKHn.js";import{t as w}from"./alert-2qBdi1l1.js";import{t as T}from"./drawer-u1pTNeW8.js";import{At as E,Ct as D,Dt as O,Et as k,Ft as A,It as j,Mt as M,Nt as N,Ot as P,St as ee,Tt as te,jt as ne,kt as re,wt as F}from"./constants-Cm1pJ8kP.js";import{Ht as I,Kt as L,Ut as R,Vt as z,Wt as B,Xr as V,bn as H,en as U,j as W,qr as G,si as K,sr as q,vi as J}from"./index-DqpzpRT-.js";import{t as Y}from"./index.es-D7t9e-wf.js";import{t as X}from"./CopyToClipboard-BpPd8B8b.js";import{t as Z}from"./ImagePreview-BfslzHEU.js";import{n as ie}from"./taskDrawerMixin-DyAUhFEq.js";import{t as ae}from"./Consumption-Ch2waQDb.js";import{i as Q,n as oe,t as se}from"./pagination-CyeMpm2N.js";import{t as ce}from"./VideoPlayer-BzaeOeXh.js";import{t as le}from"./ApiCodeButton-D08Q_WRa.js";import{t as ue}from"./BotPlaceholder-Dn8d_dlZ.js";import{t as de}from"./NoTasks-Cox5rrM8.js";import{t as fe}from"./PromptTextarea-CEL2z0Ne.js";var pe=v({name:`LayoutGrokVideo`,components:{ElDrawer:T,ElButton:J,FontAwesomeIcon:Y},mixins:[ie]}),me={class:`main flex flex-row flex-1`},he={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},ge={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function _e(t,n,r,i,o,c){let f=l(`font-awesome-icon`),m=l(`el-button`),h=l(`el-drawer`);return g(),s(`div`,me,[e(`div`,he,[d(t.$slots,`config`,{},void 0,!0)]),e(`div`,ge,[d(t.$slots,`result`,{},void 0,!0)]),u(a(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:p(()=>[a(f,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!t.tasksEmpty]]),a(h,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`350px`},{default:p(()=>[d(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ve=W(pe,[[`render`,_e],[`__scopeId`,`data-v-76ddc288`]]),ye=v({name:`GrokVideoPromptInput`,components:{PromptTextarea:fe},computed:{prompt:{get(){return this.$store.state.grokvideo?.config?.prompt},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function be(e,t,n,r,i,a){let o=l(`prompt-textarea`);return g(),f(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`grokvideo.name.prompt`),info:e.$t(`grokvideo.description.prompt`),placeholder:e.$t(`grokvideo.placeholder.prompt`),"min-rows":5},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var xe=W(ye,[[`render`,be]]),Se=v({name:`GrokVideoModelSelector`,components:{ElSelect:y,ElOption:b,InfoIcon:Q},data(){return{options:[{value:P,label:this.$t(`grokvideo.model.default`)},{value:O,label:this.$t(`grokvideo.model.preview15`)}]}},computed:{value:{get(){return this.$store.state.grokvideo?.config?.model},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,model:e})}}},mounted(){this.value||=ee}}),Ce={class:`field`},we={class:`label`},Te={class:`box`},Ee={class:`title font-bold`};function De(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,Ce,[e(`div`,we,[e(`div`,Te,[e(`h2`,Ee,i(t.$t(`grokvideo.name.model`)),1),a(m,{content:t.$t(`grokvideo.description.model`),class:`info`},null,8,[`content`])])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`grokvideo.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Oe=W(Se,[[`render`,De],[`__scopeId`,`data-v-291d93fb`]]),ke=v({name:`GrokVideoDurationSelector`,components:{ElSelect:y,ElOption:b,InfoIcon:Q},computed:{model(){return this.$store.state.grokvideo?.config?.model},maxDuration(){return A(this.model)},options(){return te.filter(e=>e<=this.maxDuration).map(e=>({value:e,label:`${e}s`}))},value:{get(){return this.$store.state.grokvideo?.config?.duration},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,duration:e})}}},watch:{maxDuration(e){this.value&&this.value>e&&(this.value=e)}},mounted(){this.value||=8}}),Ae={class:`field`},je={class:`label`},Me={class:`box`},Ne={class:`title font-bold`};function Pe(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,Ae,[e(`div`,je,[e(`div`,Me,[e(`h2`,Ne,i(t.$t(`grokvideo.name.duration`)),1),a(m,{content:t.$t(`grokvideo.description.duration`),class:`info`},null,8,[`content`])])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`grokvideo.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Fe=W(ke,[[`render`,Pe],[`__scopeId`,`data-v-9c711686`]]),Ie=v({name:`GrokVideoResolutionSelector`,components:{InfoIcon:Q},data(){return{options:[{value:M,label:`480p`},{value:N,label:`720p`},{value:ne,label:`1080p`}]}},computed:{value:{get(){return this.$store.state.grokvideo?.config?.resolution},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,resolution:e})}}},mounted(){this.value||=F}}),Le={class:`resolution`},Re={class:`header`},ze={class:`title font-bold`},Be={class:`items`},Ve=[`onClick`];function He(t,r,o,u,d,f){let p=l(`info-icon`);return g(),s(`div`,Le,[e(`div`,Re,[e(`h2`,ze,i(t.$t(`grokvideo.name.resolution`)),1),a(p,{content:t.$t(`grokvideo.description.resolution`),class:`info`},null,8,[`content`])]),e(`div`,Be,[(g(!0),s(c,null,h(t.options,e=>(g(),s(`div`,{key:e.value,class:n([`item`,{active:t.value===e.value}]),onClick:n=>t.value=e.value},i(e.label),11,Ve))),128))])])}var Ue=W(Ie,[[`render`,He],[`__scopeId`,`data-v-54f22a22`]]),We=v({name:`GrokVideoRatioSelector`,components:{InfoIcon:Q},computed:{options(){return[{value:re,label:`16:9`,w:32,h:18},{value:E,label:`9:16`,w:18,h:32},{value:`1:1`,label:`1:1`,w:24,h:24},{value:`4:3`,label:`4:3`,w:28,h:21},{value:`3:4`,label:`3:4`,w:21,h:28},{value:`3:2`,label:`3:2`,w:30,h:20},{value:`2:3`,label:`2:3`,w:20,h:30}]},value:{get(){return this.$store.state.grokvideo?.config?.aspect_ratio},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,aspect_ratio:e})}}},mounted(){this.value||=D}}),Ge={class:`ratio`},Ke={class:`header`},qe={class:`title font-bold`},Je={class:`items`},Ye=[`onClick`],Xe={class:`preview`},Ze={class:`name`};function Qe(t,r,o,u,d,f){let p=l(`info-icon`);return g(),s(`div`,Ge,[e(`div`,Ke,[e(`h2`,qe,i(t.$t(`grokvideo.name.ratio`)),1),a(p,{content:t.$t(`grokvideo.description.ratio`),class:`info`},null,8,[`content`])]),e(`div`,Je,[(g(!0),s(c,null,h(t.options,r=>(g(),s(`div`,{key:r.value,class:n([`item`,{active:t.value===r.value}]),onClick:e=>t.value=r.value},[e(`div`,Xe,[e(`div`,{class:`rect`,style:m({width:r.w+`px`,height:r.h+`px`})},null,4)]),e(`div`,Ze,i(r.label),1)],10,Ye))),128))])])}var $e=W(We,[[`render`,Qe],[`__scopeId`,`data-v-70115284`]]),et=v({name:`GrokVideoImageInput`,components:{ElUpload:x,ElButton:J,InfoIcon:Q,FontAwesomeIcon:Y,ImagePreview:Z},mixins:[B,I],data(){return{fileList:[],uploadUrl:V()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},required(){return j(this.$store.state.grokvideo?.config?.model)},urls(){return this.fileList.map(e=>e?.response?.file_url)}},methods:{onExceed(){K.warning(this.$t(`grokvideo.message.uploadExceed`))},onError(){K.error(this.$t(`grokvideo.message.uploadError`))},onSetImageUrl(){let e=this.urls?.[0];this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,image_url:e||void 0})},async onSuccess(){this.onSetImageUrl()},async onRemove(){this.onSetImageUrl()}}}),tt={class:`relative`},nt={class:`flex justify-between`},rt={class:`flex justify-start items-center`},it={class:`text-sm font-bold`},at={key:0,class:`required-badge`};function ot(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-upload`);return g(),s(`div`,tt,[e(`div`,nt,[e(`div`,rt,[e(`span`,it,i(t.$t(`grokvideo.name.image`)),1),t.required?(g(),s(`span`,at,i(t.$t(`grokvideo.name.required`)),1)):o(``,!0),a(h,{content:t.$t(`grokvideo.description.image`)},null,8,[`content`])])]),a(b,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,"on-remove":t.onRemove,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`grokvideo.button.upload`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`on-remove`,`headers`])])}var st=W(et,[[`render`,ot],[`__scopeId`,`data-v-164e5a1d`]]),ct=4,lt=v({name:`GrokVideoReferenceImagesInput`,components:{ElUpload:x,ElButton:J,InfoIcon:Q,ImagePreview:Z,FontAwesomeIcon:Y},mixins:[B,I],data(){return{fileList:[],uploadUrl:V()+`/api/v1/files/`,limit:ct,suppressWatch:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url).filter(e=>!!e)||[]},value(){return this.$store.state.grokvideo?.config?.reference_image_urls}},watch:{value:{immediate:!0,handler(e){if(this.suppressWatch)return;if(!e||e.length===0){let e=(this.fileList||[]).filter(e=>!e?.response?.file_url);this.fileList=e.length?e:[];return}let t=[];e.forEach(e=>{let n=this.fileList.find(t=>t?.response?.file_url===e||t?.url===e);n?t.push(n):t.push({name:e.split(`/`).pop()||e,url:e,status:`success`,percentage:100,response:{file_url:e}})}),(this.fileList||[]).filter(e=>!e?.response?.file_url).forEach(e=>{t.some(t=>t===e||t?.url===e?.url||t?.response?.file_url===e?.response?.file_url)||t.push(e)}),this.fileList=t}}},methods:{onChange(e){if(!e?.url&&e?.raw)try{e.url=URL.createObjectURL(e.raw)}catch{}},onRemove(e){if(e?.url&&typeof e.url==`string`&&e.url.startsWith(`blob:`))try{URL.revokeObjectURL(e.url)}catch{}this.onSetReferenceImages()},onExceed(){K.warning(this.$t(`grokvideo.message.uploadReferenceExceed`))},onError(){K.error(this.$t(`grokvideo.message.uploadError`))},onSetReferenceImages(){let e=this.urls;this.suppressWatch=!0,this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,reference_image_urls:e.length?e:void 0}),this.$nextTick(()=>{this.suppressWatch=!1})},async onSuccess(e,t){e?.file_url&&(t.url=e.file_url,t.response=e),this.onSetReferenceImages()},onRemovePreview(e,t){if(this.fileList.splice(e,1),t?.url&&typeof t.url==`string`&&t.url.startsWith(`blob:`))try{URL.revokeObjectURL(t.url)}catch{}this.onSetReferenceImages()}}}),ut={class:`field flex items-center justify-between`},dt={class:`title font-bold text-[14px] mb-[10px]`},ft={class:`upload-wrapper flex flex-col items-start gap-[8px]`},pt={class:`controls flex items-center`},mt={class:`file-list flex flex-wrap gap-[10px]`};function ht(t,n,o,u,d,m){let _=l(`font-awesome-icon`),v=l(`el-button`),y=l(`el-upload`),b=l(`info-icon`),x=l(`image-preview`);return g(),s(c,null,[e(`div`,ut,[e(`h2`,dt,i(t.$t(`grokvideo.name.referenceImages`)),1),e(`div`,ft,[e(`div`,pt,[a(y,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,name:`file`,class:`value`,limit:t.limit,multiple:!0,"show-file-list":!1,action:t.uploadUrl,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,"on-change":t.onChange,"on-remove":t.onRemove,headers:t.headers},{default:p(()=>[a(v,{size:`small`,type:`primary`,round:``},{default:p(()=>[a(_,{icon:`fa-solid fa-upload`,class:`mr-1`}),r(` `+i(t.$t(`grokvideo.button.upload`)),1)]),_:1})]),_:1},8,[`file-list`,`limit`,`action`,`on-exceed`,`on-error`,`on-success`,`on-change`,`on-remove`,`headers`]),a(b,{content:t.$t(`grokvideo.description.referenceImages`),class:`ml-2`},null,8,[`content`])])])]),e(`div`,mt,[(g(!0),s(c,null,h(t.fileList,(e,n)=>(g(),f(x,{key:e.uid||e?.response?.file_url||e.url||n,url:e.url||e?.response?.file_url,name:e.name,percentage:e.percentage,onRemove:r=>t.onRemovePreview(n,e)},null,8,[`url`,`name`,`percentage`,`onRemove`]))),128))])],64)}var gt=v({name:`GrokVideoConfigPanel`,components:{ElButton:J,FontAwesomeIcon:Y,PromptInput:xe,ModelSelector:Oe,DurationSelector:Fe,ResolutionSelector:Ue,RatioSelector:$e,ImageInput:st,ReferenceImagesInput:W(lt,[[`render`,ht]]),Consumption:ae},emits:[`generate`],computed:{config(){return this.$store.state.grokvideo?.config},supportsReferenceImages(){return!j(this.$store.state.grokvideo?.config?.model)},consumption(){return L(this.config,this.service?.cost)},service(){return this.$store.state.grokvideo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),_t={class:`flex flex-col h-full`},vt={class:`flex-1 overflow-y-auto p-5`},yt={class:`flex flex-col items-center justify-center px-5 pb-5`};function bt(t,n,c,u,d,m){let h=l(`prompt-input`),_=l(`model-selector`),v=l(`ratio-selector`),y=l(`resolution-selector`),b=l(`duration-selector`),x=l(`image-input`),S=l(`reference-images-input`),C=l(`consumption`),w=l(`font-awesome-icon`),T=l(`el-button`);return g(),s(`div`,_t,[e(`div`,vt,[a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),a(v,{class:`mb-4`}),a(y,{class:`mb-4`}),a(b,{class:`mb-4`}),a(x,{class:`mb-2`}),t.supportsReferenceImages?(g(),f(S,{key:0,class:`mb-2`})):o(``,!0)]),e(`div`,yt,[a(C,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),a(T,{type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(w,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`grokvideo.button.generate`)),1)]),_:1},8,[`onClick`])])])}var xt=W(gt,[[`render`,bt]]),St=v({name:`GrokVideoTaskPreview`,components:{ElImage:C,CopyToClipboard:X,FontAwesomeIcon:Y,ElAlert:w,VideoPlayer:ce,ElTooltip:S,ElButton:J,ImagePreview:Z,ApiCodeButton:le},props:{modelValue:{type:Object,required:!0}},data(){return{grokVideoLogo:k,nowTs:Date.now(),timer:0}},computed:{video(){return this.modelValue?.response?.data?.[0]},inputImage(){return this.modelValue?.request?.image_url},pendingElapsed(){let e=parseFloat((this.modelValue?.created_at||``).toString());if(e)return Math.max(0,Math.floor(this.nowTs/1e3-e))}},watch:{"modelValue.response":{handler(e){e&&this.stopTimer()}}},mounted(){this.modelValue?.response||(this.timer=window.setInterval(()=>{this.nowTs=Date.now()},1e3))},beforeUnmount(){this.stopTimer()},methods:{stopTimer(){this.timer&&=(window.clearInterval(this.timer),0)},onDownload(e){window.open(e,`_blank`)}}}),Ct={class:`preview`},wt={class:`left`},Tt={class:`main`},Et={class:`bot`},Dt={class:`datetime`},Ot={class:`info`},kt={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},At={key:1,class:`prompt mt-2`},jt={key:0},Mt={key:1},Nt={key:0,class:n({content:!0})},Pt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ft={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},It={key:1,class:n({content:!0})},Lt={key:0,class:`mb-4`},Rt={key:1,class:n({operations:!0,"mt-2":!0,"mb-2":!0})},zt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Bt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Vt={key:0},Ht={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ut={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Wt={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Gt={key:2,class:n({content:!0})},Kt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Jt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Yt={key:3,class:n({content:!0})},Xt={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Zt(n,c,u,d,f,m){let h=l(`el-image`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`copy-to-clipboard`),b=l(`el-alert`),x=l(`video-player`),S=l(`el-button`),C=l(`el-tooltip`),w=l(`api-code-button`);return g(),s(`div`,Ct,[e(`div`,wt,[a(h,{src:n.grokVideoLogo,class:`avatar`},null,8,[`src`])]),e(`div`,Tt,[e(`div`,Et,[r(i(n.$t(`grokvideo.name.bot`))+` `,1),e(`span`,Dt,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,Ot,[n.inputImage?(g(),s(`div`,kt,[a(_,{url:n.inputImage,name:`image`,closable:!1},null,8,[`url`])])):o(``,!0),n.modelValue?.request?.prompt?(g(),s(`p`,At,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?n.video?.state===`processing`||n.video?.state===`pending`?(g(),s(`span`,Mt,` - (`+i(n.$t(`grokvideo.status.processing`))+`) `,1)):o(``,!0):(g(),s(`span`,jt,` - (`+i(n.$t(`grokvideo.status.pending`))+`) `,1))])):o(``,!0)]),n.modelValue?.response?n.modelValue?.response?.success===!0?(g(),s(`div`,It,[n.video?.video_url?(g(),s(`div`,Lt,[a(x,{src:n.video?.video_url},null,8,[`src`])])):o(``,!0),n.video?.video_url?(g(),s(`div`,Rt,[a(C,{class:`box-item`,effect:`dark`,content:n.$t(`grokvideo.message.downloadVideo`),placement:`top-start`},{default:p(()=>[a(S,{type:`info`,size:`small`,class:`btn-action`,onClick:c[0]||=t(e=>n.onDownload(n.video?.video_url),[`stop`])},{default:p(()=>[r(i(n.$t(`grokvideo.button.download`)),1)]),_:1})]),_:1},8,[`content`]),a(w,{path:`/grok/videos`,body:n.modelValue?.request},null,8,[`body`])])):o(``,!0),a(b,{closable:!1,class:`mt-2 success`},{default:p(()=>[n.modelValue?.request?.model?(g(),s(`p`,zt,[a(v,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.video?.duration?(g(),s(`p`,Bt,[a(v,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.duration`))+`: `+i(n.video?.duration)+`s `,1)])):o(``,!0),n.modelValue?.request?.resolution?(g(),s(`p`,$,[a(v,{icon:`fa-solid fa-expand`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.resolution`))+`: `+i(n.modelValue?.request?.resolution)+` `,1),n.modelValue?.request?.aspect_ratio?(g(),s(`span`,Vt,` · `+i(n.modelValue?.request?.aspect_ratio),1)):o(``,!0)])):o(``,!0),e(`p`,Ht,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.modelValue?.elapsed?(g(),s(`p`,Ut,[a(v,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),n.modelValue?.response?.trace_id?(g(),s(`p`,Wt,[a(v,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(y,{content:n.modelValue?.response?.trace_id,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0)]),_:1})])):n.modelValue?.response?.success===!1?(g(),s(`div`,Gt,[a(b,{closable:!1,class:`failure`},{template:p(()=>[a(v,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.failure`)),1)]),default:p(()=>[e(`p`,Kt,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.modelValue?.response?.error?.message?(g(),s(`p`,qt,[a(v,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.failureReason`))+`: `+i(n.modelValue?.response?.error?.message)+` `,1),a(y,{content:n.modelValue?.response?.error?.message,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0),n.modelValue?.response?.trace_id?(g(),s(`p`,Jt,[a(v,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(y,{content:n.modelValue?.response?.trace_id,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0)]),_:1})])):(g(),s(`div`,Yt,[a(b,{closable:!1,class:`info`},{template:p(()=>[a(v,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.status`)),1)]),default:p(()=>[e(`p`,Xt,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])])]),_:1})])):(g(),s(`div`,Nt,[a(b,{closable:!1,class:`info`},{template:p(()=>[a(v,{icon:`fa-regular fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.status.pending`)),1)]),default:p(()=>[e(`p`,Pt,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.pendingElapsed===void 0?o(``,!0):(g(),s(`p`,Ft,[a(v,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.elapsed`))+`: `+i(n.pendingElapsed)+`s `,1)]))]),_:1})]))])])}var Qt=v({name:`GrokVideoRecentPanel`,components:{TaskPreview:W(St,[[`render`,Zt],[`__scopeId`,`data-v-48f65a64`]]),BotPlaceholder:ue,NoTasks:de,ScrollList:oe},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],computed:{tasks(){return{...this.$store.state.grokvideo?.tasks,items:this.$store.state.grokvideo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),$t={key:0},en={key:2,class:`w-full h-full flex items-center justify-center`};function tn(e,t,n,r,i,u){let d=l(`bot-placeholder`),m=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return g(),s(c,null,[e.tasks?.items===void 0?(g(),s(`div`,$t,[a(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(g(),f(_,{key:1,ref:`scrollList`,class:`tasks w-full h-full overflow-y-auto`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:p(()=>[(g(!0),s(c,null,h(e.tasks?.items,e=>(g(),f(m,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(g(),s(`div`,en,[a(v)])):o(``,!0)],64)}var nn=v({name:`GrokVideoIndex`,components:{ConfigPanel:xt,Layout:ve,RecentPanel:W(Qt,[[`render`,tn]])},mixins:[R],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.grokvideo?.status?.getApplications===G.Request},tasksLoading(){return this.$store.state.grokvideo?.status?.getTasks===G.Request||this.fetchingTasks},credential(){return this.$store.state.grokvideo?.credential},config(){return this.$store.state.grokvideo?.config},tasks(){return this.$store.state.grokvideo?.tasks}},watch:{initialized:{async handler(e){e&&(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 se({tasks: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(){await this.$store.dispatch(`grokvideo/getService`)},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks)return;let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};this.fetchingTasks=!0;try{await this.$store.dispatch(`grokvideo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!z(this.uploadTracker,e=>this.$t(e),e=>K.warning(e)))return;let e={...this.config||{}};typeof e?.prompt==`string`&&(e.prompt=e.prompt.trim(),e.prompt||delete e.prompt),typeof e?.image_url==`string`&&!e.image_url.trim()&&delete e.image_url,(j(e?.model)||!(Array.isArray(e?.reference_image_urls)&&e.reference_image_urls.length))&&delete e.reference_image_urls;let t=!!e?.image_url;if(j(e?.model)&&!t){K.warning(this.$t(`grokvideo.message.modelRequiresImage`));return}if(!t&&!e?.prompt){K.warning(this.$t(`grokvideo.message.promptOrImageRequired`));return}let n={...e,async:!0};if(!U())return;let r=this.credential?.token;if(!r){console.error(`no token specified`);return}K.info(this.$t(`grokvideo.message.startingTask`)),q(`grokvideo`,H.generate(n,{token:r})).then(()=>{K.success(this.$t(`grokvideo.message.startTaskSuccess`))}).catch(e=>{let t=e?.response?.data;t?.error?.code===`used_up`?K.error(this.$t(`grokvideo.message.usedUp`)):K.error(this.$t(`grokvideo.message.startTaskFailed`)+(t?.error?.message||``))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function rn(e,t,n,r,i,o){let s=l(`config-panel`),c=l(`recent-panel`),u=l(`layout`);return g(),f(u,null,{config:p(()=>[a(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:p(()=>[a(c,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var an=W(nn,[[`render`,rn]]);export{an as default};
1
+ import"./rolldown-runtime--c01j_DQ.js";import{A as e,C as t,Gt as n,I as r,Jt as i,L as a,M as o,N as s,T as c,at as l,ht as u,it as d,j as f,mt as p,qt as m,rt as h,tt as g,x as _,z as v}from"./vendor-chart-Dw-P17PN.js";import{r as y,t as b}from"./select-B0Rytq57.js";import{t as x}from"./upload-CKPXpkhw.js";import{t as S}from"./tooltip-DMkRuyNr.js";import{t as C}from"./image-C_wGl_Tq.js";import{t as w}from"./alert-9UHbWOgh.js";import{t as T}from"./drawer-BhyqFLuj.js";import{At as E,Ct as D,Dt as O,Et as k,Ft as A,It as j,Mt as M,Nt as N,Ot as P,St as ee,Tt as te,jt as ne,kt as re,wt as F}from"./constants-Cm1pJ8kP.js";import{Ht as I,Kt as L,Ut as R,Vt as z,Wt as B,Xr as V,bn as H,en as U,j as W,qr as G,si as K,sr as q,vi as J}from"./index-CEsOXc02.js";import{t as Y}from"./index.es-CZ18ogLi.js";import{t as X}from"./CopyToClipboard-BDHrbE9N.js";import{t as Z}from"./ImagePreview-CBJ5UBky.js";import{n as ie}from"./taskDrawerMixin-DyAUhFEq.js";import{t as ae}from"./Consumption-0ipkiA5W.js";import{i as Q,n as oe,t as se}from"./pagination-UvuFCwzm.js";import{t as ce}from"./VideoPlayer-CUG8KpLW.js";import{t as le}from"./ApiCodeButton-WbUyGTD7.js";import{t as ue}from"./BotPlaceholder-DeEtrFs6.js";import{t as de}from"./NoTasks-CF_GuqSx.js";import{t as fe}from"./PromptTextarea-JRe0Kgab.js";var pe=v({name:`LayoutGrokVideo`,components:{ElDrawer:T,ElButton:J,FontAwesomeIcon:Y},mixins:[ie]}),me={class:`main flex flex-row flex-1`},he={class:`config w-[320px] flex-none h-full overflow-y-auto bg-[var(--app-sidebar-bg)] border-r border-[var(--app-border-subtle)]`},ge={class:`result h-full p-6 flex-1 flex flex-col min-w-0 overflow-x-hidden bg-[var(--app-content-bg)]`};function _e(t,n,r,i,o,c){let f=l(`font-awesome-icon`),m=l(`el-button`),h=l(`el-drawer`);return g(),s(`div`,me,[e(`div`,he,[d(t.$slots,`config`,{},void 0,!0)]),e(`div`,ge,[d(t.$slots,`result`,{},void 0,!0)]),u(a(m,{circle:``,class:`menu`,onClick:n[0]||=e=>t.drawer=!0},{default:p(()=>[a(f,{icon:`fa-solid fa-magic`})]),_:1},512),[[_,!t.tasksEmpty]]),a(h,{modelValue:t.drawer,"onUpdate:modelValue":n[1]||=e=>t.drawer=e,direction:`ltr`,"with-header":!1,size:`350px`},{default:p(()=>[d(t.$slots,`config`,{},void 0,!0)]),_:3},8,[`modelValue`])])}var ve=W(pe,[[`render`,_e],[`__scopeId`,`data-v-76ddc288`]]),ye=v({name:`GrokVideoPromptInput`,components:{PromptTextarea:fe},computed:{prompt:{get(){return this.$store.state.grokvideo?.config?.prompt},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,prompt:e})}}},mounted(){this.prompt||=``}});function be(e,t,n,r,i,a){let o=l(`prompt-textarea`);return g(),f(o,{modelValue:e.prompt,"onUpdate:modelValue":t[0]||=t=>e.prompt=t,title:e.$t(`grokvideo.name.prompt`),info:e.$t(`grokvideo.description.prompt`),placeholder:e.$t(`grokvideo.placeholder.prompt`),"min-rows":5},null,8,[`modelValue`,`title`,`info`,`placeholder`])}var xe=W(ye,[[`render`,be]]),Se=v({name:`GrokVideoModelSelector`,components:{ElSelect:y,ElOption:b,InfoIcon:Q},data(){return{options:[{value:P,label:this.$t(`grokvideo.model.default`)},{value:O,label:this.$t(`grokvideo.model.preview15`)}]}},computed:{value:{get(){return this.$store.state.grokvideo?.config?.model},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,model:e})}}},mounted(){this.value||=ee}}),Ce={class:`field`},we={class:`label`},Te={class:`box`},Ee={class:`title font-bold`};function De(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,Ce,[e(`div`,we,[e(`div`,Te,[e(`h2`,Ee,i(t.$t(`grokvideo.name.model`)),1),a(m,{content:t.$t(`grokvideo.description.model`),class:`info`},null,8,[`content`])])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`grokvideo.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Oe=W(Se,[[`render`,De],[`__scopeId`,`data-v-291d93fb`]]),ke=v({name:`GrokVideoDurationSelector`,components:{ElSelect:y,ElOption:b,InfoIcon:Q},computed:{model(){return this.$store.state.grokvideo?.config?.model},maxDuration(){return A(this.model)},options(){return te.filter(e=>e<=this.maxDuration).map(e=>({value:e,label:`${e}s`}))},value:{get(){return this.$store.state.grokvideo?.config?.duration},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,duration:e})}}},watch:{maxDuration(e){this.value&&this.value>e&&(this.value=e)}},mounted(){this.value||=8}}),Ae={class:`field`},je={class:`label`},Me={class:`box`},Ne={class:`title font-bold`};function Pe(t,n,r,o,u,d){let m=l(`info-icon`),_=l(`el-option`),v=l(`el-select`);return g(),s(`div`,Ae,[e(`div`,je,[e(`div`,Me,[e(`h2`,Ne,i(t.$t(`grokvideo.name.duration`)),1),a(m,{content:t.$t(`grokvideo.description.duration`),class:`info`},null,8,[`content`])])]),a(v,{modelValue:t.value,"onUpdate:modelValue":n[0]||=e=>t.value=e,class:`value`,placeholder:t.$t(`grokvideo.placeholder.select`)},{default:p(()=>[(g(!0),s(c,null,h(t.options,e=>(g(),f(_,{key:e.value,label:e.label,value:e.value},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`])])}var Fe=W(ke,[[`render`,Pe],[`__scopeId`,`data-v-9c711686`]]),Ie=v({name:`GrokVideoResolutionSelector`,components:{InfoIcon:Q},data(){return{options:[{value:M,label:`480p`},{value:N,label:`720p`},{value:ne,label:`1080p`}]}},computed:{value:{get(){return this.$store.state.grokvideo?.config?.resolution},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,resolution:e})}}},mounted(){this.value||=F}}),Le={class:`resolution`},Re={class:`header`},ze={class:`title font-bold`},Be={class:`items`},Ve=[`onClick`];function He(t,r,o,u,d,f){let p=l(`info-icon`);return g(),s(`div`,Le,[e(`div`,Re,[e(`h2`,ze,i(t.$t(`grokvideo.name.resolution`)),1),a(p,{content:t.$t(`grokvideo.description.resolution`),class:`info`},null,8,[`content`])]),e(`div`,Be,[(g(!0),s(c,null,h(t.options,e=>(g(),s(`div`,{key:e.value,class:n([`item`,{active:t.value===e.value}]),onClick:n=>t.value=e.value},i(e.label),11,Ve))),128))])])}var Ue=W(Ie,[[`render`,He],[`__scopeId`,`data-v-54f22a22`]]),We=v({name:`GrokVideoRatioSelector`,components:{InfoIcon:Q},computed:{options(){return[{value:re,label:`16:9`,w:32,h:18},{value:E,label:`9:16`,w:18,h:32},{value:`1:1`,label:`1:1`,w:24,h:24},{value:`4:3`,label:`4:3`,w:28,h:21},{value:`3:4`,label:`3:4`,w:21,h:28},{value:`3:2`,label:`3:2`,w:30,h:20},{value:`2:3`,label:`2:3`,w:20,h:30}]},value:{get(){return this.$store.state.grokvideo?.config?.aspect_ratio},set(e){this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,aspect_ratio:e})}}},mounted(){this.value||=D}}),Ge={class:`ratio`},Ke={class:`header`},qe={class:`title font-bold`},Je={class:`items`},Ye=[`onClick`],Xe={class:`preview`},Ze={class:`name`};function Qe(t,r,o,u,d,f){let p=l(`info-icon`);return g(),s(`div`,Ge,[e(`div`,Ke,[e(`h2`,qe,i(t.$t(`grokvideo.name.ratio`)),1),a(p,{content:t.$t(`grokvideo.description.ratio`),class:`info`},null,8,[`content`])]),e(`div`,Je,[(g(!0),s(c,null,h(t.options,r=>(g(),s(`div`,{key:r.value,class:n([`item`,{active:t.value===r.value}]),onClick:e=>t.value=r.value},[e(`div`,Xe,[e(`div`,{class:`rect`,style:m({width:r.w+`px`,height:r.h+`px`})},null,4)]),e(`div`,Ze,i(r.label),1)],10,Ye))),128))])])}var $e=W(We,[[`render`,Qe],[`__scopeId`,`data-v-70115284`]]),et=v({name:`GrokVideoImageInput`,components:{ElUpload:x,ElButton:J,InfoIcon:Q,FontAwesomeIcon:Y,ImagePreview:Z},mixins:[B,I],data(){return{fileList:[],uploadUrl:V()+`/api/v1/files/`}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},required(){return j(this.$store.state.grokvideo?.config?.model)},urls(){return this.fileList.map(e=>e?.response?.file_url)}},methods:{onExceed(){K.warning(this.$t(`grokvideo.message.uploadExceed`))},onError(){K.error(this.$t(`grokvideo.message.uploadError`))},onSetImageUrl(){let e=this.urls?.[0];this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,image_url:e||void 0})},async onSuccess(){this.onSetImageUrl()},async onRemove(){this.onSetImageUrl()}}}),tt={class:`relative`},nt={class:`flex justify-between`},rt={class:`flex justify-start items-center`},it={class:`text-sm font-bold`},at={key:0,class:`required-badge`};function ot(t,n,c,u,d,m){let h=l(`info-icon`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`el-button`),b=l(`el-upload`);return g(),s(`div`,tt,[e(`div`,nt,[e(`div`,rt,[e(`span`,it,i(t.$t(`grokvideo.name.image`)),1),t.required?(g(),s(`span`,at,i(t.$t(`grokvideo.name.required`)),1)):o(``,!0),a(h,{content:t.$t(`grokvideo.description.image`)},null,8,[`content`])])]),a(b,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,name:`file`,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,limit:1,class:`upload-wrapper`,multiple:!1,action:t.uploadUrl,"list-type":`picture`,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,"on-remove":t.onRemove,headers:t.headers},{file:p(({file:e})=>[e.url&&e.percentage!==void 0?(g(),f(_,{key:0,url:e.url,name:e.name,percentage:e.percentage,onRemove:n=>t.fileList.splice(t.fileList.indexOf(e),1)},null,8,[`url`,`name`,`percentage`,`onRemove`])):o(``,!0)]),default:p(()=>[a(y,{round:``,type:`primary`,size:`small`,class:`btn btn-upload`},{default:p(()=>[a(v,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),r(` `+i(t.$t(`grokvideo.button.upload`)),1)]),_:1})]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`on-remove`,`headers`])])}var st=W(et,[[`render`,ot],[`__scopeId`,`data-v-164e5a1d`]]),ct=4,lt=v({name:`GrokVideoReferenceImagesInput`,components:{ElUpload:x,ElButton:J,InfoIcon:Q,ImagePreview:Z,FontAwesomeIcon:Y},mixins:[B,I],data(){return{fileList:[],uploadUrl:V()+`/api/v1/files/`,limit:ct,suppressWatch:!1}},computed:{headers(){return{Authorization:`Bearer ${this.$store.state.token.access}`}},urls(){return this.fileList.map(e=>e?.response?.file_url).filter(e=>!!e)||[]},value(){return this.$store.state.grokvideo?.config?.reference_image_urls}},watch:{value:{immediate:!0,handler(e){if(this.suppressWatch)return;if(!e||e.length===0){let e=(this.fileList||[]).filter(e=>!e?.response?.file_url);this.fileList=e.length?e:[];return}let t=[];e.forEach(e=>{let n=this.fileList.find(t=>t?.response?.file_url===e||t?.url===e);n?t.push(n):t.push({name:e.split(`/`).pop()||e,url:e,status:`success`,percentage:100,response:{file_url:e}})}),(this.fileList||[]).filter(e=>!e?.response?.file_url).forEach(e=>{t.some(t=>t===e||t?.url===e?.url||t?.response?.file_url===e?.response?.file_url)||t.push(e)}),this.fileList=t}}},methods:{onChange(e){if(!e?.url&&e?.raw)try{e.url=URL.createObjectURL(e.raw)}catch{}},onRemove(e){if(e?.url&&typeof e.url==`string`&&e.url.startsWith(`blob:`))try{URL.revokeObjectURL(e.url)}catch{}this.onSetReferenceImages()},onExceed(){K.warning(this.$t(`grokvideo.message.uploadReferenceExceed`))},onError(){K.error(this.$t(`grokvideo.message.uploadError`))},onSetReferenceImages(){let e=this.urls;this.suppressWatch=!0,this.$store.commit(`grokvideo/setConfig`,{...this.$store.state.grokvideo?.config,reference_image_urls:e.length?e:void 0}),this.$nextTick(()=>{this.suppressWatch=!1})},async onSuccess(e,t){e?.file_url&&(t.url=e.file_url,t.response=e),this.onSetReferenceImages()},onRemovePreview(e,t){if(this.fileList.splice(e,1),t?.url&&typeof t.url==`string`&&t.url.startsWith(`blob:`))try{URL.revokeObjectURL(t.url)}catch{}this.onSetReferenceImages()}}}),ut={class:`field flex items-center justify-between`},dt={class:`title font-bold text-[14px] mb-[10px]`},ft={class:`upload-wrapper flex flex-col items-start gap-[8px]`},pt={class:`controls flex items-center`},mt={class:`file-list flex flex-wrap gap-[10px]`};function ht(t,n,o,u,d,m){let _=l(`font-awesome-icon`),v=l(`el-button`),y=l(`el-upload`),b=l(`info-icon`),x=l(`image-preview`);return g(),s(c,null,[e(`div`,ut,[e(`h2`,dt,i(t.$t(`grokvideo.name.referenceImages`)),1),e(`div`,ft,[e(`div`,pt,[a(y,{ref:`uploader`,"file-list":t.fileList,"onUpdate:fileList":n[0]||=e=>t.fileList=e,accept:`.png,.jpg,.jpeg,.gif,.bmp,.webp`,name:`file`,class:`value`,limit:t.limit,multiple:!0,"show-file-list":!1,action:t.uploadUrl,"on-exceed":t.onExceed,"on-error":t.onError,"on-success":t.onSuccess,"on-change":t.onChange,"on-remove":t.onRemove,headers:t.headers},{default:p(()=>[a(v,{size:`small`,type:`primary`,round:``},{default:p(()=>[a(_,{icon:`fa-solid fa-upload`,class:`mr-1`}),r(` `+i(t.$t(`grokvideo.button.upload`)),1)]),_:1})]),_:1},8,[`file-list`,`limit`,`action`,`on-exceed`,`on-error`,`on-success`,`on-change`,`on-remove`,`headers`]),a(b,{content:t.$t(`grokvideo.description.referenceImages`),class:`ml-2`},null,8,[`content`])])])]),e(`div`,mt,[(g(!0),s(c,null,h(t.fileList,(e,n)=>(g(),f(x,{key:e.uid||e?.response?.file_url||e.url||n,url:e.url||e?.response?.file_url,name:e.name,percentage:e.percentage,onRemove:r=>t.onRemovePreview(n,e)},null,8,[`url`,`name`,`percentage`,`onRemove`]))),128))])],64)}var gt=v({name:`GrokVideoConfigPanel`,components:{ElButton:J,FontAwesomeIcon:Y,PromptInput:xe,ModelSelector:Oe,DurationSelector:Fe,ResolutionSelector:Ue,RatioSelector:$e,ImageInput:st,ReferenceImagesInput:W(lt,[[`render`,ht]]),Consumption:ae},emits:[`generate`],computed:{config(){return this.$store.state.grokvideo?.config},supportsReferenceImages(){return!j(this.$store.state.grokvideo?.config?.model)},consumption(){return L(this.config,this.service?.cost)},service(){return this.$store.state.grokvideo?.service}},methods:{onGenerate(){this.$emit(`generate`)}}}),_t={class:`flex flex-col h-full`},vt={class:`flex-1 overflow-y-auto p-5`},yt={class:`flex flex-col items-center justify-center px-5 pb-5`};function bt(t,n,c,u,d,m){let h=l(`prompt-input`),_=l(`model-selector`),v=l(`ratio-selector`),y=l(`resolution-selector`),b=l(`duration-selector`),x=l(`image-input`),S=l(`reference-images-input`),C=l(`consumption`),w=l(`font-awesome-icon`),T=l(`el-button`);return g(),s(`div`,_t,[e(`div`,vt,[a(h,{class:`mb-4`}),a(_,{class:`mb-4`}),a(v,{class:`mb-4`}),a(y,{class:`mb-4`}),a(b,{class:`mb-4`}),a(x,{class:`mb-2`}),t.supportsReferenceImages?(g(),f(S,{key:0,class:`mb-2`})):o(``,!0)]),e(`div`,yt,[a(C,{value:t.consumption,service:t.service},null,8,[`value`,`service`]),a(T,{type:`primary`,class:`btn w-full`,round:``,onClick:t.onGenerate},{default:p(()=>[a(w,{icon:`fa-solid fa-magic`,class:`mr-2`}),r(` `+i(t.$t(`grokvideo.button.generate`)),1)]),_:1},8,[`onClick`])])])}var xt=W(gt,[[`render`,bt]]),St=v({name:`GrokVideoTaskPreview`,components:{ElImage:C,CopyToClipboard:X,FontAwesomeIcon:Y,ElAlert:w,VideoPlayer:ce,ElTooltip:S,ElButton:J,ImagePreview:Z,ApiCodeButton:le},props:{modelValue:{type:Object,required:!0}},data(){return{grokVideoLogo:k,nowTs:Date.now(),timer:0}},computed:{video(){return this.modelValue?.response?.data?.[0]},inputImage(){return this.modelValue?.request?.image_url},pendingElapsed(){let e=parseFloat((this.modelValue?.created_at||``).toString());if(e)return Math.max(0,Math.floor(this.nowTs/1e3-e))}},watch:{"modelValue.response":{handler(e){e&&this.stopTimer()}}},mounted(){this.modelValue?.response||(this.timer=window.setInterval(()=>{this.nowTs=Date.now()},1e3))},beforeUnmount(){this.stopTimer()},methods:{stopTimer(){this.timer&&=(window.clearInterval(this.timer),0)},onDownload(e){window.open(e,`_blank`)}}}),Ct={class:`preview`},wt={class:`left`},Tt={class:`main`},Et={class:`bot`},Dt={class:`datetime`},Ot={class:`info`},kt={key:0,class:`flex justify-start items-center gap-2 mt-2 w-full overflow-x-auto`},At={key:1,class:`prompt mt-2`},jt={key:0},Mt={key:1},Nt={key:0,class:n({content:!0})},Pt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ft={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},It={key:1,class:n({content:!0})},Lt={key:0,class:`mb-4`},Rt={key:1,class:n({operations:!0,"mt-2":!0,"mb-2":!0})},zt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Bt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},$={key:2,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Vt={key:0},Ht={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Ut={key:3,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Wt={key:4,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Gt={key:2,class:n({content:!0})},Kt={class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qt={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},Jt={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Yt={key:3,class:n({content:!0})},Xt={class:`text-[var(--el-text-color-regular)] text-xs mb-0`};function Zt(n,c,u,d,f,m){let h=l(`el-image`),_=l(`image-preview`),v=l(`font-awesome-icon`),y=l(`copy-to-clipboard`),b=l(`el-alert`),x=l(`video-player`),S=l(`el-button`),C=l(`el-tooltip`),w=l(`api-code-button`);return g(),s(`div`,Ct,[e(`div`,wt,[a(h,{src:n.grokVideoLogo,class:`avatar`},null,8,[`src`])]),e(`div`,Tt,[e(`div`,Et,[r(i(n.$t(`grokvideo.name.bot`))+` `,1),e(`span`,Dt,i(n.$dayjs.format(``+new Date(parseFloat((n.modelValue?.created_at||``).toString())*1e3))),1)]),e(`div`,Ot,[n.inputImage?(g(),s(`div`,kt,[a(_,{url:n.inputImage,name:`image`,closable:!1},null,8,[`url`])])):o(``,!0),n.modelValue?.request?.prompt?(g(),s(`p`,At,[r(i(n.modelValue?.request?.prompt)+` `,1),n.modelValue?.response?n.video?.state===`processing`||n.video?.state===`pending`?(g(),s(`span`,Mt,` - (`+i(n.$t(`grokvideo.status.processing`))+`) `,1)):o(``,!0):(g(),s(`span`,jt,` - (`+i(n.$t(`grokvideo.status.pending`))+`) `,1))])):o(``,!0)]),n.modelValue?.response?n.modelValue?.response?.success===!0?(g(),s(`div`,It,[n.video?.video_url?(g(),s(`div`,Lt,[a(x,{src:n.video?.video_url},null,8,[`src`])])):o(``,!0),n.video?.video_url?(g(),s(`div`,Rt,[a(C,{class:`box-item`,effect:`dark`,content:n.$t(`grokvideo.message.downloadVideo`),placement:`top-start`},{default:p(()=>[a(S,{type:`info`,size:`small`,class:`btn-action`,onClick:c[0]||=t(e=>n.onDownload(n.video?.video_url),[`stop`])},{default:p(()=>[r(i(n.$t(`grokvideo.button.download`)),1)]),_:1})]),_:1},8,[`content`]),a(w,{path:`/grok/videos`,body:n.modelValue?.request},null,8,[`body`])])):o(``,!0),a(b,{closable:!1,class:`mt-2 success`},{default:p(()=>[n.modelValue?.request?.model?(g(),s(`p`,zt,[a(v,{icon:`fa-solid fa-cube`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.model`))+`: `+i(n.modelValue?.request?.model),1)])):o(``,!0),n.video?.duration?(g(),s(`p`,Bt,[a(v,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.duration`))+`: `+i(n.video?.duration)+`s `,1)])):o(``,!0),n.modelValue?.request?.resolution?(g(),s(`p`,$,[a(v,{icon:`fa-solid fa-expand`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.resolution`))+`: `+i(n.modelValue?.request?.resolution)+` `,1),n.modelValue?.request?.aspect_ratio?(g(),s(`span`,Vt,` · `+i(n.modelValue?.request?.aspect_ratio),1)):o(``,!0)])):o(``,!0),e(`p`,Ht,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.modelValue?.elapsed?(g(),s(`p`,Ut,[a(v,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.elapsed`))+`: `+i(n.modelValue?.elapsed?.toFixed(2))+`s `,1)])):o(``,!0),n.modelValue?.response?.trace_id?(g(),s(`p`,Wt,[a(v,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(y,{content:n.modelValue?.response?.trace_id,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0)]),_:1})])):n.modelValue?.response?.success===!1?(g(),s(`div`,Gt,[a(b,{closable:!1,class:`failure`},{template:p(()=>[a(v,{icon:`fa-solid fa-exclamation-triangle`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.failure`)),1)]),default:p(()=>[e(`p`,Kt,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.modelValue?.response?.error?.message?(g(),s(`p`,qt,[a(v,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.failureReason`))+`: `+i(n.modelValue?.response?.error?.message)+` `,1),a(y,{content:n.modelValue?.response?.error?.message,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0),n.modelValue?.response?.trace_id?(g(),s(`p`,Jt,[a(v,{icon:`fa-solid fa-hashtag`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.traceId`))+`: `+i(n.modelValue?.response?.trace_id)+` `,1),a(y,{content:n.modelValue?.response?.trace_id,class:`btn-copy inline-block`},null,8,[`content`])])):o(``,!0)]),_:1})])):(g(),s(`div`,Yt,[a(b,{closable:!1,class:`info`},{template:p(()=>[a(v,{icon:`fa-solid fa-circle-info`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.status`)),1)]),default:p(()=>[e(`p`,Xt,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])])]),_:1})])):(g(),s(`div`,Nt,[a(b,{closable:!1,class:`info`},{template:p(()=>[a(v,{icon:`fa-regular fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.status.pending`)),1)]),default:p(()=>[e(`p`,Pt,[a(v,{icon:`fa-solid fa-magic`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.taskId`))+`: `+i(n.modelValue?.id)+` `,1),a(y,{content:n.modelValue?.id,class:`btn-copy inline-block`},null,8,[`content`])]),n.pendingElapsed===void 0?o(``,!0):(g(),s(`p`,Ft,[a(v,{icon:`fa-solid fa-clock`,class:`mr-1`}),r(` `+i(n.$t(`grokvideo.name.elapsed`))+`: `+i(n.pendingElapsed)+`s `,1)]))]),_:1})]))])])}var Qt=v({name:`GrokVideoRecentPanel`,components:{TaskPreview:W(St,[[`render`,Zt],[`__scopeId`,`data-v-48f65a64`]]),BotPlaceholder:ue,NoTasks:de,ScrollList:oe},props:{loading:{type:Boolean,default:!1}},emits:[`reach-top`],computed:{tasks(){return{...this.$store.state.grokvideo?.tasks,items:this.$store.state.grokvideo?.tasks?.items?.slice()}}},methods:{getScrollElement(){return this.$refs.scrollList?.getScrollElement?.()}}}),$t={key:0},en={key:2,class:`w-full h-full flex items-center justify-center`};function tn(e,t,n,r,i,u){let d=l(`bot-placeholder`),m=l(`task-preview`),_=l(`scroll-list`),v=l(`no-tasks`);return g(),s(c,null,[e.tasks?.items===void 0?(g(),s(`div`,$t,[a(d)])):e.tasks?.items?.length&&e.tasks?.items?.length>0?(g(),f(_,{key:1,ref:`scrollList`,class:`tasks w-full h-full overflow-y-auto`,loading:e.loading,onReachTop:t[0]||=t=>e.$emit(`reach-top`)},{default:p(()=>[(g(!0),s(c,null,h(e.tasks?.items,e=>(g(),f(m,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]),_:1},8,[`loading`])):o(``,!0),e.tasks?.items?.length===0?(g(),s(`div`,en,[a(v)])):o(``,!0)],64)}var nn=v({name:`GrokVideoIndex`,components:{ConfigPanel:xt,Layout:ve,RecentPanel:W(Qt,[[`render`,tn]])},mixins:[R],inject:[`initialized`],data(){return{task:void 0,job:0,loadingMore:!1,fetchingTasks:!1}},computed:{applicationsLoading(){return this.$store.state.grokvideo?.status?.getApplications===G.Request},tasksLoading(){return this.$store.state.grokvideo?.status?.getTasks===G.Request||this.fetchingTasks},credential(){return this.$store.state.grokvideo?.credential},config(){return this.$store.state.grokvideo?.config},tasks(){return this.$store.state.grokvideo?.tasks}},watch:{initialized:{async handler(e){e&&(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 se({tasks: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(){await this.$store.dispatch(`grokvideo/getService`)},async onScrollDown(){await this.$nextTick();let e=this.getTasksScrollElement();e&&(e.scrollTop=e.scrollHeight)},async onGetTasks(e){if(this.applicationsLoading||this.fetchingTasks)return;let{limit:t=5,createdAtMin:n,createdAtMax:r}=e||{};this.fetchingTasks=!0;try{await this.$store.dispatch(`grokvideo/getTasks`,{limit:t,createdAtMin:n,createdAtMax:r})}finally{this.fetchingTasks=!1}},async onGenerate(){if(!z(this.uploadTracker,e=>this.$t(e),e=>K.warning(e)))return;let e={...this.config||{}};typeof e?.prompt==`string`&&(e.prompt=e.prompt.trim(),e.prompt||delete e.prompt),typeof e?.image_url==`string`&&!e.image_url.trim()&&delete e.image_url,(j(e?.model)||!(Array.isArray(e?.reference_image_urls)&&e.reference_image_urls.length))&&delete e.reference_image_urls;let t=!!e?.image_url;if(j(e?.model)&&!t){K.warning(this.$t(`grokvideo.message.modelRequiresImage`));return}if(!t&&!e?.prompt){K.warning(this.$t(`grokvideo.message.promptOrImageRequired`));return}let n={...e,async:!0};if(!U())return;let r=this.credential?.token;if(!r){console.error(`no token specified`);return}K.info(this.$t(`grokvideo.message.startingTask`)),q(`grokvideo`,H.generate(n,{token:r})).then(()=>{K.success(this.$t(`grokvideo.message.startTaskSuccess`))}).catch(e=>{let t=e?.response?.data;t?.error?.code===`used_up`?K.error(this.$t(`grokvideo.message.usedUp`)):K.error(this.$t(`grokvideo.message.startTaskFailed`)+(t?.error?.message||``))}).finally(async()=>{setTimeout(async()=>{await this.onGetTasks(),await this.onScrollDown()},1e3)})},getTasksScrollElement(){return this.$refs.recentPanel?.getScrollElement?.()}}});function rn(e,t,n,r,i,o){let s=l(`config-panel`),c=l(`recent-panel`),u=l(`layout`);return g(),f(u,null,{config:p(()=>[a(s,{onGenerate:e.onGenerate},null,8,[`onGenerate`])]),result:p(()=>[a(c,{ref:`recentPanel`,loading:e.loadingMore,onReachTop:e.onReachTop},null,8,[`loading`,`onReachTop`])]),_:1})}var an=W(nn,[[`render`,rn]]);export{an as default};