modern-canvas 0.6.8 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5776,9 +5776,6 @@ exports.Node = class Node extends CoreObject {
5776
5776
  return false;
5777
5777
  }
5778
5778
  }
5779
- _update(changed) {
5780
- super._update(changed);
5781
- }
5782
5779
  _updateProperty(key, value, oldValue, declaration) {
5783
5780
  super._updateProperty(key, value, oldValue, declaration);
5784
5781
  }
@@ -7303,15 +7300,12 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
7303
7300
  }
7304
7301
  requestRedraw() {
7305
7302
  this._redrawing = true;
7306
- this.requestUpdate();
7307
7303
  }
7308
7304
  requestRelayout() {
7309
7305
  this._relayouting = true;
7310
- this.requestUpdate();
7311
7306
  }
7312
7307
  requestRepaint() {
7313
7308
  this._repainting = true;
7314
- this.requestUpdate();
7315
7309
  }
7316
7310
  _updateGlobalVisible() {
7317
7311
  this._parentGlobalVisible = this.getParent()?.globalVisible;
@@ -7350,22 +7344,14 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
7350
7344
  _process(delta) {
7351
7345
  super._process(delta);
7352
7346
  const parent = this.getParent();
7353
- if (this._parentGlobalVisible !== parent?.globalVisible) {
7354
- this.requestUpdate();
7355
- }
7356
- if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7357
- this.requestUpdate();
7358
- }
7359
- }
7360
- _update(changed) {
7361
- super._update(changed);
7362
- const parent = this.getParent();
7363
7347
  if (this._parentGlobalVisible !== parent?.globalVisible) {
7364
7348
  this._updateGlobalVisible();
7365
7349
  }
7366
7350
  if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7367
7351
  this._updateGlobalOpacity();
7368
7352
  }
7353
+ }
7354
+ _updateBatchables() {
7369
7355
  const redrawing = this._redrawing;
7370
7356
  let relayouting = this._relayouting;
7371
7357
  let repainting = this._repainting;
@@ -7394,6 +7380,7 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
7394
7380
  }
7395
7381
  }
