clipoox-render 0.4.2 → 0.4.3

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 (105) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +1322 -1320
  3. package/web/assets/{FxEmbed-CGqGi2Lw.js → FxEmbed-BCmj9Q5C.js} +1 -1
  4. package/web/assets/{MotionEmbed-C3CZ3_y_.js → MotionEmbed-CEmbcq8Z.js} +1 -1
  5. package/web/assets/PluginStore-C5hyahvG.js +3 -0
  6. package/web/assets/{ShotComposer-DFfaYLoV.js → ShotComposer-0DUtMTVI.js} +4 -4
  7. package/web/assets/{TemplateEmbed-C8pXcPsc.js → TemplateEmbed-ANxSs7H5.js} +1 -1
  8. package/web/assets/{TimelinePlugins-DnkV3i4G.js → TimelinePlugins-BYZ9y4m3.js} +4 -4
  9. package/web/assets/{TimelinePlugins-DYarX9RK.css → TimelinePlugins-D841ngau.css} +1 -1
  10. package/web/assets/{TimelineShotFx-foiuuogg.js → TimelineShotFx-q5PQwq-V.js} +2 -2
  11. package/web/assets/{TransitionEmbed-BueDilY0.js → TransitionEmbed-O6LInGWq.js} +1 -1
  12. package/web/assets/{Whiteboard-zBsNHh5h.js → Whiteboard-BP_DvIAV.js} +1 -1
  13. package/web/assets/{aerial-z34Nww_T.js → aerial-CGLDKKtP.js} +2 -2
  14. package/web/assets/{agentTools-ALxghYpf.js → agentTools-2Ghb80VH.js} +2 -2
  15. package/web/assets/{analyzerRun-DNwryAlU.js → analyzerRun-DRgxrcJA.js} +1 -1
  16. package/web/assets/{analyzerSandbox-A1oFsCrO.js → analyzerSandbox-DuIVFnsk.js} +1 -1
  17. package/web/assets/{api-DUp403BK.js → api-CJ8PdbfZ.js} +5 -5
  18. package/web/assets/{auraTrack-BKVZCwNt.js → auraTrack-DQw9sVU6.js} +1 -1
  19. package/web/assets/{breakthrough-Cwt8gEwK.js → breakthrough-BNj_iTDr.js} +2 -2
  20. package/web/assets/{cameraPresets-DSOPj4oy.js → cameraPresets-CYw0OdM3.js} +1 -1
  21. package/web/assets/{captionLayout-EuB59pN_.js → captionLayout-DvDPTwO9.js} +1 -1
  22. package/web/assets/{clientExport-BL1XMTF0.js → clientExport-xhoXY6Dh.js} +1 -1
  23. package/web/assets/conversion-4rhF3xRJ.js +17 -0
  24. package/web/assets/{depthEstimate-DOvsY8mn.js → depthEstimate-DEpeCojm.js} +1 -1
  25. package/web/assets/{directorTools-BkbNYbSq.js → directorTools-C5CpTmci.js} +1 -1
  26. package/web/assets/{distortFrames-Drch0LhT.js → distortFrames-Dia8O1NM.js} +2 -2
  27. package/web/assets/{distortGL-BlmBZKRU.js → distortGL-QalhICvi.js} +1 -1
  28. package/web/assets/{editTools-BcGinqHC.js → editTools-CY_JrQfw.js} +1 -1
  29. package/web/assets/engine-BedcnK45.js +1 -0
  30. package/web/assets/{exportEncode-MUwVTI52.js → exportEncode-QYsT9JBO.js} +1 -1
  31. package/web/assets/{exportGlb-SIXFRRJM.js → exportGlb-TSj09XoV.js} +1 -1
  32. package/web/assets/{faceTracker-DCbZbLMc.js → faceTracker-CnCWOwnJ.js} +1 -1
  33. package/web/assets/{fightDirector-hlF1JS_z.js → fightDirector-DCI_FWTh.js} +1 -1
  34. package/web/assets/{fightDrama-fHN5EXk3.js → fightDrama-Bg7uP_2Q.js} +2 -2
  35. package/web/assets/{frameSink-BvOXjLuw.js → frameSink-DeM8xC8_.js} +3 -3
  36. package/web/assets/{gpuCompose-CNkLwpbZ.js → gpuCompose-CA3UmOl4.js} +1 -1
  37. package/web/assets/{gpuExport-DQB6x4eh.js → gpuExport-D31azOQA.js} +13 -9
  38. package/web/assets/{handMatte-BD7OE3Zc.js → handMatte-Dl-xVXFR.js} +1 -1
  39. package/web/assets/{handTracker-BumGtRCW.js → handTracker-CplBsAFg.js} +2 -2
  40. package/web/assets/{id3-BCR9Bqgo.js → id3-arvEpAg7.js} +1 -1
  41. package/web/assets/{index-CuaB7Y0L.js → index-D5oyVCRl.js} +1 -1
  42. package/web/assets/index-_tSTJnL9.js +8 -0
  43. package/web/assets/layer-worker-DFuo32bk.js +5 -0
  44. package/web/assets/library-BufgA-Pl.js +1 -0
  45. package/web/assets/{lottieLayer-1ET89OUr.js → lottieLayer-DzbA3bHV.js} +4 -4
  46. package/web/assets/{lottie_light_canvas-DD9pkFL8.js → lottie_light_canvas-B-d7-ATe.js} +1 -1
  47. package/web/assets/main-VVYiW8XD.js +309 -0
  48. package/web/assets/{mapBake-DLoBt_k5.js → mapBake-BKOcEd0w.js} +1 -1
  49. package/web/assets/maskTrack-CHGXtBRy.js +1 -0
  50. package/web/assets/{matteFixRun-BdHKC3m5.js → matteFixRun-vgYrINet.js} +1 -1
  51. package/web/assets/{objectLocate-bZtc5AJo.js → objectLocate-BJltm8Ob.js} +1 -1
  52. package/web/assets/{output-BwZzMbp-.js → output-p-Q7qous.js} +1 -1
  53. package/web/assets/{pendingMatte-mlyLLZCT.js → pendingMatte-BPyzzx4y.js} +2 -2
  54. package/web/assets/{personAi-CUNQeseG.js → personAi-gJu03SjU.js} +2 -2
  55. package/web/assets/{plateCamera-_jP1xXnj.js → plateCamera-B2JvhjJw.js} +1 -1
  56. package/web/assets/{plateCameraMatch-rr0oUwQ2.js → plateCameraMatch-ByB9nVQT.js} +2 -2
  57. package/web/assets/{plateFollow-BjvtcT8q.js → plateFollow-C9S-l7RH.js} +2 -2
  58. package/web/assets/{plateMatte-BqyL8cQZ.js → plateMatte-J4qlNHnY.js} +2 -2
  59. package/web/assets/{pluginAutomation-Dp188qm7.js → pluginAutomation-CkP3tA9r.js} +1 -1
  60. package/web/assets/{poseTracker-DDGDhhMF.js → poseTracker-DGLbouqt.js} +1 -1
  61. package/web/assets/{productTools-CRgI88-O.js → productTools-CkaWF1bM.js} +2 -2
  62. package/web/assets/remote-C7J0Tqhb.js +1433 -0
  63. package/web/assets/{rigTrack-UYZU4P-e.js → rigTrack-urT3nDK0.js} +1 -1
  64. package/web/assets/{rotoMaskStore-BxyxB2bD.js → rotoMaskStore-DPziPKAN.js} +1 -1
  65. package/web/assets/{rotoMatte-BdYa8FSB.js → rotoMatte-C-2o3vv0.js} +1 -1
  66. package/web/assets/{rotoscope-DDixNQCt.js → rotoscope-GvPFRUBg.js} +1 -1
  67. package/web/assets/{shot-worker-D9sZS6bn.js → shot-worker-6dYkHPoL.js} +1 -1
  68. package/web/assets/{shotFxAgent-7RQNtEe4.js → shotFxAgent-BFLkqs8v.js} +1 -1
  69. package/web/assets/{skin-CVwmK130.js → skin-DY4QLaBI.js} +1 -1
  70. package/web/assets/{spark.module-B34aiScb.js → spark.module-DzziUgOj.js} +1 -1
  71. package/web/assets/{spellDuel-BkweL6pI.js → spellDuel-BD3m2ebA.js} +2 -2
  72. package/web/assets/store-Cug4GGcP.js +1 -0
  73. package/web/assets/{store-75tQUvPT.js → store-DW4E9xnW.js} +1 -1
  74. package/web/assets/{surfaceLight-DhU-zgNL.js → surfaceLight-aDSYU8Jg.js} +1 -1
  75. package/web/assets/surfacePin-m83hCgGP.js +2 -0
  76. package/web/assets/{textAnimators-nVSz_sZo.js → textAnimators-DUZjhVGO.js} +1 -1
  77. package/web/assets/{thumb-r6dlZprA.js → thumb-CS0ZuiGS.js} +1 -1
  78. package/web/assets/{timeline3d-246tBEJl.js → timeline3d-DOw-CpZI.js} +2 -2
  79. package/web/assets/{timeline3dExport-T57qnWi9.js → timeline3dExport-BtYLU1pw.js} +1 -1
  80. package/web/assets/{timelineComp-BcewYGR2.js → timelineComp-B4GtoH2f.js} +1 -1
  81. package/web/assets/{timelineProps-CJzzAWWO.js → timelineProps-D7MVutxu.js} +1 -1
  82. package/web/assets/{timelineText-BzUhNWPB.js → timelineText-BH09jfSM.js} +1 -1
  83. package/web/assets/{titleArt-B8DVR58F.js → titleArt-Drsrtfiv.js} +3 -3
  84. package/web/assets/{titleFrameBudget-BYRZAQPs.js → titleFrameBudget-CLZWaFHO.js} +1 -1
  85. package/web/assets/{titleFrames-BVgm601q.js → titleFrames-BI1DnLBn.js} +1 -1
  86. package/web/assets/{tool-CAGU3dUa.js → tool-DktQYmS6.js} +1 -1
  87. package/web/assets/{tools-DVaOkokV.js → tools-Co9aRDiT.js} +1 -1
  88. package/web/assets/{toonTools-CfGTR_H1.js → toonTools-CD9clJvN.js} +2 -2
  89. package/web/assets/{trackAnchor-DzUt1r5Q.js → trackAnchor-sOjTtd3I.js} +1 -1
  90. package/web/assets/{userFonts-DzY0A4bD.js → userFonts-CwlKh9NR.js} +1 -1
  91. package/web/assets/{vfxAlpha-DQJOaZ9v.js → vfxAlpha-71tSN86T.js} +2 -2
  92. package/web/assets/{vfxBackground-DiktQFOD.js → vfxBackground-Bq7lJvmZ.js} +2 -2
  93. package/web/assets/{videoExport-Ce0ElSQR.js → videoExport-D4KbireJ.js} +1 -1
  94. package/web/assets/{views-V3si1lOz.js → views-ozVF4ABO.js} +1 -1
  95. package/web/assets/{weaponDuel-D6sLVGmG.js → weaponDuel-ZhX-tjGZ.js} +1 -1
  96. package/web/assets/{windowFrames-D_2QJCJJ.js → windowFrames-CpqX3kOM.js} +1 -1
  97. package/web/layer-worker.html +3 -3
  98. package/web/assets/PluginStore-DKXZ-jBj.js +0 -3
  99. package/web/assets/index-DYa7fEK0.js +0 -24
  100. package/web/assets/layer-worker-DxPMMKIZ.js +0 -5
  101. package/web/assets/library-CyjJ8nGG.js +0 -1
  102. package/web/assets/main-BKjBWQik.js +0 -309
  103. package/web/assets/maskTrack-C2SJbDGO.js +0 -1
  104. package/web/assets/remote-Dva2qg58.js +0 -1241
  105. package/web/assets/surfacePin-ObK6QgDm.js +0 -2
