clipoox-render 0.4.6 → 0.4.7

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 (108) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +999 -848
  3. package/web/assets/{FxEmbed-ROS6C_HI.js → FxEmbed-B-D-tbgP.js} +1 -1
  4. package/web/assets/{MotionEmbed-E2hCysi-.js → MotionEmbed-eB-zRpv9.js} +1 -1
  5. package/web/assets/{PluginStore-CwUSpwPp.js → PluginStore-D6UvvVXA.js} +1 -1
  6. package/web/assets/{ShotComposer-DLxWpdYH.js → ShotComposer-CoxtWL6A.js} +5 -5
  7. package/web/assets/{TemplateEmbed-qG1AXdtf.js → TemplateEmbed-DZNaQAJ-.js} +1 -1
  8. package/web/assets/{TimelinePlugins-CB1b6-Cb.js → TimelinePlugins-zhB9Uqav.js} +3 -3
  9. package/web/assets/{TimelineShotFx-CyHTgJHj.js → TimelineShotFx-muTN__gf.js} +2 -2
  10. package/web/assets/{TransitionEmbed-Dym9P7--.js → TransitionEmbed-r_B0toRr.js} +1 -1
  11. package/web/assets/{Whiteboard-BdGjJZXW.js → Whiteboard-f6owS-ne.js} +1 -1
  12. package/web/assets/{aerial-yLD_gDzw.js → aerial-DIj143Yz.js} +2 -2
  13. package/web/assets/{agentTools-B7g6tXTR.js → agentTools-CoNs1wCQ.js} +2 -2
  14. package/web/assets/{aiInbetween-6eKDYbYS.js → aiInbetween-ZFNHEXdI.js} +2 -2
  15. package/web/assets/{analyzerRun-Cr-_79RH.js → analyzerRun-BswbLsRF.js} +1 -1
  16. package/web/assets/{analyzerSandbox-N92T6amg.js → analyzerSandbox-C2rd6s8U.js} +1 -1
  17. package/web/assets/{api-Dnl2uaKO.js → api-DJC95K48.js} +3 -3
  18. package/web/assets/auraTrack-C9diszRB.js +1 -0
  19. package/web/assets/{breakthrough-DSiuVwEX.js → breakthrough-DiHiElqL.js} +2 -2
  20. package/web/assets/{cameraPresets-Cfn7qhXK.js → cameraPresets-DfKERP1j.js} +1 -1
  21. package/web/assets/{cameraTracker-DHdF8Zqx.js → cameraTracker-DFjnZ7tw.js} +1 -1
  22. package/web/assets/{captionLayout-cckQ7p-t.js → captionLayout-CAuhUiW9.js} +1 -1
  23. package/web/assets/{clientExport-pkLbOmEF.js → clientExport-DyqpYM6h.js} +1 -1
  24. package/web/assets/{clientJobs-CcsLDqFM.js → clientJobs-BqkjV5Ld.js} +2 -2
  25. package/web/assets/{depthEstimate-Cav4MmQ1.js → depthEstimate-HrGq0Ffx.js} +1 -1
  26. package/web/assets/{directorTools-DMsatulF.js → directorTools-CLn4xt6m.js} +1 -1
  27. package/web/assets/{distortFrames-D_v-aSVO.js → distortFrames-D-DK2HlN.js} +2 -2
  28. package/web/assets/{distortGL-vhnBRB59.js → distortGL-waTJhiOf.js} +1 -1
  29. package/web/assets/{domino-DBrinEUu.js → domino-BDKBYrNQ.js} +1 -1
  30. package/web/assets/{editTools-BNnAvCw-.js → editTools-BqKU-ucA.js} +1 -1
  31. package/web/assets/{engine-Co-ivzlQ.js → engine-B2YPWQZ2.js} +1 -1
  32. package/web/assets/{exportGlb-D3PrWUvi.js → exportGlb-Cm07JQXt.js} +1 -1
  33. package/web/assets/{faceTracker-ClR-lS6Y.js → faceTracker-DsmLlUZ1.js} +1 -1
  34. package/web/assets/{fightDirector-BlpVAURl.js → fightDirector-BIVLGhAP.js} +1 -1
  35. package/web/assets/{fightDrama-BK0QidpM.js → fightDrama-B_jDQ-cW.js} +2 -2
  36. package/web/assets/{focusTool-sVOb2GGS.js → focusTool-mWs2Eikj.js} +1 -1
  37. package/web/assets/{frameSink-CSRqCnwI.js → frameSink-DWkHUnvV.js} +3 -3
  38. package/web/assets/{glTransitionSources.generated-q0H-ZbnZ.js → glTransitionSources.generated-BJuEUz3E.js} +1 -1
  39. package/web/assets/{gpuCompose-B5bgbHdQ.js → gpuCompose-Fi0sIUI9.js} +1 -1
  40. package/web/assets/{gpuExport-oA2mUsdm.js → gpuExport-Dlf6YjLs.js} +3 -3
  41. package/web/assets/{handMatte-Dj2taFoC.js → handMatte-CvFkZKTL.js} +1 -1
  42. package/web/assets/{handTracker-c6_rvuwA.js → handTracker-CF1hqh09.js} +2 -2
  43. package/web/assets/{index-Ds_8isyf.js → index-EegUntr6.js} +1 -1
  44. package/web/assets/{layer-worker-ClVZG6ZW.js → layer-worker-Drj-NLVj.js} +3 -3
  45. package/web/assets/library-BhH-xsMR.js +1 -0
  46. package/web/assets/{lottieLayer-Cv8ub9f6.js → lottieLayer-Dp_vGTy8.js} +1 -1
  47. package/web/assets/{main-CwrkBJ63.js → main-DAk1Tv1E.js} +52 -52
  48. package/web/assets/{mapBake-DtQboFIX.js → mapBake-CEmw-e9Y.js} +1 -1
  49. package/web/assets/{maskTrack-D4QZfMWc.js → maskTrack-CADMBJDf.js} +1 -1
  50. package/web/assets/{matteFixRun-CytaeRzS.js → matteFixRun-BHD3Qnta.js} +1 -1
  51. package/web/assets/{objectLocate-XuAcemlO.js → objectLocate-DWsEG8eK.js} +1 -1
  52. package/web/assets/{objectSegmenter-D66spD7o.js → objectSegmenter-oGv8YQbI.js} +1 -1
  53. package/web/assets/{objectTrack.worker-BZS6WZ6l.js → objectTrack.worker-B6RVfsq4.js} +570 -419
  54. package/web/assets/{pathTracer-DykgPkkh.js → pathTracer-DxqKEvC7.js} +2 -2
  55. package/web/assets/{pendingMatte-BWBIWajI.js → pendingMatte-Taa0BlLI.js} +2 -2
  56. package/web/assets/{personAi-EhBknW6X.js → personAi-BebqXrqD.js} +2 -2
  57. package/web/assets/{personHq-Ca351o06.js → personHq-Cyq9HWnW.js} +2 -2
  58. package/web/assets/{plateCamera-BcdXD1uI.js → plateCamera-D1A1iEpf.js} +1 -1
  59. package/web/assets/{plateCameraMatch-GPZl1fQQ.js → plateCameraMatch-1_DuZ0LV.js} +2 -2
  60. package/web/assets/{plateFollow-CJUilsNV.js → plateFollow-Ztxwpq5v.js} +2 -2
  61. package/web/assets/{plateMatte-CoEoVjxZ.js → plateMatte-CWT1ymGj.js} +2 -2
  62. package/web/assets/{pluginAutomation-DAPHWZPN.js → pluginAutomation-D73Az7HS.js} +1 -1
  63. package/web/assets/{poseTracker-CzEKvJph.js → poseTracker-b1h08oRY.js} +1 -1
  64. package/web/assets/{productTools-ce-zyZO0.js → productTools-CoJ_Fnfc.js} +2 -2
  65. package/web/assets/remote-kxNNhmis.js +974 -0
  66. package/web/assets/{rigTrack-DMyqb0pb.js → rigTrack-B9r9wrdV.js} +1 -1
  67. package/web/assets/{rotoMaskStore-pE1AIt3I.js → rotoMaskStore-RmW40Pcn.js} +1 -1
  68. package/web/assets/{rotoMatte-7b7Ow64f.js → rotoMatte-DisQplSv.js} +1 -1
  69. package/web/assets/{rotoscope-BUqNTKLd.js → rotoscope-Z8bn-jRs.js} +1 -1
  70. package/web/assets/{sceneTrack-CA21MCOP.js → sceneTrack-BKknn180.js} +1 -1
  71. package/web/assets/{sceneTrack-DlAH5s74.js → sceneTrack-DyVxpl7i.js} +1 -1
  72. package/web/assets/{sceneTrack.worker-COlhlHRe.js → sceneTrack.worker-DKVLLgf9.js} +570 -419
  73. package/web/assets/{shot-worker-DL1ZoIym.js → shot-worker-DM5PUQ6g.js} +1 -1
  74. package/web/assets/{shotFxAgent-DqngnGFb.js → shotFxAgent-CsW0MAiG.js} +1 -1
  75. package/web/assets/{skin-xFScwS3T.js → skin-CXvqtCZI.js} +1 -1
  76. package/web/assets/{spark.module-DjaIF6J1.js → spark.module-B341moK0.js} +1 -1
  77. package/web/assets/{spellDuel-BYNtnE8f.js → spellDuel-KCMEFHLA.js} +2 -2
  78. package/web/assets/{store-CpqHUcA2.js → store-xR02oY0m.js} +1 -1
  79. package/web/assets/{surfaceLight-C7YI9SV8.js → surfaceLight-DBfJxggM.js} +1 -1
  80. package/web/assets/{surfacePin-CzpUj1Cw.js → surfacePin-i-X1Dz68.js} +2 -2
  81. package/web/assets/{textAnimators-B9vO_hbP.js → textAnimators-CeMuG34D.js} +1 -1
  82. package/web/assets/{thumb-BTFsBS1u.js → thumb-DzNl15MN.js} +1 -1
  83. package/web/assets/{timeline3d-DrFaMPPB.js → timeline3d-D0Ws4lcp.js} +2 -2
  84. package/web/assets/{timeline3dExport-Uo0S0CR0.js → timeline3dExport-BO--SpAn.js} +1 -1
  85. package/web/assets/{timelineComp-i-zdaoB2.js → timelineComp-D8PHGHgQ.js} +1 -1
  86. package/web/assets/{timelineOps-DSSaDsU2.js → timelineOps-CEGk2t4h.js} +20 -20
  87. package/web/assets/{timelineProps-0v-s69pw.js → timelineProps-Cm_Irino.js} +1 -1
  88. package/web/assets/{timelineText-DurRhyuh.js → timelineText-DjPW2-dd.js} +1 -1
  89. package/web/assets/{titleArt-CnC0A7x7.js → titleArt-BSu80bfN.js} +3 -3
  90. package/web/assets/{titleFrameBudget-DsM0V482.js → titleFrameBudget-BW-N1-cw.js} +718 -567
  91. package/web/assets/{titleFrames-C8kvflgT.js → titleFrames-BHFaInux.js} +1 -1
  92. package/web/assets/{tool-D1FpErrX.js → tool-Bboi3NDg.js} +1 -1
  93. package/web/assets/{tools-DIvrRu-5.js → tools-kgYkohv8.js} +1 -1
  94. package/web/assets/{toonTools-D9MNdRty.js → toonTools-Bxz_HSqT.js} +2 -2
  95. package/web/assets/{trackAnchor-XvUuvkWP.js → trackAnchor-DK9cEMCf.js} +1 -1
  96. package/web/assets/{userFonts-Djka6RJX.js → userFonts-DSkZHfmh.js} +1 -1
  97. package/web/assets/{vfxAlpha-B-JzzRI1.js → vfxAlpha-B0rNpKZN.js} +1 -1
  98. package/web/assets/vfxBackground-CBTDl1xA.js +2 -0
  99. package/web/assets/{videoExport-NN-QijHd.js → videoExport-Cu0vw-dL.js} +1 -1
  100. package/web/assets/{views-RQBs4zva.js → views-CmulxRJP.js} +1 -1
  101. package/web/assets/{weaponDuel-DKAEYJjO.js → weaponDuel-DuuMMfzY.js} +1 -1
  102. package/web/assets/{windowFrames-DhhJLIs-.js → windowFrames-BP2oDn-n.js} +1 -1
  103. package/web/layer-worker.html +3 -3
  104. package/web/shot-worker.html +22 -22
  105. package/web/assets/auraTrack-C8eAEIWQ.js +0 -1
  106. package/web/assets/library-BK0QVG4O.js +0 -1
  107. package/web/assets/remote-8XzEAnAJ.js +0 -974
  108. package/web/assets/vfxBackground-b053ziDK.js +0 -2
@@ -1,4 +1,4 @@
1
- import{G as de,hi as St,eU as jt,eV as At,n5 as pe,c_ as dt,aB as Ot,n6 as Dt,bt as Kt,by as qt,n7 as ge,cB as Ut,cz as Gt,cQ as Xt,fm as It,n8 as ye,n9 as bt,eX as Me,fb as xe,gG as we,fd as be,gI as ke,lu as Te,dW as Ae,dY as ve,fa as Pe,gH as Yt,bw as Se,na as Jt,dZ as Oe,l7 as Ie}from"./titleFrameBudget-DsM0V482.js";import{h as ae,A as Ee,j as Et,t as Ne}from"./textAnimators-B9vO_hbP.js";import{N as Fe,O as re,V as Re,p as ze,C as Ce,W as $e,F as Le,t as _e}from"./sceneTrack-DlAH5s74.js";const Nt="vfx-speed-bolt",et=Object.freeze({chunks:15,perChunk:75,fps:30,length:[.1,1.5],width:[.3,3],jag:[0,1.5]}),je=/^#[0-9a-fA-F]{6}$/,it=t=>Math.round(t*1e4)/1e4,Ft=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,Qt=t=>Math.round(Math.max(0,Math.min(1,t))*1295).toString(36).padStart(2,"0");function Ve(t){if(t.length<2)return{n:0,fps:et.fps,t0:0};const e=t[0][0],n=t.at(-1)[0]-e,a=et.chunks*et.perChunk,r=Math.min(et.fps,Math.max(1,Math.floor((a-1)/Math.max(.001,n)))),o=Math.min(a,Math.floor(n*r+1e-6)+1),i=c=>{let h=1;for(;h<t.length-1&&t[h][0]<c;)h++;const u=t[h-1],d=t[h],f=Math.max(0,Math.min(1,(c-u[0])/(d[0]-u[0]||1)));return[u[1]+(d[1]-u[1])*f,u[2]+(d[2]-u[2])*f]};let l="";for(let c=0;c<o;c++){const[h,u]=i(e+c/r);l+=Qt(h)+Qt(u)}const s={n:o,fps:r,t0:it(e)};for(let c=0;c*et.perChunk*4<l.length;c++)s["p"+c]=l.slice(c*et.perChunk*4,(c+1)*et.perChunk*4);return s}function Tn({id:t,at:e,duration:n,color:a,width:r,length:o,jag:i,source:l,point:s}){const c=de.find(w=>w.id===Nt),h=.03,u=s??[.5,.5],d={x:it(Math.max(0,Math.min(1-2*h,u[0]-h))),y:it(Math.max(0,Math.min(1-2*h,u[1]-h))),w:2*h,h:2*h},f={...c.params,color:je.test(a??"")?a:c.params.color,width:it(Ft(r,et.width,1)),length:it(Ft(o,et.length,.4)),jag:it(Ft(i,et.jag,.6))};return{id:t,nodeId:"",kind:"image",url:"",volume:0,start:it(e),duration:it(n),label:"Vệt sét",motionV:2,posX:0,posY:0,scale:1,opacity:0,motion:St({code:`@preset:${Nt}`,params:f,preset:Nt}),pendingPin:{source:l,at:it(e),region:d,mode:"bolt",...s?{}:{person:!0}}}}function An(t,e){if(e.length<2)return{pendingPin:void 0,opacity:0};const n=Object.fromEntries(Object.entries(t.motion.params).filter(([a])=>!/^p\d+$/.test(a)));return{pendingPin:void 0,opacity:1,motion:{...t.motion,params:{...n,...Ve(e)}}}}const Be=["classic","duotone-stack","outline-punch","accent-bar","neon-edge","echo-stack","tape-label","serif-year"],vn=[{id:"duotone-stack",name:"Tầng màu",sample:`ĐÁNH THỨC
1
+ import{G as de,hi as St,eU as jt,eV as At,n5 as pe,c_ as dt,aB as Ot,n6 as Dt,bt as Kt,by as qt,n7 as ge,cB as Ut,cz as Gt,cQ as Xt,fm as It,n8 as ye,n9 as bt,eX as Me,fb as xe,gG as we,fd as be,gI as ke,lu as Te,dW as Ae,dY as ve,fa as Pe,gH as Yt,bw as Se,na as Jt,dZ as Oe,l7 as Ie}from"./titleFrameBudget-BW-N1-cw.js";import{h as ae,A as Ee,j as Et,t as Ne}from"./textAnimators-CeMuG34D.js";import{N as Fe,O as re,V as Re,p as ze,C as Ce,W as $e,F as Le,t as _e}from"./sceneTrack-DyVxpl7i.js";const Nt="vfx-speed-bolt",et=Object.freeze({chunks:15,perChunk:75,fps:30,length:[.1,1.5],width:[.3,3],jag:[0,1.5]}),je=/^#[0-9a-fA-F]{6}$/,it=t=>Math.round(t*1e4)/1e4,Ft=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,Qt=t=>Math.round(Math.max(0,Math.min(1,t))*1295).toString(36).padStart(2,"0");function Ve(t){if(t.length<2)return{n:0,fps:et.fps,t0:0};const e=t[0][0],n=t.at(-1)[0]-e,a=et.chunks*et.perChunk,r=Math.min(et.fps,Math.max(1,Math.floor((a-1)/Math.max(.001,n)))),o=Math.min(a,Math.floor(n*r+1e-6)+1),i=c=>{let h=1;for(;h<t.length-1&&t[h][0]<c;)h++;const u=t[h-1],d=t[h],f=Math.max(0,Math.min(1,(c-u[0])/(d[0]-u[0]||1)));return[u[1]+(d[1]-u[1])*f,u[2]+(d[2]-u[2])*f]};let l="";for(let c=0;c<o;c++){const[h,u]=i(e+c/r);l+=Qt(h)+Qt(u)}const s={n:o,fps:r,t0:it(e)};for(let c=0;c*et.perChunk*4<l.length;c++)s["p"+c]=l.slice(c*et.perChunk*4,(c+1)*et.perChunk*4);return s}function Tn({id:t,at:e,duration:n,color:a,width:r,length:o,jag:i,source:l,point:s}){const c=de.find(w=>w.id===Nt),h=.03,u=s??[.5,.5],d={x:it(Math.max(0,Math.min(1-2*h,u[0]-h))),y:it(Math.max(0,Math.min(1-2*h,u[1]-h))),w:2*h,h:2*h},f={...c.params,color:je.test(a??"")?a:c.params.color,width:it(Ft(r,et.width,1)),length:it(Ft(o,et.length,.4)),jag:it(Ft(i,et.jag,.6))};return{id:t,nodeId:"",kind:"image",url:"",volume:0,start:it(e),duration:it(n),label:"Vệt sét",motionV:2,posX:0,posY:0,scale:1,opacity:0,motion:St({code:`@preset:${Nt}`,params:f,preset:Nt}),pendingPin:{source:l,at:it(e),region:d,mode:"bolt",...s?{}:{person:!0}}}}function An(t,e){if(e.length<2)return{pendingPin:void 0,opacity:0};const n=Object.fromEntries(Object.entries(t.motion.params).filter(([a])=>!/^p\d+$/.test(a)));return{pendingPin:void 0,opacity:1,motion:{...t.motion,params:{...n,...Ve(e)}}}}const Be=["classic","duotone-stack","outline-punch","accent-bar","neon-edge","echo-stack","tape-label","serif-year"],vn=[{id:"duotone-stack",name:"Tầng màu",sample:`ĐÁNH THỨC
2
2
  Ý TƯỞNG`,category:"Bold",fontFamily:"Anton",fontSize:78,color:"#f8f8f2",accentColor:"#32d8cd",placement:"center",preset:"rise-pop"},{id:"outline-punch",name:"Viền bật",sample:"BỨT PHÁ",category:"Bold",fontFamily:"Montserrat",fontSize:82,color:"#ffffff",accentColor:"#ffb938",placement:"center",preset:"punch-in"},{id:"accent-bar",name:"Dải nhấn",sample:`ĐIỀU MỚI
