clipoox-render 0.4.4 → 0.4.6

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 (116) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +1512 -1292
  3. package/web/assets/{FxEmbed-DbfuM8Yo.js → FxEmbed-ROS6C_HI.js} +1 -1
  4. package/web/assets/{MotionEmbed-CBQ-8Tzh.js → MotionEmbed-E2hCysi-.js} +1 -1
  5. package/web/assets/{PluginStore-OOEx0lP5.js → PluginStore-CwUSpwPp.js} +1 -1
  6. package/web/assets/{ShotComposer-Cng515xa.js → ShotComposer-DLxWpdYH.js} +8 -8
  7. package/web/assets/{TemplateEmbed-hjwM2b0o.js → TemplateEmbed-qG1AXdtf.js} +1 -1
  8. package/web/assets/{TimelinePlugins-D-NakABP.js → TimelinePlugins-CB1b6-Cb.js} +3 -3
  9. package/web/assets/{TimelineShotFx-D3kGhHN3.js → TimelineShotFx-CyHTgJHj.js} +2 -2
  10. package/web/assets/{TransitionEmbed-DR26yI3a.js → TransitionEmbed-Dym9P7--.js} +1 -1
  11. package/web/assets/{Whiteboard-BhxY0D0Z.js → Whiteboard-BdGjJZXW.js} +1 -1
  12. package/web/assets/{aerial-BisYSXzG.js → aerial-yLD_gDzw.js} +2 -2
  13. package/web/assets/{agentTools-CPFQeiDP.js → agentTools-B7g6tXTR.js} +2 -2
  14. package/web/assets/{aiInbetween-AOOM1e6p.js → aiInbetween-6eKDYbYS.js} +2 -2
  15. package/web/assets/{analyzerRun-Dtp2o7gT.js → analyzerRun-Cr-_79RH.js} +1 -1
  16. package/web/assets/{analyzerSandbox-BG_3Cea1.js → analyzerSandbox-N92T6amg.js} +1 -1
  17. package/web/assets/{api-BFN7blbw.js → api-Dnl2uaKO.js} +3 -3
  18. package/web/assets/auraTrack-C8eAEIWQ.js +1 -0
  19. package/web/assets/{breakthrough-0qFpZW-V.js → breakthrough-DSiuVwEX.js} +2 -2
  20. package/web/assets/{cameraPresets-eK3mP7qb.js → cameraPresets-Cfn7qhXK.js} +1 -1
  21. package/web/assets/{cameraTracker-BAQHuTV-.js → cameraTracker-DHdF8Zqx.js} +5 -5
  22. package/web/assets/{captionLayout-CWPcbid-.js → captionLayout-cckQ7p-t.js} +1 -1
  23. package/web/assets/{clientExport-DvpTTndR.js → clientExport-pkLbOmEF.js} +1 -1
  24. package/web/assets/{clientJobs-CIrYTMpn.js → clientJobs-CcsLDqFM.js} +2 -2
  25. package/web/assets/{depthEstimate-B7D7cGCl.js → depthEstimate-Cav4MmQ1.js} +1 -1
  26. package/web/assets/{directorTools-CJD4Huqk.js → directorTools-DMsatulF.js} +1 -1
  27. package/web/assets/{distortFrames-BLt1icUb.js → distortFrames-D_v-aSVO.js} +2 -2
  28. package/web/assets/{distortGL-BA5molk-.js → distortGL-vhnBRB59.js} +1 -1
  29. package/web/assets/domino-DBrinEUu.js +1 -0
  30. package/web/assets/{editTools-NKLsWZD1.js → editTools-BNnAvCw-.js} +1 -1
  31. package/web/assets/{engine-DioUF2mX.js → engine-Co-ivzlQ.js} +1 -1
  32. package/web/assets/{exportGlb-BOdI9cVS.js → exportGlb-D3PrWUvi.js} +1 -1
  33. package/web/assets/{faceTracker-D7CbF-qX.js → faceTracker-ClR-lS6Y.js} +1 -1
  34. package/web/assets/fightDirector-BlpVAURl.js +1 -0
  35. package/web/assets/{fightDrama-DIPcRKnc.js → fightDrama-BK0QidpM.js} +2 -2
  36. package/web/assets/{focusTool-vfabPqQ5.js → focusTool-sVOb2GGS.js} +1 -1
  37. package/web/assets/{frameSink-DYs2gTzq.js → frameSink-CSRqCnwI.js} +3 -3
  38. package/web/assets/{glTransitionSources.generated-DM5sRMX2.js → glTransitionSources.generated-q0H-ZbnZ.js} +2 -2
  39. package/web/assets/{gpuCompose-DbnZuelB.js → gpuCompose-B5bgbHdQ.js} +1 -1
  40. package/web/assets/{gpuExport-CQ7ZhpsX.js → gpuExport-oA2mUsdm.js} +7 -7
  41. package/web/assets/{handMatte-DIbMuqCu.js → handMatte-Dj2taFoC.js} +1 -1
  42. package/web/assets/handTracker-c6_rvuwA.js +2 -0
  43. package/web/assets/i18n-C9zFX25m.js +3 -0
  44. package/web/assets/{index-BfrDwjDI.js → index-Ds_8isyf.js} +1 -1
  45. package/web/assets/layer-worker-ClVZG6ZW.js +5 -0
  46. package/web/assets/library-BK0QVG4O.js +1 -0
  47. package/web/assets/{lottieLayer-C2YbiXhK.js → lottieLayer-Cv8ub9f6.js} +1 -1
  48. package/web/assets/{main-B27kf5aL.css → main-B_MAOvi6.css} +1 -1
  49. package/web/assets/{main-BKatDoGw.js → main-CwrkBJ63.js} +104 -104
  50. package/web/assets/{mapBake-C-G7WpFM.js → mapBake-DtQboFIX.js} +1 -1
  51. package/web/assets/{maskTrack-LMrwm5ub.js → maskTrack-D4QZfMWc.js} +1 -1
  52. package/web/assets/{matteFixRun-B38CbeEt.js → matteFixRun-CytaeRzS.js} +1 -1
  53. package/web/assets/{objectLocate-CKi3OTnL.js → objectLocate-XuAcemlO.js} +1 -1
  54. package/web/assets/{objectSegmenter-CziPuM61.js → objectSegmenter-D66spD7o.js} +1 -1
  55. package/web/assets/{objectTrack.worker-b7DJ-ub6.js → objectTrack.worker-BZS6WZ6l.js} +547 -327
  56. package/web/assets/{pathTracer-bqau16sX.js → pathTracer-DykgPkkh.js} +2 -2
  57. package/web/assets/{pendingMatte-CQb7jPg1.js → pendingMatte-BWBIWajI.js} +2 -2
  58. package/web/assets/{personAi-CQntGDqK.js → personAi-EhBknW6X.js} +2 -2
  59. package/web/assets/{personHq-B1c0QVJT.js → personHq-Ca351o06.js} +2 -2
  60. package/web/assets/{plateCamera-D7iLiNBy.js → plateCamera-BcdXD1uI.js} +1 -1
  61. package/web/assets/{plateCameraMatch-BM88dx-a.js → plateCameraMatch-GPZl1fQQ.js} +2 -2
  62. package/web/assets/{plateFollow-4iGUDTu1.js → plateFollow-CJUilsNV.js} +2 -2
  63. package/web/assets/{plateMatte-zTyuHHqh.js → plateMatte-CoEoVjxZ.js} +2 -2
  64. package/web/assets/{pluginAutomation-DSg-sYLF.js → pluginAutomation-DAPHWZPN.js} +1 -1
  65. package/web/assets/{poseTracker-DZl8l2qS.js → poseTracker-CzEKvJph.js} +1 -1
  66. package/web/assets/{productTools-B-jh8ukh.js → productTools-ce-zyZO0.js} +2 -2
  67. package/web/assets/remote-8XzEAnAJ.js +974 -0
  68. package/web/assets/{rigTrack-XaMj1yaH.js → rigTrack-DMyqb0pb.js} +1 -1
  69. package/web/assets/{rotoMaskStore-DdpmT9C3.js → rotoMaskStore-pE1AIt3I.js} +1 -1
  70. package/web/assets/{rotoMatte-i-cJTYmK.js → rotoMatte-7b7Ow64f.js} +1 -1
  71. package/web/assets/{rotoscope-DqRSWmHR.js → rotoscope-BUqNTKLd.js} +1 -1
  72. package/web/assets/{sceneTrack-DIPzBmMK.js → sceneTrack-CA21MCOP.js} +1 -1
  73. package/web/assets/{sceneTrack-Bbov7zET.js → sceneTrack-DlAH5s74.js} +1 -1
  74. package/web/assets/{sceneTrack.worker-Bav9h0pv.js → sceneTrack.worker-COlhlHRe.js} +547 -327
  75. package/web/assets/{shot-worker-m-q77W9f.js → shot-worker-DL1ZoIym.js} +1 -1
  76. package/web/assets/{shotFxAgent-DIMS7BGA.js → shotFxAgent-DqngnGFb.js} +1 -1
  77. package/web/assets/{skin-DrUzJE1u.js → skin-xFScwS3T.js} +1 -1
  78. package/web/assets/{spark.module-Y1SEI8Xz.js → spark.module-DjaIF6J1.js} +1 -1
  79. package/web/assets/{spellDuel-DNnyQDVr.js → spellDuel-BYNtnE8f.js} +2 -2
  80. package/web/assets/{store-GFMJzaWS.js → store-CpqHUcA2.js} +1 -1
  81. package/web/assets/{surfaceLight-C--moyc9.js → surfaceLight-C7YI9SV8.js} +1 -1
  82. package/web/assets/{surfacePin-B4-1UqXD.js → surfacePin-CzpUj1Cw.js} +2 -2
  83. package/web/assets/{textAnimators-BVXTl8bU.js → textAnimators-B9vO_hbP.js} +1 -1
  84. package/web/assets/{thumb-CTfDJgLp.js → thumb-BTFsBS1u.js} +1 -1
  85. package/web/assets/{timeline3d-Dn7PqmEe.js → timeline3d-DrFaMPPB.js} +2 -2
  86. package/web/assets/{timeline3dExport-DCOr6ARB.js → timeline3dExport-Uo0S0CR0.js} +1 -1
  87. package/web/assets/{timelineComp-Dx_kED5V.js → timelineComp-i-zdaoB2.js} +1 -1
  88. package/web/assets/timelineOps-DSSaDsU2.js +525 -0
  89. package/web/assets/{timelineProps-eYgO6gs5.js → timelineProps-0v-s69pw.js} +1 -1
  90. package/web/assets/{timelineText-RKyRP988.js → timelineText-DurRhyuh.js} +1 -1
  91. package/web/assets/{titleArt-CUtA0C3I.js → titleArt-CnC0A7x7.js} +3 -3
  92. package/web/assets/{titleFrameBudget-X7HLSDre.js → titleFrameBudget-DsM0V482.js} +801 -581
  93. package/web/assets/{titleFrames-aMG7HdVe.js → titleFrames-C8kvflgT.js} +1 -1
  94. package/web/assets/{tool-DpFjybaq.js → tool-D1FpErrX.js} +1 -1
  95. package/web/assets/{tools-CeOU0p13.js → tools-DIvrRu-5.js} +1 -1
  96. package/web/assets/toonTools-D9MNdRty.js +2 -0
  97. package/web/assets/{trackAnchor-hAOtEhKO.js → trackAnchor-XvUuvkWP.js} +1 -1
  98. package/web/assets/{userFonts-1kuRjWOo.js → userFonts-Djka6RJX.js} +1 -1
  99. package/web/assets/{vfxAlpha-DxS5-QwY.js → vfxAlpha-B-JzzRI1.js} +1 -1
  100. package/web/assets/vfxBackground-b053ziDK.js +2 -0
  101. package/web/assets/{videoExport-Cg4B2Nyh.js → videoExport-NN-QijHd.js} +1 -1
  102. package/web/assets/{views-CUXyRb9x.js → views-RQBs4zva.js} +1 -1
  103. package/web/assets/{weaponDuel-nFECu9nk.js → weaponDuel-DKAEYJjO.js} +1 -1
  104. package/web/assets/{windowFrames-1wAkkWnv.js → windowFrames-DhhJLIs-.js} +1 -1
  105. package/web/layer-worker.html +3 -3
  106. package/web/shot-worker.html +23 -23
  107. package/web/assets/auraTrack-D_gxHNVe.js +0 -1
  108. package/web/assets/fightDirector-CYP8jxo8.js +0 -1
  109. package/web/assets/handTracker-DY_g5Xmg.js +0 -2
  110. package/web/assets/i18n-BJppIrtF.js +0 -3
  111. package/web/assets/layer-worker-DLSnp1D-.js +0 -5
  112. package/web/assets/library-B6KsZUKq.js +0 -1
  113. package/web/assets/remote-DJd9xWjn.js +0 -963
  114. package/web/assets/timelineOps-afzSo188.js +0 -525
  115. package/web/assets/toonTools-DLmo37Z_.js +0 -2
  116. package/web/assets/vfxBackground-CYpaQaTa.js +0 -2
