clipoox-render 0.3.0 → 0.4.0

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 (111) hide show
  1. package/dist/server-text/titleRaster.js +23 -4
  2. package/package.json +1 -1
  3. package/scripts/render-local.mjs +229 -229
  4. package/shared/transitionStarterPack.json +355 -0
  5. package/web/assets/{FxEmbed-D7k1ThAF.js → FxEmbed-CGqGi2Lw.js} +1 -1
  6. package/web/assets/{MotionEmbed-DFni5IAh.js → MotionEmbed-C3CZ3_y_.js} +1 -1
  7. package/web/assets/{PluginStore-BrupM_8E.js → PluginStore-DKXZ-jBj.js} +1 -1
  8. package/web/assets/{ShotComposer-BLztjSKy.js → ShotComposer-DFfaYLoV.js} +4 -4
  9. package/web/assets/{TemplateEmbed-BbAimhLj.js → TemplateEmbed-C8pXcPsc.js} +1 -1
  10. package/web/assets/{TimelinePlugins-BI1bE9pX.js → TimelinePlugins-DnkV3i4G.js} +3 -3
  11. package/web/assets/{TimelineShotFx-CQN3WIfN.js → TimelineShotFx-foiuuogg.js} +2 -2
  12. package/web/assets/{TransitionEmbed-CmoIrHVr.js → TransitionEmbed-BueDilY0.js} +1 -1
  13. package/web/assets/{Whiteboard-DMk0unYK.js → Whiteboard-zBsNHh5h.js} +1 -1
  14. package/web/assets/aerial-z34Nww_T.js +2 -0
  15. package/web/assets/{agentTools-qOww5RUs.js → agentTools-ALxghYpf.js} +2 -2
  16. package/web/assets/{analyzerRun-B2FLUp4G.js → analyzerRun-DNwryAlU.js} +1 -1
  17. package/web/assets/{analyzerSandbox-CJVsEhrg.js → analyzerSandbox-A1oFsCrO.js} +1 -1
  18. package/web/assets/{api-QBI5GJTZ.js → api-DUp403BK.js} +57 -57
  19. package/web/assets/auraTrack-BKVZCwNt.js +1 -0
  20. package/web/assets/breakthrough-Cwt8gEwK.js +2 -0
  21. package/web/assets/{cameraPresets-4pFeF2YG.js → cameraPresets-DSOPj4oy.js} +1 -1
  22. package/web/assets/{captionLayout-C67EMVI1.js → captionLayout-EuB59pN_.js} +1 -1
  23. package/web/assets/clientExport-BL1XMTF0.js +1 -0
  24. package/web/assets/{depthEstimate-mnXDZMW-.js → depthEstimate-DOvsY8mn.js} +1 -1
  25. package/web/assets/{directorTools-BOHZjcww.js → directorTools-BkbNYbSq.js} +1 -1
  26. package/web/assets/{distortFrames-Csuj2jHE.js → distortFrames-Drch0LhT.js} +2 -2
  27. package/web/assets/{distortGL-BaXfN0IK.js → distortGL-BlmBZKRU.js} +2 -2
  28. package/web/assets/{editTools-m0VGPmfF.js → editTools-BcGinqHC.js} +1 -1
  29. package/web/assets/exportEncode-MUwVTI52.js +1 -0
  30. package/web/assets/{exportGlb-CLfTnbMG.js → exportGlb-SIXFRRJM.js} +1 -1
  31. package/web/assets/{faceTracker-W0iZSiMe.js → faceTracker-DCbZbLMc.js} +1 -1
  32. package/web/assets/fightDirector-hlF1JS_z.js +1 -0
  33. package/web/assets/fightDrama-fHN5EXk3.js +2 -0
  34. package/web/assets/{frameSink-BGRj7wqY.js → frameSink-BvOXjLuw.js} +3 -3
  35. package/web/assets/{gpuCompose-CIEoLFem.js → gpuCompose-CNkLwpbZ.js} +1 -1
  36. package/web/assets/gpuExport-DQB6x4eh.js +194 -0
  37. package/web/assets/{handMatte-mHxZwLZD.js → handMatte-BD7OE3Zc.js} +1 -1
  38. package/web/assets/{handTracker-dTVeSUzt.js → handTracker-BumGtRCW.js} +2 -2
  39. package/web/assets/{index-D7M5t2re.js → index-CuaB7Y0L.js} +1 -1
  40. package/web/assets/{layer-worker-Cp0pjurp.js → layer-worker-DxPMMKIZ.js} +3 -3
  41. package/web/assets/library-CyjJ8nGG.js +1 -0
  42. package/web/assets/{lottieLayer-CDCGeJyv.js → lottieLayer-1ET89OUr.js} +5 -5
  43. package/web/assets/{lottie_light_canvas-BblLU4nU.js → lottie_light_canvas-DD9pkFL8.js} +1 -1
  44. package/web/assets/{main-CVRIuDW2.js → main-BKjBWQik.js} +91 -91
  45. package/web/assets/{main-BQ8IY0WV.css → main-Ca_CVxMz.css} +1 -1
  46. package/web/assets/mapBake-DLoBt_k5.js +1 -0
  47. package/web/assets/{maskTrack-Dtv6Jr06.js → maskTrack-C2SJbDGO.js} +1 -1
  48. package/web/assets/{matteFixRun-BLDH2AjH.js → matteFixRun-BdHKC3m5.js} +1 -1
  49. package/web/assets/{objectLocate-Cy3IFBSF.js → objectLocate-bZtc5AJo.js} +1 -1
  50. package/web/assets/{pendingMatte-C2AWApuv.js → pendingMatte-mlyLLZCT.js} +2 -2
  51. package/web/assets/{personAi-DPUnoymj.js → personAi-CUNQeseG.js} +2 -2
  52. package/web/assets/plateCamera-_jP1xXnj.js +1 -0
  53. package/web/assets/{plateCameraMatch-Chk-ZjDi.js → plateCameraMatch-rr0oUwQ2.js} +2 -2
  54. package/web/assets/{plateFollow-B9_QTgvo.js → plateFollow-BjvtcT8q.js} +2 -2
  55. package/web/assets/{plateMatte-BiqyI_8x.js → plateMatte-BqyL8cQZ.js} +2 -2
  56. package/web/assets/{pluginAutomation-5DYldFrb.js → pluginAutomation-Dp188qm7.js} +1 -1
  57. package/web/assets/{poseTracker-PuI8vWpR.js → poseTracker-DDGDhhMF.js} +1 -1
  58. package/web/assets/{productTools-B1h5cgyt.js → productTools-CRgI88-O.js} +2 -2
  59. package/web/assets/remote-Dva2qg58.js +1241 -0
  60. package/web/assets/{rigTrack-CUt4O67J.js → rigTrack-UYZU4P-e.js} +1 -1
  61. package/web/assets/{rotoMaskStore-DIi45swK.js → rotoMaskStore-BxyxB2bD.js} +1 -1
  62. package/web/assets/{rotoMatte-013RKqHu.js → rotoMatte-BdYa8FSB.js} +1 -1
  63. package/web/assets/{rotoscope-d_TUxa-J.js → rotoscope-DDixNQCt.js} +1 -1
  64. package/web/assets/{shot-worker-B1iZT6F5.js → shot-worker-D9sZS6bn.js} +1 -1
  65. package/web/assets/{shotFxAgent-BDfe73TP.js → shotFxAgent-7RQNtEe4.js} +2 -2
  66. package/web/assets/{skin-GDY3QPkV.js → skin-CVwmK130.js} +1 -1
  67. package/web/assets/{spark.module-DdwuJ_hb.js → spark.module-B34aiScb.js} +1 -1
  68. package/web/assets/{spellDuel-DjNN00bv.js → spellDuel-BkweL6pI.js} +2 -2
  69. package/web/assets/{store-2zneEhhu.js → store-75tQUvPT.js} +1 -1
  70. package/web/assets/surfaceLight-DhU-zgNL.js +1 -0
  71. package/web/assets/{surfacePin-zDPmq-hH.js → surfacePin-ObK6QgDm.js} +2 -2
  72. package/web/assets/textAnimators-nVSz_sZo.js +1 -0
  73. package/web/assets/{thumb-byAKvhQP.js → thumb-r6dlZprA.js} +1 -1
  74. package/web/assets/{timeline3d-YIIk_Kn2.js → timeline3d-246tBEJl.js} +2 -2
  75. package/web/assets/timeline3dExport-T57qnWi9.js +1 -0
  76. package/web/assets/{timelineComp-B73i_8vD.js → timelineComp-BcewYGR2.js} +1 -1
  77. package/web/assets/{timelineProps-B2pnudeT.js → timelineProps-CJzzAWWO.js} +1 -1
  78. package/web/assets/{timelineText-BcL4Pw3C.js → timelineText-BzUhNWPB.js} +1 -1
  79. package/web/assets/titleArt-B8DVR58F.js +5 -0
  80. package/web/assets/{titleFrameBudget-Cml-MO53.js → titleFrameBudget-BYRZAQPs.js} +260 -260
  81. package/web/assets/titleFrames-BVgm601q.js +1 -0
  82. package/web/assets/{tool-Bt9bclIf.js → tool-CAGU3dUa.js} +1 -1
  83. package/web/assets/{tools-BXeJbgZJ.js → tools-DVaOkokV.js} +1 -1
  84. package/web/assets/{toonTools-u7Y9fdEZ.js → toonTools-CfGTR_H1.js} +2 -2
  85. package/web/assets/{trackAnchor-9MnVHe4S.js → trackAnchor-DzUt1r5Q.js} +1 -1
  86. package/web/assets/{userFonts-BHduCNtc.js → userFonts-DzY0A4bD.js} +1 -1
  87. package/web/assets/{vfxAlpha-DpV4rbI-.js → vfxAlpha-DQJOaZ9v.js} +2 -2
  88. package/web/assets/{vfxBackground-Ddviync5.js → vfxBackground-DiktQFOD.js} +2 -2
  89. package/web/assets/{videoExport-z5WjM0hw.js → videoExport-Ce0ElSQR.js} +1 -1
  90. package/web/assets/{views-CsrYzCSR.js → views-V3si1lOz.js} +1 -1
  91. package/web/assets/weaponDuel-D6sLVGmG.js +1 -0
  92. package/web/assets/{windowFrames-BQEWQkEs.js → windowFrames-D_2QJCJJ.js} +1 -1
  93. package/web/layer-worker.html +3 -3
  94. package/web/assets/aerial-DT_gUtSh.js +0 -2
  95. package/web/assets/auraTrack-CEs_Q9EP.js +0 -1
  96. package/web/assets/breakthrough-DvkxvNK9.js +0 -2
  97. package/web/assets/clientExport-C4VgAJtO.js +0 -1
  98. package/web/assets/exportEncode-D9OT7_5k.js +0 -1
  99. package/web/assets/fightDirector-CECPf2iH.js +0 -1
  100. package/web/assets/fightDrama-CqNoa5XI.js +0 -2
  101. package/web/assets/gpuExport-uyOAyrhm.js +0 -190
  102. package/web/assets/library-Dsz_MLyd.js +0 -1
  103. package/web/assets/mapBake-CNMOKXA7.js +0 -1
  104. package/web/assets/plateCamera-C96L5GKm.js +0 -1
  105. package/web/assets/remote-BJdzzFZg.js +0 -1241
  106. package/web/assets/surfaceLight-B_SYg_f8.js +0 -1
  107. package/web/assets/textAnimators-Bdt5LWXk.js +0 -1
  108. package/web/assets/timeline3dExport-CEH1RjNf.js +0 -1
  109. package/web/assets/titleArt-hb_T45WJ.js +0 -5
  110. package/web/assets/titleFrames-Dw0PEBdV.js +0 -1
  111. package/web/assets/weaponDuel-CLLgv5A4.js +0 -1