@@ -1 +1 @@
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
+ import{ab as kt,ac as Ft}from"./main-VVYiW8XD.js";import{iO as V,iP as jt}from"./remote-C7J0Tqhb.js";import"./titleFrameBudget-CLZWaFHO.js";import"./api-CJ8PdbfZ.js";import"./store-DW4E9xnW.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DzziUgOj.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";import"./userFonts-CwlKh9NR.js";import"./lottieLayer-DzbA3bHV.js";import"./timeline3d-DOw-CpZI.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-QYsT9JBO.js";import"./captionLayout-DvDPTwO9.js";import"./timelineText-BH09jfSM.js";import"./titleArt-Drsrtfiv.js";import"./rotoMatte-C-2o3vv0.js";import"./distortGL-QalhICvi.js";import"./motionBlur-uAm030t9.js";const dt=Object.freeze({core:.5,band:.16,ring:.55,sep:22,lo:.1,hi:.78,guideR:2,guideEps:.002,maxW:512,choke:[.5,.66],close:.08,closeArm:.22,chokeAI:[.45,.62],chokeArm:[.22,.4]}),ut=[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]],at=[0,1,5,9,13,17];function X(l,t,n,g,A,d,y=255){const a=Math.max(0,Math.floor(Math.min(t[0],n[0])-g)),e=Math.min(A-1,Math.ceil(Math.max(t[0],n[0])+g)),M=Math.max(0,Math.floor(Math.min(t[1],n[1])-g)),p=Math.min(d-1,Math.ceil(Math.max(t[1],n[1])+g)),U=n[0]-t[0],i=n[1]-t[1],f=U*U+i*i||1,c=g*g;for(let m=M;m<=p;m++)for(let o=a;o<=e;o++){const S=o+.5-t[0],z=m+.5-t[1],$=Math.max(0,Math.min(1,(S*U+z*i)/f)),H=S-$*U,B=z-$*i;H*H+B*B<=c&&l[m*A+o]<y&&(l[m*A+o]=y)}return l}function W(l,t,n,g,A=255){const d=t.length;if(d<3)return l;let y=1/0,a=-1/0;for(const M of t)M[1]<y&&(y=M[1]),M[1]>a&&(a=M[1]);y=Math.max(0,Math.floor(y)),a=Math.min(g-1,Math.ceil(a));const e=[];for(let M=y;M<=a;M++){const p=M+.5;e.length=0;for(let i=0,f=d-1;i<d;f=i++){const c=t[f],m=t[i];(c[1]<=p&&m[1]>p||m[1]<=p&&c[1]>p)&&e.push([c[0]+(p-c[1])/(m[1]-c[1])*(m[0]-c[0]),m[1]>c[1]?1:-1])}if(e.length<2)continue;e.sort((i,f)=>i[0]-f[0]);let U=0;for(let i=0;i<e.length-1;i++){if(U+=e[i][1],!U)continue;const f=Math.max(0,Math.ceil(e[i][0]-.5)),c=Math.min(n-1,Math.floor(e[i+1][0]-.5)),m=M*n;for(let o=f;o<=c;o++)l[m+o]<A&&(l[m+o]=A)}}return l}function ht(l,t,n,g){const A=t+1,d=l.map(y=>{const a=new Float64Array(A*(n+1));for(let e=0;e<n;e++){let M=0;for(let p=0;p<t;p++)M+=y[e*t+p],a[(e+1)*A+p+1]=a[e*A+p+1]+M}return a});return(y,a,e)=>{const M=d[y],p=Math.max(0,a-g),U=Math.min(t,a+g+1),i=Math.max(0,e-g),f=Math.min(n,e+g+1);return M[f*A+U]-M[i*A+U]-M[f*A+p]+M[i*A+p]}}function Xt(l,t,n,g,A={}){const{learned:d=null,...y}=A,a={...dt,...y},e=t*n,M=new Uint8Array(e),p=new Uint8Array(e),U=new Uint8Array(e),i=new Uint8Array(e),f=new Uint8Array(e),c=(g||[]).filter(r=>r?.lm?.length>=21);if(!c.length)return new Uint8Array(e);const m=r=>r.map(([h,x])=>[h*t,x*n]);let o=0;for(const r of c){o=Math.max(o,Math.hypot((r.lm[0][0]-r.lm[9][0])*t,(r.lm[0][1]-r.lm[9][1])*n)),W(M,m(V(r.lm,t,n,{edge:r.edge?r.edge.map(x=>Math.min(0,x)):null,scale:a.core})),t,n),W(i,m(V(r.lm,t,n,{edge:r.edge})),t,n),W(p,m(V(r.lm,t,n,{edge:r.edge,grow:a.band})),t,n),W(U,m(V(r.lm,t,n,{edge:r.edge,grow:a.ring})),t,n);const h=V(r.lm,t,n,{edge:r.edge,grow:a.band});W(f,m(jt.map(x=>h[x])),t,n)}if(d){const r=new Uint8Array(e),h=new Uint8Array(e);for(const u of c){const s=u.lm.map(([N,L])=>[N*t,L*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]),k=Array.isArray(u.armDir)?u.armDir:[(s[0][0]-s[9][0])/(F||1),(s[0][1]-s[9][1])/(F||1)],j=[s[0][0]+k[0]*4*F,s[0][1]+k[1]*4*F];for(const[N,L]of ut)X(r,s[N],s[L],.45*F,t,n),X(h,s[N],s[L],.08*F,t,n);W(r,at.map(N=>s[N]),t,n),W(h,at.map(N=>s[N]),t,n);const Q=[s[0][0]+k[0]*Math.max(t,n)*1.5,s[0][1]+k[1]*Math.max(t,n)*1.5];X(r,s[0],Q,1.6*F,t,n),X(h,s[0],j,.12*F,t,n)}const x=new Uint8Array(e);for(const u of c){const s=u.lm.map(([k,j])=>[k*t,j*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]);for(const[k,j]of ut)X(x,s[k],s[j],.45*F,t,n);W(x,at.map(k=>s[k]),t,n)}const I=[];for(let u=0;u<e;u+=2)if(h[u]&&x[u]&&d[u]>.6){const s=u*4;I.push([l[s],l[s+1],l[s+2]])}I.sort((u,s)=>u[0]+u[1]+u[2]-s[0]-s[1]-s[2]);const P=I.length>=30?[0,1,2].map(u=>{const s=I.slice(Math.floor(I.length*u/3),Math.floor(I.length*(u+1)/3));return[0,1,2].map(F=>s.reduce((k,j)=>k+j[F],0)/s.length)}):null,D=new Float32Array(e),T=new Float32Array(e),q=new Float32Array(e),C=new Float32Array(e);for(let u=0;u<e;u++)if(d[u]<.1){const s=u*4;D[u]=1,T[u]=l[s],q[u]=l[s+1],C[u]=l[s+2]}const E=P?ht([D,T,q,C],t,n,Math.max(4,Math.round(o*.6))):null,v=u=>{if(!P||!x[u])return 1;const s=u%t,F=u/t|0,k=E(0,s,F);if(k<4)return 1;const j=[E(1,s,F)/k,E(2,s,F)/k,E(3,s,F)/k],Q=u*4,N=[l[Q],l[Q+1],l[Q+2]];let L=0,et=1/0;for(const it of P){const R=[it[0]-j[0],it[1]-j[1],it[2]-j[2]],lt=R[0]*R[0]+R[1]*R[1]+R[2]*R[2];et=Math.min(et,Math.sqrt(lt)),lt>=1&&(L=Math.max(L,((N[0]-j[0])*R[0]+(N[1]-j[1])*R[1]+(N[2]-j[2])*R[2])/lt))}if(et<a.sep)return 1;const rt=Math.max(0,Math.min(1,(L-.12)/.2));return rt*rt*(3-2*rt)},J=d,G=new Uint8Array(e),[O,K]=a.chokeAI,[gt,Ut]=a.chokeArm;for(let u=0;u<e;u++){if(!r[u])continue;const s=x[u]?O:gt,F=x[u]?K:Ut;if(J[u]<s)continue;const k=Math.max(0,Math.min(1,(J[u]-s)/(F-s)))*v(u);G[u]=Math.round(255*k*k*(3-2*k))}return Mt(G,t,n,{snapped:h,band:r,core:h,arm:f,r:1,rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.03*o*o)})}const S=[];for(let r=0;r<e;r+=3)if(M[r]){const h=r*4;S.push([l[h],l[h+1],l[h+2]])}if(S.length<12)return i;S.sort((r,h)=>r[0]+r[1]+r[2]-h[0]-h[1]-h[2]);const z=r=>{const h=S.slice(Math.floor(S.length*r/3),Math.floor(S.length*(r+1)/3));return[0,1,2].map(x=>h.reduce((I,P)=>I+P[x],0)/h.length)},$=[z(0),z(1),z(2)],H=new Float32Array(e),B=new Float32Array(e),w=new Float32Array(e),tt=new Float32Array(e);let st=0,ct=0,ft=0,_=0;for(let r=0;r<e;r++)if(U[r]&&!p[r]){const h=r*4;H[r]=1,B[r]=l[h],w[r]=l[h+1],tt[r]=l[h+2],st+=B[r],ct+=w[r],ft+=tt[r],_++}const yt=_?[st/_,ct/_,ft/_]:null,b=ht([H,B,w,tt],t,n,Math.max(3,Math.round(o*.45))),Z=new Float32Array(e),nt=new Uint8Array(e);for(let r=0;r<n;r++)for(let h=0;h<t;h++){const x=r*t+h;if(!p[x]&&!(d&&U[x]&&!f[x]&&d[x]>.3))continue;if(nt[x]=1,M[x]){Z[x]=1;continue}const I=b(0,h,r),P=I>2?[b(1,h,r)/I,b(2,h,r)/I,b(3,h,r)/I]:yt;if(!P){Z[x]=i[x]/255;continue}const D=x*4,T=[l[D],l[D+1],l[D+2]];let q=0,C=1/0;for(const G of $){const O=[G[0]-P[0],G[1]-P[1],G[2]-P[2]],K=O[0]*O[0]+O[1]*O[1]+O[2]*O[2];C=Math.min(C,Math.sqrt(K)),!(K<1)&&(q=Math.max(q,((T[0]-P[0])*O[0]+(T[1]-P[1])*O[1]+(T[2]-P[2])*O[2])/K))}const E=d&&!f[x]?d[x]:null;if(C<a.sep){Z[x]=E??i[x]/255;continue}const v=Math.max(0,Math.min(1,(q-a.lo)/(a.hi-a.lo))),J=v*v*(3-2*v);Z[x]=E===null?J:E*J}const xt=kt(Z,Ft(l,t,n),t,n,{r:a.guideR,eps:a.guideEps}),ot=new Uint8Array(e),[mt,At]=a.choke;for(let r=0;r<e;r++){if(!nt[r])continue;if(M[r]){ot[r]=255;continue}const h=Math.max(0,Math.min(1,(xt[r]-mt)/(At-mt)));ot[r]=Math.round(255*h*h*(3-2*h))}return Mt(ot,t,n,{snapped:i,band:nt,core:M,arm:f,r:Math.max(1,Math.round(o*a.close)),rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.12*o*o)})}function pt(l,t,n,g,A,d,y){const a=2*d+1,e=new Uint8Array(n+a),M=new Uint8Array(n+a),p=f=>{const c=Math.max(0,Math.min(n-1,f-d));return l[g+c*A]},U=n+2*d,i=y?(f,c)=>f>c?f:c:(f,c)=>f<c?f:c;for(let f=0;f<U;f+=a){const c=Math.min(U,f+a);e[f]=p(f);for(let m=f+1;m<c;m++)e[m]=i(e[m-1],p(m));M[c-1]=p(c-1);for(let m=c-2;m>=f;m--)M[m]=i(M[m+1],p(m))}for(let f=0;f<n;f++)t[g+f*A]=i(M[f],e[f+2*d]??e[U-1])}function Y(l,t,n,g,A){const d=new Uint8Array(l.length),y=new Uint8Array(l.length);for(let a=0;a<n;a++)pt(l,d,t,a*t,1,g,A);for(let a=0;a<t;a++)pt(d,y,n,a,t,g,A);return y}function Mt(l,t,n,{snapped:g,band:A,core:d,arm:y,r:a,rArm:e,small:M}){const p=t*n,U=new Uint8Array(p);for(let o=0;o<p;o++)U[o]=l[o]>=128?255:0;const i=Y(Y(U,t,n,a,!0),t,n,a,!1),f=Y(Y(U,t,n,e,!0),t,n,e,!1);for(let o=0;o<p;o++)!U[o]&&A[o]&&(y[o]&&(i[o]||f[o])||!y[o]&&i[o]&&d[o])&&(l[o]=255);It(l,t,n,d,M,y);const c=new Uint8Array(p),m=[];for(let o=0;o<p;o++)d[o]&&l[o]>=64&&m.push(o);for(;m.length;){const o=m.pop();if(c[o]||l[o]<64)continue;c[o]=1;const S=o%t;S>0&&m.push(o-1),S<t-1&&m.push(o+1),o>=t&&m.push(o-t),o<p-t&&m.push(o+t)}for(let o=0;o<p;o++)c[o]||(l[o]=l[o]>=64?0:l[o]);return l}function It(l,t,n,g,A=0,d=null){const y=t*n,a=new Int32Array(y),e=[];for(let i=0;i<t;i++)e.push(i,(n-1)*t+i);for(let i=0;i<n;i++)e.push(i*t,i*t+t-1);const M=(i,f)=>{for(;e.length;){const c=e.pop();if(a[c]||l[c]>=128)continue;a[c]=i,f?.push(c);const m=c%t;m>0&&e.push(c-1),m<t-1&&e.push(c+1),c>=t&&e.push(c-t),c<y-t&&e.push(c+t)}};M(-1);for(let i=0,f=1;i<y;i++){if(a[i]||l[i]>=128)continue;const c=[];e.push(i),M(f++,c);const m=c.length<A&&(!d||c.every(o=>d[o]));for(const o of c)(m||g[o])&&(l[o]=255)}const p=new Uint8Array(y);for(let i=0;i<y;i++)p[i]=a[i]===-1||a[i]>0&&l[i]<128?255:0;const U=Y(p,t,n,2,!0);for(let i=0;i<y;i++)l[i]&&l[i]<255&&!U[i]&&(l[i]=255);return l}function Yt(l,t,n=dt.maxW){const g=Math.min(n,l),A=Math.max(2,Math.round(g*t/l/2)*2);return{w:Math.round(g/2)*2,h:A}}export{dt as HAND_MATTE,X as fillCapsule,W as fillPolygon,Xt as handMatteFrame,Yt as handMatteSize};
@@ -1,2 +1,2 @@
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};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-VVYiW8XD.js","assets/titleFrameBudget-CLZWaFHO.js","assets/remote-C7J0Tqhb.js","assets/api-CJ8PdbfZ.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-DW4E9xnW.js","assets/rotoMaskStore-DPziPKAN.js","assets/textAnimators-DUZjhVGO.js","assets/timelineComp-B4GtoH2f.js","assets/rigTrack-urT3nDK0.js","assets/spark.module-DzziUgOj.js","assets/userFonts-CwlKh9NR.js","assets/lottieLayer-DzbA3bHV.js","assets/timeline3d-DOw-CpZI.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-QYsT9JBO.js","assets/captionLayout-DvDPTwO9.js","assets/timelineText-BH09jfSM.js","assets/titleArt-Drsrtfiv.js","assets/rotoMatte-C-2o3vv0.js","assets/distortGL-QalhICvi.js","assets/motionBlur-uAm030t9.js","assets/main-Ca_CVxMz.css","assets/handMatte-Dl-xVXFR.js","assets/matteFixRun-vgYrINet.js"])))=>i.map(i=>d[i]);
2
+ import{c1 as Y,_ as N,a7 as Z,b_ as tt}from"./titleFrameBudget-CLZWaFHO.js";import{u as V}from"./store-DW4E9xnW.js";import{t as W}from"./api-CJ8PdbfZ.js";import{a7 as et,a8 as at,a9 as nt,a6 as X,aa as ot}from"./main-VVYiW8XD.js";import{iE as it,iF as rt,iG as J,iH as st,iI as ct,iJ as K,iK as lt,bd as z,iL as dt,iM as mt,iN as ut}from"./remote-C7J0Tqhb.js";import{handMatteSize as ht,handMatteFrame as ft}from"./handMatte-Dl-xVXFR.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DzziUgOj.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";import"./userFonts-CwlKh9NR.js";import"./lottieLayer-DzbA3bHV.js";import"./timeline3d-DOw-CpZI.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-QYsT9JBO.js";import"./captionLayout-DvDPTwO9.js";import"./timelineText-BH09jfSM.js";import"./titleArt-Drsrtfiv.js";import"./rotoMatte-C-2o3vv0.js";import"./distortGL-QalhICvi.js";import"./motionBlur-uAm030t9.js";const pt="https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task",wt=`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${X}/wasm`,gt=640;let $=null;async function yt(){if(typeof window<"u"&&window.__handTrackerStub)return{detect:window.__handTrackerStub,close:()=>{}};const{FilesetResolver:d,HandLandmarker:w}=await N(async()=>{const{FilesetResolver:c,HandLandmarker:s}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:c,HandLandmarker:s}},[]);$??=d.forVisionTasks(wt).catch(c=>{throw $=null,c});const a=await w.createFromOptions(await $,{baseOptions:{modelAssetPath:pt,delegate:"CPU"},runningMode:"VIDEO",numHands:2,minHandDetectionConfidence:.5,minHandPresenceConfidence:.5,minTrackingConfidence:.5});let f=0;return{detect:(c,s)=>{f=Math.max(f+1,Math.round(s));const b=a.detectForVideo(c,f);return(b.landmarks??[]).map((m,v)=>({lm:m.map(p=>[p.x,p.y]),label:b.handedness?.[v]?.[0]?.categoryName??"",score:b.handedness?.[v]?.[0]?.score??1}))},close:()=>a.close()}}async function Mt({clip:d,url:w,from:a,duration:f,signal:c,onProgress:s}){const b=f*(d.playbackRate||1),m=b*30<=K.maxFrames?30:15,v=Math.max(2,Math.min(K.maxFrames,Math.round(b*m)+1)),{detect:p,close:C}=await yt(),u=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});u.src=w;try{await new Promise((r,h)=>{u.onloadeddata=()=>r(),u.onerror=()=>h(Error(W("Không đọc được video để bám tay (CORS / định dạng)")))});const x=u.videoWidth||1280,H=u.videoHeight||720,S=Math.min(gt,x),o=Math.max(2,Math.round(S*H/x)),i=Object.assign(document.createElement("canvas"),{width:S,height:o}),y=i.getContext("2d",{willReadFrequently:!0}),E=z(d,a),T=[];let n=[null,null];for(let r=0;r<v;r++){if(c?.aborted)throw new DOMException("Đã huỷ","AbortError");const h=Math.max(0,Math.min(u.duration-1/60,E+r/m));Math.abs(u.currentTime-h)>1e-4&&await new Promise((t,e)=>{const l=window.setTimeout(()=>e(Error(W("Seek video quá lâu"))),8e3);u.onseeked=()=>{window.clearTimeout(l),t()},u.currentTime=h}),y.drawImage(u,0,0,S,o);const _=p(i,(r+1)*1e3/m).filter(t=>Array.isArray(t.lm)&&t.lm.length>=21).slice(0,2),k=[null,null],R=t=>t.label==="Left"?0:t.label==="Right"?1:-1,M=(t,e)=>{const l=n[e];return l?Math.hypot(l.lm[0][0]-t.lm[0][0],l.lm[0][1]-t.lm[0][1]):1/0};if(_.length===2&&R(_[0])===R(_[1])){const t=_[0],e=_[1],l=M(t,0)+M(e,1)<=M(t,1)+M(e,0),[O,A]=Number.isFinite(M(t,0)+M(e,1))||Number.isFinite(M(t,1)+M(e,0))?l?[t,e]:[e,t]:t.lm[0][0]>e.lm[0][0]?[t,e]:[e,t];k[0]={lm:O.lm.map(F=>[F[0],F[1]]),score:O.score},k[1]={lm:A.lm.map(F=>[F[0],F[1]]),score:A.score}}else for(const t of _){let e=R(t);if(e<0&&(e=t.lm[0][0]>.5?0:1),_.length===1){const l=1-e;M(t,l)<.08&&M(t,e)>.15&&(e=l)}k[e]||(k[e]={lm:t.lm.map(l=>[l[0],l[1]]),score:t.score})}if(k.some(Boolean)){const t=y.getImageData(0,0,S,o).data,e=(l,O)=>{const A=(Math.max(0,Math.min(o-1,O))*S+Math.max(0,Math.min(S-1,l)))*4;return[t[A],t[A+1],t[A+2]]};for(const l of k)if(l){const O=mt(l.lm,S,o,e);O&&(l.edge=O)}}T.push(k),n=[k[0]??n[0],k[1]??n[1]],s?.(r+1,v)}return ut({mw:x,mh:H,fps:m,s0:E,frames:T})}finally{u.removeAttribute("src"),u.load(),C()}}let B=null,q=null;async function xt(d,w,a){const f=typeof window<"u"?window.__bodySkinStub:void 0;B??=f?Promise.resolve(f):(async()=>{const{FilesetResolver:p,ImageSegmenter:C}=await N(async()=>{const{FilesetResolver:H,ImageSegmenter:S}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:H,ImageSegmenter:S}},[]),u=await p.forVisionTasks(`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${X}/wasm`),x=await C.createFromOptions(u,{baseOptions:{modelAssetPath:ot,delegate:"CPU"},runningMode:"IMAGE",outputConfidenceMasks:!0,outputCategoryMask:!1});return H=>{const S=x.segment(H);try{const o=S.confidenceMasks?.[2];if(!o)throw Error("no skin mask");return{data:o.getAsFloat32Array().slice(),width:o.width,height:o.height}}finally{S.close()}}})().catch(p=>{throw B=null,p});const c=await B;q??=document.createElement("canvas");const s=960,b=Math.max(2,Math.round(960*d.height/d.width));(q.width!==s||q.height!==b)&&Object.assign(q,{width:s,height:b}),q.getContext("2d").drawImage(d,0,0,s,b);const m=c(q),v=new Float32Array(w*a);for(let p=0;p<a;p++){const C=Math.min(m.height-1,Math.floor((p+.5)/a*m.height))*m.width;for(let u=0;u<w;u++){const x=m.data[C+Math.min(m.width-1,Math.floor((u+.5)/w*m.width))];v[p*w+u]=Math.max(0,Math.min(1,(x-.25)/.4))}}return v}const kt=[0,1,2,3,5,6,7,9,10,11,13,14,15,17,18,19];let G=null;async function bt(d,w,a,f,c,s){const{objectProbability:b}=await N(async()=>{const{objectProbability:o}=await import("./main-VVYiW8XD.js").then(i=>i.aL);return{objectProbability:o}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),m=new Float32Array(c*s),v=512;G??=Object.assign(document.createElement("canvas"),{width:v,height:v});const p=G.getContext("2d",{willReadFrequently:!0}),C=async(o,i,y,E,T)=>{p.fillStyle="#000",p.fillRect(0,0,v,v),p.drawImage(d,o,i,y,E,0,0,v,v);const n=await b(G,T.map(h=>({x:(h.x-o)/y,y:(h.y-i)/E})).filter(h=>h.x>0&&h.x<1&&h.y>0&&h.y<1)),r=new Float32Array(c*s);for(let h=0;h<s;h++){const _=((h+.5)/s*a-i)/E;if(_<0||_>=1)continue;const k=Math.floor(_*n.height)*n.width;for(let R=0;R<c;R++){const M=((R+.5)/c*w-o)/y;M<0||M>=1||(r[h*c+R]=n.data[k+Math.floor(M*n.width)])}}return r},{fillCapsule:u,fillPolygon:x}=await N(async()=>{const{fillCapsule:o,fillPolygon:i}=await import("./handMatte-Dl-xVXFR.js");return{fillCapsule:o,fillPolygon:i}},__vite__mapDeps([24,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),H=[],S=await xt(d,c,s);for(const{lm:o}of f){const i=o.map(t=>t[0]*w),y=o.map(t=>t[1]*a),E=Math.hypot(i[0]-i[9],y[0]-y[9])||1,T=kt.map(t=>({x:i[t],y:y[t]}));T.push({x:i[0]+(i[0]-i[9])*.6,y:y[0]+(y[0]-y[9])*.6});const r=await C(...((t,e,l,O=1)=>{const A=Math.min(...t)-l,F=Math.max(...t)+l,I=Math.min(...e)-l,g=Math.max(...e)+l,P=Math.max(F-A,g-I),D=Math.min(w,Math.max(F-A,P/O)),j=Math.min(a,Math.max(g-I,P/O)),L=Math.min(D,j*O),U=Math.min(j,D*O);return[Math.max(0,Math.min(w-L,(A+F)/2-L/2)),Math.max(0,Math.min(a-U,(I+g)/2-U/2)),L,U]})([...i,i[0]+(i[0]-i[9])*3],[...y,y[0]+(y[0]-y[9])*3],.6*E),T);let h=(i[0]-i[9])/E,_=(y[0]-y[9])/E;{const t=i[0]/w*c,e=y[0]/a*s,l=E/w*c;let O=0,A=0,F=0;for(let I=0;I<s;I++)for(let g=0;g<c;g++){if(r[I*c+g]<.5)continue;const P=Math.hypot(g-t,I-e);if(P<1.2*l||P>3*l)continue;const D=g-t,j=I-e;D*h+j*_<-.2*P||(O+=g,A+=I,F++)}if(F>20){const I=O/F-t,g=A/F-e,P=Math.hypot(I,g)||1;(I*h+g*_)/P>Math.cos(75*Math.PI/180)&&(h=I/P,_=g/P)}}H.push([h,_]);const k=new Uint8Array(c*s),R=i.map((t,e)=>[t/w*c,y[e]/a*s]),M=E/w*c;for(const[t,e]of[[1,2],[2,3],[3,4],[5,6],[6,7],[7,8],[9,10],[10,11],[11,12],[13,14],[14,15],[15,16],[17,18],[18,19],[19,20],[0,1],[0,5],[0,17]])u(k,R[t],R[e],.35*M,c,s);x(k,[0,1,5,9,13,17].map(t=>R[t]),c,s);for(let t=0;t<c*s;t++){const e=k[t]?Math.max(r[t],S[t]*.5):S[t];e>m[t]&&(m[t]=e)}}return{map:m,armDirs:H}}async function Q({clip:d,url:w,from:a,duration:f,until:c=1/0,refine:s=null,store:b=!0,signal:m,onProgress:v}){if(!d.hands)throw Error(W("Không tìm thấy clip video có tay"));const p=lt(d.hands),C=d.playbackRate||1,u=p.fps,x=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});x.src=w;try{await new Promise((t,e)=>{x.onloadeddata=()=>t(),x.onerror=()=>e(Error(W("Không đọc được video để bám tay (CORS / định dạng)")))});const H=x.videoWidth||p.mw,S=x.videoHeight||p.mh,{w:o,h:i}=ht(H,S),y=Object.assign(document.createElement("canvas"),{width:o,height:i}),E=y.getContext("2d",{willReadFrequently:!0}),T=z(d,a),n=Math.max(1,Math.min(K.maxFrames,Math.round(f*C*u)+1)),r=z(d,c),h=et({mw:H,mh:S,w:o,h:i,fps:u,s0:T},32),_=at(t=>h.push(t)),k=s?await Z(s):null,R=nt(x);let M=!0;for(let t=0;t<n;t++){if(m?.aborted)throw new DOMException("Đã huỷ","AbortError");const e=T+t/u;if(e>r+1e-6){_.push(new Uint8Array(o*i)),v?.(t+1,n);continue}const l=await R(Math.max(0,Math.min(x.duration-1/60,e)));E.drawImage(l,0,0,o,i);const O=Math.max(0,Math.min(p.n-1,Math.round((e-p.s0)*u))),A=[0,1].map(g=>{const P=dt(p,e,g);return P?{lm:P,edge:p.frames[O][g]?.edge??null}:null}).filter(Boolean);let F=null;if(M&&A.length)try{const g=await bt(l,H,S,A,o,i);F=g.map,g.armDirs.forEach((P,D)=>{A[D].armDir=P})}catch(g){M=!1,console.warn("hand cut-out model",g)}let I=A.length?ft(E.getImageData(0,0,o,i).data,o,i,A,{learned:F}):new Uint8Array(o*i);if(k&&s){const g=tt(k,s,e),P=s.w,D=s.h,j=new Uint8Array(o*i);for(let L=0;L<i;L++)for(let U=0;U<o;U++)j[L*o+U]=Math.round(I[L*o+U]*g[Math.min(D-1,Math.floor(L*D/i))*P+Math.min(P-1,Math.floor(U*P/o))]/255);I=j}_.push(I),v?.(t+1,n),t%4===3&&await new Promise(g=>setTimeout(g,0))}return _.finish(),await h.finish({feather:0,grow:0},{store:b})}finally{x.removeAttribute("src"),x.load()}}async function vt(d,w,a){const f=V.getState().clips.find(b=>b.id===d);if(!f||f.kind!=="video")throw Error(W("Không tìm thấy clip video có tay"));if(ct(f,w,a))return f;const c=document.querySelector(`video[data-clip-media="${f.id}"]`)?.currentSrc||f.url,s=await Mt({clip:f,url:c,from:w,duration:Math.min(a,K.maxFrames/15/(f.playbackRate||1))});if(!s.data||!/[^A]/.test(s.data.replace(/=+$/,"")))throw Error(W("Không thấy bàn tay nào trong đoạn này"));return V.setState(b=>({clips:b.clips.map(m=>m.id===f.id?{...m,hands:s}:m)})),{...f,hands:s}}const _t=d=>new Promise(w=>setTimeout(w,d));async function Jt(d,w){const a=w.params??{},f=await vt(String(a.source),a.from??0,a.duration??d.duration),c=V.getState(),{width:s,height:b}=Y(c.timelineFormat);if(a.mode==="attach"){const n=c.clips.find(r=>r.id===d.id)??d;return it(n,f,{point:a.point,side:a.side,scale:!!a.scale,offset:a.offset??null,W:s,H:b})}if(a.mode==="wipe"){const n=c.clips.find(e=>e.id===d.id)??d,r=c.clips.find(e=>e.id===f.id)??f,h=n.mask,_=rt(n,r,{point:a.point,side:a.side,dir:a.dir,feather:a.feather,W:s,H:b,mw:h?.mw,mh:h?.mh}),k=c.clips.find(e=>e.id===a.cutout),R=document.querySelector(`video[data-clip-media="${r.id}"]`)?.currentSrc||r.url;let M=null;if(k)try{M=await Q({clip:r,url:R,from:a.from??0,duration:a.duration??d.duration,refine:k.person??null})}catch(e){console.warn("hand matte",e)}const t=M||!k?void 0:J({...k,hands:r.hands});return V.setState(e=>({clips:e.clips.map(l=>l.id===a.cutout?M?{...l,person:M,mask:void 0}:t?{...l,mask:t}:l:l)})),_.patch}for(let n=0;n<360&&V.getState().clips.find(r=>r.id===a.wall)?.pendingPin;n++)await _t(500);const m=V.getState(),v=m.clips.find(n=>n.id===a.wall),p=m.clips.find(n=>n.id===d.id)??d,C=m.clips.find(n=>n.id===f.id)??f;if(!v)throw Error(W("Không còn tường HUD"));const u=st({wall:v,layer:p,src:C,clips:m.clips,cam:m.timelineCamera,W:s,H:b,events:a.events??null,grab:a.grab??"auto",side:a.side,fly:a.fly}),x=m.clips.find(n=>n.id===a.cutout),H=document.querySelector(`video[data-clip-media="${C.id}"]`)?.currentSrc||C.url,S=(a.matte?m.clips.find(n=>n.id===a.matte)?.person:null)??x?.person??null;let o=null;if(x)try{o=await Q({clip:C,url:H,from:a.from??0,duration:a.duration??d.duration,until:u.cutoutUntil,refine:S})}catch(n){console.warn("hand matte",n)}const i=x?.matteFix?.fixes??[],y=o;if(o&&i.length)try{const{fixedMatte:n}=await N(async()=>{const{fixedMatte:r}=await import("./matteFixRun-vgYrINet.js");return{fixedMatte:r}},__vite__mapDeps([25,6,1,3,0,2,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]));o=await n(o,i,C.hands)}catch(n){console.warn("hand touch-ups",n)}const E=o?void 0:J(C,{until:u.cutoutUntil}),T=n=>{const r=n.mask?.masks?.find(h=>h.id==="wall");return!r||!n.mask?n:o?{...n,person:o,mask:{...n.mask,masks:[{...r,mode:"add"}]}}:E?{...n,mask:{...E,masks:[...E.masks,{...r,mode:"intersect"}]}}:n};return V.setState(n=>({clips:n.clips.map(r=>r.id===v.id?{...r,motion:u.wall}:r.id===a.cutout?o?{...r,person:o,mask:void 0,...i.length?{matteFix:{auto:y,fixes:i}}:{}}:E?{...r,mask:E}:r:r.id===a.shadow?T(r):r)})),{motion:u.grab}}export{pt as HAND_MODEL_URL,Q as buildHandMatte,bt as learnedHands,Jt as runHandTrack,Mt as trackHands};
@@ -275,4 +275,4 @@
275
275
  * This Source Code Form is subject to the terms of the Mozilla Public
276
276
  * License, v. 2.0. If a copy of the MPL was not distributed with this
277
277
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
278
- */var lt;(function(r){r[r.Unsynchronisation=128]="Unsynchronisation",r[r.ExtendedHeader=64]="ExtendedHeader",r[r.ExperimentalIndicator=32]="ExperimentalIndicator",r[r.Footer=16]="Footer"})(lt||(lt={}));var Y;(function(r){r[r.ISO_8859_1=0]="ISO_8859_1",r[r.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",r[r.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",r[r.UTF_8=3]="UTF_8"})(Y||(Y={}));const fr=128,be=10,Pt=["Blues","Classic rock","Country","Dance","Disco","Funk","Grunge","Hip-hop","Jazz","Metal","New age","Oldies","Other","Pop","Rhythm and blues","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death metal","Pranks","Soundtrack","Euro-techno","Ambient","Trip-hop","Vocal","Jazz & funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound clip","Gospel","Noise","Alternative rock","Bass","Soul","Punk","Space","Meditative","Instrumental pop","Instrumental rock","Ethnic","Gothic","Darkwave","Techno-industrial","Electronic","Pop-folk","Eurodance","Dream","Southern rock","Comedy","Cult","Gangsta","Top 40","Christian rap","Pop/funk","Jungle music","Native US","Cabaret","New wave","Psychedelic","Rave","Showtunes","Trailer","Lo-fi","Tribal","Acid punk","Acid jazz","Polka","Retro","Musical","Rock 'n' roll","Hard rock","Folk","Folk rock","National folk","Swing","Fast fusion","Bebop","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic rock","Progressive rock","Psychedelic rock","Symphonic rock","Slow rock","Big band","Chorus","Easy listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber music","Sonata","Symphony","Booty bass","Primus","Porn groove","Satire","Slow jam","Club","Tango","Samba","Folklore","Ballad","Power ballad","Rhythmic Soul","Freestyle","Duet","Punk rock","Drum solo","A cappella","Euro-house","Dance hall","Goa music","Drum & bass","Club-house","Hardcore techno","Terror","Indie","Britpop","Negerpunk","Polsk punk","Beat","Christian gangsta rap","Heavy metal","Black metal","Crossover","Contemporary Christian","Christian rock","Merengue","Salsa","Thrash metal","Anime","Jpop","Synthpop","Christmas","Art rock","Baroque","Bhangra","Big beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math rock","New romantic","Nu-breakz","Post-punk","Post-rock","Psytrance","Shoegaze","Space rock","Trop rock","World music","Neoclassical","Audiobook","Audio theatre","Neue Deutsche Welle","Podcast","Indie rock","G-Funk","Dubstep","Garage rock","Psybient"],Pu=(r,e)=>{const t=r.filePos;e.raw??={},e.raw.TAG??=z(r,fr-3),r.filePos=t;const i=pt(r,30);i&&(e.title??=i);const n=pt(r,30);n&&(e.artist??=n);const a=pt(r,30);a&&(e.album??=a);const s=pt(r,4),o=Number.parseInt(s,10);Number.isInteger(o)&&o>0&&(e.date??=new Date(String(o)));const c=z(r,30);let l;if(c[28]===0&&c[29]!==0){const u=c[29];u>0&&(e.trackNumber??=u),r.skip(-30),l=pt(r,28),r.skip(2)}else r.skip(-30),l=pt(r,30);l&&(e.comment??=l);const d=O(r);d<Pt.length&&(e.genre??=Pt[d])},pt=(r,e)=>{const t=z(r,e),i=gt(t.indexOf(0),t.length),n=t.subarray(0,i);let a="";for(let s=0;s<n.length;s++)a+=String.fromCharCode(n[s]);return a.trimEnd()},We=r=>{const e=r.filePos,t=K(r,3),i=O(r),n=O(r),a=O(r),s=R(r);if(t!=="ID3"||i===255||n===255||(s&2155905152)!==0)return r.filePos=e,null;let o=yi(s);return a&lt.Footer&&(o+=be),{majorVersion:i,revision:n,flags:a,size:o}},Wr=(r,e,t)=>{if(![2,3,4].includes(e.majorVersion)){U._warn(`Unsupported ID3v2 major version: ${e.majorVersion}`);return}const i=e.flags&lt.Footer?e.size-be:e.size,n=z(r,i),a=new Iu(e,n);if(e.flags&lt.Unsynchronisation&&e.majorVersion===3&&a.ununsynchronizeAll(),e.flags&lt.ExtendedHeader){const s=a.readU32();e.majorVersion===3?a.pos+=s:a.pos+=s-4}for(;a.pos<=a.bytes.length-a.frameHeaderSize();){const s=a.readId3V2Frame();if(!s)break;const o=a.pos,c=a.pos+s.size;let l=!1,d=!1,u=!1;if(e.majorVersion===3?(l=!!(s.flags&64),d=!!(s.flags&128)):e.majorVersion===4&&(l=!!(s.flags&4),d=!!(s.flags&8),u=!!(s.flags&2)||!!(e.flags&lt.Unsynchronisation)),l){U._warn(`Skipping encrypted ID3v2 frame ${s.id}`),a.pos=c;continue}if(d){U._warn(`Skipping compressed ID3v2 frame ${s.id}`),a.pos=c;continue}if(u&&a.ununsynchronizeRegion(a.pos,c),t.raw??={},s.id==="TXXX"){const f=t.raw.TXXX??={},m=a.readId3V2TextEncoding(),p=a.readId3V2Text(m,c),h=a.readId3V2Text(m,c);f[p]??=h}else s.id[0]==="T"?t.raw[s.id]??=a.readId3V2EncodingAndText(c):t.raw[s.id]??=a.readBytes(s.size);switch(a.pos=o,s.id){case"TIT2":case"TT2":t.title??=a.readId3V2EncodingAndText(c);break;case"TIT3":case"TT3":t.description??=a.readId3V2EncodingAndText(c);break;case"TPE1":case"TP1":t.artist??=a.readId3V2EncodingAndText(c);break;case"TALB":case"TAL":t.album??=a.readId3V2EncodingAndText(c);break;case"TPE2":case"TP2":t.albumArtist??=a.readId3V2EncodingAndText(c);break;case"TRCK":case"TRK":{const m=a.readId3V2EncodingAndText(c).split("/"),p=Number.parseInt(m[0],10),h=m[1]&&Number.parseInt(m[1],10);Number.isInteger(p)&&p>0&&(t.trackNumber??=p),h&&Number.isInteger(h)&&h>0&&(t.tracksTotal??=h)}break;case"TPOS":case"TPA":{const m=a.readId3V2EncodingAndText(c).split("/"),p=Number.parseInt(m[0],10),h=m[1]&&Number.parseInt(m[1],10);Number.isInteger(p)&&p>0&&(t.discNumber??=p),h&&Number.isInteger(h)&&h>0&&(t.discsTotal??=h)}break;case"TCON":case"TCO":{const f=a.readId3V2EncodingAndText(c);let m=/^\((\d+)\)/.exec(f);if(m){const p=Number.parseInt(m[1]);if(Pt[p]!==void 0){t.genre??=Pt[p];break}}if(m=/^\d+$/.exec(f),m){const p=Number.parseInt(m[0]);if(Pt[p]!==void 0){t.genre??=Pt[p];break}}t.genre??=f}break;case"TDRC":case"TDAT":{const f=a.readId3V2EncodingAndText(c),m=new Date(f);Number.isNaN(m.getTime())||(t.date??=m)}break;case"TYER":case"TYE":{const f=a.readId3V2EncodingAndText(c),m=Number.parseInt(f,10);Number.isInteger(m)&&(t.date??=new Date(String(m)))}break;case"USLT":case"ULT":{const f=a.readU8();a.pos+=3,a.readId3V2Text(f,c),t.lyrics??=a.readId3V2Text(f,c)}break;case"COMM":case"COM":{const f=a.readU8();a.pos+=3,a.readId3V2Text(f,c),t.comment??=a.readId3V2Text(f,c)}break;case"APIC":case"PIC":{const f=a.readId3V2TextEncoding();let m;if(e.majorVersion===2){const k=a.readAscii(3);m=k==="PNG"?"image/png":k==="JPG"?"image/jpeg":"image/*"}else m=a.readId3V2Text(f,c);const p=a.readU8(),h=a.readId3V2Text(f,c).trimEnd(),g=c-a.pos;if(g>=0){const k=a.readBytes(g);t.images||(t.images=[]),t.images.push({data:k,mimeType:m,kind:p===3?"coverFront":p===4?"coverBack":"unknown",description:h})}}break;default:a.pos+=s.size;break}a.pos=c}};class Iu{constructor(e,t){this.header=e,this.bytes=t,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}frameHeaderSize(){return this.header.majorVersion===2?6:10}ununsynchronizeAll(){const e=[];for(let t=0;t<this.bytes.length;t++){const i=this.bytes[t];e.push(i),i===255&&t!==this.bytes.length-1&&this.bytes[t]===0&&t++}this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}ununsynchronizeRegion(e,t){const i=[];for(let s=e;s<t;s++){const o=this.bytes[s];i.push(o),o===255&&s!==t-1&&this.bytes[s+1]===0&&s++}const n=this.bytes.subarray(0,e),a=this.bytes.subarray(t);this.bytes=new Uint8Array(n.length+i.length+a.length),this.bytes.set(n,0),this.bytes.set(i,n.length),this.bytes.set(a,n.length+i.length),this.view=new DataView(this.bytes.buffer)}readBytes(e){const t=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,t}readU8(){const e=this.view.getUint8(this.pos);return this.pos+=1,e}readU16(){const e=this.view.getUint16(this.pos,!1);return this.pos+=2,e}readU24(){const e=this.view.getUint16(this.pos,!1),t=this.view.getUint8(this.pos+2);return this.pos+=3,e*256+t}readU32(){const e=this.view.getUint32(this.pos,!1);return this.pos+=4,e}readAscii(e){let t="";for(let i=0;i<e;i++)t+=String.fromCharCode(this.view.getUint8(this.pos+i));return this.pos+=e,t}readId3V2Frame(){if(this.header.majorVersion===2){const e=this.readAscii(3);if(e==="\0\0\0")return null;const t=this.readU24();return{id:e,size:t,flags:0}}else{const e=this.readAscii(4);if(e==="\0\0\0\0")return null;const t=this.readU32();let i=this.header.majorVersion===4?yi(t):t;const n=this.readU16(),a=this.pos,s=o=>{const c=this.pos+o;if(c>this.bytes.length)return!1;if(c<=this.bytes.length-this.frameHeaderSize()){this.pos+=o;const l=this.readAscii(4);if(l!=="\0\0\0\0"&&!/[0-9A-Z]{4}/.test(l))return!1}return!0};if(!s(i)){const o=this.header.majorVersion===4?t:yi(t);s(o)&&(i=o)}return this.pos=a,{id:e,size:i,flags:n}}}readId3V2TextEncoding(){const e=this.readU8();if(e>3)throw new Error(`Unsupported text encoding: ${e}`);return e}readId3V2Text(e,t){const i=this.pos,n=this.readBytes(t-this.pos);switch(e){case Y.ISO_8859_1:{let a="";for(let s=0;s<n.length;s++){const o=n[s];if(o===0){this.pos=i+s+1;break}a+=String.fromCharCode(o)}return a}case Y.UTF_16_WITH_BOM:if(n[0]===255&&n[1]===254){const a=new TextDecoder("utf-16le"),s=gt(n.findIndex((o,c)=>o===0&&n[c+1]===0&&c%2===0),n.length);return this.pos=i+Math.min(s+2,n.length),a.decode(n.subarray(2,s))}else if(n[0]===254&&n[1]===255){const a=new TextDecoder("utf-16be"),s=gt(n.findIndex((o,c)=>o===0&&n[c+1]===0&&c%2===0),n.length);return this.pos=i+Math.min(s+2,n.length),a.decode(n.subarray(2,s))}else{const a=gt(n.findIndex(s=>s===0),n.length);return this.pos=i+Math.min(a+1,n.length),le.decode(n.subarray(0,a))}case Y.UTF_16_BE_NO_BOM:{const a=new TextDecoder("utf-16be"),s=gt(n.findIndex((o,c)=>o===0&&n[c+1]===0&&c%2===0),n.length);return this.pos=i+Math.min(s+2,n.length),a.decode(n.subarray(0,s))}case Y.UTF_8:{const a=gt(n.findIndex(s=>s===0),n.length);return this.pos=i+Math.min(a+1,n.length),le.decode(n.subarray(0,a))}}}readId3V2EncodingAndText(e){if(this.pos>=e)return"";const t=this.readId3V2TextEncoding();return this.readId3V2Text(t,e)}}class Dd{constructor(e){this.helper=new Uint8Array(8),this.helperView=q(this.helper),this.writer=e}writeId3V2Tag(e){const t=this.writer.getPos();this.writeAscii("ID3"),this.writeU8(4),this.writeU8(0),this.writeU8(0),this.writeSynchsafeU32(0);const i=this.writer.getPos(),n=new Set;for(const{key:o,value:c}of _s(e))switch(o){case"title":this.writeId3V2TextFrame("TIT2",c),n.add("TIT2");break;case"description":this.writeId3V2TextFrame("TIT3",c),n.add("TIT3");break;case"artist":this.writeId3V2TextFrame("TPE1",c),n.add("TPE1");break;case"album":this.writeId3V2TextFrame("TALB",c),n.add("TALB");break;case"albumArtist":this.writeId3V2TextFrame("TPE2",c),n.add("TPE2");break;case"trackNumber":{const l=e.tracksTotal!==void 0?`${c}/${e.tracksTotal}`:c.toString();this.writeId3V2TextFrame("TRCK",l),n.add("TRCK")}break;case"discNumber":{const l=e.discsTotal!==void 0?`${c}/${e.discsTotal}`:c.toString();this.writeId3V2TextFrame("TPOS",l),n.add("TPOS")}break;case"genre":this.writeId3V2TextFrame("TCON",c),n.add("TCON");break;case"date":this.writeId3V2TextFrame("TDRC",c.toISOString().slice(0,10)),n.add("TDRC");break;case"lyrics":this.writeId3V2LyricsFrame(c),n.add("USLT");break;case"comment":this.writeId3V2CommentFrame(c),n.add("COMM");break;case"images":{const l={coverFront:3,coverBack:4,unknown:0};for(const d of c){const u=l[d.kind]??0,f=d.description??"";this.writeId3V2ApicFrame(d.mimeType,u,f,d.data)}}break;case"tracksTotal":case"discsTotal":break;case"raw":break;default:ve(o)}if(e.raw)for(const o in e.raw){const c=e.raw[o];if(c==null||o.length!==4||n.has(o))continue;let l;if(typeof c=="string")if(Xe(c)){l=new Uint8Array(c.length+2),l[0]=Y.ISO_8859_1;for(let u=0;u<c.length;u++)l[u+1]=c.charCodeAt(u)}else{const u=ye.encode(c);l=new Uint8Array(u.byteLength+2),l[0]=Y.UTF_8,l.set(u,1)}else if(c instanceof Uint8Array)l=c;else if(o==="TXXX"&&Fs(c)){for(const d in c){const u=c[d],f=Xe(d)&&Xe(u),m=f?null:ye.encode(d),p=f?null:ye.encode(u),h=f?d.length:m.byteLength,g=f?u.length:p.byteLength,k=1+h+1+g+1;this.writeAscii("TXXX"),this.writeSynchsafeU32(k),this.writeU16(0),this.writeU8(f?Y.ISO_8859_1:Y.UTF_8),f?(this.writeIsoString(d),this.writeIsoString(u)):(this.writer.write(m),this.writeU8(0),this.writer.write(p),this.writeU8(0))}continue}else continue;this.writeAscii(o),this.writeSynchsafeU32(l.byteLength),this.writeU16(0),this.writer.write(l)}const a=this.writer.getPos(),s=a-i;return this.writer.seek(t+6),this.writeSynchsafeU32(s),this.writer.seek(a),s+10}writeU8(e){this.helper[0]=e,this.writer.write(this.helper.subarray(0,1))}writeU16(e){this.helperView.setUint16(0,e,!1),this.writer.write(this.helper.subarray(0,2))}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeAscii(e){for(let t=0;t<e.length;t++)this.helper[t]=e.charCodeAt(t);this.writer.write(this.helper.subarray(0,e.length))}writeSynchsafeU32(e){this.writeU32(fc(e))}writeIsoString(e){const t=new Uint8Array(e.length+1);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);this.writer.write(t)}writeUtf8String(e){const t=ye.encode(e);this.writer.write(t),this.writeU8(0)}writeId3V2TextFrame(e,t){const i=Xe(t),a=1+(i?t.length:ye.encode(t).byteLength)+1;this.writeAscii(e),this.writeSynchsafeU32(a),this.writeU16(0),this.writeU8(i?Y.ISO_8859_1:Y.UTF_8),i?this.writeIsoString(t):this.writeUtf8String(t)}writeId3V2LyricsFrame(e){const t=Xe(e),i="",n=4+i.length+1+e.length+1;this.writeAscii("USLT"),this.writeSynchsafeU32(n),this.writeU16(0),this.writeU8(t?Y.ISO_8859_1:Y.UTF_8),this.writeAscii("und"),t?(this.writeIsoString(i),this.writeIsoString(e)):(this.writeUtf8String(i),this.writeUtf8String(e))}writeId3V2CommentFrame(e){const t=Xe(e),i=t?e.length:ye.encode(e).byteLength,n="",a=4+n.length+1+i+1;this.writeAscii("COMM"),this.writeSynchsafeU32(a),this.writeU16(0),this.writeU8(t?Y.ISO_8859_1:Y.UTF_8),this.writeU8(117),this.writeU8(110),this.writeU8(100),t?(this.writeIsoString(n),this.writeIsoString(e)):(this.writeUtf8String(n),this.writeUtf8String(e))}writeId3V2ApicFrame(e,t,i,n){const a=Xe(e)&&Xe(i),s=a?i.length:ye.encode(i).byteLength,o=1+e.length+1+1+s+1+n.byteLength;this.writeAscii("APIC"),this.writeSynchsafeU32(o),this.writeU16(0),this.writeU8(a?Y.ISO_8859_1:Y.UTF_8),a?this.writeIsoString(e):this.writeUtf8String(e),this.writeU8(t),a?this.writeIsoString(i):this.writeUtf8String(i),this.writer.write(n)}}export{Gu as $,cd as A,H as B,vu as C,ed as D,Cr as E,It as F,$s as G,Zu as H,hn as I,Mo as J,Ro as K,Eo as L,vr as M,jt as N,ji as O,he as P,es as Q,Kt as R,ie as S,Er as T,Ea as U,hu as V,hc as W,td as X,Ki as Y,Xu as Z,Gi as _,un as a,we as a$,Fu as a0,kr as a1,er as a2,vt as a3,Rr as a4,Wu as a5,id as a6,Dr as a7,Vs as a8,xi as a9,cc as aA,Vc as aB,Uc as aC,Bo as aD,Nc as aE,wa as aF,Bu as aG,zc as aH,fe as aI,rl as aJ,qs as aK,To as aL,Mr as aM,ee as aN,_t as aO,Q as aP,Us as aQ,zs as aR,Ps as aS,Ee as aT,$u as aU,Yu as aV,se as aW,Xe as aX,U as aY,Ae as aZ,pd as a_,Et as aa,Lt as ab,kt as ac,nd as ad,E as ae,xc as af,ce as ag,Ic as ah,Ni as ai,Tc as aj,Du as ak,Ds as al,fo as am,_c as an,Ju as ao,Is as ap,Eu as aq,Pc as ar,Nr as as,uc as at,aa as au,na as av,Tr as aw,lc as ax,rn as ay,sa as az,gu as b,ld as b$,_e as b0,Be as b1,Ji as b2,Es as b3,Ru as b4,v as b5,W as b6,$a as b7,Yl as b8,Mi as b9,Ri as bA,Uu as bB,qr as bC,te as bD,xd as bE,ru as bF,$e as bG,Ir as bH,qa as bI,_l as bJ,Rd as bK,Ot as bL,Ya as bM,ad as bN,sd as bO,Bd as bP,Vu as bQ,su as bR,ou as bS,ml as bT,_a as bU,nu as bV,au as bW,Ol as bX,va as bY,vl as bZ,Ha as b_,vs as ba,eu as bb,$ as bc,br as bd,$i as be,gd as bf,hd as bg,md as bh,Zl as bi,Oi as bj,Te as bk,_u as bl,vd as bm,_d as bn,Ou as bo,zu as bp,Ta as bq,Mu as br,qi as bs,Ye as bt,Nu as bu,$o as bv,ft as bw,qu as bx,Cs as by,Hu as bz,ln as c,za as c0,Hr as c1,ne as c2,Re as c3,sr as c4,Lr as c5,Ma as c6,Ie as c7,Rl as c8,Va as c9,Fl as cA,Cl as cB,Pl as cC,Fd as cD,ud as cE,ja as cF,Wa as cG,Sd as cH,dn as cI,ys as cJ,ql as cK,dd as cL,Vl as cM,Td as cN,iu as cO,tu as cP,Pd as cQ,Id as cR,Nt as cS,Cd as cT,Ed as cU,fd as cV,Na as ca,La as cb,Oa as cc,Il as cd,Tl as ce,Bl as cf,Ml as cg,El as ch,ht as ci,Ua as cj,wd as ck,bd as cl,yd as cm,Ad as cn,kd as co,xl as cp,yl as cq,Ba as cr,ke as cs,an as ct,od as cu,As as cv,_i as cw,si as cx,rt as cy,Dl as cz,_r as d,Dd as e,ju as f,b as g,q as h,ye as i,Qu as j,Se as k,Gc as l,Lu as m,$c as n,Yc as o,Ms as p,Cu as q,z as r,ve as s,ge as t,_s as u,rd as v,Ku as w,ae as x,ia as y,Z as z};
278
+ */var lt;(function(r){r[r.Unsynchronisation=128]="Unsynchronisation",r[r.ExtendedHeader=64]="ExtendedHeader",r[r.ExperimentalIndicator=32]="ExperimentalIndicator",r[r.Footer=16]="Footer"})(lt||(lt={}));var Y;(function(r){r[r.ISO_8859_1=0]="ISO_8859_1",r[r.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",r[r.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",r[r.UTF_8=3]="UTF_8"})(Y||(Y={}));const fr=128,be=10,Pt=["Blues","Classic rock","Country","Dance","Disco","Funk","Grunge","Hip-hop","Jazz","Metal","New age","Oldies","Other","Pop","Rhythm and blues","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death metal","Pranks","Soundtrack","Euro-techno","Ambient","Trip-hop","Vocal","Jazz & funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound clip","Gospel","Noise","Alternative rock","Bass","Soul","Punk","Space","Meditative","Instrumental pop","Instrumental rock","Ethnic","Gothic","Darkwave","Techno-industrial","Electronic","Pop-folk","Eurodance","Dream","Southern rock","Comedy","Cult","Gangsta","Top 40","Christian rap","Pop/funk","Jungle music","Native US","Cabaret","New wave","Psychedelic","Rave","Showtunes","Trailer","Lo-fi","Tribal","Acid punk","Acid jazz","Polka","Retro","Musical","Rock 'n' roll","Hard rock","Folk","Folk rock","National folk","Swing","Fast fusion","Bebop","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic rock","Progressive rock","Psychedelic rock","Symphonic rock","Slow rock","Big band","Chorus","Easy listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber music","Sonata","Symphony","Booty bass","Primus","Porn groove","Satire","Slow jam","Club","Tango","Samba","Folklore","Ballad","Power ballad","Rhythmic Soul","Freestyle","Duet","Punk rock","Drum solo","A cappella","Euro-house","Dance hall","Goa music","Drum & bass","Club-house","Hardcore techno","Terror","Indie","Britpop","Negerpunk","Polsk punk","Beat","Christian gangsta rap","Heavy metal","Black metal","Crossover","Contemporary Christian","Christian rock","Merengue","Salsa","Thrash metal","Anime","Jpop","Synthpop","Christmas","Art rock","Baroque","Bhangra","Big beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math rock","New romantic","Nu-breakz","Post-punk","Post-rock","Psytrance","Shoegaze","Space rock","Trop rock","World music","Neoclassical","Audiobook","Audio theatre","Neue Deutsche Welle","Podcast","Indie rock","G-Funk","Dubstep","Garage rock","Psybient"],Pu=(r,e)=>{const t=r.filePos;e.raw??={},e.raw.TAG??=z(r,fr-3),r.filePos=t;const i=pt(r,30);i&&(e.title??=i);const n=pt(r,30);n&&(e.artist??=n);const a=pt(r,30);a&&(e.album??=a);const s=pt(r,4),o=Number.parseInt(s,10);Number.isInteger(o)&&o>0&&(e.date??=new Date(String(o)));const c=z(r,30);let l;if(c[28]===0&&c[29]!==0){const u=c[29];u>0&&(e.trackNumber??=u),r.skip(-30),l=pt(r,28),r.skip(2)}else r.skip(-30),l=pt(r,30);l&&(e.comment??=l);const d=O(r);d<Pt.length&&(e.genre??=Pt[d])},pt=(r,e)=>{const t=z(r,e),i=gt(t.indexOf(0),t.length),n=t.subarray(0,i);let a="";for(let s=0;s<n.length;s++)a+=String.fromCharCode(n[s]);return a.trimEnd()},We=r=>{const e=r.filePos,t=K(r,3),i=O(r),n=O(r),a=O(r),s=R(r);if(t!=="ID3"||i===255||n===255||(s&2155905152)!==0)return r.filePos=e,null;let o=yi(s);return a&lt.Footer&&(o+=be),{majorVersion:i,revision:n,flags:a,size:o}},Wr=(r,e,t)=>{if(![2,3,4].includes(e.majorVersion)){U._warn(`Unsupported ID3v2 major version: ${e.majorVersion}`);return}const i=e.flags&lt.Footer?e.size-be:e.size,n=z(r,i),a=new Iu(e,n);if(e.flags&lt.Unsynchronisation&&e.majorVersion===3&&a.ununsynchronizeAll(),e.flags&lt.ExtendedHeader){const s=a.readU32();e.majorVersion===3?a.pos+=s:a.pos+=s-4}for(;a.pos<=a.bytes.length-a.frameHeaderSize();){const s=a.readId3V2Frame();if(!s)break;const o=a.pos,c=a.pos+s.size;let l=!1,d=!1,u=!1;if(e.majorVersion===3?(l=!!(s.flags&64),d=!!(s.flags&128)):e.majorVersion===4&&(l=!!(s.flags&4),d=!!(s.flags&8),u=!!(s.flags&2)||!!(e.flags&lt.Unsynchronisation)),l){U._warn(`Skipping encrypted ID3v2 frame ${s.id}`),a.pos=c;continue}if(d){U._warn(`Skipping compressed ID3v2 frame ${s.id}`),a.pos=c;continue}if(u&&a.ununsynchronizeRegion(a.pos,c),t.raw??={},s.id==="TXXX"){const f=t.raw.TXXX??={},m=a.readId3V2TextEncoding(),p=a.readId3V2Text(m,c),h=a.readId3V2Text(m,c);f[p]??=h}else s.id[0]==="T"?t.raw[s.id]??=a.readId3V2EncodingAndText(c):t.raw[s.id]??=a.readBytes(s.size);switch(a.pos=o,s.id){case"TIT2":case"TT2":t.title??=a.readId3V2EncodingAndText(c);break;case"TIT3":case"TT3":t.description??=a.readId3V2EncodingAndText(c);break;case"TPE1":case"TP1":t.artist??=a.readId3V2EncodingAndText(c);break;case"TALB":case"TAL":t.album??=a.readId3V2EncodingAndText(c);break;case"TPE2":case"TP2":t.albumArtist??=a.readId3V2EncodingAndText(c);break;case"TRCK":case"TRK":{const m=a.readId3V2EncodingAndText(c).split("/"),p=Number.parseInt(m[0],10),h=m[1]&&Number.parseInt(m[1],10);Number.isInteger(p)&&p>0&&(t.trackNumber??=p),h&&Number.isInteger(h)&&h>0&&(t.tracksTotal??=h)}break;case"TPOS":case"TPA":{const m=a.readId3V2EncodingAndText(c).split("/"),p=Number.parseInt(m[0],10),h=m[1]&&Number.parseInt(m[1],10);Number.isInteger(p)&&p>0&&(t.discNumber??=p),h&&Number.isInteger(h)&&h>0&&(t.discsTotal??=h)}break;case"TCON":case"TCO":{const f=a.readId3V2EncodingAndText(c);let m=/^\((\d+)\)/.exec(f);if(m){const p=Number.parseInt(m[1]);if(Pt[p]!==void 0){t.genre??=Pt[p];break}}if(m=/^\d+$/.exec(f),m){const p=Number.parseInt(m[0]);if(Pt[p]!==void 0){t.genre??=Pt[p];break}}t.genre??=f}break;case"TDRC":case"TDAT":{const f=a.readId3V2EncodingAndText(c),m=new Date(f);Number.isNaN(m.getTime())||(t.date??=m)}break;case"TYER":case"TYE":{const f=a.readId3V2EncodingAndText(c),m=Number.parseInt(f,10);Number.isInteger(m)&&(t.date??=new Date(String(m)))}break;case"USLT":case"ULT":{const f=a.readU8();a.pos+=3,a.readId3V2Text(f,c),t.lyrics??=a.readId3V2Text(f,c)}break;case"COMM":case"COM":{const f=a.readU8();a.pos+=3,a.readId3V2Text(f,c),t.comment??=a.readId3V2Text(f,c)}break;case"APIC":case"PIC":{const f=a.readId3V2TextEncoding();let m;if(e.majorVersion===2){const k=a.readAscii(3);m=k==="PNG"?"image/png":k==="JPG"?"image/jpeg":"image/*"}else m=a.readId3V2Text(f,c);const p=a.readU8(),h=a.readId3V2Text(f,c).trimEnd(),g=c-a.pos;if(g>=0){const k=a.readBytes(g);t.images||(t.images=[]),t.images.push({data:k,mimeType:m,kind:p===3?"coverFront":p===4?"coverBack":"unknown",description:h})}}break;default:a.pos+=s.size;break}a.pos=c}};class Iu{constructor(e,t){this.header=e,this.bytes=t,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}frameHeaderSize(){return this.header.majorVersion===2?6:10}ununsynchronizeAll(){const e=[];for(let t=0;t<this.bytes.length;t++){const i=this.bytes[t];e.push(i),i===255&&t!==this.bytes.length-1&&this.bytes[t]===0&&t++}this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}ununsynchronizeRegion(e,t){const i=[];for(let s=e;s<t;s++){const o=this.bytes[s];i.push(o),o===255&&s!==t-1&&this.bytes[s+1]===0&&s++}const n=this.bytes.subarray(0,e),a=this.bytes.subarray(t);this.bytes=new Uint8Array(n.length+i.length+a.length),this.bytes.set(n,0),this.bytes.set(i,n.length),this.bytes.set(a,n.length+i.length),this.view=new DataView(this.bytes.buffer)}readBytes(e){const t=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,t}readU8(){const e=this.view.getUint8(this.pos);return this.pos+=1,e}readU16(){const e=this.view.getUint16(this.pos,!1);return this.pos+=2,e}readU24(){const e=this.view.getUint16(this.pos,!1),t=this.view.getUint8(this.pos+2);return this.pos+=3,e*256+t}readU32(){const e=this.view.getUint32(this.pos,!1);return this.pos+=4,e}readAscii(e){let t="";for(let i=0;i<e;i++)t+=String.fromCharCode(this.view.getUint8(this.pos+i));return this.pos+=e,t}readId3V2Frame(){if(this.header.majorVersion===2){const e=this.readAscii(3);if(e==="\0\0\0")return null;const t=this.readU24();return{id:e,size:t,flags:0}}else{const e=this.readAscii(4);if(e==="\0\0\0\0")return null;const t=this.readU32();let i=this.header.majorVersion===4?yi(t):t;const n=this.readU16(),a=this.pos,s=o=>{const c=this.pos+o;if(c>this.bytes.length)return!1;if(c<=this.bytes.length-this.frameHeaderSize()){this.pos+=o;const l=this.readAscii(4);if(l!=="\0\0\0\0"&&!/[0-9A-Z]{4}/.test(l))return!1}return!0};if(!s(i)){const o=this.header.majorVersion===4?t:yi(t);s(o)&&(i=o)}return this.pos=a,{id:e,size:i,flags:n}}}readId3V2TextEncoding(){const e=this.readU8();if(e>3)throw new Error(`Unsupported text encoding: ${e}`);return e}readId3V2Text(e,t){const i=this.pos,n=this.readBytes(t-this.pos);switch(e){case Y.ISO_8859_1:{let a="";for(let s=0;s<n.length;s++){const o=n[s];if(o===0){this.pos=i+s+1;break}a+=String.fromCharCode(o)}return a}case Y.UTF_16_WITH_BOM:if(n[0]===255&&n[1]===254){const a=new TextDecoder("utf-16le"),s=gt(n.findIndex((o,c)=>o===0&&n[c+1]===0&&c%2===0),n.length);return this.pos=i+Math.min(s+2,n.length),a.decode(n.subarray(2,s))}else if(n[0]===254&&n[1]===255){const a=new TextDecoder("utf-16be"),s=gt(n.findIndex((o,c)=>o===0&&n[c+1]===0&&c%2===0),n.length);return this.pos=i+Math.min(s+2,n.length),a.decode(n.subarray(2,s))}else{const a=gt(n.findIndex(s=>s===0),n.length);return this.pos=i+Math.min(a+1,n.length),le.decode(n.subarray(0,a))}case Y.UTF_16_BE_NO_BOM:{const a=new TextDecoder("utf-16be"),s=gt(n.findIndex((o,c)=>o===0&&n[c+1]===0&&c%2===0),n.length);return this.pos=i+Math.min(s+2,n.length),a.decode(n.subarray(0,s))}case Y.UTF_8:{const a=gt(n.findIndex(s=>s===0),n.length);return this.pos=i+Math.min(a+1,n.length),le.decode(n.subarray(0,a))}}}readId3V2EncodingAndText(e){if(this.pos>=e)return"";const t=this.readId3V2TextEncoding();return this.readId3V2Text(t,e)}}class Dd{constructor(e){this.helper=new Uint8Array(8),this.helperView=q(this.helper),this.writer=e}writeId3V2Tag(e){const t=this.writer.getPos();this.writeAscii("ID3"),this.writeU8(4),this.writeU8(0),this.writeU8(0),this.writeSynchsafeU32(0);const i=this.writer.getPos(),n=new Set;for(const{key:o,value:c}of _s(e))switch(o){case"title":this.writeId3V2TextFrame("TIT2",c),n.add("TIT2");break;case"description":this.writeId3V2TextFrame("TIT3",c),n.add("TIT3");break;case"artist":this.writeId3V2TextFrame("TPE1",c),n.add("TPE1");break;case"album":this.writeId3V2TextFrame("TALB",c),n.add("TALB");break;case"albumArtist":this.writeId3V2TextFrame("TPE2",c),n.add("TPE2");break;case"trackNumber":{const l=e.tracksTotal!==void 0?`${c}/${e.tracksTotal}`:c.toString();this.writeId3V2TextFrame("TRCK",l),n.add("TRCK")}break;case"discNumber":{const l=e.discsTotal!==void 0?`${c}/${e.discsTotal}`:c.toString();this.writeId3V2TextFrame("TPOS",l),n.add("TPOS")}break;case"genre":this.writeId3V2TextFrame("TCON",c),n.add("TCON");break;case"date":this.writeId3V2TextFrame("TDRC",c.toISOString().slice(0,10)),n.add("TDRC");break;case"lyrics":this.writeId3V2LyricsFrame(c),n.add("USLT");break;case"comment":this.writeId3V2CommentFrame(c),n.add("COMM");break;case"images":{const l={coverFront:3,coverBack:4,unknown:0};for(const d of c){const u=l[d.kind]??0,f=d.description??"";this.writeId3V2ApicFrame(d.mimeType,u,f,d.data)}}break;case"tracksTotal":case"discsTotal":break;case"raw":break;default:ve(o)}if(e.raw)for(const o in e.raw){const c=e.raw[o];if(c==null||o.length!==4||n.has(o))continue;let l;if(typeof c=="string")if(Xe(c)){l=new Uint8Array(c.length+2),l[0]=Y.ISO_8859_1;for(let u=0;u<c.length;u++)l[u+1]=c.charCodeAt(u)}else{const u=ye.encode(c);l=new Uint8Array(u.byteLength+2),l[0]=Y.UTF_8,l.set(u,1)}else if(c instanceof Uint8Array)l=c;else if(o==="TXXX"&&Fs(c)){for(const d in c){const u=c[d],f=Xe(d)&&Xe(u),m=f?null:ye.encode(d),p=f?null:ye.encode(u),h=f?d.length:m.byteLength,g=f?u.length:p.byteLength,k=1+h+1+g+1;this.writeAscii("TXXX"),this.writeSynchsafeU32(k),this.writeU16(0),this.writeU8(f?Y.ISO_8859_1:Y.UTF_8),f?(this.writeIsoString(d),this.writeIsoString(u)):(this.writer.write(m),this.writeU8(0),this.writer.write(p),this.writeU8(0))}continue}else continue;this.writeAscii(o),this.writeSynchsafeU32(l.byteLength),this.writeU16(0),this.writer.write(l)}const a=this.writer.getPos(),s=a-i;return this.writer.seek(t+6),this.writeSynchsafeU32(s),this.writer.seek(a),s+10}writeU8(e){this.helper[0]=e,this.writer.write(this.helper.subarray(0,1))}writeU16(e){this.helperView.setUint16(0,e,!1),this.writer.write(this.helper.subarray(0,2))}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeAscii(e){for(let t=0;t<e.length;t++)this.helper[t]=e.charCodeAt(t);this.writer.write(this.helper.subarray(0,e.length))}writeSynchsafeU32(e){this.writeU32(fc(e))}writeIsoString(e){const t=new Uint8Array(e.length+1);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);this.writer.write(t)}writeUtf8String(e){const t=ye.encode(e);this.writer.write(t),this.writeU8(0)}writeId3V2TextFrame(e,t){const i=Xe(t),a=1+(i?t.length:ye.encode(t).byteLength)+1;this.writeAscii(e),this.writeSynchsafeU32(a),this.writeU16(0),this.writeU8(i?Y.ISO_8859_1:Y.UTF_8),i?this.writeIsoString(t):this.writeUtf8String(t)}writeId3V2LyricsFrame(e){const t=Xe(e),i="",n=4+i.length+1+e.length+1;this.writeAscii("USLT"),this.writeSynchsafeU32(n),this.writeU16(0),this.writeU8(t?Y.ISO_8859_1:Y.UTF_8),this.writeAscii("und"),t?(this.writeIsoString(i),this.writeIsoString(e)):(this.writeUtf8String(i),this.writeUtf8String(e))}writeId3V2CommentFrame(e){const t=Xe(e),i=t?e.length:ye.encode(e).byteLength,n="",a=4+n.length+1+i+1;this.writeAscii("COMM"),this.writeSynchsafeU32(a),this.writeU16(0),this.writeU8(t?Y.ISO_8859_1:Y.UTF_8),this.writeU8(117),this.writeU8(110),this.writeU8(100),t?(this.writeIsoString(n),this.writeIsoString(e)):(this.writeUtf8String(n),this.writeUtf8String(e))}writeId3V2ApicFrame(e,t,i,n){const a=Xe(e)&&Xe(i),s=a?i.length:ye.encode(i).byteLength,o=1+e.length+1+1+s+1+n.byteLength;this.writeAscii("APIC"),this.writeSynchsafeU32(o),this.writeU16(0),this.writeU8(a?Y.ISO_8859_1:Y.UTF_8),a?this.writeIsoString(e):this.writeUtf8String(e),this.writeU8(t),a?this.writeIsoString(i):this.writeUtf8String(i),this.writer.write(n)}}export{Xu as $,cd as A,ad as B,Z as C,vu as D,ed as E,It as F,Cr as G,$s as H,hn as I,Zu as J,Mo as K,Ro as L,vr as M,Eo as N,jt as O,he as P,wd as Q,Kt as R,ji as S,Er as T,Ea as U,hu as V,es as W,ie as X,hc as Y,td as Z,Ki as _,un as a,Ae as a$,Gi as a0,Gu as a1,Fu as a2,kr as a3,er as a4,vt as a5,Rr as a6,Wu as a7,id as a8,Dr as a9,rn as aA,sa as aB,cc as aC,Vc as aD,Uc as aE,Bo as aF,Nc as aG,wa as aH,Bu as aI,zc as aJ,fe as aK,rl as aL,qs as aM,To as aN,Mr as aO,ee as aP,_t as aQ,Q as aR,Us as aS,zs as aT,Ps as aU,Ee as aV,$u as aW,Yu as aX,se as aY,Xe as aZ,U as a_,Vs as aa,xi as ab,Et as ac,Lt as ad,kt as ae,nd as af,E as ag,xc as ah,ce as ai,Ic as aj,Ni as ak,Tc as al,Du as am,Ds as an,fo as ao,_c as ap,Ju as aq,Is as ar,Eu as as,Pc as at,Nr as au,uc as av,aa as aw,na as ax,Tr as ay,lc as az,gu as b,Ha as b$,pd as b0,we as b1,_e as b2,Be as b3,Ji as b4,Es as b5,Ru as b6,v as b7,W as b8,$a as b9,Cs as bA,Hu as bB,Ri as bC,Uu as bD,qr as bE,te as bF,xd as bG,ru as bH,$e as bI,Ir as bJ,qa as bK,_l as bL,Rd as bM,Ot as bN,Ya as bO,sd as bP,Bd as bQ,Vu as bR,su as bS,ou as bT,ml as bU,_a as bV,nu as bW,au as bX,Ol as bY,va as bZ,vl as b_,Yl as ba,Mi as bb,vs as bc,eu as bd,$ as be,br as bf,$i as bg,gd as bh,hd as bi,md as bj,Zl as bk,Oi as bl,Te as bm,_u as bn,vd as bo,_d as bp,Ou as bq,zu as br,Ta as bs,Mu as bt,qi as bu,Ye as bv,Nu as bw,$o as bx,ft as by,qu as bz,ln as c,ld as c0,za as c1,Hr as c2,ne as c3,Re as c4,sr as c5,Lr as c6,Ma as c7,Ie as c8,Rl as c9,Fl as cA,Cl as cB,Pl as cC,Fd as cD,ud as cE,ja as cF,Wa as cG,Sd as cH,dn as cI,ys as cJ,ql as cK,dd as cL,Vl as cM,Td as cN,iu as cO,tu as cP,Pd as cQ,Id as cR,Nt as cS,Cd as cT,Ed as cU,fd as cV,Va as ca,Na as cb,La as cc,Oa as cd,Il as ce,Tl as cf,Bl as cg,Ml as ch,El as ci,ht as cj,Ua as ck,bd as cl,yd as cm,Ad as cn,kd as co,xl as cp,yl as cq,Ba as cr,ke as cs,an as ct,od as cu,As as cv,_i as cw,si as cx,rt as cy,Dl as cz,_r as d,Dd as e,ju as f,b as g,H as h,q as i,ye as j,Qu as k,Se as l,Lu as m,Gc as n,$c as o,Ms as p,Yc as q,z as r,Cu as s,ge as t,ve as u,rd as v,Ku as w,_s as x,ae as y,ia as z};