clipoox-render 0.4.3 → 0.4.5

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 (191) hide show
  1. package/package.json +4 -3
  2. package/scripts/render-local.mjs +5160 -1446
  3. package/web/assets/FxEmbed-DbfuM8Yo.js +1 -0
  4. package/web/assets/MotionEmbed-CBQ-8Tzh.js +1 -0
  5. package/web/assets/PluginStore-OOEx0lP5.js +3 -0
  6. package/web/assets/ShotComposer-Cng515xa.js +287 -0
  7. package/web/assets/{ShotComposer-VixLbeMe.css → ShotComposer-deLi4grZ.css} +1 -1
  8. package/web/assets/TemplateEmbed-hjwM2b0o.js +2 -0
  9. package/web/assets/{TimelinePlugins-BYZ9y4m3.js → TimelinePlugins-D-NakABP.js} +4 -4
  10. package/web/assets/TimelineShotFx-D3kGhHN3.js +2 -0
  11. package/web/assets/TransitionEmbed-DR26yI3a.js +1 -0
  12. package/web/assets/{Whiteboard-BP_DvIAV.js → Whiteboard-BhxY0D0Z.js} +3 -3
  13. package/web/assets/aerial-BisYSXzG.js +2 -0
  14. package/web/assets/agentTools-CPFQeiDP.js +2 -0
  15. package/web/assets/aiInbetween-AOOM1e6p.js +2 -0
  16. package/web/assets/analyzerRun-Dtp2o7gT.js +1 -0
  17. package/web/assets/analyzerSandbox-BG_3Cea1.js +33 -0
  18. package/web/assets/api-BFN7blbw.js +3158 -0
  19. package/web/assets/auraTrack-D_gxHNVe.js +1 -0
  20. package/web/assets/breakthrough-0qFpZW-V.js +2 -0
  21. package/web/assets/{cameraPresets-CYw0OdM3.js → cameraPresets-eK3mP7qb.js} +1 -1
  22. package/web/assets/cameraTracker-BAQHuTV-.js +72 -0
  23. package/web/assets/captionLayout-CWPcbid-.js +1 -0
  24. package/web/assets/clientExport-DvpTTndR.js +1 -0
  25. package/web/assets/clientJobs-CIrYTMpn.js +2 -0
  26. package/web/assets/clientJobs-CuuUyhEy.js +1 -0
  27. package/web/assets/cutoutClean-CLYYAuXg.js +1 -0
  28. package/web/assets/depthEstimate-B7D7cGCl.js +1 -0
  29. package/web/assets/directorTools-CJD4Huqk.js +1 -0
  30. package/web/assets/distortFrames-BLt1icUb.js +2 -0
  31. package/web/assets/{distortGL-QalhICvi.js → distortGL-BA5molk-.js} +3 -3
  32. package/web/assets/draco_decoder-C32yEggz.wasm +0 -0
  33. package/web/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
  34. package/web/assets/draco_decoder-fzg4nYZr.js +34 -0
  35. package/web/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
  36. package/web/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
  37. package/web/assets/editTools-NKLsWZD1.js +1 -0
  38. package/web/assets/{engine-BedcnK45.js → engine-DioUF2mX.js} +1 -1
  39. package/web/assets/exportGlb-BOdI9cVS.js +2 -0
  40. package/web/assets/faceTracker-D7CbF-qX.js +1 -0
  41. package/web/assets/fightDirector-CYP8jxo8.js +1 -0
  42. package/web/assets/fightDrama-DIPcRKnc.js +2 -0
  43. package/web/assets/focusTool-vfabPqQ5.js +1 -0
  44. package/web/assets/{frameSink-DeM8xC8_.js → frameSink-DYs2gTzq.js} +3 -3
  45. package/web/assets/glTransitionSources.generated-DM5sRMX2.js +3695 -0
  46. package/web/assets/gltfLoader-U0Eebg7v.js +2 -0
  47. package/web/assets/{gpuCompose-CA3UmOl4.js → gpuCompose-DbnZuelB.js} +1 -1
  48. package/web/assets/gpuExport-CQ7ZhpsX.js +198 -0
  49. package/web/assets/handMatte-DIbMuqCu.js +1 -0
  50. package/web/assets/handTracker-DY_g5Xmg.js +2 -0
  51. package/web/assets/i18n-BJppIrtF.js +3 -0
  52. package/web/assets/index-BfrDwjDI.js +4247 -0
  53. package/web/assets/index-CKtv7gGE.js +9 -0
  54. package/web/assets/{index-D5oyVCRl.js → index-DxdDhmLR.js} +2 -2
  55. package/web/assets/layer-worker-DK67WH1a.js +5 -0
  56. package/web/assets/library-B6KsZUKq.js +1 -0
  57. package/web/assets/lottieLayer-C2YbiXhK.js +161 -0
  58. package/web/assets/{lottie_light_canvas-B-d7-ATe.js → lottie_light_canvas-DX9Wf-DS.js} +1 -1
  59. package/web/assets/main-B27kf5aL.css +1 -0
  60. package/web/assets/main-BKatDoGw.js +309 -0
  61. package/web/assets/mapBake-C-G7WpFM.js +1 -0
  62. package/web/assets/maskTrack-LMrwm5ub.js +1 -0
  63. package/web/assets/matteFixRun-B38CbeEt.js +1 -0
  64. package/web/assets/matteQuality-9X-jgJrH.js +1 -0
  65. package/web/assets/objectLocate-CKi3OTnL.js +1 -0
  66. package/web/assets/objectSegmenter-CziPuM61.js +1 -0
  67. package/web/assets/{objectTrack.worker-BlZkgpOX.js → objectTrack.worker-b7DJ-ub6.js} +196 -196
  68. package/web/assets/pathTracer-bqau16sX.js +2 -0
  69. package/web/assets/pendingMatte-CQb7jPg1.js +2 -0
  70. package/web/assets/personAi-CQntGDqK.js +2 -0
  71. package/web/assets/personHq-B1c0QVJT.js +2 -0
  72. package/web/assets/plateCamera-D7iLiNBy.js +1 -0
  73. package/web/assets/plateCameraMatch-BM88dx-a.js +2 -0
  74. package/web/assets/plateFollow-4iGUDTu1.js +2 -0
  75. package/web/assets/plateMatte-zTyuHHqh.js +2 -0
  76. package/web/assets/plugin-guide.en-DO_fHbzT.js +1 -0
  77. package/web/assets/plugin-guide.vi-CMJDxOhi.js +1 -0
  78. package/web/assets/pluginAutomation-DSg-sYLF.js +1 -0
  79. package/web/assets/poseTracker-DZl8l2qS.js +1 -0
  80. package/web/assets/productTools-B-jh8ukh.js +2 -0
  81. package/web/assets/remote-DJd9xWjn.js +963 -0
  82. package/web/assets/{rigTrack-urT3nDK0.js → rigTrack-XaMj1yaH.js} +1 -1
  83. package/web/assets/rotoMaskStore-DdpmT9C3.js +1 -0
  84. package/web/assets/{rotoMatte-C-2o3vv0.js → rotoMatte-i-cJTYmK.js} +1 -1
  85. package/web/assets/rotoscope-DqRSWmHR.js +1 -0
  86. package/web/assets/sceneTrack-Bbov7zET.js +1 -0
  87. package/web/assets/sceneTrack-DIPzBmMK.js +1 -0
  88. package/web/assets/{sceneTrack.worker-CT4uoTKn.js → sceneTrack.worker-Bav9h0pv.js} +180 -180
  89. package/web/assets/shot-worker-m-q77W9f.js +1 -0
  90. package/web/assets/{shotFxAgent-BFLkqs8v.js → shotFxAgent-DIMS7BGA.js} +2 -2
  91. package/web/assets/{skin-DY4QLaBI.js → skin-DrUzJE1u.js} +1 -1
  92. package/web/assets/{spark.module-DzziUgOj.js → spark.module-Y1SEI8Xz.js} +10 -10
  93. package/web/assets/spellDuel-DNnyQDVr.js +2 -0
  94. package/web/assets/store-GFMJzaWS.js +1 -0
  95. package/web/assets/surfaceLight-C--moyc9.js +1 -0
  96. package/web/assets/surfacePin-B4-1UqXD.js +2 -0
  97. package/web/assets/{textAnimators-DUZjhVGO.js → textAnimators-BVXTl8bU.js} +1 -1
  98. package/web/assets/{thumb-CS0ZuiGS.js → thumb-CTfDJgLp.js} +1 -1
  99. package/web/assets/timeline3d-Dn7PqmEe.js +2 -0
  100. package/web/assets/timeline3dExport-DCOr6ARB.js +1 -0
  101. package/web/assets/timelineComp-Dx_kED5V.js +1 -0
  102. package/web/assets/timelineOps-afzSo188.js +525 -0
  103. package/web/assets/timelineProps-eYgO6gs5.js +1 -0
  104. package/web/assets/timelineText-RKyRP988.js +1 -0
  105. package/web/assets/{titleArt-Drsrtfiv.js → titleArt-CUtA0C3I.js} +4 -4
  106. package/web/assets/{titleFrameBudget-CLZWaFHO.js → titleFrameBudget-X7HLSDre.js} +721 -704
  107. package/web/assets/titleFrames-aMG7HdVe.js +1 -0
  108. package/web/assets/{tool-DktQYmS6.js → tool-DpFjybaq.js} +1 -1
  109. package/web/assets/{tools-Co9aRDiT.js → tools-CeOU0p13.js} +1 -1
  110. package/web/assets/toonTools-DLmo37Z_.js +2 -0
  111. package/web/assets/trackAnchor-hAOtEhKO.js +1 -0
  112. package/web/assets/userFonts-1kuRjWOo.js +1 -0
  113. package/web/assets/{vfxAlpha-71tSN86T.js → vfxAlpha-DxS5-QwY.js} +2 -2
  114. package/web/assets/vfxBackground-CYpaQaTa.js +2 -0
  115. package/web/assets/videoExport-Cg4B2Nyh.js +1 -0
  116. package/web/assets/views-CUXyRb9x.js +1 -0
  117. package/web/assets/weaponDuel-nFECu9nk.js +1 -0
  118. package/web/assets/windowFrames-1wAkkWnv.js +1 -0
  119. package/web/layer-worker.html +3 -3
  120. package/web/shot-worker.html +41 -0
  121. package/web/assets/FxEmbed-BCmj9Q5C.js +0 -1
  122. package/web/assets/GLTFLoader-BHWu1lKg.js +0 -1
  123. package/web/assets/MotionEmbed-CEmbcq8Z.js +0 -1
  124. package/web/assets/PluginStore-C5hyahvG.js +0 -3
  125. package/web/assets/ShotComposer-0DUtMTVI.js +0 -287
  126. package/web/assets/TemplateEmbed-ANxSs7H5.js +0 -2
  127. package/web/assets/TimelineShotFx-q5PQwq-V.js +0 -2
  128. package/web/assets/TransitionEmbed-O6LInGWq.js +0 -1
  129. package/web/assets/aerial-CGLDKKtP.js +0 -2
  130. package/web/assets/agentTools-2Ghb80VH.js +0 -2
  131. package/web/assets/analyzerRun-DRgxrcJA.js +0 -1
  132. package/web/assets/analyzerSandbox-DuIVFnsk.js +0 -33
  133. package/web/assets/api-CJ8PdbfZ.js +0 -3168
  134. package/web/assets/auraTrack-DQw9sVU6.js +0 -1
  135. package/web/assets/breakthrough-BNj_iTDr.js +0 -2
  136. package/web/assets/captionLayout-DvDPTwO9.js +0 -1
  137. package/web/assets/clientExport-xhoXY6Dh.js +0 -1
  138. package/web/assets/depthEstimate-DEpeCojm.js +0 -1
  139. package/web/assets/directorTools-C5CpTmci.js +0 -1
  140. package/web/assets/distortFrames-Dia8O1NM.js +0 -2
  141. package/web/assets/editTools-CY_JrQfw.js +0 -1
  142. package/web/assets/exportEncode-QYsT9JBO.js +0 -1
  143. package/web/assets/exportGlb-TSj09XoV.js +0 -2
  144. package/web/assets/faceTracker-CnCWOwnJ.js +0 -1
  145. package/web/assets/fightDirector-DCI_FWTh.js +0 -1
  146. package/web/assets/fightDrama-Bg7uP_2Q.js +0 -2
  147. package/web/assets/gpuExport-D31azOQA.js +0 -198
  148. package/web/assets/handMatte-Dl-xVXFR.js +0 -1
  149. package/web/assets/handTracker-CplBsAFg.js +0 -2
  150. package/web/assets/layer-worker-DFuo32bk.js +0 -5
  151. package/web/assets/library-BufgA-Pl.js +0 -1
  152. package/web/assets/lottieLayer-DzbA3bHV.js +0 -158
  153. package/web/assets/main-Ca_CVxMz.css +0 -1
  154. package/web/assets/main-VVYiW8XD.js +0 -309
  155. package/web/assets/mapBake-BKOcEd0w.js +0 -1
  156. package/web/assets/maskTrack-CHGXtBRy.js +0 -1
  157. package/web/assets/matteFixRun-vgYrINet.js +0 -1
  158. package/web/assets/objectLocate-BJltm8Ob.js +0 -1
  159. package/web/assets/pendingMatte-BPyzzx4y.js +0 -2
  160. package/web/assets/personAi-gJu03SjU.js +0 -2
  161. package/web/assets/plateCamera-B2JvhjJw.js +0 -1
  162. package/web/assets/plateCameraMatch-ByB9nVQT.js +0 -2
  163. package/web/assets/plateFollow-C9S-l7RH.js +0 -2
  164. package/web/assets/plateMatte-J4qlNHnY.js +0 -2
  165. package/web/assets/plugin-guide.en-CGYh_9Su.js +0 -1
  166. package/web/assets/plugin-guide.vi-DMphSELb.js +0 -1
  167. package/web/assets/pluginAutomation-CkP3tA9r.js +0 -1
  168. package/web/assets/poseTracker-DGLbouqt.js +0 -1
  169. package/web/assets/productTools-CkaWF1bM.js +0 -2
  170. package/web/assets/remote-C7J0Tqhb.js +0 -1433
  171. package/web/assets/rotoMaskStore-DPziPKAN.js +0 -1
  172. package/web/assets/rotoscope-GvPFRUBg.js +0 -1
  173. package/web/assets/shot-worker-6dYkHPoL.js +0 -1
  174. package/web/assets/spellDuel-BD3m2ebA.js +0 -2
  175. package/web/assets/store-DW4E9xnW.js +0 -1
  176. package/web/assets/surfaceLight-aDSYU8Jg.js +0 -1
  177. package/web/assets/surfacePin-m83hCgGP.js +0 -2
  178. package/web/assets/timeline3d-DOw-CpZI.js +0 -2
  179. package/web/assets/timeline3dExport-BtYLU1pw.js +0 -1
  180. package/web/assets/timelineComp-B4GtoH2f.js +0 -1
  181. package/web/assets/timelineProps-D7MVutxu.js +0 -1
  182. package/web/assets/timelineText-BH09jfSM.js +0 -1
  183. package/web/assets/titleFrames-BI1DnLBn.js +0 -1
  184. package/web/assets/toonTools-CD9clJvN.js +0 -2
  185. package/web/assets/trackAnchor-sOjTtd3I.js +0 -1
  186. package/web/assets/userFonts-CwlKh9NR.js +0 -1
  187. package/web/assets/vfxBackground-Bq7lJvmZ.js +0 -2
  188. package/web/assets/videoExport-D4KbireJ.js +0 -1
  189. package/web/assets/views-ozVF4ABO.js +0 -1
  190. package/web/assets/weaponDuel-ZhX-tjGZ.js +0 -1
  191. package/web/assets/windowFrames-CpqX3kOM.js +0 -1