@@ -1 +1 @@
1
- import{n3 as T,lC as U,bM as V,bP as Z,bR as R,bQ as H,n4 as W,n5 as J}from"./titleFrameBudget-Cml-MO53.js";const rt=(n,a,e)=>Math.round(Math.min(4e7,Math.max(2e6,n*a*e*.16)));function at(n,a,e,t,o,r){const i=n.crop||{left:0,right:0,top:0,bottom:0},m=Math.max(2,Math.floor(a*(1-i.left-i.right)/2)*2),c=Math.max(2,Math.floor(e*(1-i.top-i.bottom)/2)*2);let h=i.left,y=i.top,s=m/a,f=c/e,w=0,u=0,l=t,x=o;const d=T(n,t,o);if(d){const b=Math.max(d.w/m,d.h/c),v=d.w/b/a,z=d.h/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z,w=d.x,u=d.y,l=d.w,x=d.h}else if(n.fit==="cover"){const b=Math.max(t/m,o/c),v=t/b/a,z=o/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z}else{const b=Math.min(t/m,o/c);l=Math.round(m*b),x=Math.round(c*b),w=(t-l)/2,u=(o-x)/2}n.flipX&&(h+=s,s=-s),n.flipY&&(y+=f,f=-f);const M=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),p=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),k=Math.trunc((t-M)/2+r.x*t),g=Math.trunc((o-p)/2+r.y*o);return{dst:[(k+w*M/t)/t,(g+u*p/o)/o,l*M/t/t,x*p/o/o],src:[h,y,s,f]}}function et(n,a){const e=Math.min(n.visualFadeIn||0,n.duration),t=Math.min(n.visualFadeOut||0,n.duration);return e>a+1e-5?{k:Math.min(1,Math.max(0,a/e)),white:n.fadeInColor==="white"}:t>0&&a>n.duration-t+1e-5?{k:Math.min(1,Math.max(0,(n.duration-a)/t)),white:n.fadeOutColor==="white"}:{k:1,white:!1}}function tt(n,a=48e3,e=.95){const t=n[0].length,o=Math.round(a*.005),r=Math.exp(-1/(a*.05)),i=new Float32Array(t);for(let h=0;h<t;h++){let y=0;for(const s of n)y=Math.max(y,Math.abs(s[h]));i[h]=y>e?e/y:1}let m=1;const c=[];for(let h=0;h<t+o;h++){if(h<t){for(;c.length&&i[c[c.length-1]]>=i[h];)c.pop();c.push(h)}const y=h-o;if(y<0)continue;for(;c.length&&c[0]<y;)c.shift();const s=c.length?i[c[0]]:1;m=Math.min(s,1-(1-m)*r);for(const f of n)f[y]*=m}}function st(n){if(n.colorBypass)return null;const a=(n.brightness??1)*2**(n.exposure??0),e=n.contrast??1,t=n.saturation??1,o=n.hue??0;if(a===1&&e===1&&t===1&&o===0)return null;const{sat:r,rot:i}=U(t,o);return{bright:a,contrast:e,sat:r,rot:i}}function it(n,a){const e=-J*255/(255-J);return(Array.isArray(n.effects)?n.effects:[]).filter(t=>!t.off&&t.amount>.001).flatMap(t=>{if(t.type==="blur")return[{type:"blur",sigma:V(t.amount,a)}];if(t.type==="glow")return[{type:"glow",sigma:Z(a),lo:e/255,k:(255-e)/255,amount:+t.amount.toFixed(4)}];if(t.type==="rgb-split")return[{type:"shift",px:R(t.amount,a)}];if(t.type==="light-burst")return[{type:"burst",amount:t.amount,lo:e/255,k:(255-e)/255}];if(t.type==="pixelate"){const r=H(t.amount,a);return r>1?[{type:"pixel",block:r}]:[]}const o=W(t.type,t.amount);return o?[{type:"colour",m:o.m,lut:o.lut,key:`${t.type}:${t.amount}`}]:[]})}function ht(n,a,e=48e3){const t=n[0]?.length??0,o=Math.max(1,Math.round(t/a));if(Math.abs(a-1)<1e-9||t<2)return n.map(u=>u.slice(0,o));const r=2*Math.round(e*.02),i=r/2,m=Math.round(e*.01),c=4,h=new Float32Array(r);for(let u=0;u<r;u++)h[u]=.5-.5*Math.cos(2*Math.PI*u/r);const y=new Float32Array(t);for(const u of n)for(let l=0;l<t;l++)y[l]+=u[l]/n.length;const s=n.map(()=>new Float32Array(o+r)),f=new Float32Array(o+r);let w=0;for(let u=0;u*i<o;u++){const l=u*i,x=Math.min(t-1,Math.round(l*a));let d=x;if(u>0){const M=w+i;let p=-1/0;for(let k=-m;k<=m;k+=2){const g=x+k;if(g<0||g+i>t||M+i>t)continue;let F=0;for(let b=0;b<i;b+=c)F+=y[g+b]*y[M+b];F>p&&(p=F,d=g)}}for(let M=0;M<n.length;M++){const p=n[M],k=s[M];for(let g=0;g<r&&d+g<t;g++)k[l+g]+=p[d+g]*h[g]}for(let M=0;M<r&&d+M<t;M++)f[l+M]+=h[M];w=d}return s.map(u=>{const l=new Float32Array(o);for(let x=0;x<o;x++)l[x]=f[x]>.001?u[x]/f[x]:u[x];return l})}function ot(n,a=48e3){if(a!==48e3)throw Error("integratedLoudness: 48 kHz only");const e=n[0].length,t=n.map(s=>{const f=new Float64Array(e),w=new Float64Array(e);let u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=1.53512485958697*s[M]-2.69169618940638*u+1.19839281085285*l+1.69065929318241*x-.73248077421585*d;l=u,u=s[M],d=x,x=p,f[M]=p}u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=f[M]-2*u+l+1.99004745483398*x-.99007225036621*d;l=u,u=f[M],d=x,x=p,w[M]=p*p}return w}),o=.4*a,r=.1*a,i=[];for(let s=0;s+o<=e;s+=r){let f=0;for(const w of t){let u=0;for(let l=s;l<s+o;l++)u+=w[l];f+=u/o}i.push(f)}const m=s=>-.691+10*Math.log10(s),c=i.filter(s=>m(s)>-70);if(!c.length)return-1/0;const h=m(c.reduce((s,f)=>s+f,0)/c.length)-10,y=c.filter(s=>m(s)>h);return m(y.reduce((s,f)=>s+f,0)/y.length)}function ct(n,a,e=48e3){const t=ot(n,e);if(!Number.isFinite(t))return t;const o=10**((a-t)/20);for(const r of n)for(let i=0;i<r.length;i++)r[i]*=o;return tt(n,e,10**(-1.5/20)),t}function ut([n,a,e,t],o,r){return[(2+n*(o-4))/o,(2+a*(r-4))/r,e*(o-4)/o,t*(r-4)/r]}function lt(n,a,e){const[[t,o],[r,i],[m,c],[h,y]]=n,s=t-r+h-m,f=o-i+y-c;let w,u,l,x,d,M,p,k;if(Math.abs(s)<1e-9&&Math.abs(f)<1e-9)w=r-t,u=h-r,l=t,x=i-o,d=y-i,M=o,p=0,k=0;else{const K=r-h,N=m-h,_=i-y,$=c-y,j=K*$-N*_;p=(s*$-N*f)/j,k=(K*f-s*_)/j,w=r-t+p*r,u=m-t+k*m,l=t,x=i-o+p*i,d=c-o+k*c,M=o}const g=[w/a,u/e,l,x/a,d/e,M,p/a,k/e,1],[F,b,v,z,L,X,I,B,C]=g,E=L*C-X*B,G=-(b*C-v*B),Q=b*X-v*L,P=-(z*C-X*I),O=F*C-v*I,q=-(F*X-v*z),S=z*B-L*I,Y=-(F*B-b*I),D=F*L-b*z,A=F*E+b*P+v*S;return[E/A,G/A,Q/A,P/A,O/A,q/A,S/A,Y/A,D/A]}function ft(n,a,e){const t=n.crop||{left:0,right:0,top:0,bottom:0},o=Math.max(2,Math.floor(a*(1-t.left-t.right)/2)*2),r=Math.max(2,Math.floor(e*(1-t.top-t.bottom)/2)*2);let i=t.left,m=t.top,c=o/a,h=r/e;return n.flipX&&(i+=c,c=-c),n.flipY&&(m+=h,h=-h),[i,m,c,h]}function Mt(n,a,e,t,o,r,i){const m=n.crop||{left:0,right:0,top:0,bottom:0},c=Math.max(2,Math.floor(a*(1-m.left-m.right)/2)*2),h=Math.max(2,Math.floor(e*(1-m.top-m.bottom)/2)*2),y=(r.rot||0)*Math.PI/180,s=Math.cos(y),f=Math.sin(y),w=O=>Math.ceil(O/2)*2,u=w(Math.hypot(c,h)),l=i?u:w(c*Math.abs(s)+h*Math.abs(f)),x=i?u:w(c*Math.abs(f)+h*Math.abs(s)),d=Math.round(o*l/x),M=Math.round(t*x/l),p=n.fit==="cover",k=p?Math.max(d,t):Math.min(d,t),g=p?Math.max(M,o):Math.min(M,o),F=p?-Math.trunc((k-t)/2):Math.trunc((t-k)/2),b=p?-Math.trunc((g-o)/2):Math.trunc((o-g)/2),v=k/l,z=g/x,L=F+k/2,X=b+g/2,I=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),B=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),C=Math.trunc((t-I)/2+r.x*t),E=Math.trunc((o-B)/2+r.y*o),G=I/t,Q=B/o,P=(O,q)=>{const S=(O-2)/(t-4)*c-c/2,Y=(q-2)/(o-4)*h-h/2,D=L+(S*s-Y*f)*v,A=X+(S*f+Y*s)*z;return[C+D*G,E+A*Q]};return{quad:[P(0,0),P(t,0),P(0,o),P(t,o)],clip:p?[C,E,I,B]:null}}function mt(n,a,e,t){const o=t*Math.PI/180,r=Math.cos(o),i=Math.sin(o),m=a/2,c=e/2,h=(y,s)=>{const f=(y-2)/(a-4),w=(s-2)/(e-4),u=(n[0]+f*n[2])*a-m,l=(n[1]+w*n[3])*e-c;return[m+u*r-l*i,c+u*i+l*r]};return[h(0,0),h(a,0),h(0,e),h(a,e)]}export{at as a,it as b,ht as c,tt as d,et as f,rt as g,st as l,ct as n,ut as p,Mt as r,ft as s,mt as t,lt as w};
1
+ import{nb as T,lI as U,bO as V,bR as Z,bT as R,bS as H,nc as W,nd as J}from"./titleFrameBudget-BYRZAQPs.js";const rt=(n,a,e)=>Math.round(Math.min(4e7,Math.max(2e6,n*a*e*.16)));function at(n,a,e,t,o,r){const i=n.crop||{left:0,right:0,top:0,bottom:0},m=Math.max(2,Math.floor(a*(1-i.left-i.right)/2)*2),c=Math.max(2,Math.floor(e*(1-i.top-i.bottom)/2)*2);let h=i.left,y=i.top,s=m/a,f=c/e,w=0,u=0,l=t,x=o;const d=T(n,t,o);if(d){const b=Math.max(d.w/m,d.h/c),v=d.w/b/a,z=d.h/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z,w=d.x,u=d.y,l=d.w,x=d.h}else if(n.fit==="cover"){const b=Math.max(t/m,o/c),v=t/b/a,z=o/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z}else{const b=Math.min(t/m,o/c);l=Math.round(m*b),x=Math.round(c*b),w=(t-l)/2,u=(o-x)/2}n.flipX&&(h+=s,s=-s),n.flipY&&(y+=f,f=-f);const M=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),p=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),k=Math.trunc((t-M)/2+r.x*t),g=Math.trunc((o-p)/2+r.y*o);return{dst:[(k+w*M/t)/t,(g+u*p/o)/o,l*M/t/t,x*p/o/o],src:[h,y,s,f]}}function et(n,a){const e=Math.min(n.visualFadeIn||0,n.duration),t=Math.min(n.visualFadeOut||0,n.duration);return e>a+1e-5?{k:Math.min(1,Math.max(0,a/e)),white:n.fadeInColor==="white"}:t>0&&a>n.duration-t+1e-5?{k:Math.min(1,Math.max(0,(n.duration-a)/t)),white:n.fadeOutColor==="white"}:{k:1,white:!1}}function tt(n,a=48e3,e=.95){const t=n[0].length,o=Math.round(a*.005),r=Math.exp(-1/(a*.05)),i=new Float32Array(t);for(let h=0;h<t;h++){let y=0;for(const s of n)y=Math.max(y,Math.abs(s[h]));i[h]=y>e?e/y:1}let m=1;const c=[];for(let h=0;h<t+o;h++){if(h<t){for(;c.length&&i[c[c.length-1]]>=i[h];)c.pop();c.push(h)}const y=h-o;if(y<0)continue;for(;c.length&&c[0]<y;)c.shift();const s=c.length?i[c[0]]:1;m=Math.min(s,1-(1-m)*r);for(const f of n)f[y]*=m}}function st(n){if(n.colorBypass)return null;const a=(n.brightness??1)*2**(n.exposure??0),e=n.contrast??1,t=n.saturation??1,o=n.hue??0;if(a===1&&e===1&&t===1&&o===0)return null;const{sat:r,rot:i}=U(t,o);return{bright:a,contrast:e,sat:r,rot:i}}function it(n,a){const e=-J*255/(255-J);return(Array.isArray(n.effects)?n.effects:[]).filter(t=>!t.off&&t.amount>.001).flatMap(t=>{if(t.type==="blur")return[{type:"blur",sigma:V(t.amount,a)}];if(t.type==="glow")return[{type:"glow",sigma:Z(a),lo:e/255,k:(255-e)/255,amount:+t.amount.toFixed(4)}];if(t.type==="rgb-split")return[{type:"shift",px:R(t.amount,a)}];if(t.type==="light-burst")return[{type:"burst",amount:t.amount,lo:e/255,k:(255-e)/255}];if(t.type==="pixelate"){const r=H(t.amount,a);return r>1?[{type:"pixel",block:r}]:[]}const o=W(t.type,t.amount);return o?[{type:"colour",m:o.m,lut:o.lut,key:`${t.type}:${t.amount}`}]:[]})}function ht(n,a,e=48e3){const t=n[0]?.length??0,o=Math.max(1,Math.round(t/a));if(Math.abs(a-1)<1e-9||t<2)return n.map(u=>u.slice(0,o));const r=2*Math.round(e*.02),i=r/2,m=Math.round(e*.01),c=4,h=new Float32Array(r);for(let u=0;u<r;u++)h[u]=.5-.5*Math.cos(2*Math.PI*u/r);const y=new Float32Array(t);for(const u of n)for(let l=0;l<t;l++)y[l]+=u[l]/n.length;const s=n.map(()=>new Float32Array(o+r)),f=new Float32Array(o+r);let w=0;for(let u=0;u*i<o;u++){const l=u*i,x=Math.min(t-1,Math.round(l*a));let d=x;if(u>0){const M=w+i;let p=-1/0;for(let k=-m;k<=m;k+=2){const g=x+k;if(g<0||g+i>t||M+i>t)continue;let F=0;for(let b=0;b<i;b+=c)F+=y[g+b]*y[M+b];F>p&&(p=F,d=g)}}for(let M=0;M<n.length;M++){const p=n[M],k=s[M];for(let g=0;g<r&&d+g<t;g++)k[l+g]+=p[d+g]*h[g]}for(let M=0;M<r&&d+M<t;M++)f[l+M]+=h[M];w=d}return s.map(u=>{const l=new Float32Array(o);for(let x=0;x<o;x++)l[x]=f[x]>.001?u[x]/f[x]:u[x];return l})}function ot(n,a=48e3){if(a!==48e3)throw Error("integratedLoudness: 48 kHz only");const e=n[0].length,t=n.map(s=>{const f=new Float64Array(e),w=new Float64Array(e);let u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=1.53512485958697*s[M]-2.69169618940638*u+1.19839281085285*l+1.69065929318241*x-.73248077421585*d;l=u,u=s[M],d=x,x=p,f[M]=p}u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=f[M]-2*u+l+1.99004745483398*x-.99007225036621*d;l=u,u=f[M],d=x,x=p,w[M]=p*p}return w}),o=.4*a,r=.1*a,i=[];for(let s=0;s+o<=e;s+=r){let f=0;for(const w of t){let u=0;for(let l=s;l<s+o;l++)u+=w[l];f+=u/o}i.push(f)}const m=s=>-.691+10*Math.log10(s),c=i.filter(s=>m(s)>-70);if(!c.length)return-1/0;const h=m(c.reduce((s,f)=>s+f,0)/c.length)-10,y=c.filter(s=>m(s)>h);return m(y.reduce((s,f)=>s+f,0)/y.length)}function ct(n,a,e=48e3){const t=ot(n,e);if(!Number.isFinite(t))return t;const o=10**((a-t)/20);for(const r of n)for(let i=0;i<r.length;i++)r[i]*=o;return tt(n,e,10**(-1.5/20)),t}function ut([n,a,e,t],o,r){return[(2+n*(o-4))/o,(2+a*(r-4))/r,e*(o-4)/o,t*(r-4)/r]}function lt(n,a,e){const[[t,o],[r,i],[m,c],[h,y]]=n,s=t-r+h-m,f=o-i+y-c;let w,u,l,x,d,M,p,k;if(Math.abs(s)<1e-9&&Math.abs(f)<1e-9)w=r-t,u=h-r,l=t,x=i-o,d=y-i,M=o,p=0,k=0;else{const N=r-h,Q=m-h,_=i-y,$=c-y,j=N*$-Q*_;p=(s*$-Q*f)/j,k=(N*f-s*_)/j,w=r-t+p*r,u=m-t+k*m,l=t,x=i-o+p*i,d=c-o+k*c,M=o}const g=[w/a,u/e,l,x/a,d/e,M,p/a,k/e,1],[F,b,v,z,O,P,I,B,C]=g,S=O*C-P*B,G=-(b*C-v*B),q=b*P-v*O,L=-(z*C-P*I),X=F*C-v*I,D=-(F*P-v*z),E=z*B-O*I,Y=-(F*B-b*I),K=F*O-b*z,A=F*S+b*L+v*E;return[S/A,G/A,q/A,L/A,X/A,D/A,E/A,Y/A,K/A]}function ft(n,a,e){const t=n.crop||{left:0,right:0,top:0,bottom:0},o=Math.max(2,Math.floor(a*(1-t.left-t.right)/2)*2),r=Math.max(2,Math.floor(e*(1-t.top-t.bottom)/2)*2);let i=t.left,m=t.top,c=o/a,h=r/e;return n.flipX&&(i+=c,c=-c),n.flipY&&(m+=h,h=-h),[i,m,c,h]}function Mt(n,a,e,t,o,r,i){const m=n.crop||{left:0,right:0,top:0,bottom:0},c=Math.max(2,Math.floor(a*(1-m.left-m.right)/2)*2),h=Math.max(2,Math.floor(e*(1-m.top-m.bottom)/2)*2),y=(r.rot||0)*Math.PI/180,s=Math.cos(y),f=Math.sin(y),w=X=>Math.ceil(X/2)*2,u=w(Math.hypot(c,h)),l=i?u:w(c*Math.abs(s)+h*Math.abs(f)),x=i?u:w(c*Math.abs(f)+h*Math.abs(s)),d=Math.round(o*l/x),M=Math.round(t*x/l),p=n.fit==="cover",k=p?Math.max(d,t):Math.min(d,t),g=p?Math.max(M,o):Math.min(M,o),F=p?-Math.trunc((k-t)/2):Math.trunc((t-k)/2),b=p?-Math.trunc((g-o)/2):Math.trunc((o-g)/2),v=k/l,z=g/x,O=F+k/2,P=b+g/2,I=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),B=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),C=Math.trunc((t-I)/2+r.x*t),S=Math.trunc((o-B)/2+r.y*o),G=I/t,q=B/o,L=(X,D)=>{const E=(X-2)/(t-4)*c-c/2,Y=(D-2)/(o-4)*h-h/2,K=O+(E*s-Y*f)*v,A=P+(E*f+Y*s)*z;return[C+K*G,S+A*q]};return{quad:[L(0,0),L(t,0),L(0,o),L(t,o)],clip:p?[C,S,I,B]:null}}function mt(n,a,e,t){const o=t*Math.PI/180,r=Math.cos(o),i=Math.sin(o),m=a/2,c=e/2,h=(y,s)=>{const f=(y-2)/(a-4),w=(s-2)/(e-4),u=(n[0]+f*n[2])*a-m,l=(n[1]+w*n[3])*e-c;return[m+u*r-l*i,c+u*i+l*r]};return[h(0,0),h(a,0),h(0,e),h(a,e)]}export{at as a,it as b,ht as c,tt as d,et as f,rt as g,st as l,ct as n,ut as p,Mt as r,ft as s,mt as t,lt as w};
@@ -0,0 +1,194 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/titleFrames-BVgm601q.js","assets/titleFrameBudget-BYRZAQPs.js","assets/titleArt-B8DVR58F.js","assets/textAnimators-nVSz_sZo.js","assets/lottieLayer-1ET89OUr.js","assets/rigTrack-UYZU4P-e.js","assets/api-DUp403BK.js","assets/frameSink-BvOXjLuw.js","assets/timeline3dExport-T57qnWi9.js","assets/timeline3d-246tBEJl.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/rotoMatte-BdYa8FSB.js","assets/store-75tQUvPT.js","assets/captionLayout-EuB59pN_.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 Ko,fF as Wo,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 Ur,cq as kr,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 Kr,a8 as Wr,a6 as Mt,lJ as to,eN as Qr,lK as Jr,el as Zr,lL as ei,lM as ti}from"./titleFrameBudget-BYRZAQPs.js";import{b as oi,e as ri,a as ii}from"./timelineComp-BcewYGR2.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 Uo,d as ci}from"./gpuCompose-CNkLwpbZ.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-MUwVTI52.js";import{c as hi}from"./distortGL-BlmBZKRU.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-BCR9Bqgo.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-BwZzMbp-.js";import"./api-DUp403BK.js";const Di=p=>p.kind==="image"&&!!p.title?.text&&!p.url&&!Zt(p)&&!Mo(p),Ht=p=>cr(p)||Di(p),Ct=48e3,ko=192e3,Ui=4,Po=(p,g)=>g?.name==="AbortError"||p>=Ui?null:Math.min(2**(p-1),4);async function ki(p,g){for(let w=1;;w++){let e;try{e=await fetch(p,{signal:g})}catch(z){const E=g?.aborted?null:Po(w,z);if(E===null)throw z;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:ko}).catch(()=>!1),ka=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:z}=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:z},ro),framerate:z,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 z=this.frames.get(w);z||(z=[],this.frames.set(w,z)),z.push(e)}}async function _o(p,g,w,e,z,E,N){const A=g.get(w.url);if(!A)return null;if(So(w)&&!w._still){const I=`${w.id}
3
+ remap
4
+ ${E}`,X=Math.round((e-E)*z);let $=p.get(I);if(!$){const te=A.samplesAtTimestamps(hr(w,E-w.start,Math.max(1,Math.round(N*z)),z))[Symbol.asyncIterator]();$={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(I,$)}for(;($.idx??0)<=X;){const te=await $.iterator.next();if($.idx=($.idx??0)+1,te.done)break;te.value&&te.value!==$.current&&($.current?.close(),$.current=te.value)}return $.current}const W=!!(w._still||w.freeze),re=W?1:w.playbackRate||1,ae=!W&&Do(w),me=ae?Er(w,E,N).start:(w.inPoint||0)+(W?0:(E-w.start)*re),xe=`${w.id}
5
+ ${W?"still":E}`;let d=p.get(xe);if(!d){const I=A.samples(Math.max(0,me-.5))[Symbol.asyncIterator]();if(d={iterator:I,peek:null,current:null,ts0:me,next:async()=>{const X=await I.next();return X.done?null:X.value}},d.peek=await d.next(),!W){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 X=O=>Number(O.toFixed(6)),$=E-w.start,te=br(w,$,$+N),oe=te.slice(0,-1).map(([O,_e],Te)=>{const[Oe,we]=te[Te+1];return{xa:X(O),dx:X(Oe-O),k:Oe-O>1e-9?X((we-_e)/(Oe-O)):0}}).filter(O=>O.dx>1e-9);d.out=O=>oe.reduce((_e,Te)=>_e+Math.min(Te.dx,Math.max(0,O-Te.xa))*Te.k,0)}p.set(xe,d)}if(W){const I=Math.round(me*z);for(;d.peek&&Math.round(d.peek.timestamp*z)<=I;)d.current?.close(),d.current=d.peek,d.peek=await d.next();return d.current??d.peek}const y=Math.round((e-E)*z),_=I=>d.out?d.out(I-d.ts0):(I-d.ts0)/re;for(;d.peek&&Math.round(_(d.peek.timestamp)*z)<=y;)d.current?.close(),d.current=d.peek,d.peek=await d.next();return d.current??d.peek}const Bi=`#version 300 es
6
+ in vec2 p;uniform vec4 dst;uniform vec4 src;out vec2 uv;
7
+ 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
8
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform float alpha;uniform float fade;uniform float white;
9
+ uniform float bright;uniform float contrast;uniform mat3 sat;uniform mat3 rot;uniform float colour;out vec4 o;
10
+ uniform sampler2D matte;uniform float useMatte;uniform vec4 mrect;
11
+ // chroma key (shared/chromaKey.js, the server's geq on the decoded picture): alpha = clip((d − similarity) / blend), d = |CbCr − key|
12
+ // / (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
13
+ // key's BT.601 Cb / Cr; then despill (mix 0.5) pulls the green / blue cast back by spill
14
+ uniform vec4 key;uniform vec4 keyOpt;
15
+ // 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
16
+ // mixer, timelineMixer.js mixerLut; ffmpeg lut3d trilinear), each on 8-bit values like the server's lut1d / lut3d
17
+ uniform highp sampler2D lut1;uniform highp sampler3D lut3;uniform float useL1;uniform float useL3;
18
+ 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));
19
+ 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;
20
+ 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;
21
+ 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);}
22
+ void main(){vec4 c=texture(tex,uv);vec3 rgb=c.rgb;
23
+ if(keyOpt.x>.5){vec3 q=floor(rgb*255.+.5);float k=224./255.;
24
+ 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);
25
+ 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);
26
+ 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.;
27
+ c.a*=floor(a*255.)/255.;
28
+ 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);}}}
29
+ if(useMatte>.5)c.a*=texture(matte,(uv-mrect.xy)/mrect.zw).r;
30
+ 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.);}
31
+ 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.;}
32
+ if(useL3>.5)rgb=floor(clamp(tri(floor(rgb*255.+.5)/255.),0.,1.)*255.+.5)/255.;
33
+ rgb=white>.5?1.-(1.-rgb)*fade:rgb*fade;o=vec4(rgb,c.a*alpha);}`,q=`#version 300 es
34
+ in vec2 p;out vec2 uv;void main(){uv=p;gl_Position=vec4(p*2.-1.,0,1);}`,Li=`#version 300 es
35
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 step;uniform float sigma;out vec4 o;
36
+ void main(){int r=min(int(ceil(sigma*3.)),128);vec4 acc=vec4(0);float wsum=0.;
37
+ 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;}
38
+ o=acc/wsum;}`,Ii=`#version 300 es
39
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform float lo;uniform float k;out vec4 o;
40
+ void main(){vec4 c=texture(tex,uv);o=vec4(clamp(lo+c.rgb*k,0.,1.),c.a);}`,Ci=`#version 300 es
41
+ precision highp float;in vec2 uv;uniform sampler2D a;uniform sampler2D b;uniform float amount;out vec4 o;
42
+ void main(){vec4 x=texture(a,uv),y=texture(b,uv);o=mix(x,1.-(1.-x)*(1.-y),amount);}`,Xi=`#version 300 es
43
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 step;uniform float b;uniform int reach;out vec4 o;
44
+ void main(){vec4 acc=texture(tex,uv);float ws=1.;float w=1.;
45
+ 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;}
46
+ o=acc/ws;}`,Oi=`#version 300 es
47
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform float taps[16];uniform int n;uniform vec2 ctr;out vec4 o;
48
+ 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
49
+ 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;
50
+ 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]));}
51
+ acc/=float(n);o=vec4(min(acc.rgb*gain,1.),acc.a);}`,Gi=`#version 300 es
52
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform float gain;out vec4 o;
53
+ void main(){vec4 c=texture(tex,uv);o=vec4(min(c.rgb*gain,1.),c.a);}`,qi=`#version 300 es
54
+ precision highp float;in vec2 uv;uniform sampler2D a;uniform sampler2D b;uniform float w;out vec4 o;
55
+ void main(){o=mix(texture(a,uv),texture(b,uv),w);}`,$i=`#version 300 es
56
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec4 colour;uniform float usetex;out vec4 o;
57
+ void main(){o=usetex>.5?texture(tex,vec2(uv.x,1.-uv.y)):colour;}`,ji=`#version 300 es
58
+ precision highp float;uniform sampler2D tex;uniform mat3 inv;uniform vec2 size;uniform vec4 rnd;uniform float keepPre;out vec4 o;
59
+ // a pinned screen's rounded corners (shared/cornerPin.js pinRoundGraph): the server's geq mask on the stretched plane BEFORE its
60
+ // 2 px inset, at pixel centres, kept at least rnd.z (the portal dive's fade to square corners); rnd.w = on
61
+ float corner(ivec2 i){if(rnd.w<.5)return 1.;vec2 k=size/(size-4.),X=(vec2(i)+.5-2.)*k;
62
+ 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)));
63
+ 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);}
64
+ 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);}
65
+ 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.;
66
+ vec2 f=floor(u),w=u-f;ivec2 i=ivec2(f);
67
+ 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);
68
+ o=keepPre>.5?c:c.a>0.?vec4(c.rgb/c.a,c.a):vec4(0);}`,Hi=`#version 300 es
69
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 size;uniform int kind;uniform float e;uniform float f;uniform float inv;
70
+ uniform vec2 ctr;uniform vec3 csh;uniform float count;out vec4 o;
71
+ 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;
72
+ 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)));
73
+ 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;}}
74
+ else if(kind==3)r=length(vec2(dx,dy))/R;
75
+ else if(kind==4)r=(abs(dx)/max(cx,W-cx)+abs(dy)/max(cy,H-cy))/2.;
76
+ 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);}
77
+ 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.;}
78
+ else{float a=atan(dx,-dy);if(a<0.)a+=6.283185307179586;r=a/6.283185307179586;}
79
+ 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
80
+ 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;
81
+ void main(){vec4 c=texture(tex,uv),v=floor(c*255.+.5);vec3 q=v.rgb;
82
+ 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.);}
83
+ 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.;
84
+ o=vec4(q/255.,c.a);}`,Yi=`#version 300 es
85
+ precision highp float;uniform sampler2D tex;uniform int px;out vec4 o;
86
+ void main(){ivec2 p=ivec2(gl_FragCoord.xy);int W=textureSize(tex,0).x;vec4 c=texelFetch(tex,p,0);
87
+ 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);}`,Ki=`#version 300 es
88
+ precision highp float;uniform sampler2D tex;uniform int b;uniform ivec2 small;out vec4 o;
89
+ 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.;
90
+ 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.;}}
91
+ o=sum/n;}`,Wi=`#version 300 es
92
+ precision highp float;uniform sampler2D small;uniform int b;uniform vec2 size;out vec4 o;
93
+ 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
94
+ 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;
95
+ 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);
96
+ 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)));
97
+ o=vec4(col,a/255.);}`,Ji=`#version 300 es
98
+ precision highp float;uniform sampler2D tex;uniform float harden;out vec4 o;
99
+ 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
100
+ precision highp float;uniform sampler2D tex;uniform ivec2 dir;uniform float sigma;out vec4 o;
101
+ 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.;
102
+ for(int i=-r;i<=r;i++){float w=exp(-float(i*i)/(2.*sigma*sigma));ivec2 q=p+dir*i;
103
+ if(q.x>=0&&q.y>=0&&q.x<n.x&&q.y<n.y)acc+=texelFetch(tex,q,0).r*w;ws+=w;}
104
+ o=vec4(floor(acc/ws*255.+.5)/255.,0,0,1);}`,ea=`#version 300 es
105
+ 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;
106
+ 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);
107
+ float band=floor(x*clamp(2.*(1.-y/max(x,1.)),0.,1.));
108
+ 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);
109
+ 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;
110
+ band=floor(band*floor(255.*m)/255.);}
111
+ o=vec4(band/255.,0,0,1);}`,ta=`#version 300 es
112
+ precision highp float;uniform sampler2D pic;uniform sampler2D band;uniform sampler2D glow;uniform vec3 col;uniform float k;uniform float am;out vec4 o;
113
+ 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);
114
+ float rim=clamp(floor(b+g*k),0.,255.);if(am<255.)rim=floor(rim*am/255.);
115
+ vec4 P=texelFetch(pic,p,0);float ra=rim/255.,oa=ra+P.a*(1.-ra);
116
+ o=vec4(oa>0.?(col*ra+P.rgb*P.a*(1.-ra))/oa:P.rgb,oa);}`,oa=`#version 300 es
117
+ 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
118
+ 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
119
+ precision highp float;uniform sampler2D tex;uniform vec2 big;uniform vec2 small;uniform vec4 q1;uniform vec4 q2;uniform float useQ;
120
+ uniform vec4 w1;uniform vec4 w2;uniform float useW;uniform float inv;out vec4 o;
121
+ 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.);}
122
+ void main(){vec2 X=floor(gl_FragCoord.xy),c=(X+.5)*big/small;vec3 a=vec3(0);
123
+ 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;
124
+ vec3 p=floor(a/4.*255.+.5)/255.;float m=1.;
125
+ 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.;
126
+ 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.);
127
+ 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;
128
+ m*=mh*rp(ch,q2.x,q2.y,q1.w)*rp(l,q2.z,q2.w,q1.w);}
129
+ 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;
130
+ if(w2.w>1.5)m*=clamp(.5-y/w1.w,0.,1.);
131
+ 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.);}}
132
+ if(inv>.5)m=1.-m;o=vec4(floor(255.*m+1e-4)/255.,0,0,1);}`,aa=`#version 300 es
133
+ precision highp float;uniform sampler2D tex;uniform highp sampler2D lut;uniform highp sampler3D t3;uniform float useT;uniform float useL;
134
+ uniform float useS;uniform mat3 sat;uniform float useR;uniform mat3 rot;out vec4 o;
135
+ 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));
136
+ 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;
137
+ 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;
138
+ 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);}
139
+ void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);vec3 g=floor(c.rgb*255.+.5);
140
+ if(useT>.5)g=floor(clamp(tri(g/255.),0.,1.)*255.+.5);
141
+ 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);}
142
+ if(useS>.5)g=floor(clamp(sat*(g/255.),0.,1.)*255.+.5);
143
+ if(useR>.5)g=floor(clamp(rot*(g/255.),0.,1.)*255.+.5);
144
+ o=vec4(g/255.,c.a);}`,na=`#version 300 es
145
+ precision highp float;uniform sampler2D base;uniform sampler2D over;uniform sampler2D mask;uniform vec2 msz;uniform float full;out vec4 o;
146
+ 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;}
147
+ 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);
148
+ o=vec4((q+floor((m*(G-q)+128.)/256.))/255.,b.a);}`,sa=`#version 300 es
149
+ precision highp float;uniform sampler2D tex;uniform float k[9];uniform float rdiv;out vec4 o;
150
+ void main(){ivec2 P=ivec2(gl_FragCoord.xy),S=textureSize(tex,0);vec3 s=vec3(0);
151
+ 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];}
152
+ vec4 c=texelFetch(tex,P,0);o=vec4(clamp(floor(s*rdiv+.5),0.,255.)/255.,c.a);}`,ca=`#version 300 es
153
+ precision highp float;uniform sampler2D tex;uniform sampler2D grain;out vec4 o;
154
+ 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
155
+ precision highp float;uniform sampler2D res;uniform sampler2D outp;uniform sampler2D inp;out vec4 o;
156
+ 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);
157
+ vec3 d=clamp(O-I+128.,0.,255.);o=vec4(clamp(R+d-128.,0.,255.)/255.,r.a);}`,la=`#version 300 es
158
+ precision highp float;uniform sampler2D tex;uniform sampler2D soft;uniform float t;out vec4 o;
159
+ 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);
160
+ 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.);
161
+ o=vec4(clamp(B+d-128.,0.,255.)/255.,c.a);}`,ua=`#version 300 es
162
+ precision highp float;in vec2 uv;uniform sampler2D top;uniform sampler2D bg;uniform int mode;out vec4 o;
163
+ 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;
164
+ if(mode==1){o=vec4(min(vec3(255.),Bp+floor(S*a/255.+.5))/255.,min(1.,a/255.+ab));return;}
165
+ // the backdrop is premultiplied (a comp's own transparent picture, gpuExport frames mode): blended against its straight colour, and
166
+ // where it is transparent the layer shows as itself (W3C / After Effects); an opaque backdrop (ab = 1) is the formula as before
167
+ vec3 B=ab>0.?(ab<1.?floor(Bp/ab+.5):Bp):vec3(0),X;
168
+ if(mode==2)X=255.-floor((255.-B)*(255.-S)/255.);
169
+ else if(mode==3)X=floor(B*S/255.);
170
+ else if(mode==4)X=mix(255.-2.*floor((255.-B)*(255.-S)/255.),2.*floor(B*S/255.),step(B,vec3(127.5)));
171
+ 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.);
172
+ 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
173
+ precision highp float;uniform sampler2D tex;uniform int ss;out vec4 o;
174
+ 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);}}
175
+ c/=float(ss*ss);o=c.a>0.?vec4(c.rgb/c.a,c.a):vec4(0);}`,pa=`#version 300 es
176
+ precision highp float;uniform sampler2D tex;uniform int px;out vec4 o;
177
+ 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;
178
+ 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
179
+ precision highp float;uniform sampler2D tex;uniform vec2 size;uniform vec2 msize;uniform float v;uniform float fr;out vec4 o;
180
+ 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.;}
181
+ 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.));}
182
+ 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;
183
+ vec2 a=clamp(f,vec2(0),msize-1.),b=clamp(f+1.,vec2(0),msize-1.);
184
+ 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);
185
+ 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
186
+ precision highp float;uniform sampler2D tex;uniform vec2 size;uniform float a[8];uniform float sx[8];uniform float sy[8];out vec4 o;
187
+ void main(){vec2 p=vec2(gl_FragCoord.x-.5,size.y-gl_FragCoord.y-.5),c=size*.5-.5;vec4 acc=vec4(0);
188
+ 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;
189
+ 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);}
190
+ o=acc/8.;}`,va=`#version 300 es
191
+ precision highp float;in vec2 uv;uniform sampler2D tex;uniform float w;out vec4 o;
192
+ void main(){vec4 c=texture(tex,uv);o=vec4(mix(c.rgb,1.-c.rgb,w),c.a);}`,ha=`#version 300 es
193
+ 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,z=(p.angle??0)*Math.PI/180,E=Math.cos(z),N=Math.sin(z),A=Ea.indexOf(p.type??""),W=p.type==="grid";return{type:"txMask",kind:W?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??(W?Sr:8)}}function Ao(p,g,w,e,z=0,E){if(!p)return[];const N=W=>Vt(p[W],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 W=_r(w,e),re=ae=>Math.max(2,Math.round(ae/2)*2);A.push({type:"txSpin",a:W.map(ae=>+ae.a.toFixed(6)),sx:W.map(ae=>re(w*ae.scale)/w),sy:W.map(ae=>re(e*ae.scale)/e),w:N("spinBlur")})}if(p.dirBlur){const W=Eo*w/1280,re=W/(1+W);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 W=Eo*w/1280,re=W/(1+W);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(z*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 z=(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,z(e.VERTEX_SHADER,n)),e.attachShader(o,z(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(q,Qi),W=E(q,Ji),re=E(q,Zi),ae=E(q,ea),me=E(q,ta),xe=E(q,oa),d=E(q,ra),y=E(q,ia),_=E(q,Li),I=E(q,Ii),X=E(q,Ci),$=E(q,ha),te=E(q,zi),oe=E(q,aa),O=E(q,na),_e=E(q,sa),Te=E(q,ca),Oe=E(q,la),we=E(q,fa),Ye=E(q,Xi),ze=E(q,Oi),ft=E(q,Gi),Fe=E(q,qi),lt=E(q,$i),Ke=E(q,ji),ye=E(q,Hi),Ge=E(q,Vi),We=E(q,Yi),Ae=E(q,Ki),Le=E(q,Wi),rt=E(q,ua),J=E(q,ma),Ee=E(q,pa),ut=E(q,va),qe=E(q,da),De=E(q,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,Ue=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 U=[],He=!1,nt=null;const St=n=>{const s=Ve(),o=(n+1)%3,l=(n+2)%3;for(const R of U){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(xe,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(U.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($,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 ke=null;const Ve=()=>ke??=[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,Kt=(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(We,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]=Kt(i,v),K=ui(mi.burst*t.amount).map(V=>pi(i,v,V));j(I,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($,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(X,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(I,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(X,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=[],k="";const x=(n,s)=>{if(k!==`${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}}),k=`${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=Ut(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(W,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 C=null,P="",ce=null,Y=[],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 Y)e.deleteTexture(H.tex),e.deleteFramebuffer(H.fb);Y=Array.from({length:7},()=>B(t,c)),Z=`${t}x${c}`}e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,Y[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,G,ht,et)=>{e.bindFramebuffer(e.FRAMEBUFFER,Y[G].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:Y[H].tex}),M=(H,G,ht,et)=>{i(_,G,[v(H)],Be=>{e.uniform1i(Be("tex"),0),e.uniform2f(Be("step"),1/t,0),e.uniform1f(Be("sigma"),et)}),i(_,ht,[v(G)],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,G]of Q.entries()){const ht=V[H];if(H===ht&&Q.some((b,D)=>D>H&&V[D]===H&&K[D])&&(i($,2,[v(u)],b=>e.uniform1i(b("tex"),0)),be.add(H)),!K[H])continue;const et=H!==ht&&be.has(ht)?G.branch:void 0,Be=et?2:u;let Et=se,bt=[1,1];if(G.qualifier){const b=Math.max(2,Math.trunc((t+Mt-1)/Mt)),D=Math.max(2,Math.trunc((c+Mt-1)/Mt)),L=`${b}x${D}`;let ie=a.get(L);ie||(ie=B(b,D),a.set(L,ie));const ee=G.qualifier,de=Math.max(.001,ee.soft??.3),Se=G.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,Y[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,de*60),Math.max(.001,de*.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"),G.invert?1:0),e.drawArrays(e.TRIANGLE_STRIP,0,4),Et=ie.tex,bt=[b*Mt,D*Mt]}else if(!G.whole&&Cr(G)&&G.window?.type!=="person"){const b=`${o.clip}#${H}`,D=`${t}x${c}@${o.local??0}`,L=go,ie=Math.max(2,Math.min(go*2,Math.round(L*c/t)));let ee=ve.get(b);if(ee||(ee={tex:pe(),at:""},ve.set(b,ee)),ee.at!==D){const de=bo(G,o.src,o.local??0,c/t,null),Se=new Uint8Array(L*ie);for(let Tt=0;Tt<ie;Tt++)for(let ge=0;ge<L;ge++)Se[Tt*L+ge]=Math.round(de((ge+.5)/L,(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,L,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(!G.whole){const b=To(G)?o.src?.depthMap:void 0,D=`${o.clip}#${H}@${t}x${c}${b?`@${b.at}:${b.data.length}:${b.data.slice(0,24)}`:""}`;let L=S.get(D);if(!L){const ie=Xr(G,t,c,To(G)?bo(G,o.src,0,c/t):null);L=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,L)}Et=L,bt=[t,c]}const kt=G.adjust??{},no=Or(G),Wt=`${o.clip}#${H}`;let Gt=fe.get(Wt);if(no&&!Gt){const b=new Float32Array(1024);for(let D=0;D<256;D++)["r","g","b"].forEach((L,ie)=>{b[D*4+ie]=+zr(kt,L,D/255,G.wheels,G.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(Wt,Gt)}let gt=null;if(Gr(G)){const b=`${Wt}:${JSON.stringify([G.cst,G.look,G.lut,G.mixer])}`;if(gt=ne.get(b)??null,!gt){const D=qr(G,L=>xi(L));if(!D)throw Error(`LUT "${G.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 L of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_3D,L,e.NEAREST);for(const L of[e.TEXTURE_WRAP_S,e.TEXTURE_WRAP_T,e.TEXTURE_WRAP_R])e.texParameteri(e.TEXTURE_3D,L,e.CLAMP_TO_EDGE);e.activeTexture(e.TEXTURE0),ne.set(b,gt)}}const{sat:No,rot:Lo}=$r(kt.saturation??1,kt.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"),(kt.saturation??1)!==1?1:0),e.uniform1f(b("useR"),(kt.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(L=>L!==b&&L!==D);if((G.blur??0)>0){const b=tt(le),D=tt(le,b);M(le,b,D,Math.max(.1,+((G.blur??0)*jr*t).toFixed(3))),le=D}const so=Hr({sharpness:G.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=G.fx?Vr(G.fx,t):null;if(he&&(he.type==="glow"||he.type==="halation")){const b=tt(le),D=tt(le,b);i(I,b,[v(le)],de=>{e.uniform1i(de("tex"),0),e.uniform1f(de("lo"),he.lo),e.uniform1f(de("k"),he.k)});let L=b;he.tint&&(i(Ge,D,[v(b),{t:at}],de=>{e.uniform1i(de("tex"),0),e.uniform1i(de("lut"),1),e.uniform1f(de("useM"),1),e.uniform1f(de("useL"),0),e.uniform1fv(de("m"),he.tint.flat())}),L=D),M(L,L===b?D:b,L,he.sigma);const ee=6;i(X,ee,[v(le),v(L)],de=>{e.uniform1i(de("a"),0),e.uniform1i(de("b"),1),e.uniform1f(de("amount"),he.amount)}),i($,3,[v(ee)],de=>e.uniform1i(de("tex"),0)),le=3}else if(he?.type==="grain"){const b=Yr(o.frame??0),D=`${b}:${t}x${c}:${he.amp}`;let L=Re.get(D);if(!L){if(Re.size>8){for(const ee of Re.values())e.deleteTexture(ee);Re.clear()}L=pe(),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,t,c,0,e.RED,e.UNSIGNED_BYTE,Kr(b,t,c,he.amp)),e.pixelStorei(e.UNPACK_ALIGNMENT,4),Re.set(D,L)}const ie=tt(le);i(Te,ie,[v(le),{t:L}],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)],L=>{e.uniform1i(L("tex"),0),e.uniform1i(L("soft"),1),e.uniform1f(L("t"),he.t)}),i($,3,[v(6)],L=>e.uniform1i(L("tex"),0)),le=3}else if(he?.type==="swirl"){const b=D=>Math.max(2,Math.round(D/2)*2);for(const D of Wr(t,c,he.deg)){const L=tt(le);i(De,L,[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=L}}const Io=et==="parallel"?2:u,Co=et==="parallel"?6:1-u;i(O,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"),G.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=Y[u].tex,e.bindFramebuffer(e.FRAMEBUFFER,l),e.viewport(R[0],R[1],R[2],R[3]),m&&e.enable(e.BLEND)},Ut=(n,s)=>C?(P!==C.key&&(Pe(n,s,C),P=C.key),"win"):"pic",xt=(n,s,o,l,R,m,t)=>{if(!ct){const M=Ut(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),Ue&&!u?(e.uniform4f(F("key"),Ue.u,Ue.v,Ue.similarity,Ue.blend),e.uniform4f(F("keyOpt"),1,Ue.blue?1:0,Ue.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&&!U.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}ke??=[Me(),Me(),Me()],ue(ke[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||U.length||He){let i=h;u&&(i=(h+1)%3,ue(ke[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,ke[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($,null,[ke[h].tex],i=>e.uniform1i(i("tex"),0));return}e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,ke[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||U.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(Ke,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){Ue=null;return}const[s,o,l]=[1,3,5].map(m=>parseInt(n.color.slice(m,m+2),16)),R=224/255;Ue={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){U=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){C=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(Ke),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i.plane.tex);const K=$e(Ke);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&&!U.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:z=null,signal:E,onProgress:N,frames:A,software:W=!1,liveMotion:re=!1,range:ae,only:me,sink:xe}){const d=performance.now(),{width:y,height:_,fps:I}=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 X=p.filter(r=>!r.disabled&&!Mo(r)),$=co(X),te=Oo(X.reduce((r,f)=>Math.max(r,f.start+f.duration),0)),oe=Math.round(te*I);if(!(oe>0)&&!A)throw Error("Empty timeline");const O=zo(z)?z:null,_e=Go($,e,O?r=>Nr(r,O,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/I+1e-6&&r.start+r.duration>ae.from/I-1e-6),ze=new Pi,ft=[...X.filter(r=>Ht(r)&&!we(r)),...qo(X)].filter(Ye);ft.length&&await(await Pt(async()=>{const{renderTitleFrames:r}=await import("./titleFrames-BVgm601q.js");return{renderTitleFrames:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]))).renderTitleFrames(ft,g,ze,E);const Fe=new Map;if(X.some(r=>we(r)&&Ye(r))){const r=await Pt(()=>import("./titleFrames-BVgm601q.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const f of X.filter(k=>we(k)&&Ye(k)))Fe.set(f.id,r.liveMotion(f,X,g))}X.some(r=>r.kind==="model")&&await(await Pt(async()=>{const{render3DFrames:r}=await import("./timeline3dExport-T57qnWi9.js");return{render3DFrames:r}},__vite__mapDeps([8,1,9,10,11,6,12,7]))).render3DFrames(p.filter(r=>!r.disabled),g,ze,E,z);for(const r of $.filter(f=>f._group&&f.comp)){const f=[],k=Math.max(1,Math.ceil(r.duration*I-1e-6));await ga(ri(ii(r),{W:y,H:_}),{format:g,signal:E,frames:{times:Array.from({length:k},(x,T)=>oi(r,T/I)),push:(x,T)=>{f[x]=T}}}),ze.frames.set(r.id,f)}const lt=performance.now();Oe(),Ne="mattes";const Ke=X.filter(r=>r.mask||r.person),ye=Ke.length?await Pt(()=>import("./rotoMatte-BdYa8FSB.js").then(r=>r.r),__vite__mapDeps([13,1,6,14])):null;ye&&await ye.prepareMattes(Ke);const Ge=ye?document.createElement("canvas"):null;Ne="media";const We=new Map,Ae=new Map,Le=new Map,rt=r=>{let f=We.get(r);return f||(f=new gi({source:new wi(r,{getRetryDelay:Po}),formats:Ti}),We.set(r,f)),f};for(const r of X){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 ki(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 k=Fe.get(r.id);if(k)return{source:await k.frame(Math.round((f-r.start)*I)),w:k.W,h:k.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)*I),Math.ceil(r.duration*I)-1,x.length-1));for(;T>0&&x[T]==="=";)T--;const C=J.get(r.id);if(C&&C.index===T)return C.pic;C?.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=X.filter(r=>$o(r)),qe=ut.length?await Pt(()=>import("./captionLayout-EuB59pN_.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 k="";for(let x=0;x<f.length;x+=32768)k+=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(k)})}`)}}const $e=new Map,F=async(r,f,k)=>{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,I),owner:r},$e.clear(),$e.set(f.start,x)}const T=k-Math.round(f.start*I);let C=-1;for(let S=0;S<x.starts.length&&x.starts[S]<=T;S++)C=S;const P=x.plan.entries[C];if(!P||P.blank)return null;const ce=x.plan.social?x.plan.social.style:fo(r.captionStyle),Y=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(Y,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,k,x)=>{const T=`${r.id}@${f.start}`;let C=mt.get(T);if(!C){const ce=Math.max(1,Math.ceil(f.duration/.1-1e-6)),Y=Array.from({length:ce+1},(S,fe)=>f.start+f.duration*fe/ce),Z=Y.map(S=>Jt(r,S-r.start,y,_)),a=S=>+(+S).toFixed(3);C={ts:Y.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,C)}const P={...x};for(const ce of wt){const Y=C.v[ce];if(Y.every(fe=>fe===Y[0])){P[ce]=Y[0];continue}let Z=C.ts.findIndex((fe,ve)=>ve<C.ts.length-1&&k<C.ts[ve+1]);Z<0&&(Z=C.ts.length-2);const a=+(Y[Z+1]-Y[Z]).toFixed(3),S=C.ts[Z+1]-C.ts[Z];P[ce]=Math.abs(Y[Z+1]-Y[Z])<1e-4?Y[Z]:Y[Z]+a*Math.max(0,Math.min(1,(k-C.ts[Z])/S))}return P},at=new Map,pt=new Map,Ie=(r,f,k,x=r,T="")=>{if(!dr(x))return yo(x,y);const C=`${r.id}${T}@${f.start}`;let P=pt.get(C);P||(P=xr(x,{offset:f.start-r.start,duration:f.duration,fps:I}),pt.set(C,P));const ce=k-Math.round(f.start*I),Y=P.find(Z=>ce>=Z.from&&ce<Z.to)??P[P.length-1];return yo({effects:vr(x,Y.t)},y)},yt=new Map,Xt=(r,f,k)=>{const x=`${r.id}@${f.start}`;yt.has(x)||yt.set(x,O?Dr(r,O,f.start,f.duration,y,_):null);const T=yt.get(x);return T?Ie(r,f,k,T,":dof"):[]},Ue=new Map,Yt=r=>{const f=JSON.stringify(r.grade);let k=Ue.get(f);if(!k){const x=P=>Array.from(P,ce=>+ce.toFixed(6)),T=gr(r.grade)?Tr(r.grade):null,C=r.grade.mixer&&wr(r.grade.mixer)?yr(r.grade.mixer):null;k={l1:T?{key:`1${f}`,r:x(T.r),g:x(T.g),b:x(T.b)}:null,l3:C?{key:`3${f}`,size:C.size,data:Float32Array.from(C.data,P=>+P.toFixed(6))}:null},Ue.set(f,k)}return k};let Ce=null;const Rt=async(r,f,k)=>{const x=X.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,I,Math.max(k.start,x.start),k.duration);if(!T)return null;const C=T.toVideoFrame();return{source:C,w:T.displayWidth,h:T.displayHeight,close:()=>C.close()}};Ne="output";const U=ba(y,_),He=io(w,{width:y,height:_,fps:I},ro),nt=w?.codec==="hevc",St=w?.container==="mov",Qe=!A&&!xe&&te*He/8>15e7&&!!navigator.storage?.getDirectory;let Xe=null,ke;if(Qe){const r=await navigator.storage.getDirectory(),f=`gpu-export-${crypto.randomUUID()}.${St?"mov":"mp4"}`,k=await r.getFileHandle(f,{create:!0});Xe={dir:r,handle:k,name:f},ke=new Ro(await k.createWritable(),{chunked:!0,chunkSize:1<<20})}else ke=xe&&!A?new Ro(xe,{chunked:!0,chunkSize:1<<22}):new Ri;const Ve=xe&&!A?!1:Qe?"reserve":"in-memory",Je=new _i({format:St?new Fi({fastStart:Ve}):new Ai({fastStart:Ve}),target:ke}),_t=new Mi(U.canvas,{codec:nt?"hevc":"avc",bitrate:He,keyFrameInterval:2,...nt?{hardwareAcceleration:"prefer-hardware"}:W?{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:I,...Qe?{maximumPacketCount:Ft-Ze+8}:{}});const Dt=new Si({codec:"aac",bitrate:ko});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"),Kt=async r=>{zt.putImageData(new ImageData(U.pixels(),y,_),0,0);const f=new Uint8Array(await(await Ot.convertToBlob({type:"image/webp",quality:.9})).arrayBuffer());let k="";for(let x=0;x<f.length;x+=32768)k+=String.fromCharCode(...f.subarray(x,x+32768));A.push(r,btoa(k))},Me=new Map;let ue=0;const j={decode:0,matte:0,titles:0,captions:0,encode:0},st=async(r,f)=>{const k=performance.now();try{return await f}finally{j[r]+=performance.now()-k}},At=(r,f)=>{const k=performance.now();try{return f()}finally{j[r]+=performance.now()-k}};try{for(let f=A?0:Ze,k=A?A.times.length:Ft;f<k;f++){Oe(),Ne="frame";const x=A?A.times[f]:f/I,T=Te(x);U.clear(A?0:1);const C=T&&qe?Ho(X,T.start+1e-5,e):void 0,P=C&&T?Vo(T.visuals,C.captionStyle?.layerTrack):-1,ce=async()=>{const Y=C&&T&&await st("captions",F(C,T,f));Y&&(U.shadow([]),U.edge(null),U.windows(null),U.matte(null),U.mode(void 0),U.key(null),U.grade(null,null),U.draw(Y,pe,pe,1,1,!1,null,[]))};for(const[Y,Z]of(T?.visuals??[]).entries()){let a=Z;if(Y===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"){U.matte(null),U.edge(null),U.windows(null),U.mode(void 0),U.shadow(uo(a,y)),U.key(null),U.grade(null,null);const m=await Ee(a,x);m&&U.draw(m,pe,pe,1,1,!1,null,[]);break e}const ne=x-a.start,Re=Jt(a,ne,y,_),se=(Ko(a)||Wo(a))&&!S&&!(O&&$t(a))&&!a.pin?je(a,T,x,Re):Re;if(!(se.opacity>1e-4))break e;if(Zt(a)){U.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,I,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,X):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);U.matte(At("matte",()=>ye.matteCanvas(a,ne,Ge,!1,X)),[m.left,m.top,t/B.w,c/B.h])}else U.matte(null);U.mode(a.blend),U.key(a.key),U.shadow(uo(a,y));{const m=a.colorBypass?[]:qt(a.grade).filter(eo);U.windows(m.length?{key:`${a.id}@${f}`,list:qt(a.grade),clip:a.id,src:a,frame:Math.round((x-a.start)*I),local:Math.round((x-a.start)*I)/I}: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;U.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 U.edge(null);{const m=a.grade&&!a.colorBypass?Yt(a):null;U.grade(m?.l1??null,m?.l3??null)}if(a.pin&&!(O&&$t(a))&&T&&vo(a,X,T.start,y,_,O)){const m=vo(a,X,x,y,_,O)??[[0,0],[0,0],[0,0],[0,0]],t=Bt(a,ne),c=er(a,X,y,_,O),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;U.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 Ut=tr(a,"rot")||or(a),xt=()=>a.motionBlur?fi(x,I).map(m=>({...Jt(a,m-a.start,y,_),rot:se.rot,opacity:se.opacity})):[se];if((Ut||Math.abs(se.rot||0)>1e-9)&&!(O&&$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&&U.blurBegin();for(const c of xt()){const u=ai(a,B.w,B.h,y,_,c,Ut);U.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&&U.blurEnd(),Pe?.close();break e}if(O&&$t(a)){const m=rr(a,ne,O,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,O,y,_),B.w,B.h,y,_),at.set(a.id,h));const i=Xt(a,T,f);h>1&&!u.length?U.warpBig(B,Nt(t.dst,y,_),t.src,Math.min(1,se.opacity),c.k,c.white,ot(a),m.quad,h,i):U.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);U.blurBegin();for(const t of xt()){const c=Lt(a,B.w,B.h,y,_,t);U.draw(B,c.dst,c.src,Math.min(1,se.opacity),m.k,m.white,ot(a),[])}U.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;U.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);U.draw(B,t.dst,m.src,Math.min(1,se.opacity),s.k,s.white,ot(a),o,m.dst)}else U.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));U.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);U.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[Y,Z]of Me){const a=Y.split(`
194
+ `)[0],S=$.find(fe=>fe.id===a);(!S||x>S.start+S.duration+1)&&(Z.current?.close(),Z.peek?.close(),await Z.iterator.return?.(),Me.delete(Y))}if(A){await Kt(f);continue}Ne="video encode",await st("encode",_t.add((f-Ze)/I,1/I)),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($.map(x=>[x.id,x])),k=await wa(X.map(x=>f.get(x.id)??x),_e,te,e,rt,E);typeof g.loudness=="number"&&si([k.getChannelData(0),k.getChannelData(1)],g.loudness,Ct),Ne="audio encode",await Dt.add(k),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 We.values())r.dispose?.()}N?.(1),Ne="file";const dt=Xe?await Xe.handle.getFile():xe?new Blob([]):new Blob([ke.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,z){const E=[new Float32Array(Math.max(1,Math.round(z*w))),new Float32Array(Math.max(1,Math.round(z*w)))],N=Math.round(Lr*w);return g.forEach((A,W)=>{if(A.silent)return;const re=Math.round((A.t1-A.t0)*w)+(W<g.length-1?N:0),ae=Math.abs(A.rate),me=Math.round(A.t0*w),xe=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-xe<2)return;const y=(d-xe)/re,_=Math.round(.06*w),I=Math.max(0,xe-_),X=Math.min(p[0].length,d+_);let $=p.map(oe=>oe.slice(I,X));A.rate<0&&$.forEach(oe=>oe.reverse());const te=Math.round((A.rate<0?X-d:xe-I)/y);$=Uo($,y,w).map(oe=>oe.subarray(te,te+re));for(let oe=0;oe<2;oe++)for(let O=0;O<re&&me+O<E[oe].length;O++){const _e=(W>0&&O<N?O/N:1)*(W<g.length-1&&O>=re-N?(re-O)/N:1);E[oe][me+O]+=($[oe][O]??0)*_e}}),E}async function wa(p,g,w,e,z,E){const N=new OfflineAudioContext({numberOfChannels:2,length:Math.max(1,Math.round(w*Ct)),sampleRate:Ct}),A=1/200,W=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 z(d.url).getPrimaryAudioTrack().then(y=>!!y,()=>!1));const me=d=>re(d)&&!!ae.get(d.url);for(const d of W){if(E?.aborted)throw new DOMException("Export cancelled","AbortError");const y=Math.max(2,Math.ceil(d.duration/A)+1),_=new Float32Array(y);let I=!1;const X=Ur(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)?kr(d,Ee-d.start)*X.gain/Pr(ut.audios,me):0;_[J]=qe,qe>0&&(I=!0)}if(!I)continue;const $=await z(d.url).getPrimaryAudioTrack();if(!$)continue;const te=So(d)?Br(d,0,d.duration):null,oe=d.playbackRate||1,O=new yi($),_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 O.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=Uo(Fe,oe,ze));const Ke=N.createBuffer(2,Fe[0].length,ze);for(let J=0;J<2;J++)Ke.copyToChannel(Fe[J],J);const ye=N.createBufferSource();ye.buffer=Ke;const Ge=N.createGain();Ge.gain.value=0,Ge.gain.setValueCurveAtTime(_,d.start,Math.max(A,d.duration));const We=N.createChannelSplitter(2),Ae=N.createChannelMerger(2),Le=N.createGain(),rt=N.createGain();Le.gain.value=X.left,rt.gain.value=X.right,ye.connect(Ge),Ge.connect(We),We.connect(Le,0),We.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 xe=await N.startRendering();return ci([xe.getChannelData(0),xe.getChannelData(1)]),xe}export{Pa as canEncodeH264,Ba as canEncodeHevc,ka as canEncodeMp4,ga as exportOnGpu,ro as gpuBitrate,La as gpuExportStage,Na as gpuExportSupported};
@@ -1 +1 @@
1
- import{aa as kt,ab as Ft}from"./main-CVRIuDW2.js";import{iG as V,iH as jt}from"./remote-BJdzzFZg.js";import"./titleFrameBudget-Cml-MO53.js";import"./api-QBI5GJTZ.js";import"./store-2zneEhhu.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DdwuJ_hb.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.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 N=o+.5-t[0],z=m+.5-t[1],$=Math.max(0,Math.min(1,(N*U+z*i)/f)),C=N-$*U,B=z-$*i;C*C+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(([P,L])=>[P*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[P,L]of ut)X(r,s[P],s[L],.45*F,t,n),X(h,s[P],s[L],.08*F,t,n);W(r,at.map(P=>s[P]),t,n),W(h,at.map(P=>s[P]),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 S=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),G=new Float32Array(e),H=new Float32Array(e),T=new Float32Array(e);for(let u=0;u<e;u++)if(d[u]<.1){const s=u*4;D[u]=1,G[u]=l[s],H[u]=l[s+1],T[u]=l[s+2]}const E=S?ht([D,G,H,T],t,n,Math.max(4,Math.round(o*.6))):null,v=u=>{if(!S||!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,P=[l[Q],l[Q+1],l[Q+2]];let L=0,et=1/0;for(const it of S){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,((P[0]-j[0])*R[0]+(P[1]-j[1])*R[1]+(P[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,q=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);q[u]=Math.round(255*k*k*(3-2*k))}return Mt(q,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 N=[];for(let r=0;r<e;r+=3)if(M[r]){const h=r*4;N.push([l[h],l[h+1],l[h+2]])}if(N.length<12)return i;N.sort((r,h)=>r[0]+r[1]+r[2]-h[0]-h[1]-h[2]);const z=r=>{const h=N.slice(Math.floor(N.length*r/3),Math.floor(N.length*(r+1)/3));return[0,1,2].map(x=>h.reduce((I,S)=>I+S[x],0)/h.length)},$=[z(0),z(1),z(2)],C=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;C[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([C,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),S=I>2?[b(1,h,r)/I,b(2,h,r)/I,b(3,h,r)/I]:yt;if(!S){Z[x]=i[x]/255;continue}const D=x*4,G=[l[D],l[D+1],l[D+2]];let H=0,T=1/0;for(const q of $){const O=[q[0]-S[0],q[1]-S[1],q[2]-S[2]],K=O[0]*O[0]+O[1]*O[1]+O[2]*O[2];T=Math.min(T,Math.sqrt(K)),!(K<1)&&(H=Math.max(H,((G[0]-S[0])*O[0]+(G[1]-S[1])*O[1]+(G[2]-S[2])*O[2])/K))}const E=d&&!f[x]?d[x]:null;if(T<a.sep){Z[x]=E??i[x]/255;continue}const v=Math.max(0,Math.min(1,(H-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 N=o%t;N>0&&m.push(o-1),N<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
+ import{aa as kt,ab as Ft}from"./main-BKjBWQik.js";import{iO as V,iP as jt}from"./remote-Dva2qg58.js";import"./titleFrameBudget-BYRZAQPs.js";import"./api-DUp403BK.js";import"./store-75tQUvPT.js";import"./three.module-Bx43vjkH.js";import"./spark.module-B34aiScb.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";import"./userFonts-DzY0A4bD.js";import"./lottieLayer-1ET89OUr.js";import"./timeline3d-246tBEJl.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-MUwVTI52.js";import"./captionLayout-EuB59pN_.js";import"./timelineText-BzUhNWPB.js";import"./titleArt-B8DVR58F.js";import"./rotoMatte-BdYa8FSB.js";import"./distortGL-BlmBZKRU.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 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-CVRIuDW2.js","assets/titleFrameBudget-Cml-MO53.js","assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js","assets/spark.module-DdwuJ_hb.js","assets/userFonts-BHduCNtc.js","assets/lottieLayer-CDCGeJyv.js","assets/timeline3d-YIIk_Kn2.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-D9OT7_5k.js","assets/captionLayout-C67EMVI1.js","assets/timelineText-BcL4Pw3C.js","assets/titleArt-hb_T45WJ.js","assets/rotoMatte-013RKqHu.js","assets/distortGL-BaXfN0IK.js","assets/motionBlur-uAm030t9.js","assets/main-BQ8IY0WV.css","assets/handMatte-mHxZwLZD.js","assets/matteFixRun-BLDH2AjH.js"])))=>i.map(i=>d[i]);
2
- import{b$ as X,_ as N,a7 as Z,bY as tt}from"./titleFrameBudget-Cml-MO53.js";import{u as V}from"./store-2zneEhhu.js";import{t as W}from"./api-QBI5GJTZ.js";import{a6 as et,a7 as at,a8 as nt,a5 as Q,a9 as ot}from"./main-CVRIuDW2.js";import{iw as it,ix as rt,iy as Y,iz as st,iA as ct,iB as $,iC as lt,bd as G,iD as dt,iE as mt,iF as ut}from"./remote-BJdzzFZg.js";import{handMatteSize as ht,handMatteFrame as ft}from"./handMatte-mHxZwLZD.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DdwuJ_hb.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.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@${Q}/wasm`,gt=640;let K=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}},[]);K??=d.forVisionTasks(wt).catch(c=>{throw K=null,c});const a=await w.createFromOptions(await K,{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<=$.maxFrames?30:15,v=Math.max(2,Math.min($.maxFrames,Math.round(b*m)+1)),{detect:p,close:F}=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=G(d,a),D=[];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(C=>[C[0],C[1]]),score:O.score},k[1]={lm:A.lm.map(C=>[C[0],C[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)}}D.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:D})}finally{u.removeAttribute("src"),u.load(),F()}}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:F}=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@${Q}/wasm`),x=await F.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 F=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[F+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 z=null;async function bt(d,w,a,f,c,s){const{objectProbability:b}=await N(async()=>{const{objectProbability:o}=await import("./main-CVRIuDW2.js").then(i=>i.aI);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;z??=Object.assign(document.createElement("canvas"),{width:v,height:v});const p=z.getContext("2d",{willReadFrequently:!0}),F=async(o,i,y,E,D)=>{p.fillStyle="#000",p.fillRect(0,0,v,v),p.drawImage(d,o,i,y,E,0,0,v,v);const n=await b(z,D.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-mHxZwLZD.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,D=kt.map(t=>({x:i[t],y:y[t]}));D.push({x:i[0]+(i[0]-i[9])*.6,y:y[0]+(y[0]-y[9])*.6});const r=await F(...((t,e,l,O=1)=>{const A=Math.min(...t)-l,C=Math.max(...t)+l,I=Math.min(...e)-l,g=Math.max(...e)+l,P=Math.max(C-A,g-I),T=Math.min(w,Math.max(C-A,P/O)),j=Math.min(a,Math.max(g-I,P/O)),L=Math.min(T,j*O),U=Math.min(j,T*O);return[Math.max(0,Math.min(w-L,(A+C)/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),D);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,C=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 T=g-t,j=I-e;T*h+j*_<-.2*P||(O+=g,A+=I,C++)}if(C>20){const I=O/C-t,g=A/C-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 J({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),F=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}),D=G(d,a),n=Math.max(1,Math.min($.maxFrames,Math.round(f*F*u)+1)),r=G(d,c),h=et({mw:H,mh:S,w:o,h:i,fps:u,s0:D},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=D+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 C=null;if(M&&A.length)try{const g=await bt(l,H,S,A,o,i);C=g.map,g.armDirs.forEach((P,T)=>{A[T].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:C}):new Uint8Array(o*i);if(k&&s){const g=tt(k,s,e),P=s.w,T=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(T-1,Math.floor(L*T/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,$.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 Yt(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}=X(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 J({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:Y({...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,F=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:F,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="${F.id}"]`)?.currentSrc||F.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 J({clip:F,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-BLDH2AjH.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,F.hands)}catch(n){console.warn("hand touch-ups",n)}const E=o?void 0:Y(F,{until:u.cutoutUntil}),D=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?D(r):r)})),{motion:u.grab}}export{pt as HAND_MODEL_URL,J as buildHandMatte,bt as learnedHands,Yt as runHandTrack,Mt as trackHands};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-BKjBWQik.js","assets/titleFrameBudget-BYRZAQPs.js","assets/remote-Dva2qg58.js","assets/api-DUp403BK.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-75tQUvPT.js","assets/rotoMaskStore-BxyxB2bD.js","assets/textAnimators-nVSz_sZo.js","assets/timelineComp-BcewYGR2.js","assets/rigTrack-UYZU4P-e.js","assets/spark.module-B34aiScb.js","assets/userFonts-DzY0A4bD.js","assets/lottieLayer-1ET89OUr.js","assets/timeline3d-246tBEJl.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-MUwVTI52.js","assets/captionLayout-EuB59pN_.js","assets/timelineText-BzUhNWPB.js","assets/titleArt-B8DVR58F.js","assets/rotoMatte-BdYa8FSB.js","assets/distortGL-BlmBZKRU.js","assets/motionBlur-uAm030t9.js","assets/main-Ca_CVxMz.css","assets/handMatte-BD7OE3Zc.js","assets/matteFixRun-BdHKC3m5.js"])))=>i.map(i=>d[i]);
2
+ import{c1 as Y,_ as N,a7 as Z,b_ as tt}from"./titleFrameBudget-BYRZAQPs.js";import{u as V}from"./store-75tQUvPT.js";import{t as W}from"./api-DUp403BK.js";import{a6 as et,a7 as at,a8 as nt,a5 as X,a9 as ot}from"./main-BKjBWQik.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-Dva2qg58.js";import{handMatteSize as ht,handMatteFrame as ft}from"./handMatte-BD7OE3Zc.js";import"./three.module-Bx43vjkH.js";import"./spark.module-B34aiScb.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";import"./userFonts-DzY0A4bD.js";import"./lottieLayer-1ET89OUr.js";import"./timeline3d-246tBEJl.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-MUwVTI52.js";import"./captionLayout-EuB59pN_.js";import"./timelineText-BzUhNWPB.js";import"./titleArt-B8DVR58F.js";import"./rotoMatte-BdYa8FSB.js";import"./distortGL-BlmBZKRU.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-BKjBWQik.js").then(i=>i.aI);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-BD7OE3Zc.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,P=Math.min(...e)-l,g=Math.max(...e)+l,I=Math.max(F-A,g-P),D=Math.min(w,Math.max(F-A,I/O)),j=Math.min(a,Math.max(g-P,I/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,(P+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 P=0;P<s;P++)for(let g=0;g<c;g++){if(r[P*c+g]<.5)continue;const I=Math.hypot(g-t,P-e);if(I<1.2*l||I>3*l)continue;const D=g-t,j=P-e;D*h+j*_<-.2*I||(O+=g,A+=P,F++)}if(F>20){const P=O/F-t,g=A/F-e,I=Math.hypot(P,g)||1;(P*h+g*_)/I>Math.cos(75*Math.PI/180)&&(h=P/I,_=g/I)}}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 I=dt(p,e,g);return I?{lm:I,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((I,D)=>{A[D].armDir=I})}catch(g){M=!1,console.warn("hand cut-out model",g)}let P=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),I=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(P[L*o+U]*g[Math.min(D-1,Math.floor(L*D/i))*I+Math.min(I-1,Math.floor(U*I/o))]/255);P=j}_.push(P),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-BdHKC3m5.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};