7396
7382
  _render(renderer) {
7383
+ this._updateBatchables();
7397
7384
  this._batchables.forEach((batchable) => {
7398
7385
  batchable.texture?.upload(renderer);
7399
7386
  renderer.batch2D.render({
package/dist/index.d.cts CHANGED
@@ -1667,7 +1667,6 @@ declare class Node extends CoreObject {
1667
1667
  get lastSibling(): Node | undefined;
1668
1668
  canProcess(): boolean;
1669
1669
  canRender(): boolean;
1670
- protected _update(changed: Map<string, any>): void;
1671
1670
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1672
1671
  protected _onTreeEnter(tree: SceneTree): void;
1673
1672
  protected _onTreeExit(oldTree: SceneTree): void;
@@ -1799,7 +1798,7 @@ declare class CanvasItem extends TimelineNode {
1799
1798
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
1800
1799
  protected _repaint(batchables: CanvasBatchable[]): CanvasBatchable[];
1801
1800
  protected _process(delta: number): void;
1802
- protected _update(changed: Map<string, any>): void;
1801
+ protected _updateBatchables(): void;
1803
1802
  protected _render(renderer: WebGLRenderer): void;
1804
1803
  }
1805
1804
 
package/dist/index.d.mts CHANGED
@@ -1667,7 +1667,6 @@ declare class Node extends CoreObject {
1667
1667
  get lastSibling(): Node | undefined;
1668
1668
  canProcess(): boolean;
1669
1669
  canRender(): boolean;
1670
- protected _update(changed: Map<string, any>): void;
1671
1670
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1672
1671
  protected _onTreeEnter(tree: SceneTree): void;
1673
1672
  protected _onTreeExit(oldTree: SceneTree): void;
@@ -1799,7 +1798,7 @@ declare class CanvasItem extends TimelineNode {
1799
1798
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
1800
1799
  protected _repaint(batchables: CanvasBatchable[]): CanvasBatchable[];
1801
1800
  protected _process(delta: number): void;
1802
- protected _update(changed: Map<string, any>): void;
1801
+ protected _updateBatchables(): void;
1803
1802
  protected _render(renderer: WebGLRenderer): void;
1804
1803
  }
1805
1804
 
package/dist/index.d.ts CHANGED
@@ -1667,7 +1667,6 @@ declare class Node extends CoreObject {
1667
1667
  get lastSibling(): Node | undefined;
1668
1668
  canProcess(): boolean;
1669
1669
  canRender(): boolean;
1670
- protected _update(changed: Map<string, any>): void;
1671
1670
  protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1672
1671
  protected _onTreeEnter(tree: SceneTree): void;
1673
1672
  protected _onTreeExit(oldTree: SceneTree): void;
@@ -1799,7 +1798,7 @@ declare class CanvasItem extends TimelineNode {
1799
1798
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
1800
1799
  protected _repaint(batchables: CanvasBatchable[]): CanvasBatchable[];
1801
1800
  protected _process(delta: number): void;
1802
- protected _update(changed: Map<string, any>): void;
1801
+ protected _updateBatchables(): void;
1803
1802
  protected _render(renderer: WebGLRenderer): void;
1804
1803
  }
1805
1804
 
package/dist/index.js CHANGED
@@ -111,7 +111,7 @@ uniform sampler2D sampler;
111
111
  uniform vec4 tint;
112
112
  void main(void) {
113
113
  gl_FragColor = texture2D(sampler, vUv) * tint;
114
- }`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}class gt extends gr{static _instance;static get instance(){return this._instance??=new this}static draw(t,e=pi.instance,A){this.instance.draw(t,e,A)}constructor(){super({vertexAttributes:{position:new le({buffer:new Ye({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new le({buffer:new Ye({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new UA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}class th extends gr{positionBuffer;uvBuffer;constructor(){const t=new Ye({data:new Float32Array,dynamic:!0}),e=new Ye({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new le({buffer:t,size:2,normalized:!1,type:"float"}),uv:new le({buffer:e,size:2,normalized:!1,type:"float"})},indexBuffer:new UA({data:new Uint16Array,dynamic:!0})}),this.positionBuffer=t,this.uvBuffer=e}}var eh=Object.defineProperty,NA=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&eh(t,e,i),i};class Dt extends Je{static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}_isPowerOfTwo=!1;_needsUpload=!1;get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}constructor(t){super(),this.source=t,this._updateSize()}_glTextureOptions(t,e){let A=this.wrapMode;return t.version===1&&!this._isPowerOfTwo&&(A="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:A,...e}}_glTexture(t,e){return t.getRelated(this,()=>t.texture.create(this._glTextureOptions(t,e)))}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=ps(this.realWidth)&&ps(this.realHeight),this.requestUpload()}_updateSize(){const t=this.source;"pixels"in t?(this.width=t.width/this.pixelRatio,this.height=t.height/this.pixelRatio):(this.width=Number(t.naturalWidth||t.videoWidth||t.width||0)/this.pixelRatio,this.height=Number(t.naturalHeight||t.videoHeight||t.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(t,e){return this._needsUpload&&this.valid?(this._needsUpload=!1,t.texture.update(this._glTexture(t,e),this._glTextureOptions(t,e)),!0):!1}activate(t,e=0){return this.valid?(t.texture.bind({target:"texture_2d",value:this._glTexture(t,{location:e}),location:e}),this.upload(t,{location:e}),!0):!1}inactivate(t){t.texture.unbind(this._glTexture(t))}free(){Do&&this.source instanceof ImageBitmap&&this.source.close()}}NA([w({protected:!0})],Dt.prototype,"source"),NA([w({fallback:0})],Dt.prototype,"width"),NA([w({fallback:0})],Dt.prototype,"height"),NA([w({fallback:"linear"})],Dt.prototype,"filterMode"),NA([w({fallback:"clamp_to_edge"})],Dt.prototype,"wrapMode"),NA([w({fallback:1})],Dt.prototype,"pixelRatio");class fr extends Je{frames;constructor(t){super();let e;if(Array.isArray(t))e=t;else if(t instanceof Dt)e=[{texture:t,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=e,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((t,e)=>e.duration+t,0),this}free(){this.frames.forEach(t=>{t.texture.free()})}}var Ah=Object.defineProperty,ih=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&Ah(t,e,i),i};class Ei extends Dt{constructor(t=document.createElement("canvas")){super(t)}_updateProperty(t,e,A,i){switch(t){case"width":this.source.width=Math.max(1,Math.ceil(e*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(e*this.pixelRatio));break}super._updateProperty(t,e,A,i)}}ih([w({fallback:2})],Ei.prototype,"pixelRatio");class ca extends Dt{static _cached=new Map;static get(t){const e=new ve(t),A=e.toHex();let i=this._cached.get(A);return i||(i=new Dt({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])}),this._cached.set(A,i)),i}constructor(t){const e=new ve(t);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}class dr extends Dt{static test(t){return ci(t)}static linearGradient(t,e,A){e=e||1,A=A||1;const i=document.createElement("canvas");i.width=e,i.height=A;const s=i.getContext("2d");if(!s)throw new Error("Failed to parse linear gradient, get canvas context is null.");let{angle:n=0,stops:o}=t;n-=Math.PI/2;const a=e/2,l=A/2,u=Math.sqrt(e*e+A*A)/2,c=a+u*Math.cos(n+Math.PI),g=l+u*Math.sin(n+Math.PI),f=a+u*Math.cos(n),d=l+u*Math.sin(n),B=s.createLinearGradient(c,g,f,d);o.forEach(F=>{B.addColorStop(F.offset,F.color)}),s.fillStyle=B,s.fillRect(0,0,i.width,i.height);const I=s.getImageData(0,0,i.width,i.height);return{width:I.width,height:I.height,pixels:new Uint8Array(I.data.buffer)}}constructor(t,e,A){super(dr.linearGradient(t,e,A))}}function rh(r){return{autoLoad:!!(r?.autoLoad??!0),useBitmap:!!(r?.useBitmap??!0)&&Bs,crossorigin:r?.crossorigin??null}}class sh extends Dt{bitmap;useBitmap;preserveBitmap=!1;_loadSource;_loadBitmap;constructor(t,e){const A=rh(e);super(t);const i=t.src,s=i.includes(".svg")||i.startsWith("data:image/svg+xml");this.useBitmap=A.useBitmap&&!s,A.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(t=>{this._loadSource=void 0;const e=this.source,A=()=>{e.onload=null,e.onerror=null},i=()=>{A(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>t(this)):t(this)},s=n=>{A(),console.warn(`Failed to load ImageTexture, src: ${e.src}`,n),this.emit("error",n),t(this)};e.complete&&e.src?i():(e.onload=i,e.onerror=s)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Bs)return Promise.resolve(this);const t=this.source,e=!t.crossOrigin||t.crossOrigin==="anonymous";return this._loadBitmap=fetch(t.src,{mode:e?"cors":"no-cors"}).then(A=>A.blob()).then(A=>createImageBitmap(A,0,0,t.width,t.height,{premultiplyAlpha:"premultiply"})).then(A=>(this.bitmap=A,this.requestUpload(),this._loadBitmap=void 0,this)).catch(A=>(console.warn("Failed to genBitmap",A),this)),this._loadBitmap}_glTextureOptions(t){return{...super._glTextureOptions(t),value:this.bitmap??this.source}}upload(t){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const A=this.source;if(di&&A instanceof HTMLImageElement&&(!A.complete||A.naturalWidth===0))return!1}const e=super.upload(t);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),e}}class Ms extends Dt{constructor(t,e=1,A=1){const i={width:e,height:A,pixels:null};t&&(ArrayBuffer.isView(t)?i.pixels=new Uint8Array(t.buffer):i.pixels=new Uint8Array(t)),super(i)}_updateProperty(t,e,A,i){switch(t){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(t,e,A,i)}}var nh=Object.defineProperty,ha=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&nh(t,e,i),i};function oh(r){return{autoLoad:!!(r?.autoLoad??!0),autoPlay:!!(r?.autoPlay??!1),fps:Number(r?.fps??0),crossorigin:r?.crossorigin??null,loop:!!(r?.loop??!1),muted:!!(r?.muted??!1),playsinline:!!(r?.playsinline??!0)}}const Rs=class xu extends Dt{static mimeTypes=new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}));get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(t){this.source.currentTime=t}_spf=0;_autoPlay=!1;_sourceLoad;_nextTime=0;_connected=!1;_requestId;_resolve;_reject;constructor(t,e){const A=oh(e);if(!xo(t)){typeof t=="string"&&(t=[t]);const i=t[0].src||t[0],s=document.createElement("video");A.autoLoad&&s.setAttribute("preload","auto"),A.playsinline&&(s.setAttribute("webkit-playsinline",""),s.setAttribute("playsinline","")),A.muted&&(s.setAttribute("muted",""),s.muted=!0),A.loop&&s.setAttribute("loop",""),A.autoPlay&&s.setAttribute("autoplay",""),Po(s,i,A.crossorigin);for(let n=0;n<t.length;++n){let{src:o,mime:a}=t[n];if(o=o||t[n],o.startsWith("data:"))a=o.slice(5,o.indexOf(";"));else if(!o.startsWith("blob:")){const u=o.split("?").shift().toLowerCase(),c=u.slice(u.lastIndexOf(".")+1);a=a||xu.mimeTypes.get(c)||`video/${c}`}const l=document.createElement("source");l.src=o,a&&(l.type=a),s.appendChild(l)}t=s}super(t),this.fps=A.fps,this._autoPlay=A.autoPlay,A.autoPlay&&this.load(),this._setupAutoUpdate()}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"fps":this._spf=e?Math.floor(1e3/e):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_onPlayStart=()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()};_onPlayStop=()=>{this._setupAutoUpdate()};_onCanPlay=()=>{const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!e&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&t.play()};_onError=t=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=void 0,this._resolve=void 0)};_onSeeked=()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)};_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(Kt.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(Kt.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Kt.off(this.requestUpload),this._connected=!1,this._nextTime=0))}_videoFrameRequestCallback=()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)};requestUpload=()=>{const t=Math.floor(Kt.elapsed*this.source.playbackRate);this._nextTime-=t,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)};async load(){if(!this._sourceLoad){const t=this.source;(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((e,A)=>{this.valid?(this._sourceLoad=void 0,e(this)):(this._resolve=e,this._reject=A,t.load())})}return this._sourceLoad}free(){this._setupAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load())}};ha([w({protected:!0,fallback:!0})],Rs.prototype,"autoUpdate"),ha([w({protected:!0,fallback:0})],Rs.prototype,"fps");let ga=Rs;class Ps extends Ms{}class fa extends Array{front=[];back=[];get internal(){return[...this.front,...this,...this.back]}constructor(...t){super(),this.set(t)}set(t){return this.front.length=0,this.length=0,this.back.length=0,t.forEach(e=>{switch(e.internalMode){case"front":this.front.push(e);break;case"default":this.push(e);break;case"back":this.back.push(e);break}}),this}getInternal(t){switch(t){case"front":return this.front;case"default":return this;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${t}`)}}toJSON(){return[...this]}}var ah=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,AA=(r,t,e,A)=>{for(var i=A>1?void 0:A?lh(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&ah(t,e,i),i};const da={};function uh(r){let t=da[r]??0;return t++,da[r]=t,t}h.Node=class extends tA{meta={};_readyed=!1;constructor(t,e=[]){super(),this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.is}:${uh(this.is)}`,...t}).append(e),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(t){if(t){const{meta:e,...A}=t;if(e)for(const i in e)this.meta[i]=e[i];super.setProperties(A)}return this}getName(){return this.name}setName(t){return this.name=t,this}_tree;get tree(){return this.getTree()}set tree(t){this.setTree(t)}getTree(){return this._tree}getViewport(){return this._tree?.getCurrentViewport()}getWindow(){return this._tree?.root}isInsideTree(){return!!this._tree}setTree(t){const e=this._tree;if(!t?.equal(e)){e&&this.emit("treeExit",e),this._tree=t,t&&this.emit("treeEnter",t);const A=this._children.internal;for(let i=A.length,s=0;s<i;s++){const n=A[s];!t&&this.emit("childExitingTree",n),n.setTree(t),t&&this.emit("childEnteredTree",n)}t&&(this.emit("treePostEnter",t),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}log(...t){this._tree?.log(...t)}_parent;get parent(){return this._parent}set parent(t){this.setParent(t)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(t){if(!this._parent?.equal(t)){const e=this._parent;e&&this.emit("unparented",e),this._parent=t,t&&this.emit("parented",t),this.setTree(t?._tree)}return this}_children=new fa;get children(){return this._children}set children(t){t instanceof fa?this._children=t:this._children.set(t)}getChild(t=0){return this._children[t]}get siblingIndex(){return this.getIndex()}set siblingIndex(t){this._parent?.moveChild(this,t)}get previousSibling(){return this._parent?.children[this.getIndex()-1]}get nextSibling(){return this._parent?.children[this.getIndex()+1]}get firstSibling(){return this._parent?.children[0]}get lastSibling(){const t=this._parent?.children;return t?t[t.length-1]:void 0}canProcess(){if(!this._tree)return!1;switch(this.processMode){case"inherit":return this._parent?.canProcess()??!0;case"pausable":return!this._tree.processPaused;case"when_paused":return this._tree.processPaused;case"always":return!0;case"disabled":default:return!1}}canRender(){if(!this._tree)return!1;switch(this.renderMode){case"inherit":return this._parent?.canRender()??!0;case"always":return!0;case"disabled":default:return!1}}_update(t){super._update(t)}_updateProperty(t,e,A,i){super._updateProperty(t,e,A,i)}_onTreeEnter(t){this._treeEnter(t),this.emit("treeEntered",t)}_onTreeExit(t){this.emit("treeExiting",t),this._treeExit(t),this.emit("treeExited",t)}_onParented(t){this._parented(t)}_onUnparented(t){this._unparented(t)}_onReady(){this._ready()}_onProcess(t=0){const e=this._tree,A=this.canRender(),i=this.canProcess(),s=[],n=[];this._children.internal.forEach(a=>{switch(a.processSortMode){case"default":n.push(a);break;case"parent_before":s.push(a);break}}),s.forEach(a=>{a.emit("process",t)}),i&&(e?.emit("nodeProcessing",this),this.emit("processing",t),this._process(t));let o;if(A){const a=e.renderStack.push(this);o=e.renderStack.currentCall,e.renderStack.currentCall=a}if(this.mask instanceof h.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const a=this.getNode("__$mask");a&&this.removeChild(a)}n.forEach(a=>{a.emit("process",t)}),A&&(e.renderStack.currentCall=o),i&&(this.emit("processed",t),e?.emit("nodeProcessed",this))}render(t,e){const A=this.mask;A&&(t.flush(),t.mask.push(this,A)),this._render(t),e?.(),A&&(t.flush(),t.mask.pop(this))}input(t,e){const A=this._children.internal;for(let i=A.length-1;i>=0;i--)A[i].input(t,e);this._input(t,e)}getIndex(){return this._parent?.children.getInternal(this.internalMode).indexOf(this)??0}getNode(t){return this._children.internal.find(e=>e.name===t)}removeNode(t){this.getNode(t)?.remove()}addSibling(t){return this.equal(t)||!this.hasParent()||t.hasParent()?this:(t.internalMode=this.internalMode,this._parent.moveChild(t,this.getIndex()+1),this)}prepend(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this.moveChild(A,0)})}append(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this.appendChild(A)})}before(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this._parent?.moveChild(A,this.getIndex())})}after(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this._parent?.moveChild(A,this.getIndex()+1)})}insertBefore(t,e){return!e.hasParent()||!this.equal(e.parent)||this.moveChild(t,e.getIndex()),t}appendChild(t,e=t.internalMode){if(this.equal(t)||t.hasParent())return t;switch(e){case"front":this._children.front.push(t);break;case"default":this._children.push(t);break;case"back":this._children.back.push(t);break}return t.internalMode!==e&&(t.internalMode=e),t.setParent(this),this.emit("appendChild",t),t}moveChild(t,e,A=t.internalMode){if(this.equal(t)||t.hasParent()&&!this.equal(t.parent))return this;const i=this._children.getInternal(t.internalMode),s=i.indexOf(t),n=this._children.getInternal(A);return(t.internalMode!==A||e!==s)&&(s>-1&&i.splice(s,1),t.setParent(this),e>-1&&e<n.length?n.splice(e,0,t):n.push(t),s>-1?this.emit("moveChild",t,e,s):this.emit("appendChild",t)),t.internalMode!==A&&(t.internalMode=A),this}removeChild(t){const e=t.getIndex();return this.equal(t.parent)&&e>-1&&(this._children.getInternal(t.internalMode).splice(e,1),t.setParent(void 0),this.emit("removeChild",t,e)),t}removeChildren(){this._children.forEach(t=>this.removeChild(t))}remove(){this._parent?.removeChild(this)}forEachChild(t){return this._children.forEach(t),this}forEachDescendant(t){return this._children.forEach(e=>{t(e),e.forEachDescendant(t)}),this}forEachAncestor(t){const e=this.parent;return e&&(t(e),e.forEachAncestor(t)),this}_ready(){}_treeEnter(t){}_treeExit(t){}_parented(t){}_unparented(t){}_process(t){}_input(t,e){}_render(t){}clone(){return new this.constructor(this.toJSON(),this._children.internal)}toJSON(){return ui({...super.toJSON(),is:this.is,children:this._children.length?[...this._children.map(t=>t.toJSON())]:void 0,meta:Object.keys(this.meta).length?{...this.meta}:void 0})}static parse(t){if(Array.isArray(t))return t.map(o=>this.parse(o));const{is:e,props:A,children:i}=t,s=lr.get(e)??h.Node,n=new s(A);return i?.forEach(o=>n.appendChild(this.parse(o))),n}},AA([w({fallback:Io()})],h.Node.prototype,"id",2),AA([w({fallback:Io()})],h.Node.prototype,"name",2),AA([w({fallback:"inherit"})],h.Node.prototype,"processMode",2),AA([w({fallback:"default"})],h.Node.prototype,"processSortMode",2),AA([w({fallback:"inherit"})],h.Node.prototype,"renderMode",2),AA([w({fallback:"default"})],h.Node.prototype,"internalMode",2),AA([w({protected:!0})],h.Node.prototype,"mask",2),h.Node=AA([st("Node")],h.Node);var ch=Object.defineProperty,hh=Object.getOwnPropertyDescriptor,Bi=(r,t,e,A)=>{for(var i=A>1?void 0:A?hh(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&ch(t,e,i),i};h.TimelineNode=class extends h.Node{constructor(t,e=[]){super(),this.setProperties(t).append(e)}computedDuration=0;_currentTime=0;_startTime=0;get timeline(){return this._tree?.timeline}get timelineCurrentTime(){return this.timeline?.currentTime??0}get parentStartTime(){return this._parent?.startTime??0}get currentTime(){return Ke(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(t){this.delay=t-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?Ke(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const t=this._currentTime;return this.computedDuration?t>=0&&t<=this.computedDuration:t>=0}_updateCurrentTime(t=!1){if(t||!this.paused){const e=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=e?.computedDuration?Math.min(this._startTime+this.duration,e.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(t){super._process(t),this._updateCurrentTime()}},Bi([w({fallback:0})],h.TimelineNode.prototype,"delay",2),Bi([w({fallback:0})],h.TimelineNode.prototype,"duration",2),Bi([w({fallback:!1})],h.TimelineNode.prototype,"paused",2),Bi([w({protected:!0,fallback:!1})],h.TimelineNode.prototype,"insideTimeRange",2),h.TimelineNode=Bi([st("TimelineNode")],h.TimelineNode);var gh=Object.defineProperty,fh=Object.getOwnPropertyDescriptor,Ci=(r,t,e,A)=>{for(var i=A>1?void 0:A?fh(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&gh(t,e,i),i};h.Viewport=class extends h.Node{constructor(t=!1){super(),this.flipY=t,this._projection.flipY(t)}_projection=new Ho;_framebufferIndex=0;_framebuffers=[{texture:new Ps,needsUpload:!1},{texture:new Ps,needsUpload:!1}];get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(t){const{width:e,height:A}=this,{pixelRatio:i}=t;return this._framebuffers.forEach(s=>{const n=s.texture;n.width=e,n.height=A,n.pixelRatio=i,n.upload(t)}),{width:e,height:A,colorTextures:[this.texture._glTexture(t)]}}_glFramebuffer(t){return t.getRelated(this.framebuffer,()=>t.framebuffer.create(this._glFramebufferOptions(t)))}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height),this.emit("updateRect");break}}requestUpload(){this._framebuffers.forEach(t=>t.needsUpload=!0)}resize(t,e){this.width=t,this.height=e}upload(t){const e=this.framebuffer;return e.needsUpload&&this.valid?(e.needsUpload=!1,t.framebuffer.update(this._glFramebuffer(t),this._glFramebufferOptions(t)),!0):!1}activate(t){return this.valid?(t.flush(),this._tree?.setCurrentViewport(this),this.upload(t),t.framebuffer.bind(this._glFramebuffer(t)),!0):!1}redraw(t,e){if(this.valid){t.flush();const A=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(t),t.clear(),A.activate(t,0),e(),!0}return!1}activateWithCopy(t,e){this.resize(e.width,e.height),this.activate(t)&&(t.clear(),e.texture.activate(t,0),gt.draw(t,pi.instance,{sampler:0}))}render(t,e){const A=this._tree?.getCurrentViewport();this.activate(t),t.clear(),super.render(t,e),t.flush(),A?A.activate(t):(t.framebuffer.bind(null),this._tree?.setCurrentViewport(void 0))}getRect(){return new xs(this.x,this.y,this.width,this.height)}toProjectionArray(t=!1){return this._projection.toArray(t)}},Ci([w({fallback:0})],h.Viewport.prototype,"x",2),Ci([w({fallback:0})],h.Viewport.prototype,"y",2),Ci([w({fallback:0})],h.Viewport.prototype,"width",2),Ci([w({fallback:0})],h.Viewport.prototype,"height",2),h.Viewport=Ci([st("Viewport")],h.Viewport);var dh=Object.defineProperty,Ih=Object.getOwnPropertyDescriptor,Qi=(r,t,e,A)=>{for(var i=A>1?void 0:A?Ih(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&dh(t,e,i),i};h.Effect=class extends h.TimelineNode{material;get _effectMode(){return this.effectMode??"parent"}viewport1=new h.Viewport;viewport2=new h.Viewport;_renderId=0;_renderViewport;_previousSibling;_nextSibling;constructor(t,e=[]){super(),this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(t).append(e)}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"glsl":{const s=new Ii(e);!this.effectMode&&s.has.transition&&(this.effectMode="transition"),this.material=s;break}case"glslSrc":{e?Ne.text.load(e).then(s=>this.glsl=s):this.glsl="";break}}}_treeEnter(t){t.on("processing",this._onProcessing),t.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(t),this.viewport2.setTree(t)}_treeExit(t){t.off("processing",this._onProcessing),t.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){if(this.canProcess())switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(t){if(!this.canProcess()||!this.isInsideTimeRange())return;const e=this._tree?.renderStack;if(e)switch(this._effectMode){case"transition":t.equal(this._previousSibling)?(this._previousSibling=void 0,e.push(this)):t.equal(this._nextSibling)&&(this._nextSibling=void 0,e.push(this));break}}_processParent(){const t=this._tree?.renderStack;if(!t)return;const e=t.currentCall?.parentCall;if(!e)return;const A=e.calls;let i,s;A.forEach((n,o)=>{(n.renderable.equal(this._parent)||n.renderable.parent?.equal(this._parent))&&(i=i??o,s=o)}),!(i===void 0||s===void 0)&&(A.splice(s+1,0,t.createCall(this)),A.splice(i,0,t.createCall(this)))}_processChildren(){this._children.length&&(super.emit("process"),this._tree?.renderStack.push(this))}_onProcess(t=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(t);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(t){const e=this._tree?.getCurrentViewport();e&&this.apply(t,e,{redraw:!0})}_renderTransition(t){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(t,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(t),t.clear();else{const e=this._renderViewport;this._renderViewport=void 0,e&&(e.activate(t),t.clear(),this.viewport1.texture.activate(t,0),this.viewport2.texture.activate(t,1),this.apply(t,e,{from:this.viewport1,to:this.viewport2}),t.texture.unbind(0),t.texture.unbind(1))}}_renderParentOrChildren(t){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(t),t.clear();else{const e=this._renderViewport;this._renderViewport=void 0,e&&(this.viewport1.activate(t),this.apply(t,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),e.activate(t),this.viewport1.texture.activate(t,0),gt.draw(t))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const t=this._parent.getRect();if(t)return[t.left/this.viewport1.width,t.top/this.viewport1.height,t.width/this.viewport1.width,t.height/this.viewport1.height]}}_render(t){switch(this._effectMode){case"before":this._renderBefore(t);break;case"transition":this._renderTransition(t);break;case"parent":case"children":default:this._renderParentOrChildren(t);break}this._renderId++}apply(t,e,A){this.material&&(A?.redraw?e.redraw(t,()=>{gt.draw(t,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:e.width/e.height})}):gt.draw(t,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:A?.from?A.from.width/A.from.height:0}))}},Qi([w({protected:!0})],h.Effect.prototype,"material",2),Qi([w()],h.Effect.prototype,"effectMode",2),Qi([w()],h.Effect.prototype,"glsl",2),Qi([w()],h.Effect.prototype,"glslSrc",2),h.Effect=Qi([st("Effect")],h.Effect);var Ia=Object.defineProperty,ph=Object.getOwnPropertyDescriptor,Eh=(r,t,e)=>t in r?Ia(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ve=(r,t,e,A)=>{for(var i=A>1?void 0:A?ph(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&Ia(t,e,i),i},Bh=(r,t,e)=>Eh(r,t+"",e);h.ColorAdjustEffect=class extends h.Effect{constructor(t,e=[]){super(),this.setProperties(t).append(e)}apply(t,e){e.redraw(t,()=>{gt.draw(t,h.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Bh(h.ColorAdjustEffect,"material",new Ct({vert:`precision mediump float;
114
+ }`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}class gt extends gr{static _instance;static get instance(){return this._instance??=new this}static draw(t,e=pi.instance,A){this.instance.draw(t,e,A)}constructor(){super({vertexAttributes:{position:new le({buffer:new Ye({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new le({buffer:new Ye({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new UA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}class th extends gr{positionBuffer;uvBuffer;constructor(){const t=new Ye({data:new Float32Array,dynamic:!0}),e=new Ye({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new le({buffer:t,size:2,normalized:!1,type:"float"}),uv:new le({buffer:e,size:2,normalized:!1,type:"float"})},indexBuffer:new UA({data:new Uint16Array,dynamic:!0})}),this.positionBuffer=t,this.uvBuffer=e}}var eh=Object.defineProperty,NA=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&eh(t,e,i),i};class Dt extends Je{static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}_isPowerOfTwo=!1;_needsUpload=!1;get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}constructor(t){super(),this.source=t,this._updateSize()}_glTextureOptions(t,e){let A=this.wrapMode;return t.version===1&&!this._isPowerOfTwo&&(A="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:A,...e}}_glTexture(t,e){return t.getRelated(this,()=>t.texture.create(this._glTextureOptions(t,e)))}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=ps(this.realWidth)&&ps(this.realHeight),this.requestUpload()}_updateSize(){const t=this.source;"pixels"in t?(this.width=t.width/this.pixelRatio,this.height=t.height/this.pixelRatio):(this.width=Number(t.naturalWidth||t.videoWidth||t.width||0)/this.pixelRatio,this.height=Number(t.naturalHeight||t.videoHeight||t.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(t,e){return this._needsUpload&&this.valid?(this._needsUpload=!1,t.texture.update(this._glTexture(t,e),this._glTextureOptions(t,e)),!0):!1}activate(t,e=0){return this.valid?(t.texture.bind({target:"texture_2d",value:this._glTexture(t,{location:e}),location:e}),this.upload(t,{location:e}),!0):!1}inactivate(t){t.texture.unbind(this._glTexture(t))}free(){Do&&this.source instanceof ImageBitmap&&this.source.close()}}NA([w({protected:!0})],Dt.prototype,"source"),NA([w({fallback:0})],Dt.prototype,"width"),NA([w({fallback:0})],Dt.prototype,"height"),NA([w({fallback:"linear"})],Dt.prototype,"filterMode"),NA([w({fallback:"clamp_to_edge"})],Dt.prototype,"wrapMode"),NA([w({fallback:1})],Dt.prototype,"pixelRatio");class fr extends Je{frames;constructor(t){super();let e;if(Array.isArray(t))e=t;else if(t instanceof Dt)e=[{texture:t,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=e,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((t,e)=>e.duration+t,0),this}free(){this.frames.forEach(t=>{t.texture.free()})}}var Ah=Object.defineProperty,ih=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&Ah(t,e,i),i};class Ei extends Dt{constructor(t=document.createElement("canvas")){super(t)}_updateProperty(t,e,A,i){switch(t){case"width":this.source.width=Math.max(1,Math.ceil(e*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(e*this.pixelRatio));break}super._updateProperty(t,e,A,i)}}ih([w({fallback:2})],Ei.prototype,"pixelRatio");class ca extends Dt{static _cached=new Map;static get(t){const e=new ve(t),A=e.toHex();let i=this._cached.get(A);return i||(i=new Dt({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])}),this._cached.set(A,i)),i}constructor(t){const e=new ve(t);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}class dr extends Dt{static test(t){return ci(t)}static linearGradient(t,e,A){e=e||1,A=A||1;const i=document.createElement("canvas");i.width=e,i.height=A;const s=i.getContext("2d");if(!s)throw new Error("Failed to parse linear gradient, get canvas context is null.");let{angle:n=0,stops:o}=t;n-=Math.PI/2;const a=e/2,l=A/2,u=Math.sqrt(e*e+A*A)/2,c=a+u*Math.cos(n+Math.PI),g=l+u*Math.sin(n+Math.PI),f=a+u*Math.cos(n),d=l+u*Math.sin(n),B=s.createLinearGradient(c,g,f,d);o.forEach(F=>{B.addColorStop(F.offset,F.color)}),s.fillStyle=B,s.fillRect(0,0,i.width,i.height);const I=s.getImageData(0,0,i.width,i.height);return{width:I.width,height:I.height,pixels:new Uint8Array(I.data.buffer)}}constructor(t,e,A){super(dr.linearGradient(t,e,A))}}function rh(r){return{autoLoad:!!(r?.autoLoad??!0),useBitmap:!!(r?.useBitmap??!0)&&Bs,crossorigin:r?.crossorigin??null}}class sh extends Dt{bitmap;useBitmap;preserveBitmap=!1;_loadSource;_loadBitmap;constructor(t,e){const A=rh(e);super(t);const i=t.src,s=i.includes(".svg")||i.startsWith("data:image/svg+xml");this.useBitmap=A.useBitmap&&!s,A.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(t=>{this._loadSource=void 0;const e=this.source,A=()=>{e.onload=null,e.onerror=null},i=()=>{A(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>t(this)):t(this)},s=n=>{A(),console.warn(`Failed to load ImageTexture, src: ${e.src}`,n),this.emit("error",n),t(this)};e.complete&&e.src?i():(e.onload=i,e.onerror=s)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Bs)return Promise.resolve(this);const t=this.source,e=!t.crossOrigin||t.crossOrigin==="anonymous";return this._loadBitmap=fetch(t.src,{mode:e?"cors":"no-cors"}).then(A=>A.blob()).then(A=>createImageBitmap(A,0,0,t.width,t.height,{premultiplyAlpha:"premultiply"})).then(A=>(this.bitmap=A,this.requestUpload(),this._loadBitmap=void 0,this)).catch(A=>(console.warn("Failed to genBitmap",A),this)),this._loadBitmap}_glTextureOptions(t){return{...super._glTextureOptions(t),value:this.bitmap??this.source}}upload(t){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const A=this.source;if(di&&A instanceof HTMLImageElement&&(!A.complete||A.naturalWidth===0))return!1}const e=super.upload(t);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),e}}class Ms extends Dt{constructor(t,e=1,A=1){const i={width:e,height:A,pixels:null};t&&(ArrayBuffer.isView(t)?i.pixels=new Uint8Array(t.buffer):i.pixels=new Uint8Array(t)),super(i)}_updateProperty(t,e,A,i){switch(t){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(t,e,A,i)}}var nh=Object.defineProperty,ha=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&nh(t,e,i),i};function oh(r){return{autoLoad:!!(r?.autoLoad??!0),autoPlay:!!(r?.autoPlay??!1),fps:Number(r?.fps??0),crossorigin:r?.crossorigin??null,loop:!!(r?.loop??!1),muted:!!(r?.muted??!1),playsinline:!!(r?.playsinline??!0)}}const Rs=class xu extends Dt{static mimeTypes=new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}));get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(t){this.source.currentTime=t}_spf=0;_autoPlay=!1;_sourceLoad;_nextTime=0;_connected=!1;_requestId;_resolve;_reject;constructor(t,e){const A=oh(e);if(!xo(t)){typeof t=="string"&&(t=[t]);const i=t[0].src||t[0],s=document.createElement("video");A.autoLoad&&s.setAttribute("preload","auto"),A.playsinline&&(s.setAttribute("webkit-playsinline",""),s.setAttribute("playsinline","")),A.muted&&(s.setAttribute("muted",""),s.muted=!0),A.loop&&s.setAttribute("loop",""),A.autoPlay&&s.setAttribute("autoplay",""),Po(s,i,A.crossorigin);for(let n=0;n<t.length;++n){let{src:o,mime:a}=t[n];if(o=o||t[n],o.startsWith("data:"))a=o.slice(5,o.indexOf(";"));else if(!o.startsWith("blob:")){const u=o.split("?").shift().toLowerCase(),c=u.slice(u.lastIndexOf(".")+1);a=a||xu.mimeTypes.get(c)||`video/${c}`}const l=document.createElement("source");l.src=o,a&&(l.type=a),s.appendChild(l)}t=s}super(t),this.fps=A.fps,this._autoPlay=A.autoPlay,A.autoPlay&&this.load(),this._setupAutoUpdate()}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"fps":this._spf=e?Math.floor(1e3/e):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_onPlayStart=()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()};_onPlayStop=()=>{this._setupAutoUpdate()};_onCanPlay=()=>{const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!e&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&t.play()};_onError=t=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=void 0,this._resolve=void 0)};_onSeeked=()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)};_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(Kt.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(Kt.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Kt.off(this.requestUpload),this._connected=!1,this._nextTime=0))}_videoFrameRequestCallback=()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)};requestUpload=()=>{const t=Math.floor(Kt.elapsed*this.source.playbackRate);this._nextTime-=t,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)};async load(){if(!this._sourceLoad){const t=this.source;(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((e,A)=>{this.valid?(this._sourceLoad=void 0,e(this)):(this._resolve=e,this._reject=A,t.load())})}return this._sourceLoad}free(){this._setupAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load())}};ha([w({protected:!0,fallback:!0})],Rs.prototype,"autoUpdate"),ha([w({protected:!0,fallback:0})],Rs.prototype,"fps");let ga=Rs;class Ps extends Ms{}class fa extends Array{front=[];back=[];get internal(){return[...this.front,...this,...this.back]}constructor(...t){super(),this.set(t)}set(t){return this.front.length=0,this.length=0,this.back.length=0,t.forEach(e=>{switch(e.internalMode){case"front":this.front.push(e);break;case"default":this.push(e);break;case"back":this.back.push(e);break}}),this}getInternal(t){switch(t){case"front":return this.front;case"default":return this;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${t}`)}}toJSON(){return[...this]}}var ah=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,AA=(r,t,e,A)=>{for(var i=A>1?void 0:A?lh(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&ah(t,e,i),i};const da={};function uh(r){let t=da[r]??0;return t++,da[r]=t,t}h.Node=class extends tA{meta={};_readyed=!1;constructor(t,e=[]){super(),this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.is}:${uh(this.is)}`,...t}).append(e),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(t){if(t){const{meta:e,...A}=t;if(e)for(const i in e)this.meta[i]=e[i];super.setProperties(A)}return this}getName(){return this.name}setName(t){return this.name=t,this}_tree;get tree(){return this.getTree()}set tree(t){this.setTree(t)}getTree(){return this._tree}getViewport(){return this._tree?.getCurrentViewport()}getWindow(){return this._tree?.root}isInsideTree(){return!!this._tree}setTree(t){const e=this._tree;if(!t?.equal(e)){e&&this.emit("treeExit",e),this._tree=t,t&&this.emit("treeEnter",t);const A=this._children.internal;for(let i=A.length,s=0;s<i;s++){const n=A[s];!t&&this.emit("childExitingTree",n),n.setTree(t),t&&this.emit("childEnteredTree",n)}t&&(this.emit("treePostEnter",t),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}log(...t){this._tree?.log(...t)}_parent;get parent(){return this._parent}set parent(t){this.setParent(t)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(t){if(!this._parent?.equal(t)){const e=this._parent;e&&this.emit("unparented",e),this._parent=t,t&&this.emit("parented",t),this.setTree(t?._tree)}return this}_children=new fa;get children(){return this._children}set children(t){t instanceof fa?this._children=t:this._children.set(t)}getChild(t=0){return this._children[t]}get siblingIndex(){return this.getIndex()}set siblingIndex(t){this._parent?.moveChild(this,t)}get previousSibling(){return this._parent?.children[this.getIndex()-1]}get nextSibling(){return this._parent?.children[this.getIndex()+1]}get firstSibling(){return this._parent?.children[0]}get lastSibling(){const t=this._parent?.children;return t?t[t.length-1]:void 0}canProcess(){if(!this._tree)return!1;switch(this.processMode){case"inherit":return this._parent?.canProcess()??!0;case"pausable":return!this._tree.processPaused;case"when_paused":return this._tree.processPaused;case"always":return!0;case"disabled":default:return!1}}canRender(){if(!this._tree)return!1;switch(this.renderMode){case"inherit":return this._parent?.canRender()??!0;case"always":return!0;case"disabled":default:return!1}}_updateProperty(t,e,A,i){super._updateProperty(t,e,A,i)}_onTreeEnter(t){this._treeEnter(t),this.emit("treeEntered",t)}_onTreeExit(t){this.emit("treeExiting",t),this._treeExit(t),this.emit("treeExited",t)}_onParented(t){this._parented(t)}_onUnparented(t){this._unparented(t)}_onReady(){this._ready()}_onProcess(t=0){const e=this._tree,A=this.canRender(),i=this.canProcess(),s=[],n=[];this._children.internal.forEach(a=>{switch(a.processSortMode){case"default":n.push(a);break;case"parent_before":s.push(a);break}}),s.forEach(a=>{a.emit("process",t)}),i&&(e?.emit("nodeProcessing",this),this.emit("processing",t),this._process(t));let o;if(A){const a=e.renderStack.push(this);o=e.renderStack.currentCall,e.renderStack.currentCall=a}if(this.mask instanceof h.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const a=this.getNode("__$mask");a&&this.removeChild(a)}n.forEach(a=>{a.emit("process",t)}),A&&(e.renderStack.currentCall=o),i&&(this.emit("processed",t),e?.emit("nodeProcessed",this))}render(t,e){const A=this.mask;A&&(t.flush(),t.mask.push(this,A)),this._render(t),e?.(),A&&(t.flush(),t.mask.pop(this))}input(t,e){const A=this._children.internal;for(let i=A.length-1;i>=0;i--)A[i].input(t,e);this._input(t,e)}getIndex(){return this._parent?.children.getInternal(this.internalMode).indexOf(this)??0}getNode(t){return this._children.internal.find(e=>e.name===t)}removeNode(t){this.getNode(t)?.remove()}addSibling(t){return this.equal(t)||!this.hasParent()||t.hasParent()?this:(t.internalMode=this.internalMode,this._parent.moveChild(t,this.getIndex()+1),this)}prepend(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this.moveChild(A,0)})}append(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this.appendChild(A)})}before(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this._parent?.moveChild(A,this.getIndex())})}after(...t){let e;Array.isArray(t[0])?e=t[0]:e=t,e.forEach(A=>{this._parent?.moveChild(A,this.getIndex()+1)})}insertBefore(t,e){return!e.hasParent()||!this.equal(e.parent)||this.moveChild(t,e.getIndex()),t}appendChild(t,e=t.internalMode){if(this.equal(t)||t.hasParent())return t;switch(e){case"front":this._children.front.push(t);break;case"default":this._children.push(t);break;case"back":this._children.back.push(t);break}return t.internalMode!==e&&(t.internalMode=e),t.setParent(this),this.emit("appendChild",t),t}moveChild(t,e,A=t.internalMode){if(this.equal(t)||t.hasParent()&&!this.equal(t.parent))return this;const i=this._children.getInternal(t.internalMode),s=i.indexOf(t),n=this._children.getInternal(A);return(t.internalMode!==A||e!==s)&&(s>-1&&i.splice(s,1),t.setParent(this),e>-1&&e<n.length?n.splice(e,0,t):n.push(t),s>-1?this.emit("moveChild",t,e,s):this.emit("appendChild",t)),t.internalMode!==A&&(t.internalMode=A),this}removeChild(t){const e=t.getIndex();return this.equal(t.parent)&&e>-1&&(this._children.getInternal(t.internalMode).splice(e,1),t.setParent(void 0),this.emit("removeChild",t,e)),t}removeChildren(){this._children.forEach(t=>this.removeChild(t))}remove(){this._parent?.removeChild(this)}forEachChild(t){return this._children.forEach(t),this}forEachDescendant(t){return this._children.forEach(e=>{t(e),e.forEachDescendant(t)}),this}forEachAncestor(t){const e=this.parent;return e&&(t(e),e.forEachAncestor(t)),this}_ready(){}_treeEnter(t){}_treeExit(t){}_parented(t){}_unparented(t){}_process(t){}_input(t,e){}_render(t){}clone(){return new this.constructor(this.toJSON(),this._children.internal)}toJSON(){return ui({...super.toJSON(),is:this.is,children:this._children.length?[...this._children.map(t=>t.toJSON())]:void 0,meta:Object.keys(this.meta).length?{...this.meta}:void 0})}static parse(t){if(Array.isArray(t))return t.map(o=>this.parse(o));const{is:e,props:A,children:i}=t,s=lr.get(e)??h.Node,n=new s(A);return i?.forEach(o=>n.appendChild(this.parse(o))),n}},AA([w({fallback:Io()})],h.Node.prototype,"id",2),AA([w({fallback:Io()})],h.Node.prototype,"name",2),AA([w({fallback:"inherit"})],h.Node.prototype,"processMode",2),AA([w({fallback:"default"})],h.Node.prototype,"processSortMode",2),AA([w({fallback:"inherit"})],h.Node.prototype,"renderMode",2),AA([w({fallback:"default"})],h.Node.prototype,"internalMode",2),AA([w({protected:!0})],h.Node.prototype,"mask",2),h.Node=AA([st("Node")],h.Node);var ch=Object.defineProperty,hh=Object.getOwnPropertyDescriptor,Bi=(r,t,e,A)=>{for(var i=A>1?void 0:A?hh(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&ch(t,e,i),i};h.TimelineNode=class extends h.Node{constructor(t,e=[]){super(),this.setProperties(t).append(e)}computedDuration=0;_currentTime=0;_startTime=0;get timeline(){return this._tree?.timeline}get timelineCurrentTime(){return this.timeline?.currentTime??0}get parentStartTime(){return this._parent?.startTime??0}get currentTime(){return Ke(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(t){this.delay=t-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?Ke(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const t=this._currentTime;return this.computedDuration?t>=0&&t<=this.computedDuration:t>=0}_updateCurrentTime(t=!1){if(t||!this.paused){const e=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=e?.computedDuration?Math.min(this._startTime+this.duration,e.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(t){super._process(t),this._updateCurrentTime()}},Bi([w({fallback:0})],h.TimelineNode.prototype,"delay",2),Bi([w({fallback:0})],h.TimelineNode.prototype,"duration",2),Bi([w({fallback:!1})],h.TimelineNode.prototype,"paused",2),Bi([w({protected:!0,fallback:!1})],h.TimelineNode.prototype,"insideTimeRange",2),h.TimelineNode=Bi([st("TimelineNode")],h.TimelineNode);var gh=Object.defineProperty,fh=Object.getOwnPropertyDescriptor,Ci=(r,t,e,A)=>{for(var i=A>1?void 0:A?fh(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&gh(t,e,i),i};h.Viewport=class extends h.Node{constructor(t=!1){super(),this.flipY=t,this._projection.flipY(t)}_projection=new Ho;_framebufferIndex=0;_framebuffers=[{texture:new Ps,needsUpload:!1},{texture:new Ps,needsUpload:!1}];get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(t){const{width:e,height:A}=this,{pixelRatio:i}=t;return this._framebuffers.forEach(s=>{const n=s.texture;n.width=e,n.height=A,n.pixelRatio=i,n.upload(t)}),{width:e,height:A,colorTextures:[this.texture._glTexture(t)]}}_glFramebuffer(t){return t.getRelated(this.framebuffer,()=>t.framebuffer.create(this._glFramebufferOptions(t)))}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height),this.emit("updateRect");break}}requestUpload(){this._framebuffers.forEach(t=>t.needsUpload=!0)}resize(t,e){this.width=t,this.height=e}upload(t){const e=this.framebuffer;return e.needsUpload&&this.valid?(e.needsUpload=!1,t.framebuffer.update(this._glFramebuffer(t),this._glFramebufferOptions(t)),!0):!1}activate(t){return this.valid?(t.flush(),this._tree?.setCurrentViewport(this),this.upload(t),t.framebuffer.bind(this._glFramebuffer(t)),!0):!1}redraw(t,e){if(this.valid){t.flush();const A=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(t),t.clear(),A.activate(t,0),e(),!0}return!1}activateWithCopy(t,e){this.resize(e.width,e.height),this.activate(t)&&(t.clear(),e.texture.activate(t,0),gt.draw(t,pi.instance,{sampler:0}))}render(t,e){const A=this._tree?.getCurrentViewport();this.activate(t),t.clear(),super.render(t,e),t.flush(),A?A.activate(t):(t.framebuffer.bind(null),this._tree?.setCurrentViewport(void 0))}getRect(){return new xs(this.x,this.y,this.width,this.height)}toProjectionArray(t=!1){return this._projection.toArray(t)}},Ci([w({fallback:0})],h.Viewport.prototype,"x",2),Ci([w({fallback:0})],h.Viewport.prototype,"y",2),Ci([w({fallback:0})],h.Viewport.prototype,"width",2),Ci([w({fallback:0})],h.Viewport.prototype,"height",2),h.Viewport=Ci([st("Viewport")],h.Viewport);var dh=Object.defineProperty,Ih=Object.getOwnPropertyDescriptor,Qi=(r,t,e,A)=>{for(var i=A>1?void 0:A?Ih(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&dh(t,e,i),i};h.Effect=class extends h.TimelineNode{material;get _effectMode(){return this.effectMode??"parent"}viewport1=new h.Viewport;viewport2=new h.Viewport;_renderId=0;_renderViewport;_previousSibling;_nextSibling;constructor(t,e=[]){super(),this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(t).append(e)}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"glsl":{const s=new Ii(e);!this.effectMode&&s.has.transition&&(this.effectMode="transition"),this.material=s;break}case"glslSrc":{e?Ne.text.load(e).then(s=>this.glsl=s):this.glsl="";break}}}_treeEnter(t){t.on("processing",this._onProcessing),t.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(t),this.viewport2.setTree(t)}_treeExit(t){t.off("processing",this._onProcessing),t.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){if(this.canProcess())switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(t){if(!this.canProcess()||!this.isInsideTimeRange())return;const e=this._tree?.renderStack;if(e)switch(this._effectMode){case"transition":t.equal(this._previousSibling)?(this._previousSibling=void 0,e.push(this)):t.equal(this._nextSibling)&&(this._nextSibling=void 0,e.push(this));break}}_processParent(){const t=this._tree?.renderStack;if(!t)return;const e=t.currentCall?.parentCall;if(!e)return;const A=e.calls;let i,s;A.forEach((n,o)=>{(n.renderable.equal(this._parent)||n.renderable.parent?.equal(this._parent))&&(i=i??o,s=o)}),!(i===void 0||s===void 0)&&(A.splice(s+1,0,t.createCall(this)),A.splice(i,0,t.createCall(this)))}_processChildren(){this._children.length&&(super.emit("process"),this._tree?.renderStack.push(this))}_onProcess(t=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(t);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(t){const e=this._tree?.getCurrentViewport();e&&this.apply(t,e,{redraw:!0})}_renderTransition(t){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(t,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(t),t.clear();else{const e=this._renderViewport;this._renderViewport=void 0,e&&(e.activate(t),t.clear(),this.viewport1.texture.activate(t,0),this.viewport2.texture.activate(t,1),this.apply(t,e,{from:this.viewport1,to:this.viewport2}),t.texture.unbind(0),t.texture.unbind(1))}}_renderParentOrChildren(t){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(t),t.clear();else{const e=this._renderViewport;this._renderViewport=void 0,e&&(this.viewport1.activate(t),this.apply(t,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),e.activate(t),this.viewport1.texture.activate(t,0),gt.draw(t))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const t=this._parent.getRect();if(t)return[t.left/this.viewport1.width,t.top/this.viewport1.height,t.width/this.viewport1.width,t.height/this.viewport1.height]}}_render(t){switch(this._effectMode){case"before":this._renderBefore(t);break;case"transition":this._renderTransition(t);break;case"parent":case"children":default:this._renderParentOrChildren(t);break}this._renderId++}apply(t,e,A){this.material&&(A?.redraw?e.redraw(t,()=>{gt.draw(t,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:e.width/e.height})}):gt.draw(t,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:A?.from?A.from.width/A.from.height:0}))}},Qi([w({protected:!0})],h.Effect.prototype,"material",2),Qi([w()],h.Effect.prototype,"effectMode",2),Qi([w()],h.Effect.prototype,"glsl",2),Qi([w()],h.Effect.prototype,"glslSrc",2),h.Effect=Qi([st("Effect")],h.Effect);var Ia=Object.defineProperty,ph=Object.getOwnPropertyDescriptor,Eh=(r,t,e)=>t in r?Ia(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ve=(r,t,e,A)=>{for(var i=A>1?void 0:A?ph(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&Ia(t,e,i),i},Bh=(r,t,e)=>Eh(r,t+"",e);h.ColorAdjustEffect=class extends h.Effect{constructor(t,e=[]){super(),this.setProperties(t).append(e)}apply(t,e){e.redraw(t,()=>{gt.draw(t,h.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Bh(h.ColorAdjustEffect,"material",new Ct({vert:`precision mediump float;
115
115
  attribute vec2 position;
116
116
  attribute vec2 uv;
117
117
  varying vec2 vUv;
@@ -274,7 +274,7 @@ void main(void) {
274
274
  }
275
275
  }
276
276
  }`})),Ns([w()],h.ColorReplaceEffect.prototype,"colors",2),Ns([w()],h.ColorReplaceEffect.prototype,"epsilon",2),h.ColorReplaceEffect=Ns([st("ColorReplaceEffect")],h.ColorReplaceEffect);function Mh(r,t,e=2){const A=t&&t.length,i=A?t[0]*e:r.length;let s=ya(r,0,i,e,!0);const n=[];if(!s||s.next===s.prev)return n;let o,a,l;if(A&&(s=Nh(r,t,s,e)),r.length>80*e){o=1/0,a=1/0;let u=-1/0,c=-1/0;for(let g=e;g<i;g+=e){const f=r[g],d=r[g+1];f<o&&(o=f),d<a&&(a=d),f>u&&(u=f),d>c&&(c=d)}l=Math.max(u-o,c-a),l=l!==0?32767/l:0}return mi(s,n,e,o,a,l,0),n}function ya(r,t,e,A,i){let s;if(i===Wh(r,t,e,A)>0)for(let n=t;n<e;n+=A)s=va(n/A|0,r[n],r[n+1],s);else for(let n=e-A;n>=t;n-=A)s=va(n/A|0,r[n],r[n+1],s);return s&&TA(s,s.next)&&(_i(s),s=s.next),s}function QA(r,t){if(!r)return r;t||(t=r);let e=r,A;do if(A=!1,!e.steiner&&(TA(e,e.next)||Qt(e.prev,e,e.next)===0)){if(_i(e),e=t=e.prev,e===e.next)break;A=!0}else e=e.next;while(A||e!==t);return t}function mi(r,t,e,A,i,s,n){if(!r)return;!n&&s&&Hh(r,A,i,s);let o=r;for(;r.prev!==r.next;){const a=r.prev,l=r.next;if(s?Ph(r,A,i,s):Rh(r)){t.push(a.i,r.i,l.i),_i(r),r=l.next,o=l.next;continue}if(r=l,r===o){n?n===1?(r=kh(QA(r),t),mi(r,t,e,A,i,s,2)):n===2&&Uh(r,t,e,A,i,s):mi(QA(r),t,e,A,i,s,1);break}}}function Rh(r){const t=r.prev,e=r,A=r.next;if(Qt(t,e,A)>=0)return!1;const i=t.x,s=e.x,n=A.x,o=t.y,a=e.y,l=A.y,u=Math.min(i,s,n),c=Math.min(o,a,l),g=Math.max(i,s,n),f=Math.max(o,a,l);let d=A.next;for(;d!==t;){if(d.x>=u&&d.x<=g&&d.y>=c&&d.y<=f&&wi(i,o,s,a,n,l,d.x,d.y)&&Qt(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Ph(r,t,e,A){const i=r.prev,s=r,n=r.next;if(Qt(i,s,n)>=0)return!1;const o=i.x,a=s.x,l=n.x,u=i.y,c=s.y,g=n.y,f=Math.min(o,a,l),d=Math.min(u,c,g),B=Math.max(o,a,l),I=Math.max(u,c,g),F=Ts(f,d,t,e,A),b=Ts(B,I,t,e,A);let y=r.prevZ,_=r.nextZ;for(;y&&y.z>=F&&_&&_.z<=b;){if(y.x>=f&&y.x<=B&&y.y>=d&&y.y<=I&&y!==i&&y!==n&&wi(o,u,a,c,l,g,y.x,y.y)&&Qt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=f&&_.x<=B&&_.y>=d&&_.y<=I&&_!==i&&_!==n&&wi(o,u,a,c,l,g,_.x,_.y)&&Qt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=F;){if(y.x>=f&&y.x<=B&&y.y>=d&&y.y<=I&&y!==i&&y!==n&&wi(o,u,a,c,l,g,y.x,y.y)&&Qt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=b;){if(_.x>=f&&_.x<=B&&_.y>=d&&_.y<=I&&_!==i&&_!==n&&wi(o,u,a,c,l,g,_.x,_.y)&&Qt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function kh(r,t){let e=r;do{const A=e.prev,i=e.next.next;!TA(A,i)&&ma(A,e,e.next,i)&&vi(A,i)&&vi(i,A)&&(t.push(A.i,e.i,i.i),_i(e),_i(e.next),e=r=i),e=e.next}while(e!==r);return QA(e)}function Uh(r,t,e,A,i,s){let n=r;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&Yh(n,o)){let a=wa(n,o);n=QA(n,n.next),a=QA(a,a.next),mi(n,t,e,A,i,s,0),mi(a,t,e,A,i,s,0);return}o=o.next}n=n.next}while(n!==r)}function Nh(r,t,e,A){const i=[];for(let s=0,n=t.length;s<n;s++){const o=t[s]*A,a=s<n-1?t[s+1]*A:r.length,l=ya(r,o,a,A,!1);l===l.next&&(l.steiner=!0),i.push(Kh(l))}i.sort(Th);for(let s=0;s<i.length;s++)e=Lh(i[s],e);return e}function Th(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const A=(r.next.y-r.y)/(r.next.x-r.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=A-i}return e}function Lh(r,t){const e=Gh(r,t);if(!e)return t;const A=wa(e,r);return QA(A,A.next),QA(e,e.next)}function Gh(r,t){let e=t;const A=r.x,i=r.y;let s=-1/0,n;if(TA(r,e))return e;do{if(TA(r,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const c=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(c<=A&&c>s&&(s=c,n=e.x<e.next.x?e:e.next,c===A))return n}e=e.next}while(e!==t);if(!n)return null;const o=n,a=n.x,l=n.y;let u=1/0;e=n;do{if(A>=e.x&&e.x>=a&&A!==e.x&&Da(i<l?A:s,i,a,l,i<l?s:A,i,e.x,e.y)){const c=Math.abs(i-e.y)/(A-e.x);vi(e,r)&&(c<u||c===u&&(e.x>n.x||e.x===n.x&&Oh(n,e)))&&(n=e,u=c)}e=e.next}while(e!==o);return n}function Oh(r,t){return Qt(r.prev,r,t.prev)<0&&Qt(t.next,r,r.next)<0}function Hh(r,t,e,A){let i=r;do i.z===0&&(i.z=Ts(i.x,i.y,t,e,A)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Jh(i)}function Jh(r){let t,e=1;do{let A=r,i;r=null;let s=null;for(t=0;A;){t++;let n=A,o=0;for(let l=0;l<e&&(o++,n=n.nextZ,!!n);l++);let a=e;for(;o>0||a>0&&n;)o!==0&&(a===0||!n||A.z<=n.z)?(i=A,A=A.nextZ,o--):(i=n,n=n.nextZ,a--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;A=n}s.nextZ=null,e*=2}while(t>1);return r}function Ts(r,t,e,A,i){return r=(r-e)*i|0,t=(t-A)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Kh(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Da(r,t,e,A,i,s,n,o){return(i-n)*(t-o)>=(r-n)*(s-o)&&(r-n)*(A-o)>=(e-n)*(t-o)&&(e-n)*(s-o)>=(i-n)*(A-o)}function wi(r,t,e,A,i,s,n,o){return!(r===n&&t===o)&&Da(r,t,e,A,i,s,n,o)}function Yh(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Vh(r,t)&&(vi(r,t)&&vi(t,r)&&zh(r,t)&&(Qt(r.prev,r,t.prev)||Qt(r,t.prev,t))||TA(r,t)&&Qt(r.prev,r,r.next)>0&&Qt(t.prev,t,t.next)>0)}function Qt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function TA(r,t){return r.x===t.x&&r.y===t.y}function ma(r,t,e,A){const i=pr(Qt(r,t,e)),s=pr(Qt(r,t,A)),n=pr(Qt(e,A,r)),o=pr(Qt(e,A,t));return!!(i!==s&&n!==o||i===0&&Ir(r,e,t)||s===0&&Ir(r,A,t)||n===0&&Ir(e,r,A)||o===0&&Ir(e,t,A))}function Ir(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function pr(r){return r>0?1:r<0?-1:0}function Vh(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&ma(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function vi(r,t){return Qt(r.prev,r,r.next)<0?Qt(r,t,r.next)>=0&&Qt(r,r.prev,t)>=0:Qt(r,t,r.prev)<0||Qt(r,r.next,t)<0}function zh(r,t){let e=r,A=!1;const i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(A=!A),e=e.next;while(e!==r);return A}function wa(r,t){const e=Ls(r.i,r.x,r.y),A=Ls(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,A.next=e,e.prev=A,s.next=A,A.prev=s,A}function va(r,t,e,A){const i=Ls(r,t,e);return A?(i.next=A.next,i.prev=A,A.next.prev=i,A.next=i):(i.prev=i,i.next=i),i}function _i(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Ls(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Wh(r,t,e,A){let i=0;for(let s=t,n=e-A;s<e;s+=A)i+=(r[n]-r[s])*(r[s+1]+r[n+1]),n=s;return i}function qh(r,t,e,A={}){const{radius:i=1}=A;r.moveTo(t,e),r.arc(t,e,i,0,Math.PI*2)}const Xh={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Gs(r,t){const{fill:e="#000",stroke:A="none",strokeWidth:i=A==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:n="miter",strokeMiterlimit:o=0,strokeDasharray:a=[],strokeDashoffset:l=0,shadowOffsetX:u=0,shadowOffsetY:c=0,shadowBlur:g=0,shadowColor:f="rgba(0, 0, 0, 0)"}=t;r.fillStyle=e,r.strokeStyle=A,r.lineWidth=i,r.lineCap=s,r.lineJoin=Xh[n],r.miterLimit=o,r.setLineDash(a),r.lineDashOffset=l,r.shadowOffsetX=u,r.shadowOffsetY=c,r.shadowBlur=g,r.shadowColor=f}class O{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new O(1/0,1/0)}static get MIN(){return new O(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const A=-t/180*Math.PI,i=this.x-e.x,s=-(this.y-e.y),n=Math.sin(A),o=Math.cos(A);return this.set(e.x+(i*o-s*n),e.y-(i*n+s*o)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,A=this.y-t.y;return e*e+A*A}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,A={x:0,y:0}){const i=t<0?A.x-this.x+A.x:this.x,s=e<0?A.y-this.y+A.y:this.y;return this.x=i*Math.abs(t),this.y=s*Math.abs(e),this}skew(t,e=0,A={x:0,y:0}){const i=this.x-A.x,s=this.y-A.y;return this.x=A.x+(i+Math.tan(t)*s),this.y=A.y+(s+Math.tan(e)*i),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,A){return this.x=t.x+(e.x-t.x)*A,this.y=t.y+(e.y-t.y)*A,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,A=this.y,i=t.elements;return this.x=i[0]*e+i[3]*A+i[6],this.y=i[1]*e+i[4]*A+i[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new O(this.x,this.y)}}class ut{constructor(t=0,e=0,A=0,i=0){this.left=t,this.top=e,this.width=A,this.height=i}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new O((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new ut;if(t.length===1)return t[0].clone();const e=t[0],A=t.slice(1).reduce((i,s)=>(i.left=Math.min(i.left,s.left),i.top=Math.min(i.top,s.top),i.right=Math.max(i.right,s.right),i.bottom=Math.max(i.bottom,s.bottom),i),{left:e?.left??0,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0});return new ut(A.left,A.top,A.right-A.left,A.bottom-A.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new ut(this.left,this.top,this.width,this.height)}}class Lt{elements=[];constructor(t=1,e=0,A=0,i=0,s=1,n=0,o=0,a=0,l=1){this.set(t,e,A,i,s,n,o,a,l)}set(t,e,A,i,s,n,o,a,l){const u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=s,u[5]=a,u[6]=A,u[7]=n,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,A=t.elements;return e[0]=A[0],e[1]=A[1],e[2]=A[2],e[3]=A[3],e[4]=A[4],e[5]=A[5],e[6]=A[6],e[7]=A[7],e[8]=A[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const A=t.elements,i=e.elements,s=this.elements,n=A[0],o=A[3],a=A[6],l=A[1],u=A[4],c=A[7],g=A[2],f=A[5],d=A[8],B=i[0],I=i[3],F=i[6],b=i[1],y=i[4],_=i[7],Q=i[2],D=i[5],S=i[8];return s[0]=n*B+o*b+a*Q,s[3]=n*I+o*y+a*D,s[6]=n*F+o*_+a*S,s[1]=l*B+u*b+c*Q,s[4]=l*I+u*y+c*D,s[7]=l*F+u*_+c*S,s[2]=g*B+f*b+d*Q,s[5]=g*I+f*y+d*D,s[8]=g*F+f*_+d*S,this}invert(){const t=this.elements,e=t[0],A=t[1],i=t[2],s=t[3],n=t[4],o=t[5],a=t[6],l=t[7],u=t[8],c=u*n-o*l,g=o*a-u*s,f=l*s-n*a,d=e*c+A*g+i*f;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);const B=1/d;return t[0]=c*B,t[1]=(i*l-u*A)*B,t[2]=(o*A-i*n)*B,t[3]=g*B,t[4]=(u*e-i*a)*B,t[5]=(i*s-o*e)*B,t[6]=f*B,t[7]=(A*a-l*e)*B,t[8]=(n*e-A*s)*B,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(Os.makeScale(t,e)),this}rotate(t){return this.premultiply(Os.makeRotation(-t)),this}translate(t,e){return this.premultiply(Os.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),A=Math.sin(t);return this.set(e,-A,0,A,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let A=0;A<9;A++)this.elements[A]=t[A+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Os=new Lt;function _a(r,t,e,A){const i=r*e+t*A,s=Math.sqrt(r*r+t*t)*Math.sqrt(e*e+A*A);let n=Math.acos(Math.max(-1,Math.min(1,i/s)));return r*A-t*e<0&&(n=-n),n}function jh(r,t,e,A,i,s,n,o){if(t===0||e===0){r.lineTo(o.x,o.y);return}A=A*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const a=(n.x-o.x)/2,l=(n.y-o.y)/2,u=Math.cos(A)*a+Math.sin(A)*l,c=-Math.sin(A)*a+Math.cos(A)*l;let g=t*t,f=e*e;const d=u*u,B=c*c,I=d/g+B/f;if(I>1){const et=Math.sqrt(I);t=et*t,e=et*e,g=t*t,f=e*e}const F=g*B+f*d,b=(g*f-F)/F;let y=Math.sqrt(Math.max(0,b));i===s&&(y=-y);const _=y*t*c/e,Q=-y*e*u/t,D=Math.cos(A)*_-Math.sin(A)*Q+(n.x+o.x)/2,S=Math.sin(A)*_+Math.cos(A)*Q+(n.y+o.y)/2,M=_a(1,0,(u-_)/t,(c-Q)/e),V=_a((u-_)/t,(c-Q)/e,(-u-_)/t,(-c-Q)/e)%(Math.PI*2);r.ellipse(D,S,t,e,A,M,M+V,s===0)}const wt={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function be(r,t,e=0){let o=0,a=!0,l="",u="";const c=[];function g(I,F,b){const y=new SyntaxError(`Unexpected character "${I}" at index ${F}.`);throw y.partial=b,y}function f(){l!==""&&(u===""?c.push(Number(l)):c.push(Number(l)*10**Number(u))),l="",u=""}let d;const B=r.length;for(let I=0;I<B;I++){if(d=r[I],Array.isArray(t)&&t.includes(c.length%e)&&wt.FLAGS.test(d)){o=1,l=d,f();continue}if(o===0){if(wt.WHITESPACE.test(d))continue;if(wt.DIGIT.test(d)||wt.SIGN.test(d)){o=1,l=d;continue}if(wt.POINT.test(d)){o=2,l=d;continue}wt.COMMA.test(d)&&(a&&g(d,I,c),a=!0)}if(o===1){if(wt.DIGIT.test(d)){l+=d;continue}if(wt.POINT.test(d)){l+=d,o=2;continue}if(wt.EXP.test(d)){o=3;continue}wt.SIGN.test(d)&&l.length===1&&wt.SIGN.test(l[0])&&g(d,I,c)}if(o===2){if(wt.DIGIT.test(d)){l+=d;continue}if(wt.EXP.test(d)){o=3;continue}wt.POINT.test(d)&&l[l.length-1]==="."&&g(d,I,c)}if(o===3){if(wt.DIGIT.test(d)){u+=d;continue}if(wt.SIGN.test(d)){if(u===""){u+=d;continue}u.length===1&&wt.SIGN.test(u)&&g(d,I,c)}}wt.WHITESPACE.test(d)?(f(),o=0,a=!1):wt.COMMA.test(d)?(f(),o=0,a=!0):wt.SIGN.test(d)?(f(),o=1,l=d):wt.POINT.test(d)?(f(),o=2,l=d):g(d,I,c)}return f(),c}function LA(r,t){return r-(t-r)}function ba(r,t){const e=new O,A=new O;for(let i=0,s=r.length;i<s;i++){const n=r[i];if(n.type==="m"||n.type==="M")n.type==="m"?e.add(n):e.copy(n),t.moveTo(e.x,e.y),A.copy(e);else if(n.type==="h"||n.type==="H")n.type==="h"?e.x+=n.x:e.x=n.x,t.lineTo(e.x,e.y),A.copy(e);else if(n.type==="v"||n.type==="V")n.type==="v"?e.y+=n.y:e.y=n.y,t.lineTo(e.x,e.y),A.copy(e);else if(n.type==="l"||n.type==="L")n.type==="l"?e.add(n):e.copy(n),t.lineTo(e.x,e.y),A.copy(e);else if(n.type==="c"||n.type==="C")n.type==="c"?(t.bezierCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),A.x=e.x+n.x2,A.y=e.y+n.y2,e.add(n)):(t.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),A.x=n.x2,A.y=n.y2,e.copy(n));else if(n.type==="s"||n.type==="S")n.type==="s"?(t.bezierCurveTo(LA(e.x,A.x),LA(e.y,A.y),e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),A.x=e.x+n.x2,A.y=e.y+n.y2,e.add(n)):(t.bezierCurveTo(LA(e.x,A.x),LA(e.y,A.y),n.x2,n.y2,n.x,n.y),A.x=n.x2,A.y=n.y2,e.copy(n));else if(n.type==="q"||n.type==="Q")n.type==="q"?(t.quadraticCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x,e.y+n.y),A.x=e.x+n.x1,A.y=e.y+n.y1,e.add(n)):(t.quadraticCurveTo(n.x1,n.y1,n.x,n.y),A.x=n.x1,A.y=n.y1,e.copy(n));else if(n.type==="t"||n.type==="T"){const o=LA(e.x,A.x),a=LA(e.y,A.y);A.x=o,A.y=a,n.type==="t"?(t.quadraticCurveTo(o,a,e.x+n.x,e.y+n.y),e.add(n)):(t.quadraticCurveTo(o,a,n.x,n.y),e.copy(n))}else if(n.type==="a"||n.type==="A"){const o=e.clone();if(n.type==="a"){if(n.x===0&&n.y===0)continue;e.add(n)}else{if(e.equals(n))continue;e.copy(n)}A.copy(e),jh(t,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,o,e)}else n.type==="z"||n.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",n)}}function Zh(r){let t,e;const A=[];for(let i=0,s=r.length;i<s;i++){const n=r[i];switch(n.type){case"m":case"M":if(n.x.toFixed(4)===e?.x.toFixed(4)&&n.y.toFixed(4)===e?.y.toFixed(4))continue;A.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y},t={x:n.x,y:n.y};break;case"h":case"H":A.push(`${n.type} ${n.x}`),e={x:n.x,y:e?.y??0};break;case"v":case"V":A.push(`${n.type} ${n.y}`),e={x:e?.x??0,y:n.y};break;case"l":case"L":A.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"c":case"C":A.push(`${n.type} ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"s":case"S":A.push(`${n.type} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"q":case"Q":A.push(`${n.type} ${n.x1} ${n.y1} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"t":case"T":A.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"a":case"A":A.push(`${n.type} ${n.rx} ${n.ry} ${n.angle} ${n.largeArcFlag} ${n.sweepFlag} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"z":case"Z":A.push(n.type),t&&(e={x:t.x,y:t.y});break}}return A.join(" ")}const $h=/[a-df-z][^a-df-z]*/gi;function xa(r){const t=[],e=r.match($h);if(!e)return t;for(let A=0,i=e.length;A<i;A++){const s=e[A],n=s.charAt(0),o=s.slice(1).trim();let a;switch(n){case"m":case"M":a=be(o);for(let l=0,u=a.length;l<u;l+=2)l===0?t.push({type:n,x:a[l],y:a[l+1]}):t.push({type:n==="m"?"l":"L",x:a[l],y:a[l+1]});break;case"h":case"H":a=be(o);for(let l=0,u=a.length;l<u;l++)t.push({type:n,x:a[l]});break;case"v":case"V":a=be(o);for(let l=0,u=a.length;l<u;l++)t.push({type:n,y:a[l]});break;case"l":case"L":a=be(o);for(let l=0,u=a.length;l<u;l+=2)t.push({type:n,x:a[l],y:a[l+1]});break;case"c":case"C":a=be(o);for(let l=0,u=a.length;l<u;l+=6)t.push({type:n,x1:a[l],y1:a[l+1],x2:a[l+2],y2:a[l+3],x:a[l+4],y:a[l+5]});break;case"s":case"S":a=be(o);for(let l=0,u=a.length;l<u;l+=4)t.push({type:n,x2:a[l],y2:a[l+1],x:a[l+2],y:a[l+3]});break;case"q":case"Q":a=be(o);for(let l=0,u=a.length;l<u;l+=4)t.push({type:n,x1:a[l],y1:a[l+1],x:a[l+2],y:a[l+3]});break;case"t":case"T":a=be(o);for(let l=0,u=a.length;l<u;l+=2)t.push({type:n,x:a[l],y:a[l+1]});break;case"a":case"A":a=be(o,[3,4],7);for(let l=0,u=a.length;l<u;l+=7)t.push({type:n,rx:a[l],ry:a[l+1],angle:a[l+2],largeArcFlag:a[l+3],sweepFlag:a[l+4],x:a[l+5],y:a[l+6]});break;case"z":case"Z":t.push({type:n});break;default:console.warn(s)}}return t}const Fa="data:image/svg+xml;",Sa=`${Fa}base64,`,Ma=`${Fa}charset=utf8,`;function Hs(r){if(typeof r=="string"){let t;r.startsWith(Sa)?(r=r.substring(Sa.length,r.length),t=atob(r)):r.startsWith(Ma)?(r=r.substring(Ma.length,r.length),t=decodeURIComponent(r)):t=r;const e=new DOMParser().parseFromString(t,"text/xml"),A=e.querySelector("parsererror");if(A)throw new Error(`${A.textContent??"parser error"}
277
- ${t}`);return e.documentElement}else return r}const tg="px",eg=90,Ra=["mm","cm","in","pt","pc","px"],Pa={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function pt(r){let t="px";if(typeof r=="string")for(let A=0,i=Ra.length;A<i;A++){const s=Ra[A];if(r.endsWith(s)){t=s,r=r.substring(0,r.length-s.length);break}}let e;return e=Pa[t][tg],e<0&&(e=Pa[t].in*eg),e*Number.parseFloat(r)}const Ag=new Lt,Er=new Lt,ka=new Lt,Ua=new Lt;function ig(r,t,e){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const A=rg(r);return e.length>0&&A.premultiply(e[e.length-1]),t.copy(A),e.push(A),A}function rg(r){const t=new Lt,e=Ag;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&t.translate(pt(r.getAttribute("x")),pt(r.getAttribute("y"))),r.hasAttribute("transform")){const A=r.getAttribute("transform").split(")");for(let i=A.length-1;i>=0;i--){const s=A[i].trim();if(s==="")continue;const n=s.indexOf("("),o=s.length;if(n>0&&n<o){const a=s.slice(0,n),l=be(s.slice(n+1));switch(e.identity(),a){case"translate":if(l.length>=1){const u=l[0];let c=0;l.length>=2&&(c=l[1]),e.translate(u,c)}break;case"rotate":if(l.length>=1){let u=0,c=0,g=0;u=l[0]*Math.PI/180,l.length>=3&&(c=l[1],g=l[2]),Er.makeTranslation(-c,-g),ka.makeRotation(u),Ua.multiplyMatrices(ka,Er),Er.makeTranslation(c,g),e.multiplyMatrices(Er,Ua)}break;case"scale":l.length>=1&&e.scale(l[0],l[1]??l[0]);break;case"skewX":l.length===1&&e.set(1,Math.tan(l[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":l.length===1&&e.set(1,0,0,Math.tan(l[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":l.length===6&&e.set(l[0],l[2],l[4],l[1],l[3],l[5],0,0,1);break}}t.premultiply(e)}}return t}function sg(r){return new Mt().arc(pt(r.getAttribute("cx")||0),pt(r.getAttribute("cy")||0),pt(r.getAttribute("r")||0),0,Math.PI*2)}function ng(r,t){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let e=0;e<r.sheet.cssRules.length;e++){const A=r.sheet.cssRules[e];if(A.type!==1)continue;const i=A.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),s={};for(let n=A.style.length,o=0;o<n;o++){const a=A.style.item(o);s[a]=A.style.getPropertyValue(a)}for(let n=0;n<i.length;n++)t[i[n]]=Object.assign(t[i[n]]||{},{...s})}}function og(r){return new Mt().ellipse(pt(r.getAttribute("cx")||0),pt(r.getAttribute("cy")||0),pt(r.getAttribute("rx")||0),pt(r.getAttribute("ry")||0),0,0,Math.PI*2)}function ag(r){return new Mt().moveTo(pt(r.getAttribute("x1")||0),pt(r.getAttribute("y1")||0)).lineTo(pt(r.getAttribute("x2")||0),pt(r.getAttribute("y2")||0))}function lg(r){const t=new Mt,e=r.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const ug=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function cg(r){const t=new Mt;let e=0;return r.getAttribute("points")?.replace(ug,(A,i,s)=>{const n=pt(i),o=pt(s);return e===0?t.moveTo(n,o):t.lineTo(n,o),e++,A}),t.currentCurve.autoClose=!0,t}const hg=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function gg(r){const t=new Mt;let e=0;return r.getAttribute("points")?.replace(hg,(A,i,s)=>{const n=pt(i),o=pt(s);return e===0?t.moveTo(n,o):t.lineTo(n,o),e++,A}),t.currentCurve.autoClose=!1,t}function fg(r){const t=pt(r.getAttribute("x")||0),e=pt(r.getAttribute("y")||0),A=pt(r.getAttribute("rx")||r.getAttribute("ry")||0),i=pt(r.getAttribute("ry")||r.getAttribute("rx")||0),s=pt(r.getAttribute("width")),n=pt(r.getAttribute("height")),o=1-.551915024494,a=new Mt;return a.moveTo(t+A,e),a.lineTo(t+s-A,e),(A!==0||i!==0)&&a.bezierCurveTo(t+s-A*o,e,t+s,e+i*o,t+s,e+i),a.lineTo(t+s,e+n-i),(A!==0||i!==0)&&a.bezierCurveTo(t+s,e+n-i*o,t+s-A*o,e+n,t+s-A,e+n),a.lineTo(t+A,e+n),(A!==0||i!==0)&&a.bezierCurveTo(t+A*o,e+n,t,e+n-i*o,t,e+n-i),a.lineTo(t,e+i),(A!==0||i!==0)&&a.bezierCurveTo(t,e+i*o,t+A*o,e,t+A,e),a}function xe(r,t,e){t=Object.assign({},t);let A={};if(r.hasAttribute("class")){const l=r.getAttribute("class").split(/\s/).filter(Boolean).map(u=>u.trim());for(let u=0;u<l.length;u++)A=Object.assign(A,e[`.${l[u]}`])}r.hasAttribute("id")&&(A=Object.assign(A,e[`#${r.getAttribute("id")}`]));for(let l=r.style.length,u=0;u<l;u++){const c=r.style.item(u),g=r.style.getPropertyValue(c);t[c]=g,A[c]=g}function i(l,u,c=s){r.hasAttribute(l)&&(t[u]=c(r.getAttribute(l))),A[l]&&(t[u]=c(A[l]))}function s(l){return l.startsWith("url")&&console.warn("url access in attributes is not implemented."),l}function n(l){return Math.max(0,Math.min(1,pt(l)))}function o(l){return Math.max(0,pt(l))}function a(l){return l.split(" ").filter(u=>u!=="").map(u=>pt(u))}return i("fill","fill"),i("fill-opacity","fillOpacity",n),i("fill-rule","fillRule"),i("opacity","opacity",n),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",n),i("stroke-width","strokeWidth",o),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",o),i("stroke-dasharray","strokeDasharray",a),i("stroke-dashoffset","strokeDashoffset",pt),i("visibility","visibility"),t}function Js(r,t,e=[],A={}){if(r.nodeType!==1)return e;let i=!1,s=null,n={...t};switch(r.nodeName){case"svg":n=xe(r,n,A);break;case"style":ng(r,A);break;case"g":n=xe(r,n,A);break;case"path":n=xe(r,n,A),r.hasAttribute("d")&&(s=lg(r));break;case"rect":n=xe(r,n,A),s=fg(r);break;case"polygon":n=xe(r,n,A),s=cg(r);break;case"polyline":n=xe(r,n,A),s=gg(r);break;case"circle":n=xe(r,n,A),s=sg(r);break;case"ellipse":n=xe(r,n,A),s=og(r);break;case"line":n=xe(r,n,A),s=ag(r);break;case"defs":i=!0;break;case"use":{n=xe(r,n,A);const g=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||r.getAttribute("href")||"").substring(1),f=r.viewportElement?.getElementById(g);f?Js(f,n,e,A):console.warn(`'use node' references non-existent node id: ${g}`);break}default:console.warn(r);break}if(n.display==="none")return e;const o=new Lt,a=[],l=ig(r,o,a);s&&(s.applyTransform(o),e.push(s),s.style={...n});const u=r.childNodes;for(let c=0,g=u.length;c<g;c++){const f=u[c];i&&f.nodeName!=="style"&&f.nodeName!=="defs"||Js(f,n,e,A)}return l&&(a.pop(),a.length>0?o.copy(a[a.length-1]):o.identity()),e}function Ks(r){const t=Hs(r);return new iA(Js(t,{}),t.getAttribute("viewBox")?.trim().split(" ").map(e=>Number(e)))}function Na(r,t,e,A,i){const s=(A-t)*.5,n=(i-e)*.5,o=r*r,a=r*o;return(2*e-2*A+s+n)*a+(-3*e+3*A-2*s-n)*o+s*r+e}function dg(r,t){const e=1-r;return e*e*e*t}function Ig(r,t){const e=1-r;return 3*e*e*r*t}function pg(r,t){return 3*(1-r)*r*r*t}function Eg(r,t){return r*r*r*t}function Ta(r,t,e,A,i){return dg(r,t)+Ig(r,e)+pg(r,A)+Eg(r,i)}function La(r,t={}){let{vertices:e=[],indices:A=[],holes:i=[],verticesStride:s=2,verticesOffset:n=e.length/s,indicesOffset:o=A.length}=t;const a=Mh(r,i,2);if(a.length){for(let u=0;u<a.length;u+=3)A[o++]=a[u]+n,A[o++]=a[u+1]+n,A[o++]=a[u+2]+n;let l=n*s;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=s}return{vertices:e,indices:A}}const Bg=8,Br=11920929e-14,Cg=1;function Qg(r,t,e,A,i,s,n,o,a=.5,l=[]){const c=Math.min(.99,Math.max(0,a));let g=(Cg-c)/1;return g*=g,Ys(r,t,e,A,i,s,n,o,l,g,0),l.push(n,o),l}function Ys(r,t,e,A,i,s,n,o,a,l,u){if(u>Bg)return;const c=(r+e)/2,g=(t+A)/2,f=(e+i)/2,d=(A+s)/2,B=(i+n)/2,I=(s+o)/2,F=(c+f)/2,b=(g+d)/2,y=(f+B)/2,_=(d+I)/2,Q=(F+y)/2,D=(b+_)/2;if(u>0){let S=n-r,M=o-t;const V=Math.abs((e-n)*M-(A-o)*S),et=Math.abs((i-n)*M-(s-o)*S);if(V>Br&&et>Br){if((V+et)*(V+et)<=l*(S*S+M*M)){a.push(Q,D);return}}else if(V>Br){if(V*V<=l*(S*S+M*M)){a.push(Q,D);return}}else if(et>Br){if(et*et<=l*(S*S+M*M)){a.push(Q,D);return}}else if(S=Q-(r+n)/2,M=D-(t+o)/2,S*S+M*M<=l){a.push(Q,D);return}}Ys(r,t,c,g,F,b,Q,D,a,l,u+1),Ys(Q,D,y,_,B,I,n,o,a,l,u+1)}const yg=8,Dg=11920929e-14,mg=1;function wg(r,t,e,A,i,s,n=.5,o=[]){const l=Math.min(.99,Math.max(0,n));let u=(mg-l)/1;return u*=u,Vs(o,r,t,e,A,i,s,u,0),o.push(i,s),o}function Vs(r,t,e,A,i,s,n,o,a){if(a>yg)return;const l=(t+A)/2,u=(e+i)/2,c=(A+s)/2,g=(i+n)/2,f=(l+c)/2,d=(u+g)/2;let B=s-t,I=n-e;const F=Math.abs((A-s)*I-(i-n)*B);if(F>Dg){if(F*F<=o*(B*B+I*I)){r.push(f,d);return}}else if(B=f-(t+s)/2,I=d-(e+n)/2,B*B+I*I<=o){r.push(f,d);return}Vs(r,t,e,l,u,f,d,o,a+1),Vs(r,f,d,c,g,s,n,o,a+1)}function vg(r,t){let e=!1;const[A,i]=r,s=t.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=t[n*2],l=t[n*2+1],u=t[o*2],c=t[o*2+1];l>i!=c>i&&A<(u-a)*(i-l)/(c-l)+a&&(e=!e)}return e}function _g(r,t){const e=1-r;return e*e*t}function bg(r,t){return 2*(1-r)*r*t}function xg(r,t){return r*r*t}function Ga(r,t,e,A){return _g(r,t)+bg(r,e)+xg(r,A)}const Fg=1e-4,Oa=1e-4;function Sg(r,t={}){const{vertices:e=[],indices:A=[],lineStyle:i={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:s=!1,closed:n=!0}=t,o=Fg;if(r.length===0)return{vertices:e,indices:A};const a=i;let l=a.alignment;if(i.alignment!==.5){let T=Mg(r);s&&(T*=-1),l=(l-.5)*T+.5}const u={x:r[0],y:r[1]},c={x:r[r.length-2],y:r[r.length-1]},g=n,f=Math.abs(u.x-c.x)<o&&Math.abs(u.y-c.y)<o;if(g){r=r.slice(),f&&(r.pop(),r.pop(),c.x=r[r.length-2],c.y=r[r.length-1]);const T=(u.x+c.x)*.5,tt=(c.y+u.y)*.5;r.unshift(T,tt),r.push(T,tt)}const d=e,B=r.length/2;let I=r.length;const F=d.length/2,b=a.width/2,y=b*b,_=a.miterLimit*a.miterLimit;let Q=r[0],D=r[1],S=r[2],M=r[3],V=0,et=0,z=-(D-M),J=Q-S,$=0,K=0,L=Math.sqrt(z*z+J*J);z/=L,J/=L,z*=b,J*=b;const it=l,G=(1-it)*2,W=it*2;g||(a.cap==="round"?I+=yA(Q-z*(G-W)*.5,D-J*(G-W)*.5,Q-z*G,D-J*G,Q+z*W,D+J*W,d,!0)+2:a.cap==="square"&&(I+=Ha(Q,D,z,J,G,W,!0,d))),d.push(Q-z*G,D-J*G),d.push(Q+z*W,D+J*W);for(let T=1;T<B-1;++T){Q=r[(T-1)*2],D=r[(T-1)*2+1],S=r[T*2],M=r[T*2+1],V=r[(T+1)*2],et=r[(T+1)*2+1],z=-(D-M),J=Q-S,L=Math.sqrt(z*z+J*J),z/=L,J/=L,z*=b,J*=b,$=-(M-et),K=S-V,L=Math.sqrt($*$+K*K),$/=L,K/=L,$*=b,K*=b;const tt=S-Q,k=D-M,P=S-V,q=et-M,Z=tt*P+k*q,nt=k*P-q*tt,X=nt<0;if(Math.abs(nt)<.001*Math.abs(Z)){d.push(S-z*G,M-J*G),d.push(S+z*W,M+J*W),Z>=0&&(a.join==="round"?I+=yA(S,M,S-z*G,M-J*G,S-$*G,M-K*G,d,!1)+4:I+=2,d.push(S-$*W,M-K*W),d.push(S+$*G,M+K*G));continue}const It=(-z+Q)*(-J+M)-(-z+S)*(-J+D),ie=(-$+V)*(-K+M)-(-$+S)*(-K+et),re=(tt*ie-P*It)/nt,Nt=(q*It-k*ie)/nt,ct=(re-S)*(re-S)+(Nt-M)*(Nt-M),yt=S+(re-S)*G,Tt=M+(Nt-M)*G,Jt=S-(re-S)*W,_t=M-(Nt-M)*W,Zt=Math.min(tt*tt+k*k,P*P+q*q),Le=X?G:W,Xr=Zt+Le*Le*y;ct<=Xr?a.join==="bevel"||ct/y>_?(X?(d.push(yt,Tt),d.push(S+z*W,M+J*W),d.push(yt,Tt),d.push(S+$*W,M+K*W)):(d.push(S-z*G,M-J*G),d.push(Jt,_t),d.push(S-$*G,M-K*G),d.push(Jt,_t)),I+=2):a.join==="round"?X?(d.push(yt,Tt),d.push(S+z*W,M+J*W),I+=yA(S,M,S+z*W,M+J*W,S+$*W,M+K*W,d,!0)+4,d.push(yt,Tt),d.push(S+$*W,M+K*W)):(d.push(S-z*G,M-J*G),d.push(Jt,_t),I+=yA(S,M,S-z*G,M-J*G,S-$*G,M-K*G,d,!1)+4,d.push(S-$*G,M-K*G),d.push(Jt,_t)):(d.push(yt,Tt),d.push(Jt,_t)):(d.push(S-z*G,M-J*G),d.push(S+z*W,M+J*W),a.join==="round"?X?I+=yA(S,M,S+z*W,M+J*W,S+$*W,M+K*W,d,!0)+2:I+=yA(S,M,S-z*G,M-J*G,S-$*G,M-K*G,d,!1)+2:a.join==="miter"&&ct/y<=_&&(X?(d.push(Jt,_t),d.push(Jt,_t)):(d.push(yt,Tt),d.push(yt,Tt)),I+=2),d.push(S-$*G,M-K*G),d.push(S+$*W,M+K*W),I+=2)}Q=r[(B-2)*2],D=r[(B-2)*2+1],S=r[(B-1)*2],M=r[(B-1)*2+1],z=-(D-M),J=Q-S,L=Math.sqrt(z*z+J*J),z/=L,J/=L,z*=b,J*=b,d.push(S-z*G,M-J*G),d.push(S+z*W,M+J*W),g||(a.cap==="round"?I+=yA(S-z*(G-W)*.5,M-J*(G-W)*.5,S-z*G,M-J*G,S+z*W,M+J*W,d,!1)+2:a.cap==="square"&&(I+=Ha(S,M,z,J,G,W,!1,d)));const At=Oa*Oa;for(let T=F;T<I+F-2;++T)Q=d[T*2],D=d[T*2+1],S=d[(T+1)*2],M=d[(T+1)*2+1],V=d[(T+2)*2],et=d[(T+2)*2+1],!(Math.abs(Q*(M-et)+S*(et-D)+V*(D-M))<At)&&A.push(T,T+1,T+2);return{vertices:e,indices:A}}function Mg(r){const t=r.length;if(t<6)return 1;let e=0;for(let A=0,i=r[t-2],s=r[t-1];A<t;A+=2){const n=r[A],o=r[A+1];e+=(n-i)*(o+s),i=n,s=o}return e<0?-1:1}function Ha(r,t,e,A,i,s,n,o){const a=r-e*i,l=t-A*i,u=r+e*s,c=t+A*s;let g,f;n?(g=A,f=-e):(g=-A,f=e);const d=a+g,B=l+f,I=u+g,F=c+f;return o.push(d,B),o.push(I,F),2}function yA(r,t,e,A,i,s,n,o){const a=e-r,l=A-t;let u=Math.atan2(a,l),c=Math.atan2(i-r,s-t);o&&u<c?u+=Math.PI*2:!o&&u>c&&(c+=Math.PI*2);let g=u;const f=c-u,d=Math.abs(f),B=Math.sqrt(a*a+l*l),I=(15*d*Math.sqrt(B)/Math.PI>>0)+1,F=f/I;if(g+=F,o){n.push(r,t),n.push(e,A);for(let b=1,y=g;b<I;b++,y+=F)n.push(r,t),n.push(r+Math.sin(y)*B,t+Math.cos(y)*B);n.push(r,t),n.push(i,s)}else{n.push(e,A),n.push(r,t);for(let b=1,y=g;b<I;b++,y+=F)n.push(r+Math.sin(y)*B,t+Math.cos(y)*B),n.push(r,t);n.push(i,s),n.push(r,t)}return I*2}class GA{arcLengthDivision=200;_arcLengths;getPointAt(t,e=new O){return this.getPoint(this.getUToTMapping(t),e)}isClockwise(){const t=this.getPoint(1),e=this.getPoint(.5),A=this.getPoint(1);return(e.x-t.x)*(A.y-e.y)-(e.y-t.y)*(A.x-e.x)<0}getControlPointRefs(){return[]}applyTransform(t){const e=typeof t=="function";return this.getControlPointRefs().forEach(A=>{e?t(A):A.applyMatrix3(t)}),this}getUnevenVertices(t=5,e=[]){const A=new O;for(let i=0,s=Math.max(1,t)-1;i<=s;i++)this.getPoint(i/s,A),e.push(A.x,A.y);return e}getSpacedVertices(t=5,e=[]){const A=new O;for(let i=0,s=Math.max(1,t)-1;i<=s;i++)this.getPointAt(i/s,A),e.push(A.x,A.y);return e}getAdaptiveVertices(t=[]){return this.getUnevenVertices(5,t)}_verticesToPoints(t,e=[]){for(let A=0,i=t.length;A<i;A+=2){const s=t[A],n=t[A+1];e.push(new O(s,n))}return e}getSpacedPoints(t,e=[]){const A=this.getSpacedVertices(t);return this._verticesToPoints(A,e),e}getUnevenPoints(t,e=[]){const A=this.getUnevenVertices(t);return this._verticesToPoints(A,e),e}getAdaptivePoints(t=[]){const e=this.getAdaptiveVertices();return this._verticesToPoints(e,t),t}getPoints(t,e=[]){let A;return t?A=this.getUnevenVertices(t):A=this.getAdaptiveVertices(),this._verticesToPoints(A,e),e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const t=this.arcLengthDivision,e=[0];for(let A=0,i=this.getPoint(0),s=1;s<=t;s++){const n=this.getPoint(s/t);A+=n.distanceTo(i),e.push(A),i=n}this._arcLengths=e}getUToTMapping(t,e){const A=this.getLengths(),i=A.length,s=e??t*A[i-1];if(i<2)return s/A[0];let n=0,o=0,a=i-1,l;for(;o<=a;)if(n=Math.floor(o+(a-o)/2),l=A[n]-s,l<0)o=n+1;else if(l>0)a=n-1;else{a=n;break}if(n=a,A[n]===s)return n/(i-1);const u=A[n],g=A[n+1]-u,f=(s-u)/g;return(n+f)/(i-1)}getTangent(t,e=new O){const i=Math.max(0,t-1e-4),s=Math.min(1,t+1e-4);return e.copy(this.getPoint(s).sub(this.getPoint(i)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new O){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let A=0,i=1,s=(A+i)/2;for(;i-A>e;){s=(A+i)/2;const n=this.getPoint(s);if(n.distanceTo(t)<e)return s;n.x<t.x?A=s:i=s}return s}getMinMax(t=O.MAX,e=O.MIN){const A=this.getPoints();for(let i=0,s=A.length;i<s;i++){const n=A[i];t.min(n),e.max(n)}return{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new ut(t.x,t.y,e.x-t.x,e.y-t.y)}getFillVertices(t){return this.getAdaptiveVertices()}fillTriangulate(t){return La(this.getFillVertices(t),t)}strokeTriangulate(t){return Sg(this.getAdaptiveVertices(),t)}toCommands(){const t=[],e=this.getPoints();for(let A=0,i=e.length;A<i;A++){const s=e[A];A===0?t.push({type:"M",x:s.x,y:s.y}):t.push({type:"L",x:s.x,y:s.y})}return t}toData(){return Zh(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivision=t.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Rg=new Lt,Ja=new Lt,Ka=new Lt,Cr=new O;class zs extends GA{constructor(t=new O,e=new O,A=new O,i=0,s=0,n=Math.PI*2,o=!1){super(),this._center=t,this._radius=e,this._diff=A,this.rotate=i,this.startAngle=s,this.endAngle=n,this.clockwise=o}get cx(){return this._center.x}set cx(t){this._center.x=t}get cy(){return this._center.y}set cy(t){this._center.y=t}get rx(){return this._radius.x}set rx(t){this._radius.x=t}get ry(){return this._radius.y}set ry(t){this._radius.y=t}get dx(){return this._diff.x}set dx(t){this._diff.x=t}get dy(){return this._diff.y}set dy(t){this._diff.y=t}isClockwise(){return this.clockwise}_getDeltaAngle(){const t=Math.PI*2;let e=this.endAngle-this.startAngle;const A=Math.abs(e)<Number.EPSILON;return e=(e%t+t)%t,A?e=0:this.clockwise||(e=e===0?-t:e-t),e}getPoint(t,e=new O){const A=this._getDeltaAngle(),i=this.startAngle+t*A;let s=this.cx+this.rx*Math.cos(i),n=this.cy+this.ry*Math.sin(i);if(this.rotate!==0){const o=Math.cos(this.rotate),a=Math.sin(this.rotate),l=s-this.cx,u=n-this.cy;s=l*o-u*a+this.cx,n=l*a+u*o+this.cy}return e.set(s,n)}toCommands(){const{cx:t,cy:e,rx:A,ry:i,startAngle:s,endAngle:n,clockwise:o,rotate:a}=this,l=t+A*Math.cos(s)*Math.cos(a)-i*Math.sin(s)*Math.sin(a),u=e+A*Math.cos(s)*Math.sin(a)+i*Math.sin(s)*Math.cos(a),c=Math.abs(s-n),g=c>Math.PI?1:0,f=o?1:0,d=a*180/Math.PI;if(c>=2*Math.PI){const B=s+Math.PI,I=t+A*Math.cos(B)*Math.cos(a)-i*Math.sin(B)*Math.sin(a),F=e+A*Math.cos(B)*Math.sin(a)+i*Math.sin(B)*Math.cos(a);return[{type:"M",x:l,y:u},{type:"A",rx:A,ry:i,angle:d,largeArcFlag:0,sweepFlag:f,x:I,y:F},{type:"A",rx:A,ry:i,angle:d,largeArcFlag:0,sweepFlag:f,x:l,y:u}]}else{const B=t+A*Math.cos(n)*Math.cos(a)-i*Math.sin(n)*Math.sin(a),I=e+A*Math.cos(n)*Math.sin(a)+i*Math.sin(n)*Math.cos(a);return[{type:"M",x:l,y:u},{type:"A",rx:A,ry:i,angle:d,largeArcFlag:g,sweepFlag:f,x:B,y:I}]}}drawTo(t){const{cx:e,cy:A,rx:i,ry:s,rotate:n,startAngle:o,endAngle:a,clockwise:l}=this;return t.ellipse(e,A,i,s,n,o,a,!l),this}applyTransform(t){return Cr.set(this.cx,this.cy),Cr.applyMatrix3(t),this.cx=Cr.x,this.cy=Cr.y,Ug(t)?Pg(this,t):kg(this,t),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(t=[]){const{cx:e,cy:A,rx:i,ry:s,dx:n,dy:o,startAngle:a,endAngle:l,clockwise:u,rotate:c}=this,g=!u;let f=Math.abs(a-l);(!g&&a>l||g&&l>a)&&(f=2*Math.PI-f);const d=Math.max(12,Math.floor(12*i**(1/3)*(f/Math.PI)));let B=f/d,I=a;B*=g?-1:1;const F=Math.cos(g?c:-c),b=Math.sin(g?c:-c);for(let y=0;y<d+1;y++){const _=n+Math.cos(I)*i,Q=o+Math.sin(I)*s,D=_*F-Q*b,S=_*b+Q*F;t.push(e+D,A+S),I+=B}return t}_getAdaptiveVerticesByCircle(t=[]){const{cx:e,cy:A,rx:i,ry:s,dx:n,dy:o,rotate:a,clockwise:l}=this;if(!(i>=0&&s>=0&&n>=0&&o>=0))return t;const u=Math.ceil(2.3*Math.sqrt(i+s)),c=u*8+(n?4:0)+(o?4:0),g=[];if(c===0)return t;{const B=g.length;if(u===0)g[B]=g[B+6]=e+n,g[B+1]=g[B+3]=A+o,g[B+2]=g[B+4]=e-n,g[B+5]=g[B+7]=A-o;else{let I=B,F=B+u*4+(n?2:0)+2,b=F,y=c,_=n+i,Q=o,D=e+_,S=e-_,M=A+Q;if(g[I++]=D,g[I++]=M,g[--F]=M,g[--F]=S,o){const et=A-Q;g[b++]=S,g[b++]=et,g[--y]=et,g[--y]=D}for(let et=1;et<u;et++){const z=Math.PI/2*(et/u),J=n+Math.cos(z)*i,$=o+Math.sin(z)*s,K=e+J,L=e-J,it=A+$,G=A-$;g[I++]=K,g[I++]=it,g[--F]=it,g[--F]=L,g[b++]=L,g[b++]=G,g[--y]=G,g[--y]=K}_=n,Q=o+s,D=e+_,S=e-_,M=A+Q;const V=A-Q;g[I++]=D,g[I++]=M,g[--y]=V,g[--y]=D,n&&(g[I++]=S,g[I++]=M,g[--y]=V,g[--y]=S)}}const f=Math.cos(l?-a:a),d=Math.sin(l?-a:a);for(let B=0;B<g.length;B+=2){const I=g[B],F=g[B+1],b=I-e,y=F-A,_=b*f-y*d,Q=b*d+y*f;t.push(e+_,A+Q)}return t}getAdaptiveVertices(t=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(t):this._getAdaptiveVerticesByArc(t)}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.rx=t.rx,this.ry=t.ry,this.dx=t.dx,this.dy=t.dy,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotate=t.rotate,this}}function Pg(r,t){const e=r.rx,A=r.ry,i=Math.cos(r.rotate),s=Math.sin(r.rotate),n=new O(e*i,e*s),o=new O(-A*s,A*i),a=n.applyMatrix3(t),l=o.applyMatrix3(t),u=Rg.set(a.x,l.x,0,a.y,l.y,0,0,0,1),c=Ja.copy(u).invert(),d=Ka.copy(c).transpose().multiply(c).elements,B=Ng(d[0],d[1],d[4]),I=Math.sqrt(B.rt1),F=Math.sqrt(B.rt2);if(r.rx=1/I,r.ry=1/F,r.rotate=Math.atan2(B.sn,B.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const y=Ja.set(I,0,0,0,F,0,0,0,1),_=Ka.set(B.cs,B.sn,0,-B.sn,B.cs,0,0,0,1),Q=y.multiply(_).multiply(u),D=S=>{const{x:M,y:V}=new O(Math.cos(S),Math.sin(S)).applyMatrix3(Q);return Math.atan2(V,M)};r.startAngle=D(r.startAngle),r.endAngle=D(r.endAngle),Ya(t)&&(r.clockwise=!r.clockwise)}}function kg(r,t){const e=Va(t),A=za(t);r.rx*=e,r.ry*=A;const i=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);r.rotate+=i,Ya(t)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function Ya(r){const t=r.elements;return t[0]*t[4]-t[1]*t[3]<0}function Ug(r){const t=r.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const A=Va(r),i=za(r);return Math.abs(e/(A*i))>Number.EPSILON}function Va(r){const t=r.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function za(r){const t=r.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function Ng(r,t,e){let A,i,s,n,o;const a=r+e,l=r-e,u=Math.sqrt(l*l+4*t*t);return a>0?(A=.5*(a+u),o=1/A,i=r*o*e-t*o*t):a<0?i=.5*(a-u):(A=.5*u,i=-.5*u),l>0?s=l+u:s=l-u,Math.abs(s)>2*Math.abs(t)?(o=-2*t/s,n=1/Math.sqrt(1+o*o),s=o*n):Math.abs(t)===0?(s=1,n=0):(o=-.5*s/t,s=1/Math.sqrt(1+o*o),n=o*s),l>0&&(o=s,s=-n,n=o),{rt1:A,rt2:i,cs:s,sn:n}}class Tg extends zs{constructor(t=0,e=0,A=1,i=0,s=Math.PI*2,n=!1){super(new O(t,e),new O(A,A),new O,0,i,s,n)}drawTo(t){const{cx:e,cy:A,rx:i,startAngle:s,endAngle:n,clockwise:o}=this;return t.arc(e,A,i,s,n,!o),this}getAdaptiveVertices(t=[]){const{cx:e,cy:A,rx:i,startAngle:s,endAngle:n,clockwise:o}=this;let a=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(a=2*Math.PI-a);let l=Math.max(6,Math.floor(6*i**(1/3)*(a/Math.PI)));l=Math.max(l,3);let u=a/l,c=s;u*=o?1:-1;for(let g=0;g<l+1;g++){const f=Math.cos(c),d=Math.sin(c),B=e+f*i,I=A+d*i;t.push(B,I),c+=u}return t}}class ze extends GA{constructor(t=new O,e=new O){super(),this.p1=t,this.p2=e}static from(t,e,A,i){return new ze(new O(t,e),new O(A,i))}getPoint(t,e=new O){return t===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(t).add(this.p1),e}getPointAt(t,e=new O){return this.getPoint(t,e)}getTangent(t,e=new O){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(t,e=new O){return this.getTangent(t,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(t=[]){return t.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),t}getMinMax(t=O.MAX,e=O.MIN){const{p1:A,p2:i}=this;return t.x=Math.min(t.x,A.x,i.x),t.y=Math.min(t.y,A.y,i.y),e.x=Math.max(e.x,A.x,i.x),e.y=Math.max(e.y,A.y,i.y),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,p2:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}getFillVertices(t={}){const e=Math.min(this.p1.x,this.p2.x),A=Math.max(this.p1.x,this.p2.x),i=Math.min(this.p1.y,this.p2.y),s=Math.max(this.p1.y,this.p2.y),n=e,o=i,a=A-e||t.style?.strokeWidth||0,l=s-i||t.style?.strokeWidth||0;return[n,o,n+a,o,n+a,o+l,n,o+l]}drawTo(t){const{p1:e,p2:A}=this;return t.lineTo(e.x,e.y),t.lineTo(A.x,A.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.p2.copy(t.p2),this}}class bi extends GA{constructor(t=[]){super(),this.curves=t}getFlatCurves(){return this.curves.flatMap(t=>t instanceof bi?t.getFlatCurves():t)}addCurve(t){return this.curves.push(t),this}getPoint(t,e=new O){const A=t*this.getLength(),i=this.getLengths();let s=0;for(;s<i.length;){if(i[s]>=A){const n=i[s]-A,o=this.curves[s],a=o.getLength();return o.getPointAt(a===0?0:1-n/a,e)}s++}return e}updateLengths(){const t=[];for(let e=0,A=0,i=this.curves.length;e<i;e++)A+=this.curves[e].getLength(),t.push(A);this._arcLengths=t}getControlPointRefs(){return this.curves.flatMap(t=>t.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(t,e){const A=[t[e-1],t[e]],i=[t[e+1],t[e+2]];return A[0]===i[0]&&A[1]===i[1]&&t.splice(e+1,2),t}getSpacedVertices(t=5,e=[]){let A;return this.curves.forEach(i=>{i.getSpacedVertices(t,e),A&&this._removeNextPointIfEqualPrevPoint(e,A),A=e.length-1}),e}getAdaptiveVertices(t=[]){let e;return this.curves.forEach(A=>{A.getAdaptiveVertices(t),e&&this._removeNextPointIfEqualPrevPoint(t,e),e=t.length-1}),t}strokeTriangulate(t){return this.curves.length===1?this.curves[0].strokeTriangulate(t):super.strokeTriangulate(t)}getFillVertices(t){if(this.curves.length===1)return this.curves[0].getFillVertices(t);{const e=[];let A;return this.curves.forEach(i=>{let s;i instanceof ze?s=i.getAdaptiveVertices():s=i.getFillVertices(t),e.push(...s),A&&this._removeNextPointIfEqualPrevPoint(e,A),A=e.length-1}),e}}applyTransform(t){return this.curves.forEach(e=>e.applyTransform(t)),this}getMinMax(t=O.MAX,e=O.MIN){return this.curves.forEach(A=>A.getMinMax(t,e)),{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new ut(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(A=>A.drawTo(t)),this}copy(t){return super.copy(t),this.curves=t.curves.map(e=>e.clone()),this}}class Ws extends GA{constructor(t=new O,e=new O,A=new O,i=new O){super(),this.p1=t,this.cp1=e,this.cp2=A,this.p2=i}static from(t,e,A,i,s,n,o,a){return new Ws(new O(t,e),new O(A,i),new O(s,n),new O(o,a))}getPoint(t,e=new O){const{p1:A,cp1:i,cp2:s,p2:n}=this;return e.set(Ta(t,A.x,i.x,s.x,n.x),Ta(t,A.y,i.y,s.y,n.y))}getAdaptiveVertices(t=[]){return Qg(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,t)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(t,e,A){const i=e*e-4*t*A;if(i<0)return[];const s=Math.sqrt(i),n=(-e+s)/(2*t),o=(-e-s)/(2*t);return[n,o].filter(a=>a>=0&&a<=1)}getMinMax(t=O.MAX,e=O.MIN){const{p1:A,cp1:i,cp2:s,p2:n}=this,o=this._solveQuadratic(3*(i.x-A.x),6*(s.x-i.x),3*(n.x-s.x)),a=this._solveQuadratic(3*(i.y-A.y),6*(s.y-i.y),3*(n.y-s.y)),l=[0,1,...o,...a];return((c,g)=>{for(const f of c)for(let d=0;d<=g;d++){const B=d/g-.5,I=Math.min(1,Math.max(0,f+B)),F=this.getPoint(I);t.x=Math.min(t.x,F.x),t.y=Math.min(t.y,F.y),e.x=Math.max(e.x,F.x),e.y=Math.max(e.y,F.y)}})(l,10),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp1:e,cp2:A,p2:i}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:A.x,y2:A.y,x:i.x,y:i.y}]}drawTo(t){const{p1:e,cp1:A,cp2:i,p2:s}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(A.x,A.y,i.x,i.y,s.x,s.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp1.copy(t.cp1),this.cp2.copy(t.cp2),this.p2.copy(t.p2),this}}class Lg extends zs{constructor(t=0,e=0,A=1,i=1,s=0,n=0,o=Math.PI*2,a=!1){super(new O(t,e),new O(A,i),new O,s,n,o,a)}drawTo(t){return t.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Gg extends bi{}class qs extends GA{constructor(t=new O,e=new O,A=new O){super(),this.p1=t,this.cp=e,this.p2=A}static from(t,e,A,i,s,n){return new qs(new O(t,e),new O(A,i),new O(s,n))}getPoint(t,e=new O){const{p1:A,cp:i,p2:s}=this;return e.set(Ga(t,A.x,i.x,s.x),Ga(t,A.y,i.y,s.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(t=[]){return wg(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,t)}getMinMax(t=O.MAX,e=O.MIN){const{p1:A,cp:i,p2:s}=this,n=.5*(A.x+i.x),o=.5*(A.y+i.y),a=.5*(A.x+s.x),l=.5*(A.y+s.y);return t.x=Math.min(t.x,A.x,s.x,n,a),t.y=Math.min(t.y,A.y,s.y,o,l),e.x=Math.max(e.x,A.x,s.x,n,a),e.y=Math.max(e.y,A.y,s.y,o,l),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp:e,p2:A}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:A.x,y:A.y}]}drawTo(t){const{p1:e,cp:A,p2:i}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(A.x,A.y,i.x,i.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp.copy(t.cp),this.p2.copy(t.p2),this}}class Og extends Gg{constructor(t=0,e=0,A=0,i=0){super(),this.x=t,this.y=e,this.width=A,this.height=i,this.update()}update(){const{x:t,y:e,width:A,height:i}=this,s=[new O(t,e),new O(t+A,e),new O(t+A,e+i),new O(t,e+i)];return this.curves=[new ze(s[0],s[1]),new ze(s[1],s[2]),new ze(s[2],s[3]),new ze(s[3],s[0])],this}drawTo(t){return t.rect(this.x,this.y,this.width,this.height),this}getFillVertices(t={}){const{x:e,y:A,width:i,height:s}=this;return[e,A,e+i,A,e+i,A+s,e,A+s]}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update(),this}}class Hg extends zs{constructor(t=0,e=0,A=1,i=1,s=1){super(),this.x=t,this.y=e,this.width=A,this.height=i,this.radius=s,this.update()}update(){const{x:t,y:e,width:A,height:i,radius:s}=this,n=A/2,o=i/2,a=t+n,l=e+o,u=Math.max(0,Math.min(s,Math.min(n,o))),c=u;return this._center=new O(a,l),this._radius=new O(u,c),this._diff=new O(n-u,o-c),this}drawTo(t){const{x:e,y:A,width:i,height:s,radius:n}=this;return t.roundRect(e,A,i,s,n),this}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.radius=t.radius,this.update(),this}}class Jg extends GA{constructor(t=[]){super(),this.points=t}getPoint(t,e=new O){const{points:A}=this,i=(A.length-1)*t,s=Math.floor(i),n=i-s,o=A[s===0?s:s-1],a=A[s],l=A[s>A.length-2?A.length-1:s+1],u=A[s>A.length-3?A.length-1:s+2];return e.set(Na(n,o.x,a.x,l.x,u.x),Na(n,o.y,a.y,l.y,u.y)),e}getControlPointRefs(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,A=t.points.length;e<A;e++)this.points.push(t.points[e].clone());return this}}class Qr extends bi{startPoint;currentPoint;autoClose=!1;constructor(t){super(),t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,A=t.length;e<A;e++){const{x:i,y:s}=t[e];this.lineTo(i,s)}return this}addCommands(t){return ba(t,this),this}addData(t){return this.addCommands(xa(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,e=[]){return this._closeVertices(super.getUnevenVertices(t,e))}getSpacedVertices(t=40,e=[]){return this._closeVertices(super.getSpacedVertices(t,e))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new O(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const e=t.getPoint(0);(!this.currentPoint||!e.equals(this.currentPoint))&&this.lineTo(e.x,e.y)}return this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;e&&!t.equals(e)&&(this.curves.push(new ze(e.clone(),t.clone())),e.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint=new O(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){const A=this.currentPoint;return A?.equals({x:t,y:e})||this.curves.push(ze.from(A?.x??0,A?.y??0,t,e)),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,A,i,s,n){const o=this.currentPoint;return o?.equals({x:s,y:n})||this.curves.push(Ws.from(o?.x??0,o?.y??0,t,e,A,i,s,n)),this._setCurrentPoint({x:s,y:n}),this}quadraticCurveTo(t,e,A,i){const s=this.currentPoint;return s?.equals({x:A,y:i})||this.curves.push(qs.from(s?.x??0,s?.y??0,t,e,A,i)),this._setCurrentPoint({x:A,y:i}),this}arc(t,e,A,i,s,n){const o=new Tg(t,e,A,i,s,!n);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(t,e,A,i,s,n){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.arc(t,e,A,i,s,n),this}arcTo(t,e,A,i,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,A,i,s,n,o,a=!0){const l=new Lg(t,e,A,i,s,n,o,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,e,A,i,s,n,o,a){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.ellipse(t,e,A,i,s,n,o,a),this}rect(t,e,A,i){const s=new Og(t,e,A,i);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:e}),this}roundRect(t,e,A,i,s){const n=new Hg(t,e,A,i,s);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){const e=this.currentPoint??new O;return this.curves.push(new Jg([e].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(A=>A.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=t.currentPoint?.clone(),this}}function Kg(r){return r.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Yg(r,t,e,A){const i=t.clone().sub(r),s=A.clone().sub(e),n=e.clone().sub(r),o=i.cross(s);if(o===0)return new O((r.x+e.x)/2,(r.y+e.y)/2);const a=n.cross(s)/o;return Math.abs(a)>1?new O((r.x+e.x)/2,(r.y+e.y)/2):new O(r.x+a*i.x,r.y+a*i.y)}class Mt extends bi{currentCurve=new Qr;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(t,e={}){super(),this.curves.push(this.currentCurve),this.style=e,t&&(t instanceof Mt?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}addPath(t){const e=this.curves.findIndex(A=>A===this.currentCurve);return e>-1&&this.curves.splice(e,1),t instanceof Mt?this.curves.push(...t.curves.filter(A=>A.curves.length).map(A=>A.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new Qr().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,e){return this.currentCurve.currentPoint?.equals({x:t,y:e})||(this.currentCurve.curves.length&&(this.currentCurve=new Qr,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,e)),this}lineTo(t,e){return this.currentCurve.lineTo(t,e),this}bezierCurveTo(t,e,A,i,s,n){return this.currentCurve.bezierCurveTo(t,e,A,i,s,n),this}quadraticCurveTo(t,e,A,i){return this.currentCurve.quadraticCurveTo(t,e,A,i),this}arc(t,e,A,i,s,n){return this.currentCurve.arc(t,e,A,i,s,n),this}arcTo(t,e,A,i,s){return this.currentCurve.arcTo(t,e,A,i,s),this}ellipse(t,e,A,i,s,n,o,a){return this.currentCurve.ellipse(t,e,A,i,s,n,o,a),this}rect(t,e,A,i){return this.currentCurve.rect(t,e,A,i),this}roundRect(t,e,A,i,s){return this.currentCurve.roundRect(t,e,A,i,s),this}reset(){return this.currentCurve=new Qr,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return ba(t,this),this}addData(t){return this.addCommands(xa(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,e=t,A={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.scale(t,e,A)}),this}skew(t,e=0,A={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.skew(t,e,A)}),this}rotate(t,e={x:0,y:0}){return this.getControlPointRefs().forEach(A=>{A.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getFlatCurves(),A=[],i=[],s=[];e.forEach((o,a)=>{const l=o.getControlPointRefs(),u=o.isClockwise();s[a]=l,i[a]=u;const c=l[0],g=l[l.length-1]??c;A.push({start:u?g:c,end:u?c:g,index:a})});const n=[];return A.forEach((o,a)=>{n[a]=[],A.forEach((l,u)=>{l.start&&o.end&&u!==a&&l.start?.equals(o.end)&&n[a].push(l.index)})}),e.forEach((o,a)=>{const l=i[a];s[a].forEach(u=>{u.add(o.getNormal(o.getTForPoint(u)).scale(l?t:-t))})}),n.forEach((o,a)=>{const l=s[a];o.forEach(u=>{const c=s[u],g=Yg(l[l.length-1],l[l.length-2]??l[l.length-1],c[0],c[1]??c[0]);g&&(l[l.length-1].copy(g),c[0].copy(g))})}),this}getMinMax(t=O.MAX,e=O.MIN,A=!0){const i=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,e),A&&i>1){const n=i/2,o=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const u=s.getPoint(l),c=s.getNormal(l),g=c.clone().scale(o?n:-n),f=c.clone().scale(o?-n:n);a.push(u.clone().add(g),u.clone().add(f),u.clone().add({x:n,y:0}),u.clone().add({x:-n,y:0}),u.clone().add({x:0,y:n}),u.clone().add({x:0,y:-n}),u.clone().add({x:n,y:n}),u.clone().add({x:-n,y:-n}))}t.min(...a),e.max(...a)}}),{min:t.finite(),max:e.finite()}}strokeTriangulate(t){const e=t?.indices??[],A=t?.vertices??[];return this.curves.forEach(i=>{i.strokeTriangulate({...t,indices:e,vertices:A,style:{...this.style}})}),{indices:e,vertices:A}}fillTriangulate(t){const e={...t,style:{...this.style,...t?.style}},A=e.indices??[],i=e.vertices??[];if((e.style.fillRule??"nonzero")==="nonzero"){const n=this.curves.map(l=>l.getFillVertices(e)),o=new Map,a=new Set;for(let l=0;l<n.length;l++){const u=[];for(let c=0;c<n.length;c++)l!==c&&vg([n[l][0],n[l][1]],n[c])&&u.push(c);u.length&&(u.forEach(c=>{let g=o.get(c);g||(g=new Set,o.set(c,g)),g.add(l)}),a.add(l))}n.forEach((l,u)=>{if(a.has(u)||!l.length)return;const c=l.slice(),g=[];o.get(u)?.forEach(f=>{g.push(c.length/2),c.push(...n[f])}),La(c,{...t,indices:A,vertices:i,holes:g,style:{...this.style}})})}else this.curves.forEach(n=>{n.fillTriangulate({...t,indices:A,vertices:i,style:{...this.style}})});return{indices:A,vertices:i}}getBoundingBox(t=!0){const{min:e,max:A}=this.getMinMax(void 0,void 0,t);return new ut(e.x,e.y,A.x-e.x,A.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:A="#000",stroke:i="none"}=e;return t.beginPath(),t.save(),Gs(t,e),this.curves.forEach(s=>{s.drawTo(t)}),A!=="none"&&t.fill(),i!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:A="#000",stroke:i="none"}=e;return t.beginPath(),t.save(),Gs(t,e),this.getControlPointRefs().forEach(s=>{qh(t,s.x,s.y,{radius:4})}),A!=="none"&&t.fill(),i!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const i in t)t[i]!==void 0&&(e[Kg(i)]=t[i]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let A="";for(const i in e)e[i]!==void 0&&(A+=`${i}:${e[i]};`);return`<path d="${this.toData()}" style="${A}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class iA{constructor(t=[],e){this.paths=t,this.viewBox=e}getBoundingBox(t=!0){if(!this.paths.length)return;const e=O.MAX,A=O.MIN;return this.paths.forEach(i=>i.getMinMax(e,A,t)),new ut(e.x,e.y,A.x-e.x,A.y-e.y)}toTriangulatedSvgString(t=this.paths.map(A=>A.fillTriangulate()),e=0){let A="";const i={x:-e,y:-e},s={x:e,y:e};(Array.isArray(t)?t:[t]).forEach(({vertices:a,indices:l})=>{const u=c=>{const g=a[c*2],f=a[c*2+1];return i.x=Math.min(i.x,g+e),s.x=Math.max(s.x,g+e),i.y=Math.min(i.y,f+e),s.y=Math.max(s.y,f+e),[g,f]};for(let c=0,g=l.length;c<g;c+=3){const f=u(l[c]),d=u(l[c+1]),B=u(l[c+2]);A+=`<polygon points="${f.join(",")} ${d.join(",")} ${B.join(",")}" fill="black" />`}});const o=[i.x,i.y,s.x-i.x,s.y-i.y];return`<svg width="${o[2]}" height="${o[3]}" viewBox="${o.join(" ")}" xmlns="http://www.w3.org/2000/svg">${A}</svg>`}toTriangulatedSvg(t,e){return new DOMParser().parseFromString(this.toTriangulatedSvgString(t,e),"image/svg+xml").documentElement}toSvgString(){const{x:t,y:e,width:A,height:i}=this.getBoundingBox(),s=this.paths.map(n=>n.toSvgPathString()).join("");return`<svg viewBox="${t} ${e} ${A} ${i}" width="${A}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...A}=t,{left:i,top:s,width:n,height:o}=this.getBoundingBox(),a=document.createElement("canvas");a.width=n*e,a.height=o*e,a.style.width=`${n}px`,a.style.height=`${o}px`;const l=a.getContext("2d");return l&&(l.scale(e,e),l.translate(-i,-s),this.paths.forEach(u=>{u.drawTo(l,A)})),a}}class Wa extends Mt{fillStyle;strokeStyle;lineCap;lineJoin;lineWidth;miterLimit;uvTransform;vertTransform;_defaultStyle=Dt.EMPTY;_draws=[];_toTexture(t){return t instanceof Dt?t:ca.get(t)}stroke(t){const e=new Mt(this);let A=this._defaultStyle;this.strokeStyle&&(A=this._toTexture(this.strokeStyle)),this.curves.length&&(this._draws.push({...t,type:"stroke",path:e,texture:A,uvTransform:this.uvTransform,vertTransform:this.vertTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),super.reset())}fillRect(t,e,A,i){this.rect(t,e,A,i).fill()}strokeRect(t,e,A,i){this.rect(t,e,A,i).stroke()}fill(t){const e=new Mt(this);let A=this._defaultStyle;this.fillStyle&&(A=this._toTexture(this.fillStyle)),this._draws.push({...t,type:"fill",path:e,texture:A,uvTransform:this.uvTransform,vertTransform:this.vertTransform}),super.reset()}copy(t){return super.copy(t),this.strokeStyle=t.strokeStyle,this.fillStyle=t.fillStyle,this.uvTransform=t.uvTransform,this.vertTransform=t.vertTransform,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this._draws=t._draws.slice(),this}reset(){return super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.uvTransform=void 0,this.vertTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._draws.length=0,this}buildUvs(t,e,A,i,s){if(i){const n=s&&(typeof s=="function"?s:(l,u)=>s.applyToPoint(l,u)),o=i.width,a=i.height;for(let l=e.length,u=t;u<l;u+=2){const c=e[u],g=e[u+1];let f,d;n?[f,d]=n(c,g):[f,d]=[c/o,g/a],A.push(f,d)}}else for(let n=e.length,o=t;o<n;o+=2)A.push(0,0)}toBatchables(){const t=[];for(let e=this._draws.length,A=0;A<e;A++){const i=this._draws[A],s=[],n=[],o=[];i.type==="fill"?i.path.fillTriangulate({vertices:s,indices:n}):i.path.strokeTriangulate({vertices:s,indices:n,lineStyle:i.style,flipAlignment:!1,closed:!0}),this.buildUvs(0,s,o,i.texture,i.uvTransform),t.push({vertices:s,indices:n,uvs:o,texture:i.texture,type:i.type,disableWrapMode:i.disableWrapMode,vertTransform:i.vertTransform})}return t}}var Vg=Object.defineProperty,zg=Object.getOwnPropertyDescriptor,xi=(r,t,e,A)=>{for(var i=A>1?void 0:A?zg(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&Vg(t,e,i),i};h.CanvasItem=class extends h.TimelineNode{_parentGlobalVisible;_globalVisible;get globalVisible(){return this._globalVisible??!0}_parentGlobalOpacity;_globalOpacity;get globalOpacity(){return this._globalOpacity??1}_modulate=new ve(4294967295);context=new Wa;_resetContext=!0;_redrawing=!0;_relayouting=!1;_repainting=!1;_originalBatchables=[];_layoutedBatchables=[];_batchables=[];constructor(t,e=[]){super(),this.setProperties(t).append(e)}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"modulate":this._modulate.value=e,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0,this.requestUpdate()}requestRelayout(){this._relayouting=!0,this.requestUpdate()}requestRepaint(){this._repainting=!0,this.requestUpdate()}_updateGlobalVisible(){this._parentGlobalVisible=this.getParent()?.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){this._parentGlobalOpacity=this.getParent()?.opacity;const t=Ke(0,this.opacity,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==t&&(this._globalOpacity=t,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){return this.log(this.name,"drawing"),this._draw(),this.context.toBatchables()}_relayout(t){return this.log(this.name,"layouting"),t}_repaint(t){return this.log(this.name,"painting"),t.map(e=>({...e,modulate:this._modulate.toArgb(this.globalOpacity,!0),blendMode:this.blendMode}))}_process(t){super._process(t);const e=this.getParent();this._parentGlobalVisible!==e?.globalVisible&&this.requestUpdate(),this._parentGlobalOpacity!==e?.globalOpacity&&this.requestUpdate()}_update(t){super._update(t);const e=this.getParent();this._parentGlobalVisible!==e?.globalVisible&&this._updateGlobalVisible(),this._parentGlobalOpacity!==e?.globalOpacity&&this._updateGlobalOpacity();const A=this._redrawing;let i=this._relayouting,s=this._repainting,n;A&&(this._originalBatchables=this._redraw(),i=!0),i&&(this._layoutedBatchables=this._relayout(this._originalBatchables),s=!0),s&&(n=this._repaint(this._layoutedBatchables)),A&&this._resetContext&&this.context.reset(),n&&(this._batchables=n,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(t){this._batchables.forEach(e=>{e.texture?.upload(t),t.batch2D.render({...e,texture:e.texture?._glTexture(t)})}),super._render(t)}},xi([w()],h.CanvasItem.prototype,"modulate",2),xi([w()],h.CanvasItem.prototype,"blendMode",2),xi([w({protected:!0,fallback:!0})],h.CanvasItem.prototype,"visible",2),xi([w({protected:!0,fallback:1})],h.CanvasItem.prototype,"opacity",2),h.CanvasItem=xi([st("CanvasItem")],h.CanvasItem);class Wg{currentCall;calls=[];createCall(t){return{renderable:t,parentCall:this.currentCall,fn:t.render.bind(t),calls:[]}}push(t){const e=this.createCall(t);return(this.currentCall?.calls??this.calls).push(e),e}render(t){this.calls.forEach(function e(A){A.fn(t,()=>{A.calls.forEach(e)})}),this.calls=[]}}var qg=Object.defineProperty,Xg=Object.getOwnPropertyDescriptor,Fi=(r,t,e,A)=>{for(var i=A>1?void 0:A?Xg(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&qg(t,e,i),i};h.Timeline=class extends h.Node{static from(t,e=!1){const[A,i]=t?Array.isArray(t)?t:[0,t]:[];return new h.Timeline({startTime:A,endTime:i,loop:e})}constructor(t){super(),this.setProperties(t)}_updateProperty(t,e,A){switch(super._updateProperty(t,e,A),t){case"startTime":this.startTime=Math.min(e,this.endTime);break;case"endTime":this.endTime=e||Number.MAX_SAFE_INTEGER;break}}addTime(t){const e=this.startTime,A=this.endTime;let i=this.currentTime;return i=i+t,this.loop&&i>A&&(i=e+i%A),i=Ke(e,i,A),this.currentTime=i,this.emit("updateCurrentTime",i,t),this}_process(t){super._process(t),this.addTime(t)}},Fi([w({fallback:0})],h.Timeline.prototype,"startTime",2),Fi([w({fallback:0})],h.Timeline.prototype,"currentTime",2),Fi([w({fallback:Number.MAX_SAFE_INTEGER})],h.Timeline.prototype,"endTime",2),Fi([w({fallback:!1})],h.Timeline.prototype,"loop",2),h.Timeline=Fi([st("Timeline")],h.Timeline);var jg=Object.defineProperty,Xs=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&jg(t,e,i),i};class Si extends hr{input=new No;renderStack=new Wg;root=new h.Viewport(!0).setTree(this);timeline;nodes=new Map;_backgroundColor=new ve;_currentViewport;getCurrentViewport(){return this._currentViewport}setCurrentViewport(t){this._currentViewport=t}constructor(t=new h.Timeline){super(),this.timeline=t.setTree(this)}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"backgroundColor":this._backgroundColor.value=e;break}}log(...t){this.debug&&console.log(`[modern-canvas][${performance.now().toFixed(4)}ms]`,...t)}_process(t=0){this.timeline.emit("process",t),this.emit("processing"),this.root.emit("process",t),this.emit("processed")}_render(t){this.emit("rendering"),t.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(t),this._renderScreen(t),this.emit("rendered")}_renderScreen(t){t.state.reset(),t.framebuffer.bind(null),t.viewport.bind({x:0,y:0,width:this.root.width*t.pixelRatio,height:this.root.height*t.pixelRatio}),this.backgroundColor&&t.gl.clearColor(...this._backgroundColor.toArray()),t.clear(),this.backgroundColor&&t.gl.clearColor(0,0,0,0);const e=this.root.texture;e.activate(t,0),gt.draw(t),t.texture.unbind(e)}free(){super.free(),this.root.children.internal.forEach(t=>this.root.removeChild(t)),this.input.removeEventListeners()}}Xs([w({fallback:!1})],Si.prototype,"processPaused"),Xs([w()],Si.prototype,"backgroundColor"),Xs([w({protected:!0,fallback:!1})],Si.prototype,"debug");var Zg=Object.getOwnPropertyDescriptor,$g=(r,t,e,A)=>{for(var i=A>1?void 0:A?Zg(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};h.Transition=class extends h.Effect{constructor(t,e=[]){super(),this.setProperties(t).append(e)}},h.Transition=$g([st("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],h.Transition);var qa=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,ef=(r,t,e)=>t in r?qa(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,js=(r,t,e,A)=>{for(var i=A>1?void 0:A?tf(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&qa(t,e,i),i},Xa=(r,t,e)=>ef(r,typeof t!="symbol"?t+"":t,e);const ja=`varying vec2 vUv[9];
277
+ ${t}`);return e.documentElement}else return r}const tg="px",eg=90,Ra=["mm","cm","in","pt","pc","px"],Pa={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function pt(r){let t="px";if(typeof r=="string")for(let A=0,i=Ra.length;A<i;A++){const s=Ra[A];if(r.endsWith(s)){t=s,r=r.substring(0,r.length-s.length);break}}let e;return e=Pa[t][tg],e<0&&(e=Pa[t].in*eg),e*Number.parseFloat(r)}const Ag=new Lt,Er=new Lt,ka=new Lt,Ua=new Lt;function ig(r,t,e){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const A=rg(r);return e.length>0&&A.premultiply(e[e.length-1]),t.copy(A),e.push(A),A}function rg(r){const t=new Lt,e=Ag;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&t.translate(pt(r.getAttribute("x")),pt(r.getAttribute("y"))),r.hasAttribute("transform")){const A=r.getAttribute("transform").split(")");for(let i=A.length-1;i>=0;i--){const s=A[i].trim();if(s==="")continue;const n=s.indexOf("("),o=s.length;if(n>0&&n<o){const a=s.slice(0,n),l=be(s.slice(n+1));switch(e.identity(),a){case"translate":if(l.length>=1){const u=l[0];let c=0;l.length>=2&&(c=l[1]),e.translate(u,c)}break;case"rotate":if(l.length>=1){let u=0,c=0,g=0;u=l[0]*Math.PI/180,l.length>=3&&(c=l[1],g=l[2]),Er.makeTranslation(-c,-g),ka.makeRotation(u),Ua.multiplyMatrices(ka,Er),Er.makeTranslation(c,g),e.multiplyMatrices(Er,Ua)}break;case"scale":l.length>=1&&e.scale(l[0],l[1]??l[0]);break;case"skewX":l.length===1&&e.set(1,Math.tan(l[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":l.length===1&&e.set(1,0,0,Math.tan(l[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":l.length===6&&e.set(l[0],l[2],l[4],l[1],l[3],l[5],0,0,1);break}}t.premultiply(e)}}return t}function sg(r){return new Mt().arc(pt(r.getAttribute("cx")||0),pt(r.getAttribute("cy")||0),pt(r.getAttribute("r")||0),0,Math.PI*2)}function ng(r,t){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let e=0;e<r.sheet.cssRules.length;e++){const A=r.sheet.cssRules[e];if(A.type!==1)continue;const i=A.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),s={};for(let n=A.style.length,o=0;o<n;o++){const a=A.style.item(o);s[a]=A.style.getPropertyValue(a)}for(let n=0;n<i.length;n++)t[i[n]]=Object.assign(t[i[n]]||{},{...s})}}function og(r){return new Mt().ellipse(pt(r.getAttribute("cx")||0),pt(r.getAttribute("cy")||0),pt(r.getAttribute("rx")||0),pt(r.getAttribute("ry")||0),0,0,Math.PI*2)}function ag(r){return new Mt().moveTo(pt(r.getAttribute("x1")||0),pt(r.getAttribute("y1")||0)).lineTo(pt(r.getAttribute("x2")||0),pt(r.getAttribute("y2")||0))}function lg(r){const t=new Mt,e=r.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const ug=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function cg(r){const t=new Mt;let e=0;return r.getAttribute("points")?.replace(ug,(A,i,s)=>{const n=pt(i),o=pt(s);return e===0?t.moveTo(n,o):t.lineTo(n,o),e++,A}),t.currentCurve.autoClose=!0,t}const hg=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function gg(r){const t=new Mt;let e=0;return r.getAttribute("points")?.replace(hg,(A,i,s)=>{const n=pt(i),o=pt(s);return e===0?t.moveTo(n,o):t.lineTo(n,o),e++,A}),t.currentCurve.autoClose=!1,t}function fg(r){const t=pt(r.getAttribute("x")||0),e=pt(r.getAttribute("y")||0),A=pt(r.getAttribute("rx")||r.getAttribute("ry")||0),i=pt(r.getAttribute("ry")||r.getAttribute("rx")||0),s=pt(r.getAttribute("width")),n=pt(r.getAttribute("height")),o=1-.551915024494,a=new Mt;return a.moveTo(t+A,e),a.lineTo(t+s-A,e),(A!==0||i!==0)&&a.bezierCurveTo(t+s-A*o,e,t+s,e+i*o,t+s,e+i),a.lineTo(t+s,e+n-i),(A!==0||i!==0)&&a.bezierCurveTo(t+s,e+n-i*o,t+s-A*o,e+n,t+s-A,e+n),a.lineTo(t+A,e+n),(A!==0||i!==0)&&a.bezierCurveTo(t+A*o,e+n,t,e+n-i*o,t,e+n-i),a.lineTo(t,e+i),(A!==0||i!==0)&&a.bezierCurveTo(t,e+i*o,t+A*o,e,t+A,e),a}function xe(r,t,e){t=Object.assign({},t);let A={};if(r.hasAttribute("class")){const l=r.getAttribute("class").split(/\s/).filter(Boolean).map(u=>u.trim());for(let u=0;u<l.length;u++)A=Object.assign(A,e[`.${l[u]}`])}r.hasAttribute("id")&&(A=Object.assign(A,e[`#${r.getAttribute("id")}`]));for(let l=r.style.length,u=0;u<l;u++){const c=r.style.item(u),g=r.style.getPropertyValue(c);t[c]=g,A[c]=g}function i(l,u,c=s){r.hasAttribute(l)&&(t[u]=c(r.getAttribute(l))),A[l]&&(t[u]=c(A[l]))}function s(l){return l.startsWith("url")&&console.warn("url access in attributes is not implemented."),l}function n(l){return Math.max(0,Math.min(1,pt(l)))}function o(l){return Math.max(0,pt(l))}function a(l){return l.split(" ").filter(u=>u!=="").map(u=>pt(u))}return i("fill","fill"),i("fill-opacity","fillOpacity",n),i("fill-rule","fillRule"),i("opacity","opacity",n),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",n),i("stroke-width","strokeWidth",o),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",o),i("stroke-dasharray","strokeDasharray",a),i("stroke-dashoffset","strokeDashoffset",pt),i("visibility","visibility"),t}function Js(r,t,e=[],A={}){if(r.nodeType!==1)return e;let i=!1,s=null,n={...t};switch(r.nodeName){case"svg":n=xe(r,n,A);break;case"style":ng(r,A);break;case"g":n=xe(r,n,A);break;case"path":n=xe(r,n,A),r.hasAttribute("d")&&(s=lg(r));break;case"rect":n=xe(r,n,A),s=fg(r);break;case"polygon":n=xe(r,n,A),s=cg(r);break;case"polyline":n=xe(r,n,A),s=gg(r);break;case"circle":n=xe(r,n,A),s=sg(r);break;case"ellipse":n=xe(r,n,A),s=og(r);break;case"line":n=xe(r,n,A),s=ag(r);break;case"defs":i=!0;break;case"use":{n=xe(r,n,A);const g=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||r.getAttribute("href")||"").substring(1),f=r.viewportElement?.getElementById(g);f?Js(f,n,e,A):console.warn(`'use node' references non-existent node id: ${g}`);break}default:console.warn(r);break}if(n.display==="none")return e;const o=new Lt,a=[],l=ig(r,o,a);s&&(s.applyTransform(o),e.push(s),s.style={...n});const u=r.childNodes;for(let c=0,g=u.length;c<g;c++){const f=u[c];i&&f.nodeName!=="style"&&f.nodeName!=="defs"||Js(f,n,e,A)}return l&&(a.pop(),a.length>0?o.copy(a[a.length-1]):o.identity()),e}function Ks(r){const t=Hs(r);return new iA(Js(t,{}),t.getAttribute("viewBox")?.trim().split(" ").map(e=>Number(e)))}function Na(r,t,e,A,i){const s=(A-t)*.5,n=(i-e)*.5,o=r*r,a=r*o;return(2*e-2*A+s+n)*a+(-3*e+3*A-2*s-n)*o+s*r+e}function dg(r,t){const e=1-r;return e*e*e*t}function Ig(r,t){const e=1-r;return 3*e*e*r*t}function pg(r,t){return 3*(1-r)*r*r*t}function Eg(r,t){return r*r*r*t}function Ta(r,t,e,A,i){return dg(r,t)+Ig(r,e)+pg(r,A)+Eg(r,i)}function La(r,t={}){let{vertices:e=[],indices:A=[],holes:i=[],verticesStride:s=2,verticesOffset:n=e.length/s,indicesOffset:o=A.length}=t;const a=Mh(r,i,2);if(a.length){for(let u=0;u<a.length;u+=3)A[o++]=a[u]+n,A[o++]=a[u+1]+n,A[o++]=a[u+2]+n;let l=n*s;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=s}return{vertices:e,indices:A}}const Bg=8,Br=11920929e-14,Cg=1;function Qg(r,t,e,A,i,s,n,o,a=.5,l=[]){const c=Math.min(.99,Math.max(0,a));let g=(Cg-c)/1;return g*=g,Ys(r,t,e,A,i,s,n,o,l,g,0),l.push(n,o),l}function Ys(r,t,e,A,i,s,n,o,a,l,u){if(u>Bg)return;const c=(r+e)/2,g=(t+A)/2,f=(e+i)/2,d=(A+s)/2,B=(i+n)/2,I=(s+o)/2,F=(c+f)/2,b=(g+d)/2,y=(f+B)/2,_=(d+I)/2,Q=(F+y)/2,D=(b+_)/2;if(u>0){let S=n-r,M=o-t;const V=Math.abs((e-n)*M-(A-o)*S),et=Math.abs((i-n)*M-(s-o)*S);if(V>Br&&et>Br){if((V+et)*(V+et)<=l*(S*S+M*M)){a.push(Q,D);return}}else if(V>Br){if(V*V<=l*(S*S+M*M)){a.push(Q,D);return}}else if(et>Br){if(et*et<=l*(S*S+M*M)){a.push(Q,D);return}}else if(S=Q-(r+n)/2,M=D-(t+o)/2,S*S+M*M<=l){a.push(Q,D);return}}Ys(r,t,c,g,F,b,Q,D,a,l,u+1),Ys(Q,D,y,_,B,I,n,o,a,l,u+1)}const yg=8,Dg=11920929e-14,mg=1;function wg(r,t,e,A,i,s,n=.5,o=[]){const l=Math.min(.99,Math.max(0,n));let u=(mg-l)/1;return u*=u,Vs(o,r,t,e,A,i,s,u,0),o.push(i,s),o}function Vs(r,t,e,A,i,s,n,o,a){if(a>yg)return;const l=(t+A)/2,u=(e+i)/2,c=(A+s)/2,g=(i+n)/2,f=(l+c)/2,d=(u+g)/2;let B=s-t,I=n-e;const F=Math.abs((A-s)*I-(i-n)*B);if(F>Dg){if(F*F<=o*(B*B+I*I)){r.push(f,d);return}}else if(B=f-(t+s)/2,I=d-(e+n)/2,B*B+I*I<=o){r.push(f,d);return}Vs(r,t,e,l,u,f,d,o,a+1),Vs(r,f,d,c,g,s,n,o,a+1)}function vg(r,t){let e=!1;const[A,i]=r,s=t.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=t[n*2],l=t[n*2+1],u=t[o*2],c=t[o*2+1];l>i!=c>i&&A<(u-a)*(i-l)/(c-l)+a&&(e=!e)}return e}function _g(r,t){const e=1-r;return e*e*t}function bg(r,t){return 2*(1-r)*r*t}function xg(r,t){return r*r*t}function Ga(r,t,e,A){return _g(r,t)+bg(r,e)+xg(r,A)}const Fg=1e-4,Oa=1e-4;function Sg(r,t={}){const{vertices:e=[],indices:A=[],lineStyle:i={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:s=!1,closed:n=!0}=t,o=Fg;if(r.length===0)return{vertices:e,indices:A};const a=i;let l=a.alignment;if(i.alignment!==.5){let T=Mg(r);s&&(T*=-1),l=(l-.5)*T+.5}const u={x:r[0],y:r[1]},c={x:r[r.length-2],y:r[r.length-1]},g=n,f=Math.abs(u.x-c.x)<o&&Math.abs(u.y-c.y)<o;if(g){r=r.slice(),f&&(r.pop(),r.pop(),c.x=r[r.length-2],c.y=r[r.length-1]);const T=(u.x+c.x)*.5,tt=(c.y+u.y)*.5;r.unshift(T,tt),r.push(T,tt)}const d=e,B=r.length/2;let I=r.length;const F=d.length/2,b=a.width/2,y=b*b,_=a.miterLimit*a.miterLimit;let Q=r[0],D=r[1],S=r[2],M=r[3],V=0,et=0,z=-(D-M),J=Q-S,$=0,K=0,L=Math.sqrt(z*z+J*J);z/=L,J/=L,z*=b,J*=b;const it=l,G=(1-it)*2,W=it*2;g||(a.cap==="round"?I+=yA(Q-z*(G-W)*.5,D-J*(G-W)*.5,Q-z*G,D-J*G,Q+z*W,D+J*W,d,!0)+2:a.cap==="square"&&(I+=Ha(Q,D,z,J,G,W,!0,d))),d.push(Q-z*G,D-J*G),d.push(Q+z*W,D+J*W);for(let T=1;T<B-1;++T){Q=r[(T-1)*2],D=r[(T-1)*2+1],S=r[T*2],M=r[T*2+1],V=r[(T+1)*2],et=r[(T+1)*2+1],z=-(D-M),J=Q-S,L=Math.sqrt(z*z+J*J),z/=L,J/=L,z*=b,J*=b,$=-(M-et),K=S-V,L=Math.sqrt($*$+K*K),$/=L,K/=L,$*=b,K*=b;const tt=S-Q,k=D-M,P=S-V,q=et-M,Z=tt*P+k*q,nt=k*P-q*tt,X=nt<0;if(Math.abs(nt)<.001*Math.abs(Z)){d.push(S-z*G,M-J*G),d.push(S+z*W,M+J*W),Z>=0&&(a.join==="round"?I+=yA(S,M,S-z*G,M-J*G,S-$*G,M-K*G,d,!1)+4:I+=2,d.push(S-$*W,M-K*W),d.push(S+$*G,M+K*G));continue}const It=(-z+Q)*(-J+M)-(-z+S)*(-J+D),ie=(-$+V)*(-K+M)-(-$+S)*(-K+et),re=(tt*ie-P*It)/nt,Nt=(q*It-k*ie)/nt,ct=(re-S)*(re-S)+(Nt-M)*(Nt-M),yt=S+(re-S)*G,Tt=M+(Nt-M)*G,Jt=S-(re-S)*W,_t=M-(Nt-M)*W,Zt=Math.min(tt*tt+k*k,P*P+q*q),Le=X?G:W,Xr=Zt+Le*Le*y;ct<=Xr?a.join==="bevel"||ct/y>_?(X?(d.push(yt,Tt),d.push(S+z*W,M+J*W),d.push(yt,Tt),d.push(S+$*W,M+K*W)):(d.push(S-z*G,M-J*G),d.push(Jt,_t),d.push(S-$*G,M-K*G),d.push(Jt,_t)),I+=2):a.join==="round"?X?(d.push(yt,Tt),d.push(S+z*W,M+J*W),I+=yA(S,M,S+z*W,M+J*W,S+$*W,M+K*W,d,!0)+4,d.push(yt,Tt),d.push(S+$*W,M+K*W)):(d.push(S-z*G,M-J*G),d.push(Jt,_t),I+=yA(S,M,S-z*G,M-J*G,S-$*G,M-K*G,d,!1)+4,d.push(S-$*G,M-K*G),d.push(Jt,_t)):(d.push(yt,Tt),d.push(Jt,_t)):(d.push(S-z*G,M-J*G),d.push(S+z*W,M+J*W),a.join==="round"?X?I+=yA(S,M,S+z*W,M+J*W,S+$*W,M+K*W,d,!0)+2:I+=yA(S,M,S-z*G,M-J*G,S-$*G,M-K*G,d,!1)+2:a.join==="miter"&&ct/y<=_&&(X?(d.push(Jt,_t),d.push(Jt,_t)):(d.push(yt,Tt),d.push(yt,Tt)),I+=2),d.push(S-$*G,M-K*G),d.push(S+$*W,M+K*W),I+=2)}Q=r[(B-2)*2],D=r[(B-2)*2+1],S=r[(B-1)*2],M=r[(B-1)*2+1],z=-(D-M),J=Q-S,L=Math.sqrt(z*z+J*J),z/=L,J/=L,z*=b,J*=b,d.push(S-z*G,M-J*G),d.push(S+z*W,M+J*W),g||(a.cap==="round"?I+=yA(S-z*(G-W)*.5,M-J*(G-W)*.5,S-z*G,M-J*G,S+z*W,M+J*W,d,!1)+2:a.cap==="square"&&(I+=Ha(S,M,z,J,G,W,!1,d)));const At=Oa*Oa;for(let T=F;T<I+F-2;++T)Q=d[T*2],D=d[T*2+1],S=d[(T+1)*2],M=d[(T+1)*2+1],V=d[(T+2)*2],et=d[(T+2)*2+1],!(Math.abs(Q*(M-et)+S*(et-D)+V*(D-M))<At)&&A.push(T,T+1,T+2);return{vertices:e,indices:A}}function Mg(r){const t=r.length;if(t<6)return 1;let e=0;for(let A=0,i=r[t-2],s=r[t-1];A<t;A+=2){const n=r[A],o=r[A+1];e+=(n-i)*(o+s),i=n,s=o}return e<0?-1:1}function Ha(r,t,e,A,i,s,n,o){const a=r-e*i,l=t-A*i,u=r+e*s,c=t+A*s;let g,f;n?(g=A,f=-e):(g=-A,f=e);const d=a+g,B=l+f,I=u+g,F=c+f;return o.push(d,B),o.push(I,F),2}function yA(r,t,e,A,i,s,n,o){const a=e-r,l=A-t;let u=Math.atan2(a,l),c=Math.atan2(i-r,s-t);o&&u<c?u+=Math.PI*2:!o&&u>c&&(c+=Math.PI*2);let g=u;const f=c-u,d=Math.abs(f),B=Math.sqrt(a*a+l*l),I=(15*d*Math.sqrt(B)/Math.PI>>0)+1,F=f/I;if(g+=F,o){n.push(r,t),n.push(e,A);for(let b=1,y=g;b<I;b++,y+=F)n.push(r,t),n.push(r+Math.sin(y)*B,t+Math.cos(y)*B);n.push(r,t),n.push(i,s)}else{n.push(e,A),n.push(r,t);for(let b=1,y=g;b<I;b++,y+=F)n.push(r+Math.sin(y)*B,t+Math.cos(y)*B),n.push(r,t);n.push(i,s),n.push(r,t)}return I*2}class GA{arcLengthDivision=200;_arcLengths;getPointAt(t,e=new O){return this.getPoint(this.getUToTMapping(t),e)}isClockwise(){const t=this.getPoint(1),e=this.getPoint(.5),A=this.getPoint(1);return(e.x-t.x)*(A.y-e.y)-(e.y-t.y)*(A.x-e.x)<0}getControlPointRefs(){return[]}applyTransform(t){const e=typeof t=="function";return this.getControlPointRefs().forEach(A=>{e?t(A):A.applyMatrix3(t)}),this}getUnevenVertices(t=5,e=[]){const A=new O;for(let i=0,s=Math.max(1,t)-1;i<=s;i++)this.getPoint(i/s,A),e.push(A.x,A.y);return e}getSpacedVertices(t=5,e=[]){const A=new O;for(let i=0,s=Math.max(1,t)-1;i<=s;i++)this.getPointAt(i/s,A),e.push(A.x,A.y);return e}getAdaptiveVertices(t=[]){return this.getUnevenVertices(5,t)}_verticesToPoints(t,e=[]){for(let A=0,i=t.length;A<i;A+=2){const s=t[A],n=t[A+1];e.push(new O(s,n))}return e}getSpacedPoints(t,e=[]){const A=this.getSpacedVertices(t);return this._verticesToPoints(A,e),e}getUnevenPoints(t,e=[]){const A=this.getUnevenVertices(t);return this._verticesToPoints(A,e),e}getAdaptivePoints(t=[]){const e=this.getAdaptiveVertices();return this._verticesToPoints(e,t),t}getPoints(t,e=[]){let A;return t?A=this.getUnevenVertices(t):A=this.getAdaptiveVertices(),this._verticesToPoints(A,e),e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const t=this.arcLengthDivision,e=[0];for(let A=0,i=this.getPoint(0),s=1;s<=t;s++){const n=this.getPoint(s/t);A+=n.distanceTo(i),e.push(A),i=n}this._arcLengths=e}getUToTMapping(t,e){const A=this.getLengths(),i=A.length,s=e??t*A[i-1];if(i<2)return s/A[0];let n=0,o=0,a=i-1,l;for(;o<=a;)if(n=Math.floor(o+(a-o)/2),l=A[n]-s,l<0)o=n+1;else if(l>0)a=n-1;else{a=n;break}if(n=a,A[n]===s)return n/(i-1);const u=A[n],g=A[n+1]-u,f=(s-u)/g;return(n+f)/(i-1)}getTangent(t,e=new O){const i=Math.max(0,t-1e-4),s=Math.min(1,t+1e-4);return e.copy(this.getPoint(s).sub(this.getPoint(i)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new O){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let A=0,i=1,s=(A+i)/2;for(;i-A>e;){s=(A+i)/2;const n=this.getPoint(s);if(n.distanceTo(t)<e)return s;n.x<t.x?A=s:i=s}return s}getMinMax(t=O.MAX,e=O.MIN){const A=this.getPoints();for(let i=0,s=A.length;i<s;i++){const n=A[i];t.min(n),e.max(n)}return{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new ut(t.x,t.y,e.x-t.x,e.y-t.y)}getFillVertices(t){return this.getAdaptiveVertices()}fillTriangulate(t){return La(this.getFillVertices(t),t)}strokeTriangulate(t){return Sg(this.getAdaptiveVertices(),t)}toCommands(){const t=[],e=this.getPoints();for(let A=0,i=e.length;A<i;A++){const s=e[A];A===0?t.push({type:"M",x:s.x,y:s.y}):t.push({type:"L",x:s.x,y:s.y})}return t}toData(){return Zh(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivision=t.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Rg=new Lt,Ja=new Lt,Ka=new Lt,Cr=new O;class zs extends GA{constructor(t=new O,e=new O,A=new O,i=0,s=0,n=Math.PI*2,o=!1){super(),this._center=t,this._radius=e,this._diff=A,this.rotate=i,this.startAngle=s,this.endAngle=n,this.clockwise=o}get cx(){return this._center.x}set cx(t){this._center.x=t}get cy(){return this._center.y}set cy(t){this._center.y=t}get rx(){return this._radius.x}set rx(t){this._radius.x=t}get ry(){return this._radius.y}set ry(t){this._radius.y=t}get dx(){return this._diff.x}set dx(t){this._diff.x=t}get dy(){return this._diff.y}set dy(t){this._diff.y=t}isClockwise(){return this.clockwise}_getDeltaAngle(){const t=Math.PI*2;let e=this.endAngle-this.startAngle;const A=Math.abs(e)<Number.EPSILON;return e=(e%t+t)%t,A?e=0:this.clockwise||(e=e===0?-t:e-t),e}getPoint(t,e=new O){const A=this._getDeltaAngle(),i=this.startAngle+t*A;let s=this.cx+this.rx*Math.cos(i),n=this.cy+this.ry*Math.sin(i);if(this.rotate!==0){const o=Math.cos(this.rotate),a=Math.sin(this.rotate),l=s-this.cx,u=n-this.cy;s=l*o-u*a+this.cx,n=l*a+u*o+this.cy}return e.set(s,n)}toCommands(){const{cx:t,cy:e,rx:A,ry:i,startAngle:s,endAngle:n,clockwise:o,rotate:a}=this,l=t+A*Math.cos(s)*Math.cos(a)-i*Math.sin(s)*Math.sin(a),u=e+A*Math.cos(s)*Math.sin(a)+i*Math.sin(s)*Math.cos(a),c=Math.abs(s-n),g=c>Math.PI?1:0,f=o?1:0,d=a*180/Math.PI;if(c>=2*Math.PI){const B=s+Math.PI,I=t+A*Math.cos(B)*Math.cos(a)-i*Math.sin(B)*Math.sin(a),F=e+A*Math.cos(B)*Math.sin(a)+i*Math.sin(B)*Math.cos(a);return[{type:"M",x:l,y:u},{type:"A",rx:A,ry:i,angle:d,largeArcFlag:0,sweepFlag:f,x:I,y:F},{type:"A",rx:A,ry:i,angle:d,largeArcFlag:0,sweepFlag:f,x:l,y:u}]}else{const B=t+A*Math.cos(n)*Math.cos(a)-i*Math.sin(n)*Math.sin(a),I=e+A*Math.cos(n)*Math.sin(a)+i*Math.sin(n)*Math.cos(a);return[{type:"M",x:l,y:u},{type:"A",rx:A,ry:i,angle:d,largeArcFlag:g,sweepFlag:f,x:B,y:I}]}}drawTo(t){const{cx:e,cy:A,rx:i,ry:s,rotate:n,startAngle:o,endAngle:a,clockwise:l}=this;return t.ellipse(e,A,i,s,n,o,a,!l),this}applyTransform(t){return Cr.set(this.cx,this.cy),Cr.applyMatrix3(t),this.cx=Cr.x,this.cy=Cr.y,Ug(t)?Pg(this,t):kg(this,t),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(t=[]){const{cx:e,cy:A,rx:i,ry:s,dx:n,dy:o,startAngle:a,endAngle:l,clockwise:u,rotate:c}=this,g=!u;let f=Math.abs(a-l);(!g&&a>l||g&&l>a)&&(f=2*Math.PI-f);const d=Math.max(12,Math.floor(12*i**(1/3)*(f/Math.PI)));let B=f/d,I=a;B*=g?-1:1;const F=Math.cos(g?c:-c),b=Math.sin(g?c:-c);for(let y=0;y<d+1;y++){const _=n+Math.cos(I)*i,Q=o+Math.sin(I)*s,D=_*F-Q*b,S=_*b+Q*F;t.push(e+D,A+S),I+=B}return t}_getAdaptiveVerticesByCircle(t=[]){const{cx:e,cy:A,rx:i,ry:s,dx:n,dy:o,rotate:a,clockwise:l}=this;if(!(i>=0&&s>=0&&n>=0&&o>=0))return t;const u=Math.ceil(2.3*Math.sqrt(i+s)),c=u*8+(n?4:0)+(o?4:0),g=[];if(c===0)return t;{const B=g.length;if(u===0)g[B]=g[B+6]=e+n,g[B+1]=g[B+3]=A+o,g[B+2]=g[B+4]=e-n,g[B+5]=g[B+7]=A-o;else{let I=B,F=B+u*4+(n?2:0)+2,b=F,y=c,_=n+i,Q=o,D=e+_,S=e-_,M=A+Q;if(g[I++]=D,g[I++]=M,g[--F]=M,g[--F]=S,o){const et=A-Q;g[b++]=S,g[b++]=et,g[--y]=et,g[--y]=D}for(let et=1;et<u;et++){const z=Math.PI/2*(et/u),J=n+Math.cos(z)*i,$=o+Math.sin(z)*s,K=e+J,L=e-J,it=A+$,G=A-$;g[I++]=K,g[I++]=it,g[--F]=it,g[--F]=L,g[b++]=L,g[b++]=G,g[--y]=G,g[--y]=K}_=n,Q=o+s,D=e+_,S=e-_,M=A+Q;const V=A-Q;g[I++]=D,g[I++]=M,g[--y]=V,g[--y]=D,n&&(g[I++]=S,g[I++]=M,g[--y]=V,g[--y]=S)}}const f=Math.cos(l?-a:a),d=Math.sin(l?-a:a);for(let B=0;B<g.length;B+=2){const I=g[B],F=g[B+1],b=I-e,y=F-A,_=b*f-y*d,Q=b*d+y*f;t.push(e+_,A+Q)}return t}getAdaptiveVertices(t=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(t):this._getAdaptiveVerticesByArc(t)}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.rx=t.rx,this.ry=t.ry,this.dx=t.dx,this.dy=t.dy,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotate=t.rotate,this}}function Pg(r,t){const e=r.rx,A=r.ry,i=Math.cos(r.rotate),s=Math.sin(r.rotate),n=new O(e*i,e*s),o=new O(-A*s,A*i),a=n.applyMatrix3(t),l=o.applyMatrix3(t),u=Rg.set(a.x,l.x,0,a.y,l.y,0,0,0,1),c=Ja.copy(u).invert(),d=Ka.copy(c).transpose().multiply(c).elements,B=Ng(d[0],d[1],d[4]),I=Math.sqrt(B.rt1),F=Math.sqrt(B.rt2);if(r.rx=1/I,r.ry=1/F,r.rotate=Math.atan2(B.sn,B.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const y=Ja.set(I,0,0,0,F,0,0,0,1),_=Ka.set(B.cs,B.sn,0,-B.sn,B.cs,0,0,0,1),Q=y.multiply(_).multiply(u),D=S=>{const{x:M,y:V}=new O(Math.cos(S),Math.sin(S)).applyMatrix3(Q);return Math.atan2(V,M)};r.startAngle=D(r.startAngle),r.endAngle=D(r.endAngle),Ya(t)&&(r.clockwise=!r.clockwise)}}function kg(r,t){const e=Va(t),A=za(t);r.rx*=e,r.ry*=A;const i=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);r.rotate+=i,Ya(t)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function Ya(r){const t=r.elements;return t[0]*t[4]-t[1]*t[3]<0}function Ug(r){const t=r.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const A=Va(r),i=za(r);return Math.abs(e/(A*i))>Number.EPSILON}function Va(r){const t=r.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function za(r){const t=r.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function Ng(r,t,e){let A,i,s,n,o;const a=r+e,l=r-e,u=Math.sqrt(l*l+4*t*t);return a>0?(A=.5*(a+u),o=1/A,i=r*o*e-t*o*t):a<0?i=.5*(a-u):(A=.5*u,i=-.5*u),l>0?s=l+u:s=l-u,Math.abs(s)>2*Math.abs(t)?(o=-2*t/s,n=1/Math.sqrt(1+o*o),s=o*n):Math.abs(t)===0?(s=1,n=0):(o=-.5*s/t,s=1/Math.sqrt(1+o*o),n=o*s),l>0&&(o=s,s=-n,n=o),{rt1:A,rt2:i,cs:s,sn:n}}class Tg extends zs{constructor(t=0,e=0,A=1,i=0,s=Math.PI*2,n=!1){super(new O(t,e),new O(A,A),new O,0,i,s,n)}drawTo(t){const{cx:e,cy:A,rx:i,startAngle:s,endAngle:n,clockwise:o}=this;return t.arc(e,A,i,s,n,!o),this}getAdaptiveVertices(t=[]){const{cx:e,cy:A,rx:i,startAngle:s,endAngle:n,clockwise:o}=this;let a=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(a=2*Math.PI-a);let l=Math.max(6,Math.floor(6*i**(1/3)*(a/Math.PI)));l=Math.max(l,3);let u=a/l,c=s;u*=o?1:-1;for(let g=0;g<l+1;g++){const f=Math.cos(c),d=Math.sin(c),B=e+f*i,I=A+d*i;t.push(B,I),c+=u}return t}}class ze extends GA{constructor(t=new O,e=new O){super(),this.p1=t,this.p2=e}static from(t,e,A,i){return new ze(new O(t,e),new O(A,i))}getPoint(t,e=new O){return t===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(t).add(this.p1),e}getPointAt(t,e=new O){return this.getPoint(t,e)}getTangent(t,e=new O){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(t,e=new O){return this.getTangent(t,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(t=[]){return t.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),t}getMinMax(t=O.MAX,e=O.MIN){const{p1:A,p2:i}=this;return t.x=Math.min(t.x,A.x,i.x),t.y=Math.min(t.y,A.y,i.y),e.x=Math.max(e.x,A.x,i.x),e.y=Math.max(e.y,A.y,i.y),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,p2:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}getFillVertices(t={}){const e=Math.min(this.p1.x,this.p2.x),A=Math.max(this.p1.x,this.p2.x),i=Math.min(this.p1.y,this.p2.y),s=Math.max(this.p1.y,this.p2.y),n=e,o=i,a=A-e||t.style?.strokeWidth||0,l=s-i||t.style?.strokeWidth||0;return[n,o,n+a,o,n+a,o+l,n,o+l]}drawTo(t){const{p1:e,p2:A}=this;return t.lineTo(e.x,e.y),t.lineTo(A.x,A.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.p2.copy(t.p2),this}}class bi extends GA{constructor(t=[]){super(),this.curves=t}getFlatCurves(){return this.curves.flatMap(t=>t instanceof bi?t.getFlatCurves():t)}addCurve(t){return this.curves.push(t),this}getPoint(t,e=new O){const A=t*this.getLength(),i=this.getLengths();let s=0;for(;s<i.length;){if(i[s]>=A){const n=i[s]-A,o=this.curves[s],a=o.getLength();return o.getPointAt(a===0?0:1-n/a,e)}s++}return e}updateLengths(){const t=[];for(let e=0,A=0,i=this.curves.length;e<i;e++)A+=this.curves[e].getLength(),t.push(A);this._arcLengths=t}getControlPointRefs(){return this.curves.flatMap(t=>t.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(t,e){const A=[t[e-1],t[e]],i=[t[e+1],t[e+2]];return A[0]===i[0]&&A[1]===i[1]&&t.splice(e+1,2),t}getSpacedVertices(t=5,e=[]){let A;return this.curves.forEach(i=>{i.getSpacedVertices(t,e),A&&this._removeNextPointIfEqualPrevPoint(e,A),A=e.length-1}),e}getAdaptiveVertices(t=[]){let e;return this.curves.forEach(A=>{A.getAdaptiveVertices(t),e&&this._removeNextPointIfEqualPrevPoint(t,e),e=t.length-1}),t}strokeTriangulate(t){return this.curves.length===1?this.curves[0].strokeTriangulate(t):super.strokeTriangulate(t)}getFillVertices(t){if(this.curves.length===1)return this.curves[0].getFillVertices(t);{const e=[];let A;return this.curves.forEach(i=>{let s;i instanceof ze?s=i.getAdaptiveVertices():s=i.getFillVertices(t),e.push(...s),A&&this._removeNextPointIfEqualPrevPoint(e,A),A=e.length-1}),e}}applyTransform(t){return this.curves.forEach(e=>e.applyTransform(t)),this}getMinMax(t=O.MAX,e=O.MIN){return this.curves.forEach(A=>A.getMinMax(t,e)),{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new ut(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(A=>A.drawTo(t)),this}copy(t){return super.copy(t),this.curves=t.curves.map(e=>e.clone()),this}}class Ws extends GA{constructor(t=new O,e=new O,A=new O,i=new O){super(),this.p1=t,this.cp1=e,this.cp2=A,this.p2=i}static from(t,e,A,i,s,n,o,a){return new Ws(new O(t,e),new O(A,i),new O(s,n),new O(o,a))}getPoint(t,e=new O){const{p1:A,cp1:i,cp2:s,p2:n}=this;return e.set(Ta(t,A.x,i.x,s.x,n.x),Ta(t,A.y,i.y,s.y,n.y))}getAdaptiveVertices(t=[]){return Qg(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,t)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(t,e,A){const i=e*e-4*t*A;if(i<0)return[];const s=Math.sqrt(i),n=(-e+s)/(2*t),o=(-e-s)/(2*t);return[n,o].filter(a=>a>=0&&a<=1)}getMinMax(t=O.MAX,e=O.MIN){const{p1:A,cp1:i,cp2:s,p2:n}=this,o=this._solveQuadratic(3*(i.x-A.x),6*(s.x-i.x),3*(n.x-s.x)),a=this._solveQuadratic(3*(i.y-A.y),6*(s.y-i.y),3*(n.y-s.y)),l=[0,1,...o,...a];return((c,g)=>{for(const f of c)for(let d=0;d<=g;d++){const B=d/g-.5,I=Math.min(1,Math.max(0,f+B)),F=this.getPoint(I);t.x=Math.min(t.x,F.x),t.y=Math.min(t.y,F.y),e.x=Math.max(e.x,F.x),e.y=Math.max(e.y,F.y)}})(l,10),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp1:e,cp2:A,p2:i}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:A.x,y2:A.y,x:i.x,y:i.y}]}drawTo(t){const{p1:e,cp1:A,cp2:i,p2:s}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(A.x,A.y,i.x,i.y,s.x,s.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp1.copy(t.cp1),this.cp2.copy(t.cp2),this.p2.copy(t.p2),this}}class Lg extends zs{constructor(t=0,e=0,A=1,i=1,s=0,n=0,o=Math.PI*2,a=!1){super(new O(t,e),new O(A,i),new O,s,n,o,a)}drawTo(t){return t.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Gg extends bi{}class qs extends GA{constructor(t=new O,e=new O,A=new O){super(),this.p1=t,this.cp=e,this.p2=A}static from(t,e,A,i,s,n){return new qs(new O(t,e),new O(A,i),new O(s,n))}getPoint(t,e=new O){const{p1:A,cp:i,p2:s}=this;return e.set(Ga(t,A.x,i.x,s.x),Ga(t,A.y,i.y,s.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(t=[]){return wg(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,t)}getMinMax(t=O.MAX,e=O.MIN){const{p1:A,cp:i,p2:s}=this,n=.5*(A.x+i.x),o=.5*(A.y+i.y),a=.5*(A.x+s.x),l=.5*(A.y+s.y);return t.x=Math.min(t.x,A.x,s.x,n,a),t.y=Math.min(t.y,A.y,s.y,o,l),e.x=Math.max(e.x,A.x,s.x,n,a),e.y=Math.max(e.y,A.y,s.y,o,l),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp:e,p2:A}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:A.x,y:A.y}]}drawTo(t){const{p1:e,cp:A,p2:i}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(A.x,A.y,i.x,i.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp.copy(t.cp),this.p2.copy(t.p2),this}}class Og extends Gg{constructor(t=0,e=0,A=0,i=0){super(),this.x=t,this.y=e,this.width=A,this.height=i,this.update()}update(){const{x:t,y:e,width:A,height:i}=this,s=[new O(t,e),new O(t+A,e),new O(t+A,e+i),new O(t,e+i)];return this.curves=[new ze(s[0],s[1]),new ze(s[1],s[2]),new ze(s[2],s[3]),new ze(s[3],s[0])],this}drawTo(t){return t.rect(this.x,this.y,this.width,this.height),this}getFillVertices(t={}){const{x:e,y:A,width:i,height:s}=this;return[e,A,e+i,A,e+i,A+s,e,A+s]}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update(),this}}class Hg extends zs{constructor(t=0,e=0,A=1,i=1,s=1){super(),this.x=t,this.y=e,this.width=A,this.height=i,this.radius=s,this.update()}update(){const{x:t,y:e,width:A,height:i,radius:s}=this,n=A/2,o=i/2,a=t+n,l=e+o,u=Math.max(0,Math.min(s,Math.min(n,o))),c=u;return this._center=new O(a,l),this._radius=new O(u,c),this._diff=new O(n-u,o-c),this}drawTo(t){const{x:e,y:A,width:i,height:s,radius:n}=this;return t.roundRect(e,A,i,s,n),this}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.radius=t.radius,this.update(),this}}class Jg extends GA{constructor(t=[]){super(),this.points=t}getPoint(t,e=new O){const{points:A}=this,i=(A.length-1)*t,s=Math.floor(i),n=i-s,o=A[s===0?s:s-1],a=A[s],l=A[s>A.length-2?A.length-1:s+1],u=A[s>A.length-3?A.length-1:s+2];return e.set(Na(n,o.x,a.x,l.x,u.x),Na(n,o.y,a.y,l.y,u.y)),e}getControlPointRefs(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,A=t.points.length;e<A;e++)this.points.push(t.points[e].clone());return this}}class Qr extends bi{startPoint;currentPoint;autoClose=!1;constructor(t){super(),t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,A=t.length;e<A;e++){const{x:i,y:s}=t[e];this.lineTo(i,s)}return this}addCommands(t){return ba(t,this),this}addData(t){return this.addCommands(xa(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,e=[]){return this._closeVertices(super.getUnevenVertices(t,e))}getSpacedVertices(t=40,e=[]){return this._closeVertices(super.getSpacedVertices(t,e))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new O(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const e=t.getPoint(0);(!this.currentPoint||!e.equals(this.currentPoint))&&this.lineTo(e.x,e.y)}return this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;e&&!t.equals(e)&&(this.curves.push(new ze(e.clone(),t.clone())),e.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint=new O(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){const A=this.currentPoint;return A?.equals({x:t,y:e})||this.curves.push(ze.from(A?.x??0,A?.y??0,t,e)),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,A,i,s,n){const o=this.currentPoint;return o?.equals({x:s,y:n})||this.curves.push(Ws.from(o?.x??0,o?.y??0,t,e,A,i,s,n)),this._setCurrentPoint({x:s,y:n}),this}quadraticCurveTo(t,e,A,i){const s=this.currentPoint;return s?.equals({x:A,y:i})||this.curves.push(qs.from(s?.x??0,s?.y??0,t,e,A,i)),this._setCurrentPoint({x:A,y:i}),this}arc(t,e,A,i,s,n){const o=new Tg(t,e,A,i,s,!n);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(t,e,A,i,s,n){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.arc(t,e,A,i,s,n),this}arcTo(t,e,A,i,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,A,i,s,n,o,a=!0){const l=new Lg(t,e,A,i,s,n,o,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,e,A,i,s,n,o,a){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.ellipse(t,e,A,i,s,n,o,a),this}rect(t,e,A,i){const s=new Og(t,e,A,i);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:e}),this}roundRect(t,e,A,i,s){const n=new Hg(t,e,A,i,s);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){const e=this.currentPoint??new O;return this.curves.push(new Jg([e].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(A=>A.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=t.currentPoint?.clone(),this}}function Kg(r){return r.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Yg(r,t,e,A){const i=t.clone().sub(r),s=A.clone().sub(e),n=e.clone().sub(r),o=i.cross(s);if(o===0)return new O((r.x+e.x)/2,(r.y+e.y)/2);const a=n.cross(s)/o;return Math.abs(a)>1?new O((r.x+e.x)/2,(r.y+e.y)/2):new O(r.x+a*i.x,r.y+a*i.y)}class Mt extends bi{currentCurve=new Qr;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(t,e={}){super(),this.curves.push(this.currentCurve),this.style=e,t&&(t instanceof Mt?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}addPath(t){const e=this.curves.findIndex(A=>A===this.currentCurve);return e>-1&&this.curves.splice(e,1),t instanceof Mt?this.curves.push(...t.curves.filter(A=>A.curves.length).map(A=>A.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new Qr().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,e){return this.currentCurve.currentPoint?.equals({x:t,y:e})||(this.currentCurve.curves.length&&(this.currentCurve=new Qr,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,e)),this}lineTo(t,e){return this.currentCurve.lineTo(t,e),this}bezierCurveTo(t,e,A,i,s,n){return this.currentCurve.bezierCurveTo(t,e,A,i,s,n),this}quadraticCurveTo(t,e,A,i){return this.currentCurve.quadraticCurveTo(t,e,A,i),this}arc(t,e,A,i,s,n){return this.currentCurve.arc(t,e,A,i,s,n),this}arcTo(t,e,A,i,s){return this.currentCurve.arcTo(t,e,A,i,s),this}ellipse(t,e,A,i,s,n,o,a){return this.currentCurve.ellipse(t,e,A,i,s,n,o,a),this}rect(t,e,A,i){return this.currentCurve.rect(t,e,A,i),this}roundRect(t,e,A,i,s){return this.currentCurve.roundRect(t,e,A,i,s),this}reset(){return this.currentCurve=new Qr,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return ba(t,this),this}addData(t){return this.addCommands(xa(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,e=t,A={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.scale(t,e,A)}),this}skew(t,e=0,A={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.skew(t,e,A)}),this}rotate(t,e={x:0,y:0}){return this.getControlPointRefs().forEach(A=>{A.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getFlatCurves(),A=[],i=[],s=[];e.forEach((o,a)=>{const l=o.getControlPointRefs(),u=o.isClockwise();s[a]=l,i[a]=u;const c=l[0],g=l[l.length-1]??c;A.push({start:u?g:c,end:u?c:g,index:a})});const n=[];return A.forEach((o,a)=>{n[a]=[],A.forEach((l,u)=>{l.start&&o.end&&u!==a&&l.start?.equals(o.end)&&n[a].push(l.index)})}),e.forEach((o,a)=>{const l=i[a];s[a].forEach(u=>{u.add(o.getNormal(o.getTForPoint(u)).scale(l?t:-t))})}),n.forEach((o,a)=>{const l=s[a];o.forEach(u=>{const c=s[u],g=Yg(l[l.length-1],l[l.length-2]??l[l.length-1],c[0],c[1]??c[0]);g&&(l[l.length-1].copy(g),c[0].copy(g))})}),this}getMinMax(t=O.MAX,e=O.MIN,A=!0){const i=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,e),A&&i>1){const n=i/2,o=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const u=s.getPoint(l),c=s.getNormal(l),g=c.clone().scale(o?n:-n),f=c.clone().scale(o?-n:n);a.push(u.clone().add(g),u.clone().add(f),u.clone().add({x:n,y:0}),u.clone().add({x:-n,y:0}),u.clone().add({x:0,y:n}),u.clone().add({x:0,y:-n}),u.clone().add({x:n,y:n}),u.clone().add({x:-n,y:-n}))}t.min(...a),e.max(...a)}}),{min:t.finite(),max:e.finite()}}strokeTriangulate(t){const e=t?.indices??[],A=t?.vertices??[];return this.curves.forEach(i=>{i.strokeTriangulate({...t,indices:e,vertices:A,style:{...this.style}})}),{indices:e,vertices:A}}fillTriangulate(t){const e={...t,style:{...this.style,...t?.style}},A=e.indices??[],i=e.vertices??[];if((e.style.fillRule??"nonzero")==="nonzero"){const n=this.curves.map(l=>l.getFillVertices(e)),o=new Map,a=new Set;for(let l=0;l<n.length;l++){const u=[];for(let c=0;c<n.length;c++)l!==c&&vg([n[l][0],n[l][1]],n[c])&&u.push(c);u.length&&(u.forEach(c=>{let g=o.get(c);g||(g=new Set,o.set(c,g)),g.add(l)}),a.add(l))}n.forEach((l,u)=>{if(a.has(u)||!l.length)return;const c=l.slice(),g=[];o.get(u)?.forEach(f=>{g.push(c.length/2),c.push(...n[f])}),La(c,{...t,indices:A,vertices:i,holes:g,style:{...this.style}})})}else this.curves.forEach(n=>{n.fillTriangulate({...t,indices:A,vertices:i,style:{...this.style}})});return{indices:A,vertices:i}}getBoundingBox(t=!0){const{min:e,max:A}=this.getMinMax(void 0,void 0,t);return new ut(e.x,e.y,A.x-e.x,A.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:A="#000",stroke:i="none"}=e;return t.beginPath(),t.save(),Gs(t,e),this.curves.forEach(s=>{s.drawTo(t)}),A!=="none"&&t.fill(),i!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:A="#000",stroke:i="none"}=e;return t.beginPath(),t.save(),Gs(t,e),this.getControlPointRefs().forEach(s=>{qh(t,s.x,s.y,{radius:4})}),A!=="none"&&t.fill(),i!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const i in t)t[i]!==void 0&&(e[Kg(i)]=t[i]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let A="";for(const i in e)e[i]!==void 0&&(A+=`${i}:${e[i]};`);return`<path d="${this.toData()}" style="${A}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class iA{constructor(t=[],e){this.paths=t,this.viewBox=e}getBoundingBox(t=!0){if(!this.paths.length)return;const e=O.MAX,A=O.MIN;return this.paths.forEach(i=>i.getMinMax(e,A,t)),new ut(e.x,e.y,A.x-e.x,A.y-e.y)}toTriangulatedSvgString(t=this.paths.map(A=>A.fillTriangulate()),e=0){let A="";const i={x:-e,y:-e},s={x:e,y:e};(Array.isArray(t)?t:[t]).forEach(({vertices:a,indices:l})=>{const u=c=>{const g=a[c*2],f=a[c*2+1];return i.x=Math.min(i.x,g+e),s.x=Math.max(s.x,g+e),i.y=Math.min(i.y,f+e),s.y=Math.max(s.y,f+e),[g,f]};for(let c=0,g=l.length;c<g;c+=3){const f=u(l[c]),d=u(l[c+1]),B=u(l[c+2]);A+=`<polygon points="${f.join(",")} ${d.join(",")} ${B.join(",")}" fill="black" />`}});const o=[i.x,i.y,s.x-i.x,s.y-i.y];return`<svg width="${o[2]}" height="${o[3]}" viewBox="${o.join(" ")}" xmlns="http://www.w3.org/2000/svg">${A}</svg>`}toTriangulatedSvg(t,e){return new DOMParser().parseFromString(this.toTriangulatedSvgString(t,e),"image/svg+xml").documentElement}toSvgString(){const{x:t,y:e,width:A,height:i}=this.getBoundingBox(),s=this.paths.map(n=>n.toSvgPathString()).join("");return`<svg viewBox="${t} ${e} ${A} ${i}" width="${A}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...A}=t,{left:i,top:s,width:n,height:o}=this.getBoundingBox(),a=document.createElement("canvas");a.width=n*e,a.height=o*e,a.style.width=`${n}px`,a.style.height=`${o}px`;const l=a.getContext("2d");return l&&(l.scale(e,e),l.translate(-i,-s),this.paths.forEach(u=>{u.drawTo(l,A)})),a}}class Wa extends Mt{fillStyle;strokeStyle;lineCap;lineJoin;lineWidth;miterLimit;uvTransform;vertTransform;_defaultStyle=Dt.EMPTY;_draws=[];_toTexture(t){return t instanceof Dt?t:ca.get(t)}stroke(t){const e=new Mt(this);let A=this._defaultStyle;this.strokeStyle&&(A=this._toTexture(this.strokeStyle)),this.curves.length&&(this._draws.push({...t,type:"stroke",path:e,texture:A,uvTransform:this.uvTransform,vertTransform:this.vertTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),super.reset())}fillRect(t,e,A,i){this.rect(t,e,A,i).fill()}strokeRect(t,e,A,i){this.rect(t,e,A,i).stroke()}fill(t){const e=new Mt(this);let A=this._defaultStyle;this.fillStyle&&(A=this._toTexture(this.fillStyle)),this._draws.push({...t,type:"fill",path:e,texture:A,uvTransform:this.uvTransform,vertTransform:this.vertTransform}),super.reset()}copy(t){return super.copy(t),this.strokeStyle=t.strokeStyle,this.fillStyle=t.fillStyle,this.uvTransform=t.uvTransform,this.vertTransform=t.vertTransform,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this._draws=t._draws.slice(),this}reset(){return super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.uvTransform=void 0,this.vertTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._draws.length=0,this}buildUvs(t,e,A,i,s){if(i){const n=s&&(typeof s=="function"?s:(l,u)=>s.applyToPoint(l,u)),o=i.width,a=i.height;for(let l=e.length,u=t;u<l;u+=2){const c=e[u],g=e[u+1];let f,d;n?[f,d]=n(c,g):[f,d]=[c/o,g/a],A.push(f,d)}}else for(let n=e.length,o=t;o<n;o+=2)A.push(0,0)}toBatchables(){const t=[];for(let e=this._draws.length,A=0;A<e;A++){const i=this._draws[A],s=[],n=[],o=[];i.type==="fill"?i.path.fillTriangulate({vertices:s,indices:n}):i.path.strokeTriangulate({vertices:s,indices:n,lineStyle:i.style,flipAlignment:!1,closed:!0}),this.buildUvs(0,s,o,i.texture,i.uvTransform),t.push({vertices:s,indices:n,uvs:o,texture:i.texture,type:i.type,disableWrapMode:i.disableWrapMode,vertTransform:i.vertTransform})}return t}}var Vg=Object.defineProperty,zg=Object.getOwnPropertyDescriptor,xi=(r,t,e,A)=>{for(var i=A>1?void 0:A?zg(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&Vg(t,e,i),i};h.CanvasItem=class extends h.TimelineNode{_parentGlobalVisible;_globalVisible;get globalVisible(){return this._globalVisible??!0}_parentGlobalOpacity;_globalOpacity;get globalOpacity(){return this._globalOpacity??1}_modulate=new ve(4294967295);context=new Wa;_resetContext=!0;_redrawing=!0;_relayouting=!1;_repainting=!1;_originalBatchables=[];_layoutedBatchables=[];_batchables=[];constructor(t,e=[]){super(),this.setProperties(t).append(e)}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"modulate":this._modulate.value=e,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestRelayout(){this._relayouting=!0}requestRepaint(){this._repainting=!0}_updateGlobalVisible(){this._parentGlobalVisible=this.getParent()?.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){this._parentGlobalOpacity=this.getParent()?.opacity;const t=Ke(0,this.opacity,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==t&&(this._globalOpacity=t,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){return this.log(this.name,"drawing"),this._draw(),this.context.toBatchables()}_relayout(t){return this.log(this.name,"layouting"),t}_repaint(t){return this.log(this.name,"painting"),t.map(e=>({...e,modulate:this._modulate.toArgb(this.globalOpacity,!0),blendMode:this.blendMode}))}_process(t){super._process(t);const e=this.getParent();this._parentGlobalVisible!==e?.globalVisible&&this._updateGlobalVisible(),this._parentGlobalOpacity!==e?.globalOpacity&&this._updateGlobalOpacity()}_updateBatchables(){const t=this._redrawing;let e=this._relayouting,A=this._repainting,i;t&&(this._originalBatchables=this._redraw(),e=!0),e&&(this._layoutedBatchables=this._relayout(this._originalBatchables),A=!0),A&&(i=this._repaint(this._layoutedBatchables)),t&&this._resetContext&&this.context.reset(),i&&(this._batchables=i,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(t){this._updateBatchables(),this._batchables.forEach(e=>{e.texture?.upload(t),t.batch2D.render({...e,texture:e.texture?._glTexture(t)})}),super._render(t)}},xi([w()],h.CanvasItem.prototype,"modulate",2),xi([w()],h.CanvasItem.prototype,"blendMode",2),xi([w({protected:!0,fallback:!0})],h.CanvasItem.prototype,"visible",2),xi([w({protected:!0,fallback:1})],h.CanvasItem.prototype,"opacity",2),h.CanvasItem=xi([st("CanvasItem")],h.CanvasItem);class Wg{currentCall;calls=[];createCall(t){return{renderable:t,parentCall:this.currentCall,fn:t.render.bind(t),calls:[]}}push(t){const e=this.createCall(t);return(this.currentCall?.calls??this.calls).push(e),e}render(t){this.calls.forEach(function e(A){A.fn(t,()=>{A.calls.forEach(e)})}),this.calls=[]}}var qg=Object.defineProperty,Xg=Object.getOwnPropertyDescriptor,Fi=(r,t,e,A)=>{for(var i=A>1?void 0:A?Xg(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&qg(t,e,i),i};h.Timeline=class extends h.Node{static from(t,e=!1){const[A,i]=t?Array.isArray(t)?t:[0,t]:[];return new h.Timeline({startTime:A,endTime:i,loop:e})}constructor(t){super(),this.setProperties(t)}_updateProperty(t,e,A){switch(super._updateProperty(t,e,A),t){case"startTime":this.startTime=Math.min(e,this.endTime);break;case"endTime":this.endTime=e||Number.MAX_SAFE_INTEGER;break}}addTime(t){const e=this.startTime,A=this.endTime;let i=this.currentTime;return i=i+t,this.loop&&i>A&&(i=e+i%A),i=Ke(e,i,A),this.currentTime=i,this.emit("updateCurrentTime",i,t),this}_process(t){super._process(t),this.addTime(t)}},Fi([w({fallback:0})],h.Timeline.prototype,"startTime",2),Fi([w({fallback:0})],h.Timeline.prototype,"currentTime",2),Fi([w({fallback:Number.MAX_SAFE_INTEGER})],h.Timeline.prototype,"endTime",2),Fi([w({fallback:!1})],h.Timeline.prototype,"loop",2),h.Timeline=Fi([st("Timeline")],h.Timeline);var jg=Object.defineProperty,Xs=(r,t,e,A)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(t,e,i)||i);return i&&jg(t,e,i),i};class Si extends hr{input=new No;renderStack=new Wg;root=new h.Viewport(!0).setTree(this);timeline;nodes=new Map;_backgroundColor=new ve;_currentViewport;getCurrentViewport(){return this._currentViewport}setCurrentViewport(t){this._currentViewport=t}constructor(t=new h.Timeline){super(),this.timeline=t.setTree(this)}_updateProperty(t,e,A,i){switch(super._updateProperty(t,e,A,i),t){case"backgroundColor":this._backgroundColor.value=e;break}}log(...t){this.debug&&console.log(`[modern-canvas][${performance.now().toFixed(4)}ms]`,...t)}_process(t=0){this.timeline.emit("process",t),this.emit("processing"),this.root.emit("process",t),this.emit("processed")}_render(t){this.emit("rendering"),t.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(t),this._renderScreen(t),this.emit("rendered")}_renderScreen(t){t.state.reset(),t.framebuffer.bind(null),t.viewport.bind({x:0,y:0,width:this.root.width*t.pixelRatio,height:this.root.height*t.pixelRatio}),this.backgroundColor&&t.gl.clearColor(...this._backgroundColor.toArray()),t.clear(),this.backgroundColor&&t.gl.clearColor(0,0,0,0);const e=this.root.texture;e.activate(t,0),gt.draw(t),t.texture.unbind(e)}free(){super.free(),this.root.children.internal.forEach(t=>this.root.removeChild(t)),this.input.removeEventListeners()}}Xs([w({fallback:!1})],Si.prototype,"processPaused"),Xs([w()],Si.prototype,"backgroundColor"),Xs([w({protected:!0,fallback:!1})],Si.prototype,"debug");var Zg=Object.getOwnPropertyDescriptor,$g=(r,t,e,A)=>{for(var i=A>1?void 0:A?Zg(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};h.Transition=class extends h.Effect{constructor(t,e=[]){super(),this.setProperties(t).append(e)}},h.Transition=$g([st("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],h.Transition);var qa=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,ef=(r,t,e)=>t in r?qa(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,js=(r,t,e,A)=>{for(var i=A>1?void 0:A?tf(t,e):t,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(A?n(t,e,i):n(i))||i);return A&&i&&qa(t,e,i),i},Xa=(r,t,e)=>ef(r,typeof t!="symbol"?t+"":t,e);const ja=`varying vec2 vUv[9];
278
278
  uniform sampler2D sampler;
279
279
 
280
280
  void main(void) {
package/dist/index.mjs CHANGED
@@ -5770,9 +5770,6 @@ let Node = class extends CoreObject {
5770
5770
  return false;
5771
5771
  }
5772
5772
  }
5773
- _update(changed) {
5774
- super._update(changed);
5775
- }
5776
5773
  _updateProperty(key, value, oldValue, declaration) {
5777
5774
  super._updateProperty(key, value, oldValue, declaration);
5778
5775
  }
@@ -7297,15 +7294,12 @@ let CanvasItem = class extends TimelineNode {
7297
7294
  }
7298
7295
  requestRedraw() {
7299
7296
  this._redrawing = true;
7300
- this.requestUpdate();
7301
7297
  }
7302
7298
  requestRelayout() {
7303
7299
  this._relayouting = true;
7304
- this.requestUpdate();
7305
7300
  }
7306
7301
  requestRepaint() {
7307
7302
  this._repainting = true;
7308
- this.requestUpdate();
7309
7303
  }
7310
7304
  _updateGlobalVisible() {
7311
7305
  this._parentGlobalVisible = this.getParent()?.globalVisible;
@@ -7344,22 +7338,14 @@ let CanvasItem = class extends TimelineNode {
7344
7338
  _process(delta) {
7345
7339
  super._process(delta);
7346
7340
  const parent = this.getParent();
7347
- if (this._parentGlobalVisible !== parent?.globalVisible) {
7348
- this.requestUpdate();
7349
- }
7350
- if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7351
- this.requestUpdate();
7352
- }
7353
- }
7354
- _update(changed) {
7355
- super._update(changed);
7356
- const parent = this.getParent();
7357
7341
  if (this._parentGlobalVisible !== parent?.globalVisible) {
7358
7342
  this._updateGlobalVisible();
7359
7343
  }
7360
7344
  if (this._parentGlobalOpacity !== parent?.globalOpacity) {
7361
7345
  this._updateGlobalOpacity();
7362
7346
  }
7347
+ }
7348
+ _updateBatchables() {
7363
7349
  const redrawing = this._redrawing;
7364
7350
  let relayouting = this._relayouting;
7365
7351
  let repainting = this._repainting;
@@ -7388,6 +7374,7 @@ let CanvasItem = class extends TimelineNode {
7388
7374
  }
7389
7375
  }
7390
7376
  _render(renderer) {
7377
+ this._updateBatchables();
7391
7378
  this._batchables.forEach((batchable) => {
7392
7379
  batchable.texture?.upload(renderer);
7393
7380
  renderer.batch2D.render({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.6.8",
4
+ "version": "0.6.9",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",