@@ -1,198 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/titleFrames-BI1DnLBn.js","assets/titleFrameBudget-CLZWaFHO.js","assets/titleArt-Drsrtfiv.js","assets/textAnimators-DUZjhVGO.js","assets/lottieLayer-DzbA3bHV.js","assets/rigTrack-urT3nDK0.js","assets/api-CJ8PdbfZ.js","assets/frameSink-DeM8xC8_.js","assets/timeline3dExport-BtYLU1pw.js","assets/timeline3d-DOw-CpZI.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/rotoMatte-C-2o3vv0.js","assets/store-DW4E9xnW.js","assets/captionLayout-DvDPTwO9.js"])))=>i.map(i=>d[i]);
2
- import{c1 as oo,U as qt,eS as Xo,eQ as co,cM as Mo,au as Oo,f9 as zo,lp as Go,iQ as qo,_ as Pt,il as Zt,aq as $o,lq as Qt,aR as jo,aP as fo,i0 as Ho,i1 as Vo,lr as lo,ep as Yo,f0 as uo,cd as Jt,cf as Wo,fF as Ko,fa as $t,f8 as Qo,W as eo,eI as mo,eK as po,eJ as xo,cU as jt,eM as Jo,f6 as Zo,dW as vo,ls as er,ce as tr,f2 as or,fy as rr,f1 as ir,hW as ar,et as Vt,jY as nr,eC as ho,eB as sr,hU as cr,lt as fr,lu as lr,b2 as ur,aQ as mr,lv as pr,lw as dr,lx as xr,bH as vr,aG as So,ly as hr,h as Do,lz as Er,lA as br,eh as gr,ei as Tr,ai as wr,lB as yr,eD as Rr,eE as _r,eF as Fr,ez as Ar,eG as Mr,lC as Sr,lD as Dr,fj as kr,cq as Ur,i4 as Pr,lE as Br,h_ as Nr,eH as Eo,lF as Lr,V as Ir,X as Cr,a0 as bo,lG as go,Y as To,an as Xr,lH as Or,ek as zr,a2 as Gr,a3 as qr,lI as $r,a4 as jr,ej as Hr,a5 as Vr,ab as Yr,aa as Wr,a8 as Kr,a6 as Mt,lJ as to,eN as Qr,lK as Jr,el as Zr,lL as ei,lM as ti}from"./titleFrameBudget-CLZWaFHO.js";import{b as oi,e as ri,a as ii}from"./timelineComp-B4GtoH2f.js";import{g as ro,l as ot,f as Bt,p as Nt,s as wo,w as It,r as ai,a as Lt,t as ni,n as si,b as yo,c as ko,d as ci}from"./gpuCompose-CA3UmOl4.js";import{t as fi}from"./motionBlur-uAm030t9.js";import{f as io,h as li,z as ui,L as mi,d as pi,c as di,l as xi,b as vi}from"./exportEncode-QYsT9JBO.js";import{c as hi}from"./distortGL-QalhICvi.js";import{c as ao,V as Ei,a as bi,I as gi,A as Ti,U as wi,b as yi}from"./id3-arvEpAg7.js";import{S as Ro,B as Ri,O as _i,M as Fi,a as Ai,C as Mi,A as Si}from"./output-p-Q7qous.js";import"./api-CJ8PdbfZ.js";const Di=p=>p.kind==="image"&&!!p.title?.text&&!p.url&&!Zt(p)&&!Mo(p),Ht=p=>cr(p)||Di(p),Ct=48e3,Uo=192e3,ki=4,Po=(p,g)=>g?.name==="AbortError"||p>=ki?null:Math.min(2**(p-1),4);async function Ui(p,g){for(let w=1;;w++){let e;try{e=await fetch(p,{signal:g})}catch(G){const E=g?.aborted?null:Po(w,G);if(E===null)throw G;await new Promise(N=>setTimeout(N,E*1e3));continue}if(!e.ok)throw Error(`media ${e.status}`);return e.blob()}}const Bo=()=>bi("aac",{numberOfChannels:2,sampleRate:Ct,bitrate:Uo}).catch(()=>!1),Ua=async(p,g)=>await ao("avc",{width:p,height:g}).catch(()=>!1)&&Bo();async function Pa(p){try{const{width:g,height:w,fps:e}=oo(p);return typeof VideoEncoder>"u"||!new OffscreenCanvas(2,2).getContext("webgl2")?!1:(await VideoEncoder.isConfigSupported({codec:"avc1.640034",width:g,height:w,bitrate:io(null,{width:g,height:w,fps:e},ro),framerate:e,hardwareAcceleration:"prefer-software"})).supported===!0}catch{return!1}}const Ba=(p,g)=>ao("hevc",{width:p,height:g}).catch(()=>!1);async function Na(p,g){try{const{width:w,height:e,fps:G}=oo(p),E=g?.codec==="hevc";return typeof VideoEncoder>"u"||typeof AudioEncoder>"u"||typeof OfflineAudioContext>"u"||!new OffscreenCanvas(2,2).getContext("webgl2")||!(await VideoEncoder.isConfigSupported({codec:E?"hvc1.1.6.L153.B0":"avc1.640034",width:w,height:e,bitrate:io(g,{width:w,height:e,fps:G},ro),framerate:G,hardwareAcceleration:"prefer-hardware"})).supported?!1:await ao(E?"hevc":"avc",{width:w,height:e})&&await Bo()}catch{return!1}}class Pi{frames=new Map;async push(g,w,e){let G=this.frames.get(w);G||(G=[],this.frames.set(w,G)),G.push(e)}}async function _o(p,g,w,e,G,E,N){const A=g.get(w.url);if(!A)return null;if(So(w)&&!w._still){const C=`${w.id}
3
- remap
4
- ${E}`,L=Math.round((e-E)*G);let O=p.get(C);if(!O){const te=A.samplesAtTimestamps(hr(w,E-w.start,Math.max(1,Math.round(N*G)),G))[Symbol.asyncIterator]();O={iterator:te,peek:null,current:null,ts0:0,idx:0,next:async()=>{const oe=await te.next();return oe.done?null:oe.value}},p.set(C,O)}for(;(O.idx??0)<=L;){const te=await O.iterator.next();if(O.idx=(O.idx??0)+1,te.done)break;te.value&&te.value!==O.current&&(O.current?.close(),O.current=te.value)}return O.current}const Y=!!(w._still||w.freeze),re=Y?1:w.playbackRate||1,ae=!Y&&Do(w),me=ae?Er(w,E,N).start:(w.inPoint||0)+(Y?0:(E-w.start)*re),de=`${w.id}
5
- ${Y?"still":E}`;let d=p.get(de);if(!d){if(!Y)for(const[L,O]of p)L!==de&&L.startsWith(`${w.id}
6
- `)&&!L.endsWith(`
7
- still`)&&!L.includes(`
8
- remap
9
- `)&&(O.current?.close(),O.peek?.close(),p.delete(L),await O.iterator.return?.());const C=A.samples(Math.max(0,me-.5))[Symbol.asyncIterator]();if(d={iterator:C,peek:null,current:null,ts0:me,next:async()=>{const L=await C.next();return L.done?null:L.value}},d.peek=await d.next(),!Y){for(;d.peek&&d.peek.timestamp<me-1e-4;)d.peek.close(),d.peek=await d.next();d.ts0=d.peek?.timestamp??me}if(ae){const L=z=>Number(z.toFixed(6)),O=E-w.start,te=br(w,O,O+N),oe=te.slice(0,-1).map(([z,_e],Te)=>{const[Oe,we]=te[Te+1];return{xa:L(z),dx:L(Oe-z),k:Oe-z>1e-9?L((we-_e)/(Oe-z)):0}}).filter(z=>z.dx>1e-9);d.out=z=>oe.reduce((_e,Te)=>_e+Math.min(Te.dx,Math.max(0,z-Te.xa))*Te.k,0)}p.set(de,d)}if(Y){const C=Math.round(me*G);for(;d.peek&&Math.round(d.peek.timestamp*G)<=C;)d.current?.close(),d.current=d.peek,d.peek=await d.next();return d.current??d.peek}const y=Math.round((e-E)*G),_=C=>d.out?d.out(C-d.ts0):(C-d.ts0)/re;for(;d.peek&&Math.round(_(d.peek.timestamp)*G)<=y;)d.current?.close(),d.current=d.peek,d.peek=await d.next();return d.current??d.peek}const Bi=`#version 300 es
10
- in vec2 p;uniform vec4 dst;uniform vec4 src;out vec2 uv;
11
- void main(){uv=src.xy+p*src.zw;vec2 q=dst.xy+p*dst.zw;gl_Position=vec4(q.x*2.-1.,1.-q.y*2.,0,1);}`,Ni=`#version 300 es
12
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float alpha;uniform float fade;uniform float white;
13
- uniform float bright;uniform float contrast;uniform mat3 sat;uniform mat3 rot;uniform float colour;out vec4 o;
14
- uniform sampler2D matte;uniform float useMatte;uniform vec4 mrect;
15
- // chroma key (shared/chromaKey.js, the server's geq on the decoded picture): alpha = clip((d − similarity) / blend), d = |CbCr − key|
16
- // / (255√2) with the picture's own Cb / Cr (8-bit studio range, back from RGB with its matrix: kmat 1 = BT.709, 0 = BT.601) and the
17
- // key's BT.601 Cb / Cr; then despill (mix 0.5) pulls the green / blue cast back by spill
18
- uniform vec4 key;uniform vec4 keyOpt;
19
- // the grade's 1D LUT (shared/timelineGrade.js gradeLut, 256 entries: an 8-bit input lands on an entry) and its 3D table (the colour
20
- // mixer, timelineMixer.js mixerLut; ffmpeg lut3d trilinear), each on 8-bit values like the server's lut1d / lut3d
21
- uniform highp sampler2D lut1;uniform highp sampler3D lut3;uniform float useL1;uniform float useL3;
22
- vec3 tri(vec3 q){int n=textureSize(lut3,0).x;vec3 p=q*float(n-1),f=floor(p),w=p-f;ivec3 i=ivec3(f),j=min(i+1,ivec3(n-1));
23
- vec3 c000=texelFetch(lut3,i,0).rgb,c100=texelFetch(lut3,ivec3(j.x,i.y,i.z),0).rgb,c010=texelFetch(lut3,ivec3(i.x,j.y,i.z),0).rgb,c110=texelFetch(lut3,ivec3(j.x,j.y,i.z),0).rgb;
24
- vec3 c001=texelFetch(lut3,ivec3(i.x,i.y,j.z),0).rgb,c101=texelFetch(lut3,ivec3(j.x,i.y,j.z),0).rgb,c011=texelFetch(lut3,ivec3(i.x,j.y,j.z),0).rgb,c111=texelFetch(lut3,j,0).rgb;
25
- return mix(mix(mix(c000,c100,w.x),mix(c010,c110,w.x),w.y),mix(mix(c001,c101,w.x),mix(c011,c111,w.x),w.y),w.z);}
26
- void main(){vec4 c=texture(tex,uv);vec3 rgb=c.rgb;
27
- if(keyOpt.x>.5){vec3 q=floor(rgb*255.+.5);float k=224./255.;
28
- float u=keyOpt.w>.5?floor((-.114572*q.r-.385428*q.g+.5*q.b)*k+128.5):floor((-.168736*q.r-.331264*q.g+.5*q.b)*k+128.5);
29
- float v=keyOpt.w>.5?floor((.5*q.r-.454153*q.g-.045847*q.b)*k+128.5):floor((.5*q.r-.418688*q.g-.081312*q.b)*k+128.5);
30
- float d=length(vec2(u-key.x,v-key.y))/360.62445840513925,a=key.w>1e-4?clamp((d-key.z)/key.w,0.,1.):step(key.z,d)-step(d,key.z)*0.;
31
- c.a*=floor(a*255.)/255.;
32
- if(keyOpt.z>0.){if(keyOpt.y>.5){float m=max(0.,rgb.b-(rgb.r*.5+rgb.g*.5));rgb.b=max(0.,rgb.b-m*keyOpt.z);}else{float m=max(0.,rgb.g-(rgb.r*.5+rgb.b*.5));rgb.g=max(0.,rgb.g-m*keyOpt.z);}}}
33
- if(useMatte>.5)c.a*=texture(matte,(uv-mrect.xy)/mrect.zw).r;
34
- if(colour>.5){rgb=clamp(rgb*bright,0.,1.);rgb=clamp((rgb-.5)*contrast+.5,0.,1.);rgb=clamp(sat*rgb,0.,1.);rgb=clamp(rot*rgb,0.,1.);}
35
- if(useL1>.5){ivec3 k=ivec3(floor(rgb*255.+.5));rgb=floor(vec3(texelFetch(lut1,ivec2(k.r,0),0).r,texelFetch(lut1,ivec2(k.g,0),0).g,texelFetch(lut1,ivec2(k.b,0),0).b)*255.+.5)/255.;}
36
- if(useL3>.5)rgb=floor(clamp(tri(floor(rgb*255.+.5)/255.),0.,1.)*255.+.5)/255.;
37
- rgb=white>.5?1.-(1.-rgb)*fade:rgb*fade;o=vec4(rgb,c.a*alpha);}`,$=`#version 300 es
38
- in vec2 p;out vec2 uv;void main(){uv=p;gl_Position=vec4(p*2.-1.,0,1);}`,Li=`#version 300 es
39
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 step;uniform float sigma;out vec4 o;
40
- void main(){int r=min(int(ceil(sigma*3.)),128);vec4 acc=vec4(0);float wsum=0.;
41
- for(int i=-r;i<=r;i++){float w=exp(-float(i*i)/(2.*sigma*sigma));acc+=texture(tex,uv+step*float(i))*w;wsum+=w;}
42
- o=acc/wsum;}`,Ii=`#version 300 es
43
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float lo;uniform float k;out vec4 o;
44
- void main(){vec4 c=texture(tex,uv);o=vec4(clamp(lo+c.rgb*k,0.,1.),c.a);}`,Ci=`#version 300 es
45
- precision highp float;in vec2 uv;uniform sampler2D a;uniform sampler2D b;uniform float amount;out vec4 o;
46
- void main(){vec4 x=texture(a,uv),y=texture(b,uv);o=mix(x,1.-(1.-x)*(1.-y),amount);}`,Xi=`#version 300 es
47
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 step;uniform float b;uniform int reach;out vec4 o;
48
- void main(){vec4 acc=texture(tex,uv);float ws=1.;float w=1.;
49
- for(int i=1;i<=512;i++){if(i>reach)break;w*=b;acc+=(texture(tex,uv+step*float(i))+texture(tex,uv-step*float(i)))*w;ws+=2.*w;}
50
- o=acc/ws;}`,Oi=`#version 300 es
51
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float taps[16];uniform int n;uniform vec2 ctr;out vec4 o;
52
- void main(){vec4 acc=vec4(0);for(int i=0;i<16;i++){if(i>=n)break;acc+=texture(tex,ctr+(uv-ctr)/taps[i]);}o=acc/float(n);}`,zi=`#version 300 es
53
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float sx[8];uniform float sy[8];uniform int n;uniform vec3 gain;out vec4 o;
54
- void main(){vec4 acc=vec4(0);for(int i=0;i<8;i++){if(i>=n)break;acc+=texture(tex,vec2(.5)+(uv-vec2(.5))/vec2(sx[i],sy[i]));}
55
- acc/=float(n);o=vec4(min(acc.rgb*gain,1.),acc.a);}`,Gi=`#version 300 es
56
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float gain;out vec4 o;
57
- void main(){vec4 c=texture(tex,uv);o=vec4(min(c.rgb*gain,1.),c.a);}`,qi=`#version 300 es
58
- precision highp float;in vec2 uv;uniform sampler2D a;uniform sampler2D b;uniform float w;out vec4 o;
59
- void main(){o=mix(texture(a,uv),texture(b,uv),w);}`,$i=`#version 300 es
60
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec4 colour;uniform float usetex;out vec4 o;
61
- void main(){o=usetex>.5?texture(tex,vec2(uv.x,1.-uv.y)):colour;}`,ji=`#version 300 es
62
- precision highp float;uniform sampler2D tex;uniform mat3 inv;uniform vec2 size;uniform vec4 rnd;uniform float keepPre;out vec4 o;
63
- // a pinned screen's rounded corners (shared/cornerPin.js pinRoundGraph): the server's geq mask on the stretched plane BEFORE its
64
- // 2 px inset, at pixel centres, kept at least rnd.z (the portal dive's fade to square corners); rnd.w = on
65
- float corner(ivec2 i){if(rnd.w<.5)return 1.;vec2 k=size/(size-4.),X=(vec2(i)+.5-2.)*k;
66
- float dx=max(0.,max(rnd.x-X.x,X.x-(size.x-rnd.x))),dy=max(0.,max(rnd.y-X.y,X.y-(size.y-rnd.y)));
67
- float m=clamp((1.-sqrt(pow(dx/rnd.x,2.)+pow(dy/rnd.y,2.)))*min(rnd.x,rnd.y)+.5,0.,1.);return max(floor(m*255.)/255.,rnd.z);}
68
- vec4 px(ivec2 i){ivec2 s=ivec2(size);i=clamp(i,ivec2(0),s-1);vec4 c=texelFetch(tex,ivec2(i.x,s.y-1-i.y),0);float a=c.a*corner(i);return vec4(c.rgb*a,a);}
69
- void main(){vec2 d=vec2(gl_FragCoord.x-.5,size.y-gl_FragCoord.y-.5);vec3 q=inv*vec3(d,1.);vec2 u=floor(q.xy/q.z*256.+.5)/256.;
70
- vec2 f=floor(u),w=u-f;ivec2 i=ivec2(f);
71
- vec4 c=mix(mix(px(i),px(i+ivec2(1,0)),w.x),mix(px(i+ivec2(0,1)),px(i+ivec2(1,1)),w.x),w.y);
72
- o=keepPre>.5?c:c.a>0.?vec4(c.rgb/c.a,c.a):vec4(0);}`,Hi=`#version 300 es
73
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 size;uniform int kind;uniform float e;uniform float f;uniform float inv;
74
- uniform vec2 ctr;uniform vec3 csh;uniform float count;out vec4 o;
75
- void main(){vec4 c=texture(tex,uv);float X=gl_FragCoord.x-.5,Y=size.y-gl_FragCoord.y-.5,W=size.x,H=size.y,r;
76
- float cx=ctr.x*W,cy=ctr.y*H,dx=X-cx,dy=Y-cy,R=length(vec2(max(cx,W-cx),max(cy,H-cy)));
77
- if(kind<=2){float lin=(X/W-.5)*csh.x+(Y/H-.5)*csh.y,h=csh.z;if(kind==2)r=abs(lin)/h;else{float u=(lin+h)/(2.*h);r=kind==1?mod(u*count,1.):u;}}
78
- else if(kind==3)r=length(vec2(dx,dy))/R;
79
- else if(kind==4)r=(abs(dx)/max(cx,W-cx)+abs(dy)/max(cy,H-cy))/2.;
80
- else if(kind==5){float u=X/W,v=Y/H,A=W/H;r=.1+.78*length(vec2(dx,dy))/R+.12*((sin(u*A*5.3+1.7)*sin(v*4.9+.4)+.55*sin(u*A*11.3-v*9.7+2.3)+.3*sin(u*A*19.1+v*17.3+.7))/1.85);}
81
- else if(kind==7){float s=W/count,i=floor(X/s),j=floor(Y/s);r=mod(i*i*31.+j*j*17.+i*j*7.+i*13.+j*29.+11.,97.)/97.;}
82
- else{float a=atan(dx,-dy);if(a<0.)a+=6.283185307179586;r=a/6.283185307179586;}
83
- float m=clamp((e-r)/f,0.,1.);if(inv>.5)m=1.-m;m=floor(m*255.+.5)/255.;o=vec4(c.rgb,c.a*m);}`,Vi=`#version 300 es
84
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform highp sampler2D lut;uniform float m[12];uniform float useM;uniform float useL;out vec4 o;
85
- void main(){vec4 c=texture(tex,uv),v=floor(c*255.+.5);vec3 q=v.rgb;
86
- if(useM>.5){vec3 r;for(int i=0;i<3;i++)r[i]=floor(v.r*m[i*4]+.5)+floor(v.g*m[i*4+1]+.5)+floor(v.b*m[i*4+2]+.5)+floor(v.a*m[i*4+3]+.5);q=clamp(r,0.,255.);}
87
- if(useL>.5)q=vec3(texelFetch(lut,ivec2(int(q.r),0),0).r,texelFetch(lut,ivec2(int(q.g),1),0).r,texelFetch(lut,ivec2(int(q.b),2),0).r)*255.;
88
- o=vec4(q/255.,c.a);}`,Yi=`#version 300 es
89
- precision highp float;uniform sampler2D tex;uniform int px;out vec4 o;
90
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);int W=textureSize(tex,0).x;vec4 c=texelFetch(tex,p,0);
91
- o=vec4(texelFetch(tex,ivec2(clamp(p.x+px,0,W-1),p.y),0).r,c.g,texelFetch(tex,ivec2(clamp(p.x-px,0,W-1),p.y),0).b,c.a);}`,Wi=`#version 300 es
92
- precision highp float;uniform sampler2D tex;uniform int b;uniform ivec2 small;out vec4 o;
93
- void main(){ivec2 s=textureSize(tex,0),k=ivec2(gl_FragCoord.xy);k.y=small.y-1-k.y;vec4 sum=vec4(0);float n=0.;
94
- for(int j=0;j<64;j++){if(j>=b)break;int y=k.y*b+j;if(y>=s.y)break;for(int i=0;i<64;i++){if(i>=b)break;int x=k.x*b+i;if(x>=s.x)break;sum+=texelFetch(tex,ivec2(x,s.y-1-y),0);n+=1.;}}
95
- o=sum/n;}`,Ki=`#version 300 es
96
- precision highp float;uniform sampler2D small;uniform int b;uniform vec2 size;out vec4 o;
97
- void main(){ivec2 p=ivec2(gl_FragCoord.xy),ss=textureSize(small,0);int y=int(size.y)-1-p.y;o=texelFetch(small,ivec2(p.x/b,ss.y-1-y/b),0);}`,Qi=`#version 300 es
98
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 off;uniform vec3 col;uniform float op;uniform float times;uniform vec2 dil;out vec4 o;
99
- void main(){vec2 p=uv-off;float v=0.;if(p.x>=0.&&p.x<=1.&&p.y>=0.&&p.y<=1.)v=floor(texture(tex,p).a*255.+.5);
100
- float a=dil.y>0.?clamp(floor((v-dil.x)*dil.y),0.,255.):times<1.5?floor(v*op):floor(255.*(1.-pow(1.-v/255.*op,times)));
101
- o=vec4(col,a/255.);}`,Ji=`#version 300 es
102
- precision highp float;uniform sampler2D tex;uniform float harden;out vec4 o;
103
- void main(){float a=floor(texelFetch(tex,ivec2(gl_FragCoord.xy),0).a*255.+.5);if(harden>0.)a=clamp((a-128.)*harden+128.,0.,255.);o=vec4(a/255.,0,0,1);}`,Zi=`#version 300 es
104
- precision highp float;uniform sampler2D tex;uniform ivec2 dir;uniform float sigma;out vec4 o;
105
- void main(){ivec2 p=ivec2(gl_FragCoord.xy),n=textureSize(tex,0);int r=min(int(ceil(sigma*3.)),128);float acc=0.,ws=0.;
106
- for(int i=-r;i<=r;i++){float w=exp(-float(i*i)/(2.*sigma*sigma));ivec2 q=p+dir*i;
107
- if(q.x>=0&&q.y>=0&&q.x<n.x&&q.y<n.y)acc+=texelFetch(tex,q,0).r*w;ws+=w;}
108
- o=vec4(floor(acc/ws*255.+.5)/255.,0,0,1);}`,ea=`#version 300 es
109
- precision highp float;uniform sampler2D a;uniform sampler2D b;uniform float arc;uniform vec2 cw;uniform vec2 cen;uniform float start;uniform float cover;uniform float comet;uniform float feather;out vec4 o;
110
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);float x=floor(texelFetch(a,p,0).r*255.+.5),y=floor(texelFetch(b,p,0).r*255.+.5);
111
- float band=floor(x*clamp(2.*(1.-y/max(x,1.)),0.,1.));
112
- if(arc>.5){float K=${to}.,TAU=6.283185307179586;vec2 u=vec2(gl_FragCoord.x,cw.y*K-gl_FragCoord.y)/K;float th=atan(u.x-cw.x*cen.x,cw.y*cen.y-u.y);
113
- float d=mod(mod(th-start,TAU)+TAU,TAU)/TAU,m=d<=cover?1.:0.;if(cover<.999)m*=clamp(min(d,cover-d)/feather,0.,1.);if(comet>.5)m*=d/cover;
114
- band=floor(band*floor(255.*m)/255.);}
115
- o=vec4(band/255.,0,0,1);}`,ta=`#version 300 es
116
- precision highp float;uniform sampler2D pic;uniform sampler2D band;uniform sampler2D glow;uniform vec3 col;uniform float k;uniform float am;out vec4 o;
117
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);float b=floor(texelFetch(band,p,0).r*255.+.5),g=floor(texelFetch(glow,p,0).r*255.+.5);
118
- float rim=clamp(floor(b+g*k),0.,255.);if(am<255.)rim=floor(rim*am/255.);
119
- vec4 P=texelFetch(pic,p,0);float ra=rim/255.,oa=ra+P.a*(1.-ra);
120
- o=vec4(oa>0.?(col*ra+P.rgb*P.a*(1.-ra))/oa:P.rgb,oa);}`,oa=`#version 300 es
121
- precision highp float;in vec2 uv;uniform sampler2D tex;out vec4 o;void main(){vec4 c=texture(tex,uv);o=vec4(c.rgb*c.a,c.a)*.25;}`,ra=`#version 300 es
122
- precision highp float;in vec2 uv;uniform sampler2D tex;out vec4 o;void main(){vec4 c=texture(tex,uv);o=c.a>0.?vec4(min(c.rgb/c.a,1.),c.a):vec4(0);}`,ia=`#version 300 es
123
- precision highp float;uniform sampler2D tex;uniform vec2 big;uniform vec2 small;uniform vec4 q1;uniform vec4 q2;uniform float useQ;
124
- uniform vec4 w1;uniform vec4 w2;uniform float useW;uniform float inv;out vec4 o;
125
- float rp(float v,float lo,float hi,float ss){return clamp((v-lo)/ss+1.,0.,1.)*clamp((hi-v)/ss+1.,0.,1.);}
126
- void main(){vec2 X=floor(gl_FragCoord.xy),c=(X+.5)*big/small;vec3 a=vec3(0);
127
- for(int j=0;j<2;j++)for(int i=0;i<2;i++)a+=texture(tex,(c+vec2(float(i)*2.-1.,float(j)*2.-1.))/big).rgb;
128
- vec3 p=floor(a/4.*255.+.5)/255.;float m=1.;
129
- if(useQ>.5){float h=atan(sqrt(3.)*(p.g-p.b),2.*p.r-p.g-p.b)*180./3.14159265358979;if(h<0.)h+=360.;
130
- float d=abs(h-q1.x);if(d>180.)d=360.-d;float mh=q1.y>=360.?1.:clamp((q1.y/2.+q1.z-d)/q1.z,0.,1.);
131
- float ch=max(max(p.r,p.g),p.b)-min(min(p.r,p.g),p.b),l=.2126*p.r+.7152*p.g+.0722*p.b;
132
- m*=mh*rp(ch,q2.x,q2.y,q1.w)*rp(l,q2.z,q2.w,q1.w);}
133
- if(useW>.5){float dx=X.x/small.x-w1.x,dy=X.y/small.y-w1.y,x=dx*w2.x-dy*w2.y,y=dx*w2.y+dy*w2.x;
134
- if(w2.w>1.5)m*=clamp(.5-y/w1.w,0.,1.);
135
- else{float nx=abs(x)/w1.z,ny=abs(y)/w2.z,dist=w2.w>.5?max(nx,ny):length(vec2(nx,ny));m*=clamp((1.+w1.w/2.-dist)/w1.w,0.,1.);}}
136
- if(inv>.5)m=1.-m;o=vec4(floor(255.*m+1e-4)/255.,0,0,1);}`,aa=`#version 300 es
137
- precision highp float;uniform sampler2D tex;uniform highp sampler2D lut;uniform highp sampler3D t3;uniform float useT;uniform float useL;
138
- uniform float useS;uniform mat3 sat;uniform float useR;uniform mat3 rot;out vec4 o;
139
- vec3 tri(vec3 q){int n=textureSize(t3,0).x;vec3 p=q*float(n-1),f=floor(p),w=p-f;ivec3 i=ivec3(f),j=min(i+1,ivec3(n-1));
140
- vec3 c000=texelFetch(t3,i,0).rgb,c100=texelFetch(t3,ivec3(j.x,i.y,i.z),0).rgb,c010=texelFetch(t3,ivec3(i.x,j.y,i.z),0).rgb,c110=texelFetch(t3,ivec3(j.x,j.y,i.z),0).rgb;
141
- vec3 c001=texelFetch(t3,ivec3(i.x,i.y,j.z),0).rgb,c101=texelFetch(t3,ivec3(j.x,i.y,j.z),0).rgb,c011=texelFetch(t3,ivec3(i.x,j.y,j.z),0).rgb,c111=texelFetch(t3,j,0).rgb;
142
- return mix(mix(mix(c000,c100,w.x),mix(c010,c110,w.x),w.y),mix(mix(c001,c101,w.x),mix(c011,c111,w.x),w.y),w.z);}
143
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);vec3 g=floor(c.rgb*255.+.5);
144
- if(useT>.5)g=floor(clamp(tri(g/255.),0.,1.)*255.+.5);
145
- if(useL>.5){ivec3 k=ivec3(g);g=floor(vec3(texelFetch(lut,ivec2(k.r,0),0).r,texelFetch(lut,ivec2(k.g,0),0).g,texelFetch(lut,ivec2(k.b,0),0).b)*255.+.5);}
146
- if(useS>.5)g=floor(clamp(sat*(g/255.),0.,1.)*255.+.5);
147
- if(useR>.5)g=floor(clamp(rot*(g/255.),0.,1.)*255.+.5);
148
- o=vec4(g/255.,c.a);}`,na=`#version 300 es
149
- precision highp float;uniform sampler2D base;uniform sampler2D over;uniform sampler2D mask;uniform vec2 msz;uniform float full;out vec4 o;
150
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 b=texelFetch(base,P,0),g=texelFetch(over,P,0);if(full>.5){o=g;return;}
151
- vec3 q=floor(b.rgb*255.+.5),G=floor(g.rgb*255.+.5);float m=floor(texture(mask,gl_FragCoord.xy/msz).r*255.+.5);
152
- o=vec4((q+floor((m*(G-q)+128.)/256.))/255.,b.a);}`,sa=`#version 300 es
153
- precision highp float;uniform sampler2D tex;uniform float k[9];uniform float rdiv;out vec4 o;
154
- void main(){ivec2 P=ivec2(gl_FragCoord.xy),S=textureSize(tex,0);vec3 s=vec3(0);
155
- for(int j=0;j<3;j++)for(int i=0;i<3;i++){int x=abs(P.x+i-1),y=abs(P.y+j-1);x=x>=S.x?2*S.x-1-x:x;y=y>=S.y?2*S.y-1-y:y;s+=floor(texelFetch(tex,ivec2(x,y),0).rgb*255.+.5)*k[j*3+i];}
156
- vec4 c=texelFetch(tex,P,0);o=vec4(clamp(floor(s*rdiv+.5),0.,255.)/255.,c.a);}`,ca=`#version 300 es
157
- precision highp float;uniform sampler2D tex;uniform sampler2D grain;out vec4 o;
158
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);float n=floor(texelFetch(grain,P,0).r*255.+.5)-128.;o=vec4(clamp(floor(c.rgb*255.+.5)+n,0.,255.)/255.,c.a);}`,fa=`#version 300 es
159
- precision highp float;uniform sampler2D res;uniform sampler2D outp;uniform sampler2D inp;out vec4 o;
160
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 r=texelFetch(res,P,0);vec3 R=floor(r.rgb*255.+.5),O=floor(texelFetch(outp,P,0).rgb*255.+.5),I=floor(texelFetch(inp,P,0).rgb*255.+.5);
161
- vec3 d=clamp(O-I+128.,0.,255.);o=vec4(clamp(R+d-128.,0.,255.)/255.,r.a);}`,la=`#version 300 es
162
- precision highp float;uniform sampler2D tex;uniform sampler2D soft;uniform float t;out vec4 o;
163
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);vec3 V=floor(c.rgb*255.+.5),B=floor(texelFetch(soft,P,0).rgb*255.+.5);
164
- vec3 x=clamp(V-B+128.,0.,255.)-128.,g=clamp((abs(x)-t)/t,0.,1.),d=clamp(floor(128.+x*g*g*(3.-2.*g)+.5),0.,255.);
165
- o=vec4(clamp(B+d-128.,0.,255.)/255.,c.a);}`,ua=`#version 300 es
166
- precision highp float;in vec2 uv;uniform sampler2D top;uniform sampler2D bg;uniform int mode;out vec4 o;
167
- void main(){vec4 s=texture(top,uv),b=texture(bg,uv);vec3 Bp=floor(b.rgb*255.+.5),S=floor(s.rgb*255.+.5);float a=floor(s.a*255.+.5),ab=b.a;
168
- if(mode==1){o=vec4(min(vec3(255.),Bp+floor(S*a/255.+.5))/255.,min(1.,a/255.+ab));return;}
169
- // the backdrop is premultiplied (a comp's own transparent picture, gpuExport frames mode): blended against its straight colour, and
170
- // where it is transparent the layer shows as itself (W3C / After Effects); an opaque backdrop (ab = 1) is the formula as before
171
- vec3 B=ab>0.?(ab<1.?floor(Bp/ab+.5):Bp):vec3(0),X;
172
- if(mode==2)X=255.-floor((255.-B)*(255.-S)/255.);
173
- else if(mode==3)X=floor(B*S/255.);
174
- else if(mode==4)X=mix(255.-2.*floor((255.-B)*(255.-S)/255.),2.*floor(B*S/255.),step(B,vec3(127.5)));
175
- else if(mode==5)X=max(B,S);else if(mode==6)X=min(B,S);else if(mode==7)X=abs(B-S);else X=B+S-2.*floor(B*S/255.);
176
- X=clamp(X,0.,255.);if(ab<1.)X=mix(S,X,ab);o=vec4(floor((X*a+Bp*(255.-a))/255.+.5)/255.,ab<1.?a/255.+ab*(1.-a/255.):b.a);}`,ma=`#version 300 es
177
- precision highp float;uniform sampler2D tex;uniform int ss;out vec4 o;
178
- void main(){ivec2 p=ivec2(gl_FragCoord.xy)*ss;vec4 c=vec4(0);for(int j=0;j<4;j++){if(j>=ss)break;for(int i=0;i<4;i++){if(i>=ss)break;c+=texelFetch(tex,p+ivec2(i,j),0);}}
179
- c/=float(ss*ss);o=c.a>0.?vec4(c.rgb/c.a,c.a):vec4(0);}`,pa=`#version 300 es
180
- precision highp float;uniform sampler2D tex;uniform int px;out vec4 o;
181
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);int W=textureSize(tex,0).x;vec4 c=texelFetch(tex,p,0);int xr=p.x-px,xb=p.x+px;
182
- o=vec4(xr>=0&&xr<W?texelFetch(tex,ivec2(xr,p.y),0).r:0.,c.g,xb>=0&&xb<W?texelFetch(tex,ivec2(xb,p.y),0).b:0.,c.a);}`,da=`#version 300 es
183
- precision highp float;uniform sampler2D tex;uniform vec2 size;uniform vec2 msize;uniform float v;uniform float fr;out vec4 o;
184
- float sh(float Y){float band=floor(Y*24./size.y),k=mod(band*73.+fr*151.+17.,97.)/97.;return k>1.-v*.6?(k-.5)*2.*v*.15:0.;}
185
- float mx(vec2 s){float X=(s.x+.5)*size.x/msize.x-.5,Y=(s.y+.5)*size.y/msize.y-.5;return floor(clamp(X-size.x*sh(Y),0.,size.x-1.));}
186
- void main(){float X=gl_FragCoord.x-.5,Y=size.y-gl_FragCoord.y-.5;vec2 p=vec2((X+.5)*msize.x/size.x-.5,(Y+.5)*msize.y/size.y-.5),f=floor(p),w=p-f;
187
- vec2 a=clamp(f,vec2(0),msize-1.),b=clamp(f+1.,vec2(0),msize-1.);
188
- float m=mix(mix(mx(a),mx(vec2(b.x,a.y)),w.x),mix(mx(vec2(a.x,b.y)),mx(b),w.x),w.y);
189
- o=texelFetch(tex,ivec2(clamp(int(floor(m+.5)),0,int(size.x)-1),int(size.y)-1-int(Y)),0);}`,xa=`#version 300 es
190
- precision highp float;uniform sampler2D tex;uniform vec2 size;uniform float a[8];uniform float sx[8];uniform float sy[8];out vec4 o;
191
- void main(){vec2 p=vec2(gl_FragCoord.x-.5,size.y-gl_FragCoord.y-.5),c=size*.5-.5;vec4 acc=vec4(0);
192
- for(int k=0;k<8;k++){vec2 d=p-c;float cs=cos(a[k]),sn=sin(a[k]);vec2 q=vec2(d.x*cs+d.y*sn,-d.x*sn+d.y*cs);vec2 s=q/vec2(sx[k],sy[k])+c;
193
- vec2 uv=vec2((s.x+.5)/size.x,1.-(s.y+.5)/size.y);acc+=(uv.x<0.||uv.x>1.||uv.y<0.||uv.y>1.)?vec4(0):texture(tex,uv);}
194
- o=acc/8.;}`,va=`#version 300 es
195
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float w;out vec4 o;
196
- void main(){vec4 c=texture(tex,uv);o=vec4(mix(c.rgb,1.-c.rgb,w),c.a);}`,ha=`#version 300 es
197
- precision highp float;in vec2 uv;uniform sampler2D tex;out vec4 o;void main(){o=texture(tex,uv);}`,Ea=["wipe","blinds","split","iris","diamond","burn"];function Fo(p,g){const w=Math.max(1e-4,p.feather??.05),e=p.progress?Vt(p.progress,g)??0:g,G=(p.angle??0)*Math.PI/180,E=Math.cos(G),N=Math.sin(G),A=Ea.indexOf(p.type??""),Y=p.type==="grid";return{type:"txMask",kind:Y?7:A<0?6:A,e:e*(1+2*w)-w,f:w,inv:!!p.invert,cx:p.cx??.5,cy:p.cy??.5,c:E,s:N,h:.5*(Math.abs(E)+Math.abs(N)),count:p.count??(Y?Sr:8)}}function Ao(p,g,w,e,G=0,E){if(!p)return[];const N=Y=>Vt(p[Y],g)??0,A=[];if(p.zoomBlur&&A.push({type:"txZoom",taps:Rr(),w:N("zoomBlur"),...E?{c:[E.cx,1-E.cy]}:{}}),p.spinBlur){const Y=_r(w,e),re=ae=>Math.max(2,Math.round(ae/2)*2);A.push({type:"txSpin",a:Y.map(ae=>+ae.a.toFixed(6)),sx:Y.map(ae=>re(w*ae.scale)/w),sy:Y.map(ae=>re(e*ae.scale)/e),w:N("spinBlur")})}if(p.dirBlur){const Y=Eo*w/1280,re=Y/(1+Y);A.push({type:"txDir",b:re,reach:Math.min(512,Math.ceil(Math.log(.001)/Math.log(re))),w:N("dirBlur")})}if(p.dirBlurV){const Y=Eo*w/1280,re=Y/(1+Y);A.push({type:"txDir",b:re,reach:Math.min(512,Math.ceil(Math.log(.001)/Math.log(re))),w:N("dirBlurV"),v:!0})}return p.blur&&A.push({type:"txGauss",sigma:Fr*w/1280,w:N("blur")}),p.glitch&&A.push({type:"txGlitch",v:N("glitch"),fr:Math.floor(G*30+.5)}),p.rgbSplit&&A.push({type:"txRgb",px:Math.trunc(N("rgbSplit")*Ar*w/1280+.5)}),p.exposure&&A.push({type:"txExpo",gain:Mr,w:N("exposure")}),p.invert&&A.push({type:"txInv",w:N("invert")}),A}function ba(p,g){const w=new OffscreenCanvas(p,g),e=w.getContext("webgl2",{premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1});if(!e)throw Error("WebGL2 unavailable");const G=(n,s)=>{const o=e.createShader(n);if(e.shaderSource(o,s),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw Error(String(e.getShaderInfoLog(o)));return o},E=(n,s)=>{const o=e.createProgram();if(e.attachShader(o,G(e.VERTEX_SHADER,n)),e.attachShader(o,G(e.FRAGMENT_SHADER,s)),e.bindAttribLocation(o,0,"p"),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw Error(String(e.getProgramInfoLog(o)));return o},N=E(Bi,Ni),A=E($,Qi),Y=E($,Ji),re=E($,Zi),ae=E($,ea),me=E($,ta),de=E($,oa),d=E($,ra),y=E($,ia),_=E($,Li),C=E($,Ii),L=E($,Ci),O=E($,ha),te=E($,zi),oe=E($,aa),z=E($,na),_e=E($,sa),Te=E($,ca),Oe=E($,la),we=E($,fa),Ye=E($,Xi),ze=E($,Oi),ft=E($,Gi),Fe=E($,qi),lt=E($,$i),We=E($,ji),ye=E($,Hi),Ge=E($,Vi),Ke=E($,Yi),Ae=E($,Wi),Le=E($,Ki),rt=E($,ua),J=E($,ma),Ee=E($,pa),ut=E($,va),qe=E($,da),De=E($,xa),it=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,it),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);const $e=n=>s=>e.getUniformLocation(n,s),F=$e(N);e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);const pe=()=>{const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);for(const[s,o]of[[e.TEXTURE_MIN_FILTER,e.LINEAR],[e.TEXTURE_MAG_FILTER,e.LINEAR],[e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE],[e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE]])e.texParameteri(e.TEXTURE_2D,s,o);return n},mt=pe(),wt=pe();let je=null;const at=pe(),pt=e.createTexture(),Ie={l1:"",l3:""};let yt=!1,Xt=!1,ke=null;const Yt={add:1,screen:2,multiply:3,overlay:4,lighten:5,darken:6,difference:7,exclusion:8};let Ce=0;const Rt=pe();let k=[],He=!1,nt=null;const St=n=>{const s=Ve(),o=(n+1)%3,l=(n+2)%3;for(const R of k){let m=n;e.disable(e.BLEND),R.sigma>.05&&(j(_,s[o].fb,[s[n].tex],h=>{e.uniform1i(h("tex"),0),e.uniform2f(h("step"),1/p,0),e.uniform1f(h("sigma"),R.sigma)}),j(_,s[l].fb,[s[o].tex],h=>{e.uniform1i(h("tex"),0),e.uniform2f(h("step"),0,1/g),e.uniform1f(h("sigma"),R.sigma)}),m=l),ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);const[t,c,u]=[1,3,5].map(h=>parseInt(R.color.slice(h,h+2),16)/255);j(A,null,[s[m].tex],h=>{e.uniform1i(h("tex"),0),e.uniform2f(h("off"),Math.trunc(R.dx)/p,-Math.trunc(R.dy)/g),e.uniform3f(h("col"),t,c,u),e.uniform1f(h("op"),R.opacity),e.uniform1f(h("times"),R.times),e.uniform2f(h("dil"),R.dilate?+(ei*255).toFixed(3):0,R.dilate?+(1/ti).toFixed(3):0)})}},Qe=n=>{const s=Ve();if(He){ue(nt.fb),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE),j(de,nt.fb,[s[n].tex],o=>e.uniform1i(o("tex"),0)),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);return}if(k.length&&St(n),Ce){Xe(s[n].tex);return}ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),j(O,null,[s[n].tex],o=>e.uniform1i(o("tex"),0))},Xe=n=>{ue(null),e.bindTexture(e.TEXTURE_2D,Rt),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA8,0,0,p,g,0),e.disable(e.BLEND),j(rt,null,[n,Rt],s=>{e.uniform1i(s("top"),0),e.uniform1i(s("bg"),1),e.uniform1i(s("mode"),Ce)})};let Ue=null;const Ve=()=>Ue??=[Me(),Me(),Me()],Je=new Map,_t=n=>{let s=Je.get(n);if(s)return s;const o=()=>{const l=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,p*n,g*n,0,e.RGBA,e.UNSIGNED_BYTE,null);const R=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,R),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l,0),{tex:l,fb:R}};return s={plane:o(),out:o()},Je.set(n,s),s},Ze=new Map,Ft=new Map,Dt=n=>{let s=Ze.get(n.key);if(s)return s;s=pe();const o=new Uint8Array(256*3);(n.lut??[]).forEach((l,R)=>o.set(l,R*256)),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,256,3,0,e.RED,e.UNSIGNED_BYTE,o),e.pixelStorei(e.UNPACK_ALIGNMENT,4);for(const l of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,l,e.NEAREST);return Ze.set(n.key,s),s},Ot=(n,s)=>{const o=`${n}x${s}`;let l=Ft.get(o);if(l)return l;const R=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);for(const t of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,t,e.NEAREST);const m=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,m),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,R,0),l={tex:R,fb:m},Ft.set(o,l),l},zt=new Map,Wt=(n,s)=>{const o=`${n}x${s}`;let l=zt.get(o);return l||(l=[0,1].map(()=>{const R=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);const m=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,m),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,R,0),{tex:R,fb:m}}),zt.set(o,l),l)},Me=()=>{const n=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,p,g,0,e.RGBA,e.UNSIGNED_BYTE,null);const s=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),{tex:n,fb:s}},ue=n=>{e.bindFramebuffer(e.FRAMEBUFFER,n),e.viewport(0,0,p,g)},j=(n,s,o,l)=>st(n,s,p,g,o,l),st=(n,s,o,l,R,m)=>{e.bindFramebuffer(e.FRAMEBUFFER,s),e.viewport(0,0,o,l),e.useProgram(n);const t=$e(n);R.forEach((c,u)=>{e.activeTexture(e.TEXTURE0+u),e.bindTexture(e.TEXTURE_2D,c)}),m(t),e.drawArrays(e.TRIANGLE_STRIP,0,4),R.length>1&&At(),e.activeTexture(e.TEXTURE0)},At=()=>{e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,wt),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,at),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_3D,pt),e.activeTexture(e.TEXTURE0)},dt=(n,s=0)=>{const o=Ve();let l=s;const R=(t,c,u,h)=>{j(_,o[c].fb,[o[t].tex],i=>{e.uniform1i(i("tex"),0),e.uniform2f(i("step"),1/p,0),e.uniform1f(i("sigma"),h)}),j(_,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform2f(i("step"),0,1/g),e.uniform1f(i("sigma"),h)})},m=(t,c,u,h)=>j(Fe,o[u].fb,[o[t].tex,o[c].tex],i=>{e.uniform1i(i("a"),0),e.uniform1i(i("b"),1),e.uniform1f(i("w"),h)});for(const t of n){const[c,u,h]=[l,(l+1)%3,(l+2)%3];if(t.type==="blur"){t.sigma>.05&&(R(c,u,h,t.sigma),l=h);continue}if(t.type==="colour"){const i=Dt(t);j(Ge,o[u].fb,[o[c].tex,i],v=>{e.uniform1i(v("tex"),0),e.uniform1i(v("lut"),1),e.uniform1f(v("useM"),t.m?1:0),e.uniform1f(v("useL"),t.lut?1:0),t.m&&e.uniform1fv(v("m"),t.m.flatMap(M=>[M[0],M[1],M[2],M[3]??0]))}),l=u;continue}if(t.type==="txRgb"){t.px>0&&(j(Ee,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform1i(i("px"),t.px)}),l=u);continue}if(t.type==="txGlitch"){t.v>1e-4&&(j(qe,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform2f(i("size"),p,g),e.uniform2f(i("msize"),Math.max(2,Math.round(p/4)),Math.max(2,Math.round(g/4))),e.uniform1f(i("v"),t.v),e.uniform1f(i("fr"),t.fr)}),l=u);continue}if(t.type==="txInv"){t.w>1e-4&&(j(ut,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform1f(i("w"),Math.min(1,t.w))}),l=u);continue}if(t.type==="shift"){j(Ke,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform1i(i("px"),t.px)}),l=u;continue}if(t.type==="pixel"){const i=Math.ceil(p/t.block),v=Math.ceil(g/t.block),M=Ot(i,v);e.bindFramebuffer(e.FRAMEBUFFER,M.fb),e.viewport(0,0,i,v),e.useProgram(Ae),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,o[c].tex),e.uniform1i(e.getUniformLocation(Ae,"tex"),0),e.uniform1i(e.getUniformLocation(Ae,"b"),t.block),e.uniform2i(e.getUniformLocation(Ae,"small"),i,v),e.drawArrays(e.TRIANGLE_STRIP,0,4),j(Le,o[u].fb,[M.tex],Q=>{e.uniform1i(Q("small"),0),e.uniform1i(Q("b"),t.block),e.uniform2f(Q("size"),p,g)}),l=u;continue}if(t.type==="txMask"){j(ye,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform2f(i("size"),p,g),e.uniform1i(i("kind"),t.kind),e.uniform1f(i("e"),t.e),e.uniform1f(i("f"),t.f),e.uniform1f(i("inv"),t.inv?1:0),e.uniform2f(i("ctr"),t.cx,t.cy),e.uniform3f(i("csh"),t.c,t.s,t.h),e.uniform1f(i("count"),t.count)}),l=u;continue}if(t.type==="txGauss"||t.type==="txDir"||t.type==="txZoom"||t.type==="txSpin"||t.type==="txExpo"){if(!(t.w>1e-4))continue;let i=u;t.type==="txGauss"?(R(c,u,h,t.sigma),i=h):t.type==="txDir"?j(Ye,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),t.v?e.uniform2f(M("step"),0,1/g):e.uniform2f(M("step"),1/p,0),e.uniform1f(M("b"),t.b),e.uniform1i(M("reach"),t.reach)}):t.type==="txZoom"?j(ze,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),e.uniform1fv(M("taps"),t.taps),e.uniform1i(M("n"),t.taps.length),e.uniform2f(M("ctr"),t.c?.[0]??.5,t.c?.[1]??.5)}):t.type==="txSpin"?j(De,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),e.uniform2f(M("size"),p,g),e.uniform1fv(M("a"),t.a),e.uniform1fv(M("sx"),t.sx),e.uniform1fv(M("sy"),t.sy)}):j(ft,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),e.uniform1f(M("gain"),t.gain)});const v=i===h?u:h;m(c,i,v,Math.min(1,t.w)),l=v;continue}if(t.type==="burst"){const{w:i,h:v}=di(p,g),[M,Q]=Wt(i,v),K=ui(mi.burst*t.amount).map(V=>pi(i,v,V));j(C,o[u].fb,[o[c].tex],V=>{e.uniform1i(V("tex"),0),e.uniform1f(V("lo"),t.lo),e.uniform1f(V("k"),t.k)}),st(O,M.fb,i,v,[o[u].tex],V=>e.uniform1i(V("tex"),0)),st(te,Q.fb,i,v,[M.tex],V=>{e.uniform1i(V("tex"),0),e.uniform1i(V("n"),K.length),e.uniform1fv(V("sx"),K.map(be=>be.sw/i)),e.uniform1fv(V("sy"),K.map(be=>be.sh/v)),e.uniform3f(V("gain"),...vi(t.amount))}),j(L,o[h].fb,[o[c].tex,Q.tex],V=>{e.uniform1i(V("a"),0),e.uniform1i(V("b"),1),e.uniform1f(V("amount"),+t.amount.toFixed(4))}),l=h;continue}j(C,o[u].fb,[o[c].tex],i=>{e.uniform1i(i("tex"),0),e.uniform1f(i("lo"),t.lo),e.uniform1f(i("k"),t.k)}),R(u,h,u,t.sigma),j(L,o[h].fb,[o[c].tex,o[u].tex],i=>{e.uniform1i(i("a"),0),e.uniform1i(i("b"),1),e.uniform1f(i("amount"),t.amount)}),l=h}return l};let ct=null,r="",f=[],U="";const x=(n,s)=>{if(U!==`${n}x${s}`){for(const o of f)e.deleteTexture(o.tex),e.deleteFramebuffer(o.fb);f=Array.from({length:4},()=>{const o=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);const l=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),{tex:o,fb:l}}),U=`${n}x${s}`}return f},T=(n,s,o,l)=>{const R=e.getParameter(e.FRAMEBUFFER_BINDING),m=e.getParameter(e.VIEWPORT),t=e.isEnabled(e.BLEND),c=x(l.ew,l.eh),u=(i,v,M,Q)=>{e.bindFramebuffer(e.FRAMEBUFFER,c[v].fb),e.viewport(0,0,l.ew,l.eh),e.useProgram(i);const K=$e(i);M.forEach((V,be)=>{e.activeTexture(e.TEXTURE0+be),e.bindTexture(e.TEXTURE_2D,c[V].tex)}),Q(K),e.drawArrays(e.TRIANGLE_STRIP,0,4),M.length>1&&At(),e.activeTexture(e.TEXTURE0)};e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,c[0].fb),e.viewport(0,0,l.ew,l.eh),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT);{const i=kt(n,o);e.bindFramebuffer(e.FRAMEBUFFER,c[0].fb),e.viewport(0,0,l.ew,l.eh),e.disable(e.BLEND),vt(n,[0,0,1,1],s,1,1,!1,i==="win"?null:o,i)}u(Y,1,[0],i=>{e.uniform1i(i("tex"),0),e.uniform1f(i("harden"),l.harden?Qr:0)});const h=(i,v,M,Q)=>{u(re,v,[i],K=>{e.uniform1i(K("tex"),0),e.uniform2i(K("dir"),1,0),e.uniform1f(K("sigma"),Q)}),u(re,M,[v],K=>{e.uniform1i(K("tex"),0),e.uniform2i(K("dir"),0,1),e.uniform1f(K("sigma"),Q)})};h(1,2,3,l.band),u(ae,2,[1,3],i=>{e.uniform1i(i("a"),0),e.uniform1i(i("b"),1);const v=l.arc;e.uniform1f(i("arc"),v?1:0),v&&(e.uniform2f(i("cw"),l.ew/to,l.eh/to),e.uniform2f(i("cen"),v.cen[0],v.cen[1]),e.uniform1f(i("start"),v.start),e.uniform1f(i("cover"),v.cover),e.uniform1f(i("comet"),v.comet?1:0),e.uniform1f(i("feather"),Jr*v.cover))}),h(2,1,3,l.glow),u(me,1,[0,2,3],i=>{e.uniform1i(i("pic"),0),e.uniform1i(i("band"),1),e.uniform1i(i("glow"),2),e.uniform3f(i("col"),...l.col),e.uniform1f(i("k"),l.k),e.uniform1f(i("am"),l.am)}),e.bindFramebuffer(e.FRAMEBUFFER,R),e.viewport(m[0],m[1],m[2],m[3]),t&&e.enable(e.BLEND)};let X=null,P="",ce=null,W=[],Z="";const a=new Map,S=new Map,fe=new Map,ve=new Map,ne=new Map,Re=new Map,se=pe(),B=(n,s)=>{const o=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);const l=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),{tex:o,fb:l}},Pe=(n,s,o)=>{const l=e.getParameter(e.FRAMEBUFFER_BINDING),R=e.getParameter(e.VIEWPORT),m=e.isEnabled(e.BLEND),t=n.w,c=n.h;if(Z!==`${t}x${c}`){for(const H of W)e.deleteTexture(H.tex),e.deleteFramebuffer(H.fb);W=Array.from({length:7},()=>B(t,c)),Z=`${t}x${c}`}e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,W[0].fb),e.viewport(0,0,t,c),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),vt(n,[0,1,1,-1],[0,0,1,1],1,1,!1,s,"base");let u=0;const h=H=>[H[0],H[3],H[6],H[1],H[4],H[7],H[2],H[5],H[8]],i=(H,q,ht,et)=>{e.bindFramebuffer(e.FRAMEBUFFER,W[q].fb),e.viewport(0,0,t,c),e.useProgram(H);const Be=$e(H);ht.forEach((Et,bt)=>{e.activeTexture(e.TEXTURE0+bt),e.bindTexture(Et.d3?e.TEXTURE_3D:e.TEXTURE_2D,Et.t)}),et(Be),e.drawArrays(e.TRIANGLE_STRIP,0,4),At()},v=H=>({t:W[H].tex}),M=(H,q,ht,et)=>{i(_,q,[v(H)],Be=>{e.uniform1i(Be("tex"),0),e.uniform2f(Be("step"),1/t,0),e.uniform1f(Be("sigma"),et)}),i(_,ht,[v(q)],Be=>{e.uniform1i(Be("tex"),0),e.uniform2f(Be("step"),0,1/c),e.uniform1f(Be("sigma"),et)})},Q=o.list,K=Q.map(H=>eo(H)),V=Ir(Q),be=new Set;for(const[H,q]of Q.entries()){const ht=V[H];if(H===ht&&Q.some((b,D)=>D>H&&V[D]===H&&K[D])&&(i(O,2,[v(u)],b=>e.uniform1i(b("tex"),0)),be.add(H)),!K[H])continue;const et=H!==ht&&be.has(ht)?q.branch:void 0,Be=et?2:u;let Et=se,bt=[1,1];if(q.qualifier){const b=Math.max(2,Math.trunc((t+Mt-1)/Mt)),D=Math.max(2,Math.trunc((c+Mt-1)/Mt)),I=`${b}x${D}`;let ie=a.get(I);ie||(ie=B(b,D),a.set(I,ie));const ee=q.qualifier,xe=Math.max(.001,ee.soft??.3),Se=q.window,Tt=-(Se?.rot??0)*Math.PI/180;e.bindFramebuffer(e.FRAMEBUFFER,ie.fb),e.viewport(0,0,b,D),e.useProgram(y),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,W[Be].tex);const ge=$e(y);e.uniform1i(ge("tex"),0),e.uniform2f(ge("big"),t,c),e.uniform2f(ge("small"),b,D),e.uniform4f(ge("q1"),ee.hue,ee.hueWidth,Math.max(1,xe*60),Math.max(.001,xe*.2)),e.uniform4f(ge("q2"),ee.satMin,ee.satMax,ee.lumMin,ee.lumMax),e.uniform1f(ge("useQ"),1),e.uniform1f(ge("useW"),Se?1:0),Se&&(e.uniform4f(ge("w1"),Se.cx,Se.cy,Math.max(1e-4,Se.w/2),Math.max(.001,Se.feather??.2)),e.uniform4f(ge("w2"),Math.cos(Tt),Math.sin(Tt),Math.max(1e-4,Se.h/2),Se.type==="gradient"?2:Se.type==="rect"?1:0)),e.uniform1f(ge("inv"),q.invert?1:0),e.drawArrays(e.TRIANGLE_STRIP,0,4),Et=ie.tex,bt=[b*Mt,D*Mt]}else if(!q.whole&&Cr(q)&&q.window?.type!=="person"){const b=`${o.clip}#${H}`,D=`${t}x${c}@${o.local??0}`,I=go,ie=Math.max(2,Math.min(go*2,Math.round(I*c/t)));let ee=ve.get(b);if(ee||(ee={tex:pe(),at:""},ve.set(b,ee)),ee.at!==D){const xe=bo(q,o.src,o.local??0,c/t,null),Se=new Uint8Array(I*ie);for(let Tt=0;Tt<ie;Tt++)for(let ge=0;ge<I;ge++)Se[Tt*I+ge]=Math.round(xe((ge+.5)/I,(Tt+.5)/ie,0,0,0)*255);e.bindTexture(e.TEXTURE_2D,ee.tex),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,I,ie,0,e.RED,e.UNSIGNED_BYTE,Se),e.pixelStorei(e.UNPACK_ALIGNMENT,4),ee.at=D}Et=ee.tex,bt=[t,c]}else if(!q.whole){const b=To(q)?o.src?.depthMap:void 0,D=`${o.clip}#${H}@${t}x${c}${b?`@${b.at}:${b.data.length}:${b.data.slice(0,24)}`:""}`;let I=S.get(D);if(!I){const ie=Xr(q,t,c,To(q)?bo(q,o.src,0,c/t):null);I=pe(),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,ie.w4,ie.h4,0,e.RED,e.UNSIGNED_BYTE,ie.px),e.pixelStorei(e.UNPACK_ALIGNMENT,4),S.set(D,I)}Et=I,bt=[t,c]}const Ut=q.adjust??{},no=Or(q),Kt=`${o.clip}#${H}`;let Gt=fe.get(Kt);if(no&&!Gt){const b=new Float32Array(1024);for(let D=0;D<256;D++)["r","g","b"].forEach((I,ie)=>{b[D*4+ie]=+zr(Ut,I,D/255,q.wheels,q.curves).toFixed(6)}),b[D*4+3]=1;Gt=pe(),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,256,1,0,e.RGBA,e.FLOAT,b);for(const D of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,D,e.NEAREST);fe.set(Kt,Gt)}let gt=null;if(Gr(q)){const b=`${Kt}:${JSON.stringify([q.cst,q.look,q.lut,q.mixer])}`;if(gt=ne.get(b)??null,!gt){const D=qr(q,I=>xi(I));if(!D)throw Error(`LUT "${q.lut?.name??""}" chưa tải xong`);gt=e.createTexture(),e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_3D,gt),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage3D(e.TEXTURE_3D,0,e.RGB32F,D.size,D.size,D.size,0,e.RGB,e.FLOAT,D.data),e.pixelStorei(e.UNPACK_ALIGNMENT,4);for(const I of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_3D,I,e.NEAREST);for(const I of[e.TEXTURE_WRAP_S,e.TEXTURE_WRAP_T,e.TEXTURE_WRAP_R])e.texParameteri(e.TEXTURE_3D,I,e.CLAMP_TO_EDGE);e.activeTexture(e.TEXTURE0),ne.set(b,gt)}}const{sat:No,rot:Lo}=$r(Ut.saturation??1,Ut.hue??0);i(oe,3,[v(Be),{t:Gt??at},{t:gt??pt,d3:!0}],b=>{e.uniform1i(b("tex"),0),e.uniform1i(b("lut"),1),e.uniform1i(b("t3"),2),e.uniform1f(b("useT"),gt?1:0),e.uniform1f(b("useL"),no?1:0),e.uniform1f(b("useS"),(Ut.saturation??1)!==1?1:0),e.uniform1f(b("useR"),(Ut.hue??0)!==0?1:0),e.uniformMatrix3fv(b("sat"),!1,h(No)),e.uniformMatrix3fv(b("rot"),!1,h(Lo))}),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_3D,null),e.activeTexture(e.TEXTURE0),At();let le=3;const tt=(b,D)=>[3,4,5].find(I=>I!==b&&I!==D);if((q.blur??0)>0){const b=tt(le),D=tt(le,b);M(le,b,D,Math.max(.1,+((q.blur??0)*jr*t).toFixed(3))),le=D}const so=Hr({sharpness:q.sharpen??0});if(so){const b=tt(le);i(_e,b,[v(le)],D=>{e.uniform1i(D("tex"),0),e.uniform1fv(D("k"),so),e.uniform1f(D("rdiv"),1/Zr)}),le=b}const he=q.fx?Vr(q.fx,t):null;if(he&&(he.type==="glow"||he.type==="halation")){const b=tt(le),D=tt(le,b);i(C,b,[v(le)],xe=>{e.uniform1i(xe("tex"),0),e.uniform1f(xe("lo"),he.lo),e.uniform1f(xe("k"),he.k)});let I=b;he.tint&&(i(Ge,D,[v(b),{t:at}],xe=>{e.uniform1i(xe("tex"),0),e.uniform1i(xe("lut"),1),e.uniform1f(xe("useM"),1),e.uniform1f(xe("useL"),0),e.uniform1fv(xe("m"),he.tint.flat())}),I=D),M(I,I===b?D:b,I,he.sigma);const ee=6;i(L,ee,[v(le),v(I)],xe=>{e.uniform1i(xe("a"),0),e.uniform1i(xe("b"),1),e.uniform1f(xe("amount"),he.amount)}),i(O,3,[v(ee)],xe=>e.uniform1i(xe("tex"),0)),le=3}else if(he?.type==="grain"){const b=Yr(o.frame??0),D=`${b}:${t}x${c}:${he.amp}`;let I=Re.get(D);if(!I){if(Re.size>8){for(const ee of Re.values())e.deleteTexture(ee);Re.clear()}I=pe(),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,t,c,0,e.RED,e.UNSIGNED_BYTE,Wr(b,t,c,he.amp)),e.pixelStorei(e.UNPACK_ALIGNMENT,4),Re.set(D,I)}const ie=tt(le);i(Te,ie,[v(le),{t:I}],ee=>{e.uniform1i(ee("tex"),0),e.uniform1i(ee("grain"),1)}),le=ie}else if(he?.type==="denoise"){const b=tt(le),D=tt(le,b);M(le,b,D,he.sigma),i(Oe,6,[v(le),v(D)],I=>{e.uniform1i(I("tex"),0),e.uniform1i(I("soft"),1),e.uniform1f(I("t"),he.t)}),i(O,3,[v(6)],I=>e.uniform1i(I("tex"),0)),le=3}else if(he?.type==="swirl"){const b=D=>Math.max(2,Math.round(D/2)*2);for(const D of Kr(t,c,he.deg)){const I=tt(le);i(De,I,[v(le)],ie=>{e.uniform1i(ie("tex"),0),e.uniform2f(ie("size"),t,c),e.uniform1fv(ie("a"),D.map(ee=>+ee.a.toFixed(6))),e.uniform1fv(ie("sx"),D.map(ee=>b(t*ee.scale)/t)),e.uniform1fv(ie("sy"),D.map(ee=>b(c*ee.scale)/c))}),le=I}}const Io=et==="parallel"?2:u,Co=et==="parallel"?6:1-u;i(z,Co,[v(Io),v(le),{t:Et}],b=>{e.uniform1i(b("base"),0),e.uniform1i(b("over"),1),e.uniform1i(b("mask"),2),e.uniform2f(b("msz"),bt[0],bt[1]),e.uniform1f(b("full"),q.whole?1:0)}),et==="parallel"&&i(we,1-u,[v(u),v(6),v(2)],b=>{e.uniform1i(b("res"),0),e.uniform1i(b("outp"),1),e.uniform1i(b("inp"),2)}),u=1-u}ce=W[u].tex,e.bindFramebuffer(e.FRAMEBUFFER,l),e.viewport(R[0],R[1],R[2],R[3]),m&&e.enable(e.BLEND)},kt=(n,s)=>X?(P!==X.key&&(Pe(n,s,X),P=X.key),"win"):"pic",xt=(n,s,o,l,R,m,t)=>{if(!ct){const M=kt(n,t);vt(n,s,o,l,R,m,M==="win"?null:t,M);return}const c=je??[0,0,1,1];r!==ct.key&&(T(n,c,t,ct),r=ct.key);const u=(o[0]-c[0])/c[2],h=(o[1]-c[1])/c[3],i=o[2]/c[2],v=o[3]/c[3];vt(n,s,[u,1-h,i,-v],l,R,m,null,"edge")},vt=(n,s,o,l,R,m,t,c)=>{const u=c==="edge"||c==="win",h=c==="pic"||c==="base";if(e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,mt),h&&e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.source),e.uniform4f(F("dst"),s[0],s[1],s[2],s[3]),e.uniform4f(F("src"),o[0],o[1],o[2],o[3]),e.uniform1f(F("alpha"),l),e.uniform1f(F("fade"),R),e.uniform1f(F("white"),m?1:0),e.uniform1f(F("colour"),t?1:0),e.uniform1i(F("tex"),0),e.uniform1i(F("matte"),1),e.uniform1f(F("useMatte"),je&&(c==="pic"||c==="win")?1:0),ke&&!u?(e.uniform4f(F("key"),ke.u,ke.v,ke.similarity,ke.blend),e.uniform4f(F("keyOpt"),1,ke.blue?1:0,ke.spill,n.bt709?1:0)):e.uniform4f(F("keyOpt"),0,0,0,0),e.uniform1i(F("lut1"),2),e.uniform1i(F("lut3"),3),e.uniform1f(F("useL1"),yt&&!u?1:0),e.uniform1f(F("useL3"),Xt&&!u?1:0),je&&e.uniform4f(F("mrect"),je[0],je[1],je[2],je[3]),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,wt),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,at),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_3D,pt),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,c==="edge"?f[1].tex:c==="win"?ce:mt),t){const i=v=>[v[0],v[3],v[6],v[1],v[4],v[7],v[2],v[5],v[8]];e.uniform1f(F("bright"),t.bright),e.uniform1f(F("contrast"),t.contrast),e.uniformMatrix3fv(F("sat"),!1,i(t.sat)),e.uniformMatrix3fv(F("rot"),!1,i(t.rot))}e.drawArrays(e.TRIANGLE_STRIP,0,4)};return{canvas:w,clear(n=1){ue(null),e.clearColor(0,0,0,n),e.clear(e.COLOR_BUFFER_BIT)},pixels(){ue(null);const n=new Uint8ClampedArray(p*g*4),s=p*4,o=new Uint8ClampedArray(p*g*4);e.readPixels(0,0,p,g,e.RGBA,e.UNSIGNED_BYTE,n);for(let l=0;l<g;l++){const R=(g-1-l)*s,m=l*s;for(let t=0;t<s;t+=4){const c=n[R+t+3];if(o[m+t+3]=c,c){const u=255/c;o[m+t]=n[R+t]*u,o[m+t+1]=n[R+t+1]*u,o[m+t+2]=n[R+t+2]*u}}}return o},draw(n,s,o,l,R,m,t=null,c=[],u=null){if(!c.length&&!Ce&&!k.length&&!He){ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),xt(n,s,o,l,R,m,t);return}Ue??=[Me(),Me(),Me()],ue(Ue[0].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),xt(n,u??s,o,l,R,m,t);const h=dt(c);if(ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),Ce||k.length||He){let i=h;u&&(i=(h+1)%3,ue(Ue[i].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Ue[h].tex),e.uniform4f(F("dst"),s[0],s[1],s[2],s[3]),e.uniform4f(F("src"),0,1,1,-1),e.uniform1f(F("alpha"),1),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("colour"),0),e.uniform1f(F("useMatte"),0),e.drawArrays(e.TRIANGLE_STRIP,0,4)),Qe(i);return}if(!u){j(O,null,[Ue[h].tex],i=>e.uniform1i(i("tex"),0));return}e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Ue[h].tex),e.uniform4f(F("dst"),s[0],s[1],s[2],s[3]),e.uniform4f(F("src"),0,1,1,-1),e.uniform1f(F("alpha"),1),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("colour"),0),e.uniform1f(F("useMatte"),0),e.drawArrays(e.TRIANGLE_STRIP,0,4)},warp(n,s,o,l,R,m,t,c,u,h=null,i=null,v=[]){const M=Ve();ue(M[0].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),xt(n,s,o,l,R,m,t);const Q=dt(c),K=Ce||k.length||He||v.length?(Q+1)%3:-1;K>=0?(ue(M[K].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)):(ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)),i&&(e.enable(e.SCISSOR_TEST),e.scissor(i[0],g-i[1]-i[3],i[2],i[3])),j(We,K>=0?M[K].fb:null,[M[Q].tex],V=>{e.uniform1i(V("tex"),0),e.uniform2f(V("size"),p,g),e.uniform1f(V("keepPre"),0),e.uniformMatrix3fv(V("inv"),!1,[u[0],u[3],u[6],u[1],u[4],u[7],u[2],u[5],u[8]]),e.uniform4f(V("rnd"),h?.[0]??0,h?.[1]??0,h?.[2]??0,h?1:0)}),e.disable(e.SCISSOR_TEST),K>=0&&Qe(v.length?dt(v,K):K)},adjust(n,s,o){const l=Ve();if(ue(null),e.bindTexture(e.TEXTURE_2D,Rt),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA8,0,0,p,g,0),ue(l[0].fb),e.disable(e.BLEND),e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Rt),e.uniform4f(F("dst"),0,0,1,1),e.uniform4f(F("src"),0,1,1,-1),e.uniform1i(F("tex"),0),e.uniform1f(F("alpha"),1),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("useMatte"),0),e.uniform1f(F("colour"),n?1:0),n){const m=t=>[t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]];e.uniform1f(F("bright"),n.bright),e.uniform1f(F("contrast"),n.contrast),e.uniformMatrix3fv(F("sat"),!1,m(n.sat)),e.uniformMatrix3fv(F("rot"),!1,m(n.rot))}e.drawArrays(e.TRIANGLE_STRIP,0,4);const R=dt(s);ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,l[R].tex),e.uniform4f(F("dst"),0,0,1,1),e.uniform4f(F("src"),0,1,1,-1),e.uniform1f(F("alpha"),o),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("colour"),0),e.uniform1f(F("useMatte"),0),e.drawArrays(e.TRIANGLE_STRIP,0,4)},grade(n,s){if(yt=!!n,Xt=!!s,n&&Ie.l1!==n.key){const o=new Float32Array(1024);for(let l=0;l<256;l++)o[l*4]=n.r[l],o[l*4+1]=n.g[l],o[l*4+2]=n.b[l],o[l*4+3]=1;e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,at),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,256,1,0,e.RGBA,e.FLOAT,o);for(const l of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,l,e.NEAREST);e.activeTexture(e.TEXTURE0),Ie.l1=n.key}if(s&&Ie.l3!==s.key){e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_3D,pt),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage3D(e.TEXTURE_3D,0,e.RGB32F,s.size,s.size,s.size,0,e.RGB,e.FLOAT,s.data),e.pixelStorei(e.UNPACK_ALIGNMENT,4);for(const o of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_3D,o,e.NEAREST);for(const o of[e.TEXTURE_WRAP_S,e.TEXTURE_WRAP_T,e.TEXTURE_WRAP_R])e.texParameteri(e.TEXTURE_3D,o,e.CLAMP_TO_EDGE);e.activeTexture(e.TEXTURE0),Ie.l3=s.key}},key(n){if(!n){ke=null;return}const[s,o,l]=[1,3,5].map(m=>parseInt(n.color.slice(m,m+2),16)),R=224/255;ke={u:Math.round(-.168736*R*s-.331264*R*o+.5*R*l+128),v:Math.round(.5*R*s-.418688*R*o-.081312*R*l+128),similarity:n.similarity,blend:n.blend,spill:+n.spill.toFixed(3),blue:l>o}},mode(n){Ce=n&&Yt[n]||0},shadow(n){k=n},blurBegin(){nt??=Me(),ue(nt.fb),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),He=!0},blurEnd(){He=!1;const n=Ve();e.disable(e.BLEND),j(d,n[0].fb,[nt.tex],s=>e.uniform1i(s("tex"),0)),Qe(0)},windows(n){X=n},edge(n){ct=n},warpBig(n,s,o,l,R,m,t,c,u,h=[]){const i=_t(u),v=p*u,M=g*u;e.bindFramebuffer(e.FRAMEBUFFER,i.plane.fb),e.viewport(0,0,v,M),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),xt(n,s,o,l,R,m,t);const Q=It(c.map(([be,H])=>[be*u,H*u]),v,M);e.bindFramebuffer(e.FRAMEBUFFER,i.out.fb),e.viewport(0,0,v,M),e.useProgram(We),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i.plane.tex);const K=$e(We);if(e.uniform1i(K("tex"),0),e.uniform2f(K("size"),v,M),e.uniform1f(K("keepPre"),1),e.uniform4f(K("rnd"),0,0,0,0),e.uniformMatrix3fv(K("inv"),!1,[Q[0],Q[3],Q[6],Q[1],Q[4],Q[7],Q[2],Q[5],Q[8]]),e.drawArrays(e.TRIANGLE_STRIP,0,4),ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),!h.length&&!Ce&&!k.length&&!He){j(J,null,[i.out.tex],be=>{e.uniform1i(be("tex"),0),e.uniform1i(be("ss"),u)});return}const V=Ve();e.disable(e.BLEND),j(J,V[0].fb,[i.out.tex],be=>{e.uniform1i(be("tex"),0),e.uniform1i(be("ss"),u)}),Qe(dt(h,0))},matte(n,s=[0,0,1,1]){je=n?s:null,n&&(e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,wt),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),e.activeTexture(e.TEXTURE0))},overlay(n,s){ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),s&&(e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,mt),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,s.w,s.h,0,e.RGBA,e.UNSIGNED_BYTE,s.data)),j(lt,null,s?[mt]:[],o=>{e.uniform1i(o("tex"),0),e.uniform1f(o("usetex"),s?1:0),e.uniform4f(o("colour"),...n??[0,0,0,0])})},finish(){e.finish()}}}let Ne="";const La=()=>Ne;async function ga(p,{format:g,encode:w=null,tracks:e={},camera:G=null,signal:E,onProgress:N,frames:A,software:Y=!1,liveMotion:re=!1,range:ae,only:me,sink:de}){const d=performance.now(),{width:y,height:_,fps:C}=oo(g);Ne="layers",await Promise.all([...new Set(p.filter(r=>!r.colorBypass).flatMap(r=>qt(r.grade).map(f=>f?.lut?.id)).filter(r=>!!r))].map(r=>li(r))),Xo(co(p.filter(r=>!r.disabled)));const L=p.filter(r=>!r.disabled&&!Mo(r)),O=co(L),te=Oo(L.reduce((r,f)=>Math.max(r,f.start+f.duration),0)),oe=Math.round(te*C);if(!(oe>0)&&!A)throw Error("Empty timeline");const z=zo(G)?G:null,_e=Go(O,e,z?r=>Nr(r,z,y,_):void 0),Te=r=>_e.find(f=>r>=f.start-1e-6&&r<f.start+f.duration-1e-6)??null,Oe=()=>{if(E?.aborted)throw new DOMException("Export cancelled","AbortError")},we=r=>re&&!A&&!!r.motion&&!r._virtual&&!r.warped,Ye=r=>A||me!=="audio"&&(!ae||r.start<ae.to/C+1e-6&&r.start+r.duration>ae.from/C-1e-6),ze=new Pi,ft=[...L.filter(r=>Ht(r)&&!we(r)),...qo(L)].filter(Ye);ft.length&&await(await Pt(async()=>{const{renderTitleFrames:r}=await import("./titleFrames-BI1DnLBn.js");return{renderTitleFrames:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]))).renderTitleFrames(ft,g,ze,E);const Fe=new Map;if(L.some(r=>we(r)&&Ye(r))){const r=await Pt(()=>import("./titleFrames-BI1DnLBn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const f of L.filter(U=>we(U)&&Ye(U)))Fe.set(f.id,r.liveMotion(f,L,g))}L.some(r=>r.kind==="model")&&await(await Pt(async()=>{const{render3DFrames:r}=await import("./timeline3dExport-BtYLU1pw.js");return{render3DFrames:r}},__vite__mapDeps([8,1,9,10,11,6,12,7]))).render3DFrames(p.filter(r=>!r.disabled),g,ze,E,G);for(const r of O.filter(f=>f._group&&f.comp)){const f=[],U=Math.max(1,Math.ceil(r.duration*C-1e-6));await ga(ri(ii(r),{W:y,H:_}),{format:g,signal:E,frames:{times:Array.from({length:U},(x,T)=>oi(r,T/C)),push:(x,T)=>{f[x]=T}}}),ze.frames.set(r.id,f)}const lt=performance.now();Oe(),Ne="mattes";const We=L.filter(r=>r.mask||r.person),ye=We.length?await Pt(()=>import("./rotoMatte-C-2o3vv0.js").then(r=>r.r),__vite__mapDeps([13,1,6,14])):null;ye&&await ye.prepareMattes(We);const Ge=ye?document.createElement("canvas"):null;Ne="media";const Ke=new Map,Ae=new Map,Le=new Map,rt=r=>{let f=Ke.get(r);return f||(f=new gi({source:new wi(r,{getRetryDelay:Po}),formats:Ti}),Ke.set(r,f)),f};for(const r of L){if(r.kind==="video"&&!Ae.has(r.url)){const f=await rt(r.url).getPrimaryVideoTrack();f&&Ae.set(r.url,new Ei(f))}if(r.kind==="image"&&!Ht(r)&&!Zt(r)&&!r._group&&!Le.has(r.url)){const f=await createImageBitmap(await Ui(r.url,E),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"});Le.set(r.url,{source:f,w:f.width,h:f.height,close:()=>f.close()})}}const J=new Map,Ee=async(r,f)=>{const U=Fe.get(r.id);if(U)return{source:await U.frame(Math.round((f-r.start)*C)),w:U.W,h:U.H};const x=ze.frames.get(r.id);if(!x?.length)return null;let T=x.length===1?0:Math.max(0,Math.min(Math.round((f-r.start)*C),Math.ceil(r.duration*C)-1,x.length-1));for(;T>0&&x[T]==="=";)T--;const X=J.get(r.id);if(X&&X.index===T)return X.pic;X?.pic?.close?.();const P=await createImageBitmap(await(await fetch(`data:image/webp;base64,${x[T]}`)).blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"}),ce={source:P,w:P.width,h:P.height,close:()=>P.close()};return J.set(r.id,{index:T,pic:ce}),ce},ut=L.filter(r=>$o(r)),qe=ut.length?await Pt(()=>import("./captionLayout-DvDPTwO9.js"),__vite__mapDeps([15,1])):null,De=new Map,it=new Map;if(qe){for(const r of new Set(ut.flatMap(f=>[Qt(jo(f.captionStyle).font),Qt(fo(f.captionStyle).font)])))if(await qe.captionFontReady(r.id),!De.has(r.id)){const f=new Uint8Array(await(await fetch(`/fonts/${r.file}`,{signal:E})).arrayBuffer());let U="";for(let x=0;x<f.length;x+=32768)U+=String.fromCharCode(...f.subarray(x,x+32768));De.set(r.id,`@font-face{font-family:'${r.family}';src:url(data:font/${r.file.endsWith(".otf")?"otf":"ttf"};base64,${btoa(U)})}`)}}const $e=new Map,F=async(r,f,U)=>{let x=$e.get(f.start);if(!x||x.owner!==r){const S=fr(r,f.start,f.duration);x={plan:S,starts:lr(S.entries,C),owner:r},$e.clear(),$e.set(f.start,x)}const T=U-Math.round(f.start*C);let X=-1;for(let S=0;S<x.starts.length&&x.starts[S]<=T;S++)X=S;const P=x.plan.entries[X];if(!P||P.blank)return null;const ce=x.plan.social?x.plan.social.style:fo(r.captionStyle),W=x.plan.social?ur(x.plan.social,P.gi,y,_,qe.measureCaption):mr({width:y,height:_,text:P.text,style:ce,measure:qe.measureCaption,second:P.second}),Z=pr(W,ce,x.plan.social?P.scale:1,y,_,P.active,P.motion);let a=it.get(Z);if(!a){const S=Qt(ce.font),fe=URL.createObjectURL(new Blob([Z.replace("<defs>",`<defs><style>${De.get(S.id)??""}</style>`)],{type:"image/svg+xml"}));try{const ve=new Image(y,_);ve.src=fe,await ve.decode();const ne=await createImageBitmap(ve,{premultiplyAlpha:"none"});a={source:ne,w:y,h:_,close:()=>ne.close()}}finally{URL.revokeObjectURL(fe)}if(it.size>64){const[ve,ne]=it.entries().next().value;ne.close?.(),it.delete(ve)}it.set(Z,a)}return a},pe=[0,0,1,1],mt=new Map,wt=["x","y","zoom","rot","sx","sy"],je=(r,f,U,x)=>{const T=`${r.id}@${f.start}`;let X=mt.get(T);if(!X){const ce=Math.max(1,Math.ceil(f.duration/.1-1e-6)),W=Array.from({length:ce+1},(S,fe)=>f.start+f.duration*fe/ce),Z=W.map(S=>Jt(r,S-r.start,y,_)),a=S=>+(+S).toFixed(3);X={ts:W.map(S=>+S.toFixed(5)),v:Object.fromEntries(wt.map(S=>[S,Z.map(fe=>a(fe[S]??(S==="sx"||S==="sy"?1:0)))]))},mt.set(T,X)}const P={...x};for(const ce of wt){const W=X.v[ce];if(W.every(fe=>fe===W[0])){P[ce]=W[0];continue}let Z=X.ts.findIndex((fe,ve)=>ve<X.ts.length-1&&U<X.ts[ve+1]);Z<0&&(Z=X.ts.length-2);const a=+(W[Z+1]-W[Z]).toFixed(3),S=X.ts[Z+1]-X.ts[Z];P[ce]=Math.abs(W[Z+1]-W[Z])<1e-4?W[Z]:W[Z]+a*Math.max(0,Math.min(1,(U-X.ts[Z])/S))}return P},at=new Map,pt=new Map,Ie=(r,f,U,x=r,T="")=>{if(!dr(x))return yo(x,y);const X=`${r.id}${T}@${f.start}`;let P=pt.get(X);P||(P=xr(x,{offset:f.start-r.start,duration:f.duration,fps:C}),pt.set(X,P));const ce=U-Math.round(f.start*C),W=P.find(Z=>ce>=Z.from&&ce<Z.to)??P[P.length-1];return yo({effects:vr(x,W.t)},y)},yt=new Map,Xt=(r,f,U)=>{const x=`${r.id}@${f.start}`;yt.has(x)||yt.set(x,z?Dr(r,z,f.start,f.duration,y,_):null);const T=yt.get(x);return T?Ie(r,f,U,T,":dof"):[]},ke=new Map,Yt=r=>{const f=JSON.stringify(r.grade);let U=ke.get(f);if(!U){const x=P=>Array.from(P,ce=>+ce.toFixed(6)),T=gr(r.grade)?Tr(r.grade):null,X=r.grade.mixer&&wr(r.grade.mixer)?yr(r.grade.mixer):null;U={l1:T?{key:`1${f}`,r:x(T.r),g:x(T.g),b:x(T.b)}:null,l3:X?{key:`3${f}`,size:X.size,data:Float32Array.from(X.data,P=>+P.toFixed(6))}:null},ke.set(f,U)}return U};let Ce=null;const Rt=async(r,f,U)=>{const x=L.find(P=>P.id===r);if(!x||f<x.start||f>=x.start+x.duration)return null;if(Ht(x)){const P=await Ee(x,f);return P&&{source:P.source,w:P.w,h:P.h}}if(x.kind==="image"){const P=Le.get(x.url);return P?{source:P.source,w:P.w,h:P.h}:null}if(x.kind!=="video")return null;const T=await _o(Me,Ae,x,f,C,Math.max(U.start,x.start),U.duration);if(!T)return null;const X=T.toVideoFrame();return{source:X,w:T.displayWidth,h:T.displayHeight,close:()=>X.close()}};Ne="output";const k=ba(y,_),He=io(w,{width:y,height:_,fps:C},ro),nt=w?.codec==="hevc",St=w?.container==="mov",Qe=!A&&!de&&te*He/8>15e7&&!!navigator.storage?.getDirectory;let Xe=null,Ue;if(Qe){const r=await navigator.storage.getDirectory(),f=`gpu-export-${crypto.randomUUID()}.${St?"mov":"mp4"}`,U=await r.getFileHandle(f,{create:!0});Xe={dir:r,handle:U,name:f},Ue=new Ro(await U.createWritable(),{chunked:!0,chunkSize:1<<20})}else Ue=de&&!A?new Ro(de,{chunked:!0,chunkSize:1<<22}):new Ri;const Ve=de&&!A?!1:Qe?"reserve":"in-memory",Je=new _i({format:St?new Fi({fastStart:Ve}):new Ai({fastStart:Ve}),target:Ue}),_t=new Mi(k.canvas,{codec:nt?"hevc":"avc",bitrate:He,keyFrameInterval:2,...nt?{hardwareAcceleration:"prefer-hardware"}:Y?{hardwareAcceleration:"prefer-software"}:{}}),Ze=me==="audio"?0:Math.max(0,Math.min(oe,ae?.from??0)),Ft=me==="audio"?0:Math.max(Ze,Math.min(oe,ae?.to??oe));me!=="audio"&&Je.addVideoTrack(_t,{frameRate:C,...Qe?{maximumPacketCount:Ft-Ze+8}:{}});const Dt=new Si({codec:"aac",bitrate:Uo});me!=="video"&&Je.addAudioTrack(Dt,Qe?{maximumPacketCount:Math.ceil(te*Ct/1024)+16}:{}),A||await Je.start();const Ot=A?new OffscreenCanvas(y,_):null,zt=Ot?.getContext("2d"),Wt=async r=>{zt.putImageData(new ImageData(k.pixels(),y,_),0,0);const f=new Uint8Array(await(await Ot.convertToBlob({type:"image/webp",quality:.9})).arrayBuffer());let U="";for(let x=0;x<f.length;x+=32768)U+=String.fromCharCode(...f.subarray(x,x+32768));A.push(r,btoa(U))},Me=new Map;let ue=0;const j={decode:0,matte:0,titles:0,captions:0,encode:0},st=async(r,f)=>{const U=performance.now();try{return await f}finally{j[r]+=performance.now()-U}},At=(r,f)=>{const U=performance.now();try{return f()}finally{j[r]+=performance.now()-U}};try{for(let f=A?0:Ze,U=A?A.times.length:Ft;f<U;f++){Oe(),Ne="frame";const x=A?A.times[f]:f/C,T=Te(x);k.clear(A?0:1);const X=T&&qe?Ho(L,T.start+1e-5,e):void 0,P=X&&T?Vo(T.visuals,X.captionStyle?.layerTrack):-1,ce=async()=>{const W=X&&T&&await st("captions",F(X,T,f));W&&(k.shadow([]),k.edge(null),k.windows(null),k.matte(null),k.mode(void 0),k.key(null),k.grade(null,null),k.draw(W,pe,pe,1,1,!1,null,[]))};for(const[W,Z]of(T?.visuals??[]).entries()){let a=Z;if(W===P&&await ce(),a.kind==="audio")continue;const S=T?lo(a,T.start,T.start+T.duration):null,fe=S?a._txIn===S?"b":"a":null,ve=S?Yo(S,x):0;e:{if(a.kind==="model"){k.matte(null),k.edge(null),k.windows(null),k.mode(void 0),k.shadow(uo(a,y)),k.key(null),k.grade(null,null);const m=await Ee(a,x);m&&k.draw(m,pe,pe,1,1,!1,null,[]);break e}const ne=x-a.start,Re=Jt(a,ne,y,_),se=(Wo(a)||Ko(a))&&!S&&!(z&&$t(a))&&!a.pin?je(a,T,x,Re):Re;if(!(se.opacity>1e-4))break e;if(Zt(a)){k.adjust(ot(a),Ie(a,T,f),Math.min(1,se.opacity));break e}let B=null,Pe=null;if(Ht(a)||a._group)B=await st("titles",Ee(a,x));else if(a.kind==="image")B=Le.get(a.url)??null;else if(a.kind==="video"){const m=await st("decode",_o(Me,Ae,a,x,C,T.start,T.duration));m&&(Pe=m.toVideoFrame(),B={source:Pe,w:m.displayWidth,h:m.displayHeight,bt709:Pe.colorSpace?.matrix?Pe.colorSpace.matrix==="bt709":m.displayHeight>=720})}if(!B)break e;if(Qo(a)){const m=a.crop||{left:0,right:0,top:0,bottom:0},t=Math.floor(B.w*m.left/2)*2,c=Math.floor(B.h*m.top/2)*2,u=Math.max(2,Math.floor(B.w*(1-m.left-m.right)/2)*2),h=Math.max(2,Math.floor(B.h*(1-m.top-m.bottom)/2)*2),i=a.distort.displace?await Rt(a.distort.displace.map,x,T):null;Ce??=hi();const v=Ce.render({source:B.source,srcW:B.w,srcH:B.h,rect:[t,c,u,h],outW:u,outH:h,distort:a.distort,local:ne,map:i?.source??null,matte:ye&&(a.mask||a.person)?ye.matteCanvas(a,ne,Ge,!1,L):null});i?.close?.(),B={source:v,w:u,h,bt709:B.bt709},a={...a,crop:void 0,mask:void 0,person:void 0}}if(ye&&(a.mask||a.person)){const m=a.crop||{left:0,right:0,top:0,bottom:0},t=Math.max(2,Math.floor(B.w*(1-m.left-m.right)/2)*2),c=Math.max(2,Math.floor(B.h*(1-m.top-m.bottom)/2)*2);k.matte(At("matte",()=>ye.matteCanvas(a,ne,Ge,!1,L)),[m.left,m.top,t/B.w,c/B.h])}else k.matte(null);k.mode(a.blend),k.key(a.key),k.shadow(uo(a,y));{const m=a.colorBypass?[]:qt(a.grade).filter(eo);k.windows(m.length?{key:`${a.id}@${f}`,list:qt(a.grade),clip:a.id,src:a,frame:Math.round((x-a.start)*C),local:Math.round((x-a.start)*C)/C}:null)}if(mo(a)&&po(xo(a),ne)>.001){const m=xo(a),t=ye&&(a.mask||a.person),c=a.crop||{left:0,right:0,top:0,bottom:0},u=t?Math.max(2,Math.floor(t.mw*(1-c.left-c.right)/2)*2):B.w,h=t?Math.max(2,Math.floor(t.mh*(1-c.top-c.bottom)/2)*2):B.h,i=u>=h?jt:Math.max(8,Math.trunc(jt*u/h/8)*8),v=u>=h?Math.max(8,Math.trunc(jt*h/u/8)*8):jt,M=Jo(m),Q=po(m,ne),K=!!m.keys?.length||m.amount<.999;k.edge({key:`${a.id}@${f}`,ew:i,eh:v,band:M.band,glow:M.glow,k:m.glow,col:[1,3,5].map(V=>parseInt(m.color.slice(V,V+2),16)/255),am:K?Math.trunc(255*Q):255,harden:!!t,arc:m.cover>=.999&&!m.comet?null:{cen:t?Zo(a):[.5,.5],start:(m.angle+m.sweep*ne)*Math.PI/180,cover:m.cover,comet:!!m.comet}})}else k.edge(null);{const m=a.grade&&!a.colorBypass?Yt(a):null;k.grade(m?.l1??null,m?.l3??null)}if(a.pin&&!(z&&$t(a))&&T&&vo(a,L,T.start,y,_,z)){const m=vo(a,L,x,y,_,z)??[[0,0],[0,0],[0,0],[0,0]],t=Bt(a,ne),c=er(a,L,y,_,z),u=a.pin.dive,h=c&&!a.pin.scene?[+(c[0]*y).toFixed(3),+(c[1]*_).toFixed(3),u?Math.max(0,Math.min(1,(x-u.at)/u.dur)):0]:null;k.warp(B,Nt([0,0,1,1],y,_),wo(a,B.w,B.h),Math.min(1,se.opacity),t.k,t.white,ot(a),Ie(a,T,f),It(m,y,_),h),Pe?.close();break e}const kt=tr(a,"rot")||or(a),xt=()=>a.motionBlur?fi(x,C).map(m=>({...Jt(a,m-a.start,y,_),rot:se.rot,opacity:se.opacity})):[se];if((kt||Math.abs(se.rot||0)>1e-9)&&!(z&&$t(a))){const m=Bt(a,ne),t=S&&fe?[...Ao(S.spec[fe],ve,y,_,x,S.spec.zoomAt),...fe==="b"&&S.spec.mask?[Fo(S.spec.mask,ve)]:[]]:[];a.motionBlur&&k.blurBegin();for(const c of xt()){const u=ai(a,B.w,B.h,y,_,c,kt);k.warp(B,Nt([0,0,1,1],y,_),wo(a,B.w,B.h),Math.min(1,se.opacity),m.k,m.white,ot(a),[],It(u.quad,y,_),null,u.clip,t)}a.motionBlur&&k.blurEnd(),Pe?.close();break e}if(z&&$t(a)){const m=rr(a,ne,z,x,y,_);if(m){const t=Lt(a,B.w,B.h,y,_,{x:0,y:0,zoom:1}),c=Bt(a,ne),u=Ie(a,T,f);let h=at.get(a.id);h===void 0&&(h=a.effects?.some(v=>!v.off)||a.mask||a.person||mo(a)||!a.colorBypass&&qt(a.grade).some(eo)?1:ir(ar(a,z,y,_),B.w,B.h,y,_),at.set(a.id,h));const i=Xt(a,T,f);h>1&&!u.length?k.warpBig(B,Nt(t.dst,y,_),t.src,Math.min(1,se.opacity),c.k,c.white,ot(a),m.quad,h,i):k.warp(B,Nt(t.dst,y,_),t.src,Math.min(1,se.opacity),c.k,c.white,ot(a),u,It(m.quad,y,_),null,null,i)}Pe?.close();break e}if(a.motionBlur&&!S&&!Ie(a,T,f).length){const m=Bt(a,ne);k.blurBegin();for(const t of xt()){const c=Lt(a,B.w,B.h,y,_,t);k.draw(B,c.dst,c.src,Math.min(1,se.opacity),m.k,m.white,ot(a),[])}k.blurEnd(),Pe?.close();break e}const{dst:vt,src:n}=Lt(a,B.w,B.h,y,_,se),s=Bt(a,ne),o=[...Ie(a,T,f),...S&&fe?Ao(S.spec[fe],ve,y,_,x,S.spec.zoomAt):[],...S&&fe==="b"&&S.spec.mask?[Fo(S.spec.mask,ve)]:[]],l=S&&fe?S.spec[fe]?.rot:null;if(l){const m=Vt(l,ve)??0;k.warp(B,Nt([0,0,1,1],y,_),n,Math.min(1,se.opacity),s.k,s.white,ot(a),[],It(ni(vt,y,_,m),y,_),null,null,o),Pe?.close();break e}if(o.length>0&&!!T&&!a.layout&&!lo(a,T.start,T.start+T.duration)&&nr(a,T.start,T.start+T.duration,y,_)){const m=Lt(a,B.w,B.h,y,_,{x:0,y:0,zoom:1}),t=Lt({},y,_,y,_,se);k.draw(B,t.dst,m.src,Math.min(1,se.opacity),s.k,s.white,ot(a),o,m.dst)}else k.draw(B,vt,n,Math.min(1,se.opacity),s.k,s.white,ot(a),o);Pe?.close()}if(S&&fe==="b"){if(S.spec.light){const Re=Math.max(2,Math.ceil(y/ho)),se=Math.max(2,Math.ceil(_/ho));k.overlay(null,{data:sr(S.spec,ve,Re,se),w:Re,h:se})}const ne=S.spec.flash;if(ne){const Re=Vt(ne.opacity,ve)??0;if(Re>1e-4){const se=parseInt(ne.color.slice(1),16);k.overlay([(se>>16&255)/255,(se>>8&255)/255,(se&255)/255,Math.min(1,Re)],null)}}}}P>=0&&P>=(T?.visuals.length??0)&&await ce();for(const[W,Z]of Me){const a=W.split(`
198
- `)[0],S=O.find(fe=>fe.id===a);(!S||x>S.start+S.duration+1)&&(Z.current?.close(),Z.peek?.close(),await Z.iterator.return?.(),Me.delete(W))}if(A){await Wt(f);continue}Ne="video encode",await st("encode",_t.add((f-Ze)/C,1/C)),N?.((me==="video"?1:.9)*(f+1-Ze)/Math.max(1,Ft-Ze))}if(A)return{blob:new Blob,ms:{titles:0,video:0,audio:0,total:Math.round(performance.now()-d)}};const r=performance.now();if(me==="video")_t.close(),Ne="finalize",await Je.finalize();else{Ne="audio";const f=new Map(O.map(x=>[x.id,x])),U=await wa(L.map(x=>f.get(x.id)??x),_e,te,e,rt,E);typeof g.loudness=="number"&&si([U.getChannelData(0),U.getChannelData(1)],g.loudness,Ct),Ne="audio encode",await Dt.add(U),ue=performance.now()-r,me!=="audio"&&_t.close(),Dt.close(),Ne="finalize",await Je.finalize()}}catch(r){throw await Je.cancel().catch(()=>{}),Xe&&await Xe.dir.removeEntry(Xe.name).catch(()=>{}),r}finally{for(const r of Me.values())r.current?.close(),r.peek?.close();Ce?.dispose();for(const r of Le.values())r.close?.();for(const r of J.values())r.pic?.close?.();for(const r of Fe.values())r.close();for(const r of it.values())r.close?.();for(const r of Ke.values())r.dispose?.()}N?.(1),Ne="file";const dt=Xe?await Xe.handle.getFile():de?new Blob([]):new Blob([Ue.buffer],{type:St?"video/quicktime":"video/mp4"});Xe&&setTimeout(()=>void Xe.dir.removeEntry(Xe.name).catch(()=>{}),600*1e3);const ct=performance.now()-d;return{blob:dt,ms:{titles:Math.round(lt-d),video:Math.round(ct-(lt-d)-ue),audio:Math.round(ue),total:Math.round(ct),parts:Object.fromEntries(Object.entries(j).map(([r,f])=>[r,Math.round(f)]))}}}function Ta(p,g,w,e,G){const E=[new Float32Array(Math.max(1,Math.round(G*w))),new Float32Array(Math.max(1,Math.round(G*w)))],N=Math.round(Lr*w);return g.forEach((A,Y)=>{if(A.silent)return;const re=Math.round((A.t1-A.t0)*w)+(Y<g.length-1?N:0),ae=Math.abs(A.rate),me=Math.round(A.t0*w),de=Math.max(0,Math.round(((A.rate>0?A.s0:A.s0-ae*re/w)-e)*w)),d=Math.min(p[0].length,Math.round(((A.rate>0?A.s0+ae*re/w:A.s0)-e)*w));if(d-de<2)return;const y=(d-de)/re,_=Math.round(.06*w),C=Math.max(0,de-_),L=Math.min(p[0].length,d+_);let O=p.map(oe=>oe.slice(C,L));A.rate<0&&O.forEach(oe=>oe.reverse());const te=Math.round((A.rate<0?L-d:de-C)/y);O=ko(O,y,w).map(oe=>oe.subarray(te,te+re));for(let oe=0;oe<2;oe++)for(let z=0;z<re&&me+z<E[oe].length;z++){const _e=(Y>0&&z<N?z/N:1)*(Y<g.length-1&&z>=re-N?(re-z)/N:1);E[oe][me+z]+=(O[oe][z]??0)*_e}}),E}async function wa(p,g,w,e,G,E){const N=new OfflineAudioContext({numberOfChannels:2,length:Math.max(1,Math.round(w*Ct)),sampleRate:Ct}),A=1/200,Y=p.filter(d=>(d.kind==="video"||d.kind==="audio")&&!d.freeze&&!Do(d)&&(d.volume??1)>0),re=d=>(d.kind==="video"||d.kind==="audio")&&!!d.url,ae=new Map;for(const d of g.flatMap(y=>y.audios))!re(d)||ae.has(d.url)||ae.set(d.url,await G(d.url).getPrimaryAudioTrack().then(y=>!!y,()=>!1));const me=d=>re(d)&&!!ae.get(d.url);for(const d of Y){if(E?.aborted)throw new DOMException("Export cancelled","AbortError");const y=Math.max(2,Math.ceil(d.duration/A)+1),_=new Float32Array(y);let C=!1;const L=kr(d.track,e);for(let J=0;J<y;J++){const Ee=d.start+Math.min(d.duration,J*A),ut=g.find(De=>Ee>=De.start-1e-6&&Ee<De.start+De.duration-1e-6),qe=ut?.audios.some(De=>De.id===d.id)?Ur(d,Ee-d.start)*L.gain/Pr(ut.audios,me):0;_[J]=qe,qe>0&&(C=!0)}if(!C)continue;const O=await G(d.url).getPrimaryAudioTrack();if(!O)continue;const te=So(d)?Br(d,0,d.duration):null,oe=d.playbackRate||1,z=new yi(O),_e=te?te.flatMap(J=>[J.s0,J.s1]):[],Te=te?Math.max(0,Math.min(..._e)-.2):d.inPoint||0,Oe=te?Math.max(..._e)+.2:Te+d.duration*oe,we=[];let Ye=Te;for await(const J of z.samples(Te,Oe))we.length||(Ye=J.timestamp),we.push(J.toAudioBuffer()),J.close();if(!we.length)continue;const ze=we[0].sampleRate,ft=we.reduce((J,Ee)=>J+Ee.length,0);let Fe=[new Float32Array(ft),new Float32Array(ft)],lt=0;for(const J of we){for(let Ee=0;Ee<2;Ee++)Fe[Ee].set(J.getChannelData(Math.min(Ee,J.numberOfChannels-1)),lt);lt+=J.length}te?Fe=Ta(Fe,te,ze,Ye,d.duration):oe!==1&&(Fe=ko(Fe,oe,ze));const We=N.createBuffer(2,Fe[0].length,ze);for(let J=0;J<2;J++)We.copyToChannel(Fe[J],J);const ye=N.createBufferSource();ye.buffer=We;const Ge=N.createGain();Ge.gain.value=0,Ge.gain.setValueCurveAtTime(_,d.start,Math.max(A,d.duration));const Ke=N.createChannelSplitter(2),Ae=N.createChannelMerger(2),Le=N.createGain(),rt=N.createGain();Le.gain.value=L.left,rt.gain.value=L.right,ye.connect(Ge),Ge.connect(Ke),Ke.connect(Le,0),Ke.connect(rt,1),Le.connect(Ae,0,0),rt.connect(Ae,0,1),Ae.connect(N.destination),ye.start(d.start,te?0:Math.max(0,Te-Ye)/oe,d.duration)}const de=await N.startRendering();return ci([de.getChannelData(0),de.getChannelData(1)]),de}export{Pa as canEncodeH264,Ba as canEncodeHevc,Ua as canEncodeMp4,ga as exportOnGpu,ro as gpuBitrate,La as gpuExportStage,Na as gpuExportSupported};
@@ -1 +0,0 @@
1
- import{ab as kt,ac as Ft}from"./main-VVYiW8XD.js";import{iO as V,iP as jt}from"./remote-C7J0Tqhb.js";import"./titleFrameBudget-CLZWaFHO.js";import"./api-CJ8PdbfZ.js";import"./store-DW4E9xnW.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DzziUgOj.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";import"./userFonts-CwlKh9NR.js";import"./lottieLayer-DzbA3bHV.js";import"./timeline3d-DOw-CpZI.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-QYsT9JBO.js";import"./captionLayout-DvDPTwO9.js";import"./timelineText-BH09jfSM.js";import"./titleArt-Drsrtfiv.js";import"./rotoMatte-C-2o3vv0.js";import"./distortGL-QalhICvi.js";import"./motionBlur-uAm030t9.js";const dt=Object.freeze({core:.5,band:.16,ring:.55,sep:22,lo:.1,hi:.78,guideR:2,guideEps:.002,maxW:512,choke:[.5,.66],close:.08,closeArm:.22,chokeAI:[.45,.62],chokeArm:[.22,.4]}),ut=[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]],at=[0,1,5,9,13,17];function X(l,t,n,g,A,d,y=255){const a=Math.max(0,Math.floor(Math.min(t[0],n[0])-g)),e=Math.min(A-1,Math.ceil(Math.max(t[0],n[0])+g)),M=Math.max(0,Math.floor(Math.min(t[1],n[1])-g)),p=Math.min(d-1,Math.ceil(Math.max(t[1],n[1])+g)),U=n[0]-t[0],i=n[1]-t[1],f=U*U+i*i||1,c=g*g;for(let m=M;m<=p;m++)for(let o=a;o<=e;o++){const S=o+.5-t[0],z=m+.5-t[1],$=Math.max(0,Math.min(1,(S*U+z*i)/f)),H=S-$*U,B=z-$*i;H*H+B*B<=c&&l[m*A+o]<y&&(l[m*A+o]=y)}return l}function W(l,t,n,g,A=255){const d=t.length;if(d<3)return l;let y=1/0,a=-1/0;for(const M of t)M[1]<y&&(y=M[1]),M[1]>a&&(a=M[1]);y=Math.max(0,Math.floor(y)),a=Math.min(g-1,Math.ceil(a));const e=[];for(let M=y;M<=a;M++){const p=M+.5;e.length=0;for(let i=0,f=d-1;i<d;f=i++){const c=t[f],m=t[i];(c[1]<=p&&m[1]>p||m[1]<=p&&c[1]>p)&&e.push([c[0]+(p-c[1])/(m[1]-c[1])*(m[0]-c[0]),m[1]>c[1]?1:-1])}if(e.length<2)continue;e.sort((i,f)=>i[0]-f[0]);let U=0;for(let i=0;i<e.length-1;i++){if(U+=e[i][1],!U)continue;const f=Math.max(0,Math.ceil(e[i][0]-.5)),c=Math.min(n-1,Math.floor(e[i+1][0]-.5)),m=M*n;for(let o=f;o<=c;o++)l[m+o]<A&&(l[m+o]=A)}}return l}function ht(l,t,n,g){const A=t+1,d=l.map(y=>{const a=new Float64Array(A*(n+1));for(let e=0;e<n;e++){let M=0;for(let p=0;p<t;p++)M+=y[e*t+p],a[(e+1)*A+p+1]=a[e*A+p+1]+M}return a});return(y,a,e)=>{const M=d[y],p=Math.max(0,a-g),U=Math.min(t,a+g+1),i=Math.max(0,e-g),f=Math.min(n,e+g+1);return M[f*A+U]-M[i*A+U]-M[f*A+p]+M[i*A+p]}}function Xt(l,t,n,g,A={}){const{learned:d=null,...y}=A,a={...dt,...y},e=t*n,M=new Uint8Array(e),p=new Uint8Array(e),U=new Uint8Array(e),i=new Uint8Array(e),f=new Uint8Array(e),c=(g||[]).filter(r=>r?.lm?.length>=21);if(!c.length)return new Uint8Array(e);const m=r=>r.map(([h,x])=>[h*t,x*n]);let o=0;for(const r of c){o=Math.max(o,Math.hypot((r.lm[0][0]-r.lm[9][0])*t,(r.lm[0][1]-r.lm[9][1])*n)),W(M,m(V(r.lm,t,n,{edge:r.edge?r.edge.map(x=>Math.min(0,x)):null,scale:a.core})),t,n),W(i,m(V(r.lm,t,n,{edge:r.edge})),t,n),W(p,m(V(r.lm,t,n,{edge:r.edge,grow:a.band})),t,n),W(U,m(V(r.lm,t,n,{edge:r.edge,grow:a.ring})),t,n);const h=V(r.lm,t,n,{edge:r.edge,grow:a.band});W(f,m(jt.map(x=>h[x])),t,n)}if(d){const r=new Uint8Array(e),h=new Uint8Array(e);for(const u of c){const s=u.lm.map(([N,L])=>[N*t,L*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]),k=Array.isArray(u.armDir)?u.armDir:[(s[0][0]-s[9][0])/(F||1),(s[0][1]-s[9][1])/(F||1)],j=[s[0][0]+k[0]*4*F,s[0][1]+k[1]*4*F];for(const[N,L]of ut)X(r,s[N],s[L],.45*F,t,n),X(h,s[N],s[L],.08*F,t,n);W(r,at.map(N=>s[N]),t,n),W(h,at.map(N=>s[N]),t,n);const Q=[s[0][0]+k[0]*Math.max(t,n)*1.5,s[0][1]+k[1]*Math.max(t,n)*1.5];X(r,s[0],Q,1.6*F,t,n),X(h,s[0],j,.12*F,t,n)}const x=new Uint8Array(e);for(const u of c){const s=u.lm.map(([k,j])=>[k*t,j*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]);for(const[k,j]of ut)X(x,s[k],s[j],.45*F,t,n);W(x,at.map(k=>s[k]),t,n)}const I=[];for(let u=0;u<e;u+=2)if(h[u]&&x[u]&&d[u]>.6){const s=u*4;I.push([l[s],l[s+1],l[s+2]])}I.sort((u,s)=>u[0]+u[1]+u[2]-s[0]-s[1]-s[2]);const P=I.length>=30?[0,1,2].map(u=>{const s=I.slice(Math.floor(I.length*u/3),Math.floor(I.length*(u+1)/3));return[0,1,2].map(F=>s.reduce((k,j)=>k+j[F],0)/s.length)}):null,D=new Float32Array(e),T=new Float32Array(e),q=new Float32Array(e),C=new Float32Array(e);for(let u=0;u<e;u++)if(d[u]<.1){const s=u*4;D[u]=1,T[u]=l[s],q[u]=l[s+1],C[u]=l[s+2]}const E=P?ht([D,T,q,C],t,n,Math.max(4,Math.round(o*.6))):null,v=u=>{if(!P||!x[u])return 1;const s=u%t,F=u/t|0,k=E(0,s,F);if(k<4)return 1;const j=[E(1,s,F)/k,E(2,s,F)/k,E(3,s,F)/k],Q=u*4,N=[l[Q],l[Q+1],l[Q+2]];let L=0,et=1/0;for(const it of P){const R=[it[0]-j[0],it[1]-j[1],it[2]-j[2]],lt=R[0]*R[0]+R[1]*R[1]+R[2]*R[2];et=Math.min(et,Math.sqrt(lt)),lt>=1&&(L=Math.max(L,((N[0]-j[0])*R[0]+(N[1]-j[1])*R[1]+(N[2]-j[2])*R[2])/lt))}if(et<a.sep)return 1;const rt=Math.max(0,Math.min(1,(L-.12)/.2));return rt*rt*(3-2*rt)},J=d,G=new Uint8Array(e),[O,K]=a.chokeAI,[gt,Ut]=a.chokeArm;for(let u=0;u<e;u++){if(!r[u])continue;const s=x[u]?O:gt,F=x[u]?K:Ut;if(J[u]<s)continue;const k=Math.max(0,Math.min(1,(J[u]-s)/(F-s)))*v(u);G[u]=Math.round(255*k*k*(3-2*k))}return Mt(G,t,n,{snapped:h,band:r,core:h,arm:f,r:1,rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.03*o*o)})}const S=[];for(let r=0;r<e;r+=3)if(M[r]){const h=r*4;S.push([l[h],l[h+1],l[h+2]])}if(S.length<12)return i;S.sort((r,h)=>r[0]+r[1]+r[2]-h[0]-h[1]-h[2]);const z=r=>{const h=S.slice(Math.floor(S.length*r/3),Math.floor(S.length*(r+1)/3));return[0,1,2].map(x=>h.reduce((I,P)=>I+P[x],0)/h.length)},$=[z(0),z(1),z(2)],H=new Float32Array(e),B=new Float32Array(e),w=new Float32Array(e),tt=new Float32Array(e);let st=0,ct=0,ft=0,_=0;for(let r=0;r<e;r++)if(U[r]&&!p[r]){const h=r*4;H[r]=1,B[r]=l[h],w[r]=l[h+1],tt[r]=l[h+2],st+=B[r],ct+=w[r],ft+=tt[r],_++}const yt=_?[st/_,ct/_,ft/_]:null,b=ht([H,B,w,tt],t,n,Math.max(3,Math.round(o*.45))),Z=new Float32Array(e),nt=new Uint8Array(e);for(let r=0;r<n;r++)for(let h=0;h<t;h++){const x=r*t+h;if(!p[x]&&!(d&&U[x]&&!f[x]&&d[x]>.3))continue;if(nt[x]=1,M[x]){Z[x]=1;continue}const I=b(0,h,r),P=I>2?[b(1,h,r)/I,b(2,h,r)/I,b(3,h,r)/I]:yt;if(!P){Z[x]=i[x]/255;continue}const D=x*4,T=[l[D],l[D+1],l[D+2]];let q=0,C=1/0;for(const G of $){const O=[G[0]-P[0],G[1]-P[1],G[2]-P[2]],K=O[0]*O[0]+O[1]*O[1]+O[2]*O[2];C=Math.min(C,Math.sqrt(K)),!(K<1)&&(q=Math.max(q,((T[0]-P[0])*O[0]+(T[1]-P[1])*O[1]+(T[2]-P[2])*O[2])/K))}const E=d&&!f[x]?d[x]:null;if(C<a.sep){Z[x]=E??i[x]/255;continue}const v=Math.max(0,Math.min(1,(q-a.lo)/(a.hi-a.lo))),J=v*v*(3-2*v);Z[x]=E===null?J:E*J}const xt=kt(Z,Ft(l,t,n),t,n,{r:a.guideR,eps:a.guideEps}),ot=new Uint8Array(e),[mt,At]=a.choke;for(let r=0;r<e;r++){if(!nt[r])continue;if(M[r]){ot[r]=255;continue}const h=Math.max(0,Math.min(1,(xt[r]-mt)/(At-mt)));ot[r]=Math.round(255*h*h*(3-2*h))}return Mt(ot,t,n,{snapped:i,band:nt,core:M,arm:f,r:Math.max(1,Math.round(o*a.close)),rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.12*o*o)})}function pt(l,t,n,g,A,d,y){const a=2*d+1,e=new Uint8Array(n+a),M=new Uint8Array(n+a),p=f=>{const c=Math.max(0,Math.min(n-1,f-d));return l[g+c*A]},U=n+2*d,i=y?(f,c)=>f>c?f:c:(f,c)=>f<c?f:c;for(let f=0;f<U;f+=a){const c=Math.min(U,f+a);e[f]=p(f);for(let m=f+1;m<c;m++)e[m]=i(e[m-1],p(m));M[c-1]=p(c-1);for(let m=c-2;m>=f;m--)M[m]=i(M[m+1],p(m))}for(let f=0;f<n;f++)t[g+f*A]=i(M[f],e[f+2*d]??e[U-1])}function Y(l,t,n,g,A){const d=new Uint8Array(l.length),y=new Uint8Array(l.length);for(let a=0;a<n;a++)pt(l,d,t,a*t,1,g,A);for(let a=0;a<t;a++)pt(d,y,n,a,t,g,A);return y}function Mt(l,t,n,{snapped:g,band:A,core:d,arm:y,r:a,rArm:e,small:M}){const p=t*n,U=new Uint8Array(p);for(let o=0;o<p;o++)U[o]=l[o]>=128?255:0;const i=Y(Y(U,t,n,a,!0),t,n,a,!1),f=Y(Y(U,t,n,e,!0),t,n,e,!1);for(let o=0;o<p;o++)!U[o]&&A[o]&&(y[o]&&(i[o]||f[o])||!y[o]&&i[o]&&d[o])&&(l[o]=255);It(l,t,n,d,M,y);const c=new Uint8Array(p),m=[];for(let o=0;o<p;o++)d[o]&&l[o]>=64&&m.push(o);for(;m.length;){const o=m.pop();if(c[o]||l[o]<64)continue;c[o]=1;const S=o%t;S>0&&m.push(o-1),S<t-1&&m.push(o+1),o>=t&&m.push(o-t),o<p-t&&m.push(o+t)}for(let o=0;o<p;o++)c[o]||(l[o]=l[o]>=64?0:l[o]);return l}function It(l,t,n,g,A=0,d=null){const y=t*n,a=new Int32Array(y),e=[];for(let i=0;i<t;i++)e.push(i,(n-1)*t+i);for(let i=0;i<n;i++)e.push(i*t,i*t+t-1);const M=(i,f)=>{for(;e.length;){const c=e.pop();if(a[c]||l[c]>=128)continue;a[c]=i,f?.push(c);const m=c%t;m>0&&e.push(c-1),m<t-1&&e.push(c+1),c>=t&&e.push(c-t),c<y-t&&e.push(c+t)}};M(-1);for(let i=0,f=1;i<y;i++){if(a[i]||l[i]>=128)continue;const c=[];e.push(i),M(f++,c);const m=c.length<A&&(!d||c.every(o=>d[o]));for(const o of c)(m||g[o])&&(l[o]=255)}const p=new Uint8Array(y);for(let i=0;i<y;i++)p[i]=a[i]===-1||a[i]>0&&l[i]<128?255:0;const U=Y(p,t,n,2,!0);for(let i=0;i<y;i++)l[i]&&l[i]<255&&!U[i]&&(l[i]=255);return l}function Yt(l,t,n=dt.maxW){const g=Math.min(n,l),A=Math.max(2,Math.round(g*t/l/2)*2);return{w:Math.round(g/2)*2,h:A}}export{dt as HAND_MATTE,X as fillCapsule,W as fillPolygon,Xt as handMatteFrame,Yt as handMatteSize};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-VVYiW8XD.js","assets/titleFrameBudget-CLZWaFHO.js","assets/remote-C7J0Tqhb.js","assets/api-CJ8PdbfZ.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-DW4E9xnW.js","assets/rotoMaskStore-DPziPKAN.js","assets/textAnimators-DUZjhVGO.js","assets/timelineComp-B4GtoH2f.js","assets/rigTrack-urT3nDK0.js","assets/spark.module-DzziUgOj.js","assets/userFonts-CwlKh9NR.js","assets/lottieLayer-DzbA3bHV.js","assets/timeline3d-DOw-CpZI.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-QYsT9JBO.js","assets/captionLayout-DvDPTwO9.js","assets/timelineText-BH09jfSM.js","assets/titleArt-Drsrtfiv.js","assets/rotoMatte-C-2o3vv0.js","assets/distortGL-QalhICvi.js","assets/motionBlur-uAm030t9.js","assets/main-Ca_CVxMz.css","assets/handMatte-Dl-xVXFR.js","assets/matteFixRun-vgYrINet.js"])))=>i.map(i=>d[i]);
2
- import{c1 as Y,_ as N,a7 as Z,b_ as tt}from"./titleFrameBudget-CLZWaFHO.js";import{u as V}from"./store-DW4E9xnW.js";import{t as W}from"./api-CJ8PdbfZ.js";import{a7 as et,a8 as at,a9 as nt,a6 as X,aa as ot}from"./main-VVYiW8XD.js";import{iE as it,iF as rt,iG as J,iH as st,iI as ct,iJ as K,iK as lt,bd as z,iL as dt,iM as mt,iN as ut}from"./remote-C7J0Tqhb.js";import{handMatteSize as ht,handMatteFrame as ft}from"./handMatte-Dl-xVXFR.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DzziUgOj.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";import"./userFonts-CwlKh9NR.js";import"./lottieLayer-DzbA3bHV.js";import"./timeline3d-DOw-CpZI.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-QYsT9JBO.js";import"./captionLayout-DvDPTwO9.js";import"./timelineText-BH09jfSM.js";import"./titleArt-Drsrtfiv.js";import"./rotoMatte-C-2o3vv0.js";import"./distortGL-QalhICvi.js";import"./motionBlur-uAm030t9.js";const pt="https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task",wt=`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${X}/wasm`,gt=640;let $=null;async function yt(){if(typeof window<"u"&&window.__handTrackerStub)return{detect:window.__handTrackerStub,close:()=>{}};const{FilesetResolver:d,HandLandmarker:w}=await N(async()=>{const{FilesetResolver:c,HandLandmarker:s}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:c,HandLandmarker:s}},[]);$??=d.forVisionTasks(wt).catch(c=>{throw $=null,c});const a=await w.createFromOptions(await $,{baseOptions:{modelAssetPath:pt,delegate:"CPU"},runningMode:"VIDEO",numHands:2,minHandDetectionConfidence:.5,minHandPresenceConfidence:.5,minTrackingConfidence:.5});let f=0;return{detect:(c,s)=>{f=Math.max(f+1,Math.round(s));const b=a.detectForVideo(c,f);return(b.landmarks??[]).map((m,v)=>({lm:m.map(p=>[p.x,p.y]),label:b.handedness?.[v]?.[0]?.categoryName??"",score:b.handedness?.[v]?.[0]?.score??1}))},close:()=>a.close()}}async function Mt({clip:d,url:w,from:a,duration:f,signal:c,onProgress:s}){const b=f*(d.playbackRate||1),m=b*30<=K.maxFrames?30:15,v=Math.max(2,Math.min(K.maxFrames,Math.round(b*m)+1)),{detect:p,close:C}=await yt(),u=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});u.src=w;try{await new Promise((r,h)=>{u.onloadeddata=()=>r(),u.onerror=()=>h(Error(W("Không đọc được video để bám tay (CORS / định dạng)")))});const x=u.videoWidth||1280,H=u.videoHeight||720,S=Math.min(gt,x),o=Math.max(2,Math.round(S*H/x)),i=Object.assign(document.createElement("canvas"),{width:S,height:o}),y=i.getContext("2d",{willReadFrequently:!0}),E=z(d,a),T=[];let n=[null,null];for(let r=0;r<v;r++){if(c?.aborted)throw new DOMException("Đã huỷ","AbortError");const h=Math.max(0,Math.min(u.duration-1/60,E+r/m));Math.abs(u.currentTime-h)>1e-4&&await new Promise((t,e)=>{const l=window.setTimeout(()=>e(Error(W("Seek video quá lâu"))),8e3);u.onseeked=()=>{window.clearTimeout(l),t()},u.currentTime=h}),y.drawImage(u,0,0,S,o);const _=p(i,(r+1)*1e3/m).filter(t=>Array.isArray(t.lm)&&t.lm.length>=21).slice(0,2),k=[null,null],R=t=>t.label==="Left"?0:t.label==="Right"?1:-1,M=(t,e)=>{const l=n[e];return l?Math.hypot(l.lm[0][0]-t.lm[0][0],l.lm[0][1]-t.lm[0][1]):1/0};if(_.length===2&&R(_[0])===R(_[1])){const t=_[0],e=_[1],l=M(t,0)+M(e,1)<=M(t,1)+M(e,0),[O,A]=Number.isFinite(M(t,0)+M(e,1))||Number.isFinite(M(t,1)+M(e,0))?l?[t,e]:[e,t]:t.lm[0][0]>e.lm[0][0]?[t,e]:[e,t];k[0]={lm:O.lm.map(F=>[F[0],F[1]]),score:O.score},k[1]={lm:A.lm.map(F=>[F[0],F[1]]),score:A.score}}else for(const t of _){let e=R(t);if(e<0&&(e=t.lm[0][0]>.5?0:1),_.length===1){const l=1-e;M(t,l)<.08&&M(t,e)>.15&&(e=l)}k[e]||(k[e]={lm:t.lm.map(l=>[l[0],l[1]]),score:t.score})}if(k.some(Boolean)){const t=y.getImageData(0,0,S,o).data,e=(l,O)=>{const A=(Math.max(0,Math.min(o-1,O))*S+Math.max(0,Math.min(S-1,l)))*4;return[t[A],t[A+1],t[A+2]]};for(const l of k)if(l){const O=mt(l.lm,S,o,e);O&&(l.edge=O)}}T.push(k),n=[k[0]??n[0],k[1]??n[1]],s?.(r+1,v)}return ut({mw:x,mh:H,fps:m,s0:E,frames:T})}finally{u.removeAttribute("src"),u.load(),C()}}let B=null,q=null;async function xt(d,w,a){const f=typeof window<"u"?window.__bodySkinStub:void 0;B??=f?Promise.resolve(f):(async()=>{const{FilesetResolver:p,ImageSegmenter:C}=await N(async()=>{const{FilesetResolver:H,ImageSegmenter:S}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:H,ImageSegmenter:S}},[]),u=await p.forVisionTasks(`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${X}/wasm`),x=await C.createFromOptions(u,{baseOptions:{modelAssetPath:ot,delegate:"CPU"},runningMode:"IMAGE",outputConfidenceMasks:!0,outputCategoryMask:!1});return H=>{const S=x.segment(H);try{const o=S.confidenceMasks?.[2];if(!o)throw Error("no skin mask");return{data:o.getAsFloat32Array().slice(),width:o.width,height:o.height}}finally{S.close()}}})().catch(p=>{throw B=null,p});const c=await B;q??=document.createElement("canvas");const s=960,b=Math.max(2,Math.round(960*d.height/d.width));(q.width!==s||q.height!==b)&&Object.assign(q,{width:s,height:b}),q.getContext("2d").drawImage(d,0,0,s,b);const m=c(q),v=new Float32Array(w*a);for(let p=0;p<a;p++){const C=Math.min(m.height-1,Math.floor((p+.5)/a*m.height))*m.width;for(let u=0;u<w;u++){const x=m.data[C+Math.min(m.width-1,Math.floor((u+.5)/w*m.width))];v[p*w+u]=Math.max(0,Math.min(1,(x-.25)/.4))}}return v}const kt=[0,1,2,3,5,6,7,9,10,11,13,14,15,17,18,19];let G=null;async function bt(d,w,a,f,c,s){const{objectProbability:b}=await N(async()=>{const{objectProbability:o}=await import("./main-VVYiW8XD.js").then(i=>i.aL);return{objectProbability:o}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),m=new Float32Array(c*s),v=512;G??=Object.assign(document.createElement("canvas"),{width:v,height:v});const p=G.getContext("2d",{willReadFrequently:!0}),C=async(o,i,y,E,T)=>{p.fillStyle="#000",p.fillRect(0,0,v,v),p.drawImage(d,o,i,y,E,0,0,v,v);const n=await b(G,T.map(h=>({x:(h.x-o)/y,y:(h.y-i)/E})).filter(h=>h.x>0&&h.x<1&&h.y>0&&h.y<1)),r=new Float32Array(c*s);for(let h=0;h<s;h++){const _=((h+.5)/s*a-i)/E;if(_<0||_>=1)continue;const k=Math.floor(_*n.height)*n.width;for(let R=0;R<c;R++){const M=((R+.5)/c*w-o)/y;M<0||M>=1||(r[h*c+R]=n.data[k+Math.floor(M*n.width)])}}return r},{fillCapsule:u,fillPolygon:x}=await N(async()=>{const{fillCapsule:o,fillPolygon:i}=await import("./handMatte-Dl-xVXFR.js");return{fillCapsule:o,fillPolygon:i}},__vite__mapDeps([24,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),H=[],S=await xt(d,c,s);for(const{lm:o}of f){const i=o.map(t=>t[0]*w),y=o.map(t=>t[1]*a),E=Math.hypot(i[0]-i[9],y[0]-y[9])||1,T=kt.map(t=>({x:i[t],y:y[t]}));T.push({x:i[0]+(i[0]-i[9])*.6,y:y[0]+(y[0]-y[9])*.6});const r=await C(...((t,e,l,O=1)=>{const A=Math.min(...t)-l,F=Math.max(...t)+l,I=Math.min(...e)-l,g=Math.max(...e)+l,P=Math.max(F-A,g-I),D=Math.min(w,Math.max(F-A,P/O)),j=Math.min(a,Math.max(g-I,P/O)),L=Math.min(D,j*O),U=Math.min(j,D*O);return[Math.max(0,Math.min(w-L,(A+F)/2-L/2)),Math.max(0,Math.min(a-U,(I+g)/2-U/2)),L,U]})([...i,i[0]+(i[0]-i[9])*3],[...y,y[0]+(y[0]-y[9])*3],.6*E),T);let h=(i[0]-i[9])/E,_=(y[0]-y[9])/E;{const t=i[0]/w*c,e=y[0]/a*s,l=E/w*c;let O=0,A=0,F=0;for(let I=0;I<s;I++)for(let g=0;g<c;g++){if(r[I*c+g]<.5)continue;const P=Math.hypot(g-t,I-e);if(P<1.2*l||P>3*l)continue;const D=g-t,j=I-e;D*h+j*_<-.2*P||(O+=g,A+=I,F++)}if(F>20){const I=O/F-t,g=A/F-e,P=Math.hypot(I,g)||1;(I*h+g*_)/P>Math.cos(75*Math.PI/180)&&(h=I/P,_=g/P)}}H.push([h,_]);const k=new Uint8Array(c*s),R=i.map((t,e)=>[t/w*c,y[e]/a*s]),M=E/w*c;for(const[t,e]of[[1,2],[2,3],[3,4],[5,6],[6,7],[7,8],[9,10],[10,11],[11,12],[13,14],[14,15],[15,16],[17,18],[18,19],[19,20],[0,1],[0,5],[0,17]])u(k,R[t],R[e],.35*M,c,s);x(k,[0,1,5,9,13,17].map(t=>R[t]),c,s);for(let t=0;t<c*s;t++){const e=k[t]?Math.max(r[t],S[t]*.5):S[t];e>m[t]&&(m[t]=e)}}return{map:m,armDirs:H}}async function Q({clip:d,url:w,from:a,duration:f,until:c=1/0,refine:s=null,store:b=!0,signal:m,onProgress:v}){if(!d.hands)throw Error(W("Không tìm thấy clip video có tay"));const p=lt(d.hands),C=d.playbackRate||1,u=p.fps,x=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});x.src=w;try{await new Promise((t,e)=>{x.onloadeddata=()=>t(),x.onerror=()=>e(Error(W("Không đọc được video để bám tay (CORS / định dạng)")))});const H=x.videoWidth||p.mw,S=x.videoHeight||p.mh,{w:o,h:i}=ht(H,S),y=Object.assign(document.createElement("canvas"),{width:o,height:i}),E=y.getContext("2d",{willReadFrequently:!0}),T=z(d,a),n=Math.max(1,Math.min(K.maxFrames,Math.round(f*C*u)+1)),r=z(d,c),h=et({mw:H,mh:S,w:o,h:i,fps:u,s0:T},32),_=at(t=>h.push(t)),k=s?await Z(s):null,R=nt(x);let M=!0;for(let t=0;t<n;t++){if(m?.aborted)throw new DOMException("Đã huỷ","AbortError");const e=T+t/u;if(e>r+1e-6){_.push(new Uint8Array(o*i)),v?.(t+1,n);continue}const l=await R(Math.max(0,Math.min(x.duration-1/60,e)));E.drawImage(l,0,0,o,i);const O=Math.max(0,Math.min(p.n-1,Math.round((e-p.s0)*u))),A=[0,1].map(g=>{const P=dt(p,e,g);return P?{lm:P,edge:p.frames[O][g]?.edge??null}:null}).filter(Boolean);let F=null;if(M&&A.length)try{const g=await bt(l,H,S,A,o,i);F=g.map,g.armDirs.forEach((P,D)=>{A[D].armDir=P})}catch(g){M=!1,console.warn("hand cut-out model",g)}let I=A.length?ft(E.getImageData(0,0,o,i).data,o,i,A,{learned:F}):new Uint8Array(o*i);if(k&&s){const g=tt(k,s,e),P=s.w,D=s.h,j=new Uint8Array(o*i);for(let L=0;L<i;L++)for(let U=0;U<o;U++)j[L*o+U]=Math.round(I[L*o+U]*g[Math.min(D-1,Math.floor(L*D/i))*P+Math.min(P-1,Math.floor(U*P/o))]/255);I=j}_.push(I),v?.(t+1,n),t%4===3&&await new Promise(g=>setTimeout(g,0))}return _.finish(),await h.finish({feather:0,grow:0},{store:b})}finally{x.removeAttribute("src"),x.load()}}async function vt(d,w,a){const f=V.getState().clips.find(b=>b.id===d);if(!f||f.kind!=="video")throw Error(W("Không tìm thấy clip video có tay"));if(ct(f,w,a))return f;const c=document.querySelector(`video[data-clip-media="${f.id}"]`)?.currentSrc||f.url,s=await Mt({clip:f,url:c,from:w,duration:Math.min(a,K.maxFrames/15/(f.playbackRate||1))});if(!s.data||!/[^A]/.test(s.data.replace(/=+$/,"")))throw Error(W("Không thấy bàn tay nào trong đoạn này"));return V.setState(b=>({clips:b.clips.map(m=>m.id===f.id?{...m,hands:s}:m)})),{...f,hands:s}}const _t=d=>new Promise(w=>setTimeout(w,d));async function Jt(d,w){const a=w.params??{},f=await vt(String(a.source),a.from??0,a.duration??d.duration),c=V.getState(),{width:s,height:b}=Y(c.timelineFormat);if(a.mode==="attach"){const n=c.clips.find(r=>r.id===d.id)??d;return it(n,f,{point:a.point,side:a.side,scale:!!a.scale,offset:a.offset??null,W:s,H:b})}if(a.mode==="wipe"){const n=c.clips.find(e=>e.id===d.id)??d,r=c.clips.find(e=>e.id===f.id)??f,h=n.mask,_=rt(n,r,{point:a.point,side:a.side,dir:a.dir,feather:a.feather,W:s,H:b,mw:h?.mw,mh:h?.mh}),k=c.clips.find(e=>e.id===a.cutout),R=document.querySelector(`video[data-clip-media="${r.id}"]`)?.currentSrc||r.url;let M=null;if(k)try{M=await Q({clip:r,url:R,from:a.from??0,duration:a.duration??d.duration,refine:k.person??null})}catch(e){console.warn("hand matte",e)}const t=M||!k?void 0:J({...k,hands:r.hands});return V.setState(e=>({clips:e.clips.map(l=>l.id===a.cutout?M?{...l,person:M,mask:void 0}:t?{...l,mask:t}:l:l)})),_.patch}for(let n=0;n<360&&V.getState().clips.find(r=>r.id===a.wall)?.pendingPin;n++)await _t(500);const m=V.getState(),v=m.clips.find(n=>n.id===a.wall),p=m.clips.find(n=>n.id===d.id)??d,C=m.clips.find(n=>n.id===f.id)??f;if(!v)throw Error(W("Không còn tường HUD"));const u=st({wall:v,layer:p,src:C,clips:m.clips,cam:m.timelineCamera,W:s,H:b,events:a.events??null,grab:a.grab??"auto",side:a.side,fly:a.fly}),x=m.clips.find(n=>n.id===a.cutout),H=document.querySelector(`video[data-clip-media="${C.id}"]`)?.currentSrc||C.url,S=(a.matte?m.clips.find(n=>n.id===a.matte)?.person:null)??x?.person??null;let o=null;if(x)try{o=await Q({clip:C,url:H,from:a.from??0,duration:a.duration??d.duration,until:u.cutoutUntil,refine:S})}catch(n){console.warn("hand matte",n)}const i=x?.matteFix?.fixes??[],y=o;if(o&&i.length)try{const{fixedMatte:n}=await N(async()=>{const{fixedMatte:r}=await import("./matteFixRun-vgYrINet.js");return{fixedMatte:r}},__vite__mapDeps([25,6,1,3,0,2,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]));o=await n(o,i,C.hands)}catch(n){console.warn("hand touch-ups",n)}const E=o?void 0:J(C,{until:u.cutoutUntil}),T=n=>{const r=n.mask?.masks?.find(h=>h.id==="wall");return!r||!n.mask?n:o?{...n,person:o,mask:{...n.mask,masks:[{...r,mode:"add"}]}}:E?{...n,mask:{...E,masks:[...E.masks,{...r,mode:"intersect"}]}}:n};return V.setState(n=>({clips:n.clips.map(r=>r.id===v.id?{...r,motion:u.wall}:r.id===a.cutout?o?{...r,person:o,mask:void 0,...i.length?{matteFix:{auto:y,fixes:i}}:{}}:E?{...r,mask:E}:r:r.id===a.shadow?T(r):r)})),{motion:u.grab}}export{pt as HAND_MODEL_URL,Q as buildHandMatte,bt as learnedHands,Jt as runHandTrack,Mt as trackHands};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-DPziPKAN.js","assets/titleFrameBudget-CLZWaFHO.js","assets/api-CJ8PdbfZ.js","assets/timeline3dExport-BtYLU1pw.js","assets/timeline3d-DOw-CpZI.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/frameSink-DeM8xC8_.js","assets/titleFrames-BI1DnLBn.js","assets/titleArt-Drsrtfiv.js","assets/textAnimators-DUZjhVGO.js","assets/lottieLayer-DzbA3bHV.js","assets/rigTrack-urT3nDK0.js","assets/rotoMatte-C-2o3vv0.js","assets/store-DW4E9xnW.js","assets/windowFrames-CpqX3kOM.js","assets/gpuExport-D31azOQA.js","assets/timelineComp-B4GtoH2f.js","assets/gpuCompose-CA3UmOl4.js","assets/motionBlur-uAm030t9.js","assets/exportEncode-QYsT9JBO.js","assets/distortGL-QalhICvi.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/clientExport-xhoXY6Dh.js","assets/engine-BedcnK45.js","assets/store-Cug4GGcP.js","assets/conversion-4rhF3xRJ.js"])))=>i.map(i=>d[i]);
2
- import{_ as f,c1 as v,iQ as $}from"./titleFrameBudget-CLZWaFHO.js";import{FrameSink as F,SKIPPED_FRAME as P}from"./frameSink-DeM8xC8_.js";class x extends F{want;next=new Map;last=new Map;out={};constructor(i){super({put:async()=>{throw Error("a pick sink keeps its frames")}}),this.want=new Map;for(const[d,s]of Object.entries(i))for(const[r,o]of Object.entries(s||{}))this.want.set(`${d}
3
- ${r}`,new Set(o));this.wants=(d,s,r)=>{const o=this.want.get(`${d}
4
- ${s}`);return!!o&&(r===void 0||o.has(r))}}async push(i,d,s){const r=`${i}
5
- ${d}`,o=this.next.get(r)??0;if(this.next.set(r,o+1),s===P)return;const n=s==="="?this.last.get(r):s;n!==void 0&&(this.last.set(r,n),this.want.get(r)?.has(o)&&(((this.out[i]??={})[d]??={})[o]=n))}picked(){return this.out}}const k=(a,i)=>Object.keys(a[i]||{}).length>0,D={async frames({clips:a,format:i,camera:d=null,want:s}){const{unpackMasks:r}=await f(async()=>{const{unpackMasks:t}=await import("./rotoMaskStore-DPziPKAN.js").then(m=>m.X);return{unpackMasks:t}},__vite__mapDeps([0,1,2])),o=await r(a);a=o.clips;const n=new x(s),w={},l=v(i).fps,u=n.wants,_=async(t,m,E)=>{for(const g of m){n.wants=(h,y,b)=>h===t&&y===g&&u(h,y,b);try{await E()}catch(h){w[g]=String(h?.message||h).slice(0,200)}finally{n.wants=u}}},c=t=>Object.keys(s[t]||{});if(k(s,"modelFrames")){const{render3DFrames:t}=await f(async()=>{const{render3DFrames:m}=await import("./timeline3dExport-BtYLU1pw.js");return{render3DFrames:m}},__vite__mapDeps([3,1,4,5,6,2,7,8]));await _("modelFrames",c("modelFrames"),()=>t(a,i,n,void 0,d))}if(k(s,"titleFrames")){const{renderTitleFrames:t}=await f(async()=>{const{renderTitleFrames:E}=await import("./titleFrames-BI1DnLBn.js");return{renderTitleFrames:E}},__vite__mapDeps([9,1,10,11,12,13,2,8])),m=[...a,...$(a)];await _("titleFrames",c("titleFrames"),()=>t(m,i,n,void 0,d))}if(k(s,"matteFrames")){const t=await f(()=>import("./rotoMatte-C-2o3vv0.js").then(E=>E.r),__vite__mapDeps([14,1,2,15])),m=[...a,...t.maskedCopies(a)];await _("matteFrames",c("matteFrames"),()=>t.renderMatteFrames(m,l,n))}if(k(s,"windowFrames")){const t=await f(()=>import("./windowFrames-CpqX3kOM.js"),__vite__mapDeps([16,1,14,2,15]));await _("windowFrames",c("windowFrames"),()=>t.renderWindowFrames(a,l,n))}return{frames:n.picked(),failed:w,missingMasks:o.missing}},async gpuExport({clips:a,format:i,tracks:d={},camera:s=null,encode:r=null,range:o,only:n,name:w="film.mp4",softwareEncoder:l=!1}){const u=await f(()=>import("./gpuExport-D31azOQA.js"),__vite__mapDeps([17,1,18,19,20,21,2,22,23,24]));if(l){if(n!=="video"||!await u.canEncodeH264(i))throw Object.assign(new Error("no H.264 encoder in this browser"),{name:"NoEncoder"})}else if(!await u.gpuExportSupported(i,r))throw Object.assign(new Error("no hardware video encoder in this browser"),{name:"NoEncoder"});const{softwareRetry:_}=await f(async()=>{const{softwareRetry:e}=await import("./clientExport-xhoXY6Dh.js");return{softwareRetry:e}},__vite__mapDeps([25,1,18])),c=e=>{try{window.__clipooxProgress?.(e)}catch{}};let t=l;const m=`/__clipoox/out/${encodeURIComponent(w)}`,E=()=>new WritableStream({async write(e){const p=await fetch(`${m}?at=${e.position}`,{method:"PATCH",body:e.data});if(!p.ok)throw new Error(`the film could not be handed over (${p.status})`)}}),g=e=>u.exportOnGpu(a,{format:i,encode:r,tracks:d,camera:s,onProgress:c,software:e,liveMotion:!0,range:o,only:n,sink:E()}),h=e=>{const p=e instanceof Error?`${e.name}: ${e.message}`:String(e);return new Error(`${u.gpuExportStage()||"start"}${o?` (frames ${o.from}–${o.to})`:""}: ${p}`)},y=await g(l).catch(e=>{if(!_(e,u.gpuExportStage(),r))throw h(e);return t=!0,g(!0).catch(p=>{throw h(p)})});let b="";try{const e=document.createElement("canvas").getContext("webgl2"),p=e?.getExtension("WEBGL_debug_renderer_info");b=String(p&&e?e.getParameter(p.UNMASKED_RENDERER_WEBGL):"").slice(0,120)}catch{}return{ms:y.ms,software:t,gpu:b}},async upscale({url:a,kind:i,scale:d=2,model:s="photo",name:r="upscaled.bin"}){const o=await f(()=>import("./engine-BedcnK45.js"),__vite__mapDeps([26,1,27,23,24,28])),n=c=>{try{window.__clipooxProgress?.(c.fraction)}catch{}},w=i==="video"?await o.upscaleVideo(a,{model:s,onProgress:n}):await o.upscaleImage(a,{scale:d,model:s,onProgress:n}),l=`/__clipoox/out/${encodeURIComponent(r)}`,u=new Uint8Array(await w.blob.arrayBuffer()),_=8<<20;for(let c=0;c<u.length;c+=_){const t=await fetch(`${l}?at=${c}`,{method:"PATCH",body:u.subarray(c,Math.min(u.length,c+_))});if(!t.ok)throw new Error(`the file could not be handed over (${t.status})`)}return{width:w.width,height:w.height,duration:w.duration??null,type:w.blob.type,bytes:u.length,backend:w.backend,seconds:w.seconds,soundDropped:!!w.soundDropped}}};window.__layerWorker=D;
@@ -1 +0,0 @@
1
- import{gE as f}from"./remote-C7J0Tqhb.js";import{ib as E,hy as G,ic as L,id as P}from"./remote-C7J0Tqhb.js";import{e as l}from"./skin-DY4QLaBI.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";async function S(o,s,a,m=2e4){let e;for(const t=Date.now()+m;!e&&Date.now()<t;){const i=o.getStage().items.find(r=>r.id===s);if(!i||i.rig!==a)return!1;e=o.engine()?.objects?.children.find(r=>r.userData.id===s)?.children[0],e||await new Promise(r=>setTimeout(r,150))}if(!e)return!1;const p=f(a,{positions:l(e).positions});let n=!1;return o.setStage(t=>({...t,items:t.items.map(i=>i.id===s&&i.rig===a?(n=!0,{...i,rig:p}):i)})),n}export{S as fitLibraryFingers,E as libraryModelFields,G as libraryModelItem,L as libraryRig,P as wantsFingers};