3
3
  BẮT ĐẦU`,category:"Social",fontFamily:"Be Vietnam Pro",fontSize:70,color:"#171b20",accentColor:"#dfff48",placement:"center",preset:"slide-left"},{id:"neon-edge",name:"Sắc điện",sample:"TỎA SÁNG",category:"Social",fontFamily:"Bungee",fontSize:66,color:"#f6fbff",accentColor:"#5de9ff",placement:"center",preset:"punch-in"},{id:"echo-stack",name:"Vang âm",sample:"TẠO KHÁC BIỆT",category:"Minimal",fontFamily:"Oswald",fontSize:82,color:"#ffffff",accentColor:"#9a73ff",placement:"center",preset:"rise-pop"},{id:"tape-label",name:"Nhãn băng keo",sample:"JAPAN, 1957",category:"Collage",fontFamily:"Oswald",fontSize:46,color:"#2a241c",accentColor:"#e6d9b8",placement:"top",preset:"slide-left"},{id:"serif-year",name:"Năm chữ có chân",sample:"1957",category:"Collage",fontFamily:"Playfair Display",fontSize:96,color:"#d62b25",accentColor:"#d62b25",placement:"top",preset:"pop-in"}],De={"word-pop":{in:[{unit:"word",stagger:.12,duration:.35,easing:"easeOutBack",from:{opacity:0,scale:.4}}]},"word-rise":{in:[{unit:"word",stagger:.1,duration:.4,easing:"easeOutCubic",from:{opacity:0,y:.6}}]},"line-slam":{in:[{unit:"line",stagger:.25,duration:.32,easing:"easeOutBack",from:{opacity:0,scale:2.2,blur:.2}}]},"type-on":{in:[{unit:"char",stagger:.04,duration:.05,easing:"linear",from:{opacity:0}}],out:"none"},"slide-in":{in:[{unit:"line",stagger:.15,duration:.45,easing:"easeOutQuart",from:{opacity:0,x:-1.5},mask:!0}]},"wipe-in":{in:[{unit:"line",stagger:.15,duration:.5,easing:"easeOutCubic",from:{wipeX:0}}]},"word-blur":{in:[{unit:"word",stagger:.09,duration:.2,easing:"easeOutCubic",from:{opacity:0,blur:.55}}]},"blur-rescale":{in:[{unit:"line",stagger:.08,duration:.24,easing:"easeOutExpo",from:{opacity:0,scale:1.6,blur:.45}}]},"flicker-on":{in:[{unit:"line",stagger:.06,duration:.4,easing:"linear",from:{flicker:1}}]},"slam-blur":{in:[{unit:"word",stagger:.08,duration:.26,easing:"easeOutExpo",from:{opacity:0,x:-2.2,scaleX:1.9,blur:.6,rotate:-6}}]},"slam-blur-right":{in:[{unit:"word",stagger:.08,duration:.26,easing:"easeOutExpo",from:{opacity:0,x:2.2,scaleX:1.9,blur:.6,rotate:6}}]},"glitch-scatter":{in:[{unit:"char",order:"random",stagger:.03,duration:.42,easing:"easeOutExpo",from:{opacity:0,scatter:2.6,rotate:-25,pixels:1,glitch:.8}}]},"pixel-burst":{in:[{unit:"word",stagger:.1,duration:.5,easing:"easeOutCubic",from:{opacity:.2,pixels:1,glitch:1,scaleX:1.25}}]},"glitch-in":{in:[{unit:"char",stagger:.025,duration:.24,easing:"easeOutCubic",from:{opacity:0,glitch:1,y:.25}}]},"mask-rise":{in:[{unit:"line",stagger:.08,duration:.36,easing:"easeOutCubic",mask:!0,from:{y:1.1}},{unit:"line",start:.1,duration:1.3,easing:"easeOutCubic",from:{brightness:.45}}]}},$t=Object.freeze(Object.fromEntries(Object.entries(De).map(([t,e])=>[t,Object.freeze(ae(e,`titleAnimations.${t}`))])));Object.freeze(Object.keys($t));const Zt=Object.freeze({weight:800,lineHeight:1.3,uppercase:!1,layers:[{type:"text",fill:"{color}",shadow:{color:"#000000",blur:.18,x:0,y:.03}}]}),mt=t=>Array.isArray(t)?t.map(mt):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([,e])=>e!==null).map(([e,n])=>[e,mt(n)])):t,Ke=t=>{if(t.length>2e4)throw Error("design: too long");try{return mt(JSON.parse(t))}catch{throw Error("design: invalid JSON")}},qe=["none","push-in","pull-out","pan-left","pan-right","slide-up","slide-left","pop-in","rise-pop","punch-in"];function Pn(t,e){if(!qe.includes(t)||!Number.isFinite(e)||e<1/30)throw Error("Invalid motion preset or duration");const n=(r,o=0,i=0,l=1)=>({time:r,x:o,y:i,zoom:l}),a=Math.min(.5,e/3);switch(t){case"none":return[];case"push-in":return[n(0),n(e,0,0,1.15)];case"pull-out":return[n(0,0,0,1.15),n(e)];case"pan-left":return[n(0,.07,0,1.2),n(e,-.07,0,1.2)];case"pan-right":return[n(0,-.07,0,1.2),n(e,.07,0,1.2)];case"slide-up":return[n(0,0,1),n(a),n(e)];case"slide-left":return[n(0,1),n(a),n(e)];case"pop-in":return[n(0,0,0,.25),n(a),n(e)];case"rise-pop":return[n(0,0,.22,.55),n(a*.7,0,-.025,1.08),n(a,0,0,1),n(e)];case"punch-in":return[n(0,0,0,.25),n(a*.7,0,0,1.13),n(a,0,0,1),n(e)]}}function Ue(t){if(typeof t.text!="string"||!t.text.trim()||t.text.length>200)throw Error("Text requires 1–200 characters");const e=t.fontSize??56,n=t.color??"#ffffff",a=t.placement??"lower";if(!Number.isFinite(e)||e<24||e>96||!/^#[0-9a-f]{6}$/i.test(n)||!["top","center","lower"].includes(a))throw Error("Invalid text style");const r=t.fontFamily??"Arial",o=t.align??"center";if(!Ee(r)||!["left","center","right"].includes(o))throw Error("Invalid font or alignment");const i=t.styleId??"classic",l=t.accentColor??"#32d8cd";if(!Be.includes(i)||!/^#[0-9a-f]{6}$/i.test(l))throw Error("Invalid text template style");const s={text:t.text,fontSize:e,color:n,placement:a,fontFamily:r,align:o,styleId:i,accentColor:l},c=typeof t.design=="string"?Ke(t.design):mt(t.design);if(typeof t.animation=="string"&&!Object.hasOwn($t,t.animation))throw Error(`Unknown title animation "${t.animation.slice(0,64)}"`);const h=mt(typeof t.animation=="string"?$t[t.animation]:t.animation);if(c!=null)s.design=Et(c),typeof t.templateId=="string"&&/^[a-z0-9][a-z0-9-]{1,63}$/.test(t.templateId)&&(s.templateId=t.templateId);else if(typeof t.templateId=="string"&&t.templateId)throw Error(`Unknown text template "${t.templateId.slice(0,64)}" (not published)`);h!=null&&(s.design||(s.design=Et(Zt)),s.animation=ae(h));const u=Ne(mt(t.animators));return u.length&&(s.design||(s.design=Et(Zt)),s.animators=u),s}const Ge={"muapi:seedance-2.5":{label:"Seedance 2.5",min:4,max:8},"muapi:wan-3.0-prime":{label:"Wan 3.0 Prime",min:2,max:8},"muapi:seedance-2.0":{label:"Seedance 2.0",min:4,max:8},"vertex:veo-omni":{label:"Gemini Omni 1.2",min:3,max:15},"muapi:seedance-2.5@480p":{label:"Seedance 2.5 · 480p",min:4,max:8,generator:"muapi:seedance-2.5",resolution:"480p"},"muapi:seedance-2.0-mini@480p":{label:"Seedance 2.0 Mini · 480p",min:4,max:8,generator:"muapi:seedance-2.0-mini",resolution:"480p"}},Sn=t=>{const e=Ge[t];return{generator:e?.generator||t,...e?.resolution?{resolution:e.resolution}:{}}},On=4,In={"openai:gpt-image-2.5-flare":{label:"GPT Image 2.5 Flare"},"openai:gpt-image-2.5-sunburst":{label:"GPT Image 2.5 Sunburst"},"openai:gpt-image-2.6-flare":{label:"GPT Image 2.6 Flare"},"openai:gpt-image-2.6-sunburst":{label:"GPT Image 2.6 Sunburst"}},En="openai:gpt-image-2.5-flare",Ht=Object.freeze(["lots","route","area","label","pin","photo","callout","overlay","icon"]),Lt=Object.freeze({glow:{vi:"Đường phát sáng",en:"Glowing line",color:"#3cf2d0",layers:[{w:18,blur:12,a:.5},{w:6},{w:2,c:"#ffffff",a:.85}]},dashed:{vi:"Nét đứt",en:"Dashed",color:"#ffffff",layers:[{w:12,blur:8,a:.35},{w:4,dash:[14,10]}]},"dashed-ring":{vi:"Vành đai (đỏ, gạch trắng)",en:"Ring road (red, white dashes)",color:"#ff2d3a",layers:[{w:24,blur:12,a:.55},{w:11},{w:3,c:"#ffffff",dash:[18,14]}]},"gradient-highway":{vi:"Cao tốc (cam → vàng)",en:"Expressway (orange → yellow)",color:"#ff7a1a",layers:[{w:26,blur:14,a:.6},{w:11},{w:5,c:"#ffd23a"},{w:1.6,c:"#fff7c2",a:.9}]},metro:{vi:"Metro (xanh ngọc)",en:"Metro line (cyan)",color:"#22e3ff",layers:[{w:18,blur:10,a:.5},{w:6},{w:1.8,c:"#ffffff",dash:[10,8],a:.9}]},link:{vi:"Đường liên kết (hồng, nét đứt)",en:"Link road (magenta, dashed)",color:"#ff2bd6",layers:[{w:16,blur:9,a:.5},{w:5},{w:2,c:"#ffffff",dash:[12,10],a:.95}]},thin:{vi:"Đường mảnh (trắng)",en:"Thin road (white)",color:"#ffffff",layers:[{w:7,blur:4,a:.3},{w:2.6}]},river:{vi:"Sông (xanh ngọc)",en:"River (teal)",color:"#1fd1c1",layers:[{w:28,blur:16,a:.45},{w:9,a:.9},{w:2.5,c:"#b9fff6",a:.6}]},trail:{vi:"Dải sáng nhiều làn (vàng)",en:"Light-trail lanes (gold)",color:"#ffdf1f",lanes:!0,layers:[{w:2.2},{w:2.2}]}}),Nn=Object.freeze(Object.keys(Lt)),Xe=Object.freeze(["rise","fade","wipe"]),Ye=/^#[0-9a-f]{6}$/i,R=(t,e,n)=>Math.max(e,Math.min(n,t)),_=t=>+t.toFixed(3),I=t=>+t.toFixed(4),Je=.2,ie=Ot["ease-in-out"],Vt=Ot["ease-out"],Qe=Ot["back-out"];function rt(t,e,n,a){if(!Array.isArray(t)||t.length<e||t.length>n)throw Error(`${a} needs ${e}–${n} points [u,v]`);return t.map(r=>{if(!Array.isArray(r)||r.length!==2||!r.every(o=>Number.isFinite(o)&&o>=-1&&o<=2))throw Error(`${a}: points are [u,v] (0..1 of the map picture)`);return[r[0],r[1]]})}const J=(t,e=60)=>typeof t=="string"?t.replace(/\s+/g," ").trim().slice(0,e):"",Ze=(t,e)=>typeof t=="string"&&Ye.test(t)?t.toLowerCase():e;function oe(t,e){const n=Math.min(1.5,2560/Math.max(t,e));return[Math.round(t*n),Math.round(e*n)]}function He(t,e){const[n,a]=oe(t,e),r=Math.min(n,a)/1e3,o=(n-1e3*r)/2,i=(a-1e3*r)/2;return{size:[n,a],pt:([l,s])=>[_((l*n/t-o)/r),_((s*a/e-i)/r)],len:l=>l*n/t/r}}function Wt(t,e=!1){if(t.length<3)return t;const n=t.length,a=s=>e?t[(s+n)%n]:t[R(s,0,n-1)],r=[],o=e?n:n-1,i=t.reduce((s,c,h)=>h?s+Math.hypot(c[0]-t[h-1][0],c[1]-t[h-1][1]):0,0),l=R(Math.round(i/10/o),2,Math.floor(240/o));for(let s=0;s<o;s++){const c=a(s-1),h=a(s),u=a(s+1),d=a(s+2);for(let f=0;f<l;f++){const w=f/l,g=w*w,T=g*w;r.push([0,1].map(O=>.5*(2*h[O]+(-c[O]+u[O])*w+(2*c[O]-5*h[O]+4*u[O]-d[O])*g+(-c[O]+3*h[O]-3*u[O]+d[O])*T)))}}return e||r.push(t[n-1]),r}const se=t=>t.reduce((e,n,a)=>a?e+Math.hypot(n[0]-t[a-1][0],n[1]-t[a-1][1]):0,0),wt=(t,e)=>{let n=Math.atan2(e,t)*180/Math.PI;return n>90&&(n-=180),n<=-90&&(n+=180),n};function We(t,e){const n=se(t);if(n<1)return{x:t[0][0],y:t[0][1],angle:0,nx:0,ny:-1};const a=[0];for(let u=1;u<t.length;u++)a.push(a[u-1]+Math.hypot(t[u][0]-t[u-1][0],t[u][1]-t[u-1][1]));const r=u=>{u=R(u,0,n);let d=1;for(;d<a.length-1&&a[d]<u;)d++;const f=(u-a[d-1])/(a[d]-a[d-1]||1);return[t[d-1][0]+(t[d][0]-t[d-1][0])*f,t[d-1][1]+(t[d][1]-t[d-1][1])*f]},o=Math.min(n/2,e*.55);let i=null;for(let u=0;u<=20;u++){const d=o+(n-2*o)*u/20,f=r(d-o),w=r(d+o),g=w[0]-f[0],T=w[1]-f[1],O=Math.hypot(g,T)||1;let B=0;for(let V=1;V<8;V++){const E=r(d-o+2*o*V/8);B=Math.max(B,Math.abs((E[0]-f[0])*T-(E[1]-f[1])*g)/O)}const U=B+Math.abs(d-n/2)/n*e*.15;(!i||U<i.score)&&(i={score:U,c:d,dx:g,dy:T})}const[l,s]=r(i.c),c=wt(i.dx,i.dy),h=c*Math.PI/180;return{x:l,y:s,angle:c,nx:Math.sin(h),ny:-Math.cos(h)}}function le(t,e=8){const n=se(t);if(n<1)return[{x:t[0][0],y:t[0][1],nx:0,ny:-1,s:0}];const a=[0];for(let l=1;l<t.length;l++)a.push(a[l-1]+Math.hypot(t[l][0]-t[l-1][0],t[l][1]-t[l-1][1]));const r=l=>{let s=1;for(;s<a.length-1&&a[s]<l;)s++;const c=(l-a[s-1])/(a[s]-a[s-1]||1);return[t[s-1][0]+(t[s][0]-t[s-1][0])*c,t[s-1][1]+(t[s][1]-t[s-1][1])*c]},o=R(Math.round(n/e),8,120),i=Array.from({length:o+1},(l,s)=>r(n*s/o));return i.map((l,s)=>{const c=i[Math.max(0,s-1)],h=i[Math.min(o,s+1)],u=h[0]-c[0],d=h[1]-c[1],f=Math.hypot(u,d)||1;return{x:l[0],y:l[1],nx:-d/f,ny:u/f,s:n*s/o}})}function ce(t,e){const n=t.map(i=>i.y),a=Math.min(...n),r=Math.max(...n)-a,o=Number.isFinite(e)?R(e,.1,1):r>24?.3:1;return t.map(i=>r>1e-6?I(o+(1-o)*(i.y-a)/r):1)}function tn(t,{lanes:e=9,width:n=70,taper:a}={}){const r=le(t),o=ce(r,a),i=R(Math.round(e),2,11),l=o.map(s=>n/2*s);return{lanes:Array.from({length:i},(s,c)=>{const h=c/(i-1)*2-1;return r.map((u,d)=>[u.x+u.nx*h*l[d],u.y+u.ny*h*l[d]])}),half:l,S:r,k:o}}const Rt=(t,e=0)=>((t+1)*.6180339887+e*.3819660113)%1;function en(t,{main:e,draw:n,dur:a,B:r,px:o,L:i}){t.lanes.length;const l=t.half.reduce((c,h)=>c+h,0)/t.half.length,s=[G("g","road glow",i(t.S.map(c=>[c.x,c.y])),!1,{stroke:q(e,r.len(l*1.8),{blur:r.len(l*.8),opacity:.28}),draw:[0,n]})];return t.lanes.forEach((c,h)=>{const u=Rt(h),d=n*.35*Rt(h,1),f=Math.min(a,d+n*.65);s.push(G("l"+(h+1),`lane ${h+1}`,i(c),!1,{stroke:q(e,r.len(o(h%3===1?3.4:2.2)),{blur:r.len(o(.8)),opacity:.8+.2*u}),draw:[d,f]}));const w=G("p"+(h+1),`streak ${h+1}`,i(c),!1,{stroke:q("#fffbe6",r.len(o(4.2)),{blur:r.len(o(2.4))})}),g=1.1+.9*Rt(h,2),T=[{time:I(f),value:-1}];for(let O=f;O<a&&T.length<58;)O+=2*g,T.push({time:I(O),value:1}),O<a&&T.push({time:I(O+.002),value:-1});w.ops=[{op:"trim",start:0,end:_(.08+.1*u),offset:0}],w.keys={"ops.0.offset":T,opacity:[{time:I(f),value:0,ease:Vt},{time:I(Math.min(f+.25,f+a)),value:1}]},s.push(w)}),s}const nn={weight:900,lineHeight:1.25,uppercase:!0,layers:[{type:"text",fill:"#000000",opacity:.45,offset:{x:.05,y:.16},shadow:{color:"#000000",blur:.35,x:0,y:0}},{type:"text",fill:"#6f7480",offset:{x:.018,y:.09}},{type:"text",fill:"#8e939d",offset:{x:.012,y:.06}},{type:"text",fill:"#b4b8c0",offset:{x:.006,y:.03}},{type:"text",fill:"#ffffff",stroke:{color:"#d9dce2",width:.02}}]},zt=t=>t===" "?.32:/[IÍÌỈĨỊ1.,:;!|'’]/.test(t)?.34:/[MWƯỨỪỬỮỰ]/.test(t)?.88:.7,an=t=>{let e=0,n=0,a=0;for(let r=0;r<t.length;r++){const o=t[r],i=t[(r+1)%t.length],l=o[0]*i[1]-i[0]*o[1];e+=l,n+=(o[0]+i[0])*l,a+=(o[1]+i[1])*l}return Math.abs(e)<1e-6?[t.reduce((r,o)=>r+o[0],0)/t.length,t.reduce((r,o)=>r+o[1],0)/t.length]:[n/(3*e),a/(3*e)]};function rn(t){const e=t.reduce((i,l)=>i+l[0],0)/t.length,n=t.reduce((i,l)=>i+l[1],0)/t.length;let a=0,r=0,o=0;for(const i of t){const l=i[0]-e,s=i[1]-n;a+=l*l,r+=l*s,o+=s*s}return wt(Math.cos(.5*Math.atan2(2*r,a-o)),Math.sin(.5*Math.atan2(2*r,a-o)))}function on(t){if(t!==void 0){if(!t||typeof t!="object"||!["w","s","e","n"].every(e=>Number.isFinite(t[e]))||t.w>=t.e||t.s>=t.n||t.w<-180||t.e>180||t.s<-85||t.n>85||t.proj!==void 0&&!["linear","mercator"].includes(t.proj))throw Error("Map bounds are {w,s,e,n} degrees (west < east, south < north) and proj linear | mercator");return t}}function Fn(t){if(t==null)return null;const e=Array.isArray(t)?{w:t[0],s:t[1],e:t[2],n:t[3]}:{w:t.w??t.west,s:t.s??t.south,e:t.e??t.east,n:t.n??t.north,...t.proj?{proj:t.proj}:{}};return on(e)}const ut=t=>Math.log(Math.tan(Math.PI/4+t*Math.PI/360));function sn(t,e,n){const a=(e-t.w)/(t.e-t.w),r=t.proj==="mercator"?(ut(t.n)-ut(n))/(ut(t.n)-ut(t.s)):(t.n-n)/(t.n-t.s);return[+a.toFixed(5),+r.toFixed(5)]}const ln=(t,e,n)=>[t.w+e*(t.e-t.w),t.proj==="mercator"?Math.atan(Math.sinh(ut(t.n)-n*(ut(t.n)-ut(t.s))))*180/Math.PI:t.n-n*(t.n-t.s)];function te(t){let e=0;for(let n=1;n<t.length;n++){const[a,r]=[t[n-1],t[n]],o=Math.PI/180,i=(r[1]-a[1])*o,l=(r[0]-a[0])*o,s=Math.sin(i/2)**2+Math.cos(a[1]*o)*Math.cos(r[1]*o)*Math.sin(l/2)**2;e+=12742*Math.asin(Math.sqrt(s))}return e}const ee=t=>t>=1?`~${(t>=10?Math.round(t):Math.round(t*10)/10).toString().replace(".",",")} km`:`~${Math.round(t*1e3/10)*10} m`;function tt(t,e,n){const a=e?.mapBounds;let r=null;if(t.geojson!=null){let i=typeof t.geojson=="string"?JSON.parse(t.geojson):t.geojson;i?.type==="FeatureCollection"&&(i=i.features?.[0]),i?.type==="Feature"&&(i=i.geometry);const l=i?.coordinates;if(r=i?.type==="Point"?[l]:i?.type==="LineString"||i?.type==="MultiPoint"?l:i?.type==="Polygon"||i?.type==="MultiLineString"?l?.[0]:i?.type==="MultiPolygon"?l?.[0]?.[0]:null,!Array.isArray(r))throw Error("GeoJSON must be a Point, LineString or Polygon (or a Feature of one)");(i.type==="Polygon"||i.type==="MultiPolygon")&&(r=r.slice(0,-1))}else t.lonlat!=null&&(r=t.lonlat);if(r){if(!a)throw Error("lon / lat points need the map bounds: send bounds [west, south, east, north] once (annotateMap / flyTo / setMapBounds)");if(!Array.isArray(r)||!r.every(i=>Array.isArray(i)&&i.length>=2&&i.every(Number.isFinite)))throw Error("lonlat points are [lon, lat]");return{uv:ne(r.map(i=>sn(a,i[0],i[1])),n),ll:r}}const o=Array.isArray(t.points)?ne(t.points,n):t.points;return{uv:o,ll:a&&Array.isArray(o)&&o.every(i=>Array.isArray(i)&&i.length===2)?o.map(i=>ln(a,i[0],i[1])):null}}function ne(t,e){if(!Array.isArray(t)||t.length<=e)return t;const n=(a,r)=>{if(a.length<3)return a;const[o,i]=[a[0],a.at(-1)],l=i[0]-o[0],s=i[1]-o[1],c=Math.hypot(l,s)||1e-9;let h=0,u=0;for(let d=1;d<a.length-1;d++){const f=Math.abs((a[d][0]-o[0])*s-(a[d][1]-o[1])*l)/c;f>h&&(h=f,u=d)}return h>r?[...n(a.slice(0,u+1),r).slice(0,-1),...n(a.slice(u),r)]:[o,i]};for(let a=1e-5;;a*=1.6){const r=n(t,a);if(r.length<=e)return r}}const G=(t,e,n,a,{fill:r,stroke:o,opacity:i=1,draw:l,show:s}={})=>{const c={id:t,name:e,type:"path",params:{pts:n.map(h=>[_(h[0]),_(h[1])]),closed:a},pos:[0,0],rot:0,scale:[1,1],opacity:i,fill:r??{type:"none"},stroke:o??null};return l&&(c.ops=[{op:"trim",start:0,end:1,offset:0}],c.keys={"ops.0.end":[{time:I(l[0]),value:0,ease:ie},{time:I(l[1]),value:1}]}),s&&(c.keys={...c.keys,opacity:[{time:I(s[0]),value:0,ease:Vt},{time:I(s[1]),value:i}]}),c},ht=(t,e,n,a,r,{fill:o,stroke:i,opacity:l=1,show:s}={})=>{const c={id:t,name:e,type:"ellipse",params:{w:_(a),h:_(r)},pos:[_(n[0]),_(n[1])],rot:0,scale:[1,1],opacity:l,fill:o??{type:"none"},stroke:i??null};return s&&(c.keys={opacity:[{time:I(s[0]),value:0,ease:Vt},{time:I(s[1]),value:l}]}),c},q=(t,e,{blur:n,dash:a,opacity:r}={})=>({color:t,width:_(R(e,0,240)),cap:"round",join:"round",...n?{blur:_(R(n,0,200))}:{},...a?{dash:a.map(_)}:{},...r!==void 0&&r<1?{opacity:_(r)}:{}});function Mt({fill:t="#ffffff",outline:e="#000000",glow:n,uppercase:a=!0,italic:r=!1}={}){return{weight:800,lineHeight:1.3,uppercase:a,...r?{lines:[{scale:1,italic:!0}]}:{},layers:[...n?[{type:"text",fill:n,shadow:{color:n,blur:.45,x:0,y:0},opacity:.9}]:[],{type:"text",fill:t,stroke:{color:e,width:.09},shadow:{color:"#000000",blur:.22,x:0,y:.04}}]}}function xt({text:t,px:e,W:n,H:a,font:r="Be Vietnam Pro",design:o,color:i="#ffffff",animation:l}){const s=Math.min(n/1280,a/720);let c=e/s,h=1;return c<24?(h=c/24,c=24):c>96&&(h=c/96,c=96),{title:Ue({text:t,fontSize:Math.round(c),color:i,placement:"center",fontFamily:r,align:"center",design:o,...l?{animation:l}:{}}),scale:I(R(h,.05,4)),label:t.slice(0,40)}}function cn(t,e,n,a,r,o){const i=[];for(let l=0;l<=10;l++){const s=r+(o-r)*l/10,c=R(s-t.start,0,t.duration),h=[[0,0],[1,0],[0,1]].map(([g,T])=>It(t,g,T,c,s,n,a,e));if(h.some(g=>!g))continue;ye(t,n,a);const[u,d]=[bt(t,0,0,n,a),bt(t,1,1,n,a)],f=d[0]-u[0],w=d[1]-u[1];i.push(Math.max(Math.hypot(h[1][0]-h[0][0],h[1][1]-h[0][1])/f,Math.hypot(h[2][0]-h[0][0],h[2][1]-h[0][1])/w))}return i.sort((l,s)=>l-s),R(i.length?i[i.length>>1]:1,.25,6)}function fe(t,e,n,a,r,o,i,l,s=[0,0]){const c=w=>{const g=It(t,e,n,R(w-t.start,0,t.duration),w,o,i,l);return g?[(g[0]+s[0]-o/2)/o,(g[1]+s[1]-i/2)/i]:null},h=Math.max(1,Math.min(120,Math.ceil((r-a)/Je))),u=[];for(let w=0;w<=h;w++){const g=a+(r-a)*w/h,T=c(g);T&&u.push([g-a,T])}if(!u.length)return null;if(u.every(([,w])=>Math.abs(w[0]-u[0][1][0])<1e-4&&Math.abs(w[1]-u[0][1][1])<1e-4))return{posX:I(R(u[0][1][0],-1,1)),posY:I(R(u[0][1][1],-1,1))};const f=w=>u.map(([g,T])=>({time:I(g),value:I(R(T[w],-1,1)),ease:"auto"}));return{x:f(0),y:f(1)}}const he=(t,e)=>{if(!e)return t;if("posX"in e)return{...t,posX:e.posX,posY:e.posY};let n={...t,motionV:2,motionKeys:[]};return n={...n,...dt(n,"x",e.x)},n={...n,...dt(n,"y",e.y)},n};function Rn(t,{base:e,W:n=1280,H:a=720,cam:r=null,materials:o=[]}){const i=t.kind;if(!Ht.includes(i))throw Error(`Map annotation kind must be ${Ht.join("/")}`);if(!e||!["image","video"].includes(e.kind)||e.title||e.shape||e.motion||e.card)throw Error("Map annotations go on a map / drone image or video clip");const l=Number.isFinite(t.at)?t.at:e.start,s=Number.isFinite(t.duration)?t.duration:e.start+e.duration-l;if(!(s>=.2)||l<e.start-1e-6||l+s>e.start+e.duration+1e-6)throw Error("The annotation must lie inside the map clip");const c=R(Number.isFinite(t.draw)?t.draw:1.1,.2,8),h=jt(r)&&At(e),u=cn(e,h?r:null,n,a,Math.min(l+c,l+s),l+s),d=(p,y)=>{const m=Math.min(l+s,l+c+.5);return It(e,p,y,R(m-e.start,0,e.duration),m,n,a,h?r:null)},f=He(n,a),w=p=>bt(e,p[0],p[1],n,a),g=p=>p/u,T=p=>Ze(t.color,p),O=p=>({nodeId:"",kind:"image",url:"",volume:0,start:+l.toFixed(4),duration:+s.toFixed(4),parentId:e.id,motionV:2,motionKeys:[],...At(e)?{is3D:!0,spatialDepth:.002}:{},exit:{type:"fade",duration:Math.min(.4,s/4)},...p,mapAnno:{base:e.id,kind:i}}),B=(p,y)=>O({label:y,shape:{v:2,items:p,size:f.size},posX:0,posY:0,scale:1}),U=p=>{const y=Math.abs(p)*Math.PI/180,m=Math.cos(y),k=Math.sin(y),b=1280,A=720;return Math.min(n/(b*m+A*k),a/(b*k+A*m))/Math.min(n/b,a/A)},V=(p,[y,m],k,b,A,v,N)=>{const x=xt({text:p,px:g(b),W:n,H:a,design:A,animation:N});return x.scale=I(R(x.scale/U(k),.05,4)),O({...x,posX:I((y-n/2)/n),posY:I((m-a/2)/a),rotation:_(k),start:+(l+v).toFixed(4),duration:+Math.max(.2,s-v).toFixed(4),enter:{type:"fade",duration:.35}})},E=(p,y,m,k,b=0)=>{const A=l+b,v=fe(e,y,m,A,l+s,n,a,h?r:null,k);return he({nodeId:"",kind:"image",url:"",volume:0,start:+A.toFixed(4),duration:+(s-b).toFixed(4),motionV:2,motionKeys:[],exit:{type:"fade",duration:Math.min(.35,s/4)},...p,mapAnno:{base:e.id,kind:i,follow:[I(y),I(m),_(k[0]),_(k[1])]}},v)},$=[],L=(p,y)=>p.map(m=>f.pt(m));switch(i){case"route":{const p=tt(t,e,200),y=rt(p.uv,2,200,"A route"),m=Lt[t.style]??Lt.glow,k=T(m.color),b=t.smooth===!1?y.map(w):Wt(y.map(w)),A=m.lanes?tn(b,{lanes:Number.isFinite(t.lanes)?t.lanes:11,width:g(Number.isFinite(t.width)?R(t.width,10,600):70),taper:t.taper}):null,v=A?en(A,{main:k,draw:c,dur:s,B:f,px:g,L}):m.layers.map((P,C)=>G("s"+(C+1),`${t.style??"glow"} ${C+1}`,L(b),!1,{stroke:q(P.c??k,f.len(g(P.w)),{blur:P.blur?f.len(g(P.blur)):void 0,dash:P.dash?.map(F=>f.len(g(F))),opacity:P.a}),draw:[0,c]}));if(t.arrow&&!A){const P=b.at(-1),C=b[Math.max(0,b.length-4)],F=Math.atan2(P[1]-C[1],P[0]-C[0]),D=g(Math.max(16,m.layers[1]?.w*2.2||16)),M=(z,K)=>[P[0]+Math.cos(F+K)*z,P[1]+Math.sin(F+K)*z];v.push(G("s9","arrow",L([M(D*.4,0),M(D,Math.PI*.82),M(D*.25,Math.PI),M(D,-Math.PI*.82)]),!0,{fill:{type:"color",color:m.layers[1]?.c??k},stroke:q("#ffffff",f.len(g(1.5)),{opacity:.8}),show:[c*.92,c]}))}$.push(B(v,`Map · ${J(t.text)||m.en}`));const N=t.distance&&p.ll?ee(te(p.ll)):"",x=[J(t.text),N].filter(Boolean).join(" · "),S=x.normalize("NFC").split(" ").filter(Boolean);if(x&&(t.labelLook==="stand"||A&&t.labelLook!=="flat")&&S.length<=8&&S.join("").length<=40){const P=A?.S??le(b),C=A?.k??ce(P,t.taper),F=A?.half??P.map(()=>g(Math.max(...m.layers.map(Q=>Q.w))/2)),D=Number.isFinite(t.textSize)?R(t.textSize,10,80):40,M=g(D),z=P.at(-1).s,K=C.map(Q=>.55+.45*Q),X=Q=>{const nt=R(Q/(z||1),0,1)*(P.length-1),Y=Math.min(P.length-2,Math.floor(nt)),Z=nt-Y,W=P[Y],ft=P[Y+1]??W,at=(kt,me)=>kt+(me-kt)*Z;return{x:at(W.x,ft.x),y:at(W.y,ft.y),nx:at(W.nx,ft.nx),ny:at(W.ny,ft.ny),k:at(K[Y],K[Y+1]??K[Y]),half:at(F[Y],F[Y+1]??F[Y])}},ct=Q=>[...Q].reduce((nt,Y)=>nt+zt(Y.toUpperCase()),0),ot=(S.reduce((Q,nt)=>Q+ct(nt),0)+zt(" ")*(S.length-1))*M*X(z/2).k;let H=R(z/2-ot/2,0,Math.max(0,z-ot)),gt=0;const yt=Math.min(.07,Math.max(.03,(s-c*.6-.8)/Math.max(1,S.join("").length)));for(const Q of S){const nt=X(H).k,Y=ct(Q)*M*nt,Z=X(H+Y/2),W=Z.ny>0?-1:1,ft=Z.k,at=Z.half+M*ft*.62,kt=wt(-Z.ny*W,Z.nx*W);$.push(V(Q,[Z.x+Z.nx*W*at,Z.y+Z.ny*W*at],kt,D*ft,nn,c*.6+gt*yt,{in:[{unit:"char",stagger:yt,duration:.5,easing:"easeOutBack",from:{opacity:0,y:.55,blur:.3}}],out:"reverse",outSpeed:1.8})),gt+=[...Q].length,H+=Y*1.02+zt(" ")*M*nt}}else if(x){const P=Number.isFinite(t.textSize)?R(t.textSize,10,80):22,C=x.length*P*.62/u,F=We(b,C),D=m.layers[1]?.w>=9,M=D?0:g(Math.max(...m.layers.map(z=>z.w))/2)+g(P)*.75;$.push(V(x,[F.x+F.nx*M,F.y+F.ny*M],F.angle,P,Mt({fill:"#ffffff",outline:D?k:"#000000"}),c*.7))}break}case"area":{const p=rt(tt(t,e,200).uv,3,200,"An area"),y=T("#39ff6a"),m=t.smooth?Wt(p.map(w),!0):p.map(w),k=[G("s1","fill",L(m),!0,{fill:{type:"color",color:y,opacity:.38},show:[c*.5,c]}),G("s2","glow",L(m),!0,{stroke:q(y,f.len(g(14)),{blur:f.len(g(10)),opacity:.75}),draw:[0,c]}),G("s3","edge",L(m),!0,{stroke:q(y,f.len(g(3.5))),draw:[0,c]})];$.push(B(k,`Map · ${J(t.text)||"area"}`));const b=J(t.text);if(b){const A=an(m),v=Number.isFinite(t.textSize)?R(t.textSize,10,80):24;$.push(V(b,A,rn(m),v,Mt({fill:"#ffffff",outline:y}),c*.8))}break}case"lots":{const p=rt(tt(t,e,4).uv,4,4,"A lot block").map(w),y=Array.isArray(t.labels)?t.labels.map(M=>J(M,12)).filter(Boolean).slice(0,10):[],m=R(Math.round(t.count??(y.length||4)),1,10),k=(M,z)=>Math.hypot(M[0]-z[0],M[1]-z[1]),b=(M,z,K)=>[M[0]+(z[0]-M[0])*K,M[1]+(z[1]-M[1])*K],[A,v,N,x]=k(p[0],p[1])+k(p[3],p[2])>=k(p[1],p[2])+k(p[0],p[3])?[p[0],p[1],p[3],p[2]]:[p[1],p[2],p[0],p[3]],S=T("#ffe066"),P="#2a2100",C=Math.min(.18,s/(3*m)),F=[G("s1","block glow",L(p),!0,{stroke:q("#ffffff",f.len(g(10)),{blur:f.len(g(8)),opacity:.55}),draw:[0,c*.8]})],D=[];for(let M=0;M<m;M++){const z=[b(A,v,M/m),b(A,v,(M+1)/m),b(N,x,(M+1)/m),b(N,x,M/m)];D.push(z),F.push(G("l"+(M+1),y[M]||`Lô ${M+1}`,L(z),!0,{fill:{type:"color",color:S,opacity:Number.isFinite(t.fillOpacity)?R(t.fillOpacity,.1,1):.9},stroke:q(P,f.len(g(1.4)),{opacity:.8}),opacity:1,show:[c*.6+M*C,c*.6+M*C+.25]}))}F.push(G("s2","block edge",L(p),!0,{stroke:q("#ffffff",f.len(g(2.4))),draw:[0,c*.8]})),$.push(B(F.slice(0,24),`Map · ${y.length?y[0]+"–"+y.at(-1):"lots"}`)),D.forEach((M,z)=>{if(!y[z])return;const K=M.reduce((gt,yt)=>[gt[0]+yt[0]/4,gt[1]+yt[1]/4],[0,0]),X=k(M[0],M[1]),ct=k(M[1],M[2]),ot=ct>=X?[(M[0][0]+M[1][0])/2-(M[3][0]+M[2][0])/2,(M[0][1]+M[1][1])/2-(M[3][1]+M[2][1])/2]:[M[1][0]-M[0][0],M[1][1]-M[0][1]],H=Math.min(Math.min(X,ct)*.55*u,Number.isFinite(t.textSize)?t.textSize:22);$.push(V(y[z],K,wt(ot[0],ot[1]),H,Mt({fill:P,outline:S,uppercase:!0}),c*.6+z*C+.15))});break}case"label":{const p=tt(t,e,2),[y,m]=rt(p.uv,2,2,"A measure").map(w),k=J(t.text,24)||(t.distance&&p.ll?ee(te(p.ll)):"");if(!k)throw Error('A measure label needs its text (e.g. "20m")');const b=T("#ff2a2a"),A=m[0]-y[0],v=m[1]-y[1],N=Math.hypot(A,v)||1,x=-v/N,S=A/N,P=g(9),C=X=>[[X[0]+x*P,X[1]+S*P],[X[0]-x*P,X[1]-S*P]],F=[G("s1","measure",L([y,m]),!1,{stroke:q("#ffffff",f.len(g(2.2))),draw:[0,c*.6]}),G("s2","tick a",L(C(y)),!1,{stroke:q("#ffffff",f.len(g(2.2))),show:[0,.2]}),G("s3","tick b",L(C(m)),!1,{stroke:q("#ffffff",f.len(g(2.2))),show:[c*.5,c*.6]})];$.push(B(F,`Map · ${k}`));const D=Number.isFinite(t.textSize)?R(t.textSize,10,80):30,M=wt(A,v),z=M*Math.PI/180,K=g(D)*.8;$.push(V(k,[(y[0]+m[0])/2+Math.sin(z)*K,(y[1]+m[1])/2-Math.cos(z)*K],M,D,{weight:900,lineHeight:1.3,uppercase:!1,lines:[{scale:1,italic:!0}],layers:[{type:"text",fill:b,stroke:{color:"#ffffff",width:.12},shadow:{color:"#000000",blur:.25,x:0,y:.05}}]},c*.5));break}case"pin":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A pin"),m=T("#3cf2d0"),k=J(t.text,24),b=a>n,A=(Number.isFinite(t.height)?t.height:b?.2:.26)*a,v=(b?.085:.06)*Math.min(n,a)*(b?1.6:1.4),N=[n/2,a/2],x=[n/2,a/2-A],S=[ht("s1","ground glow",f.pt(N),f.len(v*1.6),f.len(v*.55),{stroke:q(m,f.len(v*.35),{blur:f.len(v*.3),opacity:.7})}),G("s2","beam",L([[N[0]-v*.05,N[1]],[N[0]+v*.05,N[1]],[x[0]+v*.42,x[1]],[x[0]-v*.42,x[1]]]),!0,{fill:{type:"linear",stops:[["#e9fffb",0],[m,1]],angle:90,opacity:.55},stroke:q(m,f.len(4),{blur:f.len(6),opacity:.8})}),ht("s3","badge glow",f.pt(x),f.len(v*2.15),f.len(v*2.15),{stroke:q(m,f.len(v*.3),{blur:f.len(v*.28),opacity:.8})}),ht("s4","badge",f.pt(x),f.len(v*2),f.len(v*2),{fill:{type:"radial",stops:[["#9ffff1",0],[m,.7],["#0f8f86",1]],opacity:.95},stroke:q("#eafffb",f.len(3))}),ht("s5","point",f.pt(N),f.len(9),f.len(9),{fill:{type:"color",color:"#ffffff"},stroke:q(m,f.len(3))})],P={type:"slide-down",duration:.55,amount:.06,ease:Qe};$.push(E({label:`Map · pin ${k||""}`.trim(),shape:{v:2,items:S,size:f.size},enter:P},p,y,[0,0]));const C=t.materialId?o.find(F=>F.id===t.materialId&&F.kind==="image"):null;if(C){const F=Number.isInteger(C.width)&&C.width>1?C.width:1e3,D=Number.isInteger(C.height)&&C.height>1?C.height:1e3,M=Ut(F,D),z=Math.min(M.w,M.h),K=Math.min(n/F,a/D),X=I(R(v*1.7/(z*K),.02,4));$.push(E({nodeId:C.id,url:C.url,...C.gcsUri?{gcsUri:C.gcsUri}:{},label:"Map · logo",scale:X,mask:Gt({mw:F,mh:D},[Xt({kind:"circle",cx:.5,cy:.5,w:I(z/M.w),h:I(z/M.h),rot:0},M.w,M.h)]),mapSize:[F,D],enter:P},p,y,[0,-A]))}else if(k){const F=xt({text:k,px:Math.min(v*.42,v*3.2/Math.max(4,k.length)),W:n,H:a,font:"Be Vietnam Pro",design:{weight:800,lineHeight:1.3,uppercase:!0,layers:[{type:"text",fill:"#063b37",shadow:{color:"#ffffff",blur:.15,x:0,y:0}}]}});$.push(E({...F,enter:P},p,y,[0,-A]))}if(k&&C){const F=xt({text:k,px:22,W:n,H:a,design:Mt({fill:"#ffffff",outline:m})});$.push(E({...F,enter:P},p,y,[0,-A+v*1.45]))}break}case"photo":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A photo bubble"),m=o.find(H=>H.id===t.materialId&&H.kind==="image");if(!m?.url)throw Error("A photo bubble needs an image from Media (materialId)");const k=T("#ffd23a"),b=(Number.isFinite(t.size)?t.size:.17)*Math.min(n,a)*(a>n?1.5:1.2),A=d(p,y),v=Array.isArray(t.offset)&&t.offset.length===2&&t.offset.every(Number.isFinite)?[t.offset[0]*n,t.offset[1]*a]:[A&&A[0]<n*.35?b*.95:-b*.95,A&&A[1]<a*.38?b*1.05:-b*1.05],N=[n/2+v[0],a/2+v[1]],x=[n/2,a/2],S=Math.atan2(x[1]-N[1],x[0]-N[0]),P=b/2,C=[N[0]+Math.cos(S+Math.PI/2)*P*.62,N[1]+Math.sin(S+Math.PI/2)*P*.62],F=[N[0]+Math.cos(S-Math.PI/2)*P*.62,N[1]+Math.sin(S-Math.PI/2)*P*.62],D=[G("s1","cone",L([C,x,F]),!0,{fill:{type:"linear",stops:[[k,0],["#fff6c8",1]],angle:_(S*180/Math.PI),opacity:.6},show:[.25,.6]}),ht("s2","point",f.pt(x),f.len(10),f.len(10),{fill:{type:"color",color:"#ffffff"},stroke:q(k,f.len(3)),show:[0,.2]}),ht("s3","ring glow",f.pt(N),f.len(b*1.08),f.len(b*1.08),{stroke:q(k,f.len(b*.06),{blur:f.len(b*.06),opacity:.85}),show:[.1,.4]})];$.push(E({label:"Map · photo cone",shape:{v:2,items:D,size:f.size}},p,y,[0,0]));const M=Number.isInteger(m.width)&&m.width>1?m.width:1e3,z=Number.isInteger(m.height)&&m.height>1?m.height:1e3,K=Ut(M,z),X=Math.min(K.w,K.h),ct=Math.min(n/M,a/z);$.push(E({nodeId:m.id,url:m.url,...m.gcsUri?{gcsUri:m.gcsUri}:{},label:`Map · ${J(t.text)||m.label||"photo"}`,scale:I(R(b/(X*ct),.02,4)),mapSize:[M,z],mask:Gt({mw:M,mh:z},[Xt({kind:"circle",cx:.5,cy:.5,w:I(X/K.w),h:I(X/K.h),rot:0},K.w,K.h)]),edge:{color:k,width:.012,glow:.7},enter:{type:"pop",duration:.45}},p,y,v,.15));const ot=J(t.text,28);if(ot){const H=xt({text:ot,px:20,W:n,H:a,design:Mt({fill:"#ffffff",outline:"#000000"})});$.push(E({...H,enter:{type:"fade",duration:.3}},p,y,[v[0],v[1]-P-16],.35))}break}case"callout":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A callout"),m=J(t.text,40),k=J(t.subText,60),b=T("#c9a45c");if(!m)throw Error("A callout needs its text");const A=d(p,y),v=!!A&&A[1]<a*.38,N=!!A&&A[0]>n*.62,x=N?-1:1,S=v?-1:1,P=(Number.isFinite(t.height)?t.height:.16)*a*S,C=[n/2,a/2],F=[n/2+n*.04*x,a/2-P],D=[G("s1","leader",L([C,[C[0],F[1]+8],F]),!1,{stroke:q(b,f.len(2.4)),draw:[0,.45]}),ht("s2","point",f.pt(C),f.len(11),f.len(11),{fill:{type:"color",color:b},stroke:q("#ffffff",f.len(2.5))})];$.push(E({label:"Map · callout leader",shape:{v:2,items:D,size:f.size}},p,y,[0,0]));const M=xt({text:k?`${m}
