function au(n){return typeof n=="function"?n:()=>n}class cs{constructor(){this.subscribable=new vi(this),this.subscribers=new Set}subscribe(t){return this.subscribers.add(t),()=>this.unsubscribe(t)}unsubscribe(t){this.subscribers.delete(t)}clear(){this.subscribers.clear()}notifySubscribers(t){return[...this.subscribers].map(e=>e(t))}}class vi{constructor(t){this.dispatcher=t}subscribe(t){return this.dispatcher.subscribe(t)}unsubscribe(t){this.dispatcher.unsubscribe(t)}}class Ot extends cs{dispatch(t){this.notifySubscribers(t)}}class ou extends cs{constructor(){super(...arguments),this.value=!1}raise(){this.value||(this.value=!0,this.notifySubscribers())}reset(){this.value=!1}isRaised(){return this.value}subscribe(t){const e=super.subscribe(t);return this.value&&t(),e}}class re extends cs{get current(){return this.value}set current(t){this.value=t,this.notifySubscribers(t)}constructor(t){super(),this.value=t,this.subscribable=new lu(this)}subscribe(t,e=!0){const r=super.subscribe(t);return e&&t(this.value),r}}class lu extends vi{get current(){return this.dispatcher.current}subscribe(t,e=!0){return this.dispatcher.subscribe(t,e)}}class kt{get onChanged(){return this.value.subscribable}get onDisabled(){return this.disabled.subscribable}constructor(t,e){this.name=t,this.initial=e,this.type=void 0,this.spacing=!1,this.description="",this.disabled=new re(!1),this.value=new re(e)}get(){return this.value.current}set(t){this.value.current=this.parse(t)}parse(t){return t}serialize(){return this.value.current}clone(){return new this.constructor(this.name,this.get())}disable(t=!0){return this.disabled.current=t,this}space(t=!0){return this.spacing=t,this}describe(t){return this.description=t,this}}class hu extends kt{get onFieldsChanged(){return this.event.subscribable}constructor(t,e){const r=new Map(Object.entries(e));super(t,Object.fromEntries(Array.from(r,([i,a])=>[i,a.get()]))),this.type=Object,this.ignoreChange=!1,this.customFields={},this.handleChange=()=>{this.ignoreChange||(this.value.current={...this.transform("get"),...this.customFields})},this.event=new re([...r.values()]),this.fields=r;for(const[i,a]of this.fields)Object.defineProperty(this,i,{value:a}),a.onChanged.subscribe(this.handleChange)}set(t){this.ignoreChange=!0;for(const[e,r]of Object.entries(t)){const i=this.fields.get(e);i?i.set(r):this.customFields[e]=r}this.ignoreChange=!1,this.handleChange()}serialize(){return{...this.transform("serialize"),...this.customFields}}clone(){const t=new this.constructor(this.name,this.transform("clone"));return t.set(structuredClone(this.customFields)),t}transform(t){return Object.fromEntries(Array.from(this.fields,([r,i])=>[r,i[t]()]))}}const Gt=hu;class br extends kt{constructor(){super(...arguments),this.type=Boolean}parse(t){return!!t}}class mi extends Error{constructor(t,e){typeof t=="string"?(super(t),this.remarks=e):(super(t.message),this.remarks=t.remarks,this.object=t.object,this.durationMs=t.durationMs,this.inspect=t.inspect)}}class uu{constructor(){this.resolveCurrent=null,this.current=null}async acquire(){for(;this.current;)await this.current;this.current=new Promise(t=>{this.resolveCurrent=t})}release(){var t;this.current=null,(t=this.resolveCurrent)==null||t.call(this),this.resolveCurrent=null}}const wr=[];function fs(){const n=wr.at(-1);if(!n)throw new Error("The scene is not available in the current context.");return n}function cu(n){wr.push(n)}function fu(n){if(wr.pop()!==n)throw new Error("startScene/endScene were called out of order.")}function vt(){var n;return((n=wr.at(-1))==null?void 0:n.logger)??console}const ds=[];function xr(){const n=ds.at(-1);if(!n)throw new mi("The thread is not available in the current context.",`<p><code>useThread()</code> can only be called from within generator functions.
      It&#39;s not available during rendering.</p>
`);return n}function si(n){ds.push(n)}function ni(n){if(ds.pop()!==n)throw new Error("startThread/endThread was called out of order.")}function Ge(n){return n[0].toUpperCase()+n.slice(1)}function du(){let n;return e=>{if(e!==void 0)n=e;else return n}}function bi(n){return{message:n.message,stack:n.stack,remarks:n.remarks}}const ii=[{value:.25,text:"0.25x (Quarter)"},{value:.5,text:"0.5x (Half)"},{value:1,text:"1.0x (Full)"},{value:2,text:"2.0x (Double)"}],pu=[{value:"srgb",text:"sRGB"},{value:"display-p3",text:"DCI-P3"}],ai=[{value:30,text:"30 FPS"},{value:60,text:"60 FPS"}];var Lt;(function(n){n.Error="error",n.Warn="warn",n.Info="info",n.Http="http",n.Verbose="verbose",n.Debug="debug",n.Silly="silly"})(Lt||(Lt={}));class gu{constructor(){this.logged=new Ot,this.history=[],this.profilers={}}get onLogged(){return this.logged.subscribable}log(t){this.logged.dispatch(t),this.history.push(t)}error(t){this.logLevel(Lt.Error,t)}warn(t){this.logLevel(Lt.Warn,t)}info(t){this.logLevel(Lt.Info,t)}http(t){this.logLevel(Lt.Http,t)}verbose(t){this.logLevel(Lt.Verbose,t)}debug(t){this.logLevel(Lt.Debug,t)}silly(t){this.logLevel(Lt.Silly,t)}logLevel(t,e){const r=typeof e=="string"?{message:e}:e;r.level=t,this.log(r)}profile(t,e){const r=performance.now();if(this.profilers[t]){const i=this.profilers[t];delete this.profilers[t];const a=e??{message:t};a.level??(a.level=Lt.Debug),a.durationMs=r-i,this.log(a);return}this.profilers[t]=r}}var Ze;(function(n){n[n.Playing=0]="Playing",n[n.Rendering=1]="Rendering",n[n.Paused=2]="Paused",n[n.Presenting=3]="Presenting"})(Ze||(Ze={}));function vu(n){const t={version:new kt("version",1),shared:new Gt("General",{background:new as("background",null),range:new Sr("range",[0,1/0]),size:new Mi("resolution",new g(1920,1080)),audioOffset:new ns("audio offset",0)}),preview:new Gt("Preview",{fps:new ns("frame rate",30).setPresets(ai).setRange(1),resolutionScale:new ve("scale",ii,1)}),rendering:new Gt("Rendering",{fps:new ns("frame rate",60).setPresets(ai).setRange(1),resolutionScale:new ve("scale",ii,1),colorSpace:new ve("color space",pu),exporter:new Qu("exporter",n)})};return t.shared.audioOffset.disable(!n.audio),t}class mu extends Gt{constructor(t){super("project",vu(t))}getFullPreviewSettings(){return{...this.shared.get(),...this.preview.get()}}getFullRenderingSettings(){return{...this.shared.get(),...this.rendering.get()}}}function bu(){return new Gt("Application Settings",{version:new kt("version",1),appearance:new Gt("Appearance",{color:new as("accent color",new se("#33a6ff")).describe("The accent color for the user interface. (Leave empty to use the default color)"),font:new br("legacy font",!1).describe("Use the 'JetBrains Mono' font for the user interface."),coordinates:new br("coordinates",!0).describe("Display mouse coordinates within the preview window.")}),defaults:new Gt("Defaults",{background:new as("background",null).describe("The default background color used in new projects."),size:new Mi("resolution",new g(1920,1080)).describe("The default resolution used in new projects.")})})}function yu(n,t,e,r,i,a,h=r.logger??new gu){const c=bu();a.attach(c);const m={name:n,...r,plugins:e,versions:t,settings:c,logger:h};return m.meta=new mu(m),m.meta.shared.set(c.defaults.get()),m.experimentalFeatures??(m.experimentalFeatures=!1),i.attach(m.meta),m}function wu(n,t){return{level:Lt.Error,message:n,remarks:(t??"")+`<p>This feature requires enabling the <code>experimentalFeatures</code> flag in your project
configuration:</p>
<pre class=""><code class="language-ts"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-title function_">makeProject</span>({
  <span class="hljs-attr">experimentalFeatures</span>: <span class="hljs-literal">true</span>,
  <span class="hljs-comment">// ...</span>
});</code></pre><p><a href='https://motioncanvas.io/docs/experimental' target='_blank'>Learn more</a> about experimental
features.</p>
`}}const xu=180/Math.PI,te=Math.PI/180;function oi(n,t,e){let r=0,i=n;t!==void 0&&(r=n,i=t),e=e===void 0?r<i?1:-1:e;const a=[];let h=Math.max(Math.ceil((i-r)/e),0),c=0;for(;h--;)a[c++]=r,r+=e;return a}function Cu(n){const t=fs(),e=xr();return t.timeEvents.register(n,e.time())}const ps=[];function yi(){const n=ps.at(-1);if(!n)throw new Error("The playback is not available in the current context.");return n}function Su(n){ps.push(n)}function ku(n){if(ps.pop()!==n)throw new Error("startPlayback/endPlayback were called out of order.")}function ae(n,...t){const e={[n.name]:n},r=Object.getOwnPropertyDescriptor(e,n.name);if(r)for(let i=t.length-1;i>=0;i--)t[i](e,n.name,r)}const li=Symbol.for("@motion-canvas/core/decorators/UNINITIALIZED");function gs(n){return(t,e)=>{let r=li;Object.defineProperty(t,e,{get(){return r===li&&(r=n.call(this)),r}})}}function ut(n){return function(t,e,r){r.value.prototype.name=n??e,r.value.prototype.threadable=!0}}ae(Fe,ut());function*Fe(...n){for(const t of n)yield t;yield*Si(...n)}ae(Tu,ut());function*Tu(n,t){yield*vs(Cu(n)),t&&(yield*t)}ae(vs,ut());function*vs(n=0,t){const e=xr(),r=yi().framesToSeconds(1),i=e.time()+n;for(;i-r>e.fixed;)yield;e.time(i),t&&(yield*t)}ae(wi,ut());function*wi(){}function hi(n,t){let e;return typeof n=="string"?(e=t(),yr(e,n)):(e=n(),yr(e,e)),e}function Pu(n){return n&&(typeof n=="object"||typeof n=="function")&&"toPromise"in n}function xi(n){return n!==null&&typeof n=="object"&&Symbol.iterator in n&&"next"in n}function yr(n,t){const e=Object.getPrototypeOf(n);e.threadable||(e.threadable=!0,e.name=typeof t=="string"?t:Ci(t))}function Ci(n){return Object.getPrototypeOf(n).name??null}class ss{get onDeferred(){return this.deferred.subscribable}get fixed(){return this.fixedTime}get canceled(){var t;return this.isCanceled||(((t=this.parent)==null?void 0:t.canceled)??!1)}get paused(){var t;return this.isPaused||(((t=this.parent)==null?void 0:t.paused)??!1)}get root(){var t;return((t=this.parent)==null?void 0:t.root)??this}constructor(t){this.runner=t,this.deferred=new Ot,this.children=[],this.time=De(0),this.parent=null,this.isCanceled=!1,this.isPaused=!1,this.fixedTime=0,this.queue=[],this.runner.task&&(vt().error({message:`The generator "${Ci(this.runner)}" is already being executed by another thread.`,remarks:`<p>This usually happens when you mistakenly reuse a generator that is already
running.</p>
<p>For example, using <code>yield</code> here will run the opacity generator concurrently and
store it in the <code>task</code> variable (in case you want to cancel or await it later):</p>
<pre class=""><code class="language-ts"><span class="hljs-keyword">const</span> task = <span class="hljs-keyword">yield</span> <span class="hljs-title function_">rect</span>().<span class="hljs-title function_">opacity</span>(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>);</code></pre><p>Trying to <code>yield</code> this task again will cause the current error:</p>
<pre class=""><code class="language-ts"><span class="hljs-keyword">yield</span> task;</code></pre><p>Passing it to other flow functions will also cause the error:</p>
<pre class=""><code class="language-ts"><span class="hljs-keyword">yield</span>* <span class="hljs-title function_">all</span>(task);</code></pre><p>Try to investigate your code looking for <code>yield</code> statements whose return value
is reused in this way. Here&#39;s an example of a common mistake:</p>
<pre class="wrong"><code class="language-ts"><span class="hljs-keyword">yield</span>* <span class="hljs-title function_">all</span>(
  <span class="hljs-keyword">yield</span> <span class="hljs-title function_">rect</span>().<span class="hljs-title function_">opacity</span>(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>), 
  <span class="hljs-keyword">yield</span> <span class="hljs-title function_">rect</span>().<span class="hljs-title function_">x</span>(<span class="hljs-number">200</span>, <span class="hljs-number">1</span>),
);</code></pre><pre class="correct"><code class="language-ts"><span class="hljs-keyword">yield</span>* <span class="hljs-title function_">all</span>(
  <span class="hljs-title function_">rect</span>().<span class="hljs-title function_">opacity</span>(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>), 
  <span class="hljs-title function_">rect</span>().<span class="hljs-title function_">x</span>(<span class="hljs-number">200</span>, <span class="hljs-number">1</span>),
);</code></pre>`}),this.runner=wi()),this.runner.task=this}next(){if(this.paused)return{value:null,done:!1};si(this);const t=this.runner.next(this.value);return ni(this),this.value=null,t}update(t){this.paused||(this.time(this.time()+t),this.fixedTime+=t),this.children=this.children.filter(e=>!e.canceled)}spawn(t){return xi(t)||(t=t()),this.queue.push(t),t}add(t){t.parent=this,t.isCanceled=!1,t.time(this.time()),t.fixedTime=this.fixedTime,this.children.push(t),yr(t.runner,`unknown ${this.children.length}`)}drain(t){this.queue.forEach(t),this.queue=[]}cancel(){this.deferred.clear(),this.runner.return(),this.isCanceled=!0,this.parent=null,this.drain(t=>t.return())}pause(t){this.isPaused=t}runDeferred(){si(this),this.deferred.dispatch(),ni(this)}}ae(Si,ut());function*Si(n,...t){let e=!0;typeof n=="boolean"?e=n:t.push(n);const r=xr(),i=t.map(c=>r.children.find(m=>m.runner===c)).filter(c=>c),a=r.time();let h;if(e){for(;i.find(c=>!c.canceled);)yield;h=Math.max(...i.map(c=>c.time()))}else{for(;!i.find(m=>m.canceled);)yield;const c=i.filter(m=>m.canceled);h=Math.min(...c.map(m=>m.time()))}r.time(Math.max(a,h))}function Ru(n){return typeof(n==null?void 0:n.then)=="function"}ae(ki,ut());function*ki(n,t){const e=yi(),r=n();yr(r,"root");const i=new ss(r);t==null||t(i);let a=[i];for(;a.length>0;){const h=[],c=[...a],m=e.deltaTime;for(;c.length>0;){const y=c.pop();if(!y||y.canceled)continue;const k=y.next();if(k.done){y.cancel();continue}if(xi(k.value)){const F=new ss(k.value);y.value=k.value,y.add(F),c.push(y),c.push(F)}else k.value?(y.value=yield k.value,c.push(y)):(y.update(m),y.drain(F=>{const X=new ss(F);y.add(X),h.unshift(X)}),h.unshift(y))}a=[];for(const y of h)y.canceled||(a.push(y),y.runDeferred());a.length>0&&(yield)}}var Dt;(function(n){n[n.BeforeRender=0]="BeforeRender",n[n.BeginRender=1]="BeginRender",n[n.FinishRender=2]="FinishRender",n[n.AfterRender=3]="AfterRender"})(Dt||(Dt={}));class Mu{get onBeforeRender(){return this.beforeRender.subscribable}get onBeginRender(){return this.beginRender.subscribable}get onFinishRender(){return this.finishRender.subscribable}get onAfterRender(){return this.afterRender.subscribable}constructor(t){this.scene=t,this.beforeRender=new Ot,this.beginRender=new Ot,this.finishRender=new Ot,this.afterRender=new Ot,this.scene.onRenderLifecycle.subscribe(([e,r])=>{switch(e){case Dt.BeforeRender:return this.beforeRender.dispatch(r);case Dt.BeginRender:return this.beginRender.dispatch(r);case Dt.FinishRender:return this.finishRender.dispatch(r);case Dt.AfterRender:return this.afterRender.dispatch(r)}}),this.scene.onReset.subscribe(()=>{this.beforeRender.clear(),this.beginRender.clear(),this.finishRender.clear(),this.afterRender.clear()})}}class Ve{constructor(t){this.state=t,this.nextGauss=null}static createSeed(){return Math.floor(Math.random()*4294967296)}nextFloat(t=0,e=1){return tt(t,e,this.next())}nextInt(t=0,e=4294967296){let r=Math.floor(tt(t,e,this.next()));return r===e&&(r=t),r}gauss(t=0,e=1){let r=this.nextGauss;if(this.nextGauss=null,r===null){const i=this.next()*2*Math.PI,a=Math.sqrt(-2*Math.log(1-this.next()));r=Math.cos(i)*a,this.nextGauss=Math.sin(i)*a}return t+r*e}floatArray(t,e=0,r=1){return oi(t).map(()=>this.nextFloat(e,r))}intArray(t,e=0,r=4294967296){return oi(t).map(()=>this.nextInt(e,r))}spawn(){return new Ve(this.nextInt())}next(){this.state|=0,this.state=this.state+1831565813|0;let t=Math.imul(this.state^this.state>>>15,1|this.state);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var gt;(function(n){n[n.Initial=0]="Initial",n[n.AfterTransitionIn=1]="AfterTransitionIn",n[n.CanTransitionOut=2]="CanTransitionOut",n[n.Finished=3]="Finished"})(gt||(gt={}));const $u="resolution",Lu="destinationTexture",Au="sourceTexture",ui="time",Ou="deltaTime",zu="framerate",Iu="sourceMatrix",Fu="destinationMatrix",Eu=`#version 300 es

in vec2 position;

out vec2 screenUV;
out vec2 sourceUV;
out vec2 destinationUV;

uniform mat4 sourceMatrix;
uniform mat4 destinationMatrix;

void main() {
    vec2 position_source = position * 0.5 + 0.5;
    vec4 position_screen = sourceMatrix * vec4(position_source, 0, 1);

    screenUV = position_screen.xy;
    sourceUV = position_source;
    destinationUV = (destinationMatrix * position_screen).xy;

    gl_Position = (position_screen - 0.5) * 2.0;
}
`;class _u{constructor(t,e){this.scene=t,this.sharedContext=e,this.gl=null,this.positionBuffer=null,this.sourceTexture=null,this.destinationTexture=null,this.positionLocation=0,this.quadPositions=new Float32Array([-1,1,-1,-1,1,1,1,-1]),this.handleReload=()=>{this.gl&&this.updateViewport()},t.onReloaded.subscribe(this.handleReload)}setup(t){this.gl=t,this.updateViewport(),this.positionBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,this.quadPositions,t.STATIC_DRAW),t.vertexAttribPointer(this.positionLocation,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this.positionLocation),this.sourceTexture=t.createTexture(),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.sourceTexture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this.destinationTexture=t.createTexture(),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.destinationTexture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}teardown(t){t.deleteBuffer(this.positionBuffer),t.disableVertexAttribArray(this.positionLocation),t.deleteTexture(this.sourceTexture),t.deleteTexture(this.destinationTexture),this.positionBuffer=null,this.sourceTexture=null,this.destinationTexture=null,this.gl=null}updateViewport(){if(this.gl){const t=this.scene.getRealSize();this.gl.canvas.width=t.width,this.gl.canvas.height=t.height,this.gl.viewport(0,0,t.width,t.height)}}getGL(){return this.gl??this.sharedContext.borrow(this)}getProgram(t){const e=this.sharedContext.getProgram(t,Eu);if(!e)return null;const r=this.scene.getRealSize(),i=this.getGL();return i.useProgram(e),i.uniform1i(i.getUniformLocation(e,Au),0),i.uniform1i(i.getUniformLocation(e,Lu),1),i.uniform2f(i.getUniformLocation(e,$u),r.x,r.y),i.uniform1f(i.getUniformLocation(e,Ou),this.scene.playback.deltaTime),i.uniform1f(i.getUniformLocation(e,zu),this.scene.playback.fps),e}copyTextures(t,e){this.copyTexture(e,this.sourceTexture),this.copyTexture(t,this.destinationTexture)}clear(){const t=this.getGL();t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)}render(){const t=this.getGL();t.drawArrays(t.TRIANGLE_STRIP,0,4)}copyTexture(t,e){const r=this.getGL();r.bindTexture(r.TEXTURE_2D,e),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),r.generateMipmap(r.TEXTURE_2D)}}class Du{get onChanged(){return this.slides.subscribable}constructor(t){this.scene=t,this.slides=new re([]),this.lookup=new Map,this.collisionLookup=new Set,this.current=null,this.canResume=!1,this.waitsForId=null,this.targetId=null,this.handleReload=()=>{this.lookup.clear(),this.collisionLookup.clear(),this.current=null,this.waitsForId=null,this.targetId=null},this.handleReset=()=>{this.collisionLookup.clear(),this.current=null,this.waitsForId=null},this.handleRecalculated=()=>{this.slides.current=[...this.lookup.values()]},this.scene.onReloaded.subscribe(this.handleReload),this.scene.onReset.subscribe(this.handleReset),this.scene.onRecalculated.subscribe(this.handleRecalculated)}setTarget(t){this.targetId=t}resume(){this.canResume=!0}isWaitingFor(t){return this.waitsForId===t}isWaiting(){return this.waitsForId!==null}didHappen(t){var e;if(this.current===null)return!1;for(const r of this.lookup.keys()){if(r===t)return!0;if(r===((e=this.current)==null?void 0:e.id))return!1}return!1}getCurrent(){return this.current}register(t,e){if(this.waitsForId!==null)throw new Error(`The animation already waits for a slide: ${this.waitsForId}.`);const r=this.toId(t);this.scene.playback.state!==Ze.Presenting&&(this.lookup.has(r)||this.lookup.set(r,{id:r,name:t,time:e,scene:this.scene,stack:new Error().stack}),this.collisionLookup.has(t)?this.scene.logger.warn({message:`A slide named "${t}" already exists.`,stack:new Error().stack}):this.collisionLookup.add(t)),this.waitsForId=r,this.current=this.lookup.get(r)??null,this.canResume=!1}shouldWait(t){const e=this.toId(t);if(this.waitsForId!==e)throw new Error(`The animation waits for a different slide: ${this.waitsForId}.`);if(!this.lookup.get(e))throw new Error(`Could not find the "${t}" slide.`);let i=this.canResume;return this.scene.playback.state!==Ze.Presenting&&(i=e!==this.targetId),i&&(this.waitsForId=null),!i}toId(t){return`${this.scene.name}:${t}`}}class ju{constructor(t){this.scene=t,this.signals={},this.variables={},this.handleReset=()=>{this.signals={}},t.onReset.subscribe(this.handleReset)}get(t,e){var r;return(r=this.signals)[t]??(r[t]=De(this.variables[t]??e)),()=>this.signals[t]()}updateSignals(t){this.variables=t,Object.keys(t).map(e=>{e in this.signals&&this.signals[e](t[e])})}}class Bu{get firstFrame(){return this.cache.current.firstFrame}get lastFrame(){return this.firstFrame+this.cache.current.duration}get onCacheChanged(){return this.cache.subscribable}get onReloaded(){return this.reloaded.subscribable}get onRecalculated(){return this.recalculated.subscribable}get onThreadChanged(){return this.thread.subscribable}get onRenderLifecycle(){return this.renderLifecycle.subscribable}get onReset(){return this.afterReset.subscribable}get LifecycleEvents(){return this.logger.warn("LifecycleEvents is deprecated. Use lifecycleEvents instead."),this.lifecycleEvents}get previous(){return this.previousScene}constructor(t){this.cache=new re({firstFrame:0,transitionDuration:0,duration:0,lastFrame:0}),this.reloaded=new Ot,this.recalculated=new Ot,this.thread=new re(null),this.renderLifecycle=new Ot,this.afterReset=new Ot,this.lifecycleEvents=new Mu(this),this.previousScene=null,this.runner=null,this.state=gt.Initial,this.cached=!1,this.counters={},this.name=t.name,this.size=t.size,this.resolutionScale=t.resolutionScale,this.logger=t.logger,this.playback=t.playback,this.meta=t.meta,this.runnerFactory=t.config,this.creationStack=t.stack,this.experimentalFeatures=t.experimentalFeatures??!1,ae(this.runnerFactory,ut(this.name)),this.timeEvents=new t.timeEventsClass(this),this.variables=new ju(this),this.shaders=new _u(this,t.sharedWebGLContext),this.slides=new Du(this),this.random=new Ve(this.meta.seed.get()),this.previousOnTop=!1}update(){}async render(t){let e=0;do e++,await ht.consumePromises(),t.save(),t.clearRect(0,0,t.canvas.width,t.canvas.height),this.execute(()=>this.draw(t)),t.restore();while(ht.hasPromises()&&e<10);e>1&&this.logger.debug(`render iterations: ${e}`)}reload({config:t,size:e,stack:r,resolutionScale:i}={}){t&&(this.runnerFactory=t),e&&(this.size=e),i&&(this.resolutionScale=i),r&&(this.creationStack=r),this.cached=!1,this.reloaded.dispatch()}async recalculate(t){const e=this.cache.current;if(e.firstFrame=this.playback.frame,e.lastFrame=e.firstFrame+e.duration,this.isCached()){t(e.lastFrame),this.cache.current={...e};return}for(e.transitionDuration=-1,await this.reset();!this.canTransitionOut();)e.transitionDuration<0&&this.state===gt.AfterTransitionIn&&(e.transitionDuration=this.playback.frame-e.firstFrame),t(this.playback.frame+1),await this.next();e.transitionDuration===-1&&(e.transitionDuration=0),e.lastFrame=this.playback.frame,e.duration=e.lastFrame-e.firstFrame,await new Promise(r=>setTimeout(r,0)),this.cached=!0,this.cache.current={...e},this.recalculated.dispatch()}async next(){var e;if(!this.runner)return;let t=this.execute(()=>this.runner.next());for(this.update();t.value;){if(Pu(t.value)){const r=await t.value.toPromise();t=this.execute(()=>this.runner.next(r))}else if(Ru(t.value)){const r=await t.value;t=this.execute(()=>this.runner.next(r))}else this.logger.warn({message:"Invalid value yielded by the scene.",object:t.value}),t=this.execute(()=>this.runner.next(t.value));this.update()}if(ht.hasPromises()){const r=await ht.consumePromises();this.logger.error({message:"Tried to access an asynchronous property before the node was ready. Make sure to yield the node before accessing the property.",stack:r[0].stack,inspect:((e=r[0].owner)==null?void 0:e.key)??void 0})}t.done&&(this.state=gt.Finished)}async reset(t=null){this.counters={},this.previousScene=t,this.previousOnTop=!1,this.random=new Ve(this.meta.seed.get()),this.runner=ki(()=>this.runnerFactory(this.getView()),e=>{this.thread.current=e}),this.state=gt.AfterTransitionIn,this.afterReset.dispatch(),await this.next()}getSize(){return this.size}getRealSize(){return this.size.mul(this.resolutionScale)}isAfterTransitionIn(){return this.state===gt.AfterTransitionIn}canTransitionOut(){return this.state===gt.CanTransitionOut||this.state===gt.Finished}isFinished(){return this.state===gt.Finished}enterInitial(){this.state===gt.AfterTransitionIn?this.state=gt.Initial:this.logger.warn(`Scene ${this.name} entered initial in an unexpected state: ${this.state}`)}enterAfterTransitionIn(){this.state===gt.Initial?this.state=gt.AfterTransitionIn:this.logger.warn(`Scene ${this.name} transitioned in an unexpected state: ${this.state}`)}enterCanTransitionOut(){this.state===gt.AfterTransitionIn||this.state===gt.Initial?this.state=gt.CanTransitionOut:this.logger.warn(`Scene ${this.name} was marked as finished in an unexpected state: ${this.state}`)}isCached(){return this.cached}execute(t){let e;cu(this),Su(this.playback);try{e=t()}finally{ku(this.playback),fu(this)}return e}}function Nu(){return new Gt("scene",{version:new kt("version",1),timeEvents:new kt("time events",[]),seed:new kt("seed",Ve.createSeed())})}function Wu(n,t,e){const r=[...n],i=[...t];if(i.length>=r.length){const a=Math.floor(i.length*e),h=Math.floor(tt(r.length-1,i.length,e));let c="";for(let m=0;m<i.length;m++)m<a?c+=i[m]:(r[m]||m<=h)&&(c+=r[m]??i[m]);return c}else{const a=Math.round(r.length*(1-e)),h=Math.floor(tt(r.length+1,i.length,e)),c=[];for(let m=r.length-1;m>=0;m--)m<a?c.unshift(r[m]):(i[m]||m<h)&&c.unshift(i[m]??r[m]);return c.join("")}}function _e(n,t,e,r=!1){if(e===0)return n;if(e===1)return t;if(n==null||t==null){r||vt().warn(`Attempting to lerp ${n} -> ${t} may result in unexpected behavior.`);return}if(typeof n=="number"&&typeof t=="number")return tt(n,t,e);if(typeof n=="string"&&typeof t=="string")return Wu(n,t,e);if(typeof n=="boolean"&&typeof t=="boolean")return e<.5?n:t;if("lerp"in n)return n.lerp(t,e);if(n&&t&&typeof n=="object"&&typeof t=="object")if(Array.isArray(n)&&Array.isArray(t)){if(n.length===t.length)return n.map((i,a)=>_e(i,t[a],e))}else{let i=!1;if(!(n instanceof Map)&&!(t instanceof Map)&&(i=!0,n=new Map(Object.entries(n)),t=new Map(Object.entries(t))),n instanceof Map&&t instanceof Map){const a=new Map;for(const h of new Set([...n.keys(),...t.keys()])){const c=_e(n.get(h),t.get(h),e,!0);c!==void 0&&a.set(h,c)}return i?Object.fromEntries(a):a}}return t}function Uu(n,t,e){return e<.5?n:t}function tt(n,t,e){return n+(t-n)*e}function qu(n,t,e,r,i){return e+(i-n)*(r-e)/(t-n)}function wt(n,t,e){return e<n?n:e>t?t:e}function Ti(n,t,e){let r=t;e>1?e=1/e:r=!r;const i=r?Math.acos(wt(-1,1,1-n)):Math.asin(n),a=tt(i,tt(0,Math.PI/2,n),e);let h=Math.sin(a),c=1-Math.cos(a);return t&&([h,c]=[c,h]),new g(h,c)}function Et(n,t=0,e=1){return n=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,tt(t,e,n)}function Gu(n,t=0,e=1){return n=n===1?1:1-Math.pow(2,-10*n),tt(t,e,n)}function Xu(n,t=0,e=1){return tt(t,e,n)}ae(_t,ut());function*_t(n,t,e){const r=xr(),i=r.time(),a=r.time()+n;for(t(0,0);a>r.fixed;){const h=r.fixed-i,c=h/n;h>0&&t(c,h),yield}r.time(a),t(1,n),e==null||e(1,n)}class ht{static collectPromise(t,e=null){const r={promise:t,value:e,stack:new Error().stack},i=this.collectionStack.at(-1);return i&&(r.owner=i.owner),t.then(a=>{r.value=a,i==null||i.markDirty()}),this.promises.push(r),r}static hasPromises(){return this.promises.length>0}static async consumePromises(){const t=[...this.promises];return await Promise.all(t.map(e=>e.promise)),this.promises=this.promises.filter(e=>!t.includes(e)),t}constructor(t){this.owner=t,this.dependencies=new Set,this.event=new ou,this.markDirty=()=>this.event.raise(),this.invokable=this.invoke.bind(this),Object.defineProperty(this.invokable,"context",{value:this}),Object.defineProperty(this.invokable,"toPromise",{value:this.toPromise.bind(this)})}invoke(){}startCollecting(){if(ht.collectionSet.has(this))throw new mi("A circular dependency occurred between signals.",`This can happen when signals reference each other in a loop.
        Try using the attached stack trace to locate said loop.`);ht.collectionSet.add(this),ht.collectionStack.push(this)}finishCollecting(){if(ht.collectionSet.delete(this),ht.collectionStack.pop()!==this)throw new Error("collectStart/collectEnd was called out of order.")}clearDependencies(){this.dependencies.forEach(t=>t.unsubscribe(this.markDirty)),this.dependencies.clear()}collect(){const t=ht.collectionStack.at(-1);t&&(t.dependencies.add(this.event.subscribable),this.event.subscribe(t.markDirty))}dispose(){this.clearDependencies(),this.event.clear(),this.owner=null}async toPromise(){do await ht.consumePromises(),this.invokable();while(ht.hasPromises());return this.invokable}}ht.collectionSet=new Set;ht.collectionStack=[];ht.promises=[];const Xe=Symbol.for("@motion-canvas/core/signals/default");function Xt(n){return typeof n=="function"}function ge(n,t){return Xt(n)?()=>t(n()):t(n)}function me(n){return Xt(n)?n():n}class be extends ht{constructor(t,e,r=void 0,i=h=>h,a={}){super(r),this.initial=t,this.interpolation=e,this.parser=i,this.tweening=!1,Object.defineProperty(this.invokable,"reset",{value:this.reset.bind(this)}),Object.defineProperty(this.invokable,"save",{value:this.save.bind(this)}),Object.defineProperty(this.invokable,"isInitial",{value:this.isInitial.bind(this)}),this.initial!==void 0&&(this.current=this.initial,this.markDirty(),Xt(this.initial)||(this.last=this.parse(this.initial))),this.extensions={getter:this.getter.bind(this),setter:this.setter.bind(this),tweener:this.tweener.bind(this),...a}}toSignal(){return this.invokable}parse(t){return this.parser(t)}set(t){return this.extensions.setter(t),this.owner}setter(t){return t===Xe&&(t=this.initial),this.current===t?this.owner:(this.current=t,this.clearDependencies(),Xt(t)||(this.last=this.parse(t)),this.markDirty(),this.owner)}get(){return this.extensions.getter()}getter(){var t;if(this.event.isRaised()&&Xt(this.current)){this.clearDependencies(),this.startCollecting();try{this.last=this.parse(this.current())}catch(e){vt().error({...bi(e),inspect:(t=this.owner)==null?void 0:t.key})}this.finishCollecting()}return this.event.reset(),this.collect(),this.last}invoke(t,e,r=Et,i=this.interpolation){return t===void 0?this.get():e===void 0?this.set(t):this.createQueue(r,i).to(t,e)}createQueue(t,e){const r=this.get(),i=[],a=hi("animation chain",function*(){for(;i.length>0;)yield*i.shift()});return a.to=(h,c,m=t,y=e)=>(t=m,e=y,i.push(this.tween(h,c,m,y)),a),a.back=(h,c=t,m=e)=>(t=c,e=m,i.push(this.tween(r,h,t,e)),a),a.wait=h=>(i.push(vs(h)),a),a.run=h=>(i.push(h),a),a.do=h=>(i.push(hi(function*(){h()})),a),a}*tween(t,e,r,i){t===Xe&&(t=this.initial),this.tweening=!0,yield*this.extensions.tweener(t,e,r,i),this.set(t),this.tweening=!1}*tweener(t,e,r,i){const a=this.get();yield*_t(e,h=>{this.set(i(a,this.parse(me(t)),r(h)))})}dispose(){super.dispose(),this.initial=void 0,this.current=void 0,this.last=void 0}reset(){return this.initial!==void 0&&this.set(this.initial),this.owner}save(){return this.set(this.get())}isInitial(){return this.collect(),this.current===this.initial}getInitial(){return this.initial}raw(){return this.current}isTweening(){return this.tweening}}class Cr extends be{constructor(t,e,r,i,a=void 0,h={}){var c;super(void 0,i,a,e,h),this.entries=t,this.signals=[],this.parser=e;for(const m of t){let y,k;Array.isArray(m)?([y,k]=m,(c=k.context).owner??(c.owner=this)):(y=m,k=new be(ge(r,F=>e(F)[m]),tt,a??this.invokable).toSignal()),this.signals.push([y,k]),Object.defineProperty(this.invokable,y,{value:k})}}toSignal(){return this.invokable}parse(t){return this.parser(t)}getter(){return this.parse(Object.fromEntries(this.signals.map(([t,e])=>[t,e()])))}setter(t){if(Xt(t))for(const[e,r]of this.signals)r(()=>this.parser(t())[e]);else{const e=this.parse(t);for(const[r,i]of this.signals)i(e[r])}return this.owner}reset(){for(const[,t]of this.signals)t.reset();return this.owner}save(){for(const[,t]of this.signals)t.save();return this.owner}isInitial(){for(const[,t]of this.signals)if(!t.isInitial())return!1;return!0}raw(){return Object.fromEntries(this.signals.map(([t,e])=>[t,e.context.raw()]))}}class Hu extends ht{constructor(t,e){super(e),this.factory=t,this.markDirty()}toSignal(){return this.invokable}dispose(){super.dispose(),this.last=void 0}invoke(...t){var e;if(this.event.isRaised()){this.clearDependencies(),this.startCollecting();try{this.last=this.factory(...t)}catch(r){vt().error({...bi(r),inspect:(e=this.owner)==null?void 0:e.key})}this.finishCollecting()}return this.event.reset(),this.collect(),this.last}}class Pi extends Cr{constructor(t,e,r,i,a=void 0,h={}){super(t,e,r,i,a,h),Object.defineProperty(this.invokable,"edit",{value:this.edit.bind(this)}),Object.defineProperty(this.invokable,"mul",{value:this.mul.bind(this)}),Object.defineProperty(this.invokable,"div",{value:this.div.bind(this)}),Object.defineProperty(this.invokable,"add",{value:this.add.bind(this)}),Object.defineProperty(this.invokable,"sub",{value:this.sub.bind(this)}),Object.defineProperty(this.invokable,"dot",{value:this.dot.bind(this)}),Object.defineProperty(this.invokable,"cross",{value:this.cross.bind(this)}),Object.defineProperty(this.invokable,"mod",{value:this.mod.bind(this)})}toSignal(){return this.invokable}edit(t,e,r,i){const a=t(this.get());return this.invoke(a,e,r,i)}mul(t,e,r,i){const a=h=>h.mul(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}div(t,e,r,i){const a=h=>h.div(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}add(t,e,r,i){const a=h=>h.add(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}sub(t,e,r,i){const a=h=>h.sub(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}dot(t,e,r,i){const a=h=>h.dot(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}cross(t,e,r,i){const a=h=>h.cross(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}mod(t,e,r,i){const a=h=>h.mod(t);return e===void 0?this.edit(a):this.edit(a,e,r,i)}}function Yu(n,t){return new Hu(n,t).toSignal()}function De(n,t=_e,e){return new be(n,t,e).toSignal()}class At{static createSignal(t,e=At.lerp){return new Cr(["top","right","bottom","left"],r=>new At(r),t,e).toSignal()}static lerp(t,e,r){return new At(tt(t.top,e.top,r),tt(t.right,e.right,r),tt(t.bottom,e.bottom,r),tt(t.left,e.left,r))}get x(){return this.left+this.right}get y(){return this.top+this.bottom}constructor(t=0,e,r,i){if(this.top=0,this.right=0,this.bottom=0,this.left=0,t!=null){if(Array.isArray(t)&&(i=t[3],r=t[2],e=t[1],t=t[0]),typeof t=="number"){this.top=t,this.right=e!==void 0?e:t,this.bottom=r!==void 0?r:t,this.left=i!==void 0?i:e!==void 0?e:t;return}this.top=t.top,this.right=t.right,this.bottom=t.bottom,this.left=t.left}}lerp(t,e){return At.lerp(this,t,e)}scale(t){return new At(this.top*t,this.right*t,this.bottom*t,this.left*t)}addScalar(t){return new At(this.top+t,this.right+t,this.bottom+t,this.left+t)}toSymbol(){return At.symbol}toString(){return`Spacing(${this.top}, ${this.right}, ${this.bottom}, ${this.left})`}toUniform(t,e){t.uniform4f(e,this.top,this.right,this.bottom,this.left)}serialize(){return{top:this.top,right:this.right,bottom:this.bottom,left:this.left}}}At.symbol=Symbol.for("@motion-canvas/core/types/Spacing");const He=1e-6;class rt{static fromRotation(t){return rt.identity.rotate(t)}static fromTranslation(t){return rt.identity.translate(new g(t))}static fromScaling(t){return rt.identity.scale(new g(t))}get x(){return new g(this.values[0],this.values[1])}get y(){return new g(this.values[2],this.values[3])}get scaleX(){return this.values[0]}set scaleX(t){this.values[0]=this.x.normalized.scale(t).x}get skewX(){return this.values[1]}set skewX(t){this.values[1]=t}get scaleY(){return this.values[3]}set scaleY(t){this.values[3]=this.y.normalized.scale(t).y}get skewY(){return this.values[2]}set skewY(t){this.values[2]=t}get translateX(){return this.values[4]}set translateX(t){this.values[4]=t}get translateY(){return this.values[5]}set translateY(t){this.values[5]=t}get rotation(){return g.degrees(this.values[0],this.values[1])}set rotation(t){const e=this.rotate(t-this.rotation);this.values[0]=e.values[0],this.values[1]=e.values[1],this.values[2]=e.values[2],this.values[3]=e.values[3]}get translation(){return new g(this.values[4],this.values[5])}set translation(t){const e=new g(t);this.values[4]=e.x,this.values[5]=e.y}get scaling(){return new g(this.values[0],this.values[3])}set scaling(t){const e=new g(t),r=new g(this.values[0],this.values[1]).normalized,i=new g(this.values[2],this.values[3]).normalized;this.values[0]=r.x*e.x,this.values[1]=r.y*e.y,this.values[2]=i.x*e.x,this.values[3]=i.y*e.y}get inverse(){const t=this.values[0],e=this.values[1],r=this.values[2],i=this.values[3],a=this.values[4],h=this.values[5];let c=t*i-e*r;return c?(c=1/c,new rt(i*c,-e*c,-r*c,t*c,(r*h-i*a)*c,(e*a-t*h)*c)):null}get determinant(){return this.values[0]*this.values[3]-this.values[1]*this.values[2]}get domMatrix(){return new DOMMatrix([this.values[0],this.values[1],this.values[2],this.values[3],this.values[4],this.values[5]])}constructor(t,e,r,i,a,h){if(this.values=new Float32Array(6),arguments.length===0){this.values=new Float32Array([1,0,0,1,0,0]);return}if(arguments.length===6){this.values[0]=t,this.values[1]=e,this.values[2]=r,this.values[3]=i,this.values[4]=a,this.values[5]=h;return}if(t instanceof DOMMatrix){this.values[0]=t.m11,this.values[1]=t.m12,this.values[2]=t.m21,this.values[3]=t.m22,this.values[4]=t.m41,this.values[5]=t.m42;return}if(t instanceof rt){this.values=t.values;return}if(Array.isArray(t)){if(t.length===2){this.values[0]=t[0],this.values[1]=t[1],this.values[2]=e[0],this.values[3]=e[1],this.values[4]=r[0],this.values[5]=r[1];return}if(t.length===3){const k=new g(t[0]),F=new g(t[1]),X=new g(t[2]);this.values[0]=k.x,this.values[1]=k.y,this.values[2]=F.x,this.values[3]=F.y,this.values[4]=X.x,this.values[5]=X.y;return}this.values[0]=t[0],this.values[1]=t[1],this.values[2]=t[2],this.values[3]=t[3],this.values[4]=t[4],this.values[5]=t[5];return}const c=new g(t),m=new g(e),y=new g(r);this.values[0]=c.x,this.values[1]=c.y,this.values[2]=m.x,this.values[3]=m.y,this.values[4]=y.x,this.values[5]=y.y}column(t){return new g(this.values[t*2],this.values[t*2+1])}row(t){return[this.values[t],this.values[t+2],this.values[t+4]]}mul(t){const e=this.values[0],r=this.values[1],i=this.values[2],a=this.values[3],h=this.values[4],c=this.values[5],m=t.values[0],y=t.values[1],k=t.values[2],F=t.values[3],X=t.values[4],Q=t.values[5];return new rt(e*m+i*y,r*m+a*y,e*k+i*F,r*k+a*F,e*X+i*Q+h,r*X+a*Q+c)}rotate(t,e=!0){e&&(t*=te);const r=this.values[0],i=this.values[1],a=this.values[2],h=this.values[3],c=this.values[4],m=this.values[5],y=Math.sin(t),k=Math.cos(t);return new rt(r*k+a*y,i*k+h*y,r*-y+a*k,i*-y+h*k,c,m)}scale(t){const e=new g(t);return new rt(this.values[0]*e.x,this.values[1]*e.x,this.values[2]*e.y,this.values[3]*e.y,this.values[4],this.values[5])}mulScalar(t){return new rt(this.values[0]*t,this.values[1]*t,this.values[2]*t,this.values[3]*t,this.values[4]*t,this.values[5]*t)}translate(t){const e=new g(t);return new rt(this.values[0],this.values[1],this.values[2],this.values[3],this.values[0]*e.x+this.values[2]*e.y+this.values[4],this.values[1]*e.x+this.values[3]*e.y+this.values[5])}add(t){return new rt(this.values[0]+t.values[0],this.values[1]+t.values[1],this.values[2]+t.values[2],this.values[3]+t.values[3],this.values[4]+t.values[4],this.values[5]+t.values[5])}sub(t){return new rt(this.values[0]-t.values[0],this.values[1]-t.values[1],this.values[2]-t.values[2],this.values[3]-t.values[3],this.values[4]-t.values[4],this.values[5]-t.values[5])}toSymbol(){return rt.symbol}toUniform(t,e){t.uniformMatrix3fv(e,!1,[this.values[0],this.values[1],0,this.values[2],this.values[3],0,this.values[4],this.values[5],1])}equals(t,e=He){return Math.abs(this.values[0]-t.values[0])<=e+Number.EPSILON&&Math.abs(this.values[1]-t.values[1])<=e+Number.EPSILON&&Math.abs(this.values[2]-t.values[2])<=e+Number.EPSILON&&Math.abs(this.values[3]-t.values[3])<=e+Number.EPSILON&&Math.abs(this.values[4]-t.values[4])<=e+Number.EPSILON&&Math.abs(this.values[5]-t.values[5])<=e+Number.EPSILON}exactlyEquals(t){return this.values[0]===t.values[0]&&this.values[1]===t.values[1]&&this.values[2]===t.values[2]&&this.values[3]===t.values[3]&&this.values[4]===t.values[4]&&this.values[5]===t.values[5]}}rt.symbol=Symbol.for("@motion-canvas/core/types/Matrix2D");rt.identity=new rt(1,0,0,1,0,0);rt.zero=new rt(0,0,0,0,0,0);var ci;(function(n){n[n.Vertical=1]="Vertical",n[n.Horizontal=2]="Horizontal"})(ci||(ci={}));var xt;(function(n){n[n.Top=4]="Top",n[n.Bottom=8]="Bottom",n[n.Left=16]="Left",n[n.Right=32]="Right"})(xt||(xt={}));var it;(function(n){n[n.Middle=3]="Middle",n[n.Top=5]="Top",n[n.Bottom=9]="Bottom",n[n.Left=18]="Left",n[n.Right=34]="Right",n[n.TopLeft=20]="TopLeft",n[n.TopRight=36]="TopRight",n[n.BottomLeft=24]="BottomLeft",n[n.BottomRight=40]="BottomRight"})(it||(it={}));function Zu(n){if(n===it.Middle)return g.zero;let t=0;n&xt.Left?t=-1:n&xt.Right&&(t=1);let e=0;return n&xt.Top?e=-1:n&xt.Bottom&&(e=1),new g(t,e)}class g{static createSignal(t,e=g.lerp,r){return new Pi(["x","y"],i=>new g(i),t,e,r).toSignal()}static lerp(t,e,r){let i,a;return typeof r=="number"?i=a=r:(i=r.x,a=r.y),new g(tt(t.x,e.x,i),tt(t.y,e.y,a))}static arcLerp(t,e,r,i=!1,a){return a??(a=t.sub(e).ctg),g.lerp(t,e,Ti(r,i,a))}static createArcLerp(t,e){return(r,i,a)=>g.arcLerp(r,i,a,t,e)}static polarLerp(t,e,r,i=!1,a=g.zero){t=t.sub(a),e=e.sub(a);const h=t.degrees;let c=e.degrees;h>c!==i&&(c=c+(i?-360:360));const y=tt(h,c,r)*te,k=tt(t.magnitude,e.magnitude,r);return new g(k*Math.cos(y)+a.x,k*Math.sin(y)+a.y)}static createPolarLerp(t=!1,e=g.zero){return(r,i,a)=>g.polarLerp(r,i,a,t,new g(e))}static fromOrigin(t){const e=new g;return t===it.Middle||(t&xt.Left?e.x=-1:t&xt.Right&&(e.x=1),t&xt.Top?e.y=-1:t&xt.Bottom&&(e.y=1)),e}static fromScalar(t){return new g(t,t)}static fromRadians(t){return new g(Math.cos(t),Math.sin(t))}static fromDegrees(t){return g.fromRadians(t*te)}static radians(t,e){return Math.atan2(e,t)}static degrees(t,e){return g.radians(t,e)*xu}static magnitude(t,e){return Math.sqrt(t*t+e*e)}static squaredMagnitude(t,e){return t*t+e*e}static angleBetween(t,e){return Math.acos(wt(-1,1,t.dot(e)/(t.magnitude*e.magnitude)))*(t.cross(e)>=0?1:-1)}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}get magnitude(){return g.magnitude(this.x,this.y)}get squaredMagnitude(){return g.squaredMagnitude(this.x,this.y)}get normalized(){return this.scale(1/g.magnitude(this.x,this.y))}get safe(){return new g(isNaN(this.x)?0:this.x,isNaN(this.y)?0:this.y)}get flipped(){return new g(-this.x,-this.y)}get floored(){return new g(Math.floor(this.x),Math.floor(this.y))}get rounded(){return new g(Math.round(this.x),Math.round(this.y))}get ceiled(){return new g(Math.ceil(this.x),Math.ceil(this.y))}get perpendicular(){return new g(this.y,-this.x)}get radians(){return g.radians(this.x,this.y)}get degrees(){return g.degrees(this.x,this.y)}get ctg(){return this.x/this.y}constructor(t,e){if(this.x=0,this.y=0,t!=null){if(typeof t!="object"){this.x=t,this.y=e??t;return}if(Array.isArray(t)){this.x=t[0],this.y=t[1];return}if("width"in t){this.x=t.width,this.y=t.height;return}this.x=t.x,this.y=t.y}}lerp(t,e){return g.lerp(this,t,e)}getOriginOffset(t){const e=g.fromOrigin(t);return e.x*=this.x/2,e.y*=this.y/2,e}scale(t){return new g(this.x*t,this.y*t)}transformAsPoint(t){const e=new rt(t);return new g(this.x*e.scaleX+this.y*e.skewY+e.translateX,this.x*e.skewX+this.y*e.scaleY+e.translateY)}transform(t){const e=new rt(t);return new g(this.x*e.scaleX+this.y*e.skewY,this.x*e.skewX+this.y*e.scaleY)}mul(t){const e=new g(t);return new g(this.x*e.x,this.y*e.y)}div(t){const e=new g(t);return new g(this.x/e.x,this.y/e.y)}add(t){const e=new g(t);return new g(this.x+e.x,this.y+e.y)}sub(t){const e=new g(t);return new g(this.x-e.x,this.y-e.y)}dot(t){const e=new g(t);return this.x*e.x+this.y*e.y}cross(t){const e=new g(t);return this.x*e.y-this.y*e.x}mod(t){const e=new g(t);return new g(this.x%e.x,this.y%e.y)}rotate(t,e=g.zero){const r=new g(e),i=rt.fromTranslation(r).rotate(t).translate(r.flipped);return this.transformAsPoint(i)}addX(t){return new g(this.x+t,this.y)}addY(t){return new g(this.x,this.y+t)}map(t){return new g(t(this.x,0),t(this.y,1))}toSymbol(){return g.symbol}toString(){return`Vector2(${this.x}, ${this.y})`}toArray(){return[this.x,this.y]}toUniform(t,e){t.uniform2f(e,this.x,this.y)}serialize(){return{x:this.x,y:this.y}}exactlyEquals(t){return this.x===t.x&&this.y===t.y}equals(t,e=He){return Math.abs(this.x-t.x)<=e+Number.EPSILON&&Math.abs(this.y-t.y)<=e+Number.EPSILON}*[Symbol.iterator](){yield this.x,yield this.y}}g.symbol=Symbol.for("@motion-canvas/core/types/Vector2");g.zero=new g;g.one=new g(1,1);g.right=new g(1,0);g.left=new g(-1,0);g.up=new g(0,1);g.down=new g(0,-1);g.top=new g(0,-1);g.bottom=new g(0,1);g.topLeft=new g(-1,-1);g.topRight=new g(1,-1);g.bottomLeft=new g(-1,1);g.bottomRight=new g(1,1);class Y{static createSignal(t,e=Y.lerp){return new Cr(["x","y","width","height"],r=>new Y(r),t,e).toSignal()}static lerp(t,e,r){let i,a,h,c;return typeof r=="number"?i=a=h=c=r:r instanceof g?(i=h=r.x,a=c=r.y):(i=r.x,a=r.y,h=r.width,c=r.height),new Y(tt(t.x,e.x,i),tt(t.y,e.y,a),tt(t.width,e.width,h),tt(t.height,e.height,c))}static arcLerp(t,e,r,i=!1,a){return a??(a=(t.position.sub(e.position).ctg+t.size.sub(e.size).ctg)/2),Y.lerp(t,e,Ti(r,i,a))}static fromSizeCentered(t){return new Y(-t.width/2,-t.height/2,t.width,t.height)}static fromPoints(...t){let e=1/0,r=1/0,i=-1/0,a=-1/0;for(const h of t)h.x>i&&(i=h.x),h.x<e&&(e=h.x),h.y>a&&(a=h.y),h.y<r&&(r=h.y);return new Y(e,r,i-e,a-r)}static fromBBoxes(...t){let e=1/0,r=1/0,i=-1/0,a=-1/0;for(const h of t){const c=h.x+h.width;c>i&&(i=c),h.x<e&&(e=h.x);const m=h.y+h.height;m>a&&(a=m),h.y<r&&(r=h.y)}return new Y(e,r,i-e,a-r)}lerp(t,e){return Y.lerp(this,t,e)}get position(){return new g(this.x,this.y)}set position(t){this.x=t.x,this.y=t.y}get size(){return new g(this.width,this.height)}get center(){return new g(this.x+this.width/2,this.y+this.height/2)}get left(){return this.x}set left(t){this.width+=this.x-t,this.x=t}get right(){return this.x+this.width}set right(t){this.width=t-this.x}get top(){return this.y}set top(t){this.height+=this.y-t,this.y=t}get bottom(){return this.y+this.height}set bottom(t){this.height=t-this.y}get topLeft(){return this.position}get topRight(){return new g(this.x+this.width,this.y)}get bottomLeft(){return new g(this.x,this.y+this.height)}get bottomRight(){return new g(this.x+this.width,this.y+this.height)}get corners(){return[this.topLeft,this.topRight,this.bottomRight,this.bottomLeft]}get pixelPerfect(){return new Y(Math.floor(this.x),Math.floor(this.y),Math.ceil(this.width+1),Math.ceil(this.height+1))}constructor(t,e=0,r=0,i=0){if(this.x=0,this.y=0,this.width=0,this.height=0,t!=null){if(typeof t=="number"){this.x=t,this.y=e,this.width=r,this.height=i;return}if(t instanceof g){this.x=t.x,this.y=t.y,e instanceof g&&(this.width=e.x,this.height=e.y);return}if(Array.isArray(t)){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3];return}this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}}transform(t){return new Y(this.position.transformAsPoint(t),this.size.transform(t))}transformCorners(t){return this.corners.map(e=>e.transformAsPoint(t))}expand(t){const e=new At(t),r=new Y(this);return r.left-=e.left,r.top-=e.top,r.right+=e.right,r.bottom+=e.bottom,r}addSpacing(t){return this.expand(t)}includes(t){return t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height}intersects(t){return this.left<t.right&&this.right>t.left&&this.top<t.bottom&&this.bottom>t.top}intersection(t){const e=new Y;return this.intersects(t)&&(e.left=Math.max(this.left,t.left),e.top=Math.max(this.top,t.top),e.right=Math.min(this.right,t.right),e.bottom=Math.min(this.bottom,t.bottom)),e}union(t){const e=new Y;return e.left=Math.min(this.left,t.left),e.top=Math.min(this.top,t.top),e.right=Math.max(this.right,t.right),e.bottom=Math.max(this.bottom,t.bottom),e}toSymbol(){return Y.symbol}toString(){return`BBox(${this.x}, ${this.y}, ${this.width}, ${this.height})`}toUniform(t,e){t.uniform4f(e,this.x,this.y,this.width,this.height)}serialize(){return{x:this.x,y:this.y,width:this.width,height:this.height}}}Y.symbol=Symbol.for("@motion-canvas/core/types/Rect");var Vu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ri={exports:{}};/**
 * chroma.js - JavaScript library for color conversions
 *
 * Copyright (c) 2011-2019, Gregor Aisch
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name Gregor Aisch may not be used to endorse or promote products
 * derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * -------------------------------------------------------
 *
 * chroma.js includes colors from colorbrewer2.org, which are released under
 * the following license:
 *
 * Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
 * and The Pennsylvania State University.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * ------------------------------------------------------
 *
 * Named colors are taken from X11 Color Names.
 * http://www.w3.org/TR/css3-color/#svg-color
 *
 * @preserve
 */(function(n,t){(function(e,r){n.exports=r()})(Vu,function(){for(var e=function(s,o,l){return o===void 0&&(o=0),l===void 0&&(l=1),s<o?o:s>l?l:s},r=e,i=function(s){s._clipped=!1,s._unclipped=s.slice(0);for(var o=0;o<=3;o++)o<3?((s[o]<0||s[o]>255)&&(s._clipped=!0),s[o]=r(s[o],0,255)):o===3&&(s[o]=r(s[o],0,1));return s},a={},h=0,c=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];h<c.length;h+=1){var m=c[h];a["[object "+m+"]"]=m.toLowerCase()}var y=function(s){return a[Object.prototype.toString.call(s)]||"object"},k=y,F=function(s,o){return o===void 0&&(o=null),s.length>=3?Array.prototype.slice.call(s):k(s[0])=="object"&&o?o.split("").filter(function(l){return s[0][l]!==void 0}).map(function(l){return s[0][l]}):s[0]},X=y,Q=function(s){if(s.length<2)return null;var o=s.length-1;return X(s[o])=="string"?s[o].toLowerCase():null},at=Math.PI,T={clip_rgb:i,limit:e,type:y,unpack:F,last:Q,PI:at,TWOPI:at*2,PITHIRD:at/3,DEG2RAD:at/180,RAD2DEG:180/at},st={format:{},autodetect:[]},Pt=T.last,nt=T.clip_rgb,Be=T.type,Ft=st,ks=function(){for(var o=[],l=arguments.length;l--;)o[l]=arguments[l];var u=this;if(Be(o[0])==="object"&&o[0].constructor&&o[0].constructor===this.constructor)return o[0];var d=Pt(o),p=!1;if(!d){p=!0,Ft.sorted||(Ft.autodetect=Ft.autodetect.sort(function(x,R){return R.p-x.p}),Ft.sorted=!0);for(var f=0,v=Ft.autodetect;f<v.length;f+=1){var b=v[f];if(d=b.test.apply(b,o),d)break}}if(Ft.format[d]){var w=Ft.format[d].apply(null,p?o:o.slice(0,-1));u._rgb=nt(w)}else throw new Error("unknown format: "+o);u._rgb.length===3&&u._rgb.push(1)};ks.prototype.toString=function(){return Be(this.hex)=="function"?this.hex():"["+this._rgb.join(",")+"]"};var D=ks,nr=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(nr.Color,[null].concat(s)))};nr.Color=D,nr.version="2.4.2";var ot=nr,Fi=T.unpack,Ts=Math.max,Ei=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Fi(s,"rgb"),u=l[0],d=l[1],p=l[2];u=u/255,d=d/255,p=p/255;var f=1-Ts(u,Ts(d,p)),v=f<1?1/(1-f):0,b=(1-u-f)*v,w=(1-d-f)*v,x=(1-p-f)*v;return[b,w,x,f]},_i=Ei,Di=T.unpack,ji=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=Di(s,"cmyk");var l=s[0],u=s[1],d=s[2],p=s[3],f=s.length>4?s[4]:1;return p===1?[0,0,0,f]:[l>=1?0:255*(1-l)*(1-p),u>=1?0:255*(1-u)*(1-p),d>=1?0:255*(1-d)*(1-p),f]},Bi=ji,Ni=ot,Ps=D,Rs=st,Wi=T.unpack,Ui=T.type,qi=_i;Ps.prototype.cmyk=function(){return qi(this._rgb)},Ni.cmyk=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Ps,[null].concat(s,["cmyk"])))},Rs.format.cmyk=Bi,Rs.autodetect.push({p:2,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=Wi(s,"cmyk"),Ui(s)==="array"&&s.length===4)return"cmyk"}});var Gi=T.unpack,Xi=T.last,Rr=function(s){return Math.round(s*100)/100},Hi=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Gi(s,"hsla"),u=Xi(s)||"lsa";return l[0]=Rr(l[0]||0),l[1]=Rr(l[1]*100)+"%",l[2]=Rr(l[2]*100)+"%",u==="hsla"||l.length>3&&l[3]<1?(l[3]=l.length>3?l[3]:1,u="hsla"):l.length=3,u+"("+l.join(",")+")"},Yi=Hi,Zi=T.unpack,Vi=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=Zi(s,"rgba");var l=s[0],u=s[1],d=s[2];l/=255,u/=255,d/=255;var p=Math.min(l,u,d),f=Math.max(l,u,d),v=(f+p)/2,b,w;return f===p?(b=0,w=Number.NaN):b=v<.5?(f-p)/(f+p):(f-p)/(2-f-p),l==f?w=(u-d)/(f-p):u==f?w=2+(d-l)/(f-p):d==f&&(w=4+(l-u)/(f-p)),w*=60,w<0&&(w+=360),s.length>3&&s[3]!==void 0?[w,b,v,s[3]]:[w,b,v]},Ms=Vi,Ji=T.unpack,Qi=T.last,Ki=Yi,ta=Ms,Mr=Math.round,ea=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Ji(s,"rgba"),u=Qi(s)||"rgb";return u.substr(0,3)=="hsl"?Ki(ta(l),u):(l[0]=Mr(l[0]),l[1]=Mr(l[1]),l[2]=Mr(l[2]),(u==="rgba"||l.length>3&&l[3]<1)&&(l[3]=l.length>3?l[3]:1,u="rgba"),u+"("+l.slice(0,u==="rgb"?3:4).join(",")+")")},ra=ea,sa=T.unpack,$r=Math.round,na=function(){for(var s,o=[],l=arguments.length;l--;)o[l]=arguments[l];o=sa(o,"hsl");var u=o[0],d=o[1],p=o[2],f,v,b;if(d===0)f=v=b=p*255;else{var w=[0,0,0],x=[0,0,0],R=p<.5?p*(1+d):p+d-p*d,C=2*p-R,$=u/360;w[0]=$+1/3,w[1]=$,w[2]=$-1/3;for(var M=0;M<3;M++)w[M]<0&&(w[M]+=1),w[M]>1&&(w[M]-=1),6*w[M]<1?x[M]=C+(R-C)*6*w[M]:2*w[M]<1?x[M]=R:3*w[M]<2?x[M]=C+(R-C)*(2/3-w[M])*6:x[M]=C;s=[$r(x[0]*255),$r(x[1]*255),$r(x[2]*255)],f=s[0],v=s[1],b=s[2]}return o.length>3?[f,v,b,o[3]]:[f,v,b,1]},$s=na,Ls=$s,As=st,Os=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,zs=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,Is=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Fs=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Es=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,_s=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Ds=Math.round,js=function(s){s=s.toLowerCase().trim();var o;if(As.format.named)try{return As.format.named(s)}catch{}if(o=s.match(Os)){for(var l=o.slice(1,4),u=0;u<3;u++)l[u]=+l[u];return l[3]=1,l}if(o=s.match(zs)){for(var d=o.slice(1,5),p=0;p<4;p++)d[p]=+d[p];return d}if(o=s.match(Is)){for(var f=o.slice(1,4),v=0;v<3;v++)f[v]=Ds(f[v]*2.55);return f[3]=1,f}if(o=s.match(Fs)){for(var b=o.slice(1,5),w=0;w<3;w++)b[w]=Ds(b[w]*2.55);return b[3]=+b[3],b}if(o=s.match(Es)){var x=o.slice(1,4);x[1]*=.01,x[2]*=.01;var R=Ls(x);return R[3]=1,R}if(o=s.match(_s)){var C=o.slice(1,4);C[1]*=.01,C[2]*=.01;var $=Ls(C);return $[3]=+o[4],$}};js.test=function(s){return Os.test(s)||zs.test(s)||Is.test(s)||Fs.test(s)||Es.test(s)||_s.test(s)};var ia=js,aa=ot,Bs=D,Ns=st,oa=T.type,la=ra,Ws=ia;Bs.prototype.css=function(s){return la(this._rgb,s)},aa.css=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Bs,[null].concat(s,["css"])))},Ns.format.css=Ws,Ns.autodetect.push({p:5,test:function(s){for(var o=[],l=arguments.length-1;l-- >0;)o[l]=arguments[l+1];if(!o.length&&oa(s)==="string"&&Ws.test(s))return"css"}});var Us=D,ha=ot,ua=st,ca=T.unpack;ua.format.gl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=ca(s,"rgba");return l[0]*=255,l[1]*=255,l[2]*=255,l},ha.gl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Us,[null].concat(s,["gl"])))},Us.prototype.gl=function(){var s=this._rgb;return[s[0]/255,s[1]/255,s[2]/255,s[3]]};var fa=T.unpack,da=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=fa(s,"rgb"),u=l[0],d=l[1],p=l[2],f=Math.min(u,d,p),v=Math.max(u,d,p),b=v-f,w=b*100/255,x=f/(255-b)*100,R;return b===0?R=Number.NaN:(u===v&&(R=(d-p)/b),d===v&&(R=2+(p-u)/b),p===v&&(R=4+(u-d)/b),R*=60,R<0&&(R+=360)),[R,w,x]},pa=da,ga=T.unpack,va=Math.floor,ma=function(){for(var s,o,l,u,d,p,f=[],v=arguments.length;v--;)f[v]=arguments[v];f=ga(f,"hcg");var b=f[0],w=f[1],x=f[2],R,C,$;x=x*255;var M=w*255;if(w===0)R=C=$=x;else{b===360&&(b=0),b>360&&(b-=360),b<0&&(b+=360),b/=60;var j=va(b),W=b-j,q=x*(1-w),H=q+M*(1-W),dt=q+M*W,ft=q+M;switch(j){case 0:s=[ft,dt,q],R=s[0],C=s[1],$=s[2];break;case 1:o=[H,ft,q],R=o[0],C=o[1],$=o[2];break;case 2:l=[q,ft,dt],R=l[0],C=l[1],$=l[2];break;case 3:u=[q,H,ft],R=u[0],C=u[1],$=u[2];break;case 4:d=[dt,q,ft],R=d[0],C=d[1],$=d[2];break;case 5:p=[ft,q,H],R=p[0],C=p[1],$=p[2];break}}return[R,C,$,f.length>3?f[3]:1]},ba=ma,ya=T.unpack,wa=T.type,xa=ot,qs=D,Gs=st,Ca=pa;qs.prototype.hcg=function(){return Ca(this._rgb)},xa.hcg=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(qs,[null].concat(s,["hcg"])))},Gs.format.hcg=ba,Gs.autodetect.push({p:1,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=ya(s,"hcg"),wa(s)==="array"&&s.length===3)return"hcg"}});var Sa=T.unpack,ka=T.last,ir=Math.round,Ta=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Sa(s,"rgba"),u=l[0],d=l[1],p=l[2],f=l[3],v=ka(s)||"auto";f===void 0&&(f=1),v==="auto"&&(v=f<1?"rgba":"rgb"),u=ir(u),d=ir(d),p=ir(p);var b=u<<16|d<<8|p,w="000000"+b.toString(16);w=w.substr(w.length-6);var x="0"+ir(f*255).toString(16);switch(x=x.substr(x.length-2),v.toLowerCase()){case"rgba":return"#"+w+x;case"argb":return"#"+x+w;default:return"#"+w}},Xs=Ta,Pa=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Ra=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Ma=function(s){if(s.match(Pa)){(s.length===4||s.length===7)&&(s=s.substr(1)),s.length===3&&(s=s.split(""),s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);var o=parseInt(s,16),l=o>>16,u=o>>8&255,d=o&255;return[l,u,d,1]}if(s.match(Ra)){(s.length===5||s.length===9)&&(s=s.substr(1)),s.length===4&&(s=s.split(""),s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]+s[3]+s[3]);var p=parseInt(s,16),f=p>>24&255,v=p>>16&255,b=p>>8&255,w=Math.round((p&255)/255*100)/100;return[f,v,b,w]}throw new Error("unknown hex color: "+s)},Hs=Ma,$a=ot,Ys=D,La=T.type,Zs=st,Aa=Xs;Ys.prototype.hex=function(s){return Aa(this._rgb,s)},$a.hex=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Ys,[null].concat(s,["hex"])))},Zs.format.hex=Hs,Zs.autodetect.push({p:4,test:function(s){for(var o=[],l=arguments.length-1;l-- >0;)o[l]=arguments[l+1];if(!o.length&&La(s)==="string"&&[3,4,5,6,7,8,9].indexOf(s.length)>=0)return"hex"}});var Oa=T.unpack,Vs=T.TWOPI,za=Math.min,Ia=Math.sqrt,Fa=Math.acos,Ea=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Oa(s,"rgb"),u=l[0],d=l[1],p=l[2];u/=255,d/=255,p/=255;var f,v=za(u,d,p),b=(u+d+p)/3,w=b>0?1-v/b:0;return w===0?f=NaN:(f=(u-d+(u-p))/2,f/=Ia((u-d)*(u-d)+(u-p)*(d-p)),f=Fa(f),p>d&&(f=Vs-f),f/=Vs),[f*360,w,b]},_a=Ea,Da=T.unpack,Lr=T.limit,Se=T.TWOPI,Ar=T.PITHIRD,ke=Math.cos,ja=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=Da(s,"hsi");var l=s[0],u=s[1],d=s[2],p,f,v;return isNaN(l)&&(l=0),isNaN(u)&&(u=0),l>360&&(l-=360),l<0&&(l+=360),l/=360,l<1/3?(v=(1-u)/3,p=(1+u*ke(Se*l)/ke(Ar-Se*l))/3,f=1-(v+p)):l<2/3?(l-=1/3,p=(1-u)/3,f=(1+u*ke(Se*l)/ke(Ar-Se*l))/3,v=1-(p+f)):(l-=2/3,f=(1-u)/3,v=(1+u*ke(Se*l)/ke(Ar-Se*l))/3,p=1-(f+v)),p=Lr(d*p*3),f=Lr(d*f*3),v=Lr(d*v*3),[p*255,f*255,v*255,s.length>3?s[3]:1]},Ba=ja,Na=T.unpack,Wa=T.type,Ua=ot,Js=D,Qs=st,qa=_a;Js.prototype.hsi=function(){return qa(this._rgb)},Ua.hsi=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Js,[null].concat(s,["hsi"])))},Qs.format.hsi=Ba,Qs.autodetect.push({p:2,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=Na(s,"hsi"),Wa(s)==="array"&&s.length===3)return"hsi"}});var Ga=T.unpack,Xa=T.type,Ha=ot,Ks=D,tn=st,Ya=Ms;Ks.prototype.hsl=function(){return Ya(this._rgb)},Ha.hsl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Ks,[null].concat(s,["hsl"])))},tn.format.hsl=$s,tn.autodetect.push({p:2,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=Ga(s,"hsl"),Xa(s)==="array"&&s.length===3)return"hsl"}});var Za=T.unpack,Va=Math.min,Ja=Math.max,Qa=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=Za(s,"rgb");var l=s[0],u=s[1],d=s[2],p=Va(l,u,d),f=Ja(l,u,d),v=f-p,b,w,x;return x=f/255,f===0?(b=Number.NaN,w=0):(w=v/f,l===f&&(b=(u-d)/v),u===f&&(b=2+(d-l)/v),d===f&&(b=4+(l-u)/v),b*=60,b<0&&(b+=360)),[b,w,x]},Ka=Qa,to=T.unpack,eo=Math.floor,ro=function(){for(var s,o,l,u,d,p,f=[],v=arguments.length;v--;)f[v]=arguments[v];f=to(f,"hsv");var b=f[0],w=f[1],x=f[2],R,C,$;if(x*=255,w===0)R=C=$=x;else{b===360&&(b=0),b>360&&(b-=360),b<0&&(b+=360),b/=60;var M=eo(b),j=b-M,W=x*(1-w),q=x*(1-w*j),H=x*(1-w*(1-j));switch(M){case 0:s=[x,H,W],R=s[0],C=s[1],$=s[2];break;case 1:o=[q,x,W],R=o[0],C=o[1],$=o[2];break;case 2:l=[W,x,H],R=l[0],C=l[1],$=l[2];break;case 3:u=[W,q,x],R=u[0],C=u[1],$=u[2];break;case 4:d=[H,W,x],R=d[0],C=d[1],$=d[2];break;case 5:p=[x,W,q],R=p[0],C=p[1],$=p[2];break}}return[R,C,$,f.length>3?f[3]:1]},so=ro,no=T.unpack,io=T.type,ao=ot,en=D,rn=st,oo=Ka;en.prototype.hsv=function(){return oo(this._rgb)},ao.hsv=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(en,[null].concat(s,["hsv"])))},rn.format.hsv=so,rn.autodetect.push({p:2,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=no(s,"hsv"),io(s)==="array"&&s.length===3)return"hsv"}});var ar={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},Te=ar,lo=T.unpack,sn=Math.pow,ho=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=lo(s,"rgb"),u=l[0],d=l[1],p=l[2],f=uo(u,d,p),v=f[0],b=f[1],w=f[2],x=116*b-16;return[x<0?0:x,500*(v-b),200*(b-w)]},Or=function(s){return(s/=255)<=.04045?s/12.92:sn((s+.055)/1.055,2.4)},zr=function(s){return s>Te.t3?sn(s,1/3):s/Te.t2+Te.t0},uo=function(s,o,l){s=Or(s),o=Or(o),l=Or(l);var u=zr((.4124564*s+.3575761*o+.1804375*l)/Te.Xn),d=zr((.2126729*s+.7151522*o+.072175*l)/Te.Yn),p=zr((.0193339*s+.119192*o+.9503041*l)/Te.Zn);return[u,d,p]},nn=ho,Pe=ar,co=T.unpack,fo=Math.pow,po=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=co(s,"lab");var l=s[0],u=s[1],d=s[2],p,f,v,b,w,x;return f=(l+16)/116,p=isNaN(u)?f:f+u/500,v=isNaN(d)?f:f-d/200,f=Pe.Yn*Fr(f),p=Pe.Xn*Fr(p),v=Pe.Zn*Fr(v),b=Ir(3.2404542*p-1.5371385*f-.4985314*v),w=Ir(-.969266*p+1.8760108*f+.041556*v),x=Ir(.0556434*p-.2040259*f+1.0572252*v),[b,w,x,s.length>3?s[3]:1]},Ir=function(s){return 255*(s<=.00304?12.92*s:1.055*fo(s,1/2.4)-.055)},Fr=function(s){return s>Pe.t1?s*s*s:Pe.t2*(s-Pe.t0)},an=po,go=T.unpack,vo=T.type,mo=ot,on=D,ln=st,bo=nn;on.prototype.lab=function(){return bo(this._rgb)},mo.lab=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(on,[null].concat(s,["lab"])))},ln.format.lab=an,ln.autodetect.push({p:2,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=go(s,"lab"),vo(s)==="array"&&s.length===3)return"lab"}});var yo=T.unpack,wo=T.RAD2DEG,xo=Math.sqrt,Co=Math.atan2,So=Math.round,ko=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=yo(s,"lab"),u=l[0],d=l[1],p=l[2],f=xo(d*d+p*p),v=(Co(p,d)*wo+360)%360;return So(f*1e4)===0&&(v=Number.NaN),[u,f,v]},hn=ko,To=T.unpack,Po=nn,Ro=hn,Mo=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=To(s,"rgb"),u=l[0],d=l[1],p=l[2],f=Po(u,d,p),v=f[0],b=f[1],w=f[2];return Ro(v,b,w)},$o=Mo,Lo=T.unpack,Ao=T.DEG2RAD,Oo=Math.sin,zo=Math.cos,Io=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Lo(s,"lch"),u=l[0],d=l[1],p=l[2];return isNaN(p)&&(p=0),p=p*Ao,[u,zo(p)*d,Oo(p)*d]},un=Io,Fo=T.unpack,Eo=un,_o=an,Do=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=Fo(s,"lch");var l=s[0],u=s[1],d=s[2],p=Eo(l,u,d),f=p[0],v=p[1],b=p[2],w=_o(f,v,b),x=w[0],R=w[1],C=w[2];return[x,R,C,s.length>3?s[3]:1]},cn=Do,jo=T.unpack,Bo=cn,No=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=jo(s,"hcl").reverse();return Bo.apply(void 0,l)},Wo=No,Uo=T.unpack,qo=T.type,fn=ot,or=D,Er=st,dn=$o;or.prototype.lch=function(){return dn(this._rgb)},or.prototype.hcl=function(){return dn(this._rgb).reverse()},fn.lch=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(or,[null].concat(s,["lch"])))},fn.hcl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(or,[null].concat(s,["hcl"])))},Er.format.lch=cn,Er.format.hcl=Wo,["lch","hcl"].forEach(function(s){return Er.autodetect.push({p:2,test:function(){for(var o=[],l=arguments.length;l--;)o[l]=arguments[l];if(o=Uo(o,s),qo(o)==="array"&&o.length===3)return s}})});var Go={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},pn=Go,Xo=D,gn=st,Ho=T.type,Ne=pn,Yo=Hs,Zo=Xs;Xo.prototype.name=function(){for(var s=Zo(this._rgb,"rgb"),o=0,l=Object.keys(Ne);o<l.length;o+=1){var u=l[o];if(Ne[u]===s)return u.toLowerCase()}return s},gn.format.named=function(s){if(s=s.toLowerCase(),Ne[s])return Yo(Ne[s]);throw new Error("unknown color name: "+s)},gn.autodetect.push({p:5,test:function(s){for(var o=[],l=arguments.length-1;l-- >0;)o[l]=arguments[l+1];if(!o.length&&Ho(s)==="string"&&Ne[s.toLowerCase()])return"named"}});var Vo=T.unpack,Jo=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=Vo(s,"rgb"),u=l[0],d=l[1],p=l[2];return(u<<16)+(d<<8)+p},Qo=Jo,Ko=T.type,tl=function(s){if(Ko(s)=="number"&&s>=0&&s<=16777215){var o=s>>16,l=s>>8&255,u=s&255;return[o,l,u,1]}throw new Error("unknown num color: "+s)},el=tl,rl=ot,vn=D,mn=st,sl=T.type,nl=Qo;vn.prototype.num=function(){return nl(this._rgb)},rl.num=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(vn,[null].concat(s,["num"])))},mn.format.num=el,mn.autodetect.push({p:5,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s.length===1&&sl(s[0])==="number"&&s[0]>=0&&s[0]<=16777215)return"num"}});var il=ot,_r=D,bn=st,yn=T.unpack,wn=T.type,xn=Math.round;_r.prototype.rgb=function(s){return s===void 0&&(s=!0),s===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(xn)},_r.prototype.rgba=function(s){return s===void 0&&(s=!0),this._rgb.slice(0,4).map(function(o,l){return l<3?s===!1?o:xn(o):o})},il.rgb=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(_r,[null].concat(s,["rgb"])))},bn.format.rgb=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=yn(s,"rgba");return l[3]===void 0&&(l[3]=1),l},bn.autodetect.push({p:3,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=yn(s,"rgba"),wn(s)==="array"&&(s.length===3||s.length===4&&wn(s[3])=="number"&&s[3]>=0&&s[3]<=1))return"rgb"}});var lr=Math.log,al=function(s){var o=s/100,l,u,d;return o<66?(l=255,u=o<6?0:-155.25485562709179-.44596950469579133*(u=o-2)+104.49216199393888*lr(u),d=o<20?0:-254.76935184120902+.8274096064007395*(d=o-10)+115.67994401066147*lr(d)):(l=351.97690566805693+.114206453784165*(l=o-55)-40.25366309332127*lr(l),u=325.4494125711974+.07943456536662342*(u=o-50)-28.0852963507957*lr(u),d=255),[l,u,d,1]},Cn=al,ol=Cn,ll=T.unpack,hl=Math.round,ul=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];for(var l=ll(s,"rgb"),u=l[0],d=l[2],p=1e3,f=4e4,v=.4,b;f-p>v;){b=(f+p)*.5;var w=ol(b);w[2]/w[0]>=d/u?f=b:p=b}return hl(b)},cl=ul,Dr=ot,hr=D,jr=st,fl=cl;hr.prototype.temp=hr.prototype.kelvin=hr.prototype.temperature=function(){return fl(this._rgb)},Dr.temp=Dr.kelvin=Dr.temperature=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(hr,[null].concat(s,["temp"])))},jr.format.temp=jr.format.kelvin=jr.format.temperature=Cn;var dl=T.unpack,Br=Math.cbrt,pl=Math.pow,gl=Math.sign,vl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=dl(s,"rgb"),u=l[0],d=l[1],p=l[2],f=[Nr(u/255),Nr(d/255),Nr(p/255)],v=f[0],b=f[1],w=f[2],x=Br(.4122214708*v+.5363325363*b+.0514459929*w),R=Br(.2119034982*v+.6806995451*b+.1073969566*w),C=Br(.0883024619*v+.2817188376*b+.6299787005*w);return[.2104542553*x+.793617785*R-.0040720468*C,1.9779984951*x-2.428592205*R+.4505937099*C,.0259040371*x+.7827717662*R-.808675766*C]},Sn=vl;function Nr(s){var o=Math.abs(s);return o<.04045?s/12.92:(gl(s)||1)*pl((o+.055)/1.055,2.4)}var ml=T.unpack,ur=Math.pow,bl=Math.sign,yl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=ml(s,"lab");var l=s[0],u=s[1],d=s[2],p=ur(l+.3963377774*u+.2158037573*d,3),f=ur(l-.1055613458*u-.0638541728*d,3),v=ur(l-.0894841775*u-1.291485548*d,3);return[255*Wr(4.0767416621*p-3.3077115913*f+.2309699292*v),255*Wr(-1.2684380046*p+2.6097574011*f-.3413193965*v),255*Wr(-.0041960863*p-.7034186147*f+1.707614701*v),s.length>3?s[3]:1]},kn=yl;function Wr(s){var o=Math.abs(s);return o>.0031308?(bl(s)||1)*(1.055*ur(o,1/2.4)-.055):s*12.92}var wl=T.unpack,xl=T.type,Cl=ot,Tn=D,Pn=st,Sl=Sn;Tn.prototype.oklab=function(){return Sl(this._rgb)},Cl.oklab=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Tn,[null].concat(s,["oklab"])))},Pn.format.oklab=kn,Pn.autodetect.push({p:3,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=wl(s,"oklab"),xl(s)==="array"&&s.length===3)return"oklab"}});var kl=T.unpack,Tl=Sn,Pl=hn,Rl=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];var l=kl(s,"rgb"),u=l[0],d=l[1],p=l[2],f=Tl(u,d,p),v=f[0],b=f[1],w=f[2];return Pl(v,b,w)},Ml=Rl,$l=T.unpack,Ll=un,Al=kn,Ol=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];s=$l(s,"lch");var l=s[0],u=s[1],d=s[2],p=Ll(l,u,d),f=p[0],v=p[1],b=p[2],w=Al(f,v,b),x=w[0],R=w[1],C=w[2];return[x,R,C,s.length>3?s[3]:1]},zl=Ol,Il=T.unpack,Fl=T.type,El=ot,Rn=D,Mn=st,_l=Ml;Rn.prototype.oklch=function(){return _l(this._rgb)},El.oklch=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];return new(Function.prototype.bind.apply(Rn,[null].concat(s,["oklch"])))},Mn.format.oklch=zl,Mn.autodetect.push({p:3,test:function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];if(s=Il(s,"oklch"),Fl(s)==="array"&&s.length===3)return"oklch"}});var $n=D,Dl=T.type;$n.prototype.alpha=function(s,o){return o===void 0&&(o=!1),s!==void 0&&Dl(s)==="number"?o?(this._rgb[3]=s,this):new $n([this._rgb[0],this._rgb[1],this._rgb[2],s],"rgb"):this._rgb[3]};var jl=D;jl.prototype.clipped=function(){return this._rgb._clipped||!1};var ue=D,Bl=ar;ue.prototype.darken=function(s){s===void 0&&(s=1);var o=this,l=o.lab();return l[0]-=Bl.Kn*s,new ue(l,"lab").alpha(o.alpha(),!0)},ue.prototype.brighten=function(s){return s===void 0&&(s=1),this.darken(-s)},ue.prototype.darker=ue.prototype.darken,ue.prototype.brighter=ue.prototype.brighten;var Nl=D;Nl.prototype.get=function(s){var o=s.split("."),l=o[0],u=o[1],d=this[l]();if(u){var p=l.indexOf(u)-(l.substr(0,2)==="ok"?2:0);if(p>-1)return d[p];throw new Error("unknown channel "+u+" in mode "+l)}else return d};var Re=D,Wl=T.type,Ul=Math.pow,ql=1e-7,Gl=20;Re.prototype.luminance=function(s){if(s!==void 0&&Wl(s)==="number"){if(s===0)return new Re([0,0,0,this._rgb[3]],"rgb");if(s===1)return new Re([255,255,255,this._rgb[3]],"rgb");var o=this.luminance(),l="rgb",u=Gl,d=function(f,v){var b=f.interpolate(v,.5,l),w=b.luminance();return Math.abs(s-w)<ql||!u--?b:w>s?d(f,b):d(b,v)},p=(o>s?d(new Re([0,0,0]),this):d(this,new Re([255,255,255]))).rgb();return new Re(p.concat([this._rgb[3]]))}return Xl.apply(void 0,this._rgb.slice(0,3))};var Xl=function(s,o,l){return s=Ur(s),o=Ur(o),l=Ur(l),.2126*s+.7152*o+.0722*l},Ur=function(s){return s/=255,s<=.03928?s/12.92:Ul((s+.055)/1.055,2.4)},St={},Ln=D,An=T.type,cr=St,On=function(s,o,l){l===void 0&&(l=.5);for(var u=[],d=arguments.length-3;d-- >0;)u[d]=arguments[d+3];var p=u[0]||"lrgb";if(!cr[p]&&!u.length&&(p=Object.keys(cr)[0]),!cr[p])throw new Error("interpolation mode "+p+" is not defined");return An(s)!=="object"&&(s=new Ln(s)),An(o)!=="object"&&(o=new Ln(o)),cr[p](s,o,l).alpha(s.alpha()+l*(o.alpha()-s.alpha()))},zn=D,Hl=On;zn.prototype.mix=zn.prototype.interpolate=function(s,o){o===void 0&&(o=.5);for(var l=[],u=arguments.length-2;u-- >0;)l[u]=arguments[u+2];return Hl.apply(void 0,[this,s,o].concat(l))};var In=D;In.prototype.premultiply=function(s){s===void 0&&(s=!1);var o=this._rgb,l=o[3];return s?(this._rgb=[o[0]*l,o[1]*l,o[2]*l,l],this):new In([o[0]*l,o[1]*l,o[2]*l,l],"rgb")};var qr=D,Yl=ar;qr.prototype.saturate=function(s){s===void 0&&(s=1);var o=this,l=o.lch();return l[1]+=Yl.Kn*s,l[1]<0&&(l[1]=0),new qr(l,"lch").alpha(o.alpha(),!0)},qr.prototype.desaturate=function(s){return s===void 0&&(s=1),this.saturate(-s)};var Fn=D,En=T.type;Fn.prototype.set=function(s,o,l){l===void 0&&(l=!1);var u=s.split("."),d=u[0],p=u[1],f=this[d]();if(p){var v=d.indexOf(p)-(d.substr(0,2)==="ok"?2:0);if(v>-1){if(En(o)=="string")switch(o.charAt(0)){case"+":f[v]+=+o;break;case"-":f[v]+=+o;break;case"*":f[v]*=+o.substr(1);break;case"/":f[v]/=+o.substr(1);break;default:f[v]=+o}else if(En(o)==="number")f[v]=o;else throw new Error("unsupported value for Color.set");var b=new Fn(f,d);return l?(this._rgb=b._rgb,this):b}throw new Error("unknown channel "+p+" in mode "+d)}else return f};var Zl=D,Vl=function(s,o,l){var u=s._rgb,d=o._rgb;return new Zl(u[0]+l*(d[0]-u[0]),u[1]+l*(d[1]-u[1]),u[2]+l*(d[2]-u[2]),"rgb")};St.rgb=Vl;var Jl=D,Gr=Math.sqrt,Me=Math.pow,Ql=function(s,o,l){var u=s._rgb,d=u[0],p=u[1],f=u[2],v=o._rgb,b=v[0],w=v[1],x=v[2];return new Jl(Gr(Me(d,2)*(1-l)+Me(b,2)*l),Gr(Me(p,2)*(1-l)+Me(w,2)*l),Gr(Me(f,2)*(1-l)+Me(x,2)*l),"rgb")};St.lrgb=Ql;var Kl=D,th=function(s,o,l){var u=s.lab(),d=o.lab();return new Kl(u[0]+l*(d[0]-u[0]),u[1]+l*(d[1]-u[1]),u[2]+l*(d[2]-u[2]),"lab")};St.lab=th;var _n=D,$e=function(s,o,l,u){var d,p,f,v;u==="hsl"?(f=s.hsl(),v=o.hsl()):u==="hsv"?(f=s.hsv(),v=o.hsv()):u==="hcg"?(f=s.hcg(),v=o.hcg()):u==="hsi"?(f=s.hsi(),v=o.hsi()):u==="lch"||u==="hcl"?(u="hcl",f=s.hcl(),v=o.hcl()):u==="oklch"&&(f=s.oklch().reverse(),v=o.oklch().reverse());var b,w,x,R,C,$;(u.substr(0,1)==="h"||u==="oklch")&&(d=f,b=d[0],x=d[1],C=d[2],p=v,w=p[0],R=p[1],$=p[2]);var M,j,W,q;return!isNaN(b)&&!isNaN(w)?(w>b&&w-b>180?q=w-(b+360):w<b&&b-w>180?q=w+360-b:q=w-b,j=b+l*q):isNaN(b)?isNaN(w)?j=Number.NaN:(j=w,(C==1||C==0)&&u!="hsv"&&(M=R)):(j=b,($==1||$==0)&&u!="hsv"&&(M=x)),M===void 0&&(M=x+l*(R-x)),W=C+l*($-C),u==="oklch"?new _n([W,M,j],u):new _n([j,M,W],u)},eh=$e,Dn=function(s,o,l){return eh(s,o,l,"lch")};St.lch=Dn,St.hcl=Dn;var rh=D,sh=function(s,o,l){var u=s.num(),d=o.num();return new rh(u+l*(d-u),"num")};St.num=sh;var nh=$e,ih=function(s,o,l){return nh(s,o,l,"hcg")};St.hcg=ih;var ah=$e,oh=function(s,o,l){return ah(s,o,l,"hsi")};St.hsi=oh;var lh=$e,hh=function(s,o,l){return lh(s,o,l,"hsl")};St.hsl=hh;var uh=$e,ch=function(s,o,l){return uh(s,o,l,"hsv")};St.hsv=ch;var fh=D,dh=function(s,o,l){var u=s.oklab(),d=o.oklab();return new fh(u[0]+l*(d[0]-u[0]),u[1]+l*(d[1]-u[1]),u[2]+l*(d[2]-u[2]),"oklab")};St.oklab=dh;var ph=$e,gh=function(s,o,l){return ph(s,o,l,"oklch")};St.oklch=gh;var Xr=D,vh=T.clip_rgb,Hr=Math.pow,Yr=Math.sqrt,Zr=Math.PI,jn=Math.cos,Bn=Math.sin,mh=Math.atan2,bh=function(s,o,l){o===void 0&&(o="lrgb"),l===void 0&&(l=null);var u=s.length;l||(l=Array.from(new Array(u)).map(function(){return 1}));var d=u/l.reduce(function(j,W){return j+W});if(l.forEach(function(j,W){l[W]*=d}),s=s.map(function(j){return new Xr(j)}),o==="lrgb")return yh(s,l);for(var p=s.shift(),f=p.get(o),v=[],b=0,w=0,x=0;x<f.length;x++)if(f[x]=(f[x]||0)*l[0],v.push(isNaN(f[x])?0:l[0]),o.charAt(x)==="h"&&!isNaN(f[x])){var R=f[x]/180*Zr;b+=jn(R)*l[0],w+=Bn(R)*l[0]}var C=p.alpha()*l[0];s.forEach(function(j,W){var q=j.get(o);C+=j.alpha()*l[W+1];for(var H=0;H<f.length;H++)if(!isNaN(q[H]))if(v[H]+=l[W+1],o.charAt(H)==="h"){var dt=q[H]/180*Zr;b+=jn(dt)*l[W+1],w+=Bn(dt)*l[W+1]}else f[H]+=q[H]*l[W+1]});for(var $=0;$<f.length;$++)if(o.charAt($)==="h"){for(var M=mh(w/v[$],b/v[$])/Zr*180;M<0;)M+=360;for(;M>=360;)M-=360;f[$]=M}else f[$]=f[$]/v[$];return C/=u,new Xr(f,o).alpha(C>.99999?1:C,!0)},yh=function(s,o){for(var l=s.length,u=[0,0,0,0],d=0;d<s.length;d++){var p=s[d],f=o[d]/l,v=p._rgb;u[0]+=Hr(v[0],2)*f,u[1]+=Hr(v[1],2)*f,u[2]+=Hr(v[2],2)*f,u[3]+=v[3]*f}return u[0]=Yr(u[0]),u[1]=Yr(u[1]),u[2]=Yr(u[2]),u[3]>.9999999&&(u[3]=1),new Xr(vh(u))},Rt=ot,Le=T.type,wh=Math.pow,Vr=function(s){var o="rgb",l=Rt("#ccc"),u=0,d=[0,1],p=[],f=[0,0],v=!1,b=[],w=!1,x=0,R=1,C=!1,$={},M=!0,j=1,W=function(S){if(S=S||["#fff","#000"],S&&Le(S)==="string"&&Rt.brewer&&Rt.brewer[S.toLowerCase()]&&(S=Rt.brewer[S.toLowerCase()]),Le(S)==="array"){S.length===1&&(S=[S[0],S[0]]),S=S.slice(0);for(var z=0;z<S.length;z++)S[z]=Rt(S[z]);p.length=0;for(var N=0;N<S.length;N++)p.push(N/(S.length-1))}return yt(),b=S},q=function(S){if(v!=null){for(var z=v.length-1,N=0;N<z&&S>=v[N];)N++;return N-1}return 0},H=function(S){return S},dt=function(S){return S},ft=function(S,z){var N,B;if(z==null&&(z=!1),isNaN(S)||S===null)return l;if(z)B=S;else if(v&&v.length>2){var pt=q(S);B=pt/(v.length-2)}else R!==x?B=(S-x)/(R-x):B=1;B=dt(B),z||(B=H(B)),j!==1&&(B=wh(B,j)),B=f[0]+B*(1-f[0]-f[1]),B=Math.min(1,Math.max(0,B));var K=Math.floor(B*1e4);if(M&&$[K])N=$[K];else{if(Le(b)==="array")for(var G=0;G<p.length;G++){var Z=p[G];if(B<=Z){N=b[G];break}if(B>=Z&&G===p.length-1){N=b[G];break}if(B>Z&&B<p[G+1]){B=(B-Z)/(p[G+1]-Z),N=Rt.interpolate(b[G],b[G+1],B,o);break}}else Le(b)==="function"&&(N=b(B));M&&($[K]=N)}return N},yt=function(){return $={}};W(s);var U=function(S){var z=Rt(ft(S));return w&&z[w]?z[w]():z};return U.classes=function(S){if(S!=null){if(Le(S)==="array")v=S,d=[S[0],S[S.length-1]];else{var z=Rt.analyze(d);S===0?v=[z.min,z.max]:v=Rt.limits(z,"e",S)}return U}return v},U.domain=function(S){if(!arguments.length)return d;x=S[0],R=S[S.length-1],p=[];var z=b.length;if(S.length===z&&x!==R)for(var N=0,B=Array.from(S);N<B.length;N+=1){var pt=B[N];p.push((pt-x)/(R-x))}else{for(var K=0;K<z;K++)p.push(K/(z-1));if(S.length>2){var G=S.map(function(V,J){return J/(S.length-1)}),Z=S.map(function(V){return(V-x)/(R-x)});Z.every(function(V,J){return G[J]===V})||(dt=function(V){if(V<=0||V>=1)return V;for(var J=0;V>=Z[J+1];)J++;var $t=(V-Z[J])/(Z[J+1]-Z[J]),Jt=G[J]+$t*(G[J+1]-G[J]);return Jt})}}return d=[x,R],U},U.mode=function(S){return arguments.length?(o=S,yt(),U):o},U.range=function(S,z){return W(S),U},U.out=function(S){return w=S,U},U.spread=function(S){return arguments.length?(u=S,U):u},U.correctLightness=function(S){return S==null&&(S=!0),C=S,yt(),C?H=function(z){for(var N=ft(0,!0).lab()[0],B=ft(1,!0).lab()[0],pt=N>B,K=ft(z,!0).lab()[0],G=N+(B-N)*z,Z=K-G,V=0,J=1,$t=20;Math.abs(Z)>.01&&$t-- >0;)(function(){return pt&&(Z*=-1),Z<0?(V=z,z+=(J-z)*.5):(J=z,z+=(V-z)*.5),K=ft(z,!0).lab()[0],Z=K-G})();return z}:H=function(z){return z},U},U.padding=function(S){return S!=null?(Le(S)==="number"&&(S=[S,S]),f=S,U):f},U.colors=function(S,z){arguments.length<2&&(z="hex");var N=[];if(arguments.length===0)N=b.slice(0);else if(S===1)N=[U(.5)];else if(S>1){var B=d[0],pt=d[1]-B;N=xh(0,S,!1).map(function(J){return U(B+J/(S-1)*pt)})}else{s=[];var K=[];if(v&&v.length>2)for(var G=1,Z=v.length,V=1<=Z;V?G<Z:G>Z;V?G++:G--)K.push((v[G-1]+v[G])*.5);else K=d;N=K.map(function(J){return U(J)})}return Rt[z]&&(N=N.map(function(J){return J[z]()})),N},U.cache=function(S){return S!=null?(M=S,U):M},U.gamma=function(S){return S!=null?(j=S,U):j},U.nodata=function(S){return S!=null?(l=Rt(S),U):l},U};function xh(s,o,l){for(var u=[],d=s<o,p=l?d?o+1:o-1:o,f=s;d?f<p:f>p;d?f++:f--)u.push(f);return u}var We=D,Ch=Vr,Sh=function(s){for(var o=[1,1],l=1;l<s;l++){for(var u=[1],d=1;d<=o.length;d++)u[d]=(o[d]||0)+o[d-1];o=u}return o},kh=function(s){var o,l,u,d,p,f,v;if(s=s.map(function(C){return new We(C)}),s.length===2)o=s.map(function(C){return C.lab()}),p=o[0],f=o[1],d=function(C){var $=[0,1,2].map(function(M){return p[M]+C*(f[M]-p[M])});return new We($,"lab")};else if(s.length===3)l=s.map(function(C){return C.lab()}),p=l[0],f=l[1],v=l[2],d=function(C){var $=[0,1,2].map(function(M){return(1-C)*(1-C)*p[M]+2*(1-C)*C*f[M]+C*C*v[M]});return new We($,"lab")};else if(s.length===4){var b;u=s.map(function(C){return C.lab()}),p=u[0],f=u[1],v=u[2],b=u[3],d=function(C){var $=[0,1,2].map(function(M){return(1-C)*(1-C)*(1-C)*p[M]+3*(1-C)*(1-C)*C*f[M]+3*(1-C)*C*C*v[M]+C*C*C*b[M]});return new We($,"lab")}}else if(s.length>=5){var w,x,R;w=s.map(function(C){return C.lab()}),R=s.length-1,x=Sh(R),d=function(C){var $=1-C,M=[0,1,2].map(function(j){return w.reduce(function(W,q,H){return W+x[H]*Math.pow($,R-H)*Math.pow(C,H)*q[j]},0)});return new We(M,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return d},Th=function(s){var o=kh(s);return o.scale=function(){return Ch(o)},o},Jr=ot,Mt=function(s,o,l){if(!Mt[l])throw new Error("unknown blend mode "+l);return Mt[l](s,o)},Zt=function(s){return function(o,l){var u=Jr(l).rgb(),d=Jr(o).rgb();return Jr.rgb(s(u,d))}},Vt=function(s){return function(o,l){var u=[];return u[0]=s(o[0],l[0]),u[1]=s(o[1],l[1]),u[2]=s(o[2],l[2]),u}},Ph=function(s){return s},Rh=function(s,o){return s*o/255},Mh=function(s,o){return s>o?o:s},$h=function(s,o){return s>o?s:o},Lh=function(s,o){return 255*(1-(1-s/255)*(1-o/255))},Ah=function(s,o){return o<128?2*s*o/255:255*(1-2*(1-s/255)*(1-o/255))},Oh=function(s,o){return 255*(1-(1-o/255)/(s/255))},zh=function(s,o){return s===255?255:(s=255*(o/255)/(1-s/255),s>255?255:s)};Mt.normal=Zt(Vt(Ph)),Mt.multiply=Zt(Vt(Rh)),Mt.screen=Zt(Vt(Lh)),Mt.overlay=Zt(Vt(Ah)),Mt.darken=Zt(Vt(Mh)),Mt.lighten=Zt(Vt($h)),Mt.dodge=Zt(Vt(zh)),Mt.burn=Zt(Vt(Oh));for(var Ih=Mt,Qr=T.type,Fh=T.clip_rgb,Eh=T.TWOPI,_h=Math.pow,Dh=Math.sin,jh=Math.cos,Nn=ot,Bh=function(s,o,l,u,d){s===void 0&&(s=300),o===void 0&&(o=-1.5),l===void 0&&(l=1),u===void 0&&(u=1),d===void 0&&(d=[0,1]);var p=0,f;Qr(d)==="array"?f=d[1]-d[0]:(f=0,d=[d,d]);var v=function(b){var w=Eh*((s+120)/360+o*b),x=_h(d[0]+f*b,u),R=p!==0?l[0]+b*p:l,C=R*x*(1-x)/2,$=jh(w),M=Dh(w),j=x+C*(-.14861*$+1.78277*M),W=x+C*(-.29227*$-.90649*M),q=x+C*(1.97294*$);return Nn(Fh([j*255,W*255,q*255,1]))};return v.start=function(b){return b==null?s:(s=b,v)},v.rotations=function(b){return b==null?o:(o=b,v)},v.gamma=function(b){return b==null?u:(u=b,v)},v.hue=function(b){return b==null?l:(l=b,Qr(l)==="array"?(p=l[1]-l[0],p===0&&(l=l[1])):p=0,v)},v.lightness=function(b){return b==null?d:(Qr(b)==="array"?(d=b,f=b[1]-b[0]):(d=[b,b],f=0),v)},v.scale=function(){return Nn.scale(v)},v.hue(l),v},Nh=D,Wh="0123456789abcdef",Uh=Math.floor,qh=Math.random,Gh=function(){for(var s="#",o=0;o<6;o++)s+=Wh.charAt(Uh(qh()*16));return new Nh(s,"hex")},Kr=y,Wn=Math.log,Xh=Math.pow,Hh=Math.floor,Yh=Math.abs,Un=function(s,o){o===void 0&&(o=null);var l={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return Kr(s)==="object"&&(s=Object.values(s)),s.forEach(function(u){o&&Kr(u)==="object"&&(u=u[o]),u!=null&&!isNaN(u)&&(l.values.push(u),l.sum+=u,u<l.min&&(l.min=u),u>l.max&&(l.max=u),l.count+=1)}),l.domain=[l.min,l.max],l.limits=function(u,d){return qn(l,u,d)},l},qn=function(s,o,l){o===void 0&&(o="equal"),l===void 0&&(l=7),Kr(s)=="array"&&(s=Un(s));var u=s.min,d=s.max,p=s.values.sort(function(es,rs){return es-rs});if(l===1)return[u,d];var f=[];if(o.substr(0,1)==="c"&&(f.push(u),f.push(d)),o.substr(0,1)==="e"){f.push(u);for(var v=1;v<l;v++)f.push(u+v/l*(d-u));f.push(d)}else if(o.substr(0,1)==="l"){if(u<=0)throw new Error("Logarithmic scales are only possible for values > 0");var b=Math.LOG10E*Wn(u),w=Math.LOG10E*Wn(d);f.push(u);for(var x=1;x<l;x++)f.push(Xh(10,b+x/l*(w-b)));f.push(d)}else if(o.substr(0,1)==="q"){f.push(u);for(var R=1;R<l;R++){var C=(p.length-1)*R/l,$=Hh(C);if($===C)f.push(p[$]);else{var M=C-$;f.push(p[$]*(1-M)+p[$+1]*M)}}f.push(d)}else if(o.substr(0,1)==="k"){var j,W=p.length,q=new Array(W),H=new Array(l),dt=!0,ft=0,yt=null;yt=[],yt.push(u);for(var U=1;U<l;U++)yt.push(u+U/l*(d-u));for(yt.push(d);dt;){for(var S=0;S<l;S++)H[S]=0;for(var z=0;z<W;z++)for(var N=p[z],B=Number.MAX_VALUE,pt=void 0,K=0;K<l;K++){var G=Yh(yt[K]-N);G<B&&(B=G,pt=K),H[pt]++,q[z]=pt}for(var Z=new Array(l),V=0;V<l;V++)Z[V]=null;for(var J=0;J<W;J++)j=q[J],Z[j]===null?Z[j]=p[J]:Z[j]+=p[J];for(var $t=0;$t<l;$t++)Z[$t]*=1/H[$t];dt=!1;for(var Jt=0;Jt<l;Jt++)if(Z[Jt]!==yt[Jt]){dt=!0;break}yt=Z,ft++,ft>200&&(dt=!1)}for(var Qt={},Ae=0;Ae<l;Ae++)Qt[Ae]=[];for(var Oe=0;Oe<W;Oe++)j=q[Oe],Qt[j].push(p[Oe]);for(var Nt=[],ce=0;ce<l;ce++)Nt.push(Qt[ce][0]),Nt.push(Qt[ce][Qt[ce].length-1]);Nt=Nt.sort(function(es,rs){return es-rs}),f.push(Nt[0]);for(var Ue=1;Ue<Nt.length;Ue+=2){var fe=Nt[Ue];!isNaN(fe)&&f.indexOf(fe)===-1&&f.push(fe)}}return f},Gn={analyze:Un,limits:qn},Xn=D,Zh=function(s,o){s=new Xn(s),o=new Xn(o);var l=s.luminance(),u=o.luminance();return l>u?(l+.05)/(u+.05):(u+.05)/(l+.05)},Hn=D,Bt=Math.sqrt,lt=Math.pow,Vh=Math.min,Jh=Math.max,Yn=Math.atan2,Zn=Math.abs,fr=Math.cos,Vn=Math.sin,Qh=Math.exp,Jn=Math.PI,Kh=function(s,o,l,u,d){l===void 0&&(l=1),u===void 0&&(u=1),d===void 0&&(d=1);var p=function(fe){return 360*fe/(2*Jn)},f=function(fe){return 2*Jn*fe/360};s=new Hn(s),o=new Hn(o);var v=Array.from(s.lab()),b=v[0],w=v[1],x=v[2],R=Array.from(o.lab()),C=R[0],$=R[1],M=R[2],j=(b+C)/2,W=Bt(lt(w,2)+lt(x,2)),q=Bt(lt($,2)+lt(M,2)),H=(W+q)/2,dt=.5*(1-Bt(lt(H,7)/(lt(H,7)+lt(25,7)))),ft=w*(1+dt),yt=$*(1+dt),U=Bt(lt(ft,2)+lt(x,2)),S=Bt(lt(yt,2)+lt(M,2)),z=(U+S)/2,N=p(Yn(x,ft)),B=p(Yn(M,yt)),pt=N>=0?N:N+360,K=B>=0?B:B+360,G=Zn(pt-K)>180?(pt+K+360)/2:(pt+K)/2,Z=1-.17*fr(f(G-30))+.24*fr(f(2*G))+.32*fr(f(3*G+6))-.2*fr(f(4*G-63)),V=K-pt;V=Zn(V)<=180?V:K<=pt?V+360:V-360,V=2*Bt(U*S)*Vn(f(V)/2);var J=C-b,$t=S-U,Jt=1+.015*lt(j-50,2)/Bt(20+lt(j-50,2)),Qt=1+.045*z,Ae=1+.015*z*Z,Oe=30*Qh(-lt((G-275)/25,2)),Nt=2*Bt(lt(z,7)/(lt(z,7)+lt(25,7))),ce=-Nt*Vn(2*f(Oe)),Ue=Bt(lt(J/(l*Jt),2)+lt($t/(u*Qt),2)+lt(V/(d*Ae),2)+ce*($t/(u*Qt))*(V/(d*Ae)));return Jh(0,Vh(100,Ue))},Qn=D,tu=function(s,o,l){l===void 0&&(l="lab"),s=new Qn(s),o=new Qn(o);var u=s.get(l),d=o.get(l),p=0;for(var f in u){var v=(u[f]||0)-(d[f]||0);p+=v*v}return Math.sqrt(p)},eu=D,ru=function(){for(var s=[],o=arguments.length;o--;)s[o]=arguments[o];try{return new(Function.prototype.bind.apply(eu,[null].concat(s))),!0}catch{return!1}},Kn=ot,ti=Vr,su={cool:function(){return ti([Kn.hsl(180,1,.9),Kn.hsl(250,.7,.4)])},hot:function(){return ti(["#000","#f00","#ff0","#fff"]).mode("rgb")}},dr={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},ts=0,ei=Object.keys(dr);ts<ei.length;ts+=1){var ri=ei[ts];dr[ri.toLowerCase()]=dr[ri]}var nu=dr,ct=ot;ct.average=bh,ct.bezier=Th,ct.blend=Ih,ct.cubehelix=Bh,ct.mix=ct.interpolate=On,ct.random=Gh,ct.scale=Vr,ct.analyze=Gn.analyze,ct.contrast=Zh,ct.deltaE=Kh,ct.distance=tu,ct.limits=Gn.limits,ct.valid=ru,ct.scales=su,ct.colors=pn,ct.brewer=nu;var iu=ct;return iu})})(Ri);var et=Ri.exports;const se=(()=>(et.Color.symbol=et.Color.prototype.symbol=Symbol.for("@motion-canvas/core/types/Color"),et.Color.lerp=et.Color.prototype.lerp=(n,t,e,r="lch")=>{typeof n=="string"&&(n=new et.Color(n)),typeof t=="string"&&(t=new et.Color(t));const i=n instanceof et.Color,a=t instanceof et.Color;return i||(n=a?t.alpha(0):new et.Color("rgba(0, 0, 0, 0)")),a||(t=i?n.alpha(0):new et.Color("rgba(0, 0, 0, 0)")),et.mix(n,t,e,r)},et.Color.createLerp=et.Color.prototype.createLerp=n=>(t,e,r)=>et.Color.lerp(t,e,r,n),et.Color.createSignal=(n,t=et.Color.lerp)=>new be(n,t,void 0,e=>new et.Color(e)).toSignal(),et.Color.prototype.toSymbol=()=>et.Color.symbol,et.Color.prototype.toUniform=function(n,t){n.uniform4fv(t,this.gl())},et.Color.prototype.serialize=function(){return this.css()},et.Color.prototype.lerp=function(n,t,e){return et.Color.lerp(this,n,t,e)},et.Color))();function Ju(n,t){return g.fromDegrees(n).transform(t).degrees}function is(n,t){return g.magnitude(t.m11,t.m12)*n}class as extends kt{constructor(){super(...arguments),this.type=se.symbol}parse(t){return t===null?null:new se(t)}serialize(){var t;return((t=this.value.current)==null?void 0:t.serialize())??null}}class ve extends kt{constructor(t,e,r=(i=>(i=e[0])==null?void 0:i.value)()){super(t,r),this.options=e,this.type=ve.symbol}set(t){var e;super.set((e=this.getOption(t))==null?void 0:e.value)}parse(t){var e;return(e=this.getOption(t))==null?void 0:e.value}getOption(t){return this.options.find(e=>e.value===t)??this.options[0]}}ve.symbol=Symbol.for("@motion-canvas/core/meta/EnumMetaField");class Qu extends kt{get onFieldsChanged(){return this.fields.subscribable}get options(){return this.optionFields[this.current]}constructor(t,e,r=0){var c,m;const i=e.plugins.flatMap(y=>{var k;return((k=y.exporters)==null?void 0:k.call(y,e))??[]}),a=i.map(y=>y.meta(e)),h=new ve("exporter",i.map(y=>({value:y.id,text:y.displayName})),(c=i[r])==null?void 0:c.id);super(t,{name:h.get(),options:(m=a[r])==null?void 0:m.get()}),this.current=r,this.type=Object,this.handleChange=()=>{var F,X,Q;const y=this.exporterField.get(),k=Math.max(this.exporters.findIndex(at=>at.id===y),0);this.current!==k&&((F=this.options)==null||F.onChanged.unsubscribe(this.handleChange),this.current=k,(X=this.options)==null||X.onChanged.subscribe(this.handleChange,!1),this.fields.current=this.options?[this.exporterField,this.options]:[this.exporterField]),this.value.current={name:this.exporterField.get(),options:((Q=this.options)==null?void 0:Q.get())??null}},this.exporters=i,this.exporterField=h,this.exporterField.onChanged.subscribe(this.handleChange,!1),this.exporterField.disable(a.length<2).space(),this.optionFields=a,this.fields=new re([this.exporterField]),this.options&&(this.options.onChanged.subscribe(this.handleChange,!1),this.fields.current=[this.exporterField,this.options])}set(t){var e;this.exporterField.set(t.name),(e=this.options)==null||e.set(t.options??{})}serialize(){var t;return{name:this.exporterField.serialize(),options:((t=this.options)==null?void 0:t.serialize())??null}}clone(){return new this.constructor(this.name,this.exporters,this.current)}}var qe;class Je{constructor(t,e=!1){this.name=t,this.source=e,this.lock=new uu,this.ignoreChange=!1,this.cache=null,this.metaField=null,this.handleChanged=async()=>{}}attach(t){var e;this.metaField||(this.metaField=t,this.cache&&this.metaField.set(this.cache),(e=this.metaField)==null||e.onChanged.subscribe(this.handleChanged))}async saveData(t){if(this.source===!1)return;if(!this.source)throw new Error(`The meta file for ${this.name} is missing.`);if(qe.sourceLookup[this.source])throw new Error(`Metadata for ${this.name} is already being updated`);const e=this.source;await new Promise((r,i)=>{setTimeout(()=>{delete qe.sourceLookup[e],i(`Connection timeout when updating metadata for ${this.name}`)},1e3),qe.sourceLookup[e]=()=>{delete qe.sourceLookup[e],r()},(void 0).send("motion-canvas:meta",{source:e,data:t})})}loadData(t){var e;this.ignoreChange=!0,this.cache=t,(e=this.metaField)==null||e.set(t),this.ignoreChange=!1}}qe=Je;Je.sourceLookup={};class ns extends kt{constructor(){super(...arguments),this.type=Number,this.presets=[]}parse(t){let e=parseFloat(t);return this.min!==void 0&&e<this.min&&(e=this.min),this.max!==void 0&&e>this.max&&(e=this.max),e}getPresets(){return this.presets}setPresets(t){return this.presets=t,this}setRange(t,e){return this.min=t,this.max=e,this}getMin(){return this.min??-1/0}getMax(){return this.max??1/0}}class Sr extends kt{constructor(){super(...arguments),this.type=Sr.symbol}parse(t){return this.parseRange(1/0,t[0],t[1]??1/0)}update(t,e,r,i){this.value.current=this.parseRange(r/i-He,t/i-He,e/i-He)}parseRange(t,e=this.value.current[0],r=this.value.current[1]){return e=wt(0,t,e),r=wt(0,t,r??1/0),e>r&&([e,r]=[r,e]),r>=t&&(r=1/0),[e,r]}}Sr.symbol=Symbol.for("@motion-canvas/core/meta/RangeMetaField");class Mi extends kt{constructor(){super(...arguments),this.type=g.symbol}parse(t){return new g(t)}serialize(){return this.value.current.serialize()}}class je{static meta(t){return new Gt(this.displayName,{fastStart:new br("fast start",!0),includeAudio:new br("include audio",!0).disable(!t.audio)})}static async create(t,e){return new je(t,e)}constructor(t,e){this.project=t,this.settings=e}async start(){const t=this.settings.exporter.options;await this.invoke("start",{...this.settings,...t,audio:this.project.audio,audioOffset:this.project.meta.shared.audioOffset.get()-this.settings.range[0]})}async handleFrame(t){await this.invoke("handleFrame",{data:t.toDataURL("image/png")})}async stop(t){await this.invoke("end",t)}invoke(t,e){throw new Error("FFmpegExporter can only be used locally.")}}je.id="@motion-canvas/ffmpeg";je.displayName="Video (FFmpeg)";je.response=new Ot;const Ku=au({name:"ffmpeg-plugin",exporters(){return[je]}});let ms;ms??(ms=new Je("project",!1));ms.loadData({version:0,shared:{background:"rgba(255,0,0,0)",range:[0,null],size:{x:1920,y:1080},audioOffset:0},preview:{fps:30,resolutionScale:1},rendering:{fps:60,resolutionScale:1,colorSpace:"srgb",exporter:{name:"@motion-canvas/core/image-sequence",options:{fileType:"image/png",quality:100,groupByScene:!1}}}});const tc=ms;let bs;bs??(bs=new Je("example",!1));bs.loadData({version:0,timeEvents:[],seed:3712781475});const ec=bs;function rc(n){var t;return!!((t=n.prototype)!=null&&t.isClass)}const sc=Symbol.for("@motion-canvas/2d/fragment");function nc(n,t,e){const{ref:r,children:i,...a}=t,h=Array.isArray(i)?i.flat():i;if(n===sc)return h;if(rc(n)){const c=new n({...a,children:h,key:e});return r==null||r(c),c}else return n({...a,ref:r,children:h,key:e})}const fi={invert:{name:"invert"},sepia:{name:"sepia"},grayscale:{name:"grayscale"},brightness:{name:"brightness",default:1},contrast:{name:"contrast",default:1},saturate:{name:"saturate",default:1},hue:{name:"hue-rotate",unit:"deg",scale:1},blur:{name:"blur",transform:!0,unit:"px",scale:1}};class ic{get name(){return this.props.name}get default(){return this.props.default}constructor(t){this.props={name:"invert",default:0,unit:"%",scale:100,transform:!1,...t,value:t.value??t.default??0},this.value=De(this.props.value,tt,this)}isActive(){return this.value()!==this.props.default}serialize(t){let e=this.value();return this.props.transform&&(e=is(e,t)),`${this.props.name}(${e*this.props.scale}${this.props.unit})`}}const Wt=Symbol.for("@motion-canvas/2d/decorators/initializers");function Qe(n,t){if(!n[Wt])n[Wt]=[];else if(n[Wt]&&!Object.prototype.hasOwnProperty.call(n,Wt)){const e=Object.getPrototypeOf(n);n[Wt]=[...e[Wt]]}n[Wt].push(t)}function ac(n,t){if(n[Wt])try{n[Wt].forEach(e=>e(n,t))}catch(e){throw e.inspect??(e.inspect=n.key),e}}function E(){return(n,t)=>{Qe(n,e=>{const r=Object.getPrototypeOf(e)[t];e[t]=Yu(r.bind(e),e)})}}function os(n={},t,e){const r={};if(e&&t){const i=n.setter??(t==null?void 0:t[`set${Ge(e)}`]);i&&(r.setter=i.bind(t));const a=n.getter??(t==null?void 0:t[`get${Ge(e)}`]);a&&(r.getter=a.bind(t));const h=n.tweener??(t==null?void 0:t[`tween${Ge(e)}`]);h&&(r.tweener=h.bind(t))}return r}const Ut=Symbol.for("@motion-canvas/2d/decorators/properties");function we(n,t){var e;return((e=n[Ut])==null?void 0:e[t])??null}function ys(n,t){let e;return n[Ut]?n[Ut]&&!Object.prototype.hasOwnProperty.call(n,Ut)?n[Ut]=e=Object.fromEntries(Object.entries(n[Ut]).map(([r,i])=>[r,{...i}])):e=n[Ut]:n[Ut]=e={},e[t]??(e[t]={cloneable:!0,inspectable:!0,compoundEntries:[]}),e[t]}function $i(n){return n&&typeof n=="object"?n[Ut]??{}:{}}function ws(n,t){ac(n);for(const[e,r]of Object.entries($i(n))){const i=n[e];if(i.reset(),t[e]!==void 0&&i(t[e]),r.compoundEntries!==void 0)for(const[a,h]of r.compoundEntries)h in t&&i[a](t[h])}}function P(){return(n,t)=>{const e=ys(n,t);Qe(n,r=>{var c;let i=e.default;const a=r[`getDefault${Ge(t)}`];a&&(i=()=>a.call(r,e.default));const h=new be(i,e.interpolationFunction??_e,r,(c=e.parser)==null?void 0:c.bind(r),os(e,r,t));r[t]=h.toSignal()})}}function A(n){return(t,e)=>{const r=we(t,e);if(!r){vt().error(`Missing property decorator for "${e.toString()}"`);return}r.default=n}}function Li(n){return(t,e)=>{const r=we(t,e);if(!r){vt().error(`Missing property decorator for "${e.toString()}"`);return}r.interpolationFunction=n}}function xs(n){return(t,e)=>{const r=we(t,e);if(!r){vt().error(`Missing property decorator for "${e.toString()}"`);return}r.parser=n}}function Ke(n){return(t,e)=>{const r=we(t,e);if(!r){vt().error(`Missing property decorator for "${e.toString()}"`);return}r.parser=i=>new n(i),"lerp"in n&&(r.interpolationFunction??(r.interpolationFunction=n.lerp))}}function xe(n=!0){return(t,e)=>{const r=we(t,e);if(!r){vt().error(`Missing property decorator for "${e.toString()}"`);return}r.cloneable=n}}function Ai(n=!0){return(t,e)=>{const r=we(t,e);if(!r){vt().error(`Missing property decorator for "${e.toString()}"`);return}r.inspectable=n}}function Oi(n,t=Cr){return(e,r)=>{const i=ys(e,r);i.compound=!0,i.compoundEntries=Object.entries(n),Qe(e,a=>{if(!i.parser){vt().error(`Missing parser decorator for "${r.toString()}"`);return}const h=i.default,c=i.parser.bind(a),m=new t(i.compoundEntries.map(([y,k])=>{const F=new be(ge(h,X=>c(X)[y]),tt,a,void 0,os(void 0,a,k)).toSignal();return[y,F]}),c,h,i.interpolationFunction??_e,a,os(i,a,r));a[r]=m.toSignal()})}}function Ht(n){return(t,e)=>{Oi(typeof n=="object"?n:{x:n?`${n}X`:"x",y:n?`${n}Y`:"y"},Pi)(t,e),Ke(g)(t,e)}}var oe=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};class jt{constructor(t){ws(this,t)}canvasGradient(t){let e;switch(this.type()){case"linear":e=t.createLinearGradient(this.from.x(),this.from.y(),this.to.x(),this.to.y());break;case"conic":e=t.createConicGradient(this.angle(),this.from.x(),this.from.y());break;case"radial":e=t.createRadialGradient(this.from.x(),this.from.y(),this.fromRadius(),this.to.x(),this.to.y(),this.toRadius());break}for(const{offset:r,color:i}of this.stops())e.addColorStop(me(r),new se(me(i)).serialize());return e}}oe([A("linear"),P()],jt.prototype,"type",void 0);oe([Ht("from")],jt.prototype,"from",void 0);oe([Ht("to")],jt.prototype,"to",void 0);oe([A(0),P()],jt.prototype,"angle",void 0);oe([A(0),P()],jt.prototype,"fromRadius",void 0);oe([A(0),P()],jt.prototype,"toRadius",void 0);oe([A([]),P()],jt.prototype,"stops",void 0);oe([E()],jt.prototype,"canvasGradient",null);var Cs=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};class tr{constructor(t){ws(this,t)}canvasPattern(t){return t.createPattern(this.image(),this.repetition())}}Cs([P()],tr.prototype,"image",void 0);Cs([A(null),P()],tr.prototype,"repetition",void 0);Cs([E()],tr.prototype,"canvasPattern",null);function oc(n){return n===null?null:n instanceof jt||n instanceof tr?n:new se(n)}function ls(n,t){return n===null?"":n instanceof se?n.serialize():n instanceof jt?n.canvasGradient(t):n instanceof tr?n.canvasPattern(t)??"":""}function di(n,t,e,r,i){if(e.top===0&&e.right===0&&e.bottom===0&&e.left===0){lc(n,t);return}const a=ee(e.top,e.right,e.left,t),h=ee(e.right,e.top,e.bottom,t),c=ee(e.bottom,e.left,e.right,t),m=ee(e.left,e.bottom,e.top,t);if(r){const y=k=>{const F=k*i;return k-F};n.moveTo(t.left+a,t.top),n.lineTo(t.right-h,t.top),n.bezierCurveTo(t.right-y(h),t.top,t.right,t.top+y(h),t.right,t.top+h),n.lineTo(t.right,t.bottom-c),n.bezierCurveTo(t.right,t.bottom-y(c),t.right-y(c),t.bottom,t.right-c,t.bottom),n.lineTo(t.left+m,t.bottom),n.bezierCurveTo(t.left+y(m),t.bottom,t.left,t.bottom-y(m),t.left,t.bottom-m),n.lineTo(t.left,t.top+a),n.bezierCurveTo(t.left,t.top+y(a),t.left+y(a),t.top,t.left+a,t.top);return}n.moveTo(t.left+a,t.top),n.arcTo(t.right,t.top,t.right,t.bottom,h),n.arcTo(t.right,t.bottom,t.left,t.bottom,c),n.arcTo(t.left,t.bottom,t.left,t.top,m),n.arcTo(t.left,t.top,t.right,t.top,a)}function ee(n,t,e,r){const i=n+t>r.width?r.width*(n/(n+t)):n,a=n+e>r.height?r.height*(n/(n+e)):n;return Math.min(i,a)}function lc(n,t){n.rect(t.x,t.y,t.width,t.height)}function kr(n,t){n.moveTo(t.x,t.y)}function qt(n,t){n.lineTo(t.x,t.y)}function de(n,t){if(!(t.length<2)){kr(n,t[0]);for(const e of t.slice(1))qt(n,e)}}function hc(n,t,e=8){qt(n,t.addY(-e)),qt(n,t.addY(e)),qt(n,t),qt(n,t.addX(-e)),uc(n,t,e)}function uc(n,t,e,r=0,i=Math.PI*2,a=!1){n.arc(t.x,t.y,e,r,i,a)}function cc(n,t,e,r){n.bezierCurveTo(t.x,t.y,e.x,e.y,r.x,r.y)}function zi(n){return t=>t instanceof n}function Ii(){return(n,t)=>{P()(n,t),xs(oc)(n,t),Li(se.lerp)(n,t),A(null)(n,t)}}function fc(){return(n,t)=>{P()(n,t),Ke(se)(n,t)}}function le(n,t=e=>e){return(e,r)=>{e[`getDefault${Ge(r)}`]=function(){this.requestLayoutUpdate();const i=this.element.style[n];this.element.style[n]="";const a=t.call(this,this.styles.getPropertyValue(n));return this.element.style[n]=i,a}}}class dc extends be{constructor(t,e){super(t,_e,e);for(const r in fi){const i=fi[r];Object.defineProperty(this.invokable,r,{value:(a,h,c=Et)=>{var y,k,F;if(a===void 0)return((k=(y=this.get())==null?void 0:y.find(X=>X.name===i.name))==null?void 0:k.value())??i.default??0;let m=(F=this.get())==null?void 0:F.find(X=>X.name===i.name);return m||(m=new ic(i),this.set([...this.get(),m])),h===void 0?(m.value(a),this.owner):m.value(a,h,c)}})}}*tweener(t,e,r){const i=this.get(),a=me(t);if(gc(i,a)){yield*Fe(...i.map((m,y)=>m.value(a[y].value(),e,r))),this.set(a);return}for(const m of a)m.value(m.default);const h=a.map(m=>m.value.context.raw()),c=i.length>0&&a.length>0?e/2:e;i.length>0&&(yield*Fe(...i.map(m=>m.value(m.default,c,r)))),this.set(a),a.length>0&&(yield*Fe(...a.map((m,y)=>m.value(h[y],c,r))))}}function pc(){return(n,t)=>{const e=ys(n,t);Qe(n,r=>{r[t]=new dc(e.default??[],r).toSignal()})}}function gc(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e].name!==t[e].name)return!1;return!0}const vc=Symbol.for("@motion-canvas/2d/nodeName");function Ce(n){return function(t){t.prototype[vc]=n}}function pi(n,t){const e=wt(0,n.arcLength,t);let r=0;for(const i of n.segments){const a=r;if(r+=i.arcLength,r>=e){const h=(e-a)/i.arcLength;return i.getPoint(wt(0,1,h))}}return{position:g.zero,tangent:g.up,normal:g.up}}function Tr(n){return(t,e)=>{Oi({top:n?`${n}Top`:"top",right:n?`${n}Right`:"right",bottom:n?`${n}Bottom`:"bottom",left:n?`${n}Left`:"left"})(t,e),Ke(At)(t,e)}}function mc(n){let t;return n?typeof n=="string"?t=[{fragment:n}]:Array.isArray(n)?t=n.map(e=>typeof e=="string"?{fragment:e}:e):t=[n]:t=[],!fs().experimentalFeatures&&t.length>0&&(t=[],vt().log({...wu("Node uses experimental shaders."),inspect:this.key})),t}function gr(){return fs()}var _=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},vr;let I=vr=class{get x(){return this.position.x}get y(){return this.position.y}getAbsolutePosition(){return new g(this.parentToWorld().transformPoint(this.position()))}setAbsolutePosition(t){this.position(ge(t,e=>new g(e).transformAsPoint(this.worldToParent())))}getAbsoluteRotation(){const t=this.localToWorld();return g.degrees(t.m11,t.m12)}setAbsoluteRotation(t){this.rotation(ge(t,e=>Ju(e,this.worldToParent())))}getAbsoluteScale(){const t=this.localToWorld();return new g(g.magnitude(t.m11,t.m12),g.magnitude(t.m21,t.m22))}setAbsoluteScale(t){this.scale(ge(t,e=>this.getRelativeScale(new g(e))))}getRelativeScale(t){var r;const e=((r=this.parent())==null?void 0:r.absoluteScale())??g.one;return t.div(e)}*tweenCompositeOperation(t,e,r){const i=me(t);i==="source-over"?(yield*this.compositeOverride(1,e,r),this.compositeOverride(0),this.compositeOperation(i)):(this.compositeOperation(i),this.compositeOverride(1),yield*this.compositeOverride(0,e,r))}absoluteOpacity(){var t;return(((t=this.parent())==null?void 0:t.absoluteOpacity())??1)*this.opacity()}hasFilters(){return!!this.filters().find(t=>t.isActive())}hasShadow(){return!!this.shadowColor()&&(this.shadowBlur()>0||this.shadowOffset.x()!==0||this.shadowOffset.y()!==0)}filterString(){let t="";const e=this.compositeToWorld();for(const r of this.filters())r.isActive()&&(t+=" "+r.serialize(e));return t}getSpawner(){return this.children()}setSpawner(t){this.children(t)}setChildren(t){if(this.children.context.raw()!==t){if(this.children.context.setter(t),!Xt(t))this.spawnChildren(!1,t);else if(!this.hasSpawnedChildren)for(const e of this.realChildren)e.parent(null)}}getChildren(){return this.children.context.getter(),this.spawnedChildren()}spawnedChildren(){const t=this.children.context.getter();return Xt(this.children.context.raw())&&this.spawnChildren(!0,t),this.realChildren}sortedChildren(){return[...this.children()].sort((t,e)=>Math.sign(t.zIndex()-e.zIndex()))}constructor({children:t,spawner:e,key:r,...i}){this.compositeOverride=De(0),this.stateStack=[],this.realChildren=[],this.hasSpawnedChildren=!1,this.parent=De(null),this.properties=$i(this);const a=gr();[this.key,this.unregister]=a.registerNode(this,r),this.view2D=a.getView(),this.creationStack=new Error().stack,ws(this,i),e&&vt().warn({message:"Node.spawner() has been deprecated.",remarks:"Use <code>Node.children()</code> instead.",inspect:this.key,stack:new Error().stack}),this.children(e??t)}localToWorld(){const t=this.parent();return t?t.localToWorld().multiply(this.localToParent()):this.localToParent()}worldToLocal(){return this.localToWorld().inverse()}worldToParent(){var t;return((t=this.parent())==null?void 0:t.worldToLocal())??new DOMMatrix}parentToWorld(){var t;return((t=this.parent())==null?void 0:t.localToWorld())??new DOMMatrix}localToParent(){const t=new DOMMatrix;return t.translateSelf(this.x(),this.y()),t.rotateSelf(0,0,this.rotation()),t.scaleSelf(this.scale.x(),this.scale.y()),t.skewXSelf(this.skew.x()),t.skewYSelf(this.skew.y()),t}compositeToWorld(){var t;return((t=this.compositeRoot())==null?void 0:t.localToWorld())??new DOMMatrix}compositeRoot(){var t;return this.composite()?this:((t=this.parent())==null?void 0:t.compositeRoot())??null}compositeToLocal(){const t=this.compositeRoot();if(t){const e=this.worldToLocal();return e.m44=1,t.localToWorld().multiply(e)}return new DOMMatrix}view(){return this.view2D}add(t){return this.insert(t,1/0)}insert(t,e=0){const r=Array.isArray(t)?t:[t];if(r.length===0)return this;const i=this.children(),a=i.slice(0,e);for(const h of r)h instanceof vr&&(a.push(h),h.remove(),h.parent(this));return a.push(...i.slice(e)),this.setParsedChildren(a),this}remove(){const t=this.parent();return t===null?this:(t.removeChild(this),this.parent(null),this)}move(t=1){const e=this.parent();if(t===0||!e)return this;const r=e.children(),i=[];if(t>0)for(let a=0;a<r.length;a++){const h=r[a];if(h===this){const c=a+t;for(;a<c&&a+1<r.length;a++)i[a]=r[a+1]}i[a]=h}else for(let a=r.length-1;a>=0;a--){const h=r[a];if(h===this){const c=a+t;for(;a>c&&a>0;a--)i[a]=r[a-1]}i[a]=h}return e.setParsedChildren(i),this}moveUp(){return this.move(1)}moveDown(){return this.move(-1)}moveToTop(){return this.move(1/0)}moveToBottom(){return this.move(-1/0)}moveTo(t){const e=this.parent();if(!e)return this;const r=e.children().indexOf(this),i=t-r;return this.move(i)}moveBelow(t,e=!1){const r=this.parent();if(!r)return this;if(t.parent()!==r)return vt().error("Cannot position nodes relative to each other if they don't belong to the same parent."),this;const i=r.children(),a=i.indexOf(this),h=i.indexOf(t);if(!e&&a<h)return this;const c=h-a-1;return this.move(c)}moveAbove(t,e=!1){const r=this.parent();if(!r)return this;if(t.parent()!==r)return vt().error("Cannot position nodes relative to each other if they don't belong to the same parent."),this;const i=r.children(),a=i.indexOf(this),h=i.indexOf(t);if(!e&&a>h)return this;const c=h-a+1;return this.move(c)}reparent(t){const e=this.absolutePosition(),r=this.absoluteRotation(),i=this.absoluteScale();return t.add(this),this.absolutePosition(e),this.absoluteRotation(r),this.absoluteScale(i),this}removeChildren(){for(const t of this.realChildren)t.parent(null);return this.setParsedChildren([]),this}peekChildren(){return this.realChildren}findAll(t){const e=[],r=this.reversedChildren();for(;r.length>0;){const i=r.pop();t(i)&&e.push(i);const a=i.children();for(let h=a.length-1;h>=0;h--)r.push(a[h])}return e}findFirst(t){const e=this.reversedChildren();for(;e.length>0;){const r=e.pop();if(t(r))return r;const i=r.children();for(let a=i.length-1;a>=0;a--)e.push(i[a])}return null}findLast(t){const e=[],r=this.reversedChildren();for(;r.length>0;){const i=r.pop();e.push(i);const a=i.children();for(let h=a.length-1;h>=0;h--)r.push(a[h])}for(;e.length>0;){const i=e.pop();if(t(i))return i}return null}findAncestor(t){let e=this.parent();for(;e;){if(t(e))return e;e=e.parent()}return null}childAs(t){return this.children()[t]??null}childrenAs(){return this.children()}parentAs(){return this.parent()??null}dispose(){if(this.unregister){this.stateStack=[],this.unregister(),this.unregister=null;for(const{signal:t}of this)t==null||t.context.dispose();for(const t of this.realChildren)t.dispose()}}clone(t={}){const e={...t};Xt(this.children.context.raw())?e.children??(e.children=this.children.context.raw()):this.children().length>0&&(e.children??(e.children=this.children().map(r=>r.clone())));for(const{key:r,meta:i,signal:a}of this)if(!(!i.cloneable||r in e))if(i.compound)for(const[h,c]of i.compoundEntries){if(c in e)continue;const m=a[h];m.context.isInitial()||(e[c]=m.context.raw())}else a.context.isInitial()||(e[r]=a.context.raw());return this.instantiate(e)}snapshotClone(t={}){const e={...this.getState(),...t};return this.children().length>0&&(e.children??(e.children=this.children().map(r=>r.snapshotClone()))),this.instantiate(e)}reactiveClone(t={}){const e={...t};this.children().length>0&&(e.children??(e.children=this.children().map(r=>r.reactiveClone())));for(const{key:r,meta:i,signal:a}of this)!i.cloneable||r in e||(e[r]=()=>a());return this.instantiate(e)}instantiate(t={}){return new this.constructor(t)}setParsedChildren(t){this.children.context.setter(t),this.realChildren=t}spawnChildren(t,e){const r=this.parseChildren(e),i=new Set;for(const a of r){const h=a.parent.context.raw();h&&h!==this&&h.removeChild(a),i.add(a.key),a.parent(this)}for(const a of this.realChildren)i.has(a.key)||a.parent(null);this.hasSpawnedChildren=t,this.realChildren=r}parseChildren(t){const e=[],r=Array.isArray(t)?t:[t];for(const i of r)i instanceof vr&&e.push(i);return e}removeChild(t){this.setParsedChildren(this.children().filter(e=>e!==t))}requiresCache(){return this.cache()||this.opacity()<1||this.compositeOperation()!=="source-over"||this.hasFilters()||this.hasShadow()||this.shaders().length>0}cacheCanvas(){const t=document.createElement("canvas").getContext("2d");if(!t)throw new Error("Could not create a cache canvas");return t}cachedCanvas(){const t=this.cacheCanvas(),e=this.worldSpaceCacheBBox(),r=this.localToWorld();return t.canvas.width=e.width,t.canvas.height=e.height,t.setTransform(r.a,r.b,r.c,r.d,r.e-e.x,r.f-e.y),this.draw(t),t}getCacheBBox(){return new Y}cacheBBox(){const t=this.getCacheBBox(),e=this.children(),r=this.cachePadding();if(e.length===0)return t.addSpacing(r);const i=t.corners;for(const h of e){const c=h.fullCacheBBox(),m=h.localToParent();i.push(...c.corners.map(y=>y.transformAsPoint(m)))}return Y.fromPoints(...i).addSpacing(r)}fullCacheBBox(){const t=this.compositeToLocal(),e=this.shadowOffset().transform(t),r=is(this.shadowBlur(),t),i=this.cacheBBox().expand(this.filters.blur()*2+r);return e.x<0?(i.x+=e.x,i.width-=e.x):i.width+=e.x,e.y<0?(i.y+=e.y,i.height-=e.y):i.height+=e.y,i}worldSpaceCacheBBox(){const t=Y.fromSizeCentered(this.view().size()).expand(this.view().cachePadding()),e=Y.fromPoints(...t.transformCorners(this.view().localToWorld())),r=Y.fromPoints(...this.cacheBBox().transformCorners(this.localToWorld()));return e.intersection(r).pixelPerfect.expand(2)}parentWorldSpaceCacheBBox(){var t;return((t=this.findAncestor(e=>e.requiresCache()))==null?void 0:t.worldSpaceCacheBBox())??new Y(g.zero,gr().getRealSize())}setupDrawFromCache(t){if(t.globalCompositeOperation=this.compositeOperation(),t.globalAlpha*=this.opacity(),this.hasFilters()&&(t.filter=this.filterString()),this.hasShadow()){const r=this.compositeToWorld(),i=this.shadowOffset().transform(r),a=is(this.shadowBlur(),r);t.shadowColor=this.shadowColor().serialize(),t.shadowBlur=a,t.shadowOffsetX=i.x,t.shadowOffsetY=i.y}const e=this.worldToLocal();t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}renderFromSource(t,e,r,i){this.setupDrawFromCache(t);const a=this.compositeOverride();t.drawImage(e,r,i),a>0&&(t.save(),t.globalAlpha*=a,t.globalCompositeOperation="source-over",t.drawImage(e,r,i),t.restore())}shaderCanvas(t,e){var F,X;const r=this.shaders();if(r.length===0)return null;const i=gr(),a=i.getRealSize(),h=this.parentWorldSpaceCacheBBox(),c=new DOMMatrix().scaleSelf(a.width/h.width,a.height/-h.height).translateSelf(h.x/-a.width,h.y/a.height-1),m=this.worldSpaceCacheBBox(),y=new DOMMatrix().scaleSelf(a.width/m.width,a.height/-m.height).translateSelf(m.x/-a.width,m.y/a.height-1).invertSelf(),k=i.shaders.getGL();i.shaders.copyTextures(t,e),i.shaders.clear();for(const Q of r){const at=i.shaders.getProgram(Q.fragment);if(at){if(Q.uniforms)for(const[T,st]of Object.entries(Q.uniforms)){const Pt=k.getUniformLocation(at,T);if(Pt===null)continue;const nt=me(st);typeof nt=="number"?k.uniform1f(Pt,nt):"toUniform"in nt?nt.toUniform(k,Pt):nt.length===1?k.uniform1f(Pt,nt[0]):nt.length===2?k.uniform2f(Pt,nt[0],nt[1]):nt.length===3?k.uniform3f(Pt,nt[0],nt[1],nt[2]):nt.length===4&&k.uniform4f(Pt,nt[0],nt[1],nt[2],nt[3])}k.uniform1f(k.getUniformLocation(at,ui),this.view2D.globalTime()),k.uniform1i(k.getUniformLocation(at,ui),i.playback.frame),k.uniformMatrix4fv(k.getUniformLocation(at,Iu),!1,y.toFloat32Array()),k.uniformMatrix4fv(k.getUniformLocation(at,Fu),!1,c.toFloat32Array()),(F=Q.setup)==null||F.call(Q,k,at),i.shaders.render(),(X=Q.teardown)==null||X.call(Q,k,at)}}return k.canvas}render(t){if(!(this.absoluteOpacity()<=0)){if(t.save(),this.transformContext(t),this.requiresCache()){const e=this.worldSpaceCacheBBox();if(e.width!==0&&e.height!==0){const r=this.cachedCanvas().canvas,i=this.shaderCanvas(t.canvas,r);i?this.renderFromSource(t,i,0,0):this.renderFromSource(t,r,e.position.x,e.position.y)}}else this.draw(t);t.restore()}}draw(t){this.drawChildren(t)}drawChildren(t){for(const e of this.sortedChildren())e.render(t)}drawOverlay(t,e){const r=this.cacheBBox().transformCorners(e),i=this.getCacheBBox().transformCorners(e);t.strokeStyle="white",t.lineWidth=1,t.beginPath(),de(t,r),t.closePath(),t.stroke(),t.strokeStyle="blue",t.beginPath(),de(t,i),t.closePath(),t.stroke()}transformContext(t){const e=this.localToParent();t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}hit(t){let e=null;const r=t.transformAsPoint(this.localToParent().inverse()),i=this.children();for(let a=i.length-1;a>=0&&(e=i[a].hit(r),!e);a--);return e}collectAsyncResources(){for(const t of this.children())t.collectAsyncResources()}async toPromise(){do await ht.consumePromises(),this.collectAsyncResources();while(ht.hasPromises());return this}getState(){const t={};for(const{key:e,meta:r,signal:i}of this)!r.cloneable||e in t||(t[e]=i());return t}applyState(t,e,r=Et){if(e===void 0)for(const a in t){const h=this.signalByKey(a);h&&h(t[a])}const i=[];for(const a in t){const h=this.signalByKey(a);t[a]!==h.context.raw()&&i.push(h(t[a],e,r))}return Fe(...i)}save(){this.stateStack.push(this.getState())}restore(t,e=Et){const r=this.stateStack.pop();if(r!==void 0)return this.applyState(r,t,e)}*[Symbol.iterator](){for(const t in this.properties){const e=this.properties[t],r=this.signalByKey(t);yield{meta:e,signal:r,key:t}}}signalByKey(t){return this[t]}reversedChildren(){const t=this.children(),e=[];for(let r=t.length-1;r>=0;r--)e.push(t[r]);return e}};_([Ht()],I.prototype,"position",void 0);_([Ke(g),xe(!1),P()],I.prototype,"absolutePosition",void 0);_([A(0),P()],I.prototype,"rotation",void 0);_([xe(!1),P()],I.prototype,"absoluteRotation",void 0);_([A(g.one),Ht("scale")],I.prototype,"scale",void 0);_([A(g.zero),Ht("skew")],I.prototype,"skew",void 0);_([Ke(g),xe(!1),P()],I.prototype,"absoluteScale",void 0);_([A(0),P()],I.prototype,"zIndex",void 0);_([A(!1),P()],I.prototype,"cache",void 0);_([Tr("cachePadding")],I.prototype,"cachePadding",void 0);_([A(!1),P()],I.prototype,"composite",void 0);_([A("source-over"),P()],I.prototype,"compositeOperation",void 0);_([ut()],I.prototype,"tweenCompositeOperation",null);_([A(1),xs(n=>wt(0,1,n)),P()],I.prototype,"opacity",void 0);_([E()],I.prototype,"absoluteOpacity",null);_([pc()],I.prototype,"filters",void 0);_([A("#0000"),fc()],I.prototype,"shadowColor",void 0);_([A(0),P()],I.prototype,"shadowBlur",void 0);_([Ht("shadowOffset")],I.prototype,"shadowOffset",void 0);_([A([]),xs(mc),P()],I.prototype,"shaders",void 0);_([E()],I.prototype,"hasFilters",null);_([E()],I.prototype,"hasShadow",null);_([E()],I.prototype,"filterString",null);_([Ai(!1),xe(!1),P()],I.prototype,"spawner",void 0);_([Ai(!1),xe(!1),P()],I.prototype,"children",void 0);_([E()],I.prototype,"spawnedChildren",null);_([E()],I.prototype,"sortedChildren",null);_([E()],I.prototype,"localToWorld",null);_([E()],I.prototype,"worldToLocal",null);_([E()],I.prototype,"worldToParent",null);_([E()],I.prototype,"parentToWorld",null);_([E()],I.prototype,"localToParent",null);_([E()],I.prototype,"compositeToWorld",null);_([E()],I.prototype,"compositeRoot",null);_([E()],I.prototype,"compositeToLocal",null);_([E()],I.prototype,"cacheCanvas",null);_([E()],I.prototype,"cachedCanvas",null);_([E()],I.prototype,"cacheBBox",null);_([E()],I.prototype,"fullCacheBBox",null);_([E()],I.prototype,"worldSpaceCacheBBox",null);_([E()],I.prototype,"parentWorldSpaceCacheBBox",null);I=vr=_([Ce("Node")],I);I.prototype.isClass=!0;var O=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},mr;let L=mr=class extends I{get columnGap(){return this.gap.x}get rowGap(){return this.gap.y}getX(){return this.isLayoutRoot()?this.x.context.getter():this.computedPosition().x}setX(t){this.x.context.setter(t)}getY(){return this.isLayoutRoot()?this.y.context.getter():this.computedPosition().y}setY(t){this.y.context.setter(t)}get width(){return this.size.x}get height(){return this.size.y}getWidth(){return this.computedSize().width}setWidth(t){this.width.context.setter(t)}*tweenWidth(t,e,r,i){const a=this.desiredSize().x,h=typeof a!="number"||typeof t!="number";let c;h?c=this.size.x():c=a;let m;h?(this.size.x(t),m=this.size.x()):m=t,this.size.x(c),h&&this.lockSize(),yield*_t(e,y=>this.size.x(i(c,m,r(y)))),this.size.x(t),h&&this.releaseSize()}getHeight(){return this.computedSize().height}setHeight(t){this.height.context.setter(t)}*tweenHeight(t,e,r,i){const a=this.desiredSize().y,h=typeof a!="number"||typeof t!="number";let c;h?c=this.size.y():c=a;let m;h?(this.size.y(t),m=this.size.y()):m=t,this.size.y(c),h&&this.lockSize(),yield*_t(e,y=>this.size.y(i(c,m,r(y)))),this.size.y(t),h&&this.releaseSize()}desiredSize(){return{x:this.width.context.getter(),y:this.height.context.getter()}}*tweenSize(t,e,r,i){const a=this.desiredSize();let h;typeof a.x!="number"||typeof a.y!="number"?h=this.size():h=new g(a);let c;typeof t=="object"&&typeof t.x=="number"&&typeof t.y=="number"?c=new g(t):(this.size(t),c=this.size()),this.size(h),this.lockSize(),yield*_t(e,m=>this.size(i(h,c,r(m)))),this.releaseSize(),this.size(t)}cardinalPoint(t){switch(t){case it.TopLeft:return this.topLeft;case it.TopRight:return this.topRight;case it.BottomLeft:return this.bottomLeft;case it.BottomRight:return this.bottomRight;case it.Top:case xt.Top:return this.top;case it.Bottom:case xt.Bottom:return this.bottom;case it.Left:case xt.Left:return this.left;case it.Right:case xt.Right:return this.right;default:return this.middle}}constructor(t){super(t),this.element.dataset.motionCanvasKey=this.key}lockSize(){this.sizeLockCounter(this.sizeLockCounter()+1)}releaseSize(){this.sizeLockCounter(this.sizeLockCounter()-1)}parentTransform(){return this.findAncestor(zi(mr))}anchorPosition(){const t=this.computedSize(),e=this.offset();return t.scale(.5).mul(e)}layoutEnabled(){var t;return this.layout()??((t=this.parentTransform())==null?void 0:t.layoutEnabled())??!1}isLayoutRoot(){var t;return!this.layoutEnabled()||!((t=this.parentTransform())!=null&&t.layoutEnabled())}localToParent(){const t=super.localToParent(),e=this.offset();if(!e.exactlyEquals(g.zero)){const r=this.size().mul(e).scale(-.5);t.translateSelf(r.x,r.y)}return t}scalingRotationMatrix(){const t=new DOMMatrix;t.rotateSelf(0,0,this.rotation()),t.scaleSelf(this.scale.x(),this.scale.y());const e=this.offset();if(!e.exactlyEquals(g.zero)){const r=this.size().mul(e).scale(-.5);t.translateSelf(r.x,r.y)}return t}getComputedLayout(){return new Y(this.element.getBoundingClientRect())}computedPosition(){this.requestLayoutUpdate();const t=this.getComputedLayout(),e=new g(t.x+t.width/2*this.offset.x(),t.y+t.height/2*this.offset.y()),r=this.parentTransform();if(r){const i=r.getComputedLayout();e.x-=i.x+(i.width-t.width)/2,e.y-=i.y+(i.height-t.height)/2}return e}computedSize(){return this.requestLayoutUpdate(),this.getComputedLayout().size}requestLayoutUpdate(){const t=this.parentTransform();this.appendedToView()?(t==null||t.requestFontUpdate(),this.updateLayout()):t.requestLayoutUpdate()}appendedToView(){const t=this.isLayoutRoot();return t&&this.view().element.append(this.element),t}updateLayout(){if(this.applyFont(),this.applyFlex(),this.layoutEnabled()){const t=this.layoutChildren();for(const e of t)e.updateLayout()}}layoutChildren(){const t=[...this.children()],e=[],r=[];for(;t.length;){const i=t.shift();i instanceof mr?i.layoutEnabled()&&(e.push(i),r.push(i.element)):i&&t.unshift(...i.children())}return this.element.replaceChildren(...r),e}requestFontUpdate(){var t;this.appendedToView(),(t=this.parentTransform())==null||t.requestFontUpdate(),this.applyFont()}getCacheBBox(){return Y.fromSizeCentered(this.computedSize())}draw(t){if(this.clip()){const e=this.computedSize();if(e.width===0||e.height===0)return;t.beginPath(),t.rect(e.width/-2,e.height/-2,e.width,e.height),t.closePath(),t.clip()}this.drawChildren(t)}drawOverlay(t,e){const r=this.computedSize(),i=r.mul(this.offset()).scale(.5).transformAsPoint(e),a=Y.fromSizeCentered(r),h=a.transformCorners(e),c=a.addSpacing(this.padding().scale(-1)).transformCorners(e),m=a.addSpacing(this.margin()).transformCorners(e);t.beginPath(),de(t,m),de(t,h),t.closePath(),t.fillStyle="rgba(255,193,125,0.6)",t.fill("evenodd"),t.beginPath(),de(t,h),de(t,c),t.closePath(),t.fillStyle="rgba(180,255,147,0.6)",t.fill("evenodd"),t.beginPath(),de(t,h),t.closePath(),t.lineWidth=1,t.strokeStyle="white",t.stroke(),t.beginPath(),hc(t,i),t.stroke()}getOriginDelta(t){const e=this.computedSize().scale(.5),r=this.offset().mul(e);return t===it.Middle?r.flipped:Zu(t).mul(e).sub(r)}moveOffset(t){const e=this.computedSize().scale(.5),r=this.offset().mul(e),i=t.mul(e);this.offset(t),this.position(this.position().add(i).sub(r))}parsePixels(t){return t===null?"":`${t}px`}parseLength(t){return t===null?"":typeof t=="string"?t:`${t}px`}applyFlex(){this.element.style.position=this.isLayoutRoot()?"absolute":"relative";const t=this.desiredSize();this.element.style.width=this.parseLength(t.x),this.element.style.height=this.parseLength(t.y),this.element.style.maxWidth=this.parseLength(this.maxWidth()),this.element.style.minWidth=this.parseLength(this.minWidth()),this.element.style.maxHeight=this.parseLength(this.maxHeight()),this.element.style.minHeight=this.parseLength(this.minHeight()),this.element.style.aspectRatio=this.ratio()===null?"":this.ratio().toString(),this.element.style.marginTop=this.parsePixels(this.margin.top()),this.element.style.marginBottom=this.parsePixels(this.margin.bottom()),this.element.style.marginLeft=this.parsePixels(this.margin.left()),this.element.style.marginRight=this.parsePixels(this.margin.right()),this.element.style.paddingTop=this.parsePixels(this.padding.top()),this.element.style.paddingBottom=this.parsePixels(this.padding.bottom()),this.element.style.paddingLeft=this.parsePixels(this.padding.left()),this.element.style.paddingRight=this.parsePixels(this.padding.right()),this.element.style.flexDirection=this.direction(),this.element.style.flexBasis=this.parseLength(this.basis()),this.element.style.flexWrap=this.wrap(),this.element.style.justifyContent=this.justifyContent(),this.element.style.alignContent=this.alignContent(),this.element.style.alignItems=this.alignItems(),this.element.style.alignSelf=this.alignSelf(),this.element.style.columnGap=this.parseLength(this.gap.x()),this.element.style.rowGap=this.parseLength(this.gap.y()),this.sizeLockCounter()>0?(this.element.style.flexGrow="0",this.element.style.flexShrink="0"):(this.element.style.flexGrow=this.grow().toString(),this.element.style.flexShrink=this.shrink().toString())}applyFont(){if(this.element.style.fontFamily=this.fontFamily.isInitial()?"":this.fontFamily(),this.element.style.fontSize=this.fontSize.isInitial()?"":`${this.fontSize()}px`,this.element.style.fontStyle=this.fontStyle.isInitial()?"":this.fontStyle(),this.lineHeight.isInitial())this.element.style.lineHeight="";else{const t=this.lineHeight();this.element.style.lineHeight=typeof t=="string"?(parseFloat(t)/100).toString():`${t}px`}if(this.element.style.fontWeight=this.fontWeight.isInitial()?"":this.fontWeight().toString(),this.element.style.letterSpacing=this.letterSpacing.isInitial()?"":`${this.letterSpacing()}px`,this.element.style.textAlign=this.textAlign.isInitial()?"":this.textAlign(),this.textWrap.isInitial())this.element.style.whiteSpace="";else{const t=this.textWrap();typeof t=="boolean"?this.element.style.whiteSpace=t?"normal":"nowrap":this.element.style.whiteSpace=t}}dispose(){var t;super.dispose(),(t=this.sizeLockCounter)==null||t.context.dispose(),this.element&&(this.element.remove(),this.element.innerHTML=""),this.element=null,this.styles=null}hit(t){const e=t.transformAsPoint(this.localToParent().inverse());return this.cacheBBox().includes(e)?super.hit(t)??this:null}};O([A(null),Li(Uu),P()],L.prototype,"layout",void 0);O([A(null),P()],L.prototype,"maxWidth",void 0);O([A(null),P()],L.prototype,"maxHeight",void 0);O([A(null),P()],L.prototype,"minWidth",void 0);O([A(null),P()],L.prototype,"minHeight",void 0);O([A(null),P()],L.prototype,"ratio",void 0);O([Tr("margin")],L.prototype,"margin",void 0);O([Tr("padding")],L.prototype,"padding",void 0);O([A("row"),P()],L.prototype,"direction",void 0);O([A(null),P()],L.prototype,"basis",void 0);O([A(0),P()],L.prototype,"grow",void 0);O([A(1),P()],L.prototype,"shrink",void 0);O([A("nowrap"),P()],L.prototype,"wrap",void 0);O([A("start"),P()],L.prototype,"justifyContent",void 0);O([A("normal"),P()],L.prototype,"alignContent",void 0);O([A("stretch"),P()],L.prototype,"alignItems",void 0);O([A("auto"),P()],L.prototype,"alignSelf",void 0);O([A(0),Ht({x:"columnGap",y:"rowGap"})],L.prototype,"gap",void 0);O([le("font-family"),P()],L.prototype,"fontFamily",void 0);O([le("font-size",parseFloat),P()],L.prototype,"fontSize",void 0);O([le("font-style"),P()],L.prototype,"fontStyle",void 0);O([le("font-weight",parseInt),P()],L.prototype,"fontWeight",void 0);O([le("line-height",parseFloat),P()],L.prototype,"lineHeight",void 0);O([le("letter-spacing",n=>n==="normal"?0:parseFloat(n)),P()],L.prototype,"letterSpacing",void 0);O([le("white-space",n=>n==="pre"?"pre":n==="normal"),P()],L.prototype,"textWrap",void 0);O([A("inherit"),P()],L.prototype,"textDirection",void 0);O([le("text-align"),P()],L.prototype,"textAlign",void 0);O([A({x:null,y:null}),Ht({x:"width",y:"height"})],L.prototype,"size",void 0);O([ut()],L.prototype,"tweenWidth",null);O([ut()],L.prototype,"tweenHeight",null);O([E()],L.prototype,"desiredSize",null);O([ut()],L.prototype,"tweenSize",null);O([Ht("offset")],L.prototype,"offset",void 0);O([Yt(it.Middle)],L.prototype,"middle",void 0);O([Yt(it.Top)],L.prototype,"top",void 0);O([Yt(it.Bottom)],L.prototype,"bottom",void 0);O([Yt(it.Left)],L.prototype,"left",void 0);O([Yt(it.Right)],L.prototype,"right",void 0);O([Yt(it.TopLeft)],L.prototype,"topLeft",void 0);O([Yt(it.TopRight)],L.prototype,"topRight",void 0);O([Yt(it.BottomLeft)],L.prototype,"bottomLeft",void 0);O([Yt(it.BottomRight)],L.prototype,"bottomRight",void 0);O([A(!1),P()],L.prototype,"clip",void 0);O([A(0),P()],L.prototype,"sizeLockCounter",void 0);O([E()],L.prototype,"parentTransform",null);O([E()],L.prototype,"anchorPosition",null);O([E()],L.prototype,"layoutEnabled",null);O([E()],L.prototype,"isLayoutRoot",null);O([E()],L.prototype,"scalingRotationMatrix",null);O([E()],L.prototype,"computedPosition",null);O([E()],L.prototype,"computedSize",null);O([E()],L.prototype,"requestLayoutUpdate",null);O([E()],L.prototype,"appendedToView",null);O([E()],L.prototype,"updateLayout",null);O([E()],L.prototype,"layoutChildren",null);O([E()],L.prototype,"requestFontUpdate",null);O([E()],L.prototype,"applyFlex",null);O([E()],L.prototype,"applyFont",null);L=mr=O([Ce("Layout")],L);function Yt(n){return(t,e)=>{P()(t,e),xe(!1)(t,e);const r=we(t,e);r.parser=i=>new g(i),r.getter=function(){return this.computedSize().getOriginOffset(n).transformAsPoint(this.localToParent())},r.setter=function(i){return this.position(ge(i,a=>this.getOriginDelta(n).transform(this.scalingRotationMatrix()).flipped.add(a))),this}}}Qe(L.prototype,n=>{n.element=document.createElement("div"),n.element.style.display="flex",n.element.style.boxSizing="border-box",n.styles=getComputedStyle(n.element)});var Tt=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};let bt=class extends L{rippleSize(){return Gu(this.rippleStrength(),0,50)}constructor(t){super(t),this.rippleStrength=De(0)}applyText(t){t.direction=this.textDirection(),this.element.dir=this.textDirection()}applyStyle(t){t.fillStyle=ls(this.fill(),t),t.strokeStyle=ls(this.stroke(),t),t.lineWidth=this.lineWidth(),t.lineJoin=this.lineJoin(),t.lineCap=this.lineCap(),t.setLineDash(this.lineDash()),t.lineDashOffset=this.lineDashOffset(),this.antialiased()||(t.filter="url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxmaWx0ZXIgaWQ9ImZpbHRlciIgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj48ZmVDb21wb25lbnRUcmFuc2Zlcj48ZmVGdW5jUiB0eXBlPSJpZGVudGl0eSIvPjxmZUZ1bmNHIHR5cGU9ImlkZW50aXR5Ii8+PGZlRnVuY0IgdHlwZT0iaWRlbnRpdHkiLz48ZmVGdW5jQSB0eXBlPSJkaXNjcmV0ZSIgdGFibGVWYWx1ZXM9IjAgMSIvPjwvZmVDb21wb25lbnRUcmFuc2Zlcj48L2ZpbHRlcj48L3N2Zz4=#filter)")}draw(t){this.drawShape(t),this.clip()&&t.clip(this.getPath()),this.drawChildren(t)}drawShape(t){const e=this.getPath(),r=this.lineWidth()>0&&this.stroke()!==null,i=this.fill()!==null;t.save(),this.applyStyle(t),this.drawRipple(t),this.strokeFirst()?(r&&t.stroke(e),i&&t.fill(e)):(i&&t.fill(e),r&&t.stroke(e)),t.restore()}getCacheBBox(){return super.getCacheBBox().expand(this.lineWidth()/2)}getPath(){return new Path2D}getRipplePath(){return new Path2D}drawRipple(t){const e=this.rippleStrength();if(e>0){const r=this.getRipplePath();t.save(),t.globalAlpha*=tt(.54,0,e),t.fill(r),t.restore()}}*ripple(t=1){this.rippleStrength(0),yield*this.rippleStrength(1,t,Xu),this.rippleStrength(0)}};Tt([Ii()],bt.prototype,"fill",void 0);Tt([Ii()],bt.prototype,"stroke",void 0);Tt([A(!1),P()],bt.prototype,"strokeFirst",void 0);Tt([A(0),P()],bt.prototype,"lineWidth",void 0);Tt([A("miter"),P()],bt.prototype,"lineJoin",void 0);Tt([A("butt"),P()],bt.prototype,"lineCap",void 0);Tt([A([]),P()],bt.prototype,"lineDash",void 0);Tt([A(0),P()],bt.prototype,"lineDashOffset",void 0);Tt([A(!0),P()],bt.prototype,"antialiased",void 0);Tt([E()],bt.prototype,"rippleSize",null);Tt([E()],bt.prototype,"getPath",null);Tt([ut()],bt.prototype,"ripple",null);bt=Tt([Ce("Shape")],bt);var zt=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};let Ct=class extends bt{desiredSize(){return this.childrenBBox().size}constructor(t){super(t),this.canHaveSubpath=!1}percentageToDistance(t){return wt(0,this.baseArcLength(),this.startOffset()+this.offsetArcLength()*t)}distanceToPercentage(t){return(t-this.startOffset())/this.offsetArcLength()}baseArcLength(){return this.profile().arcLength}offsetArcLength(){const t=this.startOffset(),e=this.endOffset(),r=this.baseArcLength();return wt(0,r,r-t-e)}arcLength(){return this.offsetArcLength()*Math.abs(this.start()-this.end())}completion(){return Math.abs(this.start()-this.end())}processSubpath(t,e,r){}curveDrawingInfo(){const t=new Path2D;let e=new Path2D;const r=this.profile();let i=this.percentageToDistance(this.start()),a=this.percentageToDistance(this.end());i>a&&([i,a]=[a,i]);const h=a-i,c=Math.min(h/2,this.arrowSize());this.startArrow()&&(i+=c/2),this.endArrow()&&(a-=c/2);let m=0,y=null,k=null,F=null,X=null;for(const Q of r.segments){const at=m;if(m+=Q.arcLength,m<i)continue;const T=(i-at)/Q.arcLength,st=(a-at)/Q.arcLength,Pt=wt(0,1,T),nt=wt(0,1,st);this.canHaveSubpath&&F&&!Q.getPoint(0).position.equals(F)&&(t.addPath(e),this.processSubpath(e,y,F),e=new Path2D,y=null);const[Be,Ft]=Q.draw(e,Pt,nt,y===null);if(y===null&&(y=Be.position,k=Be.normal.flipped.perpendicular),F=Ft.position,X=Ft.normal.flipped.perpendicular,m>a)break}return this.closed()&&this.start.isInitial()&&this.end.isInitial()&&this.startOffset.isInitial()&&this.endOffset.isInitial()&&e.closePath(),this.processSubpath(e,y,F),t.addPath(e),{startPoint:y??g.zero,startTangent:k??g.right,endPoint:F??g.zero,endTangent:X??g.right,arrowSize:c,path:t,startOffset:i}}getPointAtDistance(t){return pi(this.profile(),t+this.startOffset())}getPointAtPercentage(t){return pi(this.profile(),this.percentageToDistance(t))}getComputedLayout(){return this.offsetComputedLayout(super.getComputedLayout())}offsetComputedLayout(t){return t.position=t.position.sub(this.childrenBBox().center),t}getPath(){return this.curveDrawingInfo().path}getCacheBBox(){const t=this.childrenBBox(),e=this.startArrow()||this.endArrow()?this.arrowSize():0,r=this.lineWidth(),i=this.lineWidthCoefficient();return t.expand(Math.max(0,e,r*i))}lineWidthCoefficient(){return this.lineCap()==="square"?.5*1.4143:.5}requiresProfile(){return!this.start.isInitial()||!this.startOffset.isInitial()||!this.startArrow.isInitial()||!this.end.isInitial()||!this.endOffset.isInitial()||!this.endArrow.isInitial()}drawShape(t){super.drawShape(t),(this.startArrow()||this.endArrow())&&this.drawArrows(t)}drawArrows(t){const{startPoint:e,startTangent:r,endPoint:i,endTangent:a,arrowSize:h}=this.curveDrawingInfo();h<.001||(t.save(),t.beginPath(),this.endArrow()&&this.drawArrow(t,i,a.flipped,h),this.startArrow()&&this.drawArrow(t,e,r,h),t.fillStyle=ls(this.stroke(),t),t.closePath(),t.fill(),t.restore())}drawArrow(t,e,r,i){const a=r.perpendicular,h=e.add(r.scale(-i/2));kr(t,h),qt(t,h.add(r.add(a).scale(i))),qt(t,h.add(r.sub(a).scale(i))),qt(t,h),t.closePath()}};zt([A(!1),P()],Ct.prototype,"closed",void 0);zt([A(0),P()],Ct.prototype,"start",void 0);zt([A(0),P()],Ct.prototype,"startOffset",void 0);zt([A(!1),P()],Ct.prototype,"startArrow",void 0);zt([A(1),P()],Ct.prototype,"end",void 0);zt([A(0),P()],Ct.prototype,"endOffset",void 0);zt([A(!1),P()],Ct.prototype,"endArrow",void 0);zt([A(24),P()],Ct.prototype,"arrowSize",void 0);zt([E()],Ct.prototype,"arcLength",null);zt([E()],Ct.prototype,"curveDrawingInfo",null);Ct=zt([Ce("Curve")],Ct);class Pr{}class bc extends Pr{constructor(t,e,r,i,a){super(),this.center=t,this.radius=e,this.from=r,this.to=i,this.counter=a,this.angle=Math.acos(wt(-1,1,r.dot(i))),this.length=Math.abs(this.angle*e);const h=new g(1,1).scale(e);this.points=[t.sub(h),t.add(h)]}get arcLength(){return this.length}draw(t,e,r){const i=this.counter?-1:1,a=this.from.radians+e*this.angle*i,h=this.to.radians-(1-r)*this.angle*i;Math.abs(this.angle)>1e-4&&t.arc(this.center.x,this.center.y,this.radius,a,h,this.counter);const c=g.fromRadians(a),m=g.fromRadians(h);return[{position:this.center.add(c.scale(this.radius)),tangent:this.counter?c:c.flipped,normal:this.counter?c.flipped:c},{position:this.center.add(m.scale(this.radius)),tangent:this.counter?m.flipped:m,normal:this.counter?m.flipped:m}]}getPoint(t){const e=this.counter?-1:1,r=this.from.radians+t*this.angle*e,i=g.fromRadians(r);return{position:this.center.add(i.scale(this.radius)),tangent:this.counter?i:i.flipped,normal:this.counter?i:i.flipped}}}class mt{static constant(t){return new mt(t)}static linear(t,e){return new mt(t,e)}static quadratic(t,e,r){return new mt(t,e,r)}static cubic(t,e,r,i){return new mt(t,e,r,i)}get degree(){return this.c3!==0?3:this.c2!==0?2:this.c1!==0?1:0}constructor(t,e,r,i){this.c0=t,this.c1=e??0,this.c2=r??0,this.c3=i??0}differentiate(t=1){switch(t){case 0:return this;case 1:return new mt(this.c1,2*this.c2,3*this.c3,0);case 2:return new mt(2*this.c2,6*this.c3,0,0);case 3:return new mt(6*this.c3,0,0,0);default:throw new Error("Unsupported derivative")}}eval(t,e=0){return e!==0?this.differentiate(e).eval(t):this.c3*(t*t*t)+this.c2*(t*t)+this.c1*t+this.c0}split(t){const e=1-t,r=new mt(this.c0,this.c1*t,this.c2*t*t,this.c3*t*t*t),i=new mt(this.eval(0),e*this.differentiate(1).eval(t),e*e/2*this.differentiate(2).eval(t),e*e*e/6*this.differentiate(3).eval(t));return[r,i]}roots(){switch(this.degree){case 3:return this.solveCubicRoots();case 2:return this.solveQuadraticRoots();case 1:return this.solveLinearRoot();case 0:return[];default:throw new Error(`Unsupported polynomial degree: ${this.degree}`)}}localExtrema(){return this.differentiate().roots()}localExtrema01(){const t=this.localExtrema(),e=[];for(let r=0;r<t.length;r++){const i=t[r];i>=0&&i<=1&&e.push(t[r])}return e}outputRange01(){let t=[this.eval(0),this.eval(1)];const e=r=>{t[1]>t[0]?t=[Math.min(t[0],r),Math.max(t[1],r)]:t=[Math.min(t[1],r),Math.max(t[0],r)]};return this.localExtrema01().forEach(r=>e(this.eval(r))),t}solveCubicRoots(){const t=this.c0,e=this.c1,r=this.c2,i=this.c3,a=t*t,h=t*r,c=e*e,m=(3*h-c)/(3*a),y=(2*c*e-9*h*e+27*a*i)/(27*a*t),k=this.solveDepressedCubicRoots(m,y),F=X=>X-e/(3*t);switch(k.length){case 1:return[F(k[0])];case 2:return[F(k[0]),F(k[1])];case 3:return[F(k[0]),F(k[1]),F(k[2])];default:return[]}}solveDepressedCubicRoots(t,e){if(this.almostZero(t))return[Math.cbrt(-e)];const r=Math.PI*2,i=4*t*t*t+27*e*e;if(i<1e-5){const a=2*Math.sqrt(-t/3),h=3*e/(2*t)*Math.sqrt(-3/t),c=m=>a*Math.cos(1/3*Math.acos(wt(-1,1,h))-r/3*m);return h>=.9999?[c(0),c(2)]:h<=-.9999?[c(1),c(2)]:[c(0),c(1),c(2)]}if(i>0&&t<0){const a=.3333333333333333*Math.acosh(-3*Math.abs(e)/(2*t)*Math.sqrt(-3/t));return[-2*Math.sign(e)*Math.sqrt(-t/3)*Math.cosh(a)]}if(t>0){const a=.3333333333333333*Math.asinh(3*e/(2*t)*Math.sqrt(3/t));return[-2*Math.sqrt(t/3)*Math.sinh(a)]}return[]}solveQuadraticRoots(){const t=this.c2,e=this.c1,r=this.c0,i=e*e-4*t*r;if(this.almostZero(i))return[-e/(2*t)];if(i>=0){const a=Math.sqrt(i),h=(-e-a)/(2*t),c=(-e+a)/(2*t);return[Math.min(h,c),Math.max(h,c)]}return[]}solveLinearRoot(){return[-this.c0/this.c1]}almostZero(t){return Math.abs(0-t)<=Number.EPSILON}}class Ye{constructor(t,e,r,i){this.c0=t,this.c1=e,this.c2=r,this.c3=i,t instanceof mt?(this.x=t,this.y=e):i!==void 0?(this.x=new mt(t.x,e.x,r.x,i.x),this.y=new mt(t.y,e.y,r.y,i.y)):(this.x=new mt(t.x,e.x,r.x),this.y=new mt(t.y,e.y,r.y))}eval(t,e=0){return new g(this.x.differentiate(e).eval(t),this.y.differentiate(e).eval(t))}split(t){const[e,r]=this.x.split(t),[i,a]=this.y.split(t);return[new Ye(e,i),new Ye(r,a)]}differentiate(t=1){return new Ye(this.x.differentiate(t),this.y.differentiate(t))}evalDerivative(t){return this.differentiate().eval(t)}getBounds(){const t=this.x.outputRange01(),e=this.y.outputRange01();return Y.fromPoints(new g(Math.min(...t),Math.max(...e)),new g(Math.max(...t),Math.min(...e)))}}class yc{constructor(t,e=20){this.curve=t,this.sampledDistances=[],this.resample(e)}resample(t){this.sampledDistances=[0];let e=0,r=this.curve.eval(0).position;for(let i=1;i<t;i++){const a=i/(t-1),h=this.curve.eval(a),c=r.sub(h.position).magnitude;e+=c,this.sampledDistances.push(e),r=h.position}this.sampledDistances[this.sampledDistances.length-1]=this.curve.arcLength}pointAtDistance(t){return this.curve.eval(this.distanceToT(t))}distanceToT(t){const e=this.sampledDistances.length;t=wt(0,this.curve.arcLength,t);for(let r=0;r<e;r++){const i=this.sampledDistances[r],a=this.sampledDistances[r+1];if(t>=i&&t<=a)return qu(i,a,r/(e-1),(r+1)/(e-1),t)}return 1}}class wc extends Pr{get arcLength(){return this.length}constructor(t,e){super(),this.curve=t,this.length=e,this.pointSampler=new yc(this)}getBBox(){return this.curve.getBounds()}eval(t){const e=this.tangent(t);return{position:this.curve.eval(t),tangent:e,normal:e.perpendicular}}getPoint(t){const e=this.pointSampler.pointAtDistance(this.arcLength*t);return{position:e.position,tangent:e.tangent,normal:e.tangent.perpendicular}}transformPoints(t){return this.points.map(e=>e.transformAsPoint(t))}tangent(t){return this.curve.evalDerivative(t).normalized}draw(t,e=0,r=1,i=!0){let a=null,h=e,c=r,m=this.points;if(e!==0||r!==1){const F=this.length*e,X=this.length*r;h=this.pointSampler.distanceToT(F),c=this.pointSampler.distanceToT(X);const Q=(c-h)/(1-h),[,at]=this.split(h);[a]=at.split(Q),m=a.points}i&&kr(t,m[0]),(a??this).doDraw(t);const y=this.tangent(h),k=this.tangent(c);return[{position:m[0],tangent:y,normal:y.perpendicular},{position:m.at(-1),tangent:k,normal:k.perpendicular}]}}var xc=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};class Kt extends wc{get points(){return[this.p0,this.p1,this.p2,this.p3]}constructor(t,e,r,i){super(new Ye(t,t.flipped.add(e).scale(3),t.scale(3).sub(e.scale(6)).add(r.scale(3)),t.flipped.add(e.scale(3)).sub(r.scale(3)).add(i)),Kt.getLength(t,e,r,i)),this.p0=t,this.p1=e,this.p2=r,this.p3=i}split(t){const e=new g(this.p0.x+(this.p1.x-this.p0.x)*t,this.p0.y+(this.p1.y-this.p0.y)*t),r=new g(this.p1.x+(this.p2.x-this.p1.x)*t,this.p1.y+(this.p2.y-this.p1.y)*t),i=new g(this.p2.x+(this.p3.x-this.p2.x)*t,this.p2.y+(this.p3.y-this.p2.y)*t),a=new g(e.x+(r.x-e.x)*t,e.y+(r.y-e.y)*t),h=new g(r.x+(i.x-r.x)*t,r.y+(i.y-r.y)*t),c=new g(a.x+(h.x-a.x)*t,a.y+(h.y-a.y)*t),m=new Kt(this.p0,e,a,c),y=new Kt(c,h,i,this.p3);return[m,y]}doDraw(t){cc(t,this.p1,this.p2,this.p3)}static getLength(t,e,r,i){return Kt.el.setAttribute("d",`M ${t.x} ${t.y} C ${e.x} ${e.y} ${r.x} ${r.y} ${i.x} ${i.y}`),Kt.el.getTotalLength()}}xc([gs(()=>document.createElementNS("http://www.w3.org/2000/svg","path"))],Kt,"el",void 0);class ze extends Pr{constructor(t,e){super(),this.from=t,this.to=e,this.vector=e.sub(t),this.length=this.vector.magnitude,this.normal=this.vector.perpendicular.normalized.safe,this.points=[t,e]}get arcLength(){return this.length}draw(t,e=0,r=1,i=!1){const a=this.from.add(this.vector.scale(e)),h=this.from.add(this.vector.scale(r));return i&&kr(t,a),qt(t,h),[{position:a,tangent:this.normal.flipped,normal:this.normal},{position:h,tangent:this.normal,normal:this.normal}]}getPoint(t){return{position:this.from.add(this.vector.scale(t)),tangent:this.normal.flipped,normal:this.normal}}}function Cc(n,t,e,r){const i={arcLength:0,segments:[],minSin:1},a=ee(t.top,t.right,t.left,n),h=ee(t.right,t.top,t.bottom,n),c=ee(t.bottom,t.left,t.right,n),m=ee(t.left,t.bottom,t.top,n);let y=new g(n.left+a,n.top),k=new g(n.right-h,n.top);return Ie(i,new ze(y,k)),y=new g(n.right,n.top+h),k=new g(n.right,n.bottom-c),h>0&&pr(i,y.addX(-h),h,g.down,g.right,e,r),Ie(i,new ze(y,k)),y=new g(n.right-c,n.bottom),k=new g(n.left+m,n.bottom),c>0&&pr(i,y.addY(-c),c,g.right,g.up,e,r),Ie(i,new ze(y,k)),y=new g(n.left,n.bottom-m),k=new g(n.left,n.top+a),m>0&&pr(i,y.addX(m),m,g.up,g.left,e,r),Ie(i,new ze(y,k)),y=new g(n.left+a,n.top),a>0&&pr(i,y.addY(a),a,g.left,g.down,e,r),i}function Ie(n,t){n.segments.push(t),n.arcLength+=t.arcLength}function pr(n,t,e,r,i,a,h){const c=t.add(r.scale(e)),m=t.add(i.scale(e));a?Ie(n,new Kt(c,c.add(i.scale(h*e)),m.add(r.scale(h*e)),m)):Ie(n,new bc(t,e,r,i,!1))}var er=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};let ne=class extends Ct{constructor(t){super(t)}profile(){return Cc(this.childrenBBox(),this.radius(),this.smoothCorners(),this.cornerSharpness())}desiredSize(){return{x:this.width.context.getter(),y:this.height.context.getter()}}offsetComputedLayout(t){return t}childrenBBox(){return Y.fromSizeCentered(this.computedSize())}getPath(){if(this.requiresProfile())return this.curveDrawingInfo().path;const t=new Path2D,e=this.radius(),r=this.smoothCorners(),i=this.cornerSharpness(),a=Y.fromSizeCentered(this.size());return di(t,a,e,r,i),t}getCacheBBox(){return super.getCacheBBox().expand(this.rippleSize())}getRipplePath(){const t=new Path2D,e=this.rippleSize(),r=this.radius().addScalar(e),i=this.smoothCorners(),a=this.cornerSharpness(),h=Y.fromSizeCentered(this.size()).expand(e);return di(t,h,r,i,a),t}};er([Tr("radius")],ne.prototype,"radius",void 0);er([A(!1),P()],ne.prototype,"smoothCorners",void 0);er([A(.6),P()],ne.prototype,"cornerSharpness",void 0);er([E()],ne.prototype,"profile",null);ne=er([Ce("Rect")],ne);var he=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};class It extends I{constructor({children:t,...e}){super(e),this.scene()||this.scene(new I({})),t&&this.scene().add(t)}getZoom(){return 1/this.scale.x()}setZoom(t){this.scale(ge(t,e=>1/e))}getDefaultZoom(){return this.scale.x.context.getInitial()}*tweenZoom(t,e,r,i){const a=this.scale.x();yield*_t(e,h=>{this.zoom(1/i(a,1/me(t),r(h)))})}*reset(t,e=Et){yield*Fe(this.position(Xe,t,e),this.zoom(Xe,t,e),this.rotation(Xe,t,e))}*centerOn(t,e,r=Et,i=g.lerp){const a=t instanceof I?t.absolutePosition().transformAsPoint(this.scene().worldToLocal()):t;yield*this.position(a,e,r,i)}*followCurve(t,e,r=Et){yield*_t(e,i=>{const a=r(i),h=t.getPointAtPercentage(a).position.transformAsPoint(t.localToWorld());this.position(h)})}*followCurveReverse(t,e,r=Et){yield*_t(e,i=>{const a=1-r(i),h=t.getPointAtPercentage(a).position.transformAsPoint(t.localToWorld());this.position(h)})}*followCurveWithRotation(t,e,r=Et){yield*_t(e,i=>{const a=r(i),{position:h,normal:c}=t.getPointAtPercentage(a),m=h.transformAsPoint(t.localToWorld()),y=c.flipped.perpendicular.degrees;this.position(m),this.rotation(y)})}*followCurveWithRotationReverse(t,e,r=Et){yield*_t(e,i=>{const a=1-r(i),{position:h,normal:c}=t.getPointAtPercentage(a),m=h.transformAsPoint(t.localToWorld()),y=c.flipped.perpendicular.degrees;this.position(m),this.rotation(y)})}transformContext(t){const e=this.localToParent().inverse();t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}hit(t){const e=t.transformAsPoint(this.localToParent());return this.scene().hit(e)}drawChildren(t){this.scene().drawChildren(t)}static Stage({children:t,cameraRef:e,scene:r,...i}){const a=new It({scene:r,children:t});return e==null||e(a),new ne({clip:!0,...i,children:[a]})}}he([P()],It.prototype,"scene",void 0);he([xe(!1),P()],It.prototype,"zoom",void 0);he([ut()],It.prototype,"reset",null);he([ut()],It.prototype,"centerOn",null);he([ut()],It.prototype,"followCurve",null);he([ut()],It.prototype,"followCurveReverse",null);he([ut()],It.prototype,"followCurveWithRotation",null);he([ut()],It.prototype,"followCurveWithRotationReverse",null);var rr=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},hs;let ie=hs=class extends ne{constructor(t){super({composite:!0,fontFamily:"Roboto",fontSize:48,lineHeight:"120%",textWrap:!1,fontStyle:"normal",...t}),this.view2D=this,hs.shadowRoot.append(this.element),this.applyFlex()}dispose(){this.removeChildren(),super.dispose()}render(t){this.computedSize(),this.computedPosition(),super.render(t)}findKey(t){return gr().getNode(t)??null}requestLayoutUpdate(){this.updateLayout()}requestFontUpdate(){this.applyFont()}view(){return this}};rr([A(Ze.Paused),P()],ie.prototype,"playbackState",void 0);rr([A(0),P()],ie.prototype,"globalTime",void 0);rr([P()],ie.prototype,"assetHash",void 0);rr([gs(()=>{const n="motion-canvas-2d-frame";let t=document.querySelector(`#${n}`);return t||(t=document.createElement("div"),t.id=n,t.style.position="absolute",t.style.pointerEvents="none",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.overflow="hidden",document.body.prepend(t)),t.shadowRoot??t.attachShadow({mode:"open"})})],ie,"shadowRoot",void 0);ie=hs=rr([Ce("View2D")],ie);var Sc=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};class Ee extends Pr{constructor(t,e,r,i,a,h){super(),this.startPoint=t,this.radius=e,this.xAxisRotationDegree=r,this.largeArcFlag=i,this.sweepFlag=a,this.endPoint=h,this.xAxisRotation=this.xAxisRotationDegree*te,this.radius=new g(Math.abs(e.x),Math.abs(e.y));const c=t.sub(h).div(2).transform(rt.fromRotation(-r).domMatrix),m=c.x*c.x/(e.x*e.x)+c.y*c.y/(e.y*e.y);if(m>1){const Q=Math.sqrt(m);e.x=Q*e.x,e.y=Q*e.y}const y=new g(e.ctg*c.y,e.perpendicular.ctg*c.x).scale(Math.sqrt(1/(c.x*c.x/(e.x*e.x)+c.y*c.y/(e.y*e.y))-1)*(i===a?-1:1));this.xAxisRotationMatrix=rt.fromRotation(r).domMatrix,this.center=y.transform(this.xAxisRotationMatrix).add(t.add(h).div(2));const k=c.sub(y).div(e),F=c.scale(-1).sub(y).div(e);this.startAngle=k.radians,this.deltaAngle=g.angleBetween(k,F)%(Math.PI*2),this.sweepFlag===0&&this.deltaAngle>0&&(this.deltaAngle-=Math.PI*2),this.sweepFlag===1&&this.deltaAngle<0&&(this.deltaAngle+=Math.PI*2),Ee.el.setAttribute("d",`M ${this.startPoint.x} ${this.startPoint.y} A ${this.radius.x} ${this.radius.y} ${this.xAxisRotationDegree} ${this.largeArcFlag} ${this.sweepFlag} ${this.endPoint.x} ${this.endPoint.y}`),this.length=Ee.el.getTotalLength();const X=new Y(Ee.el.getBBox());this.points=[X.topLeft,X.bottomRight]}getAnglePosition(t){return this.radius.mul(g.fromRadians(t)).transform(this.xAxisRotationMatrix).add(this.center)}getAngleDerivative(t){return new g(-this.radius.x*Math.sin(t),this.radius.y*Math.cos(t)).transform(this.xAxisRotationMatrix)}draw(t,e,r,i){const a=this.startAngle+this.deltaAngle*e,h=this.startAngle+this.deltaAngle*r,c=this.getPoint(e),m=this.getPoint(r);return i&&t.moveTo(c.position.x,c.position.y),t.ellipse(this.center.x,this.center.y,this.radius.x,this.radius.y,this.xAxisRotation,a,h,this.sweepFlag===0),[c,m]}getPoint(t){const e=this.startAngle+t*this.deltaAngle,r=this.getAngleDerivative(e).normalized;return{position:t===0?this.startPoint:t===1?this.endPoint:this.getAnglePosition(e),tangent:r,normal:r.perpendicular}}get arcLength(){return this.length}}Sc([gs(()=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");return n.appendChild(t),ie.shadowRoot.appendChild(n),t})],Ee,"el",void 0);function kc(n,t,e,r,i=!1){const a={arcLength:0,minSin:1,segments:[]};if(e<t){const k=Math.floor((t-e)/(Math.PI*2))+1;e+=Math.PI*2*k}else if(e>t+Math.PI*2){const k=Math.floor((e-t)/(Math.PI*2));e-=Math.PI*2*k}const h=(t+e)/2,c=n.mul(g.fromRadians(t)),m=n.mul(g.fromRadians(e)),y=n.mul(g.fromRadians(h)).scale(i?-1:1);return r&&us(a,new ze(g.zero,c)),gi(a,n,c,y,t,h,i),gi(a,n,y,m,h,e,i),r&&us(a,new ze(m,g.zero)),a}function us(n,t){n.segments.push(t),n.arcLength+=t.arcLength}function gi(n,t,e,r,i,a,h){const c=Math.abs(i-a)<=180?1:0,m=i>a?0:1,y=h?0:1;us(n,new Ee(e,t,0,0,c^y^m,r))}var sr=globalThis&&globalThis.__decorate||function(n,t,e,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(h=n[c])&&(a=(i<3?h(a):i>3?h(t,e,a):h(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a};let ye=class extends Ct{constructor(t){super(t)}profile(){return kc(this.size().scale(.5),this.startAngle()*te,this.endAngle()*te,this.closed(),this.counterclockwise())}desiredSize(){return{x:this.width.context.getter(),y:this.height.context.getter()}}offsetComputedLayout(t){return t}childrenBBox(){return Y.fromSizeCentered(this.computedSize())}getPath(){return this.requiresProfile()?this.curveDrawingInfo().path:this.createPath()}getRipplePath(){return this.createPath(this.rippleSize())}getCacheBBox(){return super.getCacheBBox().expand(this.rippleSize())}createPath(t=0){const e=new Path2D,r=this.startAngle()*te;let i=this.endAngle()*te;const a=this.size().scale(.5).add(t),h=this.closed();if(i>r+Math.PI*2){const c=Math.floor((i-r)/(Math.PI*2));i-=Math.PI*2*c}return h&&e.moveTo(0,0),e.ellipse(0,0,a.x,a.y,0,r,i,this.counterclockwise()),h&&e.closePath(),e}};sr([A(0),P()],ye.prototype,"startAngle",void 0);sr([A(360),P()],ye.prototype,"endAngle",void 0);sr([A(!1),P()],ye.prototype,"counterclockwise",void 0);sr([E()],ye.prototype,"profile",null);ye=sr([Ce("Circle")],ye);class Tc extends Bu{constructor(t){super(t),this.view=null,this.registeredNodes=new Map,this.nodeCounters=new Map,this.assetHash=Date.now().toString(),this.recreateView()}getView(){return this.view}next(){var t;return(t=this.getView())==null||t.playbackState(this.playback.state).globalTime(this.playback.time),super.next()}draw(t){t.save(),this.renderLifecycle.dispatch([Dt.BeforeRender,t]),t.save(),this.renderLifecycle.dispatch([Dt.BeginRender,t]),this.getView().playbackState(this.playback.state).globalTime(this.playback.time),this.getView().render(t),this.renderLifecycle.dispatch([Dt.FinishRender,t]),t.restore(),this.renderLifecycle.dispatch([Dt.AfterRender,t]),t.restore()}reset(t){for(const e of this.registeredNodes.keys())try{this.registeredNodes.get(e).dispose()}catch(r){this.logger.error(r)}return this.registeredNodes.clear(),this.registeredNodes=new Map,this.nodeCounters.clear(),this.recreateView(),super.reset(t)}inspectPosition(t,e){return this.execute(()=>{var r;return((r=this.getView().hit(new g(t,e)))==null?void 0:r.key)??null})}validateInspection(t){var e;return((e=this.getNode(t))==null?void 0:e.key)??null}inspectAttributes(t){const e=this.getNode(t);if(!e)return null;const r={stack:e.creationStack,key:e.key};for(const{key:i,meta:a,signal:h}of e)a.inspectable&&(r[i]=h());return r}drawOverlay(t,e,r){const i=this.getNode(t);i&&this.execute(()=>{const a=this.getView().findAll(zi(It)),h=[];for(const c of a){const m=c.scene();m&&(m===i||m.findFirst(y=>y===i))&&h.push(c)}if(h.length>0)for(const c of h){const m=c.parentToWorld(),y=c.localToParent().inverse(),k=i.localToWorld();i.drawOverlay(r,e.multiply(m).multiply(y).multiply(k))}else i.drawOverlay(r,e.multiply(i.localToWorld()))})}transformMousePosition(t,e){return new g(t,e).transformAsPoint(this.getView().localToParent().inverse())}registerNode(t,e){var h;const r=((h=t.constructor)==null?void 0:h.name)??"unknown",i=(this.nodeCounters.get(r)??0)+1;this.nodeCounters.set(r,i),e&&this.registeredNodes.has(e)&&(vt().error({message:`Duplicated node key: "${e}".`,inspect:e,stack:new Error().stack}),e=void 0),e??(e=`${this.name}/${r}[${i}]`),this.registeredNodes.set(e,t);const a=this.registeredNodes;return[e,()=>a.delete(e)]}getNode(t){return typeof t!="string"?null:this.registeredNodes.get(t)??null}*getDetachedNodes(){for(const t of this.registeredNodes.values())!t.parent()&&t!==this.view&&(yield t)}recreateView(){this.execute(()=>{const t=this.getSize();this.view=new ie({position:t.scale(this.resolutionScale/2),scale:this.resolutionScale,assetHash:this.assetHash,size:t})})}}function Pc(n){return{klass:Tc,config:n,stack:new Error().stack,meta:Nu(),plugins:["@motion-canvas/2d/editor"]}}const pe=Pc(function*(n){const t=du();n.add(nc(ye,{ref:t,size:320,fill:"lightseagreen"})),yield*t().scale(2,2).to(1,2)});pe.name="example";ec.attach(pe.meta);pe.onReplaced??(pe.onReplaced=new re(pe.config));const Rc={scenes:[pe]};let Ss;Ss??(Ss=new Je("\0virtual:settings",!1));Ss.loadData({version:1,appearance:{color:"rgb(0,144,255)",font:!1,coordinates:!0},defaults:{background:"rgba(255,0,0,0)",size:{x:1920,y:1080}}});const Mc=Ss,Ec=yu("project",{core:"3.17.2",two:"3.17.2",ui:"3.17.2",vitePlugin:"3.17.2"},[Ku()],Rc,tc,Mc);export{Ec as default};
