clipoox-render 0.4.7 → 0.4.8

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 (142) hide show
  1. package/package.json +2 -2
  2. package/scripts/render-local.mjs +2367 -1534
  3. package/shared/photocraft/LICENSE.txt +206 -0
  4. package/shared/photocraft/clipoox_photo.js +396 -0
  5. package/shared/photocraft/clipoox_photo_bg.wasm +0 -0
  6. package/web/assets/{FxEmbed-B-D-tbgP.js → FxEmbed-adbxHEBi.js} +1 -1
  7. package/web/assets/ImageStudio-CMxiT1jp.js +3 -0
  8. package/web/assets/ImageStudio-De_DCTrz.css +1 -0
  9. package/web/assets/{MotionEmbed-eB-zRpv9.js → MotionEmbed-CDUIyjk0.js} +1 -1
  10. package/web/assets/{PluginStore-D6UvvVXA.js → PluginStore-By_pdOOg.js} +2 -2
  11. package/web/assets/ShotComposer-DcwWZ-eP.css +1 -0
  12. package/web/assets/ShotComposer-XIbJ4nNm.js +287 -0
  13. package/web/assets/{TemplateEmbed-DZNaQAJ-.js → TemplateEmbed-a01nKECT.js} +1 -1
  14. package/web/assets/{TimelinePlugins-zhB9Uqav.js → TimelinePlugins-CqLMVjuh.js} +4 -4
  15. package/web/assets/TimelineShotFx-QmkyCg31.js +2 -0
  16. package/web/assets/{TransitionEmbed-r_B0toRr.js → TransitionEmbed-Cbwlxfl2.js} +1 -1
  17. package/web/assets/{Whiteboard-f6owS-ne.js → Whiteboard-ChYqIr3v.js} +1 -1
  18. package/web/assets/{aerial-DIj143Yz.js → aerial-CZeCeacv.js} +2 -2
  19. package/web/assets/{agentTools-CoNs1wCQ.js → agentTools-DW2ETnxE.js} +2 -2
  20. package/web/assets/{aiInbetween-ZFNHEXdI.js → aiInbetween-De98iM4m.js} +2 -2
  21. package/web/assets/analyzerRun-D5-g-Vxe.js +1 -0
  22. package/web/assets/{analyzerSandbox-C2rd6s8U.js → analyzerSandbox-E3CdovIk.js} +1 -1
  23. package/web/assets/{api-DJC95K48.js → api-CZoVJ9Fy.js} +87 -87
  24. package/web/assets/auraTrack-ClhHuqlf.js +1 -0
  25. package/web/assets/{breakthrough-DiHiElqL.js → breakthrough-DTpiUIZd.js} +2 -2
  26. package/web/assets/{cameraPresets-DfKERP1j.js → cameraPresets-DD0WmxiI.js} +1 -1
  27. package/web/assets/{cameraTracker-DFjnZ7tw.js → cameraTracker-Df9jWmz6.js} +2 -2
  28. package/web/assets/{captionLayout-CAuhUiW9.js → captionLayout-eiu9QPJu.js} +1 -1
  29. package/web/assets/{clientExport-DyqpYM6h.js → clientExport-BXegTdNc.js} +1 -1
  30. package/web/assets/{clientJobs-BqkjV5Ld.js → clientJobs-eB-lNyin.js} +2 -2
  31. package/web/assets/clipoox_photo_bg-BQ0aVNY0.wasm +0 -0
  32. package/web/assets/depthEstimate-CfwX-tXP.js +1 -0
  33. package/web/assets/{directorTools-CLn4xt6m.js → directorTools-ABbI8m0e.js} +1 -1
  34. package/web/assets/distortFrames-DMnZ8OYh.js +2 -0
  35. package/web/assets/distortGL-DQu0Df2c.js +18 -0
  36. package/web/assets/{domino-BDKBYrNQ.js → domino-trmDBvfH.js} +1 -1
  37. package/web/assets/{editTools-BqKU-ucA.js → editTools-DEFo9Ahv.js} +1 -1
  38. package/web/assets/{engine-B2YPWQZ2.js → engine-Y-GotDIy.js} +1 -1
  39. package/web/assets/exportGlb-BeLpJKJT.js +2 -0
  40. package/web/assets/{faceTracker-DsmLlUZ1.js → faceTracker-BeSFnLM8.js} +1 -1
  41. package/web/assets/{fightDirector-BIVLGhAP.js → fightDirector-Dfz3vu5-.js} +1 -1
  42. package/web/assets/{fightDrama-B_jDQ-cW.js → fightDrama-CNVn69s0.js} +2 -2
  43. package/web/assets/{focusTool-mWs2Eikj.js → focusTool-Dd2UDkiO.js} +1 -1
  44. package/web/assets/{frameSink-DWkHUnvV.js → frameSink-Rj02YES5.js} +3 -3
  45. package/web/assets/{glTransitionSources.generated-BJuEUz3E.js → glTransitionSources.generated-Cs8lVRqs.js} +438 -2
  46. package/web/assets/{gpuCompose-Fi0sIUI9.js → gpuCompose-DkkKH1Ab.js} +1 -1
  47. package/web/assets/gpuExport-DwrXpVGF.js +199 -0
  48. package/web/assets/{handMatte-CvFkZKTL.js → handMatte-B5sUeqKi.js} +1 -1
  49. package/web/assets/{handTracker-CF1hqh09.js → handTracker-CQV-D7va.js} +2 -2
  50. package/web/assets/i18n-ClNt3LKg.js +3 -0
  51. package/web/assets/{index-EegUntr6.js → index-D2u6mD-8.js} +1 -1
  52. package/web/assets/layer-worker-DP0N05Ua.js +5 -0
  53. package/web/assets/library-cb43ZEmy.js +1 -0
  54. package/web/assets/{lottieLayer-Dp_vGTy8.js → lottieLayer-DEw0c3to.js} +4 -4
  55. package/web/assets/main-C_XcvNyC.js +311 -0
  56. package/web/assets/{main-B_MAOvi6.css → main-DlzdW5C4.css} +1 -1
  57. package/web/assets/{mapBake-CEmw-e9Y.js → mapBake-BUWz0cSx.js} +1 -1
  58. package/web/assets/{maskTrack-CADMBJDf.js → maskTrack-GYpJyKFw.js} +1 -1
  59. package/web/assets/matteFixRun-BCVsuSxf.js +1 -0
  60. package/web/assets/{objectLocate-DWsEG8eK.js → objectLocate-CjIlo_u0.js} +1 -1
  61. package/web/assets/{objectSegmenter-oGv8YQbI.js → objectSegmenter-C4T9qgUL.js} +1 -1
  62. package/web/assets/{objectTrack.worker-B6RVfsq4.js → objectTrack.worker-BVvsDmR0.js} +1161 -770
  63. package/web/assets/{pathTracer-DxqKEvC7.js → pathTracer-DgL1_83l.js} +2 -2
  64. package/web/assets/{pendingMatte-Taa0BlLI.js → pendingMatte-DPTe6xoZ.js} +2 -2
  65. package/web/assets/peopleMatte-C1hruEM6.js +1 -0
  66. package/web/assets/{personAi-BebqXrqD.js → personAi-Cjg9KKeH.js} +2 -2
  67. package/web/assets/{personHq-Cyq9HWnW.js → personHq-CBP8v_cw.js} +2 -2
  68. package/web/assets/photo.worker-DK_ulTzR.js +1 -0
  69. package/web/assets/photoRun-lZ2BdSEk.js +2 -0
  70. package/web/assets/photoTools-DmUh69Qk.js +1 -0
  71. package/web/assets/plateCamera-DLqlXhMp.js +1 -0
  72. package/web/assets/{plateCameraMatch-1_DuZ0LV.js → plateCameraMatch-4VUlUMi-.js} +2 -2
  73. package/web/assets/{plateFollow-Ztxwpq5v.js → plateFollow-D2rjnmZA.js} +2 -2
  74. package/web/assets/plateMatte-0tTG7oeO.js +2 -0
  75. package/web/assets/{pluginAutomation-D73Az7HS.js → pluginAutomation-ClFdpcCR.js} +1 -1
  76. package/web/assets/popTools-B38V4wub.js +1 -0
  77. package/web/assets/{poseTracker-b1h08oRY.js → poseTracker-qtuytI-L.js} +1 -1
  78. package/web/assets/{productTools-CoJ_Fnfc.js → productTools-DlC5vWjx.js} +2 -2
  79. package/web/assets/remote-CpkPQOQH.js +989 -0
  80. package/web/assets/{rigTrack-B9r9wrdV.js → rigTrack-BbKqZGs7.js} +1 -1
  81. package/web/assets/{rotoMaskStore-RmW40Pcn.js → rotoMaskStore-BZBJLcCp.js} +1 -1
  82. package/web/assets/{rotoMatte-DisQplSv.js → rotoMatte-BI-vjjrv.js} +1 -1
  83. package/web/assets/rotoscope-DuNcCxQy.js +1 -0
  84. package/web/assets/{sceneTrack-DyVxpl7i.js → sceneTrack-CO4fTjft.js} +1 -1
  85. package/web/assets/sceneTrack-_n6WKKQv.js +1 -0
  86. package/web/assets/{sceneTrack.worker-DKVLLgf9.js → sceneTrack.worker-f2d-WOzw.js} +1207 -816
  87. package/web/assets/{shot-worker-DM5PUQ6g.js → shot-worker-BSmfIXHO.js} +1 -1
  88. package/web/assets/{shotFxAgent-CsW0MAiG.js → shotFxAgent-L2GG88W3.js} +1 -1
  89. package/web/assets/{skin-CXvqtCZI.js → skin-CirUiqcr.js} +1 -1
  90. package/web/assets/{spark.module-B341moK0.js → spark.module-3Q8DniuL.js} +1 -1
  91. package/web/assets/{spellDuel-KCMEFHLA.js → spellDuel-2CDLbiLQ.js} +2 -2
  92. package/web/assets/{store-xR02oY0m.js → store-D3Y663py.js} +1 -1
  93. package/web/assets/{surfaceLight-DBfJxggM.js → surfaceLight--HQj7xhO.js} +1 -1
  94. package/web/assets/{surfacePin-i-X1Dz68.js → surfacePin-BCmgw-40.js} +2 -2
  95. package/web/assets/{textAnimators-CeMuG34D.js → textAnimators-C4eMnVRD.js} +1 -1
  96. package/web/assets/{thumb-DzNl15MN.js → thumb-M9B_goj-.js} +1 -1
  97. package/web/assets/{timeline3d-D0Ws4lcp.js → timeline3d-BcW68fQr.js} +2 -2
  98. package/web/assets/{timeline3dExport-BO--SpAn.js → timeline3dExport-DgnorHLm.js} +1 -1
  99. package/web/assets/timelineComp-Ciu9JCWJ.js +1 -0
  100. package/web/assets/timelineOps-f1WsVbgS.js +526 -0
  101. package/web/assets/{timelineProps-Cm_Irino.js → timelineProps-CE1R11Hx.js} +1 -1
  102. package/web/assets/{timelineText-DjPW2-dd.js → timelineText-Cppd4KB7.js} +1 -1
  103. package/web/assets/{titleArt-BSu80bfN.js → titleArt-D0YI5xT2.js} +3 -3
  104. package/web/assets/{titleFrameBudget-BW-N1-cw.js → titleFrameBudget-h4nOQ5u9.js} +1382 -991
  105. package/web/assets/titleFrames-DnCzi_AI.js +1 -0
  106. package/web/assets/{tool-Bboi3NDg.js → tool-tp6gat1J.js} +1 -1
  107. package/web/assets/{tools-kgYkohv8.js → tools-C07G9KUM.js} +1 -1
  108. package/web/assets/{toonTools-Bxz_HSqT.js → toonTools-Cazx2CL7.js} +2 -2
  109. package/web/assets/{trackAnchor-DK9cEMCf.js → trackAnchor-DoqFDcJB.js} +1 -1
  110. package/web/assets/{userFonts-DSkZHfmh.js → userFonts-BlVEJfDk.js} +1 -1
  111. package/web/assets/{vfxAlpha-B0rNpKZN.js → vfxAlpha-Bp6VgIGN.js} +1 -1
  112. package/web/assets/vfxBackground-BFq44Srn.js +2 -0
  113. package/web/assets/{videoExport-Cu0vw-dL.js → videoExport-Cz02XKtX.js} +1 -1
  114. package/web/assets/{views-CmulxRJP.js → views-CNF3Afse.js} +1 -1
  115. package/web/assets/{weaponDuel-DuuMMfzY.js → weaponDuel-ChqBQo_b.js} +1 -1
  116. package/web/assets/{windowFrames-BP2oDn-n.js → windowFrames-dBMXwGek.js} +1 -1
  117. package/web/layer-worker.html +3 -3
  118. package/web/shot-worker.html +24 -24
  119. package/web/assets/ShotComposer-CoxtWL6A.js +0 -287
  120. package/web/assets/ShotComposer-deLi4grZ.css +0 -1
  121. package/web/assets/TimelineShotFx-muTN__gf.js +0 -2
  122. package/web/assets/analyzerRun-BswbLsRF.js +0 -1
  123. package/web/assets/auraTrack-C9diszRB.js +0 -1
  124. package/web/assets/depthEstimate-HrGq0Ffx.js +0 -1
  125. package/web/assets/distortFrames-D-DK2HlN.js +0 -2
  126. package/web/assets/distortGL-waTJhiOf.js +0 -12
  127. package/web/assets/exportGlb-Cm07JQXt.js +0 -2
  128. package/web/assets/gpuExport-Dlf6YjLs.js +0 -198
  129. package/web/assets/i18n-C9zFX25m.js +0 -3
  130. package/web/assets/layer-worker-Drj-NLVj.js +0 -5
  131. package/web/assets/library-BhH-xsMR.js +0 -1
  132. package/web/assets/main-DAk1Tv1E.js +0 -309
  133. package/web/assets/matteFixRun-BHD3Qnta.js +0 -1
  134. package/web/assets/plateCamera-D1A1iEpf.js +0 -1
  135. package/web/assets/plateMatte-CWT1ymGj.js +0 -2
  136. package/web/assets/remote-kxNNhmis.js +0 -974
  137. package/web/assets/rotoscope-Z8bn-jRs.js +0 -1
  138. package/web/assets/sceneTrack-BKknn180.js +0 -1
  139. package/web/assets/timelineComp-D8PHGHgQ.js +0 -1
  140. package/web/assets/timelineOps-CEGk2t4h.js +0 -525
  141. package/web/assets/titleFrames-BHFaInux.js +0 -1
  142. package/web/assets/vfxBackground-CBTDl1xA.js +0 -2