4
4
  ${k}`:m,px:24,W:n,H:a,design:{weight:800,lineHeight:1.35,uppercase:!1,...k?{lines:[{scale:1},{scale:.62,weight:500,fill:"#e8dcc0"}]}:{},layers:[{type:"box",fill:"#0f1b30",radius:.18,padX:.55,padY:.32,opacity:.92},{type:"text",fill:"#ffffff"},{type:"underline",fill:b,height:.06,width:.35,offsetY:.25}]}}),z=Math.max(...M.title.text.split(`
@@ -1 +1 @@
1
- import{iL as w,hR as W,np as A,b0 as E,b1 as M,b2 as P,aP as $,a_ as L,aQ as O,aZ as b}from"./titleFrameBudget-DsM0V482.js";function R(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),o={};for(let e=0,a=t.getUint16(4);e<a;e++){const l=12+e*16;o[String.fromCharCode(n[l],n[l+1],n[l+2],n[l+3])]=t.getUint32(l+8)}const s=t.getUint16(o.head+18),i=t.getUint16(o.hhea+34),g=e=>t.getUint16(o.hmtx+Math.min(e,i-1)*4),r=o.cmap,f=[];for(let e=0,a=t.getUint16(r+2);e<a;e++)f.push({platform:t.getUint16(r+4+e*8),encoding:t.getUint16(r+6+e*8),offset:r+t.getUint32(r+8+e*8)});const p=f.find(e=>e.platform===3&&e.encoding===10)||f.find(e=>e.platform===3&&e.encoding===1)||f.find(e=>e.platform===0);if(!p)throw Error("Font has no usable cmap");const h=t.getUint16(p.offset);return{unitsPerEm:s,glyphFor:e=>{if(h===4){const a=t.getUint16(p.offset+6)/2,l=p.offset+14,u=l+a*2+2,y=u+a*2,m=y+a*2;for(let d=0;d<a;d++){if(e>t.getUint16(l+d*2))continue;if(e<t.getUint16(u+d*2))return 0;const k=t.getUint16(m+d*2),x=t.getInt16(y+d*2);if(!k)return e+x&65535;const C=t.getUint16(m+d*2+k+(e-t.getUint16(u+d*2))*2);return C?C+x&65535:0}return 0}if(h===12){for(let a=0,l=t.getUint32(p.offset+12);a<l;a++){const u=p.offset+16+a*12,y=t.getUint32(u),m=t.getUint32(u+4);if(e>=y&&e<=m)return t.getUint32(u+8)+(e-y)}return 0}throw Error(`Unsupported cmap format ${h}`)},advanceOf:g}}const T=n=>({...R(n),advances:new Map});function j(n,t,o){let s=0;for(const i of String(t).normalize("NFC")){let g=n.advances.get(i);g===void 0&&(g=n.advanceOf(n.glyphFor(i.codePointAt(0))),n.advances.set(i,g)),s+=g}return s*o/n.unitsPerEm}let U=null;const S=new Map,v=new Map;function B(n){const t=w(n);if(S.has(t.id))return Promise.resolve();let o=v.get(t.id);return o||(o=Promise.all([fetch(`/fonts/${t.file}`).then(s=>{if(!s.ok)throw Error(String(s.status));return s.arrayBuffer()}).then(s=>{S.set(t.id,T(new Uint8Array(s)))}),document.fonts.load(`40px "${t.css}"`)]).then(()=>{}).catch(()=>{v.delete(t.id)}),v.set(t.id,o)),o}function D(n,t,o){const s=S.get(w(o).id);return s?j(s,n,t):(B(o),U??=document.createElement("canvas").getContext("2d"),U?(U.font=`${t}px "${w(o).css}"`,U.measureText(n).width):n.length*t*.55)}const F=new WeakMap,N=n=>{const t=F.get(n.captionWords);if(t&&t.style===n.captionStyle&&t.cues===n.captions)return t.prepared;const o=b(n.captionWords,n.captionStyle,n.captions);return F.set(n.captionWords,{style:n.captionStyle,cues:n.captions,prepared:o}),o},Q=(n,t)=>{const o=n.groups[t];let s=0;for(let i=o.from;i<=o.to;i++)s+=[...String(n.words[i].word)].length;return s};function Z(n,t,o,s,i,g=D){const r=W(n,t,o);if(!r)return null;const f=t-r.start;if(["social","karaoke"].includes(r.captionStyle?.style||"")&&r.captionWords?.length){const c=N(r),e=A(c.groups,f);if(e<0)return null;const a=c.style.style==="karaoke",l=c.groups[e],u=E(c.style,f-l.start,Q(c,e));return{clip:r,layout:P(c,e,s,i,g),style:c.style,scale:u.scale,motion:u.m,lit:a?M(c,e,f):void 0}}const p=$(r.captionStyle),h=L(r.captions,p.cueWords).find(c=>f>=c.start&&f<c.end);return h?{clip:r,layout:O({width:s,height:i,text:h.text,style:p,measure:g,second:h.tr}),style:p,scale:1}:null}export{B as captionFontReady,Z as captionFrameAt,Q as groupLetters,D as measureCaption};
1
+ import{iL as w,hR as W,np as A,b0 as E,b1 as M,b2 as P,aP as $,a_ as L,aQ as O,aZ as b}from"./titleFrameBudget-BW-N1-cw.js";function R(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),o={};for(let e=0,a=t.getUint16(4);e<a;e++){const l=12+e*16;o[String.fromCharCode(n[l],n[l+1],n[l+2],n[l+3])]=t.getUint32(l+8)}const s=t.getUint16(o.head+18),i=t.getUint16(o.hhea+34),g=e=>t.getUint16(o.hmtx+Math.min(e,i-1)*4),r=o.cmap,f=[];for(let e=0,a=t.getUint16(r+2);e<a;e++)f.push({platform:t.getUint16(r+4+e*8),encoding:t.getUint16(r+6+e*8),offset:r+t.getUint32(r+8+e*8)});const p=f.find(e=>e.platform===3&&e.encoding===10)||f.find(e=>e.platform===3&&e.encoding===1)||f.find(e=>e.platform===0);if(!p)throw Error("Font has no usable cmap");const h=t.getUint16(p.offset);return{unitsPerEm:s,glyphFor:e=>{if(h===4){const a=t.getUint16(p.offset+6)/2,l=p.offset+14,u=l+a*2+2,y=u+a*2,m=y+a*2;for(let d=0;d<a;d++){if(e>t.getUint16(l+d*2))continue;if(e<t.getUint16(u+d*2))return 0;const k=t.getUint16(m+d*2),x=t.getInt16(y+d*2);if(!k)return e+x&65535;const C=t.getUint16(m+d*2+k+(e-t.getUint16(u+d*2))*2);return C?C+x&65535:0}return 0}if(h===12){for(let a=0,l=t.getUint32(p.offset+12);a<l;a++){const u=p.offset+16+a*12,y=t.getUint32(u),m=t.getUint32(u+4);if(e>=y&&e<=m)return t.getUint32(u+8)+(e-y)}return 0}throw Error(`Unsupported cmap format ${h}`)},advanceOf:g}}const T=n=>({...R(n),advances:new Map});function j(n,t,o){let s=0;for(const i of String(t).normalize("NFC")){let g=n.advances.get(i);g===void 0&&(g=n.advanceOf(n.glyphFor(i.codePointAt(0))),n.advances.set(i,g)),s+=g}return s*o/n.unitsPerEm}let U=null;const S=new Map,v=new Map;function B(n){const t=w(n);if(S.has(t.id))return Promise.resolve();let o=v.get(t.id);return o||(o=Promise.all([fetch(`/fonts/${t.file}`).then(s=>{if(!s.ok)throw Error(String(s.status));return s.arrayBuffer()}).then(s=>{S.set(t.id,T(new Uint8Array(s)))}),document.fonts.load(`40px "${t.css}"`)]).then(()=>{}).catch(()=>{v.delete(t.id)}),v.set(t.id,o)),o}function D(n,t,o){const s=S.get(w(o).id);return s?j(s,n,t):(B(o),U??=document.createElement("canvas").getContext("2d"),U?(U.font=`${t}px "${w(o).css}"`,U.measureText(n).width):n.length*t*.55)}const F=new WeakMap,N=n=>{const t=F.get(n.captionWords);if(t&&t.style===n.captionStyle&&t.cues===n.captions)return t.prepared;const o=b(n.captionWords,n.captionStyle,n.captions);return F.set(n.captionWords,{style:n.captionStyle,cues:n.captions,prepared:o}),o},Q=(n,t)=>{const o=n.groups[t];let s=0;for(let i=o.from;i<=o.to;i++)s+=[...String(n.words[i].word)].length;return s};function Z(n,t,o,s,i,g=D){const r=W(n,t,o);if(!r)return null;const f=t-r.start;if(["social","karaoke"].includes(r.captionStyle?.style||"")&&r.captionWords?.length){const c=N(r),e=A(c.groups,f);if(e<0)return null;const a=c.style.style==="karaoke",l=c.groups[e],u=E(c.style,f-l.start,Q(c,e));return{clip:r,layout:P(c,e,s,i,g),style:c.style,scale:u.scale,motion:u.m,lit:a?M(c,e,f):void 0}}const p=$(r.captionStyle),h=L(r.captions,p.cueWords).find(c=>f>=c.start&&f<c.end);return h?{clip:r,layout:O({width:s,height:i,text:h.text,style:p,measure:g,second:h.tr}),style:p,scale:1}:null}export{B as captionFontReady,Z as captionFrameAt,Q as groupLetters,D as measureCaption};
@@ -1 +1 @@
1
- import{b_ as p,eU as b,eV as y,iG as x,ez as w,cD as E,eL as S,i9 as A,iH as D,fo as O,er as _,es as v,ev as B,dW as u,dY as f,iI as T,U as L,W as I,iJ as $,hJ as z,bL as P}from"./titleFrameBudget-DsM0V482.js";import{e as R,a as j}from"./timelineComp-i-zdaoB2.js";const F=new Set(["opacity","x","y","zoom","blur","exposure","dirBlur","zoomBlur","rgbSplit","invert","glitch","rot","spinBlur","dirBlurV"]),M=e=>!(e?.dirBlur&&(e.zoom||e.blur||e.zoomBlur))&&!(e?.zoomBlur&&(e.x||e.y||e.blur||e.dirBlur)),J=new Set(["id","name","category","duration","tags","version","sortOrder","a","b","flash","light","mask","zoomAt","gl"]),X=["colorPerson","matte","shocks","impacts","smoothSlow","reverse","revealType","rotFit","is3D","space","bend","bendStrip","device","deviceScreen","join","audioFx","audioTools","muffle","trail","path","links","element","modelGround","modelRotation","modelSpin","modelAnim","modelDepth","spatialDepth","pendingPin","personPending","samPending","gen","clientJobs","mapAnno","seam","warped"],H={rx:0,ry:0,rz:0,depth:0,tiltX:0,tiltY:0},K=new Set(["rot","sx","sy","depth","tiltX","tiltY"]),N=new Set(["is3D","spatialDepth"]),U=new Set(["blur","glow","light-burst","rgb-split","pixelate","sepia","invert","mono","duotone","luma-invert",...Object.keys(P)]),c=e=>e!=null&&e!==!1&&!(Array.isArray(e)&&!e.length);function V(e,{camera:a=null,W:r=1280,H:m=720}={}){const n=[];if(E(e))return[];if(e.kind==="model")return[];if(!["image","video","audio"].includes(e.kind))return[`${e.kind} layer`];const i=e.kind!=="audio"&&b(a)&&y(e),d=!i&&e.is3D===!0&&!c(e.spatialDepth);for(const t of X){if(t==="clientJobs"){Array.isArray(e.clientJobs)&&e.clientJobs.some(o=>o?.state==="pending"||o?.state==="running")&&n.push(t);continue}c(e[t])&&!(i&&N.has(t))&&!(d&&t==="is3D")&&n.push(t)}if(e.pin?.scene&&n.push("scene pin"),e.timeRemap?.blend&&e.timeRemap.blend!=="none"&&n.push("time remap frame blending"),e.kind!=="audio"&&S(e,r||1280).some(t=>t.sigma>42)&&n.push("wide shadow"),A(e)&&D(e)&&n.push("shadow on an adjustment layer"),e.motionBlur&&e.kind!=="audio"&&((e.effects||[]).some(t=>!t.off)||e.pin||e.parentId||O(e)||e.layout!==void 0||e.rotFit||i)&&n.push("motion blur"),e.kind!=="audio"&&_(e)){const t=v(e),o=B(t);t.crackle?n.push("edge crackle"):Math.max(o.band,o.glow)>42&&n.push("wide edge")}const l=!i&&e.kind!=="audio"&&(u(e,"rot").length>1||Math.abs(f(e,"rot",0))>1e-9);l&&((e.effects||[]).some(t=>!t.off)||e.layout!==void 0||e.rotFit)&&n.push("rot"),!i&&e.kind!=="audio"&&["ax","ay"].some(t=>u(e,t).length>1||Math.abs(f(e,t,0))>1e-9)&&l&&n.push("anchor with rotation"),i&&(e.transition||e._txIn||e._txOut)&&n.push("transition on a 3D layer");for(const[t,o]of Object.entries(H))!(i&&K.has(t))&&(u(e,t).length>1||Math.abs(f(e,t,0)-o)>1e-9)&&n.push(t);e.grade&&!e.colorBypass&&(e.grade.lut||T(e.grade).length)&&n.push("grade"),e.grade&&!e.colorBypass&&L(e.grade).some(t=>I(t)&&(t.window?.type==="person"||t.qualifier&&(t.window?.type==="polygon"||t.motion||t.window?.type==="face")))&&n.push("grade window");for(const t of Array.isArray(e.effects)?e.effects:[])!t.off&&!U.has(t.type)&&n.push(`effect ${t.type}`);if($(e,"T")&&n.push("reveal"),e.transition){const t=e.transition.spec||{},o=s=>!!e.transition.ramp||M(s);(Object.keys(t).some(s=>!J.has(s))||["a","b"].some(s=>t[s]&&(Object.keys(t[s]).some(k=>!F.has(k))||!o(t[s]))))&&n.push(`transition ${e.transition.id}`)}return e.kind==="video"&&z(e)&&n.push("title on video"),n}function C(e,a={}){const{reasons:r}=h(e,a);return{ok:r.length===0,reasons:r}}function G(e,a={}){return[...new Set(h(e,a).codes)].sort()}function h(e,{format:a,camera:r,look:m}={}){const n=[],i=[];e=R((e||[]).filter(t=>!t.disabled),{W:p(a).width,H:p(a).height});const d=b(r)?r:null,{width:l,height:g}=p(a);d&&(e||[]).some(t=>!t.disabled&&t.kind!=="audio"&&y(t))&&d.parentId&&(n.push("camera on a parent"),i.push("camera on a parent")),x(m)&&(n.push("look"),i.push("look"));for(const t of e||[]){if(t.disabled)continue;if(t._group&&t.comp){const s=h(j(t),{format:a});s.reasons.length&&(n.push(`${t.label||t.id} (comp): ${s.reasons.join("; ")}`),i.push(...s.codes))}const o=V(t,{camera:d,W:l,H:g});o.length&&(n.push(`${t.label||t.id}: ${o.join(", ")}`),i.push(...o))}if(!n.length)for(const t of w((e||[]).filter(o=>!o.disabled))){const o=s=>{n.push(`${t.label||t.id}: ${s}`),i.push(s)};t.timeRemap&&(t._txIn||t._txOut)&&!t._ramp&&o("time remap in a transition"),t.motionBlur&&(t._txIn||t._txOut)&&o("motion blur in a transition")}return{reasons:n,codes:i}}const q=(e,a,r)=>(a==="video encode"||a==="finalize")&&r?.codec!=="hevc"&&e?.name!=="AbortError"&&/^(OperationError|EncodingError)$/.test(e?.name||""),Q=e=>!(typeof DOMException<"u"&&e instanceof DOMException)&&!(e instanceof TypeError)&&!(e instanceof Error&&/^media \d{3}$/.test(e.message))?"":(e.message||"").replace(/\b(?:https?|blob|data):\S*/gi,"").replace(/\s+/g," ").trim();export{X as HEAVY_FIELDS,C as clientExportCheck,G as clientExportCodes,V as clipBlockers,Q as gpuErrorText,q as softwareRetry};
1
+ import{b_ as p,eU as b,eV as y,iG as x,ez as w,cD as E,eL as S,i9 as A,iH as D,fo as O,er as _,es as v,ev as B,dW as u,dY as f,iI as T,U as L,W as I,iJ as $,hJ as z,bL as P}from"./titleFrameBudget-BW-N1-cw.js";import{e as R,a as j}from"./timelineComp-D8PHGHgQ.js";const F=new Set(["opacity","x","y","zoom","blur","exposure","dirBlur","zoomBlur","rgbSplit","invert","glitch","rot","spinBlur","dirBlurV"]),M=e=>!(e?.dirBlur&&(e.zoom||e.blur||e.zoomBlur))&&!(e?.zoomBlur&&(e.x||e.y||e.blur||e.dirBlur)),J=new Set(["id","name","category","duration","tags","version","sortOrder","a","b","flash","light","mask","zoomAt","gl"]),X=["colorPerson","matte","shocks","impacts","smoothSlow","reverse","revealType","rotFit","is3D","space","bend","bendStrip","device","deviceScreen","join","audioFx","audioTools","muffle","trail","path","links","element","modelGround","modelRotation","modelSpin","modelAnim","modelDepth","spatialDepth","pendingPin","personPending","samPending","gen","clientJobs","mapAnno","seam","warped"],H={rx:0,ry:0,rz:0,depth:0,tiltX:0,tiltY:0},K=new Set(["rot","sx","sy","depth","tiltX","tiltY"]),N=new Set(["is3D","spatialDepth"]),U=new Set(["blur","glow","light-burst","rgb-split","pixelate","sepia","invert","mono","duotone","luma-invert",...Object.keys(P)]),c=e=>e!=null&&e!==!1&&!(Array.isArray(e)&&!e.length);function V(e,{camera:a=null,W:r=1280,H:m=720}={}){const n=[];if(E(e))return[];if(e.kind==="model")return[];if(!["image","video","audio"].includes(e.kind))return[`${e.kind} layer`];const i=e.kind!=="audio"&&b(a)&&y(e),d=!i&&e.is3D===!0&&!c(e.spatialDepth);for(const t of X){if(t==="clientJobs"){Array.isArray(e.clientJobs)&&e.clientJobs.some(o=>o?.state==="pending"||o?.state==="running")&&n.push(t);continue}c(e[t])&&!(i&&N.has(t))&&!(d&&t==="is3D")&&n.push(t)}if(e.pin?.scene&&n.push("scene pin"),e.timeRemap?.blend&&e.timeRemap.blend!=="none"&&n.push("time remap frame blending"),e.kind!=="audio"&&S(e,r||1280).some(t=>t.sigma>42)&&n.push("wide shadow"),A(e)&&D(e)&&n.push("shadow on an adjustment layer"),e.motionBlur&&e.kind!=="audio"&&((e.effects||[]).some(t=>!t.off)||e.pin||e.parentId||O(e)||e.layout!==void 0||e.rotFit||i)&&n.push("motion blur"),e.kind!=="audio"&&_(e)){const t=v(e),o=B(t);t.crackle?n.push("edge crackle"):Math.max(o.band,o.glow)>42&&n.push("wide edge")}const l=!i&&e.kind!=="audio"&&(u(e,"rot").length>1||Math.abs(f(e,"rot",0))>1e-9);l&&((e.effects||[]).some(t=>!t.off)||e.layout!==void 0||e.rotFit)&&n.push("rot"),!i&&e.kind!=="audio"&&["ax","ay"].some(t=>u(e,t).length>1||Math.abs(f(e,t,0))>1e-9)&&l&&n.push("anchor with rotation"),i&&(e.transition||e._txIn||e._txOut)&&n.push("transition on a 3D layer");for(const[t,o]of Object.entries(H))!(i&&K.has(t))&&(u(e,t).length>1||Math.abs(f(e,t,0)-o)>1e-9)&&n.push(t);e.grade&&!e.colorBypass&&(e.grade.lut||T(e.grade).length)&&n.push("grade"),e.grade&&!e.colorBypass&&L(e.grade).some(t=>I(t)&&(t.window?.type==="person"||t.qualifier&&(t.window?.type==="polygon"||t.motion||t.window?.type==="face")))&&n.push("grade window");for(const t of Array.isArray(e.effects)?e.effects:[])!t.off&&!U.has(t.type)&&n.push(`effect ${t.type}`);if($(e,"T")&&n.push("reveal"),e.transition){const t=e.transition.spec||{},o=s=>!!e.transition.ramp||M(s);(Object.keys(t).some(s=>!J.has(s))||["a","b"].some(s=>t[s]&&(Object.keys(t[s]).some(k=>!F.has(k))||!o(t[s]))))&&n.push(`transition ${e.transition.id}`)}return e.kind==="video"&&z(e)&&n.push("title on video"),n}function C(e,a={}){const{reasons:r}=h(e,a);return{ok:r.length===0,reasons:r}}function G(e,a={}){return[...new Set(h(e,a).codes)].sort()}function h(e,{format:a,camera:r,look:m}={}){const n=[],i=[];e=R((e||[]).filter(t=>!t.disabled),{W:p(a).width,H:p(a).height});const d=b(r)?r:null,{width:l,height:g}=p(a);d&&(e||[]).some(t=>!t.disabled&&t.kind!=="audio"&&y(t))&&d.parentId&&(n.push("camera on a parent"),i.push("camera on a parent")),x(m)&&(n.push("look"),i.push("look"));for(const t of e||[]){if(t.disabled)continue;if(t._group&&t.comp){const s=h(j(t),{format:a});s.reasons.length&&(n.push(`${t.label||t.id} (comp): ${s.reasons.join("; ")}`),i.push(...s.codes))}const o=V(t,{camera:d,W:l,H:g});o.length&&(n.push(`${t.label||t.id}: ${o.join(", ")}`),i.push(...o))}if(!n.length)for(const t of w((e||[]).filter(o=>!o.disabled))){const o=s=>{n.push(`${t.label||t.id}: ${s}`),i.push(s)};t.timeRemap&&(t._txIn||t._txOut)&&!t._ramp&&o("time remap in a transition"),t.motionBlur&&(t._txIn||t._txOut)&&o("motion blur in a transition")}return{reasons:n,codes:i}}const q=(e,a,r)=>(a==="video encode"||a==="finalize")&&r?.codec!=="hevc"&&e?.name!=="AbortError"&&/^(OperationError|EncodingError)$/.test(e?.name||""),Q=e=>!(typeof DOMException<"u"&&e instanceof DOMException)&&!(e instanceof TypeError)&&!(e instanceof Error&&/^media \d{3}$/.test(e.message))?"":(e.message||"").replace(/\b(?:https?|blob|data):\S*/gi,"").replace(/\s+/g," ").trim();export{X as HEAVY_FIELDS,C as clientExportCheck,G as clientExportCodes,V as clipBlockers,Q as gpuErrorText,q as softwareRetry};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-CwrkBJ63.js","assets/titleFrameBudget-DsM0V482.js","assets/remote-8XzEAnAJ.js","assets/index-CKtv7gGE.js","assets/i18n-C9zFX25m.js","assets/api-Dnl2uaKO.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-CpqHUcA2.js","assets/rotoMaskStore-pE1AIt3I.js","assets/sceneTrack-DlAH5s74.js","assets/timelineOps-DSSaDsU2.js","assets/cameraTracker-DHdF8Zqx.js","assets/textAnimators-B9vO_hbP.js","assets/timelineComp-i-zdaoB2.js","assets/rigTrack-DMyqb0pb.js","assets/clientJobs-CuuUyhEy.js","assets/spark.module-DjaIF6J1.js","assets/userFonts-Djka6RJX.js","assets/lottieLayer-Cv8ub9f6.js","assets/timeline3d-DrFaMPPB.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/glTransitionSources.generated-q0H-ZbnZ.js","assets/captionLayout-cckQ7p-t.js","assets/timelineText-DurRhyuh.js","assets/titleArt-CnC0A7x7.js","assets/personHq-Ca351o06.js","assets/matteQuality-9X-jgJrH.js","assets/sceneTrack-CA21MCOP.js","assets/rotoMatte-7b7Ow64f.js","assets/objectSegmenter-D66spD7o.js","assets/cutoutClean-CLYYAuXg.js","assets/distortGL-vhnBRB59.js","assets/motionBlur-uAm030t9.js","assets/main-B_MAOvi6.css","assets/poseTracker-CzEKvJph.js","assets/rotoscope-BUqNTKLd.js","assets/maskTrack-D4QZfMWc.js","assets/auraTrack-C8eAEIWQ.js","assets/mapBake-DtQboFIX.js","assets/gpuCompose-B5bgbHdQ.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/handTracker-c6_rvuwA.js","assets/handMatte-Dj2taFoC.js","assets/matteFixRun-CytaeRzS.js","assets/depthEstimate-Cav4MmQ1.js","assets/faceTracker-ClR-lS6Y.js","assets/analyzerRun-Cr-_79RH.js","assets/analyzerSandbox-N92T6amg.js","assets/pluginAutomation-DAPHWZPN.js"])))=>i.map(i=>d[i]);
2
- import{_ as c}from"./titleFrameBudget-DsM0V482.js";import{r as m}from"./index-CKtv7gGE.js";import{u as d}from"./store-CpqHUcA2.js";import{t as l}from"./i18n-C9zFX25m.js";import{al as I}from"./api-Dnl2uaKO.js";import{listClientJobs as w,claimable as E,KINDS as b,markClientJob as P}from"./clientJobs-CuuUyhEy.js";const f=t=>document.querySelector(`video[data-clip-media="${CSS.escape(t.id)}"]`)?.currentSrc||t.url,p={cutout:async(t,a)=>{const{cutoutImage:r}=await c(async()=>{const{cutoutImage:e}=await import("./main-CwrkBJ63.js").then(o=>o.ah);return{cutoutImage:e}},__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,24,25,26,27,28,29,30,31,32,33,34])),n=a.params?.mode==="person"?"person":"object";return{mask:await r({clip:t,url:t.url,mode:n,pts:n==="object"?[{x:.5,y:.55}]:[]})}},"pose-track":async(t,a)=>{const{runPoseTrack:r}=await c(async()=>{const{runPoseTrack:n}=await import("./poseTracker-CzEKvJph.js");return{runPoseTrack:n}},__vite__mapDeps([35,1,8,3,4,26,27,5,15]));return r(t,a)},rotoscope:async(t,a)=>{const{runRotoscope:r}=await c(async()=>{const{runRotoscope:n}=await import("./rotoscope-BUqNTKLd.js");return{runRotoscope:n}},__vite__mapDeps([36,4,3,5,1,11,10,12,13,14,8,15,16]));return r(t,a)},"mask-track":async(t,a)=>{const{runMaskTrack:r}=await c(async()=>{const{runMaskTrack:n}=await import("./maskTrack-D4QZfMWc.js");return{runMaskTrack:n}},__vite__mapDeps([37,1,11,10,12,13,14,5,4,3,8,15,16,28]));return r(t,a)},"aura-pose":async(t,a)=>{const{runAuraTrack:r}=await c(async()=>{const{runAuraTrack:n}=await import("./auraTrack-C8eAEIWQ.js");return{runAuraTrack:n}},__vite__mapDeps([38,35,1,8,3,4,26,27,5,15,11,10,12,13,14,16]));return r(t,a)},"map-bake":async t=>{const{bakeMap:a}=await c(async()=>{const{bakeMap:r}=await import("./mapBake-DtQboFIX.js");return{bakeMap:r}},__vite__mapDeps([39,19,1,15,4,3,5,40,41,42]));return a(t,d.getState().timelineFormat)},"hand-track":async(t,a)=>{const{runHandTrack:r}=await c(async()=>{const{runHandTrack:n}=await import("./handTracker-c6_rvuwA.js");return{runHandTrack:n}},__vite__mapDeps([43,1,8,3,4,26,27,5,11,10,12,13,14,15,16,44]));return r(t,a)},"matte-fix":async(t,a)=>{const{runMatteFixJob:r}=await c(async()=>{const{runMatteFixJob:n}=await import("./matteFixRun-CytaeRzS.js");return{runMatteFixJob:n}},__vite__mapDeps([45,8,1,3,4,26,27,5,11,10,12,13,14,15,16,44,0,2,6,7,9,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34]));return r(t,a)},"camera-track":async(t,a)=>{const{runCameraTrackJob:r}=await c(async()=>{const{runCameraTrackJob:n}=await import("./main-CwrkBJ63.js").then(e=>e.ai);return{runCameraTrackJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"camera-place":async(t,a)=>{const{runCameraPlaceJob:r}=await c(async()=>{const{runCameraPlaceJob:n}=await import("./main-CwrkBJ63.js").then(e=>e.ai);return{runCameraPlaceJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"object-track":async(t,a)=>{const{runObjectTrackJob:r}=await c(async()=>{const{runObjectTrackJob:n}=await import("./main-CwrkBJ63.js").then(e=>e.aj);return{runObjectTrackJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"object-place":async(t,a)=>{const{runObjectPlaceJob:r}=await c(async()=>{const{runObjectPlaceJob:n}=await import("./main-CwrkBJ63.js").then(e=>e.aj);return{runObjectPlaceJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"depth-map":async t=>{const[{estimateDepth:a},{upgradeDepthWindows:r},{secondariesOf:n,withSecondaries:e}]=await Promise.all([c(()=>import("./depthEstimate-Cav4MmQ1.js"),__vite__mapDeps([46,1,4,3])),c(()=>import("./timelineOps-DSSaDsU2.js").then(u=>u.d6),__vite__mapDeps([11,1,10,12,13,14,5,4,3,8,15,16])),c(()=>import("./titleFrameBudget-DsM0V482.js").then(u=>u.nL),[])]),o=await a(t,t.duration/2),i=r(n(t.grade));return{depthMap:o,...i.upgraded&&t.grade?{grade:e(t.grade,i.list)}:{}}},"face-3d":async t=>{const{trackFace3D:a}=await c(async()=>{const{trackFace3D:n}=await import("./faceTracker-ClR-lS6Y.js");return{trackFace3D:n}},__vite__mapDeps([47,1,26,27,5,4,3])),r=await a({clip:t,url:f(t)});return{face:t.face?.fix?{...r,fix:t.face.fix}:r}},"color-face":async t=>{if(t.face)return{};const{trackFace:a}=await c(async()=>{const{trackFace:r}=await import("./faceTracker-ClR-lS6Y.js");return{trackFace:r}},__vite__mapDeps([47,1,26,27,5,4,3]));return{face:await a({clip:t,url:f(t)})}},"color-person":async t=>{if(t.colorPerson)return{};if(t.person&&!t.person.src)return{colorPerson:t.person};const{segmentPerson:a}=await c(async()=>{const{segmentPerson:r}=await import("./personHq-Ca351o06.js").then(n=>n.i);return{segmentPerson:r}},__vite__mapDeps([26,1,27,5,4,3]));return{colorPerson:await a({clip:t,url:f(t)})}},"plugin-analyze":async(t,a)=>{const{runAnalyzerJob:r}=await c(async()=>{const{runAnalyzerJob:n}=await import("./analyzerRun-Cr-_79RH.js");return{runAnalyzerJob:n}},__vite__mapDeps([48,8,1,3,4,11,10,12,13,14,5,15,16,0,2,6,7,9,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,49,50]));return r(t,a)}},T=Math.random().toString(36).slice(2,10),_=(t,a,r,n={},e)=>d.setState(o=>({clips:o.clips.map(i=>i.id!==t||!i.clientJobs?.some(u=>u.id===a)?i:{...P(i,a,{state:r,...e?{error:e}:{},by:T}),...n})}));async function R({only:t}={}){const a=[],r=new Set;for(;;){const n=d.getState().clips,e=w(n).find(i=>!r.has(i.id)&&p[i.kind]&&E(i)&&(!t?.length||t.includes(i.kind)));if(!e)break;r.add(e.id);const o=n.find(i=>i.id===e.clipId);if(o){_(e.clipId,e.id,"running");try{const i=await p[e.kind](o,e);_(e.clipId,e.id,"done",i),a.push({id:e.id,kind:e.kind,clipId:e.clipId,ok:!0})}catch(i){const u=String(i?.message||i||"failed").slice(0,200);_(e.clipId,e.id,"failed",{},u),a.push({id:e.id,kind:e.kind,clipId:e.clipId,ok:!1,error:u})}}}return a}function L(){const t=d(o=>o.clips),a=d(o=>o.toast),r=m.useRef(!1),[n,e]=m.useState(0);m.useEffect(()=>{if(r.current)return;const o=w(t).find(s=>p[s.kind]&&E(s));if(!o)return;const i=t.find(s=>s.id===o.clipId);if(!i)return;r.current=!0;const u=d.getState().canvasId;_(o.clipId,o.id,"running");const k=l(b[o.kind]?.vi??o.kind),y=()=>d.getState().canvasId===u&&d.getState().clips.find(s=>s.id===o.clipId)?.clientJobs?.some(s=>s.id===o.id&&s.createdAt===o.createdAt&&s.state==="running");p[o.kind](i,o).then(s=>{y()&&(_(o.clipId,o.id,"done",s),a(l("Đã xong trên máy: {0}",[k]),"ok"))},s=>{I("client-job",s?.message||"failed",{jobKind:o.kind,op:o.op,duration:i.duration,sourceDuration:i.sourceDuration}),y()&&(_(o.clipId,o.id,"failed",{},s?.message||"failed"),a(l("Chưa xong trên máy: {0} — {1}",[k,s?.message||""]),"error"))}).finally(()=>{r.current=!1,e(s=>s+1)})},[t,n,a])}export{p as CLIENT_JOB_RUNNERS,R as runPendingClientJobs,L as useClientJobs};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-DAk1Tv1E.js","assets/titleFrameBudget-BW-N1-cw.js","assets/remote-kxNNhmis.js","assets/index-CKtv7gGE.js","assets/i18n-C9zFX25m.js","assets/api-DJC95K48.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-xR02oY0m.js","assets/rotoMaskStore-RmW40Pcn.js","assets/sceneTrack-DyVxpl7i.js","assets/timelineOps-CEGk2t4h.js","assets/cameraTracker-DFjnZ7tw.js","assets/textAnimators-CeMuG34D.js","assets/timelineComp-D8PHGHgQ.js","assets/rigTrack-B9r9wrdV.js","assets/clientJobs-CuuUyhEy.js","assets/spark.module-B341moK0.js","assets/userFonts-DSkZHfmh.js","assets/lottieLayer-Dp_vGTy8.js","assets/timeline3d-D0Ws4lcp.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/glTransitionSources.generated-BJuEUz3E.js","assets/captionLayout-CAuhUiW9.js","assets/timelineText-DjPW2-dd.js","assets/titleArt-BSu80bfN.js","assets/personHq-Cyq9HWnW.js","assets/matteQuality-9X-jgJrH.js","assets/sceneTrack-BKknn180.js","assets/rotoMatte-DisQplSv.js","assets/objectSegmenter-oGv8YQbI.js","assets/cutoutClean-CLYYAuXg.js","assets/distortGL-waTJhiOf.js","assets/motionBlur-uAm030t9.js","assets/main-B_MAOvi6.css","assets/poseTracker-b1h08oRY.js","assets/rotoscope-Z8bn-jRs.js","assets/maskTrack-CADMBJDf.js","assets/auraTrack-C9diszRB.js","assets/mapBake-CEmw-e9Y.js","assets/gpuCompose-Fi0sIUI9.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/handTracker-CF1hqh09.js","assets/handMatte-CvFkZKTL.js","assets/matteFixRun-BHD3Qnta.js","assets/depthEstimate-HrGq0Ffx.js","assets/faceTracker-DsmLlUZ1.js","assets/analyzerRun-BswbLsRF.js","assets/analyzerSandbox-C2rd6s8U.js","assets/pluginAutomation-D73Az7HS.js"])))=>i.map(i=>d[i]);
2
+ import{_ as c}from"./titleFrameBudget-BW-N1-cw.js";import{r as m}from"./index-CKtv7gGE.js";import{u as d}from"./store-xR02oY0m.js";import{t as l}from"./i18n-C9zFX25m.js";import{al as I}from"./api-DJC95K48.js";import{listClientJobs as w,claimable as E,KINDS as b,markClientJob as P}from"./clientJobs-CuuUyhEy.js";const f=t=>document.querySelector(`video[data-clip-media="${CSS.escape(t.id)}"]`)?.currentSrc||t.url,p={cutout:async(t,a)=>{const{cutoutImage:r}=await c(async()=>{const{cutoutImage:e}=await import("./main-DAk1Tv1E.js").then(o=>o.ah);return{cutoutImage:e}},__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,24,25,26,27,28,29,30,31,32,33,34])),n=a.params?.mode==="person"?"person":"object";return{mask:await r({clip:t,url:t.url,mode:n,pts:n==="object"?[{x:.5,y:.55}]:[]})}},"pose-track":async(t,a)=>{const{runPoseTrack:r}=await c(async()=>{const{runPoseTrack:n}=await import("./poseTracker-b1h08oRY.js");return{runPoseTrack:n}},__vite__mapDeps([35,1,8,3,4,26,27,5,15]));return r(t,a)},rotoscope:async(t,a)=>{const{runRotoscope:r}=await c(async()=>{const{runRotoscope:n}=await import("./rotoscope-Z8bn-jRs.js");return{runRotoscope:n}},__vite__mapDeps([36,4,3,5,1,11,10,12,13,14,8,15,16]));return r(t,a)},"mask-track":async(t,a)=>{const{runMaskTrack:r}=await c(async()=>{const{runMaskTrack:n}=await import("./maskTrack-CADMBJDf.js");return{runMaskTrack:n}},__vite__mapDeps([37,1,11,10,12,13,14,5,4,3,8,15,16,28]));return r(t,a)},"aura-pose":async(t,a)=>{const{runAuraTrack:r}=await c(async()=>{const{runAuraTrack:n}=await import("./auraTrack-C9diszRB.js");return{runAuraTrack:n}},__vite__mapDeps([38,35,1,8,3,4,26,27,5,15,11,10,12,13,14,16]));return r(t,a)},"map-bake":async t=>{const{bakeMap:a}=await c(async()=>{const{bakeMap:r}=await import("./mapBake-CEmw-e9Y.js");return{bakeMap:r}},__vite__mapDeps([39,19,1,15,4,3,5,40,41,42]));return a(t,d.getState().timelineFormat)},"hand-track":async(t,a)=>{const{runHandTrack:r}=await c(async()=>{const{runHandTrack:n}=await import("./handTracker-CF1hqh09.js");return{runHandTrack:n}},__vite__mapDeps([43,1,8,3,4,26,27,5,11,10,12,13,14,15,16,44]));return r(t,a)},"matte-fix":async(t,a)=>{const{runMatteFixJob:r}=await c(async()=>{const{runMatteFixJob:n}=await import("./matteFixRun-BHD3Qnta.js");return{runMatteFixJob:n}},__vite__mapDeps([45,8,1,3,4,26,27,5,11,10,12,13,14,15,16,44,0,2,6,7,9,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34]));return r(t,a)},"camera-track":async(t,a)=>{const{runCameraTrackJob:r}=await c(async()=>{const{runCameraTrackJob:n}=await import("./main-DAk1Tv1E.js").then(e=>e.ai);return{runCameraTrackJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"camera-place":async(t,a)=>{const{runCameraPlaceJob:r}=await c(async()=>{const{runCameraPlaceJob:n}=await import("./main-DAk1Tv1E.js").then(e=>e.ai);return{runCameraPlaceJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"object-track":async(t,a)=>{const{runObjectTrackJob:r}=await c(async()=>{const{runObjectTrackJob:n}=await import("./main-DAk1Tv1E.js").then(e=>e.aj);return{runObjectTrackJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"object-place":async(t,a)=>{const{runObjectPlaceJob:r}=await c(async()=>{const{runObjectPlaceJob:n}=await import("./main-DAk1Tv1E.js").then(e=>e.aj);return{runObjectPlaceJob:n}},__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,24,25,26,27,28,29,30,31,32,33,34]));return r(t,a)},"depth-map":async t=>{const[{estimateDepth:a},{upgradeDepthWindows:r},{secondariesOf:n,withSecondaries:e}]=await Promise.all([c(()=>import("./depthEstimate-HrGq0Ffx.js"),__vite__mapDeps([46,1,4,3])),c(()=>import("./timelineOps-CEGk2t4h.js").then(u=>u.d8),__vite__mapDeps([11,1,10,12,13,14,5,4,3,8,15,16])),c(()=>import("./titleFrameBudget-BW-N1-cw.js").then(u=>u.nL),[])]),o=await a(t,t.duration/2),i=r(n(t.grade));return{depthMap:o,...i.upgraded&&t.grade?{grade:e(t.grade,i.list)}:{}}},"face-3d":async t=>{const{trackFace3D:a}=await c(async()=>{const{trackFace3D:n}=await import("./faceTracker-DsmLlUZ1.js");return{trackFace3D:n}},__vite__mapDeps([47,1,26,27,5,4,3])),r=await a({clip:t,url:f(t)});return{face:t.face?.fix?{...r,fix:t.face.fix}:r}},"color-face":async t=>{if(t.face)return{};const{trackFace:a}=await c(async()=>{const{trackFace:r}=await import("./faceTracker-DsmLlUZ1.js");return{trackFace:r}},__vite__mapDeps([47,1,26,27,5,4,3]));return{face:await a({clip:t,url:f(t)})}},"color-person":async t=>{if(t.colorPerson)return{};if(t.person&&!t.person.src)return{colorPerson:t.person};const{segmentPerson:a}=await c(async()=>{const{segmentPerson:r}=await import("./personHq-Cyq9HWnW.js").then(n=>n.i);return{segmentPerson:r}},__vite__mapDeps([26,1,27,5,4,3]));return{colorPerson:await a({clip:t,url:f(t)})}},"plugin-analyze":async(t,a)=>{const{runAnalyzerJob:r}=await c(async()=>{const{runAnalyzerJob:n}=await import("./analyzerRun-BswbLsRF.js");return{runAnalyzerJob:n}},__vite__mapDeps([48,8,1,3,4,11,10,12,13,14,5,15,16,0,2,6,7,9,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,49,50]));return r(t,a)}},T=Math.random().toString(36).slice(2,10),_=(t,a,r,n={},e)=>d.setState(o=>({clips:o.clips.map(i=>i.id!==t||!i.clientJobs?.some(u=>u.id===a)?i:{...P(i,a,{state:r,...e?{error:e}:{},by:T}),...n})}));async function R({only:t}={}){const a=[],r=new Set;for(;;){const n=d.getState().clips,e=w(n).find(i=>!r.has(i.id)&&p[i.kind]&&E(i)&&(!t?.length||t.includes(i.kind)));if(!e)break;r.add(e.id);const o=n.find(i=>i.id===e.clipId);if(o){_(e.clipId,e.id,"running");try{const i=await p[e.kind](o,e);_(e.clipId,e.id,"done",i),a.push({id:e.id,kind:e.kind,clipId:e.clipId,ok:!0})}catch(i){const u=String(i?.message||i||"failed").slice(0,200);_(e.clipId,e.id,"failed",{},u),a.push({id:e.id,kind:e.kind,clipId:e.clipId,ok:!1,error:u})}}}return a}function L(){const t=d(o=>o.clips),a=d(o=>o.toast),r=m.useRef(!1),[n,e]=m.useState(0);m.useEffect(()=>{if(r.current)return;const o=w(t).find(s=>p[s.kind]&&E(s));if(!o)return;const i=t.find(s=>s.id===o.clipId);if(!i)return;r.current=!0;const u=d.getState().canvasId;_(o.clipId,o.id,"running");const k=l(b[o.kind]?.vi??o.kind),y=()=>d.getState().canvasId===u&&d.getState().clips.find(s=>s.id===o.clipId)?.clientJobs?.some(s=>s.id===o.id&&s.createdAt===o.createdAt&&s.state==="running");p[o.kind](i,o).then(s=>{y()&&(_(o.clipId,o.id,"done",s),a(l("Đã xong trên máy: {0}",[k]),"ok"))},s=>{I("client-job",s?.message||"failed",{jobKind:o.kind,op:o.op,duration:i.duration,sourceDuration:i.sourceDuration}),y()&&(_(o.clipId,o.id,"failed",{},s?.message||"failed"),a(l("Chưa xong trên máy: {0} — {1}",[k,s?.message||""]),"error"))}).finally(()=>{r.current=!1,e(s=>s+1)})},[t,n,a])}export{p as CLIENT_JOB_RUNNERS,R as runPendingClientJobs,L as useClientJobs};
@@ -1 +1 @@
1
- import{nC as I,nD as y,nE as F,_ as N}from"./titleFrameBudget-DsM0V482.js";import{t as g}from"./i18n-C9zFX25m.js";import"./index-CKtv7gGE.js";const B="1.31.1",H=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${B}/dist/`,l={url:"https://huggingface.co/onnx-community/depth-anything-v2-small/resolve/4472b7362082ad9968fee890ca0f1e5aca36b93d/onnx/model_quantized.onnx",sha256:"fcf51f1b230362b28690bb9d1809bf0431f29cad20534e3f589bd7285547f20d",bytes:27258801,cache:"clipoox-depth-1"},K=[.485,.456,.406],L=[.229,.224,.225],x=378;let f=null;const U=o=>[...new Uint8Array(o)].map(i=>i.toString(16).padStart(2,"0")).join("");async function W(o){const i=await caches.open(l.cache).catch(()=>null),r=await i?.match(l.url);if(r){const c=new Uint8Array(await r.arrayBuffer());if(c.length===l.bytes)return c}const h=await fetch(l.url);if(!h.ok||!h.body)throw Error(g("Không tải được mô hình độ sâu (HTTP {0})",[h.status]));const t=h.body.getReader(),n=[];let a=0;for(;;){const{done:c,value:p}=await t.read();if(c)break;n.push(p),a+=p.length,o?.(Math.min(1,a/l.bytes))}const s=new Uint8Array(a);let m=0;for(const c of n)s.set(c,m),m+=c.length;if(U(await crypto.subtle.digest("SHA-256",s))!==l.sha256)throw Error(g("Mô hình độ sâu tải về bị lỗi (mã kiểm tra không khớp) — thử lại."));return await i?.put(l.url,new Response(s,{headers:{"content-type":"application/octet-stream"}})).catch(()=>{}),s}function z(o){return f||(f=(async()=>{const i=await N(()=>import(`${H}ort.wasm.min.mjs`),[]);i.env.wasm.wasmPaths=H,i.env.wasm.numThreads=1;const r=await i.InferenceSession.create(await W(o),{executionProviders:["wasm"],graphOptimizationLevel:"all"});return Object.assign(r,{ort:i})})(),f.catch(()=>{f=null})),f}async function V(o,i){const r=document.createElement("canvas"),h=r.getContext("2d",{willReadFrequently:!0});if(o.kind==="image"){const n=new Image;return n.crossOrigin="anonymous",n.src=o.url,await new Promise((a,s)=>{n.onload=()=>a(),n.onerror=()=>s(Error(g("Không đọc được ảnh của clip")))}),r.width=n.naturalWidth,r.height=n.naturalHeight,h.drawImage(n,0,0),r}const t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=o.url;try{await new Promise((a,s)=>{t.onloadeddata=()=>a(),t.onerror=()=>s(Error(g("Không đọc được video của clip (CORS / định dạng)")))});const n=Math.max(0,Math.min(t.duration-1/60,(o.inPoint||0)+i*(o.playbackRate||1)));return await new Promise((a,s)=>{const m=window.setTimeout(()=>s(Error(g("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(m),a()},t.currentTime=n}),r.width=t.videoWidth||1280,r.height=t.videoHeight||720,h.drawImage(t,0,0),r}finally{t.removeAttribute("src"),t.load()}}async function X(o,i,r){const h=Math.max(0,Math.min(o.duration,i));if(window.__depthStub){const e=window.__depthStub(o,h);return I(e.data,e.w,e.h,h)}const[t,n]=await Promise.all([z(e=>r?.("download",e)),V(o,h)]);r?.("run");const a=n.width/Math.max(1,n.height),s=e=>Math.max(14,Math.round(e/14)*14),m=a>=1?s(x*a):x,c=a>=1?x:s(x/a),p=Object.assign(document.createElement("canvas"),{width:m,height:c}),b=p.getContext("2d",{willReadFrequently:!0});b.imageSmoothingQuality="high",b.drawImage(n,0,0,m,c);const j=b.getImageData(0,0,m,c).data,M=m*c,O=new Float32Array(3*M);for(let e=0;e<M;e++)for(let d=0;d<3;d++)O[d*M+e]=(j[e*4+d]/255-K[d])/L[d];const v=(await t.run({[t.inputNames[0]]:new t.ort.Tensor("float32",O,[1,3,c,m])}))[t.outputNames[0]],T=v.dims.at(-2),S=v.dims.at(-1),u=a>=1?y.maxSide:Math.max(2,Math.round(y.maxSide*a)),w=a>=1?Math.max(2,Math.round(y.maxSide/a)):y.maxSide,P=new Float32Array(u*w);for(let e=0;e<w;e++)for(let d=0;d<u;d++){const k=Math.floor(d*S/u),q=Math.max(k+1,Math.floor((d+1)*S/u)),A=Math.floor(e*T/w),C=Math.max(A+1,Math.floor((e+1)*T/w));let R=0,D=0;for(let E=A;E<C;E++)for(let _=k;_<q;_++)R+=v.data[E*S+_],D++;P[e*u+d]=R/Math.max(1,D)}return I(F(P),u,w,h)}export{l as DEPTH_MODEL,X as estimateDepth};
1
+ import{nC as I,nD as y,nE as F,_ as N}from"./titleFrameBudget-BW-N1-cw.js";import{t as g}from"./i18n-C9zFX25m.js";import"./index-CKtv7gGE.js";const B="1.31.1",H=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${B}/dist/`,l={url:"https://huggingface.co/onnx-community/depth-anything-v2-small/resolve/4472b7362082ad9968fee890ca0f1e5aca36b93d/onnx/model_quantized.onnx",sha256:"fcf51f1b230362b28690bb9d1809bf0431f29cad20534e3f589bd7285547f20d",bytes:27258801,cache:"clipoox-depth-1"},K=[.485,.456,.406],L=[.229,.224,.225],x=378;let f=null;const U=o=>[...new Uint8Array(o)].map(i=>i.toString(16).padStart(2,"0")).join("");async function W(o){const i=await caches.open(l.cache).catch(()=>null),r=await i?.match(l.url);if(r){const c=new Uint8Array(await r.arrayBuffer());if(c.length===l.bytes)return c}const h=await fetch(l.url);if(!h.ok||!h.body)throw Error(g("Không tải được mô hình độ sâu (HTTP {0})",[h.status]));const t=h.body.getReader(),n=[];let a=0;for(;;){const{done:c,value:p}=await t.read();if(c)break;n.push(p),a+=p.length,o?.(Math.min(1,a/l.bytes))}const s=new Uint8Array(a);let m=0;for(const c of n)s.set(c,m),m+=c.length;if(U(await crypto.subtle.digest("SHA-256",s))!==l.sha256)throw Error(g("Mô hình độ sâu tải về bị lỗi (mã kiểm tra không khớp) — thử lại."));return await i?.put(l.url,new Response(s,{headers:{"content-type":"application/octet-stream"}})).catch(()=>{}),s}function z(o){return f||(f=(async()=>{const i=await N(()=>import(`${H}ort.wasm.min.mjs`),[]);i.env.wasm.wasmPaths=H,i.env.wasm.numThreads=1;const r=await i.InferenceSession.create(await W(o),{executionProviders:["wasm"],graphOptimizationLevel:"all"});return Object.assign(r,{ort:i})})(),f.catch(()=>{f=null})),f}async function V(o,i){const r=document.createElement("canvas"),h=r.getContext("2d",{willReadFrequently:!0});if(o.kind==="image"){const n=new Image;return n.crossOrigin="anonymous",n.src=o.url,await new Promise((a,s)=>{n.onload=()=>a(),n.onerror=()=>s(Error(g("Không đọc được ảnh của clip")))}),r.width=n.naturalWidth,r.height=n.naturalHeight,h.drawImage(n,0,0),r}const t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=o.url;try{await new Promise((a,s)=>{t.onloadeddata=()=>a(),t.onerror=()=>s(Error(g("Không đọc được video của clip (CORS / định dạng)")))});const n=Math.max(0,Math.min(t.duration-1/60,(o.inPoint||0)+i*(o.playbackRate||1)));return await new Promise((a,s)=>{const m=window.setTimeout(()=>s(Error(g("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(m),a()},t.currentTime=n}),r.width=t.videoWidth||1280,r.height=t.videoHeight||720,h.drawImage(t,0,0),r}finally{t.removeAttribute("src"),t.load()}}async function X(o,i,r){const h=Math.max(0,Math.min(o.duration,i));if(window.__depthStub){const e=window.__depthStub(o,h);return I(e.data,e.w,e.h,h)}const[t,n]=await Promise.all([z(e=>r?.("download",e)),V(o,h)]);r?.("run");const a=n.width/Math.max(1,n.height),s=e=>Math.max(14,Math.round(e/14)*14),m=a>=1?s(x*a):x,c=a>=1?x:s(x/a),p=Object.assign(document.createElement("canvas"),{width:m,height:c}),b=p.getContext("2d",{willReadFrequently:!0});b.imageSmoothingQuality="high",b.drawImage(n,0,0,m,c);const j=b.getImageData(0,0,m,c).data,M=m*c,O=new Float32Array(3*M);for(let e=0;e<M;e++)for(let d=0;d<3;d++)O[d*M+e]=(j[e*4+d]/255-K[d])/L[d];const v=(await t.run({[t.inputNames[0]]:new t.ort.Tensor("float32",O,[1,3,c,m])}))[t.outputNames[0]],T=v.dims.at(-2),S=v.dims.at(-1),u=a>=1?y.maxSide:Math.max(2,Math.round(y.maxSide*a)),w=a>=1?Math.max(2,Math.round(y.maxSide/a)):y.maxSide,P=new Float32Array(u*w);for(let e=0;e<w;e++)for(let d=0;d<u;d++){const k=Math.floor(d*S/u),q=Math.max(k+1,Math.floor((d+1)*S/u)),A=Math.floor(e*T/w),C=Math.max(A+1,Math.floor((e+1)*T/w));let R=0,D=0;for(let E=A;E<C;E++)for(let _=k;_<q;_++)R+=v.data[E*S+_],D++;P[e*u+d]=R/Math.max(1,D)}return I(F(P),u,w,h)}export{l as DEPTH_MODEL,X as estimateDepth};
@@ -1 +1 @@
1
- import{C as P,c as v}from"./cameraPresets-Cfn7qhXK.js";import{de as g,fg as y,bX as k,bY as C,c6 as S,c5 as A,c7 as N,c0 as D,c1 as $,b$ as F,fy as x,bU as j,c8 as I,b_ as R}from"./remote-8XzEAnAJ.js";import{s as U}from"./weaponDuel-DKAEYJjO.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const z=["katana","spear","staff","fist"],M=P.map(t=>t.id),L=()=>crypto.randomUUID(),w=t=>Math.round(t*100)/100,b=(t,a)=>z.includes(t)?t:a,E=(t,a,l)=>({...t,shots:t.shots.map(c=>c.id===a?{...c,...l}:c)}),T=t=>{const a=g(t),l=k(a.timing,a.duration);return{hit_stops:l?.holds.length??0,slow_spans:l?.slows??[],scene_s:a.duration,video_s:w(R(a)),...a.impactFrame?{impact_frame:a.impactFrame}:{}}};function nt(t,a){const l=a.getStage(),c=g(l),n=Array.isArray(t.fighters)?t.fighters.map(String):[];if(n.length!==2)return{ok:!1,error:"give fighters: [first attacker, opponent] (two person names)"};let r;try{r=n.map(e=>y(l,e))}catch(e){return{ok:!1,error:e.message}}for(const e of r)if(!j(e))return{ok:!1,error:`'${e.name}' is not a person (or a humanoid-rigged model)`};const p=Array.isArray(t.weapons)?t.weapons:[t.weapons??t.weapon,t.weapons??t.weapon],f=[b(p[0],"katana"),b(p[1]??p[0],b(p[0],"katana"))],h=Math.max(0,Math.min(c.duration,Number(t.start??0)||0)),i=U(l,{a:r[0].id,b:r[1].id,packs:f,exchanges:Number(t.exchanges??4)||4,seed:Number(t.seed)||1,start:h,hitStops:t.hit_stops!==!1},L);if(!i.ok)return{ok:!1,error:i.error};let o=i.stage;const m=Math.min(g(o).duration,i.end+.4),u=String(t.camera??"fight");let s={kept:"your own camera"};if(u==="fight")try{const e=I(o,{fighters:r.map(_=>_.name),start:h,end:m,focal_length_mm:Number(t.focal_length_mm)||32});o=e.stage,s={fight_camera:e.result}}catch(e){s={error:e.message}}else if(u!=="none"){const e=v(o,{preset:u,subject:r[0].id,start:h,end:m});e.ok?(o=e.stage,s={preset:e.preset,subject:e.subject,keys:e.keys,cuts:e.cuts}):s={error:e.error}}if(t.impact_frame&&t.impact_frame!=="none"){const e=F({style:t.impact_frame,strength:t.impact_strength??.8});e&&(o=E(o,g(o).id,{impactFrame:e}))}return a.setStage(()=>o),{ok:!0,fighters:r.map(e=>e.name),weapons:f,start:h,end:i.end,shot_duration_s:g(o).duration,exchange:i.plan.map(e=>({time_s:e.time,attacker:e.attackerName,attack:e.attack,defence:e.defence,result:e.result})),camera:s,timing:T(o),...i.notes.length?{notes:i.notes}:{},hint:"weapons are put in the hands with a trail (set_trail to restyle); re-run with another seed for another plan; add impact effects at the strike times of blocked / body results (none on a miss = a dodge) and set_timing for slow motion on the finisher"}}function it(t,a){const l=a.getStage(),c=g(l);if(!M.includes(String(t.preset)))return{ok:!1,error:`unknown preset; use one of ${M.join(", ")}`};let n;try{n=y(l,String(t.subject??""))}catch(h){return{ok:!1,error:h.message}}const r=Math.max(0,Number(t.start??0)||0),p=t.end==null?c.duration:Number(t.end),f=v(l,{preset:String(t.preset),subject:n.id,start:r,end:p});return f.ok?(a.setStage(()=>f.stage),{ok:!0,preset:f.preset,subject:n.name,start:w(f.start),end:w(f.end),camera_keys:f.keys,hit_beats:f.beats,cuts:f.cuts,note:"camera keys inside the span are replaced; the preset tracks the subject's motion, so bake it AFTER the motion is final"}):{ok:!1,error:f.error}}function at(t,a){const l=a.getStage(),c=g(l),n=c.duration;let r=k(c.timing,n);const p=C(l).map(s=>s.time).filter(s=>s>.05&&s<n-.05),f=S[t.strength]??S.medium,h=String(t.hit_stops??"keep");if(h==="none"&&(r=k({holds:[],slows:r?.slows??[]},n)),h==="auto"){if(!p.length)return{ok:!1,error:"no strike in the shot to stop on (stage_fight / stage_duel / play_motion strikes first, or give hit_stops_at)"};r=A(r,p,f,n)}if(Array.isArray(t.hit_stops_at)&&(r=A(r,t.hit_stops_at.map(Number).filter(s=>Number.isFinite(s)&&s>=0&&s<=n),f,n)),t.clear_slow_motion&&(r=k({holds:r?.holds??[],slows:[]},n)),t.slow_finisher){if(!p.length)return{ok:!1,error:"no strike in the shot for slow_finisher"};r=N(r,p[p.length-1],.3,.3,n)}for(const s of Array.isArray(t.slow_motion)?t.slow_motion:[]){const e=Number(s?.at);if(!Number.isFinite(e))return{ok:!1,error:"slow_motion entries need at (scene seconds)"};r=N(r,e,Math.max(.05,Math.min(3,Number(s.half??.35)||.35)),Math.max(.1,Math.min(1,Number(s.speed??.3)||.3)),n)}const i=Number(t._from)||0;if(i>0){const s=k(c.timing,n);r=k({holds:[...(s?.holds??[]).filter(e=>e.at<i),...(r?.holds??[]).filter(e=>e.at>=i)],slows:[...(s?.slows??[]).filter(e=>e.start<i),...(r?.slows??[]).filter(e=>e.start>=i)]},n)}let o={timing:r??void 0},m=null;if(t.preset==="sakuga"){if(m=D({...c,timing:r??void 0},$(l).filter(_=>_.at>.05&&_.at<n-.05),{keepLook:!1}),!m)return{ok:!1,error:"no blow in the shot for preset sakuga (stage_fight / resolve_hits first)"};let s=m.shot.timing??null,e=m.shot.impacts;if(i>0){const _=k(c.timing,n);s=k({holds:[...(_?.holds??[]).filter(d=>d.at<i),...(s?.holds??[]).filter(d=>d.at>=i)],slows:[...(_?.slows??[]).filter(d=>d.start<i),...(s?.slows??[]).filter(d=>d.start>=i)]},n),e=[...(c.impacts??[]).filter(d=>d.time*n<i),...(e??[]).filter(d=>d.time*n>=i)]}o={timing:s??void 0,impacts:e,impactFrame:m.shot.impactFrame}}if(t.impact_frame==="none")o={...o,impactFrame:void 0};else if(t.impact_frame!=null){const s=F({style:t.impact_frame,strength:t.impact_strength??c.impactFrame?.strength??.8});if(!s)return{ok:!1,error:`impact_frame: one of ${x.join(", ")} or none`};o={...o,impactFrame:s}}const u=E(l,c.id,o);return a.setStage(()=>u),{ok:!0,...T(u),strike_beats:p.map(w).slice(0,30),...m?{sakuga:{blows:m.plan.kinds.length,kinds:m.plan.kinds.slice(0,30),finisher_s:m.plan.finisher==null?null:w(m.plan.finisher)}}:{},note:"a render-time warp: preview and export freeze / slow these scene instants; impact frames flash on every hit-stop"}}function mt(t,a){const l=a.getStage(),c=Array.isArray(t.names)?t.names.map(String):t.name!=null?[String(t.name)]:[];if(!c.length)return{ok:!1,error:"give names: weapons, or people (their held weapons)"};const n=new Set;for(const i of c){let o;try{o=y(l,i)}catch(m){return{ok:!1,error:m.message}}if(o.kind==="prop"&&o.hold)n.add(o.id);else if(j(o)){const m=l.items.filter(u=>u.kind==="prop"&&u.hold?.by===o.id);if(!m.length)return{ok:!1,error:`${o.name} holds nothing (hold_prop / play_motion a weapon clip / stage_duel first)`};m.forEach(u=>n.add(u.id))}else return{ok:!1,error:`'${o.name}' is not a held weapon or a person`}}const r=t.on!==!1,p={},f=typeof t.color=="string"&&/^#[0-9a-f]{6}$/i.test(t.color)?t.color:void 0,h=t.length!=null&&Number.isFinite(Number(t.length))?Math.max(.03,Math.min(.5,Number(t.length))):void 0;return a.setStage(i=>({...i,items:i.items.map(o=>{if(!n.has(o.id))return o;if(!r){p[o.name]="off";const{trail:u,...s}=o;return s}const m={...o.trail||{},...t.style==="smear"||t.style==="ribbon"?{style:t.style}:{},...f?{color:f}:{},...h!=null?{length:h}:{}};return p[o.name]=m,{...o,trail:m}})})),{ok:!0,trails:p}}export{M as CAMERA_PRESET_IDS,z as DUEL_PACKS,it as cameraPreset,at as setTiming,mt as setTrail,nt as stageDuel};
1
+ import{C as P,c as v}from"./cameraPresets-DfKERP1j.js";import{de as g,fg as y,bX as k,bY as C,c6 as S,c5 as A,c7 as N,c0 as D,c1 as $,b$ as F,fy as x,bU as j,c8 as I,b_ as R}from"./remote-kxNNhmis.js";import{s as U}from"./weaponDuel-DuuMMfzY.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-DJC95K48.js";import"./titleFrameBudget-BW-N1-cw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";const z=["katana","spear","staff","fist"],M=P.map(t=>t.id),L=()=>crypto.randomUUID(),w=t=>Math.round(t*100)/100,b=(t,a)=>z.includes(t)?t:a,E=(t,a,l)=>({...t,shots:t.shots.map(c=>c.id===a?{...c,...l}:c)}),T=t=>{const a=g(t),l=k(a.timing,a.duration);return{hit_stops:l?.holds.length??0,slow_spans:l?.slows??[],scene_s:a.duration,video_s:w(R(a)),...a.impactFrame?{impact_frame:a.impactFrame}:{}}};function nt(t,a){const l=a.getStage(),c=g(l),n=Array.isArray(t.fighters)?t.fighters.map(String):[];if(n.length!==2)return{ok:!1,error:"give fighters: [first attacker, opponent] (two person names)"};let r;try{r=n.map(e=>y(l,e))}catch(e){return{ok:!1,error:e.message}}for(const e of r)if(!j(e))return{ok:!1,error:`'${e.name}' is not a person (or a humanoid-rigged model)`};const p=Array.isArray(t.weapons)?t.weapons:[t.weapons??t.weapon,t.weapons??t.weapon],f=[b(p[0],"katana"),b(p[1]??p[0],b(p[0],"katana"))],h=Math.max(0,Math.min(c.duration,Number(t.start??0)||0)),i=U(l,{a:r[0].id,b:r[1].id,packs:f,exchanges:Number(t.exchanges??4)||4,seed:Number(t.seed)||1,start:h,hitStops:t.hit_stops!==!1},L);if(!i.ok)return{ok:!1,error:i.error};let o=i.stage;const m=Math.min(g(o).duration,i.end+.4),u=String(t.camera??"fight");let s={kept:"your own camera"};if(u==="fight")try{const e=I(o,{fighters:r.map(_=>_.name),start:h,end:m,focal_length_mm:Number(t.focal_length_mm)||32});o=e.stage,s={fight_camera:e.result}}catch(e){s={error:e.message}}else if(u!=="none"){const e=v(o,{preset:u,subject:r[0].id,start:h,end:m});e.ok?(o=e.stage,s={preset:e.preset,subject:e.subject,keys:e.keys,cuts:e.cuts}):s={error:e.error}}if(t.impact_frame&&t.impact_frame!=="none"){const e=F({style:t.impact_frame,strength:t.impact_strength??.8});e&&(o=E(o,g(o).id,{impactFrame:e}))}return a.setStage(()=>o),{ok:!0,fighters:r.map(e=>e.name),weapons:f,start:h,end:i.end,shot_duration_s:g(o).duration,exchange:i.plan.map(e=>({time_s:e.time,attacker:e.attackerName,attack:e.attack,defence:e.defence,result:e.result})),camera:s,timing:T(o),...i.notes.length?{notes:i.notes}:{},hint:"weapons are put in the hands with a trail (set_trail to restyle); re-run with another seed for another plan; add impact effects at the strike times of blocked / body results (none on a miss = a dodge) and set_timing for slow motion on the finisher"}}function it(t,a){const l=a.getStage(),c=g(l);if(!M.includes(String(t.preset)))return{ok:!1,error:`unknown preset; use one of ${M.join(", ")}`};let n;try{n=y(l,String(t.subject??""))}catch(h){return{ok:!1,error:h.message}}const r=Math.max(0,Number(t.start??0)||0),p=t.end==null?c.duration:Number(t.end),f=v(l,{preset:String(t.preset),subject:n.id,start:r,end:p});return f.ok?(a.setStage(()=>f.stage),{ok:!0,preset:f.preset,subject:n.name,start:w(f.start),end:w(f.end),camera_keys:f.keys,hit_beats:f.beats,cuts:f.cuts,note:"camera keys inside the span are replaced; the preset tracks the subject's motion, so bake it AFTER the motion is final"}):{ok:!1,error:f.error}}function at(t,a){const l=a.getStage(),c=g(l),n=c.duration;let r=k(c.timing,n);const p=C(l).map(s=>s.time).filter(s=>s>.05&&s<n-.05),f=S[t.strength]??S.medium,h=String(t.hit_stops??"keep");if(h==="none"&&(r=k({holds:[],slows:r?.slows??[]},n)),h==="auto"){if(!p.length)return{ok:!1,error:"no strike in the shot to stop on (stage_fight / stage_duel / play_motion strikes first, or give hit_stops_at)"};r=A(r,p,f,n)}if(Array.isArray(t.hit_stops_at)&&(r=A(r,t.hit_stops_at.map(Number).filter(s=>Number.isFinite(s)&&s>=0&&s<=n),f,n)),t.clear_slow_motion&&(r=k({holds:r?.holds??[],slows:[]},n)),t.slow_finisher){if(!p.length)return{ok:!1,error:"no strike in the shot for slow_finisher"};r=N(r,p[p.length-1],.3,.3,n)}for(const s of Array.isArray(t.slow_motion)?t.slow_motion:[]){const e=Number(s?.at);if(!Number.isFinite(e))return{ok:!1,error:"slow_motion entries need at (scene seconds)"};r=N(r,e,Math.max(.05,Math.min(3,Number(s.half??.35)||.35)),Math.max(.1,Math.min(1,Number(s.speed??.3)||.3)),n)}const i=Number(t._from)||0;if(i>0){const s=k(c.timing,n);r=k({holds:[...(s?.holds??[]).filter(e=>e.at<i),...(r?.holds??[]).filter(e=>e.at>=i)],slows:[...(s?.slows??[]).filter(e=>e.start<i),...(r?.slows??[]).filter(e=>e.start>=i)]},n)}let o={timing:r??void 0},m=null;if(t.preset==="sakuga"){if(m=D({...c,timing:r??void 0},$(l).filter(_=>_.at>.05&&_.at<n-.05),{keepLook:!1}),!m)return{ok:!1,error:"no blow in the shot for preset sakuga (stage_fight / resolve_hits first)"};let s=m.shot.timing??null,e=m.shot.impacts;if(i>0){const _=k(c.timing,n);s=k({holds:[...(_?.holds??[]).filter(d=>d.at<i),...(s?.holds??[]).filter(d=>d.at>=i)],slows:[...(_?.slows??[]).filter(d=>d.start<i),...(s?.slows??[]).filter(d=>d.start>=i)]},n),e=[...(c.impacts??[]).filter(d=>d.time*n<i),...(e??[]).filter(d=>d.time*n>=i)]}o={timing:s??void 0,impacts:e,impactFrame:m.shot.impactFrame}}if(t.impact_frame==="none")o={...o,impactFrame:void 0};else if(t.impact_frame!=null){const s=F({style:t.impact_frame,strength:t.impact_strength??c.impactFrame?.strength??.8});if(!s)return{ok:!1,error:`impact_frame: one of ${x.join(", ")} or none`};o={...o,impactFrame:s}}const u=E(l,c.id,o);return a.setStage(()=>u),{ok:!0,...T(u),strike_beats:p.map(w).slice(0,30),...m?{sakuga:{blows:m.plan.kinds.length,kinds:m.plan.kinds.slice(0,30),finisher_s:m.plan.finisher==null?null:w(m.plan.finisher)}}:{},note:"a render-time warp: preview and export freeze / slow these scene instants; impact frames flash on every hit-stop"}}function mt(t,a){const l=a.getStage(),c=Array.isArray(t.names)?t.names.map(String):t.name!=null?[String(t.name)]:[];if(!c.length)return{ok:!1,error:"give names: weapons, or people (their held weapons)"};const n=new Set;for(const i of c){let o;try{o=y(l,i)}catch(m){return{ok:!1,error:m.message}}if(o.kind==="prop"&&o.hold)n.add(o.id);else if(j(o)){const m=l.items.filter(u=>u.kind==="prop"&&u.hold?.by===o.id);if(!m.length)return{ok:!1,error:`${o.name} holds nothing (hold_prop / play_motion a weapon clip / stage_duel first)`};m.forEach(u=>n.add(u.id))}else return{ok:!1,error:`'${o.name}' is not a held weapon or a person`}}const r=t.on!==!1,p={},f=typeof t.color=="string"&&/^#[0-9a-f]{6}$/i.test(t.color)?t.color:void 0,h=t.length!=null&&Number.isFinite(Number(t.length))?Math.max(.03,Math.min(.5,Number(t.length))):void 0;return a.setStage(i=>({...i,items:i.items.map(o=>{if(!n.has(o.id))return o;if(!r){p[o.name]="off";const{trail:u,...s}=o;return s}const m={...o.trail||{},...t.style==="smear"||t.style==="ribbon"?{style:t.style}:{},...f?{color:f}:{},...h!=null?{length:h}:{}};return p[o.name]=m,{...o,trail:m}})})),{ok:!0,trails:p}}export{M as CAMERA_PRESET_IDS,z as DUEL_PACKS,it as cameraPreset,at as setTiming,mt as setTrail,nt as stageDuel};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMatte-7b7Ow64f.js","assets/titleFrameBudget-DsM0V482.js","assets/api-Dnl2uaKO.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/store-CpqHUcA2.js"])))=>i.map(i=>d[i]);
2
- import{eT as Q,hJ as A,b_ as Y,ez as Z,iF as tt,_ as et,f1 as ot}from"./titleFrameBudget-DsM0V482.js";import{c as at}from"./distortGL-vhnBRB59.js";import{I as rt,A as nt,U as it,V as st}from"./id3-arvEpAg7.js";const lt=["crop","mask","person","personPending","matteFix","colorPerson","distort","playbackRate","speedRamp","reverse","freeze","smoothSlow","inPoint","sourceDuration","proxy","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx","audioTools","sfx","face","roto","planar","sceneTrack","hands"],ct=["url","gcsUri","label","nodeId","start","duration","inPoint","sourceDuration","playbackRate","reverse","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx"],dt=1920,ut=e=>new Promise((p,n)=>{const l=c=>{if(!c)return n(Error("Cannot encode distort frame"));const d=new FileReader;d.onload=()=>p(String(d.result).slice(String(d.result).indexOf(",")+1)),d.onerror=()=>n(d.error),d.readAsDataURL(c)};e instanceof HTMLCanvasElement?e.toBlob(l,"image/webp",.9):e.convertToBlob({type:"image/webp",quality:.9}).then(l,n)});function mt(e,p){const n=e.distort;if(e.kind!=="image"||e.mask||e.person||(n.mesh?.keys.length??0)>1||n.puppet?.pins.some(c=>(c.keys?.length??0)>1)||(n.displace?.keys?.length??0)>1)return!1;const l=n.displace?p.find(c=>c.id===n.displace.map):null;return!l||l.kind==="image"&&!A(l)&&l.start<=e.start&&l.start+l.duration>=e.start+e.duration}async function wt(e,p,n,l,c={}){const d=e.filter(t=>Q(t)&&(t.kind==="video"||t.kind==="image")&&!A(t)&&!t.gen);if(!d.length)return{clips:e,tracks:c};const{fps:v}=Y(p),R=()=>{if(l?.aborted)throw new DOMException("Export cancelled","AbortError")},T=new Set(d.map(t=>t.id)),D={...c};let x=Math.max(0,...e.map(t=>t.track),...Object.keys(c).map(Number))+1;const h=[];for(const t of e){if(!T.has(t.id)){h.push(t);continue}const a={...t,kind:"image",warped:!0};for(const i of lt)delete a[i];if(h.push(a),t.kind==="video"&&!t.speedRamp&&!t.freeze&&(t.volume??1)>0){const i={id:`${t.id}~sound`,kind:"audio",track:x},k=t;for(const m of ct)k[m]!==void 0&&(i[m]=k[m]);c[t.track]&&(D[x]={...c[t.track]}),x++,h.push(i)}}const N=new Map(Z(e).filter(t=>t._virtual).map(t=>[t.id,t])),_=[];for(const t of d)_.push({clip:t,as:t});for(const t of tt(h))T.has(String(t._virtual))&&_.push({clip:N.get(t.id)??{...e.find(a=>a.id===t._virtual),...t,_still:!0},as:t});const w=d.some(t=>t.mask||t.person)?await et(()=>import("./rotoMatte-7b7Ow64f.js").then(t=>t.r),__vite__mapDeps([0,1,2,3,4,5])):null;w&&await w.prepareMattes(d.filter(t=>t.mask||t.person));const W=w?document.createElement("canvas"):null,O=at(),I=[],F=new Map,C=async t=>{const a=new rt({source:new it(t),formats:nt});I.push(a);const i=await a.getPrimaryVideoTrack();return i?new st(i):null},U=async t=>{let a=F.get(t);return a||(a=await createImageBitmap(await(await fetch(t,{signal:l})).blob(),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"}),F.set(t,a)),a};try{for(const{clip:t,as:a}of _){R();const i=e.find(o=>o.id===(t._virtual??t.id)),k=Math.ceil(a.duration*v),m=i.distort,$=!!(t._still||t.freeze),q=o=>{const r=o/v,u=t.playbackRate||1;return t.reverse?Math.max(0,(t.inPoint||0)+Math.max(0,t.duration-r-1/v)*u):ot(t,r,!1,$).source};let g=null,b=null;if(t.kind==="video"){const o=await C(t.url);o&&(g=o.samplesAtTimestamps(Array.from({length:k},(r,u)=>q(u))))}else b=await U(t.url);const s=m.displace?e.find(o=>o.id===m.displace.map):void 0,V=s?.kind==="video"?await C(s.url):null,L=s?.kind==="image"&&s.url&&!A(s)?await U(s.url):null,G=async o=>{if(!s||o<s.start||o>=s.start+s.duration)return null;if(L)return{source:L};if(!V)return null;const r=await V.getSample((s.inPoint||0)+(o-s.start)*(s.playbackRate||1));if(!r)return null;const u=r.toVideoFrame();return r.close(),{source:u,close:()=>u.close()}},J=mt(i,e);for(let o=0;o<k;o++){R();const r=g?(await g.next()).value??null:null;if(J&&o>0){r?.close(),await n.push("titleFrames",a.id,"=");continue}const u=r?r.toVideoFrame():null,z=u??b,y=r?r.displayWidth:b?.width??0,M=r?r.displayHeight:b?.height??0;if(!z||!y||!M){if(u?.close(),r?.close(),o===0)throw Error(`No picture for ${i.label||i.id}`);await n.push("titleFrames",a.id,"=");continue}const f=t.crop||{left:0,right:0,top:0,bottom:0},K=Math.floor(y*f.left/2)*2,X=Math.floor(M*f.top/2)*2,S=Math.max(2,Math.floor(y*(1-f.left-f.right)/2)*2),E=Math.max(2,Math.floor(M*(1-f.top-f.bottom)/2)*2),H=Math.min(1,dt/Math.max(S,E)),P=o/v,B=await G(t.start+P),j=O.render({source:z,srcW:y,srcH:M,rect:[K,X,S,E],outW:Math.max(2,Math.round(S*H)),outH:Math.max(2,Math.round(E*H)),distort:m,local:t.start+P-i.start,map:B?.source??null,matte:w&&(t.mask||t.person)?w.matteCanvas(t,P,W,!1,e):null});B?.close?.(),u?.close(),r?.close(),await n.push("titleFrames",a.id,await ut(j))}g&&await g.return(void 0)}}finally{O.dispose();for(const t of F.values())t.close();for(const t of I)t.dispose?.()}return{clips:h,tracks:D}}export{wt as distortForServer};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMatte-DisQplSv.js","assets/titleFrameBudget-BW-N1-cw.js","assets/api-DJC95K48.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/store-xR02oY0m.js"])))=>i.map(i=>d[i]);
2
+ import{eT as Q,hJ as A,b_ as Y,ez as Z,iF as tt,_ as et,f1 as ot}from"./titleFrameBudget-BW-N1-cw.js";import{c as at}from"./distortGL-waTJhiOf.js";import{I as rt,A as nt,U as it,V as st}from"./id3-arvEpAg7.js";const lt=["crop","mask","person","personPending","matteFix","colorPerson","distort","playbackRate","speedRamp","reverse","freeze","smoothSlow","inPoint","sourceDuration","proxy","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx","audioTools","sfx","face","roto","planar","sceneTrack","hands"],ct=["url","gcsUri","label","nodeId","start","duration","inPoint","sourceDuration","playbackRate","reverse","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx"],dt=1920,ut=e=>new Promise((p,n)=>{const l=c=>{if(!c)return n(Error("Cannot encode distort frame"));const d=new FileReader;d.onload=()=>p(String(d.result).slice(String(d.result).indexOf(",")+1)),d.onerror=()=>n(d.error),d.readAsDataURL(c)};e instanceof HTMLCanvasElement?e.toBlob(l,"image/webp",.9):e.convertToBlob({type:"image/webp",quality:.9}).then(l,n)});function mt(e,p){const n=e.distort;if(e.kind!=="image"||e.mask||e.person||(n.mesh?.keys.length??0)>1||n.puppet?.pins.some(c=>(c.keys?.length??0)>1)||(n.displace?.keys?.length??0)>1)return!1;const l=n.displace?p.find(c=>c.id===n.displace.map):null;return!l||l.kind==="image"&&!A(l)&&l.start<=e.start&&l.start+l.duration>=e.start+e.duration}async function wt(e,p,n,l,c={}){const d=e.filter(t=>Q(t)&&(t.kind==="video"||t.kind==="image")&&!A(t)&&!t.gen);if(!d.length)return{clips:e,tracks:c};const{fps:v}=Y(p),R=()=>{if(l?.aborted)throw new DOMException("Export cancelled","AbortError")},T=new Set(d.map(t=>t.id)),D={...c};let x=Math.max(0,...e.map(t=>t.track),...Object.keys(c).map(Number))+1;const h=[];for(const t of e){if(!T.has(t.id)){h.push(t);continue}const a={...t,kind:"image",warped:!0};for(const i of lt)delete a[i];if(h.push(a),t.kind==="video"&&!t.speedRamp&&!t.freeze&&(t.volume??1)>0){const i={id:`${t.id}~sound`,kind:"audio",track:x},k=t;for(const m of ct)k[m]!==void 0&&(i[m]=k[m]);c[t.track]&&(D[x]={...c[t.track]}),x++,h.push(i)}}const N=new Map(Z(e).filter(t=>t._virtual).map(t=>[t.id,t])),_=[];for(const t of d)_.push({clip:t,as:t});for(const t of tt(h))T.has(String(t._virtual))&&_.push({clip:N.get(t.id)??{...e.find(a=>a.id===t._virtual),...t,_still:!0},as:t});const w=d.some(t=>t.mask||t.person)?await et(()=>import("./rotoMatte-DisQplSv.js").then(t=>t.r),__vite__mapDeps([0,1,2,3,4,5])):null;w&&await w.prepareMattes(d.filter(t=>t.mask||t.person));const W=w?document.createElement("canvas"):null,O=at(),I=[],F=new Map,C=async t=>{const a=new rt({source:new it(t),formats:nt});I.push(a);const i=await a.getPrimaryVideoTrack();return i?new st(i):null},U=async t=>{let a=F.get(t);return a||(a=await createImageBitmap(await(await fetch(t,{signal:l})).blob(),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"}),F.set(t,a)),a};try{for(const{clip:t,as:a}of _){R();const i=e.find(o=>o.id===(t._virtual??t.id)),k=Math.ceil(a.duration*v),m=i.distort,$=!!(t._still||t.freeze),q=o=>{const r=o/v,u=t.playbackRate||1;return t.reverse?Math.max(0,(t.inPoint||0)+Math.max(0,t.duration-r-1/v)*u):ot(t,r,!1,$).source};let g=null,b=null;if(t.kind==="video"){const o=await C(t.url);o&&(g=o.samplesAtTimestamps(Array.from({length:k},(r,u)=>q(u))))}else b=await U(t.url);const s=m.displace?e.find(o=>o.id===m.displace.map):void 0,V=s?.kind==="video"?await C(s.url):null,L=s?.kind==="image"&&s.url&&!A(s)?await U(s.url):null,G=async o=>{if(!s||o<s.start||o>=s.start+s.duration)return null;if(L)return{source:L};if(!V)return null;const r=await V.getSample((s.inPoint||0)+(o-s.start)*(s.playbackRate||1));if(!r)return null;const u=r.toVideoFrame();return r.close(),{source:u,close:()=>u.close()}},J=mt(i,e);for(let o=0;o<k;o++){R();const r=g?(await g.next()).value??null:null;if(J&&o>0){r?.close(),await n.push("titleFrames",a.id,"=");continue}const u=r?r.toVideoFrame():null,z=u??b,y=r?r.displayWidth:b?.width??0,M=r?r.displayHeight:b?.height??0;if(!z||!y||!M){if(u?.close(),r?.close(),o===0)throw Error(`No picture for ${i.label||i.id}`);await n.push("titleFrames",a.id,"=");continue}const f=t.crop||{left:0,right:0,top:0,bottom:0},K=Math.floor(y*f.left/2)*2,X=Math.floor(M*f.top/2)*2,S=Math.max(2,Math.floor(y*(1-f.left-f.right)/2)*2),E=Math.max(2,Math.floor(M*(1-f.top-f.bottom)/2)*2),H=Math.min(1,dt/Math.max(S,E)),P=o/v,B=await G(t.start+P),j=O.render({source:z,srcW:y,srcH:M,rect:[K,X,S,E],outW:Math.max(2,Math.round(S*H)),outH:Math.max(2,Math.round(E*H)),distort:m,local:t.start+P-i.start,map:B?.source??null,matte:w&&(t.mask||t.person)?w.matteCanvas(t,P,W,!1,e):null});B?.close?.(),u?.close(),r?.close(),await n.push("titleFrames",a.id,await ut(j))}g&&await g.return(void 0)}}finally{O.dispose();for(const t of F.values())t.close();for(const t of I)t.dispose?.()}return{clips:h,tracks:D}}export{wt as distortForServer};
@@ -1,4 +1,4 @@
1
- import{jb as H,c1 as K,jc as j}from"./titleFrameBudget-DsM0V482.js";const $=`#version 300 es
1
+ import{jb as H,c1 as K,jc as j}from"./titleFrameBudget-BW-N1-cw.js";const $=`#version 300 es
2
2
  in vec4 a;uniform vec4 crop;out vec2 uv;out vec2 tc;
3
3
  void main(){tc=a.zw;uv=crop.xy+a.zw*crop.zw;gl_Position=vec4(a.x*2.-1.,a.y*2.-1.,0,1);}`,z=`#version 300 es
4
4
  precision highp float;in vec2 uv;in vec2 tc;uniform sampler2D src;uniform sampler2D matte;uniform float useMatte;out vec4 o;
@@ -1 +1 @@
1
- import{r as K,X as I,Y as W,Z as U,_ as X}from"./sceneTrack-DlAH5s74.js";import"./titleFrameBudget-DsM0V482.js";const R=200,H=Object.freeze({min:1,max:20}),Z=Object.freeze(["sequence","together"]),T=Object.freeze({width:.5,thickness:.16}),q=Object.freeze({height:.2,letterHeight:1.5,spacing:.45,colors:Object.freeze(["#f2efe8","#d9533f"]),time:.5,push:"sequence"}),P=30,j=4,S=t=>typeof t=="number"&&Number.isFinite(t),N=(t,o,n)=>Math.min(n,Math.max(o,t)),F=t=>Math.round(t*1e4)/1e4,_=Math.PI/180,x=(t,o,n,i,r,p,u=15)=>{const e=Math.max(2,Math.ceil(Math.abs(p-r)/u)),s=[];for(let l=0;l<=e;l++){const c=(r+(p-r)*l/e)*_;s.push([t+n*Math.cos(c),o+i*Math.sin(c)])}return s},v=(t,o,n,i,r=90)=>x(t,o,n,i,r,r+360),w=(...t)=>t.flatMap(o=>typeof o[0]=="number"?[o]:o),G={A:[[[0,0],[.35,1],[.7,0]],[[.13,.38],[.57,.38]]],B:[w([0,0],[0,1],[.35,1],x(.35,.76,.24,.24,90,-90),[0,.52]),w([0,.52],[.38,.52],x(.38,.26,.27,.26,90,-90),[0,0])],C:[x(.4,.5,.4,.5,45,315)],D:[w([0,0],[0,1],[.25,1],x(.25,.5,.45,.5,90,-90),[0,0])],E:[[[.62,1],[0,1],[0,0],[.62,0]],[[0,.5],[.5,.5]]],F:[[[.62,1],[0,1],[0,0]],[[0,.5],[.5,.5]]],G:[w(x(.4,.5,.4,.5,40,330),[.8,.45],[.45,.45])],H:[[[0,0],[0,1]],[[.7,0],[.7,1]],[[0,.5],[.7,.5]]],I:[[[.1,0],[.1,1]]],J:[w([.6,1],[.6,.3],x(.32,.3,.28,.3,0,-180))],K:[[[0,0],[0,1]],[[.65,1],[0,.38]],[[.22,.58],[.7,0]]],L:[[[0,1],[0,0],[.6,0]]],M:[[[0,0],[0,1],[.42,.35],[.84,1],[.84,0]]],N:[[[0,0],[0,1],[.7,0],[.7,1]]],O:[v(.4,.5,.4,.5)],P:[w([0,0],[0,1],[.35,1],x(.35,.74,.26,.26,90,-90),[0,.48])],Q:[v(.4,.5,.4,.5),[[.5,.25],[.85,-.08]]],R:[w([0,0],[0,1],[.35,1],x(.35,.74,.26,.26,90,-90),[0,.48]),[[.3,.48],[.68,0]]],S:[w(x(.36,.75,.33,.25,20,270),x(.36,.25,.36,.25,90,-160))],T:[[[0,1],[.72,1]],[[.36,1],[.36,0]]],U:[w([0,1],[0,.35],x(.35,.35,.35,.35,180,360),[.7,1])],V:[[[0,1],[.36,0],[.72,1]]],W:[[[0,1],[.23,0],[.46,.7],[.69,0],[.92,1]]],X:[[[0,1],[.7,0]],[[.7,1],[0,0]]],Y:[[[0,1],[.36,.5],[.72,1]],[[.36,.5],[.36,0]]],Z:[[[0,1],[.7,1],[0,0],[.7,0]]],0:[v(.34,.5,.34,.5)],1:[[[.06,.78],[.3,1],[.3,0]]],2:[w(x(.33,.7,.3,.3,160,-30),[0,0],[.66,0])],3:[w(x(.32,.75,.28,.25,150,-90),x(.32,.27,.32,.27,90,-150))],4:[[[.55,0],[.55,1],[0,.3],[.75,.3]]],5:[w([.66,1],[.1,1],[.05,.56],x(.36,.31,.31,.31,125,-150))],6:[x(.36,.5,.34,.5,70,250),v(.36,.29,.31,.29,180)],7:[[[0,1],[.7,1],[.24,0]]],8:[v(.34,.76,.25,.24,-90),v(.34,.27,.32,.27,90)],9:[v(.34,.71,.3,.29,0),[[.64,.71],[.58,.2],[.34,0]]],"-":[[[.05,.45],[.5,.45]]],"!":[[[.1,1],[.1,.3]],[[.1,.08],[.1,0]]],"?":[w(x(.32,.72,.3,.28,160,-60),[.32,.35],[.32,.25]),[[.32,.08],[.32,0]]],"+":[[[.05,.45],[.6,.45]],[[.32,.18],[.32,.72]]],"&":[w([.75,0],[.12,.62],x(.3,.8,.2,.2,215,-45),[.08,.3],x(.3,.22,.24,.22,180,340),[.75,.45])]};function Y(t){return String(t??"").normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/[đĐ]/g,"D").toUpperCase().replace(/[^A-Z0-9\-!?+& ]/g," ").replace(/\s+/g," ").trim().slice(0,24)}const Q=t=>Math.max(.2,...t.flat().map(o=>o[0]));function $(t){const o=Y(t),n=[];let i=0;for(const p of o){if(p===" "){i+=.55;continue}const u=G[p];if(u){for(const e of u)n.push(e.map(([s,l])=>[s+i,l]));i+=Q(u)+.35}}const r=Math.max(0,i-.35);return n.map(p=>p.map(([u,e])=>[u-r/2,e]))}function J(t,o){const n=t.filter((e,s)=>s===0||Math.hypot(e[0]-t[s-1][0],e[1]-t[s-1][1])>1e-6);if(n.length<2||!(o>0))return[];const i=[];let r=0;for(let e=1;e<n.length;e++){const s=Math.hypot(n[e][0]-n[e-1][0],n[e][1]-n[e-1][1]);i.push(s),r+=s}const p=Math.max(1,Math.round(r/o)),u=[];for(let e=0;e<=p;e++){let s=r*e/p,l=0;for(;l<i.length-1&&s>i[l];)s-=i[l],l++;const c=n[l],A=n[l+1],z=i[l]>0?Math.min(1,s/i[l]):0,b=(A[0]-c[0])/(i[l]||1),y=(A[1]-c[1])/(i[l]||1);u.push({p:[c[0]+(A[0]-c[0])*z,c[1]+(A[1]-c[1])*z],t:[b,y]})}for(let e=1;e<u.length-1;e++){const s=u[e-1].p,l=u[e+1].p,c=Math.hypot(l[0]-s[0],l[1]-s[1]);c>1e-6&&(u[e].t=[(l[0]-s[0])/c,(l[1]-s[1])/c])}return u}function V(t){const o=[[t[0]]];for(let n=1;n<t.length&&(o[o.length-1].push(t[n]),n!==t.length-1);n++){const i=t[n-1],r=t[n],p=t[n+1],u=[r[0]-i[0],r[1]-i[1]],e=[p[0]-r[0],p[1]-r[1]],s=Math.hypot(...u),l=Math.hypot(...e);if(s<1e-9||l<1e-9)continue;(u[0]*e[0]+u[1]*e[1])/(s*l)<Math.cos(45*_)&&o.push([r])}return o.filter(n=>n.length>=2)}function o0(t={}){const o=N(S(t.height)?t.height:q.height,.05,.8),n=[o*T.width,o,o*T.thickness],i=o*N(S(t.spacing)?t.spacing:q.spacing,.25,.75),r=Array.isArray(t.position)&&t.position.length===3&&t.position.every(S)?t.position:[0,0,0],p=S(t.floor)?t.floor:r[1],u=(S(t.yaw)?t.yaw:0)*_,e=Math.cos(u),s=Math.sin(u);let l;if(t.text!=null&&Y(t.text)){const m=N(S(t.letterHeight)?t.letterHeight:q.letterHeight,.3,10);l=$(t.text).map(D=>D.map(([O,h])=>[O*m,-(h-.5)*m]))}else if(Array.isArray(t.path)&&t.path.length>=2)l=[t.path.filter(m=>Array.isArray(m)&&m.length>=2&&S(m[0])&&S(m[m.length-1])).map(m=>[m[0],m[m.length-1]])];else return{runs:[],size:n,count:0,length:0,error:"give text (a word) or path ([[x, z], …] with at least 2 points)"};const c=[],A=[],z=n[0]*.9;let b=0,y=0;for(const m of l.flatMap(V)){const D=[[]];for(const O of J(m,i)){if(A.some(f=>Math.hypot(f[0]-O.p[0],f[1]-O.p[1])<z)){D[D.length-1].length&&D.push([]);continue}D[D.length-1].push(O)}for(const O of D){if(O.length<2)continue;for(const g of O)A.push(g.p);const h=t.text!=null,f=h?e:1,a=h?s:0,d=O.map(({p:g,t:M})=>{const E=(h?r[0]:0)+g[0]*f+g[1]*a,C=(h?r[2]:0)-g[0]*a+g[1]*f,k=M[0]*f+M[1]*a,B=-M[0]*a+M[1]*f;return{position:[F(E),F(p),F(C)],rotation:[0,Math.round(Math.atan2(k,B)/_*100)/100,0],tangent:[k,0,B]}});c.push(d),b+=d.length,y+=i*(d.length-1)}}return b?b>R?{runs:c,size:n,count:b,length:y,error:`${b} dominoes needed, at most ${R}: use fewer letters, a smaller letter_height or taller dominoes`}:{runs:c,size:n,count:b,length:F(y)}:{runs:c,size:n,count:b,length:y,error:"nothing to set out (empty text or a path shorter than one domino)"}}function s0(t,o=q.push){const n=Math.max(.05,t?.size?.[1]??q.height),i=.95*Math.sqrt(9.81*n),r=t?.runs??[],p=r.map(e=>Math.max(0,e.length-1)*(e.length>1?Math.hypot(e[1].position[0]-e[0].position[0],e[1].position[2]-e[0].position[2]):0)),u=o==="together"?Math.max(0,...p)/i+1:p.reduce((e,s)=>e+s,0)/i+.35*r.length+1;return Math.round(N(u,H.min,H.max)*10)/10}const L=(t,o)=>{const[n,i,r,p]=t,[u,e,s]=o,l=p*u+i*s-r*e,c=p*e+r*u-n*s,A=p*s+n*e-i*u,z=-n*u-i*e-r*s;return[l*p+z*-n+c*-r-A*-i,c*p+z*-i+A*-n-l*-r,A*p+z*-r+l*-i-c*-n]};function t0(t,o){const{runs:n,size:i}=o,r=i.map(l=>l/2),p=Z.includes(o.push)?o.push:"sequence",u=N(S(o.duration)?o.duration:6,H.min,H.max),e=S(o.floor)?o.floor:0,s=new t.World({x:0,y:-9.81,z:0});try{s.timestep=1/(P*j);const l=s.createRigidBody(t.RigidBodyDesc.fixed().setTranslation(0,e-1,0));s.createCollider(t.ColliderDesc.cuboid(1e3,1,1e3).setFriction(.6).setRestitution(.02),l);for(const h of o.statics||[]){const f=h?.min,a=h?.max;if(!Array.isArray(f)||!Array.isArray(a))continue;const d=[0,1,2].map(M=>(a[M]-f[M])/2);if(d.some(M=>!(M>.002))||a[1]<=e+.001)continue;const g=s.createRigidBody(t.RigidBodyDesc.fixed().setTranslation((f[0]+a[0])/2,(f[1]+a[1])/2,(f[2]+a[2])/2));s.createCollider(t.ColliderDesc.cuboid(d[0],d[1],d[2]).setFriction(.6).setRestitution(.02),g)}const c=[];n.forEach((h,f)=>h.forEach((a,d)=>{const g=U(a.rotation),M=[a.position[0],a.position[1]+r[1],a.position[2]],E=s.createRigidBody(t.RigidBodyDesc.dynamic().setTranslation(M[0],M[1],M[2]).setRotation({x:g[0],y:g[1],z:g[2],w:g[3]}).setAngularDamping(.05).setLinearDamping(.02));s.createCollider(t.ColliderDesc.cuboid(r[0],r[1],r[2]).setFriction(.5).setRestitution(.02).setDensity(600),E),c.push({run:f,index:d,rb:E,tangent:a.tangent,samples:[],fellAt:null})}));const A=n.map((h,f)=>c.filter(a=>a.run===f)),z=[],b=[],y=(h,f)=>{const a=A[h]?.[0];if(!a)return;const d=a.tangent,g=a.rb.translation(),M=a.rb.mass()*.6;a.rb.applyImpulseAtPoint({x:d[0]*M,y:0,z:d[2]*M},{x:g.x,y:g.y+r[1]*.9,z:g.z},!0),z.push({run:h,sec:Math.round(f*1e3)/1e3})};let m=0,D=0;p==="together"?(n.forEach((h,f)=>y(f,0)),m=n.length):(y(0,0),m=1);const O=Math.round(u*P);for(let h=0;h<=O;h++){if(h)for(let a=0;a<j;a++)s.step();const f=h/P;for(const a of c){const d=a.rb.translation(),g=a.rb.rotation(),M=[g.x,g.y,g.z,g.w],E=L(M,[0,r[1],0]),C=a.rb.linvel(),k=a.rb.angvel();a.samples.push({sec:f,centre:[d.x,d.y,d.z],pivot:[d.x-E[0],d.y-E[1],d.z-E[2]],q:M,speed:Math.hypot(C.x,C.y,C.z)+Math.hypot(k.x,k.y,k.z)*r[1]}),a.fellAt==null&&L(M,[0,1,0])[1]<Math.cos(12*_)&&(a.fellAt=f,D=f)}if(p==="sequence"&&m<n.length){const a=A[m-1],d=a[a.length-1],g=f-Math.max(D,z[z.length-1].sec)>1.2;(d.fellAt!=null||g)&&(g&&d.fellAt==null&&b.push(m-1),y(m,f),m++)}}for(let h=0;h<n.length;h++)!b.includes(h)&&A[h].some(f=>f.fellAt==null)&&b.push(h);return{bodies:c,fallen:c.filter(h=>h.fellAt!=null).length,total:c.length,pushes:z,stalled:b.sort((h,f)=>h-f),duration:u}}finally{s.free()}}async function r0(t){const o=t0(await K(),t),n=S(t.start)?Math.max(0,t.start):0,i=S(t.shotDuration)&&t.shotDuration>0?t.shotDuration:n+o.duration,r=n/i,p={},u={position:I.position,rotation:Math.max(I.rotation,3)};return o.bodies.forEach((e,s)=>{const l=t.ids[s];if(!l)return;let c=null;const A=e.samples.map(b=>{let y=W(b.q);if(c){const m=[y[0]+180,180-y[1],y[2]+180],D=O=>O.reduce((h,f,a)=>h+Math.abs(((f-c[a])%360+540)%360-180),0);D(m)<D(y)&&(y=m)}return y=y.map(m=>{const D=(m%360+540)%360-180;return Math.round((D===-180?180:D)*100)/100}),c=y,{time:r+b.sec/i,position:b.pivot.map(F),rotation:y,quat:U(y)}}),{keys:z}=X(A,{tolerance:u,seam:S(t.seam)?t.seam:null,duration:i});p[l]={keys:z,fellAt:e.fellAt==null?null:Math.round((n+e.fellAt)*1e3)/1e3}}),{tracks:p,fallen:o.fallen,total:o.total,pushes:o.pushes.map(e=>({run:e.run,sec:Math.round((n+e.sec)*1e3)/1e3})),stalled:o.stalled,seconds:o.duration}}export{q as DOMINO_DEFAULTS,Z as DOMINO_PUSHES,H as DOMINO_SECONDS,T as DOMINO_SHAPE,R as MAX_DOMINOES,r0 as bakeDominoes,s0 as dominoSeconds,Y as dominoText,o0 as layoutDominoes,J as resample,t0 as simulateDominoes,V as splitCorners,$ as textStrokes};
1
+ import{r as K,X as I,Y as W,Z as U,_ as X}from"./sceneTrack-DyVxpl7i.js";import"./titleFrameBudget-BW-N1-cw.js";const R=200,H=Object.freeze({min:1,max:20}),Z=Object.freeze(["sequence","together"]),T=Object.freeze({width:.5,thickness:.16}),q=Object.freeze({height:.2,letterHeight:1.5,spacing:.45,colors:Object.freeze(["#f2efe8","#d9533f"]),time:.5,push:"sequence"}),P=30,j=4,S=t=>typeof t=="number"&&Number.isFinite(t),N=(t,o,n)=>Math.min(n,Math.max(o,t)),F=t=>Math.round(t*1e4)/1e4,_=Math.PI/180,x=(t,o,n,i,r,p,u=15)=>{const e=Math.max(2,Math.ceil(Math.abs(p-r)/u)),s=[];for(let l=0;l<=e;l++){const c=(r+(p-r)*l/e)*_;s.push([t+n*Math.cos(c),o+i*Math.sin(c)])}return s},v=(t,o,n,i,r=90)=>x(t,o,n,i,r,r+360),w=(...t)=>t.flatMap(o=>typeof o[0]=="number"?[o]:o),G={A:[[[0,0],[.35,1],[.7,0]],[[.13,.38],[.57,.38]]],B:[w([0,0],[0,1],[.35,1],x(.35,.76,.24,.24,90,-90),[0,.52]),w([0,.52],[.38,.52],x(.38,.26,.27,.26,90,-90),[0,0])],C:[x(.4,.5,.4,.5,45,315)],D:[w([0,0],[0,1],[.25,1],x(.25,.5,.45,.5,90,-90),[0,0])],E:[[[.62,1],[0,1],[0,0],[.62,0]],[[0,.5],[.5,.5]]],F:[[[.62,1],[0,1],[0,0]],[[0,.5],[.5,.5]]],G:[w(x(.4,.5,.4,.5,40,330),[.8,.45],[.45,.45])],H:[[[0,0],[0,1]],[[.7,0],[.7,1]],[[0,.5],[.7,.5]]],I:[[[.1,0],[.1,1]]],J:[w([.6,1],[.6,.3],x(.32,.3,.28,.3,0,-180))],K:[[[0,0],[0,1]],[[.65,1],[0,.38]],[[.22,.58],[.7,0]]],L:[[[0,1],[0,0],[.6,0]]],M:[[[0,0],[0,1],[.42,.35],[.84,1],[.84,0]]],N:[[[0,0],[0,1],[.7,0],[.7,1]]],O:[v(.4,.5,.4,.5)],P:[w([0,0],[0,1],[.35,1],x(.35,.74,.26,.26,90,-90),[0,.48])],Q:[v(.4,.5,.4,.5),[[.5,.25],[.85,-.08]]],R:[w([0,0],[0,1],[.35,1],x(.35,.74,.26,.26,90,-90),[0,.48]),[[.3,.48],[.68,0]]],S:[w(x(.36,.75,.33,.25,20,270),x(.36,.25,.36,.25,90,-160))],T:[[[0,1],[.72,1]],[[.36,1],[.36,0]]],U:[w([0,1],[0,.35],x(.35,.35,.35,.35,180,360),[.7,1])],V:[[[0,1],[.36,0],[.72,1]]],W:[[[0,1],[.23,0],[.46,.7],[.69,0],[.92,1]]],X:[[[0,1],[.7,0]],[[.7,1],[0,0]]],Y:[[[0,1],[.36,.5],[.72,1]],[[.36,.5],[.36,0]]],Z:[[[0,1],[.7,1],[0,0],[.7,0]]],0:[v(.34,.5,.34,.5)],1:[[[.06,.78],[.3,1],[.3,0]]],2:[w(x(.33,.7,.3,.3,160,-30),[0,0],[.66,0])],3:[w(x(.32,.75,.28,.25,150,-90),x(.32,.27,.32,.27,90,-150))],4:[[[.55,0],[.55,1],[0,.3],[.75,.3]]],5:[w([.66,1],[.1,1],[.05,.56],x(.36,.31,.31,.31,125,-150))],6:[x(.36,.5,.34,.5,70,250),v(.36,.29,.31,.29,180)],7:[[[0,1],[.7,1],[.24,0]]],8:[v(.34,.76,.25,.24,-90),v(.34,.27,.32,.27,90)],9:[v(.34,.71,.3,.29,0),[[.64,.71],[.58,.2],[.34,0]]],"-":[[[.05,.45],[.5,.45]]],"!":[[[.1,1],[.1,.3]],[[.1,.08],[.1,0]]],"?":[w(x(.32,.72,.3,.28,160,-60),[.32,.35],[.32,.25]),[[.32,.08],[.32,0]]],"+":[[[.05,.45],[.6,.45]],[[.32,.18],[.32,.72]]],"&":[w([.75,0],[.12,.62],x(.3,.8,.2,.2,215,-45),[.08,.3],x(.3,.22,.24,.22,180,340),[.75,.45])]};function Y(t){return String(t??"").normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/[đĐ]/g,"D").toUpperCase().replace(/[^A-Z0-9\-!?+& ]/g," ").replace(/\s+/g," ").trim().slice(0,24)}const Q=t=>Math.max(.2,...t.flat().map(o=>o[0]));function $(t){const o=Y(t),n=[];let i=0;for(const p of o){if(p===" "){i+=.55;continue}const u=G[p];if(u){for(const e of u)n.push(e.map(([s,l])=>[s+i,l]));i+=Q(u)+.35}}const r=Math.max(0,i-.35);return n.map(p=>p.map(([u,e])=>[u-r/2,e]))}function J(t,o){const n=t.filter((e,s)=>s===0||Math.hypot(e[0]-t[s-1][0],e[1]-t[s-1][1])>1e-6);if(n.length<2||!(o>0))return[];const i=[];let r=0;for(let e=1;e<n.length;e++){const s=Math.hypot(n[e][0]-n[e-1][0],n[e][1]-n[e-1][1]);i.push(s),r+=s}const p=Math.max(1,Math.round(r/o)),u=[];for(let e=0;e<=p;e++){let s=r*e/p,l=0;for(;l<i.length-1&&s>i[l];)s-=i[l],l++;const c=n[l],A=n[l+1],z=i[l]>0?Math.min(1,s/i[l]):0,b=(A[0]-c[0])/(i[l]||1),y=(A[1]-c[1])/(i[l]||1);u.push({p:[c[0]+(A[0]-c[0])*z,c[1]+(A[1]-c[1])*z],t:[b,y]})}for(let e=1;e<u.length-1;e++){const s=u[e-1].p,l=u[e+1].p,c=Math.hypot(l[0]-s[0],l[1]-s[1]);c>1e-6&&(u[e].t=[(l[0]-s[0])/c,(l[1]-s[1])/c])}return u}function V(t){const o=[[t[0]]];for(let n=1;n<t.length&&(o[o.length-1].push(t[n]),n!==t.length-1);n++){const i=t[n-1],r=t[n],p=t[n+1],u=[r[0]-i[0],r[1]-i[1]],e=[p[0]-r[0],p[1]-r[1]],s=Math.hypot(...u),l=Math.hypot(...e);if(s<1e-9||l<1e-9)continue;(u[0]*e[0]+u[1]*e[1])/(s*l)<Math.cos(45*_)&&o.push([r])}return o.filter(n=>n.length>=2)}function o0(t={}){const o=N(S(t.height)?t.height:q.height,.05,.8),n=[o*T.width,o,o*T.thickness],i=o*N(S(t.spacing)?t.spacing:q.spacing,.25,.75),r=Array.isArray(t.position)&&t.position.length===3&&t.position.every(S)?t.position:[0,0,0],p=S(t.floor)?t.floor:r[1],u=(S(t.yaw)?t.yaw:0)*_,e=Math.cos(u),s=Math.sin(u);let l;if(t.text!=null&&Y(t.text)){const m=N(S(t.letterHeight)?t.letterHeight:q.letterHeight,.3,10);l=$(t.text).map(D=>D.map(([O,h])=>[O*m,-(h-.5)*m]))}else if(Array.isArray(t.path)&&t.path.length>=2)l=[t.path.filter(m=>Array.isArray(m)&&m.length>=2&&S(m[0])&&S(m[m.length-1])).map(m=>[m[0],m[m.length-1]])];else return{runs:[],size:n,count:0,length:0,error:"give text (a word) or path ([[x, z], …] with at least 2 points)"};const c=[],A=[],z=n[0]*.9;let b=0,y=0;for(const m of l.flatMap(V)){const D=[[]];for(const O of J(m,i)){if(A.some(f=>Math.hypot(f[0]-O.p[0],f[1]-O.p[1])<z)){D[D.length-1].length&&D.push([]);continue}D[D.length-1].push(O)}for(const O of D){if(O.length<2)continue;for(const g of O)A.push(g.p);const h=t.text!=null,f=h?e:1,a=h?s:0,d=O.map(({p:g,t:M})=>{const E=(h?r[0]:0)+g[0]*f+g[1]*a,C=(h?r[2]:0)-g[0]*a+g[1]*f,k=M[0]*f+M[1]*a,B=-M[0]*a+M[1]*f;return{position:[F(E),F(p),F(C)],rotation:[0,Math.round(Math.atan2(k,B)/_*100)/100,0],tangent:[k,0,B]}});c.push(d),b+=d.length,y+=i*(d.length-1)}}return b?b>R?{runs:c,size:n,count:b,length:y,error:`${b} dominoes needed, at most ${R}: use fewer letters, a smaller letter_height or taller dominoes`}:{runs:c,size:n,count:b,length:F(y)}:{runs:c,size:n,count:b,length:y,error:"nothing to set out (empty text or a path shorter than one domino)"}}function s0(t,o=q.push){const n=Math.max(.05,t?.size?.[1]??q.height),i=.95*Math.sqrt(9.81*n),r=t?.runs??[],p=r.map(e=>Math.max(0,e.length-1)*(e.length>1?Math.hypot(e[1].position[0]-e[0].position[0],e[1].position[2]-e[0].position[2]):0)),u=o==="together"?Math.max(0,...p)/i+1:p.reduce((e,s)=>e+s,0)/i+.35*r.length+1;return Math.round(N(u,H.min,H.max)*10)/10}const L=(t,o)=>{const[n,i,r,p]=t,[u,e,s]=o,l=p*u+i*s-r*e,c=p*e+r*u-n*s,A=p*s+n*e-i*u,z=-n*u-i*e-r*s;return[l*p+z*-n+c*-r-A*-i,c*p+z*-i+A*-n-l*-r,A*p+z*-r+l*-i-c*-n]};function t0(t,o){const{runs:n,size:i}=o,r=i.map(l=>l/2),p=Z.includes(o.push)?o.push:"sequence",u=N(S(o.duration)?o.duration:6,H.min,H.max),e=S(o.floor)?o.floor:0,s=new t.World({x:0,y:-9.81,z:0});try{s.timestep=1/(P*j);const l=s.createRigidBody(t.RigidBodyDesc.fixed().setTranslation(0,e-1,0));s.createCollider(t.ColliderDesc.cuboid(1e3,1,1e3).setFriction(.6).setRestitution(.02),l);for(const h of o.statics||[]){const f=h?.min,a=h?.max;if(!Array.isArray(f)||!Array.isArray(a))continue;const d=[0,1,2].map(M=>(a[M]-f[M])/2);if(d.some(M=>!(M>.002))||a[1]<=e+.001)continue;const g=s.createRigidBody(t.RigidBodyDesc.fixed().setTranslation((f[0]+a[0])/2,(f[1]+a[1])/2,(f[2]+a[2])/2));s.createCollider(t.ColliderDesc.cuboid(d[0],d[1],d[2]).setFriction(.6).setRestitution(.02),g)}const c=[];n.forEach((h,f)=>h.forEach((a,d)=>{const g=U(a.rotation),M=[a.position[0],a.position[1]+r[1],a.position[2]],E=s.createRigidBody(t.RigidBodyDesc.dynamic().setTranslation(M[0],M[1],M[2]).setRotation({x:g[0],y:g[1],z:g[2],w:g[3]}).setAngularDamping(.05).setLinearDamping(.02));s.createCollider(t.ColliderDesc.cuboid(r[0],r[1],r[2]).setFriction(.5).setRestitution(.02).setDensity(600),E),c.push({run:f,index:d,rb:E,tangent:a.tangent,samples:[],fellAt:null})}));const A=n.map((h,f)=>c.filter(a=>a.run===f)),z=[],b=[],y=(h,f)=>{const a=A[h]?.[0];if(!a)return;const d=a.tangent,g=a.rb.translation(),M=a.rb.mass()*.6;a.rb.applyImpulseAtPoint({x:d[0]*M,y:0,z:d[2]*M},{x:g.x,y:g.y+r[1]*.9,z:g.z},!0),z.push({run:h,sec:Math.round(f*1e3)/1e3})};let m=0,D=0;p==="together"?(n.forEach((h,f)=>y(f,0)),m=n.length):(y(0,0),m=1);const O=Math.round(u*P);for(let h=0;h<=O;h++){if(h)for(let a=0;a<j;a++)s.step();const f=h/P;for(const a of c){const d=a.rb.translation(),g=a.rb.rotation(),M=[g.x,g.y,g.z,g.w],E=L(M,[0,r[1],0]),C=a.rb.linvel(),k=a.rb.angvel();a.samples.push({sec:f,centre:[d.x,d.y,d.z],pivot:[d.x-E[0],d.y-E[1],d.z-E[2]],q:M,speed:Math.hypot(C.x,C.y,C.z)+Math.hypot(k.x,k.y,k.z)*r[1]}),a.fellAt==null&&L(M,[0,1,0])[1]<Math.cos(12*_)&&(a.fellAt=f,D=f)}if(p==="sequence"&&m<n.length){const a=A[m-1],d=a[a.length-1],g=f-Math.max(D,z[z.length-1].sec)>1.2;(d.fellAt!=null||g)&&(g&&d.fellAt==null&&b.push(m-1),y(m,f),m++)}}for(let h=0;h<n.length;h++)!b.includes(h)&&A[h].some(f=>f.fellAt==null)&&b.push(h);return{bodies:c,fallen:c.filter(h=>h.fellAt!=null).length,total:c.length,pushes:z,stalled:b.sort((h,f)=>h-f),duration:u}}finally{s.free()}}async function r0(t){const o=t0(await K(),t),n=S(t.start)?Math.max(0,t.start):0,i=S(t.shotDuration)&&t.shotDuration>0?t.shotDuration:n+o.duration,r=n/i,p={},u={position:I.position,rotation:Math.max(I.rotation,3)};return o.bodies.forEach((e,s)=>{const l=t.ids[s];if(!l)return;let c=null;const A=e.samples.map(b=>{let y=W(b.q);if(c){const m=[y[0]+180,180-y[1],y[2]+180],D=O=>O.reduce((h,f,a)=>h+Math.abs(((f-c[a])%360+540)%360-180),0);D(m)<D(y)&&(y=m)}return y=y.map(m=>{const D=(m%360+540)%360-180;return Math.round((D===-180?180:D)*100)/100}),c=y,{time:r+b.sec/i,position:b.pivot.map(F),rotation:y,quat:U(y)}}),{keys:z}=X(A,{tolerance:u,seam:S(t.seam)?t.seam:null,duration:i});p[l]={keys:z,fellAt:e.fellAt==null?null:Math.round((n+e.fellAt)*1e3)/1e3}}),{tracks:p,fallen:o.fallen,total:o.total,pushes:o.pushes.map(e=>({run:e.run,sec:Math.round((n+e.sec)*1e3)/1e3})),stalled:o.stalled,seconds:o.duration}}export{q as DOMINO_DEFAULTS,Z as DOMINO_PUSHES,H as DOMINO_SECONDS,T as DOMINO_SHAPE,R as MAX_DOMINOES,r0 as bakeDominoes,s0 as dominoSeconds,Y as dominoText,o0 as layoutDominoes,J as resample,t0 as simulateDominoes,V as splitCorners,$ as textStrokes};
@@ -1 +1 @@
1
- import{de as Mt,fg as tt,bU as te,cw as Jt,fh as Bt,a8 as bt,cB as kt,cC as _t,fi as Ct,cy as zt,cK as ee,fj as oe,fk as Tt,cG as Ft,cJ as wt,cO as ne,cH as Ut,cM as ae,cF as ie,fl as re}from"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./titleFrameBudget-DsM0V482.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const Wt=t=>Math.round(t*100)/100,pt=(t,a)=>({id:t.id,label:t.label??"",scope:t.scope,start_s:t.start,end_s:t.scope==="after"?null:t.end,fade_s:t.fade,...t.fadeOut!=null?{fade_out_s:t.fadeOut}:{},...t.track?{track:{from_s:t.track.t[0],to_s:t.track.t[t.track.t.length-1],samples:t.track.t.length,joints:Object.keys(t.track.pose||{}),...t.track.turn?{turn_deg_max:Math.round(Math.max(...t.track.turn.map(Math.abs)))}:{}}}:{},...t.off?{off:!0}:{},weight_now:Wt(kt(t,a)),...t.pose?{joints:t.pose}:{},...t.stance?{stance:t.stance}:{},...t.preset?{preset:t.preset}:{},...t.move?{move_m:[t.move[0],t.move[2]]}:{},...t.turn?{turn_deg:t.turn}:{}});function Kt(t,a){const f=a.getStage(),c=Mt(f),r=c.duration;let o;try{o=tt(f,String(t.name??""))}catch(h){return{ok:!1,error:h.message}}if(!te(o))return{ok:!1,error:`'${o.name}' is not a person (or a humanoid-rigged model)`};const s=c.motionEdits?.[o.id]||[],e=Math.max(0,Math.min(r,Number(t.at??0)||0)),M=h=>a.setStage(N=>({...N,shots:N.shots.map(y=>y.id===c.id?{...y,motionEdits:{...y.motionEdits,[o.id]:h}}:y)}));if(t.remove!=null){const h=String(t.remove),N=h==="all"?[]:s.filter(y=>y.id!==h);return N.length===s.length&&h!=="all"?{ok:!1,error:`no edit '${h}' on ${o.name}; edits: ${s.map(y=>y.id).join(", ")||"none"}`}:(M(N),{ok:!0,name:o.name,removed:h==="all"?s.length:1,edits:N.map(y=>pt(y,e))})}const p=t.id!=null?s.find(h=>h.id===String(t.id)):void 0;if(t.id!=null&&!p)return{ok:!1,error:`no edit '${String(t.id)}' on ${o.name}`};const n=["moment","span","after"].includes(String(t.scope))?String(t.scope):p?.scope??"moment",d=(c.clipSpans?.[o.id]||[]).find(h=>e>=h.start-.001&&e<=h.end+.001);let u=p?.start??e,i=p?.end??e;if((t.at!=null||!p)&&(u=e,i=e),n==="span"){if(t.start!=null||t.end!=null)u=Number(t.start??u),i=Number(t.end??i);else if(d)u=d.start,i=d.end;else if(!p)return{ok:!1,error:`no motion block at ${e} s on ${o.name}: give start and end for scope span`}}const m=Number(t.fade??p?.fade??Jt.default),k=t.fade_out!=null?Number(t.fade_out):p?.fadeOut;if(t.face_toward!=null){let h;try{h=tt(f,String(t.face_toward))}catch(O){return{ok:!1,error:O.message}}if(h.id===o.id)return{ok:!1,error:"face_toward another object"};const N=Math.max(0,Math.min(1,Number(t.face_strength??1))),y={scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{}},B=Math.max(0,u-m),ot=n==="after"?r:Math.min(r,i+(k??m)),ct=Math.min(Bt.samples,Math.max(2,Math.ceil((ot-B)*24)+1)),gt=s.filter(O=>O.id!==p?.id),H={...c,motionEdits:{...c.motionEdits,[o.id]:gt}},W=[],nt=[];for(let O=0;O<ct;O++){const J=B+(ot-B)*O/(ct-1),V=J/Math.max(1e-6,r),at=bt(o,H,V,f.items),T=bt(h,H,V,f.items),L=((Math.atan2(T.position[0]-at.position[0],T.position[2]-at.position[2])*180/Math.PI-(at.rotation[1]||0))%360+540)%360-180;W.push(Math.round(J*1e3)/1e3),nt.push(kt(y,J)*N*L)}const G={id:p?.id??crypto.randomUUID(),scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{},track:{t:W,turn:nt},label:String(t.label??`${o.name} faces ${h.name}`)},z=_t(s,G,r),Q=z.find(O=>O.id===G.id);return Q?(M(z),{ok:!0,name:o.name,edit:pt(Q,e),edits:z.length,...d?{motion_block:{label:d.label,start_s:d.start,end_s:d.end}}:{},note:"the heading follows the target frame by frame (keys untouched); inspect_pose to check, then move_joint for contact"}):{ok:!1,error:`${o.name} already faces ${h.name} there`}}const b={};for(const[h,N]of Object.entries(t.joints||{})){if(!(h in Ct)&&!/^(grip|index|thumb)[LR]$|^(headPitch|headRoll)$/.test(h))return{ok:!1,error:`unknown joint '${h}'; joints: ${Object.keys(Ct).join(", ")}`};Number.isFinite(Number(N))&&(b[h]=Number(N))}const P=t.preset!=null?t.preset==="none"?null:{id:String(t.preset),amount:Number(t.preset_amount??.7),...t.preset_arms?{arms:!0}:{}}:p?.preset;if(P&&!zt.some(h=>h.id===P.id))return{ok:!1,error:`unknown preset; use one of ${zt.map(h=>h.id).join(", ")}`};const $=Array.isArray(t.move_m)?[Number(t.move_m[0])||0,0,Number(t.move_m[1])||0]:p?.move,j={...p||{},id:p?.id??crypto.randomUUID(),scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{},...Object.keys(b).length?{pose:{...t.id!=null?p?.pose:{},...b}}:{},...t.stance?{stance:{...p?.stance||{},...t.stance}}:{},preset:P??void 0,move:$,...t.turn_deg!=null?{turn:Number(t.turn_deg)}:{},...typeof t.off=="boolean"?{off:t.off}:{},label:String(t.label??p?.label??"Agent")},E=_t(s,j,r),R=E.find(h=>h.id===j.id);return R?(M(E),{ok:!0,name:o.name,edit:pt(R,e),edits:E.length,...d?{motion_block:{label:d.label,start_s:d.start,end_s:d.end}}:{},note:"a correction on top of the motion (keys untouched); render_preview / check_shot to see it; edit_motion with id to refine, remove to drop it"}):{ok:!1,error:"the edit changes nothing: give joints, stance, preset, move_m or turn_deg"}}const S=t=>Math.round(t*1e3)/1e3;function Gt(t,a){return(t.clipSpans?.[a]||[]).flatMap(f=>{const c=re(f.clip),r=c?.strike;return!r||!c?.duration?[]:[{at:S(f.start+r.t*(f.end-f.start)/c.duration),limb:r.limb,zone:r.zone,cls:r.cls,clip:f.clip}]})}function Ht(t,a){if(t.some(e=>!e)||t.length<4)return null;const f=t,c=(e,M)=>e.map((p,n)=>(p-M[n])/a),r=f.slice(1).map((e,M)=>c(e,f[M])),o=r.slice(1).map((e,M)=>c(e,r[M])),s=o.slice(1).map((e,M)=>c(e,o[M]));return{speed:Wt(Math.max(...r.map(e=>Math.hypot(...e)))),jerk:Math.round(Math.max(0,...s.map(e=>Math.hypot(...e))))}}const et={surface:t=>({head:.1,chest:.13,hips:.14})[t]??.05,tip:t=>t.startsWith("hand")?.08:t.startsWith("foot")?.06:0};function qt(t,a,f,c){const r=[a[0]-c[0],a[2]-c[2]];return{forward:S(r[0]*t.facing[0]+r[1]*t.facing[2]),up:S(a[1]-f),side:S(r[0]*t.side[0]+r[1]*t.side[2])}}function se(t){const a=t.joints,f=[];if(!a.footL||!a.footR||!a.hips||!a.chest||!a.head)return{facts:f,ground:0,base:[0,0,0]};const c=.045*t.height,r=Math.min(t.ground,Math.min(a.footL[1],a.footR[1])-c),o=[a.hips[0],r,a.hips[2]],s=t.height,e=m=>m>a.head[1]+.08*s?"above the head":m>a.head[1]-.08*s?"at head height":m>a.chest[1]-.07*s?"at chest height":m>a.hips[1]-.05*s?"at waist height":m>r+.3*s?"at thigh height":"low, near the knees / floor";for(const m of["R","L"]){const k=a[`hand${m}`];if(!k)continue;const b=qt(t,k,r,o);f.push(`hand${m} ${e(k[1])}, ${b.forward>.15?`${S(b.forward)} m in front`:b.forward<-.15?`${S(-b.forward)} m behind`:"beside the body"}`)}const M=[a.chest[0]-a.hips[0],a.chest[1]-a.hips[1],a.chest[2]-a.hips[2]],p=M[0]*t.facing[0]+M[2]*t.facing[2],n=Math.round(Math.atan2(p,M[1])*180/Math.PI);f.push(Math.abs(n)<8?"torso upright":`torso leans ${n>0?"forward":"back"} ${Math.abs(n)}°`),f.push(`feet ${S(Math.hypot(a.footL[0]-a.footR[0],a.footL[2]-a.footR[2]))} m apart`);const d=Math.min(a.footL[1],a.footR[1])-c-t.ground;d>.08?f.push(`airborne: feet ${S(d)} m off the ground`):Math.abs(a.footL[1]-a.footR[1])>.12&&f.push(`one foot raised ${S(Math.abs(a.footL[1]-a.footR[1]))} m (${a.footL[1]>a.footR[1]?"footL":"footR"})`),f.push(`hips ${S(a.hips[1]-r)} m above the feet (standing ≈ ${S(.5*s)})`);const u=(m,k)=>{const b=m[0]*t.facing[0]+m[2]*t.facing[2],P=m[1],$=(m[0]*t.side[0]+m[2]*t.side[2])*(k==="L"?-1:1),j=[[b,"forward"],[-b,"back"],[P,"up"],[-P,"down"],[$,k?"out":"to its R side"],[-$,k?"in":"to its L side"]];return j.sort((E,R)=>R[0]-E[0]),j[1][0]>.45?`${j[0][1]}-${j[1][1]}`:j[0][1]};for(const m of["R","L"]){const k=t.axes[`hand${m}`],b=t.fingers[m];if(!k)continue;const P=Object.entries(wt).map(([$,j])=>[$,Math.abs(j.grip-b.grip)+Math.abs(j.index-b.index)+.5*Math.abs(j.thumb-b.thumb)]).sort(($,j)=>$[1]-j[1])[0][0];f.push(`hand${m} ${P}: fingers point ${u(k.main,m)}, palm faces ${u(k.second,m)}`)}for(const m of["R","L"]){const k=t.axes[`foot${m}`];k&&f.push(`foot${m} toes point ${u(k.main,m)}`)}const i=t.axes.head;if(i){const m=Math.round(Math.asin(Math.max(-1,Math.min(1,i.second[0]*t.side[0]+i.second[2]*t.side[2])))*180/Math.PI);f.push(`face looks ${u(i.main)}${Math.abs(m)>8?`, head tilted ${Math.abs(m)}° toward its ${m>0?"R":"L"} shoulder`:""}`)}return{facts:f,ground:r,base:o}}function ve(t,a){const f=a.getStage(),c=Mt(f),r=a.engine();let o;try{o=tt(f,String(t.name??""))}catch(n){return{ok:!1,error:n.message}}if(o.kind!=="person")return{ok:!1,error:`'${o.name}' is not a person`};if(!r)return{ok:!1,error:"the 3D view is not ready"};r.sync(f,null);const s=(Array.isArray(t.times)?t.times:[t.at??0]).slice(0,6).map(n=>Math.max(0,Math.min(c.duration,Number(n)||0))),e=f.items.filter(n=>n.kind==="person"&&n.id!==o.id),M=s.map(n=>{const d=r.jointsAt(n,o.id);if(!d)return{at_s:n,error:"not built"};const{facts:u,ground:i,base:m}=se(d),k=Object.fromEntries(Object.entries(d.joints).map(([$,j])=>[$,qt(d,j,i,m)])),b=[];for(const $ of e){const j=r.jointsAt(n,$.id);if(j)for(const E of["handR","handL","footR","footL"])for(const R of["head","chest","hips"]){const h=d.joints[E],N=R==="head"?j.headCentre:j.joints[R];if(!h||!N)continue;const y=Math.hypot(h[0]-N[0],h[1]-N[1],h[2]-N[2])-et.tip(E)-et.surface(R)*j.height/1.8;y<.45&&b.push({joint:E,other:$.name,part:R,gap_m:S(Math.max(0,y))})}}b.sort(($,j)=>$.gap_m-j.gap_m);const P=Object.fromEntries(ee.map($=>[$.id,d.joints[$.part]]).filter(([,$])=>!!$));return{at_s:n,facing:d.facing,controls:P,joints_world:d.joints,head_centre:d.headCentre,joints_local:k,axes:d.axes,fingers:d.fingers,reads:u,...b.length?{near_others:b.slice(0,6)}:{}}}),p=Gt(c,o.id);return{ok:!0,name:o.name,...p.length?{strikes:p}:{},frames:M,note:"joints_world = world metres (move_joint to); joints_local = metres in the person's frame: forward, up above its feet, side (+ toward its …R limbs). head = a point in front of the face (head_centre = the skull, for contact). near_others gap_m = the gap between the surfaces (0 = touching). axes: hand {main = fingers, second = palm}, foot {main = toes}, head {main = face, second = top of the head}, world unit vectors; fingers = curls 0..100. Check again after a fix."}}function de(t,a){const f=a.getStage(),c=Mt(f),r=a.engine();let o;try{o=tt(f,String(t.name??""))}catch(l){return{ok:!1,error:l.message}}if(o.kind!=="person")return{ok:!1,error:`'${o.name}' is not a person`};const s=t.control!=null?oe(t.control):null;if(t.control!=null&&!s)return{ok:!1,error:`control must be one of ${Tt.join(", ")}`};const e=s?.part??String(t.part??"");if(!Ft.includes(e))return{ok:!1,error:`give control (${Tt.join(", ")}) or part (${Ft.join(", ")})`};if(!r)return{ok:!1,error:"the 3D view is not ready"};r.sync(f,null);const M=Gt(c,o.id),p=t.at==="impact"?M.find(l=>l.limb===e)??M[0]:null;if(t.at==="impact"&&!p)return{ok:!1,error:`${o.name} plays no strike clip here: give at in seconds`};const n=p?p.at:Math.max(0,Math.min(c.duration,Number(t.at??0)||0)),d=r.jointsAt(n,o.id),u=d?.joints[e];if(!d||!u)return{ok:!1,error:`no ${e} on ${o.name}`};let i=null;if(Array.isArray(t.to)&&t.to.length===3)i=t.to.map(Number);else if(t.offset_m&&typeof t.offset_m=="object"){const l=t.offset_m,_=Number(l.forward)||0,g=Number(l.up)||0,v=Number(l.side)||0;i=[u[0]+_*d.facing[0]+v*d.side[0],u[1]+g,u[2]+_*d.facing[2]+v*d.side[2]]}else if(t.to_object&&typeof t.to_object=="object"){const l=t.to_object;let _;try{_=tt(f,String(l.name??""))}catch(C){return{ok:!1,error:C.message}}const g=String(l.part??"chest"),v=_.kind==="person"?r.jointsAt(n,_.id):null;if(i=v?(g==="head"?v.headCentre:v.joints[g])??null:r.worldPositionOf(_.id),!i)return{ok:!1,error:`no ${g} on ${_.name}`};const I=v?et.surface(g)*v.height/1.8:0,A=I+et.tip(e);if(A>0){const C=d.joints.chest??u,w=[C[0]-i[0],C[1]-i[1],C[2]-i[2]],x=Math.hypot(...w);x>.001&&(i=[i[0]+w[0]/x*A,i[1]+w[1]/x*A,i[2]+w[2]/x*A])}}if(i&&i.some(l=>!Number.isFinite(l)))return{ok:!1,error:"to must be 3 finite numbers"};const m=e.slice(-1),k=e==="handL"||e==="handR",b=e==="footL"||e==="footR",P=(l,_)=>{if(l==null)return null;if(Array.isArray(l)&&l.length===3&&l.every(A=>Number.isFinite(Number(A))))return l.map(Number);const g=String(l),v=m==="L"?-1:1,I={forward:d.facing,back:[-d.facing[0],0,-d.facing[2]],up:[0,1,0],down:[0,-1,0],out:[d.side[0]*v,0,d.side[2]*v],in:[-d.side[0]*v,0,-d.side[2]*v]};if(g==="target"){if(!i)return`${_} 'target' needs to / to_object`;const A=[i[0]-u[0],i[1]-u[1],i[2]-u[2]];return Math.hypot(...A)>.001?A:null}return I[g]??`${_} must be forward / back / up / down / in / out / target or [x, y, z]`},$=P(k?t.fingers:b?t.toes:e==="head"?t.face:void 0,k?"fingers":b?"toes":"face"),j=P(k?t.palm:void 0,"palm");for(const l of[$,j])if(typeof l=="string")return{ok:!1,error:l};if(!k&&!b&&e!=="head"&&(t.fingers||t.palm||t.toes||t.face))return{ok:!1,error:"fingers / palm are for a hand, toes for a foot, face for the head"};const E=t.hand_shape!=null?String(t.hand_shape):null;if(E&&(!k||!(E in wt)))return{ok:!1,error:`hand_shape is for a hand: ${Object.keys(wt).join(", ")}`};const R=$||j?{...$?{main:$}:{},...j?{second:j}:{}}:void 0,h=(e==="footL"||e==="footR")&&Number.isFinite(Number(t.roll_deg))&&Number(t.roll_deg)!==0?Math.max(-45,Math.min(70,Number(t.roll_deg))):0;if(!i&&!R&&!E&&!h)return{ok:!1,error:"give a target (to [x, y, z], offset_m {forward, up, side}, to_object {name, part}), a direction (fingers / palm, toes, face) or hand_shape"};const N=["moment","span","after"].includes(String(t.scope))?String(t.scope):e==="hips"?"after":"moment",y=c.duration,B=!!(c.objectKeys?.[o.id]?.length||c.clipSpans?.[o.id]?.length),ot=!!i&&B&&N==="moment"&&t.path!==!1&&(k||b),ct=Number(t.fade??.6),gt=Number(t.fade_out??.5),H=Math.max(0,n-ct-.25),W=Math.min(y,n+gt+.25),nt=Math.max(4,Math.round((W-H)*24)+1),G=Array.from({length:nt},(l,_)=>H+(W-H)*_/(nt-1)),z=Ht(r.jointPath(o.id,e,G),(W-H)/(G.length-1));let Q=null,O=u,J=0;if(ot&&t.align!==!1){const l=(c.clipSpans?.[o.id]||[]).find(x=>n>=x.start-.001&&n<=x.end+.001),_=l?l.start:Math.max(0,n-.7),g=Math.max(_+.05,Math.min(n,_+Number(t.warp_s??.6))),v=["footL","footR"].filter(x=>x!==e),I=[_,(_+g)/2,g,n],A=x=>{const U=r.jointPath(o.id,x,I);return U.every(Boolean)?U.slice(1).reduce((st,Y,dt)=>st+Math.hypot(Y[0]-U[dt][0],Y[2]-U[dt][2]),0):1/0},C=v.sort((x,U)=>A(x)-A(U))[0],w=r.jointPath(o.id,C,[n])[0];if(w){const x=u[0]-w[0],U=u[2]-w[2],st=i[0]-w[0],Y=i[2]-w[2],dt=Math.hypot(x,U),mt=Math.hypot(st,Y);if(dt>.12&&mt>.12){const lt=Math.max(-120,Math.min(120,((Math.atan2(st,Y)-Math.atan2(x,U))*180/Math.PI+540)%360-180)),$t=mt-dt,xt=Number(t.step_max_m??.05),Z=Math.max(-xt,Math.min(xt,$t)),Qt=st/mt,Vt=Y/mt;if(Math.abs($t-Z)>.12&&(J=S($t-Z)),Math.abs(lt)>2||Math.abs(Z)>.02){const Nt={scope:"after",start:g,end:g,fade:Math.max(Jt.min,g-_)},Xt=Math.max(1/24,(y-_)/(Bt.samples-2)),Ot=[],Et=[],Lt=[],At=[],Yt={...c,motionEdits:{...c.motionEdits,[o.id]:c.motionEdits?.[o.id]||[]}};for(let D=_;D<=y+1e-6;D+=Xt){const K=kt(Nt,D),ht=K*lt*Math.PI/180,ut=bt(o,Yt,y?D/y:0,f.items).position,It=ut[0]-w[0],Dt=ut[2]-w[2];Ot.push(Math.round(D*1e3)/1e3),Et.push(K*lt),Lt.push(w[0]+It*Math.cos(ht)+Dt*Math.sin(ht)-ut[0]+K*Z*Qt),At.push(w[2]-It*Math.sin(ht)+Dt*Math.cos(ht)-ut[2]+K*Z*Vt)}const Zt=a.getStage().shots.find(D=>D.id===c.id)?.motionEdits?.[o.id]||[],Rt={id:crypto.randomUUID(),scope:"after",start:g,end:g,fade:Nt.fade,track:{t:Ot,turn:Et,mx:Lt,mz:At},label:`${e}: align the strike`},Pt=_t(Zt,Rt,y);Pt.some(D=>D.id===Rt.id)&&(a.setStage(D=>({...D,shots:D.shots.map(K=>K.id===c.id?{...K,motionEdits:{...K.motionEdits,[o.id]:Pt}}:K)})),Q={turn_deg:Math.round(lt),step_m:S(Z),pivot:C},r.sync(a.getStage(),null),O=r.jointsAt(n,o.id)?.joints[e]??u)}}}}let V=0;if(ot&&t.level!==!1&&i&&O[1]-i[1]>.04){const l=(d?.height??1.8)/1.8,_=Math.min(.45,(O[1]-i[1])/(.45*l)),g=Number(t.fade??.5);Kt({name:o.name,at:n,scope:"moment",fade:g,fade_out:Math.max(.35,g*.8),stance:{crouch:Math.round(_*100)/100},label:`${e}: drop the level`},a).ok&&(V=Math.round(_*100)/100,r.sync(a.getStage(),null),O=r.jointsAt(n,o.id)?.joints[e]??O)}const at=i?Math.hypot(i[0]-O[0],i[1]-O[1],i[2]-O[2]):0,T=Number(t.fade??Math.min(.7,.45+.4*at)),it=Number(t.fade_out??Math.max(.35,T*.8)),L=h&&!i?(()=>{const l=r.rollFootAt(n,o.id,e,h,_=>({id:"__drag",scope:"moment",start:n,end:n,fade:T,..._}));return l?{fields:l.fields,miss:l.pivotMove,from:u,aimError:null}:null})():i||R?r.solveJointAt(n,o.id,e,i,l=>({id:"__drag",scope:"moment",start:n,end:n,fade:T,...l}),R,{lockFeet:t.lock_feet===!0}):{fields:{},miss:0,from:u,aimError:null};if(!L)return{ok:!1,error:`could not pose ${o.name} at ${n} s`};const q=L.fields,yt=E?ne(bt(o,c,c.duration?n/c.duration:0,f.items).pose,m,E)??{}:{},vt={...q.pose||{},...yt},St=[i?`→ ${i.map(l=>S(l)).join(", ")}`:"",R?"turned":"",E??""].filter(Boolean).join(" "),jt=!!i&&B&&N==="moment"&&t.path!==!1&&!["hips","head"].includes(e);let rt;if(jt){const l=Object.fromEntries(Object.entries(q.pose||{}).filter(([w])=>/^(wrist|ankle)/.test(w))),_={scope:"moment",start:n,end:n,fade:T,fadeOut:it},g=r.bakeJointPath(n,o.id,e,i,w=>kt(_,w),[n-T,n+it],{...l,...yt});if(!g)return{ok:!1,error:`could not pose ${o.name} along its path`};const v=a.getStage().shots.find(w=>w.id===c.id)?.motionEdits?.[o.id]||[],I={id:crypto.randomUUID(),scope:"moment",start:n,end:n,fade:T,fadeOut:it,track:g.track,label:String(t.label??`${e} ${St} (path)`)},A=_t(v,I,y),C=A.find(w=>w.id===I.id);if(!C)return{ok:!1,error:"the move changes nothing"};a.setStage(w=>({...w,shots:w.shots.map(x=>x.id===c.id?{...x,motionEdits:{...x.motionEdits,[o.id]:A}}:x)})),L.miss=g.miss,rt={ok:!0,name:o.name,edit:pt(C,n),edits:A.length,note:"carried along the motion's own path (keys untouched); edit_motion remove to drop it"}}else rt=Kt({name:o.name,at:n,scope:N,fade:T,fade_out:it,...t.start!=null?{start:t.start}:{},...t.end!=null?{end:t.end}:{},...Object.keys(vt).length?{joints:vt}:{},...q.move?{move_m:[q.move[0],q.move[2]]}:{},...q.stance?{stance:q.stance}:{},label:String(t.label??`${e} ${St}`)},a);if(!rt.ok)return rt;r.sync(a.getStage(),null);const X=Ht(r.jointPath(o.id,e,G),(W-H)/(G.length-1));let F="";if(i&&L.miss>.04){const l=d.joints.hips??u,_=i[0]-l[0],g=i[2]-l[2],v=Math.hypot(_,g),I=v>.05?Math.round(Math.atan2(_*d.facing[2]-g*d.facing[0],_*d.facing[0]+g*d.facing[2])*180/Math.PI):0;F=`${e} stays ${L.miss} m short (out of reach or at a joint limit)`+(Math.abs(I)>50?`: ${o.name} faces ${Math.abs(I)}° away from the target — turn first (${B?"edit_motion face_toward the target, scope span":`edit_motion turn_deg ${I}, scope span`}), then move_joint again`:`: the target is ${S(v)} m from the hips — step closer: edit_motion move_m [${S(_/v*(L.miss+.03))}, ${S(g/v*(L.miss+.03))}] (scope span), then move_joint again; or pick another time`)}J&&(F+=`${F?"; ":""}the fighters stand ${Math.abs(J)} m too ${J>0?"far apart":"close"} for this blow as the clip throws it: re-block their marks (stand_at / set_transform before the motion) rather than stretching the limb`),L.aimError!=null&&L.aimError>12&&(F+=`${F?"; ":""}${k?"the hand":b?"the foot":"the face"} points ${L.aimError}° off the asked direction (the wrist / ankle / neck limit) — turn the forearm (move_joint elbow) or the body first`);const ft=z&&X?{peak_speed_m_s:[z.speed,X.speed],peak_jerk:[z.jerk,X.jerk],jerk_change_pct:Math.round((X.jerk-z.jerk)/Math.max(1,z.jerk)*100)}:null;return ft&&X.jerk>z.jerk*1.5&&X.jerk>800&&(F+=`${F?"; ":""}the fix makes ${e} ${ft.jerk_change_pct}% jerkier — ${jt?"lengthen fade / fade_out":"try path mode (a moving person, scope moment) or lengthen fade / fade_out"}, face_toward first so less is corrected, or fix the motion itself`),{...rt,part:e,...Ut(e)?{control:Ut(e).id}:{},from:L.from,...i?{to:i.map(S),miss_m:L.miss}:{},...L.aimError!=null?{aim_error_deg:L.aimError}:{},...jt?{mode:"path"}:{},...Q?{aligned:Q}:{},...V?{lowered_crouch:V}:{},...ft?{smoothness:ft}:{},...F?{warning:F}:{}}}function Se(t,a){const f=t.engine();if(!f)return null;const c=a.filter(s=>(s.planned==="head"||s.planned==="body")&&s.limb&&/^(hand|foot)[LR]$/.test(s.limb)).sort((s,e)=>s.time-e.time),r=s=>{f.sync(t.getStage(),null);const e=t.getStage(),M=e.items.find(m=>m.name===s.attacker),p=e.items.find(m=>m.name===s.target),n=M&&f.jointsAt(s.time,M.id),d=p&&f.jointsAt(s.time,p.id),u=n?.joints[s.limb],i=s.planned==="head"?d?.headCentre:d?.joints.chest;return!u||!i||!d?null:S(Math.hypot(u[0]-i[0],u[1]-i[1],u[2]-i[2])-et.tip(s.limb)-et.surface(s.planned==="head"?"head":"chest")*d.height/1.8)},o=[];for(const s of c){const e=r(s);let M=e;for(let p=0;p<2&&M!=null&&Math.abs(M)>.015;p++){const n=a.filter(b=>b.attacker===s.attacker&&b!==s).map(b=>b.time),d=Math.max(-1/0,...n.filter(b=>b<s.time)),u=Math.min(1/0,...n.filter(b=>b>s.time)),i=Math.max(.15,Math.min(.45,.8*(s.time-d))),m=Math.max(.15,Math.min(.4,.8*(u-s.time)));if(!de({name:s.attacker,part:s.limb,at:s.time,to_object:{name:s.target,part:s.planned==="head"?"head":"chest"},align:!1,level:!1,fade:i,fade_out:m,label:"land the blow"},t).ok)break;M=r(s)}o.push({time_s:S(s.time),attacker:s.attacker,limb:s.limb,zone:s.planned,gap_before_m:e,gap_after_m:M})}return o}function xe(t,a){const f=a.getStage(),c=Mt(f);let r;try{r=tt(f,String(t.name??""))}catch(n){return{ok:!1,error:n.message}}if(r.kind!=="person")return{ok:!1,error:`'${r.name}' is not a person`};const o=Math.max(0,Math.min(c.duration,Number(t.at)||0)),s=c.duration?o/c.duration:0,e=t.breakdown_bias==null?null:Math.max(0,Math.min(1,Number(t.breakdown_bias))),M=e==null?ae(c,r,s):ie(c,r,s,e);if(!M)return{ok:!1,error:`no pose keys on both sides of ${o} s for a breakdown — set keys first (pose_key / set_pose)`};a.setStage(n=>({...n,shots:n.shots.map(d=>d.id===c.id?M:d)}));const p=M.objectKeys?.[r.id]||[];return{ok:!0,name:r.name,at_s:o,kind:e==null?"key":"breakdown",...e!=null?{bias:e}:{},keys_s:p.filter(n=>n.pose).map(n=>S(n.time*c.duration)).slice(0,40)}}export{Kt as editMotion,ve as inspectPose,Se as landBlows,de as moveJoint,xe as poseKey,Gt as strikesOf};
1
+ import{de as Mt,fg as tt,bU as te,cw as Jt,fh as Bt,a8 as bt,cB as kt,cC as _t,fi as Ct,cy as zt,cK as ee,fj as oe,fk as Tt,cG as Ft,cJ as wt,cO as ne,cH as Ut,cM as ae,cF as ie,fl as re}from"./remote-kxNNhmis.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-DJC95K48.js";import"./titleFrameBudget-BW-N1-cw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";const Wt=t=>Math.round(t*100)/100,pt=(t,a)=>({id:t.id,label:t.label??"",scope:t.scope,start_s:t.start,end_s:t.scope==="after"?null:t.end,fade_s:t.fade,...t.fadeOut!=null?{fade_out_s:t.fadeOut}:{},...t.track?{track:{from_s:t.track.t[0],to_s:t.track.t[t.track.t.length-1],samples:t.track.t.length,joints:Object.keys(t.track.pose||{}),...t.track.turn?{turn_deg_max:Math.round(Math.max(...t.track.turn.map(Math.abs)))}:{}}}:{},...t.off?{off:!0}:{},weight_now:Wt(kt(t,a)),...t.pose?{joints:t.pose}:{},...t.stance?{stance:t.stance}:{},...t.preset?{preset:t.preset}:{},...t.move?{move_m:[t.move[0],t.move[2]]}:{},...t.turn?{turn_deg:t.turn}:{}});function Kt(t,a){const f=a.getStage(),c=Mt(f),r=c.duration;let o;try{o=tt(f,String(t.name??""))}catch(h){return{ok:!1,error:h.message}}if(!te(o))return{ok:!1,error:`'${o.name}' is not a person (or a humanoid-rigged model)`};const s=c.motionEdits?.[o.id]||[],e=Math.max(0,Math.min(r,Number(t.at??0)||0)),M=h=>a.setStage(N=>({...N,shots:N.shots.map(y=>y.id===c.id?{...y,motionEdits:{...y.motionEdits,[o.id]:h}}:y)}));if(t.remove!=null){const h=String(t.remove),N=h==="all"?[]:s.filter(y=>y.id!==h);return N.length===s.length&&h!=="all"?{ok:!1,error:`no edit '${h}' on ${o.name}; edits: ${s.map(y=>y.id).join(", ")||"none"}`}:(M(N),{ok:!0,name:o.name,removed:h==="all"?s.length:1,edits:N.map(y=>pt(y,e))})}const p=t.id!=null?s.find(h=>h.id===String(t.id)):void 0;if(t.id!=null&&!p)return{ok:!1,error:`no edit '${String(t.id)}' on ${o.name}`};const n=["moment","span","after"].includes(String(t.scope))?String(t.scope):p?.scope??"moment",d=(c.clipSpans?.[o.id]||[]).find(h=>e>=h.start-.001&&e<=h.end+.001);let u=p?.start??e,i=p?.end??e;if((t.at!=null||!p)&&(u=e,i=e),n==="span"){if(t.start!=null||t.end!=null)u=Number(t.start??u),i=Number(t.end??i);else if(d)u=d.start,i=d.end;else if(!p)return{ok:!1,error:`no motion block at ${e} s on ${o.name}: give start and end for scope span`}}const m=Number(t.fade??p?.fade??Jt.default),k=t.fade_out!=null?Number(t.fade_out):p?.fadeOut;if(t.face_toward!=null){let h;try{h=tt(f,String(t.face_toward))}catch(O){return{ok:!1,error:O.message}}if(h.id===o.id)return{ok:!1,error:"face_toward another object"};const N=Math.max(0,Math.min(1,Number(t.face_strength??1))),y={scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{}},B=Math.max(0,u-m),ot=n==="after"?r:Math.min(r,i+(k??m)),ct=Math.min(Bt.samples,Math.max(2,Math.ceil((ot-B)*24)+1)),gt=s.filter(O=>O.id!==p?.id),H={...c,motionEdits:{...c.motionEdits,[o.id]:gt}},W=[],nt=[];for(let O=0;O<ct;O++){const J=B+(ot-B)*O/(ct-1),V=J/Math.max(1e-6,r),at=bt(o,H,V,f.items),T=bt(h,H,V,f.items),L=((Math.atan2(T.position[0]-at.position[0],T.position[2]-at.position[2])*180/Math.PI-(at.rotation[1]||0))%360+540)%360-180;W.push(Math.round(J*1e3)/1e3),nt.push(kt(y,J)*N*L)}const G={id:p?.id??crypto.randomUUID(),scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{},track:{t:W,turn:nt},label:String(t.label??`${o.name} faces ${h.name}`)},z=_t(s,G,r),Q=z.find(O=>O.id===G.id);return Q?(M(z),{ok:!0,name:o.name,edit:pt(Q,e),edits:z.length,...d?{motion_block:{label:d.label,start_s:d.start,end_s:d.end}}:{},note:"the heading follows the target frame by frame (keys untouched); inspect_pose to check, then move_joint for contact"}):{ok:!1,error:`${o.name} already faces ${h.name} there`}}const b={};for(const[h,N]of Object.entries(t.joints||{})){if(!(h in Ct)&&!/^(grip|index|thumb)[LR]$|^(headPitch|headRoll)$/.test(h))return{ok:!1,error:`unknown joint '${h}'; joints: ${Object.keys(Ct).join(", ")}`};Number.isFinite(Number(N))&&(b[h]=Number(N))}const P=t.preset!=null?t.preset==="none"?null:{id:String(t.preset),amount:Number(t.preset_amount??.7),...t.preset_arms?{arms:!0}:{}}:p?.preset;if(P&&!zt.some(h=>h.id===P.id))return{ok:!1,error:`unknown preset; use one of ${zt.map(h=>h.id).join(", ")}`};const $=Array.isArray(t.move_m)?[Number(t.move_m[0])||0,0,Number(t.move_m[1])||0]:p?.move,j={...p||{},id:p?.id??crypto.randomUUID(),scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{},...Object.keys(b).length?{pose:{...t.id!=null?p?.pose:{},...b}}:{},...t.stance?{stance:{...p?.stance||{},...t.stance}}:{},preset:P??void 0,move:$,...t.turn_deg!=null?{turn:Number(t.turn_deg)}:{},...typeof t.off=="boolean"?{off:t.off}:{},label:String(t.label??p?.label??"Agent")},E=_t(s,j,r),R=E.find(h=>h.id===j.id);return R?(M(E),{ok:!0,name:o.name,edit:pt(R,e),edits:E.length,...d?{motion_block:{label:d.label,start_s:d.start,end_s:d.end}}:{},note:"a correction on top of the motion (keys untouched); render_preview / check_shot to see it; edit_motion with id to refine, remove to drop it"}):{ok:!1,error:"the edit changes nothing: give joints, stance, preset, move_m or turn_deg"}}const S=t=>Math.round(t*1e3)/1e3;function Gt(t,a){return(t.clipSpans?.[a]||[]).flatMap(f=>{const c=re(f.clip),r=c?.strike;return!r||!c?.duration?[]:[{at:S(f.start+r.t*(f.end-f.start)/c.duration),limb:r.limb,zone:r.zone,cls:r.cls,clip:f.clip}]})}function Ht(t,a){if(t.some(e=>!e)||t.length<4)return null;const f=t,c=(e,M)=>e.map((p,n)=>(p-M[n])/a),r=f.slice(1).map((e,M)=>c(e,f[M])),o=r.slice(1).map((e,M)=>c(e,r[M])),s=o.slice(1).map((e,M)=>c(e,o[M]));return{speed:Wt(Math.max(...r.map(e=>Math.hypot(...e)))),jerk:Math.round(Math.max(0,...s.map(e=>Math.hypot(...e))))}}const et={surface:t=>({head:.1,chest:.13,hips:.14})[t]??.05,tip:t=>t.startsWith("hand")?.08:t.startsWith("foot")?.06:0};function qt(t,a,f,c){const r=[a[0]-c[0],a[2]-c[2]];return{forward:S(r[0]*t.facing[0]+r[1]*t.facing[2]),up:S(a[1]-f),side:S(r[0]*t.side[0]+r[1]*t.side[2])}}function se(t){const a=t.joints,f=[];if(!a.footL||!a.footR||!a.hips||!a.chest||!a.head)return{facts:f,ground:0,base:[0,0,0]};const c=.045*t.height,r=Math.min(t.ground,Math.min(a.footL[1],a.footR[1])-c),o=[a.hips[0],r,a.hips[2]],s=t.height,e=m=>m>a.head[1]+.08*s?"above the head":m>a.head[1]-.08*s?"at head height":m>a.chest[1]-.07*s?"at chest height":m>a.hips[1]-.05*s?"at waist height":m>r+.3*s?"at thigh height":"low, near the knees / floor";for(const m of["R","L"]){const k=a[`hand${m}`];if(!k)continue;const b=qt(t,k,r,o);f.push(`hand${m} ${e(k[1])}, ${b.forward>.15?`${S(b.forward)} m in front`:b.forward<-.15?`${S(-b.forward)} m behind`:"beside the body"}`)}const M=[a.chest[0]-a.hips[0],a.chest[1]-a.hips[1],a.chest[2]-a.hips[2]],p=M[0]*t.facing[0]+M[2]*t.facing[2],n=Math.round(Math.atan2(p,M[1])*180/Math.PI);f.push(Math.abs(n)<8?"torso upright":`torso leans ${n>0?"forward":"back"} ${Math.abs(n)}°`),f.push(`feet ${S(Math.hypot(a.footL[0]-a.footR[0],a.footL[2]-a.footR[2]))} m apart`);const d=Math.min(a.footL[1],a.footR[1])-c-t.ground;d>.08?f.push(`airborne: feet ${S(d)} m off the ground`):Math.abs(a.footL[1]-a.footR[1])>.12&&f.push(`one foot raised ${S(Math.abs(a.footL[1]-a.footR[1]))} m (${a.footL[1]>a.footR[1]?"footL":"footR"})`),f.push(`hips ${S(a.hips[1]-r)} m above the feet (standing ≈ ${S(.5*s)})`);const u=(m,k)=>{const b=m[0]*t.facing[0]+m[2]*t.facing[2],P=m[1],$=(m[0]*t.side[0]+m[2]*t.side[2])*(k==="L"?-1:1),j=[[b,"forward"],[-b,"back"],[P,"up"],[-P,"down"],[$,k?"out":"to its R side"],[-$,k?"in":"to its L side"]];return j.sort((E,R)=>R[0]-E[0]),j[1][0]>.45?`${j[0][1]}-${j[1][1]}`:j[0][1]};for(const m of["R","L"]){const k=t.axes[`hand${m}`],b=t.fingers[m];if(!k)continue;const P=Object.entries(wt).map(([$,j])=>[$,Math.abs(j.grip-b.grip)+Math.abs(j.index-b.index)+.5*Math.abs(j.thumb-b.thumb)]).sort(($,j)=>$[1]-j[1])[0][0];f.push(`hand${m} ${P}: fingers point ${u(k.main,m)}, palm faces ${u(k.second,m)}`)}for(const m of["R","L"]){const k=t.axes[`foot${m}`];k&&f.push(`foot${m} toes point ${u(k.main,m)}`)}const i=t.axes.head;if(i){const m=Math.round(Math.asin(Math.max(-1,Math.min(1,i.second[0]*t.side[0]+i.second[2]*t.side[2])))*180/Math.PI);f.push(`face looks ${u(i.main)}${Math.abs(m)>8?`, head tilted ${Math.abs(m)}° toward its ${m>0?"R":"L"} shoulder`:""}`)}return{facts:f,ground:r,base:o}}function ve(t,a){const f=a.getStage(),c=Mt(f),r=a.engine();let o;try{o=tt(f,String(t.name??""))}catch(n){return{ok:!1,error:n.message}}if(o.kind!=="person")return{ok:!1,error:`'${o.name}' is not a person`};if(!r)return{ok:!1,error:"the 3D view is not ready"};r.sync(f,null);const s=(Array.isArray(t.times)?t.times:[t.at??0]).slice(0,6).map(n=>Math.max(0,Math.min(c.duration,Number(n)||0))),e=f.items.filter(n=>n.kind==="person"&&n.id!==o.id),M=s.map(n=>{const d=r.jointsAt(n,o.id);if(!d)return{at_s:n,error:"not built"};const{facts:u,ground:i,base:m}=se(d),k=Object.fromEntries(Object.entries(d.joints).map(([$,j])=>[$,qt(d,j,i,m)])),b=[];for(const $ of e){const j=r.jointsAt(n,$.id);if(j)for(const E of["handR","handL","footR","footL"])for(const R of["head","chest","hips"]){const h=d.joints[E],N=R==="head"?j.headCentre:j.joints[R];if(!h||!N)continue;const y=Math.hypot(h[0]-N[0],h[1]-N[1],h[2]-N[2])-et.tip(E)-et.surface(R)*j.height/1.8;y<.45&&b.push({joint:E,other:$.name,part:R,gap_m:S(Math.max(0,y))})}}b.sort(($,j)=>$.gap_m-j.gap_m);const P=Object.fromEntries(ee.map($=>[$.id,d.joints[$.part]]).filter(([,$])=>!!$));return{at_s:n,facing:d.facing,controls:P,joints_world:d.joints,head_centre:d.headCentre,joints_local:k,axes:d.axes,fingers:d.fingers,reads:u,...b.length?{near_others:b.slice(0,6)}:{}}}),p=Gt(c,o.id);return{ok:!0,name:o.name,...p.length?{strikes:p}:{},frames:M,note:"joints_world = world metres (move_joint to); joints_local = metres in the person's frame: forward, up above its feet, side (+ toward its …R limbs). head = a point in front of the face (head_centre = the skull, for contact). near_others gap_m = the gap between the surfaces (0 = touching). axes: hand {main = fingers, second = palm}, foot {main = toes}, head {main = face, second = top of the head}, world unit vectors; fingers = curls 0..100. Check again after a fix."}}function de(t,a){const f=a.getStage(),c=Mt(f),r=a.engine();let o;try{o=tt(f,String(t.name??""))}catch(l){return{ok:!1,error:l.message}}if(o.kind!=="person")return{ok:!1,error:`'${o.name}' is not a person`};const s=t.control!=null?oe(t.control):null;if(t.control!=null&&!s)return{ok:!1,error:`control must be one of ${Tt.join(", ")}`};const e=s?.part??String(t.part??"");if(!Ft.includes(e))return{ok:!1,error:`give control (${Tt.join(", ")}) or part (${Ft.join(", ")})`};if(!r)return{ok:!1,error:"the 3D view is not ready"};r.sync(f,null);const M=Gt(c,o.id),p=t.at==="impact"?M.find(l=>l.limb===e)??M[0]:null;if(t.at==="impact"&&!p)return{ok:!1,error:`${o.name} plays no strike clip here: give at in seconds`};const n=p?p.at:Math.max(0,Math.min(c.duration,Number(t.at??0)||0)),d=r.jointsAt(n,o.id),u=d?.joints[e];if(!d||!u)return{ok:!1,error:`no ${e} on ${o.name}`};let i=null;if(Array.isArray(t.to)&&t.to.length===3)i=t.to.map(Number);else if(t.offset_m&&typeof t.offset_m=="object"){const l=t.offset_m,_=Number(l.forward)||0,g=Number(l.up)||0,v=Number(l.side)||0;i=[u[0]+_*d.facing[0]+v*d.side[0],u[1]+g,u[2]+_*d.facing[2]+v*d.side[2]]}else if(t.to_object&&typeof t.to_object=="object"){const l=t.to_object;let _;try{_=tt(f,String(l.name??""))}catch(C){return{ok:!1,error:C.message}}const g=String(l.part??"chest"),v=_.kind==="person"?r.jointsAt(n,_.id):null;if(i=v?(g==="head"?v.headCentre:v.joints[g])??null:r.worldPositionOf(_.id),!i)return{ok:!1,error:`no ${g} on ${_.name}`};const I=v?et.surface(g)*v.height/1.8:0,A=I+et.tip(e);if(A>0){const C=d.joints.chest??u,w=[C[0]-i[0],C[1]-i[1],C[2]-i[2]],x=Math.hypot(...w);x>.001&&(i=[i[0]+w[0]/x*A,i[1]+w[1]/x*A,i[2]+w[2]/x*A])}}if(i&&i.some(l=>!Number.isFinite(l)))return{ok:!1,error:"to must be 3 finite numbers"};const m=e.slice(-1),k=e==="handL"||e==="handR",b=e==="footL"||e==="footR",P=(l,_)=>{if(l==null)return null;if(Array.isArray(l)&&l.length===3&&l.every(A=>Number.isFinite(Number(A))))return l.map(Number);const g=String(l),v=m==="L"?-1:1,I={forward:d.facing,back:[-d.facing[0],0,-d.facing[2]],up:[0,1,0],down:[0,-1,0],out:[d.side[0]*v,0,d.side[2]*v],in:[-d.side[0]*v,0,-d.side[2]*v]};if(g==="target"){if(!i)return`${_} 'target' needs to / to_object`;const A=[i[0]-u[0],i[1]-u[1],i[2]-u[2]];return Math.hypot(...A)>.001?A:null}return I[g]??`${_} must be forward / back / up / down / in / out / target or [x, y, z]`},$=P(k?t.fingers:b?t.toes:e==="head"?t.face:void 0,k?"fingers":b?"toes":"face"),j=P(k?t.palm:void 0,"palm");for(const l of[$,j])if(typeof l=="string")return{ok:!1,error:l};if(!k&&!b&&e!=="head"&&(t.fingers||t.palm||t.toes||t.face))return{ok:!1,error:"fingers / palm are for a hand, toes for a foot, face for the head"};const E=t.hand_shape!=null?String(t.hand_shape):null;if(E&&(!k||!(E in wt)))return{ok:!1,error:`hand_shape is for a hand: ${Object.keys(wt).join(", ")}`};const R=$||j?{...$?{main:$}:{},...j?{second:j}:{}}:void 0,h=(e==="footL"||e==="footR")&&Number.isFinite(Number(t.roll_deg))&&Number(t.roll_deg)!==0?Math.max(-45,Math.min(70,Number(t.roll_deg))):0;if(!i&&!R&&!E&&!h)return{ok:!1,error:"give a target (to [x, y, z], offset_m {forward, up, side}, to_object {name, part}), a direction (fingers / palm, toes, face) or hand_shape"};const N=["moment","span","after"].includes(String(t.scope))?String(t.scope):e==="hips"?"after":"moment",y=c.duration,B=!!(c.objectKeys?.[o.id]?.length||c.clipSpans?.[o.id]?.length),ot=!!i&&B&&N==="moment"&&t.path!==!1&&(k||b),ct=Number(t.fade??.6),gt=Number(t.fade_out??.5),H=Math.max(0,n-ct-.25),W=Math.min(y,n+gt+.25),nt=Math.max(4,Math.round((W-H)*24)+1),G=Array.from({length:nt},(l,_)=>H+(W-H)*_/(nt-1)),z=Ht(r.jointPath(o.id,e,G),(W-H)/(G.length-1));let Q=null,O=u,J=0;if(ot&&t.align!==!1){const l=(c.clipSpans?.[o.id]||[]).find(x=>n>=x.start-.001&&n<=x.end+.001),_=l?l.start:Math.max(0,n-.7),g=Math.max(_+.05,Math.min(n,_+Number(t.warp_s??.6))),v=["footL","footR"].filter(x=>x!==e),I=[_,(_+g)/2,g,n],A=x=>{const U=r.jointPath(o.id,x,I);return U.every(Boolean)?U.slice(1).reduce((st,Y,dt)=>st+Math.hypot(Y[0]-U[dt][0],Y[2]-U[dt][2]),0):1/0},C=v.sort((x,U)=>A(x)-A(U))[0],w=r.jointPath(o.id,C,[n])[0];if(w){const x=u[0]-w[0],U=u[2]-w[2],st=i[0]-w[0],Y=i[2]-w[2],dt=Math.hypot(x,U),mt=Math.hypot(st,Y);if(dt>.12&&mt>.12){const lt=Math.max(-120,Math.min(120,((Math.atan2(st,Y)-Math.atan2(x,U))*180/Math.PI+540)%360-180)),$t=mt-dt,xt=Number(t.step_max_m??.05),Z=Math.max(-xt,Math.min(xt,$t)),Qt=st/mt,Vt=Y/mt;if(Math.abs($t-Z)>.12&&(J=S($t-Z)),Math.abs(lt)>2||Math.abs(Z)>.02){const Nt={scope:"after",start:g,end:g,fade:Math.max(Jt.min,g-_)},Xt=Math.max(1/24,(y-_)/(Bt.samples-2)),Ot=[],Et=[],Lt=[],At=[],Yt={...c,motionEdits:{...c.motionEdits,[o.id]:c.motionEdits?.[o.id]||[]}};for(let D=_;D<=y+1e-6;D+=Xt){const K=kt(Nt,D),ht=K*lt*Math.PI/180,ut=bt(o,Yt,y?D/y:0,f.items).position,It=ut[0]-w[0],Dt=ut[2]-w[2];Ot.push(Math.round(D*1e3)/1e3),Et.push(K*lt),Lt.push(w[0]+It*Math.cos(ht)+Dt*Math.sin(ht)-ut[0]+K*Z*Qt),At.push(w[2]-It*Math.sin(ht)+Dt*Math.cos(ht)-ut[2]+K*Z*Vt)}const Zt=a.getStage().shots.find(D=>D.id===c.id)?.motionEdits?.[o.id]||[],Rt={id:crypto.randomUUID(),scope:"after",start:g,end:g,fade:Nt.fade,track:{t:Ot,turn:Et,mx:Lt,mz:At},label:`${e}: align the strike`},Pt=_t(Zt,Rt,y);Pt.some(D=>D.id===Rt.id)&&(a.setStage(D=>({...D,shots:D.shots.map(K=>K.id===c.id?{...K,motionEdits:{...K.motionEdits,[o.id]:Pt}}:K)})),Q={turn_deg:Math.round(lt),step_m:S(Z),pivot:C},r.sync(a.getStage(),null),O=r.jointsAt(n,o.id)?.joints[e]??u)}}}}let V=0;if(ot&&t.level!==!1&&i&&O[1]-i[1]>.04){const l=(d?.height??1.8)/1.8,_=Math.min(.45,(O[1]-i[1])/(.45*l)),g=Number(t.fade??.5);Kt({name:o.name,at:n,scope:"moment",fade:g,fade_out:Math.max(.35,g*.8),stance:{crouch:Math.round(_*100)/100},label:`${e}: drop the level`},a).ok&&(V=Math.round(_*100)/100,r.sync(a.getStage(),null),O=r.jointsAt(n,o.id)?.joints[e]??O)}const at=i?Math.hypot(i[0]-O[0],i[1]-O[1],i[2]-O[2]):0,T=Number(t.fade??Math.min(.7,.45+.4*at)),it=Number(t.fade_out??Math.max(.35,T*.8)),L=h&&!i?(()=>{const l=r.rollFootAt(n,o.id,e,h,_=>({id:"__drag",scope:"moment",start:n,end:n,fade:T,..._}));return l?{fields:l.fields,miss:l.pivotMove,from:u,aimError:null}:null})():i||R?r.solveJointAt(n,o.id,e,i,l=>({id:"__drag",scope:"moment",start:n,end:n,fade:T,...l}),R,{lockFeet:t.lock_feet===!0}):{fields:{},miss:0,from:u,aimError:null};if(!L)return{ok:!1,error:`could not pose ${o.name} at ${n} s`};const q=L.fields,yt=E?ne(bt(o,c,c.duration?n/c.duration:0,f.items).pose,m,E)??{}:{},vt={...q.pose||{},...yt},St=[i?`→ ${i.map(l=>S(l)).join(", ")}`:"",R?"turned":"",E??""].filter(Boolean).join(" "),jt=!!i&&B&&N==="moment"&&t.path!==!1&&!["hips","head"].includes(e);let rt;if(jt){const l=Object.fromEntries(Object.entries(q.pose||{}).filter(([w])=>/^(wrist|ankle)/.test(w))),_={scope:"moment",start:n,end:n,fade:T,fadeOut:it},g=r.bakeJointPath(n,o.id,e,i,w=>kt(_,w),[n-T,n+it],{...l,...yt});if(!g)return{ok:!1,error:`could not pose ${o.name} along its path`};const v=a.getStage().shots.find(w=>w.id===c.id)?.motionEdits?.[o.id]||[],I={id:crypto.randomUUID(),scope:"moment",start:n,end:n,fade:T,fadeOut:it,track:g.track,label:String(t.label??`${e} ${St} (path)`)},A=_t(v,I,y),C=A.find(w=>w.id===I.id);if(!C)return{ok:!1,error:"the move changes nothing"};a.setStage(w=>({...w,shots:w.shots.map(x=>x.id===c.id?{...x,motionEdits:{...x.motionEdits,[o.id]:A}}:x)})),L.miss=g.miss,rt={ok:!0,name:o.name,edit:pt(C,n),edits:A.length,note:"carried along the motion's own path (keys untouched); edit_motion remove to drop it"}}else rt=Kt({name:o.name,at:n,scope:N,fade:T,fade_out:it,...t.start!=null?{start:t.start}:{},...t.end!=null?{end:t.end}:{},...Object.keys(vt).length?{joints:vt}:{},...q.move?{move_m:[q.move[0],q.move[2]]}:{},...q.stance?{stance:q.stance}:{},label:String(t.label??`${e} ${St}`)},a);if(!rt.ok)return rt;r.sync(a.getStage(),null);const X=Ht(r.jointPath(o.id,e,G),(W-H)/(G.length-1));let F="";if(i&&L.miss>.04){const l=d.joints.hips??u,_=i[0]-l[0],g=i[2]-l[2],v=Math.hypot(_,g),I=v>.05?Math.round(Math.atan2(_*d.facing[2]-g*d.facing[0],_*d.facing[0]+g*d.facing[2])*180/Math.PI):0;F=`${e} stays ${L.miss} m short (out of reach or at a joint limit)`+(Math.abs(I)>50?`: ${o.name} faces ${Math.abs(I)}° away from the target — turn first (${B?"edit_motion face_toward the target, scope span":`edit_motion turn_deg ${I}, scope span`}), then move_joint again`:`: the target is ${S(v)} m from the hips — step closer: edit_motion move_m [${S(_/v*(L.miss+.03))}, ${S(g/v*(L.miss+.03))}] (scope span), then move_joint again; or pick another time`)}J&&(F+=`${F?"; ":""}the fighters stand ${Math.abs(J)} m too ${J>0?"far apart":"close"} for this blow as the clip throws it: re-block their marks (stand_at / set_transform before the motion) rather than stretching the limb`),L.aimError!=null&&L.aimError>12&&(F+=`${F?"; ":""}${k?"the hand":b?"the foot":"the face"} points ${L.aimError}° off the asked direction (the wrist / ankle / neck limit) — turn the forearm (move_joint elbow) or the body first`);const ft=z&&X?{peak_speed_m_s:[z.speed,X.speed],peak_jerk:[z.jerk,X.jerk],jerk_change_pct:Math.round((X.jerk-z.jerk)/Math.max(1,z.jerk)*100)}:null;return ft&&X.jerk>z.jerk*1.5&&X.jerk>800&&(F+=`${F?"; ":""}the fix makes ${e} ${ft.jerk_change_pct}% jerkier — ${jt?"lengthen fade / fade_out":"try path mode (a moving person, scope moment) or lengthen fade / fade_out"}, face_toward first so less is corrected, or fix the motion itself`),{...rt,part:e,...Ut(e)?{control:Ut(e).id}:{},from:L.from,...i?{to:i.map(S),miss_m:L.miss}:{},...L.aimError!=null?{aim_error_deg:L.aimError}:{},...jt?{mode:"path"}:{},...Q?{aligned:Q}:{},...V?{lowered_crouch:V}:{},...ft?{smoothness:ft}:{},...F?{warning:F}:{}}}function Se(t,a){const f=t.engine();if(!f)return null;const c=a.filter(s=>(s.planned==="head"||s.planned==="body")&&s.limb&&/^(hand|foot)[LR]$/.test(s.limb)).sort((s,e)=>s.time-e.time),r=s=>{f.sync(t.getStage(),null);const e=t.getStage(),M=e.items.find(m=>m.name===s.attacker),p=e.items.find(m=>m.name===s.target),n=M&&f.jointsAt(s.time,M.id),d=p&&f.jointsAt(s.time,p.id),u=n?.joints[s.limb],i=s.planned==="head"?d?.headCentre:d?.joints.chest;return!u||!i||!d?null:S(Math.hypot(u[0]-i[0],u[1]-i[1],u[2]-i[2])-et.tip(s.limb)-et.surface(s.planned==="head"?"head":"chest")*d.height/1.8)},o=[];for(const s of c){const e=r(s);let M=e;for(let p=0;p<2&&M!=null&&Math.abs(M)>.015;p++){const n=a.filter(b=>b.attacker===s.attacker&&b!==s).map(b=>b.time),d=Math.max(-1/0,...n.filter(b=>b<s.time)),u=Math.min(1/0,...n.filter(b=>b>s.time)),i=Math.max(.15,Math.min(.45,.8*(s.time-d))),m=Math.max(.15,Math.min(.4,.8*(u-s.time)));if(!de({name:s.attacker,part:s.limb,at:s.time,to_object:{name:s.target,part:s.planned==="head"?"head":"chest"},align:!1,level:!1,fade:i,fade_out:m,label:"land the blow"},t).ok)break;M=r(s)}o.push({time_s:S(s.time),attacker:s.attacker,limb:s.limb,zone:s.planned,gap_before_m:e,gap_after_m:M})}return o}function xe(t,a){const f=a.getStage(),c=Mt(f);let r;try{r=tt(f,String(t.name??""))}catch(n){return{ok:!1,error:n.message}}if(r.kind!=="person")return{ok:!1,error:`'${r.name}' is not a person`};const o=Math.max(0,Math.min(c.duration,Number(t.at)||0)),s=c.duration?o/c.duration:0,e=t.breakdown_bias==null?null:Math.max(0,Math.min(1,Number(t.breakdown_bias))),M=e==null?ae(c,r,s):ie(c,r,s,e);if(!M)return{ok:!1,error:`no pose keys on both sides of ${o} s for a breakdown — set keys first (pose_key / set_pose)`};a.setStage(n=>({...n,shots:n.shots.map(d=>d.id===c.id?M:d)}));const p=M.objectKeys?.[r.id]||[];return{ok:!0,name:r.name,at_s:o,kind:e==null?"key":"breakdown",...e!=null?{bias:e}:{},keys_s:p.filter(n=>n.pose).map(n=>S(n.time*c.duration)).slice(0,40)}}export{Kt as editMotion,ve as inspectPose,Se as landBlows,de as moveJoint,xe as poseKey,Gt as strikesOf};
@@ -1 +1 @@
1
- import{_ as P}from"./titleFrameBudget-DsM0V482.js";import{readUpscaleModel as C}from"./store-Cug4GGcP.js";import{I as D,A as R,U as B,B as U,c as V,Q as X}from"./id3-arvEpAg7.js";import{O as Q,B as F,a as N}from"./output-p-Q7qous.js";import{C as Y}from"./conversion-4rhF3xRJ.js";const j=["photo","anime"],I=4,q=2048,z=8192,E=1080,G=256,K=12,x=n=>Math.max(2,Math.round(n/2)*2);function O({width:n,height:u,kind:c="image",scale:r=2,model:i="photo"}={}){const t=Math.round(Number(n)),o=Math.round(Number(u));if(!(t>0&&o>0))return{error:"no size"};if(!j.includes(i))return{error:"model"};if(c==="video"){const p=Math.min(t,o);if(p>=E)return{error:"already sharp"};const f=Math.min(2,E/p),a=x(t*f),m=x(o*f),w=Math.min(1,a/I/t);return{model:i,kind:c,inW:x(t*w),inH:x(o*w),outW:a,outH:m,scale:Math.round(a/t*100)/100}}const e=r===4?4:2,s=Math.min(1,z/(Math.max(t,o)*e)),h=Math.max(1,Math.round(t*e*s)),l=Math.max(1,Math.round(o*e*s)),d=Math.min(1,q/Math.max(t,o));return{model:i,kind:c,inW:Math.max(1,Math.round(t*d)),inH:Math.max(1,Math.round(o*d)),outW:h,outH:l,scale:Math.round(h/t*100)/100}}function $(n,u,c=G,r=K){const i=[];for(let t=0;t<u;t+=c)for(let o=0;o<n;o+=c){const e=Math.min(c,n-o),s=Math.min(c,u-t),h=Math.max(0,o-r),l=Math.max(0,t-r),d=Math.min(n,o+e+r),p=Math.min(u,t+s+r);i.push({x:h,y:l,w:d-h,h:p-l,keepX:o-h,keepY:t-l,keepW:e,keepH:s})}return i}const J="1.31.1",W=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${J}/dist/`;let _=null;const Z=()=>_??=(async()=>{const n=await P(()=>import(`${W}ort.webgpu.min.mjs`),[]);return n.env.wasm.wasmPaths=W,n.env.wasm.numThreads=globalThis.crossOriginIsolated?Math.min(4,navigator.hardwareConcurrency||1):1,n})().catch(n=>{throw _=null,n}),H=new Map;function T(n){const u=globalThis.__upscaleEngine;if(u)return Promise.resolve({run:(r,i,t)=>u.run(n,r,i,t),backend:"stub"});let c=H.get(n);return c||(c=(async()=>{const[r,i]=await Promise.all([Z(),C(n)]);let t=null,o="webgpu";return navigator.gpu&&(t=await r.InferenceSession.create(i,{executionProviders:["webgpu"],graphOptimizationLevel:"all"}).catch(()=>null)),t||(o="wasm",t=await r.InferenceSession.create(i,{executionProviders:["wasm"],graphOptimizationLevel:"all"})),{backend:o,async run(e,s,h){const l=new r.Tensor("float32",e,[1,3,h,s]),d=await t.run({input:l});try{return await d.output.getData()}finally{d.output.dispose?.()}}}})(),c.catch(()=>H.delete(n)),H.set(n,c)),c}const b=(n,u)=>new OffscreenCanvas(n,u),v=n=>n.getContext("2d",{willReadFrequently:!0});function tt(n,u,c){const r=u*c,i=new Float32Array(3*r);for(let t=0;t<r;t++)i[t]=n[4*t]/255,i[r+t]=n[4*t+1]/255,i[2*r+t]=n[4*t+2]/255;return i}function nt(n,u,c){const r=u*c,i=new ImageData(u,c),t=i.data;for(let o=0;o<r;o++)t[4*o]=n[o]*255+.5,t[4*o+1]=n[r+o]*255+.5,t[4*o+2]=n[2*r+o]*255+.5,t[4*o+3]=255;return i}async function S(n,u,c,r,i,t,o,e,s){const h=$(c,r),l=t/c,d=o/r;i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";let p=null;for(let f=0;f<h.length;f++){if(s?.aborted)throw new DOMException("Upscale cancelled","AbortError");const a=h[f],m=I,w=await n.run(tt(u.getImageData(a.x,a.y,a.w,a.h).data,a.w,a.h),a.w,a.h);(!p||p.width!==a.w*m||p.height!==a.h*m)&&(p=b(a.w*m,a.h*m)),v(p).putImageData(nt(w,a.w*m,a.h*m),0,0);const k=a.x+a.keepX,M=a.y+a.keepY,y=Math.round(k*l),g=Math.round(M*d),A=Math.round((k+a.keepW)*l),L=Math.round((M+a.keepH)*d);i.drawImage(p,a.keepX*m,a.keepY*m,a.keepW*m,a.keepH*m,y,g,A-y,L-g),e?.(f+1,h.length)}}async function st(n,{scale:u=2,model:c="photo",onProgress:r,signal:i}={}){const t=performance.now(),o=typeof n=="string"?await(await fetch(n,{signal:i})).blob():n,e=await createImageBitmap(o),s=O({width:e.width,height:e.height,kind:"image",scale:u,model:c});if(s.error!==void 0)throw Error(s.error);const h=await T(c),l=b(s.inW,s.inH),d=v(l);d.imageSmoothingQuality="high",d.drawImage(e,0,0,s.inW,s.inH),e.close();const p=b(s.outW,s.outH);await S(h,d,s.inW,s.inH,v(p),s.outW,s.outH,(m,w)=>r?.({fraction:m/w}),i);const f=s.outW*s.outH>16e6;return{blob:await p.convertToBlob(f?{type:"image/jpeg",quality:.95}:{type:"image/png"}),width:s.outW,height:s.outH,backend:h.backend,seconds:(performance.now()-t)/1e3}}async function ct(n,{model:u="photo",onProgress:c,signal:r}={}){const i=performance.now(),t=new D({source:typeof n=="string"?new B(n):new U(n),formats:R});try{const o=await t.getPrimaryVideoTrack();if(!o)throw Error("no video track");const e=O({width:o.displayWidth,height:o.displayHeight,kind:"video",model:u});if(e.error!==void 0)throw Error(e.error);const s=await t.computeDuration(),h=await T(u),l=b(e.inW,e.inH),d=v(l),p=b(e.outW,e.outH),f=v(p);d.imageSmoothingQuality="high";const a=await V("avc",{width:e.outW,height:e.outH}).catch(()=>!1),m=new Q({format:new N({fastStart:"in-memory"}),target:new F}),w=await Y.init({input:t,output:m,video:{forceTranscode:!0,quality:X,...a?{codec:"avc"}:{},processedWidth:e.outW,processedHeight:e.outH,process:async g=>(g.draw(d,0,0,e.inW,e.inH),await S(h,d,e.inW,e.inH,f,e.outW,e.outH,void 0,r),p)}});if(!w.isValid)throw Error("This video cannot be converted here");const k=w.discardedTracks.some(g=>g.track.type==="audio");w.onProgress=g=>c?.({fraction:g});const M=()=>{w.cancel()};r?.addEventListener("abort",M,{once:!0});try{await w.execute()}finally{r?.removeEventListener("abort",M)}const y=m.target.buffer;if(!y)throw Error("no output");return{blob:new Blob([y],{type:"video/mp4"}),width:e.outW,height:e.outH,duration:s,backend:h.backend,seconds:(performance.now()-i)/1e3,soundDropped:k}}finally{t.dispose?.()}}export{J as UPSCALE_ORT_VERSION,nt as fromCHW,tt as toCHW,st as upscaleImage,T as upscaleRunner,ct as upscaleVideo};
1
+ import{_ as P}from"./titleFrameBudget-BW-N1-cw.js";import{readUpscaleModel as C}from"./store-Cug4GGcP.js";import{I as D,A as R,U as B,B as U,c as V,Q as X}from"./id3-arvEpAg7.js";import{O as Q,B as F,a as N}from"./output-p-Q7qous.js";import{C as Y}from"./conversion-4rhF3xRJ.js";const j=["photo","anime"],I=4,q=2048,z=8192,E=1080,G=256,K=12,x=n=>Math.max(2,Math.round(n/2)*2);function O({width:n,height:u,kind:c="image",scale:r=2,model:i="photo"}={}){const t=Math.round(Number(n)),o=Math.round(Number(u));if(!(t>0&&o>0))return{error:"no size"};if(!j.includes(i))return{error:"model"};if(c==="video"){const p=Math.min(t,o);if(p>=E)return{error:"already sharp"};const f=Math.min(2,E/p),a=x(t*f),m=x(o*f),w=Math.min(1,a/I/t);return{model:i,kind:c,inW:x(t*w),inH:x(o*w),outW:a,outH:m,scale:Math.round(a/t*100)/100}}const e=r===4?4:2,s=Math.min(1,z/(Math.max(t,o)*e)),h=Math.max(1,Math.round(t*e*s)),l=Math.max(1,Math.round(o*e*s)),d=Math.min(1,q/Math.max(t,o));return{model:i,kind:c,inW:Math.max(1,Math.round(t*d)),inH:Math.max(1,Math.round(o*d)),outW:h,outH:l,scale:Math.round(h/t*100)/100}}function $(n,u,c=G,r=K){const i=[];for(let t=0;t<u;t+=c)for(let o=0;o<n;o+=c){const e=Math.min(c,n-o),s=Math.min(c,u-t),h=Math.max(0,o-r),l=Math.max(0,t-r),d=Math.min(n,o+e+r),p=Math.min(u,t+s+r);i.push({x:h,y:l,w:d-h,h:p-l,keepX:o-h,keepY:t-l,keepW:e,keepH:s})}return i}const J="1.31.1",W=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${J}/dist/`;let _=null;const Z=()=>_??=(async()=>{const n=await P(()=>import(`${W}ort.webgpu.min.mjs`),[]);return n.env.wasm.wasmPaths=W,n.env.wasm.numThreads=globalThis.crossOriginIsolated?Math.min(4,navigator.hardwareConcurrency||1):1,n})().catch(n=>{throw _=null,n}),H=new Map;function T(n){const u=globalThis.__upscaleEngine;if(u)return Promise.resolve({run:(r,i,t)=>u.run(n,r,i,t),backend:"stub"});let c=H.get(n);return c||(c=(async()=>{const[r,i]=await Promise.all([Z(),C(n)]);let t=null,o="webgpu";return navigator.gpu&&(t=await r.InferenceSession.create(i,{executionProviders:["webgpu"],graphOptimizationLevel:"all"}).catch(()=>null)),t||(o="wasm",t=await r.InferenceSession.create(i,{executionProviders:["wasm"],graphOptimizationLevel:"all"})),{backend:o,async run(e,s,h){const l=new r.Tensor("float32",e,[1,3,h,s]),d=await t.run({input:l});try{return await d.output.getData()}finally{d.output.dispose?.()}}}})(),c.catch(()=>H.delete(n)),H.set(n,c)),c}const b=(n,u)=>new OffscreenCanvas(n,u),v=n=>n.getContext("2d",{willReadFrequently:!0});function tt(n,u,c){const r=u*c,i=new Float32Array(3*r);for(let t=0;t<r;t++)i[t]=n[4*t]/255,i[r+t]=n[4*t+1]/255,i[2*r+t]=n[4*t+2]/255;return i}function nt(n,u,c){const r=u*c,i=new ImageData(u,c),t=i.data;for(let o=0;o<r;o++)t[4*o]=n[o]*255+.5,t[4*o+1]=n[r+o]*255+.5,t[4*o+2]=n[2*r+o]*255+.5,t[4*o+3]=255;return i}async function S(n,u,c,r,i,t,o,e,s){const h=$(c,r),l=t/c,d=o/r;i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";let p=null;for(let f=0;f<h.length;f++){if(s?.aborted)throw new DOMException("Upscale cancelled","AbortError");const a=h[f],m=I,w=await n.run(tt(u.getImageData(a.x,a.y,a.w,a.h).data,a.w,a.h),a.w,a.h);(!p||p.width!==a.w*m||p.height!==a.h*m)&&(p=b(a.w*m,a.h*m)),v(p).putImageData(nt(w,a.w*m,a.h*m),0,0);const k=a.x+a.keepX,M=a.y+a.keepY,y=Math.round(k*l),g=Math.round(M*d),A=Math.round((k+a.keepW)*l),L=Math.round((M+a.keepH)*d);i.drawImage(p,a.keepX*m,a.keepY*m,a.keepW*m,a.keepH*m,y,g,A-y,L-g),e?.(f+1,h.length)}}async function st(n,{scale:u=2,model:c="photo",onProgress:r,signal:i}={}){const t=performance.now(),o=typeof n=="string"?await(await fetch(n,{signal:i})).blob():n,e=await createImageBitmap(o),s=O({width:e.width,height:e.height,kind:"image",scale:u,model:c});if(s.error!==void 0)throw Error(s.error);const h=await T(c),l=b(s.inW,s.inH),d=v(l);d.imageSmoothingQuality="high",d.drawImage(e,0,0,s.inW,s.inH),e.close();const p=b(s.outW,s.outH);await S(h,d,s.inW,s.inH,v(p),s.outW,s.outH,(m,w)=>r?.({fraction:m/w}),i);const f=s.outW*s.outH>16e6;return{blob:await p.convertToBlob(f?{type:"image/jpeg",quality:.95}:{type:"image/png"}),width:s.outW,height:s.outH,backend:h.backend,seconds:(performance.now()-t)/1e3}}async function ct(n,{model:u="photo",onProgress:c,signal:r}={}){const i=performance.now(),t=new D({source:typeof n=="string"?new B(n):new U(n),formats:R});try{const o=await t.getPrimaryVideoTrack();if(!o)throw Error("no video track");const e=O({width:o.displayWidth,height:o.displayHeight,kind:"video",model:u});if(e.error!==void 0)throw Error(e.error);const s=await t.computeDuration(),h=await T(u),l=b(e.inW,e.inH),d=v(l),p=b(e.outW,e.outH),f=v(p);d.imageSmoothingQuality="high";const a=await V("avc",{width:e.outW,height:e.outH}).catch(()=>!1),m=new Q({format:new N({fastStart:"in-memory"}),target:new F}),w=await Y.init({input:t,output:m,video:{forceTranscode:!0,quality:X,...a?{codec:"avc"}:{},processedWidth:e.outW,processedHeight:e.outH,process:async g=>(g.draw(d,0,0,e.inW,e.inH),await S(h,d,e.inW,e.inH,f,e.outW,e.outH,void 0,r),p)}});if(!w.isValid)throw Error("This video cannot be converted here");const k=w.discardedTracks.some(g=>g.track.type==="audio");w.onProgress=g=>c?.({fraction:g});const M=()=>{w.cancel()};r?.addEventListener("abort",M,{once:!0});try{await w.execute()}finally{r?.removeEventListener("abort",M)}const y=m.target.buffer;if(!y)throw Error("no output");return{blob:new Blob([y],{type:"video/mp4"}),width:e.outW,height:e.outH,duration:s,backend:h.backend,seconds:(performance.now()-i)/1e3,soundDropped:k}}finally{t.dispose?.()}}export{J as UPSCALE_ORT_VERSION,nt as fromCHW,tt as toCHW,st as upscaleImage,T as upscaleRunner,ct as upscaleVideo};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GLTFExporter-BuGYM-Ik.js","assets/three.module-Bx43vjkH.js"])))=>i.map(i=>d[i]);
2
- import{_ as T}from"./titleFrameBudget-DsM0V482.js";import{at as x}from"./remote-8XzEAnAJ.js";import{Mesh as g,Color as D,CanvasTexture as y,SRGBColorSpace as M,NoColorSpace as _}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";async function d(e,n=15e3){const i=performance.now();for(;!(e.image&&(e.image.complete??!0)&&(e.image.naturalWidth??e.image.width??0)>0);){if(performance.now()-i>n)return null;await new Promise(a=>setTimeout(a,50))}return e.image}function b(e){const n=e.naturalWidth||e.width,i=e.naturalHeight||e.height,a=document.createElement("canvas");a.width=n,a.height=i;const r=a.getContext("2d",{willReadFrequently:!0});return r.drawImage(e,0,0),{c:a,g:r,data:r.getImageData(0,0,n,i),w:n,h:i}}const f=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,w=(e,n,i)=>{const a=Math.min(1,Math.max(0,(i-e)/(n-e)));return a*a*(3-2*a)};function S(e,n){const{c:i,g:a,data:r}=b(e),p=new D(n),t=r.data;for(let s=0;s<t.length;s+=4){const m=f(t[s]/255)-p.r,l=f(t[s+1]/255)-p.g,o=f(t[s+2]/255)-p.b;Math.hypot(m,l,o)<.09&&(t[s+3]=0)}a.putImageData(r,0,0);const u=new y(i);return u.colorSpace=M,u.flipY=!0,u}function k(e){const{c:n,g:i,data:a}=b(e),r=a.data;for(let t=0;t<r.length;t+=4){const u=f(r[t]/255),s=f(r[t+1]/255),m=f(r[t+2]/255),l=.2126*u+.7152*s+.0722*m,o=Math.max(u,s,m),h=Math.min(u,s,m),c=w(.12,.32,l)*(1-w(.55,.85,o>0?(o-h)/o:0));r[t]=255,r[t+1]=Math.round((.07+(.62-.07)*c)*255),r[t+2]=0,r[t+3]=255}i.putImageData(a,0,0);const p=new y(n);return p.colorSpace=_,p.flipY=!0,p}async function H(e){const n=x(e),i=new Map,a=[];n.traverse(t=>{t instanceof g&&a.push(t)});for(const t of a){const u=Array.isArray(t.material)?t.material:[t.material],s=[];for(const m of u){let l=i.get(m);if(!l){l=m;const o=m;if(o.map&&(o.userData.keyout||o.userData.autoFinish)){const h=await d(o.map);if(h){const c=o.clone();c.onBeforeCompile=()=>{},o.userData.keyout&&(c.map=S(h,o.userData.keyout),c.alphaTest=.5,c.transparent=!1),o.userData.autoFinish&&(c.roughness=1,c.roughnessMap=k(h),c.clearcoat=.25),l=c}}else o.map&&await d(o.map);i.set(m,l)}s.push(l)}t.material=Array.isArray(t.material)?s:s[0]}const{GLTFExporter:r}=await T(async()=>{const{GLTFExporter:t}=await import("./GLTFExporter-BuGYM-Ik.js");return{GLTFExporter:t}},__vite__mapDeps([0,1])),p=await new r().parseAsync(n,{binary:!0,maxTextureSize:4096});return n.traverse(t=>{t instanceof g&&t.geometry.dispose()}),new Blob([p],{type:"model/gltf-binary"})}export{H as recipeGlb};
2
+ import{_ as T}from"./titleFrameBudget-BW-N1-cw.js";import{at as x}from"./remote-kxNNhmis.js";import{Mesh as g,Color as D,CanvasTexture as y,SRGBColorSpace as M,NoColorSpace as _}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-DJC95K48.js";import"./gltfLoader-U0Eebg7v.js";import"./store-xR02oY0m.js";import"./rotoMaskStore-RmW40Pcn.js";import"./sceneTrack-DyVxpl7i.js";import"./timelineOps-CEGk2t4h.js";import"./cameraTracker-DFjnZ7tw.js";import"./textAnimators-CeMuG34D.js";import"./timelineComp-D8PHGHgQ.js";import"./rigTrack-B9r9wrdV.js";import"./clientJobs-CuuUyhEy.js";async function d(e,n=15e3){const i=performance.now();for(;!(e.image&&(e.image.complete??!0)&&(e.image.naturalWidth??e.image.width??0)>0);){if(performance.now()-i>n)return null;await new Promise(a=>setTimeout(a,50))}return e.image}function b(e){const n=e.naturalWidth||e.width,i=e.naturalHeight||e.height,a=document.createElement("canvas");a.width=n,a.height=i;const r=a.getContext("2d",{willReadFrequently:!0});return r.drawImage(e,0,0),{c:a,g:r,data:r.getImageData(0,0,n,i),w:n,h:i}}const f=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,w=(e,n,i)=>{const a=Math.min(1,Math.max(0,(i-e)/(n-e)));return a*a*(3-2*a)};function S(e,n){const{c:i,g:a,data:r}=b(e),p=new D(n),t=r.data;for(let s=0;s<t.length;s+=4){const m=f(t[s]/255)-p.r,l=f(t[s+1]/255)-p.g,o=f(t[s+2]/255)-p.b;Math.hypot(m,l,o)<.09&&(t[s+3]=0)}a.putImageData(r,0,0);const u=new y(i);return u.colorSpace=M,u.flipY=!0,u}function k(e){const{c:n,g:i,data:a}=b(e),r=a.data;for(let t=0;t<r.length;t+=4){const u=f(r[t]/255),s=f(r[t+1]/255),m=f(r[t+2]/255),l=.2126*u+.7152*s+.0722*m,o=Math.max(u,s,m),h=Math.min(u,s,m),c=w(.12,.32,l)*(1-w(.55,.85,o>0?(o-h)/o:0));r[t]=255,r[t+1]=Math.round((.07+(.62-.07)*c)*255),r[t+2]=0,r[t+3]=255}i.putImageData(a,0,0);const p=new y(n);return p.colorSpace=_,p.flipY=!0,p}async function H(e){const n=x(e),i=new Map,a=[];n.traverse(t=>{t instanceof g&&a.push(t)});for(const t of a){const u=Array.isArray(t.material)?t.material:[t.material],s=[];for(const m of u){let l=i.get(m);if(!l){l=m;const o=m;if(o.map&&(o.userData.keyout||o.userData.autoFinish)){const h=await d(o.map);if(h){const c=o.clone();c.onBeforeCompile=()=>{},o.userData.keyout&&(c.map=S(h,o.userData.keyout),c.alphaTest=.5,c.transparent=!1),o.userData.autoFinish&&(c.roughness=1,c.roughnessMap=k(h),c.clearcoat=.25),l=c}}else o.map&&await d(o.map);i.set(m,l)}s.push(l)}t.material=Array.isArray(t.material)?s:s[0]}const{GLTFExporter:r}=await T(async()=>{const{GLTFExporter:t}=await import("./GLTFExporter-BuGYM-Ik.js");return{GLTFExporter:t}},__vite__mapDeps([0,1])),p=await new r().parseAsync(n,{binary:!0,maxTextureSize:4096});return n.traverse(t=>{t instanceof g&&t.geometry.dispose()}),new Blob([p],{type:"model/gltf-binary"})}export{H as recipeGlb};