@motionscript/core 0.1.0-alpha.5 → 0.1.0-alpha.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 (251) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/browser/chunks/chunk-2RIYH36X.js +3 -0
  3. package/dist/browser/chunks/{chunk-QG6C23IJ.js.map → chunk-2RIYH36X.js.map} +4 -4
  4. package/dist/browser/chunks/chunk-DDJN3QII.js +15 -0
  5. package/dist/browser/chunks/chunk-DDJN3QII.js.map +7 -0
  6. package/dist/browser/chunks/chunk-DHB4COFY.js +2 -0
  7. package/dist/browser/chunks/chunk-DHB4COFY.js.map +7 -0
  8. package/dist/browser/chunks/chunk-EJDPYDQI.js +5 -0
  9. package/dist/browser/chunks/chunk-EJDPYDQI.js.map +7 -0
  10. package/dist/browser/chunks/chunk-XAWE4EAK.js +2 -0
  11. package/dist/browser/chunks/chunk-XAWE4EAK.js.map +7 -0
  12. package/dist/browser/component.js +1 -1
  13. package/dist/browser/component.js.map +4 -4
  14. package/dist/browser/experimental.js +2 -0
  15. package/dist/browser/experimental.js.map +7 -0
  16. package/dist/browser/index.js +1 -1
  17. package/dist/browser/index.js.map +4 -4
  18. package/dist/browser/jsx-jsx-dev-runtime.js +1 -1
  19. package/dist/browser/jsx-jsx-runtime.js +1 -1
  20. package/dist/browser/manifest.json +2 -1
  21. package/dist/browser/sdk.js +1 -1
  22. package/dist/component/api.d.ts +508 -0
  23. package/dist/component/api.d.ts.map +1 -0
  24. package/dist/component/api.js +4 -0
  25. package/dist/component/api.js.map +1 -0
  26. package/dist/component/builtins/audio.d.ts +26 -0
  27. package/dist/component/builtins/audio.d.ts.map +1 -0
  28. package/dist/component/builtins/audio.js +41 -0
  29. package/dist/component/builtins/audio.js.map +1 -0
  30. package/dist/component/builtins/canvas3d.d.ts +98 -0
  31. package/dist/component/builtins/canvas3d.d.ts.map +1 -0
  32. package/dist/component/builtins/canvas3d.js +21 -0
  33. package/dist/component/builtins/canvas3d.js.map +1 -0
  34. package/dist/component/builtins/composite.d.ts +56 -0
  35. package/dist/component/builtins/composite.d.ts.map +1 -0
  36. package/dist/component/builtins/composite.js +25 -0
  37. package/dist/component/builtins/composite.js.map +1 -0
  38. package/dist/component/builtins/geometry.d.ts +505 -0
  39. package/dist/component/builtins/geometry.d.ts.map +1 -0
  40. package/dist/component/builtins/geometry.js +107 -0
  41. package/dist/component/builtins/geometry.js.map +1 -0
  42. package/dist/component/builtins/layout.d.ts +88 -0
  43. package/dist/component/builtins/layout.d.ts.map +1 -0
  44. package/dist/component/builtins/layout.js +84 -0
  45. package/dist/component/builtins/layout.js.map +1 -0
  46. package/dist/component/builtins/media.d.ts +95 -0
  47. package/dist/component/builtins/media.d.ts.map +1 -0
  48. package/dist/component/builtins/media.js +149 -0
  49. package/dist/component/builtins/media.js.map +1 -0
  50. package/dist/component/builtins/providers.d.ts +23 -0
  51. package/dist/component/builtins/providers.d.ts.map +1 -0
  52. package/dist/component/builtins/providers.js +30 -0
  53. package/dist/component/builtins/providers.js.map +1 -0
  54. package/dist/component/builtins/text.d.ts +193 -0
  55. package/dist/component/builtins/text.d.ts.map +1 -0
  56. package/dist/component/builtins/text.js +113 -0
  57. package/dist/component/builtins/text.js.map +1 -0
  58. package/dist/component/builtins/three.d.ts +1085 -0
  59. package/dist/component/builtins/three.d.ts.map +1 -0
  60. package/dist/component/builtins/three.js +265 -0
  61. package/dist/component/builtins/three.js.map +1 -0
  62. package/dist/component/clip-of.d.ts +5 -0
  63. package/dist/component/clip-of.d.ts.map +1 -0
  64. package/dist/component/clip-of.js +33 -0
  65. package/dist/component/clip-of.js.map +1 -0
  66. package/dist/component/commands-for.d.ts +19 -0
  67. package/dist/component/commands-for.d.ts.map +1 -0
  68. package/dist/component/commands-for.js +5 -0
  69. package/dist/component/commands-for.js.map +1 -0
  70. package/dist/component/component-audio.d.ts +9 -0
  71. package/dist/component/component-audio.d.ts.map +1 -0
  72. package/dist/component/component-audio.js +18 -0
  73. package/dist/component/component-audio.js.map +1 -0
  74. package/dist/component/component2d.d.ts +9 -0
  75. package/dist/component/component2d.d.ts.map +1 -0
  76. package/dist/component/component2d.js +239 -0
  77. package/dist/component/component2d.js.map +1 -0
  78. package/dist/component/component3d.d.ts +9 -0
  79. package/dist/component/component3d.d.ts.map +1 -0
  80. package/dist/component/component3d.js +99 -0
  81. package/dist/component/component3d.js.map +1 -0
  82. package/dist/component/factory.d.ts +63 -0
  83. package/dist/component/factory.d.ts.map +1 -0
  84. package/dist/component/factory.js +313 -0
  85. package/dist/component/factory.js.map +1 -0
  86. package/dist/component/modules/aim.d.ts +30 -0
  87. package/dist/component/modules/aim.d.ts.map +1 -0
  88. package/dist/component/modules/aim.js +39 -0
  89. package/dist/component/modules/aim.js.map +1 -0
  90. package/dist/component/modules/corners.d.ts +13 -0
  91. package/dist/component/modules/corners.d.ts.map +1 -0
  92. package/dist/component/modules/corners.js +12 -0
  93. package/dist/component/modules/corners.js.map +1 -0
  94. package/dist/component/modules/flow.d.ts +26 -0
  95. package/dist/component/modules/flow.d.ts.map +1 -0
  96. package/dist/component/modules/flow.js +55 -0
  97. package/dist/component/modules/flow.js.map +1 -0
  98. package/dist/component/modules/material.d.ts +40 -0
  99. package/dist/component/modules/material.d.ts.map +1 -0
  100. package/dist/component/modules/material.js +75 -0
  101. package/dist/component/modules/material.js.map +1 -0
  102. package/dist/component/modules/paint.d.ts +71 -0
  103. package/dist/component/modules/paint.d.ts.map +1 -0
  104. package/dist/component/modules/paint.js +106 -0
  105. package/dist/component/modules/paint.js.map +1 -0
  106. package/dist/component/modules/shapes.d.ts +31 -0
  107. package/dist/component/modules/shapes.d.ts.map +1 -0
  108. package/dist/component/modules/shapes.js +43 -0
  109. package/dist/component/modules/shapes.js.map +1 -0
  110. package/dist/component/modules/text-layout.d.ts +26 -0
  111. package/dist/component/modules/text-layout.d.ts.map +1 -0
  112. package/dist/component/modules/text-layout.js +57 -0
  113. package/dist/component/modules/text-layout.js.map +1 -0
  114. package/dist/component/modules/text-style.d.ts +48 -0
  115. package/dist/component/modules/text-style.d.ts.map +1 -0
  116. package/dist/component/modules/text-style.js +63 -0
  117. package/dist/component/modules/text-style.js.map +1 -0
  118. package/dist/component/modules/three-entries.d.ts +23 -0
  119. package/dist/component/modules/three-entries.d.ts.map +1 -0
  120. package/dist/component/modules/three-entries.js +41 -0
  121. package/dist/component/modules/three-entries.js.map +1 -0
  122. package/dist/component/modules/view3d.d.ts +55 -0
  123. package/dist/component/modules/view3d.d.ts.map +1 -0
  124. package/dist/component/modules/view3d.js +160 -0
  125. package/dist/component/modules/view3d.js.map +1 -0
  126. package/dist/component/timeline.d.ts +22 -0
  127. package/dist/component/timeline.d.ts.map +1 -0
  128. package/dist/component/timeline.js +128 -0
  129. package/dist/component/timeline.js.map +1 -0
  130. package/dist/component/type-def.d.ts +26 -0
  131. package/dist/component/type-def.d.ts.map +1 -0
  132. package/dist/component/type-def.js +16 -0
  133. package/dist/component/type-def.js.map +1 -0
  134. package/dist/component/types.d.ts +91 -0
  135. package/dist/component/types.d.ts.map +1 -0
  136. package/dist/component/types.js +88 -0
  137. package/dist/component/types.js.map +1 -0
  138. package/dist/component/views.d.ts +121 -0
  139. package/dist/component/views.d.ts.map +1 -0
  140. package/dist/component/views.js +413 -0
  141. package/dist/component/views.js.map +1 -0
  142. package/dist/component.d.ts +4 -5
  143. package/dist/component.d.ts.map +1 -1
  144. package/dist/component.js +3 -5
  145. package/dist/component.js.map +1 -1
  146. package/dist/document/audio.d.ts +9 -1
  147. package/dist/document/audio.d.ts.map +1 -1
  148. package/dist/document/audio.js +41 -0
  149. package/dist/document/audio.js.map +1 -1
  150. package/dist/document/builtins.d.ts.map +1 -1
  151. package/dist/document/builtins.js +9 -27
  152. package/dist/document/builtins.js.map +1 -1
  153. package/dist/document/command-traits.js +3 -0
  154. package/dist/document/command-traits.js.map +1 -1
  155. package/dist/document/diff.d.ts.map +1 -1
  156. package/dist/document/diff.js +3 -3
  157. package/dist/document/diff.js.map +1 -1
  158. package/dist/document/doc-index.d.ts.map +1 -1
  159. package/dist/document/doc-index.js +3 -3
  160. package/dist/document/doc-index.js.map +1 -1
  161. package/dist/document/node-descriptor.d.ts +6 -0
  162. package/dist/document/node-descriptor.d.ts.map +1 -1
  163. package/dist/document/node-descriptor.js.map +1 -1
  164. package/dist/document/placement.js +2 -2
  165. package/dist/document/placement.js.map +1 -1
  166. package/dist/document/registry.d.ts +6 -11
  167. package/dist/document/registry.d.ts.map +1 -1
  168. package/dist/document/registry.js +17 -17
  169. package/dist/document/registry.js.map +1 -1
  170. package/dist/document/settled-index.d.ts +49 -0
  171. package/dist/document/settled-index.d.ts.map +1 -0
  172. package/dist/document/settled-index.js +247 -0
  173. package/dist/document/settled-index.js.map +1 -0
  174. package/dist/document/timeline.d.ts +27 -1
  175. package/dist/document/timeline.d.ts.map +1 -1
  176. package/dist/document/timeline.js +98 -2
  177. package/dist/document/timeline.js.map +1 -1
  178. package/dist/experimental.d.ts +22 -0
  179. package/dist/experimental.d.ts.map +1 -0
  180. package/dist/experimental.js +20 -0
  181. package/dist/experimental.js.map +1 -0
  182. package/dist/index.d.ts +9 -0
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +9 -0
  185. package/dist/index.js.map +1 -1
  186. package/dist/nodes/audio/index.d.ts +2 -2
  187. package/dist/nodes/audio/index.d.ts.map +1 -1
  188. package/dist/nodes/audio/index.js +0 -2
  189. package/dist/nodes/audio/index.js.map +1 -1
  190. package/dist/nodes/audio/sound-node.d.ts +2 -1
  191. package/dist/nodes/audio/sound-node.d.ts.map +1 -1
  192. package/dist/nodes/audio/sound-node.js +3 -0
  193. package/dist/nodes/audio/sound-node.js.map +1 -1
  194. package/dist/nodes/index.d.ts +39 -27
  195. package/dist/nodes/index.d.ts.map +1 -1
  196. package/dist/nodes/index.js +16 -30
  197. package/dist/nodes/index.js.map +1 -1
  198. package/dist/nodes/node/node.d.ts +7 -1
  199. package/dist/nodes/node/node.d.ts.map +1 -1
  200. package/dist/nodes/node/node.js +23 -8
  201. package/dist/nodes/node/node.js.map +1 -1
  202. package/dist/nodes/root/canvas2d-node.d.ts +2 -1
  203. package/dist/nodes/root/canvas2d-node.d.ts.map +1 -1
  204. package/dist/nodes/root/canvas2d-node.js +3 -0
  205. package/dist/nodes/root/canvas2d-node.js.map +1 -1
  206. package/dist/nodes/text/richtext-node.d.ts +0 -5
  207. package/dist/nodes/text/richtext-node.d.ts.map +1 -1
  208. package/dist/nodes/text/richtext-node.js +5 -71
  209. package/dist/nodes/text/richtext-node.js.map +1 -1
  210. package/dist/nodes/text/text-base.d.ts +5 -22
  211. package/dist/nodes/text/text-base.d.ts.map +1 -1
  212. package/dist/nodes/text/text-base.js +12 -363
  213. package/dist/nodes/text/text-base.js.map +1 -1
  214. package/dist/nodes/text/text-layout.d.ts +87 -0
  215. package/dist/nodes/text/text-layout.d.ts.map +1 -0
  216. package/dist/nodes/text/text-layout.js +368 -0
  217. package/dist/nodes/text/text-layout.js.map +1 -0
  218. package/dist/nodes/three/canvas3d-node.d.ts +3 -1
  219. package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
  220. package/dist/nodes/three/canvas3d-node.js +6 -0
  221. package/dist/nodes/three/canvas3d-node.js.map +1 -1
  222. package/dist/runtime/clip-instance.d.ts +4 -1
  223. package/dist/runtime/clip-instance.d.ts.map +1 -1
  224. package/dist/runtime/clip-instance.js +17 -3
  225. package/dist/runtime/clip-instance.js.map +1 -1
  226. package/dist/runtime/clip-store.d.ts +9 -0
  227. package/dist/runtime/clip-store.d.ts.map +1 -1
  228. package/dist/runtime/clip-store.js +78 -0
  229. package/dist/runtime/clip-store.js.map +1 -1
  230. package/dist/runtime/node-picking.d.ts.map +1 -1
  231. package/dist/runtime/node-picking.js +6 -7
  232. package/dist/runtime/node-picking.js.map +1 -1
  233. package/dist/runtime/node-picking3d.d.ts +11 -4
  234. package/dist/runtime/node-picking3d.d.ts.map +1 -1
  235. package/dist/runtime/node-picking3d.js +5 -0
  236. package/dist/runtime/node-picking3d.js.map +1 -1
  237. package/dist/runtime/text-geometry.d.ts.map +1 -1
  238. package/dist/runtime/text-geometry.js +7 -3
  239. package/dist/runtime/text-geometry.js.map +1 -1
  240. package/dist/sdk/index.d.ts +35 -14
  241. package/dist/sdk/index.d.ts.map +1 -1
  242. package/dist/sdk/index.js +47 -42
  243. package/dist/sdk/index.js.map +1 -1
  244. package/dist/tween/command.d.ts +12 -0
  245. package/dist/tween/command.d.ts.map +1 -1
  246. package/dist/tween/command.js +14 -0
  247. package/dist/tween/command.js.map +1 -1
  248. package/package.json +6 -1
  249. package/dist/browser/chunks/chunk-FUZVFT3W.js +0 -18
  250. package/dist/browser/chunks/chunk-FUZVFT3W.js.map +0 -7
  251. package/dist/browser/chunks/chunk-QG6C23IJ.js +0 -3
@@ -1,18 +0,0 @@
1
- import{A as kc,E as Ac,I as Mc,J as ht,K as Yt,P as Oc,T as Ec,a as m,b as yc,c as D,d as qi,e as Vi,f as Gi,g as G,l as be,m as gc,n as pt,o as xc,p as _c,t as wc,u as We,v as vc,w as Io,x as Dn,y as Sc,z as bc}from"./chunk-QG6C23IJ.js";function Cc(t){return{topLeft:t,topRight:t,bottomLeft:t,bottomRight:t}}function Gm(t,e){return{topLeft:t.top??e.topLeft,topRight:t.top??e.topRight,bottomLeft:t.bottom??e.bottomLeft,bottomRight:t.bottom??e.bottomRight}}function Ym(t,e){return{topLeft:t.left??e.topLeft,topRight:t.right??e.topRight,bottomLeft:t.left??e.bottomLeft,bottomRight:t.right??e.bottomRight}}function Rn(t,e,r,n){if(n(t))return Cc(t);let o=r??Cc(e),s=t;if("topLeft"in s||"topRight"in s||"bottomLeft"in s||"bottomRight"in s){let i=t;return{topLeft:i.topLeft??o.topLeft,topRight:i.topRight??o.topRight,bottomLeft:i.bottomLeft??o.bottomLeft,bottomRight:i.bottomRight??o.bottomRight}}return"top"in s||"bottom"in s?Gm(t,o):"left"in s||"right"in s?Ym(t,o):{...o}}function Fn(t,e,r,n){return{topLeft:n(t.topLeft,e.topLeft,r),topRight:n(t.topRight,e.topRight,r),bottomLeft:n(t.bottomLeft,e.bottomLeft,r),bottomRight:n(t.bottomRight,e.bottomRight,r)}}function In(t,e=Object.is){return e(t.topLeft,t.topRight)&&e(t.topLeft,t.bottomLeft)&&e(t.topLeft,t.bottomRight)}var vr={resolve:(t,e)=>Rn(t,0,e,r=>typeof r=="number"),lerp:(t,e,r)=>Fn(t,e,r,m),isUniformInput:t=>typeof t=="number",isUniform:t=>In(t),isZero:t=>t.topLeft===0&&t.topRight===0&&t.bottomLeft===0&&t.bottomRight===0};var zo={resolve:(t,e)=>Rn(t,"rounded",e,r=>r==="rounded"||r==="angled"),lerp:(t,e,r)=>Fn(t,e,r,(n,o)=>r<.5?n:o),isUniformInput:t=>t==="rounded"||t==="angled",isUniform:t=>In(t)},Sr=(t,e,r)=>r<.5?t:e;function Ur(t){switch(t){case"x":return{x:1,y:0};case"y":return{x:0,y:1};case"both":return{x:1,y:1};default:return{x:t.x,y:t.y}}}function Dt(t,e){let r=Ur(t),n=Ur(e);return r.x===n.x&&r.y===n.y}function U(t){return Array.isArray(t)?t:G(t)}function ke(t,e){if(t===e)return!0;let r=U(t),n=U(e);return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}var No=["mode","clip"];function R(t,e){let r={...t};if(!e)return r;for(let n of No){let o=e[n];o!==void 0&&(r[n]=o)}return r}function N(t,e){return t===void 0?{}:typeof t=="number"?{[e]:t}:t}function zn(t){switch(t){case"behind":return-1;case"centered":return 0;case"ahead":return 1;default:return Math.max(-1,Math.min(1,t))}}var Pc={lerp:(t,e,r)=>({type:"motionBlur",length:m(t.length,e.length,r),alignment:m(zn(t.alignment),zn(e.alignment),r),samples:m(t.samples,e.samples,r),strength:m(t.strength,e.strength,r),axis:D(Ur(t.axis),Ur(e.axis),r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.length===e.length&&zn(t.alignment)===zn(e.alignment)&&t.samples===e.samples&&t.strength===e.strength&&Dt(t.axis,e.axis)&&t.mode===e.mode};function Z(t,e,r){return[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r,t[2]+(e[2]-t[2])*r,t[3]+(e[3]-t[3])*r]}var jo={resolve:Tc,lerp:Z,hex(t){let[e,r,n,o]=Tc(t),s=$o(o);return`#${$o(e)}${$o(r)}${$o(n)}${s==="ff"?"":s}`}};function Tc(t){return Array.isArray(t)?t:G(t)}function $o(t){return Math.round(Math.min(1,Math.max(0,t))*255).toString(16).padStart(2,"0")}var Dc={standard:" .:-=+*#%@",blocks:" \u2591\u2592\u2593\u2588",braille:" \u2804\u28C0\u28C4\u28E4\u28F6\u28F7\u28FF",binary:"01",hex:"0123456789ABCDEF"};function Km(t){return Dc[t]??t}var Rc={lerp:(t,e,r)=>({type:"ascii",size:m(t.size,e.size,r),charset:r<.5?t.charset:e.charset,fontFamily:r<.5?t.fontFamily:e.fontFamily,ink:Z(U(t.ink),U(e.ink),r),background:Z(U(t.background),U(e.background),r),colored:r<.5?t.colored:e.colored,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.size===e.size&&t.charset===e.charset&&t.fontFamily===e.fontFamily&&ke(t.ink,e.ink)&&ke(t.background,e.background)&&t.colored===e.colored&&t.mode===e.mode,surface:"shader"};var Bo=new Set;function Xr(t,e){let r=`${t}\0${e}`;Bo.has(r)||(Bo.size>512&&Bo.clear(),Bo.add(r),console.warn(`[SkSL] ${e}`))}function Hm(t,e){if(typeof e=="number")return Number.isFinite(e)?e:(Xr("normalize",`uniform "${t}" is ${e}; ignoring it.`),null);if(!Array.isArray(e))return Xr("normalize",`uniform "${t}" is not a number or number array; ignoring it.`),null;let r=e.flat(1/0),n=[];for(let o of r){if(typeof o!="number"||!Number.isFinite(o))return Xr("normalize",`uniform "${t}" contains a non-finite entry; ignoring it.`),null;n.push(o)}return n}function Ze(t){if(!t)return{};let e=Array.isArray(t)?t.map(n=>[n.name,n.value]):Object.entries(t),r={};for(let[n,o]of e.sort(([s],[i])=>s<i?-1:s>i?1:0)){let s=Hm(n,o);s!==null&&(r[n]=s)}return r}function Ic(t,e,r){if(typeof t=="number"&&typeof e=="number")return m(t,e,r);if(Array.isArray(t)&&Array.isArray(e)){let n=Math.max(t.length,e.length);return Array.from({length:n},(o,s)=>m(t[s]??0,e[s]??0,r))}return r<.5?t:e}function zc(t,e){return typeof t=="number"&&typeof e=="number"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((r,n)=>r===e[n]):!1}function Nn(t,e,r){let n={};for(let o of[...Object.keys(t),...Object.keys(e)].sort()){if(o in n)continue;let s=t[o],i=e[o];s===void 0?n[o]=i:i===void 0?n[o]=s:n[o]=Ic(s,i,r)}return n}function $n(t,e){let r=Object.keys(t);return r.length!==Object.keys(e).length?!1:r.every(n=>{let o=e[n];return o!==void 0&&zc(t[n],o)})}function Um(t){let e=[],r=t.getUniformCount();for(let n=0;n<r;n++){let o=t.getUniform(n);e.push({name:t.getUniformName(n),slot:o.slot,length:Math.max(1,o.columns*o.rows),isInteger:!!o.isInteger})}return e}function Xm(t,e,r,n,o){let s=new Float32Array(Math.max(0,e)),i=new Int32Array(s.buffer);for(let a of t){let l=a.name in r?r[a.name]:n[a.name];if(l===void 0){Xr(o,`uniform "${a.name}" is declared but was not supplied; it will read as 0.`);continue}let c=typeof l=="number"?[l]:l;c.length!==a.length&&Xr(o,`uniform "${a.name}" expects ${a.length} float(s) but got ${c.length}; the rest will read as 0.`);let d=Math.min(c.length,a.length);for(let u=0;u<d;u++){let f=a.slot+u;if(f<0||f>=s.length)break;a.isInteger?i[f]=Math.round(c[u]):s[f]=c[u]}}for(let a of Object.keys(r))t.some(l=>l.name===a)||Xr(o,`uniform "${a}" was supplied but the shader declares no such uniform.`);return s}function Zm(t,e){let r=e.right-e.left,n=e.bottom-e.top;switch(t){case"centered":return[n,0,e.left+r/2,0,n,e.top+n/2,0,0,1];case"normalized":return[r,0,e.left,0,n,e.top,0,0,1];default:return[1,0,0,0,1,0,0,0,1]}}var Fc=/\buniform\s+(shader|colorFilter|blender)\s+([A-Za-z_]\w*)\s*;/g;function Jm(t){let e=t.replace(/\/\*[\s\S]*?\*\//g," ").replace(/\/\/[^\n]*/g," "),r=[];Fc.lastIndex=0;let n;for(;(n=Fc.exec(e))!==null;)r.push({kind:n[1],name:n[2]});return r}var Nc={lerp:(t,e,r)=>({type:"blur",radius:m(t.radius,e.radius,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.radius===e.radius&&t.mode===e.mode};var $c={lerp:(t,e,r)=>({type:"directionalBlur",radius:m(t.radius,e.radius,r),angle:m(t.angle,e.angle,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.radius===e.radius&&t.angle===e.angle&&t.mode===e.mode};var jc={lerp:(t,e,r)=>({type:"grayscale",amount:m(t.amount,e.amount,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.mode===e.mode};var Bc={lerp:(t,e,r)=>({type:"pixelate",blocks:D(t.blocks,e.blocks,r),sharpColors:r<.5?t.sharpColors:e.sharpColors,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.blocks.x===e.blocks.x&&t.blocks.y===e.blocks.y&&t.sharpColors===e.sharpColors&&t.mode===e.mode};var Lc={lerp:(t,e,r)=>({type:"bulge",strength:m(t.strength,e.strength,r),center:D(t.center,e.center,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.strength===e.strength&&t.center.x===e.center.x&&t.center.y===e.center.y&&t.mode===e.mode,surface:"shader"};var Wc={lerp:(t,e,r)=>({type:"magnify",center:D(t.center,e.center,r),scale:m(t.scale,e.scale,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.center.x===e.center.x&&t.center.y===e.center.y&&t.scale===e.scale&&t.mode===e.mode,surface:"shader"};var qc={lerp:(t,e,r)=>({type:"bloom",threshold:m(t.threshold,e.threshold,r),radius:m(t.radius,e.radius,r),intensity:m(t.intensity,e.intensity,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.threshold===e.threshold&&t.radius===e.radius&&t.intensity===e.intensity&&t.mode===e.mode};var Vc={lerp:(t,e,r)=>({type:"vintage",amount:m(t.amount,e.amount,r),warmth:m(t.warmth,e.warmth,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.warmth===e.warmth&&t.mode===e.mode};var Gc={lerp:(t,e,r)=>({type:"chromaticAberration",amount:m(t.amount,e.amount,r),angle:m(t.angle,e.angle,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.angle===e.angle&&t.mode===e.mode};var Yc={lerp:(t,e,r)=>({type:"invert",channel:r<.5?t.channel:e.channel,strength:m(t.strength,e.strength,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.channel===e.channel&&t.strength===e.strength&&t.mode===e.mode};var Kc={lerp:(t,e,r)=>({type:"scatter",strength:m(t.strength,e.strength,r),axis:r<.5?t.axis:e.axis,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.strength===e.strength&&Dt(t.axis,e.axis)&&t.mode===e.mode,surface:"shader"};var Hc={lerp:(t,e,r)=>({type:"posterize",levels:m(t.levels,e.levels,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.levels===e.levels&&t.mode===e.mode,surface:"shader"};var Uc={resolve:t=>{let e=t;if(!(t.type!=="shader"||e.shader!==void 0))return t;let{shader:n,...o}=e;return{...o,type:"shader",source:t.source??n??""}},lerp:(t,e,r)=>{let n=r<.5?t:e;return{type:"shader",source:n.source,...n.shaderId!==void 0?{shaderId:n.shaderId}:{},mode:n.mode,blendMode:n.blendMode,uniforms:Nn(Ze(t.uniforms),Ze(e.uniforms),r)}},equals:(t,e)=>t.source===e.source&&t.mode===e.mode&&t.blendMode===e.blendMode&&$n(Ze(t.uniforms),Ze(e.uniforms)),surface:t=>t.mode==="backdrop"?"shader":"filter"};var Xc={lerp:(t,e,r)=>({type:"outline",width:m(t.width,e.width,r),color:Z(U(t.color),U(e.color),r),position:r<.5?t.position:e.position,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.width===e.width&&ke(t.color,e.color)&&t.position===e.position&&t.mode===e.mode,surface:"shader"};var Zc={lerp:(t,e,r)=>({type:"dropShadow",offsetX:m(t.offsetX,e.offsetX,r),offsetY:m(t.offsetY,e.offsetY,r),blur:m(t.blur,e.blur,r),spread:m(t.spread,e.spread,r),color:Z(U(t.color),U(e.color),r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.offsetX===e.offsetX&&t.offsetY===e.offsetY&&t.blur===e.blur&&t.spread===e.spread&&ke(t.color,e.color)&&t.mode===e.mode,surface:"shader"};var Jc={lerp:(t,e,r)=>({type:"vignette",amount:m(t.amount,e.amount,r),radius:m(t.radius,e.radius,r),softness:m(t.softness,e.softness,r),color:Z(U(t.color),U(e.color),r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.radius===e.radius&&t.softness===e.softness&&ke(t.color,e.color)&&t.mode===e.mode,surface:"shader"};var Qc={lerp:(t,e,r)=>({type:"grain",amount:m(t.amount,e.amount,r),size:m(t.size,e.size,r),seed:m(t.seed,e.seed,r),animated:r<.5?t.animated:e.animated,colored:r<.5?t.colored:e.colored,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.size===e.size&&t.seed===e.seed&&t.animated===e.animated&&t.colored===e.colored&&t.mode===e.mode,surface:"shader"};var ed={lerp:(t,e,r)=>({type:"sharpen",amount:m(t.amount,e.amount,r),radius:m(t.radius,e.radius,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.radius===e.radius&&t.mode===e.mode,surface:"shader"};var td={lerp:(t,e,r)=>({type:"edges",strength:m(t.strength,e.strength,r),kernel:r<.5?t.kernel:e.kernel,colored:r<.5?t.colored:e.colored,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.strength===e.strength&&t.kernel===e.kernel&&t.colored===e.colored&&t.mode===e.mode,surface:"shader"};var rd={lerp:(t,e,r)=>({type:"threshold",level:m(t.level,e.level,r),smoothness:m(t.smoothness,e.smoothness,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.level===e.level&&t.smoothness===e.smoothness&&t.mode===e.mode,surface:"shader"};var nd={lerp:(t,e,r)=>({type:"radialBlur",amount:m(t.amount,e.amount,r),style:r<.5?t.style:e.style,center:D(t.center,e.center,r),samples:r<.5?t.samples:e.samples,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.style===e.style&&t.center.x===e.center.x&&t.center.y===e.center.y&&t.samples===e.samples&&t.mode===e.mode,surface:"shader"};var od={lerp:(t,e,r)=>({type:"halftone",size:m(t.size,e.size,r),angle:m(t.angle,e.angle,r),shape:r<.5?t.shape:e.shape,separation:r<.5?t.separation:e.separation,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.size===e.size&&t.angle===e.angle&&t.shape===e.shape&&t.separation===e.separation&&t.mode===e.mode,surface:"shader"};var sd={lerp:(t,e,r)=>({type:"dither",levels:m(t.levels,e.levels,r),matrix:r<.5?t.matrix:e.matrix,scale:m(t.scale,e.scale,r),monochrome:r<.5?t.monochrome:e.monochrome,noise:r<.5?t.noise:e.noise,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.levels===e.levels&&t.matrix===e.matrix&&t.scale===e.scale&&t.monochrome===e.monochrome&&t.noise===e.noise&&t.mode===e.mode,surface:"shader"};var id={lerp:(t,e,r)=>({type:"duotone",amount:m(t.amount,e.amount,r),shadows:Z(U(t.shadows),U(e.shadows),r),highlights:Z(U(t.highlights),U(e.highlights),r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&ke(t.shadows,e.shadows)&&ke(t.highlights,e.highlights)&&t.mode===e.mode};var ad={lerp:(t,e,r)=>({type:"curves",channel:r<.5?t.channel:e.channel,points:t.points.map(([n,o],s)=>{let[i,a]=e.points[s]??[n,o];return[m(n,i,r),m(o,a,r)]}),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.channel===e.channel&&t.mode===e.mode&&t.points.length===e.points.length&&t.points.every(([r,n],o)=>r===e.points[o]?.[0]&&n===e.points[o]?.[1]),surface:"shader"};var ld={lerp:(t,e,r)=>({type:"colorAdjustment",brightness:m(t.brightness??0,e.brightness??0,r),contrast:m(t.contrast??1,e.contrast??1,r),saturation:m(t.saturation??1,e.saturation??1,r),hue:m(t.hue??0,e.hue??0,r),vibrance:m(t.vibrance??0,e.vibrance??0,r),shadows:m(t.shadows??0,e.shadows??0,r),highlights:m(t.highlights??0,e.highlights??0,r),temperature:m(t.temperature??0,e.temperature??0,r),tint:m(t.tint??0,e.tint??0,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.brightness===e.brightness&&t.contrast===e.contrast&&t.saturation===e.saturation&&t.hue===e.hue&&t.vibrance===e.vibrance&&t.shadows===e.shadows&&t.highlights===e.highlights&&t.temperature===e.temperature&&t.tint===e.tint&&t.mode===e.mode};var Yi=(t,e)=>t.x===e.x&&t.y===e.y,cd={lerp:(t,e,r)=>({type:"rgbShift",red:D(t.red,e.red,r),green:D(t.green,e.green,r),blue:D(t.blue,e.blue,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>Yi(t.red,e.red)&&Yi(t.green,e.green)&&Yi(t.blue,e.blue)&&t.mode===e.mode,surface:"shader"};var dd={lerp:(t,e,r)=>({type:"scanlines",spacing:m(t.spacing,e.spacing,r),thickness:m(t.thickness,e.thickness,r),darkness:m(t.darkness,e.darkness,r),offset:m(t.offset,e.offset,r),angle:m(t.angle,e.angle,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.spacing===e.spacing&&t.thickness===e.thickness&&t.darkness===e.darkness&&t.offset===e.offset&&t.angle===e.angle&&t.mode===e.mode,surface:"shader"};var ud={lerp:(t,e,r)=>({type:"blockDisplace",amount:m(t.amount,e.amount,r),size:m(t.size,e.size,r),density:m(t.density,e.density,r),seed:m(t.seed,e.seed,r),axis:r<.5?t.axis:e.axis,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amount===e.amount&&t.size===e.size&&t.density===e.density&&t.seed===e.seed&&Dt(t.axis,e.axis)&&t.mode===e.mode,surface:"shader"};var fd={lerp:(t,e,r)=>({type:"bitCrush",bits:m(t.bits,e.bits,r),palette:r<.5?t.palette:e.palette,amount:m(t.amount,e.amount,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.bits===e.bits&&t.palette===e.palette&&t.amount===e.amount&&t.mode===e.mode,surface:"shader"};var pd={lerp:(t,e,r)=>({type:"streak",intensity:m(t.intensity,e.intensity,r),threshold:m(t.threshold,e.threshold,r),length:m(t.length,e.length,r),angle:m(t.angle,e.angle,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.intensity===e.intensity&&t.threshold===e.threshold&&t.length===e.length&&t.angle===e.angle&&t.mode===e.mode};function Qm(t,e,r){return t.colors.length!==e.colors.length?r<.5?t:e:{colors:t.colors.map((n,o)=>Z(U(n),U(e.colors[o]),r)),stops:t.stops.map((n,o)=>m(n,e.stops[o]??n,r))}}function ey(t,e){return t.colors.length!==e.colors.length||t.stops.length!==e.stops.length?!1:t.colors.every((r,n)=>ke(r,e.colors[n]))&&t.stops.every((r,n)=>r===e.stops[n])}var hd={lerp:(t,e,r)=>({type:"glow",threshold:m(t.threshold,e.threshold,r),radius:m(t.radius,e.radius,r),spread:m(t.spread,e.spread,r),intensity:m(t.intensity,e.intensity,r),cycles:m(t.cycles,e.cycles,r),phase:m(t.phase,e.phase,r),color:Z(U(t.color),U(e.color),r),...Qm(t,e,r),channel:r<.5?t.channel:e.channel,axis:r<.5?t.axis:e.axis,original:r<.5?t.original:e.original,blend:r<.5?t.blend:e.blend,tint:r<.5?t.tint:e.tint,loopStyle:r<.5?t.loopStyle:e.loopStyle,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.channel===e.channel&&t.threshold===e.threshold&&t.radius===e.radius&&t.spread===e.spread&&t.intensity===e.intensity&&Dt(t.axis,e.axis)&&t.original===e.original&&t.blend===e.blend&&t.tint===e.tint&&ke(t.color,e.color)&&ey(t,e)&&t.loopStyle===e.loopStyle&&t.cycles===e.cycles&&t.phase===e.phase&&t.mode===e.mode,surface:"shader"};var md={lerp:(t,e,r)=>({type:"oilPaint",radius:m(t.radius,e.radius,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.radius===e.radius&&t.mode===e.mode,surface:"shader"};var yd={lerp:(t,e,r)=>({type:"wave",amplitude:D(t.amplitude,e.amplitude,r),wavelength:m(t.wavelength,e.wavelength,r),phase:m(t.phase,e.phase,r),shape:r<.5?t.shape:e.shape,angle:m(t.angle,e.angle,r),center:D(t.center,e.center,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.amplitude.x===e.amplitude.x&&t.amplitude.y===e.amplitude.y&&t.wavelength===e.wavelength&&t.phase===e.phase&&t.shape===e.shape&&t.angle===e.angle&&t.center.x===e.center.x&&t.center.y===e.center.y&&t.mode===e.mode,surface:"shader"};var gd={lerp:(t,e,r)=>({type:"twirl",angle:m(t.angle,e.angle,r),radius:m(t.radius,e.radius,r),center:D(t.center,e.center,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.angle===e.angle&&t.radius===e.radius&&t.center.x===e.center.x&&t.center.y===e.center.y&&t.mode===e.mode,surface:"shader"};var xd={lerp:(t,e,r)=>({type:"progressiveBlur",radius:m(t.radius,e.radius,r),startRadius:m(t.startRadius,e.startRadius,r),shape:r<.5?t.shape:e.shape,start:m(t.start,e.start,r),end:m(t.end,e.end,r),angle:m(t.angle,e.angle,r),center:D(t.center,e.center,r),samples:r<.5?t.samples:e.samples,mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.radius===e.radius&&t.startRadius===e.startRadius&&t.shape===e.shape&&t.start===e.start&&t.end===e.end&&t.angle===e.angle&&t.center.x===e.center.x&&t.center.y===e.center.y&&t.samples===e.samples&&t.mode===e.mode,surface:"shader"};var _d={lerp:(t,e,r)=>({type:"kaleidoscope",segments:r<.5?t.segments:e.segments,angle:m(t.angle,e.angle,r),center:D(t.center,e.center,r),offset:m(t.offset,e.offset,r),amount:m(t.amount,e.amount,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.segments===e.segments&&t.angle===e.angle&&t.center.x===e.center.x&&t.center.y===e.center.y&&t.offset===e.offset&&t.amount===e.amount&&t.mode===e.mode,surface:"shader"};var wd={lerp:(t,e,r)=>({type:"glass",lightAngle:m(t.lightAngle,e.lightAngle,r),lightIntensity:m(t.lightIntensity,e.lightIntensity,r),refraction:m(t.refraction,e.refraction,r),depth:m(t.depth,e.depth,r),dispersion:m(t.dispersion,e.dispersion,r),frost:m(t.frost,e.frost,r),splay:m(t.splay,e.splay,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.lightAngle===e.lightAngle&&t.lightIntensity===e.lightIntensity&&t.refraction===e.refraction&&t.depth===e.depth&&t.dispersion===e.dispersion&&t.frost===e.frost&&t.splay===e.splay&&t.mode===e.mode,surface:"shader"};var vd={lerp:(t,e,r)=>({type:"lut",table:r<.5?t.table:e.table,size:r<.5?t.size:e.size,amount:m(t.amount,e.amount,r),mode:r<.5?t.mode:e.mode}),equals:(t,e)=>t.table===e.table&&t.size===e.size&&t.amount===e.amount&&t.mode===e.mode,surface:"shader"};var Sd=new Map([["blur",Nc],["directionalBlur",$c],["grayscale",jc],["pixelate",Bc],["bulge",Lc],["magnify",Wc],["bloom",qc],["vintage",Vc],["chromaticAberration",Gc],["invert",Yc],["scatter",Kc],["posterize",Hc],["motionBlur",Pc],["shader",Uc],["outline",Xc],["dropShadow",Zc],["vignette",Jc],["grain",Qc],["sharpen",ed],["edges",td],["threshold",rd],["radialBlur",nd],["halftone",od],["dither",sd],["duotone",id],["curves",ad],["colorAdjustment",ld],["rgbShift",cd],["scanlines",dd],["blockDisplace",ud],["bitCrush",fd],["ascii",Rc],["streak",pd],["glow",hd],["oilPaint",md],["wave",yd],["twirl",gd],["progressiveBlur",xd],["kaleidoscope",_d],["glass",wd],["lut",vd]]),ty=new Map([["sksl","shader"]]);function jn(t){let e=Sd.get(t);if(e)return e;let r=ty.get(t);return r?Sd.get(r):void 0}function Lo(t){let e=jn(t.type);return e?.resolve?e.resolve(t):t}function bd(t){return jn(t)!==void 0}function Bn(t){let e=jn(t.type)?.surface;return e===void 0?"filter":typeof e=="function"?e(t):e}function Wo(t,e){jn(t.type)?.declare?.(t,e)}function Ln(t,e,r){if(t.type!==e.type)return r<.5?t:e;let n=jn(t.type);if(!n)return r<.5?t:e;let o=n.lerp(t,e,r),s=r<.5?t:e,i;for(let a of No){if(o[a]===s[a])continue;i??={...o};let l=i;s[a]===void 0?delete l[a]:l[a]=s[a]}return i??o}var ry=["x","y","z","w"],ny=["r","g","b","a"];function Go(t,e){let r={...t.uniforms??{}};for(let[n,o]of Object.entries(t.properties)){let s=e&&n in e?e[n]:o.default,i=oy(o,s,n,t.name);if(i)for(let[a,l]of Object.entries(o.inputs)){let c=i[a];if(c===void 0){Vo(`shader "${t.name}" property "${n}" has no "${a}" to write to "${l}".`);continue}r[l]=c}}if(e)for(let n of Object.keys(e))n in t.properties||Vo(`shader "${t.name}" has no property "${n}"; the override is ignored.`);return r}function oy(t,e,r,n){let o=sy(t,e,r,n);if(o===void 0)return;let s=Object.keys(t.inputs);if(s.length===1&&s[0]==="value")return{value:o};let i=typeof o=="number"?[o]:o,a={value:o};for(let[l,c]of ry.entries())i[l]!==void 0&&(a[c]=i[l]);for(let[l,c]of ny.entries())i[l]!==void 0&&(a[c]=i[l]);return a}function sy(t,e,r,n){switch(t.kind){case"number":case"slider":case"angle":case"hue":return iy(e,r,n);case"boolean":return e?1:0;case"color":return ay(e,r,n);case"vector":case"point":return kd(e,r,n);default:return typeof e=="number"||Array.isArray(e)?e:void 0}}function iy(t,e,r){if(typeof t=="number"&&Number.isFinite(t))return t;Vo(`shader "${r}" property "${e}" expects a number, got ${JSON.stringify(t)}.`)}function ay(t,e,r){if(typeof t=="string"){let[n,o,s,i]=G(t);return[n,o,s,i]}return kd(t,e,r)}function kd(t,e,r){if(Array.isArray(t)&&t.every(n=>typeof n=="number"&&Number.isFinite(n)))return t;if(typeof t=="object"&&t!==null){let n=t;if(typeof n.x=="number"&&typeof n.y=="number")return[n.x,n.y]}Vo(`shader "${r}" property "${e}" expects numbers, got ${JSON.stringify(t)}.`)}var qo=new Set;function Vo(t){qo.has(t)||(qo.size>256&&qo.clear(),qo.add(t),console.warn(`[shader] ${t}`))}var br={x:.5,y:.5},ly=["white","#ffa640"],cy=[0,1],dy={x:0,y:0},uy=t=>typeof t=="number"?{x:t,y:t}:t,fy=t=>typeof t=="number"?{x:0,y:t}:t,z=class t{list;constructor(e=[]){this.list=e}append(e){return new t([...this.list,e])}blur(e){let r=N(e,"radius");return this.append(R({type:"blur",radius:r.radius??0},r))}directionalBlur(e){let r=N(e,"radius");return this.append(R({type:"directionalBlur",radius:r.radius??0,angle:r.angle??0},r))}pixelate(e){let r=N(e,"blocks");return this.append(R({type:"pixelate",blocks:uy(r.blocks??1),sharpColors:r.sharpColors??!0},r))}grayscale(e){let r=N(e,"amount");return this.append(R({type:"grayscale",amount:r.amount??0},r))}bulge(e){let r=N(e,"strength");return this.append(R({type:"bulge",strength:r.strength??0,center:r.center??br},r))}magnify(e){let r=N(e,"scale");return this.append(R({type:"magnify",scale:r.scale??2,center:r.center??br},{...r,mode:r.mode??"backdrop"}))}bloom(e){let r=N(e,"intensity");return this.append(R({type:"bloom",threshold:r.threshold??.7,radius:r.radius??12,intensity:r.intensity??1},r))}vintage(e){let r=N(e,"amount");return this.append(R({type:"vintage",amount:r.amount??1,warmth:r.warmth??.2},r))}chromaticAberration(e){let r=N(e,"amount");return this.append(R({type:"chromaticAberration",amount:r.amount??4,angle:r.angle??0},r))}invert(e){let r=N(e,"strength");return this.append(R({type:"invert",channel:r.channel??"rgba",strength:r.strength??1},r))}scatter(e){let r=N(e,"strength");return this.append(R({type:"scatter",strength:r.strength??10,axis:r.axis??"both"},r))}posterize(e){let r=N(e,"levels");return this.append(R({type:"posterize",levels:r.levels??4},r))}motionBlur(e){let r=N(e,"length");return this.append(R({type:"motionBlur",length:r.length??50,alignment:r.alignment??"centered",samples:r.samples??16,strength:r.strength??1,axis:r.axis??"both"},r))}outline(e){let r=N(e,"width");return this.append(R({type:"outline",width:r.width??4,color:r.color??"black",position:r.position??"outside"},r))}dropShadow(e){let r=N(e,"blur");return this.append(R({type:"dropShadow",offsetX:r.offsetX??0,offsetY:r.offsetY??-8,blur:r.blur??16,spread:r.spread??0,color:r.color??"black"},r))}vignette(e){let r=N(e,"amount");return this.append(R({type:"vignette",amount:r.amount??.5,radius:r.radius??.75,softness:r.softness??.5,color:r.color??"black"},r))}lut(e){return this.append(R({type:"lut",table:e.table,size:e.size,amount:e.amount??1},e))}grain(e){let r=N(e,"amount");return this.append(R({type:"grain",amount:r.amount??.25,size:r.size??1,seed:r.seed??0,animated:r.animated??!1,colored:r.colored??!1},r))}sharpen(e){let r=N(e,"amount");return this.append(R({type:"sharpen",amount:r.amount??1,radius:r.radius??1},r))}edges(e){let r=N(e,"strength");return this.append(R({type:"edges",strength:r.strength??1,kernel:r.kernel??"sobel",colored:r.colored??!1},r))}threshold(e){let r=N(e,"level");return this.append(R({type:"threshold",level:r.level??.5,smoothness:r.smoothness??.05},r))}radialBlur(e){let r=N(e,"amount");return this.append(R({type:"radialBlur",amount:r.amount??.5,style:r.style??"zoom",center:r.center??br,samples:r.samples??16},r))}halftone(e){let r=N(e,"size");return this.append(R({type:"halftone",size:r.size??8,angle:r.angle??45,shape:r.shape??"dot",separation:r.separation??"mono"},r))}dither(e){let r=N(e,"levels");return this.append(R({type:"dither",levels:r.levels??2,matrix:r.matrix??4,scale:r.scale??1,monochrome:r.monochrome??!1,noise:r.noise??"bayer"},r))}duotone(e){let r=N(e,"amount");return this.append(R({type:"duotone",amount:r.amount??1,shadows:r.shadows??"black",highlights:r.highlights??"white"},r))}curves(e){return this.append(R({type:"curves",points:e.points,channel:e.channel??"rgb"},e))}colorAdjustment(e){let{mode:r,...n}=e;return this.append(R({type:"colorAdjustment",...n},{mode:r}))}rgbShift(e){let r=N(e,"amount"),n=r.amount??4;return this.append(R({type:"rgbShift",red:r.red??{x:n,y:0},green:r.green??dy,blue:r.blue??{x:-n,y:0}},r))}scanlines(e){let r=N(e,"darkness");return this.append(R({type:"scanlines",spacing:r.spacing??4,thickness:r.thickness??.5,darkness:r.darkness??.5,offset:r.offset??0,angle:r.angle??0},r))}blockDisplace(e){let r=N(e,"amount");return this.append(R({type:"blockDisplace",amount:r.amount??20,size:r.size??16,density:r.density??.3,seed:r.seed??0,axis:r.axis??"x"},r))}bitCrush(e){let r=N(e,"bits");return this.append(R({type:"bitCrush",bits:r.bits??3,palette:r.palette??"none",amount:r.amount??1},r))}ascii(e){let r=N(e,"size");return this.append(R({type:"ascii",size:r.size??12,charset:r.charset??"standard",fontFamily:r.fontFamily??"monospace",ink:r.ink??"white",background:r.background??"black",colored:r.colored??!1},r))}oilPaint(e){let r=N(e,"radius");return this.append(R({type:"oilPaint",radius:r.radius??3},r))}streak(e){let r=N(e,"intensity");return this.append(R({type:"streak",intensity:r.intensity??1,threshold:r.threshold??.7,length:r.length??120,angle:r.angle??0},r))}glow(e){let r=N(e,"intensity");return this.append(R({type:"glow",channel:r.channel??"luminance",threshold:r.threshold??.5,radius:r.radius??25,spread:r.spread??0,intensity:r.intensity??1,axis:r.axis??"both",original:r.original??"behind",blend:r.blend??"screen",tint:r.tint??"none",color:r.color??"white",colors:r.colors??[...ly],stops:r.stops??[...cy],loopStyle:r.loopStyle??"mirror",cycles:r.cycles??1,phase:r.phase??0},r))}shader(e){let r=typeof e.source=="string"?void 0:e.source;if(r&&r.scope!=="effect")throw new Error(`Effects.shader was given a "${r.scope}" shader ("${r.name}"). A fill shader has no backdrop to sample and is bound to a shape's box; use Fills.shader.`);let n=e.mode??(r?.backdrop?"backdrop":"foreground"),o=r?r.source:e.source,s=r?{...Go(r,e.values),...Ze(e.uniforms??{})}:e.uniforms??{},i={type:"shader",source:o,uniforms:s,...r?.id!==void 0?{shaderId:r.id}:{}},a=n==="foreground"?{...i,blendMode:e.blendMode??"screen"}:i;return this.append(R(a,{mode:n}))}sksl(e){let{shader:r,...n}=e;return this.shader({...n,source:r})}wave(e){let r=N(e,"amplitude");return this.append(R({type:"wave",amplitude:fy(r.amplitude??20),wavelength:r.wavelength??120,phase:r.phase??0,shape:r.shape??"linear",angle:r.angle??0,center:r.center??br},r))}twirl(e){let r=N(e,"angle");return this.append(R({type:"twirl",angle:r.angle??180,radius:r.radius??1,center:r.center??br},r))}progressiveBlur(e){let r=N(e,"radius");return this.append(R({type:"progressiveBlur",radius:r.radius??24,startRadius:r.startRadius??0,shape:r.shape??"linear",start:r.start??0,end:r.end??1,angle:r.angle??90,center:r.center??br,samples:r.samples??20},r))}kaleidoscope(e){let r=N(e,"segments");return this.append(R({type:"kaleidoscope",segments:Math.round(r.segments??6),angle:r.angle??0,center:r.center??br,offset:r.offset??0,amount:r.amount??1},r))}glass(e){let r=N(e,"refraction");return this.append(R({type:"glass",lightAngle:r.lightAngle??-45,lightIntensity:r.lightIntensity??80,refraction:r.refraction??80,depth:r.depth??20,dispersion:r.dispersion??50,frost:r.frost??4,splay:r.splay??0},{...r,mode:r.mode??"backdrop"}))}*[Symbol.iterator](){yield*this.list}toJSON(){return this.list}},py=new z;function Ki(t){if(t===void 0)return[];if(t instanceof z)return Ad(t.list);if(Array.isArray(t)){let e=[];for(let r of t)r instanceof z?e.push(...Ad(r.list)):Array.isArray(r)?e.push(...Ki(r)):e.push(Lo(r));return e}return[Lo(t)]}function Ad(t){let e;for(let r=0;r<t.length;r++){let n=Lo(t[r]);!e&&n!==t[r]&&(e=t.slice(0,r)),e?.push(n)}return e??t}var Zr={resolve:t=>Ki(t),lerp:(t,e,r)=>{if(t===e)return t;let n=Math.max(t.length,e.length),o=[];for(let s=0;s<n;s++){let i=t[s],a=e[s];i&&a?o.push(Ln(i,a,r)):i?o.push(i):a&&o.push(a)}return o}};var Md=t=>t.mode==="backdrop",Od=[],Hi=t=>t.length===0?Od:t.filter(Md);function Ui(t){return t.length===0?Od:t.filter(e=>e.mode!=="backdrop"&&Bn(e)==="shader")}var Xi=["multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","normal"],hy=[...Xi,"pass-through"],my=Object.fromEntries(Xi.map((t,e)=>[t,e]));function yy(t){return my[t]}function qe(t,e={}){let r={...t};return e.opacity!==void 0&&(r.opacity=e.opacity),e.blend!==void 0&&(r.blend=e.blend),e.space!==void 0&&(r.space=e.space),r}var Jr=class t{list;constructor(e=[]){this.list=e}color(e,r){return new t([...this.list,qe({type:"solid",color:e},r)])}image(e,r){let{fit:n,crop:o,zoom:s,anchor:i,matrix:a,preset:l,filters:c,...d}=r??{};return new t([...this.list,qe({type:"image",src:e,fit:n,crop:o,zoom:s,anchor:i,matrix:a,preset:l,filters:c},d)])}video(e,r){let{fit:n,crop:o,zoom:s,anchor:i,matrix:a,preset:l,filters:c,timestamp:d,playing:u,trimStart:f,trimEnd:h,playStart:y,speed:w,loop:g,duration:x,..._}=r??{};return new t([...this.list,qe({type:"video",src:e,fit:n,crop:o,zoom:s,anchor:i,matrix:a,preset:l,filters:c,timestamp:d,playing:u??!0,trimStart:f,trimEnd:h,playStart:y,speed:w,loop:g,duration:x},_)])}linearGradient(e,r){let{stops:n,start:o,end:s,...i}=r??{};return new t([...this.list,qe({type:"linear-gradient",colors:e,stops:n,start:o,end:s},i)])}radialGradient(e,r){let{stops:n,center:o,radius:s,...i}=r??{};return new t([...this.list,qe({type:"radial-gradient",colors:e,stops:n,center:o,radius:s},i)])}conicGradient(e,r){let{stops:n,center:o,startAngle:s,...i}=r??{};return new t([...this.list,qe({type:"conic-gradient",colors:e,stops:n,center:o,startAngle:s},i)])}noise(e){let{size:r,density:n,color:o,seed:s,...i}=e??{};return new t([...this.list,qe({type:"noise",size:r,density:n,color:o,seed:s},i)])}fractalNoise(e){let{basis:r,octaves:n,frequency:o,lacunarity:s,gain:i,seed:a,offset:l,angle:c,colors:d,stops:u,contrast:f,...h}=e??{};return new t([...this.list,qe({type:"fractalNoise",basis:r,octaves:n,frequency:o,lacunarity:s,gain:i,seed:a,offset:l,angle:c,colors:d,stops:u,contrast:f},h)])}shader(e,r){let n=typeof e=="string"?void 0:e;if(n&&n.scope!=="fill")throw new Error(`Fills.shader was given a "${n.scope}" shader ("${n.name}"). An effect shader samples a backdrop a fill does not have; use Effects.shader.`);let{uniforms:o,coords:s,textures:i,values:a,...l}=r??{},c=n?{...Go(n,a),...Ze(o??{})}:o;return new t([...this.list,qe({type:"shader",source:typeof e=="string"?e:e.source,uniforms:c,coords:s??n?.coords,textures:i,...n?.id!==void 0?{shaderId:n.id}:{}},l)])}stripe(e){let{gap:r,strokeWidth:n,angle:o,color:s,...i}=e??{};return new t([...this.list,qe({type:"stripe",gap:r,strokeWidth:n,angle:o,color:s},i)])}dotGrid(e){let{radius:r,spacing:n,offset:o,color:s,...i}=e??{};return new t([...this.list,qe({type:"dotGrid",radius:r,spacing:n,offset:o,color:s},i)])}grid(e){let{divisions:r,subdivisions:n,offset:o,strokeWidth:s,subdivisionWidth:i,color:a,...l}=e??{};return new t([...this.list,qe({type:"grid",divisions:r,subdivisions:n,offset:o,strokeWidth:s,subdivisionWidth:i,color:a},l)])}canvas3D(e,r){let{maxPixelRatio:n,antialias:o,...s}=r??{};return new t([...this.list,qe({type:"canvas3D",scene:e,maxPixelRatio:n,antialias:o},s)])}*[Symbol.iterator](){yield*this.list}toJSON(){return this.list}},Zi=new Jr;function Qr(t){if(t==null)return[];if(t instanceof Jr)return t.list;if(Array.isArray(t)){let e=[];for(let r of t)r instanceof Jr?e.push(...r.list):Array.isArray(r)?e.push(...Qr(r)):e.push(r);return e}return[t]}var gy=4,xy=1,_y=1,Ed=.5,Cd={resolve:t=>{let e=t.color??[0,0,0,1],r=t.strokeWidth??_y;return{type:"grid",divisions:t.divisions??gy,subdivisions:t.subdivisions??xy,offset:t.offset??{x:0,y:0},strokeWidth:r,subdivisionWidth:t.subdivisionWidth??r*Ed,color:Array.isArray(e)?e:G(e),opacity:t.opacity,blend:t.blend}},lerp:(t,e,r)=>({divisions:m(t.divisions,e.divisions,r),subdivisions:m(t.subdivisions,e.subdivisions,r),offset:{x:m(t.offset.x,e.offset.x,r),y:m(t.offset.y,e.offset.y,r)},strokeWidth:m(t.strokeWidth,e.strokeWidth,r),subdivisionWidth:m(t.subdivisionWidth,e.subdivisionWidth,r),color:[m(t.color[0],e.color[0],r),m(t.color[1],e.color[1],r),m(t.color[2],e.color[2],r),m(t.color[3],e.color[3],r)],opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.divisions===e.divisions&&t.subdivisions===e.subdivisions&&t.offset.x===e.offset.x&&t.offset.y===e.offset.y&&t.strokeWidth===e.strokeWidth&&t.subdivisionWidth===e.subdivisionWidth&&t.color[0]===e.color[0]&&t.color[1]===e.color[1]&&t.color[2]===e.color[2]&&t.color[3]===e.color[3]};var Pd={lerp:(t,e,r)=>({type:"exposure",amount:m(t.amount,e.amount,r)}),equals:(t,e)=>t.amount===e.amount};var Td={lerp:(t,e,r)=>({type:"blur",radius:m(t.radius,e.radius,r)}),equals:(t,e)=>t.radius===e.radius};var Dd={lerp:(t,e,r)=>({type:"grayscale",amount:m(t.amount,e.amount,r)}),equals:(t,e)=>t.amount===e.amount};var Rd={lerp:(t,e,r)=>({type:"alpha",amount:m(t.amount,e.amount,r)}),equals:(t,e)=>t.amount===e.amount};var Fd={lerp:(t,e,r)=>({type:"colorMatrix",matrix:t.matrix.map((n,o)=>m(n,e.matrix[o]??n,r))}),equals:(t,e)=>t.matrix.length===e.matrix.length&&t.matrix.every((r,n)=>r===e.matrix[n])};var Id={lerp:(t,e,r)=>({type:"curves",channel:r<.5?t.channel:e.channel,points:t.points.map(([n,o],s)=>{let[i,a]=e.points[s]??[n,o];return[m(n,i,r),m(o,a,r)]})}),equals:(t,e)=>t.channel===e.channel&&t.points.length===e.points.length&&t.points.every(([r,n],o)=>r===e.points[o]?.[0]&&n===e.points[o]?.[1])};var zd={lerp:(t,e,r)=>({type:"colorAdjustment",brightness:m(t.brightness??0,e.brightness??0,r),contrast:m(t.contrast??1,e.contrast??1,r),saturation:m(t.saturation??1,e.saturation??1,r),hue:m(t.hue??0,e.hue??0,r),vibrance:m(t.vibrance??0,e.vibrance??0,r),shadows:m(t.shadows??0,e.shadows??0,r),highlights:m(t.highlights??0,e.highlights??0,r),temperature:m(t.temperature??0,e.temperature??0,r),tint:m(t.tint??0,e.tint??0,r),vignette:m(t.vignette??0,e.vignette??0,r)}),equals:(t,e)=>t.brightness===e.brightness&&t.contrast===e.contrast&&t.saturation===e.saturation&&t.hue===e.hue&&t.vibrance===e.vibrance&&t.shadows===e.shadows&&t.highlights===e.highlights&&t.temperature===e.temperature&&t.tint===e.tint&&t.vignette===e.vignette};var Nd={lerp:(t,e,r)=>({type:"posterizeTime",fps:m(t.fps,e.fps,r)}),equals:(t,e)=>t.fps===e.fps};var $d={lerp:(t,e,r)=>({type:"echo",echoes:Math.round(m(t.echoes,e.echoes,r)),delay:m(t.delay,e.delay,r),decay:m(t.decay??.5,e.decay??.5,r),blend:r<.5?t.blend:e.blend}),equals:(t,e)=>t.echoes===e.echoes&&t.delay===e.delay&&(t.decay??.5)===(e.decay??.5)&&t.blend===e.blend};var Yo=new Map([["exposure",Pd],["blur",Td],["grayscale",Dd],["alpha",Rd],["colorMatrix",Fd],["curves",Id],["colorAdjustment",zd],["posterizeTime",Nd],["echo",$d]]),wy=new Set(["posterizeTime","echo"]);function vy(t){return!wy.has(t)}function Sy(t){return Yo.has(t)||bd(t)}function jd(t,e,r){if(t.type!==e.type)return r<.5?t:e;let n=Yo.get(t.type);return n?n.lerp(t,e,r):Ln(t,e,r)}function Bd(t,e){Yo.has(t.type)||Wo(t,e)}function by(t){return Yo.has(t.type)?"filter":Bn({...t,mode:"foreground"})}function Wn(t,e,r){let n=Math.max(t.length,e.length),o=[];for(let s=0;s<n;s++){let i=t[s],a=e[s];i&&a?o.push(jd(i,a,r)):i?o.push(i):a&&o.push(a)}return o}function qn(t,e){return typeof t=="number"?{[e]:t}:t}function Y(t){return t.list[0]}var en=class{list;constructor(e=[]){this.list=e}append(e){let r=this.constructor;return new r([...this.list,e])}blur(e){let{radius:r}=qn(e,"radius");return this.append({type:"blur",radius:r})}grayscale(e){let{amount:r}=qn(e,"amount");return this.append({type:"grayscale",amount:r})}alpha(e){let{amount:r}=qn(e,"amount");return this.append({type:"alpha",amount:r})}exposure(e){let{amount:r}=qn(e,"amount");return this.append({type:"exposure",amount:r})}colorAdjustment(e){return this.append({type:"colorAdjustment",...e})}colorMatrix(e){let r=Array.isArray(e)?e:e.matrix;return this.append({type:"colorMatrix",matrix:r})}curves(e){return this.append({type:"curves",points:e.points,channel:e.channel})}directionalBlur(e){return this.append(Y(new z().directionalBlur(e)))}radialBlur(e){return this.append(Y(new z().radialBlur(e)))}progressiveBlur(e){return this.append(Y(new z().progressiveBlur(e)))}bloom(e){return this.append(Y(new z().bloom(e)))}streak(e){return this.append(Y(new z().streak(e)))}sharpen(e){return this.append(Y(new z().sharpen(e)))}invert(e){return this.append(Y(new z().invert(e)))}vintage(e){return this.append(Y(new z().vintage(e)))}duotone(e){return this.append(Y(new z().duotone(e)))}posterize(e){return this.append(Y(new z().posterize(e)))}threshold(e){return this.append(Y(new z().threshold(e)))}bitCrush(e){return this.append(Y(new z().bitCrush(e)))}dither(e){return this.append(Y(new z().dither(e)))}halftone(e){return this.append(Y(new z().halftone(e)))}grain(e){return this.append(Y(new z().grain(e)))}lut(e){return this.append(Y(new z().lut(e)))}scanlines(e){return this.append(Y(new z().scanlines(e)))}pixelate(e){return this.append(Y(new z().pixelate(e)))}oilPaint(e){return this.append(Y(new z().oilPaint(e)))}ascii(e){return this.append(Y(new z().ascii(e)))}edges(e){return this.append(Y(new z().edges(e)))}vignette(e){return this.append(Y(new z().vignette(e)))}chromaticAberration(e){return this.append(Y(new z().chromaticAberration(e)))}rgbShift(e){return this.append(Y(new z().rgbShift(e)))}scatter(e){return this.append(Y(new z().scatter(e)))}blockDisplace(e){return this.append(Y(new z().blockDisplace(e)))}bulge(e){return this.append(Y(new z().bulge(e)))}twirl(e){return this.append(Y(new z().twirl(e)))}wave(e){return this.append(Y(new z().wave(e)))}kaleidoscope(e){return this.append(Y(new z().kaleidoscope(e)))}shader(e){return this.append(Y(new z().shader(e)))}sksl(e){return this.append(Y(new z().sksl(e)))}*[Symbol.iterator](){yield*this.list}toJSON(){return this.list}},Ko=class extends en{posterizeTime(e){let{fps:r}=qn(e,"fps");return this.append({type:"posterizeTime",fps:r})}echo(e){return this.append({type:"echo",...e})}},Ld=new en,Wd=new Ko,ky=Ld,Ay=Wd;function Vn(t){return t===void 0?[]:t instanceof en?t.list:Array.isArray(t)?t:[t]}var Ho={topLeft:{x:-1,y:1},topCenter:{x:0,y:1},topRight:{x:1,y:1},centerLeft:{x:-1,y:0},center:{x:0,y:0},centerRight:{x:1,y:0},bottomLeft:{x:-1,y:-1},bottomCenter:{x:0,y:-1},bottomRight:{x:1,y:-1}},Ji=Object.keys(Ho);function Qi(t){if(typeof t=="string"){let e=Object.hasOwn(Ho,t)?Ho[t]:void 0;if(!e)throw new Error(`Unknown alignment value: '${t}'`);return{...e}}return{x:t.x,y:t.y}}var Q={resolve:Qi,lerp:D,keys:Ji,isKey(t){return typeof t=="string"&&Object.hasOwn(Ho,t)},validateProps(t){let e=Ji.filter(r=>t[r]!==void 0);if(e.length>1)throw new Error(`Cannot set multiple alignment props at once: ${e.join(", ")}`);if(e.length===1&&t.pivot!==void 0)throw new Error(`Cannot set both alignment prop '${e[0]}' and 'pivot' at the same time`)},findKey(t){return Ji.find(e=>t[e]!==void 0)},resolveTargetOnce(t,e,r){let n=Qi(t);return{pivot:n,x:r.x-n.x*(e.width/2),y:r.y-n.y*(e.height/2)}},bindTarget(t,e,r){let n=Qi(t);return{pivot:n,x:()=>e().x-n.x*(r().width/2),y:()=>e().y-n.y*(r().height/2)}}};var Re={resolve:(t,e)=>typeof t=="number"?{left:t,right:t,top:t,bottom:t}:{left:t.left??t.horizontal??e?.left??0,right:t.right??t.horizontal??e?.right??0,top:t.top??t.vertical??e?.top??0,bottom:t.bottom??t.vertical??e?.bottom??0},lerp:(t,e,r)=>({left:m(t.left,e.left,r),right:m(t.right,e.right,r),top:m(t.top,e.top,r),bottom:m(t.bottom,e.bottom,r)}),insetBounds:(t,e,r)=>({width:Math.max(0,t-r.left-r.right),height:Math.max(0,e-r.top-r.bottom),x:(r.left-r.right)/2,y:(r.top-r.bottom)/2}),outsetSize:(t,e,r)=>({width:t+r.left+r.right,height:e+r.top+r.bottom})};function Uo(t,e){let r=t?.adjustments??e,n=Vn(r);if(n.length!==0)return{adjustments:n,intensity:Math.min(1,Math.max(0,t?.intensity??1))}}function Xo(t,e,r){if(!t&&!e)return;let n=t??{adjustments:e.adjustments,intensity:0},o=e??{adjustments:t.adjustments,intensity:0};return{adjustments:Wn(n.adjustments,o.adjustments,r),intensity:m(n.intensity,o.intensity,r)}}function Zo(t,e){for(let r of t?.adjustments??[])Bd(r,e)}var qd={left:0,right:0,top:0,bottom:0},Vd={x:0,y:0};function ea(t){return{crop:t.crop===void 0?void 0:Re.resolve(t.crop),anchor:t.anchor===void 0?void 0:Q.resolve(t.anchor)}}function ta(t,e,r){return{matrix:r<.5?t.matrix:e.matrix,crop:t.crop||e.crop?Re.lerp(t.crop??qd,e.crop??qd,r):void 0,zoom:m(t.zoom??1,e.zoom??1,r),anchor:D(t.anchor??Vd,e.anchor??Vd,r)}}var Gd={resolve:({crop:t,anchor:e,preset:r,filters:n,...o})=>({...o,...ea({crop:t,anchor:e}),preset:Uo(r,n)}),lerp:(t,e,r)=>({src:r<.5?t.src:e.src,fit:r<.5?t.fit:e.fit,...ta(t,e,r),opacity:(t.opacity??1)+((e.opacity??1)-(t.opacity??1))*r,preset:Xo(t.preset,e.preset,r)}),equals:(t,e)=>t.src===e.src,declare:(t,e)=>{e.image(t.src),Zo(t.preset,e)}};function My(t,e,r){let n=t.trimStart??0;return Cy(t,n,Oy(t,e,r,n))}function Oy(t,e,r,n){if(t.timestamp!=null)return t.timestamp;if(!t.playing)return n;let o=Math.max(0,e-(t.playStart??0))*(t.speed??1);return ra(o,n,Ey(t,r),t.loop,t.duration)}function Ey(t,e){let r=e!==void 0&&Number.isFinite(e)&&e>0;return t.trimEnd??(r?e:1/0)}function ra(t,e,r,n,o){let s=o??(r!==1/0?r-e:void 0),i=s!==void 0&&s>0?s:void 0;if((n??"none")!=="none"&&i!==void 0){let l=t%i;if(n==="reverse"){let c=Math.floor(t/i)%2===0;return e+(c?l:i-l)}return e+l}let a=e+t;return r!==1/0?Math.min(a,r):a}function Cy(t,e,r){let n=t.preset?.adjustments.find(s=>s.type==="posterizeTime");if(!n||n.fps<=0)return r;let o=1/n.fps;return e+Math.floor((r-e)/o)*o}var Yd={resolve:({crop:t,anchor:e,preset:r,filters:n,...o})=>({...o,...ea({crop:t,anchor:e}),preset:Uo(r,n),playing:o.playing??!0}),lerp:(t,e,r)=>({src:r<.5?t.src:e.src,fit:r<.5?t.fit:e.fit,...ta(t,e,r),loop:r<.5?t.loop:e.loop,duration:r<.5?t.duration:e.duration,trimStart:r<.5?t.trimStart:e.trimStart,trimEnd:r<.5?t.trimEnd:e.trimEnd,playStart:r<.5?t.playStart:e.playStart,playing:r<.5?t.playing:e.playing,opacity:(t.opacity??1)+((e.opacity??1)-(t.opacity??1))*r,timestamp:t.timestamp==null&&e.timestamp==null?void 0:m(t.timestamp??0,e.timestamp??0,r),speed:m(t.speed??1,e.speed??1,r),preset:Xo(t.preset,e.preset,r)}),equals:(t,e)=>t.src===e.src,declare:(t,e)=>{e.video(t.src,{start:t.trimStart??0,end:t.trimEnd}),Zo(t.preset,e)}};var Je=class{_cmds=[];_x=0;_y=0;_startX=0;_startY=0;_open=!1;moveTo(e,r){return this._cmds.push({type:"M",x:e,y:r}),this._startX=e,this._startY=r,this._at(e,r)}lineTo(e,r){return this._cmds.push({type:"L",x:e,y:r}),this._at(e,r)}bezierCurveTo(e,r,n,o,s,i){return this._cmds.push({type:"C",x1:e,y1:r,x2:n,y2:o,x:s,y:i}),this._at(s,i)}quadraticCurveTo(e,r,n,o){return this._cmds.push({type:"Q",x1:e,y1:r,x:n,y:o}),this._at(n,o)}arcTo(e,r,n,o,s,i,a){return this._cmds.push({type:"A",rx:e,ry:r,rotation:n,largeArc:o,sweep:s,x:i,y:a}),this._at(i,a)}arc(e){let{cx:r,cy:n,rx:o,ry:s,from:i,sweep:a}=Kd(e),l=na(r,n,o,s,i);return this._open?(l.x!==this._x||l.y!==this._y)&&this.lineTo(l.x,l.y):this.moveTo(l.x,l.y),this._sweep(r,n,o,s,i,a)}ellipse(e){let{cx:r,cy:n,rx:o,ry:s,from:i,sweep:a}=Kd(e),l=na(r,n,o,s,i);return this.moveTo(l.x,l.y),this._sweep(r,n,o,s,i,a),this.close()}close(){return this._cmds.push({type:"Z"}),this._at(this._startX,this._startY)}toCommands(){return[...this._cmds]}toPathState(e={}){return{...e,data:this._cmds}}_at(e,r){return this._x=e,this._y=r,this._open=!0,this}_sweep(e,r,n,o,s,i){if(i===0)return this;let a=Math.ceil(Math.abs(i)/90),l=i/a,c=i>0?1:0;for(let d=1;d<=a;d++){let u=na(e,r,n,o,s+l*d);this.arcTo(n,o,0,0,c,u.x,u.y)}return this}};function Kd(t){return{cx:t.x??0,cy:t.y??0,rx:t.width/2,ry:(t.height??t.width)/2,from:t.startAngle??0,sweep:t.sweep??360}}function na(t,e,r,n,o){let s=o*Math.PI/180;return{x:t+r*Math.cos(s),y:e+n*Math.sin(s)}}var Py=new Set(["rect","ellipse","path","line","polygon","polygram","text","richText"]),B=class t{_ops=[];_opacity=1;_rotation=0;_scale=1;_transformCenter;rect(e){return this._ops.push({kind:"rect",state:e}),this}ellipse(e){return this._ops.push({kind:"ellipse",state:e}),this}path(e){let r=e instanceof Je?e.toPathState():e;return this._ops.push({kind:"path",state:r}),this}line(e){return this._ops.push({kind:"line",state:e}),this}polygon(e){return this._ops.push({kind:"polygon",state:e}),this}polygram(e){return this._ops.push({kind:"polygram",state:e}),this}text(e){return this._ops.push({kind:"text",state:e}),this}richText(e){return this._ops.push({kind:"richText",state:e}),this}fill(e){return this._ops.push({kind:"fill",fills:e}),this}stroke(e){return this._ops.push({kind:"stroke",strokes:e}),this}shadow(e){return this._ops.push({kind:"shadow",shadows:e}),this}cut(){return this._ops.push({kind:"cut"}),this}mask(e){return this._ops.push({kind:"mask",options:e}),this}applyMask(){return this._ops.push({kind:"applyMask"}),this}endMask(){return this._ops.push({kind:"endMask"}),this}opacity(e){return this._opacity=e,this}effects(e){return this._ops.push({kind:"effects",effects:Zr.resolve(e)}),this}rotation(e,r){return this._rotation=e,r!==void 0&&(this._transformCenter=r),this}scale(e,r){return this._scale=e,r!==void 0&&(this._transformCenter=r),this}ops(){return this._ops}groupOpacity(){return this._opacity}needsGroupLayer(){return this._opacity<1}groupTransform(){return this._rotation===0&&this._scale===1?null:{rotation:this._rotation,scale:this._scale,center:this._transformCenter}}isPaintOnly(){return!this._ops.some(e=>Py.has(e.kind))}_withOps(e){let r=new t;return r._ops=e,r._opacity=this._opacity,r._rotation=this._rotation,r._scale=this._scale,r._transformCenter=this._transformCenter,r}};function Gn(t){return typeof t.ops=="function"?{kind:"graphics",graphics:t}:{kind:"node",node:t}}function Hd(t){return typeof t!="string"&&"data"in t}function tn(t){return typeof t!="string"&&"source"in t}function Ty(t){return typeof t=="string"?{src:t}:t}function oa(t){return typeof t=="string"?t:Hd(t)||tn(t)?null:t.src}function rn(t){return t.startsWith("/")||t.startsWith(".")||/\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(t)}var Qo=512;function nn(t,e={}){if(t==null)return{};if(typeof t=="string")return rn(t)?{map:t}:{color:t};if(Array.isArray(t))return t.every(r=>typeof r=="number")?{color:t}:{map:Ud(t,e)};if(typeof t=="object"){if(Fy(t))return{map:Dy(t,e)};if(Ry(t))return{map:t};if(Qd(t))return{color:t.color}}return{map:Ud(t,e)}}function Dy(t,e){return{source:t,width:e.width??Qo,height:e.height??Qo}}function Ud(t,e){let r=e.width??Qo,n=e.height??Qo;return{source:new B().rect({width:r,height:n}).fill(t),width:r,height:n,static:!0,identity:`fill:${Jo(t)}:${r}x${n}`}}function Ry(t){return"src"in t||"data"in t||"source"in t&&"width"in t}function Fy(t){let e=t;return typeof e.cameraDescriptor=="function"?!1:typeof e.ops=="function"?!0:typeof e.id=="string"&&typeof e.attach=="function"}function Qd(t){let e=t;return e.type!=="solid"||e.color===void 0?!1:e.opacity===void 0&&e.blend===void 0&&e.space===void 0}function es(t,e,r){let n=Xd(t),o=Xd(e);return n!==null&&o!==null?Z(Zd(n),Zd(o),r):r<1?t:e}function Xd(t){return t==null?null:typeof t=="string"?rn(t)?null:t:Array.isArray(t)?t.every(e=>typeof e=="number")?t:null:typeof t=="object"&&Qd(t)?t.color:null}function Zd(t){return Array.isArray(t)?t:G(t)}var Jd=new WeakMap,Iy=0;function Jo(t){if(t===null||typeof t!="object")return String(t);if(Array.isArray(t))return`[${t.map(Jo).join(",")}]`;let e=t.list;if(Array.isArray(e))return Jo(e);let r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null){let o=Jd.get(t);return o===void 0&&(o=`@${Iy++}`,Jd.set(t,o)),o}let n=t;return`{${Object.keys(n).sort().map(o=>`${o}:${Jo(n[o])}`).join(",")}}`}var eu=new Set,zy;function tu(){return zy??=!1}function kr(t,e){!tu()||eu.has(t)||(eu.add(t),console.warn(`[motionscript] ${e}`))}function ru(t){if(tu()){if("geometry"in t){let e=t.geometry.params;e&&Object.keys(e).length>0&&kr(`geometry-params:${t.geometry.type}`,`\`params\` on a "${t.geometry.type}" geometry is not applied: three builds a geometry from its named fields and nothing assigns \`params\` onto it. Set the geometry's own fields instead. (\`params\` is applied on materials, lights and cameras.)`)}if("material"in t){let e=Array.isArray(t.material)?t.material:[t.material];for(let r of e)r.type==="shader"&&r.extends!=null&&kr("shader-extends",`\`extends: "${r.extends}"\` on a shader material is not applied: the shader replaces the built-in model, so scene lighting, shadows and fog do not reach it. Write the lighting you need in the shader.`)}t.kind==="model"&&/\.obj(?:$|[?#])/i.test(t.src)&&kr("model-obj",`The model "${t.src}" is an OBJ file, and only glTF/GLB models load: it will draw nothing. Convert it to .glb.`)}}var sa=new Set(["mesh","light","instances","points","line","sprite","model"]),nu=["position","rotation","quaternion","scale","lookAt","visible","shadow","renderOrder"],ou=["opacity","roughness","metalness","emission","emissionStrength","normalMap","roughnessMap","metalnessMap","aoMap","alphaMap","envMapIntensity","wireframe","shading","faces","vertexColors","blend"],Ny=[...ou,"fill","material","unlit"];function ts(t){let e=t,r;for(let n of nu)e[n]!==void 0&&((r??={})[n]=e[n]);return r}function on(t){if(t.material!==void 0)return t.material;let e={type:t.unlit?"basic":"standard"},r=nn(t.fill);r.color!==void 0&&(e.color=r.color),r.map!==void 0&&(e.map=r.map);for(let n of ou){let o=t[n];o!==void 0&&(e[n]=o)}return e}function $y(t,e){let r=t,n={type:e};for(let o in r)Ny.includes(o)||nu.includes(o)||r[o]!==void 0&&(n[o]=r[o]);return n}var Fe=class{_ops=[];record(e){ru(e),this._ops.push(e)}mesh(e,r,n){return this.record({kind:"mesh",geometry:e,material:r??{type:"standard"},transform:n}),this}sugar(e,r){let n=r??{};return this.mesh($y(n,e),on(n),ts(n))}box(e){return this.sugar("box",e)}sphere(e){return this.sugar("sphere",e)}plane(e){return this.sugar("plane",e)}cylinder(e){return this.sugar("cylinder",e)}cone(e){return this.sugar("cone",e)}torus(e){return this.sugar("torus",e)}torusKnot(e){return this.sugar("torusKnot",e)}circle(e){return this.sugar("circle",e)}ring(e){return this.sugar("ring",e)}capsule(e){return this.sugar("capsule",e)}polyhedron(e){return this.sugar("polyhedron",e)}extrude(e){return this.sugar("extrude",e)}lathe(e){return this.sugar("lathe",e)}tube(e){return this.sugar("tube",e)}instances(e,r,n,o){return this.record({kind:"instances",geometry:e,material:r,instances:n,colors:o?.colors,transform:o?.transform}),this}points(e,r,n){return this.record({kind:"points",geometry:e,material:r??{type:"points"},transform:n}),this}line(e){let{points:r,geometry:n,material:o,closed:s,segments:i,stroke:a,opacity:l}=e;if(!r&&!n)throw new Error("Graphics3D.line() needs either `points` or `geometry`.");let c=o??{type:a?.dash!==void 0?"lineDashed":"lineBasic",...a?.fill!==void 0?{color:a.fill}:{},...a?.weight!==void 0?{width:a.weight}:{},...a?.dash!==void 0?{dashSize:a.dash[0],gapSize:a.dash[1]??a.dash[0]}:{},...l!==void 0?{opacity:l}:{}};return this.record({kind:"line",geometry:n??{type:"buffer",position:jy(r)},material:c,mode:i?"segments":s?"loop":"strip",transform:ts(e)}),this}sprite(e){let{fill:r,material:n,opacity:o}=e,s=nn(r),i=n??{type:"sprite",...s.map!==void 0?{map:s.map}:{},...s.color!==void 0?{color:s.color}:{},...o!==void 0?{opacity:o}:{}};return this.record({kind:"sprite",material:i,transform:ts(e)}),this}model(e){let{src:r,animation:n,override:o}=e;return this.record({kind:"model",src:r,animation:n===void 0?void 0:Array.isArray(n)?n:[n],override:o,transform:ts(e)}),this}ops(){return this._ops}isEmpty(){return this._ops.length===0}};function jy(t){let e=[];for(let r of t)if(typeof r=="number")e.push(r,r,r);else if(Array.isArray(r))e.push(r[0]??0,r[1]??0,r[2]??0);else{let n=r;e.push(n.x??0,n.y??0,n.z??0)}return e}var Yn=class{};function Kn(t){return t===void 0||t===!1?null:t===!0?{enabled:!0}:{enabled:!0,...t}}var Ve=class extends Yn{_ops=[];_camera=null;_fog=null;_environment=null;_shadows=null;_tone=null;_post=[];_depth=0;_shadowScopes=[];begin(e){this._ops.push({kind:"push",transform:{...e.transform,key:e.id}}),this._shadowScopes.push(e.transform?.shadow),this._depth++}end(){this._ops.push({kind:"pop"}),this._shadowScopes.pop(),this._depth--}draw(e){let r=e.ops(),n=this._shadowScopes[this._shadowScopes.length-1];for(let o=0;o<r.length;o++){let s=r[o];n===void 0||s.transform?.shadow!==void 0?this._ops.push(s):this._ops.push({...s,transform:{...s.transform,shadow:n}})}return this}light(e,r){return this._ops.push({kind:"light",light:e,transform:r}),this}camera(e){return this._camera=e,this._ops.push({kind:"camera",camera:e}),this}perspective(e){return this.camera({type:"perspective",...e})}orthographic(e){return this.camera({type:"orthographic",...e})}fog(e){return e===null?this._fog=null:typeof e=="object"&&!Array.isArray(e)?this._fog=e:this._fog={color:e},this}environment(e){return e&&((e.src!==void 0||(e.faces?.length??0)>0)&&kr("environment-src",'An environment\'s `src` and `faces` (HDR, EXR, cubemap) are recorded, and no backend loads them. Only `preset: "studio"` is rendered: without a preset the scene gets no image-based light and its `background` is not drawn.'),e.params&&Object.keys(e.params).length>0&&kr("environment-params","`params` on an environment is not applied: nothing assigns it onto the generated environment.")),this._environment=e,this}shadows(e){return this._shadows=Kn(e??!0),this}tone(e){return this._tone=e,this}post(e){let r=Array.isArray(e)?e:[e];return r.length>0&&kr("post",`Post-processing (${r.map(n=>`"${n.type}"`).join(", ")}) is recorded, and no backend applies a pass: the scene renders exactly as it would without \`post\`. Use the Canvas3D's 2D \`effects\` over the composited result instead.`),this._post.push(...r),this}ops(){return this._ops}cameraDescriptor(){return this._camera}fogDescriptor(){return this._fog}environmentDescriptor(){return this._environment}shadowSettings(){return this._shadows}toneSettings(){return this._tone}postEffects(){return this._post}isEmpty(){return!this._ops.some(e=>sa.has(e.kind))}assertBalanced(){if(this._depth!==0){let e=this._depth>0?"unclosed begin()":"extra end()";throw new Error(`Scene3D has ${Math.abs(this._depth)} ${e}.`)}}};function ia(t,e){return`three:${t}:${e}`}function By(t){if(!t.startsWith("three:"))return null;let e=t.slice(6),r=e.indexOf(":");return r<=0?null:{kind:e.slice(0,r),src:e.slice(r+1)}}var aa=null,su=null;function Ly(t){aa=t}function Wy(t){su=t}function la(){return aa?.()}function ca(){return su}function qy(){return aa!==null}var iu=["map","alphaMap","aoMap","normalMap","displacementMap","envMap","lightMap","emissionMap","roughnessMap","metalnessMap","specularMap","gradientMap","matcap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap"];function au(t){return typeof t!="object"||t===null||Array.isArray(t)?!1:"src"in t||"data"in t||"source"in t}function Hn(t,e){let r=o=>{if(o)for(let s in o){let i=o[s];(typeof i=="string"&&rn(i)||au(i))&&e(i)}},n=o=>{if(o===void 0)return;let s=Array.isArray(o)?o:[o];for(let i of s){let a=i;for(let l of iu)a[l]!==void 0&&e(a[l]);r(a.uniforms)}};for(let o of t.ops())switch(o.kind){case"mesh":case"points":case"line":case"instances":n(o.material);break;case"sprite":n(o.material);break;case"model":if(o.override)for(let s in o.override)n(o.override[s]);break}if(t instanceof Ve)for(let o of t.postEffects())r(o.uniforms)}var Vy=new Set(["linear-gradient","radial-gradient","conic-gradient"]);function rs(t){return Vy.has(t)}function da(t,e){let r=t.type==="solid"||rs(t.type),n=e.type==="solid"||rs(e.type);return!r||!n?!1:rs(t.type)||rs(e.type)}function Gy(t){return Array.from({length:t},(e,r)=>r/Math.max(1,t-1))}function lu(t,e,r,n,o,s){let i=Math.max(2,s),a=Array.from({length:i},()=>[...t]),l=Gy(i),c={colors:a,stops:l,opacity:e,blend:r,space:n};switch(o){case"linear-gradient":return{type:"linear-gradient",...c,start:{x:-1,y:1},end:{x:1,y:-1}};case"radial-gradient":return{type:"radial-gradient",...c,center:{x:0,y:0},radius:100};case"conic-gradient":return{type:"conic-gradient",...c,center:{x:0,y:0},startAngle:0}}}function Yy(t,e){if(t.type===e)return t;let r={colors:t.colors,stops:t.stops,opacity:t.opacity,blend:t.blend,space:t.space};switch(e){case"linear-gradient":return{type:"linear-gradient",...r,start:{x:-1,y:1},end:{x:1,y:-1}};case"radial-gradient":return{type:"radial-gradient",...r,center:{x:0,y:0},radius:100};case"conic-gradient":return{type:"conic-gradient",...r,center:{x:0,y:0},startAngle:0}}}function cu(t,e){let r=t.type==="solid",n=e.type==="solid";if(r&&!n){let i=e;return[lu(t.color,t.opacity,t.blend,t.space,i.type,i.colors.length),i]}if(n&&!r){let i=t,a=lu(e.color,e.opacity,e.blend,e.space,i.type,i.colors.length);return[i,a]}let o=t,s=e;return[Yy(o,s.type),s]}var du={resolve:t=>({type:"solid",color:Array.isArray(t.color)?t.color:G(t.color),opacity:t.opacity,blend:t.blend}),lerp:(t,e,r)=>({color:[m(t.color[0],e.color[0],r),m(t.color[1],e.color[1],r),m(t.color[2],e.color[2],r),m(t.color[3],e.color[3],r)],opacity:(t.opacity??1)+((e.opacity??1)-(t.opacity??1))*r}),equals:(t,e)=>t.color===e.color};function Ky(t,e){let{colors:r,stops:n}=t,o=r.length-1;if(e<=n[0])return r[0];if(e>=n[o])return r[o];let s=1;for(;n[s]<e;)s++;let i=s-1,a=n[s]-n[i];return Z(r[i],r[s],a>0?(e-n[i])/a:0)}function uu(t,e,r){let n=t.stops.indexOf(e);if(n===-1)return Ky(t,e);let o=1;for(;t.stops[n+o]===e;)o++;return t.colors[n+Math.min(r,o-1)]}var Hy=(t,e)=>t.length===e.length&&t.every((r,n)=>r===e[n]);function Kt(t,e,r){if(Hy(t.stops,e.stops))return{colors:t.colors.map((i,a)=>Z(i,e.colors[a],r)),stops:t.stops.slice()};let n=new Map;for(let i of[t,e]){let a=new Map;for(let l of i.stops)a.set(l,(a.get(l)??0)+1);for(let[l,c]of a)n.set(l,Math.max(n.get(l)??0,c))}let o=[],s=[];for(let i of[...n.keys()].sort((a,l)=>a-l))for(let a=0;a<n.get(i);a++)o.push(Z(uu(t,i,a),uu(e,i,a),r)),s.push(i);return{colors:o,stops:s}}function Uy(t){return Array.isArray(t)?t:G(t)}var fu={resolve:t=>({type:"linear-gradient",colors:t.colors.map(Uy),stops:t.stops??t.colors.map((e,r)=>r/Math.max(1,t.colors.length-1)),start:t.start??{x:-1,y:1},end:t.end??{x:1,y:-1},opacity:t.opacity,blend:t.blend}),lerp:(t,e,r)=>({...Kt(t,e,r),start:D(t.start,e.start,r),end:D(t.end,e.end,r),opacity:(t.opacity??1)+((e.opacity??1)-(t.opacity??1))*r}),equals:(t,e)=>t.start.x===e.start.x&&t.start.y===e.start.y&&t.end.x===e.end.x&&t.end.y===e.end.y&&t.colors.length===e.colors.length&&t.colors.every((r,n)=>r===e.colors[n])};function Xy(t){return Array.isArray(t)?t:G(t)}var pu={resolve:t=>({type:"radial-gradient",colors:t.colors.map(Xy),stops:t.stops??t.colors.map((e,r)=>r/Math.max(1,t.colors.length-1)),center:t.center??{x:0,y:0},radius:t.radius??100,opacity:t.opacity,blend:t.blend}),lerp:(t,e,r)=>({...Kt(t,e,r),center:D(t.center,e.center,r),radius:m(t.radius,e.radius,r),opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.center.x===e.center.x&&t.center.y===e.center.y&&t.radius===e.radius&&t.colors.length===e.colors.length&&t.colors.every((r,n)=>r===e.colors[n])};function Zy(t){return Array.isArray(t)?t:G(t)}var hu={resolve:t=>({type:"conic-gradient",colors:t.colors.map(Zy),stops:t.stops??t.colors.map((e,r)=>r/Math.max(1,t.colors.length-1)),center:t.center??{x:0,y:0},startAngle:t.startAngle,opacity:t.opacity,blend:t.blend}),lerp:(t,e,r)=>({...Kt(t,e,r),center:D(t.center,e.center,r),startAngle:m(t.startAngle??0,e.startAngle??0,r),opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.center.x===e.center.x&&t.center.y===e.center.y&&(t.startAngle??0)===(e.startAngle??0)&&t.colors.length===e.colors.length&&t.colors.every((r,n)=>r===e.colors[n])};var mu={resolve:t=>{let e=t.color??[0,0,0,1];return{type:"noise",size:t.size??{x:1,y:1},density:t.density??1,color:Array.isArray(e)?e:G(e),seed:t.seed??0,opacity:t.opacity,blend:t.blend}},lerp:(t,e,r)=>({size:{x:m(t.size.x,e.size.x,r),y:m(t.size.y,e.size.y,r)},density:m(t.density,e.density,r),seed:m(t.seed,e.seed,r),color:[m(t.color[0],e.color[0],r),m(t.color[1],e.color[1],r),m(t.color[2],e.color[2],r),m(t.color[3],e.color[3],r)],opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.size.x===e.size.x&&t.size.y===e.size.y&&t.density===e.density&&t.seed===e.seed&&t.color[0]===e.color[0]&&t.color[1]===e.color[1]&&t.color[2]===e.color[2]&&t.color[3]===e.color[3]};function Jy(t){return Array.isArray(t)?t:G(t)}var Qy=[0,0,0,1],eg=[1,1,1,1],tg=t=>t===void 0?{x:3,y:3}:typeof t=="number"?{x:t,y:t}:t,yu={resolve:t=>{let e=t.colors?.length?t.colors.map(Jy):[Qy,eg];return{type:"fractalNoise",basis:t.basis??"simplex",octaves:Math.max(1,Math.min(8,Math.round(t.octaves??4))),frequency:tg(t.frequency),lacunarity:t.lacunarity??2,gain:t.gain??.5,seed:t.seed??0,offset:t.offset??{x:0,y:0},angle:t.angle??0,colors:e,stops:t.stops??e.map((r,n)=>n/Math.max(1,e.length-1)),contrast:t.contrast??1,opacity:t.opacity,blend:t.blend}},lerp:(t,e,r)=>({basis:r<.5?t.basis:e.basis,octaves:r<.5?t.octaves:e.octaves,frequency:D(t.frequency,e.frequency,r),lacunarity:m(t.lacunarity,e.lacunarity,r),gain:m(t.gain,e.gain,r),seed:m(t.seed,e.seed,r),offset:D(t.offset,e.offset,r),angle:m(t.angle,e.angle,r),...Kt(t,e,r),contrast:m(t.contrast,e.contrast,r),opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.basis===e.basis&&t.octaves===e.octaves&&t.frequency.x===e.frequency.x&&t.frequency.y===e.frequency.y&&t.lacunarity===e.lacunarity&&t.gain===e.gain&&t.seed===e.seed&&t.offset.x===e.offset.x&&t.offset.y===e.offset.y&&t.angle===e.angle&&t.contrast===e.contrast&&t.colors.length===e.colors.length&&t.colors.every((r,n)=>{let o=e.colors[n];return o!=null&&r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]})&&t.stops.length===e.stops.length&&t.stops.every((r,n)=>r===e.stops[n])};var gu={resolve:t=>({type:"stripe",gap:t.gap,strokeWidth:t.strokeWidth,angle:t.angle,color:t.color!=null?Array.isArray(t.color)?t.color:G(t.color):void 0,opacity:t.opacity,blend:t.blend}),lerp:(t,e,r)=>({gap:m(t.gap??8,e.gap??8,r),strokeWidth:m(t.strokeWidth??1,e.strokeWidth??1,r),angle:m(t.angle??-45,e.angle??-45,r),color:t.color&&e.color?[m(t.color[0],e.color[0],r),m(t.color[1],e.color[1],r),m(t.color[2],e.color[2],r),m(t.color[3],e.color[3],r)]:t.color??e.color,opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.gap===e.gap&&t.strokeWidth===e.strokeWidth&&t.angle===e.angle&&t.color?.[0]===e.color?.[0]&&t.color?.[1]===e.color?.[1]&&t.color?.[2]===e.color?.[2]&&t.color?.[3]===e.color?.[3]};var rg=2,ng=16,xu={resolve:t=>{let e=t.color??[0,0,0,1];return{type:"dotGrid",radius:t.radius??rg,spacing:t.spacing??ng,offset:t.offset??{x:0,y:0},color:Array.isArray(e)?e:G(e),opacity:t.opacity,blend:t.blend}},lerp:(t,e,r)=>({radius:m(t.radius,e.radius,r),spacing:m(t.spacing,e.spacing,r),offset:{x:m(t.offset.x,e.offset.x,r),y:m(t.offset.y,e.offset.y,r)},color:[m(t.color[0],e.color[0],r),m(t.color[1],e.color[1],r),m(t.color[2],e.color[2],r),m(t.color[3],e.color[3],r)],opacity:m(t.opacity??1,e.opacity??1,r)}),equals:(t,e)=>t.radius===e.radius&&t.spacing===e.spacing&&t.offset.x===e.offset.x&&t.offset.y===e.offset.y&&t.color[0]===e.color[0]&&t.color[1]===e.color[1]&&t.color[2]===e.color[2]&&t.color[3]===e.color[3]};var _u=4;function og(t){if(!t?.length)return;let e=[];for(let r of t)if(!(!r?.name||!r?.src)){if(e.length>=_u){console.warn(`[SkSL] A shader fill declares more than ${_u} textures; the rest are ignored.`);break}e.push({name:r.name,src:r.src})}return e.length?e:void 0}function sg(t,e){return t===e?!0:!t||!e||t.length!==e.length?!1:t.every((r,n)=>r.name===e[n].name&&r.src===e[n].src)}var wu={resolve:t=>({type:"shader",source:t.source??"",...t.shaderId!==void 0?{shaderId:t.shaderId}:{},uniforms:Ze(t.uniforms),coords:t.coords??"normalized",textures:og(t.textures),opacity:t.opacity,blend:t.blend}),lerp:(t,e,r)=>({source:r<.5?t.source:e.source,uniforms:Nn(t.uniforms,e.uniforms,r),coords:r<.5?t.coords:e.coords,textures:r<.5?t.textures:e.textures,opacity:(t.opacity??1)+((e.opacity??1)-(t.opacity??1))*r}),equals:(t,e)=>t.source===e.source&&t.coords===e.coords&&$n(t.uniforms,e.uniforms)&&sg(t.textures,e.textures),declare:(t,e)=>{for(let r of t.textures??[])e.image(r.src)}};function sn(t,e){Hn(t,n=>{if(tn(n)){let s=Gn(n.source);s.kind==="node"&&e.subtree(s.node);return}let o=oa(n);o!==null&&e.image(o)});let r=n=>{n!==void 0&&(n.type==="modelGeometry"?ns("gltf",n.src,e):(n.type==="edges"||n.type==="wireframe")&&r(n.source))};for(let n of t.ops())switch(n.kind){case"mesh":case"points":case"line":case"instances":r(n.geometry);break;case"model":ns("gltf",n.src,e);break}t instanceof Ve&&ua(t.environmentDescriptor(),e)}function ua(t,e){if(t!==null){t.src!==void 0&&ns(Su(t.src),t.src,e);for(let r of t.faces??[])ns(Su(r),r,e)}}var vu=new WeakMap;function ns(t,e,r){let n=ca();if(!n)return;let o=ia(t,e),s=vu.get(n);s||vu.set(n,s=new Map);let i=s.get(o);i||s.set(o,i=()=>n(t,e)),r.loader(o,i)}function Su(t){return t.toLowerCase().endsWith(".exr")?"exr":"hdr"}var bu={resolve:t=>({...t}),lerp:(t,e,r)=>({scene:r<.5?t.scene:e.scene,maxPixelRatio:t.maxPixelRatio??e.maxPixelRatio,antialias:t.antialias??e.antialias,opacity:(t.opacity??1)+((e.opacity??1)-(t.opacity??1))*r}),equals:(t,e)=>t.scene===e.scene,declare:(t,e)=>{sn(t.scene,e)}};var Au=new Map([["solid",du],["linear-gradient",fu],["radial-gradient",pu],["conic-gradient",hu],["noise",mu],["fractalNoise",yu],["stripe",gu],["dotGrid",xu],["grid",Cd],["shader",wu],["image",Gd],["video",Yd],["canvas3D",bu]]);function fa(t){let e=Au.get(t);if(!e)throw new Error(`Fill "${t}" is not registered`);return e}function Ht(t){if(typeof t=="string")return Ht({type:"solid",color:t});if(t instanceof Ve)return Ht({type:"canvas3D",scene:t});let e=fa(t.type).resolve(t),r=t.space;return r!==void 0?{...e,space:r}:e}var Mu=Ht({type:"image",src:""});function Ou(t,e){return t.type===e.type?t.blend===e.blend:da(t,e)}function os(t,e,r){let n=Math.min(1,Math.max(0,r));if(t.type!==e.type){if(!da(t,e))throw new Error(`No registered lerp for fills of type "${t.type}" and "${e.type}"`);let[o,s]=cu(t,e);return{...o,...fa(o.type).lerp(o,s,n)}}if(t.blend!==e.blend)throw new Error(`No registered lerp for fills of type "${t.type}" and "${e.type}"`);return{...t,...fa(t.type).lerp(t,e,n)}}function ku(t,e){return{...t,opacity:(t.opacity??1)*Math.max(0,e)}}function pa(t,e){Au.get(t.type)?.declare?.(t,e)}var q={resolve:t=>Qr(t).map(Ht),lerp:(t,e,r)=>{if(t===e)return t;if(!t.length&&!e.length)return[];let n=Math.min(1,Math.max(0,r)),o=Math.max(t.length,e.length),s=[];for(let i=0;i<o;i++){let a=t[i],l=e[i];a&&l?Ou(a,l)?s.push(os(a,l,n)):(n<1&&s.push(ku(a,1-n)),n>0&&s.push(ku(l,n))):a?s.push(os(a,{...a,opacity:0},n)):l&&s.push(os({...l,opacity:0},l,n))}return s}};function Eu(t,e){return{blur:t.blur??e?.blur??0,offset:t.offset??e?.offset,fill:t.fill!=null?q.resolve(t.fill):e?.fill??q.resolve("transparent"),inner:t.inner??e?.inner??!1,spread:t.spread??e?.spread??0}}function ig(t,e,r){return{blur:t.blur+(e.blur-t.blur)*r,offset:D(t.offset??{x:0,y:0},e.offset??{x:0,y:0},r),fill:q.lerp(t.fill,e.fill,r),inner:r<1?t.inner:e.inner,spread:t.spread+(e.spread-t.spread)*r}}var mt={resolve:(t,e)=>t==null?[]:(Array.isArray(t)?t:[t]).map((n,o)=>Eu(n,e?.[o])),lerp:(t,e,r)=>{if(t===e)return t;let n=Math.max(t.length,e.length),o=[];for(let s=0;s<n;s++){let i=t[s],a=e[s];if(!i){o.push(a);continue}if(!a){o.push(i);continue}o.push(ig(i,a,r))}return o}};function Cu(t,e){if(t==null)return e;if(typeof t=="number")return Math.max(-1,Math.min(1,t));switch(t){case"inside":return-1;case"center":return 0;case"outside":return 1}return e}var Pu=4;function Tu(t){switch(t){case"arrow":case"triangle":case"stealth":case"dot":case"box":case"diamond":case"bar":return!0}return!1}function ma(t,e){if(t==null)return e;switch(t){case"butt":case"round":case"square":return t}return e}function ha(t,e){return Tu(t)?t:ma(t,e)}function Du(t,e){if(t==null)return e;switch(t){case"miter":case"round":case"bevel":return t}return e}function Ru(t,e){let r;if(t.dash!=null){let o=Array.isArray(t.dash)?t.dash:[t.dash];r=o.length===1?[o[0],o[0]]:o}else r=e?.dash;let n=ma(t.cap,e?.cap??"butt");return{weight:t.weight??e?.weight??1,fill:t.fill!=null?q.resolve(t.fill):e?.fill??q.resolve("transparent"),dash:r,dashOffset:t.dashOffset??e?.dashOffset??0,align:Cu(t.align,e?.align??-1),cap:n,startCap:t.startCap!=null?ha(t.startCap,n):e?.startCap,endCap:t.endCap!=null?ha(t.endCap,n):e?.endCap,capScale:Math.max(0,t.capScale??e?.capScale??Pu),join:Du(t.join,e?.join??"miter"),miterLimit:t.miterLimit??e?.miterLimit??4}}function ag(t,e,r){let n=t||[],o=e||[];if(n.length===0&&o.length===0)return t;let s=Math.max(n.length,o.length),i=new Array(s);for(let a=0;a<s;a++){let l=n[a]??0,c=o[a]??0;i[a]=l+(c-l)*r}return i}function lg(t,e,r){return{weight:t.weight+(e.weight-t.weight)*r,fill:q.lerp(t.fill,e.fill,r),dash:ag(t.dash,e.dash,r),dashOffset:t.dashOffset+(e.dashOffset-t.dashOffset)*r,align:t.align+(e.align-t.align)*r,cap:r<.5?t.cap:e.cap,startCap:r<.5?t.startCap:e.startCap,endCap:r<.5?t.endCap:e.endCap,capScale:t.capScale+(e.capScale-t.capScale)*r,join:r<.5?t.join:e.join,miterLimit:t.miterLimit+(e.miterLimit-t.miterLimit)*r}}var _e={resolve:(t,e)=>t==null?[]:(Array.isArray(t)?t:[t]).map((n,o)=>Ru(n,e?.[o])),lerp:(t,e,r)=>{if(t===e)return t;let n=Math.max(t.length,e.length),o=[];for(let s=0;s<n;s++){let i=t[s],a=e[s];if(!i){o.push(a);continue}if(!a){o.push(i);continue}o.push(lg(i,a,r))}return o}};var Iu=new WeakMap,Fu=new WeakMap,cg=0;function Ut(t,e){return Iu.set(t,e),t}function zu(t){let e=Iu.get(t);if(e!==void 0)return e;let r=Fu.get(t);return r===void 0&&(r=`fn#${cg++}`,Fu.set(t,r)),r}var Nu="quad",ya=Math.PI,ga=t=>t===void 0?{type:Nu}:typeof t=="string"?{type:t}:{...t,type:t.type??Nu},ss={sine:t=>1-Math.cos(t*ya/2),quad:t=>t*t,cubic:t=>t*t*t,quart:t=>t*t*t*t,quint:t=>t*t*t*t*t,expo:t=>t===0?0:Math.pow(2,10*(t-1)),circ:t=>1-Math.sqrt(1-t*t),back:(t,e)=>{let r=e.overshoot??1.70158;return t*t*((r+1)*t-r)},elastic:(t,e)=>{if(t===0||t===1)return t;let r=e.amplitude??1,n=e.period??.3,o=n/(2*ya)*Math.asin(1/r);return-(r*Math.pow(2,10*(t-1))*Math.sin((t-1-o)*2*ya/n))},bounce:t=>1-(r=>r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-=.5454545454545454)*r+.75:r<.9090909090909091?7.5625*(r-=.8181818181818182)*r+.9375:7.5625*(r-=.9545454545454546)*r+.984375)(1-t)},xa=(t,e)=>`${t}:${e.type}:${e.overshoot??"_"}:${e.amplitude??"_"}:${e.period??"_"}`,is=()=>Ut(t=>pt(t),"lin"),$u=t=>{let e=ga(t);return Ut(r=>ss[e.type](pt(r),e),xa("in",e))},ju=t=>{let e=ga(t);return Ut(r=>1-ss[e.type](1-pt(r),e),xa("out",e))},Bu=t=>{let e=ga(t),r=e.type==="back"?{...e,overshoot:(e.overshoot??1.70158)*1.525}:e.type==="elastic"?{...e,period:e.period??.45}:e;return Ut(n=>(n=pt(n),n<.5?ss[r.type](2*n,r)/2:1-ss[r.type](2*(1-n),r)/2),xa("inOut",e))};var _a=is(),Xt=class t{segments;constructor(e=[]){this.segments=e}ramp(e,r,n,o){return new t([...this.segments,{from:e,to:r,duration:n,ease:o?.ease}])}hold(e){return new t([...this.segments,{duration:e}])}fadeIn(e,r){return new t([...this.segments,{from:0,to:1,duration:e,ease:r?.ease}])}fadeOut(e,r){return new t([...this.segments,{to:0,duration:e,ease:r?.ease}])}resolve(e,r){let n=this.segments;if(n.length===0)return[];let o=Number.isFinite(e)&&e>0?e:0,s=0,i=0;for(let f of n)f.duration===void 0?i++:s+=Math.max(0,f.duration);i>1,s>o;let a=Math.max(0,o-s),l=i>0?n.findIndex(f=>f.duration===void 0):a>0?n.length-1:-1,c=[],d=0,u=r;for(let f=0;f<n.length;f++){let h=n[f];if(i===0&&f===l&&a>0){let b=Math.min(d,o),k=Math.min(d+a,o);c.push({startTime:b,endTime:k,from:u,to:u,ease:_a,isLinear:!0}),d+=a}let y;h.duration===void 0?y=f===l?a:0:y=Math.max(0,h.duration);let w=h.from??u,g=h.to??w,x=Math.min(d,o),_=Math.min(d+y,o),S=h.ease??_a;c.push({startTime:x,endTime:_,from:w,to:g,ease:S,isLinear:S===_a}),d+=y,u=g}return c}sampleAt(e,r,n){let o=this.resolve(r,n);if(o.length===0)return n;if(e<=o[0].startTime)return o[0].from;for(let s of o)if(e>=s.startTime&&e<=s.endTime){let i=s.endTime-s.startTime,a=i>0?(e-s.startTime)/i:1;return m(s.from,s.to,s.ease(a))}return o[o.length-1].to}staticValue(e){return this.segments[0]?.from??e}};function dg(t,e,r,n){return new Xt().ramp(t,e,r,n)}function ug(t){return new Xt().hold(t)}function fg(t,e){return new Xt().fadeIn(t,e)}function pg(t,e){return new Xt().fadeOut(t,e)}function Zt(t){return t instanceof Xt}function wa(t,e=0){return Zt(t)?t.staticValue(e):t}function Qe(t){return t===void 0?"_":Zt(t)?"c["+t.segments.map(e=>`${e.from??"_"},${e.to??"_"},${e.duration??"_"},${e.ease?zu(e.ease):"lin"}`).join(";")+"]":String(t)}function le(t,e,r){return typeof t=="number"&&typeof e=="number"?m(t,e,r):r<.5?t:e}var va={resolve:t=>t,lerp:le};function pe(t,e){return t===e?!0:typeof t=="number"&&typeof e=="number"?t===e:!1}var Lu=.001;function Sa(t,e,r=e,n=Lu){let o=Math.min(r,e);if(o<=0)return 0;let s=0;for(let i=0;i<o;i+=n){let a=Math.min(n,o-i),l=Math.max(1e-6,t.sampleAt(i+a/2,e,1));s+=a/l}return s}function hg(t,e,r,n=Lu){if(r<=0)return 0;let o=0,s=0;for(;s<e;){let i=Math.min(n,e-s),a=Math.max(1e-6,t.sampleAt(s+i/2,e,1)),l=i/a;if(o+l>=r){let c=l>0?(r-o)/l:0;return s+i*c}o+=l,s+=i}return e}function an(t,e){return typeof t=="number"||Zt(t)?{[e]:t}:t}var Un=class t{list;constructor(e=[]){this.list=e}append(e){return new t([...this.list,e])}gain(e){let{value:r}=an(e,"value");return this.append({type:"gain",value:r})}volume(e){return this.gain(e)}highpass(e){let{frequency:r,q:n}=an(e,"frequency");return this.append({type:"highpass",frequency:r,q:n})}lowpass(e){let{frequency:r,q:n}=an(e,"frequency");return this.append({type:"lowpass",frequency:r,q:n})}tremolo(e){let{rate:r,depth:n}=an(e,"rate");return this.append({type:"tremolo",rate:r,depth:n??.5})}speed(e){let{value:r}=an(e,"value");return this.append({type:"speed",value:r})}echo(e){let{delay:r,feedback:n,mix:o}=an(e,"delay");return this.append({type:"echo",delay:r,feedback:n??.4,mix:o})}*[Symbol.iterator](){yield*this.list}toJSON(){return this.list}},ln=new Un;function yt(t){return t===void 0?[]:t instanceof Un?t.list:Array.isArray(t)?t:[t]}function ba(t){let e=1;for(let r of t)r.type==="speed"&&!Zt(r.value)&&r.value>0&&(e*=r.value);return e}function as(t,e){let r=ba(t);for(let n of t)if(n.type==="speed"&&Zt(n.value))return Sa(n.value,e)/r;return e/r}function Wu(t,e,r,n){let o=t.at??0,s=t.until??1/0,i=t.trimStart??0,a=t.trimEnd??1/0,l=t.loop??!1,c=yt(t.filters),d=e.getMediaDuration(t.src),u={id:`${r}|${t.src}|${o}|${n}`,src:t.src,startAt:o,endAt:1/0,trimStart:i,volume:t.volume??1,loop:l,ownerId:r};if(c.length>0&&(u.filters=c),t.bus&&(u.bus=t.bus),t.optional&&(u.optional=!0),l&&a>i&&Number.isFinite(a)&&(u.trimEnd=a),l&&Number.isFinite(s))u.endAt=s;else if(l)u.open=!0;else if(Number.isFinite(a))u.endAt=Math.min(s,o+as(c,Math.max(0,a-i)));else{let f=as(c,Math.max(0,d-i));Number.isFinite(s)?u.endAt=Math.min(s,o+f):(u.open=!0,u.mediaDuration=f)}return u}var ka=class{src;volume;loop;trimStart;trimEnd;filters;constructor(e){this.src=e.src,this.volume=e.volume??1,this.loop=e.loop??!1,this.trimStart=e.trimStart??0,this.trimEnd=e.trimEnd??e.duration??1/0,this.filters=yt(e.filters)}effectiveSpeed(){return ba(this.filters)}clipDurationFor(e){return as(this.filters,e)}sceneDurationFor(e){return this.clipDurationFor(e)}get clipDuration(){return this.trimEnd!==1/0?this.clipDurationFor(this.trimEnd-this.trimStart):void 0}};function Xn(t){return!t||t.length===0?"":t.map(e=>{switch(e.type){case"gain":case"speed":return`${e.type}:${Qe(e.value)}`;case"highpass":case"lowpass":return`${e.type}:${Qe(e.frequency)}:${Qe(e.q)}`;case"tremolo":return`tremolo:${Qe(e.rate)}:${Qe(e.depth)}`;case"echo":return`echo:${Qe(e.delay)}:${Qe(e.feedback)}:${Qe(e.mix)}`}}).join("|")}function Aa(t){return`${t.id}:${Qe(t.volume)}:${Qe(t.pan)}:${t.mute?1:0}:${Xn(t.filters)}:${t.startAt}:${t.endAt}`}var qu={lerp:(t,e,r)=>({type:"gain",value:le(t.value,e.value,r)}),equals:(t,e)=>pe(t.value,e.value)};var Vu={lerp:(t,e,r)=>({type:"highpass",frequency:le(t.frequency,e.frequency,r),q:le(t.q??1,e.q??1,r)}),equals:(t,e)=>pe(t.frequency,e.frequency)&&pe(t.q??1,e.q??1)};var Gu={lerp:(t,e,r)=>({type:"lowpass",frequency:le(t.frequency,e.frequency,r),q:le(t.q??1,e.q??1,r)}),equals:(t,e)=>pe(t.frequency,e.frequency)&&pe(t.q??1,e.q??1)};var Yu={lerp:(t,e,r)=>({type:"tremolo",rate:le(t.rate,e.rate,r),depth:le(t.depth,e.depth,r)}),equals:(t,e)=>pe(t.rate,e.rate)&&pe(t.depth,e.depth)};var Ku={lerp:(t,e,r)=>({type:"speed",value:le(t.value,e.value,r)}),equals:(t,e)=>pe(t.value,e.value)};var Hu={lerp:(t,e,r)=>({type:"echo",delay:le(t.delay,e.delay,r),feedback:le(t.feedback,e.feedback,r),mix:le(t.mix??.5,e.mix??.5,r)}),equals:(t,e)=>pe(t.delay,e.delay)&&pe(t.feedback,e.feedback)&&pe(t.mix??.5,e.mix??.5)};var yg={gain:qu,highpass:Vu,lowpass:Gu,tremolo:Yu,speed:Ku,echo:Hu},ls=class t{static registry=new Map(Object.entries(yg));static register(e,r){if(this.registry.has(e))throw new Error(`Audio filter "${e}" is already registered`);this.registry.set(e,r)}static get(e){return this.registry.get(e)}static has(e){return this.registry.has(e)}static lerp(e,r,n){if(e.type!==r.type)return n<.5?e:r;let o=this.registry.get(e.type);return o?o.lerp(e,r,n):n<.5?e:r}static lerpArray(e,r,n){let o=Math.max(e.length,r.length),s=[];for(let i=0;i<o;i++){let a=e[i],l=r[i];a&&l?s.push(t.lerp(a,l,n)):a?s.push(a):l&&s.push(l)}return s}},cs={resolve:yt,lerp:ls.lerpArray};function Ar(t){return(t.g??0)!==0||(t.h??0)!==0||(t.i??1)!==1}var ds=1e-6;function gg(t){return t>ds||t<-ds?t:t<0?-ds:ds}function Ma(){return{a:1,b:0,c:0,d:1,e:0,f:0}}function Zn(t,e){return{a:1,b:0,c:0,d:1,e:t,f:e}}function we(t,e){return Ar(t)||Ar(e)?xg(t,e):{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,e:t.a*e.e+t.c*e.f+t.e,f:t.b*e.e+t.d*e.f+t.f}}function xg(t,e){let r=t.g??0,n=t.h??0,o=t.i??1,s=e.g??0,i=e.h??0,a=e.i??1;return{a:t.a*e.a+t.c*e.b+t.e*s,c:t.a*e.c+t.c*e.d+t.e*i,e:t.a*e.e+t.c*e.f+t.e*a,b:t.b*e.a+t.d*e.b+t.f*s,d:t.b*e.c+t.d*e.d+t.f*i,f:t.b*e.e+t.d*e.f+t.f*a,g:r*e.a+n*e.b+o*s,h:r*e.c+n*e.d+o*i,i:r*e.e+n*e.f+o*a}}function ee(t,e){let r=t.a*e.x+t.c*e.y+t.e,n=t.b*e.x+t.d*e.y+t.f;if(!Ar(t))return{x:r,y:n};let o=gg((t.g??0)*e.x+(t.h??0)*e.y+(t.i??1));return{x:r/o,y:n/o}}function Ie(t){if(Ar(t))return _g(t);let e=t.a*t.d-t.b*t.c;if(e===0||!Number.isFinite(e))return null;let r=1/e;return{a:t.d*r,b:-t.b*r,c:-t.c*r,d:t.a*r,e:(t.c*t.f-t.d*t.e)*r,f:(t.b*t.e-t.a*t.f)*r}}function _g(t){let{a:e,b:r,c:n,d:o,e:s,f:i}=t,a=t.g??0,l=t.h??0,c=t.i??1,d=o*c-i*l,u=i*a-r*c,f=r*l-o*a,h=e*d+n*u+s*f;if(h===0||!Number.isFinite(h))return null;let y=1/h;return{a:d*y,c:(s*l-n*c)*y,e:(n*i-s*o)*y,b:u*y,d:(e*c-s*a)*y,f:(s*r-e*i)*y,g:f*y,h:(n*a-e*l)*y,i:(e*o-n*r)*y}}function Oa(t,e,r,n,o){let s=-o*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=n*i,c=n*a,d=n*-a,u=n*i,f=-r.x,h=r.y;return{a:l,b:c,c:d,d:u,e:t+l*f+d*h,f:e+c*f+u*h}}function Uu(t,e,r,n,o,s){let i=r*Math.PI/180,a=Math.cos(i),l=Math.sin(i),c=n*a,d=n*l,u=n*-l,f=n*a;return{a:c,b:d,c:u,d:f,e:t+o-(c*o+u*s),f:e+s-(d*o+f*s)}}var Mr={rotationX:0,rotationY:0,rotationZ:0,depth:0,perspective:0,flipHorizontal:!1,flipVertical:!1};function us(t){return t.rotationX!==0||t.rotationY!==0||t.rotationZ!==0||t.flipHorizontal||t.flipVertical||t.perspective!==0&&t.depth!==0}function Ea(t,e){let r=Math.PI/180;return Math.cos(t*r)*Math.cos(e*r)<0}function Ca(t,e,r,n,o,s,i){if(!us(i))return Uu(t,e,r,n,o,s);let a=Math.PI/180,l=Math.cos(i.rotationX*a),c=Math.sin(i.rotationX*a),d=Math.cos(i.rotationY*a),u=Math.sin(i.rotationY*a),f=(r+i.rotationZ)*a,h=Math.cos(f),y=Math.sin(f),w=d*h*n,g=-d*y*n,x=(c*u*h+l*y)*n,_=(l*h-c*u*y)*n,S=(c*y-l*u*h)*n,b=(l*u*y+c*h)*n,k=i.perspective!==0?1/i.perspective:0,M=-S*k,T=-b*k,V=1-(i.depth-(S*o+b*s))*k,W=t+o,Se=e+s,Ee=i.flipHorizontal?-1:1,Tt=i.flipVertical?-1:1;return{a:(w+W*M)*Ee,c:(g+W*T)*Tt,e:-(w*o+g*s)+W*V,b:(x+Se*M)*Ee,d:(_+Se*T)*Tt,f:-(x*o+_*s)+Se*V,g:M*Ee,h:T*Tt,i:V}}function cn(t,e,r){let n={x:m(t.x,e.x,r),y:m(t.y,e.y,r)};return(t.z!==void 0||e.z!==void 0)&&(n.z=m(t.z??0,e.z??0,r)),n}function Or(t,e){let r=new Array(12);for(let n=0;n<3;n++){let o=t[n*4],s=t[n*4+1],i=t[n*4+2],a=t[n*4+3];r[n*4]=o*e[0]+s*e[4]+i*e[8],r[n*4+1]=o*e[1]+s*e[5]+i*e[9],r[n*4+2]=o*e[2]+s*e[6]+i*e[10],r[n*4+3]=o*e[3]+s*e[7]+i*e[11]+a}return r}function hs(t,e,r,n,o,s,i){let a=Math.PI/180,l=Math.cos(i.rotationX*a),c=Math.sin(i.rotationX*a),d=Math.cos(i.rotationY*a),u=Math.sin(i.rotationY*a),f=(r+i.rotationZ)*a,h=Math.cos(f),y=Math.sin(f),w=d*h*n,g=-d*y*n,x=u*n,_=(c*u*h+l*y)*n,S=(l*h-c*u*y)*n,b=-c*d*n,k=(c*y-l*u*h)*n,M=(l*u*y+c*h)*n,T=l*d*n,V=i.flipHorizontal?-1:1,W=i.flipVertical?-1:1;return[w*V,g*W,x,t+o-(w*o+g*s),_*V,S*W,b,e+s-(_*o+S*s),k*V,M*W,T,i.depth-(k*o+M*s)]}function fs(t){let e=Math.PI/180,r=Math.sin(t.orbit*e),n=Math.cos(t.orbit*e),o=Math.sin(t.elevation*e),s=Math.cos(t.elevation*e),i=n,a=0,l=-r,c=r*o,d=s,u=n*o,f=r*s,h=-o,y=n*s,w=t.lookAt.x,g=-t.lookAt.y,x=t.lookAt.z??0;return[i,a,l,-(i*w+a*g+l*x),c,d,u,-(c*w+d*g+u*x),f,h,y,-(f*w+h*g+y*x)+t.dolly]}function Qn(t,e){let r=t.perspective>0?1/t.perspective:0,n=-e[8]*r,o=-e[9]*r,s=1-e[11]*r,i=-t.heading*Math.PI/180,a=t.zoom,l=a*Math.cos(i),c=-a*Math.sin(i),d=a*Math.sin(i),u=a*Math.cos(i),f=t.viewportX,h=t.viewportY,y={a:l*e[0]+c*e[4]+f*n,c:l*e[1]+c*e[5]+f*o,e:l*e[3]+c*e[7]+f*s,b:d*e[0]+u*e[4]+h*n,d:d*e[1]+u*e[5]+h*o,f:d*e[3]+u*e[7]+h*s};return r!==0&&(y.g=n,y.h=o,y.i=s),y}function Ta(t,e){let r=e.width/2,n=e.height/2,o=[e.x-r,e.x+r,e.x+r,e.x-r],s=[e.y-n,e.y-n,e.y+n,e.y+n],i=new Array(12);for(let l=0;l<4;l++){let c=o[l],d=s[l];i[l*3]=t[0]*c+t[1]*d+t[3],i[l*3+1]=t[4]*c+t[5]*d+t[7],i[l*3+2]=t[8]*c+t[9]*d+t[11]}let a=Math.hypot(t[2],t[6],t[10])||1;return{corners:i,cx:t[0]*e.x+t[1]*e.y+t[3],cy:t[4]*e.x+t[5]*e.y+t[7],cz:t[8]*e.x+t[9]*e.y+t[11],nx:t[2]/a,ny:t[6]/a,nz:t[10]/a}}var Da=.01,Xu=.001;function ps(t,e){if(t.perspective>0){let r=-e.cx,n=-e.cy,o=t.perspective-e.cz,s=e.nx*r+e.ny*n+e.nz*o;return{side:s,edgeOn:Math.abs(s)<=Xu*Math.hypot(r,n,o)}}return{side:e.nz,edgeOn:Math.abs(e.nz)<=Xu}}function Qu(t,e){if(t.perspective<=0)return"all";let r=0;for(let n=0;n<4;n++)1-e.corners[n*3+2]/t.perspective>Da&&r++;return r===4?"all":r===0?"none":"some"}function ef(t,e,r){let n=t.g??0,o=t.h??0,s=t.i??1,i=e.width/2+r,a=e.height/2+r,l=[{x:e.x-i,y:e.y-a},{x:e.x+i,y:e.y-a},{x:e.x+i,y:e.y+a},{x:e.x-i,y:e.y+a}],c=u=>n*u.x+o*u.y+s-Da,d=[];for(let u=0;u<l.length;u++){let f=l[u],h=l[(u+1)%l.length],y=c(f),w=c(h);if(y>=0&&d.push(f),y>=0!=w>=0){let g=y/(y-w);d.push({x:f.x+(h.x-f.x)*g,y:f.y+(h.y-f.y)*g})}}return d.length>=3?d:null}var Pa=.01;function Zu(t,e,r){let n=0,o=0;for(let i=0;i<4;i++){let a=t.nx*(e.corners[i*3]-t.cx)+t.ny*(e.corners[i*3+1]-t.cy)+t.nz*(e.corners[i*3+2]-t.cz);a>Pa?n++:a<-Pa&&o++}if(n===0&&o===0)return 0;let s=r>0?1:-1;return o===0?s:n===0?-s:0}function Jn(t,e){return t.perspective>0?e.cx*e.cx+e.cy*e.cy+(t.perspective-e.cz)**2:-e.cz}function wg(t,e,r){let n=ps(t,e);if(!n.edgeOn){let a=Zu(e,r,n.side);if(a!==0)return a>0?-1:1;if(vg(e,r))return 0}let o=ps(t,r);if(!o.edgeOn){let a=Zu(r,e,o.side);if(a!==0)return a>0?1:-1}let s=Jn(t,e),i=Jn(t,r);return s===i?0:s>i?-1:1}function vg(t,e){for(let r=0;r<4;r++){let n=t.nx*(e.corners[r*3]-t.cx)+t.ny*(e.corners[r*3+1]-t.cy)+t.nz*(e.corners[r*3+2]-t.cz);if(Math.abs(n)>Pa)return!1}return!0}function Ju(t){return{...t,viewportX:0,viewportY:0}}var Sg={lerpLookAt:cn,project(t,e){let r=Ju(t),n=fs(r),o=e.x,s=-e.y,i=e.z??0,a=n[0]*o+n[1]*s+n[2]*i+n[3],l=n[4]*o+n[5]*s+n[6]*i+n[7],c=n[8]*o+n[9]*s+n[10]*i+n[11],d=r.perspective>0?1-c/r.perspective:1;if(d<=Da)return null;let u=-r.heading*Math.PI/180,f=r.zoom*a/d,h=r.zoom*l/d;return{x:Math.cos(u)*f-Math.sin(u)*h,y:-(Math.sin(u)*f+Math.cos(u)*h)}},focusVector(t,e){let r=Ju(t),n=-r.heading*Math.PI/180,o=r.zoom||1,s=e.x,i=-e.y,a=(Math.cos(n)*s+Math.sin(n)*i)/o,l=(-Math.sin(n)*s+Math.cos(n)*i)/o,c=r.perspective>0?1-r.dolly/r.perspective:1,d=fs(r),u=a*c,f=l*c;return{x:u*d[0]+f*d[4],y:-(u*d[1]+f*d[5]),z:u*d[2]+f*d[6]}}},bg=96;function tf(t,e){let r=e.length;if(r>bg)return e.map((a,l)=>l).sort((a,l)=>Jn(t,e[l])-Jn(t,e[a])||a-l);let n=Array.from({length:r},()=>[]),o=new Array(r).fill(0);for(let a=0;a<r;a++)for(let l=a+1;l<r;l++){let c=wg(t,e[a],e[l]);c<0?(n[a].push(l),o[l]++):c>0&&(n[l].push(a),o[a]++)}let s=[],i=new Array(r).fill(!1);for(;s.length<r;){let a=-1;for(let l=0;l<r;l++)if(!i[l]&&o[l]===0){a=l;break}if(a===-1){let l=-1/0;for(let c=0;c<r;c++){if(i[c])continue;let d=Jn(t,e[c]);d>l&&(l=d,a=c)}}i[a]=!0,s.push(a);for(let l of n[a])o[l]--}return s}var ms={resolve:t=>t,lerp:(t,e,r)=>({width:m(t.width,e.width,r),height:m(t.height,e.height,r)}),expand:t=>{t.size!==void 0&&(t.width===void 0&&(t.width=t.size),t.height===void 0&&(t.height=t.size))}},ce={resolve:t=>t,lerp:(t,e,r)=>typeof t=="number"&&typeof e=="number"?m(t,e,r):r===1?e:t,resolveLayout:(t,e,r)=>typeof t=="number"?t:t==="fill"?e:t==="hug"?r:e,isAuto:t=>typeof t!="number"};var ys=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","lineHeight","textAlign","fill","stroke","shadow"],gs=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","lineHeight","textAlign"],Jt=Object.freeze({}),oe={resolve:t=>t,lerp:kg,preset:Ag,mergeStyle:rf,resolveStyle:Mg,lerpStyle:Og,lerpFontSize:nf,styleProps:Eg,flatten:Cg,applyCase:Tg};function kg(t,e,r){if(r<=0)return t;if(r>=1)return e;let n=0,o=Math.min(t.length,e.length);for(;n<o&&t.charCodeAt(n)===e.charCodeAt(n);)n++;let s=0,i=Math.min(t.length-n,e.length-n);for(;s<i&&t.charCodeAt(t.length-1-s)===e.charCodeAt(e.length-1-s);)s++;let a=t.length-n-s,l=e.length-n-s,c=a+l;if(c===0)return e;let d=t.substring(0,n),u=t.substring(t.length-s),f=a/c;if(r<f){let w=f===0?1:r/f,g=Math.round(a*(1-w));return d+t.substring(n,n+g)+u}let h=f===1?1:(r-f)/(1-f),y=Math.round(l*h);return d+e.substring(n,n+y)+u}function Ag(t){return Gi(t)??Jt}function rf(t,e){let r=null;for(let n of ys){let o=e?.[n];o!==void 0&&((r??={...t})[n]=o)}return r??t}function Mg(t,e){let r=t??{};return{fontFamily:r.fontFamily??e.fontFamily,fontSize:r.fontSize??e.fontSize,fontWeight:r.fontWeight??e.fontWeight,fontStyle:r.fontStyle??e.fontStyle,letterSpacing:r.letterSpacing??e.letterSpacing,lineHeight:r.lineHeight??e.lineHeight,textAlign:r.textAlign??e.textAlign,fill:q.resolve(r.fill??e.fill??[]),stroke:_e.resolve(r.stroke??e.stroke??[]),shadow:mt.resolve(r.shadow??e.shadow??[])}}function Og(t,e,r){return{fontFamily:r<.5?t.fontFamily:e.fontFamily,fontSize:nf(t.fontSize,e.fontSize,r),fontWeight:Ra(t.fontWeight,e.fontWeight,r),fontStyle:r<.5?t.fontStyle:e.fontStyle,letterSpacing:Ra(t.letterSpacing,e.letterSpacing,r),lineHeight:Ra(t.lineHeight,e.lineHeight,r),textAlign:r<.5?t.textAlign:e.textAlign,fill:q.lerp(t.fill,e.fill,r),stroke:_e.lerp(t.stroke,e.stroke,r),shadow:mt.lerp(t.shadow,e.shadow,r)}}function Eg(t){return rf({},t)}function Cg(t,e){let r=[],n=(o,s)=>{let i={fontFamily:o.fontFamily??s.fontFamily,fontSize:o.fontSize??s.fontSize,fontWeight:o.fontWeight??s.fontWeight,fontStyle:o.fontStyle??s.fontStyle,letterSpacing:o.letterSpacing??s.letterSpacing,fill:o.fill!=null?q.resolve(o.fill):s.fill,stroke:o.stroke!=null?_e.resolve(o.stroke):s.stroke};o.text&&r.push({text:o.text,...i});for(let a of o.children??[])n(a,i)};for(let o of t)n(o,e);return r}var Pg=/[\p{L}\p{N}'\u2019]/u;function Tg(t,e){if(e!=="upper"&&e!=="lower"&&e!=="title")return t;let r="",n="";for(let o of t){let s=e==="upper"||e==="title"&&!Pg.test(n),i=e==="lower"?o.toLowerCase():s?o.toUpperCase():o;r+=i.length===o.length?i:o,n=o}return r}function nf(t,e,r){return typeof t=="number"&&typeof e=="number"?m(t,e,r):r<.5?t:e}function Ra(t,e,r){return t==null||e==null?r<.5?t:e:m(t,e,r)}var Er=Symbol("propertyMeta");function Qt(t){return Fa(t,Er)}function Fa(t,e){let r=[],n=Object.getPrototypeOf(t);for(;n&&n!==Object.prototype;)r.unshift(n),n=Object.getPrototypeOf(n);let o=[],s=new Map;for(let i of r)if(Object.prototype.hasOwnProperty.call(i,e))for(let a of i[e]){let l=s.get(a.key);l===void 0?(s.set(a.key,o.length),o.push(a)):o[l]=a}return o}function p(t){return function(e,r){let n=r,{default:o,mapper:s,tween:i,...a}=t??{},l={key:n,default:o,options:s!=null||i!=null?{mapper:s,tween:i}:void 0,...Object.keys(a).length>0?{editor:a}:{}};Object.prototype.hasOwnProperty.call(e,Er)||(e[Er]=[]);let c=e[Er];c.some(d=>d.key===n)||c.push(l)}}function gt(t,e,r){if(t.measure){let n=t.measure(e,r);return{width:n.width??0,height:n.height??0}}return{width:of(t.width,e.maxWidth),height:of(t.height,e.maxHeight)}}function of(t,e){return typeof t=="number"?t:t==="fill"?e??0:0}function af(t,e,r,n,o){let s=e?"width":"height",i=e?"height":"width",a=(e?n.hugWidth:n.hugHeight)===!0,l=(e?n.hugHeight:n.hugWidth)===!0,c={maxWidth:n.width,maxHeight:n.height},d=t.length,u=new Array(d),f=t.map(k=>Rg(k.gapScale)),h=r==="auto"?0:r*Math.max(0,f.reduce((k,M)=>k+M,0)-1),y=0,w=0;for(let k=0;k<d;k++)t[k][s]==="fill"||l&&t[k][i]==="fill"||(u[k]=gt(t[k],c,o),y+=u[k][s],u[k][i]>w&&(w=u[k][i]));let g=l?w:n[i];if(l)for(let k=0;k<d;k++){if(t[k][s]==="fill"||t[k][i]!=="fill")continue;let M=gt(t[k],c,o);u[k]=uf(M,g,e),y+=M[s]}let x=Math.max(0,n[s]-h-y),_=0;for(let k of t)k[s]==="fill"&&(_+=sf(k.flex));for(let k=0;k<d;k++){let M=t[k];if(M[s]!=="fill")continue;let T,V;a?(V=lf(M,e,n,o),T=V[s]):(T=_>0?x*sf(M.flex)/_:0,V=gt(M,e?{maxWidth:T,maxHeight:n.height}:{maxWidth:n.width,maxHeight:T},o));let W=M[i]==="fill"?g:V[i];u[k]=e?{width:T,height:W}:{width:W,height:T}}let S=h,b=0;for(let k of u)S+=k[s],k[i]>b&&(b=k[i]);return{sizes:u,lines:d>0?[{start:0,end:d,cross:b}]:[],gapScales:f,hug:e?{width:S,height:b}:{width:b,height:S}}}function lf(t,e,r,n){let o=gt(t,e?{maxWidth:1/0,maxHeight:r.height}:{maxWidth:r.width,maxHeight:1/0},n),s=e?"width":"height";return Number.isFinite(o[s])?o:{...o,[s]:0}}function cf(t,e,r,n,o,s){let i=e?"width":"height",a=e?"height":"width",l=(e?o.hugWidth:o.hugHeight)===!0,c=l?1/0:o[i],d=r==="auto"?0:r,u={maxWidth:o.width,maxHeight:o.height},f=t.map(x=>l&&x[i]==="fill"?lf(x,e,o,s):gt(x,u,s)),h=[],y=0,w=0,g=0;for(;g<f.length;){let x=g+1,_=f[g][i];for(;x<f.length&&_+d+f[x][i]<=c;)_+=d+f[x][i],x++;let S=0;for(let b=g;b<x;b++)t[b][a]!=="fill"&&f[b][a]>S&&(S=f[b][a]);for(let b=g;b<x;b++)t[b][a]==="fill"&&(f[b]=uf(f[b],S,e));h.push({start:g,end:x,cross:S}),_>y&&(y=_),w+=S,g=x}return w+=n*Math.max(0,h.length-1),{sizes:f,lines:h,gapScales:f.map(()=>1),hug:e?{width:y,height:w}:{width:w,height:y}}}function df(t,e,r,n,o,s,i,a){let l=n?"width":"height",c=n?"height":"width",d=n?(1+i.x)/2:(1-i.y)/2,u=n?(1-i.y)/2:(1+i.x)/2,f=s*Math.max(0,e.length-1);for(let w of e)f+=w.cross;let h=u*(a[c]-f),y=new Array(t.length);for(let w of e){let g=w.end-w.start,x=0,_=0;for(let M=w.start;M<w.end;M++)x+=t[M][l],_+=r[M];let S,b=0;if(o==="auto"){let M=g>1?Math.max(0,a[l]-x)/(g-1):0;S=()=>M,x+=M*(g-1)}else{let M=T=>T<w.end?r[T]:1;S=T=>o*(r[T]+M(T+1))/2,x+=o*Math.max(0,_-1),b=o*(1-r[w.start])/2}let k=d*(a[l]-x)-b;for(let M=w.start;M<w.end;M++){let T=t[M],V=h+u*(w.cross-T[c]);y[M]=Dg(n?k:V,n?V:k,T,a),k+=T[l]+S(M)}h+=w.cross+s}return y}function Dg(t,e,r,n){return{x:t+r.width/2-n.width/2,y:n.height/2-e-r.height/2,width:r.width,height:r.height}}function uf(t,e,r){return r?{width:t.width,height:e}:{width:e,height:t.height}}function sf(t){return t==null?1:Number.isFinite(t)&&t>=0?t:1}function Rg(t){return t==null?1:Number.isFinite(t)?gc(t,0,1):1}function ff(t,e,r){let n={maxWidth:e.width,maxHeight:e.height},o=[],s={width:0,height:0};for(let i of t){let a=gt(i,n,r);o.push(a),a.width>s.width&&(s.width=a.width),a.height>s.height&&(s.height=a.height)}return{sizes:o,hug:s}}function Ia(t,e,r){return t.map(n=>({x:r.x*Math.max(0,e.width-n.width)/2,y:r.y*Math.max(0,e.height-n.height)/2,width:n.width,height:n.height}))}function pf(t,e,r,n,o,s){let i=Math.max(1,Math.round(e)),a=Math.max(0,(o.width-r*(i-1))/i),l=Fg(t,i),c=l.reduce((_,S)=>Math.max(_,S.row+S.rowSpan),0),d=o.hugHeight!==!0&&c>0,u=d?Math.max(0,(o.height-n*(c-1))/c):0,f=new Array(c).fill(u),h=t.map((_,S)=>{let b=l[S],k=za(a,b.colSpan,r),M=d?{maxWidth:k,maxHeight:za(u,b.rowSpan,n)}:{maxWidth:k},T=gt(_,M,s);return d||Ig(f,b.row,b.rowSpan,T.height,n),T}),y=[],w=0;for(let _ of f)y.push(w),w+=_+n;let g=l.map(_=>({x:_.col*(a+r),y:y[_.row]??0,width:za(a,_.colSpan,r),height:mf(f,_.row,_.rowSpan,n)})),x=f.reduce((_,S)=>_+S,0)+n*Math.max(0,c-1);return{sizes:h,cells:g,hug:{width:o.width,height:x}}}function hf(t,e){return t.map(r=>({x:r.x+r.width/2-e.width/2,y:e.height/2-r.y-r.height/2,width:Math.min(r.width,e.width),height:Math.min(r.height,e.height)}))}function Fg(t,e){let r=[],n=[],o=(l,c,d,u)=>{for(let f=0;f<u;f++)for(let h=0;h<d;h++)if(n[l+f]?.[c+h])return!1;return!0},s=(l,c,d,u)=>{for(let f=0;f<u;f++){n[l+f]??=[];for(let h=0;h<d;h++)n[l+f][c+h]=!0}},i=0,a=0;for(let l of t){let c=Math.min(l.colSpan??1,e),d=l.rowSpan??1;if(l.column!==void 0&&l.row!==void 0){s(l.row-1,l.column-1,c,d),r.push({col:l.column-1,row:l.row-1,colSpan:c,rowSpan:d});continue}for(;a+c>e&&(i++,a=0),!o(i,a,c,d);)a++;s(i,a,c,d),r.push({col:a,row:i,colSpan:c,rowSpan:d}),a+=c}return r}function Ig(t,e,r,n,o){if(r===1){n>t[e]&&(t[e]=n);return}let s=n-mf(t,e,r,o);s>0&&(t[e]+=s)}function za(t,e,r){return t*e+r*(e-1)}function mf(t,e,r,n){let o=n*(r-1);for(let s=e;s<e+r;s++)o+=t[s]??0;return o}var zg={x:0,y:0};function Ng(t,e,r,n){let o=Re.insetBounds(r.width,r.height,Re.resolve(t.padding??0));return wf(_f(t,e,o,n),t,o).map(i=>({x:i.x+o.x,y:i.y-o.y,width:i.width,height:i.height}))}function _f(t,e,r,n){let o=t.flow??"freeform";if(typeof o=="string")return Na(o,t,e,r,n);let s=Na(o.from,t,e,r,n),i=Na(o.to,t,e,r,n);return{...i,hug:Vg(s.hug,i.hug,o.t),from:s,t:o.t}}function wf(t,e,r){let n=yf(t,e,r),o=t.from;if(!o)return n;let s=yf(o,e,r),i=t.t??1;return n.map((a,l)=>({x:m(s[l].x,a.x,i),y:m(s[l].y,a.y,i),width:m(s[l].width,a.width,i),height:m(s[l].height,a.height,i)}))}function $g(t,e){let{space:r,hug:n}=t;return gf(e.width,r.width,r.hugWidth,n.width)&&gf(e.height,r.height,r.hugHeight,n.height)}function jg(t,e,r){let n=xs(t.width,e.maxWidth),o=xs(t.height,e.maxHeight),s=Re.insetBounds(n,o,r);return{width:s.width,height:s.height,hugWidth:t.width==="hug",hugHeight:t.height==="hug"}}function Bg(t,e,r,n){let o=Re.outsetSize(n.width,n.height,r);return{width:t.width==="hug"?o.width:xs(t.width,e.maxWidth),height:t.height==="hug"?o.height:xs(t.height,e.maxHeight)}}function Lg(t,e){if(t.mode!=="horizontal"&&t.mode!=="vertical"||(t.mode==="horizontal"?e.width:e.height)>0)return null;let r=t.sizes.filter(n=>n.width>0||n.height>0).length;return r===0?null:`is laying out ${r} sized child${r===1?"":"ren"} in a run of length 0 (${e.width}\xD7${e.height}, ${t.mode}). They will be positioned from its centre rather than its leading edge.`}function Wg(t,e,r){let n=typeof t=="string"?t:t.to,o=typeof e=="string"?e:e.to;return r>=1||n===o?o:{from:n,to:o,t:r}}function Na(t,e,r,n,o){if(t==="freeform")return{mode:t,items:r,space:n,...ff(r,n,o)};if(t==="grid"){let a=pf(r,e.columns??1,Sf(e),$a(e),n,o);return{mode:t,items:r,space:n,...a}}let s=t==="horizontal",i=e.wrap?cf(r,s,e.gap??0,$a(e),n,o):af(r,s,e.gap??0,n,o);return{mode:t,items:r,space:n,...i}}function yf(t,e,r){if(t.mode==="grid")return hf(t.cells??[],r);let n=vf(e);return t.mode==="freeform"?Ia(t.sizes,r,n):df(t.sizes,t.lines??[],t.gapScales??[],t.mode==="horizontal",e.gap??0,$a(e),n,r)}function qg(t,e,r){return(t.flow??"freeform")!=="freeform"?null:Ia([r],e,vf(t))[0]}function vf(t){let e=t.align;return e===void 0?zg:typeof e=="string"?Q.resolve(e):e}function Sf(t){let e=t.gap??0;return e==="auto"?0:e}function $a(t){return t.crossGap??Sf(t)}function xs(t,e){let r=e??0;return t==="hug"?r:ce.resolveLayout(t,r,0)}function Vg(t,e,r){return{width:m(t.width,e.width,r),height:m(t.height,e.height,r)}}function gf(t,e,r,n){return xf(t,e)||r===!0&&xf(t,n)}function xf(t,e){return t===e?!0:!Number.isFinite(t)||!Number.isFinite(e)?!1:Math.abs(t-e)<=1e-6*Math.max(1,Math.abs(t),Math.abs(e))}var Ge={resolve:t=>t,lerp:Wg,arrange:Ng,measure:_f,place:wf,reusable:$g,freeSlot:qg,contentBox:jg,size:Bg,collapsedRun:Lg};var bf={x:0,y:0,z:0};function de(t){if(t===void 0)return{...bf};if(typeof t=="number")return{x:t,y:t,z:t};if(Array.isArray(t))return{x:t[0]??0,y:t[1]??0,z:t[2]??0};let e=t;return{x:e.x??0,y:e.y??0,z:e.z??0}}function dn(t,e,r){return{x:m(t.x,e.x,r),y:m(t.y,e.y,r),z:m(t.z,e.z,r)}}var _s={resolve:t=>de(t),lerp:dn};function kf(t){return t===void 0?void 0:de(t)}function Af(t,e,r,n){return e===void 0?t:t!==void 0?dn(t,e,r):n==="origin"?dn(bf,e,r):r>=1?e:t}function Mf(t,e,r){return{x:m(t.x,e.x,r),y:m(t.y,e.y,r),z:m(t.z,e.z,r),order:r<.5?t.order:e.order}}var ws={resolve:t=>{let e=de(t),r=t?.order;return r?{...e,order:r}:e},lerp:Mf},Of={x:0,y:0,z:0,w:1};function Ef(t,e,r){let{x:n,y:o,z:s,w:i}=e,a=t.x*n+t.y*o+t.z*s+t.w*i;if(a<0&&(n=-n,o=-o,s=-s,i=-i,a=-a),a>.9995)return Cf({x:m(t.x,n,r),y:m(t.y,o,r),z:m(t.z,s,r),w:m(t.w,i,r)});let l=Math.acos(a),c=Math.sin(l),d=Math.sin((1-r)*l)/c,u=Math.sin(r*l)/c;return{x:t.x*d+n*u,y:t.y*d+o*u,z:t.z*d+s*u,w:t.w*d+i*u}}function Cf(t){let e=Math.hypot(t.x,t.y,t.z,t.w);return e===0?{...Of}:{x:t.x/e,y:t.y/e,z:t.z/e,w:t.w/e}}function ja(t){let e=Math.PI/360,r=Math.cos(t.x*e),n=Math.sin(t.x*e),o=Math.cos(t.y*e),s=Math.sin(t.y*e),i=Math.cos(t.z*e),a=Math.sin(t.z*e);switch(t.order??"XYZ"){case"YXZ":return{x:n*o*i+r*s*a,y:r*s*i-n*o*a,z:r*o*a-n*s*i,w:r*o*i+n*s*a};case"ZXY":return{x:n*o*i-r*s*a,y:r*s*i+n*o*a,z:r*o*a+n*s*i,w:r*o*i-n*s*a};case"ZYX":return{x:n*o*i-r*s*a,y:r*s*i+n*o*a,z:r*o*a-n*s*i,w:r*o*i+n*s*a};case"YZX":return{x:n*o*i+r*s*a,y:r*s*i+n*o*a,z:r*o*a-n*s*i,w:r*o*i-n*s*a};case"XZY":return{x:n*o*i-r*s*a,y:r*s*i-n*o*a,z:r*o*a+n*s*i,w:r*o*i+n*s*a};default:return{x:n*o*i+r*s*a,y:r*s*i-n*o*a,z:r*o*a+n*s*i,w:r*o*i-n*s*a}}}var Ba={resolve:t=>t,lerp:Ef};function ue(t,e,r,n){return o=>p({default:o&&"default"in o?o.default:t(),mapper:o?.mapper??e,tween:o?.tween??r,...o?.kind??n?{kind:o?.kind??n}:{}})}var er=ue(()=>[],q.resolve,q.lerp,"fills"),La=ue(()=>[],_e.resolve,_e.lerp,"strokes"),Wa=ue(()=>[],mt.resolve,mt.lerp,"shadows"),qa=ue(()=>[],Zr.resolve,Zr.lerp,"effects"),Ye=ue(()=>"black",jo.resolve,jo.lerp,"color"),eo=ue(()=>0,vr.resolve,vr.lerp,"cornerRadius"),to=ue(()=>"rounded",zo.resolve,zo.lerp,"cornerStyle"),ro=ue(()=>"",void 0,be.lerp,"path"),no=ue(()=>0,Re.resolve,Re.lerp,"insets"),Rt=ue(()=>"center",Q.resolve,Q.lerp,"alignment"),vs=ue(()=>"freeform",void 0,Ge.lerp),Gg=ue(()=>({x:0,y:0}),void 0,qi.lerp,"vector2"),Yg=ue(()=>"fill",void 0,ce.lerp,"size"),Va=ue(()=>"",void 0,oe.lerp,"text"),uE=ue(()=>({x:0,y:0,z:0}),_s.resolve,_s.lerp,"vector3");function Cr(t){return p({default:void 0,mapper:kf,tween:(e,r,n)=>Af(e,r,n,t),kind:"vector3"})}var fE=ue(()=>({x:0,y:0,z:0}),ws.resolve,ws.lerp,"euler3"),Pf=ue(()=>({x:0,y:0,z:0,w:1}),void 0,Ba.lerp,"quaternion"),Ga=ue(()=>0,void 0,va.lerp,"audioParam"),Tf=ue(()=>[],cs.resolve,cs.lerp,"audioFilters");var Kg=new Set(["number","slider","angle","hue","boolean","color","vector","point"]);function hE(t){return Kg.has(t.kind)}var Df=64,Rf=64e3;function Ff(t){if(typeof t!="object"||t===null)throw new Error("A shader pack must be an object.");let e=t,r=e.scope;if(r!=="fill"&&r!=="effect")throw new Error(`A shader pack needs scope "fill" or "effect", got ${JSON.stringify(r)}. The two are written against different contracts \u2014 a fill has no backdrop to sample and an effect has no shape box to map coordinates onto.`);let n=typeof e.source=="string"?e.source.trim():"";if(n==="")throw new Error(`Shader pack "${String(e.name??"?")}" has no source.`);if(n.length>Rf)throw new Error(`Shader pack "${String(e.name??"?")}" source is ${n.length} characters, over the ${Rf} ceiling.`);let o={...typeof e.$kind=="string"?{$kind:e.$kind}:{},...typeof e.id=="string"?{id:e.id}:{},name:typeof e.name=="string"&&e.name!==""?e.name:"Shader",...typeof e.description=="string"?{description:e.description}:{},source:n,...bs(e.uniforms)?{uniforms:e.uniforms}:{},properties:Hg(e.properties,String(e.name??"?"))};if(r==="fill"){let s=e.coords;return{...o,scope:"fill",...s==="normalized"||s==="centered"||s==="local"?{coords:s}:{}}}return{...o,scope:"effect",...e.backdrop===!0?{backdrop:!0}:{}}}function Hg(t,e){if(!bs(t))return{};let r={},n=new Map;for(let[o,s]of Object.entries(t)){if(Object.keys(r).length>=Df){oo(`shader "${e}" declares more than ${Df} properties; the rest are ignored.`);break}if(!bs(s)||typeof s.kind!="string"){oo(`shader "${e}" property "${o}" has no kind; ignored.`);continue}let i=s.inputs;if(!bs(i)||Object.keys(i).length===0){oo(`shader "${e}" property "${o}" names no uniform in "inputs"; ignored.`);continue}let a=!1;for(let l of Object.values(i)){if(typeof l!="string"){oo(`shader "${e}" property "${o}" has a non-string uniform name; ignored.`),a=!0;break}let c=n.get(l);if(c!==void 0){oo(`shader "${e}" properties "${c}" and "${o}" both write uniform "${l}"; "${o}" ignored.`),a=!0;break}n.set(l,o)}a||(r[o]=s)}return r}function bs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Ss=new Set;function oo(t){Ss.has(t)||(Ss.size>256&&Ss.clear(),Ss.add(t),console.warn(`[shader] ${t}`))}var L=null;function so(t){let e=L;return L=t,e}var Ke=class{_host;_name;_value;_fn=null;_running=!1;constructor(e,r=null,n=""){this._host=r,this._name=n,this._value=e}get(){if(L!==null&&L.read(this),!this._fn||this._running)return this._value;this._running=!0;try{return this._value=this._fn()}finally{this._running=!1}}set(e){L!==null&&L.write(this),this._fn=null,this._value=e}bind(e){L!==null&&L.write(this),this._fn=e}unbind(){this._fn&&(L!==null&&L.write(this),this._value=this.get(),this._fn=null)}isBound(){return this._fn!==null}snapshot(){return this._fn?{value:this.get(),fn:this._fn}:{value:this._value}}restoreFrom(e){e.fn?this.bind(e.fn):this.set(e.value)}dispose(){this._fn=null,this._value=void 0}};var Ya=class{target;props;duration;easing;atPrepared=null;constructor(e,r,n,o){this.target=e,this.props=r,this.duration=n,this.easing=o}at(e){return this.atPrepared||(this.atPrepared=this.prepare()),this.atPrepared.seek(pt(e)*this.duration),{}}_stepper(){return this.prepare()}prepare(){return this.target._prepareStep(this.props,this.duration,this.easing)}};function ks(t,e,r,n){return new Ya(t,e,r,n)}function jE(t,e){let r=Object.keys(e).filter(s=>e[s]!==void 0),n=new Array(r.length),o=new Array(r.length);for(let s=0;s<r.length;s++)n[s]=t[r[s]],o[s]=e[r[s]];return s=>{for(let i=0;i<r.length;i++)t[r[i]]=n[i]+(o[i]-n[i])*s}}function If(t,e,r){return n=>{for(let o=0;o<t.length;o++)t[o].set(e[o]+(r[o]-e[o])*n)}}function io(t,e){return{id:Symbol(e??"context"),defaultValue:t,name:e}}var Pr=class t{entries;constructor(e){this.entries=e}static EMPTY=new t(new Map);with(e,r){let n=new Map(this.entries);return n.set(e.id,r),new t(n)}get(e){return this.entries.has(e.id)?this.entries.get(e.id):e.defaultValue}};function WE(t,e){return t.__cells?.slots.get(e)}function As(t){return t.__cells??={slots:new Map}}var Tr=Symbol("commandMeta");function Ms(t){return Fa(t,Tr)}function P(t){return function(e,r){let n=r,o=t?.key??n;Object.prototype.hasOwnProperty.call(e,Tr)||(e[Tr]=[]);let s=e[Tr];s.some(i=>i.key===o)||s.push({key:o,method:n,...t?.name?{name:t.name}:{},...t?.args?{args:t.args}:{}})}}var tr="layoutBounds",Os="var:",rr="presence:",Ft="structure";function It(t,e){let r=so(t);try{return e()}finally{so(r)}}function Es(t){let e=so(null);try{return t()}finally{so(e)}}function ao(t){return t._host?`${t._host.id}.${t._name}`:t._name}function zf(t,e){return{duration:e,at:()=>({}),_stepper:()=>Ka(e)}}function Ka(t){let e=0;return{seek:r=>{e=r},advance:r=>(e+=r,e>=t)}}function Ug(t,e,r){let n=new Ke(void 0,t,e),o=As(t);o.slots.set(e,n),r?.tween&&(o.tweens??=new Map).set(e,r.tween),r?.mapper&&(o.mappers??=new Map).set(e,r.mapper),Object.defineProperty(t,e,{get:()=>n.get(),set:s=>t._writeProp(e,s),enumerable:!0,configurable:!0})}function Nf(t,e,r,n){t.__cells?.slots.get(e)?n&&(n.tween&&(As(t).tweens??=new Map).set(e,n.tween),n.mapper&&(As(t).mappers??=new Map).set(e,n.mapper)):Ug(t,e,n),t._writeProp(e,r)}function $f(t){let e={};if(t.__cells)for(let r of t.__cells.slots.keys())e[r]=t[r];return e}function Cs(t){let e=new Map,r=t.__cells?.slots;if(!r)return e;for(let[n,o]of r)e.set(n,o.snapshot());return e}function jf(t){t.__cells&&t._stateStack.push(Cs(t))}function Bf(t){return t._stateStack.pop()}function Dr(t,e){let r=t.__cells?.slots;if(r)for(let[n,o]of e)r.get(n)?.restoreFrom(o)}function Lf(t,e,r,n){let o=null;return We(r,s=>{if(!o){let i={};if(e)for(let[a,l]of e)i[a]=l.value;o=t._prepareStep(i,r)}o.seek(s*r),e&&s>=1&&Dr(t,e)},n)}function Wf(){return{total:0,creation:0,elapsed:0,started:!1}}function qf(t,e){t.started||(t.creation=e,t.started=!0),t.total=e,t.elapsed=e-t.creation}var Ha=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Xg={"2d":"2D nodes go in the 2D tree, or inside a <Canvas3D> as a HUD over its scene.","3d":"Put 3D nodes inside a <Canvas3D>, which is the one node that holds both.",audio:"Put audio nodes under an <AudioBus>, or directly on the scene root."};function Zg(t){let e=t.options?.mapper,r=typeof t.default=="function"?t.default():t.default,n=r===void 0||!e?r:e(r,void 0);return{...t.options,mapper:()=>n}}var he=class t{constructor(e){this._props=e;let r=e;this.key=r?.key,this.id=r?.id??crypto.randomUUID()}key;_hidden=!1;_locked=!1;get hidden(){return this._hidden}get locked(){return this._locked}_setEditorState(e,r){this._hidden=e,this._locked=r}initProps(e){e?.ref&&e.ref(this);for(let r of Qt(this)){if(r.withdrawn){this.applyProp(r.key,r.default,Zg(r));continue}let n=e?e[r.key]:void 0,o=n!==void 0?n:r.default;this.applyProp(r.key,o,r.options)}}adoptChildrenProp(e){if(e&&e.children){let n=(Array.isArray(e.children)?e.children:[e.children]).flat(1/0).filter(o=>o instanceof t);n.length>0&&this._addChildren(n)}}acceptsChild(e){return e.dimension===this.dimension}assertAcceptsChild(e){if(!this.acceptsChild(e))throw new TypeError(`${this.className} (${this.dimension}) cannot hold ${e.className} (${e.dimension}). ${Xg[e.dimension]}`)}_assets=null;_parent=null;_mounted=!1;get mounted(){return this._mounted}get parent(){return L!==null&&L.read(this._structureSlot()),this._parent}get assets(){if(!this._assets)throw new Error("Assets not bound \u2014 this node is not attached to a scene. See Node.attach().");return this._assets}_context=Pr.EMPTY;_contextBound=!1;_props;useContext(e){return this._context.get(e)}id;__cells;_children=[];static flattenChildrenProp(e){let r=e?e.children:void 0;return r?(Array.isArray(r)?r:[r]).flat(1/0).filter(o=>o instanceof t):[]}applyProp(e,r,n){Nf(this,e,r,n)}_writeProp(e,r){if(r===void 0)return;let n=this.__cells?.slots.get(e);if(!n)return;let o=this.__cells?.mappers?.get(e);if(typeof r=="function"){let s=r;if(o){let i;n.bind(()=>{let a=s();return a===void 0?(i??={value:this._unsetValue(e,o)}).value:o(a,n.get())})}else n.bind(s)}else n.set(o?o(r,n.get()):r)}get properties(){return $f(this)}get className(){return this.constructor.name}set(e){let r=this.__cells?.slots;if(r)for(let n in e){let o=e[n];o!==void 0&&r.has(n)&&this._writeProp(n,o)}}to(e){return ks(this,e.data??{},e.duration,e.easing)}command(e,r=1,n){return this._mounted?wc(this,e,r,n):zf(this,r)}_prepareStep(e,r,n){if(!this._mounted)return Ka(r);let o=[],s=[],i=[],a=[],l=[];for(let y of Object.keys(e)){let w=this.__cells?.slots.get(y);if(!w)continue;let g=e[y],x=this.__cells?.mappers?.get(y),_=x?x(g,this[y]):g,S=this.__cells?.tweens?.get(y);if(S){let b=this[y];a.push(k=>{w.set(S(b,_,k))})}else typeof _=="number"?(o.push(w),s.push(this[y]),i.push(_)):typeof _=="string"&&l.push([w,_])}let c=If(o,s,i),d=a.length>0,u=l.length>0,f=y=>{let w=n?n(y):y;if(c(w),d)for(let g of a)g(w);if(u&&y>=1)for(let[g,x]of l)g.set(x)},h=0;return{seek:y=>{h=y,f(r>0?Math.min(y/r,1):1)},advance:y=>(h+=y,h<r?(f(h/r),!1):(f(1),!0))}}_unsetValue(e,r){let n=Qt(this).find(s=>s.key===e)?.default,o=typeof n=="function"?n():n;return o===void 0?void 0:r(o,void 0)}_stateStack=[];save(){jf(this)}restore(e){let r=Bf(this),n=e?.duration;if(n===void 0||n<=0){r&&Dr(this,r);return}return Lf(this,r,n,e?.easing)}_time=Wf();tick(){}get time(){return L!==null&&L.clock?.(this),this._time}_advanceOwnTime(e){qf(this._time,e),this.tick(),this._sample()}_sample(){}_primeMotion(e){}attach(e){let r=!this._mounted;this._mounted=!0,this._assets!==e.assets&&(this._assets=e.assets);let n=this.provideContext(e.context);if((!this._contextBound||this._context!==n)&&(this._context=n,this._contextBound=!0),r&&this.resolveContext(n),this._advanceOwnTime(e.time),this._children.length===0)return;let s=n===e.context?e:{...e,context:n};for(let i of this._children)i.attach(s)}detach(){if(this._mounted){this._mounted=!1;for(let e of this._children)e.detach()}}_currentScope(){return this._assets&&this._contextBound?{assets:this._assets,context:this._context,time:this._time.total}:null}_attachChild(e){if(!this._mounted)return;let r=this._currentScope();r&&e.attach(r)}resolveContext(e){}provideContext(e){return e}attachDetached(e){let r=this._currentScope();r&&e.attach(r)}declareAssets(e){}declareAudio(e){}get children(){return L!==null&&L.read(this._structureSlot()),this._children}get _allChildren(){return L!==null&&L.read(this._structureSlot()),this._children}add(e){if(e instanceof t){this._addChild(e);return}let r=t.flattenChildrenProp({children:e});r.length>0&&this._addChildren(r)}remove(e){if(e instanceof t){this._removeChild(e);return}for(let r of t.flattenChildrenProp({children:e}))this._removeChild(r)}clear(){for(let e of this._children)L!==null&&this._structureChanged(e),e._parent=null,e.detach();this._children.length=0}addChildAt(e){let{child:r,index:n}=e.data;this.assertAcceptsChild(r),this._insertChildAt(r,n)}_insertChildAt(e,r){L!==null&&this._structureChanged(e),this._children.splice(r,0,e),e._parent=this,this._attachChild(e)}_structureSlot(){return this._structure??=new Ke(null,this,Ft)}_structureChanged(e){L.write(this._structureSlot()),e&&L.write(e._structureSlot())}_structure=null;_addChild(e){this.assertAcceptsChild(e),L!==null&&this._structureChanged(e),this._children.push(e),e._parent=this,this._attachChild(e)}_addChildren(e){for(let r of e)this.assertAcceptsChild(r);if(L!==null)for(let r of e)this._structureChanged(r);this._children.push(...e);for(let r of e)r._parent=this;for(let r of e)this._attachChild(r)}_removeChild(e){let r=this._children.indexOf(e);if(r<0)return;L!==null&&this._structureChanged(e);let[n]=this._children.splice(r,1);n&&(n._parent=null,n.detach())}dispose(){if(this.__cells)for(let e of this.__cells.slots.values())e.dispose();this.__cells=void 0,this._assets=null,this._mounted=!1,this._context=Pr.EMPTY,this._contextBound=!1}};Ha([P()],he.prototype,"to",null);Ha([P()],he.prototype,"restore",null);Ha([P({args:["child","index"]})],he.prototype,"addChildAt",null);var un=class extends Error{assetType;src;nodeId;constructor(e,r,n){super(`${e} asset "${r}" is not loaded. `+(n??Jg(e))),this.name="AssetNotLoadedError",this.assetType=e,this.src=r}};function Jg(t){return`Declare it from the node's ${t==="audio"?"declareAudio()":`declareAssets() (e.g. assets.${t}(...))`}, so the asset timeline loads it before this frame draws.`}var se=class{_ops=[];rect(e){return this._ops.push({kind:"rect",state:e}),this}ellipse(e){return this._ops.push({kind:"ellipse",state:e}),this}path(e){let r=e instanceof Je?e.toPathState():e;return this._ops.push({kind:"path",state:r}),this}line(e){return this._ops.push({kind:"line",state:e}),this}polygon(e){return this._ops.push({kind:"polygon",state:e}),this}polygram(e){return this._ops.push({kind:"polygram",state:e}),this}cut(){return this._ops.push({kind:"cut"}),this}ops(){return this._ops}isEmpty(){return!this._ops.some(e=>e.kind!=="cut")}};function Vf(t,e,r,n,o,s){t.prevPos?(t.prevPos.x=e,t.prevPos.y=r):t.prevPos={x:e,y:r},t.prevTime=s,t.prevRotation=n,t.prevScale=o}function Gf(){return{prevPos:null,prevTime:0,prevRotation:0,prevScale:1}}function Yf(t,e,r,n,o,s,i){let a=i-e.prevTime,l=e.prevPos;if(l&&a>0&&a<=.2){let c=(r-l.x)/a,d=(n-l.y)/a;t.dt=a,t.velocity.x=c,t.velocity.y=d,t.speed=Math.hypot(c,d),t.direction=Math.atan2(d,c)*180/Math.PI,t.angularVelocity=(o-e.prevRotation)/a,t.scaleVelocity=(s-e.prevScale)/a}else t.dt=0,t.velocity.x=0,t.velocity.y=0,t.speed=0,t.direction=0,t.angularVelocity=0,t.scaleVelocity=0;l?(l.x=r,l.y=n):e.prevPos={x:r,y:n},e.prevTime=i,e.prevRotation=o,e.prevScale=s}function Qg(t,e){let r=t.lastMeasure,n=r?.measurer;if(!n)return null;let o=r?.constraints??{maxWidth:t.measuredWidth||Number.MAX_SAFE_INTEGER,maxHeight:t.measuredHeight||Number.MAX_SAFE_INTEGER},s=e.measure(o,n);return{width:s.width??0,height:s.height??0}}var Ps=.7;function Kf(t,e,r,n,o){let s=null,i=!1,a=!1,l,c,d=()=>{let u=e.opacity;l=e.width,c=e.height,i=typeof l=="number",a=typeof c=="number";let f=i&&a?null:Qg(t,e),h=i||f!==null,y=a||f!==null,w=i?l:f?.width??0,g=a?c:f?.height??0;e.set({opacity:0,gapScale:0,...h?{width:0}:{},...y?{height:0}:{}}),t.addChildAt({data:{child:e,index:r}});let x={};h&&(x.width=w),y&&(x.height=g);let _=n*Ps,S=n-_;return Io(e,Dn(e,e.to({data:x,duration:_,easing:o}),e.to({data:{gapScale:1},duration:_,easing:o})),e.to({data:{opacity:u},duration:S,easing:o}))};return We(n,u=>{if(s||(s=d()),s.at(u),u>=1){let f={};i||(f.width=l),a||(f.height=c),(!i||!a)&&e.set(f)}})}function Hf(t,e,r,n){let o=null,s=null,i=!1,a=()=>{if(i=!0,e<0||e>=t.children.length)return;o=t.children[e];let l=o.measuredWidth,c=o.measuredHeight;o.set({width:l,height:c});let d=r*(1-Ps),u=r-d;s=Io(o,o.to({data:{opacity:0},duration:d,easing:n}),Dn(o,o.to({data:{width:0,height:0},duration:u,easing:n}),o.to({data:{gapScale:0},duration:u,easing:n})))};return We(r,l=>{if(i||a(),!s||!o)return;let c=l>=1;!c&&o.parent!==t&&t.addChildAt({data:{child:o,index:Math.min(e,t.children.length)}}),s.at(l),c&&(t.remove(o),o.set({gapScale:1}))})}function Uf(t,e,r,n){let o=r/2,s=null,i=null,a=()=>{let l=t.opacity;i=t.parent;let c=t.measuredWidth,d=t.measuredHeight;t.set({width:c,height:d});let u=o*(1-Ps),f=o-u,h=o*Ps,y=o-h;return Io(t,t.to({data:{opacity:0},duration:u,easing:n}),Dn(t,t.to({data:{width:0,height:0},duration:f,easing:n}),t.to({data:{gapScale:0},duration:f,easing:n})),Dn(t,t.to({data:{width:c,height:d},duration:h,easing:n}),t.to({data:{gapScale:1},duration:h,easing:n})),t.to({data:{opacity:l},duration:y,easing:n}))};return We(r,l=>{s||(s=a());let d=l*r>=o;d&&t.parent!==e?(i&&i.remove(t),e.add(t)):!d&&t.parent!==i&&(e.remove(t),i&&i.add(t)),s.at(l)})}var ex=[["rotationX","rotationX"],["rotationY","rotationY"],["rotationZ","rotationZ"],["depth","depth"],["perspective","perspective"],["backfaceVisible","backfaceVisible"],["flipHorizontal","flipHorizontal"],["flipVertical","flipVertical"],["origin","transformOrigin"]];function Ts(t){let e=t.transform3D;if(e==null||typeof e!="object")return;let r=e;for(let[n,o]of ex){let s=r[n];s!==void 0&&t[o]===void 0&&(t[o]=s)}}function Ua(t,e,r,n,o){if(r===0)return{x:t+n,y:e+o};let s=r*Math.PI/180,i=Math.cos(s),a=Math.sin(s);return{x:t+i*n+a*o,y:e-a*n+i*o}}function Rr(t,e,r,n,o,s,i,a=Mr){let l=o.x*(s/2),c=-o.y*(i/2);return Ca(t,e,r,n,l,c,a)}function fn(t,e,r){let n=(o,s)=>{let i=ee(t,{x:o,y:-s});return{x:i.x,y:-i.y}};return{center:n(0,0),topLeft:n(-e,r),topRight:n(e,r),bottomLeft:n(-e,-r),bottomRight:n(e,-r),topCenter:n(0,r),bottomCenter:n(0,-r),centerLeft:n(-e,0),centerRight:n(e,0)}}var Ds=Ma();function nr(t,e){let r=fs(e);return{root:t,camera:e,view:r,screen:Qn(e,r),pushed:Ds,local:Ds,flat:!0,plane:Ta(r,{x:0,y:0,width:0,height:0}),paints:!1,facesAway:!1,nearCut:null}}function pn(t,e){let r=e._spaceMatrix(),n=Or(t.view,r),o=t.camera,s=Qn(o,n),i=tx(e),a=Ta(n,i),{side:l,edgeOn:c}=ps(o,a),d=Qu(o,a),u=Ds,f=!c&&d!=="none";if(f)if(t.pushed===Ds)u=s;else{let h=Ie(t.pushed);h?u=we(h,s):f=!1}return{root:t.root,camera:o,view:n,screen:s,pushed:f?s:t.pushed,local:u,flat:r[2]===0&&r[6]===0&&r[8]===0&&r[9]===0&&r[11]===0,plane:a,paints:f,facesAway:!c&&l<0,nearCut:f&&d==="some"?nx(s,i):null}}function lo(t){let e=[];for(let r=t.parent;r;r=r.parent){let n=r._spaceCamera();if(n){let o=nr(r,n);for(let s=e.length-1;s>=0;s--)o=pn(o,e[s]);return pn(o,t)}if(!r._rendersChildrenInSpace())return null;e.push(r)}return null}function Xa(t){let e=t._spaceCamera();return e?nr(t,e):t._rendersChildrenInSpace()?lo(t):null}function Rs(t){return t.length<2||t.every(e=>e.flat)?t.map((e,r)=>r):tf(t[0].camera,t.map(e=>e.plane))}function tx(t){let e=t._localBounds();return{x:e.x,y:-e.y,width:e.width,height:e.height}}var rx=128;function nx(t,e){let r=ef(t,e,Math.max(e.width,e.height)/2+rx);if(!r)return null;let n=new Je().moveTo(r[0].x,-r[0].y);for(let s=1;s<r.length;s++)n.lineTo(r[s].x,-r[s].y);let o=Math.max(...r.map(s=>Math.max(Math.abs(s.x),Math.abs(s.y))));return new se().path(n.close().toPathState({centerBounds:[-o,-o,o,o]}))}function Xf(t,e,r,n){if(!t)return{};let o=e.x+r,s=e.y-n;return{parent:{left:-t.width/2-o,top:-t.height/2-s,right:t.width/2-o,bottom:t.height/2-s}}}function Zf(t,e,r,n,o){let s=Hi(e);s.length!==0&&(!r||r.isEmpty()||(t.beginClip(r),t.beginEffects(s,"backdrop",n,o),t.endEffects(),t.endClip()))}function Jf(t,e,r,n,o,s){let i=Ui(e),a=i.length>0;a&&t.beginEffects(i,"foreground",n,o);let l=r!=null&&!r.isEmpty();l&&t.beginClip(r),s(),l&&t.endClip(),a&&t.endEffects()}var $=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},ox={},Za={x:0,y:0},sx=[],Fs={rotationX:0,rotationY:0,rotationZ:0,depth:0,perspective:0,flipHorizontal:!1,flipVertical:!1};function Qf(t){return Fs.rotationX=t.rotationX,Fs.rotationY=t.rotationY,Fs.depth=t.depth,Fs}var ix=Object.freeze({}),ax={width:0,height:0},A=class t extends he{get dimension(){return"2d"}get parent2D(){let e=this._parent;return e instanceof t?e:null}get parent(){return L!==null&&L.read(this._structureSlot()),this.parent2D}get children(){L!==null&&L.read(this._structureSlot());let e=this._children;for(let r=0;r<e.length;r++)if(!(e[r]instanceof t))return e.filter(n=>n instanceof t);return e}constructor(e){if(super(e),e&&(ms.expand(e),Ts(e)),this.initProps(e),e&&e.flex!==void 0?(e.width===void 0&&this.applyProp("width","fill",{tween:ce.lerp}),e.height===void 0&&this.applyProp("height","fill",{tween:ce.lerp})):this.applyDefaultSize(e),e){Q.validateProps(e);let r=Q.findKey(e);if(r){let n=e[r],o=typeof n=="function"?n:()=>n,{pivot:s,x:i,y:a}=Q.bindTarget(r,o,()=>this._layoutBounds.get());this._writeProp("pivot",s),this._writeProp("x",i),this._writeProp("y",a)}}this.adoptChildrenProp(e)}set(e){let r=e.size;e.transform3D!==void 0&&(e={...e},Ts(e)),super.set(e),r!==void 0&&(e.width===void 0&&this._writeProp("width",r),e.height===void 0&&this._writeProp("height",r))}_prepareStep(e,r,n){ms.expand(e),Ts(e);let o=e.pivot;o!==void 0&&delete e.pivot,Q.validateProps(e);let s=Q.findKey(e);if(s){let i=e[s],{pivot:a,x:l,y:c}=Q.resolveTargetOnce(s,this._layoutBounds.get(),i);this._writeProp("transformOrigin",o!==void 0?Q.resolve(o):a),e.x=l,e.y=c}else o!==void 0&&this._writeProp("transformOrigin",Q.resolve(o));return super._prepareStep(e,r,n)}declareAssets(e){e.effects(this.effects)}_sample(){this._sampleMotion()}_primeMotion(e){let r=this.layoutBounds,n=this._offset();Vf(this._motionHistory,(r?.x??0)+n.x,(r?.y??0)-n.y,this.rotation,this.scale,e)}_layoutBounds=new Ke({x:0,y:0,width:0,height:0},this,tr);lastMeasure;get constraints(){return this.lastMeasure?.constraints??{}}get layoutBounds(){return this._layoutBounds.get()}static flowChildrenProp(e){return t.flattenChildrenProp(e).filter(r=>r instanceof t)}static hasFillChild(e,r){return e.some(n=>(r==="width"?n.width:n.height)==="fill")}applyDefaultSize(e){let n=t.flowChildrenProp(e).length>0?"hug":"fill";(!e||e.width===void 0)&&this.applyProp("width",n,{tween:ce.lerp}),(!e||e.height===void 0)&&this.applyProp("height",n,{tween:ce.lerp})}moveTo(e){let{path:r,target:n,targetAnchor:o,...s}=e.data??{},i=s.x!==void 0||s.y!==void 0,a=typeof n=="string"&&n!=="";if(a&&i)throw new Error("moveTo takes a `target` or an `x`/`y` destination, not both \u2014 the target's anchor is where the move ends.");let l=a?this._pointOnNode(n,o):null;if(r==null)return this.to({data:{...s,...l},duration:e.duration,easing:e.easing});if(i)throw new Error("moveTo takes a `path` or an `x`/`y` destination, not both \u2014 the path's own end is where the move ends.");let c=be.sampler(r instanceof Je?r.toCommands():r),{length:d}=c,u=c.frameAt(0),f=c.frameAt(d),h=l&&u&&f?be.endFit(u,f,l):null,y=s.pivot;return this.command(w=>{let g=c.frameAt(d*w);if(!g)return{};let x=h?h(g):g,_={x:x.x,y:x.y};return y!==void 0&&(_.transformOrigin=y),_},e.duration,e.easing)}fadeTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}rotateTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}scaleTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}layoutTo(e){return this.to({data:ep(e.data),duration:e.duration,easing:e.easing})}pulse(e){let r=this.scale,n=e.data?.factor??1.2;return this.command(o=>({scale:r*(1+(n-1)*Math.sin(Math.PI*o))}),e.duration,e.easing)}wiggle(e){let r=this.rotation,n=e.data?.angle??8,o=e.data?.turns??3;return this.command(s=>({rotation:r+n*Math.sin(2*Math.PI*o*s)*Math.sin(Math.PI*s)}),e.duration,e.easing)}effectTo(e){return this.to({data:ep(e.data),duration:e.duration,easing:e.easing})}get measuredWidth(){return this.layoutBounds.width}get measuredHeight(){return this.layoutBounds.height}_rotateOffset(e,r){let n=this._offset();return Ua(n.x,n.y,this.rotation,e,r)}get center(){let e=this._offset();return{x:e.x,y:e.y}}get topLeft(){let e=this.layoutBounds;return this._rotateOffset(-e.width/2,e.height/2)}get topRight(){let e=this.layoutBounds;return this._rotateOffset(e.width/2,e.height/2)}get bottomLeft(){let e=this.layoutBounds;return this._rotateOffset(-e.width/2,-e.height/2)}get bottomRight(){let e=this.layoutBounds;return this._rotateOffset(e.width/2,-e.height/2)}get topCenter(){let e=this.layoutBounds;return this._rotateOffset(0,e.height/2)}get bottomCenter(){let e=this.layoutBounds;return this._rotateOffset(0,-e.height/2)}get centerLeft(){let e=this.layoutBounds;return this._rotateOffset(-e.width/2,0)}get centerRight(){let e=this.layoutBounds;return this._rotateOffset(e.width/2,0)}_localMatrix(){let e=this.layoutBounds,r=this._slotMatrix(),{x:n,y:o}=this._offset();if(r)return we(r,Rr(n,-o,this.rotation,this.scale,this._transformOrigin(),e?.width??0,e?.height??0));let s=(e?.x??0)+n,i=(e?.y??0)-o;return Rr(s,i,this.rotation,this.scale,this._transformOrigin(),e?.width??0,e?.height??0)}_placement(){return this.parent2D?._placementOf(this)??null}_placementOf(e){return null}_planeOf(e){return null}_slotFor(e){let r=this._childBox,n=r?Ge.freeSlot(this.flowArrangement(),r,e):null;return r&&n?{x:r.x+n.x,y:r.y-n.y}:null}_centreShift(e=this.rotation,r=this.scale){let n=this.layoutBounds,o=Rr(0,0,e,r,this._transformOrigin(),n?.width??0,n?.height??0);return ee(o,{x:0,y:0})}_handles(){return sx}_handleValue(e,r){return null}_offsetScratch={x:0,y:0};_offset(){let e=this.parent2D?._planeOf(this);if(e)return e.toOffset(this.x,this.y);let r=this._offsetScratch;return r.x=this.x,r.y=this.y,r}_slotMatrix(e=!1){let r=this._placement();if(!r)return null;let n=this.layoutBounds;return Rr(n?.x??0,n?.y??0,r.rotation,r.scale,Za,0,0,e?Qf(r):void 0)}_slotAffine(){let e=this._placement();if(!e)return null;let r=this.layoutBounds;return hs(r?.x??0,r?.y??0,e.rotation,e.scale,0,0,Qf(e))}_transformOrigin(){return this.transformOrigin??this.pivot}_projectionScratch={rotationX:0,rotationY:0,rotationZ:0,depth:0,perspective:0,flipHorizontal:!1,flipVertical:!1};_projection(){let e=this._projectionScratch;return e.rotationX=this.rotationX,e.rotationY=this.rotationY,e.rotationZ=this.rotationZ,e.depth=this.depth,e.perspective=this.perspective,e.flipHorizontal=this.flipHorizontal,e.flipVertical=this.flipVertical,e}_spaceMatrix(){let e=this.layoutBounds,r=e?.width??0,n=e?.height??0,o=this._transformOrigin(),s=this._slotAffine(),{x:i,y:a}=this._offset();return s?Or(s,hs(i,-a,this.rotation,this.scale,o.x*(r/2),-o.y*(n/2),this._projection())):hs((e?.x??0)+i,(e?.y??0)-a,this.rotation,this.scale,o.x*(r/2),-o.y*(n/2),this._projection())}worldMatrix(){let e=this._localMatrix(),r=this.parent2D;return r?we(r.worldMatrix(),e):e}get global(){let e=this.layoutBounds,r=fn(this.worldMatrix(),(e?.width??0)/2,(e?.height??0)/2),n=0,o=1,s=1;for(let i=this;i;i=i.parent2D){let a=i._placement();n+=i.rotation+(a?.rotation??0),o*=i.scale*(a?.scale??1),s*=i.opacity*(a?.opacity??1)}return{x:r.center.x,y:r.center.y,...r,rotation:n,scale:o,opacity:s}}_pointOnNode(e,r){let n=lx(this,e);if(!n)return null;let o=Q.resolve(r??"center"),s=n.layoutBounds,i=ee(n.worldMatrix(),{x:o.x*((s?.width??0)/2),y:-o.y*((s?.height??0)/2)}),a=this.parent2D,l=a?Ie(a.worldMatrix()):null;if(a&&!l)return null;let c=l?ee(l,i):i,d=this.layoutBounds,u=c.x-(d?.x??0),f=(d?.y??0)-c.y;return a?._planeOf(this)?.toCoords(u,f)??{x:u,y:f}}resolveSizeInput(e,r,n){return ce.resolveLayout(e,r,n)}addChildAt(e){let{child:r,index:n}=e.data;if(this.assertAcceptsChild(r),e.duration===void 0){this._insertChildAt(r,n);return}return Kf(this,r,n,e.duration,e.easing)}removeChildAt(e){let r=e.data.index;if(e.duration===void 0){if(r<0||r>=this._children.length)return null;L!==null&&this._structureChanged(this._children[r]);let[n]=this._children.splice(r,1);return n&&(n._parent=null,n.detach()),n??null}return Hf(this,r,e.duration,e.easing)}_transformScratch={x:0,y:0,width:0,height:0,scale:1,rotation:0,opacity:1,blend:"pass-through",effects:[],pivot:{x:0,y:0}};_motionHistory=Gf();_renderState={id:this.id,rects:{},elapsed:0,dt:0,velocity:{x:0,y:0},direction:0,speed:0,angularVelocity:0,scaleVelocity:0};_sampleMotion(){let e=this.layoutBounds,r=this._offset(),n=(e?.x??0)+r.x,o=(e?.y??0)-r.y;Yf(this._renderState,this._motionHistory,n,o,this.rotation,this.scale,this._time.total)}applyTransform(e){let r=this.layoutBounds,n=this._transformScratch,{x:o,y:s}=this._offset();n.x=(r?.x??0)+o,n.y=(r?.y??0)-s,n.width=r?.width??0,n.height=r?.height??0,n.scale=this.scale,n.rotation=this.rotation,n.opacity=this.opacity,n.blend=this.blend,n.effects=this.effects,n.pivot=this._transformOrigin();let i=this._placement()?.opacity;i!==void 0&&(n.opacity*=i);let a=this._spaceFrame,l=a?null:this._slotMatrix(!0);if(a)n.matrix=a.local;else if(l)n.matrix=we(l,Rr(o,-s,n.rotation,n.scale,n.pivot,n.width,n.height,this._projection()));else{let c=this._projection();n.matrix=us(c)?Rr(n.x,n.y,n.rotation,n.scale,n.pivot,n.width,n.height,c):void 0}e.transform(n)}renderSelf(e){}renderOverlay(e){}renderStroke(e){}clipSelf(){return null}_cameraScope(){return null}_spaceCamera(){return null}_rendersChildrenInSpace(){return!0}_spaceFrame=null;_confinesChildren(){if(this._cameraScope()!==null)return!0;if(!this.clip)return!1;let e=this.clipSelf();return e!==null&&!e.isEmpty()}hitTestSelf(e,r){let n=this._localBounds();return Math.abs(e.x-n.x)<=n.width/2+r&&Math.abs(e.y-n.y)<=n.height/2+r}_localBounds(){return{x:0,y:0,width:this.measuredWidth,height:this.measuredHeight}}_hitTestSelf(e,r){return this.hitTestSelf(e,r)}clipPathSelf(){return null}applyClip(e){let r=this.clipSelf();return!r||r.isEmpty()?!1:(e.beginClip(r),!0)}applyBackdropEffects(e){let r=this.effects;r.length!==0&&Zf(e,r,this.clipSelf(),this.layoutBounds?.width??0,this.layoutBounds?.height??0)}renderContentWithEffects(e,r){this.applyBackdropEffects(e),Jf(e,this.effects,this.clipPathSelf(),this.layoutBounds?.width??0,this.layoutBounds?.height??0,r)}renderChildren(e){let r=this._spaceCamera();if(r){this._renderInSpace(e,nr(this,r));return}let n=this._spaceFrame;if(n){this._renderInSpace(e,n);return}for(let o of this._children)o instanceof t&&o.render(e)}_renderInSpace(e,r){let n=[];for(let i of this._children)i instanceof t&&n.push(i);let o=n.map(i=>pn(r,i)),s=e.drawsVisibleOnly?Rs(o):o.map((i,a)=>a);for(let i of s){let a=n[i];a._spaceFrame=o[i];try{a.render(e)}finally{a._spaceFrame=null}}}_paintInFront(e,r,n){if(!r){n();return}e.beginClip(r);try{n()}finally{e.endClip()}}beforeRender(e){}renderState(e){let r=this._renderState;return r.rects=e.readsSpaceRects?this._spaceRects():ox,r.elapsed=this._time.elapsed,r}_spaceRects(){let e=this._offset();return Xf(this.parent2D?.layoutBounds,this.layoutBounds,e.x,e.y)}afterRender(e){}render(e){if(!this.mounted||e.drawsVisibleOnly&&this.opacity*(this._placement()?.opacity??1)<=0||e.drawsVisibleOnly&&this.hidden)return;let r=this._spaceFrame;if(!(e.drawsVisibleOnly&&!this.backfaceVisible&&this._facesAway(r))&&!(e.drawsVisibleOnly&&r&&!r.paints&&!this._rendersChildrenInSpace()))try{e.begin(this.renderState(e));try{this.beforeRender(e),this.renderContent(e),this.afterRender(e)}finally{e.end()}}catch(n){throw n instanceof un&&(n.nodeId??=this.id),n}}renderContent(e){this.applyTransform(e);let r=this._spaceFrame;if(r&&!r.paints){this.renderChildren(e);return}let n=r?.nearCut??null;this.renderContentWithEffects(e,()=>{this._paintInFront(e,n,()=>this.renderSelf(e));let o=this.clip&&this.applyClip(e);this.renderChildren(e),o&&e.endClip(),this._paintInFront(e,n,()=>{this.renderOverlay(e),this.renderStroke(e)})})}_facesAway(e){if(e)return e.facesAway;let r=this._projection();return Ea(r.rotationX,r.rotationY)}_flowMeasure=null;_childBox=null;_flowWarned=!1;setLayoutBounds(e){let r=this._layoutBounds.get();r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height||this._layoutBounds.set(e)}flowChildren(){let e=this._children,r=0;for(;r<e.length;r++){let n=e[r];if(!(n instanceof t)||n.hidden)break}return r===e.length?e:e.filter(n=>n instanceof t&&!n.hidden)}effectivePadding(){return this.padding}flowArrangement(){return ix}layout(e,r){this.setLayoutBounds(e),this.layoutChildren(e,r)}layoutChildren(e,r){let n=this._flowMeasure;this._flowMeasure=null;let o=Re.insetBounds(e.width,e.height,this.effectivePadding());this._childBox=o;let s=this.flowChildren();if(s.length===0)return;let i=this.flowArrangement(),a=n&&Ge.reusable(n,o)?n:Ge.measure(i,s,{width:o.width,height:o.height,hugWidth:this.width==="hug",hugHeight:this.height==="hug"},r),l=Ge.place(a,i,o);for(let d=0;d<l.length;d++){let u=l[d];a.items[d].layout({x:o.x+u.x,y:o.y-u.y,width:u.width,height:u.height},r)}if(this._flowWarned)return;let c=Ge.collapsedRun(a,e);c!==null&&(this._flowWarned=!0,console.warn(`[motionscript] "${this.className}" ${c}`))}measure(e,r){this.lastMeasure={constraints:e,measurer:r};let n=this.effectivePadding(),o=this.flowChildren();if(o.length===0)return this._flowMeasure=null,Ge.size(this,e,n,ax);let s=Ge.contentBox(this,e,n),i=Ge.measure(this.flowArrangement(),o,s,r);return this._flowMeasure=i,Ge.size(this,e,n,i.hug)}reparent(e){let r=e.data.newParent;if(e.duration===void 0){let n=this.parent;n&&n.remove(this),r.add(this);return}return Uf(this,r,e.duration,e.easing)}};$([p({default:0})],A.prototype,"x",void 0);$([p({default:0})],A.prototype,"y",void 0);$([p({default:"fill",tween:ce.lerp})],A.prototype,"width",void 0);$([p({default:"fill",tween:ce.lerp})],A.prototype,"height",void 0);$([p({default:1})],A.prototype,"scale",void 0);$([p({default:0})],A.prototype,"rotation",void 0);$([p({default:1})],A.prototype,"opacity",void 0);$([p({default:"pass-through"})],A.prototype,"blend",void 0);$([qa()],A.prototype,"effects",void 0);$([no()],A.prototype,"padding",void 0);$([Rt()],A.prototype,"pivot",void 0);$([p({default:!1})],A.prototype,"flipHorizontal",void 0);$([p({default:!1})],A.prototype,"flipVertical",void 0);$([p({default:0})],A.prototype,"rotationX",void 0);$([p({default:0})],A.prototype,"rotationY",void 0);$([p({default:0})],A.prototype,"rotationZ",void 0);$([p({default:0})],A.prototype,"depth",void 0);$([p({default:0,tween:yc})],A.prototype,"perspective",void 0);$([p({default:!0})],A.prototype,"backfaceVisible",void 0);$([p({default:void 0,mapper:t=>t==null?void 0:Q.resolve(t),tween:(t,e,r)=>Q.lerp(t??e??Za,e??Za,r)})],A.prototype,"transformOrigin",void 0);$([p({default:!1})],A.prototype,"clip",void 0);$([p({default:1})],A.prototype,"flex",void 0);$([p({default:1})],A.prototype,"gapScale",void 0);$([p({default:void 0})],A.prototype,"column",void 0);$([p({default:void 0})],A.prototype,"row",void 0);$([p({default:1})],A.prototype,"colSpan",void 0);$([p({default:1})],A.prototype,"rowSpan",void 0);$([P({args:["x","y",{key:"path",kind:"path"},{key:"target",kind:"nodeRef"},{key:"targetAnchor",kind:"alignment"}]})],A.prototype,"moveTo",null);$([P({args:["opacity"]})],A.prototype,"fadeTo",null);$([P({args:["rotation"]})],A.prototype,"rotateTo",null);$([P({args:["scale"]})],A.prototype,"scaleTo",null);$([P({args:[{key:"width",kind:"size"},{key:"height",kind:"size"},{key:"padding",kind:"insets"}]})],A.prototype,"layoutTo",null);$([P({args:[{key:"factor",kind:"number",min:0,step:.05,unit:"\xD7",default:1.2}]})],A.prototype,"pulse",null);$([P({args:[{key:"angle",kind:"number",min:0,unit:"\xB0",default:8},{key:"turns",kind:"number",min:1,step:1,default:3}]})],A.prototype,"wiggle",null);$([P({args:[{key:"effects",kind:"effects"}]})],A.prototype,"effectTo",null);$([P({args:["index"]})],A.prototype,"removeChildAt",null);$([P({args:["newParent"]})],A.prototype,"reparent",null);function ep(t){let e={};for(let r in t)t[r]!==void 0&&(e[r]=t[r]);return e}function lx(t,e){let r=t;for(;r.parent;)r=r.parent;return tp(r,e)}function tp(t,e){if(t.id===e)return t instanceof A?t:null;for(let r of t._allChildren){let n=tp(r,e);if(n)return n}return null}function rp(t,e){let r=e.global,n=t.global,o=n.scale===0?0:1/n.scale,s=Ua(0,0,-n.rotation,(r.x-n.x)*o,(r.y-n.y)*o);return{x:s.x,y:s.y,rotation:r.rotation-n.rotation,scale:r.scale*o}}function Ae(t){return Q.resolve(t??{x:0,y:0})}var Is=["center","topLeft","topRight","bottomLeft","bottomRight","topCenter","bottomCenter","centerLeft","centerRight"];function cx(t){let e=Is.filter(r=>t[r]!==void 0);if(e.length>1)throw new Error(`Cannot set multiple shape alignment props at once: ${e.join(", ")}`);if(e.length===1){let r=["pivot","x","y"].find(n=>t[n]!==void 0);if(r)throw new Error(`Cannot set both shape alignment prop '${e[0]}' and '${r}' at the same time`)}}function et(t){let e={...t};for(let r of Is)delete e[r];return e}function tt(t,e,r){cx(t);let n=Is.find(o=>t[o]!==void 0);if(n){let o=t[n],s=Q.resolve(n);return{x:o.x-s.x*(e/2),y:o.y-s.y*(r/2),pivot:s}}return{x:t.x??0,y:t.y??0,pivot:t.pivot??{x:0,y:0}}}function QC(t,e,r){if(Is.find(i=>t[i]!==void 0)||t.pivot===void 0)return t;let o=Q.resolve(t.pivot);if(o.x===0&&o.y===0)return t;let s={x:t.x??0,y:t.y??0};return{...t,x:s.x-o.x*(e/2),y:s.y-o.y*(r/2),pivot:o}}function np(t){let e=t.width??0,r=t.height??0,{x:n,y:o,pivot:s}=tt(t,e,r);return{...et(t),opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:n,y:o,start:t.start??0,end:t.end??1,pivot:Ae(s),width:e,height:r,cornerRadius:t.cornerRadius??0,cornerStyle:t.cornerStyle??"rounded"}}function op(t){let e=t.width??0,r=t.height??0,{x:n,y:o,pivot:s}=tt(t,e,r);return{...et(t),opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:n,y:o,start:t.start??0,end:t.end??1,pivot:Ae(s),width:e,height:r,ratio:t.ratio??0,sweep:t.sweep??360,startAngle:t.startAngle??0}}function sp(t){let e=t.width??0,r=t.height??0,{x:n,y:o,pivot:s}=tt(t,e,r);return{...et(t),opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:n,y:o,start:t.start??0,end:t.end??1,pivot:Ae(s),width:e,height:r,sides:t.sides??5,cornerRadius:t.cornerRadius??0,cornerStyle:t.cornerStyle??"rounded"}}function ip(t){let e=t.width??0,r=t.height??0,{x:n,y:o,pivot:s}=tt(t,e,r);return{...et(t),opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:n,y:o,start:t.start??0,end:t.end??1,pivot:Ae(s),width:e,height:r,sides:t.sides??5,ratio:t.ratio??.5,cornerRadius:t.cornerRadius??0,cornerStyle:t.cornerStyle??"rounded"}}function ap(t){return{opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:t.x??0,y:t.y??0,start:t.start??0,end:t.end??1,width:t.width??0,height:t.height??0,pivot:Ae(t.pivot),points:t.points??[],radius:t.radius??0,closed:t.closed??!1}}var zs=1e-9;function Qa(t,e,r=0){return up(t.ops(),e,r)}function up(t,e,r=0){let n=!1,o=null,s=()=>{o&&lp(o,e,r)&&(n=!0),o=null};for(let i of t){if(i.kind==="cut"){o&&lp(o,e,r)&&(n=!1),o=null;continue}s(),o=i}return s(),n}function lp(t,e,r){switch(t.kind){case"rect":{let n=np(t.state),o=co(e,n,n.width,n.height);return o!==null&&cp(o,n.width,n.height,vr.resolve(n.cornerRadius),r)}case"ellipse":{let n=op(t.state),o=co(e,n,n.width,n.height);return o!==null&&dx(o,n.width,n.height,n.ratio,n.sweep,n.startAngle,r)}case"polygon":{let n=sp(t.state),o=co(e,n,n.width,n.height);return o!==null&&Ja(o,fp(n.width,n.height,n.sides),!0,r)}case"polygram":{let n=ip(t.state),o=co(e,n,n.width,n.height);return o!==null&&Ja(o,pp(n.width,n.height,n.sides,n.ratio),!0,r)}case"line":{let n=ap(t.state),o=co(e,n,n.width,n.height);return o===null||n.points.length===0?!1:n.points.length>=3&&Ja(o,n.points,!0,r)?!0:el(o,n.points,n.closed,r)}case"path":{let n=t.state,o={x:e.x-(n.x??0),y:e.y-(n.y??0)};return cp(o,n.width??0,n.height??0,vr.resolve(0),r)}}}function co(t,e,r,n){if(e.scale===0)return null;let o=e.pivot,s=o.x*(r/2),i=o.y*(n/2),a=t.x-(e.x+s),l=t.y-(e.y+i),c=e.rotation*Math.PI/180,d=Math.cos(c),u=Math.sin(c),f=(d*a-u*l)/e.scale,h=(u*a+d*l)/e.scale;return{x:f+s,y:h+i}}function cp(t,e,r,n,o){let s=e/2+o,i=r/2+o;if(Math.abs(t.x)>s||Math.abs(t.y)>i)return!1;let a=Math.min(e,r)/2,l=Math.min(a,t.x<=0?t.y>=0?n.topLeft:n.bottomLeft:t.y>=0?n.topRight:n.bottomRight);if(l<=0)return!0;let c=Math.sign(t.x||1),d=Math.sign(t.y||1),u=t.x-c*(e/2-l),f=t.y-d*(r/2-l);return Math.sign(u||1)!==c||Math.sign(f||1)!==d?!0:u*u+f*f<=(l+o)*(l+o)}function dx(t,e,r,n,o,s,i){let a=e/2,l=r/2;if(a<=0||l<=0)return!1;let c=Math.max(0,Math.min(1,n)),d=Math.abs(o)>=360;return dp(t,a+i,l+i)>1||c>0&&dp(t,Math.max(zs,a*c-i),Math.max(zs,l*c-i))<1?!1:d?!0:ux(Math.atan2(t.y/l,t.x/a)*(180/Math.PI),s,o,t,i)}function dp(t,e,r){return Math.hypot(t.x/e,t.y/r)}function ux(t,e,r,n,o){let s=r>=0?e:e+r,i=Math.abs(r),a=Math.hypot(n.x,n.y);if(a<=o)return!0;let l=o>0?o/Math.max(a,zs)*(180/Math.PI):0,c=(t-s)%360;return c<0&&(c+=360),c<=i+l||c>=360-l}function fp(t,e,r){let n=Math.max(3,Math.round(r)),o=t/2,s=e/2,i=2*Math.PI/n,a=[];for(let l=0;l<n;l++){let c=Math.PI/2-l*i;a.push({x:o*Math.cos(c),y:s*Math.sin(c)})}return a}function pp(t,e,r,n){let o=Math.max(3,Math.round(r)),s=Math.max(0,Math.min(1,n)),i=t/2,a=e/2,l=Math.PI/o,c=[];for(let d=0;d<o*2;d++){let u=Math.PI/2-d*l,f=d%2===0?1:s;c.push({x:i*f*Math.cos(u),y:a*f*Math.sin(u)})}return c}function Ja(t,e,r,n){return e.length>=3&&hp(t,e)?!0:n>0&&el(t,e,r,n)}function hp(t,e){if(e.length<3)return!1;let r=!1;for(let n=0,o=e.length-1;n<e.length;o=n++){let s=e[n],i=e[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(r=!r)}return r}function el(t,e,r,n){if(e.length===0)return!1;if(e.length===1)return Math.hypot(t.x-e[0].x,t.y-e[0].y)<=n;let o=r?e.length:e.length-1;for(let s=0;s<o;s++)if(mp(t,e[s],e[(s+1)%e.length])<=n)return!0;return!1}function mp(t,e,r){let n=r.x-e.x,o=r.y-e.y,s=n*n+o*o;if(s<=zs)return Math.hypot(t.x-e.x,t.y-e.y);let i=((t.x-e.x)*n+(t.y-e.y)*o)/s;return i=i<0?0:i>1?1:i,Math.hypot(t.x-(e.x+i*n),t.y-(e.y+i*o))}var xt=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},me=class extends A{shapeGraphics(){return null}renderSelf(e){let r=this.shapeGraphics();r&&e.draw(r.shadow(this.shadow).fill(this.fill))}renderStroke(e){let r=this.stroke;if(r.length===0)return;let n=this.shapeGraphics();n&&e.draw(this.castsShadowFromStroke()?n.shadow(this.shadow).stroke(r):n.stroke(r))}castsShadowFromStroke(){return this.shadow.length===0?!1:!this.fill.some(n=>(n.opacity??1)>0)}declareAssets(e){super.declareAssets(e),e.fill(this.fill);for(let r of this.stroke)e.fill(r.fill);for(let r of this.shadow)e.fill(r.fill)}hitTestSelf(e,r){let n=this.clipSelf();return!n||n.isEmpty()?super.hitTestSelf(e,r):Qa(n,e,r)}fillTo(e){let r=this.fill,n=q.resolve(e.data),o=e.lerp??q.lerp;return this.command(s=>({fill:o(r,n,s)}),e.duration,e.easing)}strokeTo(e){let r=this.stroke,n=_e.resolve(e.data,r),o=e.lerp??_e.lerp;return this.command(s=>({stroke:o(r,n,s)}),e.duration,e.easing)}shadowTo(e){let r=this.shadow,n=mt.resolve(e.data,r),o=e.lerp??mt.lerp;return this.command(s=>({shadow:o(r,n,s)}),e.duration,e.easing)}progressTo(e){let{start:r,end:n}=e.data??{},o={...r===void 0?{}:{start:r},...n===void 0?{}:{end:n}};return this.to({data:o,duration:e.duration,easing:e.easing})}flash(e){let r={start:this.start,end:this.end},n=Math.min(1,Math.max(.01,e.data?.portion??.25));return this.command(o=>{if(o<=0||o>=1)return r;let s=o*(1+n);return{start:Math.max(0,s-n),end:Math.min(1,s)}},e.duration,e.easing)}};xt([er()],me.prototype,"fill",void 0);xt([La()],me.prototype,"stroke",void 0);xt([Wa()],me.prototype,"shadow",void 0);xt([p({default:0})],me.prototype,"start",void 0);xt([p({default:1})],me.prototype,"end",void 0);xt([P()],me.prototype,"fillTo",null);xt([P()],me.prototype,"strokeTo",null);xt([P()],me.prototype,"shadowTo",null);xt([P({args:[{key:"start",kind:"number",min:0,max:1,step:.01,scale:100,unit:"%"},{key:"end",kind:"number",min:0,max:1,step:.01,scale:100,unit:"%"}]})],me.prototype,"progressTo",null);xt([P({args:[{key:"portion",kind:"number",min:.01,max:1,step:.01,scale:100,unit:"%",default:.25}]})],me.prototype,"flash",null);function zt(t,e){return t===""?String(e):`${t}.${e}`}function tl(t,e){t.declareAssets(e)}function rl(t,e){if(!t.mounted)return;tl(t,e);let r=t._allChildren;for(let n=0;n<r.length;n++)rl(r[n],e)}function yp(t,e){t.attachDetached(e)}function Ns(t){t._sample();for(let e of t.children)Ns(e)}function $s(t,e){t._primeMotion(e);for(let r of t.children)$s(r,e)}function nl(t,e){let r=n=>{let o=n.key!==void 0?e?.[n.key]:void 0;n._setEditorState(o?.hidden===!0,o?.locked===!0);for(let s of n._allChildren)r(s)};r(t)}var js=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Pe=class t extends he{get dimension(){return"audio"}constructor(e){super(e),this.initProps(e),this.adoptChildrenProp(e)}get childrenAudio(){return this._allChildren.filter(e=>e instanceof t)}get _busId(){let e=this._props?.id;return`bus:${typeof e=="string"?e:_p(this)}`}_prepareStep(e,r,n){for(let o of fx)if(o in e)throw new TypeError(`${this.className}: "${o}" cannot be tweened \u2014 an audio level is scheduled once, not written per frame, so a tween on it would render flat. Automate it with a curve instead: ${o}: fadeOut(1), or filters: AudioFilters.gain(ramp(1, 0, 1)).`);return super._prepareStep(e,r,n)}};js([Ga({default:1})],Pe.prototype,"volume",void 0);js([Ga({default:0})],Pe.prototype,"pan",void 0);js([p({default:!1})],Pe.prototype,"mute",void 0);js([Tf()],Pe.prototype,"filters",void 0);var fx=["volume","pan"];function Bs(t,e){let r=[],n=t.parent;for(;n instanceof Pe;)r.push(xp(n,e)),n=n.parent;return r.length>0?r:void 0}function ol(t,e){return[xp(t,e),...Bs(t,e)??[]]}function sl(t,e){let r=t;for(;r.parent;)r=r.parent;return gp(r,e)}function gp(t,e){if(t instanceof Pe&&t.id===e)return t;for(let r of t._allChildren){let n=gp(r,e);if(n)return n}return null}function xp(t,e){let r=t.filters,n=e._spanOf(t);return{id:t._busId,volume:t.volume,pan:t.pan,mute:t.mute,...r.length>0?{filters:r}:{},startAt:n.start,endAt:n.end}}function _p(t){let e=[],r=t;for(;r;){let n=r.parent;if(!n)break;e.push(String(n._allChildren.indexOf(r))),r=n}return e.reverse().join(".")}var ne=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},K=class extends A{constructor(e){super(e)}zoomTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}panTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}orbitTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}dollyTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}headingTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}fillTo(e){let r=this.fill,n=q.resolve(e.data),o=e.lerp??q.lerp;return this.command(s=>({fill:o(r,n,s)}),e.duration,e.easing)}overlayTo(e){let r=this.overlay,n=q.resolve(e.data),o=e.lerp??q.lerp;return this.command(s=>({overlay:o(r,n,s)}),e.duration,e.easing)}flowArrangement(){return this}shapeGraphics(){return new B().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}renderSelf(e){let r=this.fill;r.length!==0&&e.draw(this.shapeGraphics().fill(r))}renderOverlay(e){let r=this.overlay;r.length!==0&&e.draw(this.shapeGraphics().fill(r))}acceptsChild(e){return e.dimension==="2d"||e.dimension==="audio"}get childrenAudio(){return this._allChildren.filter(e=>e instanceof Pe)}declareAssets(e){super.declareAssets(e),e.fill(this.fill),e.fill(this.overlay)}clipSelf(){return new se().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}_cameraScope(){return this.space3D||this.zoom===1&&this.heading===0&&this.lookAt.x===0&&this.lookAt.y===0?null:{lookAt:this.lookAt,zoom:this.zoom,heading:this.heading}}_spaceCamera(){if(!this.space3D)return null;let e=this.layoutBounds;return{perspective:this.perspective,orbit:this.orbit,elevation:this.elevation,dolly:this.dolly,lookAt:this.lookAt,zoom:this.zoom,heading:this.heading,viewportX:e?.x??0,viewportY:-(e?.y??0)}}_projection(){return this.space3D?Mr:super._projection()}renderChildren(e){let r=this._spaceCamera();if(r){this._renderInSpace(e,nr(this,r));return}if(this.zoom===1&&this.heading===0&&this.lookAt.x===0&&this.lookAt.y===0){super.renderChildren(e);return}let n=this.layoutBounds,o=n?.width??0,s=n?.height??0,i=n?.x??0,a=n?.y??0;e.beginCamera({x:i,y:-a,width:o,height:s},this.lookAt,this.zoom,this.heading);for(let l of this._children)l instanceof A&&l.render(e);e.endCamera()}};ne([er()],K.prototype,"fill",void 0);ne([er()],K.prototype,"overlay",void 0);ne([vs()],K.prototype,"flow",void 0);ne([p({default:0})],K.prototype,"gap",void 0);ne([p({default:!1})],K.prototype,"wrap",void 0);ne([p({default:void 0})],K.prototype,"crossGap",void 0);ne([p({default:1})],K.prototype,"columns",void 0);ne([Rt()],K.prototype,"align",void 0);ne([p({default:1})],K.prototype,"zoom",void 0);ne([p({default:{x:0,y:0},tween:cn})],K.prototype,"lookAt",void 0);ne([p({default:0})],K.prototype,"heading",void 0);ne([p({default:!1})],K.prototype,"space3D",void 0);ne([p({default:0})],K.prototype,"orbit",void 0);ne([p({default:0})],K.prototype,"elevation",void 0);ne([p({default:0})],K.prototype,"dolly",void 0);ne([P({args:[{key:"zoom",kind:"number",min:.01,step:.1,unit:"\xD7"}]})],K.prototype,"zoomTo",null);ne([P({args:[{key:"lookAt",kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}]})],K.prototype,"panTo",null);ne([P({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",step:1,unit:"\xB0"}]})],K.prototype,"orbitTo",null);ne([P({args:[{key:"dolly",kind:"number",step:10}]})],K.prototype,"dollyTo",null);ne([P({args:[{key:"heading",kind:"number",step:1,unit:"\xB0"}]})],K.prototype,"headingTo",null);ne([P()],K.prototype,"fillTo",null);ne([P()],K.prototype,"overlayTo",null);var or=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},H=class extends me{overlayTo(e){let r=this.overlay,n=q.resolve(e.data),o=e.lerp??q.lerp;return this.command(s=>({overlay:o(r,n,s)}),e.duration,e.easing)}renderOverlay(e){let r=this.overlay;if(r.length===0)return;let n=this.shapeGraphics();n&&e.draw(n.fill(r))}declareAssets(e){super.declareAssets(e),e.fill(this.overlay)}applyDefaultSize(e){let r=A.flowChildrenProp(e),n=r.length>0,o=e?.flow??"freeform",s=o==="horizontal"||o==="freeform"||o==="grid",i=o==="vertical"||o==="freeform",a=n&&s&&A.hasFillChild(r,"width")?"fill":n?"hug":"fill",l=n&&i&&A.hasFillChild(r,"height")?"fill":n?"hug":"fill";(!e||e.width===void 0)&&this.applyProp("width",a,{tween:ce.lerp}),(!e||e.height===void 0)&&this.applyProp("height",l,{tween:ce.lerp})}flowArrangement(){return this}effectivePadding(){let e=0,r=this.padding,n=this.stroke;if(!n||!(Symbol.iterator in Object(n)))return r;for(let o of n){let s=o.weight*(1-o.align)/2;s>e&&(e=s)}return e===0?r:{left:r.left+e,right:r.right+e,top:r.top+e,bottom:r.bottom+e}}};or([er()],H.prototype,"overlay",void 0);or([vs()],H.prototype,"flow",void 0);or([p({default:0})],H.prototype,"gap",void 0);or([p({default:!1})],H.prototype,"wrap",void 0);or([p({default:void 0})],H.prototype,"crossGap",void 0);or([p({default:1})],H.prototype,"columns",void 0);or([Rt()],H.prototype,"align",void 0);or([P()],H.prototype,"overlayTo",null);var Nt=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},He=class extends H{constructor(e){super(e)}zoomTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}panTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}headingTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}shapeGraphics(){return new B().rect({width:this.layoutBounds.width,height:this.layoutBounds.height,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle,start:this.start,end:this.end})}clipSelf(){return new se().rect({width:this.layoutBounds.width,height:this.layoutBounds.height,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle})}_cameraScope(){return{lookAt:this._aim(),zoom:this.zoom,heading:this.heading}}_rendersChildrenInSpace(){return!1}renderChildren(e){let r=this.layoutBounds,n=r?.width??0,o=r?.height??0,s=r?.x??0,i=r?.y??0;e.beginCamera({x:s,y:-i,width:n,height:o},this._aim(),this.zoom,this.heading);for(let a of this._children)a instanceof A&&a.render(e);e.endCamera()}_followed=null;_aim(){let e=this.follow;if(e==="")return this.lookAt;let r=this._followed;if((!r||r.id!==e||!px(r,this))&&(r=this._followed=wp(this,e)),!r)return this.lookAt;let n=rp(this,r);return{x:n.x+this.lookAt.x,y:n.y+this.lookAt.y}}};Nt([p({default:1})],He.prototype,"zoom",void 0);Nt([p({default:{x:0,y:0},tween:D})],He.prototype,"lookAt",void 0);Nt([p({default:0})],He.prototype,"heading",void 0);Nt([p({default:"",kind:"nodeRef",animatable:!1})],He.prototype,"follow",void 0);Nt([eo()],He.prototype,"cornerRadius",void 0);Nt([to()],He.prototype,"cornerStyle",void 0);Nt([P({args:[{key:"zoom",kind:"number",min:.01,step:.1,unit:"\xD7"}]})],He.prototype,"zoomTo",null);Nt([P({args:[{key:"lookAt",kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"}}}]})],He.prototype,"panTo",null);Nt([P({args:[{key:"heading",kind:"number",step:1,unit:"\xB0"}]})],He.prototype,"headingTo",null);function px(t,e){for(let r=t.parent;r;r=r.parent)if(r===e)return!0;return!1}function wp(t,e){for(let r of t._allChildren){if(r.id===e)return r instanceof A?r:null;let n=wp(r,e);if(n)return n}return null}var rt=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},hx=1e3,Me=class extends A{constructor(e){super(e),e?.perspective===void 0&&e?.transform3D===void 0&&this._writeProp("perspective",hx)}orbitTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}dollyTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}zoomTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}panTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}headingTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}applyDefaultSize(e){(!e||e.width===void 0)&&this.applyProp("width","hug",{tween:ce.lerp}),(!e||e.height===void 0)&&this.applyProp("height","hug",{tween:ce.lerp})}_spaceCamera(){return{perspective:this.perspective,orbit:this.orbit+this.orbitSpeed*this._time.total,elevation:this.elevation,dolly:this.dolly,lookAt:this.lookAt,zoom:this.zoom,heading:this.heading,viewportX:0,viewportY:0}}_projection(){return Mr}};rt([p({default:{x:0,y:0},tween:cn})],Me.prototype,"lookAt",void 0);rt([p({default:1})],Me.prototype,"zoom",void 0);rt([p({default:0})],Me.prototype,"heading",void 0);rt([p({default:0})],Me.prototype,"orbit",void 0);rt([p({default:0})],Me.prototype,"elevation",void 0);rt([p({default:0})],Me.prototype,"dolly",void 0);rt([p({default:0})],Me.prototype,"orbitSpeed",void 0);rt([P({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",step:1,unit:"\xB0"}]})],Me.prototype,"orbitTo",null);rt([P({args:[{key:"dolly",kind:"number",step:10}]})],Me.prototype,"dollyTo",null);rt([P({args:[{key:"zoom",kind:"number",min:.01,step:.1,unit:"\xD7"}]})],Me.prototype,"zoomTo",null);rt([P({args:[{key:"lookAt",kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}]})],Me.prototype,"panTo",null);rt([P({args:[{key:"heading",kind:"number",step:1,unit:"\xB0"}]})],Me.prototype,"headingTo",null);function il(t){let e=t._localBounds(),r=t._localMatrix(),n=e.x===0&&e.y===0?r:we(r,Zn(e.x,-e.y)),o=fn(n,e.width/2,e.height/2);return[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft]}function al(t){if(t.length===0)return null;let e=1/0,r=1/0,n=-1/0,o=-1/0;for(let s of t)s.x<e&&(e=s.x),s.x>n&&(n=s.x),s.y<r&&(r=s.y),s.y>o&&(o=s.y);return{minX:e,minY:r,maxX:n,maxY:o}}function ll(t){return{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2,width:t.maxX-t.minX,height:t.maxY-t.minY}}function Ls(t,e){let r=t.children;if(r.length===0)return null;if(e==="first"){let o=al(il(r[0]));return o?ll(o):null}if(e==="union"){let o=al(r.flatMap(il));return o?ll(o):null}let n=null;for(let o of r){let s=al(il(o));if(!s||(n=n?{minX:Math.max(n.minX,s.minX),minY:Math.max(n.minY,s.minY),maxX:Math.min(n.maxX,s.maxX),maxY:Math.min(n.maxY,s.maxY)}:s,n.minX>n.maxX||n.minY>n.maxY))return null}return n?ll(n):null}var Ws=class extends H{constructor(e){super(e),this.applyProp("op",e.op??"union")}renderSelf(e){}_localBounds(){return Ls(this,mx(this.op))??super._localBounds()}_rendersChildrenInSpace(){return!1}renderContent(e){this.applyTransform(e),this.renderContentWithEffects(e,()=>{e.beginBoolean(this.op);for(let n of this._children)n instanceof A&&n.render(e);e.endBoolean(),e.draw(new B().shadow(this.shadow).fill(this.fill));let r=this.overlay;r.length>0&&e.draw(new B().fill(r)),e.draw(new B().stroke(this.stroke))})}};function mx(t){return t==="subtract"?"first":t==="intersect"?"intersect":"union"}var qs=class extends A{constructor(e){super(e),this.applyProp("mode",e.mode??"alpha"),this.applyProp("inverted",e.inverted??!1)}_localBounds(){return Ls(this,"first")??super._localBounds()}_rendersChildrenInSpace(){return!1}renderContent(e){this.applyTransform(e),this._children.length!==0&&this.renderContentWithEffects(e,()=>{let[r,...n]=this.children;if(n.length===0){r.render(e);return}e.beginMask({mode:this.mode,inverted:this.inverted}),r.render(e),e.applyMask();for(let o of n)o.render(e);e.endMask()})}};var vp=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},hn=class extends A{constructor(e){super(e)}resolveContext(){return this.context}resolveValue(){return this.value}provideContext(e){let r=this.resolveContext();if(!r)return e;let n=this.resolveValue();return e.with(r,n!==void 0?n:r.defaultValue)}};vp([p({default:void 0})],hn.prototype,"context",void 0);vp([p({default:void 0})],hn.prototype,"value",void 0);var Vs=io({},"text-style"),cl=io({},"theme"),dl=io({},"data"),Sp=io(void 0,"seed");var ul=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Fr=class extends A{constructor(e){super(e)}provideContext(e){let r=e;return this.theme&&(r=r.with(cl,{...e.get(cl),...this.theme})),this.data&&(r=r.with(dl,{...e.get(dl),...this.data})),this.seed!==void 0&&(r=r.with(Sp,this.seed)),r}};ul([p({default:void 0})],Fr.prototype,"theme",void 0);ul([p({default:void 0})],Fr.prototype,"data",void 0);ul([p({default:void 0})],Fr.prototype,"seed",void 0);var _t=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},ze=class extends A{constructor(e){super(e)}provideContext(e){let r=e.get(Vs),n=oe.mergeStyle(r,this._props);return n===r?e:e.with(Vs,n)}renderContent(e){e.pushTextStyle(this.currentStyle());try{super.renderContent(e)}finally{e.popTextStyle()}}currentStyle(){return oe.mergeStyle(Jt,this)}};_t([p({default:void 0})],ze.prototype,"fontFamily",void 0);_t([p({default:void 0})],ze.prototype,"fontSize",void 0);_t([p({default:void 0})],ze.prototype,"fontWeight",void 0);_t([p({default:void 0})],ze.prototype,"fontStyle",void 0);_t([p({default:void 0})],ze.prototype,"letterSpacing",void 0);_t([p({default:void 0})],ze.prototype,"lineHeight",void 0);_t([p({default:void 0})],ze.prototype,"textAlign",void 0);_t([p({default:void 0})],ze.prototype,"fill",void 0);_t([p({default:void 0})],ze.prototype,"stroke",void 0);_t([p({default:void 0})],ze.prototype,"shadow",void 0);function Gs(t,e,r={autofit:!0}){let n=e?.variant,o=oe.mergeStyle(oe.mergeStyle(oe.preset("default"),t.useContext(Vs)),n?oe.preset(n):void 0),s=t;for(let i of ys){if(e?.[i]!==void 0)continue;let a=o[i];a!==void 0&&(i==="fontSize"&&a==="autofit"&&!r.autofit||(s[i]=a))}}var bp=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},wt=class extends H{constructor(e){super(e)}shapeGraphics(){return new B().rect({width:this.layoutBounds.width,height:this.layoutBounds.height,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle,start:this.start,end:this.end})}clipSelf(){return new se().rect({width:this.layoutBounds.width,height:this.layoutBounds.height,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle})}};bp([eo()],wt.prototype,"cornerRadius",void 0);bp([to()],wt.prototype,"cornerStyle",void 0);var fl=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Ir=class extends H{constructor(e){super(e)}shapeGraphics(){return new B().ellipse({width:this.layoutBounds.width,height:this.layoutBounds.height,startAngle:this.startAngle,sweep:this.sweep,ratio:this.ratio,start:this.start,end:this.end})}clipSelf(){return new se().ellipse({width:this.layoutBounds.width,height:this.layoutBounds.height,startAngle:this.startAngle,sweep:this.sweep,ratio:this.ratio})}};fl([p({default:0})],Ir.prototype,"startAngle",void 0);fl([p({default:360})],Ir.prototype,"sweep",void 0);fl([p({default:0})],Ir.prototype,"ratio",void 0);var yx=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},pl=class extends H{constructor(e){super(e)}applyDefaultSize(e){this.applyProp("width",e?.width??"hug"),this.applyProp("height",e?.height??"hug")}measure(e,r){let n=this.width,o=this.height;if(n!=="hug"&&o!=="hug")return super.measure(e,r);let s=be.size(this.data),i=this.padding,a=typeof n=="number"?n:n==="hug"?s.width+i.left+i.right:e.maxWidth??0,l=typeof o=="number"?o:o==="hug"?s.height+i.top+i.bottom:e.maxHeight??0;return{width:a,height:l}}shapeGraphics(){let e=be.bounds(this.data);return new B().path({data:this.data,centerBounds:e?[e.minX,e.minY,e.maxX,e.maxY]:void 0,start:this.start,end:this.end})}};yx([ro()],pl.prototype,"data",void 0);var hl=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},zr=class extends H{constructor(e){super(e)}shapeGraphics(){return new B().polygon({width:this.layoutBounds.width,height:this.layoutBounds.height,sides:this.sides,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle,start:this.start,end:this.end})}clipSelf(){return new se().polygon({width:this.layoutBounds.width,height:this.layoutBounds.height,sides:this.sides,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle})}};hl([p({default:5})],zr.prototype,"sides",void 0);hl([p({default:0})],zr.prototype,"cornerRadius",void 0);hl([p({default:"rounded",tween:Sr})],zr.prototype,"cornerStyle",void 0);var Ys=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},sr=class extends H{constructor(e){super(e)}shapeGraphics(){return new B().polygram({width:this.layoutBounds.width,height:this.layoutBounds.height,sides:this.sides,ratio:this.ratio,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle,start:this.start,end:this.end})}clipSelf(){return new se().polygram({width:this.layoutBounds.width,height:this.layoutBounds.height,sides:this.sides,ratio:this.ratio,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle})}};Ys([p({default:5})],sr.prototype,"sides",void 0);Ys([p({default:.5})],sr.prototype,"ratio",void 0);Ys([p({default:0})],sr.prototype,"cornerRadius",void 0);Ys([p({default:"rounded",tween:Sr})],sr.prototype,"cornerStyle",void 0);var Hs=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},vt=class extends H{outlineOptions(){return{width:this.layoutBounds.width,height:this.layoutBounds.height,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle}}outline(){return be.anchorCommands(kc(this.kind(),this.outlineOptions()),e=>({x:e.x,y:-e.y}))}centerBounds(){let e=this.layoutBounds.width/2,r=this.layoutBounds.height/2;return[-e,-r,e,r]}shapeGraphics(){return new B().path({data:this.outline(),centerBounds:this.centerBounds(),start:this.start,end:this.end})}clipSelf(){return new se().rect({x:0,y:0,width:this.layoutBounds.width,height:this.layoutBounds.height})}};Hs([p({default:0})],vt.prototype,"cornerRadius",void 0);Hs([p({default:"rounded",tween:Sr})],vt.prototype,"cornerStyle",void 0);var kp=class extends vt{constructor(e){super(e)}kind(){return"triangle"}},Ap=class extends vt{constructor(e){super(e)}kind(){return"rightTriangle"}},Mp=class extends vt{constructor(e){super(e)}kind(){return"pentagon"}},Op=class extends vt{constructor(e){super(e)}kind(){return"hexagon"}},Ep=class extends vt{constructor(e){super(e)}kind(){return"octagon"}},Ks=class extends vt{constructor(e){super(e)}kind(){return"star"}outlineOptions(){return{...super.outlineOptions(),sides:Math.max(3,Math.round(this.points)),ratio:this.ratio}}};Hs([p({default:bc})],Ks.prototype,"points",void 0);Hs([p({default:Sc})],Ks.prototype,"ratio",void 0);var gx=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},uo=class extends H{constructor(e){super(e)}toLocal(){let e=this.layoutBounds.width,r=this.layoutBounds.height;return n=>({x:n.x*e,y:-n.y*r})}outline(){return be.anchorCommands(be.anchors(this.data),this.toLocal())}centerBounds(){let e=this.layoutBounds.width/2,r=this.layoutBounds.height/2;return[-e,-r,e,r]}shapeGraphics(){return new B().path({data:this.outline(),centerBounds:this.centerBounds(),start:this.start,end:this.end})}clipSelf(){return new se().rect({x:0,y:0,width:this.layoutBounds.width,height:this.layoutBounds.height})}};gx([ro()],uo.prototype,"data",void 0);var xx=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Us=100,Cp=new Set(["fontFamily","fontStyle"]),nt=class{node;ranges;overrides;constructor(e,r){this.node=e,this.ranges=_x(r,e.text.length),this.overrides={opacity:1,x:0,y:0,scale:1,rotation:0,fontFamily:e.fontFamily,fontSize:typeof e.fontSize=="number"?e.fontSize:Us,fontStyle:e.fontStyle,fontWeight:e.fontWeight,letterSpacing:e.letterSpacing,fill:null,stroke:null},e._registerSelection(this)}get isIdentity(){let e=this.overrides,r=typeof this.node.fontSize=="number"?this.node.fontSize:Us;return e.opacity===1&&e.x===0&&e.y===0&&e.scale===1&&e.rotation===0&&e.fontFamily===this.node.fontFamily&&e.fontSize===r&&e.fontStyle===this.node.fontStyle&&e.fontWeight===this.node.fontWeight&&e.letterSpacing===this.node.letterSpacing&&e.fill===null&&e.stroke===null}set(e){let r=this.overrides;for(let n of Object.keys(e)){let o=e[n];o!==void 0&&(n==="fill"?r.fill=q.resolve(o):n==="stroke"?r.stroke=_e.resolve(o):(Cp.has(n)||typeof o=="number")&&(r[n]=o))}return this}to(e){return ks(this,e.data??{},e.duration,e.easing)}_prepareStep(e,r,n){let o=this.overrides,s=[],i=[];for(let c of Object.keys(e)){let d=e[c];if(d!==void 0){if(c==="fill"){let u=o.fill??this.node.fill,f=q.resolve(d);i.push(h=>{o.fill=q.lerp(u,f,h)})}else if(c==="stroke"){let u=o.stroke??this.node.stroke,f=_e.resolve(d);i.push(h=>{o.stroke=_e.lerp(u,f,h)})}else if(Cp.has(c)){let u=d,f=o[c];i.push(h=>{o[c]=h>=1?u:f})}else if(typeof d=="number"){let u=c;s.push({key:u,from:o[u],to:d})}}}let a=c=>{let d=n?n(c):c;for(let u of s)o[u.key]=u.from+(u.to-u.from)*d;for(let u of i)u(d)},l=0;return{seek:c=>a(r>0?Math.min(c/r,1):1),advance:c=>(l+=c,l<r?(a(l/r),!1):(a(1),!0))}}};xx([P()],nt.prototype,"to",null);function _x(t,e){let r=t.map(o=>({start:Math.max(0,Math.min(o.start,e)),end:Math.max(0,Math.min(o.end,e))})).filter(o=>o.end>o.start).sort((o,s)=>o.start-s.start),n=[];for(let o of r){let s=n[n.length-1];s&&o.start<=s.end?s.end=Math.max(s.end,o.end):n.push({...o})}return n}var ot=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},ye=class extends me{get wrapsText(){return!1}get glyphPath(){return null}styledRuns(){return[]}styleRuns(){return[]}resolveContext(e){Gs(this,this._props)}applyDefaultSize(e){let r=e?.fontSize==="autofit";this.applyProp("height",e?.height??(r?"fill":"hug")),this.applyProp("width",e?.width??(r?"fill":"hug"))}measure(e,r){let n=this.glyphPath;if(n!=null){let{width:x,height:_}=be.size(n),S=this.width,b=this.height;return{width:typeof S=="number"?S:S==="hug"?x:e.maxWidth??x,height:typeof b=="number"?b:b==="hug"?_:e.maxHeight??_}}let o=this.fontSize==="autofit"?16:this.fontSize,s=this._casedText().split(`
2
- `),i=this.buildSegments(),a=i===null?null:wx(i,{fontFamily:this.fontFamily,fontSize:o,fontStyle:this.fontStyle,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing}),l=o*this.lineHeight,c=Math.max(...a?a.map(x=>x.runs.reduce((_,S)=>_+r.measureText(S.text,S.fontSize,S.fontFamily,S.fontWeight,S.letterSpacing,S.fontStyle).width,0)):s.map(x=>r.measureText(x,o,this.fontFamily,this.fontWeight,this.letterSpacing,this.fontStyle).width)),d=this.width,u=this.height,f=typeof d=="number"?d:d==="hug"?c:e.maxWidth??0,h=this.wrapsText&&f>0,y=a===null?null:h?vx(a,f,r):a.map(x=>Math.max(...x.runs.map(_=>_.fontSize))),w=y?y.reduce((x,_)=>x+_*this.lineHeight,0):(h?s.reduce((x,_)=>x+Sx(_,f,o,this.fontFamily,this.fontWeight,r,this.letterSpacing,this.fontStyle),0):s.length)*l;return{width:f,height:typeof u=="number"?u:w}}buildSegments(){if(this.glyphPath!=null)return null;let e=this.styledRuns().filter(u=>u.ranges.length>0&&!u.isIdentity),r=this.styleRuns().filter(u=>u.end>u.start),n=this._casedText();if(n.length===0)return null;let o=this.start>0||this.end<1;if(e.length===0&&r.length===0&&!o)return null;let s=Math.round(this.start*n.length),i=Math.round(this.end*n.length),a=typeof this.fontSize=="number"?this.fontSize:Us,l=new Set([0,n.length]);for(let u of r)l.add(u.start),l.add(u.end);for(let u of e)for(let f of u.ranges)l.add(f.start),l.add(f.end);o&&(l.add(s),l.add(i));let c=[...l].filter(u=>u>=0&&u<=n.length).sort((u,f)=>u-f),d=[];for(let u=0;u<c.length-1;u++){let f=c[u],h=c[u+1];if(h<=f)continue;let y={text:n.slice(f,h),fontFamily:this.fontFamily,fontSize:a,fontStyle:this.fontStyle,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,textDecoration:this.textDecoration,opacity:1,x:0,y:0,scale:1,rotation:0,fill:this.fill,stroke:this.stroke};for(let w of r)f<w.start||h>w.end||(w.fontFamily!==void 0&&(y.fontFamily=w.fontFamily),w.fontSize!==void 0&&(y.fontSize=w.fontSize),w.fontStyle!==void 0&&(y.fontStyle=w.fontStyle),w.fontWeight!==void 0&&(y.fontWeight=w.fontWeight),w.letterSpacing!==void 0&&(y.letterSpacing=w.letterSpacing),w.textDecoration!==void 0&&(y.textDecoration=w.textDecoration),w.fill!==void 0&&(y.fill=w.fill),w.stroke!==void 0&&(y.stroke=w.stroke));for(let w of e){if(!w.ranges.some(x=>f>=x.start&&h<=x.end))continue;let g=w.overrides;y.opacity*=g.opacity,y.x=g.x,y.y=g.y,y.scale=g.scale,y.rotation=g.rotation,g.fontFamily!==this.fontFamily&&(y.fontFamily=g.fontFamily),g.fontSize!==a&&(y.fontSize=g.fontSize),g.fontStyle!==this.fontStyle&&(y.fontStyle=g.fontStyle),g.fontWeight!==this.fontWeight&&(y.fontWeight=g.fontWeight),g.letterSpacing!==this.letterSpacing&&(y.letterSpacing=g.letterSpacing),g.fill!==null&&(y.fill=g.fill),g.stroke!==null&&(y.stroke=g.stroke)}o&&!(f>=s&&h<=i)&&(y.opacity=0),d.push(y)}return d}declareAssets(e){super.declareAssets(e),this.fontFamily&&e.font(this.fontFamily,this.fontWeight);for(let r of this.buildSegments()??[]){let n=r.fontFamily??this.fontFamily;n&&e.font(n,r.fontWeight),e.fill(r.fill??[]);for(let o of r.stroke??[])e.fill(o.fill)}}_textState(){return{text:this._casedText(),fontSize:this.fontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontStyle:this.fontStyle,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,textAlign:this.textAlign,verticalAlign:this.verticalAlign,textDecoration:this.textDecoration,wrap:this.wrapsText,minFontSize:this.minFontSize,width:this.layoutBounds?.width??0,height:this.layoutBounds?.height??0,segments:this.buildSegments()??void 0,path:this.glyphPath}}textOpGraphics(){let e=this._textState();return{g:new B().text(e),segments:e.segments!=null}}renderSelf(e){let{g:r,segments:n}=this.textOpGraphics();r.shadow(this.shadow),n||r.fill(this.fill),e.draw(r)}renderStroke(e){let r=this.stroke;if(r.length===0)return;let{g:n,segments:o}=this.textOpGraphics();o||e.draw(n.stroke(r))}_casedText(){return oe.applyCase(this.displayText(),this.textCase)}};ot([p()],ye.prototype,"fontFamily",void 0);ot([p({default:48,tween:oe.lerpFontSize})],ye.prototype,"fontSize",void 0);ot([p({default:400})],ye.prototype,"fontWeight",void 0);ot([p({default:"normal"})],ye.prototype,"fontStyle",void 0);ot([p({default:0})],ye.prototype,"letterSpacing",void 0);ot([p({default:1.2})],ye.prototype,"lineHeight",void 0);ot([p({default:"center"})],ye.prototype,"textAlign",void 0);ot([p({default:"center",kind:"enum",options:["top","center","bottom"]})],ye.prototype,"verticalAlign",void 0);ot([p({default:"none",kind:"enum",options:["none","underline","line-through"]})],ye.prototype,"textDecoration",void 0);ot([p({default:"none",kind:"enum",options:["none","upper","lower","title"]})],ye.prototype,"textCase",void 0);ot([p({default:12})],ye.prototype,"minFontSize",void 0);ot([p({default:void 0})],ye.prototype,"variant",void 0);function wx(t,e){let r=[{runs:[]}];for(let n of t){let o={fontFamily:n.fontFamily??e.fontFamily,fontSize:n.fontSize??e.fontSize,fontStyle:n.fontStyle??e.fontStyle,fontWeight:n.fontWeight,letterSpacing:n.letterSpacing},s=n.text.split(`
3
- `);for(let i=0;i<s.length;i++)i>0&&r.push({runs:[]}),r[r.length-1].runs.push({text:s[i],...o})}for(let n of r)n.runs.length===0&&n.runs.push({...e,text:""});return r}function vx(t,e,r){let n=[];for(let o of t){let s=[];for(let l of o.runs)for(let c of l.text.split(/(\s+)/)){if(c.length===0)continue;let d=/^\s+$/.test(c),u=r.measureText(c,l.fontSize,l.fontFamily,l.fontWeight,l.letterSpacing,l.fontStyle).width,f=s[s.length-1];f&&!f.space&&!d?(f.width+=u,f.size=Math.max(f.size,l.fontSize)):s.push({width:u,size:l.fontSize,space:d})}if(s.length===0){n.push(Math.max(...o.runs.map(l=>l.fontSize)));continue}let i=s[0].width,a=s[0].size;for(let l of s.slice(1))i+l.width<=e?(i+=l.width,a=Math.max(a,l.size)):(n.push(a),i=l.space?0:l.width,a=l.space?0:l.size);n.push(a>0?a:Math.max(...o.runs.map(l=>l.fontSize)))}return n}function Sx(t,e,r,n,o,s,i=0,a="normal"){if(t.length===0||s.measureText(t,r,n,o,i,a).width<=e)return 1;let l=t.split(/(\s+)/).filter(u=>u.length>0),c=1,d=0;for(let u of l){let f=s.measureText(u,r,n,o,i,a).width;d===0?d=f:d+f<=e?d+=f:(c++,d=/^\s+$/.test(u)?0:f)}return c}var $t=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Ue=class extends me{constructor(e){super(e)}resolveContext(e){Gs(this,this._props,{autofit:!1})}applyDefaultSize(e){this.applyProp("height",e?.height??"hug"),this.applyProp("width",e?.width??"hug")}runs(){return oe.flatten(this.spans,{fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,letterSpacing:this.letterSpacing,fill:this.fill,stroke:this.stroke})}declareAssets(e){super.declareAssets(e);for(let r of this.runs()){r.fontFamily&&e.font(r.fontFamily,r.fontWeight),e.fill(r.fill);for(let n of r.stroke)e.fill(n.fill)}}measure(e,r){let n=this.runs(),o=0,s=0,i=0,a=0,l=()=>{o>i&&(i=o),a+=s,o=0,s=0};for(let h of n){let y=h.fontSize*this.lineHeight,w=h.text.split(`
4
- `);for(let g=0;g<w.length;g++)g>0&&l(),o+=r.measureText(w[g],h.fontSize,h.fontFamily,h.fontWeight,h.letterSpacing,h.fontStyle).width,y>s&&(s=y)}l(),a===0&&(a=this.fontSize*this.lineHeight);let c=this.width,d=this.height,u=typeof c=="number"?c:c==="hug"?i:e.maxWidth??0,f=typeof d=="number"?d:d==="hug"?a:e.maxHeight??0;return{width:u,height:f}}renderSelf(e){e.draw(new B().richText({spans:this.runs(),lineHeight:this.lineHeight,textAlign:this.textAlign,width:this.layoutBounds?.width??0,height:this.layoutBounds?.height??0}))}};$t([p({default:[],mapper:t=>t==null?[]:Array.isArray(t)?t:[t]})],Ue.prototype,"spans",void 0);$t([p()],Ue.prototype,"fontFamily",void 0);$t([p({default:48})],Ue.prototype,"fontSize",void 0);$t([p({default:400})],Ue.prototype,"fontWeight",void 0);$t([p({default:"normal"})],Ue.prototype,"fontStyle",void 0);$t([p({default:0})],Ue.prototype,"letterSpacing",void 0);$t([p({default:1.2})],Ue.prototype,"lineHeight",void 0);$t([p({default:"center"})],Ue.prototype,"textAlign",void 0);$t([p({default:void 0})],Ue.prototype,"variant",void 0);var mn=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s};function bx(t){return t==null?null:t instanceof Je?t.toCommands():t}function kx(t){return Array.isArray(t)?t.map(({fill:e,stroke:r,...n})=>({...n,...e===void 0?{}:{fill:q.resolve(e)},...r===void 0?{}:{stroke:_e.resolve(r)}})):[]}var st=class extends ye{constructor(e){super(e)}displayText(){return this.text}get wrapsText(){return this.wrap}get glyphPath(){return this.path}styledRuns(){return this._selections}styleRuns(){return this.runs}applyDefaultSize(e){let r=e?.fontSize==="autofit";this.applyProp("height",e?.height??(r?"fill":"hug")),this.applyProp("width",e?.width??(r||e?.wrap?"fill":"hug"))}append(e){let r=e.data.text;return this.to({data:{text:this.text+r},duration:e.duration,easing:e.easing})}prepend(e){let r=e.data.text;return this.to({data:{text:r+this.text},duration:e.duration,easing:e.easing})}_selections=[];_registerSelection(e){this._selections.push(e)}find(e,r){let n=this.text,o=[];if(e.length>0){let a=0,l;for(;(l=n.indexOf(e,a))!==-1;)o.push({start:l,end:l+e.length}),a=l+e.length}let s=r?.index??0,i=o[s]?[o[s]]:[];return new nt(this,i)}match(e){let r=e.flags.includes("g")?e.flags:e.flags+"g",n=new RegExp(e.source,r),o=[],s;for(;(s=n.exec(this.text))!==null;){if(s[0].length===0){n.lastIndex++;continue}o.push({start:s.index,end:s.index+s[0].length})}return new nt(this,o)}line(e){let r=this.text.split(`
5
- `),n=0;for(let o=0;o<r.length;o++){let s=r[o].length;if(o===e)return new nt(this,[{start:n,end:n+s}]);n+=s+1}return new nt(this,[])}words(){return new nt(this,this._wordRanges())}word(e){let r=this._wordRanges()[e];return new nt(this,r?[r]:[])}slice(e,r){return new nt(this,[{start:e,end:r}])}filter(e){let r=[],n=-1;for(let o=0;o<this.text.length;o++)e(this.text[o],o)?n===-1&&(n=o):n!==-1&&(r.push({start:n,end:o}),n=-1);return n!==-1&&r.push({start:n,end:this.text.length}),new nt(this,r)}_wordRanges(){let e=[],r=/\S+/g,n;for(;(n=r.exec(this.text))!==null;)e.push({start:n.index,end:n.index+n[0].length});return e}};mn([Va()],st.prototype,"text",void 0);mn([p({default:!1})],st.prototype,"wrap",void 0);mn([p({default:null,mapper:bx})],st.prototype,"path",void 0);mn([p({default:[],mapper:kx,animatable:!1})],st.prototype,"runs",void 0);mn([P({args:[{key:"text",kind:"text",default:"",multiline:!0}]})],st.prototype,"append",null);mn([P({args:[{key:"text",kind:"text",default:"",multiline:!0}]})],st.prototype,"prepend",null);var Nr=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},dt=class extends ye{constructor(e){super(e)}displayText(){return this.formatted()}formatted(){return Ac(this.value,Mc(this))}countTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}};Nr([p({default:0})],dt.prototype,"value",void 0);Nr([p({default:"number"})],dt.prototype,"format",void 0);Nr([p({default:""})],dt.prototype,"customPattern",void 0);Nr([p({default:0})],dt.prototype,"fractionDigits",void 0);Nr([p({default:!0})],dt.prototype,"grouped",void 0);Nr([p({default:"$"})],dt.prototype,"currencySymbol",void 0);Nr([P({args:[{key:"value",kind:"number"}]})],dt.prototype,"countTo",null);var Ax=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},fo=class extends A{constructor(e){super(e),this._writeProp("rotation",()=>this.angle)}measure(e,r){this.lastMeasure={constraints:e,measurer:r};let n=this.angle*(Math.PI/180),o=Math.abs(Math.cos(n)),s=Math.abs(Math.sin(n)),i=Math.abs(this.angle%180)===90,a={maxWidth:e.maxWidth!==void 0&&e.maxHeight!==void 0?e.maxWidth*o+e.maxHeight*s:i?e.maxHeight:e.maxWidth,maxHeight:e.maxWidth!==void 0&&e.maxHeight!==void 0?e.maxWidth*s+e.maxHeight*o:i?e.maxWidth:e.maxHeight},l=0,c=0;for(let f of this.flowChildren()){let h=f.measure(a,r);(h.width??0)>l&&(l=h.width??0),(h.height??0)>c&&(c=h.height??0)}let d=l*o+c*s,u=l*s+c*o;return{width:this.resolveSizeInput(this.width,e.maxWidth??0,d),height:this.resolveSizeInput(this.height,e.maxHeight??0,u)}}layoutChildren(e,r){let n=this.angle*(Math.PI/180),o=Math.abs(Math.cos(n)),s=Math.abs(Math.sin(n)),i={x:e.x,y:e.y,width:e.width*o+e.height*s,height:e.width*s+e.height*o};super.layoutChildren(i,r)}};Ax([p({default:-90})],fo.prototype,"angle",void 0);var fe=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},te=class extends wt{_video=null;_videoKey="";constructor(e){super(e)}playedAt(e){let r=this.segments;if(!r||r.length===0)return null;let n=0;for(let o of r){if(e<=o.at)break;let s=o.speed??this.speed??1;n+=Math.min(e-o.at,o.duration)*s}return n}scheduledTimestamp(){let e=this.playedAt(this.time.elapsed);if(e===null)return;let r=this.trimStart??0,n=this.segments[0],o=n?n.from-r:0;return ra(e+o,r,this.trimEnd??1/0,this.loop,this.duration)}videoKey(){let e=this.crop,r=this.anchor;return[this.src??"",this.fit??"",this.zoom,this.playing?1:0,e.left,e.right,e.top,e.bottom,r.x,r.y,this.timestamp??"",this.trimStart??"",this.trimEnd??"",this.speed??"",this.loop??"",this.duration??"",this.scheduledTimestamp()??""].join("|")}syncVideo(){if(!this.src){this._video=null,this._videoKey="";return}let e=this.videoKey();if(e===this._videoKey&&this._video)return;this._videoKey=e;let r={type:"video",src:this.src,fit:this.fit,crop:this.crop,zoom:this.zoom,anchor:this.anchor,matrix:this.matrix,filters:this.filters,playing:this.playing,timestamp:this.timestamp??this.scheduledTimestamp(),trimStart:this.trimStart,trimEnd:this.trimEnd,speed:this.speed,loop:this.loop,duration:this.duration};this._video=Ht(r)}declareAssets(e){super.declareAssets(e),this.src&&e.fill(Ht({type:"video",src:this.src,filters:this.filters,trimStart:this.trimStart,trimEnd:this.trimEnd}))}declareAudio(e){let r=this.src;if(!r||this.muted)return;let n=this._busPath(e);if(this.segments.length>0){let s=this.trimEnd??e.catalog.getMediaDuration(r);for(let i of this.segments){let a=i.speed??this.speed??1,l=i.from,c=Math.min(s,l+i.duration*a);c>l&&e.clip({src:r,at:e.span.start+i.at,volume:i.volume??this.volume,trimStart:l,trimEnd:c,filters:this._soundFilters(a),bus:n,optional:!0})}return}if(!this.playing)return;let o=(this.loop??"none")!=="none";e.clip({src:r,volume:this.volume,loop:o,trimStart:this.trimStart,trimEnd:this.trimEnd??(o?void 0:e.catalog.getMediaDuration(r)),filters:this._soundFilters(this.speed??1),bus:n,optional:!0})}_soundFilters(e){let r=[];return e!==1&&r.push(...yt(ln.speed(e))),r.push(...this.audioFilters),r}_busPath(e){if(!this.bus)return;let r=sl(this,this.bus);return r?ol(r,e):void 0}rectState(){return{width:this.layoutBounds.width,height:this.layoutBounds.height,cornerRadius:this.cornerRadius,cornerStyle:this.cornerStyle,start:this.start,end:this.end}}shapeGraphics(){return new B().rect(this.rectState())}renderOverlay(e){let r=this.overlay;if(r.length===0)return;let n=(this.syncVideo(),this._video);n&&e.draw(new B().mask().rect(this.rectState()).fill([n]).applyMask().rect(this.rectState()).fill(r).endMask())}renderSelf(e){this.syncVideo();let r=[this._video??Mu];r.push(...this.fill),e.draw(this.shapeGraphics().shadow(this.shadow).fill(r))}dispose(){this._video=null,this._videoKey="",super.dispose()}};fe([p()],te.prototype,"src",void 0);fe([p()],te.prototype,"fit",void 0);fe([no()],te.prototype,"crop",void 0);fe([p({default:1})],te.prototype,"zoom",void 0);fe([Rt()],te.prototype,"anchor",void 0);fe([p()],te.prototype,"matrix",void 0);fe([p({default:[],tween:Wn,mapper:Vn})],te.prototype,"filters",void 0);fe([p({default:!0})],te.prototype,"playing",void 0);fe([p()],te.prototype,"timestamp",void 0);fe([p()],te.prototype,"trimStart",void 0);fe([p()],te.prototype,"trimEnd",void 0);fe([p()],te.prototype,"speed",void 0);fe([p()],te.prototype,"loop",void 0);fe([p()],te.prototype,"duration",void 0);fe([p({default:1})],te.prototype,"volume",void 0);fe([p({default:!1})],te.prototype,"muted",void 0);fe([p({default:[],mapper:yt})],te.prototype,"audioFilters",void 0);fe([p({default:void 0})],te.prototype,"bus",void 0);fe([p({default:[]})],te.prototype,"segments",void 0);var Mx=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},yn=class extends Pe{};Mx([p({default:!1})],yn.prototype,"solo",void 0);var po=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},St=class extends Pe{declareAudio(e){this.src&&e.clip({src:this.src,trimStart:this.trimStart,trimEnd:this.trimEnd,loop:this.loop,filters:this._filterChain(),bus:Bs(this,e)})}acceptsChild(e){return!1}_filterChain(){let r=[...this.filters],n=this.volume;return(wa(n,1)!==1||typeof n!="number")&&r.push(...ln.gain(n)),this.speed!==1&&r.push(...ln.speed(this.speed)),r}};po([p()],St.prototype,"src",void 0);po([p({default:0})],St.prototype,"trimStart",void 0);po([p({default:void 0})],St.prototype,"trimEnd",void 0);po([p({default:!1})],St.prototype,"loop",void 0);po([p({default:1})],St.prototype,"speed",void 0);var ge=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s};function gl(t){let e=t.parent;return typeof e?._spaceOf=="function"?e._spaceOf(t):null}var Pp={position:["x","y","z"],rotation:["rotationX","rotationY","rotationZ"],scale:["scaleX","scaleY","scaleZ"]},I=class t extends he{get dimension(){return"3d"}constructor(e){super(e),this.initProps(ml(e)),this.adoptChildrenProp(e)}moveTo(e){return this.to({data:yl(e.data),duration:e.duration,easing:e.easing})}rotateTo(e){return this.to({data:yl(e.data),duration:e.duration,easing:e.easing})}scaleTo(e){return this.to({data:yl(e.data),duration:e.duration,easing:e.easing})}get position(){return{x:this.x,y:this.y,z:this.z}}set position(e){this.set({position:e})}get rotation(){return{x:this.rotationX,y:this.rotationY,z:this.rotationZ,order:this.rotationOrder}}set rotation(e){this.set({rotation:e})}get scale(){return{x:this.scaleX,y:this.scaleY,z:this.scaleZ}}set scale(e){this.set({scale:e})}set(e){super.set(ml(e))}_prepareStep(e,r,n){return super._prepareStep(ml(e),r,n)}transform3D(){let e=this.quaternion,r=e.x===0&&e.y===0&&e.z===0&&e.w===1,n=gl(this);return{position:n?n.toLocal(this.x,this.y,this.z):this.position,rotation:this.rotation,quaternion:r?void 0:e,scale:this.scale,lookAt:this.lookAt,visible:this.visible,shadow:this.shadow,renderOrder:this.renderOrder}}_spaceOf(e){return null}groupTransform(){return this.transform3D()}renderSelf(e){}render(e){if(this.hidden){e.begin({id:this.id,transform:{...this.groupTransform(),visible:!1}}),e.end();return}e.begin({id:this.id,transform:this.groupTransform()}),this.renderSelf(e);for(let r of this._children)r instanceof t&&r.render(e);e.end()}declareAssets(e){if(this.renderSelf===t.prototype.renderSelf)return;let r=new Ve;this.renderSelf(r),sn(r,e)}};ge([p({default:0})],I.prototype,"x",void 0);ge([p({default:0})],I.prototype,"y",void 0);ge([p({default:0})],I.prototype,"z",void 0);ge([p({default:0})],I.prototype,"rotationX",void 0);ge([p({default:0})],I.prototype,"rotationY",void 0);ge([p({default:0})],I.prototype,"rotationZ",void 0);ge([p({default:"XYZ"})],I.prototype,"rotationOrder",void 0);ge([Pf()],I.prototype,"quaternion",void 0);ge([p({default:1})],I.prototype,"scaleX",void 0);ge([p({default:1})],I.prototype,"scaleY",void 0);ge([p({default:1})],I.prototype,"scaleZ",void 0);ge([Cr("snap")],I.prototype,"lookAt",void 0);ge([p({default:!0})],I.prototype,"visible",void 0);ge([p({default:!0})],I.prototype,"shadow",void 0);ge([p({default:0})],I.prototype,"renderOrder",void 0);ge([P({args:["x","y","z"]})],I.prototype,"moveTo",null);ge([P({args:["rotationX","rotationY","rotationZ"]})],I.prototype,"rotateTo",null);ge([P({args:[{key:"scale",kind:"number",min:0,step:.05,unit:"\xD7"},"scaleX","scaleY","scaleZ"]})],I.prototype,"scaleTo",null);function ml(t){if(!t)return t;let e;for(let r in Pp){let n=t[r];if(n===void 0)continue;e??={...t},delete e[r];let o=Pp[r];if(typeof n=="function"){let i=n;for(let a=0;a<3;a++){let l=o[a];e[l]===void 0&&(e[l]=()=>Tp(de(i()),a))}continue}let s=de(n);for(let i=0;i<3;i++){let a=o[i];e[a]===void 0&&(e[a]=Tp(s,i))}if(r==="rotation"){let i=n.order;i!==void 0&&e.rotationOrder===void 0&&(e.rotationOrder=i)}}return e??t}function yl(t){let e={};for(let r in t)t[r]!==void 0&&(e[r]=t[r]);return e}function Tp(t,e){return e===0?t.x:e===1?t.y:t.z}var Xs=class extends I{};var ie=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Ox=["opacity","roughness","metalness","emission","emissionStrength","normalMap","roughnessMap","metalnessMap","aoMap","alphaMap","envMapIntensity","wireframe","shading","faces","vertexColors","blend"],F=class extends I{buildGeometry(){return this.geometry}materialShorthand(){let e={},r=this.material;r!==void 0&&(e.material=r),this.fill!==void 0&&(e.fill=this.fill);for(let n of Ox){let o=this[n];o!==void 0&&(e[n]=o)}return this.unlit&&(e.unlit=!0),e}buildGraphics3D(){let e=new Fe,r=this.buildGeometry();return r&&e.mesh(r,on(this.materialShorthand())),e}renderSelf(e){e.draw(this.buildGraphics3D())}};ie([p({default:void 0})],F.prototype,"geometry",void 0);ie([p({default:void 0})],F.prototype,"material",void 0);ie([p({default:"white",tween:es})],F.prototype,"fill",void 0);ie([p({default:void 0})],F.prototype,"opacity",void 0);ie([p({default:void 0})],F.prototype,"roughness",void 0);ie([p({default:void 0})],F.prototype,"metalness",void 0);ie([Ye({default:void 0})],F.prototype,"emission",void 0);ie([p({default:void 0})],F.prototype,"emissionStrength",void 0);ie([p({default:void 0})],F.prototype,"normalMap",void 0);ie([p({default:void 0})],F.prototype,"roughnessMap",void 0);ie([p({default:void 0})],F.prototype,"metalnessMap",void 0);ie([p({default:void 0})],F.prototype,"aoMap",void 0);ie([p({default:void 0})],F.prototype,"alphaMap",void 0);ie([p({default:void 0})],F.prototype,"envMapIntensity",void 0);ie([p({default:void 0})],F.prototype,"wireframe",void 0);ie([p({default:void 0})],F.prototype,"shading",void 0);ie([p({default:void 0})],F.prototype,"faces",void 0);ie([p({default:void 0})],F.prototype,"vertexColors",void 0);ie([p({default:void 0})],F.prototype,"blend",void 0);ie([p({default:!1})],F.prototype,"unlit",void 0);var E=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s};function Ne(t,e,r){let n={type:t};for(let o of r){let s=e[o];s!==void 0&&(n[o]=s)}return n}var Lr=["startAngle","sweep"],Ex=["width","height","depth","cornerRadius","segments"],jt=class extends F{buildGeometry(){return Ne("box",this,Ex)}};E([p({default:void 0})],jt.prototype,"width",void 0);E([p({default:void 0})],jt.prototype,"height",void 0);E([p({default:void 0})],jt.prototype,"depth",void 0);E([p({default:void 0})],jt.prototype,"cornerRadius",void 0);E([p({default:void 0})],jt.prototype,"segments",void 0);var Cx=["radius","segments","startLatitude","latitudeSweep",...Lr],bt=class extends F{buildGeometry(){return Ne("sphere",this,Cx)}};E([p({default:void 0})],bt.prototype,"radius",void 0);E([p({default:void 0})],bt.prototype,"segments",void 0);E([p({default:void 0})],bt.prototype,"startAngle",void 0);E([p({default:void 0})],bt.prototype,"sweep",void 0);E([p({default:void 0})],bt.prototype,"startLatitude",void 0);E([p({default:void 0})],bt.prototype,"latitudeSweep",void 0);var Px=["width","height","segments"],$r=class extends F{buildGeometry(){return Ne("plane",this,Px)}};E([p({default:void 0})],$r.prototype,"width",void 0);E([p({default:void 0})],$r.prototype,"height",void 0);E([p({default:void 0})],$r.prototype,"segments",void 0);var Tx=["radius","height","segments","capped",...Lr],kt=class extends F{buildGeometry(){return Ne("cylinder",this,Tx)}};E([p({default:void 0})],kt.prototype,"radius",void 0);E([p({default:void 0})],kt.prototype,"height",void 0);E([p({default:void 0})],kt.prototype,"segments",void 0);E([p({default:void 0})],kt.prototype,"capped",void 0);E([p({default:void 0})],kt.prototype,"startAngle",void 0);E([p({default:void 0})],kt.prototype,"sweep",void 0);var Dx=["radius","height","segments","capped",...Lr],At=class extends F{buildGeometry(){return Ne("cone",this,Dx)}};E([p({default:void 0})],At.prototype,"radius",void 0);E([p({default:void 0})],At.prototype,"height",void 0);E([p({default:void 0})],At.prototype,"segments",void 0);E([p({default:void 0})],At.prototype,"capped",void 0);E([p({default:void 0})],At.prototype,"startAngle",void 0);E([p({default:void 0})],At.prototype,"sweep",void 0);var Rx=["radius","thickness","segments",...Lr],Bt=class extends F{buildGeometry(){return Ne("torus",this,Rx)}};E([p({default:void 0})],Bt.prototype,"radius",void 0);E([p({default:void 0})],Bt.prototype,"thickness",void 0);E([p({default:void 0})],Bt.prototype,"segments",void 0);E([p({default:void 0})],Bt.prototype,"startAngle",void 0);E([p({default:void 0})],Bt.prototype,"sweep",void 0);var Fx=["radius","thickness","segments","windings"],ir=class extends F{buildGeometry(){return Ne("torusKnot",this,Fx)}};E([p({default:void 0})],ir.prototype,"radius",void 0);E([p({default:void 0})],ir.prototype,"thickness",void 0);E([p({default:void 0})],ir.prototype,"segments",void 0);E([p({default:void 0})],ir.prototype,"windings",void 0);var Ix=["radius","segments",...Lr],ar=class extends F{buildGeometry(){return Ne("circle",this,Ix)}};E([p({default:void 0})],ar.prototype,"radius",void 0);E([p({default:void 0})],ar.prototype,"segments",void 0);E([p({default:void 0})],ar.prototype,"startAngle",void 0);E([p({default:void 0})],ar.prototype,"sweep",void 0);var zx=["radius","innerRadius","segments",...Lr],Lt=class extends F{buildGeometry(){return Ne("ring",this,zx)}};E([p({default:void 0})],Lt.prototype,"radius",void 0);E([p({default:void 0})],Lt.prototype,"innerRadius",void 0);E([p({default:void 0})],Lt.prototype,"segments",void 0);E([p({default:void 0})],Lt.prototype,"startAngle",void 0);E([p({default:void 0})],Lt.prototype,"sweep",void 0);var Nx=["radius","height","segments"],jr=class extends F{buildGeometry(){return Ne("capsule",this,Nx)}};E([p({default:void 0})],jr.prototype,"radius",void 0);E([p({default:void 0})],jr.prototype,"height",void 0);E([p({default:void 0})],jr.prototype,"segments",void 0);var $x=["shape","radius","segments"],Br=class extends F{buildGeometry(){return Ne("polyhedron",this,$x)}};E([p({default:"icosahedron"})],Br.prototype,"shape",void 0);E([p({default:void 0})],Br.prototype,"radius",void 0);E([p({default:void 0})],Br.prototype,"segments",void 0);var jx=["path","depth","segments","bevel"],lr=class extends F{buildGeometry(){return Ne("extrude",this,jx)}};E([p({default:void 0})],lr.prototype,"path",void 0);E([p({default:void 0})],lr.prototype,"depth",void 0);E([p({default:void 0})],lr.prototype,"segments",void 0);E([p({default:void 0})],lr.prototype,"bevel",void 0);var Bx=["points","segments",...Lr],cr=class extends F{buildGeometry(){return Ne("lathe",this,Bx)}};E([p({default:void 0})],cr.prototype,"points",void 0);E([p({default:void 0})],cr.prototype,"segments",void 0);E([p({default:void 0})],cr.prototype,"startAngle",void 0);E([p({default:void 0})],cr.prototype,"sweep",void 0);var Lx=["points","radius","segments","closed"],dr=class extends F{buildGeometry(){return Ne("tube",this,Lx)}};E([p({default:void 0})],dr.prototype,"points",void 0);E([p({default:void 0})],dr.prototype,"radius",void 0);E([p({default:void 0})],dr.prototype,"segments",void 0);E([p({default:void 0})],dr.prototype,"closed",void 0);var ve=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},gn=class extends F{buildGraphics3D(){let e=new Fe,r=this.buildGeometry(),n=this.instances;return!r||!n?.length||e.instances(r,this.resolvedMaterial(),n,{colors:this.colors}),e}resolvedMaterial(){let e=on(this.materialShorthand());return Array.isArray(e)?e[0]:e}};ve([p({default:void 0})],gn.prototype,"instances",void 0);ve([p({default:void 0})],gn.prototype,"colors",void 0);var Wx=["opacity","alphaMap","blend","vertexColors"],Zs=class extends F{buildGraphics3D(){let e=new Fe,r=this.buildGeometry();return r&&e.points(r,this.pointsMaterial()),e}pointsMaterial(){let e=this.material;if(e!==void 0)return Array.isArray(e)?e[0]:e;let r={type:"points"},n=nn(this.fill);n.color!==void 0&&(r.color=n.color),n.map!==void 0&&(r.map=n.map);for(let o of Wx){let s=this[o];s!==void 0&&(r[o]=s)}return r}},ut=class extends I{buildGraphics3D(){let e=new Fe,r=this.geometry,n=this.points;return!r&&!n?.length||e.line({points:r?void 0:n,geometry:r,closed:this.closed,segments:this.segments,stroke:this.stroke,opacity:this.opacity,material:this.material}),e}renderSelf(e){e.draw(this.buildGraphics3D())}};ve([p({default:void 0})],ut.prototype,"points",void 0);ve([p({default:void 0})],ut.prototype,"geometry",void 0);ve([p({default:!1})],ut.prototype,"closed",void 0);ve([p({default:!1})],ut.prototype,"segments",void 0);ve([p({default:void 0})],ut.prototype,"stroke",void 0);ve([p({default:void 0})],ut.prototype,"opacity",void 0);ve([p({default:void 0})],ut.prototype,"material",void 0);var Wr=class extends I{buildGraphics3D(){return new Fe().sprite({fill:this.fill,opacity:this.opacity,material:this.material})}renderSelf(e){e.draw(this.buildGraphics3D())}};ve([p({default:void 0,tween:es})],Wr.prototype,"fill",void 0);ve([p({default:void 0})],Wr.prototype,"opacity",void 0);ve([p({default:void 0})],Wr.prototype,"material",void 0);var ur=class extends I{buildGraphics3D(){let e=new Fe;return this.src&&e.model({src:this.src,animation:this.animation,override:this.override}),e}renderSelf(e){e.draw(this.buildGraphics3D())}};ve([p({default:void 0})],ur.prototype,"src",void 0);ve([p({default:void 0})],ur.prototype,"animation",void 0);ve([p({default:void 0})],ur.prototype,"override",void 0);var Js=class extends ur{constructor(e){super(e)}buildGraphics3D(){let e=new Fe;return this.src?(e.model({src:this.src,animation:{clip:Vx(this.clip),time:this.clipTime},override:this.override}),e):qx(e)}};ve([p({default:""})],Js.prototype,"clip",void 0);ve([p({default:0})],Js.prototype,"clipTime",void 0);function qx(t){return t.box({width:1,height:1,depth:1,material:{type:"basic",color:"#6b7280",wireframe:!0,transparent:!0,opacity:.7}})}function Vx(t){let e=t.trim();if(e==="")return;let r=Number(e);return Number.isInteger(r)&&r>=0?r:e}var re=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s};function wn(t,e,r){let n={type:t};for(let o of r){let s=e[o];s!==void 0&&(n[o]=s)}return n}var xn=class extends I{declareAssets(){}renderSelf(e){e.light(this.buildLight())}},ho=class extends xn{constructor(e){super(e),e?.shadow===void 0&&this.applyProp("shadow",!1)}},Gx=["color","intensity"],_n=class extends xn{buildLight(){return wn("ambient",this,Gx)}};re([Ye({default:void 0})],_n.prototype,"color",void 0);re([p({default:void 0})],_n.prototype,"intensity",void 0);var Yx=["sky","ground","intensity"],qr=class extends xn{buildLight(){return wn("hemisphere",this,Yx)}};re([Ye({default:void 0})],qr.prototype,"sky",void 0);re([Ye({default:void 0})],qr.prototype,"ground",void 0);re([p({default:void 0})],qr.prototype,"intensity",void 0);var Kx=["color","intensity","target","shadow"],Vr=class extends ho{buildLight(){return wn("directional",this,Kx)}};re([Ye({default:void 0})],Vr.prototype,"color",void 0);re([p({default:void 0})],Vr.prototype,"intensity",void 0);re([Cr("origin")],Vr.prototype,"target",void 0);var Hx=["color","intensity","distance","decay","shadow"],fr=class extends ho{buildLight(){return wn("point",this,Hx)}};re([Ye({default:void 0})],fr.prototype,"color",void 0);re([p({default:void 0})],fr.prototype,"intensity",void 0);re([p({default:void 0})],fr.prototype,"distance",void 0);re([p({default:void 0})],fr.prototype,"decay",void 0);var Ux=["color","intensity","distance","angle","penumbra","decay","target","shadow"],ft=class extends ho{buildLight(){return wn("spot",this,Ux)}};re([Ye({default:void 0})],ft.prototype,"color",void 0);re([p({default:void 0})],ft.prototype,"intensity",void 0);re([p({default:void 0})],ft.prototype,"distance",void 0);re([p({default:void 0})],ft.prototype,"angle",void 0);re([p({default:void 0})],ft.prototype,"penumbra",void 0);re([p({default:void 0})],ft.prototype,"decay",void 0);re([Cr("origin")],ft.prototype,"target",void 0);var Xx=["color","intensity","width","height"],pr=class extends xn{buildLight(){return wn("area",this,Xx)}};re([Ye({default:void 0})],pr.prototype,"color",void 0);re([p({default:void 0})],pr.prototype,"intensity",void 0);re([p({default:void 0})],pr.prototype,"width",void 0);re([p({default:void 0})],pr.prototype,"height",void 0);var Gr={orbit:0,elevation:0,distance:10};function Dp(t){return t.orbit!==void 0||t.elevation!==void 0||t.distance!==void 0}function xl(t){let e=de(t.target??0);if(!Dp(t)){let i=t.lookAt??t.target;return{position:de(t.position??0),lookAt:i===void 0?void 0:de(i)}}let r=t.distance??Gr.distance,n=(t.orbit??Gr.orbit)*Math.PI/180,o=Zx(t.elevation??Gr.elevation,-89.9,89.9)*Math.PI/180,s=Math.cos(o)*r;return{position:{x:e.x+Math.sin(n)*s,y:e.y+Math.sin(o)*r,z:e.z+Math.cos(n)*s},lookAt:e}}function Zx(t,e,r){return t<e?e:t>r?r:t}var it=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Jx=["target","orbit","elevation","distance","fov","frustumHeight","near","far","zoom"],Oe=class extends I{orbitTo(e){let r=e.data??{},n={orbit:this.orbit??Gr.orbit,elevation:this.elevation??Gr.elevation,distance:this.distance??Gr.distance};return this.command(o=>{let s={};for(let i of["orbit","elevation","distance"]){let a=r[i];a!==void 0&&(s[i]=n[i]+(a-n[i])*o)}return s},e.duration,e.easing)}lookTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}groupTransform(){return{}}buildCamera(){let e={type:this.type};for(let r of Jx){let n=this[r];n!==void 0&&(e[r]=n)}return e}declareAssets(){}renderSelf(e){e.camera({...this.transform3D(),...this.buildCamera()})}};it([p({default:"perspective"})],Oe.prototype,"type",void 0);it([Cr("origin")],Oe.prototype,"target",void 0);it([p({default:void 0})],Oe.prototype,"orbit",void 0);it([p({default:void 0})],Oe.prototype,"elevation",void 0);it([p({default:void 0})],Oe.prototype,"distance",void 0);it([p({default:void 0})],Oe.prototype,"fov",void 0);it([p({default:void 0})],Oe.prototype,"frustumHeight",void 0);it([p({default:void 0})],Oe.prototype,"near",void 0);it([p({default:void 0})],Oe.prototype,"far",void 0);it([p({default:void 0})],Oe.prototype,"zoom",void 0);it([P({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",min:-89,max:89,step:1,unit:"\xB0"},{key:"distance",kind:"number",min:.01,step:.1}]})],Oe.prototype,"orbitTo",null);it([P({args:["target"]})],Oe.prototype,"lookTo",null);var Ot=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},hr=class extends I{renderSelf(e){let r={};this.color!==void 0&&(r.color=this.color),this.density!==void 0?r.density=this.density:(this.near!==void 0&&(r.near=this.near),this.far!==void 0&&(r.far=this.far)),e.fog(r)}declareAssets(e){}};Ot([Ye({default:void 0})],hr.prototype,"color",void 0);Ot([p({default:void 0})],hr.prototype,"near",void 0);Ot([p({default:void 0})],hr.prototype,"far",void 0);Ot([p({default:void 0})],hr.prototype,"density",void 0);var Mt=class extends I{buildEnvironment(){let e={},r=!1;return this.src!==void 0&&(e.src=this.src,r=!0),this.faces!==void 0&&(e.faces=this.faces,r=!0),this.preset!==void 0&&(e.preset=this.preset,r=!0),r?(this.intensity!==void 0&&(e.intensity=this.intensity),this.background!==void 0&&(e.background=this.background),this.blur!==void 0&&(e.blur=this.blur),(this.rotationX||this.rotationY||this.rotationZ)&&(e.rotation=[this.rotationX,this.rotationY,this.rotationZ]),e):null}declareAssets(e){ua({src:this.src,faces:this.faces},e)}renderSelf(e){e.environment(this.buildEnvironment())}};Ot([p({default:void 0})],Mt.prototype,"src",void 0);Ot([p({default:void 0})],Mt.prototype,"faces",void 0);Ot([p({default:void 0})],Mt.prototype,"preset",void 0);Ot([p({default:void 0})],Mt.prototype,"intensity",void 0);Ot([p({default:void 0})],Mt.prototype,"background",void 0);Ot([p({default:void 0})],Mt.prototype,"blur",void 0);function Ip(t){let{size:e,divisions:r,majorEvery:n,showAxes:o,fade:s}=t,i=e/2,a=e/r,l=mo(t.minorColor),c=mo(t.majorColor),d=mo(t.axisXColor),u=mo(t.axisZColor),f=mo(t.fadeTo),h=[],y=[],w=(g,x,_,S,b)=>{h.push(g,0,x,_,0,S),Fp(y,b,f,Rp(g,x,i,s)),Fp(y,b,f,Rp(_,S,i,s))};for(let g=0;g<=r;g++){let x=-i+g*a,_=Math.abs(g-r/2);if(Math.abs(x)<a/2&&o)continue;let b=Number.isInteger(_)&&_%n===0?c:l;w(x,-i,x,i,b),w(-i,x,i,x,b)}return o&&(w(-i,0,i,0,d),w(0,-i,0,i,u)),{type:"buffer",position:new Float32Array(h),color:new Float32Array(y),computeNormals:!1,staticData:!0}}function Rp(t,e,r,n){if(n<=0)return 0;let o=Math.hypot(t,e)/r,s=1-n;if(o<=s)return 0;let i=Math.min(1,(o-s)/Math.max(n,1e-6));return i*i}function Fp(t,e,r,n){t.push(e[0]+(r[0]-e[0])*n,e[1]+(r[1]-e[1])*n,e[2]+(r[2]-e[2])*n)}function mo(t){let[e,r,n]=ht(t);return[_l(e),_l(r),_l(n)]}function _l(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}var X=function(t,e,r,n){var o=arguments.length,s=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Qx=async()=>{await la()},j=class t extends wt{gridCache=null;fadeColor(){let e=this.fill;if(Array.isArray(e))for(let r of e){let n=r;if(n?.type!=="solid")continue;let o=n.color;if(typeof o=="string"||Array.isArray(o)&&(o[3]??1)>0)return o}return this.gridFadeColor}gridDescriptor(){let e={size:this.gridSize,divisions:Math.max(1,Math.round(this.gridDivisions)),majorEvery:Math.max(1,Math.round(this.gridMajorEvery)),minorColor:this.gridColor,majorColor:this.gridMajorColor,axisXColor:this.axisXColor,axisZColor:this.axisZColor,showAxes:this.showAxes,fadeTo:this.fadeColor(),fade:this.gridFade},r=JSON.stringify(e);return this.gridCache?.key!==r&&(this.gridCache={key:r,geometry:Ip(e)}),this.gridCache.geometry}constructor(e){super(e??{})}orbitTo(e){let r={};for(let[n,o]of Object.entries(e.data??{}))o!==void 0&&(r[n]=o);return this.to({data:r,duration:e.duration,easing:e.easing})}acceptsChild(e){return!0}_spaceOf(e){return null}get children3D(){return this._allChildren.filter(e=>e instanceof I)}applyDefaultSize(e){(!e||e.width===void 0)&&this.applyProp("width","fill"),(!e||e.height===void 0)&&this.applyProp("height","fill")}buildScene3D(){let e=new Ve,r=Kn(this.shadows);r&&e.shadows(r),(this.tone!==void 0||this.exposure!==void 0)&&e.tone({mapping:this.tone,exposure:this.exposure}),this.post!==void 0&&e.post(this.post);for(let o of this._children)o instanceof I&&o.render(e);let n=e.fogDescriptor();if(n&&n.color===void 0){let o=e0(this.fill);o!==void 0&&e.fog({...n,color:o})}return this.showGrid&&e.draw(new Fe().line({geometry:this.gridDescriptor(),segments:!0,material:{type:"lineBasic",vertexColors:!0,toneMapped:!1}})),this.buildScene3D===t.prototype.buildScene3D&&e.isEmpty()&&!this._children.some(o=>o instanceof I)||(e.cameraDescriptor()===null&&e.perspective({fov:this.fov,orbit:Oc(this.orbit),elevation:this.elevation,distance:this.zoom}),e.ops().some(o=>o.kind==="light")||e.light({type:"ambient",intensity:this.ambientIntensity,color:this.ambientColor}).light({type:"directional",intensity:this.keyIntensity,color:this.keyColor},{position:[4,6,3]}).light({type:"directional",intensity:this.keyIntensity*.35,color:this.keyColor},{position:[-5,-2,-4]})),e}_scene3D(){return this.buildScene3D()}declareAssets(e){if(super.declareAssets(e),e.loader("three:runtime",Qx),this.buildScene3D===t.prototype.buildScene3D)return;let r=this.buildScene3D();r.isEmpty()||sn(r,e)}bindSurfaceSources(e){Hn(e,r=>{if(!tn(r))return;let n=Gn(r.source);n.kind==="node"&&this.attachDetached(n.node)})}renderSelf(e){let r=this.buildScene3D(),n=r.isEmpty()?null:r;n&&(n.assertBalanced(),this.bindSurfaceSources(n));let o=n?[...Qr(this.fill),...Zi.canvas3D(n,{maxPixelRatio:this.maxPixelRatio,antialias:this.antialias})]:this.fill;e.draw(this.shapeGraphics().shadow(this.shadow).fill(o))}};X([p({default:35})],j.prototype,"orbit",void 0);X([p({default:20})],j.prototype,"elevation",void 0);X([p({default:12})],j.prototype,"zoom",void 0);X([p({default:45})],j.prototype,"fov",void 0);X([p({default:.45})],j.prototype,"ambientIntensity",void 0);X([p({default:"#ffffff",mapper:ht,tween:Yt})],j.prototype,"ambientColor",void 0);X([p({default:2.4})],j.prototype,"keyIntensity",void 0);X([p({default:"#ffffff",mapper:ht,tween:Yt})],j.prototype,"keyColor",void 0);X([p({default:!1})],j.prototype,"showGrid",void 0);X([p({default:40})],j.prototype,"gridSize",void 0);X([p({default:40})],j.prototype,"gridDivisions",void 0);X([p({default:5})],j.prototype,"gridMajorEvery",void 0);X([p({default:"#26292f",mapper:ht,tween:Yt})],j.prototype,"gridColor",void 0);X([p({default:"#363a42",mapper:ht,tween:Yt})],j.prototype,"gridMajorColor",void 0);X([p({default:!1})],j.prototype,"showAxes",void 0);X([p({default:"#c8404f",mapper:ht,tween:Yt})],j.prototype,"axisXColor",void 0);X([p({default:"#2f6fd0",mapper:ht,tween:Yt})],j.prototype,"axisZColor",void 0);X([p({default:.55})],j.prototype,"gridFade",void 0);X([p({default:"#0b0d12",mapper:ht,tween:Yt})],j.prototype,"gridFadeColor",void 0);X([p({default:2})],j.prototype,"maxPixelRatio",void 0);X([p({default:!0})],j.prototype,"antialias",void 0);X([p({default:!1})],j.prototype,"shadows",void 0);X([p({default:void 0})],j.prototype,"tone",void 0);X([p({default:void 0})],j.prototype,"exposure",void 0);X([p({default:void 0})],j.prototype,"post",void 0);X([P({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",min:-89,max:89,step:1,unit:"\xB0"},{key:"zoom",kind:"number",min:.01,step:.1}]})],j.prototype,"orbitTo",null);function e0(t){if(t){for(let e of t)if(e&&e.type==="solid")return e.color}}function Qs(t){return t.kind==="still"}function AI(t){return t.kind==="composition"}function mr(t){return t.kind==="audio"}function t0(t){return t.kind!=="still"}var O="";function $e(t){let e=t;return{start:e.startAt??0,end:e.endAt??1/0}}function MI(t,e){return ei(new Map(t.map(r=>[r.id,r])),e)}function zp(t){let e=new Map(t.map(s=>[s.id,s])),r=new Map,n=[],o=new Set;for(let s of e.values()){if(r.has(s.id))continue;n.length=0,o.clear();let i,a=s;for(;a;){let l=r.get(a.id);if(l){i=l;break}if(o.has(a.id)){for(let c of n)r.set(c.id,ei(e,c.id));n.length=0;break}n.push(a),o.add(a.id),a=a.parentId===null?void 0:e.get(a.parentId)}for(let l=n.length-1;l>=0;l--){let c=$e(n[l]);i&&(c.start=Math.max(c.start,i.start),c.end=Math.min(c.end,i.end)),r.set(n[l].id,c),i=c}}return r}function ei(t,e){let r=t.get(e);if(!r)return;let n=$e(r),o=new Set;for(;r.parentId!==null&&!o.has(r.id);){o.add(r.id);let s=t.get(r.parentId);if(!s)break;let i=$e(s);n.start=Math.max(n.start,i.start),n.end=Math.min(n.end,i.end),r=s}return n}function OI(t){let{startAt:e,endAt:r,...n}=t;return n}function r0(t){let e=t.duration??0;return e<=0||!t.loop||t.loop.count===null?e:e*xc(t.loop)}function Et(t){if(!t0(t))return 0;if(t.duration!==void 0)return t.duration;let e=0;for(let r of t.commands)e=Math.max(e,r.at+r0(r));for(let r of t.nodes)r.startAt!==void 0&&(e=Math.max(e,r.startAt)),r.endAt!==void 0&&Number.isFinite(r.endAt)&&(e=Math.max(e,r.endAt));return e}function n0(t){return typeof t=="object"&&t!==null&&t.kind==="project"}function Np(t,e={}){return n0(t)?t:{kind:"project",name:e.name??"Untitled",fps:e.fps,viewport:e.viewport,theme:t.theme,tracks:[{id:"clip",clip:t,duration:Et(t)}]}}var ae=class extends Error{source;position;path;constructor(e,r,n=-1,o){let s=n>=0?` (at character ${n+1} of "${r}")`:` (in "${r}")`;super(`${e}${s}${o?` at ${o}`:""}`),this.name="ExpressionError",this.source=r,this.position=n,this.path=o}};var Yr=Math.PI/180,wl={abs:{arity:[1,1],apply:t=>Math.abs(t[0])},sign:{arity:[1,1],apply:t=>Math.sign(t[0])},sqrt:{arity:[1,1],apply:t=>Math.sqrt(t[0])},floor:{arity:[1,1],apply:t=>Math.floor(t[0])},ceil:{arity:[1,1],apply:t=>Math.ceil(t[0])},round:{arity:[1,2],apply:t=>t.length>1&&t[1]!==0?Math.round(t[0]/t[1])*t[1]:Math.round(t[0])},min:{arity:[1,1/0],apply:t=>Math.min(...t)},max:{arity:[1,1/0],apply:t=>Math.max(...t)},clamp:{arity:[3,3],apply:t=>Math.min(Math.max(t[0],t[1]),t[2])},mod:{arity:[2,2],apply:t=>(t[0]%t[1]+t[1])%t[1]},pow:{arity:[2,2],apply:t=>t[0]**t[1]},log:{arity:[1,2],apply:t=>t.length>1?Math.log(t[0])/Math.log(t[1]):Math.log(t[0])},exp:{arity:[1,1],apply:t=>Math.exp(t[0])},mix:{arity:[3,3],apply:t=>t[0]+(t[1]-t[0])*t[2]},smoothstep:{arity:[3,3],apply:t=>{if(Number.isNaN(t[0])||Number.isNaN(t[1])||Number.isNaN(t[2]))return NaN;if(t[0]===t[1])return t[2]<t[0]?0:1;let e=Math.min(Math.max((t[2]-t[0])/(t[1]-t[0]),0),1);return e*e*(3-2*e)}},step:{arity:[2,2],apply:t=>Number.isNaN(t[0])||Number.isNaN(t[1])?NaN:t[1]<t[0]?0:1},sin:{arity:[1,1],apply:t=>Math.sin(t[0]*Yr)},cos:{arity:[1,1],apply:t=>Math.cos(t[0]*Yr)},tan:{arity:[1,1],apply:t=>Math.tan(t[0]*Yr)},asin:{arity:[1,1],apply:t=>Math.asin(t[0])/Yr},acos:{arity:[1,1],apply:t=>Math.acos(t[0])/Yr},atan:{arity:[1,1],apply:t=>Math.atan(t[0])/Yr},atan2:{arity:[2,2],apply:t=>Math.atan2(t[0],t[1])/Yr},hypot:{arity:[2,1/0],apply:t=>Math.hypot(...t)}},$p={pi:Math.PI,tau:Math.PI*2,e:Math.E},Sn={functions:wl,constants:$p,refs:"bracket",unknownName:t=>`unknown name "${t}" \u2014 a variable is referenced as "[${t}]"; bare names are the constants ${yo($p).join(", ")}`};function yo(t){return Object.keys(t).sort()}var o0=new Set(["+","-","*","/","%","^"]);function vn(t){return t!==void 0&&t>="0"&&t<="9"}function s0(t,e){let r=[],n=0;for(;n<t.length;){let o=t[n];if(o===" "||o===" "||o===`
6
- `||o==="\r"){n++;continue}if(vn(o)||o==="."&&vn(t[n+1])){let s=n;for(;vn(t[n]);)n++;if(t[n]===".")for(n++;vn(t[n]);)n++;if(t[n]==="e"||t[n]==="E"){let i=n;if(n++,(t[n]==="+"||t[n]==="-")&&n++,vn(t[n]))for(;vn(t[n]);)n++;else n=i}if(t[n]===".")throw new ae('unexpected character "."',t,n);r.push({kind:"number",text:"",value:Number(t.slice(s,n)),pos:s});continue}if(o==="["&&e.refs==="bracket"){let s=n,i=t.indexOf("]",n+1);if(i===-1)throw new ae("unclosed `[` \u2014 a variable reference is written `[id]`",t,s);let a=t.slice(n+1,i).trim();if(a.length===0)throw new ae("empty variable reference `[]`",t,s);if(a.includes("["))throw new ae("variable references cannot nest",t,s);r.push({kind:"ref",text:a,value:0,pos:s}),n=i+1;continue}if(/[A-Za-z_]/.test(o)){let s=n;for(;n<t.length&&/[A-Za-z0-9_]/.test(t[n]);)n++;r.push({kind:"ident",text:t.slice(s,n),value:0,pos:s});continue}if(o0.has(o)){r.push({kind:"op",text:o,value:0,pos:n++});continue}if(o==="("||o===")"||o===","){r.push({kind:o,text:o,value:0,pos:n++});continue}throw new ae(`unexpected character "${o}"`,t,n)}return r.push({kind:"end",text:"",value:0,pos:t.length}),r}function ti(t,e=Sn){if(t.trim().length===0)throw new ae("empty expression",t);let r=s0(t,e),n=[],o=0,s=()=>r[o],i=()=>r[o++],a=x=>(n.includes(x)||n.push(x),{kind:"ref",name:x}),l=x=>x.kind==="number"||x.kind==="ref"||x.kind==="ident"||x.kind==="(";function c(){let x=d();for(;;){let _=s();if(_.kind==="op"&&(_.text==="+"||_.text==="-")){i(),x={kind:"binary",op:_.text,left:x,right:d()};continue}return x}}function d(){let x=u();for(;;){let _=s();if(_.kind==="op"&&(_.text==="*"||_.text==="/"||_.text==="%")){i(),x={kind:"binary",op:_.text,left:x,right:u()};continue}if(l(_)){x={kind:"binary",op:"*",left:x,right:u()};continue}return x}}function u(){let x=s();if(x.kind==="op"&&(x.text==="-"||x.text==="+")){i();let _=u();return x.text==="-"?{kind:"unary",op:"-",operand:_}:_}return f()}function f(){let x=y(),_=s();return _.kind==="op"&&_.text==="^"?(i(),{kind:"binary",op:"^",left:x,right:u()}):x}function h(x,_){let S=Object.hasOwn(e.functions,x)?e.functions[x]:void 0;if(!S)throw new ae(`unknown function "${x}" \u2014 available: ${yo(e.functions).join(", ")}`,t,_);let b=[];if(s().kind!==")")for(;b.push(c()),s().kind===",";)i();let k=i();if(k.kind!==")")throw new ae(`expected \`)\` closing ${x}(`,t,k.pos);let[M,T]=S.arity;if(b.length<M||b.length>T){let V=T===1/0?`at least ${M}`:M===T?`${M}`:`${M}\u2013${T}`,W=(T===1/0||M===T)&&M===1?"":"s";throw new ae(`${x}() takes ${V} argument${W}, got ${b.length}`,t,_)}return{kind:"call",name:x,args:b}}function y(){let x=i();switch(x.kind){case"number":return{kind:"const",value:x.value};case"ref":return a(x.text);case"(":{let _=c(),S=i();if(S.kind!==")")throw new ae("expected `)`",t,S.pos);return _}case"ident":{if(s().kind==="(")return i(),h(x.text,x.pos);let _=Object.hasOwn(e.constants,x.text)?e.constants[x.text]:void 0;if(_!==void 0)return{kind:"const",value:_};if(e.refs==="bare")return a(x.text);throw new ae(e.unknownName(x.text),t,x.pos)}default:throw new ae(x.kind==="end"?"expression ends early":`unexpected "${x.text}"`,t,x.pos)}}let w=c(),g=s();if(g.kind!=="end")throw new ae(`unexpected "${g.text}"`,t,g.pos);return{source:t,root:w,refs:n,passthrough:w.kind==="ref"}}function i0(t){return typeof t=="number"?t:typeof t=="boolean"?t?1:0:typeof t=="string"?t.trim()===""?NaN:Number(t):NaN}function ri(t,e,r){let n=s=>{let i=e(s);if(!i)throw new ae(`"${s}" resolves to nothing in this document \u2014 a reference names a variable (declared with a "variable" command), a constant (a \`constants\` row), or another node's prop as "[key.prop]" (\`key\` on that node's row)`,t.source,-1,r);return i};if(t.passthrough)return n(t.root.name);let o=s=>{switch(s.kind){case"const":{let{value:i}=s;return()=>i}case"ref":{let i=n(s.name);return()=>i0(i())}case"unary":{let i=o(s.operand);return()=>-i()}case"binary":{let i=o(s.left),a=o(s.right);switch(s.op){case"+":return()=>i()+a();case"-":return()=>i()-a();case"*":return()=>i()*a();case"/":return()=>i()/a();case"%":return()=>i()%a();case"^":return()=>i()**a()}break}case"call":{let{apply:i}=wl[s.name],a=s.args.map(o);return()=>i(a.map(l=>l()))}}throw new ae("unsupported expression node",t.source,-1,r)};return o(t.root)}function bn(t){return typeof t=="string"&&t.length>1&&t[0]==="="&&t[1]!=="="}function vl(t){return t.startsWith("==")?t.slice(1):t}var yr=t=>({dynamic:!1,value:t});function go(t,e,r){if(typeof t=="string")return r(t,e);if(Array.isArray(t)){let n=t.map((s,i)=>go(s,`${e}[${i}]`,r));if(n.some(s=>s.dynamic))return{dynamic:!0,read:()=>n.map(s=>s.dynamic?s.read():s.value)};let o=n.map(s=>s.value);return yr(o.every((s,i)=>s===t[i])?t:o)}if(l0(t)){let n=Object.keys(t),o=n.map(i=>go(t[i],`${e}.${i}`,r));if(o.some(i=>i.dynamic))return{dynamic:!0,read:()=>{let i={};return n.forEach((a,l)=>{let c=o[l];i[a]=c.dynamic?c.read():c.value}),i}};if(!o.some((i,a)=>i.value!==t[n[a]]))return yr(t);let s={};return n.forEach((i,a)=>{s[i]=o[a].value}),yr(s)}return yr(t)}function Sl(t,e,r="props"){return go(t,r,(n,o)=>bn(n)?{dynamic:!0,read:ri(ti(n.slice(1)),e,o)}:yr(vl(n)))}function jp(t,e,r="props"){let n={},o={},s=!1;for(let i of Object.keys(t??{})){let a=Sl(t[i],e,`${r}.${i}`);a.dynamic?(o[i]=a.read,s=!0):n[i]=a.value}return{literal:n,bindings:o,hasBindings:s}}function Bp(t,e){let r=[];return go(t,e,(n,o)=>(bn(n)&&r.push({path:o,source:n}),yr(n))),r}var a0=/\[([^[\]]+)\]/g;function Lp(t,e){return go(t,"",n=>bn(n)?yr(n.replace(a0,(o,s)=>{let i=e(s.trim());return i===void 0?o:`[${i}]`})):yr(n)).value}function l0(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Wp(t,e=Sn){return ti(bn(t)?t.slice(1):t,e)}var xe={isSource:bn,unescape:vl,parse:Wp,tryParse:(t,e)=>{try{return{expression:Wp(t,e)}}catch(r){return{error:r instanceof Error?r.message:String(r)}}},compile:ri,bind:Sl,bindProps:jp,collect:Bp,renameRefs:Lp,functions:()=>yo(Sn.functions),constants:()=>yo(Sn.constants),dialect:Sn};var qp=(t,e,r)=>Math.min(r,Math.max(e,t));function c0(t){let e=[];for(let r=0;r<t.length-1;r++){let n=t[r],o=t[r+1],s=t[r-1]??n,i=t[r+2]??o,a=n.out?{x:n.x+n.out.x,y:n.y+n.out.y}:{x:n.x+(o.x-s.x)/6,y:n.y+(o.y-s.y)/6},l=o.in?{x:o.x+o.in.x,y:o.y+o.in.y}:{x:o.x-(i.x-n.x)/6,y:o.y-(i.y-n.y)/6};e.push({p0:{x:n.x,y:n.y},c1:{x:qp(a.x,n.x,o.x),y:a.y},c2:{x:qp(l.x,n.x,o.x),y:l.y},p3:{x:o.x,y:o.y}})}return e}function Vp(t,e,r,n,o){let s=1-o;return s*s*s*t+3*s*s*o*e+3*s*o*o*r+o*o*o*n}function d0(t,e){let r=0,n=1;for(let o=0;o<30;o++){let s=(r+n)/2;Vp(t.p0.x,t.c1.x,t.c2.x,t.p3.x,s)<e?r=s:n=s}return(r+n)/2}function ni(t){return Array.isArray(t)&&t.length>=2&&t.every(u0)}function u0(t){if(typeof t!="object"||t===null)return!1;let{x:e,y:r}=t;return typeof e=="number"&&Number.isFinite(e)&&typeof r=="number"&&Number.isFinite(r)}function Gp(t){let e=c0(t);return e.length===0?Ut(r=>r,"lin"):Ut(r=>{if(r<=0)return e[0].p0.y;let n=e[e.length-1];if(r>=1)return n.p3.y;let o=n;for(let i of e)if(r<=i.p3.x){o=i;break}let s=d0(o,r);return Vp(o.p0.y,o.c1.y,o.c2.y,o.p3.y,s)},`curve:${JSON.stringify(t)}`)}var Yp=new Set(["linear","in","out","inOut","custom"]),Kp=new Set(["normal","reverse","alternate"]);function at(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Wt(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function f0(t,e,r){if(t===void 0)return;if(!at(t)){r.push({path:e,message:"easing must be an object with a `kind`."});return}let{kind:n,args:o}=t;if(typeof n!="string"||!Yp.has(n)){r.push({path:`${e}.kind`,message:`easing kind must be one of ${[...Yp].join(", ")} (got ${JSON.stringify(n)}).`});return}n==="custom"&&o!==void 0&&typeof o!="string"&&!ni(o)&&r.push({path:`${e}.args`,message:"a custom easing's args must be its curve \u2014 two or more `{ x, y }` points \u2014 or a registered ease's key."})}function p0(t,e,r){if(t===void 0)return;if(!at(t)){r.push({path:e,message:"loop must be an object with a `count`."});return}let{direction:n,count:o}=t;o!==null&&(typeof o!="number"||!Number.isInteger(o)||o<0)&&r.push({path:`${e}.count`,message:"loop count must be a whole number of repeats >= 0, or null to repeat for the rest of the clip."}),n!==void 0&&!Kp.has(n)&&r.push({path:`${e}.direction`,message:`loop direction must be one of ${[...Kp].join(", ")} (got ${JSON.stringify(n)}).`})}function h0(t,e,r){if(!at(t))return r.push({path:e,message:"node must be an object."}),!1;let n=!0,{id:o,type:s,parentId:i,layerOrder:a,props:l,key:c}=t;return typeof o!="string"&&(r.push({path:`${e}.id`,message:"id must be a string."}),n=!1),(typeof s!="string"||s.length===0)&&(r.push({path:`${e}.type`,message:"type must be a non-empty string."}),n=!1),i!==null&&typeof i!="string"&&(r.push({path:`${e}.parentId`,message:"parentId must be a node id or null."}),n=!1),(typeof a!="number"||!Number.isFinite(a))&&(r.push({path:`${e}.layerOrder`,message:"layerOrder must be a finite number."}),n=!1),at(l)||(r.push({path:`${e}.props`,message:"props must be an object (`{}` when nothing is set)."}),n=!1),c!==void 0&&(typeof c!="string"||c.length===0?(r.push({path:`${e}.key`,message:"key must be a non-empty string when present."}),n=!1):(c.includes("]")||c.includes("."))&&(r.push({path:`${e}.key`,message:`node key "${c}" cannot contain "]" or "." \u2014 it is referenced as "[${c}.prop]".`}),n=!1)),n}function Up(t,e){let r=new Map;for(let n of t){let o=n.spec.key;if(typeof o!="string"||o.length===0)continue;let s=r.get(o);if(s){e.push({path:`${n.path}.key`,message:`duplicate node key "${o}" (also declared at ${s.path}).`});continue}r.set(o,n)}return r}function m0(t,e,r,n){t.id===""&&(t.type!==r||t.parentId!==null)&&n.push({path:e,message:`the node with id "" is this document's root and must be \`{ type: "${r}", parentId: null }\`.`})}function y0(t,e,r){if(!at(t))return r.push({path:e,message:"command must be an object."}),!1;let n=!0,{id:o,type:s,targetId:i,at:a,duration:l,args:c}=t;return(typeof o!="string"||o.length===0)&&(r.push({path:`${e}.id`,message:"id must be a non-empty string."}),n=!1),(typeof s!="string"||s.length===0)&&(r.push({path:`${e}.type`,message:"type must be a non-empty string."}),n=!1),i!==null&&typeof i!="string"&&(r.push({path:`${e}.targetId`,message:"targetId must be a node id, or null for the scene root."}),n=!1),Wt(a)||(r.push({path:`${e}.at`,message:"at must be a finite number of seconds >= 0."}),n=!1),l!==void 0&&!Wt(l)&&(r.push({path:`${e}.duration`,message:"duration must be a finite number of seconds >= 0."}),n=!1),at(c)||(r.push({path:`${e}.args`,message:"args must be an object (`{}` when there are none)."}),n=!1),f0(t.easing,`${e}.easing`,r),p0(t.loop,`${e}.loop`,r),n}function g0(t,e,r){if(!at(t))return r.push({path:e,message:"variable must be an object."}),!1;let n=!0,{id:o,name:s,value:i,lerp:a}=t;return typeof o!="string"||o.length===0?(r.push({path:`${e}.id`,message:"id must be a non-empty string."}),n=!1):o.includes("]")&&(r.push({path:`${e}.id`,message:`variable id "${o}" cannot contain "]" \u2014 it is referenced as "[${o}]".`}),n=!1),s!==void 0&&typeof s!="string"&&(r.push({path:`${e}.name`,message:"name must be a string when present."}),n=!1),"value"in t?xe.isSource(i)&&(r.push({path:`${e}.value`,message:"a variable holds a value, not an expression \u2014 only a node prop can be bound."}),n=!1):(r.push({path:`${e}.value`,message:"value is required \u2014 a variable is what it holds before anything changes it."}),n=!1),a!==void 0&&typeof a!="string"&&(r.push({path:`${e}.lerp`,message:"lerp must be a registered lerp key when present."}),n=!1),n}function Xp(t,e){if(t===void 0)return[];if(!Array.isArray(t))return e.push({path:"variables",message:"variables must be an array."}),[];let r=[];return t.forEach((n,o)=>{let s=`variables[${o}]`;g0(n,s,e)&&r.push({spec:n,path:s})}),r}function Zp(t,e){let r=new Map;for(let n of t){let o=r.get(n.spec.id);if(o){e.push({path:`${n.path}.id`,message:`duplicate variable id "${n.spec.id}" (also declared at ${o.path}).`});continue}r.set(n.spec.id,n)}return r}function Jp(t){let e=t.indexOf(".");return e<0?void 0:{key:t.slice(0,e),prop:t.slice(e+1)}}function bl(t,e,r,n,o){for(let s of xe.collect(t,e)){let i=xe.tryParse(s.source);if("error"in i){o.push({path:s.path,message:i.error});continue}for(let a of i.expression.refs){let l=Jp(a);if(!l){if(r.has(a))continue;o.push({path:s.path,message:n.has(a)?`expression references "[${a}]", which is a node key \u2014 a node is not a value, so name the prop too: "[${a}.x]".`:`expression references "[${a}]", which this document does not declare. Declared: ${[...r].map(c=>`[${c}]`).join(", ")||"none"}.`});continue}if(l.key.length===0||l.prop.length===0||l.prop.includes(".")){o.push({path:s.path,message:`expression references "[${a}]", which is not a node reference \u2014 one is "[key.prop]".`});continue}n.has(l.key)||o.push({path:s.path,message:`expression references "[${a}]", but no node in this document is keyed "${l.key}". Keyed: ${[...n].join(", ")||"none"}.`})}}}function kl(t,e,r,n){if(at(e))for(let o of Object.keys(e)){let s=[];for(let i of xe.collect(e[o],`${r}.${o}`)){let a=xe.tryParse(i.source);if(!("error"in a))for(let l of a.expression.refs)Jp(l)&&s.push(l)}s.length>0&&n.push({id:`${t}.${o}`,path:`${r}.${o}`,reads:s})}}function Qp(t,e){let r=new Map(t.map(a=>[a.id,a])),n=new Set,o=[],s=new Set,i=a=>{let l=r.get(a);if(!l||n.has(a))return;let c=o.indexOf(a);if(c>=0){if(!s.has(a)){let d=[...o.slice(c),a];for(let u of d)s.add(u);e.push({path:l.path,message:`expression cycle ${d.join(" \u2192 ")} \u2014 a prop cannot read a prop that reads it back.`})}return}o.push(a);for(let d of l.reads)i(d);o.pop(),n.add(a)};for(let a of t)i(a.id)}function x0(t,e){let r=new Map;for(let o of t){if(r.has(o.spec.id)){e.push({path:`${o.path}.id`,message:`duplicate node id "${o.spec.id}".`});continue}r.set(o.spec.id,o)}for(let o of t){let s=o.spec.parentId;s!==null&&!r.has(s)&&e.push({path:`${o.path}.parentId`,message:`parentId "${s}" is not a node in this document.`})}let n=new Set;for(let{spec:o}of t){if(n.has(o.id))continue;let s=new Set,i=o;for(;i;){if(s.has(i.id)){e.push({path:`${r.get(i.id)?.path}.parentId`,message:`node "${i.id}" is its own ancestor \u2014 parent chain forms a cycle.`});break}if(s.add(i.id),n.has(i.id))break;let a=i.parentId;i=a===null?void 0:r.get(a)?.spec}for(let a of s)n.add(a)}}function eh(t,e,r){for(let n of t){let o=e.get(n.id);o&&r.push({path:`${o.path}.id`,message:`"${n.id}" is already a node id \u2014 nodes and variables share one id space.`})}}function th(t,e){t.constants!==void 0&&e.push({path:"constants",message:"constants were merged into `variables` \u2014 move each row there and drop its `kind`."})}function rh(t,e,r){if(!Array.isArray(t))return r.push({path:"nodes",message:"nodes must be an array."}),[];let n=[];return t.forEach((o,s)=>{let i=`nodes[${s}]`;h0(o,i,r)&&(n.push({spec:o,path:i}),m0(o,i,e,r))}),x0(n,r),n}function _0(t,e,r){let{startAt:n,endAt:o}=t;n!==void 0&&!Wt(n)&&r.push({path:`${e}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),o!==void 0&&!Wt(o)&&r.push({path:`${e}.endAt`,message:"endAt must be a finite number of seconds >= 0."}),Wt(o)&&o<=(Wt(n)?n:0)&&r.push({path:`${e}.endAt`,message:`endAt (${o}s) must be after startAt (${n??0}s).`}),t.id===""&&(n!==void 0||o!==void 0)&&r.push({path:e,message:"the root is present for the whole clip \u2014 it cannot carry startAt or endAt."})}function w0(t,e){th(t,e),t.commands!==void 0&&e.push({path:"commands",message:"a still has no timeline, so no commands \u2014 make it a composition to animate it."});let r=Zp(Xp(t.variables,e),e),n=rh(t.nodes,"canvas2d",e);for(let c of n){let{startAt:d,endAt:u}=c.spec;(d!==void 0||u!==void 0)&&e.push({path:c.path,message:"a still has no timeline \u2014 drop startAt/endAt, or make it a composition."})}let o=n.map(c=>c.spec);eh(o,r,e);let s=Up(n,e),i=new Set(r.keys()),a=new Set(s.keys()),l=[];for(let c of n)bl(c.spec.props,`${c.path}.props`,i,a,e),c.spec.key&&kl(c.spec.key,c.spec.props,`${c.path}.props`,l);Qp(l,e)}function v0(t,e){nh(t,"canvas2d",e)}function S0(t,e){nh(t,"audioBus",e)}var b0={add:"a node is a row in `nodes` \u2014 its `startAt` is when it enters.",variable:"a variable is declared in `variables`."};function nh(t,e,r){if(th(t,r),!Array.isArray(t.commands)){r.push({path:"commands",message:"commands must be an array."});return}t.duration!==void 0&&!Wt(t.duration)&&r.push({path:"duration",message:"duration must be a finite number of seconds >= 0."});let n=Zp(Xp(t.variables,r),r),o=rh(t.nodes,e,r);for(let h of o)_0(h.spec,h.path,r);let s=o.map(h=>h.spec);eh(s,n,r);let i=Up(o,r),a=[],l=new Set;t.commands.forEach((h,y)=>{if(!y0(h,`commands[${y}]`,r))return;if(l.has(h.id)){r.push({path:`commands[${y}].id`,message:`duplicate command id "${h.id}".`});return}let w=b0[h.type];if(w){r.push({path:`commands[${y}].type`,message:`there is no "${h.type}" command \u2014 ${w}`});return}l.add(h.id),a.push({spec:h,path:`commands[${y}]`})});let c=new Map(s.map(h=>[h.id,h]));for(let{spec:h,path:y}of a){if(h.targetId===null||n.has(h.targetId))continue;let w=ei(c,h.targetId);w===void 0?r.push({path:`${y}.targetId`,message:`targetId "${h.targetId}" is not a node or variable in this document.`}):h.at<w.start&&r.push({path:`${y}.at`,message:`command runs at ${h.at}s but its target "${h.targetId}" is not present until ${w.start}s.`})}let d=new Set(n.keys()),u=new Set(i.keys());for(let h of o)bl(h.spec.props,`${h.path}.props`,d,u,r);for(let{spec:h,path:y}of a)bl(h.args,`${y}.args`,d,u,r);let f=[];for(let h of o)h.spec.key&&kl(h.spec.key,h.spec.props,`${h.path}.props`,f);for(let{spec:h,path:y}of a){if(h.type!=="set"||h.targetId===null)continue;let w=c.get(h.targetId)?.key;w&&kl(w,h.args,`${y}.args`,f)}Qp(f,r)}function Al(t){let e=[];if(!at(t))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};let r=t.kind;return r==="still"?w0(t,e):r==="composition"?v0(t,e):r==="audio"?S0(t,e):e.push({path:"kind",message:`kind must be "still", "composition" or "audio" (got ${JSON.stringify(r)}).`}),{valid:e.length===0,issues:e}}function k0(t){let e=[];if(!at(t))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};let r=t;if(r.kind!=="project"&&e.push({path:"kind",message:`kind must be "project" (got ${JSON.stringify(r.kind)}).`}),(typeof r.name!="string"||r.name.length===0)&&e.push({path:"name",message:"name must be a non-empty string."}),r.fps!==void 0&&(typeof r.fps!="number"||!(r.fps>0))&&e.push({path:"fps",message:"fps must be a positive number when present."}),!Array.isArray(r.tracks))return e.push({path:"tracks",message:"tracks must be an array."}),{valid:!1,issues:e};let n=new Set;return r.tracks.forEach((o,s)=>{let i=`tracks[${s}]`;if(!at(o)){e.push({path:i,message:"track must be an object."});return}let a=o;if(typeof a.id!="string"||a.id.length===0?e.push({path:`${i}.id`,message:"id must be a non-empty string."}):n.has(a.id)?e.push({path:`${i}.id`,message:`duplicate track id "${a.id}".`}):n.add(a.id),a.name!==void 0&&typeof a.name!="string"&&e.push({path:`${i}.name`,message:"name must be a string when present."}),a.startAt!==void 0&&!Wt(a.startAt)&&e.push({path:`${i}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),Wt(a.duration)||e.push({path:`${i}.duration`,message:"duration is required, and must be a finite number of seconds >= 0."}),a.clip===void 0){e.push({path:`${i}.clip`,message:"clip is required \u2014 a track places a clip document inline."});return}for(let l of A0(a.clip))e.push({path:`${i}.clip${l.path?`.${l.path}`:""}`,message:l.message})}),{valid:e.length===0,issues:e}}var Hp=new WeakMap;function A0(t){if(!at(t))return Al(t).issues;let e=Hp.get(t);return e||(e=Al(t).issues,Hp.set(t,e)),e}function oh(t){let{valid:e,issues:r}=k0(t);if(!e){let n=r.map(o=>` ${o.path||"<root>"}: ${o.message}`).join(`
7
- `);throw new Error(`Invalid project document:
8
- ${n}`)}}function JI(t){let{valid:e,issues:r}=Al(t);if(!e){let n=r.map(o=>` ${o.path||"<root>"}: ${o.message}`).join(`
9
- `);throw new Error(`Invalid clip document:
10
- ${n}`)}return t}var Ml=Symbol("nodeMeta");function e3(t){return function(e){let r=typeof t=="string"?{key:t}:t;return e.prototype[Ml]=r,e}}function Ol(t){let e=t.prototype;if(!(!e||!Object.prototype.hasOwnProperty.call(e,Ml)))return e[Ml]}var M0={canvas2d:K,provider:hn,"theme-provider":Fr,"default-text-style":ze,rect:wt,ellipse:Ir,path:uo,polygon:zr,polygram:sr,boolean:Ws,mask:qs,camera:He,orbitCamera:Me,"rotated-box":fo,text:st,richtext:Ue,number:dt,video:te,audioBus:yn,sound:St,canvas3d:j,group3d:Xs,mesh3d:F,box3d:jt,sphere3d:bt,plane3d:$r,circle3d:ar,cylinder3d:kt,cone3d:At,capsule3d:jr,torus3d:Bt,"torus-knot3d":ir,tube3d:dr,lathe3d:cr,extrude3d:lr,ring3d:Lt,polyhedron3d:Br,points3d:Zs,line3d:ut,sprite3d:Wr,instances3d:gn,model3d:ur,camera3d:Oe,"ambient-light3d":_n,"directional-light3d":Vr,"point-light3d":fr,"spot-light3d":ft,"hemisphere-light3d":qr,"area-light3d":pr,fog3d:hr,environment3d:Mt};function oi(t,e){return(r,n,o,s)=>{let i=r[t];if(typeof i!="function")throw new Error(`Command "${t}" is not available on ${r.constructor.name}.`);return i.call(r,{data:n[e],duration:o,easing:s})}}var O0={number:m,vector2:D,vector3:dn,color:((t,e,r)=>{let[n,o,s,i]=Z(G(String(t)),G(String(e)),r),a=l=>Math.round(Math.min(Math.max(l,0),1)*255);return`rgba(${a(n)}, ${a(o)}, ${a(s)}, ${Number(i.toFixed(4))})`}),step:((t,e,r)=>r>=1?e:t)};function sh(t){for(let[e,r]of Object.entries(M0))t.addNode(e,r);for(let[e,r]of Object.entries(O0))t.addLerp(e,r);t.addCommand("to",(e,r,n,o)=>e.to({data:{...r},duration:n,easing:o})),t.addCommand("set",(e,r)=>{let n=r;return We(0,()=>{e.set(n)})},{binds:!0}),t.addCommand("fillTo",oi("fillTo","fill"),{args:[{key:"fill",kind:"fills"}],method:"fillTo"}),t.addCommand("overlayTo",oi("overlayTo","overlay"),{args:[{key:"overlay",kind:"fills"}],method:"overlayTo"}),t.addCommand("strokeTo",oi("strokeTo","stroke"),{args:[{key:"stroke",kind:"strokes"}],method:"strokeTo"}),t.addCommand("shadowTo",oi("shadowTo","shadow"),{args:[{key:"shadow",kind:"shadows"}],method:"shadowTo"}),t.addVariableCommand("variableTo",(e,r,n,o)=>{let s=r.value,i=r.lerp,a=typeof i=="string"?t.lerp(i):void 0;if(i!==void 0&&!a)throw new Error(`A "lerp" param must name a registered lerp (variable "${e.id}"), got ${JSON.stringify(i)}. Registered: ${t.lerpKeys().join(", ")}.`);let l=a??e.lerp,c,d=!1;return We(n,u=>{d||(c=e.get(),d=!0),e.set(l(c,s,u))},o)}),t.addVariableCommand("variableSet",(e,r)=>We(0,()=>{e.set(r.value)})),t.addCommand("save",e=>We(0,()=>{e.save()}))}var El=["globalThis","window","self","top","parent","frames","Function","importScripts","document","navigator","location","history","screen","customElements","fetch","XMLHttpRequest","WebSocket","EventSource","Request","Response","Headers","localStorage","sessionStorage","indexedDB","caches","cookieStore","crypto","Worker","SharedWorker","ServiceWorker","MessageChannel","BroadcastChannel","postMessage","alert","confirm","prompt","open","print","Notification"],E0=new Set(["eval","arguments"]),ih=El.filter(t=>E0.has(t));if(ih.length>0)throw new Error(`DENIED_GLOBALS cannot contain ${ih.join(", ")}: strict mode forbids binding those names, so no dynamic node would link at all. See the note in this file.`);var ah=["@motionscript/sdk","motionscript","motion-script"],si=class t{static MAX_SHADERS=512;constructor(e={}){if(this._dynamicNodes=e.dynamicNodes,e.builtins!==!1&&sh(this),Array.isArray(e.nodes))for(let r of e.nodes)this.addNode(r);else for(let[r,n]of Object.entries(e.nodes??{}))this.addNode(r,n);for(let[r,n]of Object.entries(e.lerps??{}))this.addLerp(r,n);for(let[r,n]of Object.entries(e.eases??{}))this.addEase(r,n);for(let[r,n]of Object.entries(e.shaders??{}))this.addShader(r,n)}addNode(e,r,n){let o=typeof r=="function",s=o?r:e,i=o?n:r,a=o?e:Ol(s);if(a===void 0)throw new Error(`${s.name||"The class"} carries no @node(...) declaration, so it has no document key. Decorate it, or register it explicitly: addNode("myKey", TheClass).`);let l=typeof a=="string"?{key:a}:a,c=l.key,d=this._nodes.get(c);if(d){if(d.ctor===s)return this;if(!i?.replace)throw new Error(`Node type "${c}" is already registered to a different class (${d.ctor.name} vs ${s.name}). Keys must be unique \u2014 a document naming this type would otherwise resolve differently depending on registration order.`)}let u=new Map,f=new Map;for(let h of Ms(Object.create(s.prototype)))(h.withdrawn?f:u).set(h.key,{method:h.method,args:this._describeArgs(h.args)});return this._nodes.set(c,{key:c,ctor:s,commands:u,withdrawn:f,descriptor:{...l,dimension:this._describeDimension(s),properties:this._describeProperties(s)}}),this}async addNodeFromSource(e,r){if(!this._dynamicNodes)throw new Error("addNodeFromSource needs `dynamicNodes: { sdk, compile }` on the Registry constructor.");let n=await this._dynamicNodes.compile(e),o=this._evalNodeModule(n);return this.addNode(o,r),o}node(e){return this._nodes.get(e)}hasNode(e){return this._nodes.has(e)}nodeKeys(){return[...this._nodes.keys()].sort()}describe(e){return this._nodes.get(e)?.descriptor}instantiate(e,r){let n=this._nodes.get(e.type);if(!n)throw new Error(`Unknown node type "${e.type}" (node ${e.id}). This registry knows: ${this.nodeKeys().join(", ")||"nothing"}.`);return new n.ctor({...r??e.props,id:e.id,...e.key!==void 0&&{key:e.key}})}addCommand(e,r,n){return this._claimed(e,r)?this:(this._commands.set(e,{key:e,scope:"node",factory:r,...n?.args?{args:this._describeArgs(n.args)}:{},binds:n?.binds,...n?.method?{method:n.method}:{}}),this)}addVariableCommand(e,r){return this._claimed(e,r)?this:(this._commands.set(e,{key:e,scope:"variable",factory:r}),this)}command(e){return this._commands.get(e)}nodeCommand(e,r){let n=this._nodes.get(e),o=n?.commands.get(r)??n?.withdrawn.get(r);if(o)return(s,i,a,l)=>{let c=s[o.method];if(typeof c!="function")throw new Error(`Command "${r}" needs a "${o.method}" method on ${s.constructor.name}, which has none.`);let d={};for(let u of o.args)d[u.key]=i[u.key];return c.call(s,{data:d,duration:a,easing:l})}}takesCommand(e,r){let n=this._nodes.get(e);if(!n)return!1;if(n.commands.has(r))return!0;let o=this._commands.get(r);return o?.scope!=="node"?!1:o.method===void 0?!0:n.withdrawn.has(o.method)?!1:typeof n.ctor.prototype[o.method]=="function"}commandKeys(e){return[...e===void 0?this._commands.keys():this._nodes.get(e)?.commands.keys()??[]].sort()}addLerp(e,r){let n=this._lerps.get(e);if(n&&n!==r)throw new Error(`Variable lerp "${e}" is already registered to a different function. Keys must be unique.`);return this._lerps.set(e,r),this}lerp(e){return this._lerps.get(e)}lerpKeys(){return[...this._lerps.keys()].sort()}requireLerp(e,r,n){let o=e??(typeof r=="number"?"number":"step"),s=this._lerps.get(o);if(!s)throw new Error(`Unknown variable lerp "${o}" (${n}). Registered: ${this.lerpKeys().join(", ")||"none"}.`);return s}addEase(e,r){let n=this._eases.get(e);if(n&&n!==r)throw new Error(`Ease "${e}" is already registered to a different function. Keys must be unique.`);return this._eases.set(e,r),this}ease(e){return this._eases.get(e)}easeKeys(){return[...this._eases.keys()].sort()}addShader(e,r,n){let o=Ff(r),s=this._shaders.get(e);if(s){if(s.scope===o.scope&&s.source===o.source&&s.name===o.name)return s;if(!n?.replace)throw new Error(`Shader "${e}" is already registered to a different pack ("${s.name}" vs "${o.name}"). Keys must be unique \u2014 a document naming this shader would otherwise resolve differently depending on registration order.`)}else if(this._shaders.size>=t.MAX_SHADERS)throw new Error(`Cannot register shader "${e}": the ${t.MAX_SHADERS}-shader ceiling is reached.`);return this._shaders.set(e,o),o}shader(e){return this._shaders.get(e)}fillShader(e){let r=this._shaders.get(e);return r?.scope==="fill"?r:void 0}effectShader(e){let r=this._shaders.get(e);return r?.scope==="effect"?r:void 0}shaderKeys(){return[...this._shaders.keys()].sort()}_nodes=new Map;_commands=new Map;_lerps=new Map;_eases=new Map;_shaders=new Map;_dynamicNodes;_evalNodeModule(e){let{sdk:r,jsxRuntime:n,modules:o}=this._dynamicNodes,s=c=>{if(ah.includes(c))return r;if(n&&ah.some(u=>c===`${u}/jsx-runtime`))return n;if(o&&Object.hasOwn(o,c))return o[c];let d=["@motionscript/sdk",...n?["@motionscript/sdk/jsx-runtime"]:[],...Object.keys(o??{})];throw new Error(`"${c}" isn't available to a custom node. It can require ${d.map(u=>`"${u}"`).join(", ")}; a host supplies more through \`dynamicNodes.modules\`.`)},i={exports:{}};new Function("exports","require","module",...El,`"use strict";
11
- return function () {
12
- ${e}
13
- };`)(i.exports,s,i)();let l=i.exports.default;if(typeof l!="function"||Ol(l)===void 0)throw new Error("This script must `export default` a class decorated with @node(...).");return l}_claimed(e,r){let n=this._commands.get(e);if(!n)return!1;if(n.factory===r)return!0;throw new Error(`Command type "${e}" is already registered to a different factory. Keys must be unique.`)}_describeProperties(e){let r={};for(let n of Qt(Object.create(e.prototype))){if(n.withdrawn)continue;let o=n.editor??{};r[n.key]={...o,kind:o.kind??this._inferKind(n.default),...n.default!==void 0?{default:n.default}:{}}}return r}_describeDimension(e){let r=Object.create(e.prototype).dimension;return typeof r=="string"?r:void 0}_inferKind(e){switch(typeof e){case"number":return"number";case"string":return"text";case"boolean":return"boolean";case"object":return e===null?"unknown":Array.isArray(e)&&e.every(r=>typeof r=="number")?"vector":"object";default:return"unknown"}}_describeArgs(e){return(e??[]).map(r=>typeof r=="string"?{key:r,kind:"unknown"}:{kind:"unknown",...r})}};function K3(...t){return function(e){let r=e.prototype,n=Object.create(Object.getPrototypeOf(r)),o=Qt(n),s=Ms(n);for(let i of t){if(lh(r,Er,i)||lh(r,Tr,i))throw new Error(`${e.name} both declares and withdraws "${i}".`);let a=o.find(c=>c.key===i),l=s.find(c=>c.key===i);if(!a&&!l)throw new Error(`${e.name} withdraws "${i}", which it does not inherit.`);a&&ch(r,Er).push({...a,withdrawn:!0}),l&&ch(r,Tr).push({...l,withdrawn:!0})}return e}}function lh(t,e,r){return Object.prototype.hasOwnProperty.call(t,e)?t[e].some(n=>n.key===r&&!n.withdrawn):!1}function ch(t,e){return Object.prototype.hasOwnProperty.call(t,e)||(t[e]=[]),t[e]}var C0="canvas3d";function P0(t,e,r){let n=new Set;for(let o=e;o!==void 0&&!n.has(o);o=t.describe(o)?.parentKey){if(o===r)return!0;n.add(o)}return!1}function ii(t,e,r,n){return r.some(o=>P0(t,e,o)||n.isA?.(e,o)===!0)}function T0(t,e,r,n={}){let o=t.describe(e),s=r===null?void 0:t.describe(r);if(r!==null&&s?.layout?.acceptsChildren===!1)return{kind:"leaf",parent:r};let i=o?.within??[];if(i.length>0&&(r===null||!ii(t,r,i,n)))return{kind:"within",within:i};if(r!==null&&s?.closed===!0&&!ii(t,r,i,n))return{kind:"closed",parent:r};let a=r!==null&&(s?.dimension==="3d"||ii(t,r,[C0],n));return o?.dimension==="3d"!==a?{kind:"dimension",parent:r}:null}function D0(t,e,r,n={}){let o=t.describe(e)?.beside??[];return o.length===0||r.some(s=>ii(t,s,o,n))?null:{kind:"beside",beside:o}}function X3(t,e,r={}){let n=a=>a.parentId===O?null:a.parentId,o=new Map(e.map(a=>[a.id,a])),s=new Map;for(let a of e){if(a.id===O)continue;let l=s.get(n(a));l?l.push(a.type):s.set(n(a),[a.type])}let i=new Map;for(let a of e){if(a.id===O||!t.hasNode(a.type))continue;let l=n(a),c=l===null?null:o.get(l)?.type??null,d=T0(t,a.type,c,r)??D0(t,a.type,R0(s.get(l)??[],a.type),r);d&&i.set(a.id,d)}return i}function R0(t,e){let r=t.indexOf(e);return r===-1?[...t]:[...t.slice(0,r),...t.slice(r+1)]}var ai="@bus";function F0(){return{id:ai,type:"audioBus",parentId:null,layerOrder:0,props:{}}}function I0(){return{id:"",type:"canvas2d",parentId:null,layerOrder:0,props:{}}}function kn(t){let e=[I0()];t.nodes.some(dh)||e.push(F0());for(let r of t.nodes)e.push(z0(r));return{kind:"composition",duration:t.duration,variables:t.variables,nodes:e,commands:t.commands.map(N0)}}function dh(t){return t.id===""&&t.type==="audioBus"}function z0(t){return dh(t)?{...t,id:ai,parentId:null}:t.parentId===null||t.parentId===""?{...t,parentId:ai}:t}function N0(t){return t.targetId===null||t.targetId===""?{...t,targetId:ai}:t}var hh=["center","topLeft","topRight","bottomLeft","bottomRight","topCenter","bottomCenter","centerLeft","centerRight"];function Pl(t,e,r){let n=$0.has(e.type),o=t.command(e.type);if(o?.scope==="variable"){let f=j0.has(e.type);return{scope:"variable",known:f,lifecycle:n,readsLayout:!f,writesLayout:!1}}let s=r??(e.targetId===null?yh:void 0),i=s?t.node(s.type):void 0;if(!s||!i)return null;let a;if(o){if(a=gh[e.type],a&&typeof li(i.ctor,a[0])!="function")return null}else{let f=i.commands.get(e.type);if(!f)return null;a=f.method===e.type?xh[e.type]:void 0}let l=!n&&a!==void 0&&Y0(i.ctor,a);if(!l)return{scope:"node",known:l,lifecycle:n,readsLayout:!0,writesLayout:!0};let c=e.args??{},d=s.props??{},u=V0(e.type,c);return{scope:"node",known:l,lifecycle:n,readsLayout:q0(e.type,c,d,u),writesLayout:u===void 0||u.some(f=>!Dl(t,s.type,f))}}function mh(t,e,r){let n=t.command(e.type),o=r??(e.targetId===null?yh:void 0),s=n?n.scope==="node"?n.args:void 0:o?t.node(o.type)?.commands.get(e.type)?.args:void 0,i=[];for(let a of s??[]){let l=e.args?.[a.key];a.kind==="nodeRef"&&typeof l=="string"&&l!==""&&i.push(l)}return i}function ci(t,e){let r=t.node(e)?.ctor;return r!==void 0&&li(r,"provideContext")!==li(he,"provideContext")}function Tl(t){for(let e of xe.collect(t,"")){let r=xe.tryParse(e.source);if("error"in r||r.expression.refs.some(n=>n.includes(".")))return!0}return!1}function Dl(t,e,r){let n=t.node(e);return!n||!_h().ctors.has(n.ctor)?!1:n.descriptor.dimension==="audio"?!0:B0.has(r)}var $0=new Set(["removeChildAt","addChildAt","reparent"]),j0=new Set(["variableTo","variableSet"]),B0=new Set(["x","y","rotation","scale","opacity","fill","stroke","shadow","overlay","effects","blend","transformOrigin","zoom","lookAt","heading"]),yh={id:O,type:"canvas2d",parentId:null,layerOrder:0,props:{}},je=["to","_prepareStep","_writeProp"],Kr=["command","set","_writeProp"],gh={to:je,set:["set","_writeProp"],save:["save"],fillTo:["fillTo",...Kr],overlayTo:["overlayTo",...Kr],strokeTo:["strokeTo",...Kr],shadowTo:["shadowTo",...Kr]},xh={...gh,restore:["restore","_prepareStep","_writeProp"],fadeTo:["fadeTo",...je],rotateTo:["rotateTo",...je],scaleTo:["scaleTo",...je],layoutTo:["layoutTo",...je],effectTo:["effectTo",...je],progressTo:["progressTo",...je],pulse:["pulse",...Kr],wiggle:["wiggle",...Kr],flash:["flash",...Kr],moveTo:["moveTo",...je,"command","set"],zoomTo:["zoomTo",...je],panTo:["panTo",...je],headingTo:["headingTo",...je],countTo:["countTo",...je],append:["append",...je],prepend:["prepend",...je]},L0={fadeTo:["opacity"],rotateTo:["rotation"],scaleTo:["scale"],layoutTo:["width","height","padding"],effectTo:["effects"],progressTo:["start","end"],pulse:["scale"],wiggle:["rotation"],flash:["start","end"],moveTo:["x","y"],zoomTo:["zoom"],panTo:["lookAt"],headingTo:["heading"],fillTo:["fill"],overlayTo:["overlay"],strokeTo:["stroke"],shadowTo:["shadow"]},W0=new Set(Object.keys(xh).filter(t=>t!=="set"&&t!=="save"));function q0(t,e,r,n){if(uh(e)||t==="moveTo"&&typeof e.target=="string"&&e.target!=="")return!0;let o=uh(r),s=G0(r);return t==="save"||t==="restore"?o||s.size>0:W0.has(t)?(t==="append"||t==="prepend"?["text"]:t==="countTo"?["value"]:n??[]).some(a=>s.has(a)||o&&(a==="x"||a==="y")):!1}function V0(t,e){let r=L0[t];if(r)return r;if(t!=="to"&&t!=="set")return;let n=[];for(let o of Object.keys(e))o==="size"?n.push("width","height"):t==="to"&&o==="pivot"?n.push("transformOrigin"):t==="to"&&hh.includes(o)?n.push("x","y","transformOrigin"):n.push(o);return n}function uh(t){return hh.some(e=>t[e]!==void 0)}var fh=new WeakMap;function G0(t){let e=fh.get(t);if(!e){let r=new Set;for(let n of Object.keys(t))Tl(t[n])&&r.add(n);fh.set(t,e=r)}return e}function li(t,e){return t.prototype[e]}var ph=new WeakMap;function Y0(t,e){let r=ph.get(t);r||ph.set(t,r=new Map);let n=r.get(e);return n===void 0&&(n=e.every(o=>{let s=li(t,o);return s===void 0||K0(o).has(s)}),r.set(e,n)),n}var Cl=null;function _h(){if(!Cl){let t=new si;Cl={ctors:new Set(t.nodeKeys().map(e=>t.node(e).ctor)),methods:new Map}}return Cl}function K0(t){let e=_h(),r=e.methods.get(t);if(!r){let n=new Set;for(let o of e.ctors)for(let s=o.prototype;s&&s!==Object.prototype;s=Object.getPrototypeOf(s)){let i=Object.getOwnPropertyDescriptor(s,t);i&&typeof i.value=="function"&&n.add(i.value)}e.methods.set(t,r=n)}return r}function Te(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return t!==t&&e!==e;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!Te(t[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let r=t,n=e,o=0;for(let s of Object.keys(r)){let i=r[s];if(i!==void 0&&(o++,!Te(i,n[s])))return!1}for(let s of Object.keys(n))n[s]!==void 0&&o--;return o===0}function H0(){return{identical:!0,kindChanged:!1,themeChanged:!1,rootChanged:!1,duration:!1,nodes:{added:new Set,removed:new Set,changed:new Set,respec:new Set,moved:new Set,span:new Set,reorderedParents:new Set},commands:{added:new Set,removed:new Set,changed:new Set,reorderedAts:new Set},variables:{added:new Set,removed:new Set,changed:new Set},remappedKeys:new Set}}function di(t,e){let r=H0();if(t===e)return r;if(t.kind!==e.kind)return r.kindChanged=!0,r.identical=!1,r;let n=wh(t),o=wh(e);r.themeChanged=!Te(t.theme,e.theme),r.duration=Et(n)!==Et(o),t.nodes!==e.nodes&&U0(n.nodes,o.nodes,r),t.variables!==e.variables&&J0(n.variables??[],o.variables??[],r);let s=n.kind==="composition"?n.commands:[],i=o.kind==="composition"?o.commands:[];return t.commands!==e.commands&&Z0(s,i,r),r.identical=!r.themeChanged&&!r.rootChanged&&!r.duration&&r.remappedKeys.size===0&&Rl(r.nodes)&&r.nodes.reorderedParents.size===0&&Rl(r.commands)&&r.commands.reorderedAts.size===0&&Rl(r.variables),r}function wh(t){return mr(t)?kn(t):t}function Rl(t){return t.added.size===0&&t.removed.size===0&&t.changed.size===0}var vh={id:O,type:"canvas2d",parentId:null,layerOrder:0,props:{}};function U0(t,e,r){let n=An(t),o=An(e),s=r.nodes,i=n.get(O)??vh,a=o.get(O)??vh;r.rootChanged=i!==a&&!X0(i,a);for(let[u,f]of n){if(u===O)continue;let h=o.get(u);if(!h){s.removed.add(u);continue}if(f===h)continue;let y=!1;(f.type!==h.type||f.key!==h.key||!Te(f.props,h.props))&&(s.respec.add(u),y=!0),f.parentId!==h.parentId&&(s.moved.add(u),y=!0),Ah(f,h)||(s.span.add(u),y=!0),(y||f.layerOrder!==h.layerOrder)&&s.changed.add(u)}for(let u of o.keys())u!==O&&!n.has(u)&&s.added.add(u);let l=Sh(t);for(let[u,f]of Sh(e)){let h=l.get(u);h!==void 0&&h!==f&&r.remappedKeys.add(u)}let c=bh(t),d=bh(e);for(let[u,f]of c){let h=d.get(u);h&&!Mh(f,h)&&s.reorderedParents.add(u)}}function X0(t,e){return t.type===e.type&&t.key===e.key&&t.parentId===e.parentId&&t.layerOrder===e.layerOrder&&Te(t.props,e.props)&&Ah(t,e)}function Ah(t,e){let r=$e(t),n=$e(e);return r.start===n.start&&r.end===n.end}function Z0(t,e,r){let n=An(t),o=An(e),s=r.commands;for(let[l,c]of n){let d=o.get(l);if(!d){s.removed.add(l);continue}c!==d&&(c.type!==d.type||c.targetId!==d.targetId||c.at!==d.at||(c.duration??0)!==(d.duration??0)||!Te(c.easing,d.easing)||!Te(c.loop,d.loop)||!Te(c.args,d.args))&&s.changed.add(l)}for(let l of o.keys())n.has(l)||s.added.add(l);let i=kh(t),a=kh(e);for(let[l,c]of i){let d=a.get(l);d&&!Mh(c,d)&&s.reorderedAts.add(l)}}function J0(t,e,r){let n=An(t),o=An(e),s=r.variables;for(let[i,a]of n){let l=o.get(i);if(!l){s.removed.add(i);continue}a!==l&&(a.lerp!==l.lerp||!Te(a.value,l.value))&&s.changed.add(i)}for(let i of o.keys())n.has(i)||s.added.add(i)}function An(t){let e=new Map;for(let r of t)e.set(r.id,r);return e}function Sh(t){let e=new Map;for(let r of t)r.key&&e.set(r.key,r.id);return e}function bh(t){let e=new Map;t.forEach((n,o)=>{if(n.id===O)return;let s=n.parentId??O,i=e.get(s);i||e.set(s,i=[]),i.push({id:n.id,order:n.layerOrder,index:o})});let r=new Map;for(let[n,o]of e)o.sort((s,i)=>s.order-i.order||s.index-i.index),r.set(n,o.map(s=>s.id));return r}function kh(t){let e=new Map;for(let r of t){let n=e.get(r.at);n||e.set(r.at,n=[]),n.push(r.id)}return e}function Mh(t,e){let r=new Set(e),n=new Set(t),o=t.filter(i=>r.has(i)),s=e.filter(i=>n.has(i));if(o.length!==s.length)return!1;for(let i=0;i<o.length;i++)if(o[i]!==s[i])return!1;return!0}function Q0(t){let e=t.indexOf(".");return e<0?void 0:{key:t.slice(0,e),prop:t.slice(e+1)}}function Fl(t,e=""){let r=[],n=[],o=0,s=new Set;for(let i of xe.collect(t,e)){let a=xe.tryParse(i.source);if("error"in a){o++;continue}for(let l of a.expression.refs){if(s.has(l))continue;s.add(l);let c=Q0(l);c?n.push([c.key,c.prop]):r.push(l)}}return{vars:r,keys:n,unparsable:o}}function zl(t){return new Il(mr(t)?kn(t):t)}var e_=Object.freeze({vars:[],keys:[],unparsable:0}),t_=new Map,Oh=[];function ui(t,e){return t!==void 0&&e>=t.start&&e<t.end}var Il=class{doc;nodes=new Map;nodeCount;variables=new Map;commands=new Map;ordered;byTarget=new Map;keyed=new Map;dependents={byVar:new Map,byKey:new Map};duration;issues={duplicateIds:!1,duplicateKeys:!1,unresolvedParent:!1,cycle:!1,invalidRoot:!1,unparsable:!1,unresolvedRefs:!1};constructor(e){this.doc=e,this.duration=Et(e);let r=e.kind==="composition"?e.commands:[];this._indexNodes(e.nodes),this.nodeCount=this.nodes.size-1;for(let n of e.variables??[])(this.variables.has(n.id)||this.nodes.has(n.id))&&(this.issues.duplicateIds=!0),this.variables.set(n.id,n);this.ordered=r.map((n,o)=>({spec:n,index:o})).sort((n,o)=>n.spec.at-o.spec.at||n.index-o.index).map(n=>n.spec);for(let n of this.ordered){this.commands.has(n.id)&&(this.issues.duplicateIds=!0),this.commands.set(n.id,n);let o=this.targetOf(n),s=this.byTarget.get(o);s||this.byTarget.set(o,s=[]),s.push(n.id);let i=this._byAt.get(n.at);i||this._byAt.set(n.at,i=[]),i.push(n)}this._ats=[...this._byAt.keys()],this._indexRefs(r)}children(e){return this._children.get(e)??Oh}descendants(e){let r=[],n=new Set([e]),o=[...this.children(e)].reverse();for(;o.length>0;){let s=o.pop();if(n.has(s))continue;n.add(s),r.push(s);let i=this.children(s);for(let a=i.length-1;a>=0;a--)o.push(i[a])}return r}ownSpan(e){let r=this.nodes.get(e);return r?$e(r):void 0}effSpan(e){let r=this._eff.get(e);if(r)return r;if(!this.nodes.has(e))return;let n=[],o=new Set,s={start:0,end:1/0},i=this.nodes.get(e);for(;i;){let a=this._eff.get(i.id);if(a){s=a;break}if(o.has(i.id)||(o.add(i.id),n.push(i),i.id===O||i.parentId===null))break;i=this.nodes.get(i.parentId)}for(let a=n.length-1;a>=0;a--){let l=$e(n[a]);s={start:Math.max(s.start,l.start),end:Math.min(s.end,l.end)},this._eff.set(n[a].id,s)}return this._eff.get(e)}targetOf(e){return e.targetId??O}commandsAt(e){return this._byAt.get(e)??Oh}bindings(e){return this._bindings.get(e)??t_}refs(e){return this._refs.get(e)??e_}initialKey(e){return ui(this.ownSpan(e),0)?ui(this.effSpan(e),0)?"mounted":"unmounted":"absent"}captureKey(e){let r=this.captureTime(e);return r===void 0?"none":ui(this.effSpan(e),r)?"arrival-mounted":"arrival-unmounted"}captureTime(e){let r=this.ownSpan(e);if(!r||ui(r,0))return;let n=0,o=this._ats.length;for(;n<o;){let i=n+o>>1;this._ats[i]<r.start?n=i+1:o=i}let s=this._ats[n];return s!==void 0&&s<r.end?s:void 0}_children=new Map;_eff=new Map;_byAt=new Map;_ats=[];_bindings=new Map;_refs=new Map;_indexNodes(e){let r=new Map;e.forEach((o,s)=>{if(this.nodes.has(o.id)&&(this.issues.duplicateIds=!0),this.nodes.set(o.id,o),o.key&&(this.keyed.has(o.key)&&(this.issues.duplicateKeys=!0),this.keyed.set(o.key,o.id)),o.id===O){(o.type!=="canvas2d"||o.parentId!==null)&&(this.issues.invalidRoot=!0);return}let i=o.parentId??O,a=r.get(i);a||r.set(i,a=[]),a.push({id:o.id,order:o.layerOrder,index:s})}),this.nodes.has(O)||this.nodes.set(O,{id:O,type:"canvas2d",parentId:null,layerOrder:0,props:{}});for(let[o,s]of r)s.sort((i,a)=>i.order-a.order||i.index-a.index),this._children.set(o,s.map(i=>i.id));let n=new Set([O]);for(let o of this.nodes.values()){o.parentId!==null&&!this.nodes.has(o.parentId)&&(this.issues.unresolvedParent=!0);let s=new Set,i=o;for(;i&&!n.has(i.id);){if(s.has(i.id)){this.issues.cycle=!0;break}s.add(i.id),i=i.parentId===null?void 0:this.nodes.get(i.parentId)}for(let a of s)n.add(a)}}_indexRefs(e){for(let r of this.nodes.values())this._bind(r.id,r.props);for(let r of e){if(r.type==="set"){let n=this.targetOf(r);if(this.nodes.has(n)){this._bind(n,r.args);continue}}Fl(r.args).unparsable>0&&(this.issues.unparsable=!0)}for(let[r,n]of this._bindings){let o=new Set,s=new Map,i=0;for(let a of n.values()){for(let l of a.vars)o.add(l);for(let l of a.keys)s.set(`${l[0]}.${l[1]}`,l);i+=a.unparsable}this._refs.set(r,{vars:[...o],keys:[...s.values()],unparsable:i});for(let a of o){this.variables.has(a)||(this.issues.unresolvedRefs=!0);let l=this.dependents.byVar.get(a);l||this.dependents.byVar.set(a,l=new Set),l.add(r)}for(let[a]of s.values()){this.keyed.has(a)||(this.issues.unresolvedRefs=!0);let l=this.dependents.byKey.get(a);l||this.dependents.byKey.set(a,l=new Set),l.add(r)}}}_bind(e,r){if(r)for(let n of Object.keys(r)){let o=Fl(r[n]);if(o.unparsable>0&&(this.issues.unparsable=!0),o.vars.length===0&&o.keys.length===0)continue;let s=this._bindings.get(e);s||this._bindings.set(e,s=new Map);let i=s.get(n);if(!i){s.set(n,o);continue}let a=new Set([...i.vars,...o.vars]),l=new Map([...i.keys,...o.keys].map(c=>[`${c[0]}.${c[1]}`,c]));s.set(n,{vars:[...a],keys:[...l.values()],unparsable:i.unparsable+o.unparsable})}}};var r_=16;function Fh(t,e,r,n,o={}){if(r.kindChanged||r.themeChanged||Eh(t)||Eh(e))return null;let s=t.nodes.get(O),i=e.nodes.get(O);if(r.rootChanged&&!n_(s,i)||e.issues.unparsable||e.issues.unresolvedRefs||r.remappedKeys.size>0)return null;let a=Ch(t,n),l=a&&Ch(e,n);if(!a||!l)return null;let{added:c,removed:d,respec:u,moved:f,span:h,reorderedParents:y}=r.nodes,w=v=>(e.byTarget.get(v)?.length??0)>0,g=(v,C,J,De)=>v.byTarget.get(J)?.some(Ce=>De(C.get(Ce)))??!1,x=v=>g(t,a,v,C=>!C.known)||g(e,l,v,C=>!C.known),_=(v,C)=>{let J=v.nodes.get(C)?.type;return J===void 0||n.dimensionOf?.(J)!=="audio"},S=v=>_(t,v)||_(e,v),b=[];for(let v of e.nodes.keys())v!==O&&t.nodes.has(v)&&b.push(v);let k=new Set,M=v=>{let C=t.nodes.get(v)?.type,J=e.nodes.get(v)?.type;return C!==void 0&&n.isContextProvider(C)||J!==void 0&&n.isContextProvider(J)},T=v=>{if(!k.has(v)&&(k.add(v),M(v)))for(let C of e.descendants(v))k.add(C)};for(let v of u)T(v);for(let v of f)if(T(v),Dh(t,v,n)||Dh(e,v,n))for(let C of e.descendants(v))k.add(C);for(let v of[...c,...d])if(M(v))for(let C of e.descendants(v))k.add(C);let V=!1;for(let v of b){let C=n.ctorOf(v);C!==void 0&&n.registeredCtor(e.nodes.get(v).type)!==C&&(T(v),S(v)&&(V=!0)),w(v)&&t.initialKey(v)!==e.initialKey(v)&&T(v)}let W=new Set,Se=new Set,Ee=v=>{e.variables.has(v)?Se.add(v):e.nodes.has(v)&&W.add(v)};for(let v of r.commands.added)Ee(e.targetOf(e.commands.get(v)));for(let v of r.commands.removed)Ee(t.targetOf(t.commands.get(v)));for(let v of r.commands.changed)Ee(t.targetOf(t.commands.get(v))),Ee(e.targetOf(e.commands.get(v)));for(let v of new Set([...t.byTarget.keys(),...e.byTarget.keys()]))i_(t.byTarget.get(v),e.byTarget.get(v))||Ee(v);for(let v of r.commands.reorderedAts){for(let C of t.commandsAt(v))Ee(t.targetOf(C));for(let C of e.commandsAt(v))Ee(e.targetOf(C))}if(r.duration)for(let v of e.commands.values())v.loop?.count===null&&Ee(e.targetOf(v));for(let v of r.variables.added)Se.add(v);for(let v of r.variables.changed)Se.add(v);let Tt=new Set;for(let v of b)s_(t.effSpan(v),e.effSpan(v))?w(v)&&(t.captureKey(v)!==e.captureKey(v)||t.captureTime(v)!==e.captureTime(v))&&W.add(v):(Tt.add(v),w(v)&&W.add(v));let Le=y.size>0||V||[...c].some(v=>_(e,v))||[...d].some(v=>_(t,v))||[...f].some(S)||[...h].some(S)||[...u].some(v=>S(v)&&Rh(t.nodes.get(v),e.nodes.get(v),n))||r.rootChanged&&Rh(s,i,n),Xe=new Set([...c,...d,...Tt]);r.rootChanged&&Xe.add(O);let qm=[...Ph(t,n),...Ph(e,n)],hc=(v,C)=>{let J=e.nodes.get(v)?.type;if(J===void 0||n.dimensionOf?.(J)==="audio")return!1;for(let[De,Ce]of e.bindings(v))if(C(Ce)&&!n.isLayoutNeutralProp(J,De))return!0;return!1},mc=-1;for(;mc!==W.size+Se.size+k.size+Xe.size+(Le?1:0);){mc=W.size+Se.size+k.size+Xe.size+(Le?1:0);for(let v of k)w(v)&&W.add(v);for(let v of k)Xe.add(v);for(let v of W)Xe.add(v);for(let v of Se)for(let C of e.dependents.byVar.get(v)??[])Xe.add(C),!Le&&hc(C,J=>J.vars.includes(v))&&(Le=!0);for(let v of Xe)for(let C of o_(t,e,v))for(let J of e.dependents.byKey.get(C)??[])Xe.add(J),!Le&&hc(J,De=>De.keys.some(([Ce])=>Ce===C))&&(Le=!0);for(let{reader:v,ref:C}of qm)(Th(t,C,Xe)||Th(e,C,Xe))&&Xe.add(v);for(let v of Xe)e.nodes.has(v)&&w(v)&&W.add(v);for(let v of W)v!==O&&x(v)&&T(v);if(!Le){for(let v of[...W,...Se])if(g(t,a,v,C=>C.writesLayout)||g(e,l,v,C=>C.writesLayout)){Le=!0;break}}if(Le)for(let v of e.byTarget.keys())e.nodes.has(v)&&g(e,l,v,C=>C.readsLayout)&&W.add(v)}if(W.has(O)&&x(O))return null;let Vm=Math.max((o.rebuildFraction??.5)*e.nodeCount,o.minRebuildNodes??r_);if(k.size>Vm)return null;let Tn;if([...W,...Se].some(v=>g(e,l,v,C=>C.readsLayout||!C.known)))Tn="all";else{Tn=new Set;let v=[],C=new Set;for(let J of W){let De=e.refs(J);De.vars.length===0&&De.keys.length===0||(e.byTarget.get(J)??[]).some(Ce=>e.commands.get(Ce).type!=="set")&&(C.add(J),v.push(J))}for(;v.length>0;){let J=e.refs(v.pop());for(let De of J.vars)!Se.has(De)&&w(De)&&Tn.add(De);for(let[De]of J.keys){let Ce=e.keyed.get(De);Ce!==void 0&&(!W.has(Ce)&&w(Ce)&&Tn.add(Ce),C.has(Ce)||(C.add(Ce),v.push(Ce)))}}}let Li=new Set([...d,...k]);for(let v of y)for(let C of e.children(v))t.nodes.has(C)&&Li.add(C);for(let v of k)for(let C of e.children(v))Li.add(C);let Wi=[];for(let v of new Set([...W,...k,...c])){if(!w(v))continue;let C=e.captureTime(v);C!==void 0&&Wi.push({at:C,id:v})}return Wi.sort((v,C)=>v.at-C.at),{prev:t,next:e,diff:r,added:c,removed:d,reinstantiate:k,detach:Li,dirtyNodes:W,dirtyVariables:Se,replay:Tn,captures:Wi,layoutChanged:Le}}function Eh(t){let{duplicateIds:e,duplicateKeys:r,unresolvedParent:n,cycle:o,invalidRoot:s}=t.issues;return e||r||n||o||s}function Ch(t,e){let r=new Map;for(let n of t.ordered){let o=t.targetOf(n),s=t.nodes.get(o),i=e.traits(n,s);if(!i||i.lifecycle||(i.scope==="variable"?!t.variables.has(o):!s))return null;r.set(n.id,i)}return r}function Ph(t,e){if(!e.nodeRefs)return[];let r=[];for(let n of t.ordered){let o=t.targetOf(n);for(let s of e.nodeRefs(n,t.nodes.get(o)))r.push({reader:o,ref:s})}return r}function Th(t,e,r){let n=new Set,o=e;for(;o!==void 0&&!n.has(o);){if(r.has(o))return!0;n.add(o);let s=t.nodes.get(o);if(!s||o===O)return!1;o=s.parentId??O}return!1}function Dh(t,e,r){let n=new Set([e]),o=t.nodes.get(e);for(;o&&o.id!==O;){let s=o.parentId??O;if(n.has(s))return!1;if(n.add(s),o=t.nodes.get(s),o&&r.isContextProvider(o.type))return!0}return!1}function n_(t,e){let r=$e(t),n=$e(e);return t.type===e.type&&t.key===e.key&&t.parentId===e.parentId&&t.layerOrder===e.layerOrder&&r.start===n.start&&r.end===n.end}function Rh(t,e,r){if(t.type!==e.type||t.key!==e.key)return!0;for(let n of new Set([...Object.keys(t.props),...Object.keys(e.props)]))if(!Te(t.props[n],e.props[n])&&!r.isLayoutNeutralProp(e.type,n))return!0;return!1}function o_(t,e,r){let n=[],o=t.nodes.get(r)?.key,s=e.nodes.get(r)?.key;return o&&n.push(o),s&&s!==o&&n.push(s),n}function s_(t,e){return t?.start===e?.start&&t?.end===e?.end}function i_(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function a_(t,e){if(t)switch(t.kind){case"linear":return is();case"in":return $u(t.args);case"out":return ju(t.args);case"inOut":return Bu(t.args);case"custom":{let r=t.args;if(ni(r))return Gp(r);if(typeof r!="string")throw new Error(`A "custom" ease needs a curve or its Registry.addEase key in \`args\` (got ${JSON.stringify(t.args)}).`);let n=e.ease(r);if(!n)throw new Error(`No ease registered under "${r}". Registered: ${e.easeKeys().join(", ")||"none"}.`);return n}}}function l_(t){return t.map((e,r)=>({spec:e,index:r})).sort((e,r)=>e.spec.at-r.spec.at||e.index-r.index).map(e=>e.spec)}function c_(){return{id:O,type:"canvas2d",parentId:null,layerOrder:0,props:{}}}function Ih(t){let e=[],r;for(let n of t){if(n.id===O&&n.type==="canvas2d"){r=n;continue}e.push(n)}return{root:r??c_(),rest:e}}function zh(t){let e=new Map;for(let r of t.nodes)e.set(r.id,$e(r));return e.delete(O),e}var pi=class{canvas;constructor(e,r,n){this.canvas=n,this._doc=e,this._registry=r;let{root:o,rest:s}=Ih(e.nodes);this._rootSpec=o,this._specs=s,this._varSpecs=e.variables??[],this._keyed=new Map([o,...s].filter(i=>!!i.key).map(i=>[i.key,i.id])),this._spans=zh(e),this._duration=Et(e)}get duration(){return this._duration}build(){this._buildVariables(),this._pristineRoot=Cs(this.canvas),this._applyRootProps();for(let e of this._specs)this._live.set(e.id,{spec:e,node:this._instantiate(e),initial:gr,initialStackDepth:0,baseline:gr,baseStackDepth:0,presence:new Ke(!1,null,rr+e.id)});this._baseChildCount.set(O,this.canvas._allChildren.length);for(let[e,r]of this._live)this._baseChildCount.set(e,r.node._allChildren.length);this.syncPresence(0),this._root={spec:this._rootSpec,node:this.canvas,initial:gr,initialStackDepth:0,baseline:gr,baseStackDepth:0,presence:new Ke(!0,null,rr+O)};for(let e of this._live.values())fi(e);fi(this._root),this._baselined=new Set(this._present);for(let e of this._present)this._live.get(e)?.node.mounted===!1&&(this._baselined.delete(e),this._unmounted.add(e))}compile(e=()=>{}){this._compileCommands(e),this._restoreBaselines();let r=this.syncPresence(0);(this._restoreDisplaced(this._collectDisplaced())||r)&&e()}variableValue(e){return this._vars.get(e)?.cell.get()}variables(){return this._varSpecs}placedCommands(){return this._placed}evaluateAt(e,r){if(r){Es(()=>this._restoreBaselines()),this._evaluateObserved(e,r);return}this._restoreBaselines();for(let n of this._placed){if(e<n.start)continue;let o=n.duration>0?(e-n.start)/n.duration:1;n.command.at(pt(o))}}syncPresence(e){let r=this._presenceIndex().crossed(e);if(r.length===0)return!1;let n=[],o=[];for(let i of r){let a=hi(i,e);a!==this._present.has(i.id)&&(a?n:o).push(i)}if(this._arrived=n,n.length===0&&o.length===0)return!1;o.sort(jh);for(let i of o){this._present.delete(i.id),i.siblings.add(i.slot,-1);let a=this._live.get(i.id);a&&(a.presence.set(!1),this._parentNodeOf(a.spec)?.remove(a.node))}n.sort(jh);let s=new Map;for(let i of n){let a=s.get(i.siblings);a?a.push(i):s.set(i.siblings,[i])}for(let[i,a]of s){a.sort((d,u)=>d.slot-u.slot);let l=i.parentId===O?this.canvas:this._live.get(i.parentId)?.node,c=this._baseChildCount.get(i.parentId)??0;for(let d of a){this._present.add(d.id);let u=c+i.before(d.slot);i.add(d.slot,1);let f=this._live.get(d.id);f&&(f.presence.set(!0),l?.addChildAt({data:{child:f.node,index:u}}))}}return!0}liveNode(e){return e===O?this.canvas:this._live.get(e)?.node}baselineProps(e){let r=e===O?this._root:this._live.get(e);if(!r)return;let n=r.baseline===gr?r.initial:r.baseline,o={};for(let[s,i]of n)o[s]=i.fn?i.fn():i.value;return o}presenceSlot(e){return e===O?this._root?.presence:this._live.get(e)?.presence}variableSlot(e){return this._vars.get(e)?.cell}planUpdate(e){let r=this._docIndex??=zl(this._doc);return Fh(r,zl(e),di(this._doc,e),this._patchEnvironment())}applyUpdate(e,r,n){if(!this._root)throw new Error("ClipTimeline.applyUpdate needs a built timeline.");if(e.prev!==this._docIndex)throw new Error("This patch was planned against a different version of the document.");this._restoreBaselines(),this.syncPresence(0),this._updateVariables(e),this._keyed.clear();for(let[u,f]of e.next.keyed)this._keyed.set(u,f);let o=this._updateStructure(e);for(let u of o){fi(u);let f=u.spec.id;this._present.has(f)&&(u.node.mounted?this._baselined.add(f):this._unmounted.add(f))}if(e.diff.rootChanged){let u=this.canvas;Dr(u,this._pristineRoot),u._stateStack.length=0,this._applyRootProps(),fi(this._root)}for(let u of e.dirtyNodes){let f=u===O?this._root:this._live.get(u);f&&!o.has(f)&&d_(f)}n();let s=new Map;for(let u of this._placed)s.set(u.spec.id,u);let i=this._walkPatch(e,s,r),a=u=>e.dirtyNodes.has(u)||e.dirtyVariables.has(u),l=[],c=new Set;if(this._animated=[],this._animatedVars=[],this._animatedParts=[],!Qs(this._doc))for(let u of e.next.ordered){let f=i.get(u.id);if(!f&&!a(e.next.targetOf(u))){let h=s.get(u.id);h&&(f=h.spec===u?h:{...h,spec:u})}f&&(l.push(f),this._touch(f,c))}this._placed=l,this._restoreBaselines();let d=this.syncPresence(0);(this._restoreDisplaced(this._collectDisplaced())||d)&&r()}_doc;_registry;_rootSpec;_specs;_varSpecs;_spans;_duration;_docIndex=null;_pristineRoot=gr;_live=new Map;_vars=new Map;_keyed;_placed=[];_root=null;_animated=[];_animatedVars=[];_animatedParts=[];_partBaselines=new WeakMap;_baseChildCount=new Map;_present=new Set;_baselined=new Set;_displaced=[];_unmounted=new Set;_presence=null;_arrived=[];_resolveVariable=e=>{let r=e.indexOf(".");if(r>0){let n=this._keyed.get(e.slice(0,r));if(n===void 0)return;let o=e.slice(r+1);return()=>this._nodeById(n)?.[o]}return this._vars.get(e)?.read};_nodeById(e){if(e===O)return this.canvas;let r=this._live.get(e);if(r)return L!==null&&this._readPresence(r),r.node.mounted?r.node:void 0}_readPresence(e){let r=e;for(let n=0;r&&n<=this._live.size;n++)r.presence.get(),r=r.spec.parentId===null?void 0:this._live.get(r.spec.parentId)}_applyRootProps(){let{literal:e,bindings:r}=xe.bindProps(this._rootSpec.props,this._resolveVariable);this.canvas.set({...e,...r})}_instantiate(e){let{literal:r,bindings:n,hasBindings:o}=xe.bindProps(e.props,this._resolveVariable),s=this._registry.instantiate(e,r);return o&&s.set(n),s}_buildVariables(){for(let e of this._varSpecs){if(this._vars.has(e.id))throw new Error(`Duplicate variable id "${e.id}". Ids must be unique \u2014 an expression writing "[${e.id}]" would otherwise name whichever declaration was read last.`);this._vars.set(e.id,this._liveVariable(e))}}_liveVariable(e){let r=new Ke(e.value,null,Os+e.id);return{spec:e,cell:r,read:()=>r.get(),target:this._variableTarget(e,r),baseline:e.value}}_variableTarget(e,r){let n=this._registry.requireLerp(e.lerp,e.value,`variable "${e.id}"`);return{id:e.id,get:()=>r.get(),set:o=>r.set(o),lerp:n}}_restoreBaselines(){this._restoreDisplaced(this._displaced);for(let e of this._animatedVars)e.cell.set(e.baseline);for(let e of this._animated){let r=e.node;Dr(r,e.baseline),r._stateStack.length>e.baseStackDepth&&(r._stateStack.length=e.baseStackDepth)}for(let e of this._animatedParts)e.restoreFrom(this._partBaselines.get(e))}_compileCommands(e){if(Qs(this._doc))return;let r=new Set,n=l_(this._doc.commands),o=this._refBound(n),s=this._settleWindows(n,i=>this._readsLayout(n[i],o));for(let i=0;i<n.length;i++){let a=n[i];if(this.syncPresence(a.at)){for(let c of this._arrived)this._baselined.has(c.id)||this._baselineArrival(c.id);this._baselineMounted(),s[i]&&e()}let l=this._buildPlaced(a);this._placed.push(l),this._touch(l,r)}}_collectDisplaced(){let e=[];for(let r of this._present){let n=this._live.get(r),o=n&&this._declaredParent(r);n&&o&&n.node.parent!==o&&e.push(n)}return e.sort((r,n)=>this._presenceIndex().row(r.spec.id).slot-this._presenceIndex().row(n.spec.id).slot),this._displaced=e}_restoreDisplaced(e){let r=!1;for(let n of e){let o=n.spec.id,s=this._presenceIndex().row(o),i=this._declaredParent(o);if(!s||!i||!this._present.has(o)||n.node.parent===i)continue;n.node.parent?.remove(n.node);let a=this._baseChildCount.get(s.siblings.parentId)??0;i.addChildAt({data:{child:n.node,index:a+s.siblings.before(s.slot)}}),r=!0}return r}_declaredParent(e){let r=this._presenceIndex().row(e)?.siblings.parentId;if(r!==void 0)return r===O?this.canvas:this._live.get(r)?.node}_baselineArrival(e){let r=this._live.get(e);if(r&&!r.node.mounted){this._unmounted.add(e);return}r&&$l(r),this._baselined.add(e),this._unmounted.delete(e)}_baselineMounted(){for(let e of this._unmounted){let r=this._live.get(e);r?r.node.mounted&&($l(r),this._baselined.add(e),this._unmounted.delete(e)):this._unmounted.delete(e)}}_buildPlaced(e){let r=this._registry.command(e.type);if(!r){let f=this._targetOrThrow(e).entry.spec.type,h=this._registry.nodeCommand(f,e.type);if(!h)throw new Error(`Node type "${f}" has no command "${e.type}" (command ${e.id}). It publishes: ${this._registry.commandKeys(f).join(", ")||"none"}.`+(Nh[e.type]?` ${Nh[e.type]}`:""));r={key:e.type,scope:"node",factory:h}}let n=e.duration??0,o=a_(e.easing,this._registry),s=new Nl(this._notePartWrite),i=_c(e.loop)?e.loop:void 0,a=f=>f&&i?vc(f,i,this._unlimitedFill(e.at)):f;if(r.scope==="variable"){let f=e.targetId===null?void 0:this._vars.get(e.targetId);if(!f)throw new Error(`Command ${e.id} ("${e.type}") targets variable "${e.targetId}", which this document does not declare.`);this._assertNoExpressions(e);let{factory:h}=r,y=It(s,()=>$h(()=>a(h(f.target,e.args,n,o))));return{spec:e,start:e.at,duration:i?y.duration:n,command:y,writes:s.writes,readsLayout:s.readsLayout,owner:f}}let l=this._targetOrThrow(e),c=r.binds?this._bindArgs(e.args):(this._assertNoExpressions(e),e.args),{factory:d}=r,u=It(s,()=>$h(()=>a(d(l.node,c,n,o))));return{spec:e,start:e.at,duration:i?u.duration:n,command:u,writes:s.writes,readsLayout:s.readsLayout,owner:l.entry}}_unlimitedFill(e){return Math.max(0,this._duration-e)}_touch(e,r){this._touchOwner(e.owner,r);for(let n of e.writes){let o=n._host;if(o===null)continue;let s=o.id===O?this._root:this._live.get(o.id);s?this._touchOwner(s,r):this._partBaselines.has(n)&&!r.has(n)&&(r.add(n),this._animatedParts.push(n))}}_touchOwner(e,r){r.has(e)||(r.add(e),"cell"in e?this._animatedVars.push(e):this._animated.push(e))}_notePartWrite=e=>{let r=e._host;r===null||this._partBaselines.has(e)||r.id===O||this._live.has(r.id)||this._partBaselines.set(e,e.snapshot())};_bindArgs(e){let{literal:r,bindings:n}=xe.bindProps(e,this._resolveVariable,"args");return{...r,...n}}_assertNoExpressions(e){let r=xe.collect(e.args,"args");if(r.length===0)return;let{path:n,source:o}=r[0];throw new Error(`Command ${e.id} ("${e.type}") carries an expression at ${n}: ${JSON.stringify(o)}. Expressions bind a prop to a variable; they are not tween destinations. Bind the prop where the node is authored (or with a "set" command) and animate the variable with "variableTo" instead.`)}_targetOrThrow(e){let r=this._targetOf(e);if(!r)throw new Error(`Command ${e.id} ("${e.type}") targets node "${e.targetId}", which this document does not declare.`);return r}_targetOf(e){if(e.targetId===null)return this._root?{id:O,node:this._root.node,entry:this._root}:null;let r=this._live.get(e.targetId);return r?{id:e.targetId,node:r.node,entry:r}:null}_evaluateObserved(e,r){let n=0;It({read:()=>{},write:s=>r(n,s)},()=>{for(;n<this._placed.length;n++){let s=this._placed[n];if(e<s.start)continue;let i=s.duration>0?(e-s.start)/s.duration:1;s.command.at(pt(i))}})}_settleWindows(e,r){let n=this._presenceIndex(),o=new Uint8Array(e.length),s=-1,i=n.time;for(let a=0;a<e.length;a++){let{at:l}=e[a];n.differs(i,l)&&(s=a),i=l,!(s<0||o[s])&&r(a)&&(o[s]=1)}return o}_readsLayout(e,r){let n=e.targetId??O,o=e.targetId===null?this._rootSpec:this._live.get(e.targetId)?.spec,s=Pl(this._registry,e,o);return s===null||s.readsLayout||r.has(n)}_refBound(e){let r=new Set;for(let n of e){let o=this._registry.command(n.type);o?.scope==="node"&&o.binds&&Tl(n.args)&&r.add(n.targetId??O)}return r}_presenceIndex(){return this._presence??=new mi(this._specs,this._spans)}_parentNodeOf(e){return e.parentId===null?this.canvas:this._live.get(e.parentId)?.node}_patchEnvironment(){let e=this._registry;return{traits:(r,n)=>Pl(e,r,n),nodeRefs:(r,n)=>mh(e,r,n),isContextProvider:r=>ci(e,r),isLayoutNeutralProp:(r,n)=>Dl(e,r,n),ctorOf:r=>this._live.get(r)?.node.constructor,registeredCtor:r=>e.node(r)?.ctor,dimensionOf:r=>e.node(r)?.descriptor.dimension}}_updateVariables(e){let{added:r,removed:n,changed:o}=e.diff.variables;for(let s of n)this._vars.delete(s);for(let s of r)this._vars.set(s,this._liveVariable(e.next.variables.get(s)));for(let s of o){let i=e.next.variables.get(s),a=this._vars.get(s);if(!a){this._vars.set(s,this._liveVariable(i));continue}a.baseline=i.value,a.target=this._variableTarget(i,a.cell)}for(let s of e.next.variables.values()){let i=this._vars.get(s.id);i&&(i.spec=s)}for(let s of e.dirtyVariables){let i=this._vars.get(s);i&&i.cell.set(i.baseline)}}_updateStructure(e){let{next:r}=e;for(let l of e.detach){let c=this._live.get(l);c&&(c.node.parent?.remove(c.node),c.presence.set(!1),this._present.delete(l))}let n=l=>this._live.get(l.id)?.node===l;for(let l of e.removed){let c=this._live.get(l);c&&(jl(c.node,n),this._live.delete(l),this._baseChildCount.delete(l),this._baselined.delete(l),this._unmounted.delete(l))}for(let l of e.reinstantiate){let c=this._live.get(l);c&&jl(c.node,n)}let{root:o,rest:s}=Ih(r.doc.nodes),i=new Set;for(let l of s){let c=this._live.get(l.id);if(c&&!e.reinstantiate.has(l.id)){c.spec=l;continue}let d=this._instantiate(l);c?(c.spec=l,c.node=d,this._baselined.delete(l.id),this._unmounted.delete(l.id)):(c={spec:l,node:d,initial:gr,initialStackDepth:0,baseline:gr,baseStackDepth:0,presence:new Ke(!1,null,rr+l.id)},this._live.set(l.id,c)),this._baseChildCount.set(l.id,d._allChildren.length),i.add(c)}this._doc=r.doc,this._docIndex=r,this._rootSpec=o,this._root.spec=o,this._specs=s,this._varSpecs=r.doc.variables??[],this._spans=zh(r.doc),this._duration=Et(r.doc);let a=this._presence=new mi(this._specs,this._spans);for(let l of[...this._present]){let c=a.row(l);if(c&&hi(c,0)){c.siblings.add(c.slot,1);continue}this._present.delete(l);let d=this._live.get(l);d&&(d.presence.set(!1),d.node.parent?.remove(d.node))}return this.syncPresence(0),i}_walkPatch(e,r,n){let o=new Map;if(Qs(this._doc))return o;let{next:s}=e,i=y=>e.dirtyNodes.has(y)||e.dirtyVariables.has(y),a=this._refBound(s.ordered),l=e.replay;l!=="all"&&[...a].some(i)&&(l="all");let c=[],{captures:d}=e,u=0;for(let y of s.ordered){for(;u<d.length&&d[u].at<=y.at;)c.push({at:d[u].at,capture:d[u++].id});let w=s.targetOf(y);(l==="all"||i(w)||l.has(w))&&c.push({at:y.at,spec:y})}for(;u<d.length;u++)c.push({at:d[u].at,capture:d[u].id});let f=this._settleWindows(c,y=>{let w=c[y].spec;return w!==void 0&&i(s.targetOf(w))&&this._readsLayout(w,a)}),h=!1;for(let y=0;y<c.length;y++){let w=c[y];if(f[y]&&(h=!0),this.syncPresence(w.at)&&this._baselineMounted(),w.capture!==void 0){this._baselined.delete(w.capture),this._baselineArrival(w.capture);continue}h&&(n(),h=!1);let g=w.spec,x=r.get(g.id);if(x&&!i(s.targetOf(g))){x.command.at(1);continue}o.set(g.id,this._buildPlaced(g))}return o}},Nh={add:"A node is a row in `nodes`, entering at its `startAt`.",remove:"A node leaves at its `endAt`.",variable:"A variable is declared in `variables`."},gr=new Map,Nl=class{firstWrite;writes=new Set;readsLayout=!1;constructor(e){this.firstWrite=e}read(e){e._name===tr&&(this.readsLayout=!0)}write(e){this.writes.has(e)||(this.firstWrite(e),this.writes.add(e))}};function $h(t){let e=t();return e?(e.at(1),e):We(0,()=>{t()})}function $l(t){let e=t.node;t.baseline=Cs(e),t.baseStackDepth=e._stateStack.length}function fi(t){$l(t),t.initial=t.baseline,t.initialStackDepth=t.baseStackDepth}function d_(t){let e=t.node;Dr(e,t.initial),e._stateStack.length>t.initialStackDepth&&(e._stateStack.length=t.initialStackDepth),t.baseline=t.initial,t.baseStackDepth=t.initialStackDepth}function jl(t,e){for(let r of t._allChildren)e(r)||jl(r,e);t.dispose()}function hi(t,e){return e>=t.start&&e<t.end}function jh(t,e){return t.order-e.order}var Bl=class{parentId;constructor(e,r){this.parentId=e,this._tree=new Int32Array(r+1)}add(e,r){for(let n=e+1;n<this._tree.length;n+=n&-n)this._tree[n]+=r}before(e){let r=0;for(let n=e;n>0;n-=n&-n)r+=this._tree[n];return r}_tree},mi=class{time=-1/0;constructor(e,r){let n=new Map;e.forEach((o,s)=>{if(!r.has(o.id))return;let i=o.parentId??O,a=n.get(i);a?a.push({spec:o,order:s}):n.set(i,[{spec:o,order:s}])});for(let[o,s]of n){s.sort((a,l)=>a.spec.layerOrder-l.spec.layerOrder);let i=new Bl(o,s.length);s.forEach(({spec:a,order:l},c)=>{let{start:d,end:u}=r.get(a.id),f={id:a.id,start:d,end:u,order:l,slot:c,siblings:i,pass:0};this._rows.set(a.id,f),this._events.push({time:d,row:f}),Number.isFinite(u)&&this._events.push({time:u,row:f})})}this._events.sort((o,s)=>o.time-s.time)}crossed(e){this.time=e;let r=this._upperBound(e);if(r===this._cursor)return u_;let n=Math.min(r,this._cursor),o=Math.max(r,this._cursor);this._cursor=r;let s=++this._pass,i=[];for(let a=n;a<o;a++){let{row:l}=this._events[a];l.pass!==s&&(l.pass=s,i.push(l))}return i}differs(e,r){let n=this._upperBound(Math.min(e,r)),o=this._upperBound(Math.max(e,r));for(let s=n;s<o;s++){let{row:i}=this._events[s];if(hi(i,e)!==hi(i,r))return!0}return!1}row(e){return this._rows.get(e)}_events=[];_rows=new Map;_cursor=0;_pass=0;_upperBound(e){let r=0,n=this._events.length;for(;r<n;){let o=r+n>>>1;this._events[o].time<=e?r=o+1:n=o}return r}},u_=[];function Rz(t){return t.x===0&&t.y===0&&t.scale===1&&t.rotation===0}function f_(t){let e=t.fontFamily;if(typeof e=="string"&&e!=="")return e;let r=Ec();if(r!=="")return r;let n=t.text?` drawing "${t.text.slice(0,32)}"`:"";throw new Error(`Text${n} has no fontFamily. Set one on the text itself, on an enclosing <DefaultTextStyle>, or as the theme's \`default\` typography preset \u2014 there is no fallback face.`)}function Fz(t){let e=t.width??0,r=t.height??0,{x:n,y:o,pivot:s}=tt(t,e,r);return{...et(t),opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:n,y:o,start:t.start??0,end:t.end??1,pivot:Ae(s),text:t.text??"",fontSize:t.fontSize??48,fontFamily:f_(t),fontWeight:t.fontWeight??400,fontStyle:t.fontStyle??"normal",letterSpacing:t.letterSpacing??0,lineHeight:t.lineHeight??0,textAlign:t.textAlign??"center",verticalAlign:t.verticalAlign??"center",textDecoration:t.textDecoration??"none",wrap:t.wrap??!1,minFontSize:t.minFontSize??12,width:t.width??0,height:t.height??0,segments:t.segments,path:t.path??null}}function Nz(t){let e=t.width??0,r=t.height??0,{x:n,y:o,pivot:s}=tt(t,e,r);return{...et(t),opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:n,y:o,start:t.start??0,end:t.end??1,pivot:Ae(s),spans:t.spans??[],lineHeight:t.lineHeight??1.2,textAlign:t.textAlign??"center",width:e,height:r}}function jz(t){return{x:t.x??0,y:t.y??0,width:t.width??0,height:t.height??0,opacity:t.opacity??1,blend:t.blend??"pass-through",rotation:t.rotation??0,scale:t.scale??1,effects:t.effects??[],pivot:t.pivot??{x:0,y:0},matrix:t.matrix}}function Wz(t){return typeof t=="string"?t:t.map(e=>{switch(e.type){case"M":case"m":return`${e.type} ${e.x} ${e.y}`;case"L":case"l":return`${e.type} ${e.x} ${e.y}`;case"T":case"t":return`${e.type} ${e.x} ${e.y}`;case"H":case"h":return`${e.type} ${e.x}`;case"V":case"v":return`${e.type} ${e.y}`;case"C":case"c":return`${e.type} ${e.x1} ${e.y1} ${e.x2} ${e.y2} ${e.x} ${e.y}`;case"S":case"s":return`${e.type} ${e.x2} ${e.y2} ${e.x} ${e.y}`;case"Q":case"q":return`${e.type} ${e.x1} ${e.y1} ${e.x} ${e.y}`;case"A":case"a":return`${e.type} ${e.rx} ${e.ry} ${e.rotation} ${e.largeArc} ${e.sweep} ${e.x} ${e.y}`;case"Z":case"z":return e.type}}).join(" ")}function qz(t){return{opacity:t.opacity??1,rotation:t.rotation??0,scale:t.scale??1,x:t.x??0,y:t.y??0,start:t.start??0,end:t.end??1,width:t.width??0,height:t.height??0,pivot:Ae(t.pivot),data:t.data??"",centerBounds:t.centerBounds}}var p_=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing"],h_=["lineHeight","textAlign"];function Lh(t,e){let r=Bh(e)?e:Jt,n=t.ops(),o=null;for(let s=0;s<n.length;s++){let i=n[s];if(i.kind!=="text"&&i.kind!=="richText")continue;let a=m_(i.state.variant,r);if(!Bh(a))continue;let l=i.kind==="text"?y_(i,a):g_(i,a);l&&(o||(o=n.slice()),o[s]=l)}return o?t._withOps(o):t}function m_(t,e){return oe.mergeStyle(e,t?oe.preset(t):void 0)}function Bh(t){for(let e of gs)if(t[e]!==void 0)return!0;return!1}function y_(t,e){let r=Ll(t.state,e,gs);return r?{kind:"text",state:r}:null}function g_(t,e){let r=Ll(t.state,e,h_),n=x_(t.state.spans,e);return n&&(r={...r??t.state,spans:n}),r?{kind:"richText",state:r}:null}function x_(t,e){if(!t||t.length===0)return null;let r=e.fontSize==="autofit"?{...e,fontSize:void 0}:e,n=null;for(let o=0;o<t.length;o++){let s=Ll(t[o],r,p_);s&&((n??=t.slice())[o]=s)}return n}function Ll(t,e,r){let n=t,o=null;for(let s of r){if(n[s]!==void 0)continue;let i=e[s];i!==void 0&&((o??={...n})[s]=i)}return o}var xo=class{textStyleStack=[];pushTextStyle(e){this.textStyleStack.push(e===null?Jt:oe.mergeStyle(this.defaultTextStyle,e))}popTextStyle(){this.textStyleStack.pop()}get defaultTextStyle(){return this.textStyleStack[this.textStyleStack.length-1]??oe.preset("default")}draw(e){this.drawGraphics(Lh(e,this.defaultTextStyle))}layoutTextBlock(e){return null}currentNodeStack=[];currentNodeId(){if(this.currentNodeStack.length===0)throw new Error("No current node in context");return this.currentNodeStack[this.currentNodeStack.length-1]}_disposed=!1;isDisposed(){return this._disposed}dispose(){this._disposed=!0}beginEffects(e,r,n,o){}endEffects(){}rasterize(e,r,n,o){return null}renderStateStack=[];readsSpaceRects=!0;drawsVisibleOnly=!0;begin(e){this.currentNodeStack.push(e.id),this.renderStateStack.push(e)}end(){this.currentNodeStack.pop(),this.renderStateStack.pop()}currentSpaceRects(){return this.renderStateStack[this.renderStateStack.length-1]?.rects??{}}currentRenderState(){return this.renderStateStack[this.renderStateStack.length-1]}_resetScopes(){this.textStyleStack.length=0,this.currentNodeStack.length=0,this.renderStateStack.length=0}};function Wl(t){let e=t.lines[t.lines.length-1];return e?e.end+1:1}function Wh(t){return typeof t?.layoutTextBlock=="function"?t:null}var __={width:0,height:0},ql=class extends xo{readsSpaceRects=!1;drawGraphics(e){}measureText(){return __}unmount(){}execute(e){e()}screenshot(){}rasterize(e,r,n){return n(),null}transform(e){return this}beginBoolean(e){}endBoolean(){}beginMask(e){}applyMask(){}endMask(){}beginClip(e){}endClip(){}beginCamera(e,r,n,o){}endCamera(){}};var w_={box:t=>({type:"box",...t}),sphere:t=>({type:"sphere",...t}),plane:t=>({type:"plane",...t}),cylinder:t=>({type:"cylinder",...t}),cone:t=>({type:"cone",...t}),torus:t=>({type:"torus",...t}),torusKnot:t=>({type:"torusKnot",...t}),circle:t=>({type:"circle",...t}),ring:t=>({type:"ring",...t}),capsule:t=>({type:"capsule",...t}),tetrahedron:t=>({type:"polyhedron",shape:"tetrahedron",...t}),octahedron:t=>({type:"polyhedron",shape:"octahedron",...t}),icosahedron:t=>({type:"polyhedron",shape:"icosahedron",...t}),dodecahedron:t=>({type:"polyhedron",shape:"dodecahedron",...t}),extrude:t=>({type:"extrude",...t}),lathe:t=>({type:"lathe",...t}),tube:t=>({type:"tube",...t}),buffer:t=>({type:"buffer",...t}),parametric:t=>({type:"parametric",...t}),edges:(t,e)=>({type:"edges",source:t,...e}),wireframe:t=>({type:"wireframe",source:t}),model:(t,e)=>({type:"modelGeometry",src:t,...e})},v_={basic:t=>({type:"basic",...t}),standard:t=>({type:"standard",...t}),physical:t=>({type:"physical",...t}),phong:t=>({type:"phong",...t}),lambert:t=>({type:"lambert",...t}),toon:t=>({type:"toon",...t}),normal:t=>({type:"normal",...t}),depth:t=>({type:"depth",...t}),matcap:t=>({type:"matcap",...t}),points:t=>({type:"points",...t}),lineBasic:t=>({type:"lineBasic",...t}),lineDashed:t=>({type:"lineDashed",...t}),sprite:t=>({type:"sprite",...t}),shadow:t=>({type:"shadow",...t}),shader:t=>({type:"shader",...t})},S_={image:(t,e)=>({src:t,...e}),data:(t,e,r,n)=>({data:t,width:e,height:r,...n}),surface:(t,e)=>({width:512,height:512,...e,source:t})};function b_(t,e){return t===void 0?e.map(Vl):typeof t=="number"?e.map(()=>Vl(t)):e.map((r,n)=>Vl(t[n]??r))}function Vl(t){return Math.max(1,Math.floor(t))}function k_(t,e){return e<=0?3:Math.max(3,Math.min(16,Math.round(t/e*40)))}function A_(t){let e=[t.width/2,t.height/2,t.depth/2],r=Math.max(e[0],e[1],e[2]),n=Math.max(0,Math.min(t.radius,e[0],e[1],e[2])),o=[Math.max(0,e[0]-n),Math.max(0,e[1]-n),Math.max(0,e[2]-n)],s=k_(n,r),i=[],a=[],l=[],c=[];for(let d of M_(e,o,n,t.segments,s))O_(d,e,i,a,l,c);return{type:"buffer",position:new Float32Array(i),normal:new Float32Array(a),uv:new Float32Array(l),index:new Uint32Array(c),staticData:!0}}function*M_(t,e,r,n,o){let s=[0,1,2],i=[-1,1];for(let a of s){let l=(a+1)%3,c=(a+2)%3;for(let d of i){let u=C_(a,d);yield{uSteps:n[l],vSteps:n[c],normal:()=>u,position:(f,h)=>{let y=[0,0,0];return y[a]=d*t[a],y[l]=Gl(-e[l],e[l],f),y[c]=Gl(-e[c],e[c],h),y}}}}if(!(r<=0)){for(let a of s){let l=(a+1)%3,c=(a+2)%3;for(let d of i)for(let u of i)yield{uSteps:o,vSteps:n[a],normal:f=>{let h=f*Math.PI/2,y=[0,0,0];return y[l]=d*Math.cos(h),y[c]=u*Math.sin(h),y},position:(f,h)=>{let y=f*Math.PI/2,w=[0,0,0];return w[l]=d*(e[l]+r*Math.cos(y)),w[c]=u*(e[c]+r*Math.sin(y)),w[a]=Gl(-e[a],e[a],h),w}}}for(let a of i)for(let l of i)for(let c of i){let d=[a*e[0],l*e[1],c*e[2]],u=(f,h)=>{let y=f*Math.PI/2,w=h*Math.PI/2;return[a*Math.sin(y)*Math.cos(w),l*Math.cos(y),c*Math.sin(y)*Math.sin(w)]};yield{uSteps:o,vSteps:o,normal:u,position:(f,h)=>{let y=u(f,h);return[d[0]+r*y[0],d[1]+r*y[1],d[2]+r*y[2]]}}}}}function O_(t,e,r,n,o,s){let i=r.length/3,a=t.uSteps+1,l=t.vSteps+1;for(let c=0;c<l;c++)for(let d=0;d<a;d++){let u=t.uSteps===0?0:d/t.uSteps,f=t.vSteps===0?0:c/t.vSteps,h=t.position(u,f),y=t.normal(u,f);r.push(h[0],h[1],h[2]),n.push(y[0],y[1],y[2]);let[w,g]=E_(h,y,e);o.push(w,g)}for(let c=0;c<t.vSteps;c++)for(let d=0;d<t.uSteps;d++){let u=i+c*a+d,f=u+1,h=u+a,y=h+1;qh(r,n,s,u,h,f),qh(r,n,s,f,h,y)}}function qh(t,e,r,n,o,s){let i=t[n*3],a=t[n*3+1],l=t[n*3+2],c=t[o*3],d=t[o*3+1],u=t[o*3+2],f=t[s*3],h=t[s*3+1],y=t[s*3+2],w=c-i,g=d-a,x=u-l,_=f-i,S=h-a,b=y-l,k=g*b-x*S,M=x*_-w*b,T=w*S-g*_;if(k*k+M*M+T*T<1e-20)return;k*e[n*3]+M*e[n*3+1]+T*e[n*3+2]>=0?r.push(n,o,s):r.push(n,s,o)}function E_(t,e,r){let n=Math.abs(e[0]),o=Math.abs(e[1]),s=Math.abs(e[2]),i=n>=o&&n>=s?0:o>=s?1:2,a=(i+1)%3,l=(i+2)%3;return[r[a]===0?.5:.5+t[a]/(2*r[a]),r[l]===0?.5:.5+t[l]/(2*r[l])]}function C_(t,e){let r=[0,0,0];return r[t]=e,r}function Gl(t,e,r){return t+(e-t)*r}function Vh(t){return t===void 0||t===!0?!0:t===!1?!1:t==="cast"||typeof t=="object"}function P_(t){return t===void 0||t===!0?!0:t===!1?!1:t==="receive"||typeof t=="object"}function T_(t){return Vh(t)?typeof t=="object"?t:{}:null}function Kl(t){return t===void 0?[1,1]:typeof t=="number"?[t,t]:[t[0]??1,t[1]??t[0]??1]}function D_(t){if(t===void 0)return null;let e=typeof t=="number"?{size:t}:t,r=e.size??.1;return{size:r,thickness:e.thickness??r*2,offset:e.offset??0,segments:e.segments??3}}function R_(t){let e=t.segments,[r,n]=typeof e=="number"?[e,e]:[e[0]??1,e[1]??e[0]??1],o=Math.max(1,Math.floor(r))+1,s=Math.max(1,Math.floor(n))+1,i=new Float32Array(o*s*3),a=new Float32Array(o*s*2),l=t.color?new Float32Array(o*s*3):void 0,c={x:0,y:0,z:0};for(let f=0;f<s;f++){let h=f/(s-1);for(let y=0;y<o;y++){let w=y/(o-1),g=f*o+y,x=t.vertex(w,h);if(Array.isArray(x))c.x=x[0],c.y=x[1],c.z=x[2];else{let _=x;c.x=_.x,c.y=_.y,c.z=_.z}if(i[g*3]=c.x,i[g*3+1]=c.y,i[g*3+2]=c.z,a[g*2]=w,a[g*2+1]=h,l&&t.color){let _=F_(t.color(w,h,c));l[g*3]=_[0],l[g*3+1]=_[1],l[g*3+2]=_[2]}}}let d=new Uint32Array((o-1)*(s-1)*6),u=0;for(let f=0;f<s-1;f++)for(let h=0;h<o-1;h++){let y=f*o+h,w=y+1,g=y+o,x=g+1;d[u++]=y,d[u++]=g,d[u++]=w,d[u++]=w,d[u++]=g,d[u++]=x}return{type:"buffer",position:i,uv:a,color:l,index:d,computeNormals:t.computeNormals,params:t.params}}function F_(t){let[e,r,n]=typeof t=="string"?G(t):t;return[Yl(e),Yl(r),Yl(n)]}function Yl(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ct(t,e){let r=new Array(16);for(let n=0;n<4;n++){let o=e[n*4],s=e[n*4+1],i=e[n*4+2],a=e[n*4+3];r[n*4]=t[0]*o+t[4]*s+t[8]*i+t[12]*a,r[n*4+1]=t[1]*o+t[5]*s+t[9]*i+t[13]*a,r[n*4+2]=t[2]*o+t[6]*s+t[10]*i+t[14]*a,r[n*4+3]=t[3]*o+t[7]*s+t[11]*i+t[15]*a}return r}function gi(t){let[e,r,n,o,s,i,a,l,c,d,u,f,h,y,w,g]=t,x=d*w*l-y*u*l+y*a*f-i*w*f-d*a*g+i*u*g,_=h*u*l-c*w*l-h*a*f+s*w*f+c*a*g-s*u*g,S=c*y*l-h*d*l+h*i*f-s*y*f-c*i*g+s*d*g,b=h*d*a-c*y*a-h*i*u+s*y*u+c*i*w-s*d*w,k=e*x+r*_+n*S+o*b;if(k===0)return null;let M=1/k;return[x*M,(y*u*o-d*w*o-y*n*f+r*w*f+d*n*g-r*u*g)*M,(i*w*o-y*a*o+y*n*l-r*w*l-i*n*g+r*a*g)*M,(d*a*o-i*u*o-d*n*l+r*u*l+i*n*f-r*a*f)*M,_*M,(c*w*o-h*u*o+h*n*f-e*w*f-c*n*g+e*u*g)*M,(h*a*o-s*w*o-h*n*l+e*w*l+s*n*g-e*a*g)*M,(s*u*o-c*a*o+c*n*l-e*u*l-s*n*f+e*a*f)*M,S*M,(h*d*o-c*y*o-h*r*f+e*y*f+c*r*g-e*d*g)*M,(s*y*o-h*i*o+h*r*l-e*y*l-s*r*g+e*i*g)*M,(c*i*o-s*d*o-c*r*l+e*d*l+s*r*f-e*i*f)*M,b*M,(c*y*n-h*d*n+h*r*u-e*y*u-c*r*w+e*d*w)*M,(h*i*n-s*y*n-h*r*a+e*y*a+s*r*w-e*i*w)*M,(s*d*n-c*i*n+c*r*a-e*d*a-s*r*u+e*i*u)*M]}function Pt(t,e){let{x:r,y:n,z:o}=e;return{x:t[0]*r+t[4]*n+t[8]*o+t[12],y:t[1]*r+t[5]*n+t[9]*o+t[13],z:t[2]*r+t[6]*n+t[10]*o+t[14],w:t[3]*r+t[7]*n+t[11]*o+t[15]}}function Gh(t,e,r){let{x:n,y:o,z:s,w:i}=e,a=n+n,l=o+o,c=s+s,d=n*a,u=n*l,f=n*c,h=o*l,y=o*c,w=s*c,g=i*a,x=i*l,_=i*c;return[(1-(h+w))*r.x,(u+_)*r.x,(f-x)*r.x,0,(u-_)*r.y,(1-(d+w))*r.y,(y+g)*r.y,0,(f+x)*r.z,(y-g)*r.z,(1-(d+h))*r.z,0,t.x,t.y,t.z,1]}function _o(t,e,r=I_){let n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,i=Math.hypot(n,o,s);i===0&&(s=1,i=1),n/=i,o/=i,s/=i;let a=r.y*s-r.z*o,l=r.z*n-r.x*s,c=r.x*o-r.y*n,d=Math.hypot(a,l,c);d===0&&(Math.abs(r.z)===1?n+=1e-4:s+=1e-4,i=Math.hypot(n,o,s),n/=i,o/=i,s/=i,a=r.y*s-r.z*o,l=r.z*n-r.x*s,c=r.x*o-r.y*n,d=Math.hypot(a,l,c)),a/=d,l/=d,c/=d;let u=o*c-s*l,f=s*a-n*c,h=n*l-o*a;return[a,l,c,0,u,f,h,0,n,o,s,0,0,0,0,1]}var I_={x:0,y:1,z:0};function wo(t,e){if(!t)return yi();let r=de(t.position),n=de(t.scale===void 0?1:t.scale);if(t.lookAt!==void 0){let s=de(t.lookAt),i=e?Pt(e,r):{...r,w:1},a={x:i.x,y:i.y,z:i.z},l=_o(s,a);if(e){let c=gi(Yh(e));c&&(l=Ct(c,l))}return Ct(Ct(vo(r),l),N_(n))}let o=t.quaternion??ja(z_(t.rotation));return Gh(r,o,n)}function z_(t){return{...de(t),order:t?.order}}function vo(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1]}function N_(t){return[t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1]}function Yh(t){let e=Math.hypot(t[0],t[1],t[2])||1,r=Math.hypot(t[4],t[5],t[6])||1,n=Math.hypot(t[8],t[9],t[10])||1;return[t[0]/e,t[1]/e,t[2]/e,0,t[4]/r,t[5]/r,t[6]/r,0,t[8]/n,t[9]/n,t[10]/n,0,0,0,0,1]}function xi(t,e,r,n,o){let s=r*Math.tan(t*Math.PI/360)/o,i=2*s,a=e*i,l=-.5*a;return $_(l,l+a,s,s-i,r,n)}function $_(t,e,r,n,o,s){let i=2*o/(e-t),a=2*o/(r-n),l=(e+t)/(e-t),c=(r+n)/(r-n),d=-(s+o)/(s-o),u=-2*s*o/(s-o);return[i,0,0,0,0,a,0,0,l,c,d,-1,0,0,u,0]}function Hl(t,e,r,n,o,s,i){let a=(e-t)/(2*i),l=(r-n)/(2*i),c=(e+t)/2,d=(r+n)/2,u=c-a,f=c+a,h=d+l,y=d-l,w=1/(f-u),g=1/(h-y),x=1/(s-o);return[2*w,0,0,0,0,2*g,0,0,0,0,-2*x,0,-(f+u)*w,-(h+y)*g,-(s+o)*x,1]}function Be(t,e,r){return{min:{x:-t,y:-e,z:-r},max:{x:t,y:e,z:r}}}function So(t,e){return t?e?{min:{x:Math.min(t.min.x,e.min.x),y:Math.min(t.min.y,e.min.y),z:Math.min(t.min.z,e.min.z)},max:{x:Math.max(t.max.x,e.max.x),y:Math.max(t.max.y,e.max.y),z:Math.max(t.max.z,e.max.z)}}:t:e}function _i(t){let{min:e,max:r}=t;return[{x:e.x,y:e.y,z:e.z},{x:r.x,y:e.y,z:e.z},{x:e.x,y:r.y,z:e.z},{x:r.x,y:r.y,z:e.z},{x:e.x,y:e.y,z:r.z},{x:r.x,y:e.y,z:r.z},{x:e.x,y:r.y,z:r.z},{x:r.x,y:r.y,z:r.z}]}function Mn(t,e){let r=1/0,n=1/0,o=1/0,s=-1/0,i=-1/0,a=-1/0;for(let l of _i(t)){let c=Pt(e,l);c.x<r&&(r=c.x),c.y<n&&(n=c.y),c.z<o&&(o=c.z),c.x>s&&(s=c.x),c.y>i&&(i=c.y),c.z>a&&(a=c.z)}return{min:{x:r,y:n,z:o},max:{x:s,y:i,z:a}}}function wi(t){if(!t)return null;switch(t.type){case"box":return Be((t.width??1)/2,(t.height??1)/2,(t.depth??1)/2);case"sphere":return Be(t.radius??1,t.radius??1,t.radius??1);case"plane":return Be((t.width??1)/2,(t.height??1)/2,0);case"cylinder":{let[e,r]=Kl(t.radius),n=Math.max(e,r);return Be(n,(t.height??1)/2,n)}case"cone":{let e=t.radius??1;return Be(e,(t.height??1)/2,e)}case"torus":{let e=t.radius??1,r=t.thickness??.4;return Be(e+r,e+r,r)}case"torusKnot":{let e=t.radius??1,r=t.thickness??.4;return Be(e*1.5+r,e*1.5+r,e*.5+r)}case"circle":return Be(t.radius??1,t.radius??1,0);case"ring":{let e=t.radius??1;return Be(e,e,0)}case"capsule":{let e=t.radius??.5;return Be(e,(t.height??1)/2+e,e)}case"polyhedron":{let e=t.radius??1;return Be(e,e,e)}case"lathe":{let e=0,r=1/0,n=-1/0;for(let o of t.points){let s=de(o);e=Math.max(e,Math.abs(s.x)),r=Math.min(r,s.y),n=Math.max(n,s.y)}return Number.isFinite(r)?{min:{x:-e,y:r,z:-e},max:{x:e,y:n,z:e}}:null}case"tube":{let e=t.points.map(n=>de(n)),r=j_(e);return r?L_(r,t.radius??1):null}case"buffer":return B_(t.position);case"edges":case"wireframe":return wi(t.source);default:return null}}function j_(t){if(t.length===0)return null;let e=1/0,r=1/0,n=1/0,o=-1/0,s=-1/0,i=-1/0;for(let a of t)a.x<e&&(e=a.x),a.y<r&&(r=a.y),a.z<n&&(n=a.z),a.x>o&&(o=a.x),a.y>s&&(s=a.y),a.z>i&&(i=a.z);return{min:{x:e,y:r,z:n},max:{x:o,y:s,z:i}}}function B_(t){if(t.length<3)return null;let e=1/0,r=1/0,n=1/0,o=-1/0,s=-1/0,i=-1/0;for(let a=0;a+2<t.length;a+=3){let l=t[a],c=t[a+1],d=t[a+2];l<e&&(e=l),c<r&&(r=c),d<n&&(n=d),l>o&&(o=l),c>s&&(s=c),d>i&&(i=d)}return{min:{x:e,y:r,z:n},max:{x:o,y:s,z:i}}}function L_(t,e){return{min:{x:t.min.x-e,y:t.min.y-e,z:t.min.z-e},max:{x:t.max.x+e,y:t.max.y+e,z:t.max.z+e}}}var W_=["color","opacity","visible","emission","emissionStrength","roughness","metalness","shininess","specular","reflectivity","clearcoat","clearcoatRoughness","transmission","thickness","ior","sheen","sheenColor","sheenRoughness","iridescence","iridescenceIOR","specularIntensity","specularColor","anisotropy","anisotropyRotation","attenuationColor","attenuationDistance","aoMapIntensity","lightMapIntensity","envMapIntensity","normalScale","displacementScale","displacementBias","size","width","dashSize","gapSize","scale","rotation","depthWrite","depthTest","polygonOffsetFactor","polygonOffsetUnits"],q_=["transparent","alphaTest","faces","wireframe","blend","vertexColors","toneMapped","shading","dithering","polygonOffset","raw","extends","defines"];var vi=class{onError;precomp;storageAdapter;audioDevice;lastAudioRequestKey="";lastAudioSrcs=new Set;audioFetching=new Map;audioFailed=new Map;audioReported=new Set;audioRequired=new Set;layoutGateKeys;disposed=!1;loaderDisposers=new Map;loaderInFlight=new Map;constructor(e,r,n,o=s=>console.error(`[AssetManager] ${s.message}`)){this.onError=o,this.precomp=e,this.layoutGateKeys=Kh(e),this.storageAdapter=r,this.audioDevice=n}setPrecomp(e){this.precomp=e,this.layoutGateKeys=Kh(e);for(let r of this.audioReported)this.audioFailed.delete(r);this.audioReported.clear(),this.lastAudioRequestKey=null,this.lastAudioSrcs=null}async loadAt(e){let r=[];for(let[n,o]of this.precomp.assets){if(o.record.type==="loader"){let s=this.syncLoader(n,o,e);s&&r.push(s);continue}o.cacheAt<=e&&o.record.endFrame>=e&&r.push(this.storageAdapter.loadAsset(n,o.record))}await Promise.all(r),this.audioDevice.schedulesAudio&&this.syncAudio(e)}isReady(e){return this.loaderDisposers.has(e)||this.storageAdapter.isLoaded(e)}async loadRecords(e){await Promise.all(e.map(r=>r.type==="loader"?this.runLoader(r.src,r.load):this.storageAdapter.loadAsset(r.src,r)))}prefetch(e){for(let[r,n]of this.precomp.assets){if(n.record.type==="loader"){this.syncLoader(r,n,e)?.catch(o=>{console.error(`[AssetManager] loader failed for ${r}:`,o)});continue}n.cacheAt<=e&&n.record.endFrame>=e&&this.storageAdapter.loadAsset(r,n.record).catch(o=>{console.error(`[AssetManager] prefetch failed for ${r}:`,o)})}}syncLoader(e,r,n){if(r.record.type!=="loader")return;let o=r.discardAt??1/0;if(!(r.cacheAt<=n&&n<=o)){if(this.layoutGateKeys.has(e))return;let i=this.loaderDisposers.get(e);i&&(this.loaderDisposers.delete(e),i());return}return this.runLoader(e,r.record.load)}runLoader(e,r){if(this.loaderDisposers.has(e))return;let n=this.loaderInFlight.get(e);if(n)return n;let o=r().then(s=>{this.loaderDisposers.set(e,s??V_)}).finally(()=>{this.loaderInFlight.delete(e)});return this.loaderInFlight.set(e,o),o}dispose(){for(let e of this.loaderDisposers.values())e();this.loaderDisposers.clear(),this.loaderInFlight.clear(),this.disposed=!0}syncAudio(e){let r=e/this.precomp.fps,n=[],o=new Set,s=new Set,i=new Set,a=(c,d)=>{let u=d+c.startAt,f=d+c.endAt;if(f<r||u>r+10)return;c.optional||s.add(c.src);let h=G_(c,d);i.has(h)||(i.add(h),n.push({...c,id:h,startAt:u,endAt:f,...c.bus&&{bus:c.bus.map(y=>({...y,startAt:d+y.startAt,endAt:d+y.endAt}))}}),o.add(c.src))};for(let c of this.precomp.tracks){let d=c.startFrame/this.precomp.fps;for(let u of c.audioRequests)a(u,d)}this.audioRequired=s;for(let c of o)if(!this.audioDevice.has(c)&&!this.audioFetching.has(c)&&!this.audioFailed.has(c)){let d=this.storageAdapter.fetchAudioData(c).then(u=>this.audioDevice.append(c,u)).catch(u=>this.failAudio(c,u)).finally(()=>this.audioFetching.delete(c));this.audioFetching.set(c,d)}for(let[c,d]of this.audioFailed)o.has(c)?s.has(c)&&this.reportAudio(c,d):(this.audioFailed.delete(c),this.audioReported.delete(c));let l=K_(n);l!==this.lastAudioRequestKey&&(this.audioDevice.schedule(n),this.lastAudioRequestKey=l),(this.lastAudioSrcs===null||!H_(this.lastAudioSrcs,o))&&(this.audioDevice.retain(o),this.lastAudioSrcs=o)}failAudio(e,r){this.disposed||(this.audioFailed.set(e,r),this.audioRequired.has(e)&&this.reportAudio(e,r))}reportAudio(e,r){if(this.audioReported.has(e))return;this.audioReported.add(e);let n=r instanceof Error?r.message:String(r);this.onError(new Error(`audio "${e}" could not be loaded: ${n}`,{cause:r}))}};function Kh(t){let e=new Set;for(let r of t.tracks)for(let n of r.layoutGates??[])e.add(n);return e}var V_=()=>{};function G_(t,e){return`${t.src}|${e+t.startAt}|${e+t.endAt}|${t.trimStart}|${t.trimEnd??"_"}|${t.loop?1:0}|${t.volume}|${Xn(t.filters)}|${Y_(t.bus)}`}function Y_(t){return!t||t.length===0?"":t.map(Aa).join(">")}function K_(t){return t.length===0?"":t.map(e=>e.id).sort().join(`
14
- `)}function H_(t,e){if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;return!0}function Hh(t){switch(t.type){case"image":case"video":return t.src;case"font":return t.family;case"loader":return t.key}}function U_(t){return typeof t=="number"?Number.isFinite(t)?t:400:typeof t=="string"&&parseInt(t,10)||400}var Si=class{catalog;constructor(e,r={}){this.catalog=e,this._options=r}get declarations(){return this._decls}image(e){!e||this._decls.has(e)||(this.catalog.getImageMeta(e),this._decls.set(e,{type:"image",src:e}))}video(e,r){!e||this._decls.has(e)||(this.catalog.getVideoMeta(e),this._decls.set(e,{type:"video",src:e,trimStart:r?.start??0,trimEnd:r?.end??this.catalog.getVideoDuration(e)}))}font(e,r){!e||this._decls.has(e)||this._decls.set(e,{type:"font",family:e,weight:U_(r)})}loader(e,r,n){let o=n?.gate??"render",s=this._decls.get(e);if(s===void 0){this._decls.set(e,{type:"loader",key:e,load:r,gate:o});return}s.type==="loader"&&(s.load,o==="layout"&&s.gate!=="layout"&&this._decls.set(e,{...s,gate:o}))}fill(e){if(e){if(!Array.isArray(e)){pa(e,this);return}for(let r of e)pa(r,this)}}effects(e){if(e)for(let r of e)Wo(r,this)}subtree(e){this._subtrees??=new Set,!this._subtrees.has(e)&&(this._subtrees.add(e),this._options.bindSubtree?.(e),this._options.onSubtree?this._options.onSubtree(e,this):rl(e,this))}_options;_decls=new Map;_subtrees};function Vt(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function X_(){let t=globalThis.scheduler;return typeof t?.yield=="function"?t.yield.bind(t):void 0}var qt=null,Ul=[];function Z_(){return typeof MessageChannel!="function"?null:(qt||(qt=new MessageChannel,qt.port1.onmessage=()=>Ul.shift()?.(),qt.port1.unref?.(),qt.port2.unref?.()),new Promise(t=>{Ul.push(t),qt.port2.postMessage(null)}))}function bi(){let t=X_();return t?t():Z_()??new Promise(e=>setTimeout(e,0))}function i$(){qt?.port1.close(),qt?.port2.close(),qt=null,Ul.length=0}function Hr(t,e){return t*(1/e)}function Gt(t,e){let r=t*e,n=Math.round(r);return Math.abs(r-n)<=1e-9*Math.max(1,Math.abs(r))?n:r}function l$(t,e){return{kind:"frame",frame:Math.round(Gt(t,e))}}function On(t,e){return typeof t!="number"||!Number.isFinite(t)?1:Math.max(1,Math.ceil(Gt(t,e)))}function bo(t,e){return t.map((r,n)=>{let o=Math.max(0,Math.round(Gt(r.startAt??0,e)));return{id:r.id,index:n,startFrame:o,endFrame:o+On(r.duration,e)-1}})}function Uh(t){let e=0;for(let r of t)e=Math.max(e,r.endFrame+1);return e}function xr(t,e){return t.filter(r=>e>=r.startFrame&&e<=r.endFrame)}function lt(t,e,r){return Math.min(Hr(t,e),r)}function En(t,e,r){let n=r-1,o=a=>lt(a,e,1/0),s=Math.min(n+1,Math.max(0,Math.ceil(t.start*e)));for(;s>0&&o(s-1)>=t.start;)s--;for(;s<=n&&o(s)<t.start;)s++;let i=n;if(t.end!==1/0){for(i=Math.max(-1,Math.min(n,Math.ceil(t.end*e)));i>=0&&o(i)>=t.end;)i--;for(;i<n&&o(i+1)<t.end;)i++}return s<=i?{startFrame:s,endFrame:i}:null}var ki=class{_scope;canvas;constructor(e,r,n){this._scope=n,this._clip=e,this._duration=r,this._doc=Xh(e);let{width:o,height:s}=n.viewport;this.canvas=new K({id:O,width:o,height:s,flow:"freeform"}),this._timeline=new pi(this._doc,n.registry,this.canvas),this._indexRows()}get duration(){return this._duration}get clip(){return this._clip}build(e=this._scope.measurer){this.attach(0),this._timeline.build(),this.sample(),this.layout(e),this._timeline.compile(()=>{this.sample(),this.layout(e)}),this.layout(e)}update(e,r){if(e===this._clip)return this._duration=r,!0;let n=this.planUpdate(e);return n?(this.applyUpdate(n,e,r),!0):!1}planUpdate(e){return this._timeline.planUpdate(Xh(e))}applyUpdate(e,r,n,o=this._scope.measurer){this.attach(0);let s=()=>{this.sample(),this.layout(o)};this._timeline.applyUpdate(e,s,s),this.layout(o),this._clip=r,this._doc=e.next.doc,this._duration=n,this._indexRows()}placedCommands(){return this._timeline.placedCommands()}evaluateAt(e,r){this._timeline.syncPresence(e),this._timeline.evaluateAt(e,r)}attach(e,r){this.canvas.attach({assets:this._scope.assets,context:Pr.EMPTY,time:e}),nl(this.canvas,r)}layout(e=this._scope.measurer){let{width:r,height:n}=this._scope.viewport;this.canvas.layout({x:0,y:0,width:r,height:n},e)}render(e){this.canvas.render(e)}sample(){Ns(this.canvas)}primeMotion(e){$s(this.canvas,e)}node(e){return this._timeline.liveNode(e)}baselineProps(e){return this._timeline.baselineProps(e)}rowSpans(){return[...this._rows.values()].map(e=>e.span)}rowSpan(e){return this._rows.get(e)?.span}ownerKeyOf(e){let r="";for(let n=e;;){if(n===this.canvas||this._timeline.liveNode(n.id)===n){let i=n===this.canvas?O:n.id;return r===""?i:`${i}/${r}`}let o=n.parent;if(!o)return;let s=o._allChildren.indexOf(n);r=r===""?String(s):`${s}.${r}`,n=o}}spanOf(e){for(let r=e;r;r=r.parent){if(r===this.canvas)return{start:0,end:this.duration};let n=this._rowSpan(r);if(n)return{...n}}}forEachOwner(e){let r=(n,o,s,i,a)=>{if(!n.mounted)return;let l=n===this.canvas?void 0:this._rowSpan(n);l&&(o=n.id,s="",i=l),e(n,s===""?o:`${o}/${s}`,i,a);let c=n._allChildren;for(let d=0;d<c.length;d++)r(c[d],o,s===""?String(d):`${s}.${d}`,i,zt(a,d))};r(this.canvas,O,"",{start:0,end:this.duration},"")}dispose(){for(let e of this.canvas.children)e.dispose();this.canvas.dispose()}_clip;_doc;_duration;_timeline;_rows=new Map;_indexRows(){this._rows.clear();let e=zp(this._doc.nodes);for(let r of this._doc.nodes)r.id!==O&&this._rows.set(r.id,{parentId:r.parentId,span:e.get(r.id)})}_rowSpan(e){let r=this._rows.get(e.id);if(!r)return;let n=e.parent;return(r.parentId===null||r.parentId===O?n===this.canvas:n!==null&&n.id===r.parentId)?r.span:void 0}};function Xh(t){return mr(t)?kn(t):t}var J_=new Set,ko=class{constructor(e){this._frameCount=Math.max(0,e)}setOwner(e,r){let n=new Set,o=this._owners.get(e);o&&this._unlink(e,o,n);let s={declared:new Map,learned:new Map};for(let i of r)i.endFrame>=i.startFrame&&Q_(s.declared,{...i});return s.declared.size>0?(this._owners.set(e,s),this._link(e,s,n)):this._owners.delete(e),this._refresh(n)}removeOwner(e){let r=this._owners.get(e);if(!r)return{keys:new Set};let n=new Set;return this._unlink(e,r,n),this._owners.delete(e),this._refresh(n)}learn(e,r,n){let o=Hh(r),s=this._owners.get(e);s||(s={declared:new Map,learned:new Map},this._owners.set(e,s));let i=s.learned.get(o)??[],a=i.findIndex(c=>n>=c.startFrame-1&&n<=c.endFrame+1);if(a<0)i.push({key:o,decl:r,startFrame:n,endFrame:n});else{let c=i[a];i[a]={...c,startFrame:Math.min(c.startFrame,n),endFrame:Math.max(c.endFrame,n)}}s.learned.set(o,i);let l=this._byKey.get(o);return l||this._byKey.set(o,l=new Set),l.add(e),this._refresh(new Set([o]))}setFrameCount(e){let r=Math.max(0,e);return r===this._frameCount?{keys:new Set}:(this._frameCount=r,this._refresh(new Set(this._byKey.keys())))}owners(e){return this._byKey.get(e)??J_}segmentsOf(e){let r=this._owners.get(e);if(!r)return[];let n=[];for(let o of r.declared.values())n.push(...o);for(let o of r.learned.values())n.push(...o);return n}declaredSegmentsOf(e){let r=this._owners.get(e);if(!r)return[];let n=[];for(let o of r.declared.values())n.push(...o);return n}ownerKeys(){return this._owners.keys()}records(){return this._records}layoutGates(){if(this._layoutGates===null){let e=[];for(let r of this._entries.values())r.layout&&e.push(r.record);this._layoutGates=e}return this._layoutGates}_frameCount;_owners=new Map;_byKey=new Map;_entries=new Map;_records=new Map;_layoutGates=null;_link(e,r,n){for(let o of r.declared.keys()){let s=this._byKey.get(o);s||this._byKey.set(o,s=new Set),s.add(e),n.add(o)}}_unlink(e,r,n){for(let o of[r.declared,r.learned])for(let s of o.keys()){let i=this._byKey.get(s);i&&(i.delete(e),i.size===0&&this._byKey.delete(s)),n.add(s)}}_refresh(e){let r=new Set;for(let n of e){let o=this._entries.get(n),s=this._compute(n);if(s===void 0){if(o===void 0)continue;this._entries.delete(n),this._records.delete(n)}else{if(o!==void 0&&o.layout===s.layout&&tw(o.record,s.record))continue;this._entries.set(n,s),this._records.set(n,s.record)}r.add(n)}return r.size>0&&(this._layoutGates=null),{keys:r}}_compute(e){let r=this._byKey.get(e);if(!r)return;let n=this._frameCount-1,o,s=1/0,i=-1/0,a=!1,l=c=>{if(c)for(let d of c){let u=Math.max(0,d.startFrame),f=Math.min(n,d.endFrame);f<u||(u<s&&(s=u,o=d),f>i&&(i=f),d.decl.type==="loader"&&d.decl.gate==="layout"&&(a=!0))}};for(let c of r){let d=this._owners.get(c);d&&(l(d.declared.get(e)),l(d.learned.get(e)))}if(o!==void 0)return{record:ew(o.decl,s,i),layout:o.decl.type==="font"||a}}};function Q_(t,e){let r=t.get(e.key);r?r.push(e):t.set(e.key,[e])}function ew(t,e,r){switch(t.type){case"image":return{type:"image",startFrame:e,endFrame:r,src:t.src};case"video":return{type:"video",startFrame:e,endFrame:r,src:t.src,trimStart:t.trimStart,trimEnd:t.trimEnd};case"font":return{type:"font",startFrame:e,endFrame:r,fontWeight:t.weight,fontFamily:t.family,src:t.family};case"loader":return{type:"loader",src:t.key,startFrame:e,endFrame:r,load:t.load}}}function tw(t,e){if(t.type!==e.type||t.src!==e.src||t.startFrame!==e.startFrame||t.endFrame!==e.endFrame)return!1;switch(t.type){case"video":{let r=e;return t.trimStart===r.trimStart&&t.trimEnd===r.trimEnd}case"font":return t.fontWeight===e.fontWeight;case"loader":return t.load===e.load;default:return!0}}function*Zl(t,e){let r=new Xl(t,e);for(;r.step();)yield;return r.result()}var Zh=3,Xl=class{_instance;_options;constructor(e,r){this._instance=e,this._options=r,this._last=r.frameCount-1;let{owners:n,below:o}=r,s=n!==void 0||o!==void 0;if(!(this._last<0||s&&(n?.size??0)+(o?.size??0)===0)){if(s){this._start=1/0;for(let i of[...n?.values()??[],...o?.values()??[]])this._start=Math.min(this._start,Math.max(0,i))}if(!(this._start>this._last)){this._walked=this._start-1,this._placed=e.placedCommands().map(i=>({id:i.spec.id,...this._activeFrames(i.start,i.duration),writes:new Set(i.writes)}));for(let i=0;i<this._placed.length;i++)for(let a of this._placed[i].writes)this._addWriter(a,i);this._enqueue(this._start);for(let i of this._structureSpans()){let a=En(i,r.fps,r.frameCount);a&&(this._structureFrame(a.startFrame),this._structureFrame(a.endFrame+1))}for(let i of this._placed)[...i.writes].some(Ai)&&this._forEachDueFrame(i,this._start,a=>this._structureFrame(a))}}}step(){let e=lw(this._heap);return e===void 0?!1:(this._queued.delete(e),this._frame=e,this._dueTaken=!1,this._evaluate(e),this._declareDue(e),this._heap.length>0)}result(){let e=new Map,r=new Map;for(let n of this._owners.values()){let o=n.present?[...n.intervals,[n.arrivedAt,1/0]]:n.intervals;e.set(n.key,{ownerKey:n.key,nodeId:n.node.id,segments:n.error?[]:sw(n.history,o),deps:n.allDeps,...n.error&&{error:n.error}});for(let s of n.allDeps){let i=r.get(s);i||r.set(s,i=new Set),i.add(n.key)}}for(let n of this._options.owners?.keys()??[])e.has(n)||e.set(n,{ownerKey:n,nodeId:void 0,segments:[],deps:new Set});return{owners:e,readers:r}}_last;_start=0;_walked=-1;_placed=[];_writers=new Map;_heap=[];_queued=new Set;_due=new Map;_structureFrames=new Set;_owners=new Map;_readers=new Map;_pseudo=new Set;_rewound=new Set;_frame=-1;_dueTaken=!1;_dev=iw();_presenceObserver={read:()=>{},write:e=>{Ai(e)&&this._pseudo.add(e)}};_structureSpans(){let{owners:e,below:r}=this._options;if(e===void 0&&r===void 0)return this._instance.rowSpans();let n=new Set(r?.keys());for(let s of e?.keys()??[]){let i=s.indexOf("/");n.add(i<0?s:s.slice(0,i))}let o=[];for(let s of n){let i=this._instance.rowSpan(s);i&&o.push(i)}return o}_activeFrames(e,r){let{fps:n}=this._options,o=e+Math.max(0,r),s=Math.max(0,Math.ceil(e*n));for(;s>0&&lt(s-1,n,1/0)>=e;)s--;for(;lt(s,n,1/0)<e;)s++;let i=Math.max(-1,Math.floor(o*n));for(;lt(i+1,n,1/0)<=o;)i++;for(;i>=0&&lt(i,n,1/0)>o;)i--;return{from:s,to:i}}_evaluate(e){this._options.onPhase?.("evaluate");let r=lt(e,this._options.fps,this._instance.duration);if(e>this._walked&&(e===this._start||this._structureFrames.has(e))&&this._instance.attach(r),this._pseudo.clear(),It(this._presenceObserver,()=>this._instance.evaluateAt(r,(n,o)=>{Ai(o)&&this._pseudo.add(o),this._commandWrote(n,o)})),!(e<=this._walked)){(e===this._start||this._pseudo.size>0)&&this._reconcile(e);for(let n of this._pseudo)for(let o of this._readers.get(n)??[])o.stale=!0,this._queueOwner(o,e);this._walked=e}}_reconcile(e){let r=new Set;this._instance.forEachOwner((n,o,s)=>{let i=this._limitOf(o);if(i===void 0)return;let a=this._owners.get(o);a||(a={key:o,node:n,span:s,from:i,present:!1,arrivedAt:-1,arrived:!1,intervals:[],history:[],deps:null,values:[],stale:!0,allDeps:new Set,scheduled:new Set,rounds:0},this._owners.set(o,a)),r.add(a),a.node!==n&&(a.node=n,a.stale=!0,a.present&&this._queueOwner(a,Math.max(e,a.from))),!a.present&&(a.present=!0,a.arrivedAt=Math.max(e,a.from),a.stale=!0,this._queueOwner(a,a.arrivedAt),a.arrived||(a.arrived=!0,this._options.onArrive?.(n,o,s,e)))});for(let n of this._owners.values())!n.present||r.has(n)||(e-1>=n.arrivedAt&&n.intervals.push([n.arrivedAt,e-1]),n.present=!1)}_limitOf(e){let{owners:r,below:n}=this._options;if(r===void 0&&n===void 0)return this._start;let o=r?.get(e);if(n)for(let s=e.indexOf("/");s>=0;s=e.indexOf("/",s+1)){let i=n.get(e.slice(0,s));i!==void 0&&(o===void 0||i<o)&&(o=i)}return o}_declareDue(e){this._dueTaken=!0;let r=this._due.get(e);if(this._due.delete(e),this._options.declare!==!1){for(let n of r??[])n.error||this._rewound.has(n)||!rw(n,e)||!n.stale&&nw(n)||this._declare(n,e);for(let n of this._rewound)this._queueOwner(n,e);this._rewound.clear()}}_declare(e,r){this._options.onPhase?.("declare");let n=e.node,o=new Set,s=[],i,a=!1,l=!1,c=this._options.bindSubtree??(h=>yp(n,h)),d=new Si(this._options.catalog,{bindSubtree:h=>Es(()=>c(h))});try{It({read:h=>{o.add(h),i=h,h._name===tr&&(a=!0)},write:h=>{s.push(h)},clock:()=>{l=!0}},()=>tl(n,d))}catch(h){let y=h instanceof Error?h:new Error(String(h));e.error={message:y.message,stack:y.stack,...i&&{prop:ao(i)}};return}if(this._dev){let h=n.constructor.name;if(s.length>0){let y=[...new Set(s.map(ao))].join(", ");Ao(`${h}:write:${y}`,`[assets] ${h} wrote ${y} while declaring its assets. A declaration is re-run only when something it read changes, so a write there is a frame-order dependency.`)}a&&Ao(`${h}:layout`,`[assets] ${h}.declareAssets read layoutBounds. Declarations run without layout; decode size follows the draw, so declare the asset without a size.`),l&&Ao(`${h}:clock`,`[assets] ${h}.declareAssets read time. Declarations are re-run only when a prop they read changes, so anything following the clock is missed between those frames.`)}e.stale=!1,e.deps=[...o],e.values=e.deps.map(h=>h.get());for(let h of o){if(e.allDeps.has(h))continue;e.allDeps.add(h);let y=this._readers.get(h);y||this._readers.set(h,y=new Set),y.add(e)}let u=d.declarations,f=e.history[e.history.length-1];(!f||f.frame<e.arrivedAt||!ow(f.decls,u))&&e.history.push({frame:r,decls:u}),this._scheduleWriters(e,r+1)}_scheduleWriters(e,r){for(let n of e.deps??[]){let o=this._writers.get(n);if(o)for(let s of o)e.scheduled.has(s)||(e.scheduled.add(s),this._forEachDueFrame(this._placed[s],r,i=>this._queueOwner(e,i)))}}_forEachDueFrame(e,r,n){let o=Math.max(r,e.from),s=Math.min(this._last,e.to);for(let a=o;a<=s;a++)n(a);let i=Math.max(e.to+1,e.from);i>=r&&i<=this._last&&n(i)}_commandWrote(e,r){let n=this._placed[e];if(!(!n||n.writes.has(r))){n.writes.add(r),this._addWriter(r,e),this._dev&&Ao(`command:${n.id}:${ao(r)}`,`[assets] Command ${n.id} wrote ${ao(r)} at frame ${this._frame}, which compile did not record it writing. Owners reading it are re-declared over the command's span.`);for(let o of this._readers.get(r)??[])this._requeue(o,Math.max(n.from,o.from),n.id)}}_requeue(e,r,n){if(!e.error){if(r>this._frame){this._scheduleWriters(e,r);return}if(r===this._frame){this._queueOwner(e,r);return}if(e.rounds>=Zh){this._dev&&Ao(`requeue:${e.key}`,`[assets] ${e.key} was re-queued ${Zh} times (last by command ${n}); its asset windows may be incomplete.`);return}e.rounds++,e.history=e.history.filter(o=>o.frame<r),e.stale=!0,e.scheduled.clear(),this._queueOwner(e,r);for(let[o]of e.intervals)o>r&&this._queueOwner(e,o);if(e.present&&e.arrivedAt>r&&this._queueOwner(e,e.arrivedAt),e.deps?.some(Ai))for(let o of this._structureFrames)o>=r&&o<=this._walked&&this._queueOwner(e,o);this._rewound.add(e)}}_addWriter(e,r){let n=this._writers.get(e);n?n.push(r):this._writers.set(e,[r])}_structureFrame(e){e<=this._start||e>this._last||(this._structureFrames.add(e),this._enqueue(e))}_queueOwner(e,r){if(r>this._last)return;let n=this._due.get(r);n||this._due.set(r,n=new Set),n.add(e),this._enqueue(r)}_enqueue(e){this._queued.has(e)||e===this._frame&&!this._dueTaken||(this._queued.add(e),aw(this._heap,e))}};function Ai(t){return t._name===Ft||t._name.startsWith(rr)}function rw(t,e){if(t.present&&e>=t.arrivedAt)return!0;for(let[r,n]of t.intervals)if(e>=r&&e<=n)return!0;return!1}function nw(t){let e=t.deps;if(e===null)return!1;for(let r=0;r<e.length;r++)if(!Object.is(e[r].get(),t.values[r]))return!1;return!0}function ow(t,e){if(t.size!==e.size)return!1;for(let[r,n]of t){let o=e.get(r);if(!o||!Qh(n,o))return!1}return!0}function Qh(t,e){switch(t.type){case"image":return e.type==="image"&&t.src===e.src;case"video":return e.type==="video"&&t.src===e.src&&t.trimStart===e.trimStart&&t.trimEnd===e.trimEnd;case"font":return e.type==="font"&&t.family===e.family;case"loader":return e.type==="loader"&&t.key===e.key&&t.load===e.load&&t.gate===e.gate}}function sw(t,e){let r=[];for(let[n,o]of e){let s=new Map;for(let i of t)if(!(i.frame<n||i.frame>o)){for(let[a,l]of s){let c=i.decls.get(a);c&&Qh(l.decl,c)||(r.push({...l,endFrame:i.frame-1}),s.delete(a))}for(let[a,l]of i.decls)s.has(a)||s.set(a,{key:a,decl:l,startFrame:i.frame,endFrame:o})}for(let i of s.values())r.push({...i,endFrame:o})}return r}function iw(){return!1}var Jh=new Set;function Ao(t,e){Jh.has(t)||(Jh.add(t),console.warn(e))}function aw(t,e){let r=t.length;for(t.push(e);r>0;){let n=r-1>>1;if(t[n]<=e)break;t[r]=t[n],r=n}t[r]=e}function lw(t){if(t.length===0)return;let e=t[0],r=t.pop();if(t.length===0)return e;let n=0;for(;;){let o=2*n+1;if(o>=t.length)break;let s=o+1,i=s<t.length&&t[s]<t[o]?s:o;if(t[i]>=r)break;t[n]=t[i],n=i}return t[n]=r,e}var ec="",Ei="",Ci="";function Oi(t,e){return t+ec+e}function em(t){return Ei+t}function tm(t){if(!(t.startsWith(Ei)||t.startsWith(Ci)))return t.slice(0,t.lastIndexOf(ec))}function Ql(t){return t.startsWith(Ei)||t.startsWith(Ci)?t.slice(1):t.slice(t.lastIndexOf(ec)+1)}var Pn=class{_instance;constructor(e){this._instance=e}idOf(e){let r=e._host;if(r===null)return Ei+e._name;let n=this._keys.get(r);return n===void 0&&(n=r instanceof he?this._instance.ownerKeyOf(r)??null:null,this._keys.set(r,n)),n===null?Ci+e._name:Oi(n,e._name)}idsOf(e){let r=[];for(let n of e)r.push(this.idOf(n));return r}_keys=new Map};function Mi(t){let e=[];for(let r=t.indexOf("/");r>=0;r=t.indexOf("/",r+1))e.push(t.slice(0,r));return e}function Mo(t,e,r){let n=t.get(e);n||t.set(e,n=new Set),n.add(r)}function Oo(t,e,r){let n=t.get(e);return!n||(n.delete(r),n.size>0)?!1:(t.delete(e),!0)}var Cn=new Set,Eo=class{set(e,r){this.remove(e);let n=new Set(r);this._deps.set(e,n);for(let o of Mi(e))Mo(this._ownersBelow,o,e);for(let o of n)this._readers.has(o)||this._index(o),Mo(this._readers,o,e)}remove(e){let r=this._deps.get(e);if(r){this._deps.delete(e);for(let n of Mi(e))Oo(this._ownersBelow,n,e);for(let n of r)Oo(this._readers,n,e)&&this._unindex(n)}}has(e){return this._deps.has(e)}depsOf(e){return this._deps.get(e)??Cn}readersOf(e){return this._readers.get(e)??Cn}ownersBelow(e){return this._ownersBelow.get(e)??Cn}slotsHostedBy(e){return this._byHost.get(e)??Cn}*slotsHostedBelow(e){for(let r of this._hostsBelow.get(e)??Cn)yield*this.slotsHostedBy(r)}slotsNamed(e){return this._byName.get(e)??Cn}_deps=new Map;_readers=new Map;_ownersBelow=new Map;_byHost=new Map;_hostsBelow=new Map;_byName=new Map;_index(e){Mo(this._byName,Ql(e),e);let r=tm(e);if(r!==void 0){Mo(this._byHost,r,e);for(let n of Mi(r))Mo(this._hostsBelow,n,r)}}_unindex(e){Oo(this._byName,Ql(e),e);let r=tm(e);if(r!==void 0&&Oo(this._byHost,r,e))for(let n of Mi(r))Oo(this._hostsBelow,n,r)}};function rm(t){let{patch:e,deps:r,fps:n}=t,{prev:o,next:s,diff:i}=e,a={owners:new Map,below:new Map,removed:new Set,arrivalOwners:new Set,arrivalBelow:new Set},l=(g,x,_)=>{let S=g.get(x);(S===void 0||_<S)&&g.set(x,_)},c=(g,x,_)=>{l(a.owners,g,x),_&&a.arrivalOwners.add(g)},d=(g,x,_)=>{for(let S of r.readersOf(g))c(S,x,_)},u=(g,x)=>{!t.buildsChildren(g)&&r.ownersBelow(g).size===0||(l(a.below,g,x),a.arrivalBelow.add(g))},f=(g,x)=>{let _=g.effSpan(x);return _?Jl(_.start,n):1/0},h=(g,x)=>{d(em(rr+g),x,!0),d(Oi(g,Ft),x,!0);for(let _ of[o,s]){let S=_.nodes.get(g);S&&d(Oi(S.parentId??O,Ft),x,!0)}},y=(g,x,_)=>{for(let S of r.slotsHostedBy(g)){let b=Ql(S);(_===null||_.has(b)||b===Ft)&&d(S,x,!0)}for(let S of r.slotsHostedBelow(g))d(S,x,!0)};for(let[g,x]of t.before){if(t.after.has(g))continue;let _=Jl(x.start,n);for(let S of x.writes)d(S,_,!1)}for(let[g,x]of t.after){if(t.before.has(g))continue;let _=Jl(x.start,n);for(let S of x.writes)d(S,_,!1)}for(let g of i.variables.changed)d(em(Os+g),0,!0);if(e.layoutChanged)for(let g of r.slotsNamed(tr))d(g,0,!0);for(let g of i.nodes.reorderedParents)d(Oi(g,Ft),0,!0);for(let g of i.nodes.removed){let x=f(o,g);a.removed.add(g),h(g,x),y(g,x,null)}for(let g of i.nodes.added){let x=f(s,g);x!==1/0&&(c(g,x,!0),u(g,x),h(g,x))}for(let g of s.nodes.keys()){if(g===O||!o.nodes.has(g))continue;let x=o.effSpan(g),_=s.effSpan(g);if(x?.start===_?.start&&x?.end===_?.end)continue;let S=Math.min(f(o,g),f(s,g));S!==1/0&&(c(g,S,!0),u(g,S),h(g,S))}let w=new Set([...e.reinstantiate,...i.nodes.added,...i.nodes.removed]);for(let g of e.reinstantiate){let x=cw(g,t,w);y(g,0,x),u(g,0);for(let _ of[g,...r.ownersBelow(g)])for(let S of r.depsOf(_))if(S.startsWith(Ci)){c(_,0,!0);break}i.nodes.moved.has(g)&&h(g,0)}if(i.rootChanged){let g=t.propsOf(O);y(O,0,g?nm(o.nodes.get(O),s.nodes.get(O),g):null)}return a}function cw(t,e,r){let{prev:n,next:o,diff:s}=e.patch,i=n.nodes.get(t),a=o.nodes.get(t);if(!i||!a||!s.nodes.respec.has(t)||s.nodes.moved.has(t)||i.type!==a.type||i.key!==a.key)return null;for(let c of[n,o])if(dw(c,t,r,e))return null;let l=e.propsOf(t);return l?nm(i,a,l):null}function nm(t,e,r){let n=new Set;for(let o of new Set([...Object.keys(t.props),...Object.keys(e.props)]))if(!Te(t.props[o],e.props[o])){if(!r.has(o))return null;n.add(o)}return n}function dw(t,e,r,n){let o=new Set([e]),s=t.nodes.get(e)?.parentId??null;for(;s!==null&&s!==O&&!o.has(s);){o.add(s);let i=t.nodes.get(s);if(!i)return!1;if(r.has(s)&&n.isContextProvider(i.type))return!0;s=i.parentId}return!1}function Jl(t,e){if(!(t>0))return 0;if(!Number.isFinite(t))return 1/0;let r=Math.max(0,Math.ceil(t*e));for(;r>0&&lt(r-1,e,1/0)>=t;)r--;for(;lt(r,e,1/0)<t;)r++;return r}var Co=class{setOwner(e,r){if(r.length===0)return this.removeOwner(e);let n=this._owners.get(e);return n&&im(n,r)?!1:(this._owners.set(e,r),!0)}removeOwner(e){return this._owners.delete(e)}requests(){let e=[];for(let r of this._owners.values())e.push(...r);return e}_owners=new Map};function om(t){return t.declareAudio!==he.prototype.declareAudio}function sm(t,e,r,n,o){let s=[];return t.declareAudio({catalog:r,span:{start:e.start,end:e.end},clip(i){let a={...i,at:i.at??e.start,until:i.until??e.end};s.push(Wu(a,r,n,s.length))},_spanOf(i){let a=o(i);if(!a)throw new Error(`${i.className} is not in the tree declaring "${n}"'s audio, so it has no span.`);return{start:a.start,end:a.end}}}),s}function im(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n of r)if(!im(t[n],e[n]))return!1;return!0}var To=8,_r=class{_scope;constructor(e,r,n={}){this._scope=r,this._options=n,this._refine=n.assets!==!1?"assets":n.audio!==!1?"audio":"none",this._project=e;for(let o of e.tracks)this._entries.set(o.id,this._fresh(o));this._spans=bo(e.tracks,r.fps)}get project(){return this._project}get tracks(){return this._project.tracks}get spans(){return this._spans}get version(){return this._version}get profile(){return this._options.profile}setProject(e){let r={deltas:new Map,rebuilt:[]};if(this._disposed||e===this._project)return r;let n=!Te(this._project.theme,e.theme);this._project=e;let o=this._entries;this._entries=new Map;for(let a of e.tracks){let l=o.get(a.id),c=l&&!n?this._reconcile(l,a,r):this._fresh(a);l&&c!==l&&r.rebuilt.push(a.id),this._entries.set(a.id,c)}let s=r.rebuilt.length>0||o.size!==this._entries.size;for(let[a,l]of o)this._entries.get(a)!==l&&(this._discard(l),s=!0);let i=bo(e.tracks,this._scope.fps);return(s||!mw(i,this._spans))&&this._version++,this._spans=i,r}reset(){if(this._disposed)return;let e=this._entries;this._entries=new Map;for(let r of this._project.tracks)this._entries.set(r.id,this._fresh(r));for(let r of e.values())this._discard(r);this._version++}ensureBuilt(e){let r=this._entries.get(e);return!r||r.running||this._disposed?null:(r.steps&&this._drain(r),!r.instance&&!r.failure&&(this._start(r,!0,this._refine!=="none"&&!r.discovered),this._drain(r)),r.instance)}discover(e){let r=this._entries.get(e);if(!(!r||r.running||this._disposed)){if(this._refine==="none"){this.ensureBuilt(e);return}r.discovered||(r.steps||this._start(r,!r.instance,!0),this._drain(r))}}async runAsync(e={}){let{budgetMs:r=To,isCancelled:n,onProgress:o}=e;if(this._refine!=="none")for(;;){if(this._disposed||n?.())return;let s=this._nextUndiscovered();if(!s)return;s.steps||this._start(s,!s.instance,!0);let i=Vt()+r,a=this._step(s);for(;!a;){if(Vt()>=i){if(s.profile?.suspend(),await bi(),this._disposed||n?.())return;if(s.discarded||!s.steps)break;s.profile?.resume(),i=Vt()+r}a=this._step(s)}!s.discarded&&s.discovered&&o?.()}}instanceOf(e){let r=this._entries.get(e);return r&&!r.steps?r.instance:null}generationOf(e){return this._entries.get(e)?.generation??-1}failed(e){return!!this._entries.get(e)?.failure}isDiscovered(e){return!!this._entries.get(e)?.discovered}trackAssets(e){return this._entries.get(e)?.discovered??void 0}errorsOf(e){let r=this._entries.get(e);return r?.discovered?r.errors:[]}ownersOf(e,r){return this._entries.get(e)?.index.owners(r)??new Set}layoutGates(e){let r=this._entries.get(e);return r?.discovered?r.index.layoutGates():[]}learn(e,r,n,o){let s=this._entries.get(e);return!s?.discovered||s.index.learn(r,n,o).keys.size===0?!1:this._refresh(s)}settleGates(e){let r=this._options.isReady;if(!r)return!1;let n=!1;for(let o of e){let s=this._entries.get(o);if(!s||s.unready.size===0||!s.instance||s.steps||s.running)continue;let i=s.discovered?new Set(s.index.layoutGates().map(l=>l.src)):null,a=!1;for(let l of[...s.unready])i&&!i.has(l)?s.unready.delete(l):r(l)&&(a=!0);a&&(this._rebuildInstance(s),n=!0)}return n}rebuild(e){let r=this._entries.get(e);!r||r.running||r.steps||(r.instance?.dispose(),r.instance=null,r.unready.clear(),r.generation++,r.failure&&(r.failure=null,r.discovered=null,this._version++))}release(e){let r=this._entries.get(e);!r||!r.instance||r.running||r.steps||!r.discovered||(r.instance.dispose(),r.instance=null,r.generation++)}trim(e,r){for(let n=0;n<this._spans.length;n++){let o=this._spans[n];o.endFrame>=e-r&&o.startFrame<=e+r||this.release(o.id)}}dispose(){this._disposed=!0;for(let e of this._entries.values())this._discard(e)}_options;_refine;_project;_entries=new Map;_spans;_version=0;_disposed=!1;_fresh(e){let r=On(e.duration,this._scope.fps);return{track:e,frameCount:r,instance:null,steps:null,running:!1,discarded:!1,profile:void 0,discovered:null,errors:[],index:new ko(r),audio:new Co,deps:new Eo,assetDeps:new Map,audioDeps:new Map,ownerErrors:new Map,audioErrors:new Map,failure:null,refineError:null,generation:0,writes:new WeakMap,unready:new Set}}_reconcile(e,r,n){let o=On(r.duration,this._scope.fps);if(e.track.clip===r.clip)return this._resize(e,r,o);if(e.steps||e.failure)return this._fresh(r);if(!e.instance)return e.discovered&&di(e.track.clip,r.clip).identical?this._resize(e,r,o):this._fresh(r);let s=e.instance,i;try{i=s.planUpdate(r.clip)}catch{i=null}if(!i)return this._fresh(r);if(i.diff.identical)return this._resize(e,r,o);let a=e.discovered!==null&&this._refine!=="none",l=a?this._placedWrites(e):void 0;try{this._compile(e,u=>s.applyUpdate(i,r.clip,r.duration,u))}catch{return this._fresh(r)}if(e.generation++,e.track=r,!a)return e.frameCount=o,e;if(o>e.frameCount)return this._undiscover(e,o),e;let c=rm({patch:i,deps:e.deps,before:l,after:this._placedWrites(e),fps:this._scope.fps,propsOf:u=>{let f=s.node(u);return f?new Set(f.__cells?.slots.keys()??[]):void 0},buildsChildren:u=>{let f=s.node(u);return!!f&&f._allChildren.some(h=>s.node(h.id)!==h)},isContextProvider:u=>ci(this._scope.registry,u)}),d=this._applyDirty(e,c,o);if(o!==e.frameCount){e.frameCount=o;for(let u of e.index.setFrameCount(o).keys)d.add(u)}return this._refresh(e)&&n.deltas.set(r.id,d),e}_resize(e,r,n){let o=e.track.duration;return e.track=r,r.duration===o?e:e.steps?this._fresh(r):(e.instance?.update(e.instance.clip,r.duration),this._refine==="none"||!e.discovered?e.frameCount=n:n>e.frameCount?this._undiscover(e,n):n!==e.frameCount&&(e.frameCount=n,e.index.setFrameCount(n),this._refresh(e)),e)}_undiscover(e,r){e.frameCount=r,e.discovered=null,this._version++}_discard(e){e.discarded=!0,!e.running&&(e.steps?.return(void 0),e.steps=null,e.instance?.dispose(),e.instance=null)}_nextUndiscovered(){let e,r=1/0;for(let n of this._spans){let o=this._entries.get(n.id);!o||o.discovered||o.running||(!e||n.startFrame<r)&&(e=o,r=n.startFrame)}return e}_start(e,r,n){let o=this._project.tracks.findIndex(s=>s.id===e.track.id);e.profile=n?this._options.profile?.track(o,e.track.id):void 0,e.steps=this._steps(e,r,n)}_drain(e){for(;e.steps&&!this._step(e););}_step(e){let r=e.steps;if(!r)return!0;e.running=!0;let n;try{n=r.next()}finally{e.running=!1}return e.generation++,e.discarded||this._disposed?(n.done||r.return(void 0),e.steps=null,e.instance?.dispose(),e.instance=null,!0):n.done?(e.steps=null,!0):!1}*_steps(e,r,n){let o=e.profile,{fps:s,assets:i}=this._scope;if(r){o?.enter("build"),e.unready.clear();try{let u=new ki(e.track.clip,e.track.duration,this._scope);e.instance=u,this._compile(e,f=>u.build(f))}catch(u){e.instance?.dispose(),e.instance=null,e.failure=tc(e.track.id,u),n&&(this._resetAssets(e),this._refresh(e,!0),o?.done(e.frameCount));return}if(!n)return;yield}let a=e.instance,l=e.frameCount;this._resetAssets(e);let c=new Map;try{let u=yield*Zl(a,{fps:s,frameCount:l,catalog:i,declare:this._refine==="assets",onPhase:f=>o?.enter(f),onArrive:(f,h,y)=>{o?.enter("audio"),this._declareAudio(e,f,h,y,c)}});this._commit(e,u,c)}catch(u){e.refineError=tc(e.track.id,u)}let d=this._options.isReady;if(d)for(let u of e.index.layoutGates())u.type==="loader"&&!d(u.src)&&e.unready.add(u.src);this._refresh(e,!0),o?.done(l),this._options.keepInstances===!1&&(a.dispose(),e.instance=null)}_resetAssets(e){e.index=new ko(e.frameCount),e.audio=new Co,e.deps=new Eo,e.assetDeps.clear(),e.audioDeps.clear(),e.ownerErrors.clear(),e.audioErrors.clear(),e.refineError=null}_commit(e,r,n){let o=new Pn(e.instance);for(let s of r.owners.values()){let i=s.ownerKey;s.error?e.ownerErrors.set(i,this._ownerError(e,s)):e.index.setOwner(i,s.segments),e.assetDeps.set(i,o.idsOf(s.deps))}for(let[s,i]of n)e.audioDeps.set(s,o.idsOf(i));for(let s of new Set([...e.assetDeps.keys(),...e.audioDeps.keys()]))this._link(e,s)}_applyDirty(e,r,n){let o=new Set,s=_=>{for(let S of _.keys)o.add(S)};for(let _ of r.removed)for(let S of[_,...e.deps.ownersBelow(_)])this._drop(e,S,s);if(r.owners.size===0&&r.below.size===0)return o;let i=e.instance,{fps:a,assets:l}=this._scope,c=new Set,d=new Map,u=Zl(i,{fps:a,frameCount:n,catalog:l,owners:r.owners,below:r.below,declare:this._refine==="assets",onArrive:(_,S,b,k)=>{c.add(S),k===En(b,a,n)?.startFrame&&this._declareAudio(e,_,S,b,d)}}),f=u.next();for(;!f.done;)f=u.next();e.generation++;let h=f.value,y=_=>{let S=r.owners.get(_);for(let b=_.indexOf("/");b>=0;b=_.indexOf("/",b+1)){let k=r.below.get(_.slice(0,b));k!==void 0&&(S===void 0||k<S)&&(S=k)}return S??0},w=_=>{if(r.arrivalOwners.has(_))return!0;for(let S=_.indexOf("/");S>=0;S=_.indexOf("/",S+1))if(r.arrivalBelow.has(_.slice(0,S)))return!0;return!1},g=new Set(h.owners.keys());for(let _ of r.below.keys())for(let S of e.deps.ownersBelow(_))g.add(S);let x=new Pn(i);for(let _ of g){let S=y(_),b=h.owners.get(_);if(!b&&S===0){this._drop(e,_,s);continue}let k=S>0?uw(e.index.declaredSegmentsOf(_),S):[];if(b?.error?e.ownerErrors.set(_,this._ownerError(e,b)):e.ownerErrors.delete(_),s(e.index.setOwner(_,b&&!b.error?[...k,...b.segments]:k)),b){let M=x.idsOf(b.deps);e.assetDeps.set(_,S>0?[...new Set([...e.assetDeps.get(_)??[],...M])]:M)}w(_)&&!c.has(_)&&(e.audio.removeOwner(_),e.audioDeps.delete(_),e.audioErrors.delete(_)),this._link(e,_)}for(let[_,S]of d)e.audioDeps.set(_,x.idsOf(S)),this._link(e,_);return o}_drop(e,r,n){n(e.index.removeOwner(r)),e.audio.removeOwner(r),e.assetDeps.delete(r),e.audioDeps.delete(r),e.ownerErrors.delete(r),e.audioErrors.delete(r),e.deps.remove(r)}_link(e,r){let n=e.assetDeps.get(r),o=e.audioDeps.get(r);n===void 0&&o===void 0?e.deps.remove(r):e.deps.set(r,[...n??[],...o??[]])}_declareAudio(e,r,n,o,s){let i=[];if(s.set(n,i),!om(r)){e.audio.removeOwner(n),e.audioErrors.delete(n);return}try{let a=It({read:l=>{i.push(l)},write:()=>{}},()=>sm(r,o,this._scope.assets,n,l=>e.instance.spanOf(l)));e.audio.setOwner(n,a),e.audioErrors.delete(n)}catch(a){e.audio.removeOwner(n),e.audioErrors.set(n,{...tc(e.track.id,a),nodeId:r.id})}}_ownerError(e,r){let n=r.error;return{trackId:e.track.id,message:n.message,...n.stack!==void 0&&{stack:n.stack},...r.nodeId!==void 0&&{nodeId:r.nodeId},...n.prop!==void 0&&{prop:n.prop}}}_refresh(e,r=!1){let n=e.discovered,{fps:o}=this._scope,s=n&&hw(n.assetRecords,e.index.records())?n.assetRecords:new Map(e.index.records()),i=fw(e.audio.requests(),e.frameCount/o),a=e.index.layoutGates().map(c=>c.src),l=[...e.audioErrors.values(),...e.ownerErrors.values(),...e.failure?[e.failure]:[],...e.refineError?[e.refineError]:[]];return!r&&n&&s===n.assetRecords&&n.frameCount===e.frameCount&&Po(n.audioRequests,i)&&Po(n.layoutGates,a)&&Po(e.errors,l)?!1:(e.discovered={id:e.track.id,discovered:!0,frameCount:e.frameCount,startFrame:0,audioRequests:i,assetRecords:s,layoutGates:a},e.errors=l,this._version++,!0)}_placedWrites(e){let r=e.instance,n=new Map,o;for(let s of r.placedCommands()){let i=e.writes.get(s.writes);i||(o??=new Pn(r),i={start:s.start,writes:o.idsOf(s.writes)},e.writes.set(s.writes,i)),n.set(s.writes,i)}return n}_compile(e,r){let n=this._options.isReady,o=this._scope.measurer;if(!n){r(o);return}let s=new Set;r({measureText(i,a,l,c,d,u){return s.add(l),o.measureText(i,a,l,c,d,u)}});for(let i of s)n(i)||e.unready.add(i)}_rebuildInstance(e){e.instance?.dispose(),e.instance=null,e.generation++,this._start(e,!0,!1),this._drain(e),e.failure&&e.discovered&&this._refresh(e)}};function tc(t,e){let r=e instanceof Error?e:new Error(String(e));return{trackId:t,message:r.message,stack:r.stack}}function uw(t,e){let r=[];for(let n of t)n.startFrame>=e||r.push(n.endFrame>=e?{...n,endFrame:e-1}:n);return r}function fw(t,e){let r=[];for(let n of t){let o=n.bus&&pw(n.bus,e),s=o===n.bus?{...n}:{...n,bus:o};if(n.open){r.push(s);continue}if(n.startAt>=e)continue;let i=Math.min(n.endAt,e);i<=n.startAt||r.push(i===n.endAt?s:{...s,endAt:i})}return r}function pw(t,e){return t.every(r=>r.endAt<=e)?t:t.map(r=>r.endAt<=e?r:{...r,endAt:e})}function hw(t,e){if(t.size!==e.size)return!1;for(let[r,n]of t){let o=e.get(r);if(!o||!Po(n,o))return!1}return!0}function mw(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r].id!==e[r].id||t[r].startFrame!==e[r].startFrame||t[r].endFrame!==e[r].endFrame)return!1;return!0}function Po(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null||Array.isArray(t)!==Array.isArray(e))return!1;let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n of r)if(!Po(t[n],e[n]))return!1;return!0}var Pi=class{_scope;constructor(e,r,n){this._scope=r,this._owned=n===void 0,this._store=n??new _r(e,r,{assets:!1,audio:!1}),this._slots=this._slotsFor(e.tracks,new Map),this._currentTrackId=rc(this._slots)?.track.id??null}get currentFrame(){return this._currentFrame}get currentTrackId(){return this._currentTrackId}get currentCanvas(){return this.currentInstance?.canvas??null}get currentInstance(){let e=this._slotOf(this._currentTrackId);return e?.instance&&e.instance===this._store.instanceOf(e.track.id)?e.instance:null}get activeTrackIds(){return this._active.map(e=>e.track.id)}stateAt(e){if(this._disposed)return;let r=Math.max(0,Math.floor(e)),n=this._slotsToDraw(r);if(!this._stale&&r===this._currentFrame&&yw(n,this._active)&&n.every(s=>this._settled(s)))return;this._active=n;let o=rc([...n].reverse());o&&(this._currentTrackId=o.track.id);for(let s of n)s.instance=this._store.ensureBuilt(s.track.id);for(let s of n)s.instance&&(this._evaluate(s,r-s.span.startFrame),s.generation=this._store.generationOf(s.track.id));this._currentFrame=r,this._stale=!1}layout(e=this._scope.measurer){for(let r of this._active)this._live(r)?.layout(e)}render(e){for(let r of this._active)this._live(r)?.render(e)}invalidate(){this._stale=!0}rebuild(e=this._currentTrackId){e!==null&&(this._store.rebuild(e),this._stale=!0)}setProject(e){if(this._disposed)return;this._store.setProject(e);let r=new Map(this._slots.map(o=>[o.track.id,o]));this._slots=this._slotsFor(e.tracks,r);let n=new Set(this._slots);for(let o of this._editorStates.keys())this._slotOf(o)||this._editorStates.delete(o);this._active=this._active.filter(o=>n.has(o)),this._slotOf(this._currentTrackId)||(this._currentTrackId=rc(this._slots)?.track.id??null),this._stale=!0}setEditorStates(e,r){r?this._editorStates.set(e,r):this._editorStates.delete(e),this._stale=!0}dispose(){this._disposed=!0,this._active=[];for(let e of this._slots)e.instance=null;this._owned&&this._store.dispose()}_store;_owned;_slots;_active=[];_currentFrame=0;_currentTrackId;_stale=!1;_disposed=!1;_editorStates=new Map;_slotsFor(e,r){let n=bo(e,this._scope.fps);return e.map((o,s)=>{let i=r.get(o.id);return i?(i.track=o,i.span=n[s],i):{track:o,span:n[s],instance:null,generation:-1}})}_slotOf(e){return e===null?void 0:this._slots.find(r=>r.track.id===e)}_settled(e){let r=e.track.id;return e.instance?e.instance===this._store.instanceOf(r)&&e.generation===this._store.generationOf(r):this._store.failed(r)}_live(e){return e.instance&&e.instance===this._store.instanceOf(e.track.id)?e.instance:null}_slotsToDraw(e){let r=this._slots.map(o=>o.span),n=xr(r,e);if(n.length===0){let o=Math.max(-1,...r.map(s=>s.endFrame));e>o&&o>=0&&(n=xr(r,o))}return n.map(o=>this._slots[o.index])}_evaluate(e,r){let n=e.instance,o=Hr(1,this._scope.fps),s=lt(r,this._scope.fps,e.track.duration);n.attach(s,this._editorStates.get(e.track.id));let i=Math.max(0,s-o);n.evaluateAt(i),n.layout(),n.primeMotion(i),n.evaluateAt(s),n.layout(),n.sample()}};function rc(t){return t.find(e=>!mr(e.track.clip))}function yw(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}var nc=4;async function am(t,e,r){for(let n=0;n<4;n++){if(!r())return"superseded";if(t(),!await e.warmPendingDecodes())return"settled";if(!r())return"superseded"}return"exhausted"}var Ti=class{_fps;_catalog;constructor(e,r){this._fps=e,this._catalog=r}update(e){let r=new Set,n=new Set;for(let s of e){n.add(s.id);let i=this._tracks.get(s.id);if(i&&i.records===s.records&&i.startFrame===s.startFrame)continue;let a=!i||i.startFrame!==s.startFrame;for(let[l,c]of s.records){let d=i?.records.get(l);(a||!d||!dm(d,c))&&r.add(l),this._holders(l).add(s.id)}if(i)for(let l of i.records.keys())s.records.has(l)||(r.add(l),this._release(l,s.id));this._tracks.set(s.id,{id:s.id,startFrame:s.startFrame,records:s.records})}for(let[s,i]of this._tracks)if(!n.has(s)){this._tracks.delete(s);for(let a of i.records.keys())r.add(a),this._release(a,s)}let o;for(let s of r){let i=this._entryOf(s),a=this._map.get(s);if(i===void 0){if(a===void 0)continue;o??=new Map(this._map),o.delete(s)}else(a===void 0||!bw(a,i))&&(o??=new Map(this._map),o.set(s,i))}return o&&(this._map=o),this._map}_tracks=new Map;_byKey=new Map;_map=new Map;_holders(e){let r=this._byKey.get(e);return r||this._byKey.set(e,r=new Set),r}_release(e,r){let n=this._byKey.get(e);n&&(n.delete(r),n.size===0&&this._byKey.delete(e))}_entryOf(e){let r=this._byKey.get(e);if(!r)return;let n;for(let o of r){let s=this._tracks.get(o),i=s.records.get(e);i&&(n=xw(n,gw(i,s.startFrame)))}return n&&Sw(n,this._fps,this._catalog)}};function gw(t,e){return e===0?t:{...t,startFrame:t.startFrame+e,endFrame:t.endFrame+e}}function xw(t,e){return t?{...t,startFrame:Math.min(t.startFrame,e.startFrame),endFrame:Math.max(t.endFrame,e.endFrame)}:e}function lm(t,e){let r;try{r=t.type==="image"?e.getImageMeta(t.src):e.getVideoMeta(t.src)}catch{return 0}return!(r.width>0)&&!(r.height>0)?0:vw(r.width,r.height)}var _w=2,ww=2,sc=120,oc=30;function vw(t,e){return t*e*4/(1024*1024)}function cm(t){return Math.min(sc,Math.max(ww,Math.round(t*_w)))}function Sw(t,e,r){switch(t.type){case"image":{let n=cm(lm(t,r));return{record:t,cacheAt:Math.max(0,t.startFrame-n),discardAt:t.endFrame+oc}}case"video":{let n=Math.min(sc,cm(lm(t,r))*2+Math.round(e));return{record:t,cacheAt:Math.max(0,t.startFrame-n),discardAt:t.endFrame+oc}}case"font":return{record:t,cacheAt:0,discardAt:null};case"loader":return{record:t,cacheAt:Math.max(0,t.startFrame-sc),discardAt:t.endFrame+oc};default:return}}function bw(t,e){return t.cacheAt===e.cacheAt&&t.discardAt===e.discardAt&&dm(t.record,e.record)}function dm(t,e){if(t===e)return!0;if(t.type!==e.type||t.src!==e.src||t.startFrame!==e.startFrame||t.endFrame!==e.endFrame)return!1;switch(t.type){case"video":{let r=e;return t.trimStart===r.trimStart&&t.trimEnd===r.trimEnd}case"font":{let r=e;return t.fontWeight===r.fontWeight&&t.fontFamily===r.fontFamily}case"loader":return t.load===e.load;default:return!0}}var kw=["build","declare","evaluate","audio"];function s2(){let t=[];return{timings:t,track(e,r){let n=Object.fromEntries(kw.map(l=>[l,0])),o=null,s=Vt(),i=0,a=()=>{let l=Vt()-s;o&&(n[o]+=l),i+=l};return{enter(l){a(),o=l,s=Vt()},suspend(){a(),o=null},resume(){s=Vt()},done(l){a(),o=null,t[e]={trackId:r,trackIndex:e,frameCount:l,totalMs:i,phases:n}}}}}}var Di=class{_scope;constructor(e,r,n={}){this._scope=r,this._owned=n.store===void 0,this._store=n.store??new _r(e,r,{profile:n.profile,assets:n.assets,keepInstances:!1}),this._assets=new Ti(r.fps,r.assets)}get store(){return this._store}get discoveredCount(){let e=0;for(let r of this._store.tracks)this._store.isDiscovered(r.id)&&e++;return e}result(){return this._assemble()}ensureCovering(e){for(let r of xr(this._store.spans,e))this._store.discover(r.id);return this._assemble()}run(){for(let e of this._store.tracks)this._store.discover(e.id);return this._assemble()}async runAsync(e={}){let{budgetMs:r=To,isCancelled:n,onProgress:o}=e;return await this._store.runAsync({budgetMs:r,isCancelled:n,onProgress:o&&(()=>o(this._assemble()))}),this._assemble()}setProject(e){return this._store.setProject(e),this._assemble()}learn(e,r,n,o){return this._store.learn(e,r,n,o),this._assemble()}dispose(){this._owned&&this._store.dispose()}_store;_owned;_assets;_result=null;_version=-1;_assemble(){let e=this._store;if(this._result&&this._version===e.version)return this._result;let{fps:r}=this._scope,n=e.spans,o=Uh(n),s=o/r,i=[],a=[],l=!0,c=n.map(f=>{let h=e.trackAssets(f.id);return h||(l=!1),a.push(...e.errorsOf(f.id)),h??Aw(f.id,f.endFrame-f.startFrame+1)}),d=this._assets.update(c.map((f,h)=>({id:f.id,startFrame:n[h].startFrame,records:f.assetRecords})));for(let f=0;f<c.length;f++)i.push(Mw({...c[f],startFrame:n[f].startFrame},r,s));let u=e.profile;return this._version=e.version,this._result={fps:r,tracks:i,totalFrames:o,totalDuration:s,assets:d,buildErrors:a,complete:l,timings:u?.timings?.slice()}}};function Aw(t,e){return{id:t,discovered:!1,frameCount:e,startFrame:0,audioRequests:[],assetRecords:new Map,layoutGates:[]}}function Mw(t,e,r){if(!t.audioRequests.some(s=>s.open))return t;let n=t.startFrame/e,o=t.audioRequests.map(s=>{if(!s.open)return s;let i=n+s.startAt,a=s.loop?r:Math.min(i+(s.mediaDuration??0),r);return{...s,endAt:Math.max(s.startAt,a-n)}});return{...t,audioRequests:o}}function lc(t,e,r){let n=dc(t);if(!n)return[];let o=[];for(let s of cc(t,r)){let i=n.boxes.get(s.node.id);if(!i)continue;let a=xm(i,n);a&&o.push({box:_m(s.node,s.path,a.rect,e),depth:a.depth})}return o.sort((s,i)=>i.depth-s.depth),o.map(s=>s.box)}var Ow={x:0,y:0,z:0};function hm(t,e,r,n,o,s){let i=dc(t);if(!i)return null;let a=cc(t,r).find(h=>h.path===n);if(!a)return null;let l=i.matrices.get(a.node.id),c=i.parentMatrices.get(a.node.id);if(!l||!c)return null;let d=(h,y)=>y.map(w=>um(h,w,i,e)),u=gl(a.node),f=u?o.map(h=>u.toLocal(h.x,h.y,h.z)):o;return{origin:um(l,Ow,i,e),parentPoints:d(c,f),localPoints:d(l,s)}}function um(t,e,r,n){let o=Pt(t,e),s=Pt(r.clip,{x:o.x,y:o.y,z:o.z});if(s.w<=Do)return null;let i=s.x/s.w,a=s.y/s.w,l=r.centerX+i*(r.width/2),c=r.centerY+a*(r.height/2),d=ee(n.matrix,{x:l,y:-c});return{x:d.x,y:-d.y}}function mm(t,e,r,n,o){let s=dc(t);if(!s)return null;let i=Ie(e.matrix);if(!i)return null;let a=ee(i,{x:r.x,y:-r.y}),l={x:a.x,y:-a.y},c=null,d=-1/0;for(let u of cc(t,o)){let f=s.boxes.get(u.node.id);if(!f)continue;let h=xm(f,s);h&&Fw(h.rect,l,n)&&(h.depth<=d||(d=h.depth,c={node:u.node,path:u.path,rect:h.rect}))}return c?_m(c.node,c.path,c.rect,e):null}function cc(t,e){let r=[];return ym(t._allChildren,e,r),r}function ym(t,e,r){for(let n=0;n<t.length;n++){let o=t[n];if(!(o instanceof I))continue;let s=zt(e,n);r.push({node:o,path:s}),ym(o._allChildren,s,r)}}function dc(t){let e=t._localBounds();if(!(e.width>0)||!(e.height>0))return null;let r=t._scene3D(),n=Ew(r);if(n.boxes.size===0)return null;let o=gi(n.camera);if(!o)return null;let s=e.width/e.height;return{boxes:n.boxes,matrices:n.matrices,parentMatrices:n.parentMatrices,clip:Ct(Dw(n.descriptor,s),o),view:o,width:e.width,height:e.height,centerX:e.x,centerY:e.y}}function Ew(t){let e=new Map,r=new Map,n=new Map,s=[{key:void 0,matrix:yi(),visible:!0,box:null}],i=null,a=null,l=()=>s[s.length-1];for(let c of t.ops()){let d=l();switch(c.kind){case"push":{let u=gm(d.matrix,c.transform);c.transform?.key!==void 0&&(r.set(c.transform.key,u),n.set(c.transform.key,d.matrix)),s.push({key:c.transform?.key,matrix:u,visible:d.visible&&c.transform?.visible!==!1,box:null});break}case"pop":{if(s.length===1)break;let u=s.pop();if(!u.visible||!u.box)break;u.key!==void 0&&e.set(u.key,u.box);let f=l();f.box=So(f.box,u.box);break}case"camera":{a=c.camera,i=Pw(c.camera,d.matrix);break}case"light":break;default:{if(!d.visible)break;let u=Cw(c,d.matrix);u&&(d.box=So(d.box,u));break}}}return{boxes:e,matrices:r,parentMatrices:n,camera:i??Tw,descriptor:a}}function gm(t,e){return Ct(t,wo(e,t))}function Cw(t,e){if(t.kind==="model"||!("transform"in t))return null;let r=gm(e,t.transform);if(t.kind==="sprite")return Mn(Be(.5,.5,0),r);if(!("geometry"in t))return null;let n=wi(t.geometry);if(!n)return null;if(t.kind==="instances"){let o=null;for(let s of t.instances)o=So(o,Mn(n,wo(s,null)));return o?Mn(o,r):null}return Mn(n,r)}function Pw(t,e){let r=xl(t);if(r.lookAt===void 0)return Ct(e,wo({...t,position:r.position},e));let n=Pt(e,r.position),o={x:n.x,y:n.y,z:n.z};return Ct(vo(o),_o(o,r.lookAt))}var Tw=Ct(vo({x:0,y:0,z:5}),_o({x:0,y:0,z:5},{x:0,y:0,z:0})),fm=50,ic=.1,ac=1e3;function Dw(t,e){if(t===null)return xi(fm,e,ic,ac,1);if(t.type==="perspective")return xi(t.fov??fm,e,t.near??ic,t.far??ac,t.zoom??1);let r=(t.frustumHeight??10)/2;return Hl(-r*e,r*e,r,-r,t.near??ic,t.far??ac,t.zoom??1)}var Rw=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Do=1e-4,pm=8;function xm(t,e){let n=_i(t).map(x=>Pt(e.clip,x)),o=1/0,s=1/0,i=-1/0,a=-1/0,l=!1,c=(x,_,S)=>{let b=x/S,k=_/S;b<o&&(o=b),k<s&&(s=k),b>i&&(i=b),k>a&&(a=k),l=!0};for(let[x,_]of Rw){let S=n[x],b=n[_],k=S.w>Do,M=b.w>Do;if(!k&&!M||(k&&c(S.x,S.y,S.w),M&&c(b.x,b.y,b.w),k===M))continue;let T=(Do-S.w)/(b.w-S.w);c(S.x+(b.x-S.x)*T,S.y+(b.y-S.y)*T,Do)}if(!l)return null;let d=e.width/2,u=e.height/2,f=d*pm,h=u*pm,y={minX:Ri(e.centerX+o*d,e.centerX-f,e.centerX+f),maxX:Ri(e.centerX+i*d,e.centerX-f,e.centerX+f),minY:Ri(e.centerY+s*u,e.centerY-h,e.centerY+h),maxY:Ri(e.centerY+a*u,e.centerY-h,e.centerY+h)},w={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2,z:(t.min.z+t.max.z)/2},g=Pt(e.view,w);return{rect:y,depth:g.z}}function Ri(t,e,r){return t<e?e:t>r?r:t}function Fw(t,e,r){return e.x>=t.minX-r&&e.x<=t.maxX+r&&e.y>=t.minY-r&&e.y<=t.maxY+r}function _m(t,e,r,n){let o=(s,i)=>{let a=ee(n.matrix,{x:s,y:-i});return{x:a.x,y:-a.y}};return{id:t.id,path:e,type:t.className,topLeft:o(r.minX,r.maxY),topRight:o(r.maxX,r.maxY),bottomRight:o(r.maxX,r.minY),bottomLeft:o(r.minX,r.minY),center:o((r.minX+r.maxX)/2,(r.minY+r.maxY)/2),width:r.maxX-r.minX,height:r.maxY-r.minY,rotation:n.box.rotation,scale:n.box.scale,opacity:n.box.opacity,locked:t.locked}}function ct(t){let e=lo(t);if(e)return we(ct(e.root),e.screen);let r=t.parent;return r?we(Ro(r),t._localMatrix()):t._localMatrix()}function Ro(t){let e=ct(t),r=t._spaceCamera();if(r)return we(e,nr(t,r).screen);let n=t._cameraScope();if(!n)return e;let o=t.layoutBounds;return we(e,Oa(o.x,-o.y,n.lookAt,n.zoom,n.heading))}function vm(t,e,r){if(e==="")return null;let n=wr(t,e),o=n instanceof A?n.parent:null;if(!(n instanceof A)||!o)return null;let s=Mm(n,o),i=Ie(s);if(!i)return null;let a=ee(i,{x:r.x,y:-r.y});if(uc(s,a))return null;let l=o._planeOf(n);if(!l)return{x:a.x,y:-a.y};let c=n._placement()?null:n.layoutBounds;return l.toCoords(a.x-(c?.x??0),(c?.y??0)-a.y)}function Sm(t,e,r){let n=wr(t,e);if(!(n instanceof A))return null;let o=n._planeOf(null);if(!o)return null;let s=Ie(Ro(n));if(!s)return null;let i=ee(s,{x:r.x,y:-r.y});return o.toCoords(i.x,-i.y)}function bm(t,e,r,n){let o=wr(t,e),s=wr(t,r),i=o instanceof A?o.parent:null;if(!(o instanceof A)||!(i instanceof A)||!(s instanceof A))return null;for(let V=s;V;V=V.parent)if(V===o)return null;let a=o.layoutBounds,l=s._planeOf(null),c=l?null:s._slotFor({width:a?.width??0,height:a?.height??0});if(!l&&!c)return null;let d=Mm(o,i),u=Ie(d),f=Ie(Ro(s));if(!u||!f)return null;let h=o._placement(),y=wm(i),w=wm(s),g=y.rotation+(h?.rotation??0)-w.rotation,x=w.scale===0?1:y.scale*(h?.scale??1)/w.scale,_=o._centreShift(o.rotation+g,o.scale*x),S=ee(u,ee(ct(o),{x:0,y:0})),b=i._planeOf(o),k=V=>b?{...b.toOffset(V.x,V.y)}:V,M=k({x:o.x,y:o.y});return{offsets:n.map(V=>{let W=k(V),Se=ee(d,{x:S.x+W.x-M.x,y:S.y-(W.y-M.y)}),Ee=ee(f,Se),Tt=Ee.x-_.x,Le=Ee.y-_.y;return l?l.toCoords(Tt,-Le):{x:Tt-c.x,y:c.y-Le}}),turn:g,scale:x}}function wm(t){let e=Om(t),r=t._cameraScope();return r?{rotation:e.rotation-r.heading,scale:e.scale*r.zoom}:e}function km(t,e){let r=wr(t,e);if(!(r instanceof A))return null;let n=ct(r);return r._handles().map(({prop:o,at:s})=>{let i=ee(n,{x:s.x,y:-s.y});return{prop:o,at:{x:i.x,y:-i.y}}})}function Am(t,e,r,n){let o=wr(t,e);if(!(o instanceof A))return null;let s=ct(o),i=Ie(s);if(!i)return null;let a=ee(i,{x:n.x,y:-n.y});return uc(s,a)?null:o._handleValue(r,{x:a.x,y:-a.y})}function Mm(t,e){let r=lo(t)?Xa(e):null;if(!r){let i=t._slotMatrix();return i?we(Ro(e),i):Ro(e)}let n=t._slotAffine(),o=n?Or(r.view,n):r.view,s=Or(o,[1,0,0,0,0,1,0,0,0,0,1,t.depth]);return we(ct(r.root),Qn(r.camera,s))}function uc(t,e){return Ar(t)&&(t.g??0)*e.x+(t.h??0)*e.y+(t.i??1)<=0}function Om(t){let e=0,r=1,n=1;for(let o=t;o;o=o.parent){let s=o._placement();e+=o.rotation+(s?.rotation??0),r*=o.scale*(s?.scale??1),n*=o.opacity*(s?.opacity??1);let i=o!==t?o._cameraScope():null;i&&(e-=i.heading,r*=i.zoom)}return{rotation:e,scale:r,opacity:n}}function Fo(t,e){let r=t._localBounds(),n=r.x===0&&r.y===0?ct(t):we(ct(t),Zn(r.x,-r.y)),o=fn(n,r.width/2,r.height/2),s=Om(t);return{id:t.id,path:e,type:t.className,topLeft:o.topLeft,topRight:o.topRight,bottomRight:o.bottomRight,bottomLeft:o.bottomLeft,center:o.center,width:r.width,height:r.height,rotation:s.rotation,scale:s.scale,opacity:s.opacity,locked:t.locked}}function Em(t,e){if(e==="")return Fo(t,e);let r=t,n=null,o=e.split(".");for(let i=0;i<o.length;i++){r instanceof j&&(n={node:r,path:Cm(o,i)});let a=r._allChildren[Number(o[i])];if(!a)return null;r=a}if(r instanceof A)return Fo(r,e);if(!n)return null;let s=Fi(n.node,n.path);return lc(n.node,s,n.path).find(i=>i.path===e)??null}function wr(t,e){if(e==="")return t;let r=t;for(let n of e.split(".")){let o=r._allChildren[Number(n)];if(!o)return null;r=o}return r}function Cm(t,e){return t.slice(0,e).join(".")}function Pm(t,e,r,n){if(e==="")return null;let o=t,s=null,i=e.split(".");for(let l=0;l<i.length;l++){o instanceof j&&(s={node:o,path:Cm(i,l)});let c=o._allChildren[Number(i[l])];if(!c)return null;o=c}if(o instanceof A||!s)return null;let a=Fi(s.node,s.path);return hm(s.node,a,s.path,e,r,n)}function Tm(t,e,r=0){return Dm(t,"",e,r,!0)}function Dm(t,e,r,n,o){if(t.opacity===0||t.hidden)return null;let s=Rm(t,o);if(s==="none")return null;let i=s==="all"&&Iw(t,r,n);if(!i&&s==="all"&&t._confinesChildren())return null;let a=Im(t),l=Fm(t,a);for(let c=l.length-1;c>=0;c--){let d=l[c],u=a[d];if(u===null)continue;let f=Dm(u,zt(e,d),r,n,!1);if(f)return f}if(t instanceof j&&i){let c=mm(t,Fi(t,e),r,n,e);if(c)return c}return o||t.locked?null:i?Fo(t,e):null}function fc(t,e,r,n){if(t.opacity===0||t.hidden)return;let o=Rm(t,n);if(o==="none")return;if(!n&&o==="all"&&r.push(Fo(t,e)),t instanceof j)for(let i of lc(t,Fi(t,e),e))r.push(i);let s=Im(t);for(let i of Fm(t,s)){let a=s[i];a!==null&&fc(a,zt(e,i),r,!1)}}function Rm(t,e){if(e)return"all";let r=lo(t);return r?!t.backfaceVisible&&r.facesAway?"none":r.paints?"all":t._rendersChildrenInSpace()?"children":"none":"all"}function Fm(t,e){let r=e.map((i,a)=>a),n=Xa(t);if(!n)return r;let o=r.filter(i=>e[i]!==null),s=o.map(i=>pn(n,e[i]));return Rs(s).map(i=>o[i])}function Im(t){return t instanceof j?t._allChildren.map(e=>e instanceof A?e:null):t.children}function Fi(t,e){return{box:Fo(t,e),matrix:ct(t)}}function Iw(t,e,r){let n=ct(t),o=Ie(n);if(!o)return!1;let s=ee(o,{x:e.x,y:-e.y});return uc(n,s)?!1:t._hitTestSelf({x:s.x,y:-s.y},r)}function zm(t,e,r){if(!(t instanceof st))return null;let n=r.layoutTextBlock(t._textState());if(!n)return null;let o=ct(t),s=(l,c)=>{let d=ee(o,{x:l,y:c});return{x:d.x,y:-d.y}},i=new Array(Wl(n)),a=[];for(let l of n.lines){a.push({start:l.start,end:l.end});for(let c=0;c<l.carets.length;c++){let d=l.carets[c];i[l.start+c]={offset:l.start+c,top:s(d,l.top),bottom:s(d,l.bottom)}}}return{path:e,text:t.text,carets:i,lines:a}}function O2(t,e){let r=0,n=1/0;for(let o of t.carets){let s=zw(e,o.top,o.bottom);s<n&&(n=s,r=o.offset)}return r}function E2(t,e,r){let n=Math.max(0,Math.min(e,r)),o=Math.min(t.carets.length-1,Math.max(e,r)),s=[];for(let i of t.lines){let a=Math.max(n,i.start),l=Math.min(o,i.end);if(a>=l)continue;let c=t.carets[a],d=t.carets[l];s.push({topLeft:c.top,topRight:d.top,bottomRight:d.bottom,bottomLeft:c.bottom})}return s}function zw(t,e,r){let n=r.x-e.x,o=r.y-e.y,s=n*n+o*o,i=s===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*o)/s));return Math.hypot(t.x-(e.x+i*n),t.y-(e.y+i*o))}var Ii=class{renderContext;measurer;storageAdapter;masterClock;stateEvaluator;assetManager;audioDevice;assetCatalog;onFramePainted;disposed=!1;precompRunning=!1;hasPainted=!1;seekGeneration=0;precompBudgetMs;onPrecompProgress;fps;viewport;precomper;store;overrides=new Map;precomp;get spans(){return this.precomp.tracks.map((e,r)=>({id:e.id,index:r,startFrame:e.startFrame,endFrame:e.startFrame+e.frameCount-1}))}get totalFrames(){return this.precomp.totalFrames}get totalDuration(){return this.precomp.totalDuration}get currentTrackId(){return this.stateEvaluator.currentTrackId}get buildErrors(){return this.renderErrors.length===0?this.precomp.buildErrors:[...this.precomp.buildErrors,...this.renderErrors]}renderErrors=[];onRenderError;captureRenderError(e,r){let n=e instanceof Error?e:new Error(String(e));r!==void 0&&this.recoverMissingAsset(n,r)||this.renderErrors.some(o=>o.message===n.message)||(this.renderErrors.push({trackId:this.stateEvaluator.currentTrackId??"",message:n.message,stack:n.stack}),this.onRenderError?.(this.buildErrors))}learnMissingAsset(e,r){let n=jw(e,this.assetCatalog);if(n)for(let o of[...this.stateEvaluator.activeTrackIds].reverse()){let s=this.store.instanceOf(o),i=this.precomp.tracks.find(c=>c.id===o);if(!s||!i)continue;let a;if(e.nodeId!==void 0&&s.forEachOwner((c,d)=>{a===void 0&&c.id===e.nodeId&&(a=d)}),a??=this.store.ownersOf(o,e.src).values().next().value,a===void 0)continue;let l=this.precomper.learn(o,a,n,Math.floor(r)-i.startFrame);l!==this.precomp&&this.adoptPrecomp(l);return}}rescuedAssets=new Set;recoverMissingAsset(e,r){if(!(e instanceof un)||e.assetType==="audio")return!1;let n=`${e.assetType}:${e.src}`;if(this.rescuedAssets.has(n))return!1;this.rescuedAssets.add(n),this.learnMissingAsset(e,r);let o=this.recordFor(e.assetType,e.src,r);return o?(this.storageAdapter.loadAsset(e.src,o).then(()=>{this.disposed||(this.renderAt(this.stateEvaluator.currentFrame),this.settleTrailing())}).catch(s=>{this.disposed||this.captureRenderError(new Error(`${e.message}
15
-
16
- Loading it directly also failed: ${String(s)}`))}),!0):!1}recordFor(e,r,n){try{return e==="font"?{type:"font",src:r,startFrame:n,endFrame:n,fontFamily:r,fontWeight:400}:e==="image"?(this.assetCatalog.getImageMeta(r),{type:"image",src:r,startFrame:n,endFrame:n}):(this.assetCatalog.getVideoMeta(r),{type:"video",src:r,startFrame:n,endFrame:n,trimStart:0,trimEnd:this.assetCatalog.getVideoDuration(r)})}catch{return null}}clearRenderErrors(){this.rescuedAssets.clear(),this.renderErrors.length!==0&&(this.renderErrors.length=0,this.onRenderError?.(this.buildErrors))}constructor(e){let{project:r}=e;if(r.fps===void 0||r.viewport===void 0)throw new Error("PlaybackController takes a project whose fps and viewport are resolved \u2014 see Session.");this.renderContext=e.renderContext,this.measurer=e.measurer,this.masterClock=e.masterClock,this.storageAdapter=e.storageAdapter,this.audioDevice=e.audioDevice,this.fps=r.fps,this.viewport=r.viewport,this.precompBudgetMs=e.precompBudgetMs??To,this.onPrecompProgress=e.onPrecompProgress,this.assetCatalog=e.assets;let n={registry:e.registry,viewport:this.viewport,fps:this.fps,assets:e.assets,measurer:this.measurer};this.store=new _r(r,n,{profile:e.precompProfile,isReady:o=>this.assetManager?.isReady(o)??!1}),this.precomper=new Di(r,n,{store:this.store}),this.precomp=this.precomper.ensureCovering(0),this.stateEvaluator=new Pi(r,n,this.store),this.assetManager=new vi(this.precomp,this.storageAdapter,this.audioDevice,o=>this.captureRenderError(o)),this.masterClock.setDuration(this.totalDuration),this.masterClock.onPlay((o,s,i)=>{this.audioDevice.play(o,s,i),this.storageAdapter.setPlaying(!0)}),this.masterClock.onPause(()=>{this.audioDevice.stop(),this.storageAdapter.setPlaying(!1)}),this.masterClock.onTick(async o=>{let s=++this.seekGeneration,i=Gt(o,this.fps);i>=this.totalFrames&&this.masterClock.pause(),this.discoverThrough(i),await this.loadFrame(i),this.isCurrent(s)&&(this.audioDevice.syncTo(o),this.renderAt(i),this.assetManager.prefetch(i),this.trimAround(i))}),this.startBackgroundPrecomp()}startBackgroundPrecomp(){this.precompRunning||this.disposed||this.precomp.complete||(this.precompRunning=!0,(async()=>{try{for(await bi();!this.disposed&&!this.precomp.complete;){let e=await this.precomper.runAsync({budgetMs:this.precompBudgetMs,isCancelled:()=>this.disposed,onProgress:r=>this.adoptPrecomp(r)});if(this.disposed)return;this.precomp.complete||this.adoptPrecomp(e)}}finally{this.precompRunning=!1}})())}adoptPrecomp(e){this.disposed||(this.precomp=e,this.assetManager.setPrecomp(e),this.masterClock.setDuration(this.totalDuration),this.onPrecompProgress?.(e))}discoverThrough(e){let r=this.precomper.ensureCovering(Math.floor(e));r!==this.precomp&&this.adoptPrecomp(r)}async loadFrame(e){let r=[];for(let n of xr(this.store.spans,Math.floor(e)))for(let o of this.store.layoutGates(n.id))this.assetManager.isReady(o.src)||r.push(o);if(r.length===0){await this.assetManager.loadAt(e);return}await Promise.all([this.assetManager.loadAt(e),this.assetManager.loadRecords(r)])}trimAround(e){Math.abs(e-this.lastTrimFrame)<this.fps||(this.lastTrimFrame=e,this.store.trim(Math.floor(e),Math.ceil(Nw*this.fps)))}lastTrimFrame=0;get isPlaying(){return this.masterClock.isPlaying}get currentTime(){return this.masterClock.currentTime}get currentFrame(){return Gt(this.masterClock.currentTime,this.fps)}onTime(e){this.masterClock.onTime(e)}onPlay(e){this.masterClock.onPlay(()=>e())}onPause(e){this.masterClock.onPause(e)}isCurrent(e){return!this.disposed&&e===this.seekGeneration}renderAt(e){if(!this.disposed){this.hasPainted=!0,this.renders++;try{this.store.settleGates(xr(this.store.spans,Math.floor(e)).map(r=>r.id)),this.stateEvaluator.stateAt(e),this.applyOverrides(),this.stateEvaluator.layout(this.measurer),this.renderContext.execute(()=>{this.stateEvaluator.render(this.renderContext)})}catch(r){this.captureRenderError(r,e)}this.announcePaint(e)}}announcePaint(e){if(this.onFramePainted)try{this.onFramePainted(Math.floor(e))}catch(r){console.error("[PlaybackController] onFramePainted listener threw:",r)}}async seek(e){if(this.disposed)return;let r=++this.seekGeneration;this.paintInFlight=r;try{let n=Math.max(0,Math.min(e,this.totalFrames));if(this.masterClock.pause(),this.discoverThrough(n),this.masterClock.seek(Hr(n,this.fps)),await this.loadFrame(n),!this.isCurrent(r)||await this.settle(()=>this.renderAt(n),r)==="superseded")return;this.assetManager.prefetch(n),this.trimAround(n)}finally{this.paintLanded(r)}}setProject(e){if(this.disposed)return;let r=++this.seekGeneration;this.precomper.setProject(e),this.stateEvaluator.setProject(e),this.discoverThrough(this.currentFrame),this.clearRenderErrors(),this.masterClock.setDuration(this.totalDuration);let n=Math.min(this.currentFrame,Math.max(0,this.totalFrames-1));this.pendingSwap=r,this.paintInFlight=r,this.lastReplacePaint=this.loadAndRepaint(n,r),this.startBackgroundPrecomp()}reconcileCatalog(){this.disposed||(this.store.reset(),this.setProject(this.store.project))}whenReplaced(){return this.lastReplacePaint}lastReplacePaint=Promise.resolve();pendingSwap=0;async loadAndRepaint(e,r){try{try{await this.loadFrame(e)}catch(n){console.error("[PlaybackController] swap asset load failed:",n);return}await this.settle(()=>this.renderAt(e),r)}finally{this.pendingSwap===r&&(this.pendingSwap=0),this.paintLanded(r)}}seekWhilePlaying(e){++this.seekGeneration;let r=Math.max(0,Math.min(e,this.totalFrames));this.masterClock.seek(Hr(r,this.fps))}async screenshot(){let e=this.stateEvaluator.currentFrame,r=++this.seekGeneration;this.paintInFlight=r;try{return await this.loadFrame(e),!this.isCurrent(r)||await this.settle(()=>this.renderAt(e),r,!0)==="superseded"?void 0:this.renderContext.screenshot()}finally{this.paintLanded(r)}}async settle(e,r,n=!1){let o=n?$w(this.storageAdapter):this.storageAdapter,s=await am(e,o,()=>this.isCurrent(r));return s==="exhausted"&&console.warn(`[PlaybackController] frame ${this.stateEvaluator.currentFrame} still had decodes pending after ${4} passes`),s}paintInFlight=0;renders=0;repaintOwedSince=null;paintLanded(e){if(!(this.paintInFlight!==e||this.disposed)){if(this.paintInFlight=0,this.repaintOwedSince!==null){let r=this.renders===this.repaintOwedSince;this.repaintOwedSince=null,r&&!this.isPlaying&&this.renderAt(this.stateEvaluator.currentFrame)}this.settleTrailing()}}getTreeState(){let e=this.stateEvaluator.currentInstance;if(!e)return null;let r=this.precomp.tracks.find(l=>l.id===this.stateEvaluator.currentTrackId),n=r?.startFrame??0,o=r?.frameCount??On(e.duration,this.fps),s=new Map,i=new Map;e.forEachOwner((l,c,d,u)=>{i.set(c,u);let f=En(d,this.fps,o);f&&s.set(u,{startFrame:n+f.startFrame,endFrame:n+f.endFrame})});let a=Bw(r?.audioRequests??[],i);return $m(e.canvas,"",s,a)}getNodeState(e){let r=this.stateEvaluator.currentCanvas;if(!r)return null;let n=jm(r,e);return n?{id:n.id,type:n.className,properties:n.properties}:null}getNodeInitialProps(e){return this.stateEvaluator.currentInstance?.baselineProps(e)??null}getNodeBox(e){let r=this.stateEvaluator.currentCanvas;return r?Em(r,e):null}getNodePropsAt(e){let r=this.stateEvaluator.currentCanvas;if(!r)return null;let n=wr(r,e);return n?n.properties:null}getNodeBoxes(){let e=this.stateEvaluator.currentCanvas;if(!e)return[];let r=[];return fc(e,"",r,!0),r}projectNode3D(e,r,n){let o=this.stateEvaluator.currentCanvas;return o?Pm(o,e,r,n):null}parentPlanePoint(e,r){let n=this.stateEvaluator.currentCanvas;return n?vm(n,e,r):null}childPlanePoint(e,r){let n=this.stateEvaluator.currentCanvas;return n?Sm(n,e,r):null}reparentPlacement(e,r,n){let o=this.stateEvaluator.currentCanvas;return o?bm(o,e,r,n):null}nodeHandles(e){let r=this.stateEvaluator.currentCanvas;return r?km(r,e):null}handleValue(e,r,n){let o=this.stateEvaluator.currentCanvas;return o?Am(o,e,r,n):null}getTextLayout(e){let r=this.stateEvaluator.currentCanvas;if(!r)return null;let n=Nm(r,e);return n instanceof A?this.textLayoutOf(n,e):null}textLayoutOf(e,r){let n=Wh(this.measurer);return n?zm(e,r,n):null}pickNode(e,r=0){let n=this.stateEvaluator.currentCanvas;return n?Tm(n,e,r):null}setNodeOverride(e,r){let n=this.overrides.get(e);this.overrides.set(e,n?{...n,...r}:{...r}),this.applyOverrides()}clearNodeOverrides(e){(e===void 0?this.overrides.size>0&&(this.overrides.clear(),!0):this.overrides.delete(e))&&(this.stateEvaluator.rebuild(),this.repaint())}setEditorStates(e,r){this.stateEvaluator.setEditorStates(e,r),this.repaint()}repaint(){this.hasPainted&&(this.pendingSwap!==0&&this.isCurrent(this.pendingSwap)||(this.renderAt(this.stateEvaluator.currentFrame),this.settleTrailing()))}settleTrailing(){this.trailingSettle||this.disposed||this.isPlaying||!this.hasBackgroundDecodes()||this.repaintBehindDecodes().catch(e=>{console.error("[PlaybackController] background decode failed:",e)})}trailingSettle=!1;hasBackgroundDecodes(){return this.storageAdapter.hasPendingDecodes()||this.storageAdapter.hasPendingUpgrades()}async repaintBehindDecodes(){this.trailingSettle=!0;try{for(let e=0;e<4&&this.hasBackgroundDecodes();e++){let[r,n]=await Promise.all([this.storageAdapter.warmPendingDecodes(),this.storageAdapter.warmPendingUpgrades()]);if(!(r||n)||this.disposed||this.isPlaying)return;if(this.paintInFlight!==0){this.repaintOwedSince=this.renders;return}this.renderAt(this.stateEvaluator.currentFrame)}}finally{this.trailingSettle=!1}}applyOverrides(){if(this.overrides.size===0)return;let e=this.stateEvaluator.currentCanvas;if(e)for(let[r,n]of this.overrides)Nm(e,r)?.set(n)}play(e=1,r=!1){if(this.currentFrame>=this.totalFrames){this.seek(0).then(()=>this.masterClock.play(e,r)).catch(()=>{});return}this.masterClock.play(e,r)}pause(){this.masterClock.pause()}setMuted(e){this.audioDevice.setMuted(e)}dispose(){this.disposed=!0,this.masterClock.dispose(),this.audioDevice.dispose(),this.stateEvaluator.dispose(),this.store.dispose(),this.assetManager.dispose()}},Nw=30;function $w(t){return{async warmPendingDecodes(){let[e,r]=await Promise.all([t.warmPendingDecodes(),t.warmPendingUpgrades()]);return e||r}}}function jw(t,e){switch(t.assetType){case"image":return{type:"image",src:t.src};case"font":return{type:"font",family:t.src,weight:400};case"video":try{return{type:"video",src:t.src,trimStart:0,trimEnd:e.getVideoDuration(t.src)}}catch{return}default:return}}function V2(t){return t.children.length>0}function $m(t,e,r,n){let o={id:t.id,path:e,type:t.className,children:t._allChildren.map((a,l)=>$m(a,zt(e,l),r,n))},s=n.get(e);s&&s.length>0&&(o.waveform=s);let i=r.get(e);return i&&(o.startFrame=i.startFrame,o.endFrame=i.endFrame),o}function Bw(t,e){let r=new Map;for(let n of t){let o=n.ownerId!==void 0?e.get(n.ownerId):"";if(o===void 0)continue;let s={src:n.src,startTime:n.startAt,endTime:Number.isFinite(n.endAt)?n.endAt:null},i=r.get(o);i?i.push(s):r.set(o,[s])}return r}function Nm(t,e){if(e==="")return t;let r=t;for(let n of e.split(".")){let o=r._allChildren[Number(n)];if(!o)return null;r=o}return r}function jm(t,e){if(t.id===e)return t;for(let r of t._allChildren){let n=jm(r,e);if(n)return n}return null}var zi=class{manifest;constructor(e){this.manifest=e}reconcile(e){this.manifest=e}normalizeKey(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}getImageMeta(e){let r=this.manifest.image[this.normalizeKey(e)];if(!r)throw new Error(`Image asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`);return r}getVideoMeta(e){let r=this.manifest.video[this.normalizeKey(e)];if(!r)throw new Error(`Video asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`);return r}getAudioMeta(e){let r=this.manifest.audio[this.normalizeKey(e)];if(!r)throw new Error(`No audio metadata for src: ${e}`);return r}getFontMeta(e){let r=this.manifest.font[e];if(!r)throw new Error(`No font metadata for key: ${e}`);return r}getFontFamilyMetas(e){return Object.values(this.manifest.font).filter(r=>r.fontFamily===e)}getVideoDuration(e){return this.getVideoMeta(e).duration}getAudioDuration(e){return this.getAudioMeta(e).duration}getMediaDuration(e){let r=this.normalizeKey(e),n=this.manifest.audio[r];if(n)return n.duration;let o=this.manifest.video[r];if(o)return o.duration;throw new Error(`Audio asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`)}getImageSize(e){let{width:r,height:n}=this.getImageMeta(e);return{width:r,height:n}}};var Ni=class{controller;constructor(e){this.controller=e}get isPlaying(){return this.controller.isPlaying}get frame(){return this.controller.currentFrame}play(e=1,r=!1){this.controller.play(e,r)}pause(){this.controller.pause()}seekFrame(e){this.controller.seekWhilePlaying(e)}setMuted(e){this.controller.setMuted(e)}onTime(e){this.controller.onTime(e)}onPlay(e){this.controller.onPlay(e)}onPause(e){this.controller.onPause(e)}};var $i=class{_isPlaying=!1;_currentTime=0;_duration=0;get isPlaying(){return this._isPlaying}get currentTime(){return this._currentTime}get duration(){return this._duration}setDuration(e){this._duration=e}setCurrentTime(e,r=!0){if(this._currentTime!==e&&(this._currentTime=e,!!r))for(let n of this.timeCallbacks)n(e)}setPlaying(e){this._isPlaying=e}play(e,r){this._isPlaying=!0;for(let n of this.playCallbacks)n(this._currentTime,e,r)}async tick(){await Promise.all(this.tickCallbacks.map(e=>e(this._currentTime)))}pause(){this._isPlaying=!1;for(let e of this.pauseCallbacks)e()}tickCallbacks=[];playCallbacks=[];pauseCallbacks=[];timeCallbacks=[];dispose(){this.tickCallbacks.length=0,this.playCallbacks.length=0,this.pauseCallbacks.length=0,this.timeCallbacks.length=0}onTick(e){this.tickCallbacks.push(e)}onPlay(e){this.playCallbacks.push(e)}onPause(e){this.pauseCallbacks.push(e)}onTime(e){this.timeCallbacks.push(e)}};var ji=class extends $i{seek(e){this.setCurrentTime(e)}};var Bm=class{engine;viewport;fps;constructor(e,r){this.engine=e,this._override={viewport:r.viewport,fps:r.fps},this._project=Lm(r.document,r,e),this.viewport=this._project.viewport,this.fps=this._project.fps,this._catalog=new zi(e.manifest),this._unsubscribe=e._onManifestChange(a=>{this._catalog.reconcile(a),this._storage.setCatalog(this._catalog),this._controller.reconcileCatalog()});let n={catalog:this._catalog,viewport:this.viewport,fps:this.fps};this._storage=e.platform.createStorageAdapter(n),this._renderContext=e.platform.createRenderContext(this._storage);let o=e.platform.createMeasureContext(this._storage),s=e.platform.createAudioSink(),i=e.platform.createTicker(this.fps,s);this.applyGlobals(),r.target!==void 0&&this._renderContext.mount(r.target),this._controller=new Ii({project:this._project,registry:e._registry,renderContext:this._renderContext,measurer:o,storageAdapter:this._storage,masterClock:i??new ji,audioDevice:s,assets:this._catalog,onPrecompProgress:r.onPrecompProgress}),this._playback=i===null?null:new Ni(this._controller)}get document(){return this._project}get playback(){return this._playback}get controller(){return this._controller}get surface(){return this._renderContext}get duration(){return this._controller.totalDuration}get totalFrames(){return this._controller.totalFrames}async seek(e){await this.seekFrame(Math.round(Gt(e,this.fps)))}async seekFrame(e){this.applyGlobals(),await this._controller.seek(e)}replace(e){let r=Lm(e,this._override,this);if(r.fps!==this.fps||r.viewport.width!==this.viewport.width||r.viewport.height!==this.viewport.height)throw new Error(`Cannot replace a ${this.viewport.width}\xD7${this.viewport.height} @ ${this.fps}fps document with a ${r.viewport.width}\xD7${r.viewport.height} @ ${r.fps}fps one \u2014 open a new session.`);this._project=r,this.applyGlobals(),this._controller.setProject(r)}image(e={}){return this.applyGlobals(),this.engine.exporter.exportStill({...e,frame:e.frame??{kind:"last"},project:this._project,registry:this.engine._registry,manifest:e.manifest??this.engine.manifest})}export(e={}){return this.applyGlobals(),this.engine.exporter.exportVideo({...e,project:this._project,registry:this.engine._registry,manifest:e.manifest??this.engine.manifest})}dispose(){this._unsubscribe(),this._controller.dispose(),this._renderContext.dispose()}applyGlobals(){Vi(this._project.theme)}_override;_project;_catalog;_storage;_renderContext;_controller;_playback;_unsubscribe};function Lm(t,e,r){let n=Np(t),o={...n,viewport:e.viewport??n.viewport??r.viewport,fps:e.fps??n.fps??r.fps};return oh(o),o}function ij(t,e={}){let r=e.delimiter??",",n=qw(t,r);if(n.length===0)return[];let o=n[0].map(c=>c.trim()),i=n.slice(1).map(c=>{let d={};return o.forEach((u,f)=>{d[u]=c[f]??""}),d}),a=Lw(o,i,e.numeric),l=Ww(o,i,a,e.boolean);return a.length===0&&l.length===0?i:i.map(c=>{let d={...c};for(let u of a){let f=c[u];f!==""&&(d[u]=Number(f))}for(let u of l){let f=c[u];f!==""&&(d[u]=f==="true")}return d})}function aj(t,e){throw new Error(`parseData("${t}") must be called with a static string literal so the @motionscript/vite-plugin macro can inline it at build time. If you're seeing this error at runtime, either the plugin isn't installed/registered, or this call's argument isn't a plain string literal.`)}function Lw(t,e,r){return r===!1?[]:Array.isArray(r)?r:t.filter(n=>{let o=!1;for(let s of e){let i=s[n];if(i!==""){if(!Number.isFinite(Number(i)))return!1;o=!0}}return o})}function Ww(t,e,r,n){if(n===!1)return[];if(Array.isArray(n))return n;let o=new Set(r);return t.filter(s=>{if(o.has(s))return!1;let i=!1;for(let a of e){let l=a[s];if(l!==""){if(l!=="true"&&l!=="false")return!1;i=!0}}return i})}function qw(t,e){let r=[],n=[],o="",s=!1,i=!1,a=()=>{n.push(o),o=""},l=()=>{a(),r.push(n),n=[],i=!1};for(let c=0;c<t.length;c++){let d=t[c];if(s){d==='"'?t[c+1]==='"'?(o+='"',c++):s=!1:o+=d;continue}if(d==='"'){s=!0,i=!0;continue}if(d===e){i=!0,a();continue}if(d!=="\r"){if(d===`
17
- `){(i||o)&&l();continue}o+=d,i=!0}}return(i||o)&&l(),r}var cj=(t,e)=>{let r=new Array(t);for(let n=0;n<t;n++)r[n]=e(n);return r};function uj(){let t=null;function e(r){if(r!==void 0)t=r;else{if(t===null)throw new Error("Reference not assigned yet");return t}}return e}var Bi=class{state=0;constructor(e){this.setSeed(e)}setSeed(e){this.state=typeof e=="string"?e.split("").reduce((r,n)=>(r=(r<<5)-r+n.charCodeAt(0),r&r),0):e}next(){this.state|=0,this.state=this.state+1831565813|0;var e=Math.imul(this.state^this.state>>>15,1|this.state);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}},Wm=4294967296,pc=class t{_seed;numericSeed;gen;spareGauss=null;constructor(e){this.gen=new Bi(e),this.adopt(e)}get seed(){return this._seed}set seed(e){this.adopt(e)}static toNumeric(e){return typeof e=="string"?e.split("").reduce((r,n)=>(r<<5)-r+n.charCodeAt(0),0):e}adopt(e){this._seed=e,this.numericSeed=t.toNumeric(e),this.gen.setSeed(e),this.spareGauss=null}nextFloat(e=0,r=1){return this.gen.next()*(r-e)+e}nextInt(e=0,r=Wm){return Math.floor(this.gen.next()*(r-e))+e}floatArray(e,r=0,n=1){let o=new Array(e);for(let s=0;s<e;s++)o[s]=this.nextFloat(r,n);return o}intArray(e,r=0,n=Wm){let o=new Array(e);for(let s=0;s<e;s++)o[s]=this.nextInt(r,n);return o}gauss(e=0,r=1){if(this.spareGauss!==null){let a=this.spareGauss;return this.spareGauss=null,e+r*a}let n,o,s;do n=this.gen.next()*2-1,o=this.gen.next()*2-1,s=n*n+o*o;while(s>=1||s===0);let i=Math.sqrt(-2*Math.log(s)/s);return this.spareGauss=o*i,e+r*(n*i)}noise(e,r=1){let n=e*r,o=Math.floor(n),s=n-o,i=s*s*(3-2*s),a=this.latticeValue(o),l=this.latticeValue(o+1);return a+(l-a)*i}reset(e=this._seed){this.adopt(e)}latticeValue(e){let r=Math.sin(e+this.numericSeed)*1e4;return r-Math.floor(r)}};export{Rn as a,Fn as b,In as c,vr as d,zo as e,Sr as f,Ur as g,Dt as h,U as i,ke as j,No as k,R as l,zn as m,Z as n,jo as o,Dc as p,Km as q,Ze as r,Ic as s,zc as t,Nn as u,$n as v,Um as w,Xm as x,Zm as y,Jm as z,Bn as A,Ln as B,Go as C,z as D,py as E,Ki as F,Zr as G,Md as H,Hi as I,Ui as J,Xi as K,hy as L,yy as M,Jr as N,Zi as O,Qr as P,Ed as Q,vy as R,Sy as S,jd as T,by as U,Wn as V,en as W,Ko as X,Ld as Y,Wd as Z,ky as _,Ay as $,Vn as aa,Q as ba,Re as ca,My as da,Je as ea,B as fa,Gn as ga,Hd as ha,tn as ia,Ty as ja,oa as ka,rn as la,nn as ma,sa as na,on as oa,Fe as pa,Yn as qa,Kn as ra,Ve as sa,ia as ta,By as ua,Ly as va,Wy as wa,la as xa,ca as ya,qy as za,iu as Aa,au as Ba,Hn as Ca,Ht as Da,Ou as Ea,os as Fa,q as Ga,Eu as Ha,mt as Ia,Cu as Ja,Pu as Ka,Tu as La,ma as Ma,ha as Na,Du as Oa,Ru as Pa,_e as Qa,Nu as Ra,is as Sa,$u as Ta,ju as Ua,Bu as Va,Xt as Wa,dg as Xa,ug as Ya,fg as Za,pg as _a,Zt as $a,wa as ab,le as bb,va as cb,pe as db,Sa as eb,hg as fb,Un as gb,ln as hb,yt as ib,ka as jb,Xn as kb,Aa as lb,ls as mb,cs as nb,Ar as ob,Ma as pb,Zn as qb,we as rb,ee as sb,Ie as tb,Oa as ub,Uu as vb,Mr as wb,us as xb,Ea as yb,Ca as zb,cn as Ab,Sg as Bb,ms as Cb,ce as Db,ys as Eb,gs as Fb,Jt as Gb,oe as Hb,Qt as Ib,p as Jb,Ge as Kb,de as Lb,dn as Mb,_s as Nb,Mf as Ob,ws as Pb,Of as Qb,Ef as Rb,Cf as Sb,ja as Tb,Ba as Ub,er as Vb,La as Wb,Wa as Xb,qa as Yb,Ye as Zb,eo as _b,to as $b,ro as ac,no as bc,Rt as cc,Gg as dc,Yg as ec,Va as fc,hE as gc,Df as hc,Rf as ic,Ff as jc,Ke as kc,ks as lc,jE as mc,If as nc,io as oc,Pr as pc,WE as qc,Tr as rc,Ms as sc,P as tc,he as uc,un as vc,se as wc,A as xc,lx as yc,rp as zc,Ae as Ac,Is as Bc,cx as Cc,et as Dc,tt as Ec,QC as Fc,np as Gc,op as Hc,sp as Ic,ip as Jc,ap as Kc,Qa as Lc,up as Mc,fp as Nc,pp as Oc,hp as Pc,el as Qc,mp as Rc,me as Sc,zt as Tc,Ns as Uc,$s as Vc,nl as Wc,Pe as Xc,Bs as Yc,ol as Zc,sl as _c,_p as $c,K as ad,H as bd,He as cd,Me as dd,Ws as ed,qs as fd,hn as gd,Vs as hd,cl as id,dl as jd,Sp as kd,Fr as ld,ze as md,Gs as nd,wt as od,Ir as pd,pl as qd,zr as rd,sr as sd,vt as td,kp as ud,Ap as vd,Mp as wd,Op as xd,Ep as yd,Ks as zd,uo as Ad,Us as Bd,nt as Cd,_x as Dd,ye as Ed,Ue as Fd,st as Gd,dt as Hd,fo as Id,te as Jd,yn as Kd,St as Ld,gl as Md,I as Nd,Xs as Od,F as Pd,jt as Qd,bt as Rd,$r as Sd,kt as Td,At as Ud,Bt as Vd,ir as Wd,ar as Xd,Lt as Yd,jr as Zd,Br as _d,lr as $d,cr as ae,dr as be,gn as ce,Zs as de,ut as ee,Wr as fe,ur as ge,Js as he,_n as ie,qr as je,Vr as ke,fr as le,ft as me,pr as ne,Dp as oe,xl as pe,Oe as qe,hr as re,Mt as se,j as te,Qs as ue,AI as ve,mr as we,t0 as xe,O as ye,$e as ze,MI as Ae,zp as Be,ei as Ce,OI as De,r0 as Ee,Et as Fe,n0 as Ge,Np as He,ae as Ie,xe as Je,c0 as Ke,d0 as Le,ni as Me,Gp as Ne,Al as Oe,k0 as Pe,oh as Qe,JI as Re,Ml as Se,e3 as Te,Ol as Ue,si as Ve,K3 as We,P0 as Xe,T0 as Ye,D0 as Ze,X3 as _e,ai as $e,kn as af,pi as bf,Rz as cf,f_ as df,Fz as ef,Nz as ff,jz as gf,Wz as hf,qz as if,xo as jf,Wl as kf,ql as lf,w_ as mf,v_ as nf,S_ as of,b_ as pf,A_ as qf,Vh as rf,P_ as sf,T_ as tf,Kl as uf,D_ as vf,R_ as wf,yi as xf,Ct as yf,gi as zf,Pt as Af,Gh as Bf,_o as Cf,wo as Df,vo as Ef,Yh as Ff,xi as Gf,Hl as Hf,Be as If,So as Jf,_i as Kf,Mn as Lf,wi as Mf,W_ as Nf,q_ as Of,vi as Pf,Si as Qf,Vt as Rf,bi as Sf,i$ as Tf,Hr as Uf,Gt as Vf,l$ as Wf,On as Xf,bo as Yf,Uh as Zf,xr as _f,lt as $f,En as ag,ki as bg,To as cg,_r as dg,Pi as eg,nc as fg,am as gg,s2 as hg,Di as ig,lc as jg,hm as kg,mm as lg,ct as mg,vm as ng,Sm as og,bm as pg,km as qg,Am as rg,Fo as sg,Em as tg,wr as ug,Pm as vg,Tm as wg,fc as xg,zm as yg,O2 as zg,E2 as Ag,Ii as Bg,V2 as Cg,zi as Dg,Ni as Eg,$i as Fg,ji as Gg,Bm as Hg,Lm as Ig,ij as Jg,aj as Kg,cj as Lg,uj as Mg,Bi as Ng,pc as Og};
18
- //# sourceMappingURL=chunk-FUZVFT3W.js.map