@motionscript/core 0.1.1-alpha.3 → 0.1.1-alpha.5
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.
- package/CHANGELOG.md +12 -0
- package/dist/browser/chunks/{chunk-TL432UO5.js → chunk-FPYU47XX.js} +2 -2
- package/dist/browser/chunks/{chunk-BPA7KSK2.js → chunk-XCGYJHZR.js} +1 -1
- package/dist/browser/chunks/{chunk-BPA7KSK2.js.map → chunk-XCGYJHZR.js.map} +1 -1
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/browser/sdk.js.map +4 -4
- package/dist/components/modules/paint3d.d.ts +84 -0
- package/dist/components/modules/paint3d.d.ts.map +1 -0
- package/dist/components/modules/paint3d.js +182 -0
- package/dist/components/modules/paint3d.js.map +1 -0
- package/dist/render3d/texture.d.ts +1 -1
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +2 -0
- package/dist/sdk/index.js.map +1 -1
- package/package.json +1 -1
- /package/dist/browser/chunks/{chunk-TL432UO5.js.map → chunk-FPYU47XX.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @motionscript/core
|
|
2
2
|
|
|
3
|
+
## 0.1.1-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0b752d6: - **A 3D texture's `anisotropy` is drawn**: above 1 the sampler filters anisotropically, rounded up to 4x, 8x or 16x (the most WebGPU allows), so a texture seen at a glancing angle stays sharp instead of blurring. It needs linear filters; a `nearest` texture ignores it. It was accepted and never applied before.
|
|
8
|
+
|
|
9
|
+
## 0.1.1-alpha.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 420d5d0: **`Paint3D`**: a custom 3D node paints with the same `fill` and `stroke` entries a 2D shape takes. Spread `...Paint3D.state` and `...Paint3D.commands` (`fillTo`, `strokeTo`), then draw the surface with `Paint3D.material(fill)` (one solid colour stays a tweenable `color` and `opacity`; a gradient or image becomes a texture; `{ type: "standard" }` lights it) and the lines with `Paint3D.lines(g3, stroke, segments, { through, lift })`, one instanced batch of bars per stroke layer. Stroke `weight`, `dash` and `dashOffset` are thousandths of a scene unit; a `square` cap closes outline corners; `through: true` draws hidden lines through solids. Built-in meshes keep `Material.state`.
|
|
14
|
+
|
|
3
15
|
## 0.1.1-alpha.3
|
|
4
16
|
|
|
5
17
|
## 0.1.1-alpha.2
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$b as Gt,$d as Po,Ac as gs,Ae as en,Bb as ls,Bc as ke,Be as Go,Cb as he,Cc as je,Cd as I,Ce as Yo,Db as j,Dc as ho,Dd as As,De as Wo,Eb as de,Ed as Zt,F as Xr,Fa as Ut,Fb as fs,Fc as Z,Fd as Ao,Fe as mt,Ga as Zr,Gc as ys,Gd as Mo,Ge as P,Hb as hs,He as w,Ie as tn,Ja as os,Jd as Oo,Je as me,Ka as ve,Kd as T,Ke as nn,Lb as ct,Ld as k,Le as Xo,Mb as ps,Md as Se,Me as ge,Nb as so,Nc as _s,Nd as Be,Ne as qo,Oe as sn,Pc as ws,Pd as B,Pe as Ho,Qc as po,Qd as K,Qe as Jo,Rc as mo,Rd as z,Sc as go,Se as Zo,Tc as xs,Td as To,Te as Qo,Ua as as,Uc as Xt,Ud as F,Ue as ei,Vb as dt,Vc as yo,Vd as $,Ve as ti,Wa as ot,Wb as ro,Wc as qt,Wd as Q,X as ss,Xb as ne,Xc as vs,Xd as E,Yb as oo,Yc as _o,Zb as ut,Zc as R,Zd as Eo,_b as Le,_d as Co,aa as rs,ac as be,ad as ht,ae as Qt,bc as Ce,bd as bs,be as Io,cb as cs,cc as pe,cd as ks,ce as Do,dc as lt,dd as Ss,de as Ms,ea as qr,eb as ds,ec as ft,f as Qn,fa as Hr,fb as it,fd as wo,fe as Fo,ga as rt,gc as io,gd as xo,ge as $o,hc as ao,he as No,id as Ht,jd as Jt,kb as at,kc as co,lc as Yt,m as ns,md as ko,me as Os,nb as Qr,nd as So,ne as Ts,oa as Jr,ob as Y,oc as Pe,oe as Es,pb as eo,pc as uo,pe as Lo,qe as jo,ra as fe,re as Bo,sb as to,se as Vo,tb as no,vc as lo,ve as Cs,wb as Ee,wc as fo,we as Ps,xc as ms,xe as Ko,yc as Wt,ye as pt,zb as us,ze as Uo}from"./chunk-BPA7KSK2.js";import{b as Ro,f as zo}from"./chunk-GEJEQQER.js";import{b as Wr,d as es,f as ts,h as ze,m as is,n as vo,o as bo}from"./chunk-5TDMGUXQ.js";function ni(n){return Number.isFinite(n)&&n>0?n:1}function Ve(n,e,t=e){return at(n)?to(n,e,t):Math.max(0,Math.min(t,e))/ni(n)}function Sd(n,e,t){return at(n)?no(n,e,t):Math.max(0,Math.min(e,t*ni(n)))}function Ad(n,e){let t=Math.max(0,(n.trimEnd??e)-(n.trimStart??0));return Ve(n.speed??1,t)}function si(n,e,t,s){let r=n.at??0,o=n.until??1/0,i=n.trimStart??0,a=n.trimEnd??1/0,c=n.loop??!1,d=Ee(n.effects),u=e.getMediaDuration(n.src),l=n.speed??1;c&&at(l)&&(l=Qr(l,1));let f=Math.max(0,(Number.isFinite(a)?a:u)-i),h={id:`${t}|${n.src}|${r}|${s}`,src:n.src,startAt:r,endAt:1/0,trimStart:i,volume:n.volume??1,speed:l,loop:c,ownerId:t};if(at(l)&&(h.sourceLength=f),d.length>0&&(h.effects=d),n.transitionIn&&(h.transitionIn=n.transitionIn),n.transitionOut&&(h.transitionOut=n.transitionOut),n.bus&&(h.bus=n.bus),n.optional&&(h.optional=!0),c&&a>i&&Number.isFinite(a)&&(h.trimEnd=a),c&&Number.isFinite(o))h.endAt=o;else if(c)h.open=!0;else if(Number.isFinite(a))h.endAt=Math.min(o,r+Ve(l,f));else{let p=Ve(l,f);Number.isFinite(o)?h.endAt=Math.min(o,r+p):(h.open=!0,h.mediaDuration=p)}return h}var Is=class{src;volume;speed;loop;trimStart;trimEnd;effects;constructor(e){this.src=e.src,this.volume=e.volume??1,this.speed=e.speed??1,this.loop=e.loop??!1,this.trimStart=e.trimStart??0,this.trimEnd=e.trimEnd??e.duration??1/0,this.effects=Ee(e.effects)}clipDurationFor(e){return Ve(this.speed,e)}get clipDuration(){return this.trimEnd!==1/0?this.clipDurationFor(this.trimEnd-this.trimStart):void 0}};function gt(n){return!n||n.length===0?"":n.map(e=>{switch(e.type){case"gain":return`gain:${Y(e.value)}`;case"highpass":case"lowpass":return`${e.type}:${Y(e.frequency)}:${Y(e.q)}`;case"tremolo":return`tremolo:${Y(e.rate)}:${Y(e.depth)}`;case"echo":return`echo:${Y(e.delay)}:${Y(e.feedback)}:${Y(e.mix)}`}}).join("|")}var Md=n=>Math.sin(Math.max(0,Math.min(1,n))*Math.PI/2),ri=new WeakMap;function oi(n){let e=n.curve;if(e===void 0||e==="equalPower")return Md;let t=ri.get(e);return t||ri.set(e,t=it(e)),t}function Od(n,e,t){let s={in:Math.max(0,e?.duration??0),out:Math.max(0,t?.duration??0)};if(!Number.isFinite(n))return{in:s.in,out:0};let r=s.in+s.out;if(r<=n||r===0)return s;let o=Math.max(0,n)/r;return{in:s.in*o,out:s.out*o}}function Lp(n,e,t,s){let r=Od(e,t,s),o=1;return t&&r.in>0&&n<r.in&&(o*=Math.max(0,oi(t)(Math.max(0,n)/r.in))),s&&r.out>0&&n>e-r.out&&(o*=Math.max(0,oi(s)(Math.max(0,e-n)/r.out))),o}function Ke(n){return n?`${n.duration}:${typeof n.curve=="object"?JSON.stringify(n.curve):n.curve??"equalPower"}`:"_"}function Ds(n){return`${n.id}:${Y(n.volume)}:${Y(n.pan)}:${n.mute?1:0}:${gt(n.effects)}:${Ke(n.transitionIn)}:${Ke(n.transitionOut)}:${n.startAt}:${n.endAt}`}var Td=new Set(["number","slider","angle","hue","boolean","color","vector","point"]);function km(n){return Td.has(n.kind)}var ii=64,ai=64e3;function ci(n){if(typeof n!="object"||n===null)throw new Error("A shader pack must be an object.");let e=n,t=e.scope;if(t!=="fill"&&t!=="effect")throw new Error(`A shader pack needs scope "fill" or "effect", got ${JSON.stringify(t)}. 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 s=typeof e.source=="string"?e.source.trim():"";if(s==="")throw new Error(`Shader pack "${String(e.name??"?")}" has no source.`);if(s.length>ai)throw new Error(`Shader pack "${String(e.name??"?")}" source is ${s.length} characters, over the ${ai} ceiling.`);if(e.language!==void 0&&e.language!=="wgsl")throw new Error(`Shader pack "${String(e.name??"?")}" is written in ${JSON.stringify(e.language)}; only WGSL is supported. Port it to WGSL.`);let r={...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}:{},language:"wgsl",source:s,..._t(e.uniforms)?{uniforms:e.uniforms}:{},properties:Ed(e.properties,String(e.name??"?"))};if(t==="fill"){let o=Array.isArray(e.textures)?e.textures.filter(i=>_t(i)&&typeof i.name=="string").map(i=>({name:i.name,...typeof i.description=="string"?{description:i.description}:{}})):[];return{...r,scope:"fill",...o.length?{textures:o}:{}}}return{...r,scope:"effect",...e.backdrop===!0?{backdrop:!0}:{}}}function Ed(n,e){if(!_t(n))return{};let t={},s=new Map;for(let[r,o]of Object.entries(n)){if(Object.keys(t).length>=ii){yt(`shader "${e}" declares more than ${ii} properties; the rest are ignored.`);break}if(!_t(o)||typeof o.kind!="string"){yt(`shader "${e}" property "${r}" has no kind; ignored.`);continue}let i=o.inputs;if(!_t(i)||Object.keys(i).length===0){yt(`shader "${e}" property "${r}" names no uniform in "inputs"; ignored.`);continue}let a=!1;for(let c of Object.values(i)){if(typeof c!="string"){yt(`shader "${e}" property "${r}" has a non-string uniform name; ignored.`),a=!0;break}let d=s.get(c);if(d!==void 0){yt(`shader "${e}" properties "${d}" and "${r}" both write uniform "${c}"; "${r}" ignored.`),a=!0;break}s.set(c,r)}a||(t[r]=o)}return t}function _t(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var rn=new Set;function yt(n){rn.has(n)||(rn.size>256&&rn.clear(),rn.add(n),console.warn(`[shader] ${n}`))}function ye(n,e){return n===""?String(e):`${n}.${e}`}function Fs(n,e){n.declareAssets(e)}function $s(n,e){if(!n.mounted)return;Fs(n,e);let t=n._allChildren;for(let s=0;s<t.length;s++)$s(t[s],e)}function di(n,e){n.attachDetached(e)}function on(n){n._sample();for(let e of n.children)on(e)}function an(n,e){n._primeMotion(e);for(let t of n.children)an(t,e)}function Ns(n,e){let t=s=>{let r=s.key!==void 0?e?.[s.key]:void 0;s._setEditorState(r?.hidden===!0,r?.locked===!0);for(let o of s._allChildren)t(o)};t(n)}var Ie=class extends R{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 t=this.fill,s=ve.resolve(e.data),r=e.lerp??ve.lerp;return this.command(o=>({fill:r(t,s,o)}),e.duration,e.easing)}overlayTo(e){let t=this.overlay,s=ve.resolve(e.data),r=e.lerp??ve.lerp;return this.command(o=>({overlay:r(t,s,o)}),e.duration,e.easing)}flowArrangement(){return this}shapeGraphics(){return new rt().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}renderSelf(e){let t=this.fill;t.length!==0&&e.draw(this.shapeGraphics().fill(t))}renderOverlay(e){let t=this.overlay;t.length!==0&&e.draw(this.shapeGraphics().fill(t))}acceptsChild(e){return e.dimension==="2d"||e.dimension==="audio"}get _childTrees(){return["2d","audio"]}get childrenAudio(){return this._allChildren.filter(e=>e instanceof ht)}declareAssets(e){super.declareAssets(e),e.fill(this.fill),e.fill(this.overlay)}clipSelf(){return new xs().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?hs:super._projection()}renderChildren(e){let t=this._spaceCamera();if(t){this._renderInSpace(e,Xt(this,t));return}if(this.zoom===1&&this.heading===0&&this.lookAt.x===0&&this.lookAt.y===0){super.renderChildren(e);return}let s=this.layoutBounds,r=s?.width??0,o=s?.height??0,i=s?.x??0,a=s?.y??0;e.beginCamera({x:i,y:-a,width:r,height:o},this.lookAt,this.zoom,this.heading);for(let c of this._children)c instanceof R&&c.render(e);e.endCamera()}};ro(Ie,{fill:ws(),overlay:ws(),flow:mo(),gap:ne({default:0}),wrap:ne({default:!1}),crossGap:ne({default:void 0}),columns:ne({default:1}),align:po(),zoom:ne({default:1}),lookAt:ne({default:{x:0,y:0},tween:ct}),heading:ne({default:0}),space3D:ne({default:!1}),orbit:ne({default:0}),elevation:ne({default:0}),dolly:ne({default:0}),zoomTo:ke({args:[{key:"zoom",kind:"number",min:.01,step:.1,unit:"\xD7"}]}),panTo:ke({args:[{key:"lookAt",kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}]}),orbitTo:ke({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",step:1,unit:"\xB0"}]}),dollyTo:ke({args:[{key:"dolly",kind:"number",step:10}]}),headingTo:ke({args:[{key:"heading",kind:"number",step:1,unit:"\xB0"}]}),fillTo:ke(),overlayTo:ke()});var dn={cornerRadius:k.number(0),cornerStyle:k.custom("rounded",{lerp:Qn})},ui=T({key:"rect",state:{...F,...B,...Se},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Be(n.size,e))}),li=T({key:"ellipse",state:{...F,...B,startAngle:k.number(0),sweep:k.number(360),ratio:k.number(0)},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Eo(n.size,e))}),fi=T({key:"polygon",state:{...F,...B,sides:k.number(5),...dn},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Co(n.size,e))}),hi=T({key:"polygram",state:{...F,...B,sides:k.number(5),ratio:k.number(.5),...dn},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Po(n.size,e))}),pi=T({key:"path",state:{...F,...B,data:k.path},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Io(n.size,e.data),{clipShape:Qt(n.size)})}),Sg=T({key:"facePath",state:{...F,...B,data:k.path},defaults:{width:"hug",height:"hug"},commands:{...$},measure:(n,e)=>{let t=is.size(e.data),s=e.padding;return{width:t.width+s.left+s.right,height:t.height+s.top+s.bottom}},layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Do(e.data),{clipShape:null})});function xt(n,e){return T({key:n,state:{...F,...B,...dn},commands:{...$},measure:(t,s,r)=>K(t,s,r,E(s)),layout:(t,s,r)=>z(t,s,r,E(s)),render:(t,s)=>Q(t,s,Ms(e,t.size,s),{clipShape:Qt(t.size)})})}var Ag=xt("triangle","triangle"),Mg=xt("rightTriangle","rightTriangle"),Og=xt("pentagon","pentagon"),Tg=xt("hexagon","hexagon"),Eg=xt("octagon","octagon"),Cg=T({key:"star",state:{...F,...B,...dn,points:k.number(bo),ratio:k.number(vo)},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Ms("star",n.size,{cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle,sides:Math.max(3,Math.round(e.points)),ratio:e.ratio}),{clipShape:Qt(n.size)})});var mi=T({key:"boolean",state:{...F,...B,op:k.oneOf(["union","subtract","intersect","exclude"])},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>n.merge(e.op,e)}),gi=T({key:"mask",state:{mode:k.oneOf(["alpha","vector","luminance"]),inverted:!1},render:(n,e)=>n.mask(e)});var wi=T({key:"camera",state:{...F,...B,...Fo,...Se},commands:{...$,...$o},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Be(n.size,e),{children:()=>No(n,e)})}),yi={lookAt:k.custom({x:0,y:0},{lerp:ct,kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}),zoom:k.number(1,{min:.01,step:.1,unit:"\xD7"}),heading:k.number(0,{step:1,unit:"\xB0"}),orbit:k.number(0,{step:1,unit:"\xB0"}),elevation:k.number(0,{step:1,unit:"\xB0"}),dolly:k.number(0,{step:10}),orbitSpeed:k.number(0)},xi=T({key:"orbitCamera",state:yi,defaults:{width:"hug",height:"hug",perspective:1e3},commands:To(yi,{orbitTo:{args:["orbit","elevation"]},dollyTo:{args:["dolly"]},zoomTo:{args:["zoom"]},panTo:{args:["lookAt"]},headingTo:{args:["heading"]}}),render:(n,e)=>n.space({perspective:e.perspective,orbit:e.orbit+e.orbitSpeed*n.time.total,elevation:e.elevation,dolly:e.dolly,lookAt:e.lookAt,zoom:e.zoom,heading:e.heading,viewportX:0,viewportY:0})}),vi=T({key:"rotated-box",state:{angle:k.number(-90)},defaults:{rotation:n=>n.angle},measure:(n,e,t)=>{let{cos:s,sin:r}=_i(e.angle),{width:o,height:i}=n.max,a=Math.abs(e.angle%180)===90,c=o!==void 0&&i!==void 0?{width:o*s+i*r,height:o*r+i*s}:{width:a?i:o,height:a?o:i},d=0,u=0;for(let l of t){let f=l.measure(c);d=Math.max(d,f.width),u=Math.max(u,f.height)}return{width:d*s+u*r,height:d*r+u*s}},layout:(n,e,t)=>{let{cos:s,sin:r}=_i(e.angle),o={x:0,y:0,width:n.width*s+n.height*r,height:n.width*r+n.height*s};return z(o,e,t)}});function _i(n){let e=n*(Math.PI/180);return{cos:Math.abs(Math.cos(e)),sin:Math.abs(Math.sin(e))}}var{overlay:Hg,...Bs}=F,{overlayTo:Jg,...Vs}=$,js=n=>n.fontSize==="autofit"?"fill":"hug",Cd=[];function Pd(n){return n==null?null:n instanceof Hr?n.toCommands():n}function Id(n){return Array.isArray(n)?n.map(({fill:e,stroke:t,...s})=>({...s,...e===void 0?{}:{fill:ve.resolve(e)},...t===void 0?{}:{stroke:as.resolve(t)}})):[]}var Dd={...Bs,...en,text:k.text("",{typing:!0}),wrap:!1,path:k.custom(null,{resolve:Pd}),runs:k.custom([],{resolve:Id,animatable:!1})},zs=n=>({text:n.text,wraps:n.wrap,glyphPath:n.path,runs:n.runs}),un=T({key:"text",allowedChildren:[],state:Dd,defaults:{width:n=>n.fontSize==="autofit"||n.wrap?"fill":"hug",height:js},commands:{...Vs,append:{args:{text:k.text("",{multiline:!0})},run:(n,e)=>n.tween({text:e.text+n.args.text})},prepend:{args:{text:k.text("",{multiline:!0})},run:(n,e)=>n.tween({text:n.args.text+e.text})}},load:(n,e)=>Es(n,e,zs(e)),measure:(n,e)=>Os(n,e,zs(e)),render:(n,e)=>Ts(n,e,zs(e))}),Fd={...Bs,...en,value:0,format:k.custom("number"),customPattern:"",fractionDigits:0,grouped:!0,currencySymbol:"$"},Ls=n=>({text:Ro(n.value,zo(n)),wraps:!1,glyphPath:null,runs:Cd}),bi=T({key:"number",allowedChildren:[],state:Fd,defaults:{width:js,height:js},commands:{...Vs,countTo:{args:["value"]}},load:(n,e)=>Es(n,e,Ls(e)),measure:(n,e)=>Os(n,e,Ls(e)),render:(n,e)=>Ts(n,e,Ls(e))}),{verticalAlign:Zg,textDecoration:Qg,textCase:ey,minFontSize:ty,...$d}=en,ki=T({key:"richtext",allowedChildren:[],state:{...Bs,...$d,fontSize:k.number(48,{inherit:Uo("fontSize",{autofit:!1})}),spans:k.custom([],{resolve:n=>n==null?[]:Array.isArray(n)?n:[n]})},defaults:{width:"hug",height:"hug"},commands:{...Vs},load:(n,e)=>Vo(n,e),measure:(n,e)=>jo(n,e),render:(n,e)=>Bo(n,e)}),Si=T({key:"default-text-style",state:Go,provide:(n,e)=>Yo(n,e),render:(n,e)=>n.textStyle(Wo(e),()=>n.children())});var Ai=T({key:"provider",state:{context:k.custom(void 0),value:k.custom(void 0)},provide:n=>n.context?[pt(n.context,n.value!==void 0?n.value:n.context.defaultValue)]:[]}),Mi=T({key:"theme-provider",state:{theme:k.custom(void 0),data:k.custom(void 0),seed:k.custom(void 0)},provide:(n,e)=>{let t=[];return n.theme&&t.push(pt(Cs,{...e(Cs),...n.theme})),n.data&&t.push(pt(Ps,{...e(Ps),...n.data})),n.seed!==void 0&&t.push(pt(Ko,n.seed)),t}});var Oi=mt({key:"sound",state:{src:k.custom(void 0),trimStart:0,trimEnd:k.custom(void 0),loop:!1,speed:k.custom(1,{lerp:eo,kind:"audioParam"})},allowedChildren:[],commands:{play:(n,e)=>n.sound(e.src,{trimStart:e.trimStart,trimEnd:e.trimEnd,loop:e.loop,volume:e.volume,speed:e.speed,effects:e.effects,transitionIn:e.transitionIn,transitionOut:e.transitionOut})}}),Ti=mt({key:"audioBus",state:{solo:!1}});var Nd={src:k.custom(void 0),fit:k.custom(void 0),crop:k.insets,zoom:1,anchor:k.alignment,matrix:k.custom(void 0),filters:k.custom([],{resolve:n=>rs(n),lerp:ss}),playing:!0,timestamp:k.custom(void 0),trimStart:k.custom(void 0),trimEnd:k.custom(void 0),speed:k.custom(void 0),loop:k.custom(void 0),duration:k.custom(void 0),volume:1,muted:!1,audioEffects:k.custom([],{resolve:n=>Ee(n)}),bus:k.custom(void 0),segments:k.custom([])};function Rd(n,e){if(n.segments.length===0)return null;let t=0;for(let s of n.segments){if(e<=s.at)break;t+=Math.min(e-s.at,s.duration)*(s.speed??n.speed??1)}return t}function zd(n,e){let t=Rd(n,e);if(t===null)return;let s=n.trimStart??0,r=n.segments[0];return qr(t+(r?r.from-s:0),s,n.trimEnd??1/0,n.loop,n.duration)}var Ks=new WeakMap;function Ld(n,e,t){if(!e.src)return Ks.delete(n),null;let s=zd(e,t),r=e.crop,o=e.anchor,i=[e.src,e.fit??"",e.zoom,e.playing?1:0,r.left,r.right,r.top,r.bottom,o.x,o.y,e.timestamp??"",e.trimStart??"",e.trimEnd??"",e.speed??"",e.loop??"",e.duration??"",s??""].join("|"),a=Ks.get(n);if(a&&a.key===i)return a.fill;let c={type:"video",src:e.src,fit:e.fit,crop:e.crop,zoom:e.zoom,anchor:e.anchor,matrix:e.matrix,preset:{adjustments:e.filters},playing:e.playing,timestamp:e.timestamp??s,trimStart:e.trimStart,trimEnd:e.trimEnd,speed:e.speed,loop:e.loop,duration:e.duration},d=Ut(c);return Ks.set(n,{key:i,fill:d}),d}var Ei=T({key:"video",state:{...F,...B,...Se,...Nd},commands:{...$,play:{args:{from:k.custom(void 0),volume:k.custom(void 0),speed:k.custom(void 0)},run:(n,e)=>{let t=e,s=n.args.from!==void 0;if(!t.src||t.muted||!s&&!t.playing)return n.together([]);let r=n.args.speed??t.speed??1,o=!s&&(t.loop??"none")!=="none";return n.sound(t.src,{volume:n.args.volume??t.volume,loop:o,trimStart:s?n.args.from:t.trimStart,trimEnd:t.trimEnd,speed:r,effects:t.audioEffects,bus:t.bus,optional:!0,closed:!o})}}},load:(n,e)=>{e.src&&n.fill(Ut({type:"video",src:e.src,preset:{adjustments:e.filters},trimStart:e.trimStart,trimEnd:e.trimEnd}))},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>{let t=e,s=Ld(Oo(n).host,t,n.time.elapsed),r={width:n.size.width,height:n.size.height,cornerRadius:t.cornerRadius,cornerStyle:t.cornerStyle,start:t.start,end:t.end};Q(n,e,Be(n.size,e),{fill:[s??Zr,...e.fill],overlay:()=>s?new rt().mask().rect(r).fill([s]).applyMask().rect(r).fill(e.overlay).endMask():null})}});var De={orbit:0,elevation:0,distance:10};function Ci(n){return n.orbit!==void 0||n.elevation!==void 0||n.distance!==void 0}function Us(n){let e=Z(n.target??0);if(!Ci(n)){let i=n.lookAt??n.target;return{position:Z(n.position??0),lookAt:i===void 0?void 0:Z(i)}}let t=n.distance??De.distance,s=(n.orbit??De.orbit)*Math.PI/180,r=jd(n.elevation??De.elevation,-89.9,89.9)*Math.PI/180,o=Math.cos(r)*t;return{position:{x:e.x+Math.sin(s)*o,y:e.y+Math.sin(r)*t,z:e.z+Math.cos(s)*o},lookAt:e}}function jd(n,e,t){return n<e?e:n>t?t:n}var Pi=P({key:"group3d"}),vt={geometry:w(),...qo},Ii=P({key:"mesh3d",state:vt,render:(n,e)=>n.draw(sn(e,e.geometry))}),Fe={startAngle:w(),sweep:w()},$e=["startAngle","sweep"];function ee(n,e,t,s){return P({key:n,state:{...vt,...t},render:(r,o)=>r.draw(sn(o,ge(e,o,s)))})}var Di=ee("box3d","box",{width:w(),height:w(),depth:w(),cornerRadius:w(),segments:w()},["width","height","depth","cornerRadius","segments"]),Fi=ee("sphere3d","sphere",{radius:w(),segments:w(),...Fe,startLatitude:w(),latitudeSweep:w()},["radius","segments","startLatitude","latitudeSweep",...$e]),$i=ee("plane3d","plane",{width:w(),height:w(),segments:w()},["width","height","segments"]),Ni=ee("cylinder3d","cylinder",{radius:w(),height:w(),segments:w(),capped:w(),...Fe},["radius","height","segments","capped",...$e]),Ri=ee("cone3d","cone",{radius:w(),height:w(),segments:w(),capped:w(),...Fe},["radius","height","segments","capped",...$e]),zi=ee("torus3d","torus",{radius:w(),thickness:w(),segments:w(),...Fe},["radius","thickness","segments",...$e]),Li=ee("torus-knot3d","torusKnot",{radius:w(),thickness:w(),segments:w(),windings:w()},["radius","thickness","segments","windings"]),ji=ee("circle3d","circle",{radius:w(),segments:w(),...Fe},["radius","segments",...$e]),Bi=ee("ring3d","ring",{radius:w(),innerRadius:w(),segments:w(),...Fe},["radius","innerRadius","segments",...$e]),Vi=ee("capsule3d","capsule",{radius:w(),height:w(),segments:w()},["radius","height","segments"]),Ki=P({key:"polyhedron3d",state:{...vt,shape:k.custom("icosahedron"),radius:w(),segments:w()},render:(n,e)=>n.draw(sn(e,ge("polyhedron",e,["shape","radius","segments"])))}),Ui=ee("extrude3d","extrude",{path:w(),depth:w(),segments:w(),bevel:w()},["path","depth","segments","bevel"]),Gi=ee("lathe3d","lathe",{points:w(),segments:w(),...Fe},["points","segments",...$e]),Yi=ee("tube3d","tube",{points:w(),radius:w(),segments:w(),closed:w()},["points","radius","segments","closed"]),Wi=P({key:"instances3d",state:{...vt,instances:w(),colors:w()},render:(n,e)=>{!e.geometry||!e.instances?.length||n.draw(new fe().instances(e.geometry,Ho(e),e.instances,{colors:e.colors}))}}),Xi=P({key:"points3d",state:vt,render:(n,e)=>{e.geometry&&n.draw(new fe().points(e.geometry,Jo(e)))}}),qi=P({key:"line3d",state:{points:w(),geometry:w(),closed:k.custom(!1),segments:k.custom(!1),stroke:w(),opacity:w(),material:w()},render:(n,e)=>{!e.geometry&&!e.points?.length||n.draw(new fe().line({points:e.geometry?void 0:e.points,geometry:e.geometry,closed:e.closed,segments:e.segments,stroke:e.stroke,opacity:e.opacity,material:e.material}))}}),Hi=P({key:"sprite3d",state:{fill:k.custom(void 0,{lerp:Jr}),opacity:w(),material:w()},render:(n,e)=>n.draw(new fe().sprite({fill:e.fill,opacity:e.opacity,material:e.material}))}),Ji=P({key:"model3d",state:{src:w(),animation:w(),override:w()},render:(n,e)=>{e.src&&n.draw(new fe().model({src:e.src,animation:e.animation,override:e.override}))}}),Py=P({key:"modelView3d",state:{src:w(),animation:w(),override:w(),clip:"",clipTime:0},render:(n,e)=>{if(!e.src){n.draw(new fe().box({width:1,height:1,depth:1,material:{type:"basic",color:"#6b7280",wireframe:!0,transparent:!0,opacity:.7}}));return}n.draw(new fe().model({src:e.src,animation:{clip:Bd(e.clip),time:e.clipTime},override:e.override}))}});function Bd(n){let e=n.trim();if(e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=0?t:e}var Gs={shadow:!1},Zi=P({key:"ambient-light3d",state:{color:me(),intensity:w()},render:(n,e)=>n.light(ge("ambient",e,["color","intensity"]))}),Qi=P({key:"hemisphere-light3d",state:{sky:me(),ground:me(),intensity:w()},render:(n,e)=>n.light(ge("hemisphere",e,["sky","ground","intensity"]))}),ea=P({key:"directional-light3d",state:{color:me(),intensity:w(),target:nn("origin")},defaults:Gs,render:(n,e)=>n.light(ge("directional",e,["color","intensity","target","shadow"]))}),ta=P({key:"point-light3d",state:{color:me(),intensity:w(),distance:w(),decay:w()},defaults:Gs,render:(n,e)=>n.light(ge("point",e,["color","intensity","distance","decay","shadow"]))}),na=P({key:"spot-light3d",state:{color:me(),intensity:w(),distance:w(),angle:w(),penumbra:w(),decay:w(),target:nn("origin")},defaults:Gs,render:(n,e)=>n.light(ge("spot",e,["color","intensity","distance","angle","penumbra","decay","target","shadow"]))}),sa=P({key:"area-light3d",state:{color:me(),intensity:w(),width:w(),height:w()},render:(n,e)=>n.light(ge("area",e,["color","intensity","width","height"]))}),Vd=["target","orbit","elevation","distance","fov","frustumHeight","near","far","zoom"],Kd=["orbit","elevation","distance"],ra=P({key:"camera3d",state:{type:k.custom("perspective"),target:nn("origin"),orbit:w(),elevation:w(),distance:w(),fov:w(),frustumHeight:w(),near:w(),far:w(),zoom:w()},commands:{orbitTo:{args:{orbit:tn({step:1,unit:"\xB0"}),elevation:tn({min:-89,max:89,step:1,unit:"\xB0"}),distance:tn({min:.01,step:.1})},run:(n,e)=>{let t={orbit:e.orbit??De.orbit,elevation:e.elevation??De.elevation,distance:e.distance??De.distance};return n.animate(s=>{let r={};for(let o of Kd){let i=n.args[o];i!==void 0&&(r[o]=t[o]+(i-t[o])*s)}return r})}},lookTo:{args:["target"]}},render:(n,e)=>{let t={type:e.type};for(let s of Vd)e[s]!==void 0&&(t[s]=e[s]);n.camera(t)}}),oa=P({key:"fog3d",state:{color:me(),near:w(),far:w(),density:w()},render:(n,e)=>{let t={};e.color!==void 0&&(t.color=e.color),e.density!==void 0?t.density=e.density:(e.near!==void 0&&(t.near=e.near),e.far!==void 0&&(t.far=e.far)),n.fog(t)}}),ia=P({key:"environment3d",state:{src:w(),faces:w(),preset:w(),intensity:w(),background:w(),blur:w()},render:(n,e)=>{if(e.src===void 0&&e.faces===void 0&&e.preset===void 0)return n.environment(null);let t=Xo(e,["src","faces","preset","intensity","background","blur"]);(e.rotationX||e.rotationY||e.rotationZ)&&(t.rotation=[e.rotationX,e.rotationY,e.rotationZ]),n.environment(t)}});var aa=T({key:"canvas3d",state:{...F,...B,...Se,...Zo},defaults:{width:"fill",height:"fill"},commands:{...$,...Qo},allowedChildren:["2d","3d"],load:n=>ei(n),measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>ti(n,e)});function Ue(n){return n.kind==="still"}function Ry(n){return n.kind==="composition"}function ln(n){return n.kind==="audio"}function Ud(n){return n.kind!=="still"}var b="";function U(n){let e=n;return{start:e.startAt??0,end:e.endAt??1/0}}function zy(n,e){return Ge(new Map(n.map(t=>[t.id,t])),e)}function ca(n){let e=new Map(n.map(o=>[o.id,o])),t=new Map,s=[],r=new Set;for(let o of e.values()){if(t.has(o.id))continue;s.length=0,r.clear();let i,a=o;for(;a;){let c=t.get(a.id);if(c){i=c;break}if(r.has(a.id)){for(let d of s)t.set(d.id,Ge(e,d.id));s.length=0;break}s.push(a),r.add(a.id),a=a.parentId===null?void 0:e.get(a.parentId)}for(let c=s.length-1;c>=0;c--){let d=U(s[c]);i&&(d.start=Math.max(d.start,i.start),d.end=Math.min(d.end,i.end)),t.set(s[c].id,d),i=d}}return t}function Ge(n,e){let t=n.get(e);if(!t)return;let s=U(t),r=new Set;for(;t.parentId!==null&&!r.has(t.id);){r.add(t.id);let o=n.get(t.parentId);if(!o)break;let i=U(o);s.start=Math.max(s.start,i.start),s.end=Math.min(s.end,i.end),t=o}return s}function Ly(n){let{startAt:e,endAt:t,...s}=n;return s}function Gd(n){let e=n.duration??0;return e<=0||!n.loop||n.loop.count===null?e:e*io(n.loop)}function ue(n){if(!Ud(n))return 0;if(n.duration!==void 0)return n.duration;let e=0;for(let t of n.commands)e=Math.max(e,t.at+Gd(t));for(let t of n.nodes)t.startAt!==void 0&&(e=Math.max(e,t.startAt)),t.endAt!==void 0&&Number.isFinite(t.endAt)&&(e=Math.max(e,t.endAt));return e}function Yd(n){return typeof n=="object"&&n!==null&&n.kind==="project"}function da(n,e={}){return Yd(n)?n:{kind:"project",...n.formatVersion!==void 0&&{formatVersion:n.formatVersion},name:e.name??"Untitled",fps:e.fps,viewport:e.viewport,theme:n.theme,tracks:[{id:"clip",clip:n,duration:ue(n)}]}}var Xs=3,kt=class extends Error{version;supported;constructor(e,t=3){super(`This document is format ${e}, newer than this engine reads (format ${t}). Open it with a newer engine.`),this.name="DocumentTooNewError",this.version=e,this.supported=t}},ua=[{from:0,description:"Documents start carrying `formatVersion`; a clip's retired `constants` rows become `variables`.",clip:(n,e)=>{if(!Array.isArray(n.constants))return n;let{constants:t,...s}=n,r=Array.isArray(s.variables)?[...s.variables]:[];for(let o of t){if(typeof o!="object"||o===null){r.push(o);continue}let{kind:i,...a}=o;r.push(a)}return e("constants",`${t.length} constant row(s) moved into \`variables\`.`),{...s,variables:r}}},{from:1,description:'SkSL is retired: every shader fill, shader effect and shader pack written in it says `language: "sksl"`, the `sksl` effect key becomes `shader`, and `coords` is dropped.',clip:(n,e)=>Ys(n,"",e)},{from:2,description:"An image or video fill's retired `filters` prop moves into `preset.adjustments`.",clip:(n,e)=>Ws(n,"",e)}],Wd=/\b(?:half4|float4|vec4)\s+main\s*\(|^\s*uniform\s+\w+\s+\w+/m,bt=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function Ys(n,e,t){if(Array.isArray(n)){let r;return n.forEach((o,i)=>{let a=Ys(o,`${e}[${i}]`,t);a!==o&&((r??=[...n])[i]=a)}),r??n}if(!bt(n))return n;let s;for(let[r,o]of Object.entries(n)){let i=Ys(o,e?`${e}.${r}`:r,t);i!==o&&((s??={...n})[r]=i)}return Xd(s??n,e,t)}function Xd(n,e,t){let s=n.type==="sksl";if(!(s||n.type==="shader"&&(typeof n.source=="string"||typeof n.shader=="string")||(n.scope==="fill"||n.scope==="effect")&&typeof n.source=="string"))return n;let o={...n};s&&(o.type="shader");let i=o.type==="shader"&&typeof o.shader=="string"&&o.source===void 0;i&&(o.source=o.shader,delete o.shader);let a=o.language==="sksl"||o.language===void 0&&(s||Wd.test(typeof o.source=="string"?o.source:"")),c=a&&o.language===void 0;c&&(o.language="sksl");let d="coords"in o;return delete o.coords,a?t(e,"SkSL shaders no longer draw; port it to WGSL."):s?t(e,"The retired `sksl` effect key is now `shader`."):i?t(e,"The shader's `shader` field is now `source`."):d&&t(e,"`coords` dropped; it only ever applied to SkSL."),s||i||c||d?o:n}function Ws(n,e,t){if(Array.isArray(n)){let d;return n.forEach((u,l)=>{let f=Ws(u,`${e}[${l}]`,t);f!==u&&((d??=[...n])[l]=f)}),d??n}if(!bt(n))return n;let s;for(let[d,u]of Object.entries(n)){let l=Ws(u,e?`${e}.${d}`:d,t);l!==u&&((s??={...n})[d]=l)}let r=s??n;if(!("filters"in r)||!(r.type==="image"||r.type==="video")||typeof r.src!="string")return r;let{filters:o,preset:i,...a}=r,c=bt(i)&&i.adjustments!==void 0;return t(e,c?"`filters` dropped; the fill's `preset.adjustments` already says the grade.":"`filters` moved to `preset.adjustments`."),c||i!==void 0&&!bt(i)?{...a,preset:i}:{...a,preset:{...bt(i)?i:{},adjustments:o}}}function qs(n){if(typeof n!="object"||n===null)return 0;let e=n.formatVersion;if(e===void 0)return 0;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new TypeError(`formatVersion must be a whole number >= 0 (got ${JSON.stringify(e)}).`);return e}function Hs(n){return qd(n,ua,3)}function qd(n,e,t){let s=qs(n);if(s>t)throw new kt(s,t);if(typeof n!="object"||n===null||Array.isArray(n))return{document:n,from:s,to:s,changes:[]};let r=[],o=n;return{document:o.kind==="project"?Hd(o,s,e,t,r):ha(o,s,e,t,r,""),from:s,to:t,changes:r}}function la(n,e,t){let s=[];for(let r=n;r<e;r++){let o=t.find(i=>i.from===r);if(!o)throw new Error(`No document migration from format ${r} to ${r+1}.`);s.push(o)}return s}function fa(n,e,t){return(s,r)=>n.push({from:e,path:t&&s?`${t}.${s}`:t||s,message:r})}function ha(n,e,t,s,r,o,i=!0){if(e===s)return n;let a=n;for(let c of la(e,s,t))c.clip&&(a=c.clip(a,fa(r,c.from,o)));return i?{...a,formatVersion:s}:a}function Hd(n,e,t,s,r){let o=n;if(e<s)for(let c of la(e,s,t))c.project&&(o=c.project(o,fa(r,c.from,"")));let i=!1,a=Array.isArray(o.tracks)?o.tracks.map((c,d)=>{if(typeof c!="object"||c===null)return c;let u=c.clip;if(typeof u!="object"||u===null||Array.isArray(u))return c;let l=u.formatVersion!==void 0,f=l?qs(u):e;if(f>s)throw new kt(f,s);let h=ha(u,f,t,s,r,`tracks[${d}].clip`,l);return h===u?c:(i=!0,{...c,clip:h})}):o.tracks;return e===s&&!i?n:{...o,...i?{tracks:a}:{},formatVersion:s}}var pa=new Set(["normal","reverse","alternate"]);function L(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ie(n){return typeof n=="number"&&Number.isFinite(n)&&n>=0}function _a(n,e,t){if(n===void 0)return;if(!L(n)){t.push({path:e,message:"easing must be an object with a `kind`."});return}let{kind:s,args:r}=n;if(typeof s!="string"||!ds.has(s)){t.push({path:`${e}.kind`,message:`easing kind must be one of ${[...ds].join(", ")} (got ${JSON.stringify(s)}).`});return}s==="custom"&&r!==void 0&&typeof r!="string"&&!cs(r)&&t.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 wa(n,e,t){_a(n,e,t),L(n)&&n.kind==="custom"&&!cs(n.args)&&t.push({path:`${e}.args`,message:"an audio ease cannot name a registered ease; draw its curve (two or more `{ x, y }` points) instead."})}function ma(n,e,t){if(!(n===void 0||typeof n=="number"&&Number.isFinite(n)||I.isSource(n))){if(!L(n)||!Array.isArray(n.keys)){t.push({path:e,message:"must be a finite number, an expression or a ramp, `{ keys: [{ at, value }, \u2026] }`."});return}n.keys.forEach((s,r)=>{let o=`${e}.keys[${r}]`;if(!L(s)){t.push({path:o,message:"a ramp key must be an object."});return}(s.at===void 0==(s.before===void 0)||!ie(s.at??s.before))&&t.push({path:o,message:"a ramp key needs exactly one of `at` (seconds after the start) or `before` (seconds before the end), >= 0."}),(typeof s.value!="number"||!Number.isFinite(s.value))&&t.push({path:`${o}.value`,message:"a ramp key's value must be a finite number."}),wa(s.ease,`${o}.ease`,t)})}}var Jd=new Set(["duration","curve"]);function ga(n,e,t){if(n!==void 0){if(!L(n)){t.push({path:e,message:"a transition must be an object, `{ duration, curve? }`."});return}ie(n.duration)||t.push({path:`${e}.duration`,message:"a transition's duration must be a finite number of seconds >= 0."}),n.curve!==void 0&&n.curve!=="equalPower"&&wa(n.curve,`${e}.curve`,t);for(let s of Object.keys(n))Jd.has(s)||t.push({path:`${e}.${s}`,message:`a transition has no "${s}" (yet): only duration and curve.`})}}function Zd(n,e,t,s){"filters"in e&&s.push({path:`${t}.filters`,message:"audio `filters` was renamed to `effects`."});for(let o of["volume","pan",...n==="sound"?["speed"]:[]])ma(e[o],`${t}.${o}`,s);n==="sound"&&e.loop===!0&&L(e.speed)&&s.push({path:`${t}.speed`,message:"a looping sound cannot ramp its speed: there is no one pass of the source for the ramp to run over."});let r=e.effects;r!==void 0&&(Array.isArray(r)?r:[r]).forEach((i,a)=>{let c=Array.isArray(r)?`${t}.effects[${a}]`:`${t}.effects`;if(!L(i)||typeof i.type!="string"){s.push({path:c,message:"an effect must be an object with a `type`."});return}for(let[d,u]of Object.entries(i))d!=="type"&&ma(u,`${c}.${d}`,s)}),ga(e.transitionIn,`${t}.transitionIn`,s),ga(e.transitionOut,`${t}.transitionOut`,s)}function Qd(n,e,t){if(n===void 0)return;if(!L(n)){t.push({path:e,message:"loop must be an object with a `count`."});return}let{direction:s,count:r}=n;r!==null&&(typeof r!="number"||!Number.isInteger(r)||r<0)&&t.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."}),s!==void 0&&!pa.has(s)&&t.push({path:`${e}.direction`,message:`loop direction must be one of ${[...pa].join(", ")} (got ${JSON.stringify(s)}).`})}function eu(n,e,t){if(!L(n))return t.push({path:e,message:"node must be an object."}),!1;let s=!0,{id:r,type:o,parentId:i,layerOrder:a,props:c,key:d}=n;return typeof r!="string"&&(t.push({path:`${e}.id`,message:"id must be a string."}),s=!1),(typeof o!="string"||o.length===0)&&(t.push({path:`${e}.type`,message:"type must be a non-empty string."}),s=!1),i!==null&&typeof i!="string"&&(t.push({path:`${e}.parentId`,message:"parentId must be a node id or null."}),s=!1),(typeof a!="number"||!Number.isFinite(a))&&(t.push({path:`${e}.layerOrder`,message:"layerOrder must be a finite number."}),s=!1),L(c)?(o==="sound"||o==="audioBus")&&Zd(o,c,`${e}.props`,t):(t.push({path:`${e}.props`,message:"props must be an object (`{}` when nothing is set)."}),s=!1),d!==void 0&&(typeof d!="string"||d.length===0?(t.push({path:`${e}.key`,message:"key must be a non-empty string when present."}),s=!1):(d.includes("]")||d.includes("."))&&(t.push({path:`${e}.key`,message:`node key "${d}" cannot contain "]" or "." \u2014 it is referenced as "[${d}.prop]".`}),s=!1)),s}function xa(n,e){let t=new Map;for(let s of n){let r=s.spec.key;if(typeof r!="string"||r.length===0)continue;let o=t.get(r);if(o){e.push({path:`${s.path}.key`,message:`duplicate node key "${r}" (also declared at ${o.path}).`});continue}t.set(r,s)}return t}function tu(n,e,t,s){n.id===""&&(n.type!==t||n.parentId!==null)&&s.push({path:e,message:`the node with id "" is this document's root and must be \`{ type: "${t}", parentId: null }\`.`})}function nu(n,e,t){if(!L(n))return t.push({path:e,message:"command must be an object."}),!1;let s=!0,{id:r,type:o,targetId:i,at:a,duration:c,args:d}=n;return(typeof r!="string"||r.length===0)&&(t.push({path:`${e}.id`,message:"id must be a non-empty string."}),s=!1),(typeof o!="string"||o.length===0)&&(t.push({path:`${e}.type`,message:"type must be a non-empty string."}),s=!1),i!==null&&typeof i!="string"&&(t.push({path:`${e}.targetId`,message:"targetId must be a node id, or null for the scene root."}),s=!1),ie(a)||(t.push({path:`${e}.at`,message:"at must be a finite number of seconds >= 0."}),s=!1),c!==void 0&&!ie(c)&&(t.push({path:`${e}.duration`,message:"duration must be a finite number of seconds >= 0."}),s=!1),L(d)||(t.push({path:`${e}.args`,message:"args must be an object (`{}` when there are none)."}),s=!1),_a(n.easing,`${e}.easing`,t),Qd(n.loop,`${e}.loop`,t),s}function su(n,e,t){if(!L(n))return t.push({path:e,message:"variable must be an object."}),!1;let s=!0,{id:r,name:o,value:i,lerp:a}=n;return typeof r!="string"||r.length===0?(t.push({path:`${e}.id`,message:"id must be a non-empty string."}),s=!1):r.includes("]")&&(t.push({path:`${e}.id`,message:`variable id "${r}" cannot contain "]" \u2014 it is referenced as "[${r}]".`}),s=!1),o!==void 0&&typeof o!="string"&&(t.push({path:`${e}.name`,message:"name must be a string when present."}),s=!1),"value"in n?I.isSource(i)&&(t.push({path:`${e}.value`,message:"a variable holds a value, not an expression \u2014 only a node prop can be bound."}),s=!1):(t.push({path:`${e}.value`,message:"value is required \u2014 a variable is what it holds before anything changes it."}),s=!1),a!==void 0&&typeof a!="string"&&(t.push({path:`${e}.lerp`,message:"lerp must be a registered lerp key when present."}),s=!1),s}function va(n,e){if(n===void 0)return[];if(!Array.isArray(n))return e.push({path:"variables",message:"variables must be an array."}),[];let t=[];return n.forEach((s,r)=>{let o=`variables[${r}]`;su(s,o,e)&&t.push({spec:s,path:o})}),t}function ba(n,e){let t=new Map;for(let s of n){let r=t.get(s.spec.id);if(r){e.push({path:`${s.path}.id`,message:`duplicate variable id "${s.spec.id}" (also declared at ${r.path}).`});continue}t.set(s.spec.id,s)}return t}function ka(n){let e=n.indexOf(".");return e<0?void 0:{key:n.slice(0,e),prop:n.slice(e+1)}}function Js(n,e,t,s,r){for(let o of I.collect(n,e)){let i=I.tryParse(o.source);if("error"in i){r.push({path:o.path,message:i.error});continue}for(let a of i.expression.refs){let c=ka(a);if(!c){if(t.has(a))continue;r.push({path:o.path,message:s.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: ${[...t].map(d=>`[${d}]`).join(", ")||"none"}.`});continue}if(c.key.length===0||c.prop.length===0||c.prop.includes(".")){r.push({path:o.path,message:`expression references "[${a}]", which is not a node reference \u2014 one is "[key.prop]".`});continue}s.has(c.key)||r.push({path:o.path,message:`expression references "[${a}]", but no node in this document is keyed "${c.key}". Keyed: ${[...s].join(", ")||"none"}.`})}}}function Zs(n,e,t,s){if(L(e))for(let r of Object.keys(e)){let o=[];for(let i of I.collect(e[r],`${t}.${r}`)){let a=I.tryParse(i.source);if(!("error"in a))for(let c of a.expression.refs)ka(c)&&o.push(c)}o.length>0&&s.push({id:`${n}.${r}`,path:`${t}.${r}`,reads:o})}}function Sa(n,e){let t=new Map(n.map(a=>[a.id,a])),s=new Set,r=[],o=new Set,i=a=>{let c=t.get(a);if(!c||s.has(a))return;let d=r.indexOf(a);if(d>=0){if(!o.has(a)){let u=[...r.slice(d),a];for(let l of u)o.add(l);e.push({path:c.path,message:`expression cycle ${u.join(" \u2192 ")} \u2014 a prop cannot read a prop that reads it back.`})}return}r.push(a);for(let u of c.reads)i(u);r.pop(),s.add(a)};for(let a of n)i(a.id)}function ru(n,e){let t=new Map;for(let r of n){if(t.has(r.spec.id)){e.push({path:`${r.path}.id`,message:`duplicate node id "${r.spec.id}".`});continue}t.set(r.spec.id,r)}for(let r of n){let o=r.spec.parentId;o!==null&&!t.has(o)&&e.push({path:`${r.path}.parentId`,message:`parentId "${o}" is not a node in this document.`})}let s=new Set;for(let{spec:r}of n){if(s.has(r.id))continue;let o=new Set,i=r;for(;i;){if(o.has(i.id)){e.push({path:`${t.get(i.id)?.path}.parentId`,message:`node "${i.id}" is its own ancestor \u2014 parent chain forms a cycle.`});break}if(o.add(i.id),s.has(i.id))break;let a=i.parentId;i=a===null?void 0:t.get(a)?.spec}for(let a of o)s.add(a)}}function Aa(n,e,t){for(let s of n){let r=e.get(s.id);r&&t.push({path:`${r.path}.id`,message:`"${s.id}" is already a node id \u2014 nodes and variables share one id space.`})}}function Ma(n,e){n.constants!==void 0&&e.push({path:"constants",message:"constants were merged into `variables` \u2014 move each row there and drop its `kind`."})}function Oa(n,e){let t=n.formatVersion;t!==void 0&&(typeof t!="number"||!Number.isInteger(t)||t<0?e.push({path:"formatVersion",message:"formatVersion must be a whole number >= 0 when present."}):t>3&&e.push({path:"formatVersion",message:`format ${t} is newer than this engine reads (${3}) \u2014 open it with a newer engine.`}))}var ou={visualTracks:"visual and audio tracks were merged into `tracks` \u2014 move each row there.",audioTracks:"visual and audio tracks were merged into `tracks` \u2014 move each row there.",backgrounds:"a background is a track \u2014 put it first in `tracks`.",overlays:"an overlay is a track \u2014 put it last in `tracks`.",commands:"a project has no commands \u2014 each clip carries its own.",constants:"a project has no constants \u2014 declare `variables` in each clip."};function Ta(n,e,t,s,r,o){let i=new Map([["",t]]);for(let a of n)i.set(a.spec.id,a.spec.type),r.hasNode(a.spec.type)||o.push({path:`${a.path}.type`,message:`node type "${a.spec.type}" is not registered.`});for(let{spec:a,path:c}of e){if(r.command(a.type))continue;if(a.targetId!==null&&s.has(a.targetId)){o.push({path:`${c}.type`,message:`"${a.type}" is not a variable command.`});continue}let d=i.get(a.targetId??"");d===void 0||!r.hasNode(d)||r.takesCommand(d,a.type)||o.push({path:`${c}.type`,message:`node type "${d}" has no command "${a.type}".`})}}function Ea(n,e,t){if(!Array.isArray(n))return t.push({path:"nodes",message:"nodes must be an array."}),[];let s=[];return n.forEach((r,o)=>{let i=`nodes[${o}]`;eu(r,i,t)&&(s.push({spec:r,path:i}),tu(r,i,e,t))}),ru(s,t),s}function iu(n,e,t){let{startAt:s,endAt:r}=n;s!==void 0&&!ie(s)&&t.push({path:`${e}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),r!==void 0&&!ie(r)&&t.push({path:`${e}.endAt`,message:"endAt must be a finite number of seconds >= 0."}),ie(r)&&r<=(ie(s)?s:0)&&t.push({path:`${e}.endAt`,message:`endAt (${r}s) must be after startAt (${s??0}s).`}),n.id===""&&(s!==void 0||r!==void 0)&&t.push({path:e,message:"the root is present for the whole clip \u2014 it cannot carry startAt or endAt."})}function au(n,e,t){Ma(n,e),n.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 s=ba(va(n.variables,e),e),r=Ea(n.nodes,"canvas2d",e);for(let u of r){let{startAt:l,endAt:f}=u.spec;(l!==void 0||f!==void 0)&&e.push({path:u.path,message:"a still has no timeline \u2014 drop startAt/endAt, or make it a composition."})}let o=r.map(u=>u.spec);Aa(o,s,e),t&&Ta(r,[],"canvas2d",s,t,e);let i=xa(r,e),a=new Set(s.keys()),c=new Set(i.keys()),d=[];for(let u of r)Js(u.spec.props,`${u.path}.props`,a,c,e),u.spec.key&&Zs(u.spec.key,u.spec.props,`${u.path}.props`,d);Sa(d,e)}function cu(n,e,t){Ca(n,"canvas2d",e,t)}function du(n,e,t){Ca(n,"audioBus",e,t)}var uu={add:"a node is a row in `nodes` \u2014 its `startAt` is when it enters.",variable:"a variable is declared in `variables`."};function Ca(n,e,t,s){if(Ma(n,t),!Array.isArray(n.commands)){t.push({path:"commands",message:"commands must be an array."});return}n.duration!==void 0&&!ie(n.duration)&&t.push({path:"duration",message:"duration must be a finite number of seconds >= 0."});let r=ba(va(n.variables,t),t),o=Ea(n.nodes,e,t);for(let p of o)iu(p.spec,p.path,t);let i=o.map(p=>p.spec);Aa(i,r,t);let a=xa(o,t),c=[],d=new Set;n.commands.forEach((p,g)=>{if(!nu(p,`commands[${g}]`,t))return;if(d.has(p.id)){t.push({path:`commands[${g}].id`,message:`duplicate command id "${p.id}".`});return}let m=uu[p.type];if(m){t.push({path:`commands[${g}].type`,message:`there is no "${p.type}" command \u2014 ${m}`});return}d.add(p.id),c.push({spec:p,path:`commands[${g}]`})});let u=new Map(i.map(p=>[p.id,p]));s&&Ta(o,c,e,r,s,t);for(let{spec:p,path:g}of c){if(p.targetId===null||r.has(p.targetId))continue;let m=Ge(u,p.targetId);m===void 0?t.push({path:`${g}.targetId`,message:`targetId "${p.targetId}" is not a node or variable in this document.`}):p.at<m.start&&t.push({path:`${g}.at`,message:`command runs at ${p.at}s but its target "${p.targetId}" is not present until ${m.start}s.`})}let l=new Set(r.keys()),f=new Set(a.keys());for(let p of o)Js(p.spec.props,`${p.path}.props`,l,f,t);for(let{spec:p,path:g}of c)Js(p.args,`${g}.args`,l,f,t);let h=[];for(let p of o)p.spec.key&&Zs(p.spec.key,p.spec.props,`${p.path}.props`,h);for(let{spec:p,path:g}of c){if(p.type!=="set"||p.targetId===null)continue;let m=u.get(p.targetId)?.key;m&&Zs(m,p.args,`${g}.args`,h)}Sa(h,t)}function Qs(n,e={}){let t=[];if(!L(n))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};Oa(n,t);let{registry:s}=e,r=n.kind;return r==="still"?au(n,t,s):r==="composition"?cu(n,t,s):r==="audio"?du(n,t,s):t.push({path:"kind",message:`kind must be "still", "composition" or "audio" (got ${JSON.stringify(r)}).`}),{valid:t.length===0,issues:t}}function lu(n,e={}){let t=[];if(!L(n))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};let s=n;s.kind!=="project"&&t.push({path:"kind",message:`kind must be "project" (got ${JSON.stringify(s.kind)}).`}),(typeof s.name!="string"||s.name.length===0)&&t.push({path:"name",message:"name must be a non-empty string."}),s.fps!==void 0&&(typeof s.fps!="number"||!(s.fps>0)||!Number.isFinite(s.fps))&&t.push({path:"fps",message:"fps must be a positive number when present."}),Oa(s,t);for(let[o,i]of Object.entries(ou))s[o]!==void 0&&t.push({path:o,message:i});if(!Array.isArray(s.tracks))return t.push({path:"tracks",message:"tracks must be an array."}),{valid:!1,issues:t};let r=new Set;return s.tracks.forEach((o,i)=>{let a=`tracks[${i}]`;if(!L(o)){t.push({path:a,message:"track must be an object."});return}let c=o;if(typeof c.id!="string"||c.id.length===0?t.push({path:`${a}.id`,message:"id must be a non-empty string."}):r.has(c.id)?t.push({path:`${a}.id`,message:`duplicate track id "${c.id}".`}):r.add(c.id),c.name!==void 0&&typeof c.name!="string"&&t.push({path:`${a}.name`,message:"name must be a string when present."}),c.startAt!==void 0&&!ie(c.startAt)&&t.push({path:`${a}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),ie(c.duration)||t.push({path:`${a}.duration`,message:"duration is required, and must be a finite number of seconds >= 0."}),c.clip===void 0){t.push({path:`${a}.clip`,message:"clip is required \u2014 a track places a clip document inline."});return}for(let d of fu(c.clip,e))t.push({path:`${a}.clip${d.path?`.${d.path}`:""}`,message:d.message})}),{valid:t.length===0,issues:t}}var ya=new WeakMap;function fu(n,e){if(!L(n)||e.registry)return Qs(n,e).issues;let t=ya.get(n);return t||(t=Qs(n).issues,ya.set(n,t)),t}function Pa(n,e){let{valid:t,issues:s}=lu(n,e);if(!t){let r=s.map(o=>` ${o.path||"<root>"}: ${o.message}`).join(`
|
|
1
|
+
import{$b as Gt,$d as Po,Ac as gs,Ae as en,Bb as ls,Bc as ke,Be as Go,Cb as he,Cc as je,Cd as I,Ce as Yo,Db as j,Dc as ho,Dd as As,De as Wo,Eb as de,Ed as Zt,F as Xr,Fa as Ut,Fb as fs,Fc as Z,Fd as Ao,Fe as mt,Ga as Zr,Gc as ys,Gd as Mo,Ge as P,Hb as hs,He as w,Ie as tn,Ja as os,Jd as Oo,Je as me,Ka as ve,Kd as T,Ke as nn,Lb as ct,Ld as k,Le as Xo,Mb as ps,Md as Se,Me as ge,Nb as so,Nc as _s,Nd as Be,Ne as qo,Oe as sn,Pc as ws,Pd as B,Pe as Ho,Qc as po,Qd as K,Qe as Jo,Rc as mo,Rd as z,Sc as go,Se as Zo,Tc as xs,Td as To,Te as Qo,Ua as as,Uc as Xt,Ud as F,Ue as ei,Vb as dt,Vc as yo,Vd as $,Ve as ti,Wa as ot,Wb as ro,Wc as qt,Wd as Q,X as ss,Xb as ne,Xc as vs,Xd as E,Yb as oo,Yc as _o,Zb as ut,Zc as R,Zd as Eo,_b as Le,_d as Co,aa as rs,ac as be,ad as ht,ae as Qt,bc as Ce,bd as bs,be as Io,cb as cs,cc as pe,cd as ks,ce as Do,dc as lt,dd as Ss,de as Ms,ea as qr,eb as ds,ec as ft,f as Qn,fa as Hr,fb as it,fd as wo,fe as Fo,ga as rt,gc as io,gd as xo,ge as $o,hc as ao,he as No,id as Ht,jd as Jt,kb as at,kc as co,lc as Yt,m as ns,md as ko,me as Os,nb as Qr,nd as So,ne as Ts,oa as Jr,ob as Y,oc as Pe,oe as Es,pb as eo,pc as uo,pe as Lo,qe as jo,ra as fe,re as Bo,sb as to,se as Vo,tb as no,vc as lo,ve as Cs,wb as Ee,wc as fo,we as Ps,xc as ms,xe as Ko,yc as Wt,ye as pt,zb as us,ze as Uo}from"./chunk-XCGYJHZR.js";import{b as Ro,f as zo}from"./chunk-GEJEQQER.js";import{b as Wr,d as es,f as ts,h as ze,m as is,n as vo,o as bo}from"./chunk-5TDMGUXQ.js";function ni(n){return Number.isFinite(n)&&n>0?n:1}function Ve(n,e,t=e){return at(n)?to(n,e,t):Math.max(0,Math.min(t,e))/ni(n)}function Sd(n,e,t){return at(n)?no(n,e,t):Math.max(0,Math.min(e,t*ni(n)))}function Ad(n,e){let t=Math.max(0,(n.trimEnd??e)-(n.trimStart??0));return Ve(n.speed??1,t)}function si(n,e,t,s){let r=n.at??0,o=n.until??1/0,i=n.trimStart??0,a=n.trimEnd??1/0,c=n.loop??!1,d=Ee(n.effects),u=e.getMediaDuration(n.src),l=n.speed??1;c&&at(l)&&(l=Qr(l,1));let f=Math.max(0,(Number.isFinite(a)?a:u)-i),h={id:`${t}|${n.src}|${r}|${s}`,src:n.src,startAt:r,endAt:1/0,trimStart:i,volume:n.volume??1,speed:l,loop:c,ownerId:t};if(at(l)&&(h.sourceLength=f),d.length>0&&(h.effects=d),n.transitionIn&&(h.transitionIn=n.transitionIn),n.transitionOut&&(h.transitionOut=n.transitionOut),n.bus&&(h.bus=n.bus),n.optional&&(h.optional=!0),c&&a>i&&Number.isFinite(a)&&(h.trimEnd=a),c&&Number.isFinite(o))h.endAt=o;else if(c)h.open=!0;else if(Number.isFinite(a))h.endAt=Math.min(o,r+Ve(l,f));else{let p=Ve(l,f);Number.isFinite(o)?h.endAt=Math.min(o,r+p):(h.open=!0,h.mediaDuration=p)}return h}var Is=class{src;volume;speed;loop;trimStart;trimEnd;effects;constructor(e){this.src=e.src,this.volume=e.volume??1,this.speed=e.speed??1,this.loop=e.loop??!1,this.trimStart=e.trimStart??0,this.trimEnd=e.trimEnd??e.duration??1/0,this.effects=Ee(e.effects)}clipDurationFor(e){return Ve(this.speed,e)}get clipDuration(){return this.trimEnd!==1/0?this.clipDurationFor(this.trimEnd-this.trimStart):void 0}};function gt(n){return!n||n.length===0?"":n.map(e=>{switch(e.type){case"gain":return`gain:${Y(e.value)}`;case"highpass":case"lowpass":return`${e.type}:${Y(e.frequency)}:${Y(e.q)}`;case"tremolo":return`tremolo:${Y(e.rate)}:${Y(e.depth)}`;case"echo":return`echo:${Y(e.delay)}:${Y(e.feedback)}:${Y(e.mix)}`}}).join("|")}var Md=n=>Math.sin(Math.max(0,Math.min(1,n))*Math.PI/2),ri=new WeakMap;function oi(n){let e=n.curve;if(e===void 0||e==="equalPower")return Md;let t=ri.get(e);return t||ri.set(e,t=it(e)),t}function Od(n,e,t){let s={in:Math.max(0,e?.duration??0),out:Math.max(0,t?.duration??0)};if(!Number.isFinite(n))return{in:s.in,out:0};let r=s.in+s.out;if(r<=n||r===0)return s;let o=Math.max(0,n)/r;return{in:s.in*o,out:s.out*o}}function Lp(n,e,t,s){let r=Od(e,t,s),o=1;return t&&r.in>0&&n<r.in&&(o*=Math.max(0,oi(t)(Math.max(0,n)/r.in))),s&&r.out>0&&n>e-r.out&&(o*=Math.max(0,oi(s)(Math.max(0,e-n)/r.out))),o}function Ke(n){return n?`${n.duration}:${typeof n.curve=="object"?JSON.stringify(n.curve):n.curve??"equalPower"}`:"_"}function Ds(n){return`${n.id}:${Y(n.volume)}:${Y(n.pan)}:${n.mute?1:0}:${gt(n.effects)}:${Ke(n.transitionIn)}:${Ke(n.transitionOut)}:${n.startAt}:${n.endAt}`}var Td=new Set(["number","slider","angle","hue","boolean","color","vector","point"]);function km(n){return Td.has(n.kind)}var ii=64,ai=64e3;function ci(n){if(typeof n!="object"||n===null)throw new Error("A shader pack must be an object.");let e=n,t=e.scope;if(t!=="fill"&&t!=="effect")throw new Error(`A shader pack needs scope "fill" or "effect", got ${JSON.stringify(t)}. 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 s=typeof e.source=="string"?e.source.trim():"";if(s==="")throw new Error(`Shader pack "${String(e.name??"?")}" has no source.`);if(s.length>ai)throw new Error(`Shader pack "${String(e.name??"?")}" source is ${s.length} characters, over the ${ai} ceiling.`);if(e.language!==void 0&&e.language!=="wgsl")throw new Error(`Shader pack "${String(e.name??"?")}" is written in ${JSON.stringify(e.language)}; only WGSL is supported. Port it to WGSL.`);let r={...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}:{},language:"wgsl",source:s,..._t(e.uniforms)?{uniforms:e.uniforms}:{},properties:Ed(e.properties,String(e.name??"?"))};if(t==="fill"){let o=Array.isArray(e.textures)?e.textures.filter(i=>_t(i)&&typeof i.name=="string").map(i=>({name:i.name,...typeof i.description=="string"?{description:i.description}:{}})):[];return{...r,scope:"fill",...o.length?{textures:o}:{}}}return{...r,scope:"effect",...e.backdrop===!0?{backdrop:!0}:{}}}function Ed(n,e){if(!_t(n))return{};let t={},s=new Map;for(let[r,o]of Object.entries(n)){if(Object.keys(t).length>=ii){yt(`shader "${e}" declares more than ${ii} properties; the rest are ignored.`);break}if(!_t(o)||typeof o.kind!="string"){yt(`shader "${e}" property "${r}" has no kind; ignored.`);continue}let i=o.inputs;if(!_t(i)||Object.keys(i).length===0){yt(`shader "${e}" property "${r}" names no uniform in "inputs"; ignored.`);continue}let a=!1;for(let c of Object.values(i)){if(typeof c!="string"){yt(`shader "${e}" property "${r}" has a non-string uniform name; ignored.`),a=!0;break}let d=s.get(c);if(d!==void 0){yt(`shader "${e}" properties "${d}" and "${r}" both write uniform "${c}"; "${r}" ignored.`),a=!0;break}s.set(c,r)}a||(t[r]=o)}return t}function _t(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var rn=new Set;function yt(n){rn.has(n)||(rn.size>256&&rn.clear(),rn.add(n),console.warn(`[shader] ${n}`))}function ye(n,e){return n===""?String(e):`${n}.${e}`}function Fs(n,e){n.declareAssets(e)}function $s(n,e){if(!n.mounted)return;Fs(n,e);let t=n._allChildren;for(let s=0;s<t.length;s++)$s(t[s],e)}function di(n,e){n.attachDetached(e)}function on(n){n._sample();for(let e of n.children)on(e)}function an(n,e){n._primeMotion(e);for(let t of n.children)an(t,e)}function Ns(n,e){let t=s=>{let r=s.key!==void 0?e?.[s.key]:void 0;s._setEditorState(r?.hidden===!0,r?.locked===!0);for(let o of s._allChildren)t(o)};t(n)}var Ie=class extends R{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 t=this.fill,s=ve.resolve(e.data),r=e.lerp??ve.lerp;return this.command(o=>({fill:r(t,s,o)}),e.duration,e.easing)}overlayTo(e){let t=this.overlay,s=ve.resolve(e.data),r=e.lerp??ve.lerp;return this.command(o=>({overlay:r(t,s,o)}),e.duration,e.easing)}flowArrangement(){return this}shapeGraphics(){return new rt().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}renderSelf(e){let t=this.fill;t.length!==0&&e.draw(this.shapeGraphics().fill(t))}renderOverlay(e){let t=this.overlay;t.length!==0&&e.draw(this.shapeGraphics().fill(t))}acceptsChild(e){return e.dimension==="2d"||e.dimension==="audio"}get _childTrees(){return["2d","audio"]}get childrenAudio(){return this._allChildren.filter(e=>e instanceof ht)}declareAssets(e){super.declareAssets(e),e.fill(this.fill),e.fill(this.overlay)}clipSelf(){return new xs().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?hs:super._projection()}renderChildren(e){let t=this._spaceCamera();if(t){this._renderInSpace(e,Xt(this,t));return}if(this.zoom===1&&this.heading===0&&this.lookAt.x===0&&this.lookAt.y===0){super.renderChildren(e);return}let s=this.layoutBounds,r=s?.width??0,o=s?.height??0,i=s?.x??0,a=s?.y??0;e.beginCamera({x:i,y:-a,width:r,height:o},this.lookAt,this.zoom,this.heading);for(let c of this._children)c instanceof R&&c.render(e);e.endCamera()}};ro(Ie,{fill:ws(),overlay:ws(),flow:mo(),gap:ne({default:0}),wrap:ne({default:!1}),crossGap:ne({default:void 0}),columns:ne({default:1}),align:po(),zoom:ne({default:1}),lookAt:ne({default:{x:0,y:0},tween:ct}),heading:ne({default:0}),space3D:ne({default:!1}),orbit:ne({default:0}),elevation:ne({default:0}),dolly:ne({default:0}),zoomTo:ke({args:[{key:"zoom",kind:"number",min:.01,step:.1,unit:"\xD7"}]}),panTo:ke({args:[{key:"lookAt",kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}]}),orbitTo:ke({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",step:1,unit:"\xB0"}]}),dollyTo:ke({args:[{key:"dolly",kind:"number",step:10}]}),headingTo:ke({args:[{key:"heading",kind:"number",step:1,unit:"\xB0"}]}),fillTo:ke(),overlayTo:ke()});var dn={cornerRadius:k.number(0),cornerStyle:k.custom("rounded",{lerp:Qn})},ui=T({key:"rect",state:{...F,...B,...Se},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Be(n.size,e))}),li=T({key:"ellipse",state:{...F,...B,startAngle:k.number(0),sweep:k.number(360),ratio:k.number(0)},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Eo(n.size,e))}),fi=T({key:"polygon",state:{...F,...B,sides:k.number(5),...dn},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Co(n.size,e))}),hi=T({key:"polygram",state:{...F,...B,sides:k.number(5),ratio:k.number(.5),...dn},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Po(n.size,e))}),pi=T({key:"path",state:{...F,...B,data:k.path},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Io(n.size,e.data),{clipShape:Qt(n.size)})}),Sg=T({key:"facePath",state:{...F,...B,data:k.path},defaults:{width:"hug",height:"hug"},commands:{...$},measure:(n,e)=>{let t=is.size(e.data),s=e.padding;return{width:t.width+s.left+s.right,height:t.height+s.top+s.bottom}},layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Do(e.data),{clipShape:null})});function xt(n,e){return T({key:n,state:{...F,...B,...dn},commands:{...$},measure:(t,s,r)=>K(t,s,r,E(s)),layout:(t,s,r)=>z(t,s,r,E(s)),render:(t,s)=>Q(t,s,Ms(e,t.size,s),{clipShape:Qt(t.size)})})}var Ag=xt("triangle","triangle"),Mg=xt("rightTriangle","rightTriangle"),Og=xt("pentagon","pentagon"),Tg=xt("hexagon","hexagon"),Eg=xt("octagon","octagon"),Cg=T({key:"star",state:{...F,...B,...dn,points:k.number(bo),ratio:k.number(vo)},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Ms("star",n.size,{cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle,sides:Math.max(3,Math.round(e.points)),ratio:e.ratio}),{clipShape:Qt(n.size)})});var mi=T({key:"boolean",state:{...F,...B,op:k.oneOf(["union","subtract","intersect","exclude"])},commands:{...$},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>n.merge(e.op,e)}),gi=T({key:"mask",state:{mode:k.oneOf(["alpha","vector","luminance"]),inverted:!1},render:(n,e)=>n.mask(e)});var wi=T({key:"camera",state:{...F,...B,...Fo,...Se},commands:{...$,...$o},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Q(n,e,Be(n.size,e),{children:()=>No(n,e)})}),yi={lookAt:k.custom({x:0,y:0},{lerp:ct,kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}),zoom:k.number(1,{min:.01,step:.1,unit:"\xD7"}),heading:k.number(0,{step:1,unit:"\xB0"}),orbit:k.number(0,{step:1,unit:"\xB0"}),elevation:k.number(0,{step:1,unit:"\xB0"}),dolly:k.number(0,{step:10}),orbitSpeed:k.number(0)},xi=T({key:"orbitCamera",state:yi,defaults:{width:"hug",height:"hug",perspective:1e3},commands:To(yi,{orbitTo:{args:["orbit","elevation"]},dollyTo:{args:["dolly"]},zoomTo:{args:["zoom"]},panTo:{args:["lookAt"]},headingTo:{args:["heading"]}}),render:(n,e)=>n.space({perspective:e.perspective,orbit:e.orbit+e.orbitSpeed*n.time.total,elevation:e.elevation,dolly:e.dolly,lookAt:e.lookAt,zoom:e.zoom,heading:e.heading,viewportX:0,viewportY:0})}),vi=T({key:"rotated-box",state:{angle:k.number(-90)},defaults:{rotation:n=>n.angle},measure:(n,e,t)=>{let{cos:s,sin:r}=_i(e.angle),{width:o,height:i}=n.max,a=Math.abs(e.angle%180)===90,c=o!==void 0&&i!==void 0?{width:o*s+i*r,height:o*r+i*s}:{width:a?i:o,height:a?o:i},d=0,u=0;for(let l of t){let f=l.measure(c);d=Math.max(d,f.width),u=Math.max(u,f.height)}return{width:d*s+u*r,height:d*r+u*s}},layout:(n,e,t)=>{let{cos:s,sin:r}=_i(e.angle),o={x:0,y:0,width:n.width*s+n.height*r,height:n.width*r+n.height*s};return z(o,e,t)}});function _i(n){let e=n*(Math.PI/180);return{cos:Math.abs(Math.cos(e)),sin:Math.abs(Math.sin(e))}}var{overlay:Hg,...Bs}=F,{overlayTo:Jg,...Vs}=$,js=n=>n.fontSize==="autofit"?"fill":"hug",Cd=[];function Pd(n){return n==null?null:n instanceof Hr?n.toCommands():n}function Id(n){return Array.isArray(n)?n.map(({fill:e,stroke:t,...s})=>({...s,...e===void 0?{}:{fill:ve.resolve(e)},...t===void 0?{}:{stroke:as.resolve(t)}})):[]}var Dd={...Bs,...en,text:k.text("",{typing:!0}),wrap:!1,path:k.custom(null,{resolve:Pd}),runs:k.custom([],{resolve:Id,animatable:!1})},zs=n=>({text:n.text,wraps:n.wrap,glyphPath:n.path,runs:n.runs}),un=T({key:"text",allowedChildren:[],state:Dd,defaults:{width:n=>n.fontSize==="autofit"||n.wrap?"fill":"hug",height:js},commands:{...Vs,append:{args:{text:k.text("",{multiline:!0})},run:(n,e)=>n.tween({text:e.text+n.args.text})},prepend:{args:{text:k.text("",{multiline:!0})},run:(n,e)=>n.tween({text:n.args.text+e.text})}},load:(n,e)=>Es(n,e,zs(e)),measure:(n,e)=>Os(n,e,zs(e)),render:(n,e)=>Ts(n,e,zs(e))}),Fd={...Bs,...en,value:0,format:k.custom("number"),customPattern:"",fractionDigits:0,grouped:!0,currencySymbol:"$"},Ls=n=>({text:Ro(n.value,zo(n)),wraps:!1,glyphPath:null,runs:Cd}),bi=T({key:"number",allowedChildren:[],state:Fd,defaults:{width:js,height:js},commands:{...Vs,countTo:{args:["value"]}},load:(n,e)=>Es(n,e,Ls(e)),measure:(n,e)=>Os(n,e,Ls(e)),render:(n,e)=>Ts(n,e,Ls(e))}),{verticalAlign:Zg,textDecoration:Qg,textCase:ey,minFontSize:ty,...$d}=en,ki=T({key:"richtext",allowedChildren:[],state:{...Bs,...$d,fontSize:k.number(48,{inherit:Uo("fontSize",{autofit:!1})}),spans:k.custom([],{resolve:n=>n==null?[]:Array.isArray(n)?n:[n]})},defaults:{width:"hug",height:"hug"},commands:{...Vs},load:(n,e)=>Vo(n,e),measure:(n,e)=>jo(n,e),render:(n,e)=>Bo(n,e)}),Si=T({key:"default-text-style",state:Go,provide:(n,e)=>Yo(n,e),render:(n,e)=>n.textStyle(Wo(e),()=>n.children())});var Ai=T({key:"provider",state:{context:k.custom(void 0),value:k.custom(void 0)},provide:n=>n.context?[pt(n.context,n.value!==void 0?n.value:n.context.defaultValue)]:[]}),Mi=T({key:"theme-provider",state:{theme:k.custom(void 0),data:k.custom(void 0),seed:k.custom(void 0)},provide:(n,e)=>{let t=[];return n.theme&&t.push(pt(Cs,{...e(Cs),...n.theme})),n.data&&t.push(pt(Ps,{...e(Ps),...n.data})),n.seed!==void 0&&t.push(pt(Ko,n.seed)),t}});var Oi=mt({key:"sound",state:{src:k.custom(void 0),trimStart:0,trimEnd:k.custom(void 0),loop:!1,speed:k.custom(1,{lerp:eo,kind:"audioParam"})},allowedChildren:[],commands:{play:(n,e)=>n.sound(e.src,{trimStart:e.trimStart,trimEnd:e.trimEnd,loop:e.loop,volume:e.volume,speed:e.speed,effects:e.effects,transitionIn:e.transitionIn,transitionOut:e.transitionOut})}}),Ti=mt({key:"audioBus",state:{solo:!1}});var Nd={src:k.custom(void 0),fit:k.custom(void 0),crop:k.insets,zoom:1,anchor:k.alignment,matrix:k.custom(void 0),filters:k.custom([],{resolve:n=>rs(n),lerp:ss}),playing:!0,timestamp:k.custom(void 0),trimStart:k.custom(void 0),trimEnd:k.custom(void 0),speed:k.custom(void 0),loop:k.custom(void 0),duration:k.custom(void 0),volume:1,muted:!1,audioEffects:k.custom([],{resolve:n=>Ee(n)}),bus:k.custom(void 0),segments:k.custom([])};function Rd(n,e){if(n.segments.length===0)return null;let t=0;for(let s of n.segments){if(e<=s.at)break;t+=Math.min(e-s.at,s.duration)*(s.speed??n.speed??1)}return t}function zd(n,e){let t=Rd(n,e);if(t===null)return;let s=n.trimStart??0,r=n.segments[0];return qr(t+(r?r.from-s:0),s,n.trimEnd??1/0,n.loop,n.duration)}var Ks=new WeakMap;function Ld(n,e,t){if(!e.src)return Ks.delete(n),null;let s=zd(e,t),r=e.crop,o=e.anchor,i=[e.src,e.fit??"",e.zoom,e.playing?1:0,r.left,r.right,r.top,r.bottom,o.x,o.y,e.timestamp??"",e.trimStart??"",e.trimEnd??"",e.speed??"",e.loop??"",e.duration??"",s??""].join("|"),a=Ks.get(n);if(a&&a.key===i)return a.fill;let c={type:"video",src:e.src,fit:e.fit,crop:e.crop,zoom:e.zoom,anchor:e.anchor,matrix:e.matrix,preset:{adjustments:e.filters},playing:e.playing,timestamp:e.timestamp??s,trimStart:e.trimStart,trimEnd:e.trimEnd,speed:e.speed,loop:e.loop,duration:e.duration},d=Ut(c);return Ks.set(n,{key:i,fill:d}),d}var Ei=T({key:"video",state:{...F,...B,...Se,...Nd},commands:{...$,play:{args:{from:k.custom(void 0),volume:k.custom(void 0),speed:k.custom(void 0)},run:(n,e)=>{let t=e,s=n.args.from!==void 0;if(!t.src||t.muted||!s&&!t.playing)return n.together([]);let r=n.args.speed??t.speed??1,o=!s&&(t.loop??"none")!=="none";return n.sound(t.src,{volume:n.args.volume??t.volume,loop:o,trimStart:s?n.args.from:t.trimStart,trimEnd:t.trimEnd,speed:r,effects:t.audioEffects,bus:t.bus,optional:!0,closed:!o})}}},load:(n,e)=>{e.src&&n.fill(Ut({type:"video",src:e.src,preset:{adjustments:e.filters},trimStart:e.trimStart,trimEnd:e.trimEnd}))},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>{let t=e,s=Ld(Oo(n).host,t,n.time.elapsed),r={width:n.size.width,height:n.size.height,cornerRadius:t.cornerRadius,cornerStyle:t.cornerStyle,start:t.start,end:t.end};Q(n,e,Be(n.size,e),{fill:[s??Zr,...e.fill],overlay:()=>s?new rt().mask().rect(r).fill([s]).applyMask().rect(r).fill(e.overlay).endMask():null})}});var De={orbit:0,elevation:0,distance:10};function Ci(n){return n.orbit!==void 0||n.elevation!==void 0||n.distance!==void 0}function Us(n){let e=Z(n.target??0);if(!Ci(n)){let i=n.lookAt??n.target;return{position:Z(n.position??0),lookAt:i===void 0?void 0:Z(i)}}let t=n.distance??De.distance,s=(n.orbit??De.orbit)*Math.PI/180,r=jd(n.elevation??De.elevation,-89.9,89.9)*Math.PI/180,o=Math.cos(r)*t;return{position:{x:e.x+Math.sin(s)*o,y:e.y+Math.sin(r)*t,z:e.z+Math.cos(s)*o},lookAt:e}}function jd(n,e,t){return n<e?e:n>t?t:n}var Pi=P({key:"group3d"}),vt={geometry:w(),...qo},Ii=P({key:"mesh3d",state:vt,render:(n,e)=>n.draw(sn(e,e.geometry))}),Fe={startAngle:w(),sweep:w()},$e=["startAngle","sweep"];function ee(n,e,t,s){return P({key:n,state:{...vt,...t},render:(r,o)=>r.draw(sn(o,ge(e,o,s)))})}var Di=ee("box3d","box",{width:w(),height:w(),depth:w(),cornerRadius:w(),segments:w()},["width","height","depth","cornerRadius","segments"]),Fi=ee("sphere3d","sphere",{radius:w(),segments:w(),...Fe,startLatitude:w(),latitudeSweep:w()},["radius","segments","startLatitude","latitudeSweep",...$e]),$i=ee("plane3d","plane",{width:w(),height:w(),segments:w()},["width","height","segments"]),Ni=ee("cylinder3d","cylinder",{radius:w(),height:w(),segments:w(),capped:w(),...Fe},["radius","height","segments","capped",...$e]),Ri=ee("cone3d","cone",{radius:w(),height:w(),segments:w(),capped:w(),...Fe},["radius","height","segments","capped",...$e]),zi=ee("torus3d","torus",{radius:w(),thickness:w(),segments:w(),...Fe},["radius","thickness","segments",...$e]),Li=ee("torus-knot3d","torusKnot",{radius:w(),thickness:w(),segments:w(),windings:w()},["radius","thickness","segments","windings"]),ji=ee("circle3d","circle",{radius:w(),segments:w(),...Fe},["radius","segments",...$e]),Bi=ee("ring3d","ring",{radius:w(),innerRadius:w(),segments:w(),...Fe},["radius","innerRadius","segments",...$e]),Vi=ee("capsule3d","capsule",{radius:w(),height:w(),segments:w()},["radius","height","segments"]),Ki=P({key:"polyhedron3d",state:{...vt,shape:k.custom("icosahedron"),radius:w(),segments:w()},render:(n,e)=>n.draw(sn(e,ge("polyhedron",e,["shape","radius","segments"])))}),Ui=ee("extrude3d","extrude",{path:w(),depth:w(),segments:w(),bevel:w()},["path","depth","segments","bevel"]),Gi=ee("lathe3d","lathe",{points:w(),segments:w(),...Fe},["points","segments",...$e]),Yi=ee("tube3d","tube",{points:w(),radius:w(),segments:w(),closed:w()},["points","radius","segments","closed"]),Wi=P({key:"instances3d",state:{...vt,instances:w(),colors:w()},render:(n,e)=>{!e.geometry||!e.instances?.length||n.draw(new fe().instances(e.geometry,Ho(e),e.instances,{colors:e.colors}))}}),Xi=P({key:"points3d",state:vt,render:(n,e)=>{e.geometry&&n.draw(new fe().points(e.geometry,Jo(e)))}}),qi=P({key:"line3d",state:{points:w(),geometry:w(),closed:k.custom(!1),segments:k.custom(!1),stroke:w(),opacity:w(),material:w()},render:(n,e)=>{!e.geometry&&!e.points?.length||n.draw(new fe().line({points:e.geometry?void 0:e.points,geometry:e.geometry,closed:e.closed,segments:e.segments,stroke:e.stroke,opacity:e.opacity,material:e.material}))}}),Hi=P({key:"sprite3d",state:{fill:k.custom(void 0,{lerp:Jr}),opacity:w(),material:w()},render:(n,e)=>n.draw(new fe().sprite({fill:e.fill,opacity:e.opacity,material:e.material}))}),Ji=P({key:"model3d",state:{src:w(),animation:w(),override:w()},render:(n,e)=>{e.src&&n.draw(new fe().model({src:e.src,animation:e.animation,override:e.override}))}}),Py=P({key:"modelView3d",state:{src:w(),animation:w(),override:w(),clip:"",clipTime:0},render:(n,e)=>{if(!e.src){n.draw(new fe().box({width:1,height:1,depth:1,material:{type:"basic",color:"#6b7280",wireframe:!0,transparent:!0,opacity:.7}}));return}n.draw(new fe().model({src:e.src,animation:{clip:Bd(e.clip),time:e.clipTime},override:e.override}))}});function Bd(n){let e=n.trim();if(e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=0?t:e}var Gs={shadow:!1},Zi=P({key:"ambient-light3d",state:{color:me(),intensity:w()},render:(n,e)=>n.light(ge("ambient",e,["color","intensity"]))}),Qi=P({key:"hemisphere-light3d",state:{sky:me(),ground:me(),intensity:w()},render:(n,e)=>n.light(ge("hemisphere",e,["sky","ground","intensity"]))}),ea=P({key:"directional-light3d",state:{color:me(),intensity:w(),target:nn("origin")},defaults:Gs,render:(n,e)=>n.light(ge("directional",e,["color","intensity","target","shadow"]))}),ta=P({key:"point-light3d",state:{color:me(),intensity:w(),distance:w(),decay:w()},defaults:Gs,render:(n,e)=>n.light(ge("point",e,["color","intensity","distance","decay","shadow"]))}),na=P({key:"spot-light3d",state:{color:me(),intensity:w(),distance:w(),angle:w(),penumbra:w(),decay:w(),target:nn("origin")},defaults:Gs,render:(n,e)=>n.light(ge("spot",e,["color","intensity","distance","angle","penumbra","decay","target","shadow"]))}),sa=P({key:"area-light3d",state:{color:me(),intensity:w(),width:w(),height:w()},render:(n,e)=>n.light(ge("area",e,["color","intensity","width","height"]))}),Vd=["target","orbit","elevation","distance","fov","frustumHeight","near","far","zoom"],Kd=["orbit","elevation","distance"],ra=P({key:"camera3d",state:{type:k.custom("perspective"),target:nn("origin"),orbit:w(),elevation:w(),distance:w(),fov:w(),frustumHeight:w(),near:w(),far:w(),zoom:w()},commands:{orbitTo:{args:{orbit:tn({step:1,unit:"\xB0"}),elevation:tn({min:-89,max:89,step:1,unit:"\xB0"}),distance:tn({min:.01,step:.1})},run:(n,e)=>{let t={orbit:e.orbit??De.orbit,elevation:e.elevation??De.elevation,distance:e.distance??De.distance};return n.animate(s=>{let r={};for(let o of Kd){let i=n.args[o];i!==void 0&&(r[o]=t[o]+(i-t[o])*s)}return r})}},lookTo:{args:["target"]}},render:(n,e)=>{let t={type:e.type};for(let s of Vd)e[s]!==void 0&&(t[s]=e[s]);n.camera(t)}}),oa=P({key:"fog3d",state:{color:me(),near:w(),far:w(),density:w()},render:(n,e)=>{let t={};e.color!==void 0&&(t.color=e.color),e.density!==void 0?t.density=e.density:(e.near!==void 0&&(t.near=e.near),e.far!==void 0&&(t.far=e.far)),n.fog(t)}}),ia=P({key:"environment3d",state:{src:w(),faces:w(),preset:w(),intensity:w(),background:w(),blur:w()},render:(n,e)=>{if(e.src===void 0&&e.faces===void 0&&e.preset===void 0)return n.environment(null);let t=Xo(e,["src","faces","preset","intensity","background","blur"]);(e.rotationX||e.rotationY||e.rotationZ)&&(t.rotation=[e.rotationX,e.rotationY,e.rotationZ]),n.environment(t)}});var aa=T({key:"canvas3d",state:{...F,...B,...Se,...Zo},defaults:{width:"fill",height:"fill"},commands:{...$,...Qo},allowedChildren:["2d","3d"],load:n=>ei(n),measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>ti(n,e)});function Ue(n){return n.kind==="still"}function Ry(n){return n.kind==="composition"}function ln(n){return n.kind==="audio"}function Ud(n){return n.kind!=="still"}var b="";function U(n){let e=n;return{start:e.startAt??0,end:e.endAt??1/0}}function zy(n,e){return Ge(new Map(n.map(t=>[t.id,t])),e)}function ca(n){let e=new Map(n.map(o=>[o.id,o])),t=new Map,s=[],r=new Set;for(let o of e.values()){if(t.has(o.id))continue;s.length=0,r.clear();let i,a=o;for(;a;){let c=t.get(a.id);if(c){i=c;break}if(r.has(a.id)){for(let d of s)t.set(d.id,Ge(e,d.id));s.length=0;break}s.push(a),r.add(a.id),a=a.parentId===null?void 0:e.get(a.parentId)}for(let c=s.length-1;c>=0;c--){let d=U(s[c]);i&&(d.start=Math.max(d.start,i.start),d.end=Math.min(d.end,i.end)),t.set(s[c].id,d),i=d}}return t}function Ge(n,e){let t=n.get(e);if(!t)return;let s=U(t),r=new Set;for(;t.parentId!==null&&!r.has(t.id);){r.add(t.id);let o=n.get(t.parentId);if(!o)break;let i=U(o);s.start=Math.max(s.start,i.start),s.end=Math.min(s.end,i.end),t=o}return s}function Ly(n){let{startAt:e,endAt:t,...s}=n;return s}function Gd(n){let e=n.duration??0;return e<=0||!n.loop||n.loop.count===null?e:e*io(n.loop)}function ue(n){if(!Ud(n))return 0;if(n.duration!==void 0)return n.duration;let e=0;for(let t of n.commands)e=Math.max(e,t.at+Gd(t));for(let t of n.nodes)t.startAt!==void 0&&(e=Math.max(e,t.startAt)),t.endAt!==void 0&&Number.isFinite(t.endAt)&&(e=Math.max(e,t.endAt));return e}function Yd(n){return typeof n=="object"&&n!==null&&n.kind==="project"}function da(n,e={}){return Yd(n)?n:{kind:"project",...n.formatVersion!==void 0&&{formatVersion:n.formatVersion},name:e.name??"Untitled",fps:e.fps,viewport:e.viewport,theme:n.theme,tracks:[{id:"clip",clip:n,duration:ue(n)}]}}var Xs=3,kt=class extends Error{version;supported;constructor(e,t=3){super(`This document is format ${e}, newer than this engine reads (format ${t}). Open it with a newer engine.`),this.name="DocumentTooNewError",this.version=e,this.supported=t}},ua=[{from:0,description:"Documents start carrying `formatVersion`; a clip's retired `constants` rows become `variables`.",clip:(n,e)=>{if(!Array.isArray(n.constants))return n;let{constants:t,...s}=n,r=Array.isArray(s.variables)?[...s.variables]:[];for(let o of t){if(typeof o!="object"||o===null){r.push(o);continue}let{kind:i,...a}=o;r.push(a)}return e("constants",`${t.length} constant row(s) moved into \`variables\`.`),{...s,variables:r}}},{from:1,description:'SkSL is retired: every shader fill, shader effect and shader pack written in it says `language: "sksl"`, the `sksl` effect key becomes `shader`, and `coords` is dropped.',clip:(n,e)=>Ys(n,"",e)},{from:2,description:"An image or video fill's retired `filters` prop moves into `preset.adjustments`.",clip:(n,e)=>Ws(n,"",e)}],Wd=/\b(?:half4|float4|vec4)\s+main\s*\(|^\s*uniform\s+\w+\s+\w+/m,bt=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function Ys(n,e,t){if(Array.isArray(n)){let r;return n.forEach((o,i)=>{let a=Ys(o,`${e}[${i}]`,t);a!==o&&((r??=[...n])[i]=a)}),r??n}if(!bt(n))return n;let s;for(let[r,o]of Object.entries(n)){let i=Ys(o,e?`${e}.${r}`:r,t);i!==o&&((s??={...n})[r]=i)}return Xd(s??n,e,t)}function Xd(n,e,t){let s=n.type==="sksl";if(!(s||n.type==="shader"&&(typeof n.source=="string"||typeof n.shader=="string")||(n.scope==="fill"||n.scope==="effect")&&typeof n.source=="string"))return n;let o={...n};s&&(o.type="shader");let i=o.type==="shader"&&typeof o.shader=="string"&&o.source===void 0;i&&(o.source=o.shader,delete o.shader);let a=o.language==="sksl"||o.language===void 0&&(s||Wd.test(typeof o.source=="string"?o.source:"")),c=a&&o.language===void 0;c&&(o.language="sksl");let d="coords"in o;return delete o.coords,a?t(e,"SkSL shaders no longer draw; port it to WGSL."):s?t(e,"The retired `sksl` effect key is now `shader`."):i?t(e,"The shader's `shader` field is now `source`."):d&&t(e,"`coords` dropped; it only ever applied to SkSL."),s||i||c||d?o:n}function Ws(n,e,t){if(Array.isArray(n)){let d;return n.forEach((u,l)=>{let f=Ws(u,`${e}[${l}]`,t);f!==u&&((d??=[...n])[l]=f)}),d??n}if(!bt(n))return n;let s;for(let[d,u]of Object.entries(n)){let l=Ws(u,e?`${e}.${d}`:d,t);l!==u&&((s??={...n})[d]=l)}let r=s??n;if(!("filters"in r)||!(r.type==="image"||r.type==="video")||typeof r.src!="string")return r;let{filters:o,preset:i,...a}=r,c=bt(i)&&i.adjustments!==void 0;return t(e,c?"`filters` dropped; the fill's `preset.adjustments` already says the grade.":"`filters` moved to `preset.adjustments`."),c||i!==void 0&&!bt(i)?{...a,preset:i}:{...a,preset:{...bt(i)?i:{},adjustments:o}}}function qs(n){if(typeof n!="object"||n===null)return 0;let e=n.formatVersion;if(e===void 0)return 0;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new TypeError(`formatVersion must be a whole number >= 0 (got ${JSON.stringify(e)}).`);return e}function Hs(n){return qd(n,ua,3)}function qd(n,e,t){let s=qs(n);if(s>t)throw new kt(s,t);if(typeof n!="object"||n===null||Array.isArray(n))return{document:n,from:s,to:s,changes:[]};let r=[],o=n;return{document:o.kind==="project"?Hd(o,s,e,t,r):ha(o,s,e,t,r,""),from:s,to:t,changes:r}}function la(n,e,t){let s=[];for(let r=n;r<e;r++){let o=t.find(i=>i.from===r);if(!o)throw new Error(`No document migration from format ${r} to ${r+1}.`);s.push(o)}return s}function fa(n,e,t){return(s,r)=>n.push({from:e,path:t&&s?`${t}.${s}`:t||s,message:r})}function ha(n,e,t,s,r,o,i=!0){if(e===s)return n;let a=n;for(let c of la(e,s,t))c.clip&&(a=c.clip(a,fa(r,c.from,o)));return i?{...a,formatVersion:s}:a}function Hd(n,e,t,s,r){let o=n;if(e<s)for(let c of la(e,s,t))c.project&&(o=c.project(o,fa(r,c.from,"")));let i=!1,a=Array.isArray(o.tracks)?o.tracks.map((c,d)=>{if(typeof c!="object"||c===null)return c;let u=c.clip;if(typeof u!="object"||u===null||Array.isArray(u))return c;let l=u.formatVersion!==void 0,f=l?qs(u):e;if(f>s)throw new kt(f,s);let h=ha(u,f,t,s,r,`tracks[${d}].clip`,l);return h===u?c:(i=!0,{...c,clip:h})}):o.tracks;return e===s&&!i?n:{...o,...i?{tracks:a}:{},formatVersion:s}}var pa=new Set(["normal","reverse","alternate"]);function L(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ie(n){return typeof n=="number"&&Number.isFinite(n)&&n>=0}function _a(n,e,t){if(n===void 0)return;if(!L(n)){t.push({path:e,message:"easing must be an object with a `kind`."});return}let{kind:s,args:r}=n;if(typeof s!="string"||!ds.has(s)){t.push({path:`${e}.kind`,message:`easing kind must be one of ${[...ds].join(", ")} (got ${JSON.stringify(s)}).`});return}s==="custom"&&r!==void 0&&typeof r!="string"&&!cs(r)&&t.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 wa(n,e,t){_a(n,e,t),L(n)&&n.kind==="custom"&&!cs(n.args)&&t.push({path:`${e}.args`,message:"an audio ease cannot name a registered ease; draw its curve (two or more `{ x, y }` points) instead."})}function ma(n,e,t){if(!(n===void 0||typeof n=="number"&&Number.isFinite(n)||I.isSource(n))){if(!L(n)||!Array.isArray(n.keys)){t.push({path:e,message:"must be a finite number, an expression or a ramp, `{ keys: [{ at, value }, \u2026] }`."});return}n.keys.forEach((s,r)=>{let o=`${e}.keys[${r}]`;if(!L(s)){t.push({path:o,message:"a ramp key must be an object."});return}(s.at===void 0==(s.before===void 0)||!ie(s.at??s.before))&&t.push({path:o,message:"a ramp key needs exactly one of `at` (seconds after the start) or `before` (seconds before the end), >= 0."}),(typeof s.value!="number"||!Number.isFinite(s.value))&&t.push({path:`${o}.value`,message:"a ramp key's value must be a finite number."}),wa(s.ease,`${o}.ease`,t)})}}var Jd=new Set(["duration","curve"]);function ga(n,e,t){if(n!==void 0){if(!L(n)){t.push({path:e,message:"a transition must be an object, `{ duration, curve? }`."});return}ie(n.duration)||t.push({path:`${e}.duration`,message:"a transition's duration must be a finite number of seconds >= 0."}),n.curve!==void 0&&n.curve!=="equalPower"&&wa(n.curve,`${e}.curve`,t);for(let s of Object.keys(n))Jd.has(s)||t.push({path:`${e}.${s}`,message:`a transition has no "${s}" (yet): only duration and curve.`})}}function Zd(n,e,t,s){"filters"in e&&s.push({path:`${t}.filters`,message:"audio `filters` was renamed to `effects`."});for(let o of["volume","pan",...n==="sound"?["speed"]:[]])ma(e[o],`${t}.${o}`,s);n==="sound"&&e.loop===!0&&L(e.speed)&&s.push({path:`${t}.speed`,message:"a looping sound cannot ramp its speed: there is no one pass of the source for the ramp to run over."});let r=e.effects;r!==void 0&&(Array.isArray(r)?r:[r]).forEach((i,a)=>{let c=Array.isArray(r)?`${t}.effects[${a}]`:`${t}.effects`;if(!L(i)||typeof i.type!="string"){s.push({path:c,message:"an effect must be an object with a `type`."});return}for(let[d,u]of Object.entries(i))d!=="type"&&ma(u,`${c}.${d}`,s)}),ga(e.transitionIn,`${t}.transitionIn`,s),ga(e.transitionOut,`${t}.transitionOut`,s)}function Qd(n,e,t){if(n===void 0)return;if(!L(n)){t.push({path:e,message:"loop must be an object with a `count`."});return}let{direction:s,count:r}=n;r!==null&&(typeof r!="number"||!Number.isInteger(r)||r<0)&&t.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."}),s!==void 0&&!pa.has(s)&&t.push({path:`${e}.direction`,message:`loop direction must be one of ${[...pa].join(", ")} (got ${JSON.stringify(s)}).`})}function eu(n,e,t){if(!L(n))return t.push({path:e,message:"node must be an object."}),!1;let s=!0,{id:r,type:o,parentId:i,layerOrder:a,props:c,key:d}=n;return typeof r!="string"&&(t.push({path:`${e}.id`,message:"id must be a string."}),s=!1),(typeof o!="string"||o.length===0)&&(t.push({path:`${e}.type`,message:"type must be a non-empty string."}),s=!1),i!==null&&typeof i!="string"&&(t.push({path:`${e}.parentId`,message:"parentId must be a node id or null."}),s=!1),(typeof a!="number"||!Number.isFinite(a))&&(t.push({path:`${e}.layerOrder`,message:"layerOrder must be a finite number."}),s=!1),L(c)?(o==="sound"||o==="audioBus")&&Zd(o,c,`${e}.props`,t):(t.push({path:`${e}.props`,message:"props must be an object (`{}` when nothing is set)."}),s=!1),d!==void 0&&(typeof d!="string"||d.length===0?(t.push({path:`${e}.key`,message:"key must be a non-empty string when present."}),s=!1):(d.includes("]")||d.includes("."))&&(t.push({path:`${e}.key`,message:`node key "${d}" cannot contain "]" or "." \u2014 it is referenced as "[${d}.prop]".`}),s=!1)),s}function xa(n,e){let t=new Map;for(let s of n){let r=s.spec.key;if(typeof r!="string"||r.length===0)continue;let o=t.get(r);if(o){e.push({path:`${s.path}.key`,message:`duplicate node key "${r}" (also declared at ${o.path}).`});continue}t.set(r,s)}return t}function tu(n,e,t,s){n.id===""&&(n.type!==t||n.parentId!==null)&&s.push({path:e,message:`the node with id "" is this document's root and must be \`{ type: "${t}", parentId: null }\`.`})}function nu(n,e,t){if(!L(n))return t.push({path:e,message:"command must be an object."}),!1;let s=!0,{id:r,type:o,targetId:i,at:a,duration:c,args:d}=n;return(typeof r!="string"||r.length===0)&&(t.push({path:`${e}.id`,message:"id must be a non-empty string."}),s=!1),(typeof o!="string"||o.length===0)&&(t.push({path:`${e}.type`,message:"type must be a non-empty string."}),s=!1),i!==null&&typeof i!="string"&&(t.push({path:`${e}.targetId`,message:"targetId must be a node id, or null for the scene root."}),s=!1),ie(a)||(t.push({path:`${e}.at`,message:"at must be a finite number of seconds >= 0."}),s=!1),c!==void 0&&!ie(c)&&(t.push({path:`${e}.duration`,message:"duration must be a finite number of seconds >= 0."}),s=!1),L(d)||(t.push({path:`${e}.args`,message:"args must be an object (`{}` when there are none)."}),s=!1),_a(n.easing,`${e}.easing`,t),Qd(n.loop,`${e}.loop`,t),s}function su(n,e,t){if(!L(n))return t.push({path:e,message:"variable must be an object."}),!1;let s=!0,{id:r,name:o,value:i,lerp:a}=n;return typeof r!="string"||r.length===0?(t.push({path:`${e}.id`,message:"id must be a non-empty string."}),s=!1):r.includes("]")&&(t.push({path:`${e}.id`,message:`variable id "${r}" cannot contain "]" \u2014 it is referenced as "[${r}]".`}),s=!1),o!==void 0&&typeof o!="string"&&(t.push({path:`${e}.name`,message:"name must be a string when present."}),s=!1),"value"in n?I.isSource(i)&&(t.push({path:`${e}.value`,message:"a variable holds a value, not an expression \u2014 only a node prop can be bound."}),s=!1):(t.push({path:`${e}.value`,message:"value is required \u2014 a variable is what it holds before anything changes it."}),s=!1),a!==void 0&&typeof a!="string"&&(t.push({path:`${e}.lerp`,message:"lerp must be a registered lerp key when present."}),s=!1),s}function va(n,e){if(n===void 0)return[];if(!Array.isArray(n))return e.push({path:"variables",message:"variables must be an array."}),[];let t=[];return n.forEach((s,r)=>{let o=`variables[${r}]`;su(s,o,e)&&t.push({spec:s,path:o})}),t}function ba(n,e){let t=new Map;for(let s of n){let r=t.get(s.spec.id);if(r){e.push({path:`${s.path}.id`,message:`duplicate variable id "${s.spec.id}" (also declared at ${r.path}).`});continue}t.set(s.spec.id,s)}return t}function ka(n){let e=n.indexOf(".");return e<0?void 0:{key:n.slice(0,e),prop:n.slice(e+1)}}function Js(n,e,t,s,r){for(let o of I.collect(n,e)){let i=I.tryParse(o.source);if("error"in i){r.push({path:o.path,message:i.error});continue}for(let a of i.expression.refs){let c=ka(a);if(!c){if(t.has(a))continue;r.push({path:o.path,message:s.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: ${[...t].map(d=>`[${d}]`).join(", ")||"none"}.`});continue}if(c.key.length===0||c.prop.length===0||c.prop.includes(".")){r.push({path:o.path,message:`expression references "[${a}]", which is not a node reference \u2014 one is "[key.prop]".`});continue}s.has(c.key)||r.push({path:o.path,message:`expression references "[${a}]", but no node in this document is keyed "${c.key}". Keyed: ${[...s].join(", ")||"none"}.`})}}}function Zs(n,e,t,s){if(L(e))for(let r of Object.keys(e)){let o=[];for(let i of I.collect(e[r],`${t}.${r}`)){let a=I.tryParse(i.source);if(!("error"in a))for(let c of a.expression.refs)ka(c)&&o.push(c)}o.length>0&&s.push({id:`${n}.${r}`,path:`${t}.${r}`,reads:o})}}function Sa(n,e){let t=new Map(n.map(a=>[a.id,a])),s=new Set,r=[],o=new Set,i=a=>{let c=t.get(a);if(!c||s.has(a))return;let d=r.indexOf(a);if(d>=0){if(!o.has(a)){let u=[...r.slice(d),a];for(let l of u)o.add(l);e.push({path:c.path,message:`expression cycle ${u.join(" \u2192 ")} \u2014 a prop cannot read a prop that reads it back.`})}return}r.push(a);for(let u of c.reads)i(u);r.pop(),s.add(a)};for(let a of n)i(a.id)}function ru(n,e){let t=new Map;for(let r of n){if(t.has(r.spec.id)){e.push({path:`${r.path}.id`,message:`duplicate node id "${r.spec.id}".`});continue}t.set(r.spec.id,r)}for(let r of n){let o=r.spec.parentId;o!==null&&!t.has(o)&&e.push({path:`${r.path}.parentId`,message:`parentId "${o}" is not a node in this document.`})}let s=new Set;for(let{spec:r}of n){if(s.has(r.id))continue;let o=new Set,i=r;for(;i;){if(o.has(i.id)){e.push({path:`${t.get(i.id)?.path}.parentId`,message:`node "${i.id}" is its own ancestor \u2014 parent chain forms a cycle.`});break}if(o.add(i.id),s.has(i.id))break;let a=i.parentId;i=a===null?void 0:t.get(a)?.spec}for(let a of o)s.add(a)}}function Aa(n,e,t){for(let s of n){let r=e.get(s.id);r&&t.push({path:`${r.path}.id`,message:`"${s.id}" is already a node id \u2014 nodes and variables share one id space.`})}}function Ma(n,e){n.constants!==void 0&&e.push({path:"constants",message:"constants were merged into `variables` \u2014 move each row there and drop its `kind`."})}function Oa(n,e){let t=n.formatVersion;t!==void 0&&(typeof t!="number"||!Number.isInteger(t)||t<0?e.push({path:"formatVersion",message:"formatVersion must be a whole number >= 0 when present."}):t>3&&e.push({path:"formatVersion",message:`format ${t} is newer than this engine reads (${3}) \u2014 open it with a newer engine.`}))}var ou={visualTracks:"visual and audio tracks were merged into `tracks` \u2014 move each row there.",audioTracks:"visual and audio tracks were merged into `tracks` \u2014 move each row there.",backgrounds:"a background is a track \u2014 put it first in `tracks`.",overlays:"an overlay is a track \u2014 put it last in `tracks`.",commands:"a project has no commands \u2014 each clip carries its own.",constants:"a project has no constants \u2014 declare `variables` in each clip."};function Ta(n,e,t,s,r,o){let i=new Map([["",t]]);for(let a of n)i.set(a.spec.id,a.spec.type),r.hasNode(a.spec.type)||o.push({path:`${a.path}.type`,message:`node type "${a.spec.type}" is not registered.`});for(let{spec:a,path:c}of e){if(r.command(a.type))continue;if(a.targetId!==null&&s.has(a.targetId)){o.push({path:`${c}.type`,message:`"${a.type}" is not a variable command.`});continue}let d=i.get(a.targetId??"");d===void 0||!r.hasNode(d)||r.takesCommand(d,a.type)||o.push({path:`${c}.type`,message:`node type "${d}" has no command "${a.type}".`})}}function Ea(n,e,t){if(!Array.isArray(n))return t.push({path:"nodes",message:"nodes must be an array."}),[];let s=[];return n.forEach((r,o)=>{let i=`nodes[${o}]`;eu(r,i,t)&&(s.push({spec:r,path:i}),tu(r,i,e,t))}),ru(s,t),s}function iu(n,e,t){let{startAt:s,endAt:r}=n;s!==void 0&&!ie(s)&&t.push({path:`${e}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),r!==void 0&&!ie(r)&&t.push({path:`${e}.endAt`,message:"endAt must be a finite number of seconds >= 0."}),ie(r)&&r<=(ie(s)?s:0)&&t.push({path:`${e}.endAt`,message:`endAt (${r}s) must be after startAt (${s??0}s).`}),n.id===""&&(s!==void 0||r!==void 0)&&t.push({path:e,message:"the root is present for the whole clip \u2014 it cannot carry startAt or endAt."})}function au(n,e,t){Ma(n,e),n.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 s=ba(va(n.variables,e),e),r=Ea(n.nodes,"canvas2d",e);for(let u of r){let{startAt:l,endAt:f}=u.spec;(l!==void 0||f!==void 0)&&e.push({path:u.path,message:"a still has no timeline \u2014 drop startAt/endAt, or make it a composition."})}let o=r.map(u=>u.spec);Aa(o,s,e),t&&Ta(r,[],"canvas2d",s,t,e);let i=xa(r,e),a=new Set(s.keys()),c=new Set(i.keys()),d=[];for(let u of r)Js(u.spec.props,`${u.path}.props`,a,c,e),u.spec.key&&Zs(u.spec.key,u.spec.props,`${u.path}.props`,d);Sa(d,e)}function cu(n,e,t){Ca(n,"canvas2d",e,t)}function du(n,e,t){Ca(n,"audioBus",e,t)}var uu={add:"a node is a row in `nodes` \u2014 its `startAt` is when it enters.",variable:"a variable is declared in `variables`."};function Ca(n,e,t,s){if(Ma(n,t),!Array.isArray(n.commands)){t.push({path:"commands",message:"commands must be an array."});return}n.duration!==void 0&&!ie(n.duration)&&t.push({path:"duration",message:"duration must be a finite number of seconds >= 0."});let r=ba(va(n.variables,t),t),o=Ea(n.nodes,e,t);for(let p of o)iu(p.spec,p.path,t);let i=o.map(p=>p.spec);Aa(i,r,t);let a=xa(o,t),c=[],d=new Set;n.commands.forEach((p,g)=>{if(!nu(p,`commands[${g}]`,t))return;if(d.has(p.id)){t.push({path:`commands[${g}].id`,message:`duplicate command id "${p.id}".`});return}let m=uu[p.type];if(m){t.push({path:`commands[${g}].type`,message:`there is no "${p.type}" command \u2014 ${m}`});return}d.add(p.id),c.push({spec:p,path:`commands[${g}]`})});let u=new Map(i.map(p=>[p.id,p]));s&&Ta(o,c,e,r,s,t);for(let{spec:p,path:g}of c){if(p.targetId===null||r.has(p.targetId))continue;let m=Ge(u,p.targetId);m===void 0?t.push({path:`${g}.targetId`,message:`targetId "${p.targetId}" is not a node or variable in this document.`}):p.at<m.start&&t.push({path:`${g}.at`,message:`command runs at ${p.at}s but its target "${p.targetId}" is not present until ${m.start}s.`})}let l=new Set(r.keys()),f=new Set(a.keys());for(let p of o)Js(p.spec.props,`${p.path}.props`,l,f,t);for(let{spec:p,path:g}of c)Js(p.args,`${g}.args`,l,f,t);let h=[];for(let p of o)p.spec.key&&Zs(p.spec.key,p.spec.props,`${p.path}.props`,h);for(let{spec:p,path:g}of c){if(p.type!=="set"||p.targetId===null)continue;let m=u.get(p.targetId)?.key;m&&Zs(m,p.args,`${g}.args`,h)}Sa(h,t)}function Qs(n,e={}){let t=[];if(!L(n))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};Oa(n,t);let{registry:s}=e,r=n.kind;return r==="still"?au(n,t,s):r==="composition"?cu(n,t,s):r==="audio"?du(n,t,s):t.push({path:"kind",message:`kind must be "still", "composition" or "audio" (got ${JSON.stringify(r)}).`}),{valid:t.length===0,issues:t}}function lu(n,e={}){let t=[];if(!L(n))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};let s=n;s.kind!=="project"&&t.push({path:"kind",message:`kind must be "project" (got ${JSON.stringify(s.kind)}).`}),(typeof s.name!="string"||s.name.length===0)&&t.push({path:"name",message:"name must be a non-empty string."}),s.fps!==void 0&&(typeof s.fps!="number"||!(s.fps>0)||!Number.isFinite(s.fps))&&t.push({path:"fps",message:"fps must be a positive number when present."}),Oa(s,t);for(let[o,i]of Object.entries(ou))s[o]!==void 0&&t.push({path:o,message:i});if(!Array.isArray(s.tracks))return t.push({path:"tracks",message:"tracks must be an array."}),{valid:!1,issues:t};let r=new Set;return s.tracks.forEach((o,i)=>{let a=`tracks[${i}]`;if(!L(o)){t.push({path:a,message:"track must be an object."});return}let c=o;if(typeof c.id!="string"||c.id.length===0?t.push({path:`${a}.id`,message:"id must be a non-empty string."}):r.has(c.id)?t.push({path:`${a}.id`,message:`duplicate track id "${c.id}".`}):r.add(c.id),c.name!==void 0&&typeof c.name!="string"&&t.push({path:`${a}.name`,message:"name must be a string when present."}),c.startAt!==void 0&&!ie(c.startAt)&&t.push({path:`${a}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),ie(c.duration)||t.push({path:`${a}.duration`,message:"duration is required, and must be a finite number of seconds >= 0."}),c.clip===void 0){t.push({path:`${a}.clip`,message:"clip is required \u2014 a track places a clip document inline."});return}for(let d of fu(c.clip,e))t.push({path:`${a}.clip${d.path?`.${d.path}`:""}`,message:d.message})}),{valid:t.length===0,issues:t}}var ya=new WeakMap;function fu(n,e){if(!L(n)||e.registry)return Qs(n,e).issues;let t=ya.get(n);return t||(t=Qs(n).issues,ya.set(n,t)),t}function Pa(n,e){let{valid:t,issues:s}=lu(n,e);if(!t){let r=s.map(o=>` ${o.path||"<root>"}: ${o.message}`).join(`
|
|
2
2
|
`);throw new Error(`Invalid project document:
|
|
3
3
|
${r}`)}}function Zy(n,e){let{valid:t,issues:s}=Qs(n,e);if(!t){let r=s.map(o=>` ${o.path||"<root>"}: ${o.message}`).join(`
|
|
4
4
|
`);throw new Error(`Invalid clip document:
|
|
@@ -10,4 +10,4 @@ ${e}
|
|
|
10
10
|
|
|
11
11
|
Loading it directly also failed: ${String(o)}`))}),!0):!1}recordFor(e,t,s){try{return e==="font"?{type:"font",src:t,startFrame:s,endFrame:s,fontFamily:t,fontWeight:400}:e==="image"?(this.assetCatalog.getImageMeta(t),{type:"image",src:t,startFrame:s,endFrame:s}):(this.assetCatalog.getVideoMeta(t),{type:"video",src:t,startFrame:s,endFrame:s,trimStart:0,trimEnd:this.assetCatalog.getVideoDuration(t)})}catch{return null}}clearRenderErrors(){this.rescuedAssets.clear(),this.renderErrors.length!==0&&(this.renderErrors.length=0,this.onRenderError?.(this.buildErrors))}constructor(e){let{project:t}=e;if(t.fps===void 0||t.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=t.fps,this.viewport=t.viewport,this.precompBudgetMs=e.precompBudgetMs??jt,this.onPrecompProgress=e.onPrecompProgress,this.assetCatalog=e.assets;let s={registry:e.registry,viewport:this.viewport,fps:this.fps,assets:e.assets,measurer:this.measurer};this.store=new Oe(t,s,{profile:e.precompProfile,isReady:r=>this.assetManager?.isReady(r)??!1}),this.precomper=new Vn(t,s,{store:this.store}),this.precomp=this.precomper.ensureCovering(0),this.stateEvaluator=new jn(t,s,this.store),this.assetManager=new Cn(this.precomp,this.storageAdapter,this.audioDevice,r=>this.captureRenderError(r)),this.masterClock.setDuration(this.totalDuration),this.masterClock.onPlay((r,o,i)=>{this.audioDevice.play(r,o,i),this.storageAdapter.setPlaying(!0)}),this.masterClock.onPause(()=>{this.audioDevice.stop(),this.storageAdapter.setPlaying(!1)}),this.masterClock.onTick(async r=>{let o=++this.seekGeneration,i=xe(r,this.fps);i>=this.totalFrames&&this.masterClock.pause(),this.discoverThrough(i),await this.loadFrame(i),this.isCurrent(o)&&(this.audioDevice.syncTo(r),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 In();!this.disposed&&!this.precomp.complete;){let e=await this.precomper.runAsync({budgetMs:this.precompBudgetMs,isCancelled:()=>this.disposed,onProgress:t=>this.adoptPrecomp(t)});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 t=this.precomper.ensureCovering(Math.floor(e));t!==this.precomp&&this.adoptPrecomp(t)}async loadFrame(e){let t=[];for(let s of Me(this.store.spans,Math.floor(e)))for(let r of this.store.layoutGates(s.id))this.assetManager.isReady(r.src)||t.push(r);if(t.length===0){await this.assetManager.loadAt(e);return}await Promise.all([this.assetManager.loadAt(e),this.assetManager.loadRecords(t)])}trimAround(e){Math.abs(e-this.lastTrimFrame)<this.fps||(this.lastTrimFrame=e,this.store.trim(Math.floor(e),Math.ceil(Bf*this.fps)))}lastTrimFrame=0;get isPlaying(){return this.masterClock.isPlaying}get currentTime(){return this.masterClock.currentTime}get currentFrame(){return xe(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(Me(this.store.spans,Math.floor(e)).map(t=>t.id)),this.stateEvaluator.stateAt(e),this.applyOverrides(),this.stateEvaluator.layout(this.measurer),this.renderContext.execute(()=>{this.stateEvaluator.render(this.renderContext)});for(let t of this.renderContext.takeRenderIssues()){let s=wr(t);this.captureRenderError(new Error(s.message),void 0,s)}}catch(t){this.captureRenderError(t,e)}this.announcePaint(e)}}announcePaint(e){if(this.onFramePainted)try{this.onFramePainted(Math.floor(e))}catch(t){console.error("[PlaybackController] onFramePainted listener threw:",t)}}async seek(e){if(this.disposed)return;let t=++this.seekGeneration;this.paintInFlight=t;try{let s=Math.max(0,Math.min(e,this.totalFrames));if(this.masterClock.pause(),this.discoverThrough(s),this.masterClock.seek(Re(s,this.fps)),await this.loadFrame(s),!this.isCurrent(t)||await this.settle(()=>this.renderAt(s),t)==="superseded")return;this.assetManager.prefetch(s),this.trimAround(s)}finally{this.paintLanded(t)}}setProject(e){if(this.disposed)return;let t=++this.seekGeneration;this.precomper.setProject(e),this.stateEvaluator.setProject(e),this.discoverThrough(this.currentFrame),this.clearRenderErrors(),this.masterClock.setDuration(this.totalDuration);let s=Math.min(this.currentFrame,Math.max(0,this.totalFrames-1));this.pendingSwap=t,this.paintInFlight=t,this.lastReplacePaint=this.loadAndRepaint(s,t),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,t){try{try{await this.loadFrame(e)}catch(s){console.error("[PlaybackController] swap asset load failed:",s);return}await this.settle(()=>this.renderAt(e),t)}finally{this.pendingSwap===t&&(this.pendingSwap=0),this.paintLanded(t)}}seekWhilePlaying(e){++this.seekGeneration;let t=Math.max(0,Math.min(e,this.totalFrames));this.masterClock.seek(Re(t,this.fps))}async screenshot(){let e=this.stateEvaluator.currentFrame,t=++this.seekGeneration;this.paintInFlight=t;try{return await this.loadFrame(e),!this.isCurrent(t)||await this.settle(()=>this.renderAt(e),t,!0)==="superseded"?void 0:this.renderContext.screenshot()}finally{this.paintLanded(t)}}async settle(e,t,s=!1){let r=s?Vf(this.storageAdapter):this.storageAdapter,o=await Lc(e,r,()=>this.isCurrent(t));return o==="exhausted"&&console.warn(`[PlaybackController] frame ${this.stateEvaluator.currentFrame} still had decodes pending after ${4} passes`),o}paintInFlight=0;renders=0;repaintOwedSince=null;paintLanded(e){if(!(this.paintInFlight!==e||this.disposed)){if(this.paintInFlight=0,this.repaintOwedSince!==null){let t=this.renders===this.repaintOwedSince;this.repaintOwedSince=null,t&&!this.isPlaying&&this.renderAt(this.stateEvaluator.currentFrame)}this.settleTrailing()}}getTreeState(){let e=this.stateEvaluator.currentInstance;if(!e)return null;let t=this.precomp.tracks.find(c=>c.id===this.stateEvaluator.currentTrackId),s=t?.startFrame??0,r=t?.frameCount??He(e.duration,this.fps),o=new Map,i=new Map;e.forEachOwner((c,d,u,l)=>{i.set(d,l);let f=Je(u,this.fps,r);f&&o.set(l,{startFrame:s+f.startFrame,endFrame:s+f.endFrame})});let a=Uf(t?.audioRequests??[],i);return yd(e.canvas,"",o,a)}getNodeState(e){let t=this.stateEvaluator.currentCanvas;if(!t)return null;let s=_d(t,e);return s?{id:s.id,type:s.className,properties:s.properties}:null}getNodeInitialProps(e){return this.stateEvaluator.currentInstance?.baselineProps(e)??null}getNodeBox(e){let t=this.stateEvaluator.currentCanvas;return t?ad(t,e):null}getNodePropsAt(e){let t=this.stateEvaluator.currentCanvas;if(!t)return null;let s=Te(t,e);return s?s.properties:null}getNodeBoxes(){let e=this.stateEvaluator.currentCanvas;if(!e)return[];let t=[];return Kr(e,"",t,!0),t}projectNode3D(e,t,s){let r=this.stateEvaluator.currentCanvas;return r?dd(r,e,t,s):null}parentPlanePoint(e,t){let s=this.stateEvaluator.currentCanvas;return s?ed(s,e,t):null}childPlanePoint(e,t){let s=this.stateEvaluator.currentCanvas;return s?td(s,e,t):null}reparentPlacement(e,t,s){let r=this.stateEvaluator.currentCanvas;return r?nd(r,e,t,s):null}nodeHandles(e){let t=this.stateEvaluator.currentCanvas;return t?sd(t,e):null}handleValue(e,t,s){let r=this.stateEvaluator.currentCanvas;return r?rd(r,e,t,s):null}getTextLayout(e){let t=this.stateEvaluator.currentCanvas;if(!t)return null;let s=gd(t,e);return s instanceof R?this.textLayoutOf(s,e):null}textLayoutOf(e,t){let s=xc(this.measurer);return s?md(e,t,s):null}pickNode(e,t=0){let s=this.stateEvaluator.currentCanvas;return s?ud(s,e,t):null}setNodeOverride(e,t){let s=this.overrides.get(e);this.overrides.set(e,s?{...s,...t}:{...t}),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,t){this.stateEvaluator.setEditorStates(e,t),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[t,s]=await Promise.all([this.storageAdapter.warmPendingDecodes(),this.storageAdapter.warmPendingUpgrades()]);if(!(t||s)||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[t,s]of this.overrides)gd(e,t)?.set(s)}play(e=1,t=!1){if(this.currentFrame>=this.totalFrames){this.seek(0).then(()=>this.masterClock.play(e,t)).catch(()=>{});return}this.masterClock.play(e,t)}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()}},Bf=30;function Vf(n){return{async warmPendingDecodes(){let[e,t]=await Promise.all([n.warmPendingDecodes(),n.warmPendingUpgrades()]);return e||t}}}function Kf(n,e){switch(n.assetType){case"image":return{type:"image",src:n.src};case"font":return{type:"font",family:n.src,weight:400};case"video":try{return{type:"video",src:n.src,trimStart:0,trimEnd:e.getVideoDuration(n.src)}}catch{return}default:return}}function yd(n,e,t,s){let r={id:n.id,path:e,type:n.className,children:n._allChildren.map((a,c)=>yd(a,ye(e,c),t,s))},o=s.get(e);o&&o.length>0&&(r.waveform=o);let i=t.get(e);return i&&(r.startFrame=i.startFrame,r.endFrame=i.endFrame),r}function Uf(n,e){let t=new Map;for(let s of n){let r=s.ownerId!==void 0?e.get(s.ownerId):"";if(r===void 0)continue;let o={src:s.src,startTime:s.startAt,endTime:Number.isFinite(s.endAt)?s.endAt:null},i=t.get(r);i?i.push(o):t.set(r,[o])}return t}function gd(n,e){if(e==="")return n;let t=n;for(let s of e.split(".")){let r=t._allChildren[Number(s)];if(!r)return null;t=r}return t}function _d(n,e){if(n.id===e)return n;for(let t of n._allChildren){let s=_d(t,e);if(s)return s}return null}var Yn=class{manifest;constructor(e){this.manifest=e}reconcile(e){this.manifest=e}normalizeKey(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}getImageMeta(e){let t=this.manifest.image[this.normalizeKey(e)];if(!t)throw new Error(`Image asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`);return t}getVideoMeta(e){let t=this.manifest.video[this.normalizeKey(e)];if(!t)throw new Error(`Video asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`);return t}getAudioMeta(e){let t=this.manifest.audio[this.normalizeKey(e)];if(!t)throw new Error(`No audio metadata for src: ${e}`);return t}getFontMeta(e){let t=this.manifest.font[e];if(!t)throw new Error(`No font metadata for key: ${e}`);return t}getFontFamilyMetas(e){return Object.values(this.manifest.font).filter(t=>t.fontFamily===e)}getVideoDuration(e){return this.getVideoMeta(e).duration}getAudioDuration(e){return this.getAudioMeta(e).duration}getMediaDuration(e){let t=this.normalizeKey(e),s=this.manifest.audio[t];if(s)return s.duration;let r=this.manifest.video[t];if(r)return r.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:t,height:s}=this.getImageMeta(e);return{width:t,height:s}}};var Wn=class{controller;constructor(e){this.controller=e}get isPlaying(){return this.controller.isPlaying}get frame(){return this.controller.currentFrame}play(e=1,t=!1){this.controller.play(e,t)}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 Xn=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,t=!0){if(this._currentTime!==e&&(this._currentTime=e,!!t))for(let s of this.timeCallbacks)s(e)}setPlaying(e){this._isPlaying=e}play(e,t){this._isPlaying=!0;for(let s of this.playCallbacks)s(this._currentTime,e,t)}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 qn=class extends Xn{seek(e){this.setCurrentTime(e)}};var wd=class{engine;viewport;fps;constructor(e,t){this.engine=e,this._override={viewport:t.viewport,fps:t.fps},this._project=xd(t.document,t,e),this.viewport=this._project.viewport,this.fps=this._project.fps,this._catalog=new Yn(e.manifest),this._unsubscribe=e._onManifestChange(a=>{this._catalog.reconcile(a),this._storage.setCatalog(this._catalog),this._controller.reconcileCatalog()});let s={catalog:this._catalog,viewport:this.viewport,fps:this.fps};this._storage=e.platform.createStorageAdapter(s),this._renderContext=e.platform.createRenderContext(this._storage);let r=e.platform.createMeasureContext(this._storage),o=e.platform.createAudioSink(),i=e.platform.createTicker(this.fps,o);this.applyGlobals(),t.target!==void 0&&this._renderContext.mount(t.target),this._controller=new Gn({project:this._project,registry:e._registry,renderContext:this._renderContext,measurer:r,storageAdapter:this._storage,masterClock:i??new qn,audioDevice:o,assets:this._catalog,onPrecompProgress:t.onPrecompProgress}),this._playback=i===null?null:new Wn(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(xe(e,this.fps)))}async seekFrame(e){this.applyGlobals(),await this._controller.seek(e)}replace(e){let t=xd(e,this._override,this);if(t.fps!==this.fps||t.viewport.width!==this.viewport.width||t.viewport.height!==this.viewport.height)throw new Error(`Cannot replace a ${this.viewport.width}\xD7${this.viewport.height} @ ${this.fps}fps document with a ${t.viewport.width}\xD7${t.viewport.height} @ ${t.fps}fps one \u2014 open a new session.`);this._project=t,this.applyGlobals(),this._controller.setProject(t)}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(){ts(this._project.theme)}_override;_project;_catalog;_storage;_renderContext;_controller;_playback;_unsubscribe};function xd(n,e,t){let s=da(n),r=Hs(s),o=r.changes.length>0?r.document:s,i={...o,viewport:e.viewport??o.viewport??t.viewport,fps:e.fps??o.fps??t.fps};return Pa(i),i}function Kk(n,e={}){let t=e.delimiter??",",s=Wf(n,t);if(s.length===0)return[];let r=s[0].map(d=>d.trim()),i=s.slice(1).map(d=>{let u={};return r.forEach((l,f)=>{u[l]=d[f]??""}),u}),a=Gf(r,i,e.numeric),c=Yf(r,i,a,e.boolean);return a.length===0&&c.length===0?i:i.map(d=>{let u={...d};for(let l of a){let f=d[l];f!==""&&(u[l]=Number(f))}for(let l of c){let f=d[l];f!==""&&(u[l]=f==="true")}return u})}function Uk(n,e){throw new Error(`parseData("${n}") 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 Gf(n,e,t){return t===!1?[]:Array.isArray(t)?t:n.filter(s=>{let r=!1;for(let o of e){let i=o[s];if(i!==""){if(!Number.isFinite(Number(i)))return!1;r=!0}}return r})}function Yf(n,e,t,s){if(s===!1)return[];if(Array.isArray(s))return s;let r=new Set(t);return n.filter(o=>{if(r.has(o))return!1;let i=!1;for(let a of e){let c=a[o];if(c!==""){if(c!=="true"&&c!=="false")return!1;i=!0}}return i})}function Wf(n,e){let t=[],s=[],r="",o=!1,i=!1,a=()=>{s.push(r),r=""},c=()=>{a(),t.push(s),s=[],i=!1};for(let d=0;d<n.length;d++){let u=n[d];if(o){u==='"'?n[d+1]==='"'?(r+='"',d++):o=!1:r+=u;continue}if(u==='"'){o=!0,i=!0;continue}if(u===e){i=!0,a();continue}if(u!=="\r"){if(u===`
|
|
12
12
|
`){(i||r)&&c();continue}r+=u,i=!0}}return(i||r)&&c(),t}var Yk=(n,e)=>{let t=new Array(n);for(let s=0;s<n;s++)t[s]=e(s);return t};function Xk(){let n=null;function e(t){if(t!==void 0)n=t;else{if(n===null)throw new Error("Reference not assigned yet");return n}}return e}var Hn=class{state=0;constructor(e){this.setSeed(e)}setSeed(e){this.state=typeof e=="string"?e.split("").reduce((t,s)=>(t=(t<<5)-t+s.charCodeAt(0),t&t),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}},vd=4294967296,Ur=class n{_seed;numericSeed;gen;spareGauss=null;constructor(e){this.gen=new Hn(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((t,s)=>(t<<5)-t+s.charCodeAt(0),0):e}adopt(e){this._seed=e,this.numericSeed=n.toNumeric(e),this.gen.setSeed(e),this.spareGauss=null}nextFloat(e=0,t=1){return this.gen.next()*(t-e)+e}nextInt(e=0,t=vd){return Math.floor(this.gen.next()*(t-e))+e}floatArray(e,t=0,s=1){let r=new Array(e);for(let o=0;o<e;o++)r[o]=this.nextFloat(t,s);return r}intArray(e,t=0,s=vd){let r=new Array(e);for(let o=0;o<e;o++)r[o]=this.nextInt(t,s);return r}gauss(e=0,t=1){if(this.spareGauss!==null){let a=this.spareGauss;return this.spareGauss=null,e+t*a}let s,r,o;do s=this.gen.next()*2-1,r=this.gen.next()*2-1,o=s*s+r*r;while(o>=1||o===0);let i=Math.sqrt(-2*Math.log(o)/o);return this.spareGauss=r*i,e+t*(s*i)}noise(e,t=1){let s=e*t,r=Math.floor(s),o=s-r,i=o*o*(3-2*o),a=this.latticeValue(r),c=this.latticeValue(r+1);return a+(c-a)*i}reset(e=this._seed){this.adopt(e)}latticeValue(e){let t=Math.sin(e+this.numericSeed)*1e4;return t-Math.floor(t)}};function iS(n){return typeof n?._stepper=="function"}export{Ve as a,Sd as b,Ad as c,Is as d,gt as e,Od as f,Lp as g,Ke as h,Ds as i,km as j,ii as k,ai as l,ci as m,ye as n,on as o,an as p,Ns as q,Ie as r,ui as s,li as t,fi as u,hi as v,pi as w,Sg as x,Ag as y,Mg as z,Og as A,Tg as B,Eg as C,Cg as D,mi as E,gi as F,wi as G,xi as H,vi as I,un as J,bi as K,ki as L,Si as M,Ai as N,Mi as O,Oi as P,Ti as Q,Ei as R,Ci as S,Us as T,Pi as U,Ii as V,Di as W,Fi as X,$i as Y,Ni as Z,Ri as _,zi as $,Li as aa,ji as ba,Bi as ca,Vi as da,Ki as ea,Ui as fa,Gi as ga,Yi as ha,Wi as ia,Xi as ja,qi as ka,Hi as la,Ji as ma,Py as na,Zi as oa,Qi as pa,ea as qa,ta as ra,na as sa,sa as ta,ra as ua,oa as va,ia as wa,aa as xa,Ue as ya,Ry as za,ln as Aa,Ud as Ba,b as Ca,U as Da,zy as Ea,ca as Fa,Ge as Ga,Ly as Ha,Gd as Ia,ue as Ja,Yd as Ka,da as La,Xs as Ma,kt as Na,ua as Oa,qs as Pa,Hs as Qa,Qs as Ra,lu as Sa,Pa as Ta,Zy as Ua,St as Va,_u as Wa,wu as Xa,hn as Ya,Au as Za,Mu as _a,Ou as $a,D_ as ab,mn as bb,Pu as cb,Fu as db,Ye as eb,bn as fb,Lw as gb,Vw as hb,Kw as ib,yr as jb,wr as kb,An as lb,_r as mb,bl as nb,kl as ob,Sl as pb,Al as qb,Ml as rb,Tl as sb,bc as tb,Dl as ub,Fl as vb,kr as wb,$l as xb,Nl as yb,Mn as zb,ae as Ab,Ot as Bb,le as Cb,kc as Db,Tt as Eb,Et as Fb,Ct as Gb,Sc as Hb,On as Ib,Sr as Jb,q as Kb,Xe as Lb,Tn as Mb,qe as Nb,En as Ob,Gl as Pb,Yl as Qb,Cn as Rb,Pn as Sb,we as Tb,In as Ub,Bv as Vb,Re as Wb,xe as Xb,Kv as Yb,He as Zb,Pt as _b,Oc as $b,Me as ac,se as bc,Je as cc,Dn as dc,jt as ec,Oe as fc,jn as gc,Fr as hc,Lc as ic,Bb as jc,Vn as kc,et as lc,Lr as mc,Wc as nc,Xc as oc,re as pc,ed as qc,td as rc,nd as sc,sd as tc,rd as uc,Kt as vc,ad as wc,Te as xc,dd as yc,ud as zc,Kr as Ac,md as Bc,dk as Cc,uk as Dc,Gn as Ec,Yn as Fc,Wn as Gc,Xn as Hc,qn as Ic,wd as Jc,xd as Kc,Kk as Lc,Uk as Mc,Yk as Nc,Xk as Oc,Hn as Pc,Ur as Qc,iS as Rc};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-FPYU47XX.js.map
|
|
@@ -3,4 +3,4 @@ import{A as _i,a as ht,b as m,c as gi,d as L,e as Hr,g as xi,h as N,m as rt,p as
|
|
|
3
3
|
`),s=fi(e,t),a=s===null?null:_h(s,{fontFamily:e.fontFamily,fontSize:o,fontStyle:e.fontStyle,fontWeight:e.fontWeight,letterSpacing:e.letterSpacing}),c=o*e.lineHeight,l=Math.max(...a?a.map(w=>w.runs.reduce((h,x)=>h+r.measureText(x.text,x.fontSize,x.fontFamily,x.fontWeight,x.letterSpacing,x.fontStyle).width,0)):i.map(w=>r.measureText(w,o,e.fontFamily,e.fontWeight,e.letterSpacing,e.fontStyle).width)),u=e.width,f=e.height,p=typeof u=="number"?u:u==="hug"?l:n.maxWidth??0,y=t.wraps&&p>0,g=a===null?null:y?vh(a,p,r):a.map(w=>Math.max(...w.runs.map(h=>h.fontSize))),b=g?g.reduce((w,h)=>w+h*e.lineHeight,0):(y?i.reduce((w,h)=>w+kh(h,p,o,e.fontFamily,e.fontWeight,r,e.letterSpacing,e.fontStyle),0):i.length)*c;return{width:p,height:typeof f=="number"?f:b}}function fi(e,t){if(t.glyphPath!=null)return null;let n=t.runs.filter(y=>y.end>y.start),r=ui(e,t);if(r.length===0)return null;let o=e.start>0||e.end<1;if(n.length===0&&!o)return null;let i=Math.round(e.start*r.length),s=Math.round(e.end*r.length),a=typeof e.fontSize=="number"?e.fontSize:mu,c=e.fill,l=e.stroke,u=new Set([0,r.length]);for(let y of n)u.add(y.start),u.add(y.end);o&&(u.add(i),u.add(s));let f=[...u].filter(y=>y>=0&&y<=r.length).sort((y,g)=>y-g),p=[];for(let y=0;y<f.length-1;y++){let g=f[y],b=f[y+1];if(b<=g)continue;let w={text:r.slice(g,b),fontFamily:e.fontFamily,fontSize:a,fontStyle:e.fontStyle,fontWeight:e.fontWeight,letterSpacing:e.letterSpacing,textDecoration:e.textDecoration,opacity:1,x:0,y:0,scale:1,rotation:0,fill:c,stroke:l};for(let h of n)g<h.start||b>h.end||(h.fontFamily!==void 0&&(w.fontFamily=h.fontFamily),h.fontSize!==void 0&&(w.fontSize=h.fontSize),h.fontStyle!==void 0&&(w.fontStyle=h.fontStyle),h.fontWeight!==void 0&&(w.fontWeight=h.fontWeight),h.letterSpacing!==void 0&&(w.letterSpacing=h.letterSpacing),h.textDecoration!==void 0&&(w.textDecoration=h.textDecoration),h.fill!==void 0&&(w.fill=h.fill),h.stroke!==void 0&&(w.stroke=h.stroke));o&&!(g>=i&&b<=s)&&(w.opacity=0),p.push(w)}return p}function pi(e,t,n){return{text:ui(e,t),fontSize:e.fontSize,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,textAlign:e.textAlign,verticalAlign:e.verticalAlign,textDecoration:e.textDecoration,wrap:t.wraps,minFontSize:e.minFontSize,width:n?.width??0,height:n?.height??0,segments:fi(e,t)??void 0,path:t.glyphPath}}function gu(e,t,n){e.fontFamily&&n.font(e.fontFamily,e.fontWeight);for(let r of fi(e,t)??[]){let o=r.fontFamily??e.fontFamily;o&&n.font(o,r.fontWeight),n.fill(r.fill??[]);for(let i of r.stroke??[])n.fill(i.fill)}}function _h(e,t){let n=[{runs:[]}];for(let r of e){let o={fontFamily:r.fontFamily??t.fontFamily,fontSize:r.fontSize??t.fontSize,fontStyle:r.fontStyle??t.fontStyle,fontWeight:r.fontWeight,letterSpacing:r.letterSpacing},i=r.text.split(`
|
|
4
4
|
`);for(let s=0;s<i.length;s++)s>0&&n.push({runs:[]}),n[n.length-1].runs.push({text:i[s],...o})}for(let r of n)r.runs.length===0&&r.runs.push({...t,text:""});return n}function vh(e,t,n){let r=[];for(let o of e){let i=[];for(let c of o.runs)for(let l of c.text.split(/(\s+)/)){if(l.length===0)continue;let u=/^\s+$/.test(l),f=n.measureText(l,c.fontSize,c.fontFamily,c.fontWeight,c.letterSpacing,c.fontStyle).width,p=i[i.length-1];p&&!p.space&&!u?(p.width+=f,p.size=Math.max(p.size,c.fontSize)):i.push({width:f,size:c.fontSize,space:u})}if(i.length===0){r.push(Math.max(...o.runs.map(c=>c.fontSize)));continue}let s=i[0].width,a=i[0].size;for(let c of i.slice(1))s+c.width<=t?(s+=c.width,a=Math.max(a,c.size)):(r.push(a),s=c.space?0:c.width,a=c.space?0:c.size);r.push(a>0?a:Math.max(...o.runs.map(c=>c.fontSize)))}return r}function kh(e,t,n,r,o,i,s=0,a="normal"){if(e.length===0||i.measureText(e,n,r,o,s,a).width<=t)return 1;let c=e.split(/(\s+)/).filter(f=>f.length>0),l=1,u=0;for(let f of c){let p=i.measureText(f,n,r,o,s,a).width;u===0?u=p:u+p<=t?u+=p:(l++,u=/^\s+$/.test(f)?0:p)}return l}function di(e){return I.flatten(e.spans,{fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,fill:e.fill,stroke:e.stroke})}function xu(e,t,n){let r=0,o=0,i=0,s=0,a=()=>{r>i&&(i=r),s+=o,r=0,o=0};for(let u of di(e)){let f=u.fontSize*e.lineHeight,p=u.text.split(`
|
|
5
5
|
`);for(let y=0;y<p.length;y++)y>0&&a(),r+=n.measureText(p[y],u.fontSize,u.fontFamily,u.fontWeight,u.letterSpacing,u.fontStyle).width,f>o&&(o=f)}a(),s===0&&(s=e.fontSize*e.lineHeight);let c=e.width,l=e.height;return{width:typeof c=="number"?c:c==="hug"?i:t.maxWidth??0,height:typeof l=="number"?l:l==="hug"?s:t.maxHeight??0}}function wu(e,t){return{spans:di(e),lineHeight:e.lineHeight,textAlign:e.textAlign,width:t?.width??0,height:t?.height??0}}function bu(e,t){for(let n of di(e)){n.fontFamily&&t.font(n.fontFamily,n.fontWeight),t.fill(n.fill);for(let r of n.stroke)t.fill(r.fill)}}function Oh(e,t,n){let{node:r,scope:o}=Rt();return Ul(r),yu(t,n,{maxWidth:e.max.width,maxHeight:e.max.height},o)}var Su=new WeakMap;function Mh(e,t,n){let r=dt(e);if(Su.set(r.host,{s:t,source:n}),r.probing)return;let o=r.target(),i=pi(t,n,r.host.layoutBounds),s=i.segments!=null;r.inFront(()=>{let a=new B().text(i).shadow(t.shadow);s||a.fill(t.fill),o.draw(a)}),e.children(),r.inFront(()=>{let a=t.stroke;a.length===0||s||o.draw(new B().text(i).stroke(a))})}function Eh(e,t,n){gu(t,n,e)}function Ch(e){let t=Su.get(e);return t?pi(t.s,t.source,e.layoutBounds):null}function Ah(e,t){let{scope:n}=Rt();return xu(t,{maxWidth:e.max.width,maxHeight:e.max.height},n)}function Ph(e,t){let n=dt(e);if(n.probing)return;let r=n.target();n.inFront(()=>r.draw(new B().richText(wu(t,n.host.layoutBounds)))),e.children()}function Th(e,t){bu(t,e)}var Br=rn({},"text-style"),VO=rn({},"theme"),YO=rn({},"data"),XO=rn(void 0,"seed");function _u(e,t){return{context:e,value:t}}var jh={};ht(jh,{current:()=>Ih,inherit:()=>ct,provide:()=>Rh,provided:()=>Fh,state:()=>Nh});function zh(e,t){let n=t.variant;return I.mergeStyle(I.mergeStyle(I.preset("default"),e(Br)),n?I.preset(n):void 0)}function ct(e,t={}){return(n,r)=>{let o=zh(n,r)[e];return e==="fontSize"&&o==="autofit"&&t.autofit===!1?void 0:o}}var Nh={fontFamily:_.custom(void 0,{inherit:ct("fontFamily")}),fontSize:_.custom(48,{lerp:(e,t,n)=>I.lerpFontSize(e,t,n),inherit:ct("fontSize")}),fontWeight:_.number(400,{inherit:ct("fontWeight")}),fontStyle:_.custom("normal",{inherit:ct("fontStyle")}),letterSpacing:_.number(0,{inherit:ct("letterSpacing")}),lineHeight:_.number(1.2,{inherit:ct("lineHeight")}),textAlign:_.custom("center",{inherit:ct("textAlign")}),verticalAlign:_.oneOf(["top","center","bottom"],{default:"center"}),textDecoration:_.oneOf(["none","underline","line-through"]),textCase:_.oneOf(["none","upper","lower","title"]),minFontSize:_.number(12),variant:_.custom(void 0),fill:_.fill(void 0,{inherit:ct("fill")}),stroke:_.stroke(void 0,{inherit:ct("stroke")}),shadow:_.shadow(void 0,{inherit:ct("shadow")})},Fh={fontFamily:_.custom(void 0),fontSize:_.custom(void 0),fontWeight:_.custom(void 0),fontStyle:_.custom(void 0),letterSpacing:_.custom(void 0),lineHeight:_.custom(void 0),textAlign:_.custom(void 0),fill:_.custom(void 0),stroke:_.custom(void 0),shadow:_.custom(void 0)};function Rh(e,t){return[_u(Br,I.mergeStyle(t(Br),e))]}function Ih(e){return I.mergeStyle({},e)}function rM(e){let t=Jt(e,Et);class n extends Qt(Et,t){_commandChildren(){return this.childrenAudio.map(gt)}}return te(n,t)}Rr(e=>Or(e.constructor)?.key);var hi=class{host;target=null;camera3D=!1;environment3D=null;declaring=!1;constructor(t){this.host=t}get time(){return this.host.time}draw(t){t&&this.target?.draw(t)}light(t,n){this.target?.light(t,n)}camera(t){this.camera3D=!0,this.target?.camera({...this.host._ownTransform(),...t})}fog(t){this.target?.fog(t)}environment(t){this.environment3D=t,this.target?.environment(t)}};function uM(e){let t=e,n=Jt(t,yt);class r extends Qt(yt,n){constructor(i){super(i),this._ctx3d=new hi(this)}renderSelf(i){if(!t.render)return;let s=this._ctx3d;s.target=i;try{t.render(s,this._view)}finally{s.target=null}}groupTransform(){return this._rendersCamera()?{}:super.groupTransform()}_rendersCamera(){if(this._isCamera===void 0){let i=this._ctx3d;i.camera3D=!1,t.render&&t.render(i,this._view),this._isCamera=i.camera3D}return this._isCamera}_ownTransform(){return this.transform3D()}declareAssets(i){let s=this._ctx3d;s.environment3D=null,s.declaring=!0;try{super.declareAssets(i)}finally{s.declaring=!1}so(s.environment3D,i)}_commandChildren(){return this.children.filter(i=>i instanceof yt).map(gt)}}if(t.space){let o=t.space;r.prototype._spaceOf=function(){return o(this._view)}}return te(r,n)}var Yh={};ht(Yh,{mesh:()=>Wh,points:()=>Vh,shorthand:()=>mi,single:()=>qh,state:()=>Bh});function q(){return _.custom(void 0)}function mM(e){return _.custom(void 0,{kind:"number",...e})}function vu(){return _.custom(void 0,{resolve:e=>e===void 0?void 0:Bt.resolve(e),lerp:Bt.lerp,kind:"color"})}function yM(e){return _.custom(void 0,{resolve:yr,lerp:(t,n,r)=>gr(t,n,r,e),kind:"vector3"})}function Lh(e,t){let n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=o)}return n}function gM(e,t,n){return{type:e,...Lh(t,n)}}var Bh={material:q(),fill:_.custom("white",{lerp:Zs}),opacity:q(),roughness:q(),metalness:q(),emission:vu(),emissionStrength:q(),normalMap:q(),roughnessMap:q(),metalnessMap:q(),aoMap:q(),alphaMap:q(),envMapIntensity:q(),wireframe:q(),shading:q(),faces:q(),vertexColors:q(),blend:q(),unlit:_.custom(!1)},$h=["opacity","roughness","metalness","emission","emissionStrength","normalMap","roughnessMap","metalnessMap","aoMap","alphaMap","envMapIntensity","wireframe","shading","faces","vertexColors","blend"];function mi(e){let t={};e.material!==void 0&&(t.material=e.material),e.fill!==void 0&&(t.fill=e.fill);for(let n of $h)e[n]!==void 0&&(t[n]=e[n]);return e.unlit&&(t.unlit=!0),t}function Wh(e,t){let n=new Wt;return t&&n.mesh(t,$n(mi(e))),n}function qh(e){let t=$n(mi(e));return Array.isArray(t)?t[0]:t}var Hh=["opacity","alphaMap","blend","vertexColors"];function Vh(e){if(e.material!==void 0)return Array.isArray(e.material)?e.material[0]:e.material;let t={type:"points"},n=Ue(e.fill);n.color!==void 0&&(t.color=n.color),n.map!==void 0&&(t.map=n.map);for(let r of Hh)e[r]!==void 0&&(t[r]=e[r]);return t}var em={};ht(em,{commands:()=>Uh,draw:()=>Zh,load:()=>Kh,scene:()=>Cu,state:()=>Xh});function Mu(e){let{size:t,divisions:n,majorEvery:r,showAxes:o,fade:i}=e,s=t/2,a=t/n,c=dn(e.minorColor),l=dn(e.majorColor),u=dn(e.axisXColor),f=dn(e.axisZColor),p=dn(e.fadeTo),y=[],g=[],b=(w,h,x,k,O)=>{y.push(w,0,h,x,0,k),Ou(g,O,p,ku(w,h,s,i)),Ou(g,O,p,ku(x,k,s,i))};for(let w=0;w<=n;w++){let h=-s+w*a,x=Math.abs(w-n/2);if(Math.abs(h)<a/2&&o)continue;let O=Number.isInteger(x)&&x%r===0?l:c;b(h,-s,h,s,O),b(-s,h,s,h,O)}return o&&(b(-s,0,s,0,u),b(0,-s,0,s,f)),{type:"buffer",position:new Float32Array(y),color:new Float32Array(g),computeNormals:!1,staticData:!0}}function ku(e,t,n,r){if(r<=0)return 0;let o=Math.hypot(e,t)/n,i=1-r;if(o<=i)return 0;let s=Math.min(1,(o-i)/Math.max(r,1e-6));return s*s}function Ou(e,t,n,r){e.push(t[0]+(n[0]-t[0])*r,t[1]+(n[1]-t[1])*r,t[2]+(n[2]-t[2])*r)}function dn(e){let[t,n,r]=hn(e);return[yi(t),yi(n),yi(r)]}function yi(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function jt(e){return _.custom(e,{resolve:hn,lerp:Si})}var Xh={orbit:_.number(35,{step:1,unit:"\xB0"}),elevation:_.number(20,{min:-89,max:89,step:1,unit:"\xB0"}),zoom:_.number(12,{min:.01,step:.1}),fov:_.custom(45),ambientIntensity:_.custom(.45),ambientColor:jt("#ffffff"),keyIntensity:_.custom(2.4),keyColor:jt("#ffffff"),showGrid:_.custom(!1),gridSize:_.custom(40),gridDivisions:_.custom(40),gridMajorEvery:_.custom(5),gridColor:jt("#26292f"),gridMajorColor:jt("#363a42"),showAxes:_.custom(!1),axisXColor:jt("#c8404f"),axisZColor:jt("#2f6fd0"),gridFade:_.custom(.55),gridFadeColor:jt("#0b0d12"),maxPixelRatio:_.custom(2),antialias:_.custom(!0),shadows:_.custom(!1),tone:q(),exposure:q(),post:q()},Uh={orbitTo:{args:["orbit","elevation","zoom"]}},Gh=async()=>{await aa()};function Kh(e,t){if(e.task("three:runtime",Gh),!t)return;let n=new Q;t(n);let r={type:"canvas3D",scene:n};e.fill(r)}var Eu=new WeakMap;function Cu(e,t,n){let r=e.scene3D(),o=r.ops().length>0,i=qn(t.shadows);i&&r.shadows(i),(t.tone!==void 0||t.exposure!==void 0)&&r.tone({mapping:t.tone,exposure:t.exposure}),t.post!==void 0&&r.post(t.post);let s=r.fogDescriptor();if(s&&s.color===void 0){let a=tm(t.fill);a!==void 0&&r.fog({...s,color:a})}return t.showGrid&&r.draw(new Wt().line({geometry:Jh(dt(e).host,t),segments:!0,material:{type:"lineBasic",vertexColors:!0,toneMapped:!1}})),!n&&r.isEmpty()&&!o?null:(r.cameraDescriptor()===null&&r.perspective({fov:t.fov,orbit:_i(t.orbit),elevation:t.elevation,distance:t.zoom}),r.ops().some(a=>a.kind==="light")||r.light({type:"ambient",intensity:t.ambientIntensity,color:t.ambientColor}).light({type:"directional",intensity:t.keyIntensity,color:t.keyColor},{position:[4,6,3]}).light({type:"directional",intensity:t.keyIntensity*.35,color:t.keyColor},{position:[-5,-2,-4]}),n?.(r),r.isEmpty()?null:r)}function Zh(e,t,n){let r=Cu(e,t,n),o=dt(e);if(r&&!o.probing){r.assertBalanced();let s=o.host;Hn(r,a=>{if(!Ye(a))return;let c=In(a.source);c.kind==="node"&&s.attachDetached(c.node)})}let i=r?[...t.fill,...Ms.canvas3D(r,{maxPixelRatio:t.maxPixelRatio,antialias:t.antialias})]:t.fill;li(e,t,fn(e.size,t),{fill:i})}function Jh(e,t){let n={size:t.gridSize,divisions:Math.max(1,Math.round(t.gridDivisions)),majorEvery:Math.max(1,Math.round(t.gridMajorEvery)),minorColor:t.gridColor,majorColor:t.gridMajorColor,axisXColor:t.axisXColor,axisZColor:t.axisZColor,showAxes:t.showAxes,fadeTo:Qh(t),fade:t.gridFade},r=JSON.stringify(n),o=Eu.get(e);return o?.key!==r&&Eu.set(e,o={key:r,geometry:Mu(n)}),o.geometry}function Qh(e){for(let t of e.fill){if(t?.type!=="solid")continue;let n=t.color;if(typeof n=="string"||Array.isArray(n)&&(n[3]??1)>0)return n}return e.gridFadeColor}function tm(e){for(let t of e)if(t&&t.type==="solid")return t.color}export{mn as a,yn as b,gn as c,Lt as d,Vr as e,am as f,ee as g,ki as h,xt as i,xn as j,Yr as k,ne as l,st as m,Bt as n,Sn as o,Ci as p,km as q,$t as r,Mm as s,Em as t,at as u,Bu as v,$u as w,vn as x,kn as y,Wu as z,qu as A,On as B,Uu as C,Qg as D,En as E,ws as F,Cn as G,Tn as H,P as I,Xx as J,_s as K,wt as L,ef as M,ks as N,Os as O,qe as P,Ms as Q,Zr as R,sf as S,T0 as T,D0 as U,cf as V,z0 as W,js as X,Ve as Y,Jr as Z,R0 as _,I0 as $,Ls as aa,F as ba,V as ca,nw as da,ff as ea,lt as fa,B as ga,In as ha,hf as ia,Ye as ja,cw as ka,Vs as la,Xe as ma,Ue as na,Zs as oa,na as pa,$n as qa,Wt as ra,Wn as sa,qn as ta,Q as ua,ia as va,Mw as wa,Ew as xa,Cw as ya,aa as za,ca as Aa,Aw as Ba,Mf as Ca,Ef as Da,Hn as Ea,Un as Fa,Bb as Ga,Hf as Ha,ao as Ia,$b as Ja,$ as Ka,Vf as La,qt as Ma,Xf as Na,Uf as Oa,Gf as Pa,Aa as Qa,Ca as Ra,Kf as Sa,Zf as Ta,Dt as Ua,lo as Va,K as Wa,Da as Xa,Kn as Ya,za as Za,Na as _a,Fa as $a,tp as ab,ep as bb,ja as cb,La as db,oS as eb,Ba as fb,$a as gb,Zn as hb,lS as ib,uS as jb,Jn as kb,ap as lb,cp as mb,fS as nb,Ha as ob,G as pb,Z as qb,Ya as rb,pS as sb,dS as tb,Qn as ub,yS as vb,Ga as wb,ho as xb,mo as yb,er as zb,ec as Ab,nc as Bb,_t as Cb,Ht as Db,nr as Eb,FS as Fb,hp as Gb,rr as Hb,yo as Ib,rc as Jb,oc as Kb,mp as Lb,sr as Mb,xo as Nb,jS as Ob,So as Pb,tt as Qb,wp as Rb,vo as Sb,Ze as Tb,I as Ub,Je as Vb,vt as Wb,M as Xb,D as Yb,kt as Zb,Sc as _b,y_ as $b,g_ as ac,_c as bc,x_ as cc,w_ as dc,b_ as ec,dc as fc,lr as gc,QS as hc,hc as ic,mc as jc,tn as kc,gc as lc,r_ as mc,Mo as nc,Ot as oc,o_ as pc,ur as qc,en as rc,s_ as sc,xc as tc,rn as uc,nn as vc,f_ as wc,Ap as xc,Ao as yc,dr as zc,bc as Ac,W as Bc,mt as Cc,hr as Dc,j as Ec,Vt as Fc,No as Gc,o1 as Hc,Vp as Ic,i1 as Jc,Yp as Kc,Xp as Lc,Up as Mc,s1 as Nc,Kc as Oc,w1 as Pc,Qc,b1 as Rc,br as Sc,Yt as Tc,vr as Uc,_r as Vc,Zp as Wc,D1 as Xc,ll as Yc,Y as Zc,id as _c,yl as $c,Et as ad,ad as bd,cv as cd,lv as dd,cd as ed,ld as fd,yt as gd,Bo as hd,Or as id,ot as jd,Mr as kd,ud as ld,ft as md,pt as nd,Sv as od,_l as pd,vl as qd,kl as rd,Ol as sd,Ml as td,Pl as ud,fd as vd,hd as wd,md as xd,yd,Tl as zd,gd as Ad,H as Bd,Il as Cd,vd as Dd,tk as Ed,kd as Fd,dk as Gd,Pr as Hd,Tr as Id,dt as Jd,Vk as Kd,_ as Ld,ai as Md,fn as Nd,lu as Od,Qd as Pd,eh as Qd,nh as Rd,rh as Sd,Lr as Td,fu as Ud,oh as Vd,li as Wd,ch as Xd,pu as Yd,lh as Zd,uh as _d,fh as $d,ph as ae,dh as be,hh as ce,mh as de,yh as ee,du as fe,gh as ge,xh as he,bh as ie,mu as je,Sh as ke,FO as le,Oh as me,Mh as ne,Eh as oe,Ch as pe,Ah as qe,Ph as re,Th as se,Dh as te,Br as ue,VO as ve,YO as we,XO as xe,_u as ye,ct as ze,Nh as Ae,Fh as Be,Rh as Ce,Ih as De,jh as Ee,rM as Fe,uM as Ge,q as He,mM as Ie,vu as Je,yM as Ke,Lh as Le,gM as Me,Bh as Ne,Wh as Oe,qh as Pe,Vh as Qe,Yh as Re,Xh as Se,Uh as Te,Kh as Ue,Zh as Ve,em as We};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-XCGYJHZR.js.map
|