@@ -1,8 +1,8 @@
1
- import{eU as jt,eV as At,n5 as de,c_ as dt,aB as St,n6 as Dt,bt as Kt,by as qt,n7 as pe,hi as Ot,cB as Ut,cz as Gt,cQ as Xt,fm as It,n8 as ge,n9 as bt,eX as ye,fb as Me,gG as xe,fd as we,gI as be,lu as ke,dW as Te,dY as Ae,fa as ve,gH as Yt,bw as Pe,na as Jt,dZ as Se,G as Oe,l7 as Ie}from"./titleFrameBudget-X7HLSDre.js";import{h as ae,A as Ee,j as Et,t as Ne}from"./textAnimators-BVXTl8bU.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-Bbov7zET.js";const je=["classic","duotone-stack","outline-punch","accent-bar","neon-edge","echo-stack","tape-label","serif-year"],Tn=[{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-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
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
- 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"}],Ve={"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(Ve).map(([t,e])=>[t,Object.freeze(ae(e,`titleAnimations.${t}`))])));Object.freeze(Object.keys($t));const Qt=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,Be=t=>{if(t.length>2e4)throw Error("design: too long");try{return mt(JSON.parse(t))}catch{throw Error("design: invalid JSON")}},De=["none","push-in","pull-out","pan-left","pan-right","slide-up","slide-left","pop-in","rise-pop","punch-in"];function An(t,e){if(!De.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 Ke(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(!je.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"?Be(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(Qt)),s.animation=ae(h));const u=Ne(mt(t.animators));return u.length&&(s.design||(s.design=Et(Qt)),s.animators=u),s}const qe={"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"}},vn=t=>{const e=qe[t];return{generator:e?.generator||t,...e?.resolution?{resolution:e.resolution}:{}}},Pn=4,Sn={"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"}},On="openai:gpt-image-2.5-flare",Zt=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}]}}),In=Object.freeze(Object.keys(Lt)),Ue=Object.freeze(["rise","fade","wipe"]),Ge=/^#[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),Xe=.2,ie=St["ease-in-out"],Vt=St["ease-out"],Ye=St["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):"",Je=(t,e)=>typeof t=="string"&&Ge.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 Qe(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 Ht(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 Ze(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 He(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 Nt=(t,e=0)=>((t+1)*.6180339887+e*.3819660113)%1;function We(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=Nt(h),d=n*.35*Nt(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*Nt(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 tn={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}}]},Ft=t=>t===" "?.32:/[IÍÌỈĨỊ1.,:;!|'’]/.test(t)?.34:/[MWƯỨỪỬỮỰ]/.test(t)?.88:.7,en=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 nn(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 an(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 En(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 an(e)}const ut=t=>Math.log(Math.tan(Math.PI/4+t*Math.PI/360));function rn(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 on=(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 Wt(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 te=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:ee(r.map(i=>rn(a,i[0],i[1])),n),ll:r}}const o=Array.isArray(t.points)?ee(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=>on(a,i[0],i[1])):null}}function ee(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:Ke({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 sn(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;ge(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)/Xe))),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 Nn(t,{base:e,W:n=1280,H:a=720,cam:r=null,materials:o=[]}){const i=t.kind;if(!Zt.includes(i))throw Error(`Map annotation kind must be ${Zt.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=sn(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=Qe(n,a),w=p=>bt(e,p[0],p[1],n,a),g=p=>p/u,T=p=>Je(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):Ht(y.map(w)),A=m.lanes?He(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?We(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?te(Wt(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+Ft(Y.toUpperCase()),0),ot=(S.reduce((Q,nt)=>Q+ct(nt),0)+Ft(" ")*(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,tn,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+Ft(" ")*M*nt}}else if(x){const P=Number.isFinite(t.textSize)?R(t.textSize,10,80):22,C=x.length*P*.62/u,F=Ze(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?Ht(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=en(m),v=Number.isFinite(t.textSize)?R(t.textSize,10,80):24;$.push(V(b,A,nn(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?te(Wt(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:Ye};$.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}
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(`
5
- `).map(K=>K.length))*M.title.fontSize*.3*Math.min(n/1280,a/720)*M.scale;$.push(E({...M,enter:{type:v?"slide-down":"slide-up",duration:.4,amount:.04}},p,y,[(n*.04+z)*x,-P-30*S],.3));break}case"icon":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A map icon"),m=J(t.text,40),k=J(t.subText,40),b=Dt.includes(t.look)?t.look:Dt.includes(t.style)?t.style:"gold-pin",A=Kt[t.icon]?t.icon:qt(t.icon)??qt(m)??"location",v={...pe.params,icon:A,look:b,label:m,sub:k,color:T(Pe(b)),size:R(Number.isFinite(t.size)?t.size:1,.5,2),pulse:t.pulse===!0||t.pulse!==!1&&(b==="tag"||b==="beacon")?1:0};$.push(E({label:`Map · ${m||Kt[A].vi}`,motion:Ot({code:`@preset:${Jt}`,params:v,preset:Jt})},p,y,[0,0]));break}case"overlay":{const p=de(rt(tt(t,e,4).uv,4,4,"An overlay")),y=o.find(A=>A.id===t.materialId&&A.kind==="image");if(!y?.url)throw Error("An overlay needs an image from Media (materialId): the master plan / render");const m=Ue.includes(t.reveal)?t.reveal:"rise",k=m==="rise"?_(Math.min(c*1.2,s*.6)):void 0,b={nodeId:y.id,url:y.url,...y.gcsUri?{gcsUri:y.gcsUri}:{},kind:"image",label:`Map · ${y.label||"overlay"}`,volume:0,start:+l.toFixed(4),duration:+s.toFixed(4),motionV:2,motionKeys:[],pin:{clip:e.id,corners:p.map(A=>[I(A[0]),I(A[1])]),...k?{rise:k}:{}},enter:{type:"fade",duration:m==="fade"?Math.min(1.2,s/3):.3},exit:{type:"fade",duration:Math.min(.4,s/4)},mapAnno:{base:e.id,kind:i}};if(m==="wipe"&&Object.assign(b,{revealType:"wipe-up",...dt({motionKeys:[]},"reveal",[{time:0,value:0,ease:ie},{time:_(Math.min(c*1.2,s*.6)),value:1}])}),$.push(b),t.outline!==!1){const A=p.map(w);$.push(B([G("s1","glow",L(A),!0,{stroke:q(T("#3cf2d0"),f.len(g(12)),{blur:f.len(g(9)),opacity:.8}),draw:[0,c]}),G("s2","edge",L(A),!0,{stroke:q(T("#3cf2d0"),f.len(g(3))),draw:[0,c]})],"Map · overlay edge"))}break}}return{layers:$,applied:`map ${i}${t.text?` "${J(t.text,30)}"`:""} @ ${_(l)}s`}}function Fn(t,e,{W:n=1280,H:a=720,cam:r=null}){const o=tt({...e,points:e.point!=null?[e.point]:e.points,lonlat:e.lonlat!=null&&!Array.isArray(e.lonlat[0])?[e.lonlat]:e.lonlat},t,1).uv;let[i,l]=Array.isArray(o?.[0])&&o[0].length===2&&o[0].every(Number.isFinite)?o[0]:[.5,.5],s=R(Number.isFinite(e.zoom)?e.zoom:1.6,.3,Se);const c=R(Number.isFinite(e.tilt)?e.tilt:0,0,70),h=Number.isFinite(e.at)?e.at:t.start,u=R(Number.isFinite(e.duration)?e.duration:3,.3,60),d=h+u;if(h<t.start-1e-6||d>t.start+t.duration+1e-6)throw Error("The move must lie inside the map clip");const f=jt(r)&&At(t);let w="auto";const g=(U,V,E)=>f?ln(t,r,U,V,E,c,h,d,n,a,w):{patch:cn(t,U,V,E,h,d,n,a,w)};let T=g(i,l,s),O="";if(e.keepInside!==!1){const U=Tt(t,f?r:null,h,h,n,a),V=U?h:d,E=p=>Tt(f?t:{...t,...p.patch},f?p.camera:null,V,d,n,a),$=()=>{if(E(T))return!0;if(!E(g(.5,.5,s)))return!1;let p=0,y=1;for(let m=0;m<14;m++){const k=(p+y)/2;E(g(i+(.5-i)*k,l+(.5-l)*k,s))?y=k:p=k}return i+=(.5-i)*y,l+=(.5-l)*y,T=g(i,l,s),O="aim",!0};for(let p=0;p<24&&!$();p++)s=Math.min(4,s*1.04),T=g(i,l,s),O="zoom";const L=fn(f?T.camera?.motionKeys:{...t,...T.patch}.motionKeys,f?null:t.start,h);L!=null&&Tt(t,f?r:null,L,h,n,a)&&!Tt(f?t:{...t,...T.patch},f?T.camera:null,L,h,n,a)&&(w=St["easy-ease"],T=g(i,l,s))}const B=O?` (kept on the map: ${O==="zoom"?"more zoom":"aim nudged"})`:"";return f?{camera:T.camera,applied:`fly to [${_(i)}, ${_(l)}] ×${_(s)}${c?` tilt ${c}°`:""} ${_(h)}→${_(d)}s (camera)${B}`}:{patch:T.patch,applied:`fly to [${_(i)}, ${_(l)}] ×${_(s)} ${_(h)}→${_(d)}s (map layer)${B}`}}function ln(t,e,n,a,r,o,i,l,s,c,h="auto"){const[u,d]=bt(t,n,a,s,c),f=ye(t,R(l-t.start,0,t.duration),s,c),[w,g,T]=f.corners,O=u/s,B=d/c,U=[0,1,2].map(m=>w[m]+(g[m]-w[m])*O+(T[m]-w[m])*B),V=ve(s,c),E=o*Math.PI/180,$=5*V,L=(U[2]-$*Math.cos(E))/V,p={cx:U[0]/s,cy:(U[1]+$*Math.sin(E))/c,cz:L,zoom:r,tilt:o};let y={...e??Me,enabled:!0,motionV:2,motionKeys:e?.motionKeys??[]};for(const[m,k]of Object.entries(p)){const b=xe(y,m),A=we(y,m,i),v=b.filter(S=>S.time<i-1/60||S.time>l+1/60),N=v.filter(S=>S.time<i),x=v.filter(S=>S.time>l);y=be(y,m,[...N,{time:I(i),value:I(A),ease:h},{time:I(l),value:I(R(k,...hn(m))),...x.length?{ease:"auto"}:{}},...x])}return{camera:ke(y)}}function cn(t,e,n,a,r,o,i,l,s="auto"){const[c,h]=bt(t,e,n,i,l),u={x:-(c-i/2)*a/i,y:-(h-l/2)*a/l,zoom:a};let d={};for(const[f,w]of Object.entries(u)){const g={...t,...d},T=r-t.start,O=o-t.start,B=Te(g,f),U=Ae(g,f,T),V=B.filter(E=>E.time<T-1/60||E.time>O+1/60);d={...d,...dt(g,f,[...V.filter(E=>E.time<T),{time:I(T),value:I(U),ease:s},{time:I(O),value:I(f==="zoom"?w:R(w,-10,10)),...V.some(E=>E.time>O)?{ease:"auto"}:{}},...V.filter(E=>E.time>O)])}}return d}function fn(t,e,n){const a=e??0,r=(t||[]).map(o=>o.time+a).filter(o=>o<n-1/60);return r.length?Math.max(...r):null}function Tt(t,e,n,a,r,o){const i=(l,s,c)=>{let h=0;for(let u=0;u<4;u++){const d=l[u],f=l[(u+1)%4],w=(f[0]-d[0])*(c-d[1])-(f[1]-d[1])*(s-d[0]);if(u===0)h=Math.sign(w);else if(Math.sign(w)!==h&&w!==0)return!1}return!0};for(let l=0;l<=8;l++){const s=n+(a-n)*l/8,c=R(s-t.start,0,t.duration),h=[[0,0],[1,0],[1,1],[0,1]].map(([u,d])=>It(t,u,d,c,s,r,o,e));if(h.some(u=>!u)||![[1,1],[r-1,1],[r-1,o-1],[1,o-1]].every(([u,d])=>i(h,u,d)))return!1}return!0}const hn=t=>[Yt[t].min,Yt[t].max];function Rn(t,e,n=1280,a=720){const r=new Map(t.map(o=>[o.id,o]));return t.map(o=>{const i=o.mapAnno?.follow,l=i&&r.get(o.mapAnno.base);if(!l)return o;const s=fe(l,i[0],i[1],o.start,o.start+o.duration,n,a,jt(e)&&At(l)?e:null,[i[2],i[3]]);if(!s)return o;const c={...o,motionKeys:(o.motionKeys||[]).map(h=>{const{x:u,y:d,...f}=h;if(f.ease){const{x:w,y:g,...T}=f.ease;f.ease=Object.keys(T).length?T:void 0,f.ease||delete f.ease}return f}).filter(h=>Object.keys(h).some(u=>u!=="time"&&u!=="ease"))};return he(c,s)})}const _t=Object.freeze({width:[2,80],length:[.05,3],points:256}),pt=t=>Math.round(t*1e3)/1e3,j=t=>Math.round(t*1e4)/1e4,vt=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,un=/^#[0-9a-fA-F]{6}$/;function Bt(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])=>[pt((l*n/t-o)/r),pt((s*a/e-i)/r)],len:l=>l*n/t/r}}const zn=Bt,mn=(t,e,n)=>n==="energy"?[{name:"aura",color:t,width:e*6,blur:e*5,opacity:.4},{name:"glow",color:t,width:e*3.2,blur:e*2.4,opacity:.8},{name:"line",color:t,width:e*1.2},{name:"core",color:"#ffffff",width:Math.max(1,e*.6),opacity:1}]:[{name:"glow",color:t,width:e*3.2,blur:e*2.4,opacity:.55},{name:"line",color:t,width:e},{name:"core",color:"#ffffff",width:Math.max(1,e*.35),opacity:.9}],Pt=Object.freeze({strands:12,color:"#c25bff",width:8});function dn(t,e){const n=[0];for(let o=1;o<t.length;o++)n.push(n[o-1]+Math.hypot(t[o][0]-t[o-1][0],t[o][1]-t[o-1][1]));const a=Math.max(90,e*20),r=e*2.6;return Array.from({length:Pt.strands},(o,i)=>t.map((l,s)=>{const c=t[Math.max(0,s-1)],h=t[Math.min(t.length-1,s+1)],u=h[0]-c[0],d=h[1]-c[1],f=Math.hypot(u,d)||1,w=r*Math.sin(2*Math.PI*n[s]/a+i*2*Math.PI/Pt.strands)*(.55+.45*Math.cos(i*1.7));return[l[0]-d/f*w,l[1]+u/f*w]}))}function pn(t,e,n,a){const r=(i,l,s,c)=>({id:i,name:l,type:"path",params:{pts:s.map(h=>a.pt(h)),closed:!1},pos:[0,0],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:c.color,width:pt(vt(a.len(c.width),[0,240],1)),cap:"round",join:"round",...c.blur?{blur:pt(Math.min(200,a.len(c.blur)))}:{},...c.opacity?{opacity:c.opacity}:{}}}),o=[r("s1","trail aura",t,{color:e,width:n*9,blur:n*8,opacity:.45}),r("s2","trail glow",t,{color:e,width:n*4,blur:n*3,opacity:.85})];return dn(t,n).forEach((i,l)=>{o.push(r("r"+(2*l+1),`trail strand ${l+1}`,i,{color:e,width:n*.7,blur:n*.5,opacity:1})),o.push(r("r"+(2*l+2),`trail strand core ${l+1}`,i,{color:"#fbe6ff",width:Math.max(1,n*.22),opacity:.95}))}),o}function ue(t,e,n,a,r){return r==="ribbon"?pn(t,e,n,a):mn(e,n,r).map((o,i)=>({id:"s"+(i+1),name:`trail ${o.name}`,type:"path",params:{pts:t.map(l=>a.pt(l)),closed:!1},pos:[0,0],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:o.color,width:pt(vt(a.len(o.width),[0,240],1)),cap:"round",join:"round",...o.blur?{blur:pt(Math.min(200,a.len(o.blur)))}:{},...o.opacity?{opacity:o.opacity}:{}}}))}const Rt=Object.freeze({vanish:[.5,.42],flow:1.15,spread:.05});function gn(t,e,n,{color:a,width:r,length:o,vanish:i,flow:l,ring:s,spread:c}){const h=t.map(([f,w,g])=>[j(f),j(w/e),j(g/n)]),u=Array.isArray(i)&&i.length===2?i:Rt.vanish,d="const TR="+JSON.stringify(h)+`;function render(ctx,t,env){
5
+ `).map(K=>K.length))*M.title.fontSize*.3*Math.min(n/1280,a/720)*M.scale;$.push(E({...M,enter:{type:v?"slide-down":"slide-up",duration:.4,amount:.04}},p,y,[(n*.04+z)*x,-P-30*S],.3));break}case"icon":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A map icon"),m=J(t.text,40),k=J(t.subText,40),b=Dt.includes(t.look)?t.look:Dt.includes(t.style)?t.style:"gold-pin",A=Kt[t.icon]?t.icon:qt(t.icon)??qt(m)??"location",v={...ge.params,icon:A,look:b,label:m,sub:k,color:T(Se(b)),size:R(Number.isFinite(t.size)?t.size:1,.5,2),pulse:t.pulse===!0||t.pulse!==!1&&(b==="tag"||b==="beacon")?1:0};$.push(E({label:`Map · ${m||Kt[A].vi}`,motion:St({code:`@preset:${Jt}`,params:v,preset:Jt})},p,y,[0,0]));break}case"overlay":{const p=pe(rt(tt(t,e,4).uv,4,4,"An overlay")),y=o.find(A=>A.id===t.materialId&&A.kind==="image");if(!y?.url)throw Error("An overlay needs an image from Media (materialId): the master plan / render");const m=Xe.includes(t.reveal)?t.reveal:"rise",k=m==="rise"?_(Math.min(c*1.2,s*.6)):void 0,b={nodeId:y.id,url:y.url,...y.gcsUri?{gcsUri:y.gcsUri}:{},kind:"image",label:`Map · ${y.label||"overlay"}`,volume:0,start:+l.toFixed(4),duration:+s.toFixed(4),motionV:2,motionKeys:[],pin:{clip:e.id,corners:p.map(A=>[I(A[0]),I(A[1])]),...k?{rise:k}:{}},enter:{type:"fade",duration:m==="fade"?Math.min(1.2,s/3):.3},exit:{type:"fade",duration:Math.min(.4,s/4)},mapAnno:{base:e.id,kind:i}};if(m==="wipe"&&Object.assign(b,{revealType:"wipe-up",...dt({motionKeys:[]},"reveal",[{time:0,value:0,ease:ie},{time:_(Math.min(c*1.2,s*.6)),value:1}])}),$.push(b),t.outline!==!1){const A=p.map(w);$.push(B([G("s1","glow",L(A),!0,{stroke:q(T("#3cf2d0"),f.len(g(12)),{blur:f.len(g(9)),opacity:.8}),draw:[0,c]}),G("s2","edge",L(A),!0,{stroke:q(T("#3cf2d0"),f.len(g(3))),draw:[0,c]})],"Map · overlay edge"))}break}}return{layers:$,applied:`map ${i}${t.text?` "${J(t.text,30)}"`:""} @ ${_(l)}s`}}function zn(t,e,{W:n=1280,H:a=720,cam:r=null}){const o=tt({...e,points:e.point!=null?[e.point]:e.points,lonlat:e.lonlat!=null&&!Array.isArray(e.lonlat[0])?[e.lonlat]:e.lonlat},t,1).uv;let[i,l]=Array.isArray(o?.[0])&&o[0].length===2&&o[0].every(Number.isFinite)?o[0]:[.5,.5],s=R(Number.isFinite(e.zoom)?e.zoom:1.6,.3,Oe);const c=R(Number.isFinite(e.tilt)?e.tilt:0,0,70),h=Number.isFinite(e.at)?e.at:t.start,u=R(Number.isFinite(e.duration)?e.duration:3,.3,60),d=h+u;if(h<t.start-1e-6||d>t.start+t.duration+1e-6)throw Error("The move must lie inside the map clip");const f=jt(r)&&At(t);let w="auto";const g=(U,V,E)=>f?fn(t,r,U,V,E,c,h,d,n,a,w):{patch:hn(t,U,V,E,h,d,n,a,w)};let T=g(i,l,s),O="";if(e.keepInside!==!1){const U=Tt(t,f?r:null,h,h,n,a),V=U?h:d,E=p=>Tt(f?t:{...t,...p.patch},f?p.camera:null,V,d,n,a),$=()=>{if(E(T))return!0;if(!E(g(.5,.5,s)))return!1;let p=0,y=1;for(let m=0;m<14;m++){const k=(p+y)/2;E(g(i+(.5-i)*k,l+(.5-l)*k,s))?y=k:p=k}return i+=(.5-i)*y,l+=(.5-l)*y,T=g(i,l,s),O="aim",!0};for(let p=0;p<24&&!$();p++)s=Math.min(4,s*1.04),T=g(i,l,s),O="zoom";const L=un(f?T.camera?.motionKeys:{...t,...T.patch}.motionKeys,f?null:t.start,h);L!=null&&Tt(t,f?r:null,L,h,n,a)&&!Tt(f?t:{...t,...T.patch},f?T.camera:null,L,h,n,a)&&(w=Ot["easy-ease"],T=g(i,l,s))}const B=O?` (kept on the map: ${O==="zoom"?"more zoom":"aim nudged"})`:"";return f?{camera:T.camera,applied:`fly to [${_(i)}, ${_(l)}] ×${_(s)}${c?` tilt ${c}°`:""} ${_(h)}→${_(d)}s (camera)${B}`}:{patch:T.patch,applied:`fly to [${_(i)}, ${_(l)}] ×${_(s)} ${_(h)}→${_(d)}s (map layer)${B}`}}function fn(t,e,n,a,r,o,i,l,s,c,h="auto"){const[u,d]=bt(t,n,a,s,c),f=Me(t,R(l-t.start,0,t.duration),s,c),[w,g,T]=f.corners,O=u/s,B=d/c,U=[0,1,2].map(m=>w[m]+(g[m]-w[m])*O+(T[m]-w[m])*B),V=Pe(s,c),E=o*Math.PI/180,$=5*V,L=(U[2]-$*Math.cos(E))/V,p={cx:U[0]/s,cy:(U[1]+$*Math.sin(E))/c,cz:L,zoom:r,tilt:o};let y={...e??xe,enabled:!0,motionV:2,motionKeys:e?.motionKeys??[]};for(const[m,k]of Object.entries(p)){const b=we(y,m),A=be(y,m,i),v=b.filter(S=>S.time<i-1/60||S.time>l+1/60),N=v.filter(S=>S.time<i),x=v.filter(S=>S.time>l);y=ke(y,m,[...N,{time:I(i),value:I(A),ease:h},{time:I(l),value:I(R(k,...mn(m))),...x.length?{ease:"auto"}:{}},...x])}return{camera:Te(y)}}function hn(t,e,n,a,r,o,i,l,s="auto"){const[c,h]=bt(t,e,n,i,l),u={x:-(c-i/2)*a/i,y:-(h-l/2)*a/l,zoom:a};let d={};for(const[f,w]of Object.entries(u)){const g={...t,...d},T=r-t.start,O=o-t.start,B=Ae(g,f),U=ve(g,f,T),V=B.filter(E=>E.time<T-1/60||E.time>O+1/60);d={...d,...dt(g,f,[...V.filter(E=>E.time<T),{time:I(T),value:I(U),ease:s},{time:I(O),value:I(f==="zoom"?w:R(w,-10,10)),...V.some(E=>E.time>O)?{ease:"auto"}:{}},...V.filter(E=>E.time>O)])}}return d}function un(t,e,n){const a=e??0,r=(t||[]).map(o=>o.time+a).filter(o=>o<n-1/60);return r.length?Math.max(...r):null}function Tt(t,e,n,a,r,o){const i=(l,s,c)=>{let h=0;for(let u=0;u<4;u++){const d=l[u],f=l[(u+1)%4],w=(f[0]-d[0])*(c-d[1])-(f[1]-d[1])*(s-d[0]);if(u===0)h=Math.sign(w);else if(Math.sign(w)!==h&&w!==0)return!1}return!0};for(let l=0;l<=8;l++){const s=n+(a-n)*l/8,c=R(s-t.start,0,t.duration),h=[[0,0],[1,0],[1,1],[0,1]].map(([u,d])=>It(t,u,d,c,s,r,o,e));if(h.some(u=>!u)||![[1,1],[r-1,1],[r-1,o-1],[1,o-1]].every(([u,d])=>i(h,u,d)))return!1}return!0}const mn=t=>[Yt[t].min,Yt[t].max];function Cn(t,e,n=1280,a=720){const r=new Map(t.map(o=>[o.id,o]));return t.map(o=>{const i=o.mapAnno?.follow,l=i&&r.get(o.mapAnno.base);if(!l)return o;const s=fe(l,i[0],i[1],o.start,o.start+o.duration,n,a,jt(e)&&At(l)?e:null,[i[2],i[3]]);if(!s)return o;const c={...o,motionKeys:(o.motionKeys||[]).map(h=>{const{x:u,y:d,...f}=h;if(f.ease){const{x:w,y:g,...T}=f.ease;f.ease=Object.keys(T).length?T:void 0,f.ease||delete f.ease}return f}).filter(h=>Object.keys(h).some(u=>u!=="time"&&u!=="ease"))};return he(c,s)})}const _t=Object.freeze({width:[2,80],length:[.05,3],points:256}),pt=t=>Math.round(t*1e3)/1e3,j=t=>Math.round(t*1e4)/1e4,vt=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,dn=/^#[0-9a-fA-F]{6}$/;function Bt(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])=>[pt((l*n/t-o)/r),pt((s*a/e-i)/r)],len:l=>l*n/t/r}}const $n=Bt,pn=(t,e,n)=>n==="energy"?[{name:"aura",color:t,width:e*6,blur:e*5,opacity:.4},{name:"glow",color:t,width:e*3.2,blur:e*2.4,opacity:.8},{name:"line",color:t,width:e*1.2},{name:"core",color:"#ffffff",width:Math.max(1,e*.6),opacity:1}]:[{name:"glow",color:t,width:e*3.2,blur:e*2.4,opacity:.55},{name:"line",color:t,width:e},{name:"core",color:"#ffffff",width:Math.max(1,e*.35),opacity:.9}],Pt=Object.freeze({strands:12,color:"#c25bff",width:8});function gn(t,e){const n=[0];for(let o=1;o<t.length;o++)n.push(n[o-1]+Math.hypot(t[o][0]-t[o-1][0],t[o][1]-t[o-1][1]));const a=Math.max(90,e*20),r=e*2.6;return Array.from({length:Pt.strands},(o,i)=>t.map((l,s)=>{const c=t[Math.max(0,s-1)],h=t[Math.min(t.length-1,s+1)],u=h[0]-c[0],d=h[1]-c[1],f=Math.hypot(u,d)||1,w=r*Math.sin(2*Math.PI*n[s]/a+i*2*Math.PI/Pt.strands)*(.55+.45*Math.cos(i*1.7));return[l[0]-d/f*w,l[1]+u/f*w]}))}function yn(t,e,n,a){const r=(i,l,s,c)=>({id:i,name:l,type:"path",params:{pts:s.map(h=>a.pt(h)),closed:!1},pos:[0,0],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:c.color,width:pt(vt(a.len(c.width),[0,240],1)),cap:"round",join:"round",...c.blur?{blur:pt(Math.min(200,a.len(c.blur)))}:{},...c.opacity?{opacity:c.opacity}:{}}}),o=[r("s1","trail aura",t,{color:e,width:n*9,blur:n*8,opacity:.45}),r("s2","trail glow",t,{color:e,width:n*4,blur:n*3,opacity:.85})];return gn(t,n).forEach((i,l)=>{o.push(r("r"+(2*l+1),`trail strand ${l+1}`,i,{color:e,width:n*.7,blur:n*.5,opacity:1})),o.push(r("r"+(2*l+2),`trail strand core ${l+1}`,i,{color:"#fbe6ff",width:Math.max(1,n*.22),opacity:.95}))}),o}function ue(t,e,n,a,r){return r==="ribbon"?yn(t,e,n,a):pn(e,n,r).map((o,i)=>({id:"s"+(i+1),name:`trail ${o.name}`,type:"path",params:{pts:t.map(l=>a.pt(l)),closed:!1},pos:[0,0],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:o.color,width:pt(vt(a.len(o.width),[0,240],1)),cap:"round",join:"round",...o.blur?{blur:pt(Math.min(200,a.len(o.blur)))}:{},...o.opacity?{opacity:o.opacity}:{}}}))}const Ct=Object.freeze({vanish:[.5,.42],flow:1.15,spread:.05});function Mn(t,e,n,{color:a,width:r,length:o,vanish:i,flow:l,ring:s,spread:c}){const h=t.map(([f,w,g])=>[j(f),j(w/e),j(g/n)]),u=Array.isArray(i)&&i.length===2?i:Ct.vanish,d="const TR="+JSON.stringify(h)+`;function render(ctx,t,env){
6
6
  const {width:W,height:H,params:p}=env,col=p.color||'#c25bff',L=Math.max(.2,+p.length||1.6),wk=(+p.width||8)*H/720,flow=Math.max(0,+p.flow||0),V=[(+p.vx||.5)*W,(+p.vy||.42)*H],RG=Math.max(0,+p.ring||0)*H
7
7
  // ring: the tracked point is a wheel's hub — a neon ring round the tyre (bigger as it comes closer), the energy leaves from its bottom
8
8
  const y0=TR[0][2]*H,rad=(y)=>RG*Math.max(.35,Math.min(3,(y-V[1])/Math.max(1,y0-V[1])))
@@ -25,7 +25,7 @@ ${k}`:m,px:24,W:n,H:a,design:{weight:800,lineHeight:1.35,uppercase:!1,...k?{line
25
25
  for(const [w,al,c] of passes)for(let i=1;i<P.length;i++){const a=P[i-1],b=P[i],life=Math.pow(1-b[3]/L,1.1)*fade;if(life<=0)continue
26
26
  ctx.strokeStyle=c==='#fbe6ff'?'rgba(251,230,255,'+(al*life)+')':M.rgba(c,al*life);ctx.lineWidth=Math.max(.6,w*wk*b[2]);ctx.beginPath();ctx.moveTo(a[0],a[1]);ctx.lineTo(b[0],b[1]);ctx.stroke()}}
27
27
  ctx.restore()
28
- }`;return Ot({code:d,params:{color:a,width:r,length:o,flow:Number.isFinite(l)?Math.max(0,Math.min(4,l)):Rt.flow,vx:u[0],vy:u[1],spread:Number.isFinite(c)?Math.max(0,Math.min(.3,c)):Rt.spread,...s>0?{ring:Math.min(.3,s)}:{}}})}function yn(t,e,n,{color:a,width:r,length:o,ring:i,aspect:l,rot:s,wind:c,stretch:h,taper:u}){const d=t.map(([w,g,T,O])=>[j(w),j(g/e),j(T/n),...Number.isFinite(O)?[j(O/n)]:[]]),f="const TR="+JSON.stringify(d)+`;const VOL=(ctx,W,H,blurPx,paint,draw)=>{if(typeof OffscreenCanvas==='undefined')return;const S=4,w=Math.max(2,Math.ceil(W/S)),h=Math.max(2,Math.ceil(H/S))
28
+ }`;return St({code:d,params:{color:a,width:r,length:o,flow:Number.isFinite(l)?Math.max(0,Math.min(4,l)):Ct.flow,vx:u[0],vy:u[1],spread:Number.isFinite(c)?Math.max(0,Math.min(.3,c)):Ct.spread,...s>0?{ring:Math.min(.3,s)}:{}}})}function xn(t,e,n,{color:a,width:r,length:o,ring:i,aspect:l,rot:s,wind:c,stretch:h,taper:u}){const d=t.map(([w,g,T,O])=>[j(w),j(g/e),j(T/n),...Number.isFinite(O)?[j(O/n)]:[]]),f="const TR="+JSON.stringify(d)+`;const VOL=(ctx,W,H,blurPx,paint,draw)=>{if(typeof OffscreenCanvas==='undefined')return;const S=4,w=Math.max(2,Math.ceil(W/S)),h=Math.max(2,Math.ceil(H/S))
29
29
  let A=globalThis.__VOLA,B=globalThis.__VOLB;if(!A||A.width!==w||A.height!==h){A=new OffscreenCanvas(w,h);B=new OffscreenCanvas(w,h);globalThis.__VOLA=A;globalThis.__VOLB=B}
30
30
  const a=A.getContext('2d'),b=B.getContext('2d');a.setTransform(1,0,0,1,0,0);a.clearRect(0,0,w,h);a.setTransform(1/S,0,0,1/S,0,0);a.lineCap='round';a.lineJoin='round';draw(a)
31
31
  const pass=(px)=>{b.setTransform(1,0,0,1,0,0);b.clearRect(0,0,w,h);b.filter='blur('+Math.max(.6,px/S)+'px)';b.drawImage(A,0,0);b.filter='none'}
@@ -69,4 +69,4 @@ function render(ctx,t,env){
69
69
  // the back of the tyre burns brighter where the energy leaves
70
70
  ctx.strokeStyle=M.rgba('#f6dcff',.55*fade);ctx.lineWidth=Math.max(2,r*.12*pw);ctx.beginPath();ctx.ellipse(cx,cy,r*.94*asp,r*.94,rot,back-1.1,back+1.1);ctx.stroke()
71
71
  ctx.restore()
72
- }`;return Ot({code:f,params:{color:a,width:r,length:o,ring:Number.isFinite(i)&&i>0?Math.min(.5,i):.12,ringAspect:Number.isFinite(l)?l:.92,ringRot:Number.isFinite(s)?s:0,streak:Number.isFinite(h)?Math.max(.2,Math.min(4,h)):1,taper:Number.isFinite(u)?Math.max(0,Math.min(1,u)):.75,part:"all",windX:Number.isFinite(c?.[0])?Math.max(-1,Math.min(1,c[0])):0,windY:Number.isFinite(c?.[1])?Math.max(-1,Math.min(1,c[1])):0}})}function Cn({id:t,at:e,duration:n,color:a,width:r,length:o,source:i,point:l,style:s,vanish:c,flow:h,ring:u,spread:d,aspect:f,rot:w,wind:g,stretch:T,taper:O,W:B=1280,H:U=720}){const V=s==="ribbon"||s==="wheel",E=Bt(B,U),$=un.test(a??"")?a:V?Pt.color:"#ff5fc8",L=vt(r,_t.width,V?Pt.width:10),p=.03,y={x:j(Math.max(0,Math.min(1-2*p,l[0]-p))),y:j(Math.max(0,Math.min(1-2*p,l[1]-p))),w:2*p,h:2*p};return{id:t,nodeId:"",kind:"image",url:"",volume:0,start:j(e),duration:j(n),label:"Vệt theo vật",motionV:2,posX:0,posY:0,scale:1,opacity:0,shape:{v:2,size:E.size,items:ue([[0,0],[1,1]],$,L,E,s)},trail:{color:$,width:L,length:vt(o,_t.length,.45),...s==="energy"||V?{style:s}:{},...s==="wheel"?{...u>0?{ring:j(Math.min(.5,u))}:{},...Number.isFinite(f)?{aspect:j(Math.max(.2,Math.min(1.5,f)))}:{},...Number.isFinite(w)?{rot:j(Math.max(-90,Math.min(90,w)))}:{},...Array.isArray(g)&&g.length===2&&g.every(Number.isFinite)?{wind:g.map(m=>j(Math.max(-1,Math.min(1,m))))}:{},...Number.isFinite(T)?{stretch:j(Math.max(.2,Math.min(4,T)))}:{},...Number.isFinite(O)?{taper:j(Math.max(0,Math.min(1,O)))}:{}}:{},...s==="ribbon"&&Array.isArray(c)&&c.length===2&&c.every(m=>Number.isFinite(m)&&m>=0&&m<=1)?{vanish:c.map(j)}:{},...s==="ribbon"&&Number.isFinite(h)?{flow:j(Math.max(0,Math.min(4,h)))}:{},...s==="ribbon"&&u>0?{ring:j(Math.min(.3,u))}:{},...s==="ribbon"&&Number.isFinite(d)?{spread:j(Math.max(0,Math.min(.3,d)))}:{}},pendingPin:{source:i,at:j(e),region:y,mode:"trail"}}}function $n(t,e,n,a){if(e.length<2)return{pendingPin:void 0,opacity:0};const r=Bt(n,a),{color:o,width:i,length:l,style:s,vanish:c,flow:h,ring:u,spread:d,aspect:f,rot:w,wind:g,stretch:T,taper:O}=t.trail??{color:"#ff5fc8",width:10,length:.45};if(s==="wheel"){const x=j(Math.min(t.duration,e.at(-1)[0]+.15));return{pendingPin:void 0,opacity:1,shape:void 0,motion:yn(e,n,a,{color:o,width:i,length:l,ring:u,aspect:f,rot:w,wind:g,stretch:T,taper:O}),motionV:2,motionKeys:[],duration:x>e.at(-1)[0]?x:t.duration}}if(s==="ribbon"){const x=j(Math.min(t.duration,e.at(-1)[0]+l));return{pendingPin:void 0,opacity:1,shape:void 0,motion:gn(e,n,a,{color:o,width:i,length:l,vanish:c,flow:h,ring:u,spread:d}),motionV:2,motionKeys:[],duration:x>e.at(-1)[0]?x:t.duration}}const B=[0];for(let x=1;x<e.length;x++)B.push(B[x-1]+Math.hypot(e[x][1]-e[x-1][1],e[x][2]-e[x-1][2]));const U=B.at(-1)||1,V=Math.max(1,Math.ceil(e.length/_t.points)),E=e.filter((x,S)=>S%V===0||S===e.length-1).map(x=>[x[1],x[2]]),$=x=>{if(x<=e[0][0])return 0;for(let S=1;S<e.length;S++)if(e[S][0]>=x){const P=(x-e[S-1][0])/(e[S][0]-e[S-1][0]||1);return(B[S-1]+(B[S]-B[S-1])*P)/U}return 1},L=e.map(x=>j(x[0])),p=L.map(x=>j($(x))),y=L.map(x=>j($(x-l))),m=(x,S)=>Fe(x,S,5e-4,1/0).map(P=>({time:x[P],value:S[P]})),k=L.at(-1),b=j(Math.min(t.duration,k+l)),A=b>k+1e-4?[...L,b]:L,v=b>k+1e-4?[...y,j($(b-l))]:y;let N={...t,motionV:2,shape:{...t.shape,size:r.size,items:ue(E,o,i,r,s)}};return N={...N,...dt(N,"trimEnd",m(L,p))},N={...N,...dt(N,"trimStart",m(A,v))},{pendingPin:void 0,opacity:1,shape:N.shape,motionV:2,motionKeys:N.motionKeys,duration:b>k+1e-4?b:t.duration}}const zt="vfx-speed-bolt",et=Object.freeze({chunks:15,perChunk:75,fps:30,length:[.1,1.5],width:[.3,3],jag:[0,1.5]}),Mn=/^#[0-9a-fA-F]{6}$/,it=t=>Math.round(t*1e4)/1e4,Ct=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,ne=t=>Math.round(Math.max(0,Math.min(1,t))*1295).toString(36).padStart(2,"0");function xn(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+=ne(h)+ne(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 Ln({id:t,at:e,duration:n,color:a,width:r,length:o,jag:i,source:l,point:s}){const c=Oe.find(w=>w.id===zt),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:Mn.test(a??"")?a:c.params.color,width:it(Ct(r,et.width,1)),length:it(Ct(o,et.length,.4)),jag:it(Ct(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:Ot({code:`@preset:${zt}`,params:f,preset:zt}),pendingPin:{source:l,at:it(e),region:d,mode:"bolt",...s?{}:{person:!0}}}}function _n(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,...xn(e)}}}}const lt=Object.freeze({lens:[8,300],size:.35,maxPoints:20,maxIds:50}),st=t=>typeof t=="number"&&Number.isFinite(t)?t:null;function jn(t,e){if(!e||e.kind!=="video")throw Error("trackCamera3D needs a video clip (the footage to solve the camera of)");const n=Math.max(0,Math.min(e.duration,(st(t.from)??st(t.start)??e.start)-e.start)),a=Math.min(e.duration-n,st(t.duration)??e.duration-n);if(!(a>=.3))throw Error("trackCamera3D: at least 0.3 s of the footage");const r=st(t.lens);if(r!==null&&r!==0&&!(r>=lt.lens[0]&&r<=lt.lens[1]))throw Error(`trackCamera3D lens: ${lt.lens.join("–")} mm (35 mm equivalent), or leave it out to find it`);const o=st(t.smooth);if(o!==null&&!(o>=0&&o<=1))throw Error("trackCamera3D smooth: 0 (the raw solve) … 1");return{...n<.001&&a>e.duration-.001?{}:{from:+n.toFixed(4),duration:+a.toFixed(4)},...r?{lens:r}:{},...o!==null?{smooth:o}:{}}}const Vn=(t,e,n)=>t?Ie(t,e,e/n)/e:null;function Bn(t,e,n){if(!e||e.kind==="audio")throw Error("placeOnTrack needs a visual layer (text, null, solid, picture, video, 3D model)");if(!n||n.kind!=="video"||n.id===e.id)throw Error("placeOnTrack needs sourceClipId = the footage (a video clip, not the layer itself)");const a=Array.isArray(t.points)?t.points:null,r=Array.isArray(t.pointIds)?t.pointIds:null;if(a&&!(a.length>=1&&a.length<=lt.maxPoints&&a.every(c=>Array.isArray(c)&&c.length===2&&c.every(h=>st(h)!==null&&h>=0&&h<=1))))throw Error(`placeOnTrack points: 1–${lt.maxPoints} [u, v] (0..1 of the footage picture)`);if(r&&!(r.length>=1&&r.length<=lt.maxIds&&r.every(c=>Number.isInteger(c)&&c>=0&&c<5e3)))throw Error(`placeOnTrack pointIds: 1–${lt.maxIds} solved point numbers`);if(!a&&!r)throw Error("placeOnTrack: give points [[u, v]] (where to place, 0..1 of the footage picture) or pointIds");const o=Math.max(e.start,n.start),i=Math.min(e.start+e.duration,n.start+n.duration);if(!(i>o))throw Error("placeOnTrack: the layer and the footage must play at the same time");const l=Math.max(o,Math.min(i,st(t.at)??o)),s=st(t.size);if(s!==null&&!(s>.01&&s<=3))throw Error("placeOnTrack size: 0.01–3 (share of the frame width)");return{source:n.id,at:+l.toFixed(4),...a?{points:a}:{},...r?{pointIds:r}:{},...s!==null?{size:s}:{}}}function Dn(t,e,n){const a=Math.max(0,Math.min(e.duration,n.at-e.start)),r=[],o=[];for(const l of n.pointIds??[])t.points?.[l]&&(r.push(t.points[l]),o.push(l));for(const[l,s]of n.points??[]){const[c,h]=Ce(t,e,l,s),d=(t.mode==="free"?$e(t,c,h,a,t.w*.06):[]).find(f=>!o.includes(f));d!==void 0?(r.push(t.points[d]),o.push(d)):r.push(Le(t,c,h,a))}const i=_e(t,r,a);if(!i)throw Error("NO_POINTS");return{target:i,ids:o,local:a}}function Kn(t,e,n,a=lt.size){const r=re(t,n),o=t.mode==="free"?r.C:[0,0,0],i=Math.hypot(e.center[0]-o[0],e.center[1]-o[1],e.center[2]-o[2]);return a*t.w*i/r.f}function qn(t,e){const n=re(t,e),a=[];return(t.points??[]).forEach((r,o)=>{if(!Re(t,o,e))return;const i=ze(t,r,e);!i||i[0]<0||i[1]<0||i[0]>t.w||i[1]>t.h||a.push([o,i[0],i[1],Math.hypot(r[0]-n.C[0],r[1]-n.C[1],r[2]-n.C[2])])}),a}export{qe as B,lt as C,On as D,Sn as E,De as M,In as R,Tn as T,Kn as a,vn as b,qn as c,Zt as d,Lt as e,$n as f,_n as g,En as h,Fn as i,Nn as j,Pn as k,Vn as l,An as m,Ln as n,Cn as o,Dn as p,Bn as q,Rn as r,zn as s,Ke as t,jn as u};
72
+ }`;return St({code:f,params:{color:a,width:r,length:o,ring:Number.isFinite(i)&&i>0?Math.min(.5,i):.12,ringAspect:Number.isFinite(l)?l:.92,ringRot:Number.isFinite(s)?s:0,streak:Number.isFinite(h)?Math.max(.2,Math.min(4,h)):1,taper:Number.isFinite(u)?Math.max(0,Math.min(1,u)):.75,part:"all",windX:Number.isFinite(c?.[0])?Math.max(-1,Math.min(1,c[0])):0,windY:Number.isFinite(c?.[1])?Math.max(-1,Math.min(1,c[1])):0}})}function Ln({id:t,at:e,duration:n,color:a,width:r,length:o,source:i,point:l,style:s,vanish:c,flow:h,ring:u,spread:d,aspect:f,rot:w,wind:g,stretch:T,taper:O,W:B=1280,H:U=720}){const V=s==="ribbon"||s==="wheel",E=Bt(B,U),$=dn.test(a??"")?a:V?Pt.color:"#ff5fc8",L=vt(r,_t.width,V?Pt.width:10),p=.03,y={x:j(Math.max(0,Math.min(1-2*p,l[0]-p))),y:j(Math.max(0,Math.min(1-2*p,l[1]-p))),w:2*p,h:2*p};return{id:t,nodeId:"",kind:"image",url:"",volume:0,start:j(e),duration:j(n),label:"Vệt theo vật",motionV:2,posX:0,posY:0,scale:1,opacity:0,shape:{v:2,size:E.size,items:ue([[0,0],[1,1]],$,L,E,s)},trail:{color:$,width:L,length:vt(o,_t.length,.45),...s==="energy"||V?{style:s}:{},...s==="wheel"?{...u>0?{ring:j(Math.min(.5,u))}:{},...Number.isFinite(f)?{aspect:j(Math.max(.2,Math.min(1.5,f)))}:{},...Number.isFinite(w)?{rot:j(Math.max(-90,Math.min(90,w)))}:{},...Array.isArray(g)&&g.length===2&&g.every(Number.isFinite)?{wind:g.map(m=>j(Math.max(-1,Math.min(1,m))))}:{},...Number.isFinite(T)?{stretch:j(Math.max(.2,Math.min(4,T)))}:{},...Number.isFinite(O)?{taper:j(Math.max(0,Math.min(1,O)))}:{}}:{},...s==="ribbon"&&Array.isArray(c)&&c.length===2&&c.every(m=>Number.isFinite(m)&&m>=0&&m<=1)?{vanish:c.map(j)}:{},...s==="ribbon"&&Number.isFinite(h)?{flow:j(Math.max(0,Math.min(4,h)))}:{},...s==="ribbon"&&u>0?{ring:j(Math.min(.3,u))}:{},...s==="ribbon"&&Number.isFinite(d)?{spread:j(Math.max(0,Math.min(.3,d)))}:{}},pendingPin:{source:i,at:j(e),region:y,mode:"trail"}}}function _n(t,e,n,a){if(e.length<2)return{pendingPin:void 0,opacity:0};const r=Bt(n,a),{color:o,width:i,length:l,style:s,vanish:c,flow:h,ring:u,spread:d,aspect:f,rot:w,wind:g,stretch:T,taper:O}=t.trail??{color:"#ff5fc8",width:10,length:.45};if(s==="wheel"){const x=j(Math.min(t.duration,e.at(-1)[0]+.15));return{pendingPin:void 0,opacity:1,shape:void 0,motion:xn(e,n,a,{color:o,width:i,length:l,ring:u,aspect:f,rot:w,wind:g,stretch:T,taper:O}),motionV:2,motionKeys:[],duration:x>e.at(-1)[0]?x:t.duration}}if(s==="ribbon"){const x=j(Math.min(t.duration,e.at(-1)[0]+l));return{pendingPin:void 0,opacity:1,shape:void 0,motion:Mn(e,n,a,{color:o,width:i,length:l,vanish:c,flow:h,ring:u,spread:d}),motionV:2,motionKeys:[],duration:x>e.at(-1)[0]?x:t.duration}}const B=[0];for(let x=1;x<e.length;x++)B.push(B[x-1]+Math.hypot(e[x][1]-e[x-1][1],e[x][2]-e[x-1][2]));const U=B.at(-1)||1,V=Math.max(1,Math.ceil(e.length/_t.points)),E=e.filter((x,S)=>S%V===0||S===e.length-1).map(x=>[x[1],x[2]]),$=x=>{if(x<=e[0][0])return 0;for(let S=1;S<e.length;S++)if(e[S][0]>=x){const P=(x-e[S-1][0])/(e[S][0]-e[S-1][0]||1);return(B[S-1]+(B[S]-B[S-1])*P)/U}return 1},L=e.map(x=>j(x[0])),p=L.map(x=>j($(x))),y=L.map(x=>j($(x-l))),m=(x,S)=>Fe(x,S,5e-4,1/0).map(P=>({time:x[P],value:S[P]})),k=L.at(-1),b=j(Math.min(t.duration,k+l)),A=b>k+1e-4?[...L,b]:L,v=b>k+1e-4?[...y,j($(b-l))]:y;let N={...t,motionV:2,shape:{...t.shape,size:r.size,items:ue(E,o,i,r,s)}};return N={...N,...dt(N,"trimEnd",m(L,p))},N={...N,...dt(N,"trimStart",m(A,v))},{pendingPin:void 0,opacity:1,shape:N.shape,motionV:2,motionKeys:N.motionKeys,duration:b>k+1e-4?b:t.duration}}const lt=Object.freeze({lens:[8,300],size:.35,maxPoints:20,maxIds:50}),st=t=>typeof t=="number"&&Number.isFinite(t)?t:null;function jn(t,e){if(!e||e.kind!=="video")throw Error("trackCamera3D needs a video clip (the footage to solve the camera of)");const n=Math.max(0,Math.min(e.duration,(st(t.from)??st(t.start)??e.start)-e.start)),a=Math.min(e.duration-n,st(t.duration)??e.duration-n);if(!(a>=.3))throw Error("trackCamera3D: at least 0.3 s of the footage");const r=st(t.lens);if(r!==null&&r!==0&&!(r>=lt.lens[0]&&r<=lt.lens[1]))throw Error(`trackCamera3D lens: ${lt.lens.join("–")} mm (35 mm equivalent), or leave it out to find it`);const o=st(t.smooth);if(o!==null&&!(o>=0&&o<=1))throw Error("trackCamera3D smooth: 0 (the raw solve) … 1");return{...n<.001&&a>e.duration-.001?{}:{from:+n.toFixed(4),duration:+a.toFixed(4)},...r?{lens:r}:{},...o!==null?{smooth:o}:{}}}const Vn=(t,e,n)=>t?Ie(t,e,e/n)/e:null;function Bn(t,e,n){if(!e||e.kind==="audio")throw Error("placeOnTrack needs a visual layer (text, null, solid, picture, video, 3D model)");if(!n||n.kind!=="video"||n.id===e.id)throw Error("placeOnTrack needs sourceClipId = the footage (a video clip, not the layer itself)");const a=Array.isArray(t.points)?t.points:null,r=Array.isArray(t.pointIds)?t.pointIds:null;if(a&&!(a.length>=1&&a.length<=lt.maxPoints&&a.every(c=>Array.isArray(c)&&c.length===2&&c.every(h=>st(h)!==null&&h>=0&&h<=1))))throw Error(`placeOnTrack points: 1–${lt.maxPoints} [u, v] (0..1 of the footage picture)`);if(r&&!(r.length>=1&&r.length<=lt.maxIds&&r.every(c=>Number.isInteger(c)&&c>=0&&c<5e3)))throw Error(`placeOnTrack pointIds: 1–${lt.maxIds} solved point numbers`);if(!a&&!r)throw Error("placeOnTrack: give points [[u, v]] (where to place, 0..1 of the footage picture) or pointIds");const o=Math.max(e.start,n.start),i=Math.min(e.start+e.duration,n.start+n.duration);if(!(i>o))throw Error("placeOnTrack: the layer and the footage must play at the same time");const l=Math.max(o,Math.min(i,st(t.at)??o)),s=st(t.size);if(s!==null&&!(s>.01&&s<=3))throw Error("placeOnTrack size: 0.01–3 (share of the frame width)");return{source:n.id,at:+l.toFixed(4),...a?{points:a}:{},...r?{pointIds:r}:{},...s!==null?{size:s}:{}}}function Dn(t,e,n){const a=Math.max(0,Math.min(e.duration,n.at-e.start)),r=[],o=[];for(const l of n.pointIds??[])t.points?.[l]&&(r.push(t.points[l]),o.push(l));for(const[l,s]of n.points??[]){const[c,h]=Ce(t,e,l,s),d=(t.mode==="free"?$e(t,c,h,a,t.w*.06):[]).find(f=>!o.includes(f));d!==void 0?(r.push(t.points[d]),o.push(d)):r.push(Le(t,c,h,a))}const i=_e(t,r,a);if(!i)throw Error("NO_POINTS");return{target:i,ids:o,local:a}}function Kn(t,e,n,a=lt.size){const r=re(t,n),o=t.mode==="free"?r.C:[0,0,0],i=Math.hypot(e.center[0]-o[0],e.center[1]-o[1],e.center[2]-o[2]);return a*t.w*i/r.f}function qn(t,e){const n=re(t,e),a=[];return(t.points??[]).forEach((r,o)=>{if(!Re(t,o,e))return;const i=ze(t,r,e);!i||i[0]<0||i[1]<0||i[0]>t.w||i[1]>t.h||a.push([o,i[0],i[1],Math.hypot(r[0]-n.C[0],r[1]-n.C[1],r[2]-n.C[2])])}),a}export{Ge as B,lt as C,En as D,In as E,qe as M,Nn as R,vn as T,Kn as a,Sn as b,qn as c,Ht as d,Lt as e,_n as f,An as g,Ve as h,et as i,Fn as j,zn as k,Vn as l,Pn as m,Rn as n,On as o,Dn as p,Tn as q,Cn as r,$n as s,Ue as t,Ln as u,Bn as v,jn as w};
@@ -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-X7HLSDre.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-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 +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-X7HLSDre.js";import{e as R,a as j}from"./timelineComp-Dx_kED5V.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-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,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-BKatDoGw.js","assets/titleFrameBudget-X7HLSDre.js","assets/remote-DJd9xWjn.js","assets/index-CKtv7gGE.js","assets/i18n-BJppIrtF.js","assets/api-BFN7blbw.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-GFMJzaWS.js","assets/rotoMaskStore-DdpmT9C3.js","assets/sceneTrack-Bbov7zET.js","assets/timelineOps-afzSo188.js","assets/cameraTracker-BAQHuTV-.js","assets/textAnimators-BVXTl8bU.js","assets/timelineComp-Dx_kED5V.js","assets/rigTrack-XaMj1yaH.js","assets/clientJobs-CuuUyhEy.js","assets/spark.module-Y1SEI8Xz.js","assets/userFonts-1kuRjWOo.js","assets/lottieLayer-C2YbiXhK.js","assets/timeline3d-Dn7PqmEe.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/glTransitionSources.generated-DM5sRMX2.js","assets/captionLayout-CWPcbid-.js","assets/timelineText-RKyRP988.js","assets/titleArt-CUtA0C3I.js","assets/personHq-B1c0QVJT.js","assets/matteQuality-9X-jgJrH.js","assets/sceneTrack-DIPzBmMK.js","assets/rotoMatte-i-cJTYmK.js","assets/objectSegmenter-CziPuM61.js","assets/cutoutClean-CLYYAuXg.js","assets/distortGL-BA5molk-.js","assets/motionBlur-uAm030t9.js","assets/main-B27kf5aL.css","assets/poseTracker-DZl8l2qS.js","assets/rotoscope-DqRSWmHR.js","assets/maskTrack-LMrwm5ub.js","assets/auraTrack-D_gxHNVe.js","assets/mapBake-C-G7WpFM.js","assets/gpuCompose-DbnZuelB.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/handTracker-DY_g5Xmg.js","assets/handMatte-DIbMuqCu.js","assets/matteFixRun-B38CbeEt.js","assets/depthEstimate-B7D7cGCl.js","assets/faceTracker-D7CbF-qX.js","assets/analyzerRun-Dtp2o7gT.js","assets/analyzerSandbox-BG_3Cea1.js","assets/pluginAutomation-DSg-sYLF.js"])))=>i.map(i=>d[i]);
2
- import{_ as c}from"./titleFrameBudget-X7HLSDre.js";import{r as m}from"./index-CKtv7gGE.js";import{u as d}from"./store-GFMJzaWS.js";import{t as l}from"./i18n-BJppIrtF.js";import{al as I}from"./api-BFN7blbw.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-BKatDoGw.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-DZl8l2qS.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-DqRSWmHR.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-LMrwm5ub.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-D_gxHNVe.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-C-G7WpFM.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-DY_g5Xmg.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-B38CbeEt.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-BKatDoGw.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-BKatDoGw.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-BKatDoGw.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-BKatDoGw.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-B7D7cGCl.js"),__vite__mapDeps([46,1,4,3])),c(()=>import("./timelineOps-afzSo188.js").then(u=>u.d1),__vite__mapDeps([11,1,10,12,13,14,5,4,3,8,15,16])),c(()=>import("./titleFrameBudget-X7HLSDre.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-D7CbF-qX.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-D7CbF-qX.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-B1c0QVJT.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-Dtp2o7gT.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-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 +1 @@
1
- import{nC as I,nD as y,nE as F,_ as N}from"./titleFrameBudget-X7HLSDre.js";import{t as g}from"./i18n-BJppIrtF.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-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 +1 @@
1
- import{C as P,c as v}from"./cameraPresets-eK3mP7qb.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-DJd9xWjn.js";import{s as U}from"./weaponDuel-nFECu9nk.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./titleFrameBudget-X7HLSDre.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.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-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,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMatte-i-cJTYmK.js","assets/titleFrameBudget-X7HLSDre.js","assets/api-BFN7blbw.js","assets/i18n-BJppIrtF.js","assets/index-CKtv7gGE.js","assets/store-GFMJzaWS.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-X7HLSDre.js";import{c as at}from"./distortGL-BA5molk-.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-i-cJTYmK.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-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,4 +1,4 @@
1
- import{jb as H,c1 as K,jc as j}from"./titleFrameBudget-X7HLSDre.js";const $=`#version 300 es
1
+ import{jb as H,c1 as K,jc as j}from"./titleFrameBudget-DsM0V482.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;
@@ -0,0 +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};