@@ -0,0 +1,3 @@
1
+ import{j as e,a as et}from"./remote-CpkPQOQH.js";import{r as m}from"./index-CKtv7gGE.js";import{u as ye,t as i,g as Pe}from"./i18n-ClNt3LKg.js";import{u as ct}from"./store-D3Y663py.js";import{bK as ht,bL as dt,s as Ye,u as Be}from"./api-CZoVJ9Fy.js";import{b as ut,c as qe,D as Le,e as tt,f as mt}from"./main-C_XcvNyC.js";import{T as pt}from"./textAnimators-C4eMnVRD.js";import{p as Ze,P as gt,a as xt}from"./photoTools-DmUh69Qk.js";import{photoToolPrice as ft,cancelPhoto as bt,runPhotoOnLayer as jt}from"./photoRun-lZ2BdSEk.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./rotoMaskStore-BZBJLcCp.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";import"./spark.module-3Q8DniuL.js";import"./userFonts-BlVEJfDk.js";import"./lottieLayer-DEw0c3to.js";import"./timeline3d-BcW68fQr.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./glTransitionSources.generated-Cs8lVRqs.js";import"./clientJobs-eB-lNyin.js";import"./captionLayout-eiu9QPJu.js";import"./timelineText-Cppd4KB7.js";import"./titleArt-D0YI5xT2.js";import"./personHq-CBP8v_cw.js";import"./matteQuality-9X-jgJrH.js";import"./sceneTrack-_n6WKKQv.js";import"./rotoMatte-BI-vjjrv.js";import"./objectSegmenter-C4T9qgUL.js";import"./cutoutClean-CLYYAuXg.js";import"./distortGL-DQu0Df2c.js";import"./motionBlur-uAm030t9.js";const Fe=Math.PI/180;function je(t,s=1){const r=String(t.font||"Be Vietnam Pro").replace(/["\\]/g,"");return`${t.italic?"italic ":""}${t.weight||400} ${Math.max(1,t.size*s)}px "${r}", "Be Vietnam Pro", "Noto Sans", sans-serif`}function Se(t,s,r,h,l,u){if(!s||typeof s=="string")return s||"#000000";if(s.type==="radial"){const k=t.createRadialGradient(r+l/2,h+u/2,0,r+l/2,h+u/2,Math.hypot(l,u)/2);for(const[C,w]of s.stops)k.addColorStop(C,w);return k}const p=(s.angle??180)*Fe,o=Math.sin(p),x=-Math.cos(p),M=(Math.abs(l*o)+Math.abs(u*x))/2,S=r+l/2,y=h+u/2,J=t.createLinearGradient(S-o*M,y-x*M,S+o*M,y+x*M);for(const[k,C]of s.stops)J.addColorStop(k,C);return J}function st(t,s,r,h,l,u){const p=Math.max(0,Math.min(u||0,h/2,l/2));if(t.beginPath(),!p){t.rect(s,r,h,l);return}t.moveTo(s+p,r),t.lineTo(s+h-p,r),t.arcTo(s+h,r,s+h,r+p,p),t.lineTo(s+h,r+l-p),t.arcTo(s+h,r+l,s+h-p,r+l,p),t.lineTo(s+p,r+l),t.arcTo(s,r+l,s,r+l-p,p),t.lineTo(s,r+p),t.arcTo(s,r,s+p,r,p),t.closePath()}function Te(t,s,r,h){return t.measureText(s).width+(r?r*h*Math.max(0,[...s].length-1):0)}function Ie(t,s,r,h=0,l=16){const u=[];for(const p of String(s).split(`
2
+ `)){const o=p.split(/(\s+)/).filter(M=>M.length);let x="";for(const M of o){const S=x+M;if(!x||Te(t,S.trimEnd(),h,l)<=r){x=S;continue}for(u.push(x.trimEnd()),x=M.trimStart();x&&Te(t,x,h,l)>r&&x.length>1;){let y=x.length-1;for(;y>1&&Te(t,x.slice(0,y),h,l)>r;)y--;u.push(x.slice(0,y)),x=x.slice(y)}}u.push(x.trimEnd())}return u}function yt(t,s,r,h,l,u,p){if(!l){p&&t.strokeText(s,r,h),t.fillText(s,r,h);return}let o=r;for(const x of s)p&&t.strokeText(x,o,h),t.fillText(x,o,h),o+=t.measureText(x).width+l*u}function vt(t,s){const r=s.upper?String(s.text).toLocaleUpperCase("vi"):String(s.text);t.font=je(s),t.textBaseline="middle",t.textAlign="left";const h=Ie(t,r,s.w,s.letterSpacing,s.size),l=s.size*s.lineHeight;t.fillStyle=Se(t,s.color,s.x,s.y,s.w,Math.max(s.h,h.length*l)),s.stroke&&s.strokeWidth&&(t.strokeStyle=s.stroke,t.lineWidth=s.strokeWidth,t.lineJoin="round"),h.forEach((u,p)=>{const o=Te(t,u,s.letterSpacing,s.size),x=s.align==="center"?s.x+(s.w-o)/2:s.align==="right"?s.x+s.w-o:s.x;yt(t,u,x,s.y+(p+.5)*l,s.letterSpacing,s.size,!!(s.stroke&&s.strokeWidth))})}function wt(t,s,r){if(t.save(),st(t,s.x,s.y,s.w,s.h,s.radius),t.clip(),r&&(r.width||r.naturalWidth)){const h=r.naturalWidth||r.width,l=r.naturalHeight||r.height,u=s.fit==="contain"?Math.min(s.w/h,s.h/l):Math.max(s.w/h,s.h/l),p=h*u,o=l*u;t.drawImage(r,s.x+(s.w-p)/2,s.y+(s.h-o)/2,p,o)}else if(t.fillStyle="rgba(0,0,0,0.16)",t.fillRect(s.x,s.y,s.w,s.h),!s.url){t.setLineDash([Math.max(6,s.w/40),Math.max(4,s.w/60)]),t.strokeStyle="rgba(255,255,255,0.7)",t.lineWidth=Math.max(2,Math.min(s.w,s.h)/160),t.strokeRect(s.x+t.lineWidth,s.y+t.lineWidth,s.w-2*t.lineWidth,s.h-2*t.lineWidth),t.setLineDash([]);const h=Math.max(12,Math.min(s.w/14,s.h/8,40));t.font=`600 ${h}px "Be Vietnam Pro", "Noto Sans", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillStyle="rgba(255,255,255,0.92)";const l=Ie(t,`[${s.placeholder||"ẢNH CỦA BẠN"}]`,s.w*.85,0,h);l.forEach((u,p)=>t.fillText(u,s.x+s.w/2,s.y+s.h/2+(p-(l.length-1)/2)*h*1.25))}t.restore()}function Re(t,s,{getImage:r=()=>null,scale:h=1,skip:l=null,background:u=!0}={}){t.save(),t.scale(h,h),u&&s.background&&s.background!=="transparent"&&(t.fillStyle=Se(t,s.background,0,0,s.width,s.height),t.fillRect(0,0,s.width,s.height));const p=typeof t.filter=="string";for(const o of s.layers)if(!(o.hidden||l?.has(o.id))){if(t.save(),t.globalAlpha=o.opacity??1,o.rotation){const x=o.x+o.w/2,M=o.y+o.h/2;t.translate(x,M),t.rotate(o.rotation*Fe),t.translate(-x,-M)}o.shadow&&(t.shadowColor=o.shadow.color,t.shadowBlur=o.shadow.blur,t.shadowOffsetX=o.shadow.x,t.shadowOffsetY=o.shadow.y),o.adjust&&p&&(t.filter=`brightness(${o.adjust.brightness}) contrast(${o.adjust.contrast}) saturate(${o.adjust.saturation})`),o.type==="rect"?(st(t,o.x,o.y,o.w,o.h,o.radius),o.fill!=="transparent"&&(t.fillStyle=Se(t,o.fill,o.x,o.y,o.w,o.h),t.fill()),o.stroke&&o.strokeWidth&&(t.shadowColor="transparent",t.strokeStyle=o.stroke,t.lineWidth=o.strokeWidth,t.stroke())):o.type==="ellipse"?(t.beginPath(),t.ellipse(o.x+o.w/2,o.y+o.h/2,o.w/2,o.h/2,0,0,Math.PI*2),o.fill!=="transparent"&&(t.fillStyle=Se(t,o.fill,o.x,o.y,o.w,o.h),t.fill()),o.stroke&&o.strokeWidth&&(t.shadowColor="transparent",t.strokeStyle=o.stroke,t.lineWidth=o.strokeWidth,t.stroke())):o.type==="line"?(t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(o.x+o.w,o.y+o.h),t.strokeStyle=o.stroke,t.lineWidth=o.strokeWidth,t.lineCap="round",t.stroke()):o.type==="text"?vt(t,o):o.type==="image"&&wt(t,o,r(o)),t.restore()}t.restore()}function Je(t,s,r,{includeLocked:h=!1}={}){for(let l=t.layers.length-1;l>=0;l--){const u=t.layers[l];if(u.hidden||u.locked&&!h)continue;const p=u.x+u.w/2,o=u.y+u.h/2,x=-(u.rotation||0)*Fe,M=p+(s-p)*Math.cos(x)-(r-o)*Math.sin(x),S=o+(s-p)*Math.sin(x)+(r-o)*Math.cos(x),y=u.type==="line"?Math.max(8,u.strokeWidth):0;if(M>=Math.min(u.x,u.x+u.w)-y&&M<=Math.max(u.x,u.x+u.w)+y&&S>=Math.min(u.y,u.y+u.h)-y&&S<=Math.max(u.y,u.y+u.h)+y)return u}return null}const Qe=t=>Pe()==="en"?t.label.en:t.label.vi,H=t=>t.about?Pe()==="en"?t.about.en:t.about.vi:"",R=t=>xt.find(s=>s.id===t);function D({label:t,value:s,min:r,max:h,step:l=1,onChange:u,unit:p=""}){return e.jsxs("label",{className:"is-field",children:[e.jsxs("span",{children:[t," ",e.jsxs("b",{className:"mono",children:[Math.round(s*100)/100,p]})]}),e.jsx("input",{type:"range",min:r,max:h,step:l,value:s,onChange:o=>u(Number(o.target.value))})]})}function kt({layer:t,set:s,run:r,cancel:h,restore:l,busy:u,pick:p,setPick:o,hasBox:x,hasStroke:M,clearPick:S}){ye();const[y,J]=m.useState("split_layers"),[k,C]=m.useState("auto"),[w,E]=m.useState({blur_bg:.5,auto_focus:.5,skin_retouch:.5}),[N,_]=m.useState({angle:135,elevation:40,intensity:60,ambient:50,warmth:15,softness:50}),[B,ne]=m.useState({left:0,right:0,top:0,bottom:0}),[ie,ve]=m.useState({amount:120,radius:1.2}),[F,Q]=m.useState({strength:6,details:60}),[W,de]=m.useState("gaussianBlur"),[z,X]=m.useState({}),[le,we]=m.useState(2),[I,ue]=m.useState({new_background:"",ai_edit:""}),[oe,me]=m.useState({}),O=t?.type==="image"&&t.url?t:null,G=t?.adjust||{brightness:1,contrast:1,saturation:1};m.useEffect(()=>{y!=="erase"&&y!=="ai_edit"&&p?.kind==="brush"&&o(null),!((y==="split_layers"||y==="remove_bg"||y==="new_background")&&k==="box")&&p?.kind==="box"&&o(null)},[y,k]);const pe=O?.url;m.useEffect(()=>{if(!O||!R(y)?.paid)return;let c=!0;return me(f=>({...f,[y]:void 0})),ft(y,O).then(f=>{c&&me($=>({...$,[y]:f}))}).catch(()=>{c&&me(f=>({...f,[y]:null}))}),()=>{c=!1}},[y,pe]),m.useEffect(()=>{const c=Ze(W);c&&X(Object.fromEntries(c.params.map(f=>[f.key,f.default])))},[W]);const ee=!!u,P=({id:c,params:f,disabled:$,label:q})=>e.jsx("button",{className:"is-btn is-primary is-run",disabled:ee||$,onClick:()=>r(c,f),children:q||i("Áp dụng")}),A=({id:c,star:f})=>e.jsxs("button",{className:`is-ptool${y===c?" on":""}${f?" star":""}`,"aria-expanded":y===c,onClick:()=>J(y===c?"":c),disabled:ee&&u?.tool!==c,children:[e.jsxs("span",{children:[f?"★ ":"",Qe(R(c))]}),e.jsx("small",{children:R(c).paid?"AI":i("miễn phí")})]}),Y=({people:c=!0})=>e.jsx("div",{className:"is-chips",role:"radiogroup","aria-label":i("Tách gì"),children:[["auto",i("Tự động")],...c?[["people",i("Người (Image Studio)")]]:[],["subject",i("Chủ thể")],["box",i("Khoanh vùng (Image Studio)")]].map(([f,$])=>e.jsx("button",{role:"radio","aria-checked":k===f,className:`is-chip${k===f?" on":""}`,onClick:()=>{C(f),o(f==="box"?{kind:"box"}:null)},children:$},f))}),ke=c=>c.toLocaleString(Pe()==="en"?"en-US":"vi-VN",{maximumFractionDigits:2}),te=(c,f)=>{const $=oe[c];return $===void 0?`${f} · …`:$===null?`${f} · ${i("chưa có giá")}`:`${f} · ${ke($)} credit`},se=k==="box"&&e.jsx("p",{className:"is-muted",children:x?i("Đã khoanh vùng — kéo lại để đổi."):i("Kéo một khung quanh vật thể trên ảnh.")});return e.jsxs("div",{className:"is-stack is-photo",children:[u&&e.jsxs("div",{className:"is-busy",role:"status",children:[e.jsx("div",{className:"is-bar",children:e.jsx("span",{style:{width:`${Math.round(u.f*100)}%`}})}),e.jsx("span",{children:u.label||i("Đang xử lý ảnh…")}),!R(u.tool)?.paid&&e.jsx("button",{className:"is-btn",onClick:h,children:i("Dừng")})]}),O?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"is-label",children:i("Tách & xoá")}),e.jsx(A,{id:"split_layers",star:!0}),y==="split_layers"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("split_layers"))}),e.jsx(Y,{}),se,e.jsx(P,{id:"split_layers",params:{mode:k},disabled:k==="box"&&!x,label:i("Tách lớp (Image Studio)")})]}),e.jsx(A,{id:"remove_bg"}),y==="remove_bg"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("remove_bg"))}),e.jsx(Y,{}),se,e.jsx(P,{id:"remove_bg",params:{mode:k},disabled:k==="box"&&!x,label:i("Xoá nền")})]}),e.jsx(A,{id:"erase"}),y==="erase"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("erase"))}),p?.kind!=="brush"?e.jsx("button",{className:"is-btn",onClick:()=>o({kind:"brush",size:40}),children:i("Bắt đầu tô")}):e.jsxs(e.Fragment,{children:[e.jsx(D,{label:i("Cỡ cọ"),value:p.size,min:4,max:200,onChange:c=>o({kind:"brush",size:c}),unit:" px"}),e.jsx("div",{className:"is-row",children:e.jsx("button",{className:"is-btn",onClick:S,disabled:!M,children:i("Xoá nét tô")})})]}),e.jsx(P,{id:"erase",params:{},disabled:!M,label:i("Tẩy (Image Studio)")})]}),e.jsx("div",{className:"is-label",children:i("Chỉnh ảnh")}),e.jsx(A,{id:"expand"}),y==="expand"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("expand"))}),e.jsx("div",{className:"is-chips",children:[["16:9",16/9],["1:1",1],["4:5",4/5],["9:16",9/16]].map(([c,f])=>e.jsx("button",{className:"is-chip",onClick:()=>{const $=O.w/O.h;if(f>$){const q=(f/$-1)/2;ne({left:q,right:q,top:0,bottom:0})}else{const q=($/f-1)/2;ne({left:0,right:0,top:q,bottom:q})}},children:c},c))}),["left","right","top","bottom"].map(c=>e.jsx(D,{label:{left:i("Trái"),right:i("Phải"),top:i("Trên"),bottom:i("Dưới")}[c],value:Math.round(B[c]*100),min:0,max:100,unit:"%",onChange:f=>ne({...B,[c]:f/100})},c)),e.jsx(P,{id:"expand",params:B,disabled:!(B.left+B.right+B.top+B.bottom),label:i("Mở rộng")})]}),["blur_bg","auto_focus"].map(c=>e.jsxs("div",{children:[e.jsx(A,{id:c}),y===c&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R(c))}),e.jsx(D,{label:i("Mức"),value:Math.round(w[c]*100),min:5,max:100,unit:"%",onChange:f=>E({...w,[c]:f/100})}),e.jsx(P,{id:c,params:{amount:w[c]}})]})]},c)),e.jsx(A,{id:"relight"}),y==="relight"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("relight"))}),e.jsx(D,{label:i("Hướng sáng"),value:N.angle,min:-180,max:180,unit:"°",onChange:c=>_({...N,angle:c})}),e.jsx(D,{label:i("Độ cao đèn"),value:N.elevation,min:0,max:90,unit:"°",onChange:c=>_({...N,elevation:c})}),e.jsx(D,{label:i("Cường độ"),value:N.intensity,min:0,max:100,onChange:c=>_({...N,intensity:c})}),e.jsx(D,{label:i("Ánh sáng nền"),value:N.ambient,min:0,max:100,onChange:c=>_({...N,ambient:c})}),e.jsx(D,{label:i("Ấm / lạnh"),value:N.warmth,min:-100,max:100,onChange:c=>_({...N,warmth:c})}),e.jsx(D,{label:i("Độ mềm"),value:N.softness,min:1,max:100,onChange:c=>_({...N,softness:c})}),e.jsx(P,{id:"relight",params:N})]}),e.jsx(A,{id:"sharpen"}),y==="sharpen"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("sharpen"))}),e.jsx(D,{label:i("Mức"),value:ie.amount,min:10,max:400,unit:"%",onChange:c=>ve({...ie,amount:c})}),e.jsx(D,{label:i("Bán kính"),value:ie.radius,min:.2,max:10,step:.1,unit:" px",onChange:c=>ve({...ie,radius:c})}),e.jsx(P,{id:"sharpen",params:ie})]}),e.jsx(A,{id:"upscale"}),y==="upscale"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("upscale"))}),e.jsx("div",{className:"is-chips",children:[2,4].map(c=>e.jsxs("button",{className:`is-chip${le===c?" on":""}`,onClick:()=>we(c),children:["×",c]},c))}),e.jsx(P,{id:"upscale",params:{scale:le,model:"photo"},label:i("Upscale")})]}),e.jsx(A,{id:"denoise"}),y==="denoise"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("denoise"))}),e.jsx(D,{label:i("Mức"),value:F.strength,min:1,max:10,onChange:c=>Q({...F,strength:c})}),e.jsx(D,{label:i("Giữ chi tiết"),value:F.details,min:0,max:100,unit:"%",onChange:c=>Q({...F,details:c})}),e.jsx(P,{id:"denoise",params:F})]}),e.jsx(A,{id:"skin_retouch"}),y==="skin_retouch"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("skin_retouch"))}),e.jsx(D,{label:i("Mức"),value:Math.round(w.skin_retouch*100),min:5,max:100,unit:"%",onChange:c=>E({...w,skin_retouch:c/100})}),e.jsx(P,{id:"skin_retouch",params:{amount:w.skin_retouch}})]}),e.jsxs("div",{className:"is-label",children:[i("Bộ lọc Photoshop")," ",e.jsx("span",{className:"is-free",children:"PhotoCraft"})]}),e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:i("Bộ lọc")}),e.jsx("select",{value:W,onChange:c=>de(c.target.value),children:gt.map(c=>e.jsx("option",{value:c.id,children:Qe(c)},c.id))})]}),Ze(W)?.params.map(c=>e.jsx(D,{label:Pe()==="en"?c.label.en:c.label.vi,value:z[c.key]??c.default,min:c.min,max:c.max,step:c.step,onChange:f=>X({...z,[c.key]:f})},c.key)),e.jsx(P,{id:"filter",params:{name:W,...z}}),t?.original&&e.jsx("button",{className:"is-btn",disabled:ee,onClick:l,children:i("Khôi phục ảnh gốc")})]}):e.jsx("p",{className:"is-muted",children:i("Chọn một lớp ảnh trên trang để dùng công cụ ảnh (tách lớp, xoá nền, tẩy vật thể…).")}),e.jsxs("div",{className:"is-label",children:[i("Chỉnh màu")," ",e.jsx("span",{className:"is-free",children:i("MIỄN PHÍ")})]}),t?e.jsxs(e.Fragment,{children:[[["brightness",i("Độ sáng")],["contrast",i("Tương phản")],["saturation",i("Độ bão hoà")]].map(([c,f])=>e.jsxs("label",{className:"is-field",children:[e.jsxs("span",{children:[f," ",Math.round(G[c]*100),"%"]}),e.jsx("input",{type:"range",min:0,max:200,value:Math.round(G[c]*100),onChange:$=>s({adjust:{...G,[c]:Number($.target.value)/100}})})]},c)),e.jsx("button",{className:"is-btn",onClick:()=>s({adjust:void 0}),children:i("Về như cũ")})]}):e.jsx("p",{className:"is-muted",children:i("Chọn một lớp (ảnh, hình, chữ) để chỉnh màu.")}),O&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"is-label",children:[i("AI")," ",e.jsx("span",{className:"is-paid",children:i("tính credit")})]}),e.jsx(A,{id:"grab_text"}),y==="grab_text"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("grab_text"))}),e.jsx(P,{id:"grab_text",params:{},disabled:!oe.grab_text,label:te("grab_text",i("Lấy chữ"))})]}),e.jsx(A,{id:"new_background"}),y==="new_background"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("new_background"))}),e.jsx(Y,{}),se,e.jsx("textarea",{className:"is-prompt",rows:2,value:I.new_background,placeholder:i("Mô tả nền mới, vd. bãi biển lúc hoàng hôn"),onChange:c=>ue({...I,new_background:c.target.value})}),e.jsx("div",{className:"is-chips",children:[i("Phòng studio nền trắng"),i("Bãi biển lúc hoàng hôn"),i("Văn phòng hiện đại"),i("Phố đêm đèn neon")].map(c=>e.jsx("button",{className:"is-chip",onClick:()=>ue({...I,new_background:c}),children:c},c))}),e.jsx(P,{id:"new_background",params:{prompt:I.new_background,mode:k},disabled:!oe.new_background||I.new_background.trim().length<3||k==="box"&&!x,label:te("new_background",i("Tạo nền mới"))})]}),e.jsx(A,{id:"ai_edit"}),y==="ai_edit"&&e.jsxs("div",{className:"is-popts",children:[e.jsx("p",{className:"is-muted",children:H(R("ai_edit"))}),p?.kind!=="brush"?e.jsx("button",{className:"is-btn",onClick:()=>o({kind:"brush",size:40}),children:i("Bắt đầu tô")}):e.jsxs(e.Fragment,{children:[e.jsx(D,{label:i("Cỡ cọ"),value:p.size,min:4,max:200,onChange:c=>o({kind:"brush",size:c}),unit:" px"}),e.jsx("div",{className:"is-row",children:e.jsx("button",{className:"is-btn",onClick:S,disabled:!M,children:i("Xoá nét tô")})})]}),e.jsx("textarea",{className:"is-prompt",rows:2,value:I.ai_edit,placeholder:i("Muốn đổi gì ở vùng đã tô? vd. thêm kính râm"),onChange:c=>ue({...I,ai_edit:c.target.value})}),e.jsx(P,{id:"ai_edit",params:{prompt:I.ai_edit},disabled:!oe.ai_edit||!M||I.ai_edit.trim().length<3,label:te("ai_edit",i("Sửa vùng"))})]}),e.jsx("p",{className:"is-muted is-small",children:i("Giá hiện trên nút trước khi chạy; lỗi thì credit được hoàn.")})]})]})}function Nt({layer:t,scale:s,pick:r,canvasRef:h,box:l,setBox:u,onStroke:p}){const o=m.useRef(null),x=Math.max(1,Math.round(t.w)),M=Math.max(1,Math.round(t.h)),S=k=>{const C=k.currentTarget.getBoundingClientRect(),w=C.left+C.width/2,E=C.top+C.height/2,N=-(t.rotation||0)*Math.PI/180,_=k.clientX-w,B=k.clientY-E;return{x:(_*Math.cos(N)-B*Math.sin(N))/s+t.w/2,y:(_*Math.sin(N)+B*Math.cos(N))/s+t.h/2}},y=(k,C)=>{const w=h.current?.getContext("2d");!w||r.kind!=="brush"||(w.strokeStyle="rgba(255,64,96,0.55)",w.lineCap="round",w.lineJoin="round",w.lineWidth=r.size,w.beginPath(),w.moveTo(k.x,k.y),w.lineTo(C.x+.01,C.y),w.stroke(),p())},J={left:t.x*s,top:t.y*s,width:t.w*s,height:t.h*s,transform:`rotate(${t.rotation||0}deg)`};return e.jsxs("div",{className:`is-pick is-pick-${r.kind}`,style:J,"data-testid":"photo-pick",onPointerDown:k=>{k.stopPropagation(),k.target.setPointerCapture?.(k.pointerId);const C=S(k);o.current=C,r.kind==="brush"?y(C,C):u(null)},onPointerMove:k=>{const C=o.current;if(!C)return;const w=S(k);if(r.kind==="brush"){y(C,w),o.current=w;return}const E=Math.max(0,Math.min(C.x,w.x)),N=Math.max(0,Math.min(C.y,w.y)),_=Math.min(t.w,Math.max(C.x,w.x)),B=Math.min(t.h,Math.max(C.y,w.y));u({x:E/t.w,y:N/t.h,w:(_-E)/t.w,h:(B-N)/t.h})},onPointerUp:()=>{o.current=null},children:[r.kind==="brush"&&e.jsx("canvas",{ref:h,width:x,height:M,style:{width:"100%",height:"100%"}}),r.kind==="box"&&l&&e.jsx("span",{className:"is-pickbox",style:{left:`${l.x*100}%`,top:`${l.y*100}%`,width:`${l.w*100}%`,height:`${l.h*100}%`}})]})}const Ct=["nw","n","ne","e","se","s","sw","w"],Mt=["#111111","#ffffff","#E5352B","#F2B33D","#B4E36A","#2E5BFF","#6A4CFF","#0F1B2D","#F4ECDF","#D6B46A"],St=[{type:"linear",angle:180,stops:[[0,"#c4161f"],[1,"#520609"]]},{type:"linear",angle:135,stops:[[0,"#2E5BFF"],[1,"#6A4CFF"]]},{type:"linear",angle:180,stops:[[0,"#EEF1F6"],[1,"#DCE3EE"]]},{type:"radial",stops:[[0,"#1d2a0e"],[1,"#000000"]]},{type:"linear",angle:120,stops:[[0,"#101114"],[1,"#3d3a18"]]},{type:"linear",angle:160,stops:[[0,"#ffd0d6"],[1,"#ff9aa8"]]}],Tt=t=>{const s=t.target;return!!s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.isContentEditable)},De=(t,s="#000000")=>typeof t=="string"?t==="transparent"?s:t.slice(0,7):t?.stops?.[0]?.[1]?.slice(0,7)||s,Pt=t=>typeof t=="string"?t:t.type==="radial"?`radial-gradient(${t.stops.map(([s,r])=>`${r} ${s*100}%`).join(",")})`:`linear-gradient(${t.angle}deg, ${t.stops.map(([s,r])=>`${r} ${s*100}%`).join(",")})`;function js({nodeId:t,designId:s}){ye();const r=ut(n=>n.close),h=ct(n=>n.toast),[l,u]=m.useState(null),[p,o]=m.useState(null),[x,M]=m.useState("select"),[S,y]=m.useState("templates"),[J,k]=m.useState(0),[C,w]=m.useState(null),[E,N]=m.useState("saved"),[_,B]=m.useState(null),[ne,ie]=m.useState(null),[,ve]=m.useState(0),F=m.useRef(void 0),Q=m.useRef(null),W=m.useRef([]),de=m.useRef([]),z=m.useRef(null),X=m.useRef(new Map),le=m.useRef(null),we=m.useRef(null),I=m.useRef(null),[ue,oe]=m.useState({w:800,h:600}),[me,O]=m.useState(null),[G,pe]=m.useState(null),[ee,P]=m.useState(null),[A,Y]=m.useState(!1),ke=m.useRef(null);Q.current=l;const te=m.useCallback(async(n=!1)=>{try{const a=await ht(s);F.current=a.rev,u(a.doc),N("saved"),n&&h(i("Thiết kế vừa được cập nhật (bản mới nhất đã tải)"))}catch(a){h(a.message,"error"),r()}},[s,r,h]);m.useEffect(()=>{te()},[te]),m.useEffect(()=>{const n=window.setInterval(async()=>{if(!(document.hidden||E!=="saved"))try{const a=await dt(s);F.current!==void 0&&a.rev>F.current&&te(!0)}catch{}},1e4);return()=>window.clearInterval(n)},[s,E,te]);const se=m.useCallback(async(n=!1)=>{const a=Q.current;if(a){N("saving");try{const d=await Ye(s,{doc:a,...n?{}:{baseRev:F.current}});F.current=d.rev,N(b=>b==="saving"?"saved":b)}catch(d){N(d.status===409?"conflict":"error")}}},[s]);m.useEffect(()=>{if(E!=="dirty")return;const n=window.setTimeout(()=>{se()},1200);return()=>window.clearTimeout(n)},[E,l,se]);const c=m.useCallback((n,a)=>{const d=a??Q.current;d&&(W.current=[...W.current.slice(-79),d],de.current=[]),u(n),N("dirty")},[]),f=m.useCallback((n,a)=>{const d=a??Q.current;if(!d)return null;const b=qe(d,n);return b.errors.length?(h(b.errors[0].error,"error"),null):(c(b.doc,d),b.doc)},[c,h]),$=()=>{const n=W.current.pop();!n||!l||(de.current.push(l),u(n),N("dirty"))},q=()=>{const n=de.current.pop();!n||!l||(W.current.push(l),u(n),N("dirty"))},g=l?.layers.find(n=>n.id===p)||null;m.useEffect(()=>{pe(null),P(null),Y(!1)},[p]);const Ne=n=>{if(!g)return;const a={...g,...n},d=a.type==="text"&&!("h"in n)&&["text","font","size","weight","w","lineHeight","letterSpacing","upper","italic"].some(b=>b in n)?Et(a):null;f([{op:"update",id:g.id,set:d&&d>a.h?{...n,h:d}:n}])},Z=n=>{const a=f([{op:"add",layer:n}]);return a&&(o(a.layers.at(-1).id),M("select")),a};m.useEffect(()=>{if(!l)return;for(const a of l.layers){if(a.type!=="image"||!a.url||X.current.has(a.url))continue;X.current.set(a.url,null);const d=a.url;fetch(d).then(b=>b.ok?b.blob():Promise.reject(new Error(String(b.status)))).then(b=>createImageBitmap(b)).then(b=>{X.current.set(d,b),ve(v=>v+1)}).catch(()=>{})}const n=[...new Set(l.layers.filter(a=>a.type==="text").map(a=>je(a)))];n.length&&Promise.all(n.map(a=>document.fonts.load(a).catch(()=>null))).then(()=>ve(a=>a+1))},[l]);const He=m.useCallback(n=>n.url?X.current.get(n.url)??null:null,[]);m.useLayoutEffect(()=>{const n=le.current;if(!n)return;const a=new ResizeObserver(()=>oe({w:n.clientWidth,h:n.clientHeight}));return a.observe(n),oe({w:n.clientWidth,h:n.clientHeight}),()=>a.disconnect()},[l===null]);const We=l?Math.min((ue.w-96)/l.width,(ue.h-96)/l.height):1,T=Math.max(.05,J||We),Ce=m.useMemo(()=>l&&ne?{...l,layers:[...l.layers,ne]}:l,[l,ne]);m.useEffect(()=>{const n=we.current;if(!n||!Ce)return;const a=Math.min(2,window.devicePixelRatio||1);n.width=Math.round(Ce.width*T*a),n.height=Math.round(Ce.height*T*a);const d=n.getContext("2d");d&&(d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,n.width,n.height),Re(d,Ce,{scale:T*a,getImage:He,skip:C?new Set([C]):null}))});const ge=n=>{const a=we.current.getBoundingClientRect();return{x:(n.clientX-a.left)/T,y:(n.clientY-a.top)/T}},it=n=>{if(!l||n.button!==0)return;n.target.setPointerCapture?.(n.pointerId);const a=ge(n);if(x==="hand"||n.altKey){const b=le.current;z.current={kind:"pan",start:a,base:l,client:{x:n.clientX,y:n.clientY},scroll:{x:b.scrollLeft,y:b.scrollTop}};return}if(x!=="select"){z.current={kind:"create",start:a,base:l,tool:x};return}const d=Je(l,a.x,a.y);o(d?.id??null),w(null),d&&(z.current={kind:"move",start:a,base:l,id:d.id})},ze=(n,a)=>{n.stopPropagation(),!(!l||!g)&&(n.target.setPointerCapture?.(n.pointerId),z.current={kind:a==="rot"?"rotate":"resize",start:ge(n),base:l,id:g.id,handle:a})},Ee=n=>{const a=z.current;if(!a)return;const d=ge(n),b=d.x-a.start.x,v=d.y-a.start.y;if(a.kind==="pan"){const L=le.current;L.scrollLeft=a.scroll.x-(n.clientX-a.client.x),L.scrollTop=a.scroll.y-(n.clientY-a.client.y);return}if(a.kind==="create"){const L=Math.min(a.start.x,d.x),U=Math.min(a.start.y,d.y),K=Math.abs(b),ce=Math.abs(v);ie(be(a.tool,a.tool==="line"?{x:a.start.x,y:a.start.y,w:b||1,h:v}:{x:L,y:U,w:Math.max(1,K),h:Math.max(1,ce)}));return}const j=a.base.layers.find(L=>L.id===a.id);if(!j)return;let ae;if(a.kind==="move"){let L=j.x+b,U=j.y+v;const K=L+j.w/2,ce=U+j.h/2;Math.abs(K-a.base.width/2)<6/T&&(L=a.base.width/2-j.w/2),Math.abs(ce-a.base.height/2)<6/T&&(U=a.base.height/2-j.h/2),ae={x:Math.round(L),y:Math.round(U)}}else if(a.kind==="rotate"){const L=j.x+j.w/2,U=j.y+j.h/2;let K=Math.atan2(d.y-U,d.x-L)*180/Math.PI+90;n.shiftKey&&(K=Math.round(K/15)*15),ae={rotation:Math.round((K+540)%360-180)}}else{const L=-(j.rotation||0)*Math.PI/180,U=b*Math.cos(L)-v*Math.sin(L),K=b*Math.sin(L)+v*Math.cos(L);let{x:ce,y:$e,w:xe,h:he}=j;const re=a.handle;if(re.includes("e")&&(xe=j.w+U),re.includes("s")&&(he=j.h+K),re.includes("w")&&(xe=j.w-U,ce=j.x+U),re.includes("n")&&(he=j.h-K,$e=j.y+K),n.shiftKey&&re.length===2){const Ge=Math.max(xe/j.w,he/j.h);xe=j.w*Ge,he=j.h*Ge,re.includes("w")&&(ce=j.x+j.w-xe),re.includes("n")&&($e=j.y+j.h-he)}ae={x:Math.round(ce),y:Math.round($e),w:Math.max(4,Math.round(xe)),h:Math.max(4,Math.round(he)),...j.type==="text"&&re.length===2?{size:Math.max(4,Math.round((j.size||48)*(he/j.h)))}:{}}}const Xe=qe(a.base,[{op:"update",id:j.id,set:ae}]);Xe.errors.length||u(Xe.doc)},_e=n=>{const a=z.current;if(z.current=null,!(!a||!l)){if(a.kind==="create"){const d=ge(n),v=Math.abs(d.x-a.start.x)<4&&Math.abs(d.y-a.start.y)<4?be(a.tool,{x:a.start.x-(a.tool==="text"?0:120),y:a.start.y-(a.tool==="text"?0:120),w:a.tool==="text"?Math.min(800,l.width-a.start.x):240,h:a.tool==="text"?80:240}):ne;if(ie(null),v){const j=Z(v);j&&a.tool==="text"&&w(j.layers.at(-1).id)}return}(a.kind==="move"||a.kind==="resize"||a.kind==="rotate")&&l!==a.base&&c(l,a.base)}};m.useEffect(()=>{const n=a=>{if(Tt(a))return;const d=a.metaKey||a.ctrlKey;if(d&&a.key.toLowerCase()==="z"){a.preventDefault(),a.shiftKey?q():$();return}if(d&&a.key.toLowerCase()==="d"&&g){a.preventDefault();const v=f([{op:"duplicate",id:g.id}]);v&&o(v.layers[v.layers.findIndex(j=>j.id===g.id)+1].id);return}if((a.key==="Delete"||a.key==="Backspace")&&g){a.preventDefault(),f([{op:"remove",id:g.id}]),o(null);return}if(a.key==="Escape"){G?(pe(null),P(null),Y(!1)):p?o(null):(se(),r());return}if(g&&a.key.startsWith("Arrow")){a.preventDefault();const v=a.shiftKey?10:1,j={ArrowLeft:[-v,0],ArrowRight:[v,0],ArrowUp:[0,-v],ArrowDown:[0,v]}[a.key]||[0,0];Ne({x:g.x+j[0],y:g.y+j[1]});return}if(d)return;const b={v:"select",t:"text",r:"rect",o:"ellipse",l:"line",h:"hand"};b[a.key.toLowerCase()]&&M(b[a.key.toLowerCase()])};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)});const at=async(n,a)=>{const d=g;if(!(!d||d.type!=="image"||!d.url||me)){O({tool:n,f:0,label:""});try{const b=await jt({layer:d,tool:n,params:a,brush:G?.kind==="brush"?ke.current:null,box:ee,layerIndex:Q.current.layers.findIndex(j=>j.id===d.id),onProgress:(j,ae)=>O({tool:n,f:j,label:ae})}),v=f(b);if(v&&n==="split_layers"){const j=v.layers.findIndex(ae=>ae.id===d.id);v.layers[j+1]&&o(v.layers[j+1].id)}pe(null),P(null),Y(!1)}catch(b){b.cancelled||h(b.message,"error")}finally{O(null)}}},rt=()=>{const n=ke.current;n?.getContext("2d")?.clearRect(0,0,n.width,n.height),Y(!1)},Oe=async n=>{const a=Q.current;await Promise.all(a.layers.filter(v=>v.type==="image"&&v.url&&!X.current.get(v.url)).map(async v=>{try{const j=await(await fetch(v.url)).blob();X.current.set(v.url,await createImageBitmap(j))}catch{}})),await Promise.all([...new Set(a.layers.filter(v=>v.type==="text").map(v=>je(v)))].map(v=>document.fonts.load(v).catch(()=>null)));const d=new OffscreenCanvas(a.width,a.height),b=d.getContext("2d");return Re(b,a,{getImage:He}),d.convertToBlob(n==="image/jpeg"?{type:n,quality:.92}:{type:n})},lt=async()=>{if(!(!l||_)){B("canvas");try{const n=await Oe("image/png"),a=l.title.replace(/[^\p{L}\p{N} _-]+/gu,"").trim().slice(0,50)||"design",d=await Be(new File([n],`${a}.png`,{type:"image/png"}),void 0,"image");et()?.updateNodeData(t,{url:d.url,gcsUri:d.gcsUri,width:l.width,height:l.height,label:l.title,designId:s});const b=await Ye(s,{doc:l,baseRev:F.current,preview:{gcsUri:d.gcsUri,width:l.width,height:l.height}});F.current=b.rev,N("saved"),h(i("Đã lưu thiết kế về Canvas — dùng như mọi ảnh (Timeline, tham chiếu AI…)"),"ok")}catch(n){h(n.message,"error")}finally{B(null)}}},Ue=async n=>{if(!(!l||_)){B("export");try{const a=await Oe(n),d=document.createElement("a");d.href=URL.createObjectURL(a),d.download=`${l.title||"design"}.${n==="image/png"?"png":"jpg"}`,d.click(),setTimeout(()=>URL.revokeObjectURL(d.href),4e3)}catch(a){h(a.message,"error")}finally{B(null)}}},ot=async n=>{if(l)try{const a=await Be(n,void 0,"image"),d=await createImageBitmap(n);X.current.set(a.url,d);const b=Math.min(l.width*.7/d.width,l.height*.7/d.height,1);Z({type:"image",name:n.name.replace(/\.[^.]+$/,"").slice(0,60),url:a.url,gcsUri:a.gcsUri,x:(l.width-d.width*b)/2,y:(l.height-d.height*b)/2,w:d.width*b,h:d.height*b})}catch(a){h(a.message,"error")}},Ke=(n,a)=>{g?.type==="image"&&Ne({url:n,gcsUri:a})};if(!l)return e.jsx("div",{className:"is-root is-loading",children:i("Đang mở Image Studio…")});const Ve=Object.values(Le).find(n=>n.width===l.width&&n.height===l.height)?.label;return e.jsxs("div",{className:"is-root",role:"dialog","aria-label":"Image Studio",children:[e.jsxs("header",{className:"is-top",children:[e.jsxs("button",{className:"is-btn",onClick:()=>{se(),r()},title:i("Về Canvas (Esc)"),children:["← ",i("Canvas")]}),e.jsx("span",{className:"is-brand",children:"Image Studio"}),e.jsx("input",{className:"is-title",value:l.title,"aria-label":i("Tên thiết kế"),onChange:n=>u({...l,title:n.target.value.slice(0,120)}),onBlur:()=>N("dirty")}),e.jsxs("span",{className:"is-muted mono",children:[l.width," × ",l.height,Ve?` · ${i(Ve)}`:""]}),e.jsx("span",{className:`is-save is-save-${E}`,children:E==="saved"?i("Đã lưu"):E==="saving"?i("Đang lưu…"):E==="dirty"?i("Chưa lưu"):E==="error"?i("Lưu lỗi — thử lại"):""}),e.jsx("div",{className:"is-grow"}),e.jsx("button",{className:"is-btn",onClick:$,disabled:!W.current.length,title:i("Hoàn tác (⌘Z)"),children:"↶"}),e.jsx("button",{className:"is-btn",onClick:q,disabled:!de.current.length,title:i("Làm lại (⇧⌘Z)"),children:"↷"}),e.jsxs("select",{className:"is-select","aria-label":i("Thu phóng"),value:J||0,onChange:n=>k(Number(n.target.value)),children:[e.jsxs("option",{value:0,children:[i("Vừa khung")," (",Math.round(We*100),"%)"]}),[.25,.5,.75,1,1.5,2].map(n=>e.jsxs("option",{value:n,children:[n*100,"%"]},n))]}),e.jsx("button",{className:"is-btn",disabled:!!_,onClick:()=>Ue("image/png"),children:i("Xuất PNG")}),e.jsx("button",{className:"is-btn",disabled:!!_,onClick:()=>Ue("image/jpeg"),children:i("Xuất JPG")}),e.jsx("button",{className:"is-btn is-primary",disabled:!!_,onClick:lt,children:_==="canvas"?i("Đang lưu…"):i("Lưu về Canvas")})]}),E==="conflict"&&e.jsxs("div",{className:"is-conflict",children:[i("Thiết kế này vừa được sửa ở nơi khác (AI của bạn qua MCP hoặc tab khác)."),e.jsx("button",{className:"is-btn",onClick:()=>te(),children:i("Tải bản mới")}),e.jsx("button",{className:"is-btn",onClick:()=>se(!0),children:i("Giữ bản của tôi")})]}),e.jsxs("div",{className:"is-body",children:[e.jsxs("nav",{className:"is-tools","aria-label":i("Công cụ"),children:[[["select","V",i("Chọn / di chuyển"),"M5 3l14 8-6 2-2 6z"],["text","T",i("Chữ"),"M5 5h14M12 5v14M9 19h6"],["rect","R",i("Hình chữ nhật"),"M4 5h16v14H4z"],["ellipse","O",i("Hình tròn"),"M12 4a8 7 0 100 16 8 7 0 100-16z"],["line","L",i("Đường kẻ"),"M4 20L20 4"],["hand","H",i("Bàn tay"),"M8 12V5a1.5 1.5 0 013 0v6M11 11V4a1.5 1.5 0 013 0v7M14 11V6a1.5 1.5 0 013 0v8c0 4-3 7-7 7s-6-3-7-6l-1-3a1.5 1.5 0 012.6-1.4L8 13"]].map(([n,a,d,b])=>e.jsx("button",{className:`is-tool${x===n?" on":""}`,"aria-label":`${d} (${a})`,title:`${d} (${a})`,onClick:()=>M(n),children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:e.jsx("path",{d:b})})},n)),e.jsx("button",{className:"is-tool","aria-label":i("Thêm ảnh từ máy"),title:i("Thêm ảnh từ máy"),onClick:()=>I.current?.click(),children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"M21 15l-5-5L5 21"})]})})]}),e.jsxs("aside",{className:"is-drawer","aria-label":i("Thư viện"),children:[e.jsx("div",{className:"is-tabs",role:"tablist",children:[["templates",i("Mẫu (Image Studio)")],["elements",i("Phần tử")],["text",i("Chữ")],["tools",i("Công cụ")],["canvas",i("Từ Canvas")],["uploads",i("Tải lên")]].map(([n,a])=>e.jsx("button",{role:"tab","aria-selected":S===n,className:`is-tab${S===n?" on":""}`,onClick:()=>y(n),children:a},n))}),e.jsxs("div",{className:"is-drawer-body",children:[S==="templates"&&e.jsx(Bt,{onPick:n=>{const a=tt(n);a&&(l.layers.length&&!window.confirm(i("Thay thiết kế hiện tại bằng mẫu này? (Hoàn tác được)"))||(c(a),o(null)))}}),S==="elements"&&e.jsxs("div",{className:"is-stack",children:[e.jsxs("div",{className:"is-grid3",children:[e.jsxs("button",{className:"is-el",onClick:()=>Z(be("rect",fe(l,360,240))),children:[e.jsx("span",{style:{background:"#B4E36A"}}),i("Chữ nhật")]}),e.jsxs("button",{className:"is-el",onClick:()=>Z({...be("rect",fe(l,360,240)),radius:40}),children:[e.jsx("span",{style:{background:"#B4E36A",borderRadius:8}}),i("Bo góc")]}),e.jsxs("button",{className:"is-el",onClick:()=>Z(be("ellipse",fe(l,280,280))),children:[e.jsx("span",{style:{background:"#B4E36A",borderRadius:"50%"}}),i("Hình tròn")]}),e.jsxs("button",{className:"is-el",onClick:()=>Z({...be("line",{x:l.width*.2,y:l.height/2,w:l.width*.6,h:0})}),children:[e.jsx("span",{style:{height:3,background:"#B4E36A",alignSelf:"center"}}),i("Đường kẻ")]}),e.jsxs("button",{className:"is-el",onClick:()=>Z({type:"rect",...fe(l,400,260),fill:"transparent",stroke:"#ffffff",strokeWidth:4,radius:12}),children:[e.jsx("span",{style:{border:"2px solid #B4E36A"}}),i("Khung viền")]}),e.jsxs("button",{className:"is-el",onClick:()=>Z({type:"image",...fe(l,420,420),placeholder:i("ẢNH CỦA BẠN")}),children:[e.jsx("span",{style:{border:"2px dashed #8A8F98"}}),i("Khung ảnh")]})]}),e.jsx("div",{className:"is-label",children:i("Nền trang")}),e.jsxs("div",{className:"is-swatches",children:[Mt.map(n=>e.jsx("button",{"aria-label":n,style:{background:n},onClick:()=>f([{op:"background",fill:n}])},n)),St.map((n,a)=>e.jsx("button",{"aria-label":i("Nền chuyển màu"),style:{background:Pt(n)},onClick:()=>f([{op:"background",fill:n}])},a))]})]}),S==="text"&&e.jsx("div",{className:"is-stack",children:[[i("Tiêu đề lớn"),{font:"Montserrat",size:96,weight:900}],[i("Tiêu đề phụ"),{font:"Montserrat",size:52,weight:600}],[i("Nội dung"),{font:"Inter",size:32,weight:400}],[i("Chữ sang trọng"),{font:"Playfair Display",size:80,weight:700}],[i("Chữ viết tay"),{font:"Dancing Script",size:72,weight:700}],[i("Chữ nổi bật"),{font:"Anton",size:88,weight:400,upper:!0}]].map(([n,a])=>e.jsx("button",{className:"is-textpreset",style:{fontFamily:`"${a.font}"`,fontWeight:a.weight},onClick:()=>{const d=Z({type:"text",text:n,...a,color:"#111111",...fe(l,Math.min(l.width*.8,900),a.size*1.4),align:"center"});d&&w(d.layers.at(-1).id)},children:n},n))}),S==="tools"&&e.jsx(kt,{layer:g,set:Ne,run:at,cancel:bt,restore:()=>g&&f([{op:"restore",id:g.id}]),busy:me,pick:G,setPick:n=>{pe(n),n||(P(null),Y(!1))},hasBox:!!ee&&ee.w>.01&&ee.h>.01,hasStroke:A,clearPick:rt}),S==="canvas"&&e.jsx(Rt,{onPick:(n,a,d,b)=>{if(g?.type==="image"){Ke(n,a);return}const v=Math.min(l.width*.7/d,l.height*.7/b,1);Z({type:"image",url:n,gcsUri:a,x:(l.width-d*v)/2,y:(l.height-b*v)/2,w:d*v,h:b*v})},replacing:g?.type==="image"}),S==="uploads"&&e.jsxs("div",{className:"is-stack",children:[e.jsx("button",{className:"is-btn is-primary",onClick:()=>I.current?.click(),children:i("Tải ảnh lên")}),e.jsx("p",{className:"is-muted",children:i("Ảnh tải lên thành một lớp mới trên trang. Chọn một khung ảnh trước để thay ảnh trong khung.")})]})]})]}),e.jsx("main",{className:"is-stage",ref:le,children:e.jsxs("div",{className:"is-page",style:{width:l.width*T,height:l.height*T},children:[e.jsx("canvas",{ref:we,style:{width:l.width*T,height:l.height*T},className:`is-canvas is-cursor-${x}`,onPointerDown:it,onPointerMove:Ee,onPointerUp:_e,onDoubleClick:n=>{const a=Je(l,ge(n).x,ge(n).y);a?.type==="text"&&(o(a.id),w(a.id))}}),g&&G&&g.type==="image"&&e.jsx(Nt,{layer:g,scale:T,pick:G,canvasRef:ke,box:ee,setBox:P,onStroke:()=>Y(!0)}),g&&!C&&!G&&e.jsxs("div",{className:"is-sel",style:{left:g.x*T,top:g.y*T,width:g.w*T,height:Math.max(1,g.h)*T,transform:`rotate(${g.rotation||0}deg)`},children:[!g.locked&&Ct.map(n=>e.jsx("span",{className:`is-h is-h-${n}`,onPointerDown:a=>ze(a,n),onPointerMove:Ee,onPointerUp:_e},n)),!g.locked&&e.jsx("span",{className:"is-rot",title:i("Xoay (giữ Shift: 15°)"),onPointerDown:n=>ze(n,"rot"),onPointerMove:Ee,onPointerUp:_e})]}),g&&C===g.id&&g.type==="text"&&e.jsx("textarea",{autoFocus:!0,className:"is-textedit",defaultValue:g.text,"aria-label":i("Sửa chữ"),style:{left:g.x*T,top:g.y*T,width:g.w*T,minHeight:g.h*T,font:je(g,T),color:De(g.color,"#111111"),textAlign:g.align,lineHeight:g.lineHeight,letterSpacing:`${g.letterSpacing||0}em`,transform:`rotate(${g.rotation||0}deg)`,textTransform:g.upper?"uppercase":"none"},onBlur:n=>{const a=n.target.value;w(null),a!==g.text&&Ne({text:a||" "})},onKeyDown:n=>{n.key==="Escape"&&n.target.blur()}})]})}),e.jsxs("aside",{className:"is-side","aria-label":i("Lớp và thuộc tính"),children:[e.jsxs("div",{className:"is-label",children:[i("Lớp")," ",e.jsxs("span",{className:"is-muted",children:["(",l.layers.length,")"]})]}),e.jsx("ul",{className:"is-layers",children:[...l.layers].reverse().map(n=>e.jsxs("li",{className:n.id===p?"on":"",children:[e.jsx("button",{className:"is-eye","aria-label":n.hidden?i("Hiện lớp"):i("Ẩn lớp"),onClick:()=>f([{op:"update",id:n.id,set:{hidden:!n.hidden}}]),children:n.hidden?"◌":"●"}),e.jsx("button",{className:"is-layername",onClick:()=>o(n.id),children:n.name||nt(n)}),e.jsx("button",{className:"is-eye","aria-label":n.locked?i("Mở khoá lớp"):i("Khoá lớp"),onClick:()=>f([{op:"update",id:n.id,set:{locked:!n.locked}}]),children:n.locked?"🔒︎":"⋯"})]},n.id))}),g&&e.jsxs("div",{className:"is-row",children:[e.jsx("button",{className:"is-btn",onClick:()=>f([{op:"order",id:g.id,to:"forward"}]),title:i("Đưa lên"),children:"↑"}),e.jsx("button",{className:"is-btn",onClick:()=>f([{op:"order",id:g.id,to:"backward"}]),title:i("Đưa xuống"),children:"↓"}),e.jsx("button",{className:"is-btn",onClick:()=>{const n=f([{op:"duplicate",id:g.id}]);n&&o(n.layers[n.layers.findIndex(a=>a.id===g.id)+1].id)},children:i("Nhân bản")}),e.jsx("button",{className:"is-btn is-danger",onClick:()=>{f([{op:"remove",id:g.id}]),o(null)},children:i("Xoá")})]}),g?e.jsx(_t,{layer:g,set:Ne}):e.jsx($t,{doc:l,apply:f})]})]}),e.jsx("input",{ref:I,type:"file",accept:"image/*",hidden:!0,onChange:n=>{const a=n.target.files?.[0];a&&(g?.type==="image"&&!g.url?Be(a,void 0,"image").then(d=>Ke(d.url,d.gcsUri)):ot(a)),n.target.value=""}})]})}let Me=null;function Et(t){if(Me??=document.createElement("canvas").getContext("2d"),!Me)return null;Me.font=je(t);const s=t.upper?String(t.text||"").toLocaleUpperCase("vi"):String(t.text||"");return Math.ceil(Ie(Me,s,t.w,t.letterSpacing||0,t.size||48).length*(t.size||48)*(t.lineHeight||1.2))}function fe(t,s,r){return{x:Math.round((t.width-s)/2),y:Math.round((t.height-r)/2),w:s,h:r}}function be(t,s){const r={id:"",x:Math.round(s.x),y:Math.round(s.y),w:Math.round(s.w),h:Math.round(s.h),rotation:0,opacity:1};return t==="text"?{...r,type:"text",text:i("Văn bản"),font:"Be Vietnam Pro",size:64,weight:700,color:"#111111",align:"left",lineHeight:1.2,letterSpacing:0}:t==="ellipse"?{...r,type:"ellipse",fill:"#B4E36A"}:t==="line"?{...r,type:"line",stroke:"#111111",strokeWidth:6}:{...r,type:"rect",fill:"#B4E36A",radius:0}}function nt(t){return t.type==="text"?`T · ${String(t.text).split(`
3
+ `)[0].slice(0,28)}`:t.type==="image"?t.url?i("Ảnh"):`[${t.placeholder||i("Khung ảnh")}]`:t.type==="rect"?i("Hình chữ nhật"):t.type==="ellipse"?i("Hình tròn"):i("Đường kẻ")}function V({label:t,value:s,onChange:r,step:h=1,min:l,max:u}){return e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:t}),e.jsx("input",{type:"number",value:Number.isFinite(s)?Math.round(s*100)/100:0,step:h,min:l,max:u,onChange:p=>{const o=Number(p.target.value);Number.isFinite(o)&&r(o)}})]})}function Ae({label:t,value:s,onChange:r}){const h=s&&typeof s!="string"?s:null;return e.jsxs("div",{className:"is-field is-color",children:[e.jsx("span",{children:t}),h?e.jsxs("span",{className:"is-row",children:[e.jsx("input",{type:"color","aria-label":i("Màu đầu"),value:h.stops[0][1].slice(0,7),onChange:l=>r({...h,stops:[[0,l.target.value],...h.stops.slice(1)]})}),e.jsx("input",{type:"color","aria-label":i("Màu cuối"),value:h.stops.at(-1)[1].slice(0,7),onChange:l=>r({...h,stops:[...h.stops.slice(0,-1),[1,l.target.value]]})}),e.jsx("button",{className:"is-btn",onClick:()=>r(h.stops[0][1].slice(0,7)),children:i("Màu đơn")})]}):e.jsxs("span",{className:"is-row",children:[e.jsx("input",{type:"color","aria-label":t,value:De(s,"#000000"),onChange:l=>r(l.target.value)}),e.jsx("button",{className:"is-btn",onClick:()=>r({type:"linear",angle:180,stops:[[0,De(s,"#000000")],[1,"#ffffff"]]}),children:i("Chuyển màu")}),s==="transparent"?e.jsx("span",{className:"is-muted",children:i("trong suốt")}):e.jsx("button",{className:"is-btn",onClick:()=>r("transparent"),children:i("Trong suốt")})]})]})}function _t({layer:t,set:s}){return ye(),e.jsxs("div",{className:"is-props",children:[e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:i("Tên lớp")}),e.jsx("input",{value:t.name||"",placeholder:nt(t),onChange:r=>s({name:r.target.value})})]}),e.jsxs("div",{className:"is-grid2",children:[e.jsx(V,{label:"X",value:t.x,onChange:r=>s({x:r})}),e.jsx(V,{label:"Y",value:t.y,onChange:r=>s({y:r})}),e.jsx(V,{label:"W",value:t.w,onChange:r=>s({w:r}),min:1}),e.jsx(V,{label:"H",value:t.h,onChange:r=>s({h:r}),min:1}),e.jsx(V,{label:i("Xoay"),value:t.rotation,onChange:r=>s({rotation:r})}),e.jsx(V,{label:i("Độ mờ %"),value:t.opacity*100,onChange:r=>s({opacity:r/100}),min:0,max:100})]}),t.type==="text"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:i("Nội dung")}),e.jsx("textarea",{rows:3,value:t.text,onChange:r=>s({text:r.target.value})})]}),e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:i("Font")}),e.jsx("select",{value:t.font,onChange:r=>s({font:r.target.value}),children:pt.filter(r=>r.category!=="System").map(r=>e.jsx("option",{value:r.family,style:{fontFamily:`"${r.family}"`},children:r.family},r.family))})]}),e.jsxs("div",{className:"is-grid2",children:[e.jsx(V,{label:i("Cỡ chữ"),value:t.size||48,onChange:r=>s({size:r}),min:4}),e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:i("Độ đậm")}),e.jsx("select",{value:t.weight,onChange:r=>s({weight:Number(r.target.value)}),children:[300,400,500,600,700,800,900].map(r=>e.jsx("option",{value:r,children:r},r))})]}),e.jsx(V,{label:i("Giãn dòng"),value:t.lineHeight||1.2,step:.05,onChange:r=>s({lineHeight:r})}),e.jsx(V,{label:i("Giãn chữ"),value:t.letterSpacing||0,step:.01,onChange:r=>s({letterSpacing:r})})]}),e.jsxs("div",{className:"is-row",children:[["left","center","right"].map(r=>e.jsx("button",{className:`is-btn${t.align===r?" on":""}`,onClick:()=>s({align:r}),children:r==="left"?i("Trái"):r==="center"?i("Giữa"):i("Phải")},r)),e.jsx("button",{className:`is-btn${t.italic?" on":""}`,onClick:()=>s({italic:!t.italic}),children:e.jsx("i",{children:"I"})}),e.jsx("button",{className:`is-btn${t.upper?" on":""}`,onClick:()=>s({upper:!t.upper}),children:"AA"})]}),e.jsx(Ae,{label:i("Màu chữ"),value:t.color,onChange:r=>s({color:r})})]}),(t.type==="rect"||t.type==="ellipse")&&e.jsx(Ae,{label:i("Màu nền"),value:t.fill,onChange:r=>s({fill:r})}),(t.type==="rect"||t.type==="image")&&e.jsx(V,{label:i("Bo góc"),value:t.radius||0,onChange:r=>s({radius:r}),min:0}),t.type!=="image"&&e.jsxs("div",{className:"is-grid2",children:[e.jsxs("label",{className:"is-field is-color",children:[e.jsx("span",{children:t.type==="line"?i("Màu đường"):i("Viền")}),e.jsx("input",{type:"color",value:(t.stroke||"#000000").slice(0,7),onChange:r=>s({stroke:r.target.value,strokeWidth:t.strokeWidth||2})})]}),e.jsx(V,{label:i("Độ dày viền"),value:t.strokeWidth||0,onChange:r=>s({strokeWidth:r,...t.stroke?{}:{stroke:"#000000"}}),min:0})]}),t.type==="image"&&e.jsx("div",{className:"is-row",children:["cover","contain"].map(r=>e.jsx("button",{className:`is-btn${t.fit===r?" on":""}`,onClick:()=>s({fit:r}),children:r==="cover"?i("Lấp đầy khung"):i("Vừa khung")},r))}),e.jsxs("label",{className:"is-check",children:[e.jsx("input",{type:"checkbox",checked:!!t.shadow,onChange:r=>s({shadow:r.target.checked?{color:"#00000066",blur:24,x:0,y:8}:void 0})})," ",i("Đổ bóng")]})]})}function $t({doc:t,apply:s}){return ye(),e.jsxs("div",{className:"is-props",children:[e.jsx("div",{className:"is-label",children:i("Trang")}),e.jsxs("label",{className:"is-field",children:[e.jsx("span",{children:i("Khổ")}),e.jsxs("select",{value:"",onChange:r=>{const h=Le[r.target.value];h&&s([{op:"resize",width:h.width,height:h.height,scale:!0}])},children:[e.jsxs("option",{value:"",children:[t.width," × ",t.height]}),Object.entries(Le).map(([r,h])=>e.jsxs("option",{value:r,children:[i(h.label)," · ",h.width,"×",h.height]},r))]})]}),e.jsx(Ae,{label:i("Nền trang"),value:t.background,onChange:r=>s([{op:"background",fill:r}])}),e.jsx("p",{className:"is-muted",children:i("Bấm vào một lớp để sửa. Kéo để di chuyển, kéo góc để đổi cỡ (Shift: giữ tỉ lệ), kéo chấm tròn để xoay. Double-click chữ để gõ.")})]})}function Bt({onPick:t}){ye();const[s,r]=m.useState(""),h=mt.filter(l=>!s||`${l.label} ${l.category}`.toLowerCase().includes(s.toLowerCase()));return e.jsxs("div",{className:"is-stack",children:[e.jsx("input",{className:"is-search",placeholder:i("Tìm mẫu: Tết, sale, menu…"),"aria-label":i("Tìm mẫu"),value:s,onChange:l=>r(l.target.value)}),e.jsx("div",{className:"is-grid2",children:h.map(l=>e.jsx(Lt,{id:l.id,label:i(l.label),onPick:()=>t(l.id)},l.id))})]})}function Lt({id:t,label:s,onPick:r}){const h=m.useRef(null);return m.useEffect(()=>{const l=tt(t),u=h.current;if(!l||!u)return;const p=150/Math.max(l.width,l.height);u.width=Math.round(l.width*p),u.height=Math.round(l.height*p);const o=()=>{const x=u.getContext("2d");x&&Re(x,l,{scale:p})};o(),Promise.all([...new Set(l.layers.filter(x=>x.type==="text").map(x=>je(x)))].map(x=>document.fonts.load(x).catch(()=>null))).then(o)},[t]),e.jsxs("button",{className:"is-tpl",onClick:r,title:s,children:[e.jsx("canvas",{ref:h}),e.jsx("span",{children:s})]})}function Rt({onPick:t,replacing:s}){ye();const r=(et()?.nodes()||[]).filter(h=>h.type==="image"&&h.data?.url).slice(-40).reverse();return e.jsxs("div",{className:"is-stack",children:[e.jsx("p",{className:"is-muted",children:s?i("Bấm một ảnh để thay ảnh trong khung đang chọn."):i("Bấm một ảnh trên Canvas để thêm thành lớp.")}),e.jsxs("div",{className:"is-grid2",children:[r.map(h=>{const l=h.data;return e.jsxs("button",{className:"is-tpl",onClick:()=>t(String(l.url),typeof l.gcsUri=="string"?l.gcsUri:void 0,Number(l.width)||1024,Number(l.height)||1024),children:[e.jsx("img",{src:String(l.url),alt:""}),e.jsx("span",{children:String(l.label||i("Ảnh"))})]},h.id)}),!r.length&&e.jsx("p",{className:"is-muted",children:i("Canvas chưa có ảnh nào.")})]})]})}export{js as default};
@@ -0,0 +1 @@
1
+ @font-face{font-family:Inter;src:url(/fonts/google/Inter-Variable.ttf) format("truetype");font-weight:100 900;font-display:swap}@font-face{font-family:Be Vietnam Pro;src:url(/fonts/google/BeVietnamPro-Regular.ttf) format("truetype");font-weight:400;font-display:swap}@font-face{font-family:Roboto;src:url(/fonts/google/Roboto-Variable.ttf) format("truetype");font-weight:100 900;font-stretch:75% 100%;font-display:swap}@font-face{font-family:Open Sans;src:url(/fonts/google/OpenSans-Variable.ttf) format("truetype");font-weight:300 800;font-stretch:75% 100%;font-display:swap}@font-face{font-family:Montserrat;src:url(/fonts/google/Montserrat-Variable.ttf) format("truetype");font-weight:100 900;font-display:swap}@font-face{font-family:Manrope;src:url(/fonts/google/Manrope-Variable.ttf) format("truetype");font-weight:200 800;font-display:swap}@font-face{font-family:Lexend;src:url(/fonts/google/Lexend-Variable.ttf) format("truetype");font-weight:100 900;font-display:swap}@font-face{font-family:Archivo;src:url(/fonts/google/Archivo-Variable.ttf) format("truetype");font-weight:100 900;font-stretch:62% 125%;font-display:swap}@font-face{font-family:Barlow;src:url(/fonts/google/Barlow-Regular.ttf) format("truetype");font-weight:400;font-display:swap}@font-face{font-family:Noto Sans;src:url(/fonts/google/NotoSans-Variable.ttf) format("truetype");font-weight:100 900;font-stretch:62% 100%;font-display:swap}@font-face{font-family:"Noto Serif";src:url(/fonts/google/NotoSerif-Variable.ttf) format("truetype");font-weight:100 900;font-stretch:62% 100%;font-display:swap}@font-face{font-family:Playfair Display;src:url(/fonts/google/PlayfairDisplay-Variable.ttf) format("truetype");font-weight:400 900;font-display:swap}@font-face{font-family:Oswald;src:url(/fonts/google/Oswald-Variable.ttf) format("truetype");font-weight:200 700;font-display:swap}@font-face{font-family:Anton;src:url(/fonts/google/Anton-Regular.ttf) format("truetype");font-weight:400;font-display:swap}@font-face{font-family:Bungee;src:url(/fonts/google/Bungee-Regular.ttf) format("truetype");font-weight:400;font-display:swap}@font-face{font-family:Dancing Script;src:url(/fonts/google/DancingScript-Variable.ttf) format("truetype");font-weight:400 700;font-display:swap}.is-root{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;background:#0d0f0d;color:#e7ebe6;font:13px/1.4 Inter,system-ui,sans-serif}.is-loading{align-items:center;justify-content:center;color:#8b948b}.is-top{display:flex;align-items:center;gap:8px;height:52px;padding:0 12px;border-bottom:1px solid #22261f;background:#111411;flex-shrink:0}.is-brand{font-weight:700;color:#c6f432;letter-spacing:.02em}.is-title{background:transparent;border:1px solid transparent;color:inherit;font:600 14px Inter,sans-serif;padding:5px 8px;border-radius:6px;min-width:140px;max-width:280px}.is-title:hover,.is-title:focus{border-color:#2c322a;background:#161a15;outline:none}.is-muted{color:#8b948b;font-size:12px}.mono{font-variant-numeric:tabular-nums}.is-save{font-size:12px;color:#8b948b}.is-save-dirty{color:#e8c25a}.is-save-error{color:#ff7b6b}.is-save-saved{color:#8fb86a}.is-grow{flex:1}.is-btn{background:#1a1e19;border:1px solid #2c322a;color:#e7ebe6;border-radius:7px;padding:6px 10px;font:inherit;cursor:pointer;white-space:nowrap}.is-btn:hover:not(:disabled){border-color:#4a5446;background:#20251e}.is-btn:disabled{opacity:.45;cursor:default}.is-btn.on{background:#c6f432;color:#10140c;border-color:#c6f432;font-weight:600}.is-primary{background:#c6f432;color:#10140c;border-color:#c6f432;font-weight:700}.is-primary:hover:not(:disabled){background:#d4ff4a;border-color:#d4ff4a}.is-danger{color:#ff8b7b}.is-select,.is-props select,.is-props input,.is-props textarea,.is-search{background:#161a15;border:1px solid #2c322a;color:#e7ebe6;border-radius:6px;padding:5px 7px;font:inherit;min-width:0}.is-conflict{display:flex;gap:10px;align-items:center;padding:8px 14px;background:#3a2c0d;color:#ffe2a0;border-bottom:1px solid #5a4415}.is-body{flex:1;display:flex;min-height:0}.is-tools{width:52px;display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 0;border-right:1px solid #22261f;background:#111411}.is-tool{width:38px;height:38px;border-radius:9px;border:1px solid transparent;background:transparent;color:#b8c0b6;display:grid;place-items:center;cursor:pointer}.is-tool:hover{background:#1a1e19;color:#fff}.is-tool.on{background:#c6f432;color:#10140c}.is-drawer{width:300px;display:flex;flex-direction:column;border-right:1px solid #22261f;background:#121512;min-height:0}.is-tabs{display:flex;flex-wrap:wrap;gap:4px;padding:10px;border-bottom:1px solid #22261f}.is-tab{background:transparent;border:1px solid #2c322a;color:#b8c0b6;border-radius:999px;padding:4px 10px;font:inherit;font-size:12px;cursor:pointer}.is-tab.on{background:#c6f432;color:#10140c;border-color:#c6f432;font-weight:600}.is-drawer-body{flex:1;overflow:auto;padding:12px}.is-stack{display:flex;flex-direction:column;gap:10px}.is-grid2{display:grid;grid-template-columns:1fr 1fr;gap:8px}.is-grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.is-label{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:#8b948b;display:flex;gap:6px;align-items:center}.is-free{background:#203316;color:#b4e36a;border-radius:4px;padding:1px 5px;font-size:10px}.is-el{display:flex;flex-direction:column;gap:6px;align-items:stretch;background:#181c17;border:1px solid #262b24;border-radius:8px;padding:8px;color:#cfd6cd;font:inherit;font-size:11px;cursor:pointer}.is-el span{display:block;height:34px}.is-el:hover,.is-tpl:hover,.is-textpreset:hover{border-color:#c6f432}.is-swatches{display:grid;grid-template-columns:repeat(8,1fr);gap:6px}.is-swatches button{aspect-ratio:1;border-radius:6px;border:1px solid #3a4137;cursor:pointer}.is-textpreset{background:#181c17;border:1px solid #262b24;border-radius:8px;padding:12px;color:#fff;font-size:20px;text-align:left;cursor:pointer}.is-tpl{display:flex;flex-direction:column;gap:5px;background:#181c17;border:1px solid #262b24;border-radius:8px;padding:6px;color:#cfd6cd;font:inherit;font-size:11px;cursor:pointer;text-align:left}.is-tpl canvas,.is-tpl img{width:100%;aspect-ratio:1;object-fit:contain;background:#0b0d0b;border-radius:5px}.is-soon{display:flex;flex-direction:column;gap:2px;background:#151815;border:1px dashed #2c322a;border-radius:8px;padding:7px;color:#8b948b;font-size:11px}.is-soon small{color:#5f675d;font-size:10px}.is-stage{flex:1;overflow:auto;display:grid;place-items:center;background:#1a1d19 radial-gradient(#262a24 1px,transparent 1px) 0 0/18px 18px;min-width:0;padding:48px}.is-page{position:relative;box-shadow:0 10px 40px #0000008c}.is-canvas{display:block;touch-action:none}.is-cursor-select{cursor:default}.is-cursor-hand{cursor:grab}.is-cursor-text{cursor:text}.is-cursor-rect,.is-cursor-ellipse,.is-cursor-line{cursor:crosshair}.is-sel{position:absolute;outline:1.5px solid #c6f432;pointer-events:none;transform-origin:center}.is-h{position:absolute;width:10px;height:10px;background:#fff;border:1.5px solid #6a9a10;border-radius:2px;pointer-events:auto;margin:-5px 0 0 -5px}.is-h-nw{left:0;top:0;cursor:nwse-resize}.is-h-n{left:50%;top:0;cursor:ns-resize}.is-h-ne{left:100%;top:0;cursor:nesw-resize}.is-h-e{left:100%;top:50%;cursor:ew-resize}.is-h-se{left:100%;top:100%;cursor:nwse-resize}.is-h-s{left:50%;top:100%;cursor:ns-resize}.is-h-sw{left:0;top:100%;cursor:nesw-resize}.is-h-w{left:0;top:50%;cursor:ew-resize}.is-rot{position:absolute;left:50%;top:-28px;width:14px;height:14px;margin-left:-7px;border-radius:50%;background:#c6f432;border:2px solid #10140c;pointer-events:auto;cursor:grab}.is-textedit{position:absolute;background:#ffffff0f;border:1.5px dashed #c6f432;resize:none;padding:0;margin:0;outline:none;overflow:hidden;transform-origin:center}.is-side{width:290px;overflow:auto;border-left:1px solid #22261f;background:#121512;padding:12px;display:flex;flex-direction:column;gap:10px}.is-layers{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px;max-height:240px;overflow:auto}.is-layers li{display:flex;align-items:center;gap:4px;border-radius:6px;padding:2px 4px}.is-layers li.on{background:#22301a}.is-layername{flex:1;text-align:left;background:transparent;border:0;color:#dfe5dd;font:inherit;font-size:12px;padding:4px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.is-eye{background:transparent;border:0;color:#8b948b;cursor:pointer;width:22px;font-size:12px}.is-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center}.is-props{display:flex;flex-direction:column;gap:9px}.is-field{display:flex;flex-direction:column;gap:3px;font-size:11px;color:#8b948b}.is-field input[type=color]{width:34px;height:26px;padding:1px;border-radius:5px}.is-field input[type=range]{accent-color:#c6f432}.is-check{display:flex;gap:6px;align-items:center;font-size:12px}@media(max-width:900px){.is-drawer{width:220px}.is-side{width:230px}}.is-root *,.is-root *:before,.is-root *:after{box-sizing:border-box}.is-field input:not([type=color]):not([type=range]):not([type=checkbox]),.is-field select,.is-field textarea{width:100%}.is-photo .is-ptool{display:flex;justify-content:space-between;align-items:center;width:100%;background:#151815;border:1px solid #262b25;border-radius:8px;padding:8px 10px;color:#dfe5dc;font-size:12px;cursor:pointer;text-align:left}.is-photo .is-ptool small{color:#b4e36a;font-size:10px}.is-photo .is-ptool:hover:not(:disabled){border-color:#3d4a33}.is-photo .is-ptool.on{border-color:#c6f432;background:#1b2214}.is-photo .is-ptool.star{background:linear-gradient(90deg,#24331a,#151815);border-color:#4a6b23;font-weight:700}.is-photo .is-ptool:disabled{opacity:.45;cursor:default}.is-popts{display:flex;flex-direction:column;gap:8px;padding:8px 4px 10px 8px;border-left:2px solid #2c3a20;margin:-2px 0 2px 6px}.is-chips{display:flex;flex-wrap:wrap;gap:5px}.is-chip{background:#1a1d19;border:1px solid #2c322a;color:#cfd6cc;border-radius:999px;padding:3px 10px;font-size:11px;cursor:pointer}.is-chip.on{background:#c6f432;color:#111;border-color:#c6f432}.is-run{align-self:flex-start}.is-busy{display:flex;flex-direction:column;gap:6px;background:#141a10;border:1px solid #33452a;border-radius:8px;padding:8px;font-size:11px;color:#dfe5dc}.is-bar{height:5px;background:#24291f;border-radius:3px;overflow:hidden}.is-bar span{display:block;height:100%;background:#c6f432;transition:width .2s}.is-busy .is-btn{align-self:flex-end}.is-pick{position:absolute;transform-origin:center center;z-index:4;touch-action:none;outline:1px dashed #c6f432}.is-pick-brush,.is-pick-box{cursor:crosshair}.is-pickbox{position:absolute;border:2px solid #c6f432;background:#c6f4321f;box-shadow:0 0 0 9999px #00000040;pointer-events:none}.is-paid{background:#33270f;color:#f1c46a;border-radius:4px;padding:1px 5px;font-size:10px}.is-prompt{width:100%;box-sizing:border-box;resize:vertical;min-height:44px;background:#161a15;color:#e7ebe6;border:1px solid #2c322a;border-radius:6px;padding:6px 8px;font:inherit;font-size:12px}.is-prompt:focus{outline:none;border-color:#c6f432}.is-small{font-size:11px}
@@ -1 +1 @@
1
- import{j as w,_ as F}from"./remote-kxNNhmis.js";import{r as l}from"./index-CKtv7gGE.js";import{d as M,m as E}from"./lottieLayer-Dp_vGTy8.js";import"./i18n-C9zFX25m.js";import"./api-DJC95K48.js";import"./titleFrameBudget-BW-N1-cw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";const I=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],j={"16:9":[1280,720],"9:16":[720,1280],"1:1":[960,960],"4:5":[768,960]},L=f=>j[f.aspect??"16:9"]??j["16:9"];function G(){const f=l.useRef(null),[e,R]=l.useState(null),[y,x]=l.useState(""),b=l.useRef(Promise.resolve());return l.useEffect(()=>{const r=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),h=async t=>{if(!I.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const i="id"in t.data?t.data.id:null;let o;try{o=F(t.data.motion)}catch(n){r(t,{type:"clipoox-motion-error",id:i,error:n.message});return}if(t.data.type==="clipoox-motion-play"){x(""),R(o);return}if(t.data.type==="clipoox-motion-thumb"){const[n,u]=L(o),m=480/Math.max(n,u),s=Math.round(n*m),p=Math.round(u*m);try{const d=await E({layer:"embed:thumb",motion:{v:1,code:o.code,params:o.params},t:Number.isFinite(t.data.t)?Math.max(0,Math.min(o.duration,Number(t.data.t))):o.duration*.55,width:s,height:p,duration:o.duration}),c=Object.assign(document.createElement("canvas"),{width:s,height:p}),g=c.getContext("2d");if(!g)throw Error("canvas");g.fillStyle="#16181c",g.fillRect(0,0,s,p),g.drawImage(d,0,0),d.close(),r(t,{type:"clipoox-motion-thumb",id:i,webp:c.toDataURL("image/webp",.85)})}catch(d){r(t,{type:"clipoox-motion-error",id:i,error:d.message})}finally{M("embed:thumb")}}},a=t=>{b.current=b.current.then(()=>h(t)).catch(()=>{})};return window.addEventListener("message",a),window.parent?.postMessage({type:"clipoox-motion-ready"},"*"),()=>window.removeEventListener("message",a)},[]),l.useEffect(()=>{const r=f.current,h=r?.getContext("2d");if(!e||!r||!h)return;let a=!0,t=0;const i=performance.now(),[o,n]=L(e),u=Math.min(1,960/Math.max(o,n)),m=Math.round(o*u),s=Math.round(n*u);r.width=m,r.height=s;const p=async()=>{if(!a)return;const d=(performance.now()-i)/1e3%(e.duration+.8);try{const c=await E({layer:"embed:play",motion:{v:1,code:e.code,params:e.params},t:Math.min(d,e.duration),width:m,height:s,duration:e.duration});a&&(h.clearRect(0,0,m,s),h.drawImage(c,0,0)),c.close()}catch(c){if(a){x(c.message);return}}a&&(t=requestAnimationFrame(()=>void p()))};return p(),()=>{a=!1,cancelAnimationFrame(t),M("embed:play")}},[e]),w.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[w.jsx("canvas",{ref:f,width:1280,height:720,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Motion preview"}),y&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:y})]})}export{G as default};
1
+ import{j as w,_ as F}from"./remote-CpkPQOQH.js";import{r as l}from"./index-CKtv7gGE.js";import{d as M,m as E}from"./lottieLayer-DEw0c3to.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const I=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],j={"16:9":[1280,720],"9:16":[720,1280],"1:1":[960,960],"4:5":[768,960]},L=f=>j[f.aspect??"16:9"]??j["16:9"];function G(){const f=l.useRef(null),[e,R]=l.useState(null),[y,x]=l.useState(""),b=l.useRef(Promise.resolve());return l.useEffect(()=>{const r=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),h=async t=>{if(!I.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const i="id"in t.data?t.data.id:null;let o;try{o=F(t.data.motion)}catch(n){r(t,{type:"clipoox-motion-error",id:i,error:n.message});return}if(t.data.type==="clipoox-motion-play"){x(""),R(o);return}if(t.data.type==="clipoox-motion-thumb"){const[n,u]=L(o),m=480/Math.max(n,u),s=Math.round(n*m),p=Math.round(u*m);try{const d=await E({layer:"embed:thumb",motion:{v:1,code:o.code,params:o.params},t:Number.isFinite(t.data.t)?Math.max(0,Math.min(o.duration,Number(t.data.t))):o.duration*.55,width:s,height:p,duration:o.duration}),c=Object.assign(document.createElement("canvas"),{width:s,height:p}),g=c.getContext("2d");if(!g)throw Error("canvas");g.fillStyle="#16181c",g.fillRect(0,0,s,p),g.drawImage(d,0,0),d.close(),r(t,{type:"clipoox-motion-thumb",id:i,webp:c.toDataURL("image/webp",.85)})}catch(d){r(t,{type:"clipoox-motion-error",id:i,error:d.message})}finally{M("embed:thumb")}}},a=t=>{b.current=b.current.then(()=>h(t)).catch(()=>{})};return window.addEventListener("message",a),window.parent?.postMessage({type:"clipoox-motion-ready"},"*"),()=>window.removeEventListener("message",a)},[]),l.useEffect(()=>{const r=f.current,h=r?.getContext("2d");if(!e||!r||!h)return;let a=!0,t=0;const i=performance.now(),[o,n]=L(e),u=Math.min(1,960/Math.max(o,n)),m=Math.round(o*u),s=Math.round(n*u);r.width=m,r.height=s;const p=async()=>{if(!a)return;const d=(performance.now()-i)/1e3%(e.duration+.8);try{const c=await E({layer:"embed:play",motion:{v:1,code:e.code,params:e.params},t:Math.min(d,e.duration),width:m,height:s,duration:e.duration});a&&(h.clearRect(0,0,m,s),h.drawImage(c,0,0)),c.close()}catch(c){if(a){x(c.message);return}}a&&(t=requestAnimationFrame(()=>void p()))};return p(),()=>{a=!1,cancelAnimationFrame(t),M("embed:play")}},[e]),w.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[w.jsx("canvas",{ref:f,width:1280,height:720,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Motion preview"}),y&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:y})]})}export{G as default};
@@ -1,3 +1,3 @@
1
- import{r as Te,j as n}from"./remote-kxNNhmis.js";import{r as l}from"./index-CKtv7gGE.js";import{u as ke,t}from"./i18n-C9zFX25m.js";import{a1 as Ae,a2 as Ee,a3 as Ie,a4 as we,a5 as ye,a6 as Z,a7 as _,T as Q,a8 as Ke,O as Ve,a9 as Fe,A as Oe,N as Re,aa as Be,q as qe,ab as Ge,ac as J,ad as He,ae as _e,e as We,af as Xe,ag as ze}from"./main-DAk1Tv1E.js";import{d as Qe,k as Je,m as Ye,l as Ze}from"./lottieLayer-Dp_vGTy8.js";import{p as en}from"./TimelinePlugins-zhB9Uqav.js";import"./api-DJC95K48.js";import"./titleFrameBudget-BW-N1-cw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";import"./spark.module-B341moK0.js";import"./userFonts-DSkZHfmh.js";import"./timeline3d-D0Ws4lcp.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./glTransitionSources.generated-BJuEUz3E.js";import"./clientJobs-BqkjV5Ld.js";import"./captionLayout-CAuhUiW9.js";import"./timelineText-DjPW2-dd.js";import"./titleArt-BSu80bfN.js";import"./personHq-Cyq9HWnW.js";import"./matteQuality-9X-jgJrH.js";import"./sceneTrack-BKknn180.js";import"./rotoMatte-DisQplSv.js";import"./objectSegmenter-oGv8YQbI.js";import"./cutoutClean-CLYYAuXg.js";import"./distortGL-waTJhiOf.js";import"./motionBlur-uAm030t9.js";import"./pluginAutomation-D73Az7HS.js";const Se=[{id:"all",vi:"Tất cả",en:"All"},{id:"motion",vi:"Motion",en:"Motion"},{id:"lottie",vi:"Lottie",en:"Lottie"},{id:"recipe",vi:"Công thức",en:"Recipe"},{id:"sfx",vi:"Âm thanh",en:"Sounds"},{id:"pack",vi:"Gói ngách",en:"Niche pack"},{id:"kit",vi:"Bộ 3D",en:"3D kit"},{id:"sfxlib",vi:"Kho âm thanh",en:"Sound library"},{id:"link",vi:"Cho AI agent",en:"AI agents"}],B=s=>s.kind==="pack"&&!!s.kit?.modelAssets,ie=s=>B(s)?"kit":s.kind,q=s=>s.kind==="link"&&!!s.link,nn=s=>{s.link&&window.open(s.link.url,"_blank","noopener,noreferrer")},Ce=(s,r)=>s>=1024*1024?`${(s/1024/1024).toFixed(s>=10*1024*1024?0:1).replace(".",r==="en"?".":",")} MB`:`${Math.max(1,Math.round(s/1024))} KB`,le=({n:s=28})=>n.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:s},(r,c)=>n.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(c*1.37)*Math.cos(c*.41)))}%`}},c))}),Le=(s,r)=>Se.find(c=>c.id===s)?.[r==="en"?"en":"vi"]??s,sn=5e3,tn=600*1e3,Ne=s=>s.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),Y=s=>(s.passVnd??0)>0||(s.passUsd??0)>0,an=s=>{const r=(c,h)=>c>0&&h>0?Math.min(c,h):c>0?c:h;return _({priceVnd:r(s.priceVnd,s.passVnd??0),priceUsd:r(s.priceUsd,s.passUsd??0)})};function Qn({installed:s,initialId:r=null,onClose:c,onInstalled:h,onUse:v,toast:o}){const x=ke(),u=x==="en"?"en":"vi",[j,y]=l.useState(null),[g,S]=l.useState([]),[M,U]=l.useState(""),[p,i]=l.useState("all"),[d,b]=l.useState("all"),[C,K]=l.useState(""),[W,A]=l.useState(0),[w,D]=l.useState(null),[E,N]=l.useState(!1),[P,L]=l.useState(),[T,V]=l.useState("");l.useEffect(()=>{const e=window.setTimeout(()=>V(C.trim()),250);return()=>window.clearTimeout(e)},[C]);const I=l.useCallback(e=>Ae({q:T||void 0,kind:d==="all"?void 0:d==="pack"?"niche":d,price:p==="free"?"free":p==="paid"?"paid":void 0,limit:ze,cursor:e||void 0}),[T,d,p]),F=l.useRef(null),O=l.useRef(0),[k,R]=l.useState(null),[re,ce]=l.useState(""),[X,ee]=l.useState({}),[ne,Me]=l.useState(""),G=l.useCallback(()=>Ee().then(e=>(S(e.owned),e.owned)).catch(()=>[]),[]),[oe,Ue]=l.useState(!1);l.useEffect(()=>{G().finally(()=>Ue(!0))},[G]),l.useEffect(()=>{if(p==="owned")return;const e=++O.current;y(null),U(""),I().then(a=>{e===O.current&&(y(a.items),A(a.total??a.items.length),D(a.nextCursor??null),L(a.facets))},a=>{e===O.current&&(y([]),D(null),U(a.message))})},[I,p]);const se=l.useCallback(()=>{if(!w||E||p==="owned")return;const e=O.current;N(!0),I(w).then(a=>{e===O.current&&(y(m=>{const f=new Set((m??[]).map($=>$.id));return[...m??[],...a.items.filter($=>!f.has($.id))]}),D(a.nextCursor??null))},a=>{e===O.current&&U(a.message)}).finally(()=>N(!1))},[w,E,p,I]);l.useEffect(()=>{const e=F.current;if(!e||!w)return;const a=new IntersectionObserver(m=>{m.some(f=>f.isIntersecting)&&se()},{rootMargin:"600px"});return a.observe(e),()=>a.disconnect()},[w,se,j]);const de=l.useRef(!1);l.useEffect(()=>{if(!r||de.current||j===null||!oe)return;de.current=!0;const e=j.find(a=>a.id===r)??g.find(a=>a.storeId===r&&a.item)?.item;e?R(e):Ie(r).then(a=>R(a.item),()=>o(t("Không tìm thấy plug-in này trong kho."),"error"))},[r,j,g,oe,o]),l.useEffect(()=>{const e=a=>{a.key==="Escape"&&(a.stopPropagation(),k?R(null):c())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[k,c]);const he=Object.keys(X).join(",");l.useEffect(()=>{if(!he)return;const e=window.setInterval(()=>{G().then(a=>{ee(m=>{const f={...m};for(const $ of Object.keys(f))(xe(a,$)||Date.now()-f[$]>tn)&&delete f[$];return f})})},sn);return()=>window.clearInterval(e)},[he,G]);const H=e=>g.some(a=>a.storeId===e&&a.owned),te=e=>g.find(a=>a.storeId===e),ue=e=>g.some(a=>a.storeId===e&&a.status==="refunded"),me=e=>s.some(a=>a.id===e&&a.source?.store===e),ae=async e=>{ce(e.id);try{await Be(e.id),h(),qe(),Me(e.id),o(t("Đã cài “{0}” vào Plug-in của tôi",[e.name[u]]),"ok")}catch(a){const m=en(a);o(m.text,"error")}finally{ce("")}},pe=l.useRef({}),ge=e=>e?.owned?e.expiresAt?String(e.expiresAt):"life":"none",xe=(e,a)=>{const m=e.find(f=>f.storeId===a);return!!m?.owned&&ge(m)!==(pe.current[a]??"none")},fe=(e,a)=>{pe.current[e.id]=ge(te(e.id)),Re(e.id,a),ee(m=>({...m,[e.id]:Date.now()}))},De=async e=>{const a=await G();xe(a,e)?(ee(m=>{const f={...m};return delete f[e],f}),o(t("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):o(t("Chưa thấy thanh toán. Nếu bạn vừa chuyển khoản, đợi một chút rồi kiểm tra lại."),"error")},$e=g.filter(e=>e.item).map(e=>e.item),z=(p==="owned"?$e:(j??[]).filter(e=>p==="all"||(p==="free"?e.free:!e.free))).filter(e=>(d==="all"||ie(e)===d)&&(!C.trim()||Ne(C).split(/\s+/).every(a=>Ne(`${e.name.vi} ${e.name.en} ${e.description.vi} ${e.description.en} ${e.author.name} ${e.tags.join(" ")}`).includes(a)))),Pe=[{id:"all",label:t("Plug-in")},{id:"free",label:t("Miễn phí")},{id:"paid",label:t("Trả phí")},{id:"owned",label:t("Đã sở hữu")}],ve=(e,a)=>re===e.id?n.jsxs("button",{className:a,disabled:!0,children:[n.jsx("i",{className:"spin"})," ",t("Đang cài…")]}):me(e.id)||ne===e.id?n.jsxs(n.Fragment,{children:[v?n.jsxs("button",{className:`${a} ps-use`,onClick:()=>v(e.id),children:["✓ ",t("Đã cài · Dùng ngay")]}):n.jsxs("span",{className:`${a} ps-use`,role:"status",children:["✓ ",t("Đã cài")]}),n.jsx("button",{className:"ps-reinstall",title:t("Cài lại plug-in"),onClick:()=>void ae(e),children:t("Cài lại")})]}):n.jsx("button",{className:a,onClick:()=>void ae(e),children:t("Cài plug-in")}),je=(e,a=!1)=>{const m=`ad-use${a?" ps-big":""}`;if(q(e))return n.jsxs("button",{className:m,onClick:()=>nn(e),children:[e.link.label?.[u]||t("Hướng dẫn cài")," ↗"]});if(e.free)return ve(e,m);if(X[e.id])return n.jsx("button",{className:`${m} ps-wait`,onClick:()=>void De(e.id),children:t("Đã thanh toán? Kiểm tra lại")});if(e.kind==="sfxlib"||Y(e)){const f=te(e.id);if(!a&&!f?.owned)return n.jsx("button",{className:m,onClick:()=>R(e),children:f?.expiresAt?t("Gia hạn"):t("Xem & mua")});if(a)return n.jsx(hn,{item:e,owned:f,busy:re===e.id,installed:me(e.id),onInstall:()=>void ae(e),onBuy:$=>fe(e,$)})}return H(e.id)?ve(e,m):n.jsx("button",{className:m,onClick:()=>fe(e),children:t("Mua · {0}",[_(e)])})},be=e=>{if(e.free)return n.jsx("span",{className:"ps-price free",children:t("Miễn phí")});const a=te(e.id);return a?.owned?n.jsxs("span",{className:"ps-price owned",children:["✓ ",a.expiresAt?t("Vé đến {0}",[Q(a.expiresAt,x)]):t("Đã sở hữu")]}):n.jsx("span",{className:"ps-price",children:e.kind==="sfxlib"||Y(e)?(e.passVnd||e.passUsd)&&!(e.priceVnd||e.priceUsd)?t("{0} / 30 ngày",[Z(e)]):t("từ {0}",[an(e)]):_(e)})};return Te.createPortal(n.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":t("Kho Plug-in"),onMouseDown:e=>{e.target===e.currentTarget&&c()},children:n.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:e=>e.stopPropagation(),children:[n.jsxs("header",{className:"ad-head",children:[n.jsxs("div",{className:"ad-title",children:["🛍 ",t("Kho Plug-in")]}),n.jsxs("span",{className:"ad-count",children:[p==="owned"?z.length:Math.max(W,z.length)," ",t("mục")]}),n.jsx("div",{className:"grow"}),n.jsx("button",{className:"ad-iconbtn",title:t("Đóng"),"aria-label":t("Đóng"),onClick:c,children:"✕"})]}),n.jsx("nav",{className:"ad-sources",children:Pe.map(e=>n.jsxs("button",{className:`ad-tab${p===e.id?" on":""}`,"aria-pressed":p===e.id,onClick:()=>i(e.id),children:[e.id==="all"&&n.jsx("span",{className:"ad-pin",children:"⧉"}),e.label,e.id==="owned"&&g.filter(a=>a.owned).length>0&&n.jsx("span",{className:"ps-n",children:g.filter(a=>a.owned).length})]},e.id))}),n.jsxs("div",{className:"ad-tools",children:[n.jsx("input",{className:"ad-search","aria-label":t("Tìm plug-in"),placeholder:t("Tìm plug-in, tác giả, thẻ…"),value:C,onChange:e=>K(e.target.value),onKeyDown:e=>e.stopPropagation()}),n.jsx("div",{className:"ad-chips",role:"group","aria-label":t("Loại plug-in"),children:Se.map(e=>{const a=e.id==="all"||p==="owned"?void 0:P?.kinds?.[e.id];return P&&e.id!=="all"&&p!=="owned"&&d!==e.id&&!a?null:n.jsxs("button",{className:`ad-chip${d===e.id?" on":""}`,"aria-pressed":d===e.id,onClick:()=>b(e.id),children:[e[u],a!==void 0&&n.jsx("span",{className:"ps-n",children:a.toLocaleString(u==="en"?"en-US":"vi-VN")})]},e.id)})})]}),n.jsxs("div",{className:"ad-notice",children:[n.jsxs("b",{children:["⧉ ",t("Plug-in không tốn credit.")]})," ",d==="sfxlib"?t("Kho âm thanh: mua một lần hoặc vé 30 ngày trên clipoox.com, tính là 1 plug-in; âm chỉ chép vào dự án khi bạn dùng."):t("Bản miễn phí cài ngay; bản trả phí mua một lần hoặc vé 30 ngày trên clipoox.com (chuyển khoản / thẻ), không tự trừ tiền.")]}),n.jsxs("div",{className:"ad-content",children:[M&&n.jsx("p",{role:"alert",className:"ad-alert",children:M}),j===null&&n.jsx("p",{className:"ad-muted",children:t("Đang tải…")}),j!==null&&!z.length&&n.jsx("div",{className:"ad-empty",children:p==="owned"?t("Bạn chưa mua plug-in nào."):C?t("Không có plug-in khớp tìm kiếm."):t("Kho chưa có plug-in nào trong nhóm này.")}),n.jsx("div",{className:"ad-grid",children:z.map(e=>n.jsxs("article",{className:"ad-card ps-card","data-store":e.id,children:[n.jsxs("button",{className:"ad-prev ps-open","aria-label":t("Xem {0}",[e.name[u]]),onClick:()=>R(e),children:[e.thumbnailUrl?n.jsx("img",{src:e.thumbnailUrl,alt:"",loading:"lazy"}):e.kind==="sfx"||e.kind==="sfxlib"?n.jsx(le,{}):n.jsx("span",{className:"ad-ph",children:"⧉"}),n.jsx("span",{className:"ad-badge",children:(q(e)?e.link.platform:Le(ie(e),x)).toUpperCase()}),e.featured&&n.jsxs("span",{className:"ps-featured",title:t("Đối tác tiên phong của Clipoox"),children:["★ ",t("Đối tác tiên phong")]}),e.private&&n.jsxs("span",{className:"ps-private",title:t("Chỉ các tài khoản được Clipoox chọn mới thấy gói này"),children:["🔒 ",t("Gói riêng")]})]}),n.jsxs("div",{className:"ad-meta",children:[n.jsx("div",{className:"ad-name",title:e.name[u],children:e.name[u]}),n.jsxs("div",{className:"ad-sub ps-sub",children:[n.jsxs("span",{className:"ps-by",children:[e.author.name," · v",e.version]}),be(e)]}),e.kind==="pack"&&!B(e)&&n.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",t("{0} mục trong gói",[e.itemCount??0])]}),B(e)&&n.jsxs("div",{className:"ps-kit-meta",children:["◈ ",n.jsx("b",{children:e.kit.items})," ",t("mục")," · ",n.jsx("b",{children:e.kit.models})," ",t("mô hình 3D")," · ",n.jsx("b",{children:e.kit.looks})," ",t("look")," · ",Ce(e.kit.bytes,u)]}),q(e)&&n.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",t("Cài trong {0} trên máy bạn",[e.link.platform])]}),e.kind==="sfx"&&n.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",t("{0} âm thanh",[e.soundCount??0])," · ",we(e.totalDuration)]}),e.kind==="sfxlib"&&n.jsxs("div",{className:"ps-sounds-meta",children:[e.libKind==="music"?"🎵":"📚"," ",t(e.libKind==="music"?"{0} bài nhạc":"{0} âm thanh",[(e.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",ye(e.totalDuration,u)]}),(e.kind==="sfxlib"||Y(e))&&!e.free&&!H(e.id)&&n.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[e.passVnd||e.passUsd?t("{0} / 30 ngày",[Z(e)]):"",e.priceVnd||e.priceUsd?t("{0} trọn đời",[_(e)]):""].filter(Boolean).join(" · ")}),ne===e.id&&n.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",t("Đã cài vào Plug-in của tôi")]}),X[e.id]&&n.jsxs("div",{className:"ps-waiting",role:"status",children:[n.jsx("i",{className:"spin"}),t("Đang chờ thanh toán…")]}),ue(e.id)&&!H(e.id)&&n.jsx("div",{className:"ps-waiting bad",children:t("Đơn đã hoàn tiền")}),n.jsx("div",{className:"ad-actions",children:je(e)})]})]},e.id))}),p!=="owned"&&w&&n.jsx("div",{ref:F,className:"ps-more",role:"status",children:E?n.jsxs(n.Fragment,{children:[n.jsx("i",{className:"spin"})," ",t("Đang tải thêm…")]}):n.jsx("button",{className:"ad-chip",onClick:se,children:t("Xem thêm")})})]}),k&&n.jsx(ln,{item:k,locale:u,owned:H(k.id),free:k.free,waiting:!!X[k.id],refunded:ue(k.id),action:je(k,!0),price:be(k),installed:ne===k.id,onClose:()=>R(null)},`${k.id}:${H(k.id)}`)]})}),document.body)}function ln({item:s,locale:r,owned:c,free:h,waiting:v,refunded:o,action:x,price:u,installed:j,onClose:y}){const g=l.useRef(null),[S,M]=l.useState(!1),[U,p]=l.useState(!1);return l.useEffect(()=>{if(!(h||c)||s.kind==="recipe"||s.kind==="sfx"||s.kind==="pack"||s.kind==="sfxlib"||s.kind==="link")return;let i=!0,d=0,b=null;const C=`store-preview:${s.id}`,K={v:""},W=performance.now();return(async()=>{try{b=await Ke(s.id)}catch{i&&p(!0);return}if(!i||!b)return;const A=b.manifest,w=640,D=360;if(A.kind==="motion"){const E=Ve(A,b.entry,{}),N=A.duration,P=async()=>{if(i){try{const L=await Ye({layer:C,motion:E,t:(performance.now()-W)/1e3%N,width:w,height:D,duration:N}),T=g.current?.getContext("2d");T&&i&&(T.clearRect(0,0,w,D),T.drawImage(L,0,0),M(!0)),L.close()}catch{}d=requestAnimationFrame(()=>void P())}};P()}else{const E=await Fe(b.lottie,A,Oe(A,{}));K.v=URL.createObjectURL(new Blob([JSON.stringify(E)],{type:"application/json"}));const N=b.lottie.meta,P=Math.min(w/N.w,D/N.h),L={W:Math.max(2,Math.round(N.w*P/2)*2),H:Math.max(2,Math.round(N.h*P/2)*2)},T=N.op-N.ip,V=document.createElement("canvas");V.width=L.W,V.height=L.H;const I=async()=>{if(i){try{await Ze(C,K.v,L,Math.floor((performance.now()-W)/1e3*N.fr%T),V);const F=g.current?.getContext("2d");F&&i&&(F.clearRect(0,0,w,D),F.drawImage(V,(w-L.W)/2,(D-L.H)/2),M(!0))}catch{}d=requestAnimationFrame(()=>void I())}};I()}})(),()=>{i=!1,cancelAnimationFrame(d),Qe(C),Je(C),K.v&&URL.revokeObjectURL(K.v)}},[s.id,s.kind,h,c]),n.jsx("div",{className:"ad-preview-modal",onMouseDown:i=>{i.target===i.currentTarget&&y()},children:n.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":s.name[r],children:[n.jsxs("header",{children:[n.jsx("b",{children:s.name[r]}),n.jsx("button",{className:"ad-iconbtn","aria-label":t("Đóng"),onClick:y,children:"✕"})]}),s.kind==="sfxlib"?n.jsx(dn,{item:s,locale:r}):s.kind==="sfx"?n.jsx(on,{item:s,locale:r,owned:c,free:h}):n.jsxs("div",{className:"ps-stage",children:[n.jsx("canvas",{ref:g,width:640,height:360,style:{display:S?"block":"none"}}),!S&&(s.previewUrl&&/\.(mp4|webm)(\?|$)/.test(s.previewUrl)?n.jsx("video",{src:s.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):s.previewUrl||s.thumbnailUrl?n.jsx("img",{src:s.previewUrl||s.thumbnailUrl,alt:""}):n.jsx("span",{className:"ad-ph",children:"⧉"})),n.jsx("span",{className:"ps-stage-note",children:S?t("Xem thử trực tiếp trong sandbox"):h||c?U?t("Không tải được bản xem thử"):s.kind==="recipe"?t("Công thức chạy trên clip bạn chọn"):s.kind==="pack"?t("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[s.itemCount??0]):q(s)?t("Cài trong {0} trên máy bạn — không cài vào Timeline",[s.link.platform]):t("Đang tải bản xem thử…"):t("Mua để xem thử trực tiếp và dùng")})]}),s.kind==="pack"&&n.jsx(cn,{item:s,locale:r}),n.jsxs("div",{className:"ps-info",children:[s.featured&&n.jsxs("p",{className:"ps-featured-line",children:["★ ",t("Đối tác tiên phong của Clipoox")]}),s.private&&n.jsxs("p",{className:"ps-private-line",children:["🔒 ",t("Gói riêng: chỉ các tài khoản được Clipoox chọn mới thấy và cài được.")]}),n.jsxs("div",{className:"ps-row",children:[u,n.jsxs("span",{className:"ps-kind",children:[q(s)?s.link.platform:Le(ie(s),r)," · v",s.version," · ",s.author.name,s.kit?` · ${Ce(s.kit.bytes,r)}`:"",B(s)?` · ${t("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),n.jsx("p",{children:s.description[r]}),q(s)&&s.link.commands.length>0&&n.jsx(rn,{commands:s.link.commands}),s.params.length>0&&n.jsxs("p",{className:"ps-params",children:[n.jsxs("b",{children:[t("Tham số chỉnh được"),":"]})," ",s.params.map(i=>i.label[r]).join(" · ")]}),v&&n.jsxs("div",{className:"ps-waiting",role:"status",children:[n.jsx("i",{className:"spin"}),t("Đang chờ thanh toán… Hoàn tất trên trang clipoox.com vừa mở, rồi quay lại đây.")]}),o&&!c&&n.jsx("div",{className:"ps-waiting bad",children:t("Đơn mua này đã được hoàn tiền nên không cài mới được. Các clip đã dùng vẫn giữ nguyên.")}),j&&n.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",t("Đã cài vào Plug-in của tôi — mở tab Plug-in để dùng.")]}),n.jsx("div",{className:"ad-actions",children:x}),B(s)&&!h&&!c&&n.jsxs("div",{className:"ps-lock",children:["🔒 ",t("Mô hình và texture chỉ tải về máy sau khi mua. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")]}),B(s)&&(h||c)&&n.jsx("small",{className:"muted",children:t("Tài nguyên 3D chỉ chép vào dự án khi bạn dùng một mục. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")}),!h&&!c&&s.kind!=="sfxlib"&&!Y(s)&&n.jsx("small",{className:"muted",children:t("Thanh toán một lần trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit.")})]})]})})}function rn({commands:s}){const[r,c]=l.useState(!1),h=()=>{navigator.clipboard?.writeText(s.join(`
1
+ import{r as Te,j as n}from"./remote-CpkPQOQH.js";import{r as l}from"./index-CKtv7gGE.js";import{u as ke,t}from"./i18n-ClNt3LKg.js";import{a6 as Ee,a7 as Ve,a8 as Ae,a9 as we,aa as ye,ab as Y,ac as _,Z as Q,ad as Ie,V as Ke,ae as Fe,F as Oe,U as Re,af as Be,x as qe,ag as Ge,ah as J,ai as He,aj as _e,i as We,ak as Xe,al as ze}from"./main-C_XcvNyC.js";import{d as Qe,k as Je,m as Ze,l as Ye}from"./lottieLayer-DEw0c3to.js";import{p as en}from"./TimelinePlugins-CqLMVjuh.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";import"./spark.module-3Q8DniuL.js";import"./userFonts-BlVEJfDk.js";import"./timeline3d-BcW68fQr.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./glTransitionSources.generated-Cs8lVRqs.js";import"./clientJobs-eB-lNyin.js";import"./captionLayout-eiu9QPJu.js";import"./timelineText-Cppd4KB7.js";import"./titleArt-D0YI5xT2.js";import"./personHq-CBP8v_cw.js";import"./matteQuality-9X-jgJrH.js";import"./sceneTrack-_n6WKKQv.js";import"./rotoMatte-BI-vjjrv.js";import"./objectSegmenter-C4T9qgUL.js";import"./cutoutClean-CLYYAuXg.js";import"./distortGL-DQu0Df2c.js";import"./motionBlur-uAm030t9.js";import"./pluginAutomation-ClFdpcCR.js";const Se=[{id:"all",vi:"Tất cả",en:"All"},{id:"motion",vi:"Motion",en:"Motion"},{id:"lottie",vi:"Lottie",en:"Lottie"},{id:"recipe",vi:"Công thức",en:"Recipe"},{id:"sfx",vi:"Âm thanh",en:"Sounds"},{id:"pack",vi:"Gói ngách",en:"Niche pack"},{id:"kit",vi:"Bộ 3D",en:"3D kit"},{id:"sfxlib",vi:"Kho âm thanh",en:"Sound library"},{id:"link",vi:"Cho AI agent",en:"AI agents"}],B=s=>s.kind==="pack"&&!!s.kit?.modelAssets,ie=s=>B(s)?"kit":s.kind,q=s=>s.kind==="link"&&!!s.link,nn=s=>{s.link&&window.open(s.link.url,"_blank","noopener,noreferrer")},Ce=(s,r)=>s>=1024*1024?`${(s/1024/1024).toFixed(s>=10*1024*1024?0:1).replace(".",r==="en"?".":",")} MB`:`${Math.max(1,Math.round(s/1024))} KB`,le=({n:s=28})=>n.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:s},(r,c)=>n.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(c*1.37)*Math.cos(c*.41)))}%`}},c))}),Le=(s,r)=>Se.find(c=>c.id===s)?.[r==="en"?"en":"vi"]??s,sn=5e3,tn=600*1e3,Ne=s=>s.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),Z=s=>(s.passVnd??0)>0||(s.passUsd??0)>0,an=s=>{const r=(c,h)=>c>0&&h>0?Math.min(c,h):c>0?c:h;return _({priceVnd:r(s.priceVnd,s.passVnd??0),priceUsd:r(s.priceUsd,s.passUsd??0)})};function Qn({installed:s,initialId:r=null,onClose:c,onInstalled:h,onUse:v,toast:o}){const x=ke(),u=x==="en"?"en":"vi",[j,y]=l.useState(null),[g,S]=l.useState([]),[M,U]=l.useState(""),[p,i]=l.useState("all"),[d,b]=l.useState("all"),[C,I]=l.useState(""),[W,E]=l.useState(0),[w,D]=l.useState(null),[V,N]=l.useState(!1),[P,L]=l.useState(),[T,K]=l.useState("");l.useEffect(()=>{const e=window.setTimeout(()=>K(C.trim()),250);return()=>window.clearTimeout(e)},[C]);const A=l.useCallback(e=>Ee({q:T||void 0,kind:d==="all"?void 0:d==="pack"?"niche":d,price:p==="free"?"free":p==="paid"?"paid":void 0,limit:ze,cursor:e||void 0}),[T,d,p]),F=l.useRef(null),O=l.useRef(0),[k,R]=l.useState(null),[re,ce]=l.useState(""),[X,ee]=l.useState({}),[ne,Me]=l.useState(""),G=l.useCallback(()=>Ve().then(e=>(S(e.owned),e.owned)).catch(()=>[]),[]),[oe,Ue]=l.useState(!1);l.useEffect(()=>{G().finally(()=>Ue(!0))},[G]),l.useEffect(()=>{if(p==="owned")return;const e=++O.current;y(null),U(""),A().then(a=>{e===O.current&&(y(a.items),E(a.total??a.items.length),D(a.nextCursor??null),L(a.facets))},a=>{e===O.current&&(y([]),D(null),U(a.message))})},[A,p]);const se=l.useCallback(()=>{if(!w||V||p==="owned")return;const e=O.current;N(!0),A(w).then(a=>{e===O.current&&(y(m=>{const f=new Set((m??[]).map($=>$.id));return[...m??[],...a.items.filter($=>!f.has($.id))]}),D(a.nextCursor??null))},a=>{e===O.current&&U(a.message)}).finally(()=>N(!1))},[w,V,p,A]);l.useEffect(()=>{const e=F.current;if(!e||!w)return;const a=new IntersectionObserver(m=>{m.some(f=>f.isIntersecting)&&se()},{rootMargin:"600px"});return a.observe(e),()=>a.disconnect()},[w,se,j]);const de=l.useRef(!1);l.useEffect(()=>{if(!r||de.current||j===null||!oe)return;de.current=!0;const e=j.find(a=>a.id===r)??g.find(a=>a.storeId===r&&a.item)?.item;e?R(e):Ae(r).then(a=>R(a.item),()=>o(t("Không tìm thấy plug-in này trong kho."),"error"))},[r,j,g,oe,o]),l.useEffect(()=>{const e=a=>{a.key==="Escape"&&(a.stopPropagation(),k?R(null):c())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[k,c]);const he=Object.keys(X).join(",");l.useEffect(()=>{if(!he)return;const e=window.setInterval(()=>{G().then(a=>{ee(m=>{const f={...m};for(const $ of Object.keys(f))(xe(a,$)||Date.now()-f[$]>tn)&&delete f[$];return f})})},sn);return()=>window.clearInterval(e)},[he,G]);const H=e=>g.some(a=>a.storeId===e&&a.owned),te=e=>g.find(a=>a.storeId===e),ue=e=>g.some(a=>a.storeId===e&&a.status==="refunded"),me=e=>s.some(a=>a.id===e&&a.source?.store===e),ae=async e=>{ce(e.id);try{await Be(e.id),h(),qe(),Me(e.id),o(t("Đã cài “{0}” vào Plug-in của tôi",[e.name[u]]),"ok")}catch(a){const m=en(a);o(m.text,"error")}finally{ce("")}},pe=l.useRef({}),ge=e=>e?.owned?e.expiresAt?String(e.expiresAt):"life":"none",xe=(e,a)=>{const m=e.find(f=>f.storeId===a);return!!m?.owned&&ge(m)!==(pe.current[a]??"none")},fe=(e,a)=>{pe.current[e.id]=ge(te(e.id)),Re(e.id,a),ee(m=>({...m,[e.id]:Date.now()}))},De=async e=>{const a=await G();xe(a,e)?(ee(m=>{const f={...m};return delete f[e],f}),o(t("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):o(t("Chưa thấy thanh toán. Nếu bạn vừa chuyển khoản, đợi một chút rồi kiểm tra lại."),"error")},$e=g.filter(e=>e.item).map(e=>e.item),z=(p==="owned"?$e:(j??[]).filter(e=>p==="all"||(p==="free"?e.free:!e.free))).filter(e=>(d==="all"||ie(e)===d)&&(!C.trim()||Ne(C).split(/\s+/).every(a=>Ne(`${e.name.vi} ${e.name.en} ${e.description.vi} ${e.description.en} ${e.author.name} ${e.tags.join(" ")}`).includes(a)))),Pe=[{id:"all",label:t("Plug-in")},{id:"free",label:t("Miễn phí")},{id:"paid",label:t("Trả phí")},{id:"owned",label:t("Đã sở hữu")}],ve=(e,a)=>re===e.id?n.jsxs("button",{className:a,disabled:!0,children:[n.jsx("i",{className:"spin"})," ",t("Đang cài…")]}):me(e.id)||ne===e.id?n.jsxs(n.Fragment,{children:[v?n.jsxs("button",{className:`${a} ps-use`,onClick:()=>v(e.id),children:["✓ ",t("Đã cài · Dùng ngay")]}):n.jsxs("span",{className:`${a} ps-use`,role:"status",children:["✓ ",t("Đã cài")]}),n.jsx("button",{className:"ps-reinstall",title:t("Cài lại plug-in"),onClick:()=>void ae(e),children:t("Cài lại")})]}):n.jsx("button",{className:a,onClick:()=>void ae(e),children:t("Cài plug-in")}),je=(e,a=!1)=>{const m=`ad-use${a?" ps-big":""}`;if(q(e))return n.jsxs("button",{className:m,onClick:()=>nn(e),children:[e.link.label?.[u]||t("Hướng dẫn cài")," ↗"]});if(e.free)return ve(e,m);if(X[e.id])return n.jsx("button",{className:`${m} ps-wait`,onClick:()=>void De(e.id),children:t("Đã thanh toán? Kiểm tra lại")});if(e.kind==="sfxlib"||Z(e)){const f=te(e.id);if(!a&&!f?.owned)return n.jsx("button",{className:m,onClick:()=>R(e),children:f?.expiresAt?t("Gia hạn"):t("Xem & mua")});if(a)return n.jsx(hn,{item:e,owned:f,busy:re===e.id,installed:me(e.id),onInstall:()=>void ae(e),onBuy:$=>fe(e,$)})}return H(e.id)?ve(e,m):n.jsx("button",{className:m,onClick:()=>fe(e),children:t("Mua · {0}",[_(e)])})},be=e=>{if(e.free)return n.jsx("span",{className:"ps-price free",children:t("Miễn phí")});const a=te(e.id);return a?.owned?n.jsxs("span",{className:"ps-price owned",children:["✓ ",a.expiresAt?t("Vé đến {0}",[Q(a.expiresAt,x)]):t("Đã sở hữu")]}):n.jsx("span",{className:"ps-price",children:e.kind==="sfxlib"||Z(e)?(e.passVnd||e.passUsd)&&!(e.priceVnd||e.priceUsd)?t("{0} / 30 ngày",[Y(e)]):t("từ {0}",[an(e)]):_(e)})};return Te.createPortal(n.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":t("Kho Plug-in"),onMouseDown:e=>{e.target===e.currentTarget&&c()},children:n.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:e=>e.stopPropagation(),children:[n.jsxs("header",{className:"ad-head",children:[n.jsxs("div",{className:"ad-title",children:["🛍 ",t("Kho Plug-in")]}),n.jsxs("span",{className:"ad-count",children:[p==="owned"?z.length:Math.max(W,z.length)," ",t("mục")]}),n.jsx("div",{className:"grow"}),n.jsx("button",{className:"ad-iconbtn",title:t("Đóng"),"aria-label":t("Đóng"),onClick:c,children:"✕"})]}),n.jsx("nav",{className:"ad-sources",children:Pe.map(e=>n.jsxs("button",{className:`ad-tab${p===e.id?" on":""}`,"aria-pressed":p===e.id,onClick:()=>i(e.id),children:[e.id==="all"&&n.jsx("span",{className:"ad-pin",children:"⧉"}),e.label,e.id==="owned"&&g.filter(a=>a.owned).length>0&&n.jsx("span",{className:"ps-n",children:g.filter(a=>a.owned).length})]},e.id))}),n.jsxs("div",{className:"ad-tools",children:[n.jsx("input",{className:"ad-search","aria-label":t("Tìm plug-in"),placeholder:t("Tìm plug-in, tác giả, thẻ…"),value:C,onChange:e=>I(e.target.value),onKeyDown:e=>e.stopPropagation()}),n.jsx("div",{className:"ad-chips",role:"group","aria-label":t("Loại plug-in"),children:Se.map(e=>{const a=e.id==="all"||p==="owned"?void 0:P?.kinds?.[e.id];return P&&e.id!=="all"&&p!=="owned"&&d!==e.id&&!a?null:n.jsxs("button",{className:`ad-chip${d===e.id?" on":""}`,"aria-pressed":d===e.id,onClick:()=>b(e.id),children:[e[u],a!==void 0&&n.jsx("span",{className:"ps-n",children:a.toLocaleString(u==="en"?"en-US":"vi-VN")})]},e.id)})})]}),n.jsxs("div",{className:"ad-notice",children:[n.jsxs("b",{children:["⧉ ",t("Plug-in không tốn credit.")]})," ",d==="sfxlib"?t("Kho âm thanh: mua một lần hoặc vé 30 ngày trên clipoox.com, tính là 1 plug-in; âm chỉ chép vào dự án khi bạn dùng."):t("Bản miễn phí cài ngay; bản trả phí mua một lần hoặc vé 30 ngày trên clipoox.com (chuyển khoản / thẻ), không tự trừ tiền.")]}),n.jsxs("div",{className:"ad-content",children:[M&&n.jsx("p",{role:"alert",className:"ad-alert",children:M}),j===null&&n.jsx("p",{className:"ad-muted",children:t("Đang tải…")}),j!==null&&!z.length&&n.jsx("div",{className:"ad-empty",children:p==="owned"?t("Bạn chưa mua plug-in nào."):C?t("Không có plug-in khớp tìm kiếm."):t("Kho chưa có plug-in nào trong nhóm này.")}),n.jsx("div",{className:"ad-grid",children:z.map(e=>n.jsxs("article",{className:"ad-card ps-card","data-store":e.id,children:[n.jsxs("button",{className:"ad-prev ps-open","aria-label":t("Xem {0}",[e.name[u]]),onClick:()=>R(e),children:[e.thumbnailUrl?n.jsx("img",{src:e.thumbnailUrl,alt:"",loading:"lazy"}):e.kind==="sfx"||e.kind==="sfxlib"?n.jsx(le,{}):n.jsx("span",{className:"ad-ph",children:"⧉"}),n.jsx("span",{className:"ad-badge",children:(q(e)?e.link.platform:Le(ie(e),x)).toUpperCase()}),e.featured&&n.jsxs("span",{className:"ps-featured",title:t("Đối tác tiên phong của Clipoox"),children:["★ ",t("Đối tác tiên phong")]}),e.private&&n.jsxs("span",{className:"ps-private",title:t("Chỉ các tài khoản được Clipoox chọn mới thấy gói này"),children:["🔒 ",t("Gói riêng")]})]}),n.jsxs("div",{className:"ad-meta",children:[n.jsx("div",{className:"ad-name",title:e.name[u],children:e.name[u]}),n.jsxs("div",{className:"ad-sub ps-sub",children:[n.jsxs("span",{className:"ps-by",children:[e.author.name," · v",e.version]}),be(e)]}),e.kind==="pack"&&!B(e)&&n.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",t("{0} mục trong gói",[e.itemCount??0])]}),B(e)&&n.jsxs("div",{className:"ps-kit-meta",children:["◈ ",n.jsx("b",{children:e.kit.items})," ",t("mục")," · ",n.jsx("b",{children:e.kit.models})," ",t("mô hình 3D")," · ",n.jsx("b",{children:e.kit.looks})," ",t("look")," · ",Ce(e.kit.bytes,u)]}),q(e)&&n.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",t("Cài trong {0} trên máy bạn",[e.link.platform])]}),e.kind==="sfx"&&n.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",t("{0} âm thanh",[e.soundCount??0])," · ",we(e.totalDuration)]}),e.kind==="sfxlib"&&n.jsxs("div",{className:"ps-sounds-meta",children:[e.libKind==="music"?"🎵":"📚"," ",t(e.libKind==="music"?"{0} bài nhạc":"{0} âm thanh",[(e.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",ye(e.totalDuration,u)]}),(e.kind==="sfxlib"||Z(e))&&!e.free&&!H(e.id)&&n.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[e.passVnd||e.passUsd?t("{0} / 30 ngày",[Y(e)]):"",e.priceVnd||e.priceUsd?t("{0} trọn đời",[_(e)]):""].filter(Boolean).join(" · ")}),ne===e.id&&n.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",t("Đã cài vào Plug-in của tôi")]}),X[e.id]&&n.jsxs("div",{className:"ps-waiting",role:"status",children:[n.jsx("i",{className:"spin"}),t("Đang chờ thanh toán…")]}),ue(e.id)&&!H(e.id)&&n.jsx("div",{className:"ps-waiting bad",children:t("Đơn đã hoàn tiền")}),n.jsx("div",{className:"ad-actions",children:je(e)})]})]},e.id))}),p!=="owned"&&w&&n.jsx("div",{ref:F,className:"ps-more",role:"status",children:V?n.jsxs(n.Fragment,{children:[n.jsx("i",{className:"spin"})," ",t("Đang tải thêm…")]}):n.jsx("button",{className:"ad-chip",onClick:se,children:t("Xem thêm")})})]}),k&&n.jsx(ln,{item:k,locale:u,owned:H(k.id),free:k.free,waiting:!!X[k.id],refunded:ue(k.id),action:je(k,!0),price:be(k),installed:ne===k.id,onClose:()=>R(null)},`${k.id}:${H(k.id)}`)]})}),document.body)}function ln({item:s,locale:r,owned:c,free:h,waiting:v,refunded:o,action:x,price:u,installed:j,onClose:y}){const g=l.useRef(null),[S,M]=l.useState(!1),[U,p]=l.useState(!1);return l.useEffect(()=>{if(!(h||c)||s.kind==="recipe"||s.kind==="sfx"||s.kind==="pack"||s.kind==="sfxlib"||s.kind==="link")return;let i=!0,d=0,b=null;const C=`store-preview:${s.id}`,I={v:""},W=performance.now();return(async()=>{try{b=await Ie(s.id)}catch{i&&p(!0);return}if(!i||!b)return;const E=b.manifest,w=640,D=360;if(E.kind==="motion"){const V=Ke(E,b.entry,{}),N=E.duration,P=async()=>{if(i){try{const L=await Ze({layer:C,motion:V,t:(performance.now()-W)/1e3%N,width:w,height:D,duration:N}),T=g.current?.getContext("2d");T&&i&&(T.clearRect(0,0,w,D),T.drawImage(L,0,0),M(!0)),L.close()}catch{}d=requestAnimationFrame(()=>void P())}};P()}else{const V=await Fe(b.lottie,E,Oe(E,{}));I.v=URL.createObjectURL(new Blob([JSON.stringify(V)],{type:"application/json"}));const N=b.lottie.meta,P=Math.min(w/N.w,D/N.h),L={W:Math.max(2,Math.round(N.w*P/2)*2),H:Math.max(2,Math.round(N.h*P/2)*2)},T=N.op-N.ip,K=document.createElement("canvas");K.width=L.W,K.height=L.H;const A=async()=>{if(i){try{await Ye(C,I.v,L,Math.floor((performance.now()-W)/1e3*N.fr%T),K);const F=g.current?.getContext("2d");F&&i&&(F.clearRect(0,0,w,D),F.drawImage(K,(w-L.W)/2,(D-L.H)/2),M(!0))}catch{}d=requestAnimationFrame(()=>void A())}};A()}})(),()=>{i=!1,cancelAnimationFrame(d),Qe(C),Je(C),I.v&&URL.revokeObjectURL(I.v)}},[s.id,s.kind,h,c]),n.jsx("div",{className:"ad-preview-modal",onMouseDown:i=>{i.target===i.currentTarget&&y()},children:n.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":s.name[r],children:[n.jsxs("header",{children:[n.jsx("b",{children:s.name[r]}),n.jsx("button",{className:"ad-iconbtn","aria-label":t("Đóng"),onClick:y,children:"✕"})]}),s.kind==="sfxlib"?n.jsx(dn,{item:s,locale:r}):s.kind==="sfx"?n.jsx(on,{item:s,locale:r,owned:c,free:h}):n.jsxs("div",{className:"ps-stage",children:[n.jsx("canvas",{ref:g,width:640,height:360,style:{display:S?"block":"none"}}),!S&&(s.previewUrl&&/\.(mp4|webm)(\?|$)/.test(s.previewUrl)?n.jsx("video",{src:s.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):s.previewUrl||s.thumbnailUrl?n.jsx("img",{src:s.previewUrl||s.thumbnailUrl,alt:""}):n.jsx("span",{className:"ad-ph",children:"⧉"})),n.jsx("span",{className:"ps-stage-note",children:S?t("Xem thử trực tiếp trong sandbox"):h||c?U?t("Không tải được bản xem thử"):s.kind==="recipe"?t("Công thức chạy trên clip bạn chọn"):s.kind==="pack"?t("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[s.itemCount??0]):q(s)?t("Cài trong {0} trên máy bạn — không cài vào Timeline",[s.link.platform]):t("Đang tải bản xem thử…"):t("Mua để xem thử trực tiếp và dùng")})]}),s.kind==="pack"&&n.jsx(cn,{item:s,locale:r}),n.jsxs("div",{className:"ps-info",children:[s.featured&&n.jsxs("p",{className:"ps-featured-line",children:["★ ",t("Đối tác tiên phong của Clipoox")]}),s.private&&n.jsxs("p",{className:"ps-private-line",children:["🔒 ",t("Gói riêng: chỉ các tài khoản được Clipoox chọn mới thấy và cài được.")]}),n.jsxs("div",{className:"ps-row",children:[u,n.jsxs("span",{className:"ps-kind",children:[q(s)?s.link.platform:Le(ie(s),r)," · v",s.version," · ",s.author.name,s.kit?` · ${Ce(s.kit.bytes,r)}`:"",B(s)?` · ${t("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),n.jsx("p",{children:s.description[r]}),q(s)&&s.link.commands.length>0&&n.jsx(rn,{commands:s.link.commands}),s.params.length>0&&n.jsxs("p",{className:"ps-params",children:[n.jsxs("b",{children:[t("Tham số chỉnh được"),":"]})," ",s.params.map(i=>i.label[r]).join(" · ")]}),v&&n.jsxs("div",{className:"ps-waiting",role:"status",children:[n.jsx("i",{className:"spin"}),t("Đang chờ thanh toán… Hoàn tất trên trang clipoox.com vừa mở, rồi quay lại đây.")]}),o&&!c&&n.jsx("div",{className:"ps-waiting bad",children:t("Đơn mua này đã được hoàn tiền nên không cài mới được. Các clip đã dùng vẫn giữ nguyên.")}),j&&n.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",t("Đã cài vào Plug-in của tôi — mở tab Plug-in để dùng.")]}),n.jsx("div",{className:"ad-actions",children:x}),B(s)&&!h&&!c&&n.jsxs("div",{className:"ps-lock",children:["🔒 ",t("Mô hình và texture chỉ tải về máy sau khi mua. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")]}),B(s)&&(h||c)&&n.jsx("small",{className:"muted",children:t("Tài nguyên 3D chỉ chép vào dự án khi bạn dùng một mục. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")}),!h&&!c&&s.kind!=="sfxlib"&&!Z(s)&&n.jsx("small",{className:"muted",children:t("Thanh toán một lần trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit.")})]})]})})}function rn({commands:s}){const[r,c]=l.useState(!1),h=()=>{navigator.clipboard?.writeText(s.join(`
2
2
  `)).then(()=>{c(!0),window.setTimeout(()=>c(!1),2e3)},()=>{})};return n.jsxs("div",{className:"ps-cmds",children:[n.jsxs("div",{className:"ps-cmds-head",children:[n.jsx("b",{children:t("Lệnh cài")}),n.jsx("span",{className:"muted",children:t("chạy trong terminal trên máy bạn")}),n.jsx("button",{className:"ad-chip",onClick:h,children:r?`✓ ${t("Đã chép")}`:t("Chép lệnh")})]}),n.jsx("pre",{children:s.join(`
3
- `)})]})}function cn({item:s,locale:r}){const[c,h]=l.useState(null);if(l.useEffect(()=>{let o=!0;return Xe(s.id).then(x=>{o&&h(x.items)},()=>{o&&h([])}),()=>{o=!1}},[s.id]),!c?.length)return null;const v=o=>o.kind==="model"?t("Mô hình"):o.kind==="lut"?"Look":o.kind==="motion"&&o.engine==="3d"?"3D":o.kind==="recipe"?t("Combo"):o.kind==="lottie"?"Lottie":"2D";return n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"ps-items-head",children:[n.jsx("b",{children:t("{0} mục trong gói",[c.length])})," · ",n.jsx("span",{className:"muted",children:t("ảnh chụp từ lần chạy thử")})]}),n.jsx("div",{className:"ps-items",children:c.slice(0,24).map(o=>n.jsxs("figure",{children:[o.thumbnail?n.jsx("img",{src:`data:${o.thumbnail.type};base64,${o.thumbnail.data}`,alt:""}):n.jsx("span",{className:"ph",children:o.kind==="model"?"◈":"✦"}),n.jsxs("figcaption",{title:o.name[r],children:[v(o)," · ",o.name[r]]})]},o.id))})]})}function on({item:s,locale:r,owned:c,free:h}){const[v,o]=l.useState(null),[x,u]=l.useState(!1),[j,y]=l.useState(!1),[g,S]=l.useState(null),M=l.useRef(null),U=l.useRef(0);l.useEffect(()=>{let i=!0;return _e(s.id).then(d=>{i&&(o(d.sounds),u(d.full))},()=>{i&&y(!0)}),()=>{i=!1,M.current?.pause(),window.clearTimeout(U.current)}},[s.id,c,h]);const p=i=>{if(M.current?.pause(),window.clearTimeout(U.current),g===i.id||!i.url){S(null);return}const d=new Audio(i.url);M.current=d,d.volume=.8,S(i.id),d.onended=()=>S(b=>b===i.id?null:b),i.preview&&(U.current=window.setTimeout(()=>{d.pause(),S(b=>b===i.id?null:b)},J.previewSeconds*1e3+300)),d.play().catch(()=>S(null))};return n.jsxs("div",{className:"ps-sounds","data-full":x?"1":"0",children:[n.jsxs("div",{className:"ps-sounds-head",children:[s.thumbnailUrl?n.jsx("img",{src:s.thumbnailUrl,alt:""}):n.jsx(le,{n:40}),n.jsxs("div",{children:[n.jsxs("b",{children:["♪ ",t("{0} âm thanh",[s.soundCount??v?.length??0])," · ",we(s.totalDuration)]}),n.jsx("small",{className:"muted",children:x?t("Nghe đầy đủ — bấm ▶"):t("Nghe thử {0} âm thanh đầu, mỗi âm tối đa {1} giây. Mua để nghe đủ và dùng.",[J.previewCount,J.previewSeconds])})]})]}),j&&n.jsx("p",{className:"ad-alert",role:"alert",children:t("Không tải được bản xem thử")}),v===null&&!j&&n.jsx("p",{className:"ad-muted",children:t("Đang tải…")}),v&&n.jsx("ul",{className:"ps-sound-list","aria-label":t("Âm thanh trong gói"),children:v.map(i=>{const d=i.name?.[r]||i.name?.vi||i.id;return n.jsxs("li",{className:`${g===i.id?"on":""}${i.url?"":" locked"}`,"data-store-sound":i.id,children:[n.jsx("button",{className:"tl-sfx-play",disabled:!i.url,"aria-label":i.url?`${t("Nghe thử")} ${d}`:t("Mua để nghe {0}",[d]),title:i.url?t("Nghe thử"):t("Mua để nghe"),onClick:()=>p(i),children:i.url?g===i.id?"■":"▶":"🔒"}),n.jsxs("span",{className:"ps-sound-name",children:[n.jsxs("span",{className:"ell",children:[d,i.loop?" ↻":""]}),n.jsxs("small",{className:"muted ell",children:[We(i.category,r),i.tags.length?` · ${i.tags.slice(0,3).join(", ")}`:""]})]}),n.jsxs("small",{className:"muted",children:[i.preview&&(i.previewSeconds??0)<i.duration-.05?`▶ ${(i.previewSeconds??0).toFixed(1)}s / `:"",i.duration.toFixed(1),"s"]})]},i.id)})})]})}function dn({item:s,locale:r}){const c=l.useCallback(x=>Ge(s.id,x),[s.id]),[h,v]=l.useState(null),o=l.useCallback(async x=>{const u=await c(x);return v(u.access.full),u},[c]);return n.jsxs("div",{className:"ps-sounds","data-full":h?"1":"0",children:[n.jsxs("div",{className:"ps-sounds-head",children:[s.thumbnailUrl?n.jsx("img",{src:s.thumbnailUrl,alt:""}):n.jsx(le,{n:40}),n.jsxs("div",{children:[n.jsxs("b",{children:["📚 ",t("{0} âm thanh",[(s.soundCount??0).toLocaleString(r==="en"?"en-US":"vi-VN")])," · ",ye(s.totalDuration,r)]}),n.jsxs("div",{className:"ps-stats",children:[(s.folders?.length??0)>0&&n.jsxs("span",{children:[n.jsx("b",{children:s.folders.length})," ",t("thư mục")]}),n.jsxs("span",{children:[n.jsx("b",{children:"48 kHz"})," stereo"]}),n.jsxs("span",{children:["v",s.version]})]}),n.jsx("small",{className:"muted",children:h?t("Nghe đầy đủ — thêm âm từ mục SFX của Timeline."):t("Nghe thử mọi âm ({0} giây, chất lượng thấp). Mua để nghe đủ và dùng.",[J.previewSeconds])})]})]}),n.jsx(He,{libId:s.id,fetchPage:o,variant:"store"})]})}function hn({item:s,owned:r,busy:c,installed:h,onInstall:v,onBuy:o}){const x=ke(),u=s.kind==="sfxlib",j=(s.passVnd??0)>0||(s.passUsd??0)>0,y=s.priceVnd>0||s.priceUsd>0,g=n.jsx("button",{className:"ad-use ps-big",disabled:c,onClick:v,children:c?t("Đang cài…"):h?t("Cài lại"):t("Cài plug-in")});return r?.owned&&!r.expiresAt?g:r?.owned?n.jsxs("div",{className:"ps-lib-buy-wrap",children:[g,j&&n.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>o("pass"),children:t("Gia hạn thêm 30 ngày · {0}",[Z(s)])}),n.jsx("small",{className:"muted",children:t("Vé đến {0}. Gia hạn cộng nối từ ngày đó, không tự trừ tiền.",[Q(r.expiresAt,x)])})]}):n.jsxs("div",{className:"ps-lib-buy-wrap",children:[r?.expiresAt&&n.jsx("div",{className:"ps-waiting",children:u?t("Vé 30 ngày đã hết hạn ngày {0}. Âm đã dùng trong dự án vẫn giữ nguyên.",[Q(r.expiresAt,x)]):t("Vé 30 ngày đã hết hạn ngày {0}. Lớp đã thêm vào video vẫn giữ nguyên.",[Q(r.expiresAt,x)])}),n.jsxs("div",{className:"ps-lib-buy",children:[j&&n.jsxs("button",{className:"ad-use ps-big",onClick:()=>o("pass"),children:[t("Vé 30 ngày · {0}",[Z(s)]),n.jsx("small",{children:t("Trả lại để gia hạn, không tự trừ tiền")})]}),y&&n.jsxs("button",{className:"ad-use ps-big",onClick:()=>o("lifetime"),children:[t("Mua trọn đời · {0}",[_(s)]),n.jsx("small",{children:u?t("Một lần, gồm các đợt âm mới"):t("Một lần, dùng mãi mãi")})]})]}),n.jsx("small",{className:"muted",children:u?t("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Âm đã dùng trong dự án vẫn giữ khi vé hết hạn."):t("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Hết vé thì không thêm mới được; lớp đã thêm vào video vẫn giữ nguyên.")})]})}export{Qn as default};
3
+ `)})]})}function cn({item:s,locale:r}){const[c,h]=l.useState(null);if(l.useEffect(()=>{let o=!0;return Xe(s.id).then(x=>{o&&h(x.items)},()=>{o&&h([])}),()=>{o=!1}},[s.id]),!c?.length)return null;const v=o=>o.kind==="model"?t("Mô hình"):o.kind==="lut"?"Look":o.kind==="motion"&&o.engine==="3d"?"3D":o.kind==="recipe"?t("Combo"):o.kind==="lottie"?"Lottie":"2D";return n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"ps-items-head",children:[n.jsx("b",{children:t("{0} mục trong gói",[c.length])})," · ",n.jsx("span",{className:"muted",children:t("ảnh chụp từ lần chạy thử")})]}),n.jsx("div",{className:"ps-items",children:c.slice(0,24).map(o=>n.jsxs("figure",{children:[o.thumbnail?n.jsx("img",{src:`data:${o.thumbnail.type};base64,${o.thumbnail.data}`,alt:""}):n.jsx("span",{className:"ph",children:o.kind==="model"?"◈":"✦"}),n.jsxs("figcaption",{title:o.name[r],children:[v(o)," · ",o.name[r]]})]},o.id))})]})}function on({item:s,locale:r,owned:c,free:h}){const[v,o]=l.useState(null),[x,u]=l.useState(!1),[j,y]=l.useState(!1),[g,S]=l.useState(null),M=l.useRef(null),U=l.useRef(0);l.useEffect(()=>{let i=!0;return _e(s.id).then(d=>{i&&(o(d.sounds),u(d.full))},()=>{i&&y(!0)}),()=>{i=!1,M.current?.pause(),window.clearTimeout(U.current)}},[s.id,c,h]);const p=i=>{if(M.current?.pause(),window.clearTimeout(U.current),g===i.id||!i.url){S(null);return}const d=new Audio(i.url);M.current=d,d.volume=.8,S(i.id),d.onended=()=>S(b=>b===i.id?null:b),i.preview&&(U.current=window.setTimeout(()=>{d.pause(),S(b=>b===i.id?null:b)},J.previewSeconds*1e3+300)),d.play().catch(()=>S(null))};return n.jsxs("div",{className:"ps-sounds","data-full":x?"1":"0",children:[n.jsxs("div",{className:"ps-sounds-head",children:[s.thumbnailUrl?n.jsx("img",{src:s.thumbnailUrl,alt:""}):n.jsx(le,{n:40}),n.jsxs("div",{children:[n.jsxs("b",{children:["♪ ",t("{0} âm thanh",[s.soundCount??v?.length??0])," · ",we(s.totalDuration)]}),n.jsx("small",{className:"muted",children:x?t("Nghe đầy đủ — bấm ▶"):t("Nghe thử {0} âm thanh đầu, mỗi âm tối đa {1} giây. Mua để nghe đủ và dùng.",[J.previewCount,J.previewSeconds])})]})]}),j&&n.jsx("p",{className:"ad-alert",role:"alert",children:t("Không tải được bản xem thử")}),v===null&&!j&&n.jsx("p",{className:"ad-muted",children:t("Đang tải…")}),v&&n.jsx("ul",{className:"ps-sound-list","aria-label":t("Âm thanh trong gói"),children:v.map(i=>{const d=i.name?.[r]||i.name?.vi||i.id;return n.jsxs("li",{className:`${g===i.id?"on":""}${i.url?"":" locked"}`,"data-store-sound":i.id,children:[n.jsx("button",{className:"tl-sfx-play",disabled:!i.url,"aria-label":i.url?`${t("Nghe thử")} ${d}`:t("Mua để nghe {0}",[d]),title:i.url?t("Nghe thử"):t("Mua để nghe"),onClick:()=>p(i),children:i.url?g===i.id?"■":"▶":"🔒"}),n.jsxs("span",{className:"ps-sound-name",children:[n.jsxs("span",{className:"ell",children:[d,i.loop?" ↻":""]}),n.jsxs("small",{className:"muted ell",children:[We(i.category,r),i.tags.length?` · ${i.tags.slice(0,3).join(", ")}`:""]})]}),n.jsxs("small",{className:"muted",children:[i.preview&&(i.previewSeconds??0)<i.duration-.05?`▶ ${(i.previewSeconds??0).toFixed(1)}s / `:"",i.duration.toFixed(1),"s"]})]},i.id)})})]})}function dn({item:s,locale:r}){const c=l.useCallback(x=>Ge(s.id,x),[s.id]),[h,v]=l.useState(null),o=l.useCallback(async x=>{const u=await c(x);return v(u.access.full),u},[c]);return n.jsxs("div",{className:"ps-sounds","data-full":h?"1":"0",children:[n.jsxs("div",{className:"ps-sounds-head",children:[s.thumbnailUrl?n.jsx("img",{src:s.thumbnailUrl,alt:""}):n.jsx(le,{n:40}),n.jsxs("div",{children:[n.jsxs("b",{children:["📚 ",t("{0} âm thanh",[(s.soundCount??0).toLocaleString(r==="en"?"en-US":"vi-VN")])," · ",ye(s.totalDuration,r)]}),n.jsxs("div",{className:"ps-stats",children:[(s.folders?.length??0)>0&&n.jsxs("span",{children:[n.jsx("b",{children:s.folders.length})," ",t("thư mục")]}),n.jsxs("span",{children:[n.jsx("b",{children:"48 kHz"})," stereo"]}),n.jsxs("span",{children:["v",s.version]})]}),n.jsx("small",{className:"muted",children:h?t("Nghe đầy đủ — thêm âm từ mục SFX của Timeline."):t("Nghe thử mọi âm ({0} giây, chất lượng thấp). Mua để nghe đủ và dùng.",[J.previewSeconds])})]})]}),n.jsx(He,{libId:s.id,fetchPage:o,variant:"store"})]})}function hn({item:s,owned:r,busy:c,installed:h,onInstall:v,onBuy:o}){const x=ke(),u=s.kind==="sfxlib",j=(s.passVnd??0)>0||(s.passUsd??0)>0,y=s.priceVnd>0||s.priceUsd>0,g=n.jsx("button",{className:"ad-use ps-big",disabled:c,onClick:v,children:c?t("Đang cài…"):h?t("Cài lại"):t("Cài plug-in")});return r?.owned&&!r.expiresAt?g:r?.owned?n.jsxs("div",{className:"ps-lib-buy-wrap",children:[g,j&&n.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>o("pass"),children:t("Gia hạn thêm 30 ngày · {0}",[Y(s)])}),n.jsx("small",{className:"muted",children:t("Vé đến {0}. Gia hạn cộng nối từ ngày đó, không tự trừ tiền.",[Q(r.expiresAt,x)])})]}):n.jsxs("div",{className:"ps-lib-buy-wrap",children:[r?.expiresAt&&n.jsx("div",{className:"ps-waiting",children:u?t("Vé 30 ngày đã hết hạn ngày {0}. Âm đã dùng trong dự án vẫn giữ nguyên.",[Q(r.expiresAt,x)]):t("Vé 30 ngày đã hết hạn ngày {0}. Lớp đã thêm vào video vẫn giữ nguyên.",[Q(r.expiresAt,x)])}),n.jsxs("div",{className:"ps-lib-buy",children:[j&&n.jsxs("button",{className:"ad-use ps-big",onClick:()=>o("pass"),children:[t("Vé 30 ngày · {0}",[Y(s)]),n.jsx("small",{children:t("Trả lại để gia hạn, không tự trừ tiền")})]}),y&&n.jsxs("button",{className:"ad-use ps-big",onClick:()=>o("lifetime"),children:[t("Mua trọn đời · {0}",[_(s)]),n.jsx("small",{children:u?t("Một lần, gồm các đợt âm mới"):t("Một lần, dùng mãi mãi")})]})]}),n.jsx("small",{className:"muted",children:u?t("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Âm đã dùng trong dự án vẫn giữ khi vé hết hạn."):t("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Hết vé thì không thêm mới được; lớp đã thêm vào video vẫn giữ nguyên.")})]})}export{Qn as default};